{"ast":null,"code":"import { __assign } from 'tslib';\nimport { useContext, useRef, useMemo } from 'react';\nimport { animate } from 'popmotion';\nimport { isMotionValue } from './utils/is-motion-value.js';\nimport { useMotionValue } from './use-motion-value.js';\nimport { useOnChange } from './use-on-change.js';\nimport { MotionConfigContext } from '../context/MotionConfigContext.js';\n\n/**\n * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.\n *\n * It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber\n * to another `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useSpring(0, { stiffness: 300 })\n * const y = useSpring(x, { damping: 10 })\n * ```\n *\n * @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.\n * @param springConfig - Configuration options for the spring.\n * @returns `MotionValue`\n *\n * @public\n */\nfunction useSpring(source, config) {\n  if (config === void 0) {\n    config = {};\n  }\n  var isStatic = useContext(MotionConfigContext).isStatic;\n  var activeSpringAnimation = useRef(null);\n  var value = useMotionValue(isMotionValue(source) ? source.get() : source);\n  useMemo(function () {\n    return value.attach(function (v, set) {\n      /**\n       * A more hollistic approach to this might be to use isStatic to fix VisualElement animations\n       * at that level, but this will work for now\n       */\n      if (isStatic) return set(v);\n      if (activeSpringAnimation.current) {\n        activeSpringAnimation.current.stop();\n      }\n      activeSpringAnimation.current = animate(__assign(__assign({\n        from: value.get(),\n        to: v,\n        velocity: value.getVelocity()\n      }, config), {\n        onUpdate: set\n      }));\n      return value.get();\n    });\n  }, Object.values(config));\n  useOnChange(source, function (v) {\n    return value.set(parseFloat(v));\n  });\n  return value;\n}\nexport { useSpring };","map":{"version":3,"names":["__assign","useContext","useRef","useMemo","animate","isMotionValue","useMotionValue","useOnChange","MotionConfigContext","useSpring","source","config","isStatic","activeSpringAnimation","value","get","attach","v","set","current","stop","from","to","velocity","getVelocity","onUpdate","Object","values","parseFloat"],"sources":["C:/ldt/LDT/management/node_modules/framer-motion/dist/es/value/use-spring.js"],"sourcesContent":["import { __assign } from 'tslib';\nimport { useContext, useRef, useMemo } from 'react';\nimport { animate } from 'popmotion';\nimport { isMotionValue } from './utils/is-motion-value.js';\nimport { useMotionValue } from './use-motion-value.js';\nimport { useOnChange } from './use-on-change.js';\nimport { MotionConfigContext } from '../context/MotionConfigContext.js';\n\n/**\n * Creates a `MotionValue` that, when `set`, will use a spring animation to animate to its new state.\n *\n * It can either work as a stand-alone `MotionValue` by initialising it with a value, or as a subscriber\n * to another `MotionValue`.\n *\n * @remarks\n *\n * ```jsx\n * const x = useSpring(0, { stiffness: 300 })\n * const y = useSpring(x, { damping: 10 })\n * ```\n *\n * @param inputValue - `MotionValue` or number. If provided a `MotionValue`, when the input `MotionValue` changes, the created `MotionValue` will spring towards that value.\n * @param springConfig - Configuration options for the spring.\n * @returns `MotionValue`\n *\n * @public\n */\nfunction useSpring(source, config) {\n    if (config === void 0) { config = {}; }\n    var isStatic = useContext(MotionConfigContext).isStatic;\n    var activeSpringAnimation = useRef(null);\n    var value = useMotionValue(isMotionValue(source) ? source.get() : source);\n    useMemo(function () {\n        return value.attach(function (v, set) {\n            /**\n             * A more hollistic approach to this might be to use isStatic to fix VisualElement animations\n             * at that level, but this will work for now\n             */\n            if (isStatic)\n                return set(v);\n            if (activeSpringAnimation.current) {\n                activeSpringAnimation.current.stop();\n            }\n            activeSpringAnimation.current = animate(__assign(__assign({ from: value.get(), to: v, velocity: value.getVelocity() }, config), { onUpdate: set }));\n            return value.get();\n        });\n    }, Object.values(config));\n    useOnChange(source, function (v) { return value.set(parseFloat(v)); });\n    return value;\n}\n\nexport { useSpring };\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,OAAO;AAChC,SAASC,UAAU,EAAEC,MAAM,EAAEC,OAAO,QAAQ,OAAO;AACnD,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,aAAa,QAAQ,4BAA4B;AAC1D,SAASC,cAAc,QAAQ,uBAAuB;AACtD,SAASC,WAAW,QAAQ,oBAAo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