import { jsx as e, jsxs as O, Fragment as Y } from "react/jsx-runtime";
import { a as D } from "./index.CfQlFjZU.js";
import { l as R } from "./index.C1ZfizMq.js";
import { n as F } from "./index.B0wX8xO7.js";
import { P as z } from "./PageHeader.BwFpx_pz.js";
import { S as p } from "./shared.EdGf6tcG.js";
import "react";
import { O as V } from "./Onboarding.BDRBUM0D.js";
import { B as u, a as f } from "./Button.CpTwUWVr.js";
import { F as A } from "./form.BJJLcx4p.js";
import { a as T } from "./TextInput.63vMRxAK.js";
import { u as x } from "./useInputValidation.BmDVJuIZ.js";
import { T as E } from "./Typography.a1p6WNM8.js";
const K = "creator_contentContainerStretch_0Qx32", j = "creator_mainContentContainer_JTyQX", L = "creator_formContainer_0NtYm", M = "creator_sectionFormContainer_sidqY", Q = "creator_inlineButton_8tV62", U = "creator_divider_YVXd6", X = "creator_signupContainer_VOPus", h = { contentContainerStretch: K, mainContentContainer: j, formContainer: L, sectionFormContainer: M, inlineButton: Q, divider: U, signupContainer: X };
function k({
  loading: t,
  disabled: i,
  options: n,
  email: s = "",
  invite: m,
  password: v = "",
  emailProcessor: C = () => {
  },
  passwordProcessor: g,
  shouldRemoveForm: S,
  forgotPasswordUrl: N,
  signupUrl: l,
  title: b = "Welcome back",
  onSubmit: y
}) {
  const c = !!i || !!t, d = n && n.length > 0, a = x(C, {
    value: s,
    readOnly: !!s
  }), o = x(v, g);
  function P(r) {
    r.preventDefault(), y?.({
      email: a.value,
      password: o.value
    });
  }
  function _(r) {
    return `method-${r}`;
  }
  return {
    disabled: i || !a.value || !!a.isError || !o.value || !!t,
    disabledInputs: c,
    enabledSignup: !!(!m && l),
    forgotPasswordUrl: N,
    signupUrl: l,
    emailProps: a,
    hasOptions: d,
    invite: m,
    isNativeForm: !S,
    loading: t,
    options: n,
    passwordProps: o,
    onSubmit: P,
    formContainerClassName: h.sectionFormContainer,
    inlineButtonClassName: h.inlineButton,
    dividerClassName: h.divider,
    signupContainerClassName: h.signupContainer,
    methodKey: _,
    title: b
  };
}
function q({
  title: t,
  disabled: i,
  disabledInputs: n,
  enabledSignup: s,
  forgotPasswordUrl: m,
  signupUrl: v,
  emailProps: C,
  hasOptions: g,
  isNativeForm: S,
  loading: N,
  options: l,
  onSubmit: b,
  passwordProps: y,
  formContainerClassName: c,
  inlineButtonClassName: d,
  dividerClassName: a,
  signupContainerClassName: o,
  methodKey: P
}) {
  return /* @__PURE__ */ e(V, { children: /* @__PURE__ */ O(
    A,
    {
      isNative: S,
      formProps: { className: c, onSubmit: b },
      divProps: { className: c },
      children: [
        /* @__PURE__ */ e(z, { title: t, height: "auto" }),
        /* @__PURE__ */ e(
          T,
          {
            label: "Email",
            name: "email",
            type: "email",
            isDisabled: n,
            ...C
          }
        ),
        /* @__PURE__ */ e(
          T,
          {
            label: "Password",
            name: "password",
            type: "password",
            isDisabled: n,
            ...y
          }
        ),
        /* @__PURE__ */ e(
          u,
          {
            label: "Forgot Password?",
            size: "xsmall",
            className: d,
            type: f.LINK,
            semantic: p.SECONDARY,
            href: m
          }
        ),
        /* @__PURE__ */ e(
          u,
          {
            label: "Sign in",
            size: "full",
            type: f.SUBMIT,
            semantic: p.PRIMARY,
            name: "intent",
            value: "signin",
            loading: N,
            disabled: i
          }
        ),
        /* @__PURE__ */ e(
          F,
          {
            value: g,
            then: /* @__PURE__ */ O(Y, { children: [
              /* @__PURE__ */ e("div", { className: a, children: "OR" }),
              /* @__PURE__ */ e(
                R,
                {
                  values: l,
                  layout: ({ icon: _, label: w, onClick: B, semantic: r = p.SECONDARY }, I) => /* @__PURE__ */ e(
                    u,
                    {
                      label: w,
                      size: "full",
                      type: f.BUTTON,
                      prefixIcon: _,
                      onClick: B,
                      semantic: r
                    },
                    P(I)
                  )
                }
              )
            ] })
          }
        ),
        /* @__PURE__ */ e(
          F,
          {
            value: s,
            then: /* @__PURE__ */ O("div", { className: o, children: [
              /* @__PURE__ */ e(E, { variant: "body", size: "medium", children: "Don't have an account?" }),
              /* @__PURE__ */ e(
                u,
                {
                  label: "Sign Up",
                  size: "small",
                  className: d,
                  type: f.LINK,
                  semantic: p.SECONDARY,
                  href: v
                }
              )
            ] })
          }
        )
      ]
    }
  ) });
}
const se = D(q, k);
export {
  se as S,
  q as a,
  k as u
};
