{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "alert-dialog",
  "dependencies": [
    "class-variance-authority",
    "motion",
    "radix-ui"
  ],
  "registryDependencies": [
    "utils"
  ],
  "files": [
    {
      "path": "src/components/watermelon-ui/alert-dialog.tsx",
      "content": "'use client';\n\nimport * as React from 'react';\nimport { AlertDialog as AlertDialogPrime } from 'radix-ui';\nimport { AnimatePresence, motion, type HTMLMotionProps } from 'motion/react';\nimport { cn } from '@/lib/utils';\nimport { cva } from 'class-variance-authority';\n\ntype AlertDialogProps = AlertDialogPrimitiveProps;\n\nfunction AlertDialog(props: AlertDialogProps) {\n  return <AlertDialogPrimitive {...props} />;\n}\n\ntype AlertDialogTriggerProps = AlertDialogTriggerPrimitiveProps;\n\nfunction AlertDialogTrigger(props: AlertDialogTriggerProps) {\n  return <AlertDialogTriggerPrimitive {...props} />;\n}\n\ntype AlertDialogOverlayProps = AlertDialogOverlayPrimitiveProps;\n\nfunction AlertDialogOverlay({ className, ...props }: AlertDialogOverlayProps) {\n  return (\n    <AlertDialogOverlayPrimitive\n      className={cn('fixed inset-0 z-50 bg-black/50', className)}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogContentProps = AlertDialogContentPrimitiveProps;\n\nfunction AlertDialogContent({ className, ...props }: AlertDialogContentProps) {\n  return (\n    <AlertDialogPortalPrimitive>\n      <AlertDialogOverlay />\n      <AlertDialogContentPrimitive\n        className={cn(\n          'bg-background fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg sm:max-w-lg',\n          className,\n        )}\n        {...props}\n      />\n    </AlertDialogPortalPrimitive>\n  );\n}\n\ntype AlertDialogHeaderProps = AlertDialogHeaderPrimitiveProps;\n\nfunction AlertDialogHeader({ className, ...props }: AlertDialogHeaderProps) {\n  return (\n    <AlertDialogHeaderPrimitive\n      className={cn('flex flex-col gap-2 text-center sm:text-left', className)}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogFooterProps = AlertDialogFooterPrimitiveProps;\n\nfunction AlertDialogFooter({ className, ...props }: AlertDialogFooterProps) {\n  return (\n    <AlertDialogFooterPrimitive\n      className={cn(\n        'flex flex-col-reverse gap-2 sm:flex-row sm:justify-end',\n        className,\n      )}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogTitleProps = AlertDialogTitlePrimitiveProps;\n\nfunction AlertDialogTitle({ className, ...props }: AlertDialogTitleProps) {\n  return (\n    <AlertDialogTitlePrimitive\n      className={cn('text-lg font-semibold', className)}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogDescriptionProps = AlertDialogDescriptionPrimitiveProps;\n\nfunction AlertDialogDescription({\n  className,\n  ...props\n}: AlertDialogDescriptionProps) {\n  return (\n    <AlertDialogDescriptionPrimitive\n      className={cn('text-muted-foreground text-sm', className)}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogActionProps = AlertDialogActionPrimitiveProps;\n\nfunction AlertDialogAction({\n  className,\n  ...props\n}: AlertDialogActionPrimitiveProps) {\n  return (\n    <AlertDialogActionPrimitive\n      className={cn(buttonVariants(), className)}\n      {...props}\n    />\n  );\n}\n\ntype AlertDialogCancelProps = AlertDialogCancelPrimitiveProps;\n\nfunction AlertDialogCancel({\n  className,\n  ...props\n}: AlertDialogCancelPrimitiveProps) {\n  return (\n    <AlertDialogCancelPrimitive\n      className={cn(buttonVariants({ variant: 'outline' }), className)}\n      {...props}\n    />\n  );\n}\n\nexport {\n  AlertDialog,\n  AlertDialogTrigger,\n  AlertDialogContent,\n  AlertDialogHeader,\n  AlertDialogFooter,\n  AlertDialogTitle,\n  AlertDialogDescription,\n  AlertDialogAction,\n  AlertDialogCancel,\n  type AlertDialogProps,\n  type AlertDialogTriggerProps,\n  type AlertDialogContentProps,\n  type AlertDialogHeaderProps,\n  type AlertDialogFooterProps,\n  type AlertDialogTitleProps,\n  type AlertDialogDescriptionProps,\n  type AlertDialogActionProps,\n  type AlertDialogCancelProps,\n};\n\nconst buttonVariants = cva(\n  \"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[box-shadow,_color,_background-color,_border-color,_outline-color,_text-decoration-color,_fill,_stroke] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive\",\n  {\n    variants: {\n      variant: {\n        default:\n          'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',\n        accent: 'bg-accent text-accent-foreground shadow-xs hover:bg-accent/90',\n        destructive:\n          'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',\n        outline:\n          'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',\n        secondary:\n          'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',\n        ghost:\n          'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',\n        link: 'text-primary underline-offset-4 hover:underline',\n      },\n      size: {\n        default: 'h-9 px-4 py-2 has-[>svg]:px-3',\n        sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',\n        lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',\n        icon: 'size-9',\n        'icon-sm': 'size-8 rounded-md',\n        'icon-lg': 'size-10 rounded-md',\n      },\n    },\n    defaultVariants: {\n      variant: 'default',\n      size: 'default',\n    },\n  },\n);\n\n\n\ntype AlertDialogContextType = {\n  isOpen: boolean;\n  setIsOpen: AlertDialogProps['onOpenChange'];\n};\n\nconst [AlertDialogProvider, useAlertDialog] =\n  getStrictContext<AlertDialogContextType>('AlertDialogContext');\n\ntype AlertDialogPrimitiveProps = React.ComponentProps<typeof AlertDialogPrime.Root>;\n\nfunction AlertDialogPrimitive(props: AlertDialogPrimitiveProps) {\n  const [isOpen, setIsOpen] = useControlledState({\n    value: props?.open,\n    defaultValue: props?.defaultOpen,\n    onChange: props?.onOpenChange,\n  });\n\n  return (\n    <AlertDialogProvider value={{ isOpen, setIsOpen }}>\n      <AlertDialogPrime.Root\n        data-slot=\"alert-dialog\"\n        {...props}\n        onOpenChange={setIsOpen}\n      />\n    </AlertDialogProvider>\n  );\n}\n\ntype AlertDialogTriggerPrimitiveProps = React.ComponentProps<\n  typeof AlertDialogPrime.Trigger\n>;\n\nfunction AlertDialogTriggerPrimitive(props: AlertDialogTriggerPrimitiveProps) {\n  return (\n    <AlertDialogPrime.Trigger data-slot=\"alert-dialog-trigger\" {...props} />\n  );\n}\n\ntype AlertDialogPortalPrimitiveProps = Omit<\n  React.ComponentProps<typeof AlertDialogPrime.Portal>,\n  'forceMount'\n>;\n\nfunction AlertDialogPortalPrimitive(props: AlertDialogPortalPrimitiveProps) {\n  const { isOpen } = useAlertDialog();\n\n  return (\n    <AnimatePresence>\n      {isOpen && (\n        <AlertDialogPrime.Portal\n          data-slot=\"alert-dialog-portal\"\n          forceMount\n          {...props}\n        />\n      )}\n    </AnimatePresence>\n  );\n}\n\ntype AlertDialogOverlayPrimitiveProps = Omit<\n  React.ComponentProps<typeof AlertDialogPrime.Overlay>,\n  'forceMount' | 'asChild'\n> &\n  HTMLMotionProps<'div'>;\n\nfunction AlertDialogOverlayPrimitive({\n  transition = { duration: 0.2, ease: 'easeInOut' },\n  ...props\n}: AlertDialogOverlayPrimitiveProps) {\n  return (\n    <AlertDialogPrime.Overlay\n      data-slot=\"alert-dialog-overlay\"\n      asChild\n      forceMount\n    >\n      <motion.div\n        key=\"alert-dialog-overlay\"\n        initial={{ opacity: 0, filter: 'blur(4px)' }}\n        animate={{ opacity: 1, filter: 'blur(0px)' }}\n        exit={{ opacity: 0, filter: 'blur(4px)' }}\n        transition={transition}\n        {...props}\n      />\n    </AlertDialogPrime.Overlay>\n  );\n}\n\ntype AlertDialogFlipDirection = 'top' | 'bottom' | 'left' | 'right';\n\ntype AlertDialogContentPrimitiveProps = Omit<\n  React.ComponentProps<typeof AlertDialogPrime.Content>,\n  'forceMount' | 'asChild'\n> &\n  HTMLMotionProps<'div'> & {\n    from?: AlertDialogFlipDirection;\n  };\n\nfunction AlertDialogContentPrimitive({\n  from = 'top',\n  onOpenAutoFocus,\n  onCloseAutoFocus,\n  onEscapeKeyDown,\n  transition = { type: 'spring', stiffness: 150, damping: 25 },\n  ...props\n}: AlertDialogContentPrimitiveProps) {\n  const initialRotation =\n    from === 'bottom' || from === 'left' ? '20deg' : '-20deg';\n  const isVertical = from === 'top' || from === 'bottom';\n  const rotateAxis = isVertical ? 'rotateX' : 'rotateY';\n\n  return (\n    <AlertDialogPrime.Content\n      forceMount\n      onOpenAutoFocus={onOpenAutoFocus}\n      onCloseAutoFocus={onCloseAutoFocus}\n      onEscapeKeyDown={onEscapeKeyDown}\n    >\n      <motion.div\n        key=\"alert-dialog-content\"\n        data-slot=\"alert-dialog-content\"\n        initial={{\n          opacity: 0,\n          filter: 'blur(4px)',\n          transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`,\n        }}\n        animate={{\n          opacity: 1,\n          filter: 'blur(0px)',\n          transform: `perspective(500px) ${rotateAxis}(0deg) scale(1)`,\n        }}\n        exit={{\n          opacity: 0,\n          filter: 'blur(4px)',\n          transform: `perspective(500px) ${rotateAxis}(${initialRotation}) scale(0.8)`,\n        }}\n        transition={transition}\n        {...props}\n      />\n    </AlertDialogPrime.Content>\n  );\n}\n\ntype AlertDialogCancelPrimitiveProps = React.ComponentProps<\n  typeof AlertDialogPrime.Cancel\n>;\n\nfunction AlertDialogCancelPrimitive(props: AlertDialogCancelPrimitiveProps) {\n  return (\n    <AlertDialogPrime.Cancel data-slot=\"alert-dialog-cancel\" {...props} />\n  );\n}\n\ntype AlertDialogActionPrimitiveProps = React.ComponentProps<\n  typeof AlertDialogPrime.Action\n>;\n\nfunction AlertDialogActionPrimitive(props: AlertDialogActionPrimitiveProps) {\n  return (\n    <AlertDialogPrime.Action data-slot=\"alert-dialog-action\" {...props} />\n  );\n}\n\ntype AlertDialogHeaderPrimitiveProps = React.ComponentProps<'div'>;\n\nfunction AlertDialogHeaderPrimitive(props: AlertDialogHeaderPrimitiveProps) {\n  return <div data-slot=\"alert-dialog-header\" {...props} />;\n}\n\ntype AlertDialogFooterPrimitiveProps = React.ComponentProps<'div'>;\n\nfunction AlertDialogFooterPrimitive(props: AlertDialogFooterPrimitiveProps) {\n  return <div data-slot=\"alert-dialog-footer\" {...props} />;\n}\n\ntype AlertDialogTitlePrimitiveProps = React.ComponentProps<\n  typeof AlertDialogPrime.Title\n>;\n\nfunction AlertDialogTitlePrimitive(props: AlertDialogTitlePrimitiveProps) {\n  return (\n    <AlertDialogPrime.Title data-slot=\"alert-dialog-title\" {...props} />\n  );\n}\n\ntype AlertDialogDescriptionPrimitiveProps = React.ComponentProps<\n  typeof AlertDialogPrime.Description\n>;\n\nfunction AlertDialogDescriptionPrimitive(props: AlertDialogDescriptionPrimitiveProps) {\n  return (\n    <AlertDialogPrime.Description\n      data-slot=\"alert-dialog-description\"\n      {...props}\n    />\n  );\n}\n\ninterface CommonControlledStateProps<T> {\n  value?: T;\n  defaultValue?: T;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function useControlledState<T, Rest extends any[] = []>(\n  props: CommonControlledStateProps<T> & {\n    onChange?: (value: T, ...args: Rest) => void;\n  },\n): readonly [T, (next: T, ...args: Rest) => void] {\n  const { value, defaultValue, onChange } = props;\n\n  const [state, setInternalState] = React.useState<T>(\n    value !== undefined ? value : (defaultValue as T),\n  );\n\n  React.useEffect(() => {\n    if (value !== undefined) setInternalState(value);\n  }, [value]);\n\n  const setState = React.useCallback(\n    (next: T, ...args: Rest) => {\n      setInternalState(next);\n      onChange?.(next, ...args);\n    },\n    [onChange],\n  );\n\n  return [state, setState] as const;\n}\n\nfunction getStrictContext<T>(\n  name?: string,\n): readonly [\n  ({\n    value,\n    children,\n  }: {\n    value: T;\n    children?: React.ReactNode;\n  }) => React.JSX.Element,\n  () => T,\n] {\n  const Context = React.createContext<T | undefined>(undefined);\n\n  const Provider = ({\n    value,\n    children,\n  }: {\n    value: T;\n    children?: React.ReactNode;\n  }) => <Context.Provider value={value}>{children}</Context.Provider>;\n\n  const useSafeContext = () => {\n    const ctx = React.useContext(Context);\n    if (ctx === undefined) {\n      throw new Error(`useContext must be used within ${name ?? 'a Provider'}`);\n    }\n    return ctx;\n  };\n\n  return [Provider, useSafeContext] as const;\n}\n\nexport { getStrictContext };\n",
      "type": "registry:ui",
      "target": "components/ui/alert-dialog.tsx"
    }
  ],
  "type": "registry:ui"
}
