{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "context-meter-vue",
  "title": "Context Meter (Vue)",
  "description": "How full the context window is, as a ring and a percentage, with a breakdown, Compact, token counts, cost and usage limits in a popover or in the page.",
  "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/context-meter.ts",
      "content": "import {\n  type ContextLimitRow,\n  type ContextMeterBarState,\n  type ContextMeterValueState,\n  type ContextRow,\n  contextMeterPrimitive,\n  WORDS,\n} from \"@kind-ui/agent-ui/core\";\nimport { Meter, MeterIndicator, MeterLabel, MeterTrack, MeterValue } from \"@ui-sdk/vue/meter\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport { type Component, defineComponent, h } from \"vue\";\n\nconst parts = createParts(contextMeterPrimitive, {\n  root: \"div\",\n  trigger: \"button\",\n  value: \"span\",\n  content: \"div\",\n  title: \"h2\",\n  description: \"p\",\n  rows: \"dl\",\n  viewport: \"div\",\n  compact: \"button\",\n  compacting: \"span\",\n  \"compacting-icon\": \"span\",\n  bar: \"div\",\n  breakdown: \"ul\",\n  limits: \"div\",\n});\n\n/**\n * UI SDK's Meter: a ring and the percentage, after the limit it shows from 80% used, unless you pass a slot, which\n * gets the Meter's props as `state`.\n */\nexport const ContextMeterValue = defineComponent({\n  name: \"ContextMeterValue\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Value, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: ContextMeterValueState }) =>\n            h(\n              Meter,\n              {\n                value: state.value,\n                max: state.max,\n                locale: state.locale,\n                getValueLabel: state.getValueLabel,\n                \"aria-label\": state.label,\n                \"data-agent-hidden\": \"\",\n              },\n              () => [\n                h(MeterTrack),\n                state.caption ? h(\"span\", { \"data-context-meter-caption\": \"\" }, `${state.caption} `) : null,\n                h(MeterValue),\n              ],\n            )),\n      });\n  },\n});\n\n/** Opens the details. Holds the meter unless you pass a slot. */\nexport const ContextMeterTrigger = defineComponent({\n  name: \"ContextMeterTrigger\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Trigger, attrs, { ...slots, default: slots.default ?? (() => h(ContextMeterValue)) });\n  },\n});\n\n/** How full, like \"86% full · Filling up\", unless you pass a slot. Names the details. */\nexport const ContextMeterTitle = defineComponent({\n  name: \"ContextMeterTitle\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Title, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: { fullText: string; levelText: string } }) => [\n            state.fullText,\n            state.levelText ? h(\"span\", { \"data-context-meter-level\": \"\" }, ` · ${state.levelText}`) : null,\n          ]),\n      });\n  },\n});\n\n/** Used and total tokens, unless you pass a slot. Describes the details. */\nexport const ContextMeterDescription = defineComponent({\n  name: \"ContextMeterDescription\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Description, attrs, {\n        ...slots,\n        default: slots.default ?? (({ state }: { state: { countText: string } }) => state.countText),\n      });\n  },\n});\n\n/** Each count and the cost supplied, unless you pass a slot. Rendered only when there's one. */\nexport const ContextMeterRows = defineComponent({\n  name: \"ContextMeterRows\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Rows, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: { rows: ContextRow[] } }) =>\n            state.rows.map(({ label, value }) => h(\"div\", { key: label }, [h(\"dt\", label), h(\"dd\", value)]))),\n      });\n  },\n});\n\n/** Compacts the conversation. Rendered while `on-compact` is set and nothing is compacting. */\nexport const ContextMeterCompact = defineComponent({\n  name: \"ContextMeterCompact\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(parts.Compact, attrs, { ...slots, default: slots.default ?? (() => WORDS.compact) });\n  },\n}) as unknown as typeof parts.Compact;\n\n/** A running mark and \"Compacting\", in Compact's place while the conversation compacts. */\nexport const ContextMeterCompacting = defineComponent({\n  name: \"ContextMeterCompacting\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Compacting, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: { text: string } }) => [h(parts.CompactingIcon), state.text]),\n      });\n  },\n}) as unknown as typeof parts.Compacting;\n\n/** The breakdown as one stacked bar, with a tick at `compact-at`. One image, named by the breakdown as a sentence. */\nexport const ContextMeterBar = defineComponent({\n  name: \"ContextMeterBar\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Bar, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: ContextMeterBarState }) =>\n            state.slices.map((slice) =>\n              slice.color\n                ? h(\"span\", {\n                    key: slice.id,\n                    \"data-context-meter-segment\": \"\",\n                    \"data-color\": slice.color,\n                    style: { width: slice.width },\n                  })\n                : null,\n            )),\n      });\n  },\n}) as unknown as typeof parts.Bar;\n\n/** A row per slice of the breakdown: its swatch, label, tokens and share, then Free space. */\nexport const ContextMeterBreakdown = defineComponent({\n  name: \"ContextMeterBreakdown\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Breakdown, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: ContextMeterBarState }) =>\n            state.slices.map((slice) =>\n              h(\"li\", { key: slice.id, \"data-color\": slice.color }, [\n                h(\"span\", { \"data-context-meter-swatch\": \"\", \"aria-hidden\": \"true\" }),\n                h(\"span\", { \"data-context-meter-label\": \"\" }, slice.label),\n                h(\"span\", { \"data-context-meter-tokens\": \"\" }, slice.value),\n                h(\"span\", { \"data-context-meter-share\": \"\" }, slice.percent),\n              ]),\n            )),\n      });\n  },\n}) as unknown as typeof parts.Breakdown;\n\n/** A UI SDK Meter per limit, with its share used, reset and pace. Rendered only with `limits`. */\nexport const ContextMeterLimits = defineComponent({\n  name: \"ContextMeterLimits\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Limits, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: { state: { limits: ContextLimitRow[] } }) =>\n            state.limits.map((limit) =>\n              h(\n                Meter,\n                {\n                  key: limit.id,\n                  value: limit.value,\n                  max: limit.max,\n                  getValueLabel: () => limit.valueText,\n                  \"data-agent-hidden\": \"\",\n                  \"data-level\": limit.low ? \"high\" : \"normal\",\n                },\n                () => [\n                  h(MeterLabel, null, () => limit.label),\n                  h(MeterValue, null, () => limit.percent),\n                  h(\n                    MeterTrack,\n                    limit.pace === undefined\n                      ? null\n                      : { \"data-pace\": \"\", style: { \"--kind-limit-pace\": `${limit.pace * 100}%` } },\n                    () => h(MeterIndicator),\n                  ),\n                  limit.detail ? h(\"span\", { \"data-context-meter-detail\": \"\" }, limit.detail) : null,\n                ],\n              ),\n            )),\n      });\n  },\n}) as unknown as typeof parts.Limits;\n\nconst defaultDetails = () => [\n  h(ContextMeterTitle),\n  h(ContextMeterCompact),\n  h(ContextMeterCompacting),\n  h(ContextMeterDescription),\n  h(ContextMeterBar),\n  h(ContextMeterBreakdown),\n  h(ContextMeterRows),\n  h(ContextMeterLimits),\n];\n\n/**\n * The details: how full, Compact, the breakdown, the counts and the limits, unless you pass a slot. Leaves focus on\n * the trigger.\n */\nexport const ContextMeterContent = defineComponent({\n  name: \"ContextMeterContent\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(\n        parts.Content,\n        { initialFocus: \"none\", ...attrs },\n        {\n          default: slots.default ?? defaultDetails,\n          // A sheet sits in a full-screen viewport, which renders only while the content presents as one.\n          render: (scope: {\n            props: Record<string, unknown>;\n            state: { presentation: string };\n            children: Component;\n          }) => {\n            const element = slots.render ? slots.render(scope) : h(\"div\", scope.props, [h(scope.children)]);\n            return [scope.state.presentation === \"sheet\" ? h(parts.Viewport, null, () => element) : element];\n          },\n        },\n      );\n  },\n});\n\nconst defaultParts = () => [h(ContextMeterTrigger), h(ContextMeterContent)];\n\n/**\n * How much of the context window a conversation uses, and how much of the plan's limits: a ring and its percentage,\n * with details that open on hover, keyboard focus and press, or sit in the page with `layout=\"inline\"`. A default\n * slot replaces the default parts.\n */\nexport const ContextMeter = defineComponent({\n  name: \"ContextMeter\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default: slots.default ?? (attrs.layout === \"inline\" ? defaultDetails : defaultParts),\n      });\n  },\n}) as unknown as typeof parts.Root;\n",
      "type": "registry:ui",
      "target": "@ui/vue/context-meter.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
