!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.ExifReader=t():e.ExifReader=t()}("undefined"!=typeof self?self:this,(function(){return function(){"use strict";var e={d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:1,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:1})}},t={};function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t,n){for(var r=[],i=0;i=8){var t=l(e.slice(0,8));if("ASCII\0\0\0"===t)return l(e.slice(8));if("JIS\0\0\0\0\0"===t)return"[JIS encoded text]";if("UNICODE\0"===t)return"[Unicode encoded text]";if("\0\0\0\0\0\0\0\0"===t)return"[Undefined encoding]"}return"Undefined"}function p(e){return e[0][0]/e[0][1]+e[1][0]/e[1][1]/60+e[2][0]/e[2][1]/3600}var m=18761,g=m,v=function(e,t){if(e.getUint16(t)===m)return m;if(19789===e.getUint16(t))return 19789;throw Error("Illegal byte order value. Faulty image.")},h=65505;function y(e,t){return 65472===e.getUint16(t)}function S(e,t){return 65474===e.getUint16(t)}function b(e,t){return 65506===e.getUint16(t)&&"ICC_PROFILE\0"===r(e,t+4,12)}function C(e,t){return 65506===e.getUint16(t)&&"MPF\0"===r(e,t+4,4)}function A(e,t){return 65504===e.getUint16(t)&&"JFIF"===r(e,t+4,4)&&0===e.getUint8(t+4+4)}function I(e,t){return e.getUint16(t)===h&&"Exif"===r(e,t+4,4)&&0===e.getUint8(t+4+4)}function P(e,t){return e.getUint16(t)===h&&function(e,t){return"http://ns.adobe.com/xap/1.0/\0"===r(e,t+4,29)}(e,t)}function U(e,t){return e.getUint16(t)===h&&function(e,t){return"http://ns.adobe.com/xmp/extension/\0"===r(e,t+4,35)}(e,t)}function w(e,t){return{dataOffset:e+33,length:t-31}}function T(e,t){return{dataOffset:e+79,length:t-77}}function D(e,t){return 65517===e.getUint16(t)&&"Photoshop 3.0"===r(e,t+4,13)&&0===e.getUint8(t+4+13)}function x(e,t){var n=e.getUint16(t);return n>=65504&&n<=65519||65534===n||65472===n||65474===n||65476===n||65499===n||65501===n||65498===n}function M(e,t){return 65535===e.getUint16(t)}var O="‰PNG\r\n\n",F="iTXt",R="pHYs",L="tIME";function k(e,t){return"IHDR"===r(e,t+4,4)}function E(e,t){return"iTXt"===r(e,t+4,4)&&"XML:com.adobe.xmp\0"===r(e,t+8,18)}function N(e,t){var n=r(e,t+4,4);return"tEXt"===n||"iTXt"===n}function G(e,t){return"eXIf"===r(e,t+4,4)}function B(e,t){var n=[R,L],i=r(e,t+4,4);return n.includes(i)}function j(e,t){t+=28;for(var n=0;n<2&&t=4&&function(e){var t=e.getUint16(0)===g;return 42===e.getUint16(2,t)}(e)}(e))return{hasAppMarkers:1,tiffHeaderOffset:0};if(function(e){return!!e&&e.byteLength>=2&&65496===e.getUint16(0)}(e))return function(e){for(var t,n,r,i,o,a,u,c,f,s=2;s+4+5<=e.byteLength;){if(y(e,s))n=s+2;else if(S(e,s))r=s+2;else if(A(e,s))t=e.getUint16(s+2),i=s+2;else if(I(e,s))t=e.getUint16(s+2),o=s+10;else if(P(e,s))u||(u=[]),t=e.getUint16(s+2),u.push(w(s,t));else if(U(e,s))u||(u=[]),t=e.getUint16(s+2),u.push(T(s,t));else if(D(e,s))t=e.getUint16(s+2),a=s+18;else if(b(e,s)){var l=s+18,d=(t=e.getUint16(s+2))-16,p=e.getUint8(s+16),m=e.getUint8(s+17);c||(c=[]),c.push({offset:l,length:d,chunkNumber:p,chunksTotal:m})}else if(C(e,s))t=e.getUint16(s+2),f=s+8;else{if(!x(e,s)){if(M(e,s)){s++;continue}break}t=e.getUint16(s+2)}s+=2+t}return{hasAppMarkers:s>2,fileDataOffset:n||r,jfifDataOffset:i,tiffHeaderOffset:o,iptcDataOffset:a,xmpChunks:u,iccChunks:c,mpfDataOffset:f}}(e);if(function(e){return!!e&&r(e,0,8)===O}(e))return function(e){for(var t={hasAppMarkers:0},n=8;n+4+4<=e.byteLength;){if(k(e,n))t.hasAppMarkers=1,t.pngHeaderOffset=n+8;else if(E(e,n)){var i=j(e,n);void 0!==i&&(t.hasAppMarkers=1,t.xmpChunks=[{dataOffset:i,length:e.getUint32(n+0)-(i-(n+8))}])}else if(N(e,n)){t.hasAppMarkers=1;var o=r(e,n+4,4);t.pngTextChunks||(t.pngTextChunks=[]),t.pngTextChunks.push({length:e.getUint32(n+0),type:o,offset:n+8})}else G(e,n)?(t.hasAppMarkers=1,t.tiffHeaderOffset=n+8):B(e,n)&&(t.hasAppMarkers=1,t.pngChunkOffsets||(t.pngChunkOffsets=[]),t.pngChunkOffsets.push(n+0));n+=e.getUint32(n+0)+4+4+4}return t}(e);if(function(e){if(!e)return 0;var t=r(e,8,4);return"ftyp"===r(e,4,4)&&-1!==["heic","heix","hevc","hevx","heim","heis","hevm","hevs","mif1"].indexOf(t)}(e))return function(e){var t=function(e){for(var t=0;t+4+4<=e.byteLength;){var n=z(e,t);if(n>=8&&"meta"===r(e,t+4,4))return{offset:t,length:n};t+=n}return{offset:void 0,length:0}}(e),n=t.offset,i=t.length;if(void 0===n)return{hasAppMarkers:0};var o=Math.min(n+i,e.byteLength),a=function(e,t,n){for(var i={ilocOffset:void 0,exifItemOffset:void 0,colrOffset:void 0};t+4<=n&&(!i.ilocOffset||!i.exifItemOffset||!i.colrOffset);){var o=r(e,t,4);"iloc"===o?i.ilocOffset=t:"Exif"===o?i.exifItemOffset=t+-4:"colr"===o&&(i.colrOffset=t+-4),t++}return i}(e,n,o),u=a.exifItemOffset,c=a.ilocOffset,f=a.colrOffset,s=function(e,t,n,r){if(n&&t&&!(t+2>r)){var i=e.getUint16(t);for(n+=12;n+16<=r;){if(e.getUint16(n)===i){var o=e.getUint32(n+8);if(o+4<=e.byteLength)return o+(e.getUint32(o)+4)}n+=16}}}(e,u,c,o),l=function(e,t,n){if(t&&!(t+12>n)){var i=r(e,t+8,4);if("prof"===i||"rICC"===i)return[{offset:t+12,length:z(e,t)-12,chunkNumber:1,chunksTotal:1}]}}(e,f,o);return{hasAppMarkers:void 0!==s||void 0!==l,tiffHeaderOffset:s,iccChunks:l}}(e);if(function(e){return!!e&&"RIFF"===r(e,0,4)&&"WEBP"===r(e,8,4)}(e))return function(e){for(var t,n,i,o=12,a=0;o+8=e[1]?"".concat(Math.round(e[0]/e[1])):0!==e[0]?"1/".concat(Math.round(e[1]/e[0])):"0/".concat(e[1])},FNumber:function(e){return"f/".concat(e[0]/e[1])},FocalLength:function(e){return e[0]/e[1]+" mm"},FocalPlaneResolutionUnit:function(e){return 2===e?"inches":3===e?"centimeters":"Unknown"},LightSource:function(e){return 1===e?"Daylight":2===e?"Fluorescent":3===e?"Tungsten (incandescent light)":4===e?"Flash":9===e?"Fine weather":10===e?"Cloudy weather":11===e?"Shade":12===e?"Daylight fluorescent (D 5700 – 7100K)":13===e?"Day white fluorescent (N 4600 – 5400K)":14===e?"Cool white fluorescent (W 3900 – 4500K)":15===e?"White fluorescent (WW 3200 – 3700K)":17===e?"Standard light A":18===e?"Standard light B":19===e?"Standard light C":20===e?"D55":21===e?"D65":22===e?"D75":23===e?"D50":24===e?"ISO studio tungsten":255===e?"Other light source":"Unknown"},MeteringMode:function(e){return 1===e?"Average":2===e?"CenterWeightedAverage":3===e?"Spot":4===e?"MultiSpot":5===e?"Pattern":6===e?"Partial":255===e?"Other":"Unknown"},ResolutionUnit:function(e){return 2===e?"inches":3===e?"centimeters":"Unknown"},Saturation:function(e){return 0===e?"Normal":1===e?"Low saturation":2===e?"High saturation":"Unknown"},SceneCaptureType:function(e){return 0===e?"Standard":1===e?"Landscape":2===e?"Portrait":3===e?"Night scene":"Unknown"},Sharpness:function(e){return 0===e?"Normal":1===e?"Soft":2===e?"Hard":"Unknown"},ShutterSpeedValue:function(e){var t=Math.pow(2,e[0]/e[1]);return t<=1?"".concat(Math.round(1/t)):"1/".concat(Math.round(t))},WhiteBalance:function(e){return 0===e?"Auto white balance":1===e?"Manual white balance":"Unknown"},XResolution:function(e){return""+Math.round(e[0]/e[1])},YResolution:function(e){return""+Math.round(e[0]/e[1])}};function J(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);ne.length)&&(t=e.length);for(var n=0,r=Array(t);n>31&1,e>>30&1,e>>29&1],n=[];return t[0]&&n.push("Dependent Parent Image"),t[1]&&n.push("Dependent Child Image"),t[2]&&n.push("Representative Image"),{value:t,description:n.join(", ")||"None"}}function fe(e){var t=e>>24&7;return{value:t,description:0===t?"JPEG":"Unknown"}}function se(e){var t=16777215&e;return{value:t,description:{196608:"Baseline MP Primary Image",65537:"Large Thumbnail (VGA equivalent)",65538:"Large Thumbnail (Full HD equivalent)",131073:"Multi-Frame Image (Panorama)",131074:"Multi-Frame Image (Disparity)",131075:"Multi-Frame Image (Multi-Angle)",0:"Undefined"}[t]||"Unknown"}}function le(e){return 0===e}function de(e,t,n,r,i,o){var a=X.getTypeSize("SHORT"),u={},c=function(e,t,n){return t+X.getTypeSize("SHORT")<=e.byteLength?X.getShortAt(e,t,n):0}(e,r,i);r+=a;for(var f=0;fe.byteLength);f++){var s=pe(e,t,n,r,i,o);void 0!==s&&(u[s.name]={id:s.id,value:s.value,description:s.description}),r+=12}if(r"}l===X.tagTypes.ASCII&&(a=function(e){try{return e.map((function(e){return decodeURIComponent(escape(e))}))}catch(t){return e}}(a=function(e){for(var t=[],n=0,r=0;r5&&void 0!==arguments[5]?arguments[5]:0,a=[];o&&(r*=X.typeSizes[n],n=X.tagTypes.BYTE);for(var u=0;un)){var r=X.getByteAt(e,t+7);return{value:r,description:""+r}}}(e,t,n);return{"Bits Per Sample":he(e,t,n),"Image Height":ye(e,t,n),"Image Width":Se(e,t,n),"Color Components":r,Subsampling:r&&be(e,t,r.value,n)}};function he(e,t,n){if(!(3>n)){var r=X.getByteAt(e,t+2);return{value:r,description:""+r}}}function ye(e,t,n){if(!(5>n)){var r=X.getShortAt(e,t+3);return{value:r,description:"".concat(r,"px")}}}function Se(e,t,n){if(!(7>n)){var r=X.getShortAt(e,t+5);return{value:r,description:"".concat(r,"px")}}}function be(e,t,n,r){if(!(8+3*n>r)){for(var i=[],o=0;o1?Ce(i)+Ae(i):""}}}function Ce(e){var t={1:"Y",2:"Cb",3:"Cr",4:"I",5:"Q"};return e.map((function(e){return t[e[0]]})).join("")}function Ae(e){var t={17:"4:4:4 (1 1)",18:"4:4:0 (1 2)",20:"4:4:1 (1 4)",33:"4:2:2 (2 1)",34:"4:2:0 (2 2)",36:"4:2:1 (2 4)",65:"4:1:1 (4 1)",66:"4:1:0 (4 2)"};return 0===e.length||void 0===e[0][1]||void 0===t[e[0][1]]?"":t[e[0][1]]}var Ie=function(e,t){var n=function(e,t){return X.getShortAt(e,t)}(e,t),r=function(e,t,n){if(!(15>n)){var r=X.getByteAt(e,t+14);return{value:r,description:"".concat(r,"px")}}}(e,t,n),i=function(e,t,n){if(!(16>n)){var r=X.getByteAt(e,t+15);return{value:r,description:"".concat(r,"px")}}}(e,t,n),o={"JFIF Version":Pe(e,t,n),"Resolution Unit":Ue(e,t,n),XResolution:Te(e,t,n),YResolution:De(e,t,n),"JFIF Thumbnail Width":r,"JFIF Thumbnail Height":i};if(void 0!==r&&void 0!==i){var a=function(e,t,n,r){if(!(0===n||16+n>r))return{value:e.buffer.slice(t+16,t+16+n),description:"<24-bit RGB pixel data>"}}(e,t,3*r.value*i.value,n);a&&(o["JFIF Thumbnail"]=a)}for(var u in o)void 0===o[u]&&delete o[u];return o};function Pe(e,t,n){if(!(9>n)){var r=X.getByteAt(e,t+7),i=X.getByteAt(e,t+7+1);return{value:256*r+i,description:r+"."+i}}}function Ue(e,t,n){if(!(10>n)){var r=X.getByteAt(e,t+9);return{value:r,description:we(r)}}}function we(e){return 0===e?"None":1===e?"inches":2===e?"cm":"Unknown"}function Te(e,t,n){if(!(12>n)){var r=X.getShortAt(e,t+10);return{value:r,description:""+r}}}function De(e,t,n){if(!(14>n)){var r=X.getShortAt(e,t+12);return{value:r,description:""+r}}}var xe={iptc:{256:{name:"Model Version",description:function(e){return""+((e[0]<<8)+e[1])}},261:{name:"Destination",repeatable:1},276:{name:"File Format",description:function(e){return""+((e[0]<<8)+e[1])}},278:{name:"File Format Version",description:function(e){return""+((e[0]<<8)+e[1])}},286:"Service Identifier",296:"Envelope Number",306:"Product ID",316:"Envelope Priority",326:{name:"Date Sent",description:Me},336:{name:"Time Sent",description:Oe},346:{name:"Coded Character Set",description:Fe,encoding_name:Fe},356:"UNO",376:{name:"ARM Identifier",description:function(e){return""+((e[0]<<8)+e[1])}},378:{name:"ARM Version",description:function(e){return""+((e[0]<<8)+e[1])}},512:{name:"Record Version",description:function(e){return""+((e[0]<<8)+e[1])}},515:"Object Type Reference",516:"Object Attribute Reference",517:"Object Name",519:"Edit Status",520:{name:"Editorial Update",description:function(e){return"01"===l(e)?"Additional Language":"Unknown"}},522:"Urgency",524:{name:"Subject Reference",repeatable:1,description:function(e){var t=l(e).split(":");return t[2]+(t[3]?"/"+t[3]:"")+(t[4]?"/"+t[4]:"")}},527:"Category",532:{name:"Supplemental Category",repeatable:1},534:"Fixture Identifier",537:{name:"Keywords",repeatable:1},538:{name:"Content Location Code",repeatable:1},539:{name:"Content Location Name",repeatable:1},542:"Release Date",547:"Release Time",549:"Expiration Date",550:"Expiration Time",552:"Special Instructions",554:{name:"Action Advised",description:function(e){var t=l(e);return"01"===t?"Object Kill":"02"===t?"Object Replace":"03"===t?"Object Append":"04"===t?"Object Reference":"Unknown"}},557:{name:"Reference Service",repeatable:1},559:{name:"Reference Date",repeatable:1},562:{name:"Reference Number",repeatable:1},567:{name:"Date Created",description:Me},572:{name:"Time Created",description:Oe},574:{name:"Digital Creation Date",description:Me},575:{name:"Digital Creation Time",description:Oe},577:"Originating Program",582:"Program Version",587:{name:"Object Cycle",description:function(e){var t=l(e);return"a"===t?"morning":"p"===t?"evening":"b"===t?"both":"Unknown"}},592:{name:"By-line",repeatable:1},597:{name:"By-line Title",repeatable:1},602:"City",604:"Sub-location",607:"Province/State",612:"Country/Primary Location Code",613:"Country/Primary Location Name",615:"Original Transmission Reference",617:"Headline",622:"Credit",627:"Source",628:"Copyright Notice",630:{name:"Contact",repeatable:1},632:"Caption/Abstract",634:{name:"Writer/Editor",repeatable:1},637:{name:"Rasterized Caption",description:function(e){return e}},642:"Image Type",643:{name:"Image Orientation",description:function(e){var t=l(e);return"P"===t?"Portrait":"L"===t?"Landscape":"S"===t?"Square":"Unknown"}},647:"Language Identifier",662:{name:"Audio Type",description:function(e){var t=l(e),n=t.charAt(0),r=t.charAt(1),i="";return"1"===n?i+="Mono":"2"===n&&(i+="Stereo"),"A"===r?i+=", actuality":"C"===r?i+=", question and answer session":"M"===r?i+=", music, transmitted by itself":"Q"===r?i+=", response to a question":"R"===r?i+=", raw sound":"S"===r?i+=", scener":"V"===r?i+=", voicer":"W"===r&&(i+=", wrap"),""!==i?i:t}},663:{name:"Audio Sampling Rate",description:function(e){return parseInt(l(e),10)+" Hz"}},664:{name:"Audio Sampling Resolution",description:function(e){var t=parseInt(l(e),10);return t+(1===t?" bit":" bits")}},665:{name:"Audio Duration",description:function(e){var t=l(e);return t.length>=6?t.substr(0,2)+":"+t.substr(2,2)+":"+t.substr(4,2):t}},666:"Audio Outcue",698:"Short Document ID",699:"Unique Document ID",700:"Owner ID",712:{name:function(e){return 2===e.length?"ObjectData Preview File Format":"Record 2 destination"},description:function(e){if(2===e.length){var t=(e[0]<<8)+e[1];return 0===t?"No ObjectData":1===t?"IPTC-NAA Digital Newsphoto Parameter Record":2===t?"IPTC7901 Recommended Message Format":3===t?"Tagged Image File Format (Adobe/Aldus Image data)":4===t?"Illustrator (Adobe Graphics data)":5===t?"AppleSingle (Apple Computer Inc)":6===t?"NAA 89-3 (ANPA 1312)":7===t?"MacBinary II":8===t?"IPTC Unstructured Character Oriented File Format (UCOFF)":9===t?"United Press International ANPA 1312 variant":10===t?"United Press International Down-Load Message":11===t?"JPEG File Interchange (JFIF)":12===t?"Photo-CD Image-Pac (Eastman Kodak)":13===t?"Microsoft Bit Mapped Graphics File [*.BMP]":14===t?"Digital Audio File [*.WAV] (Microsoft & Creative Labs)":15===t?"Audio plus Moving Video [*.AVI] (Microsoft)":16===t?"PC DOS/Windows Executable Files [*.COM][*.EXE]":17===t?"Compressed Binary File [*.ZIP] (PKWare Inc)":18===t?"Audio Interchange File Format AIFF (Apple Computer Inc)":19===t?"RIFF Wave (Microsoft Corporation)":20===t?"Freehand (Macromedia/Aldus)":21===t?'Hypertext Markup Language "HTML" (The Internet Society)':22===t?"MPEG 2 Audio Layer 2 (Musicom), ISO/IEC":23===t?"MPEG 2 Audio Layer 3, ISO/IEC":24===t?"Portable Document File (*.PDF) Adobe":25===t?"News Industry Text Format (NITF)":26===t?"Tape Archive (*.TAR)":27===t?"Tidningarnas Telegrambyrå NITF version (TTNITF DTD)":28===t?"Ritzaus Bureau NITF version (RBNITF DTD)":29===t?"Corel Draw [*.CDR]":"Unknown format ".concat(t)}return l(e)}},713:{name:"ObjectData Preview File Format Version",description:function(e,t){var n={"00":{"00":"1"},"01":{"01":"1","02":"2","03":"3","04":"4"},"02":{"04":"4"},"03":{"01":"5.0","02":"6.0"},"04":{"01":"1.40"},"05":{"01":"2"},"06":{"01":"1"},11:{"01":"1.02"},20:{"01":"3.1","02":"4.0","03":"5.0","04":"5.5"},21:{"02":"2.0"}},r=l(e);if(t["ObjectData Preview File Format"]){var i=l(t["ObjectData Preview File Format"].value);if(n[i]&&n[i][r])return n[i][r]}return r}},714:"ObjectData Preview Data",1802:{name:"Size Mode",description:function(e){return e[0].toString()}},1812:{name:"Max Subfile Size",description:function(e){for(var t=0,n=0;n=8?t.substr(0,4)+"-"+t.substr(4,2)+"-"+t.substr(6,2):t}function Oe(e){var t=l(e),n=t;return t.length>=6&&(n=t.substr(0,2)+":"+t.substr(2,2)+":"+t.substr(4,2),11===t.length&&(n+=t.substr(6,1)+t.substr(7,2)+":"+t.substr(9,2))),n}function Fe(e){var t=l(e);return"%G"===t?"UTF-8":"%5"===t?"Windows-1252":"%/G"===t?"UTF-8 Level 1":"%/H"===t?"UTF-8 Level 2":"%/I"===t?"UTF-8 Level 3":"/A"===t?"ISO-8859-1":"/B"===t?"ISO-8859-2":"/C"===t?"ISO-8859-3":"/D"===t?"ISO-8859-4":"/@"===t?"ISO-8859-5":"/G"===t?"ISO-8859-6":"/F"===t?"ISO-8859-7":"/H"===t?"ISO-8859-8":"Unknown"}var Re=function(e,t){var n=function(){if("undefined"!=typeof TextDecoder)return TextDecoder}();if("undefined"!=typeof n&&void 0!==e)try{return new n(e).decode(Uint8Array.from(t))}catch(e){}return function(e){try{return decodeURIComponent(escape(e))}catch(t){return e}}(t.map((function(e){return String.fromCharCode(e)})).join(""))},Le=function(e,t,n){try{if(Array.isArray(e))return Ge(new DataView(Uint8Array.from(e).buffer),{size:e.length},0,n);var r=function(e,t){for(;t+12<=e.byteLength;){var n=ke(e,t);if(Ee(n))return{naaBlock:n,dataOffset:t+12};t+=12+n.size+Ne(n)}throw Error("No IPTC NAA resource block.")}(e,t);return Ge(e,r.naaBlock,r.dataOffset,n)}catch(e){return{}}};function ke(e,t){if(943868237!==e.getUint32(t,0))throw Error("Not an IPTC resource block.");return{type:e.getUint16(t+4),size:e.getUint16(t+10)}}function Ee(e){return 1028===e.type}function Ne(e){return e.size%2!=0?1:0}function Ge(e,t,n,r){for(var i={},o=void 0,a=n+t.size;ne.length)&&(t=e.length);for(var n=0,r=Array(t);ne.length)&&(t=e.length);for(var n=0,r=Array(t);n1&&n.push(Je(e,t.slice(1))),n}(e,t),2,function(e){if(Array.isArray(e))return e}(r)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,i,o=[],a=1,u=0;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(o.push(r.value),2!==o.length);a=1);}catch(e){u=1,i=e}finally{try{a||null==n.return||n.return()}finally{if(u)throw i}}return o}}(r)||function(e,t){if(e){if("string"==typeof e)return qe(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?qe(e,2):void 0}}(r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[0],a=i[1],u=$e(n,o);if(a){var c=$e(n,a);u||c||(delete n._raw,$e(n,Je(e,t)))}return n};function Je(e,t){for(var n=t.reduce((function(e,t){return e+t.length}),0),r=new Uint8Array(n),i=0,o=0;o).+$/,"$1"),"application/xml");if("parsererror"===i.documentElement.nodeName)throw Error(i.documentElement.textContent);return{doc:i,raw:n}}(t),i=n.doc,o=n.raw;return e._raw=(e._raw||"")+o,a(e,ot(Ze(Qe(i),1))),1}catch(e){return 0}}function Qe(e){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:0,n=et(e);return tt(n)?t?{}:nt(n[0]):rt(n)}function et(e){for(var t=[],n=0;n1&&void 0!==arguments[1]?arguments[1]:void 0;if(Array.isArray(e)){var n=lt(e);return t&&"function"==typeof We[t]?We[t](e,n):n}if("object"===_e(e))return dt(e);try{return t&&"function"==typeof We[t]?We[t](e):decodeURIComponent(escape(e))}catch(t){return e}}function lt(e){return e.map((function(e){return void 0!==e.value?st(e.value):st(e)})).join(", ")}function dt(e){var t=[];for(var n in e)t.push("".concat(pt(n),": ").concat(st(e[n].value)));return t.join("; ")}function pt(e){return"CiAdrCity"===e?"CreatorCity":"CiAdrCtry"===e?"CreatorCountry":"CiAdrExtadr"===e?"CreatorAddress":"CiAdrPcode"===e?"CreatorPostalCode":"CiAdrRegion"===e?"CreatorRegion":"CiEmailWork"===e?"CreatorWorkEmail":"CiTelWork"===e?"CreatorWorkPhone":"CiUrlWork"===e?"CreatorWorkUrl":e}function mt(e){var t={};for(var n in e)ct(n)||(t[ft(n)]=gt(e[n],n));return t}function gt(e,t){return vt(e)?ht(e,t):St(e)?bt(e,t):Ct(e)?At(e,t):function(e){return void 0!==It(e.value)}(e)?function(e,t){var n=It(e.value).value["rdf:li"],r=yt(e),i=[];return void 0===n?n=[]:Array.isArray(n)||(n=[n]),n.forEach((function(e){i.push(function(e){return vt(e)?ht(e):St(e)?bt(e).value:Ct(e)?At(e).value:Pt(e)}(e))})),{value:i,attributes:r,description:st(i,t)}}(e,t):Pt(e,t)}function vt(e){return"Resource"===e.attributes["rdf:parseType"]&&void 0!==e.value["rdf:value"]||void 0!==e.value["rdf:Description"]&&void 0!==e.value["rdf:Description"].value["rdf:value"]}function ht(e,t){var n=yt(e);void 0!==e.value["rdf:Description"]&&(e=e.value["rdf:Description"]),a(n,yt(e),function(e){var t={};for(var n in e.value)"rdf:value"===n||ct(n)||(t[ft(n)]=e.value[n].value);return t}(e));var r=function(e){return Ut(e.value["rdf:value"])||e.value["rdf:value"].value}(e);return{value:r,attributes:n,description:st(r,t)}}function yt(e){var t={};for(var n in e.attributes)"rdf:parseType"===n||"rdf:resource"===n||ct(n)||(t[ft(n)]=e.attributes[n]);return t}function St(e){return"Resource"===e.attributes["rdf:parseType"]||void 0!==e.value["rdf:Description"]&&void 0===e.value["rdf:Description"].value["rdf:value"]}function bt(e,t){var n={value:{},attributes:{}};return void 0!==e.value["rdf:Description"]&&(a(n.value,at(e.value["rdf:Description"].attributes)),a(n.attributes,yt(e)),e=e.value["rdf:Description"]),a(n.value,mt(e.value)),n.description=st(n.value,t),n}function Ct(e){return 0===Object.keys(e.value).length&&void 0===e.attributes["xml:lang"]&&void 0===e.attributes["rdf:resource"]}function At(e,t){var n=at(e.attributes);return{value:n,attributes:{},description:st(n,t)}}function It(e){return e["rdf:Bag"]||e["rdf:Seq"]||e["rdf:Alt"]}function Pt(e,t){var n=Ut(e)||ot(e.value);return{value:n,attributes:yt(e),description:st(n,t)}}function Ut(e){return e.attributes&&e.attributes["rdf:resource"]}var wt={desc:{name:"ICC Description"},cprt:{name:"ICC Copyright"},dmdd:{name:"ICC Device Model Description"},vued:{name:"ICC Viewing Conditions Description"},dmnd:{name:"ICC Device Manufacturer for Display"},tech:{name:"Technology"}},Tt={4:{name:"Preferred CMM type",value:function(e,t){return r(e,t,4)},description:function(e){return null!==e?Dt(e):""}},8:{name:"Profile Version",value:function(e,t){return e.getUint8(t).toString(10)+"."+(e.getUint8(t+1)>>4).toString(10)+"."+(e.getUint8(t+1)%16).toString(10)}},12:{name:"Profile/Device class",value:function(e,t){return r(e,t,4)},description:function(e){switch(e.toLowerCase()){case"scnr":return"Input Device profile";case"mntr":return"Display Device profile";case"prtr":return"Output Device profile";case"link":return"DeviceLink profile";case"abst":return"Abstract profile";case"spac":return"ColorSpace profile";case"nmcl":return"NamedColor profile";case"cenc":return"ColorEncodingSpace profile";case"mid ":return"MultiplexIdentification profile";case"mlnk":return"MultiplexLink profile";case"mvis":return"MultiplexVisualization profile";default:return e}}},16:{name:"Color Space",value:function(e,t){return r(e,t,4)}},20:{name:"Connection Space",value:function(e,t){return r(e,t,4)}},24:{name:"ICC Profile Date",value:function(e,t){return function(e,t){var n=e.getUint16(t),r=e.getUint16(t+2)-1,i=e.getUint16(t+4),o=e.getUint16(t+6),a=e.getUint16(t+8),u=e.getUint16(t+10);return new Date(Date.UTC(n,r,i,o,a,u))}(e,t).toISOString()}},36:{name:"ICC Signature",value:function(e,t){return n=e.buffer.slice(t,t+4),String.fromCharCode.apply(null,new Uint8Array(n));var n}},40:{name:"Primary Platform",value:function(e,t){return r(e,t,4)},description:function(e){return Dt(e)}},48:{name:"Device Manufacturer",value:function(e,t){return r(e,t,4)},description:function(e){return Dt(e)}},52:{name:"Device Model Number",value:function(e,t){return r(e,t,4)}},64:{name:"Rendering Intent",value:function(e,t){return e.getUint32(t)},description:function(e){switch(e){case 0:return"Perceptual";case 1:return"Relative Colorimetric";case 2:return"Saturation";case 3:return"Absolute Colorimetric";default:return e}}},80:{name:"Profile Creator",value:function(e,t){return r(e,t,4)}}};function Dt(e){switch(e.toLowerCase()){case"appl":return"Apple";case"adbe":return"Adobe";case"msft":return"Microsoft";case"sunw":return"Sun Microsystems";case"sgi":return"Silicon Graphics";case"tgnt":return"Taligent";default:return e}}var xt=function(e,t){try{for(var n=t.reduce((function(e,t){return e+t.length}),0),o=new Uint8Array(n),a=0,u=function(e){return Array.isArray(e)?new DataView(Uint8Array.from(e).buffer).buffer:e.buffer}(e),c=function(e){var n=t.find((function(t){return t.chunkNumber===e}));if(!n)throw Error("ICC chunk ".concat(e," not found"));var r=u.slice(n.offset,n.offset+n.length),i=new Uint8Array(r);o.set(i,a),a+=i.length},f=1;f<=t.length;f++)c(f);return function(e){var t=e.buffer,n=e.getUint32();if(e.byteLength!==n)throw Error("ICC profile length not matching");if(e.length<84)throw Error("ICC profile too short");for(var o={},a=Object.keys(Tt),u=0;ut.length)return o;var y=r(e,v,4);if(y===Ot){var S=e.getUint32(v+8);if(S>h)return o;Nt(o,g,Et(t.slice(v+12,v+S+11)))}else if(y===Ft){for(var b=e.getUint32(v+8),C=e.getUint32(v+12),A=v+16,I=[],P=0;Pe.byteLength)){var n=X.getLongAt(e,t);return{value:n,description:"".concat(n,"px")}}}function jt(e,t){if(!(t+4+4>e.byteLength)){var n=X.getLongAt(e,t+4);return{value:n,description:"".concat(n,"px")}}}function zt(e,t){if(!(t+8+1>e.byteLength)){var n=X.getByteAt(e,t+8);return{value:n,description:"".concat(n)}}}function Vt(e,t){if(!(t+9+1>e.byteLength)){var n=X.getByteAt(e,t+9);return{value:n,description:{0:"Grayscale",2:"RGB",3:"Palette",4:"Grayscale with Alpha",6:"RGB with Alpha"}[n]||"Unknown"}}}function Wt(e,t){if(!(t+10+1>e.byteLength)){var n=X.getByteAt(e,t+10);return{value:n,description:0===n?"Deflate/Inflate":"Unknown"}}}function Ht(e,t){if(!(t+11+1>e.byteLength)){var n=X.getByteAt(e,t+11);return{value:n,description:0===n?"Adaptive":"Unknown"}}}function Xt(e,t){if(!(t+12+1>e.byteLength)){var n=X.getByteAt(e,t+12);return{value:n,description:{0:"Noninterlaced",1:"Adam7 Interlace"}[n]||"Unknown"}}}var Yt=function(e,t){return t.reduce((function(t,n){var r=n.offset,i=n.length,a=n.type,u=function(e,t,n,r){for(var i=[],a=[],u=[],c=[],f=_t,s=0;s1&&void 0!==arguments[1]?arguments[1]:{}).length,n={method:"GET"};return Number.isInteger(t)&&t>=0&&(n.headers={range:"bytes=0-".concat(t-1)}),fetch(e,n).then((function(e){return e.arrayBuffer()}))}(e,t):function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).length;return new Promise((function(n,r){var i={};Number.isInteger(t)&&t>=0&&(i.headers={range:"bytes=0-".concat(t-1)}),mn(e)(e,i,(function(e){if(e.statusCode>=200&&e.statusCode<=299){var t=[];e.on("data",(function(e){return t.push(Buffer.from(e))})),e.on("error",(function(e){return r(e)})),e.on("end",(function(){return n(Buffer.concat(t))}))}else r("Could not fetch file: ".concat(e.statusCode," ").concat(e.statusMessage)),e.resume()})).on("error",(function(e){return r(e)}))}))}(e,t):function(e){return/^data:[^;,]*(;base64)?,/.test(e)}(e)?Promise.resolve(function(e){var t=e.substring(e.indexOf(",")+1);if(-1!==e.indexOf(";base64")){if("undefined"!=typeof atob)return Uint8Array.from(atob(t),(function(e){return e.charCodeAt(0)})).buffer;if("undefined"==typeof Buffer)return;return void 0!==n(Buffer.from)?Buffer.from(t,"base64"):new Buffer(t,"base64")}var r=decodeURIComponent(t);return"undefined"!=typeof Buffer?void 0!==n(Buffer.from)?Buffer.from(r):new Buffer(r):Uint8Array.from(r,(function(e){return e.charCodeAt(0)})).buffer}(e)):function(e){var t=(arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}).length;return new Promise((function(n,r){var i=gn();i.open(e,(function(o,a){o?r(o):i.stat(e,(function(o,u){if(o)r(o);else{var c=Math.min(u.size,void 0!==t?t:u.size),f=Buffer.alloc(c),s={buffer:f,length:c};i.read(a,s,(function(t){t?r(t):i.close(a,(function(t){t&&console.warn("Could not close file ".concat(e,":"),t),n(f)}))}))}}))}))}))}(e,t)}(e,t).then((function(e){return vn(e,t)})):function(e){return"undefined"!=typeof window&&"undefined"!=typeof File&&e instanceof File}(e)?(r=e,new Promise((function(e,t){var n=new FileReader;n.onload=function(t){return e(t.target.result)},n.onerror=function(){return t(n.error)},n.readAsArrayBuffer(r)}))).then((function(e){return vn(e,t)})):vn(e,t);var r}function mn(e){return/^https:\/\//.test(e)?require("https").get:require("http").get}function gn(){try{return require("fs")}catch(e){return}}function vn(e,t){return function(e){try{return Buffer.isBuffer(e)}catch(e){return 0}}(e)&&(e=new Uint8Array(e).buffer),hn(function(e){try{return new DataView(e)}catch(t){return new s(e)}}(e),t)}function hn(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{expanded:0,includeUnknown:0},n=t.expanded,r=void 0===n?0:n,i=t.includeUnknown,u=void 0===i?0:i,c=0,f={},s=V(e),l=s.fileDataOffset,d=s.jfifDataOffset,p=s.tiffHeaderOffset,m=s.iptcDataOffset,g=s.xmpChunks,v=s.iccChunks,h=s.mpfDataOffset,y=s.pngHeaderOffset,S=s.pngTextChunks,b=s.pngChunkOffsets;if(yn(l)){c=1;var C=ve(e,l);r?f.file=C:f=a({},f,C)}if(Sn(d)){c=1;var A=Ie(e,d);r?f.jfif=A:f=a({},f,A)}if(bn(p)){c=1;var I=ie(e,p,u);if(I.Thumbnail&&(f.Thumbnail=I.Thumbnail,delete I.Thumbnail),r?(f.exif=I,Cn(f)):f=a({},f,I),I["IPTC-NAA"]&&!An(m)){var P=Le(I["IPTC-NAA"].value,0,u);r?f.iptc=P:f=a({},f,P)}if(I.ApplicationNotes&&!In(g)){var U=Ke(o(I.ApplicationNotes.value));r?f.xmp=U:(delete U._raw,f=a({},f,U))}if(I.ICC_Profile&&!Pn(v)){var w=xt(I.ICC_Profile.value,[{offset:0,length:I.ICC_Profile.value.length,chunkNumber:1,chunksTotal:1}]);r?f.icc=w:f=a({},f,w)}}if(An(m)){c=1;var T=Le(e,m,u);r?f.iptc=T:f=a({},f,T)}if(In(g)){c=1;var D=Ke(e,g);r?f.xmp=D:(delete D._raw,f=a({},f,D))}if(Pn(v)){c=1;var x=xt(e,v);r?f.icc=x:f=a({},f,x)}if(Un(h)){c=1;var M=oe(e,h,u);r?f.mpf=M:f=a({},f,M)}if(wn(y)){c=1;var O=Gt(e,y);r?(f.png=f.png?a({},f.png,O):O,f.pngFile=O):f=a({},f,O)}if(Tn(S)){c=1;var F=Yt(e,S);r?(f.png=f.png?a({},f.png,F):F,f.pngText=F):f=a({},f,F)}if(Dn(b)){c=1;var R=Zt(e,b);r?f.png=f.png?a({},f.png,R):R:f=a({},f,R)}var L=cn(e,f.Thumbnail,p);if(L?(c=1,f.Thumbnail=L):delete f.Thumbnail,!c)throw new sn.MetadataMissingError;return f}function yn(e){return void 0!==e}function Sn(e){return void 0!==e}function bn(e){return void 0!==e}function Cn(e){if(e.exif){if(e.exif.GPSLatitude&&e.exif.GPSLatitudeRef)try{e.gps=e.gps||{},e.gps.Latitude=p(e.exif.GPSLatitude.value),"S"===e.exif.GPSLatitudeRef.value.join("")&&(e.gps.Latitude=-e.gps.Latitude)}catch(e){}if(e.exif.GPSLongitude&&e.exif.GPSLongitudeRef)try{e.gps=e.gps||{},e.gps.Longitude=p(e.exif.GPSLongitude.value),"W"===e.exif.GPSLongitudeRef.value.join("")&&(e.gps.Longitude=-e.gps.Longitude)}catch(e){}if(e.exif.GPSAltitude&&e.exif.GPSAltitudeRef)try{e.gps=e.gps||{},e.gps.Altitude=e.exif.GPSAltitude.value[0]/e.exif.GPSAltitude.value[1],1===e.exif.GPSAltitudeRef.value&&(e.gps.Altitude=-e.gps.Altitude)}catch(e){}}}function An(e){return void 0!==e}function In(e){return Array.isArray(e)&&e.length>0}function Pn(e){return Array.isArray(e)&&e.length>0}function Un(e){return void 0!==e}function wn(e){return void 0!==e}function Tn(e){return void 0!==e}function Dn(e){return void 0!==e}return t}()})); //# sourceMappingURL=exif-reader.js.map