class ComputedStyleCompat {
    constructor(el) {
        if (!ComputedStyleCompat.colorParser) {
            const el = document.createElement('div');
            el.style.display = 'none !important';
            document.body.appendChild(el);
            ComputedStyleCompat.colorParser = el;
            ComputedStyleCompat.colorParserStyle = window.getComputedStyle(el);
        }
        this.el = el;
        this.style = window.getComputedStyle(el);
    }
    size() {
        return this.style.length;
    }
    get(propertyName) {
        return this.style.getPropertyValue(propertyName).trim();
    }
    getColor(propertyName) {
        ComputedStyleCompat.colorParser.style.color = this.get(propertyName);
        return ComputedStyleCompat.colorParserStyle.color || 'rgb(0, 0, 0)';
    }
    getNumber(propertyName) {
        // Length values in computed style will always in the unit of px
        // Maybe NaN
        return parseFloat(this.get(propertyName));
    }
}
class ComputedStyleExperimental {
    constructor(el) {
        this.el = el;
        this.style = el.computedStyleMap();
    }
    size() {
        return this.style.size;
    }
    get(propertyName) {
        return this.style.get(propertyName).toString();
    }
    getColor(propertyName) {
        return this.get(propertyName);
    }
    getNumber(propertyName) {
        const value = this.style.get(propertyName).value;
        if (typeof value === 'number') {
            // Length values in computed style will always in the unit of px
            return value;
        }
        // Maybe NaN
        return parseFloat(value);
    }
}
export function createStorage(el, compat) {
    return compat
        ? new ComputedStyleCompat(el)
        : new ComputedStyleExperimental(el);
}
//# sourceMappingURL=ComputedStyleStorage.js.map