"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "TopInlineStartCornerOverlay", {
    enumerable: true,
    get: function() {
        return TopInlineStartCornerOverlay;
    }
});
const _element = require("../../../../helpers/dom/element");
const _topInlineStartCorner = /*#__PURE__*/ _interop_require_default(require("../table/topInlineStartCorner"));
const _base = require("./_base");
const _constants = require("./constants");
function _interop_require_default(obj) {
    return obj && obj.__esModule ? obj : {
        default: obj
    };
}
class TopInlineStartCornerOverlay extends _base.Overlay {
    /**
   * Factory method to create a subclass of `Table` that is relevant to this overlay.
   *
   * @see Table#constructor
   * @param {...*} args Parameters that will be forwarded to the `Table` constructor.
   * @returns {TopInlineStartCornerOverlayTable}
   */ createTable(...args) {
        return new _topInlineStartCorner.default(...args);
    }
    /**
   * Checks if overlay should be fully rendered.
   *
   * @returns {boolean}
   */ shouldBeRendered() {
        return this.wtSettings.getSetting('shouldRenderTopOverlay') && this.wtSettings.getSetting('shouldRenderInlineStartOverlay');
    }
    /**
   * Updates the corner overlay position.
   *
   * @returns {boolean}
   */ resetFixedPosition() {
        this.updateTrimmingContainer();
        if (!this.wot.wtTable.holder.parentNode) {
            // removed from DOM
            return false;
        }
        const overlayRoot = this.clone.wtTable.holder.parentNode;
        if (this.trimmingContainer === this.domBindings.rootWindow) {
            const left = this.inlineStartOverlay.getOverlayOffset() * (this.isRtl() ? -1 : 1);
            const top = this.topOverlay.getOverlayOffset();
            (0, _element.setOverlayPosition)(overlayRoot, `${left}px`, `${top}px`);
        } else {
            (0, _element.resetCssTransform)(overlayRoot);
        }
        let tableHeight = (0, _element.outerHeight)(this.clone.wtTable.TABLE);
        const tableWidth = (0, _element.outerWidth)(this.clone.wtTable.TABLE);
        if (!this.wot.wtTable.hasDefinedSize()) {
            tableHeight = 0;
        }
        overlayRoot.style.height = `${tableHeight}px`;
        overlayRoot.style.width = `${tableWidth}px`;
        return false;
    }
    /**
   * @param {Walkontable} wotInstance The Walkontable instance. @TODO refactoring: check if can be deleted.
   * @param {FacadeGetter} facadeGetter Function which return proper facade.
   * @param {Settings} wtSettings The Walkontable settings.
   * @param {DomBindings} domBindings Dom elements bound to the current instance.
   * @param {TopOverlay} topOverlay The instance of the Top overlay.
   * @param {InlineStartOverlay} inlineStartOverlay The instance of the InlineStart overlay.
   */ constructor(wotInstance, facadeGetter, wtSettings, domBindings, topOverlay, inlineStartOverlay){
        super(wotInstance, facadeGetter, _constants.CLONE_TOP_INLINE_START_CORNER, wtSettings, domBindings);
        this.topOverlay = topOverlay;
        this.inlineStartOverlay = inlineStartOverlay;
    }
}
