import { _ as _defineProperty } from '../../../defineProperty-CrCYjjU3.js';
import { Honeybadger, HoneybadgerErrorBoundary as HoneybadgerErrorBoundary$1 } from '@honeybadger-io/react';
import { IGNORABLE_ERRORS_REGEX, IGNORABLE_ERROR_NAMES_REGEX, IGNORABLE_STACKS_REGEX } from './constants.js';
import FallbackComponent from './FallbackComponent.js';
import { isNeetoReplaySecurityError, getSessionReplayUrl, attachContext } from './utils.js';
import { jsx } from 'react/jsx-runtime';
import '../../../typeof-D-UKOauR.js';
import 'react';
import '@bigbinary/neeto-atoms';
import 'dompurify';
import 'ramda';
import 'react-i18next';

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
var HoneybadgerErrorBoundary = function HoneybadgerErrorBoundary(_ref) {
  var children = _ref.children,
    _ref$ErrorComponent = _ref.ErrorComponent,
    ErrorComponent = _ref$ErrorComponent === void 0 ? FallbackComponent : _ref$ErrorComponent,
    _ref$filterErrors = _ref.filterErrors,
    filterErrors = _ref$filterErrors === void 0 ? undefined : _ref$filterErrors,
    config = _ref.config;
  Honeybadger.beforeNotify(function (notice) {
    var _globalProps$user;
    if (!notice) return false;
    var isIgnorable = IGNORABLE_ERRORS_REGEX.test(notice.message) || IGNORABLE_ERROR_NAMES_REGEX.test(notice.name) || IGNORABLE_STACKS_REGEX.test(notice.stack) || isNeetoReplaySecurityError(notice) || (filterErrors === null || filterErrors === void 0 ? void 0 : filterErrors(notice)) === false;
    if (isIgnorable) return false;
    var context = {
      errorClass: notice.name
    };
    if (notice.name === "ChunkLoadError") {
      context.IGNORABLE_ERROR_NAMES_REGEX = IGNORABLE_ERROR_NAMES_REGEX;
      context.isChunkLoadError = IGNORABLE_ERROR_NAMES_REGEX.test(notice.name);
    }
    var user = (_globalProps$user = globalProps.user) === null || _globalProps$user === void 0 ? void 0 : _globalProps$user.email;
    if (user) context.user = user;
    var sessionReplay = getSessionReplayUrl();
    if (sessionReplay) context.sessionReplay = sessionReplay;
    attachContext(notice, context);
    return true;
  });
  var honeybadger = Honeybadger.configure(_objectSpread({
    apiKey: globalProps.honeybadgerApiKey,
    environment: globalProps.railsEnv,
    revision: globalProps.honeybadgerRevision,
    developmentEnvironments: ["development", "test"],
    enableUncaught: true,
    async: true,
    breadcrumbsEnabled: true,
    projectRoot: "",
    enableUnhandledRejection: false
  }, config));
  return /*#__PURE__*/jsx(HoneybadgerErrorBoundary$1, {
    ErrorComponent: ErrorComponent,
    honeybadger: honeybadger,
    children: children
  });
};

export { HoneybadgerErrorBoundary as default };
//# sourceMappingURL=HoneybadgerErrorBoundary.js.map
