"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseRelativeUnit = parseRelativeUnit;
exports.parseParentRelativeUnit = parseParentRelativeUnit;
exports.parseFrameRelativeUnit = parseFrameRelativeUnit;
const isFrameRelative_1 = require("../isFrameRelative");
const isParentRelative_1 = require("../isParentRelative");
function parseRelativeUnit(value, parentLength, frameLength) {
    if (typeof value === 'number') {
        return value;
    }
    else {
        if ((0, isParentRelative_1.isParentRelativeValue)(value)) {
            return parseParentRelativeUnit(value, parentLength);
        }
        else if ((0, isFrameRelative_1.isFrameRelativeValue)(value)) {
            return parseFrameRelativeUnit(value, frameLength);
        }
        else {
            const valueUnit = Number.parseFloat(value);
            return valueUnit;
        }
    }
}
function parseParentRelativeUnit(value, parentLength) {
    const valueNum = value.substring(0, value.length - 1);
    const valueUnit = Number.parseFloat(valueNum);
    const percent = valueUnit / 100;
    return percent * parentLength;
}
function parseFrameRelativeUnit(value, frameLength) {
    const valueNum = value.substring(0, value.length - 2);
    const valueUnit = Number.parseFloat(valueNum);
    const percent = valueUnit / 100;
    return percent * frameLength;
}
//# sourceMappingURL=parseRelativeUnit.js.map