{"ast":null,"code":"import { __assign } from 'tslib';\nimport { useContext, useRef, useEffect } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.js';\nimport { isPresent } from '../../components/AnimatePresence/use-presence.js';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.js';\nimport { useVisualElementContext } from '../../context/MotionContext/index.js';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.js';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.js';\nimport { LazyContext } from '../../context/LazyContext.js';\nfunction useLayoutId(_a) {\n  var layoutId = _a.layoutId;\n  var layoutGroupId = useContext(LayoutGroupContext);\n  return layoutGroupId && layoutId !== undefined ? layoutGroupId + \"-\" + layoutId : layoutId;\n}\nfunction useVisualElement(Component, visualState, props, createVisualElement) {\n  var config = useContext(MotionConfigContext);\n  var lazyContext = useContext(LazyContext);\n  var parent = useVisualElementContext();\n  var presenceContext = useContext(PresenceContext);\n  var layoutId = useLayoutId(props);\n  var visualElementRef = useRef(undefined);\n  /**\n   * If we haven't preloaded a renderer, check to see if we have one lazy-loaded\n   */\n  if (!createVisualElement) createVisualElement = lazyContext.renderer;\n  if (!visualElementRef.current && createVisualElement) {\n    visualElementRef.current = createVisualElement(Component, {\n      visualState: visualState,\n      parent: parent,\n      props: __assign(__assign({}, props), {\n        layoutId: layoutId\n      }),\n      presenceId: presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.id,\n      blockInitialAnimation: (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false\n    });\n  }\n  var visualElement = visualElementRef.current;\n  useIsomorphicLayoutEffect(function () {\n    if (!visualElement) return;\n    visualElement.setProps(__assign(__assign(__assign({}, config), props), {\n      layoutId: layoutId\n    }));\n    visualElement.isPresent = isPresent(presenceContext);\n    visualElement.isPresenceRoot = !parent || parent.presenceId !== (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.id);\n    /**\n     * Fire a render to ensure the latest state is reflected on-screen.\n     */\n    visualElement.syncRender();\n  });\n  useEffect(function () {\n    var _a;\n    if (!visualElement) return;\n    /**\n     * In a future refactor we can replace the features-as-components and\n     * have this loop through them all firing \"effect\" listeners\n     */\n    (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.animateChanges();\n  });\n  useIsomorphicLayoutEffect(function () {\n    return function () {\n      return visualElement === null || visualElement === void 0 ? void 0 : visualElement.notifyUnmount();\n    };\n  }, []);\n  return visualElement;\n}\nexport { useVisualElement };","map":{"version":3,"names":["__assign","useContext","useRef","useEffect","PresenceContext","isPresent","LayoutGroupContext","useVisualElementContext","useIsomorphicLayoutEffect","MotionConfigContext","LazyContext","useLayoutId","_a","layoutId","layoutGroupId","undefined","useVisualElement","Component","visualState","props","createVisualElement","config","lazyContext","parent","presenceContext","visualElementRef","renderer","current","presenceId","id","blockInitialAnimation","initial","visualElement","setProps","isPresenceRoot","syncRender","animationState","animateChanges","notifyUnmount"],"sources":["C:/LDT/DSP_Management/node_modules/framer-motion/dist/es/motion/utils/use-visual-element.js"],"sourcesContent":["import { __assign } from 'tslib';\nimport { useContext, useRef, useEffect } from 'react';\nimport { PresenceContext } from '../../context/PresenceContext.js';\nimport { isPresent } from '../../components/AnimatePresence/use-presence.js';\nimport { LayoutGroupContext } from '../../context/LayoutGroupContext.js';\nimport { useVisualElementContext } from '../../context/MotionContext/index.js';\nimport { useIsomorphicLayoutEffect } from '../../utils/use-isomorphic-effect.js';\nimport { MotionConfigContext } from '../../context/MotionConfigContext.js';\nimport { LazyContext } from '../../context/LazyContext.js';\n\nfunction useLayoutId(_a) {\n    var layoutId = _a.layoutId;\n    var layoutGroupId = useContext(LayoutGroupContext);\n    return layoutGroupId && layoutId !== undefined\n        ? layoutGroupId + \"-\" + layoutId\n        : layoutId;\n}\nfunction useVisualElement(Component, visualState, props, createVisualElement) {\n    var config = useContext(MotionConfigContext);\n    var lazyContext = useContext(LazyContext);\n    var parent = useVisualElementContext();\n    var presenceContext = useContext(PresenceContext);\n    var layoutId = useLayoutId(props);\n    var visualElementRef = useRef(undefined);\n    /**\n     * If we haven't preloaded a renderer, check to see if we have one lazy-loaded\n     */\n    if (!createVisualElement)\n        createVisualElement = lazyContext.renderer;\n    if (!visualElementRef.current && createVisualElement) {\n        visualElementRef.current = createVisualElement(Component, {\n            visualState: visualState,\n            parent: parent,\n            props: __assign(__assign({}, props), { layoutId: layoutId }),\n            presenceId: presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.id,\n            blockInitialAnimation: (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.initial) === false,\n        });\n    }\n    var visualElement = visualElementRef.current;\n    useIsomorphicLayoutEffect(function () {\n        if (!visualElement)\n            return;\n        visualElement.setProps(__assign(__assign(__assign({}, config), props), { layoutId: layoutId }));\n        visualElement.isPresent = isPresent(presenceContext);\n        visualElement.isPresenceRoot =\n            !parent || parent.presenceId !== (presenceContext === null || presenceContext === void 0 ? void 0 : presenceContext.id);\n        /**\n         * Fire a render to ensure the latest state is reflected on-screen.\n         */\n        visualElement.syncRender();\n    });\n    useEffect(function () {\n        var _a;\n        if (!visualElement)\n            return;\n        /**\n         * In a future refactor we can replace the features-as-components and\n         * have this loop through them all firing \"effect\" listeners\n         */\n        (_a = visualElement.animationState) === null || _a === void 0 ? void 0 : _a.animateChanges();\n    });\n    useIsomorphicLayoutEffect(function () { return function () { return visualElement === null || visualElement === void 0 ? void 0 : visualElement.notifyUnmount(); }; }, []);\n    return visualElement;\n}\n\nexport { useVisualElement };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,UAAU,EAAEC,MAAM,EAAEC,SAAS,QAAQ,OAAO;AACrD,SAASC,eAAe,QAAQ,kCAAkC;AAClE,SAASC,SAAS,QAAQ,kDAAkD;AAC5E,SAASC,kBAAkB,QAAQ,qCAAqC;AACxE,SAASC,uBAAuB,QAAQ,sCAAsC;AAC9E,SAASC,yBAAyB,QAAQ,sCAAsC;AAChF,SAASC,mBAAmB,QAAQ,sCAAsC;AAC1E,SAASC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