/*!
 * Crafted with ❤ by Salla
 */
import { d as getDefaultExportFromCjs } from './index-Cb4NFvMH.js';

function _mergeNamespaces(n, m) {
  m.forEach(function (e) {
    e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
      if (k !== 'default' && !(k in n)) {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  });
  return Object.freeze(n);
}

var filepondPluginImageExifOrientation$3 = {exports: {}};

/*!
 * FilePondPluginImageExifOrientation 1.0.11
 * Licensed under MIT, https://opensource.org/licenses/MIT/
 * Please visit https://pqina.nl/filepond/ for details.
 */
var filepondPluginImageExifOrientation$2 = filepondPluginImageExifOrientation$3.exports;

var hasRequiredFilepondPluginImageExifOrientation;

function requireFilepondPluginImageExifOrientation () {
	if (hasRequiredFilepondPluginImageExifOrientation) return filepondPluginImageExifOrientation$3.exports;
	hasRequiredFilepondPluginImageExifOrientation = 1;
	(function (module, exports) {
		/* eslint-disable */

		(function(global, factory) {
		  (module.exports = factory())
		    ;
		})(filepondPluginImageExifOrientation$2, function() {

		  // test if file is of type image
		  var isJPEG = function isJPEG(file) {
		    return /^image\/jpeg/.test(file.type);
		  };

		  var Marker = {
		    JPEG: 0xffd8,
		    APP1: 0xffe1,
		    EXIF: 0x45786966,
		    TIFF: 0x4949,
		    Orientation: 0x0112,
		    Unknown: 0xff00
		  };

		  var getUint16 = function getUint16(view, offset) {
		    var little =
		      arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
		    return view.getUint16(offset, little);
		  };
		  var getUint32 = function getUint32(view, offset) {
		    var little =
		      arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
		    return view.getUint32(offset, little);
		  };

		  var getImageOrientation = function getImageOrientation(file) {
		    return new Promise(function(resolve, reject) {
		      var reader = new FileReader();
		      reader.onload = function(e) {
		        var view = new DataView(e.target.result);

		        // Every JPEG file starts from binary value '0xFFD8'
		        if (getUint16(view, 0) !== Marker.JPEG) {
		          // This aint no JPEG
		          resolve(-1);
		          return;
		        }

		        var length = view.byteLength;
		        var offset = 2;

		        while (offset < length) {
		          var marker = getUint16(view, offset);
		          offset += 2;

		          // There's our APP1 Marker
		          if (marker === Marker.APP1) {
		            if (getUint32(view, (offset += 2)) !== Marker.EXIF) {
		              // no EXIF info defined
		              break;
		            }

		            // Get TIFF Header
		            var little = getUint16(view, (offset += 6)) === Marker.TIFF;
		            offset += getUint32(view, offset + 4, little);

		            var tags = getUint16(view, offset, little);
		            offset += 2;

		            for (var i = 0; i < tags; i++) {
		              // found the orientation tag
		              if (
		                getUint16(view, offset + i * 12, little) === Marker.Orientation
		              ) {
		                resolve(getUint16(view, offset + i * 12 + 8, little));

		                return;
		              }
		            }
		          } else if ((marker & Marker.Unknown) !== Marker.Unknown) {
		            // Invalid
		            break;
		          } else {
		            offset += getUint16(view, offset);
		          }
		        }

		        // Nothing found
		        resolve(-1);
		      };

		      // we don't need to read the entire file to get the orientation
		      reader.readAsArrayBuffer(file.slice(0, 64 * 1024));
		    });
		  };

		  var IS_BROWSER = (function() {
		    return (
		      typeof window !== 'undefined' && typeof window.document !== 'undefined'
		    );
		  })();
		  var isBrowser = function isBrowser() {
		    return IS_BROWSER;
		  };

		  // 2x1 pixel image 90CW rotated with orientation header
		  var testSrc =
		    'data:image/jpg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QA6RXhpZgAATU0AKgAAAAgAAwESAAMAAAABAAYAAAEoAAMAAAABAAIAAAITAAMAAAABAAEAAAAAAAD/2wBDAP//////////////////////////////////////////////////////////////////////////////////////wAALCAABAAIBASIA/8QAJgABAAAAAAAAAAAAAAAAAAAAAxABAAAAAAAAAAAAAAAAAAAAAP/aAAgBAQAAPwBH/9k=';

		  // should correct orientation if is presented in landscape, in which case the browser doesn't autocorrect
		  var shouldCorrect = undefined;
		  var testImage = isBrowser() ? new Image() : {};
		  testImage.onload = function() {
		    return (shouldCorrect = testImage.naturalWidth > testImage.naturalHeight);
		  };
		  testImage.src = testSrc;

		  var shouldCorrectImageExifOrientation = function shouldCorrectImageExifOrientation() {
		    return shouldCorrect;
		  };

		  /**
		   * Read Image Orientation Plugin
		   */
		  var plugin = function plugin(_ref) {
		    var addFilter = _ref.addFilter,
		      utils = _ref.utils;
		    var Type = utils.Type,
		      isFile = utils.isFile;

		    // subscribe to file load and append required info
		    addFilter('DID_LOAD_ITEM', function(item, _ref2) {
		      var query = _ref2.query;
		      return new Promise(function(resolve, reject) {
		        // get file reference
		        var file = item.file;

		        // if this is not a jpeg image we are not interested
		        if (
		          !isFile(file) ||
		          !isJPEG(file) ||
		          !query('GET_ALLOW_IMAGE_EXIF_ORIENTATION') ||
		          !shouldCorrectImageExifOrientation()
		        ) {
		          // continue with the unaltered dataset
		          return resolve(item);
		        }

		        // get orientation from exif data
		        getImageOrientation(file).then(function(orientation) {
		          item.setMetadata('exif', { orientation: orientation });
		          resolve(item);
		        });
		      });
		    });

		    // Expose plugin options
		    return {
		      options: {
		        // Enable or disable image orientation reading
		        allowImageExifOrientation: [true, Type.BOOLEAN]
		      }
		    };
		  };

		  // fire pluginloaded event if running in browser, this allows registering the plugin when using async script tags
		  var isBrowser$1 =
		    typeof window !== 'undefined' && typeof window.document !== 'undefined';
		  if (isBrowser$1) {
		    document.dispatchEvent(
		      new CustomEvent('FilePond:pluginloaded', { detail: plugin })
		    );
		  }

		  return plugin;
		}); 
	} (filepondPluginImageExifOrientation$3));
	return filepondPluginImageExifOrientation$3.exports;
}

var filepondPluginImageExifOrientationExports = requireFilepondPluginImageExifOrientation();
var filepondPluginImageExifOrientation = /*@__PURE__*/getDefaultExportFromCjs(filepondPluginImageExifOrientationExports);

var filepondPluginImageExifOrientation$1 = /*#__PURE__*/_mergeNamespaces({
  __proto__: null,
  default: filepondPluginImageExifOrientation
}, [filepondPluginImageExifOrientationExports]);

export { filepondPluginImageExifOrientation$1 as f };
