text: 'use strict';
  
  Object.defineProperty(exports, '__esModule', { value: true });
  
  var fileType = require('file-type');
  var mime = require('mime-types');
  var Reader = require('it-reader');
  
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
  
  var fileType__default = /*#__PURE__*/_interopDefaultLegacy(fileType);
  var mime__default = /*#__PURE__*/_interopDefaultLegacy(mime);
  var Reader__default = /*#__PURE__*/_interopDefaultLegacy(Reader);
  
  const minimumBytes = 4100;
  const detectContentType = async (path, source) => {
    let fileSignature;
    if (!path.endsWith('.svg')) {
      try {
        const reader = Reader__default["default"](source);
        const {value, done} = await reader.next(minimumBytes);
        if (done)
          return { source: reader };
        fileSignature = await fileType__default["default"].fromBuffer(value.slice());
        source = async function* () {
          yield value;
          yield* reader;
        }();
      } catch (err) {
        if (err.code !== 'ERR_UNDER_READ')
          throw err;
        source = async function* () {
          yield err.buffer;
        }();
      }
    }
    const mimeType = mime__default["default"].lookup(fileSignature ? fileSignature.ext : path);
    return {
      source,
      contentType: mime__default["default"].contentType(mimeType)
    };
  };
  
  exports.detectContentType = detectContentType;
  