{"version":3,"file":"Card.cjs","sources":["../../../src/components/Card/Card.tsx"],"sourcesContent":["\"use client\";\n\nimport { forwardRef, type ComponentProps } from \"react\";\nimport { get } from \"../../helpers/get\";\nimport { resolveProps } from \"../../helpers/resolve-props\";\nimport { useResolveTheme } from \"../../helpers/resolve-theme\";\nimport { twMerge } from \"../../helpers/tailwind-merge\";\nimport { useThemeProvider } from \"../../theme/provider\";\nimport type { DeepPartial, FlowbiteBoolean, ThemingProps } from \"../../types\";\nimport { cardTheme } from \"./theme\";\n\nexport interface CardTheme {\n  root: CardRootTheme;\n  img: CardImageTheme;\n}\n\nexport interface CardRootTheme {\n  base: string;\n  children: string;\n  horizontal: FlowbiteBoolean;\n  href: string;\n}\n\nexport interface CardImageTheme {\n  base: string;\n  horizontal: FlowbiteBoolean;\n}\n\ninterface CommonCardProps extends ComponentProps<\"div\">, ThemingProps<CardTheme> {\n  horizontal?: boolean;\n  href?: string;\n}\n\nexport type CardProps = (\n  | { imgAlt?: string; imgSrc?: string; renderImage?: never }\n  | {\n      /** Allows to provide a custom render function for the image component. Useful in Next.JS and Gatsby. **Setting this will disable `imgSrc` and `imgAlt`**.\n       */\n      renderImage?: (theme: DeepPartial<CardTheme>, horizontal: boolean) => JSX.Element;\n      imgAlt?: never;\n      imgSrc?: never;\n    }\n) &\n  CommonCardProps;\n\nexport const Card = forwardRef<HTMLDivElement | HTMLAnchorElement, CardProps>((props, ref) => {\n  const provider = useThemeProvider();\n  const theme = useResolveTheme(\n    [cardTheme, provider.theme?.card, props.theme],\n    [get(provider.clearTheme, \"card\"), props.clearTheme],\n    [get(provider.applyTheme, \"card\"), props.applyTheme],\n  );\n\n  const { children, className, horizontal, href, imgAlt, imgSrc, renderImage, ...restProps } = resolveProps(\n    props,\n    provider.props?.card,\n  );\n\n  const Component = typeof href === \"undefined\" ? \"div\" : \"a\";\n\n  return (\n    <Component\n      // @ts-expect-error - bypass\n      ref={ref}\n      data-testid=\"flowbite-card\"\n      href={href}\n      className={twMerge(\n        theme.root.base,\n        theme.root.horizontal[horizontal ? \"on\" : \"off\"],\n        href && theme.root.href,\n        className,\n      )}\n      {...restProps}\n    >\n      {renderImage?.(theme, !!horizontal) ??\n        (imgSrc && (\n          <img\n            data-testid=\"flowbite-card-image\"\n            alt={imgAlt ?? \"\"}\n            src={imgSrc}\n            className={twMerge(theme.img.base, theme.img.horizontal[props.horizontal ? \"on\" : \"off\"])}\n          />\n        ))}\n      <div className={theme.root.children}>{children}</div>\n    </Component>\n  );\n});\n\nCard.displayName = \"Card\";\n"],"names":["forwardRef","provider","useThemeProvider","theme","useResolveTheme","cardTheme","get","resolveProps","jsxs","twMerge","jsx"],"mappings":";;;;;;;;;;;AAUY,MAAC,IAAI,GAAGA,gBAAU,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK;AAC/C,EAAE,MAAMC,UAAQ,GAAGC,yBAAgB,EAAE;AACrC,EAAE,MAAMC,OAAK,GAAGC,4BAAe;AAC/B,IAAI,CAACC,eAAS,EAAEJ,UAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC;AAClD,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC;AACxD,IAAI,CAACK,OAAG,CAACL,UAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,EAAE,KAAK,CAAC,UAAU;AACvD,GAAG;AACH,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,SAAS,EAAE,GAAGM,yBAAY;AAC3G,IAAI,KAAK;AACT,IAAIN,UAAQ,CAAC,KAAK,EAAE;AACpB,GAAG;AACH,EAAE,MAAM,SAAS,GAAG,OAAO,IAAI,KAAK,WAAW,GAAG,KAAK,GAAG,GAAG;AAC7D,EAAE,uBAAuBO,eAAI;AAC7B,IAAI,SAAS;AACb,IAAI;AACJ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