'use strict';

var isMotionValue = require('../../../value/utils/is-motion-value.js');
var keysTransform = require('../../utils/keys-transform.js');
var scrapeMotionValues = require('../../html/utils/scrape-motion-values.js');

function scrapeMotionValuesFromProps(props, prevProps, visualElement) {
    const newValues = scrapeMotionValues.scrapeMotionValuesFromProps(props, prevProps, visualElement);
    for (const key in props) {
        if (isMotionValue.isMotionValue(props[key]) ||
            isMotionValue.isMotionValue(prevProps[key])) {
            const targetKey = keysTransform.transformPropOrder.indexOf(key) !== -1
                ? "attr" + key.charAt(0).toUpperCase() + key.substring(1)
                : key;
            newValues[targetKey] = props[key];
        }
    }
    return newValues;
}

exports.scrapeMotionValuesFromProps = scrapeMotionValuesFromProps;
