import { defineComponent as y, defineAsyncComponent as g, computed as m, reactive as C, resolveComponent as E, openBlock as p, createElementBlock as _, createElementVNode as f, toDisplayString as k, Fragment as B, renderList as V, createBlock as $, resolveDynamicComponent as q, createVNode as A } from "vue";
import { j as D, E as F, i as R, k as j } from "./index-40f191fc.mjs";
import "pinia";
const I = y({
  name: "CdsAuthRecover",
  props: {
    disabled: { type: Boolean, default: !1 },
    lang: {
      type: Object,
      default: {
        authEmail: {
          title: "Напомнить пароль по email",
          submit: "Отправить"
        }
      }
    }
  },
  emits: ["update", "recover"],
  components: {
    CdsButton: D,
    CdsInputText: g(() => import("./InputText-a41d7464.mjs"))
  },
  setup(e, { emit: a }) {
    const v = m(() => e.lang.authEmail), b = m(() => e.disabled), d = C([
      {
        data: {
          icon: F,
          validate: R,
          iconEnd: !1,
          label: "Email",
          errorMessage: "text error Message",
          placeholder: "Ваш email",
          type: "email"
        },
        meta: { autocomplete: null },
        required: !0,
        autofocus: !0,
        name: "email",
        value: "",
        component: "CdsInputText"
      }
    ]), n = C({
      email: { value: "", valid: !1 }
    }), i = m(() => {
      let o = [];
      for (let l in n)
        o = [...o, n[l].valid];
      return o.every((l) => l);
    });
    return {
      disabled: b,
      label: v,
      fields: d,
      valid: i,
      formData: n,
      updateValue: (o) => {
        const { name: l, valid: u, value: r } = o;
        if (!l)
          return;
        const c = d.find((h) => h.name === l);
        c && (c.value = r, n[c.name] = { value: r, valid: u }), u && a("update", { name: l, valid: u, value: r });
      },
      send: () => a("recover", n)
    };
  }
}), M = { class: "cds-auth__body" }, N = ["textContent"], T = { class: "cds-auth__form" }, z = { class: "cds-auth__action" };
function L(e, a, v, b, d, n) {
  const i = E("CdsButton");
  return p(), _("div", M, [
    f("div", {
      class: "cds-auth__title",
      textContent: k(e.label.title)
    }, null, 8, N),
    f("div", T, [
      (p(!0), _(B, null, V(e.fields, (t) => (p(), $(q(t.component), {
        key: t.name,
        data: t.data,
        meta: t.meta,
        value: t.value,
        required: t.required,
        name: t.name,
        autofocus: t.autofocus,
        disabled: e.disabled,
        inline: !0,
        onFieldUpdate: a[0] || (a[0] = (s) => e.updateValue(s)),
        onFieldChange: a[1] || (a[1] = (s) => e.updateValue(s))
      }, null, 40, ["data", "meta", "value", "required", "name", "autofocus", "disabled"]))), 128))
    ]),
    f("div", z, [
      A(i, {
        onClick: e.send,
        type: "submit",
        color: "success",
        fill: !0,
        size: "large",
        label: e.label.submit,
        disabled: !e.valid || e.disabled
      }, null, 8, ["onClick", "label", "disabled"])
    ])
  ]);
}
const w = /* @__PURE__ */ j(I, [["render", L]]);
export {
  w as default
};
//# sourceMappingURL=AuthRecover-2bf8281d.mjs.map
