@gisatcz/deckgl-geolib 1.4.3-dev.0 → 1.5.0-dev.0
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.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.min.js +1 -1
- package/dist/cjs/index.min.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.min.js +1 -1
- package/dist/esm/index.min.js.map +1 -1
- package/package.json +1 -1
- package/src/cogterrainlayer/CogTerrainLayer.ts +1 -2
package/dist/esm/index.min.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import{CompositeLayer as e}from"@deck.gl/core";import{TileLayer as t,TerrainLayer as i}from"@deck.gl/geo-layers";import{BitmapLayer as r}from"@deck.gl/layers";import n from"chroma-js";function s(e,t,i,r){return new(i||(i=Promise))((function(n,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}))}var a;!function(e){e.NONE="application/octet-stream",e.JPEG="image/jpeg",e.JP2="image/jp2",e.JPEGXL="image/jpegxl",e.WEBP="image/webp",e.ZSTD="application/zstd",e.LZW="application/lzw",e.DEFLATE="application/deflate",e.LZERC="application/lerc",e.LZMA="application/x-lzma"}(a||(a={}));const o={1:a.NONE,5:a.LZW,6:a.JPEG,7:a.JPEG,8:a.DEFLATE,34887:a.LZERC,34925:a.LZMA,34712:a.JP2,5e4:a.ZSTD,50001:a.WEBP,50002:a.JPEGXL};var l,h,f,c;function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}
|
|
2
2
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */!function(e){e[e.Artist=315]="Artist",e[e.BitsPerSample=258]="BitsPerSample",e[e.CellLength=265]="CellLength",e[e.CellWidth=264]="CellWidth",e[e.ColorMap=320]="ColorMap",e[e.Compression=259]="Compression",e[e.Copyright=33432]="Copyright",e[e.DateTime=306]="DateTime",e[e.ExtraSamples=338]="ExtraSamples",e[e.FillOrder=266]="FillOrder",e[e.FreeByteCounts=289]="FreeByteCounts",e[e.FreeOffsets=288]="FreeOffsets",e[e.GrayResponseCurve=291]="GrayResponseCurve",e[e.GrayResponseUnit=290]="GrayResponseUnit",e[e.HostComputer=316]="HostComputer",e[e.ImageDescription=270]="ImageDescription",e[e.ImageHeight=257]="ImageHeight",e[e.ImageWidth=256]="ImageWidth",e[e.Make=271]="Make",e[e.MaxSampleValue=281]="MaxSampleValue",e[e.MinSampleValue=280]="MinSampleValue",e[e.Model=272]="Model",e[e.NewSubFileType=254]="NewSubFileType",e[e.Orientation=274]="Orientation",e[e.PhotometricInterpretation=262]="PhotometricInterpretation",e[e.PlanarConfiguration=284]="PlanarConfiguration",e[e.ResolutionUnit=296]="ResolutionUnit",e[e.RowsPerStrip=278]="RowsPerStrip",e[e.SamplesPerPixel=277]="SamplesPerPixel",e[e.Software=305]="Software",e[e.StripByteCounts=279]="StripByteCounts",e[e.StripOffsets=273]="StripOffsets",e[e.SubFileType=255]="SubFileType",e[e.Threshholding=263]="Threshholding",e[e.XResolution=282]="XResolution",e[e.YResolution=283]="YResolution",e[e.BadFaxLines=326]="BadFaxLines",e[e.CleanFaxData=327]="CleanFaxData",e[e.ClipPath=343]="ClipPath",e[e.ConsecutiveBadFaxLines=328]="ConsecutiveBadFaxLines",e[e.Decode=433]="Decode",e[e.DefaultImageColor=434]="DefaultImageColor",e[e.DocumentName=269]="DocumentName",e[e.DotRange=336]="DotRange",e[e.HalftoneHints=321]="HalftoneHints",e[e.Indexed=346]="Indexed",e[e.JPEGTables=347]="JPEGTables",e[e.PageName=285]="PageName",e[e.PageNumber=297]="PageNumber",e[e.Predictor=317]="Predictor",e[e.PrimaryChromaticities=319]="PrimaryChromaticities",e[e.ReferenceBlackWhite=532]="ReferenceBlackWhite",e[e.SampleFormat=339]="SampleFormat",e[e.SMinSampleValue=340]="SMinSampleValue",e[e.SMaxSampleValue=341]="SMaxSampleValue",e[e.StripRowCounts=559]="StripRowCounts",e[e.SubIFDs=330]="SubIFDs",e[e.T4Options=292]="T4Options",e[e.T6Options=293]="T6Options",e[e.TileByteCounts=325]="TileByteCounts",e[e.TileHeight=323]="TileHeight",e[e.TileOffsets=324]="TileOffsets",e[e.TileWidth=322]="TileWidth",e[e.TransferFunction=301]="TransferFunction",e[e.WhitePoint=318]="WhitePoint",e[e.XClipPathUnits=344]="XClipPathUnits",e[e.XPosition=286]="XPosition",e[e.YCbCrCoefficients=529]="YCbCrCoefficients",e[e.YCbCrPositioning=531]="YCbCrPositioning",e[e.YCbCrSubSampling=530]="YCbCrSubSampling",e[e.YClipPathUnits=345]="YClipPathUnits",e[e.YPosition=287]="YPosition",e[e.ApertureValue=37378]="ApertureValue",e[e.ColorSpace=40961]="ColorSpace",e[e.DateTimeDigitized=36868]="DateTimeDigitized",e[e.DateTimeOriginal=36867]="DateTimeOriginal",e[e.ExifIFD=34665]="ExifIFD",e[e.ExifVersion=36864]="ExifVersion",e[e.ExposureTime=33434]="ExposureTime",e[e.FileSource=41728]="FileSource",e[e.Flash=37385]="Flash",e[e.FlashpixVersion=40960]="FlashpixVersion",e[e.FNumber=33437]="FNumber",e[e.ImageUniqueID=42016]="ImageUniqueID",e[e.LightSource=37384]="LightSource",e[e.MakerNote=37500]="MakerNote",e[e.ShutterSpeedValue=37377]="ShutterSpeedValue",e[e.UserComment=37510]="UserComment",e[e.IPTC=33723]="IPTC",e[e.ICCProfile=34675]="ICCProfile",e[e.XMP=700]="XMP",e[e.GDAL_METADATA=42112]="GDAL_METADATA",e[e.GDAL_NODATA=42113]="GDAL_NODATA",e[e.Photoshop=34377]="Photoshop",e[e.ModelPixelScale=33550]="ModelPixelScale",e[e.ModelTiePoint=33922]="ModelTiePoint",e[e.ModelTransformation=34264]="ModelTransformation",e[e.GeoKeyDirectory=34735]="GeoKeyDirectory",e[e.GeoDoubleParams=34736]="GeoDoubleParams",e[e.GeoAsciiParams=34737]="GeoAsciiParams"}(l||(l={})),function(e){e[e.GTModelTypeGeoKey=1024]="GTModelTypeGeoKey",e[e.GTRasterTypeGeoKey=1025]="GTRasterTypeGeoKey",e[e.GTCitationGeoKey=1026]="GTCitationGeoKey",e[e.GeographicTypeGeoKey=2048]="GeographicTypeGeoKey",e[e.GeogCitationGeoKey=2049]="GeogCitationGeoKey",e[e.GeogGeodeticDatumGeoKey=2050]="GeogGeodeticDatumGeoKey",e[e.GeogPrimeMeridianGeoKey=2051]="GeogPrimeMeridianGeoKey",e[e.GeogLinearUnitsGeoKey=2052]="GeogLinearUnitsGeoKey",e[e.GeogLinearUnitSizeGeoKey=2053]="GeogLinearUnitSizeGeoKey",e[e.GeogAngularUnitsGeoKey=2054]="GeogAngularUnitsGeoKey",e[e.GeogAngularUnitSizeGeoKey=2055]="GeogAngularUnitSizeGeoKey",e[e.GeogEllipsoidGeoKey=2056]="GeogEllipsoidGeoKey",e[e.GeogSemiMajorAxisGeoKey=2057]="GeogSemiMajorAxisGeoKey",e[e.GeogSemiMinorAxisGeoKey=2058]="GeogSemiMinorAxisGeoKey",e[e.GeogInvFlatteningGeoKey=2059]="GeogInvFlatteningGeoKey",e[e.GeogAzimuthUnitsGeoKey=2060]="GeogAzimuthUnitsGeoKey",e[e.GeogPrimeMeridianLongGeoKey=2061]="GeogPrimeMeridianLongGeoKey",e[e.GeogTOWGS84GeoKey=2062]="GeogTOWGS84GeoKey",e[e.ProjectedCSTypeGeoKey=3072]="ProjectedCSTypeGeoKey",e[e.PCSCitationGeoKey=3073]="PCSCitationGeoKey",e[e.ProjectionGeoKey=3074]="ProjectionGeoKey",e[e.ProjCoordTransGeoKey=3075]="ProjCoordTransGeoKey",e[e.ProjLinearUnitsGeoKey=3076]="ProjLinearUnitsGeoKey",e[e.ProjLinearUnitSizeGeoKey=3077]="ProjLinearUnitSizeGeoKey",e[e.ProjStdParallel1GeoKey=3078]="ProjStdParallel1GeoKey",e[e.ProjStdParallel2GeoKey=3079]="ProjStdParallel2GeoKey",e[e.ProjNatOriginLongGeoKey=3080]="ProjNatOriginLongGeoKey",e[e.ProjNatOriginLatGeoKey=3081]="ProjNatOriginLatGeoKey",e[e.ProjFalseEastingGeoKey=3082]="ProjFalseEastingGeoKey",e[e.ProjFalseNorthingGeoKey=3083]="ProjFalseNorthingGeoKey",e[e.ProjFalseOriginLongGeoKey=3084]="ProjFalseOriginLongGeoKey",e[e.ProjFalseOriginLatGeoKey=3085]="ProjFalseOriginLatGeoKey",e[e.ProjFalseOriginEastingGeoKey=3086]="ProjFalseOriginEastingGeoKey",e[e.ProjFalseOriginNorthingGeoKey=3087]="ProjFalseOriginNorthingGeoKey",e[e.ProjCenterLongGeoKey=3088]="ProjCenterLongGeoKey",e[e.ProjCenterLatGeoKey=3089]="ProjCenterLatGeoKey",e[e.ProjCenterEastingGeoKey=3090]="ProjCenterEastingGeoKey",e[e.ProjCenterNorthingGeoKey=3091]="ProjCenterNorthingGeoKey",e[e.ProjScaleAtNatOriginGeoKey=3092]="ProjScaleAtNatOriginGeoKey",e[e.ProjScaleAtCenterGeoKey=3093]="ProjScaleAtCenterGeoKey",e[e.ProjAzimuthAngleGeoKey=3094]="ProjAzimuthAngleGeoKey",e[e.ProjStraightVertPoleLongGeoKey=3095]="ProjStraightVertPoleLongGeoKey",e[e.ProjRectifiedGridAngleGeoKey=3096]="ProjRectifiedGridAngleGeoKey",e[e.VerticalCSTypeGeoKey=4096]="VerticalCSTypeGeoKey",e[e.VerticalCitationGeoKey=4097]="VerticalCitationGeoKey",e[e.VerticalDatumGeoKey=4098]="VerticalDatumGeoKey",e[e.VerticalUnitsGeoKey=4099]="VerticalUnitsGeoKey"}(h||(h={})),function(e){e[e.BYTE=1]="BYTE",e[e.ASCII=2]="ASCII",e[e.SHORT=3]="SHORT",e[e.LONG=4]="LONG",e[e.RATIONAL=5]="RATIONAL",e[e.SBYTE=6]="SBYTE",e[e.UNDEFINED=7]="UNDEFINED",e[e.SSHORT=8]="SSHORT",e[e.SLONG=9]="SLONG",e[e.SRATIONAL=10]="SRATIONAL",e[e.FLOAT=11]="FLOAT",e[e.DOUBLE=12]="DOUBLE",e[e.LONG8=16]="LONG8",e[e.SLONG8=17]="SLONG8",e[e.IFD8=18]="IFD8"}(f||(f={})),function(e){e[e.UInt8=1]="UInt8",e[e.UInt16=2]="UInt16",e[e.UInt32=4]="UInt32",e[e.UInt64=8]="UInt64",e[e.Double=8]="Double",e[e.Float=4]="Float"}(c||(c={})),"undefined"==typeof setImmediate?setTimeout:setImmediate;var d=function(e,t,i,r,n){var s,a,o=8*n-r-1,l=(1<<o)-1,h=l>>1,f=-7,c=i?n-1:0,u=i?-1:1,d=e[t+c];for(c+=u,s=d&(1<<-f)-1,d>>=-f,f+=o;f>0;s=256*s+e[t+c],c+=u,f-=8);for(a=s&(1<<-f)-1,s>>=-f,f+=r;f>0;a=256*a+e[t+c],c+=u,f-=8);if(0===s)s=1-h;else{if(s===l)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,r),s-=h}return(d?-1:1)*a*Math.pow(2,s-r)};const g=(e,t)=>String.fromCharCode(e.getUint8(t)),m=(e,t)=>e.getUint8(t),p=(e,t)=>e.getUint16(t),w=(e,t)=>e.getUint32(t),y=(e,t)=>e.getUint64(t),_=(e,t)=>d(e.bytes(t,c.Double),0,e.isLittleEndian,52,8),b=(e,t)=>[e.getUint32(t),e.getUint32(t+4)];function v(e){switch(e){case f.ASCII:return g;case f.BYTE:case f.UNDEFINED:case f.SBYTE:return m;case f.SHORT:case f.SSHORT:return p;case f.LONG:case f.SLONG:return w;case f.RATIONAL:case f.SRATIONAL:return b;case f.DOUBLE:return _;case f.LONG8:return y;default:throw new Error(`Unknown read type "${e}" "${f[e]}"`)}}class k{constructor(e,t,i){this.tiff=t,this.byteOffset=i,this.id=e,this.name=l[this.id],this.dataType=this.tiff.source.getUint16(i+2),this.dataCount=this.tiff.source.getUint(i+4,this.tiff.ifdConfig.pointer),this.dataTypeSize=function(e){switch(e){case f.BYTE:case f.ASCII:case f.SBYTE:case f.UNDEFINED:return 1;case f.SHORT:case f.SSHORT:return 2;case f.LONG:case f.SLONG:case f.FLOAT:return 4;case f.RATIONAL:case f.SRATIONAL:case f.DOUBLE:case f.LONG8:case f.SLONG8:case f.IFD8:return 8;default:throw new Error(`Invalid fieldType ${e}`)}}(this.dataType),this.dataLength=this.dataTypeSize*this.dataCount}get hasBytes(){return this.tiff.source.hasBytes(this.valuePointer,this.dataLength)}get isReady(){return!0}get dataTypeName(){return f[this.dataType]}get valuePointer(){const e=this.size-this.tiff.ifdConfig.pointer;return this.isValueInline?this.byteOffset+e:this.tiff.source.getUint(this.byteOffset+e,this.tiff.ifdConfig.pointer)}get size(){return this.tiff.ifdConfig.ifd}get isValueInline(){return this.dataLength<=this.tiff.ifdConfig.pointer}readValue(){const e=this.valuePointer,t=this.dataTypeSize,i=v(this.dataType),r=this.dataCount,n=r*t;if(1===r)return i(this.tiff.source,e);const s=[];for(let r=0;r<n;r+=t)s.push(i(this.tiff.source,e+r));return this.dataType===f.ASCII?s.join("").trim():s}toJSON(){return{id:this.id,name:this.name,offset:this.byteOffset,isReady:this.isReady,type:this.dataTypeName,value:this.value}}}class x extends k{constructor(){super(...arguments),this.value=null}get isReady(){return null!=this.value}async fetch(){return!1===this.tiff.source.hasBytes(this.valuePointer,this.dataLength)&&await this.tiff.source.loadBytes(this.valuePointer,this.dataLength),this.value=this.readValue(),this.value}}class T extends k{constructor(e,t,i){super(e,t,i),this.loadedValues=null}get value(){return null!=this.loadedValues?this.loadedValues:this.hasBytes?(this.readValue(),this.loadedValues):null}async load(){await this.tiff.source.loadBytes(this.valuePointer,this.dataLength),this.readValue()}readValue(){const e=super.readValue();return this.loadedValues="number"==typeof e?[e]:e,this.loadedValues}async getValueAt(e){if(this.loadedValues)return this.loadedValues[e];const t=this.dataTypeSize,i=this.valuePointer+t*e,r=v(this.dataType);return this.tiff.source.hasBytes(i,t)||await this.tiff.source.loadBytes(i,t),r(this.tiff.source,i)}}class A extends k{constructor(){super(...arguments),this._isRead=!1,this._value=null}get value(){return!1===this._isRead&&(this._value=this.readValue(),this._isRead=!0),this._value}}const S={create(e,t){const i=e.source.getUint16(t);if(i===l.TileOffsets||i===l.TileByteCounts||i===l.StripByteCounts||i===l.StripOffsets)return new T(i,e,t);const r=new A(i,e,t);return r.hasBytes?r:new x(i,e,t)},isStatic:e=>e instanceof A,isLazy:e=>e instanceof x,isOffsetArray:e=>e instanceof T};class I{constructor(e,t,i){this.tagsGeoLoaded=!1,this.tagsGeo=new Map,this.tif=e,this.id=t,this.tags=i}async init(e=!1){const t=[this.fetch(l.Compression),this.fetch(l.ImageHeight),this.fetch(l.ImageWidth),this.fetch(l.ModelPixelScale),this.fetch(l.ModelTiePoint),this.fetch(l.ModelTransformation),this.fetch(l.TileHeight),this.fetch(l.TileWidth)];e&&(t.push(this.fetch(l.GeoKeyDirectory)),t.push(this.fetch(l.GeoAsciiParams)),t.push(this.fetch(l.GeoDoubleParams))),await Promise.all(t),e&&await this.loadGeoTiffTags()}value(e){const t=this.tags.get(e);return null==t?null:t.value}async loadGeoTiffTags(){if(this.tagsGeoLoaded)return;const e=this.tags.get(l.GeoKeyDirectory);if(null==e)return void(this.tagsGeoLoaded=!0);if(!e.isReady&&e instanceof x&&await Promise.all([this.fetch(l.GeoKeyDirectory),this.fetch(l.GeoAsciiParams),this.fetch(l.GeoDoubleParams)]),this.tagsGeoLoaded=!0,null==e.value)return;const t=e.value;if(!Array.isArray(t))throw new Error("Invalid geo tags found");for(let e=4;e<=4*t[3];e+=4){const i=t[e],r=t[e+1],n=t[e+3];if(0===r){this.tagsGeo.set(i,n);continue}const s=this.tags.get(r);if(null==s||null==s.value)continue;const a=t[e+2];Array.isArray(s.value)?this.tagsGeo.set(i,s.value[n+a-1]):"string"==typeof s.value&&this.tagsGeo.set(i,s.value.substr(n,n+a-1).trim())}}valueGeo(e){if(!1===this.tagsGeoLoaded)throw new Error("loadGeoTiffTags() has not been called");return this.tagsGeo.get(e)}async fetch(e){const t=this.tags.get(e);return null==t?null:S.isLazy(t)?t.fetch():t.value}get origin(){const e=this.value(l.ModelTiePoint);if(null!=e&&6===e.length)return[e[3],e[4],e[5]];const t=this.value(l.ModelTransformation);if(null!=t)return[t[3],t[7],t[11]];if(1===this.value(l.NewSubFileType)&&0!==this.id)return this.tif.images[0].origin;throw new Error("Image does not have a geo transformation.")}get isGeoLocated(){return!(null==this.value(l.ModelPixelScale)&&null==this.value(l.ModelTransformation))||1===this.value(l.NewSubFileType)&&0!==this.id&&this.tif.images[0].isGeoLocated}get resolution(){const e=this.value(l.ModelPixelScale);if(null!=e)return[e[0],-e[1],e[2]];const t=this.value(l.ModelTransformation);if(null!=t)return[t[0],t[5],t[10]];if(1===this.value(l.NewSubFileType)&&0!==this.id){const e=this.tif.images[0],[t,i,r]=e.resolution,n=e.size,s=this.size;return[t*n.width/s.width,i*n.height/s.height,r]}throw new Error("Image does not have a geo transformation.")}get bbox(){const e=this.size,t=this.origin,i=this.resolution;if(null==t||null==e||null==i)throw new Error("Unable to calculate bounding box");const r=t[0],n=t[1],s=r+i[0]*e.width,a=n+i[1]*e.height;return[Math.min(r,s),Math.min(n,a),Math.max(r,s),Math.max(n,a)]}get compression(){const e=this.value(l.Compression);return null==e||"number"!=typeof e?null:o[e]}get epsg(){const e=this.valueGeo(h.ProjectedCSTypeGeoKey);return 32767===e?null:e}get size(){return{width:this.value(l.ImageWidth),height:this.value(l.ImageHeight)}}get tagList(){return[...this.tags.keys()].map((e=>l[e]))}isTiled(){return null!==this.value(l.TileWidth)}get tileSize(){return{width:this.value(l.TileWidth),height:this.value(l.TileHeight)}}get tileCount(){const e=this.size,t=this.tileSize;return{x:Math.ceil(e.width/t.width),y:Math.ceil(e.height/t.height)}}get tileOffset(){const e=this.tags.get(l.TileOffsets);if(null==e)throw new Error("No tile offsets found");return e}get stripCount(){const e=this.tags.get(l.StripByteCounts);return null==e?0:e.dataCount}async getTileOffset(e){const t=this.tileOffset;if(e<0||e>t.dataCount)throw new Error(`Tile offset: ${e} out of range: 0 -> ${t.dataCount}`);return t.getValueAt(e)}getTileBounds(e,t){const{size:i,tileSize:r}=this,n=t*r.height,s=e*r.width;return{x:s,y:n,width:s+r.width>=i.width?i.width-s:r.width,height:n+r.height>=i.height?i.height-n:r.height}}async getStrip(e){if(this.isTiled())throw new Error("Cannot read stripes, tiff is tiled");const t=this.tags.get(l.StripByteCounts),i=this.tags.get(l.StripOffsets);if(e>=t.dataCount)throw new Error("Cannot read strip, index out of bounds");const[r,n]=await Promise.all([i.getValueAt(e),t.getValueAt(e)]);return this.getBytes(r,n)}getJpegHeader(e){const t=this.value(l.JPEGTables);if(null==t)throw new Error("Unable to find Jpeg header");const i=t.slice(0,t.length-2),r=new Uint8Array(e.byteLength+i.length-2);return r.set(i,0),r.set(e.slice(2),i.length),r}async getBytes(e,t){const i=this.compression;if(null==i)throw new Error("Unsupported compression: "+this.value(l.Compression));if(0===t)return null;await this.tif.source.loadBytes(e,t);const r=this.tif.source.bytes(e,t);return this.compression===a.JPEG?{mimeType:i,bytes:this.getJpegHeader(r)}:{mimeType:i,bytes:r}}async getTile(e,t){const i=this.compression,r=this.size,n=this.tileSize;if(null==n)throw new Error("Tiff is not tiled");if(null==i)throw new Error("Unsupported compression: "+this.value(l.Compression));const s=Math.ceil(r.height/n.height),a=Math.ceil(r.width/n.width);if(e>=a||t>=s)throw new Error(`Tile index is outside of range x:${e} >= ${a} or y:${t} >= ${s}`);const o=t*a+e,h=a*s;if(o>=h)throw new Error(`Tile index is outside of tile range: ${o} >= ${h}`);const{offset:f,imageSize:c}=await this.getTileSize(o);return this.getBytes(f,c)}async hasTile(e,t){const i=this.tileSize,r=this.size;if(null==i)throw new Error("Tiff is not tiled");const n=Math.ceil(r.height/i.height),s=Math.ceil(r.width/i.width);if(e>=s||t>=n)return!1;const a=t*s+e;return(await this.getTileSize(a)).offset>0}async getTileSize(e){const t=this.tif.options.tileLeaderByteSize;if(t){const i=await this.getTileOffset(e);return 0===i?{offset:0,imageSize:0}:(await this.tif.source.loadBytes(i-t,t),{offset:i,imageSize:this.tif.source.getUint(i-t,t)})}const i=this.tags.get(l.TileByteCounts);if(null==i)throw new Error("No tile byte counts found");const[r,n]=await Promise.all([this.getTileOffset(e),i.getValueAt(e)]);return{offset:r,imageSize:n}}}var U,C,D,E,P;!function(e){e[e.Big=19789]="Big",e[e.Little=18761]="Little"}(U||(U={})),function(e){e[e.BigTiff=43]="BigTiff",e[e.Tiff=42]="Tiff"}(C||(C={})),function(e){e.GDAL_STRUCTURAL_METADATA_SIZE="GDAL_STRUCTURAL_METADATA_SIZE",e.LAYOUT="LAYOUT",e.BLOCK_ORDER="BLOCK_ORDER",e.BLOCK_LEADER="BLOCK_LEADER",e.BLOCK_TRAILER="BLOCK_TRAILER",e.KNOWN_INCOMPATIBLE_EDITION="KNOWN_INCOMPATIBLE_EDITION",e.MASK_INTERLEAVED_WITH_IMAGERY="MASK_INTERLEAVED_WITH_IMAGERY"}(D||(D={})),function(e){e.RowMajor="ROW_MAJOR"}(E||(E={})),function(e){e.uint32="SIZE_AS_UINT4"}(P||(P={}));class M{constructor(){this.options=new Map}get isCogOptimized(){return!this.isBroken&&"IFDS_BEFORE_DATA"===this.options.get(D.LAYOUT)}get isBroken(){return"YES"===this.options.get(D.KNOWN_INCOMPATIBLE_EDITION)}process(e){let t="",i="",r=!1;for(let n=0;n<e.length;n++){const s=e[n];if(0===s)break;const a=String.fromCharCode(s);"\n"===a?(this.options.set(t.trim(),i.trim()),t="",i="",r=!1):"="===a?r=!0:r?i+=a:t+=a}}get tileLeaderByteSize(){return this.options.get(D.BLOCK_LEADER)===P.uint32?c.UInt32:null}get isMaskInterleaved(){return"YES"===this.options.get(D.MASK_INTERLEAVED_WITH_IMAGERY)}}const O={version:C.Tiff,pointer:c.UInt32,offset:c.UInt16,ifd:c.UInt16+c.UInt16+2*c.UInt32},L={version:C.BigTiff,pointer:c.UInt64,offset:c.UInt64,ifd:c.UInt16+c.UInt16+2*c.UInt64};C.BigTiff,C.Tiff;class z{constructor(e,t=0){this.tiff=e,this.byteOffset=t,this.relativeOffset=0}get currentOffset(){return this.byteOffset+this.relativeOffset}seekTo(e){return this.byteOffset=e,this.relativeOffset=0,this}seek(e){const t=this.currentOffset;return this.relativeOffset+=e,t}bytes(e){return this.tiff.source.bytes(this.seek(e),e)}uint(e){return this.tiff.source.getUint(this.seek(e),e)}uint8(){return this.tiff.source.getUint8(this.seek(c.UInt8))}uint16(){return this.tiff.source.getUint16(this.seek(c.UInt16))}uint32(){return this.tiff.source.getUint32(this.seek(c.UInt32))}uint64(){return this.tiff.source.getUint64(this.seek(c.UInt64))}pointer(){const e=this.tiff.ifdConfig.pointer;return this.tiff.source.getUint(this.seek(e),e)}offset(){const e=this.tiff.ifdConfig.offset;return this.tiff.source.getUint(this.seek(e),e)}float(){return d(this.bytes(c.Float),0,this.tiff.source.isLittleEndian,23,4)}double(){return d(this.bytes(c.Double),0,this.tiff.source.isLittleEndian,52,8)}}function G(e,t=4,i=!0){const r=e.toString(16).padStart(t,"0");return i?"0x"+r:r}class B{constructor(e){this.version=C.Tiff,this.images=[],this.options=new M,this.ifdConfig=O,this.isInitialized=!1,this.source=e,this.cursor=new z(this)}static create(e){return new B(e).init()}init(e=!1){return this._initPromise||(this._initPromise=this.doInit(e)),this._initPromise}async doInit(e=!1){return this.isInitialized||(await this.source.loadBytes(0,this.source.chunkSize),await this.fetchIfd(),await Promise.all(this.images.map((t=>t.init(e)))),this.isInitialized=!0),this}async fetchIfd(){const e=this.cursor.seekTo(0),t=e.uint16();if(this.source.isLittleEndian=t===U.Little,!this.source.isLittleEndian)throw new Error("Only little endian is supported");let i;if(this.version=e.uint16(),this.version===C.BigTiff){this.ifdConfig=L;if(8!==e.uint16())throw new Error("Only 8byte pointers are supported");if(0!==e.uint16())throw new Error("Invalid big tiff header");i=e.pointer()}else{if(this.version!==C.Tiff)throw new Error(`Only tiff supported version:${this.version}`);i=e.pointer()}const r=i-this.cursor.currentOffset;return r>0&&r<16384&&this.options.process(e.bytes(r)),this.processIfd(i)}getImage(e){return this.images[e]}getImageByResolution(e){const t=this.images[0],i=t.size,[r]=t.resolution,n=r*i.width;for(let t=this.images.length-1;t>0;t--){const i=this.images[t];if(n/i.size.width-e<=.01)return i}return t}async getTile(e,t,i){const r=this.getImage(i);if(null==r)throw new Error(`Missing z: ${i}`);if(!r.isTiled())throw new Error("Tif is not tiled");return r.getTile(e,t)}async processIfd(e){const{image:t,nextOffset:i}=await this.readIfd(e);this.images.push(t),i&&await this.processIfd(i)}async readIfd(e){this.source.hasBytes(e,4096)||await this.source.loadBytes(e,4096);const t=this.cursor.seekTo(e).offset(),i=e+this.ifdConfig.offset,r=new Map;let n=i;for(let e=0;e<t;e++){const e=S.create(this,n);if(n+=e.size,null==e.name)throw new Error("Unknown IFD Tag: "+G(e.id));r.set(e.id,e)}const s=new I(this,this.images.length,r);return{nextOffset:this.source.getUint(n,this.ifdConfig.pointer),image:s}}async close(){var e,t;await(null===(t=null===(e=this.source)||void 0===e?void 0:e.close)||void 0===t?void 0:t.call(e))}}var R;!function(e){e[e.UInt8=1]="UInt8",e[e.UInt16=2]="UInt16",e[e.UInt32=4]="UInt32",e[e.UInt64=8]="UInt64",e[e.Double=8]="Double",e[e.Float=4]="Float"}(R||(R={}));const F=2**32,V="undefined"==typeof setImmediate?setTimeout:setImmediate,N=()=>{throw new Error("Method not implemented.")};class K{constructor(){this.isLittleEndian=!0,this.delayMs=1,this.maxChunkCount=10,this.chunks=new Map,this.requests=[],this.isRequestsTracked=K.DefaultTrackRequests,this.blankFillCount=16,this.maxConcurrentRequests=50,this.toFetch=new Set,this.toFetchPromise=null,this.byteOffset=0,this.getFloat32=N,this.getFloat64=N,this.getInt8=N,this.getInt16=N,this.getInt32=N,this.setFloat32=N,this.setFloat64=N,this.setInt8=N,this.setInt16=N,this.setInt32=N,this.setUint8=N,this.setUint16=N,this.setUint32=N,this.setBigInt64=N,this.setBigUint64=N}static getByteRanges(e,t=32,i=16){if(0===e.size)return{chunks:[],blankFill:[]};const r=[...e.values()].sort(((e,t)=>e-t)),n=[];let s=[];n.push(s);const a=[];for(let e=0;e<r.length;++e){const o=r[e],l=r[e-1];if(s.length>=t)s=[o],n.push(s);else if(0===e||o===l+1)s.push(o);else if(o<l+i){for(let e=l;e<o;e++)s.push(e+1),a.push(e+1);a.pop()}else s=[o],n.push(s)}return{chunks:n,blankFill:a}}async fetchData(e){if(0===this.toFetch.size)return;const t=this.toFetch;this.toFetch=new Set,this.toFetchPromise=null;const i=K.getByteRanges(t,this.maxChunkCount,this.blankFillCount),r=Date.now();for(const t of i.chunks){const i=t[0],n=t[t.length-1],s={startAt:r,requestStartAt:Date.now(),endAt:-1,chunks:t},a=i*this.chunkSize,o=n*this.chunkSize+this.chunkSize-a,l=Date.now(),h=await this.fetchBytes(a,o,e);if(s.endAt=Date.now(),this.isRequestsTracked&&this.requests.push(s),null==e||e.info({uri:this.uri,source:this.type,bytes:o,chunks:t,chunkCount:t.length,duration:Date.now()-l},"FetchChunk"),1===t.length){this.chunks.set(i,new DataView(h));continue}const f=i*this.chunkSize;for(const e of t){const t=e*this.chunkSize-f,i=h.slice(t,t+this.chunkSize);this.chunks.set(e,new DataView(i))}}}async loadBytes(e,t,i){if(e<0)throw new Error("Offset must be positive");const r=Math.floor(e/this.chunkSize),n=Math.ceil((e+t)/this.chunkSize)-1;for(let e=r;e<=n;e++)this.chunks.has(e)||this.toFetch.add(e);if(0!==this.toFetch.size){if(null==this.toFetchPromise&&(this.toFetchPromise=new Promise((e=>V(e,1))).then((()=>this.fetchData(i)))),this.toFetch.size>this.maxConcurrentRequests)throw new Error("Too many outstanding requests");await this.toFetchPromise}}getChunkId(e){return Math.floor(e/this.chunkSize)}getUint(e,t){switch(t){case R.UInt8:return this.getUint8(e);case R.UInt16:return this.getUint16(e);case R.UInt32:return this.getUint32(e);case R.UInt64:return this.getUint64(e)}}bytes(e,t){const i=this.isOneChunk(e,t);if(i){const r=this.getView(i),n=e-i*this.chunkSize;return new Uint8Array(r.buffer.slice(n,n+t))}const r=new Uint8Array(t),n=e+t,s=Math.floor(e/this.chunkSize),a=Math.ceil((e+t)/this.chunkSize)-1;let o=0;for(let t=s;t<=a;t++){const i=e+o,s=t*this.chunkSize,a=this.getView(t),l=Math.min(n,s+this.chunkSize),h=a.buffer.slice(i-s,l-s);r.set(new Uint8Array(h),o),o+=h.byteLength}return r}getView(e){const t=this.chunks.get(e);if(null==t)throw new Error(`Chunk:${e} is not ready`);return t}isOneChunk(e,t){const i=Math.floor(e/this.chunkSize);return Math.floor((e+t)/this.chunkSize)-i<1?Math.floor(i):null}hasBytes(e,t=1){const i=Math.floor(e/this.chunkSize),r=Math.ceil((e+t)/this.chunkSize)-1;for(let e=i;e<=r;e++)if(!this.chunks.has(e))return!1;return!0}toRange(e,t){if(null==t)return`bytes=${e}`;if(e<0)throw new Error("Cannot read from remote source with negative offset and length");return`bytes=${e}-${e+t}`}parseContentRange(e){const[t,i]=e.split(" ");if("bytes"!==t)throw new Error("Failed to parse content-range: "+e);if(null==i)throw new Error("Failed to parse content-range: "+e);const[,r]=i.split("/"),n=Number(r);if(isNaN(n))throw new Error("Failed to parse content-range: "+e);return n}get buffer(){throw new Error("Method not implemented.")}get byteLength(){if(this._byteLength)return this._byteLength;throw Error(".size() has not been feteched.")}getUint8(e){const t=this.getChunkId(e);return this.getView(t).getUint8(e-t*this.chunkSize)}getUint16(e){const t=this.isOneChunk(e,R.UInt8);if(null!=t){return this.getView(t).getUint16(e-t*this.chunkSize,this.isLittleEndian)}const i=this.getUint8(e),r=this.getUint8(e+R.UInt8);return this.isLittleEndian?i+(r<<8):(i<<8)+r}getUint32(e){const t=this.isOneChunk(e,R.UInt32);if(null!=t){return this.getView(t).getUint32(e-t*this.chunkSize,this.isLittleEndian)}const i=this.getUint16(e),r=this.getUint16(e+R.UInt16);return this.isLittleEndian?i+65536*r:65536*i+r}getUint64(e){const t=this.isOneChunk(e,R.UInt64);if(null!=t){const i=this.getView(t);return Number(i.getBigUint64(e-t*this.chunkSize,this.isLittleEndian))}const i=this.getUint32(e),r=this.getUint32(e+R.UInt32);return this.isLittleEndian?i+r*F:i*F+r}getBigUint64(e){const t=this.isOneChunk(e,R.UInt64);if(null!=t){return this.getView(t).getBigUint64(e-t*this.chunkSize,this.isLittleEndian)}const i=BigInt(this.getUint32(e)),r=BigInt(this.getUint32(e+R.UInt32));return this.isLittleEndian?i+(r<<BigInt(32)):(i<<BigInt(32))+r}getBigInt64(){throw new Error("Not implemented.")}}K.DefaultTrackRequests=!1;class j extends K{constructor(e){super(),this.type="url",this.protocol="http",this.chunkSize=j.DefaultChunkSize,this.uri=e}static isSource(e){return"url"===e.type}get size(){return this._size||(this._size=Promise.resolve().then((async()=>{const e=await j.fetch(this.uri,{method:"HEAD"});return Number(e.headers.get("content-length"))}))),this._size}async fetchBytes(e,t,i){const r={Range:this.toRange(e,t)},n=await j.fetch(this.uri,{headers:r});if(n.ok){const e=n.headers.get("content-range");return null==this._size&&null!=e&&(this._size=Promise.resolve(this.parseContentRange(e))),n.arrayBuffer()}throw null==i||i.error({offset:e,bytes:t,status:n.status,statusText:n.statusText,url:this.uri},"Failed to fetch"),new Error("Failed to fetch")}}j.DefaultChunkSize=32768,j.fetch=(e,t)=>fetch(e,t)
|
|
3
|
-
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */;function Z(e){let t=e.length;for(;--t>=0;)e[t]=0}const H=256,Y=286,W=30,X=15,$=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),q=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),J=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Q=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ee=new Array(576);Z(ee);const te=new Array(60);Z(te);const ie=new Array(512);Z(ie);const re=new Array(256);Z(re);const ne=new Array(29);Z(ne);const se=new Array(W);function ae(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}let oe,le,he;function fe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Z(se);const ce=e=>e<256?ie[e]:ie[256+(e>>>7)],ue=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},de=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,ue(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},ge=(e,t,i)=>{de(e,i[2*t],i[2*t+1])},me=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},pe=(e,t,i)=>{const r=new Array(16);let n,s,a=0;for(n=1;n<=X;n++)a=a+i[n-1]<<1,r[n]=a;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=me(r[t]++,t))}},we=e=>{let t;for(t=0;t<Y;t++)e.dyn_ltree[2*t]=0;for(t=0;t<W;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ye=e=>{e.bi_valid>8?ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_e=(e,t,i,r)=>{const n=2*t,s=2*i;return e[n]<e[s]||e[n]===e[s]&&r[t]<=r[i]},be=(e,t,i)=>{const r=e.heap[i];let n=i<<1;for(;n<=e.heap_len&&(n<e.heap_len&&_e(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!_e(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r},ve=(e,t,i)=>{let r,n,s,a,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,n=e.pending_buf[e.sym_buf+o++],0===r?ge(e,n,t):(s=re[n],ge(e,s+H+1,t),a=$[s],0!==a&&(n-=ne[s],de(e,n,a)),r--,s=ce(r),ge(e,s,i),a=q[s],0!==a&&(r-=se[s],de(e,r,a)))}while(o<e.sym_next);ge(e,256,t)},ke=(e,t)=>{const i=t.dyn_tree,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,l,h=-1;for(e.heap_len=0,e.heap_max=573,a=0;a<s;a++)0!==i[2*a]?(e.heap[++e.heap_len]=h=a,e.depth[a]=0):i[2*a+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=h<2?++h:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=r[2*l+1]);for(t.max_code=h,a=e.heap_len>>1;a>=1;a--)be(e,i,a);l=s;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],be(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,i[2*l]=i[2*a]+i[2*o],e.depth[l]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,i[2*a+1]=i[2*o+1]=l,e.heap[1]=l++,be(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,r=t.max_code,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let h,f,c,u,d,g,m=0;for(u=0;u<=X;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,h=e.heap_max+1;h<573;h++)f=e.heap[h],u=i[2*i[2*f+1]+1]+1,u>l&&(u=l,m++),i[2*f+1]=u,f>r||(e.bl_count[u]++,d=0,f>=o&&(d=a[f-o]),g=i[2*f],e.opt_len+=g*(u+d),s&&(e.static_len+=g*(n[2*f+1]+d)));if(0!==m){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(f=e.bl_count[u];0!==f;)c=e.heap[--h],c>r||(i[2*c+1]!==u&&(e.opt_len+=(u-i[2*c+1])*i[2*c],i[2*c+1]=u),f--)}})(e,t),pe(i,h,e.bl_count)},xe=(e,t,i)=>{let r,n,s=-1,a=t[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=a,a=t[2*(r+1)+1],++o<l&&n===a||(o<h?e.bl_tree[2*n]+=o:0!==n?(n!==s&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,s=n,0===a?(l=138,h=3):n===a?(l=6,h=3):(l=7,h=4))},Te=(e,t,i)=>{let r,n,s=-1,a=t[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),r=0;r<=i;r++)if(n=a,a=t[2*(r+1)+1],!(++o<l&&n===a)){if(o<h)do{ge(e,n,e.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(ge(e,n,e.bl_tree),o--),ge(e,16,e.bl_tree),de(e,o-3,2)):o<=10?(ge(e,17,e.bl_tree),de(e,o-3,3)):(ge(e,18,e.bl_tree),de(e,o-11,7));o=0,s=n,0===a?(l=138,h=3):n===a?(l=6,h=3):(l=7,h=4)}};let Ae=!1;const Se=(e,t,i,r)=>{de(e,0+(r?1:0),3),ye(e),ue(e,i),ue(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var Ie=(e,t,i,r)=>{let n,s,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<H;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),ke(e,e.l_desc),ke(e,e.d_desc),a=(e=>{let t;for(xe(e,e.dyn_ltree,e.l_desc.max_code),xe(e,e.dyn_dtree,e.d_desc.max_code),ke(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Q[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=n&&(n=s)):n=s=i+5,i+4<=n&&-1!==t?Se(e,t,i,r):4===e.strategy||s===n?(de(e,2+(r?1:0),3),ve(e,ee,te)):(de(e,4+(r?1:0),3),((e,t,i,r)=>{let n;for(de(e,t-257,5),de(e,i-1,5),de(e,r-4,4),n=0;n<r;n++)de(e,e.bl_tree[2*Q[n]+1],3);Te(e,e.dyn_ltree,t-1),Te(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),ve(e,e.dyn_ltree,e.dyn_dtree)),we(e),r&&ye(e)},Ue={_tr_init:e=>{Ae||((()=>{let e,t,i,r,n;const s=new Array(16);for(i=0,r=0;r<28;r++)for(ne[r]=i,e=0;e<1<<$[r];e++)re[i++]=r;for(re[i-1]=r,n=0,r=0;r<16;r++)for(se[r]=n,e=0;e<1<<q[r];e++)ie[n++]=r;for(n>>=7;r<W;r++)for(se[r]=n<<7,e=0;e<1<<q[r]-7;e++)ie[256+n++]=r;for(t=0;t<=X;t++)s[t]=0;for(e=0;e<=143;)ee[2*e+1]=8,e++,s[8]++;for(;e<=255;)ee[2*e+1]=9,e++,s[9]++;for(;e<=279;)ee[2*e+1]=7,e++,s[7]++;for(;e<=287;)ee[2*e+1]=8,e++,s[8]++;for(pe(ee,287,s),e=0;e<W;e++)te[2*e+1]=5,te[2*e]=me(e,5);oe=new ae(ee,$,257,Y,X),le=new ae(te,q,0,W,X),he=new ae(new Array(0),J,0,19,7)})(),Ae=!0),e.l_desc=new fe(e.dyn_ltree,oe),e.d_desc=new fe(e.dyn_dtree,le),e.bl_desc=new fe(e.bl_tree,he),e.bi_buf=0,e.bi_valid=0,we(e)},_tr_stored_block:Se,_tr_flush_block:Ie,_tr_tally:(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(re[i]+H+1)]++,e.dyn_dtree[2*ce(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{de(e,2,3),ge(e,256,ee),(e=>{16===e.bi_valid?(ue(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ce=(e,t,i,r)=>{let n=65535&e|0,s=e>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{n=n+t[r++]|0,s=s+n|0}while(--a);n%=65521,s%=65521}return n|s<<16|0};const De=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ee=(e,t,i,r)=>{const n=De,s=r+i;e^=-1;for(let i=r;i<s;i++)e=e>>>8^n[255&(e^t[i])];return-1^e},Pe={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Me={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Oe,_tr_stored_block:Le,_tr_flush_block:ze,_tr_tally:Ge,_tr_align:Be}=Ue,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:Fe,Z_FULL_FLUSH:Ve,Z_FINISH:Ne,Z_BLOCK:Ke,Z_OK:je,Z_STREAM_END:Ze,Z_STREAM_ERROR:He,Z_DATA_ERROR:Ye,Z_BUF_ERROR:We,Z_DEFAULT_COMPRESSION:Xe,Z_FILTERED:$e,Z_HUFFMAN_ONLY:qe,Z_RLE:Je,Z_FIXED:Qe,Z_DEFAULT_STRATEGY:et,Z_UNKNOWN:tt,Z_DEFLATED:it}=Me,rt=258,nt=262,st=42,at=113,ot=666,lt=(e,t)=>(e.msg=Pe[t],t),ht=e=>2*e-(e>4?9:0),ft=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ct=e=>{let t,i,r,n=e.w_size;t=e.hash_size,r=t;do{i=e.head[--r],e.head[r]=i>=n?i-n:0}while(--t);t=n,r=t;do{i=e.prev[--r],e.prev[r]=i>=n?i-n:0}while(--t)};let ut=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const dt=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},gt=(e,t)=>{ze(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,dt(e.strm)},mt=(e,t)=>{e.pending_buf[e.pending++]=t},pt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},wt=(e,t,i,r)=>{let n=e.avail_in;return n>r&&(n=r),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),i),1===e.state.wrap?e.adler=Ce(e.adler,t,n,i):2===e.state.wrap&&(e.adler=Ee(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)},yt=(e,t)=>{let i,r,n=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-nt?e.strstart-(e.w_size-nt):0,h=e.window,f=e.w_mask,c=e.prev,u=e.strstart+rt;let d=h[s+a-1],g=h[s+a];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(i=t,h[i+a]===g&&h[i+a-1]===d&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&s<u);if(r=rt-(u-s),s=u-rt,r>a){if(e.match_start=t,a=r,r>=o)break;d=h[s+a-1],g=h[s+a]}}}while((t=c[t&f])>l&&0!=--n);return a<=e.lookahead?a:e.lookahead},_t=e=>{const t=e.w_size;let i,r,n;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ct(e),r+=t),0===e.strm.avail_in)break;if(i=wt(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=i,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=ut(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ut(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<nt&&0!==e.strm.avail_in)},bt=(e,t)=>{let i,r,n,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,a=0,o=e.strm.avail_in;do{if(i=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,r=e.strstart-e.block_start,i>r+e.strm.avail_in&&(i=r+e.strm.avail_in),i>n&&(i=n),i<s&&(0===i&&t!==Ne||t===Re||i!==r+e.strm.avail_in))break;a=t===Ne&&i===r+e.strm.avail_in?1:0,Le(e,0,0,a),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,dt(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(wt(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===a);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?4:t!==Re&&t!==Ne&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(wt(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,s=n>e.w_size?e.w_size:n,r=e.strstart-e.block_start,(r>=s||(r||t===Ne)&&t!==Re&&0===e.strm.avail_in&&r<=n)&&(i=r>n?n:r,a=t===Ne&&0===e.strm.avail_in&&i===r?1:0,Le(e,e.block_start,i,a),e.block_start+=i,dt(e.strm)),a?3:1)},vt=(e,t)=>{let i,r;for(;;){if(e.lookahead<nt){if(_t(e),e.lookahead<nt&&t===Re)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nt&&(e.match_length=yt(e,i)),e.match_length>=3)if(r=Ge(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ut(e,e.ins_h,e.window[e.strstart+1]);else r=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2},kt=(e,t)=>{let i,r,n;for(;;){if(e.lookahead<nt){if(_t(e),e.lookahead<nt&&t===Re)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-nt&&(e.match_length=yt(e,i),e.match_length<=5&&(e.strategy===$e||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,r=Ge(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(gt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Ge(e,0,e.window[e.strstart-1]),r&>(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Ge(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2};function xt(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}const Tt=[new xt(0,0,0,0,bt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,kt),new xt(8,16,32,32,kt),new xt(8,16,128,128,kt),new xt(8,32,128,256,kt),new xt(32,128,258,1024,kt),new xt(32,258,258,4096,kt)];function At(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=it,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ft(this.dyn_ltree),ft(this.dyn_dtree),ft(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ft(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ft(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const St=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==st&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==at&&t.status!==ot?1:0},It=e=>{if(St(e))return lt(e,He);e.total_in=e.total_out=0,e.data_type=tt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?st:at,e.adler=2===t.wrap?0:1,t.last_flush=-2,Oe(t),je},Ut=e=>{const t=It(e);var i;return t===je&&((i=e.state).window_size=2*i.w_size,ft(i.head),i.max_lazy_match=Tt[i.level].max_lazy,i.good_match=Tt[i.level].good_length,i.nice_match=Tt[i.level].nice_length,i.max_chain_length=Tt[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Ct=(e,t,i,r,n,s)=>{if(!e)return He;let a=1;if(t===Xe&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),n<1||n>9||i!==it||r<8||r>15||t<0||t>9||s<0||s>Qe||8===r&&1!==a)return lt(e,He);8===r&&(r=9);const o=new At;return e.state=o,o.strm=e,o.status=st,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=s,o.method=i,Ut(e)};var Dt={deflateInit:(e,t)=>Ct(e,t,it,15,8,et),deflateInit2:Ct,deflateReset:Ut,deflateResetKeep:It,deflateSetHeader:(e,t)=>St(e)||2!==e.state.wrap?He:(e.state.gzhead=t,je),deflate:(e,t)=>{if(St(e)||t>Ke||t<0)return e?lt(e,He):He;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ot&&t!==Ne)return lt(e,0===e.avail_out?We:He);const r=i.last_flush;if(i.last_flush=t,0!==i.pending){if(dt(e),0===e.avail_out)return i.last_flush=-1,je}else if(0===e.avail_in&&ht(t)<=ht(r)&&t!==Ne)return lt(e,We);if(i.status===ot&&0!==e.avail_in)return lt(e,We);if(i.status===st&&0===i.wrap&&(i.status=at),i.status===st){let t=it+(i.w_bits-8<<4)<<8,r=-1;if(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=r<<6,0!==i.strstart&&(t|=32),t+=31-t%31,pt(i,t),0!==i.strstart&&(pt(i,e.adler>>>16),pt(i,65535&e.adler)),e.adler=1,i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je}if(57===i.status)if(e.adler=0,mt(i,31),mt(i,139),mt(i,8),i.gzhead)mt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),mt(i,255&i.gzhead.time),mt(i,i.gzhead.time>>8&255),mt(i,i.gzhead.time>>16&255),mt(i,i.gzhead.time>>24&255),mt(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),mt(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(mt(i,255&i.gzhead.extra.length),mt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ee(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(mt(i,0),mt(i,0),mt(i,0),mt(i,0),mt(i,0),mt(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),mt(i,3),i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je;if(69===i.status){if(i.gzhead.extra){let t=i.pending,r=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+r>i.pending_buf_size;){let n=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=n,dt(e),0!==i.pending)return i.last_flush=-1,je;t=0,r-=n}let n=new Uint8Array(i.gzhead.extra);i.pending_buf.set(n.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending+=r,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),dt(e),0!==i.pending)return i.last_flush=-1,je;r=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,mt(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),dt(e),0!==i.pending)return i.last_flush=-1,je;r=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,mt(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(dt(e),0!==i.pending))return i.last_flush=-1,je;mt(i,255&e.adler),mt(i,e.adler>>8&255),e.adler=0}if(i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je}if(0!==e.avail_in||0!==i.lookahead||t!==Re&&i.status!==ot){let r=0===i.level?bt(i,t):i.strategy===qe?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(_t(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,i=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Je?((e,t)=>{let i,r,n,s;const a=e.window;for(;;){if(e.lookahead<=rt){if(_t(e),e.lookahead<=rt&&t===Re)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,r=a[n],r===a[++n]&&r===a[++n]&&r===a[++n])){s=e.strstart+rt;do{}while(r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&n<s);e.match_length=rt-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ge(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2})(i,t):Tt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=ot),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),je;if(2===r&&(t===Fe?Be(i):t!==Ke&&(Le(i,0,0,!1),t===Ve&&(ft(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),dt(e),0===e.avail_out))return i.last_flush=-1,je}return t!==Ne?je:i.wrap<=0?Ze:(2===i.wrap?(mt(i,255&e.adler),mt(i,e.adler>>8&255),mt(i,e.adler>>16&255),mt(i,e.adler>>24&255),mt(i,255&e.total_in),mt(i,e.total_in>>8&255),mt(i,e.total_in>>16&255),mt(i,e.total_in>>24&255)):(pt(i,e.adler>>>16),pt(i,65535&e.adler)),dt(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?je:Ze)},deflateEnd:e=>{if(St(e))return He;const t=e.state.status;return e.state=null,t===at?lt(e,Ye):je},deflateSetDictionary:(e,t)=>{let i=t.length;if(St(e))return He;const r=e.state,n=r.wrap;if(2===n||1===n&&r.status!==st||r.lookahead)return He;if(1===n&&(e.adler=Ce(e.adler,t,i,0)),r.wrap=0,i>=r.w_size){0===n&&(ft(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(i-r.w_size,i),0),t=e,i=r.w_size}const s=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,_t(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=ut(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_t(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=a,e.input=o,e.avail_in=s,r.wrap=n,je},deflateInfo:"pako deflate (from Nodeca project)"};const Et=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Pt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Et(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i}};let Mt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Mt=!1}const Ot=new Uint8Array(256);for(let e=0;e<256;e++)Ot[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ot[254]=Ot[254]=1;var Lt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,s,a=e.length,o=0;for(n=0;n<a;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<a&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),s=0,n=0;s<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<a&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,n;const s=new Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){s[n++]=t;continue}let a=Ot[t];if(a>4)s[n++]=65533,r+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&r<i;)t=t<<6|63&e[r++],a--;a>1?s[n++]=65533:t<65536?s[n++]=t:(t-=65536,s[n++]=55296|t>>10&1023,s[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Mt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let r=0;r<t;r++)i+=String.fromCharCode(e[r]);return i})(s,n)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Ot[e[i]]>t?i:t}};var zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Gt=Object.prototype.toString,{Z_NO_FLUSH:Bt,Z_SYNC_FLUSH:Rt,Z_FULL_FLUSH:Ft,Z_FINISH:Vt,Z_OK:Nt,Z_STREAM_END:Kt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Zt,Z_DEFLATED:Ht}=Me;function Yt(e){this.options=Pt.assign({level:jt,method:Ht,chunkSize:16384,windowBits:15,memLevel:8,strategy:Zt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zt,this.strm.avail_out=0;let i=Dt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Nt)throw new Error(Pe[i]);if(t.header&&Dt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Lt.string2buf(t.dictionary):"[object ArrayBuffer]"===Gt.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Dt.deflateSetDictionary(this.strm,e),i!==Nt)throw new Error(Pe[i]);this._dict_set=!0}}Yt.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Vt:Bt,"string"==typeof e?i.input=Lt.string2buf(e):"[object ArrayBuffer]"===Gt.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(s===Rt||s===Ft)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=Dt.deflate(i,s),n===Kt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=Dt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Nt;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Yt.prototype.onData=function(e){this.chunks.push(e)},Yt.prototype.onEnd=function(e){e===Nt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const Wt=16209;var Xt=function(e,t){let i,r,n,s,a,o,l,h,f,c,u,d,g,m,p,w,y,_,b,v,k,x,T,A;const S=e.state;i=e.next_in,T=e.input,r=i+(e.avail_in-5),n=e.next_out,A=e.output,s=n-(t-e.avail_out),a=n+(e.avail_out-257),o=S.dmax,l=S.wsize,h=S.whave,f=S.wnext,c=S.window,u=S.hold,d=S.bits,g=S.lencode,m=S.distcode,p=(1<<S.lenbits)-1,w=(1<<S.distbits)-1;e:do{d<15&&(u+=T[i++]<<d,d+=8,u+=T[i++]<<d,d+=8),y=g[u&p];t:for(;;){if(_=y>>>24,u>>>=_,d-=_,_=y>>>16&255,0===_)A[n++]=65535&y;else{if(!(16&_)){if(0==(64&_)){y=g[(65535&y)+(u&(1<<_)-1)];continue t}if(32&_){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Wt;break e}b=65535&y,_&=15,_&&(d<_&&(u+=T[i++]<<d,d+=8),b+=u&(1<<_)-1,u>>>=_,d-=_),d<15&&(u+=T[i++]<<d,d+=8,u+=T[i++]<<d,d+=8),y=m[u&w];i:for(;;){if(_=y>>>24,u>>>=_,d-=_,_=y>>>16&255,!(16&_)){if(0==(64&_)){y=m[(65535&y)+(u&(1<<_)-1)];continue i}e.msg="invalid distance code",S.mode=Wt;break e}if(v=65535&y,_&=15,d<_&&(u+=T[i++]<<d,d+=8,d<_&&(u+=T[i++]<<d,d+=8)),v+=u&(1<<_)-1,v>o){e.msg="invalid distance too far back",S.mode=Wt;break e}if(u>>>=_,d-=_,_=n-s,v>_){if(_=v-_,_>h&&S.sane){e.msg="invalid distance too far back",S.mode=Wt;break e}if(k=0,x=c,0===f){if(k+=l-_,_<b){b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}}else if(f<_){if(k+=l+f-_,_-=f,_<b){b-=_;do{A[n++]=c[k++]}while(--_);if(k=0,f<b){_=f,b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}}}else if(k+=f-_,_<b){b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}for(;b>2;)A[n++]=x[k++],A[n++]=x[k++],A[n++]=x[k++],b-=3;b&&(A[n++]=x[k++],b>1&&(A[n++]=x[k++]))}else{k=n-v;do{A[n++]=A[k++],A[n++]=A[k++],A[n++]=A[k++],b-=3}while(b>2);b&&(A[n++]=A[k++],b>1&&(A[n++]=A[k++]))}break}}break}}while(i<r&&n<a);b=d>>3,i-=b,d-=b<<3,u&=(1<<d)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<a?a-n+257:257-(n-a),S.hold=u,S.bits=d};const $t=15,qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Jt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Qt=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ei=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ti=(e,t,i,r,n,s,a,o)=>{const l=o.bits;let h,f,c,u,d,g,m=0,p=0,w=0,y=0,_=0,b=0,v=0,k=0,x=0,T=0,A=null;const S=new Uint16Array(16),I=new Uint16Array(16);let U,C,D,E=null;for(m=0;m<=$t;m++)S[m]=0;for(p=0;p<r;p++)S[t[i+p]]++;for(_=l,y=$t;y>=1&&0===S[y];y--);if(_>y&&(_=y),0===y)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(w=1;w<y&&0===S[w];w++);for(_<w&&(_=w),k=1,m=1;m<=$t;m++)if(k<<=1,k-=S[m],k<0)return-1;if(k>0&&(0===e||1!==y))return-1;for(I[1]=0,m=1;m<$t;m++)I[m+1]=I[m]+S[m];for(p=0;p<r;p++)0!==t[i+p]&&(a[I[t[i+p]]++]=p);if(0===e?(A=E=a,g=20):1===e?(A=qt,E=Jt,g=257):(A=Qt,E=ei,g=0),T=0,p=0,m=w,d=s,b=_,v=0,c=-1,x=1<<_,u=x-1,1===e&&x>852||2===e&&x>592)return 1;for(;;){U=m-v,a[p]+1<g?(C=0,D=a[p]):a[p]>=g?(C=E[a[p]-g],D=A[a[p]-g]):(C=96,D=0),h=1<<m-v,f=1<<b,w=f;do{f-=h,n[d+(T>>v)+f]=U<<24|C<<16|D|0}while(0!==f);for(h=1<<m-1;T&h;)h>>=1;if(0!==h?(T&=h-1,T+=h):T=0,p++,0==--S[m]){if(m===y)break;m=t[i+a[p]]}if(m>_&&(T&u)!==c){for(0===v&&(v=_),d+=w,b=m-v,k=1<<b;b+v<y&&(k-=S[b+v],!(k<=0));)b++,k<<=1;if(x+=1<<b,1===e&&x>852||2===e&&x>592)return 1;c=T&u,n[c]=_<<24|b<<16|d-s|0}}return 0!==T&&(n[d+T]=m-v<<24|64<<16|0),o.bits=_,0};const{Z_FINISH:ii,Z_BLOCK:ri,Z_TREES:ni,Z_OK:si,Z_STREAM_END:ai,Z_NEED_DICT:oi,Z_STREAM_ERROR:li,Z_DATA_ERROR:hi,Z_MEM_ERROR:fi,Z_BUF_ERROR:ci,Z_DEFLATED:ui}=Me,di=16180,gi=16190,mi=16191,pi=16192,wi=16194,yi=16199,_i=16200,bi=16206,vi=16209,ki=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function xi(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ti=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<di||t.mode>16211?1:0},Ai=e=>{if(Ti(e))return li;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=di,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,si},Si=e=>{if(Ti(e))return li;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ai(e)},Ii=(e,t)=>{let i;if(Ti(e))return li;const r=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?li:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,Si(e))},Ui=(e,t)=>{if(!e)return li;const i=new xi;e.state=i,i.strm=e,i.window=null,i.mode=di;const r=Ii(e,t);return r!==si&&(e.state=null),r};let Ci,Di,Ei=!0;const Pi=e=>{if(Ei){Ci=new Int32Array(512),Di=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ti(1,e.lens,0,288,Ci,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ti(2,e.lens,0,32,Di,0,e.work,{bits:5}),Ei=!1}e.lencode=Ci,e.lenbits=9,e.distcode=Di,e.distbits=5},Mi=(e,t,i,r)=>{let n;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>r&&(n=r),s.window.set(t.subarray(i-r,i-r+n),s.wnext),(r-=n)?(s.window.set(t.subarray(i-r,i),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var Oi={inflateReset:Si,inflateReset2:Ii,inflateResetKeep:Ai,inflateInit:e=>Ui(e,15),inflateInit2:Ui,inflate:(e,t)=>{let i,r,n,s,a,o,l,h,f,c,u,d,g,m,p,w,y,_,b,v,k,x,T=0;const A=new Uint8Array(4);let S,I;const U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ti(e)||!e.output||!e.input&&0!==e.avail_in)return li;i=e.state,i.mode===mi&&(i.mode=pi),a=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,c=o,u=l,x=si;e:for(;;)switch(i.mode){case di:if(0===i.wrap){i.mode=pi;break}for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(2&i.wrap&&35615===h){0===i.wbits&&(i.wbits=15),i.check=0,A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0),h=0,f=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",i.mode=vi;break}if((15&h)!==ui){e.msg="unknown compression method",i.mode=vi;break}if(h>>>=4,f-=4,k=8+(15&h),0===i.wbits&&(i.wbits=k),k>15||k>i.wbits){e.msg="invalid window size",i.mode=vi;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&h?16189:mi,h=0,f=0;break;case 16181:for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(i.flags=h,(255&i.flags)!==ui){e.msg="unknown compression method",i.mode=vi;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=vi;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0,i.mode=16182;case 16182:for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.head&&(i.head.time=h),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,i.check=Ee(i.check,A,4,0)),h=0,f=0,i.mode=16183;case 16183:for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0,i.mode=16184;case 16184:if(1024&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(d=i.length,d>o&&(d=o),d&&(i.head&&(k=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(s,s+d),k)),512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===o)break e;d=0;do{k=r[s+d++],i.head&&k&&i.length<65536&&(i.head.name+=String.fromCharCode(k))}while(k&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,k)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===o)break e;d=0;do{k=r[s+d++],i.head&&k&&i.length<65536&&(i.head.comment+=String.fromCharCode(k))}while(k&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,k)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(4&i.wrap&&h!==(65535&i.check)){e.msg="header crc mismatch",i.mode=vi;break}h=0,f=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mi;break;case 16189:for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}e.adler=i.check=ki(h),h=0,f=0,i.mode=gi;case gi:if(0===i.havedict)return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,oi;e.adler=i.check=1,i.mode=mi;case mi:if(t===ri||t===ni)break e;case pi:if(i.last){h>>>=7&f,f-=7&f,i.mode=bi;break}for(;f<3;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}switch(i.last=1&h,h>>>=1,f-=1,3&h){case 0:i.mode=16193;break;case 1:if(Pi(i),i.mode=yi,t===ni){h>>>=2,f-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=vi}h>>>=2,f-=2;break;case 16193:for(h>>>=7&f,f-=7&f;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if((65535&h)!=(h>>>16^65535)){e.msg="invalid stored block lengths",i.mode=vi;break}if(i.length=65535&h,h=0,f=0,i.mode=wi,t===ni)break e;case wi:i.mode=16195;case 16195:if(d=i.length,d){if(d>o&&(d=o),d>l&&(d=l),0===d)break e;n.set(r.subarray(s,s+d),a),o-=d,s+=d,l-=d,a+=d,i.length-=d;break}i.mode=mi;break;case 16196:for(;f<14;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(i.nlen=257+(31&h),h>>>=5,f-=5,i.ndist=1+(31&h),h>>>=5,f-=5,i.ncode=4+(15&h),h>>>=4,f-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=vi;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;f<3;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.lens[U[i.have++]]=7&h,h>>>=3,f-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},x=ti(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,x){e.msg="invalid code lengths set",i.mode=vi;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;T=i.lencode[h&(1<<i.lenbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(y<16)h>>>=p,f-=p,i.lens[i.have++]=y;else{if(16===y){for(I=p+2;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(h>>>=p,f-=p,0===i.have){e.msg="invalid bit length repeat",i.mode=vi;break}k=i.lens[i.have-1],d=3+(3&h),h>>>=2,f-=2}else if(17===y){for(I=p+3;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=p,f-=p,k=0,d=3+(7&h),h>>>=3,f-=3}else{for(I=p+7;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=p,f-=p,k=0,d=11+(127&h),h>>>=7,f-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=vi;break}for(;d--;)i.lens[i.have++]=k}}if(i.mode===vi)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=vi;break}if(i.lenbits=9,S={bits:i.lenbits},x=ti(1,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,x){e.msg="invalid literal/lengths set",i.mode=vi;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},x=ti(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,x){e.msg="invalid distances set",i.mode=vi;break}if(i.mode=yi,t===ni)break e;case yi:i.mode=_i;case _i:if(o>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,Xt(e,u),a=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,i.mode===mi&&(i.back=-1);break}for(i.back=0;T=i.lencode[h&(1<<i.lenbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(w&&0==(240&w)){for(_=p,b=w,v=y;T=i.lencode[v+((h&(1<<_+b)-1)>>_)],p=T>>>24,w=T>>>16&255,y=65535&T,!(_+p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=_,f-=_,i.back+=_}if(h>>>=p,f-=p,i.back+=p,i.length=y,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=mi;break}if(64&w){e.msg="invalid literal/length code",i.mode=vi;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;T=i.distcode[h&(1<<i.distbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(0==(240&w)){for(_=p,b=w,v=y;T=i.distcode[v+((h&(1<<_+b)-1)>>_)],p=T>>>24,w=T>>>16&255,y=65535&T,!(_+p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=_,f-=_,i.back+=_}if(h>>>=p,f-=p,i.back+=p,64&w){e.msg="invalid distance code",i.mode=vi;break}i.offset=y,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=vi;break}i.mode=16204;case 16204:if(0===l)break e;if(d=u-l,i.offset>d){if(d=i.offset-d,d>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=vi;break}d>i.wnext?(d-=i.wnext,g=i.wsize-d):g=i.wnext-d,d>i.length&&(d=i.length),m=i.window}else m=n,g=a-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{n[a++]=m[g++]}while(--d);0===i.length&&(i.mode=_i);break;case 16205:if(0===l)break e;n[a++]=i.length,l--,i.mode=_i;break;case bi:if(i.wrap){for(;f<32;){if(0===o)break e;o--,h|=r[s++]<<f,f+=8}if(u-=l,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ee(i.check,n,u,a-u):Ce(i.check,n,u,a-u)),u=l,4&i.wrap&&(i.flags?h:ki(h))!==i.check){e.msg="incorrect data check",i.mode=vi;break}h=0,f=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(4&i.wrap&&h!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=vi;break}h=0,f=0}i.mode=16208;case 16208:x=ai;break e;case vi:x=hi;break e;case 16210:return fi;default:return li}return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,(i.wsize||u!==e.avail_out&&i.mode<vi&&(i.mode<bi||t!==ii))&&Mi(e,e.output,e.next_out,u-e.avail_out),c-=e.avail_in,u-=e.avail_out,e.total_in+=c,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ee(i.check,n,u,e.next_out-u):Ce(i.check,n,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===mi?128:0)+(i.mode===yi||i.mode===wi?256:0),(0===c&&0===u||t===ii)&&x===si&&(x=ci),x},inflateEnd:e=>{if(Ti(e))return li;let t=e.state;return t.window&&(t.window=null),e.state=null,si},inflateGetHeader:(e,t)=>{if(Ti(e))return li;const i=e.state;return 0==(2&i.wrap)?li:(i.head=t,t.done=!1,si)},inflateSetDictionary:(e,t)=>{const i=t.length;let r,n,s;return Ti(e)?li:(r=e.state,0!==r.wrap&&r.mode!==gi?li:r.mode===gi&&(n=1,n=Ce(n,t,i,0),n!==r.check)?hi:(s=Mi(e,t,i,i),s?(r.mode=16210,fi):(r.havedict=1,si)))},inflateInfo:"pako inflate (from Nodeca project)"};var Li=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const zi=Object.prototype.toString,{Z_NO_FLUSH:Gi,Z_FINISH:Bi,Z_OK:Ri,Z_STREAM_END:Fi,Z_NEED_DICT:Vi,Z_STREAM_ERROR:Ni,Z_DATA_ERROR:Ki,Z_MEM_ERROR:ji}=Me;function Zi(e){this.options=Pt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zt,this.strm.avail_out=0;let i=Oi.inflateInit2(this.strm,t.windowBits);if(i!==Ri)throw new Error(Pe[i]);if(this.header=new Li,Oi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Lt.string2buf(t.dictionary):"[object ArrayBuffer]"===zi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Oi.inflateSetDictionary(this.strm,t.dictionary),i!==Ri)))throw new Error(Pe[i])}function Hi(e,t){const i=new Zi(t);if(i.push(e),i.err)throw i.msg||Pe[i.err];return i.result}Zi.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Bi:Gi,"[object ArrayBuffer]"===zi.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),s=Oi.inflate(i,a),s===Vi&&n&&(s=Oi.inflateSetDictionary(i,n),s===Ri?s=Oi.inflate(i,a):s===Ki&&(s=Vi));i.avail_in>0&&s===Fi&&i.state.wrap>0&&0!==e[i.next_in];)Oi.inflateReset(i),s=Oi.inflate(i,a);switch(s){case Ni:case Ki:case Vi:case ji:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===Fi))if("string"===this.options.to){let e=Lt.utf8border(i.output,i.next_out),t=i.next_out-e,n=Lt.buf2string(i.output,e);i.next_out=t,i.avail_out=r-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Ri||0!==o){if(s===Fi)return s=Oi.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Zi.prototype.onData=function(e){this.chunks.push(e)},Zi.prototype.onEnd=function(e){e===Ri&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Yi={Inflate:Zi,inflate:Hi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Hi(e,t)},ungzip:Hi,constants:Me};const{Inflate:Wi,inflate:Xi,inflateRaw:$i,ungzip:qi}=Yi;var Ji=Xi,Qi={exports:{}};!function(e){function t(e){var t,i,r,n,s,a=Math.floor,o=new Array(64),l=new Array(64),h=new Array(64),f=new Array(64),c=new Array(65535),u=new Array(65535),d=new Array(64),g=new Array(64),m=[],p=0,w=7,y=new Array(64),_=new Array(64),b=new Array(64),v=new Array(256),k=new Array(2048),x=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],T=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],A=[0,1,2,3,4,5,6,7,8,9,10,11],S=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],I=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],U=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],C=[0,1,2,3,4,5,6,7,8,9,10,11],D=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],E=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function P(e,t){for(var i=0,r=0,n=new Array,s=1;s<=16;s++){for(var a=1;a<=e[s];a++)n[t[r]]=[],n[t[r]][0]=i,n[t[r]][1]=s,r++,i++;i*=2}return n}function M(e){for(var t=e[0],i=e[1]-1;i>=0;)t&1<<i&&(p|=1<<w),i--,--w<0&&(255==p?(O(255),O(0)):O(p),w=7,p=0)}function O(e){m.push(e)}function L(e){O(e>>8&255),O(255&e)}function z(e,t,i,r,n){for(var s,a=n[0],o=n[240],l=function(e,t){var i,r,n,s,a,o,l,h,f,c,u=0;for(f=0;f<8;++f){i=e[u],r=e[u+1],n=e[u+2],s=e[u+3],a=e[u+4],o=e[u+5],l=e[u+6];var g=i+(h=e[u+7]),m=i-h,p=r+l,w=r-l,y=n+o,_=n-o,b=s+a,v=s-a,k=g+b,x=g-b,T=p+y,A=p-y;e[u]=k+T,e[u+4]=k-T;var S=.707106781*(A+x);e[u+2]=x+S,e[u+6]=x-S;var I=.382683433*((k=v+_)-(A=w+m)),U=.5411961*k+I,C=1.306562965*A+I,D=.707106781*(T=_+w),E=m+D,P=m-D;e[u+5]=P+U,e[u+3]=P-U,e[u+1]=E+C,e[u+7]=E-C,u+=8}for(u=0,f=0;f<8;++f){i=e[u],r=e[u+8],n=e[u+16],s=e[u+24],a=e[u+32],o=e[u+40],l=e[u+48];var M=i+(h=e[u+56]),O=i-h,L=r+l,z=r-l,G=n+o,B=n-o,R=s+a,F=s-a,V=M+R,N=M-R,K=L+G,j=L-G;e[u]=V+K,e[u+32]=V-K;var Z=.707106781*(j+N);e[u+16]=N+Z,e[u+48]=N-Z;var H=.382683433*((V=F+B)-(j=z+O)),Y=.5411961*V+H,W=1.306562965*j+H,X=.707106781*(K=B+z),$=O+X,q=O-X;e[u+40]=q+Y,e[u+24]=q-Y,e[u+8]=$+W,e[u+56]=$-W,u++}for(f=0;f<64;++f)c=e[f]*t[f],d[f]=c>0?c+.5|0:c-.5|0;return d}(e,t),h=0;h<64;++h)g[x[h]]=l[h];var f=g[0]-i;i=g[0],0==f?M(r[0]):(M(r[u[s=32767+f]]),M(c[s]));for(var m=63;m>0&&0==g[m];m--);if(0==m)return M(a),i;for(var p,w=1;w<=m;){for(var y=w;0==g[w]&&w<=m;++w);var _=w-y;if(_>=16){p=_>>4;for(var b=1;b<=p;++b)M(o);_&=15}s=32767+g[w],M(n[(_<<4)+u[s]]),M(c[s]),w++}return 63!=m&&M(a),i}function G(e){if(e<=0&&(e=1),e>100&&(e=100),s!=e){(function(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],i=0;i<64;i++){var r=a((t[i]*e+50)/100);r<1?r=1:r>255&&(r=255),o[x[i]]=r}for(var n=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],s=0;s<64;s++){var c=a((n[s]*e+50)/100);c<1?c=1:c>255&&(c=255),l[x[s]]=c}for(var u=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,g=0;g<8;g++)for(var m=0;m<8;m++)h[d]=1/(o[x[d]]*u[g]*u[m]*8),f[d]=1/(l[x[d]]*u[g]*u[m]*8),d++})(e<50?Math.floor(5e3/e):Math.floor(200-2*e)),s=e}}this.encode=function(e,s){var a;(new Date).getTime(),s&&G(s),m=new Array,p=0,w=7,L(65496),L(65504),L(16),O(74),O(70),O(73),O(70),O(0),O(1),O(1),O(0),L(1),L(1),O(0),O(0),void 0!==(a=e.comments)&&a.constructor===Array&&a.forEach((e=>{if("string"==typeof e){L(65534);var t,i=e.length;for(L(i+2),t=0;t<i;t++)O(e.charCodeAt(t))}})),function(e){if(e){L(65505),69===e[0]&&120===e[1]&&105===e[2]&&102===e[3]?L(e.length+2):(L(e.length+5+2),O(69),O(120),O(105),O(102),O(0));for(var t=0;t<e.length;t++)O(e[t])}}(e.exifBuffer),function(){L(65499),L(132),O(0);for(var e=0;e<64;e++)O(o[e]);O(1);for(var t=0;t<64;t++)O(l[t])}(),function(e,t){L(65472),L(17),O(8),L(t),L(e),O(3),O(1),O(17),O(0),O(2),O(17),O(1),O(3),O(17),O(1)}(e.width,e.height),function(){L(65476),L(418),O(0);for(var e=0;e<16;e++)O(T[e+1]);for(var t=0;t<=11;t++)O(A[t]);O(16);for(var i=0;i<16;i++)O(S[i+1]);for(var r=0;r<=161;r++)O(I[r]);O(1);for(var n=0;n<16;n++)O(U[n+1]);for(var s=0;s<=11;s++)O(C[s]);O(17);for(var a=0;a<16;a++)O(D[a+1]);for(var o=0;o<=161;o++)O(E[o])}(),L(65498),L(12),O(3),O(1),O(0),O(2),O(17),O(3),O(17),O(0),O(63),O(0);var c=0,u=0,d=0;p=0,w=7,this.encode.displayName="_encode_";for(var g,v,x,P,B,R,F,V,N,K=e.data,j=e.width,Z=e.height,H=4*j,Y=0;Y<Z;){for(g=0;g<H;){for(R=B=H*Y+g,F=-1,V=0,N=0;N<64;N++)R=B+(V=N>>3)*H+(F=4*(7&N)),Y+V>=Z&&(R-=H*(Y+1+V-Z)),g+F>=H&&(R-=g+F-H+4),v=K[R++],x=K[R++],P=K[R++],y[N]=(k[v]+k[x+256>>0]+k[P+512>>0]>>16)-128,_[N]=(k[v+768>>0]+k[x+1024>>0]+k[P+1280>>0]>>16)-128,b[N]=(k[v+1280>>0]+k[x+1536>>0]+k[P+1792>>0]>>16)-128;c=z(y,h,c,t,r),u=z(_,f,u,i,n),d=z(b,f,d,i,n),g+=32}Y+=8}if(w>=0){var W=[];W[1]=w+1,W[0]=(1<<w+1)-1,M(W)}return L(65497),Buffer.from(m)},(new Date).getTime(),e||(e=50),function(){for(var e=String.fromCharCode,t=0;t<256;t++)v[t]=e(t)}(),t=P(T,A),i=P(U,C),r=P(S,I),n=P(D,E),function(){for(var e=1,t=2,i=1;i<=15;i++){for(var r=e;r<t;r++)u[32767+r]=i,c[32767+r]=[],c[32767+r][1]=i,c[32767+r][0]=r;for(var n=-(t-1);n<=-e;n++)u[32767+n]=i,c[32767+n]=[],c[32767+n][1]=i,c[32767+n][0]=t-1+n;e<<=1,t<<=1}}(),function(){for(var e=0;e<256;e++)k[e]=19595*e,k[e+256>>0]=38470*e,k[e+512>>0]=7471*e+32768,k[e+768>>0]=-11059*e,k[e+1024>>0]=-21709*e,k[e+1280>>0]=32768*e+8421375,k[e+1536>>0]=-27439*e,k[e+1792>>0]=-5329*e}(),G(e),(new Date).getTime()}Qi.exports=function(e,i){void 0===i&&(i=50);var r=new t(i),n=r.encode(e,i);return{data:n,width:e.width,height:e.height}}}();var er,tr,ir=Qi.exports,rr={exports:{}};er=rr,tr=function(){var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),t=4017,i=799,r=3406,n=2276,s=1567,a=3784,o=5793,l=2896;function h(){}function f(e,t){for(var i,r,n=0,s=[],a=16;a>0&&!e[a-1];)a--;s.push({children:[],index:0});var o,l=s[0];for(i=0;i<a;i++){for(r=0;r<e[i];r++){for((l=s.pop()).children[l.index]=t[n];l.index>0;){if(0===s.length)throw new Error("Could not recreate Huffman Table");l=s.pop()}for(l.index++,s.push(l);s.length<=i;)s.push(o={children:[],index:0}),l.children[l.index]=o.children,l=o;n++}i+1<a&&(s.push(o={children:[],index:0}),l.children[l.index]=o.children,l=o)}return s[0].children}function c(t,i,r,n,s,a,o,l,h,f){r.precision,r.samplesPerLine,r.scanLines;var c=r.mcusPerLine,u=r.progressive;r.maxH,r.maxV;var d=i,g=0,m=0;function p(){if(m>0)return m--,g>>m&1;if(255==(g=t[i++])){var e=t[i++];if(e)throw new Error("unexpected marker: "+(g<<8|e).toString(16))}return m=7,g>>>7}function w(e){for(var t,i=e;null!==(t=p());){if("number"==typeof(i=i[t]))return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function y(e){for(var t=0;e>0;){var i=p();if(null===i)return;t=t<<1|i,e--}return t}function _(e){var t=y(e);return t>=1<<e-1?t:t+(-1<<e)+1}var b,v=0,k=0;function x(e,t,i,r,n){var s=i%c,a=(i/c|0)*e.v+r,o=s*e.h+n;void 0===e.blocks[a]&&f.tolerantDecoding||t(e,e.blocks[a][o])}function T(e,t,i){var r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;void 0===e.blocks[r]&&f.tolerantDecoding||t(e,e.blocks[r][n])}var A,S,I,U,C,D,E=n.length;D=u?0===a?0===l?function(e,t){var i=w(e.huffmanTableDC),r=0===i?0:_(i)<<h;t[0]=e.pred+=r}:function(e,t){t[0]|=p()<<h}:0===l?function(t,i){if(v>0)v--;else for(var r=a,n=o;r<=n;){var s=w(t.huffmanTableAC),l=15&s,f=s>>4;if(0!==l)i[e[r+=f]]=_(l)*(1<<h),r++;else{if(f<15){v=y(f)+(1<<f)-1;break}r+=16}}}:function(t,i){for(var r=a,n=o,s=0;r<=n;){var l=e[r],f=i[l]<0?-1:1;switch(k){case 0:var c=w(t.huffmanTableAC),u=15&c;if(s=c>>4,0===u)s<15?(v=y(s)+(1<<s),k=4):(s=16,k=1);else{if(1!==u)throw new Error("invalid ACn encoding");b=_(u),k=s?2:3}continue;case 1:case 2:i[l]?i[l]+=(p()<<h)*f:0==--s&&(k=2==k?3:0);break;case 3:i[l]?i[l]+=(p()<<h)*f:(i[l]=b<<h,k=0);break;case 4:i[l]&&(i[l]+=(p()<<h)*f)}r++}4===k&&0==--v&&(k=0)}:function(t,i){var r=w(t.huffmanTableDC),n=0===r?0:_(r);i[0]=t.pred+=n;for(var s=1;s<64;){var a=w(t.huffmanTableAC),o=15&a,l=a>>4;if(0!==o)i[e[s+=l]]=_(o),s++;else{if(l<15)break;s+=16}}};var P,M,O,L,z=0;for(M=1==E?n[0].blocksPerLine*n[0].blocksPerColumn:c*r.mcusPerColumn,s||(s=M);z<M;){for(S=0;S<E;S++)n[S].pred=0;if(v=0,1==E)for(A=n[0],C=0;C<s;C++)T(A,D,z),z++;else for(C=0;C<s;C++){for(S=0;S<E;S++)for(O=(A=n[S]).h,L=A.v,I=0;I<L;I++)for(U=0;U<O;U++)x(A,D,z,I,U);if(++z===M)break}if(z===M)do{if(255===t[i]&&0!==t[i+1])break;i+=1}while(i<t.length-2);if(m=0,(P=t[i]<<8|t[i+1])<65280)throw new Error("marker was not found");if(!(P>=65488&&P<=65495))break;i+=2}return i-d}function u(e,h){var f,c,u=[],d=h.blocksPerLine,g=h.blocksPerColumn,m=d<<3,w=new Int32Array(64),y=new Uint8Array(64);function _(e,f,c){var u,d,g,m,p,w,y,_,b,v,k=h.quantizationTable,x=c;for(v=0;v<64;v++)x[v]=e[v]*k[v];for(v=0;v<8;++v){var T=8*v;0!=x[1+T]||0!=x[2+T]||0!=x[3+T]||0!=x[4+T]||0!=x[5+T]||0!=x[6+T]||0!=x[7+T]?(u=o*x[0+T]+128>>8,d=o*x[4+T]+128>>8,g=x[2+T],m=x[6+T],p=l*(x[1+T]-x[7+T])+128>>8,_=l*(x[1+T]+x[7+T])+128>>8,w=x[3+T]<<4,y=x[5+T]<<4,b=u-d+1>>1,u=u+d+1>>1,d=b,b=g*a+m*s+128>>8,g=g*s-m*a+128>>8,m=b,b=p-y+1>>1,p=p+y+1>>1,y=b,b=_+w+1>>1,w=_-w+1>>1,_=b,b=u-m+1>>1,u=u+m+1>>1,m=b,b=d-g+1>>1,d=d+g+1>>1,g=b,b=p*n+_*r+2048>>12,p=p*r-_*n+2048>>12,_=b,b=w*i+y*t+2048>>12,w=w*t-y*i+2048>>12,y=b,x[0+T]=u+_,x[7+T]=u-_,x[1+T]=d+y,x[6+T]=d-y,x[2+T]=g+w,x[5+T]=g-w,x[3+T]=m+p,x[4+T]=m-p):(b=o*x[0+T]+512>>10,x[0+T]=b,x[1+T]=b,x[2+T]=b,x[3+T]=b,x[4+T]=b,x[5+T]=b,x[6+T]=b,x[7+T]=b)}for(v=0;v<8;++v){var A=v;0!=x[8+A]||0!=x[16+A]||0!=x[24+A]||0!=x[32+A]||0!=x[40+A]||0!=x[48+A]||0!=x[56+A]?(u=o*x[0+A]+2048>>12,d=o*x[32+A]+2048>>12,g=x[16+A],m=x[48+A],p=l*(x[8+A]-x[56+A])+2048>>12,_=l*(x[8+A]+x[56+A])+2048>>12,w=x[24+A],y=x[40+A],b=u-d+1>>1,u=u+d+1>>1,d=b,b=g*a+m*s+2048>>12,g=g*s-m*a+2048>>12,m=b,b=p-y+1>>1,p=p+y+1>>1,y=b,b=_+w+1>>1,w=_-w+1>>1,_=b,b=u-m+1>>1,u=u+m+1>>1,m=b,b=d-g+1>>1,d=d+g+1>>1,g=b,b=p*n+_*r+2048>>12,p=p*r-_*n+2048>>12,_=b,b=w*i+y*t+2048>>12,w=w*t-y*i+2048>>12,y=b,x[0+A]=u+_,x[56+A]=u-_,x[8+A]=d+y,x[48+A]=d-y,x[16+A]=g+w,x[40+A]=g-w,x[24+A]=m+p,x[32+A]=m-p):(b=o*c[v+0]+8192>>14,x[0+A]=b,x[8+A]=b,x[16+A]=b,x[24+A]=b,x[32+A]=b,x[40+A]=b,x[48+A]=b,x[56+A]=b)}for(v=0;v<64;++v){var S=128+(x[v]+8>>4);f[v]=S<0?0:S>255?255:S}}p(m*g*8);for(var b=0;b<g;b++){var v=b<<3;for(f=0;f<8;f++)u.push(new Uint8Array(m));for(var k=0;k<d;k++){_(h.blocks[b][k],y,w);var x=0,T=k<<3;for(c=0;c<8;c++){var A=u[v+c];for(f=0;f<8;f++)A[T+f]=y[x++]}}}return u}function d(e){return e<0?0:e>255?255:e}h.prototype={load:function(e){var t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer",t.onload=function(){var e=new Uint8Array(t.response||t.mozResponseArrayBuffer);this.parse(e),this.onload&&this.onload()}.bind(this),t.send(null)},parse:function(t){var i=1e3*this.opts.maxResolutionInMP*1e3,r=0;function n(){var e=t[r]<<8|t[r+1];return r+=2,e}function s(e){var t,i,r=1,n=1;for(i in e.components)e.components.hasOwnProperty(i)&&(r<(t=e.components[i]).h&&(r=t.h),n<t.v&&(n=t.v));var s=Math.ceil(e.samplesPerLine/8/r),a=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];var o=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),h=s*t.h,f=a*t.v,c=[];p(f*h*256);for(var u=0;u<f;u++){for(var d=[],g=0;g<h;g++)d.push(new Int32Array(64));c.push(d)}t.blocksPerLine=o,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=s,e.mcusPerColumn=a}t.length;var a,o,l,h,d=null,g=null,m=[],w=[],y=[],_=[],b=n(),v=-1;if(this.comments=[],65496!=b)throw new Error("SOI not found");for(b=n();65497!=b;){switch(b){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var k=(l=void 0,h=void 0,l=n(),h=t.subarray(r,r+l-2),r+=h.length,h);if(65534===b){var x=String.fromCharCode.apply(null,k);this.comments.push(x)}65504===b&&74===k[0]&&70===k[1]&&73===k[2]&&70===k[3]&&0===k[4]&&(d={version:{major:k[5],minor:k[6]},densityUnits:k[7],xDensity:k[8]<<8|k[9],yDensity:k[10]<<8|k[11],thumbWidth:k[12],thumbHeight:k[13],thumbData:k.subarray(14,14+3*k[12]*k[13])}),65505===b&&69===k[0]&&120===k[1]&&105===k[2]&&102===k[3]&&0===k[4]&&(this.exifBuffer=k.subarray(5,k.length)),65518===b&&65===k[0]&&100===k[1]&&111===k[2]&&98===k[3]&&101===k[4]&&0===k[5]&&(g={version:k[6],flags0:k[7]<<8|k[8],flags1:k[9]<<8|k[10],transformCode:k[11]});break;case 65499:for(var T=n()+r-2;r<T;){var A=t[r++];p(256);var S=new Int32Array(64);if(A>>4==0)for(W=0;W<64;W++)S[e[W]]=t[r++];else{if(A>>4!=1)throw new Error("DQT: invalid table spec");for(W=0;W<64;W++)S[e[W]]=n()}m[15&A]=S}break;case 65472:case 65473:case 65474:n(),(a={}).extended=65473===b,a.progressive=65474===b,a.precision=t[r++],a.scanLines=n(),a.samplesPerLine=n(),a.components={},a.componentsOrder=[];var I=a.scanLines*a.samplesPerLine;if(I>i){var U=Math.ceil((I-i)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${U}MP`)}var C,D=t[r++];for(H=0;H<D;H++){C=t[r];var E=t[r+1]>>4,P=15&t[r+1],M=t[r+2];if(E<=0||P<=0)throw new Error("Invalid sampling factor, expected values above 0");a.componentsOrder.push(C),a.components[C]={h:E,v:P,quantizationIdx:M},r+=3}s(a),w.push(a);break;case 65476:var O=n();for(H=2;H<O;){var L=t[r++],z=new Uint8Array(16),G=0;for(W=0;W<16;W++,r++)G+=z[W]=t[r];p(16+G);var B=new Uint8Array(G);for(W=0;W<G;W++,r++)B[W]=t[r];H+=17+G,(L>>4==0?_:y)[15&L]=f(z,B)}break;case 65501:n(),o=n();break;case 65500:n(),n();break;case 65498:n();var R=t[r++],F=[];for(H=0;H<R;H++){X=a.components[t[r++]];var V=t[r++];X.huffmanTableDC=_[V>>4],X.huffmanTableAC=y[15&V],F.push(X)}var N=t[r++],K=t[r++],j=t[r++],Z=c(t,r,a,F,o,N,K,j>>4,15&j,this.opts);r+=Z;break;case 65535:255!==t[r]&&r--;break;default:if(255==t[r-3]&&t[r-2]>=192&&t[r-2]<=254){r-=3;break}if(224===b||225==b){if(-1!==v)throw new Error(`first unknown JPEG marker at offset ${v.toString(16)}, second unknown JPEG marker ${b.toString(16)} at offset ${(r-1).toString(16)}`);v=r-1;const e=n();if(255===t[r+e-2]){r+=e-2;break}}throw new Error("unknown JPEG marker "+b.toString(16))}b=n()}if(1!=w.length)throw new Error("only single frame JPEGs supported");for(var H=0;H<w.length;H++){var Y=w[H].components;for(var W in Y)Y[W].quantizationTable=m[Y[W].quantizationIdx],delete Y[W].quantizationIdx}for(this.width=a.samplesPerLine,this.height=a.scanLines,this.jfif=d,this.adobe=g,this.components=[],H=0;H<a.componentsOrder.length;H++){var X=a.components[a.componentsOrder[H]];this.components.push({lines:u(0,X),scaleX:X.h/a.maxH,scaleY:X.v/a.maxV})}},getData:function(e,t){var i,r,n,s,a,o,l,h,f,c,u,g,m,w,y,_,b,v,k,x,T,A=this.width/e,S=this.height/t,I=0,U=e*t*this.components.length;p(U);var C=new Uint8Array(U);switch(this.components.length){case 1:for(i=this.components[0],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],f=0;f<e;f++)u=a[0|f*i.scaleX*A],C[I++]=u;break;case 2:for(i=this.components[0],r=this.components[1],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],f=0;f<e;f++)u=a[0|f*i.scaleX*A],C[I++]=u,u=o[0|f*r.scaleX*A],C[I++]=u;break;case 3:for(T=!0,this.adobe&&this.adobe.transformCode?T=!0:void 0!==this.opts.colorTransform&&(T=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],l=n.lines[0|c*n.scaleY*S],f=0;f<e;f++)T?(u=a[0|f*i.scaleX*A],g=o[0|f*r.scaleX*A],v=d(u+1.402*((m=l[0|f*n.scaleX*A])-128)),k=d(u-.3441363*(g-128)-.71413636*(m-128)),x=d(u+1.772*(g-128))):(v=a[0|f*i.scaleX*A],k=o[0|f*r.scaleX*A],x=l[0|f*n.scaleX*A]),C[I++]=v,C[I++]=k,C[I++]=x;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(T=!1,this.adobe&&this.adobe.transformCode?T=!0:void 0!==this.opts.colorTransform&&(T=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],s=this.components[3],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],l=n.lines[0|c*n.scaleY*S],h=s.lines[0|c*s.scaleY*S],f=0;f<e;f++)T?(u=a[0|f*i.scaleX*A],g=o[0|f*r.scaleX*A],m=l[0|f*n.scaleX*A],w=h[0|f*s.scaleX*A],y=255-d(u+1.402*(m-128)),_=255-d(u-.3441363*(g-128)-.71413636*(m-128)),b=255-d(u+1.772*(g-128))):(y=a[0|f*i.scaleX*A],_=o[0|f*r.scaleX*A],b=l[0|f*n.scaleX*A],w=h[0|f*s.scaleX*A]),C[I++]=255-y,C[I++]=255-_,C[I++]=255-b,C[I++]=255-w;break;default:throw new Error("Unsupported color mode")}return C},copyToImageData:function(e,t){var i,r,n,s,a,o,l,h,f,c=e.width,u=e.height,g=e.data,m=this.getData(c,u),p=0,w=0;switch(this.components.length){case 1:for(r=0;r<u;r++)for(i=0;i<c;i++)n=m[p++],g[w++]=n,g[w++]=n,g[w++]=n,t&&(g[w++]=255);break;case 3:for(r=0;r<u;r++)for(i=0;i<c;i++)l=m[p++],h=m[p++],f=m[p++],g[w++]=l,g[w++]=h,g[w++]=f,t&&(g[w++]=255);break;case 4:for(r=0;r<u;r++)for(i=0;i<c;i++)a=m[p++],o=m[p++],n=m[p++],l=255-d(a*(1-(s=m[p++])/255)+s),h=255-d(o*(1-s/255)+s),f=255-d(n*(1-s/255)+s),g[w++]=l,g[w++]=h,g[w++]=f,t&&(g[w++]=255);break;default:throw new Error("Unsupported color mode")}}};var g=0,m=0;function p(e=0){var t=g+e;if(t>m){var i=Math.ceil((t-m)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${i}MB`)}g=t}return h.resetMaxMemoryUsage=function(e){g=0,m=e},h.getBytesAllocated=function(){return g},h.requestMemoryAllocation=p,h}(),er.exports=function(e,t={}){var i={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512,...t},r=new Uint8Array(e),n=new tr;n.opts=i,tr.resetMaxMemoryUsage(1024*i.maxMemoryUsageInMB*1024),n.parse(r);var s=i.formatAsRGBA?4:3,a=n.width*n.height*s;try{tr.requestMemoryAllocation(a);var o={width:n.width,height:n.height,exifBuffer:n.exifBuffer,data:i.useTArray?new Uint8Array(a):Buffer.alloc(a)};n.comments.length>0&&(o.comments=n.comments)}catch(e){if(e instanceof RangeError)throw new Error("Could not allocate enough memory for the image. Required: "+a);if(e instanceof ReferenceError&&"Buffer is not defined"===e.message)throw new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true");throw e}return n.copyToImageData(o,i.formatAsRGBA),o};var nr,sr=u({encode:ir,decode:rr.exports}),ar="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),nr=new ar(4),ar!=Float32Array&&(nr[0]=0,nr[1]=0,nr[2]=0,nr[3]=0),function(){var e=function(){var e=new ar(2);return ar!=Float32Array&&(e[0]=0,e[1]=0),e}()}(),function(){var e=function(){var e=new ar(3);return ar!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}()}();const or=Math.PI,lr=or/4,hr=180/or;function fr(e,t){let i=e.length-t,r=0;do{for(let i=t;i>0;i--)e[r+t]+=e[r],r++;i-=t}while(i>0)}function cr(e,t,i){let r=0,n=e.length;const s=n/i;for(;n>t;){for(let i=t;i>0;--i)e[r+t]+=e[r],++r;n-=t}const a=e.slice();for(let t=0;t<s;++t)for(let r=0;r<i;++r)e[i*t+r]=a[(i-r-1)*s+t]}let ur=class{async decode(e,t){const i=await this.decodeBlock(t),r=e.Predictor||1;if(1!==r){const t=!e.StripOffsets;return function(e,t,i,r,n,s){if(!t||1===t)return e;for(let e=0;e<n.length;++e){if(n[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[e]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=n[0]/8,o=2===s?1:n.length;for(let s=0;s<r&&!(s*o*i*a>=e.byteLength);++s){let r;if(2===t){switch(n[0]){case 8:r=new Uint8Array(e,s*o*i*a,o*i*a);break;case 16:r=new Uint16Array(e,s*o*i*a,o*i*a/2);break;case 32:r=new Uint32Array(e,s*o*i*a,o*i*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}fr(r,o)}else 3===t&&(r=new Uint8Array(e,s*o*i*a,o*i*a),cr(r,o,a))}return e}(i,r,t?e.TileWidth:e.ImageWidth,t?e.TileLength:e.RowsPerStrip||e.ImageLength,e.BitsPerSample,e.PlanarConfiguration)}return i}};const dr=257;function gr(e,t){for(let i=t.length-1;i>=0;i--)e.push(t[i]);return e}function mr(e){const t=new Uint16Array(4093),i=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,i[e]=e;let r=258,n=9,s=0;function a(){r=258,n=9}function o(e){const t=function(e,t,i){const r=t%8,n=Math.floor(t/8),s=8-r,a=t+i-8*(n+1);let o=8*(n+2)-(t+i);const l=8*(n+2)-t;if(o=Math.max(0,o),n>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),dr;let h=e[n]&2**(8-r)-1;h<<=i-s;let f=h;if(n+1<e.length){let t=e[n+1]>>>o;t<<=Math.max(0,i-l),f+=t}if(a>8&&n+2<e.length){const r=8*(n+3)-(t+i);f+=e[n+2]>>>r}return f}(e,s,n);return s+=n,t}function l(e,n){return i[r]=n,t[r]=e,r++,r-1}function h(e){const r=[];for(let n=e;4096!==n;n=t[n])r.push(i[n]);return r}const f=[];a();const c=new Uint8Array(e);let u,d=o(c);for(;d!==dr;){if(256===d){for(a(),d=o(c);256===d;)d=o(c);if(d===dr)break;if(d>256)throw new Error(`corrupted code at scanline ${d}`);gr(f,h(d)),u=d}else if(d<r){const e=h(d);gr(f,e),l(u,e[e.length-1]),u=d}else{const e=h(u);if(!e)throw new Error(`Bogus entry. Not in dictionary,\n ${u} / ${r},\n position: ${s}`);gr(f,e),f.push(e[e.length-1]),l(u,e[e.length-1]),u=d}r+1>=2**n&&(12===n?u=void 0:n++),d=o(c)}return new Uint8Array(f)}let pr=class extends ur{decodeBlock(e){return mr(e).buffer}};function wr(e){return(t,...i)=>_r(e,t,i)}function yr(e,t){return wr(xr(e,t).get)}const{apply:_r,construct:br,defineProperty:vr,get:kr,getOwnPropertyDescriptor:xr,getPrototypeOf:Tr,has:Ar,ownKeys:Sr,set:Ir,setPrototypeOf:Ur}=Reflect,{iterator:Cr,species:Dr,toStringTag:Er,for:Pr}=Symbol,Mr=Object,{create:Or,defineProperty:Lr,freeze:zr,is:Gr}=Mr,Br=Array.prototype[Cr],Rr=wr(Br),Fr=ArrayBuffer;yr(Fr.prototype,"byteLength");const Vr="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:null;Vr&&yr(Vr.prototype,"byteLength");const Nr=Tr(Uint8Array);Nr.from;const Kr=Nr.prototype;Kr[Cr],wr(Kr.keys),wr(Kr.values),wr(Kr.entries),wr(Kr.set),wr(Kr.reverse),wr(Kr.fill),wr(Kr.copyWithin),wr(Kr.sort),wr(Kr.slice),wr(Kr.subarray),yr(Kr,"buffer"),yr(Kr,"byteOffset"),yr(Kr,"length"),yr(Kr,Er);const jr=Uint32Array,Zr=Float32Array,Hr=Tr([][Cr]()),Yr=wr(Hr.next),Wr=wr(function*(){}().next),Xr=Tr(Hr),$r=wr(DataView.prototype.getUint16),qr=WeakMap,Jr=qr.prototype,Qr=wr(Jr.get),en=wr(Jr.set),tn=new qr,rn=Or(null,{next:{value:function(){const e=Qr(tn,this);return Yr(e)}},[Cr]:{value:function(){return this}}});const nn=new qr,sn=Or(Xr,{next:{value:function(){const e=Qr(nn,this);return Wr(e)},writable:!0,configurable:!0}});for(const e of Sr(Hr))"next"!==e&&Lr(sn,e,xr(Hr,e));const an=new Fr(4),on=new Zr(an),ln=new jr(an),hn=new jr(512),fn=new jr(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(hn[e]=0,hn[256|e]=32768,fn[e]=24,fn[256|e]=24):t<-14?(hn[e]=1024>>-t-14,hn[256|e]=1024>>-t-14|32768,fn[e]=-t-1,fn[256|e]=-t-1):t<=15?(hn[e]=t+15<<10,hn[256|e]=t+15<<10|32768,fn[e]=13,fn[256|e]=13):t<128?(hn[e]=31744,hn[256|e]=64512,fn[e]=24,fn[256|e]=24):(hn[e]=31744,hn[256|e]=64512,fn[e]=13,fn[256|e]=13)}const cn=new jr(2048),un=new jr(64),dn=new jr(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;0==(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,cn[e]=t|i}for(let e=1024;e<2048;++e)cn[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)un[e]=e<<23;un[31]=1199570944,un[32]=2147483648;for(let e=33;e<63;++e)un[e]=2147483648+(e-32<<23);un[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(dn[e]=1024);function gn(e,t,...i){return function(e){const t=e>>10;return ln[0]=cn[dn[t]+(1023&e)]+un[t],on[0]}($r(e,t,...function(e){if(e[Cr]===Br&&Hr.next===Yr)return e;const t=Or(rn);return en(tn,t,Rr(e)),t}(i)))}var mn={exports:{}};function pn(e,t,i){const r=i&&i.debug||!1;r&&console.log("[xml-utils] getting "+t+" in "+e);const n="object"==typeof e?e.outer:e,s=n.slice(0,n.indexOf(">")+1),a=['"',"'"];for(let e=0;e<a.length;e++){const i=a[e],n=t+"\\="+i+"([^"+i+"]*)"+i;r&&console.log("[xml-utils] pattern:",n);const o=new RegExp(n).exec(s);if(r&&console.log("[xml-utils] match:",o),o)return o[1]}}mn.exports=pn,mn.exports.default=pn;var wn=u(mn.exports),yn={exports:{}},_n={exports:{}},bn={exports:{}};function vn(e,t,i){const r=new RegExp(t).exec(e.slice(i));return r?i+r.index:-1}bn.exports=vn,bn.exports.default=vn;var kn=bn.exports,xn={exports:{}};function Tn(e,t,i){const r=new RegExp(t).exec(e.slice(i));return r?i+r.index+r[0].length-1:-1}xn.exports=Tn,xn.exports.default=Tn;var An=xn.exports,Sn={exports:{}};function In(e,t){const i=new RegExp(t,"g"),r=e.match(i);return r?r.length:0}Sn.exports=In,Sn.exports.default=In;var Un=Sn.exports;const Cn=kn,Dn=An,En=Un;function Pn(e,t,i){const r=i&&i.debug||!1,n=!(i&&!1===typeof i.nested),s=i&&i.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",t," and ",i);const a=Cn(e,`<${t}[ \n>/]`,s);if(r&&console.log("[xml-utils] start:",a),-1===a)return;const o=e.slice(a+t.length);let l=Dn(o,"^[^<]*[ /]>",0);const h=-1!==l&&"/"===o[l-1];if(r&&console.log("[xml-utils] selfClosing:",h),!1===h)if(n){let e=0,i=1,r=0;for(;-1!==(l=Dn(o,"[ /]"+t+">",e));){const n=o.substring(e,l+1);if(i+=En(n,"<"+t+"[ \n\t>]"),r+=En(n,"</"+t+">"),r>=i)break;e=l}}else l=Dn(o,"[ /]"+t+">",0);const f=a+t.length+l+1;if(r&&console.log("[xml-utils] end:",f),-1===f)return;const c=e.slice(a,f);let u;return u=h?null:c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:u,outer:c,start:a,end:f}}_n.exports=Pn,_n.exports.default=Pn;const Mn=_n.exports;function On(e,t,i){const r=[],n=i&&i.debug||!1,s=!i||"boolean"!=typeof i.nested||i.nested;let a,o=i&&i.startIndex||0;for(;a=Mn(e,t,{debug:n,startIndex:o});)o=s?a.start+1+t.length:a.end,r.push(a);return n&&console.log("findTagsByName found",r.length,"tags"),r}yn.exports=On,yn.exports.default=On;var Ln=u(yn.exports);const zn={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"},Gn={};for(const e in zn)zn.hasOwnProperty(e)&&(Gn[zn[e]]=parseInt(e,10));const Bn=[Gn.BitsPerSample,Gn.ExtraSamples,Gn.SampleFormat,Gn.StripByteCounts,Gn.StripOffsets,Gn.StripRowCounts,Gn.TileByteCounts,Gn.TileOffsets,Gn.SubIFDs],Rn={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"},Fn={};for(const e in Rn)Rn.hasOwnProperty(e)&&(Fn[Rn[e]]=parseInt(e,10));const Vn=0,Nn=1,Kn=2,jn=3,Zn=5,Hn=6,Yn=8,Wn=0,Xn=1,$n=0,qn=1,Jn={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"};const Qn=new Map;function es(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>Qn.set(e,t)))}function ts(e,t,i,r=1){return new(Object.getPrototypeOf(e).constructor)(t*i*r)}function is(e,t,i){return(1-i)*e+i*t}function rs(e,t,i,r,n,s="nearest"){switch(s.toLowerCase()){case"nearest":return function(e,t,i,r,n){const s=t/r,a=i/n;return e.map((e=>{const o=ts(e,r,n);for(let l=0;l<n;++l){const n=Math.min(Math.round(a*l),i-1);for(let i=0;i<r;++i){const a=Math.min(Math.round(s*i),t-1),h=e[n*t+a];o[l*r+i]=h}}return o}))}(e,t,i,r,n);case"bilinear":case"linear":return function(e,t,i,r,n){const s=t/r,a=i/n;return e.map((e=>{const o=ts(e,r,n);for(let l=0;l<n;++l){const n=a*l,h=Math.floor(n),f=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const a=s*i,c=a%1,u=Math.floor(a),d=Math.min(Math.ceil(a),t-1),g=e[h*t+u],m=e[h*t+d],p=e[f*t+u],w=e[f*t+d],y=is(is(g,m,c),is(p,w,c),n%1);o[l*r+i]=y}}return o}))}(e,t,i,r,n);default:throw new Error(`Unsupported resampling method: '${s}'`)}}function ns(e,t,i,r,n,s,a="nearest"){switch(a.toLowerCase()){case"nearest":return function(e,t,i,r,n,s){const a=t/r,o=i/n,l=ts(e,r,n,s);for(let h=0;h<n;++h){const n=Math.min(Math.round(o*h),i-1);for(let i=0;i<r;++i){const o=Math.min(Math.round(a*i),t-1);for(let a=0;a<s;++a){const f=e[n*t*s+o*s+a];l[h*r*s+i*s+a]=f}}}return l}(e,t,i,r,n,s);case"bilinear":case"linear":return function(e,t,i,r,n,s){const a=t/r,o=i/n,l=ts(e,r,n,s);for(let h=0;h<n;++h){const n=o*h,f=Math.floor(n),c=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const o=a*i,u=o%1,d=Math.floor(o),g=Math.min(Math.ceil(o),t-1);for(let a=0;a<s;++a){const o=e[f*t*s+d*s+a],m=e[f*t*s+g*s+a],p=e[c*t*s+d*s+a],w=e[c*t*s+g*s+a],y=is(is(o,m,u),is(p,w,u),n%1);l[h*r*s+i*s+a]=y}}}return l}(e,t,i,r,n,s);default:throw new Error(`Unsupported resampling method: '${a}'`)}}function ss(e,t,i){let r=0;for(let n=t;n<i;++n)r+=e[n];return r}function as(e,t,i){switch(e){case 1:if(t<=8)return new Uint8Array(i);if(t<=16)return new Uint16Array(i);if(t<=32)return new Uint32Array(i);break;case 2:if(8===t)return new Int8Array(i);if(16===t)return new Int16Array(i);if(32===t)return new Int32Array(i);break;case 3:switch(t){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}}throw Error("Unsupported data format/bitsPerSample")}es([void 0,1],(()=>Promise.resolve().then((function(){return Es})).then((e=>e.default)))),es(5,(()=>Promise.resolve().then((function(){return Ls})).then((e=>e.default)))),es(6,(()=>{throw new Error("old style JPEG compression is not supported.")})),es(7,(()=>Promise.resolve().then((function(){return Xs})).then((e=>e.default)))),es([8,32946],(()=>Promise.resolve().then((function(){return $s})).then((e=>e.default)))),es(32773,(()=>Promise.resolve().then((function(){return qs})).then((e=>e.default)))),es(34887,(()=>Promise.resolve().then((function(){return ea})).then((e=>e.default)))),es(50001,(()=>Promise.resolve().then((function(){return ta})).then((e=>e.default))));var os=class{constructor(e,t,i,r,n,s){this.fileDirectory=e,this.geoKeys=t,this.dataView=i,this.littleEndian=r,this.tiles=n?{}:null,this.isTiled=!e.StripOffsets;const a=e.PlanarConfiguration;if(this.planarConfiguration=void 0===a?1:a,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return void 0!==this.fileDirectory.SamplesPerPixel?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:void 0!==this.fileDirectory.RowsPerStrip?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,i=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(i<=8)return DataView.prototype.getUint8;if(i<=16)return DataView.prototype.getUint16;if(i<=32)return DataView.prototype.getUint32;break;case 2:if(i<=8)return DataView.prototype.getInt8;if(i<=16)return DataView.prototype.getInt16;if(i<=32)return DataView.prototype.getInt32;break;case 3:switch(i){case 16:return function(e,t){return gn(this,e,t)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,t){return as(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,i,r,n){const s=Math.ceil(this.getWidth()/this.getTileWidth()),a=Math.ceil(this.getHeight()/this.getTileHeight());let o;const{tiles:l}=this;let h,f;1===this.planarConfiguration?o=t*s+e:2===this.planarConfiguration&&(o=i*s*a+t*s+e),this.isTiled?(h=this.fileDirectory.TileOffsets[o],f=this.fileDirectory.TileByteCounts[o]):(h=this.fileDirectory.StripOffsets[o],f=this.fileDirectory.StripByteCounts[o]);const c=(await this.source.fetch([{offset:h,length:f}],n))[0];let u;return null!==l&&l[o]?u=l[o]:(u=(async()=>{let e=await r.decode(this.fileDirectory,c);const i=this.getSampleFormat(),n=this.getBitsPerSample();return function(e,t){return(1!==e&&2!==e||!(t<=32)||t%8!=0)&&(3!==e||16!==t&&32!==t&&64!==t)}(i,n)&&(e=function(e,t,i,r,n,s,a){const o=new DataView(e),l=2===i?1:r,h=as(t,n,2===i?a*s:a*s*r),f=parseInt("1".repeat(n),2);if(1===t){let e;e=1===i?r*n:n;let t=s*e;0!=(7&t)&&(t=t+7&-8);for(let e=0;e<a;++e){const i=e*t;for(let t=0;t<s;++t){const r=i+t*l*n;for(let i=0;i<l;++i){const a=r+i*n,c=(e*s+t)*l+i,u=Math.floor(a/8),d=a%8;if(d+n<=8)h[c]=o.getUint8(u)>>8-n-d&f;else if(d+n<=16)h[c]=o.getUint16(u)>>16-n-d&f;else if(d+n<=24){const e=o.getUint16(u)<<8|o.getUint8(u+2);h[c]=e>>24-n-d&f}else h[c]=o.getUint32(u)>>32-n-d&f}}}}return h.buffer}(e,i,this.planarConfiguration,this.getSamplesPerPixel(),n,this.getTileWidth(),this.getBlockHeight(t))),e})(),null!==l&&(l[o]=u)),{x:e,y:t,sample:i,data:await u}}async _readRaster(e,t,i,r,n,s,a,o,l){const h=this.getTileWidth(),f=this.getTileHeight(),c=this.getWidth(),u=this.getHeight(),d=Math.max(Math.floor(e[0]/h),0),g=Math.min(Math.ceil(e[2]/h),Math.ceil(c/h)),m=Math.max(Math.floor(e[1]/f),0),p=Math.min(Math.ceil(e[3]/f),Math.ceil(u/f)),w=e[2]-e[0];let y=this.getBytesPerPixel();const _=[],b=[];for(let e=0;e<t.length;++e)1===this.planarConfiguration?_.push(ss(this.fileDirectory.BitsPerSample,0,t[e])/8):_.push(0),b.push(this.getReaderForSample(t[e]));const v=[],{littleEndian:k}=this;for(let s=m;s<p;++s)for(let a=d;a<g;++a)for(let o=0;o<t.length;++o){const d=o,g=t[o];2===this.planarConfiguration&&(y=this.getSampleByteSize(o));const m=this.getTileOrStrip(a,s,g,n,l).then((n=>{const s=n.data,a=new DataView(s),o=this.getBlockHeight(n.y),l=n.y*f,g=n.x*h,m=l+o,p=(n.x+1)*h,v=b[d],x=Math.min(o,o-(m-e[3]),u-l),T=Math.min(h,h-(p-e[2]),c-g);for(let n=Math.max(0,e[1]-l);n<x;++n)for(let s=Math.max(0,e[0]-g);s<T;++s){const o=(n*h+s)*y,f=v.call(a,o+_[d],k);let c;r?(c=(n+l-e[1])*w*t.length+(s+g-e[0])*t.length+d,i[c]=f):(c=(n+l-e[1])*w+s+g-e[0],i[d][c]=f)}}));v.push(m)}if(await Promise.all(v),s&&e[2]-e[0]!==s||a&&e[3]-e[1]!==a){let n;return n=r?ns(i,e[2]-e[0],e[3]-e[1],s,a,t.length,o):rs(i,e[2]-e[0],e[3]-e[1],s,a,o),n.width=s,n.height=a,n}return i.width=s||e[2]-e[0],i.height=a||e[3]-e[1],i}async readRasters({window:e,samples:t=[],interleave:i,pool:r=null,width:n,height:s,resampleMethod:a,fillValue:o,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const f=(h[2]-h[0])*(h[3]-h[1]),c=this.getSamplesPerPixel();if(t&&t.length){for(let e=0;e<t.length;++e)if(t[e]>=c)return Promise.reject(new RangeError(`Invalid sample index '${t[e]}'.`))}else for(let e=0;e<c;++e)t.push(e);let u;if(i){u=as(this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,Math.max.apply(null,this.fileDirectory.BitsPerSample),f*t.length),o&&u.fill(o)}else{u=[];for(let e=0;e<t.length;++e){const i=this.getArrayForSample(t[e],f);Array.isArray(o)&&e<o.length?i.fill(o[e]):o&&!Array.isArray(o)&&i.fill(o),u.push(i)}}const d=r||await async function(e){const t=Qn.get(e.Compression);if(!t)throw new Error(`Unknown compression method identifier: ${e.Compression}`);return new(await t())(e)}(this.fileDirectory);return await this._readRaster(h,t,u,i,d,n,s,a,l)}async readRGB({window:e,interleave:t=!0,pool:i=null,width:r,height:n,resampleMethod:s,enableAlpha:a=!1,signal:o}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===Kn){let l=[0,1,2];if(this.fileDirectory.ExtraSamples!==Wn&&a){l=[];for(let e=0;e<this.fileDirectory.BitsPerSample.length;e+=1)l.push(e)}return this.readRasters({window:e,interleave:t,samples:l,pool:i,width:r,height:n,resampleMethod:s,signal:o})}let f;switch(h){case Vn:case Nn:case jn:f=[0];break;case Zn:f=[0,1,2,3];break;case Hn:case Yn:f=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const c={window:l,interleave:!0,samples:f,pool:i,width:r,height:n,resampleMethod:s,signal:o},{fileDirectory:u}=this,d=await this.readRasters(c),g=2**this.fileDirectory.BitsPerSample[0];let m;switch(h){case Vn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let s;for(let i=0,r=0;i<e.length;++i,r+=3)s=256-e[i]/t*256,n[r]=s,n[r+1]=s,n[r+2]=s;return n}(d,g);break;case Nn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let s;for(let i=0,r=0;i<e.length;++i,r+=3)s=e[i]/t*256,n[r]=s,n[r+1]=s,n[r+2]=s;return n}(d,g);break;case jn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3),s=t.length/3,a=t.length/3*2;for(let i=0,r=0;i<e.length;++i,r+=3){const o=e[i];n[r]=t[o]/65536*256,n[r+1]=t[o+s]/65536*256,n[r+2]=t[o+a]/65536*256}return n}(d,u.ColorMap);break;case Zn:m=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=4,i+=3){const n=e[t],s=e[t+1],a=e[t+2],o=e[t+3];r[i]=(255-n)/256*255*((255-o)/256),r[i+1]=(255-s)/256*255*((255-o)/256),r[i+2]=(255-a)/256*255*((255-o)/256)}return r}(d);break;case Hn:m=function(e){const{width:t,height:i}=e,r=new Uint8ClampedArray(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){const n=e[t],s=e[t+1],a=e[t+2];r[i]=n+1.402*(a-128),r[i+1]=n-.34414*(s-128)-.71414*(a-128),r[i+2]=n+1.772*(s-128)}return r}(d);break;case Yn:m=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){let n,s,a,o=(e[t+0]+16)/116,l=(e[t+1]<<24>>24)/500+o,h=o-(e[t+2]<<24>>24)/200;l=.95047*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),o=1*(o*o*o>.008856?o*o*o:(o-16/116)/7.787),h=1.08883*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),n=3.2406*l+-1.5372*o+-.4986*h,s=-.9689*l+1.8758*o+.0415*h,a=.0557*l+-.204*o+1.057*h,n=n>.0031308?1.055*n**(1/2.4)-.055:12.92*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,r[i]=255*Math.max(0,Math.min(1,n)),r[i+1]=255*Math.max(0,Math.min(1,s)),r[i+2]=255*Math.max(0,Math.min(1,a))}return r}(d);break;default:throw new Error("Unsupported photometric interpretation.")}if(!t){const e=new Uint8Array(m.length/3),t=new Uint8Array(m.length/3),i=new Uint8Array(m.length/3);for(let r=0,n=0;r<m.length;r+=3,++n)e[n]=m[r],t[n]=m[r+1],i[n]=m[r+2];m=[e,t,i]}return m.width=d.width,m.height=d.height,m}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let 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}getGDALMetadata(e=null){const t={};if(!this.fileDirectory.GDAL_METADATA)return null;const i=this.fileDirectory.GDAL_METADATA;let r=Ln(i,"Item");r=null===e?r.filter((e=>void 0===wn(e,"sample"))):r.filter((t=>Number(wn(t,"sample"))===e));for(let e=0;e<r.length;++e){const i=r[e];t[wn(i,"name")]=i.inner}return t}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const 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.")}getResolution(e=null){const t=this.fileDirectory.ModelPixelScale,i=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(i)return[i[0],i[5],i[10]];if(e){const[t,i,r]=e.getResolution();return[t*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),r*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return 1===this.geoKeys.GTRasterTypeGeoKey}getBoundingBox(){const e=this.getOrigin(),t=this.getResolution(),i=e[0],r=e[1],n=i+t[0]*this.getWidth(),s=r+t[1]*this.getHeight();return[Math.min(i,n),Math.min(r,s),Math.max(i,n),Math.max(r,s)]}};class ls{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const i=this.getUint32(e,t),r=this.getUint32(e+4,t);let n;if(t){if(n=i+2**32*r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*i+r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}getInt64(e,t){let i=0;const r=(128&this._dataView.getUint8(e+(t?7:0)))>0;let n=!0;for(let s=0;s<8;s++){let a=this._dataView.getUint8(e+(t?s:7-s));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),i+=a*256**s}return r&&(i=-i),i}getUint8(e,t){return this._dataView.getUint8(e,t)}getInt8(e,t){return this._dataView.getInt8(e,t)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return gn(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}}class hs{constructor(e,t,i,r){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=i,this._bigTiff=r}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),i=this.readUint32(e+4);let r;if(this._littleEndian){if(r=t+2**32*i,!Number.isSafeInteger(r))throw new Error(`${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=2**32*t+i,!Number.isSafeInteger(r))throw new Error(`${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}readInt64(e){let t=0;const i=(128&this._dataView.getUint8(e+(this._littleEndian?7:0)))>0;let r=!0;for(let n=0;n<8;n++){let s=this._dataView.getUint8(e+(this._littleEndian?n:7-n));i&&(r?0!==s&&(s=255&~(s-1),r=!1):s=255&~s),t+=s*256**n}return i&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class fs{async fetch(e,t=undefined){return Promise.all(e.map((e=>this.fetchSlice(e,t))))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class cs extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,cs),this.name="AbortError"}}class us extends fs{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,t){if(t&&t.aborted)throw new cs("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function ds(e,t){let i=e.length-t,r=0;do{for(let i=t;i>0;i--)e[r+t]+=e[r],r++;i-=t}while(i>0)}function gs(e,t,i){let r=0,n=e.length;const s=n/i;for(;n>t;){for(let i=t;i>0;--i)e[r+t]+=e[r],++r;n-=t}const a=e.slice();for(let t=0;t<s;++t)for(let r=0;r<i;++r)e[i*t+r]=a[(i-r-1)*s+t]}class ms{async decode(e,t){const i=await this.decodeBlock(t),r=e.Predictor||1;if(1!==r){const t=!e.StripOffsets;return function(e,t,i,r,n,s){if(!t||1===t)return e;for(let e=0;e<n.length;++e){if(n[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[e]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=n[0]/8,o=2===s?1:n.length;for(let s=0;s<r&&!(s*o*i*a>=e.byteLength);++s){let r;if(2===t){switch(n[0]){case 8:r=new Uint8Array(e,s*o*i*a,o*i*a);break;case 16:r=new Uint16Array(e,s*o*i*a,o*i*a/2);break;case 32:r=new Uint32Array(e,s*o*i*a,o*i*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}ds(r,o)}else 3===t&&(r=new Uint8Array(e,s*o*i*a,o*i*a),gs(r,o,a))}return e}(i,r,t?e.TileWidth:e.ImageWidth,t?e.TileLength:e.RowsPerStrip||e.ImageLength,e.BitsPerSample,e.PlanarConfiguration)}return i}}function ps(e){switch(e){case Fn.BYTE:case Fn.ASCII:case Fn.SBYTE:case Fn.UNDEFINED:return 1;case Fn.SHORT:case Fn.SSHORT:return 2;case Fn.LONG:case Fn.SLONG:case Fn.FLOAT:case Fn.IFD:return 4;case Fn.RATIONAL:case Fn.SRATIONAL:case Fn.DOUBLE:case Fn.LONG8:case Fn.SLONG8:case Fn.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${e}`)}}function ws(e,t,i,r){let n=null,s=null;const a=ps(t);switch(t){case Fn.BYTE:case Fn.ASCII:case Fn.UNDEFINED:n=new Uint8Array(i),s=e.readUint8;break;case Fn.SBYTE:n=new Int8Array(i),s=e.readInt8;break;case Fn.SHORT:n=new Uint16Array(i),s=e.readUint16;break;case Fn.SSHORT:n=new Int16Array(i),s=e.readInt16;break;case Fn.LONG:case Fn.IFD:n=new Uint32Array(i),s=e.readUint32;break;case Fn.SLONG:n=new Int32Array(i),s=e.readInt32;break;case Fn.LONG8:case Fn.IFD8:n=new Array(i),s=e.readUint64;break;case Fn.SLONG8:n=new Array(i),s=e.readInt64;break;case Fn.RATIONAL:n=new Uint32Array(2*i),s=e.readUint32;break;case Fn.SRATIONAL:n=new Int32Array(2*i),s=e.readInt32;break;case Fn.FLOAT:n=new Float32Array(i),s=e.readFloat32;break;case Fn.DOUBLE:n=new Float64Array(i),s=e.readFloat64;break;default:throw new RangeError(`Invalid field type: ${t}`)}if(t!==Fn.RATIONAL&&t!==Fn.SRATIONAL)for(let t=0;t<i;++t)n[t]=s.call(e,r+t*a);else for(let t=0;t<i;t+=2)n[t]=s.call(e,r+t*a),n[t+1]=s.call(e,r+(t*a+4));return t===Fn.ASCII?new TextDecoder("utf-8").decode(n):n}class ys{constructor(e,t,i){this.fileDirectory=e,this.geoKeyDirectory=t,this.nextIFDByteOffset=i}}class _s extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class bs{async readRasters(e={}){const{window:t,width:i,height:r}=e;let{resX:n,resY:s,bbox:a}=e;const o=await this.getImage();let l=o;const h=await this.getImageCount(),f=o.getBoundingBox();if(t&&a)throw new Error('Both "bbox" and "window" passed.');if(i||r){if(t){const[e,i]=o.getOrigin(),[r,n]=o.getResolution();a=[e+t[0]*r,i+t[1]*n,e+t[2]*r,i+t[3]*n]}const e=a||f;if(i){if(n)throw new Error("Both width and resX passed");n=(e[2]-e[0])/i}if(r){if(s)throw new Error("Both width and resY passed");s=(e[3]-e[1])/r}}if(n||s){const e=[];for(let t=0;t<h;++t){const i=await this.getImage(t),{SubfileType:r,NewSubfileType:n}=i.fileDirectory;(0===t||2===r||1&n)&&e.push(i)}e.sort(((e,t)=>e.getWidth()-t.getWidth()));for(let t=0;t<e.length;++t){const i=e[t],r=(f[2]-f[0])/i.getWidth(),a=(f[3]-f[1])/i.getHeight();if(l=i,n&&n>r||s&&s>a)break}}let c=t;if(a){const[e,t]=o.getOrigin(),[i,r]=l.getResolution(o);c=[Math.round((a[0]-e)/i),Math.round((a[1]-t)/r),Math.round((a[2]-e)/i),Math.round((a[3]-t)/r)],c=[Math.min(c[0],c[2]),Math.min(c[1],c[3]),Math.max(c[0],c[2]),Math.max(c[1],c[3])]}return l.readRasters({...e,window:c})}}class vs extends bs{constructor(e,t,i,r,n={}){super(),this.source=e,this.littleEndian=t,this.bigTiff=i,this.firstIFDOffset=r,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,t){const i=this.bigTiff?4048:1024;return new hs((await this.source.fetch([{offset:e,length:void 0!==t?t:i}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,i=this.bigTiff?8:2;let r=await this.getSlice(e);const n=this.bigTiff?r.readUint64(e):r.readUint16(e),s=n*t+(this.bigTiff?16:6);r.covers(e,s)||(r=await this.getSlice(e,s));const a={};let o=e+(this.bigTiff?8:2);for(let e=0;e<n;o+=t,++e){const e=r.readUint16(o),t=r.readUint16(o+2),i=this.bigTiff?r.readUint64(o+4):r.readUint32(o+4);let n,s;const l=ps(t),h=o+(this.bigTiff?12:8);if(l*i<=(this.bigTiff?8:4))n=ws(r,t,i,h);else{const e=r.readOffset(h),s=ps(t)*i;if(r.covers(e,s))n=ws(r,t,i,e);else{n=ws(await this.getSlice(e,s),t,i,e)}}s=1===i&&-1===Bn.indexOf(e)&&t!==Fn.RATIONAL&&t!==Fn.SRATIONAL?n[0]:n,a[zn[e]]=s}const l=function(e){const t=e.GeoKeyDirectory;if(!t)return null;const i={};for(let r=4;r<=4*t[3];r+=4){const n=Jn[t[r]],s=t[r+1]?zn[t[r+1]]:null,a=t[r+2],o=t[r+3];let l=null;if(s){if(l=e[s],null==l)throw new Error(`Could not get value of geoKey '${n}'.`);"string"==typeof l?l=l.substring(o,o+a-1):l.subarray&&(l=l.subarray(o,o+a),1===a&&(l=l[0]))}else l=o;i[n]=l}return i}(a),h=r.readOffset(e+i+t*n);return new ys(a,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(0===e)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(t){if(t instanceof _s)throw new _s(e);throw t}return this.ifdRequests[e]=(async()=>{const t=await this.ifdRequests[e-1];if(0===t.nextIFDByteOffset)throw new _s(e);return this.parseFileDirectoryAt(t.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const t=await this.requestIFD(e);return new os(t.fileDirectory,t.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,t=!0;for(;t;)try{await this.requestIFD(e),++e}catch(e){if(!(e instanceof _s))throw e;t=!1}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const t="GDAL_STRUCTURAL_METADATA_SIZE=",i=t.length+100;let r=await this.getSlice(e,i);if(t===ws(r,Fn.ASCII,t.length,e)){const t=ws(r,Fn.ASCII,i,e).split("\n")[0],n=Number(t.split("=")[1].split(" ")[0])+t.length;n>i&&(r=await this.getSlice(e,n));const s=ws(r,Fn.ASCII,n,e);this.ghostValues={},s.split("\n").filter((e=>e.length>0)).map((e=>e.split("="))).forEach((([e,t])=>{this.ghostValues[e]=t}))}return this.ghostValues}static async fromSource(e,t,i){const r=(await e.fetch([{offset:0,length:1024}],i))[0],n=new ls(r),s=n.getUint16(0,0);let a;if(18761===s)a=!0;else{if(19789!==s)throw new TypeError("Invalid byte order value.");a=!1}const o=n.getUint16(2,a);let l;if(42===o)l=!1;else{if(43!==o)throw new TypeError("Invalid magic number.");l=!0;if(8!==n.getUint16(4,a))throw new Error("Unsupported offset byte-size.")}const h=l?n.getUint64(8,a):n.getUint32(4,a);return new vs(e,a,l,h,t)}close(){return"function"==typeof this.source.close&&this.source.close()}}async function ks(e,t){return vs.fromSource(function(e){return new us(e)}(e),t)}const xs={type:"image",format:"uint8",useHeatMap:!0,useColorsBasedOnValues:!1,useAutoRange:!1,useDataForOpacity:!1,useSingleColor:!1,clipLow:null,clipHigh:null,multiplier:1,color:[255,0,255,255],colorScale:n.brewer.YlOrRd,colorScaleValueRange:[0,255],colorsBasedOnValues:null,alpha:255,useChannel:null,noDataValue:void 0,numOfChannels:void 0,nullColor:[0,0,0,0],unidentifiedColor:[0,0,0,0],clippedColor:[0,0,0,0]};class Ts{constructor(){this.scale=(e,t,i,r,n)=>(e-t)*(n-r)/(i-t)+r}setUrl(e){return s(this,void 0,void 0,(function*(){const t=yield fetch(e),i=yield t.arrayBuffer(),r=yield ks(i),n=yield r.getImage(0);this.data=n}))}getMap(e,t){return s(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},xs),t);switch(i.type){case"image":return this.getBitmap(e,i);case"terrain":return this.getHeightmap(e,i);default:return null}}))}getHeightmap(e,t){return s(this,void 0,void 0,(function*(){let i,r,n=[];"string"==typeof e?(yield this.setUrl(e),n=yield this.data.readRasters(),i=this.data.getWidth(),r=this.data.getHeight()):(n=e.rasters,i=e.width,r=e.height);let s=n[0];null!=t.useChannel&&n[t.useChannel]&&(s=n[t.useChannel]);const a=document.createElement("canvas");a.width=i,a.height=r;const o=a.getContext("2d"),l=o.createImageData(i,r),h=s.length/(i*r),f=i*r*4;let c=0;null!=t.useChannel&&(c=t.useChannel);for(let e=0;e<f;e+=4){s[c]*=t.multiplier;const i=1e5+10*s[c];l.data[e]=Math.trunc(1525878e-11*i),l.data[e+1]=Math.trunc(.00390625*i)-256*l.data[e],l.data[e+2]=Math.trunc(i)-65536*l.data[e]-256*l.data[e+1],l.data[e+3]=255,c+=h}o.putImageData(l,0,0);return a.toDataURL("image/png")}))}getBitmap(e,t){return s(this,void 0,void 0,(function*(){const i=Object.assign({},t);let r,n,s,a=[];"string"==typeof e?(yield this.setUrl(e),a=yield this.data.readRasters(),r=a.length,n=this.data.getWidth(),s=this.data.getHeight()):(a=e.rasters,r=a.length,n=e.width,s=e.height);const o=document.createElement("canvas");o.width=n,o.height=s;const l=o.getContext("2d"),h=l.createImageData(n,s);let f,c,u,d;const g=n*s*4;if(t.noDataValue||console.log("Missing noData value. Raster might be displayed incorrectly."),i.unidentifiedColor=this.getColorFromChromaType(i.unidentifiedColor),i.nullColor=this.getColorFromChromaType(i.nullColor),i.clippedColor=this.getColorFromChromaType(i.clippedColor),i.color=this.getColorFromChromaType(i.color),null==i.useChannel){if(1===r){if(a[0].length/(n*s)==1){const e=a[0];i.useAutoRange&&(i.colorScaleValueRange=this.getMinMax(e,i));this.getColorValue(e,i,g).forEach(((e,t)=>{h.data[t]=e}))}if(a[0].length/(n*s)==3){let e=0;for(let t=0;t<g;t+=4){const r=[a[0][e],a[0][e+1],a[0][e+2]],n=this.hasPixelsNoData(r,i.noDataValue)?i.nullColor:[...r,i.alpha];[h.data[t],h.data[t+1],h.data[t+2],h.data[t+3]]=n,e+=3}}a[0].length/(n*s)==4&&a[0].forEach(((e,t)=>{h.data[t]=e}))}if(3===r){let e=0;for(let t=0;t<g;t+=4)f=a[0][e],c=a[1][e],u=a[2][e],d=i.alpha,h.data[t]=f,h.data[t+1]=c,h.data[t+2]=u,h.data[t+3]=d,e+=1}if(4===r){let e=0;for(let t=0;t<g;t+=4)f=a[0][e],c=a[1][e],u=a[2][e],d=i.alpha,h.data[t]=f,h.data[t+1]=c,h.data[t+2]=u,h.data[t+3]=d,e+=1}}else if(i.useChannel<=i.numOfChannels){let e=a[0];a[i.useChannel]&&(e=a[i.useChannel]),i.useAutoRange&&(i.colorScaleValueRange=this.getMinMax(e,i));const t=e.length/(n*s);this.getColorValue(e,i,g,t).forEach(((e,t)=>{h.data[t]=e}))}else{console.log("Defined channel does not exist, displaying only grey values");this.getDefaultColor(g,i.nullColor).forEach(((e,t)=>{h.data[t]=e}))}l.putImageData(h,0,0);return o.toDataURL("image/png")}))}getMinMax(e,t){let i=t.maxValue?t.maxValue:Number.MIN_VALUE,r=t.minValue?t.minValue:Number.MAX_VALUE;for(let n=0;n<e.length;n+=1)void 0!==t.noDataValue&&e[n]===t.noDataValue||(e[n]>i&&(i=e[n]),e[n]<r&&(r=e[n]));return[r,i]}getColorValue(e,t,i,r=1){const s=n.scale(t.colorScale).domain(t.colorScaleValueRange);let a=null===t.useChannel?0:t.useChannel;const o=new Array(i),l=t.colorsBasedOnValues?t.colorsBasedOnValues.map((([e])=>e)):void 0,h=t.colorsBasedOnValues?t.colorsBasedOnValues.map((([,e])=>[...n(e).rgb(),255])):void 0;for(let n=0;n<i;n+=4){let i=t.nullColor;if(void 0===t.noDataValue||e[a]!==t.noDataValue)if(null!=t.clipLow&&e[a]<=t.clipLow||null!=t.clipHigh&&e[a]>=t.clipHigh)i=t.clippedColor;else{if(t.useHeatMap&&(i=[...s(e[a]).rgb(),255]),t.useColorsBasedOnValues){const r=l.indexOf(e[a]);i=r>-1?h[r]:t.unidentifiedColor}t.useSingleColor&&(i=t.color),t.useDataForOpacity&&(i[3]=this.scale(e[a],t.colorScaleValueRange[0],t.colorScaleValueRange.slice(-1)[0],0,255))}[o[n],o[n+1],o[n+2],o[n+3]]=i,a+=r}return o}getDefaultColor(e,t){const i=new Array(e);for(let r=0;r<e;r+=4)[i[r],i[r+1],i[r+2],i[r+3]]=t;return i}getColorFromChromaType(e){return Array.isArray(e)&&4===e.length?e:[...n(e).rgb(),255]}hasPixelsNoData(e,t){return void 0!==t&&e.every((e=>e===t))}}const As=40075e3,Ss=20037500;class Is{constructor(e){this.zoomRange=[0,0],this.lowestOriginTileOffset=[0,0],this.lowestOriginTileSize=0,this.loaded=!1,this.geo=new Ts,this.lzw=new pr,this.options=e}initializeCog(e){return s(this,void 0,void 0,(function*(){j.fetch=(e,t)=>s(this,void 0,void 0,(function*(){return yield fetch(e,t)}));const t=new j(e);return this.cog=yield B.create(t),this.cog.images.forEach((e=>{e.loadGeoTiffTags()})),this.tileSize=this.getTileSize(this.cog),this.lowestOriginTileOffset=this.getImageTileIndex(this.cog.images[this.cog.images.length-1]),this.zoomRange=this.getZoomRange(this.cog),this.cog}))}getTileSize(e){return e.images[e.images.length-1].tileSize.width}getZoomRange(e){const t=e.images[e.images.length-1],i=this.getZoomLevelFromResolution(e.images[e.images.length-1].tileSize.width,t.resolution[0]);return[i,i+(e.images.length-1)]}getBoundsAsLatLon(e){const{bbox:t}=e.images[e.images.length-1],i=Math.min(t[0],t[2]),r=Math.max(t[0],t[2]),n=Math.min(t[1],t[3]),s=Math.max(t[1],t[3]),a=this.getLatLon([i,n]),o=this.getLatLon([r,s]);return[a[0],a[1],o[0],o[1]]}getOriginAsLatLon(e){const{origin:t}=e.images[e.images.length-1];return this.getLatLon(t)}getImageTileIndex(e){const t=Ss+e.origin[0],i=-(Ss+(e.origin[1]-As)),r=e.tileSize.width*this.getResolutionFromZoomLevel(e.tileSize.width,this.getZoomLevelFromResolution(e.tileSize.width,e.resolution[0]));return[Math.round(t/r),Math.round(i/r),this.getZoomLevelFromResolution(e.tileSize.width,e.resolution[0])]}getResolutionFromZoomLevel(e,t){return As/e/Math.pow(2,t)}getZoomLevelFromResolution(e,t){return Math.round(Math.log2(As/(t*e)))}getLatLon(e){const t=function(e){const[t,i]=e,r=t/512*(2*or)-or,n=2*(Math.atan(Math.exp(i/512*(2*or)-or))-lr);return[r*hr,n*hr]}([12776044915782906e-21*(Ss+e[0]),12776044915782906e-21*-(Ss+(e[1]-As))]);return[t[0],-t[1]]}getTile(e,t,i){return s(this,void 0,void 0,(function*(){const r=this.getResolutionFromZoomLevel(this.tileSize,i),n=this.cog.getImageByResolution(r);let s=[0,0];if(i===this.zoomRange[0])s=this.lowestOriginTileOffset;else{const e=Math.pow(2,i-this.zoomRange[0]);s[0]=Math.floor(this.lowestOriginTileOffset[0]*e),s[1]=Math.floor(this.lowestOriginTileOffset[1]*e)}const a=n.tileCount.x,o=n.tileCount.y,l=s[0],h=s[1];let f,c;this.options.numOfChannels=Number(n.tags.get(277).value),this.options.noDataValue=this.getNoDataValue(n.tags),this.options.format||(this.options.format=this.getFormat(n.tags.get(339).value,n.tags.get(258).value));let u=n.tags.get(258).value;if(Array.isArray(u))if("terrain"===this.options.type){let e=0;u.forEach((t=>{e+=t})),u=e}else[u]=u;if(e-l>=0&&t-h>=0&&e-l<a&&t-h<o){const i=yield n.getTile(e-l,t-h);switch(n.compression){case"image/jpeg":c=sr.decode(i.bytes,{useTArray:!0});break;case"application/deflate":c=yield Ji(i.bytes);break;case"application/lzw":c=this.lzw.decodeBlock(i.bytes.buffer);break;default:console.warn(`Unexpected compression method: ${n.compression}`)}let r;switch(this.options.format){case"uint8":r=new Uint8Array(c.buffer);break;case"uint16":r=new Uint16Array(c.buffer);break;case"uint32":r=new Uint32Array(c.buffer);break;case"int8":r=new Int8Array(c.buffer);break;case"int16":r=new Int16Array(c.buffer);break;case"int32":r=new Int32Array(c.buffer);break;case"float32":r=new Float32Array(c.buffer);break;case"float64":r=new Float64Array(c.buffer);break;default:r=null}return f=yield this.geo.getMap({rasters:[r],width:this.tileSize,height:this.tileSize},this.options),f}return null}))}getFormat(e,t){let i,r=e,n=t;switch(Array.isArray(e)&&([r]=e),Array.isArray(t)&&([n]=t),r){case 1:switch(n){case 8:i="uint8";break;case 16:i="uint16";break;case 32:i="uint32";break;default:i=null}break;case 2:switch(n){case 8:i="int8";break;case 16:i="int16";break;case 32:i="int32";break;default:i=null}break;case 3:switch(n){case 32:i="float32";break;case 64:i="float64";break;default:i=null}break;default:throw new Error("Unknown data format.")}return i}getNoDataValue(e){if(e.has(42113)){const t=e.get(42113).value;if("string"==typeof t||t instanceof String){const e=t.replace(/[\0\s]/g,"");return Number(e)}return Number.isNaN(Number(t))?void 0:Number(t)}}testCog(){return s(this,void 0,void 0,(function*(){this.options={type:"image",multiplier:1,useChannel:1,alpha:180,clipLow:1,clipHigh:Number.MAX_VALUE};const e=yield this.initializeCog("https://gisat-gis.eu-central-1.linodeobjects.com/eman/versions/v2/Quadrants/Q3_Bolivia_ASTER_2002_RGB_COG_LZW.tif"),t=e.images[Math.floor(e.images.length/2)];console.log(t);const i=this.getImageTileIndex(t);console.log(i);const r=Math.floor(t.tileCount.x/2),n=Math.floor(t.tileCount.y/2);console.log(e.getTile(r,n,Math.floor(e.images.length/2)));const s=r+i[0],a=n+i[1],o=i[2],l=yield this.getTile(s,a,o);!1===l?console.log("couldn't retrieve tile"):console.log(l)}))}}class Us extends e{constructor(e,t,i){super({}),this.id="",this.id=e,this.cogTiles=new Is(i),this.url=t}initializeState(){this.state={initialized:!1},this.init(this.url)}init(e){return s(this,void 0,void 0,(function*(){const t=yield this.cogTiles.initializeCog(e);this.setState({initialized:!0}),this.tileSize=this.cogTiles.getTileSize(t);const i=this.cogTiles.getZoomRange(t);[this.minZoom,this.maxZoom]=i}))}renderLayers(){if(this.cogTiles.cog){return new t({id:`${this.id}-${String(performance.now())}`,getTileData:e=>this.cogTiles.getTile(e.index.x,e.index.y,e.index.z),minZoom:this.minZoom,maxZoom:this.maxZoom,tileSize:this.tileSize,maxRequests:6,extent:this.cogTiles.cog?this.cogTiles.getBoundsAsLatLon(this.cogTiles.cog):null,renderSubLayers:e=>{const{bbox:{west:t,south:i,east:n,north:s}}=e.tile;return new r(e,{data:null,image:e.data,bounds:[t,i,n,s],opacity:1})}})}return null}}Us.layerName="CogBitmapLayer",Us.displayName="CogBitmapLayer";class Cs extends e{constructor(e,t,i,r,n){var s;super({}),this.urlType="none",this.id="",this.id=e,r&&((s=r).includes("{x}")&&s.includes("{y}")&&s.includes("{z}")?(this.bitmapUrl=r,this.urlType="tile"):!function(e){return!!(e.includes(".tif")||e.includes(".tiff")||e.includes(".TIF")||e.includes(".TIFF"))}(r)?console.warn("URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format."):(this.bitmapCogTiles=new Is(n),this.bitmapCogTiles.initializeCog(r),this.urlType="cog")),this.terrainCogTiles=new Is(i),this.terrainUrl=t}initializeState(){this.state={initialized:!1},this.init(this.terrainUrl)}init(e){return s(this,void 0,void 0,(function*(){const t=yield this.terrainCogTiles.initializeCog(e);this.tileSize=this.terrainCogTiles.getTileSize(t);const i=this.terrainCogTiles.getZoomRange(t);[this.minZoom,this.maxZoom]=i,this.setState({initialized:!0})}))}renderLayers(){if(this.terrainCogTiles.cog){let e;this.urlType;return[new t({id:`${this.id}-${String(performance.now())}`,zoomOffset:-1,getTileData:e=>this.terrainCogTiles.getTile(e.index.x,e.index.y,e.index.z),minZoom:this.minZoom,maxZoom:this.maxZoom,tileSize:this.tileSize,maxRequests:6,refinementStrategy:"best-available",extent:this.terrainCogTiles.getBoundsAsLatLon(this.terrainCogTiles.cog),renderSubLayers:t=>{if(t.data&&void 0!==t.tile.index.x){switch(this.urlType){case"tile":r=this.bitmapUrl,n=t.tile.index.x,s=t.tile.index.y,a=t.tile.index.z,e=r.replace("{x}",String(n)).replace("{y}",String(s)).replace("{z}",String(a));break;case"cog":e=this.bitmapCogTiles.getTile(t.tile.index.x,t.tile.index.y,t.tile.index.z);break;default:e=null}return new i({id:`terrain-${t.tile.index.x}-${t.tile.index.y}-${t.tile.index.z}`,pickable:!0,elevationDecoder:{rScaler:6553.6,gScaler:25.6,bScaler:.1,offset:-1e4},elevationData:t.data,texture:e,bounds:[t.tile.bbox.west,t.tile.bbox.south,t.tile.bbox.east,t.tile.bbox.north],minZoom:this.minZoom,maxZoom:this.maxZoom,loadOptions:{terrain:{skirtHeight:2e3,tesselator:"martini"}},meshMaxError:12})}var r,n,s,a;return null}})]}return[]}}Cs.layerName="CogTerrainLayer",Cs.displayName="CogTerrainLayer";var Ds={CogBitmapLayer:Us,CogTerrainLayer:Cs,cogtiles:Is,GeoImage:Ts};var Es=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return e}}});const Ps=257;function Ms(e,t){for(let i=t.length-1;i>=0;i--)e.push(t[i]);return e}function Os(e){const t=new Uint16Array(4093),i=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,i[e]=e;let r=258,n=9,s=0;function a(){r=258,n=9}function o(e){const t=function(e,t,i){const r=t%8,n=Math.floor(t/8),s=8-r,a=t+i-8*(n+1);let o=8*(n+2)-(t+i);const l=8*(n+2)-t;if(o=Math.max(0,o),n>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),Ps;let h=e[n]&2**(8-r)-1;h<<=i-s;let f=h;if(n+1<e.length){let t=e[n+1]>>>o;t<<=Math.max(0,i-l),f+=t}if(a>8&&n+2<e.length){const r=8*(n+3)-(t+i);f+=e[n+2]>>>r}return f}(e,s,n);return s+=n,t}function l(e,n){return i[r]=n,t[r]=e,r++,r-1}function h(e){const r=[];for(let n=e;4096!==n;n=t[n])r.push(i[n]);return r}const f=[];a();const c=new Uint8Array(e);let u,d=o(c);for(;d!==Ps;){if(256===d){for(a(),d=o(c);256===d;)d=o(c);if(d===Ps)break;if(d>256)throw new Error(`corrupted code at scanline ${d}`);Ms(f,h(d)),u=d}else if(d<r){const e=h(d);Ms(f,e),l(u,e[e.length-1]),u=d}else{const e=h(u);if(!e)throw new Error(`Bogus entry. Not in dictionary, ${u} / ${r}, position: ${s}`);Ms(f,e),f.push(e[e.length-1]),l(u,e[e.length-1]),u=d}r+1>=2**n&&(12===n?u=void 0:n++),d=o(c)}return new Uint8Array(f)}var Ls=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return Os(e).buffer}}});const zs=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Gs=4017,Bs=799,Rs=3406,Fs=2276,Vs=1567,Ns=3784,Ks=5793,js=2896;function Zs(e,t){let i=0;const r=[];let n=16;for(;n>0&&!e[n-1];)--n;r.push({children:[],index:0});let s,a=r[0];for(let o=0;o<n;o++){for(let n=0;n<e[o];n++){for(a=r.pop(),a.children[a.index]=t[i];a.index>0;)a=r.pop();for(a.index++,r.push(a);r.length<=o;)r.push(s={children:[],index:0}),a.children[a.index]=s.children,a=s;i++}o+1<n&&(r.push(s={children:[],index:0}),a.children[a.index]=s.children,a=s)}return r[0].children}function Hs(e,t,i,r,n,s,a,o,l){const{mcusPerLine:h,progressive:f}=i,c=t;let u=t,d=0,g=0;function m(){if(g>0)return g--,d>>g&1;if(d=e[u++],255===d){const t=e[u++];if(t)throw new Error(`unexpected marker: ${(d<<8|t).toString(16)}`)}return g=7,d>>>7}function p(e){let t,i=e;for(;null!==(t=m());){if(i=i[t],"number"==typeof i)return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function w(e){let t=e,i=0;for(;t>0;){const e=m();if(null===e)return;i=i<<1|e,--t}return i}function y(e){const t=w(e);return t>=1<<e-1?t:t+(-1<<e)+1}let _=0;let b,v=0;function k(e,t,i,r,n){const s=i%h,a=(i/h|0)*e.v+r,o=s*e.h+n;t(e,e.blocks[a][o])}function x(e,t,i){const r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;t(e,e.blocks[r][n])}const T=r.length;let A,S,I,U,C,D;D=f?0===s?0===o?function(e,t){const i=p(e.huffmanTableDC),r=0===i?0:y(i)<<l;e.pred+=r,t[0]=e.pred}:function(e,t){t[0]|=m()<<l}:0===o?function(e,t){if(_>0)return void _--;let i=s;const r=a;for(;i<=r;){const r=p(e.huffmanTableAC),n=15&r,s=r>>4;if(0===n){if(s<15){_=w(s)+(1<<s)-1;break}i+=16}else i+=s,t[zs[i]]=y(n)*(1<<l),i++}}:function(e,t){let i=s;const r=a;let n=0;for(;i<=r;){const r=zs[i],s=t[r]<0?-1:1;switch(v){case 0:{const t=p(e.huffmanTableAC),i=15&t;if(n=t>>4,0===i)n<15?(_=w(n)+(1<<n),v=4):(n=16,v=1);else{if(1!==i)throw new Error("invalid ACn encoding");b=y(i),v=n?2:3}continue}case 1:case 2:t[r]?t[r]+=(m()<<l)*s:(n--,0===n&&(v=2===v?3:0));break;case 3:t[r]?t[r]+=(m()<<l)*s:(t[r]=b<<l,v=0);break;case 4:t[r]&&(t[r]+=(m()<<l)*s)}i++}4===v&&(_--,0===_&&(v=0))}:function(e,t){const i=p(e.huffmanTableDC),r=0===i?0:y(i);e.pred+=r,t[0]=e.pred;let n=1;for(;n<64;){const i=p(e.huffmanTableAC),r=15&i,s=i>>4;if(0===r){if(s<15)break;n+=16}else n+=s,t[zs[n]]=y(r),n++}};let E,P,M=0;P=1===T?r[0].blocksPerLine*r[0].blocksPerColumn:h*i.mcusPerColumn;const O=n||P;for(;M<P;){for(S=0;S<T;S++)r[S].pred=0;if(_=0,1===T)for(A=r[0],C=0;C<O;C++)x(A,D,M),M++;else for(C=0;C<O;C++){for(S=0;S<T;S++){A=r[S];const{h:e,v:t}=A;for(I=0;I<t;I++)for(U=0;U<e;U++)k(A,D,M,I,U)}if(M++,M===P)break}if(g=0,E=e[u]<<8|e[u+1],E<65280)throw new Error("marker was not found");if(!(E>=65488&&E<=65495))break;u+=2}return u-c}function Ys(e,t){const i=[],{blocksPerLine:r,blocksPerColumn:n}=t,s=r<<3,a=new Int32Array(64),o=new Uint8Array(64);function l(e,i,r){const n=t.quantizationTable;let s,a,o,l,h,f,c,u,d;const g=r;let m;for(m=0;m<64;m++)g[m]=e[m]*n[m];for(m=0;m<8;++m){const e=8*m;0!==g[1+e]||0!==g[2+e]||0!==g[3+e]||0!==g[4+e]||0!==g[5+e]||0!==g[6+e]||0!==g[7+e]?(s=Ks*g[0+e]+128>>8,a=Ks*g[4+e]+128>>8,o=g[2+e],l=g[6+e],h=js*(g[1+e]-g[7+e])+128>>8,u=js*(g[1+e]+g[7+e])+128>>8,f=g[3+e]<<4,c=g[5+e]<<4,d=s-a+1>>1,s=s+a+1>>1,a=d,d=o*Ns+l*Vs+128>>8,o=o*Vs-l*Ns+128>>8,l=d,d=h-c+1>>1,h=h+c+1>>1,c=d,d=u+f+1>>1,f=u-f+1>>1,u=d,d=s-l+1>>1,s=s+l+1>>1,l=d,d=a-o+1>>1,a=a+o+1>>1,o=d,d=h*Fs+u*Rs+2048>>12,h=h*Rs-u*Fs+2048>>12,u=d,d=f*Bs+c*Gs+2048>>12,f=f*Gs-c*Bs+2048>>12,c=d,g[0+e]=s+u,g[7+e]=s-u,g[1+e]=a+c,g[6+e]=a-c,g[2+e]=o+f,g[5+e]=o-f,g[3+e]=l+h,g[4+e]=l-h):(d=Ks*g[0+e]+512>>10,g[0+e]=d,g[1+e]=d,g[2+e]=d,g[3+e]=d,g[4+e]=d,g[5+e]=d,g[6+e]=d,g[7+e]=d)}for(m=0;m<8;++m){const e=m;0!==g[8+e]||0!==g[16+e]||0!==g[24+e]||0!==g[32+e]||0!==g[40+e]||0!==g[48+e]||0!==g[56+e]?(s=Ks*g[0+e]+2048>>12,a=Ks*g[32+e]+2048>>12,o=g[16+e],l=g[48+e],h=js*(g[8+e]-g[56+e])+2048>>12,u=js*(g[8+e]+g[56+e])+2048>>12,f=g[24+e],c=g[40+e],d=s-a+1>>1,s=s+a+1>>1,a=d,d=o*Ns+l*Vs+2048>>12,o=o*Vs-l*Ns+2048>>12,l=d,d=h-c+1>>1,h=h+c+1>>1,c=d,d=u+f+1>>1,f=u-f+1>>1,u=d,d=s-l+1>>1,s=s+l+1>>1,l=d,d=a-o+1>>1,a=a+o+1>>1,o=d,d=h*Fs+u*Rs+2048>>12,h=h*Rs-u*Fs+2048>>12,u=d,d=f*Bs+c*Gs+2048>>12,f=f*Gs-c*Bs+2048>>12,c=d,g[0+e]=s+u,g[56+e]=s-u,g[8+e]=a+c,g[48+e]=a-c,g[16+e]=o+f,g[40+e]=o-f,g[24+e]=l+h,g[32+e]=l-h):(d=Ks*r[m+0]+8192>>14,g[0+e]=d,g[8+e]=d,g[16+e]=d,g[24+e]=d,g[32+e]=d,g[40+e]=d,g[48+e]=d,g[56+e]=d)}for(m=0;m<64;++m){const e=128+(g[m]+8>>4);i[m]=e<0?0:e>255?255:e}}for(let e=0;e<n;e++){const n=e<<3;for(let e=0;e<8;e++)i.push(new Uint8Array(s));for(let s=0;s<r;s++){l(t.blocks[e][s],o,a);let r=0;const h=s<<3;for(let e=0;e<8;e++){const t=i[n+e];for(let e=0;e<8;e++)t[h+e]=o[r++]}}}return i}class Ws{constructor(){this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}resetFrames(){this.frames=[]}parse(e){let t=0;function i(){const i=e[t]<<8|e[t+1];return t+=2,i}function r(){const r=i(),n=e.subarray(t,t+r-2);return t+=n.length,n}function n(e){let t,i,r=0,n=0;for(i in e.components)e.components.hasOwnProperty(i)&&(t=e.components[i],r<t.h&&(r=t.h),n<t.v&&(n=t.v));const s=Math.ceil(e.samplesPerLine/8/r),a=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];const o=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),h=s*t.h,f=a*t.v,c=[];for(let e=0;e<f;e++){const e=[];for(let t=0;t<h;t++)e.push(new Int32Array(64));c.push(e)}t.blocksPerLine=o,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=s,e.mcusPerColumn=a}let s=i();if(65496!==s)throw new Error("SOI not found");for(s=i();65497!==s;){switch(s){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{const e=r();65504===s&&74===e[0]&&70===e[1]&&73===e[2]&&70===e[3]&&0===e[4]&&(this.jfif={version:{major:e[5],minor:e[6]},densityUnits:e[7],xDensity:e[8]<<8|e[9],yDensity:e[10]<<8|e[11],thumbWidth:e[12],thumbHeight:e[13],thumbData:e.subarray(14,14+3*e[12]*e[13])}),65518===s&&65===e[0]&&100===e[1]&&111===e[2]&&98===e[3]&&101===e[4]&&0===e[5]&&(this.adobe={version:e[6],flags0:e[7]<<8|e[8],flags1:e[9]<<8|e[10],transformCode:e[11]});break}case 65499:{const r=i()+t-2;for(;t<r;){const r=e[t++],n=new Int32Array(64);if(r>>4==0)for(let i=0;i<64;i++){n[zs[i]]=e[t++]}else{if(r>>4!=1)throw new Error("DQT: invalid table spec");for(let e=0;e<64;e++){n[zs[e]]=i()}}this.quantizationTables[15&r]=n}break}case 65472:case 65473:case 65474:{i();const r={extended:65473===s,progressive:65474===s,precision:e[t++],scanLines:i(),samplesPerLine:i(),components:{},componentsOrder:[]},a=e[t++];let o;for(let i=0;i<a;i++){o=e[t];const i=e[t+1]>>4,n=15&e[t+1],s=e[t+2];r.componentsOrder.push(o),r.components[o]={h:i,v:n,quantizationIdx:s},t+=3}n(r),this.frames.push(r);break}case 65476:{const r=i();for(let i=2;i<r;){const r=e[t++],n=new Uint8Array(16);let s=0;for(let i=0;i<16;i++,t++)n[i]=e[t],s+=n[i];const a=new Uint8Array(s);for(let i=0;i<s;i++,t++)a[i]=e[t];i+=17+s,r>>4==0?this.huffmanTablesDC[15&r]=Zs(n,a):this.huffmanTablesAC[15&r]=Zs(n,a)}break}case 65501:i(),this.resetInterval=i();break;case 65498:{i();const r=e[t++],n=[],s=this.frames[0];for(let i=0;i<r;i++){const i=s.components[e[t++]],r=e[t++];i.huffmanTableDC=this.huffmanTablesDC[r>>4],i.huffmanTableAC=this.huffmanTablesAC[15&r],n.push(i)}const a=e[t++],o=e[t++],l=e[t++],h=Hs(e,t,s,n,this.resetInterval,a,o,l>>4,15&l);t+=h;break}case 65535:255!==e[t]&&t--;break;default:if(255===e[t-3]&&e[t-2]>=192&&e[t-2]<=254){t-=3;break}throw new Error(`unknown JPEG marker ${s.toString(16)}`)}s=i()}}getResult(){const{frames:e}=this;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let e=0;e<this.frames.length;e++){const t=this.frames[e].components;for(const e of Object.keys(t))t[e].quantizationTable=this.quantizationTables[t[e].quantizationIdx],delete t[e].quantizationIdx}const t=e[0],{components:i,componentsOrder:r}=t,n=[],s=t.samplesPerLine,a=t.scanLines;for(let e=0;e<r.length;e++){const s=i[r[e]];n.push({lines:Ys(0,s),scaleX:s.h/t.maxH,scaleY:s.v/t.maxV})}const o=new Uint8Array(s*a*n.length);let l=0;for(let e=0;e<a;++e)for(let t=0;t<s;++t)for(let i=0;i<n.length;++i){const r=n[i];o[l]=r.lines[0|e*r.scaleY][0|t*r.scaleX],++l}return o}}var Xs=Object.freeze({__proto__:null,default:class extends ms{constructor(e){super(),this.reader=new Ws,e.JPEGTables&&this.reader.parse(e.JPEGTables)}decodeBlock(e){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(e)),this.reader.getResult().buffer}}});var $s=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return Ji(new Uint8Array(e)).buffer}}});var qs=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){const t=new DataView(e),i=[];for(let r=0;r<e.byteLength;++r){let e=t.getInt8(r);if(e<0){const n=t.getUint8(r+1);e=-e;for(let t=0;t<=e;++t)i.push(n);r+=1}else{for(let n=0;n<=e;++n)i.push(t.getUint8(r+n+1));r+=e+1}}return new Uint8Array(i).buffer}}}),Js={exports:{}};!function(e){
|
|
3
|
+
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */;function Z(e){let t=e.length;for(;--t>=0;)e[t]=0}const H=256,Y=286,W=30,X=15,$=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),q=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),J=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Q=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ee=new Array(576);Z(ee);const te=new Array(60);Z(te);const ie=new Array(512);Z(ie);const re=new Array(256);Z(re);const ne=new Array(29);Z(ne);const se=new Array(W);function ae(e,t,i,r,n){this.static_tree=e,this.extra_bits=t,this.extra_base=i,this.elems=r,this.max_length=n,this.has_stree=e&&e.length}let oe,le,he;function fe(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}Z(se);const ce=e=>e<256?ie[e]:ie[256+(e>>>7)],ue=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},de=(e,t,i)=>{e.bi_valid>16-i?(e.bi_buf|=t<<e.bi_valid&65535,ue(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=i-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=i)},ge=(e,t,i)=>{de(e,i[2*t],i[2*t+1])},me=(e,t)=>{let i=0;do{i|=1&e,e>>>=1,i<<=1}while(--t>0);return i>>>1},pe=(e,t,i)=>{const r=new Array(16);let n,s,a=0;for(n=1;n<=X;n++)a=a+i[n-1]<<1,r[n]=a;for(s=0;s<=t;s++){let t=e[2*s+1];0!==t&&(e[2*s]=me(r[t]++,t))}},we=e=>{let t;for(t=0;t<Y;t++)e.dyn_ltree[2*t]=0;for(t=0;t<W;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},ye=e=>{e.bi_valid>8?ue(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},_e=(e,t,i,r)=>{const n=2*t,s=2*i;return e[n]<e[s]||e[n]===e[s]&&r[t]<=r[i]},be=(e,t,i)=>{const r=e.heap[i];let n=i<<1;for(;n<=e.heap_len&&(n<e.heap_len&&_e(t,e.heap[n+1],e.heap[n],e.depth)&&n++,!_e(t,r,e.heap[n],e.depth));)e.heap[i]=e.heap[n],i=n,n<<=1;e.heap[i]=r},ve=(e,t,i)=>{let r,n,s,a,o=0;if(0!==e.sym_next)do{r=255&e.pending_buf[e.sym_buf+o++],r+=(255&e.pending_buf[e.sym_buf+o++])<<8,n=e.pending_buf[e.sym_buf+o++],0===r?ge(e,n,t):(s=re[n],ge(e,s+H+1,t),a=$[s],0!==a&&(n-=ne[s],de(e,n,a)),r--,s=ce(r),ge(e,s,i),a=q[s],0!==a&&(r-=se[s],de(e,r,a)))}while(o<e.sym_next);ge(e,256,t)},ke=(e,t)=>{const i=t.dyn_tree,r=t.stat_desc.static_tree,n=t.stat_desc.has_stree,s=t.stat_desc.elems;let a,o,l,h=-1;for(e.heap_len=0,e.heap_max=573,a=0;a<s;a++)0!==i[2*a]?(e.heap[++e.heap_len]=h=a,e.depth[a]=0):i[2*a+1]=0;for(;e.heap_len<2;)l=e.heap[++e.heap_len]=h<2?++h:0,i[2*l]=1,e.depth[l]=0,e.opt_len--,n&&(e.static_len-=r[2*l+1]);for(t.max_code=h,a=e.heap_len>>1;a>=1;a--)be(e,i,a);l=s;do{a=e.heap[1],e.heap[1]=e.heap[e.heap_len--],be(e,i,1),o=e.heap[1],e.heap[--e.heap_max]=a,e.heap[--e.heap_max]=o,i[2*l]=i[2*a]+i[2*o],e.depth[l]=(e.depth[a]>=e.depth[o]?e.depth[a]:e.depth[o])+1,i[2*a+1]=i[2*o+1]=l,e.heap[1]=l++,be(e,i,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const i=t.dyn_tree,r=t.max_code,n=t.stat_desc.static_tree,s=t.stat_desc.has_stree,a=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,l=t.stat_desc.max_length;let h,f,c,u,d,g,m=0;for(u=0;u<=X;u++)e.bl_count[u]=0;for(i[2*e.heap[e.heap_max]+1]=0,h=e.heap_max+1;h<573;h++)f=e.heap[h],u=i[2*i[2*f+1]+1]+1,u>l&&(u=l,m++),i[2*f+1]=u,f>r||(e.bl_count[u]++,d=0,f>=o&&(d=a[f-o]),g=i[2*f],e.opt_len+=g*(u+d),s&&(e.static_len+=g*(n[2*f+1]+d)));if(0!==m){do{for(u=l-1;0===e.bl_count[u];)u--;e.bl_count[u]--,e.bl_count[u+1]+=2,e.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(f=e.bl_count[u];0!==f;)c=e.heap[--h],c>r||(i[2*c+1]!==u&&(e.opt_len+=(u-i[2*c+1])*i[2*c],i[2*c+1]=u),f--)}})(e,t),pe(i,h,e.bl_count)},xe=(e,t,i)=>{let r,n,s=-1,a=t[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),t[2*(i+1)+1]=65535,r=0;r<=i;r++)n=a,a=t[2*(r+1)+1],++o<l&&n===a||(o<h?e.bl_tree[2*n]+=o:0!==n?(n!==s&&e.bl_tree[2*n]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,s=n,0===a?(l=138,h=3):n===a?(l=6,h=3):(l=7,h=4))},Te=(e,t,i)=>{let r,n,s=-1,a=t[1],o=0,l=7,h=4;for(0===a&&(l=138,h=3),r=0;r<=i;r++)if(n=a,a=t[2*(r+1)+1],!(++o<l&&n===a)){if(o<h)do{ge(e,n,e.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(ge(e,n,e.bl_tree),o--),ge(e,16,e.bl_tree),de(e,o-3,2)):o<=10?(ge(e,17,e.bl_tree),de(e,o-3,3)):(ge(e,18,e.bl_tree),de(e,o-11,7));o=0,s=n,0===a?(l=138,h=3):n===a?(l=6,h=3):(l=7,h=4)}};let Ae=!1;const Se=(e,t,i,r)=>{de(e,0+(r?1:0),3),ye(e),ue(e,i),ue(e,~i),i&&e.pending_buf.set(e.window.subarray(t,t+i),e.pending),e.pending+=i};var Ie=(e,t,i,r)=>{let n,s,a=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,i=4093624447;for(t=0;t<=31;t++,i>>>=1)if(1&i&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<H;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),ke(e,e.l_desc),ke(e,e.d_desc),a=(e=>{let t;for(xe(e,e.dyn_ltree,e.l_desc.max_code),xe(e,e.dyn_dtree,e.d_desc.max_code),ke(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Q[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),n=e.opt_len+3+7>>>3,s=e.static_len+3+7>>>3,s<=n&&(n=s)):n=s=i+5,i+4<=n&&-1!==t?Se(e,t,i,r):4===e.strategy||s===n?(de(e,2+(r?1:0),3),ve(e,ee,te)):(de(e,4+(r?1:0),3),((e,t,i,r)=>{let n;for(de(e,t-257,5),de(e,i-1,5),de(e,r-4,4),n=0;n<r;n++)de(e,e.bl_tree[2*Q[n]+1],3);Te(e,e.dyn_ltree,t-1),Te(e,e.dyn_dtree,i-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,a+1),ve(e,e.dyn_ltree,e.dyn_dtree)),we(e),r&&ye(e)},Ue={_tr_init:e=>{Ae||((()=>{let e,t,i,r,n;const s=new Array(16);for(i=0,r=0;r<28;r++)for(ne[r]=i,e=0;e<1<<$[r];e++)re[i++]=r;for(re[i-1]=r,n=0,r=0;r<16;r++)for(se[r]=n,e=0;e<1<<q[r];e++)ie[n++]=r;for(n>>=7;r<W;r++)for(se[r]=n<<7,e=0;e<1<<q[r]-7;e++)ie[256+n++]=r;for(t=0;t<=X;t++)s[t]=0;for(e=0;e<=143;)ee[2*e+1]=8,e++,s[8]++;for(;e<=255;)ee[2*e+1]=9,e++,s[9]++;for(;e<=279;)ee[2*e+1]=7,e++,s[7]++;for(;e<=287;)ee[2*e+1]=8,e++,s[8]++;for(pe(ee,287,s),e=0;e<W;e++)te[2*e+1]=5,te[2*e]=me(e,5);oe=new ae(ee,$,257,Y,X),le=new ae(te,q,0,W,X),he=new ae(new Array(0),J,0,19,7)})(),Ae=!0),e.l_desc=new fe(e.dyn_ltree,oe),e.d_desc=new fe(e.dyn_dtree,le),e.bl_desc=new fe(e.bl_tree,he),e.bi_buf=0,e.bi_valid=0,we(e)},_tr_stored_block:Se,_tr_flush_block:Ie,_tr_tally:(e,t,i)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=i,0===t?e.dyn_ltree[2*i]++:(e.matches++,t--,e.dyn_ltree[2*(re[i]+H+1)]++,e.dyn_dtree[2*ce(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{de(e,2,3),ge(e,256,ee),(e=>{16===e.bi_valid?(ue(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var Ce=(e,t,i,r)=>{let n=65535&e|0,s=e>>>16&65535|0,a=0;for(;0!==i;){a=i>2e3?2e3:i,i-=a;do{n=n+t[r++]|0,s=s+n|0}while(--a);n%=65521,s%=65521}return n|s<<16|0};const De=new Uint32Array((()=>{let e,t=[];for(var i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t})());var Ee=(e,t,i,r)=>{const n=De,s=r+i;e^=-1;for(let i=r;i<s;i++)e=e>>>8^n[255&(e^t[i])];return-1^e},Pe={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Me={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:Oe,_tr_stored_block:Le,_tr_flush_block:ze,_tr_tally:Ge,_tr_align:Be}=Ue,{Z_NO_FLUSH:Re,Z_PARTIAL_FLUSH:Fe,Z_FULL_FLUSH:Ve,Z_FINISH:Ne,Z_BLOCK:Ke,Z_OK:je,Z_STREAM_END:Ze,Z_STREAM_ERROR:He,Z_DATA_ERROR:Ye,Z_BUF_ERROR:We,Z_DEFAULT_COMPRESSION:Xe,Z_FILTERED:$e,Z_HUFFMAN_ONLY:qe,Z_RLE:Je,Z_FIXED:Qe,Z_DEFAULT_STRATEGY:et,Z_UNKNOWN:tt,Z_DEFLATED:it}=Me,rt=258,nt=262,st=42,at=113,ot=666,lt=(e,t)=>(e.msg=Pe[t],t),ht=e=>2*e-(e>4?9:0),ft=e=>{let t=e.length;for(;--t>=0;)e[t]=0},ct=e=>{let t,i,r,n=e.w_size;t=e.hash_size,r=t;do{i=e.head[--r],e.head[r]=i>=n?i-n:0}while(--t);t=n,r=t;do{i=e.prev[--r],e.prev[r]=i>=n?i-n:0}while(--t)};let ut=(e,t,i)=>(t<<e.hash_shift^i)&e.hash_mask;const dt=e=>{const t=e.state;let i=t.pending;i>e.avail_out&&(i=e.avail_out),0!==i&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+i),e.next_out),e.next_out+=i,t.pending_out+=i,e.total_out+=i,e.avail_out-=i,t.pending-=i,0===t.pending&&(t.pending_out=0))},gt=(e,t)=>{ze(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,dt(e.strm)},mt=(e,t)=>{e.pending_buf[e.pending++]=t},pt=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},wt=(e,t,i,r)=>{let n=e.avail_in;return n>r&&(n=r),0===n?0:(e.avail_in-=n,t.set(e.input.subarray(e.next_in,e.next_in+n),i),1===e.state.wrap?e.adler=Ce(e.adler,t,n,i):2===e.state.wrap&&(e.adler=Ee(e.adler,t,n,i)),e.next_in+=n,e.total_in+=n,n)},yt=(e,t)=>{let i,r,n=e.max_chain_length,s=e.strstart,a=e.prev_length,o=e.nice_match;const l=e.strstart>e.w_size-nt?e.strstart-(e.w_size-nt):0,h=e.window,f=e.w_mask,c=e.prev,u=e.strstart+rt;let d=h[s+a-1],g=h[s+a];e.prev_length>=e.good_match&&(n>>=2),o>e.lookahead&&(o=e.lookahead);do{if(i=t,h[i+a]===g&&h[i+a-1]===d&&h[i]===h[s]&&h[++i]===h[s+1]){s+=2,i++;do{}while(h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&h[++s]===h[++i]&&s<u);if(r=rt-(u-s),s=u-rt,r>a){if(e.match_start=t,a=r,r>=o)break;d=h[s+a-1],g=h[s+a]}}}while((t=c[t&f])>l&&0!=--n);return a<=e.lookahead?a:e.lookahead},_t=e=>{const t=e.w_size;let i,r,n;do{if(r=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-nt)&&(e.window.set(e.window.subarray(t,t+t-r),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),ct(e),r+=t),0===e.strm.avail_in)break;if(i=wt(e.strm,e.window,e.strstart+e.lookahead,r),e.lookahead+=i,e.lookahead+e.insert>=3)for(n=e.strstart-e.insert,e.ins_h=e.window[n],e.ins_h=ut(e,e.ins_h,e.window[n+1]);e.insert&&(e.ins_h=ut(e,e.ins_h,e.window[n+3-1]),e.prev[n&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=n,n++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<nt&&0!==e.strm.avail_in)},bt=(e,t)=>{let i,r,n,s=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,a=0,o=e.strm.avail_in;do{if(i=65535,n=e.bi_valid+42>>3,e.strm.avail_out<n)break;if(n=e.strm.avail_out-n,r=e.strstart-e.block_start,i>r+e.strm.avail_in&&(i=r+e.strm.avail_in),i>n&&(i=n),i<s&&(0===i&&t!==Ne||t===Re||i!==r+e.strm.avail_in))break;a=t===Ne&&i===r+e.strm.avail_in?1:0,Le(e,0,0,a),e.pending_buf[e.pending-4]=i,e.pending_buf[e.pending-3]=i>>8,e.pending_buf[e.pending-2]=~i,e.pending_buf[e.pending-1]=~i>>8,dt(e.strm),r&&(r>i&&(r=i),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+r),e.strm.next_out),e.strm.next_out+=r,e.strm.avail_out-=r,e.strm.total_out+=r,e.block_start+=r,i-=r),i&&(wt(e.strm,e.strm.output,e.strm.next_out,i),e.strm.next_out+=i,e.strm.avail_out-=i,e.strm.total_out+=i)}while(0===a);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),a?4:t!==Re&&t!==Ne&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(n=e.window_size-e.strstart,e.strm.avail_in>n&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,n+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),n>e.strm.avail_in&&(n=e.strm.avail_in),n&&(wt(e.strm,e.window,e.strstart,n),e.strstart+=n,e.insert+=n>e.w_size-e.insert?e.w_size-e.insert:n),e.high_water<e.strstart&&(e.high_water=e.strstart),n=e.bi_valid+42>>3,n=e.pending_buf_size-n>65535?65535:e.pending_buf_size-n,s=n>e.w_size?e.w_size:n,r=e.strstart-e.block_start,(r>=s||(r||t===Ne)&&t!==Re&&0===e.strm.avail_in&&r<=n)&&(i=r>n?n:r,a=t===Ne&&0===e.strm.avail_in&&i===r?1:0,Le(e,e.block_start,i,a),e.block_start+=i,dt(e.strm)),a?3:1)},vt=(e,t)=>{let i,r;for(;;){if(e.lookahead<nt){if(_t(e),e.lookahead<nt&&t===Re)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==i&&e.strstart-i<=e.w_size-nt&&(e.match_length=yt(e,i)),e.match_length>=3)if(r=Ge(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=ut(e,e.ins_h,e.window[e.strstart+1]);else r=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(r&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2},kt=(e,t)=>{let i,r,n;for(;;){if(e.lookahead<nt){if(_t(e),e.lookahead<nt&&t===Re)return 1;if(0===e.lookahead)break}if(i=0,e.lookahead>=3&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==i&&e.prev_length<e.max_lazy_match&&e.strstart-i<=e.w_size-nt&&(e.match_length=yt(e,i),e.match_length<=5&&(e.strategy===$e||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){n=e.strstart+e.lookahead-3,r=Ge(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=n&&(e.ins_h=ut(e,e.ins_h,e.window[e.strstart+3-1]),i=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,r&&(gt(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(r=Ge(e,0,e.window[e.strstart-1]),r&>(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(r=Ge(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2};function xt(e,t,i,r,n){this.good_length=e,this.max_lazy=t,this.nice_length=i,this.max_chain=r,this.func=n}const Tt=[new xt(0,0,0,0,bt),new xt(4,4,8,4,vt),new xt(4,5,16,8,vt),new xt(4,6,32,32,vt),new xt(4,4,16,16,kt),new xt(8,16,32,32,kt),new xt(8,16,128,128,kt),new xt(8,32,128,256,kt),new xt(32,128,258,1024,kt),new xt(32,258,258,4096,kt)];function At(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=it,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ft(this.dyn_ltree),ft(this.dyn_dtree),ft(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ft(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ft(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const St=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==st&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==at&&t.status!==ot?1:0},It=e=>{if(St(e))return lt(e,He);e.total_in=e.total_out=0,e.data_type=tt;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?st:at,e.adler=2===t.wrap?0:1,t.last_flush=-2,Oe(t),je},Ut=e=>{const t=It(e);var i;return t===je&&((i=e.state).window_size=2*i.w_size,ft(i.head),i.max_lazy_match=Tt[i.level].max_lazy,i.good_match=Tt[i.level].good_length,i.nice_match=Tt[i.level].nice_length,i.max_chain_length=Tt[i.level].max_chain,i.strstart=0,i.block_start=0,i.lookahead=0,i.insert=0,i.match_length=i.prev_length=2,i.match_available=0,i.ins_h=0),t},Ct=(e,t,i,r,n,s)=>{if(!e)return He;let a=1;if(t===Xe&&(t=6),r<0?(a=0,r=-r):r>15&&(a=2,r-=16),n<1||n>9||i!==it||r<8||r>15||t<0||t>9||s<0||s>Qe||8===r&&1!==a)return lt(e,He);8===r&&(r=9);const o=new At;return e.state=o,o.strm=e,o.status=st,o.wrap=a,o.gzhead=null,o.w_bits=r,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=s,o.method=i,Ut(e)};var Dt={deflateInit:(e,t)=>Ct(e,t,it,15,8,et),deflateInit2:Ct,deflateReset:Ut,deflateResetKeep:It,deflateSetHeader:(e,t)=>St(e)||2!==e.state.wrap?He:(e.state.gzhead=t,je),deflate:(e,t)=>{if(St(e)||t>Ke||t<0)return e?lt(e,He):He;const i=e.state;if(!e.output||0!==e.avail_in&&!e.input||i.status===ot&&t!==Ne)return lt(e,0===e.avail_out?We:He);const r=i.last_flush;if(i.last_flush=t,0!==i.pending){if(dt(e),0===e.avail_out)return i.last_flush=-1,je}else if(0===e.avail_in&&ht(t)<=ht(r)&&t!==Ne)return lt(e,We);if(i.status===ot&&0!==e.avail_in)return lt(e,We);if(i.status===st&&0===i.wrap&&(i.status=at),i.status===st){let t=it+(i.w_bits-8<<4)<<8,r=-1;if(r=i.strategy>=qe||i.level<2?0:i.level<6?1:6===i.level?2:3,t|=r<<6,0!==i.strstart&&(t|=32),t+=31-t%31,pt(i,t),0!==i.strstart&&(pt(i,e.adler>>>16),pt(i,65535&e.adler)),e.adler=1,i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je}if(57===i.status)if(e.adler=0,mt(i,31),mt(i,139),mt(i,8),i.gzhead)mt(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),mt(i,255&i.gzhead.time),mt(i,i.gzhead.time>>8&255),mt(i,i.gzhead.time>>16&255),mt(i,i.gzhead.time>>24&255),mt(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),mt(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(mt(i,255&i.gzhead.extra.length),mt(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(e.adler=Ee(e.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69;else if(mt(i,0),mt(i,0),mt(i,0),mt(i,0),mt(i,0),mt(i,9===i.level?2:i.strategy>=qe||i.level<2?4:0),mt(i,3),i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je;if(69===i.status){if(i.gzhead.extra){let t=i.pending,r=(65535&i.gzhead.extra.length)-i.gzindex;for(;i.pending+r>i.pending_buf_size;){let n=i.pending_buf_size-i.pending;if(i.pending_buf.set(i.gzhead.extra.subarray(i.gzindex,i.gzindex+n),i.pending),i.pending=i.pending_buf_size,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex+=n,dt(e),0!==i.pending)return i.last_flush=-1,je;t=0,r-=n}let n=new Uint8Array(i.gzhead.extra);i.pending_buf.set(n.subarray(i.gzindex,i.gzindex+r),i.pending),i.pending+=r,i.gzhead.hcrc&&i.pending>t&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-t,t)),i.gzindex=0}i.status=73}if(73===i.status){if(i.gzhead.name){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),dt(e),0!==i.pending)return i.last_flush=-1,je;r=0}t=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,mt(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),i.gzindex=0}i.status=91}if(91===i.status){if(i.gzhead.comment){let t,r=i.pending;do{if(i.pending===i.pending_buf_size){if(i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r)),dt(e),0!==i.pending)return i.last_flush=-1,je;r=0}t=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,mt(i,t)}while(0!==t);i.gzhead.hcrc&&i.pending>r&&(e.adler=Ee(e.adler,i.pending_buf,i.pending-r,r))}i.status=103}if(103===i.status){if(i.gzhead.hcrc){if(i.pending+2>i.pending_buf_size&&(dt(e),0!==i.pending))return i.last_flush=-1,je;mt(i,255&e.adler),mt(i,e.adler>>8&255),e.adler=0}if(i.status=at,dt(e),0!==i.pending)return i.last_flush=-1,je}if(0!==e.avail_in||0!==i.lookahead||t!==Re&&i.status!==ot){let r=0===i.level?bt(i,t):i.strategy===qe?((e,t)=>{let i;for(;;){if(0===e.lookahead&&(_t(e),0===e.lookahead)){if(t===Re)return 1;break}if(e.match_length=0,i=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,i&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2})(i,t):i.strategy===Je?((e,t)=>{let i,r,n,s;const a=e.window;for(;;){if(e.lookahead<=rt){if(_t(e),e.lookahead<=rt&&t===Re)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(n=e.strstart-1,r=a[n],r===a[++n]&&r===a[++n]&&r===a[++n])){s=e.strstart+rt;do{}while(r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&r===a[++n]&&n<s);e.match_length=rt-(s-n),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(i=Ge(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(i=Ge(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),i&&(gt(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===Ne?(gt(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(gt(e,!1),0===e.strm.avail_out)?1:2})(i,t):Tt[i.level].func(i,t);if(3!==r&&4!==r||(i.status=ot),1===r||3===r)return 0===e.avail_out&&(i.last_flush=-1),je;if(2===r&&(t===Fe?Be(i):t!==Ke&&(Le(i,0,0,!1),t===Ve&&(ft(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),dt(e),0===e.avail_out))return i.last_flush=-1,je}return t!==Ne?je:i.wrap<=0?Ze:(2===i.wrap?(mt(i,255&e.adler),mt(i,e.adler>>8&255),mt(i,e.adler>>16&255),mt(i,e.adler>>24&255),mt(i,255&e.total_in),mt(i,e.total_in>>8&255),mt(i,e.total_in>>16&255),mt(i,e.total_in>>24&255)):(pt(i,e.adler>>>16),pt(i,65535&e.adler)),dt(e),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?je:Ze)},deflateEnd:e=>{if(St(e))return He;const t=e.state.status;return e.state=null,t===at?lt(e,Ye):je},deflateSetDictionary:(e,t)=>{let i=t.length;if(St(e))return He;const r=e.state,n=r.wrap;if(2===n||1===n&&r.status!==st||r.lookahead)return He;if(1===n&&(e.adler=Ce(e.adler,t,i,0)),r.wrap=0,i>=r.w_size){0===n&&(ft(r.head),r.strstart=0,r.block_start=0,r.insert=0);let e=new Uint8Array(r.w_size);e.set(t.subarray(i-r.w_size,i),0),t=e,i=r.w_size}const s=e.avail_in,a=e.next_in,o=e.input;for(e.avail_in=i,e.next_in=0,e.input=t,_t(r);r.lookahead>=3;){let e=r.strstart,t=r.lookahead-2;do{r.ins_h=ut(r,r.ins_h,r.window[e+3-1]),r.prev[e&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=e,e++}while(--t);r.strstart=e,r.lookahead=2,_t(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,e.next_in=a,e.input=o,e.avail_in=s,r.wrap=n,je},deflateInfo:"pako deflate (from Nodeca project)"};const Et=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var Pt={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(const t in i)Et(i,t)&&(e[t]=i[t])}}return e},flattenChunks:e=>{let t=0;for(let i=0,r=e.length;i<r;i++)t+=e[i].length;const i=new Uint8Array(t);for(let t=0,r=0,n=e.length;t<n;t++){let n=e[t];i.set(n,r),r+=n.length}return i}};let Mt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){Mt=!1}const Ot=new Uint8Array(256);for(let e=0;e<256;e++)Ot[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;Ot[254]=Ot[254]=1;var Lt={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,i,r,n,s,a=e.length,o=0;for(n=0;n<a;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<a&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),o+=i<128?1:i<2048?2:i<65536?3:4;for(t=new Uint8Array(o),s=0,n=0;s<o;n++)i=e.charCodeAt(n),55296==(64512&i)&&n+1<a&&(r=e.charCodeAt(n+1),56320==(64512&r)&&(i=65536+(i-55296<<10)+(r-56320),n++)),i<128?t[s++]=i:i<2048?(t[s++]=192|i>>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t},buf2string:(e,t)=>{const i=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let r,n;const s=new Array(2*i);for(n=0,r=0;r<i;){let t=e[r++];if(t<128){s[n++]=t;continue}let a=Ot[t];if(a>4)s[n++]=65533,r+=a-1;else{for(t&=2===a?31:3===a?15:7;a>1&&r<i;)t=t<<6|63&e[r++],a--;a>1?s[n++]=65533:t<65536?s[n++]=t:(t-=65536,s[n++]=55296|t>>10&1023,s[n++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&Mt)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let i="";for(let r=0;r<t;r++)i+=String.fromCharCode(e[r]);return i})(s,n)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let i=t-1;for(;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Ot[e[i]]>t?i:t}};var zt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Gt=Object.prototype.toString,{Z_NO_FLUSH:Bt,Z_SYNC_FLUSH:Rt,Z_FULL_FLUSH:Ft,Z_FINISH:Vt,Z_OK:Nt,Z_STREAM_END:Kt,Z_DEFAULT_COMPRESSION:jt,Z_DEFAULT_STRATEGY:Zt,Z_DEFLATED:Ht}=Me;function Yt(e){this.options=Pt.assign({level:jt,method:Ht,chunkSize:16384,windowBits:15,memLevel:8,strategy:Zt},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zt,this.strm.avail_out=0;let i=Dt.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(i!==Nt)throw new Error(Pe[i]);if(t.header&&Dt.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?Lt.string2buf(t.dictionary):"[object ArrayBuffer]"===Gt.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,i=Dt.deflateSetDictionary(this.strm,e),i!==Nt)throw new Error(Pe[i]);this._dict_set=!0}}Yt.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=t===~~t?t:!0===t?Vt:Bt,"string"==typeof e?i.input=Lt.string2buf(e):"[object ArrayBuffer]"===Gt.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;)if(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),(s===Rt||s===Ft)&&i.avail_out<=6)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else{if(n=Dt.deflate(i,s),n===Kt)return i.next_out>0&&this.onData(i.output.subarray(0,i.next_out)),n=Dt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===Nt;if(0!==i.avail_out){if(s>0&&i.next_out>0)this.onData(i.output.subarray(0,i.next_out)),i.avail_out=0;else if(0===i.avail_in)break}else this.onData(i.output)}return!0},Yt.prototype.onData=function(e){this.chunks.push(e)},Yt.prototype.onEnd=function(e){e===Nt&&(this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};const Wt=16209;var Xt=function(e,t){let i,r,n,s,a,o,l,h,f,c,u,d,g,m,p,w,y,_,b,v,k,x,T,A;const S=e.state;i=e.next_in,T=e.input,r=i+(e.avail_in-5),n=e.next_out,A=e.output,s=n-(t-e.avail_out),a=n+(e.avail_out-257),o=S.dmax,l=S.wsize,h=S.whave,f=S.wnext,c=S.window,u=S.hold,d=S.bits,g=S.lencode,m=S.distcode,p=(1<<S.lenbits)-1,w=(1<<S.distbits)-1;e:do{d<15&&(u+=T[i++]<<d,d+=8,u+=T[i++]<<d,d+=8),y=g[u&p];t:for(;;){if(_=y>>>24,u>>>=_,d-=_,_=y>>>16&255,0===_)A[n++]=65535&y;else{if(!(16&_)){if(0==(64&_)){y=g[(65535&y)+(u&(1<<_)-1)];continue t}if(32&_){S.mode=16191;break e}e.msg="invalid literal/length code",S.mode=Wt;break e}b=65535&y,_&=15,_&&(d<_&&(u+=T[i++]<<d,d+=8),b+=u&(1<<_)-1,u>>>=_,d-=_),d<15&&(u+=T[i++]<<d,d+=8,u+=T[i++]<<d,d+=8),y=m[u&w];i:for(;;){if(_=y>>>24,u>>>=_,d-=_,_=y>>>16&255,!(16&_)){if(0==(64&_)){y=m[(65535&y)+(u&(1<<_)-1)];continue i}e.msg="invalid distance code",S.mode=Wt;break e}if(v=65535&y,_&=15,d<_&&(u+=T[i++]<<d,d+=8,d<_&&(u+=T[i++]<<d,d+=8)),v+=u&(1<<_)-1,v>o){e.msg="invalid distance too far back",S.mode=Wt;break e}if(u>>>=_,d-=_,_=n-s,v>_){if(_=v-_,_>h&&S.sane){e.msg="invalid distance too far back",S.mode=Wt;break e}if(k=0,x=c,0===f){if(k+=l-_,_<b){b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}}else if(f<_){if(k+=l+f-_,_-=f,_<b){b-=_;do{A[n++]=c[k++]}while(--_);if(k=0,f<b){_=f,b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}}}else if(k+=f-_,_<b){b-=_;do{A[n++]=c[k++]}while(--_);k=n-v,x=A}for(;b>2;)A[n++]=x[k++],A[n++]=x[k++],A[n++]=x[k++],b-=3;b&&(A[n++]=x[k++],b>1&&(A[n++]=x[k++]))}else{k=n-v;do{A[n++]=A[k++],A[n++]=A[k++],A[n++]=A[k++],b-=3}while(b>2);b&&(A[n++]=A[k++],b>1&&(A[n++]=A[k++]))}break}}break}}while(i<r&&n<a);b=d>>3,i-=b,d-=b<<3,u&=(1<<d)-1,e.next_in=i,e.next_out=n,e.avail_in=i<r?r-i+5:5-(i-r),e.avail_out=n<a?a-n+257:257-(n-a),S.hold=u,S.bits=d};const $t=15,qt=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Jt=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Qt=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),ei=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var ti=(e,t,i,r,n,s,a,o)=>{const l=o.bits;let h,f,c,u,d,g,m=0,p=0,w=0,y=0,_=0,b=0,v=0,k=0,x=0,T=0,A=null;const S=new Uint16Array(16),I=new Uint16Array(16);let U,C,D,E=null;for(m=0;m<=$t;m++)S[m]=0;for(p=0;p<r;p++)S[t[i+p]]++;for(_=l,y=$t;y>=1&&0===S[y];y--);if(_>y&&(_=y),0===y)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(w=1;w<y&&0===S[w];w++);for(_<w&&(_=w),k=1,m=1;m<=$t;m++)if(k<<=1,k-=S[m],k<0)return-1;if(k>0&&(0===e||1!==y))return-1;for(I[1]=0,m=1;m<$t;m++)I[m+1]=I[m]+S[m];for(p=0;p<r;p++)0!==t[i+p]&&(a[I[t[i+p]]++]=p);if(0===e?(A=E=a,g=20):1===e?(A=qt,E=Jt,g=257):(A=Qt,E=ei,g=0),T=0,p=0,m=w,d=s,b=_,v=0,c=-1,x=1<<_,u=x-1,1===e&&x>852||2===e&&x>592)return 1;for(;;){U=m-v,a[p]+1<g?(C=0,D=a[p]):a[p]>=g?(C=E[a[p]-g],D=A[a[p]-g]):(C=96,D=0),h=1<<m-v,f=1<<b,w=f;do{f-=h,n[d+(T>>v)+f]=U<<24|C<<16|D|0}while(0!==f);for(h=1<<m-1;T&h;)h>>=1;if(0!==h?(T&=h-1,T+=h):T=0,p++,0==--S[m]){if(m===y)break;m=t[i+a[p]]}if(m>_&&(T&u)!==c){for(0===v&&(v=_),d+=w,b=m-v,k=1<<b;b+v<y&&(k-=S[b+v],!(k<=0));)b++,k<<=1;if(x+=1<<b,1===e&&x>852||2===e&&x>592)return 1;c=T&u,n[c]=_<<24|b<<16|d-s|0}}return 0!==T&&(n[d+T]=m-v<<24|64<<16|0),o.bits=_,0};const{Z_FINISH:ii,Z_BLOCK:ri,Z_TREES:ni,Z_OK:si,Z_STREAM_END:ai,Z_NEED_DICT:oi,Z_STREAM_ERROR:li,Z_DATA_ERROR:hi,Z_MEM_ERROR:fi,Z_BUF_ERROR:ci,Z_DEFLATED:ui}=Me,di=16180,gi=16190,mi=16191,pi=16192,wi=16194,yi=16199,_i=16200,bi=16206,vi=16209,ki=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function xi(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ti=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<di||t.mode>16211?1:0},Ai=e=>{if(Ti(e))return li;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=di,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,si},Si=e=>{if(Ti(e))return li;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,Ai(e)},Ii=(e,t)=>{let i;if(Ti(e))return li;const r=e.state;return t<0?(i=0,t=-t):(i=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?li:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,Si(e))},Ui=(e,t)=>{if(!e)return li;const i=new xi;e.state=i,i.strm=e,i.window=null,i.mode=di;const r=Ii(e,t);return r!==si&&(e.state=null),r};let Ci,Di,Ei=!0;const Pi=e=>{if(Ei){Ci=new Int32Array(512),Di=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(ti(1,e.lens,0,288,Ci,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;ti(2,e.lens,0,32,Di,0,e.work,{bits:5}),Ei=!1}e.lencode=Ci,e.lenbits=9,e.distcode=Di,e.distbits=5},Mi=(e,t,i,r)=>{let n;const s=e.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),r>=s.wsize?(s.window.set(t.subarray(i-s.wsize,i),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>r&&(n=r),s.window.set(t.subarray(i-r,i-r+n),s.wnext),(r-=n)?(s.window.set(t.subarray(i-r,i),0),s.wnext=r,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var Oi={inflateReset:Si,inflateReset2:Ii,inflateResetKeep:Ai,inflateInit:e=>Ui(e,15),inflateInit2:Ui,inflate:(e,t)=>{let i,r,n,s,a,o,l,h,f,c,u,d,g,m,p,w,y,_,b,v,k,x,T=0;const A=new Uint8Array(4);let S,I;const U=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ti(e)||!e.output||!e.input&&0!==e.avail_in)return li;i=e.state,i.mode===mi&&(i.mode=pi),a=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,c=o,u=l,x=si;e:for(;;)switch(i.mode){case di:if(0===i.wrap){i.mode=pi;break}for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(2&i.wrap&&35615===h){0===i.wbits&&(i.wbits=15),i.check=0,A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0),h=0,f=0,i.mode=16181;break}if(i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&h)<<8)+(h>>8))%31){e.msg="incorrect header check",i.mode=vi;break}if((15&h)!==ui){e.msg="unknown compression method",i.mode=vi;break}if(h>>>=4,f-=4,k=8+(15&h),0===i.wbits&&(i.wbits=k),k>15||k>i.wbits){e.msg="invalid window size",i.mode=vi;break}i.dmax=1<<i.wbits,i.flags=0,e.adler=i.check=1,i.mode=512&h?16189:mi,h=0,f=0;break;case 16181:for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(i.flags=h,(255&i.flags)!==ui){e.msg="unknown compression method",i.mode=vi;break}if(57344&i.flags){e.msg="unknown header flags set",i.mode=vi;break}i.head&&(i.head.text=h>>8&1),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0,i.mode=16182;case 16182:for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.head&&(i.head.time=h),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,i.check=Ee(i.check,A,4,0)),h=0,f=0,i.mode=16183;case 16183:for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.head&&(i.head.xflags=255&h,i.head.os=h>>8),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0,i.mode=16184;case 16184:if(1024&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.length=h,i.head&&(i.head.extra_len=h),512&i.flags&&4&i.wrap&&(A[0]=255&h,A[1]=h>>>8&255,i.check=Ee(i.check,A,2,0)),h=0,f=0}else i.head&&(i.head.extra=null);i.mode=16185;case 16185:if(1024&i.flags&&(d=i.length,d>o&&(d=o),d&&(i.head&&(k=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Uint8Array(i.head.extra_len)),i.head.extra.set(r.subarray(s,s+d),k)),512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,i.length-=d),i.length))break e;i.length=0,i.mode=16186;case 16186:if(2048&i.flags){if(0===o)break e;d=0;do{k=r[s+d++],i.head&&k&&i.length<65536&&(i.head.name+=String.fromCharCode(k))}while(k&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,k)break e}else i.head&&(i.head.name=null);i.length=0,i.mode=16187;case 16187:if(4096&i.flags){if(0===o)break e;d=0;do{k=r[s+d++],i.head&&k&&i.length<65536&&(i.head.comment+=String.fromCharCode(k))}while(k&&d<o);if(512&i.flags&&4&i.wrap&&(i.check=Ee(i.check,r,d,s)),o-=d,s+=d,k)break e}else i.head&&(i.head.comment=null);i.mode=16188;case 16188:if(512&i.flags){for(;f<16;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(4&i.wrap&&h!==(65535&i.check)){e.msg="header crc mismatch",i.mode=vi;break}h=0,f=0}i.head&&(i.head.hcrc=i.flags>>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=mi;break;case 16189:for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}e.adler=i.check=ki(h),h=0,f=0,i.mode=gi;case gi:if(0===i.havedict)return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,oi;e.adler=i.check=1,i.mode=mi;case mi:if(t===ri||t===ni)break e;case pi:if(i.last){h>>>=7&f,f-=7&f,i.mode=bi;break}for(;f<3;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}switch(i.last=1&h,h>>>=1,f-=1,3&h){case 0:i.mode=16193;break;case 1:if(Pi(i),i.mode=yi,t===ni){h>>>=2,f-=2;break e}break;case 2:i.mode=16196;break;case 3:e.msg="invalid block type",i.mode=vi}h>>>=2,f-=2;break;case 16193:for(h>>>=7&f,f-=7&f;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if((65535&h)!=(h>>>16^65535)){e.msg="invalid stored block lengths",i.mode=vi;break}if(i.length=65535&h,h=0,f=0,i.mode=wi,t===ni)break e;case wi:i.mode=16195;case 16195:if(d=i.length,d){if(d>o&&(d=o),d>l&&(d=l),0===d)break e;n.set(r.subarray(s,s+d),a),o-=d,s+=d,l-=d,a+=d,i.length-=d;break}i.mode=mi;break;case 16196:for(;f<14;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(i.nlen=257+(31&h),h>>>=5,f-=5,i.ndist=1+(31&h),h>>>=5,f-=5,i.ncode=4+(15&h),h>>>=4,f-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=vi;break}i.have=0,i.mode=16197;case 16197:for(;i.have<i.ncode;){for(;f<3;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.lens[U[i.have++]]=7&h,h>>>=3,f-=3}for(;i.have<19;)i.lens[U[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},x=ti(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,x){e.msg="invalid code lengths set",i.mode=vi;break}i.have=0,i.mode=16198;case 16198:for(;i.have<i.nlen+i.ndist;){for(;T=i.lencode[h&(1<<i.lenbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(y<16)h>>>=p,f-=p,i.lens[i.have++]=y;else{if(16===y){for(I=p+2;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(h>>>=p,f-=p,0===i.have){e.msg="invalid bit length repeat",i.mode=vi;break}k=i.lens[i.have-1],d=3+(3&h),h>>>=2,f-=2}else if(17===y){for(I=p+3;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=p,f-=p,k=0,d=3+(7&h),h>>>=3,f-=3}else{for(I=p+7;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=p,f-=p,k=0,d=11+(127&h),h>>>=7,f-=7}if(i.have+d>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=vi;break}for(;d--;)i.lens[i.have++]=k}}if(i.mode===vi)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=vi;break}if(i.lenbits=9,S={bits:i.lenbits},x=ti(1,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,x){e.msg="invalid literal/lengths set",i.mode=vi;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},x=ti(2,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,x){e.msg="invalid distances set",i.mode=vi;break}if(i.mode=yi,t===ni)break e;case yi:i.mode=_i;case _i:if(o>=6&&l>=258){e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,Xt(e,u),a=e.next_out,n=e.output,l=e.avail_out,s=e.next_in,r=e.input,o=e.avail_in,h=i.hold,f=i.bits,i.mode===mi&&(i.back=-1);break}for(i.back=0;T=i.lencode[h&(1<<i.lenbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(w&&0==(240&w)){for(_=p,b=w,v=y;T=i.lencode[v+((h&(1<<_+b)-1)>>_)],p=T>>>24,w=T>>>16&255,y=65535&T,!(_+p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=_,f-=_,i.back+=_}if(h>>>=p,f-=p,i.back+=p,i.length=y,0===w){i.mode=16205;break}if(32&w){i.back=-1,i.mode=mi;break}if(64&w){e.msg="invalid literal/length code",i.mode=vi;break}i.extra=15&w,i.mode=16201;case 16201:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.length+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=16202;case 16202:for(;T=i.distcode[h&(1<<i.distbits)-1],p=T>>>24,w=T>>>16&255,y=65535&T,!(p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(0==(240&w)){for(_=p,b=w,v=y;T=i.distcode[v+((h&(1<<_+b)-1)>>_)],p=T>>>24,w=T>>>16&255,y=65535&T,!(_+p<=f);){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}h>>>=_,f-=_,i.back+=_}if(h>>>=p,f-=p,i.back+=p,64&w){e.msg="invalid distance code",i.mode=vi;break}i.offset=y,i.extra=15&w,i.mode=16203;case 16203:if(i.extra){for(I=i.extra;f<I;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}i.offset+=h&(1<<i.extra)-1,h>>>=i.extra,f-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=vi;break}i.mode=16204;case 16204:if(0===l)break e;if(d=u-l,i.offset>d){if(d=i.offset-d,d>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=vi;break}d>i.wnext?(d-=i.wnext,g=i.wsize-d):g=i.wnext-d,d>i.length&&(d=i.length),m=i.window}else m=n,g=a-i.offset,d=i.length;d>l&&(d=l),l-=d,i.length-=d;do{n[a++]=m[g++]}while(--d);0===i.length&&(i.mode=_i);break;case 16205:if(0===l)break e;n[a++]=i.length,l--,i.mode=_i;break;case bi:if(i.wrap){for(;f<32;){if(0===o)break e;o--,h|=r[s++]<<f,f+=8}if(u-=l,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ee(i.check,n,u,a-u):Ce(i.check,n,u,a-u)),u=l,4&i.wrap&&(i.flags?h:ki(h))!==i.check){e.msg="incorrect data check",i.mode=vi;break}h=0,f=0}i.mode=16207;case 16207:if(i.wrap&&i.flags){for(;f<32;){if(0===o)break e;o--,h+=r[s++]<<f,f+=8}if(4&i.wrap&&h!==(4294967295&i.total)){e.msg="incorrect length check",i.mode=vi;break}h=0,f=0}i.mode=16208;case 16208:x=ai;break e;case vi:x=hi;break e;case 16210:return fi;default:return li}return e.next_out=a,e.avail_out=l,e.next_in=s,e.avail_in=o,i.hold=h,i.bits=f,(i.wsize||u!==e.avail_out&&i.mode<vi&&(i.mode<bi||t!==ii))&&Mi(e,e.output,e.next_out,u-e.avail_out),c-=e.avail_in,u-=e.avail_out,e.total_in+=c,e.total_out+=u,i.total+=u,4&i.wrap&&u&&(e.adler=i.check=i.flags?Ee(i.check,n,u,e.next_out-u):Ce(i.check,n,u,e.next_out-u)),e.data_type=i.bits+(i.last?64:0)+(i.mode===mi?128:0)+(i.mode===yi||i.mode===wi?256:0),(0===c&&0===u||t===ii)&&x===si&&(x=ci),x},inflateEnd:e=>{if(Ti(e))return li;let t=e.state;return t.window&&(t.window=null),e.state=null,si},inflateGetHeader:(e,t)=>{if(Ti(e))return li;const i=e.state;return 0==(2&i.wrap)?li:(i.head=t,t.done=!1,si)},inflateSetDictionary:(e,t)=>{const i=t.length;let r,n,s;return Ti(e)?li:(r=e.state,0!==r.wrap&&r.mode!==gi?li:r.mode===gi&&(n=1,n=Ce(n,t,i,0),n!==r.check)?hi:(s=Mi(e,t,i,i),s?(r.mode=16210,fi):(r.havedict=1,si)))},inflateInfo:"pako inflate (from Nodeca project)"};var Li=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const zi=Object.prototype.toString,{Z_NO_FLUSH:Gi,Z_FINISH:Bi,Z_OK:Ri,Z_STREAM_END:Fi,Z_NEED_DICT:Vi,Z_STREAM_ERROR:Ni,Z_DATA_ERROR:Ki,Z_MEM_ERROR:ji}=Me;function Zi(e){this.options=Pt.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zt,this.strm.avail_out=0;let i=Oi.inflateInit2(this.strm,t.windowBits);if(i!==Ri)throw new Error(Pe[i]);if(this.header=new Li,Oi.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=Lt.string2buf(t.dictionary):"[object ArrayBuffer]"===zi.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(i=Oi.inflateSetDictionary(this.strm,t.dictionary),i!==Ri)))throw new Error(Pe[i])}function Hi(e,t){const i=new Zi(t);if(i.push(e),i.err)throw i.msg||Pe[i.err];return i.result}Zi.prototype.push=function(e,t){const i=this.strm,r=this.options.chunkSize,n=this.options.dictionary;let s,a,o;if(this.ended)return!1;for(a=t===~~t?t:!0===t?Bi:Gi,"[object ArrayBuffer]"===zi.call(e)?i.input=new Uint8Array(e):i.input=e,i.next_in=0,i.avail_in=i.input.length;;){for(0===i.avail_out&&(i.output=new Uint8Array(r),i.next_out=0,i.avail_out=r),s=Oi.inflate(i,a),s===Vi&&n&&(s=Oi.inflateSetDictionary(i,n),s===Ri?s=Oi.inflate(i,a):s===Ki&&(s=Vi));i.avail_in>0&&s===Fi&&i.state.wrap>0&&0!==e[i.next_in];)Oi.inflateReset(i),s=Oi.inflate(i,a);switch(s){case Ni:case Ki:case Vi:case ji:return this.onEnd(s),this.ended=!0,!1}if(o=i.avail_out,i.next_out&&(0===i.avail_out||s===Fi))if("string"===this.options.to){let e=Lt.utf8border(i.output,i.next_out),t=i.next_out-e,n=Lt.buf2string(i.output,e);i.next_out=t,i.avail_out=r-t,t&&i.output.set(i.output.subarray(e,e+t),0),this.onData(n)}else this.onData(i.output.length===i.next_out?i.output:i.output.subarray(0,i.next_out));if(s!==Ri||0!==o){if(s===Fi)return s=Oi.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===i.avail_in)break}}return!0},Zi.prototype.onData=function(e){this.chunks.push(e)},Zi.prototype.onEnd=function(e){e===Ri&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Pt.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Yi={Inflate:Zi,inflate:Hi,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Hi(e,t)},ungzip:Hi,constants:Me};const{Inflate:Wi,inflate:Xi,inflateRaw:$i,ungzip:qi}=Yi;var Ji=Xi,Qi={exports:{}};!function(e){function t(e){var t,i,r,n,s,a=Math.floor,o=new Array(64),l=new Array(64),h=new Array(64),f=new Array(64),c=new Array(65535),u=new Array(65535),d=new Array(64),g=new Array(64),m=[],p=0,w=7,y=new Array(64),_=new Array(64),b=new Array(64),v=new Array(256),k=new Array(2048),x=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],T=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],A=[0,1,2,3,4,5,6,7,8,9,10,11],S=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],I=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],U=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],C=[0,1,2,3,4,5,6,7,8,9,10,11],D=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],E=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];function P(e,t){for(var i=0,r=0,n=new Array,s=1;s<=16;s++){for(var a=1;a<=e[s];a++)n[t[r]]=[],n[t[r]][0]=i,n[t[r]][1]=s,r++,i++;i*=2}return n}function M(e){for(var t=e[0],i=e[1]-1;i>=0;)t&1<<i&&(p|=1<<w),i--,--w<0&&(255==p?(O(255),O(0)):O(p),w=7,p=0)}function O(e){m.push(e)}function L(e){O(e>>8&255),O(255&e)}function z(e,t,i,r,n){for(var s,a=n[0],o=n[240],l=function(e,t){var i,r,n,s,a,o,l,h,f,c,u=0;for(f=0;f<8;++f){i=e[u],r=e[u+1],n=e[u+2],s=e[u+3],a=e[u+4],o=e[u+5],l=e[u+6];var g=i+(h=e[u+7]),m=i-h,p=r+l,w=r-l,y=n+o,_=n-o,b=s+a,v=s-a,k=g+b,x=g-b,T=p+y,A=p-y;e[u]=k+T,e[u+4]=k-T;var S=.707106781*(A+x);e[u+2]=x+S,e[u+6]=x-S;var I=.382683433*((k=v+_)-(A=w+m)),U=.5411961*k+I,C=1.306562965*A+I,D=.707106781*(T=_+w),E=m+D,P=m-D;e[u+5]=P+U,e[u+3]=P-U,e[u+1]=E+C,e[u+7]=E-C,u+=8}for(u=0,f=0;f<8;++f){i=e[u],r=e[u+8],n=e[u+16],s=e[u+24],a=e[u+32],o=e[u+40],l=e[u+48];var M=i+(h=e[u+56]),O=i-h,L=r+l,z=r-l,G=n+o,B=n-o,R=s+a,F=s-a,V=M+R,N=M-R,K=L+G,j=L-G;e[u]=V+K,e[u+32]=V-K;var Z=.707106781*(j+N);e[u+16]=N+Z,e[u+48]=N-Z;var H=.382683433*((V=F+B)-(j=z+O)),Y=.5411961*V+H,W=1.306562965*j+H,X=.707106781*(K=B+z),$=O+X,q=O-X;e[u+40]=q+Y,e[u+24]=q-Y,e[u+8]=$+W,e[u+56]=$-W,u++}for(f=0;f<64;++f)c=e[f]*t[f],d[f]=c>0?c+.5|0:c-.5|0;return d}(e,t),h=0;h<64;++h)g[x[h]]=l[h];var f=g[0]-i;i=g[0],0==f?M(r[0]):(M(r[u[s=32767+f]]),M(c[s]));for(var m=63;m>0&&0==g[m];m--);if(0==m)return M(a),i;for(var p,w=1;w<=m;){for(var y=w;0==g[w]&&w<=m;++w);var _=w-y;if(_>=16){p=_>>4;for(var b=1;b<=p;++b)M(o);_&=15}s=32767+g[w],M(n[(_<<4)+u[s]]),M(c[s]),w++}return 63!=m&&M(a),i}function G(e){if(e<=0&&(e=1),e>100&&(e=100),s!=e){(function(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],i=0;i<64;i++){var r=a((t[i]*e+50)/100);r<1?r=1:r>255&&(r=255),o[x[i]]=r}for(var n=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],s=0;s<64;s++){var c=a((n[s]*e+50)/100);c<1?c=1:c>255&&(c=255),l[x[s]]=c}for(var u=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],d=0,g=0;g<8;g++)for(var m=0;m<8;m++)h[d]=1/(o[x[d]]*u[g]*u[m]*8),f[d]=1/(l[x[d]]*u[g]*u[m]*8),d++})(e<50?Math.floor(5e3/e):Math.floor(200-2*e)),s=e}}this.encode=function(e,s){var a;(new Date).getTime(),s&&G(s),m=new Array,p=0,w=7,L(65496),L(65504),L(16),O(74),O(70),O(73),O(70),O(0),O(1),O(1),O(0),L(1),L(1),O(0),O(0),void 0!==(a=e.comments)&&a.constructor===Array&&a.forEach((e=>{if("string"==typeof e){L(65534);var t,i=e.length;for(L(i+2),t=0;t<i;t++)O(e.charCodeAt(t))}})),function(e){if(e){L(65505),69===e[0]&&120===e[1]&&105===e[2]&&102===e[3]?L(e.length+2):(L(e.length+5+2),O(69),O(120),O(105),O(102),O(0));for(var t=0;t<e.length;t++)O(e[t])}}(e.exifBuffer),function(){L(65499),L(132),O(0);for(var e=0;e<64;e++)O(o[e]);O(1);for(var t=0;t<64;t++)O(l[t])}(),function(e,t){L(65472),L(17),O(8),L(t),L(e),O(3),O(1),O(17),O(0),O(2),O(17),O(1),O(3),O(17),O(1)}(e.width,e.height),function(){L(65476),L(418),O(0);for(var e=0;e<16;e++)O(T[e+1]);for(var t=0;t<=11;t++)O(A[t]);O(16);for(var i=0;i<16;i++)O(S[i+1]);for(var r=0;r<=161;r++)O(I[r]);O(1);for(var n=0;n<16;n++)O(U[n+1]);for(var s=0;s<=11;s++)O(C[s]);O(17);for(var a=0;a<16;a++)O(D[a+1]);for(var o=0;o<=161;o++)O(E[o])}(),L(65498),L(12),O(3),O(1),O(0),O(2),O(17),O(3),O(17),O(0),O(63),O(0);var c=0,u=0,d=0;p=0,w=7,this.encode.displayName="_encode_";for(var g,v,x,P,B,R,F,V,N,K=e.data,j=e.width,Z=e.height,H=4*j,Y=0;Y<Z;){for(g=0;g<H;){for(R=B=H*Y+g,F=-1,V=0,N=0;N<64;N++)R=B+(V=N>>3)*H+(F=4*(7&N)),Y+V>=Z&&(R-=H*(Y+1+V-Z)),g+F>=H&&(R-=g+F-H+4),v=K[R++],x=K[R++],P=K[R++],y[N]=(k[v]+k[x+256>>0]+k[P+512>>0]>>16)-128,_[N]=(k[v+768>>0]+k[x+1024>>0]+k[P+1280>>0]>>16)-128,b[N]=(k[v+1280>>0]+k[x+1536>>0]+k[P+1792>>0]>>16)-128;c=z(y,h,c,t,r),u=z(_,f,u,i,n),d=z(b,f,d,i,n),g+=32}Y+=8}if(w>=0){var W=[];W[1]=w+1,W[0]=(1<<w+1)-1,M(W)}return L(65497),Buffer.from(m)},(new Date).getTime(),e||(e=50),function(){for(var e=String.fromCharCode,t=0;t<256;t++)v[t]=e(t)}(),t=P(T,A),i=P(U,C),r=P(S,I),n=P(D,E),function(){for(var e=1,t=2,i=1;i<=15;i++){for(var r=e;r<t;r++)u[32767+r]=i,c[32767+r]=[],c[32767+r][1]=i,c[32767+r][0]=r;for(var n=-(t-1);n<=-e;n++)u[32767+n]=i,c[32767+n]=[],c[32767+n][1]=i,c[32767+n][0]=t-1+n;e<<=1,t<<=1}}(),function(){for(var e=0;e<256;e++)k[e]=19595*e,k[e+256>>0]=38470*e,k[e+512>>0]=7471*e+32768,k[e+768>>0]=-11059*e,k[e+1024>>0]=-21709*e,k[e+1280>>0]=32768*e+8421375,k[e+1536>>0]=-27439*e,k[e+1792>>0]=-5329*e}(),G(e),(new Date).getTime()}Qi.exports=function(e,i){void 0===i&&(i=50);var r=new t(i),n=r.encode(e,i);return{data:n,width:e.width,height:e.height}}}();var er,tr,ir=Qi.exports,rr={exports:{}};er=rr,tr=function(){var e=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),t=4017,i=799,r=3406,n=2276,s=1567,a=3784,o=5793,l=2896;function h(){}function f(e,t){for(var i,r,n=0,s=[],a=16;a>0&&!e[a-1];)a--;s.push({children:[],index:0});var o,l=s[0];for(i=0;i<a;i++){for(r=0;r<e[i];r++){for((l=s.pop()).children[l.index]=t[n];l.index>0;){if(0===s.length)throw new Error("Could not recreate Huffman Table");l=s.pop()}for(l.index++,s.push(l);s.length<=i;)s.push(o={children:[],index:0}),l.children[l.index]=o.children,l=o;n++}i+1<a&&(s.push(o={children:[],index:0}),l.children[l.index]=o.children,l=o)}return s[0].children}function c(t,i,r,n,s,a,o,l,h,f){r.precision,r.samplesPerLine,r.scanLines;var c=r.mcusPerLine,u=r.progressive;r.maxH,r.maxV;var d=i,g=0,m=0;function p(){if(m>0)return m--,g>>m&1;if(255==(g=t[i++])){var e=t[i++];if(e)throw new Error("unexpected marker: "+(g<<8|e).toString(16))}return m=7,g>>>7}function w(e){for(var t,i=e;null!==(t=p());){if("number"==typeof(i=i[t]))return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function y(e){for(var t=0;e>0;){var i=p();if(null===i)return;t=t<<1|i,e--}return t}function _(e){var t=y(e);return t>=1<<e-1?t:t+(-1<<e)+1}var b,v=0,k=0;function x(e,t,i,r,n){var s=i%c,a=(i/c|0)*e.v+r,o=s*e.h+n;void 0===e.blocks[a]&&f.tolerantDecoding||t(e,e.blocks[a][o])}function T(e,t,i){var r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;void 0===e.blocks[r]&&f.tolerantDecoding||t(e,e.blocks[r][n])}var A,S,I,U,C,D,E=n.length;D=u?0===a?0===l?function(e,t){var i=w(e.huffmanTableDC),r=0===i?0:_(i)<<h;t[0]=e.pred+=r}:function(e,t){t[0]|=p()<<h}:0===l?function(t,i){if(v>0)v--;else for(var r=a,n=o;r<=n;){var s=w(t.huffmanTableAC),l=15&s,f=s>>4;if(0!==l)i[e[r+=f]]=_(l)*(1<<h),r++;else{if(f<15){v=y(f)+(1<<f)-1;break}r+=16}}}:function(t,i){for(var r=a,n=o,s=0;r<=n;){var l=e[r],f=i[l]<0?-1:1;switch(k){case 0:var c=w(t.huffmanTableAC),u=15&c;if(s=c>>4,0===u)s<15?(v=y(s)+(1<<s),k=4):(s=16,k=1);else{if(1!==u)throw new Error("invalid ACn encoding");b=_(u),k=s?2:3}continue;case 1:case 2:i[l]?i[l]+=(p()<<h)*f:0==--s&&(k=2==k?3:0);break;case 3:i[l]?i[l]+=(p()<<h)*f:(i[l]=b<<h,k=0);break;case 4:i[l]&&(i[l]+=(p()<<h)*f)}r++}4===k&&0==--v&&(k=0)}:function(t,i){var r=w(t.huffmanTableDC),n=0===r?0:_(r);i[0]=t.pred+=n;for(var s=1;s<64;){var a=w(t.huffmanTableAC),o=15&a,l=a>>4;if(0!==o)i[e[s+=l]]=_(o),s++;else{if(l<15)break;s+=16}}};var P,M,O,L,z=0;for(M=1==E?n[0].blocksPerLine*n[0].blocksPerColumn:c*r.mcusPerColumn,s||(s=M);z<M;){for(S=0;S<E;S++)n[S].pred=0;if(v=0,1==E)for(A=n[0],C=0;C<s;C++)T(A,D,z),z++;else for(C=0;C<s;C++){for(S=0;S<E;S++)for(O=(A=n[S]).h,L=A.v,I=0;I<L;I++)for(U=0;U<O;U++)x(A,D,z,I,U);if(++z===M)break}if(z===M)do{if(255===t[i]&&0!==t[i+1])break;i+=1}while(i<t.length-2);if(m=0,(P=t[i]<<8|t[i+1])<65280)throw new Error("marker was not found");if(!(P>=65488&&P<=65495))break;i+=2}return i-d}function u(e,h){var f,c,u=[],d=h.blocksPerLine,g=h.blocksPerColumn,m=d<<3,w=new Int32Array(64),y=new Uint8Array(64);function _(e,f,c){var u,d,g,m,p,w,y,_,b,v,k=h.quantizationTable,x=c;for(v=0;v<64;v++)x[v]=e[v]*k[v];for(v=0;v<8;++v){var T=8*v;0!=x[1+T]||0!=x[2+T]||0!=x[3+T]||0!=x[4+T]||0!=x[5+T]||0!=x[6+T]||0!=x[7+T]?(u=o*x[0+T]+128>>8,d=o*x[4+T]+128>>8,g=x[2+T],m=x[6+T],p=l*(x[1+T]-x[7+T])+128>>8,_=l*(x[1+T]+x[7+T])+128>>8,w=x[3+T]<<4,y=x[5+T]<<4,b=u-d+1>>1,u=u+d+1>>1,d=b,b=g*a+m*s+128>>8,g=g*s-m*a+128>>8,m=b,b=p-y+1>>1,p=p+y+1>>1,y=b,b=_+w+1>>1,w=_-w+1>>1,_=b,b=u-m+1>>1,u=u+m+1>>1,m=b,b=d-g+1>>1,d=d+g+1>>1,g=b,b=p*n+_*r+2048>>12,p=p*r-_*n+2048>>12,_=b,b=w*i+y*t+2048>>12,w=w*t-y*i+2048>>12,y=b,x[0+T]=u+_,x[7+T]=u-_,x[1+T]=d+y,x[6+T]=d-y,x[2+T]=g+w,x[5+T]=g-w,x[3+T]=m+p,x[4+T]=m-p):(b=o*x[0+T]+512>>10,x[0+T]=b,x[1+T]=b,x[2+T]=b,x[3+T]=b,x[4+T]=b,x[5+T]=b,x[6+T]=b,x[7+T]=b)}for(v=0;v<8;++v){var A=v;0!=x[8+A]||0!=x[16+A]||0!=x[24+A]||0!=x[32+A]||0!=x[40+A]||0!=x[48+A]||0!=x[56+A]?(u=o*x[0+A]+2048>>12,d=o*x[32+A]+2048>>12,g=x[16+A],m=x[48+A],p=l*(x[8+A]-x[56+A])+2048>>12,_=l*(x[8+A]+x[56+A])+2048>>12,w=x[24+A],y=x[40+A],b=u-d+1>>1,u=u+d+1>>1,d=b,b=g*a+m*s+2048>>12,g=g*s-m*a+2048>>12,m=b,b=p-y+1>>1,p=p+y+1>>1,y=b,b=_+w+1>>1,w=_-w+1>>1,_=b,b=u-m+1>>1,u=u+m+1>>1,m=b,b=d-g+1>>1,d=d+g+1>>1,g=b,b=p*n+_*r+2048>>12,p=p*r-_*n+2048>>12,_=b,b=w*i+y*t+2048>>12,w=w*t-y*i+2048>>12,y=b,x[0+A]=u+_,x[56+A]=u-_,x[8+A]=d+y,x[48+A]=d-y,x[16+A]=g+w,x[40+A]=g-w,x[24+A]=m+p,x[32+A]=m-p):(b=o*c[v+0]+8192>>14,x[0+A]=b,x[8+A]=b,x[16+A]=b,x[24+A]=b,x[32+A]=b,x[40+A]=b,x[48+A]=b,x[56+A]=b)}for(v=0;v<64;++v){var S=128+(x[v]+8>>4);f[v]=S<0?0:S>255?255:S}}p(m*g*8);for(var b=0;b<g;b++){var v=b<<3;for(f=0;f<8;f++)u.push(new Uint8Array(m));for(var k=0;k<d;k++){_(h.blocks[b][k],y,w);var x=0,T=k<<3;for(c=0;c<8;c++){var A=u[v+c];for(f=0;f<8;f++)A[T+f]=y[x++]}}}return u}function d(e){return e<0?0:e>255?255:e}h.prototype={load:function(e){var t=new XMLHttpRequest;t.open("GET",e,!0),t.responseType="arraybuffer",t.onload=function(){var e=new Uint8Array(t.response||t.mozResponseArrayBuffer);this.parse(e),this.onload&&this.onload()}.bind(this),t.send(null)},parse:function(t){var i=1e3*this.opts.maxResolutionInMP*1e3,r=0;function n(){var e=t[r]<<8|t[r+1];return r+=2,e}function s(e){var t,i,r=1,n=1;for(i in e.components)e.components.hasOwnProperty(i)&&(r<(t=e.components[i]).h&&(r=t.h),n<t.v&&(n=t.v));var s=Math.ceil(e.samplesPerLine/8/r),a=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];var o=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),h=s*t.h,f=a*t.v,c=[];p(f*h*256);for(var u=0;u<f;u++){for(var d=[],g=0;g<h;g++)d.push(new Int32Array(64));c.push(d)}t.blocksPerLine=o,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=s,e.mcusPerColumn=a}t.length;var a,o,l,h,d=null,g=null,m=[],w=[],y=[],_=[],b=n(),v=-1;if(this.comments=[],65496!=b)throw new Error("SOI not found");for(b=n();65497!=b;){switch(b){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:var k=(l=void 0,h=void 0,l=n(),h=t.subarray(r,r+l-2),r+=h.length,h);if(65534===b){var x=String.fromCharCode.apply(null,k);this.comments.push(x)}65504===b&&74===k[0]&&70===k[1]&&73===k[2]&&70===k[3]&&0===k[4]&&(d={version:{major:k[5],minor:k[6]},densityUnits:k[7],xDensity:k[8]<<8|k[9],yDensity:k[10]<<8|k[11],thumbWidth:k[12],thumbHeight:k[13],thumbData:k.subarray(14,14+3*k[12]*k[13])}),65505===b&&69===k[0]&&120===k[1]&&105===k[2]&&102===k[3]&&0===k[4]&&(this.exifBuffer=k.subarray(5,k.length)),65518===b&&65===k[0]&&100===k[1]&&111===k[2]&&98===k[3]&&101===k[4]&&0===k[5]&&(g={version:k[6],flags0:k[7]<<8|k[8],flags1:k[9]<<8|k[10],transformCode:k[11]});break;case 65499:for(var T=n()+r-2;r<T;){var A=t[r++];p(256);var S=new Int32Array(64);if(A>>4==0)for(W=0;W<64;W++)S[e[W]]=t[r++];else{if(A>>4!=1)throw new Error("DQT: invalid table spec");for(W=0;W<64;W++)S[e[W]]=n()}m[15&A]=S}break;case 65472:case 65473:case 65474:n(),(a={}).extended=65473===b,a.progressive=65474===b,a.precision=t[r++],a.scanLines=n(),a.samplesPerLine=n(),a.components={},a.componentsOrder=[];var I=a.scanLines*a.samplesPerLine;if(I>i){var U=Math.ceil((I-i)/1e6);throw new Error(`maxResolutionInMP limit exceeded by ${U}MP`)}var C,D=t[r++];for(H=0;H<D;H++){C=t[r];var E=t[r+1]>>4,P=15&t[r+1],M=t[r+2];if(E<=0||P<=0)throw new Error("Invalid sampling factor, expected values above 0");a.componentsOrder.push(C),a.components[C]={h:E,v:P,quantizationIdx:M},r+=3}s(a),w.push(a);break;case 65476:var O=n();for(H=2;H<O;){var L=t[r++],z=new Uint8Array(16),G=0;for(W=0;W<16;W++,r++)G+=z[W]=t[r];p(16+G);var B=new Uint8Array(G);for(W=0;W<G;W++,r++)B[W]=t[r];H+=17+G,(L>>4==0?_:y)[15&L]=f(z,B)}break;case 65501:n(),o=n();break;case 65500:n(),n();break;case 65498:n();var R=t[r++],F=[];for(H=0;H<R;H++){X=a.components[t[r++]];var V=t[r++];X.huffmanTableDC=_[V>>4],X.huffmanTableAC=y[15&V],F.push(X)}var N=t[r++],K=t[r++],j=t[r++],Z=c(t,r,a,F,o,N,K,j>>4,15&j,this.opts);r+=Z;break;case 65535:255!==t[r]&&r--;break;default:if(255==t[r-3]&&t[r-2]>=192&&t[r-2]<=254){r-=3;break}if(224===b||225==b){if(-1!==v)throw new Error(`first unknown JPEG marker at offset ${v.toString(16)}, second unknown JPEG marker ${b.toString(16)} at offset ${(r-1).toString(16)}`);v=r-1;const e=n();if(255===t[r+e-2]){r+=e-2;break}}throw new Error("unknown JPEG marker "+b.toString(16))}b=n()}if(1!=w.length)throw new Error("only single frame JPEGs supported");for(var H=0;H<w.length;H++){var Y=w[H].components;for(var W in Y)Y[W].quantizationTable=m[Y[W].quantizationIdx],delete Y[W].quantizationIdx}for(this.width=a.samplesPerLine,this.height=a.scanLines,this.jfif=d,this.adobe=g,this.components=[],H=0;H<a.componentsOrder.length;H++){var X=a.components[a.componentsOrder[H]];this.components.push({lines:u(0,X),scaleX:X.h/a.maxH,scaleY:X.v/a.maxV})}},getData:function(e,t){var i,r,n,s,a,o,l,h,f,c,u,g,m,w,y,_,b,v,k,x,T,A=this.width/e,S=this.height/t,I=0,U=e*t*this.components.length;p(U);var C=new Uint8Array(U);switch(this.components.length){case 1:for(i=this.components[0],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],f=0;f<e;f++)u=a[0|f*i.scaleX*A],C[I++]=u;break;case 2:for(i=this.components[0],r=this.components[1],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],f=0;f<e;f++)u=a[0|f*i.scaleX*A],C[I++]=u,u=o[0|f*r.scaleX*A],C[I++]=u;break;case 3:for(T=!0,this.adobe&&this.adobe.transformCode?T=!0:void 0!==this.opts.colorTransform&&(T=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],l=n.lines[0|c*n.scaleY*S],f=0;f<e;f++)T?(u=a[0|f*i.scaleX*A],g=o[0|f*r.scaleX*A],v=d(u+1.402*((m=l[0|f*n.scaleX*A])-128)),k=d(u-.3441363*(g-128)-.71413636*(m-128)),x=d(u+1.772*(g-128))):(v=a[0|f*i.scaleX*A],k=o[0|f*r.scaleX*A],x=l[0|f*n.scaleX*A]),C[I++]=v,C[I++]=k,C[I++]=x;break;case 4:if(!this.adobe)throw new Error("Unsupported color mode (4 components)");for(T=!1,this.adobe&&this.adobe.transformCode?T=!0:void 0!==this.opts.colorTransform&&(T=!!this.opts.colorTransform),i=this.components[0],r=this.components[1],n=this.components[2],s=this.components[3],c=0;c<t;c++)for(a=i.lines[0|c*i.scaleY*S],o=r.lines[0|c*r.scaleY*S],l=n.lines[0|c*n.scaleY*S],h=s.lines[0|c*s.scaleY*S],f=0;f<e;f++)T?(u=a[0|f*i.scaleX*A],g=o[0|f*r.scaleX*A],m=l[0|f*n.scaleX*A],w=h[0|f*s.scaleX*A],y=255-d(u+1.402*(m-128)),_=255-d(u-.3441363*(g-128)-.71413636*(m-128)),b=255-d(u+1.772*(g-128))):(y=a[0|f*i.scaleX*A],_=o[0|f*r.scaleX*A],b=l[0|f*n.scaleX*A],w=h[0|f*s.scaleX*A]),C[I++]=255-y,C[I++]=255-_,C[I++]=255-b,C[I++]=255-w;break;default:throw new Error("Unsupported color mode")}return C},copyToImageData:function(e,t){var i,r,n,s,a,o,l,h,f,c=e.width,u=e.height,g=e.data,m=this.getData(c,u),p=0,w=0;switch(this.components.length){case 1:for(r=0;r<u;r++)for(i=0;i<c;i++)n=m[p++],g[w++]=n,g[w++]=n,g[w++]=n,t&&(g[w++]=255);break;case 3:for(r=0;r<u;r++)for(i=0;i<c;i++)l=m[p++],h=m[p++],f=m[p++],g[w++]=l,g[w++]=h,g[w++]=f,t&&(g[w++]=255);break;case 4:for(r=0;r<u;r++)for(i=0;i<c;i++)a=m[p++],o=m[p++],n=m[p++],l=255-d(a*(1-(s=m[p++])/255)+s),h=255-d(o*(1-s/255)+s),f=255-d(n*(1-s/255)+s),g[w++]=l,g[w++]=h,g[w++]=f,t&&(g[w++]=255);break;default:throw new Error("Unsupported color mode")}}};var g=0,m=0;function p(e=0){var t=g+e;if(t>m){var i=Math.ceil((t-m)/1024/1024);throw new Error(`maxMemoryUsageInMB limit exceeded by at least ${i}MB`)}g=t}return h.resetMaxMemoryUsage=function(e){g=0,m=e},h.getBytesAllocated=function(){return g},h.requestMemoryAllocation=p,h}(),er.exports=function(e,t={}){var i={colorTransform:void 0,useTArray:!1,formatAsRGBA:!0,tolerantDecoding:!0,maxResolutionInMP:100,maxMemoryUsageInMB:512,...t},r=new Uint8Array(e),n=new tr;n.opts=i,tr.resetMaxMemoryUsage(1024*i.maxMemoryUsageInMB*1024),n.parse(r);var s=i.formatAsRGBA?4:3,a=n.width*n.height*s;try{tr.requestMemoryAllocation(a);var o={width:n.width,height:n.height,exifBuffer:n.exifBuffer,data:i.useTArray?new Uint8Array(a):Buffer.alloc(a)};n.comments.length>0&&(o.comments=n.comments)}catch(e){if(e instanceof RangeError)throw new Error("Could not allocate enough memory for the image. Required: "+a);if(e instanceof ReferenceError&&"Buffer is not defined"===e.message)throw new Error("Buffer is not globally defined in this environment. Consider setting useTArray to true");throw e}return n.copyToImageData(o,i.formatAsRGBA),o};var nr,sr=u({encode:ir,decode:rr.exports}),ar="undefined"!=typeof Float32Array?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)}),nr=new ar(4),ar!=Float32Array&&(nr[0]=0,nr[1]=0,nr[2]=0,nr[3]=0),function(){var e=function(){var e=new ar(2);return ar!=Float32Array&&(e[0]=0,e[1]=0),e}()}(),function(){var e=function(){var e=new ar(3);return ar!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}()}();const or=Math.PI,lr=or/4,hr=180/or;function fr(e,t){let i=e.length-t,r=0;do{for(let i=t;i>0;i--)e[r+t]+=e[r],r++;i-=t}while(i>0)}function cr(e,t,i){let r=0,n=e.length;const s=n/i;for(;n>t;){for(let i=t;i>0;--i)e[r+t]+=e[r],++r;n-=t}const a=e.slice();for(let t=0;t<s;++t)for(let r=0;r<i;++r)e[i*t+r]=a[(i-r-1)*s+t]}let ur=class{async decode(e,t){const i=await this.decodeBlock(t),r=e.Predictor||1;if(1!==r){const t=!e.StripOffsets;return function(e,t,i,r,n,s){if(!t||1===t)return e;for(let e=0;e<n.length;++e){if(n[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[e]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=n[0]/8,o=2===s?1:n.length;for(let s=0;s<r&&!(s*o*i*a>=e.byteLength);++s){let r;if(2===t){switch(n[0]){case 8:r=new Uint8Array(e,s*o*i*a,o*i*a);break;case 16:r=new Uint16Array(e,s*o*i*a,o*i*a/2);break;case 32:r=new Uint32Array(e,s*o*i*a,o*i*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}fr(r,o)}else 3===t&&(r=new Uint8Array(e,s*o*i*a,o*i*a),cr(r,o,a))}return e}(i,r,t?e.TileWidth:e.ImageWidth,t?e.TileLength:e.RowsPerStrip||e.ImageLength,e.BitsPerSample,e.PlanarConfiguration)}return i}};const dr=257;function gr(e,t){for(let i=t.length-1;i>=0;i--)e.push(t[i]);return e}function mr(e){const t=new Uint16Array(4093),i=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,i[e]=e;let r=258,n=9,s=0;function a(){r=258,n=9}function o(e){const t=function(e,t,i){const r=t%8,n=Math.floor(t/8),s=8-r,a=t+i-8*(n+1);let o=8*(n+2)-(t+i);const l=8*(n+2)-t;if(o=Math.max(0,o),n>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),dr;let h=e[n]&2**(8-r)-1;h<<=i-s;let f=h;if(n+1<e.length){let t=e[n+1]>>>o;t<<=Math.max(0,i-l),f+=t}if(a>8&&n+2<e.length){const r=8*(n+3)-(t+i);f+=e[n+2]>>>r}return f}(e,s,n);return s+=n,t}function l(e,n){return i[r]=n,t[r]=e,r++,r-1}function h(e){const r=[];for(let n=e;4096!==n;n=t[n])r.push(i[n]);return r}const f=[];a();const c=new Uint8Array(e);let u,d=o(c);for(;d!==dr;){if(256===d){for(a(),d=o(c);256===d;)d=o(c);if(d===dr)break;if(d>256)throw new Error(`corrupted code at scanline ${d}`);gr(f,h(d)),u=d}else if(d<r){const e=h(d);gr(f,e),l(u,e[e.length-1]),u=d}else{const e=h(u);if(!e)throw new Error(`Bogus entry. Not in dictionary,\n ${u} / ${r},\n position: ${s}`);gr(f,e),f.push(e[e.length-1]),l(u,e[e.length-1]),u=d}r+1>=2**n&&(12===n?u=void 0:n++),d=o(c)}return new Uint8Array(f)}let pr=class extends ur{decodeBlock(e){return mr(e).buffer}};function wr(e){return(t,...i)=>_r(e,t,i)}function yr(e,t){return wr(xr(e,t).get)}const{apply:_r,construct:br,defineProperty:vr,get:kr,getOwnPropertyDescriptor:xr,getPrototypeOf:Tr,has:Ar,ownKeys:Sr,set:Ir,setPrototypeOf:Ur}=Reflect,{iterator:Cr,species:Dr,toStringTag:Er,for:Pr}=Symbol,Mr=Object,{create:Or,defineProperty:Lr,freeze:zr,is:Gr}=Mr,Br=Array.prototype[Cr],Rr=wr(Br),Fr=ArrayBuffer;yr(Fr.prototype,"byteLength");const Vr="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:null;Vr&&yr(Vr.prototype,"byteLength");const Nr=Tr(Uint8Array);Nr.from;const Kr=Nr.prototype;Kr[Cr],wr(Kr.keys),wr(Kr.values),wr(Kr.entries),wr(Kr.set),wr(Kr.reverse),wr(Kr.fill),wr(Kr.copyWithin),wr(Kr.sort),wr(Kr.slice),wr(Kr.subarray),yr(Kr,"buffer"),yr(Kr,"byteOffset"),yr(Kr,"length"),yr(Kr,Er);const jr=Uint32Array,Zr=Float32Array,Hr=Tr([][Cr]()),Yr=wr(Hr.next),Wr=wr(function*(){}().next),Xr=Tr(Hr),$r=wr(DataView.prototype.getUint16),qr=WeakMap,Jr=qr.prototype,Qr=wr(Jr.get),en=wr(Jr.set),tn=new qr,rn=Or(null,{next:{value:function(){const e=Qr(tn,this);return Yr(e)}},[Cr]:{value:function(){return this}}});const nn=new qr,sn=Or(Xr,{next:{value:function(){const e=Qr(nn,this);return Wr(e)},writable:!0,configurable:!0}});for(const e of Sr(Hr))"next"!==e&&Lr(sn,e,xr(Hr,e));const an=new Fr(4),on=new Zr(an),ln=new jr(an),hn=new jr(512),fn=new jr(512);for(let e=0;e<256;++e){const t=e-127;t<-27?(hn[e]=0,hn[256|e]=32768,fn[e]=24,fn[256|e]=24):t<-14?(hn[e]=1024>>-t-14,hn[256|e]=1024>>-t-14|32768,fn[e]=-t-1,fn[256|e]=-t-1):t<=15?(hn[e]=t+15<<10,hn[256|e]=t+15<<10|32768,fn[e]=13,fn[256|e]=13):t<128?(hn[e]=31744,hn[256|e]=64512,fn[e]=24,fn[256|e]=24):(hn[e]=31744,hn[256|e]=64512,fn[e]=13,fn[256|e]=13)}const cn=new jr(2048),un=new jr(64),dn=new jr(64);for(let e=1;e<1024;++e){let t=e<<13,i=0;for(;0==(8388608&t);)t<<=1,i-=8388608;t&=-8388609,i+=947912704,cn[e]=t|i}for(let e=1024;e<2048;++e)cn[e]=939524096+(e-1024<<13);for(let e=1;e<31;++e)un[e]=e<<23;un[31]=1199570944,un[32]=2147483648;for(let e=33;e<63;++e)un[e]=2147483648+(e-32<<23);un[63]=3347054592;for(let e=1;e<64;++e)32!==e&&(dn[e]=1024);function gn(e,t,...i){return function(e){const t=e>>10;return ln[0]=cn[dn[t]+(1023&e)]+un[t],on[0]}($r(e,t,...function(e){if(e[Cr]===Br&&Hr.next===Yr)return e;const t=Or(rn);return en(tn,t,Rr(e)),t}(i)))}var mn={exports:{}};function pn(e,t,i){const r=i&&i.debug||!1;r&&console.log("[xml-utils] getting "+t+" in "+e);const n="object"==typeof e?e.outer:e,s=n.slice(0,n.indexOf(">")+1),a=['"',"'"];for(let e=0;e<a.length;e++){const i=a[e],n=t+"\\="+i+"([^"+i+"]*)"+i;r&&console.log("[xml-utils] pattern:",n);const o=new RegExp(n).exec(s);if(r&&console.log("[xml-utils] match:",o),o)return o[1]}}mn.exports=pn,mn.exports.default=pn;var wn=u(mn.exports),yn={exports:{}},_n={exports:{}},bn={exports:{}};function vn(e,t,i){const r=new RegExp(t).exec(e.slice(i));return r?i+r.index:-1}bn.exports=vn,bn.exports.default=vn;var kn=bn.exports,xn={exports:{}};function Tn(e,t,i){const r=new RegExp(t).exec(e.slice(i));return r?i+r.index+r[0].length-1:-1}xn.exports=Tn,xn.exports.default=Tn;var An=xn.exports,Sn={exports:{}};function In(e,t){const i=new RegExp(t,"g"),r=e.match(i);return r?r.length:0}Sn.exports=In,Sn.exports.default=In;var Un=Sn.exports;const Cn=kn,Dn=An,En=Un;function Pn(e,t,i){const r=i&&i.debug||!1,n=!(i&&!1===typeof i.nested),s=i&&i.startIndex||0;r&&console.log("[xml-utils] starting findTagByName with",t," and ",i);const a=Cn(e,`<${t}[ \n>/]`,s);if(r&&console.log("[xml-utils] start:",a),-1===a)return;const o=e.slice(a+t.length);let l=Dn(o,"^[^<]*[ /]>",0);const h=-1!==l&&"/"===o[l-1];if(r&&console.log("[xml-utils] selfClosing:",h),!1===h)if(n){let e=0,i=1,r=0;for(;-1!==(l=Dn(o,"[ /]"+t+">",e));){const n=o.substring(e,l+1);if(i+=En(n,"<"+t+"[ \n\t>]"),r+=En(n,"</"+t+">"),r>=i)break;e=l}}else l=Dn(o,"[ /]"+t+">",0);const f=a+t.length+l+1;if(r&&console.log("[xml-utils] end:",f),-1===f)return;const c=e.slice(a,f);let u;return u=h?null:c.slice(c.indexOf(">")+1,c.lastIndexOf("<")),{inner:u,outer:c,start:a,end:f}}_n.exports=Pn,_n.exports.default=Pn;const Mn=_n.exports;function On(e,t,i){const r=[],n=i&&i.debug||!1,s=!i||"boolean"!=typeof i.nested||i.nested;let a,o=i&&i.startIndex||0;for(;a=Mn(e,t,{debug:n,startIndex:o});)o=s?a.start+1+t.length:a.end,r.push(a);return n&&console.log("findTagsByName found",r.length,"tags"),r}yn.exports=On,yn.exports.default=On;var Ln=u(yn.exports);const zn={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"},Gn={};for(const e in zn)zn.hasOwnProperty(e)&&(Gn[zn[e]]=parseInt(e,10));const Bn=[Gn.BitsPerSample,Gn.ExtraSamples,Gn.SampleFormat,Gn.StripByteCounts,Gn.StripOffsets,Gn.StripRowCounts,Gn.TileByteCounts,Gn.TileOffsets,Gn.SubIFDs],Rn={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"},Fn={};for(const e in Rn)Rn.hasOwnProperty(e)&&(Fn[Rn[e]]=parseInt(e,10));const Vn=0,Nn=1,Kn=2,jn=3,Zn=5,Hn=6,Yn=8,Wn=0,Xn=1,$n=0,qn=1,Jn={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"};const Qn=new Map;function es(e,t){Array.isArray(e)||(e=[e]),e.forEach((e=>Qn.set(e,t)))}function ts(e,t,i,r=1){return new(Object.getPrototypeOf(e).constructor)(t*i*r)}function is(e,t,i){return(1-i)*e+i*t}function rs(e,t,i,r,n,s="nearest"){switch(s.toLowerCase()){case"nearest":return function(e,t,i,r,n){const s=t/r,a=i/n;return e.map((e=>{const o=ts(e,r,n);for(let l=0;l<n;++l){const n=Math.min(Math.round(a*l),i-1);for(let i=0;i<r;++i){const a=Math.min(Math.round(s*i),t-1),h=e[n*t+a];o[l*r+i]=h}}return o}))}(e,t,i,r,n);case"bilinear":case"linear":return function(e,t,i,r,n){const s=t/r,a=i/n;return e.map((e=>{const o=ts(e,r,n);for(let l=0;l<n;++l){const n=a*l,h=Math.floor(n),f=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const a=s*i,c=a%1,u=Math.floor(a),d=Math.min(Math.ceil(a),t-1),g=e[h*t+u],m=e[h*t+d],p=e[f*t+u],w=e[f*t+d],y=is(is(g,m,c),is(p,w,c),n%1);o[l*r+i]=y}}return o}))}(e,t,i,r,n);default:throw new Error(`Unsupported resampling method: '${s}'`)}}function ns(e,t,i,r,n,s,a="nearest"){switch(a.toLowerCase()){case"nearest":return function(e,t,i,r,n,s){const a=t/r,o=i/n,l=ts(e,r,n,s);for(let h=0;h<n;++h){const n=Math.min(Math.round(o*h),i-1);for(let i=0;i<r;++i){const o=Math.min(Math.round(a*i),t-1);for(let a=0;a<s;++a){const f=e[n*t*s+o*s+a];l[h*r*s+i*s+a]=f}}}return l}(e,t,i,r,n,s);case"bilinear":case"linear":return function(e,t,i,r,n,s){const a=t/r,o=i/n,l=ts(e,r,n,s);for(let h=0;h<n;++h){const n=o*h,f=Math.floor(n),c=Math.min(Math.ceil(n),i-1);for(let i=0;i<r;++i){const o=a*i,u=o%1,d=Math.floor(o),g=Math.min(Math.ceil(o),t-1);for(let a=0;a<s;++a){const o=e[f*t*s+d*s+a],m=e[f*t*s+g*s+a],p=e[c*t*s+d*s+a],w=e[c*t*s+g*s+a],y=is(is(o,m,u),is(p,w,u),n%1);l[h*r*s+i*s+a]=y}}}return l}(e,t,i,r,n,s);default:throw new Error(`Unsupported resampling method: '${a}'`)}}function ss(e,t,i){let r=0;for(let n=t;n<i;++n)r+=e[n];return r}function as(e,t,i){switch(e){case 1:if(t<=8)return new Uint8Array(i);if(t<=16)return new Uint16Array(i);if(t<=32)return new Uint32Array(i);break;case 2:if(8===t)return new Int8Array(i);if(16===t)return new Int16Array(i);if(32===t)return new Int32Array(i);break;case 3:switch(t){case 16:case 32:return new Float32Array(i);case 64:return new Float64Array(i)}}throw Error("Unsupported data format/bitsPerSample")}es([void 0,1],(()=>Promise.resolve().then((function(){return Es})).then((e=>e.default)))),es(5,(()=>Promise.resolve().then((function(){return Ls})).then((e=>e.default)))),es(6,(()=>{throw new Error("old style JPEG compression is not supported.")})),es(7,(()=>Promise.resolve().then((function(){return Xs})).then((e=>e.default)))),es([8,32946],(()=>Promise.resolve().then((function(){return $s})).then((e=>e.default)))),es(32773,(()=>Promise.resolve().then((function(){return qs})).then((e=>e.default)))),es(34887,(()=>Promise.resolve().then((function(){return ea})).then((e=>e.default)))),es(50001,(()=>Promise.resolve().then((function(){return ta})).then((e=>e.default))));var os=class{constructor(e,t,i,r,n,s){this.fileDirectory=e,this.geoKeys=t,this.dataView=i,this.littleEndian=r,this.tiles=n?{}:null,this.isTiled=!e.StripOffsets;const a=e.PlanarConfiguration;if(this.planarConfiguration=void 0===a?1:a,1!==this.planarConfiguration&&2!==this.planarConfiguration)throw new Error("Invalid planar configuration.");this.source=s}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return void 0!==this.fileDirectory.SamplesPerPixel?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:void 0!==this.fileDirectory.RowsPerStrip?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,i=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(i<=8)return DataView.prototype.getUint8;if(i<=16)return DataView.prototype.getUint16;if(i<=32)return DataView.prototype.getUint32;break;case 2:if(i<=8)return DataView.prototype.getInt8;if(i<=16)return DataView.prototype.getInt16;if(i<=32)return DataView.prototype.getInt32;break;case 3:switch(i){case 16:return function(e,t){return gn(this,e,t)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,t){return as(this.getSampleFormat(e),this.getBitsPerSample(e),t)}async getTileOrStrip(e,t,i,r,n){const s=Math.ceil(this.getWidth()/this.getTileWidth()),a=Math.ceil(this.getHeight()/this.getTileHeight());let o;const{tiles:l}=this;let h,f;1===this.planarConfiguration?o=t*s+e:2===this.planarConfiguration&&(o=i*s*a+t*s+e),this.isTiled?(h=this.fileDirectory.TileOffsets[o],f=this.fileDirectory.TileByteCounts[o]):(h=this.fileDirectory.StripOffsets[o],f=this.fileDirectory.StripByteCounts[o]);const c=(await this.source.fetch([{offset:h,length:f}],n))[0];let u;return null!==l&&l[o]?u=l[o]:(u=(async()=>{let e=await r.decode(this.fileDirectory,c);const i=this.getSampleFormat(),n=this.getBitsPerSample();return function(e,t){return(1!==e&&2!==e||!(t<=32)||t%8!=0)&&(3!==e||16!==t&&32!==t&&64!==t)}(i,n)&&(e=function(e,t,i,r,n,s,a){const o=new DataView(e),l=2===i?1:r,h=as(t,n,2===i?a*s:a*s*r),f=parseInt("1".repeat(n),2);if(1===t){let e;e=1===i?r*n:n;let t=s*e;0!=(7&t)&&(t=t+7&-8);for(let e=0;e<a;++e){const i=e*t;for(let t=0;t<s;++t){const r=i+t*l*n;for(let i=0;i<l;++i){const a=r+i*n,c=(e*s+t)*l+i,u=Math.floor(a/8),d=a%8;if(d+n<=8)h[c]=o.getUint8(u)>>8-n-d&f;else if(d+n<=16)h[c]=o.getUint16(u)>>16-n-d&f;else if(d+n<=24){const e=o.getUint16(u)<<8|o.getUint8(u+2);h[c]=e>>24-n-d&f}else h[c]=o.getUint32(u)>>32-n-d&f}}}}return h.buffer}(e,i,this.planarConfiguration,this.getSamplesPerPixel(),n,this.getTileWidth(),this.getBlockHeight(t))),e})(),null!==l&&(l[o]=u)),{x:e,y:t,sample:i,data:await u}}async _readRaster(e,t,i,r,n,s,a,o,l){const h=this.getTileWidth(),f=this.getTileHeight(),c=this.getWidth(),u=this.getHeight(),d=Math.max(Math.floor(e[0]/h),0),g=Math.min(Math.ceil(e[2]/h),Math.ceil(c/h)),m=Math.max(Math.floor(e[1]/f),0),p=Math.min(Math.ceil(e[3]/f),Math.ceil(u/f)),w=e[2]-e[0];let y=this.getBytesPerPixel();const _=[],b=[];for(let e=0;e<t.length;++e)1===this.planarConfiguration?_.push(ss(this.fileDirectory.BitsPerSample,0,t[e])/8):_.push(0),b.push(this.getReaderForSample(t[e]));const v=[],{littleEndian:k}=this;for(let s=m;s<p;++s)for(let a=d;a<g;++a)for(let o=0;o<t.length;++o){const d=o,g=t[o];2===this.planarConfiguration&&(y=this.getSampleByteSize(o));const m=this.getTileOrStrip(a,s,g,n,l).then((n=>{const s=n.data,a=new DataView(s),o=this.getBlockHeight(n.y),l=n.y*f,g=n.x*h,m=l+o,p=(n.x+1)*h,v=b[d],x=Math.min(o,o-(m-e[3]),u-l),T=Math.min(h,h-(p-e[2]),c-g);for(let n=Math.max(0,e[1]-l);n<x;++n)for(let s=Math.max(0,e[0]-g);s<T;++s){const o=(n*h+s)*y,f=v.call(a,o+_[d],k);let c;r?(c=(n+l-e[1])*w*t.length+(s+g-e[0])*t.length+d,i[c]=f):(c=(n+l-e[1])*w+s+g-e[0],i[d][c]=f)}}));v.push(m)}if(await Promise.all(v),s&&e[2]-e[0]!==s||a&&e[3]-e[1]!==a){let n;return n=r?ns(i,e[2]-e[0],e[3]-e[1],s,a,t.length,o):rs(i,e[2]-e[0],e[3]-e[1],s,a,o),n.width=s,n.height=a,n}return i.width=s||e[2]-e[0],i.height=a||e[3]-e[1],i}async readRasters({window:e,samples:t=[],interleave:i,pool:r=null,width:n,height:s,resampleMethod:a,fillValue:o,signal:l}={}){const h=e||[0,0,this.getWidth(),this.getHeight()];if(h[0]>h[2]||h[1]>h[3])throw new Error("Invalid subsets");const f=(h[2]-h[0])*(h[3]-h[1]),c=this.getSamplesPerPixel();if(t&&t.length){for(let e=0;e<t.length;++e)if(t[e]>=c)return Promise.reject(new RangeError(`Invalid sample index '${t[e]}'.`))}else for(let e=0;e<c;++e)t.push(e);let u;if(i){u=as(this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,Math.max.apply(null,this.fileDirectory.BitsPerSample),f*t.length),o&&u.fill(o)}else{u=[];for(let e=0;e<t.length;++e){const i=this.getArrayForSample(t[e],f);Array.isArray(o)&&e<o.length?i.fill(o[e]):o&&!Array.isArray(o)&&i.fill(o),u.push(i)}}const d=r||await async function(e){const t=Qn.get(e.Compression);if(!t)throw new Error(`Unknown compression method identifier: ${e.Compression}`);return new(await t())(e)}(this.fileDirectory);return await this._readRaster(h,t,u,i,d,n,s,a,l)}async readRGB({window:e,interleave:t=!0,pool:i=null,width:r,height:n,resampleMethod:s,enableAlpha:a=!1,signal:o}={}){const l=e||[0,0,this.getWidth(),this.getHeight()];if(l[0]>l[2]||l[1]>l[3])throw new Error("Invalid subsets");const h=this.fileDirectory.PhotometricInterpretation;if(h===Kn){let l=[0,1,2];if(this.fileDirectory.ExtraSamples!==Wn&&a){l=[];for(let e=0;e<this.fileDirectory.BitsPerSample.length;e+=1)l.push(e)}return this.readRasters({window:e,interleave:t,samples:l,pool:i,width:r,height:n,resampleMethod:s,signal:o})}let f;switch(h){case Vn:case Nn:case jn:f=[0];break;case Zn:f=[0,1,2,3];break;case Hn:case Yn:f=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const c={window:l,interleave:!0,samples:f,pool:i,width:r,height:n,resampleMethod:s,signal:o},{fileDirectory:u}=this,d=await this.readRasters(c),g=2**this.fileDirectory.BitsPerSample[0];let m;switch(h){case Vn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let s;for(let i=0,r=0;i<e.length;++i,r+=3)s=256-e[i]/t*256,n[r]=s,n[r+1]=s,n[r+2]=s;return n}(d,g);break;case Nn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3);let s;for(let i=0,r=0;i<e.length;++i,r+=3)s=e[i]/t*256,n[r]=s,n[r+1]=s,n[r+2]=s;return n}(d,g);break;case jn:m=function(e,t){const{width:i,height:r}=e,n=new Uint8Array(i*r*3),s=t.length/3,a=t.length/3*2;for(let i=0,r=0;i<e.length;++i,r+=3){const o=e[i];n[r]=t[o]/65536*256,n[r+1]=t[o+s]/65536*256,n[r+2]=t[o+a]/65536*256}return n}(d,u.ColorMap);break;case Zn:m=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=4,i+=3){const n=e[t],s=e[t+1],a=e[t+2],o=e[t+3];r[i]=(255-n)/256*255*((255-o)/256),r[i+1]=(255-s)/256*255*((255-o)/256),r[i+2]=(255-a)/256*255*((255-o)/256)}return r}(d);break;case Hn:m=function(e){const{width:t,height:i}=e,r=new Uint8ClampedArray(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){const n=e[t],s=e[t+1],a=e[t+2];r[i]=n+1.402*(a-128),r[i+1]=n-.34414*(s-128)-.71414*(a-128),r[i+2]=n+1.772*(s-128)}return r}(d);break;case Yn:m=function(e){const{width:t,height:i}=e,r=new Uint8Array(t*i*3);for(let t=0,i=0;t<e.length;t+=3,i+=3){let n,s,a,o=(e[t+0]+16)/116,l=(e[t+1]<<24>>24)/500+o,h=o-(e[t+2]<<24>>24)/200;l=.95047*(l*l*l>.008856?l*l*l:(l-16/116)/7.787),o=1*(o*o*o>.008856?o*o*o:(o-16/116)/7.787),h=1.08883*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),n=3.2406*l+-1.5372*o+-.4986*h,s=-.9689*l+1.8758*o+.0415*h,a=.0557*l+-.204*o+1.057*h,n=n>.0031308?1.055*n**(1/2.4)-.055:12.92*n,s=s>.0031308?1.055*s**(1/2.4)-.055:12.92*s,a=a>.0031308?1.055*a**(1/2.4)-.055:12.92*a,r[i]=255*Math.max(0,Math.min(1,n)),r[i+1]=255*Math.max(0,Math.min(1,s)),r[i+2]=255*Math.max(0,Math.min(1,a))}return r}(d);break;default:throw new Error("Unsupported photometric interpretation.")}if(!t){const e=new Uint8Array(m.length/3),t=new Uint8Array(m.length/3),i=new Uint8Array(m.length/3);for(let r=0,n=0;r<m.length;r+=3,++n)e[n]=m[r],t[n]=m[r+1],i[n]=m[r+2];m=[e,t,i]}return m.width=d.width,m.height=d.height,m}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let 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}getGDALMetadata(e=null){const t={};if(!this.fileDirectory.GDAL_METADATA)return null;const i=this.fileDirectory.GDAL_METADATA;let r=Ln(i,"Item");r=null===e?r.filter((e=>void 0===wn(e,"sample"))):r.filter((t=>Number(wn(t,"sample"))===e));for(let e=0;e<r.length;++e){const i=r[e];t[wn(i,"name")]=i.inner}return t}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const 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.")}getResolution(e=null){const t=this.fileDirectory.ModelPixelScale,i=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(i)return[i[0],i[5],i[10]];if(e){const[t,i,r]=e.getResolution();return[t*e.getWidth()/this.getWidth(),i*e.getHeight()/this.getHeight(),r*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return 1===this.geoKeys.GTRasterTypeGeoKey}getBoundingBox(){const e=this.getOrigin(),t=this.getResolution(),i=e[0],r=e[1],n=i+t[0]*this.getWidth(),s=r+t[1]*this.getHeight();return[Math.min(i,n),Math.min(r,s),Math.max(i,n),Math.max(r,s)]}};class ls{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const i=this.getUint32(e,t),r=this.getUint32(e+4,t);let n;if(t){if(n=i+2**32*r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*i+r,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}getInt64(e,t){let i=0;const r=(128&this._dataView.getUint8(e+(t?7:0)))>0;let n=!0;for(let s=0;s<8;s++){let a=this._dataView.getUint8(e+(t?s:7-s));r&&(n?0!==a&&(a=255&~(a-1),n=!1):a=255&~a),i+=a*256**s}return r&&(i=-i),i}getUint8(e,t){return this._dataView.getUint8(e,t)}getInt8(e,t){return this._dataView.getInt8(e,t)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return gn(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}}class hs{constructor(e,t,i,r){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=i,this._bigTiff=r}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),i=this.readUint32(e+4);let r;if(this._littleEndian){if(r=t+2**32*i,!Number.isSafeInteger(r))throw new Error(`${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=2**32*t+i,!Number.isSafeInteger(r))throw new Error(`${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}readInt64(e){let t=0;const i=(128&this._dataView.getUint8(e+(this._littleEndian?7:0)))>0;let r=!0;for(let n=0;n<8;n++){let s=this._dataView.getUint8(e+(this._littleEndian?n:7-n));i&&(r?0!==s&&(s=255&~(s-1),r=!1):s=255&~s),t+=s*256**n}return i&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}class fs{async fetch(e,t=undefined){return Promise.all(e.map((e=>this.fetchSlice(e,t))))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class cs extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,cs),this.name="AbortError"}}class us extends fs{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,t){if(t&&t.aborted)throw new cs("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function ds(e,t){let i=e.length-t,r=0;do{for(let i=t;i>0;i--)e[r+t]+=e[r],r++;i-=t}while(i>0)}function gs(e,t,i){let r=0,n=e.length;const s=n/i;for(;n>t;){for(let i=t;i>0;--i)e[r+t]+=e[r],++r;n-=t}const a=e.slice();for(let t=0;t<s;++t)for(let r=0;r<i;++r)e[i*t+r]=a[(i-r-1)*s+t]}class ms{async decode(e,t){const i=await this.decodeBlock(t),r=e.Predictor||1;if(1!==r){const t=!e.StripOffsets;return function(e,t,i,r,n,s){if(!t||1===t)return e;for(let e=0;e<n.length;++e){if(n[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(n[e]!==n[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=n[0]/8,o=2===s?1:n.length;for(let s=0;s<r&&!(s*o*i*a>=e.byteLength);++s){let r;if(2===t){switch(n[0]){case 8:r=new Uint8Array(e,s*o*i*a,o*i*a);break;case 16:r=new Uint16Array(e,s*o*i*a,o*i*a/2);break;case 32:r=new Uint32Array(e,s*o*i*a,o*i*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${n[0]} bits per sample.`)}ds(r,o)}else 3===t&&(r=new Uint8Array(e,s*o*i*a,o*i*a),gs(r,o,a))}return e}(i,r,t?e.TileWidth:e.ImageWidth,t?e.TileLength:e.RowsPerStrip||e.ImageLength,e.BitsPerSample,e.PlanarConfiguration)}return i}}function ps(e){switch(e){case Fn.BYTE:case Fn.ASCII:case Fn.SBYTE:case Fn.UNDEFINED:return 1;case Fn.SHORT:case Fn.SSHORT:return 2;case Fn.LONG:case Fn.SLONG:case Fn.FLOAT:case Fn.IFD:return 4;case Fn.RATIONAL:case Fn.SRATIONAL:case Fn.DOUBLE:case Fn.LONG8:case Fn.SLONG8:case Fn.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${e}`)}}function ws(e,t,i,r){let n=null,s=null;const a=ps(t);switch(t){case Fn.BYTE:case Fn.ASCII:case Fn.UNDEFINED:n=new Uint8Array(i),s=e.readUint8;break;case Fn.SBYTE:n=new Int8Array(i),s=e.readInt8;break;case Fn.SHORT:n=new Uint16Array(i),s=e.readUint16;break;case Fn.SSHORT:n=new Int16Array(i),s=e.readInt16;break;case Fn.LONG:case Fn.IFD:n=new Uint32Array(i),s=e.readUint32;break;case Fn.SLONG:n=new Int32Array(i),s=e.readInt32;break;case Fn.LONG8:case Fn.IFD8:n=new Array(i),s=e.readUint64;break;case Fn.SLONG8:n=new Array(i),s=e.readInt64;break;case Fn.RATIONAL:n=new Uint32Array(2*i),s=e.readUint32;break;case Fn.SRATIONAL:n=new Int32Array(2*i),s=e.readInt32;break;case Fn.FLOAT:n=new Float32Array(i),s=e.readFloat32;break;case Fn.DOUBLE:n=new Float64Array(i),s=e.readFloat64;break;default:throw new RangeError(`Invalid field type: ${t}`)}if(t!==Fn.RATIONAL&&t!==Fn.SRATIONAL)for(let t=0;t<i;++t)n[t]=s.call(e,r+t*a);else for(let t=0;t<i;t+=2)n[t]=s.call(e,r+t*a),n[t+1]=s.call(e,r+(t*a+4));return t===Fn.ASCII?new TextDecoder("utf-8").decode(n):n}class ys{constructor(e,t,i){this.fileDirectory=e,this.geoKeyDirectory=t,this.nextIFDByteOffset=i}}class _s extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class bs{async readRasters(e={}){const{window:t,width:i,height:r}=e;let{resX:n,resY:s,bbox:a}=e;const o=await this.getImage();let l=o;const h=await this.getImageCount(),f=o.getBoundingBox();if(t&&a)throw new Error('Both "bbox" and "window" passed.');if(i||r){if(t){const[e,i]=o.getOrigin(),[r,n]=o.getResolution();a=[e+t[0]*r,i+t[1]*n,e+t[2]*r,i+t[3]*n]}const e=a||f;if(i){if(n)throw new Error("Both width and resX passed");n=(e[2]-e[0])/i}if(r){if(s)throw new Error("Both width and resY passed");s=(e[3]-e[1])/r}}if(n||s){const e=[];for(let t=0;t<h;++t){const i=await this.getImage(t),{SubfileType:r,NewSubfileType:n}=i.fileDirectory;(0===t||2===r||1&n)&&e.push(i)}e.sort(((e,t)=>e.getWidth()-t.getWidth()));for(let t=0;t<e.length;++t){const i=e[t],r=(f[2]-f[0])/i.getWidth(),a=(f[3]-f[1])/i.getHeight();if(l=i,n&&n>r||s&&s>a)break}}let c=t;if(a){const[e,t]=o.getOrigin(),[i,r]=l.getResolution(o);c=[Math.round((a[0]-e)/i),Math.round((a[1]-t)/r),Math.round((a[2]-e)/i),Math.round((a[3]-t)/r)],c=[Math.min(c[0],c[2]),Math.min(c[1],c[3]),Math.max(c[0],c[2]),Math.max(c[1],c[3])]}return l.readRasters({...e,window:c})}}class vs extends bs{constructor(e,t,i,r,n={}){super(),this.source=e,this.littleEndian=t,this.bigTiff=i,this.firstIFDOffset=r,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,t){const i=this.bigTiff?4048:1024;return new hs((await this.source.fetch([{offset:e,length:void 0!==t?t:i}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,i=this.bigTiff?8:2;let r=await this.getSlice(e);const n=this.bigTiff?r.readUint64(e):r.readUint16(e),s=n*t+(this.bigTiff?16:6);r.covers(e,s)||(r=await this.getSlice(e,s));const a={};let o=e+(this.bigTiff?8:2);for(let e=0;e<n;o+=t,++e){const e=r.readUint16(o),t=r.readUint16(o+2),i=this.bigTiff?r.readUint64(o+4):r.readUint32(o+4);let n,s;const l=ps(t),h=o+(this.bigTiff?12:8);if(l*i<=(this.bigTiff?8:4))n=ws(r,t,i,h);else{const e=r.readOffset(h),s=ps(t)*i;if(r.covers(e,s))n=ws(r,t,i,e);else{n=ws(await this.getSlice(e,s),t,i,e)}}s=1===i&&-1===Bn.indexOf(e)&&t!==Fn.RATIONAL&&t!==Fn.SRATIONAL?n[0]:n,a[zn[e]]=s}const l=function(e){const t=e.GeoKeyDirectory;if(!t)return null;const i={};for(let r=4;r<=4*t[3];r+=4){const n=Jn[t[r]],s=t[r+1]?zn[t[r+1]]:null,a=t[r+2],o=t[r+3];let l=null;if(s){if(l=e[s],null==l)throw new Error(`Could not get value of geoKey '${n}'.`);"string"==typeof l?l=l.substring(o,o+a-1):l.subarray&&(l=l.subarray(o,o+a),1===a&&(l=l[0]))}else l=o;i[n]=l}return i}(a),h=r.readOffset(e+i+t*n);return new ys(a,l,h)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(0===e)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(t){if(t instanceof _s)throw new _s(e);throw t}return this.ifdRequests[e]=(async()=>{const t=await this.ifdRequests[e-1];if(0===t.nextIFDByteOffset)throw new _s(e);return this.parseFileDirectoryAt(t.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const t=await this.requestIFD(e);return new os(t.fileDirectory,t.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,t=!0;for(;t;)try{await this.requestIFD(e),++e}catch(e){if(!(e instanceof _s))throw e;t=!1}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const t="GDAL_STRUCTURAL_METADATA_SIZE=",i=t.length+100;let r=await this.getSlice(e,i);if(t===ws(r,Fn.ASCII,t.length,e)){const t=ws(r,Fn.ASCII,i,e).split("\n")[0],n=Number(t.split("=")[1].split(" ")[0])+t.length;n>i&&(r=await this.getSlice(e,n));const s=ws(r,Fn.ASCII,n,e);this.ghostValues={},s.split("\n").filter((e=>e.length>0)).map((e=>e.split("="))).forEach((([e,t])=>{this.ghostValues[e]=t}))}return this.ghostValues}static async fromSource(e,t,i){const r=(await e.fetch([{offset:0,length:1024}],i))[0],n=new ls(r),s=n.getUint16(0,0);let a;if(18761===s)a=!0;else{if(19789!==s)throw new TypeError("Invalid byte order value.");a=!1}const o=n.getUint16(2,a);let l;if(42===o)l=!1;else{if(43!==o)throw new TypeError("Invalid magic number.");l=!0;if(8!==n.getUint16(4,a))throw new Error("Unsupported offset byte-size.")}const h=l?n.getUint64(8,a):n.getUint32(4,a);return new vs(e,a,l,h,t)}close(){return"function"==typeof this.source.close&&this.source.close()}}async function ks(e,t){return vs.fromSource(function(e){return new us(e)}(e),t)}const xs={type:"image",format:"uint8",useHeatMap:!0,useColorsBasedOnValues:!1,useAutoRange:!1,useDataForOpacity:!1,useSingleColor:!1,clipLow:null,clipHigh:null,multiplier:1,color:[255,0,255,255],colorScale:n.brewer.YlOrRd,colorScaleValueRange:[0,255],colorsBasedOnValues:null,alpha:255,useChannel:null,noDataValue:void 0,numOfChannels:void 0,nullColor:[0,0,0,0],unidentifiedColor:[0,0,0,0],clippedColor:[0,0,0,0]};class Ts{constructor(){this.scale=(e,t,i,r,n)=>(e-t)*(n-r)/(i-t)+r}setUrl(e){return s(this,void 0,void 0,(function*(){const t=yield fetch(e),i=yield t.arrayBuffer(),r=yield ks(i),n=yield r.getImage(0);this.data=n}))}getMap(e,t){return s(this,void 0,void 0,(function*(){const i=Object.assign(Object.assign({},xs),t);switch(i.type){case"image":return this.getBitmap(e,i);case"terrain":return this.getHeightmap(e,i);default:return null}}))}getHeightmap(e,t){return s(this,void 0,void 0,(function*(){let i,r,n=[];"string"==typeof e?(yield this.setUrl(e),n=yield this.data.readRasters(),i=this.data.getWidth(),r=this.data.getHeight()):(n=e.rasters,i=e.width,r=e.height);let s=n[0];null!=t.useChannel&&n[t.useChannel]&&(s=n[t.useChannel]);const a=document.createElement("canvas");a.width=i,a.height=r;const o=a.getContext("2d"),l=o.createImageData(i,r),h=s.length/(i*r),f=i*r*4;let c=0;null!=t.useChannel&&(c=t.useChannel);for(let e=0;e<f;e+=4){s[c]*=t.multiplier;const i=1e5+10*s[c];l.data[e]=Math.trunc(1525878e-11*i),l.data[e+1]=Math.trunc(.00390625*i)-256*l.data[e],l.data[e+2]=Math.trunc(i)-65536*l.data[e]-256*l.data[e+1],l.data[e+3]=255,c+=h}o.putImageData(l,0,0);return a.toDataURL("image/png")}))}getBitmap(e,t){return s(this,void 0,void 0,(function*(){const i=Object.assign({},t);let r,n,s,a=[];"string"==typeof e?(yield this.setUrl(e),a=yield this.data.readRasters(),r=a.length,n=this.data.getWidth(),s=this.data.getHeight()):(a=e.rasters,r=a.length,n=e.width,s=e.height);const o=document.createElement("canvas");o.width=n,o.height=s;const l=o.getContext("2d"),h=l.createImageData(n,s);let f,c,u,d;const g=n*s*4;if(t.noDataValue||console.log("Missing noData value. Raster might be displayed incorrectly."),i.unidentifiedColor=this.getColorFromChromaType(i.unidentifiedColor),i.nullColor=this.getColorFromChromaType(i.nullColor),i.clippedColor=this.getColorFromChromaType(i.clippedColor),i.color=this.getColorFromChromaType(i.color),null==i.useChannel){if(1===r){if(a[0].length/(n*s)==1){const e=a[0];i.useAutoRange&&(i.colorScaleValueRange=this.getMinMax(e,i));this.getColorValue(e,i,g).forEach(((e,t)=>{h.data[t]=e}))}if(a[0].length/(n*s)==3){let e=0;for(let t=0;t<g;t+=4){const r=[a[0][e],a[0][e+1],a[0][e+2]],n=this.hasPixelsNoData(r,i.noDataValue)?i.nullColor:[...r,i.alpha];[h.data[t],h.data[t+1],h.data[t+2],h.data[t+3]]=n,e+=3}}a[0].length/(n*s)==4&&a[0].forEach(((e,t)=>{h.data[t]=e}))}if(3===r){let e=0;for(let t=0;t<g;t+=4)f=a[0][e],c=a[1][e],u=a[2][e],d=i.alpha,h.data[t]=f,h.data[t+1]=c,h.data[t+2]=u,h.data[t+3]=d,e+=1}if(4===r){let e=0;for(let t=0;t<g;t+=4)f=a[0][e],c=a[1][e],u=a[2][e],d=i.alpha,h.data[t]=f,h.data[t+1]=c,h.data[t+2]=u,h.data[t+3]=d,e+=1}}else if(i.useChannel<=i.numOfChannels){let e=a[0];a[i.useChannel]&&(e=a[i.useChannel]),i.useAutoRange&&(i.colorScaleValueRange=this.getMinMax(e,i));const t=e.length/(n*s);this.getColorValue(e,i,g,t).forEach(((e,t)=>{h.data[t]=e}))}else{console.log("Defined channel does not exist, displaying only grey values");this.getDefaultColor(g,i.nullColor).forEach(((e,t)=>{h.data[t]=e}))}l.putImageData(h,0,0);return o.toDataURL("image/png")}))}getMinMax(e,t){let i=t.maxValue?t.maxValue:Number.MIN_VALUE,r=t.minValue?t.minValue:Number.MAX_VALUE;for(let n=0;n<e.length;n+=1)void 0!==t.noDataValue&&e[n]===t.noDataValue||(e[n]>i&&(i=e[n]),e[n]<r&&(r=e[n]));return[r,i]}getColorValue(e,t,i,r=1){const s=n.scale(t.colorScale).domain(t.colorScaleValueRange);let a=null===t.useChannel?0:t.useChannel;const o=new Array(i),l=t.colorsBasedOnValues?t.colorsBasedOnValues.map((([e])=>e)):void 0,h=t.colorsBasedOnValues?t.colorsBasedOnValues.map((([,e])=>[...n(e).rgb(),255])):void 0;for(let n=0;n<i;n+=4){let i=t.nullColor;if(void 0===t.noDataValue||e[a]!==t.noDataValue)if(null!=t.clipLow&&e[a]<=t.clipLow||null!=t.clipHigh&&e[a]>=t.clipHigh)i=t.clippedColor;else{if(t.useHeatMap&&(i=[...s(e[a]).rgb(),255]),t.useColorsBasedOnValues){const r=l.indexOf(e[a]);i=r>-1?h[r]:t.unidentifiedColor}t.useSingleColor&&(i=t.color),t.useDataForOpacity&&(i[3]=this.scale(e[a],t.colorScaleValueRange[0],t.colorScaleValueRange.slice(-1)[0],0,255))}[o[n],o[n+1],o[n+2],o[n+3]]=i,a+=r}return o}getDefaultColor(e,t){const i=new Array(e);for(let r=0;r<e;r+=4)[i[r],i[r+1],i[r+2],i[r+3]]=t;return i}getColorFromChromaType(e){return Array.isArray(e)&&4===e.length?e:[...n(e).rgb(),255]}hasPixelsNoData(e,t){return void 0!==t&&e.every((e=>e===t))}}const As=40075e3,Ss=20037500;class Is{constructor(e){this.zoomRange=[0,0],this.lowestOriginTileOffset=[0,0],this.lowestOriginTileSize=0,this.loaded=!1,this.geo=new Ts,this.lzw=new pr,this.options=e}initializeCog(e){return s(this,void 0,void 0,(function*(){j.fetch=(e,t)=>s(this,void 0,void 0,(function*(){return yield fetch(e,t)}));const t=new j(e);return this.cog=yield B.create(t),this.cog.images.forEach((e=>{e.loadGeoTiffTags()})),this.tileSize=this.getTileSize(this.cog),this.lowestOriginTileOffset=this.getImageTileIndex(this.cog.images[this.cog.images.length-1]),this.zoomRange=this.getZoomRange(this.cog),this.cog}))}getTileSize(e){return e.images[e.images.length-1].tileSize.width}getZoomRange(e){const t=e.images[e.images.length-1],i=this.getZoomLevelFromResolution(e.images[e.images.length-1].tileSize.width,t.resolution[0]);return[i,i+(e.images.length-1)]}getBoundsAsLatLon(e){const{bbox:t}=e.images[e.images.length-1],i=Math.min(t[0],t[2]),r=Math.max(t[0],t[2]),n=Math.min(t[1],t[3]),s=Math.max(t[1],t[3]),a=this.getLatLon([i,n]),o=this.getLatLon([r,s]);return[a[0],a[1],o[0],o[1]]}getOriginAsLatLon(e){const{origin:t}=e.images[e.images.length-1];return this.getLatLon(t)}getImageTileIndex(e){const t=Ss+e.origin[0],i=-(Ss+(e.origin[1]-As)),r=e.tileSize.width*this.getResolutionFromZoomLevel(e.tileSize.width,this.getZoomLevelFromResolution(e.tileSize.width,e.resolution[0]));return[Math.round(t/r),Math.round(i/r),this.getZoomLevelFromResolution(e.tileSize.width,e.resolution[0])]}getResolutionFromZoomLevel(e,t){return As/e/Math.pow(2,t)}getZoomLevelFromResolution(e,t){return Math.round(Math.log2(As/(t*e)))}getLatLon(e){const t=function(e){const[t,i]=e,r=t/512*(2*or)-or,n=2*(Math.atan(Math.exp(i/512*(2*or)-or))-lr);return[r*hr,n*hr]}([12776044915782906e-21*(Ss+e[0]),12776044915782906e-21*-(Ss+(e[1]-As))]);return[t[0],-t[1]]}getTile(e,t,i){return s(this,void 0,void 0,(function*(){const r=this.getResolutionFromZoomLevel(this.tileSize,i),n=this.cog.getImageByResolution(r);let s=[0,0];if(i===this.zoomRange[0])s=this.lowestOriginTileOffset;else{const e=Math.pow(2,i-this.zoomRange[0]);s[0]=Math.floor(this.lowestOriginTileOffset[0]*e),s[1]=Math.floor(this.lowestOriginTileOffset[1]*e)}const a=n.tileCount.x,o=n.tileCount.y,l=s[0],h=s[1];let f,c;this.options.numOfChannels=Number(n.tags.get(277).value),this.options.noDataValue=this.getNoDataValue(n.tags),this.options.format||(this.options.format=this.getFormat(n.tags.get(339).value,n.tags.get(258).value));let u=n.tags.get(258).value;if(Array.isArray(u))if("terrain"===this.options.type){let e=0;u.forEach((t=>{e+=t})),u=e}else[u]=u;if(e-l>=0&&t-h>=0&&e-l<a&&t-h<o){const i=yield n.getTile(e-l,t-h);switch(n.compression){case"image/jpeg":c=sr.decode(i.bytes,{useTArray:!0});break;case"application/deflate":c=yield Ji(i.bytes);break;case"application/lzw":c=this.lzw.decodeBlock(i.bytes.buffer);break;default:console.warn(`Unexpected compression method: ${n.compression}`)}let r;switch(this.options.format){case"uint8":r=new Uint8Array(c.buffer);break;case"uint16":r=new Uint16Array(c.buffer);break;case"uint32":r=new Uint32Array(c.buffer);break;case"int8":r=new Int8Array(c.buffer);break;case"int16":r=new Int16Array(c.buffer);break;case"int32":r=new Int32Array(c.buffer);break;case"float32":r=new Float32Array(c.buffer);break;case"float64":r=new Float64Array(c.buffer);break;default:r=null}return f=yield this.geo.getMap({rasters:[r],width:this.tileSize,height:this.tileSize},this.options),f}return null}))}getFormat(e,t){let i,r=e,n=t;switch(Array.isArray(e)&&([r]=e),Array.isArray(t)&&([n]=t),r){case 1:switch(n){case 8:i="uint8";break;case 16:i="uint16";break;case 32:i="uint32";break;default:i=null}break;case 2:switch(n){case 8:i="int8";break;case 16:i="int16";break;case 32:i="int32";break;default:i=null}break;case 3:switch(n){case 32:i="float32";break;case 64:i="float64";break;default:i=null}break;default:throw new Error("Unknown data format.")}return i}getNoDataValue(e){if(e.has(42113)){const t=e.get(42113).value;if("string"==typeof t||t instanceof String){const e=t.replace(/[\0\s]/g,"");return Number(e)}return Number.isNaN(Number(t))?void 0:Number(t)}}testCog(){return s(this,void 0,void 0,(function*(){this.options={type:"image",multiplier:1,useChannel:1,alpha:180,clipLow:1,clipHigh:Number.MAX_VALUE};const e=yield this.initializeCog("https://gisat-gis.eu-central-1.linodeobjects.com/eman/versions/v2/Quadrants/Q3_Bolivia_ASTER_2002_RGB_COG_LZW.tif"),t=e.images[Math.floor(e.images.length/2)];console.log(t);const i=this.getImageTileIndex(t);console.log(i);const r=Math.floor(t.tileCount.x/2),n=Math.floor(t.tileCount.y/2);console.log(e.getTile(r,n,Math.floor(e.images.length/2)));const s=r+i[0],a=n+i[1],o=i[2],l=yield this.getTile(s,a,o);!1===l?console.log("couldn't retrieve tile"):console.log(l)}))}}class Us extends e{constructor(e,t,i){super({}),this.id="",this.id=e,this.cogTiles=new Is(i),this.url=t}initializeState(){this.state={initialized:!1},this.init(this.url)}init(e){return s(this,void 0,void 0,(function*(){const t=yield this.cogTiles.initializeCog(e);this.setState({initialized:!0}),this.tileSize=this.cogTiles.getTileSize(t);const i=this.cogTiles.getZoomRange(t);[this.minZoom,this.maxZoom]=i}))}renderLayers(){if(this.cogTiles.cog){return new t({id:`${this.id}-${String(performance.now())}`,getTileData:e=>this.cogTiles.getTile(e.index.x,e.index.y,e.index.z),minZoom:this.minZoom,maxZoom:this.maxZoom,tileSize:this.tileSize,maxRequests:6,extent:this.cogTiles.cog?this.cogTiles.getBoundsAsLatLon(this.cogTiles.cog):null,renderSubLayers:e=>{const{bbox:{west:t,south:i,east:n,north:s}}=e.tile;return new r(e,{data:null,image:e.data,bounds:[t,i,n,s],opacity:1})}})}return null}}Us.layerName="CogBitmapLayer",Us.displayName="CogBitmapLayer";class Cs extends e{constructor(e,t,i,r,n){var s;super({}),this.urlType="none",this.id="",this.id=e,r&&((s=r).includes("{x}")&&s.includes("{y}")&&s.includes("{z}")?(this.bitmapUrl=r,this.urlType="tile"):!function(e){return!!(e.includes(".tif")||e.includes(".tiff")||e.includes(".TIF")||e.includes(".TIFF"))}(r)?console.warn("URL needs to point to a valid cog file, or needs to be in the {x}{y}{z} format."):(this.bitmapCogTiles=new Is(n),this.bitmapCogTiles.initializeCog(r),this.urlType="cog")),this.terrainCogTiles=new Is(i),this.terrainUrl=t}initializeState(){this.state={initialized:!1},this.init(this.terrainUrl)}init(e){return s(this,void 0,void 0,(function*(){const t=yield this.terrainCogTiles.initializeCog(e);this.tileSize=this.terrainCogTiles.getTileSize(t);const i=this.terrainCogTiles.getZoomRange(t);[this.minZoom,this.maxZoom]=i,this.setState({initialized:!0})}))}renderLayers(){if(this.terrainCogTiles.cog){let e;this.urlType;return[new t({id:`${this.id}-${String(performance.now())}`,zoomOffset:-1,getTileData:e=>this.terrainCogTiles.getTile(e.index.x,e.index.y,e.index.z),minZoom:this.minZoom,maxZoom:this.maxZoom,tileSize:this.tileSize,maxRequests:6,refinementStrategy:"best-available",extent:this.terrainCogTiles.getBoundsAsLatLon(this.terrainCogTiles.cog),renderSubLayers:t=>{if(t.data&&void 0!==t.tile.index.x){switch(this.urlType){case"tile":r=this.bitmapUrl,n=t.tile.index.x,s=t.tile.index.y,a=t.tile.index.z,e=r.replace("{x}",String(n)).replace("{y}",String(s)).replace("{z}",String(a));break;case"cog":e=this.bitmapCogTiles.getTile(t.tile.index.x,t.tile.index.y,t.tile.index.z);break;default:e=null}return new i({id:`terrain-${t.tile.index.x}-${t.tile.index.y}-${t.tile.index.z}`,pickable:!0,elevationDecoder:{rScaler:6553.6,gScaler:25.6,bScaler:.1,offset:-1e4},elevationData:t.data,texture:e,bounds:[t.tile.bbox.west,t.tile.bbox.south,t.tile.bbox.east,t.tile.bbox.north],operation:"terrain+draw",minZoom:this.minZoom,maxZoom:this.maxZoom,loadOptions:{terrain:{skirtHeight:2e3,tesselator:"martini"}},meshMaxError:12})}var r,n,s,a;return null}})]}return[]}}Cs.layerName="CogTerrainLayer",Cs.displayName="CogTerrainLayer";var Ds={CogBitmapLayer:Us,CogTerrainLayer:Cs,cogtiles:Is,GeoImage:Ts};var Es=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return e}}});const Ps=257;function Ms(e,t){for(let i=t.length-1;i>=0;i--)e.push(t[i]);return e}function Os(e){const t=new Uint16Array(4093),i=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,i[e]=e;let r=258,n=9,s=0;function a(){r=258,n=9}function o(e){const t=function(e,t,i){const r=t%8,n=Math.floor(t/8),s=8-r,a=t+i-8*(n+1);let o=8*(n+2)-(t+i);const l=8*(n+2)-t;if(o=Math.max(0,o),n>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),Ps;let h=e[n]&2**(8-r)-1;h<<=i-s;let f=h;if(n+1<e.length){let t=e[n+1]>>>o;t<<=Math.max(0,i-l),f+=t}if(a>8&&n+2<e.length){const r=8*(n+3)-(t+i);f+=e[n+2]>>>r}return f}(e,s,n);return s+=n,t}function l(e,n){return i[r]=n,t[r]=e,r++,r-1}function h(e){const r=[];for(let n=e;4096!==n;n=t[n])r.push(i[n]);return r}const f=[];a();const c=new Uint8Array(e);let u,d=o(c);for(;d!==Ps;){if(256===d){for(a(),d=o(c);256===d;)d=o(c);if(d===Ps)break;if(d>256)throw new Error(`corrupted code at scanline ${d}`);Ms(f,h(d)),u=d}else if(d<r){const e=h(d);Ms(f,e),l(u,e[e.length-1]),u=d}else{const e=h(u);if(!e)throw new Error(`Bogus entry. Not in dictionary, ${u} / ${r}, position: ${s}`);Ms(f,e),f.push(e[e.length-1]),l(u,e[e.length-1]),u=d}r+1>=2**n&&(12===n?u=void 0:n++),d=o(c)}return new Uint8Array(f)}var Ls=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return Os(e).buffer}}});const zs=new Int32Array([0,1,8,16,9,2,3,10,17,24,32,25,18,11,4,5,12,19,26,33,40,48,41,34,27,20,13,6,7,14,21,28,35,42,49,56,57,50,43,36,29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,47,55,62,63]),Gs=4017,Bs=799,Rs=3406,Fs=2276,Vs=1567,Ns=3784,Ks=5793,js=2896;function Zs(e,t){let i=0;const r=[];let n=16;for(;n>0&&!e[n-1];)--n;r.push({children:[],index:0});let s,a=r[0];for(let o=0;o<n;o++){for(let n=0;n<e[o];n++){for(a=r.pop(),a.children[a.index]=t[i];a.index>0;)a=r.pop();for(a.index++,r.push(a);r.length<=o;)r.push(s={children:[],index:0}),a.children[a.index]=s.children,a=s;i++}o+1<n&&(r.push(s={children:[],index:0}),a.children[a.index]=s.children,a=s)}return r[0].children}function Hs(e,t,i,r,n,s,a,o,l){const{mcusPerLine:h,progressive:f}=i,c=t;let u=t,d=0,g=0;function m(){if(g>0)return g--,d>>g&1;if(d=e[u++],255===d){const t=e[u++];if(t)throw new Error(`unexpected marker: ${(d<<8|t).toString(16)}`)}return g=7,d>>>7}function p(e){let t,i=e;for(;null!==(t=m());){if(i=i[t],"number"==typeof i)return i;if("object"!=typeof i)throw new Error("invalid huffman sequence")}return null}function w(e){let t=e,i=0;for(;t>0;){const e=m();if(null===e)return;i=i<<1|e,--t}return i}function y(e){const t=w(e);return t>=1<<e-1?t:t+(-1<<e)+1}let _=0;let b,v=0;function k(e,t,i,r,n){const s=i%h,a=(i/h|0)*e.v+r,o=s*e.h+n;t(e,e.blocks[a][o])}function x(e,t,i){const r=i/e.blocksPerLine|0,n=i%e.blocksPerLine;t(e,e.blocks[r][n])}const T=r.length;let A,S,I,U,C,D;D=f?0===s?0===o?function(e,t){const i=p(e.huffmanTableDC),r=0===i?0:y(i)<<l;e.pred+=r,t[0]=e.pred}:function(e,t){t[0]|=m()<<l}:0===o?function(e,t){if(_>0)return void _--;let i=s;const r=a;for(;i<=r;){const r=p(e.huffmanTableAC),n=15&r,s=r>>4;if(0===n){if(s<15){_=w(s)+(1<<s)-1;break}i+=16}else i+=s,t[zs[i]]=y(n)*(1<<l),i++}}:function(e,t){let i=s;const r=a;let n=0;for(;i<=r;){const r=zs[i],s=t[r]<0?-1:1;switch(v){case 0:{const t=p(e.huffmanTableAC),i=15&t;if(n=t>>4,0===i)n<15?(_=w(n)+(1<<n),v=4):(n=16,v=1);else{if(1!==i)throw new Error("invalid ACn encoding");b=y(i),v=n?2:3}continue}case 1:case 2:t[r]?t[r]+=(m()<<l)*s:(n--,0===n&&(v=2===v?3:0));break;case 3:t[r]?t[r]+=(m()<<l)*s:(t[r]=b<<l,v=0);break;case 4:t[r]&&(t[r]+=(m()<<l)*s)}i++}4===v&&(_--,0===_&&(v=0))}:function(e,t){const i=p(e.huffmanTableDC),r=0===i?0:y(i);e.pred+=r,t[0]=e.pred;let n=1;for(;n<64;){const i=p(e.huffmanTableAC),r=15&i,s=i>>4;if(0===r){if(s<15)break;n+=16}else n+=s,t[zs[n]]=y(r),n++}};let E,P,M=0;P=1===T?r[0].blocksPerLine*r[0].blocksPerColumn:h*i.mcusPerColumn;const O=n||P;for(;M<P;){for(S=0;S<T;S++)r[S].pred=0;if(_=0,1===T)for(A=r[0],C=0;C<O;C++)x(A,D,M),M++;else for(C=0;C<O;C++){for(S=0;S<T;S++){A=r[S];const{h:e,v:t}=A;for(I=0;I<t;I++)for(U=0;U<e;U++)k(A,D,M,I,U)}if(M++,M===P)break}if(g=0,E=e[u]<<8|e[u+1],E<65280)throw new Error("marker was not found");if(!(E>=65488&&E<=65495))break;u+=2}return u-c}function Ys(e,t){const i=[],{blocksPerLine:r,blocksPerColumn:n}=t,s=r<<3,a=new Int32Array(64),o=new Uint8Array(64);function l(e,i,r){const n=t.quantizationTable;let s,a,o,l,h,f,c,u,d;const g=r;let m;for(m=0;m<64;m++)g[m]=e[m]*n[m];for(m=0;m<8;++m){const e=8*m;0!==g[1+e]||0!==g[2+e]||0!==g[3+e]||0!==g[4+e]||0!==g[5+e]||0!==g[6+e]||0!==g[7+e]?(s=Ks*g[0+e]+128>>8,a=Ks*g[4+e]+128>>8,o=g[2+e],l=g[6+e],h=js*(g[1+e]-g[7+e])+128>>8,u=js*(g[1+e]+g[7+e])+128>>8,f=g[3+e]<<4,c=g[5+e]<<4,d=s-a+1>>1,s=s+a+1>>1,a=d,d=o*Ns+l*Vs+128>>8,o=o*Vs-l*Ns+128>>8,l=d,d=h-c+1>>1,h=h+c+1>>1,c=d,d=u+f+1>>1,f=u-f+1>>1,u=d,d=s-l+1>>1,s=s+l+1>>1,l=d,d=a-o+1>>1,a=a+o+1>>1,o=d,d=h*Fs+u*Rs+2048>>12,h=h*Rs-u*Fs+2048>>12,u=d,d=f*Bs+c*Gs+2048>>12,f=f*Gs-c*Bs+2048>>12,c=d,g[0+e]=s+u,g[7+e]=s-u,g[1+e]=a+c,g[6+e]=a-c,g[2+e]=o+f,g[5+e]=o-f,g[3+e]=l+h,g[4+e]=l-h):(d=Ks*g[0+e]+512>>10,g[0+e]=d,g[1+e]=d,g[2+e]=d,g[3+e]=d,g[4+e]=d,g[5+e]=d,g[6+e]=d,g[7+e]=d)}for(m=0;m<8;++m){const e=m;0!==g[8+e]||0!==g[16+e]||0!==g[24+e]||0!==g[32+e]||0!==g[40+e]||0!==g[48+e]||0!==g[56+e]?(s=Ks*g[0+e]+2048>>12,a=Ks*g[32+e]+2048>>12,o=g[16+e],l=g[48+e],h=js*(g[8+e]-g[56+e])+2048>>12,u=js*(g[8+e]+g[56+e])+2048>>12,f=g[24+e],c=g[40+e],d=s-a+1>>1,s=s+a+1>>1,a=d,d=o*Ns+l*Vs+2048>>12,o=o*Vs-l*Ns+2048>>12,l=d,d=h-c+1>>1,h=h+c+1>>1,c=d,d=u+f+1>>1,f=u-f+1>>1,u=d,d=s-l+1>>1,s=s+l+1>>1,l=d,d=a-o+1>>1,a=a+o+1>>1,o=d,d=h*Fs+u*Rs+2048>>12,h=h*Rs-u*Fs+2048>>12,u=d,d=f*Bs+c*Gs+2048>>12,f=f*Gs-c*Bs+2048>>12,c=d,g[0+e]=s+u,g[56+e]=s-u,g[8+e]=a+c,g[48+e]=a-c,g[16+e]=o+f,g[40+e]=o-f,g[24+e]=l+h,g[32+e]=l-h):(d=Ks*r[m+0]+8192>>14,g[0+e]=d,g[8+e]=d,g[16+e]=d,g[24+e]=d,g[32+e]=d,g[40+e]=d,g[48+e]=d,g[56+e]=d)}for(m=0;m<64;++m){const e=128+(g[m]+8>>4);i[m]=e<0?0:e>255?255:e}}for(let e=0;e<n;e++){const n=e<<3;for(let e=0;e<8;e++)i.push(new Uint8Array(s));for(let s=0;s<r;s++){l(t.blocks[e][s],o,a);let r=0;const h=s<<3;for(let e=0;e<8;e++){const t=i[n+e];for(let e=0;e<8;e++)t[h+e]=o[r++]}}}return i}class Ws{constructor(){this.jfif=null,this.adobe=null,this.quantizationTables=[],this.huffmanTablesAC=[],this.huffmanTablesDC=[],this.resetFrames()}resetFrames(){this.frames=[]}parse(e){let t=0;function i(){const i=e[t]<<8|e[t+1];return t+=2,i}function r(){const r=i(),n=e.subarray(t,t+r-2);return t+=n.length,n}function n(e){let t,i,r=0,n=0;for(i in e.components)e.components.hasOwnProperty(i)&&(t=e.components[i],r<t.h&&(r=t.h),n<t.v&&(n=t.v));const s=Math.ceil(e.samplesPerLine/8/r),a=Math.ceil(e.scanLines/8/n);for(i in e.components)if(e.components.hasOwnProperty(i)){t=e.components[i];const o=Math.ceil(Math.ceil(e.samplesPerLine/8)*t.h/r),l=Math.ceil(Math.ceil(e.scanLines/8)*t.v/n),h=s*t.h,f=a*t.v,c=[];for(let e=0;e<f;e++){const e=[];for(let t=0;t<h;t++)e.push(new Int32Array(64));c.push(e)}t.blocksPerLine=o,t.blocksPerColumn=l,t.blocks=c}e.maxH=r,e.maxV=n,e.mcusPerLine=s,e.mcusPerColumn=a}let s=i();if(65496!==s)throw new Error("SOI not found");for(s=i();65497!==s;){switch(s){case 65280:break;case 65504:case 65505:case 65506:case 65507:case 65508:case 65509:case 65510:case 65511:case 65512:case 65513:case 65514:case 65515:case 65516:case 65517:case 65518:case 65519:case 65534:{const e=r();65504===s&&74===e[0]&&70===e[1]&&73===e[2]&&70===e[3]&&0===e[4]&&(this.jfif={version:{major:e[5],minor:e[6]},densityUnits:e[7],xDensity:e[8]<<8|e[9],yDensity:e[10]<<8|e[11],thumbWidth:e[12],thumbHeight:e[13],thumbData:e.subarray(14,14+3*e[12]*e[13])}),65518===s&&65===e[0]&&100===e[1]&&111===e[2]&&98===e[3]&&101===e[4]&&0===e[5]&&(this.adobe={version:e[6],flags0:e[7]<<8|e[8],flags1:e[9]<<8|e[10],transformCode:e[11]});break}case 65499:{const r=i()+t-2;for(;t<r;){const r=e[t++],n=new Int32Array(64);if(r>>4==0)for(let i=0;i<64;i++){n[zs[i]]=e[t++]}else{if(r>>4!=1)throw new Error("DQT: invalid table spec");for(let e=0;e<64;e++){n[zs[e]]=i()}}this.quantizationTables[15&r]=n}break}case 65472:case 65473:case 65474:{i();const r={extended:65473===s,progressive:65474===s,precision:e[t++],scanLines:i(),samplesPerLine:i(),components:{},componentsOrder:[]},a=e[t++];let o;for(let i=0;i<a;i++){o=e[t];const i=e[t+1]>>4,n=15&e[t+1],s=e[t+2];r.componentsOrder.push(o),r.components[o]={h:i,v:n,quantizationIdx:s},t+=3}n(r),this.frames.push(r);break}case 65476:{const r=i();for(let i=2;i<r;){const r=e[t++],n=new Uint8Array(16);let s=0;for(let i=0;i<16;i++,t++)n[i]=e[t],s+=n[i];const a=new Uint8Array(s);for(let i=0;i<s;i++,t++)a[i]=e[t];i+=17+s,r>>4==0?this.huffmanTablesDC[15&r]=Zs(n,a):this.huffmanTablesAC[15&r]=Zs(n,a)}break}case 65501:i(),this.resetInterval=i();break;case 65498:{i();const r=e[t++],n=[],s=this.frames[0];for(let i=0;i<r;i++){const i=s.components[e[t++]],r=e[t++];i.huffmanTableDC=this.huffmanTablesDC[r>>4],i.huffmanTableAC=this.huffmanTablesAC[15&r],n.push(i)}const a=e[t++],o=e[t++],l=e[t++],h=Hs(e,t,s,n,this.resetInterval,a,o,l>>4,15&l);t+=h;break}case 65535:255!==e[t]&&t--;break;default:if(255===e[t-3]&&e[t-2]>=192&&e[t-2]<=254){t-=3;break}throw new Error(`unknown JPEG marker ${s.toString(16)}`)}s=i()}}getResult(){const{frames:e}=this;if(0===this.frames.length)throw new Error("no frames were decoded");this.frames.length>1&&console.warn("more than one frame is not supported");for(let e=0;e<this.frames.length;e++){const t=this.frames[e].components;for(const e of Object.keys(t))t[e].quantizationTable=this.quantizationTables[t[e].quantizationIdx],delete t[e].quantizationIdx}const t=e[0],{components:i,componentsOrder:r}=t,n=[],s=t.samplesPerLine,a=t.scanLines;for(let e=0;e<r.length;e++){const s=i[r[e]];n.push({lines:Ys(0,s),scaleX:s.h/t.maxH,scaleY:s.v/t.maxV})}const o=new Uint8Array(s*a*n.length);let l=0;for(let e=0;e<a;++e)for(let t=0;t<s;++t)for(let i=0;i<n.length;++i){const r=n[i];o[l]=r.lines[0|e*r.scaleY][0|t*r.scaleX],++l}return o}}var Xs=Object.freeze({__proto__:null,default:class extends ms{constructor(e){super(),this.reader=new Ws,e.JPEGTables&&this.reader.parse(e.JPEGTables)}decodeBlock(e){return this.reader.resetFrames(),this.reader.parse(new Uint8Array(e)),this.reader.getResult().buffer}}});var $s=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){return Ji(new Uint8Array(e)).buffer}}});var qs=Object.freeze({__proto__:null,default:class extends ms{decodeBlock(e){const t=new DataView(e),i=[];for(let r=0;r<e.byteLength;++r){let e=t.getInt8(r);if(e<0){const n=t.getUint8(r+1);e=-e;for(let t=0;t<=e;++t)i.push(n);r+=1}else{for(let n=0;n<=e;++n)i.push(t.getUint8(r+n+1));r+=e+1}}return new Uint8Array(i).buffer}}}),Js={exports:{}};!function(e){
|
|
4
4
|
/* Copyright 2015-2021 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */
|
|
5
5
|
!function(){var t,i,r,n,s,a,o,l,h,f,c,u,d,g,m,p,w=(t={defaultNoDataValue:-34027999387901484e22,decode:function(e,a){var o=(a=a||{}).encodedMaskData||null===a.encodedMaskData,l=s(e,a.inputOffset||0,o),h=null!==a.noDataValue?a.noDataValue:t.defaultNoDataValue,f=i(l,a.pixelType||Float32Array,a.encodedMaskData,h,a.returnMask),c={width:l.width,height:l.height,pixelData:f.resultPixels,minValue:f.minValue,maxValue:l.pixels.maxValue,noDataValue:h};return f.resultMask&&(c.maskData=f.resultMask),a.returnEncodedMask&&l.mask&&(c.encodedMaskData=l.mask.bitset?l.mask.bitset:null),a.returnFileInfo&&(c.fileInfo=r(l),a.computeUsedBitDepths&&(c.fileInfo.bitDepths=n(l))),c}},i=function(e,t,i,r,n){var s,o,l,h=0,f=e.pixels.numBlocksX,c=e.pixels.numBlocksY,u=Math.floor(e.width/f),d=Math.floor(e.height/c),g=2*e.maxZError,m=Number.MAX_VALUE;i=i||(e.mask?e.mask.bitset:null),o=new t(e.width*e.height),n&&i&&(l=new Uint8Array(e.width*e.height));for(var p,w,y=new Float32Array(u*d),_=0;_<=c;_++){var b=_!==c?d:e.height%c;if(0!==b)for(var v=0;v<=f;v++){var k=v!==f?u:e.width%f;if(0!==k){var x,T,A,S,I=_*e.width*d+v*u,U=e.width-k,C=e.pixels.blocks[h];if(C.encoding<2?(0===C.encoding?x=C.rawData:(a(C.stuffedData,C.bitsPerPixel,C.numValidPixels,C.offset,g,y,e.pixels.maxValue),x=y),T=0):A=2===C.encoding?0:C.offset,i)for(w=0;w<b;w++){for(7&I&&(S=i[I>>3],S<<=7&I),p=0;p<k;p++)7&I||(S=i[I>>3]),128&S?(l&&(l[I]=1),m=m>(s=C.encoding<2?x[T++]:A)?s:m,o[I++]=s):(l&&(l[I]=0),o[I++]=r),S<<=1;I+=U}else if(C.encoding<2)for(w=0;w<b;w++){for(p=0;p<k;p++)m=m>(s=x[T++])?s:m,o[I++]=s;I+=U}else for(m=m>A?A:m,w=0;w<b;w++){for(p=0;p<k;p++)o[I++]=A;I+=U}if(1===C.encoding&&T!==C.numValidPixels)throw"Block and Mask do not match";h++}}}return{resultPixels:o,resultMask:l,minValue:m}},r=function(e){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,noDataValue:e.noDataValue}}},n=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},r=0;r<t;r++){var n=e.pixels.blocks[r];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},s=function(e,t,i){var r={},n=new Uint8Array(e,t,10);if(r.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!==r.fileIdentifierString.trim())throw"Unexpected file identifier string: "+r.fileIdentifierString;t+=10;var s=new DataView(e,t,24);if(r.fileVersion=s.getInt32(0,!0),r.imageType=s.getInt32(4,!0),r.height=s.getUint32(8,!0),r.width=s.getUint32(12,!0),r.maxZError=s.getFloat64(16,!0),t+=24,!i)if(s=new DataView(e,t,16),r.mask={},r.mask.numBlocksY=s.getUint32(0,!0),r.mask.numBlocksX=s.getUint32(4,!0),r.mask.numBytes=s.getUint32(8,!0),r.mask.maxValue=s.getFloat32(12,!0),t+=16,r.mask.numBytes>0){var a=new Uint8Array(Math.ceil(r.width*r.height/8)),o=(s=new DataView(e,t,r.mask.numBytes)).getInt16(0,!0),l=2,h=0;do{if(o>0)for(;o--;)a[h++]=s.getUint8(l++);else{var f=s.getUint8(l++);for(o=-o;o--;)a[h++]=f}o=s.getInt16(l,!0),l+=2}while(l<r.mask.numBytes);if(-32768!==o||h<a.length)throw"Unexpected end of mask RLE encoding";r.mask.bitset=a,t+=r.mask.numBytes}else 0==(r.mask.numBytes|r.mask.numBlocksY|r.mask.maxValue)&&(r.mask.bitset=new Uint8Array(Math.ceil(r.width*r.height/8)));s=new DataView(e,t,16),r.pixels={},r.pixels.numBlocksY=s.getUint32(0,!0),r.pixels.numBlocksX=s.getUint32(4,!0),r.pixels.numBytes=s.getUint32(8,!0),r.pixels.maxValue=s.getFloat32(12,!0),t+=16;var c=r.pixels.numBlocksX,u=r.pixels.numBlocksY,d=c+(r.width%c>0?1:0),g=u+(r.height%u>0?1:0);r.pixels.blocks=new Array(d*g);for(var m=0,p=0;p<g;p++)for(var w=0;w<d;w++){var y=0,_=e.byteLength-t;s=new DataView(e,t,Math.min(10,_));var b={};r.pixels.blocks[m++]=b;var v=s.getUint8(0);if(y++,b.encoding=63&v,b.encoding>3)throw"Invalid block encoding ("+b.encoding+")";if(2!==b.encoding){if(0!==v&&2!==v){if(v>>=6,b.offsetType=v,2===v)b.offset=s.getInt8(1),y++;else if(1===v)b.offset=s.getInt16(1,!0),y+=2;else{if(0!==v)throw"Invalid block offset type";b.offset=s.getFloat32(1,!0),y+=4}if(1===b.encoding)if(v=s.getUint8(y),y++,b.bitsPerPixel=63&v,v>>=6,b.numValidPixelsType=v,2===v)b.numValidPixels=s.getUint8(y),y++;else if(1===v)b.numValidPixels=s.getUint16(y,!0),y+=2;else{if(0!==v)throw"Invalid valid pixel count type";b.numValidPixels=s.getUint32(y,!0),y+=4}}var k;if(t+=y,3!==b.encoding)if(0===b.encoding){var x=(r.pixels.numBytes-1)/4;if(x!==Math.floor(x))throw"uncompressed block has invalid length";k=new ArrayBuffer(4*x),new Uint8Array(k).set(new Uint8Array(e,t,4*x));var T=new Float32Array(k);b.rawData=T,t+=4*x}else if(1===b.encoding){var A=Math.ceil(b.numValidPixels*b.bitsPerPixel/8),S=Math.ceil(A/4);k=new ArrayBuffer(4*S),new Uint8Array(k).set(new Uint8Array(e,t,A)),b.stuffedData=new Uint32Array(k),t+=A}}else t++}return r.eofOffset=t,r},a=function(e,t,i,r,n,s,a){var o,l,h,f=(1<<t)-1,c=0,u=0,d=Math.ceil((a-r)/n),g=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*g,o=0;o<i;o++){if(0===u&&(h=e[c++],u=32),u>=t)l=h>>>u-t&f,u-=t;else{var m=t-u;l=(h&f)<<m&f,l+=(h=e[c++])>>>(u=32-m)}s[o]=l<d?r+l*n:a}return s},t),y=(o=function(e,t,i,r,n,s,a,o){var l,h,f,c,u,d=(1<<i)-1,g=0,m=0,p=4*e.length-Math.ceil(i*r/8);if(e[e.length-1]<<=8*p,n)for(l=0;l<r;l++)0===m&&(f=e[g++],m=32),m>=i?(h=f>>>m-i&d,m-=i):(h=(f&d)<<(c=i-m)&d,h+=(f=e[g++])>>>(m=32-c)),t[l]=n[h];else for(u=Math.ceil((o-s)/a),l=0;l<r;l++)0===m&&(f=e[g++],m=32),m>=i?(h=f>>>m-i&d,m-=i):(h=(f&d)<<(c=i-m)&d,h+=(f=e[g++])>>>(m=32-c)),t[l]=h<u?s+h*a:o},l=function(e,t,i,r,n,s){var a,o=(1<<t)-1,l=0,h=0,f=0,c=0,u=0,d=[],g=4*e.length-Math.ceil(t*i/8);e[e.length-1]<<=8*g;var m=Math.ceil((s-r)/n);for(h=0;h<i;h++)0===c&&(a=e[l++],c=32),c>=t?(u=a>>>c-t&o,c-=t):(u=(a&o)<<(f=t-c)&o,u+=(a=e[l++])>>>(c=32-f)),d[h]=u<m?r+u*n:s;return d.unshift(r),d},h=function(e,t,i,r,n,s,a,o){var l,h,f,c,u=(1<<i)-1,d=0,g=0,m=0;if(n)for(l=0;l<r;l++)0===g&&(f=e[d++],g=32,m=0),g>=i?(h=f>>>m&u,g-=i,m+=i):(h=f>>>m&u,g=32-(c=i-g),h|=((f=e[d++])&(1<<c)-1)<<i-c,m=c),t[l]=n[h];else{var p=Math.ceil((o-s)/a);for(l=0;l<r;l++)0===g&&(f=e[d++],g=32,m=0),g>=i?(h=f>>>m&u,g-=i,m+=i):(h=f>>>m&u,g=32-(c=i-g),h|=((f=e[d++])&(1<<c)-1)<<i-c,m=c),t[l]=h<p?s+h*a:o}return t},f=function(e,t,i,r,n,s){var a,o=(1<<t)-1,l=0,h=0,f=0,c=0,u=0,d=0,g=[],m=Math.ceil((s-r)/n);for(h=0;h<i;h++)0===c&&(a=e[l++],c=32,d=0),c>=t?(u=a>>>d&o,c-=t,d+=t):(u=a>>>d&o,c=32-(f=t-c),u|=((a=e[l++])&(1<<f)-1)<<t-f,d=f),g[h]=u<m?r+u*n:s;return g.unshift(r),g},c=function(e,t,i,r){var n,s,a,o,l=(1<<i)-1,h=0,f=0,c=4*e.length-Math.ceil(i*r/8);for(e[e.length-1]<<=8*c,n=0;n<r;n++)0===f&&(a=e[h++],f=32),f>=i?(s=a>>>f-i&l,f-=i):(s=(a&l)<<(o=i-f)&l,s+=(a=e[h++])>>>(f=32-o)),t[n]=s;return t},u=function(e,t,i,r){var n,s,a,o,l=(1<<i)-1,h=0,f=0,c=0;for(n=0;n<r;n++)0===f&&(a=e[h++],f=32,c=0),f>=i?(s=a>>>c&l,f-=i,c+=i):(s=a>>>c&l,f=32-(o=i-f),s|=((a=e[h++])&(1<<o)-1)<<i-o,c=o),t[n]=s;return t},d={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,i=65535,r=e.length,n=Math.floor(r/2),s=0;n;){var a=n>=359?359:n;n-=a;do{t+=e[s++]<<8,i+=t+=e[s++]}while(--a);t=(65535&t)+(t>>>16),i=(65535&i)+(i>>>16)}return 1&r&&(i+=t+=e[s]<<8),((i=(65535&i)+(i>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var i=t.ptr,r=new Uint8Array(e,i,6),n={};if(n.fileIdentifierString=String.fromCharCode.apply(null,r),0!==n.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+n.fileIdentifierString;i+=6;var s,a=new DataView(e,i,8),o=a.getInt32(0,!0);if(n.fileVersion=o,i+=4,o>=3&&(n.checksum=a.getUint32(4,!0),i+=4),a=new DataView(e,i,12),n.height=a.getUint32(0,!0),n.width=a.getUint32(4,!0),i+=8,o>=4?(n.numDims=a.getUint32(8,!0),i+=4):n.numDims=1,a=new DataView(e,i,40),n.numValidPixel=a.getUint32(0,!0),n.microBlockSize=a.getInt32(4,!0),n.blobSize=a.getInt32(8,!0),n.imageType=a.getInt32(12,!0),n.maxZError=a.getFloat64(16,!0),n.zMin=a.getFloat64(24,!0),n.zMax=a.getFloat64(32,!0),i+=40,t.headerInfo=n,t.ptr=i,o>=3&&(s=o>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,i-s,n.blobSize-14))!==n.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var i=t.headerInfo,r=this.getDataTypeArray(i.imageType),n=i.numDims*this.getDataTypeSize(i.imageType),s=this.readSubArray(e,t.ptr,r,n),a=this.readSubArray(e,t.ptr+n,r,n);t.ptr+=2*n;var o,l=!0;for(o=0;o<i.numDims;o++)if(s[o]!==a[o]){l=!1;break}return i.minValues=s,i.maxValues=a,l},readSubArray:function(e,t,i,r){var n;if(i===Uint8Array)n=new Uint8Array(e,t,r);else{var s=new ArrayBuffer(r);new Uint8Array(s).set(new Uint8Array(e,t,r)),n=new i(s)}return n},readMask:function(e,t){var i,r,n=t.ptr,s=t.headerInfo,a=s.width*s.height,o=s.numValidPixel,l=new DataView(e,n,4),h={};if(h.numBytes=l.getUint32(0,!0),n+=4,(0===o||a===o)&&0!==h.numBytes)throw"invalid mask";if(0===o)i=new Uint8Array(Math.ceil(a/8)),h.bitset=i,r=new Uint8Array(a),t.pixels.resultMask=r,n+=h.numBytes;else if(h.numBytes>0){i=new Uint8Array(Math.ceil(a/8));var f=(l=new DataView(e,n,h.numBytes)).getInt16(0,!0),c=2,u=0,d=0;do{if(f>0)for(;f--;)i[u++]=l.getUint8(c++);else for(d=l.getUint8(c++),f=-f;f--;)i[u++]=d;f=l.getInt16(c,!0),c+=2}while(c<h.numBytes);if(-32768!==f||u<i.length)throw"Unexpected end of mask RLE encoding";r=new Uint8Array(a);var g=0,m=0;for(m=0;m<a;m++)7&m?(g=i[m>>3],g<<=7&m):g=i[m>>3],128&g&&(r[m]=1);t.pixels.resultMask=r,h.bitset=i,n+=h.numBytes}return t.ptr=n,t.mask=h,!0},readDataOneSweep:function(e,t,i,r){var n,s=t.ptr,a=t.headerInfo,o=a.numDims,l=a.width*a.height,h=a.imageType,f=a.numValidPixel*d.getDataTypeSize(h)*o,c=t.pixels.resultMask;if(i===Uint8Array)n=new Uint8Array(e,s,f);else{var u=new ArrayBuffer(f);new Uint8Array(u).set(new Uint8Array(e,s,f)),n=new i(u)}if(n.length===l*o)t.pixels.resultPixels=r?d.swapDimensionOrder(n,l,o,i,!0):n;else{t.pixels.resultPixels=new i(l*o);var g=0,m=0,p=0,w=0;if(o>1){if(r){for(m=0;m<l;m++)if(c[m])for(w=m,p=0;p<o;p++,w+=l)t.pixels.resultPixels[w]=n[g++]}else for(m=0;m<l;m++)if(c[m])for(w=m*o,p=0;p<o;p++)t.pixels.resultPixels[w+p]=n[g++]}else for(m=0;m<l;m++)c[m]&&(t.pixels.resultPixels[m]=n[g++])}return s+=f,t.ptr=s,!0},readHuffmanTree:function(e,t){var i=this.HUFFMAN_LUT_BITS_MAX,r=new DataView(e,t.ptr,16);if(t.ptr+=16,r.getInt32(0,!0)<2)throw"unsupported Huffman version";var n=r.getInt32(4,!0),s=r.getInt32(8,!0),a=r.getInt32(12,!0);if(s>=a)return!1;var o=new Uint32Array(a-s);d.decodeBits(e,t,o);var l,h,f,c,u=[];for(l=s;l<a;l++)u[h=l-(l<n?0:n)]={first:o[l-s],second:null};var m=e.byteLength-t.ptr,p=Math.ceil(m/4),w=new ArrayBuffer(4*p);new Uint8Array(w).set(new Uint8Array(e,t.ptr,m));var y,_=new Uint32Array(w),b=0,v=0;for(y=_[0],l=s;l<a;l++)(c=u[h=l-(l<n?0:n)].first)>0&&(u[h].second=y<<b>>>32-c,32-b>=c?32===(b+=c)&&(b=0,y=_[++v]):(b+=c-32,y=_[++v],u[h].second|=y>>>32-b));var k=0,x=0,T=new g;for(l=0;l<u.length;l++)void 0!==u[l]&&(k=Math.max(k,u[l].first));x=k>=i?i:k;var A,S,I,U,C,D=[];for(l=s;l<a;l++)if((c=u[h=l-(l<n?0:n)].first)>0)if(A=[c,h],c<=x)for(S=u[h].second<<x-c,I=1<<x-c,f=0;f<I;f++)D[S|f]=A;else for(S=u[h].second,C=T,U=c-1;U>=0;U--)S>>>U&1?(C.right||(C.right=new g),C=C.right):(C.left||(C.left=new g),C=C.left),0!==U||C.val||(C.val=A[1]);return{decodeLut:D,numBitsLUTQick:x,numBitsLUT:k,tree:T,stuffedData:_,srcPtr:v,bitPos:b}},readHuffman:function(e,t,i,r){var n,s,a,o,l,h,f,c,u,g=t.headerInfo.numDims,m=t.headerInfo.height,p=t.headerInfo.width,w=p*m,y=this.readHuffmanTree(e,t),_=y.decodeLut,b=y.tree,v=y.stuffedData,k=y.srcPtr,x=y.bitPos,T=y.numBitsLUTQick,A=y.numBitsLUT,S=0===t.headerInfo.imageType?128:0,I=t.pixels.resultMask,U=0;x>0&&(k++,x=0);var C,D=v[k],E=1===t.encodeMode,P=new i(w*g),M=P;if(g<2||E){for(C=0;C<g;C++)if(g>1&&(M=new i(P.buffer,w*C,w),U=0),t.headerInfo.numValidPixel===p*m)for(c=0,h=0;h<m;h++)for(f=0;f<p;f++,c++){if(s=0,l=o=D<<x>>>32-T,32-x<T&&(l=o|=v[k+1]>>>64-x-T),_[l])s=_[l][1],x+=_[l][0];else for(l=o=D<<x>>>32-A,32-x<A&&(l=o|=v[k+1]>>>64-x-A),n=b,u=0;u<A;u++)if(!(n=o>>>A-u-1&1?n.right:n.left).left&&!n.right){s=n.val,x=x+u+1;break}x>=32&&(x-=32,D=v[++k]),a=s-S,E?(a+=f>0?U:h>0?M[c-p]:U,a&=255,M[c]=a,U=a):M[c]=a}else for(c=0,h=0;h<m;h++)for(f=0;f<p;f++,c++)if(I[c]){if(s=0,l=o=D<<x>>>32-T,32-x<T&&(l=o|=v[k+1]>>>64-x-T),_[l])s=_[l][1],x+=_[l][0];else for(l=o=D<<x>>>32-A,32-x<A&&(l=o|=v[k+1]>>>64-x-A),n=b,u=0;u<A;u++)if(!(n=o>>>A-u-1&1?n.right:n.left).left&&!n.right){s=n.val,x=x+u+1;break}x>=32&&(x-=32,D=v[++k]),a=s-S,E?(f>0&&I[c-1]?a+=U:h>0&&I[c-p]?a+=M[c-p]:a+=U,a&=255,M[c]=a,U=a):M[c]=a}}else for(c=0,h=0;h<m;h++)for(f=0;f<p;f++)if(c=h*p+f,!I||I[c])for(C=0;C<g;C++,c+=w){if(s=0,l=o=D<<x>>>32-T,32-x<T&&(l=o|=v[k+1]>>>64-x-T),_[l])s=_[l][1],x+=_[l][0];else for(l=o=D<<x>>>32-A,32-x<A&&(l=o|=v[k+1]>>>64-x-A),n=b,u=0;u<A;u++)if(!(n=o>>>A-u-1&1?n.right:n.left).left&&!n.right){s=n.val,x=x+u+1;break}x>=32&&(x-=32,D=v[++k]),a=s-S,M[c]=a}t.ptr=t.ptr+4*(k+1)+(x>0?4:0),t.pixels.resultPixels=P,g>1&&!r&&(t.pixels.resultPixels=d.swapDimensionOrder(P,w,g,i))},decodeBits:function(e,t,i,r,n){var s=t.headerInfo,a=s.fileVersion,d=0,g=e.byteLength-t.ptr>=5?5:e.byteLength-t.ptr,m=new DataView(e,t.ptr,g),p=m.getUint8(0);d++;var w=p>>6,y=0===w?4:3-w,_=(32&p)>0,b=31&p,v=0;if(1===y)v=m.getUint8(d),d++;else if(2===y)v=m.getUint16(d,!0),d+=2;else{if(4!==y)throw"Invalid valid pixel count type";v=m.getUint32(d,!0),d+=4}var k,x,T,A,S,I,U,C,D,E=2*s.maxZError,P=s.numDims>1?s.maxValues[n]:s.zMax;if(_){for(t.counter.lut++,C=m.getUint8(d),d++,A=Math.ceil((C-1)*b/8),S=Math.ceil(A/4),x=new ArrayBuffer(4*S),T=new Uint8Array(x),t.ptr+=d,T.set(new Uint8Array(e,t.ptr,A)),U=new Uint32Array(x),t.ptr+=A,D=0;C-1>>>D;)D++;A=Math.ceil(v*D/8),S=Math.ceil(A/4),x=new ArrayBuffer(4*S),(T=new Uint8Array(x)).set(new Uint8Array(e,t.ptr,A)),k=new Uint32Array(x),t.ptr+=A,I=a>=3?f(U,b,C-1,r,E,P):l(U,b,C-1,r,E,P),a>=3?h(k,i,D,v,I):o(k,i,D,v,I)}else t.counter.bitstuffer++,D=b,t.ptr+=d,D>0&&(A=Math.ceil(v*D/8),S=Math.ceil(A/4),x=new ArrayBuffer(4*S),(T=new Uint8Array(x)).set(new Uint8Array(e,t.ptr,A)),k=new Uint32Array(x),t.ptr+=A,a>=3?null==r?u(k,i,D,v):h(k,i,D,v,!1,r,E,P):null==r?c(k,i,D,v):o(k,i,D,v,!1,r,E,P))},readTiles:function(e,t,i,r){var n=t.headerInfo,s=n.width,a=n.height,o=s*a,l=n.microBlockSize,h=n.imageType,f=d.getDataTypeSize(h),c=Math.ceil(s/l),u=Math.ceil(a/l);t.pixels.numBlocksY=u,t.pixels.numBlocksX=c,t.pixels.ptr=0;var g,m,p,w,y,_,b,v,k,x,T=0,A=0,S=0,I=0,U=0,C=0,D=0,E=0,P=0,M=0,O=0,L=0,z=0,G=0,B=0,R=new i(l*l),F=a%l||l,V=s%l||l,N=n.numDims,K=t.pixels.resultMask,j=t.pixels.resultPixels,Z=n.fileVersion>=5?14:15,H=n.zMax;for(S=0;S<u;S++)for(U=S!==u-1?l:F,I=0;I<c;I++)for(M=S*s*l+I*l,O=s-(C=I!==c-1?l:V),v=0;v<N;v++){if(N>1?(x=j,M=S*s*l+I*l,j=new i(t.pixels.resultPixels.buffer,o*v*f,o),H=n.maxValues[v]):x=null,D=e.byteLength-t.ptr,m={},B=0,E=(g=new DataView(e,t.ptr,Math.min(10,D))).getUint8(0),B++,k=n.fileVersion>=5?4&E:0,P=E>>6&255,(E>>2&Z)!=(I*l>>3&Z))throw"integrity issue";if(k&&0===v)throw"integrity issue";if((y=3&E)>3)throw t.ptr+=B,"Invalid block encoding ("+y+")";if(2!==y)if(0===y){if(k)throw"integrity issue";if(t.counter.uncompressed++,t.ptr+=B,L=(L=U*C*f)<(z=e.byteLength-t.ptr)?L:z,p=new ArrayBuffer(L%f==0?L:L+f-L%f),new Uint8Array(p).set(new Uint8Array(e,t.ptr,L)),w=new i(p),G=0,K)for(T=0;T<U;T++){for(A=0;A<C;A++)K[M]&&(j[M]=w[G++]),M++;M+=O}else for(T=0;T<U;T++){for(A=0;A<C;A++)j[M++]=w[G++];M+=O}t.ptr+=G*f}else if(_=d.getDataTypeUsed(k&&h<6?4:h,P),b=d.getOnePixel(m,B,_,g),B+=d.getDataTypeSize(_),3===y)if(t.ptr+=B,t.counter.constantoffset++,K)for(T=0;T<U;T++){for(A=0;A<C;A++)K[M]&&(j[M]=k?Math.min(H,x[M]+b):b),M++;M+=O}else for(T=0;T<U;T++){for(A=0;A<C;A++)j[M]=k?Math.min(H,x[M]+b):b,M++;M+=O}else if(t.ptr+=B,d.decodeBits(e,t,R,b,v),B=0,k)if(K)for(T=0;T<U;T++){for(A=0;A<C;A++)K[M]&&(j[M]=R[B++]+x[M]),M++;M+=O}else for(T=0;T<U;T++){for(A=0;A<C;A++)j[M]=R[B++]+x[M],M++;M+=O}else if(K)for(T=0;T<U;T++){for(A=0;A<C;A++)K[M]&&(j[M]=R[B++]),M++;M+=O}else for(T=0;T<U;T++){for(A=0;A<C;A++)j[M++]=R[B++];M+=O}else{if(k)if(K)for(T=0;T<U;T++)for(A=0;A<C;A++)K[M]&&(j[M]=x[M]),M++;else for(T=0;T<U;T++)for(A=0;A<C;A++)j[M]=x[M],M++;t.counter.constant++,t.ptr+=B}}N>1&&!r&&(t.pixels.resultPixels=d.swapDimensionOrder(t.pixels.resultPixels,o,N,i))},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:d.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e,t){var i=e.headerInfo.zMax,r=e.headerInfo.zMin,n=e.headerInfo.maxValues,s=e.headerInfo.numDims,a=e.headerInfo.height*e.headerInfo.width,o=0,l=0,h=0,f=e.pixels.resultMask,c=e.pixels.resultPixels;if(f)if(s>1){if(t)for(o=0;o<s;o++)for(h=o*a,i=n[o],l=0;l<a;l++)f[l]&&(c[h+l]=i);else for(l=0;l<a;l++)if(f[l])for(h=l*s,o=0;o<s;o++)c[h+s]=n[o]}else for(l=0;l<a;l++)f[l]&&(c[l]=i);else if(s>1&&r!==i)if(t)for(o=0;o<s;o++)for(h=o*a,i=n[o],l=0;l<a;l++)c[h+l]=i;else for(l=0;l<a;l++)for(h=l*s,o=0;o<s;o++)c[h+o]=n[o];else for(l=0;l<a*s;l++)c[l]=i},getDataTypeArray:function(e){var t;switch(e){case 0:t=Int8Array;break;case 1:t=Uint8Array;break;case 2:t=Int16Array;break;case 3:t=Uint16Array;break;case 4:t=Int32Array;break;case 5:t=Uint32Array;break;case 6:default:t=Float32Array;break;case 7:t=Float64Array}return t},getPixelType:function(e){var t;switch(e){case 0:t="S8";break;case 1:t="U8";break;case 2:t="S16";break;case 3:t="U16";break;case 4:t="S32";break;case 5:t="U32";break;case 6:default:t="F32";break;case 7:t="F64"}return t},isValidPixelValue:function(e,t){if(null==t)return!1;var i;switch(e){case 0:i=t>=-128&&t<=127;break;case 1:i=t>=0&&t<=255;break;case 2:i=t>=-32768&&t<=32767;break;case 3:i=t>=0&&t<=65536;break;case 4:i=t>=-2147483648&&t<=2147483647;break;case 5:i=t>=0&&t<=4294967296;break;case 6:i=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:i=t>=-17976931348623157e292&&t<=17976931348623157e292;break;default:i=!1}return i},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var i=e;switch(e){case 2:case 4:i=e-t;break;case 3:case 5:i=e-2*t;break;case 6:i=0===t?e:1===t?2:1;break;case 7:i=0===t?e:e-2*t+1;break;default:i=e}return i},getOnePixel:function(e,t,i,r){var n=0;switch(i){case 0:n=r.getInt8(t);break;case 1:n=r.getUint8(t);break;case 2:n=r.getInt16(t,!0);break;case 3:n=r.getUint16(t,!0);break;case 4:n=r.getInt32(t,!0);break;case 5:n=r.getUInt32(t,!0);break;case 6:n=r.getFloat32(t,!0);break;case 7:n=r.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return n},swapDimensionOrder:function(e,t,i,r,n){var s=0,a=0,o=0,l=0,h=e;if(i>1)if(h=new r(t*i),n)for(s=0;s<t;s++)for(l=s,o=0;o<i;o++,l+=t)h[l]=e[a++];else for(s=0;s<t;s++)for(l=s,o=0;o<i;o++,l+=t)h[a++]=e[l];return h}},g=function(e,t,i){this.val=e,this.left=t,this.right=i},{decode:function(e,t){var i=(t=t||{}).noDataValue,r=0,n={};if(n.ptr=t.inputOffset||0,n.pixels={},d.readHeaderInfo(e,n)){var s=n.headerInfo,a=s.fileVersion,o=d.getDataTypeArray(s.imageType);if(a>5)throw"unsupported lerc version 2."+a;d.readMask(e,n),s.numValidPixel===s.width*s.height||n.pixels.resultMask||(n.pixels.resultMask=t.maskData);var l=s.width*s.height;n.pixels.resultPixels=new o(l*s.numDims),n.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var h,f=!t.returnPixelInterleavedDims;if(0!==s.numValidPixel)if(s.zMax===s.zMin)d.constructConstantSurface(n,f);else if(a>=4&&d.checkMinMaxRanges(e,n))d.constructConstantSurface(n,f);else{var c=new DataView(e,n.ptr,2),u=c.getUint8(0);if(n.ptr++,u)d.readDataOneSweep(e,n,o,f);else if(a>1&&s.imageType<=1&&Math.abs(s.maxZError-.5)<1e-5){var g=c.getUint8(1);if(n.ptr++,n.encodeMode=g,g>2||a<4&&g>1)throw"Invalid Huffman flag "+g;g?d.readHuffman(e,n,o,f):d.readTiles(e,n,o,f)}else d.readTiles(e,n,o,f)}n.eofOffset=n.ptr,t.inputOffset?(h=n.headerInfo.blobSize+t.inputOffset-n.ptr,Math.abs(h)>=1&&(n.eofOffset=t.inputOffset+n.headerInfo.blobSize)):(h=n.headerInfo.blobSize-n.ptr,Math.abs(h)>=1&&(n.eofOffset=n.headerInfo.blobSize));var m={width:s.width,height:s.height,pixelData:n.pixels.resultPixels,minValue:s.zMin,maxValue:s.zMax,validPixelCount:s.numValidPixel,dimCount:s.numDims,dimStats:{minValues:s.minValues,maxValues:s.maxValues},maskData:n.pixels.resultMask};if(n.pixels.resultMask&&d.isValidPixelValue(s.imageType,i)){var p=n.pixels.resultMask;for(r=0;r<l;r++)p[r]||(m.pixelData[r]=i);m.noDataValue=i}return n.noDataValue=i,t.returnFileInfo&&(m.fileInfo=d.formatFileInfo(n)),m}},getBandCount:function(e){for(var t=0,i=0,r={ptr:0,pixels:{}};i<e.byteLength-58;)d.readHeaderInfo(e,r),i+=r.headerInfo.blobSize,t++,r.ptr=i;return t}}),_=(m=new ArrayBuffer(4),p=new Uint8Array(m),new Uint32Array(m)[0]=1,1===p[0]),b={decode:function(e,t){if(!_)throw"Big endian system is not supported.";var i,r,n=(t=t||{}).inputOffset||0,s=new Uint8Array(e,n,10),a=String.fromCharCode.apply(null,s);if("CntZImage"===a.trim())i=w,r=1;else{if("Lerc2"!==a.substring(0,5))throw"Unexpected file identifier string: "+a;i=y,r=2}for(var o,l,h,f,c,u,d=0,g=e.byteLength-10,m=[],p={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]},b=0;n<g;){var v=i.decode(e,{inputOffset:n,encodedMaskData:o,maskData:h,returnMask:0===d,returnEncodedMask:0===d,returnFileInfo:!0,returnPixelInterleavedDims:t.returnPixelInterleavedDims,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});n=v.fileInfo.eofOffset,h=v.maskData,0===d&&(o=v.encodedMaskData,p.width=v.width,p.height=v.height,p.dimCount=v.dimCount||1,p.pixelType=v.pixelType||v.fileInfo.pixelType,p.mask=h),r>1&&(h&&m.push(h),v.fileInfo.mask&&v.fileInfo.mask.numBytes>0&&b++),d++,p.pixels.push(v.pixelData),p.statistics.push({minValue:v.minValue,maxValue:v.maxValue,noDataValue:v.noDataValue,dimStats:v.dimStats})}if(r>1&&b>1){for(u=p.width*p.height,p.bandMasks=m,(h=new Uint8Array(u)).set(m[0]),f=1;f<m.length;f++)for(l=m[f],c=0;c<u;c++)h[c]=h[c]&l[c];p.maskData=h}return p}};e.exports?e.exports=b:this.Lerc=b}()}(Js);var Qs=u(Js.exports);var ea=Object.freeze({__proto__:null,default:class extends ms{constructor(e){super(),this.planarConfiguration=void 0!==e.PlanarConfiguration?e.PlanarConfiguration:1,this.samplesPerPixel=void 0!==e.SamplesPerPixel?e.SamplesPerPixel:1,this.addCompression=e.LercParameters[Xn]}decodeBlock(e){switch(this.addCompression){case $n:break;case qn:e=Ji(new Uint8Array(e)).buffer;break;default:throw new Error(`Unsupported LERC additional compression method identifier: ${this.addCompression}`)}return Qs.decode(e,{returnPixelInterleavedDims:1===this.planarConfiguration}).pixels[0].buffer}}});var ta=Object.freeze({__proto__:null,default:class extends ms{constructor(){if(super(),"undefined"==typeof createImageBitmap)throw new Error("Cannot decode WebImage as `createImageBitmap` is not available");if("undefined"==typeof document&&"undefined"==typeof OffscreenCanvas)throw new Error("Cannot decode WebImage as neither `document` nor `OffscreenCanvas` is not available")}async decode(e,t){const i=new Blob([t]),r=await createImageBitmap(i);let n;"undefined"!=typeof document?(n=document.createElement("canvas"),n.width=r.width,n.height=r.height):n=new OffscreenCanvas(r.width,r.height);const s=n.getContext("2d");return s.drawImage(r,0,0),s.getImageData(0,0,r.width,r.height).data.buffer}}});export{Ds as default};
|
|
6
6
|
//# sourceMappingURL=index.min.js.map
|