{"version":3,"file":"User.cjs","sources":["../../../src/components/internal/User.tsx"],"sourcesContent":["\"use client\";\n\nimport { useUser } from \"@liveblocks/react\";\nimport type { ComponentProps } from \"react\";\nimport { useMemo } from \"react\";\n\nimport { useOverrides } from \"../../overrides\";\nimport { useCurrentUserId } from \"../../shared\";\nimport { classNames } from \"../../utils/class-names\";\n\nexport interface UserProps extends ComponentProps<\"span\"> {\n  /**\n   * The user ID to display the user name for.\n   */\n  userId: string;\n\n  /**\n   * Whether to replace the user name with \"you\" ($.USER_SELF) for the current user.\n   */\n  replaceSelf?: boolean;\n}\n\nexport function User({ userId, replaceSelf, className, ...props }: UserProps) {\n  const currentId = useCurrentUserId();\n  const { user, isLoading } = useUser(userId);\n  const $ = useOverrides();\n  const resolvedUserName = useMemo(() => {\n    return replaceSelf && currentId === userId\n      ? $.USER_SELF\n      : (user?.name ?? $.USER_UNKNOWN);\n  }, [replaceSelf, currentId, userId, $.USER_SELF, $.USER_UNKNOWN, user?.name]);\n\n  return (\n    <span\n      className={classNames(\"lb-name lb-user\", className)}\n      data-loading={isLoading ? \"\" : undefined}\n      {...props}\n    >\n      {isLoading ? null : resolvedUserName}\n    </span>\n  );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAsBO;AACL;AACA;AACA;AACA;AACE;AAEqB;AAGvB;AACG;AACmD;AACnB;AAC3B;AAEgB;AAG1B;;"}