{"version":3,"file":"SafeAnchor.mjs","names":[],"sources":["../../../../src/components/SafeAnchor/SafeAnchor.tsx"],"sourcesContent":["import type { PropsWithChildren } from 'react';\nimport React from 'react';\nimport { sanitizeUrl } from '@braintree/sanitize-url';\n\nexport type SafeAnchorProps = {\n  className?: string;\n  /** Downloads the file at `href` instead of navigating to it. */\n  download?: boolean;\n  /** Sanitized before it is rendered. The component renders nothing when it is empty. */\n  href?: string;\n  rel?: string;\n  target?: string;\n};\n\nconst UnMemoizedSafeAnchor = (props: PropsWithChildren<SafeAnchorProps>) => {\n  const { children, className, download, href, rel, target } = props;\n  if (!href) return null;\n  const sanitized = sanitizeUrl(href);\n  return (\n    <a\n      className={className}\n      download={download}\n      href={sanitized}\n      rel={rel}\n      target={target}\n    >\n      {children}\n    </a>\n  );\n};\n\n/** Anchor that sanitizes `href` to prevent XSS. */\nexport const SafeAnchor = React.memo(UnMemoizedSafeAnchor) as typeof UnMemoizedSafeAnchor;\n"],"mappings":";;;;AAcA,IAAM,wBAAwB,UAA8C;CAC1E,MAAM,EAAE,UAAU,WAAW,UAAU,MAAM,KAAK,WAAW;CAC7D,IAAI,CAAC,MAAM,OAAO;CAElB,OACE,oBAAC,KAAD;EACa;EACD;EACV,MALc,YAAY,IAKpB;EACD;EACG;EAEP;CACA,CAAA;AAEP;;AAGA,IAAa,aAAa,MAAM,KAAK,oBAAoB"}