@nika-js/onlymap 0.6.26 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +2 -2
  3. package/dist/{LercDecode.es-B4KknLMs.js → LercDecode.es-gFG_4xNk.js} +1 -1
  4. package/dist/{basemap-C4bmWq6M.js → basemap-oVln_CKU.js} +1 -1
  5. package/dist/elements/om-map.d.ts +9 -1
  6. package/dist/{geoparquet-BPMda753.js → geoparquet-CufpN8G1.js} +1 -1
  7. package/dist/{index-DtU_XhTX.js → index--zvhxlLl.js} +2 -2
  8. package/dist/{index-B5hsHnPl.js → index-CLe7spTj.js} +1 -1
  9. package/dist/{index-COuIQk2Z.js → index-CnwhAoQ5.js} +11283 -11046
  10. package/dist/{index-DMT_7aV3.js → index-DEIMxmvY.js} +1 -1
  11. package/dist/{index-DK5w4OxN.js → index-EXrBWGX7.js} +1 -1
  12. package/dist/index.d.ts +1 -1
  13. package/dist/layer-registry.d.ts +10 -0
  14. package/dist/{lerc-BNW5A6zN.js → lerc-nHFgnN0N.js} +2 -2
  15. package/dist/onlymap.standalone.js +29352 -28617
  16. package/dist/onlymapjs.js +91 -89
  17. package/dist/{raster-eMqzBMQf.js → raster-CE4jsgUi.js} +1086 -799
  18. package/dist/raster-identify.d.ts +19 -0
  19. package/dist/{raster-pipeline-Dg-GSDP3.js → raster-pipeline-ghFqryqb.js} +665 -453
  20. package/dist/raster-pipeline.d.ts +109 -14
  21. package/dist/raster.d.ts +135 -1
  22. package/dist/react.js +253 -234
  23. package/dist/runtime-core.d.ts +23 -0
  24. package/dist/version.d.ts +1 -1
  25. package/dist/widget-layout.d.ts +18 -0
  26. package/dist/{zarr-Dv7OiUcg.js → zarr-DjEYckHG.js} +10 -3
  27. package/docs/design/cog-v2.md +223 -0
  28. package/llms.txt +2 -2
  29. package/onlymapjs.attributes.json +9 -0
  30. package/onlymapjs.html-data.json +24 -0
  31. package/package.json +1 -1
  32. package/skills/onlymapjs/SKILL.md +1 -1
  33. package/skills/onlymapjs/references/syntax.md +12 -7
@@ -1,39 +1,40 @@
1
- import { c as re, t as Ae, i as nt, a as Re, s as rt, C as ot, b as it, F as at, A as st, d as lt, R as he, e as ct, p as ut, m as dt, f as ht, g as pt, h as gt } from "./raster-pipeline-Dg-GSDP3.js";
2
- import pe from "./index-CW1n5LdO.js";
3
- function mt(e, t) {
1
+ import { c as se, t as ze, i as wt, a as Be, s as St, C as Pt, b as bt, F as Ct, A as Lt, d as It, R as fe, e as Gt, p as vt, m as Et, f as Ft, g as At, r as _e, h as jt, j as Rt, k as Ut, l as Mt, n as Ot } from "./raster-pipeline-ghFqryqb.js";
2
+ import { ax as Kt, ay as xt } from "./index-CnwhAoQ5.js";
3
+ import ye from "./index-CW1n5LdO.js";
4
+ function Dt(e, t) {
4
5
  const n = e.length / 3, r = new Uint8ClampedArray(n * 4), o = 0, i = n, a = n * 2;
5
6
  for (let s = 0; s < n; s++)
6
7
  r[4 * s + 0] = e[o + s] >> 8, r[4 * s + 1] = e[i + s] >> 8, r[4 * s + 2] = e[a + s] >> 8, r[4 * s + 3] = 255;
7
8
  return new ImageData(r, n, 1);
8
9
  }
9
- var q;
10
+ var ee;
10
11
  (function(e) {
11
12
  e[e.Big = 19789] = "Big", e[e.Little = 18761] = "Little";
12
- })(q || (q = {}));
13
+ })(ee || (ee = {}));
13
14
  var J;
14
15
  (function(e) {
15
16
  e[e.ReducedImage = 1] = "ReducedImage", e[e.Page = 2] = "Page", e[e.Mask = 4] = "Mask";
16
17
  })(J || (J = {}));
17
- var ge;
18
+ var we;
18
19
  (function(e) {
19
20
  e[e.TopLeft = 1] = "TopLeft", e[e.TopRight = 2] = "TopRight", e[e.BottomRight = 3] = "BottomRight", e[e.BottomLeft = 4] = "BottomLeft", e[e.LeftTop = 5] = "LeftTop", e[e.RightTOP = 6] = "RightTOP", e[e.RightBottom = 7] = "RightBottom", e[e.LeftBottom = 8] = "LeftBottom";
20
- })(ge || (ge = {}));
21
- var T;
21
+ })(we || (we = {}));
22
+ var te;
22
23
  (function(e) {
23
24
  e[e.PixelIsArea = 1] = "PixelIsArea", e[e.PixelIsPoint = 2] = "PixelIsPoint";
24
- })(T || (T = {}));
25
- var M;
25
+ })(te || (te = {}));
26
+ var O;
26
27
  (function(e) {
27
28
  e[e.Unknown = 0] = "Unknown", e[e.Projected = 1] = "Projected", e[e.Geographic = 2] = "Geographic", e[e.Geocentric = 3] = "Geocentric", e[e.UserDefined = 32767] = "UserDefined";
28
- })(M || (M = {}));
29
- var me;
29
+ })(O || (O = {}));
30
+ var Se;
30
31
  (function(e) {
31
32
  e[e.Image = 1] = "Image", e[e.ReducedImage = 2] = "ReducedImage", e[e.Page = 3] = "Page";
32
- })(me || (me = {}));
33
- var m;
33
+ })(Se || (Se = {}));
34
+ var f;
34
35
  (function(e) {
35
36
  e[e.None = 1] = "None", e[e.Ccittrle = 2] = "Ccittrle", e[e.CcittT4 = 3] = "CcittT4", e[e.CcittT6 = 4] = "CcittT6", e[e.Lzw = 5] = "Lzw", e[e.Jpeg6 = 6] = "Jpeg6", e[e.Jpeg = 7] = "Jpeg", e[e.DeflateOther = 8] = "DeflateOther", e[e.T85 = 9] = "T85", e[e.T43 = 10] = "T43", e[e.Next = 32766] = "Next", e[e.Ccittrlew = 32771] = "Ccittrlew", e[e.PackBits = 32773] = "PackBits", e[e.ThunderScan = 32809] = "ThunderScan", e[e.It8ctpad = 32895] = "It8ctpad", e[e.It8lw = 32896] = "It8lw", e[e.It8mp = 32897] = "It8mp", e[e.It8bl = 32898] = "It8bl", e[e.PixarFilm = 32908] = "PixarFilm", e[e.PixarLog = 32909] = "PixarLog", e[e.Deflate = 32946] = "Deflate", e[e.Dcs = 32947] = "Dcs", e[e.Jbig = 34661] = "Jbig", e[e.SgiLog = 34676] = "SgiLog", e[e.SgiLog24 = 34677] = "SgiLog24", e[e.Jp2000 = 34712] = "Jp2000", e[e.Lerc = 34887] = "Lerc", e[e.Lzma = 34925] = "Lzma", e[e.Zstd = 5e4] = "Zstd", e[e.Webp = 50001] = "Webp", e[e.JpegXl = 50002] = "JpegXl", e[e.JpegXlDng17 = 52546] = "JpegXlDng17";
36
- })(m || (m = {}));
37
+ })(f || (f = {}));
37
38
  var U;
38
39
  (function(e) {
39
40
  e[e.Contig = 1] = "Contig", e[e.Separate = 2] = "Separate";
@@ -42,227 +43,227 @@ var _;
42
43
  (function(e) {
43
44
  e[e.None = 1] = "None", e[e.Horizontal = 2] = "Horizontal", e[e.FloatingPoint = 3] = "FloatingPoint";
44
45
  })(_ || (_ = {}));
45
- var F;
46
+ var A;
46
47
  (function(e) {
47
48
  e[e.Uint = 1] = "Uint", e[e.Int = 2] = "Int", e[e.Float = 3] = "Float", e[e.Void = 4] = "Void", e[e.ComplexInt = 5] = "ComplexInt", e[e.ComplexFloat = 6] = "ComplexFloat";
48
- })(F || (F = {}));
49
- var E;
49
+ })(A || (A = {}));
50
+ var F;
50
51
  (function(e) {
51
52
  e[e.MinIsWhite = 0] = "MinIsWhite", e[e.MinIsBlack = 1] = "MinIsBlack", e[e.Rgb = 2] = "Rgb", e[e.Palette = 3] = "Palette", e[e.Mask = 4] = "Mask", e[e.Separated = 5] = "Separated", e[e.Ycbcr = 6] = "Ycbcr", e[e.Cielab = 8] = "Cielab", e[e.Icclab = 9] = "Icclab", e[e.Itulab = 10] = "Itulab", e[e.Cfa = 32803] = "Cfa", e[e.Logl = 32844] = "Logl", e[e.Logluv = 32845] = "Logluv";
52
- })(E || (E = {}));
53
- var u;
53
+ })(F || (F = {}));
54
+ var d;
54
55
  (function(e) {
55
56
  e[e.SubFileType = 254] = "SubFileType", e[e.OldSubFileType = 255] = "OldSubFileType", e[e.ImageWidth = 256] = "ImageWidth", e[e.ImageHeight = 257] = "ImageHeight", e[e.BitsPerSample = 258] = "BitsPerSample", e[e.SampleFormat = 339] = "SampleFormat", e[e.Compression = 259] = "Compression", e[e.Photometric = 262] = "Photometric", e[e.TileWidth = 322] = "TileWidth", e[e.TileHeight = 323] = "TileHeight", e[e.TileOffsets = 324] = "TileOffsets", e[e.TileByteCounts = 325] = "TileByteCounts", e[e.JpegTables = 347] = "JpegTables", e[e.StripOffsets = 273] = "StripOffsets", e[e.StripByteCounts = 279] = "StripByteCounts", e[e.GdalMetadata = 42112] = "GdalMetadata", e[e.GdalNoData = 42113] = "GdalNoData", 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", e[e.LercParameters = 50674] = "LercParameters", e[e.PlanarConfiguration = 284] = "PlanarConfiguration", e[e.CellLength = 265] = "CellLength", e[e.CellWidth = 264] = "CellWidth", e[e.ColorMap = 320] = "ColorMap", 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.Make = 271] = "Make", e[e.MaxSampleValue = 281] = "MaxSampleValue", e[e.MinSampleValue = 280] = "MinSampleValue", e[e.Model = 272] = "Model", e[e.Orientation = 274] = "Orientation", e[e.ResolutionUnit = 296] = "ResolutionUnit", e[e.RowsPerStrip = 278] = "RowsPerStrip", e[e.SamplesPerPixel = 277] = "SamplesPerPixel", e[e.Software = 305] = "Software", 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.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.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.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";
56
- })(u || (u = {}));
57
- var p;
57
+ })(d || (d = {}));
58
+ var m;
58
59
  (function(e) {
59
60
  e[e.GTModelTypeGeoKey = 1024] = "GTModelTypeGeoKey", e[e.GTRasterTypeGeoKey = 1025] = "GTRasterTypeGeoKey", e[e.GTCitationGeoKey = 1026] = "GTCitationGeoKey", e[e.GeodeticCRSGeoKey = 2048] = "GeodeticCRSGeoKey", e[e.GeodeticCitationGeoKey = 2049] = "GeodeticCitationGeoKey", e[e.GeodeticDatumGeoKey = 2050] = "GeodeticDatumGeoKey", e[e.PrimeMeridianGeoKey = 2051] = "PrimeMeridianGeoKey", e[e.GeogLinearUnitsGeoKey = 2052] = "GeogLinearUnitsGeoKey", e[e.GeogLinearUnitSizeGeoKey = 2053] = "GeogLinearUnitSizeGeoKey", e[e.GeogAngularUnitsGeoKey = 2054] = "GeogAngularUnitsGeoKey", e[e.GeogAngularUnitSizeGeoKey = 2055] = "GeogAngularUnitSizeGeoKey", e[e.EllipsoidGeoKey = 2056] = "EllipsoidGeoKey", e[e.EllipsoidSemiMajorAxisGeoKey = 2057] = "EllipsoidSemiMajorAxisGeoKey", e[e.EllipsoidSemiMinorAxisGeoKey = 2058] = "EllipsoidSemiMinorAxisGeoKey", e[e.EllipsoidInvFlatteningGeoKey = 2059] = "EllipsoidInvFlatteningGeoKey", e[e.PrimeMeridianLongitudeGeoKey = 2061] = "PrimeMeridianLongitudeGeoKey", e[e.GeogTOWGS84GeoKey = 2062] = "GeogTOWGS84GeoKey", e[e.GeogAzimuthUnitsGeoKey = 2060] = "GeogAzimuthUnitsGeoKey", e[e.ProjectedCRSGeoKey = 3072] = "ProjectedCRSGeoKey", e[e.ProjectedCitationGeoKey = 3073] = "ProjectedCitationGeoKey", e[e.ProjectionGeoKey = 3074] = "ProjectionGeoKey", e[e.ProjMethodGeoKey = 3075] = "ProjMethodGeoKey", 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.VerticalGeoKey = 4096] = "VerticalGeoKey", e[e.VerticalCitationGeoKey = 4097] = "VerticalCitationGeoKey", e[e.VerticalDatumGeoKey = 4098] = "VerticalDatumGeoKey", e[e.VerticalUnitsGeoKey = 4099] = "VerticalUnitsGeoKey";
60
- })(p || (p = {}));
61
- var fe;
61
+ })(m || (m = {}));
62
+ var Pe;
62
63
  (function(e) {
63
64
  e[e.Radian = 9101] = "Radian", e[e.Degree = 9102] = "Degree", e[e.ArcMinute = 9103] = "ArcMinute", e[e.ArcDegree = 9104] = "ArcDegree", e[e.Grad = 9105] = "Grad", e[e.Gon = 9106] = "Gon", e[e.Dms = 9107] = "Dms";
64
- })(fe || (fe = {}));
65
- var ye;
65
+ })(Pe || (Pe = {}));
66
+ var be;
66
67
  (function(e) {
67
68
  e[e.Metre = 9001] = "Metre", e[e.Foot = 9002] = "Foot", e[e.FootUsSurvey = 9003] = "FootUsSurvey", e[e.FootModifiedAmerican = 9004] = "FootModifiedAmerican", e[e.FootClarke = 9005] = "FootClarke", e[e.FootIndian = 9006] = "FootIndian", e[e.Link = 9007] = "Link", e[e.LinkBenoit = 9008] = "LinkBenoit", e[e.LinkSears = 9009] = "LinkSears", e[e.ChainBenoit = 9010] = "ChainBenoit", e[e.ChainSears = 9011] = "ChainSears", e[e.YardSears = 9012] = "YardSears", e[e.YardIndian = 9013] = "YardIndian", e[e.Fathom = 9014] = "Fathom", e[e.MileInternationalNautical = 9015] = "MileInternationalNautical";
68
- })(ye || (ye = {}));
69
- const ft = {
70
- [u.TileByteCounts]: !0,
71
- [u.TileOffsets]: !0,
72
- [u.StripOffsets]: !0,
73
- [u.StripByteCounts]: !0,
74
- [u.BitsPerSample]: !0,
75
- [u.SampleFormat]: !0,
76
- [u.GeoKeyDirectory]: !0,
77
- [u.GeoDoubleParams]: !0
69
+ })(be || (be = {}));
70
+ const Nt = {
71
+ [d.TileByteCounts]: !0,
72
+ [d.TileOffsets]: !0,
73
+ [d.StripOffsets]: !0,
74
+ [d.StripByteCounts]: !0,
75
+ [d.BitsPerSample]: !0,
76
+ [d.SampleFormat]: !0,
77
+ [d.GeoKeyDirectory]: !0,
78
+ [d.GeoDoubleParams]: !0
78
79
  };
79
- var w;
80
+ var P;
80
81
  (function(e) {
81
82
  e.None = "application/octet-stream", e.Jbig = "image/jbig", e.Dcs = "image/x-kodak-dcs", e.PackBits = "application/packbits", e.Jpeg = "image/jpeg", e.Jp2000 = "image/jp2", e.JpegXl = "image/jpegxl", e.Webp = "image/webp", e.Zstd = "application/zstd", e.Lzw = "application/lzw", e.Deflate = "application/deflate", e.Lerc = "application/lerc", e.Lzma = "application/x-lzma";
82
- })(w || (w = {}));
83
- const ve = {
84
- [m.None]: w.None,
85
- [m.Lzw]: w.Lzw,
86
- [m.Jpeg6]: w.Jpeg,
87
- [m.Jpeg]: w.Jpeg,
88
- [m.DeflateOther]: w.Deflate,
89
- [m.Deflate]: w.Deflate,
90
- [m.Lerc]: w.Lerc,
91
- [m.Lzma]: w.Lzma,
92
- [m.Jp2000]: w.Jp2000,
93
- [m.Zstd]: w.Zstd,
94
- [m.Webp]: w.Webp,
95
- [m.JpegXl]: w.JpegXl,
96
- [m.Ccittrle]: w.None,
97
- [m.CcittT4]: w.None,
98
- [m.CcittT6]: w.None,
99
- [m.T85]: w.Jbig,
100
- [m.T43]: w.Jbig,
101
- [m.Next]: w.None,
102
- [m.Ccittrlew]: w.None,
103
- [m.PackBits]: w.PackBits,
104
- [m.ThunderScan]: w.None,
105
- [m.It8ctpad]: w.None,
106
- [m.It8lw]: w.None,
107
- [m.It8mp]: w.None,
108
- [m.It8bl]: w.None,
109
- [m.PixarFilm]: w.None,
110
- [m.PixarLog]: w.None,
111
- [m.Dcs]: w.Dcs,
112
- [m.Jbig]: w.Jbig,
113
- [m.SgiLog]: w.None,
114
- [m.SgiLog24]: w.None,
115
- [m.JpegXlDng17]: w.JpegXl
83
+ })(P || (P = {}));
84
+ const $e = {
85
+ [f.None]: P.None,
86
+ [f.Lzw]: P.Lzw,
87
+ [f.Jpeg6]: P.Jpeg,
88
+ [f.Jpeg]: P.Jpeg,
89
+ [f.DeflateOther]: P.Deflate,
90
+ [f.Deflate]: P.Deflate,
91
+ [f.Lerc]: P.Lerc,
92
+ [f.Lzma]: P.Lzma,
93
+ [f.Jp2000]: P.Jp2000,
94
+ [f.Zstd]: P.Zstd,
95
+ [f.Webp]: P.Webp,
96
+ [f.JpegXl]: P.JpegXl,
97
+ [f.Ccittrle]: P.None,
98
+ [f.CcittT4]: P.None,
99
+ [f.CcittT6]: P.None,
100
+ [f.T85]: P.Jbig,
101
+ [f.T43]: P.Jbig,
102
+ [f.Next]: P.None,
103
+ [f.Ccittrlew]: P.None,
104
+ [f.PackBits]: P.PackBits,
105
+ [f.ThunderScan]: P.None,
106
+ [f.It8ctpad]: P.None,
107
+ [f.It8lw]: P.None,
108
+ [f.It8mp]: P.None,
109
+ [f.It8bl]: P.None,
110
+ [f.PixarFilm]: P.None,
111
+ [f.PixarLog]: P.None,
112
+ [f.Dcs]: P.Dcs,
113
+ [f.Jbig]: P.Jbig,
114
+ [f.SgiLog]: P.None,
115
+ [f.SgiLog24]: P.None,
116
+ [f.JpegXlDng17]: P.JpegXl
116
117
  };
117
- function yt(e) {
118
- return e == null ? null : ve[e];
118
+ function zt(e) {
119
+ return e == null ? null : $e[e];
119
120
  }
120
- var y;
121
+ var w;
121
122
  (function(e) {
122
123
  e[e.Uint8 = 1] = "Uint8", e[e.Ascii = 2] = "Ascii", e[e.Uint16 = 3] = "Uint16", e[e.Uint32 = 4] = "Uint32", e[e.Rational = 5] = "Rational", e[e.Int8 = 6] = "Int8", e[e.Undefined = 7] = "Undefined", e[e.Int16 = 8] = "Int16", e[e.Int32 = 9] = "Int32", e[e.SignedRational = 10] = "SignedRational", e[e.Float32 = 11] = "Float32", e[e.Float64 = 12] = "Float64", e[e.Ifd = 13] = "Ifd", e[e.Uint64 = 16] = "Uint64", e[e.Int64 = 17] = "Int64", e[e.Ifd8 = 18] = "Ifd8";
123
- })(y || (y = {}));
124
- var v;
124
+ })(w || (w = {}));
125
+ var R;
125
126
  (function(e) {
126
127
  e[e.BigTiff = 43] = "BigTiff", e[e.Tiff = 42] = "Tiff";
127
- })(v || (v = {}));
128
+ })(R || (R = {}));
128
129
  function N(e) {
129
130
  switch (e) {
130
- case y.Uint8:
131
- case y.Ascii:
132
- case y.Int8:
133
- case y.Undefined:
131
+ case w.Uint8:
132
+ case w.Ascii:
133
+ case w.Int8:
134
+ case w.Undefined:
134
135
  return 1;
135
- case y.Uint16:
136
- case y.Int16:
136
+ case w.Uint16:
137
+ case w.Int16:
137
138
  return 2;
138
- case y.Uint32:
139
- case y.Int32:
140
- case y.Float32:
141
- case y.Ifd:
139
+ case w.Uint32:
140
+ case w.Int32:
141
+ case w.Float32:
142
+ case w.Ifd:
142
143
  return 4;
143
- case y.Rational:
144
- case y.SignedRational:
145
- case y.Float64:
146
- case y.Uint64:
147
- case y.Int64:
148
- case y.Ifd8:
144
+ case w.Rational:
145
+ case w.SignedRational:
146
+ case w.Float64:
147
+ case w.Uint64:
148
+ case w.Int64:
149
+ case w.Ifd8:
149
150
  return 8;
150
151
  default:
151
152
  throw new Error(`Invalid fieldType ${String(e)}`);
152
153
  }
153
154
  }
154
- var we;
155
+ var Ce;
155
156
  (function(e) {
156
157
  e[e.Double = 8] = "Double", e[e.Float32 = 4] = "Float32";
157
- })(we || (we = {}));
158
- var L;
158
+ })(Ce || (Ce = {}));
159
+ var I;
159
160
  (function(e) {
160
161
  e[e.UInt64 = 8] = "UInt64", e[e.UInt32 = 4] = "UInt32", e[e.UInt16 = 2] = "UInt16", e[e.UInt8 = 1] = "UInt8";
161
- })(L || (L = {}));
162
- const Se = 2 ** 32;
163
- function Ue(e, t, n) {
164
- const r = e.getUint32(t, n), o = e.getUint32(t + 4, n), i = n ? r + Se * o : Se * r + o;
162
+ })(I || (I = {}));
163
+ const Le = 2 ** 32;
164
+ function ke(e, t, n) {
165
+ const r = e.getUint32(t, n), o = e.getUint32(t + 4, n), i = n ? r + Le * o : Le * r + o;
165
166
  if (!Number.isSafeInteger(i))
166
167
  throw new Error(i + " exceeds MAX_SAFE_INTEGER. Precision may is lost");
167
168
  return i;
168
169
  }
169
170
  function K(e, t, n, r) {
170
171
  switch (n) {
171
- case L.UInt8:
172
+ case I.UInt8:
172
173
  return e.getUint8(t);
173
- case L.UInt16:
174
+ case I.UInt16:
174
175
  return e.getUint16(t, r);
175
- case L.UInt32:
176
+ case I.UInt32:
176
177
  return e.getUint32(t, r);
177
- case L.UInt64:
178
- return Ue(e, t, r);
178
+ case I.UInt64:
179
+ return ke(e, t, r);
179
180
  }
180
181
  }
181
- function Y(e, t, n) {
182
+ function X(e, t, n) {
182
183
  return !(t < e.sourceOffset || e.sourceOffset + e.byteLength < t + n);
183
184
  }
184
- const Oe = new ArrayBuffer(4), wt = new Uint32Array(Oe), St = new Uint8Array(Oe);
185
- wt[0] = 1;
186
- const Pe = St[0] === 1;
187
- function Ce(e, t, n, r) {
185
+ const We = new ArrayBuffer(4), Bt = new Uint32Array(We), _t = new Uint8Array(We);
186
+ Bt[0] = 1;
187
+ const Ie = _t[0] === 1;
188
+ function Ge(e, t, n, r) {
188
189
  switch (e) {
189
- case y.Ascii:
190
+ case w.Ascii:
190
191
  return String.fromCharCode(t.getUint8(n));
191
- case y.Undefined:
192
- case y.Uint8:
192
+ case w.Undefined:
193
+ case w.Uint8:
193
194
  return t.getUint8(n);
194
- case y.Int8:
195
+ case w.Int8:
195
196
  return t.getInt8(n);
196
- case y.Uint16:
197
+ case w.Uint16:
197
198
  return t.getUint16(n, r);
198
- case y.Int16:
199
+ case w.Int16:
199
200
  return t.getInt16(n, r);
200
- case y.Uint32:
201
- case y.Ifd:
201
+ case w.Uint32:
202
+ case w.Ifd:
202
203
  return t.getUint32(n, r);
203
- case y.Int32:
204
+ case w.Int32:
204
205
  return t.getInt32(n, r);
205
- case y.Rational:
206
+ case w.Rational:
206
207
  return [t.getUint32(n, r), t.getUint32(n + 4, r)];
207
- case y.SignedRational:
208
+ case w.SignedRational:
208
209
  return [t.getInt32(n, r), t.getInt32(n + 4, r)];
209
- case y.Float64:
210
+ case w.Float64:
210
211
  return t.getFloat64(n, r);
211
- case y.Float32:
212
+ case w.Float32:
212
213
  return t.getFloat32(n, r);
213
- case y.Uint64:
214
- return Ue(t, n, r);
214
+ case w.Uint64:
215
+ return ke(t, n, r);
215
216
  default:
216
- throw new Error(`Unknown read type "${e}" "${y[e]}"`);
217
+ throw new Error(`Unknown read type "${e}" "${w[e]}"`);
217
218
  }
218
219
  }
219
- function Me(e, t, n, r, o) {
220
+ function Je(e, t, n, r, o) {
220
221
  switch (o) {
221
- case y.Uint8:
222
+ case w.Uint8:
222
223
  return new Uint8Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
223
- case y.Uint16:
224
- return e.isLittleEndian !== Pe ? null : new Uint16Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
225
- case y.Uint32:
226
- return e.isLittleEndian !== Pe ? null : new Uint32Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
224
+ case w.Uint16:
225
+ return e.isLittleEndian !== Ie ? null : new Uint16Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
226
+ case w.Uint32:
227
+ return e.isLittleEndian !== Ie ? null : new Uint32Array(t.buffer.slice(t.byteOffset + n, t.byteOffset + n + r));
227
228
  }
228
229
  return null;
229
230
  }
230
- function x(e, t, n, r, o, i) {
231
+ function D(e, t, n, r, o, i) {
231
232
  const a = N(o), s = i * a;
232
233
  if (i === 1) {
233
- const c = Ce(o, n, r, e.isLittleEndian);
234
- return t && ft[t] ? [c] : c;
234
+ const c = Ge(o, n, r, e.isLittleEndian);
235
+ return t && Nt[t] ? [c] : c;
235
236
  }
236
237
  switch (o) {
237
- case y.Ascii:
238
+ case w.Ascii:
238
239
  return String.fromCharCode.apply(null, new Uint8Array(n.buffer, r, s - 1));
239
240
  }
240
- if (t === u.TileOffsets || t === u.TileByteCounts || t === u.StripOffsets || t === u.StripByteCounts) {
241
- const c = Me(e, n, r, s, o);
241
+ if (t === d.TileOffsets || t === d.TileByteCounts || t === d.StripOffsets || t === d.StripByteCounts) {
242
+ const c = Je(e, n, r, s, o);
242
243
  if (c)
243
244
  return c;
244
245
  }
245
246
  const l = [];
246
247
  for (let c = 0; c < s; c += a)
247
- l.push(Ce(o, n, r + c, e.isLittleEndian));
248
+ l.push(Ge(o, n, r + c, e.isLittleEndian));
248
249
  return l;
249
250
  }
250
- function Pt(e, t, n) {
251
+ function $t(e, t, n) {
251
252
  const r = t.getUint16(n + 0, e.isLittleEndian), o = t.getUint16(n + 2, e.isLittleEndian), i = K(t, n + 4, e.ifdConfig.pointer, e.isLittleEndian), s = N(o) * i;
252
253
  if (s <= e.ifdConfig.pointer) {
253
- const c = x(e, r, t, n + 4 + e.ifdConfig.pointer, o, i);
254
- return { type: "inline", id: r, name: u[r], count: i, value: c, dataType: o, tagOffset: n };
254
+ const c = D(e, r, t, n + 4 + e.ifdConfig.pointer, o, i);
255
+ return { type: "inline", id: r, name: d[r], count: i, value: c, dataType: o, tagOffset: n };
255
256
  }
256
257
  const l = K(t, n + 4 + e.ifdConfig.pointer, e.ifdConfig.pointer, e.isLittleEndian);
257
258
  switch (r) {
258
- case u.TileOffsets:
259
- case u.TileByteCounts:
260
- case u.StripByteCounts:
261
- case u.StripOffsets:
259
+ case d.TileOffsets:
260
+ case d.TileByteCounts:
261
+ case d.StripByteCounts:
262
+ case d.StripOffsets:
262
263
  const c = {
263
264
  type: "offset",
264
265
  id: r,
265
- name: u[r],
266
+ name: d[r],
266
267
  count: i,
267
268
  dataType: o,
268
269
  dataOffset: l,
@@ -270,76 +271,76 @@ function Pt(e, t, n) {
270
271
  value: [],
271
272
  tagOffset: n
272
273
  };
273
- if (Y(t, l, s)) {
274
- const d = Me(e, t, l - t.sourceOffset, s, o);
275
- d ? (c.value = d, c.isLoaded = !0) : bt(c, t);
274
+ if (X(t, l, s)) {
275
+ const u = Je(e, t, l - t.sourceOffset, s, o);
276
+ u ? (c.value = u, c.isLoaded = !0) : Jt(c, t);
276
277
  }
277
278
  return c;
278
279
  }
279
- if (Y(t, l, s)) {
280
- const c = x(e, r, t, l - t.sourceOffset, o, i);
281
- return { type: "inline", id: r, name: u[r], count: i, value: c, dataType: o, tagOffset: n };
280
+ if (X(t, l, s)) {
281
+ const c = D(e, r, t, l - t.sourceOffset, o, i);
282
+ return { type: "inline", id: r, name: d[r], count: i, value: c, dataType: o, tagOffset: n };
282
283
  }
283
- return { type: "lazy", id: r, name: u[r], count: i, dataOffset: l, dataType: o, tagOffset: n };
284
+ return { type: "lazy", id: r, name: d[r], count: i, dataOffset: l, dataType: o, tagOffset: n };
284
285
  }
285
- async function Ct(e, t, n) {
286
+ async function kt(e, t, n) {
286
287
  if (e.value != null)
287
288
  return e.value;
288
289
  const o = N(e.dataType) * e.count, i = await t.source.fetch(e.dataOffset, o, n), a = new DataView(i);
289
- return e.value = x(t, e.id, a, 0, e.dataType, e.count), e.value;
290
+ return e.value = D(t, e.id, a, 0, e.dataType, e.count), e.value;
290
291
  }
291
- async function Lt(e, t, n) {
292
+ async function Wt(e, t, n) {
292
293
  const r = N(t.dataType);
293
294
  if (t.view == null) {
294
295
  const o = await e.source.fetch(t.dataOffset, r * t.count, n);
295
296
  t.view = new DataView(o), t.view.sourceOffset = t.dataOffset;
296
297
  }
297
- return t.value = x(e, t.id, t.view, 0, t.dataType, t.count), t.view = void 0, t.isLoaded = !0, t.value;
298
+ return t.value = D(e, t.id, t.view, 0, t.dataType, t.count), t.view = void 0, t.isLoaded = !0, t.value;
298
299
  }
299
- function bt(e, t) {
300
+ function Jt(e, t) {
300
301
  const n = N(e.dataType), r = t.byteOffset + e.dataOffset - t.sourceOffset;
301
302
  e.view = new DataView(t.buffer.slice(r, r + n * e.count)), e.view.sourceOffset = e.dataOffset;
302
303
  }
303
- async function It(e, t, n, r) {
304
+ async function Vt(e, t, n, r) {
304
305
  if (n > t.count || n < 0)
305
306
  throw new Error("TagOffset: out of bounds :" + n);
306
307
  if (t.value[n] != null)
307
308
  return t.value[n];
308
309
  const o = N(t.dataType);
309
310
  if (t.view == null) {
310
- const a = await e.source.fetch(t.dataOffset + n * o, o, r), s = new DataView(a), l = x(e, void 0, s, 0, t.dataType, 1);
311
+ const a = await e.source.fetch(t.dataOffset + n * o, o, r), s = new DataView(a), l = D(e, void 0, s, 0, t.dataType, 1);
311
312
  if (typeof l != "number")
312
313
  throw new Error("Value is not a number");
313
314
  return t.value[n] = l, l;
314
315
  }
315
- const i = x(e, void 0, t.view, n * o, t.dataType, 1);
316
+ const i = D(e, void 0, t.view, n * o, t.dataType, 1);
316
317
  if (typeof i != "number")
317
318
  throw new Error("Value is not a number");
318
319
  return t.value[n] = i, i;
319
320
  }
320
- function Gt(e, t, n) {
321
+ function Ht(e, t, n) {
321
322
  if (n > t.count || n < 0)
322
323
  throw new Error("TagOffset: out of bounds :" + n);
323
324
  if (t.value[n] != null)
324
325
  return t.value[n];
325
326
  if (t.view == null)
326
327
  return null;
327
- const r = N(t.dataType), o = x(e, void 0, t.view, n * r, t.dataType, 1);
328
+ const r = N(t.dataType), o = D(e, void 0, t.view, n * r, t.dataType, 1);
328
329
  if (typeof o != "number")
329
330
  throw new Error("Value is not a number");
330
331
  return t.value[n] = o, o;
331
332
  }
332
- const Le = 32767, jt = /* @__PURE__ */ new Set([
333
- u.Compression,
334
- u.ImageHeight,
335
- u.ImageWidth,
336
- u.ModelPixelScale,
337
- u.ModelTiePoint,
338
- u.ModelTransformation,
339
- u.TileHeight,
340
- u.TileWidth
341
- ]), Et = /* @__PURE__ */ new Set([u.GeoKeyDirectory, u.GeoAsciiParams, u.GeoDoubleParams]);
342
- class Ft {
333
+ const ve = 32767, Yt = /* @__PURE__ */ new Set([
334
+ d.Compression,
335
+ d.ImageHeight,
336
+ d.ImageWidth,
337
+ d.ModelPixelScale,
338
+ d.ModelTiePoint,
339
+ d.ModelTransformation,
340
+ d.TileHeight,
341
+ d.TileWidth
342
+ ]), Xt = /* @__PURE__ */ new Set([d.GeoKeyDirectory, d.GeoAsciiParams, d.GeoDoubleParams]);
343
+ class Zt {
343
344
  /**
344
345
  * Id of the tif image, generally the image index inside the tif
345
346
  * where 0 is the root image, and every sub image is +1
@@ -365,9 +366,9 @@ class Ft {
365
366
  */
366
367
  async init(t = !0, n) {
367
368
  const r = [];
368
- jt.forEach((o) => {
369
+ Yt.forEach((o) => {
369
370
  r.push(this.fetch(o, n));
370
- }), t && Et.forEach((o) => {
371
+ }), t && Xt.forEach((o) => {
371
372
  r.push(this.fetch(o, n));
372
373
  }), await Promise.all(r), t && await this.loadGeoTiffTags();
373
374
  }
@@ -417,11 +418,11 @@ class Ft {
417
418
  if (r.type === "inline")
418
419
  return r.value;
419
420
  if (r.type === "lazy")
420
- return Ct(r, this.tiff, n);
421
+ return kt(r, this.tiff, n);
421
422
  if (r.isLoaded)
422
423
  return r.value;
423
424
  if (r.type === "offset")
424
- return Lt(this.tiff, r, n);
425
+ return Wt(this.tiff, r, n);
425
426
  throw new Error("Cannot fetch:" + t);
426
427
  }
427
428
  /**
@@ -445,7 +446,7 @@ class Ft {
445
446
  * @returns null if the tag does not exist
446
447
  */
447
448
  get noData() {
448
- const t = this.tags.get(u.GdalNoData);
449
+ const t = this.tags.get(d.GdalNoData);
449
450
  if (t == null)
450
451
  return null;
451
452
  if (t.value != null)
@@ -460,15 +461,15 @@ class Ft {
460
461
  async loadGeoTiffTags() {
461
462
  if (this.isGeoTagsLoaded)
462
463
  return;
463
- const t = this.tags.get(u.GeoKeyDirectory);
464
+ const t = this.tags.get(d.GeoKeyDirectory);
464
465
  if (t == null) {
465
466
  this.isGeoTagsLoaded = !0;
466
467
  return;
467
468
  }
468
469
  if (t.type === "lazy" && t.value == null && await Promise.all([
469
- this.fetch(u.GeoKeyDirectory),
470
- this.fetch(u.GeoAsciiParams),
471
- this.fetch(u.GeoDoubleParams)
470
+ this.fetch(d.GeoKeyDirectory),
471
+ this.fetch(d.GeoAsciiParams),
472
+ this.fetch(d.GeoDoubleParams)
472
473
  ]), this.isGeoTagsLoaded = !0, t.value == null)
473
474
  return;
474
475
  const n = t.value;
@@ -498,19 +499,19 @@ class Ft {
498
499
  * @returns origin point of the image
499
500
  */
500
501
  get origin() {
501
- const t = this.value(u.ModelTiePoint);
502
+ const t = this.value(d.ModelTiePoint);
502
503
  if (t != null && t.length === 6)
503
504
  return [t[3], t[4], t[5]];
504
- const n = this.value(u.ModelTransformation);
505
+ const n = this.value(d.ModelTransformation);
505
506
  if (n != null)
506
507
  return [n[3], n[7], n[11]];
507
- if (this.value(u.SubFileType) === J.ReducedImage && this.id !== 0)
508
+ if (this.value(d.SubFileType) === J.ReducedImage && this.id !== 0)
508
509
  return this.tiff.images[0].origin;
509
510
  throw new Error("Image does not have a geo transformation.");
510
511
  }
511
512
  /** Is there enough geo information on this image to figure out where its actually located */
512
513
  get isGeoLocated() {
513
- return this.value(u.ModelPixelScale) != null || this.value(u.ModelTransformation) != null ? !0 : this.isSubImage && this.id !== 0 ? this.tiff.images[0].isGeoLocated : !1;
514
+ return this.value(d.ModelPixelScale) != null || this.value(d.ModelTransformation) != null ? !0 : this.isSubImage && this.id !== 0 ? this.tiff.images[0].isGeoLocated : !1;
514
515
  }
515
516
  /**
516
517
  * Get the resolution of the image
@@ -518,10 +519,10 @@ class Ft {
518
519
  * @returns [x,y,z] pixel scale
519
520
  */
520
521
  get resolution() {
521
- const t = this.value(u.ModelPixelScale);
522
+ const t = this.value(d.ModelPixelScale);
522
523
  if (t != null)
523
524
  return [t[0], -t[1], t[2]];
524
- const n = this.value(u.ModelTransformation);
525
+ const n = this.value(d.ModelTransformation);
525
526
  if (n != null)
526
527
  return [n[0], n[5], n[10]];
527
528
  if (this.isSubImage && this.id !== 0) {
@@ -536,7 +537,7 @@ class Ft {
536
537
  * @returns true if SubFileType is Reduces image, false otherwise
537
538
  */
538
539
  get isSubImage() {
539
- return this.value(u.SubFileType) === J.ReducedImage;
540
+ return this.value(d.SubFileType) === J.ReducedImage;
540
541
  }
541
542
  /**
542
543
  * Bounding box of the image
@@ -558,8 +559,8 @@ class Ft {
558
559
  * @returns Compression type eg webp
559
560
  */
560
561
  get compression() {
561
- const t = this.value(u.Compression);
562
- return t == null ? null : ve[t];
562
+ const t = this.value(d.Compression);
563
+ return t == null ? null : $e[t];
563
564
  }
564
565
  /**
565
566
  * Attempt to read the EPSG Code from TiffGeoTags
@@ -569,26 +570,26 @@ class Ft {
569
570
  * @returns EPSG Code if it exists and is not user defined.
570
571
  */
571
572
  get epsg() {
572
- const t = this.valueGeo(p.ProjectionGeoKey);
573
- if (t != null && t !== Le)
573
+ const t = this.valueGeo(m.ProjectionGeoKey);
574
+ if (t != null && t !== ve)
574
575
  return t;
575
576
  let n = null;
576
- switch (this.valueGeo(p.GTModelTypeGeoKey)) {
577
- case M.Unknown:
577
+ switch (this.valueGeo(m.GTModelTypeGeoKey)) {
578
+ case O.Unknown:
578
579
  return null;
579
- case M.Projected:
580
- n = this.valueGeo(p.ProjectedCRSGeoKey);
580
+ case O.Projected:
581
+ n = this.valueGeo(m.ProjectedCRSGeoKey);
581
582
  break;
582
- case M.Geographic:
583
- n = this.valueGeo(p.GeodeticCRSGeoKey);
583
+ case O.Geographic:
584
+ n = this.valueGeo(m.GeodeticCRSGeoKey);
584
585
  break;
585
- case M.Geocentric:
586
- n = this.valueGeo(p.GeodeticCRSGeoKey);
586
+ case O.Geocentric:
587
+ n = this.valueGeo(m.GeodeticCRSGeoKey);
587
588
  break;
588
- case M.UserDefined:
589
+ case O.UserDefined:
589
590
  return null;
590
591
  }
591
- return n === Le ? null : n;
592
+ return n === ve ? null : n;
592
593
  }
593
594
  /**
594
595
  * Get the size of the image
@@ -596,7 +597,7 @@ class Ft {
596
597
  * @returns Size in pixels
597
598
  */
598
599
  get size() {
599
- const t = this.value(u.ImageWidth), n = this.value(u.ImageHeight);
600
+ const t = this.value(d.ImageWidth), n = this.value(d.ImageHeight);
600
601
  if (t == null || n == null)
601
602
  throw new Error("Tiff has no height or width");
602
603
  return { width: t, height: n };
@@ -605,13 +606,13 @@ class Ft {
605
606
  * Determine if this image is tiled
606
607
  */
607
608
  isTiled() {
608
- return this.value(u.TileWidth) !== null;
609
+ return this.value(d.TileWidth) !== null;
609
610
  }
610
611
  /**
611
612
  * Get size of individual tiles
612
613
  */
613
614
  get tileSize() {
614
- const t = this.value(u.TileWidth), n = this.value(u.TileHeight);
615
+ const t = this.value(d.TileWidth), n = this.value(d.TileHeight);
615
616
  if (t == null || n == null)
616
617
  throw new Error("Tiff is not tiled");
617
618
  return { width: t, height: n };
@@ -631,7 +632,7 @@ class Ft {
631
632
  * @returns file offset to where the tiffs are stored
632
633
  */
633
634
  get tileOffset() {
634
- const t = this.tags.get(u.TileOffsets);
635
+ const t = this.tags.get(d.TileOffsets);
635
636
  if (t == null)
636
637
  throw new Error("No tile offsets found");
637
638
  return t;
@@ -644,7 +645,7 @@ class Ft {
644
645
  * @returns number of strips present
645
646
  */
646
647
  get stripCount() {
647
- return this.tags.get(u.StripByteCounts)?.count ?? 0;
648
+ return this.tags.get(d.StripByteCounts)?.count ?? 0;
648
649
  }
649
650
  // Clamp the bounds of the output image to the size of the image, as sometimes the edge tiles are not full tiles
650
651
  getTileBounds(t, n) {
@@ -661,18 +662,18 @@ class Ft {
661
662
  async getStrip(t, n) {
662
663
  if (this.isTiled())
663
664
  throw new Error("Cannot read stripes, tiff is tiled: " + t);
664
- const r = this.tags.get(u.StripByteCounts), o = this.tags.get(u.StripOffsets);
665
+ const r = this.tags.get(d.StripByteCounts), o = this.tags.get(d.StripOffsets);
665
666
  if (t >= r.count)
666
667
  throw new Error("Cannot read strip, index out of bounds");
667
668
  const [i, a] = await Promise.all([
668
- $(this.tiff, o, t, n),
669
- $(this.tiff, r, t, n)
669
+ k(this.tiff, o, t, n),
670
+ k(this.tiff, r, t, n)
670
671
  ]);
671
672
  return this.getBytes(i, a, n);
672
673
  }
673
674
  /** The jpeg header is stored in the IFD, read the JPEG header and adjust the byte array to include it */
674
675
  getJpegHeader(t) {
675
- const n = this.value(u.JpegTables);
676
+ const n = this.value(d.JpegTables);
676
677
  if (n == null)
677
678
  throw new Error("Unable to find Jpeg header");
678
679
  const r = n.slice(0, n.length - 2), o = new Uint8Array(t.byteLength + r.length - 2);
@@ -685,10 +686,10 @@ class Ft {
685
686
  const o = await this.tiff.source.fetch(t, n, r);
686
687
  if (o.byteLength < n)
687
688
  throw new Error(`Failed to fetch bytes from offset:${t} wanted:${n} got:${o.byteLength}`);
688
- let i = this.value(u.Compression);
689
- i == null && (i = m.None);
690
- const a = yt(i) ?? w.None;
691
- return i === m.Jpeg ? { mimeType: a, bytes: this.getJpegHeader(o), compression: i } : { mimeType: a, bytes: o, compression: i };
689
+ let i = this.value(d.Compression);
690
+ i == null && (i = f.None);
691
+ const a = zt(i) ?? P.None;
692
+ return i === f.Jpeg ? { mimeType: a, bytes: this.getJpegHeader(o), compression: i } : { mimeType: a, bytes: o, compression: i };
692
693
  }
693
694
  /**
694
695
  * Load a tile into a ArrayBuffer
@@ -708,8 +709,8 @@ class Ft {
708
709
  const l = n * s + t, c = s * a;
709
710
  if (l >= c)
710
711
  throw new Error(`Tile index is outside of tile range: ${l} >= ${c}`);
711
- const { offset: d, imageSize: h } = await this.getTileSize(l, r);
712
- return this.getBytes(d, h, r);
712
+ const { offset: u, imageSize: h } = await this.getTileSize(l, r);
713
+ return this.getBytes(u, h, r);
713
714
  }
714
715
  /**
715
716
  * Does this tile exist in the tiff and does it actually have a value
@@ -741,48 +742,48 @@ class Ft {
741
742
  * @returns Offset and byteCount for the tile
742
743
  */
743
744
  async getTileSize(t, n) {
744
- const r = this.tags.get(u.TileByteCounts), o = ee(this.tiff, this.tileOffset, t), i = ee(this.tiff, r, t);
745
+ const r = this.tags.get(d.TileByteCounts), o = ne(this.tiff, this.tileOffset, t), i = ne(this.tiff, r, t);
745
746
  if (o != null && i != null)
746
747
  return { offset: o, imageSize: i };
747
748
  const a = this.tiff.options?.tileLeaderByteSize;
748
749
  if (a) {
749
- const c = o ?? await $(this.tiff, this.tileOffset, t, n);
750
+ const c = o ?? await k(this.tiff, this.tileOffset, t, n);
750
751
  if (c === 0)
751
752
  return { offset: 0, imageSize: 0 };
752
- const d = await this.tiff.source.fetch(c - a, a, n);
753
- return { offset: c, imageSize: K(new DataView(d), 0, a, this.tiff.isLittleEndian) };
753
+ const u = await this.tiff.source.fetch(c - a, a, n);
754
+ return { offset: c, imageSize: K(new DataView(u), 0, a, this.tiff.isLittleEndian) };
754
755
  }
755
756
  if (r == null)
756
757
  throw new Error("No tile byte counts found");
757
758
  const [s, l] = await Promise.all([
758
- o ?? $(this.tiff, this.tileOffset, t, n),
759
- i ?? $(this.tiff, r, t, n)
759
+ o ?? k(this.tiff, this.tileOffset, t, n),
760
+ i ?? k(this.tiff, r, t, n)
760
761
  ]);
761
762
  return { offset: s, imageSize: l };
762
763
  }
763
764
  }
764
- function $(e, t, n, r) {
765
- const o = ee(e, t, n);
766
- return o != null ? Promise.resolve(o) : It(e, t, n, r);
765
+ function k(e, t, n, r) {
766
+ const o = ne(e, t, n);
767
+ return o != null ? Promise.resolve(o) : Vt(e, t, n, r);
767
768
  }
768
- function ee(e, t, n) {
769
+ function ne(e, t, n) {
769
770
  if (n < 0)
770
- throw new Error(`Tiff: ${e.source.url.href} out of bounds ${u[t.id]} index:${n} total:${t.count}`);
771
- return n >= t.count ? 0 : t.type === "inline" || t.isLoaded ? t.value[n] : Gt(e, t, n);
771
+ throw new Error(`Tiff: ${e.source.url.href} out of bounds ${d[t.id]} index:${n} total:${t.count}`);
772
+ return n >= t.count ? 0 : t.type === "inline" || t.isLoaded ? t.value[n] : Ht(e, t, n);
772
773
  }
773
774
  var z;
774
775
  (function(e) {
775
776
  e.GdalStructuralMetadataSize = "GDAL_STRUCTURAL_METADATA_SIZE", e.Layout = "LAYOUT", e.BlockOrder = "BLOCK_ORDER", e.BlockLeader = "BLOCK_LEADER", e.BlockTrailer = "BLOCK_TRAILER", e.KnownIncompatibleEdition = "KNOWN_INCOMPATIBLE_EDITION", e.MaskInterleavedWithImagery = "MASK_INTERLEAVED_WITH_IMAGERY";
776
777
  })(z || (z = {}));
777
- var be;
778
+ var Ee;
778
779
  (function(e) {
779
780
  e.RowMajor = "ROW_MAJOR";
780
- })(be || (be = {}));
781
- var te;
781
+ })(Ee || (Ee = {}));
782
+ var re;
782
783
  (function(e) {
783
784
  e.uint32 = "SIZE_AS_UINT4";
784
- })(te || (te = {}));
785
- class At {
785
+ })(re || (re = {}));
786
+ class Qt {
786
787
  options = /* @__PURE__ */ new Map();
787
788
  /**
788
789
  * Has GDAL optimized this tiff
@@ -816,8 +817,8 @@ class At {
816
817
  */
817
818
  get tileLeaderByteSize() {
818
819
  switch (this.options.get(z.BlockLeader)) {
819
- case te.uint32:
820
- return L.UInt32;
820
+ case re.uint32:
821
+ return I.UInt32;
821
822
  default:
822
823
  return null;
823
824
  }
@@ -826,10 +827,10 @@ class At {
826
827
  return this.options.get(z.MaskInterleavedWithImagery) === "YES";
827
828
  }
828
829
  }
829
- const Ke = {
830
- version: v.Tiff,
831
- pointer: L.UInt32,
832
- offset: L.UInt16,
830
+ const Ve = {
831
+ version: R.Tiff,
832
+ pointer: I.UInt32,
833
+ offset: I.UInt16,
833
834
  /**
834
835
  * Each tag entry is specified as
835
836
  * UInt16:TagCode
@@ -837,13 +838,13 @@ const Ke = {
837
838
  * UInt32:TagCount
838
839
  * UInt32:Pointer To Value or value
839
840
  */
840
- ifd: L.UInt16 + L.UInt16 + 2 * L.UInt32
841
- }, De = {
842
- version: v.BigTiff,
841
+ ifd: I.UInt16 + I.UInt16 + 2 * I.UInt32
842
+ }, He = {
843
+ version: R.BigTiff,
843
844
  /** Size of most pointers */
844
- pointer: L.UInt64,
845
+ pointer: I.UInt64,
845
846
  /** Size of offsets */
846
- offset: L.UInt64,
847
+ offset: I.UInt64,
847
848
  /**
848
849
  * Each tag entry is specified as
849
850
  * UInt16:TagCode
@@ -851,10 +852,10 @@ const Ke = {
851
852
  * UInt64:TagCount
852
853
  * UInt64:Pointer To Value or value
853
854
  */
854
- ifd: L.UInt16 + L.UInt16 + 2 * L.UInt64
855
+ ifd: I.UInt16 + I.UInt16 + 2 * I.UInt64
855
856
  };
856
- v.BigTiff + "", v.Tiff + "";
857
- function Rt(e, t = 4, n = !0) {
857
+ R.BigTiff + "", R.Tiff + "";
858
+ function qt(e, t = 4, n = !0) {
858
859
  const r = e.toString(16).padStart(t, "0");
859
860
  return n ? "0x" + r : r;
860
861
  }
@@ -866,13 +867,13 @@ class B {
866
867
  /** Where this cog is fetching its data from */
867
868
  source;
868
869
  /** Big or small Tiff */
869
- version = v.Tiff;
870
+ version = R.Tiff;
870
871
  /** List of images, o is the base image */
871
872
  images = [];
872
873
  /** Ghost header options */
873
874
  options;
874
875
  /** Configuration for the size of the IFD */
875
- ifdConfig = Ke;
876
+ ifdConfig = Ve;
876
877
  /** Is the tiff being read is little Endian */
877
878
  isLittleEndian = !1;
878
879
  /** Has init() been called */
@@ -913,16 +914,16 @@ class B {
913
914
  async readHeader(t) {
914
915
  if (this.isInitialized)
915
916
  return this;
916
- const n = new DataView(await this.source.fetch(0, Ie(this.source, 0, this.defaultReadSize), t));
917
+ const n = new DataView(await this.source.fetch(0, Fe(this.source, 0, this.defaultReadSize), t));
917
918
  if (n.byteLength === 0)
918
919
  throw new Error("Unable to read empty tiff");
919
920
  n.sourceOffset = 0;
920
921
  let r = 0;
921
922
  const o = n.getUint16(r, this.isLittleEndian);
922
- r += 2, this.isLittleEndian = o === q.Little, this.version = n.getUint16(r, this.isLittleEndian), r += 2;
923
+ r += 2, this.isLittleEndian = o === ee.Little, this.version = n.getUint16(r, this.isLittleEndian), r += 2;
923
924
  let i;
924
- if (this.version === v.BigTiff) {
925
- this.ifdConfig = De;
925
+ if (this.version === R.BigTiff) {
926
+ this.ifdConfig = He;
926
927
  const s = n.getUint16(r, this.isLittleEndian);
927
928
  if (r += 2, s !== 8)
928
929
  throw new Error("Only 8byte pointers are supported");
@@ -930,15 +931,15 @@ class B {
930
931
  if (r += 2, l !== 0)
931
932
  throw new Error("Invalid big tiff header");
932
933
  i = K(n, r, this.ifdConfig.pointer, this.isLittleEndian), r += this.ifdConfig.pointer;
933
- } else if (this.version === v.Tiff)
934
+ } else if (this.version === R.Tiff)
934
935
  i = K(n, r, this.ifdConfig.pointer, this.isLittleEndian), r += this.ifdConfig.pointer;
935
936
  else
936
937
  throw new Error(`Only tiff supported version:${String(this.version)}`);
937
938
  const a = i - r;
938
- for (a > 0 && a < 16 * 1024 && (this.options = new At(), this.options.process(n, r, a)); i !== 0; ) {
939
+ for (a > 0 && a < 16 * 1024 && (this.options = new Qt(), this.options.process(n, r, a)); i !== 0; ) {
939
940
  let s = n;
940
- if (!Y(s, i, 1024)) {
941
- const l = await this.source.fetch(i, Ie(this.source, i, this.defaultReadSize), t);
941
+ if (!X(s, i, 1024)) {
942
+ const l = await this.source.fetch(i, Fe(this.source, i, this.defaultReadSize), t);
942
943
  s = new DataView(l), s.sourceOffset = i;
943
944
  }
944
945
  i = this.readIfd(i, s);
@@ -953,57 +954,57 @@ class B {
953
954
  */
954
955
  readIfd(t, n) {
955
956
  const r = t - n.sourceOffset, o = K(n, r, this.ifdConfig.offset, this.isLittleEndian), i = /* @__PURE__ */ new Map(), a = o * this.ifdConfig.ifd;
956
- if (!Y(n, t, a))
957
- throw new Error("IFD out of range @ " + Rt(t) + " IFD" + this.images.length);
957
+ if (!X(n, t, a))
958
+ throw new Error("IFD out of range @ " + qt(t) + " IFD" + this.images.length);
958
959
  const s = this.ifdConfig.ifd, l = r + this.ifdConfig.offset;
959
960
  for (let c = 0; c < o; c++) {
960
- const d = Pt(this, n, l + c * s);
961
- i.set(d.id, d);
961
+ const u = $t(this, n, l + c * s);
962
+ i.set(u.id, u);
962
963
  }
963
- return this.images.push(new Ft(this, this.images.length, i)), K(n, l + o * s, this.ifdConfig.pointer, this.isLittleEndian);
964
+ return this.images.push(new Zt(this, this.images.length, i)), K(n, l + o * s, this.ifdConfig.pointer, this.isLittleEndian);
964
965
  }
965
966
  }
966
- function Ie(e, t, n) {
967
+ function Fe(e, t, n) {
967
968
  const r = e.metadata?.size;
968
969
  return r == null || r < 0 ? n : t + n > r ? r - t : n;
969
970
  }
970
- async function oe(e, t) {
971
+ async function le(e, t) {
971
972
  const n = new Blob([e]), r = await createImageBitmap(n), o = new OffscreenCanvas(r.width, r.height), i = o.getContext("2d");
972
973
  i.drawImage(r, 0, 0), r.close();
973
- const { width: a, height: s } = o, c = i.getImageData(0, 0, a, s).data, d = t.samplesPerPixel;
974
- if (d === 4)
974
+ const { width: a, height: s } = o, c = i.getImageData(0, 0, a, s).data, u = t.samplesPerPixel;
975
+ if (u === 4)
975
976
  return { layout: "pixel-interleaved", data: c };
976
- if (d === 3) {
977
- const h = a * s, g = new Uint8ClampedArray(h * 3);
978
- for (let f = 0, S = 0; f < g.length; f += 3, S += 4)
979
- g[f] = c[S], g[f + 1] = c[S + 1], g[f + 2] = c[S + 2];
980
- return { layout: "pixel-interleaved", data: g };
977
+ if (u === 3) {
978
+ const h = a * s, p = new Uint8ClampedArray(h * 3);
979
+ for (let g = 0, y = 0; g < p.length; g += 3, y += 4)
980
+ p[g] = c[y], p[g + 1] = c[y + 1], p[g + 2] = c[y + 2];
981
+ return { layout: "pixel-interleaved", data: p };
981
982
  }
982
- if (d === 1) {
983
- const h = a * s, g = new Uint8ClampedArray(h);
984
- for (let f = 0, S = 0; f < h; f++, S += 4)
985
- g[f] = c[S];
986
- return { layout: "pixel-interleaved", data: g };
983
+ if (u === 1) {
984
+ const h = a * s, p = new Uint8ClampedArray(h);
985
+ for (let g = 0, y = 0; g < h; g++, y += 4)
986
+ p[g] = c[y];
987
+ return { layout: "pixel-interleaved", data: p };
987
988
  }
988
- throw new Error(`Unsupported SamplesPerPixel for JPEG: ${d}`);
989
+ throw new Error(`Unsupported SamplesPerPixel for JPEG: ${u}`);
989
990
  }
990
- function vt(e, t = "") {
991
+ function Tt(e, t = "") {
991
992
  if (!e)
992
993
  throw new Error(t);
993
994
  }
994
- async function Ut(e, { format: t, signal: n }) {
995
+ async function en(e, { format: t, signal: n }) {
995
996
  const r = e instanceof Response ? e : new Response(e);
996
- vt(r.body, "Response does not contain body.");
997
+ Tt(r.body, "Response does not contain body.");
997
998
  try {
998
999
  return await new Response(r.body.pipeThrough(new DecompressionStream(t), { signal: n })).arrayBuffer();
999
1000
  } catch {
1000
1001
  throw n?.throwIfAborted(), new Error(`Failed to decode ${t}`);
1001
1002
  }
1002
1003
  }
1003
- async function xe(e) {
1004
- return Ut(e, { format: "deflate" });
1004
+ async function Ye(e) {
1005
+ return en(e, { format: "deflate" });
1005
1006
  }
1006
- function Ot(e, t) {
1007
+ function tn(e, t) {
1007
1008
  const n = e;
1008
1009
  let r = 0, o = e.length - t;
1009
1010
  do {
@@ -1012,7 +1013,7 @@ function Ot(e, t) {
1012
1013
  o -= t;
1013
1014
  } while (o > 0);
1014
1015
  }
1015
- function Mt(e, t, n) {
1016
+ function nn(e, t, n) {
1016
1017
  let r = 0, o = e.length;
1017
1018
  const i = o / n;
1018
1019
  for (; o > t; ) {
@@ -1025,78 +1026,78 @@ function Mt(e, t, n) {
1025
1026
  for (let l = 0; l < n; l++)
1026
1027
  e[n * s + l] = a[(n - l - 1) * i + s];
1027
1028
  }
1028
- function Kt(e, t, n, r, o, i, a) {
1029
+ function rn(e, t, n, r, o, i, a) {
1029
1030
  if (t === _.None)
1030
1031
  return e;
1031
1032
  const s = o / 8, l = a === U.Separate ? 1 : i;
1032
1033
  for (let c = 0; c < r; c++) {
1033
- const d = c * l * n * s;
1034
- if (d >= e.byteLength)
1034
+ const u = c * l * n * s;
1035
+ if (u >= e.byteLength)
1035
1036
  break;
1036
1037
  if (t === _.Horizontal) {
1037
1038
  let h;
1038
- const g = l * n;
1039
+ const p = l * n;
1039
1040
  switch (o) {
1040
1041
  case 8:
1041
- h = new Uint8Array(e, d, g);
1042
+ h = new Uint8Array(e, u, p);
1042
1043
  break;
1043
1044
  case 16:
1044
- h = new Uint16Array(e, d, g);
1045
+ h = new Uint16Array(e, u, p);
1045
1046
  break;
1046
1047
  case 32:
1047
- h = new Uint32Array(e, d, g);
1048
+ h = new Uint32Array(e, u, p);
1048
1049
  break;
1049
1050
  default:
1050
1051
  throw new Error(`Predictor 2 not supported for ${o} bits per sample.`);
1051
1052
  }
1052
- Ot(h, l);
1053
+ tn(h, l);
1053
1054
  } else if (t === _.FloatingPoint) {
1054
- const h = new Uint8Array(e, d, l * n * s);
1055
- Mt(h, l, s);
1055
+ const h = new Uint8Array(e, u, l * n * s);
1056
+ nn(h, l, s);
1056
1057
  }
1057
1058
  }
1058
1059
  return e;
1059
1060
  }
1060
- async function Dt(e) {
1061
+ async function on(e) {
1061
1062
  return e;
1062
1063
  }
1063
- const A = /* @__PURE__ */ new Map();
1064
- A.set(m.None, () => Promise.resolve(Dt));
1065
- A.set(m.Deflate, () => Promise.resolve(xe));
1066
- A.set(m.DeflateOther, () => Promise.resolve(xe));
1067
- A.set(m.Lzw, () => import("./lzw-BY5a_5nb.js").then((e) => e.decode));
1068
- A.set(m.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
1069
- A.set(m.Jpeg, () => Promise.resolve(oe));
1070
- A.set(m.Jpeg6, () => Promise.resolve(oe));
1071
- A.set(m.Webp, () => Promise.resolve(oe));
1072
- A.set(m.Lerc, () => import("./lerc-BNW5A6zN.js").then((e) => e.l).then((e) => e.decode));
1073
- async function ie(e, t, n) {
1074
- const r = A.get(t);
1064
+ const j = /* @__PURE__ */ new Map();
1065
+ j.set(f.None, () => Promise.resolve(on));
1066
+ j.set(f.Deflate, () => Promise.resolve(Ye));
1067
+ j.set(f.DeflateOther, () => Promise.resolve(Ye));
1068
+ j.set(f.Lzw, () => import("./lzw-BY5a_5nb.js").then((e) => e.decode));
1069
+ j.set(f.Zstd, () => import("./zstd-jXobGRcq.js").then((e) => e.decode));
1070
+ j.set(f.Jpeg, () => Promise.resolve(le));
1071
+ j.set(f.Jpeg6, () => Promise.resolve(le));
1072
+ j.set(f.Webp, () => Promise.resolve(le));
1073
+ j.set(f.Lerc, () => import("./lerc-nHFgnN0N.js").then((e) => e.l).then((e) => e.decode));
1074
+ async function ce(e, t, n) {
1075
+ const r = j.get(t);
1075
1076
  if (!r)
1076
1077
  throw new Error(`Unsupported compression: ${t}`);
1077
1078
  const i = await (await r())(e, n);
1078
1079
  if (i instanceof ArrayBuffer) {
1079
- const { predictor: a, width: s, height: l, bitsPerSample: c, samplesPerPixel: d, planarConfiguration: h } = n, g = Kt(i, a, s, l, c, d, h);
1080
+ const { predictor: a, width: s, height: l, bitsPerSample: c, samplesPerPixel: u, planarConfiguration: h } = n, p = rn(i, a, s, l, c, u, h);
1080
1081
  return {
1081
1082
  layout: "pixel-interleaved",
1082
- data: Nt(g, n)
1083
+ data: sn(p, n)
1083
1084
  };
1084
1085
  }
1085
1086
  return i;
1086
1087
  }
1087
- function xt(e, t) {
1088
+ function an(e, t) {
1088
1089
  const n = new Uint8Array(e), r = new Uint8Array(t);
1089
1090
  for (let o = 0; o < t; o++)
1090
1091
  r[o] = n[o >> 3] >> 7 - (o & 7) & 1 ? 255 : 0;
1091
1092
  return r;
1092
1093
  }
1093
- function Nt(e, t) {
1094
+ function sn(e, t) {
1094
1095
  const { sampleFormat: n, bitsPerSample: r } = t;
1095
1096
  switch (n) {
1096
- case F.Uint:
1097
+ case A.Uint:
1097
1098
  switch (r) {
1098
1099
  case 1:
1099
- return xt(e, t.width * t.height * t.samplesPerPixel);
1100
+ return an(e, t.width * t.height * t.samplesPerPixel);
1100
1101
  case 8:
1101
1102
  return new Uint8Array(e);
1102
1103
  case 16:
@@ -1105,7 +1106,7 @@ function Nt(e, t) {
1105
1106
  return new Uint32Array(e);
1106
1107
  }
1107
1108
  break;
1108
- case F.Int:
1109
+ case A.Int:
1109
1110
  switch (r) {
1110
1111
  case 8:
1111
1112
  return new Int8Array(e);
@@ -1115,7 +1116,7 @@ function Nt(e, t) {
1115
1116
  return new Int32Array(e);
1116
1117
  }
1117
1118
  break;
1118
- case F.Float:
1119
+ case A.Float:
1119
1120
  switch (r) {
1120
1121
  case 32:
1121
1122
  return new Float32Array(e);
@@ -1126,7 +1127,7 @@ function Nt(e, t) {
1126
1127
  }
1127
1128
  throw new Error(`Unsupported sample format/depth: SampleFormat=${n}, BitsPerSample=${r}`);
1128
1129
  }
1129
- class zt {
1130
+ class ln {
1130
1131
  name = "source:cache";
1131
1132
  maxSize;
1132
1133
  /** Number of bytes cached in cacheA, when this overflows maxSize cacheA is moved to cacheB and cacheB is dropped */
@@ -1149,7 +1150,7 @@ class zt {
1149
1150
  return o ? (o.hits++, o.promise) : (o = this.cacheB.get(r), o ? (o.hits++, o.saves++, this.size += o.size, this.cacheA.set(r, o), o.promise) : (o = { promise: n(t), hits: 0, saves: 0, size: t.length }, this.size += o.size, this.size > this.maxSize && (this.size = o.size, this.cacheB = this.cacheA, this.cacheA = /* @__PURE__ */ new Map(), this.resets++), this.cacheA.set(r, o), o.promise));
1150
1151
  }
1151
1152
  }
1152
- class O extends Error {
1153
+ class M extends Error {
1153
1154
  /** Status code for the error eg 403 - Forbidden vs 404 Not found */
1154
1155
  code;
1155
1156
  /** URL that the status code came from */
@@ -1165,10 +1166,10 @@ class O extends Error {
1165
1166
  }
1166
1167
  /** Check that a unknown is a FsError */
1167
1168
  static is(t) {
1168
- return t instanceof O ? !0 : typeof t != "object" || t == null ? !1 : "_sourceError" in t && t._sourceError === "SourceError";
1169
+ return t instanceof M ? !0 : typeof t != "object" || t == null ? !1 : "_sourceError" in t && t._sourceError === "SourceError";
1169
1170
  }
1170
1171
  }
1171
- const X = {
1172
+ const Q = {
1172
1173
  /** Convert a offset/length to a range request
1173
1174
  *
1174
1175
  * @example
@@ -1205,7 +1206,7 @@ const X = {
1205
1206
  return o;
1206
1207
  }
1207
1208
  };
1208
- class Bt {
1209
+ class cn {
1209
1210
  source;
1210
1211
  middleware;
1211
1212
  static is(t) {
@@ -1246,14 +1247,14 @@ class Bt {
1246
1247
  return t({ source: this, offset: n, length: r, signal: o?.signal });
1247
1248
  }
1248
1249
  }
1249
- function _t(e) {
1250
+ function un(e) {
1250
1251
  try {
1251
1252
  return new URL(e);
1252
1253
  } catch {
1253
1254
  return null;
1254
1255
  }
1255
1256
  }
1256
- class kt {
1257
+ class dn {
1257
1258
  name = "source:chunk";
1258
1259
  /** Number of bytes to chunk requests into */
1259
1260
  chunkSize;
@@ -1265,7 +1266,7 @@ class kt {
1265
1266
  return n(t);
1266
1267
  const r = Math.floor(t.offset / this.chunkSize), o = Math.ceil((t.offset + t.length) / this.chunkSize), i = t.source.metadata?.size;
1267
1268
  if (i != null && t.offset + t.length > i)
1268
- throw new O(`Request outside of bounds ${X.toRange(t.offset, t.length)}`, 416, t.source);
1269
+ throw new M(`Request outside of bounds ${Q.toRange(t.offset, t.length)}`, 416, t.source);
1269
1270
  const a = r * this.chunkSize, l = (i != null ? Math.min(o * this.chunkSize, i) : o * this.chunkSize) - a, c = t.offset - a;
1270
1271
  return o - r > 1 ? (await this.fetchChunks(t, r, o)).slice(c, c + t.length) : t.offset === a && t.length === l ? n(t) : (await n({ ...t, offset: a, length: l })).slice(c, c + t.length);
1271
1272
  }
@@ -1281,15 +1282,15 @@ class kt {
1281
1282
  return s.buffer;
1282
1283
  }
1283
1284
  }
1284
- function Ge(e) {
1285
+ function Ae(e) {
1285
1286
  const t = {}, n = e.headers.get("content-length");
1286
1287
  n && (t.size = parseInt(n));
1287
1288
  const r = e.headers.get("content-range");
1288
- return r != null && (t.size = X.parseSize(r)), t.eTag = e.headers.get("etag") ?? void 0, t.contentType = e.headers.get("content-type") ?? void 0, t.contentDisposition = e.headers.get("content-disposition") ?? void 0, t.cacheControl = e.headers.get("cache-control") ?? void 0, t.contentEncoding = e.headers.get("content-encoding") ?? void 0, t;
1289
+ return r != null && (t.size = Q.parseSize(r)), t.eTag = e.headers.get("etag") ?? void 0, t.contentType = e.headers.get("content-type") ?? void 0, t.contentDisposition = e.headers.get("content-disposition") ?? void 0, t.cacheControl = e.headers.get("cache-control") ?? void 0, t.contentEncoding = e.headers.get("content-encoding") ?? void 0, t;
1289
1290
  }
1290
- class k {
1291
+ class $ {
1291
1292
  constructor(t, n) {
1292
- this.type = "http", this.url = typeof t == "string" ? k.tryUrl(t) : t, this.headers = n;
1293
+ this.type = "http", this.url = typeof t == "string" ? $.tryUrl(t) : t, this.headers = n;
1293
1294
  }
1294
1295
  /** Attempt to parse a relative string into a URL */
1295
1296
  static tryUrl(t) {
@@ -1300,36 +1301,36 @@ class k {
1300
1301
  }
1301
1302
  }
1302
1303
  head() {
1303
- return this._head ? this._head : (this._head = k.fetch(this.url, { method: "HEAD", headers: this.headers }).then((t) => {
1304
+ return this._head ? this._head : (this._head = $.fetch(this.url, { method: "HEAD", headers: this.headers }).then((t) => {
1304
1305
  if (!t.ok)
1305
1306
  throw delete this._head, new Error(`Failed to HEAD ${this.url.href}`, { cause: { statusCode: t.status, msg: t.statusText } });
1306
- return this.metadata = Ge(t), this.metadata;
1307
+ return this.metadata = Ae(t), this.metadata;
1307
1308
  }), this._head);
1308
1309
  }
1309
1310
  async fetch(t, n, r) {
1310
1311
  try {
1311
- const o = { range: X.toRange(t, n), ...this.headers }, i = await k.fetch(this.url, { headers: o, signal: r?.signal });
1312
+ const o = { range: Q.toRange(t, n), ...this.headers }, i = await $.fetch(this.url, { headers: o, signal: r?.signal });
1312
1313
  if (!i.ok)
1313
- throw new O(`Failed to fetch ${this.url.href} ${o.range}`, i.status, this, new Error(i.statusText));
1314
- const a = Ge(i);
1314
+ throw new M(`Failed to fetch ${this.url.href} ${o.range}`, i.status, this, new Error(i.statusText));
1315
+ const a = Ae(i);
1315
1316
  if (this.metadata == null)
1316
1317
  this.metadata = a;
1317
1318
  else if (this.metadata.eTag && this.metadata.eTag !== a.eTag)
1318
- throw new O(`ETag conflict ${this.url.href} ${o.range} expected: ${this.metadata.eTag} got: ${a.eTag}`, 409, this);
1319
+ throw new M(`ETag conflict ${this.url.href} ${o.range} expected: ${this.metadata.eTag} got: ${a.eTag}`, 409, this);
1319
1320
  return i.arrayBuffer();
1320
1321
  } catch (o) {
1321
- throw O.is(o) && o.source === this ? o : new O(`Failed to fetch: ${this.url.href}`, 500, this, o);
1322
+ throw M.is(o) && o.source === this ? o : new M(`Failed to fetch: ${this.url.href}`, 500, this, o);
1322
1323
  }
1323
1324
  }
1324
1325
  }
1325
- k.fetch = (e, t) => fetch(e, t);
1326
- function $t(e) {
1326
+ $.fetch = (e, t) => fetch(e, t);
1327
+ function hn(e) {
1327
1328
  if (typeof e != "string")
1328
1329
  return e;
1329
- const t = _t(e);
1330
+ const t = un(e);
1330
1331
  return t || new URL("memory://" + e);
1331
1332
  }
1332
- class ae {
1333
+ class ue {
1333
1334
  url;
1334
1335
  type = "memory";
1335
1336
  data;
@@ -1338,49 +1339,49 @@ class ae {
1338
1339
  return t instanceof ArrayBuffer ? t : t.byteLength === t.buffer.byteLength ? t.buffer : t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength);
1339
1340
  }
1340
1341
  constructor(t, n) {
1341
- const r = ae.toArrayBuffer(n ?? new Uint8Array());
1342
- this.url = $t(t), this.data = r, this.metadata = { size: r.byteLength };
1342
+ const r = ue.toArrayBuffer(n ?? new Uint8Array());
1343
+ this.url = hn(t), this.data = r, this.metadata = { size: r.byteLength };
1343
1344
  }
1344
1345
  head() {
1345
1346
  return Promise.resolve({ size: this.data.byteLength });
1346
1347
  }
1347
1348
  fetch(t, n) {
1348
1349
  if (t < 0 && (t = this.data.byteLength + t), t > this.data.byteLength)
1349
- throw new O(`Read offset outside of file bounds range:${X.toRange(t, n)} fileSize:${this.data.byteLength}`, 416, this);
1350
+ throw new M(`Read offset outside of file bounds range:${Q.toRange(t, n)} fileSize:${this.data.byteLength}`, 416, this);
1350
1351
  return Promise.resolve(this.data.slice(t, n == null ? void 0 : t + n));
1351
1352
  }
1352
1353
  }
1353
- const Ne = "https://proj.org/schemas/v0.7/projjson.schema.json", Wt = 1, Jt = 2, V = 32767, je = 1, Vt = 2, Ht = 3, Yt = 4, Xt = 5, Zt = 6, Qt = 7, qt = 8, Tt = 9, en = 10, tn = 11, nn = 12, rn = 14, on = 15, an = 16, sn = 17, ln = 18, cn = 21, un = 22, dn = 24, hn = 26, pn = 27, ze = 9102, gn = 9101, mn = 9105, fn = {
1354
- [ze]: "degree",
1355
- [gn]: "radian",
1356
- [mn]: "grad"
1357
- }, Be = 9001, yn = 9002, wn = 9003, Sn = {
1354
+ const Xe = "https://proj.org/schemas/v0.7/projjson.schema.json", pn = 1, mn = 2, V = 32767, je = 1, gn = 2, fn = 3, yn = 4, wn = 5, Sn = 6, Pn = 7, bn = 8, Cn = 9, Ln = 10, In = 11, Gn = 12, vn = 14, En = 15, Fn = 16, An = 17, jn = 18, Rn = 21, Un = 22, Mn = 24, On = 26, Kn = 27, Ze = 9102, xn = 9101, Dn = 9105, Nn = {
1355
+ [Ze]: "degree",
1356
+ [xn]: "radian",
1357
+ [Dn]: "grad"
1358
+ }, Qe = 9001, zn = 9002, Bn = 9003, _n = {
1358
1359
  type: "LinearUnit",
1359
1360
  name: "US survey foot",
1360
1361
  conversion_factor: 0.30480060960121924
1361
- }, Pn = {
1362
- [Be]: "metre",
1363
- [yn]: "foot",
1364
- [wn]: Sn
1362
+ }, $n = {
1363
+ [Qe]: "metre",
1364
+ [zn]: "foot",
1365
+ [Bn]: _n
1365
1366
  };
1366
- function Cn(e) {
1367
+ function kn(e) {
1367
1368
  const t = e.modelType;
1368
- if (t === Wt)
1369
- return bn(e);
1370
- if (t === Jt)
1371
- return Ln(e);
1369
+ if (t === pn)
1370
+ return Jn(e);
1371
+ if (t === mn)
1372
+ return Wn(e);
1372
1373
  throw new Error(`Unsupported GeoTIFF model type: ${t}`);
1373
1374
  }
1374
- function Ln(e) {
1375
+ function Wn(e) {
1375
1376
  const t = e.geodeticCRS;
1376
- return t !== null && t !== V ? t : _e(e, Ne);
1377
+ return t !== null && t !== V ? t : qe(e, Xe);
1377
1378
  }
1378
- function bn(e) {
1379
+ function Jn(e) {
1379
1380
  const t = e.projectedCRS;
1380
- return t !== null && t !== V ? t : In(e);
1381
+ return t !== null && t !== V ? t : Vn(e);
1381
1382
  }
1382
- function _e(e, t) {
1383
- const n = Gn(e);
1383
+ function qe(e, t) {
1384
+ const n = Hn(e);
1384
1385
  let r = "Greenwich", o = 0;
1385
1386
  e.primeMeridian !== null && e.primeMeridian !== V ? r = `EPSG:${e.primeMeridian}` : e.primeMeridianLongitude !== null && (o = e.primeMeridianLongitude, r = "User-defined");
1386
1387
  let i;
@@ -1397,22 +1398,22 @@ function _e(e, t) {
1397
1398
  type: "GeographicCRS",
1398
1399
  name: e.geodeticCitation ?? "User-defined",
1399
1400
  datum: i,
1400
- coordinate_system: En(e)
1401
+ coordinate_system: Xn(e)
1401
1402
  };
1402
1403
  return t !== void 0 && (a.$schema = t), a;
1403
1404
  }
1404
- function In(e) {
1405
- const t = _e(e), n = jn(e), r = Fn(e);
1405
+ function Vn(e) {
1406
+ const t = qe(e), n = Yn(e), r = Zn(e);
1406
1407
  return {
1407
1408
  type: "ProjectedCRS",
1408
- $schema: Ne,
1409
+ $schema: Xe,
1409
1410
  name: e.projectedCitation ?? e.citation ?? "User-defined",
1410
1411
  base_crs: t,
1411
1412
  conversion: n,
1412
1413
  coordinate_system: r
1413
1414
  };
1414
1415
  }
1415
- function Gn(e) {
1416
+ function Hn(e) {
1416
1417
  if (e.ellipsoid !== null && e.ellipsoid !== V) {
1417
1418
  const n = {
1418
1419
  name: `EPSG ellipsoid ${e.ellipsoid}`
@@ -1433,7 +1434,7 @@ function Gn(e) {
1433
1434
  throw new Error("User-defined ellipsoid requires ellipsoidInvFlattening or ellipsoidSemiMinorAxis");
1434
1435
  return t;
1435
1436
  }
1436
- function jn(e) {
1437
+ function Yn(e) {
1437
1438
  const t = e.projMethod;
1438
1439
  if (t === null)
1439
1440
  throw new Error("User-defined projected CRS requires projMethod");
@@ -1452,8 +1453,8 @@ function jn(e) {
1452
1453
  });
1453
1454
  switch (t) {
1454
1455
  case je:
1455
- case Vt:
1456
- case pn: {
1456
+ case gn:
1457
+ case Kn: {
1457
1458
  const i = t === je ? "Transverse Mercator" : "Transverse Mercator (South Orientated)";
1458
1459
  return {
1459
1460
  name: i,
@@ -1467,10 +1468,10 @@ function jn(e) {
1467
1468
  ]
1468
1469
  };
1469
1470
  }
1470
- case Ht:
1471
- case Yt:
1472
- case Xt:
1473
- case Zt: {
1471
+ case fn:
1472
+ case yn:
1473
+ case wn:
1474
+ case Sn: {
1474
1475
  const i = "Hotine Oblique Mercator (variant B)";
1475
1476
  return {
1476
1477
  name: i,
@@ -1486,7 +1487,7 @@ function jn(e) {
1486
1487
  ]
1487
1488
  };
1488
1489
  }
1489
- case Qt: {
1490
+ case Pn: {
1490
1491
  const i = "Mercator (variant A)";
1491
1492
  return {
1492
1493
  name: i,
@@ -1500,7 +1501,7 @@ function jn(e) {
1500
1501
  ]
1501
1502
  };
1502
1503
  }
1503
- case qt: {
1504
+ case bn: {
1504
1505
  const i = "Lambert Conic Conformal (2SP)";
1505
1506
  return {
1506
1507
  name: i,
@@ -1515,7 +1516,7 @@ function jn(e) {
1515
1516
  ]
1516
1517
  };
1517
1518
  }
1518
- case Tt: {
1519
+ case Cn: {
1519
1520
  const i = "Lambert Conic Conformal (1SP)";
1520
1521
  return {
1521
1522
  name: i,
@@ -1529,7 +1530,7 @@ function jn(e) {
1529
1530
  ]
1530
1531
  };
1531
1532
  }
1532
- case en: {
1533
+ case Ln: {
1533
1534
  const i = "Lambert Azimuthal Equal Area";
1534
1535
  return {
1535
1536
  name: i,
@@ -1542,7 +1543,7 @@ function jn(e) {
1542
1543
  ]
1543
1544
  };
1544
1545
  }
1545
- case tn: {
1546
+ case In: {
1546
1547
  const i = "Albers Equal Area";
1547
1548
  return {
1548
1549
  name: i,
@@ -1557,7 +1558,7 @@ function jn(e) {
1557
1558
  ]
1558
1559
  };
1559
1560
  }
1560
- case nn: {
1561
+ case Gn: {
1561
1562
  const i = "Modified Azimuthal Equidistant";
1562
1563
  return {
1563
1564
  name: i,
@@ -1570,7 +1571,7 @@ function jn(e) {
1570
1571
  ]
1571
1572
  };
1572
1573
  }
1573
- case rn: {
1574
+ case vn: {
1574
1575
  const i = "Stereographic";
1575
1576
  return {
1576
1577
  name: i,
@@ -1584,7 +1585,7 @@ function jn(e) {
1584
1585
  ]
1585
1586
  };
1586
1587
  }
1587
- case on: {
1588
+ case En: {
1588
1589
  const i = "Polar Stereographic (variant B)";
1589
1590
  return {
1590
1591
  name: i,
@@ -1597,7 +1598,7 @@ function jn(e) {
1597
1598
  ]
1598
1599
  };
1599
1600
  }
1600
- case an: {
1601
+ case Fn: {
1601
1602
  const i = "Oblique Stereographic";
1602
1603
  return {
1603
1604
  name: i,
@@ -1611,7 +1612,7 @@ function jn(e) {
1611
1612
  ]
1612
1613
  };
1613
1614
  }
1614
- case sn: {
1615
+ case An: {
1615
1616
  const i = "Equidistant Cylindrical";
1616
1617
  return {
1617
1618
  name: i,
@@ -1624,7 +1625,7 @@ function jn(e) {
1624
1625
  ]
1625
1626
  };
1626
1627
  }
1627
- case ln: {
1628
+ case jn: {
1628
1629
  const i = "Cassini-Soldner";
1629
1630
  return {
1630
1631
  name: i,
@@ -1637,7 +1638,7 @@ function jn(e) {
1637
1638
  ]
1638
1639
  };
1639
1640
  }
1640
- case un: {
1641
+ case Un: {
1641
1642
  const i = "American Polyconic";
1642
1643
  return {
1643
1644
  name: i,
@@ -1650,7 +1651,7 @@ function jn(e) {
1650
1651
  ]
1651
1652
  };
1652
1653
  }
1653
- case dn: {
1654
+ case Mn: {
1654
1655
  const i = "Sinusoidal";
1655
1656
  return {
1656
1657
  name: i,
@@ -1662,7 +1663,7 @@ function jn(e) {
1662
1663
  ]
1663
1664
  };
1664
1665
  }
1665
- case cn: {
1666
+ case Rn: {
1666
1667
  const i = "Orthographic";
1667
1668
  return {
1668
1669
  name: i,
@@ -1675,7 +1676,7 @@ function jn(e) {
1675
1676
  ]
1676
1677
  };
1677
1678
  }
1678
- case hn: {
1679
+ case On: {
1679
1680
  const i = "New Zealand Map Grid";
1680
1681
  return {
1681
1682
  name: i,
@@ -1692,8 +1693,8 @@ function jn(e) {
1692
1693
  throw new Error(`Unsupported coordinate transformation type: ${t}`);
1693
1694
  }
1694
1695
  }
1695
- function En(e) {
1696
- const t = fn[e.angularUnits ?? ze] ?? "degree";
1696
+ function Xn(e) {
1697
+ const t = Nn[e.angularUnits ?? Ze] ?? "degree";
1697
1698
  return {
1698
1699
  subtype: "ellipsoidal",
1699
1700
  axis: [
@@ -1712,8 +1713,8 @@ function En(e) {
1712
1713
  ]
1713
1714
  };
1714
1715
  }
1715
- function Fn(e) {
1716
- const t = Pn[e.projLinearUnits ?? Be] ?? "metre";
1716
+ function Zn(e) {
1717
+ const t = $n[e.projLinearUnits ?? Qe] ?? "metre";
1717
1718
  return {
1718
1719
  subtype: "Cartesian",
1719
1720
  axis: [
@@ -1722,20 +1723,20 @@ function Fn(e) {
1722
1723
  ]
1723
1724
  };
1724
1725
  }
1725
- const An = 1024 * 1024, Rn = 16 * 1024 * 1024, Ee = 6;
1726
- async function vn(e, t, n) {
1726
+ const Qn = 1024 * 1024, qn = 16 * 1024 * 1024, Re = 6;
1727
+ async function Tn(e, t, n) {
1727
1728
  if (t.length === 0)
1728
1729
  return [];
1729
- const r = n?.coalesce ?? An, o = n?.maxRangeSize ?? Rn, i = n?.signal, a = Un(t, r, o), s = await Mn(e, a, i), l = new Array(t.length);
1730
+ const r = n?.coalesce ?? Qn, o = n?.maxRangeSize ?? qn, i = n?.signal, a = er(t, r, o), s = await nr(e, a, i), l = new Array(t.length);
1730
1731
  for (let c = 0; c < t.length; c++) {
1731
- const d = t[c], h = On(a, d.offset), g = a[h], f = s[h], S = d.offset - g.offset, P = S + d.length;
1732
- if (P > f.byteLength)
1733
- throw new Error(`Failed to fetch bytes from offset:${d.offset} wanted:${d.length} got:${f.byteLength - S}`);
1734
- l[c] = f.slice(S, P);
1732
+ const u = t[c], h = tr(a, u.offset), p = a[h], g = s[h], y = u.offset - p.offset, S = y + u.length;
1733
+ if (S > g.byteLength)
1734
+ throw new Error(`Failed to fetch bytes from offset:${u.offset} wanted:${u.length} got:${g.byteLength - y}`);
1735
+ l[c] = g.slice(y, S);
1735
1736
  }
1736
1737
  return l;
1737
1738
  }
1738
- function Un(e, t, n) {
1739
+ function er(e, t, n) {
1739
1740
  const r = [...e].sort((a, s) => a.offset - s.offset), o = [];
1740
1741
  let i = null;
1741
1742
  for (const a of r) {
@@ -1743,12 +1744,12 @@ function Un(e, t, n) {
1743
1744
  i = { offset: a.offset, length: a.length };
1744
1745
  continue;
1745
1746
  }
1746
- const s = i.offset + i.length, l = a.offset + a.length, c = a.offset - s, d = Math.max(s, l), h = d - i.offset;
1747
- c <= t && h <= n ? i.length = d - i.offset : (o.push(i), i = { offset: a.offset, length: a.length });
1747
+ const s = i.offset + i.length, l = a.offset + a.length, c = a.offset - s, u = Math.max(s, l), h = u - i.offset;
1748
+ c <= t && h <= n ? i.length = u - i.offset : (o.push(i), i = { offset: a.offset, length: a.length });
1748
1749
  }
1749
1750
  return i != null && o.push(i), o;
1750
1751
  }
1751
- function On(e, t) {
1752
+ function tr(e, t) {
1752
1753
  let n = 0, r = e.length - 1;
1753
1754
  for (; n < r; ) {
1754
1755
  const o = n + r + 1 >>> 1;
@@ -1756,82 +1757,82 @@ function On(e, t) {
1756
1757
  }
1757
1758
  return n;
1758
1759
  }
1759
- async function Mn(e, t, n) {
1760
+ async function nr(e, t, n) {
1760
1761
  const r = new Array(t.length);
1761
- for (let o = 0; o < t.length; o += Ee) {
1762
- const i = t.slice(o, o + Ee), a = await Promise.all(i.map((s) => e.fetch(s.offset, s.length, { signal: n })));
1762
+ for (let o = 0; o < t.length; o += Re) {
1763
+ const i = t.slice(o, o + Re), a = await Promise.all(i.map((s) => e.fetch(s.offset, s.length, { signal: n })));
1763
1764
  for (let s = 0; s < a.length; s++)
1764
1765
  r[o + s] = a[s];
1765
1766
  }
1766
1767
  return r;
1767
1768
  }
1768
- async function ke(e, t, n, { boundless: r = !0, pool: o, signal: i } = {}) {
1769
- const a = xn(e, t, n, { signal: i }), s = e.maskImage != null ? Ve(e.maskImage, t, n, e.dataSource, {
1769
+ async function Te(e, t, n, { boundless: r = !0, pool: o, signal: i } = {}) {
1770
+ const a = ir(e, t, n, { signal: i }), s = e.maskImage != null ? rt(e.maskImage, t, n, e.dataSource, {
1770
1771
  signal: i,
1771
1772
  debug: e._debug ? { label: "mask" } : void 0
1772
1773
  }) : Promise.resolve(null), [l, c] = await Promise.all([a, s]);
1773
- return $e(e, t, n, l, c, { boundless: r, pool: o });
1774
+ return et(e, t, n, l, c, { boundless: r, pool: o });
1774
1775
  }
1775
- async function $e(e, t, n, r, o, { boundless: i, pool: a }) {
1776
- const { bitsPerSample: s, predictor: l, planarConfiguration: c, sampleFormat: d, lercParameters: h } = e.cachedTags, { sampleFormat: g, bitsPerSample: f } = Ze(d, s), S = re(e.transform, Ae(t * e.tileWidth, n * e.tileHeight)), P = e.image.value(u.SamplesPerPixel) ?? 1, C = {
1777
- sampleFormat: g,
1778
- bitsPerSample: f,
1779
- samplesPerPixel: P,
1776
+ async function et(e, t, n, r, o, { boundless: i, pool: a }) {
1777
+ const { bitsPerSample: s, predictor: l, planarConfiguration: c, sampleFormat: u, lercParameters: h } = e.cachedTags, { sampleFormat: p, bitsPerSample: g } = st(u, s), y = se(e.transform, ze(t * e.tileWidth, n * e.tileHeight)), S = e.image.value(d.SamplesPerPixel) ?? 1, b = {
1778
+ sampleFormat: p,
1779
+ bitsPerSample: g,
1780
+ samplesPerPixel: S,
1780
1781
  width: e.tileWidth,
1781
1782
  height: e.tileHeight,
1782
1783
  predictor: l,
1783
1784
  planarConfiguration: c,
1784
1785
  lercParameters: h
1785
- }, [j, b] = await Promise.all([
1786
- Dn(r, C, a),
1787
- o != null && e.maskImage != null ? Kn(o, e.maskImage, a) : Promise.resolve(null)
1788
- ]), G = {
1789
- ...j,
1790
- count: P,
1786
+ }, [v, C] = await Promise.all([
1787
+ or(r, b, a),
1788
+ o != null && e.maskImage != null ? rr(o, e.maskImage, a) : Promise.resolve(null)
1789
+ ]), L = {
1790
+ ...v,
1791
+ count: S,
1791
1792
  height: e.tileHeight,
1792
1793
  width: e.tileWidth,
1793
- mask: b,
1794
- transform: S,
1794
+ mask: C,
1795
+ transform: y,
1795
1796
  crs: e.crs,
1796
1797
  nodata: e.nodata
1797
1798
  };
1798
1799
  return {
1799
1800
  x: t,
1800
1801
  y: n,
1801
- array: i === !0 ? G : _n(e, t, n, G)
1802
+ array: i === !0 ? L : cr(e, t, n, L)
1802
1803
  };
1803
1804
  }
1804
- async function We(e, t, { boundless: n = !0, pool: r, signal: o } = {}) {
1805
+ async function tt(e, t, { boundless: n = !0, pool: r, signal: o } = {}) {
1805
1806
  if (t.length === 0)
1806
1807
  return [];
1807
- const i = zn(e, t, { signal: o }), a = e.maskImage != null ? Xe(e.maskImage, t, e.dataSource, {
1808
+ const i = sr(e, t, { signal: o }), a = e.maskImage != null ? at(e.maskImage, t, e.dataSource, {
1808
1809
  signal: o,
1809
1810
  debug: e._debug ? { label: "mask" } : void 0
1810
1811
  }) : Promise.resolve(t.map(() => null)), [s, l] = await Promise.all([
1811
1812
  i,
1812
1813
  a
1813
1814
  ]);
1814
- return Promise.all(t.map(([c, d], h) => $e(e, c, d, s[h], l[h] ?? null, {
1815
+ return Promise.all(t.map(([c, u], h) => et(e, c, u, s[h], l[h] ?? null, {
1815
1816
  boundless: n,
1816
1817
  pool: r
1817
1818
  })));
1818
1819
  }
1819
- async function Kn(e, t, n) {
1820
- const r = t.value(u.SampleFormat) ?? [1], o = t.value(u.BitsPerSample) ?? [8], { sampleFormat: i, bitsPerSample: a } = Ze(r, new Uint16Array(o)), { width: s, height: l } = t.tileSize, c = {
1820
+ async function rr(e, t, n) {
1821
+ const r = t.value(d.SampleFormat) ?? [1], o = t.value(d.BitsPerSample) ?? [8], { sampleFormat: i, bitsPerSample: a } = st(r, new Uint16Array(o)), { width: s, height: l } = t.tileSize, c = {
1821
1822
  sampleFormat: i,
1822
1823
  bitsPerSample: a,
1823
- samplesPerPixel: t.value(u.SamplesPerPixel) ?? 1,
1824
+ samplesPerPixel: t.value(d.SamplesPerPixel) ?? 1,
1824
1825
  width: s,
1825
1826
  height: l,
1826
- predictor: t.value(u.Predictor) ?? 1,
1827
- planarConfiguration: t.value(u.PlanarConfiguration) ?? U.Contig
1828
- }, d = (P, C, j) => n ? n.decode(P, C, j) : ie(P, C, j), { bytes: h, compression: g } = e, f = await d(h, g, c), S = f.layout === "pixel-interleaved" ? f.data : f.bands[0];
1829
- if (S instanceof Uint8Array)
1830
- return S;
1827
+ predictor: t.value(d.Predictor) ?? 1,
1828
+ planarConfiguration: t.value(d.PlanarConfiguration) ?? U.Contig
1829
+ }, u = (S, b, v) => n ? n.decode(S, b, v) : ce(S, b, v), { bytes: h, compression: p } = e, g = await u(h, p, c), y = g.layout === "pixel-interleaved" ? g.data : g.bands[0];
1830
+ if (y instanceof Uint8Array)
1831
+ return y;
1831
1832
  throw new Error("Expected mask data to decode to Uint8Array");
1832
1833
  }
1833
- async function Dn(e, t, n) {
1834
- const r = (o, i, a) => n ? n.decode(o, i, a) : ie(o, i, a);
1834
+ async function or(e, t, n) {
1835
+ const r = (o, i, a) => n ? n.decode(o, i, a) : ce(o, i, a);
1835
1836
  if (Array.isArray(e)) {
1836
1837
  const o = { ...t, samplesPerPixel: 1 };
1837
1838
  return { layout: "band-separate", bands: (await Promise.all(e.map(({ bytes: s, compression: l }) => r(s, l, o)))).map((s) => s.layout === "band-separate" ? s.bands[0] : s.data) };
@@ -1840,11 +1841,11 @@ async function Dn(e, t, n) {
1840
1841
  return r(o, i, t);
1841
1842
  }
1842
1843
  }
1843
- async function xn(e, t, n, { signal: r } = {}) {
1844
+ async function ir(e, t, n, { signal: r } = {}) {
1844
1845
  const o = e._debug ? { label: "data" } : void 0;
1845
1846
  switch (e.cachedTags.planarConfiguration) {
1846
1847
  case U.Contig: {
1847
- const i = await Ve(e.image, t, n, e.dataSource, {
1848
+ const i = await rt(e.image, t, n, e.dataSource, {
1848
1849
  signal: r,
1849
1850
  debug: o
1850
1851
  });
@@ -1853,32 +1854,32 @@ async function xn(e, t, n, { signal: r } = {}) {
1853
1854
  return i;
1854
1855
  }
1855
1856
  case U.Separate:
1856
- return await Nn(e, t, n, { signal: r });
1857
+ return await ar(e, t, n, { signal: r });
1857
1858
  default:
1858
1859
  throw new Error(`Unsupported PlanarConfiguration: ${e.cachedTags.planarConfiguration}`);
1859
1860
  }
1860
1861
  }
1861
- async function Je(e, t, n) {
1862
+ async function nt(e, t, n) {
1862
1863
  const { x: r, y: o } = e.image.tileCount, i = r * o, a = e.cachedTags.samplesPerPixel, s = [...Array(a).keys()].map((l) => {
1863
1864
  const c = l * i + n * r + t;
1864
1865
  return e.image.getTileSize(c);
1865
1866
  });
1866
1867
  return Promise.all(s);
1867
1868
  }
1868
- async function Nn(e, t, n, { signal: r } = {}) {
1869
- const o = e._debug ? { label: "data" } : void 0, a = (await Je(e, t, n)).map(async ({ offset: s, imageSize: l }) => {
1870
- const c = await He(e.image, s, l, e.dataSource, { signal: r, debug: o });
1869
+ async function ar(e, t, n, { signal: r } = {}) {
1870
+ const o = e._debug ? { label: "data" } : void 0, a = (await nt(e, t, n)).map(async ({ offset: s, imageSize: l }) => {
1871
+ const c = await ot(e.image, s, l, e.dataSource, { signal: r, debug: o });
1871
1872
  if (c === null)
1872
1873
  throw new Error(`Tile at (${t}, ${n}) not found`);
1873
1874
  return c;
1874
1875
  });
1875
1876
  return Promise.all(a);
1876
1877
  }
1877
- async function zn(e, t, { signal: n } = {}) {
1878
+ async function sr(e, t, { signal: n } = {}) {
1878
1879
  const r = e._debug ? { label: "data" } : void 0;
1879
1880
  switch (e.cachedTags.planarConfiguration) {
1880
1881
  case U.Contig:
1881
- return (await Xe(e.image, t, e.dataSource, {
1882
+ return (await at(e.image, t, e.dataSource, {
1882
1883
  signal: n,
1883
1884
  debug: r
1884
1885
  })).map((i, a) => {
@@ -1889,95 +1890,95 @@ async function zn(e, t, { signal: n } = {}) {
1889
1890
  return i;
1890
1891
  });
1891
1892
  case U.Separate:
1892
- return Bn(e, t, { signal: n });
1893
+ return lr(e, t, { signal: n });
1893
1894
  default:
1894
1895
  throw new Error(`Unsupported PlanarConfiguration: ${e.cachedTags.planarConfiguration}`);
1895
1896
  }
1896
1897
  }
1897
- async function Bn(e, t, { signal: n } = {}) {
1898
- const r = e._debug ? { label: "data" } : void 0, o = e.cachedTags.samplesPerPixel, a = (await Promise.all(t.map(([l, c]) => Je(e, l, c)))).flatMap((l) => l.map(({ offset: c, imageSize: d }) => ({
1898
+ async function lr(e, t, { signal: n } = {}) {
1899
+ const r = e._debug ? { label: "data" } : void 0, o = e.cachedTags.samplesPerPixel, a = (await Promise.all(t.map(([l, c]) => nt(e, l, c)))).flatMap((l) => l.map(({ offset: c, imageSize: u }) => ({
1899
1900
  offset: c,
1900
- byteCount: d
1901
- }))), s = await Ye(e.image, a, e.dataSource, { signal: n, debug: r });
1902
- return t.map(([l, c], d) => s.slice(d * o, d * o + o).map((h) => {
1901
+ byteCount: u
1902
+ }))), s = await it(e.image, a, e.dataSource, { signal: n, debug: r });
1903
+ return t.map(([l, c], u) => s.slice(u * o, u * o + o).map((h) => {
1903
1904
  if (h === null)
1904
1905
  throw new Error(`Tile at (${l}, ${c}) not found`);
1905
1906
  return h;
1906
1907
  }));
1907
1908
  }
1908
- async function Ve(e, t, n, r, o) {
1909
+ async function rt(e, t, n, r, o) {
1909
1910
  const { size: i, tileSize: a } = e;
1910
1911
  if (a == null)
1911
1912
  throw new Error("Tiff is not tiled");
1912
1913
  const s = Math.ceil(i.height / a.height), l = Math.ceil(i.width / a.width);
1913
1914
  if (t >= l || n >= s)
1914
1915
  throw new Error(`Tile index is outside of range x:${t} >= ${l} or y:${n} >= ${s}`);
1915
- const c = n * l + t, d = l * s;
1916
- if (c >= d)
1917
- throw new Error(`Tile index is outside of tile range: ${c} >= ${d}`);
1918
- const { offset: h, imageSize: g } = await e.getTileSize(c);
1919
- return He(e, h, g, r, o);
1916
+ const c = n * l + t, u = l * s;
1917
+ if (c >= u)
1918
+ throw new Error(`Tile index is outside of tile range: ${c} >= ${u}`);
1919
+ const { offset: h, imageSize: p } = await e.getTileSize(c);
1920
+ return ot(e, h, p, r, o);
1920
1921
  }
1921
- async function He(e, t, n, r, o) {
1922
+ async function ot(e, t, n, r, o) {
1922
1923
  if (n === 0)
1923
1924
  return null;
1924
1925
  o?.debug !== void 0 && console.log(`[geotiff dataSource] ${o.debug.label}: offset=${t} length=${n}`);
1925
1926
  const i = await r.fetch(t, n, o);
1926
1927
  if (i.byteLength < n)
1927
1928
  throw new Error(`Failed to fetch bytes from offset:${t} wanted:${n} got:${i.byteLength}`);
1928
- const a = e.value(u.Compression) ?? m.None;
1929
- return a === m.Jpeg ? {
1929
+ const a = e.value(d.Compression) ?? f.None;
1930
+ return a === f.Jpeg ? {
1930
1931
  bytes: e.getJpegHeader(i),
1931
1932
  compression: a
1932
1933
  } : { bytes: i, compression: a };
1933
1934
  }
1934
- async function Ye(e, t, n, r) {
1935
+ async function it(e, t, n, r) {
1935
1936
  if (t.length === 0)
1936
1937
  return [];
1937
1938
  const o = new Array(t.length), i = [], a = [];
1938
1939
  for (let c = 0; c < t.length; c++) {
1939
- const d = t[c];
1940
- d.offset === 0 || d.byteCount === 0 ? o[c] = null : (a.push(c), i.push({ offset: d.offset, length: d.byteCount }));
1940
+ const u = t[c];
1941
+ u.offset === 0 || u.byteCount === 0 ? o[c] = null : (a.push(c), i.push({ offset: u.offset, length: u.byteCount }));
1941
1942
  }
1942
1943
  if (i.length === 0)
1943
1944
  return o;
1944
1945
  if (r?.debug !== void 0)
1945
1946
  for (const c of i)
1946
1947
  console.log(`[geotiff dataSource] ${r.debug.label}: offset=${c.offset} length=${c.length}`);
1947
- const s = await vn(n, i, {
1948
+ const s = await Tn(n, i, {
1948
1949
  coalesce: r?.coalesce,
1949
1950
  maxRangeSize: r?.maxRangeSize,
1950
1951
  signal: r?.signal
1951
- }), l = e.value(u.Compression) ?? m.None;
1952
+ }), l = e.value(d.Compression) ?? f.None;
1952
1953
  for (let c = 0; c < s.length; c++) {
1953
- const d = a[c], h = s[c], g = l === m.Jpeg ? e.getJpegHeader(h) : h;
1954
- o[d] = { bytes: g, compression: l };
1954
+ const u = a[c], h = s[c], p = l === f.Jpeg ? e.getJpegHeader(h) : h;
1955
+ o[u] = { bytes: p, compression: l };
1955
1956
  }
1956
1957
  return o;
1957
1958
  }
1958
- async function Xe(e, t, n, r) {
1959
+ async function at(e, t, n, r) {
1959
1960
  if (t.length === 0)
1960
1961
  return [];
1961
1962
  const { size: o, tileSize: i } = e;
1962
1963
  if (i == null)
1963
1964
  throw new Error("Tiff is not tiled");
1964
- const a = Math.ceil(o.height / i.height), s = Math.ceil(o.width / i.width), l = s * a, c = t.map(([h, g]) => {
1965
- if (h >= s || g >= a)
1966
- throw new Error(`Tile index is outside of range x:${h} >= ${s} or y:${g} >= ${a}`);
1967
- const f = g * s + h;
1968
- if (f >= l)
1969
- throw new Error(`Tile index is outside of tile range: ${f} >= ${l}`);
1970
- return f;
1971
- }), d = await Promise.all(c.map((h) => e.getTileSize(h)));
1972
- return Ye(e, d.map((h) => ({ offset: h.offset, byteCount: h.imageSize })), n, r);
1973
- }
1974
- function _n(e, t, n, r) {
1965
+ const a = Math.ceil(o.height / i.height), s = Math.ceil(o.width / i.width), l = s * a, c = t.map(([h, p]) => {
1966
+ if (h >= s || p >= a)
1967
+ throw new Error(`Tile index is outside of range x:${h} >= ${s} or y:${p} >= ${a}`);
1968
+ const g = p * s + h;
1969
+ if (g >= l)
1970
+ throw new Error(`Tile index is outside of tile range: ${g} >= ${l}`);
1971
+ return g;
1972
+ }), u = await Promise.all(c.map((h) => e.getTileSize(h)));
1973
+ return it(e, u.map((h) => ({ offset: h.offset, byteCount: h.imageSize })), n, r);
1974
+ }
1975
+ function cr(e, t, n, r) {
1975
1976
  const { width: o, height: i } = e.image.getTileBounds(t, n);
1976
1977
  if (o === e.tileWidth && i === e.tileHeight)
1977
1978
  return r;
1978
- const a = r.mask ? Q(r.mask, e.tileWidth, o, i, 1) : r.mask;
1979
+ const a = r.mask ? T(r.mask, e.tileWidth, o, i, 1) : r.mask;
1979
1980
  if (r.layout === "pixel-interleaved") {
1980
- const { count: c, data: d } = r, h = Q(d, e.tileWidth, o, i, c);
1981
+ const { count: c, data: u } = r, h = T(u, e.tileWidth, o, i, c);
1981
1982
  return {
1982
1983
  ...r,
1983
1984
  width: o,
@@ -1986,7 +1987,7 @@ function _n(e, t, n, r) {
1986
1987
  mask: a
1987
1988
  };
1988
1989
  }
1989
- const { bands: s } = r, l = s.map((c) => Q(c, e.tileWidth, o, i, 1));
1990
+ const { bands: s } = r, l = s.map((c) => T(c, e.tileWidth, o, i, 1));
1990
1991
  return {
1991
1992
  ...r,
1992
1993
  width: o,
@@ -1995,13 +1996,13 @@ function _n(e, t, n, r) {
1995
1996
  mask: a
1996
1997
  };
1997
1998
  }
1998
- function Q(e, t, n, r, o) {
1999
+ function T(e, t, n, r, o) {
1999
2000
  const i = t * o, a = n * o, s = new e.constructor(a * r);
2000
2001
  for (let l = 0; l < r; l++)
2001
2002
  s.set(e.subarray(l * i, l * i + a), l * a);
2002
2003
  return s;
2003
2004
  }
2004
- function Ze(e, t) {
2005
+ function st(e, t) {
2005
2006
  const n = new Set(e), r = new Set(t);
2006
2007
  if (n.size > 1)
2007
2008
  throw new Error("Multiple sample formats are not supported.");
@@ -2015,172 +2016,172 @@ function Ze(e, t) {
2015
2016
  bitsPerSample: i
2016
2017
  };
2017
2018
  }
2018
- function kn(e, { count: t }) {
2019
+ function ur(e, { count: t }) {
2019
2020
  if (e == null)
2020
2021
  return null;
2021
2022
  const o = new DOMParser().parseFromString(e, "text/xml").documentElement;
2022
2023
  if (o.tagName !== "GDALMetadata")
2023
2024
  throw new Error("Not a GDALMetadata XML block");
2024
2025
  const i = /* @__PURE__ */ new Map(), a = Array(t).fill(0), s = Array(t).fill(1), l = (c) => {
2025
- const d = parseInt(c, 10) + 1;
2026
- return i.has(d) || i.set(d, {
2026
+ const u = parseInt(c, 10) + 1;
2027
+ return i.has(u) || i.set(u, {
2027
2028
  max: null,
2028
2029
  min: null,
2029
2030
  mean: null,
2030
2031
  std: null,
2031
2032
  validPercent: null
2032
- }), i.get(d);
2033
+ }), i.get(u);
2033
2034
  };
2034
2035
  for (const c of Array.from(o.querySelectorAll("Item"))) {
2035
- const d = c.getAttribute("name"), h = c.getAttribute("sample"), g = c.textContent ?? "";
2036
+ const u = c.getAttribute("name"), h = c.getAttribute("sample"), p = c.textContent ?? "";
2036
2037
  if (h !== null)
2037
- switch (d) {
2038
+ switch (u) {
2038
2039
  case "STATISTICS_MAXIMUM":
2039
- l(h).max = parseFloat(g);
2040
+ l(h).max = parseFloat(p);
2040
2041
  break;
2041
2042
  case "STATISTICS_MEAN":
2042
- l(h).mean = parseFloat(g);
2043
+ l(h).mean = parseFloat(p);
2043
2044
  break;
2044
2045
  case "STATISTICS_MINIMUM":
2045
- l(h).min = parseFloat(g);
2046
+ l(h).min = parseFloat(p);
2046
2047
  break;
2047
2048
  case "STATISTICS_STDDEV":
2048
- l(h).std = parseFloat(g);
2049
+ l(h).std = parseFloat(p);
2049
2050
  break;
2050
2051
  case "STATISTICS_VALID_PERCENT":
2051
- l(h).validPercent = parseFloat(g);
2052
+ l(h).validPercent = parseFloat(p);
2052
2053
  break;
2053
2054
  case "OFFSET":
2054
- a[parseInt(h, 10)] = parseFloat(g);
2055
+ a[parseInt(h, 10)] = parseFloat(p);
2055
2056
  break;
2056
2057
  case "SCALE":
2057
- s[parseInt(h, 10)] = parseFloat(g);
2058
+ s[parseInt(h, 10)] = parseFloat(p);
2058
2059
  break;
2059
2060
  }
2060
2061
  }
2061
2062
  return { bandStatistics: i, offsets: a, scales: s };
2062
2063
  }
2063
- async function $n(e, t = {}) {
2064
- const { signal: n } = t, r = e.value(u.Compression);
2064
+ async function dr(e, t = {}) {
2065
+ const { signal: n } = t, r = e.value(d.Compression);
2065
2066
  if (r === null)
2066
2067
  throw new Error("Compression tag should always exist.");
2067
- const [o, i, a, s, l, c, d, h, g, f, S, P, C] = await Promise.all([
2068
- e.fetch(u.BitsPerSample, { signal: n }),
2069
- e.fetch(u.ColorMap, { signal: n }),
2070
- e.fetch(u.GdalNoData, { signal: n }),
2071
- e.fetch(u.GdalMetadata, { signal: n }),
2072
- e.fetch(u.LercParameters, { signal: n }),
2073
- e.fetch(u.ModelPixelScale, { signal: n }),
2074
- e.fetch(u.ModelTiePoint, { signal: n }),
2075
- e.fetch(u.ModelTransformation, { signal: n }),
2076
- e.fetch(u.Photometric, { signal: n }),
2077
- e.fetch(u.PlanarConfiguration, { signal: n }),
2078
- e.fetch(u.Predictor, { signal: n }),
2079
- e.fetch(u.SampleFormat, { signal: n }),
2080
- e.fetch(u.SamplesPerPixel, { signal: n })
2081
- ]), j = (b) => {
2082
- throw new Error(`${b} tag should always exist.`);
2068
+ const [o, i, a, s, l, c, u, h, p, g, y, S, b] = await Promise.all([
2069
+ e.fetch(d.BitsPerSample, { signal: n }),
2070
+ e.fetch(d.ColorMap, { signal: n }),
2071
+ e.fetch(d.GdalNoData, { signal: n }),
2072
+ e.fetch(d.GdalMetadata, { signal: n }),
2073
+ e.fetch(d.LercParameters, { signal: n }),
2074
+ e.fetch(d.ModelPixelScale, { signal: n }),
2075
+ e.fetch(d.ModelTiePoint, { signal: n }),
2076
+ e.fetch(d.ModelTransformation, { signal: n }),
2077
+ e.fetch(d.Photometric, { signal: n }),
2078
+ e.fetch(d.PlanarConfiguration, { signal: n }),
2079
+ e.fetch(d.Predictor, { signal: n }),
2080
+ e.fetch(d.SampleFormat, { signal: n }),
2081
+ e.fetch(d.SamplesPerPixel, { signal: n })
2082
+ ]), v = (C) => {
2083
+ throw new Error(`${C} tag should always exist.`);
2083
2084
  };
2084
- return o === null && j("BitsPerSample"), C === null && j("SamplesPerPixel"), g === null && j("Photometric"), {
2085
+ return o === null && v("BitsPerSample"), b === null && v("SamplesPerPixel"), p === null && v("Photometric"), {
2085
2086
  bitsPerSample: new Uint16Array(o),
2086
2087
  colorMap: i ? new Uint16Array(i) : void 0,
2087
2088
  compression: r,
2088
2089
  gdalMetadata: s,
2089
2090
  lercParameters: l,
2090
- modelTiepoint: d,
2091
+ modelTiepoint: u,
2091
2092
  modelPixelScale: c,
2092
2093
  modelTransformation: h,
2093
2094
  nodata: a !== null ? Number(a) : null,
2094
- photometric: g,
2095
+ photometric: p,
2095
2096
  // PlanarConfiguration defaults to interleaved/chunky/contig
2096
2097
  // https://web.archive.org/web/20240329145253/https://www.awaresystems.be/imaging/tiff/tifftags/planarconfiguration.html
2097
- planarConfiguration: f ?? U.Contig,
2098
- predictor: S ?? _.None,
2098
+ planarConfiguration: g ?? U.Contig,
2099
+ predictor: y ?? _.None,
2099
2100
  // Uint is the default sample format according to the spec
2100
2101
  // https://web.archive.org/web/20240329145340/https://www.awaresystems.be/imaging/tiff/tifftags/sampleformat.html
2101
- sampleFormat: P ?? [F.Uint],
2102
- samplesPerPixel: C
2102
+ sampleFormat: S ?? [A.Uint],
2103
+ samplesPerPixel: b
2103
2104
  };
2104
2105
  }
2105
- function Wn(e) {
2106
+ function hr(e) {
2106
2107
  const t = (n) => e.valueGeo(n) ?? null;
2107
2108
  return {
2108
2109
  // Configuration keys
2109
- modelType: t(p.GTModelTypeGeoKey),
2110
- rasterType: t(p.GTRasterTypeGeoKey),
2111
- citation: t(p.GTCitationGeoKey),
2110
+ modelType: t(m.GTModelTypeGeoKey),
2111
+ rasterType: t(m.GTRasterTypeGeoKey),
2112
+ citation: t(m.GTCitationGeoKey),
2112
2113
  // Geographic CRS keys
2113
- geodeticCRS: t(p.GeodeticCRSGeoKey),
2114
- geodeticCitation: t(p.GeodeticCitationGeoKey),
2115
- geodeticDatum: t(p.GeodeticDatumGeoKey),
2116
- primeMeridian: t(p.PrimeMeridianGeoKey),
2117
- linearUnits: t(p.GeogLinearUnitsGeoKey),
2118
- linearUnitSize: t(p.GeogLinearUnitSizeGeoKey),
2119
- angularUnits: t(p.GeogAngularUnitsGeoKey),
2120
- angularUnitSize: t(p.GeogAngularUnitSizeGeoKey),
2121
- ellipsoid: t(p.EllipsoidGeoKey),
2122
- ellipsoidSemiMajorAxis: t(p.EllipsoidSemiMajorAxisGeoKey),
2123
- ellipsoidSemiMinorAxis: t(p.EllipsoidSemiMinorAxisGeoKey),
2124
- ellipsoidInvFlattening: t(p.EllipsoidInvFlatteningGeoKey),
2125
- azimuthUnits: t(p.GeogAzimuthUnitsGeoKey),
2126
- primeMeridianLongitude: t(p.PrimeMeridianLongitudeGeoKey),
2127
- toWGS84: t(p.GeogTOWGS84GeoKey),
2114
+ geodeticCRS: t(m.GeodeticCRSGeoKey),
2115
+ geodeticCitation: t(m.GeodeticCitationGeoKey),
2116
+ geodeticDatum: t(m.GeodeticDatumGeoKey),
2117
+ primeMeridian: t(m.PrimeMeridianGeoKey),
2118
+ linearUnits: t(m.GeogLinearUnitsGeoKey),
2119
+ linearUnitSize: t(m.GeogLinearUnitSizeGeoKey),
2120
+ angularUnits: t(m.GeogAngularUnitsGeoKey),
2121
+ angularUnitSize: t(m.GeogAngularUnitSizeGeoKey),
2122
+ ellipsoid: t(m.EllipsoidGeoKey),
2123
+ ellipsoidSemiMajorAxis: t(m.EllipsoidSemiMajorAxisGeoKey),
2124
+ ellipsoidSemiMinorAxis: t(m.EllipsoidSemiMinorAxisGeoKey),
2125
+ ellipsoidInvFlattening: t(m.EllipsoidInvFlatteningGeoKey),
2126
+ azimuthUnits: t(m.GeogAzimuthUnitsGeoKey),
2127
+ primeMeridianLongitude: t(m.PrimeMeridianLongitudeGeoKey),
2128
+ toWGS84: t(m.GeogTOWGS84GeoKey),
2128
2129
  // Projected CRS keys
2129
- projectedCRS: t(p.ProjectedCRSGeoKey),
2130
- projectedCitation: t(p.ProjectedCitationGeoKey),
2131
- projection: t(p.ProjectionGeoKey),
2132
- projMethod: t(p.ProjMethodGeoKey),
2133
- projLinearUnits: t(p.ProjLinearUnitsGeoKey),
2134
- projLinearUnitSize: t(p.ProjLinearUnitSizeGeoKey),
2135
- projStdParallel1: t(p.ProjStdParallel1GeoKey),
2136
- projStdParallel2: t(p.ProjStdParallel2GeoKey),
2137
- projNatOriginLong: t(p.ProjNatOriginLongGeoKey),
2138
- projNatOriginLat: t(p.ProjNatOriginLatGeoKey),
2139
- projFalseEasting: t(p.ProjFalseEastingGeoKey),
2140
- projFalseNorthing: t(p.ProjFalseNorthingGeoKey),
2141
- projFalseOriginLong: t(p.ProjFalseOriginLongGeoKey),
2142
- projFalseOriginLat: t(p.ProjFalseOriginLatGeoKey),
2143
- projFalseOriginEasting: t(p.ProjFalseOriginEastingGeoKey),
2144
- projFalseOriginNorthing: t(p.ProjFalseOriginNorthingGeoKey),
2145
- projCenterLong: t(p.ProjCenterLongGeoKey),
2146
- projCenterLat: t(p.ProjCenterLatGeoKey),
2147
- projCenterEasting: t(p.ProjCenterEastingGeoKey),
2148
- projCenterNorthing: t(p.ProjCenterNorthingGeoKey),
2149
- projScaleAtNatOrigin: t(p.ProjScaleAtNatOriginGeoKey),
2150
- projScaleAtCenter: t(p.ProjScaleAtCenterGeoKey),
2151
- projAzimuthAngle: t(p.ProjAzimuthAngleGeoKey),
2152
- projStraightVertPoleLong: t(p.ProjStraightVertPoleLongGeoKey),
2153
- projRectifiedGridAngle: t(p.ProjRectifiedGridAngleGeoKey),
2130
+ projectedCRS: t(m.ProjectedCRSGeoKey),
2131
+ projectedCitation: t(m.ProjectedCitationGeoKey),
2132
+ projection: t(m.ProjectionGeoKey),
2133
+ projMethod: t(m.ProjMethodGeoKey),
2134
+ projLinearUnits: t(m.ProjLinearUnitsGeoKey),
2135
+ projLinearUnitSize: t(m.ProjLinearUnitSizeGeoKey),
2136
+ projStdParallel1: t(m.ProjStdParallel1GeoKey),
2137
+ projStdParallel2: t(m.ProjStdParallel2GeoKey),
2138
+ projNatOriginLong: t(m.ProjNatOriginLongGeoKey),
2139
+ projNatOriginLat: t(m.ProjNatOriginLatGeoKey),
2140
+ projFalseEasting: t(m.ProjFalseEastingGeoKey),
2141
+ projFalseNorthing: t(m.ProjFalseNorthingGeoKey),
2142
+ projFalseOriginLong: t(m.ProjFalseOriginLongGeoKey),
2143
+ projFalseOriginLat: t(m.ProjFalseOriginLatGeoKey),
2144
+ projFalseOriginEasting: t(m.ProjFalseOriginEastingGeoKey),
2145
+ projFalseOriginNorthing: t(m.ProjFalseOriginNorthingGeoKey),
2146
+ projCenterLong: t(m.ProjCenterLongGeoKey),
2147
+ projCenterLat: t(m.ProjCenterLatGeoKey),
2148
+ projCenterEasting: t(m.ProjCenterEastingGeoKey),
2149
+ projCenterNorthing: t(m.ProjCenterNorthingGeoKey),
2150
+ projScaleAtNatOrigin: t(m.ProjScaleAtNatOriginGeoKey),
2151
+ projScaleAtCenter: t(m.ProjScaleAtCenterGeoKey),
2152
+ projAzimuthAngle: t(m.ProjAzimuthAngleGeoKey),
2153
+ projStraightVertPoleLong: t(m.ProjStraightVertPoleLongGeoKey),
2154
+ projRectifiedGridAngle: t(m.ProjRectifiedGridAngleGeoKey),
2154
2155
  // Vertical CRS keys
2155
- verticalCRS: t(p.VerticalGeoKey),
2156
- verticalCitation: t(p.VerticalCitationGeoKey),
2157
- verticalDatum: t(p.VerticalDatumGeoKey),
2158
- verticalUnits: t(p.VerticalUnitsGeoKey)
2156
+ verticalCRS: t(m.VerticalGeoKey),
2157
+ verticalCitation: t(m.VerticalCitationGeoKey),
2158
+ verticalDatum: t(m.VerticalDatumGeoKey),
2159
+ verticalUnits: t(m.VerticalUnitsGeoKey)
2159
2160
  };
2160
2161
  }
2161
- function Jn({ modelTiepoint: e, modelPixelScale: t, modelTransformation: n, rasterType: r }) {
2162
+ function pr({ modelTiepoint: e, modelPixelScale: t, modelTransformation: n, rasterType: r }) {
2162
2163
  let o;
2163
2164
  if (e && t)
2164
- o = Vn(e, t);
2165
+ o = mr(e, t);
2165
2166
  else if (n)
2166
- o = Hn(n);
2167
+ o = gr(n);
2167
2168
  else
2168
2169
  throw new Error("The image does not have an affine transformation.");
2169
- return r === T.PixelIsPoint && (o = re(o, Ae(-0.5, -0.5))), o;
2170
+ return r === te.PixelIsPoint && (o = se(o, ze(-0.5, -0.5))), o;
2170
2171
  }
2171
- function Vn(e, t) {
2172
+ function mr(e, t) {
2172
2173
  const n = e[3], r = e[4], o = t[0], i = -t[1];
2173
2174
  return [o, 0, n, 0, i, r];
2174
2175
  }
2175
- function Hn(e) {
2176
+ function gr(e) {
2176
2177
  const t = e[3], n = e[7], r = e[1], o = e[4], i = e[0], a = e[5];
2177
2178
  return [i, r, t, o, a, n];
2178
2179
  }
2179
- function Qe(e, t, n, r = Math.floor) {
2180
- const o = nt(e.transform), [i, a] = Re(o, t, n);
2180
+ function lt(e, t, n, r = Math.floor) {
2181
+ const o = wt(e.transform), [i, a] = Be(o, t, n);
2181
2182
  return [r(a), r(i)];
2182
2183
  }
2183
- function qe(e, t, n, r = "center") {
2184
+ function ct(e, t, n, r = "center") {
2184
2185
  let o, i;
2185
2186
  switch (r) {
2186
2187
  case "center":
@@ -2199,9 +2200,9 @@ function qe(e, t, n, r = "center") {
2199
2200
  o = n + 1, i = t + 1;
2200
2201
  break;
2201
2202
  }
2202
- return Re(e.transform, o, i);
2203
+ return Be(e.transform, o, i);
2203
2204
  }
2204
- class Yn {
2205
+ class fr {
2205
2206
  cachedTags;
2206
2207
  /** The data source used for fetching tile data. */
2207
2208
  dataSource;
@@ -2256,7 +2257,7 @@ class Yn {
2256
2257
  */
2257
2258
  get transform() {
2258
2259
  const t = this.geotiff.transform, n = this.geotiff.width / this.width, r = this.geotiff.height / this.height;
2259
- return re(t, rt(n, r));
2260
+ return se(t, St(n, r));
2260
2261
  }
2261
2262
  /** Image width in pixels. */
2262
2263
  get width() {
@@ -2272,7 +2273,7 @@ class Yn {
2272
2273
  * @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
2273
2274
  */
2274
2275
  async fetchTile(t, n, r = {}) {
2275
- return await ke(this, t, n, r);
2276
+ return await Te(this, t, n, r);
2276
2277
  }
2277
2278
  /**
2278
2279
  * Fetch multiple tiles in parallel.
@@ -2287,7 +2288,7 @@ class Yn {
2287
2288
  * @see {@link fetchTile} for single-tile fetching.
2288
2289
  */
2289
2290
  async fetchTiles(t, n = {}) {
2290
- return await We(this, t, n);
2291
+ return await tt(this, t, n);
2291
2292
  }
2292
2293
  // TiledMixin
2293
2294
  // Transform mixin
@@ -2301,7 +2302,7 @@ class Yn {
2301
2302
  * @returns [row, col] pixel indices.
2302
2303
  */
2303
2304
  index(t, n, r = Math.floor) {
2304
- return Qe(this, t, n, r);
2305
+ return lt(this, t, n, r);
2305
2306
  }
2306
2307
  /**
2307
2308
  * Get the geographic (x, y) coordinate of the pixel at (row, col).
@@ -2312,10 +2313,10 @@ class Yn {
2312
2313
  * @returns [x, y] in the CRS.
2313
2314
  */
2314
2315
  xy(t, n, r = "center") {
2315
- return qe(this, t, n, r);
2316
+ return ct(this, t, n, r);
2316
2317
  }
2317
2318
  }
2318
- class D {
2319
+ class x {
2319
2320
  /**
2320
2321
  * Reduced-resolution overview levels, sorted finest-to-coarsest.
2321
2322
  *
@@ -2369,7 +2370,7 @@ class D {
2369
2370
  */
2370
2371
  static async open(t) {
2371
2372
  const { dataSource: n, headerSource: r, signal: o, debug: i } = t, a = await new B(r).init({ signal: o });
2372
- return a.options = void 0, D.fromTiff(a, n, { signal: o, debug: i });
2373
+ return a.options = void 0, x.fromTiff(a, n, { signal: o, debug: i });
2373
2374
  }
2374
2375
  /**
2375
2376
  * Create a GeoTIFF from an already-initialised Tiff instance.
@@ -2385,24 +2386,24 @@ class D {
2385
2386
  const { signal: o, debug: i = !1 } = r, a = t.images;
2386
2387
  if (a.length === 0)
2387
2388
  throw new Error("TIFF does not contain any IFDs");
2388
- await Promise.all(a.map((b) => b.init(!0, { signal: o })));
2389
- const s = a[0], l = Wn(s), c = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map();
2390
- for (let b = 1; b < a.length; b++) {
2391
- const G = a[b], R = G.size, I = `${R.width},${R.height}`;
2392
- Xn(G) ? d.set(I, G) : c.set(I, G);
2389
+ await Promise.all(a.map((C) => C.init(!0, { signal: o })));
2390
+ const s = a[0], l = hr(s), c = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map();
2391
+ for (let C = 1; C < a.length; C++) {
2392
+ const L = a[C], E = L.size, G = `${E.width},${E.height}`;
2393
+ yr(L) ? u.set(G, L) : c.set(G, L);
2393
2394
  }
2394
- const h = `${s.size.width},${s.size.height}`, g = d.get(h) ?? null, f = Array.from(c.entries());
2395
- f.sort((b, G) => {
2396
- const R = b[1].size, I = G[1].size;
2397
- return I.width * I.height - R.width * R.height;
2395
+ const h = `${s.size.width},${s.size.height}`, p = u.get(h) ?? null, g = Array.from(c.entries());
2396
+ g.sort((C, L) => {
2397
+ const E = C[1].size, G = L[1].size;
2398
+ return G.width * G.height - E.width * E.height;
2398
2399
  });
2399
- const S = await $n(s, { signal: o }), P = kn(S.gdalMetadata, {
2400
- count: S.samplesPerPixel
2401
- }), C = new D(t, s, g, l, [], S, n, P, i), j = f.map(([b, G]) => {
2402
- const R = d.get(b) ?? null;
2403
- return new Yn(C, l, G, R, S, n);
2400
+ const y = await dr(s, { signal: o }), S = ur(y.gdalMetadata, {
2401
+ count: y.samplesPerPixel
2402
+ }), b = new x(t, s, p, l, [], y, n, S, i), v = g.map(([C, L]) => {
2403
+ const E = u.get(C) ?? null;
2404
+ return new fr(b, l, L, E, y, n);
2404
2405
  });
2405
- return C.overviews = j, C;
2406
+ return b.overviews = v, b;
2406
2407
  }
2407
2408
  /**
2408
2409
  * Create a GeoTIFF from an ArrayBuffer containing the entire file.
@@ -2416,8 +2417,8 @@ class D {
2416
2417
  * @returns A Promise that resolves to a GeoTIFF instance.
2417
2418
  */
2418
2419
  static async fromArrayBuffer(t) {
2419
- const n = new ae("memory://input.tif", t);
2420
- return await D.open({
2420
+ const n = new ue("memory://input.tif", t);
2421
+ return await x.open({
2421
2422
  dataSource: n,
2422
2423
  headerSource: n
2423
2424
  });
@@ -2440,13 +2441,13 @@ class D {
2440
2441
  * @returns A Promise that resolves to a GeoTIFF instance.
2441
2442
  */
2442
2443
  static async fromUrl(t, { chunkSize: n = 64 * 1024, cacheSize: r = 8 * 1024 * 1024, signal: o, debug: i } = {}) {
2443
- const a = new k(t, {});
2444
+ const a = new $(t, {});
2444
2445
  a.metadata = { size: Number.POSITIVE_INFINITY };
2445
- const s = new Bt(a, [
2446
- new kt({ size: n }),
2447
- new zt({ size: r })
2446
+ const s = new cn(a, [
2447
+ new dn({ size: n }),
2448
+ new ln({ size: r })
2448
2449
  ]);
2449
- return await D.open({
2450
+ return await x.open({
2450
2451
  // Tile data reads bypass the header cache (raw source).
2451
2452
  dataSource: a,
2452
2453
  headerSource: s,
@@ -2464,7 +2465,7 @@ class D {
2464
2465
  * See also {@link GeoTIFF.epsg} for the EPSG code directly from the TIFF tags.
2465
2466
  */
2466
2467
  get crs() {
2467
- return this._crs === void 0 && (this._crs = Cn(this.gkd)), this._crs;
2468
+ return this._crs === void 0 && (this._crs = kn(this.gkd)), this._crs;
2468
2469
  }
2469
2470
  /** Image width in pixels. */
2470
2471
  get width() {
@@ -2524,7 +2525,7 @@ class D {
2524
2525
  }
2525
2526
  /** Number of bands (samples per pixel). */
2526
2527
  get count() {
2527
- return this.image.value(u.SamplesPerPixel) ?? 1;
2528
+ return this.image.value(d.SamplesPerPixel) ?? 1;
2528
2529
  }
2529
2530
  /** Bounding box [minX, minY, maxX, maxY] in the CRS. */
2530
2531
  get bbox() {
@@ -2535,7 +2536,7 @@ class D {
2535
2536
  */
2536
2537
  get transform() {
2537
2538
  const { modelPixelScale: t, modelTiepoint: n, modelTransformation: r } = this.cachedTags;
2538
- return Jn({
2539
+ return pr({
2539
2540
  modelTiepoint: n,
2540
2541
  modelPixelScale: t,
2541
2542
  modelTransformation: r,
@@ -2553,7 +2554,7 @@ class D {
2553
2554
  * @param options.signal An optional {@link AbortSignal} to cancel the fetch request.
2554
2555
  */
2555
2556
  async fetchTile(t, n, r = {}) {
2556
- return await ke(this, t, n, r);
2557
+ return await Te(this, t, n, r);
2557
2558
  }
2558
2559
  /**
2559
2560
  * Fetch multiple tiles in parallel.
@@ -2568,7 +2569,7 @@ class D {
2568
2569
  * @see {@link fetchTile} for single-tile fetching.
2569
2570
  */
2570
2571
  async fetchTiles(t, n = {}) {
2571
- return await We(this, t, n);
2572
+ return await tt(this, t, n);
2572
2573
  }
2573
2574
  // Transform mixin
2574
2575
  /**
@@ -2581,7 +2582,7 @@ class D {
2581
2582
  * @returns [row, col] pixel indices.
2582
2583
  */
2583
2584
  index(t, n, r = Math.floor) {
2584
- return Qe(this, t, n, r);
2585
+ return lt(this, t, n, r);
2585
2586
  }
2586
2587
  /**
2587
2588
  * Get the geographic (x, y) coordinate of the pixel at (row, col).
@@ -2592,14 +2593,14 @@ class D {
2592
2593
  * @returns [x, y] in the CRS.
2593
2594
  */
2594
2595
  xy(t, n, r = "center") {
2595
- return qe(this, t, n, r);
2596
+ return ct(this, t, n, r);
2596
2597
  }
2597
2598
  }
2598
- function Xn(e) {
2599
- const t = e.value(u.SubFileType), n = e.value(u.Photometric);
2600
- return t !== null && (t & J.Mask) !== 0 && n === E.Mask;
2599
+ function yr(e) {
2600
+ const t = e.value(d.SubFileType), n = e.value(d.Photometric);
2601
+ return t !== null && (t & J.Mask) !== 0 && n === F.Mask;
2601
2602
  }
2602
- let Zn = class {
2603
+ let wr = class {
2603
2604
  worker;
2604
2605
  jobIdCounter = 0;
2605
2606
  jobs = /* @__PURE__ */ new Map();
@@ -2623,14 +2624,14 @@ let Zn = class {
2623
2624
  this.worker.terminate();
2624
2625
  }
2625
2626
  };
2626
- const Qn = typeof navigator < "u" ? navigator.hardwareConcurrency ?? 2 : 2;
2627
- class ne {
2627
+ const Sr = typeof navigator < "u" ? navigator.hardwareConcurrency ?? 2 : 2;
2628
+ class oe {
2628
2629
  workerWrappers;
2629
2630
  constructor(t = {}) {
2630
- const { size: n = Qn, createWorker: r } = t;
2631
+ const { size: n = Sr, createWorker: r } = t;
2631
2632
  if (this.workerWrappers = [], r && n > 0)
2632
2633
  for (let o = 0; o < n; o++)
2633
- this.workerWrappers.push(new Zn(r()));
2634
+ this.workerWrappers.push(new wr(r()));
2634
2635
  }
2635
2636
  /** True when workers are available for off-main-thread decoding. */
2636
2637
  get hasWorkers() {
@@ -2648,7 +2649,7 @@ class ne {
2648
2649
  */
2649
2650
  async decode(t, n, r) {
2650
2651
  if (!this.hasWorkers)
2651
- return ie(t, n, r);
2652
+ return ce(t, n, r);
2652
2653
  const o = this.leastLoaded(), i = {
2653
2654
  compression: n,
2654
2655
  metadata: r,
@@ -2670,8 +2671,8 @@ class ne {
2670
2671
  }
2671
2672
  }
2672
2673
  let H = null;
2673
- function qn() {
2674
- return H !== null || (H = new ne({
2674
+ function Pr() {
2675
+ return H !== null || (H = new oe({
2675
2676
  createWorker: () => new Worker(new URL(
2676
2677
  /* @vite-ignore */
2677
2678
  "" + new URL("assets/worker-DtIrTJB7.js", import.meta.url).href,
@@ -2679,7 +2680,7 @@ function qn() {
2679
2680
  ), { type: "module" })
2680
2681
  })), H;
2681
2682
  }
2682
- function Tn(e) {
2683
+ function br(e) {
2683
2684
  const { height: t, width: n } = e;
2684
2685
  if (e.layout === "band-separate")
2685
2686
  throw new Error("Band-separate images not yet implemented.");
@@ -2697,10 +2698,10 @@ function Tn(e) {
2697
2698
  } else
2698
2699
  throw new Error(`Unexpected number of channels in raster data: ${e.data.length / (t * n)}`);
2699
2700
  }
2700
- async function er(e) {
2701
- return typeof e == "string" || e instanceof URL ? await D.fromUrl(e) : e instanceof ArrayBuffer ? await D.fromArrayBuffer(e) : e;
2701
+ async function Cr(e) {
2702
+ return typeof e == "string" || e instanceof URL ? await x.fromUrl(e) : e instanceof ArrayBuffer ? await x.fromArrayBuffer(e) : e;
2702
2703
  }
2703
- function tr(e, t) {
2704
+ function Lr(e, t) {
2704
2705
  const [n, r, o, i] = e.bbox, a = [
2705
2706
  t.forward([n, r]),
2706
2707
  // bottom-left
@@ -2710,20 +2711,20 @@ function tr(e, t) {
2710
2711
  // top-right
2711
2712
  t.forward([n, i])
2712
2713
  // top-left
2713
- ], s = a.map((f) => f[0]), l = a.map((f) => f[1]), c = Math.min(...s), d = Math.min(...l), h = Math.max(...s), g = Math.max(...l);
2714
- return { west: c, south: d, east: h, north: g };
2714
+ ], s = a.map((g) => g[0]), l = a.map((g) => g[1]), c = Math.min(...s), u = Math.min(...l), h = Math.max(...s), p = Math.max(...l);
2715
+ return { west: c, south: u, east: h, north: p };
2715
2716
  }
2716
- const nr = (
2717
+ const Ir = (
2717
2718
  /* glsl */
2718
2719
  `
2719
2720
  vec3 black_zero_to_rgb(float value) {
2720
2721
  return vec3(value, value, value);
2721
2722
  }
2722
2723
  `
2723
- ), rr = {
2724
+ ), Gr = {
2724
2725
  name: "black-is-zero",
2725
2726
  inject: {
2726
- "fs:#decl": nr,
2727
+ "fs:#decl": Ir,
2727
2728
  "fs:DECKGL_FILTER_COLOR": (
2728
2729
  /* glsl */
2729
2730
  `
@@ -2731,7 +2732,7 @@ const nr = (
2731
2732
  `
2732
2733
  )
2733
2734
  }
2734
- }, or = (
2735
+ }, vr = (
2735
2736
  /* glsl */
2736
2737
  `
2737
2738
  const vec3 D65 = vec3(
@@ -2776,10 +2777,10 @@ const nr = (
2776
2777
  return clamp(rgb, 0.0, 1.0);
2777
2778
  }
2778
2779
  `
2779
- ), ir = {
2780
+ ), Er = {
2780
2781
  name: "cielab-to-rgb",
2781
2782
  inject: {
2782
- "fs:#decl": or,
2783
+ "fs:#decl": vr,
2783
2784
  "fs:DECKGL_FILTER_COLOR": (
2784
2785
  /* glsl */
2785
2786
  `
@@ -2787,7 +2788,7 @@ const nr = (
2787
2788
  `
2788
2789
  )
2789
2790
  }
2790
- }, ar = (
2791
+ }, Fr = (
2791
2792
  /* glsl */
2792
2793
  `
2793
2794
  vec3 cmykToRgb(vec4 cmyk) {
@@ -2801,10 +2802,10 @@ const nr = (
2801
2802
  );
2802
2803
  }
2803
2804
  `
2804
- ), sr = {
2805
+ ), Ar = {
2805
2806
  name: "cmyk-to-rgb",
2806
2807
  inject: {
2807
- "fs:#decl": ar,
2808
+ "fs:#decl": Fr,
2808
2809
  "fs:DECKGL_FILTER_COLOR": (
2809
2810
  /* glsl */
2810
2811
  `
@@ -2812,17 +2813,17 @@ const nr = (
2812
2813
  `
2813
2814
  )
2814
2815
  }
2815
- }, lr = (
2816
+ }, jr = (
2816
2817
  /* glsl */
2817
2818
  `
2818
2819
  vec3 white_zero_to_rgb(float value) {
2819
2820
  return vec3(1.0 - value, 1.0 - value, 1.0 - value);
2820
2821
  }
2821
2822
  `
2822
- ), cr = {
2823
+ ), Rr = {
2823
2824
  name: "white-is-zero",
2824
2825
  inject: {
2825
- "fs:#decl": lr,
2826
+ "fs:#decl": jr,
2826
2827
  "fs:DECKGL_FILTER_COLOR": (
2827
2828
  /* glsl */
2828
2829
  `
@@ -2830,7 +2831,7 @@ const nr = (
2830
2831
  `
2831
2832
  )
2832
2833
  }
2833
- }, ur = {
2834
+ }, Ur = {
2834
2835
  name: "mask-texture",
2835
2836
  inject: {
2836
2837
  "fs:#decl": "uniform sampler2D maskTexture;",
@@ -2848,18 +2849,18 @@ const nr = (
2848
2849
  maskTexture: e.maskTexture
2849
2850
  })
2850
2851
  };
2851
- function dr(e, t, n) {
2852
- const r = hr(e), o = pr(t), i = gr(n), a = `${r}:${i}:${o}`, s = mr[a];
2852
+ function Mr(e, t, n) {
2853
+ const r = Or(e), o = Kr(t), i = xr(n), a = `${r}:${i}:${o}`, s = Dr[a];
2853
2854
  if (!s)
2854
2855
  throw new Error(`Unsupported texture format for SamplesPerPixel=${e}, BitsPerSample=${t}, SampleFormat=${n}`);
2855
2856
  return s;
2856
2857
  }
2857
- function hr(e) {
2858
+ function Or(e) {
2858
2859
  if (e === 1 || e === 2 || e === 3 || e === 4)
2859
2860
  return e;
2860
2861
  throw new Error(`Unsupported SamplesPerPixel ${e}. Only 1, 2, 3, or 4 are supported.`);
2861
2862
  }
2862
- function pr(e) {
2863
+ function Kr(e) {
2863
2864
  const t = e[0];
2864
2865
  for (let n = 1; n < e.length; n++)
2865
2866
  if (e[n] !== t)
@@ -2868,23 +2869,23 @@ function pr(e) {
2868
2869
  throw new Error(`Unsupported BitsPerSample ${t}. Only 8, 16, or 32 are supported.`);
2869
2870
  return t;
2870
2871
  }
2871
- function gr(e) {
2872
+ function xr(e) {
2872
2873
  const t = e[0];
2873
2874
  for (let n = 1; n < e.length; n++)
2874
2875
  if (e[n] !== t)
2875
2876
  throw new Error(`Unsupported varying SampleFormat ${e}. All samples must have the same format.`);
2876
2877
  switch (t) {
2877
- case F.Uint:
2878
+ case A.Uint:
2878
2879
  return "unorm";
2879
- case F.Int:
2880
+ case A.Int:
2880
2881
  return "sint";
2881
- case F.Float:
2882
+ case A.Float:
2882
2883
  return "float";
2883
2884
  default:
2884
2885
  throw new Error(`Unsupported SampleFormat ${e}`);
2885
2886
  }
2886
2887
  }
2887
- const mr = {
2888
+ const Dr = {
2888
2889
  // 1 byte per pixel
2889
2890
  "1:sint:8": "r8sint",
2890
2891
  "1:uint:8": "r8uint",
@@ -2931,120 +2932,120 @@ const mr = {
2931
2932
  "4:sint:32": "rgba32sint",
2932
2933
  "4:uint:32": "rgba32uint"
2933
2934
  };
2934
- function fr(e, t) {
2935
+ function Nr(e, t) {
2935
2936
  const { sampleFormat: n } = e.cachedTags;
2936
2937
  if (n === null)
2937
2938
  throw new Error("SampleFormat tag is required to infer render pipeline");
2938
2939
  switch (n[0]) {
2939
2940
  // Unsigned integers
2940
- case F.Uint:
2941
- return yr(e, t);
2941
+ case A.Uint:
2942
+ return zr(e, t);
2942
2943
  }
2943
2944
  throw new Error(`Inferring render pipeline for non-unsigned integers not yet supported. Found SampleFormat: ${n}`);
2944
2945
  }
2945
- function yr(e, t) {
2946
+ function zr(e, t) {
2946
2947
  const { bitsPerSample: n, colorMap: r, photometric: o, sampleFormat: i, samplesPerPixel: a, nodata: s } = e.cachedTags, l = [
2947
2948
  {
2948
- module: it,
2949
+ module: bt,
2949
2950
  props: {
2950
- textureName: (f) => f.texture
2951
+ textureName: (g) => g.texture
2951
2952
  }
2952
2953
  }
2953
2954
  ];
2954
2955
  if (s !== null) {
2955
- const f = 2 ** n[0] - 1, S = s / f;
2956
+ const g = 2 ** n[0] - 1, y = s / g;
2956
2957
  l.push({
2957
- module: at,
2958
- props: { value: S }
2958
+ module: Ct,
2959
+ props: { value: y }
2959
2960
  });
2960
2961
  }
2961
2962
  e.maskImage !== null && l.push({
2962
- module: ur,
2963
+ module: Ur,
2963
2964
  props: {
2964
2965
  // TODO: how to handle if mask failed to load and is undefined here
2965
- maskTexture: (f) => f.mask
2966
+ maskTexture: (g) => g.mask
2966
2967
  }
2967
2968
  });
2968
- const c = wr({
2969
+ const c = Br({
2969
2970
  count: a,
2970
2971
  photometric: o,
2971
2972
  device: t,
2972
2973
  colorMap: r
2973
2974
  });
2974
2975
  c && l.push(c);
2975
- const d = o === E.Palette ? {
2976
+ const u = o === F.Palette ? {
2976
2977
  magFilter: "nearest",
2977
2978
  minFilter: "nearest"
2978
2979
  } : {
2979
2980
  magFilter: "linear",
2980
2981
  minFilter: "linear"
2981
2982
  };
2982
- return { getTileData: async (f, S) => {
2983
- const { device: P, x: C, y: j, signal: b, pool: G } = S, R = await f.fetchTile(C, j, {
2983
+ return { getTileData: async (g, y) => {
2984
+ const { device: S, x: b, y: v, signal: C, pool: L } = y, E = await g.fetchTile(b, v, {
2984
2985
  boundless: !1,
2985
- pool: G,
2986
- signal: b
2986
+ pool: L,
2987
+ signal: C
2987
2988
  });
2988
- let { array: I } = R;
2989
- const { width: se, height: le, mask: Z } = I;
2990
- let ce = a;
2991
- if (a === 3 && (I = Tn(I), ce = 4), I.layout === "band-separate")
2989
+ let { array: G } = E;
2990
+ const { width: de, height: he, mask: q } = G;
2991
+ let pe = a;
2992
+ if (a === 3 && (G = br(G), pe = 4), G.layout === "band-separate")
2992
2993
  throw new Error("Band-separate images not yet implemented.");
2993
- const et = dr(
2994
+ const ft = Mr(
2994
2995
  // Add one sample for added alpha channel
2995
- ce,
2996
+ pe,
2996
2997
  n,
2997
2998
  i
2998
2999
  );
2999
- let ue = I.data.byteLength;
3000
- const tt = P.createTexture({
3001
- data: I.data,
3002
- format: et,
3003
- width: se,
3004
- height: le,
3005
- sampler: d
3000
+ let me = G.data.byteLength;
3001
+ const yt = S.createTexture({
3002
+ data: G.data,
3003
+ format: ft,
3004
+ width: de,
3005
+ height: he,
3006
+ sampler: u
3006
3007
  });
3007
- let de;
3008
- return Z !== null && (de = P.createTexture({
3009
- data: Z,
3008
+ let ge;
3009
+ return q !== null && (ge = S.createTexture({
3010
+ data: q,
3010
3011
  // Single-channel 8-bit texture for the mask
3011
3012
  format: "r8unorm",
3012
- width: se,
3013
- height: le,
3013
+ width: de,
3014
+ height: he,
3014
3015
  // Use nearest filtering for the mask to avoid interpolated edges/halos
3015
3016
  sampler: {
3016
3017
  minFilter: "nearest",
3017
3018
  magFilter: "nearest"
3018
3019
  }
3019
- }), ue += Z.byteLength), {
3020
- texture: tt,
3021
- mask: de,
3022
- byteLength: ue,
3023
- height: I.height,
3024
- width: I.width
3020
+ }), me += q.byteLength), {
3021
+ texture: yt,
3022
+ mask: ge,
3023
+ byteLength: me,
3024
+ height: G.height,
3025
+ width: G.width
3025
3026
  };
3026
- }, renderTile: (f) => ({
3027
- renderPipeline: l.map((S, P) => Sr(S, f))
3027
+ }, renderTile: (g) => ({
3028
+ renderPipeline: l.map((y, S) => _r(y, g))
3028
3029
  }) };
3029
3030
  }
3030
- function wr({ count: e, colorMap: t, device: n, photometric: r }) {
3031
+ function Br({ count: e, colorMap: t, device: n, photometric: r }) {
3031
3032
  if (e === 3 || e === 4)
3032
3033
  return null;
3033
3034
  switch (r) {
3034
- case E.MinIsWhite:
3035
+ case F.MinIsWhite:
3035
3036
  return {
3036
- module: cr
3037
+ module: Rr
3037
3038
  };
3038
- case E.MinIsBlack:
3039
+ case F.MinIsBlack:
3039
3040
  return {
3040
- module: rr
3041
+ module: Gr
3041
3042
  };
3042
- case E.Rgb:
3043
+ case F.Rgb:
3043
3044
  return null;
3044
- case E.Palette: {
3045
+ case F.Palette: {
3045
3046
  if (!t)
3046
3047
  throw new Error("ColorMap is required for PhotometricInterpretation Palette");
3047
- const { data: o, width: i, height: a } = mt(t), s = n.createTexture({
3048
+ const { data: o, width: i, height: a } = Dt(t), s = n.createTexture({
3048
3049
  dimension: "2d-array",
3049
3050
  data: o,
3050
3051
  format: "rgba8unorm",
@@ -3061,28 +3062,28 @@ function wr({ count: e, colorMap: t, device: n, photometric: r }) {
3061
3062
  }
3062
3063
  });
3063
3064
  return {
3064
- module: ot,
3065
+ module: Pt,
3065
3066
  props: {
3066
3067
  colormapTexture: s
3067
3068
  }
3068
3069
  };
3069
3070
  }
3070
3071
  // Not sure why cogeotiff calls this "Separated", but it means CMYK
3071
- case E.Separated:
3072
+ case F.Separated:
3072
3073
  return {
3073
- module: sr
3074
+ module: Ar
3074
3075
  };
3075
- case E.Ycbcr:
3076
+ case F.Ycbcr:
3076
3077
  return null;
3077
- case E.Cielab:
3078
+ case F.Cielab:
3078
3079
  return {
3079
- module: ir
3080
+ module: Er
3080
3081
  };
3081
3082
  default:
3082
3083
  throw new Error(`Unsupported PhotometricInterpretation ${r}`);
3083
3084
  }
3084
3085
  }
3085
- function Sr(e, t) {
3086
+ function _r(e, t) {
3086
3087
  const { module: n, props: r } = e;
3087
3088
  if (!r)
3088
3089
  return { module: n };
@@ -3093,11 +3094,11 @@ function Sr(e, t) {
3093
3094
  }
3094
3095
  return { module: n, props: o };
3095
3096
  }
3096
- function Pr(e, t) {
3097
+ function $r(e, t) {
3097
3098
  const r = [
3098
3099
  ...[...e.overviews].reverse(),
3099
3100
  e
3100
- ].map((o) => new st({
3101
+ ].map((o) => new Lt({
3101
3102
  affine: o.transform,
3102
3103
  arrayWidth: o.width,
3103
3104
  arrayHeight: o.height,
@@ -3105,7 +3106,7 @@ function Pr(e, t) {
3105
3106
  tileHeight: o.tileHeight,
3106
3107
  mpu: t.mpu
3107
3108
  }));
3108
- return new lt({
3109
+ return new It({
3109
3110
  levels: r,
3110
3111
  projectTo3857: t.projectTo3857,
3111
3112
  projectFrom3857: t.projectFrom3857,
@@ -3113,7 +3114,7 @@ function Pr(e, t) {
3113
3114
  projectFrom4326: t.projectFrom4326
3114
3115
  });
3115
3116
  }
3116
- class Cr extends he {
3117
+ class kr extends fe {
3117
3118
  static layerName = "COGLayer";
3118
3119
  // COGLayer's getTileData signature differs from the base class's, so
3119
3120
  // `DefaultProps<COGLayerProps>` is not assignable to
@@ -3121,8 +3122,8 @@ class Cr extends he {
3121
3122
  // to keep inheritance happy. The only COG-specific default is
3122
3123
  // `epsgResolver`; all behavior still flows from the base class.
3123
3124
  static defaultProps = {
3124
- ...he.defaultProps,
3125
- epsgResolver: ct
3125
+ ...fe.defaultProps,
3126
+ epsgResolver: Gt
3126
3127
  };
3127
3128
  initializeState() {
3128
3129
  this.setState({});
@@ -3141,12 +3142,12 @@ class Cr extends he {
3141
3142
  });
3142
3143
  }
3143
3144
  async _parseGeoTIFF() {
3144
- const t = await er(this.props.geotiff), n = t.crs, r = typeof n == "number" ? await this.props.epsgResolver(n) : ut(n), o = pe(r, "EPSG:4326"), i = (P, C) => o.forward([P, C], !1), a = (P, C) => o.inverse([P, C], !1), s = pe(r, "EPSG:3857"), l = ht((P, C) => s.forward([P, C], !1), i), c = (P, C) => s.inverse([P, C], !1), d = r.units;
3145
- if (!d)
3145
+ const t = await Cr(this.props.geotiff), n = t.crs, r = typeof n == "number" ? await this.props.epsgResolver(n) : vt(n), o = ye(r, "EPSG:4326"), i = (S, b) => o.forward([S, b], !1), a = (S, b) => o.inverse([S, b], !1), s = ye(r, "EPSG:3857"), l = Ft((S, b) => s.forward([S, b], !1), i), c = (S, b) => s.inverse([S, b], !1), u = r.units;
3146
+ if (!u)
3146
3147
  throw new Error("Source projection is missing 'units' property, cannot compute meters per unit");
3147
- const h = dt(d, {
3148
+ const h = Et(u, {
3148
3149
  semiMajorAxis: r.datum?.a ?? r.a
3149
- }), g = Pr(t, {
3150
+ }), p = $r(t, {
3150
3151
  projectTo4326: i,
3151
3152
  projectFrom4326: a,
3152
3153
  projectTo3857: l,
@@ -3154,18 +3155,18 @@ class Cr extends he {
3154
3155
  mpu: h
3155
3156
  });
3156
3157
  if (this.props.onGeoTIFFLoad) {
3157
- const P = tr(t, o);
3158
+ const S = Lr(t, o);
3158
3159
  this.props.onGeoTIFFLoad(t, {
3159
3160
  projection: r,
3160
- geographicBounds: P
3161
+ geographicBounds: S
3161
3162
  });
3162
3163
  }
3163
- let f, S;
3164
- (!this.props.getTileData || !this.props.renderTile) && ({ getTileData: f, renderTile: S } = fr(t, this.context.device)), this.setState({
3164
+ let g, y;
3165
+ (!this.props.getTileData || !this.props.renderTile) && ({ getTileData: g, renderTile: y } = Nr(t, this.context.device)), this.setState({
3165
3166
  geotiff: t,
3166
- tilesetDescriptor: g,
3167
- defaultGetTileData: f,
3168
- defaultRenderTile: S
3167
+ tilesetDescriptor: p,
3168
+ defaultGetTileData: g,
3169
+ defaultRenderTile: y
3169
3170
  });
3170
3171
  }
3171
3172
  _tilesetDescriptor() {
@@ -3187,7 +3188,7 @@ class Cr extends he {
3187
3188
  x: a,
3188
3189
  y: s,
3189
3190
  signal: i.signal,
3190
- pool: this.props.pool ?? qn()
3191
+ pool: this.props.pool ?? Pr()
3191
3192
  });
3192
3193
  } : void 0;
3193
3194
  }
@@ -3197,7 +3198,7 @@ class Cr extends he {
3197
3198
  return t;
3198
3199
  }
3199
3200
  }
3200
- const Te = `var j;
3201
+ const ut = `var j;
3201
3202
  (function(e) {
3202
3203
  e[e.Big = 19789] = "Big", e[e.Little = 18761] = "Little";
3203
3204
  })(j || (j = {}));
@@ -3502,11 +3503,11 @@ export {
3502
3503
  t as C,
3503
3504
  S as D
3504
3505
  };
3505
- `, Fe = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Te], { type: "text/javascript;charset=utf-8" });
3506
- function Lr(e) {
3506
+ `, Ue = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", ut], { type: "text/javascript;charset=utf-8" });
3507
+ function Wr(e) {
3507
3508
  let t;
3508
3509
  try {
3509
- if (t = Fe && (self.URL || self.webkitURL).createObjectURL(Fe), !t) throw "";
3510
+ if (t = Ue && (self.URL || self.webkitURL).createObjectURL(Ue), !t) throw "";
3510
3511
  const n = new Worker(t, {
3511
3512
  type: "module",
3512
3513
  name: e?.name
@@ -3516,7 +3517,7 @@ function Lr(e) {
3516
3517
  }), n;
3517
3518
  } catch {
3518
3519
  return new Worker(
3519
- "data:text/javascript;charset=utf-8," + encodeURIComponent(Te),
3520
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(ut),
3520
3521
  {
3521
3522
  type: "module",
3522
3523
  name: e?.name
@@ -3524,58 +3525,106 @@ function Lr(e) {
3524
3525
  );
3525
3526
  }
3526
3527
  }
3527
- function br(e) {
3528
- const t = e.layout === "band-separate" ? e.bands[0] : e.data;
3529
- return t instanceof Float32Array ? t : new Float32Array(t);
3530
- }
3531
- function Ir(e) {
3532
- const t = e.width * e.height, n = new Float32Array(t * 4);
3533
- if (e.layout === "band-separate") {
3534
- const [r, o, i] = [e.bands[0], e.bands[1], e.bands[2]];
3535
- for (let a = 0; a < t; a++)
3536
- n[a * 4] = r[a], n[a * 4 + 1] = o[a], n[a * 4 + 2] = i[a], n[a * 4 + 3] = 1;
3537
- } else {
3538
- const { data: r, count: o } = e;
3539
- for (let i = 0; i < t; i++)
3540
- n[i * 4] = r[i * o], n[i * 4 + 1] = r[i * o + 1], n[i * 4 + 2] = r[i * o + 2], n[i * 4 + 3] = 1;
3541
- }
3542
- return n;
3543
- }
3544
- const Gr = async (e, { device: t, x: n, y: r, signal: o, pool: i }) => {
3545
- const a = () => {
3528
+ const Z = /* @__PURE__ */ new WeakMap(), ie = async (e, {
3529
+ device: t,
3530
+ x: n,
3531
+ y: r,
3532
+ signal: o,
3533
+ pool: i,
3534
+ dropDecode: a
3535
+ }) => {
3536
+ const s = () => {
3546
3537
  throw o?.reason ?? new DOMException("aborted", "AbortError");
3547
3538
  };
3548
- o?.aborted && a();
3549
- const s = await e.fetchTile(n, r, { boundless: !1, pool: i, signal: o });
3550
- o?.aborted && a();
3551
- const l = s.array, c = e.cachedTags.samplesPerPixel, d = { minFilter: "nearest", magFilter: "nearest" }, h = c === 1, g = h ? br(l) : Ir(l), f = t.createTexture({
3552
- data: g,
3553
- format: h ? "r32float" : "rgba32float",
3554
- width: l.width,
3555
- height: l.height,
3556
- sampler: d
3557
- });
3558
- return {
3559
- width: l.width,
3560
- height: l.height,
3561
- byteLength: g.byteLength,
3562
- texture: f,
3563
- colormapTexture: await gt(t),
3564
- bandCount: c,
3565
- nodata: l.nodata
3539
+ o?.aborted && s();
3540
+ const l = await e.fetchTile(n, r, { boundless: !1, pool: i, signal: o });
3541
+ o?.aborted && s();
3542
+ const c = l.array, u = e.cachedTags.samplesPerPixel, h = c.layout === "band-separate" ? c.bands.reduce((S, b) => S + b.byteLength || 0, 0) : c.data.byteLength, p = {
3543
+ width: c.width,
3544
+ height: c.height,
3545
+ byteLength: h,
3546
+ device: t,
3547
+ array: c,
3548
+ bandTextures: /* @__PURE__ */ new Map(),
3549
+ colormapTexture: await Ut(t),
3550
+ bandCount: u,
3551
+ nodata: c.nodata
3566
3552
  };
3553
+ if (a) {
3554
+ const S = _e(a.bands, u), b = Mt(p, S);
3555
+ return p.array = null, p.byteLength = new Set(b).size * c.width * c.height * 4, p;
3556
+ }
3557
+ let g = Z.get(e);
3558
+ g || Z.set(e, g = /* @__PURE__ */ new Map());
3559
+ const y = `${n},${r}`;
3560
+ return g.set(y, p), p.identifyKey = { image: e, key: y }, p;
3567
3561
  };
3562
+ function ae(e) {
3563
+ const t = e.bitsPerSample?.[0] ?? 8, n = e.sampleFormat?.[0] ?? 1;
3564
+ return n === 3 ? `float${t}` : n === 2 ? `int${t}` : `uint${t}`;
3565
+ }
3566
+ function dt(e) {
3567
+ return (e.bitsPerSample?.[0] ?? 8) === 8 && (e.sampleFormat?.[0] ?? 1) === 1;
3568
+ }
3569
+ const Me = /* @__PURE__ */ new WeakMap();
3570
+ function Jr(e, t) {
3571
+ let n = Me.get(e);
3572
+ return n || Me.set(e, n = /* @__PURE__ */ new Map()), { get: () => n.get(t), set: (r) => n.set(t, r) };
3573
+ }
3574
+ function ht(e, t) {
3575
+ const n = e?.bandStatistics;
3576
+ if (!n) return null;
3577
+ const r = [];
3578
+ for (const o of t) {
3579
+ const i = n.get(o + 1);
3580
+ if (!i || i.min === null || i.max === null || !Number.isFinite(i.min) || !Number.isFinite(i.max) || i.min >= i.max) return null;
3581
+ r.push([i.min, i.max]);
3582
+ }
3583
+ return t.length === 1 ? { min: r[0][0], max: r[0][1], source: "stats" } : { min: [r[0][0], r[1][0], r[2][0]], max: [r[0][1], r[1][1], r[2][1]], source: "stats" };
3584
+ }
3585
+ async function pt(e, t, n) {
3586
+ const o = (await e.fetchTile(0, 0, { boundless: !1, pool: n })).array, i = o.nodata ?? null, a = [];
3587
+ for (const s of t) {
3588
+ const l = Ot(o, s);
3589
+ let c = 1 / 0, u = -1 / 0;
3590
+ for (let h = 0; h < l.length; h++) {
3591
+ const p = l[h];
3592
+ !Number.isFinite(p) || p === i || (p < c && (c = p), p > u && (u = p));
3593
+ }
3594
+ if (!(c < u)) return null;
3595
+ a.push([c, u]);
3596
+ }
3597
+ return t.length === 1 ? { min: a[0][0], max: a[0][1], source: "overview" } : { min: [a[0][0], a[1][0], a[2][0]], max: [a[0][1], a[1][1], a[2][1]], source: "overview" };
3598
+ }
3599
+ const mt = 12;
3600
+ function gt(e, t) {
3601
+ const n = Math.floor(e.length / 3), r = t.layout === "band-separate" ? t.bands[0] : t.data, o = /* @__PURE__ */ new Set(), i = t.width * t.height, a = t.layout === "band-separate" ? 1 : t.count ?? 1;
3602
+ for (let l = 0; l < i; l++)
3603
+ if (o.add(Number(r[l * a])), o.size > mt) return null;
3604
+ const s = (l) => (l >> 8).toString(16).padStart(2, "0");
3605
+ return [...o].filter((l) => Number.isInteger(l) && l >= 0 && l < n).sort((l, c) => l - c).map((l) => ({
3606
+ color: `#${s(e[l])}${s(e[n + l])}${s(e[n * 2 + l])}`,
3607
+ label: String(l)
3608
+ }));
3609
+ }
3610
+ const Oe = /* @__PURE__ */ new WeakSet(), Ke = /* @__PURE__ */ new Set(), xe = /* @__PURE__ */ new Set(), De = /* @__PURE__ */ new Set();
3611
+ function Ne(e, t, n) {
3612
+ if (Ke.has(e)) return;
3613
+ Ke.add(e);
3614
+ const r = (i) => Array.isArray(i) ? `[${i.map((a) => +a.toFixed(4)).join(", ")}]` : String(+i.toFixed(4)), o = n.source === "stats" ? "from file statistics" : "SAMPLED FROM THE COARSEST OVERVIEW (no GDAL statistics tags) — the window is data-derived and can move if the file is regenerated";
3615
+ console.warn(`[onlymapjs] "${e}" is ${t} — auto-stretched to [${r(n.min)}, ${r(n.max)}] ${o}. Set min/max (or rescale) explicitly for stable styling.`);
3616
+ }
3568
3617
  let W;
3569
- function jr() {
3618
+ function Y() {
3570
3619
  if (W) return W;
3571
3620
  try {
3572
- W = new ne({ createWorker: () => new Lr() });
3621
+ W = new oe({ createWorker: () => new Wr() });
3573
3622
  } catch (e) {
3574
- console.warn("[onlymapjs] COGLayer: worker decode unavailable — falling back to main-thread decode.", e), W = new ne({});
3623
+ console.warn("[onlymapjs] COGLayer: worker decode unavailable — falling back to main-thread decode.", e), W = new oe({});
3575
3624
  }
3576
3625
  return W;
3577
3626
  }
3578
- class Er extends Cr {
3627
+ class Vr extends kr {
3579
3628
  static layerName = "OmCOGLayer";
3580
3629
  // Plain nulls (not `{type:"number", value:null}` specs): deck's typed
3581
3630
  // number props reject null defaults with a console warning per instance.
@@ -3583,32 +3632,270 @@ class Er extends Cr {
3583
3632
  rescaleMin: null,
3584
3633
  rescaleMax: null,
3585
3634
  colormap: null,
3586
- nodataOverride: null
3635
+ nodataOverride: null,
3636
+ bands: null,
3637
+ stretch: null,
3638
+ gamma: null,
3639
+ reverse: null
3587
3640
  };
3588
3641
  constructor(t) {
3589
- const n = t, r = { ...t, pool: t.pool ?? jr() };
3590
- if (!(n.rescaleMin != null || n.rescaleMax != null || n.colormap != null && n.colormap !== "" || n.nodataOverride != null)) {
3591
- super(r);
3642
+ super({ ...t, pool: t.pool ?? Y() }, {
3643
+ // Free the per-tile band textures + retained decode on cache eviction
3644
+ // (the guard makes this a no-op for the unstyled path's upstream tile
3645
+ // shape); the sprite texture is device-scoped and must NOT die here.
3646
+ onTileUnload: (n) => {
3647
+ const r = n.data;
3648
+ !r || typeof r != "object" || !("bandTextures" in r) || (At(r), r.identifyKey && Z.get(r.identifyKey.image)?.delete(r.identifyKey.key));
3649
+ }
3650
+ });
3651
+ }
3652
+ // The styled/unstyled fork lives in the CALLBACK RESOLVERS, not the
3653
+ // constructor (COG v2 phase 3): the fork now depends on the file header
3654
+ // (bit depth, palette, stats), which only exists once the async open
3655
+ // lands in state. Upstream reads these resolvers per render and recreates
3656
+ // its own wrappers each call, so fresh closures here are its native
3657
+ // convention — tile refetch is keyed on the tileset descriptor, never on
3658
+ // callback identity.
3659
+ /**
3660
+ * Upstream's `_parseGeoTIFF` EAGERLY infers a render pipeline at its tail
3661
+ * and HARD-THROWS for int/float sources ("Inferring render pipeline for
3662
+ * non-unsigned integers not yet supported") — before `state.geotiff` ever
3663
+ * lands, which would kill the exact auto-route that exists to serve those
3664
+ * sources. Conditional retry: the normal run stays untouched (uint8 infers
3665
+ * fine, one header fetch); on the inference throw only, re-run with a
3666
+ * props OVERLAY (prototype chain — the real props object is never mutated)
3667
+ * whose callback pair suppresses the infer, so state.geotiff lands and the
3668
+ * resolvers below route the source through the styled pipeline. The retry
3669
+ * costs one extra header fetch, paid only by sources that were a dead
3670
+ * layer before this existed.
3671
+ */
3672
+ /** Structured runtime errors (phase 6) through the injected onRasterError → core.onRuntimeError channel — the layer stays mounted, the map stays alive. */
3673
+ omReportError(t, n, r, o) {
3674
+ const i = this.props.onRasterError;
3675
+ i?.({ severity: t, element: `om-layer#${this.props.id}`, attribute: n, message: r, fix: o });
3676
+ }
3677
+ async _parseGeoTIFF() {
3678
+ const t = String(this.props.geotiff ?? "");
3679
+ try {
3680
+ try {
3681
+ await super._parseGeoTIFF();
3682
+ } catch (i) {
3683
+ if (!/Inferring render pipeline|SampleFormat tag is required/.test(String(i))) throw i;
3684
+ await this.omRetryWithoutInference();
3685
+ }
3686
+ } catch (i) {
3687
+ if (i instanceof TypeError || /Failed to fetch|NetworkError|CORS/i.test(String(i))) {
3688
+ this.omReportError(
3689
+ "error",
3690
+ "src",
3691
+ `Could not read "${t}" — the server refused a cross-origin Range request.`,
3692
+ "Serve the COG with Access-Control-Allow-Origin (and expose Range/Content-Range headers), or host it same-origin."
3693
+ );
3694
+ return;
3695
+ }
3696
+ this.omReportError("error", "src", `Could not open "${t}" as a GeoTIFF: ${String(i).slice(0, 200)}`, "Check the URL serves a valid (Cloud-Optimized) GeoTIFF over HTTP range requests.");
3592
3697
  return;
3593
3698
  }
3594
- super(r, {
3595
- getTileData: Gr,
3596
- renderTile: (i) => i ? pt(i, n) : null,
3597
- // Free the per-tile texture on cache eviction; the sprite texture is
3598
- // device-scoped (WeakMap above) and must NOT be destroyed here.
3599
- onTileUnload: (i) => {
3600
- const a = i.data;
3601
- a && typeof a == "object" && "texture" in a && a.texture.destroy();
3699
+ const n = this.omGeotiff();
3700
+ if (!n) return;
3701
+ const r = n.cachedTags;
3702
+ n.overviews.length === 0 && !xe.has(t) && (xe.add(t), this.omReportError(
3703
+ "warning",
3704
+ "src",
3705
+ `"${t}" is a plain (non-cloud-optimized) GeoTIFF — every view re-reads the full image.`,
3706
+ "Convert once: rio cogeo create in.tif out.tif (or gdal_translate -of COG)."
3707
+ ));
3708
+ const o = this.omExtra();
3709
+ if (o.bands != null && !De.has(t)) {
3710
+ const i = r.samplesPerPixel ?? 1, a = typeof o.bands == "number" ? [o.bands] : o.bands;
3711
+ Array.isArray(a) && a.some((s) => !Number.isInteger(s) || s < 1 || s > i) && (De.add(t), this.omReportError(
3712
+ "error",
3713
+ "bands",
3714
+ `bands="${JSON.stringify(o.bands)}" but "${t}" has ${i} band${i === 1 ? "" : "s"}.`,
3715
+ `Select 1-based bands within 1..${i} (rendering falls back to the default selection meanwhile).`
3716
+ ));
3717
+ }
3718
+ }
3719
+ async omRetryWithoutInference() {
3720
+ {
3721
+ const t = this, n = t.props;
3722
+ t.props = Object.create(n, {
3723
+ getTileData: { value: ie, configurable: !0 },
3724
+ renderTile: { value: () => null, configurable: !0 }
3725
+ });
3726
+ try {
3727
+ await super._parseGeoTIFF();
3728
+ } finally {
3729
+ t.props = n;
3730
+ }
3731
+ }
3732
+ }
3733
+ omExtra() {
3734
+ return this.props;
3735
+ }
3736
+ omAuthoredStyled() {
3737
+ const t = this.omExtra();
3738
+ return t.rescaleMin != null || t.rescaleMax != null || t.colormap != null && t.colormap !== "" || t.nodataOverride != null || t.bands != null || t.stretch != null || t.gamma != null || t.reverse != null || t.rescale === "auto";
3739
+ }
3740
+ omGeotiff() {
3741
+ return this.state?.geotiff;
3742
+ }
3743
+ /**
3744
+ * The bit-depth auto-route (the "my COG is blank" fix): a non-8-bit
3745
+ * source with NO styling attrs enters the styled pipeline anyway, with a
3746
+ * window from the header. Paletted sources (ColorMap tag) never route —
3747
+ * upstream renders the palette.
3748
+ */
3749
+ omAutoWanted() {
3750
+ const t = this.omExtra();
3751
+ if (t.rescale === "auto") return !0;
3752
+ if (t.rescaleMin != null && t.rescaleMax != null) return !1;
3753
+ const n = this.omGeotiff();
3754
+ if (!n) return !1;
3755
+ const r = n.cachedTags;
3756
+ return r.colorMap ? !1 : this.omAuthoredStyled() ? !0 : !dt(r);
3757
+ }
3758
+ /** Resolved auto window, kicking off the one-shot overview sample when stats are absent. Undefined while pending/unavailable. */
3759
+ omAutoWindow() {
3760
+ if (!this.omAutoWanted()) return;
3761
+ const t = this.omGeotiff();
3762
+ if (!t) return;
3763
+ const n = this.omExtra(), r = t.cachedTags, o = _e(n.bands, r.samplesPerPixel ?? 1), i = Jr(t, o.join(",")), a = i.get();
3764
+ if (a === "pending" || a === null) return;
3765
+ if (a) return a;
3766
+ const s = ht(t.gdalMetadata, o);
3767
+ if (s)
3768
+ return i.set(s), Ne(n.geotiff ?? "", ae(r), s), this.omPublishWindow(s, o), s;
3769
+ i.set("pending");
3770
+ const l = t.overviews[t.overviews.length - 1] ?? t;
3771
+ pt(l, o, this.props.pool ?? Y()).then((c) => {
3772
+ i.set(c), c && (Ne(n.geotiff ?? "", ae(r), c), this.omPublishWindow(c, o));
3773
+ try {
3774
+ this.setState({ omAutoWindowTick: this.state?.omAutoWindowTick === 1 ? 2 : 1 });
3775
+ } catch {
3602
3776
  }
3777
+ }).catch(() => i.set(null));
3778
+ }
3779
+ /** Feeds the resolved window to the consumer (legend derivation) via the injected onAutoWindow deck prop — the onTilesetLoad compose precedent. */
3780
+ omPublishWindow(t, n) {
3781
+ const r = this.props.onAutoWindow;
3782
+ r?.({ min: t.min, max: t.max, bands: n.map((o) => o + 1), source: t.source });
3783
+ }
3784
+ omStyledActive() {
3785
+ return this.omAuthoredStyled() ? !0 : this.omAutoWindow() !== void 0;
3786
+ }
3787
+ /** Authored style + auto window filling any unauthored window end. */
3788
+ omEffectiveStyle() {
3789
+ const t = this.omExtra(), n = this.omAutoWindow();
3790
+ return {
3791
+ ...t,
3792
+ rescaleMin: t.rescaleMin ?? n?.min ?? null,
3793
+ rescaleMax: t.rescaleMax ?? n?.max ?? null
3794
+ };
3795
+ }
3796
+ /**
3797
+ * Pixel identify (COG v2 phase 4): lngLat → source CRS (the descriptor's
3798
+ * own projector) → full-res pixel (geotiff.index) → the FINEST currently-
3799
+ * loaded tile containing it → all bands sampled from the retained decode.
3800
+ * No fetch, no GPU readback; null when the point is outside the image or
3801
+ * no covering tile is resident.
3802
+ */
3803
+ identify(t) {
3804
+ if (this.props.identify === "off") return null;
3805
+ const n = this.omGeotiff(), r = this.state?.tilesetDescriptor;
3806
+ if (!n || !r?.projectFrom4326) return null;
3807
+ let o;
3808
+ try {
3809
+ o = r.projectFrom4326(t[0], t[1]);
3810
+ } catch {
3811
+ return null;
3812
+ }
3813
+ const [i, a] = n.index(o[0], o[1], Math.floor);
3814
+ if (i < 0 || a < 0 || i >= n.height || a >= n.width) return null;
3815
+ const s = n.cachedTags.samplesPerPixel ?? 1, l = [n, ...n.overviews];
3816
+ for (const c of l) {
3817
+ const u = Z.get(c);
3818
+ if (!u || u.size === 0) continue;
3819
+ const h = Math.min(c.height - 1, Math.floor(i * c.height / n.height)), p = Math.min(c.width - 1, Math.floor(a * c.width / n.width)), g = Math.floor(p / c.tileWidth), y = Math.floor(h / c.tileHeight), S = u.get(`${g},${y}`);
3820
+ if (!S?.array) continue;
3821
+ const b = Math.min(S.width - 1, p - g * c.tileWidth), v = Math.min(S.height - 1, h - y * c.tileHeight), C = jt(S.array, b, v, s), L = S.nodata;
3822
+ return {
3823
+ values: C,
3824
+ bands: C.map((E, G) => G + 1),
3825
+ nodata: L != null && C.every((E) => E === L)
3826
+ };
3827
+ }
3828
+ return null;
3829
+ }
3830
+ updateState(t) {
3831
+ super.updateState(t), Kt(this.props.id, (n) => this.identify(n)), this.omMaybePaletteLegend();
3832
+ }
3833
+ /** One-shot palette legend derivation per opened file (phase 5). */
3834
+ omMaybePaletteLegend() {
3835
+ const t = this.omGeotiff();
3836
+ if (!t || Oe.has(t)) return;
3837
+ const n = t.cachedTags;
3838
+ if (!n.colorMap) return;
3839
+ Oe.add(t);
3840
+ const r = n.colorMap;
3841
+ (t.overviews[t.overviews.length - 1] ?? t).fetchTile(0, 0, { boundless: !1, pool: this.props.pool ?? Y() }).then((i) => {
3842
+ const a = gt(r, i.array);
3843
+ if (!a || a.length === 0) return;
3844
+ const s = this.props.onPaletteLegend;
3845
+ s?.(a);
3846
+ }).catch(() => {
3603
3847
  });
3604
3848
  }
3849
+ finalizeState(t) {
3850
+ xt(this.props.id), super.finalizeState(t);
3851
+ }
3852
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3853
+ _getTileDataCallback() {
3854
+ if (!this.omStyledActive()) return super._getTileDataCallback();
3855
+ const t = this.omGeotiff();
3856
+ if (!t) return;
3857
+ const n = this.props.pool ?? Y(), r = this.props.identify === "off" ? { bands: this.omEffectiveStyle().bands } : void 0;
3858
+ return async (o, i) => {
3859
+ const { x: a, y: s, z: l } = o.index, c = l === t.overviews.length ? t : t.overviews[t.overviews.length - 1 - l];
3860
+ return ie(c, { device: i.device, x: a, y: s, signal: i.signal, pool: n, dropDecode: r });
3861
+ };
3862
+ }
3863
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3864
+ _renderTileCallback() {
3865
+ if (!this.omStyledActive()) return super._renderTileCallback();
3866
+ const t = this.omEffectiveStyle();
3867
+ return (n) => n ? Rt(n, t) : null;
3868
+ }
3869
+ /**
3870
+ * identify="off" bakes the selection into fetch-time textures, so a bands
3871
+ * change — or flipping identify back on, which must repopulate the
3872
+ * retained arrays — has to REFETCH. Surfaced as the inner TileLayer's own
3873
+ * `getTileData` update trigger by cloning what upstream renders (it
3874
+ * passes no such trigger through, and `_renderTileLayer` is TS-private).
3875
+ * Retained mode pins a constant, keeping the v2 contract: refetch keyed
3876
+ * on the tileset descriptor alone, never on styling.
3877
+ */
3878
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3879
+ renderLayers() {
3880
+ const t = super.renderLayers();
3881
+ if (!t || !this.omStyledActive()) return t;
3882
+ const r = this.props.identify === "off" ? `off:${JSON.stringify(this.omEffectiveStyle().bands ?? null)}` : "retained", o = (i) => i && typeof i.clone == "function" && i.props?.getTileData ? i.clone({ updateTriggers: { ...i.props.updateTriggers ?? {}, getTileData: r } }) : i;
3883
+ return Array.isArray(t) ? t.map(o) : o(t);
3884
+ }
3605
3885
  }
3606
- const vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3886
+ const Qr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3607
3887
  __proto__: null,
3608
- OmCOGLayer: Er
3888
+ OmCOGLayer: Vr,
3889
+ PALETTE_LEGEND_MAX_CLASSES: mt,
3890
+ dtypeName: ae,
3891
+ isUint8: dt,
3892
+ omGetTileData: ie,
3893
+ overviewWindow: pt,
3894
+ paletteLegendEntries: gt,
3895
+ statsWindow: ht
3609
3896
  }, Symbol.toStringTag, { value: "Module" }));
3610
3897
  export {
3611
- m as C,
3612
- A as D,
3613
- vr as r
3898
+ f as C,
3899
+ j as D,
3900
+ Qr as r
3614
3901
  };