"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HTMLUtilities = exports.HTMLShapeGeometry = void 0;
class HTMLShapeGeometry {
    top;
    left;
    height;
    width;
    topPadding;
    bottomPadding;
    rightPadding;
    constructor(top, left, height, width) {
        this.top = top;
        this.left = left;
        this.height = height;
        this.width = width;
    }
    get topWithPadding() {
        return this.top - (this.topPadding ?? 0);
    }
    get heightWithPadding() {
        return this.height + (this.topPadding ?? 0) + (this.bottomPadding ?? 0);
    }
    get right() {
        return this.left + this.width + (this.rightPadding ?? 0);
    }
    get bottom() {
        return this.top + this.height + (this.bottomPadding ?? 0);
    }
}
exports.HTMLShapeGeometry = HTMLShapeGeometry;
class HTMLUtilities {
    static getGeometry(id, parentId) {
        let element = document.getElementById(id);
        if (!element)
            return;
        return this.getGeometryFromElement(element, parentId);
    }
    static getGeometryFromElement(elem, parentId) {
        let element = elem;
        let top = 0, left = 0;
        do {
            top += element.offsetTop || 0;
            left += element.offsetLeft || 0;
            if (parentId && element.offsetParent && element.offsetParent.id === parentId) {
                break;
            }
            else {
                element = element.offsetParent;
            }
        } while (element);
        return new HTMLShapeGeometry(top, left, elem.offsetHeight, elem.offsetWidth);
    }
}
exports.HTMLUtilities = HTMLUtilities;
//# sourceMappingURL=HTMLUtilities.js.map