Comparing version 4.3.3 to 4.3.4
@@ -11,3 +11,7 @@ # Changelog | ||
- d.ts types | ||
- IE10 DataView related bug | ||
### Added | ||
- `.cjs` copy of all `legacy` builds in dist/. | ||
## [4.3.0] | ||
@@ -14,0 +18,0 @@ |
@@ -1,1 +0,1 @@ | ||
function e(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let t="undefined"!=typeof self?self:global;var i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let r=t.Buffer,a=t.BigInt;var o=!!r;function h(e){return f(e)?void 0:e}const l=e=>void 0!==e;function f(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(l).length)}function u(e){let t=new Error(e);return delete t.stack,t}function d(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function c(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}const g=new TextDecoder("utf-8");function p(e){return g.decode(e)}class m{static from(e,t){return e instanceof this&&e.le===t?e:new m(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 m){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw u("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 u("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=m){if(e instanceof DataView||e instanceof m?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw u("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 m(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 p(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 a)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),a(t)<<a(32)|a(i);throw u("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 y(e,t){throw u("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class b extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||y(this.kind,e),t&&(e in t||function(e,t){throw u("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||y(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var w=new b("file parser"),k=new b("segment parser"),S=new b("file reader");function v(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return O(e,t,"url",C);if(n)return x(e,t,"fs");throw u("Invalid input argument");var s}async function O(e,t,i,s){if(S.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new m(i)}(e,s);throw u("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(S.get(i))(e,t);return await s.read(),s}async function C(e){return fetch(e).then(e=>e.arrayBuffer())}async function A(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class U extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function B(e,t,i){let s=new U;for(let[e,t]of i)s.set(e,t);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 I=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],V=["ifd0","ifd1","exif","gps","interop"],N=[...z,...V],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],R=[...E,"sanitize","mergeOutput"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends j{get needed(){return this.enabled||this.deps.size>0}constructor(t,i,s,n){if(super(),e(this,"enabled",!1),e(this,"skip",new Set),e(this,"pick",new Set),e(this,"deps",new Set),e(this,"translateKeys",!1),e(this,"translateValues",!1),e(this,"reviveValues",!1),this.key=t,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=V.includes(t),this.canBeFiltered&&(this.dict=I.get(t)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:e,skip:t}=s;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw u("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){if(this.dict){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)}else for(let i of e)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},_=new Map;class W 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 u("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 R)this[e]=H[e];for(e of M)this[e]=H[e];for(e of N)this[e]=new G(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of R)this[e]=H[e];for(e of M)this[e]=!0;for(e of N)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of R)this[t]=H[t];for(t of M)this[t]=H[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),T))this[t]=X(e[t],H[t]);for(t of R)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 V)this[t]=new G(t,H[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=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=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 z)this[e].enabled&&!k.has(e)&&y("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=I.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)}e(W,"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]}),Q=Object.assign({},q,{tiff:!1,ifd1:!0,mergeOutput:!1});class ${constructor(t){e(this,"parsers",{}),this.options=W.useCached(t)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=w.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=w.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 u("Unknown file format");this.file.isHeic=!0,e=w.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 v(e,t);if(i&&!s&&e instanceof HTMLImageElement)return v(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new m(e);if(i&&e instanceof Blob)return O(e,t,"blob",A);throw u("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=h(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=k.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 ee(e,t){let i=new $(t);return await i.read(e),i.parse()}async function te(e){let t=new $(Q);await t.read(e);let i=await t.extractThumbnail();return i&&o?r.from(i):i}async function ie(e){let t=await this.thumbnail(e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function se(e){let t=new $(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 ne(e){let t=new $(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}var re=Object.freeze({__proto__:null,parse:ee,thumbnail:te,thumbnailUrl:ie,gps:se,orientation:ne,Exifr:$,fileParsers:w,segmentParsers:k,fileReaders:S,tagKeys:I,tagValues:F,tagRevivers:L,createDictionary:B,extendDictionary:P,fetchUrlAsArrayBuffer:C,readBlobAsArrayBuffer:A,chunkedProps:T,otherSegments:D,segments:z,tiffBlocks:V,segmentsAndBlocks:N,tiffExtractables:M,inheritables:E,allFormatters:R,Options:W,disableAllOptions:q,gpsOnlyOptions:Y,orientationOnlyOptions:Z,thumbnailOnlyOptions:Q});class ae extends m{constructor(...t){super(...t),e(this,"ranges",new oe),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 t;t=o?r.allocUnsafe(e):new Uint8Array(e);let i=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:i}}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 oe{constructor(){e(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>he(e,t.offset,s)||he(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 he(e,t,i){return e<=t&&t<=i}class le extends ae{constructor(t,i){super(0),e(this,"chunksRead",0),this.input=t,this.options=i}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(){}}S.set("blob",class extends le{async readWhole(){this.chunked=!1;let e=await A(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 A(s);return this.set(n,e,!0)}});class fe{constructor(t,i,s){e(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 u("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 u("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=i,this.parsers=s}createParser(e,t){let i=new(k.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class ue{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 W({[this.type]:t})).parse()}normalizeInput(e){return e instanceof m?e:new m(e)}constructor(t,i={},s){e(this,"errors",[]),e(this,"raw",new Map),e(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(t),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=I.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}}e(ue,"headerLength",4),e(ue,"type",void 0),e(ue,"multiSegment",!1),e(ue,"canHandle",()=>!1);function de(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ce(e){return e>=224&&e<=239}function ge(e,t){for(let[i,s]of k)if(s.canHandle(e,t))return i}w.set("jpeg",class extends fe{constructor(...t){super(...t),e(this,"appSegments",[]),e(this,"jpegSegments",[]),e(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(k.keyList())):(e=void 0===e?k.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&k.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&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=k.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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),ce(i)){if(s=h.getUint16(e+2),n=ge(h,e),n&&f.has(n)&&(r=k.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=ue.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(de(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)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=k.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(k.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 pe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class me extends ue{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw u("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 u("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=pe[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw u("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 u("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 d(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 u("Invalid tiff type ".concat(e))}}}class ye extends me{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}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 u("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw u("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,c(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=m.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,c(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",be(...e.get(2),e.get(1))),e.set("longitude",be(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!f(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 be(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}e(ye,"type","tiff"),e(ye,"headerLength",10),k.set("tiff",ye);var we=Object.freeze({__proto__:null,default:re,parse:ee,thumbnail:te,thumbnailUrl:ie,gps:se,orientation:ne,Exifr:$,fileParsers:w,segmentParsers:k,fileReaders:S,tagKeys:I,tagValues:F,tagRevivers:L,createDictionary:B,extendDictionary:P,fetchUrlAsArrayBuffer:C,readBlobAsArrayBuffer:A,chunkedProps:T,otherSegments:D,segments:z,tiffBlocks:V,segmentsAndBlocks:N,tiffExtractables:M,inheritables:E,allFormatters:R,Options:W,disableAllOptions:q,gpsOnlyOptions:Y,orientationOnlyOptions:Z,thumbnailOnlyOptions:Q});S.set("url",class extends le{async readWhole(){this.chunked=!1;let e=await C(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 ke extends fe{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}}w.set("heic",class extends ke{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(I,["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(I,"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(I,"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 Se=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 ve={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Se.set(37392,ve),Se.set(41488,ve);const Oe={0:"Normal",1:"Low",2:"High"};function xe(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 Ce(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 Ae(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(Ue(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Ue(e[i],e[i+1]));return d(String.fromCodePoint(...t))}function Ue(e,t){return e<<8|t}Se.set(41992,Oe),Se.set(41993,Oe),Se.set(41994,Oe),B(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?p(e):e}],[306,Ce],[40091,Ae],[40092,Ae],[40093,Ae],[40094,Ae],[40095,Ae]]),B(L,"exif",[[40960,xe],[36864,xe],[36867,Ce],[36868,Ce]]),B(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Be extends ue{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(Ne,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Ie.findAll(e,"rdf","Description");0===t.length&&t.push(new Ie("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=De(t.ns,s),Fe(t,i);return function(e){let t;for(let i in e)t=e[i]=h(e[i]),void 0===t&&delete e[i];return h(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}}e(Be,"type","xmp"),e(Be,"multiSegment",!0),k.set("xmp",Be);class Pe{static findAll(e){return ze(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Pe.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Ve(s),new Pe(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Ie{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 ze(e,s).map(Ie.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Ie(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Pe.findAll(i),this.children=Ie.findAll(s),this.value=0===this.children.length?Ve(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 Te(this.children.map(Le));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Fe(t,e);return void 0!==this.value&&(e.value=this.value),h(e)}}function Fe(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Le=e=>e.serialize(),Te=e=>1===e.length?e[0]:e,De=(e,t)=>t[e]?t[e]:t[e]={};function ze(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ve(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 Ne=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;export default we;export{$ as Exifr,W as Options,R as allFormatters,T as chunkedProps,B as createDictionary,q as disableAllOptions,P as extendDictionary,C as fetchUrlAsArrayBuffer,w as fileParsers,S as fileReaders,se as gps,Y as gpsOnlyOptions,E as inheritables,ne as orientation,Z as orientationOnlyOptions,D as otherSegments,ee as parse,A as readBlobAsArrayBuffer,k as segmentParsers,z as segments,N as segmentsAndBlocks,I as tagKeys,L as tagRevivers,F as tagValues,te as thumbnail,Q as thumbnailOnlyOptions,ie as thumbnailUrl,V as tiffBlocks,M as tiffExtractables}; | ||
function e(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let t="undefined"!=typeof self?self:global;var i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let r=t.Buffer,a=t.BigInt;var o=!!r;function h(e){return f(e)?void 0:e}const l=e=>void 0!==e;function f(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(l).length)}function u(e){let t=new Error(e);return delete t.stack,t}function d(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function c(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}const g=new TextDecoder("utf-8");function p(e){return g.decode(e)}class m{static from(e,t){return e instanceof this&&e.le===t?e:new m(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){void 0===i&&(i=e.byteLength-t);let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof m){if(void 0===i&&(i=e.byteLength-t),(t+=e.byteOffset)+i>e.byteOffset+e.byteLength)throw u("Creating view outside of available memory in ArrayBuffer");let s=new DataView(e.buffer,t,i);this._swapDataView(s)}else{if("number"!=typeof e)throw u("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=m){if(e instanceof DataView||e instanceof m?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw u("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 m(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 p(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 a)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),a(t)<<a(32)|a(i);throw u("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 y(e,t){throw u("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class b extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||y(this.kind,e),t&&(e in t||function(e,t){throw u("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||y(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var w=new b("file parser"),k=new b("segment parser"),S=new b("file reader");function v(e,t){if((s=e).startsWith("data:")||s.length>1e4)return x(e,t,"base64");if(i)return O(e,t,"url",C);if(n)return x(e,t,"fs");throw u("Invalid input argument");var s}async function O(e,t,i,s){if(S.has(i))return x(e,t,i);if(s)return async function(e,t){let i=await t(e);return new m(i)}(e,s);throw u("Parser ".concat(i," is not loaded"))}async function x(e,t,i){let s=new(S.get(i))(e,t);return await s.read(),s}async function C(e){return fetch(e).then(e=>e.arrayBuffer())}async function A(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class U extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function B(e,t,i){let s=new U;for(let[e,t]of i)s.set(e,t);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 I=new Map,F=new Map,L=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],D=["jfif","xmp","icc","iptc"],z=["tiff",...D],V=["ifd0","ifd1","exif","gps","interop"],N=[...z,...V],M=["makerNote","userComment"],E=["translateKeys","translateValues","reviveValues","multiSegment"],R=[...E,"sanitize","mergeOutput"];class j{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class G extends j{get needed(){return this.enabled||this.deps.size>0}constructor(t,i,s,n){if(super(),e(this,"enabled",!1),e(this,"skip",new Set),e(this,"pick",new Set),e(this,"deps",new Set),e(this,"translateKeys",!1),e(this,"translateValues",!1),e(this,"reviveValues",!1),this.key=t,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=V.includes(t),this.canBeFiltered&&(this.dict=I.get(t)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:e,skip:t}=s;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw u("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(e){let t,i;for(t of E)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){if(this.dict){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)}else for(let i of e)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},_=new Map;class W 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 u("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 R)this[e]=H[e];for(e of M)this[e]=H[e];for(e of N)this[e]=new G(e,H[e],void 0,this)}setupFromTrue(){let e;for(e of T)this[e]=H[e];for(e of R)this[e]=H[e];for(e of M)this[e]=!0;for(e of N)this[e]=new G(e,!0,void 0,this)}setupFromArray(e){let t;for(t of T)this[t]=H[t];for(t of R)this[t]=H[t];for(t of M)this[t]=H[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),T))this[t]=X(e[t],H[t]);for(t of R)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 V)this[t]=new G(t,H[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=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=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 z)this[e].enabled&&!k.has(e)&&y("segment parser",e)}}function K(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=I.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)}e(W,"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]}),Q=Object.assign({},q,{tiff:!1,ifd1:!0,mergeOutput:!1});class ${constructor(t){e(this,"parsers",{}),this.options=W.useCached(t)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=w.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=w.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 u("Unknown file format");this.file.isHeic=!0,e=w.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 v(e,t);if(i&&!s&&e instanceof HTMLImageElement)return v(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new m(e);if(i&&e instanceof Blob)return O(e,t,"blob",A);throw u("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=h(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=k.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 ee(e,t){let i=new $(t);return await i.read(e),i.parse()}async function te(e){let t=new $(Q);await t.read(e);let i=await t.extractThumbnail();return i&&o?r.from(i):i}async function ie(e){let t=await this.thumbnail(e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function se(e){let t=new $(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 ne(e){let t=new $(Z);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}var re=Object.freeze({__proto__:null,parse:ee,thumbnail:te,thumbnailUrl:ie,gps:se,orientation:ne,Exifr:$,fileParsers:w,segmentParsers:k,fileReaders:S,tagKeys:I,tagValues:F,tagRevivers:L,createDictionary:B,extendDictionary:P,fetchUrlAsArrayBuffer:C,readBlobAsArrayBuffer:A,chunkedProps:T,otherSegments:D,segments:z,tiffBlocks:V,segmentsAndBlocks:N,tiffExtractables:M,inheritables:E,allFormatters:R,Options:W,disableAllOptions:q,gpsOnlyOptions:Y,orientationOnlyOptions:Z,thumbnailOnlyOptions:Q});class ae extends m{constructor(...t){super(...t),e(this,"ranges",new oe),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 t;t=o?r.allocUnsafe(e):new Uint8Array(e);let i=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:i}}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 oe{constructor(){e(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>he(e,t.offset,s)||he(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 he(e,t,i){return e<=t&&t<=i}class le extends ae{constructor(t,i){super(0),e(this,"chunksRead",0),this.input=t,this.options=i}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(){}}S.set("blob",class extends le{async readWhole(){this.chunked=!1;let e=await A(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 A(s);return this.set(n,e,!0)}});class fe{constructor(t,i,s){e(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 u("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 u("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=i,this.parsers=s}createParser(e,t){let i=new(k.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class ue{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 W({[this.type]:t})).parse()}normalizeInput(e){return e instanceof m?e:new m(e)}constructor(t,i={},s){e(this,"errors",[]),e(this,"raw",new Map),e(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(t),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=I.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}}e(ue,"headerLength",4),e(ue,"type",void 0),e(ue,"multiSegment",!1),e(ue,"canHandle",()=>!1);function de(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ce(e){return e>=224&&e<=239}function ge(e,t){for(let[i,s]of k)if(s.canHandle(e,t))return i}w.set("jpeg",class extends fe{constructor(...t){super(...t),e(this,"appSegments",[]),e(this,"jpegSegments",[]),e(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(k.keyList())):(e=void 0===e?k.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&k.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&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=k.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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),ce(i)){if(s=h.getUint16(e+2),n=ge(h,e),n&&f.has(n)&&(r=k.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=ue.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(de(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)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=k.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(k.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 pe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class me extends ue{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw u("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 u("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=pe[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw u("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 u("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 d(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 u("Invalid tiff type ".concat(e))}}}class ye extends me{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}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 u("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw u("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,c(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=m.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,c(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",be(...e.get(2),e.get(1))),e.set("longitude",be(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!f(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 be(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}e(ye,"type","tiff"),e(ye,"headerLength",10),k.set("tiff",ye);var we=Object.freeze({__proto__:null,default:re,parse:ee,thumbnail:te,thumbnailUrl:ie,gps:se,orientation:ne,Exifr:$,fileParsers:w,segmentParsers:k,fileReaders:S,tagKeys:I,tagValues:F,tagRevivers:L,createDictionary:B,extendDictionary:P,fetchUrlAsArrayBuffer:C,readBlobAsArrayBuffer:A,chunkedProps:T,otherSegments:D,segments:z,tiffBlocks:V,segmentsAndBlocks:N,tiffExtractables:M,inheritables:E,allFormatters:R,Options:W,disableAllOptions:q,gpsOnlyOptions:Y,orientationOnlyOptions:Z,thumbnailOnlyOptions:Q});S.set("url",class extends le{async readWhole(){this.chunked=!1;let e=await C(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 ke extends fe{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}}w.set("heic",class extends ke{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(I,["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(I,"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(I,"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 Se=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 ve={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Se.set(37392,ve),Se.set(41488,ve);const Oe={0:"Normal",1:"Low",2:"High"};function xe(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 Ce(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 Ae(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(Ue(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Ue(e[i],e[i+1]));return d(String.fromCodePoint(...t))}function Ue(e,t){return e<<8|t}Se.set(41992,Oe),Se.set(41993,Oe),Se.set(41994,Oe),B(L,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?p(e):e}],[306,Ce],[40091,Ae],[40092,Ae],[40093,Ae],[40094,Ae],[40095,Ae]]),B(L,"exif",[[40960,xe],[36864,xe],[36867,Ce],[36868,Ce]]),B(L,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Be extends ue{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(Ne,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Ie.findAll(e,"rdf","Description");0===t.length&&t.push(new Ie("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=De(t.ns,s),Fe(t,i);return function(e){let t;for(let i in e)t=e[i]=h(e[i]),void 0===t&&delete e[i];return h(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}}e(Be,"type","xmp"),e(Be,"multiSegment",!0),k.set("xmp",Be);class Pe{static findAll(e){return ze(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(Pe.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[3].slice(1,-1);return s=Ve(s),new Pe(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Ie{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 ze(e,s).map(Ie.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Ie(t,i,s,n)}constructor(e,t,i,s){this.ns=e,this.name=t,this.attrString=i,this.innerXml=s,this.attrs=Pe.findAll(i),this.children=Ie.findAll(s),this.value=0===this.children.length?Ve(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 Te(this.children.map(Le));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Fe(t,e);return void 0!==this.value&&(e.value=this.value),h(e)}}function Fe(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Le=e=>e.serialize(),Te=e=>1===e.length?e[0]:e,De=(e,t)=>t[e]?t[e]:t[e]={};function ze(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ve(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 Ne=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;export default we;export{$ as Exifr,W as Options,R as allFormatters,T as chunkedProps,B as createDictionary,q as disableAllOptions,P as extendDictionary,C as fetchUrlAsArrayBuffer,w as fileParsers,S as fileReaders,se as gps,Y as gpsOnlyOptions,E as inheritables,ne as orientation,Z as orientationOnlyOptions,D as otherSegments,ee as parse,A as readBlobAsArrayBuffer,k as segmentParsers,z as segments,N as segmentsAndBlocks,I as tagKeys,L as tagRevivers,F as tagValues,te as thumbnail,Q as thumbnailOnlyOptions,ie as thumbnailUrl,V 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";function t(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let i="undefined"!=typeof self?self:global;var s="undefined"!=typeof navigator,n=s&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let a=i.Buffer,o=i.BigInt;var h=!!a;function l(e){return u(e)?void 0:e}const f=e=>void 0!==e;function u(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(f).length)}function d(e){let t=new Error(e);return delete t.stack,t}function c(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function g(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}const p=new TextDecoder("utf-8");function m(e){return p.decode(e)}class y{static from(e,t){return e instanceof this&&e.le===t?e:new y(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 y){let{byteOffset:s,byteLength:n}=e;if(void 0===i&&(i=n-t),(t+=s)+i>s+n)throw d("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 d("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=y){if(e instanceof DataView||e instanceof y?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw d("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 y(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 m(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 o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw d("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 b(e,t){throw d("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class w extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||b(this.kind,e),t&&(e in t||function(e,t){throw d("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||b(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var k=new w("file parser"),S=new w("segment parser"),O=new w("file reader");function v(e,t){if((i=e).startsWith("data:")||i.length>1e4)return C(e,t,"base64");if(s)return x(e,t,"url",A);if(r)return C(e,t,"fs");throw d("Invalid input argument");var i}async function x(e,t,i,s){if(O.has(i))return C(e,t,i);if(s)return async function(e,t){let i=await t(e);return new y(i)}(e,s);throw d("Parser ".concat(i," is not loaded"))}async function C(e,t,i){let s=new(O.get(i))(e,t);return await s.read(),s}async function A(e){return fetch(e).then(e=>e.arrayBuffer())}async function B(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class P extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function U(e,t,i){let s=new P;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function I(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const F=new Map,L=new Map,D=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],V=["jfif","xmp","icc","iptc"],z=["tiff",...V],N=["ifd0","ifd1","exif","gps","interop"],M=[...z,...N],E=["makerNote","userComment"],R=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...R,"sanitize","mergeOutput"];class G{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class _ extends G{get needed(){return this.enabled||this.deps.size>0}constructor(e,i,s,n){if(super(),t(this,"enabled",!1),t(this,"skip",new Set),t(this,"pick",new Set),t(this,"deps",new Set),t(this,"translateKeys",!1),t(this,"translateValues",!1),t(this,"reviveValues",!1),this.key=e,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=F.get(e)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:e,skip:t}=s;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw d("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(e){let t,i;for(t of R)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){if(this.dict){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)}else for(let i of e)t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,q(this.pick,this.deps)):this.enabled&&this.pick.size>0&&q(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 K 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 d("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=s?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 E)this[e]=H[e];for(e of M)this[e]=new _(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 E)this[e]=!0;for(e of M)this[e]=new _(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 E)this[t]=H[t];for(t of M)this[t]=new _(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]=J(e[t],H[t]);for(t of j)this[t]=J(e[t],H[t]);for(t of E)this[t]=J(e[t],H[t]);for(t of z)this[t]=new _(t,H[t],e[t],this);for(t of N)this[t]=new _(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,M),!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=X(e,i);for(let[e,i]of t)q(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=X(t,i);for(let[t,i]of e)q(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!V.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!S.has(e)&&b("segment parser",e)}}function X(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=F.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 J(e,t){return void 0!==e?e:void 0!==t?t:void 0}function q(e,t){for(let i of t)e.add(i)}t(K,"default",H);const Y={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Z=Object.assign({},Y,{firstChunkSize:4e4,gps:[1,2,3,4]}),Q=Object.assign({},Y,{firstChunkSize:4e4,ifd0:[274]}),$=Object.assign({},Y,{tiff:!1,ifd1:!0,mergeOutput:!1});class ee{constructor(e){t(this,"parsers",{}),this.options=K.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=k.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=k.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 d("Unknown file format");this.file.isHeic=!0,e=k.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 v(e,t);if(s&&!n&&e instanceof HTMLImageElement)return v(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new y(e);if(s&&e instanceof Blob)return x(e,t,"blob",B);throw d("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=l(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=S.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 te(e,t){let i=new ee(t);return await i.read(e),i.parse()}async function ie(e){let t=new ee($);await t.read(e);let i=await t.extractThumbnail();return i&&h?a.from(i):i}async function se(e){let t=await this.thumbnail(e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function ne(e){let t=new ee(Z);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 re(e){let t=new ee(Q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}var ae=Object.freeze({__proto__:null,parse:te,thumbnail:ie,thumbnailUrl:se,gps:ne,orientation:re,Exifr:ee,fileParsers:k,segmentParsers:S,fileReaders:O,tagKeys:F,tagValues:L,tagRevivers:D,createDictionary:U,extendDictionary:I,fetchUrlAsArrayBuffer:A,readBlobAsArrayBuffer:B,chunkedProps:T,otherSegments:V,segments:z,tiffBlocks:N,segmentsAndBlocks:M,tiffExtractables:E,inheritables:R,allFormatters:j,Options:K,disableAllOptions:Y,gpsOnlyOptions:Z,orientationOnlyOptions:Q,thumbnailOnlyOptions:$});class oe extends y{constructor(...e){super(...e),t(this,"ranges",new he),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 t;t=h?a.allocUnsafe(e):new Uint8Array(e);let i=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:i}}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 he{constructor(){t(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>le(e,t.offset,s)||le(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 le(e,t,i){return e<=t&&t<=i}class fe extends oe{constructor(e,i){super(0),t(this,"chunksRead",0),this.input=e,this.options=i}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(){}}O.set("blob",class extends fe{async readWhole(){this.chunked=!1;let e=await B(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 B(s);return this.set(n,e,!0)}});class ue{constructor(e,i,s){t(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 d("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 d("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=i,this.parsers=s}createParser(e,t){let i=new(S.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class de{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 K({[this.type]:t})).parse()}normalizeInput(e){return e instanceof y?e:new y(e)}constructor(e,i={},s){t(this,"errors",[]),t(this,"raw",new Map),t(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=D.get(t),s=L.get(t),n=F.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}}t(de,"headerLength",4),t(de,"type",void 0),t(de,"multiSegment",!1),t(de,"canHandle",()=>!1);function ce(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ge(e){return e>=224&&e<=239}function pe(e,t){for(let[i,s]of S)if(s.canHandle(e,t))return i}k.set("jpeg",class extends ue{constructor(...e){super(...e),t(this,"appSegments",[]),t(this,"jpegSegments",[]),t(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(S.keyList())):(e=void 0===e?S.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&S.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&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=S.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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),ge(i)){if(s=h.getUint16(e+2),n=pe(h,e),n&&f.has(n)&&(r=S.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=de.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(ce(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)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=S.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(S.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 me=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ye extends de{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw d("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 d("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=me[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw d("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 d("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 c(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 d("Invalid tiff type ".concat(e))}}}class be extends ye{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}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 d("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw d("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,g(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=y.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,g(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",we(...e.get(2),e.get(1))),e.set("longitude",we(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!u(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 we(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}t(be,"type","tiff"),t(be,"headerLength",10),S.set("tiff",be);var ke=Object.freeze({__proto__:null,default:ae,parse:te,thumbnail:ie,thumbnailUrl:se,gps:ne,orientation:re,Exifr:ee,fileParsers:k,segmentParsers:S,fileReaders:O,tagKeys:F,tagValues:L,tagRevivers:D,createDictionary:U,extendDictionary:I,fetchUrlAsArrayBuffer:A,readBlobAsArrayBuffer:B,chunkedProps:T,otherSegments:V,segments:z,tiffBlocks:N,segmentsAndBlocks:M,tiffExtractables:E,inheritables:R,allFormatters:j,Options:K,disableAllOptions:Y,gpsOnlyOptions:Z,orientationOnlyOptions:Q,thumbnailOnlyOptions:$});O.set("url",class extends fe{async readWhole(){this.chunked=!1;let e=await A(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 Se extends ue{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}}k.set("heic",class extends Se{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}}}),U(F,["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(F,"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(F,"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(L,["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 Oe=U(L,"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 ve={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Oe.set(37392,ve),Oe.set(41488,ve);const xe={0:"Normal",1:"Low",2:"High"};function Ce(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 Ae(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(Pe(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Pe(e[i],e[i+1]));return c(String.fromCodePoint(...t))}function Pe(e,t){return e<<8|t}Oe.set(41992,xe),Oe.set(41993,xe),Oe.set(41994,xe),U(D,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?m(e):e}],[306,Ae],[40091,Be],[40092,Be],[40093,Be],[40094,Be],[40095,Be]]),U(D,"exif",[[40960,Ce],[36864,Ce],[36867,Ae],[36868,Ae]]),U(D,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Ue extends de{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(Me,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Fe.findAll(e,"rdf","Description");0===t.length&&t.push(new Fe("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Ve(t.ns,s),Le(t,i);return function(e){let t;for(let i in e)t=e[i]=l(e[i]),void 0===t&&delete e[i];return l(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}}t(Ue,"type","xmp"),t(Ue,"multiSegment",!0),S.set("xmp",Ue);class Ie{static findAll(e){return ze(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=Ne(s),new Ie(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Fe{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 ze(e,s).map(Fe.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Fe(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=Fe.findAll(s),this.value=0===this.children.length?Ne(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 Te(this.children.map(De));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Le(t,e);return void 0!==this.value&&(e.value=this.value),l(e)}}function Le(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var De=e=>e.serialize(),Te=e=>1===e.length?e[0]:e,Ve=(e,t)=>t[e]?t[e]:t[e]={};function ze(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ne(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 Me=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;e.Exifr=ee,e.Options=K,e.allFormatters=j,e.chunkedProps=T,e.createDictionary=U,e.default=ke,e.disableAllOptions=Y,e.extendDictionary=I,e.fetchUrlAsArrayBuffer=A,e.fileParsers=k,e.fileReaders=O,e.gps=ne,e.gpsOnlyOptions=Z,e.inheritables=R,e.orientation=re,e.orientationOnlyOptions=Q,e.otherSegments=V,e.parse=te,e.readBlobAsArrayBuffer=B,e.segmentParsers=S,e.segments=z,e.segmentsAndBlocks=M,e.tagKeys=F,e.tagRevivers=D,e.tagValues=L,e.thumbnail=ie,e.thumbnailOnlyOptions=$,e.thumbnailUrl=se,e.tiffBlocks=N,e.tiffExtractables=E,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,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}let i="undefined"!=typeof self?self:global;var s="undefined"!=typeof navigator,n=s&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let a=i.Buffer,o=i.BigInt;var h=!!a;function l(e){return u(e)?void 0:e}const f=e=>void 0!==e;function u(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(f).length)}function d(e){let t=new Error(e);return delete t.stack,t}function c(e){return""===(e=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(e).trim())?void 0:e}function g(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}const p=new TextDecoder("utf-8");function m(e){return p.decode(e)}class y{static from(e,t){return e instanceof this&&e.le===t?e:new y(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){void 0===i&&(i=e.byteLength-t);let s=new DataView(e,t,i);this._swapDataView(s)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof y){if(void 0===i&&(i=e.byteLength-t),(t+=e.byteOffset)+i>e.byteOffset+e.byteLength)throw d("Creating view outside of available memory in ArrayBuffer");let s=new DataView(e.buffer,t,i);this._swapDataView(s)}else{if("number"!=typeof e)throw d("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=y){if(e instanceof DataView||e instanceof y?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),!(e instanceof Uint8Array))throw d("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 y(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 m(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 o)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),o(t)<<o(32)|o(i);throw d("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 b(e,t){throw d("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}class w extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||b(this.kind,e),t&&(e in t||function(e,t){throw d("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||b(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var k=new w("file parser"),S=new w("segment parser"),O=new w("file reader");function v(e,t){if((i=e).startsWith("data:")||i.length>1e4)return C(e,t,"base64");if(s)return x(e,t,"url",A);if(r)return C(e,t,"fs");throw d("Invalid input argument");var i}async function x(e,t,i,s){if(O.has(i))return C(e,t,i);if(s)return async function(e,t){let i=await t(e);return new y(i)}(e,s);throw d("Parser ".concat(i," is not loaded"))}async function C(e,t,i){let s=new(O.get(i))(e,t);return await s.read(),s}async function A(e){return fetch(e).then(e=>e.arrayBuffer())}async function B(e){return new Promise((t,i)=>{let s=new FileReader;s.onloadend=()=>t(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(e)})}class P extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function U(e,t,i){let s=new P;for(let[e,t]of i)s.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,s);else e.set(t,s);return s}function I(e,t,i){let s,n=e.get(t);for(s of i)n.set(s[0],s[1])}const F=new Map,L=new Map,D=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],V=["jfif","xmp","icc","iptc"],z=["tiff",...V],N=["ifd0","ifd1","exif","gps","interop"],M=[...z,...N],E=["makerNote","userComment"],R=["translateKeys","translateValues","reviveValues","multiSegment"],j=[...R,"sanitize","mergeOutput"];class G{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class _ extends G{get needed(){return this.enabled||this.deps.size>0}constructor(e,i,s,n){if(super(),t(this,"enabled",!1),t(this,"skip",new Set),t(this,"pick",new Set),t(this,"deps",new Set),t(this,"translateKeys",!1),t(this,"translateValues",!1),t(this,"reviveValues",!1),this.key=e,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=N.includes(e),this.canBeFiltered&&(this.dict=F.get(e)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:e,skip:t}=s;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw d("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(e){let t,i;for(t of R)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){if(this.dict){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)}else for(let i of e)t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,q(this.pick,this.deps)):this.enabled&&this.pick.size>0&&q(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 K 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 d("Invalid options argument ".concat(e));this.setupFromObject(e)}void 0===this.firstChunkSize&&(this.firstChunkSize=s?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 E)this[e]=H[e];for(e of M)this[e]=new _(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 E)this[e]=!0;for(e of M)this[e]=new _(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 E)this[t]=H[t];for(t of M)this[t]=new _(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]=J(e[t],H[t]);for(t of j)this[t]=J(e[t],H[t]);for(t of E)this[t]=J(e[t],H[t]);for(t of z)this[t]=new _(t,H[t],e[t],this);for(t of N)this[t]=new _(t,H[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,N,M),!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=X(e,i);for(let[e,i]of t)q(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=X(t,i);for(let[t,i]of e)q(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!V.map(e=>this[e].enabled).some(e=>!0===e)&&this.tiff.enabled}checkLoadedPlugins(){for(let e of z)this[e].enabled&&!S.has(e)&&b("segment parser",e)}}function X(e,t){let i,s,n,r,a=[];for(n of t){for(r of(i=F.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 J(e,t){return void 0!==e?e:void 0!==t?t:void 0}function q(e,t){for(let i of t)e.add(i)}t(K,"default",H);const Y={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Z=Object.assign({},Y,{firstChunkSize:4e4,gps:[1,2,3,4]}),Q=Object.assign({},Y,{firstChunkSize:4e4,ifd0:[274]}),$=Object.assign({},Y,{tiff:!1,ifd1:!0,mergeOutput:!1});class ee{constructor(e){t(this,"parsers",{}),this.options=K.useCached(e)}setup(){if(this.fileParser)return;let e,t=this.file.getUint16(0);if(18761===t||19789===t)this.file.isTiff=!0,e=k.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=k.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 d("Unknown file format");this.file.isHeic=!0,e=k.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 v(e,t);if(s&&!n&&e instanceof HTMLImageElement)return v(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new y(e);if(s&&e instanceof Blob)return x(e,t,"blob",B);throw d("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=l(e),this.file.close&&this.file.close(),e}async extractThumbnail(){this.setup();let e=S.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 te(e,t){let i=new ee(t);return await i.read(e),i.parse()}async function ie(e){let t=new ee($);await t.read(e);let i=await t.extractThumbnail();return i&&h?a.from(i):i}async function se(e){let t=await this.thumbnail(e);if(void 0!==t){let e=new Blob([t]);return URL.createObjectURL(e)}}async function ne(e){let t=new ee(Z);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 re(e){let t=new ee(Q);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}var ae=Object.freeze({__proto__:null,parse:te,thumbnail:ie,thumbnailUrl:se,gps:ne,orientation:re,Exifr:ee,fileParsers:k,segmentParsers:S,fileReaders:O,tagKeys:F,tagValues:L,tagRevivers:D,createDictionary:U,extendDictionary:I,fetchUrlAsArrayBuffer:A,readBlobAsArrayBuffer:B,chunkedProps:T,otherSegments:V,segments:z,tiffBlocks:N,segmentsAndBlocks:M,tiffExtractables:E,inheritables:R,allFormatters:j,Options:K,disableAllOptions:Y,gpsOnlyOptions:Z,orientationOnlyOptions:Q,thumbnailOnlyOptions:$});class oe extends y{constructor(...e){super(...e),t(this,"ranges",new he),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 t;t=h?a.allocUnsafe(e):new Uint8Array(e);let i=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:i}}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 he{constructor(){t(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let s=e+t,n=this.list.filter(t=>le(e,t.offset,s)||le(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 le(e,t,i){return e<=t&&t<=i}class fe extends oe{constructor(e,i){super(0),t(this,"chunksRead",0),this.input=e,this.options=i}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(){}}O.set("blob",class extends fe{async readWhole(){this.chunked=!1;let e=await B(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 B(s);return this.set(n,e,!0)}});class ue{constructor(e,i,s){t(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 d("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 d("Segment unreachable: "+JSON.stringify(e));e.chunk=this.file.subarray(t)}return e.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=i,this.parsers=s}createParser(e,t){let i=new(S.get(e))(t,this.options,this.file);return this.parsers[e]=i}}class de{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 K({[this.type]:t})).parse()}normalizeInput(e){return e instanceof y?e:new y(e)}constructor(e,i={},s){t(this,"errors",[]),t(this,"raw",new Map),t(this,"handleError",e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)}),this.chunk=this.normalizeInput(e),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=D.get(t),s=L.get(t),n=F.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}}t(de,"headerLength",4),t(de,"type",void 0),t(de,"multiSegment",!1),t(de,"canHandle",()=>!1);function ce(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function ge(e){return e>=224&&e<=239}function pe(e,t){for(let[i,s]of S)if(s.canHandle(e,t))return i}k.set("jpeg",class extends ue{constructor(...e){super(...e),t(this,"appSegments",[]),t(this,"jpegSegments",[]),t(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(S.keyList())):(e=void 0===e?S.keyList().filter(e=>this.options[e].enabled):e.filter(e=>this.options[e].enabled&&S.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&&this.file.chunked&&(s=Array.from(n).some(e=>{let t=S.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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),ge(i)){if(s=h.getUint16(e+2),n=pe(h,e),n&&f.has(n)&&(r=S.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=de.findPosition(h,e),a.marker=i,this.unknownSegments.push(a)),e+=s+1}else if(ce(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)}(this.appSegments,"type");this.mergedAppSegments=e.map(([e,t])=>{let i=S.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(S.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 me=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ye extends de{parseHeader(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw d("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 d("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=me[s];if(r*n<=4?e+=8:e=this.chunk.getUint32(e+8),s<1||s>13)throw d("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 d("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 c(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 d("Invalid tiff type ".concat(e))}}}class be extends ye{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(e){try{return await this[e]()}catch(e){this.handleError(e)}}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 d("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw d("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,g(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=y.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,g(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",we(...e.get(2),e.get(1))),e.set("longitude",we(...e.get(4),e.get(3)))),e}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!u(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 we(e,t,i,s){var n=e+t/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}t(be,"type","tiff"),t(be,"headerLength",10),S.set("tiff",be);var ke=Object.freeze({__proto__:null,default:ae,parse:te,thumbnail:ie,thumbnailUrl:se,gps:ne,orientation:re,Exifr:ee,fileParsers:k,segmentParsers:S,fileReaders:O,tagKeys:F,tagValues:L,tagRevivers:D,createDictionary:U,extendDictionary:I,fetchUrlAsArrayBuffer:A,readBlobAsArrayBuffer:B,chunkedProps:T,otherSegments:V,segments:z,tiffBlocks:N,segmentsAndBlocks:M,tiffExtractables:E,inheritables:R,allFormatters:j,Options:K,disableAllOptions:Y,gpsOnlyOptions:Z,orientationOnlyOptions:Q,thumbnailOnlyOptions:$});O.set("url",class extends fe{async readWhole(){this.chunked=!1;let e=await A(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 Se extends ue{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}}k.set("heic",class extends Se{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}}}),U(F,["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(F,"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(F,"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(L,["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 Oe=U(L,"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 ve={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Oe.set(37392,ve),Oe.set(41488,ve);const xe={0:"Normal",1:"Low",2:"High"};function Ce(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 Ae(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(Pe(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Pe(e[i],e[i+1]));return c(String.fromCodePoint(...t))}function Pe(e,t){return e<<8|t}Oe.set(41992,xe),Oe.set(41993,xe),Oe.set(41994,xe),U(D,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?m(e):e}],[306,Ae],[40091,Be],[40092,Be],[40093,Be],[40094,Be],[40095,Be]]),U(D,"exif",[[40960,Ce],[36864,Ce],[36867,Ae],[36868,Ae]]),U(D,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Ue extends de{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(Me,(e,i,s)=>"<"===i?"".concat(e,"#").concat(t[s]++):"".concat(e,"#").concat(--t[s]))}(e);let t=Fe.findAll(e,"rdf","Description");0===t.length&&t.push(new Fe("rdf","Description",void 0,e));let i,s={};for(let e of t)for(let t of e.properties)i=Ve(t.ns,s),Le(t,i);return function(e){let t;for(let i in e)t=e[i]=l(e[i]),void 0===t&&delete e[i];return l(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}}t(Ue,"type","xmp"),t(Ue,"multiSegment",!0),S.set("xmp",Ue);class Ie{static findAll(e){return ze(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=Ne(s),new Ie(t,i,s)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class Fe{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 ze(e,s).map(Fe.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],s=e[4],n=e[8];return new Fe(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=Fe.findAll(s),this.value=0===this.children.length?Ne(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 Te(this.children.map(De));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Le(t,e);return void 0!==this.value&&(e.value=this.value),l(e)}}function Le(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var De=e=>e.serialize(),Te=e=>1===e.length?e[0]:e,Ve=(e,t)=>t[e]?t[e]:t[e]={};function ze(e,t){let i,s=[];if(!e)return s;for(;null!==(i=t.exec(e));)s.push(i);return s}function Ne(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 Me=/(<|\/)(rdf:li|rdf:Seq|rdf:Bag|rdf:Alt)/g;e.Exifr=ee,e.Options=K,e.allFormatters=j,e.chunkedProps=T,e.createDictionary=U,e.default=ke,e.disableAllOptions=Y,e.extendDictionary=I,e.fetchUrlAsArrayBuffer=A,e.fileParsers=k,e.fileReaders=O,e.gps=ne,e.gpsOnlyOptions=Z,e.inheritables=R,e.orientation=re,e.orientationOnlyOptions=Q,e.otherSegments=V,e.parse=te,e.readBlobAsArrayBuffer=B,e.segmentParsers=S,e.segments=z,e.segmentsAndBlocks=M,e.tagKeys=F,e.tagRevivers=D,e.tagValues=L,e.thumbnail=ie,e.thumbnailOnlyOptions=$,e.thumbnailUrl=se,e.tiffBlocks=N,e.tiffExtractables=E,Object.defineProperty(e,"__esModule",{value:!0})})); |
@@ -1,1 +0,1 @@ | ||
function t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let e="undefined"!=typeof self?self:global;var i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let r=e.Buffer,a=e.BigInt;var h=!!r;const f=t=>void 0!==t;function l(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(f).length)}function o(t){let e=new Error(t);return delete e.stack,e}function u(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}const d=new TextDecoder("utf-8");class c{static from(t,e){return t instanceof this&&t.le===e?t:new c(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 c){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw o("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 o("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=c){if(t instanceof DataView||t instanceof c?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.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new c(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,d.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 a)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),a(e)<<a(32)|a(i);throw o("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 p(t,e){throw o("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class g extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||p(this.kind,t),e&&(t in e||function(t,e){throw o("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||p(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var y=new g("file parser"),k=new g("segment parser"),w=new g("file reader");function m(t,e){if((s=t).startsWith("data:")||s.length>1e4)return O(t,e,"base64");if(i)return b(t,e,"url",v);if(n)return O(t,e,"fs");throw o("Invalid input argument");var s}async function b(t,e,i,s){if(w.has(i))return O(t,e,i);if(s)return async function(t,e){let i=await e(t);return new c(i)}(t,s);throw o("Parser ".concat(i," is not loaded"))}async function O(t,e,i){let s=new(w.get(i))(t,e);return await s.read(),s}async function v(t){return fetch(t).then(t=>t.arrayBuffer())}async function S(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class U extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function A(t,e,i){let s=new U;for(let[t,e]of i)s.set(t,e);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 B=new Map,C=new Map,V=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"],P=["translateKeys","translateValues","reviveValues","multiSegment"],D=[...P,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class _ extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,i,s,n){if(super(),t(this,"enabled",!1),t(this,"skip",new Set),t(this,"pick",new Set),t(this,"deps",new Set),t(this,"translateKeys",!1),t(this,"translateValues",!1),t(this,"reviveValues",!1),this.key=e,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=z.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:t,skip:e}=s;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw o("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(t){let e,i;for(e of P)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){if(this.dict){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)}else for(let i of t)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 M={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},N=new Map;class R extends E{static useCached(t){let e=N.get(t);return void 0!==e?e:(e=new this(t),N.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 o("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 I)this[t]=M[t];for(t of D)this[t]=M[t];for(t of j)this[t]=M[t];for(t of F)this[t]=new _(t,M[t],void 0,this)}setupFromTrue(){let t;for(t of I)this[t]=M[t];for(t of D)this[t]=M[t];for(t of j)this[t]=!0;for(t of F)this[t]=new _(t,!0,void 0,this)}setupFromArray(t){let e;for(e of I)this[e]=M[e];for(e of D)this[e]=M[e];for(e of j)this[e]=M[e];for(e of F)this[e]=new _(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]=K(t[e],M[e]);for(e of D)this[e]=K(t[e],M[e]);for(e of j)this[e]=K(t[e],M[e]);for(e of L)this[e]=new _(e,M[e],t[e],this);for(e of z)this[e]=new _(e,M[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=W(t,i);for(let[t,i]of e)H(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=W(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=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&&!k.has(t)&&p("segment parser",t)}}function W(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=B.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 K(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)}t(R,"default",M);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]}),q=Object.assign({},G,{tiff:!1,ifd1:!0,mergeOutput:!1});class Q{constructor(e){t(this,"parsers",{}),this.options=R.useCached(e)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=y.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=y.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 o("Unknown file format");this.file.isHeic=!0,t=y.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 c(t);if(i&&t instanceof Blob)return b(t,e,"blob",S);throw o("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=l(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=k.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 Y(t,e){let i=new Q(e);return await i.read(t),i.parse()}async function Z(t){let e=new Q(q);await e.read(t);let i=await e.extractThumbnail();return i&&h?r.from(i):i}async function $(t){let e=await this.thumbnail(t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function tt(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 et(t){let e=new Q(X);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}var it=Object.freeze({__proto__:null,parse:Y,thumbnail:Z,thumbnailUrl:$,gps:tt,orientation:et,Exifr:Q,fileParsers:y,segmentParsers:k,fileReaders:w,tagKeys:B,tagValues:C,tagRevivers:V,createDictionary:A,extendDictionary:x,fetchUrlAsArrayBuffer:v,readBlobAsArrayBuffer:S,chunkedProps:I,otherSegments:T,segments:L,tiffBlocks:z,segmentsAndBlocks:F,tiffExtractables:j,inheritables:P,allFormatters:D,Options:R,disableAllOptions:G,gpsOnlyOptions:J,orientationOnlyOptions:X,thumbnailOnlyOptions:q});class st extends c{constructor(...e){super(...e),t(this,"ranges",new nt),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 e;e=h?r.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}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 nt{constructor(){t(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>rt(t,e.offset,s)||rt(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 rt(t,e,i){return t<=e&&e<=i}class at extends st{constructor(e,i){super(0),t(this,"chunksRead",0),this.input=e,this.options=i}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(){}}w.set("blob",class extends at{async readWhole(){this.chunked=!1;let t=await S(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 S(s);return this.set(n,t,!0)}});class ht{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 R({[this.type]:e})).parse()}normalizeInput(t){return t instanceof c?t:new c(t)}constructor(e,i={},s){t(this,"errors",[]),t(this,"raw",new Map),t(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(e),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=V.get(e),s=C.get(e),n=B.get(e),r=this.options[e],a=r.reviveValues&&!!i,h=r.translateValues&&!!s,f=r.translateKeys&&!!n,l={};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),l[e]=r;return l}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}}t(ht,"headerLength",4),t(ht,"type",void 0),t(ht,"multiSegment",!1),t(ht,"canHandle",()=>!1);function ft(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function lt(t){return t>=224&&t<=239}function ot(t,e){for(let[i,s]of k)if(s.canHandle(t,e))return i}y.set("jpeg",class extends class{constructor(e,i,s){t(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 o("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 o("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=i,this.parsers=s}createParser(t,e){let i=new(k.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...e){super(...e),t(this,"appSegments",[]),t(this,"jpegSegments",[]),t(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(k.keyList())):(t=void 0===t?k.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&k.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&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=k.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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:l,wanted:o,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),lt(i)){if(s=f.getUint16(t+2),n=ot(f,t),n&&o.has(n)&&(r=k.get(n),a=r.findPosition(f,t),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=ht.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(ft(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)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=k.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(k.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 ut=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class dt extends ht{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)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(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=ut[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw o("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 o("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 o("Invalid tiff type ".concat(t))}}}class ct extends dt{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}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 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,u(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=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,u(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",pt(...t.get(2),t.get(1))),t.set("longitude",pt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!l(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 pt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}t(ct,"type","tiff"),t(ct,"headerLength",10),k.set("tiff",ct);export default it;export{Q as Exifr,R as Options,D as allFormatters,I as chunkedProps,A as createDictionary,G as disableAllOptions,x as extendDictionary,v as fetchUrlAsArrayBuffer,y as fileParsers,w as fileReaders,tt as gps,J as gpsOnlyOptions,P as inheritables,et as orientation,X as orientationOnlyOptions,T as otherSegments,Y as parse,S as readBlobAsArrayBuffer,k as segmentParsers,L as segments,F as segmentsAndBlocks,B as tagKeys,V as tagRevivers,C as tagValues,Z as thumbnail,q as thumbnailOnlyOptions,$ as thumbnailUrl,z as tiffBlocks,j as tiffExtractables}; | ||
function t(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let e="undefined"!=typeof self?self:global;var i="undefined"!=typeof navigator,s=i&&"undefined"==typeof HTMLImageElement,n=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let r=e.Buffer,a=e.BigInt;var h=!!r;const f=t=>void 0!==t;function l(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(f).length)}function o(t){let e=new Error(t);return delete e.stack,e}function u(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}const d=new TextDecoder("utf-8");class c{static from(t,e){return t instanceof this&&t.le===e?t:new c(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){void 0===i&&(i=t.byteLength-e);let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof c){if(void 0===i&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength)throw o("Creating view outside of available memory in ArrayBuffer");let s=new DataView(t.buffer,e,i);this._swapDataView(s)}else{if("number"!=typeof t)throw o("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=c){if(t instanceof DataView||t instanceof c?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.");return this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new c(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,d.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 a)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),a(e)<<a(32)|a(i);throw o("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 p(t,e){throw o("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class g extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||p(this.kind,t),e&&(t in e||function(t,e){throw o("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||p(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var y=new g("file parser"),b=new g("segment parser"),k=new g("file reader");function w(t,e){if((s=t).startsWith("data:")||s.length>1e4)return O(t,e,"base64");if(i)return m(t,e,"url",v);if(n)return O(t,e,"fs");throw o("Invalid input argument");var s}async function m(t,e,i,s){if(k.has(i))return O(t,e,i);if(s)return async function(t,e){let i=await e(t);return new c(i)}(t,s);throw o("Parser ".concat(i," is not loaded"))}async function O(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 S(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class U extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function A(t,e,i){let s=new U;for(let[t,e]of i)s.set(t,e);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 B=new Map,C=new Map,V=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"],P=["translateKeys","translateValues","reviveValues","multiSegment"],D=[...P,"sanitize","mergeOutput"];class E{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class _ extends E{get needed(){return this.enabled||this.deps.size>0}constructor(e,i,s,n){if(super(),t(this,"enabled",!1),t(this,"skip",new Set),t(this,"pick",new Set),t(this,"deps",new Set),t(this,"translateKeys",!1),t(this,"translateValues",!1),t(this,"reviveValues",!1),this.key=e,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=z.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:t,skip:e}=s;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw o("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(t){let e,i;for(e of P)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){if(this.dict){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)}else for(let i of t)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 M={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},N=new Map;class R extends E{static useCached(t){let e=N.get(t);return void 0!==e?e:(e=new this(t),N.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 o("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 I)this[t]=M[t];for(t of D)this[t]=M[t];for(t of j)this[t]=M[t];for(t of F)this[t]=new _(t,M[t],void 0,this)}setupFromTrue(){let t;for(t of I)this[t]=M[t];for(t of D)this[t]=M[t];for(t of j)this[t]=!0;for(t of F)this[t]=new _(t,!0,void 0,this)}setupFromArray(t){let e;for(e of I)this[e]=M[e];for(e of D)this[e]=M[e];for(e of j)this[e]=M[e];for(e of F)this[e]=new _(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]=K(t[e],M[e]);for(e of D)this[e]=K(t[e],M[e]);for(e of j)this[e]=K(t[e],M[e]);for(e of L)this[e]=new _(e,M[e],t[e],this);for(e of z)this[e]=new _(e,M[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=W(t,i);for(let[t,i]of e)H(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=W(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=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&&!b.has(t)&&p("segment parser",t)}}function W(t,e){let i,s,n,r,a=[];for(n of e){for(r of(i=B.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 K(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)}t(R,"default",M);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]}),q=Object.assign({},G,{tiff:!1,ifd1:!0,mergeOutput:!1});class Q{constructor(e){t(this,"parsers",{}),this.options=R.useCached(e)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=y.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=y.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 o("Unknown file format");this.file.isHeic=!0,t=y.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 c(t);if(i&&t instanceof Blob)return m(t,e,"blob",S);throw o("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=l(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=b.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 Y(t,e){let i=new Q(e);return await i.read(t),i.parse()}async function Z(t){let e=new Q(q);await e.read(t);let i=await e.extractThumbnail();return i&&h?r.from(i):i}async function $(t){let e=await this.thumbnail(t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function tt(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 et(t){let e=new Q(X);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}var it=Object.freeze({__proto__:null,parse:Y,thumbnail:Z,thumbnailUrl:$,gps:tt,orientation:et,Exifr:Q,fileParsers:y,segmentParsers:b,fileReaders:k,tagKeys:B,tagValues:C,tagRevivers:V,createDictionary:A,extendDictionary:x,fetchUrlAsArrayBuffer:v,readBlobAsArrayBuffer:S,chunkedProps:I,otherSegments:T,segments:L,tiffBlocks:z,segmentsAndBlocks:F,tiffExtractables:j,inheritables:P,allFormatters:D,Options:R,disableAllOptions:G,gpsOnlyOptions:J,orientationOnlyOptions:X,thumbnailOnlyOptions:q});class st extends c{constructor(...e){super(...e),t(this,"ranges",new nt),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 e;e=h?r.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}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 nt{constructor(){t(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>rt(t,e.offset,s)||rt(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 rt(t,e,i){return t<=e&&e<=i}class at extends st{constructor(e,i){super(0),t(this,"chunksRead",0),this.input=e,this.options=i}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 at{async readWhole(){this.chunked=!1;let t=await S(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 S(s);return this.set(n,t,!0)}});class ht{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 R({[this.type]:e})).parse()}normalizeInput(t){return t instanceof c?t:new c(t)}constructor(e,i={},s){t(this,"errors",[]),t(this,"raw",new Map),t(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(e),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=V.get(e),s=C.get(e),n=B.get(e),r=this.options[e],a=r.reviveValues&&!!i,h=r.translateValues&&!!s,f=r.translateKeys&&!!n,l={};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),l[e]=r;return l}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}}t(ht,"headerLength",4),t(ht,"type",void 0),t(ht,"multiSegment",!1),t(ht,"canHandle",()=>!1);function ft(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function lt(t){return t>=224&&t<=239}function ot(t,e){for(let[i,s]of b)if(s.canHandle(t,e))return i}y.set("jpeg",class extends class{constructor(e,i,s){t(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 o("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 o("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=i,this.parsers=s}createParser(t,e){let i=new(b.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...e){super(...e),t(this,"appSegments",[]),t(this,"jpegSegments",[]),t(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(b.keyList())):(t=void 0===t?b.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&b.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&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=b.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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:l,wanted:o,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),lt(i)){if(s=f.getUint16(t+2),n=ot(f,t),n&&o.has(n)&&(r=b.get(n),a=r.findPosition(f,t),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=ht.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(ft(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)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=b.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(b.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 ut=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class dt extends ht{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)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(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=ut[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw o("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 o("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 o("Invalid tiff type ".concat(t))}}}class ct extends dt{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}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 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,u(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=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,u(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",pt(...t.get(2),t.get(1))),t.set("longitude",pt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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],!l(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 pt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}t(ct,"type","tiff"),t(ct,"headerLength",10),b.set("tiff",ct);export default it;export{Q as Exifr,R as Options,D as allFormatters,I as chunkedProps,A as createDictionary,G as disableAllOptions,x as extendDictionary,v as fetchUrlAsArrayBuffer,y as fileParsers,k as fileReaders,tt as gps,J as gpsOnlyOptions,P as inheritables,et as orientation,X as orientationOnlyOptions,T as otherSegments,Y as parse,S as readBlobAsArrayBuffer,b as segmentParsers,L as segments,F as segmentsAndBlocks,B as tagKeys,V as tagRevivers,C as tagValues,Z as thumbnail,q as thumbnailOnlyOptions,$ 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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(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}});var n=["prototype","__proto__","caller","arguments","length","name"];Object.getOwnPropertyNames(t).forEach((function(r){-1===n.indexOf(r)&&e[r]!==t[r]&&(e[r]=t[r])})),t&&u(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){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 f(e,t,n){return(f=o()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&u(i,n.prototype),i}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;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,r)}function r(){return f(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?c(e):t}function d(e,t,n){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}var v=Object.values||function(e){var t=[];for(var n in e)t.push(e[n]);return t},p=Object.entries||function(e){var t=[];for(var n in e)t.push([n,e[n]]);return t},y=Object.assign||function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach((function(t){for(var n in t)e[n]=t[n]})),e},g=Object.fromEntries||function(e){var t={};return k(e).forEach((function(e){var n=e[0],r=e[1];t[n]=r})),t},k=Array.from||function(e){if(e instanceof P){var t=[];return e.forEach((function(e,n){return t.push([n,e])})),t}return Array.prototype.slice.call(e)};function m(e){return-1!==this.indexOf(e)}Array.prototype.includes||(Array.prototype.includes=m),String.prototype.includes||(String.prototype.includes=m),String.prototype.startsWith||(String.prototype.startsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.substring(t,t+e.length)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return this.substring(t-e.length,t)===e});var b="undefined"!=typeof self?self:global,w=b.TextDecoder||function(){function e(){t(this,e)}return r(e,[{key:"decode",value:function(e){var t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}}]),e}(),A=b.fetch||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,r){var i=new XMLHttpRequest;if(i.open("get",e,!0),i.responseType="arraybuffer",i.onerror=r,t.headers)for(var s in t.headers)i.setRequestHeader(s,t.headers[s]);i.onload=function(){n({ok:i.status>=200&&i.status<300,status:i.status,arrayBuffer:function(){return Promise.resolve(i.response)}})},i.send(null)}))},O=function(e){var t=[];if(Object.defineProperties(t,{size:{get:function(){return this.length}},has:{value:function(e){return-1!==this.indexOf(e)}},add:{value:function(e){this.has(e)||this.push(e)}},delete:{value:function(e){if(this.has(e)){var t=this.indexOf(e);this.splice(t,1)}}}}),Array.isArray(e))for(var n=0;n<e.length;n++)t.add(e[n]);return t},S=function(e){return new P(e)},P=void 0!==b.Map&&void 0!==b.Map.prototype.keys?b.Map:function(){function e(n){if(t(this,e),this.clear(),n)for(var r=0;r<n.length;r++)this.set(n[r][0],n[r][1])}return r(e,[{key:"clear",value:function(){this._map={},this._keys=[]}},{key:"get",value:function(e){return this._map["map_"+e]}},{key:"set",value:function(e,t){return this._map["map_"+e]=t,this._keys.indexOf(e)<0&&this._keys.push(e),this}},{key:"has",value:function(e){return this._keys.indexOf(e)>=0}},{key:"delete",value:function(e){var t=this._keys.indexOf(e);return!(t<0)&&(delete this._map["map_"+e],this._keys.splice(t,1),!0)}},{key:"keys",value:function(){return this._keys.slice(0)}},{key:"values",value:function(){var e=this;return this._keys.map((function(t){return e.get(t)}))}},{key:"entries",value:function(){var e=this;return this._keys.map((function(t){return[t,e.get(t)]}))}},{key:"forEach",value:function(e,t){for(var n=0;n<this._keys.length;n++)e.call(t,this._map["map_"+this._keys[n]],this._keys[n],this)}},{key:"size",get:function(){return this._keys.length}}]),e}(),U="undefined"!=typeof self?self:global,x="undefined"!=typeof navigator,B=x&&"undefined"==typeof HTMLImageElement,C=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node),j=U.Buffer,_=U.BigInt,V=!!j;var T=function(e){return void 0!==e};function I(e){return void 0===e||(e instanceof P?0===e.size:0===v(e).filter(T).length)}function z(e){var t=new Error(e);return delete t.stack,t}function L(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 F=new w("utf-8");function E(e){return F.decode(e)}var D=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(t(this,e),"boolean"==typeof s&&(this.le=s),Array.isArray(n)&&(n=new Uint8Array(n)),0===n)this.byteOffset=0,this.byteLength=0;else if(n instanceof ArrayBuffer){var a=new DataView(n,r,i);this._swapDataView(a)}else if(n instanceof Uint8Array||n instanceof DataView||n instanceof e){var u=n,o=u.byteOffset,f=u.byteLength;if(void 0===i&&(i=f-r),(r+=o)+i>o+f)throw z("Creating view outside of available memory in ArrayBuffer");var h=new DataView(n.buffer,r,i);this._swapDataView(h)}else{if("number"!=typeof n)throw z("Invalid input argument for BufferView: "+n);var c=new DataView(new ArrayBuffer(n));this._swapDataView(c)}}return r(e,null,[{key:"from",value:function(t,n){return t instanceof this&&t.le===n?t:new e(t,void 0,void 0,n)}}]),r(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,n){var r=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 z("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,n),new r(this,n,t.byteLength)}},{key:"subarray",value:function(t,n){return new e(this,t,n=n||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,n=this.getUint8Array(e,t);return E(n)}},{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,n=[],r=0;r<t&&e+r<this.byteLength;r+=2)n.push(this.getUint16(e+r));return n.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 t=this.getUint32(e),n=this.getUint32(e+4);if(t<1048575)return t<<32|n;if(void 0!==typeof _)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),_(t)<<_(32)|_(n);throw z("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,n){switch(t){case 1:return this.getUint8(e,n);case 2:return this.getUint16(e,n);case 4:return this.getUint32(e,n);case 8:return this.getUint64(e,n)}}},{key:"getUint",value:function(e,t,n){switch(t){case 8:return this.getUint8(e,n);case 16:return this.getUint16(e,n);case 32:return this.getUint32(e,n);case 64:return this.getUint64(e,n)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function R(e,t){throw z("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var N=function(e){function n(e){var r;return t(this,n),(r=l(this,a(n).call(this))).kind=e,r}return s(n,e),r(n,[{key:"get",value:function(e,t){return this.has(e)||R(this.kind,e),t&&(e in t||function(e,t){throw z("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||R(this.kind,e)),d(a(n.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return k(this.keys())}}]),n}(h(P)),M=new N("file parser"),W=new N("segment parser"),K=new N("file reader");function H(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function G(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var J=H((function(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){return t(r.result||new ArrayBuffer)},r.onerror=n,r.readAsArrayBuffer(e)}))})),X=H((function(e){return A(e).then((function(e){return e.arrayBuffer()}))})),q=H((function(e,t){return G(t(e),(function(e){return new D(e)}))})),Q=H((function(e,t,n){var r=new(K.get(n))(e,t);return G(r.read(),(function(){return r}))})),Y=H((function(e,t,n,r){if(K.has(n))return Q(e,t,n);if(r)return q(e,r);throw z("Parser ".concat(n," is not loaded"))}));function Z(e,t){if((n=e).startsWith("data:")||n.length>1e4)return Q(e,t,"base64");if(x)return Y(e,t,"url",X);if(C)return Q(e,t,"fs");throw z("Invalid input argument");var n}var $=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"tagKeys",get:function(){return this.allKeys||(this.allKeys=k(this.keys())),this.allKeys}},{key:"tagValues",get:function(){return this.allValues||(this.allValues=k(this.values())),this.allValues}}]),n}(h(P));function ee(e,t,n){var r=new $,i=n;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s],u=a[0],o=a[1];r.set(u,o)}if(Array.isArray(t)){var f=t;Array.isArray(f)||("function"==typeof f.entries&&(f=f.entries()),f=k(f));for(var h=0;h<f.length;h++){var c=f[h];e.set(c,r)}}else e.set(t,r);return r}function te(e,t,n){var r,i=e.get(t),s=n;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)r=s[a],i.set(r[0],r[1])}var ne=S(),re=S(),ie=S(),se=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],ae=["jfif","xmp","icc","iptc"],ue=["tiff"].concat(ae),oe=["ifd0","ifd1","exif","gps","interop"],fe=[].concat(ue,oe),he=["makerNote","userComment"],ce=["translateKeys","translateValues","reviveValues","multiSegment"],le=[].concat(ce,["sanitize","mergeOutput"]),de=function(){function e(){t(this,e)}return r(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),ve=function(e){function n(e,r,s,u){var o;if(t(this,n),i(c(o=l(this,a(n).call(this))),"enabled",!1),i(c(o),"skip",O()),i(c(o),"pick",O()),i(c(o),"deps",O()),i(c(o),"translateKeys",!1),i(c(o),"translateValues",!1),i(c(o),"reviveValues",!1),o.key=e,o.enabled=r,o.parse=o.enabled,o.applyInheritables(u),o.canBeFiltered=oe.includes(e),o.canBeFiltered&&(o.dict=ne.get(e)),void 0!==s)if(Array.isArray(s))o.parse=o.enabled=!0,o.canBeFiltered&&s.length>0&&o.translateTagSet(s,o.pick);else if("object"==typeof s){if(o.enabled=!0,o.parse=!1!==s.parse,o.canBeFiltered){var f=s.pick,h=s.skip;f&&f.length>0&&o.translateTagSet(f,o.pick),h&&h.length>0&&o.translateTagSet(h,o.skip)}o.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw z("Invalid options argument: ".concat(s));o.parse=o.enabled=s}return o}return s(n,e),r(n,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),r(n,[{key:"applyInheritables",value:function(e){var t,n,r=ce;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)void 0!==(n=e[t=r[i]])&&(this[t]=n)}},{key:"translateTagSet",value:function(e,t){if(this.dict){var n,r,i=this.dict,s=i.tagKeys,a=i.tagValues,u=e;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)"string"==typeof(n=u[o])?(-1===(r=a.indexOf(n))&&(r=s.indexOf(Number(n))),-1!==r&&t.add(Number(s[r]))):t.add(n)}else{var f=e;Array.isArray(f)||("function"==typeof f.entries&&(f=f.entries()),f=k(f));for(var h=0;h<f.length;h++){var c=f[h];t.add(c)}}}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,be(this.pick,this.deps)):this.enabled&&this.pick.size>0&&be(this.pick,this.deps)}}]),n}(de),pe={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},ye=S(),ge=function(e){function n(e){var r;if(t(this,n),r=l(this,a(n).call(this)),!0===e)r.setupFromTrue();else if(void 0===e)r.setupFromUndefined();else if(Array.isArray(e))r.setupFromArray(e);else{if("object"!=typeof e)throw z("Invalid options argument ".concat(e));r.setupFromObject(e)}return void 0===r.firstChunkSize&&(r.firstChunkSize=x?r.firstChunkSizeBrowser:r.firstChunkSizeNode),r.mergeOutput&&(r.ifd1.enabled=!1),r.filterNestedSegmentTags(),r.traverseTiffDependencyTree(),r.checkLoadedPlugins(),r}return s(n,e),r(n,null,[{key:"useCached",value:function(e){var t=ye.get(e);return void 0!==t?t:(t=new this(e),ye.set(e,t),t)}}]),r(n,[{key:"setupFromUndefined",value:function(){var e,t=se;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=pe[e];var r=le;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=pe[e];var s=he;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=pe[e];var u=fe;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new ve(e,pe[e],void 0,this)}},{key:"setupFromTrue",value:function(){var e,t=se;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=pe[e];var r=le;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=pe[e];var s=he;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=!0;var u=fe;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new ve(e,!0,void 0,this)}},{key:"setupFromArray",value:function(e){var t,n=se;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=pe[t];var i=le;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=pe[t];var a=he;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=pe[t];var o=fe;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new ve(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,oe)}},{key:"setupFromObject",value:function(e){var t;oe.ifd0=oe.ifd0||oe.image,oe.ifd1=oe.ifd1||oe.thumbnail,y(this,e);var n=se;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=me(e[t],pe[t]);var i=le;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=me(e[t],pe[t]);var a=he;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=me(e[t],pe[t]);var o=ue;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new ve(t,pe[t],e[t],this);var h=oe;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++)this[t=h[c]]=new ve(t,pe[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,oe,fe),!0===e.tiff?this.batchEnableWithBool(oe,!0):!1===e.tiff?this.batchEnableWithUserValue(oe,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,oe):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,oe)}},{key:"batchEnableWithBool",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){this[n[r]].enabled=t}}},{key:"batchEnableWithUserValue",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=t[i];this[i].enabled=!1!==s&&void 0!==s}}},{key:"setupGlobalFilters",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(e&&e.length){var i=r;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s];this[a].enabled=!1}var u=ke(e,n),o=u;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++){var h=o[f],c=h[0],l=h[1];be(this[c].pick,l),this[c].enabled=!0}}else if(t&&t.length){var d=ke(t,n),v=d;Array.isArray(v)||("function"==typeof v.entries&&(v=v.entries()),v=k(v));for(var p=0;p<v.length;p++){var y=v[p],g=y[0],m=y[1];be(this[g].skip,m)}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,n=this.xmp,r=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),n.enabled||e.skip.add(700),r.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,n=this.exif,r=this.gps;this.interop.needed&&(n.deps.add(40965),t.deps.add(40965)),n.needed&&t.deps.add(34665),r.needed&&t.deps.add(34853),this.tiff.enabled=oe.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){this[i[s]].finalizeFilters()}}},{key:"checkLoadedPlugins",value:function(){var e=ue;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t];this[n].enabled&&!W.has(n)&&R("segment parser",n)}}},{key:"onlyTiff",get:function(){var e=this;return!ae.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),n}(de);function ke(e,t){var n,r,i,s=[],a=t;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++){r=a[u],n=[];var o=ne.get(r);Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)i=o[f],(e.includes(i[0])||e.includes(i[1]))&&n.push(i[0]);n.length&&s.push([r,n])}return s}function me(e,t){return void 0!==e?e:void 0!==t?t:void 0}function be(e,t){var n=t;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r];e.add(i)}}i(ge,"default",pe);var we={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Ae=y({},we,{firstChunkSize:4e4,gps:[1,2,3,4]}),Oe=y({},we,{firstChunkSize:4e4,ifd0:[274]}),Se=y({},we,{tiff:!1,ifd1:!0,mergeOutput:!1});function Pe(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function Ue(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function xe(){}var Be=function(){function e(n){t(this,e),i(this,"parsers",{}),this.options=ge.useCached(n)}return r(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=M.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=M.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 n=16,r=[];n<t;)r.push(e.getString(n,4)),n+=4;return r.includes("heic")}(this.file))throw z("Unknown file format");this.file.isHeic=!0,e=M.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:function(e){try{var t=this;return Pe(function(e,t){if("string"==typeof e)return Z(e,t);if(x&&!B&&e instanceof HTMLImageElement)return Z(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new D(e);if(x&&e instanceof Blob)return Y(e,t,"blob",J);throw z("Invalid input argument")}(e,t.options),(function(e){t.file=e}))}catch(e){return Promise.reject(e)}}},{key:"parse",value:function(){try{var e=this;return e.setup(),Pe(e.fileParser.parse(),(function(){var t,n={},r=[],i=v(e.parsers).map((t=function(t){var i;return Ue((function(){return e.options.silentErrors?(n=function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return Pe(t.parse(),(function(e){i=e}))}),(function(e){r.push(e)})),s=function(){t.errors.length&&r.push.apply(r,t.errors)},n&&n.then?n.then(s):s(n)):Pe(t.parse(),(function(e){i=e}));var n,s}),(function(){t.assignToOutput(n,i)}))},function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(t.apply(this,e))}catch(e){return Promise.reject(e)}}));return Pe(Promise.all(i),(function(){var t;return e.options.silentErrors&&r.length>0&&(n.errors=r),n=I(t=n)?void 0:t,e.file.close&&e.file.close(),n}))}))}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;e.setup();var t,n=W.get("tiff",e.options);return Ue((function(){if(!e.file.isTiff)return function(e){var t=e();if(t&&t.then)return t.then(xe)}((function(){if(e.file.isJpeg)return Pe(e.fileParser.getOrFindSegment("tiff"),(function(e){t=e}))}));t={start:0,type:"tiff"}}),(function(){if(void 0!==t)return Pe(e.fileParser.ensureSegmentChunk(t),(function(t){return Pe((e.parsers.tiff=new n(t,e.options,e.file)).extractThumbnail(),(function(t){return e.file.close&&e.file.close(),t}))}))}))}catch(e){return Promise.reject(e)}}}]),e}();function Ce(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function je(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}var _e=je((function(e){var t=new Be(Oe);return Ce(t.read(e),(function(){return Ce(t.parse(),(function(e){if(e&&e.ifd0)return e.ifd0[274]}))}))})),Ve=je((function(e){var t=new Be(Ae);return Ce(t.read(e),(function(){return Ce(t.parse(),(function(e){if(e&&e.gps){var t=e.gps;return{latitude:t.latitude,longitude:t.longitude}}}))}))})),Te=je((function(e){return Ce(this.thumbnail(e),(function(e){if(void 0!==e){var t=new Blob([e]);return URL.createObjectURL(t)}}))})),Ie=je((function(e){var t=new Be(Se);return Ce(t.read(e),(function(){return Ce(t.extractThumbnail(),(function(e){return e&&V?j.from(e):e}))}))})),ze=je((function(e,t){var n=new Be(t);return Ce(n.read(e),(function(){return n.parse()}))})),Le=Object.freeze({__proto__:null,orientation:_e,gps:Ve,thumbnailUrl:Te,thumbnail:Ie,parse:ze,Exifr:Be,fileParsers:M,segmentParsers:W,fileReaders:K,tagKeys:ne,tagValues:re,tagRevivers:ie,createDictionary:ee,extendDictionary:te,fetchUrlAsArrayBuffer:X,readBlobAsArrayBuffer:J,chunkedProps:se,otherSegments:ae,segments:ue,tiffBlocks:oe,segmentsAndBlocks:fe,tiffExtractables:he,inheritables:ce,allFormatters:le,Options:ge,disableAllOptions:we,gpsOnlyOptions:Ae,orientationOnlyOptions:Oe,thumbnailOnlyOptions:Se});function Fe(){}var Ee=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"ranges",new De),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}return s(n,e),r(n,[{key:"_tryExtend",value:function(e,t,n){if(0===e&&0===this.byteLength&&n){var r=new DataView(n.buffer||n,n.byteOffset,n.byteLength);this._swapDataView(r)}else{var i=e+t;if(i>this.byteLength){var s=this._extend(i).dataView;this._swapDataView(s)}}}},{key:"_extend",value:function(e){var t;t=V?j.allocUnsafe(e):new Uint8Array(e);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:n}}},{key:"subarray",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=t||this._lengthToEnd(e),r&&this._tryExtend(e,t),this.ranges.add(e,t),d(a(n.prototype),"subarray",this).call(this,e,t)}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this._tryExtend(t,e.byteLength,e);var i=d(a(n.prototype),"set",this).call(this,e,t);return this.ranges.add(t,i.byteLength),i}},{key:"ensureChunk",value:function(e,t){try{if(!this.chunked)return;if(this.ranges.available(e,t))return;return function(e,t){if(!t)return e&&e.then?e.then(Fe):Promise.resolve()}(this.readChunk(e,t))}catch(e){return Promise.reject(e)}}},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),n}(D),De=function(){function e(){t(this,e),i(this,"list",[])}return r(e,[{key:"add",value:function(e,t){var n=e+t,r=this.list.filter((function(t){return Re(e,t.offset,n)||Re(e,t.end,n)}));if(r.length>0){e=Math.min.apply(Math,[e].concat(r.map((function(e){return e.offset})))),t=(n=Math.max.apply(Math,[n].concat(r.map((function(e){return e.end})))))-e;var i=r.shift();i.offset=e,i.length=t,i.end=n,this.list=this.list.filter((function(e){return!r.includes(e)}))}else this.list.push({offset:e,length:t,end:n})}},{key:"available",value:function(e,t){var n=e+t;return this.list.some((function(t){return t.offset<=e&&n<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Re(e,t,n){return e<=t&&t<=n}function Ne(){}function Me(e,t){if(!t)return e&&e.then?e.then(Ne):Promise.resolve()}function We(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var Ke=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"readWhole",value:function(){try{var e=this;return e.chunked=!1,We(J(e.input),(function(t){e._swapArrayBuffer(t)}))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,d(a(n.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:function(e,t){try{var n=this,r=t?e+t:void 0,i=n.input.slice(e,r);return We(J(i),(function(t){return n.set(t,e,!0)}))}catch(e){return Promise.reject(e)}}}]),n}(function(e){function n(e,r){var s;return t(this,n),i(c(s=l(this,a(n).call(this,0))),"chunksRead",0),s.input=e,s.options=r,s}return s(n,e),r(n,[{key:"readWhole",value:function(){try{return this.chunked=!1,Me(this.readChunk(this.nextChunkOffset))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){try{return this.chunked=!0,Me(this.readChunk(0,this.options.firstChunkSize))}catch(e){return Promise.reject(e)}}},{key:"readNextChunk",value:function(e){try{if(void 0===e&&(e=this.nextChunkOffset),this.fullyRead)return this.chunksRead++,!1;var t=this.options.chunkSize;return n=this.readChunk(e,t),r=function(e){return!!e&&e.byteLength===t},i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n)}catch(e){return Promise.reject(e)}var n,r,i}},{key:"readChunk",value:function(e,t){try{if(this.chunksRead++,0===(t=this.safeWrapAddress(e,t)))return;return this._readChunk(e,t)}catch(e){return Promise.reject(e)}}},{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}}]),n}(Ee));K.set("blob",Ke);var He=function(){function e(n,r,s){var a,u=this;t(this,e),i(this,"ensureSegmentChunk",(a=function(e){var t,n,r,i=e.start,s=e.size||65536;return t=function(){if(u.file.chunked)return function(){if(!u.file.available(i,s))return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return t=u.file.readChunk(i,s),n=function(t){e.chunk=t},r?n?n(t):t:(t&&t.then||(t=Promise.resolve(t)),n?t.then(n):t);var t,n,r}),(function(t){throw z("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}));e.chunk=u.file.subarray(i,s)}();if(u.file.byteLength>i+s)e.chunk=u.file.subarray(i,s);else{if(void 0!==e.size)throw z("Segment unreachable: "+JSON.stringify(e));e.chunk=u.file.subarray(i)}},n=function(t){return e.chunk},(r=t())&&r.then?r.then(n):n(r)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}})),this.extendOptions&&this.extendOptions(n),this.options=n,this.file=r,this.parsers=s}return r(e,[{key:"createParser",value:function(e,t){var n=new(W.get(e))(t,this.options,this.file);return this.parsers[e]=n}}]),e}(),Ge=function(){function e(n){var r=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;t(this,e),i(this,"errors",[]),i(this,"raw",S()),i(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=this.normalizeInput(n),this.file=a,this.type=this.constructor.type,this.globalOptions=this.options=s,this.localOptions=s[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}return r(e,[{key:"normalizeInput",value:function(e){return e instanceof D?e:new D(e)}}],[{key:"findPosition",value:function(e,t){var n=e.getUint16(t+2)+2,r="function"==typeof this.headerLength?this.headerLength(e,t,n):this.headerLength,i=t+r,s=n-r;return{offset:t,length:n,headerLength:r,start:i,size:s,end:i+s}}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new ge(i({},this.type,t)),r=new this(e,n);return r.parse()}}]),r(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var n=ie.get(t),r=re.get(t),i=ne.get(t),s=this.options[t],a=s.reviveValues&&!!n,u=s.translateValues&&!!r,o=s.translateKeys&&!!i,f={},h=e;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++){var l=h[c],d=l[0],v=l[1];a&&n.has(d)?v=n.get(d)(v):u&&r.has(d)&&(v=this.translateValue(v,r.get(d))),o&&i.has(d)&&(d=i.get(d)||d),f[d]=v}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,n){if(this.globalOptions.mergeOutput)return y(e,n);e[t]?y(e[t],n):e[t]=n}},{key:"output",get:function(){return this.translated?this.translated:this.raw?g(this.raw):void 0}}]),e}();function Je(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}i(Ge,"headerLength",4),i(Ge,"type",void 0),i(Ge,"multiSegment",!1),i(Ge,"canHandle",(function(){return!1}));function Xe(){}function qe(e,t){if(!t)return e&&e.then?e.then(Xe):Promise.resolve()}function Qe(e){var t=e();if(t&&t.then)return t.then(Xe)}function Ye(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function Ze(e,t,n){if(!e.s){if(n instanceof $e){if(!n.s)return void(n.o=Ze.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ze.bind(null,e,t),Ze.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var $e=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var s=1&i?t:n;if(s){try{Ze(r,1,s(this.v))}catch(e){Ze(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?Ze(r,1,t?t(i):i):n?Ze(r,1,n(i)):Ze(r,2,i)}catch(e){Ze(r,2,e)}},r},e}();function et(e){return e instanceof $e&&1&e.s}function tt(e,t,n){for(var r;;){var i=e();if(et(i)&&(i=i.v),!i)return s;if(i.then){r=0;break}var s=n();if(s&&s.then){if(!et(s)){r=1;break}s=s.s}if(t){var a=t();if(a&&a.then&&!et(a)){r=2;break}}}var u=new $e,o=Ze.bind(null,u,2);return(0===r?i.then(h):1===r?s.then(f):a.then(c)).then(void 0,o),u;function f(r){s=r;do{if(t&&(a=t())&&a.then&&!et(a))return void a.then(c).then(void 0,o);if(!(i=e())||et(i)&&!i.v)return void Ze(u,1,s);if(i.then)return void i.then(h).then(void 0,o);et(s=n())&&(s=s.v)}while(!s||!s.then);s.then(f).then(void 0,o)}function h(e){e?(s=n())&&s.then?s.then(f).then(void 0,o):f(s):Ze(u,1,s)}function c(){(i=e())?i.then?i.then(h).then(void 0,o):h(i):Ze(u,1,s)}}function nt(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function rt(e){return e>=224&&e<=239}function it(e,t){var n=W;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0];if(i[1].canHandle(e,t))return s}}var st=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"appSegments",[]),i(c(r),"jpegSegments",[]),i(c(r),"unknownSegments",[]),r}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return Je(e.findAppSegments(),(function(){return Je(e.readSegments(),(function(){e.mergeMultiSegments(),e.createParsers()}))}))}catch(e){return Promise.reject(e)}}},{key:"readSegments",value:function(){try{var e=this.appSegments.map(this.ensureSegmentChunk);return qe(Promise.all(e))}catch(e){return Promise.reject(e)}}},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=O(W.keyList())):(e=void 0===e?W.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&W.has(e)})),this.findAll=!1,this.remaining=O(e),this.wanted=O(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;try{var n=this;n.setupSegmentFinderArgs(t);var r=n.file,i=n.findAll,s=n.wanted,a=n.remaining;return Ye((function(){if(!i&&n.file.chunked)return i=k(s).some((function(e){var t=W.get(e),r=n.options[e];return t.multiSegment&&r.multiSegment})),Qe((function(){if(i)return qe(n.file.readWhole())}))}),(function(){var t=!1;if(e=n._findAppSegments(e,r.byteLength,i,s,a),!n.options.onlyTiff)return function(){if(r.chunked){var i=!1;return tt((function(){return!t&&a.size>0&&!i&&(!!r.canReadNextChunk||!!n.unfinishedMultiSegment)}),void 0,(function(){var s=r.nextChunkOffset,a=n.appSegments.some((function(e){return!n.file.available(e.offset||e.start,e.length||e.size)}));return Ye((function(){return e>s&&!a?Je(r.readNextChunk(e),(function(e){i=!e})):Je(r.readNextChunk(s),(function(e){i=!e}))}),(function(){void 0===(e=n._findAppSegments(e,r.byteLength))&&(t=!0)}))}))}}()}))}catch(e){return Promise.reject(e)}}},{key:"_findAppSegments",value:function(e,t){for(var n,r,i,s,a,u,o=this.file,f=this.findAll,h=this.wanted,c=this.remaining,l=this.options;e<t;e++)if(255===o.getUint8(e))if(rt(n=o.getUint8(e+1))){if(r=o.getUint16(e+2),(i=it(o,e))&&h.has(i)&&(a=(s=W.get(i)).findPosition(o,e),u=l[i],a.type=i,this.appSegments.push(a),!f&&(s.multiSegment&&u.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||c.delete(i)):c.delete(i),0===c.size)))break;l.recordUnknownSegments&&((a=Ge.findPosition(o,e)).marker=n,this.unknownSegments.push(a)),e+=r+1}else if(nt(n)){if(r=o.getUint16(e+2),218===n&&!1!==l.stopAfterSos)return;l.recordJpegSegments&&this.jpegSegments.push({offset:e,length:r,marker:n}),e+=r+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 n,r,i,s=S(),a=0;a<e.length;a++)n=e[a],r=n[t],s.has(r)?i=s.get(r):s.set(r,i=[]),i.push(n);return k(s)}(this.appSegments,"type");this.mergedAppSegments=t.map((function(t){var n=t[0],r=t[1],i=W.get(n,e.options);return i.handleMultiSegments?{type:n,chunk:i.handleMultiSegments(r)}:r[0]}))}}},{key:"createParsers",value:function(){try{var e=this.mergedAppSegments||this.appSegments;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t],r=n.type,i=n.chunk;if(this.options[r].enabled){var s=this.parsers[r];if(s&&s.append);else if(!s){var a=new(W.get(r,this.options))(i,this.options,this.file);this.parsers[r]=a}}}return Je()}catch(e){return Promise.reject(e)}}},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:function(e){try{var t=this,n=t.getSegment(e);return Ye((function(){if(void 0===n)return Je(t.findAppSegments(0,[e]),(function(){n=t.getSegment(e)}))}),(function(){return n}))}catch(e){return Promise.reject(e)}}}]),n}(He);function at(){}M.set("jpeg",st);function ut(e,t){if(!t)return e&&e.then?e.then(at):Promise.resolve()}function ot(e,t){var n=e();return n&&n.then?n.then(t):t(n)}var ft=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var ht=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return e.parseHeader(),ot((function(){if(e.options.ifd0.enabled)return ut(e.parseIfd0Block())}),(function(){return ot((function(){if(e.options.exif.enabled)return ut(e.saveParseBlock("parseExifBlock"))}),(function(){return ot((function(){if(e.options.gps.enabled)return ut(e.saveParseBlock("parseGpsBlock"))}),(function(){return ot((function(){if(e.options.interop.enabled)return ut(e.saveParseBlock("parseInteropBlock"))}),(function(){return ot((function(){if(e.options.ifd1.enabled)return ut(e.saveParseBlock("parseThumbnailBlock"))}),(function(){return e.createOutput()}))}))}))}))}))}catch(e){return Promise.reject(e)}}},{key:"saveParseBlock",value:function(e){try{var t=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return n=t[e](),i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n);var n,r,i}),(function(e){t.handleError(e)}))}catch(e){return Promise.reject(e)}}},{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 n=S();return this[t]=n,this.parseTags(e,t,n),n}},{key:"parseIfd0Block",value:function(){try{var e=this;if(e.ifd0)return;if(e.findIfd0Offset(),e.ifd0Offset<8)throw z("Invalid EXIF data: IFD0 offset should be less than 8");if(!e.file.chunked&&e.ifd0Offset>e.file.byteLength)throw z("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(e.ifd0Offset,", file.byteLength: ").concat(e.file.byteLength));return ot((function(){if(e.file.isTiff)return ut(e.file.ensureChunk(e.ifd0Offset,L(e.options)))}),(function(){var t=e.parseBlock(e.ifd0Offset,"ifd0");if(0!==t.size)return e.exifOffset=t.get(34665),e.interopOffset=t.get(40965),e.gpsOffset=t.get(34853),e.xmp=t.get(700),e.iptc=t.get(33723),e.icc=t.get(34675),e.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t}))}catch(e){return Promise.reject(e)}}},{key:"ensureBlockChunk",value:function(e,t){try{var n=this;return ot((function(){if(n.file.isTiff)return ut(n.file.ensureChunk(e,t))}),(function(){e>n.chunk.byteLength&&(n.chunk=D.from(n.file,n.le))}))}catch(e){return Promise.reject(e)}}},{key:"parseExifBlock",value:function(){try{var e=this;if(e.exif)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){if(void 0!==e.exifOffset)return ot((function(){if(e.file.isTiff)return ut(e.file.ensureChunk(e.exifOffset,L(e.options)))}),(function(){var t=e.parseBlock(e.exifOffset,"exif");return e.interopOffset||(e.interopOffset=t.get(40965)),e.makerNote=t.get(37500),e.userComment=t.get(37510),e.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),e.unpack(t,41728),e.unpack(t,41729),t}))}))}catch(e){return Promise.reject(e)}}},{key:"unpack",value:function(e,t){var n=e.get(t);n&&1===n.length&&e.set(t,n[0])}},{key:"parseGpsBlock",value:function(){try{var e=this;if(e.gps)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){if(void 0!==e.gpsOffset){var t=e.parseBlock(e.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",ct.apply(void 0,t.get(2).concat([t.get(1)]))),t.set("longitude",ct.apply(void 0,t.get(4).concat([t.get(3)])))),t}}))}catch(e){return Promise.reject(e)}}},{key:"parseInteropBlock",value:function(){try{var e=this;if(e.interop)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){return ot((function(){if(void 0===e.interopOffset&&!e.exif)return ut(e.parseExifBlock())}),(function(){if(void 0!==e.interopOffset)return e.parseBlock(e.interopOffset,"interop")}))}))}catch(e){return Promise.reject(e)}}},{key:"parseThumbnailBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{var t=this;if(t.ifd1||t.ifd1Parsed)return;if(t.options.mergeOutput&&!e)return;return t.findIfd1Offset(),t.ifd1Offset>0&&(t.parseBlock(t.ifd1Offset,"ifd1"),t.ifd1Parsed=!0),t.ifd1}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;return e.headerParsed||e.parseHeader(),ot((function(){if(!e.ifd1Parsed)return ut(e.parseThumbnailBlock(!0))}),(function(){if(void 0!==e.ifd1){var t=e.ifd1.get(513),n=e.ifd1.get(514);return e.chunk.getUint8Array(t,n)}}))}catch(e){return Promise.reject(e)}}},{key:"createOutput",value:function(){var e,t,n,r={},i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)if(!I(e=this[t=i[s]]))if(n=this.canTranslate?this.translateBlock(e,t):g(e),this.options.mergeOutput){if("ifd1"===t)continue;y(r,n)}else r[t]=n;return this.makerNote&&(r.makerNote=this.makerNote),this.userComment&&(r.userComment=this.userComment),r}},{key:"assignToOutput",value:function(e,t){if(this.globalOptions.mergeOutput)y(e,t);else{var n=p(t);Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0],a=i[1];this.assignObjectToOutput(e,s,a)}}}},{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)}}]),n}(function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parseHeader",value:function(){var e=this.chunk.getUint16();if(18761===e)this.le=!0;else{if(19789!==e)throw z("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 z("Invalid EXIF data: expected 0x002A.");this.headerParsed=!0}},{key:"parseTags",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S(),r=this.options[t],i=r.pick,s=r.skip,a=(i=O(i)).size>0,u=0===s.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var h=this.chunk.getUint16(e);if(a){if(i.has(h)&&(n.set(h,this.parseTag(e,h,t)),i.delete(h),0===i.size))break}else!u&&s.has(h)||n.set(h,this.parseTag(e,h,t));e+=12}return n}},{key:"parseTag",value:function(e,t,n){var r,i=this.chunk.getUint16(e+2),s=this.chunk.getUint32(e+4),a=ft[i];if(a*s<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw z("Invalid TIFF value type. block: ".concat(n.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw z("Invalid TIFF value offset. block: ".concat(n.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,s);if(2===i)return""===(r=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(r=this.chunk.getString(e,s)).trim())?void 0:r;if(7===i)return this.chunk.getUint8Array(e,s);if(1===s)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))(s),o=a,f=0;f<s;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 z("Invalid tiff type ".concat(e))}}}]),n}(Ge));function ct(e,t,n,r){var i=e+t/60+n/3600;return"S"!==r&&"W"!==r||(i*=-1),i}i(ht,"type","tiff"),i(ht,"headerLength",10),W.set("tiff",ht),e.Exifr=Be,e.Options=ge,e.allFormatters=le,e.chunkedProps=se,e.createDictionary=ee,e.default=Le,e.disableAllOptions=we,e.extendDictionary=te,e.fetchUrlAsArrayBuffer=X,e.fileParsers=M,e.fileReaders=K,e.gps=Ve,e.gpsOnlyOptions=Ae,e.inheritables=ce,e.orientation=_e,e.orientationOnlyOptions=Oe,e.otherSegments=ae,e.parse=ze,e.readBlobAsArrayBuffer=J,e.segmentParsers=W,e.segments=ue,e.segmentsAndBlocks=fe,e.tagKeys=ne,e.tagRevivers=ie,e.tagValues=re,e.thumbnail=Ie,e.thumbnailOnlyOptions=Se,e.thumbnailUrl=Te,e.tiffBlocks=oe,e.tiffExtractables=he,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,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function r(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(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}});var n=["prototype","__proto__","caller","arguments","length","name"];Object.getOwnPropertyNames(t).forEach((function(r){-1===n.indexOf(r)&&e[r]!==t[r]&&(e[r]=t[r])})),t&&u(e,t)}function a(e){return(a=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function u(e,t){return(u=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(){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 f(e,t,n){return(f=o()?Reflect.construct:function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&u(i,n.prototype),i}).apply(null,arguments)}function h(e){var t="function"==typeof Map?new Map:void 0;return(h=function(e){if(null===e||(n=e,-1===Function.toString.call(n).indexOf("[native code]")))return e;var n;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,r)}function r(){return f(e,arguments,a(this).constructor)}return r.prototype=Object.create(e.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),u(r,e)})(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function l(e,t){return!t||"object"!=typeof t&&"function"!=typeof t?c(e):t}function d(e,t,n){return(d="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(e,t,n){var r=function(e,t){for(;!Object.prototype.hasOwnProperty.call(e,t)&&null!==(e=a(e)););return e}(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(n):i.value}})(e,t,n||e)}var v=Object.values||function(e){var t=[];for(var n in e)t.push(e[n]);return t},p=Object.entries||function(e){var t=[];for(var n in e)t.push([n,e[n]]);return t},y=Object.assign||function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return n.forEach((function(t){for(var n in t)e[n]=t[n]})),e},g=Object.fromEntries||function(e){var t={};return k(e).forEach((function(e){var n=e[0],r=e[1];t[n]=r})),t},k=Array.from||function(e){if(e instanceof P){var t=[];return e.forEach((function(e,n){return t.push([n,e])})),t}return Array.prototype.slice.call(e)};function m(e){return-1!==this.indexOf(e)}Array.prototype.includes||(Array.prototype.includes=m),String.prototype.includes||(String.prototype.includes=m),String.prototype.startsWith||(String.prototype.startsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;return this.substring(t,t+e.length)===e}),String.prototype.endsWith||(String.prototype.endsWith=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.length;return this.substring(t-e.length,t)===e});var b="undefined"!=typeof self?self:global,w=b.TextDecoder||function(){function e(){t(this,e)}return r(e,[{key:"decode",value:function(e){var t=String.fromCharCode.apply(null,e);return decodeURIComponent(escape(t))}}]),e}(),A=b.fetch||function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(n,r){var i=new XMLHttpRequest;if(i.open("get",e,!0),i.responseType="arraybuffer",i.onerror=r,t.headers)for(var s in t.headers)i.setRequestHeader(s,t.headers[s]);i.onload=function(){n({ok:i.status>=200&&i.status<300,status:i.status,arrayBuffer:function(){return Promise.resolve(i.response)}})},i.send(null)}))},O=function(e){var t=[];if(Object.defineProperties(t,{size:{get:function(){return this.length}},has:{value:function(e){return-1!==this.indexOf(e)}},add:{value:function(e){this.has(e)||this.push(e)}},delete:{value:function(e){if(this.has(e)){var t=this.indexOf(e);this.splice(t,1)}}}}),Array.isArray(e))for(var n=0;n<e.length;n++)t.add(e[n]);return t},S=function(e){return new P(e)},P=void 0!==b.Map&&void 0!==b.Map.prototype.keys?b.Map:function(){function e(n){if(t(this,e),this.clear(),n)for(var r=0;r<n.length;r++)this.set(n[r][0],n[r][1])}return r(e,[{key:"clear",value:function(){this._map={},this._keys=[]}},{key:"get",value:function(e){return this._map["map_"+e]}},{key:"set",value:function(e,t){return this._map["map_"+e]=t,this._keys.indexOf(e)<0&&this._keys.push(e),this}},{key:"has",value:function(e){return this._keys.indexOf(e)>=0}},{key:"delete",value:function(e){var t=this._keys.indexOf(e);return!(t<0)&&(delete this._map["map_"+e],this._keys.splice(t,1),!0)}},{key:"keys",value:function(){return this._keys.slice(0)}},{key:"values",value:function(){var e=this;return this._keys.map((function(t){return e.get(t)}))}},{key:"entries",value:function(){var e=this;return this._keys.map((function(t){return[t,e.get(t)]}))}},{key:"forEach",value:function(e,t){for(var n=0;n<this._keys.length;n++)e.call(t,this._map["map_"+this._keys[n]],this._keys[n],this)}},{key:"size",get:function(){return this._keys.length}}]),e}(),U="undefined"!=typeof self?self:global,x="undefined"!=typeof navigator,B=x&&"undefined"==typeof HTMLImageElement,C=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node),j=U.Buffer,_=U.BigInt,V=!!j;var T=function(e){return void 0!==e};function I(e){return void 0===e||(e instanceof P?0===e.size:0===v(e).filter(T).length)}function L(e){var t=new Error(e);return delete t.stack,t}function z(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 F=new w("utf-8");function E(e){return F.decode(e)}var D=function(){function e(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0;if(t(this,e),"boolean"==typeof s&&(this.le=s),Array.isArray(n)&&(n=new Uint8Array(n)),0===n)this.byteOffset=0,this.byteLength=0;else if(n instanceof ArrayBuffer){void 0===i&&(i=n.byteLength-r);var a=new DataView(n,r,i);this._swapDataView(a)}else if(n instanceof Uint8Array||n instanceof DataView||n instanceof e){if(void 0===i&&(i=n.byteLength-r),(r+=n.byteOffset)+i>n.byteOffset+n.byteLength)throw L("Creating view outside of available memory in ArrayBuffer");var u=new DataView(n.buffer,r,i);this._swapDataView(u)}else{if("number"!=typeof n)throw L("Invalid input argument for BufferView: "+n);var o=new DataView(new ArrayBuffer(n));this._swapDataView(o)}}return r(e,null,[{key:"from",value:function(t,n){return t instanceof this&&t.le===n?t:new e(t,void 0,void 0,n)}}]),r(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,n){var r=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 L("BufferView.set(): Invalid data argument.");var i=this.toUint8();return i.set(t,n),new r(this,n,t.byteLength)}},{key:"subarray",value:function(t,n){return new e(this,t,n=n||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,n=this.getUint8Array(e,t);return E(n)}},{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,n=[],r=0;r<t&&e+r<this.byteLength;r+=2)n.push(this.getUint16(e+r));return n.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 t=this.getUint32(e),n=this.getUint32(e+4);if(t<1048575)return t<<32|n;if(void 0!==typeof _)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),_(t)<<_(32)|_(n);throw L("Trying to read 64b value but JS can only handle 53b numbers.")}},{key:"getUintBytes",value:function(e,t,n){switch(t){case 1:return this.getUint8(e,n);case 2:return this.getUint16(e,n);case 4:return this.getUint32(e,n);case 8:return this.getUint64(e,n)}}},{key:"getUint",value:function(e,t,n){switch(t){case 8:return this.getUint8(e,n);case 16:return this.getUint16(e,n);case 32:return this.getUint32(e,n);case 64:return this.getUint64(e,n)}}},{key:"toString",value:function(e){return this.dataView.toString(e,this.constructor.name)}},{key:"ensureChunk",value:function(){}}]),e}();function R(e,t){throw L("".concat(e," '").concat(t,"' was not loaded, try using full build of exifr."))}var N=function(e){function n(e){var r;return t(this,n),(r=l(this,a(n).call(this))).kind=e,r}return s(n,e),r(n,[{key:"get",value:function(e,t){return this.has(e)||R(this.kind,e),t&&(e in t||function(e,t){throw L("Unknown ".concat(e," '").concat(t,"'."))}(this.kind,e),t[e].enabled||R(this.kind,e)),d(a(n.prototype),"get",this).call(this,e)}},{key:"keyList",value:function(){return k(this.keys())}}]),n}(h(P)),M=new N("file parser"),W=new N("segment parser"),K=new N("file reader");function H(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}function G(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var J=H((function(e){return new Promise((function(t,n){var r=new FileReader;r.onloadend=function(){return t(r.result||new ArrayBuffer)},r.onerror=n,r.readAsArrayBuffer(e)}))})),X=H((function(e){return A(e).then((function(e){return e.arrayBuffer()}))})),q=H((function(e,t){return G(t(e),(function(e){return new D(e)}))})),Q=H((function(e,t,n){var r=new(K.get(n))(e,t);return G(r.read(),(function(){return r}))})),Y=H((function(e,t,n,r){if(K.has(n))return Q(e,t,n);if(r)return q(e,r);throw L("Parser ".concat(n," is not loaded"))}));function Z(e,t){if((n=e).startsWith("data:")||n.length>1e4)return Q(e,t,"base64");if(x)return Y(e,t,"url",X);if(C)return Q(e,t,"fs");throw L("Invalid input argument");var n}var $=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"tagKeys",get:function(){return this.allKeys||(this.allKeys=k(this.keys())),this.allKeys}},{key:"tagValues",get:function(){return this.allValues||(this.allValues=k(this.values())),this.allValues}}]),n}(h(P));function ee(e,t,n){var r=new $,i=n;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s],u=a[0],o=a[1];r.set(u,o)}if(Array.isArray(t)){var f=t;Array.isArray(f)||("function"==typeof f.entries&&(f=f.entries()),f=k(f));for(var h=0;h<f.length;h++){var c=f[h];e.set(c,r)}}else e.set(t,r);return r}function te(e,t,n){var r,i=e.get(t),s=n;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)r=s[a],i.set(r[0],r[1])}var ne=S(),re=S(),ie=S(),se=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],ae=["jfif","xmp","icc","iptc"],ue=["tiff"].concat(ae),oe=["ifd0","ifd1","exif","gps","interop"],fe=[].concat(ue,oe),he=["makerNote","userComment"],ce=["translateKeys","translateValues","reviveValues","multiSegment"],le=[].concat(ce,["sanitize","mergeOutput"]),de=function(){function e(){t(this,e)}return r(e,[{key:"translate",get:function(){return this.translateKeys||this.translateValues||this.reviveValues}}]),e}(),ve=function(e){function n(e,r,s,u){var o;if(t(this,n),i(c(o=l(this,a(n).call(this))),"enabled",!1),i(c(o),"skip",O()),i(c(o),"pick",O()),i(c(o),"deps",O()),i(c(o),"translateKeys",!1),i(c(o),"translateValues",!1),i(c(o),"reviveValues",!1),o.key=e,o.enabled=r,o.parse=o.enabled,o.applyInheritables(u),o.canBeFiltered=oe.includes(e),o.canBeFiltered&&(o.dict=ne.get(e)),void 0!==s)if(Array.isArray(s))o.parse=o.enabled=!0,o.canBeFiltered&&s.length>0&&o.translateTagSet(s,o.pick);else if("object"==typeof s){if(o.enabled=!0,o.parse=!1!==s.parse,o.canBeFiltered){var f=s.pick,h=s.skip;f&&f.length>0&&o.translateTagSet(f,o.pick),h&&h.length>0&&o.translateTagSet(h,o.skip)}o.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw L("Invalid options argument: ".concat(s));o.parse=o.enabled=s}return o}return s(n,e),r(n,[{key:"needed",get:function(){return this.enabled||this.deps.size>0}}]),r(n,[{key:"applyInheritables",value:function(e){var t,n,r=ce;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)void 0!==(n=e[t=r[i]])&&(this[t]=n)}},{key:"translateTagSet",value:function(e,t){if(this.dict){var n,r,i=this.dict,s=i.tagKeys,a=i.tagValues,u=e;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)"string"==typeof(n=u[o])?(-1===(r=a.indexOf(n))&&(r=s.indexOf(Number(n))),-1!==r&&t.add(Number(s[r]))):t.add(n)}else{var f=e;Array.isArray(f)||("function"==typeof f.entries&&(f=f.entries()),f=k(f));for(var h=0;h<f.length;h++){var c=f[h];t.add(c)}}}},{key:"finalizeFilters",value:function(){!this.enabled&&this.deps.size>0?(this.enabled=!0,be(this.pick,this.deps)):this.enabled&&this.pick.size>0&&be(this.pick,this.deps)}}]),n}(de),pe={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},ye=S(),ge=function(e){function n(e){var r;if(t(this,n),r=l(this,a(n).call(this)),!0===e)r.setupFromTrue();else if(void 0===e)r.setupFromUndefined();else if(Array.isArray(e))r.setupFromArray(e);else{if("object"!=typeof e)throw L("Invalid options argument ".concat(e));r.setupFromObject(e)}return void 0===r.firstChunkSize&&(r.firstChunkSize=x?r.firstChunkSizeBrowser:r.firstChunkSizeNode),r.mergeOutput&&(r.ifd1.enabled=!1),r.filterNestedSegmentTags(),r.traverseTiffDependencyTree(),r.checkLoadedPlugins(),r}return s(n,e),r(n,null,[{key:"useCached",value:function(e){var t=ye.get(e);return void 0!==t?t:(t=new this(e),ye.set(e,t),t)}}]),r(n,[{key:"setupFromUndefined",value:function(){var e,t=se;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=pe[e];var r=le;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=pe[e];var s=he;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=pe[e];var u=fe;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new ve(e,pe[e],void 0,this)}},{key:"setupFromTrue",value:function(){var e,t=se;Array.isArray(t)||("function"==typeof t.entries&&(t=t.entries()),t=k(t));for(var n=0;n<t.length;n++)this[e=t[n]]=pe[e];var r=le;Array.isArray(r)||("function"==typeof r.entries&&(r=r.entries()),r=k(r));for(var i=0;i<r.length;i++)this[e=r[i]]=pe[e];var s=he;Array.isArray(s)||("function"==typeof s.entries&&(s=s.entries()),s=k(s));for(var a=0;a<s.length;a++)this[e=s[a]]=!0;var u=fe;Array.isArray(u)||("function"==typeof u.entries&&(u=u.entries()),u=k(u));for(var o=0;o<u.length;o++)this[e=u[o]]=new ve(e,!0,void 0,this)}},{key:"setupFromArray",value:function(e){var t,n=se;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=pe[t];var i=le;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=pe[t];var a=he;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=pe[t];var o=fe;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new ve(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,oe)}},{key:"setupFromObject",value:function(e){var t;oe.ifd0=oe.ifd0||oe.image,oe.ifd1=oe.ifd1||oe.thumbnail,y(this,e);var n=se;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++)this[t=n[r]]=me(e[t],pe[t]);var i=le;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)this[t=i[s]]=me(e[t],pe[t]);var a=he;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++)this[t=a[u]]=me(e[t],pe[t]);var o=ue;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)this[t=o[f]]=new ve(t,pe[t],e[t],this);var h=oe;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++)this[t=h[c]]=new ve(t,pe[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,oe,fe),!0===e.tiff?this.batchEnableWithBool(oe,!0):!1===e.tiff?this.batchEnableWithUserValue(oe,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,oe):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,oe)}},{key:"batchEnableWithBool",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){this[n[r]].enabled=t}}},{key:"batchEnableWithUserValue",value:function(e,t){var n=e;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=t[i];this[i].enabled=!1!==s&&void 0!==s}}},{key:"setupGlobalFilters",value:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:n;if(e&&e.length){var i=r;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){var a=i[s];this[a].enabled=!1}var u=ke(e,n),o=u;Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++){var h=o[f],c=h[0],l=h[1];be(this[c].pick,l),this[c].enabled=!0}}else if(t&&t.length){var d=ke(t,n),v=d;Array.isArray(v)||("function"==typeof v.entries&&(v=v.entries()),v=k(v));for(var p=0;p<v.length;p++){var y=v[p],g=y[0],m=y[1];be(this[g].skip,m)}}}},{key:"filterNestedSegmentTags",value:function(){var e=this.ifd0,t=this.exif,n=this.xmp,r=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),n.enabled||e.skip.add(700),r.enabled||e.skip.add(33723),i.enabled||e.skip.add(34675)}},{key:"traverseTiffDependencyTree",value:function(){var e=this,t=this.ifd0,n=this.exif,r=this.gps;this.interop.needed&&(n.deps.add(40965),t.deps.add(40965)),n.needed&&t.deps.add(34665),r.needed&&t.deps.add(34853),this.tiff.enabled=oe.some((function(t){return!0===e[t].enabled}))||this.makerNote||this.userComment;var i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++){this[i[s]].finalizeFilters()}}},{key:"checkLoadedPlugins",value:function(){var e=ue;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t];this[n].enabled&&!W.has(n)&&R("segment parser",n)}}},{key:"onlyTiff",get:function(){var e=this;return!ae.map((function(t){return e[t].enabled})).some((function(e){return!0===e}))&&this.tiff.enabled}}]),n}(de);function ke(e,t){var n,r,i,s=[],a=t;Array.isArray(a)||("function"==typeof a.entries&&(a=a.entries()),a=k(a));for(var u=0;u<a.length;u++){r=a[u],n=[];var o=ne.get(r);Array.isArray(o)||("function"==typeof o.entries&&(o=o.entries()),o=k(o));for(var f=0;f<o.length;f++)i=o[f],(e.includes(i[0])||e.includes(i[1]))&&n.push(i[0]);n.length&&s.push([r,n])}return s}function me(e,t){return void 0!==e?e:void 0!==t?t:void 0}function be(e,t){var n=t;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r];e.add(i)}}i(ge,"default",pe);var we={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Ae=y({},we,{firstChunkSize:4e4,gps:[1,2,3,4]}),Oe=y({},we,{firstChunkSize:4e4,ifd0:[274]}),Se=y({},we,{tiff:!1,ifd1:!0,mergeOutput:!1});function Pe(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function Ue(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function xe(){}var Be=function(){function e(n){t(this,e),i(this,"parsers",{}),this.options=ge.useCached(n)}return r(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=M.get("tiff");else if(65496===t)this.file.isJpeg=!0,e=M.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 n=16,r=[];n<t;)r.push(e.getString(n,4)),n+=4;return r.includes("heic")}(this.file))throw L("Unknown file format");this.file.isHeic=!0,e=M.get("heic")}this.fileParser=new e(this.options,this.file,this.parsers)}}},{key:"read",value:function(e){try{var t=this;return Pe(function(e,t){if("string"==typeof e)return Z(e,t);if(x&&!B&&e instanceof HTMLImageElement)return Z(e.src,t);if(e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView)return new D(e);if(x&&e instanceof Blob)return Y(e,t,"blob",J);throw L("Invalid input argument")}(e,t.options),(function(e){t.file=e}))}catch(e){return Promise.reject(e)}}},{key:"parse",value:function(){try{var e=this;return e.setup(),Pe(e.fileParser.parse(),(function(){var t,n={},r=[],i=v(e.parsers).map((t=function(t){var i;return Ue((function(){return e.options.silentErrors?(n=function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return Pe(t.parse(),(function(e){i=e}))}),(function(e){r.push(e)})),s=function(){t.errors.length&&r.push.apply(r,t.errors)},n&&n.then?n.then(s):s(n)):Pe(t.parse(),(function(e){i=e}));var n,s}),(function(){t.assignToOutput(n,i)}))},function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];try{return Promise.resolve(t.apply(this,e))}catch(e){return Promise.reject(e)}}));return Pe(Promise.all(i),(function(){var t;return e.options.silentErrors&&r.length>0&&(n.errors=r),n=I(t=n)?void 0:t,e.file.close&&e.file.close(),n}))}))}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;e.setup();var t,n=W.get("tiff",e.options);return Ue((function(){if(!e.file.isTiff)return function(e){var t=e();if(t&&t.then)return t.then(xe)}((function(){if(e.file.isJpeg)return Pe(e.fileParser.getOrFindSegment("tiff"),(function(e){t=e}))}));t={start:0,type:"tiff"}}),(function(){if(void 0!==t)return Pe(e.fileParser.ensureSegmentChunk(t),(function(t){return Pe((e.parsers.tiff=new n(t,e.options,e.file)).extractThumbnail(),(function(t){return e.file.close&&e.file.close(),t}))}))}))}catch(e){return Promise.reject(e)}}}]),e}();function Ce(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}function je(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];try{return Promise.resolve(e.apply(this,t))}catch(e){return Promise.reject(e)}}}var _e=je((function(e){var t=new Be(Oe);return Ce(t.read(e),(function(){return Ce(t.parse(),(function(e){if(e&&e.ifd0)return e.ifd0[274]}))}))})),Ve=je((function(e){var t=new Be(Ae);return Ce(t.read(e),(function(){return Ce(t.parse(),(function(e){if(e&&e.gps){var t=e.gps;return{latitude:t.latitude,longitude:t.longitude}}}))}))})),Te=je((function(e){return Ce(this.thumbnail(e),(function(e){if(void 0!==e){var t=new Blob([e]);return URL.createObjectURL(t)}}))})),Ie=je((function(e){var t=new Be(Se);return Ce(t.read(e),(function(){return Ce(t.extractThumbnail(),(function(e){return e&&V?j.from(e):e}))}))})),Le=je((function(e,t){var n=new Be(t);return Ce(n.read(e),(function(){return n.parse()}))})),ze=Object.freeze({__proto__:null,orientation:_e,gps:Ve,thumbnailUrl:Te,thumbnail:Ie,parse:Le,Exifr:Be,fileParsers:M,segmentParsers:W,fileReaders:K,tagKeys:ne,tagValues:re,tagRevivers:ie,createDictionary:ee,extendDictionary:te,fetchUrlAsArrayBuffer:X,readBlobAsArrayBuffer:J,chunkedProps:se,otherSegments:ae,segments:ue,tiffBlocks:oe,segmentsAndBlocks:fe,tiffExtractables:he,inheritables:ce,allFormatters:le,Options:ge,disableAllOptions:we,gpsOnlyOptions:Ae,orientationOnlyOptions:Oe,thumbnailOnlyOptions:Se});function Fe(){}var Ee=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"ranges",new De),0!==r.byteLength&&r.ranges.add(0,r.byteLength),r}return s(n,e),r(n,[{key:"_tryExtend",value:function(e,t,n){if(0===e&&0===this.byteLength&&n){var r=new DataView(n.buffer||n,n.byteOffset,n.byteLength);this._swapDataView(r)}else{var i=e+t;if(i>this.byteLength){var s=this._extend(i).dataView;this._swapDataView(s)}}}},{key:"_extend",value:function(e){var t;t=V?j.allocUnsafe(e):new Uint8Array(e);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return t.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:t,dataView:n}}},{key:"subarray",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return t=t||this._lengthToEnd(e),r&&this._tryExtend(e,t),this.ranges.add(e,t),d(a(n.prototype),"subarray",this).call(this,e,t)}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r&&this._tryExtend(t,e.byteLength,e);var i=d(a(n.prototype),"set",this).call(this,e,t);return this.ranges.add(t,i.byteLength),i}},{key:"ensureChunk",value:function(e,t){try{if(!this.chunked)return;if(this.ranges.available(e,t))return;return function(e,t){if(!t)return e&&e.then?e.then(Fe):Promise.resolve()}(this.readChunk(e,t))}catch(e){return Promise.reject(e)}}},{key:"available",value:function(e,t){return this.ranges.available(e,t)}}]),n}(D),De=function(){function e(){t(this,e),i(this,"list",[])}return r(e,[{key:"add",value:function(e,t){var n=e+t,r=this.list.filter((function(t){return Re(e,t.offset,n)||Re(e,t.end,n)}));if(r.length>0){e=Math.min.apply(Math,[e].concat(r.map((function(e){return e.offset})))),t=(n=Math.max.apply(Math,[n].concat(r.map((function(e){return e.end})))))-e;var i=r.shift();i.offset=e,i.length=t,i.end=n,this.list=this.list.filter((function(e){return!r.includes(e)}))}else this.list.push({offset:e,length:t,end:n})}},{key:"available",value:function(e,t){var n=e+t;return this.list.some((function(t){return t.offset<=e&&n<=t.end}))}},{key:"length",get:function(){return this.list.length}}]),e}();function Re(e,t,n){return e<=t&&t<=n}function Ne(){}function Me(e,t){if(!t)return e&&e.then?e.then(Ne):Promise.resolve()}function We(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}var Ke=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"readWhole",value:function(){try{var e=this;return e.chunked=!1,We(J(e.input),(function(t){e._swapArrayBuffer(t)}))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){return this.chunked=!0,this.size=this.input.size,d(a(n.prototype),"readChunked",this).call(this)}},{key:"_readChunk",value:function(e,t){try{var n=this,r=t?e+t:void 0,i=n.input.slice(e,r);return We(J(i),(function(t){return n.set(t,e,!0)}))}catch(e){return Promise.reject(e)}}}]),n}(function(e){function n(e,r){var s;return t(this,n),i(c(s=l(this,a(n).call(this,0))),"chunksRead",0),s.input=e,s.options=r,s}return s(n,e),r(n,[{key:"readWhole",value:function(){try{return this.chunked=!1,Me(this.readChunk(this.nextChunkOffset))}catch(e){return Promise.reject(e)}}},{key:"readChunked",value:function(){try{return this.chunked=!0,Me(this.readChunk(0,this.options.firstChunkSize))}catch(e){return Promise.reject(e)}}},{key:"readNextChunk",value:function(e){try{if(void 0===e&&(e=this.nextChunkOffset),this.fullyRead)return this.chunksRead++,!1;var t=this.options.chunkSize;return n=this.readChunk(e,t),r=function(e){return!!e&&e.byteLength===t},i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n)}catch(e){return Promise.reject(e)}var n,r,i}},{key:"readChunk",value:function(e,t){try{if(this.chunksRead++,0===(t=this.safeWrapAddress(e,t)))return;return this._readChunk(e,t)}catch(e){return Promise.reject(e)}}},{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}}]),n}(Ee));K.set("blob",Ke);var He=function(){function e(n,r,s){var a,u=this;t(this,e),i(this,"ensureSegmentChunk",(a=function(e){var t,n,r,i=e.start,s=e.size||65536;return t=function(){if(u.file.chunked)return function(){if(!u.file.available(i,s))return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return t=u.file.readChunk(i,s),n=function(t){e.chunk=t},r?n?n(t):t:(t&&t.then||(t=Promise.resolve(t)),n?t.then(n):t);var t,n,r}),(function(t){throw L("Couldn't read segment: ".concat(JSON.stringify(e),". ").concat(t.message))}));e.chunk=u.file.subarray(i,s)}();if(u.file.byteLength>i+s)e.chunk=u.file.subarray(i,s);else{if(void 0!==e.size)throw L("Segment unreachable: "+JSON.stringify(e));e.chunk=u.file.subarray(i)}},n=function(t){return e.chunk},(r=t())&&r.then?r.then(n):n(r)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{return Promise.resolve(a.apply(this,e))}catch(e){return Promise.reject(e)}})),this.extendOptions&&this.extendOptions(n),this.options=n,this.file=r,this.parsers=s}return r(e,[{key:"createParser",value:function(e,t){var n=new(W.get(e))(t,this.options,this.file);return this.parsers[e]=n}}]),e}(),Ge=function(){function e(n){var r=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;t(this,e),i(this,"errors",[]),i(this,"raw",S()),i(this,"handleError",(function(e){if(!r.options.silentErrors)throw e;r.errors.push(e.message)})),this.chunk=this.normalizeInput(n),this.file=a,this.type=this.constructor.type,this.globalOptions=this.options=s,this.localOptions=s[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}return r(e,[{key:"normalizeInput",value:function(e){return e instanceof D?e:new D(e)}}],[{key:"findPosition",value:function(e,t){var n=e.getUint16(t+2)+2,r="function"==typeof this.headerLength?this.headerLength(e,t,n):this.headerLength,i=t+r,s=n-r;return{offset:t,length:n,headerLength:r,start:i,size:s,end:i+s}}},{key:"parse",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=new ge(i({},this.type,t)),r=new this(e,n);return r.parse()}}]),r(e,[{key:"translate",value:function(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}},{key:"translateBlock",value:function(e,t){var n=ie.get(t),r=re.get(t),i=ne.get(t),s=this.options[t],a=s.reviveValues&&!!n,u=s.translateValues&&!!r,o=s.translateKeys&&!!i,f={},h=e;Array.isArray(h)||("function"==typeof h.entries&&(h=h.entries()),h=k(h));for(var c=0;c<h.length;c++){var l=h[c],d=l[0],v=l[1];a&&n.has(d)?v=n.get(d)(v):u&&r.has(d)&&(v=this.translateValue(v,r.get(d))),o&&i.has(d)&&(d=i.get(d)||d),f[d]=v}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,n){if(this.globalOptions.mergeOutput)return y(e,n);e[t]?y(e[t],n):e[t]=n}},{key:"output",get:function(){return this.translated?this.translated:this.raw?g(this.raw):void 0}}]),e}();function Je(e,t,n){return n?t?t(e):e:(e&&e.then||(e=Promise.resolve(e)),t?e.then(t):e)}i(Ge,"headerLength",4),i(Ge,"type",void 0),i(Ge,"multiSegment",!1),i(Ge,"canHandle",(function(){return!1}));function Xe(){}function qe(e,t){if(!t)return e&&e.then?e.then(Xe):Promise.resolve()}function Qe(e){var t=e();if(t&&t.then)return t.then(Xe)}function Ye(e,t){var n=e();return n&&n.then?n.then(t):t(n)}function Ze(e,t,n){if(!e.s){if(n instanceof $e){if(!n.s)return void(n.o=Ze.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(Ze.bind(null,e,t),Ze.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}var $e=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var s=1&i?t:n;if(s){try{Ze(r,1,s(this.v))}catch(e){Ze(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?Ze(r,1,t?t(i):i):n?Ze(r,1,n(i)):Ze(r,2,i)}catch(e){Ze(r,2,e)}},r},e}();function et(e){return e instanceof $e&&1&e.s}function tt(e,t,n){for(var r;;){var i=e();if(et(i)&&(i=i.v),!i)return s;if(i.then){r=0;break}var s=n();if(s&&s.then){if(!et(s)){r=1;break}s=s.s}if(t){var a=t();if(a&&a.then&&!et(a)){r=2;break}}}var u=new $e,o=Ze.bind(null,u,2);return(0===r?i.then(h):1===r?s.then(f):a.then(c)).then(void 0,o),u;function f(r){s=r;do{if(t&&(a=t())&&a.then&&!et(a))return void a.then(c).then(void 0,o);if(!(i=e())||et(i)&&!i.v)return void Ze(u,1,s);if(i.then)return void i.then(h).then(void 0,o);et(s=n())&&(s=s.v)}while(!s||!s.then);s.then(f).then(void 0,o)}function h(e){e?(s=n())&&s.then?s.then(f).then(void 0,o):f(s):Ze(u,1,s)}function c(){(i=e())?i.then?i.then(h).then(void 0,o):h(i):Ze(u,1,s)}}function nt(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function rt(e){return e>=224&&e<=239}function it(e,t){var n=W;Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0];if(i[1].canHandle(e,t))return s}}var st=function(e){function n(){var e,r;t(this,n);for(var s=arguments.length,u=new Array(s),o=0;o<s;o++)u[o]=arguments[o];return i(c(r=l(this,(e=a(n)).call.apply(e,[this].concat(u)))),"appSegments",[]),i(c(r),"jpegSegments",[]),i(c(r),"unknownSegments",[]),r}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return Je(e.findAppSegments(),(function(){return Je(e.readSegments(),(function(){e.mergeMultiSegments(),e.createParsers()}))}))}catch(e){return Promise.reject(e)}}},{key:"readSegments",value:function(){try{var e=this.appSegments.map(this.ensureSegmentChunk);return qe(Promise.all(e))}catch(e){return Promise.reject(e)}}},{key:"setupSegmentFinderArgs",value:function(e){var t=this;!0===e?(this.findAll=!0,this.wanted=O(W.keyList())):(e=void 0===e?W.keyList().filter((function(e){return t.options[e].enabled})):e.filter((function(e){return t.options[e].enabled&&W.has(e)})),this.findAll=!1,this.remaining=O(e),this.wanted=O(e)),this.unfinishedMultiSegment=!1}},{key:"findAppSegments",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,t=arguments.length>1?arguments[1]:void 0;try{var n=this;n.setupSegmentFinderArgs(t);var r=n.file,i=n.findAll,s=n.wanted,a=n.remaining;return Ye((function(){if(!i&&n.file.chunked)return i=k(s).some((function(e){var t=W.get(e),r=n.options[e];return t.multiSegment&&r.multiSegment})),Qe((function(){if(i)return qe(n.file.readWhole())}))}),(function(){var t=!1;if(e=n._findAppSegments(e,r.byteLength,i,s,a),!n.options.onlyTiff)return function(){if(r.chunked){var i=!1;return tt((function(){return!t&&a.size>0&&!i&&(!!r.canReadNextChunk||!!n.unfinishedMultiSegment)}),void 0,(function(){var s=r.nextChunkOffset,a=n.appSegments.some((function(e){return!n.file.available(e.offset||e.start,e.length||e.size)}));return Ye((function(){return e>s&&!a?Je(r.readNextChunk(e),(function(e){i=!e})):Je(r.readNextChunk(s),(function(e){i=!e}))}),(function(){void 0===(e=n._findAppSegments(e,r.byteLength))&&(t=!0)}))}))}}()}))}catch(e){return Promise.reject(e)}}},{key:"_findAppSegments",value:function(e,t){for(var n,r,i,s,a,u,o=this.file,f=this.findAll,h=this.wanted,c=this.remaining,l=this.options;e<t;e++)if(255===o.getUint8(e))if(rt(n=o.getUint8(e+1))){if(r=o.getUint16(e+2),(i=it(o,e))&&h.has(i)&&(a=(s=W.get(i)).findPosition(o,e),u=l[i],a.type=i,this.appSegments.push(a),!f&&(s.multiSegment&&u.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||c.delete(i)):c.delete(i),0===c.size)))break;l.recordUnknownSegments&&((a=Ge.findPosition(o,e)).marker=n,this.unknownSegments.push(a)),e+=r+1}else if(nt(n)){if(r=o.getUint16(e+2),218===n&&!1!==l.stopAfterSos)return;l.recordJpegSegments&&this.jpegSegments.push({offset:e,length:r,marker:n}),e+=r+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 n,r,i,s=S(),a=0;a<e.length;a++)n=e[a],r=n[t],s.has(r)?i=s.get(r):s.set(r,i=[]),i.push(n);return k(s)}(this.appSegments,"type");this.mergedAppSegments=t.map((function(t){var n=t[0],r=t[1],i=W.get(n,e.options);return i.handleMultiSegments?{type:n,chunk:i.handleMultiSegments(r)}:r[0]}))}}},{key:"createParsers",value:function(){try{var e=this.mergedAppSegments||this.appSegments;Array.isArray(e)||("function"==typeof e.entries&&(e=e.entries()),e=k(e));for(var t=0;t<e.length;t++){var n=e[t],r=n.type,i=n.chunk;if(this.options[r].enabled){var s=this.parsers[r];if(s&&s.append);else if(!s){var a=new(W.get(r,this.options))(i,this.options,this.file);this.parsers[r]=a}}}return Je()}catch(e){return Promise.reject(e)}}},{key:"getSegment",value:function(e){return this.appSegments.find((function(t){return t.type===e}))}},{key:"getOrFindSegment",value:function(e){try{var t=this,n=t.getSegment(e);return Ye((function(){if(void 0===n)return Je(t.findAppSegments(0,[e]),(function(){n=t.getSegment(e)}))}),(function(){return n}))}catch(e){return Promise.reject(e)}}}]),n}(He);function at(){}M.set("jpeg",st);function ut(e,t){if(!t)return e&&e.then?e.then(at):Promise.resolve()}function ot(e,t){var n=e();return n&&n.then?n.then(t):t(n)}var ft=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];var ht=function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parse",value:function(){try{var e=this;return e.parseHeader(),ot((function(){if(e.options.ifd0.enabled)return ut(e.parseIfd0Block())}),(function(){return ot((function(){if(e.options.exif.enabled)return ut(e.saveParseBlock("parseExifBlock"))}),(function(){return ot((function(){if(e.options.gps.enabled)return ut(e.saveParseBlock("parseGpsBlock"))}),(function(){return ot((function(){if(e.options.interop.enabled)return ut(e.saveParseBlock("parseInteropBlock"))}),(function(){return ot((function(){if(e.options.ifd1.enabled)return ut(e.saveParseBlock("parseThumbnailBlock"))}),(function(){return e.createOutput()}))}))}))}))}))}catch(e){return Promise.reject(e)}}},{key:"saveParseBlock",value:function(e){try{var t=this;return function(e,t){try{var n=e()}catch(e){return t(e)}return n&&n.then?n.then(void 0,t):n}((function(){return n=t[e](),i?r?r(n):n:(n&&n.then||(n=Promise.resolve(n)),r?n.then(r):n);var n,r,i}),(function(e){t.handleError(e)}))}catch(e){return Promise.reject(e)}}},{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 n=S();return this[t]=n,this.parseTags(e,t,n),n}},{key:"parseIfd0Block",value:function(){try{var e=this;if(e.ifd0)return;if(e.findIfd0Offset(),e.ifd0Offset<8)throw L("Invalid EXIF data: IFD0 offset should be less than 8");if(!e.file.chunked&&e.ifd0Offset>e.file.byteLength)throw L("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(e.ifd0Offset,", file.byteLength: ").concat(e.file.byteLength));return ot((function(){if(e.file.isTiff)return ut(e.file.ensureChunk(e.ifd0Offset,z(e.options)))}),(function(){var t=e.parseBlock(e.ifd0Offset,"ifd0");if(0!==t.size)return e.exifOffset=t.get(34665),e.interopOffset=t.get(40965),e.gpsOffset=t.get(34853),e.xmp=t.get(700),e.iptc=t.get(33723),e.icc=t.get(34675),e.options.sanitize&&(t.delete(34665),t.delete(40965),t.delete(34853),t.delete(700),t.delete(33723),t.delete(34675)),t}))}catch(e){return Promise.reject(e)}}},{key:"ensureBlockChunk",value:function(e,t){try{var n=this;return ot((function(){if(n.file.isTiff)return ut(n.file.ensureChunk(e,t))}),(function(){e>n.chunk.byteLength&&(n.chunk=D.from(n.file,n.le))}))}catch(e){return Promise.reject(e)}}},{key:"parseExifBlock",value:function(){try{var e=this;if(e.exif)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){if(void 0!==e.exifOffset)return ot((function(){if(e.file.isTiff)return ut(e.file.ensureChunk(e.exifOffset,z(e.options)))}),(function(){var t=e.parseBlock(e.exifOffset,"exif");return e.interopOffset||(e.interopOffset=t.get(40965)),e.makerNote=t.get(37500),e.userComment=t.get(37510),e.options.sanitize&&(t.delete(40965),t.delete(37500),t.delete(37510)),e.unpack(t,41728),e.unpack(t,41729),t}))}))}catch(e){return Promise.reject(e)}}},{key:"unpack",value:function(e,t){var n=e.get(t);n&&1===n.length&&e.set(t,n[0])}},{key:"parseGpsBlock",value:function(){try{var e=this;if(e.gps)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){if(void 0!==e.gpsOffset){var t=e.parseBlock(e.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",ct.apply(void 0,t.get(2).concat([t.get(1)]))),t.set("longitude",ct.apply(void 0,t.get(4).concat([t.get(3)])))),t}}))}catch(e){return Promise.reject(e)}}},{key:"parseInteropBlock",value:function(){try{var e=this;if(e.interop)return;return ot((function(){if(!e.ifd0)return ut(e.parseIfd0Block())}),(function(){return ot((function(){if(void 0===e.interopOffset&&!e.exif)return ut(e.parseExifBlock())}),(function(){if(void 0!==e.interopOffset)return e.parseBlock(e.interopOffset,"interop")}))}))}catch(e){return Promise.reject(e)}}},{key:"parseThumbnailBlock",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{var t=this;if(t.ifd1||t.ifd1Parsed)return;if(t.options.mergeOutput&&!e)return;return t.findIfd1Offset(),t.ifd1Offset>0&&(t.parseBlock(t.ifd1Offset,"ifd1"),t.ifd1Parsed=!0),t.ifd1}catch(e){return Promise.reject(e)}}},{key:"extractThumbnail",value:function(){try{var e=this;return e.headerParsed||e.parseHeader(),ot((function(){if(!e.ifd1Parsed)return ut(e.parseThumbnailBlock(!0))}),(function(){if(void 0!==e.ifd1){var t=e.ifd1.get(513),n=e.ifd1.get(514);return e.chunk.getUint8Array(t,n)}}))}catch(e){return Promise.reject(e)}}},{key:"createOutput",value:function(){var e,t,n,r={},i=oe;Array.isArray(i)||("function"==typeof i.entries&&(i=i.entries()),i=k(i));for(var s=0;s<i.length;s++)if(!I(e=this[t=i[s]]))if(n=this.canTranslate?this.translateBlock(e,t):g(e),this.options.mergeOutput){if("ifd1"===t)continue;y(r,n)}else r[t]=n;return this.makerNote&&(r.makerNote=this.makerNote),this.userComment&&(r.userComment=this.userComment),r}},{key:"assignToOutput",value:function(e,t){if(this.globalOptions.mergeOutput)y(e,t);else{var n=p(t);Array.isArray(n)||("function"==typeof n.entries&&(n=n.entries()),n=k(n));for(var r=0;r<n.length;r++){var i=n[r],s=i[0],a=i[1];this.assignObjectToOutput(e,s,a)}}}},{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)}}]),n}(function(e){function n(){return t(this,n),l(this,a(n).apply(this,arguments))}return s(n,e),r(n,[{key:"parseHeader",value:function(){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}},{key:"parseTags",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:S(),r=this.options[t],i=r.pick,s=r.skip,a=(i=O(i)).size>0,u=0===s.size,o=this.chunk.getUint16(e);e+=2;for(var f=0;f<o;f++){var h=this.chunk.getUint16(e);if(a){if(i.has(h)&&(n.set(h,this.parseTag(e,h,t)),i.delete(h),0===i.size))break}else!u&&s.has(h)||n.set(h,this.parseTag(e,h,t));e+=12}return n}},{key:"parseTag",value:function(e,t,n){var r,i=this.chunk.getUint16(e+2),s=this.chunk.getUint32(e+4),a=ft[i];if(a*s<=4?e+=8:e=this.chunk.getUint32(e+8),i<1||i>13)throw L("Invalid TIFF value type. block: ".concat(n.toUpperCase(),", tag: ").concat(t.toString(16),", type: ").concat(i,", offset ").concat(e));if(e>this.chunk.byteLength)throw L("Invalid TIFF value offset. block: ".concat(n.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,s);if(2===i)return""===(r=function(e){for(;e.endsWith("\0");)e=e.slice(0,-1);return e}(r=this.chunk.getString(e,s)).trim())?void 0:r;if(7===i)return this.chunk.getUint8Array(e,s);if(1===s)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))(s),o=a,f=0;f<s;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 L("Invalid tiff type ".concat(e))}}}]),n}(Ge));function ct(e,t,n,r){var i=e+t/60+n/3600;return"S"!==r&&"W"!==r||(i*=-1),i}i(ht,"type","tiff"),i(ht,"headerLength",10),W.set("tiff",ht),e.Exifr=Be,e.Options=ge,e.allFormatters=le,e.chunkedProps=se,e.createDictionary=ee,e.default=ze,e.disableAllOptions=we,e.extendDictionary=te,e.fetchUrlAsArrayBuffer=X,e.fileParsers=M,e.fileReaders=K,e.gps=Ve,e.gpsOnlyOptions=Ae,e.inheritables=ce,e.orientation=_e,e.orientationOnlyOptions=Oe,e.otherSegments=ae,e.parse=Le,e.readBlobAsArrayBuffer=J,e.segmentParsers=W,e.segments=ue,e.segmentsAndBlocks=fe,e.tagKeys=ne,e.tagRevivers=ie,e.tagValues=re,e.thumbnail=Ie,e.thumbnailOnlyOptions=Se,e.thumbnailUrl=Te,e.tiffBlocks=oe,e.tiffExtractables=he,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";function e(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let i="undefined"!=typeof self?self:global;var s="undefined"!=typeof navigator,n=s&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let a=i.Buffer,h=i.BigInt;var f=!!a;const l=t=>void 0!==t;function o(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(l).length)}function u(t){let e=new Error(t);return delete e.stack,e}function d(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}const c=new TextDecoder("utf-8");class p{static from(t,e){return t instanceof this&&t.le===e?t:new p(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 p){let{byteOffset:s,byteLength:n}=t;if(void 0===i&&(i=n-e),(e+=s)+i>s+n)throw u("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 u("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=p){if(t instanceof DataView||t instanceof p?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw u("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 p(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,c.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 h)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),h(e)<<h(32)|h(i);throw u("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 g(t,e){throw u("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class y extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||g(this.kind,t),e&&(t in e||function(t,e){throw u("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||g(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var m=new y("file parser"),b=new y("segment parser"),k=new y("file reader");function w(t,e){if((i=t).startsWith("data:")||i.length>1e4)return v(t,e,"base64");if(s)return O(t,e,"url",S);if(r)return v(t,e,"fs");throw u("Invalid input argument");var i}async function O(t,e,i,s){if(k.has(i))return v(t,e,i);if(s)return async function(t,e){let i=await e(t);return new p(i)}(t,s);throw u("Parser ".concat(i," is not loaded"))}async function v(t,e,i){let s=new(k.get(i))(t,e);return await s.read(),s}async function S(t){return fetch(t).then(t=>t.arrayBuffer())}async function U(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class A extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function x(t,e,i){let s=new A;for(let[t,e]of i)s.set(t,e);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function B(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,I=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],z=["tiff",...L],F=["ifd0","ifd1","exif","gps","interop"],P=[...z,...F],j=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...D,"sanitize","mergeOutput"];class _{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class M extends _{get needed(){return this.enabled||this.deps.size>0}constructor(t,i,s,n){if(super(),e(this,"enabled",!1),e(this,"skip",new Set),e(this,"pick",new Set),e(this,"deps",new Set),e(this,"translateKeys",!1),e(this,"translateValues",!1),e(this,"reviveValues",!1),this.key=t,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=F.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:t,skip:e}=s;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw u("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(t){let e,i;for(e of D)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){if(this.dict){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)}else for(let i of t)e.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 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},R=new Map;class K extends _{static useCached(t){let e=R.get(t);return void 0!==e?e:(e=new this(t),R.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 u("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=s?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of T)this[t]=N[t];for(t of E)this[t]=N[t];for(t of j)this[t]=N[t];for(t of P)this[t]=new M(t,N[t],void 0,this)}setupFromTrue(){let t;for(t of T)this[t]=N[t];for(t of E)this[t]=N[t];for(t of j)this[t]=!0;for(t of P)this[t]=new M(t,!0,void 0,this)}setupFromArray(t){let e;for(e of T)this[e]=N[e];for(e of E)this[e]=N[e];for(e of j)this[e]=N[e];for(e of P)this[e]=new M(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,F)}setupFromObject(t){let e;for(e of(F.ifd0=F.ifd0||F.image,F.ifd1=F.ifd1||F.thumbnail,Object.assign(this,t),T))this[e]=H(t[e],N[e]);for(e of E)this[e]=H(t[e],N[e]);for(e of j)this[e]=H(t[e],N[e]);for(e of z)this[e]=new M(e,N[e],t[e],this);for(e of F)this[e]=new M(e,N[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,F,P),!0===t.tiff?this.batchEnableWithBool(F,!0):!1===t.tiff?this.batchEnableWithUserValue(F,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,F):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,F)}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=W(t,i);for(let[t,i]of e)G(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=W(e,i);for(let[e,i]of t)G(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=F.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of F)this[t].finalizeFilters()}get onlyTiff(){return!L.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of z)this[t].enabled&&!b.has(t)&&g("segment parser",t)}}function W(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 G(t,e){for(let i of e)t.add(i)}e(K,"default",N);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},X=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]}),Q=Object.assign({},J,{tiff:!1,ifd1:!0,mergeOutput:!1});class Y{constructor(t){e(this,"parsers",{}),this.options=K.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=m.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=m.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 u("Unknown file format");this.file.isHeic=!0,t=m.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(s&&!n&&t instanceof HTMLImageElement)return w(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new p(t);if(s&&t instanceof Blob)return O(t,e,"blob",U);throw u("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=o(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=b.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 Z(t,e){let i=new Y(e);return await i.read(t),i.parse()}async function $(t){let e=new Y(Q);await e.read(t);let i=await e.extractThumbnail();return i&&f?a.from(i):i}async function tt(t){let e=await this.thumbnail(t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function et(t){let e=new Y(X);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 it(t){let e=new Y(q);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}var st=Object.freeze({__proto__:null,parse:Z,thumbnail:$,thumbnailUrl:tt,gps:et,orientation:it,Exifr:Y,fileParsers:m,segmentParsers:b,fileReaders:k,tagKeys:C,tagValues:V,tagRevivers:I,createDictionary:x,extendDictionary:B,fetchUrlAsArrayBuffer:S,readBlobAsArrayBuffer:U,chunkedProps:T,otherSegments:L,segments:z,tiffBlocks:F,segmentsAndBlocks:P,tiffExtractables:j,inheritables:D,allFormatters:E,Options:K,disableAllOptions:J,gpsOnlyOptions:X,orientationOnlyOptions:q,thumbnailOnlyOptions:Q});class nt extends p{constructor(...t){super(...t),e(this,"ranges",new rt),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 e;e=f?a.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}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 rt{constructor(){e(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>at(t,e.offset,s)||at(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 at(t,e,i){return t<=e&&e<=i}class ht extends nt{constructor(t,i){super(0),e(this,"chunksRead",0),this.input=t,this.options=i}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 ht{async readWhole(){this.chunked=!1;let t=await U(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 U(s);return this.set(n,t,!0)}});class ft{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 K({[this.type]:e})).parse()}normalizeInput(t){return t instanceof p?t:new p(t)}constructor(t,i={},s){e(this,"errors",[]),e(this,"raw",new Map),e(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(t),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=I.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,l={};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),l[e]=r;return l}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}}e(ft,"headerLength",4),e(ft,"type",void 0),e(ft,"multiSegment",!1),e(ft,"canHandle",()=>!1);function lt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function ot(t){return t>=224&&t<=239}function ut(t,e){for(let[i,s]of b)if(s.canHandle(t,e))return i}m.set("jpeg",class extends class{constructor(t,i,s){e(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 u("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 u("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=i,this.parsers=s}createParser(t,e){let i=new(b.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),e(this,"appSegments",[]),e(this,"jpegSegments",[]),e(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(b.keyList())):(t=void 0===t?b.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&b.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&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=b.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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:l,wanted:o,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),ot(i)){if(s=f.getUint16(t+2),n=ut(f,t),n&&o.has(n)&&(r=b.get(n),a=r.findPosition(f,t),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=ft.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(lt(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)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=b.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(b.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 dt=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ct extends ft{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw u("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 u("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=dt[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw u("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 u("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 u("Invalid tiff type ".concat(t))}}}class pt extends ct{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}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 u("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw u("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,d(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=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,d(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",gt(...t.get(2),t.get(1))),t.set("longitude",gt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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 F)if(t=this[e],!o(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 gt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}e(pt,"type","tiff"),e(pt,"headerLength",10),b.set("tiff",pt),t.Exifr=Y,t.Options=K,t.allFormatters=E,t.chunkedProps=T,t.createDictionary=x,t.default=st,t.disableAllOptions=J,t.extendDictionary=B,t.fetchUrlAsArrayBuffer=S,t.fileParsers=m,t.fileReaders=k,t.gps=et,t.gpsOnlyOptions=X,t.inheritables=D,t.orientation=it,t.orientationOnlyOptions=q,t.otherSegments=L,t.parse=Z,t.readBlobAsArrayBuffer=U,t.segmentParsers=b,t.segments=z,t.segmentsAndBlocks=P,t.tagKeys=C,t.tagRevivers=I,t.tagValues=V,t.thumbnail=$,t.thumbnailOnlyOptions=Q,t.thumbnailUrl=tt,t.tiffBlocks=F,t.tiffExtractables=j,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";function e(t,e,i){return e in t?Object.defineProperty(t,e,{value:i,enumerable:!0,configurable:!0,writable:!0}):t[e]=i,t}let i="undefined"!=typeof self?self:global;var s="undefined"!=typeof navigator,n=s&&"undefined"==typeof HTMLImageElement,r=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node);let a=i.Buffer,h=i.BigInt;var f=!!a;const l=t=>void 0!==t;function o(t){return void 0===t||(t instanceof Map?0===t.size:0===Object.values(t).filter(l).length)}function u(t){let e=new Error(t);return delete e.stack,e}function d(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}const c=new TextDecoder("utf-8");class p{static from(t,e){return t instanceof this&&t.le===e?t:new p(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){void 0===i&&(i=t.byteLength-e);let s=new DataView(t,e,i);this._swapDataView(s)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof p){if(void 0===i&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength)throw u("Creating view outside of available memory in ArrayBuffer");let s=new DataView(t.buffer,e,i);this._swapDataView(s)}else{if("number"!=typeof t)throw u("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=p){if(t instanceof DataView||t instanceof p?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),!(t instanceof Uint8Array))throw u("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 p(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,c.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 h)return console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),h(e)<<h(32)|h(i);throw u("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 g(t,e){throw u("".concat(t," '").concat(e,"' was not loaded, try using full build of exifr."))}class y extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||g(this.kind,t),e&&(t in e||function(t,e){throw u("Unknown ".concat(t," '").concat(e,"'."))}(this.kind,t),e[t].enabled||g(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}}var b=new y("file parser"),m=new y("segment parser"),k=new y("file reader");function w(t,e){if((i=t).startsWith("data:")||i.length>1e4)return v(t,e,"base64");if(s)return O(t,e,"url",S);if(r)return v(t,e,"fs");throw u("Invalid input argument");var i}async function O(t,e,i,s){if(k.has(i))return v(t,e,i);if(s)return async function(t,e){let i=await e(t);return new p(i)}(t,s);throw u("Parser ".concat(i," is not loaded"))}async function v(t,e,i){let s=new(k.get(i))(t,e);return await s.read(),s}async function S(t){return fetch(t).then(t=>t.arrayBuffer())}async function U(t){return new Promise((e,i)=>{let s=new FileReader;s.onloadend=()=>e(s.result||new ArrayBuffer),s.onerror=i,s.readAsArrayBuffer(t)})}class A extends Map{get tagKeys(){return this.allKeys||(this.allKeys=Array.from(this.keys())),this.allKeys}get tagValues(){return this.allValues||(this.allValues=Array.from(this.values())),this.allValues}}function x(t,e,i){let s=new A;for(let[t,e]of i)s.set(t,e);if(Array.isArray(e))for(let i of e)t.set(i,s);else t.set(e,s);return s}function B(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,I=new Map,T=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],L=["jfif","xmp","icc","iptc"],z=["tiff",...L],F=["ifd0","ifd1","exif","gps","interop"],P=[...z,...F],j=["makerNote","userComment"],D=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...D,"sanitize","mergeOutput"];class _{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class M extends _{get needed(){return this.enabled||this.deps.size>0}constructor(t,i,s,n){if(super(),e(this,"enabled",!1),e(this,"skip",new Set),e(this,"pick",new Set),e(this,"deps",new Set),e(this,"translateKeys",!1),e(this,"translateValues",!1),e(this,"reviveValues",!1),this.key=t,this.enabled=i,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=F.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),void 0!==s)if(Array.isArray(s))this.parse=this.enabled=!0,this.canBeFiltered&&s.length>0&&this.translateTagSet(s,this.pick);else if("object"==typeof s){if(this.enabled=!0,this.parse=!1!==s.parse,this.canBeFiltered){let{pick:t,skip:e}=s;t&&t.length>0&&this.translateTagSet(t,this.pick),e&&e.length>0&&this.translateTagSet(e,this.skip)}this.applyInheritables(s)}else{if(!0!==s&&!1!==s)throw u("Invalid options argument: ".concat(s));this.parse=this.enabled=s}}applyInheritables(t){let e,i;for(e of D)i=t[e],void 0!==i&&(this[e]=i)}translateTagSet(t,e){if(this.dict){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)}else for(let i of t)e.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 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},R=new Map;class K extends _{static useCached(t){let e=R.get(t);return void 0!==e?e:(e=new this(t),R.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 u("Invalid options argument ".concat(t));this.setupFromObject(t)}void 0===this.firstChunkSize&&(this.firstChunkSize=s?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of T)this[t]=N[t];for(t of E)this[t]=N[t];for(t of j)this[t]=N[t];for(t of P)this[t]=new M(t,N[t],void 0,this)}setupFromTrue(){let t;for(t of T)this[t]=N[t];for(t of E)this[t]=N[t];for(t of j)this[t]=!0;for(t of P)this[t]=new M(t,!0,void 0,this)}setupFromArray(t){let e;for(e of T)this[e]=N[e];for(e of E)this[e]=N[e];for(e of j)this[e]=N[e];for(e of P)this[e]=new M(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,F)}setupFromObject(t){let e;for(e of(F.ifd0=F.ifd0||F.image,F.ifd1=F.ifd1||F.thumbnail,Object.assign(this,t),T))this[e]=H(t[e],N[e]);for(e of E)this[e]=H(t[e],N[e]);for(e of j)this[e]=H(t[e],N[e]);for(e of z)this[e]=new M(e,N[e],t[e],this);for(e of F)this[e]=new M(e,N[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,F,P),!0===t.tiff?this.batchEnableWithBool(F,!0):!1===t.tiff?this.batchEnableWithUserValue(F,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,F):"object"==typeof t.tiff&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,F)}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=W(t,i);for(let[t,i]of e)G(this[t].pick,i),this[t].enabled=!0}else if(e&&e.length){let t=W(e,i);for(let[e,i]of t)G(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=F.some(t=>!0===this[t].enabled)||this.makerNote||this.userComment;for(let t of F)this[t].finalizeFilters()}get onlyTiff(){return!L.map(t=>this[t].enabled).some(t=>!0===t)&&this.tiff.enabled}checkLoadedPlugins(){for(let t of z)this[t].enabled&&!m.has(t)&&g("segment parser",t)}}function W(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 G(t,e){for(let i of e)t.add(i)}e(K,"default",N);const J={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},X=Object.assign({},J,{firstChunkSize:4e4,gps:[1,2,3,4]}),q=Object.assign({},J,{firstChunkSize:4e4,ifd0:[274]}),Q=Object.assign({},J,{tiff:!1,ifd1:!0,mergeOutput:!1});class Y{constructor(t){e(this,"parsers",{}),this.options=K.useCached(t)}setup(){if(this.fileParser)return;let t,e=this.file.getUint16(0);if(18761===e||19789===e)this.file.isTiff=!0,t=b.get("tiff");else if(65496===e)this.file.isJpeg=!0,t=b.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 u("Unknown file format");this.file.isHeic=!0,t=b.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(s&&!n&&t instanceof HTMLImageElement)return w(t.src,e);if(t instanceof Uint8Array||t instanceof ArrayBuffer||t instanceof DataView)return new p(t);if(s&&t instanceof Blob)return O(t,e,"blob",U);throw u("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=o(s=t)?void 0:s,this.file.close&&this.file.close(),t}async extractThumbnail(){this.setup();let t=m.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 Z(t,e){let i=new Y(e);return await i.read(t),i.parse()}async function $(t){let e=new Y(Q);await e.read(t);let i=await e.extractThumbnail();return i&&f?a.from(i):i}async function tt(t){let e=await this.thumbnail(t);if(void 0!==e){let t=new Blob([e]);return URL.createObjectURL(t)}}async function et(t){let e=new Y(X);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 it(t){let e=new Y(q);await e.read(t);let i=await e.parse();if(i&&i.ifd0)return i.ifd0[274]}var st=Object.freeze({__proto__:null,parse:Z,thumbnail:$,thumbnailUrl:tt,gps:et,orientation:it,Exifr:Y,fileParsers:b,segmentParsers:m,fileReaders:k,tagKeys:C,tagValues:V,tagRevivers:I,createDictionary:x,extendDictionary:B,fetchUrlAsArrayBuffer:S,readBlobAsArrayBuffer:U,chunkedProps:T,otherSegments:L,segments:z,tiffBlocks:F,segmentsAndBlocks:P,tiffExtractables:j,inheritables:D,allFormatters:E,Options:K,disableAllOptions:J,gpsOnlyOptions:X,orientationOnlyOptions:q,thumbnailOnlyOptions:Q});class nt extends p{constructor(...t){super(...t),e(this,"ranges",new rt),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 e;e=f?a.allocUnsafe(t):new Uint8Array(t);let i=new DataView(e.buffer,e.byteOffset,e.byteLength);return e.set(new Uint8Array(this.buffer,this.byteOffset,this.byteLength),0),{uintView:e,dataView:i}}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 rt{constructor(){e(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let s=t+e,n=this.list.filter(e=>at(t,e.offset,s)||at(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 at(t,e,i){return t<=e&&e<=i}class ht extends nt{constructor(t,i){super(0),e(this,"chunksRead",0),this.input=t,this.options=i}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 ht{async readWhole(){this.chunked=!1;let t=await U(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 U(s);return this.set(n,t,!0)}});class ft{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 K({[this.type]:e})).parse()}normalizeInput(t){return t instanceof p?t:new p(t)}constructor(t,i={},s){e(this,"errors",[]),e(this,"raw",new Map),e(this,"handleError",t=>{if(!this.options.silentErrors)throw t;this.errors.push(t.message)}),this.chunk=this.normalizeInput(t),this.file=s,this.type=this.constructor.type,this.globalOptions=this.options=i,this.localOptions=i[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=I.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,l={};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),l[e]=r;return l}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}}e(ft,"headerLength",4),e(ft,"type",void 0),e(ft,"multiSegment",!1),e(ft,"canHandle",()=>!1);function lt(t){return 192===t||194===t||196===t||219===t||221===t||218===t||254===t}function ot(t){return t>=224&&t<=239}function ut(t,e){for(let[i,s]of m)if(s.canHandle(t,e))return i}b.set("jpeg",class extends class{constructor(t,i,s){e(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 u("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 u("Segment unreachable: "+JSON.stringify(t));t.chunk=this.file.subarray(e)}return t.chunk}),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=i,this.parsers=s}createParser(t,e){let i=new(m.get(t))(e,this.options,this.file);return this.parsers[t]=i}}{constructor(...t){super(...t),e(this,"appSegments",[]),e(this,"jpegSegments",[]),e(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(m.keyList())):(t=void 0===t?m.keyList().filter(t=>this.options[t].enabled):t.filter(t=>this.options[t].enabled&&m.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&&this.file.chunked&&(s=Array.from(n).some(t=>{let e=m.get(t),i=this.options[t];return e.multiSegment&&i.multiSegment}),s&&await this.file.readWhole()),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:l,wanted:o,remaining:u,options:d}=this;for(;t<e;t++)if(255===f.getUint8(t))if(i=f.getUint8(t+1),ot(i)){if(s=f.getUint16(t+2),n=ut(f,t),n&&o.has(n)&&(r=m.get(n),a=r.findPosition(f,t),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=ft.findPosition(f,t),a.marker=i,this.unknownSegments.push(a)),t+=s+1}else if(lt(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)}(this.appSegments,"type");this.mergedAppSegments=t.map(([t,e])=>{let i=m.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(m.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 dt=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class ct extends ft{parseHeader(){var t=this.chunk.getUint16();if(18761===t)this.le=!0;else{if(19789!==t)throw u("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 u("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=dt[s];if(r*n<=4?t+=8:t=this.chunk.getUint32(t+8),s<1||s>13)throw u("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 u("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 u("Invalid tiff type ".concat(t))}}}class pt extends ct{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.saveParseBlock("parseExifBlock"),this.options.gps.enabled&&await this.saveParseBlock("parseGpsBlock"),this.options.interop.enabled&&await this.saveParseBlock("parseInteropBlock"),this.options.ifd1.enabled&&await this.saveParseBlock("parseThumbnailBlock"),this.createOutput()}async saveParseBlock(t){try{return await this[t]()}catch(t){this.handleError(t)}}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 u("Invalid EXIF data: IFD0 offset should be less than 8");if(!this.file.chunked&&this.ifd0Offset>this.file.byteLength)throw u("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,d(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=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,d(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",gt(...t.get(2),t.get(1))),t.set("longitude",gt(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),void 0!==this.interopOffset||this.exif||await 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 F)if(t=this[e],!o(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 gt(t,e,i,s){var n=t+e/60+i/3600;return"S"!==s&&"W"!==s||(n*=-1),n}e(pt,"type","tiff"),e(pt,"headerLength",10),m.set("tiff",pt),t.Exifr=Y,t.Options=K,t.allFormatters=E,t.chunkedProps=T,t.createDictionary=x,t.default=st,t.disableAllOptions=J,t.extendDictionary=B,t.fetchUrlAsArrayBuffer=S,t.fileParsers=b,t.fileReaders=k,t.gps=et,t.gpsOnlyOptions=X,t.inheritables=D,t.orientation=it,t.orientationOnlyOptions=q,t.otherSegments=L,t.parse=Z,t.readBlobAsArrayBuffer=U,t.segmentParsers=m,t.segments=z,t.segmentsAndBlocks=P,t.tagKeys=C,t.tagRevivers=I,t.tagValues=V,t.thumbnail=$,t.thumbnailOnlyOptions=Q,t.thumbnailUrl=tt,t.tiffBlocks=F,t.tiffExtractables=j,Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "exifr", | ||
"version": "4.3.3", | ||
"version": "4.3.4", | ||
"description": "📷 The fastest and most versatile JavaScript EXIF reading library.", | ||
@@ -5,0 +5,0 @@ "author": "Mike Kovarik", |
@@ -950,3 +950,3 @@ <img src="https://raw.githubusercontent.com/MikeKovarik/exifr/master/logo/blue-small.png" width="160" alt="exifr"> | ||
**npm** (~900 kB, ~60 files): The module includes both `src/` and `dist/`. That's source codes of all the readers, parsers and dictionaries. Multiplied by 3 bundles (*full*, *lite*, *mini*). Then multiplied by 3 bundle formats (*ESM*, *UMD*, *legacy* for IE10). But you won't use all of the files. They're there so you can choose what's best for your project. | ||
**npm** (~1MB, ~65 files): The module includes both `src/` and `dist/`. That's source codes of all the readers, parsers and dictionaries. Multiplied by 3 bundles (*full*, *lite*, *mini*). Then multiplied by 3 bundle formats (*ESM*, *UMD*, *legacy* for IE10) and multiplied by 2 extensions (`.mjs`+`.js` or `.cjs`+`.js`). But you won't use all of the files. They're there so you can choose what's best for your project, tooling and environment. | ||
@@ -953,0 +953,0 @@ **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. |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1193919
65
8172