/// <reference path="../Say.ts" />
class SayLeftRight extends Say {
    private left : Say = new Say();
    private right : Say = new Say();

    public constructor () {
        super();
    }

    public addLeft (...objs : Array<Say | OneOf | Object | Printable | string | number | String | ((say : Say) => string)>) {
        this.left.add(...objs);
    }

    public addRight (...objs : Array<Say | OneOf | Object | Printable | string | number | String | ((say : Say) => string)>) {
        this.right.add(...objs);
    }

    public async getPureElements () : Promise<Array<Element | Text>> {
        if (this.left.sequence.length == 0) {
            return await this.right.getPureElements();
        } else if (this.right.sequence.length == 0) {
            return await this.left.getPureElements();
        }

        let mainDiv = document.createElement("div");
        mainDiv.classList.add("horFlex");

        let left = document.createElement("div");
        left.classList.add("horFlexColumn");
        mainDiv.appendChild(left);

        let right = document.createElement("div");
        right.classList.add("horFlexColumn");
        mainDiv.appendChild(right);

        await this.left.getPureElements().then(value => {
            value.forEach(element => {
                left.appendChild(element);
            })
        });

        await this.right.getPureElements().then(value => {
            value.forEach(element => {
                right.appendChild(element);
            })
        });

        return [mainDiv];
    }
}