import { BASE64_IMAGE_REGEX, BASE64_IMAGE_ERROR_MESSAGE } from '../v2Containers/Cap/constants';

export const containsBase64Images = ({content, CapNotification, callback}) => {
    if (!content || typeof content !== 'string') {
      return false;
    }
    // Create a new regex instance to avoid global flag state issues
    const regex = new RegExp(BASE64_IMAGE_REGEX.source, BASE64_IMAGE_REGEX.flags);
    if (regex.test(content)) { 
      CapNotification && CapNotification.error(BASE64_IMAGE_ERROR_MESSAGE);
      callback && callback();
      return true;
    }
    return false;
  };