"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
    if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
const mobx_1 = require("mobx");
const boxes_1 = require("./boxes");
const OrderedList_1 = require("./OrderedList");
class PiCompositeProjection {
    constructor(name) {
        this.projections = new OrderedList_1.OrderedList();
        this._rootProjection = null;
        this.name = "";
        if (!!name) {
            this.name = name;
        }
    }
    set rootProjection(p) {
        this._rootProjection = p;
        this.projections.toArray().forEach(child => (child.element.rootProjection = p));
    }
    getBox(element) {
        for (let p of this.projections.toArray()) {
            const result = p.element.getBox(element);
            if (result !== null) {
                return result;
            }
        }
        return new boxes_1.LabelBox(element, "unknown-projection", () => "unknown box for " + element);
    }
    addProjection(p) {
        this.projections.add(p.name, p);
        p.rootProjection = this;
    }
    projectiontoFront(name) {
        this.projections.toFront(name);
    }
    projectionToBack(name) {
        this.projections.toBack(name);
    }
    projectionNames() {
        return this.projections.toArray().map(p => p.name);
    }
}
__decorate([
    mobx_1.observable,
    __metadata("design:type", OrderedList_1.OrderedList)
], PiCompositeProjection.prototype, "projections", void 0);
exports.PiCompositeProjection = PiCompositeProjection;
//# sourceMappingURL=PiCompositeProjection.js.map