{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "checkpoint",
  "title": "Checkpoint",
  "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/react@0.1.0-beta.17"
  ],
  "registryDependencies": [
    "@kind-ui/agent-ui-setup",
    "@kind-ui/internal-alert-dialog",
    "@kind-ui/internal-radio",
    "@kind-ui/internal-tooltip"
  ],
  "files": [
    {
      "path": "packages/agent-ui/src/react/checkpoint.tsx",
      "content": "\"use client\";\n\nimport { type CheckpointDialogState, checkpointPrimitive } from \"@kind-ui/agent-ui/core\";\nimport { createParts } from \"@ui-sdk/react/primitive\";\nimport type { ComponentProps, ReactNode } from \"react\";\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\nexport type CheckpointProps = ComponentProps<typeof parts.Root>;\n\n/**\n * A marker in the conversation that a person can restore. Restore opens a dialog that asks before calling\n * `onRestore`. Any `children` replace the default parts.\n */\nexport function Checkpoint({ children = DEFAULT_PARTS, ...props }: CheckpointProps) {\n  return <parts.Root {...props}>{children}</parts.Root>;\n}\n\nexport const CheckpointLine = parts.Line;\n\nexport type CheckpointLabelProps = ComponentProps<typeof parts.Label>;\n\n/** The `label`, unless you pass children. */\nexport function CheckpointLabel({ children = ({ label }) => label, ...props }: CheckpointLabelProps) {\n  return <parts.Label {...props}>{children}</parts.Label>;\n}\n\nexport type CheckpointDescriptionProps = ComponentProps<typeof parts.Description>;\n\n/** The `description`, unless you pass children. Rendered only with one. */\nexport function CheckpointDescription({\n  children = ({ description }) => description,\n  ...props\n}: CheckpointDescriptionProps) {\n  return <parts.Description {...props}>{children}</parts.Description>;\n}\n\nexport type CheckpointRestoreProps = ComponentProps<typeof parts.Restore>;\n\n/**\n * Restore and its dialog, unless you pass children: a function that gets the Alert Dialog's props. Rendered only\n * while `onRestore` is set and the checkpoint isn't `restored`.\n */\nexport function CheckpointRestore({\n  children = ({ controller, dismissible, ...dialog }) => (\n    <KindAlertDialog controller={controller} dismissible={dismissible}>\n      <KindTooltip type=\"label\">\n        <KindTooltipTrigger\n          render={<KindAlertDialogTrigger />}\n          data-checkpoint-trigger=\"\"\n          data-kind-icon-button=\"\"\n        />\n        <KindTooltipContent>Restore checkpoint</KindTooltipContent>\n      </KindTooltip>\n      <CheckpointDialog {...dialog} />\n    </KindAlertDialog>\n  ),\n  ...props\n}: CheckpointRestoreProps) {\n  return <parts.Restore {...props}>{children}</parts.Restore>;\n}\n\nexport type CheckpointDialogProps = Omit<CheckpointDialogState, \"controller\" | \"dismissible\" | \"busy\"> & {\n  busy?: boolean;\n  children?: ReactNode;\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 children, which replace the scope and the answers.\n */\nexport function CheckpointDialog({\n  title,\n  point,\n  description,\n  note,\n  initialFocus,\n  busy,\n  children,\n}: CheckpointDialogProps) {\n  return (\n    <>\n      <KindAlertDialogBackdrop />\n      <KindAlertDialogContent initialFocus={initialFocus} aria-busy={busy || undefined}>\n        <KindAlertDialogTitle>{title}</KindAlertDialogTitle>\n        {point ? <p data-checkpoint-point=\"\">{point}</p> : null}\n        {children ?? (\n          <>\n            <CheckpointScope />\n            <CheckpointLoss description={description} note={note} />\n            {DEFAULT_ANSWERS}\n          </>\n        )}\n      </KindAlertDialogContent>\n    </>\n  );\n}\n\nexport type CheckpointLossProps = Pick<CheckpointDialogState, \"description\" | \"note\">;\n\n/** The loss sentence, then the note, as the dialog's description, so both are read as it opens. */\nexport function CheckpointLoss({ description, note }: CheckpointLossProps) {\n  return (\n    <KindAlertDialogDescription data-checkpoint-loss=\"\">\n      <span data-checkpoint-loss-text=\"\">{description}</span>\n      <span data-checkpoint-note=\"\">{note}</span>\n    </KindAlertDialogDescription>\n  );\n}\n\nexport type CheckpointScopeProps = ComponentProps<typeof parts.Scope>;\n\n/**\n * \"Restore\" and a radio per scope, unless you pass children: a function that gets the Radio group's props. Rendered\n * only while the host offers more than one scope.\n */\nexport function CheckpointScope({\n  children = ({ controller, defaultValue, options, label }) => (\n    <>\n      <span aria-hidden=\"true\" data-checkpoint-scope-label=\"\">\n        {label}\n      </span>\n      <KindRadioGroup\n        controller={controller}\n        defaultValue={defaultValue}\n        aria-label={label}\n        data-agent-hidden=\"\"\n      >\n        {options.map((option) => (\n          // biome-ignore lint/a11y/noLabelWithoutControl: the label wraps UI SDK's radio, which it names.\n          <label key={option.value} data-checkpoint-option=\"\">\n            <KindRadio value={option.value}>\n              <KindRadioIndicator />\n            </KindRadio>\n            {option.label}\n          </label>\n        ))}\n      </KindRadioGroup>\n    </>\n  ),\n  ...props\n}: CheckpointScopeProps) {\n  return <parts.Scope {...props}>{children}</parts.Scope>;\n}\n\nexport type CheckpointCompareProps = ComponentProps<typeof parts.Compare>;\n\n/** Calls `onCompare`. Reads \"Compare\" with its icon unless you pass children. Rendered only with `onCompare`. */\nexport function CheckpointCompare({ children = COMPARE_LABEL, ...props }: CheckpointCompareProps) {\n  return <parts.Compare {...props}>{children}</parts.Compare>;\n}\n\nexport type CheckpointRestoredProps = ComponentProps<typeof parts.Restored>;\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 children.\n */\nexport function CheckpointRestored({\n  children = ({ outcome, meta }) => (\n    <>\n      <span aria-hidden=\"true\" data-status-mark=\"\" data-status=\"complete\" />\n      {outcome}\n      {meta ? <span data-checkpoint-outcome-meta=\"\">{meta}</span> : null}\n    </>\n  ),\n  ...props\n}: CheckpointRestoredProps) {\n  return <parts.Restored {...props}>{children}</parts.Restored>;\n}\n\nexport type CheckpointErrorProps = ComponentProps<typeof parts.Error>;\n\n/** \"Couldn't restore. Try again.\" after a restore fails, unless you pass children. */\nexport function CheckpointError({\n  children = \"Couldn't restore. Try again.\",\n  ...props\n}: CheckpointErrorProps) {\n  return <parts.Error {...props}>{children}</parts.Error>;\n}\n\nexport type CheckpointCancelProps = ComponentProps<typeof parts.Cancel>;\n\n/** Closes the dialog. Reads \"Cancel\" unless you pass children. */\nexport function CheckpointCancel({ children = \"Cancel\", ...props }: CheckpointCancelProps) {\n  return <parts.Cancel {...props}>{children}</parts.Cancel>;\n}\n\nexport type CheckpointConfirmProps = ComponentProps<typeof parts.Confirm>;\n\n/** Calls `onRestore`. Reads \"Restore\", with a running mark while the restore is pending, unless you pass children. */\nexport function CheckpointConfirm({ children = CONFIRM_LABEL, ...props }: CheckpointConfirmProps) {\n  return <parts.Confirm {...props}>{children}</parts.Confirm>;\n}\n\n// The mark shows only while the restore is pending (controls.css).\nconst CONFIRM_LABEL = (\n  <>\n    <span data-kind-pending-mark=\"\" data-status-mark=\"\" data-status=\"running\" aria-hidden=\"true\" />\n    Restore\n  </>\n);\n\nconst COMPARE_LABEL = (\n  <>\n    <span data-checkpoint-compare-icon=\"\" aria-hidden=\"true\" />\n    Compare\n  </>\n);\n\n// Shared, so an update doesn't render the default parts' wrappers again.\nconst DEFAULT_ANSWERS = (\n  <div data-checkpoint-answers=\"\">\n    <CheckpointCompare />\n    <CheckpointError />\n    <CheckpointCancel />\n    <CheckpointConfirm />\n  </div>\n);\n\nconst DEFAULT_PARTS = (\n  <>\n    <CheckpointLabel />\n    <CheckpointDescription />\n    <CheckpointLine />\n    <CheckpointRestore />\n    <CheckpointRestored />\n  </>\n);\n",
      "type": "registry:ui",
      "target": "@ui/checkpoint.tsx"
    }
  ],
  "meta": {
    "layer": "react"
  },
  "type": "registry:ui"
}
