{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "bubble",
  "title": "Bubble",
  "description": "Chat bubbles that grow from their sender’s corner, with grouped messages, reply actions and delayed reactions, built on UI SDK core.",
  "dependencies": [
    "@ui-sdk/core@0.1.0-beta.9",
    "@ui-sdk/react@0.1.0-beta.9"
  ],
  "registryDependencies": [
    "@keyframery/motion",
    "@keyframery/agent-content",
    "@keyframery/message-scroller"
  ],
  "files": [
    {
      "path": "registry/components/keyframery/core/bubble-core.ts",
      "content": "/* Chat bubbles, as UI SDK primitives. UI SDK ships no bubble, so these are defined with its core:\n   the same definitions render in React, Vue, Svelte, Solid and web components.\n\n   `bubble` is one bubble: a root that carries its variant and side, the content (the bubble you\n   see), and reactions pinned to its edge. `bubbleGroup` stacks bubbles from one sender. A bubble\n   plays its entrance when it mounts, unless it sits in a message that was already there when its\n   message scroller first showed. */\n\nimport { definePrimitive } from \"@ui-sdk/core\"\n\nimport { bindAgentContent } from \"@/components/keyframery/core/agent-content-core\"\nimport { enter } from \"@/components/keyframery/core/message-scroller-core\"\n\ntype BubbleVariant = \"default\" | \"secondary\" | \"muted\" | \"tinted\" | \"outline\" | \"ghost\" | \"destructive\"\n\ntype BubbleOptions = {\n  /** How the bubble is filled. */\n  variant?: BubbleVariant\n  /** Which side it hangs from: `\"start\"` for the other person, `\"end\"` for your own. */\n  align?: \"start\" | \"end\"\n}\n\ntype BubbleState = { variant: BubbleVariant; align: \"start\" | \"end\"; content: string }\n\nconst bubble = definePrimitive({\n  name: \"bubble\",\n  options: { variant: \"string\", align: \"string\" },\n  state: (options: BubbleOptions): BubbleState => ({\n    variant: options.variant ?? \"default\",\n    align: options.align ?? \"start\",\n    content: \"\",\n  }),\n  sync: (options) => ({ variant: options.variant ?? \"default\", align: options.align ?? \"start\" }),\n  controlled: [\"align\", \"content\"],\n  api: () => ({}),\n  slots: (slot) => ({\n    root: slot<{}, Pick<BubbleState, \"variant\" | \"align\">>({\n      state: (state) => ({ variant: state.variant, align: state.align }),\n      attrs: (state) => ({ \"data-variant\": state.variant, \"data-align\": state.align }),\n      bind: (el, part) => {\n        enter(el)\n        return bindAgentContent(el, (content) => part.store.set({ content }))\n      },\n    }),\n    content: slot<{}, Pick<BubbleState, \"variant\" | \"align\">>({\n      state: (state) => ({ variant: state.variant, align: state.align }),\n    }),\n    reactions: slot<{ side?: \"top\" | \"bottom\"; align?: \"start\" | \"end\" }, { side: \"top\" | \"bottom\"; align: \"start\" | \"end\" }>({\n      props: { side: \"string\", align: \"string\" },\n      state: (_state, part) => ({ side: part.props.side ?? \"bottom\", align: part.props.align ?? \"end\" }),\n      attrs: (_state, part) => ({ \"data-side\": part.props.side ?? \"bottom\", \"data-align\": part.props.align ?? \"end\" }),\n      bind: (el) => {\n        enter(el)\n      },\n    }),\n  }),\n  /* Bubble content is readable; reactions and other controls expose their own actions. */\n  agent: { actions: [] },\n})\n\nconst bubbleGroup = definePrimitive({\n  name: \"bubble-group\",\n  state: () => ({}),\n  controlled: [],\n  api: () => ({}),\n  slots: (slot) => ({\n    root: slot({}),\n  }),\n  agent: { actions: [] },\n})\n\nexport { bubble, bubbleGroup, type BubbleOptions, type BubbleVariant }\n",
      "type": "registry:component",
      "target": "components/keyframery/core/bubble-core.ts"
    },
    {
      "path": "registry/components/keyframery/primitives/bubble.tsx",
      "content": "\"use client\"\n\n/* Animated chat bubbles, on UI SDK's core. UI SDK ships no bubble, so the behaviour is defined in\n   `@/components/core/bubble` with `definePrimitive` and rendered here. This file adds motion only.\n   Colours, radii, shadows and spacing stay yours (style `data-variant` and `data-align`).\n\n   - Pop: a new bubble grows out of its tail corner (bottom start for the other person, bottom end\n     for you) from 60%, with a blur that clears, settling with `ease-pop`. Bubbles in a group\n     arrive one after another.\n   - Reactions pop a beat later, from the edge they hang on.\n   - A bubble whose content is a button or a link presses in. */\n\nimport { createParts } from \"@ui-sdk/react/primitive\"\nimport * as React from \"react\"\n\nimport { bubble, bubbleGroup } from \"@/components/keyframery/core/bubble-core\"\nimport { cn } from \"@/lib/utils\"\n\n/* UI SDK accepts a class name or a function of state; keep both working. */\nfunction withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {\n  return typeof className === \"function\" ? (state: S) => cn(base, className(state)) : cn(base, className)\n}\n\nconst { Root: BubbleRoot, Content: BubbleContentPart, Reactions: BubbleReactionsPart } = createParts(bubble, {\n  root: \"div\",\n  content: \"div\",\n  reactions: \"div\",\n})\nconst { Root: BubbleGroupRoot } = createParts(bubbleGroup, { root: \"div\" })\n\nfunction BubbleGroup({ className, ...props }: React.ComponentProps<typeof BubbleGroupRoot>) {\n  return (\n    <BubbleGroupRoot\n      className={withClass(/* In a group, each bubble arrives a beat after the one above it. */\n        \"*:data-[slot=bubble]:[transition-delay:calc((min(sibling-index(),6)-1)*90ms*var(--kf-speed,1))]\", className)}\n      {...props}\n    />\n  )\n}\n\n/* Pop. Only scale, translate, opacity and filter transition, so the delay never slows anything else. */\nfunction Bubble({ className, ...props }: React.ComponentProps<typeof BubbleRoot>) {\n  return (\n    <BubbleRoot\n      className={withClass(\n        cn(\n          \"group/bubble origin-bottom-left rtl:origin-bottom-right data-[align=end]:origin-bottom-right rtl:data-[align=end]:origin-bottom-left\",\n          \"transition-[scale,translate,opacity,filter] duration-[calc(560ms*var(--kf-speed,1))] ease-pop\",\n          \"data-starting-style:scale-[0.6] data-starting-style:translate-y-2 data-starting-style:opacity-0 data-starting-style:blur-[6px] data-starting-style:transition-none\",\n          \"motion-reduce:transition-none!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* Press, for a bubble that is a button or a link (`render={<button />}`). */\nfunction BubbleContent({ className, ...props }: React.ComponentProps<typeof BubbleContentPart>) {\n  return (\n    <BubbleContentPart\n      className={withClass(\n        cn(\n          \"[button&,a&]:transition-[scale] [button&,a&]:duration-[calc(200ms*var(--kf-speed,1))] [button&,a&]:ease-pop [button&,a&]:active:scale-[0.97]\",\n          \"motion-reduce:transition-none!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* Pops in a beat after its bubble, from the edge it hangs on. */\nfunction BubbleReactions({ className, ...props }: React.ComponentProps<typeof BubbleReactionsPart>) {\n  return (\n    <BubbleReactionsPart\n      className={withClass(\n        cn(\n          \"data-[side=bottom]:origin-top data-[side=top]:origin-bottom\",\n          \"transition-[scale,opacity,filter] duration-[calc(480ms*var(--kf-speed,1))] ease-pop delay-[calc(260ms*var(--kf-speed,1))]\",\n          \"data-starting-style:scale-[0.4] data-starting-style:opacity-0 data-starting-style:blur-[3px] data-starting-style:transition-none\",\n          \"motion-reduce:transition-none!\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Bubble, BubbleContent, BubbleGroup, BubbleReactions }\n",
      "type": "registry:component",
      "target": "components/keyframery/primitives/bubble.tsx"
    },
    {
      "path": "registry/components/keyframery/bubble.tsx",
      "content": "\"use client\"\n\nexport * from \"@/components/keyframery/primitives/bubble\"\n\n/* Theming variables (set on a part or ancestor; absent values preserve the theme):\n   --bubble-face: Incoming surface; default: bg-muted.\n   --bubble-ink: Incoming text; default: text-foreground.\n   --bubble-radius: Bubble corners; default: rounded-[18px].\n   --bubble-font: Message size; default: text-[14px].\n   --bubble-inset-x: Side padding; default: px-3.5.\n   --bubble-inset-y: Vertical padding; default: py-2.\n   --bubble-max-width: Bubble width; default: max-w-[80%].\n*/\n\n/* Styled chat bubbles: the animated primitive plus the Keyframery look. A soft 18px bubble whose\n   corner toward the sender is tucked to 4px; your own are the primary colour, the other person's a\n   quiet well. Reactions sit on the bubble's edge as a small key. */\n\nimport * as React from \"react\"\n\nimport {\n  Bubble as BubblePrimitive,\n  BubbleContent as BubbleContentPrimitive,\n  BubbleGroup as BubbleGroupPrimitive,\n  BubbleReactions as BubbleReactionsPrimitive,\n} from \"@/components/keyframery/primitives/bubble\"\nimport { Speed, type SpeedProps } from \"@/lib/keyframery\"\nimport { cn } from \"@/lib/utils\"\n\n/* UI SDK accepts a class name or a function of state; keep both working. */\nfunction withClass<S>(base: string, className: string | ((state: S) => string | undefined) | undefined) {\n  return typeof className === \"function\" ? (state: S) => cn(base, className(state)) : cn(base, className)\n}\n\n/* Each variant fills the content part; a bubble that is a button or a link darkens a touch on hover. */\nconst variants = [\n  \"data-[variant=default]:*:data-[slot=bubble-content]:bg-primary data-[variant=default]:*:data-[slot=bubble-content]:text-primary-foreground\",\n  \"data-[variant=default]:*:data-[slot=bubble-content]:shadow-[inset_0_1px_0_rgb(255_255_255/0.12),0_1px_2px_rgb(0_0_0/0.12)]\",\n  \"data-[variant=default]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklab,var(--primary),var(--background)_10%)]\",\n  \"data-[variant=secondary]:*:data-[slot=bubble-content]:bg-[var(--bubble-face,var(--message-face,var(--secondary)))] data-[variant=secondary]:*:data-[slot=bubble-content]:text-secondary-foreground\",\n  \"data-[variant=secondary]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklab,var(--secondary),var(--foreground)_5%)]\",\n  \"data-[variant=muted]:*:data-[slot=bubble-content]:bg-[var(--bubble-face,var(--message-face,var(--muted)))] data-[variant=muted]:*:data-[slot=bubble-content]:text-[color:var(--bubble-ink,var(--foreground))]\",\n  \"data-[variant=muted]:*:data-[slot=bubble-content]:shadow-[inset_0_0_0_1px_rgb(0_0_0/0.03)] dark:data-[variant=muted]:*:data-[slot=bubble-content]:shadow-[inset_0_0_0_1px_rgb(255_255_255/0.04)]\",\n  \"data-[variant=muted]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklab,var(--muted),var(--foreground)_5%)]\",\n  \"data-[variant=tinted]:*:data-[slot=bubble-content]:bg-[var(--bubble-face,var(--message-face,color-mix(in_oklab,var(--primary)_9%,var(--background))))] data-[variant=tinted]:*:data-[slot=bubble-content]:text-[color:var(--bubble-ink,var(--foreground))]\",\n  \"dark:data-[variant=tinted]:*:data-[slot=bubble-content]:bg-[var(--bubble-face,var(--message-face,color-mix(in_oklab,var(--primary)_16%,var(--background))))]\",\n  \"data-[variant=tinted]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[color-mix(in_oklab,var(--primary)_14%,var(--background))]\",\n  \"data-[variant=outline]:*:data-[slot=bubble-content]:bg-[var(--bubble-face,var(--message-face,var(--background)))] data-[variant=outline]:*:data-[slot=bubble-content]:text-[color:var(--bubble-ink,var(--foreground))]\",\n  \"data-[variant=outline]:*:data-[slot=bubble-content]:shadow-[0_0_0_1px_rgb(0_0_0/0.09),0_1px_2px_rgb(0_0_0/0.05)] dark:data-[variant=outline]:*:data-[slot=bubble-content]:shadow-[0_0_0_1px_rgb(255_255_255/0.1)]\",\n  \"data-[variant=outline]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-[var(--bubble-face,var(--message-face,var(--muted)))]\",\n  \"data-[variant=ghost]:max-w-full data-[variant=ghost]:*:data-[slot=bubble-content]:rounded-none data-[variant=ghost]:*:data-[slot=bubble-content]:bg-transparent data-[variant=ghost]:*:data-[slot=bubble-content]:p-0\",\n  \"data-[variant=destructive]:*:data-[slot=bubble-content]:bg-destructive/10 data-[variant=destructive]:*:data-[slot=bubble-content]:text-destructive dark:data-[variant=destructive]:*:data-[slot=bubble-content]:bg-destructive/20\",\n  \"data-[variant=destructive]:[&>[data-slot=bubble-content]:is(button,a):hover]:bg-destructive/15\",\n]\n\nfunction BubbleGroup({ speed, className, ...props }: React.ComponentProps<typeof BubbleGroupPrimitive> & SpeedProps) {\n  return (\n    <Speed speed={speed}>\n      <BubbleGroupPrimitive\n        className={withClass(\n          cn(\n            \"flex min-w-0 flex-col gap-1\",\n            /* Bubbles from one sender share a run: the corners between them tuck in too. */\n            \"*:data-[align=start]:not-first:*:data-[slot=bubble-content]:rounded-ss-[4px] *:data-[align=start]:not-last:*:data-[slot=bubble-content]:rounded-es-[4px]\",\n            \"*:data-[align=end]:not-first:*:data-[slot=bubble-content]:rounded-se-[4px] *:data-[align=end]:not-last:*:data-[slot=bubble-content]:rounded-ee-[4px]\",\n          ),\n          className,\n        )}\n        {...props}\n      />\n    </Speed>\n  )\n}\n\nfunction Bubble({ speed, className, ...props }: React.ComponentProps<typeof BubblePrimitive> & SpeedProps) {\n  return (\n    <Speed speed={speed}>\n      <BubblePrimitive\n        className={withClass(\n          cn(\n            \"relative flex w-fit max-w-[var(--bubble-max-width,80%)] min-w-0 flex-col gap-1\",\n            \"data-[align=end]:self-end group-data-[align=end]/message:self-end\",\n            variants,\n          ),\n          className,\n        )}\n        {...props}\n      />\n    </Speed>\n  )\n}\n\nfunction BubbleContent({ className, ...props }: React.ComponentProps<typeof BubbleContentPrimitive>) {\n  return (\n    <BubbleContentPrimitive\n      className={withClass(\n        cn(\n          \"w-fit max-w-full min-w-0 overflow-hidden rounded-[var(--bubble-radius,18px)] px-[var(--bubble-inset-x,0.875rem)] py-[var(--bubble-inset-y,0.5rem)] text-[length:var(--bubble-font,14px)] leading-[1.45] wrap-break-word\",\n          \"group-data-[align=start]/bubble:rounded-es-[4px] group-data-[align=end]/bubble:self-end group-data-[align=end]/bubble:rounded-ee-[4px]\",\n          \"[button&]:cursor-pointer [button&]:text-left [button&,a&]:outline-none\",\n          \"[button&,a&]:focus-visible:ring-2 [button&,a&]:focus-visible:ring-ring [button&,a&]:focus-visible:ring-offset-2 [button&,a&]:focus-visible:ring-offset-background\",\n          \"[button&,a&]:transition-[scale,background-color] [button&,a&]:duration-[calc(150ms*var(--kf-speed,1))]\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/* A small key on the bubble's edge, ringed in the page colour so it cuts out of the bubble. On a\n   surface that is not `background`, set `--bubble-cutout` to its colour. */\nfunction BubbleReactions({ className, ...props }: React.ComponentProps<typeof BubbleReactionsPrimitive>) {\n  return (\n    <BubbleReactionsPrimitive\n      className={withClass(\n        cn(\n          \"absolute z-10 flex h-6 w-fit shrink-0 items-center justify-center gap-1 rounded-full bg-background px-1.5 text-[12px] leading-none tabular-nums\",\n          \"shadow-[0_0_0_2px_var(--bubble-cutout,var(--background)),0_0_0_3px_rgb(0_0_0/0.06),0_2px_5px_-1px_rgb(0_0_0/0.12)]\",\n          \"dark:bg-accent dark:shadow-[0_0_0_2px_var(--bubble-cutout,var(--background)),0_0_0_3px_rgb(255_255_255/0.07),0_2px_6px_-1px_rgb(0_0_0/0.6)]\",\n          \"data-[side=bottom]:bottom-0 data-[side=bottom]:translate-y-2/3 data-[side=top]:top-0 data-[side=top]:-translate-y-2/3\",\n          \"data-[align=end]:end-2 data-[align=start]:start-2\",\n          \"has-[button]:p-0\",\n        ),\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport { Bubble, BubbleContent, BubbleGroup, BubbleReactions }\n",
      "type": "registry:component",
      "target": "components/keyframery/bubble.tsx"
    }
  ],
  "type": "registry:component"
}