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 SimpleContentView extends BaseView {
    constructor(options) {
        super(options);
    }
    get autoFocusOnLoad() {
        return this.state.get("autoFocusOnLoad", true);
    }
    get source() {
        return super.source;
    }
    get assemblers() {
        return this.controls.getByType(AssemblerView);
    }
    template() {
        return `<div role="content" class="-fb-layout-content"></div>`;
    }
    selectGroup(groupId) {
        this.assemblers.each(view => {
            if (view.source.id != groupId) {
                view.hide();
            }
        });
        this.assemblers.each(view => {
            if (view.source.id == groupId) {
                view.source.globals.storage.selectedGroupId = view.source.id;
                view.show();
            }
        });
    }
    onActivate(e) {
        super.onActivate(e);
        this.generateGroupViews();
        this.globals.events.navigationSelectSubscribe((e) => {
            this.selectGroup(e.id);
        });
    }
    generateGroupViews() {
        this.source.featureSet.groups.forEach((group, index) => {
            let view = null;
            if (group.isMicro) {
                view = new MicroView({
                    source: group,
                    visible: index === 0,
                    isDefaultView: index === 0,
                    autoFocusOnLoad: this.autoFocusOnLoad
                });
            }
            else {
                view = new MacroView({
                    source: group,
                    visible: index === 0,
                    isDefaultView: index === 0
                });
            }
            this.controls.add(view);
        });
    }
}
