Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

exifr

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exifr - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

23

CHANGELOG.md

@@ -5,2 +5,19 @@ # Changelog

## [4.0.0]
### Added
- XMP XML Parser
- XMP Extended support. To extract all XMP segments, set `options.multiSegment` or `options.xmp.multiSegment` to true.
### Changed
- `output.xmp` is no longer where the XMP segment data are stored. XMP tags are parsed, grouped by namespace and each namespace is assigned directly to `output` object, like `output.xmlns`, `output.GPano`, `output.crs` and more. This can be disabled by setting `options.xmp.parse: false`
### Fixed
- `window.BigInt` bug in webworker
## [3.0.1]
### Fixed
- Fixed types in d.ts (`String` -> `string`, `Number` -> `number`).
## [3.0.0]

@@ -114,4 +131,6 @@

[Unreleased]: https://github.com/MikeKovarik/exifr/compare/v3.0.0...HEAD
[3.0.0]: https://github.com/MikeKovarik/exifr/compare/v2.1.3...v3.0.0
[Unreleased]: https://github.com/MikeKovarik/exifr/compare/v4.0.0...HEAD
[4.0.0]: https://github.com/MikeKovarik/exifr/compare/v3.0.1...v4.0.0
[3.0.1]: https://github.com/MikeKovarik/exifr/compare/v3.0.0...v3.0.1
[3.0.0]: https://github.com/MikeKovarik/exifr/compare/v2.1.4...v3.0.0
[2.1.4]: https://github.com/MikeKovarik/exifr/compare/v2.1.3...v2.1.4

@@ -118,0 +137,0 @@ [2.1.3]: https://github.com/MikeKovarik/exifr/compare/v2.1.2...v2.1.3

2

dist/core.esm.js

@@ -1,1 +0,1 @@

var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.keys(e).length}(e)?void 0:e}function a(e){let t=new Error(e);return delete t.stack,t}let f=s?global.BigInt:window.BigInt;const o=new TextDecoder("utf-8");class h{static from(e,t){return e instanceof this&&e.le===t?e:new h(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof h){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw a("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw a("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=h){if(e instanceof DataView||e instanceof h?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw a("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new h(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,o.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof f)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),f(t)<<f(32)|f(i);throw a("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function l(e,t){throw a("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class u extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||l(this.kind,e),t&&(e in t||function(e,t){throw a("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||l(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}function d(e,t,i=[],s=[]){for(let s of i)void 0===e[s]&&(e[s]=t.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(e,i)){let s=Object.getOwnPropertyDescriptor(t.prototype,i);Object.defineProperty(e,i,s)}}}var c=new u("file parser"),p=new u("segment parser"),g=new u("file reader");function w(e,i){if((r=e).startsWith("data:")||r.length>1e4)return b(e,i,"base64");if(t)return y(e,i,"url",m);if(s)return b(e,i,"fs");throw a("Invalid input argument");var r}async function y(e,t,i,s){if(g.has(i))return b(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw a("Parser ".concat(i," is not loaded"))}async function b(e,t,i){let s=new(g.get(i))(e,t);return await s.read(),s}async function m(e){return fetch(e).then(e=>e.arrayBuffer())}async function k(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}d(c,u,["keyList"]),d(p,u,["keyList"]),d(g,u,["keyList"]);const v=Symbol("keys"),U=Symbol("values");class V extends Map{get tagKeys(){return this[v]||(this[v]=Array.from(this.keys())),this[v]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}function S(e,t,i){let s=new V(i);if(d(s,V,void 0,["tagKeys","tagValues"]),Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function A(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])}const O=new Map,B=new Map,F=new Map,L=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],T=["jfif","xmp","icc","iptc"],z=["tiff",...T],C=["ifd0","ifd1","exif","gps","interop"],D=[...z,...C],j=["makerNote","userComment"],x=["translateKeys","translateValues","reviveValues","multiSegment"],I=[...x,"mergeOutput","sanitize"];class P{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class E extends P{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.applyInheritables(s),this.canBeFiltered=C.includes(e),this.canBeFiltered&&(this.dict=O.get(e)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw a("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(e){let t,i;for(t of x)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,W(this.pick,this.deps)):this.enabled&&this.pick.size>0&&W(this.pick,this.deps)}}var N={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class M extends P{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw a("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of L)this[e]=N[e];for(e of I)this[e]=N[e];for(e of j)this[e]=N[e];for(e of D)this[e]=new E(e,N[e],void 0,this)}setupFromTrue(){let e;for(e of L)this[e]=N[e];for(e of I)this[e]=N[e];for(e of j)this[e]=!0;for(e of D)this[e]=new E(e,!0,void 0,this)}setupFromArray(e){let t;for(t of L)this[t]=N[t];for(t of I)this[t]=N[t];for(t of j)this[t]=N[t];for(t of D)this[t]=new E(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,C)}setupFromObject(e){let t;for(t of(C.ifd0=C.ifd0||C.image,C.ifd1=C.ifd1||C.thumbnail,Object.assign(this,e),L))this[t]=G(e[t],N[t]);for(t of I)this[t]=G(e[t],N[t]);for(t of j)this[t]=G(e[t],N[t]);for(t of z)this[t]=new E(t,N[t],e[t],this);for(t of C)this[t]=new E(t,N[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,C,D),!0===e.tiff?this.batchEnableWithBool(C,!0):!1===e.tiff?this.batchEnableWithUserValue(C,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,C):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,C)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)W(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)W(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=C.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of C)this[e].finalizeFilters()}get onlyTiff(){return!T.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!p.has(e)&&l("segment parser",e)}}function K(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=O.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function G(e,t){return void 0!==e?e:void 0!==t?t:void 0}function W(e,t){for(let i of t)e.add(i)}r(M,"default",N);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},H=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),R=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(e){r(this,"parsers",{}),this.options=M.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=c.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=c.get("jpeg");else{if(!function(e){let t=e.getUint32(0),i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw a("Unknown file format");this.file.isHeic=!0,e=c.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return w(e,s);if(t&&!i&&e instanceof HTMLImageElement)return w(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new h(e);if(t&&e instanceof Blob)return y(e,s,"blob",k);throw a("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},{mergeOutput:t}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let r;if(this.options.silentErrors){try{r=await s.parse()}catch(e){i.push(e)}s.errors.length&&i.push(...s.errors)}else r=await s.parse();(t||s.constructor.mergeOutput)&&"string"!=typeof r?Object.assign(e,r):void 0!==r&&(e[s.constructor.type]=r)});return await Promise.all(s),this.options.silentErrors&&i.length>0&&(e.errors=i),e=n(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=p.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}async function Q(e,t){let i=new q(t);return await i.read(e),i.parse()}async function X(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(t);let r=await s.extractThumbnail();return r&&e?Buffer.from(r):r}async function Y(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function Z(e){let t=new q(H);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function $(e){let t=new q(R);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}export{q as Exifr,M as Options,I as allFormatters,L as chunkedProps,S as createDictionary,J as disableAllOptions,A as extendDictionary,m as fetchUrlAsArrayBuffer,c as fileParsers,g as fileReaders,Z as gps,H as gpsOnlyOptions,x as inheritables,$ as orientation,R as orientationOnlyOptions,T as otherSegments,Q as parse,k as readBlobAsArrayBuffer,p as segmentParsers,z as segments,D as segmentsAndBlocks,O as tagKeys,F as tagRevivers,B as tagValues,X as thumbnail,Y as thumbnailUrl,C as tiffBlocks,j as tiffExtractables};
var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function n(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(a).length}(e)?void 0:e}const a=e=>void 0!==e;function f(e){let t=new Error(e);return delete t.stack,t}let o=s?global.BigInt:self.BigInt;const h=new TextDecoder("utf-8");class l{static from(e,t){return e instanceof this&&e.le===t?e:new l(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof l){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw f("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw f("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=l){if(e instanceof DataView||e instanceof l?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new l(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,h.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function u(e,t){throw f("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class d extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||u(this.kind,e),t&&(e in t||function(e,t){throw f("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||u(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var c=new d("file parser"),p=new d("segment parser"),g=new d("file reader");function w(e,i){if((r=e).startsWith("data:")||r.length>1e4)return y(e,i,"base64");if(t)return b(e,i,"url",m);if(s)return y(e,i,"fs");throw f("Invalid input argument");var r}async function b(e,t,i,s){if(g.has(i))return y(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw f("Parser ".concat(i," is not loaded"))}async function y(e,t,i){let s=new(g.get(i))(e,t);return await s.read(),s}async function m(e){return fetch(e).then(e=>e.arrayBuffer())}async function k(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const v=Symbol("keys"),U=Symbol("values");class V extends Map{get tagKeys(){return this[v]||(this[v]=Array.from(this.keys())),this[v]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}function S(e,t,i){let s=new V(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function A(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])}const B=new Map,F=new Map,O=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],z=["jfif","xmp","icc","iptc"],C=["tiff",...z],L=["ifd0","ifd1","exif","gps","interop"],x=[...C,...L],I=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...D,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class N extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=L.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of D)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,W(this.pick,this.deps)):this.enabled&&this.pick.size>0&&W(this.pick,this.deps)}}var P={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class M extends E{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw f("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=P[e];for(e of j)this[e]=P[e];for(e of I)this[e]=P[e];for(e of x)this[e]=new N(e,P[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=P[e];for(e of j)this[e]=P[e];for(e of I)this[e]=!0;for(e of x)this[e]=new N(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=P[t];for(t of j)this[t]=P[t];for(t of I)this[t]=P[t];for(t of x)this[t]=new N(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,L)}setupFromObject(e){let t;for(t of(L.ifd0=L.ifd0||L.image,L.ifd1=L.ifd1||L.thumbnail,Object.assign(this,e),T))this[t]=G(e[t],P[t]);for(t of j)this[t]=G(e[t],P[t]);for(t of I)this[t]=G(e[t],P[t]);for(t of C)this[t]=new N(t,P[t],e[t],this);for(t of L)this[t]=new N(t,P[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,L,x),!0===e.tiff?this.batchEnableWithBool(L,!0):!1===e.tiff?this.batchEnableWithUserValue(L,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,L):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,L)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)W(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)W(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=L.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of L)this[e].finalizeFilters()}get onlyTiff(){return!z.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of C)this[e].enabled&&!p.has(e)&&u("segment parser",e)}}function K(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=B.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function G(e,t){return void 0!==e?e:void 0!==t?t:void 0}function W(e,t){for(let i of t)e.add(i)}r(M,"default",P);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},H=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),R=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(e){r(this,"parsers",{}),this.options=M.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=c.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=c.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,e=c.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return w(e,s);if(t&&!i&&e instanceof HTMLImageElement)return w(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new l(e);if(t&&e instanceof Blob)return b(e,s,"blob",k);throw f("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=n(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=p.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}async function Q(e,t){let i=new q(t);return await i.read(e),i.parse()}async function X(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(t);let r=await s.extractThumbnail();return r&&e?Buffer.from(r):r}async function Y(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function Z(e){let t=new q(H);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function $(e){let t=new q(R);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}export{q as Exifr,M as Options,j as allFormatters,T as chunkedProps,S as createDictionary,J as disableAllOptions,A as extendDictionary,m as fetchUrlAsArrayBuffer,c as fileParsers,g as fileReaders,Z as gps,H as gpsOnlyOptions,D as inheritables,$ as orientation,R as orientationOnlyOptions,z as otherSegments,Q as parse,k as readBlobAsArrayBuffer,p as segmentParsers,C as segments,x as segmentsAndBlocks,B as tagKeys,O as tagRevivers,F as tagValues,X as thumbnail,Y as thumbnailUrl,L as tiffBlocks,I as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.keys(e).length}(e)?void 0:e}function f(e){let t=new Error(e);return delete t.stack,t}let o=r?global.BigInt:window.BigInt;const l=new TextDecoder("utf-8");class h{static from(e,t){return e instanceof this&&e.le===t?e:new h(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof h){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw f("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw f("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=h){if(e instanceof DataView||e instanceof h?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new h(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,l.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function u(e,t){throw f("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class d extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||u(this.kind,e),t&&(e in t||function(e,t){throw f("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||u(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}function c(e,t,i=[],s=[]){for(let s of i)void 0===e[s]&&(e[s]=t.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(e,i)){let s=Object.getOwnPropertyDescriptor(t.prototype,i);Object.defineProperty(e,i,s)}}}var p=new d("file parser"),g=new d("segment parser"),y=new d("file reader");function w(e,t){if((s=e).startsWith("data:")||s.length>1e4)return m(e,t,"base64");if(i)return b(e,t,"url",k);if(r)return m(e,t,"fs");throw f("Invalid input argument");var s}async function b(e,t,i,s){if(y.has(i))return m(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw f("Parser ".concat(i," is not loaded"))}async function m(e,t,i){let s=new(y.get(i))(e,t);return await s.read(),s}async function k(e){return fetch(e).then(e=>e.arrayBuffer())}async function v(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}c(p,d,["keyList"]),c(g,d,["keyList"]),c(y,d,["keyList"]);const U=Symbol("keys"),V=Symbol("values");class A extends Map{get tagKeys(){return this[U]||(this[U]=Array.from(this.keys())),this[U]}get tagValues(){return this[V]||(this[V]=Array.from(this.values())),this[V]}}const O=new Map,S=new Map,B=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],x=["jfif","xmp","icc","iptc"],L=["tiff",...x],T=["ifd0","ifd1","exif","gps","interop"],z=[...L,...T],C=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...D,"mergeOutput","sanitize"];class I{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends I{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.applyInheritables(s),this.canBeFiltered=T.includes(e),this.canBeFiltered&&(this.dict=O.get(e)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(e){let t,i;for(t of D)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,G(this.pick,this.deps)):this.enabled&&this.pick.size>0&&G(this.pick,this.deps)}}var E={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class N extends I{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw f("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=E[e];for(e of j)this[e]=E[e];for(e of C)this[e]=E[e];for(e of z)this[e]=new P(e,E[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=E[e];for(e of j)this[e]=E[e];for(e of C)this[e]=!0;for(e of z)this[e]=new P(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=E[t];for(t of j)this[t]=E[t];for(t of C)this[t]=E[t];for(t of z)this[t]=new P(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,T)}setupFromObject(e){let t;for(t of(T.ifd0=T.ifd0||T.image,T.ifd1=T.ifd1||T.thumbnail,Object.assign(this,e),F))this[t]=K(e[t],E[t]);for(t of j)this[t]=K(e[t],E[t]);for(t of C)this[t]=K(e[t],E[t]);for(t of L)this[t]=new P(t,E[t],e[t],this);for(t of T)this[t]=new P(t,E[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,T,z),!0===e.tiff?this.batchEnableWithBool(T,!0):!1===e.tiff?this.batchEnableWithUserValue(T,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,T):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,T)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=M(e,i);for(let[e,i]of t)G(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=M(t,i);for(let[t,i]of e)G(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=T.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of T)this[e].finalizeFilters()}get onlyTiff(){return!x.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of L)this[e].enabled&&!g.has(e)&&u("segment parser",e)}}function M(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=O.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function G(e,t){for(let i of t)e.add(i)}n(N,"default",E);const R={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},W=Object.assign({},R,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},R,{firstChunkSize:4e4,ifd0:[274]});class H{constructor(e){n(this,"parsers",{}),this.options=N.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=p.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=p.get("jpeg");else{if(!function(e){let t=e.getUint32(0),i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,e=p.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return w(e,t);if(i&&!s&&e instanceof HTMLImageElement)return w(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new h(e);if(i&&e instanceof Blob)return b(e,t,"blob",v);throw f("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},{mergeOutput:t}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let r;if(this.options.silentErrors){try{r=await s.parse()}catch(e){i.push(e)}s.errors.length&&i.push(...s.errors)}else r=await s.parse();(t||s.constructor.mergeOutput)&&"string"!=typeof r?Object.assign(e,r):void 0!==r&&(e[s.constructor.type]=r)});return await Promise.all(s),this.options.silentErrors&&i.length>0&&(e.errors=i),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=g.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}e.Exifr=H,e.Options=N,e.allFormatters=j,e.chunkedProps=F,e.createDictionary=function(e,t,i){let s=new A(i);if(c(s,A,void 0,["tagKeys","tagValues"]),Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s},e.disableAllOptions=R,e.extendDictionary=function(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=k,e.fileParsers=p,e.fileReaders=y,e.gps=async function(e){let t=new H(W);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=W,e.inheritables=D,e.orientation=async function(e){let t=new H(J);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=J,e.otherSegments=x,e.parse=async function(e,t){let i=new H(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=v,e.segmentParsers=g,e.segments=L,e.segmentsAndBlocks=z,e.tagKeys=O,e.tagRevivers=B,e.tagValues=S,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new H(i);await s.read(e);let r=await s.extractThumbnail();return r&&t?Buffer.from(r):r},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=T,e.tiffExtractables=C,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return function(e){if(void 0===e)return!0;return e instanceof Map?0===e.size:0===Object.values(e).filter(f).length}(e)?void 0:e}const f=e=>void 0!==e;function o(e){let t=new Error(e);return delete t.stack,t}let h=r?global.BigInt:self.BigInt;const l=new TextDecoder("utf-8");class u{static from(e,t){return e instanceof this&&e.le===t?e:new u(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof u){let{byteOffset:s,byteLength:r}=e;if(void 0===i&&(i=r-t),(t+=s)+i>s+r)throw o("Creating view outside of available memory in ArrayBuffer");let n=new DataView(e.buffer,t,i);this._swapDataView(n)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=u){if(e instanceof DataView||e instanceof u?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new u(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return s=i,l.decode(s);var s}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof h)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),h(t)<<h(32)|h(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function d(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||d(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||d(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),w=new c("file reader");function y(e,t){if((s=e).startsWith("data:")||s.length>1e4)return m(e,t,"base64");if(i)return b(e,t,"url",k);if(r)return m(e,t,"fs");throw o("Invalid input argument");var s}async function b(e,t,i,s){if(w.has(i))return m(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function m(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function k(e){return fetch(e).then(e=>e.arrayBuffer())}async function v(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const U=Symbol("keys"),V=Symbol("values");class A extends Map{get tagKeys(){return this[U]||(this[U]=Array.from(this.keys())),this[U]}get tagValues(){return this[V]||(this[V]=Array.from(this.values())),this[V]}}const S=new Map,B=new Map,O=new Map,F=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],x=["jfif","xmp","icc","iptc"],T=["tiff",...x],z=["ifd0","ifd1","exif","gps","interop"],C=[...T,...z],D=["makerNote","userComment"],L=["translateKeys","translateValues","reviveValues","multiSegment"],I=[...L,"sanitize","mergeOutput"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends j{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=z.includes(e),this.canBeFiltered&&(this.dict=S.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of L)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:r,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(s=n.indexOf(i),-1===s&&(s=r.indexOf(Number(i))),-1!==s&&t.add(Number(r[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,G(this.pick,this.deps)):this.enabled&&this.pick.size>0&&G(this.pick,this.deps)}}var E={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class N extends j{static useCached(e){let t=_.get(e);return void 0!==t?t:(t=new this(e),_.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of D)this[e]=E[e];for(e of C)this[e]=new P(e,E[e],void 0,this)}setupFromTrue(){let e;for(e of F)this[e]=E[e];for(e of I)this[e]=E[e];for(e of D)this[e]=!0;for(e of C)this[e]=new P(e,!0,void 0,this)}setupFromArray(e){let t;for(t of F)this[t]=E[t];for(t of I)this[t]=E[t];for(t of D)this[t]=E[t];for(t of C)this[t]=new P(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,z)}setupFromObject(e){let t;for(t of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,e),F))this[t]=K(e[t],E[t]);for(t of I)this[t]=K(e[t],E[t]);for(t of D)this[t]=K(e[t],E[t]);for(t of T)this[t]=new P(t,E[t],e[t],this);for(t of z)this[t]=new P(t,E[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,z,C),!0===e.tiff?this.batchEnableWithBool(z,!0):!1===e.tiff?this.batchEnableWithUserValue(z,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,z):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,z)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=M(e,i);for(let[e,i]of t)G(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=M(t,i);for(let[t,i]of e)G(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:r}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),r.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=z.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of z)this[e].finalizeFilters()}get onlyTiff(){return!x.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!g.has(e)&&d("segment parser",e)}}function M(e,t){let i,s,r,n,a=[];for(r of t){for(n of(i=S.get(r),s=[],i))(e.includes(n[0])||e.includes(n[1]))&&s.push(n[0]);s.length&&a.push([r,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function G(e,t){for(let i of t)e.add(i)}n(N,"default",E);const R={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},W=Object.assign({},R,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},R,{firstChunkSize:4e4,ifd0:[274]});class H{constructor(e){n(this,"parsers",{}),this.options=N.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=p.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=p.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=p.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return y(e,t);if(i&&!s&&e instanceof HTMLImageElement)return y(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new u(e);if(i&&e instanceof Blob)return b(e,t,"blob",v);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=g.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),r=await s.extractThumbnail();return this.file.close&&this.file.close(),r}}e.Exifr=H,e.Options=N,e.allFormatters=I,e.chunkedProps=F,e.createDictionary=function(e,t,i){let s=new A(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s},e.disableAllOptions=R,e.extendDictionary=function(e,t,i){let s,r=e.get(t);for(s of i)r.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=k,e.fileParsers=p,e.fileReaders=w,e.gps=async function(e){let t=new H(W);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=W,e.inheritables=L,e.orientation=async function(e){let t=new H(J);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=J,e.otherSegments=x,e.parse=async function(e,t){let i=new H(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=v,e.segmentParsers=g,e.segments=T,e.segmentsAndBlocks=C,e.tagKeys=S,e.tagRevivers=O,e.tagValues=B,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new H(i);await s.read(e);let r=await s.extractThumbnail();return r&&t?Buffer.from(r):r},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=z,e.tiffExtractables=D,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.keys(e).length)}function a(e){let t=new Error(e);return delete t.stack,t}function o(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function h(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let f=s?global.BigInt:window.BigInt;const l=new TextDecoder("utf-8");function u(e){return l.decode(e)}class d{static from(e,t){return e instanceof this&&e.le===t?e:new d(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof d){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw a("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw a("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=d){if(e instanceof DataView||e instanceof d?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw a("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new d(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return u(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof f)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),f(t)<<f(32)|f(i);throw a("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function c(e,t){throw a("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class g extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||c(this.kind,e),t&&(e in t||function(e,t){throw a("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||c(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}function p(e,t,i=[],s=[]){for(let s of i)void 0===e[s]&&(e[s]=t.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(e,i)){let s=Object.getOwnPropertyDescriptor(t.prototype,i);Object.defineProperty(e,i,s)}}}var m=new g("file parser"),y=new g("segment parser"),b=new g("file reader");function w(e,i){if((n=e).startsWith("data:")||n.length>1e4)return S(e,i,"base64");if(t)return k(e,i,"url",x);if(s)return S(e,i,"fs");throw a("Invalid input argument");var n}async function k(e,t,i,s){if(b.has(i))return S(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw a("Parser ".concat(i," is not loaded"))}async function S(e,t,i){let s=new(b.get(i))(e,t);return await s.read(),s}async function x(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}p(m,g,["keyList"]),p(y,g,["keyList"]),p(b,g,["keyList"]);const v=Symbol("keys"),O=Symbol("values");class I extends Map{get tagKeys(){return this[v]||(this[v]=Array.from(this.keys())),this[v]}get tagValues(){return this[O]||(this[O]=Array.from(this.values())),this[O]}}function U(e,t,i){let s=new I(i);if(p(s,I,void 0,["tagKeys","tagValues"]),Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function P(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const A=new Map,B=new Map,F=new Map,L=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],T=["tiff",...D],V=["ifd0","ifd1","exif","gps","interop"],N=[...T,...V],z=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],M=[...E,"mergeOutput","sanitize"];class G{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class R extends G{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.applyInheritables(s),this.canBeFiltered=V.includes(e),this.canBeFiltered&&(this.dict=A.get(e)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw a("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,X(this.pick,this.deps)):this.enabled&&this.pick.size>0&&X(this.pick,this.deps)}}var j={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},H=new Map;class W extends G{static useCached(e){let t=H.get(e);return void 0!==t?t:(t=new this(e),H.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw a("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of L)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=j[e];for(e of N)this[e]=new R(e,j[e],void 0,this)}setupFromTrue(){let e;for(e of L)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=!0;for(e of N)this[e]=new R(e,!0,void 0,this)}setupFromArray(e){let t;for(t of L)this[t]=j[t];for(t of M)this[t]=j[t];for(t of z)this[t]=j[t];for(t of N)this[t]=new R(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,V)}setupFromObject(e){let t;for(t of(V.ifd0=V.ifd0||V.image,V.ifd1=V.ifd1||V.thumbnail,Object.assign(this,e),L))this[t]=K(e[t],j[t]);for(t of M)this[t]=K(e[t],j[t]);for(t of z)this[t]=K(e[t],j[t]);for(t of T)this[t]=new R(t,j[t],e[t],this);for(t of V)this[t]=new R(t,j[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,V,N),!0===e.tiff?this.batchEnableWithBool(V,!0):!1===e.tiff?this.batchEnableWithUserValue(V,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,V):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,V)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=_(e,i);for(let[e,i]of t)X(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=_(t,i);for(let[t,i]of e)X(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=V.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of V)this[e].finalizeFilters()}get onlyTiff(){return!D.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!y.has(e)&&c("segment parser",e)}}function _(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=A.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function X(e,t){for(let i of t)e.add(i)}n(W,"default",j);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]});class Z{constructor(e){n(this,"parsers",{}),this.options=W.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=m.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=m.get("jpeg");else{if(!function(e){let t=e.getUint32(0),i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw a("Unknown file format");this.file.isHeic=!0,e=m.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return w(e,s);if(t&&!i&&e instanceof HTMLImageElement)return w(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new d(e);if(t&&e instanceof Blob)return k(e,s,"blob",C);throw a("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},{mergeOutput:t}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let n;if(this.options.silentErrors){try{n=await s.parse()}catch(e){i.push(e)}s.errors.length&&i.push(...s.errors)}else n=await s.parse();(t||s.constructor.mergeOutput)&&"string"!=typeof n?Object.assign(e,n):void 0!==n&&(e[s.constructor.type]=n)});var n;return await Promise.all(s),this.options.silentErrors&&i.length>0&&(e.errors=i),e=r(n=e)?void 0:n,this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=y.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function Q(e,t){let i=new Z(t);return await i.read(e),i.parse()}async function $(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Z(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n}async function ee(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function te(e){let t=new Z(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function ie(e){let t=new Z(q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}class se extends d{constructor(...e){super(...e),n(this,"ranges",new ne),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class ne{constructor(e){n(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>re(e,t.offset,s)||re(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function re(e,t,i){return e<=t&&t<=i}class ae extends se{constructor(e,t){super(0),n(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}b.set("blob",class extends ae{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class oe{constructor(e,t,i){n(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw a("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw a("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(y.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class he{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,start:n,size:r,end:n+r}}static parse(e,t,i){return"object"==typeof t&&(i=t,t=void 0),new this(new d(e,t),W.useCached(i)).parse()}constructor(e,t={},i){n(this,"errors",[]),n(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=e,this.options=t,this.file=i,this.type=this.constructor.type,this.segOptions=t[this.type],this.canTranslate=this.segOptions.translate,this.raw=new Map}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(e,t){let i=F.get(t),s=B.get(t),n=A.get(t),r=this.options[t],a=r.reviveValues&&i,o=r.translateValues&&s,h=r.translateKeys&&n,f={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):o&&s.has(t)&&(r=this.translateValue(r,s.get(t))),h&&n.has(t)&&(t=n.get(t)||t),f[t]=r;return f}translateValue(e,t){return t[e]||e}}n(he,"headerLength",4),n(he,"type",void 0),n(he,"mergeOutput",!1),n(he,"multiSegment",!1),n(he,"canHandle",()=>!1);function fe(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function le(e){return e>=224&&e<=239}function ue(e,t){for(let[i,s]of y)if(s.canHandle(e,t))return i}function de(...e){let t=e[0].constructor,i=0;for(let t of e)i+=t.length;let s=new t(i),n=0;for(let t of e)s.set(t,n),n+=t.length;return s}m.set("jpeg",class extends oe{constructor(...e){super(...e),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(y.keyList())):(e=void 0===e?y.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&y.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){if(y.get(e).multiSegment){s=!0,await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,o,{file:h,findAll:f,wanted:l,remaining:u,options:d}=this;for(;e<t;e++)if(255===h.getUint8(e))if(i=h.getUint8(e+1),le(i)){if(s=h.getUint16(e+2),n=ue(h,e),n&&l.has(n)&&(r=y.get(n),a=r.findPosition(h,e),o=d[n],a.type=n,this.appSegments.push(a),!f&&(a.multiSegment&&o.multiSegment?a.chunkNumber<a.chunkCount?this.unfinishedMultiSegment=!0:(this.unfinishedMultiSegment=!1,u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=he.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(fe(i)){if(s=h.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}async createParsers(){let e;if(this.hasMultiSegments){e=[];let t=[];for(let i of this.appSegments)if(i.multiSegment){if(t.includes(i.type))break;t.push(i.type);let s=de(...this.appSegments.filter(e=>e.type===i.type).sort((e,t)=>e.chunkNumber-t.chunkNumber).map(e=>e.chunk.toUint8()));e.push({type:i.type,chunk:new d(s)})}else e.push(i)}else e=this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(y.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}get hasMultiSegments(){return this.appSegments.some(e=>e.multiSegment)}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const ce=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ge extends he{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw a("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw a("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,o=this.chunk.getUint16(e);e+=2;for(let h=0;h<o;h++){let o=this.chunk.getUint16(e);if(r){if(s.has(o)&&(i.set(o,this.parseTag(e,o,t)),s.delete(o),0===s.size))break}else!a&&n.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=ce[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw a("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw a("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return o(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw a("Invalid tiff type ".concat(e))}}}class pe extends ge{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw a("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw a("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,h(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=d.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,h(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",me(...e.get(2),e.get(1))),e.set("longitude",me(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of V)if(e=this[t],!r(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}}function me(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(pe,"type","tiff"),n(pe,"mergeOutput",!0),n(pe,"headerLength",10),y.set("tiff",pe);b.set("url",class extends ae{async readWhole(){this.chunked=!1;let e=await x(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class ye extends oe{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}m.set("heic",class extends ye{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let o=4+this.file.getUint32(r);r+=o,a-=o,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),o=2===e.version?4:2,h=1===e.version||2===e.version?2:0,f=a+s+n,l=2===e.version?4:2,u=this.file.getUintBytes(i,l);for(i+=l;u--;){let e=this.file.getUintBytes(i,o);i+=o+h+2+r;let l=this.file.getUint16(i);if(i+=2,e===t)return l>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=l*f}}}),U(A,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),U(A,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),U(A,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),U(B,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);let be=U(B,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]);const we={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};be.set(37392,we),be.set(41488,we);const ke={0:"Normal",1:"Low",2:"High"};function Se(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function xe(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function Ce(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(ve(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(ve(e[i],e[i+1]));return o(String.fromCodePoint(...t))}function ve(e,t){return e<<8|t}be.set(41992,ke),be.set(41993,ke),be.set(41994,ke),U(F,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?u(e):e}],[306,xe],[40091,Ce],[40092,Ce],[40093,Ce],[40094,Ce],[40095,Ce]]),U(F,"exif",[[40960,Se],[36864,Se],[36867,xe],[36868,xe]]),U(F,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Oe extends he{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)}parse(){let e=this.chunk.getString(),t=e.indexOf("<"),i=e.lastIndexOf(">")+1;return e=e.slice(t,i).trim(),e.startsWith("<?xpacket")&&(t=e.indexOf(">")+1,i=e.lastIndexOf("<?xpacket"),e=e.slice(t,i).trim()),this.parseXml?this.parseXml(e):e}}n(Oe,"type","xmp"),y.set("xmp",Oe);export{Z as Exifr,W as Options,M as allFormatters,L as chunkedProps,U as createDictionary,J as disableAllOptions,P as extendDictionary,x as fetchUrlAsArrayBuffer,m as fileParsers,b as fileReaders,te as gps,Y as gpsOnlyOptions,E as inheritables,ie as orientation,q as orientationOnlyOptions,D as otherSegments,Q as parse,C as readBlobAsArrayBuffer,y as segmentParsers,T as segments,N as segmentsAndBlocks,A as tagKeys,F as tagRevivers,B as tagValues,$ as thumbnail,ee as thumbnailUrl,V as tiffBlocks,z as tiffExtractables};
var e="undefined"!=typeof Buffer,t="undefined"!=typeof navigator,i=t&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function r(e){return h(e)?void 0:e}const a=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(a).length)}function o(e){let t=new Error(e);return delete t.stack,t}function l(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function f(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let u=s?global.BigInt:self.BigInt;const d=new TextDecoder("utf-8");function c(e){return d.decode(e)}class g{static from(e,t){return e instanceof this&&e.le===t?e:new g(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof g){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw o("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=g){if(e instanceof DataView||e instanceof g?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new g(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return c(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof u)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),u(t)<<u(32)|u(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function p(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class m extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||p(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||p(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var y=new m("file parser"),b=new m("segment parser"),w=new m("file reader");function k(e,i){if((n=e).startsWith("data:")||n.length>1e4)return v(e,i,"base64");if(t)return S(e,i,"url",x);if(s)return v(e,i,"fs");throw o("Invalid input argument");var n}async function S(e,t,i,s){if(w.has(i))return v(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function v(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function x(e){return fetch(e).then(e=>e.arrayBuffer())}async function O(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const C=Symbol("keys"),I=Symbol("values");class A extends Map{get tagKeys(){return this[C]||(this[C]=Array.from(this.keys())),this[C]}get tagValues(){return this[I]||(this[I]=Array.from(this.values())),this[I]}}function U(e,t,i){let s=new A(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function P(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const B=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],N=["ifd0","ifd1","exif","gps","interop"],V=[...z,...N],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...E,"sanitize","mergeOutput"];class G{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class R extends G{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,J(this.pick,this.deps)):this.enabled&&this.pick.size>0&&J(this.pick,this.deps)}}var H={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},W=new Map;class _ extends G{static useCached(e){let t=W.get(e);return void 0!==t?t:(t=new this(e),W.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=t?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=H[e];for(e of V)this[e]=new R(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=!0;for(e of V)this[e]=new R(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of j)this[t]=H[t];for(t of M)this[t]=H[t];for(t of V)this[t]=new R(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,N)}setupFromObject(e){let t;for(t of(N.ifd0=N.ifd0||N.image,N.ifd1=N.ifd1||N.thumbnail,Object.assign(this,e),T))this[t]=X(e[t],H[t]);for(t of j)this[t]=X(e[t],H[t]);for(t of M)this[t]=X(e[t],H[t]);for(t of z)this[t]=new R(t,H[t],e[t],this);for(t of N)this[t]=new R(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,V),!0===e.tiff?this.batchEnableWithBool(N,!0):!1===e.tiff?this.batchEnableWithUserValue(N,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,N):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,N)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)J(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)J(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=N.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of N)this[e].finalizeFilters()}get onlyTiff(){return!D.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!b.has(e)&&p("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=B.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function X(e,t){return void 0!==e?e:void 0!==t?t:void 0}function J(e,t){for(let i of t)e.add(i)}n(_,"default",H);const q={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},q,{firstChunkSize:4e4,gps:[1,2,3,4]}),Z=Object.assign({},q,{firstChunkSize:4e4,ifd0:[274]});class Q{constructor(e){n(this,"parsers",{}),this.options=_.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=y.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=y.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=y.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,s){if("string"==typeof e)return k(e,s);if(t&&!i&&e instanceof HTMLImageElement)return k(e.src,s);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new g(e);if(t&&e instanceof Blob)return S(e,s,"blob",O);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=r(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=b.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function $(e,t){let i=new Q(t);return await i.read(e),i.parse()}async function ee(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Q(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n}async function te(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function ie(e){let t=new Q(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}}async function se(e){let t=new Q(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}class ne extends g{constructor(...e){super(...e),n(this,"ranges",new re),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class re{constructor(e){n(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>ae(e,t.offset,s)||ae(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function ae(e,t,i){return e<=t&&t<=i}class he extends ne{constructor(e,t){super(0),n(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}w.set("blob",class extends he{async readWhole(){this.chunked=!1;let e=await O(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await O(s);return this.set(n,e,!0)}});class oe{constructor(e,t,i){n(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw o("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw o("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(b.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class le{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new _({[this.type]:t})).parse()}normalizeInput(e){return e instanceof g?e:new g(e)}constructor(e,t={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(e,t){let i=L.get(t),s=F.get(t),n=B.get(t),r=this.options[t],a=r.reviveValues&&i,h=r.translateValues&&s,o=r.translateKeys&&n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):h&&s.has(t)&&(r=this.translateValue(r,s.get(t))),o&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}n(le,"headerLength",4),n(le,"type",void 0),n(le,"multiSegment",!1),n(le,"canHandle",()=>!1);function fe(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ue(e){return e>=224&&e<=239}function de(e,t){for(let[i,s]of b)if(s.canHandle(e,t))return i}y.set("jpeg",class extends oe{constructor(...e){super(...e),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(b.keyList())):(e=void 0===e?b.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&b.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){let t=b.get(e),i=this.options[e];if(t.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,h,{file:o,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===o.getUint8(e))if(i=o.getUint8(e+1),ue(i)){if(s=o.getUint16(e+2),n=de(o,e),n&&f.has(n)&&(r=b.get(n),a=r.findPosition(o,e),h=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=le.findPosition(o,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(fe(i)){if(s=o.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=b.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(b.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const ce=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ge extends le{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw o("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw o("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(e);e+=2;for(let o=0;o<h;o++){let h=this.chunk.getUint16(e);if(r){if(s.has(h)&&(i.set(h,this.parseTag(e,h,t)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(e,h,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=ce[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw o("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw o("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return l(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw o("Invalid tiff type ".concat(e))}}}class pe extends ge{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw o("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw o("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=g.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",me(...e.get(2),e.get(1))),e.set("longitude",me(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of N)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function me(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(pe,"type","tiff"),n(pe,"headerLength",10),b.set("tiff",pe);w.set("url",class extends he{async readWhole(){this.chunked=!1;let e=await x(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class ye extends oe{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}y.set("heic",class extends ye{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let h=4+this.file.getUint32(r);r+=h,a-=h,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),h=2===e.version?4:2,o=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,h);i+=h+o+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),U(B,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),U(B,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),U(B,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),U(F,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);let be=U(F,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]);const we={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};be.set(37392,we),be.set(41488,we);const ke={0:"Normal",1:"Low",2:"High"};function Se(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ve(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),h=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(h.setHours(n),h.setMinutes(r),h.setSeconds(a)),Number.isNaN(+h)?e:h}}function xe(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(Oe(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Oe(e[i],e[i+1]));return l(String.fromCodePoint(...t))}function Oe(e,t){return e<<8|t}be.set(41992,ke),be.set(41993,ke),be.set(41994,ke),U(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?c(e):e}],[306,ve],[40091,xe],[40092,xe],[40093,xe],[40094,xe],[40095,xe]]),U(L,"exif",[[40960,Se],[36864,Se],[36867,ve],[36868,ve]]),U(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Ce extends le{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(De,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Ae.findAll(e,"rdf","Description");0===t.length&&t.push(new Ae("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Fe(t.ns,s),Ue(t,i);return function(e){let t;for(let i of Object.keys(e))t=e[i]=r(e[i]),void 0===t&&delete e[i];return r(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}n(Ce,"type","xmp"),n(Ce,"multiSegment",!0),b.set("xmp",Ce);class Ie{static findAll(e){return Le(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Ie.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Te(s),new Ie(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Ae{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Le(e,s).map(Ae.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Ae(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Ie.findAll(i),this.children=Ae.findAll(s),this.value=0===this.children.length?Te(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Be(this.children.map(Pe));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Ue(t,e);return void 0!==this.value&&(e.value=this.value),r(e)}}function Ue(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Pe=e=>e.serialize(),Be=e=>1===e.length?e[0]:e,Fe=(e,t)=>t[e]?t[e]:t[e]={};function Le(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Te(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const De=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;export{Q as Exifr,_ as Options,j as allFormatters,T as chunkedProps,U as createDictionary,q as disableAllOptions,P as extendDictionary,x as fetchUrlAsArrayBuffer,y as fileParsers,w as fileReaders,ie as gps,Y as gpsOnlyOptions,E as inheritables,se as orientation,Z as orientationOnlyOptions,D as otherSegments,$ as parse,O as readBlobAsArrayBuffer,b as segmentParsers,z as segments,V as segmentsAndBlocks,B as tagKeys,L as tagRevivers,F as tagValues,ee as thumbnail,te as thumbnailUrl,N as tiffBlocks,M as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.keys(e).length)}function o(e){let t=new Error(e);return delete t.stack,t}function h(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function f(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let l=n?global.BigInt:window.BigInt;const u=new TextDecoder("utf-8");function d(e){return u.decode(e)}class c{static from(e,t){return e instanceof this&&e.le===t?e:new c(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof c){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw o("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw o("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=c){if(e instanceof DataView||e instanceof c?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw o("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new c(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return d(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof l)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),l(t)<<l(32)|l(i);throw o("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function p(e,t){throw o("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class g extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||p(this.kind,e),t&&(e in t||function(e,t){throw o("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||p(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}function m(e,t,i=[],s=[]){for(let s of i)void 0===e[s]&&(e[s]=t.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(e,i)){let s=Object.getOwnPropertyDescriptor(t.prototype,i);Object.defineProperty(e,i,s)}}}var y=new g("file parser"),b=new g("segment parser"),w=new g("file reader");function k(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return S(e,t,"url",v);if(n)return x(e,t,"fs");throw o("Invalid input argument");var s}async function S(e,t,i,s){if(w.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw o("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(w.get(i))(e,t);return await s.read(),s}async function v(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}m(y,g,["keyList"]),m(b,g,["keyList"]),m(w,g,["keyList"]);const O=Symbol("keys"),I=Symbol("values");class U extends Map{get tagKeys(){return this[O]||(this[O]=Array.from(this.keys())),this[O]}get tagValues(){return this[I]||(this[I]=Array.from(this.values())),this[I]}}function A(e,t,i){let s=new U(i);if(m(s,U,void 0,["tagKeys","tagValues"]),Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}const P=new Map,B=new Map,F=new Map,D=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],T=["tiff",...L],V=["ifd0","ifd1","exif","gps","interop"],N=[...T,...V],z=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],M=[...E,"mergeOutput","sanitize"];class R{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends R{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.applyInheritables(s),this.canBeFiltered=V.includes(e),this.canBeFiltered&&(this.dict=P.get(e)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw o("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,X(this.pick,this.deps)):this.enabled&&this.pick.size>0&&X(this.pick,this.deps)}}var j={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},H=new Map;class W extends R{static useCached(e){let t=H.get(e);return void 0!==t?t:(t=new this(e),H.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw o("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of D)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=j[e];for(e of N)this[e]=new G(e,j[e],void 0,this)}setupFromTrue(){let e;for(e of D)this[e]=j[e];for(e of M)this[e]=j[e];for(e of z)this[e]=!0;for(e of N)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of D)this[t]=j[t];for(t of M)this[t]=j[t];for(t of z)this[t]=j[t];for(t of N)this[t]=new G(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,V)}setupFromObject(e){let t;for(t of(V.ifd0=V.ifd0||V.image,V.ifd1=V.ifd1||V.thumbnail,Object.assign(this,e),D))this[t]=K(e[t],j[t]);for(t of M)this[t]=K(e[t],j[t]);for(t of z)this[t]=K(e[t],j[t]);for(t of T)this[t]=new G(t,j[t],e[t],this);for(t of V)this[t]=new G(t,j[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,V,N),!0===e.tiff?this.batchEnableWithBool(V,!0):!1===e.tiff?this.batchEnableWithUserValue(V,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,V):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,V)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=_(e,i);for(let[e,i]of t)X(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=_(t,i);for(let[t,i]of e)X(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=V.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of V)this[e].finalizeFilters()}get onlyTiff(){return!L.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of T)this[e].enabled&&!b.has(e)&&p("segment parser",e)}}function _(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=P.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function K(e,t){return void 0!==e?e:void 0!==t?t:void 0}function X(e,t){for(let i of t)e.add(i)}r(W,"default",j);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]});class Z{constructor(e){r(this,"parsers",{}),this.options=W.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=y.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=y.get("jpeg");else{if(!function(e){let t=e.getUint32(0),i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw o("Unknown file format");this.file.isHeic=!0,e=y.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return k(e,t);if(i&&!s&&e instanceof HTMLImageElement)return k(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new c(e);if(i&&e instanceof Blob)return S(e,t,"blob",C);throw o("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},{mergeOutput:t}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let n;if(this.options.silentErrors){try{n=await s.parse()}catch(e){i.push(e)}s.errors.length&&i.push(...s.errors)}else n=await s.parse();(t||s.constructor.mergeOutput)&&"string"!=typeof n?Object.assign(e,n):void 0!==n&&(e[s.constructor.type]=n)});var n;return await Promise.all(s),this.options.silentErrors&&i.length>0&&(e.errors=i),e=a(n=e)?void 0:n,this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=b.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class Q extends c{constructor(...e){super(...e),r(this,"ranges",new $),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class ${constructor(e){r(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>ee(e,t.offset,s)||ee(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function ee(e,t,i){return e<=t&&t<=i}class te extends Q{constructor(e,t){super(0),r(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}w.set("blob",class extends te{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class ie{constructor(e,t,i){r(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw o("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw o("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(b.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class se{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,start:n,size:r,end:n+r}}static parse(e,t,i){return"object"==typeof t&&(i=t,t=void 0),new this(new c(e,t),W.useCached(i)).parse()}constructor(e,t={},i){r(this,"errors",[]),r(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=e,this.options=t,this.file=i,this.type=this.constructor.type,this.segOptions=t[this.type],this.canTranslate=this.segOptions.translate,this.raw=new Map}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(e,t){let i=F.get(t),s=B.get(t),n=P.get(t),r=this.options[t],a=r.reviveValues&&i,o=r.translateValues&&s,h=r.translateKeys&&n,f={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):o&&s.has(t)&&(r=this.translateValue(r,s.get(t))),h&&n.has(t)&&(t=n.get(t)||t),f[t]=r;return f}translateValue(e,t){return t[e]||e}}r(se,"headerLength",4),r(se,"type",void 0),r(se,"mergeOutput",!1),r(se,"multiSegment",!1),r(se,"canHandle",()=>!1);function ne(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function re(e){return e>=224&&e<=239}function ae(e,t){for(let[i,s]of b)if(s.canHandle(e,t))return i}function oe(...e){let t=e[0].constructor,i=0;for(let t of e)i+=t.length;let s=new t(i),n=0;for(let t of e)s.set(t,n),n+=t.length;return s}y.set("jpeg",class extends ie{constructor(...e){super(...e),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(b.keyList())):(e=void 0===e?b.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&b.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){if(b.get(e).multiSegment){s=!0,await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,o,{file:h,findAll:f,wanted:l,remaining:u,options:d}=this;for(;e<t;e++)if(255===h.getUint8(e))if(i=h.getUint8(e+1),re(i)){if(s=h.getUint16(e+2),n=ae(h,e),n&&l.has(n)&&(r=b.get(n),a=r.findPosition(h,e),o=d[n],a.type=n,this.appSegments.push(a),!f&&(a.multiSegment&&o.multiSegment?a.chunkNumber<a.chunkCount?this.unfinishedMultiSegment=!0:(this.unfinishedMultiSegment=!1,u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=se.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(ne(i)){if(s=h.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}async createParsers(){let e;if(this.hasMultiSegments){e=[];let t=[];for(let i of this.appSegments)if(i.multiSegment){if(t.includes(i.type))break;t.push(i.type);let s=oe(...this.appSegments.filter(e=>e.type===i.type).sort((e,t)=>e.chunkNumber-t.chunkNumber).map(e=>e.chunk.toUint8()));e.push({type:i.type,chunk:new c(s)})}else e.push(i)}else e=this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(b.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}get hasMultiSegments(){return this.appSegments.some(e=>e.multiSegment)}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const he=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class fe extends se{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw o("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw o("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,o=this.chunk.getUint16(e);e+=2;for(let h=0;h<o;h++){let o=this.chunk.getUint16(e);if(r){if(s.has(o)&&(i.set(o,this.parseTag(e,o,t)),s.delete(o),0===s.size))break}else!a&&n.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=he[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw o("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw o("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return h(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw o("Invalid tiff type ".concat(e))}}}class le extends fe{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw o("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw o("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=c.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",ue(...e.get(2),e.get(1))),e.set("longitude",ue(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of V)if(e=this[t],!a(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}}function ue(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(le,"type","tiff"),r(le,"mergeOutput",!0),r(le,"headerLength",10),b.set("tiff",le);w.set("url",class extends te{async readWhole(){this.chunked=!1;let e=await v(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class de extends ie{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}y.set("heic",class extends de{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let o=4+this.file.getUint32(r);r+=o,a-=o,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),o=2===e.version?4:2,h=1===e.version||2===e.version?2:0,f=a+s+n,l=2===e.version?4:2,u=this.file.getUintBytes(i,l);for(i+=l;u--;){let e=this.file.getUintBytes(i,o);i+=o+h+2+r;let l=this.file.getUint16(i);if(i+=2,e===t)return l>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=l*f}}}),A(P,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),A(P,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),A(P,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),A(B,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);let ce=A(B,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]);const pe={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};ce.set(37392,pe),ce.set(41488,pe);const ge={0:"Normal",1:"Low",2:"High"};function me(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ye(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function be(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(we(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(we(e[i],e[i+1]));return h(String.fromCodePoint(...t))}function we(e,t){return e<<8|t}ce.set(41992,ge),ce.set(41993,ge),ce.set(41994,ge),A(F,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?d(e):e}],[306,ye],[40091,be],[40092,be],[40093,be],[40094,be],[40095,be]]),A(F,"exif",[[40960,me],[36864,me],[36867,ye],[36868,ye]]),A(F,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class ke extends se{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)}parse(){let e=this.chunk.getString(),t=e.indexOf("<"),i=e.lastIndexOf(">")+1;return e=e.slice(t,i).trim(),e.startsWith("<?xpacket")&&(t=e.indexOf(">")+1,i=e.lastIndexOf("<?xpacket"),e=e.slice(t,i).trim()),this.parseXml?this.parseXml(e):e}}r(ke,"type","xmp"),b.set("xmp",ke),e.Exifr=Z,e.Options=W,e.allFormatters=M,e.chunkedProps=D,e.createDictionary=A,e.disableAllOptions=J,e.extendDictionary=function(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=v,e.fileParsers=y,e.fileReaders=w,e.gps=async function(e){let t=new Z(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=Y,e.inheritables=E,e.orientation=async function(e){let t=new Z(q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=q,e.otherSegments=L,e.parse=async function(e,t){let i=new Z(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=C,e.segmentParsers=b,e.segments=T,e.segmentsAndBlocks=N,e.tagKeys=P,e.tagRevivers=F,e.tagValues=B,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Z(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=V,e.tiffExtractables=z,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";var t="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function a(e){return h(e)?void 0:e}const o=e=>void 0!==e;function h(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(o).length)}function l(e){let t=new Error(e);return delete t.stack,t}function f(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function u(e){let t=function(e){let t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}let d=n?global.BigInt:self.BigInt;const c=new TextDecoder("utf-8");function g(e){return c.decode(e)}class p{static from(e,t){return e instanceof this&&e.le===t?e:new p(e,void 0,void 0,t)}constructor(e,t=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(e)&&(e=new Uint8Array(e)),0===e)this.byteOffset=0,this.byteLength=0;else if(e instanceof ArrayBuffer){let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof p){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw l("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else{if("number"!=typeof e)throw l("Invalid input argument for BufferView: "+e);{let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}}}_swapArrayBuffer(e){this._swapDataView(new DataView(e))}_swapBuffer(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}_swapDataView(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}_lengthToEnd(e){return this.byteLength-e}set(e,t,i=p){if(e instanceof DataView||e instanceof p?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw l("BufferView.set(): Invalid data argument.");return this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new p(this,e,t)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}getString(e=0,t=this.byteLength){return g(this.getUint8Array(e,t))}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let s=0;s<t&&e+s<this.byteLength;s+=2)i.push(this.getUint16(e+s));return i.map(e=>String.fromCharCode(e)).join("")}getInt8(e){return this.dataView.getInt8(e)}getUint8(e){return this.dataView.getUint8(e)}getInt16(e,t=this.le){return this.dataView.getInt16(e,t)}getInt32(e,t=this.le){return this.dataView.getInt32(e,t)}getUint16(e,t=this.le){return this.dataView.getUint16(e,t)}getUint32(e,t=this.le){return this.dataView.getUint32(e,t)}getFloat32(e,t=this.le){return this.dataView.getFloat32(e,t)}getFloat64(e,t=this.le){return this.dataView.getFloat64(e,t)}getFloat(e,t=this.le){return this.dataView.getFloat32(e,t)}getDouble(e,t=this.le){return this.dataView.getFloat64(e,t)}getUint64(e){let t=this.getUint32(e),i=this.getUint32(e+4);if(t<1048575)return t<<32|i;if(void 0!==typeof d)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),d(t)<<d(32)|d(i);throw l("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(e,t,i){switch(t){case 1:return this.getUint8(e,i);case 2:return this.getUint16(e,i);case 4:return this.getUint32(e,i);case 8:return this.getUint64(e,i)}}getUint(e,t,i){switch(t){case 8:return this.getUint8(e,i);case 16:return this.getUint16(e,i);case 32:return this.getUint32(e,i);case 64:return this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function m(e,t){throw l("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class y extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||m(this.kind,e),t&&(e in t||function(e,t){throw l("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||m(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var b=new y("file parser"),w=new y("segment parser"),k=new y("file reader");function S(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return v(e,t,"url",O);if(n)return x(e,t,"fs");throw l("Invalid input argument");var s}async function v(e,t,i,s){if(k.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new DataView(i)}(e,s);throw l("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(k.get(i))(e,t);return await s.read(),s}async function O(e){return fetch(e).then(e=>e.arrayBuffer())}async function C(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}const A=Symbol("keys"),I=Symbol("values");class U extends Map{get tagKeys(){return this[A]||(this[A]=Array.from(this.keys())),this[A]}get tagValues(){return this[I]||(this[I]=Array.from(this.values())),this[I]}}function B(e,t,i){let s=new U(i);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}const P=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],N=["ifd0","ifd1","exif","gps","interop"],V=[...z,...N],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...E,"sanitize","mergeOutput"];class R{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends R{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=P.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw l("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of e)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&t.add(Number(n[s]))):t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,J(this.pick,this.deps)):this.enabled&&this.pick.size>0&&J(this.pick,this.deps)}}var H={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},W=new Map;class _ extends R{static useCached(e){let t=W.get(e);return void 0!==t?t:(t=new this(e),W.set(e,t),t)}constructor(e){if(super(),!0===e)this.setupFromTrue();else if(void 0===e)this.setupFromUndefined();else if(Array.isArray(e))this.setupFromArray(e);else{if("object"!=typeof e)throw l("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=H[e];for(e of V)this[e]=new G(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of j)this[e]=H[e];for(e of M)this[e]=!0;for(e of V)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of j)this[t]=H[t];for(t of M)this[t]=H[t];for(t of V)this[t]=new G(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,N)}setupFromObject(e){let t;for(t of(N.ifd0=N.ifd0||N.image,N.ifd1=N.ifd1||N.thumbnail,Object.assign(this,e),T))this[t]=X(e[t],H[t]);for(t of j)this[t]=X(e[t],H[t]);for(t of M)this[t]=X(e[t],H[t]);for(t of z)this[t]=new G(t,H[t],e[t],this);for(t of N)this[t]=new G(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,V),!0===e.tiff?this.batchEnableWithBool(N,!0):!1===e.tiff?this.batchEnableWithUserValue(N,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,N):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,N)}batchEnableWithBool(e,t){for(let i of e)this[i].enabled=t}batchEnableWithUserValue(e,t){for(let i of e){let e=t[i];this[i].enabled=!1!==e&&void 0!==e}}setupGlobalFilters(e,t,i,s=i){if(e&&e.length){for(let e of s)this[e].enabled=!1;let t=K(e,i);for(let[e,i]of t)J(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=K(t,i);for(let[t,i]of e)J(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:s,icc:n}=this;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),i.enabled||e.skip.add(700),s.enabled||e.skip.add(33723),n.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:s}=this;s.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=N.some(e=>!0===this[e].enabled)||this.makerNote||this.userComment;for(let e of N)this[e].finalizeFilters()}get onlyTiff(){return!D.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!w.has(e)&&m("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=P.get(n),s=[],i))(e.includes(r[0])||e.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function X(e,t){return void 0!==e?e:void 0!==t?t:void 0}function J(e,t){for(let i of t)e.add(i)}r(_,"default",H);const q={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Y=Object.assign({},q,{firstChunkSize:4e4,gps:[1,2,3,4]}),Z=Object.assign({},q,{firstChunkSize:4e4,ifd0:[274]});class Q{constructor(e){r(this,"parsers",{}),this.options=_.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=b.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=b.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;let t=e.getUint16(2);if(t>50)return!1;let i=16,s=[];for(;i<t;)s.push(e.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw l("Unknown file format");this.file.isHeic=!0,e=b.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}async read(e){this.file=await function(e,t){if("string"==typeof e)return S(e,t);if(i&&!s&&e instanceof HTMLImageElement)return S(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new p(e);if(i&&e instanceof Blob)return v(e,t,"blob",C);throw l("Invalid input argument")}(e,this.options)}async parse(){this.setup(),await this.fileParser.parse();let e={},t=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(e){t.push(e)}i.errors.length&&t.push(...i.errors)}else s=await i.parse();i.assignToOutput(e,s)});return await Promise.all(i),this.options.silentErrors&&t.length>0&&(e.errors=t),e=a(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=w.get("tiff",this.options);var t;if(this.file.isTiff?t={start:0,type:"tiff"}:this.file.isJpeg&&(t=await this.fileParser.getOrFindSegment("tiff")),void 0===t)return;let i=await this.fileParser.ensureSegmentChunk(t),s=this.parsers.tiff=new e(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class $ extends p{constructor(...e){super(...e),r(this,"ranges",new ee),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(e,t,i){if(0===e&&0===this.byteLength&&i){let e=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(e)}else{let i=e+t;if(i>this.byteLength){let{dataView:e}=this._extend(i);this._swapDataView(e)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(e,t,i=!1){return t=t||this._lengthToEnd(e),i&&this._tryExtend(e,t),this.ranges.add(e,t),super.subarray(e,t)}set(e,t,i=!1){i&&this._tryExtend(t,e.byteLength,e);let s=super.set(e,t);return this.ranges.add(t,s.byteLength),s}async ensureChunk(e,t){this.chunked&&(this.ranges.available(e,t)||await this.readChunk(e,t))}available(e,t){return this.ranges.available(e,t)}}class ee{constructor(e){r(this,"list",[]),void 0!==e&&Array.isArray(e)&&this.addMultiple(e)}get length(){return this.list.length}addMultiple(e){if(Array.isArray(e[0]))for(let[t,i]of e)this.add(t,i);else for(let{offset:t,length:i}of e)this.add(t,i)}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>te(e,t.offset,s)||te(e,t.end,s));if(n.length>0){e=Math.min(e,...n.map(e=>e.offset)),s=Math.max(s,...n.map(e=>e.end)),t=s-e;let i=n.shift();i.offset=e,i.length=t,i.end=s,this.list=this.list.filter(e=>!n.includes(e))}else this.list.push({offset:e,length:t,end:s})}available(e,t){let i=e+t;return this.list.some(t=>t.offset<=e&&i<=t.end)}}function te(e,t,i){return e<=t&&t<=i}class ie extends ${constructor(e,t){super(0),r(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}k.set("blob",class extends ie{async readWhole(){this.chunked=!1;let e=await C(this.input);this._swapArrayBuffer(e)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(e,t){let i=t?e+t:void 0,s=this.input.slice(e,i),n=await C(s);return this.set(n,e,!0)}});class se{constructor(e,t,i){r(this,"ensureSegmentChunk",async e=>{let t=e.start,i=e.size||65536;if(this.file.chunked)if(this.file.available(t,i))e.chunk=this.file.subarray(t,i);else try{e.chunk=await this.file.readChunk(t,i)}catch(t){throw l("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}else if(this.file.byteLength>t+i)e.chunk=this.file.subarray(t,i);else{if(void 0!==e.size)throw l("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}createParser(e,t){let i=new(w.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class ne{static findPosition(e,t){let i=e.getUint16(t+2)+2,s="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,n=t+s,r=i-s;return{offset:t,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(e,t={}){return new this(e,new _({[this.type]:t})).parse()}normalizeInput(e){return e instanceof p?e:new p(e)}constructor(e,t={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(e,t){let i=L.get(t),s=F.get(t),n=P.get(t),r=this.options[t],a=r.reviveValues&&i,o=r.translateValues&&s,h=r.translateKeys&&n,l={};for(let[t,r]of e)a&&i.has(t)?r=i.get(t)(r):o&&s.has(t)&&(r=this.translateValue(r,s.get(t))),h&&n.has(t)&&(t=n.get(t)||t),l[t]=r;return l}translateValue(e,t){return t[e]||e}assignToOutput(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}assignObjectToOutput(e,t,i){if(this.globalOptions.mergeOutput)return Object.assign(e,i);e[t]?Object.assign(e[t],i):e[t]=i}}r(ne,"headerLength",4),r(ne,"type",void 0),r(ne,"multiSegment",!1),r(ne,"canHandle",()=>!1);function re(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ae(e){return e>=224&&e<=239}function oe(e,t){for(let[i,s]of w)if(s.canHandle(e,t))return i}b.set("jpeg",class extends se{constructor(...e){super(...e),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let e=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(e)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(w.keyList())):(e=void 0===e?w.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&w.has(e)),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}async findAppSegments(e=0,t){this.setupSegmentFinderArgs(t);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let e of n){let t=w.get(e),i=this.options[e];if(t.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(e=this._findAppSegments(e,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let t=!1;for(;r.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(e=>!this.file.available(e.offset||e.start,e.length||e.size));if(t=e>s&&!n?!await i.readNextChunk(e):!await i.readNextChunk(s),void 0===(e=this._findAppSegments(e,i.byteLength)))return}}}_findAppSegments(e,t){let i,s,n,r,a,o,{file:h,findAll:l,wanted:f,remaining:u,options:d}=this;for(;e<t;e++)if(255===h.getUint8(e))if(i=h.getUint8(e+1),ae(i)){if(s=h.getUint16(e+2),n=oe(h,e),n&&f.has(n)&&(r=w.get(n),a=r.findPosition(h,e),o=d[n],a.type=n,this.appSegments.push(a),!l&&(r.multiSegment&&o.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=ne.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(re(i)){if(s=h.getUint16(e+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:e,length:s,marker:i}),e+=s+1}return e}mergeMultiSegments(){if(!this.appSegments.some(e=>e.multiSegment))return;let e=function(e,t){let i,s,n,r=new Map;for(let a=0;a<e.length;a++)i=e[a],s=i[t],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=w.get(e,this.options);if(i.handleMultiSegments){return{type:e,chunk:i.handleMultiSegments(t)}}return t[0]})}async createParsers(){let e=this.mergedAppSegments||this.appSegments;for(let t of e){let{type:e,chunk:i}=t;if(!this.options[e].enabled)continue;let s=this.parsers[e];if(s&&s.append);else if(!s){let t=new(w.get(e,this.options))(i,this.options,this.file);this.parsers[e]=t}}}getSegment(e){return this.appSegments.find(t=>t.type===e)}async getOrFindSegment(e){let t=this.getSegment(e);return void 0===t&&(await this.findAppSegments(0,[e]),t=this.getSegment(e)),t}});const he=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class le extends ne{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw l("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw l("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:s,skip:n}=this.options[t];s=new Set(s);let r=s.size>0,a=0===n.size,o=this.chunk.getUint16(e);e+=2;for(let h=0;h<o;h++){let o=this.chunk.getUint16(e);if(r){if(s.has(o)&&(i.set(o,this.parseTag(e,o,t)),s.delete(o),0===s.size))break}else!a&&n.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let s=this.chunk.getUint16(e+2),n=this.chunk.getUint32(e+4),r=he[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw l("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e));if(e>this.chunk.byteLength)throw l("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(s,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(e,n);if(2===s)return f(this.chunk.getString(e,n));if(7===s)return this.chunk.getUint8Array(e,n);if(1===n)return this.parseTagValue(s,e);{let t=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw l("Invalid tiff type ".concat(e))}}}class fe extends le{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}parseBlock(e,t){let i=new Map;return this[t]=i,this.parseTags(e,t,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw l("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw l("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,u(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==e.size?(this.exifOffset=e.get(34665),this.interopOffset=e.get(40965),this.gpsOffset=e.get(34853),this.xmp=e.get(700),this.iptc=e.get(33723),this.icc=e.get(34675),this.options.sanitize&&(e.delete(34665),e.delete(40965),e.delete(34853),e.delete(700),e.delete(33723),e.delete(34675)),e):void 0}async ensureBlockChunk(e,t){this.file.isTiff&&await this.file.ensureChunk(e,t),e>this.chunk.byteLength&&(this.chunk=p.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,u(this.options));let e=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=e.get(40965)),this.makerNote=e.get(37500),this.userComment=e.get(37510),this.options.sanitize&&(e.delete(40965),e.delete(37500),e.delete(37510)),this.unpack(e,41728),this.unpack(e,41729),e}unpack(e,t){let i=e.get(t);i&&1===i.length&&e.set(t,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let e=this.parseBlock(this.gpsOffset,"gps");return e&&e.has(2)&&e.has(4)&&(e.set("latitude",ue(...e.get(2),e.get(1))),e.set("longitude",ue(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(e=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||e))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let e=this.ifd1.get(513),t=this.ifd1.get(514);return this.chunk.getUint8Array(e,t)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let e,t,i,s={};for(t of N)if(e=this[t],!h(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(s,i)}else s[t]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,s]of Object.entries(t))this.assignObjectToOutput(e,i,s)}}function ue(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(fe,"type","tiff"),r(fe,"headerLength",10),w.set("tiff",fe);k.set("url",class extends ie{async readWhole(){this.chunked=!1;let e=await O(this.input);this._swapArrayBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,s={};(e||i)&&(s.range="bytes=".concat([e,i].join("-")));let n=await fetch(this.input,{headers:s}),r=await n.arrayBuffer(),a=r.byteLength;if(416!==n.status)return a!==t&&(this.size=e+a),this.set(r,e,!0)}});class de extends se{parseBoxes(e=0){let t=[];for(;e<this.file.byteLength-4;){let i=this.parseBoxHead(e);if(t.push(i),0===i.length)break;e+=i.length}return t}parseSubBoxes(e){e.boxes=this.parseBoxes(e.start)}findBox(e,t){return void 0===e.boxes&&this.parseSubBoxes(e),e.boxes.find(e=>e.kind===t)}parseBoxHead(e){let t=this.file.getUint32(e),i=this.file.getString(e+4,4),s=e+8;return 1===t&&(t=this.file.getUint64(e+8),s+=8),{offset:e,length:t,kind:i,start:s}}parseBoxFullHead(e){let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}b.set("heic",class extends de{async parse(){var e=this.file.getUint32(0);let t=this.parseBoxHead(e);await this.file.ensureChunk(t.offset,t.length),this.parseBoxFullHead(t),this.parseSubBoxes(t),this.options.icc.enabled&&await this.findIcc(t),this.options.tiff.enabled&&await this.findExif(t)}async registerSegment(e,t,i){await this.file.ensureChunk(t,i);let s=this.file.subarray(t,i);this.createParser(e,s)}async findIcc(e){let t=this.findBox(e,"iprp");if(void 0===t)return;let i=this.findBox(t,"ipco");if(void 0===i)return;let s=this.findBox(i,"colr");void 0!==s&&await this.registerSegment("icc",s.offset+12,s.length)}async findExif(e){let t=this.findBox(e,"iinf");if(void 0===t)return;let i=this.findBox(e,"iloc");if(void 0===i)return;let s=this.findExifLocIdInIinf(t),n=this.findExtentInIloc(i,s);if(void 0===n)return;let[r,a]=n;await this.file.ensureChunk(r,a);let o=4+this.file.getUint32(r);r+=o,a-=o,await this.registerSegment("tiff",r,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,s,n,r=e.start,a=this.file.getUint16(r);for(r+=2;a--;){if(t=this.parseBoxHead(r),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(s=3===t.version?4:2,n=this.file.getString(i+s+2,4),"Exif"===n))return this.file.getUintBytes(i,s);r+=t.length}}get8bits(e){let t=this.file.getUint8(e);return[t>>4,15&t]}findExtentInIloc(e,t){this.parseBoxFullHead(e);let i=e.start,[s,n]=this.get8bits(i++),[r,a]=this.get8bits(i++),o=2===e.version?4:2,h=1===e.version||2===e.version?2:0,l=a+s+n,f=2===e.version?4:2,u=this.file.getUintBytes(i,f);for(i+=f;u--;){let e=this.file.getUintBytes(i,o);i+=o+h+2+r;let f=this.file.getUint16(i);if(i+=2,e===t)return f>1&&console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"),[this.file.getUintBytes(i+a,s),this.file.getUintBytes(i+a+s,n)];i+=f*l}}}),B(P,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),B(P,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),B(P,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),B(F,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);let ce=B(F,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]);const ge={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};ce.set(37392,ge),ce.set(41488,ge);const pe={0:"Normal",1:"Low",2:"High"};function me(e){let t=Array.from(e).slice(1);return t[1]>15&&(t=t.map(e=>String.fromCharCode(e))),"0"!==t[2]&&0!==t[2]||t.pop(),t.join(".")}function ye(e){if("string"==typeof e){var[t,i,s,n,r,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,s);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function be(e){if("string"==typeof e)return e;let t=[];if(0===e[1]&&0===e[e.length-1])for(let i=0;i<e.length;i+=2)t.push(we(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(we(e[i],e[i+1]));return f(String.fromCodePoint(...t))}function we(e,t){return e<<8|t}ce.set(41992,pe),ce.set(41993,pe),ce.set(41994,pe),B(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?g(e):e}],[306,ye],[40091,be],[40092,be],[40093,be],[40094,be],[40095,be]]),B(L,"exif",[[40960,me],[36864,me],[36867,ye],[36868,ye]]),B(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class ke extends ne{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,"http://ns.adobe.com/".length)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,"http://ns.adobe.com/xmp/extension/".length)?79:4+"http://ns.adobe.com/xap/1.0/".length+1}static findPosition(e,t){let i=super.findPosition(e,t);return i.multiSegment=i.extended=79===i.headerLength,i.multiSegment?(i.chunkCount=e.getUint8(t+72),i.chunkNumber=e.getUint8(t+76),0!==e.getUint8(t+77)&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(e){return e.map(e=>e.chunk.getString()).join("")}normalizeInput(e){return"string"==typeof e?e:e.getString&&e.getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={"rdf:li":1,"rdf:Seq":1,"rdf:Bag":1,"rdf:Alt":1};return e.replace(Be,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=ve.findAll(e,"rdf","Description");0===t.length&&t.push(new ve("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Ae(t.ns,s),xe(t,i);return function(e){let t;for(let i of Object.keys(e))t=e[i]=a(e[i]),void 0===t&&delete e[i];return a(e)}(s)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,s]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",s);break;case"exif":this.assignObjectToOutput(e,"exif",s);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,s)}else e.xmp=t}}r(ke,"type","xmp"),r(ke,"multiSegment",!0),w.set("xmp",ke);class Se{static findAll(e){return Ie(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Se.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Ue(s),new Se(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class ve{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var s=new RegExp("<(".concat(t,"):(").concat(i,")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"),"gm")}else s=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Ie(e,s).map(ve.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new ve(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Se.findAll(i),this.children=ve.findAll(s),this.value=0===this.children.length?Ue(s):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return void 0!==this.value&&0===this.attrs.length&&0===this.children.length}get isListContainer(){return 1===this.children.length&&this.children[0].isList}get isList(){let{ns:e,name:t}=this;return"rdf"===e&&("Seq"===t||"Bag"===t||"Alt"===t)}get isListItem(){return"rdf"===this.ns&&"li"===this.name}serialize(){if(0===this.properties.length&&void 0===this.value)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Ce(this.children.map(Oe));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)xe(t,e);return void 0!==this.value&&(e.value=this.value),a(e)}}function xe(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Oe=e=>e.serialize(),Ce=e=>1===e.length?e[0]:e,Ae=(e,t)=>t[e]?t[e]:t[e]={};function Ie(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ue(e){if(function(e){return null==e||"null"===e||"undefined"===e||""===e||""===e.trim()}(e))return;let t=Number(e);if(!Number.isNaN(t))return t;let i=e.toLowerCase();return"true"===i||"false"!==i&&e.trim()}const Be=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;e.Exifr=Q,e.Options=_,e.allFormatters=j,e.chunkedProps=T,e.createDictionary=B,e.disableAllOptions=q,e.extendDictionary=function(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])},e.fetchUrlAsArrayBuffer=O,e.fileParsers=b,e.fileReaders=k,e.gps=async function(e){let t=new Q(Y);await t.read(e);let i=await t.parse();if(i&&i.gps){let{latitude:e,longitude:t}=i.gps;return{latitude:e,longitude:t}}},e.gpsOnlyOptions=Y,e.inheritables=E,e.orientation=async function(e){let t=new Q(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]},e.orientationOnlyOptions=Z,e.otherSegments=D,e.parse=async function(e,t){let i=new Q(t);return await i.read(e),i.parse()},e.readBlobAsArrayBuffer=C,e.segmentParsers=w,e.segments=z,e.segmentsAndBlocks=V,e.tagKeys=P,e.tagRevivers=L,e.tagValues=F,e.thumbnail=async function(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new Q(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n},e.thumbnailUrl=async function(...e){let t=await this.thumbnail(...e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}},e.tiffBlocks=N,e.tiffExtractables=M,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

var t="undefined"!=typeof Buffer,e="undefined"!=typeof navigator,i=e&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function r(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.keys(t).length)}function a(t){let e=new Error(t);return delete e.stack,e}function h(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let f=s?global.BigInt:window.BigInt;const o=new TextDecoder("utf-8");class l{static from(t,e){return t instanceof this&&t.le===e?t:new l(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof l){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw a("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw a("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=l){if(t instanceof DataView||t instanceof l?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw a("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new l(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return s=i,o.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof f)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),f(e)<<f(32)|f(i);throw a("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function u(t,e){throw a("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class d extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||u(this.kind,t),e&&(t in e||function(t,e){throw a("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||u(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}function c(t,e,i=[],s=[]){for(let s of i)void 0===t[s]&&(t[s]=e.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(t,i)){let s=Object.getOwnPropertyDescriptor(e.prototype,i);Object.defineProperty(t,i,s)}}}var p=new d("file parser"),g=new d("segment parser"),y=new d("file reader");function w(t,i){if((n=t).startsWith("data:")||n.length>1e4)return b(t,i,"base64");if(e)return k(t,i,"url",m);if(s)return b(t,i,"fs");throw a("Invalid input argument");var n}async function k(t,e,i,s){if(y.has(i))return b(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw a("Parser ".concat(i," is not loaded"))}async function b(t,e,i){let s=new(y.get(i))(t,e);return await s.read(),s}async function m(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}c(p,d,["keyList"]),c(g,d,["keyList"]),c(y,d,["keyList"]);const S=Symbol("keys"),O=Symbol("values");class U extends Map{get tagKeys(){return this[S]||(this[S]=Array.from(this.keys())),this[S]}get tagValues(){return this[O]||(this[O]=Array.from(this.values())),this[O]}}function A(t,e,i){let s=new U(i);if(c(s,U,void 0,["tagKeys","tagValues"]),Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function x(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])}const C=new Map,V=new Map,B=new Map,I=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],T=["tiff",...L],z=["ifd0","ifd1","exif","gps","interop"],F=[...T,...z],D=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...E,"mergeOutput","sanitize"];class N{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends N{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=t,this.enabled=e,this.applyInheritables(s),this.canBeFiltered=z.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw a("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(t){let e,i;for(e of E)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var _={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},M=new Map;class W extends N{static useCached(t){let e=M.get(t);return void 0!==e?e:(e=new this(t),M.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw a("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=e?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of I)this[t]=_[t];for(t of j)this[t]=_[t];for(t of D)this[t]=_[t];for(t of F)this[t]=new P(t,_[t],void 0,this)}setupFromTrue(){let t;for(t of I)this[t]=_[t];for(t of j)this[t]=_[t];for(t of D)this[t]=!0;for(t of F)this[t]=new P(t,!0,void 0,this)}setupFromArray(t){let e;for(e of I)this[e]=_[e];for(e of j)this[e]=_[e];for(e of D)this[e]=_[e];for(e of F)this[e]=new P(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,z)}setupFromObject(t){let e;for(e of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,t),I))this[e]=H(t[e],_[e]);for(e of j)this[e]=H(t[e],_[e]);for(e of D)this[e]=H(t[e],_[e]);for(e of T)this[e]=new P(e,_[e],t[e],this);for(e of z)this[e]=new P(e,_[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,z,F),!0===t.tiff?this.batchEnableWithBool(z,!0):!1===t.tiff?this.batchEnableWithUserValue(z,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,z):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,z)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)K(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)K(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=z.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of z)this[t].finalizeFilters()}get onlyTiff(){return!L.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of T)this[t].enabled&&!g.has(t)&&u("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=C.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function H(t,e){return void 0!==t?t:void 0!==e?e:void 0}function K(t,e){for(let i of e)t.add(i)}n(W,"default",_);const G={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},J=Object.assign({},G,{firstChunkSize:4e4,gps:[1,2,3,4]}),X=Object.assign({},G,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(t){n(this,"parsers",{}),this.options=W.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=p.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=p.get("jpeg");else{if(!function(t){let e=t.getUint32(0),i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw a("Unknown file format");this.file.isHeic=!0,t=p.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,s){if("string"==typeof t)return w(t,s);if(e&&!i&&t instanceof HTMLImageElement)return w(t.src,s);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new l(t);if(e&&t instanceof Blob)return k(t,s,"blob",v);throw a("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},{mergeOutput:e}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let n;if(this.options.silentErrors){try{n=await s.parse()}catch(t){i.push(t)}s.errors.length&&i.push(...s.errors)}else n=await s.parse();(e||s.constructor.mergeOutput)&&"string"!=typeof n?Object.assign(t,n):void 0!==n&&(t[s.constructor.type]=n)});var n;return await Promise.all(s),this.options.silentErrors&&i.length>0&&(t.errors=i),t=r(n=t)?void 0:n,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=g.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function Q(t,e){let i=new q(e);return await i.read(t),i.parse()}async function Y(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n}async function Z(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function $(t){let e=new q(J);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}}async function tt(t){let e=new q(X);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}class et extends l{constructor(...t){super(...t),n(this,"ranges",new it),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}}class it{constructor(t){n(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>st(t,e.offset,s)||st(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function st(t,e,i){return t<=e&&e<=i}class nt extends et{constructor(t,e){super(0),n(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}y.set("blob",class extends nt{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class rt{static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,start:n,size:r,end:n+r}}static parse(t,e,i){return"object"==typeof e&&(i=e,e=void 0),new this(new l(t,e),W.useCached(i)).parse()}constructor(t,e={},i){n(this,"errors",[]),n(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=t,this.options=e,this.file=i,this.type=this.constructor.type,this.segOptions=e[this.type],this.canTranslate=this.segOptions.translate,this.raw=new Map}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=B.get(e),s=V.get(e),n=C.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||t}}n(rt,"headerLength",4),n(rt,"type",void 0),n(rt,"mergeOutput",!1),n(rt,"multiSegment",!1),n(rt,"canHandle",()=>!1);function at(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function ht(t){return t>=224&&t<=239}function ft(t,e){for(let[i,s]of g)if(s.canHandle(t,e))return i}function ot(...t){let e=t[0].constructor,i=0;for(let e of t)i+=e.length;let s=new e(i),n=0;for(let e of t)s.set(e,n),n+=e.length;return s}p.set("jpeg",class extends class{constructor(t,e,i){n(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw a("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw a("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(g.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(g.keyList())):(t=void 0===t?g.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&g.has(t)),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){if(g.get(t).multiSegment){s=!0,await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),ht(i)){if(s=f.getUint16(t+2),n=ft(f,t),n&&l.has(n)&&(r=g.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(a.multiSegment&&h.multiSegment?a.chunkNumber<a.chunkCount?this.unfinishedMultiSegment=!0:(this.unfinishedMultiSegment=!1,u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=rt.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(at(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}async createParsers(){let t;if(this.hasMultiSegments){t=[];let e=[];for(let i of this.appSegments)if(i.multiSegment){if(e.includes(i.type))break;e.push(i.type);let s=ot(...this.appSegments.filter(t=>t.type===i.type).sort((t,e)=>t.chunkNumber-e.chunkNumber).map(t=>t.chunk.toUint8()));t.push({type:i.type,chunk:new l(s)})}else t.push(i)}else t=this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(g.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}get hasMultiSegments(){return this.appSegments.some(t=>t.multiSegment)}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const lt=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ut extends rt{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw a("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw a("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=lt[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw a("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw a("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(h=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(h=this.chunk.getString(t,n)).trim())?void 0:h;var h;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw a("Invalid tiff type ".concat(t))}}}class dt extends ut{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw a("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw a("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,h(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=l.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,h(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",ct(...t.get(2),t.get(1))),t.set("longitude",ct(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,s={};for(e of z)if(t=this[e],!r(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}}function ct(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(dt,"type","tiff"),n(dt,"mergeOutput",!0),n(dt,"headerLength",10),g.set("tiff",dt);export{q as Exifr,W as Options,j as allFormatters,I as chunkedProps,A as createDictionary,G as disableAllOptions,x as extendDictionary,m as fetchUrlAsArrayBuffer,p as fileParsers,y as fileReaders,$ as gps,J as gpsOnlyOptions,E as inheritables,tt as orientation,X as orientationOnlyOptions,L as otherSegments,Q as parse,v as readBlobAsArrayBuffer,g as segmentParsers,T as segments,F as segmentsAndBlocks,C as tagKeys,B as tagRevivers,V as tagValues,Y as thumbnail,Z as thumbnailUrl,z as tiffBlocks,D as tiffExtractables};
var t="undefined"!=typeof Buffer,e="undefined"!=typeof navigator,i=e&&"undefined"==typeof HTMLImageElement,s=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function n(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const r=t=>void 0!==t;function a(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(r).length)}function h(t){let e=new Error(t);return delete e.stack,e}function f(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let o=s?global.BigInt:self.BigInt;const l=new TextDecoder("utf-8");class u{static from(t,e){return t instanceof this&&t.le===e?t:new u(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof u){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw h("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw h("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=u){if(t instanceof DataView||t instanceof u?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw h("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new u(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return s=i,l.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(e)<<o(32)|o(i);throw h("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function d(t,e){throw h("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||d(this.kind,t),e&&(t in e||function(t,e){throw h("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||d(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var p=new c("file parser"),g=new c("segment parser"),y=new c("file reader");function w(t,i){if((n=t).startsWith("data:")||n.length>1e4)return b(t,i,"base64");if(e)return k(t,i,"url",m);if(s)return b(t,i,"fs");throw h("Invalid input argument");var n}async function k(t,e,i,s){if(y.has(i))return b(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw h("Parser ".concat(i," is not loaded"))}async function b(t,e,i){let s=new(y.get(i))(t,e);return await s.read(),s}async function m(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}const O=Symbol("keys"),S=Symbol("values");class U extends Map{get tagKeys(){return this[O]||(this[O]=Array.from(this.keys())),this[O]}get tagValues(){return this[S]||(this[S]=Array.from(this.values())),this[S]}}function A(t,e,i){let s=new U(i);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function x(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])}const C=new Map,V=new Map,B=new Map,I=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],T=["jfif","xmp","icc","iptc"],L=["tiff",...T],z=["ifd0","ifd1","exif","gps","interop"],F=[...L,...z],j=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],D=[...E,"sanitize","mergeOutput"];class M{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class N extends M{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),n(this,"enabled",!1),n(this,"skip",new Set),n(this,"pick",new Set),n(this,"deps",new Set),n(this,"translateKeys",!1),n(this,"translateValues",!1),n(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=z.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw h("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of E)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var _={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},P=new Map;class W extends M{static useCached(t){let e=P.get(t);return void 0!==e?e:(e=new this(t),P.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw h("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=e?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of I)this[t]=_[t];for(t of D)this[t]=_[t];for(t of j)this[t]=_[t];for(t of F)this[t]=new N(t,_[t],void 0,this)}setupFromTrue(){let t;for(t of I)this[t]=_[t];for(t of D)this[t]=_[t];for(t of j)this[t]=!0;for(t of F)this[t]=new N(t,!0,void 0,this)}setupFromArray(t){let e;for(e of I)this[e]=_[e];for(e of D)this[e]=_[e];for(e of j)this[e]=_[e];for(e of F)this[e]=new N(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,z)}setupFromObject(t){let e;for(e of(z.ifd0=z.ifd0||z.image,z.ifd1=z.ifd1||z.thumbnail,Object.assign(this,t),I))this[e]=H(t[e],_[e]);for(e of D)this[e]=H(t[e],_[e]);for(e of j)this[e]=H(t[e],_[e]);for(e of L)this[e]=new N(e,_[e],t[e],this);for(e of z)this[e]=new N(e,_[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,z,F),!0===t.tiff?this.batchEnableWithBool(z,!0):!1===t.tiff?this.batchEnableWithUserValue(z,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,z):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,z)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)K(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)K(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=z.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of z)this[t].finalizeFilters()}get onlyTiff(){return!T.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of L)this[t].enabled&&!g.has(t)&&d("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=C.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function H(t,e){return void 0!==t?t:void 0!==e?e:void 0}function K(t,e){for(let i of e)t.add(i)}n(W,"default",_);const G={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},J=Object.assign({},G,{firstChunkSize:4e4,gps:[1,2,3,4]}),X=Object.assign({},G,{firstChunkSize:4e4,ifd0:[274]});class q{constructor(t){n(this,"parsers",{}),this.options=W.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=p.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=p.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw h("Unknown file format");this.file.isHeic=!0,t=p.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,s){if("string"==typeof t)return w(t,s);if(e&&!i&&t instanceof HTMLImageElement)return w(t.src,s);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new u(t);if(e&&t instanceof Blob)return k(t,s,"blob",v);throw h("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=a(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=g.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}async function Q(t,e){let i=new q(e);return await i.read(t),i.parse()}async function Y(e,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new q(i);await s.read(e);let n=await s.extractThumbnail();return n&&t?Buffer.from(n):n}async function Z(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function $(t){let e=new q(J);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}}async function tt(t){let e=new q(X);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}class et extends u{constructor(...t){super(...t),n(this,"ranges",new it),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(e){let i;i=t?Buffer.allocUnsafe(e):new Uint8Array(e);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}}class it{constructor(t){n(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>st(t,e.offset,s)||st(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function st(t,e,i){return t<=e&&e<=i}class nt extends et{constructor(t,e){super(0),n(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}y.set("blob",class extends nt{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class rt{static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new W({[this.type]:e})).parse()}normalizeInput(t){return t instanceof u?t:new u(t)}constructor(t,e={},i){n(this,"errors",[]),n(this,"raw",new Map),n(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=B.get(e),s=V.get(e),n=C.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||t}assignToOutput(t,e){this.assignObjectToOutput(t,this.constructor.type,e)}assignObjectToOutput(t,e,i){if(this.globalOptions.mergeOutput)return Object.assign(t,i);t[e]?Object.assign(t[e],i):t[e]=i}}n(rt,"headerLength",4),n(rt,"type",void 0),n(rt,"multiSegment",!1),n(rt,"canHandle",()=>!1);function at(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function ht(t){return t>=224&&t<=239}function ft(t,e){for(let[i,s]of g)if(s.canHandle(t,e))return i}p.set("jpeg",class extends class{constructor(t,e,i){n(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw h("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw h("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(g.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),n(this,"appSegments",[]),n(this,"jpegSegments",[]),n(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(g.keyList())):(t=void 0===t?g.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&g.has(t)),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){let e=g.get(t),i=this.options[t];if(e.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),ht(i)){if(s=f.getUint16(t+2),n=ft(f,t),n&&l.has(n)&&(r=g.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=rt.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(at(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=g.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(g.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const ot=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class lt extends rt{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw h("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw h("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=ot[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw h("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw h("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw h("Invalid tiff type ".concat(t))}}}class ut extends lt{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw h("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw h("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=u.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",dt(...t.get(2),t.get(1))),t.set("longitude",dt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,s={};for(e of z)if(t=this[e],!a(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function dt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}n(ut,"type","tiff"),n(ut,"headerLength",10),g.set("tiff",ut);export{q as Exifr,W as Options,D as allFormatters,I as chunkedProps,A as createDictionary,G as disableAllOptions,x as extendDictionary,m as fetchUrlAsArrayBuffer,p as fileParsers,y as fileReaders,$ as gps,J as gpsOnlyOptions,E as inheritables,tt as orientation,X as orientationOnlyOptions,T as otherSegments,Q as parse,v as readBlobAsArrayBuffer,g as segmentParsers,L as segments,F as segmentsAndBlocks,C as tagKeys,B as tagRevivers,V as tagValues,Y as thumbnail,Z as thumbnailUrl,z as tiffBlocks,j as tiffExtractables};

@@ -1,1 +0,1 @@

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,r,n,i,a,s){try{var u=e[a](s),o=u.value}catch(e){return void r(e)}u.done?t(o):Promise.resolve(o).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var s=e.apply(t,n);function u(e){r(s,i,a,u,o,"next",e)}function o(e){r(s,i,a,u,o,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&c(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function c(e,t){return(c=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function l(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function h(e,t,r){return(h=l()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&c(i,r.prototype),i}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return h(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var b="undefined"!=typeof Buffer,m="undefined"!=typeof navigator,w=m&&"undefined"==typeof HTMLImageElement,x=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function S(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.keys(e).length)}function O(e){var t=new Error(e);return delete t.stack,t}function R(e){var t=function(e){var t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}var A=x?global.BigInt:window.BigInt,U=new TextDecoder("utf-8");function C(e){return U.decode(e)}var B=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;if(i(this,e),"boolean"==typeof a&&(this.le=a),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){var s=new DataView(t,r,n);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof e){var u=t,o=u.byteOffset,f=u.byteLength;if(void 0===n&&(n=f-r),(r+=o)+n>o+f)throw O("Creating view outside of available memory in ArrayBuffer");var c=new DataView(t.buffer,r,n);this._swapDataView(c)}else{if("number"!=typeof t)throw O("Invalid input argument for BufferView: "+t);var l=new DataView(new ArrayBuffer(t));this._swapDataView(l)}}return s(e,null,[{key:"from",value:function(t,r){return t instanceof this&&t.le===r?t:new e(t,void 0,void 0,r)}}]),s(e,[{key:"_swapArrayBuffer",value:function(e){this._swapDataView(new DataView(e))}},{key:"_swapBuffer",value:function(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}},{key:"_swapDataView",value:function(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}},{key:"_lengthToEnd",value:function(e){return this.byteLength-e}},{key:"set",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(t instanceof DataView||t instanceof e?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw O("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,r),new n(this,r,t.byteLength)}},{key:"subarray",value:function(t,r){return new e(this,t,r=r||this._lengthToEnd(t))}},{key:"toUint8",value:function(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}},{key:"getUint8Array",value:function(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}},{key:"getString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=this.getUint8Array(e,t);return C(r)}},{key:"getUnicodeString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=[],n=0;n<t&&e+n<this.byteLength;n+=2)r.push(this.getUint16(e+n));return r.map((function(e){return String.fromCharCode(e)})).join("")}},{key:"getInt8",value:function(e){return this.dataView.getInt8(e)}},{key:"getUint8",value:function(e){return this.dataView.getUint8(e)}},{key:"getInt16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt16(e,t)}},{key:"getInt32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt32(e,t)}},{key:"getUint16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint16(e,t)}},{key:"getUint32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint32(e,t)}},{key:"getFloat32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getDouble",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getUint64",value:function(e){var r=this.getUint32(e),n=this.getUint32(e+4);if(r<1048575)return r<<32|n;if(void 0!==t(A))return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),A(r)<<A(32)|A(n);throw O("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,r){switch(t){case 1:return this.getUint8(e,r);case 2:return this.getUint16(e,r);case 4:return this.getUint32(e,r);case 8:return this.getUint64(e,r)}}},{key:"getUint",value:function(e,t,r){switch(t){case 8:return this.getUint8(e,r);case 16:return this.getUint16(e,r);case 32:return this.getUint32(e,r);case 64:return this.getUint64(e,r)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function V(e,t){throw O("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var I=function(e){function t(e){var r;return i(this,t),(r=y(this,f(t).call(this))).kind=e,r}return o(t,e),s(t,[{key:"get",value:function(e,r){return this.has(e)||V(this.kind,e),r&&(e in r||function(e,t){throw O("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),r[e].enabled||V(this.kind,e)),v(f(t.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return Array.from(this.keys())}}]),t}(p(Map));function L(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=!0,a=!1,s=void 0;try{for(var u,o=r[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;void 0===e[f]&&(e[f]=t.prototype[f])}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var c=!0,l=!1,h=void 0;try{for(var p,d=n[Symbol.iterator]();!(c=(p=d.next()).done);c=!0){var y=p.value,v=Object.getOwnPropertyDescriptor(e,y);if(void 0===v){var g=Object.getOwnPropertyDescriptor(t.prototype,y);Object.defineProperty(e,y,g)}}}catch(e){l=!0,h=e}finally{try{c||null==d.return||d.return()}finally{if(l)throw h}}}var T=new I("file parser"),j=new I("segment parser"),F=new I("file reader");function z(e,t){if("string"==typeof e)return P(e,t);if(m&&!w&&e instanceof HTMLImageElement)return P(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new B(e);if(m&&e instanceof Blob)return E(e,t,"blob",G);throw O("Invalid input argument")}function P(e,t){if((r=e).startsWith("data:")||r.length>1e4)return _(e,t,"base64");if(m)return E(e,t,"url",K);if(x)return _(e,t,"fs");throw O("Invalid input argument");var r}function E(e,t,r,n){return D.apply(this,arguments)}function D(){return(D=n(regeneratorRuntime.mark((function e(t,r,n,i){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!F.has(n)){e.next=4;break}return e.abrupt("return",_(t,r,n));case 4:if(!i){e.next=8;break}return e.abrupt("return",N(t,i));case 8:throw O("Parser ".concat(n," is not loaded"));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function _(e,t,r){return M.apply(this,arguments)}function M(){return(M=n(regeneratorRuntime.mark((function e(t,r,n){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=F.get(n),a=new i(t,r),e.next=4,a.read();case 4:return e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function N(e,t){return W.apply(this,arguments)}function W(){return(W=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r(t);case 2:return n=e.sent,e.abrupt("return",new DataView(n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function K(e){return H.apply(this,arguments)}function H(){return(H=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch(t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function G(e){return J.apply(this,arguments)}function J(){return(J=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=new FileReader;n.onloadend=function(){return e(n.result||new ArrayBuffer)},n.onerror=r,n.readAsArrayBuffer(t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}L(T,I,["keyList"]),L(j,I,["keyList"]),L(F,I,["keyList"]);var X=Symbol("keys"),q=Symbol("values"),Q=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"tagKeys",get:function(){return this[X]||(this[X]=Array.from(this.keys())),this[X]}},{key:"tagValues",get:function(){return this[q]||(this[q]=Array.from(this.values())),this[q]}}]),t}(p(Map));var Y=new Map,Z=new Map,$=new Map,ee=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],te=["jfif","xmp","icc","iptc"],re=["tiff"].concat(te),ne=["ifd0","ifd1","exif","gps","interop"],ie=[].concat(k(re),ne),ae=["makerNote","userComment"],se=["translateKeys","translateValues","reviveValues","multiSegment"],ue=[].concat(se,["mergeOutput","sanitize"]),oe=function(){function e(){i(this,e)}return s(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),fe=function(e){function r(e,n,a,s){var o;if(i(this,r),u(d(o=y(this,f(r).call(this))),"enabled",!1),u(d(o),"skip",new Set),u(d(o),"pick",new Set),u(d(o),"deps",new Set),u(d(o),"translateKeys",!1),u(d(o),"translateValues",!1),u(d(o),"reviveValues",!1),o.key=e,o.enabled=n,o.applyInheritables(s),o.canBeFiltered=ne.includes(e),o.canBeFiltered&&(o.dict=Y.get(e)),void 0!==a)if(Array.isArray(a))o.enabled=!0,o.canBeFiltered&&a.length>0&&o.translateTagSet(a,o.pick);else if("object"===t(a)){if(o.enabled=!0,o.canBeFiltered){var c=a.pick,l=a.skip;c&&c.length>0&&o.translateTagSet(c,o.pick),l&&l.length>0&&o.translateTagSet(l,o.skip)}o.applyInheritables(a)}else{if(!0!==a&&!1!==a)throw O("Invalid options argument: ".concat(a));o.enabled=a}return o}return o(r,e),s(r,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),s(r,[{key:"applyInheritables",value:function(e){var t,r,n=!0,i=!1,a=void 0;try{for(var s,u=se[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)void 0!==(r=e[t=s.value])&&(this[t]=r)}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}}},{key:"translateTagSet",value:function(e,t){var r,n,i=this.dict,a=i.tagKeys,s=i.tagValues,u=!0,o=!1,f=void 0;try{for(var c,l=e[Symbol.iterator]();!(u=(c=l.next()).done);u=!0)"string"==typeof(r=c.value)?(-1===(n=s.indexOf(r))&&(n=a.indexOf(Number(r))),-1!==n&&t.add(Number(a[n]))):t.add(r)}catch(e){o=!0,f=e}finally{try{u||null==l.return||l.return()}finally{if(o)throw f}}}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,ye(this.pick,this.deps)):this.enabled&&this.pick.size>0&&ye(this.pick,this.deps)}}]),r}(oe),ce={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},le=new Map,he=function(e){function r(e){var n;if(i(this,r),n=y(this,f(r).call(this)),!0===e)n.setupFromTrue();else if(void 0===e)n.setupFromUndefined();else if(Array.isArray(e))n.setupFromArray(e);else{if("object"!==t(e))throw O("Invalid options argument ".concat(e));n.setupFromObject(e)}return void 0===n.firstChunkSize&&(n.firstChunkSize=m?n.firstChunkSizeBrowser:n.firstChunkSizeNode),n.mergeOutput&&(n.ifd1.enabled=!1),n.filterNestedSegmentTags(),n.traverseTiffDependencyTree(),n.checkLoadedPlugins(),n}return o(r,e),s(r,null,[{key:"useCached",value:function(e){var t=le.get(e);return void 0!==t?t:(t=new this(e),le.set(e,t),t)}}]),s(r,[{key:"setupFromUndefined",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=ee[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,c=ue[Symbol.iterator]();!(s=(f=c.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==c.return||c.return()}finally{if(u)throw o}}var l=!0,h=!1,p=void 0;try{for(var d,y=ae[Symbol.iterator]();!(l=(d=y.next()).done);l=!0)this[e=d.value]=ce[e]}catch(e){h=!0,p=e}finally{try{l||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ie[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new fe(e,ce[e],void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromTrue",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=ee[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,c=ue[Symbol.iterator]();!(s=(f=c.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==c.return||c.return()}finally{if(u)throw o}}var l=!0,h=!1,p=void 0;try{for(var d,y=ae[Symbol.iterator]();!(l=(d=y.next()).done);l=!0)this[e=d.value]=!0}catch(e){h=!0,p=e}finally{try{l||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ie[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new fe(e,!0,void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromArray",value:function(e){var t,r=!0,n=!1,i=void 0;try{for(var a,s=ee[Symbol.iterator]();!(r=(a=s.next()).done);r=!0)this[t=a.value]=ce[t]}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}var u=!0,o=!1,f=void 0;try{for(var c,l=ue[Symbol.iterator]();!(u=(c=l.next()).done);u=!0)this[t=c.value]=ce[t]}catch(e){o=!0,f=e}finally{try{u||null==l.return||l.return()}finally{if(o)throw f}}var h=!0,p=!1,d=void 0;try{for(var y,v=ae[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)this[t=y.value]=ce[t]}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}var g=!0,k=!1,b=void 0;try{for(var m,w=ie[Symbol.iterator]();!(g=(m=w.next()).done);g=!0)this[t=m.value]=new fe(t,!1,void 0,this)}catch(e){k=!0,b=e}finally{try{g||null==w.return||w.return()}finally{if(k)throw b}}this.setupGlobalFilters(e,void 0,ne)}},{key:"setupFromObject",value:function(e){var r;ne.ifd0=ne.ifd0||ne.image,ne.ifd1=ne.ifd1||ne.thumbnail,Object.assign(this,e);var n=!0,i=!1,a=void 0;try{for(var s,u=ee[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)this[r=s.value]=de(e[r],ce[r])}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}var o=!0,f=!1,c=void 0;try{for(var l,h=ue[Symbol.iterator]();!(o=(l=h.next()).done);o=!0)this[r=l.value]=de(e[r],ce[r])}catch(e){f=!0,c=e}finally{try{o||null==h.return||h.return()}finally{if(f)throw c}}var p=!0,d=!1,y=void 0;try{for(var v,g=ae[Symbol.iterator]();!(p=(v=g.next()).done);p=!0)this[r=v.value]=de(e[r],ce[r])}catch(e){d=!0,y=e}finally{try{p||null==g.return||g.return()}finally{if(d)throw y}}var k=!0,b=!1,m=void 0;try{for(var w,x=re[Symbol.iterator]();!(k=(w=x.next()).done);k=!0)this[r=w.value]=new fe(r,ce[r],e[r],this)}catch(e){b=!0,m=e}finally{try{k||null==x.return||x.return()}finally{if(b)throw m}}var S=!0,O=!1,R=void 0;try{for(var A,U=ne[Symbol.iterator]();!(S=(A=U.next()).done);S=!0)this[r=A.value]=new fe(r,ce[r],e[r],this.tiff)}catch(e){O=!0,R=e}finally{try{S||null==U.return||U.return()}finally{if(O)throw R}}this.setupGlobalFilters(e.pick,e.skip,ne,ie),!0===e.tiff?this.batchEnableWithBool(ne,!0):!1===e.tiff?this.batchEnableWithUserValue(ne,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,ne):"object"===t(e.tiff)&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,ne)}},{key:"batchEnableWithBool",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){this[a.value].enabled=t}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"batchEnableWithUserValue",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value,o=t[u];this[u].enabled=!1!==o&&void 0!==o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"setupGlobalFilters",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;if(e&&e.length){var i=!0,a=!1,s=void 0;try{for(var u,o=n[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;this[f].enabled=!1}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var c=pe(e,r),l=!0,h=!1,p=void 0;try{for(var d,y=c[Symbol.iterator]();!(l=(d=y.next()).done);l=!0){var v=g(d.value,2),k=v[0],b=v[1];ye(this[k].pick,b),this[k].enabled=!0}}catch(e){h=!0,p=e}finally{try{l||null==y.return||y.return()}finally{if(h)throw p}}}else if(t&&t.length){var m=pe(t,r),w=!0,x=!1,S=void 0;try{for(var O,R=m[Symbol.iterator]();!(w=(O=R.next()).done);w=!0){var A=g(O.value,2),U=A[0],C=A[1];ye(this[U].skip,C)}}catch(e){x=!0,S=e}finally{try{w||null==R.return||R.return()}finally{if(x)throw S}}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,r=this.xmp,n=this.iptc,i=this.icc;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),r.enabled||e.skip.add(700),n.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,r=this.exif,n=this.gps;this.interop.needed&&(r.deps.add(40965),t.deps.add(40965)),r.needed&&t.deps.add(34665),n.needed&&t.deps.add(34853),this.tiff.enabled=ne.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=!0,a=!1,s=void 0;try{for(var u,o=ne[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){this[u.value].finalizeFilters()}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}},{key:"checkLoadedPlugins",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=re[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=n.value;this[a].enabled&&!j.has(a)&&V("segment parser",a)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"onlyTiff",get:function(){var e=this;return!te.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),r}(oe);function pe(e,t){var r,n,i,a,s=[],u=!0,o=!1,f=void 0;try{for(var c,l=t[Symbol.iterator]();!(u=(c=l.next()).done);u=!0){i=c.value,r=Y.get(i),n=[];var h=!0,p=!1,d=void 0;try{for(var y,v=r[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)a=y.value,(e.includes(a[0])||e.includes(a[1]))&&n.push(a[0])}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}n.length&&s.push([i,n])}}catch(e){o=!0,f=e}finally{try{u||null==l.return||l.return()}finally{if(o)throw f}}return s}function de(e,t){return void 0!==e?e:void 0!==t?t:void 0}function ye(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value;e.add(u)}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}u(he,"default",ce);var ve={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},ge=Object.assign({},ve,{firstChunkSize:4e4,gps:[1,2,3,4]}),ke=Object.assign({},ve,{firstChunkSize:4e4,ifd0:[274]});var be=function(){function e(t){i(this,e),u(this,"parsers",{}),this.options=he.useCached(t)}var t,r;return s(e,[{key:"setup",value:function(){if(!this.fileParser){var e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=T.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=T.get("jpeg");else{if(!function(e){for(var t=e.getUint32(0),r=16,n=[];r<t;)n.push(e.getString(r,4)),r+=4;return n.includes("heic")}(this.file))throw O("Unknown file format");this.file.isHeic=!0,e=T.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:(r=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,z(t,this.options);case 2:this.file=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){var t,r,i,a,s=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setup(),e.next=3,this.fileParser.parse();case 3:return t={},r=this.options.mergeOutput,i=[],a=Object.values(this.parsers).map(function(){var e=n(regeneratorRuntime.mark((function e(n){var a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!s.options.silentErrors){e.next=13;break}return e.prev=1,e.next=4,n.parse();case 4:a=e.sent,e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),i.push(e.t0);case 10:n.errors.length&&i.push.apply(i,k(n.errors)),e.next=16;break;case 13:return e.next=15,n.parse();case 15:a=e.sent;case 16:(r||n.constructor.mergeOutput)&&"string"!=typeof a?Object.assign(t,a):void 0!==a&&(t[n.constructor.type]=a);case 17:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}()),e.next=9,Promise.all(a);case 9:return this.options.silentErrors&&i.length>0&&(t.errors=i),t=S(u=t)?void 0:u,this.file.close&&this.file.close(),e.abrupt("return",t);case 13:case"end":return e.stop()}var u}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"extractThumbnail",value:(t=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.setup(),t=j.get("tiff",this.options),!this.file.isTiff){e.next=6;break}r={start:0,type:"tiff"},e.next=10;break;case 6:if(!this.file.isJpeg){e.next=10;break}return e.next=9,this.fileParser.getOrFindSegment("tiff");case 9:r=e.sent;case 10:if(void 0!==r){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,this.fileParser.ensureSegmentChunk(r);case 14:return n=e.sent,i=this.parsers.tiff=new t(n,this.options,this.file),e.next=18,i.extractThumbnail();case 18:return a=e.sent,this.file.close&&this.file.close(),e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function me(){return(me=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new be(r),e.next=3,n.read(t);case 3:return e.abrupt("return",n.parse());case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function we(){return(we=n(regeneratorRuntime.mark((function e(t){var r,n,i,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=a.length>1&&void 0!==a[1]?a[1]:{}).ifd1=!0,r.mergeOutput=!0,n=new be(r),e.next=6,n.read(t);case 6:return e.next=8,n.extractThumbnail();case 8:if(!(i=e.sent)||!b){e.next=13;break}return e.abrupt("return",Buffer.from(i));case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(){return(xe=n(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.thumbnail.apply(this,n);case 2:if(void 0===(t=e.sent)){e.next=6;break}return r=new Blob([t]),e.abrupt("return",URL.createObjectURL(r));case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}function Se(){return(Se=n(regeneratorRuntime.mark((function e(t){var r,n,i,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new be(ge),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.gps){e.next=9;break}return i=n.gps,a=i.latitude,s=i.longitude,e.abrupt("return",{latitude:a,longitude:s});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Oe(){return(Oe=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new be(ke),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.ifd0){e.next=8;break}return e.abrupt("return",n.ifd0[274]);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Re=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"ranges",new Ae),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}var r;return o(t,e),s(t,[{key:"_tryExtend",value:function(e,t,r){if(0===e&&0===this.byteLength&&r){var n=new DataView(r.buffer||r,r.byteOffset,r.byteLength);this._swapDataView(n)}else{var i=e+t;if(i>this.byteLength){var a=this._extend(i).dataView;this._swapDataView(a)}}}},{key:"_extend",value:function(e){var t;t=b?Buffer.allocUnsafe(e):new Uint8Array(e);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:r}}},{key:"subarray",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return r=r||this._lengthToEnd(e),n&&this._tryExtend(e,r),this.ranges.add(e,r),v(f(t.prototype),"subarray",this).call(this,e,r)}},{key:"set",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n&&this._tryExtend(r,e.byteLength,e);var i=v(f(t.prototype),"set",this).call(this,e,r);return this.ranges.add(r,i.byteLength),i}},{key:"ensureChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunked){e.next=2;break}return e.abrupt("return");case 2:if(!this.ranges.available(t,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,this.readChunk(t,r);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),t}(B),Ae=function(){function e(t){i(this,e),u(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}return s(e,[{key:"addMultiple",value:function(e){if(Array.isArray(e[0])){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=g(i.value,2),u=s[0],o=s[1];this.add(u,o)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}else{var f=!0,c=!1,l=void 0;try{for(var h,p=e[Symbol.iterator]();!(f=(h=p.next()).done);f=!0){var d=h.value,y=d.offset,v=d.length;this.add(y,v)}}catch(e){c=!0,l=e}finally{try{f||null==p.return||p.return()}finally{if(c)throw l}}}}},{key:"add",value:function(e,t){var r=e+t,n=this.list.filter((function(t){return Ue(e,t.offset,r)||Ue(e,t.end,r)}));if(n.length>0){e=Math.min.apply(Math,[e].concat(k(n.map((function(e){return e.offset}))))),t=(r=Math.max.apply(Math,[r].concat(k(n.map((function(e){return e.end}))))))-e;var i=n.shift();i.offset=e,i.length=t,i.end=r,this.list=this.list.filter((function(e){return!n.includes(e)}))}else this.list.push({offset:e,length:t,end:r})}},{key:"available",value:function(e,t){var r=e+t;return this.list.some((function(t){return t.offset<=e&&r<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Ue(e,t,r){return e<=t&&t<=r}var Ce=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a;return o(t,e),s(t,[{key:"readWhole",value:(a=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,G(this.input);case 3:t=e.sent,this._swapArrayBuffer(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,v(f(t.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){var n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r?t+r:void 0,i=this.input.slice(t,n),e.next=4,G(i);case 4:return a=e.sent,e.abrupt("return",this.set(a,t,!0));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),t}(function(e){function t(e,r){var n;return i(this,t),u(d(n=y(this,f(t).call(this,0))),"chunksRead",0),n.input=e,n.options=r,n}var r,a,c,l;return o(t,e),s(t,[{key:"readWhole",value:(l=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,this.readChunk(this.nextChunkOffset);case 3:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"readChunked",value:(c=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!0,e.next=3,this.readChunk(0,this.options.firstChunkSize);case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"readNextChunk",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:this.nextChunkOffset,!this.fullyRead){e.next=4;break}return this.chunksRead++,e.abrupt("return",!1);case 4:return r=this.options.chunkSize,e.next=7,this.readChunk(t,r);case 7:if(!(n=e.sent)){e.next=10;break}return e.abrupt("return",n.byteLength===r);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunksRead++,0!==(r=this.safeWrapAddress(t,r))){e.next=4;break}return e.abrupt("return",void 0);case 4:return e.abrupt("return",this._readChunk(t,r));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"safeWrapAddress",value:function(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}},{key:"read",value:function(){return this.options.chunked?this.readChunked():this.readWhole()}},{key:"close",value:function(){}},{key:"nextChunkOffset",get:function(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}},{key:"canReadNextChunk",get:function(){return this.chunksRead<this.options.chunkLimit}},{key:"fullyRead",get:function(){return void 0!==this.size&&this.nextChunkOffset===this.size}}]),t}(Re));F.set("blob",Ce);var Be=function(){function e(t,r,a){var s=this;i(this,e),u(this,"ensureSegmentChunk",function(){var e=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.start,n=t.size||65536,!s.file.chunked){e.next=18;break}if(!s.file.available(r,n)){e.next=7;break}t.chunk=s.file.subarray(r,n),e.next=16;break;case 7:return e.prev=7,e.next=10,s.file.readChunk(r,n);case 10:t.chunk=e.sent,e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(7),O("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.t0.message));case 16:e.next=27;break;case 18:if(!(s.file.byteLength>r+n)){e.next=22;break}t.chunk=s.file.subarray(r,n),e.next=27;break;case 22:if(void 0!==t.size){e.next=26;break}t.chunk=s.file.subarray(r),e.next=27;break;case 26:throw O("Segment unreachable: "+JSON.stringify(t));case 27:return e.abrupt("return",t.chunk);case 28:case"end":return e.stop()}}),e,null,[[7,13]])})));return function(t){return e.apply(this,arguments)}}()),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=r,this.parsers=a}return s(e,[{key:"createParser",value:function(e,t){var r=new(j.get(e))(t,this.options,this.file);return this.parsers[e]=r}}]),e}(),Ve=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;i(this,e),u(this,"errors",[]),u(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=t,this.options=n,this.file=a,this.type=this.constructor.type,this.segOptions=n[this.type],this.canTranslate=this.segOptions.translate,this.raw=new Map}return s(e,null,[{key:"findPosition",value:function(e,t){var r=e.getUint16(t+2)+2,n="function"==typeof this.headerLength?this.headerLength(e,t,r):this.headerLength,i=t+n,a=r-n;return{offset:t,length:r,start:i,size:a,end:i+a}}},{key:"parse",value:function(e,r,n){return"object"===t(r)&&(n=r,r=void 0),new this(new B(e,r),he.useCached(n)).parse()}}]),s(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var r=$.get(t),n=Z.get(t),i=Y.get(t),a=this.options[t],s=a.reviveValues&&r,u=a.translateValues&&n,o=a.translateKeys&&i,f={},c=!0,l=!1,h=void 0;try{for(var p,d=e[Symbol.iterator]();!(c=(p=d.next()).done);c=!0){var y=g(p.value,2),v=y[0],k=y[1];s&&r.has(v)?k=r.get(v)(k):u&&n.has(v)&&(k=this.translateValue(k,n.get(v))),o&&i.has(v)&&(v=i.get(v)||v),f[v]=k}}catch(e){l=!0,h=e}finally{try{c||null==d.return||d.return()}finally{if(l)throw h}}return f}},{key:"translateValue",value:function(e,t){return t[e]||e}},{key:"output",get:function(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}}]),e}();u(Ve,"headerLength",4),u(Ve,"type",void 0),u(Ve,"mergeOutput",!1),u(Ve,"multiSegment",!1),u(Ve,"canHandle",(function(){return!1}));function Ie(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function Le(e){return e>=224&&e<=239}function Te(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=j[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=g(a.value,2),o=u[0];if(u[1].canHandle(e,t))return o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}var je=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"appSegments",[]),u(d(r),"jpegSegments",[]),u(d(r),"unknownSegments",[]),r}var r,a,c,l;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.findAppSegments();case 2:return e.next=4,this.readSegments();case 4:this.createParsers();case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"readSegments",value:(l=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.appSegments.map(this.ensureSegmentChunk),e.next=3,Promise.all(t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=new Set(j.keyList())):(e=void 0===e?j.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&j.has(e)})),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:(c=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,c,l,h,p,d,y,v=this,g=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=g.length>0&&void 0!==g[0]?g[0]:0,r=g.length>1?g[1]:void 0,this.setupSegmentFinderArgs(r),n=this.file,i=this.findAll,a=this.wanted,s=this.remaining,i){e.next=35;break}u=!0,o=!1,f=void 0,e.prev=8,c=a[Symbol.iterator]();case 10:if(u=(l=c.next()).done){e.next=21;break}if(h=l.value,!j.get(h).multiSegment){e.next=18;break}return i=!0,e.next=17,this.file.readWhole();case 17:return e.abrupt("break",21);case 18:u=!0,e.next=10;break;case 21:e.next=27;break;case 23:e.prev=23,e.t0=e.catch(8),o=!0,f=e.t0;case 27:e.prev=27,e.prev=28,u||null==c.return||c.return();case 30:if(e.prev=30,!o){e.next=33;break}throw f;case 33:return e.finish(30);case 34:return e.finish(27);case 35:if(t=this._findAppSegments(t,n.byteLength,i,a,s),!this.options.onlyTiff){e.next=38;break}return e.abrupt("return");case 38:if(!n.chunked){e.next=57;break}p=!1;case 40:if(!(s.size>0)||p||!n.canReadNextChunk&&!this.unfinishedMultiSegment){e.next=57;break}if(d=n.nextChunkOffset,y=this.appSegments.some((function(e){return!v.file.available(e.offset||e.start,e.length||e.size)})),!(t>d)||y){e.next=49;break}return e.next=46,n.readNextChunk(t);case 46:p=!e.sent,e.next=52;break;case 49:return e.next=51,n.readNextChunk(d);case 51:p=!e.sent;case 52:if(void 0!==(t=this._findAppSegments(t,n.byteLength))){e.next=55;break}return e.abrupt("return");case 55:e.next=40;break;case 57:case"end":return e.stop()}}),e,this,[[8,23,27,35],[28,,30,34]])}))),function(){return c.apply(this,arguments)})},{key:"_findAppSegments",value:function(e,t){for(var r,n,i,a,s,u=this.file,o=this.findAll,f=this.wanted,c=this.remaining,l=this.options;e<t;e++)if(255===u.getUint8(e))if(Le(r=u.getUint8(e+1))){if(n=u.getUint16(e+2),(i=Te(u,e))&&f.has(i)&&(a=j.get(i).findPosition(u,e),s=l[i],a.type=i,this.appSegments.push(a),!o&&(a.multiSegment&&s.multiSegment?a.chunkNumber<a.chunkCount?this.unfinishedMultiSegment=!0:(this.unfinishedMultiSegment=!1,c.delete(i)):c.delete(i),0===c.size)))break;l.recordUnknownSegments&&((a=Ve.findPosition(u,e)).marker=r,this.unknownSegments.push(a)),e+=n+1}else if(Ie(r)){if(n=u.getUint16(e+2),218===r&&!1!==l.stopAfterSos)return;l.recordJpegSegments&&this.jpegSegments.push({offset:e,length:n,marker:r}),e+=n+1}return e}},{key:"createParsers",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,c,l,h,p,d,y,v,g,b,m,w=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.hasMultiSegments){e.next=32;break}t=[],r=[],n=!0,i=!1,a=void 0,e.prev=6,s=function(){var e=o.value;if(e.multiSegment){if(r.includes(e.type))return"break";r.push(e.type);var n=w.appSegments.filter((function(t){return t.type===e.type})).sort((function(e,t){return e.chunkNumber-t.chunkNumber})).map((function(e){return e.chunk.toUint8()})),i=Fe.apply(void 0,k(n));t.push({type:e.type,chunk:new B(i)})}else t.push(e)},u=this.appSegments[Symbol.iterator]();case 9:if(n=(o=u.next()).done){e.next=16;break}if("break"!==s()){e.next=13;break}return e.abrupt("break",16);case 13:n=!0,e.next=9;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(6),i=!0,a=e.t0;case 22:e.prev=22,e.prev=23,n||null==u.return||u.return();case 25:if(e.prev=25,!i){e.next=28;break}throw a;case 28:return e.finish(25);case 29:return e.finish(22);case 30:e.next=33;break;case 32:t=this.appSegments;case 33:f=!0,c=!1,l=void 0,e.prev=36,h=t[Symbol.iterator]();case 38:if(f=(p=h.next()).done){e.next=48;break}if(d=p.value,y=d.type,v=d.chunk,this.options[y].enabled){e.next=43;break}return e.abrupt("continue",45);case 43:(g=this.parsers[y])&&g.append||g||(b=j.get(y,this.options),m=new b(v,this.options,this.file),this.parsers[y]=m);case 45:f=!0,e.next=38;break;case 48:e.next=54;break;case 50:e.prev=50,e.t1=e.catch(36),c=!0,l=e.t1;case 54:e.prev=54,e.prev=55,f||null==h.return||h.return();case 57:if(e.prev=57,!c){e.next=60;break}throw l;case 60:return e.finish(57);case 61:return e.finish(54);case 62:case"end":return e.stop()}}),e,this,[[6,18,22,30],[23,,25,29],[36,50,54,62],[55,,57,61]])}))),function(){return a.apply(this,arguments)})},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:(r=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(r=this.getSegment(t))){e.next=5;break}return e.next=4,this.findAppSegments(0,[t]);case 4:r=this.getSegment(t);case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"hasMultiSegments",get:function(){return this.appSegments.some((function(e){return e.multiSegment}))}}]),t}(Be);function Fe(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];for(var n=t[0].constructor,i=0,a=0,s=t;a<s.length;a++){var u=s[a];i+=u.length}for(var o=new n(i),f=0,c=0,l=t;c<l.length;c++){var h=l[c];o.set(h,f),f+=h.length}return o}T.set("jpeg",je);var ze=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var Pe=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a,u,c,l,h,p;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.parseHeader(),!this.options.ifd0.enabled){e.next=4;break}return e.next=4,this.parseIfd0Block();case 4:if(!this.options.exif.enabled){e.next=7;break}return e.next=7,this.parseExifBlock().catch(this.handleError);case 7:if(!this.options.gps.enabled){e.next=10;break}return e.next=10,this.parseGpsBlock().catch(this.handleError);case 10:if(!this.options.interop.enabled){e.next=13;break}return e.next=13,this.parseInteropBlock().catch(this.handleError);case 13:if(!this.options.ifd1.enabled){e.next=16;break}return e.next=16,this.parseThumbnailBlock().catch(this.handleError);case 16:return e.abrupt("return",this.createOutput());case 17:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"findIfd0Offset",value:function(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}},{key:"findIfd1Offset",value:function(){if(void 0===this.ifd1Offset){this.findIfd0Offset();var e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}},{key:"parseBlock",value:function(e,t){var r=new Map;return this[t]=r,this.parseTags(e,t,r),r}},{key:"parseIfd0Block",value:(p=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.ifd0){e.next=2;break}return e.abrupt("return");case 2:if(this.findIfd0Offset(),!(this.ifd0Offset<8)){e.next=5;break}throw O("Invalid EXIF data: IFD0 offset should be less than 8");case 5:if(this.file.chunked||!(this.ifd0Offset>this.file.byteLength)){e.next=7;break}throw O("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.ifd0Offset,R(this.options));case 10:if(0!==(t=this.parseBlock(this.ifd0Offset,"ifd0")).size){e.next=13;break}return e.abrupt("return");case 13:return this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),e.abrupt("return",t);case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"ensureBlockChunk",value:(h=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.file.isTiff){e.next=3;break}return e.next=3,this.file.ensureChunk(t,r);case 3:t>this.chunk.byteLength&&(this.chunk=B.from(this.file,this.le));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"parseExifBlock",value:(l=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.exif){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.exifOffset){e.next=7;break}return e.abrupt("return");case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.exifOffset,R(this.options));case 10:return t=this.parseBlock(this.exifOffset,"exif"),this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"unpack",value:function(e,t){var r=e.get(t);r&&1===r.length&&e.set(t,r[0])}},{key:"parseGpsBlock",value:(c=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.gps){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.gpsOffset){e.next=7;break}return e.abrupt("return");case 7:return(t=this.parseBlock(this.gpsOffset,"gps"))&&t.has(2)&&t.has(4)&&(t.set("latitude",Ee.apply(void 0,k(t.get(2)).concat([t.get(1)]))),t.set("longitude",Ee.apply(void 0,k(t.get(4)).concat([t.get(3)])))),e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"parseInteropBlock",value:(u=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.interop){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset){e.next=8;break}return e.abrupt("return");case 8:return e.abrupt("return",this.parseBlock(this.interopOffset,"interop"));case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"parseThumbnailBlock",value:(a=n(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this.ifd1&&!this.ifd1Parsed){e.next=3;break}return e.abrupt("return");case 3:if(!this.options.mergeOutput||t){e.next=5;break}return e.abrupt("return");case 5:return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),e.abrupt("return",this.ifd1);case 8:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"extractThumbnail",value:(r=n(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.headerParsed||this.parseHeader(),this.ifd1Parsed){e.next=4;break}return e.next=4,this.parseThumbnailBlock(!0);case 4:if(void 0!==this.ifd1){e.next=6;break}return e.abrupt("return");case 6:return t=this.ifd1.get(513),r=this.ifd1.get(514),e.abrupt("return",this.chunk.getUint8Array(t,r));case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createOutput",value:function(){var e,t,r,n={},i=!0,a=!1,s=void 0;try{for(var u,o=ne[Symbol.iterator]();!(i=(u=o.next()).done);i=!0)if(!S(e=this[t=u.value]))if(r=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(n,r)}else n[t]=r}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}},{key:"image",get:function(){return this.ifd0}},{key:"thumbnail",get:function(){return this.ifd1}}],[{key:"canHandle",value:function(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}}]),t}(function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"parseHeader",value:function(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw O("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw O("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}},{key:"parseTags",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=this.options[t],i=n.pick,a=n.skip,s=(i=new Set(i)).size>0,u=0===a.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var c=this.chunk.getUint16(e);if(s){if(i.has(c)&&(r.set(c,this.parseTag(e,c,t)),i.delete(c),0===i.size))break}else!u&&a.has(c)||r.set(c,this.parseTag(e,c,t));e+=12}return r}},{key:"parseTag",value:function(e,t,r){var n,i=this.chunk.getUint16(e+2),a=this.chunk.getUint32(e+4),s=ze[i];if(s*a<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw O("Invalid TIFF value type. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw O("Invalid TIFF value offset. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===i)return this.chunk.getUint8Array(e,a);if(2===i)return""===(n=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(n=this.chunk.getString(e,a)).trim())?void 0:n;if(7===i)return this.chunk.getUint8Array(e,a);if(1===a)return this.parseTagValue(i,e);for(var u=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(i))(a),o=s,f=0;f<a;f++)u[f]=this.parseTagValue(i,e),e+=o;return u}},{key:"parseTagValue",value:function(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw O("Invalid tiff type ".concat(e))}}}]),t}(Ve));function Ee(e,t,r,n){var i=e+t/60+r/3600;return"S"!==n&&"W"!==n||(i*=-1),i}u(Pe,"type","tiff"),u(Pe,"mergeOutput",!0),u(Pe,"headerLength",10),j.set("tiff",Pe),e.Exifr=be,e.Options=he,e.allFormatters=ue,e.chunkedProps=ee,e.createDictionary=function(e,t,r){var n=new Q(r);if(L(n,Q,void 0,["tagKeys","tagValues"]),Array.isArray(t)){var i=!0,a=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;e.set(f,n)}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}else e.set(t,n);return n},e.disableAllOptions=ve,e.extendDictionary=function(e,t,r){var n,i=e.get(t),a=!0,s=!1,u=void 0;try{for(var o,f=r[Symbol.iterator]();!(a=(o=f.next()).done);a=!0)n=o.value,i.set(n[0],n[1])}catch(e){s=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(s)throw u}}},e.fetchUrlAsArrayBuffer=K,e.fileParsers=T,e.fileReaders=F,e.gps=function(e){return Se.apply(this,arguments)},e.gpsOnlyOptions=ge,e.inheritables=se,e.orientation=function(e){return Oe.apply(this,arguments)},e.orientationOnlyOptions=ke,e.otherSegments=te,e.parse=function(e,t){return me.apply(this,arguments)},e.readBlobAsArrayBuffer=G,e.segmentParsers=j,e.segments=re,e.segmentsAndBlocks=ie,e.tagKeys=Y,e.tagRevivers=$,e.tagValues=Z,e.thumbnail=function(e){return we.apply(this,arguments)},e.thumbnailUrl=function(){return xe.apply(this,arguments)},e.tiffBlocks=ne,e.tiffExtractables=ae,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],t):t((e=e||self).exifr={})}(this,(function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function r(e,t,r,n,i,a,s){try{var u=e[a](s),o=u.value}catch(e){return void r(e)}u.done?t(o):Promise.resolve(o).then(n,i)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(i,a){var s=e.apply(t,n);function u(e){r(s,i,a,u,o,"next",e)}function o(e){r(s,i,a,u,o,"throw",e)}u(void 0)}))}}function i(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function s(e,t,r){return t&&a(e.prototype,t),r&&a(e,r),e}function u(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function f(e){return(f=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function l(e,t){return(l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function c(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function h(e,t,r){return(h=c()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i}).apply(null,arguments)}function p(e){var t="function"==typeof Map?new Map:void 0;return(p=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return h(e,arguments,f(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)})(e)}function d(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function y(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?d(e):t}function v(e,t,r){return(v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,r){var n=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=f(e)););return e}(e,t);if(n){var i=Object.getOwnPropertyDescriptor(n,t);return i.get?i.get.call(r):i.value}})(e,t,r||e)}function g(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){if(!(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e)))return;var r=[],n=!0,i=!1,a=void 0;try{for(var s,u=e[Symbol.iterator]();!(n=(s=u.next()).done)&&(r.push(s.value),!t||r.length!==t);n=!0);}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}function k(e){return function(e){if(Array.isArray(e)){for(var t=0,r=new Array(e.length);t<e.length;t++)r[t]=e[t];return r}}(e)||function(e){if(Symbol.iterator in Object(e)||"[object Arguments]"===Object.prototype.toString.call(e))return Array.from(e)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance")}()}var b="undefined"!=typeof Buffer,m="undefined"!=typeof navigator,w=m&&"undefined"==typeof HTMLImageElement,x=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);var S=function(e){return void 0!==e};function O(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(S).length)}function R(e){var t=new Error(e);return delete t.stack,t}function A(e){var t=function(e){var t=0;return e.ifd0.enabled&&(t+=1024),e.exif.enabled&&(t+=2048),e.makerNote&&(t+=2048),e.userComment&&(t+=1024),e.gps.enabled&&(t+=512),e.interop.enabled&&(t+=100),e.ifd1.enabled&&(t+=1024),t+2048}(e);return e.jfif.enabled&&(t+=50),e.xmp.enabled&&(t+=2e4),e.iptc.enabled&&(t+=14e3),e.icc.enabled&&(t+=6e3),t}var U=x?global.BigInt:self.BigInt,C=new TextDecoder("utf-8");function B(e){return C.decode(e)}var V=function(){function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0;if(i(this,e),"boolean"==typeof a&&(this.le=a),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){var s=new DataView(t,r,n);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof e){var u=t,o=u.byteOffset,f=u.byteLength;if(void 0===n&&(n=f-r),(r+=o)+n>o+f)throw R("Creating view outside of available memory in ArrayBuffer");var l=new DataView(t.buffer,r,n);this._swapDataView(l)}else{if("number"!=typeof t)throw R("Invalid input argument for BufferView: "+t);var c=new DataView(new ArrayBuffer(t));this._swapDataView(c)}}return s(e,null,[{key:"from",value:function(t,r){return t instanceof this&&t.le===r?t:new e(t,void 0,void 0,r)}}]),s(e,[{key:"_swapArrayBuffer",value:function(e){this._swapDataView(new DataView(e))}},{key:"_swapBuffer",value:function(e){this._swapDataView(new DataView(e.buffer,e.byteOffset,e.byteLength))}},{key:"_swapDataView",value:function(e){this.dataView=e,this.buffer=e.buffer,this.byteOffset=e.byteOffset,this.byteLength=e.byteLength}},{key:"_lengthToEnd",value:function(e){return this.byteLength-e}},{key:"set",value:function(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e;if(t instanceof DataView||t instanceof e?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw R("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,r),new n(this,r,t.byteLength)}},{key:"subarray",value:function(t,r){return new e(this,t,r=r||this._lengthToEnd(t))}},{key:"toUint8",value:function(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}},{key:"getUint8Array",value:function(e,t){return new Uint8Array(this.buffer,this.byteOffset+e,t)}},{key:"getString",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=this.getUint8Array(e,t);return B(r)}},{key:"getUnicodeString",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.byteLength,r=[],n=0;n<t&&e+n<this.byteLength;n+=2)r.push(this.getUint16(e+n));return r.map((function(e){return String.fromCharCode(e)})).join("")}},{key:"getInt8",value:function(e){return this.dataView.getInt8(e)}},{key:"getUint8",value:function(e){return this.dataView.getUint8(e)}},{key:"getInt16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt16(e,t)}},{key:"getInt32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getInt32(e,t)}},{key:"getUint16",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint16(e,t)}},{key:"getUint32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getUint32(e,t)}},{key:"getFloat32",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getFloat",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat32(e,t)}},{key:"getDouble",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.le;return this.dataView.getFloat64(e,t)}},{key:"getUint64",value:function(e){var r=this.getUint32(e),n=this.getUint32(e+4);if(r<1048575)return r<<32|n;if(void 0!==t(U))return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),U(r)<<U(32)|U(n);throw R("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,r){switch(t){case 1:return this.getUint8(e,r);case 2:return this.getUint16(e,r);case 4:return this.getUint32(e,r);case 8:return this.getUint64(e,r)}}},{key:"getUint",value:function(e,t,r){switch(t){case 8:return this.getUint8(e,r);case 16:return this.getUint16(e,r);case 32:return this.getUint32(e,r);case 64:return this.getUint64(e,r)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function I(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=!0,a=!1,s=void 0;try{for(var u,o=r[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;void 0===e[f]&&(e[f]=t.prototype[f])}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var l=!0,c=!1,h=void 0;try{for(var p,d=n[Symbol.iterator]();!(l=(p=d.next()).done);l=!0){var y=p.value,v=Object.getOwnPropertyDescriptor(e,y);if(void 0===v){var g=Object.getOwnPropertyDescriptor(t.prototype,y);Object.defineProperty(e,y,g)}}}catch(e){c=!0,h=e}finally{try{l||null==d.return||d.return()}finally{if(c)throw h}}}function T(e,t){throw R("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var L=function(e){function t(e){var r;return i(this,t),(r=y(this,f(t).call(this))).kind=e,r}return o(t,e),s(t,[{key:"get",value:function(e,r){return this.has(e)||T(this.kind,e),r&&(e in r||function(e,t){throw R("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),r[e].enabled||T(this.kind,e)),v(f(t.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return Array.from(this.keys())}}]),t}(p(Map)),j=new L("file parser"),z=new L("segment parser"),F=new L("file reader");function P(e,t){if("string"==typeof e)return E(e,t);if(m&&!w&&e instanceof HTMLImageElement)return E(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new V(e);if(m&&e instanceof Blob)return D(e,t,"blob",J);throw R("Invalid input argument")}function E(e,t){if((r=e).startsWith("data:")||r.length>1e4)return M(e,t,"base64");if(m)return D(e,t,"url",H);if(x)return M(e,t,"fs");throw R("Invalid input argument");var r}function D(e,t,r,n){return _.apply(this,arguments)}function _(){return(_=n(regeneratorRuntime.mark((function e(t,r,n,i){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!F.has(n)){e.next=4;break}return e.abrupt("return",M(t,r,n));case 4:if(!i){e.next=8;break}return e.abrupt("return",W(t,i));case 8:throw R("Parser ".concat(n," is not loaded"));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function M(e,t,r){return N.apply(this,arguments)}function N(){return(N=n(regeneratorRuntime.mark((function e(t,r,n){var i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=F.get(n),a=new i(t,r),e.next=4,a.read();case 4:return e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function W(e,t){return K.apply(this,arguments)}function K(){return(K=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,r(t);case 2:return n=e.sent,e.abrupt("return",new DataView(n));case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function H(e){return G.apply(this,arguments)}function G(){return(G=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",fetch(t).then((function(e){return e.arrayBuffer()})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function J(e){return X.apply(this,arguments)}function X(){return(X=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e,r){var n=new FileReader;n.onloadend=function(){return e(n.result||new ArrayBuffer)},n.onerror=r,n.readAsArrayBuffer(t)})));case 1:case"end":return e.stop()}}),e)})))).apply(this,arguments)}I(j,L,["keyList"]),I(z,L,["keyList"]),I(F,L,["keyList"]);var q=Symbol("keys"),Q=Symbol("values"),Y=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"tagKeys",get:function(){return this[q]||(this[q]=Array.from(this.keys())),this[q]}},{key:"tagValues",get:function(){return this[Q]||(this[Q]=Array.from(this.values())),this[Q]}}]),t}(p(Map));var Z=new Map,$=new Map,ee=new Map,te=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],re=["jfif","xmp","icc","iptc"],ne=["tiff"].concat(re),ie=["ifd0","ifd1","exif","gps","interop"],ae=[].concat(k(ne),ie),se=["makerNote","userComment"],ue=["translateKeys","translateValues","reviveValues","multiSegment"],oe=[].concat(ue,["sanitize","mergeOutput"]),fe=function(){function e(){i(this,e)}return s(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),le=function(e){function r(e,n,a,s){var o;if(i(this,r),u(d(o=y(this,f(r).call(this))),"enabled",!1),u(d(o),"skip",new Set),u(d(o),"pick",new Set),u(d(o),"deps",new Set),u(d(o),"translateKeys",!1),u(d(o),"translateValues",!1),u(d(o),"reviveValues",!1),o.key=e,o.enabled=n,o.parse=o.enabled,o.applyInheritables(s),o.canBeFiltered=ie.includes(e),o.canBeFiltered&&(o.dict=Z.get(e)),void 0!==a)if(Array.isArray(a))o.parse=o.enabled=!0,o.canBeFiltered&&a.length>0&&o.translateTagSet(a,o.pick);else if("object"===t(a)){if(o.enabled=!0,o.parse=!1!==a.parse,o.canBeFiltered){var l=a.pick,c=a.skip;l&&l.length>0&&o.translateTagSet(l,o.pick),c&&c.length>0&&o.translateTagSet(c,o.skip)}o.applyInheritables(a)}else{if(!0!==a&&!1!==a)throw R("Invalid options argument: ".concat(a));o.parse=o.enabled=a}return o}return o(r,e),s(r,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),s(r,[{key:"applyInheritables",value:function(e){var t,r,n=!0,i=!1,a=void 0;try{for(var s,u=ue[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)void 0!==(r=e[t=s.value])&&(this[t]=r)}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}}},{key:"translateTagSet",value:function(e,t){var r,n,i=this.dict,a=i.tagKeys,s=i.tagValues,u=!0,o=!1,f=void 0;try{for(var l,c=e[Symbol.iterator]();!(u=(l=c.next()).done);u=!0)"string"==typeof(r=l.value)?(-1===(n=s.indexOf(r))&&(n=a.indexOf(Number(r))),-1!==n&&t.add(Number(a[n]))):t.add(r)}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,ve(this.pick,this.deps)):this.enabled&&this.pick.size>0&&ve(this.pick,this.deps)}}]),r}(fe),ce={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},he=new Map,pe=function(e){function r(e){var n;if(i(this,r),n=y(this,f(r).call(this)),!0===e)n.setupFromTrue();else if(void 0===e)n.setupFromUndefined();else if(Array.isArray(e))n.setupFromArray(e);else{if("object"!==t(e))throw R("Invalid options argument ".concat(e));n.setupFromObject(e)}return void 0===n.firstChunkSize&&(n.firstChunkSize=m?n.firstChunkSizeBrowser:n.firstChunkSizeNode),n.mergeOutput&&(n.ifd1.enabled=!1),n.filterNestedSegmentTags(),n.traverseTiffDependencyTree(),n.checkLoadedPlugins(),n}return o(r,e),s(r,null,[{key:"useCached",value:function(e){var t=he.get(e);return void 0!==t?t:(t=new this(e),he.set(e,t),t)}}]),s(r,[{key:"setupFromUndefined",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=te[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,l=oe[Symbol.iterator]();!(s=(f=l.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw o}}var c=!0,h=!1,p=void 0;try{for(var d,y=se[Symbol.iterator]();!(c=(d=y.next()).done);c=!0)this[e=d.value]=ce[e]}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ae[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new le(e,ce[e],void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromTrue",value:function(){var e,t=!0,r=!1,n=void 0;try{for(var i,a=te[Symbol.iterator]();!(t=(i=a.next()).done);t=!0)this[e=i.value]=ce[e]}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}var s=!0,u=!1,o=void 0;try{for(var f,l=oe[Symbol.iterator]();!(s=(f=l.next()).done);s=!0)this[e=f.value]=ce[e]}catch(e){u=!0,o=e}finally{try{s||null==l.return||l.return()}finally{if(u)throw o}}var c=!0,h=!1,p=void 0;try{for(var d,y=se[Symbol.iterator]();!(c=(d=y.next()).done);c=!0)this[e=d.value]=!0}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}var v=!0,g=!1,k=void 0;try{for(var b,m=ae[Symbol.iterator]();!(v=(b=m.next()).done);v=!0)this[e=b.value]=new le(e,!0,void 0,this)}catch(e){g=!0,k=e}finally{try{v||null==m.return||m.return()}finally{if(g)throw k}}}},{key:"setupFromArray",value:function(e){var t,r=!0,n=!1,i=void 0;try{for(var a,s=te[Symbol.iterator]();!(r=(a=s.next()).done);r=!0)this[t=a.value]=ce[t]}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}var u=!0,o=!1,f=void 0;try{for(var l,c=oe[Symbol.iterator]();!(u=(l=c.next()).done);u=!0)this[t=l.value]=ce[t]}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}var h=!0,p=!1,d=void 0;try{for(var y,v=se[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)this[t=y.value]=ce[t]}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}var g=!0,k=!1,b=void 0;try{for(var m,w=ae[Symbol.iterator]();!(g=(m=w.next()).done);g=!0)this[t=m.value]=new le(t,!1,void 0,this)}catch(e){k=!0,b=e}finally{try{g||null==w.return||w.return()}finally{if(k)throw b}}this.setupGlobalFilters(e,void 0,ie)}},{key:"setupFromObject",value:function(e){var r;ie.ifd0=ie.ifd0||ie.image,ie.ifd1=ie.ifd1||ie.thumbnail,Object.assign(this,e);var n=!0,i=!1,a=void 0;try{for(var s,u=te[Symbol.iterator]();!(n=(s=u.next()).done);n=!0)this[r=s.value]=ye(e[r],ce[r])}catch(e){i=!0,a=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw a}}var o=!0,f=!1,l=void 0;try{for(var c,h=oe[Symbol.iterator]();!(o=(c=h.next()).done);o=!0)this[r=c.value]=ye(e[r],ce[r])}catch(e){f=!0,l=e}finally{try{o||null==h.return||h.return()}finally{if(f)throw l}}var p=!0,d=!1,y=void 0;try{for(var v,g=se[Symbol.iterator]();!(p=(v=g.next()).done);p=!0)this[r=v.value]=ye(e[r],ce[r])}catch(e){d=!0,y=e}finally{try{p||null==g.return||g.return()}finally{if(d)throw y}}var k=!0,b=!1,m=void 0;try{for(var w,x=ne[Symbol.iterator]();!(k=(w=x.next()).done);k=!0)this[r=w.value]=new le(r,ce[r],e[r],this)}catch(e){b=!0,m=e}finally{try{k||null==x.return||x.return()}finally{if(b)throw m}}var S=!0,O=!1,R=void 0;try{for(var A,U=ie[Symbol.iterator]();!(S=(A=U.next()).done);S=!0)this[r=A.value]=new le(r,ce[r],e[r],this.tiff)}catch(e){O=!0,R=e}finally{try{S||null==U.return||U.return()}finally{if(O)throw R}}this.setupGlobalFilters(e.pick,e.skip,ie,ae),!0===e.tiff?this.batchEnableWithBool(ie,!0):!1===e.tiff?this.batchEnableWithUserValue(ie,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,ie):"object"===t(e.tiff)&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,ie)}},{key:"batchEnableWithBool",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){this[a.value].enabled=t}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"batchEnableWithUserValue",value:function(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=e[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value,o=t[u];this[u].enabled=!1!==o&&void 0!==o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}},{key:"setupGlobalFilters",value:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:r;if(e&&e.length){var i=!0,a=!1,s=void 0;try{for(var u,o=n[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;this[f].enabled=!1}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}var l=de(e,r),c=!0,h=!1,p=void 0;try{for(var d,y=l[Symbol.iterator]();!(c=(d=y.next()).done);c=!0){var v=g(d.value,2),k=v[0],b=v[1];ve(this[k].pick,b),this[k].enabled=!0}}catch(e){h=!0,p=e}finally{try{c||null==y.return||y.return()}finally{if(h)throw p}}}else if(t&&t.length){var m=de(t,r),w=!0,x=!1,S=void 0;try{for(var O,R=m[Symbol.iterator]();!(w=(O=R.next()).done);w=!0){var A=g(O.value,2),U=A[0],C=A[1];ve(this[U].skip,C)}}catch(e){x=!0,S=e}finally{try{w||null==R.return||R.return()}finally{if(x)throw S}}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,r=this.xmp,n=this.iptc,i=this.icc;this.makerNote?t.deps.add(37500):t.skip.add(37500),this.userComment?t.deps.add(37510):t.skip.add(37510),r.enabled||e.skip.add(700),n.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,r=this.exif,n=this.gps;this.interop.needed&&(r.deps.add(40965),t.deps.add(40965)),r.needed&&t.deps.add(34665),n.needed&&t.deps.add(34853),this.tiff.enabled=ie.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=!0,a=!1,s=void 0;try{for(var u,o=ie[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){this[u.value].finalizeFilters()}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}},{key:"checkLoadedPlugins",value:function(){var e=!0,t=!1,r=void 0;try{for(var n,i=ne[Symbol.iterator]();!(e=(n=i.next()).done);e=!0){var a=n.value;this[a].enabled&&!z.has(a)&&T("segment parser",a)}}catch(e){t=!0,r=e}finally{try{e||null==i.return||i.return()}finally{if(t)throw r}}}},{key:"onlyTiff",get:function(){var e=this;return!re.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),r}(fe);function de(e,t){var r,n,i,a,s=[],u=!0,o=!1,f=void 0;try{for(var l,c=t[Symbol.iterator]();!(u=(l=c.next()).done);u=!0){i=l.value,r=Z.get(i),n=[];var h=!0,p=!1,d=void 0;try{for(var y,v=r[Symbol.iterator]();!(h=(y=v.next()).done);h=!0)a=y.value,(e.includes(a[0])||e.includes(a[1]))&&n.push(a[0])}catch(e){p=!0,d=e}finally{try{h||null==v.return||v.return()}finally{if(p)throw d}}n.length&&s.push([i,n])}}catch(e){o=!0,f=e}finally{try{u||null==c.return||c.return()}finally{if(o)throw f}}return s}function ye(e,t){return void 0!==e?e:void 0!==t?t:void 0}function ve(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=a.value;e.add(u)}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}u(pe,"default",ce);var ge={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},ke=Object.assign({},ge,{firstChunkSize:4e4,gps:[1,2,3,4]}),be=Object.assign({},ge,{firstChunkSize:4e4,ifd0:[274]});var me=function(){function e(t){i(this,e),u(this,"parsers",{}),this.options=pe.useCached(t)}var t,r;return s(e,[{key:"setup",value:function(){if(!this.fileParser){var e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=j.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=j.get("jpeg");else{if(!function(e){if(0!==e.getUint16(0))return!1;var t=e.getUint16(2);if(t>50)return!1;for(var r=16,n=[];r<t;)n.push(e.getString(r,4)),r+=4;return n.includes("heic")}(this.file))throw R("Unknown file format");this.file.isHeic=!0,e=j.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:(r=n(regeneratorRuntime.mark((function e(t){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,P(t,this.options);case 2:this.file=e.sent;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})},{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){var t,r,i,a=this;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.setup(),e.next=3,this.fileParser.parse();case 3:return t={},r=[],i=Object.values(this.parsers).map(function(){var e=n(regeneratorRuntime.mark((function e(n){var i;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!a.options.silentErrors){e.next=13;break}return e.prev=1,e.next=4,n.parse();case 4:i=e.sent,e.next=10;break;case 7:e.prev=7,e.t0=e.catch(1),r.push(e.t0);case 10:n.errors.length&&r.push.apply(r,k(n.errors)),e.next=16;break;case 13:return e.next=15,n.parse();case 15:i=e.sent;case 16:n.assignToOutput(t,i);case 17:case"end":return e.stop()}}),e,null,[[1,7]])})));return function(t){return e.apply(this,arguments)}}()),e.next=8,Promise.all(i);case 8:return this.options.silentErrors&&r.length>0&&(t.errors=r),t=O(s=t)?void 0:s,this.file.close&&this.file.close(),e.abrupt("return",t);case 12:case"end":return e.stop()}var s}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"extractThumbnail",value:(t=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.setup(),t=z.get("tiff",this.options),!this.file.isTiff){e.next=6;break}r={start:0,type:"tiff"},e.next=10;break;case 6:if(!this.file.isJpeg){e.next=10;break}return e.next=9,this.fileParser.getOrFindSegment("tiff");case 9:r=e.sent;case 10:if(void 0!==r){e.next=12;break}return e.abrupt("return");case 12:return e.next=14,this.fileParser.ensureSegmentChunk(r);case 14:return n=e.sent,i=this.parsers.tiff=new t(n,this.options,this.file),e.next=18,i.extractThumbnail();case 18:return a=e.sent,this.file.close&&this.file.close(),e.abrupt("return",a);case 21:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})}]),e}();function we(){return(we=n(regeneratorRuntime.mark((function e(t,r){var n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=new me(r),e.next=3,n.read(t);case 3:return e.abrupt("return",n.parse());case 4:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function xe(){return(xe=n(regeneratorRuntime.mark((function e(t){var r,n,i,a=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(r=a.length>1&&void 0!==a[1]?a[1]:{}).ifd1=!0,r.mergeOutput=!0,n=new me(r),e.next=6,n.read(t);case 6:return e.next=8,n.extractThumbnail();case 8:if(!(i=e.sent)||!b){e.next=13;break}return e.abrupt("return",Buffer.from(i));case 13:return e.abrupt("return",i);case 14:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Se(){return(Se=n(regeneratorRuntime.mark((function e(){var t,r,n=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.thumbnail.apply(this,n);case 2:if(void 0===(t=e.sent)){e.next=6;break}return r=new Blob([t]),e.abrupt("return",URL.createObjectURL(r));case 6:case"end":return e.stop()}}),e,this)})))).apply(this,arguments)}function Oe(){return(Oe=n(regeneratorRuntime.mark((function e(t){var r,n,i,a,s;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new me(ke),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.gps){e.next=9;break}return i=n.gps,a=i.latitude,s=i.longitude,e.abrupt("return",{latitude:a,longitude:s});case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Re(){return(Re=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=new me(be),e.next=3,r.read(t);case 3:return e.next=5,r.parse();case 5:if(!(n=e.sent)||!n.ifd0){e.next=8;break}return e.abrupt("return",n.ifd0[274]);case 8:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var Ae=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"ranges",new Ue),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}var r;return o(t,e),s(t,[{key:"_tryExtend",value:function(e,t,r){if(0===e&&0===this.byteLength&&r){var n=new DataView(r.buffer||r,r.byteOffset,r.byteLength);this._swapDataView(n)}else{var i=e+t;if(i>this.byteLength){var a=this._extend(i).dataView;this._swapDataView(a)}}}},{key:"_extend",value:function(e){var t;t=b?Buffer.allocUnsafe(e):new Uint8Array(e);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:r}}},{key:"subarray",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return r=r||this._lengthToEnd(e),n&&this._tryExtend(e,r),this.ranges.add(e,r),v(f(t.prototype),"subarray",this).call(this,e,r)}},{key:"set",value:function(e,r){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];n&&this._tryExtend(r,e.byteLength,e);var i=v(f(t.prototype),"set",this).call(this,e,r);return this.ranges.add(r,i.byteLength),i}},{key:"ensureChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunked){e.next=2;break}return e.abrupt("return");case 2:if(!this.ranges.available(t,r)){e.next=4;break}return e.abrupt("return");case 4:return e.next=6,this.readChunk(t,r);case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),t}(V),Ue=function(){function e(t){i(this,e),u(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}return s(e,[{key:"addMultiple",value:function(e){if(Array.isArray(e[0])){var t=!0,r=!1,n=void 0;try{for(var i,a=e[Symbol.iterator]();!(t=(i=a.next()).done);t=!0){var s=g(i.value,2),u=s[0],o=s[1];this.add(u,o)}}catch(e){r=!0,n=e}finally{try{t||null==a.return||a.return()}finally{if(r)throw n}}}else{var f=!0,l=!1,c=void 0;try{for(var h,p=e[Symbol.iterator]();!(f=(h=p.next()).done);f=!0){var d=h.value,y=d.offset,v=d.length;this.add(y,v)}}catch(e){l=!0,c=e}finally{try{f||null==p.return||p.return()}finally{if(l)throw c}}}}},{key:"add",value:function(e,t){var r=e+t,n=this.list.filter((function(t){return Ce(e,t.offset,r)||Ce(e,t.end,r)}));if(n.length>0){e=Math.min.apply(Math,[e].concat(k(n.map((function(e){return e.offset}))))),t=(r=Math.max.apply(Math,[r].concat(k(n.map((function(e){return e.end}))))))-e;var i=n.shift();i.offset=e,i.length=t,i.end=r,this.list=this.list.filter((function(e){return!n.includes(e)}))}else this.list.push({offset:e,length:t,end:r})}},{key:"available",value:function(e,t){var r=e+t;return this.list.some((function(t){return t.offset<=e&&r<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Ce(e,t,r){return e<=t&&t<=r}var Be=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a;return o(t,e),s(t,[{key:"readWhole",value:(a=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,J(this.input);case 3:t=e.sent,this._swapArrayBuffer(t);case 5:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,v(f(t.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){var n,i,a;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r?t+r:void 0,i=this.input.slice(t,n),e.next=4,J(i);case 4:return a=e.sent,e.abrupt("return",this.set(a,t,!0));case 6:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})}]),t}(function(e){function t(e,r){var n;return i(this,t),u(d(n=y(this,f(t).call(this,0))),"chunksRead",0),n.input=e,n.options=r,n}var r,a,l,c;return o(t,e),s(t,[{key:"readWhole",value:(c=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!1,e.next=3,this.readChunk(this.nextChunkOffset);case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"readChunked",value:(l=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.chunked=!0,e.next=3,this.readChunk(0,this.options.firstChunkSize);case 3:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"readNextChunk",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:this.nextChunkOffset,!this.fullyRead){e.next=4;break}return this.chunksRead++,e.abrupt("return",!1);case 4:return r=this.options.chunkSize,e.next=7,this.readChunk(t,r);case 7:if(!(n=e.sent)){e.next=10;break}return e.abrupt("return",n.byteLength===r);case 10:return e.abrupt("return",!1);case 11:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"readChunk",value:(r=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.chunksRead++,0!==(r=this.safeWrapAddress(t,r))){e.next=4;break}return e.abrupt("return",void 0);case 4:return e.abrupt("return",this._readChunk(t,r));case 5:case"end":return e.stop()}}),e,this)}))),function(e,t){return r.apply(this,arguments)})},{key:"safeWrapAddress",value:function(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}},{key:"read",value:function(){return this.options.chunked?this.readChunked():this.readWhole()}},{key:"close",value:function(){}},{key:"nextChunkOffset",get:function(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}},{key:"canReadNextChunk",get:function(){return this.chunksRead<this.options.chunkLimit}},{key:"fullyRead",get:function(){return void 0!==this.size&&this.nextChunkOffset===this.size}}]),t}(Ae));F.set("blob",Be);var Ve=function(){function e(t,r,a){var s=this;i(this,e),u(this,"ensureSegmentChunk",function(){var e=n(regeneratorRuntime.mark((function e(t){var r,n;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.start,n=t.size||65536,!s.file.chunked){e.next=18;break}if(!s.file.available(r,n)){e.next=7;break}t.chunk=s.file.subarray(r,n),e.next=16;break;case 7:return e.prev=7,e.next=10,s.file.readChunk(r,n);case 10:t.chunk=e.sent,e.next=16;break;case 13:throw e.prev=13,e.t0=e.catch(7),R("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.t0.message));case 16:e.next=27;break;case 18:if(!(s.file.byteLength>r+n)){e.next=22;break}t.chunk=s.file.subarray(r,n),e.next=27;break;case 22:if(void 0!==t.size){e.next=26;break}t.chunk=s.file.subarray(r),e.next=27;break;case 26:throw R("Segment unreachable: "+JSON.stringify(t));case 27:return e.abrupt("return",t.chunk);case 28:case"end":return e.stop()}}),e,null,[[7,13]])})));return function(t){return e.apply(this,arguments)}}()),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=r,this.parsers=a}return s(e,[{key:"createParser",value:function(e,t){var r=new(z.get(e))(t,this.options,this.file);return this.parsers[e]=r}}]),e}(),Ie=function(){function e(t){var r=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;i(this,e),u(this,"errors",[]),u(this,"raw",new Map),u(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=this.normalizeInput(t),this.file=a,this.type=this.constructor.type,this.globalOptions=this.options=n,this.localOptions=n[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}return s(e,[{key:"normalizeInput",value:function(e){return e instanceof V?e:new V(e)}}],[{key:"findPosition",value:function(e,t){var r=e.getUint16(t+2)+2,n="function"==typeof this.headerLength?this.headerLength(e,t,r):this.headerLength,i=t+n,a=r-n;return{offset:t,length:r,headerLength:n,start:i,size:a,end:i+a}}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=new pe(u({},this.type,t)),n=new this(e,r);return n.parse()}}]),s(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var r=ee.get(t),n=$.get(t),i=Z.get(t),a=this.options[t],s=a.reviveValues&&r,u=a.translateValues&&n,o=a.translateKeys&&i,f={},l=!0,c=!1,h=void 0;try{for(var p,d=e[Symbol.iterator]();!(l=(p=d.next()).done);l=!0){var y=g(p.value,2),v=y[0],k=y[1];s&&r.has(v)?k=r.get(v)(k):u&&n.has(v)&&(k=this.translateValue(k,n.get(v))),o&&i.has(v)&&(v=i.get(v)||v),f[v]=k}}catch(e){c=!0,h=e}finally{try{l||null==d.return||d.return()}finally{if(c)throw h}}return f}},{key:"translateValue",value:function(e,t){return t[e]||e}},{key:"assignToOutput",value:function(e,t){this.assignObjectToOutput(e,this.constructor.type,t)}},{key:"assignObjectToOutput",value:function(e,t,r){if(this.globalOptions.mergeOutput)return Object.assign(e,r);e[t]?Object.assign(e[t],r):e[t]=r}},{key:"output",get:function(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}}]),e}();u(Ie,"headerLength",4),u(Ie,"type",void 0),u(Ie,"multiSegment",!1),u(Ie,"canHandle",(function(){return!1}));function Te(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function Le(e){return e>=224&&e<=239}function je(e,t){var r=!0,n=!1,i=void 0;try{for(var a,s=z[Symbol.iterator]();!(r=(a=s.next()).done);r=!0){var u=g(a.value,2),o=u[0];if(u[1].canHandle(e,t))return o}}catch(e){n=!0,i=e}finally{try{r||null==s.return||s.return()}finally{if(n)throw i}}}var ze=function(e){function t(){var e,r;i(this,t);for(var n=arguments.length,a=new Array(n),s=0;s<n;s++)a[s]=arguments[s];return u(d(r=y(this,(e=f(t)).call.apply(e,[this].concat(a)))),"appSegments",[]),u(d(r),"jpegSegments",[]),u(d(r),"unknownSegments",[]),r}var r,a,l,c;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.findAppSegments();case 2:return e.next=4,this.readSegments();case 4:this.mergeMultiSegments(),this.createParsers();case 6:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"readSegments",value:(c=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.appSegments.map(this.ensureSegmentChunk),e.next=3,Promise.all(t);case 3:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=new Set(z.keyList())):(e=void 0===e?z.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&z.has(e)})),this.findAll=!1,this.remaining=new Set(e),this.wanted=new Set(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:(l=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,l,c,h,p,d,y,v,g,k=this,b=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=b.length>0&&void 0!==b[0]?b[0]:0,r=b.length>1?b[1]:void 0,this.setupSegmentFinderArgs(r),n=this.file,i=this.findAll,a=this.wanted,s=this.remaining,i){e.next=37;break}u=!0,o=!1,f=void 0,e.prev=8,l=a[Symbol.iterator]();case 10:if(u=(c=l.next()).done){e.next=23;break}if(h=c.value,p=z.get(h),d=this.options[h],!p.multiSegment||!d.multiSegment){e.next=20;break}if(i=!0,!this.file.chunked){e.next=19;break}return e.next=19,this.file.readWhole();case 19:return e.abrupt("break",23);case 20:u=!0,e.next=10;break;case 23:e.next=29;break;case 25:e.prev=25,e.t0=e.catch(8),o=!0,f=e.t0;case 29:e.prev=29,e.prev=30,u||null==l.return||l.return();case 32:if(e.prev=32,!o){e.next=35;break}throw f;case 35:return e.finish(32);case 36:return e.finish(29);case 37:if(t=this._findAppSegments(t,n.byteLength,i,a,s),!this.options.onlyTiff){e.next=40;break}return e.abrupt("return");case 40:if(!n.chunked){e.next=59;break}y=!1;case 42:if(!(s.size>0)||y||!n.canReadNextChunk&&!this.unfinishedMultiSegment){e.next=59;break}if(v=n.nextChunkOffset,g=this.appSegments.some((function(e){return!k.file.available(e.offset||e.start,e.length||e.size)})),!(t>v)||g){e.next=51;break}return e.next=48,n.readNextChunk(t);case 48:y=!e.sent,e.next=54;break;case 51:return e.next=53,n.readNextChunk(v);case 53:y=!e.sent;case 54:if(void 0!==(t=this._findAppSegments(t,n.byteLength))){e.next=57;break}return e.abrupt("return");case 57:e.next=42;break;case 59:case"end":return e.stop()}}),e,this,[[8,25,29,37],[30,,32,36]])}))),function(){return l.apply(this,arguments)})},{key:"_findAppSegments",value:function(e,t){for(var r,n,i,a,s,u,o=this.file,f=this.findAll,l=this.wanted,c=this.remaining,h=this.options;e<t;e++)if(255===o.getUint8(e))if(Le(r=o.getUint8(e+1))){if(n=o.getUint16(e+2),(i=je(o,e))&&l.has(i)&&(s=(a=z.get(i)).findPosition(o,e),u=h[i],s.type=i,this.appSegments.push(s),!f&&(a.multiSegment&&u.multiSegment?(this.unfinishedMultiSegment=s.chunkNumber<s.chunkCount,this.unfinishedMultiSegment||c.delete(i)):c.delete(i),0===c.size)))break;h.recordUnknownSegments&&((s=Ie.findPosition(o,e)).marker=r,this.unknownSegments.push(s)),e+=n+1}else if(Te(r)){if(n=o.getUint16(e+2),218===r&&!1!==h.stopAfterSos)return;h.recordJpegSegments&&this.jpegSegments.push({offset:e,length:n,marker:r}),e+=n+1}return e}},{key:"mergeMultiSegments",value:function(){var e=this;if(this.appSegments.some((function(e){return e.multiSegment}))){var t=function(e,t){for(var r,n,i,a=new Map,s=0;s<e.length;s++)r=e[s],n=r[t],a.has(n)?i=a.get(n):a.set(n,i=[]),i.push(r);return Array.from(a.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map((function(t){var r=g(t,2),n=r[0],i=r[1],a=z.get(n,e.options);return a.handleMultiSegments?{type:n,chunk:a.handleMultiSegments(i)}:i[0]}))}}},{key:"createParsers",value:(a=n(regeneratorRuntime.mark((function e(){var t,r,n,i,a,s,u,o,f,l,c,h;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=this.mergedAppSegments||this.appSegments,r=!0,n=!1,i=void 0,e.prev=4,a=t[Symbol.iterator]();case 6:if(r=(s=a.next()).done){e.next=16;break}if(u=s.value,o=u.type,f=u.chunk,this.options[o].enabled){e.next=11;break}return e.abrupt("continue",13);case 11:(l=this.parsers[o])&&l.append||l||(c=z.get(o,this.options),h=new c(f,this.options,this.file),this.parsers[o]=h);case 13:r=!0,e.next=6;break;case 16:e.next=22;break;case 18:e.prev=18,e.t0=e.catch(4),n=!0,i=e.t0;case 22:e.prev=22,e.prev=23,r||null==a.return||a.return();case 25:if(e.prev=25,!n){e.next=28;break}throw i;case 28:return e.finish(25);case 29:return e.finish(22);case 30:case"end":return e.stop()}}),e,this,[[4,18,22,30],[23,,25,29]])}))),function(){return a.apply(this,arguments)})},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:(r=n(regeneratorRuntime.mark((function e(t){var r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(void 0!==(r=this.getSegment(t))){e.next=5;break}return e.next=4,this.findAppSegments(0,[t]);case 4:r=this.getSegment(t);case 5:return e.abrupt("return",r);case 6:case"end":return e.stop()}}),e,this)}))),function(e){return r.apply(this,arguments)})}]),t}(Ve);j.set("jpeg",ze);var Fe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var Pe=function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}var r,a,u,l,c,h,p;return o(t,e),s(t,[{key:"parse",value:function(){var e=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.parseHeader(),!this.options.ifd0.enabled){e.next=4;break}return e.next=4,this.parseIfd0Block();case 4:if(!this.options.exif.enabled){e.next=7;break}return e.next=7,this.parseExifBlock().catch(this.handleError);case 7:if(!this.options.gps.enabled){e.next=10;break}return e.next=10,this.parseGpsBlock().catch(this.handleError);case 10:if(!this.options.interop.enabled){e.next=13;break}return e.next=13,this.parseInteropBlock().catch(this.handleError);case 13:if(!this.options.ifd1.enabled){e.next=16;break}return e.next=16,this.parseThumbnailBlock().catch(this.handleError);case 16:return e.abrupt("return",this.createOutput());case 17:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}()},{key:"findIfd0Offset",value:function(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}},{key:"findIfd1Offset",value:function(){if(void 0===this.ifd1Offset){this.findIfd0Offset();var e=this.chunk.getUint16(this.ifd0Offset),t=this.ifd0Offset+2+12*e;this.ifd1Offset=this.chunk.getUint32(t)}}},{key:"parseBlock",value:function(e,t){var r=new Map;return this[t]=r,this.parseTags(e,t,r),r}},{key:"parseIfd0Block",value:(p=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.ifd0){e.next=2;break}return e.abrupt("return");case 2:if(this.findIfd0Offset(),!(this.ifd0Offset<8)){e.next=5;break}throw R("Invalid EXIF data: IFD0 offset should be less than 8");case 5:if(this.file.chunked||!(this.ifd0Offset>this.file.byteLength)){e.next=7;break}throw R("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.ifd0Offset,A(this.options));case 10:if(0!==(t=this.parseBlock(this.ifd0Offset,"ifd0")).size){e.next=13;break}return e.abrupt("return");case 13:return this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),e.abrupt("return",t);case 21:case"end":return e.stop()}}),e,this)}))),function(){return p.apply(this,arguments)})},{key:"ensureBlockChunk",value:(h=n(regeneratorRuntime.mark((function e(t,r){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.file.isTiff){e.next=3;break}return e.next=3,this.file.ensureChunk(t,r);case 3:t>this.chunk.byteLength&&(this.chunk=V.from(this.file,this.le));case 4:case"end":return e.stop()}}),e,this)}))),function(e,t){return h.apply(this,arguments)})},{key:"parseExifBlock",value:(c=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.exif){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.exifOffset){e.next=7;break}return e.abrupt("return");case 7:if(!this.file.isTiff){e.next=10;break}return e.next=10,this.file.ensureChunk(this.exifOffset,A(this.options));case 10:return t=this.parseBlock(this.exifOffset,"exif"),this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),e.abrupt("return",t);case 18:case"end":return e.stop()}}),e,this)}))),function(){return c.apply(this,arguments)})},{key:"unpack",value:function(e,t){var r=e.get(t);r&&1===r.length&&e.set(t,r[0])}},{key:"parseGpsBlock",value:(l=n(regeneratorRuntime.mark((function e(){var t;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.gps){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.gpsOffset){e.next=7;break}return e.abrupt("return");case 7:return(t=this.parseBlock(this.gpsOffset,"gps"))&&t.has(2)&&t.has(4)&&(t.set("latitude",Ee.apply(void 0,k(t.get(2)).concat([t.get(1)]))),t.set("longitude",Ee.apply(void 0,k(t.get(4)).concat([t.get(3)])))),e.abrupt("return",t);case 10:case"end":return e.stop()}}),e,this)}))),function(){return l.apply(this,arguments)})},{key:"parseInteropBlock",value:(u=n(regeneratorRuntime.mark((function e(){return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.interop){e.next=2;break}return e.abrupt("return");case 2:if(this.ifd0){e.next=5;break}return e.next=5,this.parseIfd0Block();case 5:if(void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset){e.next=8;break}return e.abrupt("return");case 8:return e.abrupt("return",this.parseBlock(this.interopOffset,"interop"));case 9:case"end":return e.stop()}}),e,this)}))),function(){return u.apply(this,arguments)})},{key:"parseThumbnailBlock",value:(a=n(regeneratorRuntime.mark((function e(){var t,r=arguments;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=r.length>0&&void 0!==r[0]&&r[0],!this.ifd1&&!this.ifd1Parsed){e.next=3;break}return e.abrupt("return");case 3:if(!this.options.mergeOutput||t){e.next=5;break}return e.abrupt("return");case 5:return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),e.abrupt("return",this.ifd1);case 8:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})},{key:"extractThumbnail",value:(r=n(regeneratorRuntime.mark((function e(){var t,r;return regeneratorRuntime.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.headerParsed||this.parseHeader(),this.ifd1Parsed){e.next=4;break}return e.next=4,this.parseThumbnailBlock(!0);case 4:if(void 0!==this.ifd1){e.next=6;break}return e.abrupt("return");case 6:return t=this.ifd1.get(513),r=this.ifd1.get(514),e.abrupt("return",this.chunk.getUint8Array(t,r));case 9:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"createOutput",value:function(){var e,t,r,n={},i=!0,a=!1,s=void 0;try{for(var u,o=ie[Symbol.iterator]();!(i=(u=o.next()).done);i=!0)if(!O(e=this[t=u.value]))if(r=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(n,r)}else n[t]=r}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}},{key:"assignToOutput",value:function(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(var r=0,n=Object.entries(t);r<n.length;r++){var i=g(n[r],2),a=i[0],s=i[1];this.assignObjectToOutput(e,a,s)}}},{key:"image",get:function(){return this.ifd0}},{key:"thumbnail",get:function(){return this.ifd1}}],[{key:"canHandle",value:function(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}}]),t}(function(e){function t(){return i(this,t),y(this,f(t).apply(this,arguments))}return o(t,e),s(t,[{key:"parseHeader",value:function(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw R("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw R("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}},{key:"parseTags",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Map,n=this.options[t],i=n.pick,a=n.skip,s=(i=new Set(i)).size>0,u=0===a.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var l=this.chunk.getUint16(e);if(s){if(i.has(l)&&(r.set(l,this.parseTag(e,l,t)),i.delete(l),0===i.size))break}else!u&&a.has(l)||r.set(l,this.parseTag(e,l,t));e+=12}return r}},{key:"parseTag",value:function(e,t,r){var n,i=this.chunk.getUint16(e+2),a=this.chunk.getUint32(e+4),s=Fe[i];if(s*a<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw R("Invalid TIFF value type. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw R("Invalid TIFF value offset. block: ".concat(r.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e," is outside of chunk size ").concat(this.chunk.byteLength));if(1===i)return this.chunk.getUint8Array(e,a);if(2===i)return""===(n=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(n=this.chunk.getString(e,a)).trim())?void 0:n;if(7===i)return this.chunk.getUint8Array(e,a);if(1===a)return this.parseTagValue(i,e);for(var u=new(function(e){switch(e){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(i))(a),o=s,f=0;f<a;f++)u[f]=this.parseTagValue(i,e),e+=o;return u}},{key:"parseTagValue",value:function(e,t){switch(e){case 1:return this.chunk.getUint8(t);case 3:return this.chunk.getUint16(t);case 4:return this.chunk.getUint32(t);case 5:return this.chunk.getUint32(t)/this.chunk.getUint32(t+4);case 6:return this.chunk.getInt8(t);case 8:return this.chunk.getInt16(t);case 9:return this.chunk.getInt32(t);case 10:return this.chunk.getInt32(t)/this.chunk.getInt32(t+4);case 11:return this.chunk.getFloat(t);case 12:return this.chunk.getDouble(t);case 13:return this.chunk.getUint32(t);default:throw R("Invalid tiff type ".concat(e))}}}]),t}(Ie));function Ee(e,t,r,n){var i=e+t/60+r/3600;return"S"!==n&&"W"!==n||(i*=-1),i}u(Pe,"type","tiff"),u(Pe,"headerLength",10),z.set("tiff",Pe),e.Exifr=me,e.Options=pe,e.allFormatters=oe,e.chunkedProps=te,e.createDictionary=function(e,t,r){var n=new Y(r);if(I(n,Y,void 0,["tagKeys","tagValues"]),Array.isArray(t)){var i=!0,a=!1,s=void 0;try{for(var u,o=t[Symbol.iterator]();!(i=(u=o.next()).done);i=!0){var f=u.value;e.set(f,n)}}catch(e){a=!0,s=e}finally{try{i||null==o.return||o.return()}finally{if(a)throw s}}}else e.set(t,n);return n},e.disableAllOptions=ge,e.extendDictionary=function(e,t,r){var n,i=e.get(t),a=!0,s=!1,u=void 0;try{for(var o,f=r[Symbol.iterator]();!(a=(o=f.next()).done);a=!0)n=o.value,i.set(n[0],n[1])}catch(e){s=!0,u=e}finally{try{a||null==f.return||f.return()}finally{if(s)throw u}}},e.fetchUrlAsArrayBuffer=H,e.fileParsers=j,e.fileReaders=F,e.gps=function(e){return Oe.apply(this,arguments)},e.gpsOnlyOptions=ke,e.inheritables=ue,e.orientation=function(e){return Re.apply(this,arguments)},e.orientationOnlyOptions=be,e.otherSegments=re,e.parse=function(e,t){return we.apply(this,arguments)},e.readBlobAsArrayBuffer=J,e.segmentParsers=z,e.segments=ne,e.segmentsAndBlocks=ae,e.tagKeys=Z,e.tagRevivers=ee,e.tagValues=$,e.thumbnail=function(e){return xe.apply(this,arguments)},e.thumbnailUrl=function(){return Se.apply(this,arguments)},e.tiffBlocks=ie,e.tiffExtractables=se,Object.defineProperty(e,"__esModule",{value:!0})}));

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],e):e((t=t||self).exifr={})}(this,(function(t){"use strict";var e="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}function a(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.keys(t).length)}function h(t){let e=new Error(t);return delete e.stack,e}function f(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let o=n?global.BigInt:window.BigInt;const l=new TextDecoder("utf-8");class u{static from(t,e){return t instanceof this&&t.le===e?t:new u(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof u){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw h("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw h("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=u){if(t instanceof DataView||t instanceof u?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw h("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new u(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return s=i,l.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(e)<<o(32)|o(i);throw h("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function d(t,e){throw h("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class c extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||d(this.kind,t),e&&(t in e||function(t,e){throw h("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||d(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}function p(t,e,i=[],s=[]){for(let s of i)void 0===t[s]&&(t[s]=e.prototype[s]);for(let i of s){if(void 0===Object.getOwnPropertyDescriptor(t,i)){let s=Object.getOwnPropertyDescriptor(e.prototype,i);Object.defineProperty(t,i,s)}}}var g=new c("file parser"),y=new c("segment parser"),k=new c("file reader");function w(t,e){if((s=t).startsWith("data:")||s.length>1e4)return m(t,e,"base64");if(i)return b(t,e,"url",v);if(n)return m(t,e,"fs");throw h("Invalid input argument");var s}async function b(t,e,i,s){if(k.has(i))return m(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw h("Parser ".concat(i," is not loaded"))}async function m(t,e,i){let s=new(k.get(i))(t,e);return await s.read(),s}async function v(t){return fetch(t).then(t=>t.arrayBuffer())}async function O(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}p(g,c,["keyList"]),p(y,c,["keyList"]),p(k,c,["keyList"]);const S=Symbol("keys"),U=Symbol("values");class A extends Map{get tagKeys(){return this[S]||(this[S]=Array.from(this.keys())),this[S]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}const x=new Map,C=new Map,B=new Map,V=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],I=["jfif","xmp","icc","iptc"],L=["tiff",...I],T=["ifd0","ifd1","exif","gps","interop"],z=[...L,...T],F=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...D,"mergeOutput","sanitize"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class P extends j{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=t,this.enabled=e,this.applyInheritables(s),this.canBeFiltered=T.includes(t),this.canBeFiltered&&(this.dict=x.get(t)),void 0!==i)if(Array.isArray(i))this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw h("Invalid options argument: ".concat(i));this.enabled=i}}applyInheritables(t){let e,i;for(e of D)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,K(this.pick,this.deps)):this.enabled&&this.pick.size>0&&K(this.pick,this.deps)}}var N={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class M extends j{static useCached(t){let e=_.get(t);return void 0!==e?e:(e=new this(t),_.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw h("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of V)this[t]=N[t];for(t of E)this[t]=N[t];for(t of F)this[t]=N[t];for(t of z)this[t]=new P(t,N[t],void 0,this)}setupFromTrue(){let t;for(t of V)this[t]=N[t];for(t of E)this[t]=N[t];for(t of F)this[t]=!0;for(t of z)this[t]=new P(t,!0,void 0,this)}setupFromArray(t){let e;for(e of V)this[e]=N[e];for(e of E)this[e]=N[e];for(e of F)this[e]=N[e];for(e of z)this[e]=new P(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,T)}setupFromObject(t){let e;for(e of(T.ifd0=T.ifd0||T.image,T.ifd1=T.ifd1||T.thumbnail,Object.assign(this,t),V))this[e]=W(t[e],N[e]);for(e of E)this[e]=W(t[e],N[e]);for(e of F)this[e]=W(t[e],N[e]);for(e of L)this[e]=new P(e,N[e],t[e],this);for(e of T)this[e]=new P(e,N[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,T,z),!0===t.tiff?this.batchEnableWithBool(T,!0):!1===t.tiff?this.batchEnableWithUserValue(T,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,T):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,T)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)K(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)K(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=T.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of T)this[t].finalizeFilters()}get onlyTiff(){return!I.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of L)this[t].enabled&&!y.has(t)&&d("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=x.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function W(t,e){return void 0!==t?t:void 0!==e?e:void 0}function K(t,e){for(let i of e)t.add(i)}r(M,"default",N);const H={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},G=Object.assign({},H,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},H,{firstChunkSize:4e4,ifd0:[274]});class X{constructor(t){r(this,"parsers",{}),this.options=M.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=g.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=g.get("jpeg");else{if(!function(t){let e=t.getUint32(0),i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw h("Unknown file format");this.file.isHeic=!0,t=g.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,e){if("string"==typeof t)return w(t,e);if(i&&!s&&t instanceof HTMLImageElement)return w(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new u(t);if(i&&t instanceof Blob)return b(t,e,"blob",O);throw h("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},{mergeOutput:e}=this.options,i=[],s=Object.values(this.parsers).map(async s=>{let n;if(this.options.silentErrors){try{n=await s.parse()}catch(t){i.push(t)}s.errors.length&&i.push(...s.errors)}else n=await s.parse();(e||s.constructor.mergeOutput)&&"string"!=typeof n?Object.assign(t,n):void 0!==n&&(t[s.constructor.type]=n)});var n;return await Promise.all(s),this.options.silentErrors&&i.length>0&&(t.errors=i),t=a(n=t)?void 0:n,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=y.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class q extends u{constructor(...t){super(...t),r(this,"ranges",new Q),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}}class Q{constructor(t){r(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>Y(t,e.offset,s)||Y(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function Y(t,e,i){return t<=e&&e<=i}class Z extends q{constructor(t,e){super(0),r(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}k.set("blob",class extends Z{async readWhole(){this.chunked=!1;let t=await O(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await O(s);return this.set(n,t,!0)}});class ${static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,start:n,size:r,end:n+r}}static parse(t,e,i){return"object"==typeof e&&(i=e,e=void 0),new this(new u(t,e),M.useCached(i)).parse()}constructor(t,e={},i){r(this,"errors",[]),r(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=t,this.options=e,this.file=i,this.type=this.constructor.type,this.segOptions=e[this.type],this.canTranslate=this.segOptions.translate,this.raw=new Map}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=B.get(e),s=C.get(e),n=x.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||t}}r($,"headerLength",4),r($,"type",void 0),r($,"mergeOutput",!1),r($,"multiSegment",!1),r($,"canHandle",()=>!1);function tt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function et(t){return t>=224&&t<=239}function it(t,e){for(let[i,s]of y)if(s.canHandle(t,e))return i}function st(...t){let e=t[0].constructor,i=0;for(let e of t)i+=e.length;let s=new e(i),n=0;for(let e of t)s.set(e,n),n+=e.length;return s}g.set("jpeg",class extends class{constructor(t,e,i){r(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw h("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw h("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(y.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(y.keyList())):(t=void 0===t?y.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&y.has(t)),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){if(y.get(t).multiSegment){s=!0,await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),et(i)){if(s=f.getUint16(t+2),n=it(f,t),n&&l.has(n)&&(r=y.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(a.multiSegment&&h.multiSegment?a.chunkNumber<a.chunkCount?this.unfinishedMultiSegment=!0:(this.unfinishedMultiSegment=!1,u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=$.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(tt(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}async createParsers(){let t;if(this.hasMultiSegments){t=[];let e=[];for(let i of this.appSegments)if(i.multiSegment){if(e.includes(i.type))break;e.push(i.type);let s=st(...this.appSegments.filter(t=>t.type===i.type).sort((t,e)=>t.chunkNumber-e.chunkNumber).map(t=>t.chunk.toUint8()));t.push({type:i.type,chunk:new u(s)})}else t.push(i)}else t=this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(y.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}get hasMultiSegments(){return this.appSegments.some(t=>t.multiSegment)}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const nt=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class rt extends ${parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw h("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw h("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=nt[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw h("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw h("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw h("Invalid tiff type ".concat(t))}}}class at extends rt{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw h("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw h("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,f(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=u.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,f(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",ht(...t.get(2),t.get(1))),t.set("longitude",ht(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,s={};for(e of T)if(t=this[e],!a(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}}function ht(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(at,"type","tiff"),r(at,"mergeOutput",!0),r(at,"headerLength",10),y.set("tiff",at),t.Exifr=X,t.Options=M,t.allFormatters=E,t.chunkedProps=V,t.createDictionary=function(t,e,i){let s=new A(i);if(p(s,A,void 0,["tagKeys","tagValues"]),Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s},t.disableAllOptions=H,t.extendDictionary=function(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])},t.fetchUrlAsArrayBuffer=v,t.fileParsers=g,t.fileReaders=k,t.gps=async function(t){let e=new X(G);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}},t.gpsOnlyOptions=G,t.inheritables=D,t.orientation=async function(t){let e=new X(J);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]},t.orientationOnlyOptions=J,t.otherSegments=I,t.parse=async function(t,e){let i=new X(e);return await i.read(t),i.parse()},t.readBlobAsArrayBuffer=O,t.segmentParsers=y,t.segments=L,t.segmentsAndBlocks=z,t.tagKeys=x,t.tagRevivers=B,t.tagValues=C,t.thumbnail=async function(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new X(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n},t.thumbnailUrl=async function(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}},t.tiffBlocks=T,t.tiffExtractables=F,Object.defineProperty(t,"__esModule",{value:!0})}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define("exifr",["exports"],e):e((t=t||self).exifr={})}(this,(function(t){"use strict";var e="undefined"!=typeof Buffer,i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);function r(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}const a=t=>void 0!==t;function h(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(a).length)}function f(t){let e=new Error(t);return delete e.stack,e}function o(t){let e=function(t){let e=0;return t.ifd0.enabled&&(e+=1024),t.exif.enabled&&(e+=2048),t.makerNote&&(e+=2048),t.userComment&&(e+=1024),t.gps.enabled&&(e+=512),t.interop.enabled&&(e+=100),t.ifd1.enabled&&(e+=1024),e+2048}(t);return t.jfif.enabled&&(e+=50),t.xmp.enabled&&(e+=2e4),t.iptc.enabled&&(e+=14e3),t.icc.enabled&&(e+=6e3),e}let l=n?global.BigInt:self.BigInt;const u=new TextDecoder("utf-8");class d{static from(t,e){return t instanceof this&&t.le===e?t:new d(t,void 0,void 0,e)}constructor(t,e=0,i,s){if("boolean"==typeof s&&(this.le=s),Array.isArray(t)&&(t=new Uint8Array(t)),0===t)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof d){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw f("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else{if("number"!=typeof t)throw f("Invalid input argument for BufferView: "+t);{let e=new DataView(new ArrayBuffer(t));this._swapDataView(e)}}}_swapArrayBuffer(t){this._swapDataView(new DataView(t))}_swapBuffer(t){this._swapDataView(new DataView(t.buffer,t.byteOffset,t.byteLength))}_swapDataView(t){this.dataView=t,this.buffer=t.buffer,this.byteOffset=t.byteOffset,this.byteLength=t.byteLength}_lengthToEnd(t){return this.byteLength-t}set(t,e,i=d){if(t instanceof DataView||t instanceof d?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw f("BufferView.set(): Invalid data argument.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new d(this,t,e)}toUint8(){return new Uint8Array(this.buffer,this.byteOffset,this.byteLength)}getUint8Array(t,e){return new Uint8Array(this.buffer,this.byteOffset+t,e)}getString(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return s=i,u.decode(s);var s}getUnicodeString(t=0,e=this.byteLength){const i=[];for(let s=0;s<e&&t+s<this.byteLength;s+=2)i.push(this.getUint16(t+s));return i.map(t=>String.fromCharCode(t)).join("")}getInt8(t){return this.dataView.getInt8(t)}getUint8(t){return this.dataView.getUint8(t)}getInt16(t,e=this.le){return this.dataView.getInt16(t,e)}getInt32(t,e=this.le){return this.dataView.getInt32(t,e)}getUint16(t,e=this.le){return this.dataView.getUint16(t,e)}getUint32(t,e=this.le){return this.dataView.getUint32(t,e)}getFloat32(t,e=this.le){return this.dataView.getFloat32(t,e)}getFloat64(t,e=this.le){return this.dataView.getFloat64(t,e)}getFloat(t,e=this.le){return this.dataView.getFloat32(t,e)}getDouble(t,e=this.le){return this.dataView.getFloat64(t,e)}getUint64(t){let e=this.getUint32(t),i=this.getUint32(t+4);if(e<1048575)return e<<32|i;if(void 0!==typeof l)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),l(e)<<l(32)|l(i);throw f("Trying to read 64b value but JS can only handle 53b numbers.")}getUintBytes(t,e,i){switch(e){case 1:return this.getUint8(t,i);case 2:return this.getUint16(t,i);case 4:return this.getUint32(t,i);case 8:return this.getUint64(t,i)}}getUint(t,e,i){switch(e){case 8:return this.getUint8(t,i);case 16:return this.getUint16(t,i);case 32:return this.getUint32(t,i);case 64:return this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}}function c(t,e){throw f("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class p extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||c(this.kind,t),e&&(t in e||function(t,e){throw f("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||c(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var g=new p("file parser"),y=new p("segment parser"),b=new p("file reader");function m(t,e){if((s=t).startsWith("data:")||s.length>1e4)return k(t,e,"base64");if(i)return w(t,e,"url",O);if(n)return k(t,e,"fs");throw f("Invalid input argument");var s}async function w(t,e,i,s){if(b.has(i))return k(t,e,i);if(s)return async function(t,e){let i=await e(t);return new DataView(i)}(t,s);throw f("Parser ".concat(i," is not loaded"))}async function k(t,e,i){let s=new(b.get(i))(t,e);return await s.read(),s}async function O(t){return fetch(t).then(t=>t.arrayBuffer())}async function v(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}const S=Symbol("keys"),U=Symbol("values");class A extends Map{get tagKeys(){return this[S]||(this[S]=Array.from(this.keys())),this[S]}get tagValues(){return this[U]||(this[U]=Array.from(this.values())),this[U]}}const x=new Map,C=new Map,B=new Map,V=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],I=["jfif","xmp","icc","iptc"],T=["tiff",...I],L=["ifd0","ifd1","exif","gps","interop"],z=[...T,...L],F=["makerNote","userComment"],j=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...j,"sanitize","mergeOutput"];class D{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class M extends D{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,s){if(super(),r(this,"enabled",!1),r(this,"skip",new Set),r(this,"pick",new Set),r(this,"deps",new Set),r(this,"translateKeys",!1),r(this,"translateValues",!1),r(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(s),this.canBeFiltered=L.includes(t),this.canBeFiltered&&(this.dict=x.get(t)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:t,skip:e}=i;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(i)}else{if(!0!==i&&!1!==i)throw f("Invalid options argument: ".concat(i));this.parse=this.enabled=i}}applyInheritables(t){let e,i;for(e of j)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){let i,s,{tagKeys:n,tagValues:r}=this.dict;for(i of t)"string"==typeof i?(s=r.indexOf(i),-1===s&&(s=n.indexOf(Number(i))),-1!==s&&e.add(Number(n[s]))):e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,H(this.pick,this.deps)):this.enabled&&this.pick.size>0&&H(this.pick,this.deps)}}var P={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,makerNote:!1,userComment:!1,multiSegment:!1,skip:[],pick:[],translateKeys:!0,translateValues:!0,reviveValues:!0,sanitize:!0,mergeOutput:!0,silentErrors:!0,chunked:!0,firstChunkSize:void 0,firstChunkSizeNode:512,firstChunkSizeBrowser:65536,chunkSize:65536,chunkLimit:5},_=new Map;class N extends D{static useCached(t){let e=_.get(t);return void 0!==e?e:(e=new this(t),_.set(t,e),e)}constructor(t){if(super(),!0===t)this.setupFromTrue();else if(void 0===t)this.setupFromUndefined();else if(Array.isArray(t))this.setupFromArray(t);else{if("object"!=typeof t)throw f("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=i?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of V)this[t]=P[t];for(t of E)this[t]=P[t];for(t of F)this[t]=P[t];for(t of z)this[t]=new M(t,P[t],void 0,this)}setupFromTrue(){let t;for(t of V)this[t]=P[t];for(t of E)this[t]=P[t];for(t of F)this[t]=!0;for(t of z)this[t]=new M(t,!0,void 0,this)}setupFromArray(t){let e;for(e of V)this[e]=P[e];for(e of E)this[e]=P[e];for(e of F)this[e]=P[e];for(e of z)this[e]=new M(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,L)}setupFromObject(t){let e;for(e of(L.ifd0=L.ifd0||L.image,L.ifd1=L.ifd1||L.thumbnail,Object.assign(this,t),V))this[e]=W(t[e],P[e]);for(e of E)this[e]=W(t[e],P[e]);for(e of F)this[e]=W(t[e],P[e]);for(e of T)this[e]=new M(e,P[e],t[e],this);for(e of L)this[e]=new M(e,P[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,L,z),!0===t.tiff?this.batchEnableWithBool(L,!0):!1===t.tiff?this.batchEnableWithUserValue(L,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,L):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,L)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let t=e[i];this[i].enabled=!1!==t&&void 0!==t}}setupGlobalFilters(t,e,i,s=i){if(t&&t.length){for(let t of s)this[t].enabled=!1;let e=R(t,i);for(let[t,i]of e)H(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=R(e,i);for(let[e,i]of t)H(this[e].skip,i)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:s,icc:n}=this;this.makerNote?e.deps.add(37500):e.skip.add(37500),this.userComment?e.deps.add(37510):e.skip.add(37510),i.enabled||t.skip.add(700),s.enabled||t.skip.add(33723),n.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:s}=this;s.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=L.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of L)this[t].finalizeFilters()}get onlyTiff(){return!I.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of T)this[t].enabled&&!y.has(t)&&c("segment parser",t)}}function R(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=x.get(n),s=[],i))(t.includes(r[0])||t.includes(r[1]))&&s.push(r[0]);s.length&&a.push([n,s])}return a}function W(t,e){return void 0!==t?t:void 0!==e?e:void 0}function H(t,e){for(let i of e)t.add(i)}r(N,"default",P);const K={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},G=Object.assign({},K,{firstChunkSize:4e4,gps:[1,2,3,4]}),J=Object.assign({},K,{firstChunkSize:4e4,ifd0:[274]});class X{constructor(t){r(this,"parsers",{}),this.options=N.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=g.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=g.get("jpeg");else{if(!function(t){if(0!==t.getUint16(0))return!1;let e=t.getUint16(2);if(e>50)return!1;let i=16,s=[];for(;i<e;)s.push(t.getString(i,4)),i+=4;return s.includes("heic")}(this.file))throw f("Unknown file format");this.file.isHeic=!0,t=g.get("heic")}this.fileParser=new t(this.options,this.file,this.parsers)}async read(t){this.file=await function(t,e){if("string"==typeof t)return m(t,e);if(i&&!s&&t instanceof HTMLImageElement)return m(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new d(t);if(i&&t instanceof Blob)return w(t,e,"blob",v);throw f("Invalid input argument")}(t,this.options)}async parse(){this.setup(),await this.fileParser.parse();let t={},e=[],i=Object.values(this.parsers).map(async i=>{let s;if(this.options.silentErrors){try{s=await i.parse()}catch(t){e.push(t)}i.errors.length&&e.push(...i.errors)}else s=await i.parse();i.assignToOutput(t,s)});var s;return await Promise.all(i),this.options.silentErrors&&e.length>0&&(t.errors=e),t=h(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=y.get("tiff",this.options);var e;if(this.file.isTiff?e={start:0,type:"tiff"}:this.file.isJpeg&&(e=await this.fileParser.getOrFindSegment("tiff")),void 0===e)return;let i=await this.fileParser.ensureSegmentChunk(e),s=this.parsers.tiff=new t(i,this.options,this.file),n=await s.extractThumbnail();return this.file.close&&this.file.close(),n}}class q extends d{constructor(...t){super(...t),r(this,"ranges",new Q),0!==this.byteLength&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(0===t&&0===this.byteLength&&i){let t=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(t)}else{let i=t+e;if(i>this.byteLength){let{dataView:t}=this._extend(i);this._swapDataView(t)}}}_extend(t){let i;i=e?Buffer.allocUnsafe(t):new Uint8Array(t);let s=new DataView(i.buffer,i.byteOffset,i.byteLength);return i.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:i,dataView:s}}subarray(t,e,i=!1){return e=e||this._lengthToEnd(t),i&&this._tryExtend(t,e),this.ranges.add(t,e),super.subarray(t,e)}set(t,e,i=!1){i&&this._tryExtend(e,t.byteLength,t);let s=super.set(t,e);return this.ranges.add(e,s.byteLength),s}async ensureChunk(t,e){this.chunked&&(this.ranges.available(t,e)||await this.readChunk(t,e))}available(t,e){return this.ranges.available(t,e)}}class Q{constructor(t){r(this,"list",[]),void 0!==t&&Array.isArray(t)&&this.addMultiple(t)}get length(){return this.list.length}addMultiple(t){if(Array.isArray(t[0]))for(let[e,i]of t)this.add(e,i);else for(let{offset:e,length:i}of t)this.add(e,i)}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>Y(t,e.offset,s)||Y(t,e.end,s));if(n.length>0){t=Math.min(t,...n.map(t=>t.offset)),s=Math.max(s,...n.map(t=>t.end)),e=s-t;let i=n.shift();i.offset=t,i.length=e,i.end=s,this.list=this.list.filter(t=>!n.includes(t))}else this.list.push({offset:t,length:e,end:s})}available(t,e){let i=t+e;return this.list.some(e=>e.offset<=t&&i<=e.end)}}function Y(t,e,i){return t<=e&&e<=i}class Z extends q{constructor(t,e){super(0),r(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,0!==(e=this.safeWrapAddress(t,e)))return this._readChunk(t,e)}safeWrapAddress(t,e){return void 0!==this.size&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}b.set("blob",class extends Z{async readWhole(){this.chunked=!1;let t=await v(this.input);this._swapArrayBuffer(t)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(t,e){let i=e?t+e:void 0,s=this.input.slice(t,i),n=await v(s);return this.set(n,t,!0)}});class ${static findPosition(t,e){let i=t.getUint16(e+2)+2,s="function"==typeof this.headerLength?this.headerLength(t,e,i):this.headerLength,n=e+s,r=i-s;return{offset:e,length:i,headerLength:s,start:n,size:r,end:n+r}}static parse(t,e={}){return new this(t,new N({[this.type]:e})).parse()}normalizeInput(t){return t instanceof d?t:new d(t)}constructor(t,e={},i){r(this,"errors",[]),r(this,"raw",new Map),r(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=B.get(e),s=C.get(e),n=x.get(e),r=this.options[e],a=r.reviveValues&&i,h=r.translateValues&&s,f=r.translateKeys&&n,o={};for(let[e,r]of t)a&&i.has(e)?r=i.get(e)(r):h&&s.has(e)&&(r=this.translateValue(r,s.get(e))),f&&n.has(e)&&(e=n.get(e)||e),o[e]=r;return o}translateValue(t,e){return e[t]||t}assignToOutput(t,e){this.assignObjectToOutput(t,this.constructor.type,e)}assignObjectToOutput(t,e,i){if(this.globalOptions.mergeOutput)return Object.assign(t,i);t[e]?Object.assign(t[e],i):t[e]=i}}r($,"headerLength",4),r($,"type",void 0),r($,"multiSegment",!1),r($,"canHandle",()=>!1);function tt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function et(t){return t>=224&&t<=239}function it(t,e){for(let[i,s]of y)if(s.canHandle(t,e))return i}g.set("jpeg",class extends class{constructor(t,e,i){r(this,"ensureSegmentChunk",async t=>{let e=t.start,i=t.size||65536;if(this.file.chunked)if(this.file.available(e,i))t.chunk=this.file.subarray(e,i);else try{t.chunk=await this.file.readChunk(e,i)}catch(e){throw f("Couldn't read segment: ".concat(JSON.stringify(t),". ").concat(e.message))}else if(this.file.byteLength>e+i)t.chunk=this.file.subarray(e,i);else{if(void 0!==t.size)throw f("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}createParser(t,e){let i=new(y.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),r(this,"appSegments",[]),r(this,"jpegSegments",[]),r(this,"unknownSegments",[])}async parse(){await this.findAppSegments(),await this.readSegments(),this.mergeMultiSegments(),this.createParsers()}async readSegments(){let t=this.appSegments.map(this.ensureSegmentChunk);await Promise.all(t)}setupSegmentFinderArgs(t){!0===t?(this.findAll=!0,this.wanted=new Set(y.keyList())):(t=void 0===t?y.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&y.has(t)),this.findAll=!1,this.remaining=new Set(t),this.wanted=new Set(t)),this.unfinishedMultiSegment=!1}async findAppSegments(t=0,e){this.setupSegmentFinderArgs(e);let{file:i,findAll:s,wanted:n,remaining:r}=this;if(!s)for(let t of n){let e=y.get(t),i=this.options[t];if(e.multiSegment&&i.multiSegment){s=!0,this.file.chunked&&await this.file.readWhole();break}}if(t=this._findAppSegments(t,i.byteLength,s,n,r),!this.options.onlyTiff&&i.chunked){let e=!1;for(;r.size>0&&!e&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:s}=i,n=this.appSegments.some(t=>!this.file.available(t.offset||t.start,t.length||t.size));if(e=t>s&&!n?!await i.readNextChunk(t):!await i.readNextChunk(s),void 0===(t=this._findAppSegments(t,i.byteLength)))return}}}_findAppSegments(t,e){let i,s,n,r,a,h,{file:f,findAll:o,wanted:l,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),et(i)){if(s=f.getUint16(t+2),n=it(f,t),n&&l.has(n)&&(r=y.get(n),a=r.findPosition(f,t),h=d[n],a.type=n,this.appSegments.push(a),!o&&(r.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(n)):u.delete(n),0===u.size)))break;d.recordUnknownSegments&&(a=$.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(tt(i)){if(s=f.getUint16(t+2),218===i&&!1!==d.stopAfterSos)return;d.recordJpegSegments&&this.jpegSegments.push({offset:t,length:s,marker:i}),t+=s+1}return t}mergeMultiSegments(){if(!this.appSegments.some(t=>t.multiSegment))return;let t=function(t,e){let i,s,n,r=new Map;for(let a=0;a<t.length;a++)i=t[a],s=i[e],r.has(s)?n=r.get(s):r.set(s,n=[]),n.push(i);return Array.from(r.entries())}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=y.get(t,this.options);if(i.handleMultiSegments){return{type:t,chunk:i.handleMultiSegments(e)}}return e[0]})}async createParsers(){let t=this.mergedAppSegments||this.appSegments;for(let e of t){let{type:t,chunk:i}=e;if(!this.options[t].enabled)continue;let s=this.parsers[t];if(s&&s.append);else if(!s){let e=new(y.get(t,this.options))(i,this.options,this.file);this.parsers[t]=e}}}getSegment(t){return this.appSegments.find(e=>e.type===t)}async getOrFindSegment(t){let e=this.getSegment(t);return void 0===e&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}});const st=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class nt extends ${parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw f("Invalid EXIF data: expected byte order marker (0x4949 or 0x4D4D).");this.le=!1}if(this.chunk.le=this.le,42!==this.chunk.getUint16(2))throw f("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:s,skip:n}=this.options[e];s=new Set(s);let r=s.size>0,a=0===n.size,h=this.chunk.getUint16(t);t+=2;for(let f=0;f<h;f++){let h=this.chunk.getUint16(t);if(r){if(s.has(h)&&(i.set(h,this.parseTag(t,h,e)),s.delete(h),0===s.size))break}else!a&&n.has(h)||i.set(h,this.parseTag(t,h,e));t+=12}return i}parseTag(t,e,i){let s=this.chunk.getUint16(t+2),n=this.chunk.getUint32(t+4),r=st[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw f("Invalid TIFF value type. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t));if(t>this.chunk.byteLength)throw f("Invalid TIFF value offset. block: ".concat(i.toUpperCase(),", tag: ").concat(e.toString(16),", type: ").concat(s,", offset ").concat(t," is outside of chunk size ").concat(this.chunk.byteLength));if(1===s)return this.chunk.getUint8Array(t,n);if(2===s)return""===(a=function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t}(a=this.chunk.getString(t,n)).trim())?void 0:a;var a;if(7===s)return this.chunk.getUint8Array(t,n);if(1===n)return this.parseTagValue(s,t);{let e=new(function(t){switch(t){case 1:return Uint8Array;case 3:return Uint16Array;case 4:return Uint32Array;case 5:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 10:return Array;case 11:return Float32Array;case 12:return Float64Array;default:return Array}}(s))(n),i=r;for(let r=0;r<n;r++)e[r]=this.parseTagValue(s,t),t+=i;return e}}parseTagValue(t,e){switch(t){case 1:return this.chunk.getUint8(e);case 3:return this.chunk.getUint16(e);case 4:return this.chunk.getUint32(e);case 5:return this.chunk.getUint32(e)/this.chunk.getUint32(e+4);case 6:return this.chunk.getInt8(e);case 8:return this.chunk.getInt16(e);case 9:return this.chunk.getInt32(e);case 10:return this.chunk.getInt32(e)/this.chunk.getInt32(e+4);case 11:return this.chunk.getFloat(e);case 12:return this.chunk.getDouble(e);case 13:return this.chunk.getUint32(e);default:throw f("Invalid tiff type ".concat(t))}}}class rt extends nt{static canHandle(t,e){return 225===t.getUint8(e+1)&&1165519206===t.getUint32(e+4)&&0===t.getUint16(e+8)}async parse(){return this.parseHeader(),this.options.ifd0.enabled&&await this.parseIfd0Block(),this.options.exif.enabled&&await this.parseExifBlock().catch(this.handleError),this.options.gps.enabled&&await this.parseGpsBlock().catch(this.handleError),this.options.interop.enabled&&await this.parseInteropBlock().catch(this.handleError),this.options.ifd1.enabled&&await this.parseThumbnailBlock().catch(this.handleError),this.createOutput()}findIfd0Offset(){void 0===this.ifd0Offset&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(void 0===this.ifd1Offset){this.findIfd0Offset();let t=this.chunk.getUint16(this.ifd0Offset),e=this.ifd0Offset+2+12*t;this.ifd1Offset=this.chunk.getUint32(e)}}parseBlock(t,e){let i=new Map;return this[e]=i,this.parseTags(t,e,i),i}async parseIfd0Block(){if(this.ifd0)return;if(this.findIfd0Offset(),this.ifd0Offset<8)throw f("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw f("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset,", file.byteLength: ").concat(this.file.byteLength));this.file.isTiff&&await this.file.ensureChunk(this.ifd0Offset,o(this.options));let t=this.parseBlock(this.ifd0Offset,"ifd0");return 0!==t.size?(this.exifOffset=t.get(34665),this.interopOffset=t.get(40965),this.gpsOffset=t.get(34853),this.xmp=t.get(700),this.iptc=t.get(33723),this.icc=t.get(34675),this.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t):void 0}async ensureBlockChunk(t,e){this.file.isTiff&&await this.file.ensureChunk(t,e),t>this.chunk.byteLength&&(this.chunk=d.from(this.file,this.le))}async parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.isTiff&&await this.file.ensureChunk(this.exifOffset,o(this.options));let t=this.parseBlock(this.exifOffset,"exif");return this.interopOffset||(this.interopOffset=t.get(40965)),this.makerNote=t.get(37500),this.userComment=t.get(37510),this.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),this.unpack(t,41728),this.unpack(t,41729),t}unpack(t,e){let i=t.get(e);i&&1===i.length&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.gpsOffset)return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",at(...t.get(2),t.get(1))),t.set("longitude",at(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||this.parseExifBlock(),void 0!==this.interopOffset))return this.parseBlock(this.interopOffset,"interop")}async parseThumbnailBlock(t=!1){if(!this.ifd1&&!this.ifd1Parsed&&(!this.options.mergeOutput||t))return this.findIfd1Offset(),this.ifd1Offset>0&&(this.parseBlock(this.ifd1Offset,"ifd1"),this.ifd1Parsed=!0),this.ifd1}async extractThumbnail(){if(this.headerParsed||this.parseHeader(),this.ifd1Parsed||await this.parseThumbnailBlock(!0),void 0===this.ifd1)return;let t=this.ifd1.get(513),e=this.ifd1.get(514);return this.chunk.getUint8Array(t,e)}get image(){return this.ifd0}get thumbnail(){return this.ifd1}createOutput(){let t,e,i,s={};for(e of L)if(t=this[e],!h(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if("ifd1"===e)continue;Object.assign(s,i)}else s[e]=i;return this.makerNote&&(s.makerNote=this.makerNote),this.userComment&&(s.userComment=this.userComment),s}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,s]of Object.entries(e))this.assignObjectToOutput(t,i,s)}}function at(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}r(rt,"type","tiff"),r(rt,"headerLength",10),y.set("tiff",rt),t.Exifr=X,t.Options=N,t.allFormatters=E,t.chunkedProps=V,t.createDictionary=function(t,e,i){let s=new A(i);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s},t.disableAllOptions=K,t.extendDictionary=function(t,e,i){let s,n=t.get(e);for(s of i)n.set(s[0],s[1])},t.fetchUrlAsArrayBuffer=O,t.fileParsers=g,t.fileReaders=b,t.gps=async function(t){let e=new X(G);await e.read(t);let i=await e.parse();if(i&&i.gps){let{latitude:t,longitude:e}=i.gps;return{latitude:t,longitude:e}}},t.gpsOnlyOptions=G,t.inheritables=j,t.orientation=async function(t){let e=new X(J);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]},t.orientationOnlyOptions=J,t.otherSegments=I,t.parse=async function(t,e){let i=new X(e);return await i.read(t),i.parse()},t.readBlobAsArrayBuffer=v,t.segmentParsers=y,t.segments=T,t.segmentsAndBlocks=z,t.tagKeys=x,t.tagRevivers=B,t.tagValues=C,t.thumbnail=async function(t,i={}){i.ifd1=!0,i.mergeOutput=!0;let s=new X(i);await s.read(t);let n=await s.extractThumbnail();return n&&e?Buffer.from(n):n},t.thumbnailUrl=async function(...t){let e=await this.thumbnail(...t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}},t.tiffBlocks=L,t.tiffExtractables=F,Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "exifr",
"version": "3.0.1",
"version": "4.0.0",
"description": "📷 The fastest and most versatile JavaScript EXIF reading library.",

@@ -5,0 +5,0 @@ "author": "Mike Kovarik",

@@ -7,3 +7,3 @@ <img src="https://raw.githubusercontent.com/MikeKovarik/exifr/master/logo/blue-small.png" width="160" alt="exifr">

[![Dependency Status](https://david-dm.org/MikeKovarik/exifr.svg)](https://david-dm.org/MikeKovarik/exifr)
[![jsDelivr downloads](https://data.jsdelivr.com/v1/package/npm/exifr/badge?style=rounded)](https://www.jsdelivr.com/package/npm/exifr)
[![jsDelivr downloads](https://data.jsdelivr.com/v1/package/npm/exifr/badge?style=rounded)](https://www.jsdelivr.com/package/npm/exifr?path=dist)
[![npm downloads size](https://img.shields.io/npm/dm/exifr)](https://npmjs.org/package/exifr)

@@ -21,2 +21,6 @@ [![NPM Version](https://img.shields.io/npm/v/exifr.svg?style=flat)](https://npmjs.org/package/exifr)

[Performance](#performance)
[FAQ](#faq)
[Contributing](#contributing)

@@ -35,3 +39,3 @@ 📷 The fastest and most versatile JavaScript EXIF reading library.

* 🗃️ **Any input**: buffers, url, &lt;img&gt; tag, and more
* 📷 Files: **.jpg**, **.tif**, **.heic** photos
* 📷 Files: **.jpg**, **.tif**, **.heic**
* 🔎 Segments: **TIFF** (EXIF, GPS, etc...), **XMP**, **ICC**, **IPTC**, **JFIF**

@@ -51,2 +55,17 @@ * 📑 **Reads only first few bytes**

<details>
<summary>and more (click to expand)</summary>
<ul>
<li>XMP Parser - minimalistic, reliable, without dependencies</li>
<li>XMP Extended</li>
<li>Multi-segment ICC</li>
<li>Extracts all ICC tags (RedMatrixColumn, GreenTRC, B2A2, etc...)</li>
<li>TIFF dictionaries contain less frequently used, non-standard and proprietary TIFF/EXIF tags (only in full bundle)</li>
<li>Handles UCS2 formatted strings (XPTitle tag), instead of leaving it as a buffer</li>
<li>Normalizes strings</li>
<li>Revives dates into Date class instances</li>
<li>Converts GPS coords from DMS to DD format. From `<code>GPSLatitude</code>, <code>GPSLatitudeRef</code> tags (<code>[50, 17, 58.57]</code> & <code>"N"</code>) to single <code>latitude</code> value (<code>50.29960</code>).</li>
</ul>
</details>
You don't need to read the whole file to tell if there's EXIF in it. And you don't need to extract all the data when you're looking for just a few tags. Exifr just jumps through the file structure, from pointer to pointer. Instead of reading it byte by byte, from beginning to end.

@@ -99,3 +118,3 @@

`mini` and `lite` are recommended for browsers because of balance between features and file size.
`lite` and `mini` are recommended for browsers because of balance between features and file size.

@@ -107,4 +126,4 @@ Need to support older browsers? Use `legacy` build along with polyfills. Learn more about IE11 at [examples/legacy.html](examples/legacy.html).

* **full** - Contains everything. Intended for use in Node.js.
* **lite** - Reads JPEG and HEIC. Parses TIFF/EXIF and XMP. Includes chunked reader.
* **mini** - Stripped down to basics. Parses most useful TIFF/EXIF from JPEGs. No dictionaries.
* **lite** - Reads JPEG and HEIC. Parses TIFF/EXIF and XMP.
* **mini** - Stripped down to basics. Parses most useful TIFF/EXIF from JPEGs. **Has no tag dictionaries**.
* **core** - Contains nothing. It's up to you to import readers, parser and dictionaries you need.

@@ -114,3 +133,2 @@

<details>

@@ -121,3 +139,3 @@ <summary><b>Detailed comparison (click to expand)</b></summary>

|-----------------|------|------|------|------|
| chunked<br>file readers | BlobReader<br>UrlFetcher<br>FsReader<br>Base64Reader | BlobReader<br>UrlFetcher | BlobReader | none |
| chunked<br>file readers | BlobReader<br>UrlFetcher<br>FsReader<br>Base64Reader | BlobReader<br>UrlFetcher | BlobReader | none |
| file parsers | `*.jpg`<br>`*.heic`<br>`*.tif` | `*.jpg`<br>`*.heic` | `*.jpg` | none |

@@ -207,8 +225,15 @@ | segment<br>parsers | TIFF (EXIF)<br>IPTC<br>XMP<br>ICC<br>JFIF | TIFF (EXIF)<br>XMP | TIFF (EXIF) | none |

* [playground](https://mutiny.cz/exifr)
* [**playground**](https://mutiny.cz/exifr)
* [examples/thumbnail.html](https://mutiny.cz/exifr/examples/thumbnail.html), [code](examples/thumbnail.html)
<br>Extracts and displays embedded thumbnail.
* [examples/depth-map-extraction.html](https://mutiny.cz/exifr/examples/depth-map-extraction.html), [code](examples/depth-map-extraction.js)
<br>Extracts and displays depth map.
* [benchmark/gps-dnd.html](https://mutiny.cz/exifr/benchmark/gps-dnd.html), [code](benchmark/gps-dnd.html)
<br>Drag-n-Drop multiple photos and mesure the time and RAM it took to extract GPS. Then they're marked on a map.
* [examples/worker.html](https://mutiny.cz/exifr/examples/worker.html), [code](examples/worker.html)
* [examples/legacy.html](https://mutiny.cz/exifr/examples/legacy.html), [code](examples/legacy.html) (view this in IE11)
* [benchmark/formats-reading.html](https://mutiny.cz/exifr/benchmark/formats-reading.html), [code](benchmark/formats-reading.html) (tests speed of processing of various input types)
* [benchmark/gps-dnd.html](https://mutiny.cz/exifr/benchmark/gps-dnd.html), [code](benchmark/gps-dnd.html) (Drag-n-Drop multiple photos and mesure the time it takes to extract GPS)
<br>Parsing file in WebWorker.
* [examples/legacy.html](https://mutiny.cz/exifr/examples/legacy.html), [code](examples/legacy.html)
<br>Visit in IE11,
* [benchmark/formats-reading.html](https://mutiny.cz/exifr/benchmark/formats-reading.html), [code](benchmark/formats-reading.html)
<br>Compares reading speed of various input types.

@@ -229,3 +254,3 @@ and a lot more in the [examples/](examples/) folder

Extracts only GPS coordinates from a photo.
Only extracts GPS coordinates.

@@ -239,3 +264,3 @@ *Uses `pick`/`skip` filters and perf improvements to only extract latitude and longitude tags from GPS block. And to get GPS-IFD pointer it only scans through IFD0 without reading any other unrelated data.*

Extracts only photo's orientation.
Only extracts photo's orientation.

@@ -413,2 +438,58 @@ ### `thumbnail(file)`

#### XMP
Extracted XMP tags are grouped by namespace. Each ns is separate object in `output`. E.g. `output.xmlns`, `output.GPano`, `output.crs`, etc...
For XMP Extended see [`options.multiSegment`](#optionsmultisegment)
*Exifr contains minimalistic opinionated XML parser for parsing data from XMP. It may not be 100% spec-compliant, because XMP is based on XML which cannot be translated 1:1 to JSON. The output is opinionated and may alter or simplify the data structure. If the XMP parser doesn't suit you, it can be disabled by setting `options.xmp.parse` to `false`. Then a raw XMP string will be available at `output.xmp`.*
##### Caveats & XML to JSON mapping
1) Tags with both attributes and children-value are combined into object.
2) Arrays (RDF Containers) with single item are unwrapped. The single item is used in place of the array.
2) If `options.mergeOutput:false`: Tags of `tiff` namespace (`<tiff:Model>`) are merged into `output.ifd0`. Likewise `exif` ns is merged into `output.exif`.
```xml
<rdf:Description foo:name="Exifr">
<foo:author>Mike Kovařík</foo:author>
<foo:description xml:lang="en-us">Some string here</foo:description>
<foo:formats><rdf:Seq><rdf:li>jpeg</rdf:li></rdf:Seq></foo:formats>
<foo:segments><rdf:Seq><rdf:li>xmp</rdf:li><rdf:li>tiff</rdf:li><rdf:li>iptc</rdf:li></rdf:Seq></foo:segments>
</rdf:Description>
```
parses as:
```js
{
name: 'Exifr', // attribute belonging to the same namespace
author: 'Mike Kovařík', // simple tag of the namespace
description: {lang: 'en-us', value: 'Some string here'}, // tag with attrs and value becomes object
formats: 'jpeg', // single item array is unwrapped
segments: ['xmp', 'tiff', 'iptc'] // array as usual
}
```
#### `options.multiSegment`
Type: `bool`
<br>
Default: `false`
Enables looking for more than just a single segment of ICC or XMP (XMP Extended).
*In some rare cases the photo can contain additional layers, embedded images, or metadata that doesn't fit inside single 64kB (JPEG) segment.*
Side effect: Disables chunked reading. The whole file has to be read to locate all segments.
When is it useful:
* VR photos with combination of left/right eye (XMP Extended)
* "Portrait mode" photo that contains depth map (XMP Extended)
* Photos with custom ICC color profile
Sub-options:
* `options.xmp.multiSegment`
* `options.icc.multiSegment`
#### Shortcuts

@@ -440,16 +521,9 @@

{
exif: true,
gps: true,
exif: true, gps: true,
pick: ['FNumber', 'ISO', 'GPSLatitude', 0x0004] // 0x0004 is GPSLongitude
}
// is a shortcut for
{
exif: ['FNumber', 'ISO'],
gps: ['GPSLatitude', 0x0004]
}
{exif: ['FNumber', 'ISO'], gps: ['GPSLatitude', 0x0004]}
// which is another shortcut for
{
exif: {pick: ['FNumber', 'ISO']},
gps: {pick: ['GPSLatitude', 0x0004]}
}
{exif: {pick: ['FNumber', 'ISO']}, gps: {pick: ['GPSLatitude', 0x0004]}}
```

@@ -495,3 +569,3 @@

This limit is bypassed if multi-segment segments ocurs in the file and if `options.multiSegment` allows reading all of them.
This limit is bypassed if multi-segment segments ocurs in the file and if [`options.multiSegment`](#optionsmultisegment) allows reading all of them.

@@ -871,8 +945,32 @@ *If the exif isn't found within N chunks (64\*5 = 320KB) it probably isn't in the file and it's not worth reading anymore.*

## Notable breaking changes, migration from 2.x.x
## Breaking changes & migration
see [`CHANGELOG.md`](CHANGELOG.md)
See [`CHANGELOG.md`](CHANGELOG.md)
## F.A.Q.
<details>
<summary><b>Why are there different kB sizes on npm, bundlephobia, and badge in the readme?</b></summary>
**TL;DR:** Because exifr comes in four bundles, each in three variants, plus source codes are included.
**npm** (~588 kB): The module includes both `src/` and `dist/`. That source codes of all the readers, parsers and dictionaries. Multiplied by 4 bundles (*full*, *lite*, *mini*, *core*). Then multiplied by 3 bundle formats (*ESM*, *UMD*, *legacy* for IE11). But you will never use all of the files. They're there so you can choose what's best for your project.
**bundlephobia** (~63/22 kB): *Full* build is the `"main"` entry point (in `package.json`) picked up by Node and bundlephobia. But it's meant for use in Node where size doesn't matter.
**badge in readme** (~9 kB, ~30 files): The badge points to *mini* bundle which contains the bare minimum needed to cover the most use-cases (get orientation, coords, exif info, etc...). This is meant for browsers where file size matters.
</details>
## Contributing
Contributions are welcome in any form. Suggestions, bug reports, docs improvements, new tests or even feature PRs. Don't be shy, I don't bite.
If you're filing a bug, please include the problematic photo. Or better yet write a test.
If you're creating a PR, please run the tests:
* in browser by visiting `/test/index.html` (*uses import maps, you may need to enable experimental flags in your browser*)
* in Node.js by running `npm run test`
## License
MIT, Mike Kovařík, Mutiny.cz

@@ -12,3 +12,7 @@ import {read} from './reader.js'

function isHeic(file) {
let ftypLength = file.getUint32(0)
// FTYP length is the first 32b but it's not likely there will be more than 30, let alone 2^32 FTYPs.
// So it's safe to assume that if first two bytes are 0, then this is HEIC.
if (file.getUint16(0) !== 0) return false
let ftypLength = file.getUint16(2)
if (ftypLength > 50) return false
let offset = 16

@@ -63,3 +67,2 @@ let compatibleBrands = []

let output = {}
let {mergeOutput} = this.options
let errors = []

@@ -80,6 +83,3 @@ let promises = Object.values(this.parsers).map(async parser => {

}
if ((mergeOutput || parser.constructor.mergeOutput) && typeof parserOutput !== 'string')
Object.assign(output, parserOutput)
else if (parserOutput !== undefined)
output[parser.constructor.type] = parserOutput
parser.assignToOutput(output, parserOutput)
})

@@ -86,0 +86,0 @@ await Promise.all(promises)

@@ -27,3 +27,3 @@ import {TAG_MAKERNOTE, TAG_USERCOMMENT} from './tags.js'

export const inheritables = ['translateKeys', 'translateValues', 'reviveValues', 'multiSegment']
export const allFormatters = [...inheritables, 'mergeOutput', 'sanitize']
export const allFormatters = [...inheritables, 'sanitize', 'mergeOutput']

@@ -59,3 +59,4 @@

this.key = key
this.enabled = defaultValue
this.enabled = defaultValue // todo: rename to extract
this.parse = this.enabled

@@ -70,3 +71,3 @@ this.applyInheritables(parent)

if (Array.isArray(userValue)) {
this.enabled = true
this.parse = this.enabled = true
if (this.canBeFiltered && userValue.length > 0)

@@ -76,2 +77,3 @@ this.translateTagSet(userValue, this.pick)

this.enabled = true
this.parse = userValue.parse !== false
if (this.canBeFiltered) {

@@ -84,3 +86,3 @@ let {pick, skip} = userValue

} else if (userValue === true || userValue === false) {
this.enabled = userValue
this.parse = this.enabled = userValue
} else {

@@ -90,2 +92,3 @@ throw customError(`Invalid options argument: ${userValue}`)

}
}

@@ -92,0 +95,0 @@

@@ -66,4 +66,2 @@ import {BufferView} from './util/BufferView.js'

static type = undefined
// output is merged into library output or is assigned with parser id
static mergeOutput = false
// The data may span multiple APP segments.

@@ -74,4 +72,2 @@ static multiSegment = false

errors = []
// offset + length === end | begining and end of the whole segment, including the segment header 0xFF 0xEn + two lenght bytes.

@@ -82,28 +78,36 @@ // start + size === end | begining and end of parseable content

let length = buffer.getUint16(offset + 2) + 2
let headerLength = typeof this.headerLength === 'function' ? this.headerLength(buffer, offset, length) : this.headerLength
let headerLength = typeof this.headerLength === 'function'
? this.headerLength(buffer, offset, length)
: this.headerLength
let start = offset + headerLength
let size = length - headerLength
let end = start + size
return {offset, length, start, size, end}
return {offset, length, headerLength, start, size, end}
}
static parse(buffer, start, options) {
if (typeof start === 'object') {
options = start
start = undefined
}
let view = new BufferView(buffer, start)
let instance = new this(view, Options.useCached(options))
static parse(input, segOptions = {}) {
let options = new Options({[this.type]: segOptions})
let instance = new this(input, options)
return instance.parse()
}
normalizeInput(input) {
return input instanceof BufferView
? input
: new BufferView(input)
}
errors = []
// raw parsed tags
raw = new Map
constructor(chunk, options = {}, file) {
this.chunk = chunk
this.options = options
// BufferView instance of the segment chunk. Possibly a subview of the same memory shared with this.file
this.chunk = this.normalizeInput(chunk)
// BufferView instance of the whole file.
this.file = file
this.type = this.constructor.type
this.segOptions = options[this.type]
this.canTranslate = this.segOptions.translate
// raw parsed tags
this.raw = new Map
this.globalOptions = this.options = options // todo: rename to fileOptions ???
this.localOptions = options[this.type] // todo: rename to this.options
this.canTranslate = this.localOptions && this.localOptions.translate
}

@@ -129,3 +133,3 @@

let keyDict = tagKeys.get(blockKey)
let blockOptions = this.options[blockKey]
let blockOptions = this.options[blockKey] // todo: refactor tiff so this isn't needed anymore (in favor of segOptions & options)
let canRevive = blockOptions.reviveValues && revivers

@@ -159,2 +163,15 @@ let canTranslateVal = blockOptions.translateValues && valDict

assignToOutput(root, parserOutput) {
this.assignObjectToOutput(root, this.constructor.type, parserOutput)
}
assignObjectToOutput(root, key, parserOutput) {
if (this.globalOptions.mergeOutput)
return Object.assign(root, parserOutput)
if (root[key])
Object.assign(root[key], parserOutput)
else
root[key] = parserOutput
}
}

@@ -161,0 +178,0 @@

import {customError} from './util/helpers.js'
import {fixIeSubclassing} from './util/ieFix.js'

@@ -38,18 +39,2 @@

export function fixIeSubclassing(target, Class, methods = [], getters = []) {
// Hack to get IE11 to work. IE11 has builtin Map but it doesn't support subclassing.
// PluginList doesn't change behavior of .get(), we just add checks that throw if key was not found.
// IE wont throw these errors but will work. I'm ok with this regression.
// We just need to copy additional custom method.
for (let key of methods)
if (target[key] === undefined) target[key] = Class.prototype[key]
for (let key of getters) {
let targetDesc = Object.getOwnPropertyDescriptor(target, key)
if (targetDesc === undefined) {
let protoDesc = Object.getOwnPropertyDescriptor(Class.prototype, key)
Object.defineProperty(target, key, protoDesc)
}
}
}
export var fileParsers = new PluginList('file parser')

@@ -56,0 +41,0 @@ export var segmentParsers = new PluginList('segment parser')

@@ -1,2 +0,2 @@

import {fixIeSubclassing} from './plugins.js'
import {fixIeSubclassing} from './util/ieFix.js'

@@ -3,0 +3,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc