{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "edit-conflict",
  "title": "Edit Conflict",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/edit-conflict/EditConflict.tsx",
      "content": "import * as React from 'react'\nimport { View, type ViewProps } from 'react-native'\nimport { Alert, AlertDescription } from '@/components/ui/alert'\nimport { Button } from '@/components/ui/button'\nimport { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\n\nexport type EditConflictChoice = 'saved' | 'draft'\n\nexport interface EditConflictVersion {\n  /** A revision ID. Give a replacement version a different ID. */\n  id: string\n  summary: string\n  /** A caller-localized date or time. */\n  updatedAt?: string\n}\n\nexport interface EditConflictDecision {\n  choice: EditConflictChoice\n  savedId: string\n  draftId: string\n}\n\nconst defaultLabels = {\n  options: 'Choose the version to keep',\n  saved: 'Keep saved version',\n  draft: 'Keep my draft',\n  apply: 'Apply choice',\n  applying: 'Applying choice…',\n  retry: 'Retry applying choice',\n  failed: 'The choice could not be applied. Both versions are still shown.',\n}\n\nexport interface EditConflictProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  title: string\n  description?: string\n  saved: EditConflictVersion\n  draft: EditConflictVersion\n  onResolve: (decision: EditConflictDecision) => void | boolean | Promise<void | boolean>\n  disabled?: boolean\n  labels?: Partial<typeof defaultLabels>\n}\n\nexport function EditConflict(props: EditConflictProps) {\n  return <ConflictDecision key={JSON.stringify([props.saved.id, props.draft.id])} {...props} />\n}\n\nfunction ConflictDecision({\n  className,\n  title,\n  description,\n  saved,\n  draft,\n  onResolve,\n  disabled = false,\n  labels,\n  ...props\n}: EditConflictProps) {\n  const copy = { ...defaultLabels, ...labels }\n  const [choice, setChoice] = React.useState<EditConflictChoice>()\n  const [pending, setPending] = React.useState(false)\n  const [failed, setFailed] = React.useState(false)\n  const inFlight = React.useRef(false)\n  const actionLabel = pending ? copy.applying : failed ? copy.retry : copy.apply\n  useAnnouncement(failed ? copy.failed : undefined)\n\n  async function confirm() {\n    if (!choice || disabled || inFlight.current) return\n    inFlight.current = true\n    setPending(true)\n    setFailed(false)\n    try {\n      if ((await onResolve({ choice, savedId: saved.id, draftId: draft.id })) === false) setFailed(true)\n    } catch {\n      setFailed(true)\n    } finally {\n      inFlight.current = false\n      setPending(false)\n    }\n  }\n\n  return (\n    <View {...props} className={cn('gap-4', className)}>\n      <View className=\"gap-1\">\n        <Text size=\"xl\" accessibilityRole=\"header\">\n          {title}\n        </Text>\n        {description ? <Text variant=\"muted\">{description}</Text> : null}\n      </View>\n      <RadioGroup\n        accessibilityLabel={copy.options}\n        value={choice ?? ''}\n        disabled={pending || disabled}\n        onValueChange={(value) => {\n          if (inFlight.current || (value !== 'saved' && value !== 'draft')) return\n          setChoice(value)\n          setFailed(false)\n        }}\n      >\n        <RadioGroupItem\n          value=\"saved\"\n          label={copy.saved}\n          accessibilityLabel={[copy.saved, saved.updatedAt, saved.summary].filter(Boolean).join(', ')}\n          className={cn('items-start rounded-xl border border-border bg-card', choice === 'saved' && 'border-primary')}\n        >\n          {saved.updatedAt ? (\n            <Text variant=\"muted\" size=\"sm\">\n              {saved.updatedAt}\n            </Text>\n          ) : null}\n          <Text>{saved.summary}</Text>\n        </RadioGroupItem>\n        <RadioGroupItem\n          value=\"draft\"\n          label={copy.draft}\n          accessibilityLabel={[copy.draft, draft.updatedAt, draft.summary].filter(Boolean).join(', ')}\n          className={cn('items-start rounded-xl border border-border bg-card', choice === 'draft' && 'border-primary')}\n        >\n          {draft.updatedAt ? (\n            <Text variant=\"muted\" size=\"sm\">\n              {draft.updatedAt}\n            </Text>\n          ) : null}\n          <Text>{draft.summary}</Text>\n        </RadioGroupItem>\n      </RadioGroup>\n      {failed ? (\n        <Alert accessibilityRole=\"none\" variant=\"destructive\">\n          <AlertDescription>{copy.failed}</AlertDescription>\n        </Alert>\n      ) : null}\n      <Button\n        loading={pending}\n        disabled={disabled || !choice}\n        accessibilityLabel={actionLabel}\n        onPress={() => {\n          void confirm()\n        }}\n      >\n        {actionLabel}\n      </Button>\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/edit-conflict/EditConflict.tsx"
    },
    {
      "path": "packages/registry-native/blocks/edit-conflict/index.ts",
      "content": "export {\n  EditConflict,\n  type EditConflictChoice,\n  type EditConflictDecision,\n  type EditConflictProps,\n  type EditConflictVersion,\n} from './EditConflict'\n",
      "type": "registry:block",
      "target": "~/components/blocks/edit-conflict/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/alert.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/radio-group.json",
    "https://native.uipkge.dev/r/native/text.json"
  ],
  "description": "A native section for comparing saved and draft edits and applying a revision-specific choice.",
  "categories": [
    "workflow",
    "editing"
  ]
}