{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "core-user-avatar",
  "type": "registry:lib",
  "title": "core/user-avatar",
  "description": "Framework-free behaviour shared by the ui-* components (user-avatar); no DOM, no lit. Copied from @purpurabog/ui 2.3.0; the package is the maintained source, this copy is yours to change. Icons from the Carbon Design System (Apache-2.0, © IBM Corp.; see THIRD-PARTY-NOTICES.md in the package).",
  "dependencies": [],
  "registryDependencies": [],
  "files": [
    {
      "path": "src/core/user-avatar.ts",
      "type": "registry:lib",
      "target": "components/ui/core/user-avatar.ts",
      "content": "/** Carbon `UserAvatar` sizes: sm 24px, md 32px, lg 48px, xl 64px. */\nexport type UserAvatarSize = 'sm' | 'md' | 'lg' | 'xl';\n\n/**\n * Carbon `UserAvatar` background colours, in Carbon's order: 1–6 the 60 grades (50 on g90 / g100), 7–12 the 80\n * grades (30 on g90 / g100) — `--ui-avatar-1` … `--ui-avatar-12`.\n */\nexport const USER_AVATAR_COLORS = [\n    'order-1-cyan',\n    'order-2-gray',\n    'order-3-green',\n    'order-4-magenta',\n    'order-5-purple',\n    'order-6-teal',\n    'order-7-cyan',\n    'order-8-gray',\n    'order-9-green',\n    'order-10-magenta',\n    'order-11-purple',\n    'order-12-teal',\n] as const;\n\nexport type UserAvatarColor = (typeof USER_AVATAR_COLORS)[number];\n\n/** The `--ui-avatar-*` token of a colour (unknown names fall back to the first, as Carbon's default). */\nexport function avatarColorToken(color: string | undefined): string {\n    const index = USER_AVATAR_COLORS.indexOf(color as UserAvatarColor);\n    return `--ui-avatar-${Math.max(index, 0) + 1}`;\n}\n\n/** Each size in px. */\nexport const USER_AVATAR_PX: Record<UserAvatarSize, number> = { sm: 24, md: 32, lg: 48, xl: 64 };\n\n/** The icon's size in each avatar size (Carbon React: 16 / 20 / 24 / 32). */\nexport const USER_AVATAR_ICON_SIZE: Record<UserAvatarSize, number> = { sm: 16, md: 20, lg: 24, xl: 32 };\n\n/** Thai characters that are not consonants: vowels written before, above, below or after one, tone marks and signs (U+0E2F–U+0E4F). */\nconst THAI_NON_CONSONANTS = /[\\u0E2F-\\u0E4F]/gu;\n\n/**\n * Carbon's initials: one word gives its first two letters (\"thomas\" → \"TH\"), more give the first letter of the\n * first and of the last word (\"thomas j. watson\" → \"TW\"). Thai words count their consonants only, so a leading\n * vowel or a tone mark is never an initial (\"เกษม ใจดี\" → \"กจ\").\n */\nexport function avatarInitials(name: string | undefined): string {\n    const parts = (name ?? '').trim().split(/\\s+/).map((word) => word.replaceAll(THAI_NON_CONSONANTS, ''));\n    const first = parts[0] ?? '';\n    if (parts.length === 1) return first.slice(0, 2).toUpperCase();\n    return (first.charAt(0) + (parts.at(-1) ?? '').charAt(0)).toUpperCase();\n}\n"
    }
  ]
}
