import { AssemblerView } from "../../Views/Assembler/AssemblerView.js";
import MacroView from "../../Views/Assembler/MacroView.js";
import MicroView from "../../Views/Assembler/MicroView.js";
import { BaseView } from "../../Views/BaseView.js";
export class TabbedContent extends BaseView {
    constructor(options) {
        super(options);
    }
    get source() {
        return this.state.get("source");
    }
    get assemblers() {
        return this.controls.getByType(AssemblerView);
    }
    template() {
        return `<div role="content"></div>`;
    }
    selectGroup(groupId) {
        this.assemblers.each(view => {
            if (view.source.id == groupId) {
                view.show();
            }
            else {
                view.hide();
            }
        });
    }
    onActivate(e) {
        super.onActivate(e);
        this.generateGroupViews();
        this.eventBus.subscribe("feature-blend:tab:select", (groupId) => {
            this.selectGroup(groupId);
        });
    }
    generateGroupViews() {
        this.source.groups.forEach((group, index) => {
            let view = null;
            if (group.isMicro) {
                view = new MicroView({
                    eventBus: this.eventBus,
                    source: group,
                    visible: index === 0,
                    isDefaultView: index === 0
                });
            }
            else {
                view = new MacroView({
                    eventBus: this.eventBus,
                    source: group,
                    visible: index === 0,
                    isDefaultView: index === 0
                });
            }
            this.controls.add(view);
        });
    }
}
