import { U as reactExports, L as jsxRuntimeExports } from "./server-DSC_YmUp.js";
import { r as createLucideIcon, z as supabase, B as Button, E as toast, G as useAuth, S as useNavigate } from "./router-CEZm8MTA.js";
import { i as Avatar, k as AvatarImage, j as AvatarFallback, T as Tabs, p as TabsList, q as TabsTrigger, o as TabsContent, C as Chat } from "./tabs-BcrBvEup.js";
import { S as Save, a as TargetsPanel, W as WeightTracker } from "./TargetsPanel-DjzMGHx9.js";
import { C as Card } from "./card-CdzUIPcf.js";
import { L as Label, I as Input } from "./label-gF41I2IG.js";
import { L as LoaderCircle, U as User } from "./user-BbyUVYOA.js";
import { T as TrendingUp } from "./trending-up-DlL_CVAh.js";
import { M as MessageCircle } from "./utensils-Cya-B9wL.js";
import { U as Users } from "./users-LIPb0en-.js";
import "node:async_hooks";
import "node:stream/web";
import "node:stream";
import "./textarea-Bvg_-Pfo.js";
const __iconNode = [
  [
    "path",
    {
      d: "M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",
      key: "18u6gg"
    }
  ],
  ["circle", { cx: "12", cy: "13", r: "3", key: "1vg3eu" }]
];
const Camera = createLucideIcon("camera", __iconNode);
const HEIGHT_MIN = 100;
const HEIGHT_MAX = 230;
const WEIGHT_MIN = 25;
const WEIGHT_MAX = 350;
function ProfileEditor({ userId }) {
  const [fullName, setFullName] = reactExports.useState("");
  const [nickname, setNickname] = reactExports.useState("");
  const [heightCm, setHeightCm] = reactExports.useState("");
  const [goalKg, setGoalKg] = reactExports.useState("");
  const [avatarUrl, setAvatarUrl] = reactExports.useState(null);
  const [uploading, setUploading] = reactExports.useState(false);
  const [saving, setSaving] = reactExports.useState(false);
  const fileRef = reactExports.useRef(null);
  reactExports.useEffect(() => {
    supabase.from("profiles").select("full_name,nickname,height_cm,goal_weight_kg,avatar_url").eq("id", userId).maybeSingle().then(({ data }) => {
      if (!data) return;
      setFullName(data.full_name ?? "");
      setNickname(data.nickname ?? "");
      setHeightCm(data.height_cm?.toString() ?? "");
      setGoalKg(data.goal_weight_kg?.toString() ?? "");
      setAvatarUrl(data.avatar_url ?? null);
    });
  }, [userId]);
  const onPickAvatar = async (file) => {
    if (file.size > 5 * 1024 * 1024) {
      toast.error("Imaginea e prea mare (max 5MB)");
      return;
    }
    setUploading(true);
    try {
      const ext = (file.name.split(".").pop() || "jpg").toLowerCase();
      const path = `${userId}/avatar-${Date.now()}.${ext}`;
      const { error } = await supabase.storage.from("avatars").upload(path, file, { upsert: true });
      if (error) throw error;
      const { data: pub } = supabase.storage.from("avatars").getPublicUrl(path);
      const url = pub.publicUrl;
      const { error: upErr } = await supabase.from("profiles").update({ avatar_url: url }).eq("id", userId);
      if (upErr) throw upErr;
      setAvatarUrl(url);
      toast.success("Avatar actualizat");
    } catch (e) {
      toast.error(e instanceof Error ? e.message : String(e));
    } finally {
      setUploading(false);
      if (fileRef.current) fileRef.current.value = "";
    }
  };
  const save = async (e) => {
    e.preventDefault();
    if (!fullName.trim()) {
      toast.error("Numele complet este obligatoriu");
      return;
    }
    const h = heightCm ? Number(heightCm) : null;
    if (h != null && (h < HEIGHT_MIN || h > HEIGHT_MAX)) {
      toast.error(`Înălțimea trebuie între ${HEIGHT_MIN} și ${HEIGHT_MAX} cm`);
      return;
    }
    const g = goalKg ? Number(goalKg) : null;
    if (g != null && (g < WEIGHT_MIN || g > WEIGHT_MAX)) {
      toast.error(`Greutatea țintă trebuie între ${WEIGHT_MIN} și ${WEIGHT_MAX} kg`);
      return;
    }
    setSaving(true);
    const { error } = await supabase.from("profiles").update({
      full_name: fullName,
      nickname: nickname || null,
      height_cm: h,
      goal_weight_kg: g
    }).eq("id", userId);
    setSaving(false);
    if (error) toast.error(error.message);
    else toast.success("Profil salvat");
  };
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "p-5 sm:p-7 rounded-2xl shadow-[var(--shadow-card)]", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "mb-5", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "font-display text-xl font-bold tracking-tight", children: "Profilul tău" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground", children: "Modifică numele, poreclă, înălțime, greutate țintă și avatar." })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs("form", { onSubmit: save, className: "space-y-5 max-w-md", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(Avatar, { className: "h-20 w-20 ring-2 ring-primary/15 ring-offset-2 ring-offset-card", children: [
            avatarUrl && /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarImage, { src: avatarUrl }),
            /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarFallback, { className: "text-lg font-display font-bold bg-primary/15 text-primary", children: (nickname || fullName || "?").slice(0, 2).toUpperCase() })
          ] }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            "button",
            {
              type: "button",
              onClick: () => fileRef.current?.click(),
              disabled: uploading,
              "aria-label": "Schimbă avatarul",
              className: "absolute -bottom-1 -right-1 grid place-items-center h-8 w-8 rounded-full bg-primary text-primary-foreground shadow-soft transition-transform hover:scale-105 active:scale-95 disabled:opacity-50",
              children: uploading ? /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-3.5 w-3.5 animate-spin" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Camera, { className: "h-3.5 w-3.5" })
            }
          ),
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            "input",
            {
              ref: fileRef,
              type: "file",
              accept: "image/*",
              className: "hidden",
              onChange: (e) => e.target.files?.[0] && onPickAvatar(e.target.files[0])
            }
          )
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "text-sm text-muted-foreground", children: [
          uploading ? "Se încarcă…" : "Apasă pe iconița aparatului foto pentru a schimba poza.",
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-xs", children: "PNG sau JPG, max 5MB." })
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-nick", children: "Poreclă (afișată în chat)" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          Input,
          {
            id: "p-nick",
            value: nickname,
            onChange: (e) => setNickname(e.target.value),
            placeholder: "ex: Andrei",
            maxLength: 40
          }
        )
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-name", children: "Nume complet" }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(
          Input,
          {
            id: "p-name",
            value: fullName,
            onChange: (e) => setFullName(e.target.value),
            required: true,
            maxLength: 80,
            autoComplete: "name"
          }
        )
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-4", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-h", children: "Înălțime (cm)" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Input,
            {
              id: "p-h",
              type: "number",
              inputMode: "numeric",
              min: HEIGHT_MIN,
              max: HEIGHT_MAX,
              value: heightCm,
              onChange: (e) => setHeightCm(e.target.value),
              className: "font-num"
            }
          )
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { htmlFor: "p-g", children: "Greutate țintă (kg)" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(
            Input,
            {
              id: "p-g",
              type: "number",
              step: "0.1",
              inputMode: "decimal",
              min: WEIGHT_MIN,
              max: WEIGHT_MAX,
              value: goalKg,
              onChange: (e) => setGoalKg(e.target.value),
              className: "font-num"
            }
          )
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", disabled: saving, className: "rounded-full", children: saving ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(LoaderCircle, { className: "h-4 w-4 mr-2 animate-spin" }),
        "Se salvează…"
      ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(Save, { className: "h-4 w-4 mr-2" }),
        "Salvează profilul"
      ] }) })
    ] })
  ] });
}
function Dashboard() {
  const {
    user,
    loading,
    isAdmin
  } = useAuth();
  const navigate = useNavigate();
  const [profile, setProfile] = reactExports.useState(null);
  const [unread, setUnread] = reactExports.useState(0);
  const [groupUnread, setGroupUnread] = reactExports.useState({});
  const [activeTab, setActiveTab] = reactExports.useState("weight");
  const [groups, setGroups] = reactExports.useState([]);
  const [chatTab, setChatTab] = reactExports.useState("coach");
  const activeTabRef = reactExports.useRef(activeTab);
  const chatTabRef = reactExports.useRef(chatTab);
  reactExports.useEffect(() => {
    activeTabRef.current = activeTab;
  }, [activeTab]);
  reactExports.useEffect(() => {
    chatTabRef.current = chatTab;
  }, [chatTab]);
  reactExports.useEffect(() => {
    if (!loading && !user) navigate({
      to: "/auth"
    });
    if (!loading && isAdmin) navigate({
      to: "/admin"
    });
  }, [user, loading, isAdmin, navigate]);
  reactExports.useEffect(() => {
    if (!user) return;
    supabase.from("profiles").select("full_name,nickname,avatar_url,goal_weight_kg,current_weight_kg,onboarding_completed").eq("id", user.id).maybeSingle().then(({
      data
    }) => {
      setProfile(data);
      if (data && !data.onboarding_completed) navigate({
        to: "/onboarding"
      });
    });
  }, [user, navigate]);
  reactExports.useEffect(() => {
    if (!user) return;
    supabase.from("chat_group_members").select("group_id, chat_groups(id,name,avatar_url)").eq("user_id", user.id).then(({
      data
    }) => {
      const list = (data ?? []).map((r) => r.chat_groups).filter((g) => !!g);
      setGroups(list);
    });
  }, [user]);
  reactExports.useEffect(() => {
    if (!user) return;
    const load = async () => {
      const {
        count
      } = await supabase.from("messages").select("id", {
        count: "exact",
        head: true
      }).eq("client_id", user.id).neq("sender_id", user.id).is("read_at", null);
      setUnread(count ?? 0);
    };
    load();
    const ch = supabase.channel(`unread:${user.id}`).on("postgres_changes", {
      event: "*",
      schema: "public",
      table: "messages",
      filter: `client_id=eq.${user.id}`
    }, () => load()).subscribe();
    return () => {
      supabase.removeChannel(ch);
    };
  }, [user]);
  reactExports.useEffect(() => {
    if (!user || groups.length === 0) return;
    const lastSeenKey = (gid) => `lastSeen:group:${user.id}:${gid}`;
    const getSeen = (gid) => Number(localStorage.getItem(lastSeenKey(gid)) || 0);
    (async () => {
      const counts = {};
      await Promise.all(groups.map(async (g) => {
        const since = new Date(getSeen(g.id) || 0).toISOString();
        const {
          count
        } = await supabase.from("messages").select("id", {
          count: "exact",
          head: true
        }).eq("group_id", g.id).neq("sender_id", user.id).gt("created_at", since);
        counts[g.id] = count ?? 0;
      }));
      setGroupUnread(counts);
    })();
    if (typeof window !== "undefined" && "Notification" in window && Notification.permission === "default") {
      Notification.requestPermission().catch(() => void 0);
    }
    const channels = groups.map((g) => supabase.channel(`group-notif:${g.id}:${user.id}`).on("postgres_changes", {
      event: "INSERT",
      schema: "public",
      table: "messages",
      filter: `group_id=eq.${g.id}`
    }, async (payload) => {
      const msg = payload.new;
      if (msg.sender_id === user.id) return;
      const isViewing = activeTabRef.current === "chat" && chatTabRef.current === g.id && !document.hidden;
      if (isViewing) {
        localStorage.setItem(lastSeenKey(g.id), String(Date.now()));
        return;
      }
      const {
        data: sender
      } = await supabase.from("profiles").select("nickname,full_name").eq("id", msg.sender_id).maybeSingle();
      const senderName = sender?.nickname || sender?.full_name || "Cineva";
      const preview = msg.content || (msg.media_type ? `Media: ${msg.media_type}` : "Mesaj nou");
      setGroupUnread((u) => ({
        ...u,
        [g.id]: (u[g.id] ?? 0) + 1
      }));
      toast.message(g.name, {
        description: `${senderName}: ${preview.slice(0, 80)}`,
        action: {
          label: "Deschide",
          onClick: () => {
            setActiveTab("chat");
            setChatTab(g.id);
          }
        }
      });
      if (typeof window !== "undefined" && "Notification" in window && Notification.permission === "granted" && document.hidden) {
        try {
          const n = new Notification(`${g.name} - ${senderName}`, {
            body: preview.slice(0, 140),
            tag: `group-${g.id}`,
            icon: "/favicon.svg"
          });
          n.onclick = () => {
            window.focus();
            setActiveTab("chat");
            setChatTab(g.id);
            n.close();
          };
        } catch {
        }
      }
    }).subscribe());
    return () => {
      channels.forEach((ch) => supabase.removeChannel(ch));
    };
  }, [user, groups]);
  reactExports.useEffect(() => {
    if (!user || activeTab !== "chat" || chatTab === "coach") return;
    localStorage.setItem(`lastSeen:group:${user.id}:${chatTab}`, String(Date.now()));
    setGroupUnread((u) => ({
      ...u,
      [chatTab]: 0
    }));
  }, [user, activeTab, chatTab]);
  const totalGroupUnread = reactExports.useMemo(() => Object.values(groupUnread).reduce((s, n) => s + n, 0), [groupUnread]);
  const totalUnread = unread + totalGroupUnread;
  if (!user) return null;
  const greeting = profile?.nickname || profile?.full_name || "client";
  const goal = profile?.goal_weight_kg;
  const current = profile?.current_weight_kg;
  const delta = goal != null && current != null ? +(current - goal).toFixed(1) : null;
  return /* @__PURE__ */ jsxRuntimeExports.jsx("main", { className: "bg-soft min-h-[calc(100svh-4rem)]", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "container mx-auto px-3 sm:px-4 py-6 sm:py-10 max-w-5xl", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsxs("header", { className: "relative overflow-hidden rounded-3xl border border-border bg-card p-5 sm:p-8 shadow-[var(--shadow-card)] mb-6", children: [
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute -right-16 -top-16 h-56 w-56 rounded-full bg-primary/10 blur-3xl" }),
      /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "aria-hidden": true, className: "absolute -left-10 -bottom-10 h-44 w-44 rounded-full bg-accent/10 blur-3xl" }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex flex-col sm:flex-row sm:items-center gap-5 sm:gap-6", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(Avatar, { className: "h-16 w-16 ring-2 ring-primary/15 ring-offset-2 ring-offset-card", children: [
          profile?.avatar_url && /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarImage, { src: profile.avatar_url }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(AvatarFallback, { className: "bg-primary/15 text-primary font-display font-bold text-lg", children: greeting.slice(0, 2).toUpperCase() })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-medium uppercase tracking-[0.18em] text-primary mb-1", children: salutation() }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("h1", { className: "font-display text-3xl sm:text-4xl font-bold tracking-tight", children: greeting }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Vezi-ți progresul și discută cu coach-ul tău." })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-3 gap-3 sm:gap-4 shrink-0", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(Stat, { label: "Curent", value: current != null ? `${current.toFixed(1)} kg` : "-" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Stat, { label: "Țintă", value: goal != null ? `${goal.toFixed(1)} kg` : "-" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx(Stat, { label: "Δ", value: delta != null ? `${delta > 0 ? "-" : "+"}${Math.abs(delta).toFixed(1)} kg` : "-", tone: delta != null ? delta > 0 ? "warning" : "success" : "muted" })
        ] })
      ] })
    ] }),
    /* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: activeTab, onValueChange: (v) => {
      setActiveTab(v);
      if (v === "chat") setUnread(0);
    }, children: [
      /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "w-full grid grid-cols-3 h-auto bg-card p-1.5 rounded-2xl border shadow-[var(--shadow-card)]", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "weight", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl data-[state=active]:shadow-sm", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(TrendingUp, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hidden xs:inline sm:inline", children: "Progres" })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "chat", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl data-[state=active]:shadow-sm relative", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(MessageCircle, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hidden xs:inline sm:inline", children: "Chat" }),
          totalUnread > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-1 inline-flex items-center justify-center min-w-[18px] h-[18px] text-[10px] font-bold bg-destructive text-destructive-foreground rounded-full px-1.5", children: totalUnread > 99 ? "99+" : totalUnread })
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "profile", className: "gap-1.5 text-xs sm:text-sm py-2.5 rounded-xl data-[state=active]:shadow-sm", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsx(User, { className: "h-4 w-4" }),
          /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "hidden xs:inline sm:inline", children: "Profil" })
        ] })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsContent, { value: "weight", className: "mt-5 space-y-5", children: [
        /* @__PURE__ */ jsxRuntimeExports.jsx(TargetsPanel, { clientId: user.id, isAdmin: false, currentUserId: user.id }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(WeightTracker, { userId: user.id, goalKg: profile?.goal_weight_kg })
      ] }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "chat", className: "mt-5 space-y-3", children: groups.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tabs, { value: chatTab, onValueChange: setChatTab, children: [
        /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsList, { className: "w-full overflow-x-auto flex-wrap h-auto bg-card p-1.5 rounded-2xl border shadow-[var(--shadow-card)]", children: [
          /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: "coach", className: "gap-1.5 text-xs sm:text-sm rounded-xl", children: [
            "Coach",
            unread > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-1 inline-flex items-center justify-center min-w-[18px] h-[18px] text-[10px] font-bold bg-destructive text-destructive-foreground rounded-full px-1.5", children: unread })
          ] }),
          groups.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsxs(TabsTrigger, { value: g.id, className: "gap-1.5 text-xs sm:text-sm rounded-xl", children: [
            /* @__PURE__ */ jsxRuntimeExports.jsx(Users, { className: "h-3.5 w-3.5" }),
            g.name,
            (groupUnread[g.id] ?? 0) > 0 && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-1 inline-flex items-center justify-center min-w-[18px] h-[18px] text-[10px] font-bold bg-destructive text-destructive-foreground rounded-full px-1.5", children: groupUnread[g.id] })
          ] }, g.id))
        ] }),
        /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "coach", className: "mt-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Chat, { clientId: user.id, currentUserId: user.id, isAdmin: false }) }),
        groups.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: g.id, className: "mt-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Chat, { groupId: g.id, currentUserId: user.id, isAdmin: false }) }, g.id))
      ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Chat, { clientId: user.id, currentUserId: user.id, isAdmin: false }) }),
      /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "profile", className: "mt-5", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ProfileEditor, { userId: user.id }) })
    ] })
  ] }) });
}
function Stat({
  label,
  value,
  tone = "muted"
}) {
  const color = tone === "success" ? "text-success" : tone === "warning" ? "text-warning" : "text-foreground";
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "rounded-xl bg-muted/60 px-3 py-2 text-center min-w-[72px]", children: [
    /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: label }),
    /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `font-display font-bold text-base sm:text-lg font-num ${color}`, children: value })
  ] });
}
function salutation() {
  if (typeof window === "undefined") return "Bună";
  const h = (/* @__PURE__ */ new Date()).getHours();
  if (h < 6) return "Bună noapte";
  if (h < 11) return "Bună dimineața";
  if (h < 18) return "Bună ziua";
  return "Bună seara";
}
export {
  Dashboard as component
};
