import { r as registerInstance, h, H as Host } from './index-acdc1ac0.js';
import './index-d9d18e9c.js';
import './state-tunnel-04c0b67a.js';
import './context-6b5bc156.js';
import { i as injectContext } from './index-0210701e.js';
import { B as BaseField } from './BaseField-d94c5b14.js';

const DvnMemberInfoForm = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.onSubmit = (event) => {
      const data = event.detail.values;
      this.progressing = true;
      this.apiUye.updateMembership(this.membership.config._id, this.membership._id, data)
        .then(this.onUpdateSucceed, this.onUpdateFail)
        .finally(() => this.progressing = false);
    };
    this.onUpdateSucceed = () => {
      this.appContextInvalidator();
    };
    this.onUpdateFail = (error) => {
      this.error = error;
    };
  }
  render() {
    const { membership, progressing } = this;
    if (!membership) {
      return null;
    }
    return (h(Host, { class: "d-block" }, h("doldurma-form", { fields: membership.config.fields
        .filter(field => field.id !== 'user') // remove the user from the form
        .map(field => (BaseField.decode(Object.assign(Object.assign({}, field), { value: membership[field.id] })))), onSubmit: this.onSubmit, submitButtonLabel: "Save", progressing: progressing })));
  }
};
injectContext(DvnMemberInfoForm);

export { DvnMemberInfoForm as dvn_member_info_form };
