@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,4 @@
1
+ import { M as r } from "./ControlGrid-rVNG7B9O.js";
2
+ export {
3
+ r as MapboxOverlay
4
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./ControlGrid-DN5md8hp.cjs");exports.MapboxOverlay=e.MapboxOverlay;
@@ -0,0 +1,107 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./index-IrsIiQNM.cjs"),G=require("./geotiff-De1w1lBy.cjs"),V=require("./index-B-Nr9y7J.cjs"),m=require("./ControlGrid-DN5md8hp.cjs"),ze="Queued Requests",Ne="Active Requests",Ve="Cancelled Requests",Fe="Queued Requests Ever",qe="Active Requests Ever",Ge={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0};class Be{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...Ge,...t},this.stats=new m.Stats({id:this.props.id}),this.stats.get(ze),this.stats.get(Ne),this.stats.get(Ve),this.stats.get(Fe),this.stats.get(qe)}scheduleRequest(t,e=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);const s={handle:t,priority:0,getPriority:e},i=new Promise(o=>(s.resolve=o,s));return this.requestQueue.push(s),this.requestMap.set(t,i),this._issueNewRequests(),i}_issueRequest(t){const{handle:e,resolve:s}=t;let i=!1;const o=()=>{i||(i=!0,this.requestMap.delete(e),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,s?s({done:o}):Promise.resolve({done:o})}_issueNewRequests(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=setTimeout(()=>this._issueNewRequestsAsync(),this.props.debounceTime)}_issueNewRequestsAsync(){this.updateTimer!==null&&clearTimeout(this.updateTimer),this.updateTimer=null;const t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let e=0;e<t;++e){const s=this.requestQueue.shift();s&&this._issueRequest(s)}}}_updateAllRequests(){const t=this.requestQueue;for(let e=0;e<t.length;++e){const s=t[e];this._updateRequest(s)||(t.splice(e,1),this.requestMap.delete(s.handle),e--)}t.sort((e,s)=>e.priority-s.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}}function De(n){let t=1/0,e=1/0,s=1/0,i=-1/0,o=-1/0,r=-1/0;const a=n.POSITION?n.POSITION.value:[],c=a&&a.length;for(let h=0;h<c;h+=3){const u=a[h],l=a[h+1],d=a[h+2];t=u<t?u:t,e=l<e?l:e,s=d<s?d:s,i=u>i?u:i,o=l>o?l:o,r=d>r?d:r}return[[t,e,s],[i,o,r]]}let Y;class xt extends m.Vector{static get ZERO(){return Y||(Y=new xt(0,0,0,0),Object.freeze(Y)),Y}constructor(t=0,e=0,s=0,i=0){super(-0,-0,-0,-0),m.isArray(t)&&arguments.length===1?this.copy(t):(m.config.debug&&(m.checkNumber(t),m.checkNumber(e),m.checkNumber(s),m.checkNumber(i)),this[0]=t,this[1]=e,this[2]=s,this[3]=i)}set(t,e,s,i){return this[0]=t,this[1]=e,this[2]=s,this[3]=i,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}fromObject(t){return m.config.debug&&(m.checkNumber(t.x),m.checkNumber(t.y),m.checkNumber(t.z),m.checkNumber(t.w)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t.w=this[3],t}get ELEMENTS(){return 4}get z(){return this[2]}set z(t){this[2]=m.checkNumber(t)}get w(){return this[3]}set w(t){this[3]=m.checkNumber(t)}transform(t){return m.transformMat4(this,this,t),this.check()}transformByMatrix3(t){return m.vec4_transformMat3(this,this,t),this.check()}transformByMatrix2(t){return m.vec4_transformMat2(this,this,t),this.check()}transformByQuaternion(t){return m.transformQuat(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}}function Ue(){const n=new m.ARRAY_TYPE(9);return m.ARRAY_TYPE!=Float32Array&&(n[1]=0,n[2]=0,n[3]=0,n[5]=0,n[6]=0,n[7]=0),n[0]=1,n[4]=1,n[8]=1,n}function ke(n,t){if(n===t){const e=t[1],s=t[2],i=t[5];n[1]=t[3],n[2]=t[6],n[3]=e,n[5]=t[7],n[6]=s,n[7]=i}else n[0]=t[0],n[1]=t[3],n[2]=t[6],n[3]=t[1],n[4]=t[4],n[5]=t[7],n[6]=t[2],n[7]=t[5],n[8]=t[8];return n}function We(n,t){const e=t[0],s=t[1],i=t[2],o=t[3],r=t[4],a=t[5],c=t[6],h=t[7],u=t[8],l=u*r-a*h,d=-u*o+a*c,f=h*o-r*c;let p=e*l+s*d+i*f;return p?(p=1/p,n[0]=l*p,n[1]=(-u*s+i*h)*p,n[2]=(a*s-i*r)*p,n[3]=d*p,n[4]=(u*e-i*c)*p,n[5]=(-a*e+i*o)*p,n[6]=f*p,n[7]=(-h*e+s*c)*p,n[8]=(r*e-s*o)*p,n):null}function je(n){const t=n[0],e=n[1],s=n[2],i=n[3],o=n[4],r=n[5],a=n[6],c=n[7],h=n[8];return t*(h*o-r*c)+e*(-h*i+r*a)+s*(c*i-o*a)}function Nt(n,t,e){const s=t[0],i=t[1],o=t[2],r=t[3],a=t[4],c=t[5],h=t[6],u=t[7],l=t[8],d=e[0],f=e[1],p=e[2],g=e[3],y=e[4],_=e[5],x=e[6],M=e[7],T=e[8];return n[0]=d*s+f*r+p*h,n[1]=d*i+f*a+p*u,n[2]=d*o+f*c+p*l,n[3]=g*s+y*r+_*h,n[4]=g*i+y*a+_*u,n[5]=g*o+y*c+_*l,n[6]=x*s+M*r+T*h,n[7]=x*i+M*a+T*u,n[8]=x*o+M*c+T*l,n}function Ye(n,t,e){const s=t[0],i=t[1],o=t[2],r=t[3],a=t[4],c=t[5],h=t[6],u=t[7],l=t[8],d=e[0],f=e[1];return n[0]=s,n[1]=i,n[2]=o,n[3]=r,n[4]=a,n[5]=c,n[6]=d*s+f*r+h,n[7]=d*i+f*a+u,n[8]=d*o+f*c+l,n}function Xe(n,t,e){const s=t[0],i=t[1],o=t[2],r=t[3],a=t[4],c=t[5],h=t[6],u=t[7],l=t[8],d=Math.sin(e),f=Math.cos(e);return n[0]=f*s+d*r,n[1]=f*i+d*a,n[2]=f*o+d*c,n[3]=f*r-d*s,n[4]=f*a-d*i,n[5]=f*c-d*o,n[6]=h,n[7]=u,n[8]=l,n}function Vt(n,t,e){const s=e[0],i=e[1];return n[0]=s*t[0],n[1]=s*t[1],n[2]=s*t[2],n[3]=i*t[3],n[4]=i*t[4],n[5]=i*t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n}function $e(n,t){const e=t[0],s=t[1],i=t[2],o=t[3],r=e+e,a=s+s,c=i+i,h=e*r,u=s*r,l=s*a,d=i*r,f=i*a,p=i*c,g=o*r,y=o*a,_=o*c;return n[0]=1-l-p,n[3]=u-_,n[6]=d+y,n[1]=u+_,n[4]=1-h-p,n[7]=f-g,n[2]=d-y,n[5]=f+g,n[8]=1-h-l,n}var dt;(function(n){n[n.COL0ROW0=0]="COL0ROW0",n[n.COL0ROW1=1]="COL0ROW1",n[n.COL0ROW2=2]="COL0ROW2",n[n.COL1ROW0=3]="COL1ROW0",n[n.COL1ROW1=4]="COL1ROW1",n[n.COL1ROW2=5]="COL1ROW2",n[n.COL2ROW0=6]="COL2ROW0",n[n.COL2ROW1=7]="COL2ROW1",n[n.COL2ROW2=8]="COL2ROW2"})(dt||(dt={}));const Ze=Object.freeze([1,0,0,0,1,0,0,0,1]);class E extends m.Matrix{static get IDENTITY(){return Ke()}static get ZERO(){return He()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return dt}constructor(t,...e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):e.length>0?this.copy([t,...e]):this.identity()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this.check()}identity(){return this.copy(Ze)}fromObject(t){return this.check()}fromQuaternion(t){return $e(this,t),this.check()}set(t,e,s,i,o,r,a,c,h){return this[0]=t,this[1]=e,this[2]=s,this[3]=i,this[4]=o,this[5]=r,this[6]=a,this[7]=c,this[8]=h,this.check()}setRowMajor(t,e,s,i,o,r,a,c,h){return this[0]=t,this[1]=i,this[2]=a,this[3]=e,this[4]=o,this[5]=c,this[6]=s,this[7]=r,this[8]=h,this.check()}determinant(){return je(this)}transpose(){return ke(this,this),this.check()}invert(){return We(this,this),this.check()}multiplyLeft(t){return Nt(this,t,this),this.check()}multiplyRight(t){return Nt(this,this,t),this.check()}rotate(t){return Xe(this,this,t),this.check()}scale(t){return Array.isArray(t)?Vt(this,this,t):Vt(this,this,[t,t]),this.check()}translate(t){return Ye(this,this,t),this.check()}transform(t,e){let s;switch(t.length){case 2:s=m.transformMat3$1(e||[-0,-0],t,this);break;case 3:s=m.transformMat3(e||[-0,-0,-0],t,this);break;case 4:s=m.vec4_transformMat3(e||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return m.checkVector(s,t.length),s}transformVector(t,e){return this.transform(t,e)}transformVector2(t,e){return this.transform(t,e)}transformVector3(t,e){return this.transform(t,e)}}let X,$=null;function He(){return X||(X=new E([0,0,0,0,0,0,0,0,0]),Object.freeze(X)),X}function Ke(){return $||($=new E,Object.freeze($)),$}function Ft(){const n=new m.ARRAY_TYPE(4);return m.ARRAY_TYPE!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n[3]=1,n}function Qe(n){return n[0]=0,n[1]=0,n[2]=0,n[3]=1,n}function le(n,t,e){e=e*.5;const s=Math.sin(e);return n[0]=s*t[0],n[1]=s*t[1],n[2]=s*t[2],n[3]=Math.cos(e),n}function qt(n,t,e){const s=t[0],i=t[1],o=t[2],r=t[3],a=e[0],c=e[1],h=e[2],u=e[3];return n[0]=s*u+r*a+i*h-o*c,n[1]=i*u+r*c+o*a-s*h,n[2]=o*u+r*h+s*c-i*a,n[3]=r*u-s*a-i*c-o*h,n}function Je(n,t,e){e*=.5;const s=t[0],i=t[1],o=t[2],r=t[3],a=Math.sin(e),c=Math.cos(e);return n[0]=s*c+r*a,n[1]=i*c+o*a,n[2]=o*c-i*a,n[3]=r*c-s*a,n}function ts(n,t,e){e*=.5;const s=t[0],i=t[1],o=t[2],r=t[3],a=Math.sin(e),c=Math.cos(e);return n[0]=s*c-o*a,n[1]=i*c+r*a,n[2]=o*c+s*a,n[3]=r*c-i*a,n}function es(n,t,e){e*=.5;const s=t[0],i=t[1],o=t[2],r=t[3],a=Math.sin(e),c=Math.cos(e);return n[0]=s*c+i*a,n[1]=i*c-s*a,n[2]=o*c+r*a,n[3]=r*c-o*a,n}function ss(n,t){const e=t[0],s=t[1],i=t[2];return n[0]=e,n[1]=s,n[2]=i,n[3]=Math.sqrt(Math.abs(1-e*e-s*s-i*i)),n}function et(n,t,e,s){const i=t[0],o=t[1],r=t[2],a=t[3];let c=e[0],h=e[1],u=e[2],l=e[3],d,f,p,g,y;return d=i*c+o*h+r*u+a*l,d<0&&(d=-d,c=-c,h=-h,u=-u,l=-l),1-d>m.EPSILON?(f=Math.acos(d),y=Math.sin(f),p=Math.sin((1-s)*f)/y,g=Math.sin(s*f)/y):(p=1-s,g=s),n[0]=p*i+g*c,n[1]=p*o+g*h,n[2]=p*r+g*u,n[3]=p*a+g*l,n}function ns(n,t){const e=t[0],s=t[1],i=t[2],o=t[3],r=e*e+s*s+i*i+o*o,a=r?1/r:0;return n[0]=-e*a,n[1]=-s*a,n[2]=-i*a,n[3]=o*a,n}function is(n,t){return n[0]=-t[0],n[1]=-t[1],n[2]=-t[2],n[3]=t[3],n}function he(n,t){const e=t[0]+t[4]+t[8];let s;if(e>0)s=Math.sqrt(e+1),n[3]=.5*s,s=.5/s,n[0]=(t[5]-t[7])*s,n[1]=(t[6]-t[2])*s,n[2]=(t[1]-t[3])*s;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[i*3+i]&&(i=2);const o=(i+1)%3,r=(i+2)%3;s=Math.sqrt(t[i*3+i]-t[o*3+o]-t[r*3+r]+1),n[i]=.5*s,s=.5/s,n[3]=(t[o*3+r]-t[r*3+o])*s,n[o]=(t[o*3+i]+t[i*3+o])*s,n[r]=(t[r*3+i]+t[i*3+r])*s}return n}const os=m.add,rs=m.scale,as=m.dot,cs=m.lerp,ls=m.length,hs=m.squaredLength,ue=m.normalize$1,us=(function(){const n=m.create(),t=m.fromValues(1,0,0),e=m.fromValues(0,1,0);return function(s,i,o){const r=m.dot$1(i,o);return r<-.999999?(m.cross(n,t,i),m.len(n)<1e-6&&m.cross(n,e,i),m.normalize(n,n),le(s,n,Math.PI),s):r>.999999?(s[0]=0,s[1]=0,s[2]=0,s[3]=1,s):(m.cross(n,i,o),s[0]=n[0],s[1]=n[1],s[2]=n[2],s[3]=1+r,ue(s,s))}})();(function(){const n=Ft(),t=Ft();return function(e,s,i,o,r,a){return et(n,s,r,a),et(t,i,o,a),et(e,n,t,2*a*(1-a)),e}})();(function(){const n=Ue();return function(t,e,s,i){return n[0]=s[0],n[3]=s[1],n[6]=s[2],n[1]=i[0],n[4]=i[1],n[7]=i[2],n[2]=-e[0],n[5]=-e[1],n[8]=-e[2],ue(t,he(t,n))}})();const ds=[0,0,0,1];class Gt extends m.MathArray{constructor(t=0,e=0,s=0,i=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,e,s,i)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,e,s,i){return this[0]=t,this[1]=e,this[2]=s,this[3]=i,this.check()}fromObject(t){return this[0]=t.x,this[1]=t.y,this[2]=t.z,this[3]=t.w,this.check()}fromMatrix3(t){return he(this,t),this.check()}fromAxisRotation(t,e){return le(this,t,e),this.check()}identity(){return Qe(this),this.check()}setAxisAngle(t,e){return this.fromAxisRotation(t,e)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=m.checkNumber(t)}get y(){return this[1]}set y(t){this[1]=m.checkNumber(t)}get z(){return this[2]}set z(t){this[2]=m.checkNumber(t)}get w(){return this[3]}set w(t){this[3]=m.checkNumber(t)}len(){return ls(this)}lengthSquared(){return hs(this)}dot(t){return as(this,t)}rotationTo(t,e){return us(this,t,e),this.check()}add(t){return os(this,this,t),this.check()}calculateW(){return ss(this,this),this.check()}conjugate(){return is(this,this),this.check()}invert(){return ns(this,this),this.check()}lerp(t,e,s){return s===void 0?this.lerp(this,t,e):(cs(this,t,e,s),this.check())}multiplyRight(t){return qt(this,this,t),this.check()}multiplyLeft(t){return qt(this,t,this),this.check()}normalize(){const t=this.len(),e=t>0?1/t:0;return this[0]=this[0]*e,this[1]=this[1]*e,this[2]=this[2]*e,this[3]=this[3]*e,t===0&&(this[3]=1),this.check()}rotateX(t){return Je(this,this,t),this.check()}rotateY(t){return ts(this,this,t),this.check()}rotateZ(t){return es(this,this,t),this.check()}scale(t){return rs(this,this,t),this.check()}slerp(t,e,s){let i,o,r;switch(arguments.length){case 1:({start:i=ds,target:o,ratio:r}=t);break;case 2:i=this,o=t,r=e;break;default:i=t,o=e,r=s}return et(this,i,o,r),this.check()}transformVector4(t,e=new xt){return m.transformQuat$1(e,t,this),m.checkVector(e,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,e){return this.setAxisAngle(t,e)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}}const fs=1e-15,ms=1e-20,de={name:"phongMaterial",dependencies:[m.lighting],source:m.PHONG_WGSL,vs:m.PHONG_VS,fs:m.PHONG_FS,defines:{LIGHTING_FRAGMENT:!0},uniformTypes:{ambient:"f32",diffuse:"f32",shininess:"f32",specularColor:"vec3<f32>"},defaultUniforms:{ambient:.35,diffuse:.6,shininess:32,specularColor:[.15,.15,.15]},getUniforms(n){const t={...n};return t.specularColor&&(t.specularColor=t.specularColor.map(e=>e/255)),{...de.defaultUniforms,...t}}},fe=[0,0,0,255],ps=[0,0,0,255],gs={stroked:!0,filled:!0,extruded:!1,elevationScale:1,wireframe:!1,_normalize:!0,_windingOrder:"CW",lineWidthUnits:"meters",lineWidthScale:1,lineWidthMinPixels:0,lineWidthMaxPixels:Number.MAX_SAFE_INTEGER,lineJointRounded:!1,lineMiterLimit:4,getPolygon:{type:"accessor",value:n=>n.polygon},getFillColor:{type:"accessor",value:ps},getLineColor:{type:"accessor",value:fe},getLineWidth:{type:"accessor",value:1},getElevation:{type:"accessor",value:1e3},material:!0};class Mt extends m.CompositeLayer{initializeState(){this.state={paths:[],pathsDiff:null},this.props.getLineDashArray&&m.defaultLogger.removed("getLineDashArray","PathStyleExtension")()}updateState({changeFlags:t}){const e=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getPolygon);if(e&&Array.isArray(t.dataChanged)){const s=this.state.paths.slice(),i=t.dataChanged.map(o=>m.replaceInRange({data:s,getIndex:r=>r.__source.index,dataRange:o,replace:this._getPaths(o)}));this.setState({paths:s,pathsDiff:i})}else e&&this.setState({paths:this._getPaths(),pathsDiff:null})}_getPaths(t={}){const{data:e,getPolygon:s,positionFormat:i,_normalize:o}=this.props,r=[],a=i==="XY"?2:3,{startRow:c,endRow:h}=t,{iterable:u,objectInfo:l}=m.createIterable(e,c,h);for(const d of u){l.index++;let f=s(d,l);o&&(f=m.normalize$2(f,a));const{holeIndices:p}=f,g=f.positions||f;if(p)for(let y=0;y<=p.length;y++){const _=g.slice(p[y-1]||0,p[y]||g.length);r.push(this.getSubLayerRow({path:_},d,l.index))}else r.push(this.getSubLayerRow({path:g},d,l.index))}return r}renderLayers(){const{data:t,_dataDiff:e,stroked:s,filled:i,extruded:o,wireframe:r,_normalize:a,_windingOrder:c,elevationScale:h,transitions:u,positionFormat:l}=this.props,{lineWidthUnits:d,lineWidthScale:f,lineWidthMinPixels:p,lineWidthMaxPixels:g,lineJointRounded:y,lineMiterLimit:_,lineDashJustified:x}=this.props,{getFillColor:M,getLineColor:T,getLineWidth:w,getLineDashArray:S,getElevation:L,getPolygon:R,updateTriggers:b,material:C}=this.props,{paths:q,pathsDiff:k}=this.state,ot=this.getSubLayerClass("fill",m.SolidPolygonLayer),rt=this.getSubLayerClass("stroke",m.PathLayer),W=this.shouldRenderSubLayer("fill",q)&&new ot({_dataDiff:e,extruded:o,elevationScale:h,filled:i,wireframe:r,_normalize:a,_windingOrder:c,getElevation:L,getFillColor:M,getLineColor:o&&r?T:fe,material:C,transitions:u},this.getSubLayerProps({id:"fill",updateTriggers:b&&{getPolygon:b.getPolygon,getElevation:b.getElevation,getFillColor:b.getFillColor,lineColors:o&&r,getLineColor:b.getLineColor}}),{data:t,positionFormat:l,getPolygon:R}),Oe=!o&&s&&this.shouldRenderSubLayer("stroke",q)&&new rt({_dataDiff:k&&(()=>k),widthUnits:d,widthScale:f,widthMinPixels:p,widthMaxPixels:g,jointRounded:y,miterLimit:_,dashJustified:x,_pathType:"loop",transitions:u&&{getWidth:u.getLineWidth,getColor:u.getLineColor,getPath:u.getPolygon},getColor:this.getSubLayerAccessor(T),getWidth:this.getSubLayerAccessor(w),getDashArray:this.getSubLayerAccessor(S)},this.getSubLayerProps({id:"stroke",updateTriggers:b&&{getWidth:b.getLineWidth,getColor:b.getLineColor,getDashArray:b.getLineDashArray}}),{data:q,positionFormat:l,getPath:ve=>ve.path});return[!o&&W,Oe,o&&W]}}Mt.layerName="PolygonLayer";Mt.defaultProps=gs;class ys{constructor(t){this.index=t,this.isVisible=!1,this.isSelected=!1,this.parent=null,this.children=[],this.content=null,this._loader=void 0,this._abortController=null,this._loaderId=0,this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1}get bbox(){return this._bbox}set bbox(t){this._bbox||(this._bbox=t,"west"in t?this.boundingBox=[[t.west,t.south],[t.east,t.north]]:this.boundingBox=[[t.left,t.top],[t.right,t.bottom]])}get data(){return this.isLoading&&this._loader?this._loader.then(()=>this.data):this.content}get isLoaded(){return this._isLoaded&&!this._needsReload}get isLoading(){return!!this._loader&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){const t=this.content?this.content.byteLength:0;return Number.isFinite(t)||console.error("byteLength not defined in tile data"),t}async _loadData({getData:t,requestScheduler:e,onLoad:s,onError:i}){const{index:o,id:r,bbox:a,userData:c,zoom:h}=this,u=this._loaderId;this._abortController=new AbortController;const{signal:l}=this._abortController,d=await e.scheduleRequest(this,g=>g.isSelected?1:-1);if(!d){this._isCancelled=!0;return}if(this._isCancelled){d.done();return}let f=null,p;try{f=await t({index:o,id:r,bbox:a,userData:c,zoom:h,signal:l})}catch(g){p=g||!0}finally{d.done()}if(u===this._loaderId){if(this._loader=void 0,this.content=f,this._isCancelled&&!f){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?i(p,this):s(this)}}loadData(t){return this._isLoaded=!1,this._isCancelled=!1,this._needsReload=!1,this._loaderId++,this._loader=this._loadData(t),this._loader}setNeedsReload(){this.isLoading&&(this.abort(),this._loader=void 0),this._needsReload=!0}abort(){this.isLoaded||(this._isCancelled=!0,this._abortController?.abort())}}const P={OUTSIDE:-1,INTERSECTING:0,INSIDE:1},Bt=new m.Vector3,_s=new m.Vector3;class Tt{constructor(t=[0,0,0],e=[0,0,0],s){s=s||Bt.copy(t).add(e).scale(.5),this.center=new m.Vector3(s),this.halfDiagonal=new m.Vector3(e).subtract(this.center),this.minimum=new m.Vector3(t),this.maximum=new m.Vector3(e)}clone(){return new Tt(this.minimum,this.maximum,this.center)}equals(t){return this===t||!!t&&this.minimum.equals(t.minimum)&&this.maximum.equals(t.maximum)}transform(t){return this.center.transformAsPoint(t),this.halfDiagonal.transform(t),this.minimum.transform(t),this.maximum.transform(t),this}intersectPlane(t){const{halfDiagonal:e}=this,s=_s.from(t.normal),i=e.x*Math.abs(s.x)+e.y*Math.abs(s.y)+e.z*Math.abs(s.z),o=this.center.dot(s)+t.distance;return o-i>0?P.INSIDE:o+i<0?P.OUTSIDE:P.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=Bt.from(t).subtract(this.center),{halfDiagonal:s}=this;let i=0,o;return o=Math.abs(e.x)-s.x,o>0&&(i+=o*o),o=Math.abs(e.y)-s.y,o>0&&(i+=o*o),o=Math.abs(e.z)-s.z,o>0&&(i+=o*o),i}}const j=new m.Vector3,Dt=new m.Vector3;class wt{constructor(t=[0,0,0],e=0){this.radius=-0,this.center=new m.Vector3,this.fromCenterRadius(t,e)}fromCenterRadius(t,e){return this.center.from(t),this.radius=e,this}fromCornerPoints(t,e){return e=j.from(e),this.center=new m.Vector3().from(t).add(e).scale(.5),this.radius=this.center.distance(e),this}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new wt(this.center,this.radius)}union(t){const e=this.center,s=this.radius,i=t.center,o=t.radius,r=j.copy(i).subtract(e),a=r.magnitude();if(s>=a+o)return this.clone();if(o>=a+s)return t.clone();const c=(s+a+o)*.5;return Dt.copy(r).scale((-s+c)/a).add(e),this.center.copy(Dt),this.radius=c,this}expand(t){const s=j.from(t).subtract(this.center).magnitude();return s>this.radius&&(this.radius=s),this}transform(t){this.center.transform(t);const e=m.getScaling(j,t);return this.radius=Math.max(e[0],Math.max(e[1],e[2]))*this.radius,this}distanceSquaredTo(t){const e=this.distanceTo(t);return e*e}distanceTo(t){const s=j.from(t).subtract(this.center);return Math.max(0,s.len()-this.radius)}intersectPlane(t){const e=this.center,s=this.radius,o=t.normal.dot(e)+t.distance;return o<-s?P.OUTSIDE:o<s?P.INTERSECTING:P.INSIDE}}const xs=new m.Vector3,Ms=new m.Vector3,Z=new m.Vector3,H=new m.Vector3,K=new m.Vector3,Ts=new m.Vector3,ws=new m.Vector3,O={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8};class bt{constructor(t=[0,0,0],e=[0,0,0,0,0,0,0,0,0]){this.center=new m.Vector3().from(t),this.halfAxes=new E(e)}get halfSize(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2);return[new m.Vector3(t).len(),new m.Vector3(e).len(),new m.Vector3(s).len()]}get quaternion(){const t=this.halfAxes.getColumn(0),e=this.halfAxes.getColumn(1),s=this.halfAxes.getColumn(2),i=new m.Vector3(t).normalize(),o=new m.Vector3(e).normalize(),r=new m.Vector3(s).normalize();return new Gt().fromMatrix3(new E([...i,...o,...r]))}fromCenterHalfSizeQuaternion(t,e,s){const i=new Gt(s),o=new E().fromQuaternion(i);return o[0]=o[0]*e[0],o[1]=o[1]*e[0],o[2]=o[2]*e[0],o[3]=o[3]*e[1],o[4]=o[4]*e[1],o[5]=o[5]*e[1],o[6]=o[6]*e[2],o[7]=o[7]*e[2],o[8]=o[8]*e[2],this.center=new m.Vector3().from(t),this.halfAxes=o,this}clone(){return new bt(this.center,this.halfAxes)}equals(t){return this===t||!!t&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new wt){const e=this.halfAxes,s=e.getColumn(0,Z),i=e.getColumn(1,H),o=e.getColumn(2,K),r=xs.copy(s).add(i).add(o);return t.center.copy(this.center),t.radius=r.magnitude(),t}intersectPlane(t){const e=this.center,s=t.normal,i=this.halfAxes,o=s.x,r=s.y,a=s.z,c=Math.abs(o*i[O.COLUMN0ROW0]+r*i[O.COLUMN0ROW1]+a*i[O.COLUMN0ROW2])+Math.abs(o*i[O.COLUMN1ROW0]+r*i[O.COLUMN1ROW1]+a*i[O.COLUMN1ROW2])+Math.abs(o*i[O.COLUMN2ROW0]+r*i[O.COLUMN2ROW1]+a*i[O.COLUMN2ROW2]),h=s.dot(e)+t.distance;return h<=-c?P.OUTSIDE:h>=c?P.INSIDE:P.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){const e=Ms.from(t).subtract(this.center),s=this.halfAxes,i=s.getColumn(0,Z),o=s.getColumn(1,H),r=s.getColumn(2,K),a=i.magnitude(),c=o.magnitude(),h=r.magnitude();i.normalize(),o.normalize(),r.normalize();let u=0,l;return l=Math.abs(e.dot(i))-a,l>0&&(u+=l*l),l=Math.abs(e.dot(o))-c,l>0&&(u+=l*l),l=Math.abs(e.dot(r))-h,l>0&&(u+=l*l),u}computePlaneDistances(t,e,s=[-0,-0]){let i=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY;const r=this.center,a=this.halfAxes,c=a.getColumn(0,Z),h=a.getColumn(1,H),u=a.getColumn(2,K),l=Ts.copy(c).add(h).add(u).add(r),d=ws.copy(l).subtract(t);let f=e.dot(d);return i=Math.min(f,i),o=Math.max(f,o),l.copy(r).add(c).add(h).subtract(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),l.copy(r).add(c).subtract(h).add(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),l.copy(r).add(c).subtract(h).subtract(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),r.copy(l).subtract(c).add(h).add(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),r.copy(l).subtract(c).add(h).subtract(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),r.copy(l).subtract(c).subtract(h).add(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),r.copy(l).subtract(c).subtract(h).subtract(u),d.copy(l).subtract(t),f=e.dot(d),i=Math.min(f,i),o=Math.max(f,o),s[0]=i,s[1]=o,s}transform(t){this.center.transformAsPoint(t);const e=this.halfAxes.getColumn(0,Z);e.transformAsPoint(t);const s=this.halfAxes.getColumn(1,H);s.transformAsPoint(t);const i=this.halfAxes.getColumn(2,K);return i.transformAsPoint(t),this.halfAxes=new E([...e,...s,...i]),this}getTransform(){throw new Error("not implemented")}}const Ut=new m.Vector3,kt=new m.Vector3;class U{constructor(t=[0,0,1],e=0){this.normal=new m.Vector3,this.distance=-0,this.fromNormalDistance(t,e)}fromNormalDistance(t,e){return m.assert(Number.isFinite(e)),this.normal.from(t).normalize(),this.distance=e,this}fromPointNormal(t,e){t=Ut.from(t),this.normal.from(e).normalize();const s=-this.normal.dot(t);return this.distance=s,this}fromCoefficients(t,e,s,i){return this.normal.set(t,e,s),m.assert(m.equals(this.normal.len(),1)),this.distance=i,this}clone(){return new U(this.normal,this.distance)}equals(t){return m.equals(this.distance,t.distance)&&m.equals(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){const e=kt.copy(this.normal).transformAsVector(t).normalize(),s=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(s,e)}projectPointOntoPlane(t,e=[0,0,0]){const s=Ut.from(t),i=this.getPointDistance(s),o=kt.copy(this.normal).scale(i);return s.subtract(o).to(e)}}const Wt=[new m.Vector3([1,0,0]),new m.Vector3([0,1,0]),new m.Vector3([0,0,1])],jt=new m.Vector3,bs=new m.Vector3;class A{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Wt.length;const e=t.center,s=t.radius;let i=0;for(const o of Wt){let r=this.planes[i],a=this.planes[i+1];r||(r=this.planes[i]=new U),a||(a=this.planes[i+1]=new U);const c=jt.copy(o).scale(-s).add(e);r.fromPointNormal(c,o);const h=jt.copy(o).scale(s).add(e),u=bs.copy(o).negate();a.fromPointNormal(h,u),i+=2}return this}computeVisibility(t){let e=P.INSIDE;for(const s of this.planes)switch(t.intersectPlane(s)){case P.OUTSIDE:return P.OUTSIDE;case P.INTERSECTING:e=P.INTERSECTING;break}return e}computeVisibilityWithPlaneMask(t,e){if(m.assert(Number.isFinite(e),"parentPlaneMask is required."),e===A.MASK_OUTSIDE||e===A.MASK_INSIDE)return e;let s=A.MASK_INSIDE;const i=this.planes;for(let o=0;o<this.planes.length;++o){const r=o<31?1<<o:0;if(o<31&&(e&r)===0)continue;const a=i[o],c=t.intersectPlane(a);if(c===P.OUTSIDE)return A.MASK_OUTSIDE;c===P.INTERSECTING&&(s|=r)}return s}}A.MASK_OUTSIDE=4294967295;A.MASK_INSIDE=0;A.MASK_INDETERMINATE=2147483647;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;new m.Vector3;const I=new E,Ss=new E,Cs=new E,Q=new E,Yt=new E;function Ls(n,t={}){const e=ms,s=10;let i=0,o=0;const r=Ss,a=Cs;r.identity(),a.copy(n);const c=e*Es(a);for(;o<s&&Ps(a)>c;)Rs(a,Q),Yt.copy(Q).transpose(),a.multiplyRight(Q),a.multiplyLeft(Yt),r.multiplyRight(Q),++i>2&&(++o,i=0);return t.unitary=r.toTarget(t.unitary),t.diagonal=a.toTarget(t.diagonal),t}function Es(n){let t=0;for(let e=0;e<9;++e){const s=n[e];t+=s*s}return Math.sqrt(t)}const ft=[1,0,0],mt=[2,2,1];function Ps(n){let t=0;for(let e=0;e<3;++e){const s=n[I.getElementIndex(mt[e],ft[e])];t+=2*s*s}return Math.sqrt(t)}function Rs(n,t){const e=fs;let s=0,i=1;for(let h=0;h<3;++h){const u=Math.abs(n[I.getElementIndex(mt[h],ft[h])]);u>s&&(i=h,s=u)}const o=ft[i],r=mt[i];let a=1,c=0;if(Math.abs(n[I.getElementIndex(r,o)])>e){const h=n[I.getElementIndex(r,r)],u=n[I.getElementIndex(o,o)],l=n[I.getElementIndex(r,o)],d=(h-u)/2/l;let f;d<0?f=-1/(-d+Math.sqrt(1+d*d)):f=1/(d+Math.sqrt(1+d*d)),a=1/Math.sqrt(1+f*f),c=f*a}return E.IDENTITY.to(t),t[I.getElementIndex(o,o)]=t[I.getElementIndex(r,r)]=a,t[I.getElementIndex(r,o)]=c,t[I.getElementIndex(o,r)]=-c,t}const z=new m.Vector3,Is=new m.Vector3,As=new m.Vector3,Os=new m.Vector3,vs=new m.Vector3,zs=new E,Ns={diagonal:new E,unitary:new E};function me(n,t=new bt){if(!n||n.length===0)return t.halfAxes=new E([0,0,0,0,0,0,0,0,0]),t.center=new m.Vector3,t;const e=n.length,s=new m.Vector3(0,0,0);for(const b of n)s.add(b);const i=1/e;s.multiplyByScalar(i);let o=0,r=0,a=0,c=0,h=0,u=0;for(const b of n){const C=z.copy(b).subtract(s);o+=C.x*C.x,r+=C.x*C.y,a+=C.x*C.z,c+=C.y*C.y,h+=C.y*C.z,u+=C.z*C.z}o*=i,r*=i,a*=i,c*=i,h*=i,u*=i;const l=zs;l[0]=o,l[1]=r,l[2]=a,l[3]=r,l[4]=c,l[5]=h,l[6]=a,l[7]=h,l[8]=u;const{unitary:d}=Ls(l,Ns),f=t.halfAxes.copy(d);let p=f.getColumn(0,As),g=f.getColumn(1,Os),y=f.getColumn(2,vs),_=-Number.MAX_VALUE,x=-Number.MAX_VALUE,M=-Number.MAX_VALUE,T=Number.MAX_VALUE,w=Number.MAX_VALUE,S=Number.MAX_VALUE;for(const b of n)z.copy(b),_=Math.max(z.dot(p),_),x=Math.max(z.dot(g),x),M=Math.max(z.dot(y),M),T=Math.min(z.dot(p),T),w=Math.min(z.dot(g),w),S=Math.min(z.dot(y),S);p=p.multiplyByScalar(.5*(T+_)),g=g.multiplyByScalar(.5*(w+x)),y=y.multiplyByScalar(.5*(S+M)),t.center.copy(p).add(g).add(y);const L=Is.set(_-T,x-w,M-S).multiplyByScalar(.5),R=new E([L[0],0,0,0,L[1],0,0,0,L[2]]);return t.halfAxes.multiplyRight(R),t}const B=512,Xt=3,pe=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],ge=pe.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),Vs=ge.concat([[.25,.5],[.75,.5]]);class D{constructor(t,e,s){this.x=t,this.y=e,this.z=s}get children(){if(!this._children){const t=this.x*2,e=this.y*2,s=this.z+1;this._children=[new D(t,e,s),new D(t,e+1,s),new D(t+1,e,s),new D(t+1,e+1,s)]}return this._children}update(t){const{viewport:e,cullingVolume:s,elevationBounds:i,minZ:o,maxZ:r,bounds:a,offset:c,project:h}=t,u=this.getBoundingVolume(i,c,h);if(a&&!this.insideBounds(a)||s.computeVisibility(u)<0)return!1;if(!this.childVisible){let{z:d}=this;if(d<r&&d>=o){const f=u.distanceTo(e.cameraPosition)*e.scale/e.height;d+=Math.floor(Math.log2(f))}if(d>=r)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(const d of this.children)d.update(t);return!0}getSelected(t=[]){if(this.selected&&t.push(this),this._children)for(const e of this._children)e.getSelected(t);return t}insideBounds([t,e,s,i]){const o=Math.pow(2,this.z),r=B/o;return this.x*r<s&&this.y*r<i&&(this.x+1)*r>t&&(this.y+1)*r>e}getBoundingVolume(t,e,s){if(s){const c=this.z<1?Vs:this.z<2?ge:pe,h=[];for(const u of c){const l=gt(this.x+u[0],this.y+u[1],this.z);l[2]=t[0],h.push(s(l)),t[0]!==t[1]&&(l[2]=t[1],h.push(s(l)))}return me(h)}const i=Math.pow(2,this.z),o=B/i,r=this.x*o+e*B,a=B-(this.y+1)*o;return new Tt([r,a,t[0]],[r+o,a+o,t[1]])}}function Fs(n,t,e,s){const i=n instanceof m.GlobeViewport&&n.resolution?n.projectPosition:null,o=Object.values(n.getFrustumPlanes()).map(({normal:f,distance:p})=>new U(f.clone().negate(),p)),r=new A(o),a=n.distanceScales.unitsPerMeter[2],c=e&&e[0]*a||0,h=e&&e[1]*a||0,u=n instanceof m.WebMercatorViewport&&n.pitch<=60?t:0;if(s){const[f,p,g,y]=s,_=m.lngLatToWorld([f,y]),x=m.lngLatToWorld([g,p]);s=[_[0],B-_[1],x[0],B-x[1]]}const l=new D(0,0,0),d={viewport:n,project:i,cullingVolume:r,elevationBounds:[c,h],minZ:u,maxZ:t,bounds:s,offset:0};if(l.update(d),n instanceof m.WebMercatorViewport&&n.subViewports&&n.subViewports.length>1){for(d.offset=-1;l.update(d)&&!(--d.offset<-Xt););for(d.offset=1;l.update(d)&&!(++d.offset>Xt););}return l.getSelected()}const v=512,qs=[-1/0,-1/0,1/0,1/0],Gs={equal:(n,t)=>{if(n===t)return!0;if(!Array.isArray(n)||!Array.isArray(t))return!1;const e=n.length;if(e!==t.length)return!1;for(let s=0;s<e;s++)if(n[s]!==t[s])return!1;return!0}};function St(n,t){const e=[t.transformAsPoint([n[0],n[1]]),t.transformAsPoint([n[2],n[1]]),t.transformAsPoint([n[0],n[3]]),t.transformAsPoint([n[2],n[3]])];return[Math.min(...e.map(i=>i[0])),Math.min(...e.map(i=>i[1])),Math.max(...e.map(i=>i[0])),Math.max(...e.map(i=>i[1]))]}function Bs(n){return Math.abs(n.split("").reduce((t,e)=>(t<<5)-t+e.charCodeAt(0)|0,0))}function Ds(n,t){if(!n||!n.length)return null;const{index:e,id:s}=t;if(Array.isArray(n)){const o=Bs(s)%n.length;n=n[o]}let i=n;for(const o of Object.keys(e)){const r=new RegExp(`{${o}}`,"g");i=i.replace(r,String(e[o]))}return Number.isInteger(e.y)&&Number.isInteger(e.z)&&(i=i.replace(/\{-y\}/g,String(Math.pow(2,e.z)-e.y-1))),i}function Us(n,t,e){let s;return s=n.getBounds(),n.isGeospatial?[Math.max(s[0],e[0]),Math.max(s[1],e[1]),Math.min(s[2],e[2]),Math.min(s[3],e[3])]:[Math.max(Math.min(s[0],e[2]),e[0]),Math.max(Math.min(s[1],e[3]),e[1]),Math.min(Math.max(s[2],e[0]),e[2]),Math.min(Math.max(s[3],e[1]),e[3])]}function ks({viewport:n,z:t,cullRect:e}){return(n.subViewports||[n]).map(i=>pt(i,t||0,e))}function pt(n,t,e){if(!Array.isArray(t)){const o=e.x-n.x,r=e.y-n.y,{width:a,height:c}=e,h={targetZ:t},u=n.unproject([o,r],h),l=n.unproject([o+a,r],h),d=n.unproject([o,r+c],h),f=n.unproject([o+a,r+c],h);return[Math.min(u[0],l[0],d[0],f[0]),Math.min(u[1],l[1],d[1],f[1]),Math.max(u[0],l[0],d[0],f[0]),Math.max(u[1],l[1],d[1],f[1])]}const s=pt(n,t[0],e),i=pt(n,t[1],e);return[Math.min(s[0],i[0]),Math.min(s[1],i[1]),Math.max(s[2],i[2]),Math.max(s[3],i[3])]}function Ws(n,t,e){return e?St(n,e).map(i=>i*t/v):n.map(s=>s*t/v)}function Ct(n,t){return Math.pow(2,n)*v/t}function gt(n,t,e){const s=Ct(e,v),i=n/s*360-180,o=Math.PI-2*Math.PI*t/s,r=180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)));return[i,r]}function $t(n,t,e,s){const i=Ct(e,s);return[n/i*v,t/i*v]}function js(n,t,e,s,i=v){if(n.isGeospatial){const[h,u]=gt(t,e,s),[l,d]=gt(t+1,e+1,s);return{west:h,north:u,east:l,south:d}}const[o,r]=$t(t,e,s,i),[a,c]=$t(t+1,e+1,s,i);return{left:o,top:r,right:a,bottom:c}}function Ys(n,t,e,s,i){const o=Us(n,null,s),r=Ct(t,e),[a,c,h,u]=Ws(o,r,i),l=[];for(let d=Math.floor(a);d<h;d++)for(let f=Math.floor(c);f<u;f++)l.push({x:d,y:f,z:t});return l}function Xs({viewport:n,maxZoom:t,minZoom:e,zRange:s,extent:i,tileSize:o=v,modelMatrix:r,modelMatrixInverse:a,zoomOffset:c=0}){let h=n.isGeospatial?Math.round(n.zoom+Math.log2(v/o))+c:Math.ceil(n.zoom)+c;if(typeof e=="number"&&Number.isFinite(e)&&h<e){if(!i)return[];h=e}typeof t=="number"&&Number.isFinite(t)&&h>t&&(h=t);let u=i;return r&&a&&i&&!n.isGeospatial&&(u=St(i,r)),n.isGeospatial?Fs(n,h,s,i):Ys(n,h,o,u||qs,a)}function $s(n){let t={},e;return s=>{for(const i in s)if(!Zs(s[i],t[i])){e=n(s),t=s;break}return e}}function Zs(n,t){if(n===t)return!0;if(Array.isArray(n)){const e=n.length;if(!t||t.length!==e)return!1;for(let s=0;s<e;s++)if(n[s]!==t[s])return!1;return!0}return!1}const Zt=1,nt=2,Hs="never",Ks="no-overlap",Lt="best-available",Qs=5,Js={[Lt]:en,[Ks]:sn,[Hs]:()=>{}},tn={extent:null,tileSize:512,maxZoom:null,minZoom:null,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:"best-available",zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{}};class Et{constructor(t){this._getCullBounds=$s(ks),this.opts={...tn,...t},this.setOptions(this.opts),this.onTileLoad=e=>{this.opts.onTileLoad?.(e),this.opts.maxCacheByteSize!==null&&(this._cacheByteSize+=e.byteLength,this._resizeCache())},this._requestScheduler=new Be({throttleRequests:this.opts.maxRequests>0||this.opts.debounceTime>0,maxRequests:this.opts.maxRequests,debounceTime:this.opts.debounceTime}),this._cache=new Map,this._tiles=[],this._dirty=!1,this._cacheByteSize=0,this._viewport=null,this._zRange=null,this._selectedTiles=null,this._frameNumber=0,this._modelMatrix=new m.Matrix4,this._modelMatrixInverse=new m.Matrix4}get tiles(){return this._tiles}get selectedTiles(){return this._selectedTiles}get isLoaded(){return this._selectedTiles!==null&&this._selectedTiles.every(t=>t.isLoaded)}get needsReload(){return this._selectedTiles!==null&&this._selectedTiles.some(t=>t.needsReload)}setOptions(t){Object.assign(this.opts,t),Number.isFinite(t.maxZoom)&&(this._maxZoom=Math.floor(t.maxZoom)),Number.isFinite(t.minZoom)&&(this._minZoom=Math.ceil(t.minZoom))}finalize(){for(const t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(const t of this._cache.keys()){const e=this._cache.get(t);!this._selectedTiles||!this._selectedTiles.includes(e)?this._cache.delete(t):e.setNeedsReload()}}update(t,{zRange:e,modelMatrix:s}={zRange:null,modelMatrix:null}){const i=s?new m.Matrix4(s):new m.Matrix4,o=!i.equals(this._modelMatrix);if(!this._viewport||!t.equals(this._viewport)||!m.equals(this._zRange,e)||o){o&&(this._modelMatrixInverse=i.clone().invert(),this._modelMatrix=i),this._viewport=t,this._zRange=e;const a=this.getTileIndices({viewport:t,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:e,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=a.map(c=>this._getTile(c,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(a=>this._getTile(a.index,!0)));const r=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),r&&this._frameNumber++,this._frameNumber}isTileVisible(t,e,s){if(!t.isVisible)return!1;if(e&&this._viewport){const i=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:e});let{bbox:o}=t;for(const[r,a,c,h]of i){let u;if("west"in o)u=o.west<c&&o.east>r&&o.south<h&&o.north>a;else{if(s&&!m.Matrix4.IDENTITY.equals(s)){const[f,p,g,y]=St([o.left,o.top,o.right,o.bottom],s);o={left:f,top:p,right:g,bottom:y}}const l=Math.min(o.top,o.bottom),d=Math.max(o.top,o.bottom);u=o.left<c&&o.right>r&&l<h&&d>a}if(u)return!0}return!1}return!0}getTileIndices({viewport:t,maxZoom:e,minZoom:s,zRange:i,modelMatrix:o,modelMatrixInverse:r}){const{tileSize:a,extent:c,zoomOffset:h}=this.opts;return Xs({viewport:t,maxZoom:e,minZoom:s,zRange:i,tileSize:a,extent:c,modelMatrix:o,modelMatrixInverse:r,zoomOffset:h})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){const{tileSize:e}=this.opts;return{bbox:js(this._viewport,t.x,t.y,t.z,e)}}getParentIndex(t){const e=Math.floor(t.x/2),s=Math.floor(t.y/2),i=t.z-1;return{x:e,y:s,z:i}}updateTileStates(){const t=this.opts.refinementStrategy||Lt,e=new Array(this._cache.size);let s=0;for(const i of this._cache.values())e[s++]=i.isVisible,i.isSelected=!1,i.isVisible=!1;for(const i of this._selectedTiles)i.isSelected=!0,i.isVisible=!0;(typeof t=="function"?t:Js[t])(Array.from(this._cache.values())),s=0;for(const i of this._cache.values())if(e[s++]!==i.isVisible)return!0;return!1}_pruneRequests(){const{maxRequests:t=0}=this.opts,e=[];let s=0;for(const i of this._cache.values())i.isLoading&&(s++,!i.isSelected&&!i.isVisible&&e.push(i));for(;t>0&&s>t&&e.length>0;)e.shift().abort(),s--}_rebuildTree(){const{_cache:t}=this;for(const e of t.values())e.parent=null,e.children&&(e.children.length=0);for(const e of t.values()){const s=this._getNearestAncestor(e);e.parent=s,s?.children&&s.children.push(e)}}_resizeCache(){const{_cache:t,opts:e}=this,s=e.maxCacheSize??(e.maxCacheByteSize!==null?1/0:Qs*this.selectedTiles.length),i=e.maxCacheByteSize??1/0;if(t.size>s||this._cacheByteSize>i){for(const[r,a]of t)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=e.maxCacheByteSize!==null?a.byteLength:0,t.delete(r),this.opts.onTileUnload?.(a)),t.size<=s&&this._cacheByteSize<=i)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((r,a)=>r.zoom-a.zoom),this._dirty=!1)}_getTile(t,e){const s=this.getTileId(t);let i=this._cache.get(s),o=!1;return!i&&e?(i=new ys(t),Object.assign(i,this.getTileMetadata(i.index)),Object.assign(i,{id:s,zoom:this.getTileZoom(i.index)}),o=!0,this._cache.set(s,i),this._dirty=!0):i&&i.needsReload&&(o=!0),i&&o&&i.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),i}_getNearestAncestor(t){const{_minZoom:e=0}=this;let s=t.index;for(;this.getTileZoom(s)>e;){s=this.getParentIndex(s);const i=this._getTile(s);if(i)return i}return null}}function en(n){for(const t of n)t.state=0;for(const t of n)t.isSelected&&!ye(t)&&Pt(t);for(const t of n)t.isVisible=!!(t.state&nt)}function sn(n){for(const e of n)e.state=0;for(const e of n)e.isSelected&&ye(e);const t=Array.from(n).sort((e,s)=>e.zoom-s.zoom);for(const e of t)if(e.isVisible=!!(e.state&nt),e.children&&(e.isVisible||e.state&Zt))for(const s of e.children)s.state=Zt;else e.isSelected&&Pt(e)}function ye(n){let t=n;for(;t;){if(t.isLoaded||t.content)return t.state|=nt,!0;t=t.parent}return!1}function Pt(n){for(const t of n.children)t.isLoaded||t.content?t.state|=nt:Pt(t)}const nn={TilesetClass:Et,data:{type:"data",value:[]},dataComparator:Gs.equal,renderSubLayers:{type:"function",value:n=>new m.GeoJsonLayer(n)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:n=>{}},onTileUnload:{type:"function",value:n=>{}},onTileError:{type:"function",value:n=>console.error(n)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:Lt,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0};class it extends m.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return!!this.state?.tileset?.selectedTiles?.every(t=>t.isLoaded&&t.layers&&t.layers.every(e=>e.isLoaded))}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({changeFlags:t}){let{tileset:e}=this.state;const s=t.propsOrDataChanged||t.updateTriggersChanged,i=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getTileData);e?s&&(e.setOptions(this._getTilesetOptions()),i?e.reloadAll():e.tiles.forEach(o=>{o.layers=null})):(e=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:e})),this._updateTileset()}_getTilesetOptions(){const{tileSize:t,maxCacheSize:e,maxCacheByteSize:s,refinementStrategy:i,extent:o,maxZoom:r,minZoom:a,maxRequests:c,debounceTime:h,zoomOffset:u}=this.props;return{maxCacheSize:e,maxCacheByteSize:s,maxZoom:r,minZoom:a,tileSize:t,refinementStrategy:i,extent:o,maxRequests:c,debounceTime:h,zoomOffset:u,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){const t=this.state.tileset,{zRange:e,modelMatrix:s}=this.props,i=t.update(this.context.viewport,{zRange:e,modelMatrix:s}),{isLoaded:o}=t,r=this.state.isLoaded!==o,a=this.state.frameNumber!==i;o&&(r||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:i}),this.state.isLoaded=o}_onViewportLoad(){const{tileset:t}=this.state,{onViewportLoad:e}=this.props;e&&e(t.selectedTiles)}_onTileLoad(t){this.props.onTileLoad(t),t.layers=null,this.setNeedsUpdate()}_onTileError(t,e){this.props.onTileError(t),e.layers=null,this.setNeedsUpdate()}_onTileUnload(t){this.props.onTileUnload(t)}getTileData(t){const{data:e,getTileData:s,fetch:i}=this.props,{signal:o}=t;return t.url=typeof e=="string"||Array.isArray(e)?Ds(e,t):null,s?s(t):i&&t.url?i(t.url,{propName:"data",layer:this,signal:o}):null}renderSubLayers(t){return this.props.renderSubLayers(t)}getSubLayerPropsByTile(t){return null}getPickingInfo(t){const e=t.sourceLayer,s=e.props.tile,i=t.info;return i.picked&&(i.tile=s),i.sourceTile=s,i.sourceTileSubLayer=e,i}_updateAutoHighlight(t){t.sourceTileSubLayer.updateAutoHighlight(t)}renderLayers(){return this.state.tileset.tiles.map(t=>{const e=this.getSubLayerPropsByTile(t);if(!(!t.isLoaded&&!t.content))if(t.layers)e&&t.layers[0]&&Object.keys(e).some(s=>t.layers[0].props[s]!==e[s])&&(t.layers=t.layers.map(s=>s.clone(e)));else{const s=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:t.id,updateTriggers:this.props.updateTriggers}),data:t.content,_offset:0,tile:t});t.layers=m.flatten(s,Boolean).map(i=>i.clone({tile:t,...e}))}return t.layers})}filterSubLayer({layer:t,cullRect:e}){const{tile:s}=t.props,{modelMatrix:i}=this.props;return this.state.tileset.isTileVisible(s,e,i?new m.Matrix4(i):null)}}it.defaultProps=nn;it.layerName="TileLayer";const at=Math.PI/180,J=new Float32Array(16),Ht=new Float32Array(12);function Kt(n,t,e){const s=t[0]*at,i=t[1]*at,o=t[2]*at,r=Math.sin(o),a=Math.sin(s),c=Math.sin(i),h=Math.cos(o),u=Math.cos(s),l=Math.cos(i),d=e[0],f=e[1],p=e[2];n[0]=d*l*u,n[1]=d*c*u,n[2]=d*-a,n[3]=f*(-c*h+l*a*r),n[4]=f*(l*h+c*a*r),n[5]=f*u*r,n[6]=p*(c*r+l*a*h),n[7]=p*(-l*r+c*a*h),n[8]=p*u*h}function Qt(n){return n[0]=n[0],n[1]=n[1],n[2]=n[2],n[3]=n[4],n[4]=n[5],n[5]=n[6],n[6]=n[8],n[7]=n[9],n[8]=n[10],n[9]=n[12],n[10]=n[13],n[11]=n[14],n.subarray(0,12)}const on={size:12,accessor:["getOrientation","getScale","getTranslation","getTransformMatrix"],shaderAttributes:{instanceModelMatrixCol0:{size:3,elementOffset:0},instanceModelMatrixCol1:{size:3,elementOffset:3},instanceModelMatrixCol2:{size:3,elementOffset:6},instanceTranslation:{size:3,elementOffset:9}},update(n,{startRow:t,endRow:e}){const{data:s,getOrientation:i,getScale:o,getTranslation:r,getTransformMatrix:a}=this.props,c=Array.isArray(a),h=c&&a.length===16,u=Array.isArray(o),l=Array.isArray(i),d=Array.isArray(r),f=h||!c&&!!a(s[0]);f?n.constant=h:n.constant=l&&u&&d;const p=n.value;if(n.constant){let g;f?(J.set(a),g=Qt(J)):(g=Ht,Kt(g,i,o),g.set(r,9)),n.value=new Float32Array(g)}else{let g=t*n.size;const{iterable:y,objectInfo:_}=m.createIterable(s,t,e);for(const x of y){_.index++;let M;if(f)J.set(h?a:a(x,_)),M=Qt(J);else{M=Ht;const T=l?i:i(x,_),w=u?o:o(x,_);Kt(M,T,w),M.set(d?r:r(x,_),9)}p[g++]=M[0],p[g++]=M[1],p[g++]=M[2],p[g++]=M[3],p[g++]=M[4],p[g++]=M[5],p[g++]=M[6],p[g++]=M[7],p[g++]=M[8],p[g++]=M[9],p[g++]=M[10],p[g++]=M[11]}}}};function rn(n,t){return t===m.COORDINATE_SYSTEM.CARTESIAN||t===m.COORDINATE_SYSTEM.METER_OFFSETS||t===m.COORDINATE_SYSTEM.DEFAULT&&!n.isGeospatial}const Jt=`uniform simpleMeshUniforms {
2
+ float sizeScale;
3
+ bool composeModelMatrix;
4
+ bool hasTexture;
5
+ bool flatShading;
6
+ } simpleMesh;
7
+ `,an={name:"simpleMesh",vs:Jt,fs:Jt,uniformTypes:{sizeScale:"f32",composeModelMatrix:"f32",hasTexture:"f32",flatShading:"f32"}},cn=`#version 300 es
8
+ #define SHADER_NAME simple-mesh-layer-vs
9
+ in vec3 positions;
10
+ in vec3 normals;
11
+ in vec3 colors;
12
+ in vec2 texCoords;
13
+ in vec3 instancePositions;
14
+ in vec3 instancePositions64Low;
15
+ in vec4 instanceColors;
16
+ in vec3 instancePickingColors;
17
+ in vec3 instanceModelMatrixCol0;
18
+ in vec3 instanceModelMatrixCol1;
19
+ in vec3 instanceModelMatrixCol2;
20
+ in vec3 instanceTranslation;
21
+ out vec2 vTexCoord;
22
+ out vec3 cameraPosition;
23
+ out vec3 normals_commonspace;
24
+ out vec4 position_commonspace;
25
+ out vec4 vColor;
26
+ void main(void) {
27
+ geometry.worldPosition = instancePositions;
28
+ geometry.uv = texCoords;
29
+ geometry.pickingColor = instancePickingColors;
30
+ vTexCoord = texCoords;
31
+ cameraPosition = project.cameraPosition;
32
+ vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
33
+ mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
34
+ vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale + instanceTranslation;
35
+ if (simpleMesh.composeModelMatrix) {
36
+ DECKGL_FILTER_SIZE(pos, geometry);
37
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
38
+ geometry.worldPosition += pos;
39
+ gl_Position = project_position_to_clipspace(pos + instancePositions, instancePositions64Low, vec3(0.0), position_commonspace);
40
+ geometry.position = position_commonspace;
41
+ }
42
+ else {
43
+ pos = project_size(pos);
44
+ DECKGL_FILTER_SIZE(pos, geometry);
45
+ gl_Position = project_position_to_clipspace(instancePositions, instancePositions64Low, pos, position_commonspace);
46
+ geometry.position = position_commonspace;
47
+ normals_commonspace = project_normal(instanceModelMatrix * normals);
48
+ }
49
+ geometry.normal = normals_commonspace;
50
+ DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
51
+ DECKGL_FILTER_COLOR(vColor, geometry);
52
+ }
53
+ `,ln=`#version 300 es
54
+ #define SHADER_NAME simple-mesh-layer-fs
55
+ precision highp float;
56
+ uniform sampler2D sampler;
57
+ in vec2 vTexCoord;
58
+ in vec3 cameraPosition;
59
+ in vec3 normals_commonspace;
60
+ in vec4 position_commonspace;
61
+ in vec4 vColor;
62
+ out vec4 fragColor;
63
+ void main(void) {
64
+ geometry.uv = vTexCoord;
65
+ vec3 normal;
66
+ if (simpleMesh.flatShading) {
67
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
68
+ } else {
69
+ normal = normals_commonspace;
70
+ }
71
+ vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
72
+ DECKGL_FILTER_COLOR(color, geometry);
73
+ vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
74
+ fragColor = vec4(lightColor, color.a * layer.opacity);
75
+ }
76
+ `;function ct(n){const t=n.positions||n.POSITION;m.defaultLogger.assert(t,'no "postions" or "POSITION" attribute in mesh');const e=t.value.length/t.size;let s=n.COLOR_0||n.colors;s||(s={size:3,value:new Float32Array(e*3).fill(1)});let i=n.NORMAL||n.normals;i||(i={size:3,value:new Float32Array(e*3).fill(0)});let o=n.TEXCOORD_0||n.texCoords;return o||(o={size:2,value:new Float32Array(e*2).fill(0)}),{positions:t,colors:s,normals:i,texCoords:o}}function te(n){return n instanceof m.Geometry?(n.attributes=ct(n.attributes),n):n.attributes?new m.Geometry({...n,topology:"triangle-list",attributes:ct(n.attributes)}):new m.Geometry({topology:"triangle-list",attributes:ct(n)})}const hn=[0,0,0,255],un={mesh:{type:"object",value:null,async:!0},texture:{type:"image",value:null,async:!0},sizeScale:{type:"number",value:1,min:0},_instanced:!0,wireframe:!1,material:!0,getPosition:{type:"accessor",value:n=>n.position},getColor:{type:"accessor",value:hn},getOrientation:{type:"accessor",value:[0,0,0]},getScale:{type:"accessor",value:[1,1,1]},getTranslation:{type:"accessor",value:[0,0,0]},getTransformMatrix:{type:"accessor",value:[]},textureParameters:{type:"object",ignore:!0,value:null}};class st extends m.Layer{getShaders(){return super.getShaders({vs:cn,fs:ln,modules:[m.project32,de,m.picking,an]})}getBounds(){if(this.props._instanced)return super.getBounds();let t=this.state.positionBounds;if(t)return t;const{mesh:e}=this.props;if(!e)return null;if(t=e.header?.boundingBox,!t){const{attributes:s}=te(e);s.POSITION=s.POSITION||s.positions,t=De(s)}return this.state.positionBounds=t,t}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{transition:!0,type:"float64",fp64:this.use64bitPositions(),size:3,accessor:"getPosition"},instanceColors:{type:"unorm8",transition:!0,size:this.props.colorFormat.length,accessor:"getColor",defaultValue:[0,0,0,255]},instanceModelMatrix:on}),this.setState({emptyTexture:this.context.device.createTexture({data:new Uint8Array(4),width:1,height:1})})}updateState(t){super.updateState(t);const{props:e,oldProps:s,changeFlags:i}=t;if(e.mesh!==s.mesh||i.extensionsChanged){if(this.state.positionBounds=null,this.state.model?.destroy(),e.mesh){this.state.model=this.getModel(e.mesh);const o=e.mesh.attributes||e.mesh;this.setState({hasNormals:!!(o.NORMAL||o.normals)})}this.getAttributeManager().invalidateAll()}e.texture!==s.texture&&e.texture instanceof m.Texture&&this.setTexture(e.texture),this.state.model&&this.state.model.setTopology(this.props.wireframe?"line-strip":"triangle-list")}finalizeState(t){super.finalizeState(t),this.state.emptyTexture.delete()}draw({uniforms:t}){const{model:e}=this.state;if(!e)return;const{viewport:s,renderPass:i}=this.context,{sizeScale:o,coordinateSystem:r,_instanced:a}=this.props,c={sizeScale:o,composeModelMatrix:!a||rn(s,r),flatShading:!this.state.hasNormals};e.shaderInputs.setProps({simpleMesh:c}),e.draw(i)}get isLoaded(){return!!(this.state?.model&&super.isLoaded)}getModel(t){const e=new m.Model(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:te(t),isInstanced:!0}),{texture:s}=this.props,{emptyTexture:i}=this.state,o={sampler:s||i,hasTexture:!!s};return e.shaderInputs.setProps({simpleMesh:o}),e}setTexture(t){const{emptyTexture:e,model:s}=this.state;if(s){const i={sampler:t||e,hasTexture:!!t};s.shaderInputs.setProps({simpleMesh:i})}}}st.defaultProps=un;st.layerName="SimpleMeshLayer";const dn=[[1/3,1/3,1/3],[.5,.5,0],[.5,0,.5],[0,.5,.5]],fn=.125;class mn{reprojectors;width;height;uvs;exactOutputPositions;triangles;_halfedges;_candidatesUV;_queueIndices;_queue;_errors;_pending;_pendingLen;constructor(t,e,s=e){this.reprojectors=t,this.width=e,this.height=s,this.uvs=[],this.exactOutputPositions=[],this.triangles=[],this._halfedges=[],this._candidatesUV=[],this._queueIndices=[],this._queue=[],this._errors=[],this._pending=[],this._pendingLen=0;const i=1,o=1,r=this._addPoint(0,0),a=this._addPoint(i,0),c=this._addPoint(0,o),h=this._addPoint(i,o),u=this._addTriangle(h,r,c,-1,-1,-1);this._addTriangle(r,h,a,u,-1,-1),this._flush()}run(t=fn){if(t<=0)throw new Error("maxError must be positive");for(;this.getMaxError()>t;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}_flush(){for(let t=0;t<this._pendingLen;t++){const e=this._pending[t];this._findReprojectionCandidate(e)}this._pendingLen=0}_findReprojectionCandidate(t){const e=2*this.triangles[t*3+0],s=2*this.triangles[t*3+1],i=2*this.triangles[t*3+2],o=this.uvs[e],r=this.uvs[e+1],a=this.uvs[s],c=this.uvs[s+1],h=this.uvs[i],u=this.uvs[i+1],l=this.exactOutputPositions[e],d=this.exactOutputPositions[e+1],f=this.exactOutputPositions[s],p=this.exactOutputPositions[s+1],g=this.exactOutputPositions[i],y=this.exactOutputPositions[i+1];let _=0,x=0,M=0;for(const T of dn){const w=tt(o,a,h,T[0],T[1],T[2]),S=tt(r,c,u,T[0],T[1],T[2]),L=tt(l,f,g,T[0],T[1],T[2]),R=tt(d,p,y,T[0],T[1],T[2]),b=w*(this.width-1),C=S*(this.height-1),q=this.reprojectors.inverseReproject(L,R),k=this.reprojectors.inverseTransform(q[0],q[1]),ot=b-k[0],rt=C-k[1],W=Math.hypot(ot,rt);W>_&&(_=W,x=w,M=S)}(x===o&&M===r||x===a&&M===c||x===h&&M===u)&&(_=0),this._candidatesUV[2*t]=x,this._candidatesUV[2*t+1]=M,this._queuePush(t,_)}_step(){const t=this._queuePop(),e=t*3+0,s=t*3+1,i=t*3+2,o=this.triangles[e],r=this.triangles[s],a=this.triangles[i],c=this.uvs[2*o],h=this.uvs[2*o+1],u=this.uvs[2*r],l=this.uvs[2*r+1],d=this.uvs[2*a],f=this.uvs[2*a+1],p=this._candidatesUV[2*t],g=this._candidatesUV[2*t+1],y=this._addPoint(p,g);if(lt(c,h,u,l,p,g)===0)this._handleCollinear(y,e);else if(lt(u,l,d,f,p,g)===0)this._handleCollinear(y,s);else if(lt(d,f,c,h,p,g)===0)this._handleCollinear(y,i);else{const _=this._halfedges[e],x=this._halfedges[s],M=this._halfedges[i],T=this._addTriangle(o,r,y,_,-1,-1,e),w=this._addTriangle(r,a,y,x,-1,T+1),S=this._addTriangle(a,o,y,M,T+2,w+1);this._legalize(T),this._legalize(w),this._legalize(S)}}_addPoint(t,e){const s=this.uvs.length>>1;this.uvs.push(t,e);const i=t*(this.width-1),o=e*(this.height-1),r=this.reprojectors.forwardTransform(i,o),a=this.reprojectors.forwardReproject(r[0],r[1]);return this.exactOutputPositions.push(a[0],a[1]),s}_addTriangle(t,e,s,i,o,r,a=this.triangles.length){const c=a/3;return this.triangles[a+0]=t,this.triangles[a+1]=e,this.triangles[a+2]=s,this._halfedges[a+0]=i,this._halfedges[a+1]=o,this._halfedges[a+2]=r,i>=0&&(this._halfedges[i]=a+0),o>=0&&(this._halfedges[o]=a+1),r>=0&&(this._halfedges[r]=a+2),this._candidatesUV[2*c+0]=0,this._candidatesUV[2*c+1]=0,this._queueIndices[c]=-1,this._pending[this._pendingLen++]=c,a}_legalize(t){const e=this._halfedges[t];if(e<0)return;const s=t-t%3,i=e-e%3,o=s+(t+1)%3,r=s+(t+2)%3,a=i+(e+2)%3,c=i+(e+1)%3,h=this.triangles[r],u=this.triangles[t],l=this.triangles[o],d=this.triangles[a],f=this.uvs;if(!pn(f[2*h],f[2*h+1],f[2*u],f[2*u+1],f[2*l],f[2*l+1],f[2*d],f[2*d+1]))return;const p=this._halfedges[o],g=this._halfedges[r],y=this._halfedges[a],_=this._halfedges[c];this._queueRemove(s/3),this._queueRemove(i/3);const x=this._addTriangle(h,d,l,-1,y,p,s),M=this._addTriangle(d,h,u,x,g,_,i);this._legalize(x+1),this._legalize(M+2)}_handleCollinear(t,e){const s=e-e%3,i=s+(e+1)%3,o=s+(e+2)%3,r=this.triangles[o],a=this.triangles[e],c=this.triangles[i],h=this._halfedges[i],u=this._halfedges[o],l=this._halfedges[e];if(l<0){const S=this._addTriangle(t,r,a,-1,u,-1,s),L=this._addTriangle(r,t,c,S,-1,h);this._legalize(S+1),this._legalize(L+2);return}const d=l-l%3,f=d+(l+2)%3,p=d+(l+1)%3,g=this.triangles[f],y=this._halfedges[f],_=this._halfedges[p];this._queueRemove(d/3);const x=this._addTriangle(r,a,t,u,-1,-1,s),M=this._addTriangle(a,g,t,_,-1,x+1,d),T=this._addTriangle(g,c,t,y,-1,M+1),w=this._addTriangle(c,r,t,h,x+2,T+1);this._legalize(x),this._legalize(M),this._legalize(T),this._legalize(w)}_queuePush(t,e){const s=this._queue.length;this._queueIndices[t]=s,this._queue.push(t),this._errors.push(e),this._queueUp(s)}_queuePop(){const t=this._queue.length-1;return this._queueSwap(0,t),this._queueDown(0,t),this._queuePopBack()}_queuePopBack(){const t=this._queue.pop();return this._errors.pop(),this._queueIndices[t]=-1,t}_queueRemove(t){const e=this._queueIndices[t];if(e<0){const i=this._pending.indexOf(t);if(i!==-1)this._pending[i]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}const s=this._queue.length-1;s!==e&&(this._queueSwap(e,s),this._queueDown(e,s)||this._queueUp(e)),this._queuePopBack()}_queueLess(t,e){return this._errors[t]>this._errors[e]}_queueSwap(t,e){const s=this._queue[t],i=this._queue[e];this._queue[t]=i,this._queue[e]=s,this._queueIndices[s]=e,this._queueIndices[i]=t;const o=this._errors[t];this._errors[t]=this._errors[e],this._errors[e]=o}_queueUp(t){let e=t;for(;;){const s=e-1>>1;if(s===e||!this._queueLess(e,s))break;this._queueSwap(s,e),e=s}}_queueDown(t,e){let s=t;for(;;){const i=2*s+1;if(i>=e||i<0)break;const o=i+1;let r=i;if(o<e&&this._queueLess(o,i)&&(r=o),!this._queueLess(r,s))break;this._queueSwap(s,r),s=r}return s>t}}function lt(n,t,e,s,i,o){return(e-i)*(t-o)-(s-o)*(n-i)}function pn(n,t,e,s,i,o,r,a){const c=n-r,h=t-a,u=e-r,l=s-a,d=i-r,f=o-a,p=c*c+h*h,g=u*u+l*l,y=d*d+f*f;return c*(l*y-g*f)-h*(u*y-g*d)+p*(u*f-l*d)<0}function tt(n,t,e,s,i,o){return s*n+i*t+o*e}const gn=`#version 300 es
77
+ #define SHADER_NAME simple-mesh-layer-fs
78
+
79
+ precision highp float;
80
+
81
+ in vec2 vTexCoord;
82
+ in vec3 cameraPosition;
83
+ in vec3 normals_commonspace;
84
+ in vec4 position_commonspace;
85
+ in vec4 vColor;
86
+
87
+ out vec4 fragColor;
88
+
89
+ void main(void) {
90
+ geometry.uv = vTexCoord;
91
+
92
+ vec3 normal;
93
+ if (simpleMesh.flatShading) {
94
+
95
+ normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
96
+ } else {
97
+ normal = normals_commonspace;
98
+ }
99
+
100
+ // We initialize color here before passing into DECKGL_FILTER_COLOR
101
+ vec4 color;
102
+ DECKGL_FILTER_COLOR(color, geometry);
103
+
104
+ vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
105
+ fragColor = vec4(lightColor, color.a * layer.opacity);
106
+ }
107
+ `;class yn extends st{static layerName="mesh-texture-layer";static defaultProps=st.defaultProps;getShaders(){const t=super.getShaders(),e=t.modules;for(const s of this.props.renderPipeline)e.push(s.module);return{...t,fs:gn,modules:e}}draw(t){const e={};for(const s of this.props.renderPipeline)e[s.module.name]=s.props||{};for(const s of super.getModels())s.shaderInputs.setProps(e);super.draw(t)}}const _n=.125,ee=[[252,73,163],[255,51,204],[204,102,255],[153,51,255],[102,204,255],[51,153,255],[102,255,204],[51,255,170],[0,255,0],[51,204,51],[255,204,102],[255,179,71],[255,102,102],[255,80,80],[255,0,0],[204,0,0],[255,128,0],[255,153,51],[255,255,102],[255,255,51],[0,255,255],[0,204,255]],xn={debug:!1,debugOpacity:.5};class _e extends m.CompositeLayer{static layerName="RasterLayer";static defaultProps=xn;initializeState(){this.setState({})}updateState(t){super.updateState(t);const{props:e,oldProps:s,changeFlags:i}=t;(i.dataChanged||e.width!==s.width||e.height!==s.height||e.reprojectionFns!==s.reprojectionFns||e.maxError!==s.maxError)&&this._generateMesh()}_generateMesh(){const{width:t,height:e,reprojectionFns:s,maxError:i=_n}=this.props,o=new mn(s,t+1,e+1);o.run(i);const{indices:r,positions:a,texCoords:c}=Mn(o);this.setState({reprojector:o,mesh:{positions:a,indices:r,texCoords:c}})}renderDebugLayer(){const{reprojector:t}=this.state,{debugOpacity:e}=this.props;return t?new Mt(this.getSubLayerProps({id:"polygon",data:{reprojector:t,length:t.triangles.length/3},getPolygon:(s,{index:i,data:o})=>{const r=o.reprojector.triangles,a=t.exactOutputPositions,c=r[i*3],h=r[i*3+1],u=r[i*3+2];return[[a[c*2],a[c*2+1]],[a[h*2],a[h*2+1]],[a[u*2],a[u*2+1]],[a[c*2],a[c*2+1]]]},getFillColor:(s,{index:i,target:o})=>{const r=ee[i%ee.length];return o[0]=r[0],o[1]=r[1],o[2]=r[2],o[3]=255,o},getLineColor:[0,0,0],getLineWidth:1,lineWidthUnits:"pixels",opacity:e!==void 0&&Number.isFinite(e)?Math.max(0,Math.min(1,e)):1,pickable:!1})):null}_createRenderPipeline(){if(this.props.renderPipeline instanceof ImageData){const t=this.props.renderPipeline,e=this.context.device.createTexture({format:"rgba8unorm",width:t.width,height:t.height,data:t.data});return[{module:V.CreateTexture,props:{textureName:e}}]}else return this.props.renderPipeline}renderLayers(){const{mesh:t}=this.state,{debug:e}=this.props;if(!t)return null;const{indices:s,positions:i,texCoords:o}=t,a=[new yn(this.getSubLayerProps({id:"raster",renderPipeline:this._createRenderPipeline(),data:[1],mesh:{indices:{value:s,size:1},attributes:{POSITION:{value:i,size:3},TEXCOORD_0:{value:o,size:2}}},_instanced:!1,getPosition:[0,0,0],getColor:[255,255,255]}))];if(e){const c=this.renderDebugLayer();c&&a.push(c)}return a}}function Mn(n){const t=n.uvs.length/2,e=new Float32Array(t*3),s=new Float32Array(n.uvs);for(let o=0;o<t;o++)e[o*3]=n.exactOutputPositions[o*2],e[o*3+1]=n.exactOutputPositions[o*2+1],e[o*3+2]=0;return{indices:new Uint32Array(n.triangles),positions:e,texCoords:s}}const se=512,Tn=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],wn=Tn.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),bn=6378137,yt=2*Math.PI*bn,ne=yt/2,Sn=28e-5;class Rt{x;y;z;metadata;childVisible;selected;_children;constructor(t,e,s,i){this.x=t,this.y=e,this.z=s,this.metadata=i}get tileMatrix(){return this.metadata.tileMatrices[this.z]}get children(){if(!this._children){const t=this.metadata.tileMatrices.length-1;if(this.z>=t)return this._children=null,null;const e=this.tileMatrix,s=this.z+1,i=this.metadata.tileMatrices[s],o=ie({x:this.x,y:this.y,transform:e.geotransform,tileWidth:e.tileWidth,tileHeight:e.tileHeight}),{minCol:r,maxCol:a,minRow:c,maxRow:h}=En(o,i),u=[];for(let l=c;l<=h;l++)for(let d=r;d<=a;d++)u.push(new Rt(d,l,s,this.metadata));this._children=u.length>0?u:null}return this._children}update(t){this.childVisible=!1,this.selected=!1;const{viewport:e,cullingVolume:s,elevationBounds:i,minZ:o,maxZ:r=this.metadata.tileMatrices.length-1,project:a,bounds:c}=t,{boundingVolume:h,commonSpaceBounds:u}=this.getBoundingVolume(i,a);if(c&&!this.insideBounds(c,u)||s.computeVisibility(h)<0)return!1;const d=this.children;if(!this.childVisible&&this.z>=o){const f=In(h,e.zoom);if(this.tileMatrix.scaleDenominator*Sn<=f||this.z>=r||d===null&&this.z>=o)return this.selected=!0,!0}if(d&&d.length>0){this.selected=!1;let f=!1;for(const p of d)p.update(t)&&(f=!0);return this.childVisible=f,f}return!0}getSelected(t=[]){if(this.selected&&t.push(this),this._children)for(const e of this._children)e.getSelected(t);return t}insideBounds(t,e){const[s,i,o,r]=t,[a,c,h,u]=e;return a<o&&h>s&&c<r&&u>i}getBoundingVolume(t,e){return e&&m.assert$1(!1,"TODO: implement getBoundingVolume in Globe view"),this._getGenericBoundingVolume(t)}_getGenericBoundingVolume(t){const e=this.tileMatrix,{tileWidth:s,tileHeight:i,geotransform:o}=e,[r,a]=t,c=ie({x:this.x,y:this.y,transform:o,tileWidth:s,tileHeight:i}),u=Cn(wn,c,this.metadata.projectTo3857).map(_=>Ln(_)),l=[];for(const _ of u)l.push([_[0],_[1],r]),r!==a&&l.push([_[0],_[1],a]);let d=Number.POSITIVE_INFINITY,f=Number.POSITIVE_INFINITY,p=Number.NEGATIVE_INFINITY,g=Number.NEGATIVE_INFINITY;for(const[_,x]of u)_<d&&(d=_),x<f&&(f=x),_>p&&(p=_),x>g&&(g=x);const y=[d,f,p,g];return{boundingVolume:me(l),commonSpaceBounds:y}}}function ie({x:n,y:t,transform:e,tileWidth:s,tileHeight:i}){const[o,r,a,c,h,u]=e;if(r!==0||c!==0)throw new Error(`Rotated/skewed geotransforms not yet supported (b=${r}, d=${c}). Only north-up, non-rotated rasters are currently supported.`);const l=n*s,d=t*i,f=(n+1)*s,p=(t+1)*i,g=o*l+r*d+a,y=c*l+h*d+u,_=o*f+r*p+a,x=c*f+h*p+u;return[Math.min(g,_),Math.min(y,x),Math.max(g,_),Math.max(y,x)]}function Cn(n,t,e){const[s,i,o,r]=t,a=[];for(const[c,h]of n){const u=s+c*(o-s),l=i+h*(r-i),d=e([u,l]);a.push(d)}return a}function Ln([n,t]){const e=Math.max(-ne,Math.min(ne,t));return[(n/yt+.5)*se,(e/yt+.5)*se]}function En(n,t){const[e,s,i,o]=n,{tileWidth:r,tileHeight:a,cellSize:c,matrixWidth:h,matrixHeight:u,pointOfOrigin:l}=t,d=r*c,f=a*c,p=l[0],g=l[1];let y=Math.floor((e-p)/d),_=Math.floor((i-p)/d),x=Math.floor((g-o)/f),M=Math.floor((g-s)/f);return y=Math.max(0,Math.min(h-1,y)),_=Math.max(0,Math.min(h-1,_)),x=Math.max(0,Math.min(u-1,x)),M=Math.max(0,Math.min(u-1,M)),{minCol:y,maxCol:_,minRow:x,maxRow:M}}function Pn(n,t){const{viewport:e,maxZ:s,zRange:i}=t,o=e instanceof m.GlobeViewport&&e.resolution?e.projectPosition:null,r=Object.values(e.getFrustumPlanes()).map(({normal:b,distance:C})=>new U(b.clone().negate(),C)),a=new A(r),c=e.distanceScales.unitsPerMeter[2],h=i&&i[0]*c||0,u=i&&i[1]*c||0,l=0,{lowerLeft:d,upperRight:f}=n.wgsBounds,[p,g]=d,[y,_]=f,x=m.lngLatToWorld([p,g]),M=m.lngLatToWorld([y,_]),T=[x[0],x[1],M[0],M[1]],w=n.tileMatrices[0],S=[];for(let b=0;b<w.matrixHeight;b++)for(let C=0;C<w.matrixWidth;C++)S.push(new Rt(C,b,0,n));const L={viewport:e,project:o,cullingVolume:a,elevationBounds:[h,u],minZ:l,maxZ:s,bounds:T};for(const b of S)b.update(L);const R=[];for(const b of S)b.getSelected(R);return R}function Rn(n,t){return 40075016686e-3*Math.cos(n*Math.PI/180)/2**(t+8)}function In(n,t){const[e,s]=m.worldToLngLat(n.center);return Rn(s,t)}class An extends Et{metadata;constructor(t,e){super(e),this.metadata=t}getTileIndices(t){const e=this.metadata.tileMatrices.length-1,s=typeof t.maxZoom=="number"?Math.min(t.maxZoom,e):e;return Pn(this.metadata,{viewport:t.viewport,maxZ:s,zRange:t.zRange??null})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getParentIndex(t){if(t.z===0)return t;const e=this.metadata.tileMatrices[t.z],s=this.metadata.tileMatrices[t.z-1],i=e.cellSize/s.cellSize;return{x:Math.floor(t.x/i),y:Math.floor(t.y/i),z:t.z-1}}getTileZoom(t){return t.z}getTileMetadata(t){const{x:e,y:s,z:i}=t,{tileMatrices:o}=this.metadata,r=o[i],{geotransform:a,tileHeight:c,tileWidth:h}=r,[u,l,d,f,p,g]=a,y=e*h,_=s*c,x=(e+1)*h,M=(s+1)*c,T=[u*y+l*_+d,f*y+p*_+g],w=[u*x+l*_+d,f*x+p*_+g],S=[u*y+l*M+d,f*y+p*M+g],L=[u*x+l*M+d,f*x+p*M+g],R={topLeft:T,topRight:w,bottomLeft:S,bottomRight:L};return{bounds:[Math.min(T[0],w[0],S[0],L[0]),Math.min(T[1],w[1],S[1],L[1]),Math.max(T[0],w[0],S[0],L[0]),Math.max(T[1],w[1],S[1],L[1])],projectedBounds:R,tileWidth:h,tileHeight:c,tileMatrix:r}}}const On={MERIT:{a:6378137},SGS85:{a:6378136},GRS80:{a:6378137},IAU76:{a:6378140},airy:{a:6377563396e-3,b:635625691e-2},APL4:{a:6378137},NWL9D:{a:6378145},mod_airy:{a:6377340189e-3,b:6356034446e-3},andrae:{a:637710443e-2},aust_SA:{a:6378160},GRS67:{a:6378160},bessel:{a:6377397155e-3},bess_nam:{a:6377483865e-3},clrk66:{a:63782064e-1,b:63565838e-1},clrk80:{a:6378249145e-3},clrk80ign:{a:63782492e-1,b:6356515},clrk58:{a:6378293645208759e-9},CPM:{a:63757387e-1},delmbr:{a:6376428},engelis:{a:637813605e-2},evrst30:{a:6377276345e-3},evrst48:{a:6377304063e-3},evrst56:{a:6377301243e-3},evrst69:{a:6377295664e-3},evrstSS:{a:6377298556e-3},fschr60:{a:6378166},fschr60m:{a:6378155},fschr68:{a:6378150},helmert:{a:6378200},hough:{a:6378270},intl:{a:6378388},kaula:{a:6378163},lerch:{a:6378139},mprts:{a:6397300},new_intl:{a:63781575e-1,b:63567722e-1},plessis:{a:6376523},krass:{a:6378245},SEasia:{a:6378155,b:63567733205e-4},walbeck:{a:6376896,b:63558348467e-4},WGS60:{a:6378165},WGS66:{a:6378145},WGS7:{a:6378135},WGS84:{a:6378137},sphere:{a:6370997,b:6370997}};function vn(n){if(zn(n))throw new Error("Cannot invert degenerate transform");const t=1/xe(n),[e,s,i,o,r,a]=n,c=r*t,h=-s*t,u=-o*t,l=e*t;return[c,h,-i*c-a*h,u,l,-i*u-a*l]}function zn(n){return xe(n)===0}function xe(n){const[t,e,s,i,o,r]=n;return t*o-e*i}function oe(n,t,e){const[s,i,o,r,a,c]=e;return[s*n+i*t+o,r*n+a*t+c]}const Nn={$schema:"https://proj.org/schemas/v0.7/projjson.schema.json",type:"GeographicCRS",name:"WGS 84 (CRS84)",datum_ensemble:{name:"World Geodetic System 1984 ensemble",members:[{name:"World Geodetic System 1984 (Transit)",id:{authority:"EPSG",code:1166}},{name:"World Geodetic System 1984 (G730)",id:{authority:"EPSG",code:1152}},{name:"World Geodetic System 1984 (G873)",id:{authority:"EPSG",code:1153}},{name:"World Geodetic System 1984 (G1150)",id:{authority:"EPSG",code:1154}},{name:"World Geodetic System 1984 (G1674)",id:{authority:"EPSG",code:1155}},{name:"World Geodetic System 1984 (G1762)",id:{authority:"EPSG",code:1156}},{name:"World Geodetic System 1984 (G2139)",id:{authority:"EPSG",code:1309}}],ellipsoid:{name:"WGS 84",semi_major_axis:6378137,inverse_flattening:298.257223563},accuracy:"2.0",id:{authority:"EPSG",code:6326}},coordinate_system:{subtype:"ellipsoidal",axis:[{name:"Geodetic longitude",abbreviation:"Lon",direction:"east",unit:"degree"},{name:"Geodetic latitude",abbreviation:"Lat",direction:"north",unit:"degree"}]},scope:"Not known.",area:"World.",bbox:{south_latitude:-90,west_longitude:-180,north_latitude:90,east_longitude:180},id:{authority:"OGC",code:"CRS84"}};async function Me(n,t,e=Nn){const s=await n.getImage(),i=Te(s),o=F.default(t,e),{forwardTransform:r,inverseTransform:a}=It(i);return{forwardTransform:r,inverseTransform:a,forwardReproject:(c,h)=>o.forward([c,h],!1),inverseReproject:(c,h)=>o.inverse([c,h],!1)}}function It(n){const t=vn(n);return{forwardTransform:(e,s)=>oe(e,s,n),inverseTransform:(e,s)=>oe(e,s,t)}}function Te(n){const t=n.getOrigin(),e=n.getResolution(),i=n.getFileDirectory().ModelTransformation;let o=0,r=0;return i&&i.length>=16&&(o=i[1],r=i[4]),[e[0],o,t[0],r,e[1],t[1]]}const we=28e-5;async function be(n,t){const e=await n.getImage();if(!e.isTiled)throw new Error("COG TileMatrixSet requires a tiled GeoTIFF");const s=await n.getImageCount(),i=e.getBoundingBox(),o=e.getWidth(),r=e.getHeight(),a=await t(e.getGeoKeys());if(a===null)throw new Error("Could not determine coordinate reference system from GeoTIFF geo keys");const c=F.default(a.def,"EPSG:4326").forward,h=F.default(a.def,"EPSG:3857").forward,u={lowerLeft:[i[0],i[1]],upperRight:[i[2],i[3]]},l=Te(e);if(l[1]!==0||l[3]!==0)throw new Error("COG TileMatrixSet with rotation/skewed geotransform is not supported");const d=Math.abs(l[0]),f=e.getTileWidth(),p=e.getTileHeight(),g=[{id:String(s-1),scaleDenominator:d*At(a.parsed,a.coordinatesUnits)/we,cellSize:d,pointOfOrigin:[l[2],l[5]],tileWidth:e.getTileWidth(),tileHeight:e.getTileHeight(),matrixWidth:Math.ceil(o/f),matrixHeight:Math.ceil(r/p),geotransform:l}];for(let y=1;y<s;y++){const _=await n.getImage(y);if(!_.isTiled)throw new Error("COG TileMatrixSet requires a tiled GeoTIFF");const x=Vn({id:String(s-1-y),image:_,fullWidth:o,baseTransform:l,crs:a});g.push(x)}return g.reverse(),{crs:a,boundingBox:u,wgsBounds:Fn(u,c),tileMatrices:g,projectToWgs84:c,projectTo3857:h}}function At(n,t){const e=(t||n.units)?.toLowerCase();switch(e){case"m":case"metre":case"meter":case"meters":return 1;case"foot":return .3048;case"us survey foot":return 1200/3937}if(e==="degree"){const{a:s}=On[n.ellps];return 2*Math.PI*s/360}throw new Error(`Unsupported CRS units: ${e}`)}function Vn({id:n,image:t,fullWidth:e,baseTransform:s,crs:i}){const o=t.getWidth(),r=t.getHeight(),c=e/o,h=[s[0]*c,s[1]*c,s[2],s[3]*c,s[4]*c,s[5]],u=Math.abs(h[0]),l=t.getTileWidth(),d=t.getTileHeight();return{id:n,scaleDenominator:u*At(i.parsed,i.coordinatesUnits)/we,cellSize:u,pointOfOrigin:[h[2],h[5]],tileWidth:l,tileHeight:d,matrixWidth:Math.ceil(o/l),matrixHeight:Math.ceil(r/d),geotransform:h}}function Fn(n,t){const e=t(n.lowerLeft),s=t([n.upperRight[0],n.lowerLeft[1]]),i=t(n.upperRight),o=t([n.lowerLeft[0],n.upperRight[1]]),r=Math.min(e[0],s[0],i[0],o[0]),a=Math.max(e[0],s[0],i[0],o[0]),c=Math.min(e[1],s[1],i[1],o[1]),h=Math.max(e[1],s[1],i[1],o[1]);return{lowerLeft:[r,c],upperRight:[a,h]}}const qn={metersPerUnit:At};let ht=null;function Se(){return ht===null&&(ht=new G.Pool),ht}async function Ce(n,t){const e={...t,interleave:!0,enableAlpha:!0},s=await n.readRGB(e);return{texture:Le(s),height:s.height,width:s.width}}function Le(n){const{height:t,width:e}=n;if(n.length===t*e*4)return new ImageData(new Uint8ClampedArray(n),e,t);if(n.length===t*e*3){const s=n.length/3*4,i=new Uint8ClampedArray(s);for(let o=0;o<n.length/3;++o)i[o*4]=n[o*3],i[o*4+1]=n[o*3+1],i[o*4+2]=n[o*3+2],i[o*4+3]=255;return new ImageData(i,e,t)}else throw new Error(`Unexpected number of channels in raster data: ${n.length/(t*e)}`)}function Ee(n){const t=n.length/3,e=new Uint8ClampedArray(t*4),s=0,i=t,o=t*2;for(let r=0;r<t;r++)e[4*r+0]=n[s+r]>>8,e[4*r+1]=n[i+r]>>8,e[4*r+2]=n[o+r]>>8,e[4*r+3]=255;return new ImageData(e,t,1)}async function Pe(n){return typeof n=="string"?G.fromUrl(n):n instanceof ArrayBuffer?G.fromArrayBuffer(n):n instanceof Blob?G.fromBlob(n):n instanceof G.BaseClient?G.fromCustomClient(n):n}function Re(n,t){const e=n.getBoundingBox(),[s,i,o,r]=e,a=[t.forward([s,i]),t.forward([o,i]),t.forward([o,r]),t.forward([s,r])],c=a.map(p=>p[0]),h=a.map(p=>p[1]),u=Math.min(...c),l=Math.min(...h),d=Math.max(...c),f=Math.max(...h);return{west:u,south:l,east:d,north:f}}function Gn(n){if(!n)return null;const t=n?.[n?.length-1]==="\0"?n.slice(0,-1):n;return t?.length>0?parseFloat(t):null}function Bn(n,t,e){const s=n.getFileDirectory(),i=s.SamplesPerPixel,o=Ot(i,s.BitsPerSample,s.SampleFormat);return{data:t,format:o,width:e.width,height:e.height}}function Ot(n,t,e){const s=Dn(n),i=Un(t),o=kn(e),r=`${s}:${o}:${i}`,a=Wn[r];if(!a)throw new Error(`Unsupported texture format for SamplesPerPixel=${n}, BitsPerSample=${t}, SampleFormat=${e}`);return a}function Dn(n){if(n===1||n===2||n===3||n===4)return n;throw new Error(`Unsupported SamplesPerPixel ${n}. Only 1, 2, 3, or 4 are supported.`)}function Un(n){const t=n[0];for(let e=1;e<n.length;e++)if(n[e]!==t)throw new Error(`Unsupported varying BitsPerSample ${n}. All samples must have the same bit width.`);if(t!==8&&t!==16&&t!==32)throw new Error(`Unsupported BitsPerSample ${t}. Only 8, 16, or 32 are supported.`);return t}function kn(n){const t=n[0];for(let e=1;e<n.length;e++)if(n[e]!==t)throw new Error(`Unsupported varying SampleFormat ${n}. All samples must have the same format.`);switch(t){case 1:return"unorm";case 2:return"sint";case 3:return"float";default:throw new Error(`Unsupported SampleFormat ${n}`)}}const Wn={"1:sint:8":"r8sint","1:uint:8":"r8uint","1:unorm:8":"r8unorm","1:float:16":"r16float","1:sint:16":"r16sint","1:uint:16":"r16uint","1:unorm:16":"r16unorm","2:sint:8":"rg8sint","2:uint:8":"rg8uint","2:unorm:8":"rg8unorm","1:float:32":"r32float","1:sint:32":"r32sint","1:uint:32":"r32uint","2:float:16":"rg16float","2:sint:16":"rg16sint","2:uint:16":"rg16uint","2:unorm:16":"rg16unorm","4:sint:8":"rgba8sint","4:uint:8":"rgba8uint","4:unorm:8":"rgba8unorm","3:uint:16":"rgb16unorm-webgl","2:float:32":"rg32float","2:sint:32":"rg32sint","2:uint:32":"rg32uint","4:float:16":"rgba16float","4:sint:16":"rgba16sint","4:uint:16":"rgba16uint","4:unorm:16":"rgba16unorm","3:float:32":"rgb32float-webgl","4:float:32":"rgba32float","4:sint:32":"rgba32sint","4:uint:32":"rgba32uint"},jn=Object.freeze(Object.defineProperty({__proto__:null,createTextureProps:Bn,inferTextureFormat:Ot},Symbol.toStringTag,{value:"Module"}));var N;(function(n){n[n.WhiteIsZero=0]="WhiteIsZero",n[n.BlackIsZero=1]="BlackIsZero",n[n.RGB=2]="RGB",n[n.Palette=3]="Palette",n[n.TransparencyMask=4]="TransparencyMask",n[n.CMYK=5]="CMYK",n[n.YCbCr=6]="YCbCr",n[n.CIELab=8]="CIELab",n[n.ICCLab=9]="ICCLab"})(N||(N={}));var re;(function(n){n[n.Chunky=1]="Chunky",n[n.Planar=2]="Planar"})(re||(re={}));function Yn(n,t){const{SampleFormat:e}=n;if(e[0]===1)return Xn(n,t);throw new Error(`Inferring render pipeline for non-unsigned integers not yet supported. Found SampleFormat: ${e}`)}function Xn(n,t){const{BitsPerSample:e,ColorMap:s,GDAL_NODATA:i,PhotometricInterpretation:o,SampleFormat:r,SamplesPerPixel:a}=n,c=[{module:V.CreateTexture,props:{textureName:p=>p.texture}}],h=Gn(i);if(h!==null){const p=h/255;c.push({module:V.FilterNoDataVal,props:{value:p}})}const u=$n(o,t,s);u&&c.push(u);const l=o===N.Palette?{magFilter:"nearest",minFilter:"nearest"}:{magFilter:"linear",minFilter:"linear"};return{getTileData:async(p,g)=>{const{device:y}=g,_={...g,interleave:!0};let x=await p.readRasters(_),M=a;a===3&&(x=Le(x),M=4);const T=Ot(M,e,r);return{texture:y.createTexture({data:x,format:T,width:x.width,height:x.height,sampler:l}),height:x.height,width:x.width}},renderTile:p=>c.map((g,y)=>Zn(g,p))}}function $n(n,t,e){switch(n){case N.RGB:return null;case N.Palette:{if(!e)throw new Error("ColorMap is required for PhotometricInterpretation Palette");const{data:s,width:i,height:o}=Ee(e),r=t.createTexture({data:s,format:"rgba8unorm",width:i,height:o,sampler:{minFilter:"nearest",magFilter:"nearest",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}});return{module:V.Colormap,props:{colormapTexture:r}}}case N.CMYK:return{module:V.CMYKToRGB};case N.YCbCr:return{module:V.YCbCrToRGB};case N.CIELab:return{module:V.cieLabToRGB};default:throw new Error(`Unsupported PhotometricInterpretation ${n}`)}}function Zn(n,t){const{module:e,props:s}=n;if(!s)return{module:e};const i={};for(const[o,r]of Object.entries(s)){const a=typeof r=="function"?r(t):r;a!==void 0&&(i[o]=a)}return{module:e,props:i}}async function vt(n){const t=n.ProjectedCSTypeGeoKey||n.GeographicTypeGeoKey||null,e=await Hn(t);if(!e)return null;const s=Ie(e);return{def:e,parsed:s,coordinatesUnits:s.units}}async function Hn(n){if(n===null)return null;const t=`https://epsg.io/${n}.json`,e=await fetch(t);if(!e.ok)throw new Error(`Failed to fetch projection data from ${t}`);return await e.json()}function Ie(n){const t="__deck.gl-geotiff-internal__";return F.default.defs(t,n),F.default.defs(t)}const Kn=Object.freeze(Object.defineProperty({__proto__:null,epsgIoGeoKeyParser:vt,parseCrs:Ie},Symbol.toStringTag,{value:"Module"})),Qn={geoKeysParser:vt,debug:!1,debugOpacity:.5};class Jn extends m.CompositeLayer{static layerName="COGLayer";static defaultProps=Qn;initializeState(){this.setState({})}updateState(t){super.updateState(t);const{props:e,oldProps:s,changeFlags:i}=t;(i.dataChanged||e.geotiff!==s.geotiff)&&this._parseGeoTIFF()}async _parseGeoTIFF(){const t=await Pe(this.props.geotiff),e=this.props.geoKeysParser,s=await be(t,e),i=await t.getImage(),o=await t.getImageCount(),r=[];for(let f=0;f<o;f++)r.push(await t.getImage(f));const a=await e(i.getGeoKeys());if(!a)throw new Error("Could not determine source projection from GeoTIFF geo keys");const c=F.default(a.def,"EPSG:4326"),h=(f,p)=>c.forward([f,p],!1),u=(f,p)=>c.inverse([f,p],!1);if(this.props.onGeoTIFFLoad){const f=Re(i,c);this.props.onGeoTIFFLoad(t,{projection:a,geographicBounds:f})}const{getTileData:l,renderTile:d}=Yn(i.fileDirectory,this.context.device);this.setState({metadata:s,forwardReproject:h,inverseReproject:u,images:r,defaultGetTileData:l,defaultRenderTile:d})}async _getTileData(t,e,s){const{signal:i}=t,{x:o,y:r,z:a}=t.index,c=e[e.length-1-a],h=c.getHeight(),u=c.getWidth(),l=s.tileMatrices[a],{tileWidth:d,tileHeight:f}=l,p=ti(o,r,l),{forwardTransform:g,inverseTransform:y}=It(p),_=[o*d,r*f,Math.min((o+1)*d,u),Math.min((r+1)*f,h)],x=this.props.getTileData||this.state.defaultGetTileData,M=i&&this.props.signal?AbortSignal.any([i,this.props.signal]):i||this.props.signal;return{data:await x(c,{device:this.context.device,window:_,signal:M,pool:this.props.pool||Se()}),forwardTransform:g,inverseTransform:y}}_renderSubLayers(t,e,s,i){const{maxError:o,debug:r,debugOpacity:a}=this.props,{tile:c}=t;if(!t.data)return null;const{data:h,forwardTransform:u,inverseTransform:l}=t.data,d=[];if(h){const{height:f,width:p}=h,g=this.props.renderTile||this.state.defaultRenderTile;d.push(new _e({id:`${t.id}-raster`,width:p,height:f,renderPipeline:g(h),maxError:o,reprojectionFns:{forwardTransform:u,inverseTransform:l,forwardReproject:s,inverseReproject:i},debug:r,debugOpacity:a}))}if(r){const f=c?.projectedBounds;if(!f||!e)return[];const{topLeft:p,topRight:g,bottomLeft:y,bottomRight:_}=f,x=e.projectToWgs84(p),M=e.projectToWgs84(g),T=e.projectToWgs84(_),w=e.projectToWgs84(y),S=[x,M,T,w,x];d.push(new m.PathLayer({id:`${this.id}-${c.id}-bounds`,data:[S],getPath:L=>L,getColor:[255,0,0,255],getWidth:2,widthUnits:"pixels",pickable:!1}))}return d}renderTileLayer(t,e,s,i){class o extends An{constructor(a){super(t,a)}}return new it({id:`cog-tile-layer-${this.id}`,TilesetClass:o,getTileData:async r=>this._getTileData(r,i,t),renderSubLayers:r=>this._renderSubLayers(r,t,e,s)})}renderLayers(){const{forwardReproject:t,inverseReproject:e,metadata:s,images:i}=this.state;return!t||!e||!s||!i?null:this.renderTileLayer(s,t,e,i)}}function ti(n,t,e){const{tileWidth:s,tileHeight:i}=e,o=n*s,r=t*i,[a,c,h,u,l,d]=e.geotransform,f=a*o+c*r+h,p=u*o+l*r+d;return[a,c,f,u,l,p]}const ei={geoKeysParser:vt};class si extends m.CompositeLayer{static layerName="GeoTIFFLayer";static defaultProps=ei;initializeState(){this.setState({})}updateState(t){super.updateState(t);const{props:e,oldProps:s,changeFlags:i}=t;(i.dataChanged||e.geotiff!==s.geotiff||e.maxError!==s.maxError)&&this._parseGeoTIFF()}async _parseGeoTIFF(){const t=await Pe(this.props.geotiff),e=await t.getImage(),s=this.props.geoKeysParser,i=await s(e.getGeoKeys());if(!i)throw new Error("Could not determine source projection from GeoTIFF geo keys");const o=F.default(i.def,"EPSG:4326");if(this.props.onGeoTIFFLoad){const u=Re(e,o);this.props.onGeoTIFFLoad(t,{projection:i,geographicBounds:u})}const r=await Me(t,i.def),{texture:a,height:c,width:h}=await Ce(e,{pool:this.props.pool||Se()});this.setState({reprojectionFns:r,imageData:a,height:c,width:h})}renderLayers(){const{reprojectionFns:t,imageData:e,height:s,width:i}=this.state;if(!t||!e||!s||!i)return null;const{maxError:o,debug:r,debugOpacity:a}=this.props;return new _e(this.getSubLayerProps({id:"raster",width:i,height:s,reprojectionFns:t,maxError:o,texture:e,debug:r,debugOpacity:a}))}}class ni{constructor(){this.ids=[],this.values=[],this.length=0}clear(){this.length=0}push(t,e){let s=this.length++;for(;s>0;){const i=s-1>>1,o=this.values[i];if(e>=o)break;this.ids[s]=this.ids[i],this.values[s]=o,s=i}this.ids[s]=t,this.values[s]=e}pop(){if(this.length===0)return;const t=this.ids,e=this.values,s=t[0],i=--this.length;if(i>0){const o=t[i],r=e[i];let a=0;const c=i>>1;for(;a<c;){const h=(a<<1)+1,u=h+1,l=h+(+(u<i)&+(e[u]<e[h]));if(e[l]>=r)break;t[a]=t[l],e[a]=e[l],a=l}t[a]=o,e[a]=r}return s}peek(){return this.length>0?this.ids[0]:void 0}peekValue(){return this.length>0?this.values[0]:void 0}shrink(){this.ids.length=this.values.length=this.length}}const ae=[Int8Array,Uint8Array,Uint8ClampedArray,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array],ut=3;class zt{static from(t,e=0){if(e%8!==0)throw new Error("byteOffset must be 8-byte aligned.");if(!t||t.byteLength===void 0||t.buffer)throw new Error("Data must be an instance of ArrayBuffer or SharedArrayBuffer.");const[s,i]=new Uint8Array(t,e+0,2);if(s!==251)throw new Error("Data does not appear to be in a Flatbush format.");const o=i>>4;if(o!==ut)throw new Error(`Got v${o} data when expected v${ut}.`);const r=ae[i&15];if(!r)throw new Error("Unrecognized array type.");const[a]=new Uint16Array(t,e+2,1),[c]=new Uint32Array(t,e+4,1);return new zt(c,a,r,void 0,t,e)}constructor(t,e=16,s=Float64Array,i=ArrayBuffer,o,r=0){if(t===void 0)throw new Error("Missing required argument: numItems.");if(isNaN(t)||t<=0)throw new Error(`Unexpected numItems value: ${t}.`);this.numItems=+t,this.nodeSize=Math.min(Math.max(+e,2),65535),this.byteOffset=r;let a=t,c=a;this._levelBounds=[a*4];do a=Math.ceil(a/this.nodeSize),c+=a,this._levelBounds.push(c*4);while(a!==1);this.ArrayType=s,this.IndexArrayType=c<16384?Uint16Array:Uint32Array;const h=ae.indexOf(s),u=c*4*s.BYTES_PER_ELEMENT;if(h<0)throw new Error(`Unexpected typed array class: ${s}.`);if(o)this.data=o,this._boxes=new s(o,r+8,c*4),this._indices=new this.IndexArrayType(o,r+8+u,c),this._pos=c*4,this.minX=this._boxes[this._pos-4],this.minY=this._boxes[this._pos-3],this.maxX=this._boxes[this._pos-2],this.maxY=this._boxes[this._pos-1];else{const l=this.data=new i(8+u+c*this.IndexArrayType.BYTES_PER_ELEMENT);this._boxes=new s(l,8,c*4),this._indices=new this.IndexArrayType(l,8+u,c),this._pos=0,this.minX=1/0,this.minY=1/0,this.maxX=-1/0,this.maxY=-1/0,new Uint8Array(l,0,2).set([251,(ut<<4)+h]),new Uint16Array(l,2,1)[0]=e,new Uint32Array(l,4,1)[0]=t}this._queue=new ni}add(t,e,s=t,i=e){const o=this._pos>>2,r=this._boxes;return this._indices[o]=o,r[this._pos++]=t,r[this._pos++]=e,r[this._pos++]=s,r[this._pos++]=i,t<this.minX&&(this.minX=t),e<this.minY&&(this.minY=e),s>this.maxX&&(this.maxX=s),i>this.maxY&&(this.maxY=i),o}finish(){if(this._pos>>2!==this.numItems)throw new Error(`Added ${this._pos>>2} items when expected ${this.numItems}.`);const t=this._boxes;if(this.numItems<=this.nodeSize){t[this._pos++]=this.minX,t[this._pos++]=this.minY,t[this._pos++]=this.maxX,t[this._pos++]=this.maxY;return}const e=this.maxX-this.minX||1,s=this.maxY-this.minY||1,i=new Uint32Array(this.numItems),o=65535;for(let r=0,a=0;r<this.numItems;r++){const c=t[a++],h=t[a++],u=t[a++],l=t[a++],d=Math.floor(o*((c+u)/2-this.minX)/e),f=Math.floor(o*((h+l)/2-this.minY)/s);i[r]=oi(d,f)}_t(i,t,this._indices,0,this.numItems-1,this.nodeSize);for(let r=0,a=0;r<this._levelBounds.length-1;r++){const c=this._levelBounds[r];for(;a<c;){const h=a;let u=t[a++],l=t[a++],d=t[a++],f=t[a++];for(let p=1;p<this.nodeSize&&a<c;p++)u=Math.min(u,t[a++]),l=Math.min(l,t[a++]),d=Math.max(d,t[a++]),f=Math.max(f,t[a++]);this._indices[this._pos>>2]=h,t[this._pos++]=u,t[this._pos++]=l,t[this._pos++]=d,t[this._pos++]=f}}}search(t,e,s,i,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let r=this._boxes.length-4;const a=[],c=[];for(;r!==void 0;){const h=Math.min(r+this.nodeSize*4,ce(r,this._levelBounds));for(let u=r;u<h;u+=4){const l=this._boxes[u];if(s<l)continue;const d=this._boxes[u+1];if(i<d)continue;const f=this._boxes[u+2];if(t>f)continue;const p=this._boxes[u+3];if(e>p)continue;const g=this._indices[u>>2]|0;r>=this.numItems*4?a.push(g):(o===void 0||o(g,l,d,f,p))&&c.push(g)}r=a.pop()}return c}neighbors(t,e,s=1/0,i=1/0,o){if(this._pos!==this._boxes.length)throw new Error("Data not yet indexed - call index.finish().");let r=this._boxes.length-4;const a=this._queue,c=[],h=i*i;t:for(;r!==void 0;){const u=Math.min(r+this.nodeSize*4,ce(r,this._levelBounds));for(let l=r;l<u;l+=4){const d=this._indices[l>>2]|0,f=this._boxes[l],p=this._boxes[l+1],g=this._boxes[l+2],y=this._boxes[l+3],_=t<f?f-t:t>g?t-g:0,x=e<p?p-e:e>y?e-y:0,M=_*_+x*x;M>h||(r>=this.numItems*4?a.push(d<<1,M):(o===void 0||o(d))&&a.push((d<<1)+1,M))}for(;a.length&&a.peek()&1;)if(a.peekValue()>h||(c.push(a.pop()>>1),c.length===s))break t;r=a.length?a.pop()>>1:void 0}return a.clear(),c}}function ce(n,t){let e=0,s=t.length-1;for(;e<s;){const i=e+s>>1;t[i]>n?s=i:e=i+1}return t[e]}function _t(n,t,e,s,i,o){if(Math.floor(s/o)>=Math.floor(i/o))return;const r=n[s],a=n[s+i>>1],c=n[i];let h=c;const u=Math.max(r,a);c>u?h=u:u===r?h=Math.max(a,c):u===a&&(h=Math.max(r,c));let l=s-1,d=i+1;for(;;){do l++;while(n[l]<h);do d--;while(n[d]>h);if(l>=d)break;ii(n,t,e,l,d)}_t(n,t,e,s,d,o),_t(n,t,e,d+1,i,o)}function ii(n,t,e,s,i){const o=n[s];n[s]=n[i],n[i]=o;const r=4*s,a=4*i,c=t[r],h=t[r+1],u=t[r+2],l=t[r+3];t[r]=t[a],t[r+1]=t[a+1],t[r+2]=t[a+2],t[r+3]=t[a+3],t[a]=c,t[a+1]=h,t[a+2]=u,t[a+3]=l;const d=e[s];e[s]=e[i],e[i]=d}function oi(n,t){let e=n^t,s=65535^e,i=65535^(n|t),o=n&(t^65535),r=e|s>>1,a=e>>1^e,c=i>>1^s&o>>1^i,h=e&i>>1^o>>1^o;e=r,s=a,i=c,o=h,r=e&e>>2^s&s>>2,a=e&s>>2^s&(e^s)>>2,c^=e&i>>2^s&o>>2,h^=s&i>>2^(e^s)&o>>2,e=r,s=a,i=c,o=h,r=e&e>>4^s&s>>4,a=e&s>>4^s&(e^s)>>4,c^=e&i>>4^s&o>>4,h^=s&i>>4^(e^s)&o>>4,e=r,s=a,i=c,o=h,c^=e&i>>8^s&o>>8,h^=s&i>>8^(e^s)&o>>8,e=c^c>>1,s=h^h>>1;let u=n^t,l=s|65535^(u|e);return u=(u|u<<8)&16711935,u=(u|u<<4)&252645135,u=(u|u<<2)&858993459,u=(u|u<<1)&1431655765,l=(l|l<<8)&16711935,l=(l|l<<4)&252645135,l=(l|l<<2)&858993459,l=(l|l<<1)&1431655765,(l<<1|u)>>>0}class Ae extends Et{sources;index;constructor(t,e){super(e),this.sources=t.map((i,o)=>({x:i.x===void 0?o:i.x,y:i.y===void 0?0:i.y,z:i.z===void 0?0:i.z,...i}));const s=new zt(t.length);for(const i of t){const[o,r,a,c]=i.bbox;s.add(o,r,a,c)}s.finish(),this.index=s}getTileIndices({viewport:t,maxZoom:e,minZoom:s}){if(t.zoom<(s??-1/0))return[];if(t.zoom>(e??1/0))return[];const i=t.getBounds();return this.index.search(...i).map(r=>this.sources[r])}}const ri={};class ai extends m.CompositeLayer{static layerName="MosaicLayer";static defaultProps=ri;renderTileLayer(t,e){const{id:s,minZoom:i,maxZoom:o,extent:r,maxCacheByteSize:a,maxCacheSize:c,maxRequests:h}=this.props;class u extends Ae{constructor(d){super(t,d)}}return new it({id:`mosaic-layer-${s}`,TilesetClass:u,minZoom:i,maxZoom:o,extent:r,...a!==void 0&&{maxCacheByteSize:a},maxCacheSize:c,maxRequests:h,getTileData:async l=>{const d=l.index,{signal:f}=l,p=this.props.getSource&&await this.props.getSource(d,{signal:f});return{source:d,data:p,signal:f}},renderSubLayers:l=>{const{data:d}=l,{source:f,signal:p,data:g}=d;return e(f,{data:g,signal:p})}})}renderLayers(){const{sources:t,renderSource:e}=this.props;return!t||t.length===0?null:this.renderTileLayer(t,e)}}const ci={...qn};exports.COGLayer=Jn;exports.GeoTIFFLayer=si;exports.MosaicLayer=ai;exports.MosaicTileset2D=Ae;exports.__TEST_EXPORTS=ci;exports.extractGeotiffReprojectors=Me;exports.fromGeoTransform=It;exports.loadRgbImage=Ce;exports.parseCOGTileMatrixSet=be;exports.parseColormap=Ee;exports.proj=Kn;exports.texture=jn;