"use strict";
/**
 *  ExpandAncestorAwareStyler
 *
 *  Copyright (C) 2010-2020 R-T Specialty, LLC.
 *
 *  This file is part of liza.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExpandAncestorAwareStyler = void 0;
var AncestorAwareStyler_1 = require("./AncestorAwareStyler");
/**
 * Expand an HTML element's ancestor's size
 */
var ExpandAncestorAwareStyler = /** @class */ (function () {
    function ExpandAncestorAwareStyler() {
    }
    /**
     * Expand an ancestor to account for spill-over caused by the element
     *
     * @param element - target element
     * @param n       - number of generations back
     */
    ExpandAncestorAwareStyler.prototype.style = function (element, generation) {
        var ancestor = AncestorAwareStyler_1.getNthAncestor(element, generation);
        if (!ancestor) {
            return;
        }
        var ancestor_rect = ancestor.getBoundingClientRect();
        var element_rect = element.getBoundingClientRect();
        var margin = Math.max(0, element_rect.bottom - ancestor_rect.bottom);
        ancestor.style.marginBottom = margin + "px";
    };
    return ExpandAncestorAwareStyler;
}());
exports.ExpandAncestorAwareStyler = ExpandAncestorAwareStyler;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRXhwYW5kQW5jZXN0b3JBd2FyZVN0eWxlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIkV4cGFuZEFuY2VzdG9yQXdhcmVTdHlsZXIudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHOzs7QUFFSCw2REFBMEU7QUFHMUU7O0dBRUc7QUFDSDtJQUFBO0lBcUJBLENBQUM7SUFwQkM7Ozs7O09BS0c7SUFDSSx5Q0FBSyxHQUFaLFVBQWEsT0FBb0IsRUFBRSxVQUEyQjtRQUM1RCxJQUFNLFFBQVEsR0FBRyxvQ0FBYyxDQUFDLE9BQU8sRUFBRSxVQUFVLENBQUMsQ0FBQztRQUVyRCxJQUFJLENBQUMsUUFBUSxFQUFFO1lBQ2IsT0FBTztTQUNSO1FBRUQsSUFBTSxhQUFhLEdBQUcsUUFBUSxDQUFDLHFCQUFxQixFQUFFLENBQUM7UUFDdkQsSUFBTSxZQUFZLEdBQUcsT0FBTyxDQUFDLHFCQUFxQixFQUFFLENBQUM7UUFFckQsSUFBTSxNQUFNLEdBQUcsSUFBSSxDQUFDLEdBQUcsQ0FBQyxDQUFDLEVBQUUsWUFBWSxDQUFDLE1BQU0sR0FBRyxhQUFhLENBQUMsTUFBTSxDQUFDLENBQUM7UUFFdkUsUUFBUSxDQUFDLEtBQUssQ0FBQyxZQUFZLEdBQU0sTUFBTSxPQUFJLENBQUM7SUFDOUMsQ0FBQztJQUNILGdDQUFDO0FBQUQsQ0FBQyxBQXJCRCxJQXFCQztBQXJCWSw4REFBeUIifQ==