import { localStorageProp as le, prop as U, Use as q, html as l, attr as t, on as E, When as _, coalesce as g, Ensure as W, computedOf as b, Fragment as z, bind as me, ForEach as ue, Value as oe, OneOfValue as pe } from "@tempots/dom";
import { i as te, S as T } from "./stack-BJgsPJ9A.js";
import { t as de, u as G, a as ne, b as A } from "./use-form-BSvvERhX.js";
import { o as H, s as C, b as F, M as he } from "./modal-Dkje8L_l.js";
import { d as f, A as x } from "./translations-jUYta1_1.js";
import { P as O, E as j, N as X } from "./notice-BmkckDsD.js";
import { B as M } from "./input-container-DhUiLmXE.js";
import { T as ge } from "./text-input-BZmAB3_o.js";
import { I as fe } from "./translations-BGblCUBj.js";
import { classes as be } from "@tempots/ui";
const Y = {
  google: { name: "Google", icon: "logos:google-icon", color: "#4285f4" },
  github: { name: "GitHub", icon: "logos:github-icon", color: "#333" },
  apple: { name: "Apple", icon: "logos:apple", color: "#000" },
  facebook: { name: "Facebook", icon: "logos:facebook", color: "#1877f2" },
  twitter: { name: "Twitter", icon: "logos:twitter", color: "#1da1f2" },
  microsoft: {
    name: "Microsoft",
    icon: "logos:microsoft-icon",
    color: "#00a4ef"
  },
  discord: { name: "Discord", icon: "logos:discord-icon", color: "#5865f2" },
  linkedin: { name: "LinkedIn", icon: "logos:linkedin-icon", color: "#0077b5" },
  instagram: {
    name: "Instagram",
    icon: "logos:instagram-icon",
    color: "#e4405f"
  },
  tiktok: { name: "TikTok", icon: "logos:tiktok-icon", color: "#000" },
  snapchat: { name: "Snapchat", icon: "logos:snapchat-icon", color: "#fffc00" },
  reddit: { name: "Reddit", icon: "logos:reddit-icon", color: "#ff4500" },
  pinterest: {
    name: "Pinterest",
    icon: "logos:pinterest-icon",
    color: "#bd081c"
  },
  twitch: { name: "Twitch", icon: "logos:twitch", color: "#9146ff" },
  steam: { name: "Steam", icon: "logos:steam-icon", color: "#000" },
  epic: {
    name: "Epic Games",
    icon: "simple-icons:epicgames",
    color: "#313131"
  },
  playstation: {
    name: "PlayStation",
    icon: "logos:playstation-icon",
    color: "#003791"
  },
  xbox: { name: "Xbox", icon: "logos:xbox-icon", color: "#107c10" },
  whatsapp: { name: "WhatsApp", icon: "logos:whatsapp-icon", color: "#25d366" },
  wechat: { name: "WeChat", icon: "logos:wechat-icon", color: "#1aad19" },
  amazon: { name: "Amazon", icon: "logos:amazon-icon", color: "#ff9900" },
  yahoo: { name: "Yahoo", icon: "logos:yahoo-icon", color: "#720e9e" },
  paypal: { name: "PayPal", icon: "logos:paypal", color: "#0070ba" },
  x: { name: "X", icon: "simple-icons:x", color: "#000" }
};
function we(e) {
  return Y[e]?.name || e;
}
function Re(e) {
  return Y[e]?.icon || "mdi:account";
}
function Ue(e) {
  return Y[e]?.color || "#666";
}
function Me(e, o = "Continue with {provider}") {
  return o.replace("{provider}", we(e));
}
const $ = {
  minLength: 8,
  requireUppercase: !0,
  requireLowercase: !0,
  requireNumbers: !0,
  requireSymbols: !1
};
function Ne(e) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
}
function _e(e = 32) {
  const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  let s = "";
  for (let a = 0; a < e; a++)
    s += o.charAt(Math.floor(Math.random() * o.length));
  return s;
}
function Ve(e, o, s, a = [], c = {}) {
  const r = {
    google: "https://accounts.google.com/oauth/authorize",
    github: "https://github.com/login/oauth/authorize",
    apple: "https://appleid.apple.com/auth/authorize",
    facebook: "https://www.facebook.com/v18.0/dialog/oauth",
    twitter: "https://twitter.com/i/oauth2/authorize",
    microsoft: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
    discord: "https://discord.com/api/oauth2/authorize",
    linkedin: "https://www.linkedin.com/oauth/v2/authorization",
    instagram: "https://api.instagram.com/oauth/authorize",
    tiktok: "https://www.tiktok.com/v2/auth/authorize",
    snapchat: "https://accounts.snapchat.com/accounts/oauth2/authorize",
    reddit: "https://www.reddit.com/api/v1/authorize",
    pinterest: "https://api.pinterest.com/oauth/",
    twitch: "https://id.twitch.tv/oauth2/authorize",
    steam: "https://steamcommunity.com/oauth/authorize",
    epic: "https://auth.epicgames.com/authorize",
    playstation: "https://auth.api.sonyentertainmentnetwork.com/oauth/authorize",
    xbox: "https://login.live.com/oauth20_authorize.srf",
    whatsapp: "https://web.whatsapp.com/oauth/authorize",
    wechat: "https://open.weixin.qq.com/connect/qrconnect",
    amazon: "https://www.amazon.com/ap/oa",
    yahoo: "https://api.login.yahoo.com/oauth2/request_auth",
    paypal: "https://www.paypal.com/signin/authorize",
    x: "https://api.twitter.com/oauth2/authorize"
  }, u = {
    google: ["openid", "email", "profile"],
    github: ["user:email"],
    apple: ["email", "name"],
    facebook: ["email"],
    twitter: ["users.read"],
    microsoft: ["openid", "email", "profile"],
    discord: ["identify", "email"],
    linkedin: ["r_liteprofile", "r_emailaddress"],
    instagram: ["user_profile", "user_media"],
    tiktok: ["user.info.basic", "user.external.id"],
    snapchat: ["user.info.basic", "user.external.id"],
    reddit: ["identity", "email"],
    pinterest: ["read_public", "read_relationships"],
    twitch: ["openid", "email", "profile"],
    steam: ["openid", "email", "profile"],
    epic: ["openid", "email", "profile"],
    playstation: ["openid", "email", "profile"],
    xbox: ["openid", "email", "profile"],
    whatsapp: ["openid", "email", "profile"],
    wechat: ["openid", "email", "profile"],
    amazon: ["openid", "email", "profile"],
    yahoo: ["openid", "email", "profile"],
    paypal: ["openid", "email", "profile"],
    x: ["openid", "email", "profile"]
  }, n = r[e];
  if (!n)
    throw new Error(`Unsupported provider: ${e}`);
  const m = a.length > 0 ? a : u[e], i = _e(), h = new URLSearchParams({
    client_id: o,
    redirect_uri: s,
    scope: m.join(" "),
    state: i,
    response_type: "code",
    ...c
  });
  return `${n}?${h.toString()}`;
}
function De(e, o, s, a) {
  const c = window.open(
    e,
    `${o}_login`,
    "width=500,height=600,scrollbars=yes,resizable=yes"
  );
  if (!c) {
    a?.(new Error("Failed to open popup window"));
    return;
  }
  const r = setInterval(() => {
    c.closed && (clearInterval(r), a?.(new Error("Login cancelled")));
  }, 1e3), u = (n) => {
    n.origin === window.location.origin && (n.data.type === "SOCIAL_LOGIN_SUCCESS" ? (clearInterval(r), c.close(), window.removeEventListener("message", u), s?.(n.data.result)) : n.data.type === "SOCIAL_LOGIN_ERROR" && (clearInterval(r), c.close(), window.removeEventListener("message", u), a?.(new Error(n.data.error))));
  };
  window.addEventListener("message", u);
}
function Fe(e) {
  return e instanceof Error ? e.message : typeof e == "string" ? e : e && typeof e == "object" && "message" in e ? String(e.message) : "An unexpected error occurred";
}
function Oe() {
  return typeof window < "u" && typeof document < "u";
}
function Z({
  task: e,
  message: o,
  onStart: s,
  onEnd: a
}) {
  return async (c) => {
    s?.();
    const r = await de({
      task: e != null ? () => e(c) : async () => null,
      errorMessage: o,
      errorPath: ["root"],
      validation: (u) => u != null ? te.invalid({ message: u }) : te.valid
    });
    return a?.(), r;
  };
}
function J(e = $, o) {
  const s = o ?? f;
  let a = C();
  return e.minLength && (a = a.min(
    e.minLength,
    (s.passwordMinLength ?? f.passwordMinLength)(
      e.minLength
    )
  )), e.requireUppercase && (a = a.regex(
    /[A-Z]/,
    s.passwordRequireUppercase ?? f.passwordRequireUppercase
  )), e.requireLowercase && (a = a.regex(
    /[a-z]/,
    s.passwordRequireLowercase ?? f.passwordRequireLowercase
  )), e.requireNumbers && (a = a.regex(
    /[0-9]/,
    s.passwordRequireNumber ?? f.passwordRequireNumber
  )), e.requireSymbols && (a = a.regex(
    /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/,
    s.passwordRequireSpecialChar ?? f.passwordRequireSpecialChar
  )), e.customValidation && (a = a.refine((c) => e.customValidation(c))), a;
}
function N(e) {
  const o = e ?? f;
  return C().min(1, o.emailRequired ?? f.emailRequired).email(o.invalidEmail ?? f.invalidEmail);
}
const re = N();
function K(e, o) {
  const s = o ?? f, a = e ? J(e, o) : C().refine(
    (c) => c.length > 0 ? null : s.passwordRequired ?? f.passwordRequired
  );
  return H({
    email: N(o),
    password: a,
    rememberMe: F().default(!1)
  }).schema();
}
function Q(e = $, o, s) {
  const a = s ?? f, c = J(e, s), r = o?.showNameField !== !1, u = o?.showConfirmPassword !== !1, n = o?.showAcceptTermsAndConditions !== !1, m = {
    name: r ? C().min(1, a.nameRequired ?? f.nameRequired).optional() : C().optional(),
    email: N(s),
    password: c,
    // Always require confirmPassword as string to match SignUpData interface
    // When not shown, it should accept any value (including empty string)
    confirmPassword: u ? C().min(
      1,
      a.confirmPasswordRequired ?? f.confirmPasswordRequired
    ) : C(),
    // Accept any string value when not shown
    acceptTerms: n ? F().refine(
      (h) => h === !0,
      a.acceptTermsRequired ?? f.acceptTermsRequired
    ) : F().default(!0)
    // Default to true when not shown
  }, i = H(m);
  return u ? i.refine(
    (h) => h.password === h.confirmPassword ? null : a.passwordsDoNotMatch ?? f.passwordsDoNotMatch,
    { path: ["confirmPassword"] }
  ).schema() : i.schema();
}
const ie = H({
  email: re
}).schema(), We = K(), Ge = Q(), He = {
  signIn: K,
  signUp: Q,
  resetPassword: () => ie
};
function je(e, o) {
  const s = o ?? f, c = (o ? N(o) : re).validate(e);
  return c.success ? null : c.errors[0]?.message || (s.invalidEmailAddress ?? f.invalidEmailAddress);
}
function Xe(e, o = $, s) {
  const a = s ?? f, r = J(o, s).validate(e);
  return r.success ? null : r.errors[0]?.message || (a.invalidPassword ?? f.invalidPassword);
}
function ee(e, o = $) {
  const s = {
    length: e.length >= (o.minLength || 8),
    uppercase: /[A-Z]/.test(e),
    lowercase: /[a-z]/.test(e),
    numbers: /[0-9]/.test(e),
    symbols: /[!@#$%^&*()_+\-=[\]{};':"\\|,.<>/?]/.test(e),
    custom: o.customValidation ? o.customValidation(e) === null : e.length > 0
    // For consistency, fail if password is empty
  }, a = [
    !0,
    // length is always enabled
    o.requireUppercase,
    o.requireLowercase,
    o.requireNumbers,
    o.requireSymbols,
    !!o.customValidation
  ].filter(Boolean).length, c = [
    s.length,
    o.requireUppercase ? s.uppercase : null,
    o.requireLowercase ? s.lowercase : null,
    o.requireNumbers ? s.numbers : null,
    o.requireSymbols ? s.symbols : null,
    o.customValidation ? s.custom : null
  ].filter((n) => n === !0).length, r = a > 0 ? Math.round(c / a * 100) : 0;
  let u;
  return r < 40 ? u = "weak" : r < 60 ? u = "fair" : r < 80 ? u = "good" : u = "strong", { strength: u, score: r, checks: s };
}
const ce = () => le({
  key: "bui_auth_email",
  defaultValue: null
});
function Le({
  onSignIn: e,
  passwordRules: o,
  labels: s,
  showRememberMe: a
}) {
  const c = U(!1), r = ce(), u = K(o), n = G({
    schema: u,
    onSubmit: Z({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        c.set(!0), n.controller.disable();
      },
      onEnd: () => {
        c.set(!1), n.controller.enable();
      }
    }),
    initialValue: {
      email: "",
      password: ""
    }
  }), { controller: m, submit: i } = n;
  c.on(m.setDisabled);
  const h = m.field("email"), L = m.field("password");
  return r.on((v) => {
    v != null && h.change(v);
  }), h.signal.on((v) => {
    r.value != null && (r.value = v);
  }), q(
    x,
    (v) => (
      // Email/Password form
      l.form(
        t.class("bc-auth-form__form"),
        E.submit(i),
        T(
          t.class("bc-auth-form__fields"),
          W(
            m.error,
            (k) => X(
              { variant: "danger", tone: "prominent", role: "alert" },
              l.div(k)
            )
          ),
          // Email field
          A(j, {
            controller: h,
            label: g(s?.emailLabel, v.$.emailLabel)
          }),
          // Password field
          A(O, {
            controller: L,
            label: g(s?.passwordLabel, v.$.passwordLabel)
          }),
          // Remember me checkbox
          _(
            a ?? !0,
            () => l.div(
              t.class("bc-auth-form__remember-me"),
              l.label(
                t.class("bc-auth-form__checkbox-label"),
                ne({
                  value: r.map((k) => k != null),
                  after: l.span(
                    g(s?.rememberMeLabel, v.$.rememberMeLabel)
                  ),
                  onChange: (k) => {
                    k ? r.value = h.signal.value ?? "" : r.value = null;
                  }
                })
              )
            )
          )
        ),
        // Submit button
        M(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: c,
            disabled: m.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          g(s?.signInButton, v.$.signInButton)
        )
      )
    )
  );
}
function ve({
  password: e,
  rules: o = $,
  showLabel: s = !0,
  className: a
}) {
  const c = b(e)((i) => !i || i.length === 0 ? {
    strength: "weak",
    score: 0,
    checks: {
      length: !1,
      uppercase: !1,
      lowercase: !1,
      numbers: !1,
      symbols: !1,
      custom: !1
    }
  } : ee(i, o)), r = c.map((i) => i.strength), u = c.map((i) => i.score), n = c.map((i) => i.checks), m = b(
    r,
    a
  )((i, h) => [
    "bc-password-strength",
    `bc-password-strength--${i}`,
    h
  ].filter(Boolean).join(" "));
  return l.div(
    t.class(m),
    // Strength bar
    l.div(
      t.class("bc-password-strength__bar"),
      l.div(
        t.class("bc-password-strength__fill"),
        t.style(u.map((i) => `width: ${i}%`))
      )
    ),
    // Strength label (optional)
    _(
      s,
      () => q(
        x,
        (i) => l.div(
          t.class("bc-password-strength__label"),
          b(
            r,
            i
          )((h, L) => {
            switch (h) {
              case "weak":
                return L.passwordStrengthWeak;
              case "fair":
                return L.passwordStrengthFair;
              case "good":
                return L.passwordStrengthGood;
              case "strong":
                return L.passwordStrengthStrong;
              default:
                return L.passwordStrengthWeak;
            }
          })
        )
      )
    ),
    // Requirements checklist
    l.div(
      t.class("bc-password-strength__requirements"),
      // Length requirement
      _(
        o.minLength !== void 0,
        () => l.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            b(n)(
              (i) => i.length ? "bc-password-strength__requirement--met" : ""
            )
          ),
          l.span(
            t.class("bc-password-strength__requirement-icon"),
            b(n)((i) => i.length ? "✓" : "○")
          ),
          l.span(
            t.class("bc-password-strength__requirement-text"),
            `At least ${o.minLength} characters`
          )
        )
      ),
      // Uppercase requirement
      _(
        o.requireUppercase === !0,
        () => l.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            b(n)(
              (i) => i.uppercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          l.span(
            t.class("bc-password-strength__requirement-icon"),
            b(n)((i) => i.uppercase ? "✓" : "○")
          ),
          l.span(
            t.class("bc-password-strength__requirement-text"),
            "One uppercase letter"
          )
        )
      ),
      // Lowercase requirement
      _(
        o.requireLowercase === !0,
        () => l.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            b(n)(
              (i) => i.lowercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          l.span(
            t.class("bc-password-strength__requirement-icon"),
            b(n)((i) => i.lowercase ? "✓" : "○")
          ),
          l.span(
            t.class("bc-password-strength__requirement-text"),
            "One lowercase letter"
          )
        )
      ),
      // Numbers requirement
      _(
        o.requireNumbers === !0,
        () => l.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            b(n)(
              (i) => i.numbers ? "bc-password-strength__requirement--met" : ""
            )
          ),
          l.span(
            t.class("bc-password-strength__requirement-icon"),
            b(n)((i) => i.numbers ? "✓" : "○")
          ),
          l.span(
            t.class("bc-password-strength__requirement-text"),
            "One number"
          )
        )
      ),
      // Symbols requirement
      _(
        o.requireSymbols === !0,
        () => l.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            b(n)(
              (i) => i.symbols ? "bc-password-strength__requirement--met" : ""
            )
          ),
          l.span(
            t.class("bc-password-strength__requirement-icon"),
            b(n)((i) => i.symbols ? "✓" : "○")
          ),
          l.span(
            t.class("bc-password-strength__requirement-text"),
            "One special character"
          )
        )
      )
    )
  );
}
function Ye({
  password: e,
  rules: o = $,
  className: s
}) {
  const a = b(e)((n) => !n || n.length === 0 ? { strength: "weak", score: 0 } : ee(n, o)), c = a.map((n) => n.strength), r = a.map((n) => n.score), u = b(
    c,
    s
  )((n, m) => [
    "bc-password-strength-bar",
    `bc-password-strength-bar--${n}`,
    m
  ].filter(Boolean).join(" "));
  return l.div(
    t.class(u),
    l.div(
      t.class("bc-password-strength-bar__fill"),
      t.style(r.map((n) => `width: ${n}%`))
    )
  );
}
function Ze({
  password: e,
  rules: o = $,
  className: s
}) {
  const a = b(e)((r) => !r || r.length === 0 ? "weak" : ee(r, o).strength), c = b(
    a,
    s
  )((r, u) => [
    "bc-password-strength-text",
    `bc-password-strength-text--${r}`,
    u
  ].filter(Boolean).join(" "));
  return z(
    q(
      x,
      (r) => l.span(
        t.class(c),
        b(
          a,
          r
        )((u, n) => {
          switch (u) {
            case "weak":
              return n.passwordStrengthWeak;
            case "fair":
              return n.passwordStrengthFair;
            case "good":
              return n.passwordStrengthGood;
            case "strong":
              return n.passwordStrengthStrong;
            default:
              return n.passwordStrengthWeak;
          }
        })
      )
    )
  );
}
function ke({
  passwordRules: e,
  labels: o,
  initialEmail: s,
  initialName: a,
  showPasswordStrength: c,
  onSignUp: r,
  showNameField: u,
  showConfirmPassword: n,
  showAcceptTermsAndConditions: m,
  termsAndConditions: i
}) {
  const h = U(!1), L = e || $, v = Q(L, {
    showNameField: u !== !1,
    showConfirmPassword: n !== !1,
    showAcceptTermsAndConditions: m !== !1
  }), k = G({
    schema: v,
    onSubmit: Z({
      task: r != null ? (w) => r({
        email: w.email,
        password: w.password,
        name: w.name,
        acceptTerms: w.acceptTerms
      }) : void 0,
      message: "Reset password failed",
      onStart: () => {
        h.set(!0), k.controller.disable();
      },
      onEnd: () => {
        h.set(!1), k.controller.enable();
      }
    }),
    initialValue: {
      name: a ?? "",
      email: s ?? "",
      password: "",
      confirmPassword: "",
      acceptTerms: !1
    }
  }), { controller: S, submit: V } = k;
  h.on(S.setDisabled);
  const B = S.field("name"), P = S.field("email"), R = S.field("password"), D = S.field("confirmPassword"), I = S.field("acceptTerms");
  return q(
    x,
    (w) => (
      // Registration form
      l.form(
        t.class("bc-auth-form__form"),
        E.submit(V),
        T(
          t.class("bc-auth-form__fields"),
          W(
            S.error,
            (y) => X(
              { variant: "danger", tone: "prominent", role: "alert" },
              l.div(y)
            )
          ),
          // Name field (optional)
          _(
            u !== !1,
            () => A(ge, {
              controller: B.transform(
                (y) => y ?? "",
                (y) => y === "" ? void 0 : y
              ),
              label: g(o?.nameLabel, w.$.nameLabel)
            })
          ),
          // Email field
          A(j, {
            controller: P,
            label: g(o?.emailLabel, w.$.emailLabel)
          }),
          // Password field
          A(O, {
            controller: R,
            label: g(o?.passwordLabel, w.$.passwordLabel)
          }),
          // Password strength indicator
          _(
            c ?? !1,
            () => ve({
              password: R.signal,
              rules: L,
              showLabel: !0
            })
          ),
          // Confirm password field
          _(
            n ?? !1,
            () => A(O, {
              controller: D,
              label: g(
                o?.confirmPasswordLabel,
                w.$.confirmPasswordLabel
              )
            })
          ),
          // Terms acceptance checkbox
          _(
            m ?? !1,
            () => l.div(
              t.class("bc-auth-form__terms"),
              l.label(
                t.class("bc-auth-form__checkbox-label"),
                ne({
                  value: I.signal.map((y) => y ?? !1),
                  onChange: (y) => I.change(y)
                }),
                l.span(
                  i || g(o?.acceptTermsLabel, w.$.acceptTermsLabel)
                )
              ),
              _(
                I.errorVisible,
                () => l.div(
                  t.class("bc-auth-form__field-error"),
                  I.error.map((y) => y || "")
                )
              )
            )
          )
        ),
        // Submit button
        M(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: h,
            disabled: S.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          g(o?.signUpButton, w.$.signUpButton)
        )
      )
    )
  );
}
function ye({
  onResetPassword: e,
  labels: o = {}
}) {
  const s = ce(), a = U(!1), c = G({
    schema: ie,
    onSubmit: Z({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        a.set(!0), c.controller.disable();
      },
      onEnd: () => {
        a.set(!1), c.controller.enable();
      }
    }),
    initialValue: {
      email: ""
    }
  }), { controller: r, submit: u } = c;
  a.on(r.setDisabled);
  const n = r.field("email");
  return s.on((m) => {
    m != null && n.change(m);
  }), q(
    x,
    (m) => (
      // Reset password form
      l.form(
        t.class("bc-auth-form__form"),
        W(
          r.error,
          (i) => X(
            { variant: "danger", tone: "prominent", role: "alert" },
            l.div(i)
          )
        ),
        // Description
        l.p(
          t.class("bc-auth-form__description"),
          g(o?.resetPasswordDescription, m.$.resetPasswordDescription)
        ),
        E.submit(u),
        T(
          t.class("bc-auth-form__fields"),
          // Email field
          A(j, {
            controller: n,
            label: g(o?.emailLabel, m.$.emailLabel)
          })
        ),
        // Submit button
        M(
          {
            loading: a,
            type: "submit",
            variant: "filled",
            color: "primary",
            disabled: r.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          g(o?.resetPasswordButton, m.$.resetPasswordButton)
        )
      )
    )
  );
}
function d({
  provider: e,
  onClick: o,
  size: s = "md",
  name: a,
  icon: c,
  color: r,
  flow: u,
  labels: n
}) {
  return M(
    {
      type: "button",
      variant: "filled",
      size: s,
      color: r,
      onClick: async () => {
        if (o)
          try {
            u === "popup" ? await o() : await o();
          } catch (i) {
            console.error(
              `Social login error for ${e} (${u || "redirect"} flow):`,
              i
            );
          }
      },
      roundedness: "full"
    },
    t.class("bc-social-login-button"),
    t.class(
      b(e)((i) => `bc-social-login-button--${i}`)
    ),
    l.span(
      t.class("bc-social-login-button__inner"),
      l.span(
        t.class("bc-social-login-button__icon"),
        fe({ icon: c, size: s }, t.class("bc-social-login-button__icon-inner"))
      ),
      q(
        x,
        (i) => l.span(
          t.class("bc-social-login-button__label"),
          me(
            g(n?.continueWithProvider, i.$.continueWithProvider)
          )(a)
        )
      )
    )
  );
}
function Se({
  providers: e,
  onProviderClick: o,
  size: s = "md",
  className: a
}) {
  return T(
    t.class("bc-social-login-buttons"),
    t.class(a),
    ue(
      e,
      (c) => d({
        provider: c.$.provider,
        flow: c.$.flow,
        color: c.map(
          ({ provider: r }) => p[r].color
        ),
        name: c.map(({ provider: r }) => p[r].name),
        icon: c.map(({ provider: r }) => p[r].icon),
        onClick: async () => {
          o && await o(c.$.provider.value);
        },
        size: s
      })
    )
  );
}
const p = {
  // Core
  google: {
    name: "Google",
    icon: "logos:google-icon",
    color: "red"
  },
  github: {
    name: "GitHub",
    icon: "logos:github-icon",
    color: "black"
  },
  apple: {
    name: "Apple",
    icon: "logos:apple",
    color: "stone"
    // using stone to differentiate from GitHub/X
  },
  facebook: {
    name: "Facebook",
    icon: "logos:facebook",
    color: "blue"
  },
  twitter: {
    name: "Twitter",
    icon: "logos:twitter",
    color: "sky"
  },
  x: {
    name: "X",
    icon: "logos:x",
    color: "zinc"
    // avoids duplicate black
  },
  microsoft: {
    name: "Microsoft",
    icon: "logos:microsoft-icon",
    color: "amber"
  },
  discord: {
    name: "Discord",
    icon: "logos:discord-icon",
    color: "indigo"
  },
  linkedin: {
    name: "LinkedIn",
    icon: "logos:linkedin-icon",
    color: "cyan"
  },
  // Social / Media
  instagram: {
    name: "Instagram",
    icon: "logos:instagram-icon",
    color: "fuchsia"
  },
  tiktok: {
    name: "TikTok",
    icon: "logos:tiktok-icon",
    color: "teal"
  },
  snapchat: {
    name: "Snapchat",
    icon: "simple-icons:snapchat",
    color: "yellow"
  },
  reddit: {
    name: "Reddit",
    icon: "logos:reddit-icon",
    color: "orange"
  },
  pinterest: {
    name: "Pinterest",
    icon: "logos:pinterest",
    color: "rose"
  },
  // Gaming / Entertainment
  twitch: {
    name: "Twitch",
    icon: "logos:twitch",
    color: "purple"
  },
  steam: {
    name: "Steam",
    icon: "logos:steam",
    color: "slate"
  },
  epic: {
    name: "Epic Games",
    icon: "simple-icons:epicgames",
    color: "neutral"
  },
  playstation: {
    name: "PlayStation",
    icon: "simple-icons:playstation",
    color: "violet"
  },
  xbox: {
    name: "Xbox",
    icon: "simple-icons:xbox",
    color: "green"
  },
  // Messaging
  whatsapp: {
    name: "WhatsApp",
    icon: "logos:whatsapp-icon",
    color: "emerald"
  },
  wechat: {
    name: "WeChat",
    icon: "simple-icons:wechat",
    color: "lime"
  },
  // Other Identity
  amazon: {
    name: "Amazon",
    icon: "simple-icons:amazon",
    color: "red"
    // distinct warm tone (not used elsewhere here)
  },
  yahoo: {
    name: "Yahoo",
    icon: "logos:yahoo",
    color: "rose"
    // unique variation for Yahoo
  },
  paypal: {
    name: "PayPal",
    icon: "logos:paypal",
    color: "blue"
    // distinct deep blue tone (not Facebook’s exact blue)
  }
}, Je = (e) => d({
  ...e,
  ...p.google,
  provider: "google"
}), Ke = (e) => d({
  ...e,
  ...p.github,
  provider: "github"
}), Qe = (e) => d({
  ...e,
  ...p.apple,
  provider: "apple"
}), eo = (e) => d({
  ...e,
  ...p.facebook,
  provider: "facebook"
}), oo = (e) => d({
  ...e,
  ...p.x,
  provider: "x"
}), to = (e) => d({
  ...e,
  ...p.twitter,
  provider: "twitter"
}), ao = (e) => d({
  ...e,
  ...p.microsoft,
  provider: "microsoft"
}), so = (e) => d({
  ...e,
  ...p.discord,
  provider: "discord"
}), no = (e) => d({
  ...e,
  ...p.linkedin,
  provider: "linkedin"
}), ro = (e) => d({
  ...e,
  ...p.instagram,
  provider: "instagram"
}), io = (e) => d({
  ...e,
  ...p.tiktok,
  provider: "tiktok"
}), co = (e) => d({
  ...e,
  ...p.snapchat,
  provider: "snapchat"
}), lo = (e) => d({
  ...e,
  ...p.reddit,
  provider: "reddit"
}), mo = (e) => d({
  ...e,
  ...p.pinterest,
  provider: "pinterest"
}), uo = (e) => d({
  ...e,
  ...p.twitch,
  provider: "twitch"
}), po = (e) => d({
  ...e,
  ...p.steam,
  provider: "steam"
}), ho = (e) => d({
  ...e,
  ...p.epic,
  provider: "epic"
}), go = (e) => d({
  ...e,
  ...p.playstation,
  provider: "playstation"
}), fo = (e) => d({
  ...e,
  ...p.xbox,
  provider: "xbox"
}), bo = (e) => d({
  ...e,
  ...p.whatsapp,
  provider: "whatsapp"
}), wo = (e) => d({
  ...e,
  ...p.wechat,
  provider: "wechat"
}), _o = (e) => d({
  ...e,
  ...p.amazon,
  provider: "amazon"
}), Lo = (e) => d({
  ...e,
  ...p.yahoo,
  provider: "yahoo"
}), vo = (e) => d({
  ...e,
  ...p.paypal,
  provider: "paypal"
});
function ae({
  providers: e,
  onSocialLogin: o
}) {
  return T(
    Se({
      providers: e,
      onProviderClick: o
    })
  );
}
function Pe({
  mode: e,
  socialProviders: o,
  initialName: s,
  initialEmail: a,
  passwordRules: c,
  showRememberMe: r,
  showSocialDivider: u,
  showPasswordStrength: n,
  labels: m,
  onSignIn: i,
  onSignUp: h,
  onResetPassword: L,
  onModeChange: v,
  onSocialLogin: k,
  showContainer: S
}, ...V) {
  const B = e != null ? oe.deriveProp(e) : U("signin");
  return B.on((P) => v?.(P)), q(x, (P) => {
    function R() {
      const w = g(m?.hasAccountLink, P.$.hasAccountLink);
      return l.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => B.set("signin")),
        w
      );
    }
    function D() {
      return l.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => B.set("signup")),
        g(m?.noAccountLink, P.$.noAccountLink)
      );
    }
    function I() {
      return l.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => B.set("reset-password")),
        g(m?.forgotPasswordLink, P.$.forgotPasswordLink)
      );
    }
    return l.div(
      be({
        "bc-auth-container": !0,
        "bc-auth-container--styled": oe.map(S ?? !0, (w) => w)
      }),
      t.class(B.map((w) => `bc-auth-container--${w}`)),
      t.class("bc-auth-form"),
      pe(B, {
        signin: () => z(
          l.h2(
            t.class("bc-auth-form__title"),
            g(m?.signInTitle, P.$.signInTitle)
          ),
          o != null ? z(
            ae({
              providers: o,
              onSocialLogin: k
            }),
            _(u ?? !1, se)
          ) : null,
          Le({
            onSignIn: i,
            showRememberMe: r,
            passwordRules: c,
            labels: {
              emailLabel: m?.emailLabel,
              passwordLabel: m?.passwordLabel,
              rememberMeLabel: m?.rememberMeLabel,
              signInButton: m?.signInButton,
              forgotPasswordLink: m?.forgotPasswordLink,
              noAccountLink: m?.noAccountLink
            }
          }),
          T(
            t.class("bc-auth-form__footer"),
            D(),
            I()
          )
        ),
        signup: () => z(
          l.h2(
            t.class("bc-auth-form__title"),
            g(m?.signUpTitle, P.$.signUpTitle)
          ),
          o != null ? z(
            ae({
              providers: o,
              onSocialLogin: k
            }),
            _(u ?? !1, se)
          ) : null,
          ke({
            labels: {
              nameLabel: m?.nameLabel,
              emailLabel: m?.emailLabel,
              passwordLabel: m?.passwordLabel,
              confirmPasswordLabel: m?.confirmPasswordLabel,
              acceptTermsLabel: m?.acceptTermsLabel,
              signUpButton: m?.signUpButton,
              hasAccountLink: m?.hasAccountLink
            },
            initialEmail: a,
            initialName: s,
            onSignUp: h,
            passwordRules: c,
            showPasswordStrength: n
          }),
          T(t.class("bc-auth-form__footer"), R())
        ),
        "reset-password": () => z(
          l.h2(
            t.class("bc-auth-form__title"),
            g(m?.resetPasswordTitle, P.$.resetPasswordTitle)
          ),
          ye({
            labels: {
              backToSignInLink: m?.backToSignInLink,
              emailLabel: m?.emailLabel,
              resetPasswordButton: m?.resetPasswordButton,
              resetPasswordDescription: m?.resetPasswordDescription
            },
            onResetPassword: L
          }),
          T(t.class("bc-auth-form__footer"), R())
        )
      }),
      ...V
    );
  });
}
function ko(e) {
  return he(
    {
      size: "sm",
      dismissable: !0,
      showCloseButton: !0
    },
    (o, s) => e(
      (a) => o({
        body: Pe({ showContainer: !1, ...a }),
        header: q(
          x,
          (c) => g(a.modalTitle, c.$.authenticationTitle)
        )
      })
    )
  );
}
function se({
  labels: e,
  className: o
} = {}) {
  return l.div(
    t.class("bc-auth-divider"),
    t.class(o),
    l.div(t.class("bc-auth-divider__line")),
    q(
      x,
      (s) => l.span(
        t.class("bc-auth-divider__text"),
        g(e?.text, s.$.orDivider)
      )
    ),
    l.div(t.class("bc-auth-divider__line"))
  );
}
export {
  Ue as $,
  Pe as A,
  mo as B,
  uo as C,
  so as D,
  po as E,
  eo as F,
  Je as G,
  ho as H,
  ro as I,
  go as J,
  fo as K,
  no as L,
  ao as M,
  wo as N,
  _o as O,
  ve as P,
  vo as Q,
  ye as R,
  Le as S,
  to as T,
  ae as U,
  Y as V,
  bo as W,
  oo as X,
  Lo as Y,
  we as Z,
  Re as _,
  ko as a,
  Me as a0,
  $ as a1,
  Ne as a2,
  _e as a3,
  Ve as a4,
  De as a5,
  Fe as a6,
  Oe as a7,
  Z as a8,
  se as b,
  Ye as c,
  Ze as d,
  J as e,
  N as f,
  re as g,
  K as h,
  Q as i,
  We as j,
  Ge as k,
  He as l,
  Xe as m,
  ee as n,
  ke as o,
  d as p,
  Se as q,
  ie as r,
  p as s,
  Ke as t,
  ce as u,
  je as v,
  Qe as w,
  io as x,
  co as y,
  lo as z
};
