{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkpoint-vue",
  "title": "Checkpoint (Vue)",
  "description": "A marker in the conversation that restores to that point, after a dialog asks what to restore and says what's lost.",
  "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",
    "@kind-ui/internal-alert-dialog-vue",
    "@kind-ui/internal-radio-vue",
    "@kind-ui/internal-tooltip-vue"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/vue/checkpoint.ts",
      "content": "import {\n  type CheckpointDialogState,\n  type CheckpointScopeState,\n  checkpointPrimitive,\n} from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/vue/primitive\";\nimport type { RadioGroupController } from \"@ui-sdk/vue/radio\";\nimport { defineComponent, Fragment, h, type VNode } from \"vue\";\nimport {\n  KindAlertDialog,\n  KindAlertDialogBackdrop,\n  KindAlertDialogContent,\n  KindAlertDialogDescription,\n  KindAlertDialogTitle,\n  KindAlertDialogTrigger,\n} from \"./internal/alert-dialog\";\nimport { KindRadio, KindRadioGroup, KindRadioIndicator } from \"./internal/radio\";\nimport { KindTooltip, KindTooltipContent, KindTooltipTrigger } from \"./internal/tooltip\";\n\nconst parts = createParts(checkpointPrimitive, {\n  root: \"div\",\n  label: \"span\",\n  description: \"span\",\n  line: \"span\",\n  restore: \"div\",\n  restored: \"span\",\n  scope: \"div\",\n  compare: \"button\",\n  error: \"span\",\n  cancel: \"button\",\n  confirm: \"button\",\n});\n\ntype Scope<State> = { state: State };\n\n/**\n * A marker in the conversation that a person can restore. Restore opens a dialog that asks before calling\n * `onRestore`. A default slot replaces the default parts.\n */\nexport const Checkpoint = defineComponent({\n  name: \"Checkpoint\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Root, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (() => [\n            h(CheckpointLabel),\n            h(CheckpointDescription),\n            h(CheckpointLine),\n            h(CheckpointRestore),\n            h(CheckpointRestored),\n          ]),\n      });\n  },\n});\n\nexport const CheckpointLine = parts.Line;\n\n/** The `label`, unless you pass a default slot. */\nexport const CheckpointLabel = defineComponent({\n  name: \"CheckpointLabel\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Label, attrs, {\n        ...slots,\n        default: slots.default ?? (({ state }: Scope<{ label: string }>) => state.label),\n      });\n  },\n});\n\n/** The `description`, unless you pass a default slot. Rendered only with one. */\nexport const CheckpointDescription = defineComponent({\n  name: \"CheckpointDescription\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Description, attrs, {\n        ...slots,\n        default: slots.default ?? (({ state }: Scope<{ description?: string }>) => state.description),\n      });\n  },\n});\n\nconst restoreTrigger = () =>\n  h(KindTooltip, { type: \"label\" }, () => [\n    h(\n      KindTooltipTrigger,\n      { \"data-checkpoint-trigger\": \"\", \"data-kind-icon-button\": \"\" },\n      {\n        render: ({ props, children }: { props: Record<string, unknown>; children: () => VNode }) =>\n          h(KindAlertDialogTrigger, props, () => h(children)),\n      },\n    ),\n    h(KindTooltipContent, null, () => \"Restore checkpoint\"),\n  ]);\n\n/**\n * Restore and its dialog, unless you pass a default slot, which gets the Alert Dialog's props as `state`. Rendered\n * only while `onRestore` is set and the checkpoint isn't `restored`.\n */\nexport const CheckpointRestore = defineComponent({\n  name: \"CheckpointRestore\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Restore, attrs, {\n        ...slots,\n        default: ({ state }: Scope<CheckpointDialogState>) => {\n          // The slot's state is a proxy that tracks each key read and lists none, so it's copied key by key for a\n          // slot that binds it with `v-bind`.\n          const dialog: CheckpointDialogState = {\n            controller: state.controller,\n            dismissible: state.dismissible,\n            busy: state.busy,\n            initialFocus: state.initialFocus,\n            title: state.title,\n            point: state.point,\n            description: state.description,\n            note: state.note,\n          };\n          if (slots.default) return slots.default({ state: dialog });\n          const { controller, dismissible, ...rest } = dialog;\n          return h(KindAlertDialog, { controller, dismissible }, () => [\n            restoreTrigger(),\n            h(CheckpointDialog, rest),\n          ]);\n        },\n      });\n  },\n});\n\nconst answers = () =>\n  h(\"div\", { \"data-checkpoint-answers\": \"\" }, [\n    h(CheckpointCompare),\n    h(CheckpointError),\n    h(CheckpointCancel),\n    h(CheckpointConfirm),\n  ]);\n\n/**\n * The dialog's backdrop and content: its title, the checkpoint's description, the scope, the loss sentence as its\n * description, and the answers, unless you pass a default slot, which replaces the scope and the answers.\n */\nexport const CheckpointDialog = defineComponent({\n  name: \"CheckpointDialog\",\n  props: {\n    title: { type: String, required: true },\n    point: { type: String, required: true },\n    description: { type: String, required: true },\n    note: { type: String, required: true },\n    initialFocus: { type: String, required: true },\n    busy: { type: Boolean, default: undefined },\n  },\n  setup(props, { slots }) {\n    return () =>\n      h(Fragment, [\n        h(KindAlertDialogBackdrop),\n        h(\n          KindAlertDialogContent,\n          { initialFocus: props.initialFocus, \"aria-busy\": props.busy || undefined },\n          () => [\n            h(KindAlertDialogTitle, null, () => props.title),\n            props.point ? h(\"p\", { \"data-checkpoint-point\": \"\" }, props.point) : null,\n            ...(slots.default\n              ? [slots.default()]\n              : [\n                  h(CheckpointScope),\n                  h(CheckpointLoss, { description: props.description, note: props.note }),\n                  answers(),\n                ]),\n          ],\n        ),\n      ]);\n  },\n});\n\n/** The loss sentence, then the note, as the dialog's description, so both are read as it opens. */\nexport const CheckpointLoss = defineComponent({\n  name: \"CheckpointLoss\",\n  props: {\n    description: { type: String, required: true },\n    note: { type: String, required: true },\n  },\n  setup(props) {\n    return () =>\n      h(KindAlertDialogDescription, { \"data-checkpoint-loss\": \"\" }, () => [\n        h(\"span\", { \"data-checkpoint-loss-text\": \"\" }, props.description),\n        h(\"span\", { \"data-checkpoint-note\": \"\" }, props.note),\n      ]);\n  },\n});\n\n/**\n * \"Restore\" and a radio per scope, unless you pass a default slot, which gets the Radio group's props as `state`.\n * Rendered only while the host offers more than one scope.\n */\nexport const CheckpointScope = defineComponent({\n  name: \"CheckpointScope\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Scope, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: Scope<CheckpointScopeState>) => [\n            h(\"span\", { \"aria-hidden\": \"true\", \"data-checkpoint-scope-label\": \"\" }, state.label),\n            h(\n              KindRadioGroup,\n              {\n                // Vue's Radio group takes a string controller, not the scope union core's is typed with.\n                controller: state.controller as RadioGroupController,\n                defaultValue: state.defaultValue,\n                \"aria-label\": state.label,\n                \"data-agent-hidden\": \"\",\n              },\n              () =>\n                state.options.map((option) =>\n                  h(\"label\", { key: option.value, \"data-checkpoint-option\": \"\" }, [\n                    h(KindRadio, { value: option.value }, () => h(KindRadioIndicator)),\n                    option.label,\n                  ]),\n                ),\n            ),\n          ]),\n      });\n  },\n});\n\n/** Calls `onCompare`. Reads \"Compare\" with its icon unless you pass a default slot. Rendered only with `onCompare`. */\nexport const CheckpointCompare = defineComponent({\n  name: \"CheckpointCompare\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Compare, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (() => [h(\"span\", { \"data-checkpoint-compare-icon\": \"\", \"aria-hidden\": \"true\" }), \"Compare\"]),\n      });\n  },\n});\n\n/**\n * \"Restored code and conversation\" with a check and what it brought back, in Restore's place once the host restores\n * the checkpoint, unless you pass a default slot.\n */\nexport const CheckpointRestored = defineComponent({\n  name: \"CheckpointRestored\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Restored, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (({ state }: Scope<{ outcome: string; meta: string }>) => [\n            h(\"span\", { \"aria-hidden\": \"true\", \"data-status-mark\": \"\", \"data-status\": \"complete\" }),\n            state.outcome,\n            state.meta ? h(\"span\", { \"data-checkpoint-outcome-meta\": \"\" }, state.meta) : null,\n          ]),\n      });\n  },\n});\n\n/** \"Couldn't restore. Try again.\" after a restore fails, unless you pass a default slot. */\nexport const CheckpointError = defineComponent({\n  name: \"CheckpointError\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Error, attrs, { ...slots, default: slots.default ?? (() => \"Couldn't restore. Try again.\") });\n  },\n});\n\n/** Closes the dialog. Reads \"Cancel\" unless you pass a default slot. */\nexport const CheckpointCancel = defineComponent({\n  name: \"CheckpointCancel\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () => h(parts.Cancel, attrs, { ...slots, default: slots.default ?? (() => \"Cancel\") });\n  },\n});\n\n/** Calls `onRestore`. Reads \"Restore\", with a running mark while the restore is pending, unless you pass a default slot. */\nexport const CheckpointConfirm = defineComponent({\n  name: \"CheckpointConfirm\",\n  inheritAttrs: false,\n  setup(_, { attrs, slots }) {\n    return () =>\n      h(parts.Confirm, attrs, {\n        ...slots,\n        default:\n          slots.default ??\n          (() => [\n            // The mark shows only while the restore is pending (controls.css).\n            h(\"span\", {\n              \"data-kind-pending-mark\": \"\",\n              \"data-status-mark\": \"\",\n              \"data-status\": \"running\",\n              \"aria-hidden\": \"true\",\n            }),\n            \"Restore\",\n          ]),\n      });\n  },\n});\n",
      "type": "registry:ui",
      "target": "@ui/vue/checkpoint.ts"
    }
  ],
  "meta": {
    "layer": "vue"
  },
  "type": "registry:ui"
}
