{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "item-substitution",
  "title": "Item Substitution",
  "type": "registry:block",
  "files": [
    {
      "path": "packages/registry-native/blocks/item-substitution/ItemSubstitution.tsx",
      "content": "import { View, type ViewProps } from 'react-native'\nimport { Button } from '@/components/ui/button'\nimport { Text } from '@/components/ui/text'\nimport { useAnnouncement } from '@/lib/accessibility'\nimport { cn } from '@/lib/utils'\n\nexport interface SubstitutionItem {\n  title: string\n  detail?: string\n  /** Localized price for the full line, including the relevant quantity. */\n  price: string\n}\n\nexport type SubstitutionDecision = 'accept' | 'refund'\nexport type ItemSubstitutionStatus = 'review' | 'accepted' | 'refund-requested'\n\ninterface SubstitutionLabels {\n  original: string\n  replacement: string\n  noReplacement: string\n  estimate: string\n  accept: string\n  refund: string\n  accepted: string\n  refundRequested: string\n}\n\nexport interface ItemSubstitutionProps extends Omit<ViewProps, 'children'> {\n  className?: string\n  title?: string\n  original: SubstitutionItem\n  replacement: SubstitutionItem | null\n  /** An estimated, already formatted price delta, for example \"+$0.55\". */\n  priceDifference?: string\n  status?: ItemSubstitutionStatus\n  pending?: SubstitutionDecision\n  error?: string\n  labels?: Partial<SubstitutionLabels>\n  onDecision?: (decision: SubstitutionDecision) => void\n}\n\nexport function ItemSubstitution({\n  className,\n  title = 'Review replacement',\n  original,\n  replacement,\n  priceDifference,\n  status = 'review',\n  pending,\n  error,\n  labels,\n  onDecision,\n  ...props\n}: ItemSubstitutionProps) {\n  const reviewing = status === 'review'\n  const outcome =\n    status === 'accepted'\n      ? (labels?.accepted ?? 'Replacement accepted')\n      : status === 'refund-requested'\n        ? (labels?.refundRequested ?? 'Refund requested')\n        : undefined\n  useAnnouncement(outcome ?? error)\n\n  return (\n    <View {...props} className={cn('gap-[16px]', className)}>\n      <Text size=\"title\" accessibilityRole=\"header\">\n        {outcome ?? title}\n      </Text>\n      <View className=\"gap-[12px] rounded-lg border border-border bg-card p-[16px]\">\n        <View className=\"gap-[4px]\">\n          <Text size=\"sm\" variant=\"muted\">\n            {labels?.original ?? 'Unavailable item'}\n          </Text>\n          <View className=\"flex-row flex-wrap items-start justify-between gap-[8px]\">\n            <View className=\"min-w-[120px] flex-1 gap-[4px]\">\n              <Text className=\"font-semibold text-card-foreground\">{original.title}</Text>\n              {original.detail ? (\n                <Text size=\"sm\" variant=\"muted\">\n                  {original.detail}\n                </Text>\n              ) : null}\n            </View>\n            <Text className=\"shrink font-semibold text-card-foreground\" style={{ fontVariant: ['tabular-nums'] }}>\n              {original.price}\n            </Text>\n          </View>\n        </View>\n        {replacement && status !== 'refund-requested' ? (\n          <View className=\"gap-[4px] border-t border-border pt-[12px]\">\n            <Text size=\"sm\" variant=\"muted\">\n              {labels?.replacement ?? 'Replacement'}\n            </Text>\n            <View className=\"flex-row flex-wrap items-start justify-between gap-[8px]\">\n              <View className=\"min-w-[120px] flex-1 gap-[4px]\">\n                <Text className=\"font-semibold text-card-foreground\">{replacement.title}</Text>\n                {replacement.detail ? (\n                  <Text size=\"sm\" variant=\"muted\">\n                    {replacement.detail}\n                  </Text>\n                ) : null}\n              </View>\n              <Text className=\"shrink font-semibold text-card-foreground\" style={{ fontVariant: ['tabular-nums'] }}>\n                {replacement.price}\n              </Text>\n            </View>\n          </View>\n        ) : null}\n      </View>\n\n      {reviewing ? (\n        <>\n          {replacement && priceDifference ? (\n            <View className=\"flex-row flex-wrap items-start justify-between gap-[8px]\">\n              <Text size=\"sm\" variant=\"muted\" className=\"shrink\">\n                {labels?.estimate ?? 'Estimated price difference'}\n              </Text>\n              <Text size=\"sm\" className=\"shrink font-semibold\" style={{ fontVariant: ['tabular-nums'] }}>\n                {priceDifference}\n              </Text>\n            </View>\n          ) : !replacement ? (\n            <Text size=\"sm\" variant=\"muted\">\n              {labels?.noReplacement ?? 'A replacement isn’t available.'}\n            </Text>\n          ) : null}\n          {error ? (\n            <Text size=\"sm\" accessibilityRole=\"alert\" className=\"text-destructive\">\n              {error}\n            </Text>\n          ) : null}\n          {onDecision ? (\n            <View className=\"gap-[8px]\">\n              {replacement ? (\n                <Button\n                  accessibilityLabel={labels?.accept ?? 'Accept replacement'}\n                  disabled={pending === 'refund'}\n                  loading={pending === 'accept'}\n                  onPress={() => {\n                    if (!pending) onDecision('accept')\n                  }}\n                >\n                  {labels?.accept ?? 'Accept replacement'}\n                </Button>\n              ) : null}\n              <Button\n                accessibilityLabel={labels?.refund ?? 'Request refund'}\n                variant={replacement ? 'outline' : 'default'}\n                disabled={pending === 'accept'}\n                loading={pending === 'refund'}\n                onPress={() => {\n                  if (!pending) onDecision('refund')\n                }}\n              >\n                {labels?.refund ?? 'Request refund'}\n              </Button>\n            </View>\n          ) : null}\n        </>\n      ) : null}\n    </View>\n  )\n}\n",
      "type": "registry:block",
      "target": "~/components/blocks/item-substitution/ItemSubstitution.tsx"
    },
    {
      "path": "packages/registry-native/blocks/item-substitution/index.ts",
      "content": "export {\n  ItemSubstitution,\n  type ItemSubstitutionProps,\n  type ItemSubstitutionStatus,\n  type SubstitutionDecision,\n  type SubstitutionItem,\n} from './ItemSubstitution'\n",
      "type": "registry:block",
      "target": "~/components/blocks/item-substitution/index.ts"
    }
  ],
  "dependencies": [],
  "devDependencies": [],
  "registryDependencies": [
    "https://native.uipkge.dev/r/native/accessibility.json",
    "https://native.uipkge.dev/r/native/button.json",
    "https://native.uipkge.dev/r/native/text.json",
    "https://native.uipkge.dev/r/native/utils.json"
  ],
  "description": "Compare an out-of-stock order item with its proposed replacement, then accept or request a refund.",
  "categories": [
    "commerce"
  ]
}