;
{
  try {
    let e = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : {}, n = new e.Error().stack;
    n && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[n] = "11b6a9c2-9b99-4dea-a7ea-03d6621387bf", e._sentryDebugIdIdentifier = "sentry-dbid-11b6a9c2-9b99-4dea-a7ea-03d6621387bf");
  } catch (e) {
  }
}
;
import { j as TaskTypes, aW as remediationPayoutApiKeyMapping, aX as remediationBusinessDetailsApiKeyMapping, aY as remediationIndividualOnfidoApiKeyMapping } from "./StoreProvider-CqQrndhS.js";
import { a as assignToProp } from "./utils-DNSfZiio.js";
const isMaintenanceModeError = (error) => error && typeof error === "object" && "messageCode" in error && error.messageCode === "maintenanceMode";
const overrideKeyMapping = {
  [TaskTypes.INDIVIDUAL]: {
    TAX_ID_NUMBER: "individual.taxInformation"
  },
  [TaskTypes.BUSINESS_DETAILS]: {
    TAX_ID_NUMBER: "organization.taxInformation"
  }
};
const processValidationErrors = (validationError, dropinTask, keyMappings) => {
  if (validationError?.invalidFields && validationError?.invalidFields.length > 0) {
    return validationError?.invalidFields.reduce(
      (acc, invalidField) => {
        if (invalidField?.name) {
          let mappedFieldPath = mapField(invalidField?.name, dropinTask);
          if (keyMappings) {
            mappedFieldPath = keyMappings[invalidField?.name];
          }
          if (mappedFieldPath) {
            assignToProp(mappedFieldPath, acc, true);
          }
        }
        return acc;
      },
      {}
    );
  }
};
const mapField = (lePath, dropinTask) => {
  switch (dropinTask) {
    case TaskTypes.INDIVIDUAL: {
      const mappedPath = overrideKeyMapping?.[TaskTypes.INDIVIDUAL]?.[lePath];
      return mappedPath ? mappedPath : remediationIndividualOnfidoApiKeyMapping[lePath];
    }
    case TaskTypes.BUSINESS_DETAILS: {
      const mappedPath = overrideKeyMapping?.[TaskTypes.BUSINESS_DETAILS]?.[lePath];
      return mappedPath ? mappedPath : remediationBusinessDetailsApiKeyMapping[lePath];
    }
    case TaskTypes.PAYOUT:
    case TaskTypes.PAYIN:
      return remediationPayoutApiKeyMapping[lePath];
    default:
      return null;
  }
};
const API_VALIDATION_ERROR_CODE = "30_102";
const ID_DOCUMENT_UPLOAD_ERROR_CODE = "30_105";
const BANK_STATEMENT_UPLOAD_ERROR_CODE = "30_106";
const CreateOrUpdateTransferInstrumentErrorMessage = {
  TRANSFER_INSTRUMENT_LIMIT_HAS_ALREADY_BEEN_MET: "Transfer instrument limit has already been met"
};
const validateErrorCode = (error, errorCode) => !!error && typeof error === "object" && "errorCode" in error && error.errorCode === errorCode;
const isValidationError = (error) => validateErrorCode(error, API_VALIDATION_ERROR_CODE);
const isIdDocumentUploadError = (error) => validateErrorCode(error, ID_DOCUMENT_UPLOAD_ERROR_CODE);
const isBankStatementUploadError = (error) => validateErrorCode(error, BANK_STATEMENT_UPLOAD_ERROR_CODE);
const mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable = (error) => {
  if (!error) {
    return "failedToUpdateDetails";
  }
  const message = error?.sourceError?.detail;
  switch (message) {
    case CreateOrUpdateTransferInstrumentErrorMessage.TRANSFER_INSTRUMENT_LIMIT_HAS_ALREADY_BEEN_MET:
      return "transferInstrumentLimitHasAlreadyBeenMet";
    default:
      return "failedToUpdateDetails";
  }
};
export {
  isMaintenanceModeError as a,
  isIdDocumentUploadError as b,
  isBankStatementUploadError as c,
  isValidationError as i,
  mapCreateOrUpdateTransferInstrumentErrorMessageToTranslatable as m,
  processValidationErrors as p
};
