{"version":3,"file":"animation-state.mjs","sources":["../../../../src/render/utils/animation-state.ts"],"sourcesContent":["import type {\n    AnimationDefinition,\n    TargetAndTransition,\n    VariantLabels,\n} from \"../../node/types\"\nimport type { AnimationType } from \"../types\"\nimport type { VisualElementAnimationOptions } from \"../../animation/interfaces/types\"\nimport { animateVisualElement } from \"../../animation/interfaces/visual-element\"\nimport { calcChildStagger } from \"../../animation/utils/calc-child-stagger\"\nimport { isMotionValue } from \"../../value/utils/is-motion-value\"\nimport { isAnimationControls } from \"./is-animation-controls\"\nimport { isVariantLabel } from \"./is-variant-label\"\nimport { getTypeCustom, resolveVariant } from \"./resolve-dynamic-variants\"\nimport { shallowCompare } from \"./shallow-compare\"\nimport { variantPriorityOrder } from \"./variant-props\"\n\nexport type { VisualElementAnimationOptions }\n\nexport interface AnimationState {\n    animateChanges: (type?: AnimationType) => Promise<any>\n    setActive: (\n        type: AnimationType,\n        isActive: boolean,\n        options?: VisualElementAnimationOptions\n    ) => Promise<any>\n    setAnimateFunction: (fn: any) => void\n    getState: () => { [key: string]: AnimationTypeState }\n    reset: () => void\n}\n\ninterface DefinitionAndOptions {\n    animation: AnimationDefinition\n    options?: VisualElementAnimationOptions\n}\n\nexport type AnimationList = string[] | TargetAndTransition[]\n\n/**\n * Type for the animate function that can be injected.\n * This allows the animation implementation to be provided by the framework layer.\n */\nexport type AnimateFunction = (\n    animations: DefinitionAndOptions[]\n) => Promise<any>\n\nconst reversePriorityOrder = [...variantPriorityOrder].reverse()\n\n/**\n * Diffs the element's animation props (one layer per AnimationType, highest\n * priority wins each value) against the previous call and starts animations\n * for what changed.\n *\n * Uses `any` type for visualElement to avoid circular dependencies. It reads\n * props, parent, presenceContext, variantChildren, enteringChildren,\n * manuallyAnimateOnMount, blockInitialAnimation, getValue(),\n * getBaseTargetFromProps(), baseTarget and initialValues.\n */\nexport function createAnimationState(visualElement: any): AnimationState {\n    let animate: AnimateFunction = (animations) =>\n        Promise.all(\n            animations.map(({ animation, options }) =>\n                animateVisualElement(visualElement, animation, options)\n            )\n        )\n    let state = createState()\n    let isInitialRender = true\n\n    /**\n     * After a reset (StrictMode, Suspense, AnimatePresence re-entry) the next\n     * animateChanges() mounts again, but initial={false} no longer applies.\n     */\n    let wasReset = false\n\n    function animateChanges(changedActiveType?: AnimationType) {\n        const { props, parent, manuallyAnimateOnMount } = visualElement\n        const isMounting = isInitialRender || wasReset\n        const animations: DefinitionAndOptions[] = []\n\n        /**\n         * Values removed from a type. A lower-priority type that defines\n         * them animates them back, otherwise they fall back to a base target.\n         */\n        const removedKeys = new Set<string>()\n\n        /**\n         * Values claimed by active, higher-priority types.\n         */\n        let encounteredKeys: { [key: string]: any } = {}\n\n        /**\n         * Once a type has been deactivated, lower-priority variant labels\n         * re-animate so variant children animate back too.\n         */\n        let removedVariantIndex = Infinity\n\n        /**\n         * Variant labels are inherited from the closest variant-controlling\n         * ancestor, unless an element on the way has inherit={false}.\n         */\n        let source = visualElement\n        do source = source.props.inherit !== false && source.parent\n        while (source && !source.isControllingVariants)\n\n        reversePriorityOrder.forEach((type, i) => {\n            const typeState = state[type]\n            const ownProp = props[type]\n            const inheritedProp = source && source.props[type]\n            const prop =\n                ownProp !== undefined\n                    ? ownProp\n                    : isVariantLabel(inheritedProp) || inheritedProp === false\n                    ? inheritedProp\n                    : undefined\n            const propIsVariant = isVariantLabel(prop)\n            const activeDelta =\n                type === changedActiveType ? typeState.isActive : null\n\n            if (activeDelta === false) removedVariantIndex = i\n\n            /**\n             * Inherited labels are animated by the parent through\n             * variantChildren, unless this element mounted after its parent.\n             */\n            const isInherited =\n                propIsVariant &&\n                ownProp === undefined &&\n                !(isMounting && manuallyAnimateOnMount)\n\n            typeState.protectedKeys = { ...encounteredKeys }\n\n            if (\n                (!typeState.isActive && activeDelta === null) ||\n                (!prop && !typeState.prevProp) ||\n                isAnimationControls(prop) ||\n                typeof prop === \"boolean\"\n            ) {\n                return\n            }\n\n            /**\n             * Don't re-resolve a running exit: a changed custom would start\n             * new value animations that stop the originals, leaving the exit\n             * promise unresolved and the element stuck in the DOM.\n             */\n            if (type === \"exit\" && typeState.isActive && activeDelta !== true) {\n                encounteredKeys = {\n                    ...encounteredKeys,\n                    ...typeState.prevResolvedValues,\n                }\n                return\n            }\n\n            const variantDidChange = checkVariantsDidChange(\n                typeState.prevProp,\n                prop\n            )\n            let shouldAnimateType =\n                variantDidChange ||\n                (propIsVariant &&\n                    ((activeDelta && !isInherited) || i > removedVariantIndex))\n            let handledRemovedValues = false\n            const definitionList = Array.isArray(prop) ? prop : [prop]\n            let resolvedValues: { [key: string]: any } = {}\n\n            if (activeDelta !== false) {\n                for (const definition of definitionList) {\n                    const { transition, transitionEnd, ...target } =\n                        resolveVariant(\n                            visualElement,\n                            definition,\n                            getTypeCustom(visualElement, type)\n                        ) || {}\n                    resolvedValues = {\n                        ...resolvedValues,\n                        ...target,\n                        ...transitionEnd,\n                    }\n                }\n            }\n\n            const { prevResolvedValues } = typeState\n\n            for (const key in { ...prevResolvedValues, ...resolvedValues }) {\n                if (key in encounteredKeys) continue\n\n                const next = resolvedValues[key]\n                const prev = prevResolvedValues[key]\n\n                /**\n                 * Keyframes compare by value, but replay whenever the\n                 * variant label changed.\n                 */\n                const valueHasChanged =\n                    Array.isArray(next) && Array.isArray(prev)\n                        ? !shallowCompare(next, prev) || variantDidChange\n                        : next !== prev\n\n                if (valueHasChanged && (next === undefined || next === null)) {\n                    removedKeys.add(key)\n                } else if (\n                    valueHasChanged ||\n                    (next !== undefined && removedKeys.has(key))\n                ) {\n                    shouldAnimateType = true\n                    if (removedKeys.delete(key)) handledRemovedValues = true\n                    typeState.needsAnimating[key] = true\n\n                    const motionValue = visualElement.getValue(key)\n                    if (motionValue) motionValue.liveStyle = false\n                } else {\n                    typeState.protectedKeys[key] = true\n                }\n            }\n\n            typeState.prevProp = prop\n            typeState.prevResolvedValues = resolvedValues\n\n            if (typeState.isActive) {\n                encounteredKeys = { ...encounteredKeys, ...resolvedValues }\n            }\n\n            if (\n                shouldAnimateType &&\n                (!(isInherited && variantDidChange) || handledRemovedValues)\n            ) {\n                for (const animation of definitionList) {\n                    const options: VisualElementAnimationOptions = { type }\n\n                    /**\n                     * Elements that mount into an already-mounted parent\n                     * animate themselves, staggered by the parent variant's\n                     * delayChildren.\n                     */\n                    if (\n                        typeof animation === \"string\" &&\n                        isMounting &&\n                        manuallyAnimateOnMount &&\n                        parent?.enteringChildren\n                    ) {\n                        const delayChildren = resolveVariant(parent, animation)\n                            ?.transition?.delayChildren\n\n                        options.delay = calcChildStagger(\n                            parent.enteringChildren,\n                            visualElement,\n                            delayChildren\n                        )\n                    }\n\n                    animations.push({ animation, options })\n                }\n            }\n        })\n\n        /**\n         * Removed values that no lower-priority type defines animate back to\n         * initial, then style, then the value as first read. If initial no\n         * longer defines a value it once did, it stays where it is.\n         */\n        if (removedKeys.size) {\n            const { initial } = props\n            const fallbackAnimation: { [key: string]: any } = {}\n            const resolvedInitial =\n                typeof initial !== \"boolean\" &&\n                resolveVariant(\n                    visualElement,\n                    Array.isArray(initial) ? initial[0] : initial,\n                    visualElement.presenceContext?.custom\n                )\n\n            if (resolvedInitial && resolvedInitial.transition) {\n                fallbackAnimation.transition = resolvedInitial.transition\n            }\n\n            removedKeys.forEach((key) => {\n                const motionValue = visualElement.getValue(key)\n                if (motionValue) motionValue.liveStyle = true\n\n                const fromInitial =\n                    resolvedInitial && !Array.isArray(initial)\n                        ? (resolvedInitial as any)[key]\n                        : undefined\n                const fromProps = visualElement.getBaseTargetFromProps(\n                    props,\n                    key\n                )\n\n                fallbackAnimation[key] =\n                    (fromInitial !== undefined\n                        ? fromInitial\n                        : fromProps !== undefined && !isMotionValue(fromProps)\n                        ? fromProps\n                        : visualElement.initialValues[key] === undefined\n                        ? visualElement.baseTarget[key]\n                        : undefined) ?? null\n\n                /**\n                 * If it stays where it is, that's now its base. Otherwise a\n                 * later removal (like a gesture ending) would also stay,\n                 * leaving the value stuck. Stop first so accelerated\n                 * animations sync the value they reached. In practice initial\n                 * only changes like this with Fast Refresh, so this is\n                 * dev-only (#3787).\n                 */\n                if (\n                    process.env.NODE_ENV !== \"production\" &&\n                    fallbackAnimation[key] === null &&\n                    visualElement.initialValues[key] !== undefined\n                ) {\n                    delete visualElement.initialValues[key]\n                    motionValue?.stop()\n                    visualElement.baseTarget[key] = motionValue?.get()\n                }\n            })\n\n            animations.push({ animation: fallbackAnimation })\n        }\n\n        const blockAnimation =\n            (isMounting && visualElement.blockInitialAnimation) ||\n            (isInitialRender &&\n                !manuallyAnimateOnMount &&\n                (props.initial === false || props.initial === props.animate))\n\n        isInitialRender = wasReset = false\n\n        return !blockAnimation && animations.length\n            ? animate(animations)\n            : Promise.resolve()\n    }\n\n    /**\n     * Change whether a certain animation type is active.\n     */\n    function setActive(type: AnimationType, isActive: boolean) {\n        if (state[type].isActive === isActive) return Promise.resolve()\n\n        visualElement.variantChildren?.forEach((child: any) =>\n            child.animationState?.setActive(type, isActive)\n        )\n\n        state[type].isActive = isActive\n\n        const animations = animateChanges(type)\n\n        for (const key in state) {\n            state[key as AnimationType].protectedKeys = {}\n        }\n\n        return animations\n    }\n\n    return {\n        animateChanges,\n        setActive,\n        /**\n         * Allows tests to inject a mocked animate function.\n         * @internal\n         */\n        setAnimateFunction: (makeAnimator) => {\n            animate = makeAnimator(visualElement)\n        },\n        getState: () => state,\n        reset: () => {\n            state = createState()\n            wasReset = true\n        },\n    }\n}\n\nexport function checkVariantsDidChange(prev: any, next: any) {\n    if (typeof next === \"string\") {\n        return next !== prev\n    } else if (Array.isArray(next)) {\n        return !shallowCompare(next, prev)\n    }\n\n    return false\n}\n\nexport interface AnimationTypeState {\n    isActive: boolean\n    protectedKeys: { [key: string]: true }\n    needsAnimating: { [key: string]: boolean }\n    prevResolvedValues: { [key: string]: any }\n    prevProp?: VariantLabels | TargetAndTransition\n}\n\nfunction createState() {\n    const state = {} as { [K in AnimationType]: AnimationTypeState }\n\n    for (const type of variantPriorityOrder) {\n        state[type] = {\n            isActive: type === \"animate\",\n            protectedKeys: {},\n            needsAnimating: {},\n            prevResolvedValues: {},\n        }\n    }\n\n    return state\n}\n"],"names":[],"mappings":";;;;;;;;;AA6CA,MAAM,oBAAoB,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,OAAO,EAAE;AAEhE;;;;;;;;;AASG;AACG,SAAU,oBAAoB,CAAC,aAAkB,EAAA;AACnD,IAAA,IAAI,OAAO,GAAoB,CAAC,UAAU,KACtC,OAAO,CAAC,GAAG,CACP,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,KAClC,oBAAoB,CAAC,aAAa,EAAE,SAAS,EAAE,OAAO,CAAC,CAC1D,CACJ;AACL,IAAA,IAAI,KAAK,GAAG,WAAW,EAAE;IACzB,IAAI,eAAe,GAAG,IAAI;AAE1B;;;AAGG;IACH,IAAI,QAAQ,GAAG,KAAK;IAEpB,SAAS,cAAc,CAAC,iBAAiC,EAAA;QACrD,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,EAAE,GAAG,aAAa;AAC/D,QAAA,MAAM,UAAU,GAAG,eAAe,IAAI,QAAQ;QAC9C,MAAM,UAAU,GAA2B,EAAE;AAE7C;;;AAGG;AACH,QAAA,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU;AAErC;;AAEG;QACH,IAAI,eAAe,GAA2B,EAAE;AAEhD;;;AAGG;QACH,IAAI,mBAAmB,GAAG,QAAQ;AAElC;;;AAGG;QACH,IAAI,MAAM,GAAG,aAAa;AAC1B,QAAA;AAAG,YAAA,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,KAAK,KAAK,IAAI,MAAM,CAAC,MAAM;AACpD,eAAA,MAAM,IAAI,CAAC,MAAM,CAAC,qBAAqB;QAE9C,oBAAoB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,KAAI;AACrC,YAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;AAC7B,YAAA,MAAM,OAAO,GA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