UNPKG

dicom-microscopy-viewer-changed

Version:
1 lines 235 kB
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).GeoTIFF={})}(this,(function(e){"use strict";function t(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function r(e){if(Array.isArray(e))return e}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}}function a(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function o(e,t){return r(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,i,a=[],o=!0,s=!1;try{for(r=r.call(e);!(o=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);o=!0);}catch(e){s=!0,i=e}finally{try{o||null==r.return||r.return()}finally{if(s)throw i}}return a}}(e,t)||i(e,t)||a()}function s(e,t,r,n,i,a,o){try{var s=e[a](o),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var a=e.apply(t,r);function o(e){s(a,n,i,o,u,"next",e)}function u(e){s(a,n,i,o,u,"throw",e)}o(void 0)}))}}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function c(e,t,r){return t&&f(e.prototype,t),r&&f(e,r),e}function l(e,t){return l=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},l(e,t)}function h(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&l(e,t)}function d(e){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},d(e)}function p(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function m(e,t){if(t&&("object"===d(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return p(e)}function v(e){return v=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},v(e)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function g(e,t,r){return g=y()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&l(i,r.prototype),i},g.apply(null,arguments)}function w(e){var t="function"==typeof Map?new Map:void 0;return w=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return g(e,arguments,v(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),l(n,e)},w(e)}function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var k={exports:{}};!function(e){var t=function(e){var t,r=Object.prototype,n=r.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",o=i.asyncIterator||"@@asyncIterator",s=i.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var i=t&&t.prototype instanceof y?t:y,a=Object.create(i.prototype),o=new U(n||[]);return a._invoke=function(e,t,r){var n=l;return function(i,a){if(n===p)throw new Error("Generator is already running");if(n===m){if("throw"===i)throw a;return D()}for(r.method=i,r.arg=a;;){var o=r.delegate;if(o){var s=P(o,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===l)throw n=m,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var u=c(e,t,r);if("normal"===u.type){if(n=r.done?m:h,u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=m,r.method="throw",r.arg=u.arg)}}}(e,r,o),a}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=f;var l="suspendedStart",h="suspendedYield",p="executing",m="completed",v={};function y(){}function g(){}function w(){}var b={};u(b,a,(function(){return this}));var k=Object.getPrototypeOf,x=k&&k(k(O([])));x&&x!==r&&n.call(x,a)&&(b=x);var A=w.prototype=y.prototype=Object.create(b);function _(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function I(e,t){function r(i,a,o,s){var u=c(e[i],e,a);if("throw"!==u.type){var f=u.arg,l=f.value;return l&&"object"===d(l)&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,o,s)}),(function(e){r("throw",e,o,s)})):t.resolve(l).then((function(e){f.value=e,o(f)}),(function(e){return r("throw",e,o,s)}))}s(u.arg)}var i;this._invoke=function(e,n){function a(){return new t((function(t,i){r(e,n,t,i)}))}return i=i?i.then(a,a):a()}}function P(e,r){var n=e.iterator[r.method];if(n===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method))return v;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var i=c(n,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,v;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function S(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function T(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function U(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(S,this),this.reset(!0)}function O(e){if(e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}return{next:D}}function D(){return{value:t,done:!0}}return g.prototype=w,u(A,"constructor",w),u(w,"constructor",g),g.displayName=u(w,s,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,w):(e.__proto__=w,u(e,s,"GeneratorFunction")),e.prototype=Object.create(A),e},e.awrap=function(e){return{__await:e}},_(I.prototype),u(I.prototype,o,(function(){return this})),e.AsyncIterator=I,e.async=function(t,r,n,i,a){void 0===a&&(a=Promise);var o=new I(f(t,r,n,i),a);return e.isGeneratorFunction(r)?o:o.next().then((function(e){return e.done?e.value:o.next()}))},_(A),u(A,s,"Generator"),u(A,a,(function(){return this})),u(A,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,U.prototype={constructor:U,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(T),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var a=this.tryEntries.length-1;a>=0;--a){var o=this.tryEntries[a],s=o.completion;if("root"===o.tryLoc)return i("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),f=n.call(o,"finallyLoc");if(u&&f){if(this.prev<o.catchLoc)return i(o.catchLoc,!0);if(this.prev<o.finallyLoc)return i(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return i(o.catchLoc,!0)}else{if(!f)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return i(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var a=i;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=t,a?(this.method="next",this.next=a.finallyLoc,v):this.complete(o)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),T(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;T(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:O(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),v}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"===("undefined"==typeof globalThis?"undefined":d(globalThis))?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(k);for(var x=k.exports,A=new ArrayBuffer(4),_=new Float32Array(A),I=new Uint32Array(A),P=new Uint32Array(512),S=new Uint32Array(512),T=0;T<256;++T){var U=T-127;U<-27?(P[T]=0,P[256|T]=32768,S[T]=24,S[256|T]=24):U<-14?(P[T]=1024>>-U-14,P[256|T]=1024>>-U-14|32768,S[T]=-U-1,S[256|T]=-U-1):U<=15?(P[T]=U+15<<10,P[256|T]=U+15<<10|32768,S[T]=13,S[256|T]=13):U<128?(P[T]=31744,P[256|T]=64512,S[T]=24,S[256|T]=24):(P[T]=31744,P[256|T]=64512,S[T]=13,S[256|T]=13)}var O=new Uint32Array(2048),D=new Uint32Array(64),E=new Uint32Array(64);O[0]=0;for(var R=1;R<1024;++R){for(var M=R<<13,B=0;0==(8388608&M);)B-=8388608,M<<=1;M&=-8388609,B+=947912704,O[R]=M|B}for(var C=1024;C<2048;++C)O[C]=939524096+(C-1024<<13);D[0]=0;for(var L=1;L<31;++L)D[L]=L<<23;D[31]=1199570944,D[32]=2147483648;for(var F=33;F<63;++F)D[F]=2147483648+(F-32<<23);D[63]=3347054592,E[0]=0;for(var V=1;V<64;++V)E[V]=32===V?0:1024;function G(e){var t=e>>10;return I[0]=O[E[t]+(1023&e)]+D[t],_[0]}function j(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function z(e){return function(e){if(Array.isArray(e))return n(e)}(e)||j(e)||i(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var N=Reflect.getPrototypeOf(Uint8Array).prototype,K=Reflect.getOwnPropertyDescriptor(N,Symbol.toStringTag).get;var Z=Object.prototype.toString;function H(e){return!!ArrayBuffer.isView(e)&&(!function(e){return void 0!==K.call(e)}(e)&&"[object DataView]"===Z.call(e))}function Y(e,t){if(!H(e))throw new TypeError("First argument to getFloat16 function must be a DataView");for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return G(e.getUint16.apply(e,[t].concat(n)))}var q=function(e,t,r){var n=r&&r.debug||!1;n&&console.log("getting "+t+" in "+e);var i="object"===d(e)?e.outer:e,a="".concat(t,'\\="([^"]*)"');n&&console.log("pattern:",a);var o=new RegExp(a).exec(i);if(n&&console.log("match:",o),o)return o[1]};var X=function(e,t,r){var n=new RegExp(t).exec(e.slice(r));return n?r+n.index:-1};var W=function(e,t,r){var n=r&&r.debug||!1,i=r&&r.startIndex||0;n&&console.log("starting findTagByName with",t," and ",r);var a=X(e,"<".concat(t,"[ >]"),i);if(n&&console.log("start:",a),-1!==a){var o=e.slice(a+t.length),s=X(o,"[ /]"+t+">",0),u=-1===s;u&&(s=X(o,"[ /]>",0));var f=a+t.length+s+1+(u?0:t.length)+1;if(n&&console.log("end:",f),-1!==f){var c=e.slice(a,f);return{inner:u?null:c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),outer:c,start:a,end:f}}}};var J=function(e,t,r){for(var n,i=[],a=r&&r.debug||!1,o=r&&r.startIndex||0;n=W(e,t,{debug:a,startIndex:o});)o=n.end,i.push(n);return a&&console.log("findTagsByName found",i.length,"tags"),i},Q={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},$={};for(var ee in Q)Q.hasOwnProperty(ee)&&($[Q[ee]]=parseInt(ee,10));var te={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34665:"LONG",34735:"SHORT",34737:"ASCII",42113:"ASCII"},re=[$.BitsPerSample,$.ExtraSamples,$.SampleFormat,$.StripByteCounts,$.StripOffsets,$.StripRowCounts,$.TileByteCounts,$.TileOffsets,$.SubIFDs],ne={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},ie={};for(var ae in ne)ne.hasOwnProperty(ae)&&(ie[ne[ae]]=parseInt(ae,10));var oe={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},se={Unspecified:0,Assocalpha:1,Unassalpha:2},ue={Version:0,AddCompression:1},fe={None:0,Deflate:1},ce={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},le={};for(var he in ce)ce.hasOwnProperty(he)&&(le[ce[he]]=parseInt(he,10));var de=Object.freeze({__proto__:null,fieldTagNames:Q,fieldTags:$,fieldTagTypes:te,arrayFields:re,fieldTypeNames:ne,fieldTypes:ie,photometricInterpretations:oe,ExtraSamplesValues:se,LercParameters:ue,LercAddCompression:fe,geoKeyNames:ce,geoKeys:le});function pe(e,t){for(var r,n=e.width,i=e.height,a=new Uint8Array(n*i*3),o=0,s=0;o<e.length;++o,s+=3)r=256-e[o]/t*256,a[s]=r,a[s+1]=r,a[s+2]=r;return a}function me(e,t){for(var r,n=e.width,i=e.height,a=new Uint8Array(n*i*3),o=0,s=0;o<e.length;++o,s+=3)r=e[o]/t*256,a[s]=r,a[s+1]=r,a[s+2]=r;return a}function ve(e,t){for(var r=e.width,n=e.height,i=new Uint8Array(r*n*3),a=t.length/3,o=t.length/3*2,s=0,u=0;s<e.length;++s,u+=3){var f=e[s];i[u]=t[f]/65536*256,i[u+1]=t[f+a]/65536*256,i[u+2]=t[f+o]/65536*256}return i}function ye(e){for(var t=e.width,r=e.height,n=new Uint8Array(t*r*3),i=0,a=0;i<e.length;i+=4,a+=3){var o=e[i],s=e[i+1],u=e[i+2],f=e[i+3];n[a]=(255-o)/256*255*((255-f)/256),n[a+1]=(255-s)/256*255*((255-f)/256),n[a+2]=(255-u)/256*255*((255-f)/256)}return n}function ge(e){for(var t=e.width,r=e.height,n=new Uint8ClampedArray(t*r*3),i=0,a=0;i<e.length;i+=3,a+=3){var o=e[i],s=e[i+1],u=e[i+2];n[a]=o+1.402*(u-128),n[a+1]=o-.34414*(s-128)-.71414*(u-128),n[a+2]=o+1.772*(s-128)}return n}function we(e){for(var t=e.width,r=e.height,n=new Uint8Array(t*r*3),i=0,a=0;i<e.length;i+=3,a+=3){var o=(e[i+0]+16)/116,s=(e[i+1]<<24>>24)/500+o,u=o-(e[i+2]<<24>>24)/200,f=void 0,c=void 0,l=void 0;c=-.9689*(s=.95047*(s*s*s>.008856?s*s*s:(s-16/116)/7.787))+1.8758*(o=1*(o*o*o>.008856?o*o*o:(o-16/116)/7.787))+.0415*(u=1.08883*(u*u*u>.008856?u*u*u:(u-16/116)/7.787)),l=.0557*s+-.204*o+1.057*u,f=(f=3.2406*s+-1.5372*o+-.4986*u)>.0031308?1.055*Math.pow(f,1/2.4)-.055:12.92*f,c=c>.0031308?1.055*Math.pow(c,1/2.4)-.055:12.92*c,l=l>.0031308?1.055*Math.pow(l,1/2.4)-.055:12.92*l,n[a]=255*Math.max(0,Math.min(1,f)),n[a+1]=255*Math.max(0,Math.min(1,c)),n[a+2]=255*Math.max(0,Math.min(1,l))}return n}var be=Object.freeze({__proto__:null,fromWhiteIsZero:pe,fromBlackIsZero:me,fromPalette:ve,fromCMYK:ye,fromYCbCr:ge,fromCIELab:we}),ke=new Map;function xe(e,t){Array.isArray(e)||(e=[e]),e.forEach((function(e){return ke.set(e,t)}))}function Ae(e){return _e.apply(this,arguments)}function _e(){return(_e=u(x.mark((function e(t){var r,n;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=ke.get(t.Compression)){e.next=3;break}throw new Error("Unknown compression method identifier: ".concat(t.Compression));case 3:return e.next=5,r();case 5:return n=e.sent,e.abrupt("return",new n(t));case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Ie(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1;return new(Object.getPrototypeOf(e).constructor)(t*r*n)}function Pe(e,t,r,n,i){var a=t/n,o=r/i;return e.map((function(e){for(var s=Ie(e,n,i),u=0;u<i;++u)for(var f=Math.min(Math.round(o*u),r-1),c=0;c<n;++c){var l=Math.min(Math.round(a*c),t-1),h=e[f*t+l];s[u*n+c]=h}return s}))}function Se(e,t,r){return(1-r)*e+r*t}function Te(e,t,r,n,i){var a=t/n,o=r/i;return e.map((function(e){for(var s=Ie(e,n,i),u=0;u<i;++u)for(var f=o*u,c=Math.floor(f),l=Math.min(Math.ceil(f),r-1),h=0;h<n;++h){var d=a*h,p=d%1,m=Math.floor(d),v=Math.min(Math.ceil(d),t-1),y=e[c*t+m],g=e[c*t+v],w=e[l*t+m],b=e[l*t+v],k=Se(Se(y,g,p),Se(w,b,p),f%1);s[u*n+h]=k}return s}))}function Ue(e,t,r,n,i){var a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:"nearest";switch(a.toLowerCase()){case"nearest":return Pe(e,t,r,n,i);case"bilinear":case"linear":return Te(e,t,r,n,i);default:throw new Error("Unsupported resampling method: '".concat(a,"'"))}}function Oe(e,t,r,n,i,a){for(var o=t/n,s=r/i,u=Ie(e,n,i,a),f=0;f<i;++f)for(var c=Math.min(Math.round(s*f),r-1),l=0;l<n;++l)for(var h=Math.min(Math.round(o*l),t-1),d=0;d<a;++d){var p=e[c*t*a+h*a+d];u[f*n*a+l*a+d]=p}return u}function De(e,t,r,n,i,a){for(var o=t/n,s=r/i,u=Ie(e,n,i,a),f=0;f<i;++f)for(var c=s*f,l=Math.floor(c),h=Math.min(Math.ceil(c),r-1),d=0;d<n;++d)for(var p=o*d,m=p%1,v=Math.floor(p),y=Math.min(Math.ceil(p),t-1),g=0;g<a;++g){var w=e[l*t*a+v*a+g],b=e[l*t*a+y*a+g],k=e[h*t*a+v*a+g],x=e[h*t*a+y*a+g],A=Se(Se(w,b,m),Se(k,x,m),c%1);u[f*n*a+d*a+g]=A}return u}function Ee(e,t,r,n,i,a){var o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:"nearest";switch(o.toLowerCase()){case"nearest":return Oe(e,t,r,n,i,a);case"bilinear":case"linear":return De(e,t,r,n,i,a);default:throw new Error("Unsupported resampling method: '".concat(o,"'"))}}function Re(e,t,r){for(var n=0,i=t;i<r;++i)n+=e[i];return n}function Me(e,t,r){switch(e){case 1:if(t<=8)return new Uint8Array(r);if(t<=16)return new Uint16Array(r);if(t<=32)return new Uint32Array(r);break;case 2:if(8===t)return new Int8Array(r);if(16===t)return new Int16Array(r);if(32===t)return new Int32Array(r);break;case 3:switch(t){case 16:case 32:return new Float32Array(r);case 64:return new Float64Array(r)}}throw Error("Unsupported data format/bitsPerSample")}function Be(e,t){return(1!==e&&2!==e||!(t<=32)||t%8!=0)&&(3!==e||16!==t&&32!==t&&64!==t)}function Ce(e,t,r,n,i,a,o){var s=new DataView(e),u=2===r?1:n,f=Me(t,i,2===r?o*a:o*a*n),c=parseInt("1".repeat(i),2);if(1===t){var l=a*(1===r?n*i:i);0!=(7&l)&&(l=l+7&-8);for(var h=0;h<o;++h)for(var d=h*l,p=0;p<a;++p)for(var m=d+p*u*i,v=0;v<u;++v){var y=m+v*i,g=(h*a+p)*u+v,w=Math.floor(y/8),b=y%8;if(b+i<=8)f[g]=s.getUint8(w)>>8-i-b&c;else if(b+i<=16)f[g]=s.getUint16(w)>>16-i-b&c;else if(b+i<=24){var k=s.getUint16(w)<<8|s.getUint8(w+2);f[g]=k>>24-i-b&c}else f[g]=s.getUint32(w)>>32-i-b&c}}return f.buffer}xe([void 0,1],(function(){return Promise.resolve().then((function(){return Fr})).then((function(e){return e.default}))})),xe(5,(function(){return Promise.resolve().then((function(){return Nr})).then((function(e){return e.default}))})),xe(6,(function(){throw new Error("old style JPEG compression is not supported.")})),xe(7,(function(){return Promise.resolve().then((function(){return on})).then((function(e){return e.default}))})),xe([8,32946],(function(){return Promise.resolve().then((function(){return vi})).then((function(e){return e.default}))})),xe(32773,(function(){return Promise.resolve().then((function(){return wi})).then((function(e){return e.default}))})),xe(34887,(function(){return Promise.resolve().then((function(){return _i})).then((function(e){return e.default}))})),xe(50001,(function(){return Promise.resolve().then((function(){return Si})).then((function(e){return e.default}))}));var Le=function(){function e(t,r,n,i,a,o){b(this,e),this.fileDirectory=t,this.geoKeys=r,this.dataView=n,this.littleEndian=i,this.tiles=a?{}:null,this.isTiled=!t.StripOffsets;var s=t.PlanarConfiguration;if(this.planarConfiguration=void 0===s?1:s,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");this.source=o}var t,r,n,i;return c(e,[{key:"getFileDirectory",value:function(){return this.fileDirectory}},{key:"getGeoKeys",value:function(){return this.geoKeys}},{key:"getWidth",value:function(){return this.fileDirectory.ImageWidth}},{key:"getHeight",value:function(){return this.fileDirectory.ImageLength}},{key:"getSamplesPerPixel",value:function(){return void 0!==this.fileDirectory.SamplesPerPixel?this.fileDirectory.SamplesPerPixel:1}},{key:"getTileWidth",value:function(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}},{key:"getTileHeight",value:function(){return this.isTiled?this.fileDirectory.TileLength:void 0!==this.fileDirectory.RowsPerStrip?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}},{key:"getBlockWidth",value:function(){return this.getTileWidth()}},{key:"getBlockHeight",value:function(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}},{key:"getBytesPerPixel",value:function(){for(var e=0,t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}},{key:"getSampleByteSize",value:function(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError("Sample index ".concat(e," is out of range."));return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}},{key:"getReaderForSample",value:function(e){var t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,r=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(r<=8)return DataView.prototype.getUint8;if(r<=16)return DataView.prototype.getUint16;if(r<=32)return DataView.prototype.getUint32;break;case 2:if(r<=8)return DataView.prototype.getInt8;if(r<=16)return DataView.prototype.getInt16;if(r<=32)return DataView.prototype.getInt32;break;case 3:switch(r){case 16:return function(e,t){return Y(this,e,t)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}},{key:"getSampleFormat",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}},{key:"getBitsPerSample",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this.fileDirectory.BitsPerSample[e]}},{key:"getArrayForSample",value:function(e,t){return Me(this.getSampleFormat(e),this.getBitsPerSample(e),t)}},{key:"getTileOrStrip",value:(i=u(x.mark((function e(t,r,n,i,a){var o,s,f,c,l,h,d,p,m=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=Math.ceil(this.getWidth()/this.getTileWidth()),s=Math.ceil(this.getHeight()/this.getTileHeight()),c=this.tiles,1===this.planarConfiguration?f=r*o+t:2===this.planarConfiguration&&(f=n*o*s+r*o+t),this.isTiled?(l=this.fileDirectory.TileOffsets[f],h=this.fileDirectory.TileByteCounts[f]):(l=this.fileDirectory.StripOffsets[f],h=this.fileDirectory.StripByteCounts[f]),e.next=7,this.source.fetch([{offset:l,length:h}],a);case 7:return d=e.sent[0],null!==c&&c[f]?p=c[f]:(p=u(x.mark((function e(){var t,n,a;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,i.decode(m.fileDirectory,d);case 2:return t=e.sent,n=m.getSampleFormat(),a=m.getBitsPerSample(),Be(n,a)&&(t=Ce(t,n,m.planarConfiguration,m.getSamplesPerPixel(),a,m.getTileWidth(),m.getBlockHeight(r))),e.abrupt("return",t);case 7:case"end":return e.stop()}}),e)})))(),null!==c&&(c[f]=p)),e.t0=t,e.t1=r,e.t2=n,e.next=14,p;case 14:return e.t3=e.sent,e.abrupt("return",{x:e.t0,y:e.t1,sample:e.t2,data:e.t3});case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n,a){return i.apply(this,arguments)})},{key:"_readRaster",value:(n=u(x.mark((function e(t,r,n,i,a,o,s,u,f){var c,l,h,d,p,m,v,y,g,w,b,k,A,_,I,P,S,T,U,O,D=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:for(c=this.getTileWidth(),l=this.getTileHeight(),h=this.getWidth(),d=this.getHeight(),p=Math.max(Math.floor(t[0]/c),0),m=Math.min(Math.ceil(t[2]/c),Math.ceil(h/c)),v=Math.max(Math.floor(t[1]/l),0),y=Math.min(Math.ceil(t[3]/l),Math.ceil(d/l)),g=t[2]-t[0],w=this.getBytesPerPixel(),b=[],k=[],A=0;A<r.length;++A)1===this.planarConfiguration?b.push(Re(this.fileDirectory.BitsPerSample,0,r[A])/8):b.push(0),k.push(this.getReaderForSample(r[A]));for(_=[],I=this.littleEndian,P=v;P<y;++P)for(S=p;S<m;++S)for(T=function(e){var o=e,s=r[e];2===D.planarConfiguration&&(w=D.getSampleByteSize(e));var u=D.getTileOrStrip(S,P,s,a,f).then((function(e){for(var a=e.data,s=new DataView(a),u=D.getBlockHeight(e.y),f=e.y*l,p=e.x*c,m=f+u,v=(e.x+1)*c,y=k[o],x=Math.min(u,u-(m-t[3]),d-f),A=Math.min(c,c-(v-t[2]),h-p),_=Math.max(0,t[1]-f);_<x;++_)for(var P=Math.max(0,t[0]-p);P<A;++P){var S=(_*c+P)*w,T=y.call(s,S+b[o],I),U=void 0;i?(U=(_+f-t[1])*g*r.length+(P+p-t[0])*r.length+o,n[U]=T):(U=(_+f-t[1])*g+P+p-t[0],n[o][U]=T)}}));_.push(u)},U=0;U<r.length;++U)T(U);return e.next=18,Promise.all(_);case 18:if(!(o&&t[2]-t[0]!==o||s&&t[3]-t[1]!==s)){e.next=23;break}return(O=i?Ee(n,t[2]-t[0],t[3]-t[1],o,s,r.length,u):Ue(n,t[2]-t[0],t[3]-t[1],o,s,u)).width=o,O.height=s,e.abrupt("return",O);case 23:return n.width=o||t[2]-t[0],n.height=s||t[3]-t[1],e.abrupt("return",n);case 26:case"end":return e.stop()}}),e,this)}))),function(e,t,r,i,a,o,s,u,f){return n.apply(this,arguments)})},{key:"readRasters",value:(r=u(x.mark((function e(){var t,r,n,i,a,o,s,u,f,c,l,h,d,p,m,v,y,g,w,b,k,A,_,I,P,S,T=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=T.length>0&&void 0!==T[0]?T[0]:{},r=t.window,n=t.samples,i=void 0===n?[]:n,a=t.interleave,o=t.pool,s=void 0===o?null:o,u=t.width,f=t.height,c=t.resampleMethod,l=t.fillValue,h=t.signal,!((d=r||[0,0,this.getWidth(),this.getHeight()])[0]>d[2]||d[1]>d[3])){e.next=4;break}throw new Error("Invalid subsets");case 4:if(p=d[2]-d[0],m=d[3]-d[1],v=p*m,y=this.getSamplesPerPixel(),i&&i.length){e.next=12;break}for(g=0;g<y;++g)i.push(g);e.next=19;break;case 12:w=0;case 13:if(!(w<i.length)){e.next=19;break}if(!(i[w]>=y)){e.next=16;break}return e.abrupt("return",Promise.reject(new RangeError("Invalid sample index '".concat(i[w],"'."))));case 16:++w,e.next=13;break;case 19:if(a)k=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,A=Math.max.apply(null,this.fileDirectory.BitsPerSample),b=Me(k,A,v*i.length),l&&b.fill(l);else for(b=[],_=0;_<i.length;++_)I=this.getArrayForSample(i[_],v),Array.isArray(l)&&_<l.length?I.fill(l[_]):l&&!Array.isArray(l)&&I.fill(l),b.push(I);if(e.t0=s,e.t0){e.next=25;break}return e.next=24,Ae(this.fileDirectory);case 24:e.t0=e.sent;case 25:return P=e.t0,e.next=28,this._readRaster(d,i,b,a,P,u,f,c,h);case 28:return S=e.sent,e.abrupt("return",S);case 30:case"end":return e.stop()}}),e,this)}))),function(){return r.apply(this,arguments)})},{key:"readRGB",value:(t=u(x.mark((function e(){var t,r,n,i,a,o,s,u,f,c,l,h,d,p,m,v,y,g,w,b,k,A,_,I,P,S,T,U=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=U.length>0&&void 0!==U[0]?U[0]:{},r=t.window,n=t.interleave,i=void 0===n||n,a=t.pool,o=void 0===a?null:a,s=t.width,u=t.height,f=t.resampleMethod,c=t.enableAlpha,l=void 0!==c&&c,h=t.signal,!((d=r||[0,0,this.getWidth(),this.getHeight()])[0]>d[2]||d[1]>d[3])){e.next=4;break}throw new Error("Invalid subsets");case 4:if((p=this.fileDirectory.PhotometricInterpretation)!==oe.RGB){e.next=9;break}if(m=[0,1,2],this.fileDirectory.ExtraSamples!==se.Unspecified&&l)for(m=[],v=0;v<this.fileDirectory.BitsPerSample.length;v+=1)m.push(v);return e.abrupt("return",this.readRasters({window:r,interleave:i,samples:m,pool:o,width:s,height:u,resampleMethod:f,signal:h}));case 9:e.t0=p,e.next=e.t0===oe.WhiteIsZero||e.t0===oe.BlackIsZero||e.t0===oe.Palette?12:e.t0===oe.CMYK?14:e.t0===oe.YCbCr||e.t0===oe.CIELab?16:18;break;case 12:return y=[0],e.abrupt("break",19);case 14:return y=[0,1,2,3],e.abrupt("break",19);case 16:return y=[0,1,2],e.abrupt("break",19);case 18:throw new Error("Invalid or unsupported photometric interpretation.");case 19:return g={window:d,interleave:!0,samples:y,pool:o,width:s,height:u,resampleMethod:f,signal:h},w=this.fileDirectory,e.next=23,this.readRasters(g);case 23:b=e.sent,k=Math.pow(2,this.fileDirectory.BitsPerSample[0]),e.t1=p,e.next=e.t1===oe.WhiteIsZero?28:e.t1===oe.BlackIsZero?30:e.t1===oe.Palette?32:e.t1===oe.CMYK?34:e.t1===oe.YCbCr?36:e.t1===oe.CIELab?38:40;break;case 28:return A=pe(b,k),e.abrupt("break",41);case 30:return A=me(b,k),e.abrupt("break",41);case 32:return A=ve(b,w.ColorMap),e.abrupt("break",41);case 34:return A=ye(b),e.abrupt("break",41);case 36:return A=ge(b),e.abrupt("break",41);case 38:return A=we(b),e.abrupt("break",41);case 40:throw new Error("Unsupported photometric interpretation.");case 41:if(!i){for(_=new Uint8Array(A.length/3),I=new Uint8Array(A.length/3),P=new Uint8Array(A.length/3),S=0,T=0;S<A.length;S+=3,++T)_[T]=A[S],I[T]=A[S+1],P[T]=A[S+2];A=[_,I,P]}return A.width=b.width,A.height=b.height,e.abrupt("return",A);case 45:case"end":return e.stop()}}),e,this)}))),function(){return t.apply(this,arguments)})},{key:"getTiePoints",value:function(){if(!this.fileDirectory.ModelTiepoint)return[];for(var e=[],t=0;t<this.fileDirectory.ModelTiepoint.length;t+=6)e.push({i:this.fileDirectory.ModelTiepoint[t],j:this.fileDirectory.ModelTiepoint[t+1],k:this.fileDirectory.ModelTiepoint[t+2],x:this.fileDirectory.ModelTiepoint[t+3],y:this.fileDirectory.ModelTiepoint[t+4],z:this.fileDirectory.ModelTiepoint[t+5]});return e}},{key:"getGDALMetadata",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t={};if(!this.fileDirectory.GDAL_METADATA)return null;var r=this.fileDirectory.GDAL_METADATA,n=J(r,"Item");n=null===e?n.filter((function(e){return void 0===q(e,"sample")})):n.filter((function(t){return Number(q(t,"sample"))===e}));for(var i=0;i<n.length;++i){var a=n[i];t[q(a,"name")]=a.inner}return t}},{key:"getGDALNoData",value:function(){if(!this.fileDirectory.GDAL_NODATA)return null;var e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}},{key:"getOrigin",value:function(){var e=this.fileDirectory.ModelTiepoint,t=this.fileDirectory.ModelTransformation;if(e&&6===e.length)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}},{key:"getResolution",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=this.fileDirectory.ModelPixelScale,r=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(r)return[r[0],r[5],r[10]];if(e){var n=e.getResolution(),i=o(n,3),a=i[0],s=i[1],u=i[2];return[a*e.getWidth()/this.getWidth(),s*e.getHeight()/this.getHeight(),u*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}},{key:"pixelIsArea",value:function(){return 1===this.geoKeys.GTRasterTypeGeoKey}},{key:"getBoundingBox",value:function(){var e=this.getOrigin(),t=this.getResolution(),r=e[0],n=e[1],i=r+t[0]*this.getWidth(),a=n+t[1]*this.getHeight();return[Math.min(r,i),Math.min(n,a),Math.max(r,i),Math.max(n,a)]}}]),e}(),Fe=Le,Ve=function(){function e(t){b(this,e),this._dataView=new DataView(t)}return c(e,[{key:"buffer",get:function(){return this._dataView.buffer}},{key:"getUint64",value:function(e,t){var r,n=this.getUint32(e,t),i=this.getUint32(e+4,t);if(t){if(r=n+Math.pow(2,32)*i,!Number.isSafeInteger(r))throw new Error("".concat(r," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return r}if(r=Math.pow(2,32)*n+i,!Number.isSafeInteger(r))throw new Error("".concat(r," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return r}},{key:"getInt64",value:function(e,t){for(var r=0,n=(128&this._dataView.getUint8(e+(t?7:0)))>0,i=!0,a=0;a<8;a++){var o=this._dataView.getUint8(e+(t?a:7-a));n&&(i?0!==o&&(o=255&~(o-1),i=!1):o=255&~o),r+=o*Math.pow(256,a)}return n&&(r=-r),r}},{key:"getUint8",value:function(e,t){return this._dataView.getUint8(e,t)}},{key:"getInt8",value:function(e,t){return this._dataView.getInt8(e,t)}},{key:"getUint16",value:function(e,t){return this._dataView.getUint16(e,t)}},{key:"getInt16",value:function(e,t){return this._dataView.getInt16(e,t)}},{key:"getUint32",value:function(e,t){return this._dataView.getUint32(e,t)}},{key:"getInt32",value:function(e,t){return this._dataView.getInt32(e,t)}},{key:"getFloat16",value:function(e,t){return Y(this._dataView,e,t)}},{key:"getFloat32",value:function(e,t){return this._dataView.getFloat32(e,t)}},{key:"getFloat64",value:function(e,t){return this._dataView.getFloat64(e,t)}}]),e}(),Ge=function(){function e(t,r,n,i){b(this,e),this._dataView=new DataView(t),this._sliceOffset=r,this._littleEndian=n,this._bigTiff=i}return c(e,[{key:"sliceOffset",get:function(){return this._sliceOffset}},{key:"sliceTop",get:function(){return this._sliceOffset+this.buffer.byteLength}},{key:"littleEndian",get:function(){return this._littleEndian}},{key:"bigTiff",get:function(){return this._bigTiff}},{key:"buffer",get:function(){return this._dataView.buffer}},{key:"covers",value:function(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}},{key:"readUint8",value:function(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}},{key:"readInt8",value:function(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}},{key:"readUint16",value:function(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}},{key:"readInt16",value:function(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}},{key:"readUint32",value:function(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}},{key:"readInt32",value:function(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}},{key:"readFloat32",value:function(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}},{key:"readFloat64",value:function(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}},{key:"readUint64",value:function(e){var t,r=this.readUint32(e),n=this.readUint32(e+4);if(this._littleEndian){if(t=r+Math.pow(2,32)*n,!Number.isSafeInteger(t))throw new Error("".concat(t," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return t}if(t=Math.pow(2,32)*r+n,!Number.isSafeInteger(t))throw new Error("".concat(t," exceeds MAX_SAFE_INTEGER. ")+"Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues");return t}},{key:"readInt64",value:function(e){for(var t=0,r=(128&this._dataView.getUint8(e+(this._littleEndian?7:0)))>0,n=!0,i=0;i<8;i++){var a=this._dataView.getUint8(e+(this._littleEndian?i:7-i));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),t+=a*Math.pow(256,i)}return r&&(t=-t),t}},{key:"readOffset",value:function(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}]),e}(),je="undefined"!=typeof navigator&&navigator.hardwareConcurrency||2,ze=function(){function e(){var t=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:je,n=arguments.length>1?arguments[1]:void 0;b(this,e),this.workers=null,this._awaitingDecoder=null,this.size=r,this.messageId=0,r&&(this._awaitingDecoder=n?Promise.resolve(n):new Promise((function(e){Promise.resolve().then((function(){return Ui})).then((function(t){e(t.create)}))})),this._awaitingDecoder.then((function(e){t._awaitingDecoder=null,t.workers=[];for(var n=0;n<r;n++)t.workers.push({worker:e(),idle:!0})})))}var t;return c(e,[{key:"decode",value:(t=u(x.mark((function e(t,r){var n=this;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._awaitingDecoder){e.next=3;break}return e.next=3,this._awaitingDecoder;case 3:return e.abrupt("return",0===this.size?Ae(t).then((function(e){return e.decode(t,r)})):new Promise((function(e){var i=n.workers.find((function(e){return e.idle}))||n.workers[Math.floor(Math.random()*n.size)];i.idle=!1;var a=n.messageId++;i.worker.addEventListener("message",(function t(r){r.data.id===a&&(i.idle=!0,e(r.data.decoded),i.worker.removeEventListener("message",t))})),i.worker.postMessage({fileDirectory:t,buffer:r,id:a},[r])})));case 4:case"end":return e.stop()}}),e,this)}))),function(e,r){return t.apply(this,arguments)})},{key:"destroy",value:function(){this.workers&&(this.workers.forEach((function(e){e.worker.terminate()})),this.workers=null)}}]),e}(),Ne=ze;function Ke(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}function Ze(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return He(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return He(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function He(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var Ye="\r\n\r\n";function qe(e){if(void 0!==Object.fromEntries)return Object.fromEntries(e);var t,r={},n=Ze(e);try{for(n.s();!(t=n.n()).done;){var i=o(t.value,2),a=i[0],s=i[1];r[a.toLowerCase()]=s}}catch(e){n.e(e)}finally{n.f()}return r}function Xe(e){return qe(e.split("\r\n").map((function(e){var t=e.split(":").map((function(e){return e.trim()}));return t[0]=t[0].toLowerCase(),t})))}function We(e){var t,n=e.split(";").map((function(e){return e.trim()})),o=r(t=n)||j(t)||i(t)||a();return{type:o[0],params:qe(o.slice(1).map((function(e){return e.split("=")})))}}function Je(e){var t,r,n;if(e){var i=o(e.match(/bytes (\d+)-(\d+)\/(\d+)/),4);t=i[1],r=i[2],n=i[3],t=parseInt(t,10),r=parseInt(r,10),n=parseInt(n,10)}return{start:t,end:r,total:n}}function Qe(e,t){for(var r=null,n=new TextDecoder("ascii"),i=[],a="--".concat(t),o="".concat(a,"--"),s=0;s<10;++s){n.decode(new Uint8Array(e,s,a.length))===a&&(r=s)}if(null===r)throw new Error("Could not find initial boundary");for(;r<e.byteLength;){var u=n.decode(new Uint8Array(e,r,Math.min(a.length+1024,e.byteLength-r)));if(0===u.length||u.startsWith(o))break;if(!u.startsWith(a))throw new Error("Part does not start with boundary");var f=u.substr(a.length+2);if(0===f.length)break;var c=f.indexOf(Ye),l=Xe(f.substr(0,c)),h=Je(l["content-range"]),d=h.start,p=h.end,m=h.total,v=r+a.length+c+Ye.length,y=parseInt(p,10)+1-parseInt(d,10);i.push({headers:l,data:e.slice(v,v+y),offset:d,length:y,fileSize:m}),r=v+y+4}return i}var $e=function(){function e(){b(this,e)}var t,r,n;return c(e,[{key:"fetch",value:(n=u(x.mark((function e(t){var r,n=this,i=arguments;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=i.length>1&&void 0!==i[1]?i[1]:void 0,e.abrupt("return",Promise.all(t.map((function(e){return n.fetchSlice(e,r)}))));case 2:case"end":return e.stop()}}),e)}))),function(e){return n.apply(this,arguments)})},{key:"fetchSlice",value:(r=u(x.mark((function e(t){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:throw new Error("fetching of slice ".concat(t," not possible, not implemented"));case 1:case"end":return e.stop()}}),e)}))),function(e){return r.apply(this,arguments)})},{key:"fileSize",get:function(){return null}},{key:"close",value:(t=u(x.mark((function e(){return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)}))),function(){return t.apply(this,arguments)})}]),e}();function et(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return tt(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return tt(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,o=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return o=e.done,e},e:function(e){s=!0,a=e},f:function(){try{o||null==r.return||r.return()}finally{if(s)throw a}}}}function tt(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function rt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,n=v(e);if(t){var i=v(this).constructor;r=Reflect.construct(n,arguments,i)}else r=n.apply(this,arguments);return m(this,r)}}var nt=function(e,t,r){h(i,e);var n=rt(i);function i(){var e,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(b(this,i),e=n.call(this),!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if("number"==typeof t.maxAge&&0===t.maxAge)throw new TypeError("`maxAge` must be a number greater than 0");return e.maxSize=t.maxSize,e.maxAge=t.maxAge||Number.POSITIVE_INFINITY,e.onEviction=t.onEviction,e.cache=new Map,e.oldCache=new Map,e._size=0,e}return c(i,[{key:"_emitEvictions",value:function(e){if("function"==typeof this.onEviction){var t,r=et(e);try{for(r.s();!(t=r.n()).done;){var n=o(t.value,2),i=n[0],a=n[1];this.onEviction(i,a.value)}}catch(e){r.e(e)}finally{r.f()}}}},{key:"_deleteIfExpired",value:function(e,t){return"number"==typeof t.expiry&&t.expiry<=Date.now()&&("function"==typeof this.onEviction&&this.onEviction(e,t.value),this.delete(e))}},{key:"_getOrDeleteIfExpired",value:function(e,t){if(!1===this._deleteIfExpired(e,t))return t.value}},{key:"_getItemValue",value:function(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}},{key:"_peek",value:function(e,t){var r=t.get(e);return this._getItemValue(e,r)}},{key:"_set",value:function(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}},{key:"_moveToRecent",value:function(e,t){this.oldCache.delete(e),this._set(e,t)}},{key:"_entriesAscending",value:x.mark((function e(){var t,r,n,i,a,s,u,f,c,l,h,d;return x.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=et(this.oldCache),e.prev=1,t.s();case 3:if((r=t.n()).done){e.next=13;break}if(n=r.value,i=o(n,2),a=i[0],s=i[1],this.cache.has(a)){e.next=11;break}if(!1!==this._deleteIfExpired(a,s)){e.next=11;break}return e.next=11,n;case 11:e.next=3;break;case 13:e.next=18;break;case 15:e.prev=15,e.t0=e.catch(1),t.e(e.t0);case 18:return e.prev=18,t.f(),e.finish(18);case 21:u=et(this.cache),e.prev=22,u.s();case 24:if((f=u.n()).done){e.next=33;break}if(c=f.value,l=o(c,2),h=l[0],d=l[1],!1!==this._deleteIfExpired(h,d)){e.next=31;break}return e.next=31,c;case 31:e.next=24;break;case 33:e.next=38;break;case 35:e.prev=35,e.t1=e.catch(22),u.e(e.t1);case 38:return e.prev=38,u.f(),e.finish(38);case 41:case"end":return e.stop()}}),e,this,[[1,15,18,21],[22,35,38,41]])}))},{key:"get",value:function(e){if(this.cache.has(e)){var t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){var r=this.oldCache.get(e);if(!1===this._deleteIfExpired(e,r))return this._moveToRecent(e,r),r.value}}},{key:"set",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.maxAge,i=void 0===n?this.maxAge:n,a="number"==typeof i&&i!==Number.POSITIVE_INFINITY?Date.now()+i:void 0;this.cache.has(e)?this.cache.set(e,{value:t,expiry:a}):this._set(e,{value:t,expiry:a})}},{key:"has",value:function(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):!!this.oldCache.has(e)&&!this._deleteIfExpired(e,this.oldCache.get(e))}},{key:"peek",value:function(e){return this.cache.has(e)?this._peek(e,this.cache):this.oldCache.has(e)?this._peek(e,this.oldCache):void 0}},{key:"delete",value:function(e){var t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}},{key:"clear",value:function(){this.cache.clear(),this.oldCache.clear(),this._size=0}},{key:"resize",value:function(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");var t=z(this._entriesAscending()),r=t.length-e