import { cloneElement, isValidElement, type HTMLAttributes, type ReactNode } from "react"; export function renderAsChild( asChild: boolean | undefined, children: ReactNode, props: HTMLAttributes ) { if (asChild && isValidElement>(children)) { return cloneElement(children, { ...props, ...children.props }); } return {children}; }