@gisfun/maplibre-gl-components 0.15.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (196) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1960 -0
  3. package/dist/ControlGrid-DN5md8hp.cjs +19636 -0
  4. package/dist/ControlGrid-rVNG7B9O.js +170422 -0
  5. package/dist/DuckDBConverter-B98M0DFs.cjs +23 -0
  6. package/dist/DuckDBConverter-RPq48-t0.js +434 -0
  7. package/dist/ShapefileConverter-AjbEjEyq.cjs +1 -0
  8. package/dist/ShapefileConverter-trvt8J3z.js +125 -0
  9. package/dist/decoder-CLokFc0V.js +8 -0
  10. package/dist/decoder-D9LU4bUo.cjs +1 -0
  11. package/dist/deflate-BA1jZeSX.js +10 -0
  12. package/dist/deflate-DEdCz12a.cjs +1 -0
  13. package/dist/geojson-BQSVgKFt.cjs +1 -0
  14. package/dist/geojson-BSUuDj5k.js +2551 -0
  15. package/dist/geotiff-De1w1lBy.cjs +8 -0
  16. package/dist/geotiff-o_Fq1Na4.js +3108 -0
  17. package/dist/index-8ZZtuDTp.js +705 -0
  18. package/dist/index-B-Nr9y7J.cjs +84 -0
  19. package/dist/index-B5NoFrpY.js +8892 -0
  20. package/dist/index-Bi1MMPUx.js +4163 -0
  21. package/dist/index-C9fk_HKR.js +167 -0
  22. package/dist/index-CBBRBJvR.cjs +274 -0
  23. package/dist/index-CZxPF1qt.js +4 -0
  24. package/dist/index-CiDPSJ9T.cjs +1 -0
  25. package/dist/index-CjM_nbxd.cjs +107 -0
  26. package/dist/index-DQXdX5y1.js +4666 -0
  27. package/dist/index-Dh1kpCb6.cjs +1 -0
  28. package/dist/index-IrsIiQNM.cjs +4 -0
  29. package/dist/index.cjs +3819 -0
  30. package/dist/index.mjs +19580 -0
  31. package/dist/jpeg-CF9OGQg_.js +533 -0
  32. package/dist/jpeg-JSQOxGHy.cjs +1 -0
  33. package/dist/lerc-7LlQoT6u.js +1032 -0
  34. package/dist/lerc-BIsodce9.cjs +1 -0
  35. package/dist/lzw-BZniWIYG.js +84 -0
  36. package/dist/lzw-BhML-BvT.cjs +1 -0
  37. package/dist/main-dist-Bymiy5aM.cjs +2 -0
  38. package/dist/main-dist-Cv8AKwrY.js +629 -0
  39. package/dist/maplibre-geoman.es-Bxdg-2EU.cjs +129 -0
  40. package/dist/maplibre-geoman.es-CFgM2ajb.js +22827 -0
  41. package/dist/maplibre-gl-components.css +1 -0
  42. package/dist/packbits-B9b7gX2c.cjs +1 -0
  43. package/dist/packbits-DWY5O-FG.js +24 -0
  44. package/dist/pako.esm-Bx5X36Wo.js +1074 -0
  45. package/dist/pako.esm-DZC2QrbJ.cjs +1 -0
  46. package/dist/raw-C3ARbSFo.cjs +1 -0
  47. package/dist/raw-DUslI1gr.js +9 -0
  48. package/dist/react.cjs +1 -0
  49. package/dist/react.mjs +1306 -0
  50. package/dist/types/index.d.ts +44 -0
  51. package/dist/types/index.d.ts.map +1 -0
  52. package/dist/types/lib/adapters/AddVectorAdapter.d.ts +66 -0
  53. package/dist/types/lib/adapters/AddVectorAdapter.d.ts.map +1 -0
  54. package/dist/types/lib/adapters/CogLayerAdapter.d.ts +126 -0
  55. package/dist/types/lib/adapters/CogLayerAdapter.d.ts.map +1 -0
  56. package/dist/types/lib/adapters/PMTilesLayerAdapter.d.ts +78 -0
  57. package/dist/types/lib/adapters/PMTilesLayerAdapter.d.ts.map +1 -0
  58. package/dist/types/lib/adapters/StacLayerAdapter.d.ts +71 -0
  59. package/dist/types/lib/adapters/StacLayerAdapter.d.ts.map +1 -0
  60. package/dist/types/lib/adapters/ZarrLayerAdapter.d.ts +72 -0
  61. package/dist/types/lib/adapters/ZarrLayerAdapter.d.ts.map +1 -0
  62. package/dist/types/lib/adapters/index.d.ts +7 -0
  63. package/dist/types/lib/adapters/index.d.ts.map +1 -0
  64. package/dist/types/lib/addControlGrid.d.ts +80 -0
  65. package/dist/types/lib/addControlGrid.d.ts.map +1 -0
  66. package/dist/types/lib/colormaps/diverging.d.ts +30 -0
  67. package/dist/types/lib/colormaps/diverging.d.ts.map +1 -0
  68. package/dist/types/lib/colormaps/index.d.ts +32 -0
  69. package/dist/types/lib/colormaps/index.d.ts.map +1 -0
  70. package/dist/types/lib/colormaps/misc.d.ts +38 -0
  71. package/dist/types/lib/colormaps/misc.d.ts.map +1 -0
  72. package/dist/types/lib/colormaps/sequential.d.ts +22 -0
  73. package/dist/types/lib/colormaps/sequential.d.ts.map +1 -0
  74. package/dist/types/lib/converters/DuckDBConverter.d.ts +112 -0
  75. package/dist/types/lib/converters/DuckDBConverter.d.ts.map +1 -0
  76. package/dist/types/lib/converters/ShapefileConverter.d.ts +56 -0
  77. package/dist/types/lib/converters/ShapefileConverter.d.ts.map +1 -0
  78. package/dist/types/lib/converters/index.d.ts +8 -0
  79. package/dist/types/lib/converters/index.d.ts.map +1 -0
  80. package/dist/types/lib/converters/types.d.ts +75 -0
  81. package/dist/types/lib/converters/types.d.ts.map +1 -0
  82. package/dist/types/lib/core/AddVector.d.ts +116 -0
  83. package/dist/types/lib/core/AddVector.d.ts.map +1 -0
  84. package/dist/types/lib/core/Basemap.d.ts +206 -0
  85. package/dist/types/lib/core/Basemap.d.ts.map +1 -0
  86. package/dist/types/lib/core/BasemapReact.d.ts +32 -0
  87. package/dist/types/lib/core/BasemapReact.d.ts.map +1 -0
  88. package/dist/types/lib/core/BookmarkControl.d.ts +180 -0
  89. package/dist/types/lib/core/BookmarkControl.d.ts.map +1 -0
  90. package/dist/types/lib/core/ChoroplethControl.d.ts +105 -0
  91. package/dist/types/lib/core/ChoroplethControl.d.ts.map +1 -0
  92. package/dist/types/lib/core/CogLayer.d.ts +139 -0
  93. package/dist/types/lib/core/CogLayer.d.ts.map +1 -0
  94. package/dist/types/lib/core/CogLayerReact.d.ts +32 -0
  95. package/dist/types/lib/core/CogLayerReact.d.ts.map +1 -0
  96. package/dist/types/lib/core/Colorbar.d.ts +133 -0
  97. package/dist/types/lib/core/Colorbar.d.ts.map +1 -0
  98. package/dist/types/lib/core/ColorbarGuiControl.d.ts +79 -0
  99. package/dist/types/lib/core/ColorbarGuiControl.d.ts.map +1 -0
  100. package/dist/types/lib/core/ColorbarReact.d.ts +34 -0
  101. package/dist/types/lib/core/ColorbarReact.d.ts.map +1 -0
  102. package/dist/types/lib/core/ControlGrid.d.ts +125 -0
  103. package/dist/types/lib/core/ControlGrid.d.ts.map +1 -0
  104. package/dist/types/lib/core/ControlGridReact.d.ts +32 -0
  105. package/dist/types/lib/core/ControlGridReact.d.ts.map +1 -0
  106. package/dist/types/lib/core/HtmlControl.d.ts +140 -0
  107. package/dist/types/lib/core/HtmlControl.d.ts.map +1 -0
  108. package/dist/types/lib/core/HtmlControlReact.d.ts +32 -0
  109. package/dist/types/lib/core/HtmlControlReact.d.ts.map +1 -0
  110. package/dist/types/lib/core/HtmlGuiControl.d.ts +68 -0
  111. package/dist/types/lib/core/HtmlGuiControl.d.ts.map +1 -0
  112. package/dist/types/lib/core/InspectControl.d.ts +202 -0
  113. package/dist/types/lib/core/InspectControl.d.ts.map +1 -0
  114. package/dist/types/lib/core/InspectControlReact.d.ts +32 -0
  115. package/dist/types/lib/core/InspectControlReact.d.ts.map +1 -0
  116. package/dist/types/lib/core/Legend.d.ts +142 -0
  117. package/dist/types/lib/core/Legend.d.ts.map +1 -0
  118. package/dist/types/lib/core/LegendGuiControl.d.ts +69 -0
  119. package/dist/types/lib/core/LegendGuiControl.d.ts.map +1 -0
  120. package/dist/types/lib/core/LegendReact.d.ts +34 -0
  121. package/dist/types/lib/core/LegendReact.d.ts.map +1 -0
  122. package/dist/types/lib/core/MeasureControl.d.ts +211 -0
  123. package/dist/types/lib/core/MeasureControl.d.ts.map +1 -0
  124. package/dist/types/lib/core/MinimapControl.d.ts +77 -0
  125. package/dist/types/lib/core/MinimapControl.d.ts.map +1 -0
  126. package/dist/types/lib/core/MinimapControlReact.d.ts +32 -0
  127. package/dist/types/lib/core/MinimapControlReact.d.ts.map +1 -0
  128. package/dist/types/lib/core/PMTilesLayer.d.ts +119 -0
  129. package/dist/types/lib/core/PMTilesLayer.d.ts.map +1 -0
  130. package/dist/types/lib/core/PrintControl.d.ts +226 -0
  131. package/dist/types/lib/core/PrintControl.d.ts.map +1 -0
  132. package/dist/types/lib/core/SearchControl.d.ts +172 -0
  133. package/dist/types/lib/core/SearchControl.d.ts.map +1 -0
  134. package/dist/types/lib/core/SearchControlReact.d.ts +32 -0
  135. package/dist/types/lib/core/SearchControlReact.d.ts.map +1 -0
  136. package/dist/types/lib/core/StacLayer.d.ts +107 -0
  137. package/dist/types/lib/core/StacLayer.d.ts.map +1 -0
  138. package/dist/types/lib/core/StacSearch.d.ts +109 -0
  139. package/dist/types/lib/core/StacSearch.d.ts.map +1 -0
  140. package/dist/types/lib/core/Terrain.d.ts +165 -0
  141. package/dist/types/lib/core/Terrain.d.ts.map +1 -0
  142. package/dist/types/lib/core/TerrainReact.d.ts +32 -0
  143. package/dist/types/lib/core/TerrainReact.d.ts.map +1 -0
  144. package/dist/types/lib/core/VectorDataset.d.ts +228 -0
  145. package/dist/types/lib/core/VectorDataset.d.ts.map +1 -0
  146. package/dist/types/lib/core/VectorDatasetReact.d.ts +31 -0
  147. package/dist/types/lib/core/VectorDatasetReact.d.ts.map +1 -0
  148. package/dist/types/lib/core/ViewStateControl.d.ts +205 -0
  149. package/dist/types/lib/core/ViewStateControl.d.ts.map +1 -0
  150. package/dist/types/lib/core/ViewStateControlReact.d.ts +32 -0
  151. package/dist/types/lib/core/ViewStateControlReact.d.ts.map +1 -0
  152. package/dist/types/lib/core/ZarrLayer.d.ts +110 -0
  153. package/dist/types/lib/core/ZarrLayer.d.ts.map +1 -0
  154. package/dist/types/lib/core/types.d.ts +2793 -0
  155. package/dist/types/lib/core/types.d.ts.map +1 -0
  156. package/dist/types/lib/hooks/index.d.ts +13 -0
  157. package/dist/types/lib/hooks/index.d.ts.map +1 -0
  158. package/dist/types/lib/hooks/useBasemap.d.ts +43 -0
  159. package/dist/types/lib/hooks/useBasemap.d.ts.map +1 -0
  160. package/dist/types/lib/hooks/useCogLayer.d.ts +44 -0
  161. package/dist/types/lib/hooks/useCogLayer.d.ts.map +1 -0
  162. package/dist/types/lib/hooks/useColorbar.d.ts +36 -0
  163. package/dist/types/lib/hooks/useColorbar.d.ts.map +1 -0
  164. package/dist/types/lib/hooks/useControlGrid.d.ts +41 -0
  165. package/dist/types/lib/hooks/useControlGrid.d.ts.map +1 -0
  166. package/dist/types/lib/hooks/useHtmlControl.d.ts +39 -0
  167. package/dist/types/lib/hooks/useHtmlControl.d.ts.map +1 -0
  168. package/dist/types/lib/hooks/useInspectControl.d.ts +49 -0
  169. package/dist/types/lib/hooks/useInspectControl.d.ts.map +1 -0
  170. package/dist/types/lib/hooks/useLegend.d.ts +41 -0
  171. package/dist/types/lib/hooks/useLegend.d.ts.map +1 -0
  172. package/dist/types/lib/hooks/useMinimapControl.d.ts +35 -0
  173. package/dist/types/lib/hooks/useMinimapControl.d.ts.map +1 -0
  174. package/dist/types/lib/hooks/useSearchControl.d.ts +43 -0
  175. package/dist/types/lib/hooks/useSearchControl.d.ts.map +1 -0
  176. package/dist/types/lib/hooks/useTerrain.d.ts +43 -0
  177. package/dist/types/lib/hooks/useTerrain.d.ts.map +1 -0
  178. package/dist/types/lib/hooks/useVectorDataset.d.ts +35 -0
  179. package/dist/types/lib/hooks/useVectorDataset.d.ts.map +1 -0
  180. package/dist/types/lib/hooks/useViewState.d.ts +43 -0
  181. package/dist/types/lib/hooks/useViewState.d.ts.map +1 -0
  182. package/dist/types/lib/utils/color.d.ts +47 -0
  183. package/dist/types/lib/utils/color.d.ts.map +1 -0
  184. package/dist/types/lib/utils/fileHelpers.d.ts +207 -0
  185. package/dist/types/lib/utils/fileHelpers.d.ts.map +1 -0
  186. package/dist/types/lib/utils/helpers.d.ts +48 -0
  187. package/dist/types/lib/utils/helpers.d.ts.map +1 -0
  188. package/dist/types/lib/utils/index.d.ts +4 -0
  189. package/dist/types/lib/utils/index.d.ts.map +1 -0
  190. package/dist/types/lib/utils/providers.d.ts +46 -0
  191. package/dist/types/lib/utils/providers.d.ts.map +1 -0
  192. package/dist/types/react.d.ts +15 -0
  193. package/dist/types/react.d.ts.map +1 -0
  194. package/dist/webimage-CBRffWZD.cjs +1 -0
  195. package/dist/webimage-ibSPOLHJ.js +19 -0
  196. package/package.json +137 -0
@@ -0,0 +1,8 @@
1
+ "use strict";const Ve=require("./ControlGrid-DN5md8hp.cjs"),L={};function T(r){return(e,...t)=>Gt(r,e,t)}function q(r,e){return T(je(r,e).get)}const{apply:Gt,getOwnPropertyDescriptor:je,getPrototypeOf:De,ownKeys:Ut}=Reflect,{iterator:J,toStringTag:_t}=Symbol,vt=Object,{create:Ee,defineProperty:Lt}=vt,Nt=Array,Kt=Nt.prototype,He=Kt[J],qt=T(He),Ye=ArrayBuffer,zt=Ye.prototype;q(zt,"byteLength");const Ge=typeof SharedArrayBuffer<"u"?SharedArrayBuffer:null;Ge&&q(Ge.prototype,"byteLength");const $e=De(Uint8Array);$e.from;const E=$e.prototype;E[J];T(E.keys);T(E.values);T(E.entries);T(E.set);T(E.reverse);T(E.fill);T(E.copyWithin);T(E.sort);T(E.slice);T(E.subarray);q(E,"buffer");q(E,"byteOffset");q(E,"length");q(E,_t);const Vt=Uint8Array,Xe=Uint16Array,Pe=Uint32Array,jt=Float32Array,Z=De([][J]()),Ze=T(Z.next),Ht=T((function*(){})().next),Yt=De(Z),$t=DataView.prototype,Xt=T($t.getUint16),Oe=WeakMap,Je=Oe.prototype,Qe=T(Je.get),Zt=T(Je.set),We=new Oe,Jt=Ee(null,{next:{value:function(){const e=Qe(We,this);return Ze(e)}},[J]:{value:function(){return this}}});function Qt(r){if(r[J]===He&&Z.next===Ze)return r;const e=Ee(Jt);return Zt(We,e,qt(r)),e}const Wt=new Oe,er=Ee(Yt,{next:{value:function(){const e=Qe(Wt,this);return Ht(e)},writable:!0,configurable:!0}});for(const r of Ut(Z))r!=="next"&&Lt(er,r,je(Z,r));const et=new Ye(4),tr=new jt(et),rr=new Pe(et),R=new Xe(512),B=new Vt(512);for(let r=0;r<256;++r){const e=r-127;e<-24?(R[r]=0,R[r|256]=32768,B[r]=24,B[r|256]=24):e<-14?(R[r]=1024>>-e-14,R[r|256]=1024>>-e-14|32768,B[r]=-e-1,B[r|256]=-e-1):e<=15?(R[r]=e+15<<10,R[r|256]=e+15<<10|32768,B[r]=13,B[r|256]=13):e<128?(R[r]=31744,R[r|256]=64512,B[r]=24,B[r|256]=24):(R[r]=31744,R[r|256]=64512,B[r]=13,B[r|256]=13)}const Ce=new Pe(2048);for(let r=1;r<1024;++r){let e=r<<13,t=0;for(;(e&8388608)===0;)e<<=1,t-=8388608;e&=-8388609,t+=947912704,Ce[r]=e|t}for(let r=1024;r<2048;++r)Ce[r]=939524096+(r-1024<<13);const z=new Pe(64);for(let r=1;r<31;++r)z[r]=r<<23;z[31]=1199570944;z[32]=2147483648;for(let r=33;r<63;++r)z[r]=2147483648+(r-32<<23);z[63]=3347054592;const tt=new Xe(64);for(let r=1;r<64;++r)r!==32&&(tt[r]=1024);function sr(r){const e=r>>10;return rr[0]=Ce[tt[e]+(r&1023)]+z[e],tr[0]}function rt(r,e,...t){return sr(Xt(r,e,...Qt(t)))}var ne={exports:{}},Ue;function ir(){if(Ue)return ne.exports;Ue=1;function r(e,t,s){const i=s&&s.debug||!1;i&&console.log("[xml-utils] getting "+t+" in "+e);const n=typeof e=="object"?e.outer:e,a=n.slice(0,n.indexOf(">")+1),o=['"',"'"];for(let l=0;l<o.length;l++){const c=o[l],f=t+"\\="+c+"([^"+c+"]*)"+c;i&&console.log("[xml-utils] pattern:",f);const u=new RegExp(f).exec(a);if(i&&console.log("[xml-utils] match:",u),u)return u[1]}}return ne.exports=r,ne.exports.default=r,ne.exports}var nr=ir();const Se=Ve.getDefaultExportFromCjs(nr);var oe={exports:{}},ae={exports:{}},le={exports:{}},_e;function or(){if(_e)return le.exports;_e=1;function r(e,t,s){const n=new RegExp(t).exec(e.slice(s));return n?s+n.index:-1}return le.exports=r,le.exports.default=r,le.exports}var ce={exports:{}},ve;function ar(){if(ve)return ce.exports;ve=1;function r(e,t,s){const n=new RegExp(t).exec(e.slice(s));return n?s+n.index+n[0].length-1:-1}return ce.exports=r,ce.exports.default=r,ce.exports}var fe={exports:{}},Le;function lr(){if(Le)return fe.exports;Le=1;function r(e,t){const s=new RegExp(t,"g"),i=e.match(s);return i?i.length:0}return fe.exports=r,fe.exports.default=r,fe.exports}var Ne;function cr(){if(Ne)return ae.exports;Ne=1;const r=or(),e=ar(),t=lr();function s(i,n,a){const o=a&&a.debug||!1,l=!(a&&typeof a.nested===!1),c=a&&a.startIndex||0;o&&console.log("[xml-utils] starting findTagByName with",n," and ",a);const f=r(i,`<${n}[
2
+ >/]`,c);if(o&&console.log("[xml-utils] start:",f),f===-1)return;const h=i.slice(f+n.length);let u=e(h,"^[^<]*[ /]>",0);const d=u!==-1&&h[u-1]==="/";if(o&&console.log("[xml-utils] selfClosing:",d),d===!1)if(l){let x=0,w=1,S=0;for(;(u=e(h,"[ /]"+n+">",x))!==-1;){const I=h.substring(x,u+1);if(w+=t(I,"<"+n+`[
3
+ >]`),S+=t(I,"</"+n+">"),S>=w)break;x=u}}else u=e(h,"[ /]"+n+">",0);const g=f+n.length+u+1;if(o&&console.log("[xml-utils] end:",g),g===-1)return;const y=i.slice(f,g);let p;return d?p=null:p=y.slice(y.indexOf(">")+1,y.lastIndexOf("<")),{inner:p,outer:y,start:f,end:g}}return ae.exports=s,ae.exports.default=s,ae.exports}var Ke;function fr(){if(Ke)return oe.exports;Ke=1;const r=cr();function e(t,s,i){const n=[],a=i&&i.debug||!1,o=i&&typeof i.nested=="boolean"?i.nested:!0;let l=i&&i.startIndex||0,c;for(;c=r(t,s,{debug:a,startIndex:l});)o?l=c.start+1+s.length:l=c.end,n.push(c);return a&&console.log("findTagsByName found",n.length,"tags"),n}return oe.exports=e,oe.exports.default=e,oe.exports}var hr=fr();const ur=Ve.getDefaultExportFromCjs(hr),U={315:"Artist",258:"BitsPerSample",265:"CellLength",264:"CellWidth",320:"ColorMap",259:"Compression",33432:"Copyright",306:"DateTime",338:"ExtraSamples",266:"FillOrder",289:"FreeByteCounts",288:"FreeOffsets",291:"GrayResponseCurve",290:"GrayResponseUnit",316:"HostComputer",270:"ImageDescription",257:"ImageLength",256:"ImageWidth",271:"Make",281:"MaxSampleValue",280:"MinSampleValue",272:"Model",254:"NewSubfileType",274:"Orientation",262:"PhotometricInterpretation",284:"PlanarConfiguration",296:"ResolutionUnit",278:"RowsPerStrip",277:"SamplesPerPixel",305:"Software",279:"StripByteCounts",273:"StripOffsets",255:"SubfileType",263:"Threshholding",282:"XResolution",283:"YResolution",326:"BadFaxLines",327:"CleanFaxData",343:"ClipPath",328:"ConsecutiveBadFaxLines",433:"Decode",434:"DefaultImageColor",269:"DocumentName",336:"DotRange",321:"HalftoneHints",346:"Indexed",347:"JPEGTables",285:"PageName",297:"PageNumber",317:"Predictor",319:"PrimaryChromaticities",532:"ReferenceBlackWhite",339:"SampleFormat",340:"SMinSampleValue",341:"SMaxSampleValue",559:"StripRowCounts",330:"SubIFDs",292:"T4Options",293:"T6Options",325:"TileByteCounts",323:"TileLength",324:"TileOffsets",322:"TileWidth",301:"TransferFunction",318:"WhitePoint",344:"XClipPathUnits",286:"XPosition",529:"YCbCrCoefficients",531:"YCbCrPositioning",530:"YCbCrSubSampling",345:"YClipPathUnits",287:"YPosition",37378:"ApertureValue",40961:"ColorSpace",36868:"DateTimeDigitized",36867:"DateTimeOriginal",34665:"Exif IFD",36864:"ExifVersion",33434:"ExposureTime",41728:"FileSource",37385:"Flash",40960:"FlashpixVersion",33437:"FNumber",42016:"ImageUniqueID",37384:"LightSource",37500:"MakerNote",37377:"ShutterSpeedValue",37510:"UserComment",33723:"IPTC",34675:"ICC Profile",700:"XMP",42112:"GDAL_METADATA",42113:"GDAL_NODATA",34377:"Photoshop",33550:"ModelPixelScale",33922:"ModelTiepoint",34264:"ModelTransformation",34735:"GeoKeyDirectory",34736:"GeoDoubleParams",34737:"GeoAsciiParams",50674:"LercParameters"},F={};for(const r in U)U.hasOwnProperty(r)&&(F[U[r]]=parseInt(r,10));const ge={256:"SHORT",257:"SHORT",258:"SHORT",259:"SHORT",262:"SHORT",273:"LONG",274:"SHORT",277:"SHORT",278:"LONG",279:"LONG",282:"RATIONAL",283:"RATIONAL",284:"SHORT",286:"SHORT",287:"RATIONAL",296:"SHORT",297:"SHORT",305:"ASCII",306:"ASCII",338:"SHORT",339:"SHORT",513:"LONG",514:"LONG",1024:"SHORT",1025:"SHORT",2048:"SHORT",2049:"ASCII",3072:"SHORT",3073:"ASCII",33550:"DOUBLE",33922:"DOUBLE",34264:"DOUBLE",34665:"LONG",34735:"SHORT",34736:"DOUBLE",34737:"ASCII",42113:"ASCII"},st=[F.BitsPerSample,F.ExtraSamples,F.SampleFormat,F.StripByteCounts,F.StripOffsets,F.StripRowCounts,F.TileByteCounts,F.TileOffsets,F.SubIFDs],X={1:"BYTE",2:"ASCII",3:"SHORT",4:"LONG",5:"RATIONAL",6:"SBYTE",7:"UNDEFINED",8:"SSHORT",9:"SLONG",10:"SRATIONAL",11:"FLOAT",12:"DOUBLE",13:"IFD",16:"LONG8",17:"SLONG8",18:"IFD8"},m={};for(const r in X)X.hasOwnProperty(r)&&(m[X[r]]=parseInt(r,10));const O={WhiteIsZero:0,BlackIsZero:1,RGB:2,Palette:3,TransparencyMask:4,CMYK:5,YCbCr:6,CIELab:8,ICCLab:9},it={Unspecified:0,Assocalpha:1,Unassalpha:2},nt={Version:0,AddCompression:1},ot={None:0,Deflate:1,Zstandard:2},N={1024:"GTModelTypeGeoKey",1025:"GTRasterTypeGeoKey",1026:"GTCitationGeoKey",2048:"GeographicTypeGeoKey",2049:"GeogCitationGeoKey",2050:"GeogGeodeticDatumGeoKey",2051:"GeogPrimeMeridianGeoKey",2052:"GeogLinearUnitsGeoKey",2053:"GeogLinearUnitSizeGeoKey",2054:"GeogAngularUnitsGeoKey",2055:"GeogAngularUnitSizeGeoKey",2056:"GeogEllipsoidGeoKey",2057:"GeogSemiMajorAxisGeoKey",2058:"GeogSemiMinorAxisGeoKey",2059:"GeogInvFlatteningGeoKey",2060:"GeogAzimuthUnitsGeoKey",2061:"GeogPrimeMeridianLongGeoKey",2062:"GeogTOWGS84GeoKey",3072:"ProjectedCSTypeGeoKey",3073:"PCSCitationGeoKey",3074:"ProjectionGeoKey",3075:"ProjCoordTransGeoKey",3076:"ProjLinearUnitsGeoKey",3077:"ProjLinearUnitSizeGeoKey",3078:"ProjStdParallel1GeoKey",3079:"ProjStdParallel2GeoKey",3080:"ProjNatOriginLongGeoKey",3081:"ProjNatOriginLatGeoKey",3082:"ProjFalseEastingGeoKey",3083:"ProjFalseNorthingGeoKey",3084:"ProjFalseOriginLongGeoKey",3085:"ProjFalseOriginLatGeoKey",3086:"ProjFalseOriginEastingGeoKey",3087:"ProjFalseOriginNorthingGeoKey",3088:"ProjCenterLongGeoKey",3089:"ProjCenterLatGeoKey",3090:"ProjCenterEastingGeoKey",3091:"ProjCenterNorthingGeoKey",3092:"ProjScaleAtNatOriginGeoKey",3093:"ProjScaleAtCenterGeoKey",3094:"ProjAzimuthAngleGeoKey",3095:"ProjStraightVertPoleLongGeoKey",3096:"ProjRectifiedGridAngleGeoKey",4096:"VerticalCSTypeGeoKey",4097:"VerticalCitationGeoKey",4098:"VerticalDatumGeoKey",4099:"VerticalUnitsGeoKey"},at={};for(const r in N)N.hasOwnProperty(r)&&(at[N[r]]=parseInt(r,10));const gr=Object.freeze(Object.defineProperty({__proto__:null,ExtraSamplesValues:it,LercAddCompression:ot,LercParameters:nt,arrayFields:st,fieldTagNames:U,fieldTagTypes:ge,fieldTags:F,fieldTypeNames:X,fieldTypes:m,geoKeyNames:N,geoKeys:at,photometricInterpretations:O},Symbol.toStringTag,{value:"Module"}));function lt(r,e){const{width:t,height:s}=r,i=new Uint8Array(t*s*3);let n;for(let a=0,o=0;a<r.length;++a,o+=3)n=256-r[a]/e*256,i[o]=n,i[o+1]=n,i[o+2]=n;return i}function ct(r,e){const{width:t,height:s}=r,i=new Uint8Array(t*s*3);let n;for(let a=0,o=0;a<r.length;++a,o+=3)n=r[a]/e*256,i[o]=n,i[o+1]=n,i[o+2]=n;return i}function ft(r,e){const{width:t,height:s}=r,i=new Uint8Array(t*s*3),n=e.length/3,a=e.length/3*2;for(let o=0,l=0;o<r.length;++o,l+=3){const c=r[o];i[l]=e[c]/65536*256,i[l+1]=e[c+n]/65536*256,i[l+2]=e[c+a]/65536*256}return i}function ht(r){const{width:e,height:t}=r,s=new Uint8Array(e*t*3);for(let i=0,n=0;i<r.length;i+=4,n+=3){const a=r[i],o=r[i+1],l=r[i+2],c=r[i+3];s[n]=255*((255-a)/256)*((255-c)/256),s[n+1]=255*((255-o)/256)*((255-c)/256),s[n+2]=255*((255-l)/256)*((255-c)/256)}return s}function ut(r){const{width:e,height:t}=r,s=new Uint8ClampedArray(e*t*3);for(let i=0,n=0;i<r.length;i+=3,n+=3){const a=r[i],o=r[i+1],l=r[i+2];s[n]=a+1.402*(l-128),s[n+1]=a-.34414*(o-128)-.71414*(l-128),s[n+2]=a+1.772*(o-128)}return s}const dr=.95047,yr=1,pr=1.08883;function gt(r){const{width:e,height:t}=r,s=new Uint8Array(e*t*3);for(let i=0,n=0;i<r.length;i+=3,n+=3){const a=r[i+0],o=r[i+1]<<24>>24,l=r[i+2]<<24>>24;let c=(a+16)/116,f=o/500+c,h=c-l/200,u,d,g;f=dr*(f*f*f>.008856?f*f*f:(f-16/116)/7.787),c=yr*(c*c*c>.008856?c*c*c:(c-16/116)/7.787),h=pr*(h*h*h>.008856?h*h*h:(h-16/116)/7.787),u=f*3.2406+c*-1.5372+h*-.4986,d=f*-.9689+c*1.8758+h*.0415,g=f*.0557+c*-.204+h*1.057,u=u>.0031308?1.055*u**(1/2.4)-.055:12.92*u,d=d>.0031308?1.055*d**(1/2.4)-.055:12.92*d,g=g>.0031308?1.055*g**(1/2.4)-.055:12.92*g,s[n]=Math.max(0,Math.min(1,u))*255,s[n+1]=Math.max(0,Math.min(1,d))*255,s[n+2]=Math.max(0,Math.min(1,g))*255}return s}const wr=Object.freeze(Object.defineProperty({__proto__:null,fromBlackIsZero:ct,fromCIELab:gt,fromCMYK:ht,fromPalette:ft,fromWhiteIsZero:lt,fromYCbCr:ut},Symbol.toStringTag,{value:"Module"})),dt=new Map;function G(r,e){Array.isArray(r)||(r=[r]),r.forEach(t=>dt.set(t,e))}async function Fe(r){const e=dt.get(r.Compression);if(!e)throw new Error(`Unknown compression method identifier: ${r.Compression}`);const t=await e();return new t(r)}G([void 0,1],()=>Promise.resolve().then(()=>require("./raw-C3ARbSFo.cjs")).then(r=>r.default));G(5,()=>Promise.resolve().then(()=>require("./lzw-BhML-BvT.cjs")).then(r=>r.default));G(6,()=>{throw new Error("old style JPEG compression is not supported.")});G(7,()=>Promise.resolve().then(()=>require("./jpeg-JSQOxGHy.cjs")).then(r=>r.default));G([8,32946],()=>Promise.resolve().then(()=>require("./deflate-DEdCz12a.cjs")).then(r=>r.default));G(32773,()=>Promise.resolve().then(()=>require("./packbits-B9b7gX2c.cjs")).then(r=>r.default));G(34887,()=>Promise.resolve().then(()=>require("./lerc-BIsodce9.cjs")).then(async r=>(await r.zstd.init(),r)).then(r=>r.default));G(50001,()=>Promise.resolve().then(()=>require("./webimage-CBRffWZD.cjs")).then(r=>r.default));function de(r,e,t,s=1){return new(Object.getPrototypeOf(r)).constructor(e*t*s)}function mr(r,e,t,s,i){const n=e/s,a=t/i;return r.map(o=>{const l=de(o,s,i);for(let c=0;c<i;++c){const f=Math.min(Math.round(a*c),t-1);for(let h=0;h<s;++h){const u=Math.min(Math.round(n*h),e-1),d=o[f*e+u];l[c*s+h]=d}}return l})}function K(r,e,t){return(1-t)*r+t*e}function xr(r,e,t,s,i){const n=e/s,a=t/i;return r.map(o=>{const l=de(o,s,i);for(let c=0;c<i;++c){const f=a*c,h=Math.floor(f),u=Math.min(Math.ceil(f),t-1);for(let d=0;d<s;++d){const g=n*d,y=g%1,p=Math.floor(g),x=Math.min(Math.ceil(g),e-1),w=o[h*e+p],S=o[h*e+x],I=o[u*e+p],b=o[u*e+x],P=K(K(w,S,y),K(I,b,y),f%1);l[c*s+d]=P}}return l})}function Sr(r,e,t,s,i,n="nearest"){switch(n.toLowerCase()){case"nearest":return mr(r,e,t,s,i);case"bilinear":case"linear":return xr(r,e,t,s,i);default:throw new Error(`Unsupported resampling method: '${n}'`)}}function Ir(r,e,t,s,i,n){const a=e/s,o=t/i,l=de(r,s,i,n);for(let c=0;c<i;++c){const f=Math.min(Math.round(o*c),t-1);for(let h=0;h<s;++h){const u=Math.min(Math.round(a*h),e-1);for(let d=0;d<n;++d){const g=r[f*e*n+u*n+d];l[c*s*n+h*n+d]=g}}}return l}function br(r,e,t,s,i,n){const a=e/s,o=t/i,l=de(r,s,i,n);for(let c=0;c<i;++c){const f=o*c,h=Math.floor(f),u=Math.min(Math.ceil(f),t-1);for(let d=0;d<s;++d){const g=a*d,y=g%1,p=Math.floor(g),x=Math.min(Math.ceil(g),e-1);for(let w=0;w<n;++w){const S=r[h*e*n+p*n+w],I=r[h*e*n+x*n+w],b=r[u*e*n+p*n+w],P=r[u*e*n+x*n+w],V=K(K(S,I,y),K(b,P,y),f%1);l[c*s*n+d*n+w]=V}}}return l}function Tr(r,e,t,s,i,n,a="nearest"){switch(a.toLowerCase()){case"nearest":return Ir(r,e,t,s,i,n);case"bilinear":case"linear":return br(r,e,t,s,i,n);default:throw new Error(`Unsupported resampling method: '${a}'`)}}function Ar(r,e,t){let s=0;for(let i=e;i<t;++i)s+=r[i];return s}function Ie(r,e,t){switch(r){case 1:if(e<=8)return new Uint8Array(t);if(e<=16)return new Uint16Array(t);if(e<=32)return new Uint32Array(t);break;case 2:if(e===8)return new Int8Array(t);if(e===16)return new Int16Array(t);if(e===32)return new Int32Array(t);break;case 3:switch(e){case 16:case 32:return new Float32Array(t);case 64:return new Float64Array(t)}break}throw Error("Unsupported data format/bitsPerSample")}function Dr(r,e){return(r===1||r===2)&&e<=32&&e%8===0?!1:!(r===3&&(e===16||e===32||e===64))}function Er(r,e,t,s,i,n,a){const o=new DataView(r),l=t===2?a*n:a*n*s,c=t===2?1:s,f=Ie(e,i,l),h=parseInt("1".repeat(i),2);if(e===1){let u;t===1?u=s*i:u=i;let d=n*u;(d&7)!==0&&(d=d+7&-8);for(let g=0;g<a;++g){const y=g*d;for(let p=0;p<n;++p){const x=y+p*c*i;for(let w=0;w<c;++w){const S=x+w*i,I=(g*n+p)*c+w,b=Math.floor(S/8),P=S%8;if(P+i<=8)f[I]=o.getUint8(b)>>8-i-P&h;else if(P+i<=16)f[I]=o.getUint16(b)>>16-i-P&h;else if(P+i<=24){const V=o.getUint16(b)<<8|o.getUint8(b+2);f[I]=V>>24-i-P&h}else f[I]=o.getUint32(b)>>32-i-P&h}}}}return f.buffer}class ke{constructor(e,t,s,i,n,a){this.fileDirectory=e,this.geoKeys=t,this.dataView=s,this.littleEndian=i,this.tiles=n?{}:null,this.isTiled=!e.StripOffsets;const o=e.PlanarConfiguration;if(this.planarConfiguration=typeof o>"u"?1:o,this.planarConfiguration!==1&&this.planarConfiguration!==2)throw new Error("Invalid planar configuration.");this.source=a}getFileDirectory(){return this.fileDirectory}getGeoKeys(){return this.geoKeys}getWidth(){return this.fileDirectory.ImageWidth}getHeight(){return this.fileDirectory.ImageLength}getSamplesPerPixel(){return typeof this.fileDirectory.SamplesPerPixel<"u"?this.fileDirectory.SamplesPerPixel:1}getTileWidth(){return this.isTiled?this.fileDirectory.TileWidth:this.getWidth()}getTileHeight(){return this.isTiled?this.fileDirectory.TileLength:typeof this.fileDirectory.RowsPerStrip<"u"?Math.min(this.fileDirectory.RowsPerStrip,this.getHeight()):this.getHeight()}getBlockWidth(){return this.getTileWidth()}getBlockHeight(e){return this.isTiled||(e+1)*this.getTileHeight()<=this.getHeight()?this.getTileHeight():this.getHeight()-e*this.getTileHeight()}getBytesPerPixel(){let e=0;for(let t=0;t<this.fileDirectory.BitsPerSample.length;++t)e+=this.getSampleByteSize(t);return e}getSampleByteSize(e){if(e>=this.fileDirectory.BitsPerSample.length)throw new RangeError(`Sample index ${e} is out of range.`);return Math.ceil(this.fileDirectory.BitsPerSample[e]/8)}getReaderForSample(e){const t=this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1,s=this.fileDirectory.BitsPerSample[e];switch(t){case 1:if(s<=8)return DataView.prototype.getUint8;if(s<=16)return DataView.prototype.getUint16;if(s<=32)return DataView.prototype.getUint32;break;case 2:if(s<=8)return DataView.prototype.getInt8;if(s<=16)return DataView.prototype.getInt16;if(s<=32)return DataView.prototype.getInt32;break;case 3:switch(s){case 16:return function(i,n){return rt(this,i,n)};case 32:return DataView.prototype.getFloat32;case 64:return DataView.prototype.getFloat64}break}throw Error("Unsupported data format/bitsPerSample")}getSampleFormat(e=0){return this.fileDirectory.SampleFormat?this.fileDirectory.SampleFormat[e]:1}getBitsPerSample(e=0){return this.fileDirectory.BitsPerSample[e]}getArrayForSample(e,t){const s=this.getSampleFormat(e),i=this.getBitsPerSample(e);return Ie(s,i,t)}async getTileOrStrip(e,t,s,i,n){const a=Math.ceil(this.getWidth()/this.getTileWidth()),o=Math.ceil(this.getHeight()/this.getTileHeight());let l;const{tiles:c}=this;this.planarConfiguration===1?l=t*a+e:this.planarConfiguration===2&&(l=s*a*o+t*a+e);let f,h;this.isTiled?(f=this.fileDirectory.TileOffsets[l],h=this.fileDirectory.TileByteCounts[l]):(f=this.fileDirectory.StripOffsets[l],h=this.fileDirectory.StripByteCounts[l]);const u=(await this.source.fetch([{offset:f,length:h}],n))[0];let d;return c===null||!c[l]?(d=(async()=>{let g=await i.decode(this.fileDirectory,u);const y=this.getSampleFormat(),p=this.getBitsPerSample();return Dr(y,p)&&(g=Er(g,y,this.planarConfiguration,this.getSamplesPerPixel(),p,this.getTileWidth(),this.getBlockHeight(t))),g})(),c!==null&&(c[l]=d)):d=c[l],{x:e,y:t,sample:s,data:await d}}async _readRaster(e,t,s,i,n,a,o,l,c){const f=this.getTileWidth(),h=this.getTileHeight(),u=this.getWidth(),d=this.getHeight(),g=Math.max(Math.floor(e[0]/f),0),y=Math.min(Math.ceil(e[2]/f),Math.ceil(u/f)),p=Math.max(Math.floor(e[1]/h),0),x=Math.min(Math.ceil(e[3]/h),Math.ceil(d/h)),w=e[2]-e[0];let S=this.getBytesPerPixel();const I=[],b=[];for(let D=0;D<t.length;++D)this.planarConfiguration===1?I.push(Ar(this.fileDirectory.BitsPerSample,0,t[D])/8):I.push(0),b.push(this.getReaderForSample(t[D]));const P=[],{littleEndian:V}=this;for(let D=p;D<x;++D)for(let ee=g;ee<y;++ee){let me;this.planarConfiguration===1&&(me=this.getTileOrStrip(ee,D,0,n,c));for(let te=0;te<t.length;++te){const re=te,Be=t[te];this.planarConfiguration===2&&(S=this.getSampleByteSize(Be),me=this.getTileOrStrip(ee,D,Be,n,c));const Et=me.then(j=>{const Pt=j.data,Ot=new DataView(Pt),xe=this.getBlockHeight(j.y),H=j.y*h,se=j.x*f,Ct=H+xe,Ft=(j.x+1)*f,kt=b[re],Rt=Math.min(xe,xe-(Ct-e[3]),d-H),Bt=Math.min(f,f-(Ft-e[2]),u-se);for(let Y=Math.max(0,e[1]-H);Y<Rt;++Y)for(let $=Math.max(0,e[0]-se);$<Bt;++$){const Mt=(Y*f+$)*S,Me=kt.call(Ot,Mt+I[re],V);let ie;i?(ie=(Y+H-e[1])*w*t.length+($+se-e[0])*t.length+re,s[ie]=Me):(ie=(Y+H-e[1])*w+$+se-e[0],s[re][ie]=Me)}});P.push(Et)}}if(await Promise.all(P),a&&e[2]-e[0]!==a||o&&e[3]-e[1]!==o){let D;return i?D=Tr(s,e[2]-e[0],e[3]-e[1],a,o,t.length,l):D=Sr(s,e[2]-e[0],e[3]-e[1],a,o,l),D.width=a,D.height=o,D}return s.width=a||e[2]-e[0],s.height=o||e[3]-e[1],s}async readRasters({window:e,samples:t=[],interleave:s,pool:i=null,width:n,height:a,resampleMethod:o,fillValue:l,signal:c}={}){const f=e||[0,0,this.getWidth(),this.getHeight()];if(f[0]>f[2]||f[1]>f[3])throw new Error("Invalid subsets");const h=f[2]-f[0],u=f[3]-f[1],d=h*u,g=this.getSamplesPerPixel();if(!t||!t.length)for(let w=0;w<g;++w)t.push(w);else for(let w=0;w<t.length;++w)if(t[w]>=g)return Promise.reject(new RangeError(`Invalid sample index '${t[w]}'.`));let y;if(s){const w=this.fileDirectory.SampleFormat?Math.max.apply(null,this.fileDirectory.SampleFormat):1,S=Math.max.apply(null,this.fileDirectory.BitsPerSample);y=Ie(w,S,d*t.length),l&&y.fill(l)}else{y=[];for(let w=0;w<t.length;++w){const S=this.getArrayForSample(t[w],d);Array.isArray(l)&&w<l.length?S.fill(l[w]):l&&!Array.isArray(l)&&S.fill(l),y.push(S)}}const p=i||await Fe(this.fileDirectory);return await this._readRaster(f,t,y,s,p,n,a,o,c)}async readRGB({window:e,interleave:t=!0,pool:s=null,width:i,height:n,resampleMethod:a,enableAlpha:o=!1,signal:l}={}){const c=e||[0,0,this.getWidth(),this.getHeight()];if(c[0]>c[2]||c[1]>c[3])throw new Error("Invalid subsets");const f=this.fileDirectory.PhotometricInterpretation;if(f===O.RGB){let x=[0,1,2];if(this.fileDirectory.ExtraSamples!==it.Unspecified&&o){x=[];for(let w=0;w<this.fileDirectory.BitsPerSample.length;w+=1)x.push(w)}return this.readRasters({window:e,interleave:t,samples:x,pool:s,width:i,height:n,resampleMethod:a,signal:l})}let h;switch(f){case O.WhiteIsZero:case O.BlackIsZero:case O.Palette:h=[0];break;case O.CMYK:h=[0,1,2,3];break;case O.YCbCr:case O.CIELab:h=[0,1,2];break;default:throw new Error("Invalid or unsupported photometric interpretation.")}const u={window:c,interleave:!0,samples:h,pool:s,width:i,height:n,resampleMethod:a,signal:l},{fileDirectory:d}=this,g=await this.readRasters(u),y=2**this.fileDirectory.BitsPerSample[0];let p;switch(f){case O.WhiteIsZero:p=lt(g,y);break;case O.BlackIsZero:p=ct(g,y);break;case O.Palette:p=ft(g,d.ColorMap);break;case O.CMYK:p=ht(g);break;case O.YCbCr:p=ut(g);break;case O.CIELab:p=gt(g);break;default:throw new Error("Unsupported photometric interpretation.")}if(!t){const x=new Uint8Array(p.length/3),w=new Uint8Array(p.length/3),S=new Uint8Array(p.length/3);for(let I=0,b=0;I<p.length;I+=3,++b)x[b]=p[I],w[b]=p[I+1],S[b]=p[I+2];p=[x,w,S]}return p.width=g.width,p.height=g.height,p}getTiePoints(){if(!this.fileDirectory.ModelTiepoint)return[];const e=[];for(let t=0;t<this.fileDirectory.ModelTiepoint.length;t+=6)e.push({i:this.fileDirectory.ModelTiepoint[t],j:this.fileDirectory.ModelTiepoint[t+1],k:this.fileDirectory.ModelTiepoint[t+2],x:this.fileDirectory.ModelTiepoint[t+3],y:this.fileDirectory.ModelTiepoint[t+4],z:this.fileDirectory.ModelTiepoint[t+5]});return e}getGDALMetadata(e=null){const t={};if(!this.fileDirectory.GDAL_METADATA)return null;const s=this.fileDirectory.GDAL_METADATA;let i=ur(s,"Item");e===null?i=i.filter(n=>Se(n,"sample")===void 0):i=i.filter(n=>Number(Se(n,"sample"))===e);for(let n=0;n<i.length;++n){const a=i[n];t[Se(a,"name")]=a.inner}return t}getGDALNoData(){if(!this.fileDirectory.GDAL_NODATA)return null;const e=this.fileDirectory.GDAL_NODATA;return Number(e.substring(0,e.length-1))}getOrigin(){const e=this.fileDirectory.ModelTiepoint,t=this.fileDirectory.ModelTransformation;if(e&&e.length===6)return[e[3],e[4],e[5]];if(t)return[t[3],t[7],t[11]];throw new Error("The image does not have an affine transformation.")}getResolution(e=null){const t=this.fileDirectory.ModelPixelScale,s=this.fileDirectory.ModelTransformation;if(t)return[t[0],-t[1],t[2]];if(s)return s[1]===0&&s[4]===0?[s[0],-s[5],s[10]]:[Math.sqrt(s[0]*s[0]+s[4]*s[4]),-Math.sqrt(s[1]*s[1]+s[5]*s[5]),s[10]];if(e){const[i,n,a]=e.getResolution();return[i*e.getWidth()/this.getWidth(),n*e.getHeight()/this.getHeight(),a*e.getWidth()/this.getWidth()]}throw new Error("The image does not have an affine transformation.")}pixelIsArea(){return this.geoKeys.GTRasterTypeGeoKey===1}getBoundingBox(e=!1){const t=this.getHeight(),s=this.getWidth();if(this.fileDirectory.ModelTransformation&&!e){const[i,n,a,o,l,c,f,h]=this.fileDirectory.ModelTransformation,d=[[0,0],[0,t],[s,0],[s,t]].map(([p,x])=>[o+i*p+n*x,h+l*p+c*x]),g=d.map(p=>p[0]),y=d.map(p=>p[1]);return[Math.min(...g),Math.min(...y),Math.max(...g),Math.max(...y)]}else{const i=this.getOrigin(),n=this.getResolution(),a=i[0],o=i[1],l=a+n[0]*s,c=o+n[1]*t;return[Math.min(a,l),Math.min(o,c),Math.max(a,l),Math.max(o,c)]}}}class Pr{constructor(e){this._dataView=new DataView(e)}get buffer(){return this._dataView.buffer}getUint64(e,t){const s=this.getUint32(e,t),i=this.getUint32(e+4,t);let n;if(t){if(n=s+2**32*i,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}if(n=2**32*s+i,!Number.isSafeInteger(n))throw new Error(`${n} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return n}getInt64(e,t){let s=0;const i=(this._dataView.getUint8(e+(t?7:0))&128)>0;let n=!0;for(let a=0;a<8;a++){let o=this._dataView.getUint8(e+(t?a:7-a));i&&(n?o!==0&&(o=~(o-1)&255,n=!1):o=~o&255),s+=o*256**a}return i&&(s=-s),s}getUint8(e,t){return this._dataView.getUint8(e,t)}getInt8(e,t){return this._dataView.getInt8(e,t)}getUint16(e,t){return this._dataView.getUint16(e,t)}getInt16(e,t){return this._dataView.getInt16(e,t)}getUint32(e,t){return this._dataView.getUint32(e,t)}getInt32(e,t){return this._dataView.getInt32(e,t)}getFloat16(e,t){return rt(this._dataView,e,t)}getFloat32(e,t){return this._dataView.getFloat32(e,t)}getFloat64(e,t){return this._dataView.getFloat64(e,t)}}class Or{constructor(e,t,s,i){this._dataView=new DataView(e),this._sliceOffset=t,this._littleEndian=s,this._bigTiff=i}get sliceOffset(){return this._sliceOffset}get sliceTop(){return this._sliceOffset+this.buffer.byteLength}get littleEndian(){return this._littleEndian}get bigTiff(){return this._bigTiff}get buffer(){return this._dataView.buffer}covers(e,t){return this.sliceOffset<=e&&this.sliceTop>=e+t}readUint8(e){return this._dataView.getUint8(e-this._sliceOffset,this._littleEndian)}readInt8(e){return this._dataView.getInt8(e-this._sliceOffset,this._littleEndian)}readUint16(e){return this._dataView.getUint16(e-this._sliceOffset,this._littleEndian)}readInt16(e){return this._dataView.getInt16(e-this._sliceOffset,this._littleEndian)}readUint32(e){return this._dataView.getUint32(e-this._sliceOffset,this._littleEndian)}readInt32(e){return this._dataView.getInt32(e-this._sliceOffset,this._littleEndian)}readFloat32(e){return this._dataView.getFloat32(e-this._sliceOffset,this._littleEndian)}readFloat64(e){return this._dataView.getFloat64(e-this._sliceOffset,this._littleEndian)}readUint64(e){const t=this.readUint32(e),s=this.readUint32(e+4);let i;if(this._littleEndian){if(i=t+2**32*s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}if(i=2**32*t+s,!Number.isSafeInteger(i))throw new Error(`${i} exceeds MAX_SAFE_INTEGER. Precision may be lost. Please report if you get this message to https://github.com/geotiffjs/geotiff.js/issues`);return i}readInt64(e){let t=0;const s=(this._dataView.getUint8(e+(this._littleEndian?7:0))&128)>0;let i=!0;for(let n=0;n<8;n++){let a=this._dataView.getUint8(e+(this._littleEndian?n:7-n));s&&(i?a!==0&&(a=~(a-1)&255,i=!1):a=~a&255),t+=a*256**n}return s&&(t=-t),t}readOffset(e){return this._bigTiff?this.readUint64(e):this.readUint32(e)}}const Cr=typeof navigator<"u"&&navigator.hardwareConcurrency||2;class yt{constructor(e=Cr,t){this.workers=null,this._awaitingDecoder=null,this.size=e,this.messageId=0,e&&(this._awaitingDecoder=t?Promise.resolve(t):new Promise(s=>{Promise.resolve().then(()=>require("./decoder-D9LU4bUo.cjs")).then(i=>{s(i.create)})}),this._awaitingDecoder.then(s=>{this._awaitingDecoder=null,this.workers=[];for(let i=0;i<e;i++)this.workers.push({worker:s(),idle:!0})}))}async decode(e,t){return this._awaitingDecoder&&await this._awaitingDecoder,this.size===0?Fe(e).then(s=>s.decode(e,t)):new Promise(s=>{const i=this.workers.find(o=>o.idle)||this.workers[Math.floor(Math.random()*this.size)];i.idle=!1;const n=this.messageId++,a=o=>{o.data.id===n&&(i.idle=!0,s(o.data.decoded),i.worker.removeEventListener("message",a))};i.worker.addEventListener("message",a),i.worker.postMessage({fileDirectory:e,buffer:t,id:n},[t])})}destroy(){this.workers&&(this.workers.forEach(e=>{e.worker.terminate()}),this.workers=null)}}const qe=`\r
4
+ \r
5
+ `;function pt(r){if(typeof Object.fromEntries<"u")return Object.fromEntries(r);const e={};for(const[t,s]of r)e[t.toLowerCase()]=s;return e}function Fr(r){const e=r.split(`\r
6
+ `).map(t=>{const s=t.split(":").map(i=>i.trim());return s[0]=s[0].toLowerCase(),s});return pt(e)}function kr(r){const[e,...t]=r.split(";").map(i=>i.trim()),s=t.map(i=>i.split("="));return{type:e,params:pt(s)}}function be(r){let e,t,s;return r&&([,e,t,s]=r.match(/bytes (\d+)-(\d+)\/(\d+)/),e=parseInt(e,10),t=parseInt(t,10),s=parseInt(s,10)),{start:e,end:t,total:s}}function Rr(r,e){let t=null;const s=new TextDecoder("ascii"),i=[],n=`--${e}`,a=`${n}--`;for(let o=0;o<10;++o)s.decode(new Uint8Array(r,o,n.length))===n&&(t=o);if(t===null)throw new Error("Could not find initial boundary");for(;t<r.byteLength;){const o=s.decode(new Uint8Array(r,t,Math.min(n.length+1024,r.byteLength-t)));if(o.length===0||o.startsWith(a))break;if(!o.startsWith(n))throw new Error("Part does not start with boundary");const l=o.substr(n.length+2);if(l.length===0)break;const c=l.indexOf(qe),f=Fr(l.substr(0,c)),{start:h,end:u,total:d}=be(f["content-range"]),g=t+n.length+c+qe.length,y=parseInt(u,10)+1-parseInt(h,10);i.push({headers:f,data:r.slice(g,g+y),offset:h,length:y,fileSize:d}),t=g+y+4}return i}class Q{async fetch(e,t=void 0){return Promise.all(e.map(s=>this.fetchSlice(s,t)))}async fetchSlice(e){throw new Error(`fetching of slice ${e} not possible, not implemented`)}get fileSize(){return null}async close(){}}class Br extends Map{constructor(e={}){if(super(),!(e.maxSize&&e.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof e.maxAge=="number"&&e.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=e.maxSize,this.maxAge=e.maxAge||Number.POSITIVE_INFINITY,this.onEviction=e.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(e){if(typeof this.onEviction=="function")for(const[t,s]of e)this.onEviction(t,s.value)}_deleteIfExpired(e,t){return typeof t.expiry=="number"&&t.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(e,t.value),this.delete(e)):!1}_getOrDeleteIfExpired(e,t){if(this._deleteIfExpired(e,t)===!1)return t.value}_getItemValue(e,t){return t.expiry?this._getOrDeleteIfExpired(e,t):t.value}_peek(e,t){const s=t.get(e);return this._getItemValue(e,s)}_set(e,t){this.cache.set(e,t),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(e,t){this.oldCache.delete(e),this._set(e,t)}*_entriesAscending(){for(const e of this.oldCache){const[t,s]=e;this.cache.has(t)||this._deleteIfExpired(t,s)===!1&&(yield e)}for(const e of this.cache){const[t,s]=e;this._deleteIfExpired(t,s)===!1&&(yield e)}}get(e){if(this.cache.has(e)){const t=this.cache.get(e);return this._getItemValue(e,t)}if(this.oldCache.has(e)){const t=this.oldCache.get(e);if(this._deleteIfExpired(e,t)===!1)return this._moveToRecent(e,t),t.value}}set(e,t,{maxAge:s=this.maxAge}={}){const i=typeof s=="number"&&s!==Number.POSITIVE_INFINITY?Date.now()+s:void 0;return this.cache.has(e)?this.cache.set(e,{value:t,expiry:i}):this._set(e,{value:t,expiry:i}),this}has(e){return this.cache.has(e)?!this._deleteIfExpired(e,this.cache.get(e)):this.oldCache.has(e)?!this._deleteIfExpired(e,this.oldCache.get(e)):!1}peek(e){if(this.cache.has(e))return this._peek(e,this.cache);if(this.oldCache.has(e))return this._peek(e,this.oldCache)}delete(e){const t=this.cache.delete(e);return t&&this._size--,this.oldCache.delete(e)||t}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(e){if(!(e&&e>0))throw new TypeError("`maxSize` must be a number greater than 0");const t=[...this._entriesAscending()],s=t.length-e;s<0?(this.cache=new Map(t),this.oldCache=new Map,this._size=t.length):(s>0&&this._emitEvictions(t.slice(0,s)),this.oldCache=new Map(t.slice(s)),this.cache=new Map,this._size=0),this.maxSize=e}*keys(){for(const[e]of this)yield e}*values(){for(const[,e]of this)yield e}*[Symbol.iterator](){for(const e of this.cache){const[t,s]=e;this._deleteIfExpired(t,s)===!1&&(yield[t,s.value])}for(const e of this.oldCache){const[t,s]=e;this.cache.has(t)||this._deleteIfExpired(t,s)===!1&&(yield[t,s.value])}}*entriesDescending(){let e=[...this.cache];for(let t=e.length-1;t>=0;--t){const s=e[t],[i,n]=s;this._deleteIfExpired(i,n)===!1&&(yield[i,n.value])}e=[...this.oldCache];for(let t=e.length-1;t>=0;--t){const s=e[t],[i,n]=s;this.cache.has(i)||this._deleteIfExpired(i,n)===!1&&(yield[i,n.value])}}*entriesAscending(){for(const[e,t]of this._entriesAscending())yield[e,t.value]}get size(){if(!this._size)return this.oldCache.size;let e=0;for(const t of this.oldCache.keys())this.cache.has(t)||e++;return Math.min(this._size+e,this.maxSize)}entries(){return this.entriesAscending()}forEach(e,t=this){for(const[s,i]of this.entriesAscending())e.call(t,i,s,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}}function wt(r,e){for(const t in e)e.hasOwnProperty(t)&&(r[t]=e[t])}function mt(r,e){return r.length<e.length?!1:r.substr(r.length-e.length)===e}function Mr(r,e){const{length:t}=r;for(let s=0;s<t;s++)e(r[s],s)}function Re(r){const e={};for(const t in r)if(r.hasOwnProperty(t)){const s=r[t];e[s]=t}return e}function C(r,e){const t=[];for(let s=0;s<r;s++)t.push(e(s));return t}async function Gr(r){return new Promise(e=>setTimeout(e,r))}function Ur(r,e){const t=Array.isArray(r)?r:Array.from(r),s=Array.isArray(e)?e:Array.from(e);return t.map((i,n)=>[i,s[n]])}class _ extends Error{constructor(e){super(e),Error.captureStackTrace&&Error.captureStackTrace(this,_),this.name="AbortError"}}class _r extends Error{constructor(e,t){super(t),this.errors=e,this.message=t,this.name="AggregateError"}}const vr=_r;class Lr{constructor(e,t,s=null){this.offset=e,this.length=t,this.data=s}get top(){return this.offset+this.length}}class ze{constructor(e,t,s){this.offset=e,this.length=t,this.blockIds=s}}class Nr extends Q{constructor(e,{blockSize:t=65536,cacheSize:s=100}={}){super(),this.source=e,this.blockSize=t,this.blockCache=new Br({maxSize:s,onEviction:(i,n)=>{this.evictedBlocks.set(i,n)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(e,t){const s=[],i=[],n=[];this.evictedBlocks.clear();for(const{offset:u,length:d}of e){let g=u+d;const{fileSize:y}=this;y!==null&&(g=Math.min(g,y));const p=Math.floor(u/this.blockSize)*this.blockSize;for(let x=p;x<g;x+=this.blockSize){const w=Math.floor(x/this.blockSize);!this.blockCache.has(w)&&!this.blockRequests.has(w)&&(this.blockIdsToFetch.add(w),i.push(w)),this.blockRequests.has(w)&&s.push(this.blockRequests.get(w)),n.push(w)}}await Gr(),this.fetchBlocks(t);const a=[];for(const u of i)this.blockRequests.has(u)&&a.push(this.blockRequests.get(u));await Promise.allSettled(s),await Promise.allSettled(a);const o=[],l=n.filter(u=>this.abortedBlockIds.has(u)||!this.blockCache.has(u));if(l.forEach(u=>this.blockIdsToFetch.add(u)),l.length>0&&t&&!t.aborted){this.fetchBlocks(null);for(const u of l){const d=this.blockRequests.get(u);if(!d)throw new Error(`Block ${u} is not in the block requests`);o.push(d)}await Promise.allSettled(o)}if(t&&t.aborted)throw new _("Request was aborted");const c=n.map(u=>this.blockCache.get(u)||this.evictedBlocks.get(u)),f=c.filter(u=>!u);if(f.length)throw new vr(f,"Request failed");const h=new Map(Ur(n,c));return this.readSliceData(e,h)}fetchBlocks(e){if(this.blockIdsToFetch.size>0){const t=this.groupBlocks(this.blockIdsToFetch),s=this.source.fetch(t,e);for(let i=0;i<t.length;++i){const n=t[i];for(const a of n.blockIds)this.blockRequests.set(a,(async()=>{try{const o=(await s)[i],l=a*this.blockSize,c=l-o.offset,f=Math.min(c+this.blockSize,o.data.byteLength),h=o.data.slice(c,f),u=new Lr(l,h.byteLength,h,a);this.blockCache.set(a,u),this.abortedBlockIds.delete(a)}catch(o){if(o.name==="AbortError")o.signal=e,this.blockCache.delete(a),this.abortedBlockIds.add(a);else throw o}finally{this.blockRequests.delete(a)}})())}this.blockIdsToFetch.clear()}}groupBlocks(e){const t=Array.from(e).sort((a,o)=>a-o);if(t.length===0)return[];let s=[],i=null;const n=[];for(const a of t)i===null||i+1===a?(s.push(a),i=a):(n.push(new ze(s[0]*this.blockSize,s.length*this.blockSize,s)),s=[a],i=a);return n.push(new ze(s[0]*this.blockSize,s.length*this.blockSize,s)),n}readSliceData(e,t){return e.map(s=>{let i=s.offset+s.length;this.fileSize!==null&&(i=Math.min(this.fileSize,i));const n=Math.floor(s.offset/this.blockSize),a=Math.floor(i/this.blockSize),o=new ArrayBuffer(s.length),l=new Uint8Array(o);for(let c=n;c<=a;++c){const f=t.get(c),h=f.offset-s.offset,u=f.top-i;let d=0,g=0,y;h<0?d=-h:h>0&&(g=h),u<0?y=f.length-d:y=i-f.offset-d;const p=new Uint8Array(f.data,d,y);l.set(p,g)}return o})}}class ye{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(e){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}}class W{constructor(e){this.url=e}async request({headers:e,signal:t}={}){throw new Error("request is not implemented")}}class Kr extends ye{constructor(e){super(),this.response=e}get status(){return this.response.status}getHeader(e){return this.response.headers.get(e)}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}}class qr extends W{constructor(e,t){super(e),this.credentials=t}async request({headers:e,signal:t}={}){const s=await fetch(this.url,{headers:e,credentials:this.credentials,signal:t});return new Kr(s)}}class zr extends ye{constructor(e,t){super(),this.xhr=e,this.data=t}get status(){return this.xhr.status}getHeader(e){return this.xhr.getResponseHeader(e)}async getData(){return this.data}}class Vr extends W{constructRequest(e,t){return new Promise((s,i)=>{const n=new XMLHttpRequest;n.open("GET",this.url),n.responseType="arraybuffer";for(const[a,o]of Object.entries(e))n.setRequestHeader(a,o);n.onload=()=>{const a=n.response;s(new zr(n,a))},n.onerror=i,n.onabort=()=>i(new _("Request aborted")),n.send(),t&&(t.aborted&&n.abort(),t.addEventListener("abort",()=>n.abort()))})}async request({headers:e,signal:t}={}){return await this.constructRequest(e,t)}}class jr extends ye{constructor(e,t){super(),this.response=e,this.dataPromise=t}get status(){return this.response.statusCode}getHeader(e){return this.response.headers[e]}async getData(){return await this.dataPromise}}class Hr extends W{constructor(e){super(e),this.parsedUrl=L.parse(this.url),this.httpApi=(this.parsedUrl.protocol==="http:",L)}constructRequest(e,t){return new Promise((s,i)=>{const n=this.httpApi.get({...this.parsedUrl,headers:e},a=>{const o=new Promise(l=>{const c=[];a.on("data",f=>{c.push(f)}),a.on("end",()=>{const f=Buffer.concat(c).buffer;l(f)}),a.on("error",i)});s(new jr(a,o))});n.on("error",i),t&&(t.aborted&&n.destroy(new _("Request aborted")),t.addEventListener("abort",()=>n.destroy(new _("Request aborted"))))})}async request({headers:e,signal:t}={}){return await this.constructRequest(e,t)}}class pe extends Q{constructor(e,t,s,i){super(),this.client=e,this.headers=t,this.maxRanges=s,this.allowFullFile=i,this._fileSize=null}async fetch(e,t){return this.maxRanges>=e.length?this.fetchSlices(e,t):(this.maxRanges>0&&e.length>1,Promise.all(e.map(s=>this.fetchSlice(s,t))))}async fetchSlices(e,t){const s=await this.client.request({headers:{...this.headers,Range:`bytes=${e.map(({offset:i,length:n})=>`${i}-${i+n}`).join(",")}`},signal:t});if(s.ok)if(s.status===206){const{type:i,params:n}=kr(s.getHeader("content-type"));if(i==="multipart/byteranges"){const h=Rr(await s.getData(),n.boundary);return this._fileSize=h[0].fileSize||null,h}const a=await s.getData(),{start:o,end:l,total:c}=be(s.getHeader("content-range"));this._fileSize=c||null;const f=[{data:a,offset:o,length:l-o}];if(e.length>1){const h=await Promise.all(e.slice(1).map(u=>this.fetchSlice(u,t)));return f.concat(h)}return f}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const i=await s.getData();return this._fileSize=i.byteLength,[{data:i,offset:0,length:i.byteLength}]}else throw new Error("Error fetching data.")}async fetchSlice(e,t){const{offset:s,length:i}=e,n=await this.client.request({headers:{...this.headers,Range:`bytes=${s}-${s+i}`},signal:t});if(n.ok)if(n.status===206){const a=await n.getData(),{total:o}=be(n.getHeader("content-range"));return this._fileSize=o||null,{data:a,offset:s,length:i}}else{if(!this.allowFullFile)throw new Error("Server responded with full file");const a=await n.getData();return this._fileSize=a.byteLength,{data:a,offset:0,length:a.byteLength}}else throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}}function we(r,{blockSize:e,cacheSize:t}){return e===null?r:new Nr(r,{blockSize:e,cacheSize:t})}function Yr(r,{headers:e={},credentials:t,maxRanges:s=0,allowFullFile:i=!1,...n}={}){const a=new qr(r,t),o=new pe(a,e,s,i);return we(o,n)}function $r(r,{headers:e={},maxRanges:t=0,allowFullFile:s=!1,...i}={}){const n=new Vr(r),a=new pe(n,e,t,s);return we(a,i)}function Xr(r,{headers:e={},maxRanges:t=0,allowFullFile:s=!1,...i}={}){const n=new Hr(r),a=new pe(n,e,t,s);return we(a,i)}function Zr(r,{headers:e={},maxRanges:t=0,allowFullFile:s=!1,...i}={}){const n=new pe(r,e,t,s);return we(n,i)}function Te(r,{forceXHR:e=!1,...t}={}){return typeof fetch=="function"&&!e?Yr(r,t):typeof XMLHttpRequest<"u"?$r(r,t):Xr(r,t)}class Jr extends Q{constructor(e){super(),this.arrayBuffer=e}fetchSlice(e,t){if(t&&t.aborted)throw new _("Request aborted");return this.arrayBuffer.slice(e.offset,e.offset+e.length)}}function Qr(r){return new Jr(r)}class Wr extends Q{constructor(e){super(),this.file=e}async fetchSlice(e,t){return new Promise((s,i)=>{const n=this.file.slice(e.offset,e.offset+e.length),a=new FileReader;a.onload=o=>s(o.target.result),a.onerror=i,a.onabort=i,a.readAsArrayBuffer(n),t&&t.addEventListener("abort",()=>a.abort())})}}function es(r){return new Wr(r)}function ts(r){return new Promise((e,t)=>{L.close(r,s=>{s?t(s):e()})})}function rs(r,e,t=void 0){return new Promise((s,i)=>{L.open(r,e,t,(n,a)=>{n?i(n):s(a)})})}function ss(...r){return new Promise((e,t)=>{L.read(...r,(s,i,n)=>{s?t(s):e({bytesRead:i,buffer:n})})})}class is extends Q{constructor(e){super(),this.path=e,this.openRequest=rs(e,"r")}async fetchSlice(e){const t=await this.openRequest,{buffer:s}=await ss(t,Buffer.alloc(e.length),0,e.length,e.offset);return s.buffer}async close(){const e=await this.openRequest;await ts(e)}}function ns(r){return new is(r)}const os=Re(U),as=Re(N),M={};wt(M,os);wt(M,as);const ls=Re(X),ue=1e3,A={nextZero:(r,e)=>{let t=e;for(;r[t]!==0;)t++;return t},readUshort:(r,e)=>r[e]<<8|r[e+1],readShort:(r,e)=>{const t=A.ui8;return t[0]=r[e+1],t[1]=r[e+0],A.i16[0]},readInt:(r,e)=>{const t=A.ui8;return t[0]=r[e+3],t[1]=r[e+2],t[2]=r[e+1],t[3]=r[e+0],A.i32[0]},readUint:(r,e)=>{const t=A.ui8;return t[0]=r[e+3],t[1]=r[e+2],t[2]=r[e+1],t[3]=r[e+0],A.ui32[0]},readASCII:(r,e,t)=>t.map(s=>String.fromCharCode(r[e+s])).join(""),readFloat:(r,e)=>{const t=A.ui8;return C(4,s=>{t[s]=r[e+3-s]}),A.fl32[0]},readDouble:(r,e)=>{const t=A.ui8;return C(8,s=>{t[s]=r[e+7-s]}),A.fl64[0]},writeUshort:(r,e,t)=>{r[e]=t>>8&255,r[e+1]=t&255},writeUint:(r,e,t)=>{r[e]=t>>24&255,r[e+1]=t>>16&255,r[e+2]=t>>8&255,r[e+3]=t>>0&255},writeASCII:(r,e,t)=>{C(t.length,s=>{r[e+s]=t.charCodeAt(s)})},ui8:new Uint8Array(8)};A.fl64=new Float64Array(A.ui8.buffer);A.writeDouble=(r,e,t)=>{A.fl64[0]=t,C(8,s=>{r[e+s]=A.ui8[7-s]})};const cs=(r,e,t,s)=>{let i=t;const n=Object.keys(s).filter(o=>o!=null&&o!=="undefined");r.writeUshort(e,i,n.length),i+=2;let a=i+12*n.length+4;for(const o of n){let l=null;typeof o=="number"?l=o:typeof o=="string"&&(l=parseInt(o,10));const c=ge[l],f=ls[c];if(c==null||c===void 0||typeof c>"u")throw new Error(`unknown type of tag: ${l}`);let h=s[o];if(h===void 0)throw new Error(`failed to get value for key ${o}`);c==="ASCII"&&typeof h=="string"&&mt(h,"\0")===!1&&(h+="\0");const u=h.length;r.writeUshort(e,i,l),i+=2,r.writeUshort(e,i,f),i+=2,r.writeUint(e,i,u),i+=4;let d=[-1,1,1,2,4,8,0,0,0,0,0,0,8][f]*u,g=i;d>4&&(r.writeUint(e,i,a),g=a),c==="ASCII"?r.writeASCII(e,g,h):c==="SHORT"?C(u,y=>{r.writeUshort(e,g+2*y,h[y])}):c==="LONG"?C(u,y=>{r.writeUint(e,g+4*y,h[y])}):c==="RATIONAL"?C(u,y=>{r.writeUint(e,g+8*y,Math.round(h[y]*1e4)),r.writeUint(e,g+8*y+4,1e4)}):c==="DOUBLE"&&C(u,y=>{r.writeDouble(e,g+8*y,h[y])}),d>4&&(d+=d&1,a+=d),i+=4}return[i,a]},fs=r=>{const e=new Uint8Array(ue);let t=4;const s=A;e[0]=77,e[1]=77,e[3]=42;let i=8;if(s.writeUint(e,t,i),t+=4,r.forEach((a,o)=>{const l=cs(s,e,i,a);i=l[1],o<r.length-1&&s.writeUint(e,l[0],i)}),e.slice)return e.slice(0,i).buffer;const n=new Uint8Array(i);for(let a=0;a<i;a++)n[a]=e[a];return n.buffer},hs=(r,e,t,s)=>{if(t==null)throw new Error(`you passed into encodeImage a width of type ${t}`);if(e==null)throw new Error(`you passed into encodeImage a width of type ${e}`);const i={256:[e],257:[t],273:[ue],278:[t],305:"geotiff.js"};if(s)for(const c in s)s.hasOwnProperty(c)&&(i[c]=s[c]);const n=new Uint8Array(fs([i])),a=new Uint8Array(r),o=i[277],l=new Uint8Array(ue+e*t*o);return C(n.length,c=>{l[c]=n[c]}),Mr(a,(c,f)=>{l[ue+f]=c}),l.buffer},us=r=>{const e={};for(const t in r)t!=="StripOffsets"&&(M[t]||console.error(t,"not in name2code:",Object.keys(M)),e[M[t]]=r[t]);return e},gs=r=>Array.isArray(r)?r:[r],ds=[["Compression",1],["PlanarConfiguration",1],["ExtraSamples",0]];function ys(r,e){const t=typeof r[0]=="number";let s,i,n,a;t?(s=e.height||e.ImageLength,n=e.width||e.ImageWidth,i=r.length/(s*n),a=r):(i=r.length,s=r[0].length,n=r[0][0].length,a=[],C(s,f=>{C(n,h=>{C(i,u=>{a.push(r[u][f][h])})})})),e.ImageLength=s,delete e.height,e.ImageWidth=n,delete e.width,e.BitsPerSample||(e.BitsPerSample=C(i,()=>8)),ds.forEach(f=>{const h=f[0];if(!e[h]){const u=f[1];e[h]=u}}),e.PhotometricInterpretation||(e.PhotometricInterpretation=e.BitsPerSample.length===3?2:1),e.SamplesPerPixel||(e.SamplesPerPixel=[i]),e.StripByteCounts||(e.StripByteCounts=[i*s*n]),e.ModelPixelScale||(e.ModelPixelScale=[360/n,180/s,0]),e.SampleFormat||(e.SampleFormat=C(i,()=>1)),!e.hasOwnProperty("GeographicTypeGeoKey")&&!e.hasOwnProperty("ProjectedCSTypeGeoKey")&&(e.GeographicTypeGeoKey=4326,e.ModelTiepoint=[0,0,0,-180,90,0],e.GeogCitationGeoKey="WGS 84",e.GTModelTypeGeoKey=2);const o=Object.keys(e).filter(f=>mt(f,"GeoKey")).sort((f,h)=>M[f]-M[h]);if(!e.GeoAsciiParams){let f="";o.forEach(h=>{const u=Number(M[h]);ge[u]==="ASCII"&&(f+=`${e[h].toString()}\0`)}),f.length>0&&(e.GeoAsciiParams=f)}if(!e.GeoKeyDirectory){const h=[1,1,0,o.length];o.forEach(u=>{const d=Number(M[u]);h.push(d);let g,y,p;ge[d]==="SHORT"?(g=1,y=0,p=e[u]):u==="GeogCitationGeoKey"?(g=e.GeoAsciiParams.length,y=Number(M.GeoAsciiParams),p=0):console.log(`[geotiff.js] couldn't get TIFFTagLocation for ${u}`),h.push(y),h.push(g),h.push(p)}),e.GeoKeyDirectory=h}for(const f of o)e.hasOwnProperty(f)&&delete e[f];["Compression","ExtraSamples","GeographicTypeGeoKey","GTModelTypeGeoKey","GTRasterTypeGeoKey","ImageLength","ImageWidth","Orientation","PhotometricInterpretation","ProjectedCSTypeGeoKey","PlanarConfiguration","ResolutionUnit","SamplesPerPixel","XPosition","YPosition","RowsPerStrip"].forEach(f=>{e[f]&&(e[f]=gs(e[f]))});const l=us(e);return hs(a,n,s,l)}class ps{log(){}debug(){}info(){}warn(){}error(){}time(){}timeEnd(){}}function ws(r=new ps){}function ms(r,e){let t=r.length-e,s=0;do{for(let i=e;i>0;i--)r[s+e]+=r[s],s++;t-=e}while(t>0)}function xs(r,e,t){let s=0,i=r.length;const n=i/t;for(;i>e;){for(let o=e;o>0;--o)r[s+e]+=r[s],++s;i-=e}const a=r.slice();for(let o=0;o<n;++o)for(let l=0;l<t;++l)r[t*o+l]=a[(t-l-1)*n+o]}function Ss(r,e,t,s,i,n){if(e===1)return r;for(let l=0;l<i.length;++l){if(i[l]%8!==0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(i[l]!==i[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=i[0]/8,o=n===2?1:i.length;for(let l=0;l<s&&!(l*o*t*a>=r.byteLength);++l){let c;if(e===2){switch(i[0]){case 8:c=new Uint8Array(r,l*o*t*a,o*t*a);break;case 16:c=new Uint16Array(r,l*o*t*a,o*t*a/2);break;case 32:c=new Uint32Array(r,l*o*t*a,o*t*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${i[0]} bits per sample.`)}ms(c,o)}else e===3&&(c=new Uint8Array(r,l*o*t*a,o*t*a),xs(c,o,a))}return r}class xt{async decode(e,t){const s=await this.decodeBlock(t),i=e.Predictor||1;if(i!==1){const n=!e.StripOffsets,a=n?e.TileWidth:e.ImageWidth,o=n?e.TileLength:e.RowsPerStrip||e.ImageLength;return Ss(s,i,a,o,e.BitsPerSample,e.PlanarConfiguration)}return s}}function Ae(r){switch(r){case m.BYTE:case m.ASCII:case m.SBYTE:case m.UNDEFINED:return 1;case m.SHORT:case m.SSHORT:return 2;case m.LONG:case m.SLONG:case m.FLOAT:case m.IFD:return 4;case m.RATIONAL:case m.SRATIONAL:case m.DOUBLE:case m.LONG8:case m.SLONG8:case m.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${r}`)}}function Is(r){const e=r.GeoKeyDirectory;if(!e)return null;const t={};for(let s=4;s<=e[3]*4;s+=4){const i=N[e[s]],n=e[s+1]?U[e[s+1]]:null,a=e[s+2],o=e[s+3];let l=null;if(!n)l=o;else{if(l=r[n],typeof l>"u"||l===null)throw new Error(`Could not get value of geoKey '${i}'.`);typeof l=="string"?l=l.substring(o,o+a-1):l.subarray&&(l=l.subarray(o,o+a),a===1&&(l=l[0]))}t[i]=l}return t}function v(r,e,t,s){let i=null,n=null;const a=Ae(e);switch(e){case m.BYTE:case m.ASCII:case m.UNDEFINED:i=new Uint8Array(t),n=r.readUint8;break;case m.SBYTE:i=new Int8Array(t),n=r.readInt8;break;case m.SHORT:i=new Uint16Array(t),n=r.readUint16;break;case m.SSHORT:i=new Int16Array(t),n=r.readInt16;break;case m.LONG:case m.IFD:i=new Uint32Array(t),n=r.readUint32;break;case m.SLONG:i=new Int32Array(t),n=r.readInt32;break;case m.LONG8:case m.IFD8:i=new Array(t),n=r.readUint64;break;case m.SLONG8:i=new Array(t),n=r.readInt64;break;case m.RATIONAL:i=new Uint32Array(t*2),n=r.readUint32;break;case m.SRATIONAL:i=new Int32Array(t*2),n=r.readInt32;break;case m.FLOAT:i=new Float32Array(t),n=r.readFloat32;break;case m.DOUBLE:i=new Float64Array(t),n=r.readFloat64;break;default:throw new RangeError(`Invalid field type: ${e}`)}if(e===m.RATIONAL||e===m.SRATIONAL)for(let o=0;o<t;o+=2)i[o]=n.call(r,s+o*a),i[o+1]=n.call(r,s+(o*a+4));else for(let o=0;o<t;++o)i[o]=n.call(r,s+o*a);return e===m.ASCII?new TextDecoder("utf-8").decode(i):i}class bs{constructor(e,t,s){this.fileDirectory=e,this.geoKeyDirectory=t,this.nextIFDByteOffset=s}}class he extends Error{constructor(e){super(`No image at index ${e}`),this.index=e}}class St{async readRasters(e={}){const{window:t,width:s,height:i}=e;let{resX:n,resY:a,bbox:o}=e;const l=await this.getImage();let c=l;const f=await this.getImageCount(),h=l.getBoundingBox();if(t&&o)throw new Error('Both "bbox" and "window" passed.');if(s||i){if(t){const[g,y]=l.getOrigin(),[p,x]=l.getResolution();o=[g+t[0]*p,y+t[1]*x,g+t[2]*p,y+t[3]*x]}const d=o||h;if(s){if(n)throw new Error("Both width and resX passed");n=(d[2]-d[0])/s}if(i){if(a)throw new Error("Both width and resY passed");a=(d[3]-d[1])/i}}if(n||a){const d=[];for(let g=0;g<f;++g){const y=await this.getImage(g),{SubfileType:p,NewSubfileType:x}=y.fileDirectory;(g===0||p===2||x&1)&&d.push(y)}d.sort((g,y)=>g.getWidth()-y.getWidth());for(let g=0;g<d.length;++g){const y=d[g],p=(h[2]-h[0])/y.getWidth(),x=(h[3]-h[1])/y.getHeight();if(c=y,n&&n>p||a&&a>x)break}}let u=t;if(o){const[d,g]=l.getOrigin(),[y,p]=c.getResolution(l);u=[Math.round((o[0]-d)/y),Math.round((o[1]-g)/p),Math.round((o[2]-d)/y),Math.round((o[3]-g)/p)],u=[Math.min(u[0],u[2]),Math.min(u[1],u[3]),Math.max(u[0],u[2]),Math.max(u[1],u[3])]}return c.readRasters({...e,window:u})}}class k extends St{constructor(e,t,s,i,n={}){super(),this.source=e,this.littleEndian=t,this.bigTiff=s,this.firstIFDOffset=i,this.cache=n.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(e,t){const s=this.bigTiff?4048:1024;return new Or((await this.source.fetch([{offset:e,length:typeof t<"u"?t:s}]))[0],e,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(e){const t=this.bigTiff?20:12,s=this.bigTiff?8:2;let i=await this.getSlice(e);const n=this.bigTiff?i.readUint64(e):i.readUint16(e),a=n*t+(this.bigTiff?16:6);i.covers(e,a)||(i=await this.getSlice(e,a));const o={};let l=e+(this.bigTiff?8:2);for(let h=0;h<n;l+=t,++h){const u=i.readUint16(l),d=i.readUint16(l+2),g=this.bigTiff?i.readUint64(l+4):i.readUint32(l+4);let y,p;const x=Ae(d),w=l+(this.bigTiff?12:8);if(x*g<=(this.bigTiff?8:4))y=v(i,d,g,w);else{const S=i.readOffset(w),I=Ae(d)*g;if(i.covers(S,I))y=v(i,d,g,S);else{const b=await this.getSlice(S,I);y=v(b,d,g,S)}}g===1&&st.indexOf(u)===-1&&!(d===m.RATIONAL||d===m.SRATIONAL)?p=y[0]:p=y,o[U[u]]=p}const c=Is(o),f=i.readOffset(e+s+t*n);return new bs(o,c,f)}async requestIFD(e){if(this.ifdRequests[e])return this.ifdRequests[e];if(e===0)return this.ifdRequests[e]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[e];if(!this.ifdRequests[e-1])try{this.ifdRequests[e-1]=this.requestIFD(e-1)}catch(t){throw t instanceof he?new he(e):t}return this.ifdRequests[e]=(async()=>{const t=await this.ifdRequests[e-1];if(t.nextIFDByteOffset===0)throw new he(e);return this.parseFileDirectoryAt(t.nextIFDByteOffset)})(),this.ifdRequests[e]}async getImage(e=0){const t=await this.requestIFD(e);return new ke(t.fileDirectory,t.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let e=0,t=!0;for(;t;)try{await this.requestIFD(e),++e}catch(s){if(s instanceof he)t=!1;else throw s}return e}async getGhostValues(){const e=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;const t="GDAL_STRUCTURAL_METADATA_SIZE=",s=t.length+100;let i=await this.getSlice(e,s);if(t===v(i,m.ASCII,t.length,e)){const a=v(i,m.ASCII,s,e).split(`
7
+ `)[0],o=Number(a.split("=")[1].split(" ")[0])+a.length;o>s&&(i=await this.getSlice(e,o));const l=v(i,m.ASCII,o,e);this.ghostValues={},l.split(`
8
+ `).filter(c=>c.length>0).map(c=>c.split("=")).forEach(([c,f])=>{this.ghostValues[c]=f})}return this.ghostValues}static async fromSource(e,t,s){const i=(await e.fetch([{offset:0,length:1024}],s))[0],n=new Pr(i),a=n.getUint16(0,0);let o;if(a===18761)o=!0;else if(a===19789)o=!1;else throw new TypeError("Invalid byte order value.");const l=n.getUint16(2,o);let c;if(l===42)c=!1;else if(l===43){if(c=!0,n.getUint16(4,o)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");const f=c?n.getUint64(8,o):n.getUint32(4,o);return new k(e,o,c,f,t)}close(){return typeof this.source.close=="function"?this.source.close():!1}}class It extends St{constructor(e,t){super(),this.mainFile=e,this.overviewFiles=t,this.imageFiles=[e].concat(t),this.fileDirectoriesPerFile=null,this.fileDirectoriesPerFileParsing=null,this.imageCount=null}async parseFileDirectoriesPerFile(){const e=[this.mainFile.parseFileDirectoryAt(this.mainFile.firstIFDOffset)].concat(this.overviewFiles.map(t=>t.parseFileDirectoryAt(t.firstIFDOffset)));return this.fileDirectoriesPerFile=await Promise.all(e),this.fileDirectoriesPerFile}async getImage(e=0){await this.getImageCount(),await this.parseFileDirectoriesPerFile();let t=0,s=0;for(let i=0;i<this.imageFiles.length;i++){const n=this.imageFiles[i];for(let a=0;a<this.imageCounts[i];a++){if(e===t){const o=await n.requestIFD(s);return new ke(o.fileDirectory,o.geoKeyDirectory,n.dataView,n.littleEndian,n.cache,n.source)}t++,s++}s=0}throw new RangeError("Invalid image index")}async getImageCount(){if(this.imageCount!==null)return this.imageCount;const e=[this.mainFile.getImageCount()].concat(this.overviewFiles.map(t=>t.getImageCount()));return this.imageCounts=await Promise.all(e),this.imageCount=this.imageCounts.reduce((t,s)=>t+s,0),this.imageCount}}async function bt(r,e={},t){return k.fromSource(Te(r,e),t)}async function Tt(r,e={},t){return k.fromSource(Zr(r,e),t)}async function At(r,e){return k.fromSource(Qr(r),e)}async function Ts(r,e){return k.fromSource(ns(r),e)}async function Dt(r,e){return k.fromSource(es(r),e)}async function As(r,e=[],t={},s){const i=await k.fromSource(Te(r,t),s),n=await Promise.all(e.map(a=>k.fromSource(Te(a,t))));return new It(i,n)}function Ds(r,e){return ys(r,e)}const Es=Object.freeze(Object.defineProperty({__proto__:null,BaseClient:W,BaseDecoder:xt,BaseResponse:ye,GeoTIFF:k,GeoTIFFImage:ke,MultiGeoTIFF:It,Pool:yt,addDecoder:G,default:k,fromArrayBuffer:At,fromBlob:Dt,fromCustomClient:Tt,fromFile:Ts,fromUrl:bt,fromUrls:As,getDecoder:Fe,globals:gr,rgb:wr,setLogger:ws,writeArrayBuffer:Ds},Symbol.toStringTag,{value:"Module"}));exports.BaseClient=W;exports.BaseDecoder=xt;exports.LercAddCompression=ot;exports.LercParameters=nt;exports.Pool=yt;exports.fromArrayBuffer=At;exports.fromBlob=Dt;exports.fromCustomClient=Tt;exports.fromUrl=bt;exports.geotiff=Es;