import { localStorageProp as ce, prop as V, Use as q, html as i, OnDispose as C, attr as t, on as E, When as b, coalesce as h, Ensure as W, computedOf as g, Fragment as z, bind as le, ForEach as me, Value as oe, OneOfValue as ue } from "@tempots/dom";
import { t as de, a as te, u as G, S as $, b as ae, c as T, P as N, E as H, N as j } from "../notice-Dgv1Puqy.js";
import { s as A, o as X, b as R, M as pe } from "../modal-Dx7nHv_u.js";
import { AuthI18n as B } from "../translations-BaKCl3Vc.js";
import { B as F, T as he, I as ge } from "../translations-DoBmuZ5v.js";
import { classes as fe } 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 be(e) {
  return Y[e]?.name || e;
}
function Te(e) {
  return Y[e]?.icon || "mdi:account";
}
function Ae(e) {
  return Y[e]?.color || "#666";
}
function Ce(e, o = "Continue with {provider}") {
  return o.replace("{provider}", be(e));
}
const I = {
  minLength: 8,
  requireUppercase: !0,
  requireLowercase: !0,
  requireNumbers: !0,
  requireSymbols: !1
};
function ze(e) {
  return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
}
function we(e = 32) {
  const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
  let c = "";
  for (let m = 0; m < e; m++)
    c += o.charAt(Math.floor(Math.random() * o.length));
  return c;
}
function Ee(e, o, c, m = [], l = {}) {
  const n = {
    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"]
  }, s = n[e];
  if (!s)
    throw new Error(`Unsupported provider: ${e}`);
  const a = m.length > 0 ? m : u[e], r = we(), f = new URLSearchParams({
    client_id: o,
    redirect_uri: c,
    scope: a.join(" "),
    state: r,
    response_type: "code",
    ...l
  });
  return `${s}?${f.toString()}`;
}
function Ue(e, o, c, m) {
  const l = window.open(
    e,
    `${o}_login`,
    "width=500,height=600,scrollbars=yes,resizable=yes"
  );
  if (!l) {
    m?.(new Error("Failed to open popup window"));
    return;
  }
  const n = setInterval(() => {
    l.closed && (clearInterval(n), m?.(new Error("Login cancelled")));
  }, 1e3), u = (s) => {
    s.origin === window.location.origin && (s.data.type === "SOCIAL_LOGIN_SUCCESS" ? (clearInterval(n), l.close(), window.removeEventListener("message", u), c?.(s.data.result)) : s.data.type === "SOCIAL_LOGIN_ERROR" && (clearInterval(n), l.close(), window.removeEventListener("message", u), m?.(new Error(s.data.error))));
  };
  window.addEventListener("message", u);
}
function Oe(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 Ve() {
  return typeof window < "u" && typeof document < "u";
}
function Z({
  task: e,
  message: o,
  onStart: c,
  onEnd: m
}) {
  return async (l) => {
    c?.();
    const n = await de({
      task: e != null ? () => e(l) : async () => null,
      errorMessage: o,
      errorPath: ["root"],
      validation: (u) => u != null ? te.invalid({ message: u }) : te.valid
    });
    return m?.(), n;
  };
}
function J(e = I) {
  let o = A();
  return e.minLength && (o = o.min(
    e.minLength,
    `Password must be at least ${e.minLength} characters`
  )), e.requireUppercase && (o = o.regex(
    /[A-Z]/,
    "Password must contain at least one uppercase letter"
  )), e.requireLowercase && (o = o.regex(
    /[a-z]/,
    "Password must contain at least one lowercase letter"
  )), e.requireNumbers && (o = o.regex(
    /[0-9]/,
    "Password must contain at least one number"
  )), e.requireSymbols && (o = o.regex(
    /[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,
    "Password must contain at least one special character"
  )), e.customValidation && (o = o.refine((c) => e.customValidation(c))), o;
}
const M = A().min(1, "Email is required").email("Please enter a valid email address");
function K(e) {
  const o = e ? J(e) : A().refine(
    (c) => c.length > 0 ? null : "Password is required"
  );
  return X({
    email: M,
    password: o,
    rememberMe: R().default(!1)
  }).schema();
}
function Q(e = I, o) {
  const c = J(e), m = o?.showNameField !== !1, l = o?.showConfirmPassword !== !1, n = o?.showAcceptTermsAndConditions !== !1, u = {
    name: m ? A().min(1, "Name is required").optional() : A().optional(),
    email: M,
    password: c,
    // Always require confirmPassword as string to match SignUpData interface
    // When not shown, it should accept any value (including empty string)
    confirmPassword: l ? A().min(1, "Please confirm your password") : A(),
    // Accept any string value when not shown
    acceptTerms: n ? R().refine(
      (a) => a === !0,
      "You must accept the terms and conditions"
    ) : R().default(!0)
    // Default to true when not shown
  }, s = X(u);
  return l ? s.refine(
    (a) => a.password === a.confirmPassword ? null : "Passwords don't match",
    { path: ["confirmPassword"] }
  ).schema() : s.schema();
}
const re = X({
  email: M
}).schema(), Fe = K(), Me = Q(), De = {
  signIn: K,
  signUp: Q,
  resetPassword: () => re
};
function Ne(e) {
  const o = M.validate(e);
  return o.success ? null : o.errors[0]?.message || "Invalid email";
}
function Re(e, o = I) {
  const m = J(o).validate(e);
  return m.success ? null : m.errors[0]?.message || "Invalid password";
}
function ee(e, o = I) {
  const c = {
    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
  }, m = [
    !0,
    // length is always enabled
    o.requireUppercase,
    o.requireLowercase,
    o.requireNumbers,
    o.requireSymbols,
    !!o.customValidation
  ].filter(Boolean).length, l = [
    c.length,
    o.requireUppercase ? c.uppercase : null,
    o.requireLowercase ? c.lowercase : null,
    o.requireNumbers ? c.numbers : null,
    o.requireSymbols ? c.symbols : null,
    o.customValidation ? c.custom : null
  ].filter((s) => s === !0).length, n = m > 0 ? Math.round(l / m * 100) : 0;
  let u;
  return n < 40 ? u = "weak" : n < 60 ? u = "fair" : n < 80 ? u = "good" : u = "strong", { strength: u, score: n, checks: c };
}
const ie = () => ce({
  key: "bui_auth_email",
  defaultValue: null
});
function _e({
  onSignIn: e,
  passwordRules: o,
  labels: c,
  showRememberMe: m
}) {
  const l = V(!1), n = ie(), u = K(o), s = G({
    schema: u,
    onSubmit: Z({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        l.set(!0), s.controller.disable();
      },
      onEnd: () => {
        l.set(!1), s.controller.enable();
      }
    }),
    initialValue: {
      email: "",
      password: ""
    }
  }), { controller: a, submit: r } = s;
  l.on(a.setDisabled);
  const f = a.field("email"), w = a.field("password");
  return n.on((_) => {
    _ != null && f.change(_);
  }), f.signal.on((_) => {
    n.value != null && (n.value = _);
  }), q(
    B,
    (_) => (
      // Email/Password form
      i.form(
        C(a.dispose, n.dispose, l.dispose),
        t.class("bc-auth-form__form"),
        E.submit(r),
        $(
          t.class("bc-auth-form__fields"),
          W(
            a.error,
            (k) => j(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(k)
            )
          ),
          // Email field
          T(H, {
            controller: f,
            label: h(c?.emailLabel, _.$.emailLabel)
          }),
          // Password field
          T(N, {
            controller: w,
            label: h(c?.passwordLabel, _.$.passwordLabel)
          }),
          // Remember me checkbox
          b(
            m ?? !0,
            () => i.div(
              t.class("bc-auth-form__remember-me"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                ae({
                  value: n.map((k) => k != null),
                  after: i.span(
                    h(c?.rememberMeLabel, _.$.rememberMeLabel)
                  ),
                  onChange: (k) => {
                    k ? n.value = f.signal.value ?? "" : n.value = null;
                  }
                })
              )
            )
          )
        ),
        // Submit button
        F(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: l,
            disabled: a.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(c?.signInButton, _.$.signInButton)
        )
      )
    )
  );
}
function Le({
  password: e,
  rules: o = I,
  showLabel: c = !0,
  className: m
}) {
  const l = g(e)((r) => !r || r.length === 0 ? {
    strength: "weak",
    score: 0,
    checks: {
      length: !1,
      uppercase: !1,
      lowercase: !1,
      numbers: !1,
      symbols: !1,
      custom: !1
    }
  } : ee(r, o)), n = l.map((r) => r.strength), u = l.map((r) => r.score), s = l.map((r) => r.checks), a = g(
    n,
    m
  )((r, f) => [
    "bc-password-strength",
    `bc-password-strength--${r}`,
    f
  ].filter(Boolean).join(" "));
  return i.div(
    C(l, a),
    t.class(a),
    // Strength bar
    i.div(
      t.class("bc-password-strength__bar"),
      i.div(
        t.class("bc-password-strength__fill"),
        t.style(u.map((r) => `width: ${r}%`))
      )
    ),
    // Strength label (optional)
    b(
      c,
      () => q(
        B,
        (r) => i.div(
          t.class("bc-password-strength__label"),
          g(
            n,
            r
          )((f, w) => {
            switch (f) {
              case "weak":
                return w.passwordStrengthWeak;
              case "fair":
                return w.passwordStrengthFair;
              case "good":
                return w.passwordStrengthGood;
              case "strong":
                return w.passwordStrengthStrong;
              default:
                return w.passwordStrengthWeak;
            }
          })
        )
      )
    ),
    // Requirements checklist
    i.div(
      t.class("bc-password-strength__requirements"),
      // Length requirement
      b(
        o.minLength !== void 0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(s)(
              (r) => r.length ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(s)((r) => r.length ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            `At least ${o.minLength} characters`
          )
        )
      ),
      // Uppercase requirement
      b(
        o.requireUppercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(s)(
              (r) => r.uppercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(s)((r) => r.uppercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One uppercase letter"
          )
        )
      ),
      // Lowercase requirement
      b(
        o.requireLowercase === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(s)(
              (r) => r.lowercase ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(s)((r) => r.lowercase ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One lowercase letter"
          )
        )
      ),
      // Numbers requirement
      b(
        o.requireNumbers === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(s)(
              (r) => r.numbers ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(s)((r) => r.numbers ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One number"
          )
        )
      ),
      // Symbols requirement
      b(
        o.requireSymbols === !0,
        () => i.div(
          t.class("bc-password-strength__requirement"),
          t.class(
            g(s)(
              (r) => r.symbols ? "bc-password-strength__requirement--met" : ""
            )
          ),
          i.span(
            t.class("bc-password-strength__requirement-icon"),
            g(s)((r) => r.symbols ? "✓" : "○")
          ),
          i.span(
            t.class("bc-password-strength__requirement-text"),
            "One special character"
          )
        )
      )
    )
  );
}
function We({
  password: e,
  rules: o = I,
  className: c
}) {
  const m = g(e)((s) => !s || s.length === 0 ? { strength: "weak", score: 0 } : ee(s, o)), l = m.map((s) => s.strength), n = m.map((s) => s.score), u = g(
    l,
    c
  )((s, a) => [
    "bc-password-strength-bar",
    `bc-password-strength-bar--${s}`,
    a
  ].filter(Boolean).join(" "));
  return i.div(
    C(m, u),
    t.class(u),
    i.div(
      t.class("bc-password-strength-bar__fill"),
      t.style(n.map((s) => `width: ${s}%`))
    )
  );
}
function Ge({
  password: e,
  rules: o = I,
  className: c
}) {
  const m = g(e)((n) => !n || n.length === 0 ? "weak" : ee(n, o).strength), l = g(
    m,
    c
  )((n, u) => [
    "bc-password-strength-text",
    `bc-password-strength-text--${n}`,
    u
  ].filter(Boolean).join(" "));
  return z(
    C(m, l),
    q(
      B,
      (n) => i.span(
        t.class(l),
        g(
          m,
          n
        )((u, s) => {
          switch (u) {
            case "weak":
              return s.passwordStrengthWeak;
            case "fair":
              return s.passwordStrengthFair;
            case "good":
              return s.passwordStrengthGood;
            case "strong":
              return s.passwordStrengthStrong;
            default:
              return s.passwordStrengthWeak;
          }
        })
      )
    )
  );
}
function ke({
  passwordRules: e,
  labels: o,
  initialEmail: c,
  initialName: m,
  showPasswordStrength: l,
  onSignUp: n,
  showNameField: u,
  showConfirmPassword: s,
  showAcceptTermsAndConditions: a,
  termsAndConditions: r
}) {
  const f = V(!1), w = e || I, _ = Q(w, {
    showNameField: u !== !1,
    showConfirmPassword: s !== !1,
    showAcceptTermsAndConditions: a !== !1
  }), k = G({
    schema: _,
    onSubmit: Z({
      task: n != null ? (P) => n({
        email: P.email,
        password: P.password,
        name: P.name
      }) : void 0,
      message: "Reset password failed",
      onStart: () => {
        f.set(!0), k.controller.disable();
      },
      onEnd: () => {
        f.set(!1), k.controller.enable();
      }
    }),
    initialValue: {
      name: m ?? "",
      email: c ?? "",
      password: "",
      confirmPassword: "",
      acceptTerms: !1
    }
  }), { controller: v, submit: x } = k;
  f.on(v.setDisabled);
  const y = v.field("name"), U = v.field("email"), O = v.field("password"), D = v.field("confirmPassword"), S = v.field("acceptTerms");
  return q(
    B,
    (P) => (
      // Registration form
      i.form(
        C(v.dispose, f.dispose),
        t.class("bc-auth-form__form"),
        E.submit(x),
        $(
          t.class("bc-auth-form__fields"),
          W(
            v.error,
            (L) => j(
              { variant: "danger", tone: "prominent", role: "alert" },
              i.div(L)
            )
          ),
          // Name field (optional)
          b(
            u !== !1,
            () => T(he, {
              controller: y.transform(
                (L) => L ?? "",
                (L) => L === "" ? void 0 : L
              ),
              label: h(o?.nameLabel, P.$.nameLabel)
            })
          ),
          // Email field
          T(H, {
            controller: U,
            label: h(o?.emailLabel, P.$.emailLabel)
          }),
          // Password field
          T(N, {
            controller: O,
            label: h(o?.passwordLabel, P.$.passwordLabel)
          }),
          // Password strength indicator
          b(
            l ?? !1,
            () => Le({
              password: O.signal,
              rules: w,
              showLabel: !0
            })
          ),
          // Confirm password field
          b(
            s ?? !1,
            () => T(N, {
              controller: D,
              label: h(
                o?.confirmPasswordLabel,
                P.$.confirmPasswordLabel
              )
            })
          ),
          // Terms acceptance checkbox
          b(
            a ?? !1,
            () => i.div(
              t.class("bc-auth-form__terms"),
              i.label(
                t.class("bc-auth-form__checkbox-label"),
                ae({
                  value: S.signal.map((L) => L ?? !1),
                  onChange: (L) => S.change(L)
                }),
                i.span(
                  r || h(o?.acceptTermsLabel, P.$.acceptTermsLabel)
                )
              ),
              b(
                S.errorVisible,
                () => i.div(
                  t.class("bc-auth-form__field-error"),
                  S.error.map((L) => L || "")
                )
              )
            )
          )
        ),
        // Submit button
        F(
          {
            type: "submit",
            variant: "filled",
            color: "primary",
            loading: f,
            disabled: v.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.signUpButton, P.$.signUpButton)
        )
      )
    )
  );
}
function ve({
  onResetPassword: e,
  labels: o = {}
}) {
  const c = ie(), m = V(!1), l = G({
    schema: re,
    onSubmit: Z({
      task: e,
      message: "Reset password failed",
      onStart: () => {
        m.set(!0), l.controller.disable();
      },
      onEnd: () => {
        m.set(!1), l.controller.enable();
      }
    }),
    initialValue: {
      email: ""
    }
  }), { controller: n, submit: u } = l;
  m.on(n.setDisabled);
  const s = n.field("email");
  return c.on((a) => {
    a != null && s.change(a);
  }), q(
    B,
    (a) => (
      // Reset password form
      i.form(
        C(n.dispose, c.dispose, m.dispose),
        t.class("bc-auth-form__form"),
        W(
          n.error,
          (r) => j(
            { variant: "danger", tone: "prominent", role: "alert" },
            i.div(r)
          )
        ),
        // Description
        i.p(
          t.class("bc-auth-form__description"),
          h(o?.resetPasswordDescription, a.$.resetPasswordDescription)
        ),
        E.submit(u),
        $(
          t.class("bc-auth-form__fields"),
          // Email field
          T(H, {
            controller: s,
            label: h(o?.emailLabel, a.$.emailLabel)
          })
        ),
        // Submit button
        F(
          {
            loading: m,
            type: "submit",
            variant: "filled",
            color: "primary",
            disabled: n.disabledOrHasErrors
          },
          t.class("bc-auth-form__submit"),
          h(o?.resetPasswordButton, a.$.resetPasswordButton)
        )
      )
    )
  );
}
function p({
  provider: e,
  onClick: o,
  size: c = "md",
  name: m,
  icon: l,
  color: n,
  flow: u,
  labels: s
}) {
  return F(
    {
      type: "button",
      variant: "filled",
      size: c,
      color: n,
      onClick: async () => {
        if (o)
          try {
            u === "popup" ? await o() : await o();
          } catch (r) {
            console.error(
              `Social login error for ${e} (${u || "redirect"} flow):`,
              r
            );
          }
      },
      roundedness: "full"
    },
    t.class("bc-social-login-button"),
    t.class(
      g(e)((r) => `bc-social-login-button--${r}`)
    ),
    i.span(
      t.class("bc-social-login-button__inner"),
      i.span(
        t.class("bc-social-login-button__icon"),
        ge({ icon: l, size: c }, t.class("bc-social-login-button__icon-inner"))
      ),
      q(
        B,
        (r) => i.span(
          t.class("bc-social-login-button__label"),
          le(
            h(s?.continueWithProvider, r.$.continueWithProvider)
          )(m)
        )
      )
    )
  );
}
function ye({
  providers: e,
  onProviderClick: o,
  size: c = "md",
  className: m
}) {
  return $(
    t.class("bc-social-login-buttons"),
    t.class(m),
    me(
      e,
      (l) => p({
        provider: l.$.provider,
        flow: l.$.flow,
        color: l.map(
          ({ provider: n }) => d[n].color
        ),
        name: l.map(({ provider: n }) => d[n].name),
        icon: l.map(({ provider: n }) => d[n].icon),
        onClick: async () => {
          o && await o(l.$.provider.value);
        },
        size: c
      })
    )
  );
}
const d = {
  // 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: "streamline-logos:snapchat-logo-solid",
    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: "streamline-logos:epic-games-logo-solid",
    color: "neutral"
  },
  playstation: {
    name: "PlayStation",
    icon: "streamline-logos:playstation-logo-solid",
    color: "violet"
  },
  xbox: {
    name: "Xbox",
    icon: "streamline-logos:xbox-live-logo-solid",
    color: "green"
  },
  // Messaging
  whatsapp: {
    name: "WhatsApp",
    icon: "logos:whatsapp-icon",
    color: "emerald"
  },
  wechat: {
    name: "WeChat",
    icon: "streamline-logos:wechat-logo",
    color: "lime"
  },
  // Other Identity
  amazon: {
    name: "Amazon",
    icon: "streamline-logos:amazon-logo-solid",
    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)
  }
}, He = (e) => p({
  ...e,
  ...d.google,
  provider: "google"
}), je = (e) => p({
  ...e,
  ...d.github,
  provider: "github"
}), Xe = (e) => p({
  ...e,
  ...d.apple,
  provider: "apple"
}), Ye = (e) => p({
  ...e,
  ...d.facebook,
  provider: "facebook"
}), Ze = (e) => p({
  ...e,
  ...d.x,
  provider: "x"
}), Je = (e) => p({
  ...e,
  ...d.twitter,
  provider: "twitter"
}), Ke = (e) => p({
  ...e,
  ...d.microsoft,
  provider: "microsoft"
}), Qe = (e) => p({
  ...e,
  ...d.discord,
  provider: "discord"
}), eo = (e) => p({
  ...e,
  ...d.linkedin,
  provider: "linkedin"
}), oo = (e) => p({
  ...e,
  ...d.instagram,
  provider: "instagram"
}), to = (e) => p({
  ...e,
  ...d.tiktok,
  provider: "tiktok"
}), so = (e) => p({
  ...e,
  ...d.snapchat,
  provider: "snapchat"
}), no = (e) => p({
  ...e,
  ...d.reddit,
  provider: "reddit"
}), ao = (e) => p({
  ...e,
  ...d.pinterest,
  provider: "pinterest"
}), ro = (e) => p({
  ...e,
  ...d.twitch,
  provider: "twitch"
}), io = (e) => p({
  ...e,
  ...d.steam,
  provider: "steam"
}), co = (e) => p({
  ...e,
  ...d.epic,
  provider: "epic"
}), lo = (e) => p({
  ...e,
  ...d.playstation,
  provider: "playstation"
}), mo = (e) => p({
  ...e,
  ...d.xbox,
  provider: "xbox"
}), uo = (e) => p({
  ...e,
  ...d.whatsapp,
  provider: "whatsapp"
}), po = (e) => p({
  ...e,
  ...d.wechat,
  provider: "wechat"
}), ho = (e) => p({
  ...e,
  ...d.amazon,
  provider: "amazon"
}), go = (e) => p({
  ...e,
  ...d.yahoo,
  provider: "yahoo"
}), fo = (e) => p({
  ...e,
  ...d.paypal,
  provider: "paypal"
});
function se({ providers: e }) {
  return $(
    ye({
      providers: e
    })
  );
}
function Se({
  mode: e,
  socialProviders: o,
  initialName: c,
  initialEmail: m,
  passwordRules: l,
  showRememberMe: n,
  showSocialDivider: u,
  showPasswordStrength: s,
  labels: a,
  onSignIn: r,
  onSignUp: f,
  onResetPassword: w,
  onModeChange: _,
  // onSocialLogin,
  showContainer: k
}, ...v) {
  const x = e != null ? oe.deriveProp(e) : V("signin");
  return x.on((y) => _?.(y)), q(B, (y) => {
    function U() {
      const S = h(a?.hasAccountLink, y.$.hasAccountLink);
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => x.set("signin")),
        S
      );
    }
    function O() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => x.set("signup")),
        h(a?.noAccountLink, y.$.noAccountLink)
      );
    }
    function D() {
      return i.button(
        t.type("button"),
        t.class("bc-auth-form__link"),
        E.click(() => x.set("reset-password")),
        h(a?.forgotPasswordLink, y.$.forgotPasswordLink)
      );
    }
    return i.div(
      fe({
        "bc-auth-container": !0,
        "bc-auth-container--styled": oe.map(k ?? !0, (S) => S)
      }),
      t.class(x.map((S) => `bc-auth-container--${S}`)),
      t.class("bc-auth-form"),
      C(x.dispose),
      ue(x, {
        signin: () => z(
          i.h2(
            t.class("bc-auth-form__title"),
            h(a?.signInTitle, y.$.signInTitle)
          ),
          o != null ? z(
            se({ providers: o }),
            b(u ?? !1, ne)
          ) : null,
          _e({
            onSignIn: r,
            showRememberMe: n,
            passwordRules: l,
            labels: {
              emailLabel: a?.emailLabel,
              passwordLabel: a?.passwordLabel,
              rememberMeLabel: a?.rememberMeLabel,
              signInButton: a?.signInButton,
              forgotPasswordLink: a?.forgotPasswordLink,
              noAccountLink: a?.noAccountLink
            }
          }),
          $(
            t.class("bc-auth-form__footer"),
            O(),
            D()
          )
        ),
        signup: () => z(
          i.h2(
            t.class("bc-auth-form__title"),
            h(a?.signUpTitle, y.$.signUpTitle)
          ),
          o != null ? z(
            se({ providers: o }),
            b(u ?? !1, ne)
          ) : null,
          ke({
            labels: {
              nameLabel: a?.nameLabel,
              emailLabel: a?.emailLabel,
              passwordLabel: a?.passwordLabel,
              confirmPasswordLabel: a?.confirmPasswordLabel,
              acceptTermsLabel: a?.acceptTermsLabel,
              signUpButton: a?.signUpButton,
              hasAccountLink: a?.hasAccountLink
            },
            initialEmail: m,
            initialName: c,
            onSignUp: f,
            passwordRules: l,
            showPasswordStrength: s
          }),
          $(t.class("bc-auth-form__footer"), U())
        ),
        "reset-password": () => z(
          i.h2(
            t.class("bc-auth-form__title"),
            h(a?.resetPasswordTitle, y.$.resetPasswordTitle)
          ),
          ve({
            labels: {
              backToSignInLink: a?.backToSignInLink,
              emailLabel: a?.emailLabel,
              resetPasswordButton: a?.resetPasswordButton,
              resetPasswordDescription: a?.resetPasswordDescription
            },
            onResetPassword: w
          }),
          $(t.class("bc-auth-form__footer"), U())
        )
      }),
      ...v
    );
  });
}
function bo(e) {
  return pe(
    {
      size: "sm",
      dismissable: !0,
      showCloseButton: !0
    },
    (o, c) => e(
      (m) => o({
        body: Se({ showContainer: !1, ...m }),
        header: q(
          B,
          (l) => h(m.modalTitle, l.$.authenticationTitle)
        )
      })
    )
  );
}
function ne({
  labels: e,
  className: o
} = {}) {
  return i.div(
    t.class("bc-auth-divider"),
    t.class(o),
    i.div(t.class("bc-auth-divider__line")),
    q(
      B,
      (c) => i.span(
        t.class("bc-auth-divider__text"),
        h(e?.text, c.$.orDivider)
      )
    ),
    i.div(t.class("bc-auth-divider__line"))
  );
}
export {
  ho as AmazonLoginButton,
  Xe as AppleLoginButton,
  Se as AuthContainer,
  ne as AuthDivider,
  bo as AuthModal,
  Qe as DiscordLoginButton,
  co as EpicLoginButton,
  Ye as FacebookLoginButton,
  je as GitHubLoginButton,
  He as GoogleLoginButton,
  oo as InstagramLoginButton,
  eo as LinkedInLoginButton,
  Ke as MicrosoftLoginButton,
  We as PasswordStrengthBar,
  Le as PasswordStrengthIndicator,
  Ge as PasswordStrengthText,
  fo as PayPalLoginButton,
  ao as PinterestLoginButton,
  lo as PlayStationLoginButton,
  no as RedditLoginButton,
  ve as ResetPasswordForm,
  _e as SignInForm,
  ke as SignUpForm,
  so as SnapchatLoginButton,
  p as SocialLoginButton,
  ye as SocialLoginButtons,
  se as SocialProviders,
  io as SteamLoginButton,
  to as TiktokLoginButton,
  ro as TwitchLoginButton,
  Je as TwitterLoginButton,
  po as WeChatLoginButton,
  uo as WhatsAppLoginButton,
  Ze as XLoginButtin,
  mo as XboxLoginButton,
  go as YahooLoginButton,
  De as authSchemas,
  ee as calculatePasswordStrength,
  J as createPasswordSchema,
  K as createSignInSchema,
  Q as createSignUpSchema,
  Ee as createSocialLoginUrl,
  I as defaultPasswordRules,
  Fe as defaultSignInSchema,
  Me as defaultSignUpSchema,
  M as emailSchema,
  Oe as formatAuthError,
  be as formatProviderName,
  Ce as formatSocialLoginText,
  we as generateRandomString,
  Ae as getProviderColor,
  Te as getProviderIcon,
  Ve as isBrowser,
  ze as isValidEmail,
  Ue as openSocialLoginPopup,
  Y as providerInfo,
  Z as requestToControllerValidation,
  re as resetPasswordSchema,
  d as socialProviderInfo,
  ie as useAuthEmailProp,
  Ne as validateEmail,
  Re as validatePassword
};
