'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const __chunk_1 = require('./chunk-91f43df3.js');

class FormController {
    constructor(hostRef) {
        __chunk_1.registerInstance(this, hostRef);
        this.modalCtrl = __chunk_1.getConnect(this, "ion-modal-controller");
    }
    async create(feature, options) {
        let form = document.createElement('gl-form');
        form.feature = feature;
        for (let optionName in options)
            form[optionName] = options[optionName];
        const modal = await this.modalCtrl.create({
            component: form
        });
        await modal.present();
        return await new Promise((resolve) => {
            form.addEventListener('glFormCancel', () => {
                modal.dismiss();
                resolve();
            });
            form.addEventListener('glFormSubmit', () => {
                modal.dismiss();
                resolve(feature);
            });
        });
    }
}

exports.gl_form_controller = FormController;
