UNPKG

@leverj/flipcard

Version:

A Lit-based web component for displaying interactive flipcard images with grid support.

62 lines (55 loc) 84.7 kB
import{css as e,LitElement as t,html as i}from"lit";const r=e` /* Default CSS reset for <img> to prevent browser styles from interfering */ img { max-width: unset !important; } /* Main card container with perspective for 3D effect */ .iaw-card { perspective: 10000px; -webkit-perspective: 10000px; scale: 0.95; } /* Card inner container with transition effects */ .iaw-card-inner { transition: transform 1.5s; transform-style: preserve-3d; width: var(--container-width); height: var(--container-height); transform: rotateY(var(--rotate-by)); } /* Common styles for front and back face of card */ .iaw-card-front, .iaw-card-back { position: absolute; width: 100%; height: 100%; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; } /* Back face is rotated 180 degrees to show reverse side */ .iaw-card-back { transform: rotateY(180deg); } /* Common styles for images on both front and back */ .iaw-front, .iaw-back { position: relative; object-fit: contain; object-position: center; height: var(--img-height); width: var(--img-width); } /* Positioning for front image on back card face */ .iaw-card .iaw-card-inner .iaw-card-back .iaw-front { position: relative; top: var(--front-img-top); left: var(--front-img-left); } /* Positioning for back image on back card face */ .iaw-card .iaw-card-inner .iaw-card-back .iaw-back { position: relative; top: var(--back-img-top); left: var(--back-img-left); } `;var s="undefined"!=typeof self?self:global;const n="undefined"!=typeof navigator,a=n&&"undefined"==typeof HTMLImageElement,o=!("undefined"==typeof global||"undefined"==typeof process||!process.versions||!process.versions.node),l=s.Buffer,h=s.BigInt,c=!!l,u=e=>e;function f(e,t=u){if(o)try{return"function"==typeof require?Promise.resolve(t(require(e))):import(e).then(t)}catch(t){}}let d=s.fetch;if(!s.fetch){const e=f("http",(e=>e)),t=f("https",(e=>e)),i=(r,{headers:s}={})=>new Promise((async(n,a)=>{let{port:o,hostname:l,pathname:h,protocol:c,search:u}=new URL(r);const f={method:"GET",hostname:l,path:encodeURI(h)+u,headers:s};""!==o&&(f.port=Number(o));const d=("https:"===c?await t:await e).request(f,(e=>{if(301===e.statusCode||302===e.statusCode){let t=new URL(e.headers.location,r).toString();return i(t,{headers:s}).then(n).catch(a)}n({status:e.statusCode,arrayBuffer:()=>new Promise((t=>{let i=[];e.on("data",(e=>i.push(e))),e.on("end",(()=>t(Buffer.concat(i))))}))})}));d.on("error",a),d.end()}));(e=>{d=e})(i)}function g(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}const p=e=>y(e)?void 0:e,m=e=>void 0!==e;function y(e){return void 0===e||(e instanceof Map?0===e.size:0===Object.values(e).filter(m).length)}function S(e){let t=new Error(e);throw 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 b(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 w=e=>String.fromCharCode.apply(null,e),I="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):void 0;function P(e){return I?I.decode(e):c?Buffer.from(e).toString("utf8"):decodeURIComponent(escape(w(e)))}class k{static from(e,t){return e instanceof this&&e.le===t?e:new k(e,void 0,void 0,t)}constructor(e,t=0,i,r){if("boolean"==typeof r&&(this.le=r),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 r=new DataView(e,t,i);this._swapDataView(r)}else if(e instanceof Uint8Array||e instanceof DataView||e instanceof k){void 0===i&&(i=e.byteLength-t),(t+=e.byteOffset)+i>e.byteOffset+e.byteLength&&S("Creating view outside of available memory in ArrayBuffer");let r=new DataView(e.buffer,t,i);this._swapDataView(r)}else if("number"==typeof e){let t=new DataView(new ArrayBuffer(e));this._swapDataView(t)}else S("Invalid input argument for BufferView: "+e)}_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=k){return e instanceof DataView||e instanceof k?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e instanceof ArrayBuffer&&(e=new Uint8Array(e)),e instanceof Uint8Array||S("BufferView.set(): Invalid data argument."),this.toUint8().set(e,t),new i(this,t,e.byteLength)}subarray(e,t){return t=t||this._lengthToEnd(e),new k(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))}getLatin1String(e=0,t=this.byteLength){let i=this.getUint8Array(e,t);return w(i)}getUnicodeString(e=0,t=this.byteLength){const i=[];for(let r=0;r<t&&e+r<this.byteLength;r+=2)i.push(this.getUint16(e+r));return w(i)}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)}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&&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&&this.getUint64(e,i)}}toString(e){return this.dataView.toString(e,this.constructor.name)}ensureChunk(){}}function T(e,t){S(`${e} '${t}' was not loaded, try using full build of exifr.`)}class v extends Map{constructor(e){super(),this.kind=e}get(e,t){return this.has(e)||T(this.kind,e),t&&(e in t||function(e,t){S(`Unknown ${e} '${t}'.`)}(this.kind,e),t[e].enabled||T(this.kind,e)),super.get(e)}keyList(){return Array.from(this.keys())}}var A=new v("file parser"),D=new v("segment parser"),O=new v("file reader");function x(e,t){return(i=e).startsWith("data:")||i.length>1e4?L(e,t,"base64"):o&&e.includes("://")?R(e,t,"url",M):o?L(e,t,"fs"):n?R(e,t,"url",M):void S("Invalid input argument");var i}async function R(e,t,i,r){return O.has(i)?L(e,t,i):r?async function(e,t){let i=await t(e);return new k(i)}(e,r):void S(`Parser ${i} is not loaded`)}async function L(e,t,i){let r=new(O.get(i))(e,t);return await r.read(),r}const M=e=>d(e).then((e=>e.arrayBuffer())),U=e=>new Promise(((t,i)=>{let r=new FileReader;r.onloadend=()=>t(r.result||new ArrayBuffer),r.onerror=i,r.readAsArrayBuffer(e)}));class F 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 E(e,t,i){let r=new F;for(let[e,t]of i)r.set(e,t);if(Array.isArray(t))for(let i of t)e.set(i,r);else e.set(t,r);return r}function N(e,t,i){let r,s=e.get(t);for(r of i)s.set(r[0],r[1])}const B=new Map,G=new Map,z=new Map,V=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],H=["jfif","xmp","icc","iptc","ihdr"],W=["tiff",...H],j=["ifd0","ifd1","exif","gps","interop"],K=[...W,...j],X=["makerNote","userComment"],_=["translateKeys","translateValues","reviveValues","multiSegment"],$=[..._,"sanitize","mergeOutput","silentErrors"];class J{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}}class Y extends J{get needed(){return this.enabled||this.deps.size>0}constructor(e,t,i,r){if(super(),g(this,"enabled",!1),g(this,"skip",new Set),g(this,"pick",new Set),g(this,"deps",new Set),g(this,"translateKeys",!1),g(this,"translateValues",!1),g(this,"reviveValues",!1),this.key=e,this.enabled=t,this.parse=this.enabled,this.applyInheritables(r),this.canBeFiltered=j.includes(e),this.canBeFiltered&&(this.dict=B.get(e)),void 0!==i)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if("object"==typeof i){if(this.enabled=!0,this.parse=!1!==i.parse,this.canBeFiltered){let{pick:e,skip:t}=i;e&&e.length>0&&this.translateTagSet(e,this.pick),t&&t.length>0&&this.translateTagSet(t,this.skip)}this.applyInheritables(i)}else!0===i||!1===i?this.parse=this.enabled=i:S(`Invalid options argument: ${i}`)}applyInheritables(e){let t,i;for(t of _)i=e[t],void 0!==i&&(this[t]=i)}translateTagSet(e,t){if(this.dict){let i,r,{tagKeys:s,tagValues:n}=this.dict;for(i of e)"string"==typeof i?(r=n.indexOf(i),-1===r&&(r=s.indexOf(Number(i))),-1!==r&&t.add(Number(s[r]))):t.add(i)}else for(let i of e)t.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,ie(this.pick,this.deps)):this.enabled&&this.pick.size>0&&ie(this.pick,this.deps)}}var q={jfif:!1,tiff:!0,xmp:!1,icc:!1,iptc:!1,ifd0:!0,ifd1:!1,exif:!0,gps:!0,interop:!1,ihdr:void 0,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},Q=new Map;class Z extends J{static useCached(e){let t=Q.get(e);return void 0!==t||(t=new this(e),Q.set(e,t)),t}constructor(e){super(),!0===e?this.setupFromTrue():void 0===e?this.setupFromUndefined():Array.isArray(e)?this.setupFromArray(e):"object"==typeof e?this.setupFromObject(e):S(`Invalid options argument ${e}`),void 0===this.firstChunkSize&&(this.firstChunkSize=n?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let e;for(e of V)this[e]=q[e];for(e of $)this[e]=q[e];for(e of X)this[e]=q[e];for(e of K)this[e]=new Y(e,q[e],void 0,this)}setupFromTrue(){let e;for(e of V)this[e]=q[e];for(e of $)this[e]=q[e];for(e of X)this[e]=!0;for(e of K)this[e]=new Y(e,!0,void 0,this)}setupFromArray(e){let t;for(t of V)this[t]=q[t];for(t of $)this[t]=q[t];for(t of X)this[t]=q[t];for(t of K)this[t]=new Y(t,!1,void 0,this);this.setupGlobalFilters(e,void 0,j)}setupFromObject(e){let t;for(t of(j.ifd0=j.ifd0||j.image,j.ifd1=j.ifd1||j.thumbnail,Object.assign(this,e),V))this[t]=te(e[t],q[t]);for(t of $)this[t]=te(e[t],q[t]);for(t of X)this[t]=te(e[t],q[t]);for(t of W)this[t]=new Y(t,q[t],e[t],this);for(t of j)this[t]=new Y(t,q[t],e[t],this.tiff);this.setupGlobalFilters(e.pick,e.skip,j,K),!0===e.tiff?this.batchEnableWithBool(j,!0):!1===e.tiff?this.batchEnableWithUserValue(j,e):Array.isArray(e.tiff)?this.setupGlobalFilters(e.tiff,void 0,j):"object"==typeof e.tiff&&this.setupGlobalFilters(e.tiff.pick,e.tiff.skip,j)}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,r=i){if(e&&e.length){for(let e of r)this[e].enabled=!1;let t=ee(e,i);for(let[e,i]of t)ie(this[e].pick,i),this[e].enabled=!0}else if(t&&t.length){let e=ee(t,i);for(let[t,i]of e)ie(this[t].skip,i)}}filterNestedSegmentTags(){let{ifd0:e,exif:t,xmp:i,iptc:r,icc:s}=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),r.enabled||e.skip.add(33723),s.enabled||e.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:e,exif:t,gps:i,interop:r}=this;r.needed&&(t.deps.add(40965),e.deps.add(40965)),t.needed&&e.deps.add(34665),i.needed&&e.deps.add(34853),this.tiff.enabled=j.some((e=>!0===this[e].enabled))||this.makerNote||this.userComment;for(let e of j)this[e].finalizeFilters()}get onlyTiff(){return!H.map((e=>this[e].enabled)).some((e=>!0===e))&&this.tiff.enabled}checkLoadedPlugins(){for(let e of W)this[e].enabled&&!D.has(e)&&T("segment parser",e)}}function ee(e,t){let i,r,s,n,a=[];for(s of t){for(n of(i=B.get(s),r=[],i))(e.includes(n[0])||e.includes(n[1]))&&r.push(n[0]);r.length&&a.push([s,r])}return a}function te(e,t){return void 0!==e?e:void 0!==t?t:void 0}function ie(e,t){for(let i of t)e.add(i)}g(Z,"default",q);class re{constructor(e){g(this,"parsers",{}),g(this,"output",{}),g(this,"errors",[]),g(this,"pushToErrors",(e=>this.errors.push(e))),this.options=Z.useCached(e)}async read(e){this.file=await function(e,t){return"string"==typeof e?x(e,t):n&&!a&&e instanceof HTMLImageElement?x(e.src,t):e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView?new k(e):n&&e instanceof Blob?R(e,t,"blob",U):void S("Invalid input argument")}(e,this.options)}setup(){if(this.fileParser)return;let{file:e}=this,t=e.getUint16(0);for(let[i,r]of A)if(r.canHandle(e,t))return this.fileParser=new r(this.options,this.file,this.parsers),e[i]=!0;this.file.close&&this.file.close(),S("Unknown file format")}async parse(){let{output:e,errors:t}=this;return this.setup(),this.options.silentErrors?(await this.executeParsers().catch(this.pushToErrors),t.push(...this.fileParser.errors)):await this.executeParsers(),this.file.close&&this.file.close(),this.options.silentErrors&&t.length>0&&(e.errors=t),p(e)}async executeParsers(){let{output:e}=this;await this.fileParser.parse();let t=Object.values(this.parsers).map((async t=>{let i=await t.parse();t.assignToOutput(e,i)}));this.options.silentErrors&&(t=t.map((e=>e.catch(this.pushToErrors)))),await Promise.all(t)}async extractThumbnail(){this.setup();let{options:e,file:t}=this,i=D.get("tiff",e);var r;if(t.tiff?r={start:0,type:"tiff"}:t.jpeg&&(r=await this.fileParser.getOrFindSegment("tiff")),void 0===r)return;let s=await this.fileParser.ensureSegmentChunk(r),n=this.parsers.tiff=new i(s,e,t),a=await n.extractThumbnail();return t.close&&t.close(),a}}async function se(e,t){let i=new re(t);return await i.read(e),i.parse()}var ne=Object.freeze({__proto__:null,parse:se,Exifr:re,fileParsers:A,segmentParsers:D,fileReaders:O,tagKeys:B,tagValues:G,tagRevivers:z,createDictionary:E,extendDictionary:N,fetchUrlAsArrayBuffer:M,readBlobAsArrayBuffer:U,chunkedProps:V,otherSegments:H,segments:W,tiffBlocks:j,segmentsAndBlocks:K,tiffExtractables:X,inheritables:_,allFormatters:$,Options:Z});class ae{constructor(e,t,i){g(this,"errors",[]),g(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){S(`Couldn't read segment: ${JSON.stringify(e)}. ${t.message}`)}else this.file.byteLength>t+i?e.chunk=this.file.subarray(t,i):void 0===e.size?e.chunk=this.file.subarray(t):S("Segment unreachable: "+JSON.stringify(e));return e.chunk})),this.extendOptions&&this.extendOptions(e),this.options=e,this.file=t,this.parsers=i}injectSegment(e,t){this.options[e].enabled&&this.createParser(e,t)}createParser(e,t){let i=new(D.get(e))(t,this.options,this.file);return this.parsers[e]=i}createParsers(e){for(let t of e){let{type:e,chunk:i}=t,r=this.options[e];if(r&&r.enabled){let t=this.parsers[e];t&&t.append||t||this.createParser(e,i)}}}async readSegments(e){let t=e.map(this.ensureSegmentChunk);await Promise.all(t)}}class oe{static findPosition(e,t){let i=e.getUint16(t+2)+2,r="function"==typeof this.headerLength?this.headerLength(e,t,i):this.headerLength,s=t+r,n=i-r;return{offset:t,length:i,headerLength:r,start:s,size:n,end:s+n}}static parse(e,t={}){return new this(e,new Z({[this.type]:t}),e).parse()}normalizeInput(e){return e instanceof k?e:new k(e)}constructor(e,t={},i){g(this,"errors",[]),g(this,"raw",new Map),g(this,"handleError",(e=>{if(!this.options.silentErrors)throw e;this.errors.push(e.message)})),this.chunk=this.normalizeInput(e),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=t,this.localOptions=t[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(e,t){let i=z.get(t),r=G.get(t),s=B.get(t),n=this.options[t],a=n.reviveValues&&!!i,o=n.translateValues&&!!r,l=n.translateKeys&&!!s,h={};for(let[t,n]of e)a&&i.has(t)?n=i.get(t)(n):o&&r.has(t)&&(n=this.translateValue(n,r.get(t))),l&&s.has(t)&&(t=s.get(t)||t),h[t]=n;return h}translateValue(e,t){return t[e]||t.DEFAULT||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}}function le(e){return 192===e||194===e||196===e||219===e||221===e||218===e||254===e}function he(e){return e>=224&&e<=239}function ce(e,t,i){for(let[r,s]of D)if(s.canHandle(e,t,i))return r}g(oe,"headerLength",4),g(oe,"type",void 0),g(oe,"multiSegment",!1),g(oe,"canHandle",(()=>!1));class ue extends ae{constructor(...e){super(...e),g(this,"appSegments",[]),g(this,"jpegSegments",[]),g(this,"unknownSegments",[])}static canHandle(e,t){return 65496===t}async parse(){await this.findAppSegments(),await this.readSegments(this.appSegments),this.mergeMultiSegments(),this.createParsers(this.mergedAppSegments||this.appSegments)}setupSegmentFinderArgs(e){!0===e?(this.findAll=!0,this.wanted=new Set(D.keyList())):(e=void 0===e?D.keyList().filter((e=>this.options[e].enabled)):e.filter((e=>this.options[e].enabled&&D.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:r,wanted:s,remaining:n}=this;if(!r&&this.file.chunked&&(r=Array.from(s).some((e=>{let t=D.get(e),i=this.options[e];return t.multiSegment&&i.multiSegment})),r&&await this.file.readWhole()),e=this.findAppSegmentsInRange(e,i.byteLength),!this.options.onlyTiff&&i.chunked){let t=!1;for(;n.size>0&&!t&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:r}=i,s=this.appSegments.some((e=>!this.file.available(e.offset||e.start,e.length||e.size)));if(t=e>r&&!s?!await i.readNextChunk(e):!await i.readNextChunk(r),void 0===(e=this.findAppSegmentsInRange(e,i.byteLength)))return}}}findAppSegmentsInRange(e,t){t-=2;let i,r,s,n,a,o,{file:l,findAll:h,wanted:c,remaining:u,options:f}=this;for(;e<t;e++)if(255===l.getUint8(e))if(i=l.getUint8(e+1),he(i)){if(r=l.getUint16(e+2),s=ce(l,e,r),s&&c.has(s)&&(n=D.get(s),a=n.findPosition(l,e),o=f[s],a.type=s,this.appSegments.push(a),!h&&(n.multiSegment&&o.multiSegment?(this.unfinishedMultiSegment=a.chunkNumber<a.chunkCount,this.unfinishedMultiSegment||u.delete(s)):u.delete(s),0===u.size)))break;f.recordUnknownSegments&&(a=oe.findPosition(l,e),a.marker=i,this.unknownSegments.push(a)),e+=r+1}else if(le(i)){if(r=l.getUint16(e+2),218===i&&!1!==f.stopAfterSos)return;f.recordJpegSegments&&this.jpegSegments.push({offset:e,length:r,marker:i}),e+=r+1}return e}mergeMultiSegments(){if(!this.appSegments.some((e=>e.multiSegment)))return;let e=function(e){let t,i,r,s=new Map;for(let n=0;n<e.length;n++)t=e[n],i=t.type,s.has(i)?r=s.get(i):s.set(i,r=[]),r.push(t);return Array.from(s)}(this.appSegments);this.mergedAppSegments=e.map((([e,t])=>{let i=D.get(e,this.options);return i.handleMultiSegments?{type:e,chunk:i.handleMultiSegments(t)}:t[0]}))}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}}g(ue,"type","jpeg"),A.set("jpeg",ue);const fe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4];class de extends oe{parseHeader(){var e=this.chunk.getUint16();18761===e?this.le=!0:19789===e&&(this.le=!1),this.chunk.le=this.le,this.headerParsed=!0}parseTags(e,t,i=new Map){let{pick:r,skip:s}=this.options[t];r=new Set(r);let n=r.size>0,a=0===s.size,o=this.chunk.getUint16(e);e+=2;for(let l=0;l<o;l++){let o=this.chunk.getUint16(e);if(n){if(r.has(o)&&(i.set(o,this.parseTag(e,o,t)),r.delete(o),0===r.size))break}else!a&&s.has(o)||i.set(o,this.parseTag(e,o,t));e+=12}return i}parseTag(e,t,i){let{chunk:r}=this,s=r.getUint16(e+2),n=r.getUint32(e+4),a=fe[s];if(a*n<=4?e+=8:e=r.getUint32(e+8),(s<1||s>13)&&S(`Invalid TIFF value type. block: ${i.toUpperCase()}, tag: ${t.toString(16)}, type: ${s}, offset ${e}`),e>r.byteLength&&S(`Invalid TIFF value offset. block: ${i.toUpperCase()}, tag: ${t.toString(16)}, type: ${s}, offset ${e} is outside of chunk size ${r.byteLength}`),1===s)return r.getUint8Array(e,n);if(2===s)return C(r.getString(e,n));if(7===s)return r.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:case 10:default:return Array;case 6:return Int8Array;case 8:return Int16Array;case 9:return Int32Array;case 11:return Float32Array;case 12:return Float64Array}}(s))(n),i=a;for(let r=0;r<n;r++)t[r]=this.parseTagValue(s,e),e+=i;return t}}parseTagValue(e,t){let{chunk:i}=this;switch(e){case 1:return i.getUint8(t);case 3:return i.getUint16(t);case 4:case 13:return i.getUint32(t);case 5:return i.getUint32(t)/i.getUint32(t+4);case 6:return i.getInt8(t);case 8:return i.getInt16(t);case 9:return i.getInt32(t);case 10:return i.getInt32(t)/i.getInt32(t+4);case 11:return i.getFloat(t);case 12:return i.getDouble(t);default:S(`Invalid tiff type ${e}`)}}}class ge extends de{static canHandle(e,t){return 225===e.getUint8(t+1)&&1165519206===e.getUint32(t+4)&&0===e.getUint16(t+8)}async parse(){this.parseHeader();let{options:e}=this;return e.ifd0.enabled&&await this.parseIfd0Block(),e.exif.enabled&&await this.safeParse("parseExifBlock"),e.gps.enabled&&await this.safeParse("parseGpsBlock"),e.interop.enabled&&await this.safeParse("parseInteropBlock"),e.ifd1.enabled&&await this.safeParse("parseThumbnailBlock"),this.createOutput()}safeParse(e){let t=this[e]();return void 0!==t.catch&&(t=t.catch(this.handleError)),t}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;let{file:e}=this;this.findIfd0Offset(),this.ifd0Offset<8&&S("Malformed EXIF data"),!e.chunked&&this.ifd0Offset>e.byteLength&&S(`IFD0 offset points to outside of file.\nthis.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${e.byteLength}`),e.tiff&&await e.ensureChunk(this.ifd0Offset,b(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 parseExifBlock(){if(this.exif)return;if(this.ifd0||await this.parseIfd0Block(),void 0===this.exifOffset)return;this.file.tiff&&await this.file.ensureChunk(this.exifOffset,b(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",pe(...e.get(2),e.get(1))),e.set("longitude",pe(...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,r={};for(t of j)if(e=this[t],!y(e))if(i=this.canTranslate?this.translateBlock(e,t):Object.fromEntries(e),this.options.mergeOutput){if("ifd1"===t)continue;Object.assign(r,i)}else r[t]=i;return this.makerNote&&(r.makerNote=this.makerNote),this.userComment&&(r.userComment=this.userComment),r}assignToOutput(e,t){if(this.globalOptions.mergeOutput)Object.assign(e,t);else for(let[i,r]of Object.entries(t))this.assignObjectToOutput(e,i,r)}}function pe(e,t,i,r){var s=e+t/60+i/3600;return"S"!==r&&"W"!==r||(s*=-1),s}g(ge,"type","tiff"),g(ge,"headerLength",10),D.set("tiff",ge);var me=Object.freeze({__proto__:null,default:ne,Exifr:re,fileParsers:A,segmentParsers:D,fileReaders:O,tagKeys:B,tagValues:G,tagRevivers:z,createDictionary:E,extendDictionary:N,fetchUrlAsArrayBuffer:M,readBlobAsArrayBuffer:U,chunkedProps:V,otherSegments:H,segments:W,tiffBlocks:j,segmentsAndBlocks:K,tiffExtractables:X,inheritables:_,allFormatters:$,Options:Z,parse:se});const ye={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Se=Object.assign({},ye,{firstChunkSize:4e4,gps:[1,2,3,4]});async function Ce(e){let t=new re(Se);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}}}const be=Object.assign({},ye,{tiff:!1,ifd1:!0,mergeOutput:!1});async function we(e){let t=new re(be);await t.read(e);let i=await t.extractThumbnail();return i&&c?l.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)}}const Pe=Object.assign({},ye,{firstChunkSize:4e4,ifd0:[274]});async function ke(e){let t=new re(Pe);await t.read(e);let i=await t.parse();if(i&&i.ifd0)return i.ifd0[274]}const Te=Object.freeze({1:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:0,rad:0},2:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:0,rad:0},3:{dimensionSwapped:!1,scaleX:1,scaleY:1,deg:180,rad:180*Math.PI/180},4:{dimensionSwapped:!1,scaleX:-1,scaleY:1,deg:180,rad:180*Math.PI/180},5:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:90,rad:90*Math.PI/180},6:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:90,rad:90*Math.PI/180},7:{dimensionSwapped:!0,scaleX:1,scaleY:-1,deg:270,rad:270*Math.PI/180},8:{dimensionSwapped:!0,scaleX:1,scaleY:1,deg:270,rad:270*Math.PI/180}});let ve=!0,Ae=!0;if("object"==typeof navigator){let e=navigator.userAgent;if(e.includes("iPad")||e.includes("iPhone")){let t=e.match(/OS (\d+)_(\d+)/);if(t){let[,e,i]=t,r=Number(e)+.1*Number(i);ve=r<13.4,Ae=!1}}else if(e.includes("OS X 10")){let[,t]=e.match(/OS X 10[_.](\d+)/);ve=Ae=Number(t)<15}if(e.includes("Chrome/")){let[,t]=e.match(/Chrome\/(\d+)/);ve=Ae=Number(t)<81}else if(e.includes("Firefox/")){let[,t]=e.match(/Firefox\/(\d+)/);ve=Ae=Number(t)<77}}async function De(e){let t=await ke(e);return Object.assign({canvas:ve,css:Ae},Te[t])}class Oe extends k{constructor(...e){super(...e),g(this,"ranges",new xe),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=c?l.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 r=super.set(e,t);return this.ranges.add(t,r.byteLength),r}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 xe{constructor(){g(this,"list",[])}get length(){return this.list.length}add(e,t,i=0){let r=e+t,s=this.list.filter((t=>Re(e,t.offset,r)||Re(e,t.end,r)));if(s.length>0){e=Math.min(e,...s.map((e=>e.offset))),r=Math.max(r,...s.map((e=>e.end))),t=r-e;let i=s.shift();i.offset=e,i.length=t,i.end=r,this.list=this.list.filter((e=>!s.includes(e)))}else this.list.push({offset:e,length:t,end:r})}available(e,t){let i=e+t;return this.list.some((t=>t.offset<=e&&i<=t.end))}}function Re(e,t,i){return e<=t&&t<=i}class Le extends Oe{constructor(e,t){super(0),g(this,"chunksRead",0),this.input=e,this.options=t}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(e=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let t=this.options.chunkSize,i=await this.readChunk(e,t);return!!i&&i.byteLength===t}async readChunk(e,t){if(this.chunksRead++,0!==(t=this.safeWrapAddress(e,t)))return this._readChunk(e,t)}safeWrapAddress(e,t){return void 0!==this.size&&e+t>this.size?Math.max(0,this.size-e):t}get nextChunkOffset(){if(0!==this.ranges.list.length)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return void 0!==this.size&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}}O.set("blob",class extends Le{async readWhole(){this.chunked=!1;let e=await U(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,r=this.input.slice(e,i),s=await U(r);return this.set(s,e,!0)}});var Me=Object.freeze({__proto__:null,default:me,Exifr:re,fileParsers:A,segmentParsers:D,fileReaders:O,tagKeys:B,tagValues:G,tagRevivers:z,createDictionary:E,extendDictionary:N,fetchUrlAsArrayBuffer:M,readBlobAsArrayBuffer:U,chunkedProps:V,otherSegments:H,segments:W,tiffBlocks:j,segmentsAndBlocks:K,tiffExtractables:X,inheritables:_,allFormatters:$,Options:Z,parse:se,gpsOnlyOptions:Se,gps:Ce,thumbnailOnlyOptions:be,thumbnail:we,thumbnailUrl:Ie,orientationOnlyOptions:Pe,orientation:ke,rotations:Te,get rotateCanvas(){return ve},get rotateCss(){return Ae},rotation:De});O.set("url",class extends Le{async readWhole(){this.chunked=!1;let e=await M(this.input);e instanceof ArrayBuffer?this._swapArrayBuffer(e):e instanceof Uint8Array&&this._swapBuffer(e)}async _readChunk(e,t){let i=t?e+t-1:void 0,r=this.options.httpHeaders||{};(e||i)&&(r.range=`bytes=${[e,i].join("-")}`);let s=await d(this.input,{headers:r}),n=await s.arrayBuffer(),a=n.byteLength;if(416!==s.status)return a!==t&&(this.size=e+a),this.set(n,e,!0)}}),k.prototype.getUint64=function(e){let t=this.getUint32(e),i=this.getUint32(e+4);return t<1048575?t<<32|i:void 0!==typeof h?h(t)<<h(32)|h(i):void S("Trying to read 64b value but JS can only handle 53b numbers.")};class Ue extends ae{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),r=e+8;return 1===t&&(t=this.file.getUint64(e+8),r+=8),{offset:e,length:t,kind:i,start:r}}parseBoxFullHead(e){if(void 0!==e.version)return;let t=this.file.getUint32(e.start);e.version=t>>24,e.start+=4}}class Fe extends Ue{static canHandle(e,t){if(0!==t)return!1;let i=e.getUint16(2);if(i>50)return!1;let r=16,s=[];for(;r<i;)s.push(e.getString(r,4)),r+=4;return s.includes(this.type)}async parse(){let e=this.file.getUint32(0),t=this.parseBoxHead(e);for(;"meta"!==t.kind;)e+=t.length,await this.file.ensureChunk(e,16),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 r=this.file.subarray(t,i);this.createParser(e,r)}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 r=this.findBox(i,"colr");void 0!==r&&await this.registerSegment("icc",r.offset+12,r.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 r=this.findExifLocIdInIinf(t),s=this.findExtentInIloc(i,r);if(void 0===s)return;let[n,a]=s;await this.file.ensureChunk(n,a);let o=4+this.file.getUint32(n);n+=o,a-=o,await this.registerSegment("tiff",n,a)}findExifLocIdInIinf(e){this.parseBoxFullHead(e);let t,i,r,s,n=e.start,a=this.file.getUint16(n);for(n+=2;a--;){if(t=this.parseBoxHead(n),this.parseBoxFullHead(t),i=t.start,t.version>=2&&(r=3===t.version?4:2,s=this.file.getString(i+r+2,4),"Exif"===s))return this.file.getUintBytes(i,r);n+=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,[r,s]=this.get8bits(i++),[n,a]=this.get8bits(i++),o=2===e.version?4:2,l=1===e.version||2===e.version?2:0,h=a+r+s,c=2===e.version?4:2,u=this.file.getUintBytes(i,c);for(i+=c;u--;){let e=this.file.getUintBytes(i,o);i+=o+l+2+n;let c=this.file.getUint16(i);if(i+=2,e===t)return[this.file.getUintBytes(i+a,r),this.file.getUintBytes(i+a+r,s)];i+=c*h}}}class Ee extends Fe{}g(Ee,"type","heic");class Ne extends Fe{}g(Ne,"type","avif"),A.set("heic",Ee),A.set("avif",Ne),E(B,["ifd0","ifd1"],[[256,"ImageWidth"],[257,"ImageHeight"],[258,"BitsPerSample"],[259,"Compression"],[262,"PhotometricInterpretation"],[270,"ImageDescription"],[271,"Make"],[272,"Model"],[273,"StripOffsets"],[274,"Orientation"],[277,"SamplesPerPixel"],[278,"RowsPerStrip"],[279,"StripByteCounts"],[282,"XResolution"],[283,"YResolution"],[284,"PlanarConfiguration"],[296,"ResolutionUnit"],[301,"TransferFunction"],[305,"Software"],[306,"ModifyDate"],[315,"Artist"],[316,"HostComputer"],[317,"Predictor"],[318,"WhitePoint"],[319,"PrimaryChromaticities"],[513,"ThumbnailOffset"],[514,"ThumbnailLength"],[529,"YCbCrCoefficients"],[530,"YCbCrSubSampling"],[531,"YCbCrPositioning"],[532,"ReferenceBlackWhite"],[700,"ApplicationNotes"],[33432,"Copyright"],[33723,"IPTC"],[34665,"ExifIFD"],[34675,"ICC"],[34853,"GpsIFD"],[330,"SubIFD"],[40965,"InteropIFD"],[40091,"XPTitle"],[40092,"XPComment"],[40093,"XPAuthor"],[40094,"XPKeywords"],[40095,"XPSubject"]]),E(B,"exif",[[33434,"ExposureTime"],[33437,"FNumber"],[34850,"ExposureProgram"],[34852,"SpectralSensitivity"],[34855,"ISO"],[34858,"TimeZoneOffset"],[34859,"SelfTimerMode"],[34864,"SensitivityType"],[34865,"StandardOutputSensitivity"],[34866,"RecommendedExposureIndex"],[34867,"ISOSpeed"],[34868,"ISOSpeedLatitudeyyy"],[34869,"ISOSpeedLatitudezzz"],[36864,"ExifVersion"],[36867,"DateTimeOriginal"],[36868,"CreateDate"],[36873,"GooglePlusUploadCode"],[36880,"OffsetTime"],[36881,"OffsetTimeOriginal"],[36882,"OffsetTimeDigitized"],[37121,"ComponentsConfiguration"],[37122,"CompressedBitsPerPixel"],[37377,"ShutterSpeedValue"],[37378,"ApertureValue"],[37379,"BrightnessValue"],[37380,"ExposureCompensation"],[37381,"MaxApertureValue"],[37382,"SubjectDistance"],[37383,"MeteringMode"],[37384,"LightSource"],[37385,"Flash"],[37386,"FocalLength"],[37393,"ImageNumber"],[37394,"SecurityClassification"],[37395,"ImageHistory"],[37396,"SubjectArea"],[37500,"MakerNote"],[37510,"UserComment"],[37520,"SubSecTime"],[37521,"SubSecTimeOriginal"],[37522,"SubSecTimeDigitized"],[37888,"AmbientTemperature"],[37889,"Humidity"],[37890,"Pressure"],[37891,"WaterDepth"],[37892,"Acceleration"],[37893,"CameraElevationAngle"],[40960,"FlashpixVersion"],[40961,"ColorSpace"],[40962,"ExifImageWidth"],[40963,"ExifImageHeight"],[40964,"RelatedSoundFile"],[41483,"FlashEnergy"],[41486,"FocalPlaneXResolution"],[41487,"FocalPlaneYResolution"],[41488,"FocalPlaneResolutionUnit"],[41492,"SubjectLocation"],[41493,"ExposureIndex"],[41495,"SensingMethod"],[41728,"FileSource"],[41729,"SceneType"],[41730,"CFAPattern"],[41985,"CustomRendered"],[41986,"ExposureMode"],[41987,"WhiteBalance"],[41988,"DigitalZoomRatio"],[41989,"FocalLengthIn35mmFormat"],[41990,"SceneCaptureType"],[41991,"GainControl"],[41992,"Contrast"],[41993,"Saturation"],[41994,"Sharpness"],[41996,"SubjectDistanceRange"],[42016,"ImageUniqueID"],[42032,"OwnerName"],[42033,"SerialNumber"],[42034,"LensInfo"],[42035,"LensMake"],[42036,"LensModel"],[42037,"LensSerialNumber"],[42080,"CompositeImage"],[42081,"CompositeImageCount"],[42082,"CompositeImageExposureTimes"],[42240,"Gamma"],[59932,"Padding"],[59933,"OffsetSchema"],[65e3,"OwnerName"],[65001,"SerialNumber"],[65002,"Lens"],[65100,"RawFile"],[65101,"Converter"],[65102,"WhiteBalance"],[65105,"Exposure"],[65106,"Shadows"],[65107,"Brightness"],[65108,"Contrast"],[65109,"Saturation"],[65110,"Sharpness"],[65111,"Smoothness"],[65112,"MoireFilter"],[40965,"InteropIFD"]]),E(B,"gps",[[0,"GPSVersionID"],[1,"GPSLatitudeRef"],[2,"GPSLatitude"],[3,"GPSLongitudeRef"],[4,"GPSLongitude"],[5,"GPSAltitudeRef"],[6,"GPSAltitude"],[7,"GPSTimeStamp"],[8,"GPSSatellites"],[9,"GPSStatus"],[10,"GPSMeasureMode"],[11,"GPSDOP"],[12,"GPSSpeedRef"],[13,"GPSSpeed"],[14,"GPSTrackRef"],[15,"GPSTrack"],[16,"GPSImgDirectionRef"],[17,"GPSImgDirection"],[18,"GPSMapDatum"],[19,"GPSDestLatitudeRef"],[20,"GPSDestLatitude"],[21,"GPSDestLongitudeRef"],[22,"GPSDestLongitude"],[23,"GPSDestBearingRef"],[24,"GPSDestBearing"],[25,"GPSDestDistanceRef"],[26,"GPSDestDistance"],[27,"GPSProcessingMethod"],[28,"GPSAreaInformation"],[29,"GPSDateStamp"],[30,"GPSDifferential"],[31,"GPSHPositioningError"]]),E(G,["ifd0","ifd1"],[[274,{1:"Horizontal (normal)",2:"Mirror horizontal",3:"Rotate 180",4:"Mirror vertical",5:"Mirror horizontal and rotate 270 CW",6:"Rotate 90 CW",7:"Mirror horizontal and rotate 90 CW",8:"Rotate 270 CW"}],[296,{1:"None",2:"inches",3:"cm"}]]);let Be=E(G,"exif",[[34850,{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"}],[37121,{0:"-",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}],[37383,{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"}],[37384,{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"}],[37385,{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"}],[41495,{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"}],[41728,{1:"Film Scanner",2:"Reflection Print Scanner",3:"Digital Camera"}],[41729,{1:"Directly photographed"}],[41985,{0:"Normal",1:"Custom",2:"HDR (no original saved)",3:"HDR (original saved)",4:"Original (for HDR)",6:"Panorama",7:"Portrait HDR",8:"Portrait"}],[41986,{0:"Auto",1:"Manual",2:"Auto bracket"}],[41987,{0:"Auto",1:"Manual"}],[41990,{0:"Standard",1:"Landscape",2:"Portrait",3:"Night",4:"Other"}],[41991,{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"}],[41996,{0:"Unknown",1:"Macro",2:"Close",3:"Distant"}],[42080,{0:"Unknown",1:"Not a Composite Image",2:"General Composite Image",3:"Composite Image Captured While Shooting"}]]);const Ge={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};Be.set(37392,Ge),Be.set(41488,Ge);const ze={0:"Normal",1:"Low",2:"High"};function Ve(e){return"object"==typeof e&&void 0!==e.length?e[0]:e}function He(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 We(e){if("string"==typeof e){var[t,i,r,s,n,a]=e.trim().split(/[-: ]/g).map(Number),o=new Date(t,i-1,r);return Number.isNaN(s)||Number.isNaN(n)||Number.isNaN(a)||(o.setHours(s),o.setMinutes(n),o.setSeconds(a)),Number.isNaN(+o)?e:o}}function je(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(Ke(e[i+1],e[i]));else for(let i=0;i<e.length;i+=2)t.push(Ke(e[i],e[i+1]));return C(String.fromCodePoint(...t))}function Ke(e,t){return e<<8|t}Be.set(41992,ze),Be.set(41993,ze),Be.set(41994,ze),E(z,["ifd0","ifd1"],[[50827,function(e){return"string"!=typeof e?P(e):e}],[306,We],[40091,je],[40092,je],[40093,je],[40094,je],[40095,je]]),E(z,"exif",[[40960,He],[36864,He],[36867,We],[36868,We],[40962,Ve],[40963,Ve]]),E(z,"gps",[[0,e=>Array.from(e).join(".")],[7,e=>Array.from(e).join(":")]]);class Xe extends oe{static canHandle(e,t){return 225===e.getUint8(t+1)&&1752462448===e.getUint32(t+4)&&"http://ns.adobe.com/"===e.getString(t+4,20)}static headerLength(e,t){return"http://ns.adobe.com/xmp/extension/"===e.getString(t+4,34)?79:33}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:k.from(e).getString()}parse(e=this.chunk){if(!this.localOptions.parse)return e;e=function(e){let t={},i={};for(let e of tt)t[e]=[],i[e]=0;return e.replace(it,((e,r,s)=>{if("<"===r){let r=++i[s];return t[s].push(r),`${e}#${r}`}return`${e}#${t[s].pop()}`}))}(e);let t=$e.findAll(e,"rdf","Description");0===t.length&&t.push(new $e("rdf","Description",void 0,e));let i,r={};for(let e of t)for(let t of e.properties)i=Qe(t.ns,r),Je(t,i);return function(e){let t;for(let i in e)t=e[i]=p(e[i]),void 0===t&&delete e[i];return p(e)}(r)}assignToOutput(e,t){if(this.localOptions.parse)for(let[i,r]of Object.entries(t))switch(i){case"tiff":this.assignObjectToOutput(e,"ifd0",r);break;case"exif":this.assignObjectToOutput(e,"exif",r);break;case"xmlns":break;default:this.assignObjectToOutput(e,i,r)}else e.xmp=t}}g(Xe,"type","xmp"),g(Xe,"multiSegment",!0),D.set("xmp",Xe);class _e{static findAll(e){return Ze(e,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_e.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],r=e[3].slice(1,-1);return r=et(r),new _e(t,i,r)}constructor(e,t,i){this.ns=e,this.name=t,this.value=i}serialize(){return this.value}}class $e{static findAll(e,t,i){if(void 0!==t||void 0!==i){t=t||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var r=new RegExp(`<(${t}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else r=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return Ze(e,r).map($e.unpackMatch)}static unpackMatch(e){let t=e[1],i=e[2],r=e[4],s=e[8];return new $e(t,i,r,s)}constructor(e,t,i,r){this.ns=e,this.name=t,this.attrString=i,this.innerXml=r,this.attrs=_e.findAll(i),this.children=$e.findAll(r),this.value=0===this.children.length?et(r):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 qe(this.children.map(Ye));if(this.isListItem&&1===this.children.length&&0===this.attrs.length)return this.children[0].serialize();let e={};for(let t of this.properties)Je(t,e);return void 0!==this.value&&(e.value=this.value),p(e)}}function Je(e,t){let i=e.serialize();void 0!==i&&(t[e.name]=i)}var Ye=e=>e.serialize(),qe=e=>1===e.length?e[0]:e,Qe=(e,t)=>t[e]?t[e]:t[e]={};function Ze(e,t){let i,r=[];if(!e)return r;for(;null!==(i=t.exec(e));)r.push(i);return r}function et(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 tt=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],it=new RegExp(`(<|\\/)(${tt.join("|")})`,"g");var rt=Object.freeze({__proto__:null,default:Me,Exifr:re,fileParsers:A,segmentParsers:D,fileReaders:O,tagKeys:B,tagValues:G,tagRevivers:z,createDictionary:E,extendDictionary:N,fetchUrlAsArrayBuffer:M,readBlobAsArrayBuffer:U,chunkedProps:V,otherSegments:H,segments:W,tiffBlocks:j,segmentsAndBlocks:K,tiffExtractables:X,inheritables:_,allFormatters:$,Options:Z,parse:se,gpsOnlyOptions:Se,gps:Ce,thumbnailOnlyOptions:be,thumbnail:we,thumbnailUrl:Ie,orientationOnlyOptions:Pe,orientation:ke,rotations:Te,get rotateCanvas(){return ve},get rotateCss(){return Ae},rotation:De});let st=f("fs",(e=>e.promises));O.set("fs",class extends Le{async readWhole(){this.chunked=!1,this.fs=await st;let e=await this.fs.readFile(this.input);this._swapBuffer(e)}async readChunked(){this.chunked=!0,this.fs=await st,await this.open(),await this.readChunk(0,this.options.firstChunkSize)}async open(){void 0===this.fh&&(this.fh=await this.fs.open(this.input,"r"),this.size=(await this.fh.stat(this.input)).size)}async _readChunk(e,t){void 0===this.fh&&await this.open(),e+t>this.size&&(t=this.size-e);var i=this.subarray(e,t,!0);return await this.fh.read(i.dataView,0,t,e),i}async close(){if(this.fh){let e=this.fh;this.fh=void 0,await e.close()}}}),O.set("base64",class extends Le{constructor(...e){super(...e),this.input=this.input.replace(/^data:([^;]+);base64,/gim,""),this.size=this.input.length/4*3,this.input.endsWith("==")?this.size-=2:this.input.endsWith("=")&&(this.size-=1)}async _readChunk(e,t){let i,r,s=this.input;void 0===e?(e=0,i=0,r=0):(i=4*Math.floor(e/3),r=e-i/4*3),void 0===t&&(t=this.size);let n=e+t,a=i+4*Math.ceil(n/3);s=s.slice(i,a);let o=Math.min(t,this.size-e);if(c){let t=l.from(s,"base64").slice(r,r+o);return this.set(t,e,!0)}{let t=this.subarray(e,o,!0),i=atob(s),n=t.toUint8();for(let e=0;e<o;e++)n[e]=i.charCodeAt(r+e);return t}}});class nt extends ae{static canHandle(e,t){return 18761===t||19789===t}extendOptions(e){let{ifd0:t,xmp:i,iptc:r,icc:s}=e;i.enabled&&t.deps.add(700),r.enabled&&t.deps.add(33723),s.enabled&&t.deps.add(34675),t.finalizeFilters()}async parse(){let{tiff:e,xmp:t,iptc:i,icc:r}=this.options;if(e.enabled||t.enabled||i.enabled||r.enabled){let e=Math.max(b(this.options),this.options.chunkSize);await this.file.ensureChunk(0,e),this.createParser("tiff",this.file),this.parsers.tiff.parseHeader(),await this.parsers.tiff.parseIfd0Block(),this.adaptTiffPropAsSegment("xmp"),this.adaptTiffPropAsSegment("iptc"),this.adaptTiffPropAsSegment("icc")}}adaptTiffPropAsSegment(e){if(this.parsers.tiff[e]){let t=this.parsers.tiff[e];this.injectSegment(e,t)}}}g(nt,"type","tiff"),A.set("tiff",nt);let at=f("zlib");const ot=["ihdr","iccp","text","itxt","exif"];class lt extends ae{constructor(...e){super(...e),g(this,"catchError",(e=>this.errors.push(e))),g(this,"metaChunks",[]),g(this,"unknownChunks",[])}static canHandle(e,t){return 35152===t&&2303741511===e.getUint32(0)&&218765834===e.getUint32(4)}async parse(){let{file:e}=this;await this.findPngChunksInRange(8,e.byteLength),await this.readSegments(this.metaChunks),this.findIhdr(),this.parseTextChunks(),await this.findExif().catch(this.catchError),await this.findXmp().catch(this.catchError),await this.findIcc().catch(t