"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _default = (sourceFilePath, filetypes) => {
  // Try to match as the RegExp pattern
  for (const pattern of filetypes) {
    if (!pattern.match(/^\.[a-z0-9A-Z]+?$/)) {
      if (sourceFilePath.match(new RegExp(pattern))) {
        return pattern;
      }
    }
  }

  const extensionDotIndex = sourceFilePath.lastIndexOf('.');

  if (extensionDotIndex > -1) {
    const extension = sourceFilePath.substr(extensionDotIndex);
    const index = filetypes.indexOf(extension);

    if (index > -1) {
      return filetypes[index];
    }
  }

  return null;
};

exports.default = _default;
//# sourceMappingURL=findMatchedFiletype.js.map