{
  "version": 3,
  "sources": ["../../src/modules/error/components/ErrorBoundary/ThrownErrorBoundary.tsx", "../../src/modules/error/contexts/ErrorReporter/Provider.tsx", "../../src/modules/error/contexts/ErrorReporter/Context.ts", "../../src/modules/error/contexts/ErrorReporter/useErrorReporter.tsx", "../../src/modules/error/components/ErrorQuickTipButton.tsx"],
  "sourcesContent": ["import type { ErrorEx, ErrorReporter } from '@ariestools/sdk-react-ui/error'\nimport { ErrorRender } from '@ariestools/sdk-react-ui/error'\nimport type { ErrorInfo, ReactNode } from 'react'\nimport React, { Component } from 'react'\n\nimport { useErrorReporter } from '../../contexts/index.ts'\n\n/** Properties accepted by the thrown error boundary component. */\nexport interface ThrownErrorBoundaryProps<T = void> {\n  /** Boundary name used by the thrown error boundary props. */\n  boundaryName?: string\n  /** Children used by the thrown error boundary props. */\n  children: ReactNode\n  /** Error component used by the thrown error boundary props. */\n  errorComponent?: (e: ErrorEx<T>, boundaryName?: string) => ReactNode\n  /** Rethrow used by the thrown error boundary props. */\n  rethrow?: boolean\n  /** Rollbar used by the thrown error boundary props. */\n  rollbar?: ErrorReporter\n  /** Scope used by the thrown error boundary props. */\n  scope?: string\n  /** Title used by the thrown error boundary props. */\n  title?: string\n}\n\n/** Error state maintained by the thrown-error boundary. */\nexport interface ThrownErrorBoundaryState<T = void> {\n  /** Error ex used by the thrown error boundary state. */\n  errorEx: ErrorEx<T> | undefined\n  /** Has error used by the thrown error boundary state. */\n  hasError?: boolean\n  /** Xyo error used by the thrown error boundary state. */\n  xyoError?: T\n}\n\n/** Class boundary that captures descendant errors and renders an error view or custom fallback. */\nexport class ThrownErrorBoundaryInner<T> extends Component<ThrownErrorBoundaryProps<T>, ThrownErrorBoundaryState<T>> {\n  /** State used by the thrown error boundary inner. */\n  override state: ThrownErrorBoundaryState<T> = { errorEx: undefined }\n\n  /** Returns derived state from error from the current error state. */\n  static getDerivedStateFromError<T = void>(error: ErrorEx<T>) {\n    // React calls this method unbound, so `this` is undefined here.\n    // eslint-disable-next-line unicorn/class-reference-in-static-methods\n    const xyoError = ThrownErrorBoundaryInner.normalizeError<T>(error)\n    const thrownErrorBoundaryState: ThrownErrorBoundaryState<T> = {\n      hasError: true, errorEx: error, xyoError,\n    }\n    return thrownErrorBoundaryState\n  }\n\n  /** Converts the captured error into the boundary's generic error payload. */\n  static normalizeError<T>(error: ErrorEx<T>): T {\n    return error as T\n  }\n\n  /** Reports the captured error and optionally rethrows it after logging. */\n  override componentDidCatch(error: Error, errorInfo: ErrorInfo) {\n    const { rethrow, rollbar } = this.props\n    const { errorEx } = this.state\n\n    rollbar?.error(error)\n\n    console.error('Error:', errorEx, errorInfo)\n    if (rethrow === true) {\n      throw error\n    }\n  }\n\n  /** Renders children until an error is captured, then renders the configured error view. */\n  override render() {\n    const { errorEx } = this.state\n    const {\n      children, boundaryName, errorComponent, scope, title,\n    } = this.props\n\n    // TODO - support custom error renderer for xyoErrors\n    if (errorEx) {\n      return errorComponent ? errorComponent(errorEx, boundaryName) : <ErrorRender<T> error={errorEx} errorContext={`${boundaryName} Boundary`} scope={scope} title={title} />\n    }\n\n    return children\n  }\n}\n\n// calling the hook outside of the component since only can be called in functional component\n/** Catches descendant render errors and renders the configured fallback. */\nexport function ThrownErrorBoundary<T = void>({ rollbar, ...props }: ThrownErrorBoundaryProps<T>): React.JSX.Element {\n  const { rollbar: rollbarErrorReporter } = useErrorReporter()\n  return <ThrownErrorBoundaryInner<T> rollbar={rollbar ?? rollbarErrorReporter ?? globalThis.rollbar} {...props} />\n}\n", "import type { ErrorReporter } from '@ariestools/sdk-react-ui/error'\nimport type { PropsWithChildren } from 'react'\nimport React, { useMemo } from 'react'\n\nimport { ErrorReporterContext } from './Context.ts'\n\n/** Properties accepted by the error reporter provider component. */\nexport interface ErrorReporterProviderProps {\n  /** Rollbar used by the error reporter provider props. */\n  rollbar: ErrorReporter\n}\n\n/** Provides error reporter state to descendant components. */\nconst ErrorReporterProvider: React.FC<PropsWithChildren<ErrorReporterProviderProps>> = ({ children, rollbar: rollbarProp }) => {\n  if (rollbarProp === undefined && globalThis.rollbar === undefined) {\n    throw new Error('ErrorReporterProvider unable to find a Rollbar instance either passed as prop or from Provider')\n  }\n\n  const rollbar = rollbarProp ?? globalThis.rollbar\n\n  const value = useMemo(() => ({ rollbar }), [rollbar])\n\n  return <ErrorReporterContext value={value}>{children}</ErrorReporterContext>\n}\n\nexport { ErrorReporterProvider }\n", "import { createContext } from 'react'\n\nimport type { ErrorReporterContextState } from './State.ts'\n\nexport const ErrorReporterContext = createContext<ErrorReporterContextState>({})\n", "import { use } from 'react'\n\nimport { ErrorReporterContext } from './Context.ts'\n\n/** Returns the error reporter supplied by the nearest provider. */\nexport const useErrorReporter = () => {\n  const context = use(ErrorReporterContext)\n  if (context === undefined) {\n    console.warn('useErrorReporter must be used within a ErrorReporterContext')\n  }\n\n  return context ?? {}\n}\n", "import { isDefined } from '@ariestools/sdk'\nimport { FlexCol } from '@ariestools/sdk-react-foundation/flexbox'\nimport { ErrorRender } from '@ariestools/sdk-react-ui/error'\nimport type { QuickTipButtonProps } from '@ariestools/sdk-react-ui/quick-tip-button'\nimport { QuickTipButton } from '@ariestools/sdk-react-ui/quick-tip-button'\nimport { CancelRounded as CancelRoundedIcon, CheckCircleOutlineRounded as CheckCircleOutlineRoundedIcon } from '@mui/icons-material'\nimport { type SvgIconProps, Typography } from '@mui/material'\nimport React from 'react'\n\nconst InvalidIcon = ({ ref, ...props }: SvgIconProps\n  & { ref?: React.Ref<SVGSVGElement | null> }) => <CancelRoundedIcon color=\"error\" ref={ref} {...props} />\nInvalidIcon.displayName = 'InvalidIcon'\n\n/** Properties accepted by the error quick tip button component. */\nexport interface ErrorQuickTipButtonProps extends QuickTipButtonProps {\n  /** Bound witness type used by the error quick tip button props. */\n  boundWitnessType?: string\n  /** Errors used by the error quick tip button props. */\n  errors?: Error[]\n  /** Icon colors used by the error quick tip button props. */\n  iconColors?: boolean\n  /** Validate error used by the error quick tip button props. */\n  validateError?: Error\n}\n\n/** Opens a quick-tip dialog containing details about an app error. */\nexport const ErrorQuickTipButton: React.FC<ErrorQuickTipButtonProps> = ({\n  boundWitnessType = 'Bound Witness', errors, iconColors, validateError, ...props\n}) => {\n  const hasErrors = isDefined(errors) && errors.length > 0\n  return (\n    <QuickTipButton\n      Icon={hasErrors\n        ? ({ ref, ...props }) => {\n            return <InvalidIcon color={iconColors === true ? 'error' : undefined} ref={ref} {...props} />\n          }\n        : ({ ref, ...props }) => {\n            return <CheckCircleOutlineRoundedIcon color={iconColors === true ? 'success' : undefined} ref={ref} {...props} />\n          }}\n      hoverText={hasErrors ? `Invalid ${boundWitnessType}` : 'Valid'}\n      {...props}\n    >\n      {hasErrors\n        ? (\n            <FlexCol\n              sx={{\n                flexWrap: 'wrap',\n                alignItems: 'start',\n              }}\n            >\n              <ErrorRender error={validateError} scope=\"VerificationError\" />\n              {errors.map((error) => {\n                return <Typography key={error.name}>{error.toString()}</Typography>\n              })}\n            </FlexCol>\n          )\n        : <Typography>No Errors</Typography>}\n    </QuickTipButton>\n  )\n}\n"],
  "mappings": ";AACA,SAAS,mBAAmB;AAE5B,SAAgB,iBAAiB;;;ACDjC,SAAgB,eAAe;;;ACF/B,SAAS,qBAAqB;AAIvB,IAAM,uBAAuB,cAAyC,CAAC,CAAC;;;ADkBtE;AATT,IAAM,wBAAiF,CAAC,EAAE,UAAU,SAAS,YAAY,MAAM;AAC7H,MAAI,gBAAgB,UAAa,WAAW,YAAY,QAAW;AACjE,UAAM,IAAI,MAAM,gGAAgG;AAAA,EAClH;AAEA,QAAM,UAAU,eAAe,WAAW;AAE1C,QAAM,QAAQ,QAAQ,OAAO,EAAE,QAAQ,IAAI,CAAC,OAAO,CAAC;AAEpD,SAAO,oBAAC,wBAAqB,OAAe,UAAS;AACvD;;;AEvBA,SAAS,WAAW;AAKb,IAAM,mBAAmB,MAAM;AACpC,QAAM,UAAU,IAAI,oBAAoB;AACxC,MAAI,YAAY,QAAW;AACzB,YAAQ,KAAK,6DAA6D;AAAA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