{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "comp-324",
  "type": "registry:component",
  "title": "Comp 324",
  "description": "Comp 324",
  "files": [
    {
      "path": "registry/ui-basic/comp-324.tsx",
      "content": "\"use client\";\r\n\r\nimport { useEffect, useRef, useState } from \"react\";\r\n\r\nimport { Button } from \"@/components/ui/button\";\r\nimport {\r\n\tDialog,\r\n\tDialogClose,\r\n\tDialogContent,\r\n\tDialogDescription,\r\n\tDialogHeader,\r\n\tDialogTitle,\r\n\tDialogTrigger,\r\n} from \"@/components/ui/dialog\";\r\nimport { OTPInput, SlotProps } from \"input-otp\";\r\n\r\nimport { cn } from \"../utilities/cn\";\r\n\r\nconst CORRECT_CODE = \"6548\";\r\n\r\nexport default function Component() {\r\n\tconst [value, setValue] = useState(\"\");\r\n\tconst [hasGuessed, setHasGuessed] = useState<undefined | boolean>(undefined);\r\n\tconst inputRef = useRef<HTMLInputElement>(null);\r\n\tconst closeButtonRef = useRef<HTMLButtonElement>(null);\r\n\r\n\tuseEffect(() => {\r\n\t\tif (hasGuessed) {\r\n\t\t\tcloseButtonRef.current?.focus();\r\n\t\t}\r\n\t}, [hasGuessed]);\r\n\r\n\tasync function onSubmit(e?: React.FormEvent<HTMLFormElement>) {\r\n\t\te?.preventDefault?.();\r\n\r\n\t\tinputRef.current?.select();\r\n\t\tawait new Promise((r) => setTimeout(r, 1_00));\r\n\r\n\t\tsetHasGuessed(value === CORRECT_CODE);\r\n\r\n\t\tsetValue(\"\");\r\n\t\tsetTimeout(() => {\r\n\t\t\tinputRef.current?.blur();\r\n\t\t}, 20);\r\n\t}\r\n\r\n\treturn (\r\n\t\t<Dialog>\r\n\t\t\t<DialogTrigger asChild>\r\n\t\t\t\t<Button variant=\"outline\">OTP code</Button>\r\n\t\t\t</DialogTrigger>\r\n\t\t\t<DialogContent>\r\n\t\t\t\t<div className=\"flex flex-col items-center gap-2\">\r\n\t\t\t\t\t<div\r\n\t\t\t\t\t\tclassName=\"flex size-11 shrink-0 items-center justify-center rounded-full border\"\r\n\t\t\t\t\t\taria-hidden=\"true\"\r\n\t\t\t\t\t>\r\n\t\t\t\t\t\t<svg\r\n\t\t\t\t\t\t\tclassName=\"stroke-zinc-800 dark:stroke-zinc-100\"\r\n\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\r\n\t\t\t\t\t\t\twidth=\"20\"\r\n\t\t\t\t\t\t\theight=\"20\"\r\n\t\t\t\t\t\t\tviewBox=\"0 0 32 32\"\r\n\t\t\t\t\t\t\taria-hidden=\"true\"\r\n\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t<circle\r\n\t\t\t\t\t\t\t\tcx=\"16\"\r\n\t\t\t\t\t\t\t\tcy=\"16\"\r\n\t\t\t\t\t\t\t\tr=\"12\"\r\n\t\t\t\t\t\t\t\tfill=\"none\"\r\n\t\t\t\t\t\t\t\tstrokeWidth=\"8\"\r\n\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t</svg>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<DialogHeader>\r\n\t\t\t\t\t\t<DialogTitle className=\"sm:text-center\">\r\n\t\t\t\t\t\t\t{hasGuessed ? \"Code verified!\" : \"Enter confirmation code\"}\r\n\t\t\t\t\t\t</DialogTitle>\r\n\t\t\t\t\t\t<DialogDescription className=\"sm:text-center\">\r\n\t\t\t\t\t\t\t{hasGuessed\r\n\t\t\t\t\t\t\t\t? \"Your code has been successfully verified.\"\r\n\t\t\t\t\t\t\t\t: `Check your email and enter the code - Try ${CORRECT_CODE}`}\r\n\t\t\t\t\t\t</DialogDescription>\r\n\t\t\t\t\t</DialogHeader>\r\n\t\t\t\t</div>\r\n\r\n\t\t\t\t{hasGuessed ? (\r\n\t\t\t\t\t<div className=\"text-center\">\r\n\t\t\t\t\t\t<DialogClose asChild>\r\n\t\t\t\t\t\t\t<Button type=\"button\" ref={closeButtonRef}>\r\n\t\t\t\t\t\t\t\tClose\r\n\t\t\t\t\t\t\t</Button>\r\n\t\t\t\t\t\t</DialogClose>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t) : (\r\n\t\t\t\t\t<div className=\"space-y-4\">\r\n\t\t\t\t\t\t<div className=\"flex justify-center\">\r\n\t\t\t\t\t\t\t<OTPInput\r\n\t\t\t\t\t\t\t\tid=\"cofirmation-code\"\r\n\t\t\t\t\t\t\t\tref={inputRef}\r\n\t\t\t\t\t\t\t\tvalue={value}\r\n\t\t\t\t\t\t\t\tonChange={setValue}\r\n\t\t\t\t\t\t\t\tcontainerClassName=\"flex items-center gap-3 has-disabled:opacity-50\"\r\n\t\t\t\t\t\t\t\tmaxLength={4}\r\n\t\t\t\t\t\t\t\tonFocus={() => setHasGuessed(undefined)}\r\n\t\t\t\t\t\t\t\trender={({ slots }) => (\r\n\t\t\t\t\t\t\t\t\t<div className=\"flex gap-2\">\r\n\t\t\t\t\t\t\t\t\t\t{slots.map((slot, idx) => (\r\n\t\t\t\t\t\t\t\t\t\t\t<Slot key={idx} {...slot} />\r\n\t\t\t\t\t\t\t\t\t\t))}\r\n\t\t\t\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t\t\tonComplete={onSubmit}\r\n\t\t\t\t\t\t\t/>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t\t{hasGuessed === false && (\r\n\t\t\t\t\t\t\t<p\r\n\t\t\t\t\t\t\t\tclassName=\"text-muted-foreground text-center text-xs\"\r\n\t\t\t\t\t\t\t\trole=\"alert\"\r\n\t\t\t\t\t\t\t\taria-live=\"polite\"\r\n\t\t\t\t\t\t\t>\r\n\t\t\t\t\t\t\t\tInvalid code. Please try again.\r\n\t\t\t\t\t\t\t</p>\r\n\t\t\t\t\t\t)}\r\n\t\t\t\t\t\t<p className=\"text-center text-sm\">\r\n\t\t\t\t\t\t\t<a className=\"underline hover:no-underline\" href=\"#\">\r\n\t\t\t\t\t\t\t\tResend code\r\n\t\t\t\t\t\t\t</a>\r\n\t\t\t\t\t\t</p>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t)}\r\n\t\t\t</DialogContent>\r\n\t\t</Dialog>\r\n\t);\r\n}\r\n\r\nfunction Slot(props: SlotProps) {\r\n\treturn (\r\n\t\t<div\r\n\t\t\tclassName={cn(\r\n\t\t\t\t\"border-input bg-background text-foreground flex size-9 items-center justify-center rounded-md border font-medium shadow-2xs transition-[color,box-shadow]\",\r\n\t\t\t\t{ \"border-ring ring-ring/50 z-10 ring-[3px]\": props.isActive }\r\n\t\t\t)}\r\n\t\t>\r\n\t\t\t{props.char !== null && <div>{props.char}</div>}\r\n\t\t</div>\r\n\t);\r\n}\r\n",
      "type": "registry:ui"
    },
    {
      "path": "components/ui/button.tsx",
      "content": "import * as React from \"react\";\r\n\r\nimport { cn } from \"@/registry/utilities/cn\";\r\nimport { Slot } from \"@radix-ui/react-slot\";\r\nimport { cva, type VariantProps } from \"class-variance-authority\";\r\n\r\nconst buttonVariants = cva(\r\n\t\"inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm text-white hover:text-gray-400 font-medium ring-offset-background transition-colors focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50\",\r\n\t{\r\n\t\tvariants: {\r\n\t\t\tvariant: {\r\n\t\t\t\tsimple:\r\n\t\t\t\t\t\"bg-secondary relative z-10 bg-transparent hover:border-secondary hover:bg-secondary/50  border border-transparent dark:text-white text-sm md:text-sm transition font-medium duration-200  rounded-md px-4 py-2  flex items-center justify-center\",\r\n\t\t\t\tdefault: \"bg-primary text-primary-foreground hover:bg-primary/90\",\r\n\t\t\t\tdestructive:\r\n\t\t\t\t\t\"bg-destructive text-destructive-foreground hover:bg-destructive/90\",\r\n\t\t\t\toutline:\r\n\t\t\t\t\t\"border border-input bg-background hover:bg-accent hover:text-accent-foreground\",\r\n\t\t\t\tsecondary:\r\n\t\t\t\t\t\"bg-secondary text-secondary-foreground hover:bg-secondary/80\",\r\n\t\t\t\tghost: \"hover:bg-accent hover:text-black hover:stroke-black dark:text-white text-black\",\r\n\t\t\t\tlink: \"text-primary underline-offset-4 hover:underline\",\r\n\t\t\t},\r\n\t\t\tsize: {\r\n\t\t\t\tdefault: \"h-10 px-4 py-2\",\r\n\t\t\t\tsm: \"h-9 rounded-md px-3\",\r\n\t\t\t\tlg: \"h-11 rounded-md px-8\",\r\n\t\t\t\ticon: \"h-10 w-10\",\r\n\t\t\t},\r\n\t\t},\r\n\t\tdefaultVariants: {\r\n\t\t\tvariant: \"default\",\r\n\t\t\tsize: \"default\",\r\n\t\t},\r\n\t}\r\n);\r\n\r\nexport interface ButtonProps\r\n\textends React.ButtonHTMLAttributes<HTMLButtonElement>,\r\n\t\tVariantProps<typeof buttonVariants> {\r\n\tasChild?: boolean;\r\n}\r\n\r\nconst Button = React.forwardRef<HTMLButtonElement, ButtonProps>(\r\n\t({ className, variant, size, asChild = false, ...props }, ref) => {\r\n\t\tconst Comp = asChild ? Slot : \"button\";\r\n\t\treturn (\r\n\t\t\t<Comp\r\n\t\t\t\tclassName={cn(buttonVariants({ variant, size, className }))}\r\n\t\t\t\tref={ref}\r\n\t\t\t\t{...props}\r\n\t\t\t/>\r\n\t\t);\r\n\t}\r\n);\r\nButton.displayName = \"Button\";\r\n\r\nexport { Button, buttonVariants };\r\n",
      "type": "registry:ui"
    },
    {
      "path": "registry/utilities/cn.ts",
      "content": "import { ClassValue, clsx } from \"clsx\";\r\nimport { twMerge } from \"tailwind-merge\";\r\n\r\nexport function cn(...inputs: ClassValue[]) {\r\n\treturn twMerge(clsx(inputs));\r\n}\r\n",
      "type": "registry:ui"
    }
  ]
}