@copio/sdk 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +154 -151
  2. package/dist/adapters/image/canvas2d-adapter.js +1 -1
  3. package/dist/adapters/image/index.js +1 -1
  4. package/dist/adapters/index.js +1 -1
  5. package/dist/adapters/indexeddb-adapter.js +1 -1
  6. package/dist/adapters/pdf/index.js +1 -1
  7. package/dist/adapters/pdf/pdfkit-adapter.js +1 -1
  8. package/dist/adapters/storage/index.js +1 -1
  9. package/dist/adapters/storage/indexeddb-adapter.js +1 -1
  10. package/dist/cdn.js +42 -1119
  11. package/dist/{chunk-534NMCRQ.js → chunk-G5EUMLYT.js} +2 -2
  12. package/dist/{chunk-4YYY7PHH.js → chunk-GGERQ3CJ.js} +11 -11
  13. package/dist/chunk-K4NR6OAC.js +2 -0
  14. package/dist/chunk-L4OVZN23.js +2 -0
  15. package/dist/chunk-NQW6FFN7.js +50 -0
  16. package/dist/{chunk-DOKG4LX2.js → chunk-O7IV7A6O.js} +2 -2
  17. package/dist/chunk-Q7XPZMZA.js +1395 -0
  18. package/dist/core.js +1 -1
  19. package/dist/custom-elements.json +260 -1770
  20. package/dist/index.js +2 -2
  21. package/dist/scanner.js +16 -1120
  22. package/dist/sync.js +1 -1
  23. package/dist/types/sdk/elements.d.ts +0 -12
  24. package/dist/types/sdk/index.d.ts +0 -6
  25. package/dist/types/sdk/scanner.d.ts +2 -7
  26. package/dist/types/sdk/version.d.ts +1 -1
  27. package/package.json +2 -2
  28. package/sdk/index.js +0 -6
  29. package/sdk/scanner.js +5 -12
  30. package/sdk/version.js +1 -1
  31. package/dist/chunk-4XWSVHFW.js +0 -2472
  32. package/dist/chunk-5KUKBKWL.js +0 -33
  33. package/dist/chunk-DY5ZSP4Q.js +0 -2
  34. package/dist/chunk-IH2AI54D.js +0 -2
  35. package/dist/chunk-RDCHJL6F.js +0 -2
  36. package/dist/chunk-XEN5VKAV.js +0 -19
  37. package/dist/types/js/components/copio-header.d.ts +0 -23
  38. package/dist/types/js/components/copio-loader.d.ts +0 -6
  39. package/dist/types/js/core/store.d.ts +0 -2
  40. package/dist/types/js/routes/add-edit/copio-add-edit-dialog.d.ts +0 -9
  41. package/dist/types/js/routes/doc/copio-carousel.d.ts +0 -42
  42. package/dist/types/js/routes/doc/copio-images.d.ts +0 -33
  43. package/dist/types/js/routes/home/copio-row.d.ts +0 -49
  44. package/dist/types/js/styles/cropper-styles.d.ts +0 -5
@@ -1,4 +1,4 @@
1
1
  import{a as Et}from"./chunk-ULTSZWZO.js";function c(s,t,e){return t in s?Object.defineProperty(s,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):s[t]=e,s}var At=typeof self<"u"?self:global,q=typeof navigator<"u",me=q&&typeof HTMLImageElement>"u",Nt=!(typeof global>"u"||typeof process>"u"||!process.versions||!process.versions.node),It=At.Buffer,tt=At.BigInt,Ut=!!It,et=s=>Yt(s)?void 0:s,ye=s=>s!==void 0;function Yt(s){return s===void 0||(s instanceof Map?s.size===0:Object.values(s).filter(ye).length===0)}function m(s){let t=new Error(s);throw delete t.stack,t}function qt(s){return(s=(function(t){for(;t.endsWith("\0");)t=t.slice(0,-1);return t})(s).trim())===""?void 0:s}function zt(s){let t=(function(e){let i=0;return e.ifd0.enabled&&(i+=1024),e.exif.enabled&&(i+=2048),e.makerNote&&(i+=2048),e.userComment&&(i+=1024),e.gps.enabled&&(i+=512),e.interop.enabled&&(i+=100),e.ifd1.enabled&&(i+=1024),i+2048})(s);return s.jfif.enabled&&(t+=50),s.xmp.enabled&&(t+=2e4),s.iptc.enabled&&(t+=14e3),s.icc.enabled&&(t+=6e3),t}var yt=s=>String.fromCharCode.apply(null,s),Vt=typeof TextDecoder<"u"?new TextDecoder("utf-8"):void 0;function Zt(s){return Vt?Vt.decode(s):Ut?Buffer.from(s).toString("utf8"):decodeURIComponent(escape(yt(s)))}var O=class s{static from(t,e){return t instanceof this&&t.le===e?t:new s(t,void 0,void 0,e)}constructor(t,e=0,i,n){if(typeof n=="boolean"&&(this.le=n),Array.isArray(t)&&(t=new Uint8Array(t)),t===0)this.byteOffset=0,this.byteLength=0;else if(t instanceof ArrayBuffer){i===void 0&&(i=t.byteLength-e);let r=new DataView(t,e,i);this._swapDataView(r)}else if(t instanceof Uint8Array||t instanceof DataView||t instanceof s){i===void 0&&(i=t.byteLength-e),(e+=t.byteOffset)+i>t.byteOffset+t.byteLength&&m("Creating view outside of available memory in ArrayBuffer");let r=new DataView(t.buffer,e,i);this._swapDataView(r)}else if(typeof t=="number"){let r=new DataView(new ArrayBuffer(t));this._swapDataView(r)}else m("Invalid input argument for BufferView: "+t)}_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=s){return t instanceof DataView||t instanceof s?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t instanceof ArrayBuffer&&(t=new Uint8Array(t)),t instanceof Uint8Array||m("BufferView.set(): Invalid data argument."),this.toUint8().set(t,e),new i(this,e,t.byteLength)}subarray(t,e){return e=e||this._lengthToEnd(t),new s(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){return Zt(this.getUint8Array(t,e))}getLatin1String(t=0,e=this.byteLength){let i=this.getUint8Array(t,e);return yt(i)}getUnicodeString(t=0,e=this.byteLength){let i=[];for(let n=0;n<e&&t+n<this.byteLength;n+=2)i.push(this.getUint16(t+n));return yt(i)}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)}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&&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&&this.getUint64(t,i)}}toString(t){return this.dataView.toString(t,this.constructor.name)}ensureChunk(){}};function bt(s,t){m(`${s} '${t}' was not loaded, try using full build of exifr.`)}var Z=class extends Map{constructor(t){super(),this.kind=t}get(t,e){return this.has(t)||bt(this.kind,t),e&&(t in e||(function(i,n){m(`Unknown ${i} '${n}'.`)})(this.kind,t),e[t].enabled||bt(this.kind,t)),super.get(t)}keyList(){return Array.from(this.keys())}},z=new Z("file parser"),b=new Z("segment parser"),V=new Z("file reader"),Jt=At.fetch;function Rt(s,t){return(e=s).startsWith("data:")||e.length>1e4?St(s,t,"base64"):Nt&&s.includes("://")?wt(s,t,"url",G):Nt?St(s,t,"fs"):q?wt(s,t,"url",G):void m("Invalid input argument");var e}async function wt(s,t,e,i){return V.has(e)?St(s,t,e):i?(async function(n,r){let a=await r(n);return new O(a)})(s,i):void m(`Parser ${e} is not loaded`)}async function St(s,t,e){let i=new(V.get(e))(s,t);return await i.read(),i}var G=s=>Jt(s).then((t=>t.arrayBuffer())),H=s=>new Promise(((t,e)=>{let i=new FileReader;i.onloadend=()=>t(i.result||new ArrayBuffer),i.onerror=e,i.readAsArrayBuffer(s)})),kt=class 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 k(s,t,e){let i=new kt;for(let[n,r]of e)i.set(n,r);if(Array.isArray(t))for(let n of t)s.set(n,i);else s.set(t,i);return i}function Bt(s,t,e){let i,n=s.get(t);for(i of e)n.set(i[0],i[1])}var C=new Map,$=new Map,N=new Map,D=["chunked","firstChunkSize","firstChunkSizeNode","firstChunkSizeBrowser","chunkSize","chunkLimit"],J=["jfif","xmp","icc","iptc","ihdr"],W=["tiff",...J],p=["ifd0","ifd1","exif","gps","interop"],F=[...W,...p],T=["makerNote","userComment"],Q=["translateKeys","translateValues","reviveValues","multiSegment"],E=[...Q,"sanitize","mergeOutput","silentErrors"],it=class{get translate(){return this.translateKeys||this.translateValues||this.reviveValues}},L=class extends it{get needed(){return this.enabled||this.deps.size>0}constructor(t,e,i,n){if(super(),c(this,"enabled",!1),c(this,"skip",new Set),c(this,"pick",new Set),c(this,"deps",new Set),c(this,"translateKeys",!1),c(this,"translateValues",!1),c(this,"reviveValues",!1),this.key=t,this.enabled=e,this.parse=this.enabled,this.applyInheritables(n),this.canBeFiltered=p.includes(t),this.canBeFiltered&&(this.dict=C.get(t)),i!==void 0)if(Array.isArray(i))this.parse=this.enabled=!0,this.canBeFiltered&&i.length>0&&this.translateTagSet(i,this.pick);else if(typeof i=="object"){if(this.enabled=!0,this.parse=i.parse!==!1,this.canBeFiltered){let{pick:r,skip:a}=i;r&&r.length>0&&this.translateTagSet(r,this.pick),a&&a.length>0&&this.translateTagSet(a,this.skip)}this.applyInheritables(i)}else i===!0||i===!1?this.parse=this.enabled=i:m(`Invalid options argument: ${i}`)}applyInheritables(t){let e,i;for(e of Q)i=t[e],i!==void 0&&(this[e]=i)}translateTagSet(t,e){if(this.dict){let i,n,{tagKeys:r,tagValues:a}=this.dict;for(i of t)typeof i=="string"?(n=a.indexOf(i),n===-1&&(n=r.indexOf(Number(i))),n!==-1&&e.add(Number(r[n]))):e.add(i)}else for(let i of t)e.add(i)}finalizeFilters(){!this.enabled&&this.deps.size>0?(this.enabled=!0,st(this.pick,this.deps)):this.enabled&&this.pick.size>0&&st(this.pick,this.deps)}},y={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},jt=new Map,I=class extends it{static useCached(t){let e=jt.get(t);return e!==void 0||(e=new this(t),jt.set(t,e)),e}constructor(t){super(),t===!0?this.setupFromTrue():t===void 0?this.setupFromUndefined():Array.isArray(t)?this.setupFromArray(t):typeof t=="object"?this.setupFromObject(t):m(`Invalid options argument ${t}`),this.firstChunkSize===void 0&&(this.firstChunkSize=q?this.firstChunkSizeBrowser:this.firstChunkSizeNode),this.mergeOutput&&(this.ifd1.enabled=!1),this.filterNestedSegmentTags(),this.traverseTiffDependencyTree(),this.checkLoadedPlugins()}setupFromUndefined(){let t;for(t of D)this[t]=y[t];for(t of E)this[t]=y[t];for(t of T)this[t]=y[t];for(t of F)this[t]=new L(t,y[t],void 0,this)}setupFromTrue(){let t;for(t of D)this[t]=y[t];for(t of E)this[t]=y[t];for(t of T)this[t]=!0;for(t of F)this[t]=new L(t,!0,void 0,this)}setupFromArray(t){let e;for(e of D)this[e]=y[e];for(e of E)this[e]=y[e];for(e of T)this[e]=y[e];for(e of F)this[e]=new L(e,!1,void 0,this);this.setupGlobalFilters(t,void 0,p)}setupFromObject(t){let e;for(e of(p.ifd0=p.ifd0||p.image,p.ifd1=p.ifd1||p.thumbnail,Object.assign(this,t),D))this[e]=gt(t[e],y[e]);for(e of E)this[e]=gt(t[e],y[e]);for(e of T)this[e]=gt(t[e],y[e]);for(e of W)this[e]=new L(e,y[e],t[e],this);for(e of p)this[e]=new L(e,y[e],t[e],this.tiff);this.setupGlobalFilters(t.pick,t.skip,p,F),t.tiff===!0?this.batchEnableWithBool(p,!0):t.tiff===!1?this.batchEnableWithUserValue(p,t):Array.isArray(t.tiff)?this.setupGlobalFilters(t.tiff,void 0,p):typeof t.tiff=="object"&&this.setupGlobalFilters(t.tiff.pick,t.tiff.skip,p)}batchEnableWithBool(t,e){for(let i of t)this[i].enabled=e}batchEnableWithUserValue(t,e){for(let i of t){let n=e[i];this[i].enabled=n!==!1&&n!==void 0}}setupGlobalFilters(t,e,i,n=i){if(t&&t.length){for(let a of n)this[a].enabled=!1;let r=Gt(t,i);for(let[a,o]of r)st(this[a].pick,o),this[a].enabled=!0}else if(e&&e.length){let r=Gt(e,i);for(let[a,o]of r)st(this[a].skip,o)}}filterNestedSegmentTags(){let{ifd0:t,exif:e,xmp:i,iptc:n,icc:r}=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),n.enabled||t.skip.add(33723),r.enabled||t.skip.add(34675)}traverseTiffDependencyTree(){let{ifd0:t,exif:e,gps:i,interop:n}=this;n.needed&&(e.deps.add(40965),t.deps.add(40965)),e.needed&&t.deps.add(34665),i.needed&&t.deps.add(34853),this.tiff.enabled=p.some((r=>this[r].enabled===!0))||this.makerNote||this.userComment;for(let r of p)this[r].finalizeFilters()}get onlyTiff(){return!J.map((t=>this[t].enabled)).some((t=>t===!0))&&this.tiff.enabled}checkLoadedPlugins(){for(let t of W)this[t].enabled&&!b.has(t)&&bt("segment parser",t)}};function Gt(s,t){let e,i,n,r,a=[];for(n of t){for(r of(e=C.get(n),i=[],e))(s.includes(r[0])||s.includes(r[1]))&&i.push(r[0]);i.length&&a.push([n,i])}return a}function gt(s,t){return s!==void 0?s:t!==void 0?t:void 0}function st(s,t){for(let e of t)s.add(e)}c(I,"default",y);var P=class{constructor(t){c(this,"parsers",{}),c(this,"output",{}),c(this,"errors",[]),c(this,"pushToErrors",(e=>this.errors.push(e))),this.options=I.useCached(t)}async read(t){this.file=await(function(e,i){return typeof e=="string"?Rt(e,i):q&&!me&&e instanceof HTMLImageElement?Rt(e.src,i):e instanceof Uint8Array||e instanceof ArrayBuffer||e instanceof DataView?new O(e):q&&e instanceof Blob?wt(e,i,"blob",H):void m("Invalid input argument")})(t,this.options)}setup(){if(this.fileParser)return;let{file:t}=this,e=t.getUint16(0);for(let[i,n]of z)if(n.canHandle(t,e))return this.fileParser=new n(this.options,this.file,this.parsers),t[i]=!0;this.file.close&&this.file.close(),m("Unknown file format")}async parse(){let{output:t,errors:e}=this;return this.setup(),this.options.silentErrors?(await this.executeParsers().catch(this.pushToErrors),e.push(...this.fileParser.errors)):await this.executeParsers(),this.file.close&&this.file.close(),this.options.silentErrors&&e.length>0&&(t.errors=e),et(t)}async executeParsers(){let{output:t}=this;await this.fileParser.parse();let e=Object.values(this.parsers).map((async i=>{let n=await i.parse();i.assignToOutput(t,n)}));this.options.silentErrors&&(e=e.map((i=>i.catch(this.pushToErrors)))),await Promise.all(e)}async extractThumbnail(){this.setup();let{options:t,file:e}=this,i=b.get("tiff",t);var n;if(e.tiff?n={start:0,type:"tiff"}:e.jpeg&&(n=await this.fileParser.getOrFindSegment("tiff")),n===void 0)return;let r=await this.fileParser.ensureSegmentChunk(n),a=this.parsers.tiff=new i(r,t,e),o=await a.extractThumbnail();return e.close&&e.close(),o}};async function Mt(s,t){let e=new P(t);return await e.read(s),e.parse()}var be=Object.freeze({__proto__:null,parse:Mt,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I}),nt=class{constructor(t,e,i){c(this,"errors",[]),c(this,"ensureSegmentChunk",(async n=>{let r=n.start,a=n.size||65536;if(this.file.chunked)if(this.file.available(r,a))n.chunk=this.file.subarray(r,a);else try{n.chunk=await this.file.readChunk(r,a)}catch(o){m(`Couldn't read segment: ${JSON.stringify(n)}. ${o.message}`)}else this.file.byteLength>r+a?n.chunk=this.file.subarray(r,a):n.size===void 0?n.chunk=this.file.subarray(r):m("Segment unreachable: "+JSON.stringify(n));return n.chunk})),this.extendOptions&&this.extendOptions(t),this.options=t,this.file=e,this.parsers=i}injectSegment(t,e){this.options[t].enabled&&this.createParser(t,e)}createParser(t,e){let i=new(b.get(t))(e,this.options,this.file);return this.parsers[t]=i}createParsers(t){for(let e of t){let{type:i,chunk:n}=e,r=this.options[i];if(r&&r.enabled){let a=this.parsers[i];a&&a.append||a||this.createParser(i,n)}}}async readSegments(t){let e=t.map(this.ensureSegmentChunk);await Promise.all(e)}},v=class{static findPosition(t,e){let i=t.getUint16(e+2)+2,n=typeof this.headerLength=="function"?this.headerLength(t,e,i):this.headerLength,r=e+n,a=i-n;return{offset:e,length:i,headerLength:n,start:r,size:a,end:r+a}}static parse(t,e={}){return new this(t,new I({[this.type]:e}),t).parse()}normalizeInput(t){return t instanceof O?t:new O(t)}constructor(t,e={},i){c(this,"errors",[]),c(this,"raw",new Map),c(this,"handleError",(n=>{if(!this.options.silentErrors)throw n;this.errors.push(n.message)})),this.chunk=this.normalizeInput(t),this.file=i,this.type=this.constructor.type,this.globalOptions=this.options=e,this.localOptions=e[this.type],this.canTranslate=this.localOptions&&this.localOptions.translate}translate(){this.canTranslate&&(this.translated=this.translateBlock(this.raw,this.type))}get output(){return this.translated?this.translated:this.raw?Object.fromEntries(this.raw):void 0}translateBlock(t,e){let i=N.get(e),n=$.get(e),r=C.get(e),a=this.options[e],o=a.reviveValues&&!!i,h=a.translateValues&&!!n,l=a.translateKeys&&!!r,u={};for(let[d,f]of t)o&&i.has(d)?f=i.get(d)(f):h&&n.has(d)&&(f=this.translateValue(f,n.get(d))),l&&r.has(d)&&(d=r.get(d)||d),u[d]=f;return u}translateValue(t,e){return e[t]||e.DEFAULT||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}};c(v,"headerLength",4),c(v,"type",void 0),c(v,"multiSegment",!1),c(v,"canHandle",(()=>!1));function we(s){return s===192||s===194||s===196||s===219||s===221||s===218||s===254}function Se(s){return s>=224&&s<=239}function ke(s,t,e){for(let[i,n]of b)if(n.canHandle(s,t,e))return i}var rt=class extends nt{constructor(...t){super(...t),c(this,"appSegments",[]),c(this,"jpegSegments",[]),c(this,"unknownSegments",[])}static canHandle(t,e){return e===65496}async parse(){await this.findAppSegments(),await this.readSegments(this.appSegments),this.mergeMultiSegments(),this.createParsers(this.mergedAppSegments||this.appSegments)}setupSegmentFinderArgs(t){t===!0?(this.findAll=!0,this.wanted=new Set(b.keyList())):(t=t===void 0?b.keyList().filter((e=>this.options[e].enabled)):t.filter((e=>this.options[e].enabled&&b.has(e))),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:n,wanted:r,remaining:a}=this;if(!n&&this.file.chunked&&(n=Array.from(r).some((o=>{let h=b.get(o),l=this.options[o];return h.multiSegment&&l.multiSegment})),n&&await this.file.readWhole()),t=this.findAppSegmentsInRange(t,i.byteLength),!this.options.onlyTiff&&i.chunked){let o=!1;for(;a.size>0&&!o&&(i.canReadNextChunk||this.unfinishedMultiSegment);){let{nextChunkOffset:h}=i,l=this.appSegments.some((u=>!this.file.available(u.offset||u.start,u.length||u.size)));if(o=t>h&&!l?!await i.readNextChunk(t):!await i.readNextChunk(h),(t=this.findAppSegmentsInRange(t,i.byteLength))===void 0)return}}}findAppSegmentsInRange(t,e){e-=2;let i,n,r,a,o,h,{file:l,findAll:u,wanted:d,remaining:f,options:g}=this;for(;t<e;t++)if(l.getUint8(t)===255){if(i=l.getUint8(t+1),Se(i)){if(n=l.getUint16(t+2),r=ke(l,t,n),r&&d.has(r)&&(a=b.get(r),o=a.findPosition(l,t),h=g[r],o.type=r,this.appSegments.push(o),!u&&(a.multiSegment&&h.multiSegment?(this.unfinishedMultiSegment=o.chunkNumber<o.chunkCount,this.unfinishedMultiSegment||f.delete(r)):f.delete(r),f.size===0)))break;g.recordUnknownSegments&&(o=v.findPosition(l,t),o.marker=i,this.unknownSegments.push(o)),t+=n+1}else if(we(i)){if(n=l.getUint16(t+2),i===218&&g.stopAfterSos!==!1)return;g.recordJpegSegments&&this.jpegSegments.push({offset:t,length:n,marker:i}),t+=n+1}}return t}mergeMultiSegments(){if(!this.appSegments.some((e=>e.multiSegment)))return;let t=(function(e,i){let n,r,a,o=new Map;for(let h=0;h<e.length;h++)n=e[h],r=n[i],o.has(r)?a=o.get(r):o.set(r,a=[]),a.push(n);return Array.from(o)})(this.appSegments,"type");this.mergedAppSegments=t.map((([e,i])=>{let n=b.get(e,this.options);return n.handleMultiSegments?{type:e,chunk:n.handleMultiSegments(i)}:i[0]}))}getSegment(t){return this.appSegments.find((e=>e.type===t))}async getOrFindSegment(t){let e=this.getSegment(t);return e===void 0&&(await this.findAppSegments(0,[t]),e=this.getSegment(t)),e}};c(rt,"type","jpeg"),z.set("jpeg",rt);var xe=[void 0,1,1,2,4,8,1,1,2,4,8,4,8,4],xt=class extends v{parseHeader(){var t=this.chunk.getUint16();t===18761?this.le=!0:t===19789&&(this.le=!1),this.chunk.le=this.le,this.headerParsed=!0}parseTags(t,e,i=new Map){let{pick:n,skip:r}=this.options[e];n=new Set(n);let a=n.size>0,o=r.size===0,h=this.chunk.getUint16(t);t+=2;for(let l=0;l<h;l++){let u=this.chunk.getUint16(t);if(a){if(n.has(u)&&(i.set(u,this.parseTag(t,u,e)),n.delete(u),n.size===0))break}else!o&&r.has(u)||i.set(u,this.parseTag(t,u,e));t+=12}return i}parseTag(t,e,i){let{chunk:n}=this,r=n.getUint16(t+2),a=n.getUint32(t+4),o=xe[r];if(o*a<=4?t+=8:t=n.getUint32(t+8),(r<1||r>13)&&m(`Invalid TIFF value type. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${r}, offset ${t}`),t>n.byteLength&&m(`Invalid TIFF value offset. block: ${i.toUpperCase()}, tag: ${e.toString(16)}, type: ${r}, offset ${t} is outside of chunk size ${n.byteLength}`),r===1)return n.getUint8Array(t,a);if(r===2)return qt(n.getString(t,a));if(r===7)return n.getUint8Array(t,a);if(a===1)return this.parseTagValue(r,t);{let h=new((function(u){switch(u){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}})(r))(a),l=o;for(let u=0;u<a;u++)h[u]=this.parseTagValue(r,t),t+=l;return h}}parseTagValue(t,e){let{chunk:i}=this;switch(t){case 1:return i.getUint8(e);case 3:return i.getUint16(e);case 4:return i.getUint32(e);case 5:return i.getUint32(e)/i.getUint32(e+4);case 6:return i.getInt8(e);case 8:return i.getInt16(e);case 9:return i.getInt32(e);case 10:return i.getInt32(e)/i.getInt32(e+4);case 11:return i.getFloat(e);case 12:return i.getDouble(e);case 13:return i.getUint32(e);default:m(`Invalid tiff type ${t}`)}}},X=class extends xt{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1165519206&&t.getUint16(e+8)===0}async parse(){this.parseHeader();let{options:t}=this;return t.ifd0.enabled&&await this.parseIfd0Block(),t.exif.enabled&&await this.safeParse("parseExifBlock"),t.gps.enabled&&await this.safeParse("parseGpsBlock"),t.interop.enabled&&await this.safeParse("parseInteropBlock"),t.ifd1.enabled&&await this.safeParse("parseThumbnailBlock"),this.createOutput()}safeParse(t){let e=this[t]();return e.catch!==void 0&&(e=e.catch(this.handleError)),e}findIfd0Offset(){this.ifd0Offset===void 0&&(this.ifd0Offset=this.chunk.getUint32(4))}findIfd1Offset(){if(this.ifd1Offset===void 0){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;let{file:t}=this;this.findIfd0Offset(),this.ifd0Offset<8&&m("Malformed EXIF data"),!t.chunked&&this.ifd0Offset>t.byteLength&&m(`IFD0 offset points to outside of file.
2
2
  this.ifd0Offset: ${this.ifd0Offset}, file.byteLength: ${t.byteLength}`),t.tiff&&await t.ensureChunk(this.ifd0Offset,zt(this.options));let e=this.parseBlock(this.ifd0Offset,"ifd0");return e.size!==0?(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 parseExifBlock(){if(this.exif||(this.ifd0||await this.parseIfd0Block(),this.exifOffset===void 0))return;this.file.tiff&&await this.file.ensureChunk(this.exifOffset,zt(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&&i.length===1&&t.set(e,i[0])}async parseGpsBlock(){if(this.gps||(this.ifd0||await this.parseIfd0Block(),this.gpsOffset===void 0))return;let t=this.parseBlock(this.gpsOffset,"gps");return t&&t.has(2)&&t.has(4)&&(t.set("latitude",Ht(...t.get(2),t.get(1))),t.set("longitude",Ht(...t.get(4),t.get(3)))),t}async parseInteropBlock(){if(!this.interop&&(this.ifd0||await this.parseIfd0Block(),this.interopOffset!==void 0||this.exif||await this.parseExifBlock(),this.interopOffset!==void 0))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),this.ifd1===void 0)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,n={};for(e of p)if(t=this[e],!Yt(t))if(i=this.canTranslate?this.translateBlock(t,e):Object.fromEntries(t),this.options.mergeOutput){if(e==="ifd1")continue;Object.assign(n,i)}else n[e]=i;return this.makerNote&&(n.makerNote=this.makerNote),this.userComment&&(n.userComment=this.userComment),n}assignToOutput(t,e){if(this.globalOptions.mergeOutput)Object.assign(t,e);else for(let[i,n]of Object.entries(e))this.assignObjectToOutput(t,i,n)}};function Ht(s,t,e,i){var n=s+t/60+e/3600;return i!=="S"&&i!=="W"||(n*=-1),n}c(X,"type","tiff"),c(X,"headerLength",10),b.set("tiff",X);var ve=Object.freeze({__proto__:null,default:be,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I,parse:Mt}),Lt={ifd0:!1,ifd1:!1,exif:!1,gps:!1,interop:!1,sanitize:!1,reviveValues:!0,translateKeys:!1,translateValues:!1,mergeOutput:!1},Qt=Object.assign({},Lt,{firstChunkSize:4e4,gps:[1,2,3,4]});async function Ce(s){let t=new P(Qt);await t.read(s);let e=await t.parse();if(e&&e.gps){let{latitude:i,longitude:n}=e.gps;return{latitude:i,longitude:n}}}var te=Object.assign({},Lt,{tiff:!1,ifd1:!0,mergeOutput:!1});async function Oe(s){let t=new P(te);await t.read(s);let e=await t.extractThumbnail();return e&&Ut?It.from(e):e}async function Pe(s){let t=await this.thumbnail(s);if(t!==void 0){let e=new Blob([t]);return URL.createObjectURL(e)}}var ee=Object.assign({},Lt,{firstChunkSize:4e4,ifd0:[274]});async function ie(s){let t=new P(ee);await t.read(s);let e=await t.parse();if(e&&e.ifd0)return e.ifd0[274]}var se=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}}),R=!0,j=!0;if(typeof navigator=="object"){let s=navigator.userAgent;if(s.includes("iPad")||s.includes("iPhone")){let t=s.match(/OS (\d+)_(\d+)/);if(t){let[,e,i]=t;R=Number(e)+.1*Number(i)<13.4,j=!1}}else if(s.includes("OS X 10")){let[,t]=s.match(/OS X 10[_.](\d+)/);R=j=Number(t)<15}if(s.includes("Chrome/")){let[,t]=s.match(/Chrome\/(\d+)/);R=j=Number(t)<81}else if(s.includes("Firefox/")){let[,t]=s.match(/Firefox\/(\d+)/);R=j=Number(t)<77}}async function Ae(s){let t=await ie(s);return Object.assign({canvas:R,css:j},se[t])}var vt=class extends O{constructor(...t){super(...t),c(this,"ranges",new Ct),this.byteLength!==0&&this.ranges.add(0,this.byteLength)}_tryExtend(t,e,i){if(t===0&&this.byteLength===0&&i){let n=new DataView(i.buffer||i,i.byteOffset,i.byteLength);this._swapDataView(n)}else{let n=t+e;if(n>this.byteLength){let{dataView:r}=this._extend(n);this._swapDataView(r)}}}_extend(t){let e;e=Ut?It.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 n=super.set(t,e);return this.ranges.add(e,n.byteLength),n}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)}},Ct=class{constructor(){c(this,"list",[])}get length(){return this.list.length}add(t,e,i=0){let n=t+e,r=this.list.filter((a=>Wt(t,a.offset,n)||Wt(t,a.end,n)));if(r.length>0){t=Math.min(t,...r.map((o=>o.offset))),n=Math.max(n,...r.map((o=>o.end))),e=n-t;let a=r.shift();a.offset=t,a.length=e,a.end=n,this.list=this.list.filter((o=>!r.includes(o)))}else this.list.push({offset:t,length:e,end:n})}available(t,e){let i=t+e;return this.list.some((n=>n.offset<=t&&i<=n.end))}};function Wt(s,t,e){return s<=t&&t<=e}var at=class extends vt{constructor(t,e){super(0),c(this,"chunksRead",0),this.input=t,this.options=e}async readWhole(){this.chunked=!1,await this.readChunk(this.nextChunkOffset)}async readChunked(){this.chunked=!0,await this.readChunk(0,this.options.firstChunkSize)}async readNextChunk(t=this.nextChunkOffset){if(this.fullyRead)return this.chunksRead++,!1;let e=this.options.chunkSize,i=await this.readChunk(t,e);return!!i&&i.byteLength===e}async readChunk(t,e){if(this.chunksRead++,(e=this.safeWrapAddress(t,e))!==0)return this._readChunk(t,e)}safeWrapAddress(t,e){return this.size!==void 0&&t+e>this.size?Math.max(0,this.size-t):e}get nextChunkOffset(){if(this.ranges.list.length!==0)return this.ranges.list[0].length}get canReadNextChunk(){return this.chunksRead<this.options.chunkLimit}get fullyRead(){return this.size!==void 0&&this.nextChunkOffset===this.size}read(){return this.options.chunked?this.readChunked():this.readWhole()}close(){}};V.set("blob",class extends at{async readWhole(){this.chunked=!1;let s=await H(this.input);this._swapArrayBuffer(s)}readChunked(){return this.chunked=!0,this.size=this.input.size,super.readChunked()}async _readChunk(s,t){let e=t?s+t:void 0,i=this.input.slice(s,e),n=await H(i);return this.set(n,s,!0)}});var Ie=Object.freeze({__proto__:null,default:ve,Exifr:P,fileParsers:z,segmentParsers:b,fileReaders:V,tagKeys:C,tagValues:$,tagRevivers:N,createDictionary:k,extendDictionary:Bt,fetchUrlAsArrayBuffer:G,readBlobAsArrayBuffer:H,chunkedProps:D,otherSegments:J,segments:W,tiffBlocks:p,segmentsAndBlocks:F,tiffExtractables:T,inheritables:Q,allFormatters:E,Options:I,parse:Mt,gpsOnlyOptions:Qt,gps:Ce,thumbnailOnlyOptions:te,thumbnail:Oe,thumbnailUrl:Pe,orientationOnlyOptions:ee,orientation:ie,rotations:se,get rotateCanvas(){return R},get rotateCss(){return j},rotation:Ae});V.set("url",class extends at{async readWhole(){this.chunked=!1;let s=await G(this.input);s instanceof ArrayBuffer?this._swapArrayBuffer(s):s instanceof Uint8Array&&this._swapBuffer(s)}async _readChunk(s,t){let e=t?s+t-1:void 0,i=this.options.httpHeaders||{};(s||e)&&(i.range=`bytes=${[s,e].join("-")}`);let n=await Jt(this.input,{headers:i}),r=await n.arrayBuffer(),a=r.byteLength;if(n.status!==416)return a!==t&&(this.size=s+a),this.set(r,s,!0)}});O.prototype.getUint64=function(s){let t=this.getUint32(s),e=this.getUint32(s+4);return t<1048575?t<<32|e:typeof tt!==void 0?(console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."),tt(t)<<tt(32)|tt(e)):void m("Trying to read 64b value but JS can only handle 53b numbers.")};var Ot=class extends nt{parseBoxes(t=0){let e=[];for(;t<this.file.byteLength-4;){let i=this.parseBoxHead(t);if(e.push(i),i.length===0)break;t+=i.length}return e}parseSubBoxes(t){t.boxes=this.parseBoxes(t.start)}findBox(t,e){return t.boxes===void 0&&this.parseSubBoxes(t),t.boxes.find((i=>i.kind===e))}parseBoxHead(t){let e=this.file.getUint32(t),i=this.file.getString(t+4,4),n=t+8;return e===1&&(e=this.file.getUint64(t+8),n+=8),{offset:t,length:e,kind:i,start:n}}parseBoxFullHead(t){if(t.version!==void 0)return;let e=this.file.getUint32(t.start);t.version=e>>24,t.start+=4}},ot=class extends Ot{static canHandle(t,e){if(e!==0)return!1;let i=t.getUint16(2);if(i>50)return!1;let n=16,r=[];for(;n<i;)r.push(t.getString(n,4)),n+=4;return r.includes(this.type)}async parse(){let t=this.file.getUint32(0),e=this.parseBoxHead(t);for(;e.kind!=="meta";)t+=e.length,await this.file.ensureChunk(t,16),e=this.parseBoxHead(t);await this.file.ensureChunk(e.offset,e.length),this.parseBoxFullHead(e),this.parseSubBoxes(e),this.options.icc.enabled&&await this.findIcc(e),this.options.tiff.enabled&&await this.findExif(e)}async registerSegment(t,e,i){await this.file.ensureChunk(e,i);let n=this.file.subarray(e,i);this.createParser(t,n)}async findIcc(t){let e=this.findBox(t,"iprp");if(e===void 0)return;let i=this.findBox(e,"ipco");if(i===void 0)return;let n=this.findBox(i,"colr");n!==void 0&&await this.registerSegment("icc",n.offset+12,n.length)}async findExif(t){let e=this.findBox(t,"iinf");if(e===void 0)return;let i=this.findBox(t,"iloc");if(i===void 0)return;let n=this.findExifLocIdInIinf(e),r=this.findExtentInIloc(i,n);if(r===void 0)return;let[a,o]=r;await this.file.ensureChunk(a,o);let h=4+this.file.getUint32(a);a+=h,o-=h,await this.registerSegment("tiff",a,o)}findExifLocIdInIinf(t){this.parseBoxFullHead(t);let e,i,n,r,a=t.start,o=this.file.getUint16(a);for(a+=2;o--;){if(e=this.parseBoxHead(a),this.parseBoxFullHead(e),i=e.start,e.version>=2&&(n=e.version===3?4:2,r=this.file.getString(i+n+2,4),r==="Exif"))return this.file.getUintBytes(i,n);a+=e.length}}get8bits(t){let e=this.file.getUint8(t);return[e>>4,15&e]}findExtentInIloc(t,e){this.parseBoxFullHead(t);let i=t.start,[n,r]=this.get8bits(i++),[a,o]=this.get8bits(i++),h=t.version===2?4:2,l=t.version===1||t.version===2?2:0,u=o+n+r,d=t.version===2?4:2,f=this.file.getUintBytes(i,d);for(i+=d;f--;){let g=this.file.getUintBytes(i,h);i+=h+l+2+a;let S=this.file.getUint16(i);if(i+=2,g===e)return S>1&&console.warn(`ILOC box has more than one extent but we're only processing one
3
- Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+o,n),this.file.getUintBytes(i+o+n,r)];i+=S*u}}},ht=class extends ot{};c(ht,"type","heic");var lt=class extends ot{};c(lt,"type","avif"),z.set("heic",ht),z.set("avif",lt),k(C,["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"]]),k(C,"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"]]),k(C,"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"]]),k($,["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"}]]);var K=k($,"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"}]]),$t={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};K.set(37392,$t),K.set(41488,$t);var pt={0:"Normal",1:"Low",2:"High"};function _t(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Xt(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function mt(s){if(typeof s=="string"){var[t,e,i,n,r,a]=s.trim().split(/[-: ]/g).map(Number),o=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?s:o}}function _(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Kt(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Kt(s[e],s[e+1]));return qt(String.fromCodePoint(...t))}function Kt(s,t){return s<<8|t}K.set(41992,pt),K.set(41993,pt),K.set(41994,pt),k(N,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Zt(s):s}],[306,mt],[40091,_],[40092,_],[40093,_],[40094,_],[40095,_]]),k(N,"exif",[[40960,Xt],[36864,Xt],[36867,mt],[36868,mt],[40962,_t],[40963,_t]]),k(N,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var Y=class extends v{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:O.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(r){let a={},o={};for(let h of oe)a[h]=[],o[h]=0;return r.replace(Le,((h,l,u)=>{if(l==="<"){let d=++o[u];return a[u].push(d),`${h}#${d}`}return`${h}#${a[u].pop()}`}))})(t);let e=ft.findAll(t,"rdf","Description");e.length===0&&e.push(new ft("rdf","Description",void 0,t));let i,n={};for(let r of e)for(let a of r.properties)i=Me(a.ns,n),ne(a,i);return(function(r){let a;for(let o in r)a=r[o]=et(r[o]),a===void 0&&delete r[o];return et(r)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};c(Y,"type","xmp"),c(Y,"multiSegment",!0),b.set("xmp",Y);var Pt=class s{static findAll(t){return re(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=ae(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},ft=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return re(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],r=t[8];return new s(e,i,n,r)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=Pt.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?ae(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Be(this.children.map(Ue));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)ne(e,t);return this.value!==void 0&&(t.value=this.value),et(t)}};function ne(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var Ue=s=>s.serialize(),Be=s=>s.length===1?s[0]:s,Me=(s,t)=>t[s]?t[s]:t[s]={};function re(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function ae(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var oe=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],Le=new RegExp(`(<|\\/)(${oe.join("|")})`,"g"),he=Ie;async function Ve(s){try{return await he.parse(s)||null}catch{return null}}function Re(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function je(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let o=await s.arrayBuffer(),h=globalThis.Buffer,l=typeof h<"u"?h.from(o).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(o)));return`data:${s.type||"image/png"};base64,${l}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((o,h)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(s)});let r=document.createElement("canvas");r.width=Math.round(t.width*n),r.height=Math.round(t.height*n),r.getContext("2d").drawImage(t,0,0,r.width,r.height),t.close();let a=s.type==="image/png"?"image/png":"image/jpeg";return r.toDataURL(a,a==="image/png"?void 0:.82)}function le(s,t=21,e=.2,i=128){let{data:n,width:r,height:a}=s,o=r+1,h=new Float64Array((r+1)*(a+1)),l=new Float64Array((r+1)*(a+1)),u=new Uint8Array(r*a);for(let f=0;f<a;f++){let g=0,S=0,U=f*r,B=(f+1)*o,A=f*o;for(let w=0;w<r;w++){let x=(U+w)*4,M=n[x]*77+n[x+1]*150+n[x+2]*29>>8;u[U+w]=M,g+=M,S+=M*M,h[B+w+1]=h[A+w+1]+g,l[B+w+1]=l[A+w+1]+S}}let d=Math.floor(t/2);for(let f=0;f<a;f++){let g=Math.max(0,f-d),S=Math.min(a-1,f+d),U=g*o,B=(S+1)*o;for(let A=0;A<r;A++){let w=Math.max(0,A-d),x=Math.min(r-1,A+d),M=(x-w+1)*(S-g+1),ue=h[B+x+1]-h[U+x+1]-h[B+w]+h[U+w],de=l[B+x+1]-l[U+x+1]-l[B+w]+l[U+w],ut=ue/M,ce=Math.max(0,de/M-ut*ut),ge=Math.sqrt(ce),pe=ut*(1+e*(ge/i-1)),Tt=f*r+A,dt=u[Tt]<pe?0:255,ct=Tt*4;n[ct]=dt,n[ct+1]=dt,n[ct+2]=dt}}return s}function Ge(s,t=21,e=.2,i=128){return new Promise(n=>{let r=new Image;r.onload=()=>{let a=document.createElement("canvas");a.width=r.width,a.height=r.height;let o=a.getContext("2d");o.drawImage(r,0,0);let h=o.getImageData(0,0,a.width,a.height);le(h,t,e,i),o.putImageData(h,0,0);let l=s.startsWith("data:image/png"),u=l?"image/png":"image/jpeg";n(a.toDataURL(u,l?void 0:.82))},r.src=s})}function He(s){return new Promise(t=>{let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=e.height,i.height=e.width;let n=i.getContext("2d");n.translate(i.width/2,i.height/2),n.rotate(Math.PI/2),n.drawImage(e,-e.width/2,-e.height/2);let r=s.startsWith("data:image/png"),a=r?"image/png":"image/jpeg";t(i.toDataURL(a,r?void 0:.82))},e.src=s})}function We(s,t=""){if(!s)return"";let e=s.getCroppedCanvas(),i=t.startsWith("data:image/png"),n=i?"image/png":"image/jpeg";return e.toDataURL(n,i?void 0:.82)}function Dt(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=null;s.crop&&typeof s.crop=="object"&&(s.crop.width>0&&s.crop.height>0?t={x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:s.crop.w>0&&s.crop.h>0&&(t={x:Number(s.crop.x)||0,y:Number(s.crop.y)||0,w:Number(s.crop.w)||1,h:Number(s.crop.h)||1}));let e=s.rotation!==void 0?s.rotation:s.rotate,i=(Math.round(Number(e)||0)%360+360)%360,n=s.filter==="bw"?"bw":"none";return{crop:t,rotation:i,filter:n}}function De(s){if(!s)return!1;let t=Dt(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function Ft(s,t){let e=Dt(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,r=document.createElement("canvas"),a=i,o=n,h=0,l=0;if(e.crop){let f=e.crop;"w"in f&&!("width"in f)?(h=Math.max(0,Math.min(Math.round(f.x*i),i)),l=Math.max(0,Math.min(Math.round(f.y*n),n)),a=Math.max(1,Math.min(Math.round(f.w*i),i-h)),o=Math.max(1,Math.min(Math.round(f.h*n),n-l))):(h=Math.max(0,Math.min(f.x,i)),l=Math.max(0,Math.min(f.y,n)),a=Math.max(1,Math.min(f.width,i-h)),o=Math.max(1,Math.min(f.height,n-l)))}r.width=a,r.height=o,r.getContext("2d").drawImage(s,h,l,a,o,0,0,a,o);let d=r;if(e.rotation!==0){let f=e.rotation,g=document.createElement("canvas");f===90||f===270?(g.width=d.height,g.height=d.width):(g.width=d.width,g.height=d.height);let S=g.getContext("2d");S.translate(g.width/2,g.height/2),S.rotate(f*Math.PI/180),S.drawImage(d,-d.width/2,-d.height/2),d=g}if(e.filter==="bw"){let f=d.getContext("2d"),g=f.getImageData(0,0,d.width,d.height);le(g),f.putImageData(g,0,0)}return d}function $e(s,t){if(!s)return Promise.resolve("");let e=Dt(t);return De(e)?new Promise((i,n)=>{let r=new Image;r.onload=()=>{try{let a=s.startsWith("data:image/png"),o=a?"image/png":"image/jpeg",h=Ft(r,e);i(h.toDataURL(o,a?void 0:.82))}catch(a){n(a)}},r.onerror=n,r.src=s}):Promise.resolve(s)}function Fe(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var fe=class extends Et{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await Fe(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),Ft(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};export{Ve as a,Re as b,je as c,le as d,Ge as e,He as f,We as g,Dt as h,De as i,Ft as j,$e as k,fe as l};
4
- //# sourceMappingURL=chunk-534NMCRQ.js.map
3
+ Please create an issue at https://github.com/MikeKovarik/exifr with this file`),[this.file.getUintBytes(i+o,n),this.file.getUintBytes(i+o+n,r)];i+=S*u}}},ht=class extends ot{};c(ht,"type","heic");var lt=class extends ot{};c(lt,"type","avif"),z.set("heic",ht),z.set("avif",lt),k(C,["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"]]),k(C,"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"]]),k(C,"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"]]),k($,["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"}]]);var K=k($,"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"}]]),$t={1:"No absolute unit of measurement",2:"Inch",3:"Centimeter"};K.set(37392,$t),K.set(41488,$t);var pt={0:"Normal",1:"Low",2:"High"};function _t(s){return typeof s=="object"&&s.length!==void 0?s[0]:s}function Xt(s){let t=Array.from(s).slice(1);return t[1]>15&&(t=t.map((e=>String.fromCharCode(e)))),t[2]!=="0"&&t[2]!==0||t.pop(),t.join(".")}function mt(s){if(typeof s=="string"){var[t,e,i,n,r,a]=s.trim().split(/[-: ]/g).map(Number),o=new Date(t,e-1,i);return Number.isNaN(n)||Number.isNaN(r)||Number.isNaN(a)||(o.setHours(n),o.setMinutes(r),o.setSeconds(a)),Number.isNaN(+o)?s:o}}function _(s){if(typeof s=="string")return s;let t=[];if(s[1]===0&&s[s.length-1]===0)for(let e=0;e<s.length;e+=2)t.push(Kt(s[e+1],s[e]));else for(let e=0;e<s.length;e+=2)t.push(Kt(s[e],s[e+1]));return qt(String.fromCodePoint(...t))}function Kt(s,t){return s<<8|t}K.set(41992,pt),K.set(41993,pt),K.set(41994,pt),k(N,["ifd0","ifd1"],[[50827,function(s){return typeof s!="string"?Zt(s):s}],[306,mt],[40091,_],[40092,_],[40093,_],[40094,_],[40095,_]]),k(N,"exif",[[40960,Xt],[36864,Xt],[36867,mt],[36868,mt],[40962,_t],[40963,_t]]),k(N,"gps",[[0,s=>Array.from(s).join(".")],[7,s=>Array.from(s).join(":")]]);var Y=class extends v{static canHandle(t,e){return t.getUint8(e+1)===225&&t.getUint32(e+4)===1752462448&&t.getString(e+4,20)==="http://ns.adobe.com/"}static headerLength(t,e){return t.getString(e+4,34)==="http://ns.adobe.com/xmp/extension/"?79:33}static findPosition(t,e){let i=super.findPosition(t,e);return i.multiSegment=i.extended=i.headerLength===79,i.multiSegment?(i.chunkCount=t.getUint8(e+72),i.chunkNumber=t.getUint8(e+76),t.getUint8(e+77)!==0&&i.chunkNumber++):(i.chunkCount=1/0,i.chunkNumber=-1),i}static handleMultiSegments(t){return t.map((e=>e.chunk.getString())).join("")}normalizeInput(t){return typeof t=="string"?t:O.from(t).getString()}parse(t=this.chunk){if(!this.localOptions.parse)return t;t=(function(r){let a={},o={};for(let h of oe)a[h]=[],o[h]=0;return r.replace(Le,((h,l,u)=>{if(l==="<"){let d=++o[u];return a[u].push(d),`${h}#${d}`}return`${h}#${a[u].pop()}`}))})(t);let e=ft.findAll(t,"rdf","Description");e.length===0&&e.push(new ft("rdf","Description",void 0,t));let i,n={};for(let r of e)for(let a of r.properties)i=Me(a.ns,n),ne(a,i);return(function(r){let a;for(let o in r)a=r[o]=et(r[o]),a===void 0&&delete r[o];return et(r)})(n)}assignToOutput(t,e){if(this.localOptions.parse)for(let[i,n]of Object.entries(e))switch(i){case"tiff":this.assignObjectToOutput(t,"ifd0",n);break;case"exif":this.assignObjectToOutput(t,"exif",n);break;case"xmlns":break;default:this.assignObjectToOutput(t,i,n)}else t.xmp=e}};c(Y,"type","xmp"),c(Y,"multiSegment",!0),b.set("xmp",Y);var Pt=class s{static findAll(t){return re(t,/([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[3].slice(1,-1);return n=ae(n),new s(e,i,n)}constructor(t,e,i){this.ns=t,this.name=e,this.value=i}serialize(){return this.value}},ft=class s{static findAll(t,e,i){if(e!==void 0||i!==void 0){e=e||"[\\w\\d-]+",i=i||"[\\w\\d-]+";var n=new RegExp(`<(${e}):(${i})(#\\d+)?((\\s+?[\\w\\d-:]+=("[^"]*"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)`,"gm")}else n=/<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;return re(t,n).map(s.unpackMatch)}static unpackMatch(t){let e=t[1],i=t[2],n=t[4],r=t[8];return new s(e,i,n,r)}constructor(t,e,i,n){this.ns=t,this.name=e,this.attrString=i,this.innerXml=n,this.attrs=Pt.findAll(i),this.children=s.findAll(n),this.value=this.children.length===0?ae(n):void 0,this.properties=[...this.attrs,...this.children]}get isPrimitive(){return this.value!==void 0&&this.attrs.length===0&&this.children.length===0}get isListContainer(){return this.children.length===1&&this.children[0].isList}get isList(){let{ns:t,name:e}=this;return t==="rdf"&&(e==="Seq"||e==="Bag"||e==="Alt")}get isListItem(){return this.ns==="rdf"&&this.name==="li"}serialize(){if(this.properties.length===0&&this.value===void 0)return;if(this.isPrimitive)return this.value;if(this.isListContainer)return this.children[0].serialize();if(this.isList)return Be(this.children.map(Ue));if(this.isListItem&&this.children.length===1&&this.attrs.length===0)return this.children[0].serialize();let t={};for(let e of this.properties)ne(e,t);return this.value!==void 0&&(t.value=this.value),et(t)}};function ne(s,t){let e=s.serialize();e!==void 0&&(t[s.name]=e)}var Ue=s=>s.serialize(),Be=s=>s.length===1?s[0]:s,Me=(s,t)=>t[s]?t[s]:t[s]={};function re(s,t){let e,i=[];if(!s)return i;for(;(e=t.exec(s))!==null;)i.push(e);return i}function ae(s){if((function(i){return i==null||i==="null"||i==="undefined"||i===""||i.trim()===""})(s))return;let t=Number(s);if(!Number.isNaN(t))return t;let e=s.toLowerCase();return e==="true"||e!=="false"&&s.trim()}var oe=["rdf:li","rdf:Seq","rdf:Bag","rdf:Alt","rdf:Description"],Le=new RegExp(`(<|\\/)(${oe.join("|")})`,"g"),he=Ie;async function Ve(s){try{return await he.parse(s)||null}catch{return null}}function Re(){return Array.from(crypto.getRandomValues(new Uint8Array(16)),s=>s.toString(16).padStart(2,"0")).join("")}async function je(s){if(typeof createImageBitmap>"u"||typeof document>"u"){if(s&&typeof s.arrayBuffer=="function"){let o=await s.arrayBuffer(),h=globalThis.Buffer,l=typeof h<"u"?h.from(o).toString("base64"):btoa(String.fromCharCode(...new Uint8Array(o)));return`data:${s.type||"image/png"};base64,${l}`}if(typeof s=="string")return s}let t=await createImageBitmap(s),n=Math.min(1,1654/t.width,2339/t.height);if(n===1&&(s.type==="image/jpeg"||s.type==="image/jpg"||s.type==="image/png"||s.type==="image/webp"))return t.close(),new Promise((o,h)=>{let l=new FileReader;l.onload=()=>o(l.result),l.onerror=h,l.readAsDataURL(s)});let r=document.createElement("canvas");r.width=Math.round(t.width*n),r.height=Math.round(t.height*n),r.getContext("2d").drawImage(t,0,0,r.width,r.height),t.close();let a=s.type==="image/png"?"image/png":"image/jpeg";return r.toDataURL(a,a==="image/png"?void 0:.82)}function le(s,t=21,e=.2,i=128){let{data:n,width:r,height:a}=s,o=r+1,h=new Float64Array((r+1)*(a+1)),l=new Float64Array((r+1)*(a+1)),u=new Uint8Array(r*a);for(let f=0;f<a;f++){let g=0,S=0,U=f*r,B=(f+1)*o,A=f*o;for(let w=0;w<r;w++){let x=(U+w)*4,M=n[x]*77+n[x+1]*150+n[x+2]*29>>8;u[U+w]=M,g+=M,S+=M*M,h[B+w+1]=h[A+w+1]+g,l[B+w+1]=l[A+w+1]+S}}let d=Math.floor(t/2);for(let f=0;f<a;f++){let g=Math.max(0,f-d),S=Math.min(a-1,f+d),U=g*o,B=(S+1)*o;for(let A=0;A<r;A++){let w=Math.max(0,A-d),x=Math.min(r-1,A+d),M=(x-w+1)*(S-g+1),ue=h[B+x+1]-h[U+x+1]-h[B+w]+h[U+w],de=l[B+x+1]-l[U+x+1]-l[B+w]+l[U+w],ut=ue/M,ce=Math.max(0,de/M-ut*ut),ge=Math.sqrt(ce),pe=ut*(1+e*(ge/i-1)),Tt=f*r+A,dt=u[Tt]<pe?0:255,ct=Tt*4;n[ct]=dt,n[ct+1]=dt,n[ct+2]=dt}}return s}function Ge(s,t=21,e=.2,i=128){return new Promise(n=>{let r=new Image;r.onload=()=>{let a=document.createElement("canvas");a.width=r.width,a.height=r.height;let o=a.getContext("2d");o.drawImage(r,0,0);let h=o.getImageData(0,0,a.width,a.height);le(h,t,e,i),o.putImageData(h,0,0);let l=s.startsWith("data:image/png"),u=l?"image/png":"image/jpeg";n(a.toDataURL(u,l?void 0:.82))},r.src=s})}function He(s){return new Promise(t=>{let e=new Image;e.onload=()=>{let i=document.createElement("canvas");i.width=e.height,i.height=e.width;let n=i.getContext("2d");n.translate(i.width/2,i.height/2),n.rotate(Math.PI/2),n.drawImage(e,-e.width/2,-e.height/2);let r=s.startsWith("data:image/png"),a=r?"image/png":"image/jpeg";t(i.toDataURL(a,r?void 0:.82))},e.src=s})}function We(s,t=""){if(!s)return"";let e=s.getCroppedCanvas(),i=t.startsWith("data:image/png"),n=i?"image/png":"image/jpeg";return e.toDataURL(n,i?void 0:.82)}function Dt(s){if(!s||typeof s!="object")return{crop:null,rotation:0,filter:"none"};let t=null;s.crop&&typeof s.crop=="object"&&(s.crop.width>0&&s.crop.height>0?t={x:Math.round(s.crop.x||0),y:Math.round(s.crop.y||0),width:Math.round(s.crop.width),height:Math.round(s.crop.height)}:s.crop.w>0&&s.crop.h>0&&(t={x:Number(s.crop.x)||0,y:Number(s.crop.y)||0,w:Number(s.crop.w)||1,h:Number(s.crop.h)||1}));let e=s.rotation!==void 0?s.rotation:s.rotate,i=(Math.round(Number(e)||0)%360+360)%360,n=s.filter==="bw"?"bw":"none";return{crop:t,rotation:i,filter:n}}function De(s){if(!s)return!1;let t=Dt(s);return!!(t.crop||t.rotation!==0||t.filter!=="none")}function Ft(s,t){let e=Dt(t),i=s.naturalWidth||s.width||0,n=s.naturalHeight||s.height||0,r=document.createElement("canvas"),a=i,o=n,h=0,l=0;if(e.crop){let f=e.crop;"w"in f&&!("width"in f)?(h=Math.max(0,Math.min(Math.round(f.x*i),i)),l=Math.max(0,Math.min(Math.round(f.y*n),n)),a=Math.max(1,Math.min(Math.round(f.w*i),i-h)),o=Math.max(1,Math.min(Math.round(f.h*n),n-l))):(h=Math.max(0,Math.min(f.x,i)),l=Math.max(0,Math.min(f.y,n)),a=Math.max(1,Math.min(f.width,i-h)),o=Math.max(1,Math.min(f.height,n-l)))}r.width=a,r.height=o,r.getContext("2d").drawImage(s,h,l,a,o,0,0,a,o);let d=r;if(e.rotation!==0){let f=e.rotation,g=document.createElement("canvas");f===90||f===270?(g.width=d.height,g.height=d.width):(g.width=d.width,g.height=d.height);let S=g.getContext("2d");S.translate(g.width/2,g.height/2),S.rotate(f*Math.PI/180),S.drawImage(d,-d.width/2,-d.height/2),d=g}if(e.filter==="bw"){let f=d.getContext("2d"),g=f.getImageData(0,0,d.width,d.height);le(g),f.putImageData(g,0,0)}return d}function $e(s,t){if(!s)return Promise.resolve("");let e=Dt(t);return De(e)?new Promise((i,n)=>{let r=new Image;r.onload=()=>{try{let a=s.startsWith("data:image/png"),o=a?"image/png":"image/jpeg",h=Ft(r,e);i(h.toDataURL(o,a?void 0:.82))}catch(a){n(a)}},r.onerror=n,r.src=s}):Promise.resolve(s)}function Fe(s){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=e,i.src=s})}var fe=class extends Et{async renderEdits(t,e={}){if(!t)return"";if(typeof document>"u")return t;try{let i=await Fe(t),n={...e};return e?.crop&&"w"in e.crop&&(n.crop={x:Math.round((e.crop.x||0)*i.naturalWidth),y:Math.round((e.crop.y||0)*i.naturalHeight),width:Math.round((e.crop.w||1)*i.naturalWidth),height:Math.round((e.crop.h||1)*i.naturalHeight)}),e?.rotate!==void 0&&(n.rotation=e.rotate),Ft(i,n).toDataURL("image/jpeg",.92)}catch{return t}}async crop(t,e){return this.renderEdits(t,{crop:e})}async rotate(t,e){return this.renderEdits(t,{rotate:e})}async applyFilter(t,e){return this.renderEdits(t,{filter:e})}};export{Ve as a,Re as b,je as c,le as d,Ge as e,He as f,We as g,Dt as h,Ft as i,$e as j,fe as k};
4
+ //# sourceMappingURL=chunk-G5EUMLYT.js.map