export class EditorExtender extends Jade.UI.Control {
    constructor(options) {
        super(options);
        this.m_editorModel = options.editorModel;
        this.state.unset("editorModel", { silent: true });
    }
    get button() {
        this.ensureButton();
        return this.m_button;
    }
    get editorModel() {
        return this.m_editorModel;
    }
    get extenderId() {
        return this.state.get("extenderId");
    }
    get feature() {
        return this.editorModel.feature;
    }
    get featureGroup() {
        return this.feature.parent;
    }
    get featureSet() {
        return this.featureGroup.parent;
    }
    get globals() {
        return this.editorModel.root.context.globals;
    }
    get visible() {
        return this.node.css("display") != "none";
    }
    get locals() {
        return this.featureGroup.locals;
    }
    get clickCallback() {
        return this.state.get("click", () => { });
    }
    set clickCallback(value) {
        this.state.set("click", value);
    }
    mount(e) {
        this.clickCallback = e.click || (() => { });
        this.button.on(Jade.BrowserEvent.CLICK, () => {
            this.toggleVisibleState(!this.visible);
            this.clickCallback({
                visible: this.visible
            });
            this.activeButton_onClick({
                visible: this.visible
            });
        });
        return this.button;
    }
    isActive() {
        return true;
    }
    setActiveState(active) {
    }
    createButton() {
        return $(`<button></button>`);
    }
    ensureButton() {
        if (this.m_button == null) {
            this.m_button = this.createButton();
        }
    }
    toggleVisibleState(visible = true) {
        if (!visible) {
            this.node.hide();
            this.button.removeClass("-fb-enabled");
            this.button.removeClass("-fb-selected");
        }
        else {
            this.node.show();
            this.button.addClass("-fb-enabled");
            this.button.addClass("-fb-selected");
        }
    }
    activeButton_onClick(e) {
    }
}
