import { Blockly } from '@kano/kwc-blockly/blockly.js';
import { KCSequenceConfig } from '../components/kc-sequence-config.js';
export class FieldSequenceConfig extends Blockly.FieldConfig {
    constructor(title, value, optValidator) {
        super(value.toString(), optValidator);
        this.title = title;
    }
    showEditor_() {
        Blockly.WidgetDiv.show(this, this.sourceBlock_.RTL, FieldSequenceConfig.widgetDispose_);
        const div = Blockly.WidgetDiv.DIV;
        this.customEl = new KCSequenceConfig();
        this.customEl.title = this.title;
        this.customEl.value = parseInt(this.getValue(), 10);
        const sequenceField = this.sourceBlock_.getField('SEQUENCE');
        if (!sequenceField) {
            return;
        }
        this.customEl.addEventListener('change', ((e) => {
            sequenceField.setSize(e.detail);
            this.setValue(e.detail.toString());
        }));
        div.appendChild(this.customEl);
        this.customEl.updateComplete.then(() => {
            this.position();
        });
    }
    static widgetDispose_() { }
}
//# sourceMappingURL=field-sequence-config.js.map