import { defineComponent as w, computed as r, reactive as u, openBlock as c, createElementBlock as f, createElementVNode as p, toDisplayString as C, unref as s, Fragment as q, renderList as x, createBlock as D, resolveDynamicComponent as L, createVNode as B } from "vue";
import { E as H, i as z, p as I, j as V } from "./index-db7a2498.mjs";
import "pinia";
const N = { class: "cds-auth__body" }, R = ["textContent"], T = { class: "cds-auth__form" }, j = { class: "cds-auth__action" }, S = /* @__PURE__ */ w({
  __name: "AuthEmail",
  props: {
    disabled: { type: Boolean, default: !1 },
    lang: { default: {
      title: "Войти по email",
      submit: "Войти",
      emailLabel: "Email",
      emailHint: "name@company.org",
      passwordLabel: "Пароль",
      passwordHint: "оЧеньсЛожНыйПароЛь"
    } }
  },
  emits: ["update", "auth-email"],
  setup(_, { emit: v }) {
    const m = _, t = r(() => m.lang), o = r(() => m.disabled), h = u({
      disabled: o.value,
      card: !1,
      inline: !1,
      iconEnd: !0,
      size: "large"
    }), d = u([
      {
        icon: H,
        validate: z,
        iconEnd: !1,
        label: t.value.emailLabel,
        hint: t.value.emailHint,
        params: { autocomplete: "email", type: "email" },
        required: !0,
        key: "email",
        value: "",
        component: "CdsInputText"
      },
      {
        icon: null,
        validate: I,
        iconEnd: !1,
        label: t.value.passwordLabel,
        hint: t.value.passwordHint,
        type: null,
        params: { autocomplete: "current-password" },
        required: !0,
        key: "password",
        value: "",
        component: "CdsInputPassword"
      }
    ]), i = u({
      email: { value: "", valid: !1 },
      password: { value: "", valid: !1 }
    }), y = r(() => {
      let n = [];
      for (let a in i)
        n = [...n, i[a].valid];
      return n.every((a) => a);
    }), b = (n) => {
      const { key: a, valid: e, value: l } = n;
      if (!a)
        return;
      const k = d.findIndex((E) => E.key === a);
      d[k].value = l, i[a] = { value: l, valid: e }, e && v("update", { key: a, valid: e, value: l });
    }, g = () => v("auth-email", i);
    return (n, a) => (c(), f("div", N, [
      p("div", {
        class: "cds-auth__title",
        textContent: C(s(t).title)
      }, null, 8, R),
      p("div", T, [
        (c(!0), f(q, null, x(d, (e) => (c(), D(L(e.component), {
          base: {
            key: e.key,
            autocapitalizationType: !1,
            hint: e.hint,
            icon: e.icon,
            label: e.label,
            required: e.required,
            validate: e.validate,
            value: e.value
          },
          decorations: h,
          disabled: s(o),
          hint: e.hint,
          icon: e.icon,
          iconEnd: !0,
          inline: !1,
          label: e.label,
          name: e.name,
          params: e.params,
          required: e.required,
          validate: e.validate,
          value: e.value,
          onChangeData: a[0] || (a[0] = (l) => b(l)),
          onUpdateData: a[1] || (a[1] = (l) => b(l))
        }, null, 40, ["base", "decorations", "disabled", "hint", "icon", "label", "name", "params", "required", "validate", "value"]))), 256))
      ]),
      p("div", j, [
        B(V, {
          disabled: !s(y) || s(o),
          fill: !0,
          label: s(t).submit,
          color: "success",
          size: "large",
          type: "submit",
          onClick: g
        }, null, 8, ["disabled", "label"])
      ])
    ]));
  }
});
export {
  S as default
};
//# sourceMappingURL=AuthEmail-ade8270f.mjs.map
