{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "discord-chat-widget",
  "title": "Discord Chat Widget",
  "description": "A Discord-style chat bubble widget with a typing simulation, quick replies, a notification popup, member/online counts, and a launch-invite send flow.",
  "dependencies": [
    "clsx",
    "tailwind-merge"
  ],
  "files": [
    {
      "path": "registry/new-york/discord-chat-widget/discord-chat-widget.tsx",
      "content": "\"use client\";\n\nimport * as React from \"react\";\nimport { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nfunction cn(...inputs: ClassValue[]) {\n  return twMerge(clsx(inputs));\n}\n\nconst D_BLURPLE = \"#5865F2\";\n\nexport type DiscordAvailability = \"online\" | \"idle\" | \"dnd\" | \"offline\";\nexport type DiscordWidgetTheme = \"dark\" | \"light\";\nexport type DiscordWidgetPosition = \"bottom-right\" | \"bottom-left\";\n\nexport interface DiscordQuickReply {\n  label: string;\n  message: string;\n}\n\nexport interface DiscordChatWidgetProps {\n  serverName?: string;\n  serverAvatar?: string;\n  channelName?: string;\n  memberCount?: string;\n  onlineCount?: string;\n  agentName?: string;\n  inviteCode: string;\n  availability?: DiscordAvailability;\n  showBoostBadge?: boolean;\n  offlineMessage?: string;\n  greeting?: string;\n  quickReplies?: DiscordQuickReply[];\n  popupMessage?: string;\n  theme?: DiscordWidgetTheme;\n  accentColor?: string;\n  fontFamily?: string;\n  serverNameFontSize?: number;\n  greetingFontSize?: number;\n  quickReplyFontSize?: number;\n  inputFontSize?: number;\n  widgetBorderRadius?: number;\n  /** Fixed to the viewport corner (typical widget usage). Set false to render inline, e.g. inside a preview card. */\n  fixed?: boolean;\n  position?: DiscordWidgetPosition;\n  notificationCount?: number;\n  popupDelay?: number;\n  typingDuration?: number;\n  autoOpenDelay?: number;\n}\n\nconst STATUS_COLORS: Record<DiscordAvailability, string> = {\n  online: \"#3ba55d\",\n  idle: \"#faa81a\",\n  dnd: \"#ed4245\",\n  offline: \"#747f8d\",\n};\n\nfunction DiscordIcon({ size = 26, color = \"#fff\" }: { size?: number; color?: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 16 16\" fill={color}>\n      <path d=\"M13.545 2.907a13.227 13.227 0 0 0-3.257-1.011.05.05 0 0 0-.052.025c-.141.25-.297.577-.406.833a12.19 12.19 0 0 0-3.658 0 8.258 8.258 0 0 0-.412-.833.051.051 0 0 0-.052-.025c-1.125.194-2.22.534-3.257 1.011a.041.041 0 0 0-.021.018C.356 6.024-.213 9.047.066 12.032c.001.014.01.028.021.037a13.276 13.276 0 0 0 3.995 2.02.05.05 0 0 0 .056-.019c.308-.42.582-.863.818-1.329a.05.05 0 0 0-.01-.059.051.051 0 0 0-.018-.011 8.875 8.875 0 0 1-1.248-.595.05.05 0 0 1-.02-.066.051.051 0 0 1 .015-.019c.084-.063.168-.129.248-.195a.05.05 0 0 1 .051-.007c2.619 1.196 5.454 1.196 8.041 0a.052.052 0 0 1 .053.007c.08.066.164.132.248.195a.051.051 0 0 1-.004.085 8.254 8.254 0 0 1-1.249.594.05.05 0 0 0-.03.03.052.052 0 0 0 .003.041c.24.465.515.909.817 1.329a.05.05 0 0 0 .056.019 13.235 13.235 0 0 0 4.001-2.02.049.049 0 0 0 .021-.037c.334-3.451-.559-6.449-2.366-9.106a.034.034 0 0 0-.02-.019Zm-8.198 7.307c-.789 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.45.73 1.438 1.613 0 .888-.637 1.612-1.438 1.612Zm5.316 0c-.788 0-1.438-.724-1.438-1.612 0-.889.637-1.613 1.438-1.613.807 0 1.451.73 1.438 1.613 0 .888-.631 1.612-1.438 1.612Z\" />\n    </svg>\n  );\n}\n\nfunction HashIcon({ size = 13, color = \"#8e9297\" }: { size?: number; color?: string }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\" stroke={color} strokeWidth={2.5} strokeLinecap=\"round\">\n      <line x1=\"4\" y1=\"9\" x2=\"20\" y2=\"9\" />\n      <line x1=\"4\" y1=\"15\" x2=\"20\" y2=\"15\" />\n      <line x1=\"10\" y1=\"3\" x2=\"8\" y2=\"21\" />\n      <line x1=\"16\" y1=\"3\" x2=\"14\" y2=\"21\" />\n    </svg>\n  );\n}\n\nfunction CloseIcon({ color = \"#b9bbbe\", size = 18 }: { color?: string; size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"none\">\n      <path d=\"M18 6L6 18M6 6l12 12\" stroke={color} strokeWidth={2.5} strokeLinecap=\"round\" />\n    </svg>\n  );\n}\n\nfunction SendIcon({ color = \"#fff\" }: { color?: string }) {\n  return (\n    <svg width={18} height={18} viewBox=\"0 0 24 24\" fill=\"none\">\n      <path d=\"M22 2L11 13\" stroke={color} strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n      <path d=\"M22 2L15 22L11 13L2 9L22 2Z\" stroke={color} strokeWidth={2.2} strokeLinecap=\"round\" strokeLinejoin=\"round\" />\n    </svg>\n  );\n}\n\nfunction MembersIcon({ color = \"#8e9297\", size = 12 }: { color?: string; size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" fill={color}>\n      <path d=\"M16 11c1.66 0 2.99-1.34 2.99-3S17.66 5 16 5c-1.66 0-3 1.34-3 3s1.34 3 3 3zm-8 0c1.66 0 2.99-1.34 2.99-3S9.66 5 8 5C6.34 5 5 6.34 5 8s1.34 3 3 3zm0 2c-2.33 0-7 1.17-7 3.5V19h14v-2.5c0-2.33-4.67-3.5-7-3.5zm8 0c-.29 0-.62.02-.97.05 1.16.84 1.97 1.97 1.97 3.45V19h6v-2.5c0-2.33-4.67-3.5-7-3.5z\" />\n    </svg>\n  );\n}\n\nfunction BoostIcon({ size = 12 }: { size?: number }) {\n  return (\n    <svg width={size} height={size} viewBox=\"0 0 24 24\" fill=\"#f47fff\">\n      <path d=\"M12 2L9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.64-7.03L22 9.24l-7.19-.61z\" />\n    </svg>\n  );\n}\n\nfunction ServerIcon({\n  size,\n  avatarSrc,\n  accentColor,\n  serverName,\n  widgetBorderRadius,\n  fontFamily,\n}: {\n  size: number;\n  avatarSrc?: string;\n  accentColor: string;\n  serverName: string;\n  widgetBorderRadius: number;\n  fontFamily: string;\n}) {\n  const radius = widgetBorderRadius > 8 ? \"50%\" : 10;\n  return avatarSrc ? (\n    <img src={avatarSrc} alt=\"\" className=\"shrink-0 object-cover\" style={{ width: size, height: size, borderRadius: radius }} />\n  ) : (\n    <div\n      className=\"flex shrink-0 items-center justify-center font-bold text-white\"\n      style={{ width: size, height: size, background: accentColor, fontSize: size * 0.4, borderRadius: radius, fontFamily }}\n    >\n      {serverName.slice(0, 2).toUpperCase()}\n    </div>\n  );\n}\n\nfunction BotAvatar({ avatarSrc, accentColor }: { avatarSrc?: string; accentColor: string }) {\n  return avatarSrc ? (\n    <img src={avatarSrc} alt=\"\" className=\"h-9 w-9 shrink-0 rounded-full object-cover\" />\n  ) : (\n    <div className=\"flex h-9 w-9 shrink-0 items-center justify-center rounded-full\" style={{ background: accentColor }}>\n      <DiscordIcon size={18} />\n    </div>\n  );\n}\n\nfunction StatusDot({ outerSize = 14, dotSize = 10, borderColor, statusColor, isDnd }: { outerSize?: number; dotSize?: number; borderColor: string; statusColor: string; isDnd: boolean }) {\n  return (\n    <div className=\"relative shrink-0\" style={{ width: outerSize, height: outerSize }}>\n      <div className=\"absolute bottom-0 right-0 rounded-full\" style={{ width: dotSize, height: dotSize, background: statusColor, border: `2.5px solid ${borderColor}` }} />\n      {isDnd && <div className=\"absolute rounded-[1px]\" style={{ bottom: 3.5, right: 3.5, width: 4, height: 1.5, background: borderColor }} />}\n    </div>\n  );\n}\n\nconst DEFAULT_QUICK_REPLIES: DiscordQuickReply[] = [\n  { label: \"🎮  Join the server\", message: \"I'd like to join your server!\" },\n  { label: \"❓  Get support\", message: \"I need some help, please.\" },\n  { label: \"💬  General questions\", message: \"I have a general question.\" },\n];\n\nexport function DiscordChatWidget({\n  serverName = \"My Server\",\n  serverAvatar,\n  channelName = \"support\",\n  memberCount = \"1,204\",\n  onlineCount = \"47\",\n  agentName = \"Support Bot\",\n  inviteCode,\n  availability = \"online\",\n  showBoostBadge = false,\n  offlineMessage = \"We're currently offline. Join the server and leave a message, we'll get back to you!\",\n  greeting = \"Welcome! 👾\\n\\nNeed help? Our team is here.\\nJoin the server or send us a message!\",\n  quickReplies = DEFAULT_QUICK_REPLIES,\n  popupMessage = \"👾 Hey! Join our Discord server, we're online and ready to help.\",\n  theme = \"dark\",\n  accentColor = D_BLURPLE,\n  fontFamily = \"'gg sans', 'Noto Sans', Whitney, 'Helvetica Neue', Helvetica, Arial, sans-serif\",\n  serverNameFontSize = 15,\n  greetingFontSize = 14,\n  quickReplyFontSize = 13.5,\n  inputFontSize = 14,\n  widgetBorderRadius = 8,\n  fixed = true,\n  position = \"bottom-right\",\n  notificationCount = 1,\n  popupDelay = 4,\n  typingDuration = 1.5,\n  autoOpenDelay = 0,\n}: DiscordChatWidgetProps) {\n  const [isOpen, setIsOpen] = React.useState(false);\n  const [inputValue, setInputValue] = React.useState(\"\");\n  const [isVisible, setIsVisible] = React.useState(false);\n  const [showBadge, setShowBadge] = React.useState(notificationCount > 0);\n  const [msgTime, setMsgTime] = React.useState(\"Today at 12:00 AM\");\n  const [showPopup, setShowPopup] = React.useState(false);\n  const [popupDismissed, setPopupDismissed] = React.useState(false);\n  const [showTyping, setShowTyping] = React.useState(false);\n  const [greetingVisible, setGreetingVisible] = React.useState(false);\n\n  const inputRef = React.useRef<HTMLInputElement>(null);\n\n  const isDark = theme === \"dark\";\n  const isOffline = availability === \"offline\";\n  const isDnd = availability === \"dnd\";\n  const statusColor = STATUS_COLORS[availability];\n\n  const panelBg = isDark ? \"#2f3136\" : \"#ffffff\";\n  const headerBg = isDark ? \"#202225\" : \"#f2f3f5\";\n  const chatBg = isDark ? \"#36393f\" : \"#ffffff\";\n  const inputAreaBg = isDark ? \"#2f3136\" : \"#f2f3f5\";\n  const inputBg = isDark ? \"#40444b\" : \"#e3e5e8\";\n  const bubbleBg = isDark ? \"#32353b\" : \"#f2f3f5\";\n  const textPrimary = isDark ? \"#dcddde\" : \"#2e3338\";\n  const textMuted = isDark ? \"#72767d\" : \"#747f8d\";\n  const textHeader = isDark ? \"#ffffff\" : \"#060607\";\n  const border = isDark ? \"#202225\" : \"#e3e5e8\";\n  const hoverBg = isDark ? \"rgba(79,84,92,0.16)\" : \"rgba(0,0,0,0.06)\";\n\n  React.useEffect(() => setShowBadge(notificationCount > 0), [notificationCount]);\n\n  React.useEffect(() => {\n    const t = setTimeout(() => setIsVisible(true), 300);\n    return () => clearTimeout(t);\n  }, []);\n\n  React.useEffect(() => {\n    if (autoOpenDelay > 0) {\n      const t = setTimeout(() => setIsOpen(true), autoOpenDelay * 1000);\n      return () => clearTimeout(t);\n    }\n  }, [autoOpenDelay]);\n\n  React.useEffect(() => {\n    if (popupDelay > 0 && !popupDismissed) {\n      const t = setTimeout(() => {\n        if (!isOpen) setShowPopup(true);\n      }, popupDelay * 1000);\n      return () => clearTimeout(t);\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [popupDelay, popupDismissed]);\n\n  React.useEffect(() => {\n    if (isOpen) {\n      setShowBadge(false);\n      setShowPopup(false);\n\n      const now = new Date();\n      const hh = now.getHours();\n      const mm = now.getMinutes().toString().padStart(2, \"0\");\n      const period = hh >= 12 ? \"PM\" : \"AM\";\n      const h12 = hh % 12 || 12;\n      setMsgTime(`Today at ${h12}:${mm} ${period}`);\n\n      if (typingDuration > 0) {\n        setShowTyping(true);\n        setGreetingVisible(false);\n        const t = setTimeout(() => {\n          setShowTyping(false);\n          setGreetingVisible(true);\n        }, typingDuration * 1000);\n        const f = setTimeout(() => inputRef.current?.focus(), 420);\n        return () => {\n          clearTimeout(t);\n          clearTimeout(f);\n        };\n      }\n      setShowTyping(false);\n      setGreetingVisible(true);\n      const f = setTimeout(() => inputRef.current?.focus(), 420);\n      return () => clearTimeout(f);\n    }\n    setShowTyping(false);\n    setGreetingVisible(false);\n  }, [isOpen, typingDuration]);\n\n  const handleOpen = () => setIsOpen(true);\n  const handleClose = () => setIsOpen(false);\n  const handleDismissPopup = (e: React.MouseEvent) => {\n    e.stopPropagation();\n    setShowPopup(false);\n    setPopupDismissed(true);\n  };\n  const openDiscord = () => {\n    const code = inviteCode.replace(/^(https?:\\/\\/)?(discord\\.gg\\/|discord\\.com\\/invite\\/)/, \"\");\n    window.open(`https://discord.gg/${code}`, \"_blank\");\n  };\n  const handleSend = () => {\n    const msg = inputValue.trim();\n    if (!msg) return;\n    openDiscord();\n    setInputValue(\"\");\n  };\n  const handleQuickReply = (qr: DiscordQuickReply) => {\n    setInputValue(qr.message);\n    setTimeout(() => inputRef.current?.focus(), 50);\n  };\n\n  const isRight = position !== \"bottom-left\";\n  const chatOrigin = isRight ? \"bottom right\" : \"bottom left\";\n  // Never wider than the viewport: leave the corner offset on both sides when fixed,\n  // and a bit more slack when inline (the surrounding layout may add its own padding).\n  const panelMaxWidth = fixed ? \"calc(100vw - 3rem)\" : \"calc(100vw - 5rem)\";\n\n  return (\n    <div\n      className={cn(fixed ? \"fixed bottom-6 z-[99999]\" : \"relative\", isRight ? \"right-6\" : \"left-6\")}\n      style={{ fontFamily, ...(fixed ? undefined : { display: \"inline-block\" }) }}\n    >\n      {showPopup && !isOpen && (\n        <div\n          onClick={handleOpen}\n          className={cn(\"absolute bottom-[76px] w-[300px] cursor-pointer overflow-hidden border\", isRight ? \"right-0\" : \"left-0\")}\n          style={{\n            maxWidth: panelMaxWidth,\n            background: panelBg,\n            borderColor: border,\n            borderRadius: widgetBorderRadius + 4,\n            boxShadow: isDark ? \"0 16px 48px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.4)\" : \"0 16px 48px rgba(0,0,0,0.14), 0 4px 16px rgba(0,0,0,0.08)\",\n            animation: \"dc-popup-in 0.42s cubic-bezier(0.34,1.56,0.64,1) forwards\",\n          }}\n        >\n          <div className=\"flex items-center gap-2.5 border-b px-3.5 py-3\" style={{ background: headerBg, borderColor: border }}>\n            <div className=\"relative shrink-0\">\n              <ServerIcon size={36} avatarSrc={serverAvatar} accentColor={accentColor} serverName={serverName} widgetBorderRadius={widgetBorderRadius} fontFamily={fontFamily} />\n              <div className=\"absolute -bottom-0.5 -right-0.5\">\n                <StatusDot outerSize={14} dotSize={10} borderColor={headerBg} statusColor={statusColor} isDnd={isDnd} />\n              </div>\n            </div>\n            <div className=\"min-w-0 flex-1\">\n              <div className=\"flex items-center gap-1.5 font-bold\" style={{ color: textHeader, fontSize: serverNameFontSize - 2 }}>\n                {serverName}\n                {showBoostBadge && <BoostIcon size={11} />}\n              </div>\n              <div className=\"mt-px flex items-center gap-1 text-[11px]\" style={{ color: textMuted }}>\n                <span className=\"h-1.5 w-1.5 shrink-0 rounded-full bg-[#3ba55d]\" />\n                {onlineCount} online\n                <span className=\"opacity-50\">·</span>\n                <MembersIcon color={textMuted} />\n                {memberCount}\n              </div>\n            </div>\n            <button\n              aria-label=\"Dismiss notification\" onClick={handleDismissPopup}\n              className=\"flex h-7 w-7 shrink-0 items-center justify-center rounded transition-colors\"\n              style={{ background: \"none\", transitionTimingFunction: \"ease\" }}\n              onMouseEnter={(e) => (e.currentTarget.style.background = hoverBg)}\n              onMouseLeave={(e) => (e.currentTarget.style.background = \"none\")}\n            >\n              <CloseIcon size={14} color={textMuted} />\n            </button>\n          </div>\n          <div className=\"px-3.5 pb-3.5 pt-3\" style={{ background: chatBg }}>\n            <div className=\"flex items-start gap-2.5\">\n              <BotAvatar avatarSrc={serverAvatar} accentColor={accentColor} />\n              <div>\n                <div className=\"mb-1 flex items-baseline gap-1.5\">\n                  <span className=\"font-semibold\" style={{ color: textHeader, fontSize: greetingFontSize }}>{agentName}</span>\n                  <span className=\"rounded px-1 py-px text-[9px] font-bold tracking-wide text-white\" style={{ background: accentColor }}>BOT</span>\n                </div>\n                <div className=\"inline-block max-w-full rounded-[0_8px_8px_8px] px-3 py-2.5 leading-relaxed\" style={{ background: bubbleBg, color: textPrimary, fontSize: greetingFontSize - 0.5 }}>\n                  {popupMessage}\n                </div>\n              </div>\n            </div>\n            <div className={cn(\"mt-2.5 text-[11.5px]\", isRight ? \"text-right\" : \"text-left\")} style={{ color: textMuted }}>\n              Click to join server →\n            </div>\n          </div>\n        </div>\n      )}\n\n      <div\n        className={cn(\"absolute bottom-[76px] flex w-[380px] flex-col overflow-hidden border\", isRight ? \"right-0\" : \"left-0\")}\n        style={{\n          maxWidth: panelMaxWidth,\n          maxHeight: \"calc(100dvh - 100px)\",\n          background: panelBg,\n          borderColor: border,\n          borderRadius: widgetBorderRadius + 4,\n          boxShadow: isOpen ? (isDark ? \"0 24px 72px rgba(0,0,0,0.6), 0 8px 24px rgba(0,0,0,0.5)\" : \"0 24px 72px rgba(0,0,0,0.16), 0 8px 24px rgba(0,0,0,0.1)\") : \"none\",\n          transformOrigin: chatOrigin,\n          transform: isOpen ? \"scale(1) translateY(0px)\" : \"scale(0.72) translateY(24px)\",\n          opacity: isOpen ? 1 : 0,\n          filter: isOpen ? \"blur(0px)\" : \"blur(6px)\",\n          pointerEvents: isOpen ? \"all\" : \"none\",\n          transition: isOpen\n            ? \"transform 0.45s cubic-bezier(0.34,1.56,0.64,1), opacity 0.28s ease, filter 0.28s ease, box-shadow 0.3s ease\"\n            : \"transform 0.3s cubic-bezier(0.4,0,0.2,1), opacity 0.22s ease, filter 0.22s ease\",\n        }}\n      >\n        <div className=\"border-b\" style={{ background: headerBg, borderColor: border }}>\n          <div className=\"flex items-center gap-2.5 px-4 pb-2.5 pt-3\">\n            <div className=\"relative shrink-0\">\n              <ServerIcon size={42} avatarSrc={serverAvatar} accentColor={accentColor} serverName={serverName} widgetBorderRadius={widgetBorderRadius} fontFamily={fontFamily} />\n              <div className=\"absolute -bottom-0.5 -right-0.5\">\n                <StatusDot outerSize={16} dotSize={12} borderColor={headerBg} statusColor={statusColor} isDnd={isDnd} />\n              </div>\n            </div>\n            <div className=\"min-w-0 flex-1\">\n              <div className=\"flex items-center gap-1.5\">\n                <span className=\"font-bold leading-tight tracking-tight\" style={{ color: textHeader, fontSize: serverNameFontSize }}>{serverName}</span>\n                {showBoostBadge && <BoostIcon size={13} />}\n              </div>\n              <div className=\"mt-0.5 flex items-center gap-2\">\n                <div className=\"flex items-center gap-1\">\n                  <span className=\"h-1.5 w-1.5 rounded-full bg-[#3ba55d]\" />\n                  <span className=\"text-xs\" style={{ color: textMuted }}>{onlineCount} online</span>\n                </div>\n                <div className=\"flex items-center gap-1\">\n                  <MembersIcon color={textMuted} />\n                  <span className=\"text-xs\" style={{ color: textMuted }}>{memberCount} members</span>\n                </div>\n              </div>\n            </div>\n            <button\n              aria-label=\"Close chat\" onClick={handleClose}\n              className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded transition-all hover:scale-110\"\n              style={{ transitionTimingFunction: \"ease\" }}\n              onMouseEnter={(e) => (e.currentTarget.style.background = hoverBg)}\n              onMouseLeave={(e) => (e.currentTarget.style.background = \"none\")}\n            >\n              <CloseIcon color={textMuted} size={17} />\n            </button>\n          </div>\n          <div className=\"flex items-center gap-1 px-4 pb-2.5\">\n            <div className=\"flex items-center gap-1 rounded-2xl py-[3px] pl-[7px] pr-2.5\" style={{ background: isDark ? \"rgba(79,84,92,0.3)\" : \"rgba(0,0,0,0.07)\" }}>\n              <HashIcon color={textMuted} />\n              <span className=\"text-xs font-semibold\" style={{ color: textMuted }}>{channelName}</span>\n            </div>\n          </div>\n        </div>\n\n        {isOffline && (\n          <div className=\"flex items-start gap-1.5 border-b px-3.5 py-2.5\" style={{ background: isDark ? \"#1a1c1f\" : \"#fef3c7\", borderColor: isDark ? \"#2f3136\" : \"#fde68a\", color: isDark ? textMuted : \"#92400e\", fontSize: greetingFontSize - 1.5 }}>\n            <span className=\"shrink-0 text-sm\">🔔</span>\n            <span>{offlineMessage}</span>\n          </div>\n        )}\n        {isDnd && (\n          <div className=\"flex items-center gap-1.5 border-b px-3.5 py-2\" style={{ background: isDark ? \"rgba(237,66,69,0.12)\" : \"#fef2f2\", borderColor: isDark ? \"rgba(237,66,69,0.2)\" : \"#fca5a5\", color: isDark ? \"#f87171\" : \"#b91c1c\", fontSize: greetingFontSize - 1.5 }}>\n            <span className=\"text-[13px]\">🔴</span>\n            <span>Do Not Disturb, responses may be delayed.</span>\n          </div>\n        )}\n\n        <div className=\"flex max-h-[320px] min-h-[min(220px,calc(100dvh-330px))] flex-col gap-0.5 overflow-y-auto px-4 py-4\" style={{ background: chatBg }}>\n          {showTyping && (\n            <div className=\"flex items-start gap-3 py-1\" style={{ animation: \"dc-msg-in 0.28s ease forwards\" }}>\n              <BotAvatar avatarSrc={serverAvatar} accentColor={accentColor} />\n              <div>\n                <div className=\"mb-1 flex items-baseline gap-1.5\">\n                  <span className=\"font-semibold\" style={{ color: textHeader, fontSize: greetingFontSize }}>{agentName}</span>\n                  <span className=\"rounded px-1 py-px text-[9px] font-bold text-white\" style={{ background: accentColor }}>BOT</span>\n                </div>\n                <div className=\"inline-flex items-center gap-1.5 rounded-[0_8px_8px_8px] px-3.5 py-2.5\" style={{ background: bubbleBg }}>\n                  <span className=\"h-[7px] w-[7px] animate-[dc-dot_1.2s_ease-in-out_0s_infinite] rounded-full\" style={{ background: textMuted }} />\n                  <span className=\"h-[7px] w-[7px] animate-[dc-dot_1.2s_ease-in-out_0.2s_infinite] rounded-full\" style={{ background: textMuted }} />\n                  <span className=\"h-[7px] w-[7px] animate-[dc-dot_1.2s_ease-in-out_0.4s_infinite] rounded-full\" style={{ background: textMuted }} />\n                </div>\n              </div>\n            </div>\n          )}\n\n          {greetingVisible && (\n            <div className=\"flex items-start gap-3 py-1\" style={{ animation: \"dc-msg-in 0.35s cubic-bezier(0.34,1.2,0.64,1) forwards\" }}>\n              <BotAvatar avatarSrc={serverAvatar} accentColor={accentColor} />\n              <div className=\"flex-1\">\n                <div className=\"mb-1 flex items-baseline gap-1.5\">\n                  <span className=\"font-semibold\" style={{ color: textHeader, fontSize: greetingFontSize }}>{agentName}</span>\n                  <span className=\"rounded px-1 py-px text-[9px] font-bold text-white\" style={{ background: accentColor }}>BOT</span>\n                  <span className=\"text-[11px]\" style={{ color: textMuted }}>{msgTime}</span>\n                </div>\n                <p className=\"whitespace-pre-line leading-relaxed\" style={{ color: textPrimary, fontSize: greetingFontSize }}>{greeting}</p>\n              </div>\n            </div>\n          )}\n\n          {greetingVisible && quickReplies.length > 0 && (\n            <div className=\"ml-12 mt-2.5 flex flex-col gap-1.5\" style={{ animation: \"dc-msg-in 0.38s cubic-bezier(0.34,1.2,0.64,1) 0.08s both\" }}>\n              {quickReplies.map((qr, i) => (\n                <button\n                  key={i}\n                  onClick={() => handleQuickReply(qr)}\n                  className=\"flex items-center gap-2 rounded border-[1.5px] px-3.5 py-2 text-left font-medium transition-all\"\n                  style={{ borderColor: isDark ? \"rgba(79,84,92,0.6)\" : \"#d4d7dc\", color: textPrimary, fontSize: quickReplyFontSize, fontFamily, transitionTimingFunction: \"ease\" }}\n                  onMouseEnter={(e) => {\n                    e.currentTarget.style.background = hoverBg;\n                    e.currentTarget.style.borderColor = isDark ? \"rgba(79,84,92,1)\" : \"#b9bbbe\";\n                    e.currentTarget.style.color = textHeader;\n                  }}\n                  onMouseLeave={(e) => {\n                    e.currentTarget.style.background = \"transparent\";\n                    e.currentTarget.style.borderColor = isDark ? \"rgba(79,84,92,0.6)\" : \"#d4d7dc\";\n                    e.currentTarget.style.color = textPrimary;\n                  }}\n                >\n                  {qr.label}\n                </button>\n              ))}\n\n              <button\n                aria-label=\"Open in Discord\" onClick={openDiscord}\n                className=\"mt-1 flex items-center justify-center gap-2 rounded px-3.5 py-2.5 text-center font-bold text-white transition-all\"\n                style={{ background: accentColor, boxShadow: `0 4px 16px ${accentColor}55`, fontSize: quickReplyFontSize, fontFamily, transitionTimingFunction: \"ease\" }}\n                onMouseEnter={(e) => {\n                  e.currentTarget.style.filter = \"brightness(1.12)\";\n                  e.currentTarget.style.transform = \"translateY(-1px)\";\n                  e.currentTarget.style.boxShadow = `0 6px 20px ${accentColor}77`;\n                }}\n                onMouseLeave={(e) => {\n                  e.currentTarget.style.filter = \"brightness(1)\";\n                  e.currentTarget.style.transform = \"translateY(0)\";\n                  e.currentTarget.style.boxShadow = `0 4px 16px ${accentColor}55`;\n                }}\n              >\n                <DiscordIcon size={16} />\n                Join Server\n              </button>\n            </div>\n          )}\n        </div>\n\n        <div className=\"border-t px-4 py-3\" style={{ background: inputAreaBg, borderColor: border }}>\n          <div className=\"flex items-center gap-2 rounded-lg px-2.5\" style={{ background: inputBg }}>\n            <input aria-label=\"Type a message\"\n              ref={inputRef}\n              value={inputValue}\n              onChange={(e) => setInputValue(e.target.value)}\n              onKeyDown={(e) => e.key === \"Enter\" && handleSend()}\n              placeholder={`Message #${channelName}`}\n              className=\"flex-1 border-none bg-transparent py-2.5 outline-none\"\n              style={{ color: textPrimary, fontSize: inputFontSize, fontFamily }}\n            />\n            <button\n              aria-label=\"Send message\" onClick={handleSend}\n              className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded transition-all\"\n              style={{ background: inputValue.trim() ? accentColor : \"transparent\", cursor: inputValue.trim() ? \"pointer\" : \"default\", transitionTimingFunction: \"ease\" }}\n              onMouseEnter={(e) => {\n                if (inputValue.trim()) e.currentTarget.style.transform = \"scale(1.12)\";\n              }}\n              onMouseLeave={(e) => (e.currentTarget.style.transform = \"scale(1)\")}\n            >\n              <SendIcon color={inputValue.trim() ? \"#fff\" : textMuted} />\n            </button>\n          </div>\n        </div>\n\n        <div className=\"flex items-center justify-center gap-1.5 border-t py-2 text-center text-[11px]\" style={{ background: inputAreaBg, borderColor: border, color: textMuted }}>\n          <DiscordIcon size={11} color={textMuted} />\n          <span>Powered by Discord</span>\n        </div>\n      </div>\n\n      <div className=\"relative inline-flex\">\n        <button\n          aria-label={isOpen ? \"Close chat\" : \"Open chat\"} onClick={isOpen ? handleClose : handleOpen}\n          className=\"relative flex h-[60px] w-[60px] items-center justify-center overflow-hidden rounded-full\"\n          style={{\n            background: isOpen ? \"linear-gradient(135deg, #ff6b6b, #ee5a24)\" : isOffline ? \"linear-gradient(135deg, #4e5058, #36393f)\" : `linear-gradient(135deg, ${accentColor}, #7289da)`,\n            boxShadow: isOpen ? \"0 6px 24px rgba(238,90,36,0.45)\" : `0 8px 28px ${accentColor}70`,\n            transform: isVisible ? \"scale(1)\" : \"scale(0)\",\n            opacity: isVisible ? 1 : 0,\n            transition: \"transform 0.4s cubic-bezier(0.34,1.56,0.64,1), opacity 0.3s ease, background 0.4s ease, box-shadow 0.3s ease\",\n          }}\n          // Source drives the hover scale imperatively via the same\n          // `transform` property used for the mount pop-in animation — a\n          // Tailwind `hover:scale-110` class can't win here since an\n          // inline `style.transform` always overrides a stylesheet rule,\n          // pseudo-class included.\n          onMouseEnter={(e) => (e.currentTarget.style.transform = \"scale(1.1)\")}\n          onMouseLeave={(e) => (e.currentTarget.style.transform = \"scale(1)\")}\n        >\n          <span\n            className=\"pointer-events-none absolute inset-0 rounded-full bg-white/15\"\n            style={{ transform: \"scale(0)\", animation: isOpen ? \"dc-ripple 0.4s ease-out forwards\" : \"none\" }}\n          />\n          {!isOpen && !isOffline && (\n            <>\n              <div className=\"pointer-events-none absolute -inset-[5px] animate-[dc-pulse_2.4s_ease-in-out_1.2s_infinite] rounded-full border-2\" style={{ borderColor: accentColor }} />\n              <div className=\"pointer-events-none absolute -inset-[11px] animate-[dc-pulse_2.4s_ease-in-out_1.8s_infinite] rounded-full border opacity-40\" style={{ borderColor: \"#7289da\" }} />\n            </>\n          )}\n          <div className=\"pointer-events-none absolute transition-all duration-[350ms]\" style={{ transform: isOpen ? \"rotate(-90deg) scale(0.3)\" : \"rotate(0deg) scale(1)\", opacity: isOpen ? 0 : 1 }}>\n            <DiscordIcon size={28} />\n          </div>\n          <div className=\"pointer-events-none absolute transition-all duration-[350ms]\" style={{ transform: isOpen ? \"rotate(0deg) scale(1)\" : \"rotate(90deg) scale(0.3)\", opacity: isOpen ? 1 : 0 }}>\n            <CloseIcon color=\"#fff\" size={22} />\n          </div>\n        </button>\n\n        {!isOpen && showBadge && notificationCount > 0 && (\n          <div\n            className=\"pointer-events-none absolute -right-1 -top-1 z-[1] flex h-5 min-w-5 items-center justify-center rounded-full border-[2.5px] border-white bg-[#ed4245] px-1.5 text-[11px] font-bold text-white shadow-[0_2px_8px_rgba(237,66,69,0.6)]\"\n            style={{ animation: \"dc-badge-pop 0.5s cubic-bezier(0.34,1.56,0.64,1) 1.1s both\" }}\n          >\n            {notificationCount > 9 ? \"9+\" : notificationCount}\n          </div>\n        )}\n      </div>\n\n      <style>{`\n        @keyframes dc-pulse { 0% { transform: scale(1); opacity: 0.55; } 70% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1.6); opacity: 0; } }\n        @keyframes dc-ripple { 0% { transform: scale(0); opacity: 1; } 100% { transform: scale(2.5); opacity: 0; } }\n        @keyframes dc-dot { 0%, 60%, 100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-5px); opacity: 1; } }\n        @keyframes dc-msg-in { from { transform: translateY(10px) scale(0.97); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }\n        @keyframes dc-popup-in { from { transform: translateY(18px) scale(0.88); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }\n        @keyframes dc-badge-pop { 0% { transform: scale(0) rotate(-20deg); } 70% { transform: scale(1.25) rotate(5deg); } 100% { transform: scale(1) rotate(0deg); } }\n      `}</style>\n    </div>\n  );\n}\n",
      "type": "registry:component"
    }
  ],
  "type": "registry:component"
}