{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "message",
  "title": "Message",
  "description": "A chat turn: a plain article for the assistant, a bubble for the user. Adapted from beUI (MIT).",
  "dependencies": [
    "motion@^12.23.12"
  ],
  "registryDependencies": [
    "@khaeli/ease",
    "@khaeli/utils"
  ],
  "files": [
    {
      "path": "registry/khaeli/ui/message.tsx",
      "content": "\"use client\"\n\n/*\n * beUI, https://github.com/starc007/ui-components\n * MIT License, Copyright (c) 2026 Saurabh Chauhan\n *\n * Permission is hereby granted, free of charge, to any person obtaining a copy\n * of this software and associated documentation files (the \"Software\"), to deal\n * in the Software without restriction, including without limitation the rights\n * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the Software, and to permit persons to whom the Software is\n * furnished to do so, subject to the following conditions:\n * The above copyright notice and this permission notice shall be included in all\n * copies or substantial portions of the Software.\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n * SOFTWARE.\n */\n// Adapted from beUI (MIT) https://beui.dev — components/agents/message.\n// Trimmed for this design system's answer-first chat grammar: no avatars, no\n// bubbles for the assistant — a turn is a plain article whose side comes\n// from `from`.\n// Kept from beUI: the data-slot/data-from contract and the trailing-edge\n// pop-up a freshly sent row plays once on mount.\n\nimport {\n  useRef,\n  useState,\n  useSyncExternalStore,\n  type ComponentPropsWithRef,\n  type ReactNode,\n} from \"react\"\nimport { useReducedMotion } from \"motion/react\"\nimport * as m from \"motion/react-m\"\nimport { cn } from \"@/lib/utils\"\n\nimport { SPRING_POP_UP } from \"@/lib/ease\"\n\nconst subscribeToNothing = () => () => {}\n\n/**\n * True for the life of a component whose first render hydrated server markup.\n * A server cannot read the motion setting, so its markup always carries the\n * animated start style, and the render that hydrates it has to write the same.\n */\nfunction useHydratedFromServer() {\n  const hydrating = !useSyncExternalStore(\n    subscribeToNothing,\n    () => true,\n    () => false\n  )\n  return useState(hydrating)[0]\n}\n\nexport type MessageFrom = \"user\" | \"assistant\"\n\nexport interface MessageProps\n  extends Omit<ComponentPropsWithRef<typeof m.article>, \"children\"> {\n  from: MessageFrom\n  /** Plays a trailing-edge pop-up once when this message row mounts. */\n  animateIn?: boolean\n  children: ReactNode\n}\n\nexport function Message({\n  from,\n  animateIn = false,\n  children,\n  className,\n  style,\n  ref: forwardedRef,\n  ...props\n}: MessageProps) {\n  const reduce = useReducedMotion() ?? false\n  const fromServer = useHydratedFromServer()\n  const ref = useRef<HTMLElement | null>(null)\n  // Under reduced motion a message is committed at rest: nothing rises and\n  // nothing fades. The one that cannot be is a message hydrated from server\n  // markup, which starts from the server's style and is placed at once.\n  const rises = animateIn && (!reduce || fromServer)\n\n  return (\n    <m.article\n      ref={(node) => {\n        ref.current = node\n        if (typeof forwardedRef === \"function\") forwardedRef(node)\n        else if (forwardedRef) forwardedRef.current = node\n      }}\n      data-slot=\"message\"\n      data-from={from}\n      aria-label={props[\"aria-label\"] ?? `${from} message`}\n      initial={\n        rises\n          ? { opacity: 0, transform: \"translateY(8px) scale(0.95)\" }\n          : false\n      }\n      animate={\n        rises\n          ? { opacity: 1, transform: reduce ? \"none\" : \"translateY(0px) scale(1)\" }\n          : { opacity: 1 }\n      }\n      transition={\n        reduce ? { duration: rises ? 0 : 0.12 } : SPRING_POP_UP\n      }\n      onAnimationComplete={() => ref.current?.style.removeProperty(\"transform\")}\n      style={{\n        transformOrigin: from === \"user\" ? \"100% 100%\" : \"0% 100%\",\n        ...style,\n      }}\n      className={cn(\n        \"group/message flex w-full min-w-0\",\n        from === \"user\" ? \"justify-end\" : \"flex-col\",\n        className\n      )}\n      {...props}\n    >\n      {children}\n    </m.article>\n  )\n}\n",
      "type": "registry:ui"
    }
  ],
  "docs": "Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.",
  "type": "registry:ui"
}