import { C as z } from "./text-input-BZmAB3_o.js";
import { Use as V, input as j, attr as t, coalesce as A, on as m, Empty as w, emitValue as I, prop as O, computedOf as C, html as p, aria as F, When as P, Fragment as $, Value as g, Unless as M, Ensure as R } from "@tempots/dom";
import { a as S, I as k } from "./input-container-DhUiLmXE.js";
import { B as x, I as E } from "./translations-BGblCUBj.js";
import { C as W } from "./use-form-BSvvERhX.js";
const X = (n) => {
  const l = {
    name: "email",
    autocomplete: "email",
    ...n
  }, {
    value: r,
    before: s,
    onBlur: o,
    onChange: d,
    onInput: c,
    placeholder: v
  } = l, b = s ?? S({
    icon: "line-md:email",
    size: n.size,
    color: "neutral"
  });
  return V(
    x,
    (f) => k({
      ...n,
      before: b,
      input: j.email(
        z(l),
        t.placeholder(A(v, f.$.emailPlaceholderText)),
        t.value(r),
        t.class("bc-input"),
        o != null ? m.blur(I(o)) : w,
        d != null ? m.change(I(d)) : w,
        c != null ? m.input(I(c)) : w
      )
    })
  );
}, Y = (n) => {
  const {
    value: l,
    onBlur: r,
    onChange: s,
    onInput: o,
    before: d,
    after: c,
    hasError: v,
    disabled: b,
    autocomplete: f,
    placeholder: _,
    ...h
  } = n, T = {
    name: "password",
    disabled: b,
    ...h
  }, i = O(!0), a = C(
    i,
    f
  )((e, u) => e ? u ?? "current-password" : "off");
  return V(x, (e) => {
    const u = C(
      e.$.passwordPlaceholderText,
      i,
      _
    )((y, N, U) => N ? "•••••••••••••••" : U ?? y), B = p.button(
      t.type("button"),
      t.class("bc-input-container__password-toggle"),
      F.label(e.$.togglePasswordVisibility),
      m.click(() => i.update((y) => !y)),
      P(
        i,
        () => E({ icon: "line-md:watch" }),
        () => E({ icon: "line-md:watch-off" })
      )
    );
    return k({
      before: d,
      disabled: b,
      hasError: v,
      input: p.input(
        z({
          ...T,
          autocomplete: a,
          placeholder: u
        }),
        P(
          i,
          () => $(t.type("password")),
          () => $(t.type("text"))
        ),
        t.class("bc-input"),
        t.value(l),
        r != null ? m.blur(I(r)) : w,
        s != null ? m.change(I(s)) : w,
        o != null ? m.input(I(o)) : w
      ),
      after: c != null ? $(B, c) : B
    });
  });
};
function q(n) {
  switch (n) {
    case "success":
      return "material-symbols:check-circle-outline";
    case "warning":
      return "material-symbols:warning-outline";
    case "danger":
      return "material-symbols:error-outline";
    case "info":
    default:
      return "material-symbols:info-outline";
  }
}
function D(n) {
  switch (n) {
    case "success":
      return "success";
    case "warning":
      return "warning";
    case "danger":
      return "danger";
    case "info":
    default:
      return "info";
  }
}
function G(n, l, r, s) {
  const o = [
    "bc-notice",
    `bc-notice--${n}`,
    `bc-notice--tone-${l}`
  ];
  return r && o.push("bc-notice--dismissible"), s && s.length > 0 && o.push(s), o.join(" ");
}
function Z({
  variant: n = "info",
  tone: l = "subtle",
  role: r,
  title: s,
  icon: o,
  closable: d = !1,
  onDismiss: c,
  class: v
}, ...b) {
  const f = O(!0);
  return P(f, () => {
    const _ = g.map(
      d,
      (a) => !!a || c != null
    ), h = g.map(n, (a) => a ?? "info"), T = g.map(l, (a) => a ?? "subtle"), i = C(
      r,
      h
    )(
      (a, e) => a ?? (e === "danger" ? "alert" : "status")
    );
    return V(
      x,
      (a) => p.div(
        t.class(
          C(
            h,
            T,
            _,
            v
          )((e, u, B, y) => G(e, u, B, y))
        ),
        // Accessibility role mapping (always defined)
        t.role(g.map(i, (e) => e)),
        M(
          g.map(o, (e) => e === !1),
          () => p.div(
            t.class("bc-notice__icon"),
            E({
              icon: C(
                o,
                h
              )(
                (e, u) => e === void 0 ? q(u) : String(e)
              ),
              size: "md",
              color: g.map(h, D)
            })
          )
        ),
        p.div(
          t.class("bc-notice__body"),
          R(
            s,
            (e) => p.div(t.class("bc-notice__title"), e)
          ),
          p.div(t.class("bc-notice__content"), ...b)
        ),
        P(
          _,
          () => W({
            size: "xs",
            label: a.$.closeModal,
            onClick: () => {
              f.set(!1), c?.();
            }
          })
        )
      )
    );
  });
}
export {
  X as E,
  Z as N,
  Y as P
};
