export function computeOffsetPixels(offset, contextHeight) {
    var pixelOffset = parseOffsetAsPixels(offset);
    if (typeof pixelOffset === 'number') {
        return pixelOffset;
    }
    if (typeof offset === 'string') {
        var percentOffset = parseOffsetAsPercentage(offset);
        if (typeof percentOffset === 'number') {
            return percentOffset * contextHeight;
        }
    }
    return undefined;
}
function parseOffsetAsPercentage(str) {
    if (str.slice(-1) === '%') {
        return parseFloat(str.slice(0, -1)) / 100;
    }
    return undefined;
}
function parseOffsetAsPixels(str) {
    var val;
    if (typeof str === 'number') {
        val = str;
    }
    else {
        val = parseFloat(str);
    }
    if (!Number.isNaN(val) && Number.isFinite(val)) {
        return val;
    }
    return undefined;
}
