/*!
 * Custom elements for Nanopore-Digital Web applications
 */
export default function Slide(parent) {
    this.parent = parent;
    this.isOriginLeft = parent.originSide == 'left';
    this.cells = [];
    this.outerWidth = 0;
    this.height = 0;
}
const proto = Slide.prototype;
proto.addCell = function (cell) {
    this.cells.push(cell);
    this.outerWidth += cell.size.outerWidth;
    this.height = Math.max(cell.size.outerHeight, this.height);
    // first cell stuff
    if (this.cells.length == 1) {
        this.x = cell.x; // x comes from first cell
        const beginMargin = this.isOriginLeft ? 'marginLeft' : 'marginRight';
        this.firstMargin = cell.size[beginMargin];
    }
};
proto.updateTarget = function () {
    const endMargin = this.isOriginLeft ? 'marginRight' : 'marginLeft';
    const lastCell = this.getLastCell();
    const lastMargin = lastCell ? lastCell.size[endMargin] : 0;
    const slideWidth = this.outerWidth - (this.firstMargin + lastMargin);
    this.target = this.x + this.firstMargin + slideWidth * this.parent.cellAlign;
};
proto.getLastCell = function () {
    return this.cells[this.cells.length - 1];
};
proto.select = function () {
    this.cells.forEach(function (cell) {
        cell.select();
    });
};
proto.unselect = function () {
    this.cells.forEach(function (cell) {
        cell.unselect();
    });
};
proto.getCellElements = function () {
    return this.cells.map(function (cell) {
        return cell.element;
    });
};
