Skip to content

armgit / anime

Public Imported from GitHub
0

JavaScript animation engine

Build 4.3.0-beta.0

Julian Garnierc1d7f91f4e8c
diff --git a/dist/bundles/anime.esm.js b/dist/bundles/anime.esm.js
index bcb2acd4..84ea8312 100644
--- a/dist/bundles/anime.esm.js
+++ b/dist/bundles/anime.esm.js
@@ -1,6 +1,6 @@
/**
* Anime.js - ESM bundle
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -37,7 +37,7 @@
/** @typedef {JSAnimation|Timeline} Renderable */
/** @typedef {Timer|Renderable} Tickable */
/** @typedef {Timer&JSAnimation&Timeline} CallbackArgument */
-/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope} Revertible */
+/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope|AutoLayout} Revertible */
// Stagger types
@@ -361,6 +361,7 @@
* @typedef {Object} TimelineOptions
* @property {DefaultsParams} [defaults]
* @property {EasingParam} [playbackEase]
+ * @property {Boolean} [composition]
*/
/**
@@ -638,8 +639,10 @@
// TODO: Do we need to check if we're running inside a worker ?
const isBrowser = typeof window !== 'undefined';
-/** @type {Window & {AnimeJS: Array}|null} */
-const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
+/** @typedef {Window & {AnimeJS: Array} & {AnimeJSDevTools: any}|null} AnimeJSWindow
+
+/** @type {AnimeJSWindow} */
+const win = isBrowser ? /** @type {AnimeJSWindow} */(/** @type {unknown} */(window)) : null;
/** @type {Document|null} */
const doc = isBrowser ? document : null;
@@ -691,7 +694,7 @@ const proxyTargetSymbol = Symbol();
const minValue = 1e-11;
const maxValue = 1e12;
const K = 1e3;
-const maxFps = 120;
+const maxFps = 240;
// Strings
@@ -796,7 +799,9 @@ const globals = {
tickThreshold: 200,
};
-const globalVersions = { version: '4.2.2', engine: null };
+const devTools = isBrowser && win.AnimeJSDevTools;
+
+const globalVersions = { version: '4.3.0-beta.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
@@ -1826,7 +1831,7 @@ class Clock {
/** @type {Number} */
this._currentTime = initTime;
/** @type {Number} */
- this._elapsedTime = initTime;
+ this._lastTickTime = initTime;
/** @type {Number} */
this._startTime = initTime;
/** @type {Number} */
@@ -1834,7 +1839,7 @@ class Clock {
/** @type {Number} */
this._scheduledTime = 0;
/** @type {Number} */
- this._frameDuration = round$1(K / maxFps, 0);
+ this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
/** @type {Number} */
@@ -1855,7 +1860,8 @@ class Clock {
const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
- const frameDuration = round$1(K / fps, 0);
+ const frameDuration = K / fps;
+ if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
this._scheduledTime += frameDuration - previousFrameDuration;
@@ -1876,14 +1882,13 @@ class Clock {
*/
requestTick(time) {
const scheduledTime = this._scheduledTime;
- const elapsedTime = this._elapsedTime;
- this._elapsedTime += (time - elapsedTime);
- // If the elapsed time is lower than the scheduled time
+ this._lastTickTime = time;
+ // If the current time is lower than the scheduled time
// this means not enough time has passed to hit one frameDuration
// so skip that frame
- if (elapsedTime < scheduledTime) return tickModes.NONE;
+ if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = elapsedTime - scheduledTime;
+ const frameDelta = time - scheduledTime;
// Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
// Skips ahead if the actual elapsed time is higher.
this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
@@ -2020,7 +2025,7 @@ class Engine extends Clock {
wake() {
if (this.useDefaultMainLoop && !this.reqId) {
- // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
+ // Imediatly request a tick to update engine._lastTickTime and get accurate offsetPosition calculation in timer.js
this.requestTick(now());
this.reqId = engineTickMethod(tickEngine);
}
@@ -2508,6 +2513,8 @@ class Timer extends Clock {
super(0);
+ ++timerId;
+
const {
id,
delay,
@@ -2529,31 +2536,42 @@ class Timer extends Clock {
if (scope.current) scope.current.register(this);
- const timerInitTime = parent ? 0 : engine._elapsedTime;
+ const timerInitTime = parent ? 0 : engine._lastTickTime;
const timerDefaults = parent ? parent.defaults : globals.defaults;
const timerDelay = /** @type {Number} */(isFnc(delay) || isUnd(delay) ? timerDefaults.delay : +delay);
const timerDuration = isFnc(duration) || isUnd(duration) ? Infinity : +duration;
const timerLoop = setValue(loop, timerDefaults.loop);
const timerLoopDelay = setValue(loopDelay, timerDefaults.loopDelay);
- const timerIterationCount = timerLoop === true ||
- timerLoop === Infinity ||
- /** @type {Number} */(timerLoop) < 0 ? Infinity :
- /** @type {Number} */(timerLoop) + 1;
+ let timerIterationCount = timerLoop === true ||
+ timerLoop === Infinity ||
+ /** @type {Number} */(timerLoop) < 0 ? Infinity :
+ /** @type {Number} */(timerLoop) + 1;
+
+ if (devTools) {
+ const isInfinite = timerIterationCount === Infinity;
+ const registered = devTools.register(this, parameters, isInfinite);
+ if (registered && isInfinite) {
+ const minIterations = alternate ? 2 : 1;
+ const iterations = parent ? devTools.maxNestedInfiniteLoops : devTools.maxInfiniteLoops;
+ timerIterationCount = Math.max(iterations, minIterations);
+ }
+ }
let offsetPosition = 0;
if (parent) {
offsetPosition = parentPosition;
} else {
- // Make sure to tick the engine once if not currently running to get up to date engine._elapsedTime
+ // Make sure to tick the engine once if not currently running to get up to date engine._lastTickTime
// to avoid big gaps with the following offsetPosition calculation
if (!engine.reqId) engine.requestTick(now());
// Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
- offsetPosition = (engine._elapsedTime - engine._startTime) * globals.timeScale;
+ offsetPosition = (engine._lastTickTime - engine._startTime) * globals.timeScale;
}
// Timer's parameters
- this.id = !isUnd(id) ? id : ++timerId;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : timerId;
/** @type {Timeline} */
this.parent = parent;
// Total duration of the timer
@@ -2613,7 +2631,7 @@ class Timer extends Clock {
// Clock's parameters
/** @type {Number} */
- this._elapsedTime = timerInitTime;
+ this._lastTickTime = timerInitTime;
/** @type {Number} */
this._startTime = timerInitTime;
/** @type {Number} */
@@ -2644,7 +2662,7 @@ class Timer extends Clock {
}
get iterationCurrentTime() {
- return round$1(this._iterationTime, globals.precision);
+ return clamp$1(round$1(this._iterationTime, globals.precision), 0, this.iterationDuration);
}
set iterationCurrentTime(time) {
@@ -2742,9 +2760,9 @@ class Timer extends Clock {
/** @return {this} */
resetTime() {
const timeScale = 1 / (this._speed * engine._speed);
- // TODO: See if we can safely use engine._elapsedTime here
+ // TODO: See if we can safely use engine._lastTickTime here
// if (!engine.reqId) engine.requestTick(now())
- // this._startTime = engine._elapsedTime - (this._currentTime + this._delay) * timeScale;
+ // this._startTime = engine._lastTickTime - (this._currentTime + this._delay) * timeScale;
this._startTime = now() - (this._currentTime + this._delay) * timeScale;
return this;
}
@@ -3258,6 +3276,7 @@ const fastSetValuesArray = [null, null];
const keyObjectTarget = { to: null };
let tweenId = 0;
+let JSAnimationId = 0;
let keyframes;
/** @type {TweenParamsOptions & TweenValues} */
let key;
@@ -3372,6 +3391,8 @@ class JSAnimation extends Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ ++JSAnimationId;
+
const parsedTargets = registerTargets(targets);
const targetsLength = parsedTargets.length;
@@ -3381,6 +3402,7 @@ class JSAnimation extends Timer {
const params = /** @type {AnimationParams} */(kfParams ? mergeObjects(generateKeyframes(/** @type {DurationKeyframes} */(kfParams), parameters), parameters) : parameters);
const {
+ id,
delay,
duration,
ease,
@@ -3391,11 +3413,12 @@ class JSAnimation extends Timer {
} = params;
const animDefaults = parent ? parent.defaults : globals.defaults;
- const animaPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
- const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
- const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
+ const animEase = setValue(ease, animDefaults.ease);
+ const animPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
+ const parsedAnimPlaybackEase = animPlaybackEase ? parseEase(animPlaybackEase) : null;
+ const hasSpring = !isUnd(/** @type {Spring} */(animEase).ease);
+ const tEasing = hasSpring ? /** @type {Spring} */(animEase).ease : setValue(ease, parsedAnimPlaybackEase ? 'linear' : animDefaults.ease);
+ const tDuration = hasSpring ? /** @type {Spring} */(animEase).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
@@ -3403,7 +3426,7 @@ class JSAnimation extends Timer {
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
// This allows targeting the current animation in the spring onComplete callback
- if (hasSpring) /** @type {Spring} */(ease).parent = this;
+ if (hasSpring) /** @type {Spring} */(animEase).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -3547,6 +3570,8 @@ class JSAnimation extends Timer {
if (isFromToValue) {
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[0], target, ti, tl) : tweenFromValue, fromTargetObject);
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[1], target, ti, tl, toFunctionStore) : tweenToValue, toTargetObject);
+ // Needed to force an inline style registration
+ const originalValue = getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore);
if (fromTargetObject.t === valueTypes.NUMBER) {
if (prevSibling) {
if (prevSibling._valueType === valueTypes.UNIT) {
@@ -3555,7 +3580,7 @@ class JSAnimation extends Timer {
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
+ originalValue,
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -3774,12 +3799,14 @@ class JSAnimation extends Timer {
}
/** @type {TargetsArray} */
this.targets = parsedTargets;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : JSAnimationId;
/** @type {Number} */
this.duration = iterationDuration === minValue ? minValue : clampInfinity(((iterationDuration + this._loopDelay) * this.iterationCount) - this._loopDelay) || minValue;
/** @type {Callback<this>} */
this.onRender = onRender || animDefaults.onRender;
/** @type {EasingFunction} */
- this._ease = animEase;
+ this._ease = parsedAnimPlaybackEase;
/** @type {Number} */
this._delay = iterationDelay;
// NOTE: I'm keeping delay values separated from offsets in timelines because delays can override previous tweens and it could be confusing to debug a timeline with overridden tweens and no associated visible delays.
@@ -4117,11 +4144,11 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
const isSetter = isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= minValue;
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
const adjustedPosition = isSetter ? timePosition - minValue : timePosition;
- tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
+ if (tl.composition) tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
const tlChild = targets ?
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
- tlChild.init(true);
+ if (tl.composition) tlChild.init(true);
// TODO: Might be better to insert at a position relative to startTime?
addChild(tl, tlChild);
forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -4133,6 +4160,8 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
return tl;
}
+let TLId = 0;
+
class Timeline extends Timer {
/**
@@ -4140,6 +4169,9 @@ class Timeline extends Timer {
*/
constructor(parameters = {}) {
super(/** @type {TimerParams&TimelineParams} */(parameters), null, 0);
+ ++TLId;
+ /** @type {String|Number} */
+ this.id = !isUnd(parameters.id) ? parameters.id : TLId;
/** @type {Number} */
this.duration = 0; // TL duration starts at 0 and grows when adding children
/** @type {Record<String, Number>} */
@@ -4148,6 +4180,8 @@ class Timeline extends Timer {
const globalDefaults = globals.defaults;
/** @type {DefaultsParams} */
this.defaults = defaultsParams ? mergeObjects(defaultsParams, globalDefaults) : globalDefaults;
+ /** @type {Boolean} */
+ this.composition = setValue(parameters.composition, true);
/** @type {Callback<this>} */
this.onRender = parameters.onRender || globalDefaults.onRender;
const tlPlaybackEase = setValue(parameters.playbackEase, globalDefaults.playbackEase);
@@ -4225,7 +4259,8 @@ class Timeline extends Timer {
parseTimelinePosition(this,a2),
);
}
- return this.init(true);
+ if (this.composition) this.init(true);
+ return this;
}
}
@@ -4252,7 +4287,7 @@ class Timeline extends Timer {
if (isUnd(synced) || synced && isUnd(synced.pause)) return this;
synced.pause();
const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
- return this.add(synced, { currentTime: [0, duration], duration, ease: 'linear' }, position);
+ return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
}
/**
@@ -4275,7 +4310,7 @@ class Timeline extends Timer {
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
- return this.add({ duration: 0, onComplete: () => callback(this) }, position);
+ return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
/**
@@ -7281,1517 +7316,2884 @@ var index$3 = /*#__PURE__*/Object.freeze({
steps: steps
});
-// Chain-able utilities
-const numberUtils = numberImports; // Needed to keep the import when bundling
-const chainables = {};
-/**
- * @callback UtilityFunction
- * @param {...*} args
- * @return {Number|String}
- *
- * @param {UtilityFunction} fn
- * @param {Number} [last=0]
- * @return {function(...(Number|String)): function(Number|String): (Number|String)}
- */
-const curry = (fn, last = 0) => (...args) => last ? v => fn(...args, v) : v => fn(v, ...args);
-/**
- * @param {Function} fn
- * @return {function(...(Number|String))}
- */
-const chain = fn => {
- return (...args) => {
- const result = fn(...args);
- return new Proxy(noop, {
- apply: (_, __, [v]) => result(v),
- get: (_, prop) => chain(/**@param {...Number|String} nextArgs */(...nextArgs) => {
- const nextResult = chainables[prop](...nextArgs);
- return (/**@type {Number|String} */v) => nextResult(result(v));
- })
- });
- }
-};
-/**
- * @param {UtilityFunction} fn
- * @param {String} name
- * @param {Number} [right]
- * @return {function(...(Number|String)): UtilityFunction}
- */
-const makeChainable = (name, fn, right = 0) => {
- const chained = (...args) => (args.length < fn.length ? chain(curry(fn, right)) : fn)(...args);
- if (!chainables[name]) chainables[name] = chained;
- return chained;
-};
/**
- * @typedef {Object} ChainablesMap
- * @property {ChainedClamp} clamp
- * @property {ChainedRound} round
- * @property {ChainedSnap} snap
- * @property {ChainedWrap} wrap
- * @property {ChainedLerp} lerp
- * @property {ChainedDamp} damp
- * @property {ChainedMapRange} mapRange
- * @property {ChainedRoundPad} roundPad
- * @property {ChainedPadStart} padStart
- * @property {ChainedPadEnd} padEnd
- * @property {ChainedDegToRad} degToRad
- * @property {ChainedRadToDeg} radToDeg
+ * Converts an easing function into a valid CSS linear() timing function string
+ * @param {EasingFunction} fn
+ * @param {number} [samples=100]
+ * @returns {string} CSS linear() timing function
*/
+const easingToLinear = (fn, samples = 100) => {
+ const points = [];
+ for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
+ return `linear(${points.join(', ')})`;
+};
-/**
- * @callback ChainedUtilsResult
- * @param {Number} value - The value to process through the chained operations
- * @return {Number} The processed result
- */
+const WAAPIEasesLookups = {};
/**
- * @typedef {ChainablesMap & ChainedUtilsResult} ChainableUtil
+ * @param {EasingParam} ease
+ * @return {String}
*/
+const parseWAAPIEasing = (ease) => {
+ let parsedEase = WAAPIEasesLookups[ease];
+ if (parsedEase) return parsedEase;
+ parsedEase = 'linear';
+ if (isStr(ease)) {
+ if (
+ stringStartsWith(ease, 'linear') ||
+ stringStartsWith(ease, 'cubic-') ||
+ stringStartsWith(ease, 'steps') ||
+ stringStartsWith(ease, 'ease')
+ ) {
+ parsedEase = ease;
+ } else if (stringStartsWith(ease, 'cubicB')) {
+ parsedEase = toLowerCase(ease);
+ } else {
+ const parsed = parseEaseString(ease);
+ if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
+ }
+ // Only cache string based easing name, otherwise function arguments get lost
+ WAAPIEasesLookups[ease] = parsedEase;
+ } else if (isFnc(ease)) {
+ const easing = easingToLinear(ease);
+ if (easing) parsedEase = easing;
+ } else if (/** @type {Spring} */(ease).ease) {
+ parsedEase = easingToLinear(/** @type {Spring} */(ease).ease);
+ }
+ return parsedEase;
+};
-// Chainable
+const transformsShorthands = ['x', 'y', 'z'];
+const commonDefaultPXProperties = [
+ 'perspective',
+ 'width',
+ 'height',
+ 'margin',
+ 'padding',
+ 'top',
+ 'right',
+ 'bottom',
+ 'left',
+ 'borderWidth',
+ 'fontSize',
+ 'borderRadius',
+ ...transformsShorthands
+];
-/**
- * @callback ChainedRoundPad
- * @param {Number} decimalLength - Number of decimal places
- * @return {ChainableUtil}
- */
-const roundPad = /** @type {typeof numberUtils.roundPad & ChainedRoundPad} */(makeChainable('roundPad', numberUtils.roundPad));
+const validIndividualTransforms = /*#__PURE__*/ (() => [...transformsShorthands, ...validTransforms.filter(t => ['X', 'Y', 'Z'].some(axis => t.endsWith(axis)))])();
-/**
- * @callback ChainedPadStart
- * @param {Number} totalLength - Target length
- * @param {String} padString - String to pad with
- * @return {ChainableUtil}
- */
-const padStart = /** @type {typeof numberUtils.padStart & ChainedPadStart} */(makeChainable('padStart', numberUtils.padStart));
+let transformsPropertiesRegistered = null;
/**
- * @callback ChainedPadEnd
- * @param {Number} totalLength - Target length
- * @param {String} padString - String to pad with
- * @return {ChainableUtil}
+ * @param {String} propName
+ * @param {WAAPIKeyframeValue} value
+ * @param {DOMTarget} $el
+ * @param {Number} i
+ * @param {Number} targetsLength
+ * @return {String}
*/
-const padEnd = /** @type {typeof numberUtils.padEnd & ChainedPadEnd} */(makeChainable('padEnd', numberUtils.padEnd));
+const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ if (!isNum(v)) return v;
+ if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
+ if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
+ return `${v}`;
+};
/**
- * @callback ChainedWrap
- * @param {Number} min - Minimum boundary
- * @param {Number} max - Maximum boundary
- * @return {ChainableUtil}
+ * @param {DOMTarget} $el
+ * @param {String} propName
+ * @param {WAAPIKeyframeValue} from
+ * @param {WAAPIKeyframeValue} to
+ * @param {Number} i
+ * @param {Number} targetsLength
+ * @return {WAAPITweenValue}
*/
-const wrap = /** @type {typeof numberUtils.wrap & ChainedWrap} */(makeChainable('wrap', numberUtils.wrap));
+const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
+ /** @type {WAAPITweenValue} */
+ let tweenValue = '0';
+ const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
+ if (!isUnd(from)) {
+ const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
+ tweenValue = [computedFrom, computedTo];
+ } else {
+ tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
+ }
+ return tweenValue;
+};
+class WAAPIAnimation {
/**
- * @callback ChainedMapRange
- * @param {Number} inLow - Input range minimum
- * @param {Number} inHigh - Input range maximum
- * @param {Number} outLow - Output range minimum
- * @param {Number} outHigh - Output range maximum
- * @return {ChainableUtil}
+ * @param {DOMTargetsParam} targets
+ * @param {WAAPIAnimationParams} params
*/
-const mapRange = /** @type {typeof numberUtils.mapRange & ChainedMapRange} */(makeChainable('mapRange', numberUtils.mapRange));
+ constructor(targets, params) {
-/**
- * @callback ChainedDegToRad
- * @return {ChainableUtil}
- */
-const degToRad = /** @type {typeof numberUtils.degToRad & ChainedDegToRad} */(makeChainable('degToRad', numberUtils.degToRad));
+ if (scope.current) scope.current.register(this);
-/**
- * @callback ChainedRadToDeg
- * @return {ChainableUtil}
- */
-const radToDeg = /** @type {typeof numberUtils.radToDeg & ChainedRadToDeg} */(makeChainable('radToDeg', numberUtils.radToDeg));
+ // Skip the registration and fallback to no animation in case CSS.registerProperty is not supported
+ if (isNil(transformsPropertiesRegistered)) {
+ if (isBrowser && (isUnd(CSS) || !Object.hasOwnProperty.call(CSS, 'registerProperty'))) {
+ transformsPropertiesRegistered = false;
+ } else {
+ validTransforms.forEach(t => {
+ const isSkew = stringStartsWith(t, 'skew');
+ const isScale = stringStartsWith(t, 'scale');
+ const isRotate = stringStartsWith(t, 'rotate');
+ const isTranslate = stringStartsWith(t, 'translate');
+ const isAngle = isRotate || isSkew;
+ const syntax = isAngle ? '<angle>' : isScale ? "<number>" : isTranslate ? "<length-percentage>" : "*";
+ try {
+ CSS.registerProperty({
+ name: '--' + t,
+ syntax,
+ inherits: false,
+ initialValue: isTranslate ? '0px' : isAngle ? '0deg' : isScale ? '1' : '0',
+ });
+ } catch {} });
+ transformsPropertiesRegistered = true;
+ }
+ }
-/**
- * @callback ChainedSnap
- * @param {Number|Array<Number>} increment - Step size or array of snap points
- * @return {ChainableUtil}
- */
-const snap = /** @type {typeof numberUtils.snap & ChainedSnap} */(makeChainable('snap', numberUtils.snap));
+ const parsedTargets = registerTargets(targets);
+ const targetsLength = parsedTargets.length;
-/**
- * @callback ChainedClamp
- * @param {Number} min - Minimum boundary
- * @param {Number} max - Maximum boundary
- * @return {ChainableUtil}
- */
-const clamp = /** @type {typeof numberUtils.clamp & ChainedClamp} */(makeChainable('clamp', numberUtils.clamp));
+ if (!targetsLength) {
+ console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
+ }
-/**
- * @callback ChainedRound
- * @param {Number} decimalLength - Number of decimal places
- * @return {ChainableUtil}
- */
-const round = /** @type {typeof numberUtils.round & ChainedRound} */(makeChainable('round', numberUtils.round));
+ const ease = setValue(params.ease, parseWAAPIEasing(globals.defaults.ease));
+ const spring = /** @type {Spring} */(ease).ease && ease;
+ const autoplay = setValue(params.autoplay, globals.defaults.autoplay);
+ const scroll = autoplay && /** @type {ScrollObserver} */(autoplay).link ? autoplay : false;
+ const alternate = params.alternate && /** @type {Boolean} */(params.alternate) === true;
+ const reversed = params.reversed && /** @type {Boolean} */(params.reversed) === true;
+ const loop = setValue(params.loop, globals.defaults.loop);
+ const iterations = /** @type {Number} */((loop === true || loop === Infinity) ? Infinity : isNum(loop) ? loop + 1 : 1);
+ /** @type {PlaybackDirection} */
+ const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
+ /** @type {FillMode} */
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
+ /** @type {String} */
+ const easing = parseWAAPIEasing(ease);
+ const timeScale = (globals.timeScale === 1 ? 1 : K);
-/**
- * @callback ChainedLerp
- * @param {Number} start - Starting value
- * @param {Number} end - Ending value
- * @return {ChainableUtil}
- */
-const lerp = /** @type {typeof numberUtils.lerp & ChainedLerp} */(makeChainable('lerp', numberUtils.lerp, 1));
+ /** @type {DOMTargetsArray}] */
+ this.targets = parsedTargets;
+ /** @type {Array<globalThis.Animation>}] */
+ this.animations = [];
+ /** @type {globalThis.Animation}] */
+ this.controlAnimation = null;
+ /** @type {Callback<this>} */
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
+ /** @type {Number} */
+ this.duration = 0;
+ /** @type {Boolean} */
+ this.muteCallbacks = false;
+ /** @type {Boolean} */
+ this.completed = false;
+ /** @type {Boolean} */
+ this.paused = !autoplay || scroll !== false;
+ /** @type {Boolean} */
+ this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
+ /** @type {Boolean|ScrollObserver} */
+ this.autoplay = autoplay;
+ /** @type {Number} */
+ this._speed = setValue(params.playbackRate, globals.defaults.playbackRate);
+ /** @type {Function} */
+ this._resolve = noop; // Used by .then()
+ /** @type {Number} */
+ this._completed = 0;
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
-/**
- * @callback ChainedDamp
- * @param {Number} start - Starting value
- * @param {Number} end - Target value
- * @param {Number} deltaTime - Delta time in ms
- * @return {ChainableUtil}
- */
-const damp = /** @type {typeof numberUtils.damp & ChainedDamp} */(makeChainable('damp', numberUtils.damp, 1));
+ parsedTargets.forEach(($el, i) => {
-/**
- * Generate a random number between optional min and max (inclusive) and decimal precision
- *
- * @callback RandomNumberGenerator
- * @param {Number} [min=0] - The minimum value (inclusive)
- * @param {Number} [max=1] - The maximum value (inclusive)
- * @param {Number} [decimalLength=0] - Number of decimal places to round to
- * @return {Number} A random number between min and max
- */
+ const cachedTransforms = $el[transformsSymbol];
+ const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
-/**
- * Generates a random number between min and max (inclusive) with optional decimal precision
- *
- * @type {RandomNumberGenerator}
- */
-const random = (min = 0, max = 1, decimalLength = 0) => {
- const m = 10 ** decimalLength;
- return Math.floor((Math.random() * (max - min + (1 / m)) + min) * m) / m;
-};
+ /** @type {Number} */
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ /** @type {Number} */
+ const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
+ /** @type {CompositeOperation} */
+ const composite = /** @type {CompositeOperation} */(setValue(params.composition, 'replace'));
-let _seed = 0;
+ for (let name in params) {
+ if (!isKey(name)) continue;
+ /** @type {PropertyIndexedKeyframes} */
+ const keyframes = {};
+ /** @type {KeyframeAnimationOptions} */
+ const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
+ const propertyValue = params[name];
+ const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
-/**
- * Creates a seeded pseudorandom number generator function
- *
- * @param {Number} [seed] - The seed value for the random number generator
- * @param {Number} [seededMin=0] - The minimum default value (inclusive) of the returned function
- * @param {Number} [seededMax=1] - The maximum default value (inclusive) of the returned function
- * @param {Number} [seededDecimalLength=0] - Default number of decimal places to round to of the returned function
- * @return {RandomNumberGenerator} A function to generate a random number between optional min and max (inclusive) and decimal precision
- */
-const createSeededRandom = (seed, seededMin = 0, seededMax = 1, seededDecimalLength = 0) => {
- let t = seed === undefined ? _seed++ : seed;
- return (min = seededMin, max = seededMax, decimalLength = seededDecimalLength) => {
- t += 0x6D2B79F5;
- t = Math.imul(t ^ t >>> 15, t | 1);
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
- const m = 10 ** decimalLength;
- return Math.floor(((((t ^ t >>> 14) >>> 0) / 4294967296) * (max - min + (1 / m)) + min) * m) / m;
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
+
+ let parsedPropertyValue;
+ if (isObj(propertyValue)) {
+ const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
+ const tweenOptionsEase = setValue(tweenOptions.ease, ease);
+ const tweenOptionsSpring = /** @type {Spring} */(tweenOptionsEase).ease && tweenOptionsEase;
+ const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
+ const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
+ /** @type {Number} */
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ /** @type {Number} */
+ tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
+ /** @type {CompositeOperation} */
+ tweenParams.composite = /** @type {CompositeOperation} */(setValue(tweenOptions.composition, composite));
+ /** @type {String} */
+ tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
+ parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
+ if (individualTransformProperty) {
+ keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
+ cachedTransforms[individualTransformProperty] = parsedPropertyValue;
+ } else {
+ keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
+ }
+ addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
+ if (!isUnd(from)) {
+ if (!individualTransformProperty) {
+ elStyle[name] = keyframes[name][0];
+ } else {
+ const key = `--${individualTransformProperty}`;
+ elStyle.setProperty(key, keyframes[key][0]);
+ }
+ }
+ } else {
+ parsedPropertyValue = isArr(propertyValue) ?
+ propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
+ normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
+ if (individualTransformProperty) {
+ keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
+ cachedTransforms[individualTransformProperty] = parsedPropertyValue;
+ } else {
+ keyframes[name] = parsedPropertyValue;
+ }
+ addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
+ }
+ }
+ if (hasIndividualTransforms) {
+ let transforms = emptyString;
+ for (let t in cachedTransforms) {
+ transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
+ }
+ elStyle.transform = transforms;
+ }
+ });
+
+ if (scroll) {
+ /** @type {ScrollObserver} */(this.autoplay).link(this);
+ }
}
-};
-/**
- * Picks a random element from an array or a string
- *
- * @template T
- * @param {String|Array<T>} items - The array or string to pick from
- * @return {String|T} A random element from the array or character from the string
- */
-const randomPick = items => items[random(0, items.length - 1)];
+ /**
+ * @callback forEachCallback
+ * @param {globalThis.Animation} animation
+ */
-/**
- * Shuffles an array in-place using the Fisher-Yates algorithm
- * Adapted from https://bost.ocks.org/mike/shuffle/
- *
- * @param {Array} items - The array to shuffle (will be modified in-place)
- * @return {Array} The same array reference, now shuffled
- */
-const shuffle = items => {
- let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
- return items;
-};
+ /**
+ * @param {forEachCallback|String} callback
+ * @return {this}
+ */
+ forEach(callback) {
+ try {
+ const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
+ this.animations.forEach(cb);
+ } catch {} return this;
+ }
+ get speed() {
+ return this._speed;
+ }
+ set speed(speed) {
+ this._speed = +speed;
+ this.forEach(anim => anim.playbackRate = speed);
+ }
+ get currentTime() {
+ const controlAnimation = this.controlAnimation;
+ const timeScale = globals.timeScale;
+ return this.completed ? this.duration : controlAnimation ? +controlAnimation.currentTime * (timeScale === 1 ? 1 : timeScale) : 0;
+ }
+ set currentTime(time) {
+ const t = time * (globals.timeScale === 1 ? 1 : K);
+ this.forEach(anim => {
+ // Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
+ // The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
+ // https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
+ anim.currentTime = t;
+ });
+ }
-/**
- * @overload
- * @param {Number} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
-/**
- * @overload
- * @param {String} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
-/**
- * @overload
- * @param {[Number, Number]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
-/**
- * @overload
- * @param {[String, String]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
-/**
- * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
- * @param {StaggerParams} [params] The stagger parameters
- * @return {StaggerFunction<Number|String>}
- */
-const stagger = (val, params = {}) => {
- let values = [];
- let maxValue = 0;
- const from = params.from;
- const reversed = params.reversed;
- const ease = params.ease;
- const hasEasing = !isUnd(ease);
- const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
- const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
- const grid = params.grid;
- const axis = params.axis;
- const customTotal = params.total;
- const fromFirst = isUnd(from) || from === 0 || from === 'first';
- const fromCenter = from === 'center';
- const fromLast = from === 'last';
- const fromRandom = from === 'random';
- const isRange = isArr(val);
- const useProp = params.use;
- const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
- const val2 = isRange ? parseNumber(val[1]) : 0;
- const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
- const start = params.start || 0 + (isRange ? val1 : 0);
- let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
- return (target, i, t, tl) => {
- const [ registeredTarget ] = registerTargets(target);
- const total = isUnd(customTotal) ? t : customTotal;
- const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
- if (fromCenter) fromIndex = (total - 1) / 2;
- if (fromLast) fromIndex = total - 1;
- if (!values.length) {
- for (let index = 0; index < total; index++) {
- if (!grid) {
- values.push(abs(fromIndex - index));
+ get progress() {
+ return this.currentTime / this.duration;
+ }
+
+ set progress(progress) {
+ this.forEach(anim => anim.currentTime = progress * this.duration || 0);
+ }
+
+ resume() {
+ if (!this.paused) return this;
+ this.paused = false;
+ // TODO: Store the current time, and seek back to the last position
+ return this.forEach('play');
+ }
+
+ pause() {
+ if (this.paused) return this;
+ this.paused = true;
+ return this.forEach('pause');
+ }
+
+ alternate() {
+ this.reversed = !this.reversed;
+ this.forEach('reverse');
+ if (this.paused) this.forEach('pause');
+ return this;
+ }
+
+ play() {
+ if (this.reversed) this.alternate();
+ return this.resume();
+ }
+
+ reverse() {
+ if (!this.reversed) this.alternate();
+ return this.resume();
+ }
+
+ /**
+ * @param {Number} time
+ * @param {Boolean} muteCallbacks
+ */
+ seek(time, muteCallbacks = false) {
+ if (muteCallbacks) this.muteCallbacks = true;
+ if (time < this.duration) this.completed = false;
+ this.currentTime = time;
+ this.muteCallbacks = false;
+ if (this.paused) this.pause();
+ return this;
+ }
+
+ restart() {
+ this.completed = false;
+ return this.seek(0, true).resume();
+ }
+
+ commitStyles() {
+ return this.forEach('commitStyles');
+ }
+
+ complete() {
+ return this.seek(this.duration);
+ }
+
+ cancel() {
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ this.commitStyles().forEach('cancel');
+ this.animations.length = 0; // Needed to release all animations from memory
+ requestAnimationFrame(() => {
+ this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
+ if ($el.style.transform === 'none') $el.style.removeProperty('transform');
+ });
+ });
+ return this;
+ }
+
+ revert() {
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values if they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
} else {
- const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
- const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
- const toX = index % grid[0];
- const toY = floor(index / grid[0]);
- const distanceX = fromX - toX;
- const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
- if (axis === 'x') value = -distanceX;
- if (axis === 'y') value = -distanceY;
- values.push(value);
+ $el.style[name] = originalInlinedValue;
}
- maxValue = max(...values);
}
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
- }
- const spacing = isRange ? (val2 - val1) / maxValue : val1;
- const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
- /** @type {String|Number} */
- let output = offset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
- if (params.modifier) output = params.modifier(output);
- if (unitMatch) output = `${output}${unitMatch[2]}`;
- return output;
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
+ return this;
+ }
+
+ /**
+ * @typedef {this & {then: null}} ResolvedWAAPIAnimation
+ */
+
+ /**
+ * @param {Callback<ResolvedWAAPIAnimation>} [callback]
+ * @return Promise<this>
+ */
+ then(callback = noop) {
+ const then = this.then;
+ const onResolve = () => {
+ this.then = null;
+ callback(/** @type {ResolvedWAAPIAnimation} */(this));
+ this.then = then;
+ this._resolve = noop;
+ };
+ return new Promise(r => {
+ this._resolve = () => r(onResolve());
+ if (this.completed) this._resolve();
+ return this;
+ });
}
+}
+
+const waapi = {
+/**
+ * @param {DOMTargetsParam} targets
+ * @param {WAAPIAnimationParams} params
+ * @return {WAAPIAnimation}
+ */
+ animate: (targets, params) => new WAAPIAnimation(targets, params),
+ convertEase: easingToLinear
};
-var index$2 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- $: registerTargets,
- clamp: clamp,
- cleanInlineStyles: cleanInlineStyles,
- createSeededRandom: createSeededRandom,
- damp: damp,
- degToRad: degToRad,
- get: get,
- keepTime: keepTime,
- lerp: lerp,
- mapRange: mapRange,
- padEnd: padEnd,
- padStart: padStart,
- radToDeg: radToDeg,
- random: random,
- randomPick: randomPick,
- remove: remove,
- round: round,
- roundPad: roundPad,
- set: set,
- shuffle: shuffle,
- snap: snap,
- stagger: stagger,
- sync: sync,
- wrap: wrap
-});
+
+
+
+
+
/**
- * @param {TargetsParam} path
- * @return {SVGGeometryElement|void}
+ * @typedef {DOMTargetSelector|Array<DOMTargetSelector>} LayoutChildrenParam
*/
-const getPath = path => {
- const parsedTargets = parseTargets(path);
- const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
- if (!$parsedSvg || !isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
- return $parsedSvg;
-};
+/**
+ * @typedef {Record<String, Number|String>} LayoutStateParams
+ */
+/**
+ * @typedef {Object} LayoutAnimationParams
+ * @property {Number} [duration]
+ * @property {Number|FunctionValue} [delay]
+ * @property {EasingParam} [ease]
+ * @property {LayoutStateParams} [frozen]
+ * @property {LayoutStateParams} [added]
+ * @property {LayoutStateParams} [removed]
+ * @property {Callback<AutoLayout>} [onComplete]
+ */
-// Motion path animation
+/**
+ * @typedef {LayoutAnimationParams & {
+ * children?: LayoutChildrenParam,
+ * properties?: Array<String>,
+ * }} AutoLayoutParams
+ */
/**
- * @param {SVGGeometryElement} $path
- * @param {Number} totalLength
- * @param {Number} progress
- * @param {Number} lookup
- * @param {Boolean} shouldClamp
- * @return {DOMPoint}
+ * @typedef {Record<String, Number|String> & {
+ * transform: String,
+ * x: Number,
+ * y: Number,
+ * left: Number,
+ * top: Number,
+ * clientLeft: Number,
+ * clientTop: Number,
+ * width: Number,
+ * height: Number,
+ * }} LayoutNodeProperties
*/
-const getPathPoint = ($path, totalLength, progress, lookup, shouldClamp) => {
- const point = progress + lookup;
- const pointOnPath = shouldClamp
- ? Math.max(0, Math.min(point, totalLength)) // Clamp between 0 and totalLength
- : (point % totalLength + totalLength) % totalLength; // Wrap around
- return $path.getPointAtLength(pointOnPath);
-};
/**
- * @param {SVGGeometryElement} $path
- * @param {String} pathProperty
- * @param {Number} [offset=0]
- * @return {FunctionValue}
+ * @typedef {Object} LayoutNode
+ * @property {String} id
+ * @property {DOMTarget} $el
+ * @property {Number} index
+ * @property {Number} total
+ * @property {Number} delay
+ * @property {Number} duration
+ * @property {DOMTarget} $measure
+ * @property {LayoutSnapshot} state
+ * @property {AutoLayout} layout
+ * @property {LayoutNode|null} parentNode
+ * @property {Boolean} isTarget
+ * @property {Boolean} hasTransform
+ * @property {Boolean} isAnimated
+ * @property {Array<String>} inlineStyles
+ * @property {String|null} inlineTransforms
+ * @property {String|null} inlineTransition
+ * @property {Boolean} branchAdded
+ * @property {Boolean} branchRemoved
+ * @property {Boolean} branchNotRendered
+ * @property {Boolean} sizeChanged
+ * @property {Boolean} isInlined
+ * @property {Boolean} hasVisibilitySwap
+ * @property {Boolean} hasDisplayNone
+ * @property {Boolean} hasVisibilityHidden
+ * @property {String|null} measuredInlineTransform
+ * @property {String|null} measuredInlineTransition
+ * @property {String|null} measuredDisplay
+ * @property {String|null} measuredVisibility
+ * @property {String|null} measuredPosition
+ * @property {Boolean} measuredHasDisplayNone
+ * @property {Boolean} measuredHasVisibilityHidden
+ * @property {Boolean} measuredIsVisible
+ * @property {Boolean} measuredIsRemoved
+ * @property {Boolean} measuredIsInsideRoot
+ * @property {LayoutNodeProperties} properties
+ * @property {LayoutNode|null} _head
+ * @property {LayoutNode|null} _tail
+ * @property {LayoutNode|null} _prev
+ * @property {LayoutNode|null} _next
+ */
+
+/**
+ * @callback LayoutNodeIterator
+ * @param {LayoutNode} node
+ * @param {Number} index
+ * @return {void}
*/
-const getPathProgess = ($path, pathProperty, offset = 0) => {
- return $el => {
- const totalLength = +($path.getTotalLength());
- const inSvg = $el[isSvgSymbol];
- const ctm = $path.getCTM();
- const shouldClamp = offset === 0;
- /** @type {TweenObjectValue} */
- return {
- from: 0,
- to: totalLength,
- /** @type {TweenModifier} */
- modifier: progress => {
- const offsetLength = offset * totalLength;
- const newProgress = progress + offsetLength;
- if (pathProperty === 'a') {
- const p0 = getPathPoint($path, totalLength, newProgress, -1, shouldClamp);
- const p1 = getPathPoint($path, totalLength, newProgress, 1, shouldClamp);
- return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
- } else {
- const p = getPathPoint($path, totalLength, newProgress, 0, shouldClamp);
- return pathProperty === 'x' ?
- inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
- inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
- }
- }
- }
- }
-};
+
+let layoutId = 0;
+let nodeId = 0;
/**
- * @param {TargetsParam} path
- * @param {Number} [offset=0]
+ * @param {DOMTarget} root
+ * @param {DOMTarget} $el
+ * @return {Boolean}
*/
-const createMotionPath = (path, offset = 0) => {
- const $path = getPath(path);
- if (!$path) return;
- return {
- translateX: getPathProgess($path, 'x', offset),
- translateY: getPathProgess($path, 'y', offset),
- rotate: getPathProgess($path, 'a', offset),
- }
+const isElementInRoot = (root, $el) => {
+ if (!root || !$el) return false;
+ return root === $el || root.contains($el);
};
-
-
/**
- * @param {SVGGeometryElement} [$el]
- * @return {Number}
+ * @param {Node} node
+ * @param {'previousSibling'|'nextSibling'} direction
+ * @return {Boolean}
*/
-const getScaleFactor = $el => {
- let scaleFactor = 1;
- if ($el && $el.getCTM) {
- const ctm = $el.getCTM();
- if (ctm) {
- const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
- const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
- scaleFactor = (scaleX + scaleY) / 2;
- }
+const hasTextSibling = (node, direction) => {
+ let sibling = node[direction];
+ while (sibling && sibling.nodeType === Node.TEXT_NODE && !sibling.textContent.trim()) {
+ sibling = sibling[direction];
}
- return scaleFactor;
+ return sibling && sibling.nodeType === Node.TEXT_NODE;
};
/**
- * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
- * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
- * @param {number} start - Starting position (0-1)
- * @param {number} end - Ending position (0-1)
- * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
+ * @param {DOMTarget} $el
+ * @return {Boolean}
*/
-const createDrawableProxy = ($el, start, end) => {
- const pathLength = K;
- const computedStyles = getComputedStyle($el);
- const strokeLineCap = computedStyles.strokeLinecap;
- // @ts-ignore
- const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
- let currentCap = strokeLineCap;
-
- const proxy = new Proxy($el, {
- get(target, property) {
- const value = target[property];
- if (property === proxyTargetSymbol) return target;
- if (property === 'setAttribute') {
- return (...args) => {
- if (args[0] === 'draw') {
- const value = args[1];
- const values = value.split(' ');
- const v1 = +values[0];
- const v2 = +values[1];
- // TOTO: Benchmark if performing two slices is more performant than one split
- // const spaceIndex = value.indexOf(' ');
- // const v1 = round(+value.slice(0, spaceIndex), precision);
- // const v2 = round(+value.slice(spaceIndex + 1), precision);
- const scaleFactor = getScaleFactor($scalled);
- const os = v1 * -pathLength * scaleFactor;
- const d1 = (v2 * pathLength * scaleFactor) + os;
- const d2 = (pathLength * scaleFactor +
- ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
- if (strokeLineCap !== 'butt') {
- const newCap = v1 === v2 ? 'butt' : strokeLineCap;
- if (currentCap !== newCap) {
- target.style.strokeLinecap = `${newCap}`;
- currentCap = newCap;
- }
- }
- target.setAttribute('stroke-dashoffset', `${os}`);
- target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
- }
- return Reflect.apply(value, target, args);
- };
- }
+const isElementSurroundedByText = $el => hasTextSibling($el, 'previousSibling') || hasTextSibling($el, 'nextSibling');
- if (isFnc(value)) {
- return (...args) => Reflect.apply(value, target, args);
- } else {
- return value;
- }
- }
- });
+/**
+ * @param {DOMTarget|null} $el
+ * @return {String|null}
+ */
+const muteElementTransition = $el => {
+ if (!$el) return null;
+ const style = $el.style;
+ const transition = style.transition || '';
+ style.setProperty('transition', 'none', 'important');
+ return transition;
+};
- if ($el.getAttribute('pathLength') !== `${pathLength}`) {
- $el.setAttribute('pathLength', `${pathLength}`);
- proxy.setAttribute('draw', `${start} ${end}`);
+/**
+ * @param {DOMTarget|null} $el
+ * @param {String|null} transition
+ */
+const restoreElementTransition = ($el, transition) => {
+ if (!$el) return;
+ const style = $el.style;
+ if (transition) {
+ style.transition = transition;
+ } else {
+ style.removeProperty('transition');
}
-
- return /** @type {DrawableSVGGeometry} */(proxy);
};
/**
- * Creates drawable proxies for multiple SVG elements.
- * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
- * @param {number} [start=0] - Starting position (0-1)
- * @param {number} [end=0] - Ending position (0-1)
- * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
+ * @param {LayoutNode} node
*/
-const createDrawable = (selector, start = 0, end = 0) => {
- const els = parseTargets(selector);
- return els.map($el => createDrawableProxy(
- /** @type {SVGGeometryElement} */($el),
- start,
- end
- ));
+const muteNodeTransition = node => {
+ const store = node.layout.transitionMuteStore;
+ const $el = node.$el;
+ const $measure = node.$measure;
+ if ($el && !store.has($el)) store.set($el, muteElementTransition($el));
+ if ($measure && !store.has($measure)) store.set($measure, muteElementTransition($measure));
};
+/**
+ * @param {Map<DOMTarget, String|null>} store
+ */
+const restoreLayoutTransition = store => {
+ store.forEach((value, $el) => restoreElementTransition($el, value));
+ store.clear();
+};
+const hiddenComputedStyle = /** @type {CSSStyleDeclaration} */({
+ display: 'none',
+ visibility: 'hidden',
+ opacity: '0',
+ transform: 'none',
+ position: 'static',
+});
/**
- * @param {TargetsParam} path2
- * @param {Number} [precision]
- * @return {FunctionValue}
+ * @param {LayoutNode|null} node
*/
-const morphTo = (path2, precision = .33) => ($path1) => {
- const tagName1 = ($path1.tagName || '').toLowerCase();
- if (!tagName1.match(/^(path|polygon|polyline)$/)) {
- throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
- }
- const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
- if (!$path2) {
- throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
- }
- const tagName2 = ($path2.tagName || '').toLowerCase();
- if (!tagName2.match(/^(path|polygon|polyline)$/)) {
- throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
- }
- const isPath = $path1.tagName === 'path';
- const separator = isPath ? ' ' : ',';
- const previousPoints = $path1[morphPointsSymbol];
- if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
+const detachNode = node => {
+ if (!node) return;
+ const parent = node.parentNode;
+ if (!parent) return;
+ if (parent._head === node) parent._head = node._next;
+ if (parent._tail === node) parent._tail = node._prev;
+ if (node._prev) node._prev._next = node._next;
+ if (node._next) node._next._prev = node._prev;
+ node._prev = null;
+ node._next = null;
+ node.parentNode = null;
+};
- let v1 = '', v2 = '';
+/**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @param {LayoutSnapshot} state
+ * @param {LayoutNode} [recycledNode]
+ * @return {LayoutNode}
+ */
+const createNode = ($el, parentNode, state, recycledNode) => {
+ let dataId = $el.dataset.layoutId;
+ if (!dataId) dataId = $el.dataset.layoutId = `node-${nodeId++}`;
+ const node = recycledNode ? recycledNode : /** @type {LayoutNode} */({});
+ node.$el = $el;
+ node.$measure = $el;
+ node.id = dataId;
+ node.index = 0;
+ node.total = 1;
+ node.delay = 0;
+ node.duration = 0;
+ node.state = state;
+ node.layout = state.layout;
+ node.parentNode = parentNode || null;
+ node.isTarget = false;
+ node.hasTransform = false;
+ node.isAnimated = false;
+ node.inlineStyles = [];
+ node.inlineTransforms = null;
+ node.inlineTransition = null;
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.sizeChanged = false;
+ node.isInlined = false;
+ node.hasVisibilitySwap = false;
+ node.hasDisplayNone = false;
+ node.hasVisibilityHidden = false;
+ node.measuredInlineTransform = null;
+ node.measuredInlineTransition = null;
+ node.measuredDisplay = null;
+ node.measuredVisibility = null;
+ node.measuredPosition = null;
+ node.measuredHasDisplayNone = false;
+ node.measuredHasVisibilityHidden = false;
+ node.measuredIsVisible = false;
+ node.measuredIsRemoved = false;
+ node.measuredIsInsideRoot = false;
+ node.properties = /** @type {LayoutNodeProperties} */({
+ transform: 'none',
+ x: 0,
+ y: 0,
+ left: 0,
+ top: 0,
+ clientLeft: 0,
+ clientTop: 0,
+ width: 0,
+ height: 0,
+ });
+ node.layout.properties.forEach(prop => node.properties[prop] = 0);
+ node._head = null;
+ node._tail = null;
+ node._prev = null;
+ node._next = null;
+ return node;
+};
- if (!precision) {
- v1 = $path1.getAttribute(isPath ? 'd' : 'points');
- v2 = $path2.getAttribute(isPath ? 'd' : 'points');
- } else {
- const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
- const length2 = $path2.getTotalLength();
- const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
- for (let i = 0; i < maxPoints; i++) {
- const t = i / (maxPoints - 1);
- const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
- const pointOnPath2 = $path2.getPointAtLength(length2 * t);
- const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
- v1 += prefix + round$1(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
- v2 += prefix + round$1(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
+/**
+ * @param {LayoutNode} node
+ * @param {DOMTarget} $measure
+ * @param {CSSStyleDeclaration} computedStyle
+ * @param {Boolean} skipMeasurements
+ * @return {LayoutNode}
+ */
+const recordNodeState = (node, $measure, computedStyle, skipMeasurements) => {
+ const $el = node.$el;
+ const root = node.layout.root;
+ const isRoot = root === $el;
+ const properties = node.properties;
+ const rootNode = node.state.rootNode;
+ const parentNode = node.parentNode;
+ const computedTransforms = computedStyle.transform;
+ const inlineTransforms = $el.style.transform;
+ const parentNotRendered = parentNode ? parentNode.measuredIsRemoved : false;
+ const position = computedStyle.position;
+ if (isRoot) node.layout.absoluteCoords = position === 'fixed' || position === 'absolute';
+ node.$measure = $measure;
+ node.inlineTransforms = inlineTransforms;
+ node.hasTransform = computedTransforms && computedTransforms !== 'none';
+ node.measuredIsInsideRoot = isElementInRoot(root, $measure);
+ node.measuredInlineTransform = null;
+ node.measuredDisplay = computedStyle.display;
+ node.measuredVisibility = computedStyle.visibility;
+ node.measuredPosition = position;
+ node.measuredHasDisplayNone = computedStyle.display === 'none';
+ node.measuredHasVisibilityHidden = computedStyle.visibility === 'hidden';
+ node.measuredIsVisible = !(node.measuredHasDisplayNone || node.measuredHasVisibilityHidden);
+ node.measuredIsRemoved = node.measuredHasDisplayNone || node.measuredHasVisibilityHidden || parentNotRendered;
+ node.isInlined = node.measuredDisplay.includes('inline') && isElementSurroundedByText($el);
+
+ // Mute transforms (and transition to avoid triggering an animation) before the position calculation
+ if (node.hasTransform && !skipMeasurements) {
+ const transitionMuteStore = node.layout.transitionMuteStore;
+ if (!transitionMuteStore.get($el)) node.inlineTransition = muteElementTransition($el);
+ if ($measure === $el) {
+ $el.style.transform = 'none';
+ } else {
+ if (!transitionMuteStore.get($measure)) node.measuredInlineTransition = muteElementTransition($measure);
+ node.measuredInlineTransform = $measure.style.transform;
+ $measure.style.transform = 'none';
}
}
- $path1[morphPointsSymbol] = v2;
-
- return [v1, v2];
-};
-
-var index$1 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- createDrawable: createDrawable,
- createMotionPath: createMotionPath,
- morphTo: morphTo
-});
-
+ let left = 0;
+ let top = 0;
+ let width = 0;
+ let height = 0;
+ if (!skipMeasurements) {
+ const rect = $measure.getBoundingClientRect();
+ left = rect.left;
+ top = rect.top;
+ width = rect.width;
+ height = rect.height;
+ }
-const segmenter = (typeof Intl !== 'undefined') && Intl.Segmenter;
-const valueRgx = /\{value\}/g;
-const indexRgx = /\{i\}/g;
-const whiteSpaceGroupRgx = /(\s+)/;
-const whiteSpaceRgx = /^\s+$/;
-const lineType = 'line';
-const wordType = 'word';
-const charType = 'char';
-const dataLine = `data-line`;
+ for (let name in properties) {
+ const computedProp = name === 'transform' ? computedTransforms : computedStyle[name] || (computedStyle.getPropertyValue && computedStyle.getPropertyValue(name));
+ if (!isUnd(computedProp)) properties[name] = computedProp;
+ }
-/**
- * @typedef {Object} Segment
- * @property {String} segment
- * @property {Boolean} [isWordLike]
- */
+ properties.left = left;
+ properties.top = top;
+ properties.clientLeft = skipMeasurements ? 0 : $measure.clientLeft;
+ properties.clientTop = skipMeasurements ? 0 : $measure.clientTop;
+ // Compute local x/y relative to parent
+ let absoluteLeft, absoluteTop;
+ if (isRoot) {
+ if (!node.layout.absoluteCoords) {
+ absoluteLeft = 0;
+ absoluteTop = 0;
+ } else {
+ absoluteLeft = left;
+ absoluteTop = top;
+ }
+ } else {
+ const p = parentNode || rootNode;
+ const parentLeft = p.properties.left;
+ const parentTop = p.properties.top;
+ const borderLeft = p.properties.clientLeft;
+ const borderTop = p.properties.clientTop;
+ if (!node.layout.absoluteCoords) {
+ if (p === rootNode) {
+ const rootLeft = rootNode.properties.left;
+ const rootTop = rootNode.properties.top;
+ const rootBorderLeft = rootNode.properties.clientLeft;
+ const rootBorderTop = rootNode.properties.clientTop;
+ absoluteLeft = left - rootLeft - rootBorderLeft;
+ absoluteTop = top - rootTop - rootBorderTop;
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ }
+ properties.x = absoluteLeft;
+ properties.y = absoluteTop;
+ properties.width = width;
+ properties.height = height;
+ return node;
+};
/**
- * @typedef {Object} Segmenter
- * @property {function(String): Iterable<Segment>} segment
+ * @param {LayoutNode} node
+ * @param {LayoutStateParams} [props]
*/
-
-/** @type {Segmenter} */
-let wordSegmenter = null;
-/** @type {Segmenter} */
-let graphemeSegmenter = null;
-let $splitTemplate = null;
+const updateNodeProperties = (node, props) => {
+ if (!props) return;
+ for (let name in props) {
+ node.properties[name] = props[name];
+ }
+};
/**
- * @param {Segment} seg
- * @return {Boolean}
+ * @param {LayoutNode} node
*/
-const isSegmentWordLike = seg => {
- return seg.isWordLike ||
- seg.segment === ' ' || // Consider spaces as words first, then handle them diffrently later
- isNum(+seg.segment); // Safari doesn't considers numbers as words
+const recordNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ stylesStore.length = 0;
+ node.layout.recordedProperties.forEach(prop => {
+ stylesStore.push(prop, style[prop] || '');
+ });
};
/**
- * @param {HTMLElement} $el
+ * @param {LayoutNode} node
*/
-const setAriaHidden = $el => $el.setAttribute('aria-hidden', 'true');
+const restoreNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ for (let i = 0, l = stylesStore.length; i < l; i += 2) {
+ const property = stylesStore[i];
+ const styleValue = stylesStore[i + 1];
+ if (styleValue && styleValue !== '') {
+ style[property] = styleValue;
+ } else {
+ style[property] = '';
+ style.removeProperty(property);
+ }
+ }
+};
/**
- * @param {DOMTarget} $el
- * @param {String} type
- * @return {Array<HTMLElement>}
+ * @param {LayoutNode} node
*/
-const getAllTopLevelElements = ($el, type) => [.../** @type {*} */($el.querySelectorAll(`[data-${type}]:not([data-${type}] [data-${type}])`))];
-
-const debugColors = { line: '#00D672', word: '#FF4B4B', char: '#5A87FF' };
+const restoreNodeTransform = node => {
+ const inlineTransforms = node.inlineTransforms;
+ const nodeStyle = node.$el.style;
+ if (!node.hasTransform || !inlineTransforms || (node.hasTransform && nodeStyle.transform === 'none') || (inlineTransforms && inlineTransforms === 'none')) {
+ nodeStyle.removeProperty('transform');
+ } else if (inlineTransforms) {
+ nodeStyle.transform = inlineTransforms;
+ }
+ const $measure = node.$measure;
+ if (node.hasTransform && $measure !== node.$el) {
+ const measuredStyle = $measure.style;
+ const measuredInline = node.measuredInlineTransform;
+ if (measuredInline && measuredInline !== '') {
+ measuredStyle.transform = measuredInline;
+ } else {
+ measuredStyle.removeProperty('transform');
+ }
+ }
+ node.measuredInlineTransform = null;
+ if (node.inlineTransition !== null) {
+ restoreElementTransition(node.$el, node.inlineTransition);
+ node.inlineTransition = null;
+ }
+ if ($measure !== node.$el && node.measuredInlineTransition !== null) {
+ restoreElementTransition($measure, node.measuredInlineTransition);
+ node.measuredInlineTransition = null;
+ }
+};
/**
- * @param {HTMLElement} $el
+ * @param {LayoutNode} node
*/
-const filterEmptyElements = $el => {
- if (!$el.childElementCount && !$el.textContent.trim()) {
- const $parent = $el.parentElement;
- $el.remove();
- if ($parent) filterEmptyElements($parent);
+const restoreNodeVisualState = node => {
+ if (node.measuredIsRemoved || node.hasVisibilitySwap) {
+ node.$el.style.removeProperty('display');
+ node.$el.style.removeProperty('visibility');
+ if (node.hasVisibilitySwap) {
+ node.$measure.style.removeProperty('display');
+ node.$measure.style.removeProperty('visibility');
+ }
+ }
+ if (node.measuredIsRemoved) {
+ node.layout.pendingRemoved.delete(node.$el);
}
};
/**
- * @param {HTMLElement} $el
- * @param {Number} lineIndex
- * @param {Set<HTMLElement>} bin
- * @returns {Set<HTMLElement>}
- */
-const filterLineElements = ($el, lineIndex, bin) => {
- const dataLineAttr = $el.getAttribute(dataLine);
- if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') bin.add($el);
- let i = $el.childElementCount;
- while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
- return bin;
+ * @param {LayoutNode} node
+ * @param {LayoutNode} targetNode
+ * @param {LayoutSnapshot} newState
+ * @return {LayoutNode}
+ */
+const cloneNodeProperties = (node, targetNode, newState) => {
+ targetNode.properties = /** @type {LayoutNodeProperties} */({ ...node.properties });
+ targetNode.state = newState;
+ targetNode.isTarget = node.isTarget;
+ targetNode.hasTransform = node.hasTransform;
+ targetNode.inlineTransforms = node.inlineTransforms;
+ targetNode.measuredIsVisible = node.measuredIsVisible;
+ targetNode.measuredDisplay = node.measuredDisplay;
+ targetNode.measuredIsRemoved = node.measuredIsRemoved;
+ targetNode.measuredHasDisplayNone = node.measuredHasDisplayNone;
+ targetNode.measuredHasVisibilityHidden = node.measuredHasVisibilityHidden;
+ targetNode.hasDisplayNone = node.hasDisplayNone;
+ targetNode.isInlined = node.isInlined;
+ targetNode.hasVisibilityHidden = node.hasVisibilityHidden;
+ return targetNode;
};
-/**
- * @param {'line'|'word'|'char'} type
- * @param {SplitTemplateParams} params
- * @return {String}
- */
-const generateTemplate = (type, params = {}) => {
- let template = ``;
- const classString = isStr(params.class) ? ` class="${params.class}"` : '';
- const cloneType = setValue(params.clone, false);
- const wrapType = setValue(params.wrap, false);
- const overflow = wrapType ? wrapType === true ? 'clip' : wrapType : cloneType ? 'clip' : false;
- if (wrapType) template += `<span${overflow ? ` style="overflow:${overflow};"` : ''}>`;
- template += `<span${classString}${cloneType ? ` style="position:relative;"` : ''} data-${type}="{i}">`;
- if (cloneType) {
- const left = cloneType === 'left' ? '-100%' : cloneType === 'right' ? '100%' : '0';
- const top = cloneType === 'top' ? '-100%' : cloneType === 'bottom' ? '100%' : '0';
- template += `<span>{value}</span>`;
- template += `<span inert style="position:absolute;top:${top};left:${left};white-space:nowrap;">{value}</span>`;
- } else {
- template += `{value}`;
+class LayoutSnapshot {
+ /**
+ * @param {AutoLayout} layout
+ */
+ constructor(layout) {
+ /** @type {AutoLayout} */
+ this.layout = layout;
+ /** @type {LayoutNode|null} */
+ this.rootNode = null;
+ /** @type {Set<LayoutNode>} */
+ this.rootNodes = new Set();
+ /** @type {Map<String, LayoutNode>} */
+ this.nodes = new Map();
+ /** @type {Number} */
+ this.scrollX = 0;
+ /** @type {Number} */
+ this.scrollY = 0;
}
- template += `</span>`;
- if (wrapType) template += `</span>`;
- return template;
-};
-/**
- * @param {String|SplitFunctionValue} htmlTemplate
- * @param {Array<HTMLElement>} store
- * @param {Node|HTMLElement} node
- * @param {DocumentFragment} $parentFragment
- * @param {'line'|'word'|'char'} type
- * @param {Boolean} debug
- * @param {Number} lineIndex
- * @param {Number} [wordIndex]
- * @param {Number} [charIndex]
- * @return {HTMLElement}
- */
-const processHTMLTemplate = (htmlTemplate, store, node, $parentFragment, type, debug, lineIndex, wordIndex, charIndex) => {
- const isLine = type === lineType;
- const isChar = type === charType;
- const className = `_${type}_`;
- const template = isFnc(htmlTemplate) ? htmlTemplate(node) : htmlTemplate;
- const displayStyle = isLine ? 'block' : 'inline-block';
- $splitTemplate.innerHTML = template
- .replace(valueRgx, `<i class="${className}"></i>`)
- .replace(indexRgx, `${isChar ? charIndex : isLine ? lineIndex : wordIndex}`);
- const $content = $splitTemplate.content;
- const $highestParent = /** @type {HTMLElement} */($content.firstElementChild);
- const $split = /** @type {HTMLElement} */($content.querySelector(`[data-${type}]`)) || $highestParent;
- const $replacables = /** @type {NodeListOf<HTMLElement>} */($content.querySelectorAll(`i.${className}`));
- const replacablesLength = $replacables.length;
- if (replacablesLength) {
- $highestParent.style.display = displayStyle;
- $split.style.display = displayStyle;
- $split.setAttribute(dataLine, `${lineIndex}`);
- if (!isLine) {
- $split.setAttribute('data-word', `${wordIndex}`);
- if (isChar) $split.setAttribute('data-char', `${charIndex}`);
+ /**
+ * @return {this}
+ */
+ revert() {
+ this.forEachNode(node => {
+ node.$el.removeAttribute('data-layout-id');
+ node.$measure.removeAttribute('data-layout-id');
+ });
+ this.rootNode = null;
+ this.rootNodes.clear();
+ this.nodes.clear();
+ return this;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @return {LayoutNodeProperties|undefined}
+ */
+ get($el) {
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
}
- let i = replacablesLength;
- while (i--) {
- const $replace = $replacables[i];
- const $closestParent = $replace.parentElement;
- $closestParent.style.display = displayStyle;
- if (isLine) {
- $closestParent.innerHTML = /** @type {HTMLElement} */(node).innerHTML;
- } else {
- $closestParent.replaceChild(node.cloneNode(true), $replace);
- }
+ return node.properties;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} prop
+ * @return {Number|String|undefined}
+ */
+ getValue($el, prop) {
+ if (!$el || !$el.dataset) {
+ console.warn(`No element found on state (${$el})`);
+ return;
}
- store.push($split);
- $parentFragment.appendChild($content);
- } else {
- console.warn(`The expression "{value}" is missing from the provided template.`);
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ const value = node.properties[prop];
+ if (!isUnd(value)) return getFunctionValue(value, $el, node.index, node.total);
}
- if (debug) $highestParent.style.outline = `1px dotted ${debugColors[type]}`;
- return $highestParent;
-};
-/**
- * A class that splits text into words and wraps them in span elements while preserving the original HTML structure.
- * @class
- */
-class TextSplitter {
/**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
+ * @param {LayoutNode|null} rootNode
+ * @param {LayoutNodeIterator} cb
*/
- constructor(target, parameters = {}) {
- // Only init segmenters when needed
- if (!wordSegmenter) wordSegmenter = segmenter ? new segmenter([], { granularity: wordType }) : {
- segment: (text) => {
- const segments = [];
- const words = text.split(whiteSpaceGroupRgx);
- for (let i = 0, l = words.length; i < l; i++) {
- const segment = words[i];
- segments.push({
- segment,
- isWordLike: !whiteSpaceRgx.test(segment), // Consider non-whitespace as word-like
- });
+ forEach(rootNode, cb) {
+ let node = rootNode;
+ let i = 0;
+ while (node) {
+ cb(node, i++);
+ if (node._head) {
+ node = node._head;
+ } else if (node._next) {
+ node = node._next;
+ } else {
+ while (node && !node._next) {
+ node = node.parentNode;
}
- return segments;
+ if (node) node = node._next;
}
- };
- if (!graphemeSegmenter) graphemeSegmenter = segmenter ? new segmenter([], { granularity: 'grapheme' }) : {
- segment: text => [...text].map(char => ({ segment: char }))
- };
- if (!$splitTemplate && isBrowser) $splitTemplate = doc.createElement('template');
- if (scope.current) scope.current.register(this);
- const { words, chars, lines, accessible, includeSpaces, debug } = parameters;
- const $target = /** @type {HTMLElement} */((target = isArr(target) ? target[0] : target) && /** @type {Node} */(target).nodeType ? target : (getNodeList(target) || [])[0]);
- const lineParams = lines === true ? {} : lines;
- const wordParams = words === true || isUnd(words) ? {} : words;
- const charParams = chars === true ? {} : chars;
- this.debug = setValue(debug, false);
- this.includeSpaces = setValue(includeSpaces, false);
- this.accessible = setValue(accessible, true);
- this.linesOnly = lineParams && (!wordParams && !charParams);
- /** @type {String|false|SplitFunctionValue} */
- this.lineTemplate = isObj(lineParams) ? generateTemplate(lineType, /** @type {SplitTemplateParams} */(lineParams)) : lineParams;
- /** @type {String|false|SplitFunctionValue} */
- this.wordTemplate = isObj(wordParams) || this.linesOnly ? generateTemplate(wordType, /** @type {SplitTemplateParams} */(wordParams)) : wordParams;
- /** @type {String|false|SplitFunctionValue} */
- this.charTemplate = isObj(charParams) ? generateTemplate(charType, /** @type {SplitTemplateParams} */(charParams)) : charParams;
- this.$target = $target;
- this.html = $target && $target.innerHTML;
- this.lines = [];
- this.words = [];
- this.chars = [];
- this.effects = [];
- this.effectsCleanups = [];
- this.cache = null;
- this.ready = false;
- this.width = 0;
- this.resizeTimeout = null;
- const handleSplit = () => this.html && (lineParams || wordParams || charParams) && this.split();
- // Make sure this is declared before calling handleSplit() in case revert() is called inside an effect callback
- this.resizeObserver = new ResizeObserver(() => {
- // Use a setTimeout instead of a Timer for better tree shaking
- clearTimeout(this.resizeTimeout);
- this.resizeTimeout = setTimeout(() => {
- const currentWidth = /** @type {HTMLElement} */($target).offsetWidth;
- if (currentWidth === this.width) return;
- this.width = currentWidth;
- handleSplit();
- }, 150);
- });
- // Only declare the font ready promise when splitting by lines and not alreay split
- if (this.lineTemplate && !this.ready) {
- doc.fonts.ready.then(handleSplit);
- } else {
- handleSplit();
}
- $target ? this.resizeObserver.observe($target) : console.warn('No Text Splitter target found.');
}
/**
- * @param {(...args: any[]) => Tickable | (() => void)} effect
- * @return this
+ * @param {LayoutNodeIterator} cb
*/
- addEffect(effect) {
- if (!isFnc(effect)) return console.warn('Effect must return a function.');
- const refreshableEffect = keepTime(effect);
- this.effects.push(refreshableEffect);
- if (this.ready) this.effectsCleanups[this.effects.length - 1] = refreshableEffect(this);
- return this;
+ forEachRootNode(cb) {
+ this.forEach(this.rootNode, cb);
}
- revert() {
- clearTimeout(this.resizeTimeout);
- this.lines.length = this.words.length = this.chars.length = 0;
- this.resizeObserver.disconnect();
- // Make sure to revert the effects after disconnecting the resizeObserver to avoid triggering it in the process
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) ? cleanup(this) : cleanup.revert && cleanup.revert());
- this.$target.innerHTML = this.html;
- return this;
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachNode(cb) {
+ for (const rootNode of this.rootNodes) {
+ this.forEach(rootNode, cb);
+ }
}
/**
- * Recursively processes a node and its children
- * @param {Node} node
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @return {LayoutNode|null}
*/
- splitNode(node) {
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const includeSpaces = this.includeSpaces;
- const debug = this.debug;
- const nodeType = node.nodeType;
- if (nodeType === 3) {
- const nodeText = node.nodeValue;
- // If the nodeText is only whitespace, leave it as is
- if (nodeText.trim()) {
- const tempWords = [];
- const words = this.words;
- const chars = this.chars;
- const wordSegments = wordSegmenter.segment(nodeText);
- const $wordsFragment = doc.createDocumentFragment();
- let prevSeg = null;
- for (const wordSegment of wordSegments) {
- const segment = wordSegment.segment;
- const isWordLike = isSegmentWordLike(wordSegment);
- // Determine if this segment should be a new word, first segment always becomes a new word
- if (!prevSeg || (isWordLike && (prevSeg && (isSegmentWordLike(prevSeg))))) {
- tempWords.push(segment);
- } else {
- // Only concatenate if both current and previous are non-word-like and don't contain spaces
- const lastWordIndex = tempWords.length - 1;
- const lastWord = tempWords[lastWordIndex];
- if (!lastWord.includes(' ') && !segment.includes(' ')) {
- tempWords[lastWordIndex] += segment;
- } else {
- tempWords.push(segment);
- }
+ registerElement($el, parentNode) {
+ if (!$el || $el.nodeType !== 1) return null;
+
+ if (!this.layout.transitionMuteStore.has($el)) this.layout.transitionMuteStore.set($el, muteElementTransition($el));
+
+ /** @type {Array<DOMTarget|LayoutNode|null>} */
+ const stack = [$el, parentNode];
+ const root = this.layout.root;
+ let firstNode = null;
+
+ while (stack.length) {
+ /** @type {LayoutNode|null} */
+ const $parent = /** @type {LayoutNode|null} */(stack.pop());
+ /** @type {DOMTarget|null} */
+ const $current = /** @type {DOMTarget|null} */(stack.pop());
+ if (!$current || $current.nodeType !== 1 || isSvg($current)) continue;
+
+ const skipMeasurements = $parent ? $parent.measuredIsRemoved : false;
+
+ const computedStyle = skipMeasurements ? hiddenComputedStyle : getComputedStyle($current);
+ const hasDisplayNone = skipMeasurements ? true : computedStyle.display === 'none';
+ const hasVisibilityHidden = skipMeasurements ? true : computedStyle.visibility === 'hidden';
+ const isVisible = !hasDisplayNone && !hasVisibilityHidden;
+ const existingId = $current.dataset.layoutId;
+ const isInsideRoot = isElementInRoot(root, $current);
+
+ let node = existingId ? this.nodes.get(existingId) : null;
+
+ if (node && node.$el !== $current) {
+ const nodeInsideRoot = isElementInRoot(root, node.$el);
+ const measuredVisible = node.measuredIsVisible;
+ const shouldReassignNode = !nodeInsideRoot && (isInsideRoot || (!isInsideRoot && !measuredVisible && isVisible));
+ const shouldReuseMeasurements = nodeInsideRoot && !measuredVisible && isVisible;
+ // Rebind nodes that move into the root or whose detached twin just became visible
+ if (shouldReassignNode) {
+ detachNode(node);
+ node = createNode($current, $parent, this, node);
+ // for hidden element with in-root sibling, keep the hidden node but borrow measurements from its visible in-root twin element
+ } else if (shouldReuseMeasurements) {
+ recordNodeState(node, $current, computedStyle, skipMeasurements);
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
}
- prevSeg = wordSegment;
+ if (!firstNode) firstNode = node;
+ continue;
+ // No reassignment needed so keep walking descendants under the current parent
+ } else {
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), $parent);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
}
+ } else {
+ node = createNode($current, $parent, this, node);
+ }
- for (let i = 0, l = tempWords.length; i < l; i++) {
- const word = tempWords[i];
- if (!word.trim()) {
- // Preserve whitespace only if includeSpaces is false and if the current space is not the first node
- if (i && includeSpaces) continue;
- $wordsFragment.appendChild(doc.createTextNode(word));
- } else {
- const nextWord = tempWords[i + 1];
- const hasWordFollowingSpace = includeSpaces && nextWord && !nextWord.trim();
- const wordToProcess = word;
- const charSegments = charTemplate ? graphemeSegmenter.segment(wordToProcess) : null;
- const $charsFragment = charTemplate ? doc.createDocumentFragment() : doc.createTextNode(hasWordFollowingSpace ? word + '\xa0' : word);
- if (charTemplate) {
- const charSegmentsArray = [...charSegments];
- for (let j = 0, jl = charSegmentsArray.length; j < jl; j++) {
- const charSegment = charSegmentsArray[j];
- const isLastChar = j === jl - 1;
- // If this is the last character and includeSpaces is true with a following space, append the space
- const charText = isLastChar && hasWordFollowingSpace ? charSegment.segment + '\xa0' : charSegment.segment;
- const $charNode = doc.createTextNode(charText);
- processHTMLTemplate(charTemplate, chars, $charNode, /** @type {DocumentFragment} */($charsFragment), charType, debug, -1, words.length, chars.length);
- }
- }
- if (wordTemplate) {
- processHTMLTemplate(wordTemplate, words, $charsFragment, $wordsFragment, wordType, debug, -1, words.length, chars.length);
- // Chars elements must be re-parsed in the split() method if both words and chars are parsed
- } else if (charTemplate) {
- $wordsFragment.appendChild($charsFragment);
- } else {
- $wordsFragment.appendChild(doc.createTextNode(word));
- }
- // Skip the next iteration if we included a space
- if (hasWordFollowingSpace) i++;
- }
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.isTarget = false;
+ node.isAnimated = false;
+ node.hasVisibilityHidden = hasVisibilityHidden;
+ node.hasDisplayNone = hasDisplayNone;
+ node.hasVisibilitySwap = (hasVisibilityHidden && !node.measuredHasVisibilityHidden) || (hasDisplayNone && !node.measuredHasDisplayNone);
+ // node.hasVisibilitySwap = (hasVisibilityHidden !== node.measuredHasVisibilityHidden) || (hasDisplayNone !== node.measuredHasDisplayNone);
+
+ this.nodes.set(node.id, node);
+
+ node.parentNode = $parent || null;
+ node._prev = null;
+ node._next = null;
+
+ if ($parent) {
+ this.rootNodes.delete(node);
+ if (!$parent._head) {
+ $parent._head = node;
+ $parent._tail = node;
+ } else {
+ $parent._tail._next = node;
+ node._prev = $parent._tail;
+ $parent._tail = node;
}
- node.parentNode.replaceChild($wordsFragment, node);
+ } else {
+ this.rootNodes.add(node);
}
- } else if (nodeType === 1) {
- // Converting to an array is necessary to work around childNodes pottential mutation
- const childNodes = /** @type {Array<Node>} */([.../** @type {*} */(node.childNodes)]);
- for (let i = 0, l = childNodes.length; i < l; i++) this.splitNode(childNodes[i]);
+
+ recordNodeState(node, node.$el, computedStyle, skipMeasurements);
+
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+
+ if (!firstNode) firstNode = node;
}
+
+ return firstNode;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {Set<DOMTarget>} candidates
+ * @return {LayoutNode|null}
+ */
+ ensureDetachedNode($el, candidates) {
+ if (!$el || $el === this.layout.root) return null;
+ const existingId = $el.dataset.layoutId;
+ const existingNode = existingId ? this.nodes.get(existingId) : null;
+ if (existingNode && existingNode.$el === $el) return existingNode;
+ let parentNode = null;
+ let $ancestor = $el.parentElement;
+ while ($ancestor && $ancestor !== this.layout.root) {
+ if (candidates.has($ancestor)) {
+ parentNode = this.ensureDetachedNode($ancestor, candidates);
+ break;
+ }
+ $ancestor = $ancestor.parentElement;
+ }
+ return this.registerElement($el, parentNode);
}
/**
- * @param {Boolean} clearCache
* @return {this}
*/
- split(clearCache = false) {
- const $el = this.$target;
- const isCached = !!this.cache && !clearCache;
- const lineTemplate = this.lineTemplate;
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const fontsReady = doc.fonts.status !== 'loading';
- const canSplitLines = lineTemplate && fontsReady;
- this.ready = !lineTemplate || fontsReady;
- if (canSplitLines || clearCache) {
- // No need to revert effects animations here since it's already taken care by the refreshable
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
+ record() {
+ const { children, root } = this.layout;
+ const toParse = isArr(children) ? children : [children];
+ const scoped = [];
+ const scopeRoot = children === '*' ? root : scope.root;
+
+ for (let i = 0, l = toParse.length; i < l; i++) {
+ const child = toParse[i];
+ scoped[i] = isStr(child) ? scopeRoot.querySelectorAll(child) : child;
}
- if (!isCached) {
- if (clearCache) {
- $el.innerHTML = this.html;
- this.words.length = this.chars.length = 0;
+
+ const parsedChildren = registerTargets(scoped);
+
+ this.nodes.clear();
+ this.rootNodes.clear();
+
+ const rootNode = this.registerElement(root, null);
+ // Root node are always targets
+ rootNode.isTarget = true;
+ this.rootNode = rootNode;
+
+ // Track ids of nodes that belong to the current root to filter detached matches
+ const inRootNodeIds = new Set();
+ this.nodes.forEach((node, id) => {
+ if (node && node.measuredIsInsideRoot) {
+ inRootNodeIds.add(id);
+ }
+ });
+
+ // Elements with a layout id outside the root that match the children selector
+ const detachedElementsLookup = new Set();
+ const orderedDetachedElements = [];
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ if (!$el || $el.nodeType !== 1 || $el === root) continue;
+ const insideRoot = isElementInRoot(root, $el);
+ if (!insideRoot) {
+ const layoutNodeId = $el.dataset.layoutId;
+ if (!layoutNodeId || !inRootNodeIds.has(layoutNodeId)) continue;
+ }
+ if (!detachedElementsLookup.has($el)) {
+ detachedElementsLookup.add($el);
+ orderedDetachedElements.push($el);
}
- this.splitNode($el);
- this.cache = $el.innerHTML;
- }
- if (canSplitLines) {
- if (isCached) $el.innerHTML = this.cache;
- this.lines.length = 0;
- if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
}
- // Always reparse characters after a line reset or if both words and chars are activated
- if (charTemplate && (canSplitLines || wordTemplate)) {
- this.chars = getAllTopLevelElements($el, charType);
+
+ for (let i = 0, l = orderedDetachedElements.length; i < l; i++) {
+ this.ensureDetachedNode(orderedDetachedElements[i], detachedElementsLookup);
}
- // Words are used when lines only and prioritized over chars
- const elementsArray = this.words.length ? this.words : this.chars;
- let y, linesCount = 0;
- for (let i = 0, l = elementsArray.length; i < l; i++) {
- const $el = elementsArray[i];
- const { top, height } = $el.getBoundingClientRect();
- if (y && top - y > height * .5) linesCount++;
- $el.setAttribute(dataLine, `${linesCount}`);
- const nested = $el.querySelectorAll(`[${dataLine}]`);
- let c = nested.length;
- while (c--) nested[c].setAttribute(dataLine, `${linesCount}`);
- y = top;
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (node) {
+ let cur = node;
+ while (cur) {
+ if (cur.isTarget) break;
+ cur.isTarget = true;
+ cur = cur.parentNode;
+ }
+ }
}
- if (canSplitLines) {
- const linesFragment = doc.createDocumentFragment();
- const parents = new Set();
- const clones = [];
- for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
- const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
- filterLineElements($clone, lineIndex, new Set()).forEach($el => {
- const $parent = $el.parentElement;
- if ($parent) parents.add($parent);
- $el.remove();
+
+ this.scrollX = window.scrollX;
+ this.scrollY = window.scrollY;
+
+ const total = this.nodes.size;
+
+ this.forEachNode(restoreNodeTransform);
+ this.forEachNode((node, i) => {
+ node.index = i;
+ node.total = total;
+ });
+
+ return this;
+ }
+}
+
+class AutoLayout {
+ /**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ */
+ constructor(root, params = {}) {
+ if (scope.current) scope.current.register(this);
+ const frozenParams = params.frozen;
+ const addedParams = params.added;
+ const removedParams = params.removed;
+ const propsParams = params.properties;
+ /** @type {AutoLayoutParams} */
+ this.params = params;
+ /** @type {DOMTarget} */
+ this.root = /** @type {DOMTarget} */(registerTargets(root)[0]);
+ /** @type {Number} */
+ this.id = layoutId++;
+ /** @type {LayoutChildrenParam} */
+ this.children = params.children || '*';
+ /** @type {Boolean} */
+ this.absoluteCoords = false;
+ /** @type {Number} */
+ this.duration = setValue(params.duration, 500);
+ /** @type {Number|FunctionValue} */
+ this.delay = setValue(params.delay, 0);
+ /** @type {EasingParam} */
+ this.ease = setValue(params.ease, 'inOutExpo');
+ /** @type {Callback<this>} */
+ this.onComplete = setValue(params.onComplete, /** @type {Callback<this>} */(noop));
+ /** @type {LayoutStateParams} */
+ this.frozenParams = frozenParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.addedParams = addedParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.removedParams = removedParams || { opacity: 0 };
+ /** @type {Set<String>} */
+ this.properties = new Set([
+ 'opacity',
+ 'borderRadius',
+ ]);
+ if (frozenParams) for (let name in frozenParams) this.properties.add(name);
+ if (addedParams) for (let name in addedParams) this.properties.add(name);
+ if (removedParams) for (let name in removedParams) this.properties.add(name);
+ if (propsParams) for (let i = 0, l = propsParams.length; i < l; i++) this.properties.add(propsParams[i]);
+ /** @type {Set<String>} */
+ this.recordedProperties = new Set([
+ 'display',
+ 'visibility',
+ 'translate',
+ 'position',
+ 'left',
+ 'top',
+ 'marginLeft',
+ 'marginTop',
+ 'width',
+ 'height',
+ 'maxWidth',
+ 'maxHeight',
+ 'minWidth',
+ 'minHeight',
+ ]);
+ this.properties.forEach(prop => this.recordedProperties.add(prop));
+ /** @type {WeakSet<DOMTarget>} */
+ this.pendingRemoved = new WeakSet();
+ /** @type {Map<DOMTarget, String|null>} */
+ this.transitionMuteStore = new Map();
+ /** @type {LayoutSnapshot} */
+ this.oldState = new LayoutSnapshot(this);
+ /** @type {LayoutSnapshot} */
+ this.newState = new LayoutSnapshot(this);
+ /** @type {Timeline|null} */
+ this.timeline = null;
+ /** @type {WAAPIAnimation|null} */
+ this.transformAnimation = null;
+ /** @type {Array<DOMTarget>} */
+ this.frozen = [];
+ /** @type {Array<DOMTarget>} */
+ this.removed = [];
+ /** @type {Array<DOMTarget>} */
+ this.added = [];
+ // Record the current state as the old state to init the data attributes
+ this.oldState.record();
+ // And all layout transition muted during the record
+ restoreLayoutTransition(this.transitionMuteStore);
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ if (this.timeline) {
+ this.timeline.complete();
+ this.timeline = null;
+ }
+ if (this.transformAnimation) {
+ this.transformAnimation.complete();
+ this.transformAnimation = null;
+ }
+ this.root.classList.remove('is-animated');
+ this.frozen.length = this.removed.length = this.added.length = 0;
+ this.oldState.revert();
+ this.newState.revert();
+ requestAnimationFrame(() => restoreLayoutTransition(this.transitionMuteStore));
+ return this;
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ // Commit transforms before measuring
+ if (this.transformAnimation) {
+ this.transformAnimation.cancel();
+ this.transformAnimation = null;
+ }
+ // Record the old state
+ this.oldState.record();
+ // Cancel any running timeline
+ if (this.timeline) {
+ this.timeline.cancel();
+ this.timeline = null;
+ }
+ // Restore previously captured inline styles
+ this.newState.forEachRootNode(restoreNodeInlineStyles);
+ return this;
+ }
+
+ /**
+ * @param {LayoutAnimationParams} [params]
+ * @return {Timeline}
+ */
+ animate(params = {}) {
+ const delay = setValue(params.delay, this.delay);
+ const duration = setValue(params.duration, this.duration);
+ const onComplete = setValue(params.onComplete, this.onComplete);
+ const frozenParams = params.frozen ? mergeObjects(params.frozen, this.frozenParams) : this.frozenParams;
+ const addedParams = params.added ? mergeObjects(params.added, this.addedParams) : this.addedParams;
+ const removedParams = params.removed ? mergeObjects(params.removed, this.removedParams) : this.removedParams;
+ const oldState = this.oldState;
+ const newState = this.newState;
+ const added = this.added;
+ const removed = this.removed;
+ const frozen = this.frozen;
+ const pendingRemoved = this.pendingRemoved;
+
+ added.length = removed.length = frozen.length = 0;
+
+ // Mute old state CSS transitions to prevent wrong properties calculation
+ oldState.forEachRootNode(muteNodeTransition);
+ // Capture the new state before animation
+ newState.record();
+ newState.forEachRootNode(recordNodeInlineStyles);
+
+ const targets = [];
+ const animated = [];
+ const transformed = [];
+ const animatedFrozen = [];
+ const root = newState.rootNode.$el;
+
+ newState.forEachRootNode(node => {
+ const $el = node.$el;
+ const id = node.id;
+ const parent = node.parentNode;
+ const parentAdded = parent ? parent.branchAdded : false;
+ const parentRemoved = parent ? parent.branchRemoved : false;
+ const parentNotRendered = parent ? parent.branchNotRendered : false;
+
+ // Delay and duration must be calculated in the animate() call to support delay override
+ node.delay = +(isFnc(delay) ? delay($el, node.index, node.total) : delay);
+ node.duration = +(isFnc(duration) ? duration($el, node.index, node.total) : duration);
+
+ let oldStateNode = oldState.nodes.get(id);
+
+ const hasNoOldState = !oldStateNode;
+
+ if (hasNoOldState) {
+ oldStateNode = cloneNodeProperties(node, /** @type {LayoutNode} */({}), oldState);
+ oldState.nodes.set(id, oldStateNode);
+ oldStateNode.measuredIsRemoved = true;
+ } else if (oldStateNode.measuredIsRemoved && !node.measuredIsRemoved) {
+ cloneNodeProperties(node, oldStateNode, oldState);
+ oldStateNode.measuredIsRemoved = true;
+ }
+
+ const oldParentNode = oldStateNode.parentNode;
+ const oldParentId = oldParentNode ? oldParentNode.id : null;
+ const newParentId = parent ? parent.id : null;
+ const parentChanged = oldParentId !== newParentId;
+ const elementChanged = oldStateNode.$el !== node.$el;
+ const wasRemovedBefore = oldStateNode.measuredIsRemoved;
+ const isRemovedNow = node.measuredIsRemoved;
+
+ // Recalculate postion relative to their parent for elements that have been moved
+ if (!oldStateNode.measuredIsRemoved && !isRemovedNow && !hasNoOldState && (parentChanged || elementChanged)) {
+ let offsetX = 0;
+ let offsetY = 0;
+ let current = node.parentNode;
+ while (current) {
+ offsetX += current.properties.x || 0;
+ offsetY += current.properties.y || 0;
+ if (current.parentNode === newState.rootNode) break;
+ current = current.parentNode;
+ }
+ let oldOffsetX = 0;
+ let oldOffsetY = 0;
+ let oldCurrent = oldStateNode.parentNode;
+ while (oldCurrent) {
+ oldOffsetX += oldCurrent.properties.x || 0;
+ oldOffsetY += oldCurrent.properties.y || 0;
+ if (oldCurrent.parentNode === oldState.rootNode) break;
+ oldCurrent = oldCurrent.parentNode;
+ }
+ oldStateNode.properties.x += oldOffsetX - offsetX;
+ oldStateNode.properties.y += oldOffsetY - offsetY;
+ }
+
+ if (node.hasVisibilitySwap) {
+ if (node.hasVisibilityHidden) {
+ node.$el.style.visibility = 'visible';
+ node.$measure.style.visibility = 'hidden';
+ }
+ if (node.hasDisplayNone) {
+ node.$el.style.display = oldStateNode.measuredDisplay || node.measuredDisplay || '';
+ // Setting visibility 'hidden' instead of display none to avoid calculation issues
+ node.$measure.style.visibility = 'hidden';
+ // @TODO: check why setting display here can cause calculation issues
+ // node.$measure.style.display = 'none';
+ }
+ }
+
+ const wasPendingRemoval = pendingRemoved.has($el);
+ const wasVisibleBefore = oldStateNode.measuredIsVisible;
+ const isVisibleNow = node.measuredIsVisible;
+ const becomeVisible = !wasVisibleBefore && isVisibleNow && !parentNotRendered;
+ const topLevelAdded = !isRemovedNow && (wasRemovedBefore || wasPendingRemoval) && !parentAdded;
+ const newlyRemoved = isRemovedNow && !wasRemovedBefore && !parentRemoved;
+ const topLevelRemoved = newlyRemoved || isRemovedNow && wasPendingRemoval && !parentRemoved;
+
+ if (node.measuredIsRemoved && wasVisibleBefore) {
+ node.$el.style.display = oldStateNode.measuredDisplay;
+ node.$el.style.visibility = 'visible';
+ cloneNodeProperties(oldStateNode, node, newState);
+ }
+
+ if (newlyRemoved) {
+ removed.push($el);
+ pendingRemoved.add($el);
+ } else if (!isRemovedNow && wasPendingRemoval) {
+ pendingRemoved.delete($el);
+ }
+
+ // Node is added
+ if ((topLevelAdded && !parentNotRendered) || becomeVisible) {
+ updateNodeProperties(oldStateNode, addedParams);
+ added.push($el);
+ // Node is removed
+ } else if (topLevelRemoved && !parentNotRendered) {
+ updateNodeProperties(node, removedParams);
+ }
+
+ // Compute function based propety values before cheking for changes
+ for (let name in node.properties) {
+ node.properties[name] = newState.getValue(node.$el, name);
+ // NOTE: I'm using node.$el to get the value of old state, make sure this is valid instead of oldStateNode.$el
+ oldStateNode.properties[name] = oldState.getValue(node.$el, name);
+ }
+
+ const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
+ let propertyChanged = false;
+
+
+ if (node.isTarget && (!node.measuredIsRemoved && wasVisibleBefore || node.measuredIsRemoved && isVisibleNow)) {
+ if (!node.isInlined && (node.properties.transform !== 'none' || oldStateNode.properties.transform !== 'none')) {
+ node.hasTransform = true;
+ propertyChanged = true;
+ transformed.push($el);
+ }
+ for (let name in node.properties) {
+ if (name !== 'transform' && (node.properties[name] !== oldStateNode.properties[name] || hiddenStateChanged)) {
+ propertyChanged = true;
+ animated.push($el);
+ break;
+ }
+ }
+ }
+
+ const nodeHasChanged = (propertyChanged || topLevelAdded || topLevelRemoved || becomeVisible);
+ const nodeIsAnimated = node.isTarget && nodeHasChanged;
+
+ node.isAnimated = nodeIsAnimated;
+ node.branchAdded = parentAdded || topLevelAdded;
+ node.branchRemoved = parentRemoved || topLevelRemoved;
+ node.branchNotRendered = parentNotRendered || node.measuredIsRemoved;
+
+ const sizeTolerance = 1;
+ const widthChanged = Math.abs(node.properties.width - oldStateNode.properties.width) > sizeTolerance;
+ const heightChanged = Math.abs(node.properties.height - oldStateNode.properties.height) > sizeTolerance;
+
+ node.sizeChanged = (widthChanged || heightChanged);
+
+ targets.push($el);
+
+ if (!node.isTarget) {
+ frozen.push($el);
+ if ((nodeHasChanged || node.sizeChanged) && parent && parent.isTarget && parent.isAnimated && parent.sizeChanged) {
+ animatedFrozen.push($el);
+ }
+ }
+ });
+
+ const defaults = {
+ ease: setValue(params.ease, this.ease),
+ duration: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).duration,
+ delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+
+ this.timeline = createTimeline({
+ onComplete: () => {
+ // Make sure to call .cancel() after restoreNodeInlineStyles(node); otehrwise the commited styles get reverted
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(node => {
+ restoreNodeVisualState(node);
+ restoreNodeInlineStyles(node);
});
- clones.push($clone);
+ for (let i = 0, l = transformed.length; i < l; i++) {
+ const $el = transformed[i];
+ $el.style.transform = newState.getValue($el, 'transform');
+ }
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ // Avoid CSS transitions at the end of the animation by restoring them on the next frame
+ requestAnimationFrame(() => {
+ if (this.root.classList.contains('is-animated')) return;
+ restoreLayoutTransition(this.transitionMuteStore);
+ });
+ },
+ onPause: () => {
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(restoreNodeVisualState);
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ },
+ composition: false,
+ defaults,
+ });
+
+ if (targets.length) {
+
+ this.root.classList.add('is-animated');
+
+ for (let i = 0, l = targets.length; i < l; i++) {
+ const $el = targets[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+
+ // Make sure to mute all CSS transition before applying the oldState styles back
+ muteNodeTransition(newNode);
+
+ // Don't animate dimensions and positions of inlined elements
+ if (!newNode.isInlined) {
+ // Display grid can mess with the absolute positioning, so set it to block during transition
+ // if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.display = 'block';
+ $el.style.display = 'block';
+ // All children must be in position absolue
+ if ($el !== root || this.absoluteCoords) {
+ $el.style.position = this.absoluteCoords ? 'fixed' : 'absolute';
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ $el.style.marginLeft = '0px';
+ $el.style.marginTop = '0px';
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ if ($el === root && newNode.measuredPosition === 'static') {
+ $el.style.position = 'relative';
+ // Cancel left / trop in case the static element had muted values now activated by potision relative
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ }
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ }
}
- parents.forEach(filterEmptyElements);
- for (let cloneIndex = 0, clonesLength = clones.length; cloneIndex < clonesLength; cloneIndex++) {
- processHTMLTemplate(lineTemplate, this.lines, clones[cloneIndex], linesFragment, lineType, this.debug, cloneIndex);
+
+ // Restore the scroll position if the oldState differs from the current state
+ if (oldState.scrollX !== window.scrollX || oldState.scrollY !== window.scrollY) {
+ // Restoring in the next frame avoids race conditions if for example a waapi animation commit styles that affect the root height
+ requestAnimationFrame(() => {
+ window.scrollTo(oldState.scrollX, oldState.scrollY);
+ });
}
- $el.innerHTML = '';
- $el.appendChild(linesFragment);
- if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
- if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
- }
- // Remove the word wrappers and clear the words array if lines split only
- if (this.linesOnly) {
- const words = this.words;
- let w = words.length;
- while (w--) {
- const $word = words[w];
- $word.replaceWith($word.textContent);
+
+ for (let i = 0, l = animated.length; i < l; i++) {
+ const $el = animated[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+ const newNodeState = newNode.properties;
+ let hasChanged = false;
+ const animatedProps = {
+ composition: 'none',
+ // delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+ if (!newNode.isInlined) {
+ if (oldNodeState.width !== newNodeState.width) {
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
+ hasChanged = true;
+ }
+ if (oldNodeState.height !== newNodeState.height) {
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
+ hasChanged = true;
+ }
+ // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
+ // Always animate translate
+ if (!newNode.hasTransform) {
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
+ hasChanged = true;
+ }
+ }
+ this.properties.forEach(prop => {
+ const oldVal = oldNodeState[prop];
+ const newVal = newNodeState[prop];
+ if (prop !== 'transform' && oldVal !== newVal) {
+ animatedProps[prop] = [oldVal, newVal];
+ hasChanged = true;
+ }
+ });
+ if (hasChanged) {
+ this.timeline.add($el, animatedProps, 0);
+ }
}
- words.length = 0;
+
}
- if (this.accessible && (canSplitLines || !isCached)) {
- const $accessible = doc.createElement('span');
- // Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
- $accessible.style.cssText = `position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;`;
- // $accessible.setAttribute('tabindex', '-1');
- $accessible.innerHTML = this.html;
- $el.insertBefore($accessible, $el.firstChild);
- this.lines.forEach(setAriaHidden);
- this.words.forEach(setAriaHidden);
- this.chars.forEach(setAriaHidden);
+
+ if (frozen.length) {
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const oldNode = oldState.nodes.get($el.dataset.layoutId);
+ if (!oldNode.isInlined) {
+ const oldNodeState = oldState.get($el);
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${oldState.getValue($el, prop)}`;
+ }
+ });
+ }
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const newNode = newState.nodes.get($el.dataset.layoutId);
+ const newNodeState = newState.get($el);
+ this.timeline.call(() => {
+ if (!newNode.isInlined) {
+ $el.style.width = `${newNodeState.width}px`;
+ $el.style.height = `${newNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${newNodeState.x}px ${newNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${newState.getValue($el, prop)}`;
+ }
+ });
+ }, newNode.delay + newNode.duration / 2);
+ }
+
+ if (animatedFrozen.length) {
+ const animatedFrozenParams = /** @type {AnimationParams} */({});
+ if (frozenParams) {
+ for (let prop in frozenParams) {
+ animatedFrozenParams[prop] = [
+ { from: (/** @type {HTMLElement} */$el) => oldState.getValue($el, prop), ease: 'in(1.75)', to: frozenParams[prop] },
+ { from: frozenParams[prop], to: (/** @type {HTMLElement} */$el) => newState.getValue($el, prop), ease: 'out(1.75)' }
+ ];
+ }
+ }
+ this.timeline.add(animatedFrozen, animatedFrozenParams, 0);
+ }
+
}
- this.width = /** @type {HTMLElement} */($el).offsetWidth;
- if (canSplitLines || clearCache) {
- this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
+
+ const transformedLength = transformed.length;
+
+ if (transformedLength) {
+ // We only need to set the transform property here since translate is alread defined the targets loop
+ for (let i = 0; i < transformedLength; i++) {
+ const $el = transformed[i];
+ $el.style.translate = `${oldState.get($el).x}px ${oldState.get($el).y}px`,
+ $el.style.transform = oldState.getValue($el, 'transform');
+ }
+ this.transformAnimation = waapi.animate(transformed, {
+ translate: (/** @type {HTMLElement} */$el) => `${newState.get($el).x}px ${newState.get($el).y}px`,
+ transform: (/** @type {HTMLElement} */$el) => newState.getValue($el, 'transform'),
+ autoplay: false,
+ persist: true,
+ ...defaults,
+ });
+ this.timeline.sync(this.transformAnimation, 0);
}
- return this;
+
+ return this.timeline.init();
}
- refresh() {
- this.split(true);
+ /**
+ * @param {(layout: this) => void} callback
+ * @param {LayoutAnimationParams} [params]
+ * @return {this}
+ */
+ update(callback, params = {}) {
+ this.record();
+ callback(this);
+ this.animate(params);
+ return this;
}
}
/**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- * @return {TextSplitter}
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ * @return {AutoLayout}
*/
-const splitText = (target, parameters) => new TextSplitter(target, parameters);
+const createLayout = (root, params) => new AutoLayout(root, params);
+
+// Chain-able utilities
+
+const numberUtils = numberImports; // Needed to keep the import when bundling
+
+const chainables = {};
/**
- * @deprecated text.split() is deprecated, import splitText() directly, or text.splitText()
+ * @callback UtilityFunction
+ * @param {...*} args
+ * @return {Number|String}
*
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- * @return {TextSplitter}
- */
-const split = (target, parameters) => {
- console.warn('text.split() is deprecated, import splitText() directly, or text.splitText()');
- return new TextSplitter(target, parameters);
+ * @param {UtilityFunction} fn
+ * @param {Number} [last=0]
+ * @return {function(...(Number|String)): function(Number|String): (Number|String)}
+ */
+const curry = (fn, last = 0) => (...args) => last ? v => fn(...args, v) : v => fn(v, ...args);
+
+/**
+ * @param {Function} fn
+ * @return {function(...(Number|String))}
+ */
+const chain = fn => {
+ return (...args) => {
+ const result = fn(...args);
+ return new Proxy(noop, {
+ apply: (_, __, [v]) => result(v),
+ get: (_, prop) => chain(/**@param {...Number|String} nextArgs */(...nextArgs) => {
+ const nextResult = chainables[prop](...nextArgs);
+ return (/**@type {Number|String} */v) => nextResult(result(v));
+ })
+ });
+ }
};
-var index = /*#__PURE__*/Object.freeze({
+/**
+ * @param {UtilityFunction} fn
+ * @param {String} name
+ * @param {Number} [right]
+ * @return {function(...(Number|String)): UtilityFunction}
+ */
+const makeChainable = (name, fn, right = 0) => {
+ const chained = (...args) => (args.length < fn.length ? chain(curry(fn, right)) : fn)(...args);
+ if (!chainables[name]) chainables[name] = chained;
+ return chained;
+};
+
+/**
+ * @typedef {Object} ChainablesMap
+ * @property {ChainedClamp} clamp
+ * @property {ChainedRound} round
+ * @property {ChainedSnap} snap
+ * @property {ChainedWrap} wrap
+ * @property {ChainedLerp} lerp
+ * @property {ChainedDamp} damp
+ * @property {ChainedMapRange} mapRange
+ * @property {ChainedRoundPad} roundPad
+ * @property {ChainedPadStart} padStart
+ * @property {ChainedPadEnd} padEnd
+ * @property {ChainedDegToRad} degToRad
+ * @property {ChainedRadToDeg} radToDeg
+ */
+
+/**
+ * @callback ChainedUtilsResult
+ * @param {Number} value - The value to process through the chained operations
+ * @return {Number} The processed result
+ */
+
+/**
+ * @typedef {ChainablesMap & ChainedUtilsResult} ChainableUtil
+ */
+
+// Chainable
+
+/**
+ * @callback ChainedRoundPad
+ * @param {Number} decimalLength - Number of decimal places
+ * @return {ChainableUtil}
+ */
+const roundPad = /** @type {typeof numberUtils.roundPad & ChainedRoundPad} */(makeChainable('roundPad', numberUtils.roundPad));
+
+/**
+ * @callback ChainedPadStart
+ * @param {Number} totalLength - Target length
+ * @param {String} padString - String to pad with
+ * @return {ChainableUtil}
+ */
+const padStart = /** @type {typeof numberUtils.padStart & ChainedPadStart} */(makeChainable('padStart', numberUtils.padStart));
+
+/**
+ * @callback ChainedPadEnd
+ * @param {Number} totalLength - Target length
+ * @param {String} padString - String to pad with
+ * @return {ChainableUtil}
+ */
+const padEnd = /** @type {typeof numberUtils.padEnd & ChainedPadEnd} */(makeChainable('padEnd', numberUtils.padEnd));
+
+/**
+ * @callback ChainedWrap
+ * @param {Number} min - Minimum boundary
+ * @param {Number} max - Maximum boundary
+ * @return {ChainableUtil}
+ */
+const wrap = /** @type {typeof numberUtils.wrap & ChainedWrap} */(makeChainable('wrap', numberUtils.wrap));
+
+/**
+ * @callback ChainedMapRange
+ * @param {Number} inLow - Input range minimum
+ * @param {Number} inHigh - Input range maximum
+ * @param {Number} outLow - Output range minimum
+ * @param {Number} outHigh - Output range maximum
+ * @return {ChainableUtil}
+ */
+const mapRange = /** @type {typeof numberUtils.mapRange & ChainedMapRange} */(makeChainable('mapRange', numberUtils.mapRange));
+
+/**
+ * @callback ChainedDegToRad
+ * @return {ChainableUtil}
+ */
+const degToRad = /** @type {typeof numberUtils.degToRad & ChainedDegToRad} */(makeChainable('degToRad', numberUtils.degToRad));
+
+/**
+ * @callback ChainedRadToDeg
+ * @return {ChainableUtil}
+ */
+const radToDeg = /** @type {typeof numberUtils.radToDeg & ChainedRadToDeg} */(makeChainable('radToDeg', numberUtils.radToDeg));
+
+/**
+ * @callback ChainedSnap
+ * @param {Number|Array<Number>} increment - Step size or array of snap points
+ * @return {ChainableUtil}
+ */
+const snap = /** @type {typeof numberUtils.snap & ChainedSnap} */(makeChainable('snap', numberUtils.snap));
+
+/**
+ * @callback ChainedClamp
+ * @param {Number} min - Minimum boundary
+ * @param {Number} max - Maximum boundary
+ * @return {ChainableUtil}
+ */
+const clamp = /** @type {typeof numberUtils.clamp & ChainedClamp} */(makeChainable('clamp', numberUtils.clamp));
+
+/**
+ * @callback ChainedRound
+ * @param {Number} decimalLength - Number of decimal places
+ * @return {ChainableUtil}
+ */
+const round = /** @type {typeof numberUtils.round & ChainedRound} */(makeChainable('round', numberUtils.round));
+
+/**
+ * @callback ChainedLerp
+ * @param {Number} start - Starting value
+ * @param {Number} end - Ending value
+ * @return {ChainableUtil}
+ */
+const lerp = /** @type {typeof numberUtils.lerp & ChainedLerp} */(makeChainable('lerp', numberUtils.lerp, 1));
+
+/**
+ * @callback ChainedDamp
+ * @param {Number} start - Starting value
+ * @param {Number} end - Target value
+ * @param {Number} deltaTime - Delta time in ms
+ * @return {ChainableUtil}
+ */
+const damp = /** @type {typeof numberUtils.damp & ChainedDamp} */(makeChainable('damp', numberUtils.damp, 1));
+
+/**
+ * Generate a random number between optional min and max (inclusive) and decimal precision
+ *
+ * @callback RandomNumberGenerator
+ * @param {Number} [min=0] - The minimum value (inclusive)
+ * @param {Number} [max=1] - The maximum value (inclusive)
+ * @param {Number} [decimalLength=0] - Number of decimal places to round to
+ * @return {Number} A random number between min and max
+ */
+
+/**
+ * Generates a random number between min and max (inclusive) with optional decimal precision
+ *
+ * @type {RandomNumberGenerator}
+ */
+const random = (min = 0, max = 1, decimalLength = 0) => {
+ const m = 10 ** decimalLength;
+ return Math.floor((Math.random() * (max - min + (1 / m)) + min) * m) / m;
+};
+
+let _seed = 0;
+
+/**
+ * Creates a seeded pseudorandom number generator function
+ *
+ * @param {Number} [seed] - The seed value for the random number generator
+ * @param {Number} [seededMin=0] - The minimum default value (inclusive) of the returned function
+ * @param {Number} [seededMax=1] - The maximum default value (inclusive) of the returned function
+ * @param {Number} [seededDecimalLength=0] - Default number of decimal places to round to of the returned function
+ * @return {RandomNumberGenerator} A function to generate a random number between optional min and max (inclusive) and decimal precision
+ */
+const createSeededRandom = (seed, seededMin = 0, seededMax = 1, seededDecimalLength = 0) => {
+ let t = seed === undefined ? _seed++ : seed;
+ return (min = seededMin, max = seededMax, decimalLength = seededDecimalLength) => {
+ t += 0x6D2B79F5;
+ t = Math.imul(t ^ t >>> 15, t | 1);
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
+ const m = 10 ** decimalLength;
+ return Math.floor(((((t ^ t >>> 14) >>> 0) / 4294967296) * (max - min + (1 / m)) + min) * m) / m;
+ }
+};
+
+/**
+ * Picks a random element from an array or a string
+ *
+ * @template T
+ * @param {String|Array<T>} items - The array or string to pick from
+ * @return {String|T} A random element from the array or character from the string
+ */
+const randomPick = items => items[random(0, items.length - 1)];
+
+/**
+ * Shuffles an array in-place using the Fisher-Yates algorithm
+ * Adapted from https://bost.ocks.org/mike/shuffle/
+ *
+ * @param {Array} items - The array to shuffle (will be modified in-place)
+ * @return {Array} The same array reference, now shuffled
+ */
+const shuffle = items => {
+ let m = items.length, t, i;
+ while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ return items;
+};
+
+
+
+
+
+/**
+ * @overload
+ * @param {Number} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<Number>}
+ */
+/**
+ * @overload
+ * @param {String} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<String>}
+ */
+/**
+ * @overload
+ * @param {[Number, Number]} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<Number>}
+ */
+/**
+ * @overload
+ * @param {[String, String]} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<String>}
+ */
+/**
+ * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
+ * @param {StaggerParams} [params] The stagger parameters
+ * @return {StaggerFunction<Number|String>}
+ */
+const stagger = (val, params = {}) => {
+ let values = [];
+ let maxValue = 0;
+ const from = params.from;
+ const reversed = params.reversed;
+ const ease = params.ease;
+ const hasEasing = !isUnd(ease);
+ const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
+ const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
+ const grid = params.grid;
+ const axis = params.axis;
+ const customTotal = params.total;
+ const fromFirst = isUnd(from) || from === 0 || from === 'first';
+ const fromCenter = from === 'center';
+ const fromLast = from === 'last';
+ const fromRandom = from === 'random';
+ const isRange = isArr(val);
+ const useProp = params.use;
+ const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
+ const val2 = isRange ? parseNumber(val[1]) : 0;
+ const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
+ const start = params.start || 0 + (isRange ? val1 : 0);
+ let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
+ return (target, i, t, tl) => {
+ const [ registeredTarget ] = registerTargets(target);
+ const total = isUnd(customTotal) ? t : customTotal;
+ const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
+ const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ if (fromCenter) fromIndex = (total - 1) / 2;
+ if (fromLast) fromIndex = total - 1;
+ if (!values.length) {
+ for (let index = 0; index < total; index++) {
+ if (!grid) {
+ values.push(abs(fromIndex - index));
+ } else {
+ const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
+ const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
+ const toX = index % grid[0];
+ const toY = floor(index / grid[0]);
+ const distanceX = fromX - toX;
+ const distanceY = fromY - toY;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ if (axis === 'x') value = -distanceX;
+ if (axis === 'y') value = -distanceY;
+ values.push(value);
+ }
+ maxValue = max(...values);
+ }
+ if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
+ if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
+ if (fromRandom) values = shuffle(values);
+ }
+ const spacing = isRange ? (val2 - val1) / maxValue : val1;
+ const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
+ /** @type {String|Number} */
+ let output = offset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
+ if (params.modifier) output = params.modifier(output);
+ if (unitMatch) output = `${output}${unitMatch[2]}`;
+ return output;
+ }
+};
+
+var index$2 = /*#__PURE__*/Object.freeze({
__proto__: null,
- TextSplitter: TextSplitter,
- split: split,
- splitText: splitText
+ $: registerTargets,
+ clamp: clamp,
+ cleanInlineStyles: cleanInlineStyles,
+ createSeededRandom: createSeededRandom,
+ damp: damp,
+ degToRad: degToRad,
+ get: get,
+ keepTime: keepTime,
+ lerp: lerp,
+ mapRange: mapRange,
+ padEnd: padEnd,
+ padStart: padStart,
+ radToDeg: radToDeg,
+ random: random,
+ randomPick: randomPick,
+ remove: remove,
+ round: round,
+ roundPad: roundPad,
+ set: set,
+ shuffle: shuffle,
+ snap: snap,
+ stagger: stagger,
+ sync: sync,
+ wrap: wrap
});
-
-
-
-
-/**
- * Converts an easing function into a valid CSS linear() timing function string
- * @param {EasingFunction} fn
- * @param {number} [samples=100]
- * @returns {string} CSS linear() timing function
- */
-const easingToLinear = (fn, samples = 100) => {
- const points = [];
- for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
- return `linear(${points.join(', ')})`;
-};
-
-const WAAPIEasesLookups = {};
-
/**
- * @param {EasingParam} ease
- * @return {String}
+ * @param {TargetsParam} path
+ * @return {SVGGeometryElement|void}
*/
-const parseWAAPIEasing = (ease) => {
- let parsedEase = WAAPIEasesLookups[ease];
- if (parsedEase) return parsedEase;
- parsedEase = 'linear';
- if (isStr(ease)) {
- if (
- stringStartsWith(ease, 'linear') ||
- stringStartsWith(ease, 'cubic-') ||
- stringStartsWith(ease, 'steps') ||
- stringStartsWith(ease, 'ease')
- ) {
- parsedEase = ease;
- } else if (stringStartsWith(ease, 'cubicB')) {
- parsedEase = toLowerCase(ease);
- } else {
- const parsed = parseEaseString(ease);
- if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
- }
- // Only cache string based easing name, otherwise function arguments get lost
- WAAPIEasesLookups[ease] = parsedEase;
- } else if (isFnc(ease)) {
- const easing = easingToLinear(ease);
- if (easing) parsedEase = easing;
- } else if (/** @type {Spring} */(ease).ease) {
- parsedEase = easingToLinear(/** @type {Spring} */(ease).ease);
- }
- return parsedEase;
+const getPath = path => {
+ const parsedTargets = parseTargets(path);
+ const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
+ if (!$parsedSvg || !isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
+ return $parsedSvg;
};
-const transformsShorthands = ['x', 'y', 'z'];
-const commonDefaultPXProperties = [
- 'perspective',
- 'width',
- 'height',
- 'margin',
- 'padding',
- 'top',
- 'right',
- 'bottom',
- 'left',
- 'borderWidth',
- 'fontSize',
- 'borderRadius',
- ...transformsShorthands
-];
-const validIndividualTransforms = /*#__PURE__*/ (() => [...transformsShorthands, ...validTransforms.filter(t => ['X', 'Y', 'Z'].some(axis => t.endsWith(axis)))])();
-let transformsPropertiesRegistered = null;
+// Motion path animation
/**
- * @param {String} propName
- * @param {WAAPIKeyframeValue} value
- * @param {DOMTarget} $el
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {String}
+ * @param {SVGGeometryElement} $path
+ * @param {Number} totalLength
+ * @param {Number} progress
+ * @param {Number} lookup
+ * @param {Boolean} shouldClamp
+ * @return {DOMPoint}
*/
-const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
- let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
- if (!isNum(v)) return v;
- if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
- if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
- return `${v}`;
+const getPathPoint = ($path, totalLength, progress, lookup, shouldClamp) => {
+ const point = progress + lookup;
+ const pointOnPath = shouldClamp
+ ? Math.max(0, Math.min(point, totalLength)) // Clamp between 0 and totalLength
+ : (point % totalLength + totalLength) % totalLength; // Wrap around
+ return $path.getPointAtLength(pointOnPath);
};
/**
- * @param {DOMTarget} $el
- * @param {String} propName
- * @param {WAAPIKeyframeValue} from
- * @param {WAAPIKeyframeValue} to
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {WAAPITweenValue}
+ * @param {SVGGeometryElement} $path
+ * @param {String} pathProperty
+ * @param {Number} [offset=0]
+ * @return {FunctionValue}
*/
-const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
- /** @type {WAAPITweenValue} */
- let tweenValue = '0';
- const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
- if (!isUnd(from)) {
- const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
- tweenValue = [computedFrom, computedTo];
- } else {
- tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
+const getPathProgess = ($path, pathProperty, offset = 0) => {
+ return $el => {
+ const totalLength = +($path.getTotalLength());
+ const inSvg = $el[isSvgSymbol];
+ const ctm = $path.getCTM();
+ const shouldClamp = offset === 0;
+ /** @type {TweenObjectValue} */
+ return {
+ from: 0,
+ to: totalLength,
+ /** @type {TweenModifier} */
+ modifier: progress => {
+ const offsetLength = offset * totalLength;
+ const newProgress = progress + offsetLength;
+ if (pathProperty === 'a') {
+ const p0 = getPathPoint($path, totalLength, newProgress, -1, shouldClamp);
+ const p1 = getPathPoint($path, totalLength, newProgress, 1, shouldClamp);
+ return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
+ } else {
+ const p = getPathPoint($path, totalLength, newProgress, 0, shouldClamp);
+ return pathProperty === 'x' ?
+ inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
+ inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
+ }
+ }
+ }
}
- return tweenValue;
};
-class WAAPIAnimation {
/**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
+ * @param {TargetsParam} path
+ * @param {Number} [offset=0]
*/
- constructor(targets, params) {
-
- if (scope.current) scope.current.register(this);
-
- // Skip the registration and fallback to no animation in case CSS.registerProperty is not supported
- if (isNil(transformsPropertiesRegistered)) {
- if (isBrowser && (isUnd(CSS) || !Object.hasOwnProperty.call(CSS, 'registerProperty'))) {
- transformsPropertiesRegistered = false;
- } else {
- validTransforms.forEach(t => {
- const isSkew = stringStartsWith(t, 'skew');
- const isScale = stringStartsWith(t, 'scale');
- const isRotate = stringStartsWith(t, 'rotate');
- const isTranslate = stringStartsWith(t, 'translate');
- const isAngle = isRotate || isSkew;
- const syntax = isAngle ? '<angle>' : isScale ? "<number>" : isTranslate ? "<length-percentage>" : "*";
- try {
- CSS.registerProperty({
- name: '--' + t,
- syntax,
- inherits: false,
- initialValue: isTranslate ? '0px' : isAngle ? '0deg' : isScale ? '1' : '0',
- });
- } catch {} });
- transformsPropertiesRegistered = true;
- }
- }
-
- const parsedTargets = registerTargets(targets);
- const targetsLength = parsedTargets.length;
-
- if (!targetsLength) {
- console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
- }
-
- const ease = setValue(params.ease, parseWAAPIEasing(globals.defaults.ease));
- const spring = /** @type {Spring} */(ease).ease && ease;
- const autoplay = setValue(params.autoplay, globals.defaults.autoplay);
- const scroll = autoplay && /** @type {ScrollObserver} */(autoplay).link ? autoplay : false;
- const alternate = params.alternate && /** @type {Boolean} */(params.alternate) === true;
- const reversed = params.reversed && /** @type {Boolean} */(params.reversed) === true;
- const loop = setValue(params.loop, globals.defaults.loop);
- const iterations = /** @type {Number} */((loop === true || loop === Infinity) ? Infinity : isNum(loop) ? loop + 1 : 1);
- /** @type {PlaybackDirection} */
- const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
- /** @type {FillMode} */
- const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
- /** @type {String} */
- const easing = parseWAAPIEasing(ease);
- const timeScale = (globals.timeScale === 1 ? 1 : K);
-
- /** @type {DOMTargetsArray}] */
- this.targets = parsedTargets;
- /** @type {Array<globalThis.Animation>}] */
- this.animations = [];
- /** @type {globalThis.Animation}] */
- this.controlAnimation = null;
- /** @type {Callback<this>} */
- this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
- /** @type {Number} */
- this.duration = 0;
- /** @type {Boolean} */
- this.muteCallbacks = false;
- /** @type {Boolean} */
- this.completed = false;
- /** @type {Boolean} */
- this.paused = !autoplay || scroll !== false;
- /** @type {Boolean} */
- this.reversed = reversed;
- /** @type {Boolean} */
- this.persist = setValue(params.persist, globals.defaults.persist);
- /** @type {Boolean|ScrollObserver} */
- this.autoplay = autoplay;
- /** @type {Number} */
- this._speed = setValue(params.playbackRate, globals.defaults.playbackRate);
- /** @type {Function} */
- this._resolve = noop; // Used by .then()
- /** @type {Number} */
- this._completed = 0;
- /** @type {Array.<Object>} */
- this._inlineStyles = [];
-
- parsedTargets.forEach(($el, i) => {
+const createMotionPath = (path, offset = 0) => {
+ const $path = getPath(path);
+ if (!$path) return;
+ return {
+ translateX: getPathProgess($path, 'x', offset),
+ translateY: getPathProgess($path, 'y', offset),
+ rotate: getPathProgess($path, 'a', offset),
+ }
+};
- const cachedTransforms = $el[transformsSymbol];
- const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
- const elStyle = $el.style;
- const inlineStyles = this._inlineStyles[i] = {};
- /** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- const composite = /** @type {CompositeOperation} */(setValue(params.composition, 'replace'));
- for (let name in params) {
- if (!isKey(name)) continue;
- /** @type {PropertyIndexedKeyframes} */
- const keyframes = {};
- /** @type {KeyframeAnimationOptions} */
- const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
- const propertyValue = params[name];
- const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+/**
+ * @param {SVGGeometryElement} [$el]
+ * @return {Number}
+ */
+const getScaleFactor = $el => {
+ let scaleFactor = 1;
+ if ($el && $el.getCTM) {
+ const ctm = $el.getCTM();
+ if (ctm) {
+ const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
+ const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
+ scaleFactor = (scaleX + scaleY) / 2;
+ }
+ }
+ return scaleFactor;
+};
- const styleName = individualTransformProperty ? 'transform' : name;
- if (!inlineStyles[styleName]) {
- inlineStyles[styleName] = elStyle[styleName];
- }
+/**
+ * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
+ * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
+ * @param {number} start - Starting position (0-1)
+ * @param {number} end - Ending position (0-1)
+ * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
+ */
+const createDrawableProxy = ($el, start, end) => {
+ const pathLength = K;
+ const computedStyles = getComputedStyle($el);
+ const strokeLineCap = computedStyles.strokeLinecap;
+ // @ts-ignore
+ const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
+ let currentCap = strokeLineCap;
- let parsedPropertyValue;
- if (isObj(propertyValue)) {
- const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
- const tweenOptionsEase = setValue(tweenOptions.ease, ease);
- const tweenOptionsSpring = /** @type {Spring} */(tweenOptionsEase).ease && tweenOptionsEase;
- const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
- const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
- /** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- tweenParams.composite = /** @type {CompositeOperation} */(setValue(tweenOptions.composition, composite));
- /** @type {String} */
- tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
- parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- } else {
- keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- if (!isUnd(from)) {
- if (!individualTransformProperty) {
- elStyle[name] = keyframes[name][0];
- } else {
- const key = `--${individualTransformProperty}`;
- elStyle.setProperty(key, keyframes[key][0]);
+ const proxy = new Proxy($el, {
+ get(target, property) {
+ const value = target[property];
+ if (property === proxyTargetSymbol) return target;
+ if (property === 'setAttribute') {
+ return (...args) => {
+ if (args[0] === 'draw') {
+ const value = args[1];
+ const values = value.split(' ');
+ const v1 = +values[0];
+ const v2 = +values[1];
+ // TOTO: Benchmark if performing two slices is more performant than one split
+ // const spaceIndex = value.indexOf(' ');
+ // const v1 = round(+value.slice(0, spaceIndex), precision);
+ // const v2 = round(+value.slice(spaceIndex + 1), precision);
+ const scaleFactor = getScaleFactor($scalled);
+ const os = v1 * -pathLength * scaleFactor;
+ const d1 = (v2 * pathLength * scaleFactor) + os;
+ const d2 = (pathLength * scaleFactor +
+ ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
+ if (strokeLineCap !== 'butt') {
+ const newCap = v1 === v2 ? 'butt' : strokeLineCap;
+ if (currentCap !== newCap) {
+ target.style.strokeLinecap = `${newCap}`;
+ currentCap = newCap;
+ }
}
+ target.setAttribute('stroke-dashoffset', `${os}`);
+ target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
}
- } else {
- parsedPropertyValue = isArr(propertyValue) ?
- propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
- normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- } else {
- keyframes[name] = parsedPropertyValue;
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- }
- }
- if (hasIndividualTransforms) {
- let transforms = emptyString;
- for (let t in cachedTransforms) {
- transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
- }
- elStyle.transform = transforms;
+ return Reflect.apply(value, target, args);
+ };
}
- });
- if (scroll) {
- /** @type {ScrollObserver} */(this.autoplay).link(this);
+ if (isFnc(value)) {
+ return (...args) => Reflect.apply(value, target, args);
+ } else {
+ return value;
+ }
}
+ });
+
+ if ($el.getAttribute('pathLength') !== `${pathLength}`) {
+ $el.setAttribute('pathLength', `${pathLength}`);
+ proxy.setAttribute('draw', `${start} ${end}`);
}
- /**
- * @callback forEachCallback
- * @param {globalThis.Animation} animation
- */
+ return /** @type {DrawableSVGGeometry} */(proxy);
+};
- /**
- * @param {forEachCallback|String} callback
- * @return {this}
- */
- forEach(callback) {
- const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
- this.animations.forEach(cb);
- return this;
- }
+/**
+ * Creates drawable proxies for multiple SVG elements.
+ * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
+ * @param {number} [start=0] - Starting position (0-1)
+ * @param {number} [end=0] - Ending position (0-1)
+ * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
+ */
+const createDrawable = (selector, start = 0, end = 0) => {
+ const els = parseTargets(selector);
+ return els.map($el => createDrawableProxy(
+ /** @type {SVGGeometryElement} */($el),
+ start,
+ end
+ ));
+};
- get speed() {
- return this._speed;
- }
- set speed(speed) {
- this._speed = +speed;
- this.forEach(anim => anim.playbackRate = speed);
- }
- get currentTime() {
- const controlAnimation = this.controlAnimation;
- const timeScale = globals.timeScale;
- return this.completed ? this.duration : controlAnimation ? +controlAnimation.currentTime * (timeScale === 1 ? 1 : timeScale) : 0;
+/**
+ * @param {TargetsParam} path2
+ * @param {Number} [precision]
+ * @return {FunctionValue}
+ */
+const morphTo = (path2, precision = .33) => ($path1) => {
+ const tagName1 = ($path1.tagName || '').toLowerCase();
+ if (!tagName1.match(/^(path|polygon|polyline)$/)) {
+ throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
+ }
+ const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
+ if (!$path2) {
+ throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
+ }
+ const tagName2 = ($path2.tagName || '').toLowerCase();
+ if (!tagName2.match(/^(path|polygon|polyline)$/)) {
+ throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
}
+ const isPath = $path1.tagName === 'path';
+ const separator = isPath ? ' ' : ',';
+ const previousPoints = $path1[morphPointsSymbol];
+ if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
- set currentTime(time) {
- const t = time * (globals.timeScale === 1 ? 1 : K);
- this.forEach(anim => {
- // Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
- // The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
- // https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- // This is not needed for persisting animations since they never finish.
- if (!this.persist && t >= this.duration) anim.play();
- anim.currentTime = t;
- });
+ let v1 = '', v2 = '';
+
+ if (!precision) {
+ v1 = $path1.getAttribute(isPath ? 'd' : 'points');
+ v2 = $path2.getAttribute(isPath ? 'd' : 'points');
+ } else {
+ const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
+ const length2 = $path2.getTotalLength();
+ const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
+ for (let i = 0; i < maxPoints; i++) {
+ const t = i / (maxPoints - 1);
+ const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
+ const pointOnPath2 = $path2.getPointAtLength(length2 * t);
+ const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
+ v1 += prefix + round$1(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
+ v2 += prefix + round$1(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
+ }
}
- get progress() {
- return this.currentTime / this.duration;
- }
+ $path1[morphPointsSymbol] = v2;
+
+ return [v1, v2];
+};
+
+var index$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ createDrawable: createDrawable,
+ createMotionPath: createMotionPath,
+ morphTo: morphTo
+});
+
+
+
+const segmenter = (typeof Intl !== 'undefined') && Intl.Segmenter;
+const valueRgx = /\{value\}/g;
+const indexRgx = /\{i\}/g;
+const whiteSpaceGroupRgx = /(\s+)/;
+const whiteSpaceRgx = /^\s+$/;
+const lineType = 'line';
+const wordType = 'word';
+const charType = 'char';
+const dataLine = `data-line`;
+
+/**
+ * @typedef {Object} Segment
+ * @property {String} segment
+ * @property {Boolean} [isWordLike]
+ */
- set progress(progress) {
- this.forEach(anim => anim.currentTime = progress * this.duration || 0);
- }
+/**
+ * @typedef {Object} Segmenter
+ * @property {function(String): Iterable<Segment>} segment
+ */
- resume() {
- if (!this.paused) return this;
- this.paused = false;
- // TODO: Store the current time, and seek back to the last position
- return this.forEach('play');
- }
+/** @type {Segmenter} */
+let wordSegmenter = null;
+/** @type {Segmenter} */
+let graphemeSegmenter = null;
+let $splitTemplate = null;
- pause() {
- if (this.paused) return this;
- this.paused = true;
- return this.forEach('pause');
- }
+/**
+ * @param {Segment} seg
+ * @return {Boolean}
+ */
+const isSegmentWordLike = seg => {
+ return seg.isWordLike ||
+ seg.segment === ' ' || // Consider spaces as words first, then handle them diffrently later
+ isNum(+seg.segment); // Safari doesn't considers numbers as words
+};
- alternate() {
- this.reversed = !this.reversed;
- this.forEach('reverse');
- if (this.paused) this.forEach('pause');
- return this;
- }
+/**
+ * @param {HTMLElement} $el
+ */
+const setAriaHidden = $el => $el.setAttribute('aria-hidden', 'true');
- play() {
- if (this.reversed) this.alternate();
- return this.resume();
- }
+/**
+ * @param {DOMTarget} $el
+ * @param {String} type
+ * @return {Array<HTMLElement>}
+ */
+const getAllTopLevelElements = ($el, type) => [.../** @type {*} */($el.querySelectorAll(`[data-${type}]:not([data-${type}] [data-${type}])`))];
- reverse() {
- if (!this.reversed) this.alternate();
- return this.resume();
+const debugColors = { line: '#00D672', word: '#FF4B4B', char: '#5A87FF' };
+
+/**
+ * @param {HTMLElement} $el
+ */
+const filterEmptyElements = $el => {
+ if (!$el.childElementCount && !$el.textContent.trim()) {
+ const $parent = $el.parentElement;
+ $el.remove();
+ if ($parent) filterEmptyElements($parent);
}
+};
- /**
- * @param {Number} time
- * @param {Boolean} muteCallbacks
- */
- seek(time, muteCallbacks = false) {
- if (muteCallbacks) this.muteCallbacks = true;
- if (time < this.duration) this.completed = false;
- this.currentTime = time;
- this.muteCallbacks = false;
- if (this.paused) this.pause();
- return this;
+/**
+ * @param {HTMLElement} $el
+ * @param {Number} lineIndex
+ * @param {Set<HTMLElement|Node>} bin
+ * @returns {Set<HTMLElement|Node>}
+ */
+const filterLineElements = ($el, lineIndex, bin) => {
+ const dataLineAttr = $el.getAttribute(dataLine);
+ if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') {
+ bin.add($el);
+ // Also remove adjacent whitespace-only text nodes
+ const prev = $el.previousSibling;
+ const next = $el.nextSibling;
+ if (prev && prev.nodeType === 3 && whiteSpaceRgx.test(prev.textContent)) {
+ bin.add(prev);
+ }
+ if (next && next.nodeType === 3 && whiteSpaceRgx.test(next.textContent)) {
+ bin.add(next);
+ }
}
+ let i = $el.childElementCount;
+ while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
+ return bin;
+};
- restart() {
- this.completed = false;
- return this.seek(0, true).resume();
+/**
+ * @param {'line'|'word'|'char'} type
+ * @param {SplitTemplateParams} params
+ * @return {String}
+ */
+const generateTemplate = (type, params = {}) => {
+ let template = ``;
+ const classString = isStr(params.class) ? ` class="${params.class}"` : '';
+ const cloneType = setValue(params.clone, false);
+ const wrapType = setValue(params.wrap, false);
+ const overflow = wrapType ? wrapType === true ? 'clip' : wrapType : cloneType ? 'clip' : false;
+ if (wrapType) template += `<span${overflow ? ` style="overflow:${overflow};"` : ''}>`;
+ template += `<span${classString}${cloneType ? ` style="position:relative;"` : ''} data-${type}="{i}">`;
+ if (cloneType) {
+ const left = cloneType === 'left' ? '-100%' : cloneType === 'right' ? '100%' : '0';
+ const top = cloneType === 'top' ? '-100%' : cloneType === 'bottom' ? '100%' : '0';
+ template += `<span>{value}</span>`;
+ template += `<span inert style="position:absolute;top:${top};left:${left};white-space:nowrap;">{value}</span>`;
+ } else {
+ template += `{value}`;
}
+ template += `</span>`;
+ if (wrapType) template += `</span>`;
+ return template;
+};
- commitStyles() {
- return this.forEach('commitStyles');
+/**
+ * @param {String|SplitFunctionValue} htmlTemplate
+ * @param {Array<HTMLElement>} store
+ * @param {Node|HTMLElement} node
+ * @param {DocumentFragment} $parentFragment
+ * @param {'line'|'word'|'char'} type
+ * @param {Boolean} debug
+ * @param {Number} lineIndex
+ * @param {Number} [wordIndex]
+ * @param {Number} [charIndex]
+ * @return {HTMLElement}
+ */
+const processHTMLTemplate = (htmlTemplate, store, node, $parentFragment, type, debug, lineIndex, wordIndex, charIndex) => {
+ const isLine = type === lineType;
+ const isChar = type === charType;
+ const className = `_${type}_`;
+ const template = isFnc(htmlTemplate) ? htmlTemplate(node) : htmlTemplate;
+ const displayStyle = isLine ? 'block' : 'inline-block';
+ $splitTemplate.innerHTML = template
+ .replace(valueRgx, `<i class="${className}"></i>`)
+ .replace(indexRgx, `${isChar ? charIndex : isLine ? lineIndex : wordIndex}`);
+ const $content = $splitTemplate.content;
+ const $highestParent = /** @type {HTMLElement} */($content.firstElementChild);
+ const $split = /** @type {HTMLElement} */($content.querySelector(`[data-${type}]`)) || $highestParent;
+ const $replacables = /** @type {NodeListOf<HTMLElement>} */($content.querySelectorAll(`i.${className}`));
+ const replacablesLength = $replacables.length;
+ if (replacablesLength) {
+ $highestParent.style.display = displayStyle;
+ $split.style.display = displayStyle;
+ $split.setAttribute(dataLine, `${lineIndex}`);
+ if (!isLine) {
+ $split.setAttribute('data-word', `${wordIndex}`);
+ if (isChar) $split.setAttribute('data-char', `${charIndex}`);
+ }
+ let i = replacablesLength;
+ while (i--) {
+ const $replace = $replacables[i];
+ const $closestParent = $replace.parentElement;
+ $closestParent.style.display = displayStyle;
+ if (isLine) {
+ $closestParent.innerHTML = /** @type {HTMLElement} */(node).innerHTML;
+ } else {
+ $closestParent.replaceChild(node.cloneNode(true), $replace);
+ }
+ }
+ store.push($split);
+ $parentFragment.appendChild($content);
+ } else {
+ console.warn(`The expression "{value}" is missing from the provided template.`);
}
+ if (debug) $highestParent.style.outline = `1px dotted ${debugColors[type]}`;
+ return $highestParent;
+};
- complete() {
- return this.seek(this.duration);
+/**
+ * A class that splits text into words and wraps them in span elements while preserving the original HTML structure.
+ * @class
+ */
+class TextSplitter {
+ /**
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ */
+ constructor(target, parameters = {}) {
+ // Only init segmenters when needed
+ if (!wordSegmenter) wordSegmenter = segmenter ? new segmenter([], { granularity: wordType }) : {
+ segment: (text) => {
+ const segments = [];
+ const words = text.split(whiteSpaceGroupRgx);
+ for (let i = 0, l = words.length; i < l; i++) {
+ const segment = words[i];
+ segments.push({
+ segment,
+ isWordLike: !whiteSpaceRgx.test(segment), // Consider non-whitespace as word-like
+ });
+ }
+ return segments;
+ }
+ };
+ if (!graphemeSegmenter) graphemeSegmenter = segmenter ? new segmenter([], { granularity: 'grapheme' }) : {
+ segment: text => [...text].map(char => ({ segment: char }))
+ };
+ if (!$splitTemplate && isBrowser) $splitTemplate = doc.createElement('template');
+ if (scope.current) scope.current.register(this);
+ const { words, chars, lines, accessible, includeSpaces, debug } = parameters;
+ const $target = /** @type {HTMLElement} */((target = isArr(target) ? target[0] : target) && /** @type {Node} */(target).nodeType ? target : (getNodeList(target) || [])[0]);
+ const lineParams = lines === true ? {} : lines;
+ const wordParams = words === true || isUnd(words) ? {} : words;
+ const charParams = chars === true ? {} : chars;
+ this.debug = setValue(debug, false);
+ this.includeSpaces = setValue(includeSpaces, false);
+ this.accessible = setValue(accessible, true);
+ this.linesOnly = lineParams && (!wordParams && !charParams);
+ /** @type {String|false|SplitFunctionValue} */
+ this.lineTemplate = isObj(lineParams) ? generateTemplate(lineType, /** @type {SplitTemplateParams} */(lineParams)) : lineParams;
+ /** @type {String|false|SplitFunctionValue} */
+ this.wordTemplate = isObj(wordParams) || this.linesOnly ? generateTemplate(wordType, /** @type {SplitTemplateParams} */(wordParams)) : wordParams;
+ /** @type {String|false|SplitFunctionValue} */
+ this.charTemplate = isObj(charParams) ? generateTemplate(charType, /** @type {SplitTemplateParams} */(charParams)) : charParams;
+ this.$target = $target;
+ this.html = $target && $target.innerHTML;
+ this.lines = [];
+ this.words = [];
+ this.chars = [];
+ this.effects = [];
+ this.effectsCleanups = [];
+ this.cache = null;
+ this.ready = false;
+ this.width = 0;
+ this.resizeTimeout = null;
+ const handleSplit = () => this.html && (lineParams || wordParams || charParams) && this.split();
+ // Make sure this is declared before calling handleSplit() in case revert() is called inside an effect callback
+ this.resizeObserver = new ResizeObserver(() => {
+ // Use a setTimeout instead of a Timer for better tree shaking
+ clearTimeout(this.resizeTimeout);
+ this.resizeTimeout = setTimeout(() => {
+ const currentWidth = /** @type {HTMLElement} */($target).offsetWidth;
+ if (currentWidth === this.width) return;
+ this.width = currentWidth;
+ handleSplit();
+ }, 150);
+ });
+ // Only declare the font ready promise when splitting by lines and not alreay split
+ if (this.lineTemplate && !this.ready) {
+ doc.fonts.ready.then(handleSplit);
+ } else {
+ handleSplit();
+ }
+ $target ? this.resizeObserver.observe($target) : console.warn('No Text Splitter target found.');
}
- cancel() {
- this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
- return this.commitStyles().forEach('cancel');
+ /**
+ * @param {(...args: any[]) => Tickable | (() => void)} effect
+ * @return this
+ */
+ addEffect(effect) {
+ if (!isFnc(effect)) return console.warn('Effect must return a function.');
+ const refreshableEffect = keepTime(effect);
+ this.effects.push(refreshableEffect);
+ if (this.ready) this.effectsCleanups[this.effects.length - 1] = refreshableEffect(this);
+ return this;
}
revert() {
- // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
- // This means if you have multiple animations animating different transforms on the same target,
- // reverting one of them will also override the transform property of the other animations.
- // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
- // and update the CSS variables with the orignal value
- this.cancel().targets.forEach(($el, i) => {
- const targetStyle = $el.style;
- const targetInlineStyles = this._inlineStyles[i];
- for (let name in targetInlineStyles) {
- const originalInlinedValue = targetInlineStyles[name];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(toLowerCase(name));
- } else {
- targetStyle[name] = originalInlinedValue;
- }
- }
- // Remove style attribute if empty
- if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
- });
+ clearTimeout(this.resizeTimeout);
+ this.lines.length = this.words.length = this.chars.length = 0;
+ this.resizeObserver.disconnect();
+ // Make sure to revert the effects after disconnecting the resizeObserver to avoid triggering it in the process
+ this.effectsCleanups.forEach(cleanup => isFnc(cleanup) ? cleanup(this) : cleanup.revert && cleanup.revert());
+ this.$target.innerHTML = this.html;
return this;
}
/**
- * @typedef {this & {then: null}} ResolvedWAAPIAnimation
+ * Recursively processes a node and its children
+ * @param {Node} node
*/
+ splitNode(node) {
+ const wordTemplate = this.wordTemplate;
+ const charTemplate = this.charTemplate;
+ const includeSpaces = this.includeSpaces;
+ const debug = this.debug;
+ const nodeType = node.nodeType;
+ if (nodeType === 3) {
+ const nodeText = node.nodeValue;
+ // If the nodeText is only whitespace, leave it as is
+ if (nodeText.trim()) {
+ const tempWords = [];
+ const words = this.words;
+ const chars = this.chars;
+ const wordSegments = wordSegmenter.segment(nodeText);
+ const $wordsFragment = doc.createDocumentFragment();
+ let prevSeg = null;
+ for (const wordSegment of wordSegments) {
+ const segment = wordSegment.segment;
+ const isWordLike = isSegmentWordLike(wordSegment);
+ // Determine if this segment should be a new word, first segment always becomes a new word
+ if (!prevSeg || (isWordLike && (prevSeg && (isSegmentWordLike(prevSeg))))) {
+ tempWords.push(segment);
+ } else {
+ // Only concatenate if both current and previous are non-word-like and don't contain spaces
+ const lastWordIndex = tempWords.length - 1;
+ const lastWord = tempWords[lastWordIndex];
+ if (!whiteSpaceGroupRgx.test(lastWord) && !whiteSpaceGroupRgx.test(segment)) {
+ tempWords[lastWordIndex] += segment;
+ } else {
+ tempWords.push(segment);
+ }
+ }
+ prevSeg = wordSegment;
+ }
+
+ for (let i = 0, l = tempWords.length; i < l; i++) {
+ const word = tempWords[i];
+ if (!word.trim()) {
+ // Preserve whitespace only if includeSpaces is false and if the current space is not the first node
+ if (i && includeSpaces) continue;
+ $wordsFragment.appendChild(doc.createTextNode(word));
+ } else {
+ const nextWord = tempWords[i + 1];
+ const hasWordFollowingSpace = includeSpaces && nextWord && !nextWord.trim();
+ const wordToProcess = word;
+ const charSegments = charTemplate ? graphemeSegmenter.segment(wordToProcess) : null;
+ const $charsFragment = charTemplate ? doc.createDocumentFragment() : doc.createTextNode(hasWordFollowingSpace ? word + '\xa0' : word);
+ if (charTemplate) {
+ const charSegmentsArray = [...charSegments];
+ for (let j = 0, jl = charSegmentsArray.length; j < jl; j++) {
+ const charSegment = charSegmentsArray[j];
+ const isLastChar = j === jl - 1;
+ // If this is the last character and includeSpaces is true with a following space, append the space
+ const charText = isLastChar && hasWordFollowingSpace ? charSegment.segment + '\xa0' : charSegment.segment;
+ const $charNode = doc.createTextNode(charText);
+ processHTMLTemplate(charTemplate, chars, $charNode, /** @type {DocumentFragment} */($charsFragment), charType, debug, -1, words.length, chars.length);
+ }
+ }
+ if (wordTemplate) {
+ processHTMLTemplate(wordTemplate, words, $charsFragment, $wordsFragment, wordType, debug, -1, words.length, chars.length);
+ // Chars elements must be re-parsed in the split() method if both words and chars are parsed
+ } else if (charTemplate) {
+ $wordsFragment.appendChild($charsFragment);
+ } else {
+ $wordsFragment.appendChild(doc.createTextNode(word));
+ }
+ // Skip the next iteration if we included a space
+ if (hasWordFollowingSpace) i++;
+ }
+ }
+ node.parentNode.replaceChild($wordsFragment, node);
+ }
+ } else if (nodeType === 1) {
+ // Converting to an array is necessary to work around childNodes pottential mutation
+ const childNodes = /** @type {Array<Node>} */([.../** @type {*} */(node.childNodes)]);
+ for (let i = 0, l = childNodes.length; i < l; i++) this.splitNode(childNodes[i]);
+ }
+ }
/**
- * @param {Callback<ResolvedWAAPIAnimation>} [callback]
- * @return Promise<this>
+ * @param {Boolean} clearCache
+ * @return {this}
*/
- then(callback = noop) {
- const then = this.then;
- const onResolve = () => {
- this.then = null;
- callback(/** @type {ResolvedWAAPIAnimation} */(this));
- this.then = then;
- this._resolve = noop;
- };
- return new Promise(r => {
- this._resolve = () => r(onResolve());
- if (this.completed) this._resolve();
- return this;
- });
+ split(clearCache = false) {
+ const $el = this.$target;
+ const isCached = !!this.cache && !clearCache;
+ const lineTemplate = this.lineTemplate;
+ const wordTemplate = this.wordTemplate;
+ const charTemplate = this.charTemplate;
+ const fontsReady = doc.fonts.status !== 'loading';
+ const canSplitLines = lineTemplate && fontsReady;
+ this.ready = !lineTemplate || fontsReady;
+ if (canSplitLines || clearCache) {
+ // No need to revert effects animations here since it's already taken care by the refreshable
+ this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
+ }
+ if (!isCached) {
+ if (clearCache) {
+ $el.innerHTML = this.html;
+ this.words.length = this.chars.length = 0;
+ }
+ this.splitNode($el);
+ this.cache = $el.innerHTML;
+ }
+ if (canSplitLines) {
+ if (isCached) $el.innerHTML = this.cache;
+ this.lines.length = 0;
+ if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
+ }
+ // Always reparse characters after a line reset or if both words and chars are activated
+ if (charTemplate && (canSplitLines || wordTemplate)) {
+ this.chars = getAllTopLevelElements($el, charType);
+ }
+ // Words are used when lines only and prioritized over chars
+ const elementsArray = this.words.length ? this.words : this.chars;
+ let y, linesCount = 0;
+ for (let i = 0, l = elementsArray.length; i < l; i++) {
+ const $el = elementsArray[i];
+ const { top, height } = $el.getBoundingClientRect();
+ if (!isUnd(y) && top - y > height * .5) linesCount++;
+ $el.setAttribute(dataLine, `${linesCount}`);
+ const nested = $el.querySelectorAll(`[${dataLine}]`);
+ let c = nested.length;
+ while (c--) nested[c].setAttribute(dataLine, `${linesCount}`);
+ y = top;
+ }
+ if (canSplitLines) {
+ const linesFragment = doc.createDocumentFragment();
+ const parents = new Set();
+ const clones = [];
+ for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
+ const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
+ filterLineElements($clone, lineIndex, new Set()).forEach($el => {
+ const $parent = $el.parentNode;
+ if ($parent) {
+ if ($el.nodeType === 1) parents.add(/** @type {HTMLElement} */($parent));
+ $parent.removeChild($el);
+ }
+ });
+ clones.push($clone);
+ }
+ parents.forEach(filterEmptyElements);
+ for (let cloneIndex = 0, clonesLength = clones.length; cloneIndex < clonesLength; cloneIndex++) {
+ processHTMLTemplate(lineTemplate, this.lines, clones[cloneIndex], linesFragment, lineType, this.debug, cloneIndex);
+ }
+ $el.innerHTML = '';
+ $el.appendChild(linesFragment);
+ if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
+ if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
+ }
+
+ // Remove the word wrappers and clear the words array if lines split only
+ if (this.linesOnly) {
+ const words = this.words;
+ let w = words.length;
+ while (w--) {
+ const $word = words[w];
+ $word.replaceWith($word.textContent);
+ }
+ words.length = 0;
+ }
+ if (this.accessible && (canSplitLines || !isCached)) {
+ const $accessible = doc.createElement('span');
+ // Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
+ $accessible.style.cssText = `position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;`;
+ // $accessible.setAttribute('tabindex', '-1');
+ $accessible.innerHTML = this.html;
+ $el.insertBefore($accessible, $el.firstChild);
+ this.lines.forEach(setAriaHidden);
+ this.words.forEach(setAriaHidden);
+ this.chars.forEach(setAriaHidden);
+ }
+ this.width = /** @type {HTMLElement} */($el).offsetWidth;
+ if (canSplitLines || clearCache) {
+ this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
+ }
+ return this;
+ }
+
+ refresh() {
+ this.split(true);
}
}
-const waapi = {
/**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
- * @return {WAAPIAnimation}
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ * @return {TextSplitter}
*/
- animate: (targets, params) => new WAAPIAnimation(targets, params),
- convertEase: easingToLinear
+const splitText = (target, parameters) => new TextSplitter(target, parameters);
+
+/**
+ * @deprecated text.split() is deprecated, import splitText() directly, or text.splitText()
+ *
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ * @return {TextSplitter}
+ */
+const split = (target, parameters) => {
+ console.warn('text.split() is deprecated, import splitText() directly, or text.splitText()');
+ return new TextSplitter(target, parameters);
};
-export { registerTargets as $, Animatable, Draggable, JSAnimation, Scope, ScrollObserver, Spring, TextSplitter, Timeline, Timer, WAAPIAnimation, animate, clamp, cleanInlineStyles, createAnimatable, createDraggable, createDrawable, createMotionPath, createScope, createSeededRandom, createSpring, createTimeline, createTimer, cubicBezier, damp, degToRad, eases, index$3 as easings, engine, get, irregular, keepTime, lerp, linear, mapRange, morphTo, onScroll, padEnd, padStart, radToDeg, random, randomPick, remove, round, roundPad, scrollContainers, set, shuffle, snap, split, splitText, spring, stagger, steps, index$1 as svg, sync, index as text, index$2 as utils, waapi, wrap };
+var index = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ TextSplitter: TextSplitter,
+ split: split,
+ splitText: splitText
+});
+
+export { registerTargets as $, Animatable, AutoLayout, Draggable, JSAnimation, Scope, ScrollObserver, Spring, TextSplitter, Timeline, Timer, WAAPIAnimation, animate, clamp, cleanInlineStyles, createAnimatable, createDraggable, createDrawable, createLayout, createMotionPath, createScope, createSeededRandom, createSpring, createTimeline, createTimer, cubicBezier, damp, degToRad, eases, index$3 as easings, engine, get, irregular, keepTime, lerp, linear, mapRange, morphTo, onScroll, padEnd, padStart, radToDeg, random, randomPick, remove, round, roundPad, scrollContainers, set, shuffle, snap, split, splitText, spring, stagger, steps, index$1 as svg, sync, index as text, index$2 as utils, waapi, wrap };
diff --git a/dist/bundles/anime.esm.min.js b/dist/bundles/anime.esm.min.js
index 8bd66963..b858b717 100644
--- a/dist/bundles/anime.esm.min.js
+++ b/dist/bundles/anime.esm.min.js
@@ -1,7 +1,7 @@
/**
* Anime.js - ESM minified bundle
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=Symbol(),u=Symbol(),p=1e-11,m=1e12,f=1e3,g=120,_="",y="var(",v=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),b=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],T=b.reduce((t,e)=>({...t,[e]:e+"("}),{}),S=()=>{},w=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,x=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,C=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,E=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,k=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,$=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,B=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,O=/([a-z])([A-Z])/g,N=/(\w+)(\([^)]+\)+)/g,R=/(\*=|\+=|-=)/,D=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,L={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:g,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:f,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:t=>t,onBegin:S,onBeforeUpdate:S,onUpdate:S,onLoop:S,onPause:S,onComplete:S,onRender:S},A={current:null,root:s},F={defaults:L,precision:4,timeScale:1,tickThreshold:200},M={version:"4.2.2",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(M));const P=t=>t.replace(O,"$1-$2").toLowerCase(),I=(t,e)=>0===t.indexOf(e),z=Date.now,U=Array.isArray,X=t=>t&&t.constructor===Object,Y=t=>"number"==typeof t&&!isNaN(t),V=t=>"string"==typeof t,W=t=>"function"==typeof t,H=t=>void 0===t,q=t=>H(t)||null===t,j=e=>t&&e instanceof SVGElement,G=t=>w.test(t),Q=t=>I(t,"rgb"),J=t=>I(t,"hsl"),Z=t=>G(t)||Q(t)||J(t),K=t=>!F.defaults.hasOwnProperty(t),tt=["opacity","rotate","overflow","color"],et=(t,e)=>{if(tt.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},st=t=>V(t)?parseFloat(t):t,it=Math.pow,rt=Math.sqrt,nt=Math.sin,ot=Math.cos,at=Math.abs,ht=Math.exp,lt=Math.ceil,ct=Math.floor,dt=Math.asin,ut=Math.max,pt=Math.atan2,mt=Math.PI,ft=Math.round,gt=(t,e,s)=>t<e?e:t>s?s:t,_t={},yt=(t,e)=>{if(e<0)return t;if(!e)return ft(t);let s=_t[e];return s||(s=_t[e]=10**e),ft(t*s)/s},vt=(t,e)=>U(e)?e.reduce((e,s)=>at(s-t)<at(e-t)?s:e):e?ft(t/e)*e:t,bt=(t,e,s)=>t+(e-t)*s,Tt=t=>t===1/0?m:t===-1/0?-m:t,St=t=>t<=p?p:Tt(yt(t,11)),wt=t=>U(t)?[...t]:t,xt=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=H(r)?e[i]:r}return s},Ct=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},Et=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},kt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},$t=(t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[c];let o;for(;o=N.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!H(r)?r:I(e,"scale")?"1":I(e,"rotate")||I(e,"skew")?"0deg":"0px"},Bt=t=>{const e=x.exec(t)||C.exec(t),s=H(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},Ot=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},Nt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Rt=t=>{const e=E.exec(t)||k.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=H(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=yt(255*Nt(e,t,s+1/3),0),a=yt(255*Nt(e,t,s),0),h=yt(255*Nt(e,t,s-1/3),0)}return[o,a,h,n]},Dt=t=>Q(t)?Bt(t):G(t)?Ot(t):J(t)?Rt(t):[0,0,0,1],Lt=(t,e)=>H(t)?e:t,At=(t,e,s,i,r)=>{let n;if(W(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!V(t)||!I(t,y))return t;n=()=>{const s=t.match(D),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==_||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},Ft=(t,e)=>t[h]?t[l]&&et(t,e)?i.ATTRIBUTE:b.includes(e)||v.get(e)?i.TRANSFORM:I(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,Mt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[u]||t).getPropertyValue(e);return"auto"===r?"0":r},Pt=(t,e,s,r)=>{const n=H(s)?Ft(t,e):s;return n===i.OBJECT?t[e]||0:n===i.ATTRIBUTE?t.getAttribute(e):n===i.TRANSFORM?$t(t,e,r):n===i.CSS_VAR?Mt(t,e,r).trimStart():Mt(t,e,r)},It=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,zt=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Ut=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const i=!s.includes(" ")&&B.exec(s);if(i)return e.t=r.UNIT,e.n=+i[1],e.u=i[2],e;if(e.o)return e.n=+s,e;if(Z(s))return e.t=r.COLOR,e.d=Dt(s),e;{const t=s.match($);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=s.split($)||[],e}}return e.n=s,e},Xt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=wt(t._toNumbers),e.s=wt(t._strings),e),Yt=zt(),Vt=(t,e,s,a,h)=>{const l=t.parent,d=t.duration,u=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,y=t._loopDelay,v=t._reversed,b=t._alternate,S=t._hasChildren,w=t._delay,x=t._currentTime,C=w+m,E=e-w,k=gt(x,-w,d),$=gt(E,-w,d),B=E-x,O=$>0,N=$>=d,R=d<=p,D=h===n.FORCE;let L=0,A=E,M=0;if(f>1){const e=~~($/(m+(N?0:y)));t._currentIteration=gt(e,0,f),N&&t._currentIteration--,L=t._currentIteration%2,A=$%(m+y)||0}const P=v^(b&&L),I=t._ease;let z=N?P?0:d:P?m-A:A;I&&(z=m*I(z/m)||0);const U=(l?l.backwards:E<x)?!P:!!P;if(t._currentTime=E,t._iterationTime=z,t.backwards=U,O&&!t.began?(t.began=!0,s||l&&(U||!l.began)||t.onBegin(t)):E<=0&&(t.began=!1),s||S||!O||t._currentIteration===g||t.onLoop(t),D||h===n.AUTO&&(e>=w&&e<=C||e<=w&&k>w||e>=C&&k!==d)||z>=C&&k!==d||z<=w&&k>0||e<=k&&k===d&&u||N&&!u&&R){if(O&&(t.computeDeltaTime(k),s||t.onBeforeUpdate(t)),!S){const e=D||(U?-1*B:B)>=F.tickThreshold,n=t._offset+(l?l._offset:0)+w+z;let h,d,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,l=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,y=m._nextRep,v=m._prevRep,b=t!==o.none;if((e||(s!==l||n<=g+(y?y._delay:0))&&(0!==s||n>=m._absoluteStartTime))&&(!b||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!y||y._isOverridden||n<=y._absoluteStartTime)&&(!v||v._isOverridden||n>=v._absoluteStartTime+v._changeDuration+m._delay))){const e=m._currentTime=gt(z-m._startTime,0,l),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,_=m._tweenType,y=_===i.OBJECT,v=g===r.NUMBER,T=v&&y||0===s||1===s?-1:F.precision;let S,w;if(v)S=w=n(yt(bt(m._fromNumber,m._toNumber,s),T));else if(g===r.UNIT)w=n(yt(bt(m._fromNumber,m._toNumber,s),T)),S=`${w}${m._unit}`;else if(g===r.COLOR){const t=m._fromNumbers,e=m._toNumbers,i=yt(gt(n(bt(t[0],e[0],s)),0,255),0),r=yt(gt(n(bt(t[1],e[1],s)),0,255),0),o=yt(gt(n(bt(t[2],e[2],s)),0,255),0),a=gt(n(yt(bt(t[3],e[3],s),T)),0,1);if(S=`rgba(${i},${r},${o},${a})`,b){const t=m._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(g===r.COMPLEX){S=m._strings[0];for(let t=0,e=m._toNumbers.length;t<e;t++){const e=n(yt(bt(m._fromNumbers[t],m._toNumbers[t],s),T)),i=m._strings[t+1];S+=`${i?e+i:e}`,b&&(m._numbers[t]=e)}}if(b&&(m._number=w),a||t===o.blend)m._value=S;else{const t=m.property;h=m.target,y?h[t]=S:_===i.ATTRIBUTE?h.setAttribute(t,S):(d=h.style,_===i.TRANSFORM?(h!==u&&(u=h,p=h[c]),p[t]=S,f=1):_===i.CSS?d[t]=S:_===i.CSS_VAR&&d.setProperty(t,S)),O&&(M=1)}}if(f&&m._renderTransforms){let t=_;for(let e in p)t+=`${T[e]}${p[e]}) `;d.transform=t,f=0}m=m._next}!s&&M&&t.onRender(t)}!s&&O&&t.onUpdate(t)}return l&&R?!s&&(l.began&&!U&&E>0&&!u||U&&E<=p&&u)&&(t.onComplete(t),t.completed=!U):O&&N?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,u||S||(t.completed=!0,s||l&&(U||!l.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,M},Wt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Vt(t,e,s,i,r),t._hasChildren){const a=t,h=a.backwards,l=i?e:a._iterationTime,c=z();let d=0,u=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;Ct(a,e=>{if(h){const i=e.duration,r=e._offset+e._delay;s||!(i<=p)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Vt(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}Ct(a,t=>{const e=yt((l-t._offset)*t._speed,12),n=t._fps<a._fps?t.requestTick(c):r;d+=Vt(t,e,s,i,n),!t.completed&&u&&(u=!1)},h),!s&&d&&a.onRender(a),(u||h)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},Ht={},qt=(t,e,s)=>{if(s===i.TRANSFORM)return v.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&j(e)&&t in e.style){const e=Ht[t];if(e)return e;{const e=t?P(t):t;return Ht[t]=e,e}}return t},jt=t=>{if(t._hasChildren)Ct(t,jt,!0);else{const e=t;e.pause(),Ct(e,t=>{const s=t.property,r=t.target;if(r[h]){const n=r.style,o=t._inlineValue,a=q(o)||o===_;if(t._tweenType===i.TRANSFORM){const e=r[c];if(a?delete e[s]:e[s]=o,t._renderTransforms)if(Object.keys(e).length){let t=_;for(let s in e)t+=T[s]+e[s]+") ";n.transform=t}else n.removeProperty("transform")}else a?n.removeProperty(P(s)):n[s]=o;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===_&&t.removeAttribute("style")})}})}return t};class Gt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=yt(f/g,0),this._fps=g,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<p?p:s,r=yt(f/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<p?p:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return n.NONE;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,n.AUTO}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Qt={animation:null,update:S},Jt=t=>{let e=Qt.animation;return e||(e={duration:p,computeDeltaTime:S,_offset:0,_delay:0,_head:null,_tail:null},Qt.animation=e,Qt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?wt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Vt(e,1,1,0,n.FORCE)}),e},Zt=(()=>t?requestAnimationFrame:setImmediate)(),Kt=(()=>t?cancelAnimationFrame:clearImmediate)();class te extends Gt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=L,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=z();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(Et(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Wt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}Qt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(z()),this.reqId=Zt(se)),this}pause(){if(this.reqId)return this.paused=!0,ie()}resume(){if(this.paused)return this.paused=!1,Ct(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===F.timeScale?1:f)}set speed(t){this._speed=t*F.timeScale,Ct(this,t=>t.speed=t._speed)}get timeUnit(){return 1===F.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(F.timeScale!==s){F.timeScale=s,F.tickThreshold=200*s;const t=e?.001:f;this.defaults.duration*=t,this._speed*=t}}get precision(){return F.precision}set precision(t){F.precision=t}}const ee=(()=>{const e=new te(z());return t&&(M.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),se=()=>{ee._head?(ee.reqId=Zt(se),ee.update()):ee.reqId=0},ie=()=>(Kt(ee.reqId),ee.reqId=0,ee),re={_rep:new WeakMap,_add:new Map},ne=(t,e,s="_rep")=>{const i=re[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},oe=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,ae=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=p,t._currentTime=p},he=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;kt(e,t,oe,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){ae(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)ae(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=yt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<p&&ae(i)}let o=!0;if(Ct(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;Ct(t,t=>{t!==e&&Ct(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===o.blend){const e=ne(t.target,t.property,"_add"),s=Jt(re._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=p,i._startTime=0,i._numbers=wt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,kt(e,i),kt(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=wt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers){const e=wt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}kt(e,t,null,"_prevAdd","_nextAdd")}return t},le=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=re._rep.get(s)[i];if(Et(r,t,"_prevRep","_nextRep"),e===o.blend){const e=re._add,r=e.get(s);if(!r)return;const n=r[i],o=Qt.animation;Et(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){Et(n,a,"_prevAdd","_nextAdd"),Et(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ce=(t,e,s)=>{let r=!1;return Ct(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,h=qt(s,o,a);(!h||h&&h===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),Et(e,n),le(n),r=!0)}},!0),r},de=(t,e,s)=>{const i=e||ee;let r;if(i._hasChildren){let e=0;Ct(i,n=>{if(!n._hasChildren)if(r=ce(t,n,s),r&&!n._head)n.cancel(),Et(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?de(t,n,s):n._hasChildren=!1},!0),H(i.iterationDuration)||(i.iterationDuration=e)}else r=ce(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},ue=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),pe=t=>t._cancelled?(t._hasChildren?Ct(t,pe):Ct(t,t=>{t._composition!==o.none&&he(t,ne(t.target,t.property))}),t._cancelled=0,t):t;let me=0;class fe extends Gt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:d,playbackRate:u,onComplete:m,onLoop:f,onPause:g,onBegin:_,onBeforeUpdate:y,onUpdate:v}=t;A.current&&A.current.register(this);const b=e?0:ee._elapsedTime,T=e?e.defaults:F.defaults,w=W(r)||H(r)?T.delay:+r,x=W(n)||H(n)?1/0:+n,C=Lt(h,T.loop),E=Lt(l,T.loopDelay),k=!0===C||C===1/0||C<0?1/0:C+1;let $=0;e?$=s:(ee.reqId||ee.requestTick(z()),$=(ee._elapsedTime-ee._startTime)*F.timeScale),this.id=H(i)?++me:i,this.parent=e,this.duration=Tt((x+E)*k-E)||p,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=_||T.onBegin,this.onBeforeUpdate=y||T.onBeforeUpdate,this.onUpdate=v||T.onUpdate,this.onLoop=f||T.onLoop,this.onPause=g||T.onPause,this.onComplete=m||T.onComplete,this.iterationDuration=x,this.iterationCount=k,this._autoplay=!e&&Lt(c,T.autoplay),this._offset=$,this._delay=w,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=S,this._running=!1,this._reversed=+Lt(o,T.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Lt(a,T.alternate),this._prev=null,this._next=null,this._elapsedTime=b,this._startTime=b,this._lastTime=b,this._fps=Lt(d,T.frameRate),this._speed=Lt(u,T.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return gt(yt(this._currentTime,F.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return yt(this._iterationTime,F.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return gt(yt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return gt(yt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*gt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return pe(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Wt(this,0,1,~~t,n.FORCE),ue(this),this._hasChildren&&Ct(this,ue),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Wt(this,this.duration,1,~~t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!H(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*ee._speed);return this._startTime=z()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=p&&!this._hasChildren?Wt(this,p,0,0,n.FORCE):(this._running||(kt(ee,this),ee._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,ee.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){pe(this),this.completed=!1;const i=this.paused;return this.paused=!0,Wt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ct(m/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?Ct(this,t=>t.cancel(),!0):Ct(this,le),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=St(t);if(e===s)return this;const i=t/e,r=t<=p;return this.duration=r?p:s,this.iterationDuration=r?p:St(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Wt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const ge=t=>new fe(t,null,0).init();function _e(t){const e=V(t)?A.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ye(e){if(q(e))return[];if(!t)return U(e)&&e.flat(1/0)||[e];if(U(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!q(i)){const t=_e(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!q(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=_e(e);return s?Array.from(s):[e]}function ve(t){const e=ye(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=j(s);(s.nodeType||t)&&(s[h]=!0,s[l]=t,s[c]={})}}return e}const be={deg:1,rad:180/mt,turn:360},Te={},Se=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const h=a+o+i,l=Te[h];if(H(l)||n){let r;if(o in be)r=a*be[o]/be[i];else{const e=100,n=t.cloneNode(),h=t.parentNode,l=h&&h!==s?h:s.body;l.appendChild(n);const c=n.style;c.width=e+o;const d=n.offsetWidth||e;c.width=e+i;const u=d/(n.offsetWidth||e);l.removeChild(n),r=u*a}e.n=r,Te[h]=r}else e.n=l;return e.t,e.u=i,e},we=t=>t,xe=(t=1.68)=>e=>it(e,+t),Ce={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},Ee=mt/2,ke=2*mt,$e={[_]:xe,Quad:xe(2),Cubic:xe(3),Quart:xe(4),Quint:xe(5),Sine:t=>1-ot(t*Ee),Circ:t=>1-rt(1-t*t),Expo:t=>t?it(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=it(2,--s))-1)/11;);return 1/it(4,3-s)-7.5625*it((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=gt(+t,1,10),i=gt(+e,p,2),r=i/ke*dt(1/s),n=ke/i;return t=>0===t||1===t?t:-s*it(2,-10*(1-t))*nt((1-t-r)*n)}},Be=(()=>{const t={linear:we,none:we};for(let e in Ce)for(let s in $e){const i=$e[s],r=Ce[e];t[e+s]=s===_||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Oe={linear:we,none:we},Ne=t=>{if(Oe[t])return Oe[t];if(t.indexOf("(")<=-1){const e=Ce[t]||t.includes("Back")||t.includes("Elastic")?Be[t]():Be[t];return e?Oe[t]=e:we}{const e=t.slice(0,-1).split("("),s=Be[e[0]];return s?Oe[t]=s(...e[1].split(",")):we}},Re=["steps(","irregular(","linear(","cubicBezier("],De=t=>{if(V(t))for(let e=0,s=Re.length;e<s;e++)if(I(t,Re[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),we;return W(t)?t:V(t)?Ne(t):we},Le=zt(),Ae=zt(),Fe={},Me={func:null},Pe=[null],Ie=[null,null],ze={to:null};let Ue,Xe,Ye=0;const Ve=(t,e)=>{const s={};if(U(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(K);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];K(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Lt(e.duration,F.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(K(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class We extends fe{constructor(t,e,s,n,a=!1,h=0,l=0){super(e,s,n);const c=ve(t),d=c.length,u=e.keyframes,m=u?xt(Ve(u,e),e):e,{delay:g,duration:_,ease:y,playbackEase:v,modifier:b,composition:T,onRender:S}=m,w=s?s.defaults:F.defaults,x=Lt(v,w.playbackEase),C=x?De(x):null,E=!H(y)&&!H(y.ease),k=E?y.ease:Lt(y,C?"linear":w.ease),$=E?y.settlingDuration:Lt(_,w.duration),B=Lt(g,w.delay),O=b||w.modifier,N=H(T)&&d>=f?o.none:H(T)?w.composition:T,R=this._offset+(s?s._offset:0);E&&(y.parent=this);let D=NaN,L=NaN,A=0,M=0;for(let t=0;t<d;t++){const e=c[t],n=h||t,u=l||d;let f=NaN,g=NaN;for(let t in m)if(K(t)){const h=Ft(e,t),l=qt(t,e,h);let c=m[t];const d=U(c);if(a&&!d&&(Ie[0]=c,Ie[1]=c,c=Ie),d){const t=c.length,e=!X(c[0]);2===t&&e?(ze.to=c,Pe[0]=ze,Ue=Pe):t>2&&e?(Ue=[],c.forEach((t,e)=>{e?1===e?(Ie[1]=t,Ue.push(Ie)):Ue.push(t):Ie[0]=t})):Ue=c}else Pe[0]=c,Ue=Pe;let _=null,y=null,v=NaN,b=0,T=0;for(let t=Ue.length;T<t;T++){const i=Ue[T];X(i)?Xe=i:(ze.to=i,Xe=ze),Me.func=null;const a=At(Xe.to,e,n,u,Me);let c;X(a)&&!H(a.to)?(Xe=a,c=a.to):c=a;const d=At(Xe.from,e,n,u),m=Xe.ease,f=!H(m)&&!H(m.ease),g=f?m.ease:m||k,S=f?m.settlingDuration:At(Lt(Xe.duration,t>1?At($,e,n,u)/t:$),e,n,u),w=At(Lt(Xe.delay,T?0:B),e,n,u),x=At(Lt(Xe.composition,N),e,n,u),C=Y(x)?x:o[x],E=Xe.modifier||O,D=!H(d),L=!H(c),F=U(c),P=F||D&&L,I=y?b+w:w,z=yt(R+I,12);M||!D&&!F||(M=1);let V=y;if(C!==o.none){_||(_=ne(e,l));let t=_._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=z;)if(V=t,t=t._nextRep,t&&t._absoluteStartTime>=z)for(;t;)ae(t),t=t._nextRep}if(P?(Ut(F?At(c[0],e,n,u):d,Le),Ut(F?At(c[1],e,n,u,Me):c,Ae),Le.t===r.NUMBER&&(V?V._valueType===r.UNIT&&(Le.t=r.UNIT,Le.u=V._unit):(Ut(Pt(e,l,h,Fe),Yt),Yt.t===r.UNIT&&(Le.t=r.UNIT,Le.u=Yt.u)))):(L?Ut(c,Ae):y?Xt(y,Ae):Ut(s&&V&&V.parent.parent===s?V._value:Pt(e,l,h,Fe),Ae),D?Ut(d,Le):y?Xt(y,Le):Ut(s&&V&&V.parent.parent===s?V._value:Pt(e,l,h,Fe),Le)),Le.o&&(Le.n=It(V?V._toNumber:Ut(Pt(e,l,h,Fe),Yt).n,Le.n,Le.o)),Ae.o&&(Ae.n=It(Le.n,Ae.n,Ae.o)),Le.t!==Ae.t)if(Le.t===r.COMPLEX||Ae.t===r.COMPLEX){const t=Le.t===r.COMPLEX?Le:Ae,e=Le.t===r.COMPLEX?Ae:Le;e.t=r.COMPLEX,e.s=wt(t.s),e.d=t.d.map(()=>e.n)}else if(Le.t===r.UNIT||Ae.t===r.UNIT){const t=Le.t===r.UNIT?Le:Ae,e=Le.t===r.UNIT?Ae:Le;e.t=r.UNIT,e.u=t.u}else if(Le.t===r.COLOR||Ae.t===r.COLOR){const t=Le.t===r.COLOR?Le:Ae,e=Le.t===r.COLOR?Ae:Le;e.t=r.COLOR,e.s=t.s,e.d=[0,0,0,1]}if(Le.u!==Ae.u){let t=Ae.u?Le:Ae;t=Se(e,t,Ae.u?Ae.u:Le.u,!1)}if(Ae.d&&Le.d&&Ae.d.length!==Le.d.length){const t=Le.d.length>Ae.d.length?Le:Ae,e=t===Le?Ae:Le;e.d=t.d.map((t,s)=>H(e.d[s])?0:e.d[s]),e.s=wt(t.s)}const W=yt(+S||p,12);let j=Fe[l];q(j)||(Fe[l]=null);const G={parent:this,id:Ye++,property:l,target:e,_value:null,_func:Me.func,_ease:De(g),_fromNumbers:wt(Le.d),_toNumbers:wt(Ae.d),_strings:wt(Ae.s),_fromNumber:Le.n,_toNumber:Ae.n,_numbers:wt(Le.d),_number:Le.n,_unit:Ae.u,_modifier:E,_currentTime:0,_startTime:I,_delay:+w,_updateDuration:W,_changeDuration:W,_absoluteStartTime:z,_tweenType:h,_valueType:Ae.t,_composition:C,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:j,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};C!==o.none&&he(G,_),isNaN(v)&&(v=G._startTime),b=yt(I+W,12),y=G,A++,kt(this,G)}(isNaN(L)||v<L)&&(L=v),(isNaN(D)||b>D)&&(D=b),h===i.TRANSFORM&&(f=A-T,g=A)}if(!isNaN(f)){let t=0;Ct(this,e=>{t>=f&&t<g&&(e._renderTransforms=1,e._composition===o.blend&&Ct(Qt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}d||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),L?(Ct(this,t=>{t._startTime-t._delay||(t._delay-=L),t._startTime-=L}),D-=L):L=0,D||(D=p,this.iterationCount=0),this.targets=c,this.duration=D===p?p:Tt((D+this._loopDelay)*this.iterationCount-this._loopDelay)||p,this.onRender=S||w.onRender,this._ease=C,this._delay=L,this.iterationDuration=D,!this._autoplay&&M&&this.onRender(this)}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e;return Ct(this,t=>{t._updateDuration=St(t._updateDuration*s),t._changeDuration=St(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return Ct(this,t=>{const e=t._func;if(e){const s=Pt(t.target,t.property,t._tweenType);Ut(s,Yt),Ut(e(),Ae),t._fromNumbers=wt(Yt.d),t._fromNumber=Yt.n,t._toNumbers=wt(Ae.d),t._strings=wt(Ae.s),t._toNumber=Ae.o?It(Yt.n,Ae.n,Ae.o):Ae.n}}),this.duration===p&&this.restart(),this}revert(){return super.revert(),jt(this)}then(t){return super.then(t)}}const He=(t,e)=>new We(t,e,null,0,!1).init(),qe={_head:null,_tail:null},je=(t,e,s)=>{let i,r=qe._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),Et(qe,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Ge=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),je(e,s),kt(qe,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{je(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Qe(t,e,s){const i=ve(t);if(!i.length)return;const[n]=i,o=Ft(n,e),a=qt(e,n,o);let h=Pt(n,a);if(H(s))return h;if(Ut(h,Yt),Yt.t===r.NUMBER||Yt.t===r.UNIT){if(!1===s)return Yt.n;{const t=Se(n,Yt,s,!1);return`${yt(t.n,F.precision)}${t.u}`}}}const Je=(t,e)=>{if(!H(e))return e.duration=p,e.composition=Lt(e.composition,o.none),new We(t,e,null,0,!0).resume()},Ze=(t,e,s)=>{const i=ye(t);for(let t=0,r=i.length;t<r;t++)je(i[t],s,e&&e.controlAnimation&&e);return de(i,e,s),i},Ke=(t,e)=>{if(I(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},ts=(t,e)=>{let s=t.iterationDuration;if(s===p&&(s=0),H(e))return s;if(Y(+e))return+e;const i=e,r=t?t.labels:null,n=!q(r),o=Ke(t,i),a=!H(o),h=R.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return It(c,d,t[0])}return a?o:n?H(r[i])?s:r[i]:s};function es(t){return Tt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||p}function ss(t,e,s,i,r,o){const a=Y(t.duration)&&t.duration<=p?s-p:s;Wt(e,a,1,1,n.AUTO);const h=i?new We(i,t,e,a,!1,r,o):new fe(t,e,a);return h.init(!0),kt(e,h),Ct(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=es(e),e}class is extends fe{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=F.defaults;this.defaults=e?xt(e,s):s,this.onRender=t.onRender||s.onRender;const i=Lt(t.playbackEase,s.playbackEase);this._ease=i?De(i):null,this.iterationDuration=0}add(t,e,s){const i=X(e),r=X(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(W(s)){const e=s,r=ye(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,H(a)||(s.id=a+"-"+h),ss(s,this,ts(this,e(t,h,l,this)),t,h,l),h++})}else ss(i,this,ts(this,s),t)}else ss(t,this,ts(this,e));return this.init(!0)}}sync(t,e){if(H(t)||t&&H(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return H(e)?this:(e.duration=p,e.composition=o.replace,this.add(t,e,s))}call(t,e){return H(t)||t&&!W(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return H(t)||t&&!V(t)||(this.labels[t]=ts(this,e)),this}remove(t,e){return de(ye(t),this,e),this}stretch(t){const e=this.duration;if(e===St(t))return this;const s=t/e,i=this.labels;Ct(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return Ct(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),Ct(this,t=>t.revert,!0),jt(this)}then(t){return super.then(t)}}const rs=t=>new is(t).init();class ns{constructor(t,e){A.current&&A.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!H(t)&&!H(e)){for(let t in e){const s=e[t];K(t)?n[t]=s:I(t,"on")?r[t]=s:i[t]=s}this.callbacks=new We({v:0},r);for(let e in n){const s=n[e],r=X(s);let a={},h="+=0";if(r){const t=s.unit;V(t)&&(h+=t)}else a.duration=s;a[e]=r?xt({to:h},s):h;const l=xt(i,a);l.composition=o.replace,l.autoplay=!1;const c=this.animations[e]=new We(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(H(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return Ct(c,e=>{if(U(t))for(let s=0,i=t.length;s<i;s++)H(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;H(s)||(e._ease=De(s)),e._currentTime=0}),H(e)||c.stretch(e),c.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=S,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const os=(t,e)=>new ns(t,e),as=(t,e)=>(+t).toFixed(e),hs=(t,e,s)=>`${t}`.padStart(e,s),ls=(t,e,s)=>`${t}`.padEnd(e,s),cs=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,ds=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),us=t=>t*Math.PI/180,ps=t=>180*t/Math.PI,ms=(t,e,s,i)=>i?1===i?e:bt(t,e,1-Math.exp(-i*s*.1)):t;var fs=Object.freeze({__proto__:null,clamp:gt,damp:ms,degToRad:us,lerp:bt,mapRange:ds,padEnd:ls,padStart:hs,radToDeg:ps,round:yt,roundPad:as,snap:vt,wrap:cs});const gs=10*f;class _s{constructor(t={}){const e=!H(t.bounce)||!H(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/f,this.maxIterations=this.maxDuration/this.timeStep/f,this.bn=gt(Lt(t.bounce,.5),-1,1),this.pd=gt(Lt(t.duration,628),10*F.timeScale,gs*F.timeScale),this.m=gt(Lt(t.mass,1),1,gs),this.s=gt(Lt(t.stiffness,100),p,gs),this.d=gt(Lt(t.damping,10),p,gs),this.v=gt(Lt(t.velocity,0),-1e4,gs),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||S,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?ht(-n*e*s)*(1*ot(i*n)+r*nt(i*n)):1===e?(1+r*n)*ht(-n*s):((1+r)*ht((-e*s+i)*n)+(1-r)*ht((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===F.timeScale?this.pd/f:this.pd;this.m=1,this.v=0,this.s=it(2*mt/t,2),this.bn>=0?this.d=4*(1-this.bn)*mt/t:this.d=4*mt/(t*(1+this.bn)),this.s=yt(gt(this.s,p,gs),3),this.d=yt(gt(this.d,p,300),3)}calculateBDFromSD(){const t=2*mt/rt(this.s);this.pd=t*(1===F.timeScale?f:1);const e=this.d/(2*rt(this.s));this.bn=e<=1?1-this.d*t/(4*mt):4*mt/(this.d*t)-1,this.bn=yt(gt(this.bn,-1,1),3),this.pd=yt(gt(this.pd,10*F.timeScale,gs*F.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=gt(rt(o/r),p,f),l=this.zeta=n/(2*rt(o*r));l<1?(this.wd=h*rt(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*rt(l*l-1),this.b=(l*h-a)/this.wd);let c=0,d=0,u=0;for(;d<=t&&u<=e;)at(1-this.solve(c))<s?d++:d=0,this.solverDuration=c,c+=i,u++;this.settlingDuration=yt(this.solverDuration*f,0)*F.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=gt(Lt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=gt(Lt(t,1),10*F.timeScale,gs*F.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=gt(Lt(t,100),p,gs),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=gt(Lt(t,10),p,gs),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=gt(Lt(t,1),1,gs),this.compute()}get velocity(){return this.v}set velocity(t){this.v=gt(Lt(t,0),-1e4,gs),this.compute()}}const ys=t=>new _s(t),vs=t=>(console.warn("createSpring() is deprecated use spring() instead"),new _s(t)),bs=t=>{t.cancelable&&t.preventDefault()};class Ts{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:S,remove:S}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ss{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const ws=(t,e)=>t&&W(t)?t(e):t;let xs=0;class Cs{constructor(t,i={}){if(!t)return;A.current&&A.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,h=i.releaseEase,l=h&&De(h),c=!H(h)&&!H(h.ease),d=X(r)&&!H(r.mapTo)?r.mapTo:"translateX",u=X(n)&&!H(n.mapTo)?n.mapTo:"translateY",p=ws(i.container,this);this.containerArray=U(p)?p:null,this.$container=p&&!this.containerArray?ye(p)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=X(t)?new Ts(t):ye(t)[0],this.$trigger=ye(o||t)[0],this.fixed="fixed"===Qe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:ys({mass:Lt(i.releaseMass,1),stiffness:Lt(i.releaseStiffness,80),damping:Lt(i.releaseDamping,20)}),this.releaseYSpring=c?h:ys({mass:Lt(i.releaseMass,1),stiffness:Lt(i.releaseStiffness,80),damping:Lt(i.releaseDamping,20)}),this.releaseEase=l||Be.outQuint,this.hasReleaseSpring=c,this.onGrab=i.onGrab||S,this.onDrag=i.onDrag||S,this.onRelease=i.onRelease||S,this.onUpdate=i.onUpdate||S,this.onSettle=i.onSettle||S,this.onSnap=i.onSnap||S,this.onResize=i.onResize||S,this.onAfterResize=i.onAfterResize||S,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),H(r)||!0===r)f[d]=0;else if(X(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(H(n)||!0===n)f[u]=0;else if(X(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new ns(this.$target,f),this.xProp=d,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-m,m,m,-m],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=z(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ss(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new fe({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new fe({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!H(p),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=pt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new fe({autoplay:!1,duration:150*F.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),X(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=z(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=yt(gt(rt(t*t+e*e)/r*o,a,h),5);const c=ut(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=yt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=vt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=yt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=vt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return yt(this.animate[this.xProp](),F.precision)}set x(t){this.setX(t,!1)}get y(){return yt(this.animate[this.yProp](),F.precision)}set y(t){this.setY(t,!1)}get progressX(){return ds(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(ds(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return ds(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(ds(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=yt(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=yt(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,h=this.window[1]=e.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,_]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?gt(c,a,c):c,this.scrollView[1]=l?gt(d,h,d):d,this.updateScrollCoords();const{width:y,height:v,left:b,top:T,right:S,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=yt(l?gt(y,a,a):y,0),this.dragArea[3]=yt(l?gt(v,h,h):v,0);const x=Qe(t,"overflow"),C="visible"===x,E="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===s.body&&C||!E&&!C)&&(c>this.dragArea[2]+_-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!U(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-y:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=yt(r.top+s-(l?0:T),0),this.targetBounds[1]=yt(r.right+e-(l?a:S),0),this.targetBounds[2]=yt(r.bottom+s-(l?h:w),0),this.targetBounds[3]=yt(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+_):(this.containerBounds[0]=-yt(r.top-(u?gt(T,0,h):T)+o-m,0),this.containerBounds[1]=-yt(r.right-(u?gt(S,0,a):S)-c+f,0),this.containerBounds[2]=-yt(r.bottom-(u?gt(w,0,h):w)-d+g,0),this.containerBounds[3]=-yt(r.left-(u?gt(b,0,a):b)+n-_,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=ws(t.container,this),o=ws(t.containerPadding,this)||0,a=U(o)?o:[o,o,o,o],h=this.x,l=this.y,c=ws(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}const u=ws(t.dragThreshold,this),p={mouse:3,touch:7};if(Y(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;H(t)||(p.mouse=t),H(e)||(p.touch=e)}this.containerArray=U(n)?n:null,this.$container=n&&!this.containerArray?ye(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Lt(a,[0,0,0,0]),this.containerFriction=gt(Lt(ws(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=gt(Lt(ws(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=ws(X(i)&&!H(i.snap)?i.snap:t.snap,this),this.snapY=ws(X(r)&&!H(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Lt(ws(t.scrollSpeed,this),1.5),this.scrollThreshold=Lt(ws(t.scrollThreshold,this),20),this.dragSpeed=Lt(ws(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=Lt(ws(t.minVelocity,this),0),this.maxVelocity=Lt(ws(t.maxVelocity,this),50),this.velocityMultiplier=Lt(ws(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[m,f,g,_]=this.containerBounds;this.setX(gt(h,_,f),!0),this.setY(gt(l,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?gt(c,this.window[0],c):c,p=this.useWin?gt(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,_=this.scrollThreshold,[y,v]=this.coords,[b,T,S,w]=this.scrollBounds,x=yt(gt((v-b+t)/_,-1,0)*g,0),C=yt(gt((y-T-e)/_,0,1)*g,0),E=yt(gt((v-S-s)/_,0,1)*g,0),k=yt(gt((y-w+i)/_,-1,0)*g,0);if(x||E||k||C){const[t,e]=this.disabled;let s=h,i=l;t||(s=yt(gt(h+(k||C),0,r-o),0),this.coords[0]-=h-s),e||(i=yt(gt(l+(x||E),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=pt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return de([this],null,"x"),de([this],null,"y"),de([this],null,"progressX"),de([this],null,"progressY"),de([this.scroll]),de([this.overshootCoords]),this}scrollInView(t,e=0,s=Be.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,u=yt(gt(r-h,-m,0),0),p=yt(gt(i-l,0,m),0),f=yt(gt(r-c,0,m),0),g=yt(gt(i-d,-m,0),0);new We(n,{x:yt(n.x+(g?g-e:p?p+e:0),0),y:yt(n.y+(u?u-e:f?f+e:0),0),duration:H(t)?350*F.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Je(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Be.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=gt(vt(i,this.snapX),u,c),a=gt(vt(r,this.snapY),l,d),h=H(t)?350*F.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Qe(this.$target,"zIndex",!1);xs=(f>xs?f:xs)+1,this.targetStyles=Je(this.$target,{zIndex:xs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Je(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Be.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Qe(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(bs(t),this.triggerStyles||(this.triggerStyles=Je(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",bs,{passive:!1}),this.$trigger.addEventListener("touchmove",bs,{passive:!1}),this.$trigger.addEventListener("touchend",bs),(this.dragged||!this.disabled[0]&&at(o)>this.dragThreshold||!this.disabled[1]&&at(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,_=this.releaseYSpring,y=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,w=this.computeVelocity(i-h,r-l),x=this.angle=pt(r-a,i-n),C=150*w,E=(1-this.releaseContainerFriction)*this.dragSpeed,k=T+ot(x)*C,$=S+nt(x)*C,B=k>d?d+(k-d)*E:k<p?p+(k-p)*E:k,O=$>u?u+($-u)*E:$<c?c+($-c)*E:$,N=this.destX=gt(yt(vt(B,this.snapX),5),p,d),R=this.destY=gt(yt(vt(O,this.snapY),5),c,u),D=this.isOutOfBounds(this.containerBounds,k,$);let L=0,A=0,M=y,P=y,I=0;if(b.x=T,b.y=S,!t){const t=N===d?T>d?-1:1:T<p?-1:1,s=yt(T-N,0);g.velocity=e&&v?s?C*t/at(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=g;L=T===N?0:v?r:r-n*F.timeScale,v&&(M=i),L>I&&(I=L)}if(!e){const e=R===u?S>u?-1:1:S<c?-1:1,s=yt(S-R,0);_.velocity=t&&v?s?C*e/at(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=_;A=S===R?0:v?r:r-n*F.timeScale,v&&(P=i),A>I&&(I=A)}if(!v&&D&&E&&(L||A)){const t=o.blend;new We(b,{x:{to:B,duration:.65*L},y:{to:O,duration:.65*A},ease:y,composition:t}).init(),new We(b,{x:{to:N,duration:L},y:{to:R,duration:A},ease:y,composition:t}).init(),this.overshootTicker.stretch(ut(L,A)).restart()}else t||this.animate[this.xProp](N,L,M),e||this.animate[this.yProp](R,A,P);this.scrollInView(I,this.scrollThreshold,y);let z=!1;N!==m&&(this.snapped[0]=N,this.snapX&&(z=!0)),R!==f&&this.snapY&&(this.snapped[1]=R,this.snapY&&(z=!0)),z&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",bs),this.$trigger.removeEventListener("touchmove",bs),this.$trigger.removeEventListener("touchend",bs),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Je(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":bs(t)}}}const Es=(t,e)=>new Cs(t,e),ks=(t=S)=>new fe({duration:1*F.timeScale,onComplete:t},null,0).resume(),$s=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!W(a)&&a.revert&&(e=a),H(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||S}};class Bs{constructor(t={}){A.current&&A.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||ye(i)[0]||s);const n=t.defaults,o=F.defaults,a=t.mediaQueries;if(this.defaults=n?xt(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=A.current,s=A.root,i=F.defaults;A.current=this,A.root=this.root,F.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return A.current=e,A.root=s,F.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);W(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,W(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);W(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,W(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);W(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(W(s))return s(this);const i=$s(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const Os=t=>new Bs(t),Ns=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Rs=(t,e)=>t&&W(t)?t(e):t,Ds=new Map;class Ls{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new fe({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;Ct(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new fe({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=yt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new fe({autoplay:!1,duration:250*F.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new fe({autoplay:!1,duration:500*F.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=yt(t?e.scrollX:s.scrollLeft,0),this.scrollY=yt(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=Ns()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){Ct(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),Ct(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),Ds.delete(this.element)}}const As=t=>{const e=t&&ye(t)[0]||s.body;let i=Ds.get(e);return i||(i=new Ls(e),Ds.set(e,i)),i},Fs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Ut(a,Yt);let c=h;return"%"===l?c=h/100*s:l&&(c=Se(t,Yt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},Ms=(t,e,s,i,r)=>{let n;if(V(e)){const o=R.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=Fs(t,l[0],s,i,r),p=Fs(t,l[1],s,i,r);if(c){const e=It(Fs(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=It(Fs(t,"max",s),p,h);n=e>u?u:e}else n=It(u,p,h)}else n=Fs(t,e,s,i,r)}else n=e;return yt(n,0)},Ps=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[h]){e=i;break}}return e};let Is=0;const zs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Us{constructor(t={}){A.current&&A.current.register(this);const e=Lt(t.sync,"play pause"),i=e?De(e):null,r=e&&("linear"===e||e===we),n=e&&!(i===we&&!r),o=e&&(Y(e)||!0===e||r),a=e&&V(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=Is++,this.id=H(t.id)?this.index:t.id,this.container=As(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:S,this.onSyncLeave=h&&!l&&h[1]?h[1]:S,this.onSyncEnterForward=h&&l&&h[0]?h[0]:S,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:S,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:S,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:S,this.onEnter=t.onEnter||S,this.onLeave=t.onLeave||S,this.onEnterForward=t.onEnterForward||S,this.onLeaveForward=t.onLeaveForward||S,this.onEnterBackward=t.onEnterBackward||S,this.onLeaveBackward=t.onLeaveBackward||S,this.onUpdate=t.onUpdate||S,this.onSyncComplete=t.onSyncComplete||S,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Lt(t.debug,!1),this._next=null,this._prev=null,kt(this.container,this),ks(()=>{if(!this.reverted){if(!this.target){const e=ye(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,H(t)||(t.persist=!0),!this._params.target)){let e;H(t.targets)?Ct(t,t=>{t.targets&&!e&&(e=Ps(t))}):e=Ps(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:yt(gt(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Lt(Rs(t.repeat,this),!0),this.horizontal="x"===Lt(Rs(t.axis,this),"y"),this.enter=Lt(Rs(t.enter,this),"end start"),this.leave=Lt(Rs(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=zs[this.index%zs.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,_=e?g:15,y=e?60:g,v=e?y:_,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:c)}`,i||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?d:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,h=(r?0:this.offset)+t,m=i%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),S=s.createElement("div"),C=e?b?"right":"left":b?"bottom":"top",E=b?(e?y:_)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${x[m]}${this.thresholds[i]}`,T.style.cssText=`${w("absolute",0,0,y,_)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${C}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${_};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let k=h-E+(e?1:0);T.style[e?"left":"top"]=`${k}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Qe(t.element,"position")&&(this.debugStyles=Je(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==i.element&&a!==s.body;){const e="sticky"===Qe(a,"position")&&Je(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=i.scale,c=(r?h.left+i.scrollX-i.left:h.top+i.scrollY-i.top)*l,d=(r?h.width:h.height)*l,u=r?i.width:i.height,p=(r?i.scrollWidth:i.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",_="end",y="end",v="start";if(V(m)){const t=m.split(" ");y=t[0],g=t.length>1?t[1]:g}else if(X(m)){const t=m;H(t.container)||(y=t.container),H(t.target)||(g=t.target)}else Y(m)&&(y=m);if(V(f)){const t=f.split(" ");v=t[0],_=t.length>1?t[1]:_}else if(X(f)){const t=f;H(t.container)||(v=t.container),H(t.target)||(_=t.target)}else Y(f)&&(v=f);const b=Ms(e,g,d),T=Ms(e,_,d),S=b+c-u,w=T+c-p,x=Ms(e,y,u,S,w),C=Ms(e,v,u,S,w),E=b+c-x,k=T+c-C,$=k-E;this.offset=c,this.offsetStart=E,this.offsetEnd=k,this.distance=$<=0?0:$,this.thresholds=[g,_,y,v],this.coords=[b,T,x,C],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&Y(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=yt(bt(e,g,bt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return Et(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const Xs=(t={})=>new Us(t),Ys=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,Vs=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ys(r,e,s)-t,i>0?o=r:n=r}while(at(i)>1e-7&&++a<100);return r},Ws=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?we:r=>0===r||1===r?r:Ys(Vs(r,t,s),e,i),Hs=(t=10,e)=>{const s=e?lt:ct;return e=>s(gt(e,0,1)*t)*(1/t)},qs=(...t)=>{const e=t.length;if(!e)return we;const s=e-1,i=t[0],r=t[s],n=[0],o=[st(i)];for(let e=1;e<s;e++){const i=t[e],r=V(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(H(h)?e/s:st(h)/100),o.push(st(a))}return o.push(st(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},js=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(gt(o,r,1))}return s.push(1),qs(...s)};var Gs=Object.freeze({__proto__:null,Spring:_s,createSpring:vs,cubicBezier:Ws,eases:Be,irregular:js,linear:qs,spring:ys,steps:Hs});const Qs=fs,Js={},Zs=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),Ks=t=>(...e)=>{const s=t(...e);return new Proxy(S,{apply:(t,e,[i])=>s(i),get:(t,e)=>Ks((...t)=>{const i=Js[e](...t);return t=>i(s(t))})})},ti=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?Ks(Zs(e,s)):e)(...t);return Js[t]||(Js[t]=i),i},ei=ti("roundPad",Qs.roundPad),si=ti("padStart",Qs.padStart),ii=ti("padEnd",Qs.padEnd),ri=ti("wrap",Qs.wrap),ni=ti("mapRange",Qs.mapRange),oi=ti("degToRad",Qs.degToRad),ai=ti("radToDeg",Qs.radToDeg),hi=ti("snap",Qs.snap),li=ti("clamp",Qs.clamp),ci=ti("round",Qs.round),di=ti("lerp",Qs.lerp,1),ui=ti("damp",Qs.damp,1),pi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let mi=0;const fi=(t,e=0,s=1,i=0)=>{let r=void 0===t?mi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},gi=t=>t[pi(0,t.length-1)],_i=t=>{let e,s,i=t.length;for(;i;)s=pi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},yi=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!H(o),h=a&&!H(o.ease)?o.ease:a?De(o):null,l=e.grid,c=e.axis,d=e.total,u=H(r)||0===r||"first"===r,p="center"===r,m="last"===r,f="random"===r,g=U(t),y=e.use,v=st(g?t[0]:t),b=g?st(t[1]):0,T=B.exec((g?t[1]:t)+_),S=e.start||0+(g?v:0);let w=u?0:Y(r)?r:0;return(t,r,o,a)=>{const[u]=ve(t),_=H(d)?o:d,x=!H(y)&&(W(y)?y(u,r,_):Pt(u,y)),C=Y(x)||V(x)&&Y(+x)?+x:r;if(p&&(w=(_-1)/2),m&&(w=_-1),!s.length){for(let t=0;t<_;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:ct(w/l[0]),r=e-t%l[0],n=i-ct(t/l[0]);let o=rt(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(at(w-t));i=ut(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:at(i-t))),f&&(s=_i(s))}const E=g?(b-v)/i:v;let k=(a?ts(a,H(e.start)?a.iterationDuration:S):S)+(E*yt(s[C],2)||0);return e.modifier&&(k=e.modifier(k)),T&&(k=`${k}${T[2]}`),k}};var vi=Object.freeze({__proto__:null,$:ve,clamp:li,cleanInlineStyles:jt,createSeededRandom:fi,damp:ui,degToRad:oi,get:Qe,keepTime:$s,lerp:di,mapRange:ni,padEnd:ii,padStart:si,radToDeg:ai,random:pi,randomPick:gi,remove:Ze,round:ci,roundPad:ei,set:Je,shuffle:_i,snap:hi,stagger:yi,sync:ks,wrap:ri});const bi=t=>{const e=ye(t)[0];return e&&j(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ti=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},Si=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[l],o=t.getCTM(),a=0===s;return{from:0,to:r,modifier:i=>{const h=i+s*r;if("a"===e){const e=Ti(t,r,h,-1,a),s=Ti(t,r,h,1,a);return 180*pt(s.y-e.y,s.x-e.x)/mt}{const s=Ti(t,r,h,0,a);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},wi=(t,e=0)=>{const s=bi(t);if(s)return{translateX:Si(s,"x",e),translateY:Si(s,"y",e),rotate:Si(s,"a",e)}},xi=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(rt(s.a*s.a+s.b*s.b)+rt(s.c*s.c+s.d*s.d))/2)}return e},Ci=(t,e,s)=>{const i=f,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===u?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=xi(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:W(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h},Ei=(t,e=0,s=0)=>ye(t).map(t=>Ci(t,e,s)),ki=(t,e=.33)=>s=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const i=bi(t);if(!i)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(i.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${i.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const r="path"===s.tagName,n=r?" ":",",o=s[d];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+yt(d.x,3)+n+d.y+" ",h+=p+yt(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[d]=h,[a,h]};var $i=Object.freeze({__proto__:null,createDrawable:Ei,createMotionPath:wi,morphTo:ki});const Bi="undefined"!=typeof Intl&&Intl.Segmenter,Oi=/\{value\}/g,Ni=/\{i\}/g,Ri=/(\s+)/,Di=/^\s+$/,Li="line",Ai="word",Fi="char",Mi="data-line";let Pi=null,Ii=null,zi=null;const Ui=t=>t.isWordLike||" "===t.segment||Y(+t.segment),Xi=t=>t.setAttribute("aria-hidden","true"),Yi=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Vi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Wi=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Wi(e)}},Hi=(t,e,s)=>{const i=t.getAttribute(Mi);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)Hi(t.children[r],e,s);return s},qi=(t,e={})=>{let s="";const i=V(e.class)?` class="${e.class}"`:"",r=Lt(e.clone,!1),n=Lt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},ji=(t,e,s,i,r,n,o,a,h)=>{const l=r===Li,c=r===Fi,d=`_${r}_`,u=W(t)?t(s):t,p=l?"block":"inline-block";zi.innerHTML=u.replace(Oi,`<i class="${d}"></i>`).replace(Ni,`${c?h:l?o:a}`);const m=zi.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,_=m.querySelectorAll(`i.${d}`),y=_.length;if(y){f.style.display=p,g.style.display=p,g.setAttribute(Mi,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=y;for(;t--;){const e=_[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Vi[r]}`),f};class Gi{constructor(e,i={}){Pi||(Pi=Bi?new Bi([],{granularity:Ai}):{segment:t=>{const e=[],s=t.split(Ri);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Di.test(i)})}return e}}),Ii||(Ii=Bi?new Bi([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!zi&&t&&(zi=s.createElement("template")),A.current&&A.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=i,c=(e=U(e)?e[0]:e)&&e.nodeType?e:(_e(e)||[])[0],d=!0===o?{}:o,u=!0===r||H(r)?{}:r,p=!0===n?{}:n;this.debug=Lt(l,!1),this.includeSpaces=Lt(h,!1),this.accessible=Lt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=X(d)?qi(Li,d):d,this.wordTemplate=X(u)||this.linesOnly?qi(Ai,u):u,this.charTemplate=X(p)?qi(Fi,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!W(t))return console.warn("Effect must return a function.");const e=$s(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>W(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=Pi.segment(o),d=s.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=Ui(t);if(!u||s&&u&&Ui(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=i?Ii.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=s.createTextNode(a);ji(i,l,c,f,Fi,n,-1,h.length,l.length)}}e?ji(e,h,f,d,Ai,n,-1,h.length,l.length):i?d.appendChild(f):d.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>W(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Yi(e,Ai))),o&&(h||n)&&(this.chars=Yi(e,Fi));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(Mi,`${d}`);const r=e.querySelectorAll(`[${Mi}]`);let n=r.length;for(;n--;)r[n].setAttribute(Mi,`${d}`);c=s}if(h){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<d+1;t++){const s=e.cloneNode(!0);Hi(s,t,new Set).forEach(t=>{const e=t.parentElement;e&&i.add(e),t.remove()}),a.push(s)}i.forEach(Wi);for(let e=0,s=a.length;e<s;e++)ji(r,this.lines,a[e],t,Li,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Yi(e,Ai)),o&&(this.chars=Yi(e,Fi))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Xi),this.words.forEach(Xi),this.chars.forEach(Xi)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Qi=(t,e)=>new Gi(t,e),Ji=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Gi(t,e));var Zi=Object.freeze({__proto__:null,TextSplitter:Gi,split:Ji,splitText:Qi});const Ki=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(yt(t(i/e),4));return`linear(${s.join(", ")})`},tr={},er=t=>{let e=tr[t];if(e)return e;if(e="linear",V(t)){if(I(t,"linear")||I(t,"cubic-")||I(t,"steps")||I(t,"ease"))e=t;else if(I(t,"cubicB"))e=P(t);else{const s=Ne(t);W(s)&&(e=s===we?"linear":Ki(s))}tr[t]=e}else if(W(t)){const s=Ki(t);s&&(e=s)}else t.ease&&(e=Ki(t.ease));return e},sr=["x","y","z"],ir=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...sr],rr=(()=>[...sr,...b.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let nr=null;const or=(t,e,s,i,r)=>{let n=V(e)?e:At(e,s,i,r);return Y(n)?ir.includes(t)||I(t,"translate")?`${n}px`:I(t,"rotate")||I(t,"skew")?`${n}deg`:`${n}`:n},ar=(t,e,s,i,r,n)=>{let o="0";const a=H(i)?getComputedStyle(t)[e]:or(e,i,t,r,n);return o=H(s)?U(i)?i.map(s=>or(e,s,t,r,n)):a:[or(e,s,t,r,n),a],o};class hr{constructor(e,s){A.current&&A.current.register(this),q(nr)&&(!t||!H(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(b.forEach(t=>{const e=I(t,"skew"),s=I(t,"scale"),i=I(t,"rotate"),r=I(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),nr=!0):nr=!1);const i=ve(e),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Lt(s.ease,er(F.defaults.ease)),o=n.ease&&n,a=Lt(s.autoplay,F.defaults.autoplay),h=!(!a||!a.link)&&a,l=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=Lt(s.loop,F.defaults.loop),p=!0===u||u===1/0?1/0:Y(u)?u+1:1,m=l?d?"alternate-reverse":"alternate":d?"reverse":"normal",g=er(n),y=1===F.timeScale?1:f;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||F.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==h,this.reversed=d,this.persist=Lt(s.persist,F.defaults.persist),this.autoplay=a,this._speed=Lt(s.playbackRate,F.defaults.playbackRate),this._resolve=S,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[c],a=rr.some(t=>s.hasOwnProperty(t)),h=t.style,l=this._inlineStyles[e]={},d=(o?o.settlingDuration:At(Lt(s.duration,F.defaults.duration),t,e,r))*y,u=At(Lt(s.delay,F.defaults.delay),t,e,r)*y,f=Lt(s.composition,"replace");for(let o in s){if(!K(o))continue;const c={},_={iterations:p,direction:m,fill:"both",easing:g,duration:d,delay:u,composite:f},T=s[o],S=!!a&&(b.includes(o)?o:v.get(o)),w=S?"transform":o;let x;if(l[w]||(l[w]=h[w]),X(T)){const s=T,a=Lt(s.ease,n),l=a.ease&&a,p=s.to,m=s.from;if(_.duration=(l?l.settlingDuration:At(Lt(s.duration,d),t,e,r))*y,_.delay=At(Lt(s.delay,u),t,e,r)*y,_.composite=Lt(s.composition,f),_.easing=er(a),x=ar(t,o,m,p,e,r),S?(c[`--${S}`]=x,i[S]=x):c[o]=ar(t,o,m,p,e,r),Ge(this,t,o,c,_),!H(m))if(S){const t=`--${S}`;h.setProperty(t,c[t][0])}else h[o]=c[o][0]}else x=U(T)?T.map(s=>or(o,s,t,e,r)):or(o,T,t,e,r),S?(c[`--${S}`]=x,i[S]=x):c[o]=x,Ge(this,t,o,c,_)}if(a){let t=_;for(let e in i)t+=`${T[e]}var(--${e})) `;h.transform=t}}),h&&this.autoplay.link(this)}forEach(t){const e=V(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=F.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===F.timeScale?1:f);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel")}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let t in i){const e=i[t];H(e)||e===_?s.removeProperty(P(t)):s[t]=e}t.getAttribute("style")===_&&t.removeAttribute("style")}),this}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const lr={animate:(t,e)=>new hr(t,e),convertEase:Ki};export{ve as $,ns as Animatable,Cs as Draggable,We as JSAnimation,Bs as Scope,Us as ScrollObserver,_s as Spring,Gi as TextSplitter,is as Timeline,fe as Timer,hr as WAAPIAnimation,He as animate,li as clamp,jt as cleanInlineStyles,os as createAnimatable,Es as createDraggable,Ei as createDrawable,wi as createMotionPath,Os as createScope,fi as createSeededRandom,vs as createSpring,rs as createTimeline,ge as createTimer,Ws as cubicBezier,ui as damp,oi as degToRad,Be as eases,Gs as easings,ee as engine,Qe as get,js as irregular,$s as keepTime,di as lerp,qs as linear,ni as mapRange,ki as morphTo,Xs as onScroll,ii as padEnd,si as padStart,ai as radToDeg,pi as random,gi as randomPick,Ze as remove,ci as round,ei as roundPad,Ds as scrollContainers,Je as set,_i as shuffle,hi as snap,Ji as split,Qi as splitText,ys as spring,yi as stagger,Hs as steps,$i as svg,ks as sync,Zi as text,vi as utils,lr as waapi,ri as wrap};
+const t="undefined"!=typeof window,e=t?window:null,s=t?document:null,i={OBJECT:0,ATTRIBUTE:1,CSS:2,TRANSFORM:3,CSS_VAR:4},r={NUMBER:0,UNIT:1,COLOR:2,COMPLEX:3},n={NONE:0,AUTO:1,FORCE:2},o={replace:0,none:1,blend:2},a=Symbol(),h=Symbol(),l=Symbol(),d=Symbol(),c=Symbol(),u=Symbol(),p=1e-11,m=1e12,f=1e3,g=240,y="",v="var(",_=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),b=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],T=b.reduce((t,e)=>({...t,[e]:e+"("}),{}),S=()=>{},x=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,w=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,$=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,E=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,C=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,N=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,R=/([a-z])([A-Z])/g,I=/(\w+)(\([^)]+\)+)/g,D=/(\*=|\+=|-=)/,A=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,O={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:g,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:f,delay:0,loopDelay:0,ease:"out(2)",composition:o.replace,modifier:t=>t,onBegin:S,onBeforeUpdate:S,onUpdate:S,onLoop:S,onPause:S,onComplete:S,onRender:S},B={current:null,root:s},L={defaults:O,precision:4,timeScale:1,tickThreshold:200},P=t&&e.AnimeJSDevTools,M={version:"4.3.0-beta.0",engine:null};t&&(e.AnimeJS||(e.AnimeJS=[]),e.AnimeJS.push(M));const F=t=>t.replace(R,"$1-$2").toLowerCase(),V=(t,e)=>0===t.indexOf(e),z=Date.now,X=Array.isArray,H=t=>t&&t.constructor===Object,U=t=>"number"==typeof t&&!isNaN(t),Y=t=>"string"==typeof t,W=t=>"function"==typeof t,q=t=>void 0===t,j=t=>q(t)||null===t,G=e=>t&&e instanceof SVGElement,Q=t=>x.test(t),J=t=>V(t,"rgb"),Z=t=>V(t,"hsl"),K=t=>Q(t)||J(t)||Z(t),tt=t=>!L.defaults.hasOwnProperty(t),et=["opacity","rotate","overflow","color"],st=(t,e)=>{if(et.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}},it=t=>Y(t)?parseFloat(t):t,rt=Math.pow,nt=Math.sqrt,ot=Math.sin,at=Math.cos,ht=Math.abs,lt=Math.exp,dt=Math.ceil,ct=Math.floor,ut=Math.asin,pt=Math.max,mt=Math.atan2,ft=Math.PI,gt=Math.round,yt=(t,e,s)=>t<e?e:t>s?s:t,vt={},_t=(t,e)=>{if(e<0)return t;if(!e)return gt(t);let s=vt[e];return s||(s=vt[e]=10**e),gt(t*s)/s},bt=(t,e)=>X(e)?e.reduce((e,s)=>ht(s-t)<ht(e-t)?s:e):e?gt(t/e)*e:t,Tt=(t,e,s)=>t+(e-t)*s,St=t=>t===1/0?m:t===-1/0?-m:t,xt=t=>t<=p?p:St(_t(t,11)),wt=t=>X(t)?[...t]:t,$t=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=q(r)?e[i]:r}return s},Et=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},Ct=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},Nt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},kt=(t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[d];let o;for(;o=I.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!q(r)?r:V(e,"scale")?"1":V(e,"rotate")||V(e,"skew")?"0deg":"0px"},Rt=t=>{const e=w.exec(t)||$.exec(t),s=q(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]},It=t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]},Dt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),At=t=>{const e=E.exec(t)||C.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=q(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=_t(255*Dt(e,t,s+1/3),0),a=_t(255*Dt(e,t,s),0),h=_t(255*Dt(e,t,s-1/3),0)}return[o,a,h,n]},Ot=t=>J(t)?Rt(t):Q(t)?It(t):Z(t)?At(t):[0,0,0,1],Bt=(t,e)=>q(t)?e:t,Lt=(t,e,s,i,r)=>{let n;if(W(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!Y(t)||!V(t,v))return t;n=()=>{const s=t.match(A),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==y||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},Pt=(t,e)=>t[h]?t[l]&&st(t,e)?i.ATTRIBUTE:b.includes(e)||_.get(e)?i.TRANSFORM:V(e,"--")?i.CSS_VAR:e in t.style?i.CSS:e in t?i.OBJECT:i.ATTRIBUTE:i.OBJECT,Mt=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[u]||t).getPropertyValue(e);return"auto"===r?"0":r},Ft=(t,e,s,r)=>{const n=q(s)?Pt(t,e):s;return n===i.OBJECT?t[e]||0:n===i.ATTRIBUTE?t.getAttribute(e):n===i.TRANSFORM?kt(t,e,r):n===i.CSS_VAR?Mt(t,e,r).trimStart():Mt(t,e,r)},Vt=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,zt=()=>({t:r.NUMBER,n:0,u:null,o:null,d:null,s:null}),Xt=(t,e)=>{if(e.t=r.NUMBER,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const i=!s.includes(" ")&&k.exec(s);if(i)return e.t=r.UNIT,e.n=+i[1],e.u=i[2],e;if(e.o)return e.n=+s,e;if(K(s))return e.t=r.COLOR,e.d=Ot(s),e;{const t=s.match(N);return e.t=r.COMPLEX,e.d=t?t.map(Number):[],e.s=s.split(N)||[],e}}return e.n=s,e},Ht=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=wt(t._toNumbers),e.s=wt(t._strings),e),Ut=zt(),Yt=(t,e,s,a,h)=>{const l=t.parent,c=t.duration,u=t.completed,m=t.iterationDuration,f=t.iterationCount,g=t._currentIteration,v=t._loopDelay,_=t._reversed,b=t._alternate,S=t._hasChildren,x=t._delay,w=t._currentTime,$=x+m,E=e-x,C=yt(w,-x,c),N=yt(E,-x,c),k=E-w,R=N>0,I=N>=c,D=c<=p,A=h===n.FORCE;let O=0,B=E,P=0;if(f>1){const e=~~(N/(m+(I?0:v)));t._currentIteration=yt(e,0,f),I&&t._currentIteration--,O=t._currentIteration%2,B=N%(m+v)||0}const M=_^(b&&O),F=t._ease;let V=I?M?0:c:M?m-B:B;F&&(V=m*F(V/m)||0);const z=(l?l.backwards:E<w)?!M:!!M;if(t._currentTime=E,t._iterationTime=V,t.backwards=z,R&&!t.began?(t.began=!0,s||l&&(z||!l.began)||t.onBegin(t)):E<=0&&(t.began=!1),s||S||!R||t._currentIteration===g||t.onLoop(t),A||h===n.AUTO&&(e>=x&&e<=$||e<=x&&C>x||e>=$&&C!==c)||V>=$&&C!==c||V<=x&&C>0||e<=C&&C===c&&u||I&&!u&&D){if(R&&(t.computeDeltaTime(C),s||t.onBeforeUpdate(t)),!S){const e=A||(z?-1*k:k)>=L.tickThreshold,n=t._offset+(l?l._offset:0)+x+V;let h,c,u,p,m=t._head,f=0;for(;m;){const t=m._composition,s=m._currentTime,l=m._changeDuration,g=m._absoluteStartTime+m._changeDuration,v=m._nextRep,_=m._prevRep,b=t!==o.none;if((e||(s!==l||n<=g+(v?v._delay:0))&&(0!==s||n>=m._absoluteStartTime))&&(!b||!m._isOverridden&&(!m._isOverlapped||n<=g)&&(!v||v._isOverridden||n<=v._absoluteStartTime)&&(!_||_._isOverridden||n>=_._absoluteStartTime+_._changeDuration+m._delay))){const e=m._currentTime=yt(V-m._startTime,0,l),s=m._ease(e/m._updateDuration),n=m._modifier,g=m._valueType,y=m._tweenType,v=y===i.OBJECT,_=g===r.NUMBER,T=_&&v||0===s||1===s?-1:L.precision;let S,x;if(_)S=x=n(_t(Tt(m._fromNumber,m._toNumber,s),T));else if(g===r.UNIT)x=n(_t(Tt(m._fromNumber,m._toNumber,s),T)),S=`${x}${m._unit}`;else if(g===r.COLOR){const t=m._fromNumbers,e=m._toNumbers,i=_t(yt(n(Tt(t[0],e[0],s)),0,255),0),r=_t(yt(n(Tt(t[1],e[1],s)),0,255),0),o=_t(yt(n(Tt(t[2],e[2],s)),0,255),0),a=yt(n(_t(Tt(t[3],e[3],s),T)),0,1);if(S=`rgba(${i},${r},${o},${a})`,b){const t=m._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(g===r.COMPLEX){S=m._strings[0];for(let t=0,e=m._toNumbers.length;t<e;t++){const e=n(_t(Tt(m._fromNumbers[t],m._toNumbers[t],s),T)),i=m._strings[t+1];S+=`${i?e+i:e}`,b&&(m._numbers[t]=e)}}if(b&&(m._number=x),a||t===o.blend)m._value=S;else{const t=m.property;h=m.target,v?h[t]=S:y===i.ATTRIBUTE?h.setAttribute(t,S):(c=h.style,y===i.TRANSFORM?(h!==u&&(u=h,p=h[d]),p[t]=S,f=1):y===i.CSS?c[t]=S:y===i.CSS_VAR&&c.setProperty(t,S)),R&&(P=1)}}if(f&&m._renderTransforms){let t=y;for(let e in p)t+=`${T[e]}${p[e]}) `;c.transform=t,f=0}m=m._next}!s&&P&&t.onRender(t)}!s&&R&&t.onUpdate(t)}return l&&D?!s&&(l.began&&!z&&E>0&&!u||z&&E<=p&&u)&&(t.onComplete(t),t.completed=!z):R&&I?f===1/0?t._startTime+=t.duration:t._currentIteration>=f-1&&(t.paused=!0,u||S||(t.completed=!0,s||l&&(z||!l.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,P},Wt=(t,e,s,i,r)=>{const o=t._currentIteration;if(Yt(t,e,s,i,r),t._hasChildren){const a=t,h=a.backwards,l=i?e:a._iterationTime,d=z();let c=0,u=!0;if(!i&&a._currentIteration!==o){const t=a.iterationDuration;Et(a,e=>{if(h){const i=e.duration,r=e._offset+e._delay;s||!(i<=p)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Yt(e,t,s,1,n.FORCE),e.began=!1,e.completed=!1}),s||a.onLoop(a)}Et(a,t=>{const e=_t((l-t._offset)*t._speed,12),n=t._fps<a._fps?t.requestTick(d):r;c+=Yt(t,e,s,i,n),!t.completed&&u&&(u=!1)},h),!s&&c&&a.onRender(a),(u||h)&&a._currentTime>=a.duration&&(a.paused=!0,a.completed||(a.completed=!0,s||(a.onComplete(a),a._resolve(a))))}},qt={},jt=(t,e,s)=>{if(s===i.TRANSFORM)return _.get(t)||t;if(s===i.CSS||s===i.ATTRIBUTE&&G(e)&&t in e.style){const e=qt[t];if(e)return e;{const e=t?F(t):t;return qt[t]=e,e}}return t},Gt=t=>{if(t._hasChildren)Et(t,Gt,!0);else{const e=t;e.pause(),Et(e,t=>{const s=t.property,r=t.target;if(r[h]){const n=r.style,o=t._inlineValue,a=j(o)||o===y;if(t._tweenType===i.TRANSFORM){const e=r[d];if(a?delete e[s]:e[s]=o,t._renderTransforms)if(Object.keys(e).length){let t=y;for(let s in e)t+=T[s]+e[s]+") ";n.transform=t}else n.removeProperty("transform")}else a?n.removeProperty(F(s)):n[s]=o;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===y&&t.removeAttribute("style")})}})}return t};class Qt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=f/g,this._fps=g,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<p?p:s,r=f/i;i>O.frameRate&&(O.frameRate=i),this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<p?p:e}requestTick(t){const e=this._scheduledTime;if(this._lastTickTime=t,t<e)return n.NONE;const s=this._frameDuration,i=t-e;return this._scheduledTime+=i<s?s:i,n.AUTO}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Jt={animation:null,update:S},Zt=t=>{let e=Jt.animation;return e||(e={duration:p,computeDeltaTime:S,_offset:0,_delay:0,_head:null,_tail:null},Jt.animation=e,Jt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=t===r.COMPLEX||t===r.COLOR?wt(i._fromNumbers):null;let n=i._fromNumber,o=s._tail;for(;o&&o!==i;){if(e)for(let t=0,s=o._numbers.length;t<s;t++)e[t]+=o._numbers[t];else n+=o._number;o=o._prevAdd}i._toNumber=n,i._toNumbers=e}}}),Yt(e,1,1,0,n.FORCE)}),e},Kt=(()=>t?requestAnimationFrame:setImmediate)(),te=(()=>t?cancelAnimationFrame:clearImmediate)();class ee extends Qt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=O,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=z();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(Ct(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Wt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):n.AUTO),i=r}Jt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(z()),this.reqId=Kt(ie)),this}pause(){if(this.reqId)return this.paused=!0,re()}resume(){if(this.paused)return this.paused=!1,Et(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===L.timeScale?1:f)}set speed(t){this._speed=t*L.timeScale,Et(this,t=>t.speed=t._speed)}get timeUnit(){return 1===L.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(L.timeScale!==s){L.timeScale=s,L.tickThreshold=200*s;const t=e?.001:f;this.defaults.duration*=t,this._speed*=t}}get precision(){return L.precision}set precision(t){L.precision=t}}const se=(()=>{const e=new ee(z());return t&&(M.engine=e,s.addEventListener("visibilitychange",()=>{e.pauseOnDocumentHidden&&(s.hidden?e.pause():e.resume())})),e})(),ie=()=>{se._head?(se.reqId=Kt(ie),se.update()):se.reqId=0},re=()=>(te(se.reqId),se.reqId=0,se),ne={_rep:new WeakMap,_add:new Map},oe=(t,e,s="_rep")=>{const i=ne[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},ae=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,he=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=p,t._currentTime=p},le=(t,e)=>{const s=t._composition;if(s===o.replace){const s=t._absoluteStartTime;Nt(e,t,ae,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){he(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)he(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=_t(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<p&&he(i)}let o=!0;if(Et(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;Et(t,t=>{t!==e&&Et(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===o.blend){const e=oe(t.target,t.property,"_add"),s=Zt(ne._add);let i=e._head;i||(i={...t},i._composition=o.replace,i._updateDuration=p,i._startTime=0,i._numbers=wt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,Nt(e,i),Nt(s,i));const r=t._toNumber;if(t._fromNumber=i._fromNumber-r,t._toNumber=0,t._numbers=wt(t._fromNumbers),t._number=0,i._fromNumber=r,t._toNumbers){const e=wt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}Nt(e,t,null,"_prevAdd","_nextAdd")}return t},de=t=>{const e=t._composition;if(e!==o.none){const s=t.target,i=t.property,r=ne._rep.get(s)[i];if(Ct(r,t,"_prevRep","_nextRep"),e===o.blend){const e=ne._add,r=e.get(s);if(!r)return;const n=r[i],o=Jt.animation;Ct(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){Ct(n,a,"_prevAdd","_nextAdd"),Ct(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},ce=(t,e,s)=>{let r=!1;return Et(e,n=>{const o=n.target;if(t.includes(o)){const t=n.property,a=n._tweenType,h=jt(s,o,a);(!h||h&&h===t)&&(n.parent._tail===n&&n._tweenType===i.TRANSFORM&&n._prev&&n._prev._tweenType===i.TRANSFORM&&(n._prev._renderTransforms=1),Ct(e,n),de(n),r=!0)}},!0),r},ue=(t,e,s)=>{const i=e||se;let r;if(i._hasChildren){let e=0;Et(i,n=>{if(!n._hasChildren)if(r=ce(t,n,s),r&&!n._head)n.cancel(),Ct(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?ue(t,n,s):n._hasChildren=!1},!0),q(i.iterationDuration)||(i.iterationDuration=e)}else r=ce(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},pe=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),me=t=>t._cancelled?(t._hasChildren?Et(t,me):Et(t,t=>{t._composition!==o.none&&le(t,oe(t.target,t.property))}),t._cancelled=0,t):t;let fe=0;class ge extends Qt{constructor(t={},e=null,s=0){super(0),++fe;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:d,frameRate:c,playbackRate:u,onComplete:m,onLoop:f,onPause:g,onBegin:y,onBeforeUpdate:v,onUpdate:_}=t;B.current&&B.current.register(this);const b=e?0:se._lastTickTime,T=e?e.defaults:L.defaults,x=W(r)||q(r)?T.delay:+r,w=W(n)||q(n)?1/0:+n,$=Bt(h,T.loop),E=Bt(l,T.loopDelay);let C=!0===$||$===1/0||$<0?1/0:$+1;if(P){const s=C===1/0;if(P.register(this,t,s)&&s){const t=a?2:1,s=e?P.maxNestedInfiniteLoops:P.maxInfiniteLoops;C=Math.max(s,t)}}let N=0;e?N=s:(se.reqId||se.requestTick(z()),N=(se._lastTickTime-se._startTime)*L.timeScale),this.id=q(i)?fe:i,this.parent=e,this.duration=St((w+E)*C-E)||p,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=y||T.onBegin,this.onBeforeUpdate=v||T.onBeforeUpdate,this.onUpdate=_||T.onUpdate,this.onLoop=f||T.onLoop,this.onPause=g||T.onPause,this.onComplete=m||T.onComplete,this.iterationDuration=w,this.iterationCount=C,this._autoplay=!e&&Bt(d,T.autoplay),this._offset=N,this._delay=x,this._loopDelay=E,this._iterationTime=0,this._currentIteration=0,this._resolve=S,this._running=!1,this._reversed=+Bt(o,T.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Bt(a,T.alternate),this._prev=null,this._next=null,this._lastTickTime=b,this._startTime=b,this._lastTime=b,this._fps=Bt(c,T.frameRate),this._speed=Bt(u,T.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return yt(_t(this._currentTime,L.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return yt(_t(this._iterationTime,L.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return yt(_t(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return yt(_t(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*yt(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return me(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Wt(this,0,1,~~t,n.FORCE),pe(this),this._hasChildren&&Et(this,pe),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Wt(this,this.duration,1,~~t,n.FORCE),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!q(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*se._speed);return this._startTime=z()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=p&&!this._hasChildren?Wt(this,p,0,0,n.FORCE):(this._running||(Nt(se,this),se._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,se.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){me(this),this.completed=!1;const i=this.paused;return this.paused=!0,Wt(this,t+this._delay,~~e,~~s,n.AUTO),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?ct(m/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?Et(this,t=>t.cancel(),!0):Et(this,de),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=xt(t);if(e===s)return this;const i=t/e,r=t<=p;return this.duration=r?p:s,this.iterationDuration=r?p:xt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Wt(this,0,1,0,n.AUTO);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const ye=t=>new ge(t,null,0).init();function ve(t){const e=Y(t)?B.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function _e(e){if(j(e))return[];if(!t)return X(e)&&e.flat(1/0)||[e];if(X(e)){const t=e.flat(1/0),s=[];for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!j(i)){const t=ve(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!j(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=ve(e);return s?Array.from(s):[e]}function be(t){const e=_e(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[a]){s[a]=!0;const t=G(s);(s.nodeType||t)&&(s[h]=!0,s[l]=t,s[d]={})}}return e}const Te={deg:1,rad:180/ft,turn:360},Se={},xe=(t,e,i,n=!1)=>{const o=e.u,a=e.n;if(e.t===r.UNIT&&o===i)return e;const h=a+o+i,l=Se[h];if(q(l)||n){let r;if(o in Te)r=a*Te[o]/Te[i];else{const e=100,n=t.cloneNode(),h=t.parentNode,l=h&&h!==s?h:s.body;l.appendChild(n);const d=n.style;d.width=e+o;const c=n.offsetWidth||e;d.width=e+i;const u=c/(n.offsetWidth||e);l.removeChild(n),r=u*a}e.n=r,Se[h]=r}else e.n=l;return e.t,e.u=i,e},we=t=>t,$e=(t=1.68)=>e=>rt(e,+t),Ee={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},Ce=ft/2,Ne=2*ft,ke={[y]:$e,Quad:$e(2),Cubic:$e(3),Quart:$e(4),Quint:$e(5),Sine:t=>1-at(t*Ce),Circ:t=>1-nt(1-t*t),Expo:t=>t?rt(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=rt(2,--s))-1)/11;);return 1/rt(4,3-s)-7.5625*rt((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=yt(+t,1,10),i=yt(+e,p,2),r=i/Ne*ut(1/s),n=Ne/i;return t=>0===t||1===t?t:-s*rt(2,-10*(1-t))*ot((1-t-r)*n)}},Re=(()=>{const t={linear:we,none:we};for(let e in Ee)for(let s in ke){const i=ke[s],r=Ee[e];t[e+s]=s===y||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),Ie={linear:we,none:we},De=t=>{if(Ie[t])return Ie[t];if(t.indexOf("(")<=-1){const e=Ee[t]||t.includes("Back")||t.includes("Elastic")?Re[t]():Re[t];return e?Ie[t]=e:we}{const e=t.slice(0,-1).split("("),s=Re[e[0]];return s?Ie[t]=s(...e[1].split(",")):we}},Ae=["steps(","irregular(","linear(","cubicBezier("],Oe=t=>{if(Y(t))for(let e=0,s=Ae.length;e<s;e++)if(V(t,Ae[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),we;return W(t)?t:Y(t)?De(t):we},Be=zt(),Le=zt(),Pe={},Me={func:null},Fe=[null],Ve=[null,null],ze={to:null};let Xe,He,Ue=0,Ye=0;const We=(t,e)=>{const s={};if(X(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(tt);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];tt(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Bt(e.duration,L.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(tt(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?d:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s};class qe extends ge{constructor(t,e,s,n,a=!1,h=0,l=0){super(e,s,n),++Ye;const d=be(t),c=d.length,u=e.keyframes,m=u?$t(We(u,e),e):e,{id:g,delay:y,duration:v,ease:_,playbackEase:b,modifier:T,composition:S,onRender:x}=m,w=s?s.defaults:L.defaults,$=Bt(_,w.ease),E=Bt(b,w.playbackEase),C=E?Oe(E):null,N=!q($.ease),k=N?$.ease:Bt(_,C?"linear":w.ease),R=N?$.settlingDuration:Bt(v,w.duration),I=Bt(y,w.delay),D=T||w.modifier,A=q(S)&&c>=f?o.none:q(S)?w.composition:S,O=this._offset+(s?s._offset:0);N&&($.parent=this);let B=NaN,P=NaN,M=0,F=0;for(let t=0;t<c;t++){const e=d[t],n=h||t,u=l||c;let f=NaN,g=NaN;for(let t in m)if(tt(t)){const h=Pt(e,t),l=jt(t,e,h);let d=m[t];const c=X(d);if(a&&!c&&(Ve[0]=d,Ve[1]=d,d=Ve),c){const t=d.length,e=!H(d[0]);2===t&&e?(ze.to=d,Fe[0]=ze,Xe=Fe):t>2&&e?(Xe=[],d.forEach((t,e)=>{e?1===e?(Ve[1]=t,Xe.push(Ve)):Xe.push(t):Ve[0]=t})):Xe=d}else Fe[0]=d,Xe=Fe;let y=null,v=null,_=NaN,b=0,T=0;for(let t=Xe.length;T<t;T++){const i=Xe[T];H(i)?He=i:(ze.to=i,He=ze),Me.func=null;const a=Lt(He.to,e,n,u,Me);let d;H(a)&&!q(a.to)?(He=a,d=a.to):d=a;const c=Lt(He.from,e,n,u),m=He.ease,f=!q(m)&&!q(m.ease),g=f?m.ease:m||k,S=f?m.settlingDuration:Lt(Bt(He.duration,t>1?Lt(R,e,n,u)/t:R),e,n,u),x=Lt(Bt(He.delay,T?0:I),e,n,u),w=Lt(Bt(He.composition,A),e,n,u),$=U(w)?w:o[w],E=He.modifier||D,C=!q(c),N=!q(d),B=X(d),L=B||C&&N,P=v?b+x:x,V=_t(O+P,12);F||!C&&!B||(F=1);let z=v;if($!==o.none){y||(y=oe(e,l));let t=y._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=V;)if(z=t,t=t._nextRep,t&&t._absoluteStartTime>=V)for(;t;)he(t),t=t._nextRep}if(L){Xt(B?Lt(d[0],e,n,u):c,Be),Xt(B?Lt(d[1],e,n,u,Me):d,Le);const t=Ft(e,l,h,Pe);Be.t===r.NUMBER&&(z?z._valueType===r.UNIT&&(Be.t=r.UNIT,Be.u=z._unit):(Xt(t,Ut),Ut.t===r.UNIT&&(Be.t=r.UNIT,Be.u=Ut.u)))}else N?Xt(d,Le):v?Ht(v,Le):Xt(s&&z&&z.parent.parent===s?z._value:Ft(e,l,h,Pe),Le),C?Xt(c,Be):v?Ht(v,Be):Xt(s&&z&&z.parent.parent===s?z._value:Ft(e,l,h,Pe),Be);if(Be.o&&(Be.n=Vt(z?z._toNumber:Xt(Ft(e,l,h,Pe),Ut).n,Be.n,Be.o)),Le.o&&(Le.n=Vt(Be.n,Le.n,Le.o)),Be.t!==Le.t)if(Be.t===r.COMPLEX||Le.t===r.COMPLEX){const t=Be.t===r.COMPLEX?Be:Le,e=Be.t===r.COMPLEX?Le:Be;e.t=r.COMPLEX,e.s=wt(t.s),e.d=t.d.map(()=>e.n)}else if(Be.t===r.UNIT||Le.t===r.UNIT){const t=Be.t===r.UNIT?Be:Le,e=Be.t===r.UNIT?Le:Be;e.t=r.UNIT,e.u=t.u}else if(Be.t===r.COLOR||Le.t===r.COLOR){const t=Be.t===r.COLOR?Be:Le,e=Be.t===r.COLOR?Le:Be;e.t=r.COLOR,e.s=t.s,e.d=[0,0,0,1]}if(Be.u!==Le.u){let t=Le.u?Be:Le;t=xe(e,t,Le.u?Le.u:Be.u,!1)}if(Le.d&&Be.d&&Le.d.length!==Be.d.length){const t=Be.d.length>Le.d.length?Be:Le,e=t===Be?Le:Be;e.d=t.d.map((t,s)=>q(e.d[s])?0:e.d[s]),e.s=wt(t.s)}const Y=_t(+S||p,12);let W=Pe[l];j(W)||(Pe[l]=null);const G={parent:this,id:Ue++,property:l,target:e,_value:null,_func:Me.func,_ease:Oe(g),_fromNumbers:wt(Be.d),_toNumbers:wt(Le.d),_strings:wt(Le.s),_fromNumber:Be.n,_toNumber:Le.n,_numbers:wt(Be.d),_number:Be.n,_unit:Le.u,_modifier:E,_currentTime:0,_startTime:P,_delay:+x,_updateDuration:Y,_changeDuration:Y,_absoluteStartTime:V,_tweenType:h,_valueType:Le.t,_composition:$,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:W,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};$!==o.none&&le(G,y),isNaN(_)&&(_=G._startTime),b=_t(P+Y,12),v=G,M++,Nt(this,G)}(isNaN(P)||_<P)&&(P=_),(isNaN(B)||b>B)&&(B=b),h===i.TRANSFORM&&(f=M-T,g=M)}if(!isNaN(f)){let t=0;Et(this,e=>{t>=f&&t<g&&(e._renderTransforms=1,e._composition===o.blend&&Et(Jt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}c||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),P?(Et(this,t=>{t._startTime-t._delay||(t._delay-=P),t._startTime-=P}),B-=P):P=0,B||(B=p,this.iterationCount=0),this.targets=d,this.id=q(g)?Ye:g,this.duration=B===p?p:St((B+this._loopDelay)*this.iterationCount-this._loopDelay)||p,this.onRender=x||w.onRender,this._ease=C,this._delay=P,this.iterationDuration=B,!this._autoplay&&F&&this.onRender(this)}stretch(t){const e=this.duration;if(e===xt(t))return this;const s=t/e;return Et(this,t=>{t._updateDuration=xt(t._updateDuration*s),t._changeDuration=xt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return Et(this,t=>{const e=t._func;if(e){const s=Ft(t.target,t.property,t._tweenType);Xt(s,Ut),Xt(e(),Le),t._fromNumbers=wt(Ut.d),t._fromNumber=Ut.n,t._toNumbers=wt(Le.d),t._strings=wt(Le.s),t._toNumber=Le.o?Vt(Ut.n,Le.n,Le.o):Le.n}}),this.duration===p&&this.restart(),this}revert(){return super.revert(),Gt(this)}then(t){return super.then(t)}}const je=(t,e)=>new qe(t,e,null,0,!1).init(),Ge={_head:null,_tail:null},Qe=(t,e,s)=>{let i,r=Ge._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),Ct(Ge,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Je=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Qe(e,s),Nt(Ge,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Qe(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Ze(t,e,s){const i=be(t);if(!i.length)return;const[n]=i,o=Pt(n,e),a=jt(e,n,o);let h=Ft(n,a);if(q(s))return h;if(Xt(h,Ut),Ut.t===r.NUMBER||Ut.t===r.UNIT){if(!1===s)return Ut.n;{const t=xe(n,Ut,s,!1);return`${_t(t.n,L.precision)}${t.u}`}}}const Ke=(t,e)=>{if(!q(e))return e.duration=p,e.composition=Bt(e.composition,o.none),new qe(t,e,null,0,!0).resume()},ts=(t,e,s)=>{const i=_e(t);for(let t=0,r=i.length;t<r;t++)Qe(i[t],s,e&&e.controlAnimation&&e);return ue(i,e,s),i},es=(t,e)=>{if(V(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}},ss=(t,e)=>{let s=t.iterationDuration;if(s===p&&(s=0),q(e))return s;if(U(+e))return+e;const i=e,r=t?t.labels:null,n=!j(r),o=es(t,i),a=!q(o),h=D.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,d=a?o:n?l:s,c=+e[1];return Vt(d,c,t[0])}return a?o:n?q(r[i])?s:r[i]:s};function is(t){return St((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||p}function rs(t,e,s,i,r,o){const a=U(t.duration)&&t.duration<=p?s-p:s;e.composition&&Wt(e,a,1,1,n.AUTO);const h=i?new qe(i,t,e,a,!1,r,o):new ge(t,e,a);return e.composition&&h.init(!0),Nt(e,h),Et(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=is(e),e}let ns=0;class os extends ge{constructor(t={}){super(t,null,0),++ns,this.id=q(t.id)?ns:t.id,this.duration=0,this.labels={};const e=t.defaults,s=L.defaults;this.defaults=e?$t(e,s):s,this.composition=Bt(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=Bt(t.playbackEase,s.playbackEase);this._ease=i?Oe(i):null,this.iterationDuration=0}add(t,e,s){const i=H(e),r=H(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(W(s)){const e=s,r=_e(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,q(a)||(s.id=a+"-"+h),rs(s,this,ss(this,e(t,h,l,this)),t,h,l),h++})}else rs(i,this,ss(this,s),t)}else rs(t,this,ss(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(q(t)||t&&q(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e)}set(t,e,s){return q(e)?this:(e.duration=p,e.composition=o.replace,this.add(t,e,s))}call(t,e){return q(t)||t&&!W(t)?this:this.add({duration:0,delay:0,onComplete:()=>t(this)},e)}label(t,e){return q(t)||t&&!Y(t)||(this.labels[t]=ss(this,e)),this}remove(t,e){return ue(_e(t),this,e),this}stretch(t){const e=this.duration;if(e===xt(t))return this;const s=t/e,i=this.labels;Et(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return Et(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),Et(this,t=>t.revert,!0),Gt(this)}then(t){return super.then(t)}}const as=t=>new os(t).init();class hs{constructor(t,e){B.current&&B.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},r={v:1,autoplay:!1},n={};if(this.targets=[],this.animations={},this.callbacks=null,!q(t)&&!q(e)){for(let t in e){const s=e[t];tt(t)?n[t]=s:V(t,"on")?r[t]=s:i[t]=s}this.callbacks=new qe({v:0},r);for(let e in n){const s=n[e],r=H(s);let a={},h="+=0";if(r){const t=s.unit;Y(t)&&(h+=t)}else a.duration=s;a[e]=r?$t({to:h},s):h;const l=$t(i,a);l.composition=o.replace,l.autoplay=!1;const d=this.animations[e]=new qe(t,l,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(q(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return Et(d,e=>{if(X(t))for(let s=0,i=t.length;s<i;s++)q(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;q(s)||(e._ease=Oe(s)),e._currentTime=0}),q(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=S,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const ls=(t,e)=>new hs(t,e),ds=(t,e)=>(+t).toFixed(e),cs=(t,e,s)=>`${t}`.padStart(e,s),us=(t,e,s)=>`${t}`.padEnd(e,s),ps=(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e,ms=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i),fs=t=>t*Math.PI/180,gs=t=>180*t/Math.PI,ys=(t,e,s,i)=>i?1===i?e:Tt(t,e,1-Math.exp(-i*s*.1)):t;var vs=Object.freeze({__proto__:null,clamp:yt,damp:ys,degToRad:fs,lerp:Tt,mapRange:ms,padEnd:us,padStart:cs,radToDeg:gs,round:_t,roundPad:ds,snap:bt,wrap:ps});const _s=10*f;class bs{constructor(t={}){const e=!q(t.bounce)||!q(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/f,this.maxIterations=this.maxDuration/this.timeStep/f,this.bn=yt(Bt(t.bounce,.5),-1,1),this.pd=yt(Bt(t.duration,628),10*L.timeScale,_s*L.timeScale),this.m=yt(Bt(t.mass,1),1,_s),this.s=yt(Bt(t.stiffness,100),p,_s),this.d=yt(Bt(t.damping,10),p,_s),this.v=yt(Bt(t.velocity,0),-1e4,_s),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||S,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?lt(-n*e*s)*(1*at(i*n)+r*ot(i*n)):1===e?(1+r*n)*lt(-n*s):((1+r)*lt((-e*s+i)*n)+(1-r)*lt((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===L.timeScale?this.pd/f:this.pd;this.m=1,this.v=0,this.s=rt(2*ft/t,2),this.bn>=0?this.d=4*(1-this.bn)*ft/t:this.d=4*ft/(t*(1+this.bn)),this.s=_t(yt(this.s,p,_s),3),this.d=_t(yt(this.d,p,300),3)}calculateBDFromSD(){const t=2*ft/nt(this.s);this.pd=t*(1===L.timeScale?f:1);const e=this.d/(2*nt(this.s));this.bn=e<=1?1-this.d*t/(4*ft):4*ft/(this.d*t)-1,this.bn=_t(yt(this.bn,-1,1),3),this.pd=_t(yt(this.pd,10*L.timeScale,_s*L.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=yt(nt(o/r),p,f),l=this.zeta=n/(2*nt(o*r));l<1?(this.wd=h*nt(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*nt(l*l-1),this.b=(l*h-a)/this.wd);let d=0,c=0,u=0;for(;c<=t&&u<=e;)ht(1-this.solve(d))<s?c++:c=0,this.solverDuration=d,d+=i,u++;this.settlingDuration=_t(this.solverDuration*f,0)*L.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=yt(Bt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=yt(Bt(t,1),10*L.timeScale,_s*L.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=yt(Bt(t,100),p,_s),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=yt(Bt(t,10),p,_s),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=yt(Bt(t,1),1,_s),this.compute()}get velocity(){return this.v}set velocity(t){this.v=yt(Bt(t,0),-1e4,_s),this.compute()}}const Ts=t=>new bs(t),Ss=t=>(console.warn("createSpring() is deprecated use spring() instead"),new bs(t)),xs=t=>{t.cancelable&&t.preventDefault()};class ws{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:S,remove:S}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class $s{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,i=0;for(;e&&e!==s;)t(e,i),e=e.parentElement,i++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const Es=(t,e)=>t&&W(t)?t(e):t;let Cs=0;class Ns{constructor(t,i={}){if(!t)return;B.current&&B.current.register(this);const r=i.x,n=i.y,o=i.trigger,a=i.modifier,h=i.releaseEase,l=h&&Oe(h),d=!q(h)&&!q(h.ease),c=H(r)&&!q(r.mapTo)?r.mapTo:"translateX",u=H(n)&&!q(n.mapTo)?n.mapTo:"translateY",p=Es(i.container,this);this.containerArray=X(p)?p:null,this.$container=p&&!this.containerArray?_e(p)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.$target=H(t)?new ws(t):_e(t)[0],this.$trigger=_e(o||t)[0],this.fixed="fixed"===Ze(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?h:Ts({mass:Bt(i.releaseMass,1),stiffness:Bt(i.releaseStiffness,80),damping:Bt(i.releaseDamping,20)}),this.releaseYSpring=d?h:Ts({mass:Bt(i.releaseMass,1),stiffness:Bt(i.releaseStiffness,80),damping:Bt(i.releaseDamping,20)}),this.releaseEase=l||Re.outQuint,this.hasReleaseSpring=d,this.onGrab=i.onGrab||S,this.onDrag=i.onDrag||S,this.onRelease=i.onRelease||S,this.onUpdate=i.onUpdate||S,this.onSettle=i.onSettle||S,this.onSnap=i.onSnap||S,this.onResize=i.onResize||S,this.onAfterResize=i.onAfterResize||S,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),q(r)||!0===r)f[c]=0;else if(H(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[c]=e}else!1===r&&(f[c]=0,this.disabled[0]=1);if(q(n)||!0===n)f[u]=0;else if(H(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[u]=e}else!1===n&&(f[u]=0,this.disabled[1]=1);this.animate=new hs(this.$target,f),this.xProp=c,this.yProp=u,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-m,m,m,-m],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=z(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new $s(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new ge({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new ge({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!q(p),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?c:u,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=mt(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new ge({autoplay:!1,duration:150*L.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=i,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),H(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=z(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=_t(yt(nt(t*t+e*e)/r*o,a,h),5);const d=pt(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(l+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=_t(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=bt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=_t(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=bt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return _t(this.animate[this.xProp](),L.precision)}set x(t){this.setX(t,!1)}get y(){return _t(this.animate[this.yProp](),L.precision)}set y(t){this.setY(t,!1)}get progressX(){return ms(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(ms(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return ms(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(ms(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=_t(this.useWin?e.scrollX:this.$container.scrollLeft,0),s=_t(this.useWin?e.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=s,this.scrollBounds[0]=s-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=s-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const i=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=e.innerWidth,h=this.window[1]=e.innerHeight,l=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?yt(d,a,d):d,this.scrollView[1]=l?yt(c,h,c):c,this.updateScrollCoords();const{width:v,height:_,left:b,top:T,right:S,bottom:x}=t.getBoundingClientRect();this.dragArea[2]=_t(l?yt(v,a,a):v,0),this.dragArea[3]=_t(l?yt(_,h,h):_,0);const w=Ze(t,"overflow"),$="visible"===w,E="hidden"===w;if(this.canScroll=!u&&this.contained&&(t===s.body&&$||!E&&!$)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!X(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,d=i?this.scrollView[0]-n-v:0,c=i?this.scrollView[1]-o-_:0;this.targetBounds[0]=_t(r.top+s-(l?0:T),0),this.targetBounds[1]=_t(r.right+e-(l?a:S),0),this.targetBounds[2]=_t(r.bottom+s-(l?h:x),0),this.targetBounds[3]=_t(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-_t(r.top-(u?yt(T,0,h):T)+o-m,0),this.containerBounds[1]=-_t(r.right-(u?yt(S,0,a):S)-d+f,0),this.containerBounds[2]=-_t(r.bottom-(u?yt(x,0,h):x)-c+g,0),this.containerBounds[3]=-_t(r.left-(u?yt(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(i,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,d=!h&&s<i||!h&&s>n;return l&&!d?1:!l&&d?2:l&&d?3:0}refresh(){const t=this.parameters,i=t.x,r=t.y,n=Es(t.container,this),o=Es(t.containerPadding,this)||0,a=X(o)?o:[o,o,o,o],h=this.x,l=this.y,d=Es(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=Es(t.dragThreshold,this),p={mouse:3,touch:7};if(U(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;q(t)||(p.mouse=t),q(e)||(p.touch=e)}this.containerArray=X(n)?n:null,this.$container=n&&!this.containerArray?_e(n)[0]:s.body,this.useWin=this.$container===s.body,this.$scrollContainer=this.useWin?e:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Bt(a,[0,0,0,0]),this.containerFriction=yt(Bt(Es(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=yt(Bt(Es(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=Es(H(i)&&!q(i.snap)?i.snap:t.snap,this),this.snapY=Es(H(r)&&!q(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Bt(Es(t.scrollSpeed,this),1.5),this.scrollThreshold=Bt(Es(t.scrollThreshold,this),20),this.dragSpeed=Bt(Es(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=Bt(Es(t.minVelocity,this),0),this.maxVelocity=Bt(Es(t.maxVelocity,this),50),this.velocityMultiplier=Bt(Es(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(yt(h,y,f),!0),this.setY(yt(l,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?yt(d,this.window[0],d):d,p=this.useWin?yt(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[v,_]=this.coords,[b,T,S,x]=this.scrollBounds,w=_t(yt((_-b+t)/y,-1,0)*g,0),$=_t(yt((v-T-e)/y,0,1)*g,0),E=_t(yt((_-S-s)/y,0,1)*g,0),C=_t(yt((v-x+i)/y,-1,0)*g,0);if(w||E||C||$){const[t,e]=this.disabled;let s=h,i=l;t||(s=_t(yt(h+(C||$),0,r-o),0),this.coords[0]-=h-s),e||(i=_t(yt(l+(w||E),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-h,n-l),this.angle=mt(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return ue([this],null,"x"),ue([this],null,"y"),ue([this],null,"progressX"),ue([this],null,"progressY"),ue([this.scroll]),ue([this.overshootCoords]),this}scrollInView(t,e=0,s=Re.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,d,c]=o,u=_t(yt(r-h,-m,0),0),p=_t(yt(i-l,0,m),0),f=_t(yt(r-d,0,m),0),g=_t(yt(i-c,-m,0),0);new qe(n,{x:_t(n.x+(g?g-e:p?p+e:0),0),y:_t(n.y+(u?u-e:f?f+e:0),0),duration:q(t)?350*L.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Ke(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=Re.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=yt(bt(i,this.snapX),u,d),a=yt(bt(r,this.snapY),l,c),h=q(t)?350*L.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const i=t.changedTouches,r=i?i[0].clientX:t.clientX,n=i?i[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Ze(this.$target,"zIndex",!1);Cs=(f>Cs?f:Cs)+1,this.targetStyles=Ke(this.$target,{zIndex:Cs}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Ke(s.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,Re.out(3)),this.onGrab(this),s.addEventListener("touchmove",this),s.addEventListener("touchend",this),s.addEventListener("touchcancel",this),s.addEventListener("mousemove",this),s.addEventListener("mouseup",this),s.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,d=!1,c=!1;for(;e&&h&&h!==this.$trigger;){const t=Ze(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){c=!0,l=t<=3,d=t>=e-s-3;break}}h=h.parentElement}c&&(!l&&!d||l&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(xs(t),this.triggerStyles||(this.triggerStyles=Ke(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",xs,{passive:!1}),this.$trigger.addEventListener("touchmove",xs,{passive:!1}),this.$trigger.addEventListener("touchend",xs),(this.dragged||!this.disabled[0]&&ht(o)>this.dragThreshold||!this.disabled[1]&&ht(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[i,r,n,a,h,l]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,v=this.releaseEase,_=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,S=this.y,x=this.computeVelocity(i-h,r-l),w=this.angle=mt(r-a,i-n),$=150*x,E=(1-this.releaseContainerFriction)*this.dragSpeed,C=T+at(w)*$,N=S+ot(w)*$,k=C>c?c+(C-c)*E:C<p?p+(C-p)*E:C,R=N>u?u+(N-u)*E:N<d?d+(N-d)*E:N,I=this.destX=yt(_t(bt(k,this.snapX),5),p,c),D=this.destY=yt(_t(bt(R,this.snapY),5),d,u),A=this.isOutOfBounds(this.containerBounds,C,N);let O=0,B=0,P=v,M=v,F=0;if(b.x=T,b.y=S,!t){const t=I===c?T>c?-1:1:T<p?-1:1,s=_t(T-I,0);g.velocity=e&&_?s?$*t/ht(s):0:x;const{ease:i,settlingDuration:r,restDuration:n}=g;O=T===I?0:_?r:r-n*L.timeScale,_&&(P=i),O>F&&(F=O)}if(!e){const e=D===u?S>u?-1:1:S<d?-1:1,s=_t(S-D,0);y.velocity=t&&_?s?$*e/ht(s):0:x;const{ease:i,settlingDuration:r,restDuration:n}=y;B=S===D?0:_?r:r-n*L.timeScale,_&&(M=i),B>F&&(F=B)}if(!_&&A&&E&&(O||B)){const t=o.blend;new qe(b,{x:{to:k,duration:.65*O},y:{to:R,duration:.65*B},ease:v,composition:t}).init(),new qe(b,{x:{to:I,duration:O},y:{to:D,duration:B},ease:v,composition:t}).init(),this.overshootTicker.stretch(pt(O,B)).restart()}else t||this.animate[this.xProp](I,O,P),e||this.animate[this.yProp](D,B,M);this.scrollInView(F,this.scrollThreshold,v);let V=!1;I!==m&&(this.snapped[0]=I,this.snapX&&(V=!0)),D!==f&&this.snapY&&(this.snapped[1]=D,this.snapY&&(V=!0)),V&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",xs),this.$trigger.removeEventListener("touchmove",xs),this.$trigger.removeEventListener("touchend",xs),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Ke(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),s.removeEventListener("touchmove",this),s.removeEventListener("touchend",this),s.removeEventListener("touchcancel",this),s.removeEventListener("mousemove",this),s.removeEventListener("mouseup",this),s.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":xs(t)}}}const ks=(t,e)=>new Ns(t,e),Rs=(t=S)=>new ge({duration:1*L.timeScale,onComplete:t},null,0).resume(),Is=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!W(a)&&a.revert&&(e=a),q(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||S}};class Ds{constructor(t={}){B.current&&B.current.register(this);const i=t.root;let r=s;i&&(r=i.current||i.nativeElement||_e(i)[0]||s);const n=t.defaults,o=L.defaults,a=t.mediaQueries;if(this.defaults=n?$t(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const s=e.matchMedia(a[t]);this.mediaQueryLists[t]=s,s.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=B.current,s=B.root,i=L.defaults;B.current=this,B.root=this.root,L.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return B.current=e,B.root=s,L.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);W(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,W(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);W(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,W(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);W(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(W(s))return s(this);const i=Is(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const As=t=>new Ds(t),Os=()=>{const t=s.createElement("div");s.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return s.body.removeChild(t),e},Bs=(t,e)=>t&&W(t)?t(e):t,Ls=new Map;class Ps{constructor(t){this.element=t,this.useWin=this.element===s.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new ge({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;Et(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new ge({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=_t(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new ge({autoplay:!1,duration:250*L.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new ge({autoplay:!1,duration:500*L.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?e:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,s=this.element;this.scrollX=_t(t?e.scrollX:s.scrollLeft,0),this.scrollY=_t(t?e.scrollY:s.scrollTop,0)}updateWindowBounds(){this.winWidth=e.innerWidth,this.winHeight=Os()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){Et(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),Et(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?e:this.element).removeEventListener("scroll",this),Ls.delete(this.element)}}const Ms=t=>{const e=t&&_e(t)[0]||s.body;let i=Ls.get(e);return i||(i=new Ps(e),Ls.set(e,i)),i},Fs=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Xt(a,Ut);let d=h;return"%"===l?d=h/100*s:l&&(d=xe(t,Ut,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},Vs=(t,e,s,i,r)=>{let n;if(Y(e)){const o=D.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),d="min"===l[0],c="max"===l[0],u=Fs(t,l[0],s,i,r),p=Fs(t,l[1],s,i,r);if(d){const e=Vt(Fs(t,"min",s),p,h);n=e<u?u:e}else if(c){const e=Vt(Fs(t,"max",s),p,h);n=e>u?u:e}else n=Vt(u,p,h)}else n=Fs(t,e,s,i,r)}else n=e;return _t(n,0)},zs=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[h]){e=i;break}}return e};let Xs=0;const Hs=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class Us{constructor(t={}){B.current&&B.current.register(this);const e=Bt(t.sync,"play pause"),i=e?Oe(e):null,r=e&&("linear"===e||e===we),n=e&&!(i===we&&!r),o=e&&(U(e)||!0===e||r),a=e&&Y(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=Xs++,this.id=q(t.id)?this.index:t.id,this.container=Ms(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?i:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:S,this.onSyncLeave=h&&!l&&h[1]?h[1]:S,this.onSyncEnterForward=h&&l&&h[0]?h[0]:S,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:S,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:S,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:S,this.onEnter=t.onEnter||S,this.onLeave=t.onLeave||S,this.onEnterForward=t.onEnterForward||S,this.onLeaveForward=t.onLeaveForward||S,this.onEnterBackward=t.onEnterBackward||S,this.onLeaveBackward=t.onLeaveBackward||S,this.onUpdate=t.onUpdate||S,this.onSyncComplete=t.onSyncComplete||S,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Bt(t.debug,!1),this._next=null,this._prev=null,Nt(this.container,this),Rs(()=>{if(!this.reverted){if(!this.target){const e=_e(t.target)[0];this.target=e||s.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,q(t)||(t.persist=!0),!this._params.target)){let e;q(t.targets)?Et(t,t=>{t.targets&&!e&&(e=zs(t))}):e=zs(t),this.target=e||s.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:_t(yt(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Bt(Bs(t.repeat,this),!0),this.horizontal="x"===Bt(Bs(t.axis,this),"y"),this.enter=Bt(Bs(t.enter,this),"end start"),this.leave=Bt(Bs(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,i=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=s.createElement("div"),n=s.createElement("div"),o=s.createElement("div"),a=Hs[this.index%Hs.length],h=t.useWin,l=h?t.winWidth:t.width,d=h?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,v=e?60:g,_=e?v:y,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",S=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,x=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${x("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${x("sticky",0,0,e?l:g,e?g:d)}`,i||(n.style.cssText+=`background:\n ${S("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${S("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${x("relative",0,0,e?c:g,e?g:u)}`,i||(o.style.cssText+=`background:\n ${S("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${S("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const w=[" enter: "," leave: "];this.coords.forEach((t,i)=>{const r=i>1,h=(r?0:this.offset)+t,m=i%2,f=h<_,g=h>(r?e?l:d:e?c:u)-_,b=(r?m&&!f:!m&&!f)||g,T=s.createElement("div"),S=s.createElement("div"),$=e?b?"right":"left":b?"bottom":"top",E=b?(e?v:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;S.innerHTML=`${this.id}${w[m]}${this.thresholds[i]}`,T.style.cssText=`${x("absolute",0,0,v,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${$}: 2px solid ${a};\n `,S.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(S);let C=h-E+(e?1:0);T.style[e?"left":"top"]=`${C}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),i||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Ze(t.element,"position")&&(this.debugStyles=Ke(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,i=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==i.element&&a!==s.body;){const e="sticky"===Ze(a,"position")&&Ke(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=i.scale,d=(r?h.left+i.scrollX-i.left:h.top+i.scrollY-i.top)*l,c=(r?h.width:h.height)*l,u=r?i.width:i.height,p=(r?i.scrollWidth:i.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",v="end",_="start";if(Y(m)){const t=m.split(" ");v=t[0],g=t.length>1?t[1]:g}else if(H(m)){const t=m;q(t.container)||(v=t.container),q(t.target)||(g=t.target)}else U(m)&&(v=m);if(Y(f)){const t=f.split(" ");_=t[0],y=t.length>1?t[1]:y}else if(H(f)){const t=f;q(t.container)||(_=t.container),q(t.target)||(y=t.target)}else U(f)&&(_=f);const b=Vs(e,g,c),T=Vs(e,y,c),S=b+d-u,x=T+d-p,w=Vs(e,v,u,S,x),$=Vs(e,_,u,S,x),E=b+d-w,C=T+d-$,N=C-E;this.offset=d,this.offsetStart=E,this.offsetEnd=C,this.distance=N<=0?0:N,this.thresholds=[g,y,v,_],this.coords=[b,T,w,$],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,d=!h&&!l,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&U(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=_t(Tt(e,g,Tt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return Ct(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const Ys=(t={})=>new Us(t),Ws=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,qs=(t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=Ws(r,e,s)-t,i>0?o=r:n=r}while(ht(i)>1e-7&&++a<100);return r},js=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?we:r=>0===r||1===r?r:Ws(qs(r,t,s),e,i),Gs=(t=10,e)=>{const s=e?dt:ct;return e=>s(yt(e,0,1)*t)*(1/t)},Qs=(...t)=>{const e=t.length;if(!e)return we;const s=e-1,i=t[0],r=t[s],n=[0],o=[it(i)];for(let e=1;e<s;e++){const i=t[e],r=Y(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(q(h)?e/s:it(h)/100),o.push(it(a))}return o.push(it(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},Js=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(yt(o,r,1))}return s.push(1),Qs(...s)};var Zs=Object.freeze({__proto__:null,Spring:bs,createSpring:Ss,cubicBezier:js,eases:Re,irregular:Js,linear:Qs,spring:Ts,steps:Gs});const Ks=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(_t(t(i/e),4));return`linear(${s.join(", ")})`},ti={},ei=t=>{let e=ti[t];if(e)return e;if(e="linear",Y(t)){if(V(t,"linear")||V(t,"cubic-")||V(t,"steps")||V(t,"ease"))e=t;else if(V(t,"cubicB"))e=F(t);else{const s=De(t);W(s)&&(e=s===we?"linear":Ks(s))}ti[t]=e}else if(W(t)){const s=Ks(t);s&&(e=s)}else t.ease&&(e=Ks(t.ease));return e},si=["x","y","z"],ii=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...si],ri=(()=>[...si,...b.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let ni=null;const oi=(t,e,s,i,r)=>{let n=Y(e)?e:Lt(e,s,i,r);return U(n)?ii.includes(t)||V(t,"translate")?`${n}px`:V(t,"rotate")||V(t,"skew")?`${n}deg`:`${n}`:n},ai=(t,e,s,i,r,n)=>{let o="0";const a=q(i)?getComputedStyle(t)[e]:oi(e,i,t,r,n);return o=q(s)?X(i)?i.map(s=>oi(e,s,t,r,n)):a:[oi(e,s,t,r,n),a],o};class hi{constructor(e,s){B.current&&B.current.register(this),j(ni)&&(!t||!q(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(b.forEach(t=>{const e=V(t,"skew"),s=V(t,"scale"),i=V(t,"rotate"),r=V(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),ni=!0):ni=!1);const i=be(e),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Bt(s.ease,ei(L.defaults.ease)),o=n.ease&&n,a=Bt(s.autoplay,L.defaults.autoplay),h=!(!a||!a.link)&&a,l=s.alternate&&!0===s.alternate,c=s.reversed&&!0===s.reversed,u=Bt(s.loop,L.defaults.loop),p=!0===u||u===1/0?1/0:U(u)?u+1:1,m=l?c?"alternate-reverse":"alternate":c?"reverse":"normal",g=ei(n),v=1===L.timeScale?1:f;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||L.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==h,this.reversed=c,this.persist=Bt(s.persist,L.defaults.persist),this.autoplay=a,this._speed=Bt(s.playbackRate,L.defaults.playbackRate),this._resolve=S,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[d],a=ri.some(t=>s.hasOwnProperty(t)),h=t.style,l=this._inlineStyles[e]={},c=(o?o.settlingDuration:Lt(Bt(s.duration,L.defaults.duration),t,e,r))*v,u=Lt(Bt(s.delay,L.defaults.delay),t,e,r)*v,f=Bt(s.composition,"replace");for(let o in s){if(!tt(o))continue;const d={},y={iterations:p,direction:m,fill:"both",easing:g,duration:c,delay:u,composite:f},T=s[o],S=!!a&&(b.includes(o)?o:_.get(o)),x=S?"transform":o;let w;if(l[x]||(l[x]=h[x]),H(T)){const s=T,a=Bt(s.ease,n),l=a.ease&&a,p=s.to,m=s.from;if(y.duration=(l?l.settlingDuration:Lt(Bt(s.duration,c),t,e,r))*v,y.delay=Lt(Bt(s.delay,u),t,e,r)*v,y.composite=Bt(s.composition,f),y.easing=ei(a),w=ai(t,o,m,p,e,r),S?(d[`--${S}`]=w,i[S]=w):d[o]=ai(t,o,m,p,e,r),Je(this,t,o,d,y),!q(m))if(S){const t=`--${S}`;h.setProperty(t,d[t][0])}else h[o]=d[o][0]}else w=X(T)?T.map(s=>oi(o,s,t,e,r)):oi(o,T,t,e,r),S?(d[`--${S}`]=w,i[S]=w):d[o]=w,Je(this,t,o,d,y)}if(a){let t=y;for(let e in i)t+=`${T[e]}var(--${e})) `;h.transform=t}}),h&&this.autoplay.link(this)}forEach(t){try{const e=Y(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=L.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===L.timeScale?1:f);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];q(r)||r===y?s.removeProperty(F(e)):t.style[e]=r}t.getAttribute("style")===y&&t.removeAttribute("style")}),this}then(t=S){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=S};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const li={animate:(t,e)=>new hi(t,e),convertEase:Ks};let di=0,ci=0;const ui=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),pi=(t,e)=>{let s=t[e];for(;s&&s.nodeType===Node.TEXT_NODE&&!s.textContent.trim();)s=s[e];return s&&s.nodeType===Node.TEXT_NODE},mi=t=>pi(t,"previousSibling")||pi(t,"nextSibling"),fi=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},gi=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},yi=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,fi(s)),i&&!e.has(i)&&e.set(i,fi(i))},vi=t=>{t.forEach((t,e)=>gi(e,t)),t.clear()},_i={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},bi=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},Ti=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+ci++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.total=1,n.delay=0,n.duration=0,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.hasTransform=!1,n.isAnimated=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.isInlined=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},Si=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,h=t.state.rootNode,l=t.parentNode,d=s.transform,c=r.style.transform,u=!!l&&l.measuredIsRemoved,p=s.position;if(o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=ui(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u,t.isInlined=t.measuredDisplay.includes("inline")&&mi(r),t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=fi(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=fi(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let m,f,g=0,y=0,v=0,_=0;if(!i){const t=e.getBoundingClientRect();g=t.left,y=t.top,v=t.width,_=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);q(e)||(a[t]=e)}if(a.left=g,a.top=y,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(m=g,f=y):(m=0,f=0);else{const e=l||h,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)m=g-s-r,f=y-i-n;else if(e===h){const t=h.properties.left,e=h.properties.top;m=g-t-h.properties.clientLeft,f=y-e-h.properties.clientTop}else m=g-s-r,f=y-i-n}return a.x=m,a.y=f,a.width=v,a.height=_,t},xi=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},wi=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},$i=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},Ei=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(gi(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(gi(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},Ci=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.measuredIsRemoved&&t.layout.pendingRemoved.delete(t.$el)},Ni=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class ki{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}get(t){const e=this.nodes.get(t.dataset.layoutId);if(e)return e.properties;console.warn("No node found on state")}getValue(t,e){if(!t||!t.dataset)return void console.warn(`No element found on state (${t})`);const s=this.nodes.get(t.dataset.layoutId);if(!s)return void console.warn("No node found on state");const i=s.properties[e];return q(i)?void 0:Lt(i,t,s.index,s.total)}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,fi(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||G(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?_i:getComputedStyle(e),a=!!n||"none"===o.display,h=!!n||"hidden"===o.visibility,l=!a&&!h,d=e.dataset.layoutId,c=ui(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=ui(i,u.$el),h=u.measuredIsVisible;if(a||!c&&(c||h||!l)){if(a&&!h&&l){Si(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}bi(u),u=Ti(e,t,this,u)}else u=Ti(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.isAnimated=!1,u.hasVisibilityHidden=h,u.hasDisplayNone=a,u.hasVisibilitySwap=h&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),Si(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const{children:t,root:e}=this.layout,s=X(t)?t:[t],i=[],r="*"===t?e:B.root;for(let t=0,e=s.length;t<e;t++){const e=s[t];i[t]=Y(e)?r.querySelectorAll(e):e}const n=be(i);this.nodes.clear(),this.rootNodes.clear();const o=this.registerElement(e,null);o.isTarget=!0,this.rootNode=o;const a=new Set;this.nodes.forEach((t,e)=>{t&&t.measuredIsInsideRoot&&a.add(e)});const h=new Set,l=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];if(s&&1===s.nodeType&&s!==e){if(!ui(e,s)){const t=s.dataset.layoutId;if(!t||!a.has(t))continue}h.has(s)||(h.add(s),l.push(s))}}for(let t=0,e=l.length;t<e;t++)this.ensureDetachedNode(l[t],h);for(let t=0,e=n.length;t<e;t++){const e=n[t],s=this.nodes.get(e.dataset.layoutId);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY;const d=this.nodes.size;return this.forEachNode(Ei),this.forEachNode((t,e)=>{t.index=e,t.total=d}),this}}class Ri{constructor(t,e={}){B.current&&B.current.register(this);const s=e.frozen,i=e.added,r=e.removed,n=e.properties;if(this.params=e,this.root=be(t)[0],this.id=di++,this.children=e.children||"*",this.absoluteCoords=!1,this.duration=Bt(e.duration,500),this.delay=Bt(e.delay,0),this.ease=Bt(e.ease,"inOutExpo"),this.onComplete=Bt(e.onComplete,S),this.frozenParams=s||{opacity:0},this.addedParams=i||{opacity:0},this.removedParams=r||{opacity:0},this.properties=new Set(["opacity","borderRadius"]),s)for(let t in s)this.properties.add(t);if(i)for(let t in i)this.properties.add(t);if(r)for(let t in r)this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoved=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new ki(this),this.newState=new ki(this),this.timeline=null,this.transformAnimation=null,this.frozen=[],this.removed=[],this.added=[],this.oldState.record(),vi(this.transitionMuteStore)}revert(){return this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.root.classList.remove("is-animated"),this.frozen.length=this.removed.length=this.added.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>vi(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode($i),this}animate(t={}){const e=Bt(t.delay,this.delay),s=Bt(t.duration,this.duration),i=Bt(t.onComplete,this.onComplete),r=t.frozen?$t(t.frozen,this.frozenParams):this.frozenParams,n=t.added?$t(t.added,this.addedParams):this.addedParams,o=t.removed?$t(t.removed,this.removedParams):this.removedParams,a=this.oldState,h=this.newState,l=this.added,d=this.removed,c=this.frozen,u=this.pendingRemoved;l.length=d.length=c.length=0,a.forEachRootNode(yi),h.record(),h.forEachRootNode(wi);const p=[],m=[],f=[],g=[],y=h.rootNode.$el;h.forEachRootNode(t=>{const i=t.$el,r=t.id,y=t.parentNode,v=!!y&&y.branchAdded,_=!!y&&y.branchRemoved,b=!!y&&y.branchNotRendered;t.delay=+(W(e)?e(i,t.index,t.total):e),t.duration=+(W(s)?s(i,t.index,t.total):s);let T=a.nodes.get(r);const S=!T;S?(T=Ni(t,{},a),a.nodes.set(r,T),T.measuredIsRemoved=!0):T.measuredIsRemoved&&!t.measuredIsRemoved&&(Ni(t,T,a),T.measuredIsRemoved=!0);const x=T.parentNode,w=(x?x.id:null)!==(y?y.id:null),$=T.$el!==t.$el,E=T.measuredIsRemoved,C=t.measuredIsRemoved;if(!T.measuredIsRemoved&&!C&&!S&&(w||$)){let e=0,s=0,i=t.parentNode;for(;i&&(e+=i.properties.x||0,s+=i.properties.y||0,i.parentNode!==h.rootNode);)i=i.parentNode;let r=0,n=0,o=T.parentNode;for(;o&&(r+=o.properties.x||0,n+=o.properties.y||0,o.parentNode!==a.rootNode);)o=o.parentNode;T.properties.x+=r-e,T.properties.y+=n-s}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=T.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const N=u.has(i),k=T.measuredIsVisible,R=t.measuredIsVisible,I=!k&&R&&!b,D=!C&&(E||N)&&!v,A=C&&!E&&!_,O=A||C&&N&&!_;t.measuredIsRemoved&&k&&(t.$el.style.display=T.measuredDisplay,t.$el.style.visibility="visible",Ni(T,t,h)),A?(d.push(i),u.add(i)):!C&&N&&u.delete(i),D&&!b||I?(xi(T,n),l.push(i)):O&&!b&&xi(t,o);for(let e in t.properties)t.properties[e]=h.getValue(t.$el,e),T.properties[e]=a.getValue(t.$el,e);const B=(D||A)&&E!==C;let L=!1;if(t.isTarget&&(!t.measuredIsRemoved&&k||t.measuredIsRemoved&&R)){t.isInlined||"none"===t.properties.transform&&"none"===T.properties.transform||(t.hasTransform=!0,L=!0,f.push(i));for(let e in t.properties)if("transform"!==e&&(t.properties[e]!==T.properties[e]||B)){L=!0,m.push(i);break}}const P=L||D||O||I,M=t.isTarget&&P;t.isAnimated=M,t.branchAdded=v||D,t.branchRemoved=_||O,t.branchNotRendered=b||t.measuredIsRemoved;const F=Math.abs(t.properties.width-T.properties.width)>1,V=Math.abs(t.properties.height-T.properties.height)>1;t.sizeChanged=F||V,p.push(i),t.isTarget||(c.push(i),(P||t.sizeChanged)&&y&&y.isTarget&&y.isAnimated&&y.sizeChanged&&g.push(i))});const v={ease:Bt(t.ease,this.ease),duration:t=>h.nodes.get(t.dataset.layoutId).duration,delay:t=>h.nodes.get(t.dataset.layoutId).delay};if(this.timeline=as({onComplete:()=>{this.transformAnimation&&this.transformAnimation.cancel(),h.forEachRootNode(t=>{Ci(t),$i(t)});for(let t=0,e=f.length;t<e;t++){const e=f[t];e.style.transform=h.getValue(e,"transform")}this.root.classList.remove("is-animated"),i&&i(this),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||vi(this.transitionMuteStore)})},onPause:()=>{this.transformAnimation&&this.transformAnimation.cancel(),h.forEachRootNode(Ci),this.root.classList.remove("is-animated"),i&&i(this)},composition:!1,defaults:v}),p.length){this.root.classList.add("is-animated");for(let t=0,e=p.length;t<e;t++){const e=p[t],s=e.dataset.layoutId,i=a.nodes.get(s),r=h.nodes.get(s),n=i.properties;yi(r),r.isInlined||(e.style.display="block",(e!==y||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===y&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px"),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none")}a.scrollX===window.scrollX&&a.scrollY===window.scrollY||requestAnimationFrame(()=>{window.scrollTo(a.scrollX,a.scrollY)});for(let t=0,e=m.length;t<e;t++){const e=m[t],s=e.dataset.layoutId,i=a.nodes.get(s),r=h.nodes.get(s),n=i.properties,o=r.properties;let l=!1;const d={composition:"none"};r.isInlined||(n.width!==o.width&&(d.width=[n.width,o.width],l=!0),n.height!==o.height&&(d.height=[n.height,o.height],l=!0),r.hasTransform||(d.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],l=!0)),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(d[t]=[e,s],l=!0)}),l&&this.timeline.add(e,d,0)}}if(c.length){for(let t=0,e=c.length;t<e;t++){const e=c[t];if(!a.nodes.get(e.dataset.layoutId).isInlined){const t=a.get(e);e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",e.style.translate=`${t.x}px ${t.y}px`}this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${a.getValue(e,t)}`)})}for(let t=0,e=c.length;t<e;t++){const e=c[t],s=h.nodes.get(e.dataset.layoutId),i=h.get(e);this.timeline.call(()=>{s.isInlined||(e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${h.getValue(e,t)}`)})},s.delay+s.duration/2)}if(g.length){const t={};if(r)for(let e in r)t[e]=[{from:t=>a.getValue(t,e),ease:"in(1.75)",to:r[e]},{from:r[e],to:t=>h.getValue(t,e),ease:"out(1.75)"}];this.timeline.add(g,t,0)}}const _=f.length;if(_){for(let t=0;t<_;t++){const e=f[t];e.style.translate=`${a.get(e).x}px ${a.get(e).y}px`,e.style.transform=a.getValue(e,"transform")}this.transformAnimation=li.animate(f,{translate:t=>`${h.get(t).x}px ${h.get(t).y}px`,transform:t=>h.getValue(t,"transform"),autoplay:!1,persist:!0,...v}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e),this}}const Ii=(t,e)=>new Ri(t,e),Di=vs,Ai={},Oi=(t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s),Bi=t=>(...e)=>{const s=t(...e);return new Proxy(S,{apply:(t,e,[i])=>s(i),get:(t,e)=>Bi((...t)=>{const i=Ai[e](...t);return t=>i(s(t))})})},Li=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?Bi(Oi(e,s)):e)(...t);return Ai[t]||(Ai[t]=i),i},Pi=Li("roundPad",Di.roundPad),Mi=Li("padStart",Di.padStart),Fi=Li("padEnd",Di.padEnd),Vi=Li("wrap",Di.wrap),zi=Li("mapRange",Di.mapRange),Xi=Li("degToRad",Di.degToRad),Hi=Li("radToDeg",Di.radToDeg),Ui=Li("snap",Di.snap),Yi=Li("clamp",Di.clamp),Wi=Li("round",Di.round),qi=Li("lerp",Di.lerp,1),ji=Li("damp",Di.damp,1),Gi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let Qi=0;const Ji=(t,e=0,s=1,i=0)=>{let r=void 0===t?Qi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},Zi=t=>t[Gi(0,t.length-1)],Ki=t=>{let e,s,i=t.length;for(;i;)s=Gi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},tr=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!q(o),h=a&&!q(o.ease)?o.ease:a?Oe(o):null,l=e.grid,d=e.axis,c=e.total,u=q(r)||0===r||"first"===r,p="center"===r,m="last"===r,f="random"===r,g=X(t),v=e.use,_=it(g?t[0]:t),b=g?it(t[1]):0,T=k.exec((g?t[1]:t)+y),S=e.start||0+(g?_:0);let x=u?0:U(r)?r:0;return(t,r,o,a)=>{const[u]=be(t),y=q(c)?o:c,w=!q(v)&&(W(v)?v(u,r,y):Ft(u,v)),$=U(w)||Y(w)&&U(+w)?+w:r;if(p&&(x=(y-1)/2),m&&(x=y-1),!s.length){for(let t=0;t<y;t++){if(l){const e=p?(l[0]-1)/2:x%l[0],i=p?(l[1]-1)/2:ct(x/l[0]),r=e-t%l[0],n=i-ct(t/l[0]);let o=nt(r*r+n*n);"x"===d&&(o=-r),"y"===d&&(o=-n),s.push(o)}else s.push(ht(x-t));i=pt(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>d?t<0?-1*t:-t:ht(i-t))),f&&(s=Ki(s))}const E=g?(b-_)/i:_;let C=(a?ss(a,q(e.start)?a.iterationDuration:S):S)+(E*_t(s[$],2)||0);return e.modifier&&(C=e.modifier(C)),T&&(C=`${C}${T[2]}`),C}};var er=Object.freeze({__proto__:null,$:be,clamp:Yi,cleanInlineStyles:Gt,createSeededRandom:Ji,damp:ji,degToRad:Xi,get:Ze,keepTime:Is,lerp:qi,mapRange:zi,padEnd:Fi,padStart:Mi,radToDeg:Hi,random:Gi,randomPick:Zi,remove:ts,round:Wi,roundPad:Pi,set:Ke,shuffle:Ki,snap:Ui,stagger:tr,sync:Rs,wrap:Vi});const sr=t=>{const e=_e(t)[0];return e&&G(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},ir=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},rr=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[l],o=t.getCTM(),a=0===s;return{from:0,to:r,modifier:i=>{const h=i+s*r;if("a"===e){const e=ir(t,r,h,-1,a),s=ir(t,r,h,1,a);return 180*mt(s.y-e.y,s.x-e.x)/ft}{const s=ir(t,r,h,0,a);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},nr=(t,e=0)=>{const s=sr(t);if(s)return{translateX:rr(s,"x",e),translateY:rr(s,"y",e),rotate:rr(s,"a",e)}},or=t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(nt(s.a*s.a+s.b*s.b)+nt(s.c*s.c+s.d*s.d))/2)}return e},ar=(t,e,s)=>{const i=f,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===u?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=or(o),d=-1e3*r*l,c=h*i*l+d,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-c;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:W(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h},hr=(t,e=0,s=0)=>_e(t).map(t=>ar(t,e,s)),lr=(t,e=.33)=>s=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const i=sr(t);if(!i)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(i.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${i.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const r="path"===s.tagName,n=r?" ":",",o=s[c];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const d=e/(l-1),c=s.getPointAtLength(t*d),u=i.getPointAtLength(o*d),p=r?0===e?"M":"L":"";a+=p+_t(c.x,3)+n+c.y+" ",h+=p+_t(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[c]=h,[a,h]};var dr=Object.freeze({__proto__:null,createDrawable:hr,createMotionPath:nr,morphTo:lr});const cr="undefined"!=typeof Intl&&Intl.Segmenter,ur=/\{value\}/g,pr=/\{i\}/g,mr=/(\s+)/,fr=/^\s+$/,gr="line",yr="word",vr="char",_r="data-line";let br=null,Tr=null,Sr=null;const xr=t=>t.isWordLike||" "===t.segment||U(+t.segment),wr=t=>t.setAttribute("aria-hidden","true"),$r=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Er={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Cr=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Cr(e)}},Nr=(t,e,s)=>{const i=t.getAttribute(_r);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&fr.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&fr.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Nr(t.children[r],e,s);return s},kr=(t,e={})=>{let s="";const i=Y(e.class)?` class="${e.class}"`:"",r=Bt(e.clone,!1),n=Bt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},Rr=(t,e,s,i,r,n,o,a,h)=>{const l=r===gr,d=r===vr,c=`_${r}_`,u=W(t)?t(s):t,p=l?"block":"inline-block";Sr.innerHTML=u.replace(ur,`<i class="${c}"></i>`).replace(pr,`${d?h:l?o:a}`);const m=Sr.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),v=y.length;if(v){f.style.display=p,g.style.display=p,g.setAttribute(_r,`${o}`),l||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${h}`));let t=v;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Er[r]}`),f};class Ir{constructor(e,i={}){br||(br=cr?new cr([],{granularity:yr}):{segment:t=>{const e=[],s=t.split(mr);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!fr.test(i)})}return e}}),Tr||(Tr=cr?new cr([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Sr&&t&&(Sr=s.createElement("template")),B.current&&B.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=i,d=(e=X(e)?e[0]:e)&&e.nodeType?e:(ve(e)||[])[0],c=!0===o?{}:o,u=!0===r||q(r)?{}:r,p=!0===n?{}:n;this.debug=Bt(l,!1),this.includeSpaces=Bt(h,!1),this.accessible=Bt(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=H(c)?kr(gr,c):c,this.wordTemplate=H(u)||this.linesOnly?kr(yr,u):u,this.charTemplate=H(p)?kr(vr,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?s.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!W(t))return console.warn("Effect must return a function.");const e=Is(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>W(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,i=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,d=br.segment(o),c=s.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=xr(t);if(!u||s&&u&&xr(u))a.push(e);else{const t=a.length-1,s=a[t];mr.test(s)||mr.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=i?Tr.segment(p):null,f=i?s.createDocumentFragment():s.createTextNode(u?o+" ":o);if(i){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=s.createTextNode(a);Rr(i,l,d,f,vr,n,-1,h.length,l.length)}}e?Rr(e,h,f,c,yr,n,-1,h.length,l.length):i?c.appendChild(f):c.appendChild(s.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(s.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,i=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==s.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>W(t)&&t(this)),i||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(i&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=$r(e,yr))),o&&(h||n)&&(this.chars=$r(e,vr));const l=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();!q(d)&&s-d>.5*i&&c++,e.setAttribute(_r,`${c}`);const r=e.querySelectorAll(`[${_r}]`);let n=r.length;for(;n--;)r[n].setAttribute(_r,`${c}`);d=s}if(h){const t=s.createDocumentFragment(),i=new Set,a=[];for(let t=0;t<c+1;t++){const s=e.cloneNode(!0);Nr(s,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&i.add(e),e.removeChild(t))}),a.push(s)}i.forEach(Cr);for(let e=0,s=a.length;e<s;e++)Rr(r,this.lines,a[e],t,gr,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=$r(e,yr)),o&&(this.chars=$r(e,vr))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!i)){const t=s.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(wr),this.words.forEach(wr),this.chars.forEach(wr)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Dr=(t,e)=>new Ir(t,e),Ar=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new Ir(t,e));var Or=Object.freeze({__proto__:null,TextSplitter:Ir,split:Ar,splitText:Dr});export{be as $,hs as Animatable,Ri as AutoLayout,Ns as Draggable,qe as JSAnimation,Ds as Scope,Us as ScrollObserver,bs as Spring,Ir as TextSplitter,os as Timeline,ge as Timer,hi as WAAPIAnimation,je as animate,Yi as clamp,Gt as cleanInlineStyles,ls as createAnimatable,ks as createDraggable,hr as createDrawable,Ii as createLayout,nr as createMotionPath,As as createScope,Ji as createSeededRandom,Ss as createSpring,as as createTimeline,ye as createTimer,js as cubicBezier,ji as damp,Xi as degToRad,Re as eases,Zs as easings,se as engine,Ze as get,Js as irregular,Is as keepTime,qi as lerp,Qs as linear,zi as mapRange,lr as morphTo,Ys as onScroll,Fi as padEnd,Mi as padStart,Hi as radToDeg,Gi as random,Zi as randomPick,ts as remove,Wi as round,Pi as roundPad,Ls as scrollContainers,Ke as set,Ki as shuffle,Ui as snap,Ar as split,Dr as splitText,Ts as spring,tr as stagger,Gs as steps,dr as svg,Rs as sync,Or as text,er as utils,li as waapi,Vi as wrap};
diff --git a/dist/bundles/anime.umd.js b/dist/bundles/anime.umd.js
index 89751bfd..cdc0ba47 100644
--- a/dist/bundles/anime.umd.js
+++ b/dist/bundles/anime.umd.js
@@ -1,6 +1,6 @@
/**
* Anime.js - UMD bundle
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -37,7 +37,7 @@
/** @typedef {JSAnimation|Timeline} Renderable */
/** @typedef {Timer|Renderable} Tickable */
/** @typedef {Timer&JSAnimation&Timeline} CallbackArgument */
-/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope} Revertible */
+/** @typedef {Animatable|Tickable|WAAPIAnimation|Draggable|ScrollObserver|TextSplitter|Scope|AutoLayout} Revertible */
// Stagger types
@@ -361,6 +361,7 @@
* @typedef {Object} TimelineOptions
* @property {DefaultsParams} [defaults]
* @property {EasingParam} [playbackEase]
+ * @property {Boolean} [composition]
*/
/**
@@ -644,8 +645,10 @@
// TODO: Do we need to check if we're running inside a worker ?
const isBrowser = typeof window !== 'undefined';
- /** @type {Window & {AnimeJS: Array}|null} */
- const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
+ /** @typedef {Window & {AnimeJS: Array} & {AnimeJSDevTools: any}|null} AnimeJSWindow
+
+ /** @type {AnimeJSWindow} */
+ const win = isBrowser ? /** @type {AnimeJSWindow} */(/** @type {unknown} */(window)) : null;
/** @type {Document|null} */
const doc = isBrowser ? document : null;
@@ -697,7 +700,7 @@
const minValue = 1e-11;
const maxValue = 1e12;
const K = 1e3;
- const maxFps = 120;
+ const maxFps = 240;
// Strings
@@ -802,7 +805,9 @@
tickThreshold: 200,
};
- const globalVersions = { version: '4.2.2', engine: null };
+ const devTools = isBrowser && win.AnimeJSDevTools;
+
+ const globalVersions = { version: '4.3.0-beta.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
@@ -1832,7 +1837,7 @@
/** @type {Number} */
this._currentTime = initTime;
/** @type {Number} */
- this._elapsedTime = initTime;
+ this._lastTickTime = initTime;
/** @type {Number} */
this._startTime = initTime;
/** @type {Number} */
@@ -1840,7 +1845,7 @@
/** @type {Number} */
this._scheduledTime = 0;
/** @type {Number} */
- this._frameDuration = round$1(K / maxFps, 0);
+ this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
/** @type {Number} */
@@ -1861,7 +1866,8 @@
const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
- const frameDuration = round$1(K / fps, 0);
+ const frameDuration = K / fps;
+ if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
this._scheduledTime += frameDuration - previousFrameDuration;
@@ -1882,14 +1888,13 @@
*/
requestTick(time) {
const scheduledTime = this._scheduledTime;
- const elapsedTime = this._elapsedTime;
- this._elapsedTime += (time - elapsedTime);
- // If the elapsed time is lower than the scheduled time
+ this._lastTickTime = time;
+ // If the current time is lower than the scheduled time
// this means not enough time has passed to hit one frameDuration
// so skip that frame
- if (elapsedTime < scheduledTime) return tickModes.NONE;
+ if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = elapsedTime - scheduledTime;
+ const frameDelta = time - scheduledTime;
// Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
// Skips ahead if the actual elapsed time is higher.
this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
@@ -2026,7 +2031,7 @@
wake() {
if (this.useDefaultMainLoop && !this.reqId) {
- // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
+ // Imediatly request a tick to update engine._lastTickTime and get accurate offsetPosition calculation in timer.js
this.requestTick(now());
this.reqId = engineTickMethod(tickEngine);
}
@@ -2514,6 +2519,8 @@
super(0);
+ ++timerId;
+
const {
id,
delay,
@@ -2535,31 +2542,42 @@
if (scope.current) scope.current.register(this);
- const timerInitTime = parent ? 0 : engine._elapsedTime;
+ const timerInitTime = parent ? 0 : engine._lastTickTime;
const timerDefaults = parent ? parent.defaults : globals.defaults;
const timerDelay = /** @type {Number} */(isFnc(delay) || isUnd(delay) ? timerDefaults.delay : +delay);
const timerDuration = isFnc(duration) || isUnd(duration) ? Infinity : +duration;
const timerLoop = setValue(loop, timerDefaults.loop);
const timerLoopDelay = setValue(loopDelay, timerDefaults.loopDelay);
- const timerIterationCount = timerLoop === true ||
- timerLoop === Infinity ||
- /** @type {Number} */(timerLoop) < 0 ? Infinity :
- /** @type {Number} */(timerLoop) + 1;
+ let timerIterationCount = timerLoop === true ||
+ timerLoop === Infinity ||
+ /** @type {Number} */(timerLoop) < 0 ? Infinity :
+ /** @type {Number} */(timerLoop) + 1;
+
+ if (devTools) {
+ const isInfinite = timerIterationCount === Infinity;
+ const registered = devTools.register(this, parameters, isInfinite);
+ if (registered && isInfinite) {
+ const minIterations = alternate ? 2 : 1;
+ const iterations = parent ? devTools.maxNestedInfiniteLoops : devTools.maxInfiniteLoops;
+ timerIterationCount = Math.max(iterations, minIterations);
+ }
+ }
let offsetPosition = 0;
if (parent) {
offsetPosition = parentPosition;
} else {
- // Make sure to tick the engine once if not currently running to get up to date engine._elapsedTime
+ // Make sure to tick the engine once if not currently running to get up to date engine._lastTickTime
// to avoid big gaps with the following offsetPosition calculation
if (!engine.reqId) engine.requestTick(now());
// Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
- offsetPosition = (engine._elapsedTime - engine._startTime) * globals.timeScale;
+ offsetPosition = (engine._lastTickTime - engine._startTime) * globals.timeScale;
}
// Timer's parameters
- this.id = !isUnd(id) ? id : ++timerId;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : timerId;
/** @type {Timeline} */
this.parent = parent;
// Total duration of the timer
@@ -2619,7 +2637,7 @@
// Clock's parameters
/** @type {Number} */
- this._elapsedTime = timerInitTime;
+ this._lastTickTime = timerInitTime;
/** @type {Number} */
this._startTime = timerInitTime;
/** @type {Number} */
@@ -2650,7 +2668,7 @@
}
get iterationCurrentTime() {
- return round$1(this._iterationTime, globals.precision);
+ return clamp$1(round$1(this._iterationTime, globals.precision), 0, this.iterationDuration);
}
set iterationCurrentTime(time) {
@@ -2748,9 +2766,9 @@
/** @return {this} */
resetTime() {
const timeScale = 1 / (this._speed * engine._speed);
- // TODO: See if we can safely use engine._elapsedTime here
+ // TODO: See if we can safely use engine._lastTickTime here
// if (!engine.reqId) engine.requestTick(now())
- // this._startTime = engine._elapsedTime - (this._currentTime + this._delay) * timeScale;
+ // this._startTime = engine._lastTickTime - (this._currentTime + this._delay) * timeScale;
this._startTime = now() - (this._currentTime + this._delay) * timeScale;
return this;
}
@@ -3264,6 +3282,7 @@
const keyObjectTarget = { to: null };
let tweenId = 0;
+ let JSAnimationId = 0;
let keyframes;
/** @type {TweenParamsOptions & TweenValues} */
let key;
@@ -3378,6 +3397,8 @@
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ ++JSAnimationId;
+
const parsedTargets = registerTargets(targets);
const targetsLength = parsedTargets.length;
@@ -3387,6 +3408,7 @@
const params = /** @type {AnimationParams} */(kfParams ? mergeObjects(generateKeyframes(/** @type {DurationKeyframes} */(kfParams), parameters), parameters) : parameters);
const {
+ id,
delay,
duration,
ease,
@@ -3397,11 +3419,12 @@
} = params;
const animDefaults = parent ? parent.defaults : globals.defaults;
- const animaPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
- const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
- const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
+ const animEase = setValue(ease, animDefaults.ease);
+ const animPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
+ const parsedAnimPlaybackEase = animPlaybackEase ? parseEase(animPlaybackEase) : null;
+ const hasSpring = !isUnd(/** @type {Spring} */(animEase).ease);
+ const tEasing = hasSpring ? /** @type {Spring} */(animEase).ease : setValue(ease, parsedAnimPlaybackEase ? 'linear' : animDefaults.ease);
+ const tDuration = hasSpring ? /** @type {Spring} */(animEase).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
@@ -3409,7 +3432,7 @@
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
// This allows targeting the current animation in the spring onComplete callback
- if (hasSpring) /** @type {Spring} */(ease).parent = this;
+ if (hasSpring) /** @type {Spring} */(animEase).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -3553,6 +3576,8 @@
if (isFromToValue) {
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[0], target, ti, tl) : tweenFromValue, fromTargetObject);
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[1], target, ti, tl, toFunctionStore) : tweenToValue, toTargetObject);
+ // Needed to force an inline style registration
+ const originalValue = getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore);
if (fromTargetObject.t === valueTypes.NUMBER) {
if (prevSibling) {
if (prevSibling._valueType === valueTypes.UNIT) {
@@ -3561,7 +3586,7 @@
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
+ originalValue,
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -3780,12 +3805,14 @@
}
/** @type {TargetsArray} */
this.targets = parsedTargets;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : JSAnimationId;
/** @type {Number} */
this.duration = iterationDuration === minValue ? minValue : clampInfinity(((iterationDuration + this._loopDelay) * this.iterationCount) - this._loopDelay) || minValue;
/** @type {Callback<this>} */
this.onRender = onRender || animDefaults.onRender;
/** @type {EasingFunction} */
- this._ease = animEase;
+ this._ease = parsedAnimPlaybackEase;
/** @type {Number} */
this._delay = iterationDelay;
// NOTE: I'm keeping delay values separated from offsets in timelines because delays can override previous tweens and it could be confusing to debug a timeline with overridden tweens and no associated visible delays.
@@ -4123,11 +4150,11 @@
const isSetter = isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= minValue;
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
const adjustedPosition = isSetter ? timePosition - minValue : timePosition;
- tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
+ if (tl.composition) tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
const tlChild = targets ?
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
- tlChild.init(true);
+ if (tl.composition) tlChild.init(true);
// TODO: Might be better to insert at a position relative to startTime?
addChild(tl, tlChild);
forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -4139,6 +4166,8 @@
return tl;
}
+ let TLId = 0;
+
class Timeline extends Timer {
/**
@@ -4146,6 +4175,9 @@
*/
constructor(parameters = {}) {
super(/** @type {TimerParams&TimelineParams} */(parameters), null, 0);
+ ++TLId;
+ /** @type {String|Number} */
+ this.id = !isUnd(parameters.id) ? parameters.id : TLId;
/** @type {Number} */
this.duration = 0; // TL duration starts at 0 and grows when adding children
/** @type {Record<String, Number>} */
@@ -4154,6 +4186,8 @@
const globalDefaults = globals.defaults;
/** @type {DefaultsParams} */
this.defaults = defaultsParams ? mergeObjects(defaultsParams, globalDefaults) : globalDefaults;
+ /** @type {Boolean} */
+ this.composition = setValue(parameters.composition, true);
/** @type {Callback<this>} */
this.onRender = parameters.onRender || globalDefaults.onRender;
const tlPlaybackEase = setValue(parameters.playbackEase, globalDefaults.playbackEase);
@@ -4231,7 +4265,8 @@
parseTimelinePosition(this,a2),
);
}
- return this.init(true);
+ if (this.composition) this.init(true);
+ return this;
}
}
@@ -4258,7 +4293,7 @@
if (isUnd(synced) || synced && isUnd(synced.pause)) return this;
synced.pause();
const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
- return this.add(synced, { currentTime: [0, duration], duration, ease: 'linear' }, position);
+ return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
}
/**
@@ -4281,7 +4316,7 @@
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
- return this.add({ duration: 0, onComplete: () => callback(this) }, position);
+ return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
/**
@@ -7287,1521 +7322,2889 @@
steps: steps
});
- // Chain-able utilities
+
- const numberUtils = numberImports; // Needed to keep the import when bundling
+
- const chainables = {};
+
/**
- * @callback UtilityFunction
- * @param {...*} args
- * @return {Number|String}
- *
- * @param {UtilityFunction} fn
- * @param {Number} [last=0]
- * @return {function(...(Number|String)): function(Number|String): (Number|String)}
+ * Converts an easing function into a valid CSS linear() timing function string
+ * @param {EasingFunction} fn
+ * @param {number} [samples=100]
+ * @returns {string} CSS linear() timing function
*/
- const curry = (fn, last = 0) => (...args) => last ? v => fn(...args, v) : v => fn(v, ...args);
+ const easingToLinear = (fn, samples = 100) => {
+ const points = [];
+ for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
+ return `linear(${points.join(', ')})`;
+ };
+
+ const WAAPIEasesLookups = {};
/**
- * @param {Function} fn
- * @return {function(...(Number|String))}
+ * @param {EasingParam} ease
+ * @return {String}
*/
- const chain = fn => {
- return (...args) => {
- const result = fn(...args);
- return new Proxy(noop, {
- apply: (_, __, [v]) => result(v),
- get: (_, prop) => chain(/**@param {...Number|String} nextArgs */(...nextArgs) => {
- const nextResult = chainables[prop](...nextArgs);
- return (/**@type {Number|String} */v) => nextResult(result(v));
- })
- });
+ const parseWAAPIEasing = (ease) => {
+ let parsedEase = WAAPIEasesLookups[ease];
+ if (parsedEase) return parsedEase;
+ parsedEase = 'linear';
+ if (isStr(ease)) {
+ if (
+ stringStartsWith(ease, 'linear') ||
+ stringStartsWith(ease, 'cubic-') ||
+ stringStartsWith(ease, 'steps') ||
+ stringStartsWith(ease, 'ease')
+ ) {
+ parsedEase = ease;
+ } else if (stringStartsWith(ease, 'cubicB')) {
+ parsedEase = toLowerCase(ease);
+ } else {
+ const parsed = parseEaseString(ease);
+ if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
+ }
+ // Only cache string based easing name, otherwise function arguments get lost
+ WAAPIEasesLookups[ease] = parsedEase;
+ } else if (isFnc(ease)) {
+ const easing = easingToLinear(ease);
+ if (easing) parsedEase = easing;
+ } else if (/** @type {Spring} */(ease).ease) {
+ parsedEase = easingToLinear(/** @type {Spring} */(ease).ease);
}
+ return parsedEase;
};
- /**
- * @param {UtilityFunction} fn
- * @param {String} name
- * @param {Number} [right]
- * @return {function(...(Number|String)): UtilityFunction}
- */
- const makeChainable = (name, fn, right = 0) => {
- const chained = (...args) => (args.length < fn.length ? chain(curry(fn, right)) : fn)(...args);
- if (!chainables[name]) chainables[name] = chained;
- return chained;
- };
+ const transformsShorthands = ['x', 'y', 'z'];
+ const commonDefaultPXProperties = [
+ 'perspective',
+ 'width',
+ 'height',
+ 'margin',
+ 'padding',
+ 'top',
+ 'right',
+ 'bottom',
+ 'left',
+ 'borderWidth',
+ 'fontSize',
+ 'borderRadius',
+ ...transformsShorthands
+ ];
- /**
- * @typedef {Object} ChainablesMap
- * @property {ChainedClamp} clamp
- * @property {ChainedRound} round
- * @property {ChainedSnap} snap
- * @property {ChainedWrap} wrap
- * @property {ChainedLerp} lerp
- * @property {ChainedDamp} damp
- * @property {ChainedMapRange} mapRange
- * @property {ChainedRoundPad} roundPad
- * @property {ChainedPadStart} padStart
- * @property {ChainedPadEnd} padEnd
- * @property {ChainedDegToRad} degToRad
- * @property {ChainedRadToDeg} radToDeg
- */
+ const validIndividualTransforms = /*#__PURE__*/ (() => [...transformsShorthands, ...validTransforms.filter(t => ['X', 'Y', 'Z'].some(axis => t.endsWith(axis)))])();
- /**
- * @callback ChainedUtilsResult
- * @param {Number} value - The value to process through the chained operations
- * @return {Number} The processed result
- */
+ let transformsPropertiesRegistered = null;
/**
- * @typedef {ChainablesMap & ChainedUtilsResult} ChainableUtil
+ * @param {String} propName
+ * @param {WAAPIKeyframeValue} value
+ * @param {DOMTarget} $el
+ * @param {Number} i
+ * @param {Number} targetsLength
+ * @return {String}
*/
-
- // Chainable
+ const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
+ // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
+ let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
+ if (!isNum(v)) return v;
+ if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
+ if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
+ return `${v}`;
+ };
/**
- * @callback ChainedRoundPad
- * @param {Number} decimalLength - Number of decimal places
- * @return {ChainableUtil}
+ * @param {DOMTarget} $el
+ * @param {String} propName
+ * @param {WAAPIKeyframeValue} from
+ * @param {WAAPIKeyframeValue} to
+ * @param {Number} i
+ * @param {Number} targetsLength
+ * @return {WAAPITweenValue}
*/
- const roundPad = /** @type {typeof numberUtils.roundPad & ChainedRoundPad} */(makeChainable('roundPad', numberUtils.roundPad));
+ const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
+ /** @type {WAAPITweenValue} */
+ let tweenValue = '0';
+ const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
+ if (!isUnd(from)) {
+ const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
+ tweenValue = [computedFrom, computedTo];
+ } else {
+ tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
+ }
+ return tweenValue;
+ };
+ class WAAPIAnimation {
/**
- * @callback ChainedPadStart
- * @param {Number} totalLength - Target length
- * @param {String} padString - String to pad with
- * @return {ChainableUtil}
+ * @param {DOMTargetsParam} targets
+ * @param {WAAPIAnimationParams} params
*/
- const padStart = /** @type {typeof numberUtils.padStart & ChainedPadStart} */(makeChainable('padStart', numberUtils.padStart));
+ constructor(targets, params) {
- /**
- * @callback ChainedPadEnd
- * @param {Number} totalLength - Target length
- * @param {String} padString - String to pad with
- * @return {ChainableUtil}
- */
- const padEnd = /** @type {typeof numberUtils.padEnd & ChainedPadEnd} */(makeChainable('padEnd', numberUtils.padEnd));
+ if (scope.current) scope.current.register(this);
- /**
- * @callback ChainedWrap
- * @param {Number} min - Minimum boundary
- * @param {Number} max - Maximum boundary
- * @return {ChainableUtil}
- */
- const wrap = /** @type {typeof numberUtils.wrap & ChainedWrap} */(makeChainable('wrap', numberUtils.wrap));
+ // Skip the registration and fallback to no animation in case CSS.registerProperty is not supported
+ if (isNil(transformsPropertiesRegistered)) {
+ if (isBrowser && (isUnd(CSS) || !Object.hasOwnProperty.call(CSS, 'registerProperty'))) {
+ transformsPropertiesRegistered = false;
+ } else {
+ validTransforms.forEach(t => {
+ const isSkew = stringStartsWith(t, 'skew');
+ const isScale = stringStartsWith(t, 'scale');
+ const isRotate = stringStartsWith(t, 'rotate');
+ const isTranslate = stringStartsWith(t, 'translate');
+ const isAngle = isRotate || isSkew;
+ const syntax = isAngle ? '<angle>' : isScale ? "<number>" : isTranslate ? "<length-percentage>" : "*";
+ try {
+ CSS.registerProperty({
+ name: '--' + t,
+ syntax,
+ inherits: false,
+ initialValue: isTranslate ? '0px' : isAngle ? '0deg' : isScale ? '1' : '0',
+ });
+ } catch {} });
+ transformsPropertiesRegistered = true;
+ }
+ }
- /**
- * @callback ChainedMapRange
- * @param {Number} inLow - Input range minimum
- * @param {Number} inHigh - Input range maximum
- * @param {Number} outLow - Output range minimum
- * @param {Number} outHigh - Output range maximum
- * @return {ChainableUtil}
- */
- const mapRange = /** @type {typeof numberUtils.mapRange & ChainedMapRange} */(makeChainable('mapRange', numberUtils.mapRange));
+ const parsedTargets = registerTargets(targets);
+ const targetsLength = parsedTargets.length;
- /**
- * @callback ChainedDegToRad
- * @return {ChainableUtil}
- */
- const degToRad = /** @type {typeof numberUtils.degToRad & ChainedDegToRad} */(makeChainable('degToRad', numberUtils.degToRad));
+ if (!targetsLength) {
+ console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
+ }
- /**
- * @callback ChainedRadToDeg
- * @return {ChainableUtil}
- */
- const radToDeg = /** @type {typeof numberUtils.radToDeg & ChainedRadToDeg} */(makeChainable('radToDeg', numberUtils.radToDeg));
+ const ease = setValue(params.ease, parseWAAPIEasing(globals.defaults.ease));
+ const spring = /** @type {Spring} */(ease).ease && ease;
+ const autoplay = setValue(params.autoplay, globals.defaults.autoplay);
+ const scroll = autoplay && /** @type {ScrollObserver} */(autoplay).link ? autoplay : false;
+ const alternate = params.alternate && /** @type {Boolean} */(params.alternate) === true;
+ const reversed = params.reversed && /** @type {Boolean} */(params.reversed) === true;
+ const loop = setValue(params.loop, globals.defaults.loop);
+ const iterations = /** @type {Number} */((loop === true || loop === Infinity) ? Infinity : isNum(loop) ? loop + 1 : 1);
+ /** @type {PlaybackDirection} */
+ const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
+ /** @type {FillMode} */
+ const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
+ /** @type {String} */
+ const easing = parseWAAPIEasing(ease);
+ const timeScale = (globals.timeScale === 1 ? 1 : K);
- /**
- * @callback ChainedSnap
- * @param {Number|Array<Number>} increment - Step size or array of snap points
- * @return {ChainableUtil}
- */
- const snap = /** @type {typeof numberUtils.snap & ChainedSnap} */(makeChainable('snap', numberUtils.snap));
+ /** @type {DOMTargetsArray}] */
+ this.targets = parsedTargets;
+ /** @type {Array<globalThis.Animation>}] */
+ this.animations = [];
+ /** @type {globalThis.Animation}] */
+ this.controlAnimation = null;
+ /** @type {Callback<this>} */
+ this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
+ /** @type {Number} */
+ this.duration = 0;
+ /** @type {Boolean} */
+ this.muteCallbacks = false;
+ /** @type {Boolean} */
+ this.completed = false;
+ /** @type {Boolean} */
+ this.paused = !autoplay || scroll !== false;
+ /** @type {Boolean} */
+ this.reversed = reversed;
+ /** @type {Boolean} */
+ this.persist = setValue(params.persist, globals.defaults.persist);
+ /** @type {Boolean|ScrollObserver} */
+ this.autoplay = autoplay;
+ /** @type {Number} */
+ this._speed = setValue(params.playbackRate, globals.defaults.playbackRate);
+ /** @type {Function} */
+ this._resolve = noop; // Used by .then()
+ /** @type {Number} */
+ this._completed = 0;
+ /** @type {Array.<Object>} */
+ this._inlineStyles = [];
- /**
- * @callback ChainedClamp
- * @param {Number} min - Minimum boundary
- * @param {Number} max - Maximum boundary
- * @return {ChainableUtil}
- */
- const clamp = /** @type {typeof numberUtils.clamp & ChainedClamp} */(makeChainable('clamp', numberUtils.clamp));
+ parsedTargets.forEach(($el, i) => {
- /**
- * @callback ChainedRound
- * @param {Number} decimalLength - Number of decimal places
- * @return {ChainableUtil}
- */
- const round = /** @type {typeof numberUtils.round & ChainedRound} */(makeChainable('round', numberUtils.round));
+ const cachedTransforms = $el[transformsSymbol];
+ const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
+ const elStyle = $el.style;
+ const inlineStyles = this._inlineStyles[i] = {};
- /**
- * @callback ChainedLerp
- * @param {Number} start - Starting value
- * @param {Number} end - Ending value
- * @return {ChainableUtil}
- */
- const lerp = /** @type {typeof numberUtils.lerp & ChainedLerp} */(makeChainable('lerp', numberUtils.lerp, 1));
+ /** @type {Number} */
+ const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
+ /** @type {Number} */
+ const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
+ /** @type {CompositeOperation} */
+ const composite = /** @type {CompositeOperation} */(setValue(params.composition, 'replace'));
- /**
- * @callback ChainedDamp
- * @param {Number} start - Starting value
- * @param {Number} end - Target value
- * @param {Number} deltaTime - Delta time in ms
- * @return {ChainableUtil}
- */
- const damp = /** @type {typeof numberUtils.damp & ChainedDamp} */(makeChainable('damp', numberUtils.damp, 1));
+ for (let name in params) {
+ if (!isKey(name)) continue;
+ /** @type {PropertyIndexedKeyframes} */
+ const keyframes = {};
+ /** @type {KeyframeAnimationOptions} */
+ const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
+ const propertyValue = params[name];
+ const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
- /**
- * Generate a random number between optional min and max (inclusive) and decimal precision
- *
- * @callback RandomNumberGenerator
- * @param {Number} [min=0] - The minimum value (inclusive)
- * @param {Number} [max=1] - The maximum value (inclusive)
- * @param {Number} [decimalLength=0] - Number of decimal places to round to
- * @return {Number} A random number between min and max
- */
+ const styleName = individualTransformProperty ? 'transform' : name;
+ if (!inlineStyles[styleName]) {
+ inlineStyles[styleName] = elStyle[styleName];
+ }
- /**
- * Generates a random number between min and max (inclusive) with optional decimal precision
- *
- * @type {RandomNumberGenerator}
- */
- const random = (min = 0, max = 1, decimalLength = 0) => {
- const m = 10 ** decimalLength;
- return Math.floor((Math.random() * (max - min + (1 / m)) + min) * m) / m;
- };
+ let parsedPropertyValue;
+ if (isObj(propertyValue)) {
+ const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
+ const tweenOptionsEase = setValue(tweenOptions.ease, ease);
+ const tweenOptionsSpring = /** @type {Spring} */(tweenOptionsEase).ease && tweenOptionsEase;
+ const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
+ const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
+ /** @type {Number} */
+ tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
+ /** @type {Number} */
+ tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
+ /** @type {CompositeOperation} */
+ tweenParams.composite = /** @type {CompositeOperation} */(setValue(tweenOptions.composition, composite));
+ /** @type {String} */
+ tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
+ parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
+ if (individualTransformProperty) {
+ keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
+ cachedTransforms[individualTransformProperty] = parsedPropertyValue;
+ } else {
+ keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
+ }
+ addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
+ if (!isUnd(from)) {
+ if (!individualTransformProperty) {
+ elStyle[name] = keyframes[name][0];
+ } else {
+ const key = `--${individualTransformProperty}`;
+ elStyle.setProperty(key, keyframes[key][0]);
+ }
+ }
+ } else {
+ parsedPropertyValue = isArr(propertyValue) ?
+ propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
+ normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
+ if (individualTransformProperty) {
+ keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
+ cachedTransforms[individualTransformProperty] = parsedPropertyValue;
+ } else {
+ keyframes[name] = parsedPropertyValue;
+ }
+ addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
+ }
+ }
+ if (hasIndividualTransforms) {
+ let transforms = emptyString;
+ for (let t in cachedTransforms) {
+ transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
+ }
+ elStyle.transform = transforms;
+ }
+ });
- let _seed = 0;
+ if (scroll) {
+ /** @type {ScrollObserver} */(this.autoplay).link(this);
+ }
+ }
- /**
- * Creates a seeded pseudorandom number generator function
- *
- * @param {Number} [seed] - The seed value for the random number generator
- * @param {Number} [seededMin=0] - The minimum default value (inclusive) of the returned function
- * @param {Number} [seededMax=1] - The maximum default value (inclusive) of the returned function
- * @param {Number} [seededDecimalLength=0] - Default number of decimal places to round to of the returned function
- * @return {RandomNumberGenerator} A function to generate a random number between optional min and max (inclusive) and decimal precision
- */
- const createSeededRandom = (seed, seededMin = 0, seededMax = 1, seededDecimalLength = 0) => {
- let t = seed === undefined ? _seed++ : seed;
- return (min = seededMin, max = seededMax, decimalLength = seededDecimalLength) => {
- t += 0x6D2B79F5;
- t = Math.imul(t ^ t >>> 15, t | 1);
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
- const m = 10 ** decimalLength;
- return Math.floor(((((t ^ t >>> 14) >>> 0) / 4294967296) * (max - min + (1 / m)) + min) * m) / m;
+ /**
+ * @callback forEachCallback
+ * @param {globalThis.Animation} animation
+ */
+
+ /**
+ * @param {forEachCallback|String} callback
+ * @return {this}
+ */
+ forEach(callback) {
+ try {
+ const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
+ this.animations.forEach(cb);
+ } catch {} return this;
}
- };
- /**
- * Picks a random element from an array or a string
- *
- * @template T
- * @param {String|Array<T>} items - The array or string to pick from
- * @return {String|T} A random element from the array or character from the string
- */
- const randomPick = items => items[random(0, items.length - 1)];
+ get speed() {
+ return this._speed;
+ }
- /**
- * Shuffles an array in-place using the Fisher-Yates algorithm
- * Adapted from https://bost.ocks.org/mike/shuffle/
- *
- * @param {Array} items - The array to shuffle (will be modified in-place)
- * @return {Array} The same array reference, now shuffled
- */
- const shuffle = items => {
- let m = items.length, t, i;
- while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
- return items;
- };
+ set speed(speed) {
+ this._speed = +speed;
+ this.forEach(anim => anim.playbackRate = speed);
+ }
-
+ get currentTime() {
+ const controlAnimation = this.controlAnimation;
+ const timeScale = globals.timeScale;
+ return this.completed ? this.duration : controlAnimation ? +controlAnimation.currentTime * (timeScale === 1 ? 1 : timeScale) : 0;
+ }
-
+ set currentTime(time) {
+ const t = time * (globals.timeScale === 1 ? 1 : K);
+ this.forEach(anim => {
+ // Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
+ // The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
+ // https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
+ // This is not needed for persisting animations since they never finish.
+ if (!this.persist && t >= this.duration) anim.play();
+ anim.currentTime = t;
+ });
+ }
- /**
- * @overload
- * @param {Number} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
- /**
- * @overload
- * @param {String} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
- /**
- * @overload
- * @param {[Number, Number]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<Number>}
- */
- /**
- * @overload
- * @param {[String, String]} val
- * @param {StaggerParams} [params]
- * @return {StaggerFunction<String>}
- */
- /**
- * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
- * @param {StaggerParams} [params] The stagger parameters
- * @return {StaggerFunction<Number|String>}
- */
- const stagger = (val, params = {}) => {
- let values = [];
- let maxValue = 0;
- const from = params.from;
- const reversed = params.reversed;
- const ease = params.ease;
- const hasEasing = !isUnd(ease);
- const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
- const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
- const grid = params.grid;
- const axis = params.axis;
- const customTotal = params.total;
- const fromFirst = isUnd(from) || from === 0 || from === 'first';
- const fromCenter = from === 'center';
- const fromLast = from === 'last';
- const fromRandom = from === 'random';
- const isRange = isArr(val);
- const useProp = params.use;
- const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
- const val2 = isRange ? parseNumber(val[1]) : 0;
- const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
- const start = params.start || 0 + (isRange ? val1 : 0);
- let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
- return (target, i, t, tl) => {
- const [ registeredTarget ] = registerTargets(target);
- const total = isUnd(customTotal) ? t : customTotal;
- const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
- const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
- if (fromCenter) fromIndex = (total - 1) / 2;
- if (fromLast) fromIndex = total - 1;
- if (!values.length) {
- for (let index = 0; index < total; index++) {
- if (!grid) {
- values.push(abs(fromIndex - index));
+ get progress() {
+ return this.currentTime / this.duration;
+ }
+
+ set progress(progress) {
+ this.forEach(anim => anim.currentTime = progress * this.duration || 0);
+ }
+
+ resume() {
+ if (!this.paused) return this;
+ this.paused = false;
+ // TODO: Store the current time, and seek back to the last position
+ return this.forEach('play');
+ }
+
+ pause() {
+ if (this.paused) return this;
+ this.paused = true;
+ return this.forEach('pause');
+ }
+
+ alternate() {
+ this.reversed = !this.reversed;
+ this.forEach('reverse');
+ if (this.paused) this.forEach('pause');
+ return this;
+ }
+
+ play() {
+ if (this.reversed) this.alternate();
+ return this.resume();
+ }
+
+ reverse() {
+ if (!this.reversed) this.alternate();
+ return this.resume();
+ }
+
+ /**
+ * @param {Number} time
+ * @param {Boolean} muteCallbacks
+ */
+ seek(time, muteCallbacks = false) {
+ if (muteCallbacks) this.muteCallbacks = true;
+ if (time < this.duration) this.completed = false;
+ this.currentTime = time;
+ this.muteCallbacks = false;
+ if (this.paused) this.pause();
+ return this;
+ }
+
+ restart() {
+ this.completed = false;
+ return this.seek(0, true).resume();
+ }
+
+ commitStyles() {
+ return this.forEach('commitStyles');
+ }
+
+ complete() {
+ return this.seek(this.duration);
+ }
+
+ cancel() {
+ this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
+ this.commitStyles().forEach('cancel');
+ this.animations.length = 0; // Needed to release all animations from memory
+ requestAnimationFrame(() => {
+ this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
+ if ($el.style.transform === 'none') $el.style.removeProperty('transform');
+ });
+ });
+ return this;
+ }
+
+ revert() {
+ // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
+ // This means if you have multiple animations animating different transforms on the same target,
+ // reverting one of them will also override the transform property of the other animations.
+ // A better approach would be to store the original custom property values if they exist instead of the entire transform value,
+ // and update the CSS variables with the orignal value
+ this.cancel().targets.forEach(($el, i) => {
+ const targetStyle = $el.style;
+ const targetInlineStyles = this._inlineStyles[i];
+ for (let name in targetInlineStyles) {
+ const originalInlinedValue = targetInlineStyles[name];
+ if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
+ targetStyle.removeProperty(toLowerCase(name));
} else {
- const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
- const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
- const toX = index % grid[0];
- const toY = floor(index / grid[0]);
- const distanceX = fromX - toX;
- const distanceY = fromY - toY;
- let value = sqrt(distanceX * distanceX + distanceY * distanceY);
- if (axis === 'x') value = -distanceX;
- if (axis === 'y') value = -distanceY;
- values.push(value);
+ $el.style[name] = originalInlinedValue;
}
- maxValue = max(...values);
}
- if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
- if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
- if (fromRandom) values = shuffle(values);
- }
- const spacing = isRange ? (val2 - val1) / maxValue : val1;
- const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
- /** @type {String|Number} */
- let output = offset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
- if (params.modifier) output = params.modifier(output);
- if (unitMatch) output = `${output}${unitMatch[2]}`;
- return output;
+ // Remove style attribute if empty
+ if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
+ });
+ return this;
}
- };
- var index$2 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- $: registerTargets,
- clamp: clamp,
- cleanInlineStyles: cleanInlineStyles,
- createSeededRandom: createSeededRandom,
- damp: damp,
- degToRad: degToRad,
- get: get,
- keepTime: keepTime,
- lerp: lerp,
- mapRange: mapRange,
- padEnd: padEnd,
- padStart: padStart,
- radToDeg: radToDeg,
- random: random,
- randomPick: randomPick,
- remove: remove,
- round: round,
- roundPad: roundPad,
- set: set,
- shuffle: shuffle,
- snap: snap,
- stagger: stagger,
- sync: sync,
- wrap: wrap
- });
+ /**
+ * @typedef {this & {then: null}} ResolvedWAAPIAnimation
+ */
-
+ /**
+ * @param {Callback<ResolvedWAAPIAnimation>} [callback]
+ * @return Promise<this>
+ */
+ then(callback = noop) {
+ const then = this.then;
+ const onResolve = () => {
+ this.then = null;
+ callback(/** @type {ResolvedWAAPIAnimation} */(this));
+ this.then = then;
+ this._resolve = noop;
+ };
+ return new Promise(r => {
+ this._resolve = () => r(onResolve());
+ if (this.completed) this._resolve();
+ return this;
+ });
+ }
+ }
+ const waapi = {
/**
- * @param {TargetsParam} path
- * @return {SVGGeometryElement|void}
+ * @param {DOMTargetsParam} targets
+ * @param {WAAPIAnimationParams} params
+ * @return {WAAPIAnimation}
*/
- const getPath = path => {
- const parsedTargets = parseTargets(path);
- const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
- if (!$parsedSvg || !isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
- return $parsedSvg;
+ animate: (targets, params) => new WAAPIAnimation(targets, params),
+ convertEase: easingToLinear
};
- // Motion path animation
+
+
+
+
+
/**
- * @param {SVGGeometryElement} $path
- * @param {Number} totalLength
- * @param {Number} progress
- * @param {Number} lookup
- * @param {Boolean} shouldClamp
- * @return {DOMPoint}
+ * @typedef {DOMTargetSelector|Array<DOMTargetSelector>} LayoutChildrenParam
*/
- const getPathPoint = ($path, totalLength, progress, lookup, shouldClamp) => {
- const point = progress + lookup;
- const pointOnPath = shouldClamp
- ? Math.max(0, Math.min(point, totalLength)) // Clamp between 0 and totalLength
- : (point % totalLength + totalLength) % totalLength; // Wrap around
- return $path.getPointAtLength(pointOnPath);
- };
/**
- * @param {SVGGeometryElement} $path
- * @param {String} pathProperty
- * @param {Number} [offset=0]
- * @return {FunctionValue}
+ * @typedef {Record<String, Number|String>} LayoutStateParams
*/
- const getPathProgess = ($path, pathProperty, offset = 0) => {
- return $el => {
- const totalLength = +($path.getTotalLength());
- const inSvg = $el[isSvgSymbol];
- const ctm = $path.getCTM();
- const shouldClamp = offset === 0;
- /** @type {TweenObjectValue} */
- return {
- from: 0,
- to: totalLength,
- /** @type {TweenModifier} */
- modifier: progress => {
- const offsetLength = offset * totalLength;
- const newProgress = progress + offsetLength;
- if (pathProperty === 'a') {
- const p0 = getPathPoint($path, totalLength, newProgress, -1, shouldClamp);
- const p1 = getPathPoint($path, totalLength, newProgress, 1, shouldClamp);
- return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
- } else {
- const p = getPathPoint($path, totalLength, newProgress, 0, shouldClamp);
- return pathProperty === 'x' ?
- inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
- inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
- }
- }
- }
- }
- };
/**
- * @param {TargetsParam} path
- * @param {Number} [offset=0]
+ * @typedef {Object} LayoutAnimationParams
+ * @property {Number} [duration]
+ * @property {Number|FunctionValue} [delay]
+ * @property {EasingParam} [ease]
+ * @property {LayoutStateParams} [frozen]
+ * @property {LayoutStateParams} [added]
+ * @property {LayoutStateParams} [removed]
+ * @property {Callback<AutoLayout>} [onComplete]
*/
- const createMotionPath = (path, offset = 0) => {
- const $path = getPath(path);
- if (!$path) return;
- return {
- translateX: getPathProgess($path, 'x', offset),
- translateY: getPathProgess($path, 'y', offset),
- rotate: getPathProgess($path, 'a', offset),
- }
- };
-
-
/**
- * @param {SVGGeometryElement} [$el]
- * @return {Number}
+ * @typedef {LayoutAnimationParams & {
+ * children?: LayoutChildrenParam,
+ * properties?: Array<String>,
+ * }} AutoLayoutParams
*/
- const getScaleFactor = $el => {
- let scaleFactor = 1;
- if ($el && $el.getCTM) {
- const ctm = $el.getCTM();
- if (ctm) {
- const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
- const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
- scaleFactor = (scaleX + scaleY) / 2;
- }
- }
- return scaleFactor;
- };
/**
- * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
- * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
- * @param {number} start - Starting position (0-1)
- * @param {number} end - Ending position (0-1)
- * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
+ * @typedef {Record<String, Number|String> & {
+ * transform: String,
+ * x: Number,
+ * y: Number,
+ * left: Number,
+ * top: Number,
+ * clientLeft: Number,
+ * clientTop: Number,
+ * width: Number,
+ * height: Number,
+ * }} LayoutNodeProperties
*/
- const createDrawableProxy = ($el, start, end) => {
- const pathLength = K;
- const computedStyles = getComputedStyle($el);
- const strokeLineCap = computedStyles.strokeLinecap;
- // @ts-ignore
- const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
- let currentCap = strokeLineCap;
-
- const proxy = new Proxy($el, {
- get(target, property) {
- const value = target[property];
- if (property === proxyTargetSymbol) return target;
- if (property === 'setAttribute') {
- return (...args) => {
- if (args[0] === 'draw') {
- const value = args[1];
- const values = value.split(' ');
- const v1 = +values[0];
- const v2 = +values[1];
- // TOTO: Benchmark if performing two slices is more performant than one split
- // const spaceIndex = value.indexOf(' ');
- // const v1 = round(+value.slice(0, spaceIndex), precision);
- // const v2 = round(+value.slice(spaceIndex + 1), precision);
- const scaleFactor = getScaleFactor($scalled);
- const os = v1 * -pathLength * scaleFactor;
- const d1 = (v2 * pathLength * scaleFactor) + os;
- const d2 = (pathLength * scaleFactor +
- ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
- if (strokeLineCap !== 'butt') {
- const newCap = v1 === v2 ? 'butt' : strokeLineCap;
- if (currentCap !== newCap) {
- target.style.strokeLinecap = `${newCap}`;
- currentCap = newCap;
- }
- }
- target.setAttribute('stroke-dashoffset', `${os}`);
- target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
- }
- return Reflect.apply(value, target, args);
- };
- }
- if (isFnc(value)) {
- return (...args) => Reflect.apply(value, target, args);
- } else {
- return value;
- }
- }
- });
+ /**
+ * @typedef {Object} LayoutNode
+ * @property {String} id
+ * @property {DOMTarget} $el
+ * @property {Number} index
+ * @property {Number} total
+ * @property {Number} delay
+ * @property {Number} duration
+ * @property {DOMTarget} $measure
+ * @property {LayoutSnapshot} state
+ * @property {AutoLayout} layout
+ * @property {LayoutNode|null} parentNode
+ * @property {Boolean} isTarget
+ * @property {Boolean} hasTransform
+ * @property {Boolean} isAnimated
+ * @property {Array<String>} inlineStyles
+ * @property {String|null} inlineTransforms
+ * @property {String|null} inlineTransition
+ * @property {Boolean} branchAdded
+ * @property {Boolean} branchRemoved
+ * @property {Boolean} branchNotRendered
+ * @property {Boolean} sizeChanged
+ * @property {Boolean} isInlined
+ * @property {Boolean} hasVisibilitySwap
+ * @property {Boolean} hasDisplayNone
+ * @property {Boolean} hasVisibilityHidden
+ * @property {String|null} measuredInlineTransform
+ * @property {String|null} measuredInlineTransition
+ * @property {String|null} measuredDisplay
+ * @property {String|null} measuredVisibility
+ * @property {String|null} measuredPosition
+ * @property {Boolean} measuredHasDisplayNone
+ * @property {Boolean} measuredHasVisibilityHidden
+ * @property {Boolean} measuredIsVisible
+ * @property {Boolean} measuredIsRemoved
+ * @property {Boolean} measuredIsInsideRoot
+ * @property {LayoutNodeProperties} properties
+ * @property {LayoutNode|null} _head
+ * @property {LayoutNode|null} _tail
+ * @property {LayoutNode|null} _prev
+ * @property {LayoutNode|null} _next
+ */
+
+ /**
+ * @callback LayoutNodeIterator
+ * @param {LayoutNode} node
+ * @param {Number} index
+ * @return {void}
+ */
- if ($el.getAttribute('pathLength') !== `${pathLength}`) {
- $el.setAttribute('pathLength', `${pathLength}`);
- proxy.setAttribute('draw', `${start} ${end}`);
- }
+ let layoutId = 0;
+ let nodeId = 0;
- return /** @type {DrawableSVGGeometry} */(proxy);
+ /**
+ * @param {DOMTarget} root
+ * @param {DOMTarget} $el
+ * @return {Boolean}
+ */
+ const isElementInRoot = (root, $el) => {
+ if (!root || !$el) return false;
+ return root === $el || root.contains($el);
};
/**
- * Creates drawable proxies for multiple SVG elements.
- * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
- * @param {number} [start=0] - Starting position (0-1)
- * @param {number} [end=0] - Ending position (0-1)
- * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
+ * @param {Node} node
+ * @param {'previousSibling'|'nextSibling'} direction
+ * @return {Boolean}
*/
- const createDrawable = (selector, start = 0, end = 0) => {
- const els = parseTargets(selector);
- return els.map($el => createDrawableProxy(
- /** @type {SVGGeometryElement} */($el),
- start,
- end
- ));
+ const hasTextSibling = (node, direction) => {
+ let sibling = node[direction];
+ while (sibling && sibling.nodeType === Node.TEXT_NODE && !sibling.textContent.trim()) {
+ sibling = sibling[direction];
+ }
+ return sibling && sibling.nodeType === Node.TEXT_NODE;
};
-
-
/**
- * @param {TargetsParam} path2
- * @param {Number} [precision]
- * @return {FunctionValue}
+ * @param {DOMTarget} $el
+ * @return {Boolean}
*/
- const morphTo = (path2, precision = .33) => ($path1) => {
- const tagName1 = ($path1.tagName || '').toLowerCase();
- if (!tagName1.match(/^(path|polygon|polyline)$/)) {
- throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
- }
- const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
- if (!$path2) {
- throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
- }
- const tagName2 = ($path2.tagName || '').toLowerCase();
- if (!tagName2.match(/^(path|polygon|polyline)$/)) {
- throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
- }
- const isPath = $path1.tagName === 'path';
- const separator = isPath ? ' ' : ',';
- const previousPoints = $path1[morphPointsSymbol];
- if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
+ const isElementSurroundedByText = $el => hasTextSibling($el, 'previousSibling') || hasTextSibling($el, 'nextSibling');
- let v1 = '', v2 = '';
+ /**
+ * @param {DOMTarget|null} $el
+ * @return {String|null}
+ */
+ const muteElementTransition = $el => {
+ if (!$el) return null;
+ const style = $el.style;
+ const transition = style.transition || '';
+ style.setProperty('transition', 'none', 'important');
+ return transition;
+ };
- if (!precision) {
- v1 = $path1.getAttribute(isPath ? 'd' : 'points');
- v2 = $path2.getAttribute(isPath ? 'd' : 'points');
+ /**
+ * @param {DOMTarget|null} $el
+ * @param {String|null} transition
+ */
+ const restoreElementTransition = ($el, transition) => {
+ if (!$el) return;
+ const style = $el.style;
+ if (transition) {
+ style.transition = transition;
} else {
- const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
- const length2 = $path2.getTotalLength();
- const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
- for (let i = 0; i < maxPoints; i++) {
- const t = i / (maxPoints - 1);
- const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
- const pointOnPath2 = $path2.getPointAtLength(length2 * t);
- const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
- v1 += prefix + round$1(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
- v2 += prefix + round$1(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
- }
+ style.removeProperty('transition');
}
-
- $path1[morphPointsSymbol] = v2;
-
- return [v1, v2];
};
- var index$1 = /*#__PURE__*/Object.freeze({
- __proto__: null,
- createDrawable: createDrawable,
- createMotionPath: createMotionPath,
- morphTo: morphTo
- });
-
-
-
- const segmenter = (typeof Intl !== 'undefined') && Intl.Segmenter;
- const valueRgx = /\{value\}/g;
- const indexRgx = /\{i\}/g;
- const whiteSpaceGroupRgx = /(\s+)/;
- const whiteSpaceRgx = /^\s+$/;
- const lineType = 'line';
- const wordType = 'word';
- const charType = 'char';
- const dataLine = `data-line`;
-
/**
- * @typedef {Object} Segment
- * @property {String} segment
- * @property {Boolean} [isWordLike]
+ * @param {LayoutNode} node
*/
+ const muteNodeTransition = node => {
+ const store = node.layout.transitionMuteStore;
+ const $el = node.$el;
+ const $measure = node.$measure;
+ if ($el && !store.has($el)) store.set($el, muteElementTransition($el));
+ if ($measure && !store.has($measure)) store.set($measure, muteElementTransition($measure));
+ };
/**
- * @typedef {Object} Segmenter
- * @property {function(String): Iterable<Segment>} segment
+ * @param {Map<DOMTarget, String|null>} store
*/
+ const restoreLayoutTransition = store => {
+ store.forEach((value, $el) => restoreElementTransition($el, value));
+ store.clear();
+ };
- /** @type {Segmenter} */
- let wordSegmenter = null;
- /** @type {Segmenter} */
- let graphemeSegmenter = null;
- let $splitTemplate = null;
+ const hiddenComputedStyle = /** @type {CSSStyleDeclaration} */({
+ display: 'none',
+ visibility: 'hidden',
+ opacity: '0',
+ transform: 'none',
+ position: 'static',
+ });
/**
- * @param {Segment} seg
- * @return {Boolean}
+ * @param {LayoutNode|null} node
*/
- const isSegmentWordLike = seg => {
- return seg.isWordLike ||
- seg.segment === ' ' || // Consider spaces as words first, then handle them diffrently later
- isNum(+seg.segment); // Safari doesn't considers numbers as words
+ const detachNode = node => {
+ if (!node) return;
+ const parent = node.parentNode;
+ if (!parent) return;
+ if (parent._head === node) parent._head = node._next;
+ if (parent._tail === node) parent._tail = node._prev;
+ if (node._prev) node._prev._next = node._next;
+ if (node._next) node._next._prev = node._prev;
+ node._prev = null;
+ node._next = null;
+ node.parentNode = null;
};
/**
- * @param {HTMLElement} $el
- */
- const setAriaHidden = $el => $el.setAttribute('aria-hidden', 'true');
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @param {LayoutSnapshot} state
+ * @param {LayoutNode} [recycledNode]
+ * @return {LayoutNode}
+ */
+ const createNode = ($el, parentNode, state, recycledNode) => {
+ let dataId = $el.dataset.layoutId;
+ if (!dataId) dataId = $el.dataset.layoutId = `node-${nodeId++}`;
+ const node = recycledNode ? recycledNode : /** @type {LayoutNode} */({});
+ node.$el = $el;
+ node.$measure = $el;
+ node.id = dataId;
+ node.index = 0;
+ node.total = 1;
+ node.delay = 0;
+ node.duration = 0;
+ node.state = state;
+ node.layout = state.layout;
+ node.parentNode = parentNode || null;
+ node.isTarget = false;
+ node.hasTransform = false;
+ node.isAnimated = false;
+ node.inlineStyles = [];
+ node.inlineTransforms = null;
+ node.inlineTransition = null;
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.sizeChanged = false;
+ node.isInlined = false;
+ node.hasVisibilitySwap = false;
+ node.hasDisplayNone = false;
+ node.hasVisibilityHidden = false;
+ node.measuredInlineTransform = null;
+ node.measuredInlineTransition = null;
+ node.measuredDisplay = null;
+ node.measuredVisibility = null;
+ node.measuredPosition = null;
+ node.measuredHasDisplayNone = false;
+ node.measuredHasVisibilityHidden = false;
+ node.measuredIsVisible = false;
+ node.measuredIsRemoved = false;
+ node.measuredIsInsideRoot = false;
+ node.properties = /** @type {LayoutNodeProperties} */({
+ transform: 'none',
+ x: 0,
+ y: 0,
+ left: 0,
+ top: 0,
+ clientLeft: 0,
+ clientTop: 0,
+ width: 0,
+ height: 0,
+ });
+ node.layout.properties.forEach(prop => node.properties[prop] = 0);
+ node._head = null;
+ node._tail = null;
+ node._prev = null;
+ node._next = null;
+ return node;
+ };
/**
- * @param {DOMTarget} $el
- * @param {String} type
- * @return {Array<HTMLElement>}
- */
- const getAllTopLevelElements = ($el, type) => [.../** @type {*} */($el.querySelectorAll(`[data-${type}]:not([data-${type}] [data-${type}])`))];
+ * @param {LayoutNode} node
+ * @param {DOMTarget} $measure
+ * @param {CSSStyleDeclaration} computedStyle
+ * @param {Boolean} skipMeasurements
+ * @return {LayoutNode}
+ */
+ const recordNodeState = (node, $measure, computedStyle, skipMeasurements) => {
+ const $el = node.$el;
+ const root = node.layout.root;
+ const isRoot = root === $el;
+ const properties = node.properties;
+ const rootNode = node.state.rootNode;
+ const parentNode = node.parentNode;
+ const computedTransforms = computedStyle.transform;
+ const inlineTransforms = $el.style.transform;
+ const parentNotRendered = parentNode ? parentNode.measuredIsRemoved : false;
+ const position = computedStyle.position;
+ if (isRoot) node.layout.absoluteCoords = position === 'fixed' || position === 'absolute';
+ node.$measure = $measure;
+ node.inlineTransforms = inlineTransforms;
+ node.hasTransform = computedTransforms && computedTransforms !== 'none';
+ node.measuredIsInsideRoot = isElementInRoot(root, $measure);
+ node.measuredInlineTransform = null;
+ node.measuredDisplay = computedStyle.display;
+ node.measuredVisibility = computedStyle.visibility;
+ node.measuredPosition = position;
+ node.measuredHasDisplayNone = computedStyle.display === 'none';
+ node.measuredHasVisibilityHidden = computedStyle.visibility === 'hidden';
+ node.measuredIsVisible = !(node.measuredHasDisplayNone || node.measuredHasVisibilityHidden);
+ node.measuredIsRemoved = node.measuredHasDisplayNone || node.measuredHasVisibilityHidden || parentNotRendered;
+ node.isInlined = node.measuredDisplay.includes('inline') && isElementSurroundedByText($el);
+
+ // Mute transforms (and transition to avoid triggering an animation) before the position calculation
+ if (node.hasTransform && !skipMeasurements) {
+ const transitionMuteStore = node.layout.transitionMuteStore;
+ if (!transitionMuteStore.get($el)) node.inlineTransition = muteElementTransition($el);
+ if ($measure === $el) {
+ $el.style.transform = 'none';
+ } else {
+ if (!transitionMuteStore.get($measure)) node.measuredInlineTransition = muteElementTransition($measure);
+ node.measuredInlineTransform = $measure.style.transform;
+ $measure.style.transform = 'none';
+ }
+ }
- const debugColors = { line: '#00D672', word: '#FF4B4B', char: '#5A87FF' };
+ let left = 0;
+ let top = 0;
+ let width = 0;
+ let height = 0;
+
+ if (!skipMeasurements) {
+ const rect = $measure.getBoundingClientRect();
+ left = rect.left;
+ top = rect.top;
+ width = rect.width;
+ height = rect.height;
+ }
+
+ for (let name in properties) {
+ const computedProp = name === 'transform' ? computedTransforms : computedStyle[name] || (computedStyle.getPropertyValue && computedStyle.getPropertyValue(name));
+ if (!isUnd(computedProp)) properties[name] = computedProp;
+ }
+
+ properties.left = left;
+ properties.top = top;
+ properties.clientLeft = skipMeasurements ? 0 : $measure.clientLeft;
+ properties.clientTop = skipMeasurements ? 0 : $measure.clientTop;
+ // Compute local x/y relative to parent
+ let absoluteLeft, absoluteTop;
+ if (isRoot) {
+ if (!node.layout.absoluteCoords) {
+ absoluteLeft = 0;
+ absoluteTop = 0;
+ } else {
+ absoluteLeft = left;
+ absoluteTop = top;
+ }
+ } else {
+ const p = parentNode || rootNode;
+ const parentLeft = p.properties.left;
+ const parentTop = p.properties.top;
+ const borderLeft = p.properties.clientLeft;
+ const borderTop = p.properties.clientTop;
+ if (!node.layout.absoluteCoords) {
+ if (p === rootNode) {
+ const rootLeft = rootNode.properties.left;
+ const rootTop = rootNode.properties.top;
+ const rootBorderLeft = rootNode.properties.clientLeft;
+ const rootBorderTop = rootNode.properties.clientTop;
+ absoluteLeft = left - rootLeft - rootBorderLeft;
+ absoluteTop = top - rootTop - rootBorderTop;
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ }
+ properties.x = absoluteLeft;
+ properties.y = absoluteTop;
+ properties.width = width;
+ properties.height = height;
+ return node;
+ };
/**
- * @param {HTMLElement} $el
+ * @param {LayoutNode} node
+ * @param {LayoutStateParams} [props]
*/
- const filterEmptyElements = $el => {
- if (!$el.childElementCount && !$el.textContent.trim()) {
- const $parent = $el.parentElement;
- $el.remove();
- if ($parent) filterEmptyElements($parent);
+ const updateNodeProperties = (node, props) => {
+ if (!props) return;
+ for (let name in props) {
+ node.properties[name] = props[name];
}
};
/**
- * @param {HTMLElement} $el
- * @param {Number} lineIndex
- * @param {Set<HTMLElement>} bin
- * @returns {Set<HTMLElement>}
+ * @param {LayoutNode} node
*/
- const filterLineElements = ($el, lineIndex, bin) => {
- const dataLineAttr = $el.getAttribute(dataLine);
- if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') bin.add($el);
- let i = $el.childElementCount;
- while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
- return bin;
+ const recordNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ stylesStore.length = 0;
+ node.layout.recordedProperties.forEach(prop => {
+ stylesStore.push(prop, style[prop] || '');
+ });
};
/**
- * @param {'line'|'word'|'char'} type
- * @param {SplitTemplateParams} params
- * @return {String}
+ * @param {LayoutNode} node
*/
- const generateTemplate = (type, params = {}) => {
- let template = ``;
- const classString = isStr(params.class) ? ` class="${params.class}"` : '';
- const cloneType = setValue(params.clone, false);
- const wrapType = setValue(params.wrap, false);
- const overflow = wrapType ? wrapType === true ? 'clip' : wrapType : cloneType ? 'clip' : false;
- if (wrapType) template += `<span${overflow ? ` style="overflow:${overflow};"` : ''}>`;
- template += `<span${classString}${cloneType ? ` style="position:relative;"` : ''} data-${type}="{i}">`;
- if (cloneType) {
- const left = cloneType === 'left' ? '-100%' : cloneType === 'right' ? '100%' : '0';
- const top = cloneType === 'top' ? '-100%' : cloneType === 'bottom' ? '100%' : '0';
- template += `<span>{value}</span>`;
- template += `<span inert style="position:absolute;top:${top};left:${left};white-space:nowrap;">{value}</span>`;
- } else {
- template += `{value}`;
+ const restoreNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ for (let i = 0, l = stylesStore.length; i < l; i += 2) {
+ const property = stylesStore[i];
+ const styleValue = stylesStore[i + 1];
+ if (styleValue && styleValue !== '') {
+ style[property] = styleValue;
+ } else {
+ style[property] = '';
+ style.removeProperty(property);
+ }
}
- template += `</span>`;
- if (wrapType) template += `</span>`;
- return template;
};
/**
- * @param {String|SplitFunctionValue} htmlTemplate
- * @param {Array<HTMLElement>} store
- * @param {Node|HTMLElement} node
- * @param {DocumentFragment} $parentFragment
- * @param {'line'|'word'|'char'} type
- * @param {Boolean} debug
- * @param {Number} lineIndex
- * @param {Number} [wordIndex]
- * @param {Number} [charIndex]
- * @return {HTMLElement}
+ * @param {LayoutNode} node
*/
- const processHTMLTemplate = (htmlTemplate, store, node, $parentFragment, type, debug, lineIndex, wordIndex, charIndex) => {
- const isLine = type === lineType;
- const isChar = type === charType;
- const className = `_${type}_`;
- const template = isFnc(htmlTemplate) ? htmlTemplate(node) : htmlTemplate;
- const displayStyle = isLine ? 'block' : 'inline-block';
- $splitTemplate.innerHTML = template
- .replace(valueRgx, `<i class="${className}"></i>`)
- .replace(indexRgx, `${isChar ? charIndex : isLine ? lineIndex : wordIndex}`);
- const $content = $splitTemplate.content;
- const $highestParent = /** @type {HTMLElement} */($content.firstElementChild);
- const $split = /** @type {HTMLElement} */($content.querySelector(`[data-${type}]`)) || $highestParent;
- const $replacables = /** @type {NodeListOf<HTMLElement>} */($content.querySelectorAll(`i.${className}`));
- const replacablesLength = $replacables.length;
- if (replacablesLength) {
- $highestParent.style.display = displayStyle;
- $split.style.display = displayStyle;
- $split.setAttribute(dataLine, `${lineIndex}`);
- if (!isLine) {
- $split.setAttribute('data-word', `${wordIndex}`);
- if (isChar) $split.setAttribute('data-char', `${charIndex}`);
- }
- let i = replacablesLength;
- while (i--) {
- const $replace = $replacables[i];
- const $closestParent = $replace.parentElement;
- $closestParent.style.display = displayStyle;
- if (isLine) {
- $closestParent.innerHTML = /** @type {HTMLElement} */(node).innerHTML;
- } else {
- $closestParent.replaceChild(node.cloneNode(true), $replace);
- }
+ const restoreNodeTransform = node => {
+ const inlineTransforms = node.inlineTransforms;
+ const nodeStyle = node.$el.style;
+ if (!node.hasTransform || !inlineTransforms || (node.hasTransform && nodeStyle.transform === 'none') || (inlineTransforms && inlineTransforms === 'none')) {
+ nodeStyle.removeProperty('transform');
+ } else if (inlineTransforms) {
+ nodeStyle.transform = inlineTransforms;
+ }
+ const $measure = node.$measure;
+ if (node.hasTransform && $measure !== node.$el) {
+ const measuredStyle = $measure.style;
+ const measuredInline = node.measuredInlineTransform;
+ if (measuredInline && measuredInline !== '') {
+ measuredStyle.transform = measuredInline;
+ } else {
+ measuredStyle.removeProperty('transform');
}
- store.push($split);
- $parentFragment.appendChild($content);
- } else {
- console.warn(`The expression "{value}" is missing from the provided template.`);
}
- if (debug) $highestParent.style.outline = `1px dotted ${debugColors[type]}`;
- return $highestParent;
+ node.measuredInlineTransform = null;
+ if (node.inlineTransition !== null) {
+ restoreElementTransition(node.$el, node.inlineTransition);
+ node.inlineTransition = null;
+ }
+ if ($measure !== node.$el && node.measuredInlineTransition !== null) {
+ restoreElementTransition($measure, node.measuredInlineTransition);
+ node.measuredInlineTransition = null;
+ }
};
/**
- * A class that splits text into words and wraps them in span elements while preserving the original HTML structure.
- * @class
+ * @param {LayoutNode} node
*/
- class TextSplitter {
- /**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- */
- constructor(target, parameters = {}) {
- // Only init segmenters when needed
- if (!wordSegmenter) wordSegmenter = segmenter ? new segmenter([], { granularity: wordType }) : {
- segment: (text) => {
- const segments = [];
- const words = text.split(whiteSpaceGroupRgx);
- for (let i = 0, l = words.length; i < l; i++) {
- const segment = words[i];
- segments.push({
- segment,
- isWordLike: !whiteSpaceRgx.test(segment), // Consider non-whitespace as word-like
- });
- }
- return segments;
- }
- };
- if (!graphemeSegmenter) graphemeSegmenter = segmenter ? new segmenter([], { granularity: 'grapheme' }) : {
- segment: text => [...text].map(char => ({ segment: char }))
- };
- if (!$splitTemplate && isBrowser) $splitTemplate = doc.createElement('template');
- if (scope.current) scope.current.register(this);
- const { words, chars, lines, accessible, includeSpaces, debug } = parameters;
- const $target = /** @type {HTMLElement} */((target = isArr(target) ? target[0] : target) && /** @type {Node} */(target).nodeType ? target : (getNodeList(target) || [])[0]);
- const lineParams = lines === true ? {} : lines;
- const wordParams = words === true || isUnd(words) ? {} : words;
- const charParams = chars === true ? {} : chars;
- this.debug = setValue(debug, false);
- this.includeSpaces = setValue(includeSpaces, false);
- this.accessible = setValue(accessible, true);
- this.linesOnly = lineParams && (!wordParams && !charParams);
- /** @type {String|false|SplitFunctionValue} */
- this.lineTemplate = isObj(lineParams) ? generateTemplate(lineType, /** @type {SplitTemplateParams} */(lineParams)) : lineParams;
- /** @type {String|false|SplitFunctionValue} */
- this.wordTemplate = isObj(wordParams) || this.linesOnly ? generateTemplate(wordType, /** @type {SplitTemplateParams} */(wordParams)) : wordParams;
- /** @type {String|false|SplitFunctionValue} */
- this.charTemplate = isObj(charParams) ? generateTemplate(charType, /** @type {SplitTemplateParams} */(charParams)) : charParams;
- this.$target = $target;
- this.html = $target && $target.innerHTML;
- this.lines = [];
- this.words = [];
- this.chars = [];
- this.effects = [];
- this.effectsCleanups = [];
- this.cache = null;
- this.ready = false;
- this.width = 0;
- this.resizeTimeout = null;
- const handleSplit = () => this.html && (lineParams || wordParams || charParams) && this.split();
- // Make sure this is declared before calling handleSplit() in case revert() is called inside an effect callback
- this.resizeObserver = new ResizeObserver(() => {
- // Use a setTimeout instead of a Timer for better tree shaking
- clearTimeout(this.resizeTimeout);
- this.resizeTimeout = setTimeout(() => {
- const currentWidth = /** @type {HTMLElement} */($target).offsetWidth;
- if (currentWidth === this.width) return;
- this.width = currentWidth;
- handleSplit();
- }, 150);
- });
- // Only declare the font ready promise when splitting by lines and not alreay split
- if (this.lineTemplate && !this.ready) {
- doc.fonts.ready.then(handleSplit);
- } else {
- handleSplit();
+ const restoreNodeVisualState = node => {
+ if (node.measuredIsRemoved || node.hasVisibilitySwap) {
+ node.$el.style.removeProperty('display');
+ node.$el.style.removeProperty('visibility');
+ if (node.hasVisibilitySwap) {
+ node.$measure.style.removeProperty('display');
+ node.$measure.style.removeProperty('visibility');
}
- $target ? this.resizeObserver.observe($target) : console.warn('No Text Splitter target found.');
}
+ if (node.measuredIsRemoved) {
+ node.layout.pendingRemoved.delete(node.$el);
+ }
+ };
+
+ /**
+ * @param {LayoutNode} node
+ * @param {LayoutNode} targetNode
+ * @param {LayoutSnapshot} newState
+ * @return {LayoutNode}
+ */
+ const cloneNodeProperties = (node, targetNode, newState) => {
+ targetNode.properties = /** @type {LayoutNodeProperties} */({ ...node.properties });
+ targetNode.state = newState;
+ targetNode.isTarget = node.isTarget;
+ targetNode.hasTransform = node.hasTransform;
+ targetNode.inlineTransforms = node.inlineTransforms;
+ targetNode.measuredIsVisible = node.measuredIsVisible;
+ targetNode.measuredDisplay = node.measuredDisplay;
+ targetNode.measuredIsRemoved = node.measuredIsRemoved;
+ targetNode.measuredHasDisplayNone = node.measuredHasDisplayNone;
+ targetNode.measuredHasVisibilityHidden = node.measuredHasVisibilityHidden;
+ targetNode.hasDisplayNone = node.hasDisplayNone;
+ targetNode.isInlined = node.isInlined;
+ targetNode.hasVisibilityHidden = node.hasVisibilityHidden;
+ return targetNode;
+ };
+ class LayoutSnapshot {
/**
- * @param {(...args: any[]) => Tickable | (() => void)} effect
- * @return this
+ * @param {AutoLayout} layout
*/
- addEffect(effect) {
- if (!isFnc(effect)) return console.warn('Effect must return a function.');
- const refreshableEffect = keepTime(effect);
- this.effects.push(refreshableEffect);
- if (this.ready) this.effectsCleanups[this.effects.length - 1] = refreshableEffect(this);
- return this;
+ constructor(layout) {
+ /** @type {AutoLayout} */
+ this.layout = layout;
+ /** @type {LayoutNode|null} */
+ this.rootNode = null;
+ /** @type {Set<LayoutNode>} */
+ this.rootNodes = new Set();
+ /** @type {Map<String, LayoutNode>} */
+ this.nodes = new Map();
+ /** @type {Number} */
+ this.scrollX = 0;
+ /** @type {Number} */
+ this.scrollY = 0;
}
+ /**
+ * @return {this}
+ */
revert() {
- clearTimeout(this.resizeTimeout);
- this.lines.length = this.words.length = this.chars.length = 0;
- this.resizeObserver.disconnect();
- // Make sure to revert the effects after disconnecting the resizeObserver to avoid triggering it in the process
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) ? cleanup(this) : cleanup.revert && cleanup.revert());
- this.$target.innerHTML = this.html;
+ this.forEachNode(node => {
+ node.$el.removeAttribute('data-layout-id');
+ node.$measure.removeAttribute('data-layout-id');
+ });
+ this.rootNode = null;
+ this.rootNodes.clear();
+ this.nodes.clear();
return this;
}
/**
- * Recursively processes a node and its children
- * @param {Node} node
+ * @param {DOMTarget} $el
+ * @return {LayoutNodeProperties|undefined}
*/
- splitNode(node) {
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const includeSpaces = this.includeSpaces;
- const debug = this.debug;
- const nodeType = node.nodeType;
- if (nodeType === 3) {
- const nodeText = node.nodeValue;
- // If the nodeText is only whitespace, leave it as is
- if (nodeText.trim()) {
- const tempWords = [];
- const words = this.words;
- const chars = this.chars;
- const wordSegments = wordSegmenter.segment(nodeText);
- const $wordsFragment = doc.createDocumentFragment();
- let prevSeg = null;
- for (const wordSegment of wordSegments) {
- const segment = wordSegment.segment;
- const isWordLike = isSegmentWordLike(wordSegment);
- // Determine if this segment should be a new word, first segment always becomes a new word
- if (!prevSeg || (isWordLike && (prevSeg && (isSegmentWordLike(prevSeg))))) {
- tempWords.push(segment);
- } else {
- // Only concatenate if both current and previous are non-word-like and don't contain spaces
- const lastWordIndex = tempWords.length - 1;
- const lastWord = tempWords[lastWordIndex];
- if (!lastWord.includes(' ') && !segment.includes(' ')) {
- tempWords[lastWordIndex] += segment;
- } else {
- tempWords.push(segment);
- }
- }
- prevSeg = wordSegment;
- }
+ get($el) {
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ return node.properties;
+ }
- for (let i = 0, l = tempWords.length; i < l; i++) {
- const word = tempWords[i];
- if (!word.trim()) {
- // Preserve whitespace only if includeSpaces is false and if the current space is not the first node
- if (i && includeSpaces) continue;
- $wordsFragment.appendChild(doc.createTextNode(word));
- } else {
- const nextWord = tempWords[i + 1];
- const hasWordFollowingSpace = includeSpaces && nextWord && !nextWord.trim();
- const wordToProcess = word;
- const charSegments = charTemplate ? graphemeSegmenter.segment(wordToProcess) : null;
- const $charsFragment = charTemplate ? doc.createDocumentFragment() : doc.createTextNode(hasWordFollowingSpace ? word + '\xa0' : word);
- if (charTemplate) {
- const charSegmentsArray = [...charSegments];
- for (let j = 0, jl = charSegmentsArray.length; j < jl; j++) {
- const charSegment = charSegmentsArray[j];
- const isLastChar = j === jl - 1;
- // If this is the last character and includeSpaces is true with a following space, append the space
- const charText = isLastChar && hasWordFollowingSpace ? charSegment.segment + '\xa0' : charSegment.segment;
- const $charNode = doc.createTextNode(charText);
- processHTMLTemplate(charTemplate, chars, $charNode, /** @type {DocumentFragment} */($charsFragment), charType, debug, -1, words.length, chars.length);
- }
- }
- if (wordTemplate) {
- processHTMLTemplate(wordTemplate, words, $charsFragment, $wordsFragment, wordType, debug, -1, words.length, chars.length);
- // Chars elements must be re-parsed in the split() method if both words and chars are parsed
- } else if (charTemplate) {
- $wordsFragment.appendChild($charsFragment);
- } else {
- $wordsFragment.appendChild(doc.createTextNode(word));
- }
- // Skip the next iteration if we included a space
- if (hasWordFollowingSpace) i++;
- }
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} prop
+ * @return {Number|String|undefined}
+ */
+ getValue($el, prop) {
+ if (!$el || !$el.dataset) {
+ console.warn(`No element found on state (${$el})`);
+ return;
+ }
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ const value = node.properties[prop];
+ if (!isUnd(value)) return getFunctionValue(value, $el, node.index, node.total);
+ }
+
+ /**
+ * @param {LayoutNode|null} rootNode
+ * @param {LayoutNodeIterator} cb
+ */
+ forEach(rootNode, cb) {
+ let node = rootNode;
+ let i = 0;
+ while (node) {
+ cb(node, i++);
+ if (node._head) {
+ node = node._head;
+ } else if (node._next) {
+ node = node._next;
+ } else {
+ while (node && !node._next) {
+ node = node.parentNode;
}
- node.parentNode.replaceChild($wordsFragment, node);
+ if (node) node = node._next;
}
- } else if (nodeType === 1) {
- // Converting to an array is necessary to work around childNodes pottential mutation
- const childNodes = /** @type {Array<Node>} */([.../** @type {*} */(node.childNodes)]);
- for (let i = 0, l = childNodes.length; i < l; i++) this.splitNode(childNodes[i]);
}
}
/**
- * @param {Boolean} clearCache
- * @return {this}
+ * @param {LayoutNodeIterator} cb
*/
- split(clearCache = false) {
- const $el = this.$target;
- const isCached = !!this.cache && !clearCache;
- const lineTemplate = this.lineTemplate;
- const wordTemplate = this.wordTemplate;
- const charTemplate = this.charTemplate;
- const fontsReady = doc.fonts.status !== 'loading';
- const canSplitLines = lineTemplate && fontsReady;
- this.ready = !lineTemplate || fontsReady;
- if (canSplitLines || clearCache) {
- // No need to revert effects animations here since it's already taken care by the refreshable
- this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
+ forEachRootNode(cb) {
+ this.forEach(this.rootNode, cb);
+ }
+
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachNode(cb) {
+ for (const rootNode of this.rootNodes) {
+ this.forEach(rootNode, cb);
}
- if (!isCached) {
- if (clearCache) {
- $el.innerHTML = this.html;
- this.words.length = this.chars.length = 0;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @return {LayoutNode|null}
+ */
+ registerElement($el, parentNode) {
+ if (!$el || $el.nodeType !== 1) return null;
+
+ if (!this.layout.transitionMuteStore.has($el)) this.layout.transitionMuteStore.set($el, muteElementTransition($el));
+
+ /** @type {Array<DOMTarget|LayoutNode|null>} */
+ const stack = [$el, parentNode];
+ const root = this.layout.root;
+ let firstNode = null;
+
+ while (stack.length) {
+ /** @type {LayoutNode|null} */
+ const $parent = /** @type {LayoutNode|null} */(stack.pop());
+ /** @type {DOMTarget|null} */
+ const $current = /** @type {DOMTarget|null} */(stack.pop());
+ if (!$current || $current.nodeType !== 1 || isSvg($current)) continue;
+
+ const skipMeasurements = $parent ? $parent.measuredIsRemoved : false;
+
+ const computedStyle = skipMeasurements ? hiddenComputedStyle : getComputedStyle($current);
+ const hasDisplayNone = skipMeasurements ? true : computedStyle.display === 'none';
+ const hasVisibilityHidden = skipMeasurements ? true : computedStyle.visibility === 'hidden';
+ const isVisible = !hasDisplayNone && !hasVisibilityHidden;
+ const existingId = $current.dataset.layoutId;
+ const isInsideRoot = isElementInRoot(root, $current);
+
+ let node = existingId ? this.nodes.get(existingId) : null;
+
+ if (node && node.$el !== $current) {
+ const nodeInsideRoot = isElementInRoot(root, node.$el);
+ const measuredVisible = node.measuredIsVisible;
+ const shouldReassignNode = !nodeInsideRoot && (isInsideRoot || (!isInsideRoot && !measuredVisible && isVisible));
+ const shouldReuseMeasurements = nodeInsideRoot && !measuredVisible && isVisible;
+ // Rebind nodes that move into the root or whose detached twin just became visible
+ if (shouldReassignNode) {
+ detachNode(node);
+ node = createNode($current, $parent, this, node);
+ // for hidden element with in-root sibling, keep the hidden node but borrow measurements from its visible in-root twin element
+ } else if (shouldReuseMeasurements) {
+ recordNodeState(node, $current, computedStyle, skipMeasurements);
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ // No reassignment needed so keep walking descendants under the current parent
+ } else {
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), $parent);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ }
+ } else {
+ node = createNode($current, $parent, this, node);
}
- this.splitNode($el);
- this.cache = $el.innerHTML;
+
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.isTarget = false;
+ node.isAnimated = false;
+ node.hasVisibilityHidden = hasVisibilityHidden;
+ node.hasDisplayNone = hasDisplayNone;
+ node.hasVisibilitySwap = (hasVisibilityHidden && !node.measuredHasVisibilityHidden) || (hasDisplayNone && !node.measuredHasDisplayNone);
+ // node.hasVisibilitySwap = (hasVisibilityHidden !== node.measuredHasVisibilityHidden) || (hasDisplayNone !== node.measuredHasDisplayNone);
+
+ this.nodes.set(node.id, node);
+
+ node.parentNode = $parent || null;
+ node._prev = null;
+ node._next = null;
+
+ if ($parent) {
+ this.rootNodes.delete(node);
+ if (!$parent._head) {
+ $parent._head = node;
+ $parent._tail = node;
+ } else {
+ $parent._tail._next = node;
+ node._prev = $parent._tail;
+ $parent._tail = node;
+ }
+ } else {
+ this.rootNodes.add(node);
+ }
+
+ recordNodeState(node, node.$el, computedStyle, skipMeasurements);
+
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+
+ if (!firstNode) firstNode = node;
}
- if (canSplitLines) {
- if (isCached) $el.innerHTML = this.cache;
- this.lines.length = 0;
- if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
+
+ return firstNode;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {Set<DOMTarget>} candidates
+ * @return {LayoutNode|null}
+ */
+ ensureDetachedNode($el, candidates) {
+ if (!$el || $el === this.layout.root) return null;
+ const existingId = $el.dataset.layoutId;
+ const existingNode = existingId ? this.nodes.get(existingId) : null;
+ if (existingNode && existingNode.$el === $el) return existingNode;
+ let parentNode = null;
+ let $ancestor = $el.parentElement;
+ while ($ancestor && $ancestor !== this.layout.root) {
+ if (candidates.has($ancestor)) {
+ parentNode = this.ensureDetachedNode($ancestor, candidates);
+ break;
+ }
+ $ancestor = $ancestor.parentElement;
}
- // Always reparse characters after a line reset or if both words and chars are activated
- if (charTemplate && (canSplitLines || wordTemplate)) {
- this.chars = getAllTopLevelElements($el, charType);
+ return this.registerElement($el, parentNode);
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ const { children, root } = this.layout;
+ const toParse = isArr(children) ? children : [children];
+ const scoped = [];
+ const scopeRoot = children === '*' ? root : scope.root;
+
+ for (let i = 0, l = toParse.length; i < l; i++) {
+ const child = toParse[i];
+ scoped[i] = isStr(child) ? scopeRoot.querySelectorAll(child) : child;
}
- // Words are used when lines only and prioritized over chars
- const elementsArray = this.words.length ? this.words : this.chars;
- let y, linesCount = 0;
- for (let i = 0, l = elementsArray.length; i < l; i++) {
- const $el = elementsArray[i];
- const { top, height } = $el.getBoundingClientRect();
- if (y && top - y > height * .5) linesCount++;
- $el.setAttribute(dataLine, `${linesCount}`);
- const nested = $el.querySelectorAll(`[${dataLine}]`);
- let c = nested.length;
- while (c--) nested[c].setAttribute(dataLine, `${linesCount}`);
- y = top;
+
+ const parsedChildren = registerTargets(scoped);
+
+ this.nodes.clear();
+ this.rootNodes.clear();
+
+ const rootNode = this.registerElement(root, null);
+ // Root node are always targets
+ rootNode.isTarget = true;
+ this.rootNode = rootNode;
+
+ // Track ids of nodes that belong to the current root to filter detached matches
+ const inRootNodeIds = new Set();
+ this.nodes.forEach((node, id) => {
+ if (node && node.measuredIsInsideRoot) {
+ inRootNodeIds.add(id);
+ }
+ });
+
+ // Elements with a layout id outside the root that match the children selector
+ const detachedElementsLookup = new Set();
+ const orderedDetachedElements = [];
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ if (!$el || $el.nodeType !== 1 || $el === root) continue;
+ const insideRoot = isElementInRoot(root, $el);
+ if (!insideRoot) {
+ const layoutNodeId = $el.dataset.layoutId;
+ if (!layoutNodeId || !inRootNodeIds.has(layoutNodeId)) continue;
+ }
+ if (!detachedElementsLookup.has($el)) {
+ detachedElementsLookup.add($el);
+ orderedDetachedElements.push($el);
+ }
}
- if (canSplitLines) {
- const linesFragment = doc.createDocumentFragment();
- const parents = new Set();
- const clones = [];
- for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
- const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
- filterLineElements($clone, lineIndex, new Set()).forEach($el => {
- const $parent = $el.parentElement;
- if ($parent) parents.add($parent);
- $el.remove();
+
+ for (let i = 0, l = orderedDetachedElements.length; i < l; i++) {
+ this.ensureDetachedNode(orderedDetachedElements[i], detachedElementsLookup);
+ }
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (node) {
+ let cur = node;
+ while (cur) {
+ if (cur.isTarget) break;
+ cur.isTarget = true;
+ cur = cur.parentNode;
+ }
+ }
+ }
+
+ this.scrollX = window.scrollX;
+ this.scrollY = window.scrollY;
+
+ const total = this.nodes.size;
+
+ this.forEachNode(restoreNodeTransform);
+ this.forEachNode((node, i) => {
+ node.index = i;
+ node.total = total;
+ });
+
+ return this;
+ }
+ }
+
+ class AutoLayout {
+ /**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ */
+ constructor(root, params = {}) {
+ if (scope.current) scope.current.register(this);
+ const frozenParams = params.frozen;
+ const addedParams = params.added;
+ const removedParams = params.removed;
+ const propsParams = params.properties;
+ /** @type {AutoLayoutParams} */
+ this.params = params;
+ /** @type {DOMTarget} */
+ this.root = /** @type {DOMTarget} */(registerTargets(root)[0]);
+ /** @type {Number} */
+ this.id = layoutId++;
+ /** @type {LayoutChildrenParam} */
+ this.children = params.children || '*';
+ /** @type {Boolean} */
+ this.absoluteCoords = false;
+ /** @type {Number} */
+ this.duration = setValue(params.duration, 500);
+ /** @type {Number|FunctionValue} */
+ this.delay = setValue(params.delay, 0);
+ /** @type {EasingParam} */
+ this.ease = setValue(params.ease, 'inOutExpo');
+ /** @type {Callback<this>} */
+ this.onComplete = setValue(params.onComplete, /** @type {Callback<this>} */(noop));
+ /** @type {LayoutStateParams} */
+ this.frozenParams = frozenParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.addedParams = addedParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.removedParams = removedParams || { opacity: 0 };
+ /** @type {Set<String>} */
+ this.properties = new Set([
+ 'opacity',
+ 'borderRadius',
+ ]);
+ if (frozenParams) for (let name in frozenParams) this.properties.add(name);
+ if (addedParams) for (let name in addedParams) this.properties.add(name);
+ if (removedParams) for (let name in removedParams) this.properties.add(name);
+ if (propsParams) for (let i = 0, l = propsParams.length; i < l; i++) this.properties.add(propsParams[i]);
+ /** @type {Set<String>} */
+ this.recordedProperties = new Set([
+ 'display',
+ 'visibility',
+ 'translate',
+ 'position',
+ 'left',
+ 'top',
+ 'marginLeft',
+ 'marginTop',
+ 'width',
+ 'height',
+ 'maxWidth',
+ 'maxHeight',
+ 'minWidth',
+ 'minHeight',
+ ]);
+ this.properties.forEach(prop => this.recordedProperties.add(prop));
+ /** @type {WeakSet<DOMTarget>} */
+ this.pendingRemoved = new WeakSet();
+ /** @type {Map<DOMTarget, String|null>} */
+ this.transitionMuteStore = new Map();
+ /** @type {LayoutSnapshot} */
+ this.oldState = new LayoutSnapshot(this);
+ /** @type {LayoutSnapshot} */
+ this.newState = new LayoutSnapshot(this);
+ /** @type {Timeline|null} */
+ this.timeline = null;
+ /** @type {WAAPIAnimation|null} */
+ this.transformAnimation = null;
+ /** @type {Array<DOMTarget>} */
+ this.frozen = [];
+ /** @type {Array<DOMTarget>} */
+ this.removed = [];
+ /** @type {Array<DOMTarget>} */
+ this.added = [];
+ // Record the current state as the old state to init the data attributes
+ this.oldState.record();
+ // And all layout transition muted during the record
+ restoreLayoutTransition(this.transitionMuteStore);
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ if (this.timeline) {
+ this.timeline.complete();
+ this.timeline = null;
+ }
+ if (this.transformAnimation) {
+ this.transformAnimation.complete();
+ this.transformAnimation = null;
+ }
+ this.root.classList.remove('is-animated');
+ this.frozen.length = this.removed.length = this.added.length = 0;
+ this.oldState.revert();
+ this.newState.revert();
+ requestAnimationFrame(() => restoreLayoutTransition(this.transitionMuteStore));
+ return this;
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ // Commit transforms before measuring
+ if (this.transformAnimation) {
+ this.transformAnimation.cancel();
+ this.transformAnimation = null;
+ }
+ // Record the old state
+ this.oldState.record();
+ // Cancel any running timeline
+ if (this.timeline) {
+ this.timeline.cancel();
+ this.timeline = null;
+ }
+ // Restore previously captured inline styles
+ this.newState.forEachRootNode(restoreNodeInlineStyles);
+ return this;
+ }
+
+ /**
+ * @param {LayoutAnimationParams} [params]
+ * @return {Timeline}
+ */
+ animate(params = {}) {
+ const delay = setValue(params.delay, this.delay);
+ const duration = setValue(params.duration, this.duration);
+ const onComplete = setValue(params.onComplete, this.onComplete);
+ const frozenParams = params.frozen ? mergeObjects(params.frozen, this.frozenParams) : this.frozenParams;
+ const addedParams = params.added ? mergeObjects(params.added, this.addedParams) : this.addedParams;
+ const removedParams = params.removed ? mergeObjects(params.removed, this.removedParams) : this.removedParams;
+ const oldState = this.oldState;
+ const newState = this.newState;
+ const added = this.added;
+ const removed = this.removed;
+ const frozen = this.frozen;
+ const pendingRemoved = this.pendingRemoved;
+
+ added.length = removed.length = frozen.length = 0;
+
+ // Mute old state CSS transitions to prevent wrong properties calculation
+ oldState.forEachRootNode(muteNodeTransition);
+ // Capture the new state before animation
+ newState.record();
+ newState.forEachRootNode(recordNodeInlineStyles);
+
+ const targets = [];
+ const animated = [];
+ const transformed = [];
+ const animatedFrozen = [];
+ const root = newState.rootNode.$el;
+
+ newState.forEachRootNode(node => {
+ const $el = node.$el;
+ const id = node.id;
+ const parent = node.parentNode;
+ const parentAdded = parent ? parent.branchAdded : false;
+ const parentRemoved = parent ? parent.branchRemoved : false;
+ const parentNotRendered = parent ? parent.branchNotRendered : false;
+
+ // Delay and duration must be calculated in the animate() call to support delay override
+ node.delay = +(isFnc(delay) ? delay($el, node.index, node.total) : delay);
+ node.duration = +(isFnc(duration) ? duration($el, node.index, node.total) : duration);
+
+ let oldStateNode = oldState.nodes.get(id);
+
+ const hasNoOldState = !oldStateNode;
+
+ if (hasNoOldState) {
+ oldStateNode = cloneNodeProperties(node, /** @type {LayoutNode} */({}), oldState);
+ oldState.nodes.set(id, oldStateNode);
+ oldStateNode.measuredIsRemoved = true;
+ } else if (oldStateNode.measuredIsRemoved && !node.measuredIsRemoved) {
+ cloneNodeProperties(node, oldStateNode, oldState);
+ oldStateNode.measuredIsRemoved = true;
+ }
+
+ const oldParentNode = oldStateNode.parentNode;
+ const oldParentId = oldParentNode ? oldParentNode.id : null;
+ const newParentId = parent ? parent.id : null;
+ const parentChanged = oldParentId !== newParentId;
+ const elementChanged = oldStateNode.$el !== node.$el;
+ const wasRemovedBefore = oldStateNode.measuredIsRemoved;
+ const isRemovedNow = node.measuredIsRemoved;
+
+ // Recalculate postion relative to their parent for elements that have been moved
+ if (!oldStateNode.measuredIsRemoved && !isRemovedNow && !hasNoOldState && (parentChanged || elementChanged)) {
+ let offsetX = 0;
+ let offsetY = 0;
+ let current = node.parentNode;
+ while (current) {
+ offsetX += current.properties.x || 0;
+ offsetY += current.properties.y || 0;
+ if (current.parentNode === newState.rootNode) break;
+ current = current.parentNode;
+ }
+ let oldOffsetX = 0;
+ let oldOffsetY = 0;
+ let oldCurrent = oldStateNode.parentNode;
+ while (oldCurrent) {
+ oldOffsetX += oldCurrent.properties.x || 0;
+ oldOffsetY += oldCurrent.properties.y || 0;
+ if (oldCurrent.parentNode === oldState.rootNode) break;
+ oldCurrent = oldCurrent.parentNode;
+ }
+ oldStateNode.properties.x += oldOffsetX - offsetX;
+ oldStateNode.properties.y += oldOffsetY - offsetY;
+ }
+
+ if (node.hasVisibilitySwap) {
+ if (node.hasVisibilityHidden) {
+ node.$el.style.visibility = 'visible';
+ node.$measure.style.visibility = 'hidden';
+ }
+ if (node.hasDisplayNone) {
+ node.$el.style.display = oldStateNode.measuredDisplay || node.measuredDisplay || '';
+ // Setting visibility 'hidden' instead of display none to avoid calculation issues
+ node.$measure.style.visibility = 'hidden';
+ // @TODO: check why setting display here can cause calculation issues
+ // node.$measure.style.display = 'none';
+ }
+ }
+
+ const wasPendingRemoval = pendingRemoved.has($el);
+ const wasVisibleBefore = oldStateNode.measuredIsVisible;
+ const isVisibleNow = node.measuredIsVisible;
+ const becomeVisible = !wasVisibleBefore && isVisibleNow && !parentNotRendered;
+ const topLevelAdded = !isRemovedNow && (wasRemovedBefore || wasPendingRemoval) && !parentAdded;
+ const newlyRemoved = isRemovedNow && !wasRemovedBefore && !parentRemoved;
+ const topLevelRemoved = newlyRemoved || isRemovedNow && wasPendingRemoval && !parentRemoved;
+
+ if (node.measuredIsRemoved && wasVisibleBefore) {
+ node.$el.style.display = oldStateNode.measuredDisplay;
+ node.$el.style.visibility = 'visible';
+ cloneNodeProperties(oldStateNode, node, newState);
+ }
+
+ if (newlyRemoved) {
+ removed.push($el);
+ pendingRemoved.add($el);
+ } else if (!isRemovedNow && wasPendingRemoval) {
+ pendingRemoved.delete($el);
+ }
+
+ // Node is added
+ if ((topLevelAdded && !parentNotRendered) || becomeVisible) {
+ updateNodeProperties(oldStateNode, addedParams);
+ added.push($el);
+ // Node is removed
+ } else if (topLevelRemoved && !parentNotRendered) {
+ updateNodeProperties(node, removedParams);
+ }
+
+ // Compute function based propety values before cheking for changes
+ for (let name in node.properties) {
+ node.properties[name] = newState.getValue(node.$el, name);
+ // NOTE: I'm using node.$el to get the value of old state, make sure this is valid instead of oldStateNode.$el
+ oldStateNode.properties[name] = oldState.getValue(node.$el, name);
+ }
+
+ const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
+ let propertyChanged = false;
+
+
+ if (node.isTarget && (!node.measuredIsRemoved && wasVisibleBefore || node.measuredIsRemoved && isVisibleNow)) {
+ if (!node.isInlined && (node.properties.transform !== 'none' || oldStateNode.properties.transform !== 'none')) {
+ node.hasTransform = true;
+ propertyChanged = true;
+ transformed.push($el);
+ }
+ for (let name in node.properties) {
+ if (name !== 'transform' && (node.properties[name] !== oldStateNode.properties[name] || hiddenStateChanged)) {
+ propertyChanged = true;
+ animated.push($el);
+ break;
+ }
+ }
+ }
+
+ const nodeHasChanged = (propertyChanged || topLevelAdded || topLevelRemoved || becomeVisible);
+ const nodeIsAnimated = node.isTarget && nodeHasChanged;
+
+ node.isAnimated = nodeIsAnimated;
+ node.branchAdded = parentAdded || topLevelAdded;
+ node.branchRemoved = parentRemoved || topLevelRemoved;
+ node.branchNotRendered = parentNotRendered || node.measuredIsRemoved;
+
+ const sizeTolerance = 1;
+ const widthChanged = Math.abs(node.properties.width - oldStateNode.properties.width) > sizeTolerance;
+ const heightChanged = Math.abs(node.properties.height - oldStateNode.properties.height) > sizeTolerance;
+
+ node.sizeChanged = (widthChanged || heightChanged);
+
+ targets.push($el);
+
+ if (!node.isTarget) {
+ frozen.push($el);
+ if ((nodeHasChanged || node.sizeChanged) && parent && parent.isTarget && parent.isAnimated && parent.sizeChanged) {
+ animatedFrozen.push($el);
+ }
+ }
+ });
+
+ const defaults = {
+ ease: setValue(params.ease, this.ease),
+ duration: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).duration,
+ delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+
+ this.timeline = createTimeline({
+ onComplete: () => {
+ // Make sure to call .cancel() after restoreNodeInlineStyles(node); otehrwise the commited styles get reverted
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(node => {
+ restoreNodeVisualState(node);
+ restoreNodeInlineStyles(node);
});
- clones.push($clone);
+ for (let i = 0, l = transformed.length; i < l; i++) {
+ const $el = transformed[i];
+ $el.style.transform = newState.getValue($el, 'transform');
+ }
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ // Avoid CSS transitions at the end of the animation by restoring them on the next frame
+ requestAnimationFrame(() => {
+ if (this.root.classList.contains('is-animated')) return;
+ restoreLayoutTransition(this.transitionMuteStore);
+ });
+ },
+ onPause: () => {
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(restoreNodeVisualState);
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ },
+ composition: false,
+ defaults,
+ });
+
+ if (targets.length) {
+
+ this.root.classList.add('is-animated');
+
+ for (let i = 0, l = targets.length; i < l; i++) {
+ const $el = targets[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+
+ // Make sure to mute all CSS transition before applying the oldState styles back
+ muteNodeTransition(newNode);
+
+ // Don't animate dimensions and positions of inlined elements
+ if (!newNode.isInlined) {
+ // Display grid can mess with the absolute positioning, so set it to block during transition
+ // if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.display = 'block';
+ $el.style.display = 'block';
+ // All children must be in position absolue
+ if ($el !== root || this.absoluteCoords) {
+ $el.style.position = this.absoluteCoords ? 'fixed' : 'absolute';
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ $el.style.marginLeft = '0px';
+ $el.style.marginTop = '0px';
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ if ($el === root && newNode.measuredPosition === 'static') {
+ $el.style.position = 'relative';
+ // Cancel left / trop in case the static element had muted values now activated by potision relative
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ }
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ }
}
- parents.forEach(filterEmptyElements);
- for (let cloneIndex = 0, clonesLength = clones.length; cloneIndex < clonesLength; cloneIndex++) {
- processHTMLTemplate(lineTemplate, this.lines, clones[cloneIndex], linesFragment, lineType, this.debug, cloneIndex);
+
+ // Restore the scroll position if the oldState differs from the current state
+ if (oldState.scrollX !== window.scrollX || oldState.scrollY !== window.scrollY) {
+ // Restoring in the next frame avoids race conditions if for example a waapi animation commit styles that affect the root height
+ requestAnimationFrame(() => {
+ window.scrollTo(oldState.scrollX, oldState.scrollY);
+ });
}
- $el.innerHTML = '';
- $el.appendChild(linesFragment);
- if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
- if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
- }
- // Remove the word wrappers and clear the words array if lines split only
- if (this.linesOnly) {
- const words = this.words;
- let w = words.length;
- while (w--) {
- const $word = words[w];
- $word.replaceWith($word.textContent);
+
+ for (let i = 0, l = animated.length; i < l; i++) {
+ const $el = animated[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+ const newNodeState = newNode.properties;
+ let hasChanged = false;
+ const animatedProps = {
+ composition: 'none',
+ // delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+ if (!newNode.isInlined) {
+ if (oldNodeState.width !== newNodeState.width) {
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
+ hasChanged = true;
+ }
+ if (oldNodeState.height !== newNodeState.height) {
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
+ hasChanged = true;
+ }
+ // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
+ // Always animate translate
+ if (!newNode.hasTransform) {
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
+ hasChanged = true;
+ }
+ }
+ this.properties.forEach(prop => {
+ const oldVal = oldNodeState[prop];
+ const newVal = newNodeState[prop];
+ if (prop !== 'transform' && oldVal !== newVal) {
+ animatedProps[prop] = [oldVal, newVal];
+ hasChanged = true;
+ }
+ });
+ if (hasChanged) {
+ this.timeline.add($el, animatedProps, 0);
+ }
}
- words.length = 0;
+
}
- if (this.accessible && (canSplitLines || !isCached)) {
- const $accessible = doc.createElement('span');
- // Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
- $accessible.style.cssText = `position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;`;
- // $accessible.setAttribute('tabindex', '-1');
- $accessible.innerHTML = this.html;
- $el.insertBefore($accessible, $el.firstChild);
- this.lines.forEach(setAriaHidden);
- this.words.forEach(setAriaHidden);
- this.chars.forEach(setAriaHidden);
+
+ if (frozen.length) {
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const oldNode = oldState.nodes.get($el.dataset.layoutId);
+ if (!oldNode.isInlined) {
+ const oldNodeState = oldState.get($el);
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${oldState.getValue($el, prop)}`;
+ }
+ });
+ }
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const newNode = newState.nodes.get($el.dataset.layoutId);
+ const newNodeState = newState.get($el);
+ this.timeline.call(() => {
+ if (!newNode.isInlined) {
+ $el.style.width = `${newNodeState.width}px`;
+ $el.style.height = `${newNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${newNodeState.x}px ${newNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${newState.getValue($el, prop)}`;
+ }
+ });
+ }, newNode.delay + newNode.duration / 2);
+ }
+
+ if (animatedFrozen.length) {
+ const animatedFrozenParams = /** @type {AnimationParams} */({});
+ if (frozenParams) {
+ for (let prop in frozenParams) {
+ animatedFrozenParams[prop] = [
+ { from: (/** @type {HTMLElement} */$el) => oldState.getValue($el, prop), ease: 'in(1.75)', to: frozenParams[prop] },
+ { from: frozenParams[prop], to: (/** @type {HTMLElement} */$el) => newState.getValue($el, prop), ease: 'out(1.75)' }
+ ];
+ }
+ }
+ this.timeline.add(animatedFrozen, animatedFrozenParams, 0);
+ }
+
}
- this.width = /** @type {HTMLElement} */($el).offsetWidth;
- if (canSplitLines || clearCache) {
- this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
+
+ const transformedLength = transformed.length;
+
+ if (transformedLength) {
+ // We only need to set the transform property here since translate is alread defined the targets loop
+ for (let i = 0; i < transformedLength; i++) {
+ const $el = transformed[i];
+ $el.style.translate = `${oldState.get($el).x}px ${oldState.get($el).y}px`,
+ $el.style.transform = oldState.getValue($el, 'transform');
+ }
+ this.transformAnimation = waapi.animate(transformed, {
+ translate: (/** @type {HTMLElement} */$el) => `${newState.get($el).x}px ${newState.get($el).y}px`,
+ transform: (/** @type {HTMLElement} */$el) => newState.getValue($el, 'transform'),
+ autoplay: false,
+ persist: true,
+ ...defaults,
+ });
+ this.timeline.sync(this.transformAnimation, 0);
}
- return this;
+
+ return this.timeline.init();
}
- refresh() {
- this.split(true);
+ /**
+ * @param {(layout: this) => void} callback
+ * @param {LayoutAnimationParams} [params]
+ * @return {this}
+ */
+ update(callback, params = {}) {
+ this.record();
+ callback(this);
+ this.animate(params);
+ return this;
}
}
/**
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- * @return {TextSplitter}
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ * @return {AutoLayout}
*/
- const splitText = (target, parameters) => new TextSplitter(target, parameters);
+ const createLayout = (root, params) => new AutoLayout(root, params);
+
+ // Chain-able utilities
+
+ const numberUtils = numberImports; // Needed to keep the import when bundling
+
+ const chainables = {};
/**
- * @deprecated text.split() is deprecated, import splitText() directly, or text.splitText()
+ * @callback UtilityFunction
+ * @param {...*} args
+ * @return {Number|String}
*
- * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
- * @param {TextSplitterParams} [parameters]
- * @return {TextSplitter}
+ * @param {UtilityFunction} fn
+ * @param {Number} [last=0]
+ * @return {function(...(Number|String)): function(Number|String): (Number|String)}
*/
- const split = (target, parameters) => {
- console.warn('text.split() is deprecated, import splitText() directly, or text.splitText()');
- return new TextSplitter(target, parameters);
+ const curry = (fn, last = 0) => (...args) => last ? v => fn(...args, v) : v => fn(v, ...args);
+
+ /**
+ * @param {Function} fn
+ * @return {function(...(Number|String))}
+ */
+ const chain = fn => {
+ return (...args) => {
+ const result = fn(...args);
+ return new Proxy(noop, {
+ apply: (_, __, [v]) => result(v),
+ get: (_, prop) => chain(/**@param {...Number|String} nextArgs */(...nextArgs) => {
+ const nextResult = chainables[prop](...nextArgs);
+ return (/**@type {Number|String} */v) => nextResult(result(v));
+ })
+ });
+ }
};
- var index = /*#__PURE__*/Object.freeze({
+ /**
+ * @param {UtilityFunction} fn
+ * @param {String} name
+ * @param {Number} [right]
+ * @return {function(...(Number|String)): UtilityFunction}
+ */
+ const makeChainable = (name, fn, right = 0) => {
+ const chained = (...args) => (args.length < fn.length ? chain(curry(fn, right)) : fn)(...args);
+ if (!chainables[name]) chainables[name] = chained;
+ return chained;
+ };
+
+ /**
+ * @typedef {Object} ChainablesMap
+ * @property {ChainedClamp} clamp
+ * @property {ChainedRound} round
+ * @property {ChainedSnap} snap
+ * @property {ChainedWrap} wrap
+ * @property {ChainedLerp} lerp
+ * @property {ChainedDamp} damp
+ * @property {ChainedMapRange} mapRange
+ * @property {ChainedRoundPad} roundPad
+ * @property {ChainedPadStart} padStart
+ * @property {ChainedPadEnd} padEnd
+ * @property {ChainedDegToRad} degToRad
+ * @property {ChainedRadToDeg} radToDeg
+ */
+
+ /**
+ * @callback ChainedUtilsResult
+ * @param {Number} value - The value to process through the chained operations
+ * @return {Number} The processed result
+ */
+
+ /**
+ * @typedef {ChainablesMap & ChainedUtilsResult} ChainableUtil
+ */
+
+ // Chainable
+
+ /**
+ * @callback ChainedRoundPad
+ * @param {Number} decimalLength - Number of decimal places
+ * @return {ChainableUtil}
+ */
+ const roundPad = /** @type {typeof numberUtils.roundPad & ChainedRoundPad} */(makeChainable('roundPad', numberUtils.roundPad));
+
+ /**
+ * @callback ChainedPadStart
+ * @param {Number} totalLength - Target length
+ * @param {String} padString - String to pad with
+ * @return {ChainableUtil}
+ */
+ const padStart = /** @type {typeof numberUtils.padStart & ChainedPadStart} */(makeChainable('padStart', numberUtils.padStart));
+
+ /**
+ * @callback ChainedPadEnd
+ * @param {Number} totalLength - Target length
+ * @param {String} padString - String to pad with
+ * @return {ChainableUtil}
+ */
+ const padEnd = /** @type {typeof numberUtils.padEnd & ChainedPadEnd} */(makeChainable('padEnd', numberUtils.padEnd));
+
+ /**
+ * @callback ChainedWrap
+ * @param {Number} min - Minimum boundary
+ * @param {Number} max - Maximum boundary
+ * @return {ChainableUtil}
+ */
+ const wrap = /** @type {typeof numberUtils.wrap & ChainedWrap} */(makeChainable('wrap', numberUtils.wrap));
+
+ /**
+ * @callback ChainedMapRange
+ * @param {Number} inLow - Input range minimum
+ * @param {Number} inHigh - Input range maximum
+ * @param {Number} outLow - Output range minimum
+ * @param {Number} outHigh - Output range maximum
+ * @return {ChainableUtil}
+ */
+ const mapRange = /** @type {typeof numberUtils.mapRange & ChainedMapRange} */(makeChainable('mapRange', numberUtils.mapRange));
+
+ /**
+ * @callback ChainedDegToRad
+ * @return {ChainableUtil}
+ */
+ const degToRad = /** @type {typeof numberUtils.degToRad & ChainedDegToRad} */(makeChainable('degToRad', numberUtils.degToRad));
+
+ /**
+ * @callback ChainedRadToDeg
+ * @return {ChainableUtil}
+ */
+ const radToDeg = /** @type {typeof numberUtils.radToDeg & ChainedRadToDeg} */(makeChainable('radToDeg', numberUtils.radToDeg));
+
+ /**
+ * @callback ChainedSnap
+ * @param {Number|Array<Number>} increment - Step size or array of snap points
+ * @return {ChainableUtil}
+ */
+ const snap = /** @type {typeof numberUtils.snap & ChainedSnap} */(makeChainable('snap', numberUtils.snap));
+
+ /**
+ * @callback ChainedClamp
+ * @param {Number} min - Minimum boundary
+ * @param {Number} max - Maximum boundary
+ * @return {ChainableUtil}
+ */
+ const clamp = /** @type {typeof numberUtils.clamp & ChainedClamp} */(makeChainable('clamp', numberUtils.clamp));
+
+ /**
+ * @callback ChainedRound
+ * @param {Number} decimalLength - Number of decimal places
+ * @return {ChainableUtil}
+ */
+ const round = /** @type {typeof numberUtils.round & ChainedRound} */(makeChainable('round', numberUtils.round));
+
+ /**
+ * @callback ChainedLerp
+ * @param {Number} start - Starting value
+ * @param {Number} end - Ending value
+ * @return {ChainableUtil}
+ */
+ const lerp = /** @type {typeof numberUtils.lerp & ChainedLerp} */(makeChainable('lerp', numberUtils.lerp, 1));
+
+ /**
+ * @callback ChainedDamp
+ * @param {Number} start - Starting value
+ * @param {Number} end - Target value
+ * @param {Number} deltaTime - Delta time in ms
+ * @return {ChainableUtil}
+ */
+ const damp = /** @type {typeof numberUtils.damp & ChainedDamp} */(makeChainable('damp', numberUtils.damp, 1));
+
+ /**
+ * Generate a random number between optional min and max (inclusive) and decimal precision
+ *
+ * @callback RandomNumberGenerator
+ * @param {Number} [min=0] - The minimum value (inclusive)
+ * @param {Number} [max=1] - The maximum value (inclusive)
+ * @param {Number} [decimalLength=0] - Number of decimal places to round to
+ * @return {Number} A random number between min and max
+ */
+
+ /**
+ * Generates a random number between min and max (inclusive) with optional decimal precision
+ *
+ * @type {RandomNumberGenerator}
+ */
+ const random = (min = 0, max = 1, decimalLength = 0) => {
+ const m = 10 ** decimalLength;
+ return Math.floor((Math.random() * (max - min + (1 / m)) + min) * m) / m;
+ };
+
+ let _seed = 0;
+
+ /**
+ * Creates a seeded pseudorandom number generator function
+ *
+ * @param {Number} [seed] - The seed value for the random number generator
+ * @param {Number} [seededMin=0] - The minimum default value (inclusive) of the returned function
+ * @param {Number} [seededMax=1] - The maximum default value (inclusive) of the returned function
+ * @param {Number} [seededDecimalLength=0] - Default number of decimal places to round to of the returned function
+ * @return {RandomNumberGenerator} A function to generate a random number between optional min and max (inclusive) and decimal precision
+ */
+ const createSeededRandom = (seed, seededMin = 0, seededMax = 1, seededDecimalLength = 0) => {
+ let t = seed === undefined ? _seed++ : seed;
+ return (min = seededMin, max = seededMax, decimalLength = seededDecimalLength) => {
+ t += 0x6D2B79F5;
+ t = Math.imul(t ^ t >>> 15, t | 1);
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
+ const m = 10 ** decimalLength;
+ return Math.floor(((((t ^ t >>> 14) >>> 0) / 4294967296) * (max - min + (1 / m)) + min) * m) / m;
+ }
+ };
+
+ /**
+ * Picks a random element from an array or a string
+ *
+ * @template T
+ * @param {String|Array<T>} items - The array or string to pick from
+ * @return {String|T} A random element from the array or character from the string
+ */
+ const randomPick = items => items[random(0, items.length - 1)];
+
+ /**
+ * Shuffles an array in-place using the Fisher-Yates algorithm
+ * Adapted from https://bost.ocks.org/mike/shuffle/
+ *
+ * @param {Array} items - The array to shuffle (will be modified in-place)
+ * @return {Array} The same array reference, now shuffled
+ */
+ const shuffle = items => {
+ let m = items.length, t, i;
+ while (m) { i = random(0, --m); t = items[m]; items[m] = items[i]; items[i] = t; }
+ return items;
+ };
+
+
+
+
+
+ /**
+ * @overload
+ * @param {Number} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<Number>}
+ */
+ /**
+ * @overload
+ * @param {String} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<String>}
+ */
+ /**
+ * @overload
+ * @param {[Number, Number]} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<Number>}
+ */
+ /**
+ * @overload
+ * @param {[String, String]} val
+ * @param {StaggerParams} [params]
+ * @return {StaggerFunction<String>}
+ */
+ /**
+ * @param {Number|String|[Number, Number]|[String, String]} val The staggered value or range
+ * @param {StaggerParams} [params] The stagger parameters
+ * @return {StaggerFunction<Number|String>}
+ */
+ const stagger = (val, params = {}) => {
+ let values = [];
+ let maxValue = 0;
+ const from = params.from;
+ const reversed = params.reversed;
+ const ease = params.ease;
+ const hasEasing = !isUnd(ease);
+ const hasSpring = hasEasing && !isUnd(/** @type {Spring} */(ease).ease);
+ const staggerEase = hasSpring ? /** @type {Spring} */(ease).ease : hasEasing ? parseEase(ease) : null;
+ const grid = params.grid;
+ const axis = params.axis;
+ const customTotal = params.total;
+ const fromFirst = isUnd(from) || from === 0 || from === 'first';
+ const fromCenter = from === 'center';
+ const fromLast = from === 'last';
+ const fromRandom = from === 'random';
+ const isRange = isArr(val);
+ const useProp = params.use;
+ const val1 = isRange ? parseNumber(val[0]) : parseNumber(val);
+ const val2 = isRange ? parseNumber(val[1]) : 0;
+ const unitMatch = unitsExecRgx.exec((isRange ? val[1] : val) + emptyString);
+ const start = params.start || 0 + (isRange ? val1 : 0);
+ let fromIndex = fromFirst ? 0 : isNum(from) ? from : 0;
+ return (target, i, t, tl) => {
+ const [ registeredTarget ] = registerTargets(target);
+ const total = isUnd(customTotal) ? t : customTotal;
+ const customIndex = !isUnd(useProp) ? isFnc(useProp) ? useProp(registeredTarget, i, total) : getOriginalAnimatableValue(registeredTarget, useProp) : false;
+ const staggerIndex = isNum(customIndex) || isStr(customIndex) && isNum(+customIndex) ? +customIndex : i;
+ if (fromCenter) fromIndex = (total - 1) / 2;
+ if (fromLast) fromIndex = total - 1;
+ if (!values.length) {
+ for (let index = 0; index < total; index++) {
+ if (!grid) {
+ values.push(abs(fromIndex - index));
+ } else {
+ const fromX = !fromCenter ? fromIndex % grid[0] : (grid[0] - 1) / 2;
+ const fromY = !fromCenter ? floor(fromIndex / grid[0]) : (grid[1] - 1) / 2;
+ const toX = index % grid[0];
+ const toY = floor(index / grid[0]);
+ const distanceX = fromX - toX;
+ const distanceY = fromY - toY;
+ let value = sqrt(distanceX * distanceX + distanceY * distanceY);
+ if (axis === 'x') value = -distanceX;
+ if (axis === 'y') value = -distanceY;
+ values.push(value);
+ }
+ maxValue = max(...values);
+ }
+ if (staggerEase) values = values.map(val => staggerEase(val / maxValue) * maxValue);
+ if (reversed) values = values.map(val => axis ? (val < 0) ? val * -1 : -val : abs(maxValue - val));
+ if (fromRandom) values = shuffle(values);
+ }
+ const spacing = isRange ? (val2 - val1) / maxValue : val1;
+ const offset = tl ? parseTimelinePosition(tl, isUnd(params.start) ? tl.iterationDuration : start) : /** @type {Number} */(start);
+ /** @type {String|Number} */
+ let output = offset + ((spacing * round$1(values[staggerIndex], 2)) || 0);
+ if (params.modifier) output = params.modifier(output);
+ if (unitMatch) output = `${output}${unitMatch[2]}`;
+ return output;
+ }
+ };
+
+ var index$2 = /*#__PURE__*/Object.freeze({
__proto__: null,
- TextSplitter: TextSplitter,
- split: split,
- splitText: splitText
+ $: registerTargets,
+ clamp: clamp,
+ cleanInlineStyles: cleanInlineStyles,
+ createSeededRandom: createSeededRandom,
+ damp: damp,
+ degToRad: degToRad,
+ get: get,
+ keepTime: keepTime,
+ lerp: lerp,
+ mapRange: mapRange,
+ padEnd: padEnd,
+ padStart: padStart,
+ radToDeg: radToDeg,
+ random: random,
+ randomPick: randomPick,
+ remove: remove,
+ round: round,
+ roundPad: roundPad,
+ set: set,
+ shuffle: shuffle,
+ snap: snap,
+ stagger: stagger,
+ sync: sync,
+ wrap: wrap
});
-
-
-
-
- /**
- * Converts an easing function into a valid CSS linear() timing function string
- * @param {EasingFunction} fn
- * @param {number} [samples=100]
- * @returns {string} CSS linear() timing function
- */
- const easingToLinear = (fn, samples = 100) => {
- const points = [];
- for (let i = 0; i <= samples; i++) points.push(round$1(fn(i / samples), 4));
- return `linear(${points.join(', ')})`;
- };
-
- const WAAPIEasesLookups = {};
-
/**
- * @param {EasingParam} ease
- * @return {String}
+ * @param {TargetsParam} path
+ * @return {SVGGeometryElement|void}
*/
- const parseWAAPIEasing = (ease) => {
- let parsedEase = WAAPIEasesLookups[ease];
- if (parsedEase) return parsedEase;
- parsedEase = 'linear';
- if (isStr(ease)) {
- if (
- stringStartsWith(ease, 'linear') ||
- stringStartsWith(ease, 'cubic-') ||
- stringStartsWith(ease, 'steps') ||
- stringStartsWith(ease, 'ease')
- ) {
- parsedEase = ease;
- } else if (stringStartsWith(ease, 'cubicB')) {
- parsedEase = toLowerCase(ease);
- } else {
- const parsed = parseEaseString(ease);
- if (isFnc(parsed)) parsedEase = parsed === none ? 'linear' : easingToLinear(parsed);
- }
- // Only cache string based easing name, otherwise function arguments get lost
- WAAPIEasesLookups[ease] = parsedEase;
- } else if (isFnc(ease)) {
- const easing = easingToLinear(ease);
- if (easing) parsedEase = easing;
- } else if (/** @type {Spring} */(ease).ease) {
- parsedEase = easingToLinear(/** @type {Spring} */(ease).ease);
- }
- return parsedEase;
+ const getPath = path => {
+ const parsedTargets = parseTargets(path);
+ const $parsedSvg = /** @type {SVGGeometryElement} */(parsedTargets[0]);
+ if (!$parsedSvg || !isSvg($parsedSvg)) return console.warn(`${path} is not a valid SVGGeometryElement`);
+ return $parsedSvg;
};
- const transformsShorthands = ['x', 'y', 'z'];
- const commonDefaultPXProperties = [
- 'perspective',
- 'width',
- 'height',
- 'margin',
- 'padding',
- 'top',
- 'right',
- 'bottom',
- 'left',
- 'borderWidth',
- 'fontSize',
- 'borderRadius',
- ...transformsShorthands
- ];
-
- const validIndividualTransforms = /*#__PURE__*/ (() => [...transformsShorthands, ...validTransforms.filter(t => ['X', 'Y', 'Z'].some(axis => t.endsWith(axis)))])();
+
- let transformsPropertiesRegistered = null;
+ // Motion path animation
/**
- * @param {String} propName
- * @param {WAAPIKeyframeValue} value
- * @param {DOMTarget} $el
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {String}
+ * @param {SVGGeometryElement} $path
+ * @param {Number} totalLength
+ * @param {Number} progress
+ * @param {Number} lookup
+ * @param {Boolean} shouldClamp
+ * @return {DOMPoint}
*/
- const normalizeTweenValue = (propName, value, $el, i, targetsLength) => {
- // Do not try to compute strings with getFunctionValue otherwise it will convert CSS variables
- let v = isStr(value) ? value : getFunctionValue(/** @type {any} */(value), $el, i, targetsLength);
- if (!isNum(v)) return v;
- if (commonDefaultPXProperties.includes(propName) || stringStartsWith(propName, 'translate')) return `${v}px`;
- if (stringStartsWith(propName, 'rotate') || stringStartsWith(propName, 'skew')) return `${v}deg`;
- return `${v}`;
+ const getPathPoint = ($path, totalLength, progress, lookup, shouldClamp) => {
+ const point = progress + lookup;
+ const pointOnPath = shouldClamp
+ ? Math.max(0, Math.min(point, totalLength)) // Clamp between 0 and totalLength
+ : (point % totalLength + totalLength) % totalLength; // Wrap around
+ return $path.getPointAtLength(pointOnPath);
};
/**
- * @param {DOMTarget} $el
- * @param {String} propName
- * @param {WAAPIKeyframeValue} from
- * @param {WAAPIKeyframeValue} to
- * @param {Number} i
- * @param {Number} targetsLength
- * @return {WAAPITweenValue}
+ * @param {SVGGeometryElement} $path
+ * @param {String} pathProperty
+ * @param {Number} [offset=0]
+ * @return {FunctionValue}
*/
- const parseIndividualTweenValue = ($el, propName, from, to, i, targetsLength) => {
- /** @type {WAAPITweenValue} */
- let tweenValue = '0';
- const computedTo = !isUnd(to) ? normalizeTweenValue(propName, to, $el, i, targetsLength) : getComputedStyle($el)[propName];
- if (!isUnd(from)) {
- const computedFrom = normalizeTweenValue(propName, from, $el, i, targetsLength);
- tweenValue = [computedFrom, computedTo];
- } else {
- tweenValue = isArr(to) ? to.map((/** @type {any} */v) => normalizeTweenValue(propName, v, $el, i, targetsLength)) : computedTo;
+ const getPathProgess = ($path, pathProperty, offset = 0) => {
+ return $el => {
+ const totalLength = +($path.getTotalLength());
+ const inSvg = $el[isSvgSymbol];
+ const ctm = $path.getCTM();
+ const shouldClamp = offset === 0;
+ /** @type {TweenObjectValue} */
+ return {
+ from: 0,
+ to: totalLength,
+ /** @type {TweenModifier} */
+ modifier: progress => {
+ const offsetLength = offset * totalLength;
+ const newProgress = progress + offsetLength;
+ if (pathProperty === 'a') {
+ const p0 = getPathPoint($path, totalLength, newProgress, -1, shouldClamp);
+ const p1 = getPathPoint($path, totalLength, newProgress, 1, shouldClamp);
+ return atan2(p1.y - p0.y, p1.x - p0.x) * 180 / PI;
+ } else {
+ const p = getPathPoint($path, totalLength, newProgress, 0, shouldClamp);
+ return pathProperty === 'x' ?
+ inSvg || !ctm ? p.x : p.x * ctm.a + p.y * ctm.c + ctm.e :
+ inSvg || !ctm ? p.y : p.x * ctm.b + p.y * ctm.d + ctm.f
+ }
+ }
+ }
}
- return tweenValue;
};
- class WAAPIAnimation {
/**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
+ * @param {TargetsParam} path
+ * @param {Number} [offset=0]
*/
- constructor(targets, params) {
-
- if (scope.current) scope.current.register(this);
-
- // Skip the registration and fallback to no animation in case CSS.registerProperty is not supported
- if (isNil(transformsPropertiesRegistered)) {
- if (isBrowser && (isUnd(CSS) || !Object.hasOwnProperty.call(CSS, 'registerProperty'))) {
- transformsPropertiesRegistered = false;
- } else {
- validTransforms.forEach(t => {
- const isSkew = stringStartsWith(t, 'skew');
- const isScale = stringStartsWith(t, 'scale');
- const isRotate = stringStartsWith(t, 'rotate');
- const isTranslate = stringStartsWith(t, 'translate');
- const isAngle = isRotate || isSkew;
- const syntax = isAngle ? '<angle>' : isScale ? "<number>" : isTranslate ? "<length-percentage>" : "*";
- try {
- CSS.registerProperty({
- name: '--' + t,
- syntax,
- inherits: false,
- initialValue: isTranslate ? '0px' : isAngle ? '0deg' : isScale ? '1' : '0',
- });
- } catch {} });
- transformsPropertiesRegistered = true;
- }
- }
-
- const parsedTargets = registerTargets(targets);
- const targetsLength = parsedTargets.length;
-
- if (!targetsLength) {
- console.warn(`No target found. Make sure the element you're trying to animate is accessible before creating your animation.`);
- }
-
- const ease = setValue(params.ease, parseWAAPIEasing(globals.defaults.ease));
- const spring = /** @type {Spring} */(ease).ease && ease;
- const autoplay = setValue(params.autoplay, globals.defaults.autoplay);
- const scroll = autoplay && /** @type {ScrollObserver} */(autoplay).link ? autoplay : false;
- const alternate = params.alternate && /** @type {Boolean} */(params.alternate) === true;
- const reversed = params.reversed && /** @type {Boolean} */(params.reversed) === true;
- const loop = setValue(params.loop, globals.defaults.loop);
- const iterations = /** @type {Number} */((loop === true || loop === Infinity) ? Infinity : isNum(loop) ? loop + 1 : 1);
- /** @type {PlaybackDirection} */
- const direction = alternate ? reversed ? 'alternate-reverse' : 'alternate' : reversed ? 'reverse' : 'normal';
- /** @type {FillMode} */
- const fill = 'both'; // We use 'both' here because the animation can be reversed during playback
- /** @type {String} */
- const easing = parseWAAPIEasing(ease);
- const timeScale = (globals.timeScale === 1 ? 1 : K);
-
- /** @type {DOMTargetsArray}] */
- this.targets = parsedTargets;
- /** @type {Array<globalThis.Animation>}] */
- this.animations = [];
- /** @type {globalThis.Animation}] */
- this.controlAnimation = null;
- /** @type {Callback<this>} */
- this.onComplete = params.onComplete || /** @type {Callback<WAAPIAnimation>} */(/** @type {unknown} */(globals.defaults.onComplete));
- /** @type {Number} */
- this.duration = 0;
- /** @type {Boolean} */
- this.muteCallbacks = false;
- /** @type {Boolean} */
- this.completed = false;
- /** @type {Boolean} */
- this.paused = !autoplay || scroll !== false;
- /** @type {Boolean} */
- this.reversed = reversed;
- /** @type {Boolean} */
- this.persist = setValue(params.persist, globals.defaults.persist);
- /** @type {Boolean|ScrollObserver} */
- this.autoplay = autoplay;
- /** @type {Number} */
- this._speed = setValue(params.playbackRate, globals.defaults.playbackRate);
- /** @type {Function} */
- this._resolve = noop; // Used by .then()
- /** @type {Number} */
- this._completed = 0;
- /** @type {Array.<Object>} */
- this._inlineStyles = [];
-
- parsedTargets.forEach(($el, i) => {
-
- const cachedTransforms = $el[transformsSymbol];
- const hasIndividualTransforms = validIndividualTransforms.some(t => params.hasOwnProperty(t));
- const elStyle = $el.style;
- const inlineStyles = this._inlineStyles[i] = {};
+ const createMotionPath = (path, offset = 0) => {
+ const $path = getPath(path);
+ if (!$path) return;
+ return {
+ translateX: getPathProgess($path, 'x', offset),
+ translateY: getPathProgess($path, 'y', offset),
+ rotate: getPathProgess($path, 'a', offset),
+ }
+ };
- /** @type {Number} */
- const duration = (spring ? /** @type {Spring} */(spring).settlingDuration : getFunctionValue(setValue(params.duration, globals.defaults.duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- const delay = getFunctionValue(setValue(params.delay, globals.defaults.delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- const composite = /** @type {CompositeOperation} */(setValue(params.composition, 'replace'));
+
- for (let name in params) {
- if (!isKey(name)) continue;
- /** @type {PropertyIndexedKeyframes} */
- const keyframes = {};
- /** @type {KeyframeAnimationOptions} */
- const tweenParams = { iterations, direction, fill, easing, duration, delay, composite };
- const propertyValue = params[name];
- const individualTransformProperty = hasIndividualTransforms ? validTransforms.includes(name) ? name : shortTransforms.get(name) : false;
+ /**
+ * @param {SVGGeometryElement} [$el]
+ * @return {Number}
+ */
+ const getScaleFactor = $el => {
+ let scaleFactor = 1;
+ if ($el && $el.getCTM) {
+ const ctm = $el.getCTM();
+ if (ctm) {
+ const scaleX = sqrt(ctm.a * ctm.a + ctm.b * ctm.b);
+ const scaleY = sqrt(ctm.c * ctm.c + ctm.d * ctm.d);
+ scaleFactor = (scaleX + scaleY) / 2;
+ }
+ }
+ return scaleFactor;
+ };
- const styleName = individualTransformProperty ? 'transform' : name;
- if (!inlineStyles[styleName]) {
- inlineStyles[styleName] = elStyle[styleName];
- }
+ /**
+ * Creates a proxy that wraps an SVGGeometryElement and adds drawing functionality.
+ * @param {SVGGeometryElement} $el - The SVG element to transform into a drawable
+ * @param {number} start - Starting position (0-1)
+ * @param {number} end - Ending position (0-1)
+ * @return {DrawableSVGGeometry} - Returns a proxy that preserves the original element's type with additional 'draw' attribute functionality
+ */
+ const createDrawableProxy = ($el, start, end) => {
+ const pathLength = K;
+ const computedStyles = getComputedStyle($el);
+ const strokeLineCap = computedStyles.strokeLinecap;
+ // @ts-ignore
+ const $scalled = computedStyles.vectorEffect === 'non-scaling-stroke' ? $el : null;
+ let currentCap = strokeLineCap;
- let parsedPropertyValue;
- if (isObj(propertyValue)) {
- const tweenOptions = /** @type {WAAPITweenOptions} */(propertyValue);
- const tweenOptionsEase = setValue(tweenOptions.ease, ease);
- const tweenOptionsSpring = /** @type {Spring} */(tweenOptionsEase).ease && tweenOptionsEase;
- const to = /** @type {WAAPITweenOptions} */(tweenOptions).to;
- const from = /** @type {WAAPITweenOptions} */(tweenOptions).from;
- /** @type {Number} */
- tweenParams.duration = (tweenOptionsSpring ? /** @type {Spring} */(tweenOptionsSpring).settlingDuration : getFunctionValue(setValue(tweenOptions.duration, duration), $el, i, targetsLength)) * timeScale;
- /** @type {Number} */
- tweenParams.delay = getFunctionValue(setValue(tweenOptions.delay, delay), $el, i, targetsLength) * timeScale;
- /** @type {CompositeOperation} */
- tweenParams.composite = /** @type {CompositeOperation} */(setValue(tweenOptions.composition, composite));
- /** @type {String} */
- tweenParams.easing = parseWAAPIEasing(tweenOptionsEase);
- parsedPropertyValue = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- } else {
- keyframes[name] = parseIndividualTweenValue($el, name, from, to, i, targetsLength);
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- if (!isUnd(from)) {
- if (!individualTransformProperty) {
- elStyle[name] = keyframes[name][0];
- } else {
- const key = `--${individualTransformProperty}`;
- elStyle.setProperty(key, keyframes[key][0]);
+ const proxy = new Proxy($el, {
+ get(target, property) {
+ const value = target[property];
+ if (property === proxyTargetSymbol) return target;
+ if (property === 'setAttribute') {
+ return (...args) => {
+ if (args[0] === 'draw') {
+ const value = args[1];
+ const values = value.split(' ');
+ const v1 = +values[0];
+ const v2 = +values[1];
+ // TOTO: Benchmark if performing two slices is more performant than one split
+ // const spaceIndex = value.indexOf(' ');
+ // const v1 = round(+value.slice(0, spaceIndex), precision);
+ // const v2 = round(+value.slice(spaceIndex + 1), precision);
+ const scaleFactor = getScaleFactor($scalled);
+ const os = v1 * -pathLength * scaleFactor;
+ const d1 = (v2 * pathLength * scaleFactor) + os;
+ const d2 = (pathLength * scaleFactor +
+ ((v1 === 0 && v2 === 1) || (v1 === 1 && v2 === 0) ? 0 : 10 * scaleFactor) - d1);
+ if (strokeLineCap !== 'butt') {
+ const newCap = v1 === v2 ? 'butt' : strokeLineCap;
+ if (currentCap !== newCap) {
+ target.style.strokeLinecap = `${newCap}`;
+ currentCap = newCap;
+ }
}
+ target.setAttribute('stroke-dashoffset', `${os}`);
+ target.setAttribute('stroke-dasharray', `${d1} ${d2}`);
}
- } else {
- parsedPropertyValue = isArr(propertyValue) ?
- propertyValue.map((/** @type {any} */v) => normalizeTweenValue(name, v, $el, i, targetsLength)) :
- normalizeTweenValue(name, /** @type {any} */(propertyValue), $el, i, targetsLength);
- if (individualTransformProperty) {
- keyframes[`--${individualTransformProperty}`] = parsedPropertyValue;
- cachedTransforms[individualTransformProperty] = parsedPropertyValue;
- } else {
- keyframes[name] = parsedPropertyValue;
- }
- addWAAPIAnimation(this, $el, name, keyframes, tweenParams);
- }
- }
- if (hasIndividualTransforms) {
- let transforms = emptyString;
- for (let t in cachedTransforms) {
- transforms += `${transformsFragmentStrings[t]}var(--${t})) `;
- }
- elStyle.transform = transforms;
+ return Reflect.apply(value, target, args);
+ };
}
- });
- if (scroll) {
- /** @type {ScrollObserver} */(this.autoplay).link(this);
+ if (isFnc(value)) {
+ return (...args) => Reflect.apply(value, target, args);
+ } else {
+ return value;
+ }
}
+ });
+
+ if ($el.getAttribute('pathLength') !== `${pathLength}`) {
+ $el.setAttribute('pathLength', `${pathLength}`);
+ proxy.setAttribute('draw', `${start} ${end}`);
}
- /**
- * @callback forEachCallback
- * @param {globalThis.Animation} animation
- */
+ return /** @type {DrawableSVGGeometry} */(proxy);
+ };
- /**
- * @param {forEachCallback|String} callback
- * @return {this}
- */
- forEach(callback) {
- const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
- this.animations.forEach(cb);
- return this;
- }
+ /**
+ * Creates drawable proxies for multiple SVG elements.
+ * @param {TargetsParam} selector - CSS selector, SVG element, or array of elements and selectors
+ * @param {number} [start=0] - Starting position (0-1)
+ * @param {number} [end=0] - Ending position (0-1)
+ * @return {Array<DrawableSVGGeometry>} - Array of proxied elements with drawing functionality
+ */
+ const createDrawable = (selector, start = 0, end = 0) => {
+ const els = parseTargets(selector);
+ return els.map($el => createDrawableProxy(
+ /** @type {SVGGeometryElement} */($el),
+ start,
+ end
+ ));
+ };
- get speed() {
- return this._speed;
- }
+
- set speed(speed) {
- this._speed = +speed;
- this.forEach(anim => anim.playbackRate = speed);
+ /**
+ * @param {TargetsParam} path2
+ * @param {Number} [precision]
+ * @return {FunctionValue}
+ */
+ const morphTo = (path2, precision = .33) => ($path1) => {
+ const tagName1 = ($path1.tagName || '').toLowerCase();
+ if (!tagName1.match(/^(path|polygon|polyline)$/)) {
+ throw new Error(`Can't morph a <${$path1.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
}
-
- get currentTime() {
- const controlAnimation = this.controlAnimation;
- const timeScale = globals.timeScale;
- return this.completed ? this.duration : controlAnimation ? +controlAnimation.currentTime * (timeScale === 1 ? 1 : timeScale) : 0;
+ const $path2 = /** @type {SVGGeometryElement} */(getPath(path2));
+ if (!$path2) {
+ throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");
+ }
+ const tagName2 = ($path2.tagName || '').toLowerCase();
+ if (!tagName2.match(/^(path|polygon|polyline)$/)) {
+ throw new Error(`Can't morph a <${$path2.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);
}
+ const isPath = $path1.tagName === 'path';
+ const separator = isPath ? ' ' : ',';
+ const previousPoints = $path1[morphPointsSymbol];
+ if (previousPoints) $path1.setAttribute(isPath ? 'd' : 'points', previousPoints);
- set currentTime(time) {
- const t = time * (globals.timeScale === 1 ? 1 : K);
- this.forEach(anim => {
- // Make sure the animation playState is not 'paused' in order to properly trigger an onfinish callback.
- // The "paused" play state supersedes the "finished" play state; if the animation is both paused and finished, the "paused" state is the one that will be reported.
- // https://developer.mozilla.org/en-US/docs/Web/API/Animation/finish_event
- // This is not needed for persisting animations since they never finish.
- if (!this.persist && t >= this.duration) anim.play();
- anim.currentTime = t;
- });
+ let v1 = '', v2 = '';
+
+ if (!precision) {
+ v1 = $path1.getAttribute(isPath ? 'd' : 'points');
+ v2 = $path2.getAttribute(isPath ? 'd' : 'points');
+ } else {
+ const length1 = /** @type {SVGGeometryElement} */($path1).getTotalLength();
+ const length2 = $path2.getTotalLength();
+ const maxPoints = Math.max(Math.ceil(length1 * precision), Math.ceil(length2 * precision));
+ for (let i = 0; i < maxPoints; i++) {
+ const t = i / (maxPoints - 1);
+ const pointOnPath1 = /** @type {SVGGeometryElement} */($path1).getPointAtLength(length1 * t);
+ const pointOnPath2 = $path2.getPointAtLength(length2 * t);
+ const prefix = isPath ? (i === 0 ? 'M' : 'L') : '';
+ v1 += prefix + round$1(pointOnPath1.x, 3) + separator + pointOnPath1.y + ' ';
+ v2 += prefix + round$1(pointOnPath2.x, 3) + separator + pointOnPath2.y + ' ';
+ }
}
- get progress() {
- return this.currentTime / this.duration;
- }
+ $path1[morphPointsSymbol] = v2;
+
+ return [v1, v2];
+ };
+
+ var index$1 = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ createDrawable: createDrawable,
+ createMotionPath: createMotionPath,
+ morphTo: morphTo
+ });
+
+
+
+ const segmenter = (typeof Intl !== 'undefined') && Intl.Segmenter;
+ const valueRgx = /\{value\}/g;
+ const indexRgx = /\{i\}/g;
+ const whiteSpaceGroupRgx = /(\s+)/;
+ const whiteSpaceRgx = /^\s+$/;
+ const lineType = 'line';
+ const wordType = 'word';
+ const charType = 'char';
+ const dataLine = `data-line`;
+
+ /**
+ * @typedef {Object} Segment
+ * @property {String} segment
+ * @property {Boolean} [isWordLike]
+ */
- set progress(progress) {
- this.forEach(anim => anim.currentTime = progress * this.duration || 0);
- }
+ /**
+ * @typedef {Object} Segmenter
+ * @property {function(String): Iterable<Segment>} segment
+ */
- resume() {
- if (!this.paused) return this;
- this.paused = false;
- // TODO: Store the current time, and seek back to the last position
- return this.forEach('play');
- }
+ /** @type {Segmenter} */
+ let wordSegmenter = null;
+ /** @type {Segmenter} */
+ let graphemeSegmenter = null;
+ let $splitTemplate = null;
- pause() {
- if (this.paused) return this;
- this.paused = true;
- return this.forEach('pause');
- }
+ /**
+ * @param {Segment} seg
+ * @return {Boolean}
+ */
+ const isSegmentWordLike = seg => {
+ return seg.isWordLike ||
+ seg.segment === ' ' || // Consider spaces as words first, then handle them diffrently later
+ isNum(+seg.segment); // Safari doesn't considers numbers as words
+ };
- alternate() {
- this.reversed = !this.reversed;
- this.forEach('reverse');
- if (this.paused) this.forEach('pause');
- return this;
- }
+ /**
+ * @param {HTMLElement} $el
+ */
+ const setAriaHidden = $el => $el.setAttribute('aria-hidden', 'true');
- play() {
- if (this.reversed) this.alternate();
- return this.resume();
- }
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} type
+ * @return {Array<HTMLElement>}
+ */
+ const getAllTopLevelElements = ($el, type) => [.../** @type {*} */($el.querySelectorAll(`[data-${type}]:not([data-${type}] [data-${type}])`))];
- reverse() {
- if (!this.reversed) this.alternate();
- return this.resume();
+ const debugColors = { line: '#00D672', word: '#FF4B4B', char: '#5A87FF' };
+
+ /**
+ * @param {HTMLElement} $el
+ */
+ const filterEmptyElements = $el => {
+ if (!$el.childElementCount && !$el.textContent.trim()) {
+ const $parent = $el.parentElement;
+ $el.remove();
+ if ($parent) filterEmptyElements($parent);
}
+ };
- /**
- * @param {Number} time
- * @param {Boolean} muteCallbacks
- */
- seek(time, muteCallbacks = false) {
- if (muteCallbacks) this.muteCallbacks = true;
- if (time < this.duration) this.completed = false;
- this.currentTime = time;
- this.muteCallbacks = false;
- if (this.paused) this.pause();
- return this;
+ /**
+ * @param {HTMLElement} $el
+ * @param {Number} lineIndex
+ * @param {Set<HTMLElement|Node>} bin
+ * @returns {Set<HTMLElement|Node>}
+ */
+ const filterLineElements = ($el, lineIndex, bin) => {
+ const dataLineAttr = $el.getAttribute(dataLine);
+ if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') {
+ bin.add($el);
+ // Also remove adjacent whitespace-only text nodes
+ const prev = $el.previousSibling;
+ const next = $el.nextSibling;
+ if (prev && prev.nodeType === 3 && whiteSpaceRgx.test(prev.textContent)) {
+ bin.add(prev);
+ }
+ if (next && next.nodeType === 3 && whiteSpaceRgx.test(next.textContent)) {
+ bin.add(next);
+ }
}
+ let i = $el.childElementCount;
+ while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
+ return bin;
+ };
- restart() {
- this.completed = false;
- return this.seek(0, true).resume();
+ /**
+ * @param {'line'|'word'|'char'} type
+ * @param {SplitTemplateParams} params
+ * @return {String}
+ */
+ const generateTemplate = (type, params = {}) => {
+ let template = ``;
+ const classString = isStr(params.class) ? ` class="${params.class}"` : '';
+ const cloneType = setValue(params.clone, false);
+ const wrapType = setValue(params.wrap, false);
+ const overflow = wrapType ? wrapType === true ? 'clip' : wrapType : cloneType ? 'clip' : false;
+ if (wrapType) template += `<span${overflow ? ` style="overflow:${overflow};"` : ''}>`;
+ template += `<span${classString}${cloneType ? ` style="position:relative;"` : ''} data-${type}="{i}">`;
+ if (cloneType) {
+ const left = cloneType === 'left' ? '-100%' : cloneType === 'right' ? '100%' : '0';
+ const top = cloneType === 'top' ? '-100%' : cloneType === 'bottom' ? '100%' : '0';
+ template += `<span>{value}</span>`;
+ template += `<span inert style="position:absolute;top:${top};left:${left};white-space:nowrap;">{value}</span>`;
+ } else {
+ template += `{value}`;
}
+ template += `</span>`;
+ if (wrapType) template += `</span>`;
+ return template;
+ };
- commitStyles() {
- return this.forEach('commitStyles');
+ /**
+ * @param {String|SplitFunctionValue} htmlTemplate
+ * @param {Array<HTMLElement>} store
+ * @param {Node|HTMLElement} node
+ * @param {DocumentFragment} $parentFragment
+ * @param {'line'|'word'|'char'} type
+ * @param {Boolean} debug
+ * @param {Number} lineIndex
+ * @param {Number} [wordIndex]
+ * @param {Number} [charIndex]
+ * @return {HTMLElement}
+ */
+ const processHTMLTemplate = (htmlTemplate, store, node, $parentFragment, type, debug, lineIndex, wordIndex, charIndex) => {
+ const isLine = type === lineType;
+ const isChar = type === charType;
+ const className = `_${type}_`;
+ const template = isFnc(htmlTemplate) ? htmlTemplate(node) : htmlTemplate;
+ const displayStyle = isLine ? 'block' : 'inline-block';
+ $splitTemplate.innerHTML = template
+ .replace(valueRgx, `<i class="${className}"></i>`)
+ .replace(indexRgx, `${isChar ? charIndex : isLine ? lineIndex : wordIndex}`);
+ const $content = $splitTemplate.content;
+ const $highestParent = /** @type {HTMLElement} */($content.firstElementChild);
+ const $split = /** @type {HTMLElement} */($content.querySelector(`[data-${type}]`)) || $highestParent;
+ const $replacables = /** @type {NodeListOf<HTMLElement>} */($content.querySelectorAll(`i.${className}`));
+ const replacablesLength = $replacables.length;
+ if (replacablesLength) {
+ $highestParent.style.display = displayStyle;
+ $split.style.display = displayStyle;
+ $split.setAttribute(dataLine, `${lineIndex}`);
+ if (!isLine) {
+ $split.setAttribute('data-word', `${wordIndex}`);
+ if (isChar) $split.setAttribute('data-char', `${charIndex}`);
+ }
+ let i = replacablesLength;
+ while (i--) {
+ const $replace = $replacables[i];
+ const $closestParent = $replace.parentElement;
+ $closestParent.style.display = displayStyle;
+ if (isLine) {
+ $closestParent.innerHTML = /** @type {HTMLElement} */(node).innerHTML;
+ } else {
+ $closestParent.replaceChild(node.cloneNode(true), $replace);
+ }
+ }
+ store.push($split);
+ $parentFragment.appendChild($content);
+ } else {
+ console.warn(`The expression "{value}" is missing from the provided template.`);
}
+ if (debug) $highestParent.style.outline = `1px dotted ${debugColors[type]}`;
+ return $highestParent;
+ };
- complete() {
- return this.seek(this.duration);
+ /**
+ * A class that splits text into words and wraps them in span elements while preserving the original HTML structure.
+ * @class
+ */
+ class TextSplitter {
+ /**
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ */
+ constructor(target, parameters = {}) {
+ // Only init segmenters when needed
+ if (!wordSegmenter) wordSegmenter = segmenter ? new segmenter([], { granularity: wordType }) : {
+ segment: (text) => {
+ const segments = [];
+ const words = text.split(whiteSpaceGroupRgx);
+ for (let i = 0, l = words.length; i < l; i++) {
+ const segment = words[i];
+ segments.push({
+ segment,
+ isWordLike: !whiteSpaceRgx.test(segment), // Consider non-whitespace as word-like
+ });
+ }
+ return segments;
+ }
+ };
+ if (!graphemeSegmenter) graphemeSegmenter = segmenter ? new segmenter([], { granularity: 'grapheme' }) : {
+ segment: text => [...text].map(char => ({ segment: char }))
+ };
+ if (!$splitTemplate && isBrowser) $splitTemplate = doc.createElement('template');
+ if (scope.current) scope.current.register(this);
+ const { words, chars, lines, accessible, includeSpaces, debug } = parameters;
+ const $target = /** @type {HTMLElement} */((target = isArr(target) ? target[0] : target) && /** @type {Node} */(target).nodeType ? target : (getNodeList(target) || [])[0]);
+ const lineParams = lines === true ? {} : lines;
+ const wordParams = words === true || isUnd(words) ? {} : words;
+ const charParams = chars === true ? {} : chars;
+ this.debug = setValue(debug, false);
+ this.includeSpaces = setValue(includeSpaces, false);
+ this.accessible = setValue(accessible, true);
+ this.linesOnly = lineParams && (!wordParams && !charParams);
+ /** @type {String|false|SplitFunctionValue} */
+ this.lineTemplate = isObj(lineParams) ? generateTemplate(lineType, /** @type {SplitTemplateParams} */(lineParams)) : lineParams;
+ /** @type {String|false|SplitFunctionValue} */
+ this.wordTemplate = isObj(wordParams) || this.linesOnly ? generateTemplate(wordType, /** @type {SplitTemplateParams} */(wordParams)) : wordParams;
+ /** @type {String|false|SplitFunctionValue} */
+ this.charTemplate = isObj(charParams) ? generateTemplate(charType, /** @type {SplitTemplateParams} */(charParams)) : charParams;
+ this.$target = $target;
+ this.html = $target && $target.innerHTML;
+ this.lines = [];
+ this.words = [];
+ this.chars = [];
+ this.effects = [];
+ this.effectsCleanups = [];
+ this.cache = null;
+ this.ready = false;
+ this.width = 0;
+ this.resizeTimeout = null;
+ const handleSplit = () => this.html && (lineParams || wordParams || charParams) && this.split();
+ // Make sure this is declared before calling handleSplit() in case revert() is called inside an effect callback
+ this.resizeObserver = new ResizeObserver(() => {
+ // Use a setTimeout instead of a Timer for better tree shaking
+ clearTimeout(this.resizeTimeout);
+ this.resizeTimeout = setTimeout(() => {
+ const currentWidth = /** @type {HTMLElement} */($target).offsetWidth;
+ if (currentWidth === this.width) return;
+ this.width = currentWidth;
+ handleSplit();
+ }, 150);
+ });
+ // Only declare the font ready promise when splitting by lines and not alreay split
+ if (this.lineTemplate && !this.ready) {
+ doc.fonts.ready.then(handleSplit);
+ } else {
+ handleSplit();
+ }
+ $target ? this.resizeObserver.observe($target) : console.warn('No Text Splitter target found.');
}
- cancel() {
- this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
- return this.commitStyles().forEach('cancel');
+ /**
+ * @param {(...args: any[]) => Tickable | (() => void)} effect
+ * @return this
+ */
+ addEffect(effect) {
+ if (!isFnc(effect)) return console.warn('Effect must return a function.');
+ const refreshableEffect = keepTime(effect);
+ this.effects.push(refreshableEffect);
+ if (this.ready) this.effectsCleanups[this.effects.length - 1] = refreshableEffect(this);
+ return this;
}
revert() {
- // NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
- // This means if you have multiple animations animating different transforms on the same target,
- // reverting one of them will also override the transform property of the other animations.
- // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
- // and update the CSS variables with the orignal value
- this.cancel().targets.forEach(($el, i) => {
- const targetStyle = $el.style;
- const targetInlineStyles = this._inlineStyles[i];
- for (let name in targetInlineStyles) {
- const originalInlinedValue = targetInlineStyles[name];
- if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
- targetStyle.removeProperty(toLowerCase(name));
- } else {
- targetStyle[name] = originalInlinedValue;
- }
- }
- // Remove style attribute if empty
- if ($el.getAttribute('style') === emptyString) $el.removeAttribute('style');
- });
+ clearTimeout(this.resizeTimeout);
+ this.lines.length = this.words.length = this.chars.length = 0;
+ this.resizeObserver.disconnect();
+ // Make sure to revert the effects after disconnecting the resizeObserver to avoid triggering it in the process
+ this.effectsCleanups.forEach(cleanup => isFnc(cleanup) ? cleanup(this) : cleanup.revert && cleanup.revert());
+ this.$target.innerHTML = this.html;
return this;
}
/**
- * @typedef {this & {then: null}} ResolvedWAAPIAnimation
+ * Recursively processes a node and its children
+ * @param {Node} node
*/
+ splitNode(node) {
+ const wordTemplate = this.wordTemplate;
+ const charTemplate = this.charTemplate;
+ const includeSpaces = this.includeSpaces;
+ const debug = this.debug;
+ const nodeType = node.nodeType;
+ if (nodeType === 3) {
+ const nodeText = node.nodeValue;
+ // If the nodeText is only whitespace, leave it as is
+ if (nodeText.trim()) {
+ const tempWords = [];
+ const words = this.words;
+ const chars = this.chars;
+ const wordSegments = wordSegmenter.segment(nodeText);
+ const $wordsFragment = doc.createDocumentFragment();
+ let prevSeg = null;
+ for (const wordSegment of wordSegments) {
+ const segment = wordSegment.segment;
+ const isWordLike = isSegmentWordLike(wordSegment);
+ // Determine if this segment should be a new word, first segment always becomes a new word
+ if (!prevSeg || (isWordLike && (prevSeg && (isSegmentWordLike(prevSeg))))) {
+ tempWords.push(segment);
+ } else {
+ // Only concatenate if both current and previous are non-word-like and don't contain spaces
+ const lastWordIndex = tempWords.length - 1;
+ const lastWord = tempWords[lastWordIndex];
+ if (!whiteSpaceGroupRgx.test(lastWord) && !whiteSpaceGroupRgx.test(segment)) {
+ tempWords[lastWordIndex] += segment;
+ } else {
+ tempWords.push(segment);
+ }
+ }
+ prevSeg = wordSegment;
+ }
+
+ for (let i = 0, l = tempWords.length; i < l; i++) {
+ const word = tempWords[i];
+ if (!word.trim()) {
+ // Preserve whitespace only if includeSpaces is false and if the current space is not the first node
+ if (i && includeSpaces) continue;
+ $wordsFragment.appendChild(doc.createTextNode(word));
+ } else {
+ const nextWord = tempWords[i + 1];
+ const hasWordFollowingSpace = includeSpaces && nextWord && !nextWord.trim();
+ const wordToProcess = word;
+ const charSegments = charTemplate ? graphemeSegmenter.segment(wordToProcess) : null;
+ const $charsFragment = charTemplate ? doc.createDocumentFragment() : doc.createTextNode(hasWordFollowingSpace ? word + '\xa0' : word);
+ if (charTemplate) {
+ const charSegmentsArray = [...charSegments];
+ for (let j = 0, jl = charSegmentsArray.length; j < jl; j++) {
+ const charSegment = charSegmentsArray[j];
+ const isLastChar = j === jl - 1;
+ // If this is the last character and includeSpaces is true with a following space, append the space
+ const charText = isLastChar && hasWordFollowingSpace ? charSegment.segment + '\xa0' : charSegment.segment;
+ const $charNode = doc.createTextNode(charText);
+ processHTMLTemplate(charTemplate, chars, $charNode, /** @type {DocumentFragment} */($charsFragment), charType, debug, -1, words.length, chars.length);
+ }
+ }
+ if (wordTemplate) {
+ processHTMLTemplate(wordTemplate, words, $charsFragment, $wordsFragment, wordType, debug, -1, words.length, chars.length);
+ // Chars elements must be re-parsed in the split() method if both words and chars are parsed
+ } else if (charTemplate) {
+ $wordsFragment.appendChild($charsFragment);
+ } else {
+ $wordsFragment.appendChild(doc.createTextNode(word));
+ }
+ // Skip the next iteration if we included a space
+ if (hasWordFollowingSpace) i++;
+ }
+ }
+ node.parentNode.replaceChild($wordsFragment, node);
+ }
+ } else if (nodeType === 1) {
+ // Converting to an array is necessary to work around childNodes pottential mutation
+ const childNodes = /** @type {Array<Node>} */([.../** @type {*} */(node.childNodes)]);
+ for (let i = 0, l = childNodes.length; i < l; i++) this.splitNode(childNodes[i]);
+ }
+ }
/**
- * @param {Callback<ResolvedWAAPIAnimation>} [callback]
- * @return Promise<this>
+ * @param {Boolean} clearCache
+ * @return {this}
*/
- then(callback = noop) {
- const then = this.then;
- const onResolve = () => {
- this.then = null;
- callback(/** @type {ResolvedWAAPIAnimation} */(this));
- this.then = then;
- this._resolve = noop;
- };
- return new Promise(r => {
- this._resolve = () => r(onResolve());
- if (this.completed) this._resolve();
- return this;
- });
+ split(clearCache = false) {
+ const $el = this.$target;
+ const isCached = !!this.cache && !clearCache;
+ const lineTemplate = this.lineTemplate;
+ const wordTemplate = this.wordTemplate;
+ const charTemplate = this.charTemplate;
+ const fontsReady = doc.fonts.status !== 'loading';
+ const canSplitLines = lineTemplate && fontsReady;
+ this.ready = !lineTemplate || fontsReady;
+ if (canSplitLines || clearCache) {
+ // No need to revert effects animations here since it's already taken care by the refreshable
+ this.effectsCleanups.forEach(cleanup => isFnc(cleanup) && cleanup(this));
+ }
+ if (!isCached) {
+ if (clearCache) {
+ $el.innerHTML = this.html;
+ this.words.length = this.chars.length = 0;
+ }
+ this.splitNode($el);
+ this.cache = $el.innerHTML;
+ }
+ if (canSplitLines) {
+ if (isCached) $el.innerHTML = this.cache;
+ this.lines.length = 0;
+ if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
+ }
+ // Always reparse characters after a line reset or if both words and chars are activated
+ if (charTemplate && (canSplitLines || wordTemplate)) {
+ this.chars = getAllTopLevelElements($el, charType);
+ }
+ // Words are used when lines only and prioritized over chars
+ const elementsArray = this.words.length ? this.words : this.chars;
+ let y, linesCount = 0;
+ for (let i = 0, l = elementsArray.length; i < l; i++) {
+ const $el = elementsArray[i];
+ const { top, height } = $el.getBoundingClientRect();
+ if (!isUnd(y) && top - y > height * .5) linesCount++;
+ $el.setAttribute(dataLine, `${linesCount}`);
+ const nested = $el.querySelectorAll(`[${dataLine}]`);
+ let c = nested.length;
+ while (c--) nested[c].setAttribute(dataLine, `${linesCount}`);
+ y = top;
+ }
+ if (canSplitLines) {
+ const linesFragment = doc.createDocumentFragment();
+ const parents = new Set();
+ const clones = [];
+ for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
+ const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
+ filterLineElements($clone, lineIndex, new Set()).forEach($el => {
+ const $parent = $el.parentNode;
+ if ($parent) {
+ if ($el.nodeType === 1) parents.add(/** @type {HTMLElement} */($parent));
+ $parent.removeChild($el);
+ }
+ });
+ clones.push($clone);
+ }
+ parents.forEach(filterEmptyElements);
+ for (let cloneIndex = 0, clonesLength = clones.length; cloneIndex < clonesLength; cloneIndex++) {
+ processHTMLTemplate(lineTemplate, this.lines, clones[cloneIndex], linesFragment, lineType, this.debug, cloneIndex);
+ }
+ $el.innerHTML = '';
+ $el.appendChild(linesFragment);
+ if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
+ if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
+ }
+
+ // Remove the word wrappers and clear the words array if lines split only
+ if (this.linesOnly) {
+ const words = this.words;
+ let w = words.length;
+ while (w--) {
+ const $word = words[w];
+ $word.replaceWith($word.textContent);
+ }
+ words.length = 0;
+ }
+ if (this.accessible && (canSplitLines || !isCached)) {
+ const $accessible = doc.createElement('span');
+ // Make the accessible element visually-hidden (https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html)
+ $accessible.style.cssText = `position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;`;
+ // $accessible.setAttribute('tabindex', '-1');
+ $accessible.innerHTML = this.html;
+ $el.insertBefore($accessible, $el.firstChild);
+ this.lines.forEach(setAriaHidden);
+ this.words.forEach(setAriaHidden);
+ this.chars.forEach(setAriaHidden);
+ }
+ this.width = /** @type {HTMLElement} */($el).offsetWidth;
+ if (canSplitLines || clearCache) {
+ this.effects.forEach((effect, i) => this.effectsCleanups[i] = effect(this));
+ }
+ return this;
+ }
+
+ refresh() {
+ this.split(true);
}
}
- const waapi = {
/**
- * @param {DOMTargetsParam} targets
- * @param {WAAPIAnimationParams} params
- * @return {WAAPIAnimation}
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ * @return {TextSplitter}
*/
- animate: (targets, params) => new WAAPIAnimation(targets, params),
- convertEase: easingToLinear
+ const splitText = (target, parameters) => new TextSplitter(target, parameters);
+
+ /**
+ * @deprecated text.split() is deprecated, import splitText() directly, or text.splitText()
+ *
+ * @param {HTMLElement|NodeList|String|Array<HTMLElement>} target
+ * @param {TextSplitterParams} [parameters]
+ * @return {TextSplitter}
+ */
+ const split = (target, parameters) => {
+ console.warn('text.split() is deprecated, import splitText() directly, or text.splitText()');
+ return new TextSplitter(target, parameters);
};
+ var index = /*#__PURE__*/Object.freeze({
+ __proto__: null,
+ TextSplitter: TextSplitter,
+ split: split,
+ splitText: splitText
+ });
+
exports.$ = registerTargets;
exports.Animatable = Animatable;
+ exports.AutoLayout = AutoLayout;
exports.Draggable = Draggable;
exports.JSAnimation = JSAnimation;
exports.Scope = Scope;
@@ -8817,6 +10220,7 @@
exports.createAnimatable = createAnimatable;
exports.createDraggable = createDraggable;
exports.createDrawable = createDrawable;
+ exports.createLayout = createLayout;
exports.createMotionPath = createMotionPath;
exports.createScope = createScope;
exports.createSeededRandom = createSeededRandom;
diff --git a/dist/bundles/anime.umd.min.js b/dist/bundles/anime.umd.min.js
index 904bcc5b..7d414a42 100644
--- a/dist/bundles/anime.umd.min.js
+++ b/dist/bundles/anime.umd.min.js
@@ -1,7 +1,7 @@
/**
* Anime.js - UMD minified bundle
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),h=Symbol(),l=Symbol(),c=Symbol(),d=1e-11,u=1e12,p=1e3,m="",f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],y=g.reduce((t,e)=>({...t,[e]:e+"("}),{}),_=()=>{},v=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,b=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,S=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,w=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,T=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,k=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,$=/([a-z])([A-Z])/g,C=/(\w+)(\([^)]+\)+)/g,E=/(\*=|\+=|-=)/,D=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,B={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:120,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:p,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:_,onBeforeUpdate:_,onUpdate:_,onLoop:_,onPause:_,onComplete:_,onRender:_},L={current:null,root:i},N={defaults:B,precision:4,timeScale:1,tickThreshold:200},A={version:"4.2.2",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(A));const F=t=>t.replace($,"$1-$2").toLowerCase(),P=(t,e)=>0===t.indexOf(e),O=Date.now,R=Array.isArray,M=t=>t&&t.constructor===Object,z=t=>"number"==typeof t&&!isNaN(t),I=t=>"string"==typeof t,Y=t=>"function"==typeof t,X=t=>void 0===t,V=t=>X(t)||null===t,W=t=>e&&t instanceof SVGElement,H=t=>v.test(t),U=t=>P(t,"rgb"),q=t=>P(t,"hsl"),j=t=>!N.defaults.hasOwnProperty(t),G=["opacity","rotate","overflow","color"],Q=t=>I(t)?parseFloat(t):t,Z=Math.pow,J=Math.sqrt,K=Math.sin,tt=Math.cos,et=Math.abs,st=Math.exp,it=Math.ceil,rt=Math.floor,nt=Math.asin,ot=Math.max,at=Math.atan2,ht=Math.PI,lt=Math.round,ct=(t,e,s)=>t<e?e:t>s?s:t,dt={},ut=(t,e)=>{if(e<0)return t;if(!e)return lt(t);let s=dt[e];return s||(s=dt[e]=10**e),lt(t*s)/s},pt=(t,e)=>R(e)?e.reduce((e,s)=>et(s-t)<et(e-t)?s:e):e?lt(t/e)*e:t,mt=(t,e,s)=>t+(e-t)*s,ft=t=>t===1/0?u:t===-1/0?-u:t,gt=t=>t<=d?d:ft(ut(t,11)),yt=t=>R(t)?[...t]:t,_t=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=X(r)?e[i]:r}return s},vt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},bt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},St=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},wt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),Tt=(t,e)=>X(t)?e:t,xt=(t,e,s,i,r)=>{let n;if(Y(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!I(t)||!P(t,"var("))return t;n=()=>{const s=t.match(D),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==m||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},kt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(G.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:P(e,"--")?4:e in t.style?2:e in t?0:1:0,$t=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[c]||t).getPropertyValue(e);return"auto"===r?"0":r},Ct=(t,e,s,i)=>{const r=X(s)?kt(t,e):s;return 0===r?t[e]||0:1===r?t.getAttribute(e):3===r?((t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[h];let o;for(;o=C.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!X(r)?r:P(e,"scale")?"1":P(e,"rotate")||P(e,"skew")?"0deg":"0px"})(t,e,i):4===r?$t(t,e,i).trimStart():$t(t,e,i)},Et=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Dt=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&k.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(H(r=s)||U(r)||q(r))return e.t=2,e.d=U(i=s)?(t=>{const e=b.exec(t)||S.exec(t),s=X(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):H(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):q(i)?(t=>{const e=w.exec(t)||T.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=X(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=ut(255*wt(e,t,s+1/3),0),a=ut(255*wt(e,t,s),0),h=ut(255*wt(e,t,s-1/3),0)}return[o,a,h,n]})(i):[0,0,0,1],e;{const t=s.match(x);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(x)||[],e}}var i,r;return e.n=s,e},Bt=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=yt(t._toNumbers),e.s=yt(t._strings),e),Lt={t:0,n:0,u:null,o:null,d:null,s:null},Nt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,l=t.completed,c=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,f=t._loopDelay,g=t._reversed,_=t._alternate,v=t._hasChildren,b=t._delay,S=t._currentTime,w=b+c,T=e-b,x=ct(S,-b,a),k=ct(T,-b,a),$=T-S,C=k>0,E=k>=a,D=a<=d,B=2===n;let L=0,A=T,F=0;if(u>1){const e=~~(k/(c+(E?0:f)));t._currentIteration=ct(e,0,u),E&&t._currentIteration--,L=t._currentIteration%2,A=k%(c+f)||0}const P=g^(_&&L),O=t._ease;let R=E?P?0:a:P?c-A:A;O&&(R=c*O(R/c)||0);const M=(o?o.backwards:T<S)?!P:!!P;if(t._currentTime=T,t._iterationTime=R,t.backwards=M,C&&!t.began?(t.began=!0,s||o&&(M||!o.began)||t.onBegin(t)):T<=0&&(t.began=!1),s||v||!C||t._currentIteration===p||t.onLoop(t),B||1===n&&(e>=b&&e<=w||e<=b&&x>b||e>=w&&x!==a)||R>=w&&x!==a||R<=b&&x>0||e<=x&&x===a&&l||E&&!l&&D){if(C&&(t.computeDeltaTime(x),s||t.onBeforeUpdate(t)),!v){const e=B||(M?-1*$:$)>=N.tickThreshold,n=t._offset+(o?o._offset:0)+b+R;let a,l,c,d,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,f=u._absoluteStartTime+u._changeDuration,g=u._nextRep,_=u._prevRep,v=t!==r.none;if((e||(s!==o||n<=f+(g?g._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!v||!u._isOverridden&&(!u._isOverlapped||n<=f)&&(!g||g._isOverridden||n<=g._absoluteStartTime)&&(!_||_._isOverridden||n>=_._absoluteStartTime+_._changeDuration+u._delay))){const e=u._currentTime=ct(R-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,y=0===m,_=y&&g||0===s||1===s?-1:N.precision;let b,S;if(y)b=S=n(ut(mt(u._fromNumber,u._toNumber,s),_));else if(1===m)S=n(ut(mt(u._fromNumber,u._toNumber,s),_)),b=`${S}${u._unit}`;else if(2===m){const t=u._fromNumbers,e=u._toNumbers,i=ut(ct(n(mt(t[0],e[0],s)),0,255),0),r=ut(ct(n(mt(t[1],e[1],s)),0,255),0),o=ut(ct(n(mt(t[2],e[2],s)),0,255),0),a=ct(n(ut(mt(t[3],e[3],s),_)),0,1);if(b=`rgba(${i},${r},${o},${a})`,v){const t=u._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(3===m){b=u._strings[0];for(let t=0,e=u._toNumbers.length;t<e;t++){const e=n(ut(mt(u._fromNumbers[t],u._toNumbers[t],s),_)),i=u._strings[t+1];b+=`${i?e+i:e}`,v&&(u._numbers[t]=e)}}if(v&&(u._number=S),i||t===r.blend)u._value=b;else{const t=u.property;a=u.target,g?a[t]=b:1===f?a.setAttribute(t,b):(l=a.style,3===f?(a!==c&&(c=a,d=a[h]),d[t]=b,p=1):2===f?l[t]=b:4===f&&l.setProperty(t,b)),C&&(F=1)}}if(p&&u._renderTransforms){let t=m;for(let e in d)t+=`${y[e]}${d[e]}) `;l.transform=t,p=0}u=u._next}!s&&F&&t.onRender(t)}!s&&C&&t.onUpdate(t)}return o&&D?!s&&(o.began&&!M&&T>0&&!l||M&&T<=d&&l)&&(t.onComplete(t),t.completed=!M):C&&E?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,l||v||(t.completed=!0,s||o&&(M||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,F},At=(t,e,s,i,r)=>{const n=t._currentIteration;if(Nt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,h=i?e:o._iterationTime,l=O();let c=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;vt(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=d)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Nt(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}vt(o,t=>{const e=ut((h-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(l):r;c+=Nt(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&c&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Ft={},Pt=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&W(e)&&t in e.style){const e=Ft[t];if(e)return e;{const e=t?F(t):t;return Ft[t]=e,e}}return t},Ot=t=>{if(t._hasChildren)vt(t,Ot,!0);else{const e=t;e.pause(),vt(e,t=>{const s=t.property,i=t.target;if(i[o]){const r=i.style,n=t._inlineValue,o=V(n)||n===m;if(3===t._tweenType){const e=i[h];if(o?delete e[s]:e[s]=n,t._renderTransforms)if(Object.keys(e).length){let t=m;for(let s in e)t+=y[s]+e[s]+") ";r.transform=t}else r.removeProperty("transform")}else o?r.removeProperty(F(s)):r[s]=n;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===m&&t.removeAttribute("style")})}})}return t};class Rt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._elapsedTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=ut(p/120,0),this._fps=120,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<d?d:s,r=ut(p/i,0);this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<d?d:e}requestTick(t){const e=this._scheduledTime,s=this._elapsedTime;if(this._elapsedTime+=t-s,s<e)return 0;const i=this._frameDuration,r=s-e;return this._scheduledTime+=r<i?i:r,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Mt={animation:null,update:_},zt=(()=>e?requestAnimationFrame:setImmediate)(),It=(()=>e?cancelAnimationFrame:clearImmediate)();class Yt extends Rt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=B,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=O();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(bt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):At(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Mt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(O()),this.reqId=zt(Vt)),this}pause(){if(this.reqId)return this.paused=!0,Wt()}resume(){if(this.paused)return this.paused=!1,vt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===N.timeScale?1:p)}set speed(t){this._speed=t*N.timeScale,vt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===N.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(N.timeScale!==s){N.timeScale=s,N.tickThreshold=200*s;const t=e?.001:p;this.defaults.duration*=t,this._speed*=t}}get precision(){return N.precision}set precision(t){N.precision=t}}const Xt=(()=>{const t=new Yt(O());return e&&(A.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),Vt=()=>{Xt._head?(Xt.reqId=zt(Vt),Xt.update()):Xt.reqId=0},Wt=()=>(It(Xt.reqId),Xt.reqId=0,Xt),Ht={_rep:new WeakMap,_add:new Map},Ut=(t,e,s="_rep")=>{const i=Ht[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},qt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,jt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=d,t._currentTime=d},Gt=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;St(e,t,qt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){jt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)jt(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=ut(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<d&&jt(i)}let o=!0;if(vt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;vt(t,t=>{t!==e&&vt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=Ut(t.target,t.property,"_add"),s=(t=>{let e=Mt.animation;return e||(e={duration:d,computeDeltaTime:_,_offset:0,_delay:0,_head:null,_tail:null},Mt.animation=e,Mt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?yt(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),Nt(e,1,1,0,2)}),e})(Ht._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=d,i._startTime=0,i._numbers=yt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,St(e,i),St(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=yt(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=yt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}St(e,t,null,"_prevAdd","_nextAdd")}return t},Qt=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Ht._rep.get(s)[i];if(bt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Ht._add,r=e.get(s);if(!r)return;const n=r[i],o=Mt.animation;bt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){bt(n,a,"_prevAdd","_nextAdd"),bt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},Zt=(t,e,s)=>{let i=!1;return vt(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Pt(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),bt(e,r),Qt(r),i=!0)}},!0),i},Jt=(t,e,s)=>{const i=e||Xt;let r;if(i._hasChildren){let e=0;vt(i,n=>{if(!n._hasChildren)if(r=Zt(t,n,s),r&&!n._head)n.cancel(),bt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?Jt(t,n,s):n._hasChildren=!1},!0),X(i.iterationDuration)||(i.iterationDuration=e)}else r=Zt(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},Kt=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),te=t=>t._cancelled?(t._hasChildren?vt(t,te):vt(t,t=>{t._composition!==r.none&&Gt(t,Ut(t.target,t.property))}),t._cancelled=0,t):t;let ee=0;class se extends Rt{constructor(t={},e=null,s=0){super(0);const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:c,frameRate:u,playbackRate:p,onComplete:m,onLoop:f,onPause:g,onBegin:y,onBeforeUpdate:v,onUpdate:b}=t;L.current&&L.current.register(this);const S=e?0:Xt._elapsedTime,w=e?e.defaults:N.defaults,T=Y(r)||X(r)?w.delay:+r,x=Y(n)||X(n)?1/0:+n,k=Tt(h,w.loop),$=Tt(l,w.loopDelay),C=!0===k||k===1/0||k<0?1/0:k+1;let E=0;e?E=s:(Xt.reqId||Xt.requestTick(O()),E=(Xt._elapsedTime-Xt._startTime)*N.timeScale),this.id=X(i)?++ee:i,this.parent=e,this.duration=ft((x+$)*C-$)||d,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=y||w.onBegin,this.onBeforeUpdate=v||w.onBeforeUpdate,this.onUpdate=b||w.onUpdate,this.onLoop=f||w.onLoop,this.onPause=g||w.onPause,this.onComplete=m||w.onComplete,this.iterationDuration=x,this.iterationCount=C,this._autoplay=!e&&Tt(c,w.autoplay),this._offset=E,this._delay=T,this._loopDelay=$,this._iterationTime=0,this._currentIteration=0,this._resolve=_,this._running=!1,this._reversed=+Tt(o,w.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=Tt(a,w.alternate),this._prev=null,this._next=null,this._elapsedTime=S,this._startTime=S,this._lastTime=S,this._fps=Tt(u,w.frameRate),this._speed=Tt(p,w.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return ct(ut(this._currentTime,N.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ut(this._iterationTime,N.precision)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ct(ut(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ct(ut(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ct(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return te(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,At(this,0,1,~~t,2),Kt(this),this._hasChildren&&vt(this,Kt),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&At(this,this.duration,1,~~t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!X(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Xt._speed);return this._startTime=O()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=d&&!this._hasChildren?At(this,d,0,0,2):(this._running||(St(Xt,this),Xt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Xt.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){te(this),this.completed=!1;const i=this.paused;return this.paused=!0,At(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?rt(u/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?vt(this,t=>t.cancel(),!0):vt(this,Qt),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=gt(t);if(e===s)return this;const i=t/e,r=t<=d;return this.duration=r?d:s,this.iterationDuration=r?d:gt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){At(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function ie(t){const e=I(t)?L.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function re(t){if(V(t))return[];if(!e)return R(t)&&t.flat(1/0)||[t];if(R(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!V(i)){const t=ie(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!V(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=ie(t);return s?Array.from(s):[t]}function ne(t){const e=re(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=W(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[h]={})}}return e}const oe={deg:1,rad:180/ht,turn:360},ae={},he=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,h=ae[a];if(X(h)||r){let r;if(n in oe)r=o*oe[n]/oe[s];else{const e=100,a=t.cloneNode(),h=t.parentNode,l=h&&h!==i?h:i.body;l.appendChild(a);const c=a.style;c.width=e+n;const d=a.offsetWidth||e;c.width=e+s;const u=d/(a.offsetWidth||e);l.removeChild(a),r=u*o}e.n=r,ae[a]=r}else e.n=h;return e.t,e.u=s,e},le=t=>t,ce=(t=1.68)=>e=>Z(e,+t),de={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},ue=ht/2,pe=2*ht,me={[m]:ce,Quad:ce(2),Cubic:ce(3),Quart:ce(4),Quint:ce(5),Sine:t=>1-tt(t*ue),Circ:t=>1-J(1-t*t),Expo:t=>t?Z(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=Z(2,--s))-1)/11;);return 1/Z(4,3-s)-7.5625*Z((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ct(+t,1,10),i=ct(+e,d,2),r=i/pe*nt(1/s),n=pe/i;return t=>0===t||1===t?t:-s*Z(2,-10*(1-t))*K((1-t-r)*n)}},fe=(()=>{const t={linear:le,none:le};for(let e in de)for(let s in me){const i=me[s],r=de[e];t[e+s]=s===m||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),ge={linear:le,none:le},ye=t=>{if(ge[t])return ge[t];if(t.indexOf("(")<=-1){const e=de[t]||t.includes("Back")||t.includes("Elastic")?fe[t]():fe[t];return e?ge[t]=e:le}{const e=t.slice(0,-1).split("("),s=fe[e[0]];return s?ge[t]=s(...e[1].split(",")):le}},_e=["steps(","irregular(","linear(","cubicBezier("],ve=t=>{if(I(t))for(let e=0,s=_e.length;e<s;e++)if(P(t,_e[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),le;return Y(t)?t:I(t)?ye(t):le},be={t:0,n:0,u:null,o:null,d:null,s:null},Se={t:0,n:0,u:null,o:null,d:null,s:null},we={},Te={func:null},xe=[null],ke=[null,null],$e={to:null};let Ce,Ee,De=0;class Be extends se{constructor(t,e,s,i,n=!1,o=0,a=0){super(e,s,i);const h=ne(t),l=h.length,c=e.keyframes,u=c?_t(((t,e)=>{const s={};if(R(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(j);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];j(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=Tt(e.duration,N.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(j(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let c=0;for(let t=0;t<a;t++)c+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?c:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(c,e),e):e,{delay:m,duration:f,ease:g,playbackEase:y,modifier:_,composition:v,onRender:b}=u,S=s?s.defaults:N.defaults,w=Tt(y,S.playbackEase),T=w?ve(w):null,x=!X(g)&&!X(g.ease),k=x?g.ease:Tt(g,T?"linear":S.ease),$=x?g.settlingDuration:Tt(f,S.duration),C=Tt(m,S.delay),E=_||S.modifier,D=X(v)&&l>=p?r.none:X(v)?S.composition:v,B=this._offset+(s?s._offset:0);x&&(g.parent=this);let L=NaN,A=NaN,F=0,P=0;for(let t=0;t<l;t++){const e=h[t],i=o||t,c=a||l;let p=NaN,m=NaN;for(let t in u)if(j(t)){const o=kt(e,t),a=Pt(t,e,o);let h=u[t];const l=R(h);if(n&&!l&&(ke[0]=h,ke[1]=h,h=ke),l){const t=h.length,e=!M(h[0]);2===t&&e?($e.to=h,xe[0]=$e,Ce=xe):t>2&&e?(Ce=[],h.forEach((t,e)=>{e?1===e?(ke[1]=t,Ce.push(ke)):Ce.push(t):ke[0]=t})):Ce=h}else xe[0]=h,Ce=xe;let f=null,g=null,y=NaN,_=0,v=0;for(let t=Ce.length;v<t;v++){const n=Ce[v];M(n)?Ee=n:($e.to=n,Ee=$e),Te.func=null;const h=xt(Ee.to,e,i,c,Te);let l;M(h)&&!X(h.to)?(Ee=h,l=h.to):l=h;const u=xt(Ee.from,e,i,c),p=Ee.ease,m=!X(p)&&!X(p.ease),b=m?p.ease:p||k,S=m?p.settlingDuration:xt(Tt(Ee.duration,t>1?xt($,e,i,c)/t:$),e,i,c),w=xt(Tt(Ee.delay,v?0:C),e,i,c),T=xt(Tt(Ee.composition,D),e,i,c),x=z(T)?T:r[T],L=Ee.modifier||E,N=!X(u),A=!X(l),O=R(l),I=O||N&&A,Y=g?_+w:w,W=ut(B+Y,12);P||!N&&!O||(P=1);let H=g;if(x!==r.none){f||(f=Ut(e,a));let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=W;)if(H=t,t=t._nextRep,t&&t._absoluteStartTime>=W)for(;t;)jt(t),t=t._nextRep}if(I?(Dt(O?xt(l[0],e,i,c):u,be),Dt(O?xt(l[1],e,i,c,Te):l,Se),0===be.t&&(H?1===H._valueType&&(be.t=1,be.u=H._unit):(Dt(Ct(e,a,o,we),Lt),1===Lt.t&&(be.t=1,be.u=Lt.u)))):(A?Dt(l,Se):g?Bt(g,Se):Dt(s&&H&&H.parent.parent===s?H._value:Ct(e,a,o,we),Se),N?Dt(u,be):g?Bt(g,be):Dt(s&&H&&H.parent.parent===s?H._value:Ct(e,a,o,we),be)),be.o&&(be.n=Et(H?H._toNumber:Dt(Ct(e,a,o,we),Lt).n,be.n,be.o)),Se.o&&(Se.n=Et(be.n,Se.n,Se.o)),be.t!==Se.t)if(3===be.t||3===Se.t){const t=3===be.t?be:Se,e=3===be.t?Se:be;e.t=3,e.s=yt(t.s),e.d=t.d.map(()=>e.n)}else if(1===be.t||1===Se.t){const t=1===be.t?be:Se,e=1===be.t?Se:be;e.t=1,e.u=t.u}else if(2===be.t||2===Se.t){const t=2===be.t?be:Se,e=2===be.t?Se:be;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(be.u!==Se.u){let t=Se.u?be:Se;t=he(e,t,Se.u?Se.u:be.u,!1)}if(Se.d&&be.d&&Se.d.length!==be.d.length){const t=be.d.length>Se.d.length?be:Se,e=t===be?Se:be;e.d=t.d.map((t,s)=>X(e.d[s])?0:e.d[s]),e.s=yt(t.s)}const U=ut(+S||d,12);let q=we[a];V(q)||(we[a]=null);const j={parent:this,id:De++,property:a,target:e,_value:null,_func:Te.func,_ease:ve(b),_fromNumbers:yt(be.d),_toNumbers:yt(Se.d),_strings:yt(Se.s),_fromNumber:be.n,_toNumber:Se.n,_numbers:yt(be.d),_number:be.n,_unit:Se.u,_modifier:L,_currentTime:0,_startTime:Y,_delay:+w,_updateDuration:U,_changeDuration:U,_absoluteStartTime:W,_tweenType:o,_valueType:Se.t,_composition:x,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:q,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};x!==r.none&&Gt(j,f),isNaN(y)&&(y=j._startTime),_=ut(Y+U,12),g=j,F++,St(this,j)}(isNaN(A)||y<A)&&(A=y),(isNaN(L)||_>L)&&(L=_),3===o&&(p=F-v,m=F)}if(!isNaN(p)){let t=0;vt(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===r.blend&&vt(Mt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),A?(vt(this,t=>{t._startTime-t._delay||(t._delay-=A),t._startTime-=A}),L-=A):A=0,L||(L=d,this.iterationCount=0),this.targets=h,this.duration=L===d?d:ft((L+this._loopDelay)*this.iterationCount-this._loopDelay)||d,this.onRender=b||S.onRender,this._ease=T,this._delay=A,this.iterationDuration=L,!this._autoplay&&P&&this.onRender(this)}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e;return vt(this,t=>{t._updateDuration=gt(t._updateDuration*s),t._changeDuration=gt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return vt(this,t=>{const e=t._func;if(e){const s=Ct(t.target,t.property,t._tweenType);Dt(s,Lt),Dt(e(),Se),t._fromNumbers=yt(Lt.d),t._fromNumber=Lt.n,t._toNumbers=yt(Se.d),t._strings=yt(Se.s),t._toNumber=Se.o?Et(Lt.n,Se.n,Se.o):Se.n}}),this.duration===d&&this.restart(),this}revert(){return super.revert(),Ot(this)}then(t){return super.then(t)}}const Le={_head:null,_tail:null},Ne=(t,e,s)=>{let i,r=Le._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),bt(Le,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Ae=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Ne(e,s),St(Le,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Ne(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Fe(t,e,s){const i=ne(t);if(!i.length)return;const[r]=i,n=kt(r,e),o=Pt(e,r,n);let a=Ct(r,o);if(X(s))return a;if(Dt(a,Lt),0===Lt.t||1===Lt.t){if(!1===s)return Lt.n;{const t=he(r,Lt,s,!1);return`${ut(t.n,N.precision)}${t.u}`}}}const Pe=(t,e)=>{if(!X(e))return e.duration=d,e.composition=Tt(e.composition,r.none),new Be(t,e,null,0,!0).resume()},Oe=(t,e,s)=>{const i=re(t);for(let t=0,r=i.length;t<r;t++)Ne(i[t],s,e&&e.controlAnimation&&e);return Jt(i,e,s),i},Re=(t,e)=>{let s=t.iterationDuration;if(s===d&&(s=0),X(e))return s;if(z(+e))return+e;const i=e,r=t?t.labels:null,n=!V(r),o=((t,e)=>{if(P(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!X(o),h=E.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,c=a?o:n?l:s,d=+e[1];return Et(c,d,t[0])}return a?o:n?X(r[i])?s:r[i]:s};function Me(t,e,s,i,r,n){const o=z(t.duration)&&t.duration<=d?s-d:s;At(e,o,1,1,1);const a=i?new Be(i,t,e,o,!1,r,n):new se(t,e,o);return a.init(!0),St(e,a),vt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return ft((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||d}(e),e}class ze extends se{constructor(t={}){super(t,null,0),this.duration=0,this.labels={};const e=t.defaults,s=N.defaults;this.defaults=e?_t(e,s):s,this.onRender=t.onRender||s.onRender;const i=Tt(t.playbackEase,s.playbackEase);this._ease=i?ve(i):null,this.iterationDuration=0}add(t,e,s){const i=M(e),r=M(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(Y(s)){const e=s,r=re(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,X(a)||(s.id=a+"-"+h),Me(s,this,Re(this,e(t,h,l,this)),t,h,l),h++})}else Me(i,this,Re(this,s),t)}else Me(t,this,Re(this,e));return this.init(!0)}}sync(t,e){if(X(t)||t&&X(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,ease:"linear"},e)}set(t,e,s){return X(e)?this:(e.duration=d,e.composition=r.replace,this.add(t,e,s))}call(t,e){return X(t)||t&&!Y(t)?this:this.add({duration:0,onComplete:()=>t(this)},e)}label(t,e){return X(t)||t&&!I(t)||(this.labels[t]=Re(this,e)),this}remove(t,e){return Jt(re(t),this,e),this}stretch(t){const e=this.duration;if(e===gt(t))return this;const s=t/e,i=this.labels;vt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return vt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),vt(this,t=>t.revert,!0),Ot(this)}then(t){return super.then(t)}}class Ie{constructor(t,e){L.current&&L.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!X(t)&&!X(e)){for(let t in e){const s=e[t];j(t)?o[t]=s:P(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Be({v:0},n);for(let e in o){const s=o[e],n=M(s);let a={},h="+=0";if(n){const t=s.unit;I(t)&&(h+=t)}else a.duration=s;a[e]=n?_t({to:h},s):h;const l=_t(i,a);l.composition=r.replace,l.autoplay=!1;const c=this.animations[e]=new Be(t,l,null,0,!1).init();this.targets.length||this.targets.push(...c.targets),this[e]=(t,e,s)=>{const i=c._head;if(X(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return vt(c,e=>{if(R(t))for(let s=0,i=t.length;s<i;s++)X(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;X(s)||(e._ease=ve(s)),e._currentTime=0}),X(e)||c.stretch(e),c.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=_,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const Ye=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Xe=Object.freeze({__proto__:null,clamp:ct,damp:(t,e,s,i)=>i?1===i?e:mt(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:mt,mapRange:Ye,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:ut,roundPad:(t,e)=>(+t).toFixed(e),snap:pt,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const Ve=10*p;class We{constructor(t={}){const e=!X(t.bounce)||!X(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/p,this.maxIterations=this.maxDuration/this.timeStep/p,this.bn=ct(Tt(t.bounce,.5),-1,1),this.pd=ct(Tt(t.duration,628),10*N.timeScale,Ve*N.timeScale),this.m=ct(Tt(t.mass,1),1,Ve),this.s=ct(Tt(t.stiffness,100),d,Ve),this.d=ct(Tt(t.damping,10),d,Ve),this.v=ct(Tt(t.velocity,0),-1e4,Ve),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||_,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?st(-n*e*s)*(1*tt(i*n)+r*K(i*n)):1===e?(1+r*n)*st(-n*s):((1+r)*st((-e*s+i)*n)+(1-r)*st((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===N.timeScale?this.pd/p:this.pd;this.m=1,this.v=0,this.s=Z(2*ht/t,2),this.bn>=0?this.d=4*(1-this.bn)*ht/t:this.d=4*ht/(t*(1+this.bn)),this.s=ut(ct(this.s,d,Ve),3),this.d=ut(ct(this.d,d,300),3)}calculateBDFromSD(){const t=2*ht/J(this.s);this.pd=t*(1===N.timeScale?p:1);const e=this.d/(2*J(this.s));this.bn=e<=1?1-this.d*t/(4*ht):4*ht/(this.d*t)-1,this.bn=ut(ct(this.bn,-1,1),3),this.pd=ut(ct(this.pd,10*N.timeScale,Ve*N.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=ct(J(o/r),d,p),l=this.zeta=n/(2*J(o*r));l<1?(this.wd=h*J(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*J(l*l-1),this.b=(l*h-a)/this.wd);let c=0,u=0,m=0;for(;u<=t&&m<=e;)et(1-this.solve(c))<s?u++:u=0,this.solverDuration=c,c+=i,m++;this.settlingDuration=ut(this.solverDuration*p,0)*N.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=ct(Tt(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=ct(Tt(t,1),10*N.timeScale,Ve*N.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ct(Tt(t,100),d,Ve),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=ct(Tt(t,10),d,Ve),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=ct(Tt(t,1),1,Ve),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ct(Tt(t,0),-1e4,Ve),this.compute()}}const He=t=>new We(t),Ue=t=>(console.warn("createSpring() is deprecated use spring() instead"),new We(t)),qe=t=>{t.cancelable&&t.preventDefault()};class je{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:_,remove:_}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ge{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const Qe=(t,e)=>t&&Y(t)?t(e):t;let Ze=0;class Je{constructor(t,e={}){if(!t)return;L.current&&L.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,h=e.releaseEase,l=h&&ve(h),c=!X(h)&&!X(h.ease),d=M(r)&&!X(r.mapTo)?r.mapTo:"translateX",p=M(n)&&!X(n.mapTo)?n.mapTo:"translateY",m=Qe(e.container,this);this.containerArray=R(m)?m:null,this.$container=m&&!this.containerArray?re(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=M(t)?new je(t):re(t)[0],this.$trigger=re(o||t)[0],this.fixed="fixed"===Fe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=c?h:He({mass:Tt(e.releaseMass,1),stiffness:Tt(e.releaseStiffness,80),damping:Tt(e.releaseDamping,20)}),this.releaseYSpring=c?h:He({mass:Tt(e.releaseMass,1),stiffness:Tt(e.releaseStiffness,80),damping:Tt(e.releaseDamping,20)}),this.releaseEase=l||fe.outQuint,this.hasReleaseSpring=c,this.onGrab=e.onGrab||_,this.onDrag=e.onDrag||_,this.onRelease=e.onRelease||_,this.onUpdate=e.onUpdate||_,this.onSettle=e.onSettle||_,this.onSnap=e.onSnap||_,this.onResize=e.onResize||_,this.onAfterResize=e.onAfterResize||_,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),X(r)||!0===r)f[d]=0;else if(M(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[d]=e}else!1===r&&(f[d]=0,this.disabled[0]=1);if(X(n)||!0===n)f[p]=0;else if(M(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new Ie(this.$target,f),this.xProp=d,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-u,u,u,-u],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=O(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ge(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new se({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new se({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!X(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?d:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=at(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new se({autoplay:!1,duration:150*N.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),M(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=O(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=ut(ct(J(t*t+e*e)/r*o,a,h),5);const c=ot(n[0],n[1],n[2]);return this.velocity=c,this.velocityStackIndex=(l+1)%3,c}setX(t,e=!1){if(this.disabled[0])return;const s=ut(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=pt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=ut(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=pt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return ut(this.animate[this.xProp](),N.precision)}set x(t){this.setX(t,!1)}get y(){return ut(this.animate[this.yProp](),N.precision)}set y(t){this.setY(t,!1)}get progressX(){return Ye(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(Ye(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return Ye(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(Ye(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=ut(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=ut(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,h=this.window[1]=s.innerHeight,l=this.useWin,c=t.scrollWidth,d=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?ct(c,a,c):c,this.scrollView[1]=l?ct(d,h,d):d,this.updateScrollCoords();const{width:_,height:v,left:b,top:S,right:w,bottom:T}=t.getBoundingClientRect();this.dragArea[2]=ut(l?ct(_,a,a):_,0),this.dragArea[3]=ut(l?ct(v,h,h):v,0);const x=Fe(t,"overflow"),k="visible"===x,$="hidden"===x;if(this.canScroll=!u&&this.contained&&(t===i.body&&k||!$&&!k)&&(c>this.dragArea[2]+y-f||d>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!R(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,c=i?this.scrollView[0]-n-_:0,d=i?this.scrollView[1]-o-v:0;this.targetBounds[0]=ut(r.top+s-(l?0:S),0),this.targetBounds[1]=ut(r.right+e-(l?a:w),0),this.targetBounds[2]=ut(r.bottom+s-(l?h:T),0),this.targetBounds[3]=ut(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-ut(r.top-(u?ct(S,0,h):S)+o-m,0),this.containerBounds[1]=-ut(r.right-(u?ct(w,0,a):w)-c+f,0),this.containerBounds[2]=-ut(r.bottom-(u?ct(T,0,h):T)-d+g,0),this.containerBounds[3]=-ut(r.left-(u?ct(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,c=!h&&s<i||!h&&s>n;return l&&!c?1:!l&&c?2:l&&c?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=Qe(t.container,this),o=Qe(t.containerPadding,this)||0,a=R(o)?o:[o,o,o,o],h=this.x,l=this.y,c=Qe(t.cursor,this),d={onHover:"grab",onGrab:"grabbing"};if(c){const{onHover:t,onGrab:e}=c;t&&(d.onHover=t),e&&(d.onGrab=e)}const u=Qe(t.dragThreshold,this),p={mouse:3,touch:7};if(z(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;X(t)||(p.mouse=t),X(e)||(p.touch=e)}this.containerArray=R(n)?n:null,this.$container=n&&!this.containerArray?re(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=Tt(a,[0,0,0,0]),this.containerFriction=ct(Tt(Qe(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ct(Tt(Qe(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=Qe(M(e)&&!X(e.snap)?e.snap:t.snap,this),this.snapY=Qe(M(r)&&!X(r.snap)?r.snap:t.snap,this),this.scrollSpeed=Tt(Qe(t.scrollSpeed,this),1.5),this.scrollThreshold=Tt(Qe(t.scrollThreshold,this),20),this.dragSpeed=Tt(Qe(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=Tt(Qe(t.minVelocity,this),0),this.maxVelocity=Tt(Qe(t.maxVelocity,this),50),this.velocityMultiplier=Tt(Qe(t.velocityMultiplier,this),1),this.cursor=!1!==c&&d,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(ct(h,y,f),!0),this.setY(ct(l,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,c=this.$container.scrollWidth,d=this.$container.scrollHeight,u=this.useWin?ct(c,this.window[0],c):c,p=this.useWin?ct(d,this.window[1],d):d,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[_,v]=this.coords,[b,S,w,T]=this.scrollBounds,x=ut(ct((v-b+t)/y,-1,0)*g,0),k=ut(ct((_-S-e)/y,0,1)*g,0),$=ut(ct((v-w-s)/y,0,1)*g,0),C=ut(ct((_-T+i)/y,-1,0)*g,0);if(x||$||C||k){const[t,e]=this.disabled;let s=h,i=l;t||(s=ut(ct(h+(C||k),0,r-o),0),this.coords[0]-=h-s),e||(i=ut(ct(l+(x||$),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[c,d]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(c>e?e+(c-e)*m:c<i?i+(c-i)*m:c,!1),this.setY(d>s?s+(d-s)*m:d<t?t+(d-t)*m:d,!1),this.computeVelocity(r-h,n-l),this.angle=at(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return Jt([this],null,"x"),Jt([this],null,"y"),Jt([this],null,"progressX"),Jt([this],null,"progressY"),Jt([this.scroll]),Jt([this.overshootCoords]),this}scrollInView(t,e=0,s=fe.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,c,d]=o,p=ut(ct(r-h,-u,0),0),m=ut(ct(i-l,0,u),0),f=ut(ct(r-c,0,u),0),g=ut(ct(i-d,-u,0),0);new Be(n,{x:ut(n.x+(g?g-e:m?m+e:0),0),y:ut(n.y+(p?p-e:f?f+e:0),0),duration:X(t)?350*N.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Pe(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=fe.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,c=this.scroll.x-this.targetBounds[1]-o-e,d=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,c,d,u],i,r);if(p){const[e,n]=this.disabled,o=ct(pt(i,this.snapX),u,c),a=ct(pt(r,this.snapY),l,d),h=X(t)?350*N.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,c,d]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<d?d+(p-d)/u:p:p,this.coords[1]=this.coords[3]=u?m>c?c+(m-c)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Fe(this.$target,"zIndex",!1);Ze=(f>Ze?f:Ze)+1,this.targetStyles=Pe(this.$target,{zIndex:Ze}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Pe(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,fe.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,c=!1,d=!1;for(;e&&h&&h!==this.$trigger;){const t=Fe(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){d=!0,l=t<=3,c=t>=e-s-3;break}}h=h.parentElement}d&&(!l&&!c||l&&a<0||c&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(qe(t),this.triggerStyles||(this.triggerStyles=Pe(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",qe,{passive:!1}),this.$trigger.addEventListener("touchmove",qe,{passive:!1}),this.$trigger.addEventListener("touchend",qe),(this.dragged||!this.disabled[0]&&et(o)>this.dragThreshold||!this.disabled[1]&&et(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,h,l]=this.pointer,[c,d,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,_=this.releaseEase,v=this.hasReleaseSpring,b=this.overshootCoords,S=this.x,w=this.y,T=this.computeVelocity(s-h,n-l),x=this.angle=at(n-a,s-o),k=150*T,$=(1-this.releaseContainerFriction)*this.dragSpeed,C=S+tt(x)*k,E=w+K(x)*k,D=C>d?d+(C-d)*$:C<p?p+(C-p)*$:C,B=E>u?u+(E-u)*$:E<c?c+(E-c)*$:E,L=this.destX=ct(ut(pt(D,this.snapX),5),p,d),A=this.destY=ct(ut(pt(B,this.snapY),5),c,u),F=this.isOutOfBounds(this.containerBounds,C,E);let P=0,O=0,R=_,M=_,z=0;if(b.x=S,b.y=w,!t){const t=L===d?S>d?-1:1:S<p?-1:1,s=ut(S-L,0);g.velocity=e&&v?s?k*t/et(s):0:T;const{ease:i,settlingDuration:r,restDuration:n}=g;P=S===L?0:v?r:r-n*N.timeScale,v&&(R=i),P>z&&(z=P)}if(!e){const e=A===u?w>u?-1:1:w<c?-1:1,s=ut(w-A,0);y.velocity=t&&v?s?k*e/et(s):0:T;const{ease:i,settlingDuration:r,restDuration:n}=y;O=w===A?0:v?r:r-n*N.timeScale,v&&(M=i),O>z&&(z=O)}if(!v&&F&&$&&(P||O)){const t=r.blend;new Be(b,{x:{to:D,duration:.65*P},y:{to:B,duration:.65*O},ease:_,composition:t}).init(),new Be(b,{x:{to:L,duration:P},y:{to:A,duration:O},ease:_,composition:t}).init(),this.overshootTicker.stretch(ot(P,O)).restart()}else t||this.animate[this.xProp](L,P,R),e||this.animate[this.yProp](A,O,M);this.scrollInView(z,this.scrollThreshold,_);let I=!1;L!==m&&(this.snapped[0]=L,this.snapX&&(I=!0)),A!==f&&this.snapY&&(this.snapped[1]=A,this.snapY&&(I=!0)),I&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",qe),this.$trigger.removeEventListener("touchmove",qe),this.$trigger.removeEventListener("touchend",qe),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Pe(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":qe(t)}}}const Ke=(t=_)=>new se({duration:1*N.timeScale,onComplete:t},null,0).resume(),ts=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!Y(a)&&a.revert&&(e=a),X(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||_}};class es{constructor(t={}){L.current&&L.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||re(e)[0]||i);const n=t.defaults,o=N.defaults,a=t.mediaQueries;if(this.defaults=n?_t(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=L.current,s=L.root,i=N.defaults;L.current=this,L.root=this.root,N.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return L.current=e,L.root=s,N.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);Y(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,Y(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);Y(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,Y(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);Y(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(Y(s))return s(this);const i=ts(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const ss=(t,e)=>t&&Y(t)?t(e):t,is=new Map;class rs{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new se({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;vt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new se({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=ut(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new se({autoplay:!1,duration:250*N.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new se({autoplay:!1,duration:500*N.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=ut(t?s.scrollX:e.scrollLeft,0),this.scrollY=ut(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){vt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),vt(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),is.delete(this.element)}}const ns=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Dt(a,Lt);let c=h;return"%"===l?c=h/100*s:l&&(c=he(t,Lt,"px",!0).n),o&&i<0&&(c+=i),n&&r>0&&(c+=r),c},os=(t,e,s,i,r)=>{let n;if(I(e)){const o=E.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),c="min"===l[0],d="max"===l[0],u=ns(t,l[0],s,i,r),p=ns(t,l[1],s,i,r);if(c){const e=Et(ns(t,"min",s),p,h);n=e<u?u:e}else if(d){const e=Et(ns(t,"max",s),p,h);n=e>u?u:e}else n=Et(u,p,h)}else n=ns(t,e,s,i,r)}else n=e;return ut(n,0)},as=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let hs=0;const ls=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class cs{constructor(t={}){L.current&&L.current.register(this);const e=Tt(t.sync,"play pause"),s=e?ve(e):null,r=e&&("linear"===e||e===le),n=e&&!(s===le&&!r),o=e&&(z(e)||!0===e||r),a=e&&I(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=hs++,this.id=X(t.id)?this.index:t.id,this.container=(t=>{const e=t&&re(t)[0]||i.body;let s=is.get(e);return s||(s=new rs(e),is.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:_,this.onSyncLeave=h&&!l&&h[1]?h[1]:_,this.onSyncEnterForward=h&&l&&h[0]?h[0]:_,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:_,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:_,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:_,this.onEnter=t.onEnter||_,this.onLeave=t.onLeave||_,this.onEnterForward=t.onEnterForward||_,this.onLeaveForward=t.onLeaveForward||_,this.onEnterBackward=t.onEnterBackward||_,this.onLeaveBackward=t.onLeaveBackward||_,this.onUpdate=t.onUpdate||_,this.onSyncComplete=t.onSyncComplete||_,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=Tt(t.debug,!1),this._next=null,this._prev=null,St(this.container,this),Ke(()=>{if(!this.reverted){if(!this.target){const e=re(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,X(t)||(t.persist=!0),!this._params.target)){let e;X(t.targets)?vt(t,t=>{t.targets&&!e&&(e=as(t))}):e=as(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:ut(ct(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=Tt(ss(t.repeat,this),!0),this.horizontal="x"===Tt(ss(t.axis,this),"y"),this.enter=Tt(ss(t.enter,this),"end start"),this.leave=Tt(ss(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=ls[this.index%ls.length],h=t.useWin,l=h?t.winWidth:t.width,c=h?t.winHeight:t.height,d=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,_=e?60:g,v=e?_:y,b=e?"repeat-x":"repeat-y",S=t=>e?"0px "+t+"px":t+"px 2px",w=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,T=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${T("absolute",m,f,e?d:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${T("sticky",0,0,e?l:g,e?g:c)}`,s||(n.style.cssText+=`background:\n ${w("#FFFF")}${S(g-10)} / 100px 100px ${b},\n ${w("#FFF8")}${S(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${T("relative",0,0,e?d:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${w("#FFFF")}${S(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${w("#FFF8")}${S(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const x=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,h=(r?0:this.offset)+t,m=s%2,f=h<v,g=h>(r?e?l:c:e?d:u)-v,b=(r?m&&!f:!m&&!f)||g,S=i.createElement("div"),w=i.createElement("div"),k=e?b?"right":"left":b?"bottom":"top",$=b?(e?_:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;w.innerHTML=`${this.id}${x[m]}${this.thresholds[s]}`,S.style.cssText=`${T("absolute",0,0,_,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${k}: 2px solid ${a};\n `,w.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,S.appendChild(w);let C=h-$+(e?1:0);S.style[e?"left":"top"]=`${C}px`,(r?n:o).appendChild(S)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Fe(t.element,"position")&&(this.debugStyles=Pe(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==s.element&&a!==i.body;){const e="sticky"===Fe(a,"position")&&Pe(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=s.scale,c=(r?h.left+s.scrollX-s.left:h.top+s.scrollY-s.top)*l,d=(r?h.width:h.height)*l,u=r?s.width:s.height,p=(r?s.scrollWidth:s.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",_="end",v="start";if(I(m)){const t=m.split(" ");_=t[0],g=t.length>1?t[1]:g}else if(M(m)){const t=m;X(t.container)||(_=t.container),X(t.target)||(g=t.target)}else z(m)&&(_=m);if(I(f)){const t=f.split(" ");v=t[0],y=t.length>1?t[1]:y}else if(M(f)){const t=f;X(t.container)||(v=t.container),X(t.target)||(y=t.target)}else z(f)&&(v=f);const b=os(e,g,d),S=os(e,y,d),w=b+c-u,T=S+c-p,x=os(e,_,u,w,T),k=os(e,v,u,w,T),$=b+c-x,C=S+c-k,E=C-$;this.offset=c,this.offsetStart=$,this.offsetEnd=C,this.distance=E<=0?0:E,this.thresholds=[g,y,_,v],this.coords=[b,S,x,k],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,c=!h&&!l,d=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&d,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&z(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=ut(mt(e,g,mt(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(c&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(c&&(this.isInView=!0),this.forceEnter&&this.hasEntered?c&&(this.forceEnter=!1):(p&&c&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(c||!c&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!c&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return bt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const ds=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,us=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?le:r=>0===r||1===r?r:ds(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=ds(r,e,s)-t,i>0?o=r:n=r}while(et(i)>1e-7&&++a<100);return r})(r,t,s),e,i),ps=(t=10,e)=>{const s=e?it:rt;return e=>s(ct(e,0,1)*t)*(1/t)},ms=(...t)=>{const e=t.length;if(!e)return le;const s=e-1,i=t[0],r=t[s],n=[0],o=[Q(i)];for(let e=1;e<s;e++){const i=t[e],r=I(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(X(h)?e/s:Q(h)/100),o.push(Q(a))}return o.push(Q(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},fs=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ct(o,r,1))}return s.push(1),ms(...s)};var gs=Object.freeze({__proto__:null,Spring:We,createSpring:Ue,cubicBezier:us,eases:fe,irregular:fs,linear:ms,spring:He,steps:ps});const ys=Xe,_s={},vs=t=>(...e)=>{const s=t(...e);return new Proxy(_,{apply:(t,e,[i])=>s(i),get:(t,e)=>vs((...t)=>{const i=_s[e](...t);return t=>i(s(t))})})},bs=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?vs(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return _s[t]||(_s[t]=i),i},Ss=bs("roundPad",ys.roundPad),ws=bs("padStart",ys.padStart),Ts=bs("padEnd",ys.padEnd),xs=bs("wrap",ys.wrap),ks=bs("mapRange",ys.mapRange),$s=bs("degToRad",ys.degToRad),Cs=bs("radToDeg",ys.radToDeg),Es=bs("snap",ys.snap),Ds=bs("clamp",ys.clamp),Bs=bs("round",ys.round),Ls=bs("lerp",ys.lerp,1),Ns=bs("damp",ys.damp,1),As=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let Fs=0;const Ps=(t,e=0,s=1,i=0)=>{let r=void 0===t?Fs++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},Os=t=>t[As(0,t.length-1)],Rs=t=>{let e,s,i=t.length;for(;i;)s=As(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},Ms=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!X(o),h=a&&!X(o.ease)?o.ease:a?ve(o):null,l=e.grid,c=e.axis,d=e.total,u=X(r)||0===r||"first"===r,p="center"===r,f="last"===r,g="random"===r,y=R(t),_=e.use,v=Q(y?t[0]:t),b=y?Q(t[1]):0,S=k.exec((y?t[1]:t)+m),w=e.start||0+(y?v:0);let T=u?0:z(r)?r:0;return(t,r,o,a)=>{const[u]=ne(t),m=X(d)?o:d,x=!X(_)&&(Y(_)?_(u,r,m):Ct(u,_)),k=z(x)||I(x)&&z(+x)?+x:r;if(p&&(T=(m-1)/2),f&&(T=m-1),!s.length){for(let t=0;t<m;t++){if(l){const e=p?(l[0]-1)/2:T%l[0],i=p?(l[1]-1)/2:rt(T/l[0]),r=e-t%l[0],n=i-rt(t/l[0]);let o=J(r*r+n*n);"x"===c&&(o=-r),"y"===c&&(o=-n),s.push(o)}else s.push(et(T-t));i=ot(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>c?t<0?-1*t:-t:et(i-t))),g&&(s=Rs(s))}const $=y?(b-v)/i:v;let C=(a?Re(a,X(e.start)?a.iterationDuration:w):w)+($*ut(s[k],2)||0);return e.modifier&&(C=e.modifier(C)),S&&(C=`${C}${S[2]}`),C}};var zs=Object.freeze({__proto__:null,$:ne,clamp:Ds,cleanInlineStyles:Ot,createSeededRandom:Ps,damp:Ns,degToRad:$s,get:Fe,keepTime:ts,lerp:Ls,mapRange:ks,padEnd:Ts,padStart:ws,radToDeg:Cs,random:As,randomPick:Os,remove:Oe,round:Bs,roundPad:Ss,set:Pe,shuffle:Rs,snap:Es,stagger:Ms,sync:Ke,wrap:xs});const Is=t=>{const e=re(t)[0];return e&&W(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},Ys=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},Xs=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[a],o=t.getCTM(),h=0===s;return{from:0,to:r,modifier:i=>{const a=i+s*r;if("a"===e){const e=Ys(t,r,a,-1,h),s=Ys(t,r,a,1,h);return 180*at(s.y-e.y,s.x-e.x)/ht}{const s=Ys(t,r,a,0,h);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},Vs=(t,e=0)=>{const s=Is(t);if(s)return{translateX:Xs(s,"x",e),translateY:Xs(s,"y",e),rotate:Xs(s,"a",e)}},Ws=(t,e=0,s=0)=>re(t).map(t=>((t,e,s)=>{const i=p,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===c?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(J(s.a*s.a+s.b*s.b)+J(s.c*s.c+s.d*s.d))/2)}return e})(o),c=-1e3*r*l,d=h*i*l+c,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-d;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${c}`),t.setAttribute("stroke-dasharray",`${d} ${u}`)}return Reflect.apply(s,t,e)}:Y(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h})(t,e,s)),Hs=(t,e=.33)=>s=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const i=Is(t);if(!i)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(i.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${i.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const r="path"===s.tagName,n=r?" ":",",o=s[l];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const c=e/(l-1),d=s.getPointAtLength(t*c),u=i.getPointAtLength(o*c),p=r?0===e?"M":"L":"";a+=p+ut(d.x,3)+n+d.y+" ",h+=p+ut(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[l]=h,[a,h]};var Us=Object.freeze({__proto__:null,createDrawable:Ws,createMotionPath:Vs,morphTo:Hs});const qs="undefined"!=typeof Intl&&Intl.Segmenter,js=/\{value\}/g,Gs=/\{i\}/g,Qs=/(\s+)/,Zs=/^\s+$/,Js="line",Ks="word",ti="char",ei="data-line";let si=null,ii=null,ri=null;const ni=t=>t.isWordLike||" "===t.segment||z(+t.segment),oi=t=>t.setAttribute("aria-hidden","true"),ai=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],hi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},li=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&li(e)}},ci=(t,e,s)=>{const i=t.getAttribute(ei);(null!==i&&+i!==e||"BR"===t.tagName)&&s.add(t);let r=t.childElementCount;for(;r--;)ci(t.children[r],e,s);return s},di=(t,e={})=>{let s="";const i=I(e.class)?` class="${e.class}"`:"",r=Tt(e.clone,!1),n=Tt(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},ui=(t,e,s,i,r,n,o,a,h)=>{const l=r===Js,c=r===ti,d=`_${r}_`,u=Y(t)?t(s):t,p=l?"block":"inline-block";ri.innerHTML=u.replace(js,`<i class="${d}"></i>`).replace(Gs,`${c?h:l?o:a}`);const m=ri.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${d}`),_=y.length;if(_){f.style.display=p,g.style.display=p,g.setAttribute(ei,`${o}`),l||(g.setAttribute("data-word",`${a}`),c&&g.setAttribute("data-char",`${h}`));let t=_;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${hi[r]}`),f};class pi{constructor(t,s={}){si||(si=qs?new qs([],{granularity:Ks}):{segment:t=>{const e=[],s=t.split(Qs);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Zs.test(i)})}return e}}),ii||(ii=qs?new qs([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!ri&&e&&(ri=i.createElement("template")),L.current&&L.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=s,c=(t=R(t)?t[0]:t)&&t.nodeType?t:(ie(t)||[])[0],d=!0===o?{}:o,u=!0===r||X(r)?{}:r,p=!0===n?{}:n;this.debug=Tt(l,!1),this.includeSpaces=Tt(h,!1),this.accessible=Tt(a,!0),this.linesOnly=d&&!u&&!p,this.lineTemplate=M(d)?di(Js,d):d,this.wordTemplate=M(u)||this.linesOnly?di(Ks,u):u,this.charTemplate=M(p)?di(ti,p):p,this.$target=c,this.html=c&&c.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(d||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=c.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),c?this.resizeObserver.observe(c):console.warn("No Text Splitter target found.")}addEffect(t){if(!Y(t))return console.warn("Effect must return a function.");const e=ts(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>Y(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,c=si.segment(o),d=i.createDocumentFragment();let u=null;for(const t of c){const e=t.segment,s=ni(t);if(!u||s&&u&&ni(u))a.push(e);else{const t=a.length-1;a[t].includes(" ")||e.includes(" ")?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const c=a[t+1],u=r&&c&&!c.trim(),p=o,m=s?ii.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,c=i.createTextNode(a);ui(s,l,c,f,ti,n,-1,h.length,l.length)}}e?ui(e,h,f,d,Ks,n,-1,h.length,l.length):s?d.appendChild(f):d.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;d.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(d,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>Y(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=ai(e,Ks))),o&&(h||n)&&(this.chars=ai(e,ti));const l=this.words.length?this.words:this.chars;let c,d=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();c&&s-c>.5*i&&d++,e.setAttribute(ei,`${d}`);const r=e.querySelectorAll(`[${ei}]`);let n=r.length;for(;n--;)r[n].setAttribute(ei,`${d}`);c=s}if(h){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<d+1;t++){const i=e.cloneNode(!0);ci(i,t,new Set).forEach(t=>{const e=t.parentElement;e&&s.add(e),t.remove()}),a.push(i)}s.forEach(li);for(let e=0,s=a.length;e<s;e++)ui(r,this.lines,a[e],t,Js,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=ai(e,Ks)),o&&(this.chars=ai(e,ti))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(oi),this.words.forEach(oi),this.chars.forEach(oi)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const mi=(t,e)=>new pi(t,e),fi=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new pi(t,e));var gi=Object.freeze({__proto__:null,TextSplitter:pi,split:fi,splitText:mi});const yi=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(ut(t(i/e),4));return`linear(${s.join(", ")})`},_i={},vi=t=>{let e=_i[t];if(e)return e;if(e="linear",I(t)){if(P(t,"linear")||P(t,"cubic-")||P(t,"steps")||P(t,"ease"))e=t;else if(P(t,"cubicB"))e=F(t);else{const s=ye(t);Y(s)&&(e=s===le?"linear":yi(s))}_i[t]=e}else if(Y(t)){const s=yi(t);s&&(e=s)}else t.ease&&(e=yi(t.ease));return e},bi=["x","y","z"],Si=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...bi],wi=(()=>[...bi,...g.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let Ti=null;const xi=(t,e,s,i,r)=>{let n=I(e)?e:xt(e,s,i,r);return z(n)?Si.includes(t)||P(t,"translate")?`${n}px`:P(t,"rotate")||P(t,"skew")?`${n}deg`:`${n}`:n},ki=(t,e,s,i,r,n)=>{let o="0";const a=X(i)?getComputedStyle(t)[e]:xi(e,i,t,r,n);return o=X(s)?R(i)?i.map(s=>xi(e,s,t,r,n)):a:[xi(e,s,t,r,n),a],o};class $i{constructor(t,s){L.current&&L.current.register(this),V(Ti)&&(!e||!X(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach(t=>{const e=P(t,"skew"),s=P(t,"scale"),i=P(t,"rotate"),r=P(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),Ti=!0):Ti=!1);const i=ne(t),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=Tt(s.ease,vi(N.defaults.ease)),o=n.ease&&n,a=Tt(s.autoplay,N.defaults.autoplay),l=!(!a||!a.link)&&a,c=s.alternate&&!0===s.alternate,d=s.reversed&&!0===s.reversed,u=Tt(s.loop,N.defaults.loop),v=!0===u||u===1/0?1/0:z(u)?u+1:1,b=c?d?"alternate-reverse":"alternate":d?"reverse":"normal",S=vi(n),w=1===N.timeScale?1:p;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||N.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==l,this.reversed=d,this.persist=Tt(s.persist,N.defaults.persist),this.autoplay=a,this._speed=Tt(s.playbackRate,N.defaults.playbackRate),this._resolve=_,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[h],a=wi.some(t=>s.hasOwnProperty(t)),l=t.style,c=this._inlineStyles[e]={},d=(o?o.settlingDuration:xt(Tt(s.duration,N.defaults.duration),t,e,r))*w,u=xt(Tt(s.delay,N.defaults.delay),t,e,r)*w,p=Tt(s.composition,"replace");for(let o in s){if(!j(o))continue;const h={},m={iterations:v,direction:b,fill:"both",easing:S,duration:d,delay:u,composite:p},y=s[o],_=!!a&&(g.includes(o)?o:f.get(o)),T=_?"transform":o;let x;if(c[T]||(c[T]=l[T]),M(y)){const s=y,a=Tt(s.ease,n),c=a.ease&&a,f=s.to,g=s.from;if(m.duration=(c?c.settlingDuration:xt(Tt(s.duration,d),t,e,r))*w,m.delay=xt(Tt(s.delay,u),t,e,r)*w,m.composite=Tt(s.composition,p),m.easing=vi(a),x=ki(t,o,g,f,e,r),_?(h[`--${_}`]=x,i[_]=x):h[o]=ki(t,o,g,f,e,r),Ae(this,t,o,h,m),!X(g))if(_){const t=`--${_}`;l.setProperty(t,h[t][0])}else l[o]=h[o][0]}else x=R(y)?y.map(s=>xi(o,s,t,e,r)):xi(o,y,t,e,r),_?(h[`--${_}`]=x,i[_]=x):h[o]=x,Ae(this,t,o,h,m)}if(a){let t=m;for(let e in i)t+=`${y[e]}var(--${e})) `;l.transform=t}}),l&&this.autoplay.link(this)}forEach(t){const e=I(t)?e=>e[t]():t;return this.animations.forEach(e),this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=N.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===N.timeScale?1:p);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel")}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let t in i){const e=i[t];X(e)||e===m?s.removeProperty(F(t)):s[t]=e}t.getAttribute("style")===m&&t.removeAttribute("style")}),this}then(t=_){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=_};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const Ci={animate:(t,e)=>new $i(t,e),convertEase:yi};t.$=ne,t.Animatable=Ie,t.Draggable=Je,t.JSAnimation=Be,t.Scope=es,t.ScrollObserver=cs,t.Spring=We,t.TextSplitter=pi,t.Timeline=ze,t.Timer=se,t.WAAPIAnimation=$i,t.animate=(t,e)=>new Be(t,e,null,0,!1).init(),t.clamp=Ds,t.cleanInlineStyles=Ot,t.createAnimatable=(t,e)=>new Ie(t,e),t.createDraggable=(t,e)=>new Je(t,e),t.createDrawable=Ws,t.createMotionPath=Vs,t.createScope=t=>new es(t),t.createSeededRandom=Ps,t.createSpring=Ue,t.createTimeline=t=>new ze(t).init(),t.createTimer=t=>new se(t,null,0).init(),t.cubicBezier=us,t.damp=Ns,t.degToRad=$s,t.eases=fe,t.easings=gs,t.engine=Xt,t.get=Fe,t.irregular=fs,t.keepTime=ts,t.lerp=Ls,t.linear=ms,t.mapRange=ks,t.morphTo=Hs,t.onScroll=(t={})=>new cs(t),t.padEnd=Ts,t.padStart=ws,t.radToDeg=Cs,t.random=As,t.randomPick=Os,t.remove=Oe,t.round=Bs,t.roundPad=Ss,t.scrollContainers=is,t.set=Pe,t.shuffle=Rs,t.snap=Es,t.split=fi,t.splitText=mi,t.spring=He,t.stagger=Ms,t.steps=ps,t.svg=Us,t.sync=Ke,t.text=gi,t.utils=zs,t.waapi=Ci,t.wrap=xs});
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).anime={})}(this,function(t){"use strict";const e="undefined"!=typeof window,s=e?window:null,i=e?document:null,r={replace:0,none:1,blend:2},n=Symbol(),o=Symbol(),a=Symbol(),h=Symbol(),l=Symbol(),d=Symbol(),c=1e-11,u=1e12,p=1e3,m="",f=(()=>{const t=new Map;return t.set("x","translateX"),t.set("y","translateY"),t.set("z","translateZ"),t})(),g=["translateX","translateY","translateZ","rotate","rotateX","rotateY","rotateZ","scale","scaleX","scaleY","scaleZ","skew","skewX","skewY","matrix","matrix3d","perspective"],y=g.reduce((t,e)=>({...t,[e]:e+"("}),{}),v=()=>{},_=/(^#([\da-f]{3}){1,2}$)|(^#([\da-f]{4}){1,2}$)/i,b=/rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)/i,T=/rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,x=/hsl\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*\)/i,w=/hsla\(\s*(-?\d+|-?\d*.\d+)\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)%\s*,\s*(-?\d+|-?\d*.\d+)\s*\)/i,S=/[-+]?\d*\.?\d+(?:e[-+]?\d)?/gi,$=/^([-+]?\d*\.?\d+(?:e[-+]?\d+)?)([a-z]+|%)$/i,k=/([a-z])([A-Z])/g,E=/(\w+)(\([^)]+\)+)/g,C=/(\*=|\+=|-=)/,N=/var\(\s*(--[\w-]+)(?:\s*,\s*([^)]+))?\s*\)/,D={id:null,keyframes:null,playbackEase:null,playbackRate:1,frameRate:240,loop:0,reversed:!1,alternate:!1,autoplay:!0,persist:!1,duration:p,delay:0,loopDelay:0,ease:"out(2)",composition:r.replace,modifier:t=>t,onBegin:v,onBeforeUpdate:v,onUpdate:v,onLoop:v,onPause:v,onComplete:v,onRender:v},I={current:null,root:i},A={defaults:D,precision:4,timeScale:1,tickThreshold:200},B=e&&s.AnimeJSDevTools,R={version:"4.3.0-beta.0",engine:null};e&&(s.AnimeJS||(s.AnimeJS=[]),s.AnimeJS.push(R));const L=t=>t.replace(k,"$1-$2").toLowerCase(),P=(t,e)=>0===t.indexOf(e),F=Date.now,M=Array.isArray,V=t=>t&&t.constructor===Object,z=t=>"number"==typeof t&&!isNaN(t),O=t=>"string"==typeof t,H=t=>"function"==typeof t,X=t=>void 0===t,Y=t=>X(t)||null===t,W=t=>e&&t instanceof SVGElement,U=t=>_.test(t),q=t=>P(t,"rgb"),j=t=>P(t,"hsl"),G=t=>!A.defaults.hasOwnProperty(t),Q=["opacity","rotate","overflow","color"],Z=t=>O(t)?parseFloat(t):t,J=Math.pow,K=Math.sqrt,tt=Math.sin,et=Math.cos,st=Math.abs,it=Math.exp,rt=Math.ceil,nt=Math.floor,ot=Math.asin,at=Math.max,ht=Math.atan2,lt=Math.PI,dt=Math.round,ct=(t,e,s)=>t<e?e:t>s?s:t,ut={},pt=(t,e)=>{if(e<0)return t;if(!e)return dt(t);let s=ut[e];return s||(s=ut[e]=10**e),dt(t*s)/s},mt=(t,e)=>M(e)?e.reduce((e,s)=>st(s-t)<st(e-t)?s:e):e?dt(t/e)*e:t,ft=(t,e,s)=>t+(e-t)*s,gt=t=>t===1/0?u:t===-1/0?-u:t,yt=t=>t<=c?c:gt(pt(t,11)),vt=t=>M(t)?[...t]:t,_t=(t,e)=>{const s={...t};for(let i in e){const r=t[i];s[i]=X(r)?e[i]:r}return s},bt=(t,e,s,i="_prev",r="_next")=>{let n=t._head,o=r;for(s&&(n=t._tail,o=i);n;){const t=n[o];e(n),n=t}},Tt=(t,e,s="_prev",i="_next")=>{const r=e[s],n=e[i];r?r[i]=n:t._head=n,n?n[s]=r:t._tail=r,e[s]=null,e[i]=null},xt=(t,e,s,i="_prev",r="_next")=>{let n=t._tail;for(;n&&s&&s(n,e);)n=n[i];const o=n?n[r]:t._head;n?n[r]=e:t._head=e,o?o[i]=e:t._tail=e,e[i]=n,e[r]=o},wt=(t,e,s)=>(s<0&&(s+=1),s>1&&(s-=1),s<1/6?t+6*(e-t)*s:s<.5?e:s<2/3?t+(e-t)*(2/3-s)*6:t),St=(t,e)=>X(t)?e:t,$t=(t,e,s,i,r)=>{let n;if(H(t))n=()=>{const r=t(e,s,i);return isNaN(+r)?r||0:+r};else{if(!O(t)||!P(t,"var("))return t;n=()=>{const s=t.match(N),i=s[1],r=s[2];let n=getComputedStyle(e)?.getPropertyValue(i);return n&&n.trim()!==m||!r||(n=r.trim()),n||0}}return r&&(r.func=n),n()},kt=(t,e)=>t[o]?t[a]&&((t,e)=>{if(Q.includes(e))return!1;if(t.getAttribute(e)||e in t){if("scale"===e){const e=t.parentNode;return e&&"filter"===e.tagName}return!0}})(t,e)?1:g.includes(e)||f.get(e)?3:P(e,"--")?4:e in t.style?2:e in t?0:1:0,Et=(t,e,s)=>{const i=t.style[e];i&&s&&(s[e]=i);const r=i||getComputedStyle(t[d]||t).getPropertyValue(e);return"auto"===r?"0":r},Ct=(t,e,s,i)=>{const r=X(s)?kt(t,e):s;return 0===r?t[e]||0:1===r?t.getAttribute(e):3===r?((t,e,s)=>{const i=t.style.transform;let r;if(i){const n=t[h];let o;for(;o=E.exec(i);){const t=o[1],i=o[2].slice(1,-1);n[t]=i,t===e&&(r=i,s&&(s[e]=i))}}return i&&!X(r)?r:P(e,"scale")?"1":P(e,"rotate")||P(e,"skew")?"0deg":"0px"})(t,e,i):4===r?Et(t,e,i).trimStart():Et(t,e,i)},Nt=(t,e,s)=>"-"===s?t-e:"+"===s?t+e:t*e,Dt=(t,e)=>{if(e.t=0,e.n=0,e.u=null,e.o=null,e.d=null,e.s=null,!t)return e;const s=+t;if(isNaN(s)){let s=t;"="===s[1]&&(e.o=s[0],s=s.slice(2));const n=!s.includes(" ")&&$.exec(s);if(n)return e.t=1,e.n=+n[1],e.u=n[2],e;if(e.o)return e.n=+s,e;if(U(r=s)||q(r)||j(r))return e.t=2,e.d=q(i=s)?(t=>{const e=b.exec(t)||T.exec(t),s=X(e[4])?1:+e[4];return[+e[1],+e[2],+e[3],s]})(i):U(i)?(t=>{const e=t.length,s=4===e||5===e;return[+("0x"+t[1]+t[s?1:2]),+("0x"+t[s?2:3]+t[s?2:4]),+("0x"+t[s?3:5]+t[s?3:6]),5===e||9===e?+(+("0x"+t[s?4:7]+t[s?4:8])/255).toFixed(3):1]})(i):j(i)?(t=>{const e=x.exec(t)||w.exec(t),s=+e[1]/360,i=+e[2]/100,r=+e[3]/100,n=X(e[4])?1:+e[4];let o,a,h;if(0===i)o=a=h=r;else{const t=r<.5?r*(1+i):r+i-r*i,e=2*r-t;o=pt(255*wt(e,t,s+1/3),0),a=pt(255*wt(e,t,s),0),h=pt(255*wt(e,t,s-1/3),0)}return[o,a,h,n]})(i):[0,0,0,1],e;{const t=s.match(S);return e.t=3,e.d=t?t.map(Number):[],e.s=s.split(S)||[],e}}var i,r;return e.n=s,e},It=(t,e)=>(e.t=t._valueType,e.n=t._toNumber,e.u=t._unit,e.o=null,e.d=vt(t._toNumbers),e.s=vt(t._strings),e),At={t:0,n:0,u:null,o:null,d:null,s:null},Bt=(t,e,s,i,n)=>{const o=t.parent,a=t.duration,l=t.completed,d=t.iterationDuration,u=t.iterationCount,p=t._currentIteration,f=t._loopDelay,g=t._reversed,v=t._alternate,_=t._hasChildren,b=t._delay,T=t._currentTime,x=b+d,w=e-b,S=ct(T,-b,a),$=ct(w,-b,a),k=w-T,E=$>0,C=$>=a,N=a<=c,D=2===n;let I=0,B=w,R=0;if(u>1){const e=~~($/(d+(C?0:f)));t._currentIteration=ct(e,0,u),C&&t._currentIteration--,I=t._currentIteration%2,B=$%(d+f)||0}const L=g^(v&&I),P=t._ease;let F=C?L?0:a:L?d-B:B;P&&(F=d*P(F/d)||0);const M=(o?o.backwards:w<T)?!L:!!L;if(t._currentTime=w,t._iterationTime=F,t.backwards=M,E&&!t.began?(t.began=!0,s||o&&(M||!o.began)||t.onBegin(t)):w<=0&&(t.began=!1),s||_||!E||t._currentIteration===p||t.onLoop(t),D||1===n&&(e>=b&&e<=x||e<=b&&S>b||e>=x&&S!==a)||F>=x&&S!==a||F<=b&&S>0||e<=S&&S===a&&l||C&&!l&&N){if(E&&(t.computeDeltaTime(S),s||t.onBeforeUpdate(t)),!_){const e=D||(M?-1*k:k)>=A.tickThreshold,n=t._offset+(o?o._offset:0)+b+F;let a,l,d,c,u=t._head,p=0;for(;u;){const t=u._composition,s=u._currentTime,o=u._changeDuration,f=u._absoluteStartTime+u._changeDuration,g=u._nextRep,v=u._prevRep,_=t!==r.none;if((e||(s!==o||n<=f+(g?g._delay:0))&&(0!==s||n>=u._absoluteStartTime))&&(!_||!u._isOverridden&&(!u._isOverlapped||n<=f)&&(!g||g._isOverridden||n<=g._absoluteStartTime)&&(!v||v._isOverridden||n>=v._absoluteStartTime+v._changeDuration+u._delay))){const e=u._currentTime=ct(F-u._startTime,0,o),s=u._ease(e/u._updateDuration),n=u._modifier,m=u._valueType,f=u._tweenType,g=0===f,y=0===m,v=y&&g||0===s||1===s?-1:A.precision;let b,T;if(y)b=T=n(pt(ft(u._fromNumber,u._toNumber,s),v));else if(1===m)T=n(pt(ft(u._fromNumber,u._toNumber,s),v)),b=`${T}${u._unit}`;else if(2===m){const t=u._fromNumbers,e=u._toNumbers,i=pt(ct(n(ft(t[0],e[0],s)),0,255),0),r=pt(ct(n(ft(t[1],e[1],s)),0,255),0),o=pt(ct(n(ft(t[2],e[2],s)),0,255),0),a=ct(n(pt(ft(t[3],e[3],s),v)),0,1);if(b=`rgba(${i},${r},${o},${a})`,_){const t=u._numbers;t[0]=i,t[1]=r,t[2]=o,t[3]=a}}else if(3===m){b=u._strings[0];for(let t=0,e=u._toNumbers.length;t<e;t++){const e=n(pt(ft(u._fromNumbers[t],u._toNumbers[t],s),v)),i=u._strings[t+1];b+=`${i?e+i:e}`,_&&(u._numbers[t]=e)}}if(_&&(u._number=T),i||t===r.blend)u._value=b;else{const t=u.property;a=u.target,g?a[t]=b:1===f?a.setAttribute(t,b):(l=a.style,3===f?(a!==d&&(d=a,c=a[h]),c[t]=b,p=1):2===f?l[t]=b:4===f&&l.setProperty(t,b)),E&&(R=1)}}if(p&&u._renderTransforms){let t=m;for(let e in c)t+=`${y[e]}${c[e]}) `;l.transform=t,p=0}u=u._next}!s&&R&&t.onRender(t)}!s&&E&&t.onUpdate(t)}return o&&N?!s&&(o.began&&!M&&w>0&&!l||M&&w<=c&&l)&&(t.onComplete(t),t.completed=!M):E&&C?u===1/0?t._startTime+=t.duration:t._currentIteration>=u-1&&(t.paused=!0,l||_||(t.completed=!0,s||o&&(M||!o.began)||(t.onComplete(t),t._resolve(t)))):t.completed=!1,R},Rt=(t,e,s,i,r)=>{const n=t._currentIteration;if(Bt(t,e,s,i,r),t._hasChildren){const o=t,a=o.backwards,h=i?e:o._iterationTime,l=F();let d=0,u=!0;if(!i&&o._currentIteration!==n){const t=o.iterationDuration;bt(o,e=>{if(a){const i=e.duration,r=e._offset+e._delay;s||!(i<=c)||r&&r+i!==t||e.onComplete(e)}else!e.completed&&!e.backwards&&e._currentTime<e.iterationDuration&&Bt(e,t,s,1,2),e.began=!1,e.completed=!1}),s||o.onLoop(o)}bt(o,t=>{const e=pt((h-t._offset)*t._speed,12),n=t._fps<o._fps?t.requestTick(l):r;d+=Bt(t,e,s,i,n),!t.completed&&u&&(u=!1)},a),!s&&d&&o.onRender(o),(u||a)&&o._currentTime>=o.duration&&(o.paused=!0,o.completed||(o.completed=!0,s||(o.onComplete(o),o._resolve(o))))}},Lt={},Pt=(t,e,s)=>{if(3===s)return f.get(t)||t;if(2===s||1===s&&W(e)&&t in e.style){const e=Lt[t];if(e)return e;{const e=t?L(t):t;return Lt[t]=e,e}}return t},Ft=t=>{if(t._hasChildren)bt(t,Ft,!0);else{const e=t;e.pause(),bt(e,t=>{const s=t.property,i=t.target;if(i[o]){const r=i.style,n=t._inlineValue,o=Y(n)||n===m;if(3===t._tweenType){const e=i[h];if(o?delete e[s]:e[s]=n,t._renderTransforms)if(Object.keys(e).length){let t=m;for(let s in e)t+=y[s]+e[s]+") ";r.transform=t}else r.removeProperty("transform")}else o?r.removeProperty(L(s)):r[s]=n;e._tail===t&&e.targets.forEach(t=>{t.getAttribute&&t.getAttribute("style")===m&&t.removeAttribute("style")})}})}return t};class Mt{constructor(t=0){this.deltaTime=0,this._currentTime=t,this._lastTickTime=t,this._startTime=t,this._lastTime=t,this._scheduledTime=0,this._frameDuration=p/240,this._fps=240,this._speed=1,this._hasChildren=!1,this._head=null,this._tail=null}get fps(){return this._fps}set fps(t){const e=this._frameDuration,s=+t,i=s<c?c:s,r=p/i;i>D.frameRate&&(D.frameRate=i),this._fps=i,this._frameDuration=r,this._scheduledTime+=r-e}get speed(){return this._speed}set speed(t){const e=+t;this._speed=e<c?c:e}requestTick(t){const e=this._scheduledTime;if(this._lastTickTime=t,t<e)return 0;const s=this._frameDuration,i=t-e;return this._scheduledTime+=i<s?s:i,1}computeDeltaTime(t){const e=t-this._lastTime;return this.deltaTime=e,this._lastTime=t,e}}const Vt={animation:null,update:v},zt=(()=>e?requestAnimationFrame:setImmediate)(),Ot=(()=>e?cancelAnimationFrame:clearImmediate)();class Ht extends Mt{constructor(t){super(t),this.useDefaultMainLoop=!0,this.pauseOnDocumentHidden=!0,this.defaults=D,this.paused=!0,this.reqId=0}update(){const t=this._currentTime=F();if(this.requestTick(t)){this.computeDeltaTime(t);const e=this._speed,s=this._fps;let i=this._head;for(;i;){const r=i._next;i.paused?(Tt(this,i),this._hasChildren=!!this._tail,i._running=!1,i.completed&&!i._cancelled&&i.cancel()):Rt(i,(t-i._startTime)*i._speed*e,0,0,i._fps<s?i.requestTick(t):1),i=r}Vt.update()}}wake(){return this.useDefaultMainLoop&&!this.reqId&&(this.requestTick(F()),this.reqId=zt(Yt)),this}pause(){if(this.reqId)return this.paused=!0,Wt()}resume(){if(this.paused)return this.paused=!1,bt(this,t=>t.resetTime()),this.wake()}get speed(){return this._speed*(1===A.timeScale?1:p)}set speed(t){this._speed=t*A.timeScale,bt(this,t=>t.speed=t._speed)}get timeUnit(){return 1===A.timeScale?"ms":"s"}set timeUnit(t){const e="s"===t,s=e?.001:1;if(A.timeScale!==s){A.timeScale=s,A.tickThreshold=200*s;const t=e?.001:p;this.defaults.duration*=t,this._speed*=t}}get precision(){return A.precision}set precision(t){A.precision=t}}const Xt=(()=>{const t=new Ht(F());return e&&(R.engine=t,i.addEventListener("visibilitychange",()=>{t.pauseOnDocumentHidden&&(i.hidden?t.pause():t.resume())})),t})(),Yt=()=>{Xt._head?(Xt.reqId=zt(Yt),Xt.update()):Xt.reqId=0},Wt=()=>(Ot(Xt.reqId),Xt.reqId=0,Xt),Ut={_rep:new WeakMap,_add:new Map},qt=(t,e,s="_rep")=>{const i=Ut[s];let r=i.get(t);return r||(r={},i.set(t,r)),r[e]?r[e]:r[e]={_head:null,_tail:null}},jt=(t,e)=>t._isOverridden||t._absoluteStartTime>e._absoluteStartTime,Gt=t=>{t._isOverlapped=1,t._isOverridden=1,t._changeDuration=c,t._currentTime=c},Qt=(t,e)=>{const s=t._composition;if(s===r.replace){const s=t._absoluteStartTime;xt(e,t,jt,"_prevRep","_nextRep");const i=t._prevRep;if(i){const e=i.parent,r=i._absoluteStartTime+i._changeDuration;if(t.parent.id!==e.id&&e.iterationCount>1&&r+(e.duration-e.iterationDuration)>s){Gt(i);let t=i._prevRep;for(;t&&t.parent.id===e.id;)Gt(t),t=t._prevRep}const n=s-t._delay;if(r>n){const t=i._startTime,e=r-(t+i._updateDuration),s=pt(n-e-t,12);i._changeDuration=s,i._currentTime=s,i._isOverlapped=1,s<c&&Gt(i)}let o=!0;if(bt(e,t=>{t._isOverlapped||(o=!1)}),o){const t=e.parent;if(t){let s=!0;bt(t,t=>{t!==e&&bt(t,t=>{t._isOverlapped||(s=!1)})}),s&&t.cancel()}else e.cancel()}}}else if(s===r.blend){const e=qt(t.target,t.property,"_add"),s=(t=>{let e=Vt.animation;return e||(e={duration:c,computeDeltaTime:v,_offset:0,_delay:0,_head:null,_tail:null},Vt.animation=e,Vt.update=()=>{t.forEach(t=>{for(let e in t){const s=t[e],i=s._head;if(i){const t=i._valueType,e=3===t||2===t?vt(i._fromNumbers):null;let r=i._fromNumber,n=s._tail;for(;n&&n!==i;){if(e)for(let t=0,s=n._numbers.length;t<s;t++)e[t]+=n._numbers[t];else r+=n._number;n=n._prevAdd}i._toNumber=r,i._toNumbers=e}}}),Bt(e,1,1,0,2)}),e})(Ut._add);let i=e._head;i||(i={...t},i._composition=r.replace,i._updateDuration=c,i._startTime=0,i._numbers=vt(t._fromNumbers),i._number=0,i._next=null,i._prev=null,xt(e,i),xt(s,i));const n=t._toNumber;if(t._fromNumber=i._fromNumber-n,t._toNumber=0,t._numbers=vt(t._fromNumbers),t._number=0,i._fromNumber=n,t._toNumbers){const e=vt(t._toNumbers);e&&e.forEach((e,s)=>{t._fromNumbers[s]=i._fromNumbers[s]-e,t._toNumbers[s]=0}),i._fromNumbers=e}xt(e,t,null,"_prevAdd","_nextAdd")}return t},Zt=t=>{const e=t._composition;if(e!==r.none){const s=t.target,i=t.property,n=Ut._rep.get(s)[i];if(Tt(n,t,"_prevRep","_nextRep"),e===r.blend){const e=Ut._add,r=e.get(s);if(!r)return;const n=r[i],o=Vt.animation;Tt(n,t,"_prevAdd","_nextAdd");const a=n._head;if(a&&a===n._tail){Tt(n,a,"_prevAdd","_nextAdd"),Tt(o,a);let t=!0;for(let e in r)if(r[e]._head){t=!1;break}t&&e.delete(s)}}}return t},Jt=(t,e,s)=>{let i=!1;return bt(e,r=>{const n=r.target;if(t.includes(n)){const t=r.property,o=r._tweenType,a=Pt(s,n,o);(!a||a&&a===t)&&(r.parent._tail===r&&3===r._tweenType&&r._prev&&3===r._prev._tweenType&&(r._prev._renderTransforms=1),Tt(e,r),Zt(r),i=!0)}},!0),i},Kt=(t,e,s)=>{const i=e||Xt;let r;if(i._hasChildren){let e=0;bt(i,n=>{if(!n._hasChildren)if(r=Jt(t,n,s),r&&!n._head)n.cancel(),Tt(i,n);else{const t=n._offset+n._delay+n.duration;t>e&&(e=t)}n._head?Kt(t,n,s):n._hasChildren=!1},!0),X(i.iterationDuration)||(i.iterationDuration=e)}else r=Jt(t,i,s);r&&!i._head&&(i._hasChildren=!1,i.cancel&&i.cancel())},te=t=>(t.paused=!0,t.began=!1,t.completed=!1,t),ee=t=>t._cancelled?(t._hasChildren?bt(t,ee):bt(t,t=>{t._composition!==r.none&&Qt(t,qt(t.target,t.property))}),t._cancelled=0,t):t;let se=0;class ie extends Mt{constructor(t={},e=null,s=0){super(0),++se;const{id:i,delay:r,duration:n,reversed:o,alternate:a,loop:h,loopDelay:l,autoplay:d,frameRate:u,playbackRate:p,onComplete:m,onLoop:f,onPause:g,onBegin:y,onBeforeUpdate:_,onUpdate:b}=t;I.current&&I.current.register(this);const T=e?0:Xt._lastTickTime,x=e?e.defaults:A.defaults,w=H(r)||X(r)?x.delay:+r,S=H(n)||X(n)?1/0:+n,$=St(h,x.loop),k=St(l,x.loopDelay);let E=!0===$||$===1/0||$<0?1/0:$+1;if(B){const s=E===1/0;if(B.register(this,t,s)&&s){const t=a?2:1,s=e?B.maxNestedInfiniteLoops:B.maxInfiniteLoops;E=Math.max(s,t)}}let C=0;e?C=s:(Xt.reqId||Xt.requestTick(F()),C=(Xt._lastTickTime-Xt._startTime)*A.timeScale),this.id=X(i)?se:i,this.parent=e,this.duration=gt((S+k)*E-k)||c,this.backwards=!1,this.paused=!0,this.began=!1,this.completed=!1,this.onBegin=y||x.onBegin,this.onBeforeUpdate=_||x.onBeforeUpdate,this.onUpdate=b||x.onUpdate,this.onLoop=f||x.onLoop,this.onPause=g||x.onPause,this.onComplete=m||x.onComplete,this.iterationDuration=S,this.iterationCount=E,this._autoplay=!e&&St(d,x.autoplay),this._offset=C,this._delay=w,this._loopDelay=k,this._iterationTime=0,this._currentIteration=0,this._resolve=v,this._running=!1,this._reversed=+St(o,x.reversed),this._reverse=this._reversed,this._cancelled=0,this._alternate=St(a,x.alternate),this._prev=null,this._next=null,this._lastTickTime=T,this._startTime=T,this._lastTime=T,this._fps=St(u,x.frameRate),this._speed=St(p,x.playbackRate)}get cancelled(){return!!this._cancelled}set cancelled(t){t?this.cancel():this.reset(!0).play()}get currentTime(){return ct(pt(this._currentTime,A.precision),-this._delay,this.duration)}set currentTime(t){const e=this.paused;this.pause().seek(+t),e||this.resume()}get iterationCurrentTime(){return ct(pt(this._iterationTime,A.precision),0,this.iterationDuration)}set iterationCurrentTime(t){this.currentTime=this.iterationDuration*this._currentIteration+t}get progress(){return ct(pt(this._currentTime/this.duration,10),0,1)}set progress(t){this.currentTime=this.duration*t}get iterationProgress(){return ct(pt(this._iterationTime/this.iterationDuration,10),0,1)}set iterationProgress(t){const e=this.iterationDuration;this.currentTime=e*this._currentIteration+e*t}get currentIteration(){return this._currentIteration}set currentIteration(t){this.currentTime=this.iterationDuration*ct(+t,0,this.iterationCount-1)}get reversed(){return!!this._reversed}set reversed(t){t?this.reverse():this.play()}get speed(){return super.speed}set speed(t){super.speed=t,this.resetTime()}reset(t=!1){return ee(this),this._reversed&&!this._reverse&&(this.reversed=!1),this._iterationTime=this.iterationDuration,Rt(this,0,1,~~t,2),te(this),this._hasChildren&&bt(this,te),this}init(t=!1){this.fps=this._fps,this.speed=this._speed,!t&&this._hasChildren&&Rt(this,this.duration,1,~~t,2),this.reset(t);const e=this._autoplay;return!0===e?this.resume():e&&!X(e.linked)&&e.link(this),this}resetTime(){const t=1/(this._speed*Xt._speed);return this._startTime=F()-(this._currentTime+this._delay)*t,this}pause(){return this.paused||(this.paused=!0,this.onPause(this)),this}resume(){return this.paused?(this.paused=!1,this.duration<=c&&!this._hasChildren?Rt(this,c,0,0,2):(this._running||(xt(Xt,this),Xt._hasChildren=!0,this._running=!0),this.resetTime(),this._startTime-=12,Xt.wake()),this):this}restart(){return this.reset().resume()}seek(t,e=0,s=0){ee(this),this.completed=!1;const i=this.paused;return this.paused=!0,Rt(this,t+this._delay,~~e,~~s,1),i?this:this.resume()}alternate(){const t=this._reversed,e=this.iterationCount,s=this.iterationDuration,i=e===1/0?nt(u/s):e;return this._reversed=+(!this._alternate||i%2?!t:t),e===1/0?this.iterationProgress=this._reversed?1-this.iterationProgress:this.iterationProgress:this.seek(s*i-this._currentTime),this.resetTime(),this}play(){return this._reversed&&this.alternate(),this.resume()}reverse(){return this._reversed||this.alternate(),this.resume()}cancel(){return this._hasChildren?bt(this,t=>t.cancel(),!0):bt(this,Zt),this._cancelled=1,this.pause()}stretch(t){const e=this.duration,s=yt(t);if(e===s)return this;const i=t/e,r=t<=c;return this.duration=r?c:s,this.iterationDuration=r?c:yt(this.iterationDuration*i),this._offset*=i,this._delay*=i,this._loopDelay*=i,this}revert(){Rt(this,0,1,0,1);const t=this._autoplay;return t&&t.linked&&t.linked===this&&t.revert(),this.cancel()}complete(){return this.seek(this.duration).cancel()}then(t=v){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=v};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}function re(t){const e=O(t)?I.root.querySelectorAll(t):t;if(e instanceof NodeList||e instanceof HTMLCollection)return e}function ne(t){if(Y(t))return[];if(!e)return M(t)&&t.flat(1/0)||[t];if(M(t)){const e=t.flat(1/0),s=[];for(let t=0,i=e.length;t<i;t++){const i=e[t];if(!Y(i)){const t=re(i);if(t)for(let e=0,i=t.length;e<i;e++){const i=t[e];if(!Y(i)){let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}else{let t=!1;for(let e=0,r=s.length;e<r;e++)if(s[e]===i){t=!0;break}t||s.push(i)}}}return s}const s=re(t);return s?Array.from(s):[t]}function oe(t){const e=ne(t),s=e.length;if(s)for(let t=0;t<s;t++){const s=e[t];if(!s[n]){s[n]=!0;const t=W(s);(s.nodeType||t)&&(s[o]=!0,s[a]=t,s[h]={})}}return e}const ae={deg:1,rad:180/lt,turn:360},he={},le=(t,e,s,r=!1)=>{const n=e.u,o=e.n;if(1===e.t&&n===s)return e;const a=o+n+s,h=he[a];if(X(h)||r){let r;if(n in ae)r=o*ae[n]/ae[s];else{const e=100,a=t.cloneNode(),h=t.parentNode,l=h&&h!==i?h:i.body;l.appendChild(a);const d=a.style;d.width=e+n;const c=a.offsetWidth||e;d.width=e+s;const u=c/(a.offsetWidth||e);l.removeChild(a),r=u*o}e.n=r,he[a]=r}else e.n=h;return e.t,e.u=s,e},de=t=>t,ce=(t=1.68)=>e=>J(e,+t),ue={in:t=>e=>t(e),out:t=>e=>1-t(1-e),inOut:t=>e=>e<.5?t(2*e)/2:1-t(-2*e+2)/2,outIn:t=>e=>e<.5?(1-t(1-2*e))/2:(t(2*e-1)+1)/2},pe=lt/2,me=2*lt,fe={[m]:ce,Quad:ce(2),Cubic:ce(3),Quart:ce(4),Quint:ce(5),Sine:t=>1-et(t*pe),Circ:t=>1-K(1-t*t),Expo:t=>t?J(2,10*t-10):0,Bounce:t=>{let e,s=4;for(;t<((e=J(2,--s))-1)/11;);return 1/J(4,3-s)-7.5625*J((3*e-2)/22-t,2)},Back:(t=1.7)=>e=>(+t+1)*e*e*e-+t*e*e,Elastic:(t=1,e=.3)=>{const s=ct(+t,1,10),i=ct(+e,c,2),r=i/me*ot(1/s),n=me/i;return t=>0===t||1===t?t:-s*J(2,-10*(1-t))*tt((1-t-r)*n)}},ge=(()=>{const t={linear:de,none:de};for(let e in ue)for(let s in fe){const i=fe[s],r=ue[e];t[e+s]=s===m||"Back"===s||"Elastic"===s?(t,e)=>r(i(t,e)):r(i)}return t})(),ye={linear:de,none:de},ve=t=>{if(ye[t])return ye[t];if(t.indexOf("(")<=-1){const e=ue[t]||t.includes("Back")||t.includes("Elastic")?ge[t]():ge[t];return e?ye[t]=e:de}{const e=t.slice(0,-1).split("("),s=ge[e[0]];return s?ye[t]=s(...e[1].split(",")):de}},_e=["steps(","irregular(","linear(","cubicBezier("],be=t=>{if(O(t))for(let e=0,s=_e.length;e<s;e++)if(P(t,_e[e]))return console.warn(`String syntax for \`ease: "${t}"\` has been removed from the core and replaced by importing and passing the easing function directly: \`ease: ${t}\``),de;return H(t)?t:O(t)?ve(t):de},Te={t:0,n:0,u:null,o:null,d:null,s:null},xe={t:0,n:0,u:null,o:null,d:null,s:null},we={},Se={func:null},$e=[null],ke=[null,null],Ee={to:null};let Ce,Ne,De=0,Ie=0;class Ae extends ie{constructor(t,e,s,i,n=!1,o=0,a=0){super(e,s,i),++Ie;const h=oe(t),l=h.length,d=e.keyframes,u=d?_t(((t,e)=>{const s={};if(M(t)){const e=[].concat(...t.map(t=>Object.keys(t))).filter(G);for(let i=0,r=e.length;i<r;i++){const r=e[i],n=t.map(t=>{const e={};for(let s in t){const i=t[s];G(s)?s===r&&(e.to=i):e[s]=i}return e});s[r]=n}}else{const i=St(e.duration,A.defaults.duration),r=Object.keys(t).map(e=>({o:parseFloat(e)/100,p:t[e]})).sort((t,e)=>t.o-e.o);r.forEach(t=>{const e=t.o,r=t.p;for(let t in r)if(G(t)){let n=s[t];n||(n=s[t]=[]);const o=e*i;let a=n.length,h=n[a-1];const l={to:r[t]};let d=0;for(let t=0;t<a;t++)d+=n[t].duration;1===a&&(l.from=h.to),r.ease&&(l.ease=r.ease),l.duration=o-(a?d:0),n.push(l)}return t});for(let t in s){const e=s[t];let i;for(let t=0,s=e.length;t<s;t++){const s=e[t],r=s.ease;s.ease=i||void 0,i=r}e[0].duration||e.shift()}}return s})(d,e),e):e,{id:m,delay:f,duration:g,ease:y,playbackEase:v,modifier:_,composition:b,onRender:T}=u,x=s?s.defaults:A.defaults,w=St(y,x.ease),S=St(v,x.playbackEase),$=S?be(S):null,k=!X(w.ease),E=k?w.ease:St(y,$?"linear":x.ease),C=k?w.settlingDuration:St(g,x.duration),N=St(f,x.delay),D=_||x.modifier,I=X(b)&&l>=p?r.none:X(b)?x.composition:b,B=this._offset+(s?s._offset:0);k&&(w.parent=this);let R=NaN,L=NaN,P=0,F=0;for(let t=0;t<l;t++){const e=h[t],i=o||t,d=a||l;let p=NaN,m=NaN;for(let t in u)if(G(t)){const o=kt(e,t),a=Pt(t,e,o);let h=u[t];const l=M(h);if(n&&!l&&(ke[0]=h,ke[1]=h,h=ke),l){const t=h.length,e=!V(h[0]);2===t&&e?(Ee.to=h,$e[0]=Ee,Ce=$e):t>2&&e?(Ce=[],h.forEach((t,e)=>{e?1===e?(ke[1]=t,Ce.push(ke)):Ce.push(t):ke[0]=t})):Ce=h}else $e[0]=h,Ce=$e;let f=null,g=null,y=NaN,v=0,_=0;for(let t=Ce.length;_<t;_++){const n=Ce[_];V(n)?Ne=n:(Ee.to=n,Ne=Ee),Se.func=null;const h=$t(Ne.to,e,i,d,Se);let l;V(h)&&!X(h.to)?(Ne=h,l=h.to):l=h;const u=$t(Ne.from,e,i,d),p=Ne.ease,m=!X(p)&&!X(p.ease),b=m?p.ease:p||E,T=m?p.settlingDuration:$t(St(Ne.duration,t>1?$t(C,e,i,d)/t:C),e,i,d),x=$t(St(Ne.delay,_?0:N),e,i,d),w=$t(St(Ne.composition,I),e,i,d),S=z(w)?w:r[w],$=Ne.modifier||D,k=!X(u),A=!X(l),R=M(l),L=R||k&&A,O=g?v+x:x,H=pt(B+O,12);F||!k&&!R||(F=1);let W=g;if(S!==r.none){f||(f=qt(e,a));let t=f._head;for(;t&&!t._isOverridden&&t._absoluteStartTime<=H;)if(W=t,t=t._nextRep,t&&t._absoluteStartTime>=H)for(;t;)Gt(t),t=t._nextRep}if(L){Dt(R?$t(l[0],e,i,d):u,Te),Dt(R?$t(l[1],e,i,d,Se):l,xe);const t=Ct(e,a,o,we);0===Te.t&&(W?1===W._valueType&&(Te.t=1,Te.u=W._unit):(Dt(t,At),1===At.t&&(Te.t=1,Te.u=At.u)))}else A?Dt(l,xe):g?It(g,xe):Dt(s&&W&&W.parent.parent===s?W._value:Ct(e,a,o,we),xe),k?Dt(u,Te):g?It(g,Te):Dt(s&&W&&W.parent.parent===s?W._value:Ct(e,a,o,we),Te);if(Te.o&&(Te.n=Nt(W?W._toNumber:Dt(Ct(e,a,o,we),At).n,Te.n,Te.o)),xe.o&&(xe.n=Nt(Te.n,xe.n,xe.o)),Te.t!==xe.t)if(3===Te.t||3===xe.t){const t=3===Te.t?Te:xe,e=3===Te.t?xe:Te;e.t=3,e.s=vt(t.s),e.d=t.d.map(()=>e.n)}else if(1===Te.t||1===xe.t){const t=1===Te.t?Te:xe,e=1===Te.t?xe:Te;e.t=1,e.u=t.u}else if(2===Te.t||2===xe.t){const t=2===Te.t?Te:xe,e=2===Te.t?xe:Te;e.t=2,e.s=t.s,e.d=[0,0,0,1]}if(Te.u!==xe.u){let t=xe.u?Te:xe;t=le(e,t,xe.u?xe.u:Te.u,!1)}if(xe.d&&Te.d&&xe.d.length!==Te.d.length){const t=Te.d.length>xe.d.length?Te:xe,e=t===Te?xe:Te;e.d=t.d.map((t,s)=>X(e.d[s])?0:e.d[s]),e.s=vt(t.s)}const U=pt(+T||c,12);let q=we[a];Y(q)||(we[a]=null);const j={parent:this,id:De++,property:a,target:e,_value:null,_func:Se.func,_ease:be(b),_fromNumbers:vt(Te.d),_toNumbers:vt(xe.d),_strings:vt(xe.s),_fromNumber:Te.n,_toNumber:xe.n,_numbers:vt(Te.d),_number:Te.n,_unit:xe.u,_modifier:$,_currentTime:0,_startTime:O,_delay:+x,_updateDuration:U,_changeDuration:U,_absoluteStartTime:H,_tweenType:o,_valueType:xe.t,_composition:S,_isOverlapped:0,_isOverridden:0,_renderTransforms:0,_inlineValue:q,_prevRep:null,_nextRep:null,_prevAdd:null,_nextAdd:null,_prev:null,_next:null};S!==r.none&&Qt(j,f),isNaN(y)&&(y=j._startTime),v=pt(O+U,12),g=j,P++,xt(this,j)}(isNaN(L)||y<L)&&(L=y),(isNaN(R)||v>R)&&(R=v),3===o&&(p=P-_,m=P)}if(!isNaN(p)){let t=0;bt(this,e=>{t>=p&&t<m&&(e._renderTransforms=1,e._composition===r.blend&&bt(Vt.animation,t=>{t.id===e.id&&(t._renderTransforms=1)})),t++})}}l||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation."),L?(bt(this,t=>{t._startTime-t._delay||(t._delay-=L),t._startTime-=L}),R-=L):L=0,R||(R=c,this.iterationCount=0),this.targets=h,this.id=X(m)?Ie:m,this.duration=R===c?c:gt((R+this._loopDelay)*this.iterationCount-this._loopDelay)||c,this.onRender=T||x.onRender,this._ease=$,this._delay=L,this.iterationDuration=R,!this._autoplay&&F&&this.onRender(this)}stretch(t){const e=this.duration;if(e===yt(t))return this;const s=t/e;return bt(this,t=>{t._updateDuration=yt(t._updateDuration*s),t._changeDuration=yt(t._changeDuration*s),t._currentTime*=s,t._startTime*=s,t._absoluteStartTime*=s}),super.stretch(t)}refresh(){return bt(this,t=>{const e=t._func;if(e){const s=Ct(t.target,t.property,t._tweenType);Dt(s,At),Dt(e(),xe),t._fromNumbers=vt(At.d),t._fromNumber=At.n,t._toNumbers=vt(xe.d),t._strings=vt(xe.s),t._toNumber=xe.o?Nt(At.n,xe.n,xe.o):xe.n}}),this.duration===c&&this.restart(),this}revert(){return super.revert(),Ft(this)}then(t){return super.then(t)}}const Be={_head:null,_tail:null},Re=(t,e,s)=>{let i,r=Be._head;for(;r;){const n=r._next,o=r.$el===t,a=!e||r.property===e,h=!s||r.parent===s;if(o&&a&&h){i=r.animation;try{i.commitStyles()}catch{}i.cancel(),Tt(Be,r);const t=r.parent;t&&(t._completed++,t.animations.length===t._completed&&(t.completed=!0,t.paused=!0,t.muteCallbacks||(t.onComplete(t),t._resolve(t))))}r=n}return i},Le=(t,e,s,i,r)=>{const n=e.animate(i,r),o=r.delay+ +r.duration*r.iterations;n.playbackRate=t._speed,t.paused&&n.pause(),t.duration<o&&(t.duration=o,t.controlAnimation=n),t.animations.push(n),Re(e,s),xt(Be,{parent:t,animation:n,$el:e,property:s,_next:null,_prev:null});const a=()=>{Re(e,s,t)};return n.oncancel=a,n.onremove=a,t.persist||(n.onfinish=a),n};function Pe(t,e,s){const i=oe(t);if(!i.length)return;const[r]=i,n=kt(r,e),o=Pt(e,r,n);let a=Ct(r,o);if(X(s))return a;if(Dt(a,At),0===At.t||1===At.t){if(!1===s)return At.n;{const t=le(r,At,s,!1);return`${pt(t.n,A.precision)}${t.u}`}}}const Fe=(t,e)=>{if(!X(e))return e.duration=c,e.composition=St(e.composition,r.none),new Ae(t,e,null,0,!0).resume()},Me=(t,e,s)=>{const i=ne(t);for(let t=0,r=i.length;t<r;t++)Re(i[t],s,e&&e.controlAnimation&&e);return Kt(i,e,s),i},Ve=(t,e)=>{let s=t.iterationDuration;if(s===c&&(s=0),X(e))return s;if(z(+e))return+e;const i=e,r=t?t.labels:null,n=!Y(r),o=((t,e)=>{if(P(e,"<")){const s="<"===e[1],i=t._tail,r=i?i._offset+i._delay:0;return s?r:r+i.duration}})(t,i),a=!X(o),h=C.exec(i);if(h){const t=h[0],e=i.split(t),l=n&&e[0]?r[e[0]]:s,d=a?o:n?l:s,c=+e[1];return Nt(d,c,t[0])}return a?o:n?X(r[i])?s:r[i]:s};function ze(t,e,s,i,r,n){const o=z(t.duration)&&t.duration<=c?s-c:s;e.composition&&Rt(e,o,1,1,1);const a=i?new Ae(i,t,e,o,!1,r,n):new ie(t,e,o);return e.composition&&a.init(!0),xt(e,a),bt(e,t=>{const s=t._offset+t._delay+t.duration;s>e.iterationDuration&&(e.iterationDuration=s)}),e.duration=function(t){return gt((t.iterationDuration+t._loopDelay)*t.iterationCount-t._loopDelay)||c}(e),e}let Oe=0;class He extends ie{constructor(t={}){super(t,null,0),++Oe,this.id=X(t.id)?Oe:t.id,this.duration=0,this.labels={};const e=t.defaults,s=A.defaults;this.defaults=e?_t(e,s):s,this.composition=St(t.composition,!0),this.onRender=t.onRender||s.onRender;const i=St(t.playbackEase,s.playbackEase);this._ease=i?be(i):null,this.iterationDuration=0}add(t,e,s){const i=V(e),r=V(t);if(i||r){if(this._hasChildren=!0,i){const i=e;if(H(s)){const e=s,r=ne(t),n=this.duration,o=this.iterationDuration,a=i.id;let h=0;const l=r.length;r.forEach(t=>{const s={...i};this.duration=n,this.iterationDuration=o,X(a)||(s.id=a+"-"+h),ze(s,this,Ve(this,e(t,h,l,this)),t,h,l),h++})}else ze(i,this,Ve(this,s),t)}else ze(t,this,Ve(this,e));return this.composition&&this.init(!0),this}}sync(t,e){if(X(t)||t&&X(t.pause))return this;t.pause();const s=+(t.effect?t.effect.getTiming().duration:t.duration);return this.add(t,{currentTime:[0,s],duration:s,delay:0,ease:"linear",playbackEase:"linear"},e)}set(t,e,s){return X(e)?this:(e.duration=c,e.composition=r.replace,this.add(t,e,s))}call(t,e){return X(t)||t&&!H(t)?this:this.add({duration:0,delay:0,onComplete:()=>t(this)},e)}label(t,e){return X(t)||t&&!O(t)||(this.labels[t]=Ve(this,e)),this}remove(t,e){return Kt(ne(t),this,e),this}stretch(t){const e=this.duration;if(e===yt(t))return this;const s=t/e,i=this.labels;bt(this,t=>t.stretch(t.duration*s));for(let t in i)i[t]*=s;return super.stretch(t)}refresh(){return bt(this,t=>{t.refresh&&t.refresh()}),this}revert(){return super.revert(),bt(this,t=>t.revert,!0),Ft(this)}then(t){return super.then(t)}}const Xe=t=>new He(t).init();class Ye{constructor(t,e){I.current&&I.current.register(this);const s=()=>{if(this.callbacks.completed)return;let t=!0;for(let e in this.animations)if(!this.animations[e].paused&&t){t=!1;break}t&&this.callbacks.complete()},i={onBegin:()=>{this.callbacks.completed&&this.callbacks.reset(),this.callbacks.play()},onComplete:s,onPause:s},n={v:1,autoplay:!1},o={};if(this.targets=[],this.animations={},this.callbacks=null,!X(t)&&!X(e)){for(let t in e){const s=e[t];G(t)?o[t]=s:P(t,"on")?n[t]=s:i[t]=s}this.callbacks=new Ae({v:0},n);for(let e in o){const s=o[e],n=V(s);let a={},h="+=0";if(n){const t=s.unit;O(t)&&(h+=t)}else a.duration=s;a[e]=n?_t({to:h},s):h;const l=_t(i,a);l.composition=r.replace,l.autoplay=!1;const d=this.animations[e]=new Ae(t,l,null,0,!1).init();this.targets.length||this.targets.push(...d.targets),this[e]=(t,e,s)=>{const i=d._head;if(X(t)&&i){const t=i._numbers;return t&&t.length?t:i._modifier(i._number)}return bt(d,e=>{if(M(t))for(let s=0,i=t.length;s<i;s++)X(e._numbers[s])||(e._fromNumbers[s]=e._modifier(e._numbers[s]),e._toNumbers[s]=t[s]);else e._fromNumber=e._modifier(e._number),e._toNumber=t;X(s)||(e._ease=be(s)),e._currentTime=0}),X(e)||d.stretch(e),d.reset(!0).resume(),this}}}}revert(){for(let t in this.animations)this[t]=v,this.animations[t].revert();return this.animations={},this.targets.length=0,this.callbacks&&this.callbacks.revert(),this}}const We=(t,e,s,i,r)=>i+(t-e)/(s-e)*(r-i);var Ue=Object.freeze({__proto__:null,clamp:ct,damp:(t,e,s,i)=>i?1===i?e:ft(t,e,1-Math.exp(-i*s*.1)):t,degToRad:t=>t*Math.PI/180,lerp:ft,mapRange:We,padEnd:(t,e,s)=>`${t}`.padEnd(e,s),padStart:(t,e,s)=>`${t}`.padStart(e,s),radToDeg:t=>180*t/Math.PI,round:pt,roundPad:(t,e)=>(+t).toFixed(e),snap:mt,wrap:(t,e,s)=>((t-e)%(s-e)+(s-e))%(s-e)+e});const qe=10*p;class je{constructor(t={}){const e=!X(t.bounce)||!X(t.duration);this.timeStep=.02,this.restThreshold=5e-4,this.restDuration=200,this.maxDuration=6e4,this.maxRestSteps=this.restDuration/this.timeStep/p,this.maxIterations=this.maxDuration/this.timeStep/p,this.bn=ct(St(t.bounce,.5),-1,1),this.pd=ct(St(t.duration,628),10*A.timeScale,qe*A.timeScale),this.m=ct(St(t.mass,1),1,qe),this.s=ct(St(t.stiffness,100),c,qe),this.d=ct(St(t.damping,10),c,qe),this.v=ct(St(t.velocity,0),-1e4,qe),this.w0=0,this.zeta=0,this.wd=0,this.b=0,this.completed=!1,this.solverDuration=0,this.settlingDuration=0,this.parent=null,this.onComplete=t.onComplete||v,e&&this.calculateSDFromBD(),this.compute(),this.ease=t=>{const e=t*this.settlingDuration,s=this.completed,i=this.pd;return e>=i&&!s&&(this.completed=!0,this.onComplete(this.parent)),e<i&&s&&(this.completed=!1),0===t||1===t?t:this.solve(t*this.solverDuration)}}solve(t){const{zeta:e,w0:s,wd:i,b:r}=this;let n=t;return n=e<1?it(-n*e*s)*(1*et(i*n)+r*tt(i*n)):1===e?(1+r*n)*it(-n*s):((1+r)*it((-e*s+i)*n)+(1-r)*it((-e*s-i)*n))/2,1-n}calculateSDFromBD(){const t=1===A.timeScale?this.pd/p:this.pd;this.m=1,this.v=0,this.s=J(2*lt/t,2),this.bn>=0?this.d=4*(1-this.bn)*lt/t:this.d=4*lt/(t*(1+this.bn)),this.s=pt(ct(this.s,c,qe),3),this.d=pt(ct(this.d,c,300),3)}calculateBDFromSD(){const t=2*lt/K(this.s);this.pd=t*(1===A.timeScale?p:1);const e=this.d/(2*K(this.s));this.bn=e<=1?1-this.d*t/(4*lt):4*lt/(this.d*t)-1,this.bn=pt(ct(this.bn,-1,1),3),this.pd=pt(ct(this.pd,10*A.timeScale,qe*A.timeScale),3)}compute(){const{maxRestSteps:t,maxIterations:e,restThreshold:s,timeStep:i,m:r,d:n,s:o,v:a}=this,h=this.w0=ct(K(o/r),c,p),l=this.zeta=n/(2*K(o*r));l<1?(this.wd=h*K(1-l*l),this.b=(l*h-a)/this.wd):1===l?(this.wd=0,this.b=-a+h):(this.wd=h*K(l*l-1),this.b=(l*h-a)/this.wd);let d=0,u=0,m=0;for(;u<=t&&m<=e;)st(1-this.solve(d))<s?u++:u=0,this.solverDuration=d,d+=i,m++;this.settlingDuration=pt(this.solverDuration*p,0)*A.timeScale}get bounce(){return this.bn}set bounce(t){this.bn=ct(St(t,1),-1,1),this.calculateSDFromBD(),this.compute()}get duration(){return this.pd}set duration(t){this.pd=ct(St(t,1),10*A.timeScale,qe*A.timeScale),this.calculateSDFromBD(),this.compute()}get stiffness(){return this.s}set stiffness(t){this.s=ct(St(t,100),c,qe),this.calculateBDFromSD(),this.compute()}get damping(){return this.d}set damping(t){this.d=ct(St(t,10),c,qe),this.calculateBDFromSD(),this.compute()}get mass(){return this.m}set mass(t){this.m=ct(St(t,1),1,qe),this.compute()}get velocity(){return this.v}set velocity(t){this.v=ct(St(t,0),-1e4,qe),this.compute()}}const Ge=t=>new je(t),Qe=t=>(console.warn("createSpring() is deprecated use spring() instead"),new je(t)),Ze=t=>{t.cancelable&&t.preventDefault()};class Je{constructor(t){this.el=t,this.zIndex=0,this.parentElement=null,this.classList={add:v,remove:v}}get x(){return this.el.x||0}set x(t){this.el.x=t}get y(){return this.el.y||0}set y(t){this.el.y=t}get width(){return this.el.width||0}set width(t){this.el.width=t}get height(){return this.el.height||0}set height(t){this.el.height=t}getBoundingClientRect(){return{top:this.y,right:this.x,bottom:this.y+this.height,left:this.x+this.width}}}class Ke{constructor(t){this.$el=t,this.inlineTransforms=[],this.point=new DOMPoint,this.inversedMatrix=this.getMatrix().inverse()}normalizePoint(t,e){return this.point.x=t,this.point.y=e,this.point.matrixTransform(this.inversedMatrix)}traverseUp(t){let e=this.$el.parentElement,s=0;for(;e&&e!==i;)t(e,s),e=e.parentElement,s++}getMatrix(){const t=new DOMMatrix;return this.traverseUp(e=>{const s=getComputedStyle(e).transform;if(s){const e=new DOMMatrix(s);t.preMultiplySelf(e)}}),t}remove(){this.traverseUp((t,e)=>{this.inlineTransforms[e]=t.style.transform,t.style.transform="none"})}revert(){this.traverseUp((t,e)=>{const s=this.inlineTransforms[e];""===s?t.style.removeProperty("transform"):t.style.transform=s})}}const ts=(t,e)=>t&&H(t)?t(e):t;let es=0;class ss{constructor(t,e={}){if(!t)return;I.current&&I.current.register(this);const r=e.x,n=e.y,o=e.trigger,a=e.modifier,h=e.releaseEase,l=h&&be(h),d=!X(h)&&!X(h.ease),c=V(r)&&!X(r.mapTo)?r.mapTo:"translateX",p=V(n)&&!X(n.mapTo)?n.mapTo:"translateY",m=ts(e.container,this);this.containerArray=M(m)?m:null,this.$container=m&&!this.containerArray?ne(m)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.$target=V(t)?new Je(t):ne(t)[0],this.$trigger=ne(o||t)[0],this.fixed="fixed"===Pe(this.$target,"position"),this.isFinePointer=!0,this.containerPadding=[0,0,0,0],this.containerFriction=0,this.releaseContainerFriction=0,this.snapX=0,this.snapY=0,this.scrollSpeed=0,this.scrollThreshold=0,this.dragSpeed=0,this.dragThreshold=3,this.maxVelocity=0,this.minVelocity=0,this.velocityMultiplier=0,this.cursor=!1,this.releaseXSpring=d?h:Ge({mass:St(e.releaseMass,1),stiffness:St(e.releaseStiffness,80),damping:St(e.releaseDamping,20)}),this.releaseYSpring=d?h:Ge({mass:St(e.releaseMass,1),stiffness:St(e.releaseStiffness,80),damping:St(e.releaseDamping,20)}),this.releaseEase=l||ge.outQuint,this.hasReleaseSpring=d,this.onGrab=e.onGrab||v,this.onDrag=e.onDrag||v,this.onRelease=e.onRelease||v,this.onUpdate=e.onUpdate||v,this.onSettle=e.onSettle||v,this.onSnap=e.onSnap||v,this.onResize=e.onResize||v,this.onAfterResize=e.onAfterResize||v,this.disabled=[0,0];const f={};if(a&&(f.modifier=a),X(r)||!0===r)f[c]=0;else if(V(r)){const t=r,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[c]=e}else!1===r&&(f[c]=0,this.disabled[0]=1);if(X(n)||!0===n)f[p]=0;else if(V(n)){const t=n,e={};t.modifier&&(e.modifier=t.modifier),t.composition&&(e.composition=t.composition),f[p]=e}else!1===n&&(f[p]=0,this.disabled[1]=1);this.animate=new Ye(this.$target,f),this.xProp=c,this.yProp=p,this.destX=0,this.destY=0,this.deltaX=0,this.deltaY=0,this.scroll={x:0,y:0},this.coords=[this.x,this.y,0,0],this.snapped=[0,0],this.pointer=[0,0,0,0,0,0,0,0],this.scrollView=[0,0],this.dragArea=[0,0,0,0],this.containerBounds=[-u,u,u,-u],this.scrollBounds=[0,0,0,0],this.targetBounds=[0,0,0,0],this.window=[0,0],this.velocityStack=[0,0,0],this.velocityStackIndex=0,this.velocityTime=F(),this.velocity=0,this.angle=0,this.cursorStyles=null,this.triggerStyles=null,this.bodyStyles=null,this.targetStyles=null,this.touchActionStyles=null,this.transforms=new Ke(this.$target),this.overshootCoords={x:0,y:0},this.overshootTicker=new ie({autoplay:!1,onUpdate:()=>{this.updated=!0,this.manual=!0,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,1),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,1)},onComplete:()=>{this.manual=!1,this.disabled[0]||this.animate[this.xProp](this.overshootCoords.x,0),this.disabled[1]||this.animate[this.yProp](this.overshootCoords.y,0)}},null,0).init(),this.updateTicker=new ie({autoplay:!1,onUpdate:()=>this.update()},null,0).init(),this.contained=!X(m),this.manual=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.enabled=!1,this.initialized=!1,this.activeProp=this.disabled[1]?c:p,this.animate.callbacks.onRender=()=>{const t=this.updated,e=!(this.grabbed&&t)&&this.released,s=this.x,i=this.y,r=s-this.coords[2],n=i-this.coords[3];this.deltaX=r,this.deltaY=n,this.coords[2]=s,this.coords[3]=i,t&&(r||n)&&this.onUpdate(this),e?(this.computeVelocity(r,n),this.angle=ht(n,r)):this.updated=!1},this.animate.callbacks.onComplete=()=>{!this.grabbed&&this.released&&(this.released=!1),this.manual||(this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.onSettle(this))},this.resizeTicker=new ie({autoplay:!1,duration:150*A.timeScale,onComplete:()=>{this.onResize(this),this.refresh(),this.onAfterResize(this)}}).init(),this.parameters=e,this.resizeObserver=new ResizeObserver(()=>{this.initialized?this.resizeTicker.restart():this.initialized=!0}),this.enable(),this.refresh(),this.resizeObserver.observe(this.$container),V(t)||this.resizeObserver.observe(this.$target)}computeVelocity(t,e){const s=this.velocityTime,i=F(),r=i-s;if(r<17)return this.velocity;this.velocityTime=i;const n=this.velocityStack,o=this.velocityMultiplier,a=this.minVelocity,h=this.maxVelocity,l=this.velocityStackIndex;n[l]=pt(ct(K(t*t+e*e)/r*o,a,h),5);const d=at(n[0],n[1],n[2]);return this.velocity=d,this.velocityStackIndex=(l+1)%3,d}setX(t,e=!1){if(this.disabled[0])return;const s=pt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destX=s,this.snapped[0]=mt(s,this.snapX),this.animate[this.xProp](s,0),this.manual=!1,this}setY(t,e=!1){if(this.disabled[1])return;const s=pt(t,5);return this.overshootTicker.pause(),this.manual=!0,this.updated=!e,this.destY=s,this.snapped[1]=mt(s,this.snapY),this.animate[this.yProp](s,0),this.manual=!1,this}get x(){return pt(this.animate[this.xProp](),A.precision)}set x(t){this.setX(t,!1)}get y(){return pt(this.animate[this.yProp](),A.precision)}set y(t){this.setY(t,!1)}get progressX(){return We(this.x,this.containerBounds[3],this.containerBounds[1],0,1)}set progressX(t){this.setX(We(t,0,1,this.containerBounds[3],this.containerBounds[1]),!1)}get progressY(){return We(this.y,this.containerBounds[0],this.containerBounds[2],0,1)}set progressY(t){this.setY(We(t,0,1,this.containerBounds[0],this.containerBounds[2]),!1)}updateScrollCoords(){const t=pt(this.useWin?s.scrollX:this.$container.scrollLeft,0),e=pt(this.useWin?s.scrollY:this.$container.scrollTop,0),[i,r,n,o]=this.containerPadding,a=this.scrollThreshold;this.scroll.x=t,this.scroll.y=e,this.scrollBounds[0]=e-this.targetBounds[0]+i-a,this.scrollBounds[1]=t-this.targetBounds[1]-r+a,this.scrollBounds[2]=e-this.targetBounds[2]-n+a,this.scrollBounds[3]=t-this.targetBounds[3]+o-a}updateBoundingValues(){const t=this.$container;if(!t)return;const e=this.x,r=this.y,n=this.coords[2],o=this.coords[3];this.coords[2]=0,this.coords[3]=0,this.setX(0,!0),this.setY(0,!0),this.transforms.remove();const a=this.window[0]=s.innerWidth,h=this.window[1]=s.innerHeight,l=this.useWin,d=t.scrollWidth,c=t.scrollHeight,u=this.fixed,p=t.getBoundingClientRect(),[m,f,g,y]=this.containerPadding;this.dragArea[0]=l?0:p.left,this.dragArea[1]=l?0:p.top,this.scrollView[0]=l?ct(d,a,d):d,this.scrollView[1]=l?ct(c,h,c):c,this.updateScrollCoords();const{width:v,height:_,left:b,top:T,right:x,bottom:w}=t.getBoundingClientRect();this.dragArea[2]=pt(l?ct(v,a,a):v,0),this.dragArea[3]=pt(l?ct(_,h,h):_,0);const S=Pe(t,"overflow"),$="visible"===S,k="hidden"===S;if(this.canScroll=!u&&this.contained&&(t===i.body&&$||!k&&!$)&&(d>this.dragArea[2]+y-f||c>this.dragArea[3]+m-g)&&(!this.containerArray||this.containerArray&&!M(this.containerArray)),this.contained){const e=this.scroll.x,s=this.scroll.y,i=this.canScroll,r=this.$target.getBoundingClientRect(),n=i?l?0:t.scrollLeft:0,o=i?l?0:t.scrollTop:0,d=i?this.scrollView[0]-n-v:0,c=i?this.scrollView[1]-o-_:0;this.targetBounds[0]=pt(r.top+s-(l?0:T),0),this.targetBounds[1]=pt(r.right+e-(l?a:x),0),this.targetBounds[2]=pt(r.bottom+s-(l?h:w),0),this.targetBounds[3]=pt(r.left+e-(l?0:b),0),this.containerArray?(this.containerBounds[0]=this.containerArray[0]+m,this.containerBounds[1]=this.containerArray[1]-f,this.containerBounds[2]=this.containerArray[2]-g,this.containerBounds[3]=this.containerArray[3]+y):(this.containerBounds[0]=-pt(r.top-(u?ct(T,0,h):T)+o-m,0),this.containerBounds[1]=-pt(r.right-(u?ct(x,0,a):x)-d+f,0),this.containerBounds[2]=-pt(r.bottom-(u?ct(w,0,h):w)-c+g,0),this.containerBounds[3]=-pt(r.left-(u?ct(b,0,a):b)+n-y,0))}this.transforms.revert(),this.coords[2]=n,this.coords[3]=o,this.setX(e,!0),this.setY(r,!0)}isOutOfBounds(t,e,s){if(!this.contained)return 0;const[i,r,n,o]=t,[a,h]=this.disabled,l=!a&&e<o||!a&&e>r,d=!h&&s<i||!h&&s>n;return l&&!d?1:!l&&d?2:l&&d?3:0}refresh(){const t=this.parameters,e=t.x,r=t.y,n=ts(t.container,this),o=ts(t.containerPadding,this)||0,a=M(o)?o:[o,o,o,o],h=this.x,l=this.y,d=ts(t.cursor,this),c={onHover:"grab",onGrab:"grabbing"};if(d){const{onHover:t,onGrab:e}=d;t&&(c.onHover=t),e&&(c.onGrab=e)}const u=ts(t.dragThreshold,this),p={mouse:3,touch:7};if(z(u))p.mouse=u,p.touch=u;else if(u){const{mouse:t,touch:e}=u;X(t)||(p.mouse=t),X(e)||(p.touch=e)}this.containerArray=M(n)?n:null,this.$container=n&&!this.containerArray?ne(n)[0]:i.body,this.useWin=this.$container===i.body,this.$scrollContainer=this.useWin?s:this.$container,this.isFinePointer=matchMedia("(pointer:fine)").matches,this.containerPadding=St(a,[0,0,0,0]),this.containerFriction=ct(St(ts(t.containerFriction,this),.8),0,1),this.releaseContainerFriction=ct(St(ts(t.releaseContainerFriction,this),this.containerFriction),0,1),this.snapX=ts(V(e)&&!X(e.snap)?e.snap:t.snap,this),this.snapY=ts(V(r)&&!X(r.snap)?r.snap:t.snap,this),this.scrollSpeed=St(ts(t.scrollSpeed,this),1.5),this.scrollThreshold=St(ts(t.scrollThreshold,this),20),this.dragSpeed=St(ts(t.dragSpeed,this),1),this.dragThreshold=this.isFinePointer?p.mouse:p.touch,this.minVelocity=St(ts(t.minVelocity,this),0),this.maxVelocity=St(ts(t.maxVelocity,this),50),this.velocityMultiplier=St(ts(t.velocityMultiplier,this),1),this.cursor=!1!==d&&c,this.updateBoundingValues();const[m,f,g,y]=this.containerBounds;this.setX(ct(h,y,f),!0),this.setY(ct(l,m,g),!0)}update(){if(this.updateScrollCoords(),this.canScroll){const[t,e,s,i]=this.containerPadding,[r,n]=this.scrollView,o=this.dragArea[2],a=this.dragArea[3],h=this.scroll.x,l=this.scroll.y,d=this.$container.scrollWidth,c=this.$container.scrollHeight,u=this.useWin?ct(d,this.window[0],d):d,p=this.useWin?ct(c,this.window[1],c):c,m=r-u,f=n-p;this.dragged&&m>0&&(this.coords[0]-=m,this.scrollView[0]=u),this.dragged&&f>0&&(this.coords[1]-=f,this.scrollView[1]=p);const g=10*this.scrollSpeed,y=this.scrollThreshold,[v,_]=this.coords,[b,T,x,w]=this.scrollBounds,S=pt(ct((_-b+t)/y,-1,0)*g,0),$=pt(ct((v-T-e)/y,0,1)*g,0),k=pt(ct((_-x-s)/y,0,1)*g,0),E=pt(ct((v-w+i)/y,-1,0)*g,0);if(S||k||E||$){const[t,e]=this.disabled;let s=h,i=l;t||(s=pt(ct(h+(E||$),0,r-o),0),this.coords[0]-=h-s),e||(i=pt(ct(l+(S||k),0,n-a),0),this.coords[1]-=l-i),this.useWin?this.$scrollContainer.scrollBy(-(h-s),-(l-i)):this.$scrollContainer.scrollTo(s,i)}}const[t,e,s,i]=this.containerBounds,[r,n,o,a,h,l]=this.pointer;this.coords[0]+=(r-h)*this.dragSpeed,this.coords[1]+=(n-l)*this.dragSpeed,this.pointer[4]=r,this.pointer[5]=n;const[d,c]=this.coords,[u,p]=this.snapped,m=(1-this.containerFriction)*this.dragSpeed;this.setX(d>e?e+(d-e)*m:d<i?i+(d-i)*m:d,!1),this.setY(c>s?s+(c-s)*m:c<t?t+(c-t)*m:c,!1),this.computeVelocity(r-h,n-l),this.angle=ht(n-a,r-o);const[f,g]=this.snapped;(f!==u&&this.snapX||g!==p&&this.snapY)&&this.onSnap(this)}stop(){this.updateTicker.pause(),this.overshootTicker.pause();for(let t in this.animate.animations)this.animate.animations[t].pause();return Kt([this],null,"x"),Kt([this],null,"y"),Kt([this],null,"progressX"),Kt([this],null,"progressY"),Kt([this.scroll]),Kt([this.overshootCoords]),this}scrollInView(t,e=0,s=ge.inOutQuad){this.updateScrollCoords();const i=this.destX,r=this.destY,n=this.scroll,o=this.scrollBounds,a=this.canScroll;if(!this.containerArray&&this.isOutOfBounds(o,i,r)){const[h,l,d,c]=o,p=pt(ct(r-h,-u,0),0),m=pt(ct(i-l,0,u),0),f=pt(ct(r-d,0,u),0),g=pt(ct(i-c,-u,0),0);new Ae(n,{x:pt(n.x+(g?g-e:m?m+e:0),0),y:pt(n.y+(p?p-e:f?f+e:0),0),duration:X(t)?350*A.timeScale:t,ease:s,onUpdate:()=>{this.canScroll=!1,this.$scrollContainer.scrollTo(n.x,n.y)}}).init().then(()=>{this.canScroll=a})}return this}handleHover(){this.isFinePointer&&this.cursor&&!this.cursorStyles&&(this.cursorStyles=Fe(this.$trigger,{cursor:this.cursor.onHover}))}animateInView(t,e=0,s=ge.inOutQuad){this.stop(),this.updateBoundingValues();const i=this.x,r=this.y,[n,o,a,h]=this.containerPadding,l=this.scroll.y-this.targetBounds[0]+n+e,d=this.scroll.x-this.targetBounds[1]-o-e,c=this.scroll.y-this.targetBounds[2]-a-e,u=this.scroll.x-this.targetBounds[3]+h+e,p=this.isOutOfBounds([l,d,c,u],i,r);if(p){const[e,n]=this.disabled,o=ct(mt(i,this.snapX),u,d),a=ct(mt(r,this.snapY),l,c),h=X(t)?350*A.timeScale:t;e||1!==p&&3!==p||this.animate[this.xProp](o,h,s),n||2!==p&&3!==p||this.animate[this.yProp](a,h,s)}return this}handleDown(t){const e=t.target;if(this.grabbed||"range"===e.type)return;t.stopPropagation(),this.grabbed=!0,this.released=!1,this.stop(),this.updateBoundingValues();const s=t.changedTouches,r=s?s[0].clientX:t.clientX,n=s?s[0].clientY:t.clientY,{x:o,y:a}=this.transforms.normalizePoint(r,n),[h,l,d,c]=this.containerBounds,u=(1-this.containerFriction)*this.dragSpeed,p=this.x,m=this.y;this.coords[0]=this.coords[2]=u?p>l?l+(p-l)/u:p<c?c+(p-c)/u:p:p,this.coords[1]=this.coords[3]=u?m>d?d+(m-d)/u:m<h?h+(m-h)/u:m:m,this.pointer[0]=o,this.pointer[1]=a,this.pointer[2]=o,this.pointer[3]=a,this.pointer[4]=o,this.pointer[5]=a,this.pointer[6]=o,this.pointer[7]=a,this.deltaX=0,this.deltaY=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null);const f=Pe(this.$target,"zIndex",!1);es=(f>es?f:es)+1,this.targetStyles=Fe(this.$target,{zIndex:es}),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.isFinePointer&&this.cursor&&(this.bodyStyles=Fe(i.body,{cursor:this.cursor.onGrab})),this.scrollInView(100,0,ge.out(3)),this.onGrab(this),i.addEventListener("touchmove",this),i.addEventListener("touchend",this),i.addEventListener("touchcancel",this),i.addEventListener("mousemove",this),i.addEventListener("mouseup",this),i.addEventListener("selectstart",this)}handleMove(t){if(!this.grabbed)return;const e=t.changedTouches,s=e?e[0].clientX:t.clientX,i=e?e[0].clientY:t.clientY,{x:r,y:n}=this.transforms.normalizePoint(s,i),o=r-this.pointer[6],a=n-this.pointer[7];let h=t.target,l=!1,d=!1,c=!1;for(;e&&h&&h!==this.$trigger;){const t=Pe(h,"overflow-y");if("hidden"!==t&&"visible"!==t){const{scrollTop:t,scrollHeight:e,clientHeight:s}=h;if(e>s){c=!0,l=t<=3,d=t>=e-s-3;break}}h=h.parentElement}c&&(!l&&!d||l&&a<0||d&&a>0)?(this.pointer[0]=r,this.pointer[1]=n,this.pointer[2]=r,this.pointer[3]=n,this.pointer[4]=r,this.pointer[5]=n,this.pointer[6]=r,this.pointer[7]=n):(Ze(t),this.triggerStyles||(this.triggerStyles=Fe(this.$trigger,{pointerEvents:"none"})),this.$trigger.addEventListener("touchstart",Ze,{passive:!1}),this.$trigger.addEventListener("touchmove",Ze,{passive:!1}),this.$trigger.addEventListener("touchend",Ze),(this.dragged||!this.disabled[0]&&st(o)>this.dragThreshold||!this.disabled[1]&&st(a)>this.dragThreshold)&&(this.updateTicker.resume(),this.pointer[2]=this.pointer[0],this.pointer[3]=this.pointer[1],this.pointer[0]=r,this.pointer[1]=n,this.dragged=!0,this.released=!1,this.onDrag(this)))}handleUp(){if(!this.grabbed)return;this.updateTicker.pause(),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null);const[t,e]=this.disabled,[s,n,o,a,h,l]=this.pointer,[d,c,u,p]=this.containerBounds,[m,f]=this.snapped,g=this.releaseXSpring,y=this.releaseYSpring,v=this.releaseEase,_=this.hasReleaseSpring,b=this.overshootCoords,T=this.x,x=this.y,w=this.computeVelocity(s-h,n-l),S=this.angle=ht(n-a,s-o),$=150*w,k=(1-this.releaseContainerFriction)*this.dragSpeed,E=T+et(S)*$,C=x+tt(S)*$,N=E>c?c+(E-c)*k:E<p?p+(E-p)*k:E,D=C>u?u+(C-u)*k:C<d?d+(C-d)*k:C,I=this.destX=ct(pt(mt(N,this.snapX),5),p,c),B=this.destY=ct(pt(mt(D,this.snapY),5),d,u),R=this.isOutOfBounds(this.containerBounds,E,C);let L=0,P=0,F=v,M=v,V=0;if(b.x=T,b.y=x,!t){const t=I===c?T>c?-1:1:T<p?-1:1,s=pt(T-I,0);g.velocity=e&&_?s?$*t/st(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=g;L=T===I?0:_?r:r-n*A.timeScale,_&&(F=i),L>V&&(V=L)}if(!e){const e=B===u?x>u?-1:1:x<d?-1:1,s=pt(x-B,0);y.velocity=t&&_?s?$*e/st(s):0:w;const{ease:i,settlingDuration:r,restDuration:n}=y;P=x===B?0:_?r:r-n*A.timeScale,_&&(M=i),P>V&&(V=P)}if(!_&&R&&k&&(L||P)){const t=r.blend;new Ae(b,{x:{to:N,duration:.65*L},y:{to:D,duration:.65*P},ease:v,composition:t}).init(),new Ae(b,{x:{to:I,duration:L},y:{to:B,duration:P},ease:v,composition:t}).init(),this.overshootTicker.stretch(at(L,P)).restart()}else t||this.animate[this.xProp](I,L,F),e||this.animate[this.yProp](B,P,M);this.scrollInView(V,this.scrollThreshold,v);let z=!1;I!==m&&(this.snapped[0]=I,this.snapX&&(z=!0)),B!==f&&this.snapY&&(this.snapped[1]=B,this.snapY&&(z=!0)),z&&this.onSnap(this),this.grabbed=!1,this.dragged=!1,this.updated=!0,this.released=!0,this.onRelease(this),this.$trigger.removeEventListener("touchstart",Ze),this.$trigger.removeEventListener("touchmove",Ze),this.$trigger.removeEventListener("touchend",Ze),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this)}reset(){return this.stop(),this.resizeTicker.pause(),this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.setX(0,!0),this.setY(0,!0),this.coords[0]=0,this.coords[1]=0,this.pointer[0]=0,this.pointer[1]=0,this.pointer[2]=0,this.pointer[3]=0,this.pointer[4]=0,this.pointer[5]=0,this.pointer[6]=0,this.pointer[7]=0,this.velocity=0,this.velocityStack[0]=0,this.velocityStack[1]=0,this.velocityStack[2]=0,this.velocityStackIndex=0,this.angle=0,this}enable(){return this.enabled||(this.enabled=!0,this.$target.classList.remove("is-disabled"),this.touchActionStyles=Fe(this.$trigger,{touchAction:this.disabled[0]?"pan-x":this.disabled[1]?"pan-y":"none"}),this.$trigger.addEventListener("touchstart",this,{passive:!0}),this.$trigger.addEventListener("mousedown",this,{passive:!0}),this.$trigger.addEventListener("mouseenter",this)),this}disable(){return this.enabled=!1,this.grabbed=!1,this.dragged=!1,this.updated=!1,this.released=!1,this.canScroll=!1,this.touchActionStyles.revert(),this.cursorStyles&&(this.cursorStyles.revert(),this.cursorStyles=null),this.triggerStyles&&(this.triggerStyles.revert(),this.triggerStyles=null),this.bodyStyles&&(this.bodyStyles.revert(),this.bodyStyles=null),this.targetStyles&&(this.targetStyles.revert(),this.targetStyles=null),this.$target.classList.add("is-disabled"),this.$trigger.removeEventListener("touchstart",this),this.$trigger.removeEventListener("mousedown",this),this.$trigger.removeEventListener("mouseenter",this),i.removeEventListener("touchmove",this),i.removeEventListener("touchend",this),i.removeEventListener("touchcancel",this),i.removeEventListener("mousemove",this),i.removeEventListener("mouseup",this),i.removeEventListener("selectstart",this),this}revert(){return this.reset(),this.disable(),this.$target.classList.remove("is-disabled"),this.updateTicker.revert(),this.overshootTicker.revert(),this.resizeTicker.revert(),this.animate.revert(),this.resizeObserver.disconnect(),this}handleEvent(t){switch(t.type){case"mousedown":case"touchstart":this.handleDown(t);break;case"mousemove":case"touchmove":this.handleMove(t);break;case"mouseup":case"touchend":case"touchcancel":this.handleUp();break;case"mouseenter":this.handleHover();break;case"selectstart":Ze(t)}}}const is=(t=v)=>new ie({duration:1*A.timeScale,onComplete:t},null,0).resume(),rs=t=>{let e;return(...s)=>{let i,r,n,o;e&&(i=e.currentIteration,r=e.iterationProgress,n=e.reversed,o=e._alternate,e.revert());const a=t(...s);return a&&!H(a)&&a.revert&&(e=a),X(r)||(e.currentIteration=i,e.iterationProgress=(o&&i%2?!n:n)?1-r:r),a||v}};class ns{constructor(t={}){I.current&&I.current.register(this);const e=t.root;let r=i;e&&(r=e.current||e.nativeElement||ne(e)[0]||i);const n=t.defaults,o=A.defaults,a=t.mediaQueries;if(this.defaults=n?_t(n,o):o,this.root=r,this.constructors=[],this.revertConstructors=[],this.revertibles=[],this.constructorsOnce=[],this.revertConstructorsOnce=[],this.revertiblesOnce=[],this.once=!1,this.onceIndex=0,this.methods={},this.matches={},this.mediaQueryLists={},this.data={},a)for(let t in a){const e=s.matchMedia(a[t]);this.mediaQueryLists[t]=e,e.addEventListener("change",this)}}register(t){(this.once?this.revertiblesOnce:this.revertibles).push(t)}execute(t){let e=I.current,s=I.root,i=A.defaults;I.current=this,I.root=this.root,A.defaults=this.defaults;const r=this.mediaQueryLists;for(let t in r)this.matches[t]=r[t].matches;const n=t(this);return I.current=e,I.root=s,A.defaults=i,n}refresh(){return this.onceIndex=0,this.execute(()=>{let t=this.revertibles.length,e=this.revertConstructors.length;for(;t--;)this.revertibles[t].revert();for(;e--;)this.revertConstructors[e](this);this.revertibles.length=0,this.revertConstructors.length=0,this.constructors.forEach(t=>{const e=t(this);H(e)&&this.revertConstructors.push(e)})}),this}add(t,e){if(this.once=!1,H(t)){const e=t;this.constructors.push(e),this.execute(()=>{const t=e(this);H(t)&&this.revertConstructors.push(t)})}else this.methods[t]=(...t)=>this.execute(()=>e(...t));return this}addOnce(t){if(this.once=!0,H(t)){const e=this.onceIndex++;if(this.constructorsOnce[e])return this;const s=t;this.constructorsOnce[e]=s,this.execute(()=>{const t=s(this);H(t)&&this.revertConstructorsOnce.push(t)})}return this}keepTime(t){this.once=!0;const e=this.onceIndex++,s=this.constructorsOnce[e];if(H(s))return s(this);const i=rs(t);let r;return this.constructorsOnce[e]=i,this.execute(()=>{r=i(this)}),r}handleEvent(t){"change"===t.type&&this.refresh()}revert(){const t=this.revertibles,e=this.revertConstructors,s=this.revertiblesOnce,i=this.revertConstructorsOnce,r=this.mediaQueryLists;let n=t.length,o=e.length,a=s.length,h=i.length;for(;n--;)t[n].revert();for(;o--;)e[o](this);for(;a--;)s[a].revert();for(;h--;)i[h](this);for(let t in r)r[t].removeEventListener("change",this);t.length=0,e.length=0,this.constructors.length=0,s.length=0,i.length=0,this.constructorsOnce.length=0,this.onceIndex=0,this.matches={},this.methods={},this.mediaQueryLists={},this.data={}}}const os=(t,e)=>t&&H(t)?t(e):t,as=new Map;class hs{constructor(t){this.element=t,this.useWin=this.element===i.body,this.winWidth=0,this.winHeight=0,this.width=0,this.height=0,this.left=0,this.top=0,this.scale=1,this.zIndex=0,this.scrollX=0,this.scrollY=0,this.prevScrollX=0,this.prevScrollY=0,this.scrollWidth=0,this.scrollHeight=0,this.velocity=0,this.backwardX=!1,this.backwardY=!1,this.scrollTicker=new ie({autoplay:!1,onBegin:()=>this.dataTimer.resume(),onUpdate:()=>{const t=this.backwardX||this.backwardY;bt(this,t=>t.handleScroll(),t)},onComplete:()=>this.dataTimer.pause()}).init(),this.dataTimer=new ie({autoplay:!1,frameRate:30,onUpdate:t=>{const e=t.deltaTime,s=this.prevScrollX,i=this.prevScrollY,r=this.scrollX,n=this.scrollY,o=s-r,a=i-n;this.prevScrollX=r,this.prevScrollY=n,o&&(this.backwardX=s>r),a&&(this.backwardY=i>n),this.velocity=pt(e>0?Math.sqrt(o*o+a*a)/e:0,5)}}).init(),this.resizeTicker=new ie({autoplay:!1,duration:250*A.timeScale,onComplete:()=>{this.updateWindowBounds(),this.refreshScrollObservers(),this.handleScroll()}}).init(),this.wakeTicker=new ie({autoplay:!1,duration:500*A.timeScale,onBegin:()=>{this.scrollTicker.resume()},onComplete:()=>{this.scrollTicker.pause()}}).init(),this._head=null,this._tail=null,this.updateScrollCoords(),this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll(),this.resizeObserver=new ResizeObserver(()=>this.resizeTicker.restart()),this.resizeObserver.observe(this.element),(this.useWin?s:this.element).addEventListener("scroll",this,!1)}updateScrollCoords(){const t=this.useWin,e=this.element;this.scrollX=pt(t?s.scrollX:e.scrollLeft,0),this.scrollY=pt(t?s.scrollY:e.scrollTop,0)}updateWindowBounds(){this.winWidth=s.innerWidth,this.winHeight=(()=>{const t=i.createElement("div");i.body.appendChild(t),t.style.height="100lvh";const e=t.offsetHeight;return i.body.removeChild(t),e})()}updateBounds(){const t=getComputedStyle(this.element),e=this.element;let s,i;if(this.scrollWidth=e.scrollWidth+parseFloat(t.marginLeft)+parseFloat(t.marginRight),this.scrollHeight=e.scrollHeight+parseFloat(t.marginTop)+parseFloat(t.marginBottom),this.updateWindowBounds(),this.useWin)s=this.winWidth,i=this.winHeight;else{const t=e.getBoundingClientRect();s=e.clientWidth,i=e.clientHeight,this.top=t.top,this.left=t.left,this.scale=t.width?s/t.width:t.height?i/t.height:1}this.width=s,this.height=i}refreshScrollObservers(){bt(this,t=>{t._debug&&t.removeDebug()}),this.updateBounds(),bt(this,t=>{t.refresh(),t._debug&&t.debug()})}refresh(){this.updateWindowBounds(),this.updateBounds(),this.refreshScrollObservers(),this.handleScroll()}handleScroll(){this.updateScrollCoords(),this.wakeTicker.restart()}handleEvent(t){"scroll"===t.type&&this.handleScroll()}revert(){this.scrollTicker.cancel(),this.dataTimer.cancel(),this.resizeTicker.cancel(),this.wakeTicker.cancel(),this.resizeObserver.disconnect(),(this.useWin?s:this.element).removeEventListener("scroll",this),as.delete(this.element)}}const ls=(t,e,s,i,r)=>{const n="min"===e,o="max"===e,a="top"===e||"left"===e||"start"===e||n?0:"bottom"===e||"right"===e||"end"===e||o?"100%":"center"===e?"50%":e,{n:h,u:l}=Dt(a,At);let d=h;return"%"===l?d=h/100*s:l&&(d=le(t,At,"px",!0).n),o&&i<0&&(d+=i),n&&r>0&&(d+=r),d},ds=(t,e,s,i,r)=>{let n;if(O(e)){const o=C.exec(e);if(o){const a=o[0],h=a[0],l=e.split(a),d="min"===l[0],c="max"===l[0],u=ls(t,l[0],s,i,r),p=ls(t,l[1],s,i,r);if(d){const e=Nt(ls(t,"min",s),p,h);n=e<u?u:e}else if(c){const e=Nt(ls(t,"max",s),p,h);n=e>u?u:e}else n=Nt(u,p,h)}else n=ls(t,e,s,i,r)}else n=e;return pt(n,0)},cs=t=>{let e;const s=t.targets;for(let t=0,i=s.length;t<i;t++){const i=s[t];if(i[o]){e=i;break}}return e};let us=0;const ps=["#FF4B4B","#FF971B","#FFC730","#F9F640","#7AFF5A","#18FF74","#17E09B","#3CFFEC","#05DBE9","#33B3F1","#638CF9","#C563FE","#FF4FCF","#F93F8A"];class ms{constructor(t={}){I.current&&I.current.register(this);const e=St(t.sync,"play pause"),s=e?be(e):null,r=e&&("linear"===e||e===de),n=e&&!(s===de&&!r),o=e&&(z(e)||!0===e||r),a=e&&O(e)&&!n&&!o,h=a?e.split(" ").map(t=>()=>{const e=this.linked;return e&&e[t]?e[t]():null}):null,l=a&&h.length>2;this.index=us++,this.id=X(t.id)?this.index:t.id,this.container=(t=>{const e=t&&ne(t)[0]||i.body;let s=as.get(e);return s||(s=new hs(e),as.set(e,s)),s})(t.container),this.target=null,this.linked=null,this.repeat=null,this.horizontal=null,this.enter=null,this.leave=null,this.sync=n||o||!!h,this.syncEase=n?s:null,this.syncSmooth=o?!0===e||r?1:e:null,this.onSyncEnter=h&&!l&&h[0]?h[0]:v,this.onSyncLeave=h&&!l&&h[1]?h[1]:v,this.onSyncEnterForward=h&&l&&h[0]?h[0]:v,this.onSyncLeaveForward=h&&l&&h[1]?h[1]:v,this.onSyncEnterBackward=h&&l&&h[2]?h[2]:v,this.onSyncLeaveBackward=h&&l&&h[3]?h[3]:v,this.onEnter=t.onEnter||v,this.onLeave=t.onLeave||v,this.onEnterForward=t.onEnterForward||v,this.onLeaveForward=t.onLeaveForward||v,this.onEnterBackward=t.onEnterBackward||v,this.onLeaveBackward=t.onLeaveBackward||v,this.onUpdate=t.onUpdate||v,this.onSyncComplete=t.onSyncComplete||v,this.reverted=!1,this.ready=!1,this.completed=!1,this.began=!1,this.isInView=!1,this.forceEnter=!1,this.hasEntered=!1,this.offset=0,this.offsetStart=0,this.offsetEnd=0,this.distance=0,this.prevProgress=0,this.thresholds=["start","end","end","start"],this.coords=[0,0,0,0],this.debugStyles=null,this.$debug=null,this._params=t,this._debug=St(t.debug,!1),this._next=null,this._prev=null,xt(this.container,this),is(()=>{if(!this.reverted){if(!this.target){const e=ne(t.target)[0];this.target=e||i.body,this.refresh()}this._debug&&this.debug()}})}link(t){if(t&&(t.pause(),this.linked=t,X(t)||(t.persist=!0),!this._params.target)){let e;X(t.targets)?bt(t,t=>{t.targets&&!e&&(e=cs(t))}):e=cs(t),this.target=e||i.body,this.refresh()}return this}get velocity(){return this.container.velocity}get backward(){return this.horizontal?this.container.backwardX:this.container.backwardY}get scroll(){return this.horizontal?this.container.scrollX:this.container.scrollY}get progress(){const t=(this.scroll-this.offsetStart)/this.distance;return t===1/0||isNaN(t)?0:pt(ct(t,0,1),6)}refresh(){this.ready=!0,this.reverted=!1;const t=this._params;return this.repeat=St(os(t.repeat,this),!0),this.horizontal="x"===St(os(t.axis,this),"y"),this.enter=St(os(t.enter,this),"end start"),this.leave=St(os(t.leave,this),"start end"),this.updateBounds(),this.handleScroll(),this}removeDebug(){return this.$debug&&(this.$debug.parentNode.removeChild(this.$debug),this.$debug=null),this.debugStyles&&(this.debugStyles.revert(),this.$debug=null),this}debug(){this.removeDebug();const t=this.container,e=this.horizontal,s=t.element.querySelector(":scope > .animejs-onscroll-debug"),r=i.createElement("div"),n=i.createElement("div"),o=i.createElement("div"),a=ps[this.index%ps.length],h=t.useWin,l=h?t.winWidth:t.width,d=h?t.winHeight:t.height,c=t.scrollWidth,u=t.scrollHeight,p=this.container.width>360?320:260,m=e?0:10,f=e?10:0,g=e?24:p/2,y=e?g:15,v=e?60:g,_=e?v:y,b=e?"repeat-x":"repeat-y",T=t=>e?"0px "+t+"px":t+"px 2px",x=t=>`linear-gradient(${e?90:0}deg, ${t} 2px, transparent 1px)`,w=(t,e,s,i,r)=>`position:${t};left:${e}px;top:${s}px;width:${i}px;height:${r}px;`;r.style.cssText=`${w("absolute",m,f,e?c:p,e?p:u)}\n pointer-events: none;\n z-index: ${this.container.zIndex++};\n display: flex;\n flex-direction: ${e?"column":"row"};\n filter: drop-shadow(0px 1px 0px rgba(0,0,0,.75));\n `,n.style.cssText=`${w("sticky",0,0,e?l:g,e?g:d)}`,s||(n.style.cssText+=`background:\n ${x("#FFFF")}${T(g-10)} / 100px 100px ${b},\n ${x("#FFF8")}${T(g-10)} / 10px 10px ${b};\n `),o.style.cssText=`${w("relative",0,0,e?c:g,e?g:u)}`,s||(o.style.cssText+=`background:\n ${x("#FFFF")}${T(0)} / ${e?"100px 10px":"10px 100px"} ${b},\n ${x("#FFF8")}${T(0)} / ${e?"10px 0px":"0px 10px"} ${b};\n `);const S=[" enter: "," leave: "];this.coords.forEach((t,s)=>{const r=s>1,h=(r?0:this.offset)+t,m=s%2,f=h<_,g=h>(r?e?l:d:e?c:u)-_,b=(r?m&&!f:!m&&!f)||g,T=i.createElement("div"),x=i.createElement("div"),$=e?b?"right":"left":b?"bottom":"top",k=b?(e?v:y)+(r?e?-1:g?0:-2:e?-1:-2):e?1:0;x.innerHTML=`${this.id}${S[m]}${this.thresholds[s]}`,T.style.cssText=`${w("absolute",0,0,v,y)}\n display: flex;\n flex-direction: ${e?"column":"row"};\n justify-content: flex-${r?"start":"end"};\n align-items: flex-${b?"end":"start"};\n border-${$}: 2px solid ${a};\n `,x.style.cssText=`\n overflow: hidden;\n max-width: ${p/2-10}px;\n height: ${y};\n margin-${e?b?"right":"left":b?"bottom":"top"}: -2px;\n padding: 1px;\n font-family: ui-monospace, monospace;\n font-size: 10px;\n letter-spacing: -.025em;\n line-height: 9px;\n font-weight: 600;\n text-align: ${e&&b||!e&&!r?"right":"left"};\n white-space: pre;\n text-overflow: ellipsis;\n color: ${m?a:"rgba(0,0,0,.75)"};\n background-color: ${m?"rgba(0,0,0,.65)":a};\n border: 2px solid ${m?a:"transparent"};\n border-${e?b?"top-left":"top-right":b?"top-left":"bottom-left"}-radius: 5px;\n border-${e?b?"bottom-left":"bottom-right":b?"top-right":"bottom-right"}-radius: 5px;\n `,T.appendChild(x);let E=h-k+(e?1:0);T.style[e?"left":"top"]=`${E}px`,(r?n:o).appendChild(T)}),r.appendChild(n),r.appendChild(o),t.element.appendChild(r),s||r.classList.add("animejs-onscroll-debug"),this.$debug=r,"static"===Pe(t.element,"position")&&(this.debugStyles=Fe(t.element,{position:"relative "}))}updateBounds(){let t;this._debug&&this.removeDebug();const e=this.target,s=this.container,r=this.horizontal,n=this.linked;let o,a=e;for(n&&(o=n.currentTime,n.seek(0,!0)),a.parentElement;a&&a!==s.element&&a!==i.body;){const e="sticky"===Pe(a,"position")&&Fe(a,{position:"static"});a=a.parentElement,e&&(t||(t=[]),t.push(e))}const h=e.getBoundingClientRect(),l=s.scale,d=(r?h.left+s.scrollX-s.left:h.top+s.scrollY-s.top)*l,c=(r?h.width:h.height)*l,u=r?s.width:s.height,p=(r?s.scrollWidth:s.scrollHeight)-u,m=this.enter,f=this.leave;let g="start",y="end",v="end",_="start";if(O(m)){const t=m.split(" ");v=t[0],g=t.length>1?t[1]:g}else if(V(m)){const t=m;X(t.container)||(v=t.container),X(t.target)||(g=t.target)}else z(m)&&(v=m);if(O(f)){const t=f.split(" ");_=t[0],y=t.length>1?t[1]:y}else if(V(f)){const t=f;X(t.container)||(_=t.container),X(t.target)||(y=t.target)}else z(f)&&(_=f);const b=ds(e,g,c),T=ds(e,y,c),x=b+d-u,w=T+d-p,S=ds(e,v,u,x,w),$=ds(e,_,u,x,w),k=b+d-S,E=T+d-$,C=E-k;this.offset=d,this.offsetStart=k,this.offsetEnd=E,this.distance=C<=0?0:C,this.thresholds=[g,y,v,_],this.coords=[b,T,S,$],t&&t.forEach(t=>t.revert()),n&&n.seek(o,!0),this._debug&&this.debug()}handleScroll(){if(!this.ready)return;const t=this.linked,e=this.sync,s=this.syncEase,i=this.syncSmooth,r=t&&(s||i),n=this.horizontal,o=this.container,a=this.scroll,h=a<=this.offsetStart,l=a>=this.offsetEnd,d=!h&&!l,c=a===this.offsetStart||a===this.offsetEnd,u=!this.hasEntered&&c,p=this._debug&&this.$debug;let m=!1,f=!1,g=this.progress;if(h&&this.began&&(this.began=!1),g>0&&!this.began&&(this.began=!0),r){const e=t.progress;if(i&&z(i)){if(i<1){const t=1e-4,s=e<g&&1===g?t:e>g&&!g?-t:0;g=pt(ft(e,g,ft(.01,.2,i))+s,6)}}else s&&(g=s(g));m=g!==this.prevProgress,f=1===e,m&&!f&&i&&e&&o.wakeTicker.restart()}if(p){const t=n?o.scrollY:o.scrollX;p.style[n?"top":"left"]=t+10+"px"}(d&&!this.isInView||u&&!this.forceEnter&&!this.hasEntered)&&(d&&(this.isInView=!0),this.forceEnter&&this.hasEntered?d&&(this.forceEnter=!1):(p&&d&&(p.style.zIndex=""+this.container.zIndex++),this.onSyncEnter(this),this.onEnter(this),this.backward?(this.onSyncEnterBackward(this),this.onEnterBackward(this)):(this.onSyncEnterForward(this),this.onEnterForward(this)),this.hasEntered=!0,u&&(this.forceEnter=!0))),(d||!d&&this.isInView)&&(m=!0),m&&(r&&t.seek(t.duration*g),this.onUpdate(this)),!d&&this.isInView&&(this.isInView=!1,this.onSyncLeave(this),this.onLeave(this),this.backward?(this.onSyncLeaveBackward(this),this.onLeaveBackward(this)):(this.onSyncLeaveForward(this),this.onLeaveForward(this)),e&&!i&&(f=!0)),g>=1&&this.began&&!this.completed&&(e&&f||!e)&&(e&&this.onSyncComplete(this),this.completed=!0,(!this.repeat&&!t||!this.repeat&&t&&t.completed)&&this.revert()),g<1&&this.completed&&(this.completed=!1),this.prevProgress=g}revert(){if(this.reverted)return;const t=this.container;return Tt(t,this),t._head||t.revert(),this._debug&&this.removeDebug(),this.reverted=!0,this.ready=!1,this}}const fs=(t,e,s)=>(((1-3*s+3*e)*t+(3*s-6*e))*t+3*e)*t,gs=(t=.5,e=0,s=.5,i=1)=>t===e&&s===i?de:r=>0===r||1===r?r:fs(((t,e,s)=>{let i,r,n=0,o=1,a=0;do{r=n+(o-n)/2,i=fs(r,e,s)-t,i>0?o=r:n=r}while(st(i)>1e-7&&++a<100);return r})(r,t,s),e,i),ys=(t=10,e)=>{const s=e?rt:nt;return e=>s(ct(e,0,1)*t)*(1/t)},vs=(...t)=>{const e=t.length;if(!e)return de;const s=e-1,i=t[0],r=t[s],n=[0],o=[Z(i)];for(let e=1;e<s;e++){const i=t[e],r=O(i)?i.trim().split(" "):[i],a=r[0],h=r[1];n.push(X(h)?e/s:Z(h)/100),o.push(Z(a))}return o.push(Z(r)),n.push(1),function(t){for(let e=1,s=n.length;e<s;e++){const s=n[e];if(t<=s){const i=n[e-1],r=o[e-1];return r+(o[e]-r)*(t-i)/(s-i)}}return o[o.length-1]}},_s=(t=10,e=1)=>{const s=[0],i=t-1;for(let t=1;t<i;t++){const r=s[t-1],n=t/i,o=n*(1-e)+(n+((t+1)/i-n)*Math.random())*e;s.push(ct(o,r,1))}return s.push(1),vs(...s)};var bs=Object.freeze({__proto__:null,Spring:je,createSpring:Qe,cubicBezier:gs,eases:ge,irregular:_s,linear:vs,spring:Ge,steps:ys});const Ts=(t,e=100)=>{const s=[];for(let i=0;i<=e;i++)s.push(pt(t(i/e),4));return`linear(${s.join(", ")})`},xs={},ws=t=>{let e=xs[t];if(e)return e;if(e="linear",O(t)){if(P(t,"linear")||P(t,"cubic-")||P(t,"steps")||P(t,"ease"))e=t;else if(P(t,"cubicB"))e=L(t);else{const s=ve(t);H(s)&&(e=s===de?"linear":Ts(s))}xs[t]=e}else if(H(t)){const s=Ts(t);s&&(e=s)}else t.ease&&(e=Ts(t.ease));return e},Ss=["x","y","z"],$s=["perspective","width","height","margin","padding","top","right","bottom","left","borderWidth","fontSize","borderRadius",...Ss],ks=(()=>[...Ss,...g.filter(t=>["X","Y","Z"].some(e=>t.endsWith(e)))])();let Es=null;const Cs=(t,e,s,i,r)=>{let n=O(e)?e:$t(e,s,i,r);return z(n)?$s.includes(t)||P(t,"translate")?`${n}px`:P(t,"rotate")||P(t,"skew")?`${n}deg`:`${n}`:n},Ns=(t,e,s,i,r,n)=>{let o="0";const a=X(i)?getComputedStyle(t)[e]:Cs(e,i,t,r,n);return o=X(s)?M(i)?i.map(s=>Cs(e,s,t,r,n)):a:[Cs(e,s,t,r,n),a],o};class Ds{constructor(t,s){I.current&&I.current.register(this),Y(Es)&&(!e||!X(CSS)&&Object.hasOwnProperty.call(CSS,"registerProperty")?(g.forEach(t=>{const e=P(t,"skew"),s=P(t,"scale"),i=P(t,"rotate"),r=P(t,"translate"),n=i||e,o=n?"<angle>":s?"<number>":r?"<length-percentage>":"*";try{CSS.registerProperty({name:"--"+t,syntax:o,inherits:!1,initialValue:r?"0px":n?"0deg":s?"1":"0"})}catch{}}),Es=!0):Es=!1);const i=oe(t),r=i.length;r||console.warn("No target found. Make sure the element you're trying to animate is accessible before creating your animation.");const n=St(s.ease,ws(A.defaults.ease)),o=n.ease&&n,a=St(s.autoplay,A.defaults.autoplay),l=!(!a||!a.link)&&a,d=s.alternate&&!0===s.alternate,c=s.reversed&&!0===s.reversed,u=St(s.loop,A.defaults.loop),_=!0===u||u===1/0?1/0:z(u)?u+1:1,b=d?c?"alternate-reverse":"alternate":c?"reverse":"normal",T=ws(n),x=1===A.timeScale?1:p;this.targets=i,this.animations=[],this.controlAnimation=null,this.onComplete=s.onComplete||A.defaults.onComplete,this.duration=0,this.muteCallbacks=!1,this.completed=!1,this.paused=!a||!1!==l,this.reversed=c,this.persist=St(s.persist,A.defaults.persist),this.autoplay=a,this._speed=St(s.playbackRate,A.defaults.playbackRate),this._resolve=v,this._completed=0,this._inlineStyles=[],i.forEach((t,e)=>{const i=t[h],a=ks.some(t=>s.hasOwnProperty(t)),l=t.style,d=this._inlineStyles[e]={},c=(o?o.settlingDuration:$t(St(s.duration,A.defaults.duration),t,e,r))*x,u=$t(St(s.delay,A.defaults.delay),t,e,r)*x,p=St(s.composition,"replace");for(let o in s){if(!G(o))continue;const h={},m={iterations:_,direction:b,fill:"both",easing:T,duration:c,delay:u,composite:p},y=s[o],v=!!a&&(g.includes(o)?o:f.get(o)),w=v?"transform":o;let S;if(d[w]||(d[w]=l[w]),V(y)){const s=y,a=St(s.ease,n),d=a.ease&&a,f=s.to,g=s.from;if(m.duration=(d?d.settlingDuration:$t(St(s.duration,c),t,e,r))*x,m.delay=$t(St(s.delay,u),t,e,r)*x,m.composite=St(s.composition,p),m.easing=ws(a),S=Ns(t,o,g,f,e,r),v?(h[`--${v}`]=S,i[v]=S):h[o]=Ns(t,o,g,f,e,r),Le(this,t,o,h,m),!X(g))if(v){const t=`--${v}`;l.setProperty(t,h[t][0])}else l[o]=h[o][0]}else S=M(y)?y.map(s=>Cs(o,s,t,e,r)):Cs(o,y,t,e,r),v?(h[`--${v}`]=S,i[v]=S):h[o]=S,Le(this,t,o,h,m)}if(a){let t=m;for(let e in i)t+=`${y[e]}var(--${e})) `;l.transform=t}}),l&&this.autoplay.link(this)}forEach(t){try{const e=O(t)?e=>e[t]():t;this.animations.forEach(e)}catch{}return this}get speed(){return this._speed}set speed(t){this._speed=+t,this.forEach(e=>e.playbackRate=t)}get currentTime(){const t=this.controlAnimation,e=A.timeScale;return this.completed?this.duration:t?+t.currentTime*(1===e?1:e):0}set currentTime(t){const e=t*(1===A.timeScale?1:p);this.forEach(t=>{!this.persist&&e>=this.duration&&t.play(),t.currentTime=e})}get progress(){return this.currentTime/this.duration}set progress(t){this.forEach(e=>e.currentTime=t*this.duration||0)}resume(){return this.paused?(this.paused=!1,this.forEach("play")):this}pause(){return this.paused?this:(this.paused=!0,this.forEach("pause"))}alternate(){return this.reversed=!this.reversed,this.forEach("reverse"),this.paused&&this.forEach("pause"),this}play(){return this.reversed&&this.alternate(),this.resume()}reverse(){return this.reversed||this.alternate(),this.resume()}seek(t,e=!1){return e&&(this.muteCallbacks=!0),t<this.duration&&(this.completed=!1),this.currentTime=t,this.muteCallbacks=!1,this.paused&&this.pause(),this}restart(){return this.completed=!1,this.seek(0,!0).resume()}commitStyles(){return this.forEach("commitStyles")}complete(){return this.seek(this.duration)}cancel(){return this.muteCallbacks=!0,this.commitStyles().forEach("cancel"),this.animations.length=0,requestAnimationFrame(()=>{this.targets.forEach(t=>{"none"===t.style.transform&&t.style.removeProperty("transform")})}),this}revert(){return this.cancel().targets.forEach((t,e)=>{const s=t.style,i=this._inlineStyles[e];for(let e in i){const r=i[e];X(r)||r===m?s.removeProperty(L(e)):t.style[e]=r}t.getAttribute("style")===m&&t.removeAttribute("style")}),this}then(t=v){const e=this.then,s=()=>{this.then=null,t(this),this.then=e,this._resolve=v};return new Promise(t=>(this._resolve=()=>t(s()),this.completed&&this._resolve(),this))}}const Is={animate:(t,e)=>new Ds(t,e),convertEase:Ts};let As=0,Bs=0;const Rs=(t,e)=>!(!t||!e)&&(t===e||t.contains(e)),Ls=(t,e)=>{let s=t[e];for(;s&&s.nodeType===Node.TEXT_NODE&&!s.textContent.trim();)s=s[e];return s&&s.nodeType===Node.TEXT_NODE},Ps=t=>{if(!t)return null;const e=t.style,s=e.transition||"";return e.setProperty("transition","none","important"),s},Fs=(t,e)=>{if(!t)return;const s=t.style;e?s.transition=e:s.removeProperty("transition")},Ms=t=>{const e=t.layout.transitionMuteStore,s=t.$el,i=t.$measure;s&&!e.has(s)&&e.set(s,Ps(s)),i&&!e.has(i)&&e.set(i,Ps(i))},Vs=t=>{t.forEach((t,e)=>Fs(e,t)),t.clear()},zs={display:"none",visibility:"hidden",opacity:"0",transform:"none",position:"static"},Os=t=>{if(!t)return;const e=t.parentNode;e&&(e._head===t&&(e._head=t._next),e._tail===t&&(e._tail=t._prev),t._prev&&(t._prev._next=t._next),t._next&&(t._next._prev=t._prev),t._prev=null,t._next=null,t.parentNode=null)},Hs=(t,e,s,i)=>{let r=t.dataset.layoutId;r||(r=t.dataset.layoutId="node-"+Bs++);const n=i||{};return n.$el=t,n.$measure=t,n.id=r,n.index=0,n.total=1,n.delay=0,n.duration=0,n.state=s,n.layout=s.layout,n.parentNode=e||null,n.isTarget=!1,n.hasTransform=!1,n.isAnimated=!1,n.inlineStyles=[],n.inlineTransforms=null,n.inlineTransition=null,n.branchAdded=!1,n.branchRemoved=!1,n.branchNotRendered=!1,n.sizeChanged=!1,n.isInlined=!1,n.hasVisibilitySwap=!1,n.hasDisplayNone=!1,n.hasVisibilityHidden=!1,n.measuredInlineTransform=null,n.measuredInlineTransition=null,n.measuredDisplay=null,n.measuredVisibility=null,n.measuredPosition=null,n.measuredHasDisplayNone=!1,n.measuredHasVisibilityHidden=!1,n.measuredIsVisible=!1,n.measuredIsRemoved=!1,n.measuredIsInsideRoot=!1,n.properties={transform:"none",x:0,y:0,left:0,top:0,clientLeft:0,clientTop:0,width:0,height:0},n.layout.properties.forEach(t=>n.properties[t]=0),n._head=null,n._tail=null,n._prev=null,n._next=null,n},Xs=(t,e,s,i)=>{const r=t.$el,n=t.layout.root,o=n===r,a=t.properties,h=t.state.rootNode,l=t.parentNode,d=s.transform,c=r.style.transform,u=!!l&&l.measuredIsRemoved,p=s.position;if(o&&(t.layout.absoluteCoords="fixed"===p||"absolute"===p),t.$measure=e,t.inlineTransforms=c,t.hasTransform=d&&"none"!==d,t.measuredIsInsideRoot=Rs(n,e),t.measuredInlineTransform=null,t.measuredDisplay=s.display,t.measuredVisibility=s.visibility,t.measuredPosition=p,t.measuredHasDisplayNone="none"===s.display,t.measuredHasVisibilityHidden="hidden"===s.visibility,t.measuredIsVisible=!(t.measuredHasDisplayNone||t.measuredHasVisibilityHidden),t.measuredIsRemoved=t.measuredHasDisplayNone||t.measuredHasVisibilityHidden||u,t.isInlined=t.measuredDisplay.includes("inline")&&(t=>Ls(t,"previousSibling")||Ls(t,"nextSibling"))(r),t.hasTransform&&!i){const s=t.layout.transitionMuteStore;s.get(r)||(t.inlineTransition=Ps(r)),e===r?r.style.transform="none":(s.get(e)||(t.measuredInlineTransition=Ps(e)),t.measuredInlineTransform=e.style.transform,e.style.transform="none")}let m,f,g=0,y=0,v=0,_=0;if(!i){const t=e.getBoundingClientRect();g=t.left,y=t.top,v=t.width,_=t.height}for(let t in a){const e="transform"===t?d:s[t]||s.getPropertyValue&&s.getPropertyValue(t);X(e)||(a[t]=e)}if(a.left=g,a.top=y,a.clientLeft=i?0:e.clientLeft,a.clientTop=i?0:e.clientTop,o)t.layout.absoluteCoords?(m=g,f=y):(m=0,f=0);else{const e=l||h,s=e.properties.left,i=e.properties.top,r=e.properties.clientLeft,n=e.properties.clientTop;if(t.layout.absoluteCoords)m=g-s-r,f=y-i-n;else if(e===h){const t=h.properties.left,e=h.properties.top;m=g-t-h.properties.clientLeft,f=y-e-h.properties.clientTop}else m=g-s-r,f=y-i-n}return a.x=m,a.y=f,a.width=v,a.height=_,t},Ys=(t,e)=>{if(e)for(let s in e)t.properties[s]=e[s]},Ws=t=>{const e=t.$el.style,s=t.inlineStyles;s.length=0,t.layout.recordedProperties.forEach(t=>{s.push(t,e[t]||"")})},Us=t=>{const e=t.$el.style,s=t.inlineStyles;for(let t=0,i=s.length;t<i;t+=2){const i=s[t],r=s[t+1];r&&""!==r?e[i]=r:(e[i]="",e.removeProperty(i))}},qs=t=>{const e=t.inlineTransforms,s=t.$el.style;!t.hasTransform||!e||t.hasTransform&&"none"===s.transform||e&&"none"===e?s.removeProperty("transform"):e&&(s.transform=e);const i=t.$measure;if(t.hasTransform&&i!==t.$el){const e=i.style,s=t.measuredInlineTransform;s&&""!==s?e.transform=s:e.removeProperty("transform")}t.measuredInlineTransform=null,null!==t.inlineTransition&&(Fs(t.$el,t.inlineTransition),t.inlineTransition=null),i!==t.$el&&null!==t.measuredInlineTransition&&(Fs(i,t.measuredInlineTransition),t.measuredInlineTransition=null)},js=t=>{(t.measuredIsRemoved||t.hasVisibilitySwap)&&(t.$el.style.removeProperty("display"),t.$el.style.removeProperty("visibility"),t.hasVisibilitySwap&&(t.$measure.style.removeProperty("display"),t.$measure.style.removeProperty("visibility"))),t.measuredIsRemoved&&t.layout.pendingRemoved.delete(t.$el)},Gs=(t,e,s)=>(e.properties={...t.properties},e.state=s,e.isTarget=t.isTarget,e.hasTransform=t.hasTransform,e.inlineTransforms=t.inlineTransforms,e.measuredIsVisible=t.measuredIsVisible,e.measuredDisplay=t.measuredDisplay,e.measuredIsRemoved=t.measuredIsRemoved,e.measuredHasDisplayNone=t.measuredHasDisplayNone,e.measuredHasVisibilityHidden=t.measuredHasVisibilityHidden,e.hasDisplayNone=t.hasDisplayNone,e.isInlined=t.isInlined,e.hasVisibilityHidden=t.hasVisibilityHidden,e);class Qs{constructor(t){this.layout=t,this.rootNode=null,this.rootNodes=new Set,this.nodes=new Map,this.scrollX=0,this.scrollY=0}revert(){return this.forEachNode(t=>{t.$el.removeAttribute("data-layout-id"),t.$measure.removeAttribute("data-layout-id")}),this.rootNode=null,this.rootNodes.clear(),this.nodes.clear(),this}get(t){const e=this.nodes.get(t.dataset.layoutId);if(e)return e.properties;console.warn("No node found on state")}getValue(t,e){if(!t||!t.dataset)return void console.warn(`No element found on state (${t})`);const s=this.nodes.get(t.dataset.layoutId);if(!s)return void console.warn("No node found on state");const i=s.properties[e];return X(i)?void 0:$t(i,t,s.index,s.total)}forEach(t,e){let s=t,i=0;for(;s;)if(e(s,i++),s._head)s=s._head;else if(s._next)s=s._next;else{for(;s&&!s._next;)s=s.parentNode;s&&(s=s._next)}}forEachRootNode(t){this.forEach(this.rootNode,t)}forEachNode(t){for(const e of this.rootNodes)this.forEach(e,t)}registerElement(t,e){if(!t||1!==t.nodeType)return null;this.layout.transitionMuteStore.has(t)||this.layout.transitionMuteStore.set(t,Ps(t));const s=[t,e],i=this.layout.root;let r=null;for(;s.length;){const t=s.pop(),e=s.pop();if(!e||1!==e.nodeType||W(e))continue;const n=!!t&&t.measuredIsRemoved,o=n?zs:getComputedStyle(e),a=!!n||"none"===o.display,h=!!n||"hidden"===o.visibility,l=!a&&!h,d=e.dataset.layoutId,c=Rs(i,e);let u=d?this.nodes.get(d):null;if(u&&u.$el!==e){const a=Rs(i,u.$el),h=u.measuredIsVisible;if(a||!c&&(c||h||!l)){if(a&&!h&&l){Xs(u,e,o,n);let t=e.lastElementChild;for(;t;)s.push(t,u),t=t.previousElementSibling;r||(r=u);continue}{let i=e.lastElementChild;for(;i;)s.push(i,t),i=i.previousElementSibling;r||(r=u);continue}}Os(u),u=Hs(e,t,this,u)}else u=Hs(e,t,this,u);u.branchAdded=!1,u.branchRemoved=!1,u.branchNotRendered=!1,u.isTarget=!1,u.isAnimated=!1,u.hasVisibilityHidden=h,u.hasDisplayNone=a,u.hasVisibilitySwap=h&&!u.measuredHasVisibilityHidden||a&&!u.measuredHasDisplayNone,this.nodes.set(u.id,u),u.parentNode=t||null,u._prev=null,u._next=null,t?(this.rootNodes.delete(u),t._head?(t._tail._next=u,u._prev=t._tail,t._tail=u):(t._head=u,t._tail=u)):this.rootNodes.add(u),Xs(u,u.$el,o,n);let p=e.lastElementChild;for(;p;)s.push(p,u),p=p.previousElementSibling;r||(r=u)}return r}ensureDetachedNode(t,e){if(!t||t===this.layout.root)return null;const s=t.dataset.layoutId,i=s?this.nodes.get(s):null;if(i&&i.$el===t)return i;let r=null,n=t.parentElement;for(;n&&n!==this.layout.root;){if(e.has(n)){r=this.ensureDetachedNode(n,e);break}n=n.parentElement}return this.registerElement(t,r)}record(){const{children:t,root:e}=this.layout,s=M(t)?t:[t],i=[],r="*"===t?e:I.root;for(let t=0,e=s.length;t<e;t++){const e=s[t];i[t]=O(e)?r.querySelectorAll(e):e}const n=oe(i);this.nodes.clear(),this.rootNodes.clear();const o=this.registerElement(e,null);o.isTarget=!0,this.rootNode=o;const a=new Set;this.nodes.forEach((t,e)=>{t&&t.measuredIsInsideRoot&&a.add(e)});const h=new Set,l=[];for(let t=0,s=n.length;t<s;t++){const s=n[t];if(s&&1===s.nodeType&&s!==e){if(!Rs(e,s)){const t=s.dataset.layoutId;if(!t||!a.has(t))continue}h.has(s)||(h.add(s),l.push(s))}}for(let t=0,e=l.length;t<e;t++)this.ensureDetachedNode(l[t],h);for(let t=0,e=n.length;t<e;t++){const e=n[t],s=this.nodes.get(e.dataset.layoutId);if(s){let t=s;for(;t&&!t.isTarget;)t.isTarget=!0,t=t.parentNode}}this.scrollX=window.scrollX,this.scrollY=window.scrollY;const d=this.nodes.size;return this.forEachNode(qs),this.forEachNode((t,e)=>{t.index=e,t.total=d}),this}}class Zs{constructor(t,e={}){I.current&&I.current.register(this);const s=e.frozen,i=e.added,r=e.removed,n=e.properties;if(this.params=e,this.root=oe(t)[0],this.id=As++,this.children=e.children||"*",this.absoluteCoords=!1,this.duration=St(e.duration,500),this.delay=St(e.delay,0),this.ease=St(e.ease,"inOutExpo"),this.onComplete=St(e.onComplete,v),this.frozenParams=s||{opacity:0},this.addedParams=i||{opacity:0},this.removedParams=r||{opacity:0},this.properties=new Set(["opacity","borderRadius"]),s)for(let t in s)this.properties.add(t);if(i)for(let t in i)this.properties.add(t);if(r)for(let t in r)this.properties.add(t);if(n)for(let t=0,e=n.length;t<e;t++)this.properties.add(n[t]);this.recordedProperties=new Set(["display","visibility","translate","position","left","top","marginLeft","marginTop","width","height","maxWidth","maxHeight","minWidth","minHeight"]),this.properties.forEach(t=>this.recordedProperties.add(t)),this.pendingRemoved=new WeakSet,this.transitionMuteStore=new Map,this.oldState=new Qs(this),this.newState=new Qs(this),this.timeline=null,this.transformAnimation=null,this.frozen=[],this.removed=[],this.added=[],this.oldState.record(),Vs(this.transitionMuteStore)}revert(){return this.timeline&&(this.timeline.complete(),this.timeline=null),this.transformAnimation&&(this.transformAnimation.complete(),this.transformAnimation=null),this.root.classList.remove("is-animated"),this.frozen.length=this.removed.length=this.added.length=0,this.oldState.revert(),this.newState.revert(),requestAnimationFrame(()=>Vs(this.transitionMuteStore)),this}record(){return this.transformAnimation&&(this.transformAnimation.cancel(),this.transformAnimation=null),this.oldState.record(),this.timeline&&(this.timeline.cancel(),this.timeline=null),this.newState.forEachRootNode(Us),this}animate(t={}){const e=St(t.delay,this.delay),s=St(t.duration,this.duration),i=St(t.onComplete,this.onComplete),r=t.frozen?_t(t.frozen,this.frozenParams):this.frozenParams,n=t.added?_t(t.added,this.addedParams):this.addedParams,o=t.removed?_t(t.removed,this.removedParams):this.removedParams,a=this.oldState,h=this.newState,l=this.added,d=this.removed,c=this.frozen,u=this.pendingRemoved;l.length=d.length=c.length=0,a.forEachRootNode(Ms),h.record(),h.forEachRootNode(Ws);const p=[],m=[],f=[],g=[],y=h.rootNode.$el;h.forEachRootNode(t=>{const i=t.$el,r=t.id,y=t.parentNode,v=!!y&&y.branchAdded,_=!!y&&y.branchRemoved,b=!!y&&y.branchNotRendered;t.delay=+(H(e)?e(i,t.index,t.total):e),t.duration=+(H(s)?s(i,t.index,t.total):s);let T=a.nodes.get(r);const x=!T;x?(T=Gs(t,{},a),a.nodes.set(r,T),T.measuredIsRemoved=!0):T.measuredIsRemoved&&!t.measuredIsRemoved&&(Gs(t,T,a),T.measuredIsRemoved=!0);const w=T.parentNode,S=(w?w.id:null)!==(y?y.id:null),$=T.$el!==t.$el,k=T.measuredIsRemoved,E=t.measuredIsRemoved;if(!T.measuredIsRemoved&&!E&&!x&&(S||$)){let e=0,s=0,i=t.parentNode;for(;i&&(e+=i.properties.x||0,s+=i.properties.y||0,i.parentNode!==h.rootNode);)i=i.parentNode;let r=0,n=0,o=T.parentNode;for(;o&&(r+=o.properties.x||0,n+=o.properties.y||0,o.parentNode!==a.rootNode);)o=o.parentNode;T.properties.x+=r-e,T.properties.y+=n-s}t.hasVisibilitySwap&&(t.hasVisibilityHidden&&(t.$el.style.visibility="visible",t.$measure.style.visibility="hidden"),t.hasDisplayNone&&(t.$el.style.display=T.measuredDisplay||t.measuredDisplay||"",t.$measure.style.visibility="hidden"));const C=u.has(i),N=T.measuredIsVisible,D=t.measuredIsVisible,I=!N&&D&&!b,A=!E&&(k||C)&&!v,B=E&&!k&&!_,R=B||E&&C&&!_;t.measuredIsRemoved&&N&&(t.$el.style.display=T.measuredDisplay,t.$el.style.visibility="visible",Gs(T,t,h)),B?(d.push(i),u.add(i)):!E&&C&&u.delete(i),A&&!b||I?(Ys(T,n),l.push(i)):R&&!b&&Ys(t,o);for(let e in t.properties)t.properties[e]=h.getValue(t.$el,e),T.properties[e]=a.getValue(t.$el,e);const L=(A||B)&&k!==E;let P=!1;if(t.isTarget&&(!t.measuredIsRemoved&&N||t.measuredIsRemoved&&D)){t.isInlined||"none"===t.properties.transform&&"none"===T.properties.transform||(t.hasTransform=!0,P=!0,f.push(i));for(let e in t.properties)if("transform"!==e&&(t.properties[e]!==T.properties[e]||L)){P=!0,m.push(i);break}}const F=P||A||R||I,M=t.isTarget&&F;t.isAnimated=M,t.branchAdded=v||A,t.branchRemoved=_||R,t.branchNotRendered=b||t.measuredIsRemoved;const V=Math.abs(t.properties.width-T.properties.width)>1,z=Math.abs(t.properties.height-T.properties.height)>1;t.sizeChanged=V||z,p.push(i),t.isTarget||(c.push(i),(F||t.sizeChanged)&&y&&y.isTarget&&y.isAnimated&&y.sizeChanged&&g.push(i))});const v={ease:St(t.ease,this.ease),duration:t=>h.nodes.get(t.dataset.layoutId).duration,delay:t=>h.nodes.get(t.dataset.layoutId).delay};if(this.timeline=Xe({onComplete:()=>{this.transformAnimation&&this.transformAnimation.cancel(),h.forEachRootNode(t=>{js(t),Us(t)});for(let t=0,e=f.length;t<e;t++){const e=f[t];e.style.transform=h.getValue(e,"transform")}this.root.classList.remove("is-animated"),i&&i(this),requestAnimationFrame(()=>{this.root.classList.contains("is-animated")||Vs(this.transitionMuteStore)})},onPause:()=>{this.transformAnimation&&this.transformAnimation.cancel(),h.forEachRootNode(js),this.root.classList.remove("is-animated"),i&&i(this)},composition:!1,defaults:v}),p.length){this.root.classList.add("is-animated");for(let t=0,e=p.length;t<e;t++){const e=p[t],s=e.dataset.layoutId,i=a.nodes.get(s),r=h.nodes.get(s),n=i.properties;Ms(r),r.isInlined||(e.style.display="block",(e!==y||this.absoluteCoords)&&(e.style.position=this.absoluteCoords?"fixed":"absolute",e.style.left="0px",e.style.top="0px",e.style.marginLeft="0px",e.style.marginTop="0px",e.style.translate=`${n.x}px ${n.y}px`),e===y&&"static"===r.measuredPosition&&(e.style.position="relative",e.style.left="0px",e.style.top="0px"),e.style.width=`${n.width}px`,e.style.height=`${n.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none")}a.scrollX===window.scrollX&&a.scrollY===window.scrollY||requestAnimationFrame(()=>{window.scrollTo(a.scrollX,a.scrollY)});for(let t=0,e=m.length;t<e;t++){const e=m[t],s=e.dataset.layoutId,i=a.nodes.get(s),r=h.nodes.get(s),n=i.properties,o=r.properties;let l=!1;const d={composition:"none"};r.isInlined||(n.width!==o.width&&(d.width=[n.width,o.width],l=!0),n.height!==o.height&&(d.height=[n.height,o.height],l=!0),r.hasTransform||(d.translate=[`${n.x}px ${n.y}px`,`${o.x}px ${o.y}px`],l=!0)),this.properties.forEach(t=>{const e=n[t],s=o[t];"transform"!==t&&e!==s&&(d[t]=[e,s],l=!0)}),l&&this.timeline.add(e,d,0)}}if(c.length){for(let t=0,e=c.length;t<e;t++){const e=c[t];if(!a.nodes.get(e.dataset.layoutId).isInlined){const t=a.get(e);e.style.width=`${t.width}px`,e.style.height=`${t.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",e.style.translate=`${t.x}px ${t.y}px`}this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${a.getValue(e,t)}`)})}for(let t=0,e=c.length;t<e;t++){const e=c[t],s=h.nodes.get(e.dataset.layoutId),i=h.get(e);this.timeline.call(()=>{s.isInlined||(e.style.width=`${i.width}px`,e.style.height=`${i.height}px`,e.style.minWidth="auto",e.style.minHeight="auto",e.style.maxWidth="none",e.style.maxHeight="none",e.style.translate=`${i.x}px ${i.y}px`),this.properties.forEach(t=>{"transform"!==t&&(e.style[t]=`${h.getValue(e,t)}`)})},s.delay+s.duration/2)}if(g.length){const t={};if(r)for(let e in r)t[e]=[{from:t=>a.getValue(t,e),ease:"in(1.75)",to:r[e]},{from:r[e],to:t=>h.getValue(t,e),ease:"out(1.75)"}];this.timeline.add(g,t,0)}}const _=f.length;if(_){for(let t=0;t<_;t++){const e=f[t];e.style.translate=`${a.get(e).x}px ${a.get(e).y}px`,e.style.transform=a.getValue(e,"transform")}this.transformAnimation=Is.animate(f,{translate:t=>`${h.get(t).x}px ${h.get(t).y}px`,transform:t=>h.getValue(t,"transform"),autoplay:!1,persist:!0,...v}),this.timeline.sync(this.transformAnimation,0)}return this.timeline.init()}update(t,e={}){return this.record(),t(this),this.animate(e),this}}const Js=Ue,Ks={},ti=t=>(...e)=>{const s=t(...e);return new Proxy(v,{apply:(t,e,[i])=>s(i),get:(t,e)=>ti((...t)=>{const i=Ks[e](...t);return t=>i(s(t))})})},ei=(t,e,s=0)=>{const i=(...t)=>(t.length<e.length?ti(((t,e=0)=>(...s)=>e?e=>t(...s,e):e=>t(e,...s))(e,s)):e)(...t);return Ks[t]||(Ks[t]=i),i},si=ei("roundPad",Js.roundPad),ii=ei("padStart",Js.padStart),ri=ei("padEnd",Js.padEnd),ni=ei("wrap",Js.wrap),oi=ei("mapRange",Js.mapRange),ai=ei("degToRad",Js.degToRad),hi=ei("radToDeg",Js.radToDeg),li=ei("snap",Js.snap),di=ei("clamp",Js.clamp),ci=ei("round",Js.round),ui=ei("lerp",Js.lerp,1),pi=ei("damp",Js.damp,1),mi=(t=0,e=1,s=0)=>{const i=10**s;return Math.floor((Math.random()*(e-t+1/i)+t)*i)/i};let fi=0;const gi=(t,e=0,s=1,i=0)=>{let r=void 0===t?fi++:t;return(t=e,n=s,o=i)=>{r+=1831565813,r=Math.imul(r^r>>>15,1|r),r^=r+Math.imul(r^r>>>7,61|r);const a=10**o;return Math.floor((((r^r>>>14)>>>0)/4294967296*(n-t+1/a)+t)*a)/a}},yi=t=>t[mi(0,t.length-1)],vi=t=>{let e,s,i=t.length;for(;i;)s=mi(0,--i),e=t[i],t[i]=t[s],t[s]=e;return t},_i=(t,e={})=>{let s=[],i=0;const r=e.from,n=e.reversed,o=e.ease,a=!X(o),h=a&&!X(o.ease)?o.ease:a?be(o):null,l=e.grid,d=e.axis,c=e.total,u=X(r)||0===r||"first"===r,p="center"===r,f="last"===r,g="random"===r,y=M(t),v=e.use,_=Z(y?t[0]:t),b=y?Z(t[1]):0,T=$.exec((y?t[1]:t)+m),x=e.start||0+(y?_:0);let w=u?0:z(r)?r:0;return(t,r,o,a)=>{const[u]=oe(t),m=X(c)?o:c,S=!X(v)&&(H(v)?v(u,r,m):Ct(u,v)),$=z(S)||O(S)&&z(+S)?+S:r;if(p&&(w=(m-1)/2),f&&(w=m-1),!s.length){for(let t=0;t<m;t++){if(l){const e=p?(l[0]-1)/2:w%l[0],i=p?(l[1]-1)/2:nt(w/l[0]),r=e-t%l[0],n=i-nt(t/l[0]);let o=K(r*r+n*n);"x"===d&&(o=-r),"y"===d&&(o=-n),s.push(o)}else s.push(st(w-t));i=at(...s)}h&&(s=s.map(t=>h(t/i)*i)),n&&(s=s.map(t=>d?t<0?-1*t:-t:st(i-t))),g&&(s=vi(s))}const k=y?(b-_)/i:_;let E=(a?Ve(a,X(e.start)?a.iterationDuration:x):x)+(k*pt(s[$],2)||0);return e.modifier&&(E=e.modifier(E)),T&&(E=`${E}${T[2]}`),E}};var bi=Object.freeze({__proto__:null,$:oe,clamp:di,cleanInlineStyles:Ft,createSeededRandom:gi,damp:pi,degToRad:ai,get:Pe,keepTime:rs,lerp:ui,mapRange:oi,padEnd:ri,padStart:ii,radToDeg:hi,random:mi,randomPick:yi,remove:Me,round:ci,roundPad:si,set:Fe,shuffle:vi,snap:li,stagger:_i,sync:is,wrap:ni});const Ti=t=>{const e=ne(t)[0];return e&&W(e)?e:console.warn(`${t} is not a valid SVGGeometryElement`)},xi=(t,e,s,i,r)=>{const n=s+i,o=r?Math.max(0,Math.min(n,e)):(n%e+e)%e;return t.getPointAtLength(o)},wi=(t,e,s=0)=>i=>{const r=+t.getTotalLength(),n=i[a],o=t.getCTM(),h=0===s;return{from:0,to:r,modifier:i=>{const a=i+s*r;if("a"===e){const e=xi(t,r,a,-1,h),s=xi(t,r,a,1,h);return 180*ht(s.y-e.y,s.x-e.x)/lt}{const s=xi(t,r,a,0,h);return"x"===e?n||!o?s.x:s.x*o.a+s.y*o.c+o.e:n||!o?s.y:s.x*o.b+s.y*o.d+o.f}}}},Si=(t,e=0)=>{const s=Ti(t);if(s)return{translateX:wi(s,"x",e),translateY:wi(s,"y",e),rotate:wi(s,"a",e)}},$i=(t,e=0,s=0)=>ne(t).map(t=>((t,e,s)=>{const i=p,r=getComputedStyle(t),n=r.strokeLinecap,o="non-scaling-stroke"===r.vectorEffect?t:null;let a=n;const h=new Proxy(t,{get(t,e){const s=t[e];return e===d?t:"setAttribute"===e?(...e)=>{if("draw"===e[0]){const s=e[1].split(" "),r=+s[0],h=+s[1],l=(t=>{let e=1;if(t&&t.getCTM){const s=t.getCTM();s&&(e=(K(s.a*s.a+s.b*s.b)+K(s.c*s.c+s.d*s.d))/2)}return e})(o),d=-1e3*r*l,c=h*i*l+d,u=i*l+(0===r&&1===h||1===r&&0===h?0:10*l)-c;if("butt"!==n){const e=r===h?"butt":n;a!==e&&(t.style.strokeLinecap=`${e}`,a=e)}t.setAttribute("stroke-dashoffset",`${d}`),t.setAttribute("stroke-dasharray",`${c} ${u}`)}return Reflect.apply(s,t,e)}:H(s)?(...e)=>Reflect.apply(s,t,e):s}});return"1000"!==t.getAttribute("pathLength")&&(t.setAttribute("pathLength","1000"),h.setAttribute("draw",`${e} ${s}`)),h})(t,e,s)),ki=(t,e=.33)=>s=>{if(!(s.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${s.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const i=Ti(t);if(!i)throw new Error("Can't morph to an invalid target. 'path2' must resolve to an existing <path>, <polygon> or <polyline> SVG element.");if(!(i.tagName||"").toLowerCase().match(/^(path|polygon|polyline)$/))throw new Error(`Can't morph a <${i.tagName}> SVG element. Use <path>, <polygon> or <polyline>.`);const r="path"===s.tagName,n=r?" ":",",o=s[l];o&&s.setAttribute(r?"d":"points",o);let a="",h="";if(e){const t=s.getTotalLength(),o=i.getTotalLength(),l=Math.max(Math.ceil(t*e),Math.ceil(o*e));for(let e=0;e<l;e++){const d=e/(l-1),c=s.getPointAtLength(t*d),u=i.getPointAtLength(o*d),p=r?0===e?"M":"L":"";a+=p+pt(c.x,3)+n+c.y+" ",h+=p+pt(u.x,3)+n+u.y+" "}}else a=s.getAttribute(r?"d":"points"),h=i.getAttribute(r?"d":"points");return s[l]=h,[a,h]};var Ei=Object.freeze({__proto__:null,createDrawable:$i,createMotionPath:Si,morphTo:ki});const Ci="undefined"!=typeof Intl&&Intl.Segmenter,Ni=/\{value\}/g,Di=/\{i\}/g,Ii=/(\s+)/,Ai=/^\s+$/,Bi="line",Ri="word",Li="char",Pi="data-line";let Fi=null,Mi=null,Vi=null;const zi=t=>t.isWordLike||" "===t.segment||z(+t.segment),Oi=t=>t.setAttribute("aria-hidden","true"),Hi=(t,e)=>[...t.querySelectorAll(`[data-${e}]:not([data-${e}] [data-${e}])`)],Xi={line:"#00D672",word:"#FF4B4B",char:"#5A87FF"},Yi=t=>{if(!t.childElementCount&&!t.textContent.trim()){const e=t.parentElement;t.remove(),e&&Yi(e)}},Wi=(t,e,s)=>{const i=t.getAttribute(Pi);if(null!==i&&+i!==e||"BR"===t.tagName){s.add(t);const e=t.previousSibling,i=t.nextSibling;e&&3===e.nodeType&&Ai.test(e.textContent)&&s.add(e),i&&3===i.nodeType&&Ai.test(i.textContent)&&s.add(i)}let r=t.childElementCount;for(;r--;)Wi(t.children[r],e,s);return s},Ui=(t,e={})=>{let s="";const i=O(e.class)?` class="${e.class}"`:"",r=St(e.clone,!1),n=St(e.wrap,!1),o=n?!0===n?"clip":n:!!r&&"clip";return n&&(s+=`<span${o?` style="overflow:${o};"`:""}>`),s+=`<span${i}${r?' style="position:relative;"':""} data-${t}="{i}">`,r?(s+="<span>{value}</span>",s+=`<span inert style="position:absolute;top:${"top"===r?"-100%":"bottom"===r?"100%":"0"};left:${"left"===r?"-100%":"right"===r?"100%":"0"};white-space:nowrap;">{value}</span>`):s+="{value}",s+="</span>",n&&(s+="</span>"),s},qi=(t,e,s,i,r,n,o,a,h)=>{const l=r===Bi,d=r===Li,c=`_${r}_`,u=H(t)?t(s):t,p=l?"block":"inline-block";Vi.innerHTML=u.replace(Ni,`<i class="${c}"></i>`).replace(Di,`${d?h:l?o:a}`);const m=Vi.content,f=m.firstElementChild,g=m.querySelector(`[data-${r}]`)||f,y=m.querySelectorAll(`i.${c}`),v=y.length;if(v){f.style.display=p,g.style.display=p,g.setAttribute(Pi,`${o}`),l||(g.setAttribute("data-word",`${a}`),d&&g.setAttribute("data-char",`${h}`));let t=v;for(;t--;){const e=y[t],i=e.parentElement;i.style.display=p,l?i.innerHTML=s.innerHTML:i.replaceChild(s.cloneNode(!0),e)}e.push(g),i.appendChild(m)}else console.warn('The expression "{value}" is missing from the provided template.');return n&&(f.style.outline=`1px dotted ${Xi[r]}`),f};class ji{constructor(t,s={}){Fi||(Fi=Ci?new Ci([],{granularity:Ri}):{segment:t=>{const e=[],s=t.split(Ii);for(let t=0,i=s.length;t<i;t++){const i=s[t];e.push({segment:i,isWordLike:!Ai.test(i)})}return e}}),Mi||(Mi=Ci?new Ci([],{granularity:"grapheme"}):{segment:t=>[...t].map(t=>({segment:t}))}),!Vi&&e&&(Vi=i.createElement("template")),I.current&&I.current.register(this);const{words:r,chars:n,lines:o,accessible:a,includeSpaces:h,debug:l}=s,d=(t=M(t)?t[0]:t)&&t.nodeType?t:(re(t)||[])[0],c=!0===o?{}:o,u=!0===r||X(r)?{}:r,p=!0===n?{}:n;this.debug=St(l,!1),this.includeSpaces=St(h,!1),this.accessible=St(a,!0),this.linesOnly=c&&!u&&!p,this.lineTemplate=V(c)?Ui(Bi,c):c,this.wordTemplate=V(u)||this.linesOnly?Ui(Ri,u):u,this.charTemplate=V(p)?Ui(Li,p):p,this.$target=d,this.html=d&&d.innerHTML,this.lines=[],this.words=[],this.chars=[],this.effects=[],this.effectsCleanups=[],this.cache=null,this.ready=!1,this.width=0,this.resizeTimeout=null;const m=()=>this.html&&(c||u||p)&&this.split();this.resizeObserver=new ResizeObserver(()=>{clearTimeout(this.resizeTimeout),this.resizeTimeout=setTimeout(()=>{const t=d.offsetWidth;t!==this.width&&(this.width=t,m())},150)}),this.lineTemplate&&!this.ready?i.fonts.ready.then(m):m(),d?this.resizeObserver.observe(d):console.warn("No Text Splitter target found.")}addEffect(t){if(!H(t))return console.warn("Effect must return a function.");const e=rs(t);return this.effects.push(e),this.ready&&(this.effectsCleanups[this.effects.length-1]=e(this)),this}revert(){return clearTimeout(this.resizeTimeout),this.lines.length=this.words.length=this.chars.length=0,this.resizeObserver.disconnect(),this.effectsCleanups.forEach(t=>H(t)?t(this):t.revert&&t.revert()),this.$target.innerHTML=this.html,this}splitNode(t){const e=this.wordTemplate,s=this.charTemplate,r=this.includeSpaces,n=this.debug,o=t.nodeType;if(3===o){const o=t.nodeValue;if(o.trim()){const a=[],h=this.words,l=this.chars,d=Fi.segment(o),c=i.createDocumentFragment();let u=null;for(const t of d){const e=t.segment,s=zi(t);if(!u||s&&u&&zi(u))a.push(e);else{const t=a.length-1,s=a[t];Ii.test(s)||Ii.test(e)?a.push(e):a[t]+=e}u=t}for(let t=0,o=a.length;t<o;t++){const o=a[t];if(o.trim()){const d=a[t+1],u=r&&d&&!d.trim(),p=o,m=s?Mi.segment(p):null,f=s?i.createDocumentFragment():i.createTextNode(u?o+" ":o);if(s){const t=[...m];for(let e=0,r=t.length;e<r;e++){const o=t[e],a=e===r-1&&u?o.segment+" ":o.segment,d=i.createTextNode(a);qi(s,l,d,f,Li,n,-1,h.length,l.length)}}e?qi(e,h,f,c,Ri,n,-1,h.length,l.length):s?c.appendChild(f):c.appendChild(i.createTextNode(o)),u&&t++}else{if(t&&r)continue;c.appendChild(i.createTextNode(o))}}t.parentNode.replaceChild(c,t)}}else if(1===o){const e=[...t.childNodes];for(let t=0,s=e.length;t<s;t++)this.splitNode(e[t])}}split(t=!1){const e=this.$target,s=!!this.cache&&!t,r=this.lineTemplate,n=this.wordTemplate,o=this.charTemplate,a="loading"!==i.fonts.status,h=r&&a;this.ready=!r||a,(h||t)&&this.effectsCleanups.forEach(t=>H(t)&&t(this)),s||(t&&(e.innerHTML=this.html,this.words.length=this.chars.length=0),this.splitNode(e),this.cache=e.innerHTML),h&&(s&&(e.innerHTML=this.cache),this.lines.length=0,n&&(this.words=Hi(e,Ri))),o&&(h||n)&&(this.chars=Hi(e,Li));const l=this.words.length?this.words:this.chars;let d,c=0;for(let t=0,e=l.length;t<e;t++){const e=l[t],{top:s,height:i}=e.getBoundingClientRect();!X(d)&&s-d>.5*i&&c++,e.setAttribute(Pi,`${c}`);const r=e.querySelectorAll(`[${Pi}]`);let n=r.length;for(;n--;)r[n].setAttribute(Pi,`${c}`);d=s}if(h){const t=i.createDocumentFragment(),s=new Set,a=[];for(let t=0;t<c+1;t++){const i=e.cloneNode(!0);Wi(i,t,new Set).forEach(t=>{const e=t.parentNode;e&&(1===t.nodeType&&s.add(e),e.removeChild(t))}),a.push(i)}s.forEach(Yi);for(let e=0,s=a.length;e<s;e++)qi(r,this.lines,a[e],t,Bi,this.debug,e);e.innerHTML="",e.appendChild(t),n&&(this.words=Hi(e,Ri)),o&&(this.chars=Hi(e,Li))}if(this.linesOnly){const t=this.words;let e=t.length;for(;e--;){const s=t[e];s.replaceWith(s.textContent)}t.length=0}if(this.accessible&&(h||!s)){const t=i.createElement("span");t.style.cssText="position:absolute;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);width:1px;height:1px;white-space:nowrap;",t.innerHTML=this.html,e.insertBefore(t,e.firstChild),this.lines.forEach(Oi),this.words.forEach(Oi),this.chars.forEach(Oi)}return this.width=e.offsetWidth,(h||t)&&this.effects.forEach((t,e)=>this.effectsCleanups[e]=t(this)),this}refresh(){this.split(!0)}}const Gi=(t,e)=>new ji(t,e),Qi=(t,e)=>(console.warn("text.split() is deprecated, import splitText() directly, or text.splitText()"),new ji(t,e));var Zi=Object.freeze({__proto__:null,TextSplitter:ji,split:Qi,splitText:Gi});t.$=oe,t.Animatable=Ye,t.AutoLayout=Zs,t.Draggable=ss,t.JSAnimation=Ae,t.Scope=ns,t.ScrollObserver=ms,t.Spring=je,t.TextSplitter=ji,t.Timeline=He,t.Timer=ie,t.WAAPIAnimation=Ds,t.animate=(t,e)=>new Ae(t,e,null,0,!1).init(),t.clamp=di,t.cleanInlineStyles=Ft,t.createAnimatable=(t,e)=>new Ye(t,e),t.createDraggable=(t,e)=>new ss(t,e),t.createDrawable=$i,t.createLayout=(t,e)=>new Zs(t,e),t.createMotionPath=Si,t.createScope=t=>new ns(t),t.createSeededRandom=gi,t.createSpring=Qe,t.createTimeline=Xe,t.createTimer=t=>new ie(t,null,0).init(),t.cubicBezier=gs,t.damp=pi,t.degToRad=ai,t.eases=ge,t.easings=bs,t.engine=Xt,t.get=Pe,t.irregular=_s,t.keepTime=rs,t.lerp=ui,t.linear=vs,t.mapRange=oi,t.morphTo=ki,t.onScroll=(t={})=>new ms(t),t.padEnd=ri,t.padStart=ii,t.radToDeg=hi,t.random=mi,t.randomPick=yi,t.remove=Me,t.round=ci,t.roundPad=si,t.scrollContainers=as,t.set=Fe,t.shuffle=vi,t.snap=li,t.split=Qi,t.splitText=Gi,t.spring=Ge,t.stagger=_i,t.steps=ys,t.svg=Ei,t.sync=is,t.text=Zi,t.utils=bi,t.waapi=Is,t.wrap=ni});
diff --git a/dist/modules/animatable/animatable.cjs b/dist/modules/animatable/animatable.cjs
index 17000d7d..04460092 100644
--- a/dist/modules/animatable/animatable.cjs
+++ b/dist/modules/animatable/animatable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animatable/animatable.js b/dist/modules/animatable/animatable.js
index be27f8bf..1636f98e 100644
--- a/dist/modules/animatable/animatable.js
+++ b/dist/modules/animatable/animatable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animatable/index.cjs b/dist/modules/animatable/index.cjs
index 3eb5c82a..5b943b62 100644
--- a/dist/modules/animatable/index.cjs
+++ b/dist/modules/animatable/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animatable/index.js b/dist/modules/animatable/index.js
index b52f7bef..ffc8660b 100644
--- a/dist/modules/animatable/index.js
+++ b/dist/modules/animatable/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animatable - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/additive.cjs b/dist/modules/animation/additive.cjs
index 7f2e0c7d..92813033 100644
--- a/dist/modules/animation/additive.cjs
+++ b/dist/modules/animation/additive.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/additive.js b/dist/modules/animation/additive.js
index 206c86cf..52fb1eb5 100644
--- a/dist/modules/animation/additive.js
+++ b/dist/modules/animation/additive.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/animation.cjs b/dist/modules/animation/animation.cjs
index e1ef0c3e..b582db27 100644
--- a/dist/modules/animation/animation.cjs
+++ b/dist/modules/animation/animation.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -60,6 +60,7 @@ const fastSetValuesArray = [null, null];
const keyObjectTarget = { to: null };
let tweenId = 0;
+let JSAnimationId = 0;
let keyframes;
/** @type {TweenParamsOptions & TweenValues} */
let key;
@@ -174,6 +175,8 @@ class JSAnimation extends timer.Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ ++JSAnimationId;
+
const parsedTargets = targets.registerTargets(targets$1);
const targetsLength = parsedTargets.length;
@@ -183,6 +186,7 @@ class JSAnimation extends timer.Timer {
const params = /** @type {AnimationParams} */(kfParams ? helpers.mergeObjects(generateKeyframes(/** @type {DurationKeyframes} */(kfParams), parameters), parameters) : parameters);
const {
+ id,
delay,
duration,
ease,
@@ -193,11 +197,12 @@ class JSAnimation extends timer.Timer {
} = params;
const animDefaults = parent ? parent.defaults : globals.globals.defaults;
- const animaPlaybackEase = values.setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? parser.parseEase(animaPlaybackEase) : null;
- const hasSpring = !helpers.isUnd(ease) && !helpers.isUnd(/** @type {Spring} */(ease).ease);
- const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : values.setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : values.setValue(duration, animDefaults.duration);
+ const animEase = values.setValue(ease, animDefaults.ease);
+ const animPlaybackEase = values.setValue(playbackEase, animDefaults.playbackEase);
+ const parsedAnimPlaybackEase = animPlaybackEase ? parser.parseEase(animPlaybackEase) : null;
+ const hasSpring = !helpers.isUnd(/** @type {Spring} */(animEase).ease);
+ const tEasing = hasSpring ? /** @type {Spring} */(animEase).ease : values.setValue(ease, parsedAnimPlaybackEase ? 'linear' : animDefaults.ease);
+ const tDuration = hasSpring ? /** @type {Spring} */(animEase).settlingDuration : values.setValue(duration, animDefaults.duration);
const tDelay = values.setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
@@ -205,7 +210,7 @@ class JSAnimation extends timer.Timer {
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
// This allows targeting the current animation in the spring onComplete callback
- if (hasSpring) /** @type {Spring} */(ease).parent = this;
+ if (hasSpring) /** @type {Spring} */(animEase).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -349,6 +354,8 @@ class JSAnimation extends timer.Timer {
if (isFromToValue) {
values.decomposeRawValue(isFromToArray ? values.getFunctionValue(tweenToValue[0], target, ti, tl) : tweenFromValue, fromTargetObject);
values.decomposeRawValue(isFromToArray ? values.getFunctionValue(tweenToValue[1], target, ti, tl, toFunctionStore) : tweenToValue, toTargetObject);
+ // Needed to force an inline style registration
+ const originalValue = values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore);
if (fromTargetObject.t === consts.valueTypes.NUMBER) {
if (prevSibling) {
if (prevSibling._valueType === consts.valueTypes.UNIT) {
@@ -357,7 +364,7 @@ class JSAnimation extends timer.Timer {
}
} else {
values.decomposeRawValue(
- values.getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
+ originalValue,
values.decomposedOriginalValue
);
if (values.decomposedOriginalValue.t === consts.valueTypes.UNIT) {
@@ -576,12 +583,14 @@ class JSAnimation extends timer.Timer {
}
/** @type {TargetsArray} */
this.targets = parsedTargets;
+ /** @type {String|Number} */
+ this.id = !helpers.isUnd(id) ? id : JSAnimationId;
/** @type {Number} */
this.duration = iterationDuration === consts.minValue ? consts.minValue : helpers.clampInfinity(((iterationDuration + this._loopDelay) * this.iterationCount) - this._loopDelay) || consts.minValue;
/** @type {Callback<this>} */
this.onRender = onRender || animDefaults.onRender;
/** @type {EasingFunction} */
- this._ease = animEase;
+ this._ease = parsedAnimPlaybackEase;
/** @type {Number} */
this._delay = iterationDelay;
// NOTE: I'm keeping delay values separated from offsets in timelines because delays can override previous tweens and it could be confusing to debug a timeline with overridden tweens and no associated visible delays.
diff --git a/dist/modules/animation/animation.js b/dist/modules/animation/animation.js
index e20109c0..dca18146 100644
--- a/dist/modules/animation/animation.js
+++ b/dist/modules/animation/animation.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -9,7 +9,7 @@ import { K, compositionTypes, valueTypes, minValue, tweenTypes } from '../core/c
import { mergeObjects, isUnd, isKey, isObj, round, cloneArray, isNil, addChild, forEachChildren, clampInfinity, normalizeTime, isArr, isNum } from '../core/helpers.js';
import { globals } from '../core/globals.js';
import { registerTargets } from '../core/targets.js';
-import { setValue, getTweenType, getFunctionValue, decomposeRawValue, createDecomposedValueTargetObject, getOriginalAnimatableValue, decomposedOriginalValue, getRelativeValue, decomposeTweenValue } from '../core/values.js';
+import { setValue, getTweenType, getFunctionValue, decomposeRawValue, getOriginalAnimatableValue, createDecomposedValueTargetObject, decomposedOriginalValue, getRelativeValue, decomposeTweenValue } from '../core/values.js';
import { sanitizePropertyName, cleanInlineStyles } from '../core/styles.js';
import { convertValueUnit } from '../core/units.js';
import { parseEase } from '../easings/eases/parser.js';
@@ -58,6 +58,7 @@ const fastSetValuesArray = [null, null];
const keyObjectTarget = { to: null };
let tweenId = 0;
+let JSAnimationId = 0;
let keyframes;
/** @type {TweenParamsOptions & TweenValues} */
let key;
@@ -172,6 +173,8 @@ class JSAnimation extends Timer {
super(/** @type {TimerParams & AnimationParams} */(parameters), parent, parentPosition);
+ ++JSAnimationId;
+
const parsedTargets = registerTargets(targets);
const targetsLength = parsedTargets.length;
@@ -181,6 +184,7 @@ class JSAnimation extends Timer {
const params = /** @type {AnimationParams} */(kfParams ? mergeObjects(generateKeyframes(/** @type {DurationKeyframes} */(kfParams), parameters), parameters) : parameters);
const {
+ id,
delay,
duration,
ease,
@@ -191,11 +195,12 @@ class JSAnimation extends Timer {
} = params;
const animDefaults = parent ? parent.defaults : globals.defaults;
- const animaPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
- const animEase = animaPlaybackEase ? parseEase(animaPlaybackEase) : null;
- const hasSpring = !isUnd(ease) && !isUnd(/** @type {Spring} */(ease).ease);
- const tEasing = hasSpring ? /** @type {Spring} */(ease).ease : setValue(ease, animEase ? 'linear' : animDefaults.ease);
- const tDuration = hasSpring ? /** @type {Spring} */(ease).settlingDuration : setValue(duration, animDefaults.duration);
+ const animEase = setValue(ease, animDefaults.ease);
+ const animPlaybackEase = setValue(playbackEase, animDefaults.playbackEase);
+ const parsedAnimPlaybackEase = animPlaybackEase ? parseEase(animPlaybackEase) : null;
+ const hasSpring = !isUnd(/** @type {Spring} */(animEase).ease);
+ const tEasing = hasSpring ? /** @type {Spring} */(animEase).ease : setValue(ease, parsedAnimPlaybackEase ? 'linear' : animDefaults.ease);
+ const tDuration = hasSpring ? /** @type {Spring} */(animEase).settlingDuration : setValue(duration, animDefaults.duration);
const tDelay = setValue(delay, animDefaults.delay);
const tModifier = modifier || animDefaults.modifier;
// If no composition is defined and the targets length is high (>= 1000) set the composition to 'none' (0) for faster tween creation
@@ -203,7 +208,7 @@ class JSAnimation extends Timer {
// const absoluteOffsetTime = this._offset;
const absoluteOffsetTime = this._offset + (parent ? parent._offset : 0);
// This allows targeting the current animation in the spring onComplete callback
- if (hasSpring) /** @type {Spring} */(ease).parent = this;
+ if (hasSpring) /** @type {Spring} */(animEase).parent = this;
let iterationDuration = NaN;
let iterationDelay = NaN;
@@ -347,6 +352,8 @@ class JSAnimation extends Timer {
if (isFromToValue) {
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[0], target, ti, tl) : tweenFromValue, fromTargetObject);
decomposeRawValue(isFromToArray ? getFunctionValue(tweenToValue[1], target, ti, tl, toFunctionStore) : tweenToValue, toTargetObject);
+ // Needed to force an inline style registration
+ const originalValue = getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore);
if (fromTargetObject.t === valueTypes.NUMBER) {
if (prevSibling) {
if (prevSibling._valueType === valueTypes.UNIT) {
@@ -355,7 +362,7 @@ class JSAnimation extends Timer {
}
} else {
decomposeRawValue(
- getOriginalAnimatableValue(target, propName, tweenType, inlineStylesStore),
+ originalValue,
decomposedOriginalValue
);
if (decomposedOriginalValue.t === valueTypes.UNIT) {
@@ -574,12 +581,14 @@ class JSAnimation extends Timer {
}
/** @type {TargetsArray} */
this.targets = parsedTargets;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : JSAnimationId;
/** @type {Number} */
this.duration = iterationDuration === minValue ? minValue : clampInfinity(((iterationDuration + this._loopDelay) * this.iterationCount) - this._loopDelay) || minValue;
/** @type {Callback<this>} */
this.onRender = onRender || animDefaults.onRender;
/** @type {EasingFunction} */
- this._ease = animEase;
+ this._ease = parsedAnimPlaybackEase;
/** @type {Number} */
this._delay = iterationDelay;
// NOTE: I'm keeping delay values separated from offsets in timelines because delays can override previous tweens and it could be confusing to debug a timeline with overridden tweens and no associated visible delays.
diff --git a/dist/modules/animation/composition.cjs b/dist/modules/animation/composition.cjs
index 9db81bf9..dca6e102 100644
--- a/dist/modules/animation/composition.cjs
+++ b/dist/modules/animation/composition.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/composition.js b/dist/modules/animation/composition.js
index cf31a1b6..a5c93606 100644
--- a/dist/modules/animation/composition.js
+++ b/dist/modules/animation/composition.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/index.cjs b/dist/modules/animation/index.cjs
index 1b49bf47..54c3aa52 100644
--- a/dist/modules/animation/index.cjs
+++ b/dist/modules/animation/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/animation/index.js b/dist/modules/animation/index.js
index 85142505..4805219c 100644
--- a/dist/modules/animation/index.js
+++ b/dist/modules/animation/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - animation - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/clock.cjs b/dist/modules/core/clock.cjs
index 01de2088..8ee88764 100644
--- a/dist/modules/core/clock.cjs
+++ b/dist/modules/core/clock.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -8,7 +8,7 @@
'use strict';
var consts = require('./consts.cjs');
-var helpers = require('./helpers.cjs');
+var globals = require('./globals.cjs');
/**
* @import {
@@ -30,7 +30,7 @@ class Clock {
/** @type {Number} */
this._currentTime = initTime;
/** @type {Number} */
- this._elapsedTime = initTime;
+ this._lastTickTime = initTime;
/** @type {Number} */
this._startTime = initTime;
/** @type {Number} */
@@ -38,7 +38,7 @@ class Clock {
/** @type {Number} */
this._scheduledTime = 0;
/** @type {Number} */
- this._frameDuration = helpers.round(consts.K / consts.maxFps, 0);
+ this._frameDuration = consts.K / consts.maxFps;
/** @type {Number} */
this._fps = consts.maxFps;
/** @type {Number} */
@@ -59,7 +59,8 @@ class Clock {
const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < consts.minValue ? consts.minValue : fr;
- const frameDuration = helpers.round(consts.K / fps, 0);
+ const frameDuration = consts.K / fps;
+ if (fps > globals.defaults.frameRate) globals.defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
this._scheduledTime += frameDuration - previousFrameDuration;
@@ -80,14 +81,13 @@ class Clock {
*/
requestTick(time) {
const scheduledTime = this._scheduledTime;
- const elapsedTime = this._elapsedTime;
- this._elapsedTime += (time - elapsedTime);
- // If the elapsed time is lower than the scheduled time
+ this._lastTickTime = time;
+ // If the current time is lower than the scheduled time
// this means not enough time has passed to hit one frameDuration
// so skip that frame
- if (elapsedTime < scheduledTime) return consts.tickModes.NONE;
+ if (time < scheduledTime) return consts.tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = elapsedTime - scheduledTime;
+ const frameDelta = time - scheduledTime;
// Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
// Skips ahead if the actual elapsed time is higher.
this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
diff --git a/dist/modules/core/clock.d.ts b/dist/modules/core/clock.d.ts
index d757d6af..7669560c 100644
--- a/dist/modules/core/clock.d.ts
+++ b/dist/modules/core/clock.d.ts
@@ -12,7 +12,7 @@ export class Clock {
/** @type {Number} */
_currentTime: number;
/** @type {Number} */
- _elapsedTime: number;
+ _lastTickTime: number;
/** @type {Number} */
_startTime: number;
/** @type {Number} */
diff --git a/dist/modules/core/clock.js b/dist/modules/core/clock.js
index f25ca29c..dc4240ed 100644
--- a/dist/modules/core/clock.js
+++ b/dist/modules/core/clock.js
@@ -1,12 +1,12 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
import { K, maxFps, minValue, tickModes } from './consts.js';
-import { round } from './helpers.js';
+import { defaults } from './globals.js';
/**
* @import {
@@ -28,7 +28,7 @@ class Clock {
/** @type {Number} */
this._currentTime = initTime;
/** @type {Number} */
- this._elapsedTime = initTime;
+ this._lastTickTime = initTime;
/** @type {Number} */
this._startTime = initTime;
/** @type {Number} */
@@ -36,7 +36,7 @@ class Clock {
/** @type {Number} */
this._scheduledTime = 0;
/** @type {Number} */
- this._frameDuration = round(K / maxFps, 0);
+ this._frameDuration = K / maxFps;
/** @type {Number} */
this._fps = maxFps;
/** @type {Number} */
@@ -57,7 +57,8 @@ class Clock {
const previousFrameDuration = this._frameDuration;
const fr = +frameRate;
const fps = fr < minValue ? minValue : fr;
- const frameDuration = round(K / fps, 0);
+ const frameDuration = K / fps;
+ if (fps > defaults.frameRate) defaults.frameRate = fps;
this._fps = fps;
this._frameDuration = frameDuration;
this._scheduledTime += frameDuration - previousFrameDuration;
@@ -78,14 +79,13 @@ class Clock {
*/
requestTick(time) {
const scheduledTime = this._scheduledTime;
- const elapsedTime = this._elapsedTime;
- this._elapsedTime += (time - elapsedTime);
- // If the elapsed time is lower than the scheduled time
+ this._lastTickTime = time;
+ // If the current time is lower than the scheduled time
// this means not enough time has passed to hit one frameDuration
// so skip that frame
- if (elapsedTime < scheduledTime) return tickModes.NONE;
+ if (time < scheduledTime) return tickModes.NONE;
const frameDuration = this._frameDuration;
- const frameDelta = elapsedTime - scheduledTime;
+ const frameDelta = time - scheduledTime;
// Ensures that _scheduledTime progresses in steps of at least 1 frameDuration.
// Skips ahead if the actual elapsed time is higher.
this._scheduledTime += frameDelta < frameDuration ? frameDuration : frameDelta;
diff --git a/dist/modules/core/colors.cjs b/dist/modules/core/colors.cjs
index 508f86eb..3b413546 100644
--- a/dist/modules/core/colors.cjs
+++ b/dist/modules/core/colors.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/colors.js b/dist/modules/core/colors.js
index abffa854..af2f65ae 100644
--- a/dist/modules/core/colors.js
+++ b/dist/modules/core/colors.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/consts.cjs b/dist/modules/core/consts.cjs
index 3f184015..1f04f307 100644
--- a/dist/modules/core/consts.cjs
+++ b/dist/modules/core/consts.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -12,8 +12,10 @@
// TODO: Do we need to check if we're running inside a worker ?
const isBrowser = typeof window !== 'undefined';
-/** @type {Window & {AnimeJS: Array}|null} */
-const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
+/** @typedef {Window & {AnimeJS: Array} & {AnimeJSDevTools: any}|null} AnimeJSWindow
+
+/** @type {AnimeJSWindow} */
+const win = isBrowser ? /** @type {AnimeJSWindow} */(/** @type {unknown} */(window)) : null;
/** @type {Document|null} */
const doc = isBrowser ? document : null;
@@ -65,7 +67,7 @@ const proxyTargetSymbol = Symbol();
const minValue = 1e-11;
const maxValue = 1e12;
const K = 1e3;
-const maxFps = 120;
+const maxFps = 240;
// Strings
diff --git a/dist/modules/core/consts.d.ts b/dist/modules/core/consts.d.ts
index aa4347f7..670fcf96 100644
--- a/dist/modules/core/consts.d.ts
+++ b/dist/modules/core/consts.d.ts
@@ -1,8 +1,8 @@
export const isBrowser: boolean;
-/** @type {Window & {AnimeJS: Array}|null} */
-export const win: (Window & {
- AnimeJS: any[];
-}) | null;
+/** @typedef {Window & {AnimeJS: Array} & {AnimeJSDevTools: any}|null} AnimeJSWindow
+
+/** @type {AnimeJSWindow} */
+export const win: AnimeJSWindow;
/** @type {Document|null} */
export const doc: Document | null;
export type tweenTypes = number;
@@ -41,7 +41,7 @@ export const proxyTargetSymbol: unique symbol;
export const minValue: 1e-11;
export const maxValue: 1000000000000;
export const K: 1000;
-export const maxFps: 120;
+export const maxFps: 240;
export const emptyString: "";
export const cssVarPrefix: "var(";
export const shortTransforms: Map<any, any>;
@@ -59,3 +59,11 @@ export const lowerCaseRgx: RegExp;
export const transformsExecRgx: RegExp;
export const relativeValuesExecRgx: RegExp;
export const cssVariableMatchRgx: RegExp;
+/**
+ * /**
+ */
+export type AnimeJSWindow = (Window & {
+ AnimeJS: any[];
+} & {
+ AnimeJSDevTools: any;
+}) | null;
diff --git a/dist/modules/core/consts.js b/dist/modules/core/consts.js
index e889247c..77f3e049 100644
--- a/dist/modules/core/consts.js
+++ b/dist/modules/core/consts.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -10,8 +10,10 @@
// TODO: Do we need to check if we're running inside a worker ?
const isBrowser = typeof window !== 'undefined';
-/** @type {Window & {AnimeJS: Array}|null} */
-const win = isBrowser ? /** @type {Window & {AnimeJS: Array}} */(/** @type {unknown} */(window)) : null;
+/** @typedef {Window & {AnimeJS: Array} & {AnimeJSDevTools: any}|null} AnimeJSWindow
+
+/** @type {AnimeJSWindow} */
+const win = isBrowser ? /** @type {AnimeJSWindow} */(/** @type {unknown} */(window)) : null;
/** @type {Document|null} */
const doc = isBrowser ? document : null;
@@ -63,7 +65,7 @@ const proxyTargetSymbol = Symbol();
const minValue = 1e-11;
const maxValue = 1e12;
const K = 1e3;
-const maxFps = 120;
+const maxFps = 240;
// Strings
diff --git a/dist/modules/core/globals.cjs b/dist/modules/core/globals.cjs
index 74b83690..72823e56 100644
--- a/dist/modules/core/globals.cjs
+++ b/dist/modules/core/globals.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -65,7 +65,9 @@ const globals = {
tickThreshold: 200,
};
-const globalVersions = { version: '4.2.2', engine: null };
+const devTools = consts.isBrowser && consts.win.AnimeJSDevTools;
+
+const globalVersions = { version: '4.3.0-beta.0', engine: null };
if (consts.isBrowser) {
if (!consts.win.AnimeJS) consts.win.AnimeJS = [];
@@ -73,6 +75,7 @@ if (consts.isBrowser) {
}
exports.defaults = defaults;
+exports.devTools = devTools;
exports.globalVersions = globalVersions;
exports.globals = globals;
exports.scope = scope;
diff --git a/dist/modules/core/globals.d.ts b/dist/modules/core/globals.d.ts
index 88e1227f..7d85c57e 100644
--- a/dist/modules/core/globals.d.ts
+++ b/dist/modules/core/globals.d.ts
@@ -20,6 +20,7 @@ export namespace globals {
export let timeScale: number;
export let tickThreshold: number;
}
+export const devTools: any;
export namespace globalVersions {
let version: string;
let engine: any;
diff --git a/dist/modules/core/globals.js b/dist/modules/core/globals.js
index cc9b876c..9dcf789a 100644
--- a/dist/modules/core/globals.js
+++ b/dist/modules/core/globals.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -63,11 +63,13 @@ const globals = {
tickThreshold: 200,
};
-const globalVersions = { version: '4.2.2', engine: null };
+const devTools = isBrowser && win.AnimeJSDevTools;
+
+const globalVersions = { version: '4.3.0-beta.0', engine: null };
if (isBrowser) {
if (!win.AnimeJS) win.AnimeJS = [];
win.AnimeJS.push(globalVersions);
}
-export { defaults, globalVersions, globals, scope };
+export { defaults, devTools, globalVersions, globals, scope };
diff --git a/dist/modules/core/helpers.cjs b/dist/modules/core/helpers.cjs
index 7541a9f7..f2501855 100644
--- a/dist/modules/core/helpers.cjs
+++ b/dist/modules/core/helpers.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/helpers.js b/dist/modules/core/helpers.js
index caf78c3d..c837a0e0 100644
--- a/dist/modules/core/helpers.js
+++ b/dist/modules/core/helpers.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/render.cjs b/dist/modules/core/render.cjs
index d4349157..17976dbc 100644
--- a/dist/modules/core/render.cjs
+++ b/dist/modules/core/render.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/render.js b/dist/modules/core/render.js
index 1ea5f8dd..5972a865 100644
--- a/dist/modules/core/render.js
+++ b/dist/modules/core/render.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/styles.cjs b/dist/modules/core/styles.cjs
index bea43a16..4ecc7d2f 100644
--- a/dist/modules/core/styles.cjs
+++ b/dist/modules/core/styles.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/styles.js b/dist/modules/core/styles.js
index 63a3248f..ae3ab1b4 100644
--- a/dist/modules/core/styles.js
+++ b/dist/modules/core/styles.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/targets.cjs b/dist/modules/core/targets.cjs
index fc8faa66..2e94fef4 100644
--- a/dist/modules/core/targets.cjs
+++ b/dist/modules/core/targets.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/targets.js b/dist/modules/core/targets.js
index 67b580cd..f613deee 100644
--- a/dist/modules/core/targets.js
+++ b/dist/modules/core/targets.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/transforms.cjs b/dist/modules/core/transforms.cjs
index 02d89591..68cfc05a 100644
--- a/dist/modules/core/transforms.cjs
+++ b/dist/modules/core/transforms.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/transforms.js b/dist/modules/core/transforms.js
index f3f3ee8b..30d13342 100644
--- a/dist/modules/core/transforms.js
+++ b/dist/modules/core/transforms.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/units.cjs b/dist/modules/core/units.cjs
index e01c066e..d1fe084f 100644
--- a/dist/modules/core/units.cjs
+++ b/dist/modules/core/units.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/units.js b/dist/modules/core/units.js
index 3cba437f..a91c5b07 100644
--- a/dist/modules/core/units.js
+++ b/dist/modules/core/units.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/values.cjs b/dist/modules/core/values.cjs
index 87b1a999..a8e45546 100644
--- a/dist/modules/core/values.cjs
+++ b/dist/modules/core/values.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - core - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/core/values.js b/dist/modules/core/values.js
index fea014d8..58b81f50 100644
--- a/dist/modules/core/values.js
+++ b/dist/modules/core/values.js
@@ -1,6 +1,6 @@
/**
* Anime.js - core - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/draggable/draggable.cjs b/dist/modules/draggable/draggable.cjs
index 660d8102..1ef9d87f 100644
--- a/dist/modules/draggable/draggable.cjs
+++ b/dist/modules/draggable/draggable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/draggable/draggable.js b/dist/modules/draggable/draggable.js
index 06e5e85a..5de09fff 100644
--- a/dist/modules/draggable/draggable.js
+++ b/dist/modules/draggable/draggable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/draggable/index.cjs b/dist/modules/draggable/index.cjs
index 2ba7ccdc..94f5d36e 100644
--- a/dist/modules/draggable/index.cjs
+++ b/dist/modules/draggable/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/draggable/index.js b/dist/modules/draggable/index.js
index f871a45f..0441ba38 100644
--- a/dist/modules/draggable/index.js
+++ b/dist/modules/draggable/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - draggable - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/cubic-bezier/index.cjs b/dist/modules/easings/cubic-bezier/index.cjs
index ffb54a7f..4aaee723 100644
--- a/dist/modules/easings/cubic-bezier/index.cjs
+++ b/dist/modules/easings/cubic-bezier/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/cubic-bezier/index.js b/dist/modules/easings/cubic-bezier/index.js
index c9d99c6e..9c4bb1b8 100644
--- a/dist/modules/easings/cubic-bezier/index.js
+++ b/dist/modules/easings/cubic-bezier/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/index.cjs b/dist/modules/easings/eases/index.cjs
index 09150ef1..2cb5f73a 100644
--- a/dist/modules/easings/eases/index.cjs
+++ b/dist/modules/easings/eases/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/index.js b/dist/modules/easings/eases/index.js
index 589fd622..b712f596 100644
--- a/dist/modules/easings/eases/index.js
+++ b/dist/modules/easings/eases/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/parser.cjs b/dist/modules/easings/eases/parser.cjs
index 1d74d0a5..b7e2f279 100644
--- a/dist/modules/easings/eases/parser.cjs
+++ b/dist/modules/easings/eases/parser.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/eases/parser.js b/dist/modules/easings/eases/parser.js
index 72fd4573..433ad932 100644
--- a/dist/modules/easings/eases/parser.js
+++ b/dist/modules/easings/eases/parser.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/index.cjs b/dist/modules/easings/index.cjs
index f39aeed1..12aeccce 100644
--- a/dist/modules/easings/index.cjs
+++ b/dist/modules/easings/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/index.js b/dist/modules/easings/index.js
index ffa65b58..5a17137a 100644
--- a/dist/modules/easings/index.js
+++ b/dist/modules/easings/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/irregular/index.cjs b/dist/modules/easings/irregular/index.cjs
index c2c610bd..199a9694 100644
--- a/dist/modules/easings/irregular/index.cjs
+++ b/dist/modules/easings/irregular/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/irregular/index.js b/dist/modules/easings/irregular/index.js
index 0aa562e4..3bc7158b 100644
--- a/dist/modules/easings/irregular/index.js
+++ b/dist/modules/easings/irregular/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/linear/index.cjs b/dist/modules/easings/linear/index.cjs
index 2d0d7339..a24722b6 100644
--- a/dist/modules/easings/linear/index.cjs
+++ b/dist/modules/easings/linear/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/linear/index.js b/dist/modules/easings/linear/index.js
index ce109a92..d1eac133 100644
--- a/dist/modules/easings/linear/index.js
+++ b/dist/modules/easings/linear/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/none.cjs b/dist/modules/easings/none.cjs
index 19153ef6..afdb7af2 100644
--- a/dist/modules/easings/none.cjs
+++ b/dist/modules/easings/none.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/none.js b/dist/modules/easings/none.js
index f6ca005d..c835b2de 100644
--- a/dist/modules/easings/none.js
+++ b/dist/modules/easings/none.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/spring/index.cjs b/dist/modules/easings/spring/index.cjs
index e0393e53..9fa6077a 100644
--- a/dist/modules/easings/spring/index.cjs
+++ b/dist/modules/easings/spring/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/spring/index.js b/dist/modules/easings/spring/index.js
index 937347cf..b0fee159 100644
--- a/dist/modules/easings/spring/index.js
+++ b/dist/modules/easings/spring/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/steps/index.cjs b/dist/modules/easings/steps/index.cjs
index 931e3edb..ca0ba2cd 100644
--- a/dist/modules/easings/steps/index.cjs
+++ b/dist/modules/easings/steps/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/easings/steps/index.js b/dist/modules/easings/steps/index.js
index 2247ddb4..199f8bd3 100644
--- a/dist/modules/easings/steps/index.js
+++ b/dist/modules/easings/steps/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - easings - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/engine/engine.cjs b/dist/modules/engine/engine.cjs
index f608d3bd..8180157f 100644
--- a/dist/modules/engine/engine.cjs
+++ b/dist/modules/engine/engine.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -77,7 +77,7 @@ class Engine extends clock.Clock {
wake() {
if (this.useDefaultMainLoop && !this.reqId) {
- // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
+ // Imediatly request a tick to update engine._lastTickTime and get accurate offsetPosition calculation in timer.js
this.requestTick(helpers.now());
this.reqId = engineTickMethod(tickEngine);
}
diff --git a/dist/modules/engine/engine.js b/dist/modules/engine/engine.js
index 993b7f45..d5308e69 100644
--- a/dist/modules/engine/engine.js
+++ b/dist/modules/engine/engine.js
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -75,7 +75,7 @@ class Engine extends Clock {
wake() {
if (this.useDefaultMainLoop && !this.reqId) {
- // Imediatly request a tick to update engine._elapsedTime and get accurate offsetPosition calculation in timer.js
+ // Imediatly request a tick to update engine._lastTickTime and get accurate offsetPosition calculation in timer.js
this.requestTick(now());
this.reqId = engineTickMethod(tickEngine);
}
diff --git a/dist/modules/engine/index.cjs b/dist/modules/engine/index.cjs
index 1db95844..becc1231 100644
--- a/dist/modules/engine/index.cjs
+++ b/dist/modules/engine/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/engine/index.js b/dist/modules/engine/index.js
index e0cfbf19..4e2e8a3c 100644
--- a/dist/modules/engine/index.js
+++ b/dist/modules/engine/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - engine - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/events/index.cjs b/dist/modules/events/index.cjs
index 5cae2c52..2e076f7e 100644
--- a/dist/modules/events/index.cjs
+++ b/dist/modules/events/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - events - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/events/index.js b/dist/modules/events/index.js
index 88c9c4d0..cff8a8a9 100644
--- a/dist/modules/events/index.js
+++ b/dist/modules/events/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - events - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/events/scroll.cjs b/dist/modules/events/scroll.cjs
index 7953e0ac..0d61503d 100644
--- a/dist/modules/events/scroll.cjs
+++ b/dist/modules/events/scroll.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - events - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/events/scroll.js b/dist/modules/events/scroll.js
index 5a746c67..ac1736cf 100644
--- a/dist/modules/events/scroll.js
+++ b/dist/modules/events/scroll.js
@@ -1,6 +1,6 @@
/**
* Anime.js - events - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/index.cjs b/dist/modules/index.cjs
index 61ea3da1..eeeb40dc 100644
--- a/dist/modules/index.cjs
+++ b/dist/modules/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -16,6 +16,7 @@ var scope = require('./scope/scope.cjs');
var scroll = require('./events/scroll.cjs');
var engine = require('./engine/engine.cjs');
var index = require('./easings/index.cjs');
+var layout = require('./layout/layout.cjs');
var index$1 = require('./utils/index.cjs');
var index$2 = require('./svg/index.cjs');
var index$3 = require('./text/index.cjs');
@@ -57,6 +58,8 @@ exports.onScroll = scroll.onScroll;
exports.scrollContainers = scroll.scrollContainers;
exports.engine = engine.engine;
exports.easings = index;
+exports.AutoLayout = layout.AutoLayout;
+exports.createLayout = layout.createLayout;
exports.utils = index$1;
exports.svg = index$2;
exports.text = index$3;
diff --git a/dist/modules/index.d.ts b/dist/modules/index.d.ts
index 36082f82..d79cf605 100644
--- a/dist/modules/index.d.ts
+++ b/dist/modules/index.d.ts
@@ -7,6 +7,7 @@ export * from "./scope/index.js";
export * from "./events/index.js";
export * from "./engine/index.js";
export * from "./easings/index.js";
+export * from "./layout/index.js";
export * from "./utils/index.js";
export * from "./svg/index.js";
export * from "./text/index.js";
diff --git a/dist/modules/index.js b/dist/modules/index.js
index fe587832..2a842eff 100644
--- a/dist/modules/index.js
+++ b/dist/modules/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -15,6 +15,7 @@ export { ScrollObserver, onScroll, scrollContainers } from './events/scroll.js';
export { engine } from './engine/engine.js';
import * as index from './easings/index.js';
export { index as easings };
+export { AutoLayout, createLayout } from './layout/layout.js';
import * as index$1 from './utils/index.js';
export { index$1 as utils };
import * as index$2 from './svg/index.js';
diff --git a/dist/modules/layout/index.cjs b/dist/modules/layout/index.cjs
new file mode 100644
index 00000000..7669868b
--- /dev/null
+++ b/dist/modules/layout/index.cjs
@@ -0,0 +1,15 @@
+/**
+ * Anime.js - layout - CJS
+ * @version v4.3.0-beta.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+'use strict';
+
+var layout = require('./layout.cjs');
+
+
+
+exports.AutoLayout = layout.AutoLayout;
+exports.createLayout = layout.createLayout;
diff --git a/dist/modules/layout/index.d.ts b/dist/modules/layout/index.d.ts
new file mode 100644
index 00000000..ed4c2a72
--- /dev/null
+++ b/dist/modules/layout/index.d.ts
@@ -0,0 +1 @@
+export * from "./layout.js";
diff --git a/dist/modules/layout/index.js b/dist/modules/layout/index.js
new file mode 100644
index 00000000..5fc0d208
--- /dev/null
+++ b/dist/modules/layout/index.js
@@ -0,0 +1,8 @@
+/**
+ * Anime.js - layout - ESM
+ * @version v4.3.0-beta.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+export { AutoLayout, createLayout } from './layout.js';
diff --git a/dist/modules/layout/layout.cjs b/dist/modules/layout/layout.cjs
new file mode 100644
index 00000000..a3174223
--- /dev/null
+++ b/dist/modules/layout/layout.cjs
@@ -0,0 +1,1384 @@
+/**
+ * Anime.js - layout - CJS
+ * @version v4.3.0-beta.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+'use strict';
+
+var helpers = require('../core/helpers.cjs');
+var targets = require('../core/targets.cjs');
+var values = require('../core/values.cjs');
+var consts = require('../core/consts.cjs');
+var timeline = require('../timeline/timeline.cjs');
+var waapi = require('../waapi/waapi.cjs');
+var globals = require('../core/globals.cjs');
+
+/**
+ * @import {
+ * AnimationParams,
+ * } from '../types/index.js'
+*/
+
+/**
+ * @import {
+ * Timeline,
+ * } from '../timeline/timeline.js'
+*/
+
+/**
+ * @import {
+ * WAAPIAnimation
+ * } from '../waapi/waapi.js'
+*/
+
+/**
+ * @import {
+ * DOMTarget,
+ * DOMTargetSelector,
+ * FunctionValue,
+ * EasingParam,
+ * Callback,
+ } from '../types/index.js'
+*/
+
+/**
+ * @typedef {DOMTargetSelector|Array<DOMTargetSelector>} LayoutChildrenParam
+ */
+
+/**
+ * @typedef {Record<String, Number|String>} LayoutStateParams
+ */
+
+/**
+ * @typedef {Object} LayoutAnimationParams
+ * @property {Number} [duration]
+ * @property {Number|FunctionValue} [delay]
+ * @property {EasingParam} [ease]
+ * @property {LayoutStateParams} [frozen]
+ * @property {LayoutStateParams} [added]
+ * @property {LayoutStateParams} [removed]
+ * @property {Callback<AutoLayout>} [onComplete]
+ */
+
+/**
+ * @typedef {LayoutAnimationParams & {
+ * children?: LayoutChildrenParam,
+ * properties?: Array<String>,
+ * }} AutoLayoutParams
+ */
+
+/**
+ * @typedef {Record<String, Number|String> & {
+ * transform: String,
+ * x: Number,
+ * y: Number,
+ * left: Number,
+ * top: Number,
+ * clientLeft: Number,
+ * clientTop: Number,
+ * width: Number,
+ * height: Number,
+ * }} LayoutNodeProperties
+ */
+
+/**
+ * @typedef {Object} LayoutNode
+ * @property {String} id
+ * @property {DOMTarget} $el
+ * @property {Number} index
+ * @property {Number} total
+ * @property {Number} delay
+ * @property {Number} duration
+ * @property {DOMTarget} $measure
+ * @property {LayoutSnapshot} state
+ * @property {AutoLayout} layout
+ * @property {LayoutNode|null} parentNode
+ * @property {Boolean} isTarget
+ * @property {Boolean} hasTransform
+ * @property {Boolean} isAnimated
+ * @property {Array<String>} inlineStyles
+ * @property {String|null} inlineTransforms
+ * @property {String|null} inlineTransition
+ * @property {Boolean} branchAdded
+ * @property {Boolean} branchRemoved
+ * @property {Boolean} branchNotRendered
+ * @property {Boolean} sizeChanged
+ * @property {Boolean} isInlined
+ * @property {Boolean} hasVisibilitySwap
+ * @property {Boolean} hasDisplayNone
+ * @property {Boolean} hasVisibilityHidden
+ * @property {String|null} measuredInlineTransform
+ * @property {String|null} measuredInlineTransition
+ * @property {String|null} measuredDisplay
+ * @property {String|null} measuredVisibility
+ * @property {String|null} measuredPosition
+ * @property {Boolean} measuredHasDisplayNone
+ * @property {Boolean} measuredHasVisibilityHidden
+ * @property {Boolean} measuredIsVisible
+ * @property {Boolean} measuredIsRemoved
+ * @property {Boolean} measuredIsInsideRoot
+ * @property {LayoutNodeProperties} properties
+ * @property {LayoutNode|null} _head
+ * @property {LayoutNode|null} _tail
+ * @property {LayoutNode|null} _prev
+ * @property {LayoutNode|null} _next
+ */
+
+/**
+ * @callback LayoutNodeIterator
+ * @param {LayoutNode} node
+ * @param {Number} index
+ * @return {void}
+ */
+
+let layoutId = 0;
+let nodeId = 0;
+
+/**
+ * @param {DOMTarget} root
+ * @param {DOMTarget} $el
+ * @return {Boolean}
+ */
+const isElementInRoot = (root, $el) => {
+ if (!root || !$el) return false;
+ return root === $el || root.contains($el);
+};
+
+/**
+ * @param {Node} node
+ * @param {'previousSibling'|'nextSibling'} direction
+ * @return {Boolean}
+ */
+const hasTextSibling = (node, direction) => {
+ let sibling = node[direction];
+ while (sibling && sibling.nodeType === Node.TEXT_NODE && !sibling.textContent.trim()) {
+ sibling = sibling[direction];
+ }
+ return sibling && sibling.nodeType === Node.TEXT_NODE;
+};
+
+/**
+ * @param {DOMTarget} $el
+ * @return {Boolean}
+ */
+const isElementSurroundedByText = $el => hasTextSibling($el, 'previousSibling') || hasTextSibling($el, 'nextSibling');
+
+/**
+ * @param {DOMTarget|null} $el
+ * @return {String|null}
+ */
+const muteElementTransition = $el => {
+ if (!$el) return null;
+ const style = $el.style;
+ const transition = style.transition || '';
+ style.setProperty('transition', 'none', 'important');
+ return transition;
+};
+
+/**
+ * @param {DOMTarget|null} $el
+ * @param {String|null} transition
+ */
+const restoreElementTransition = ($el, transition) => {
+ if (!$el) return;
+ const style = $el.style;
+ if (transition) {
+ style.transition = transition;
+ } else {
+ style.removeProperty('transition');
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const muteNodeTransition = node => {
+ const store = node.layout.transitionMuteStore;
+ const $el = node.$el;
+ const $measure = node.$measure;
+ if ($el && !store.has($el)) store.set($el, muteElementTransition($el));
+ if ($measure && !store.has($measure)) store.set($measure, muteElementTransition($measure));
+};
+
+/**
+ * @param {Map<DOMTarget, String|null>} store
+ */
+const restoreLayoutTransition = store => {
+ store.forEach((value, $el) => restoreElementTransition($el, value));
+ store.clear();
+};
+
+const hiddenComputedStyle = /** @type {CSSStyleDeclaration} */({
+ display: 'none',
+ visibility: 'hidden',
+ opacity: '0',
+ transform: 'none',
+ position: 'static',
+});
+
+/**
+ * @param {LayoutNode|null} node
+ */
+const detachNode = node => {
+ if (!node) return;
+ const parent = node.parentNode;
+ if (!parent) return;
+ if (parent._head === node) parent._head = node._next;
+ if (parent._tail === node) parent._tail = node._prev;
+ if (node._prev) node._prev._next = node._next;
+ if (node._next) node._next._prev = node._prev;
+ node._prev = null;
+ node._next = null;
+ node.parentNode = null;
+};
+
+/**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @param {LayoutSnapshot} state
+ * @param {LayoutNode} [recycledNode]
+ * @return {LayoutNode}
+ */
+const createNode = ($el, parentNode, state, recycledNode) => {
+ let dataId = $el.dataset.layoutId;
+ if (!dataId) dataId = $el.dataset.layoutId = `node-${nodeId++}`;
+ const node = recycledNode ? recycledNode : /** @type {LayoutNode} */({});
+ node.$el = $el;
+ node.$measure = $el;
+ node.id = dataId;
+ node.index = 0;
+ node.total = 1;
+ node.delay = 0;
+ node.duration = 0;
+ node.state = state;
+ node.layout = state.layout;
+ node.parentNode = parentNode || null;
+ node.isTarget = false;
+ node.hasTransform = false;
+ node.isAnimated = false;
+ node.inlineStyles = [];
+ node.inlineTransforms = null;
+ node.inlineTransition = null;
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.sizeChanged = false;
+ node.isInlined = false;
+ node.hasVisibilitySwap = false;
+ node.hasDisplayNone = false;
+ node.hasVisibilityHidden = false;
+ node.measuredInlineTransform = null;
+ node.measuredInlineTransition = null;
+ node.measuredDisplay = null;
+ node.measuredVisibility = null;
+ node.measuredPosition = null;
+ node.measuredHasDisplayNone = false;
+ node.measuredHasVisibilityHidden = false;
+ node.measuredIsVisible = false;
+ node.measuredIsRemoved = false;
+ node.measuredIsInsideRoot = false;
+ node.properties = /** @type {LayoutNodeProperties} */({
+ transform: 'none',
+ x: 0,
+ y: 0,
+ left: 0,
+ top: 0,
+ clientLeft: 0,
+ clientTop: 0,
+ width: 0,
+ height: 0,
+ });
+ node.layout.properties.forEach(prop => node.properties[prop] = 0);
+ node._head = null;
+ node._tail = null;
+ node._prev = null;
+ node._next = null;
+ return node;
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {DOMTarget} $measure
+ * @param {CSSStyleDeclaration} computedStyle
+ * @param {Boolean} skipMeasurements
+ * @return {LayoutNode}
+ */
+const recordNodeState = (node, $measure, computedStyle, skipMeasurements) => {
+ const $el = node.$el;
+ const root = node.layout.root;
+ const isRoot = root === $el;
+ const properties = node.properties;
+ const rootNode = node.state.rootNode;
+ const parentNode = node.parentNode;
+ const computedTransforms = computedStyle.transform;
+ const inlineTransforms = $el.style.transform;
+ const parentNotRendered = parentNode ? parentNode.measuredIsRemoved : false;
+ const position = computedStyle.position;
+ if (isRoot) node.layout.absoluteCoords = position === 'fixed' || position === 'absolute';
+ node.$measure = $measure;
+ node.inlineTransforms = inlineTransforms;
+ node.hasTransform = computedTransforms && computedTransforms !== 'none';
+ node.measuredIsInsideRoot = isElementInRoot(root, $measure);
+ node.measuredInlineTransform = null;
+ node.measuredDisplay = computedStyle.display;
+ node.measuredVisibility = computedStyle.visibility;
+ node.measuredPosition = position;
+ node.measuredHasDisplayNone = computedStyle.display === 'none';
+ node.measuredHasVisibilityHidden = computedStyle.visibility === 'hidden';
+ node.measuredIsVisible = !(node.measuredHasDisplayNone || node.measuredHasVisibilityHidden);
+ node.measuredIsRemoved = node.measuredHasDisplayNone || node.measuredHasVisibilityHidden || parentNotRendered;
+ node.isInlined = node.measuredDisplay.includes('inline') && isElementSurroundedByText($el);
+
+ // Mute transforms (and transition to avoid triggering an animation) before the position calculation
+ if (node.hasTransform && !skipMeasurements) {
+ const transitionMuteStore = node.layout.transitionMuteStore;
+ if (!transitionMuteStore.get($el)) node.inlineTransition = muteElementTransition($el);
+ if ($measure === $el) {
+ $el.style.transform = 'none';
+ } else {
+ if (!transitionMuteStore.get($measure)) node.measuredInlineTransition = muteElementTransition($measure);
+ node.measuredInlineTransform = $measure.style.transform;
+ $measure.style.transform = 'none';
+ }
+ }
+
+ let left = 0;
+ let top = 0;
+ let width = 0;
+ let height = 0;
+
+ if (!skipMeasurements) {
+ const rect = $measure.getBoundingClientRect();
+ left = rect.left;
+ top = rect.top;
+ width = rect.width;
+ height = rect.height;
+ }
+
+ for (let name in properties) {
+ const computedProp = name === 'transform' ? computedTransforms : computedStyle[name] || (computedStyle.getPropertyValue && computedStyle.getPropertyValue(name));
+ if (!helpers.isUnd(computedProp)) properties[name] = computedProp;
+ }
+
+ properties.left = left;
+ properties.top = top;
+ properties.clientLeft = skipMeasurements ? 0 : $measure.clientLeft;
+ properties.clientTop = skipMeasurements ? 0 : $measure.clientTop;
+ // Compute local x/y relative to parent
+ let absoluteLeft, absoluteTop;
+ if (isRoot) {
+ if (!node.layout.absoluteCoords) {
+ absoluteLeft = 0;
+ absoluteTop = 0;
+ } else {
+ absoluteLeft = left;
+ absoluteTop = top;
+ }
+ } else {
+ const p = parentNode || rootNode;
+ const parentLeft = p.properties.left;
+ const parentTop = p.properties.top;
+ const borderLeft = p.properties.clientLeft;
+ const borderTop = p.properties.clientTop;
+ if (!node.layout.absoluteCoords) {
+ if (p === rootNode) {
+ const rootLeft = rootNode.properties.left;
+ const rootTop = rootNode.properties.top;
+ const rootBorderLeft = rootNode.properties.clientLeft;
+ const rootBorderTop = rootNode.properties.clientTop;
+ absoluteLeft = left - rootLeft - rootBorderLeft;
+ absoluteTop = top - rootTop - rootBorderTop;
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ }
+ properties.x = absoluteLeft;
+ properties.y = absoluteTop;
+ properties.width = width;
+ properties.height = height;
+ return node;
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {LayoutStateParams} [props]
+ */
+const updateNodeProperties = (node, props) => {
+ if (!props) return;
+ for (let name in props) {
+ node.properties[name] = props[name];
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const recordNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ stylesStore.length = 0;
+ node.layout.recordedProperties.forEach(prop => {
+ stylesStore.push(prop, style[prop] || '');
+ });
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ for (let i = 0, l = stylesStore.length; i < l; i += 2) {
+ const property = stylesStore[i];
+ const styleValue = stylesStore[i + 1];
+ if (styleValue && styleValue !== '') {
+ style[property] = styleValue;
+ } else {
+ style[property] = '';
+ style.removeProperty(property);
+ }
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeTransform = node => {
+ const inlineTransforms = node.inlineTransforms;
+ const nodeStyle = node.$el.style;
+ if (!node.hasTransform || !inlineTransforms || (node.hasTransform && nodeStyle.transform === 'none') || (inlineTransforms && inlineTransforms === 'none')) {
+ nodeStyle.removeProperty('transform');
+ } else if (inlineTransforms) {
+ nodeStyle.transform = inlineTransforms;
+ }
+ const $measure = node.$measure;
+ if (node.hasTransform && $measure !== node.$el) {
+ const measuredStyle = $measure.style;
+ const measuredInline = node.measuredInlineTransform;
+ if (measuredInline && measuredInline !== '') {
+ measuredStyle.transform = measuredInline;
+ } else {
+ measuredStyle.removeProperty('transform');
+ }
+ }
+ node.measuredInlineTransform = null;
+ if (node.inlineTransition !== null) {
+ restoreElementTransition(node.$el, node.inlineTransition);
+ node.inlineTransition = null;
+ }
+ if ($measure !== node.$el && node.measuredInlineTransition !== null) {
+ restoreElementTransition($measure, node.measuredInlineTransition);
+ node.measuredInlineTransition = null;
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeVisualState = node => {
+ if (node.measuredIsRemoved || node.hasVisibilitySwap) {
+ node.$el.style.removeProperty('display');
+ node.$el.style.removeProperty('visibility');
+ if (node.hasVisibilitySwap) {
+ node.$measure.style.removeProperty('display');
+ node.$measure.style.removeProperty('visibility');
+ }
+ }
+ if (node.measuredIsRemoved) {
+ node.layout.pendingRemoved.delete(node.$el);
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {LayoutNode} targetNode
+ * @param {LayoutSnapshot} newState
+ * @return {LayoutNode}
+ */
+const cloneNodeProperties = (node, targetNode, newState) => {
+ targetNode.properties = /** @type {LayoutNodeProperties} */({ ...node.properties });
+ targetNode.state = newState;
+ targetNode.isTarget = node.isTarget;
+ targetNode.hasTransform = node.hasTransform;
+ targetNode.inlineTransforms = node.inlineTransforms;
+ targetNode.measuredIsVisible = node.measuredIsVisible;
+ targetNode.measuredDisplay = node.measuredDisplay;
+ targetNode.measuredIsRemoved = node.measuredIsRemoved;
+ targetNode.measuredHasDisplayNone = node.measuredHasDisplayNone;
+ targetNode.measuredHasVisibilityHidden = node.measuredHasVisibilityHidden;
+ targetNode.hasDisplayNone = node.hasDisplayNone;
+ targetNode.isInlined = node.isInlined;
+ targetNode.hasVisibilityHidden = node.hasVisibilityHidden;
+ return targetNode;
+};
+
+class LayoutSnapshot {
+ /**
+ * @param {AutoLayout} layout
+ */
+ constructor(layout) {
+ /** @type {AutoLayout} */
+ this.layout = layout;
+ /** @type {LayoutNode|null} */
+ this.rootNode = null;
+ /** @type {Set<LayoutNode>} */
+ this.rootNodes = new Set();
+ /** @type {Map<String, LayoutNode>} */
+ this.nodes = new Map();
+ /** @type {Number} */
+ this.scrollX = 0;
+ /** @type {Number} */
+ this.scrollY = 0;
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ this.forEachNode(node => {
+ node.$el.removeAttribute('data-layout-id');
+ node.$measure.removeAttribute('data-layout-id');
+ });
+ this.rootNode = null;
+ this.rootNodes.clear();
+ this.nodes.clear();
+ return this;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @return {LayoutNodeProperties|undefined}
+ */
+ get($el) {
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ return node.properties;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} prop
+ * @return {Number|String|undefined}
+ */
+ getValue($el, prop) {
+ if (!$el || !$el.dataset) {
+ console.warn(`No element found on state (${$el})`);
+ return;
+ }
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ const value = node.properties[prop];
+ if (!helpers.isUnd(value)) return values.getFunctionValue(value, $el, node.index, node.total);
+ }
+
+ /**
+ * @param {LayoutNode|null} rootNode
+ * @param {LayoutNodeIterator} cb
+ */
+ forEach(rootNode, cb) {
+ let node = rootNode;
+ let i = 0;
+ while (node) {
+ cb(node, i++);
+ if (node._head) {
+ node = node._head;
+ } else if (node._next) {
+ node = node._next;
+ } else {
+ while (node && !node._next) {
+ node = node.parentNode;
+ }
+ if (node) node = node._next;
+ }
+ }
+ }
+
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachRootNode(cb) {
+ this.forEach(this.rootNode, cb);
+ }
+
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachNode(cb) {
+ for (const rootNode of this.rootNodes) {
+ this.forEach(rootNode, cb);
+ }
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @return {LayoutNode|null}
+ */
+ registerElement($el, parentNode) {
+ if (!$el || $el.nodeType !== 1) return null;
+
+ if (!this.layout.transitionMuteStore.has($el)) this.layout.transitionMuteStore.set($el, muteElementTransition($el));
+
+ /** @type {Array<DOMTarget|LayoutNode|null>} */
+ const stack = [$el, parentNode];
+ const root = this.layout.root;
+ let firstNode = null;
+
+ while (stack.length) {
+ /** @type {LayoutNode|null} */
+ const $parent = /** @type {LayoutNode|null} */(stack.pop());
+ /** @type {DOMTarget|null} */
+ const $current = /** @type {DOMTarget|null} */(stack.pop());
+ if (!$current || $current.nodeType !== 1 || helpers.isSvg($current)) continue;
+
+ const skipMeasurements = $parent ? $parent.measuredIsRemoved : false;
+
+ const computedStyle = skipMeasurements ? hiddenComputedStyle : getComputedStyle($current);
+ const hasDisplayNone = skipMeasurements ? true : computedStyle.display === 'none';
+ const hasVisibilityHidden = skipMeasurements ? true : computedStyle.visibility === 'hidden';
+ const isVisible = !hasDisplayNone && !hasVisibilityHidden;
+ const existingId = $current.dataset.layoutId;
+ const isInsideRoot = isElementInRoot(root, $current);
+
+ let node = existingId ? this.nodes.get(existingId) : null;
+
+ if (node && node.$el !== $current) {
+ const nodeInsideRoot = isElementInRoot(root, node.$el);
+ const measuredVisible = node.measuredIsVisible;
+ const shouldReassignNode = !nodeInsideRoot && (isInsideRoot || (!isInsideRoot && !measuredVisible && isVisible));
+ const shouldReuseMeasurements = nodeInsideRoot && !measuredVisible && isVisible;
+ // Rebind nodes that move into the root or whose detached twin just became visible
+ if (shouldReassignNode) {
+ detachNode(node);
+ node = createNode($current, $parent, this, node);
+ // for hidden element with in-root sibling, keep the hidden node but borrow measurements from its visible in-root twin element
+ } else if (shouldReuseMeasurements) {
+ recordNodeState(node, $current, computedStyle, skipMeasurements);
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ // No reassignment needed so keep walking descendants under the current parent
+ } else {
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), $parent);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ }
+ } else {
+ node = createNode($current, $parent, this, node);
+ }
+
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.isTarget = false;
+ node.isAnimated = false;
+ node.hasVisibilityHidden = hasVisibilityHidden;
+ node.hasDisplayNone = hasDisplayNone;
+ node.hasVisibilitySwap = (hasVisibilityHidden && !node.measuredHasVisibilityHidden) || (hasDisplayNone && !node.measuredHasDisplayNone);
+ // node.hasVisibilitySwap = (hasVisibilityHidden !== node.measuredHasVisibilityHidden) || (hasDisplayNone !== node.measuredHasDisplayNone);
+
+ this.nodes.set(node.id, node);
+
+ node.parentNode = $parent || null;
+ node._prev = null;
+ node._next = null;
+
+ if ($parent) {
+ this.rootNodes.delete(node);
+ if (!$parent._head) {
+ $parent._head = node;
+ $parent._tail = node;
+ } else {
+ $parent._tail._next = node;
+ node._prev = $parent._tail;
+ $parent._tail = node;
+ }
+ } else {
+ this.rootNodes.add(node);
+ }
+
+ recordNodeState(node, node.$el, computedStyle, skipMeasurements);
+
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+
+ if (!firstNode) firstNode = node;
+ }
+
+ return firstNode;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {Set<DOMTarget>} candidates
+ * @return {LayoutNode|null}
+ */
+ ensureDetachedNode($el, candidates) {
+ if (!$el || $el === this.layout.root) return null;
+ const existingId = $el.dataset.layoutId;
+ const existingNode = existingId ? this.nodes.get(existingId) : null;
+ if (existingNode && existingNode.$el === $el) return existingNode;
+ let parentNode = null;
+ let $ancestor = $el.parentElement;
+ while ($ancestor && $ancestor !== this.layout.root) {
+ if (candidates.has($ancestor)) {
+ parentNode = this.ensureDetachedNode($ancestor, candidates);
+ break;
+ }
+ $ancestor = $ancestor.parentElement;
+ }
+ return this.registerElement($el, parentNode);
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ const { children, root } = this.layout;
+ const toParse = helpers.isArr(children) ? children : [children];
+ const scoped = [];
+ const scopeRoot = children === '*' ? root : globals.scope.root;
+
+ for (let i = 0, l = toParse.length; i < l; i++) {
+ const child = toParse[i];
+ scoped[i] = helpers.isStr(child) ? scopeRoot.querySelectorAll(child) : child;
+ }
+
+ const parsedChildren = targets.registerTargets(scoped);
+
+ this.nodes.clear();
+ this.rootNodes.clear();
+
+ const rootNode = this.registerElement(root, null);
+ // Root node are always targets
+ rootNode.isTarget = true;
+ this.rootNode = rootNode;
+
+ // Track ids of nodes that belong to the current root to filter detached matches
+ const inRootNodeIds = new Set();
+ this.nodes.forEach((node, id) => {
+ if (node && node.measuredIsInsideRoot) {
+ inRootNodeIds.add(id);
+ }
+ });
+
+ // Elements with a layout id outside the root that match the children selector
+ const detachedElementsLookup = new Set();
+ const orderedDetachedElements = [];
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ if (!$el || $el.nodeType !== 1 || $el === root) continue;
+ const insideRoot = isElementInRoot(root, $el);
+ if (!insideRoot) {
+ const layoutNodeId = $el.dataset.layoutId;
+ if (!layoutNodeId || !inRootNodeIds.has(layoutNodeId)) continue;
+ }
+ if (!detachedElementsLookup.has($el)) {
+ detachedElementsLookup.add($el);
+ orderedDetachedElements.push($el);
+ }
+ }
+
+ for (let i = 0, l = orderedDetachedElements.length; i < l; i++) {
+ this.ensureDetachedNode(orderedDetachedElements[i], detachedElementsLookup);
+ }
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (node) {
+ let cur = node;
+ while (cur) {
+ if (cur.isTarget) break;
+ cur.isTarget = true;
+ cur = cur.parentNode;
+ }
+ }
+ }
+
+ this.scrollX = window.scrollX;
+ this.scrollY = window.scrollY;
+
+ const total = this.nodes.size;
+
+ this.forEachNode(restoreNodeTransform);
+ this.forEachNode((node, i) => {
+ node.index = i;
+ node.total = total;
+ });
+
+ return this;
+ }
+}
+
+class AutoLayout {
+ /**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ */
+ constructor(root, params = {}) {
+ if (globals.scope.current) globals.scope.current.register(this);
+ const frozenParams = params.frozen;
+ const addedParams = params.added;
+ const removedParams = params.removed;
+ const propsParams = params.properties;
+ /** @type {AutoLayoutParams} */
+ this.params = params;
+ /** @type {DOMTarget} */
+ this.root = /** @type {DOMTarget} */(targets.registerTargets(root)[0]);
+ /** @type {Number} */
+ this.id = layoutId++;
+ /** @type {LayoutChildrenParam} */
+ this.children = params.children || '*';
+ /** @type {Boolean} */
+ this.absoluteCoords = false;
+ /** @type {Number} */
+ this.duration = values.setValue(params.duration, 500);
+ /** @type {Number|FunctionValue} */
+ this.delay = values.setValue(params.delay, 0);
+ /** @type {EasingParam} */
+ this.ease = values.setValue(params.ease, 'inOutExpo');
+ /** @type {Callback<this>} */
+ this.onComplete = values.setValue(params.onComplete, /** @type {Callback<this>} */(consts.noop));
+ /** @type {LayoutStateParams} */
+ this.frozenParams = frozenParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.addedParams = addedParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.removedParams = removedParams || { opacity: 0 };
+ /** @type {Set<String>} */
+ this.properties = new Set([
+ 'opacity',
+ 'borderRadius',
+ ]);
+ if (frozenParams) for (let name in frozenParams) this.properties.add(name);
+ if (addedParams) for (let name in addedParams) this.properties.add(name);
+ if (removedParams) for (let name in removedParams) this.properties.add(name);
+ if (propsParams) for (let i = 0, l = propsParams.length; i < l; i++) this.properties.add(propsParams[i]);
+ /** @type {Set<String>} */
+ this.recordedProperties = new Set([
+ 'display',
+ 'visibility',
+ 'translate',
+ 'position',
+ 'left',
+ 'top',
+ 'marginLeft',
+ 'marginTop',
+ 'width',
+ 'height',
+ 'maxWidth',
+ 'maxHeight',
+ 'minWidth',
+ 'minHeight',
+ ]);
+ this.properties.forEach(prop => this.recordedProperties.add(prop));
+ /** @type {WeakSet<DOMTarget>} */
+ this.pendingRemoved = new WeakSet();
+ /** @type {Map<DOMTarget, String|null>} */
+ this.transitionMuteStore = new Map();
+ /** @type {LayoutSnapshot} */
+ this.oldState = new LayoutSnapshot(this);
+ /** @type {LayoutSnapshot} */
+ this.newState = new LayoutSnapshot(this);
+ /** @type {Timeline|null} */
+ this.timeline = null;
+ /** @type {WAAPIAnimation|null} */
+ this.transformAnimation = null;
+ /** @type {Array<DOMTarget>} */
+ this.frozen = [];
+ /** @type {Array<DOMTarget>} */
+ this.removed = [];
+ /** @type {Array<DOMTarget>} */
+ this.added = [];
+ // Record the current state as the old state to init the data attributes
+ this.oldState.record();
+ // And all layout transition muted during the record
+ restoreLayoutTransition(this.transitionMuteStore);
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ if (this.timeline) {
+ this.timeline.complete();
+ this.timeline = null;
+ }
+ if (this.transformAnimation) {
+ this.transformAnimation.complete();
+ this.transformAnimation = null;
+ }
+ this.root.classList.remove('is-animated');
+ this.frozen.length = this.removed.length = this.added.length = 0;
+ this.oldState.revert();
+ this.newState.revert();
+ requestAnimationFrame(() => restoreLayoutTransition(this.transitionMuteStore));
+ return this;
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ // Commit transforms before measuring
+ if (this.transformAnimation) {
+ this.transformAnimation.cancel();
+ this.transformAnimation = null;
+ }
+ // Record the old state
+ this.oldState.record();
+ // Cancel any running timeline
+ if (this.timeline) {
+ this.timeline.cancel();
+ this.timeline = null;
+ }
+ // Restore previously captured inline styles
+ this.newState.forEachRootNode(restoreNodeInlineStyles);
+ return this;
+ }
+
+ /**
+ * @param {LayoutAnimationParams} [params]
+ * @return {Timeline}
+ */
+ animate(params = {}) {
+ const delay = values.setValue(params.delay, this.delay);
+ const duration = values.setValue(params.duration, this.duration);
+ const onComplete = values.setValue(params.onComplete, this.onComplete);
+ const frozenParams = params.frozen ? helpers.mergeObjects(params.frozen, this.frozenParams) : this.frozenParams;
+ const addedParams = params.added ? helpers.mergeObjects(params.added, this.addedParams) : this.addedParams;
+ const removedParams = params.removed ? helpers.mergeObjects(params.removed, this.removedParams) : this.removedParams;
+ const oldState = this.oldState;
+ const newState = this.newState;
+ const added = this.added;
+ const removed = this.removed;
+ const frozen = this.frozen;
+ const pendingRemoved = this.pendingRemoved;
+
+ added.length = removed.length = frozen.length = 0;
+
+ // Mute old state CSS transitions to prevent wrong properties calculation
+ oldState.forEachRootNode(muteNodeTransition);
+ // Capture the new state before animation
+ newState.record();
+ newState.forEachRootNode(recordNodeInlineStyles);
+
+ const targets = [];
+ const animated = [];
+ const transformed = [];
+ const animatedFrozen = [];
+ const root = newState.rootNode.$el;
+
+ newState.forEachRootNode(node => {
+ const $el = node.$el;
+ const id = node.id;
+ const parent = node.parentNode;
+ const parentAdded = parent ? parent.branchAdded : false;
+ const parentRemoved = parent ? parent.branchRemoved : false;
+ const parentNotRendered = parent ? parent.branchNotRendered : false;
+
+ // Delay and duration must be calculated in the animate() call to support delay override
+ node.delay = +(helpers.isFnc(delay) ? delay($el, node.index, node.total) : delay);
+ node.duration = +(helpers.isFnc(duration) ? duration($el, node.index, node.total) : duration);
+
+ let oldStateNode = oldState.nodes.get(id);
+
+ const hasNoOldState = !oldStateNode;
+
+ if (hasNoOldState) {
+ oldStateNode = cloneNodeProperties(node, /** @type {LayoutNode} */({}), oldState);
+ oldState.nodes.set(id, oldStateNode);
+ oldStateNode.measuredIsRemoved = true;
+ } else if (oldStateNode.measuredIsRemoved && !node.measuredIsRemoved) {
+ cloneNodeProperties(node, oldStateNode, oldState);
+ oldStateNode.measuredIsRemoved = true;
+ }
+
+ const oldParentNode = oldStateNode.parentNode;
+ const oldParentId = oldParentNode ? oldParentNode.id : null;
+ const newParentId = parent ? parent.id : null;
+ const parentChanged = oldParentId !== newParentId;
+ const elementChanged = oldStateNode.$el !== node.$el;
+ const wasRemovedBefore = oldStateNode.measuredIsRemoved;
+ const isRemovedNow = node.measuredIsRemoved;
+
+ // Recalculate postion relative to their parent for elements that have been moved
+ if (!oldStateNode.measuredIsRemoved && !isRemovedNow && !hasNoOldState && (parentChanged || elementChanged)) {
+ let offsetX = 0;
+ let offsetY = 0;
+ let current = node.parentNode;
+ while (current) {
+ offsetX += current.properties.x || 0;
+ offsetY += current.properties.y || 0;
+ if (current.parentNode === newState.rootNode) break;
+ current = current.parentNode;
+ }
+ let oldOffsetX = 0;
+ let oldOffsetY = 0;
+ let oldCurrent = oldStateNode.parentNode;
+ while (oldCurrent) {
+ oldOffsetX += oldCurrent.properties.x || 0;
+ oldOffsetY += oldCurrent.properties.y || 0;
+ if (oldCurrent.parentNode === oldState.rootNode) break;
+ oldCurrent = oldCurrent.parentNode;
+ }
+ oldStateNode.properties.x += oldOffsetX - offsetX;
+ oldStateNode.properties.y += oldOffsetY - offsetY;
+ }
+
+ if (node.hasVisibilitySwap) {
+ if (node.hasVisibilityHidden) {
+ node.$el.style.visibility = 'visible';
+ node.$measure.style.visibility = 'hidden';
+ }
+ if (node.hasDisplayNone) {
+ node.$el.style.display = oldStateNode.measuredDisplay || node.measuredDisplay || '';
+ // Setting visibility 'hidden' instead of display none to avoid calculation issues
+ node.$measure.style.visibility = 'hidden';
+ // @TODO: check why setting display here can cause calculation issues
+ // node.$measure.style.display = 'none';
+ }
+ }
+
+ const wasPendingRemoval = pendingRemoved.has($el);
+ const wasVisibleBefore = oldStateNode.measuredIsVisible;
+ const isVisibleNow = node.measuredIsVisible;
+ const becomeVisible = !wasVisibleBefore && isVisibleNow && !parentNotRendered;
+ const topLevelAdded = !isRemovedNow && (wasRemovedBefore || wasPendingRemoval) && !parentAdded;
+ const newlyRemoved = isRemovedNow && !wasRemovedBefore && !parentRemoved;
+ const topLevelRemoved = newlyRemoved || isRemovedNow && wasPendingRemoval && !parentRemoved;
+
+ if (node.measuredIsRemoved && wasVisibleBefore) {
+ node.$el.style.display = oldStateNode.measuredDisplay;
+ node.$el.style.visibility = 'visible';
+ cloneNodeProperties(oldStateNode, node, newState);
+ }
+
+ if (newlyRemoved) {
+ removed.push($el);
+ pendingRemoved.add($el);
+ } else if (!isRemovedNow && wasPendingRemoval) {
+ pendingRemoved.delete($el);
+ }
+
+ // Node is added
+ if ((topLevelAdded && !parentNotRendered) || becomeVisible) {
+ updateNodeProperties(oldStateNode, addedParams);
+ added.push($el);
+ // Node is removed
+ } else if (topLevelRemoved && !parentNotRendered) {
+ updateNodeProperties(node, removedParams);
+ }
+
+ // Compute function based propety values before cheking for changes
+ for (let name in node.properties) {
+ node.properties[name] = newState.getValue(node.$el, name);
+ // NOTE: I'm using node.$el to get the value of old state, make sure this is valid instead of oldStateNode.$el
+ oldStateNode.properties[name] = oldState.getValue(node.$el, name);
+ }
+
+ const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
+ let propertyChanged = false;
+
+
+ if (node.isTarget && (!node.measuredIsRemoved && wasVisibleBefore || node.measuredIsRemoved && isVisibleNow)) {
+ if (!node.isInlined && (node.properties.transform !== 'none' || oldStateNode.properties.transform !== 'none')) {
+ node.hasTransform = true;
+ propertyChanged = true;
+ transformed.push($el);
+ }
+ for (let name in node.properties) {
+ if (name !== 'transform' && (node.properties[name] !== oldStateNode.properties[name] || hiddenStateChanged)) {
+ propertyChanged = true;
+ animated.push($el);
+ break;
+ }
+ }
+ }
+
+ const nodeHasChanged = (propertyChanged || topLevelAdded || topLevelRemoved || becomeVisible);
+ const nodeIsAnimated = node.isTarget && nodeHasChanged;
+
+ node.isAnimated = nodeIsAnimated;
+ node.branchAdded = parentAdded || topLevelAdded;
+ node.branchRemoved = parentRemoved || topLevelRemoved;
+ node.branchNotRendered = parentNotRendered || node.measuredIsRemoved;
+
+ const sizeTolerance = 1;
+ const widthChanged = Math.abs(node.properties.width - oldStateNode.properties.width) > sizeTolerance;
+ const heightChanged = Math.abs(node.properties.height - oldStateNode.properties.height) > sizeTolerance;
+
+ node.sizeChanged = (widthChanged || heightChanged);
+
+ targets.push($el);
+
+ if (!node.isTarget) {
+ frozen.push($el);
+ if ((nodeHasChanged || node.sizeChanged) && parent && parent.isTarget && parent.isAnimated && parent.sizeChanged) {
+ animatedFrozen.push($el);
+ }
+ }
+ });
+
+ const defaults = {
+ ease: values.setValue(params.ease, this.ease),
+ duration: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).duration,
+ delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+
+ this.timeline = timeline.createTimeline({
+ onComplete: () => {
+ // Make sure to call .cancel() after restoreNodeInlineStyles(node); otehrwise the commited styles get reverted
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(node => {
+ restoreNodeVisualState(node);
+ restoreNodeInlineStyles(node);
+ });
+ for (let i = 0, l = transformed.length; i < l; i++) {
+ const $el = transformed[i];
+ $el.style.transform = newState.getValue($el, 'transform');
+ }
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ // Avoid CSS transitions at the end of the animation by restoring them on the next frame
+ requestAnimationFrame(() => {
+ if (this.root.classList.contains('is-animated')) return;
+ restoreLayoutTransition(this.transitionMuteStore);
+ });
+ },
+ onPause: () => {
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(restoreNodeVisualState);
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ },
+ composition: false,
+ defaults,
+ });
+
+ if (targets.length) {
+
+ this.root.classList.add('is-animated');
+
+ for (let i = 0, l = targets.length; i < l; i++) {
+ const $el = targets[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+
+ // Make sure to mute all CSS transition before applying the oldState styles back
+ muteNodeTransition(newNode);
+
+ // Don't animate dimensions and positions of inlined elements
+ if (!newNode.isInlined) {
+ // Display grid can mess with the absolute positioning, so set it to block during transition
+ // if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.display = 'block';
+ $el.style.display = 'block';
+ // All children must be in position absolue
+ if ($el !== root || this.absoluteCoords) {
+ $el.style.position = this.absoluteCoords ? 'fixed' : 'absolute';
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ $el.style.marginLeft = '0px';
+ $el.style.marginTop = '0px';
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ if ($el === root && newNode.measuredPosition === 'static') {
+ $el.style.position = 'relative';
+ // Cancel left / trop in case the static element had muted values now activated by potision relative
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ }
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ }
+ }
+
+ // Restore the scroll position if the oldState differs from the current state
+ if (oldState.scrollX !== window.scrollX || oldState.scrollY !== window.scrollY) {
+ // Restoring in the next frame avoids race conditions if for example a waapi animation commit styles that affect the root height
+ requestAnimationFrame(() => {
+ window.scrollTo(oldState.scrollX, oldState.scrollY);
+ });
+ }
+
+ for (let i = 0, l = animated.length; i < l; i++) {
+ const $el = animated[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+ const newNodeState = newNode.properties;
+ let hasChanged = false;
+ const animatedProps = {
+ composition: 'none',
+ // delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+ if (!newNode.isInlined) {
+ if (oldNodeState.width !== newNodeState.width) {
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
+ hasChanged = true;
+ }
+ if (oldNodeState.height !== newNodeState.height) {
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
+ hasChanged = true;
+ }
+ // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
+ // Always animate translate
+ if (!newNode.hasTransform) {
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
+ hasChanged = true;
+ }
+ }
+ this.properties.forEach(prop => {
+ const oldVal = oldNodeState[prop];
+ const newVal = newNodeState[prop];
+ if (prop !== 'transform' && oldVal !== newVal) {
+ animatedProps[prop] = [oldVal, newVal];
+ hasChanged = true;
+ }
+ });
+ if (hasChanged) {
+ this.timeline.add($el, animatedProps, 0);
+ }
+ }
+
+ }
+
+ if (frozen.length) {
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const oldNode = oldState.nodes.get($el.dataset.layoutId);
+ if (!oldNode.isInlined) {
+ const oldNodeState = oldState.get($el);
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${oldState.getValue($el, prop)}`;
+ }
+ });
+ }
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const newNode = newState.nodes.get($el.dataset.layoutId);
+ const newNodeState = newState.get($el);
+ this.timeline.call(() => {
+ if (!newNode.isInlined) {
+ $el.style.width = `${newNodeState.width}px`;
+ $el.style.height = `${newNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${newNodeState.x}px ${newNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${newState.getValue($el, prop)}`;
+ }
+ });
+ }, newNode.delay + newNode.duration / 2);
+ }
+
+ if (animatedFrozen.length) {
+ const animatedFrozenParams = /** @type {AnimationParams} */({});
+ if (frozenParams) {
+ for (let prop in frozenParams) {
+ animatedFrozenParams[prop] = [
+ { from: (/** @type {HTMLElement} */$el) => oldState.getValue($el, prop), ease: 'in(1.75)', to: frozenParams[prop] },
+ { from: frozenParams[prop], to: (/** @type {HTMLElement} */$el) => newState.getValue($el, prop), ease: 'out(1.75)' }
+ ];
+ }
+ }
+ this.timeline.add(animatedFrozen, animatedFrozenParams, 0);
+ }
+
+ }
+
+ const transformedLength = transformed.length;
+
+ if (transformedLength) {
+ // We only need to set the transform property here since translate is alread defined the targets loop
+ for (let i = 0; i < transformedLength; i++) {
+ const $el = transformed[i];
+ $el.style.translate = `${oldState.get($el).x}px ${oldState.get($el).y}px`,
+ $el.style.transform = oldState.getValue($el, 'transform');
+ }
+ this.transformAnimation = waapi.waapi.animate(transformed, {
+ translate: (/** @type {HTMLElement} */$el) => `${newState.get($el).x}px ${newState.get($el).y}px`,
+ transform: (/** @type {HTMLElement} */$el) => newState.getValue($el, 'transform'),
+ autoplay: false,
+ persist: true,
+ ...defaults,
+ });
+ this.timeline.sync(this.transformAnimation, 0);
+ }
+
+ return this.timeline.init();
+ }
+
+ /**
+ * @param {(layout: this) => void} callback
+ * @param {LayoutAnimationParams} [params]
+ * @return {this}
+ */
+ update(callback, params = {}) {
+ this.record();
+ callback(this);
+ this.animate(params);
+ return this;
+ }
+}
+
+/**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ * @return {AutoLayout}
+ */
+const createLayout = (root, params) => new AutoLayout(root, params);
+
+exports.AutoLayout = AutoLayout;
+exports.createLayout = createLayout;
diff --git a/dist/modules/layout/layout.d.ts b/dist/modules/layout/layout.d.ts
new file mode 100644
index 00000000..64ede722
--- /dev/null
+++ b/dist/modules/layout/layout.d.ts
@@ -0,0 +1,211 @@
+export class AutoLayout {
+ /**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ */
+ constructor(root: DOMTargetSelector, params?: AutoLayoutParams);
+ /** @type {AutoLayoutParams} */
+ params: AutoLayoutParams;
+ /** @type {DOMTarget} */
+ root: DOMTarget;
+ /** @type {Number} */
+ id: number;
+ /** @type {LayoutChildrenParam} */
+ children: LayoutChildrenParam;
+ /** @type {Boolean} */
+ absoluteCoords: boolean;
+ /** @type {Number} */
+ duration: number;
+ /** @type {Number|FunctionValue} */
+ delay: number | FunctionValue;
+ /** @type {EasingParam} */
+ ease: EasingParam;
+ /** @type {Callback<this>} */
+ onComplete: Callback<this>;
+ /** @type {LayoutStateParams} */
+ frozenParams: LayoutStateParams;
+ /** @type {LayoutStateParams} */
+ addedParams: LayoutStateParams;
+ /** @type {LayoutStateParams} */
+ removedParams: LayoutStateParams;
+ /** @type {Set<String>} */
+ properties: Set<string>;
+ /** @type {Set<String>} */
+ recordedProperties: Set<string>;
+ /** @type {WeakSet<DOMTarget>} */
+ pendingRemoved: WeakSet<DOMTarget>;
+ /** @type {Map<DOMTarget, String|null>} */
+ transitionMuteStore: Map<DOMTarget, string | null>;
+ /** @type {LayoutSnapshot} */
+ oldState: LayoutSnapshot;
+ /** @type {LayoutSnapshot} */
+ newState: LayoutSnapshot;
+ /** @type {Timeline|null} */
+ timeline: Timeline | null;
+ /** @type {WAAPIAnimation|null} */
+ transformAnimation: WAAPIAnimation | null;
+ /** @type {Array<DOMTarget>} */
+ frozen: Array<DOMTarget>;
+ /** @type {Array<DOMTarget>} */
+ removed: Array<DOMTarget>;
+ /** @type {Array<DOMTarget>} */
+ added: Array<DOMTarget>;
+ /**
+ * @return {this}
+ */
+ revert(): this;
+ /**
+ * @return {this}
+ */
+ record(): this;
+ /**
+ * @param {LayoutAnimationParams} [params]
+ * @return {Timeline}
+ */
+ animate(params?: LayoutAnimationParams): Timeline;
+ /**
+ * @param {(layout: this) => void} callback
+ * @param {LayoutAnimationParams} [params]
+ * @return {this}
+ */
+ update(callback: (layout: this) => void, params?: LayoutAnimationParams): this;
+}
+export function createLayout(root: DOMTargetSelector, params?: AutoLayoutParams): AutoLayout;
+export type LayoutChildrenParam = DOMTargetSelector | Array<DOMTargetSelector>;
+export type LayoutStateParams = Record<string, number | string>;
+export type LayoutAnimationParams = {
+ duration?: number;
+ delay?: number | FunctionValue;
+ ease?: EasingParam;
+ frozen?: LayoutStateParams;
+ added?: LayoutStateParams;
+ removed?: LayoutStateParams;
+ onComplete?: Callback<AutoLayout>;
+};
+export type AutoLayoutParams = LayoutAnimationParams & {
+ children?: LayoutChildrenParam;
+ properties?: Array<string>;
+};
+export type LayoutNodeProperties = Record<string, number | string> & {
+ transform: string;
+ x: number;
+ y: number;
+ left: number;
+ top: number;
+ clientLeft: number;
+ clientTop: number;
+ width: number;
+ height: number;
+};
+export type LayoutNode = {
+ id: string;
+ $el: DOMTarget;
+ index: number;
+ total: number;
+ delay: number;
+ duration: number;
+ $measure: DOMTarget;
+ state: LayoutSnapshot;
+ layout: AutoLayout;
+ parentNode: LayoutNode | null;
+ isTarget: boolean;
+ hasTransform: boolean;
+ isAnimated: boolean;
+ inlineStyles: Array<string>;
+ inlineTransforms: string | null;
+ inlineTransition: string | null;
+ branchAdded: boolean;
+ branchRemoved: boolean;
+ branchNotRendered: boolean;
+ sizeChanged: boolean;
+ isInlined: boolean;
+ hasVisibilitySwap: boolean;
+ hasDisplayNone: boolean;
+ hasVisibilityHidden: boolean;
+ measuredInlineTransform: string | null;
+ measuredInlineTransition: string | null;
+ measuredDisplay: string | null;
+ measuredVisibility: string | null;
+ measuredPosition: string | null;
+ measuredHasDisplayNone: boolean;
+ measuredHasVisibilityHidden: boolean;
+ measuredIsVisible: boolean;
+ measuredIsRemoved: boolean;
+ measuredIsInsideRoot: boolean;
+ properties: LayoutNodeProperties;
+ _head: LayoutNode | null;
+ _tail: LayoutNode | null;
+ _prev: LayoutNode | null;
+ _next: LayoutNode | null;
+};
+export type LayoutNodeIterator = (node: LayoutNode, index: number) => void;
+import type { DOMTarget } from '../types/index.js';
+import type { FunctionValue } from '../types/index.js';
+import type { EasingParam } from '../types/index.js';
+import type { Callback } from '../types/index.js';
+declare class LayoutSnapshot {
+ /**
+ * @param {AutoLayout} layout
+ */
+ constructor(layout: AutoLayout);
+ /** @type {AutoLayout} */
+ layout: AutoLayout;
+ /** @type {LayoutNode|null} */
+ rootNode: LayoutNode | null;
+ /** @type {Set<LayoutNode>} */
+ rootNodes: Set<LayoutNode>;
+ /** @type {Map<String, LayoutNode>} */
+ nodes: Map<string, LayoutNode>;
+ /** @type {Number} */
+ scrollX: number;
+ /** @type {Number} */
+ scrollY: number;
+ /**
+ * @return {this}
+ */
+ revert(): this;
+ /**
+ * @param {DOMTarget} $el
+ * @return {LayoutNodeProperties|undefined}
+ */
+ get($el: DOMTarget): LayoutNodeProperties | undefined;
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} prop
+ * @return {Number|String|undefined}
+ */
+ getValue($el: DOMTarget, prop: string): number | string | undefined;
+ /**
+ * @param {LayoutNode|null} rootNode
+ * @param {LayoutNodeIterator} cb
+ */
+ forEach(rootNode: LayoutNode | null, cb: LayoutNodeIterator): void;
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachRootNode(cb: LayoutNodeIterator): void;
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachNode(cb: LayoutNodeIterator): void;
+ /**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @return {LayoutNode|null}
+ */
+ registerElement($el: DOMTarget, parentNode: LayoutNode | null): LayoutNode | null;
+ /**
+ * @param {DOMTarget} $el
+ * @param {Set<DOMTarget>} candidates
+ * @return {LayoutNode|null}
+ */
+ ensureDetachedNode($el: DOMTarget, candidates: Set<DOMTarget>): LayoutNode | null;
+ /**
+ * @return {this}
+ */
+ record(): this;
+}
+import type { Timeline } from '../timeline/timeline.js';
+import type { WAAPIAnimation } from '../waapi/waapi.js';
+import type { DOMTargetSelector } from '../types/index.js';
+export {};
diff --git a/dist/modules/layout/layout.js b/dist/modules/layout/layout.js
new file mode 100644
index 00000000..1da0a5f2
--- /dev/null
+++ b/dist/modules/layout/layout.js
@@ -0,0 +1,1381 @@
+/**
+ * Anime.js - layout - ESM
+ * @version v4.3.0-beta.0
+ * @license MIT
+ * @copyright 2025 - Julian Garnier
+ */
+
+import { mergeObjects, isFnc, isUnd, isSvg, isStr, isArr } from '../core/helpers.js';
+import { registerTargets } from '../core/targets.js';
+import { setValue, getFunctionValue } from '../core/values.js';
+import { noop } from '../core/consts.js';
+import { createTimeline } from '../timeline/timeline.js';
+import { waapi } from '../waapi/waapi.js';
+import { scope } from '../core/globals.js';
+
+/**
+ * @import {
+ * AnimationParams,
+ * } from '../types/index.js'
+*/
+
+/**
+ * @import {
+ * Timeline,
+ * } from '../timeline/timeline.js'
+*/
+
+/**
+ * @import {
+ * WAAPIAnimation
+ * } from '../waapi/waapi.js'
+*/
+
+/**
+ * @import {
+ * DOMTarget,
+ * DOMTargetSelector,
+ * FunctionValue,
+ * EasingParam,
+ * Callback,
+ } from '../types/index.js'
+*/
+
+/**
+ * @typedef {DOMTargetSelector|Array<DOMTargetSelector>} LayoutChildrenParam
+ */
+
+/**
+ * @typedef {Record<String, Number|String>} LayoutStateParams
+ */
+
+/**
+ * @typedef {Object} LayoutAnimationParams
+ * @property {Number} [duration]
+ * @property {Number|FunctionValue} [delay]
+ * @property {EasingParam} [ease]
+ * @property {LayoutStateParams} [frozen]
+ * @property {LayoutStateParams} [added]
+ * @property {LayoutStateParams} [removed]
+ * @property {Callback<AutoLayout>} [onComplete]
+ */
+
+/**
+ * @typedef {LayoutAnimationParams & {
+ * children?: LayoutChildrenParam,
+ * properties?: Array<String>,
+ * }} AutoLayoutParams
+ */
+
+/**
+ * @typedef {Record<String, Number|String> & {
+ * transform: String,
+ * x: Number,
+ * y: Number,
+ * left: Number,
+ * top: Number,
+ * clientLeft: Number,
+ * clientTop: Number,
+ * width: Number,
+ * height: Number,
+ * }} LayoutNodeProperties
+ */
+
+/**
+ * @typedef {Object} LayoutNode
+ * @property {String} id
+ * @property {DOMTarget} $el
+ * @property {Number} index
+ * @property {Number} total
+ * @property {Number} delay
+ * @property {Number} duration
+ * @property {DOMTarget} $measure
+ * @property {LayoutSnapshot} state
+ * @property {AutoLayout} layout
+ * @property {LayoutNode|null} parentNode
+ * @property {Boolean} isTarget
+ * @property {Boolean} hasTransform
+ * @property {Boolean} isAnimated
+ * @property {Array<String>} inlineStyles
+ * @property {String|null} inlineTransforms
+ * @property {String|null} inlineTransition
+ * @property {Boolean} branchAdded
+ * @property {Boolean} branchRemoved
+ * @property {Boolean} branchNotRendered
+ * @property {Boolean} sizeChanged
+ * @property {Boolean} isInlined
+ * @property {Boolean} hasVisibilitySwap
+ * @property {Boolean} hasDisplayNone
+ * @property {Boolean} hasVisibilityHidden
+ * @property {String|null} measuredInlineTransform
+ * @property {String|null} measuredInlineTransition
+ * @property {String|null} measuredDisplay
+ * @property {String|null} measuredVisibility
+ * @property {String|null} measuredPosition
+ * @property {Boolean} measuredHasDisplayNone
+ * @property {Boolean} measuredHasVisibilityHidden
+ * @property {Boolean} measuredIsVisible
+ * @property {Boolean} measuredIsRemoved
+ * @property {Boolean} measuredIsInsideRoot
+ * @property {LayoutNodeProperties} properties
+ * @property {LayoutNode|null} _head
+ * @property {LayoutNode|null} _tail
+ * @property {LayoutNode|null} _prev
+ * @property {LayoutNode|null} _next
+ */
+
+/**
+ * @callback LayoutNodeIterator
+ * @param {LayoutNode} node
+ * @param {Number} index
+ * @return {void}
+ */
+
+let layoutId = 0;
+let nodeId = 0;
+
+/**
+ * @param {DOMTarget} root
+ * @param {DOMTarget} $el
+ * @return {Boolean}
+ */
+const isElementInRoot = (root, $el) => {
+ if (!root || !$el) return false;
+ return root === $el || root.contains($el);
+};
+
+/**
+ * @param {Node} node
+ * @param {'previousSibling'|'nextSibling'} direction
+ * @return {Boolean}
+ */
+const hasTextSibling = (node, direction) => {
+ let sibling = node[direction];
+ while (sibling && sibling.nodeType === Node.TEXT_NODE && !sibling.textContent.trim()) {
+ sibling = sibling[direction];
+ }
+ return sibling && sibling.nodeType === Node.TEXT_NODE;
+};
+
+/**
+ * @param {DOMTarget} $el
+ * @return {Boolean}
+ */
+const isElementSurroundedByText = $el => hasTextSibling($el, 'previousSibling') || hasTextSibling($el, 'nextSibling');
+
+/**
+ * @param {DOMTarget|null} $el
+ * @return {String|null}
+ */
+const muteElementTransition = $el => {
+ if (!$el) return null;
+ const style = $el.style;
+ const transition = style.transition || '';
+ style.setProperty('transition', 'none', 'important');
+ return transition;
+};
+
+/**
+ * @param {DOMTarget|null} $el
+ * @param {String|null} transition
+ */
+const restoreElementTransition = ($el, transition) => {
+ if (!$el) return;
+ const style = $el.style;
+ if (transition) {
+ style.transition = transition;
+ } else {
+ style.removeProperty('transition');
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const muteNodeTransition = node => {
+ const store = node.layout.transitionMuteStore;
+ const $el = node.$el;
+ const $measure = node.$measure;
+ if ($el && !store.has($el)) store.set($el, muteElementTransition($el));
+ if ($measure && !store.has($measure)) store.set($measure, muteElementTransition($measure));
+};
+
+/**
+ * @param {Map<DOMTarget, String|null>} store
+ */
+const restoreLayoutTransition = store => {
+ store.forEach((value, $el) => restoreElementTransition($el, value));
+ store.clear();
+};
+
+const hiddenComputedStyle = /** @type {CSSStyleDeclaration} */({
+ display: 'none',
+ visibility: 'hidden',
+ opacity: '0',
+ transform: 'none',
+ position: 'static',
+});
+
+/**
+ * @param {LayoutNode|null} node
+ */
+const detachNode = node => {
+ if (!node) return;
+ const parent = node.parentNode;
+ if (!parent) return;
+ if (parent._head === node) parent._head = node._next;
+ if (parent._tail === node) parent._tail = node._prev;
+ if (node._prev) node._prev._next = node._next;
+ if (node._next) node._next._prev = node._prev;
+ node._prev = null;
+ node._next = null;
+ node.parentNode = null;
+};
+
+/**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @param {LayoutSnapshot} state
+ * @param {LayoutNode} [recycledNode]
+ * @return {LayoutNode}
+ */
+const createNode = ($el, parentNode, state, recycledNode) => {
+ let dataId = $el.dataset.layoutId;
+ if (!dataId) dataId = $el.dataset.layoutId = `node-${nodeId++}`;
+ const node = recycledNode ? recycledNode : /** @type {LayoutNode} */({});
+ node.$el = $el;
+ node.$measure = $el;
+ node.id = dataId;
+ node.index = 0;
+ node.total = 1;
+ node.delay = 0;
+ node.duration = 0;
+ node.state = state;
+ node.layout = state.layout;
+ node.parentNode = parentNode || null;
+ node.isTarget = false;
+ node.hasTransform = false;
+ node.isAnimated = false;
+ node.inlineStyles = [];
+ node.inlineTransforms = null;
+ node.inlineTransition = null;
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.sizeChanged = false;
+ node.isInlined = false;
+ node.hasVisibilitySwap = false;
+ node.hasDisplayNone = false;
+ node.hasVisibilityHidden = false;
+ node.measuredInlineTransform = null;
+ node.measuredInlineTransition = null;
+ node.measuredDisplay = null;
+ node.measuredVisibility = null;
+ node.measuredPosition = null;
+ node.measuredHasDisplayNone = false;
+ node.measuredHasVisibilityHidden = false;
+ node.measuredIsVisible = false;
+ node.measuredIsRemoved = false;
+ node.measuredIsInsideRoot = false;
+ node.properties = /** @type {LayoutNodeProperties} */({
+ transform: 'none',
+ x: 0,
+ y: 0,
+ left: 0,
+ top: 0,
+ clientLeft: 0,
+ clientTop: 0,
+ width: 0,
+ height: 0,
+ });
+ node.layout.properties.forEach(prop => node.properties[prop] = 0);
+ node._head = null;
+ node._tail = null;
+ node._prev = null;
+ node._next = null;
+ return node;
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {DOMTarget} $measure
+ * @param {CSSStyleDeclaration} computedStyle
+ * @param {Boolean} skipMeasurements
+ * @return {LayoutNode}
+ */
+const recordNodeState = (node, $measure, computedStyle, skipMeasurements) => {
+ const $el = node.$el;
+ const root = node.layout.root;
+ const isRoot = root === $el;
+ const properties = node.properties;
+ const rootNode = node.state.rootNode;
+ const parentNode = node.parentNode;
+ const computedTransforms = computedStyle.transform;
+ const inlineTransforms = $el.style.transform;
+ const parentNotRendered = parentNode ? parentNode.measuredIsRemoved : false;
+ const position = computedStyle.position;
+ if (isRoot) node.layout.absoluteCoords = position === 'fixed' || position === 'absolute';
+ node.$measure = $measure;
+ node.inlineTransforms = inlineTransforms;
+ node.hasTransform = computedTransforms && computedTransforms !== 'none';
+ node.measuredIsInsideRoot = isElementInRoot(root, $measure);
+ node.measuredInlineTransform = null;
+ node.measuredDisplay = computedStyle.display;
+ node.measuredVisibility = computedStyle.visibility;
+ node.measuredPosition = position;
+ node.measuredHasDisplayNone = computedStyle.display === 'none';
+ node.measuredHasVisibilityHidden = computedStyle.visibility === 'hidden';
+ node.measuredIsVisible = !(node.measuredHasDisplayNone || node.measuredHasVisibilityHidden);
+ node.measuredIsRemoved = node.measuredHasDisplayNone || node.measuredHasVisibilityHidden || parentNotRendered;
+ node.isInlined = node.measuredDisplay.includes('inline') && isElementSurroundedByText($el);
+
+ // Mute transforms (and transition to avoid triggering an animation) before the position calculation
+ if (node.hasTransform && !skipMeasurements) {
+ const transitionMuteStore = node.layout.transitionMuteStore;
+ if (!transitionMuteStore.get($el)) node.inlineTransition = muteElementTransition($el);
+ if ($measure === $el) {
+ $el.style.transform = 'none';
+ } else {
+ if (!transitionMuteStore.get($measure)) node.measuredInlineTransition = muteElementTransition($measure);
+ node.measuredInlineTransform = $measure.style.transform;
+ $measure.style.transform = 'none';
+ }
+ }
+
+ let left = 0;
+ let top = 0;
+ let width = 0;
+ let height = 0;
+
+ if (!skipMeasurements) {
+ const rect = $measure.getBoundingClientRect();
+ left = rect.left;
+ top = rect.top;
+ width = rect.width;
+ height = rect.height;
+ }
+
+ for (let name in properties) {
+ const computedProp = name === 'transform' ? computedTransforms : computedStyle[name] || (computedStyle.getPropertyValue && computedStyle.getPropertyValue(name));
+ if (!isUnd(computedProp)) properties[name] = computedProp;
+ }
+
+ properties.left = left;
+ properties.top = top;
+ properties.clientLeft = skipMeasurements ? 0 : $measure.clientLeft;
+ properties.clientTop = skipMeasurements ? 0 : $measure.clientTop;
+ // Compute local x/y relative to parent
+ let absoluteLeft, absoluteTop;
+ if (isRoot) {
+ if (!node.layout.absoluteCoords) {
+ absoluteLeft = 0;
+ absoluteTop = 0;
+ } else {
+ absoluteLeft = left;
+ absoluteTop = top;
+ }
+ } else {
+ const p = parentNode || rootNode;
+ const parentLeft = p.properties.left;
+ const parentTop = p.properties.top;
+ const borderLeft = p.properties.clientLeft;
+ const borderTop = p.properties.clientTop;
+ if (!node.layout.absoluteCoords) {
+ if (p === rootNode) {
+ const rootLeft = rootNode.properties.left;
+ const rootTop = rootNode.properties.top;
+ const rootBorderLeft = rootNode.properties.clientLeft;
+ const rootBorderTop = rootNode.properties.clientTop;
+ absoluteLeft = left - rootLeft - rootBorderLeft;
+ absoluteTop = top - rootTop - rootBorderTop;
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ } else {
+ absoluteLeft = left - parentLeft - borderLeft;
+ absoluteTop = top - parentTop - borderTop;
+ }
+ }
+ properties.x = absoluteLeft;
+ properties.y = absoluteTop;
+ properties.width = width;
+ properties.height = height;
+ return node;
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {LayoutStateParams} [props]
+ */
+const updateNodeProperties = (node, props) => {
+ if (!props) return;
+ for (let name in props) {
+ node.properties[name] = props[name];
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const recordNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ stylesStore.length = 0;
+ node.layout.recordedProperties.forEach(prop => {
+ stylesStore.push(prop, style[prop] || '');
+ });
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeInlineStyles = node => {
+ const style = node.$el.style;
+ const stylesStore = node.inlineStyles;
+ for (let i = 0, l = stylesStore.length; i < l; i += 2) {
+ const property = stylesStore[i];
+ const styleValue = stylesStore[i + 1];
+ if (styleValue && styleValue !== '') {
+ style[property] = styleValue;
+ } else {
+ style[property] = '';
+ style.removeProperty(property);
+ }
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeTransform = node => {
+ const inlineTransforms = node.inlineTransforms;
+ const nodeStyle = node.$el.style;
+ if (!node.hasTransform || !inlineTransforms || (node.hasTransform && nodeStyle.transform === 'none') || (inlineTransforms && inlineTransforms === 'none')) {
+ nodeStyle.removeProperty('transform');
+ } else if (inlineTransforms) {
+ nodeStyle.transform = inlineTransforms;
+ }
+ const $measure = node.$measure;
+ if (node.hasTransform && $measure !== node.$el) {
+ const measuredStyle = $measure.style;
+ const measuredInline = node.measuredInlineTransform;
+ if (measuredInline && measuredInline !== '') {
+ measuredStyle.transform = measuredInline;
+ } else {
+ measuredStyle.removeProperty('transform');
+ }
+ }
+ node.measuredInlineTransform = null;
+ if (node.inlineTransition !== null) {
+ restoreElementTransition(node.$el, node.inlineTransition);
+ node.inlineTransition = null;
+ }
+ if ($measure !== node.$el && node.measuredInlineTransition !== null) {
+ restoreElementTransition($measure, node.measuredInlineTransition);
+ node.measuredInlineTransition = null;
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ */
+const restoreNodeVisualState = node => {
+ if (node.measuredIsRemoved || node.hasVisibilitySwap) {
+ node.$el.style.removeProperty('display');
+ node.$el.style.removeProperty('visibility');
+ if (node.hasVisibilitySwap) {
+ node.$measure.style.removeProperty('display');
+ node.$measure.style.removeProperty('visibility');
+ }
+ }
+ if (node.measuredIsRemoved) {
+ node.layout.pendingRemoved.delete(node.$el);
+ }
+};
+
+/**
+ * @param {LayoutNode} node
+ * @param {LayoutNode} targetNode
+ * @param {LayoutSnapshot} newState
+ * @return {LayoutNode}
+ */
+const cloneNodeProperties = (node, targetNode, newState) => {
+ targetNode.properties = /** @type {LayoutNodeProperties} */({ ...node.properties });
+ targetNode.state = newState;
+ targetNode.isTarget = node.isTarget;
+ targetNode.hasTransform = node.hasTransform;
+ targetNode.inlineTransforms = node.inlineTransforms;
+ targetNode.measuredIsVisible = node.measuredIsVisible;
+ targetNode.measuredDisplay = node.measuredDisplay;
+ targetNode.measuredIsRemoved = node.measuredIsRemoved;
+ targetNode.measuredHasDisplayNone = node.measuredHasDisplayNone;
+ targetNode.measuredHasVisibilityHidden = node.measuredHasVisibilityHidden;
+ targetNode.hasDisplayNone = node.hasDisplayNone;
+ targetNode.isInlined = node.isInlined;
+ targetNode.hasVisibilityHidden = node.hasVisibilityHidden;
+ return targetNode;
+};
+
+class LayoutSnapshot {
+ /**
+ * @param {AutoLayout} layout
+ */
+ constructor(layout) {
+ /** @type {AutoLayout} */
+ this.layout = layout;
+ /** @type {LayoutNode|null} */
+ this.rootNode = null;
+ /** @type {Set<LayoutNode>} */
+ this.rootNodes = new Set();
+ /** @type {Map<String, LayoutNode>} */
+ this.nodes = new Map();
+ /** @type {Number} */
+ this.scrollX = 0;
+ /** @type {Number} */
+ this.scrollY = 0;
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ this.forEachNode(node => {
+ node.$el.removeAttribute('data-layout-id');
+ node.$measure.removeAttribute('data-layout-id');
+ });
+ this.rootNode = null;
+ this.rootNodes.clear();
+ this.nodes.clear();
+ return this;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @return {LayoutNodeProperties|undefined}
+ */
+ get($el) {
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ return node.properties;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {String} prop
+ * @return {Number|String|undefined}
+ */
+ getValue($el, prop) {
+ if (!$el || !$el.dataset) {
+ console.warn(`No element found on state (${$el})`);
+ return;
+ }
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (!node) {
+ console.warn(`No node found on state`);
+ return;
+ }
+ const value = node.properties[prop];
+ if (!isUnd(value)) return getFunctionValue(value, $el, node.index, node.total);
+ }
+
+ /**
+ * @param {LayoutNode|null} rootNode
+ * @param {LayoutNodeIterator} cb
+ */
+ forEach(rootNode, cb) {
+ let node = rootNode;
+ let i = 0;
+ while (node) {
+ cb(node, i++);
+ if (node._head) {
+ node = node._head;
+ } else if (node._next) {
+ node = node._next;
+ } else {
+ while (node && !node._next) {
+ node = node.parentNode;
+ }
+ if (node) node = node._next;
+ }
+ }
+ }
+
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachRootNode(cb) {
+ this.forEach(this.rootNode, cb);
+ }
+
+ /**
+ * @param {LayoutNodeIterator} cb
+ */
+ forEachNode(cb) {
+ for (const rootNode of this.rootNodes) {
+ this.forEach(rootNode, cb);
+ }
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {LayoutNode|null} parentNode
+ * @return {LayoutNode|null}
+ */
+ registerElement($el, parentNode) {
+ if (!$el || $el.nodeType !== 1) return null;
+
+ if (!this.layout.transitionMuteStore.has($el)) this.layout.transitionMuteStore.set($el, muteElementTransition($el));
+
+ /** @type {Array<DOMTarget|LayoutNode|null>} */
+ const stack = [$el, parentNode];
+ const root = this.layout.root;
+ let firstNode = null;
+
+ while (stack.length) {
+ /** @type {LayoutNode|null} */
+ const $parent = /** @type {LayoutNode|null} */(stack.pop());
+ /** @type {DOMTarget|null} */
+ const $current = /** @type {DOMTarget|null} */(stack.pop());
+ if (!$current || $current.nodeType !== 1 || isSvg($current)) continue;
+
+ const skipMeasurements = $parent ? $parent.measuredIsRemoved : false;
+
+ const computedStyle = skipMeasurements ? hiddenComputedStyle : getComputedStyle($current);
+ const hasDisplayNone = skipMeasurements ? true : computedStyle.display === 'none';
+ const hasVisibilityHidden = skipMeasurements ? true : computedStyle.visibility === 'hidden';
+ const isVisible = !hasDisplayNone && !hasVisibilityHidden;
+ const existingId = $current.dataset.layoutId;
+ const isInsideRoot = isElementInRoot(root, $current);
+
+ let node = existingId ? this.nodes.get(existingId) : null;
+
+ if (node && node.$el !== $current) {
+ const nodeInsideRoot = isElementInRoot(root, node.$el);
+ const measuredVisible = node.measuredIsVisible;
+ const shouldReassignNode = !nodeInsideRoot && (isInsideRoot || (!isInsideRoot && !measuredVisible && isVisible));
+ const shouldReuseMeasurements = nodeInsideRoot && !measuredVisible && isVisible;
+ // Rebind nodes that move into the root or whose detached twin just became visible
+ if (shouldReassignNode) {
+ detachNode(node);
+ node = createNode($current, $parent, this, node);
+ // for hidden element with in-root sibling, keep the hidden node but borrow measurements from its visible in-root twin element
+ } else if (shouldReuseMeasurements) {
+ recordNodeState(node, $current, computedStyle, skipMeasurements);
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ // No reassignment needed so keep walking descendants under the current parent
+ } else {
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), $parent);
+ $child = $child.previousElementSibling;
+ }
+ if (!firstNode) firstNode = node;
+ continue;
+ }
+ } else {
+ node = createNode($current, $parent, this, node);
+ }
+
+ node.branchAdded = false;
+ node.branchRemoved = false;
+ node.branchNotRendered = false;
+ node.isTarget = false;
+ node.isAnimated = false;
+ node.hasVisibilityHidden = hasVisibilityHidden;
+ node.hasDisplayNone = hasDisplayNone;
+ node.hasVisibilitySwap = (hasVisibilityHidden && !node.measuredHasVisibilityHidden) || (hasDisplayNone && !node.measuredHasDisplayNone);
+ // node.hasVisibilitySwap = (hasVisibilityHidden !== node.measuredHasVisibilityHidden) || (hasDisplayNone !== node.measuredHasDisplayNone);
+
+ this.nodes.set(node.id, node);
+
+ node.parentNode = $parent || null;
+ node._prev = null;
+ node._next = null;
+
+ if ($parent) {
+ this.rootNodes.delete(node);
+ if (!$parent._head) {
+ $parent._head = node;
+ $parent._tail = node;
+ } else {
+ $parent._tail._next = node;
+ node._prev = $parent._tail;
+ $parent._tail = node;
+ }
+ } else {
+ this.rootNodes.add(node);
+ }
+
+ recordNodeState(node, node.$el, computedStyle, skipMeasurements);
+
+ let $child = $current.lastElementChild;
+ while ($child) {
+ stack.push(/** @type {DOMTarget} */($child), node);
+ $child = $child.previousElementSibling;
+ }
+
+ if (!firstNode) firstNode = node;
+ }
+
+ return firstNode;
+ }
+
+ /**
+ * @param {DOMTarget} $el
+ * @param {Set<DOMTarget>} candidates
+ * @return {LayoutNode|null}
+ */
+ ensureDetachedNode($el, candidates) {
+ if (!$el || $el === this.layout.root) return null;
+ const existingId = $el.dataset.layoutId;
+ const existingNode = existingId ? this.nodes.get(existingId) : null;
+ if (existingNode && existingNode.$el === $el) return existingNode;
+ let parentNode = null;
+ let $ancestor = $el.parentElement;
+ while ($ancestor && $ancestor !== this.layout.root) {
+ if (candidates.has($ancestor)) {
+ parentNode = this.ensureDetachedNode($ancestor, candidates);
+ break;
+ }
+ $ancestor = $ancestor.parentElement;
+ }
+ return this.registerElement($el, parentNode);
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ const { children, root } = this.layout;
+ const toParse = isArr(children) ? children : [children];
+ const scoped = [];
+ const scopeRoot = children === '*' ? root : scope.root;
+
+ for (let i = 0, l = toParse.length; i < l; i++) {
+ const child = toParse[i];
+ scoped[i] = isStr(child) ? scopeRoot.querySelectorAll(child) : child;
+ }
+
+ const parsedChildren = registerTargets(scoped);
+
+ this.nodes.clear();
+ this.rootNodes.clear();
+
+ const rootNode = this.registerElement(root, null);
+ // Root node are always targets
+ rootNode.isTarget = true;
+ this.rootNode = rootNode;
+
+ // Track ids of nodes that belong to the current root to filter detached matches
+ const inRootNodeIds = new Set();
+ this.nodes.forEach((node, id) => {
+ if (node && node.measuredIsInsideRoot) {
+ inRootNodeIds.add(id);
+ }
+ });
+
+ // Elements with a layout id outside the root that match the children selector
+ const detachedElementsLookup = new Set();
+ const orderedDetachedElements = [];
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ if (!$el || $el.nodeType !== 1 || $el === root) continue;
+ const insideRoot = isElementInRoot(root, $el);
+ if (!insideRoot) {
+ const layoutNodeId = $el.dataset.layoutId;
+ if (!layoutNodeId || !inRootNodeIds.has(layoutNodeId)) continue;
+ }
+ if (!detachedElementsLookup.has($el)) {
+ detachedElementsLookup.add($el);
+ orderedDetachedElements.push($el);
+ }
+ }
+
+ for (let i = 0, l = orderedDetachedElements.length; i < l; i++) {
+ this.ensureDetachedNode(orderedDetachedElements[i], detachedElementsLookup);
+ }
+
+ for (let i = 0, l = parsedChildren.length; i < l; i++) {
+ const $el = parsedChildren[i];
+ const node = this.nodes.get($el.dataset.layoutId);
+ if (node) {
+ let cur = node;
+ while (cur) {
+ if (cur.isTarget) break;
+ cur.isTarget = true;
+ cur = cur.parentNode;
+ }
+ }
+ }
+
+ this.scrollX = window.scrollX;
+ this.scrollY = window.scrollY;
+
+ const total = this.nodes.size;
+
+ this.forEachNode(restoreNodeTransform);
+ this.forEachNode((node, i) => {
+ node.index = i;
+ node.total = total;
+ });
+
+ return this;
+ }
+}
+
+class AutoLayout {
+ /**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ */
+ constructor(root, params = {}) {
+ if (scope.current) scope.current.register(this);
+ const frozenParams = params.frozen;
+ const addedParams = params.added;
+ const removedParams = params.removed;
+ const propsParams = params.properties;
+ /** @type {AutoLayoutParams} */
+ this.params = params;
+ /** @type {DOMTarget} */
+ this.root = /** @type {DOMTarget} */(registerTargets(root)[0]);
+ /** @type {Number} */
+ this.id = layoutId++;
+ /** @type {LayoutChildrenParam} */
+ this.children = params.children || '*';
+ /** @type {Boolean} */
+ this.absoluteCoords = false;
+ /** @type {Number} */
+ this.duration = setValue(params.duration, 500);
+ /** @type {Number|FunctionValue} */
+ this.delay = setValue(params.delay, 0);
+ /** @type {EasingParam} */
+ this.ease = setValue(params.ease, 'inOutExpo');
+ /** @type {Callback<this>} */
+ this.onComplete = setValue(params.onComplete, /** @type {Callback<this>} */(noop));
+ /** @type {LayoutStateParams} */
+ this.frozenParams = frozenParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.addedParams = addedParams || { opacity: 0 };
+ /** @type {LayoutStateParams} */
+ this.removedParams = removedParams || { opacity: 0 };
+ /** @type {Set<String>} */
+ this.properties = new Set([
+ 'opacity',
+ 'borderRadius',
+ ]);
+ if (frozenParams) for (let name in frozenParams) this.properties.add(name);
+ if (addedParams) for (let name in addedParams) this.properties.add(name);
+ if (removedParams) for (let name in removedParams) this.properties.add(name);
+ if (propsParams) for (let i = 0, l = propsParams.length; i < l; i++) this.properties.add(propsParams[i]);
+ /** @type {Set<String>} */
+ this.recordedProperties = new Set([
+ 'display',
+ 'visibility',
+ 'translate',
+ 'position',
+ 'left',
+ 'top',
+ 'marginLeft',
+ 'marginTop',
+ 'width',
+ 'height',
+ 'maxWidth',
+ 'maxHeight',
+ 'minWidth',
+ 'minHeight',
+ ]);
+ this.properties.forEach(prop => this.recordedProperties.add(prop));
+ /** @type {WeakSet<DOMTarget>} */
+ this.pendingRemoved = new WeakSet();
+ /** @type {Map<DOMTarget, String|null>} */
+ this.transitionMuteStore = new Map();
+ /** @type {LayoutSnapshot} */
+ this.oldState = new LayoutSnapshot(this);
+ /** @type {LayoutSnapshot} */
+ this.newState = new LayoutSnapshot(this);
+ /** @type {Timeline|null} */
+ this.timeline = null;
+ /** @type {WAAPIAnimation|null} */
+ this.transformAnimation = null;
+ /** @type {Array<DOMTarget>} */
+ this.frozen = [];
+ /** @type {Array<DOMTarget>} */
+ this.removed = [];
+ /** @type {Array<DOMTarget>} */
+ this.added = [];
+ // Record the current state as the old state to init the data attributes
+ this.oldState.record();
+ // And all layout transition muted during the record
+ restoreLayoutTransition(this.transitionMuteStore);
+ }
+
+ /**
+ * @return {this}
+ */
+ revert() {
+ if (this.timeline) {
+ this.timeline.complete();
+ this.timeline = null;
+ }
+ if (this.transformAnimation) {
+ this.transformAnimation.complete();
+ this.transformAnimation = null;
+ }
+ this.root.classList.remove('is-animated');
+ this.frozen.length = this.removed.length = this.added.length = 0;
+ this.oldState.revert();
+ this.newState.revert();
+ requestAnimationFrame(() => restoreLayoutTransition(this.transitionMuteStore));
+ return this;
+ }
+
+ /**
+ * @return {this}
+ */
+ record() {
+ // Commit transforms before measuring
+ if (this.transformAnimation) {
+ this.transformAnimation.cancel();
+ this.transformAnimation = null;
+ }
+ // Record the old state
+ this.oldState.record();
+ // Cancel any running timeline
+ if (this.timeline) {
+ this.timeline.cancel();
+ this.timeline = null;
+ }
+ // Restore previously captured inline styles
+ this.newState.forEachRootNode(restoreNodeInlineStyles);
+ return this;
+ }
+
+ /**
+ * @param {LayoutAnimationParams} [params]
+ * @return {Timeline}
+ */
+ animate(params = {}) {
+ const delay = setValue(params.delay, this.delay);
+ const duration = setValue(params.duration, this.duration);
+ const onComplete = setValue(params.onComplete, this.onComplete);
+ const frozenParams = params.frozen ? mergeObjects(params.frozen, this.frozenParams) : this.frozenParams;
+ const addedParams = params.added ? mergeObjects(params.added, this.addedParams) : this.addedParams;
+ const removedParams = params.removed ? mergeObjects(params.removed, this.removedParams) : this.removedParams;
+ const oldState = this.oldState;
+ const newState = this.newState;
+ const added = this.added;
+ const removed = this.removed;
+ const frozen = this.frozen;
+ const pendingRemoved = this.pendingRemoved;
+
+ added.length = removed.length = frozen.length = 0;
+
+ // Mute old state CSS transitions to prevent wrong properties calculation
+ oldState.forEachRootNode(muteNodeTransition);
+ // Capture the new state before animation
+ newState.record();
+ newState.forEachRootNode(recordNodeInlineStyles);
+
+ const targets = [];
+ const animated = [];
+ const transformed = [];
+ const animatedFrozen = [];
+ const root = newState.rootNode.$el;
+
+ newState.forEachRootNode(node => {
+ const $el = node.$el;
+ const id = node.id;
+ const parent = node.parentNode;
+ const parentAdded = parent ? parent.branchAdded : false;
+ const parentRemoved = parent ? parent.branchRemoved : false;
+ const parentNotRendered = parent ? parent.branchNotRendered : false;
+
+ // Delay and duration must be calculated in the animate() call to support delay override
+ node.delay = +(isFnc(delay) ? delay($el, node.index, node.total) : delay);
+ node.duration = +(isFnc(duration) ? duration($el, node.index, node.total) : duration);
+
+ let oldStateNode = oldState.nodes.get(id);
+
+ const hasNoOldState = !oldStateNode;
+
+ if (hasNoOldState) {
+ oldStateNode = cloneNodeProperties(node, /** @type {LayoutNode} */({}), oldState);
+ oldState.nodes.set(id, oldStateNode);
+ oldStateNode.measuredIsRemoved = true;
+ } else if (oldStateNode.measuredIsRemoved && !node.measuredIsRemoved) {
+ cloneNodeProperties(node, oldStateNode, oldState);
+ oldStateNode.measuredIsRemoved = true;
+ }
+
+ const oldParentNode = oldStateNode.parentNode;
+ const oldParentId = oldParentNode ? oldParentNode.id : null;
+ const newParentId = parent ? parent.id : null;
+ const parentChanged = oldParentId !== newParentId;
+ const elementChanged = oldStateNode.$el !== node.$el;
+ const wasRemovedBefore = oldStateNode.measuredIsRemoved;
+ const isRemovedNow = node.measuredIsRemoved;
+
+ // Recalculate postion relative to their parent for elements that have been moved
+ if (!oldStateNode.measuredIsRemoved && !isRemovedNow && !hasNoOldState && (parentChanged || elementChanged)) {
+ let offsetX = 0;
+ let offsetY = 0;
+ let current = node.parentNode;
+ while (current) {
+ offsetX += current.properties.x || 0;
+ offsetY += current.properties.y || 0;
+ if (current.parentNode === newState.rootNode) break;
+ current = current.parentNode;
+ }
+ let oldOffsetX = 0;
+ let oldOffsetY = 0;
+ let oldCurrent = oldStateNode.parentNode;
+ while (oldCurrent) {
+ oldOffsetX += oldCurrent.properties.x || 0;
+ oldOffsetY += oldCurrent.properties.y || 0;
+ if (oldCurrent.parentNode === oldState.rootNode) break;
+ oldCurrent = oldCurrent.parentNode;
+ }
+ oldStateNode.properties.x += oldOffsetX - offsetX;
+ oldStateNode.properties.y += oldOffsetY - offsetY;
+ }
+
+ if (node.hasVisibilitySwap) {
+ if (node.hasVisibilityHidden) {
+ node.$el.style.visibility = 'visible';
+ node.$measure.style.visibility = 'hidden';
+ }
+ if (node.hasDisplayNone) {
+ node.$el.style.display = oldStateNode.measuredDisplay || node.measuredDisplay || '';
+ // Setting visibility 'hidden' instead of display none to avoid calculation issues
+ node.$measure.style.visibility = 'hidden';
+ // @TODO: check why setting display here can cause calculation issues
+ // node.$measure.style.display = 'none';
+ }
+ }
+
+ const wasPendingRemoval = pendingRemoved.has($el);
+ const wasVisibleBefore = oldStateNode.measuredIsVisible;
+ const isVisibleNow = node.measuredIsVisible;
+ const becomeVisible = !wasVisibleBefore && isVisibleNow && !parentNotRendered;
+ const topLevelAdded = !isRemovedNow && (wasRemovedBefore || wasPendingRemoval) && !parentAdded;
+ const newlyRemoved = isRemovedNow && !wasRemovedBefore && !parentRemoved;
+ const topLevelRemoved = newlyRemoved || isRemovedNow && wasPendingRemoval && !parentRemoved;
+
+ if (node.measuredIsRemoved && wasVisibleBefore) {
+ node.$el.style.display = oldStateNode.measuredDisplay;
+ node.$el.style.visibility = 'visible';
+ cloneNodeProperties(oldStateNode, node, newState);
+ }
+
+ if (newlyRemoved) {
+ removed.push($el);
+ pendingRemoved.add($el);
+ } else if (!isRemovedNow && wasPendingRemoval) {
+ pendingRemoved.delete($el);
+ }
+
+ // Node is added
+ if ((topLevelAdded && !parentNotRendered) || becomeVisible) {
+ updateNodeProperties(oldStateNode, addedParams);
+ added.push($el);
+ // Node is removed
+ } else if (topLevelRemoved && !parentNotRendered) {
+ updateNodeProperties(node, removedParams);
+ }
+
+ // Compute function based propety values before cheking for changes
+ for (let name in node.properties) {
+ node.properties[name] = newState.getValue(node.$el, name);
+ // NOTE: I'm using node.$el to get the value of old state, make sure this is valid instead of oldStateNode.$el
+ oldStateNode.properties[name] = oldState.getValue(node.$el, name);
+ }
+
+ const hiddenStateChanged = (topLevelAdded || newlyRemoved) && wasRemovedBefore !== isRemovedNow;
+ let propertyChanged = false;
+
+
+ if (node.isTarget && (!node.measuredIsRemoved && wasVisibleBefore || node.measuredIsRemoved && isVisibleNow)) {
+ if (!node.isInlined && (node.properties.transform !== 'none' || oldStateNode.properties.transform !== 'none')) {
+ node.hasTransform = true;
+ propertyChanged = true;
+ transformed.push($el);
+ }
+ for (let name in node.properties) {
+ if (name !== 'transform' && (node.properties[name] !== oldStateNode.properties[name] || hiddenStateChanged)) {
+ propertyChanged = true;
+ animated.push($el);
+ break;
+ }
+ }
+ }
+
+ const nodeHasChanged = (propertyChanged || topLevelAdded || topLevelRemoved || becomeVisible);
+ const nodeIsAnimated = node.isTarget && nodeHasChanged;
+
+ node.isAnimated = nodeIsAnimated;
+ node.branchAdded = parentAdded || topLevelAdded;
+ node.branchRemoved = parentRemoved || topLevelRemoved;
+ node.branchNotRendered = parentNotRendered || node.measuredIsRemoved;
+
+ const sizeTolerance = 1;
+ const widthChanged = Math.abs(node.properties.width - oldStateNode.properties.width) > sizeTolerance;
+ const heightChanged = Math.abs(node.properties.height - oldStateNode.properties.height) > sizeTolerance;
+
+ node.sizeChanged = (widthChanged || heightChanged);
+
+ targets.push($el);
+
+ if (!node.isTarget) {
+ frozen.push($el);
+ if ((nodeHasChanged || node.sizeChanged) && parent && parent.isTarget && parent.isAnimated && parent.sizeChanged) {
+ animatedFrozen.push($el);
+ }
+ }
+ });
+
+ const defaults = {
+ ease: setValue(params.ease, this.ease),
+ duration: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).duration,
+ delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+
+ this.timeline = createTimeline({
+ onComplete: () => {
+ // Make sure to call .cancel() after restoreNodeInlineStyles(node); otehrwise the commited styles get reverted
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(node => {
+ restoreNodeVisualState(node);
+ restoreNodeInlineStyles(node);
+ });
+ for (let i = 0, l = transformed.length; i < l; i++) {
+ const $el = transformed[i];
+ $el.style.transform = newState.getValue($el, 'transform');
+ }
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ // Avoid CSS transitions at the end of the animation by restoring them on the next frame
+ requestAnimationFrame(() => {
+ if (this.root.classList.contains('is-animated')) return;
+ restoreLayoutTransition(this.transitionMuteStore);
+ });
+ },
+ onPause: () => {
+ if (this.transformAnimation) this.transformAnimation.cancel();
+ newState.forEachRootNode(restoreNodeVisualState);
+ this.root.classList.remove('is-animated');
+ if (onComplete) onComplete(this);
+ },
+ composition: false,
+ defaults,
+ });
+
+ if (targets.length) {
+
+ this.root.classList.add('is-animated');
+
+ for (let i = 0, l = targets.length; i < l; i++) {
+ const $el = targets[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+
+ // Make sure to mute all CSS transition before applying the oldState styles back
+ muteNodeTransition(newNode);
+
+ // Don't animate dimensions and positions of inlined elements
+ if (!newNode.isInlined) {
+ // Display grid can mess with the absolute positioning, so set it to block during transition
+ // if (oldNode.measuredDisplay === 'grid' || newNode.measuredDisplay === 'grid') $el.style.display = 'block';
+ $el.style.display = 'block';
+ // All children must be in position absolue
+ if ($el !== root || this.absoluteCoords) {
+ $el.style.position = this.absoluteCoords ? 'fixed' : 'absolute';
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ $el.style.marginLeft = '0px';
+ $el.style.marginTop = '0px';
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ if ($el === root && newNode.measuredPosition === 'static') {
+ $el.style.position = 'relative';
+ // Cancel left / trop in case the static element had muted values now activated by potision relative
+ $el.style.left = '0px';
+ $el.style.top = '0px';
+ }
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ }
+ }
+
+ // Restore the scroll position if the oldState differs from the current state
+ if (oldState.scrollX !== window.scrollX || oldState.scrollY !== window.scrollY) {
+ // Restoring in the next frame avoids race conditions if for example a waapi animation commit styles that affect the root height
+ requestAnimationFrame(() => {
+ window.scrollTo(oldState.scrollX, oldState.scrollY);
+ });
+ }
+
+ for (let i = 0, l = animated.length; i < l; i++) {
+ const $el = animated[i];
+ const id = $el.dataset.layoutId;
+ const oldNode = oldState.nodes.get(id);
+ const newNode = newState.nodes.get(id);
+ const oldNodeState = oldNode.properties;
+ const newNodeState = newNode.properties;
+ let hasChanged = false;
+ const animatedProps = {
+ composition: 'none',
+ // delay: (/** @type {HTMLElement} */$el) => newState.nodes.get($el.dataset.layoutId).delay,
+ };
+ if (!newNode.isInlined) {
+ if (oldNodeState.width !== newNodeState.width) {
+ animatedProps.width = [oldNodeState.width, newNodeState.width];
+ hasChanged = true;
+ }
+ if (oldNodeState.height !== newNodeState.height) {
+ animatedProps.height = [oldNodeState.height, newNodeState.height];
+ hasChanged = true;
+ }
+ // If the node has transforms we handle the translate animation in wappi otherwise translate and other transforms can be out of sync
+ // Always animate translate
+ if (!newNode.hasTransform) {
+ animatedProps.translate = [`${oldNodeState.x}px ${oldNodeState.y}px`, `${newNodeState.x}px ${newNodeState.y}px`];
+ hasChanged = true;
+ }
+ }
+ this.properties.forEach(prop => {
+ const oldVal = oldNodeState[prop];
+ const newVal = newNodeState[prop];
+ if (prop !== 'transform' && oldVal !== newVal) {
+ animatedProps[prop] = [oldVal, newVal];
+ hasChanged = true;
+ }
+ });
+ if (hasChanged) {
+ this.timeline.add($el, animatedProps, 0);
+ }
+ }
+
+ }
+
+ if (frozen.length) {
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const oldNode = oldState.nodes.get($el.dataset.layoutId);
+ if (!oldNode.isInlined) {
+ const oldNodeState = oldState.get($el);
+ $el.style.width = `${oldNodeState.width}px`;
+ $el.style.height = `${oldNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${oldNodeState.x}px ${oldNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${oldState.getValue($el, prop)}`;
+ }
+ });
+ }
+
+ for (let i = 0, l = frozen.length; i < l; i++) {
+ const $el = frozen[i];
+ const newNode = newState.nodes.get($el.dataset.layoutId);
+ const newNodeState = newState.get($el);
+ this.timeline.call(() => {
+ if (!newNode.isInlined) {
+ $el.style.width = `${newNodeState.width}px`;
+ $el.style.height = `${newNodeState.height}px`;
+ // Overrides user defined min and max to prevents width and height clamping
+ $el.style.minWidth = `auto`;
+ $el.style.minHeight = `auto`;
+ $el.style.maxWidth = `none`;
+ $el.style.maxHeight = `none`;
+ $el.style.translate = `${newNodeState.x}px ${newNodeState.y}px`;
+ }
+ this.properties.forEach(prop => {
+ if (prop !== 'transform') {
+ $el.style[prop] = `${newState.getValue($el, prop)}`;
+ }
+ });
+ }, newNode.delay + newNode.duration / 2);
+ }
+
+ if (animatedFrozen.length) {
+ const animatedFrozenParams = /** @type {AnimationParams} */({});
+ if (frozenParams) {
+ for (let prop in frozenParams) {
+ animatedFrozenParams[prop] = [
+ { from: (/** @type {HTMLElement} */$el) => oldState.getValue($el, prop), ease: 'in(1.75)', to: frozenParams[prop] },
+ { from: frozenParams[prop], to: (/** @type {HTMLElement} */$el) => newState.getValue($el, prop), ease: 'out(1.75)' }
+ ];
+ }
+ }
+ this.timeline.add(animatedFrozen, animatedFrozenParams, 0);
+ }
+
+ }
+
+ const transformedLength = transformed.length;
+
+ if (transformedLength) {
+ // We only need to set the transform property here since translate is alread defined the targets loop
+ for (let i = 0; i < transformedLength; i++) {
+ const $el = transformed[i];
+ $el.style.translate = `${oldState.get($el).x}px ${oldState.get($el).y}px`,
+ $el.style.transform = oldState.getValue($el, 'transform');
+ }
+ this.transformAnimation = waapi.animate(transformed, {
+ translate: (/** @type {HTMLElement} */$el) => `${newState.get($el).x}px ${newState.get($el).y}px`,
+ transform: (/** @type {HTMLElement} */$el) => newState.getValue($el, 'transform'),
+ autoplay: false,
+ persist: true,
+ ...defaults,
+ });
+ this.timeline.sync(this.transformAnimation, 0);
+ }
+
+ return this.timeline.init();
+ }
+
+ /**
+ * @param {(layout: this) => void} callback
+ * @param {LayoutAnimationParams} [params]
+ * @return {this}
+ */
+ update(callback, params = {}) {
+ this.record();
+ callback(this);
+ this.animate(params);
+ return this;
+ }
+}
+
+/**
+ * @param {DOMTargetSelector} root
+ * @param {AutoLayoutParams} [params]
+ * @return {AutoLayout}
+ */
+const createLayout = (root, params) => new AutoLayout(root, params);
+
+export { AutoLayout, createLayout };
diff --git a/dist/modules/scope/index.cjs b/dist/modules/scope/index.cjs
index 2c27b00e..225fe1e9 100644
--- a/dist/modules/scope/index.cjs
+++ b/dist/modules/scope/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/scope/index.js b/dist/modules/scope/index.js
index 7fc6a9c3..5f3e6db1 100644
--- a/dist/modules/scope/index.js
+++ b/dist/modules/scope/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/scope/scope.cjs b/dist/modules/scope/scope.cjs
index b028752a..c5c2850a 100644
--- a/dist/modules/scope/scope.cjs
+++ b/dist/modules/scope/scope.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/scope/scope.js b/dist/modules/scope/scope.js
index d046d078..40f7c402 100644
--- a/dist/modules/scope/scope.js
+++ b/dist/modules/scope/scope.js
@@ -1,6 +1,6 @@
/**
* Anime.js - scope - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/drawable.cjs b/dist/modules/svg/drawable.cjs
index 4f3fb046..20be55ac 100644
--- a/dist/modules/svg/drawable.cjs
+++ b/dist/modules/svg/drawable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/drawable.js b/dist/modules/svg/drawable.js
index 0482e366..ae07cc7e 100644
--- a/dist/modules/svg/drawable.js
+++ b/dist/modules/svg/drawable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/helpers.cjs b/dist/modules/svg/helpers.cjs
index 0b0dd354..effef37f 100644
--- a/dist/modules/svg/helpers.cjs
+++ b/dist/modules/svg/helpers.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/helpers.js b/dist/modules/svg/helpers.js
index 196baa8f..2366d942 100644
--- a/dist/modules/svg/helpers.js
+++ b/dist/modules/svg/helpers.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/index.cjs b/dist/modules/svg/index.cjs
index cc969614..3a9fcc27 100644
--- a/dist/modules/svg/index.cjs
+++ b/dist/modules/svg/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/index.js b/dist/modules/svg/index.js
index 42ad0824..101823ed 100644
--- a/dist/modules/svg/index.js
+++ b/dist/modules/svg/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/morphto.cjs b/dist/modules/svg/morphto.cjs
index 6eb02830..b4b68122 100644
--- a/dist/modules/svg/morphto.cjs
+++ b/dist/modules/svg/morphto.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/morphto.js b/dist/modules/svg/morphto.js
index 8468193a..8ec9e9b6 100644
--- a/dist/modules/svg/morphto.js
+++ b/dist/modules/svg/morphto.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/motionpath.cjs b/dist/modules/svg/motionpath.cjs
index 60a97836..11c900be 100644
--- a/dist/modules/svg/motionpath.cjs
+++ b/dist/modules/svg/motionpath.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/svg/motionpath.js b/dist/modules/svg/motionpath.js
index 27902cca..2808cc3d 100644
--- a/dist/modules/svg/motionpath.js
+++ b/dist/modules/svg/motionpath.js
@@ -1,6 +1,6 @@
/**
* Anime.js - svg - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/text/index.cjs b/dist/modules/text/index.cjs
index 2c2d7519..94a2f47b 100644
--- a/dist/modules/text/index.cjs
+++ b/dist/modules/text/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - text - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/text/index.js b/dist/modules/text/index.js
index 70472cea..973683a1 100644
--- a/dist/modules/text/index.js
+++ b/dist/modules/text/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - text - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/text/split.cjs b/dist/modules/text/split.cjs
index 3baa88a9..c94161ca 100644
--- a/dist/modules/text/split.cjs
+++ b/dist/modules/text/split.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - text - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -89,12 +89,23 @@ const filterEmptyElements = $el => {
/**
* @param {HTMLElement} $el
* @param {Number} lineIndex
- * @param {Set<HTMLElement>} bin
- * @returns {Set<HTMLElement>}
+ * @param {Set<HTMLElement|Node>} bin
+ * @returns {Set<HTMLElement|Node>}
*/
const filterLineElements = ($el, lineIndex, bin) => {
const dataLineAttr = $el.getAttribute(dataLine);
- if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') bin.add($el);
+ if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') {
+ bin.add($el);
+ // Also remove adjacent whitespace-only text nodes
+ const prev = $el.previousSibling;
+ const next = $el.nextSibling;
+ if (prev && prev.nodeType === 3 && whiteSpaceRgx.test(prev.textContent)) {
+ bin.add(prev);
+ }
+ if (next && next.nodeType === 3 && whiteSpaceRgx.test(next.textContent)) {
+ bin.add(next);
+ }
+ }
let i = $el.childElementCount;
while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
return bin;
@@ -309,7 +320,7 @@ class TextSplitter {
// Only concatenate if both current and previous are non-word-like and don't contain spaces
const lastWordIndex = tempWords.length - 1;
const lastWord = tempWords[lastWordIndex];
- if (!lastWord.includes(' ') && !segment.includes(' ')) {
+ if (!whiteSpaceGroupRgx.test(lastWord) && !whiteSpaceGroupRgx.test(segment)) {
tempWords[lastWordIndex] += segment;
} else {
tempWords.push(segment);
@@ -402,7 +413,7 @@ class TextSplitter {
for (let i = 0, l = elementsArray.length; i < l; i++) {
const $el = elementsArray[i];
const { top, height } = $el.getBoundingClientRect();
- if (y && top - y > height * .5) linesCount++;
+ if (!helpers.isUnd(y) && top - y > height * .5) linesCount++;
$el.setAttribute(dataLine, `${linesCount}`);
const nested = $el.querySelectorAll(`[${dataLine}]`);
let c = nested.length;
@@ -416,9 +427,11 @@ class TextSplitter {
for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
filterLineElements($clone, lineIndex, new Set()).forEach($el => {
- const $parent = $el.parentElement;
- if ($parent) parents.add($parent);
- $el.remove();
+ const $parent = $el.parentNode;
+ if ($parent) {
+ if ($el.nodeType === 1) parents.add(/** @type {HTMLElement} */($parent));
+ $parent.removeChild($el);
+ }
});
clones.push($clone);
}
@@ -431,6 +444,7 @@ class TextSplitter {
if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
}
+
// Remove the word wrappers and clear the words array if lines split only
if (this.linesOnly) {
const words = this.words;
diff --git a/dist/modules/text/split.js b/dist/modules/text/split.js
index 2924ab52..18846ab2 100644
--- a/dist/modules/text/split.js
+++ b/dist/modules/text/split.js
@@ -1,6 +1,6 @@
/**
* Anime.js - text - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -87,12 +87,23 @@ const filterEmptyElements = $el => {
/**
* @param {HTMLElement} $el
* @param {Number} lineIndex
- * @param {Set<HTMLElement>} bin
- * @returns {Set<HTMLElement>}
+ * @param {Set<HTMLElement|Node>} bin
+ * @returns {Set<HTMLElement|Node>}
*/
const filterLineElements = ($el, lineIndex, bin) => {
const dataLineAttr = $el.getAttribute(dataLine);
- if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') bin.add($el);
+ if (dataLineAttr !== null && +dataLineAttr !== lineIndex || $el.tagName === 'BR') {
+ bin.add($el);
+ // Also remove adjacent whitespace-only text nodes
+ const prev = $el.previousSibling;
+ const next = $el.nextSibling;
+ if (prev && prev.nodeType === 3 && whiteSpaceRgx.test(prev.textContent)) {
+ bin.add(prev);
+ }
+ if (next && next.nodeType === 3 && whiteSpaceRgx.test(next.textContent)) {
+ bin.add(next);
+ }
+ }
let i = $el.childElementCount;
while (i--) filterLineElements(/** @type {HTMLElement} */($el.children[i]), lineIndex, bin);
return bin;
@@ -307,7 +318,7 @@ class TextSplitter {
// Only concatenate if both current and previous are non-word-like and don't contain spaces
const lastWordIndex = tempWords.length - 1;
const lastWord = tempWords[lastWordIndex];
- if (!lastWord.includes(' ') && !segment.includes(' ')) {
+ if (!whiteSpaceGroupRgx.test(lastWord) && !whiteSpaceGroupRgx.test(segment)) {
tempWords[lastWordIndex] += segment;
} else {
tempWords.push(segment);
@@ -400,7 +411,7 @@ class TextSplitter {
for (let i = 0, l = elementsArray.length; i < l; i++) {
const $el = elementsArray[i];
const { top, height } = $el.getBoundingClientRect();
- if (y && top - y > height * .5) linesCount++;
+ if (!isUnd(y) && top - y > height * .5) linesCount++;
$el.setAttribute(dataLine, `${linesCount}`);
const nested = $el.querySelectorAll(`[${dataLine}]`);
let c = nested.length;
@@ -414,9 +425,11 @@ class TextSplitter {
for (let lineIndex = 0; lineIndex < linesCount + 1; lineIndex++) {
const $clone = /** @type {HTMLElement} */($el.cloneNode(true));
filterLineElements($clone, lineIndex, new Set()).forEach($el => {
- const $parent = $el.parentElement;
- if ($parent) parents.add($parent);
- $el.remove();
+ const $parent = $el.parentNode;
+ if ($parent) {
+ if ($el.nodeType === 1) parents.add(/** @type {HTMLElement} */($parent));
+ $parent.removeChild($el);
+ }
});
clones.push($clone);
}
@@ -429,6 +442,7 @@ class TextSplitter {
if (wordTemplate) this.words = getAllTopLevelElements($el, wordType);
if (charTemplate) this.chars = getAllTopLevelElements($el, charType);
}
+
// Remove the word wrappers and clear the words array if lines split only
if (this.linesOnly) {
const words = this.words;
diff --git a/dist/modules/timeline/index.cjs b/dist/modules/timeline/index.cjs
index 14ef01fa..fae1f637 100644
--- a/dist/modules/timeline/index.cjs
+++ b/dist/modules/timeline/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timeline/index.js b/dist/modules/timeline/index.js
index 98c29d6a..71c4a289 100644
--- a/dist/modules/timeline/index.js
+++ b/dist/modules/timeline/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timeline/position.cjs b/dist/modules/timeline/position.cjs
index d1bc8bef..45b19f9c 100644
--- a/dist/modules/timeline/position.cjs
+++ b/dist/modules/timeline/position.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timeline/position.js b/dist/modules/timeline/position.js
index 5192809a..7a69df28 100644
--- a/dist/modules/timeline/position.js
+++ b/dist/modules/timeline/position.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timeline/timeline.cjs b/dist/modules/timeline/timeline.cjs
index 60a04d05..3a330cd0 100644
--- a/dist/modules/timeline/timeline.cjs
+++ b/dist/modules/timeline/timeline.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timeline - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -77,11 +77,11 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
const isSetter = helpers.isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= consts.minValue;
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
const adjustedPosition = isSetter ? timePosition - consts.minValue : timePosition;
- render.tick(tl, adjustedPosition, 1, 1, consts.tickModes.AUTO);
+ if (tl.composition) render.tick(tl, adjustedPosition, 1, 1, consts.tickModes.AUTO);
const tlChild = targets ?
new animation.JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
new timer.Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
- tlChild.init(true);
+ if (tl.composition) tlChild.init(true);
// TODO: Might be better to insert at a position relative to startTime?
helpers.addChild(tl, tlChild);
helpers.forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -93,6 +93,8 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
return tl;
}
+let TLId = 0;
+
class Timeline extends timer.Timer {
/**
@@ -100,6 +102,9 @@ class Timeline extends timer.Timer {
*/
constructor(parameters = {}) {
super(/** @type {TimerParams&TimelineParams} */(parameters), null, 0);
+ ++TLId;
+ /** @type {String|Number} */
+ this.id = !helpers.isUnd(parameters.id) ? parameters.id : TLId;
/** @type {Number} */
this.duration = 0; // TL duration starts at 0 and grows when adding children
/** @type {Record<String, Number>} */
@@ -108,6 +113,8 @@ class Timeline extends timer.Timer {
const globalDefaults = globals.globals.defaults;
/** @type {DefaultsParams} */
this.defaults = defaultsParams ? helpers.mergeObjects(defaultsParams, globalDefaults) : globalDefaults;
+ /** @type {Boolean} */
+ this.composition = values.setValue(parameters.composition, true);
/** @type {Callback<this>} */
this.onRender = parameters.onRender || globalDefaults.onRender;
const tlPlaybackEase = values.setValue(parameters.playbackEase, globalDefaults.playbackEase);
@@ -185,7 +192,8 @@ class Timeline extends timer.Timer {
position.parseTimelinePosition(this,a2),
);
}
- return this.init(true);
+ if (this.composition) this.init(true);
+ return this;
}
}
@@ -212,7 +220,7 @@ class Timeline extends timer.Timer {
if (helpers.isUnd(synced) || synced && helpers.isUnd(synced.pause)) return this;
synced.pause();
const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
- return this.add(synced, { currentTime: [0, duration], duration, ease: 'linear' }, position);
+ return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
}
/**
@@ -235,7 +243,7 @@ class Timeline extends timer.Timer {
*/
call(callback, position) {
if (helpers.isUnd(callback) || callback && !helpers.isFnc(callback)) return this;
- return this.add({ duration: 0, onComplete: () => callback(this) }, position);
+ return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
/**
diff --git a/dist/modules/timeline/timeline.d.ts b/dist/modules/timeline/timeline.d.ts
index 7a3f0468..52a5a8c5 100644
--- a/dist/modules/timeline/timeline.d.ts
+++ b/dist/modules/timeline/timeline.d.ts
@@ -7,6 +7,8 @@ export class Timeline extends Timer {
labels: Record<string, number>;
/** @type {DefaultsParams} */
defaults: DefaultsParams;
+ /** @type {Boolean} */
+ composition: boolean;
/** @type {Callback<this>} */
onRender: Callback<this>;
_ease: import("../types/index.js").EasingFunction;
diff --git a/dist/modules/timeline/timeline.js b/dist/modules/timeline/timeline.js
index d20c1ac7..4dcdb72b 100644
--- a/dist/modules/timeline/timeline.js
+++ b/dist/modules/timeline/timeline.js
@@ -1,13 +1,13 @@
/**
* Anime.js - timeline - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
import { globals } from '../core/globals.js';
import { minValue, compositionTypes, tickModes } from '../core/consts.js';
-import { mergeObjects, isObj, isFnc, isUnd, isStr, normalizeTime, forEachChildren, isNum, addChild, clampInfinity } from '../core/helpers.js';
+import { isUnd, mergeObjects, isObj, isFnc, isStr, normalizeTime, forEachChildren, isNum, addChild, clampInfinity } from '../core/helpers.js';
import { setValue } from '../core/values.js';
import { parseTargets } from '../core/targets.js';
import { tick } from '../core/render.js';
@@ -75,11 +75,11 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
const isSetter = isNum(childParams.duration) && /** @type {Number} */(childParams.duration) <= minValue;
// Offset the tl position with -minValue for 0 duration animations or .set() calls in order to align their end value with the defined position
const adjustedPosition = isSetter ? timePosition - minValue : timePosition;
- tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
+ if (tl.composition) tick(tl, adjustedPosition, 1, 1, tickModes.AUTO);
const tlChild = targets ?
new JSAnimation(targets,/** @type {AnimationParams} */(childParams), tl, adjustedPosition, false, index, length) :
new Timer(/** @type {TimerParams} */(childParams), tl, adjustedPosition);
- tlChild.init(true);
+ if (tl.composition) tlChild.init(true);
// TODO: Might be better to insert at a position relative to startTime?
addChild(tl, tlChild);
forEachChildren(tl, (/** @type {Renderable} */child) => {
@@ -91,6 +91,8 @@ function addTlChild(childParams, tl, timePosition, targets, index, length) {
return tl;
}
+let TLId = 0;
+
class Timeline extends Timer {
/**
@@ -98,6 +100,9 @@ class Timeline extends Timer {
*/
constructor(parameters = {}) {
super(/** @type {TimerParams&TimelineParams} */(parameters), null, 0);
+ ++TLId;
+ /** @type {String|Number} */
+ this.id = !isUnd(parameters.id) ? parameters.id : TLId;
/** @type {Number} */
this.duration = 0; // TL duration starts at 0 and grows when adding children
/** @type {Record<String, Number>} */
@@ -106,6 +111,8 @@ class Timeline extends Timer {
const globalDefaults = globals.defaults;
/** @type {DefaultsParams} */
this.defaults = defaultsParams ? mergeObjects(defaultsParams, globalDefaults) : globalDefaults;
+ /** @type {Boolean} */
+ this.composition = setValue(parameters.composition, true);
/** @type {Callback<this>} */
this.onRender = parameters.onRender || globalDefaults.onRender;
const tlPlaybackEase = setValue(parameters.playbackEase, globalDefaults.playbackEase);
@@ -183,7 +190,8 @@ class Timeline extends Timer {
parseTimelinePosition(this,a2),
);
}
- return this.init(true);
+ if (this.composition) this.init(true);
+ return this;
}
}
@@ -210,7 +218,7 @@ class Timeline extends Timer {
if (isUnd(synced) || synced && isUnd(synced.pause)) return this;
synced.pause();
const duration = +(/** @type {globalThis.Animation} */(synced).effect ? /** @type {globalThis.Animation} */(synced).effect.getTiming().duration : /** @type {Tickable} */(synced).duration);
- return this.add(synced, { currentTime: [0, duration], duration, ease: 'linear' }, position);
+ return this.add(synced, { currentTime: [0, duration], duration, delay: 0, ease: 'linear', playbackEase: 'linear' }, position);
}
/**
@@ -233,7 +241,7 @@ class Timeline extends Timer {
*/
call(callback, position) {
if (isUnd(callback) || callback && !isFnc(callback)) return this;
- return this.add({ duration: 0, onComplete: () => callback(this) }, position);
+ return this.add({ duration: 0, delay: 0, onComplete: () => callback(this) }, position);
}
/**
diff --git a/dist/modules/timer/index.cjs b/dist/modules/timer/index.cjs
index 2c4954ec..bbd5a09f 100644
--- a/dist/modules/timer/index.cjs
+++ b/dist/modules/timer/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timer/index.js b/dist/modules/timer/index.js
index cb1bf490..d16983dc 100644
--- a/dist/modules/timer/index.js
+++ b/dist/modules/timer/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/timer/timer.cjs b/dist/modules/timer/timer.cjs
index 7a1c1845..4b18a763 100644
--- a/dist/modules/timer/timer.cjs
+++ b/dist/modules/timer/timer.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - timer - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -82,6 +82,8 @@ class Timer extends clock.Clock {
super(0);
+ ++timerId;
+
const {
id,
delay,
@@ -103,31 +105,42 @@ class Timer extends clock.Clock {
if (globals.scope.current) globals.scope.current.register(this);
- const timerInitTime = parent ? 0 : engine.engine._elapsedTime;
+ const timerInitTime = parent ? 0 : engine.engine._lastTickTime;
const timerDefaults = parent ? parent.defaults : globals.globals.defaults;
const timerDelay = /** @type {Number} */(helpers.isFnc(delay) || helpers.isUnd(delay) ? timerDefaults.delay : +delay);
const timerDuration = helpers.isFnc(duration) || helpers.isUnd(duration) ? Infinity : +duration;
const timerLoop = values.setValue(loop, timerDefaults.loop);
const timerLoopDelay = values.setValue(loopDelay, timerDefaults.loopDelay);
- const timerIterationCount = timerLoop === true ||
- timerLoop === Infinity ||
- /** @type {Number} */(timerLoop) < 0 ? Infinity :
- /** @type {Number} */(timerLoop) + 1;
+ let timerIterationCount = timerLoop === true ||
+ timerLoop === Infinity ||
+ /** @type {Number} */(timerLoop) < 0 ? Infinity :
+ /** @type {Number} */(timerLoop) + 1;
+
+ if (globals.devTools) {
+ const isInfinite = timerIterationCount === Infinity;
+ const registered = globals.devTools.register(this, parameters, isInfinite);
+ if (registered && isInfinite) {
+ const minIterations = alternate ? 2 : 1;
+ const iterations = parent ? globals.devTools.maxNestedInfiniteLoops : globals.devTools.maxInfiniteLoops;
+ timerIterationCount = Math.max(iterations, minIterations);
+ }
+ }
let offsetPosition = 0;
if (parent) {
offsetPosition = parentPosition;
} else {
- // Make sure to tick the engine once if not currently running to get up to date engine._elapsedTime
+ // Make sure to tick the engine once if not currently running to get up to date engine._lastTickTime
// to avoid big gaps with the following offsetPosition calculation
if (!engine.engine.reqId) engine.engine.requestTick(helpers.now());
// Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
- offsetPosition = (engine.engine._elapsedTime - engine.engine._startTime) * globals.globals.timeScale;
+ offsetPosition = (engine.engine._lastTickTime - engine.engine._startTime) * globals.globals.timeScale;
}
// Timer's parameters
- this.id = !helpers.isUnd(id) ? id : ++timerId;
+ /** @type {String|Number} */
+ this.id = !helpers.isUnd(id) ? id : timerId;
/** @type {Timeline} */
this.parent = parent;
// Total duration of the timer
@@ -187,7 +200,7 @@ class Timer extends clock.Clock {
// Clock's parameters
/** @type {Number} */
- this._elapsedTime = timerInitTime;
+ this._lastTickTime = timerInitTime;
/** @type {Number} */
this._startTime = timerInitTime;
/** @type {Number} */
@@ -218,7 +231,7 @@ class Timer extends clock.Clock {
}
get iterationCurrentTime() {
- return helpers.round(this._iterationTime, globals.globals.precision);
+ return helpers.clamp(helpers.round(this._iterationTime, globals.globals.precision), 0, this.iterationDuration);
}
set iterationCurrentTime(time) {
@@ -316,9 +329,9 @@ class Timer extends clock.Clock {
/** @return {this} */
resetTime() {
const timeScale = 1 / (this._speed * engine.engine._speed);
- // TODO: See if we can safely use engine._elapsedTime here
+ // TODO: See if we can safely use engine._lastTickTime here
// if (!engine.reqId) engine.requestTick(now())
- // this._startTime = engine._elapsedTime - (this._currentTime + this._delay) * timeScale;
+ // this._startTime = engine._lastTickTime - (this._currentTime + this._delay) * timeScale;
this._startTime = helpers.now() - (this._currentTime + this._delay) * timeScale;
return this;
}
diff --git a/dist/modules/timer/timer.d.ts b/dist/modules/timer/timer.d.ts
index f2a1bfc4..aabd636f 100644
--- a/dist/modules/timer/timer.d.ts
+++ b/dist/modules/timer/timer.d.ts
@@ -8,6 +8,7 @@ export class Timer extends Clock {
* @param {Number} [parentPosition]
*/
constructor(parameters?: TimerParams, parent?: Timeline, parentPosition?: number);
+ /** @type {String|Number} */
id: string | number;
/** @type {Timeline} */
parent: Timeline;
diff --git a/dist/modules/timer/timer.js b/dist/modules/timer/timer.js
index e987b0f1..bb185e87 100644
--- a/dist/modules/timer/timer.js
+++ b/dist/modules/timer/timer.js
@@ -1,13 +1,13 @@
/**
* Anime.js - timer - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
import { minValue, noop, maxValue, compositionTypes, tickModes } from '../core/consts.js';
import { isFnc, isUnd, now, clampInfinity, clamp, round, forEachChildren, addChild, normalizeTime, floor } from '../core/helpers.js';
-import { globals, scope } from '../core/globals.js';
+import { globals, devTools, scope } from '../core/globals.js';
import { setValue } from '../core/values.js';
import { tick } from '../core/render.js';
import { removeTweenSliblings, composeTween, getTweenSiblings } from '../animation/composition.js';
@@ -80,6 +80,8 @@ class Timer extends Clock {
super(0);
+ ++timerId;
+
const {
id,
delay,
@@ -101,31 +103,42 @@ class Timer extends Clock {
if (scope.current) scope.current.register(this);
- const timerInitTime = parent ? 0 : engine._elapsedTime;
+ const timerInitTime = parent ? 0 : engine._lastTickTime;
const timerDefaults = parent ? parent.defaults : globals.defaults;
const timerDelay = /** @type {Number} */(isFnc(delay) || isUnd(delay) ? timerDefaults.delay : +delay);
const timerDuration = isFnc(duration) || isUnd(duration) ? Infinity : +duration;
const timerLoop = setValue(loop, timerDefaults.loop);
const timerLoopDelay = setValue(loopDelay, timerDefaults.loopDelay);
- const timerIterationCount = timerLoop === true ||
- timerLoop === Infinity ||
- /** @type {Number} */(timerLoop) < 0 ? Infinity :
- /** @type {Number} */(timerLoop) + 1;
+ let timerIterationCount = timerLoop === true ||
+ timerLoop === Infinity ||
+ /** @type {Number} */(timerLoop) < 0 ? Infinity :
+ /** @type {Number} */(timerLoop) + 1;
+
+ if (devTools) {
+ const isInfinite = timerIterationCount === Infinity;
+ const registered = devTools.register(this, parameters, isInfinite);
+ if (registered && isInfinite) {
+ const minIterations = alternate ? 2 : 1;
+ const iterations = parent ? devTools.maxNestedInfiniteLoops : devTools.maxInfiniteLoops;
+ timerIterationCount = Math.max(iterations, minIterations);
+ }
+ }
let offsetPosition = 0;
if (parent) {
offsetPosition = parentPosition;
} else {
- // Make sure to tick the engine once if not currently running to get up to date engine._elapsedTime
+ // Make sure to tick the engine once if not currently running to get up to date engine._lastTickTime
// to avoid big gaps with the following offsetPosition calculation
if (!engine.reqId) engine.requestTick(now());
// Make sure to scale the offset position with globals.timeScale to properly handle seconds unit
- offsetPosition = (engine._elapsedTime - engine._startTime) * globals.timeScale;
+ offsetPosition = (engine._lastTickTime - engine._startTime) * globals.timeScale;
}
// Timer's parameters
- this.id = !isUnd(id) ? id : ++timerId;
+ /** @type {String|Number} */
+ this.id = !isUnd(id) ? id : timerId;
/** @type {Timeline} */
this.parent = parent;
// Total duration of the timer
@@ -185,7 +198,7 @@ class Timer extends Clock {
// Clock's parameters
/** @type {Number} */
- this._elapsedTime = timerInitTime;
+ this._lastTickTime = timerInitTime;
/** @type {Number} */
this._startTime = timerInitTime;
/** @type {Number} */
@@ -216,7 +229,7 @@ class Timer extends Clock {
}
get iterationCurrentTime() {
- return round(this._iterationTime, globals.precision);
+ return clamp(round(this._iterationTime, globals.precision), 0, this.iterationDuration);
}
set iterationCurrentTime(time) {
@@ -314,9 +327,9 @@ class Timer extends Clock {
/** @return {this} */
resetTime() {
const timeScale = 1 / (this._speed * engine._speed);
- // TODO: See if we can safely use engine._elapsedTime here
+ // TODO: See if we can safely use engine._lastTickTime here
// if (!engine.reqId) engine.requestTick(now())
- // this._startTime = engine._elapsedTime - (this._currentTime + this._delay) * timeScale;
+ // this._startTime = engine._lastTickTime - (this._currentTime + this._delay) * timeScale;
this._startTime = now() - (this._currentTime + this._delay) * timeScale;
return this;
}
diff --git a/dist/modules/types/index.d.ts b/dist/modules/types/index.d.ts
index 5ab38aa4..753dbf3f 100644
--- a/dist/modules/types/index.d.ts
+++ b/dist/modules/types/index.d.ts
@@ -26,7 +26,7 @@ export type DefaultsParams = {
export type Renderable = JSAnimation | Timeline;
export type Tickable = Timer | Renderable;
export type CallbackArgument = Timer & JSAnimation & Timeline;
-export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope;
+export type Revertible = Animatable | Tickable | WAAPIAnimation | Draggable | ScrollObserver | TextSplitter | Scope | AutoLayout;
export type StaggerFunction<T> = (target?: Target, index?: number, length?: number, tl?: Timeline) => T;
export type StaggerParams = {
start?: number | string;
@@ -249,6 +249,7 @@ export type TimelineAnimationPosition = TimelinePosition | StaggerFunction<numbe
export type TimelineOptions = {
defaults?: DefaultsParams;
playbackEase?: EasingParam;
+ composition?: boolean;
};
export type TimelineParams = TimerOptions & TimelineOptions & TickableCallbacks<Timeline> & RenderableCallbacks<Timeline>;
export type WAAPITweenValue = string | number | Array<string> | Array<number>;
@@ -403,6 +404,7 @@ import type { WAAPIAnimation } from '../waapi/waapi.js';
import type { Draggable } from '../draggable/draggable.js';
import type { TextSplitter } from '../text/split.js';
import type { Scope } from '../scope/scope.js';
+import type { AutoLayout } from '../layout/layout.js';
import type { Spring } from '../easings/spring/index.js';
import type { tweenTypes } from '../core/consts.js';
import type { valueTypes } from '../core/consts.js';
diff --git a/dist/modules/utils/chainable.cjs b/dist/modules/utils/chainable.cjs
index d7fd8357..ca5cf2f5 100644
--- a/dist/modules/utils/chainable.cjs
+++ b/dist/modules/utils/chainable.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/chainable.js b/dist/modules/utils/chainable.js
index af6a2ec2..63617f86 100644
--- a/dist/modules/utils/chainable.js
+++ b/dist/modules/utils/chainable.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/index.cjs b/dist/modules/utils/index.cjs
index c653cc09..d9e3b8e8 100644
--- a/dist/modules/utils/index.cjs
+++ b/dist/modules/utils/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/index.js b/dist/modules/utils/index.js
index 13c761fb..6bde69b8 100644
--- a/dist/modules/utils/index.js
+++ b/dist/modules/utils/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/number.cjs b/dist/modules/utils/number.cjs
index 8b8f1088..21be02b0 100644
--- a/dist/modules/utils/number.cjs
+++ b/dist/modules/utils/number.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/number.js b/dist/modules/utils/number.js
index 65529079..33b151f8 100644
--- a/dist/modules/utils/number.js
+++ b/dist/modules/utils/number.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/random.cjs b/dist/modules/utils/random.cjs
index 497b618b..9955a53a 100644
--- a/dist/modules/utils/random.cjs
+++ b/dist/modules/utils/random.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/random.js b/dist/modules/utils/random.js
index 2d84d9dd..4e5619d3 100644
--- a/dist/modules/utils/random.js
+++ b/dist/modules/utils/random.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/stagger.cjs b/dist/modules/utils/stagger.cjs
index 07ccffef..c8c6d18f 100644
--- a/dist/modules/utils/stagger.cjs
+++ b/dist/modules/utils/stagger.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/stagger.js b/dist/modules/utils/stagger.js
index 094e8c68..21b314f6 100644
--- a/dist/modules/utils/stagger.js
+++ b/dist/modules/utils/stagger.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/target.cjs b/dist/modules/utils/target.cjs
index cc95aa57..567d0822 100644
--- a/dist/modules/utils/target.cjs
+++ b/dist/modules/utils/target.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/target.js b/dist/modules/utils/target.js
index ecce1789..0be9ff0d 100644
--- a/dist/modules/utils/target.js
+++ b/dist/modules/utils/target.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/time.cjs b/dist/modules/utils/time.cjs
index 9336c47c..149edeb6 100644
--- a/dist/modules/utils/time.cjs
+++ b/dist/modules/utils/time.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/utils/time.js b/dist/modules/utils/time.js
index e83deb1f..52c5a921 100644
--- a/dist/modules/utils/time.js
+++ b/dist/modules/utils/time.js
@@ -1,6 +1,6 @@
/**
* Anime.js - utils - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/waapi/composition.cjs b/dist/modules/waapi/composition.cjs
index 83bbc70c..b567ed6a 100644
--- a/dist/modules/waapi/composition.cjs
+++ b/dist/modules/waapi/composition.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/waapi/composition.js b/dist/modules/waapi/composition.js
index 519785e1..a6d9e7b8 100644
--- a/dist/modules/waapi/composition.js
+++ b/dist/modules/waapi/composition.js
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/waapi/index.cjs b/dist/modules/waapi/index.cjs
index 37c09d71..2a29c5f3 100644
--- a/dist/modules/waapi/index.cjs
+++ b/dist/modules/waapi/index.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/waapi/index.js b/dist/modules/waapi/index.js
index 1848e02b..db626d17 100644
--- a/dist/modules/waapi/index.js
+++ b/dist/modules/waapi/index.js
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
diff --git a/dist/modules/waapi/waapi.cjs b/dist/modules/waapi/waapi.cjs
index 37aa8e25..cd41e381 100644
--- a/dist/modules/waapi/waapi.cjs
+++ b/dist/modules/waapi/waapi.cjs
@@ -1,6 +1,6 @@
/**
* Anime.js - waapi - CJS
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
@@ -333,9 +333,10 @@ class WAAPIAnimation {
* @return {this}
*/
forEach(callback) {
- const cb = helpers.isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
- this.animations.forEach(cb);
- return this;
+ try {
+ const cb = helpers.isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
+ this.animations.forEach(cb);
+ } catch {} return this;
}
get speed() {
@@ -431,14 +432,21 @@ class WAAPIAnimation {
cancel() {
this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
- return this.commitStyles().forEach('cancel');
+ this.commitStyles().forEach('cancel');
+ this.animations.length = 0; // Needed to release all animations from memory
+ requestAnimationFrame(() => {
+ this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
+ if ($el.style.transform === 'none') $el.style.removeProperty('transform');
+ });
+ });
+ return this;
}
revert() {
// NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
// This means if you have multiple animations animating different transforms on the same target,
// reverting one of them will also override the transform property of the other animations.
- // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // A better approach would be to store the original custom property values if they exist instead of the entire transform value,
// and update the CSS variables with the orignal value
this.cancel().targets.forEach(($el, i) => {
const targetStyle = $el.style;
@@ -448,7 +456,7 @@ class WAAPIAnimation {
if (helpers.isUnd(originalInlinedValue) || originalInlinedValue === consts.emptyString) {
targetStyle.removeProperty(helpers.toLowerCase(name));
} else {
- targetStyle[name] = originalInlinedValue;
+ $el.style[name] = originalInlinedValue;
}
}
// Remove style attribute if empty
diff --git a/dist/modules/waapi/waapi.js b/dist/modules/waapi/waapi.js
index 7fd8c50d..3280de6c 100644
--- a/dist/modules/waapi/waapi.js
+++ b/dist/modules/waapi/waapi.js
@@ -1,11 +1,11 @@
/**
* Anime.js - waapi - ESM
- * @version v4.2.2
+ * @version v4.3.0-beta.0
* @license MIT
* @copyright 2025 - Julian Garnier
*/
-import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, toLowerCase, round, isStr, isFnc, isNum } from '../core/helpers.js';
+import { isNil, isUnd, stringStartsWith, isKey, isObj, isArr, isStr, toLowerCase, round, isFnc, isNum } from '../core/helpers.js';
import { scope, globals } from '../core/globals.js';
import { registerTargets } from '../core/targets.js';
import { setValue, getFunctionValue } from '../core/values.js';
@@ -331,9 +331,10 @@ class WAAPIAnimation {
* @return {this}
*/
forEach(callback) {
- const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
- this.animations.forEach(cb);
- return this;
+ try {
+ const cb = isStr(callback) ? (/** @type {globalThis.Animation} */a) => a[callback]() : callback;
+ this.animations.forEach(cb);
+ } catch {} return this;
}
get speed() {
@@ -429,14 +430,21 @@ class WAAPIAnimation {
cancel() {
this.muteCallbacks = true; // This prevents triggering the onComplete callback and resolving the Promise
- return this.commitStyles().forEach('cancel');
+ this.commitStyles().forEach('cancel');
+ this.animations.length = 0; // Needed to release all animations from memory
+ requestAnimationFrame(() => {
+ this.targets.forEach(($el) => { // Needed to avoid unecessary inline transorms
+ if ($el.style.transform === 'none') $el.style.removeProperty('transform');
+ });
+ });
+ return this;
}
revert() {
// NOTE: We need a better way to revert the transforms, since right now the entire transform property value is reverted,
// This means if you have multiple animations animating different transforms on the same target,
// reverting one of them will also override the transform property of the other animations.
- // A better approach would be to store the original custom property values is they exist instead of the entire transform value,
+ // A better approach would be to store the original custom property values if they exist instead of the entire transform value,
// and update the CSS variables with the orignal value
this.cancel().targets.forEach(($el, i) => {
const targetStyle = $el.style;
@@ -446,7 +454,7 @@ class WAAPIAnimation {
if (isUnd(originalInlinedValue) || originalInlinedValue === emptyString) {
targetStyle.removeProperty(toLowerCase(name));
} else {
- targetStyle[name] = originalInlinedValue;
+ $el.style[name] = originalInlinedValue;
}
}
// Remove style attribute if empty