export var SERIALIZABLE_ATTRIBUTES = ['data-test-id', 'data-testid'];
var WHITELISTED_ATTRIBNUTES = ['type', 'name'].concat(SERIALIZABLE_ATTRIBUTES);
var REG_MATCH_NOTALLOWED_ATTRIBUTES = new RegExp("\\[(?!".concat(WHITELISTED_ATTRIBNUTES.join('|'), ").*?\\]"), 'gmu');

// attributes may contain UGC that we need to strip out
// only allow type and name attributes
var sanitiseUiBreadcrumbMessage = function sanitiseUiBreadcrumbMessage(message) {
  return message.replace(REG_MATCH_NOTALLOWED_ATTRIBUTES, '');
};
/**
 * Sanitizes messages within UI category breadcrumbs to ensure user-generated content is
 * appropriately cleaned before being logged by Sentry. This helps in maintaining
 * privacy and security by preventing sensitive data exposure.
 */
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
export var normaliseSentryBreadcrumbs = function normaliseSentryBreadcrumbs(breadcrumb) {
  var _ref = breadcrumb || {},
    category = _ref.category;

  // allow "ui*"" category breadcrumbs, that include clicks and inputs on DOM elements
  // they may contain UGC that needs to be stripped out
  if (category !== null && category !== void 0 && category.startsWith('ui')) {
    // sentry can include the element attributes in the data
    // which may contain UGC that we need to strip out
    var sanitisedBreadCrumb = breadcrumb;
    var message = sanitisedBreadCrumb.message;
    if (message !== null && message !== undefined) {
      sanitisedBreadCrumb.message = sanitiseUiBreadcrumbMessage(message);
    }
    return breadcrumb;
  }
  return breadcrumb;
};