{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "inline-citation-vue",
  "title": "Inline Citation (Vue)",
  "description": "A marker in running text whose card shows the sources it points to, paging through several.",
  "dependencies": [
    "@kind-ui/agent-ui@0.9.0",
    "@ui-sdk/core@0.1.0-beta.17",
    "@ui-sdk/vue@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/inline-citation.ts",
      "content": "import {\n  type InlineCitationCarouselState,\n  type InlineCitationRootState,\n  inlineCitationPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { Avatar, AvatarFallback, AvatarImage } from \"@ui-sdk/vue/avatar\";\nimport {\n  CarouselContent,\n  CarouselItem,\n  CarouselNext,\n  CarouselPrevious,\n  Carousel as CarouselRoot,\n  CarouselViewport,\n} from \"@ui-sdk/vue/carousel\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h, type Slots, type VNode } from \"vue\";\n\n// Every part is a `span`, so a citation is valid inside a paragraph.\nconst parts = createParts(inlineCitationPrimitive, {\n  root: \"span\",\n  trigger: \"button\",\n  content: \"span\",\n  carousel: \"span\",\n  item: \"span\",\n  link: \"a\",\n  icon: \"span\",\n  host: \"span\",\n  \"source-title\": \"span\",\n  snippet: \"span\",\n  index: \"span\",\n});\n\ntype Scope<State> = { state: State };\n\n// Lucide \"chevron-left\" and \"chevron-right\", see THIRD_PARTY_NOTICES.md.\nconst chevron = (d: string) => () =>\n  h(\n    \"svg\",\n    {\n      viewBox: \"0 0 24 24\",\n      fill: \"none\",\n      stroke: \"currentColor\",\n      \"stroke-width\": \"2\",\n      \"aria-hidden\": \"true\",\n    },\n    [h(\"path\", { d, \"stroke-linecap\": \"round\", \"stroke-linejoin\": \"round\" })],\n  );\nconst chevronLeft = chevron(\"m15 18-6-6 6-6\");\nconst chevronRight = chevron(\"m9 18 6-6-6-6\");\n\n// Renders a Carousel part as a `span`.\nconst asSpan = {\n  render: ({ props, children }: { props: Record<string, unknown>; children: Component }) => [\n    h(\"span\", props, [h(children)]),\n  ],\n};\n\n// A part whose default slot falls back to `fallback` when the caller fills none.\nfunction withDefault<C extends Component>(part: C, name: string, fallback: (scope: never) => unknown): C {\n  const Part = defineComponent({\n    name,\n    inheritAttrs: false,\n    setup(_, { attrs, slots }) {\n      return () => h(part, attrs, { ...slots, default: slots.default ?? fallback } as Slots);\n    },\n  });\n  return Part as unknown as C;\n}\n\n/** The marker, which opens the card. Reads the `label` unless you fill its slot. */\nexport const InlineCitationTrigger = withDefault(\n  parts.Trigger,\n  \"InlineCitationTrigger\",\n  ({ state }: Scope<{ label: string }>) => state.label,\n);\n\n/** The card. Leaves focus on the marker when it opens. */\nexport const InlineCitationContent = defineComponent({\n  name: \"InlineCitationContent\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        parts.Content,\n        \"initialFocus\" in attrs || \"initial-focus\" in attrs ? attrs : { initialFocus: \"none\", ...attrs },\n        slots,\n      );\n  },\n}) as unknown as typeof parts.Content;\n\n/** Links to the source's `url` in a new tab; an `a` without `href`, which is text, when the URL isn't safe. */\nexport const InlineCitationLink = parts.Link;\n\n/** A UI SDK Avatar of the source's `favicon`, showing a link glyph until it loads or without one. */\nexport const InlineCitationIcon = withDefault(\n  parts.Icon,\n  \"InlineCitationIcon\",\n  ({ state }: Scope<{ favicon: string | undefined }>) =>\n    h(Avatar, null, () => [\n      state.favicon ? h(AvatarImage, { src: state.favicon, alt: \"\" }) : null,\n      h(AvatarFallback),\n    ]),\n);\n\n/** The host name of the source's `url`, unless you fill its slot. Rendered only with a safe `url`. */\nexport const InlineCitationHost = withDefault(\n  parts.Host,\n  \"InlineCitationHost\",\n  ({ state }: Scope<{ host: string }>) => state.host,\n);\n\n/** The source's `title`, unless you fill its slot. */\nexport const InlineCitationSourceTitle = withDefault(\n  parts.SourceTitle,\n  \"InlineCitationSourceTitle\",\n  ({ state }: Scope<{ title: string }>) => state.title,\n);\n\n/** The source's `snippet`, unless you fill its slot. Rendered only with a `snippet`. */\nexport const InlineCitationSnippet = withDefault(\n  parts.Snippet,\n  \"InlineCitationSnippet\",\n  ({ state }: Scope<{ snippet: string }>) => state.snippet,\n);\n\n/** Which source the card shows, like \"1 of 3\", unless you fill its slot. */\nexport const InlineCitationIndex = withDefault(\n  parts.Index,\n  \"InlineCitationIndex\",\n  ({ state }: Scope<{ text: string }>) => state.text,\n);\n\n/**\n * The source whose `id` is `value`. Without a default slot, it shows its icon, title and host name, a link when its\n * `url` is safe, then its snippet.\n */\nexport const InlineCitationItem = withDefault(parts.Item, \"InlineCitationItem\", () => [\n  h(InlineCitationLink, null, () => [\n    h(InlineCitationIcon),\n    h(InlineCitationSourceTitle),\n    h(InlineCitationHost),\n  ]),\n  h(InlineCitationSnippet),\n]);\n\n// Previous and Next are hidden from agents, which takes the Carousel out of their snapshot: an agent pages with the\n// citation's own `next` and `previous`.\n\n/** Shows the previous source. */\nexport const InlineCitationPrevious = defineComponent({\n  name: \"InlineCitationPrevious\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        CarouselPrevious,\n        { \"aria-label\": \"Previous source\", \"data-agent-hidden\": \"\", \"data-kind-icon-button\": \"\", ...attrs },\n        { ...slots, default: slots.default ?? chevronLeft },\n      );\n  },\n}) as unknown as typeof CarouselPrevious;\n\n/** Shows the next source. */\nexport const InlineCitationNext = defineComponent({\n  name: \"InlineCitationNext\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        CarouselNext,\n        { \"aria-label\": \"Next source\", \"data-agent-hidden\": \"\", \"data-kind-icon-button\": \"\", ...attrs },\n        { ...slots, default: slots.default ?? chevronRight },\n      );\n  },\n}) as unknown as typeof CarouselNext;\n\n/**\n * UI SDK's Carousel, a slide per source with Previous, the page and Next below. Rendered only for more than one\n * source. A default slot replaces the slides and controls, inside the Carousel.\n */\nexport const InlineCitationCarousel = defineComponent({\n  name: \"InlineCitationCarousel\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Carousel, attrs, {\n        ...slots,\n        default: ({ state }: Scope<InlineCitationCarouselState>) =>\n          h(\n            CarouselRoot,\n            {\n              controller: state.controller,\n              defaultPage: state.defaultPage,\n              drag: false,\n              \"aria-label\": \"Sources\",\n            },\n            {\n              ...asSpan,\n              default: (): VNode[] =>\n                (slots.default?.() as VNode[] | undefined) ?? [\n                  h(CarouselViewport, null, {\n                    ...asSpan,\n                    default: () =>\n                      h(CarouselContent, null, {\n                        ...asSpan,\n                        default: () =>\n                          state.ids.map((id) =>\n                            h(\n                              CarouselItem,\n                              { key: id },\n                              { ...asSpan, default: () => h(InlineCitationItem, { value: id }) },\n                            ),\n                          ),\n                      }),\n                  }),\n                  h(\"span\", { \"data-inline-citation-controls\": \"\" }, [\n                    h(InlineCitationPrevious),\n                    h(InlineCitationIndex),\n                    h(InlineCitationNext),\n                  ]),\n                ],\n            },\n          ),\n      });\n  },\n}) as unknown as typeof parts.Carousel;\n\n/**\n * A marker in running text for the sources a sentence came from, with a card that opens on hover, keyboard focus and\n * press. More than one source pages in the card. Anything in its default slot replaces the marker and the card.\n */\nexport const InlineCitation = defineComponent({\n  name: \"InlineCitation\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: Scope<InlineCitationRootState>) => {\n            const ids = state.ids;\n            return [\n              h(InlineCitationTrigger),\n              h(InlineCitationContent, null, () =>\n                ids.length > 1\n                  ? h(InlineCitationCarousel)\n                  : ids[0]\n                    ? h(InlineCitationItem, { value: ids[0] })\n                    : null,\n              ),\n            ];\n          }),\n      });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/inline-citation.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
