{
  "version": 3,
  "sources": ["../../src/modules/link/LinkEx.tsx", "../../src/modules/link/LinkToEx.tsx", "../../src/modules/link/LinkExProps.tsx"],
  "sourcesContent": ["import { toPromise } from '@ariestools/sdk'\nimport { useUserEvents } from '@ariestools/sdk-react-foundation/user-events'\nimport { Link } from '@mui/material'\nimport type { MouseEvent } from 'react'\nimport React from 'react'\n\nimport type { LinkExProps } from './LinkExProps.tsx'\nimport { LinkToEx } from './LinkToEx.tsx'\n\n/** Renders a link that supports either an external `href` or app navigation target. */\nexport const LinkEx = ({\n  ref, onClick, disableUserEvents, funnel, intent, placement, target, href, to, toOptions, ...props\n}: LinkExProps & { ref?: React.RefObject<HTMLAnchorElement | null> }) => {\n  const userEvents = useUserEvents()\n  const localOnClick = (event: MouseEvent<HTMLAnchorElement>) => {\n    // we do this crazy navigate thing so that we can set it up outside the promise so that safari does not block it\n    const windowToNavigate = () => (target !== undefined && target.length > 0 && href !== undefined && href.length > 0) ? window.open('', target) ?? globalThis : globalThis\n    const callOnClickAndFollowHref = (windowToNav = windowToNavigate()) => {\n      onClick?.(event)\n      if (href !== undefined && href.length > 0) {\n        windowToNav.location.href = href\n      }\n    }\n    if (disableUserEvents !== true && userEvents) {\n      const elementName = props['aria-label'] ?? event.currentTarget.textContent\n      event.preventDefault()\n      const windowToNav = windowToNavigate()\n      void (async () => {\n        try {\n          await toPromise(userEvents.userClick({\n            elementName, funnel, intent, placement,\n          }))\n          callOnClickAndFollowHref(windowToNav)\n        } catch (ex) {\n          console.error('User event failed', elementName, funnel, placement, ex)\n          callOnClickAndFollowHref(windowToNav)\n        }\n      })()\n    } else {\n      callOnClickAndFollowHref()\n    }\n  }\n  return to === undefined\n    ? <Link ref={ref} href={href} target={target} onClick={localOnClick} {...props} />\n    : <LinkToEx ref={ref} to={to} toOptions={toOptions} target={target} onClick={onClick} {...props} />\n}\n\nLinkEx.displayName = 'LinkExXYLabs'\n", "import { toPromise } from '@ariestools/sdk'\nimport { useUserEvents } from '@ariestools/sdk-react-foundation/user-events'\nimport { Link } from '@mui/material'\nimport type { MouseEvent } from 'react'\nimport React from 'react'\nimport { Link as RouterLink, useNavigate } from 'react-router'\n\nimport type { LinkExProps } from './LinkExProps.tsx'\n\n/** Renders an application-navigation link while preserving the configured link behavior. */\nexport const LinkToEx = ({\n  ref, intent, funnel, onClick, to, toOptions, placement, disableUserEvents, ...props\n}: LinkExProps & { ref?: React.RefObject<HTMLAnchorElement | null> }) => {\n  const userEvents = useUserEvents()\n  const navigate = useNavigate()\n  const localOnClick = (event: MouseEvent<HTMLAnchorElement>) => {\n    if (disableUserEvents !== true && userEvents) {\n      const elementName = props['aria-label'] ?? event.currentTarget.textContent\n      const callOnClickAndNavigate = () => {\n        try {\n          onClick?.(event)\n        } catch (ex) {\n          console.error('onClick threw', elementName, funnel, placement, ex)\n        }\n        if (to !== undefined && toOptions !== undefined) {\n          void navigate(to, toOptions)\n        }\n      }\n      void (async () => {\n        try {\n          await toPromise(userEvents.userClick({\n            elementName, funnel, intent, placement,\n          }))\n          callOnClickAndNavigate()\n        } catch (ex) {\n          console.error('User event failed', elementName, funnel, placement, ex)\n          callOnClickAndNavigate()\n        }\n      })()\n    } else {\n      onClick?.(event)\n    }\n  }\n\n  return <Link ref={ref} rel=\"noopener noreferrer\" to={toOptions === undefined ? to : undefined} component={RouterLink} onClick={localOnClick} {...props} />\n}\n\nLinkToEx.displayName = 'LinkToExXYLabs'\n", "import type { LinkProps } from '@mui/material'\nimport type { NavigateOptions, To } from 'react-router'\n\n/** Properties accepted by the link only href component. */\nexport interface LinkOnlyHrefProps {\n  /** Href used by the link only href props. */\n  href?: string\n  /** To used by the link only href props. */\n  to?: never\n  /** To options used by the link only href props. */\n  toOptions?: never\n}\n\n/** Properties accepted by the link only to component. */\nexport interface LinkOnlyToProps {\n  /** Href used by the link only to props. */\n  href?: never\n  /** To used by the link only to props. */\n  to?: To\n  /** To options used by the link only to props. */\n  toOptions?: NavigateOptions\n}\n\n/** Properties accepted by the link no to or href component. */\nexport interface LinkNoToOrHrefProps {\n  /** Href used by the link no to or href props. */\n  href?: never\n  /** To used by the link no to or href props. */\n  to?: never\n  /** To options used by the link no to or href props. */\n  toOptions?: never\n}\n\n/** Properties accepted by the link href or to or no component. */\nexport type LinkHrefOrToOrNoProps = LinkOnlyHrefProps | LinkOnlyToProps | LinkNoToOrHrefProps\n\n/** Properties accepted by the link href and to component. */\nexport interface LinkHrefAndToProps {\n  /** Href used by the link href and to props. */\n  href?: string\n  /** To used by the link href and to props. */\n  to?: To\n  /** To options used by the link href and to props. */\n  toOptions?: NavigateOptions\n}\n\n/** As link href or to props used by the link public API. */\nexport const asLinkHrefOrToProps = (props: LinkHrefAndToProps): LinkHrefOrToOrNoProps => {\n  if (props.href !== undefined && props.href.length > 0 && (props.to !== undefined || props.toOptions !== undefined)) {\n    throw new Error('LinkExProps: cannot have both href and to')\n  }\n  if (props.href !== undefined && props.href.length > 0) {\n    return { href: props.href }\n  }\n  return props.to === undefined ? {} : { to: props.to, toOptions: props.toOptions }\n}\n\n/** Properties accepted by the link ex base component. */\nexport interface LinkExBaseProps extends Omit<LinkProps, 'ref' | 'href'> {\n  /** Disable user events used by the link ex base props. */\n  disableUserEvents?: boolean\n  /** Funnel used by the link ex base props. */\n  funnel?: string\n  /** Intent used by the link ex base props. */\n  intent?: string\n  /** Placement used by the link ex base props. */\n  placement?: string\n}\n\n/** Properties accepted by the link ex component. */\nexport type LinkExProps = LinkExBaseProps & LinkHrefOrToOrNoProps\n"],
  "mappings": ";AAAA,SAAS,aAAAA,kBAAiB;AAC1B,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,QAAAC,aAAY;;;ACFrB,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAC9B,SAAS,YAAY;AAGrB,SAAS,QAAQ,YAAY,mBAAmB;AAuCvC;AAlCF,IAAM,WAAW,CAAC;AAAA,EACvB;AAAA,EAAK;AAAA,EAAQ;AAAA,EAAQ;AAAA,EAAS;AAAA,EAAI;AAAA,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