@deck.gl/geo-layers 9.0.35 → 9.1.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/dist/dist.dev.js +23221 -6550
  2. package/dist/geo-cell-layer/GeoCellLayer.d.ts.map +1 -1
  3. package/dist/geo-cell-layer/GeoCellLayer.js +3 -0
  4. package/dist/geohash-layer/geohash-layer.d.ts.map +1 -1
  5. package/dist/geohash-layer/geohash-layer.js +3 -0
  6. package/dist/geohash-layer/geohash-utils.d.ts.map +1 -1
  7. package/dist/geohash-layer/geohash-utils.js +3 -0
  8. package/dist/great-circle-layer/great-circle-layer.d.ts.map +1 -1
  9. package/dist/great-circle-layer/great-circle-layer.js +3 -0
  10. package/dist/h3-layers/h3-cluster-layer.d.ts.map +1 -1
  11. package/dist/h3-layers/h3-cluster-layer.js +3 -0
  12. package/dist/h3-layers/h3-hexagon-layer.d.ts.map +1 -1
  13. package/dist/h3-layers/h3-hexagon-layer.js +3 -0
  14. package/dist/h3-layers/h3-utils.d.ts.map +1 -1
  15. package/dist/h3-layers/h3-utils.js +3 -0
  16. package/dist/index.cjs +173 -48
  17. package/dist/index.cjs.map +4 -4
  18. package/dist/index.d.ts.map +1 -1
  19. package/dist/index.js +3 -19
  20. package/dist/mesh-layer/mesh-layer-fragment.glsl.d.ts +1 -1
  21. package/dist/mesh-layer/mesh-layer-fragment.glsl.d.ts.map +1 -1
  22. package/dist/mesh-layer/mesh-layer-fragment.glsl.js +8 -8
  23. package/dist/mesh-layer/mesh-layer-uniforms.d.ts +12 -0
  24. package/dist/mesh-layer/mesh-layer-uniforms.d.ts.map +1 -0
  25. package/dist/mesh-layer/mesh-layer-uniforms.js +16 -0
  26. package/dist/mesh-layer/mesh-layer-vertex.glsl.d.ts +1 -1
  27. package/dist/mesh-layer/mesh-layer-vertex.glsl.d.ts.map +1 -1
  28. package/dist/mesh-layer/mesh-layer-vertex.glsl.js +7 -7
  29. package/dist/mesh-layer/mesh-layer.d.ts +2 -2
  30. package/dist/mesh-layer/mesh-layer.d.ts.map +1 -1
  31. package/dist/mesh-layer/mesh-layer.js +35 -16
  32. package/dist/mvt-layer/coordinate-transform.d.ts.map +1 -1
  33. package/dist/mvt-layer/coordinate-transform.js +3 -0
  34. package/dist/mvt-layer/find-index-binary.d.ts.map +1 -1
  35. package/dist/mvt-layer/find-index-binary.js +3 -0
  36. package/dist/mvt-layer/mvt-layer.d.ts.map +1 -1
  37. package/dist/mvt-layer/mvt-layer.js +3 -0
  38. package/dist/quadkey-layer/quadkey-layer.d.ts.map +1 -1
  39. package/dist/quadkey-layer/quadkey-layer.js +3 -0
  40. package/dist/quadkey-layer/quadkey-utils.d.ts.map +1 -1
  41. package/dist/quadkey-layer/quadkey-utils.js +3 -0
  42. package/dist/s2-layer/s2-geometry.d.ts.map +1 -1
  43. package/dist/s2-layer/s2-geometry.js +3 -0
  44. package/dist/s2-layer/s2-layer.d.ts.map +1 -1
  45. package/dist/s2-layer/s2-layer.js +3 -19
  46. package/dist/s2-layer/s2-utils.d.ts.map +1 -1
  47. package/dist/s2-layer/s2-utils.js +3 -0
  48. package/dist/terrain-layer/terrain-layer.d.ts.map +1 -1
  49. package/dist/terrain-layer/terrain-layer.js +3 -19
  50. package/dist/tile-3d-layer/tile-3d-layer.d.ts +6 -6
  51. package/dist/tile-3d-layer/tile-3d-layer.d.ts.map +1 -1
  52. package/dist/tile-3d-layer/tile-3d-layer.js +3 -0
  53. package/dist/tile-layer/tile-layer.d.ts.map +1 -1
  54. package/dist/tile-layer/tile-layer.js +3 -0
  55. package/dist/tileset-2d/index.d.ts.map +1 -1
  56. package/dist/tileset-2d/index.js +3 -1
  57. package/dist/tileset-2d/memoize.d.ts.map +1 -1
  58. package/dist/tileset-2d/memoize.js +3 -0
  59. package/dist/tileset-2d/tile-2d-header.d.ts.map +1 -1
  60. package/dist/tileset-2d/tile-2d-header.js +3 -0
  61. package/dist/tileset-2d/tile-2d-traversal.d.ts.map +1 -1
  62. package/dist/tileset-2d/tile-2d-traversal.js +3 -0
  63. package/dist/tileset-2d/tileset-2d.d.ts.map +1 -1
  64. package/dist/tileset-2d/tileset-2d.js +3 -0
  65. package/dist/tileset-2d/types.d.ts.map +1 -1
  66. package/dist/tileset-2d/types.js +3 -0
  67. package/dist/tileset-2d/utils.d.ts.map +1 -1
  68. package/dist/tileset-2d/utils.js +3 -0
  69. package/dist/trips-layer/trips-layer-uniforms.d.ts +16 -0
  70. package/dist/trips-layer/trips-layer-uniforms.d.ts.map +1 -0
  71. package/dist/trips-layer/trips-layer-uniforms.js +20 -0
  72. package/dist/trips-layer/trips-layer.d.ts.map +1 -1
  73. package/dist/trips-layer/trips-layer.js +11 -32
  74. package/dist/wms-layer/utils.d.ts.map +1 -1
  75. package/dist/wms-layer/utils.js +3 -0
  76. package/dist/wms-layer/wms-layer.d.ts.map +1 -1
  77. package/dist/wms-layer/wms-layer.js +3 -0
  78. package/dist.min.js +530 -260
  79. package/package.json +13 -13
  80. package/src/geo-cell-layer/GeoCellLayer.ts +4 -0
  81. package/src/geohash-layer/geohash-layer.ts +4 -0
  82. package/src/geohash-layer/geohash-utils.ts +4 -0
  83. package/src/great-circle-layer/great-circle-layer.ts +4 -19
  84. package/src/h3-layers/h3-cluster-layer.ts +4 -0
  85. package/src/h3-layers/h3-hexagon-layer.ts +4 -0
  86. package/src/h3-layers/h3-utils.ts +4 -0
  87. package/src/index.ts +4 -19
  88. package/src/mesh-layer/mesh-layer-fragment.glsl.ts +9 -8
  89. package/src/mesh-layer/mesh-layer-uniforms.ts +24 -0
  90. package/src/mesh-layer/mesh-layer-vertex.glsl.ts +8 -9
  91. package/src/mesh-layer/mesh-layer.ts +37 -16
  92. package/src/mvt-layer/coordinate-transform.ts +4 -0
  93. package/src/mvt-layer/find-index-binary.ts +4 -0
  94. package/src/mvt-layer/mvt-layer.ts +4 -0
  95. package/src/quadkey-layer/quadkey-layer.ts +4 -0
  96. package/src/quadkey-layer/quadkey-utils.ts +4 -0
  97. package/src/s2-layer/s2-geometry.ts +4 -0
  98. package/src/s2-layer/s2-layer.ts +3 -19
  99. package/src/s2-layer/s2-utils.ts +4 -0
  100. package/src/terrain-layer/terrain-layer.ts +3 -19
  101. package/src/tile-3d-layer/tile-3d-layer.ts +4 -0
  102. package/src/tile-layer/tile-layer.ts +4 -0
  103. package/src/tileset-2d/index.ts +4 -0
  104. package/src/tileset-2d/memoize.ts +4 -0
  105. package/src/tileset-2d/tile-2d-header.ts +4 -0
  106. package/src/tileset-2d/tile-2d-traversal.ts +4 -0
  107. package/src/tileset-2d/tileset-2d.ts +4 -0
  108. package/src/tileset-2d/types.ts +4 -0
  109. package/src/tileset-2d/utils.ts +4 -0
  110. package/src/trips-layer/trips-layer-uniforms.ts +30 -0
  111. package/src/trips-layer/trips-layer.ts +12 -33
  112. package/src/wms-layer/utils.ts +4 -0
  113. package/src/wms-layer/wms-layer.ts +4 -0
package/dist.min.js CHANGED
@@ -4,57 +4,156 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['deck'] = factory();
6
6
  else root['deck'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var ng=Object.create;var Hr=Object.defineProperty;var sg=Object.getOwnPropertyDescriptor;var og=Object.getOwnPropertyNames;var ig=Object.getPrototypeOf,ag=Object.prototype.hasOwnProperty;var cg=(e,t,r)=>t in e?Hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var cl=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var tt=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),ut=(e,t)=>{for(var r in t)Hr(e,r,{get:t[r],enumerable:!0})},Kn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of og(t))!ag.call(e,s)&&s!==r&&Hr(e,s,{get:()=>t[s],enumerable:!(n=sg(t,s))||n.enumerable});return e},ue=(e,t,r)=>(Kn(e,t,"default"),r&&Kn(r,t,"default")),N=(e,t,r)=>(r=e!=null?ng(ig(e)):{},Kn(t||!e||!e.__esModule?Hr(r,"default",{value:e,enumerable:!0}):r,e)),lg=e=>Kn(Hr({},"__esModule",{value:!0}),e);var ar=(e,t,r)=>(cg(e,typeof t!="symbol"?t+"":t,r),r);var Ot=tt((tb,ll)=>{ll.exports=globalThis.deck});var Nt=tt((rb,fl)=>{fl.exports=globalThis.deck});var Zn=tt(te=>{"use strict";var hl=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",fg=hl+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",dl="["+hl+"]["+fg+"]*",hg=new RegExp("^"+dl+"$"),dg=function(e,t){let r=[],n=t.exec(e);for(;n;){let s=[];s.startIndex=t.lastIndex-n[0].length;let o=n.length;for(let i=0;i<o;i++)s.push(n[i]);r.push(s),n=t.exec(e)}return r},pg=function(e){let t=hg.exec(e);return!(t===null||typeof t>"u")};te.isExist=function(e){return typeof e<"u"};te.isEmptyObject=function(e){return Object.keys(e).length===0};te.merge=function(e,t,r){if(t){let n=Object.keys(t),s=n.length;for(let o=0;o<s;o++)r==="strict"?e[n[o]]=[t[n[o]]]:e[n[o]]=t[n[o]]}};te.getValue=function(e){return te.isExist(e)?e:""};te.isName=pg;te.getAllMatches=dg;te.nameRegexp=dl});var Xo=tt(xl=>{"use strict";var jo=Zn(),mg={allowBooleanAttributes:!1,unpairedTags:[]};xl.validate=function(e,t){t=Object.assign({},mg,t);let r=[],n=!1,s=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let o=0;o<e.length;o++)if(e[o]==="<"&&e[o+1]==="?"){if(o+=2,o=ml(e,o),o.err)return o}else if(e[o]==="<"){let i=o;if(o++,e[o]==="!"){o=gl(e,o);continue}else{let a=!1;e[o]==="/"&&(a=!0,o++);let c="";for(;o<e.length&&e[o]!==">"&&e[o]!==" "&&e[o]!==" "&&e[o]!==`
8
- `&&e[o]!=="\r";o++)c+=e[o];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),o--),!Bg(c)){let f;return c.trim().length===0?f="Invalid space after '<'.":f="Tag '"+c+"' is an invalid name.",st("InvalidTag",f,xt(e,o))}let l=xg(e,o);if(l===!1)return st("InvalidAttr","Attributes for '"+c+"' have open quote.",xt(e,o));let u=l.value;if(o=l.index,u[u.length-1]==="/"){let f=o-u.length;u=u.substring(0,u.length-1);let h=Al(u,t);if(h===!0)n=!0;else return st(h.err.code,h.err.msg,xt(e,f+h.err.line))}else if(a)if(l.tagClosed){if(u.trim().length>0)return st("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",xt(e,i));{let f=r.pop();if(c!==f.tagName){let h=xt(e,f.tagStartPos);return st("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+h.line+", col "+h.col+") instead of closing tag '"+c+"'.",xt(e,i))}r.length==0&&(s=!0)}}else return st("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",xt(e,o));else{let f=Al(u,t);if(f!==!0)return st(f.err.code,f.err.msg,xt(e,o-u.length+f.err.line));if(s===!0)return st("InvalidXml","Multiple possible root nodes found.",xt(e,o));t.unpairedTags.indexOf(c)!==-1||r.push({tagName:c,tagStartPos:i}),n=!0}for(o++;o<e.length;o++)if(e[o]==="<")if(e[o+1]==="!"){o++,o=gl(e,o);continue}else if(e[o+1]==="?"){if(o=ml(e,++o),o.err)return o}else break;else if(e[o]==="&"){let f=_g(e,o);if(f==-1)return st("InvalidChar","char '&' is not expected.",xt(e,o));o=f}else if(s===!0&&!pl(e[o]))return st("InvalidXml","Extra text at the end",xt(e,o));e[o]==="<"&&o--}}else{if(pl(e[o]))continue;return st("InvalidChar","char '"+e[o]+"' is not expected.",xt(e,o))}if(n){if(r.length==1)return st("InvalidTag","Unclosed tag '"+r[0].tagName+"'.",xt(e,r[0].tagStartPos));if(r.length>0)return st("InvalidXml","Invalid '"+JSON.stringify(r.map(o=>o.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return st("InvalidXml","Start tag expected.",1);return!0};function pl(e){return e===" "||e===" "||e===`
9
- `||e==="\r"}function ml(e,t){let r=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let n=e.substr(r,t-r);if(t>5&&n==="xml")return st("InvalidXml","XML declaration allowed only at the start of the document.",xt(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function gl(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let r=1;for(t+=8;t<e.length;t++)if(e[t]==="<")r++;else if(e[t]===">"&&(r--,r===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var gg='"',Ag="'";function xg(e,t){let r="",n="",s=!1;for(;t<e.length;t++){if(e[t]===gg||e[t]===Ag)n===""?n=e[t]:n!==e[t]||(n="");else if(e[t]===">"&&n===""){s=!0;break}r+=e[t]}return n!==""?!1:{value:r,index:t,tagClosed:s}}var yg=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Al(e,t){let r=jo.getAllMatches(e,yg),n={};for(let s=0;s<r.length;s++){if(r[s][1].length===0)return st("InvalidAttr","Attribute '"+r[s][2]+"' has no space in starting.",zr(r[s]));if(r[s][3]!==void 0&&r[s][4]===void 0)return st("InvalidAttr","Attribute '"+r[s][2]+"' is without value.",zr(r[s]));if(r[s][3]===void 0&&!t.allowBooleanAttributes)return st("InvalidAttr","boolean attribute '"+r[s][2]+"' is not allowed.",zr(r[s]));let o=r[s][2];if(!Eg(o))return st("InvalidAttr","Attribute '"+o+"' is an invalid name.",zr(r[s]));if(!n.hasOwnProperty(o))n[o]=1;else return st("InvalidAttr","Attribute '"+o+"' is repeated.",zr(r[s]))}return!0}function Tg(e,t){let r=/\d/;for(e[t]==="x"&&(t++,r=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(r))break}return-1}function _g(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,Tg(e,t);let r=0;for(;t<e.length;t++,r++)if(!(e[t].match(/\w/)&&r<20)){if(e[t]===";")break;return-1}return t}function st(e,t,r){return{err:{code:e,msg:t,line:r.line||r,col:r.col}}}function Eg(e){return jo.isName(e)}function Bg(e){return jo.isName(e)}function xt(e,t){let r=e.substring(0,t).split(/\r?\n/);return{line:r.length,col:r[r.length-1].length+1}}function zr(e){return e.startIndex+e[1].length}});var Tl=tt(Wo=>{var yl={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,r){return e}},Cg=function(e){return Object.assign({},yl,e)};Wo.buildOptions=Cg;Wo.defaultOptions=yl});var El=tt((ab,_l)=>{"use strict";var Yo=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,r){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:r})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,[":@"]:t[":@"]}):this.child.push({[t.tagname]:t.child})}};_l.exports=Yo});var Cl=tt((cb,Bl)=>{var Sg=Zn();function bg(e,t){let r={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let n=1,s=!1,o=!1,i="";for(;t<e.length;t++)if(e[t]==="<"&&!o){if(s&&wg(e,t))t+=7,[entityName,val,t]=Mg(e,t+1),val.indexOf("&")===-1&&(r[Pg(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(s&&Lg(e,t))t+=8;else if(s&&Fg(e,t))t+=8;else if(s&&Rg(e,t))t+=9;else if(Ig)o=!0;else throw new Error("Invalid DOCTYPE");n++,i=""}else if(e[t]===">"){if(o?e[t-1]==="-"&&e[t-2]==="-"&&(o=!1,n--):n--,n===0)break}else e[t]==="["?s=!0:i+=e[t];if(n!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:r,i:t}}function Mg(e,t){let r="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)r+=e[t];if(r=r.trim(),r.indexOf(" ")!==-1)throw new Error("External entites are not supported");let n=e[t++],s="";for(;t<e.length&&e[t]!==n;t++)s+=e[t];return[r,s,t]}function Ig(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function wg(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function Lg(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function Fg(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function Rg(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function Pg(e){if(Sg.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}Bl.exports=bg});var bl=tt((lb,Sl)=>{var Og=/^[-+]?0x[a-fA-F0-9]+$/,Ng=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var Dg={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function vg(e,t={}){if(t=Object.assign({},Dg,t),!e||typeof e!="string")return e;let r=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(r))return e;if(t.hex&&Og.test(r))return Number.parseInt(r,16);{let n=Ng.exec(r);if(n){let s=n[1],o=n[2],i=Ug(n[3]),a=n[4]||n[6];if(!t.leadingZeros&&o.length>0&&s&&r[2]!==".")return e;if(!t.leadingZeros&&o.length>0&&!s&&r[1]!==".")return e;{let c=Number(r),l=""+c;return l.search(/[eE]/)!==-1||a?t.eNotation?c:e:r.indexOf(".")!==-1?l==="0"&&i===""||l===i||s&&l==="-"+i?c:e:o?i===l||s+i===l?c:e:r===l||r===s+l?c:e}}else return e}}function Ug(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substr(0,e.length-1))),e}Sl.exports=vg});var wl=tt((ub,Il)=>{"use strict";var Ml=Zn(),kr=El(),Gg=Cl(),Vg=bl(),Ko=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(r,n)=>String.fromCharCode(Number.parseInt(n,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(r,n)=>String.fromCharCode(Number.parseInt(n,16))}},this.addExternalEntities=Hg,this.parseXml=jg,this.parseTextData=zg,this.resolveNameSpace=kg,this.buildAttributesMap=qg,this.isItStopNode=Kg,this.replaceEntitiesValue=Wg,this.readStopNodeData=Zg,this.saveTextToParentTag=Yg,this.addChild=Xg}};function Hg(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];this.lastEntities[n]={regex:new RegExp("&"+n+";","g"),val:e[n]}}}function zg(e,t,r,n,s,o,i){if(e!==void 0&&(this.options.trimValues&&!n&&(e=e.trim()),e.length>0)){i||(e=this.replaceEntitiesValue(e));let a=this.options.tagValueProcessor(t,e,r,s,o);return a==null?e:typeof a!=typeof e||a!==e?a:this.options.trimValues?Zo(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?Zo(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function kg(e){if(this.options.removeNSPrefix){let t=e.split(":"),r=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=r+t[1])}return e}var Jg=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function qg(e,t,r){if(!this.options.ignoreAttributes&&typeof e=="string"){let n=Ml.getAllMatches(e,Jg),s=n.length,o={};for(let i=0;i<s;i++){let a=this.resolveNameSpace(n[i][1]),c=n[i][4],l=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(l=this.options.transformAttributeName(l)),l==="__proto__"&&(l="#__proto__"),c!==void 0){this.options.trimValues&&(c=c.trim()),c=this.replaceEntitiesValue(c);let u=this.options.attributeValueProcessor(a,c,t);u==null?o[l]=c:typeof u!=typeof c||u!==c?o[l]=u:o[l]=Zo(c,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(o[l]=!0)}if(!Object.keys(o).length)return;if(this.options.attributesGroupName){let i={};return i[this.options.attributesGroupName]=o,i}return o}}var jg=function(e){e=e.replace(/\r\n?/g,`
10
- `);let t=new kr("!xml"),r=t,n="",s="";for(let o=0;o<e.length;o++)if(e[o]==="<")if(e[o+1]==="/"){let a=Le(e,">",o,"Closing Tag is not closed."),c=e.substring(o+2,a).trim();if(this.options.removeNSPrefix){let f=c.indexOf(":");f!==-1&&(c=c.substr(f+1))}this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&(n=this.saveTextToParentTag(n,r,s));let l=s.substring(s.lastIndexOf(".")+1);if(c&&this.options.unpairedTags.indexOf(c)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${c}>`);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=s.lastIndexOf("."),s=s.substring(0,u),r=this.tagsNodeStack.pop(),n="",o=a}else if(e[o+1]==="?"){let a=Qo(e,o,!1,"?>");if(!a)throw new Error("Pi Tag is not closed.");if(n=this.saveTextToParentTag(n,r,s),!(this.options.ignoreDeclaration&&a.tagName==="?xml"||this.options.ignorePiTags)){let c=new kr(a.tagName);c.add(this.options.textNodeName,""),a.tagName!==a.tagExp&&a.attrExpPresent&&(c[":@"]=this.buildAttributesMap(a.tagExp,s,a.tagName)),this.addChild(r,c,s)}o=a.closeIndex+1}else if(e.substr(o+1,3)==="!--"){let a=Le(e,"-->",o+4,"Comment is not closed.");if(this.options.commentPropName){let c=e.substring(o+4,a-2);n=this.saveTextToParentTag(n,r,s),r.add(this.options.commentPropName,[{[this.options.textNodeName]:c}])}o=a}else if(e.substr(o+1,2)==="!D"){let a=Gg(e,o);this.docTypeEntities=a.entities,o=a.i}else if(e.substr(o+1,2)==="!["){let a=Le(e,"]]>",o,"CDATA is not closed.")-2,c=e.substring(o+9,a);n=this.saveTextToParentTag(n,r,s);let l=this.parseTextData(c,r.tagname,s,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?r.add(this.options.cdataPropName,[{[this.options.textNodeName]:c}]):r.add(this.options.textNodeName,l),o=a+2}else{let a=Qo(e,o,this.options.removeNSPrefix),c=a.tagName,l=a.rawTagName,u=a.tagExp,f=a.attrExpPresent,h=a.closeIndex;this.options.transformTagName&&(c=this.options.transformTagName(c)),r&&n&&r.tagname!=="!xml"&&(n=this.saveTextToParentTag(n,r,s,!1));let d=r;if(d&&this.options.unpairedTags.indexOf(d.tagname)!==-1&&(r=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),c!==t.tagname&&(s+=s?"."+c:c),this.isItStopNode(this.options.stopNodes,s,c)){let p="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)o=a.closeIndex;else if(this.options.unpairedTags.indexOf(c)!==-1)o=a.closeIndex;else{let g=this.readStopNodeData(e,l,h+1);if(!g)throw new Error(`Unexpected end of ${l}`);o=g.i,p=g.tagContent}let A=new kr(c);c!==u&&f&&(A[":@"]=this.buildAttributesMap(u,s,c)),p&&(p=this.parseTextData(p,c,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),A.add(this.options.textNodeName,p),this.addChild(r,A,s)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){c[c.length-1]==="/"?(c=c.substr(0,c.length-1),s=s.substr(0,s.length-1),u=c):u=u.substr(0,u.length-1),this.options.transformTagName&&(c=this.options.transformTagName(c));let p=new kr(c);c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(r,p,s),s=s.substr(0,s.lastIndexOf("."))}else{let p=new kr(c);this.tagsNodeStack.push(r),c!==u&&f&&(p[":@"]=this.buildAttributesMap(u,s,c)),this.addChild(r,p,s),r=p}n="",o=h}}else n+=e[o];return t.child};function Xg(e,t,r){let n=this.options.updateTag(t.tagname,r,t[":@"]);n===!1||(typeof n=="string"&&(t.tagname=n),e.addChild(t))}var Wg=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let r=this.docTypeEntities[t];e=e.replace(r.regx,r.val)}for(let t in this.lastEntities){let r=this.lastEntities[t];e=e.replace(r.regex,r.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let r=this.htmlEntities[t];e=e.replace(r.regex,r.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function Yg(e,t,r,n){return e&&(n===void 0&&(n=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,r,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,n),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function Kg(e,t,r){let n="*."+r;for(let s in e){let o=e[s];if(n===o||t===o)return!0}return!1}function Qg(e,t,r=">"){let n,s="";for(let o=t;o<e.length;o++){let i=e[o];if(n)i===n&&(n="");else if(i==='"'||i==="'")n=i;else if(i===r[0])if(r[1]){if(e[o+1]===r[1])return{data:s,index:o}}else return{data:s,index:o};else i===" "&&(i=" ");s+=i}}function Le(e,t,r,n){let s=e.indexOf(t,r);if(s===-1)throw new Error(n);return s+t.length-1}function Qo(e,t,r,n=">"){let s=Qg(e,t+1,n);if(!s)return;let o=s.data,i=s.index,a=o.search(/\s/),c=o,l=!0;a!==-1&&(c=o.substring(0,a),o=o.substring(a+1).trimStart());let u=c;if(r){let f=c.indexOf(":");f!==-1&&(c=c.substr(f+1),l=c!==s.data.substr(f+1))}return{tagName:c,tagExp:o,closeIndex:i,attrExpPresent:l,rawTagName:u}}function Zg(e,t,r){let n=r,s=1;for(;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="/"){let o=Le(e,">",r,`${t} is not closed`);if(e.substring(r+2,o).trim()===t&&(s--,s===0))return{tagContent:e.substring(n,r),i:o};r=o}else if(e[r+1]==="?")r=Le(e,"?>",r+1,"StopNode is not closed.");else if(e.substr(r+1,3)==="!--")r=Le(e,"-->",r+3,"StopNode is not closed.");else if(e.substr(r+1,2)==="![")r=Le(e,"]]>",r,"StopNode is not closed.")-2;else{let o=Qo(e,r,">");o&&((o&&o.tagName)===t&&o.tagExp[o.tagExp.length-1]!=="/"&&s++,r=o.closeIndex)}}function Zo(e,t,r){if(t&&typeof e=="string"){let n=e.trim();return n==="true"?!0:n==="false"?!1:Vg(e,r)}else return Ml.isExist(e)?e:""}Il.exports=Ko});var Rl=tt(Fl=>{"use strict";function $g(e,t){return Ll(e,t)}function Ll(e,t,r){let n,s={};for(let o=0;o<e.length;o++){let i=e[o],a=t0(i),c="";if(r===void 0?c=a:c=r+"."+a,a===t.textNodeName)n===void 0?n=i[a]:n+=""+i[a];else{if(a===void 0)continue;if(i[a]){let l=Ll(i[a],t,c),u=r0(l,t);i[":@"]?e0(l,i[":@"],c,t):Object.keys(l).length===1&&l[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?l=l[t.textNodeName]:Object.keys(l).length===0&&(t.alwaysCreateTextNode?l[t.textNodeName]="":l=""),s[a]!==void 0&&s.hasOwnProperty(a)?(Array.isArray(s[a])||(s[a]=[s[a]]),s[a].push(l)):t.isArray(a,c,u)?s[a]=[l]:s[a]=l}}}return typeof n=="string"?n.length>0&&(s[t.textNodeName]=n):n!==void 0&&(s[t.textNodeName]=n),s}function t0(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(n!==":@")return n}}function e0(e,t,r,n){if(t){let s=Object.keys(t),o=s.length;for(let i=0;i<o;i++){let a=s[i];n.isArray(a,r+"."+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function r0(e,t){let{textNodeName:r}=t,n=Object.keys(e).length;return!!(n===0||n===1&&(e[r]||typeof e[r]=="boolean"||e[r]===0))}Fl.prettify=$g});var Ol=tt((hb,Pl)=>{var{buildOptions:n0}=Tl(),s0=wl(),{prettify:o0}=Rl(),i0=Xo(),$o=class{constructor(t){this.externalEntities={},this.options=n0(t)}parse(t,r){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(r){r===!0&&(r={});let o=i0.validate(t,r);if(o!==!0)throw Error(`${o.err.msg}:${o.err.line}:${o.err.col}`)}let n=new s0(this.options);n.addExternalEntities(this.externalEntities);let s=n.parseXml(t);return this.options.preserveOrder||s===void 0?s:o0(s,this.options)}addEntity(t,r){if(r.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(r==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=r}};Pl.exports=$o});var Gl=tt((db,Ul)=>{var a0=`
11
- `;function c0(e,t){let r="";return t.format&&t.indentBy.length>0&&(r=a0),Dl(e,t,"",r)}function Dl(e,t,r,n){let s="",o=!1;for(let i=0;i<e.length;i++){let a=e[i],c=l0(a);if(c===void 0)continue;let l="";if(r.length===0?l=c:l=`${r}.${c}`,c===t.textNodeName){let p=a[c];u0(l,t)||(p=t.tagValueProcessor(c,p),p=vl(p,t)),o&&(s+=n),s+=p,o=!1;continue}else if(c===t.cdataPropName){o&&(s+=n),s+=`<![CDATA[${a[c][0][t.textNodeName]}]]>`,o=!1;continue}else if(c===t.commentPropName){s+=n+`<!--${a[c][0][t.textNodeName]}-->`,o=!0;continue}else if(c[0]==="?"){let p=Nl(a[":@"],t),A=c==="?xml"?"":n,g=a[c][0][t.textNodeName];g=g.length!==0?" "+g:"",s+=A+`<${c}${g}${p}?>`,o=!0;continue}let u=n;u!==""&&(u+=t.indentBy);let f=Nl(a[":@"],t),h=n+`<${c}${f}`,d=Dl(a[c],t,l,u);t.unpairedTags.indexOf(c)!==-1?t.suppressUnpairedNode?s+=h+">":s+=h+"/>":(!d||d.length===0)&&t.suppressEmptyNode?s+=h+"/>":d&&d.endsWith(">")?s+=h+`>${d}${n}</${c}>`:(s+=h+">",d&&n!==""&&(d.includes("/>")||d.includes("</"))?s+=n+t.indentBy+d+n:s+=d,s+=`</${c}>`),o=!0}return s}function l0(e){let t=Object.keys(e);for(let r=0;r<t.length;r++){let n=t[r];if(e.hasOwnProperty(n)&&n!==":@")return n}}function Nl(e,t){let r="";if(e&&!t.ignoreAttributes)for(let n in e){if(!e.hasOwnProperty(n))continue;let s=t.attributeValueProcessor(n,e[n]);s=vl(s,t),s===!0&&t.suppressBooleanAttributes?r+=` ${n.substr(t.attributeNamePrefix.length)}`:r+=` ${n.substr(t.attributeNamePrefix.length)}="${s}"`}return r}function u0(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let r=e.substr(e.lastIndexOf(".")+1);for(let n in t.stopNodes)if(t.stopNodes[n]===e||t.stopNodes[n]==="*."+r)return!0;return!1}function vl(e,t){if(e&&e.length>0&&t.processEntities)for(let r=0;r<t.entities.length;r++){let n=t.entities[r];e=e.replace(n.regex,n.val)}return e}Ul.exports=c0});var Hl=tt((pb,Vl)=>{"use strict";var f0=Gl(),h0={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function fe(e){this.options=Object.assign({},h0,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=m0),this.processTextOrObjNode=d0,this.options.format?(this.indentate=p0,this.tagEndChar=`>
7
+ "use strict";var __exports__=(()=>{var S3=Object.create;var ps=Object.defineProperty;var B3=Object.getOwnPropertyDescriptor;var C3=Object.getOwnPropertyNames;var L3=Object.getPrototypeOf,R3=Object.prototype.hasOwnProperty;var w3=(e,t,n)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var K0=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var it=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),At=(e,t)=>{for(var n in t)ps(e,n,{get:t[n],enumerable:!0})},Ri=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of C3(t))!R3.call(e,s)&&s!==n&&ps(e,s,{get:()=>t[s],enumerable:!(r=B3(t,s))||r.enumerable});return e},We=(e,t,n)=>(Ri(e,t,"default"),n&&Ri(n,t,"default")),D=(e,t,n)=>(n=e!=null?S3(L3(e)):{},Ri(t||!e||!e.__esModule?ps(n,"default",{value:e,enumerable:!0}):n,e)),I3=e=>Ri(ps({},"__esModule",{value:!0}),e);var sr=(e,t,n)=>(w3(e,typeof t!="symbol"?t+"":t,n),n);var ee=it((EF,Z0)=>{Z0.exports=globalThis.deck});var ne=it((_F,$0)=>{$0.exports=globalThis.deck});var Ii=it(we=>{"use strict";var t1=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",O3=t1+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",e1="["+t1+"]["+O3+"]*",P3=new RegExp("^"+e1+"$"),N3=function(e,t){let n=[],r=t.exec(e);for(;r;){let s=[];s.startIndex=t.lastIndex-r[0].length;let i=r.length;for(let o=0;o<i;o++)s.push(r[o]);n.push(s),r=t.exec(e)}return n},F3=function(e){let t=P3.exec(e);return!(t===null||typeof t>"u")};we.isExist=function(e){return typeof e<"u"};we.isEmptyObject=function(e){return Object.keys(e).length===0};we.merge=function(e,t,n){if(t){let r=Object.keys(t),s=r.length;for(let i=0;i<s;i++)n==="strict"?e[r[i]]=[t[r[i]]]:e[r[i]]=t[r[i]]}};we.getValue=function(e){return we.isExist(e)?e:""};we.isName=F3;we.getAllMatches=N3;we.nameRegexp=e1});var Ma=it(o1=>{"use strict";var xa=Ii(),v3={allowBooleanAttributes:!1,unpairedTags:[]};o1.validate=function(e,t){t=Object.assign({},v3,t);let n=[],r=!1,s=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let i=0;i<e.length;i++)if(e[i]==="<"&&e[i+1]==="?"){if(i+=2,i=r1(e,i),i.err)return i}else if(e[i]==="<"){let o=i;if(i++,e[i]==="!"){i=s1(e,i);continue}else{let c=!1;e[i]==="/"&&(c=!0,i++);let a="";for(;i<e.length&&e[i]!==">"&&e[i]!==" "&&e[i]!==" "&&e[i]!==`
8
+ `&&e[i]!=="\r";i++)a+=e[i];if(a=a.trim(),a[a.length-1]==="/"&&(a=a.substring(0,a.length-1),i--),!H3(a)){let f;return a.trim().length===0?f="Invalid space after '<'.":f="Tag '"+a+"' is an invalid name.",ft("InvalidTag",f,vt(e,i))}let h=G3(e,i);if(h===!1)return ft("InvalidAttr","Attributes for '"+a+"' have open quote.",vt(e,i));let l=h.value;if(i=h.index,l[l.length-1]==="/"){let f=i-l.length;l=l.substring(0,l.length-1);let p=i1(l,t);if(p===!0)r=!0;else return ft(p.err.code,p.err.msg,vt(e,f+p.err.line))}else if(c)if(h.tagClosed){if(l.trim().length>0)return ft("InvalidTag","Closing tag '"+a+"' can't have attributes or invalid starting.",vt(e,o));if(n.length===0)return ft("InvalidTag","Closing tag '"+a+"' has not been opened.",vt(e,o));{let f=n.pop();if(a!==f.tagName){let p=vt(e,f.tagStartPos);return ft("InvalidTag","Expected closing tag '"+f.tagName+"' (opened in line "+p.line+", col "+p.col+") instead of closing tag '"+a+"'.",vt(e,o))}n.length==0&&(s=!0)}}else return ft("InvalidTag","Closing tag '"+a+"' doesn't have proper closing.",vt(e,i));else{let f=i1(l,t);if(f!==!0)return ft(f.err.code,f.err.msg,vt(e,i-l.length+f.err.line));if(s===!0)return ft("InvalidXml","Multiple possible root nodes found.",vt(e,i));t.unpairedTags.indexOf(a)!==-1||n.push({tagName:a,tagStartPos:o}),r=!0}for(i++;i<e.length;i++)if(e[i]==="<")if(e[i+1]==="!"){i++,i=s1(e,i);continue}else if(e[i+1]==="?"){if(i=r1(e,++i),i.err)return i}else break;else if(e[i]==="&"){let f=V3(e,i);if(f==-1)return ft("InvalidChar","char '&' is not expected.",vt(e,i));i=f}else if(s===!0&&!n1(e[i]))return ft("InvalidXml","Extra text at the end",vt(e,i));e[i]==="<"&&i--}}else{if(n1(e[i]))continue;return ft("InvalidChar","char '"+e[i]+"' is not expected.",vt(e,i))}if(r){if(n.length==1)return ft("InvalidTag","Unclosed tag '"+n[0].tagName+"'.",vt(e,n[0].tagStartPos));if(n.length>0)return ft("InvalidXml","Invalid '"+JSON.stringify(n.map(i=>i.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return ft("InvalidXml","Start tag expected.",1);return!0};function n1(e){return e===" "||e===" "||e===`
9
+ `||e==="\r"}function r1(e,t){let n=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let r=e.substr(n,t-n);if(t>5&&r==="xml")return ft("InvalidXml","XML declaration allowed only at the start of the document.",vt(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function s1(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let n=1;for(t+=8;t<e.length;t++)if(e[t]==="<")n++;else if(e[t]===">"&&(n--,n===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var D3='"',U3="'";function G3(e,t){let n="",r="",s=!1;for(;t<e.length;t++){if(e[t]===D3||e[t]===U3)r===""?r=e[t]:r!==e[t]||(r="");else if(e[t]===">"&&r===""){s=!0;break}n+=e[t]}return r!==""?!1:{value:n,index:t,tagClosed:s}}var z3=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function i1(e,t){let n=xa.getAllMatches(e,z3),r={};for(let s=0;s<n.length;s++){if(n[s][1].length===0)return ft("InvalidAttr","Attribute '"+n[s][2]+"' has no space in starting.",us(n[s]));if(n[s][3]!==void 0&&n[s][4]===void 0)return ft("InvalidAttr","Attribute '"+n[s][2]+"' is without value.",us(n[s]));if(n[s][3]===void 0&&!t.allowBooleanAttributes)return ft("InvalidAttr","boolean attribute '"+n[s][2]+"' is not allowed.",us(n[s]));let i=n[s][2];if(!q3(i))return ft("InvalidAttr","Attribute '"+i+"' is an invalid name.",us(n[s]));if(!r.hasOwnProperty(i))r[i]=1;else return ft("InvalidAttr","Attribute '"+i+"' is repeated.",us(n[s]))}return!0}function k3(e,t){let n=/\d/;for(e[t]==="x"&&(t++,n=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(n))break}return-1}function V3(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,k3(e,t);let n=0;for(;t<e.length;t++,n++)if(!(e[t].match(/\w/)&&n<20)){if(e[t]===";")break;return-1}return t}function ft(e,t,n){return{err:{code:e,msg:t,line:n.line||n,col:n.col}}}function q3(e){return xa.isName(e)}function H3(e){return xa.isName(e)}function vt(e,t){let n=e.substring(0,t).split(/\r?\n/);return{line:n.length,col:n[n.length-1].length+1}}function us(e){return e.startIndex+e[1].length}});var a1=it(Aa=>{var c1={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,n){return e}},Y3=function(e){return Object.assign({},c1,e)};Aa.buildOptions=Y3;Aa.defaultOptions=c1});var l1=it((RF,h1)=>{"use strict";var ya=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,n){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:n})}addChild(t){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,[":@"]:t[":@"]}):this.child.push({[t.tagname]:t.child})}};h1.exports=ya});var p1=it((wF,f1)=>{var W3=Ii();function J3(e,t){let n={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,s=!1,i=!1,o="";for(;t<e.length;t++)if(e[t]==="<"&&!i){if(s&&K3(e,t))t+=7,[entityName,val,t]=X3(e,t+1),val.indexOf("&")===-1&&(n[tE(entityName)]={regx:RegExp(`&${entityName};`,"g"),val});else if(s&&Z3(e,t))t+=8;else if(s&&Q3(e,t))t+=8;else if(s&&$3(e,t))t+=9;else if(j3)i=!0;else throw new Error("Invalid DOCTYPE");r++,o=""}else if(e[t]===">"){if(i?e[t-1]==="-"&&e[t-2]==="-"&&(i=!1,r--):r--,r===0)break}else e[t]==="["?s=!0:o+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:n,i:t}}function X3(e,t){let n="";for(;t<e.length&&e[t]!=="'"&&e[t]!=='"';t++)n+=e[t];if(n=n.trim(),n.indexOf(" ")!==-1)throw new Error("External entites are not supported");let r=e[t++],s="";for(;t<e.length&&e[t]!==r;t++)s+=e[t];return[n,s,t]}function j3(e,t){return e[t+1]==="!"&&e[t+2]==="-"&&e[t+3]==="-"}function K3(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="N"&&e[t+4]==="T"&&e[t+5]==="I"&&e[t+6]==="T"&&e[t+7]==="Y"}function Z3(e,t){return e[t+1]==="!"&&e[t+2]==="E"&&e[t+3]==="L"&&e[t+4]==="E"&&e[t+5]==="M"&&e[t+6]==="E"&&e[t+7]==="N"&&e[t+8]==="T"}function Q3(e,t){return e[t+1]==="!"&&e[t+2]==="A"&&e[t+3]==="T"&&e[t+4]==="T"&&e[t+5]==="L"&&e[t+6]==="I"&&e[t+7]==="S"&&e[t+8]==="T"}function $3(e,t){return e[t+1]==="!"&&e[t+2]==="N"&&e[t+3]==="O"&&e[t+4]==="T"&&e[t+5]==="A"&&e[t+6]==="T"&&e[t+7]==="I"&&e[t+8]==="O"&&e[t+9]==="N"}function tE(e){if(W3.isName(e))return e;throw new Error(`Invalid entity name ${e}`)}f1.exports=J3});var d1=it((IF,u1)=>{var eE=/^[-+]?0x[a-fA-F0-9]+$/,nE=/^([\-\+])?(0*)(\.[0-9]+([eE]\-?[0-9]+)?|[0-9]+(\.[0-9]+([eE]\-?[0-9]+)?)?)$/;!Number.parseInt&&window.parseInt&&(Number.parseInt=window.parseInt);!Number.parseFloat&&window.parseFloat&&(Number.parseFloat=window.parseFloat);var rE={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function sE(e,t={}){if(t=Object.assign({},rE,t),!e||typeof e!="string")return e;let n=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(n))return e;if(t.hex&&eE.test(n))return Number.parseInt(n,16);{let r=nE.exec(n);if(r){let s=r[1],i=r[2],o=iE(r[3]),c=r[4]||r[6];if(!t.leadingZeros&&i.length>0&&s&&n[2]!==".")return e;if(!t.leadingZeros&&i.length>0&&!s&&n[1]!==".")return e;{let a=Number(n),h=""+a;return h.search(/[eE]/)!==-1||c?t.eNotation?a:e:n.indexOf(".")!==-1?h==="0"&&o===""||h===o||s&&h==="-"+o?a:e:i?o===h||s+o===h?a:e:n===h||n===s+h?a:e}}else return e}}function iE(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substr(0,e.length-1))),e}u1.exports=sE});var x1=it((bF,g1)=>{"use strict";var m1=Ii(),ds=l1(),oE=p1(),cE=d1(),Ea=class{constructor(t){this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,10))},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(n,r)=>String.fromCharCode(Number.parseInt(r,16))}},this.addExternalEntities=aE,this.parseXml=uE,this.parseTextData=hE,this.resolveNameSpace=lE,this.buildAttributesMap=pE,this.isItStopNode=xE,this.replaceEntitiesValue=mE,this.readStopNodeData=AE,this.saveTextToParentTag=gE,this.addChild=dE}};function aE(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];this.lastEntities[r]={regex:new RegExp("&"+r+";","g"),val:e[r]}}}function hE(e,t,n,r,s,i,o){if(e!==void 0&&(this.options.trimValues&&!r&&(e=e.trim()),e.length>0)){o||(e=this.replaceEntitiesValue(e));let c=this.options.tagValueProcessor(t,e,n,s,i);return c==null?e:typeof c!=typeof e||c!==e?c:this.options.trimValues?_a(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?_a(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function lE(e){if(this.options.removeNSPrefix){let t=e.split(":"),n=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=n+t[1])}return e}var fE=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function pE(e,t,n){if(!this.options.ignoreAttributes&&typeof e=="string"){let r=m1.getAllMatches(e,fE),s=r.length,i={};for(let o=0;o<s;o++){let c=this.resolveNameSpace(r[o][1]),a=r[o][4],h=this.options.attributeNamePrefix+c;if(c.length)if(this.options.transformAttributeName&&(h=this.options.transformAttributeName(h)),h==="__proto__"&&(h="#__proto__"),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a);let l=this.options.attributeValueProcessor(c,a,t);l==null?i[h]=a:typeof l!=typeof a||l!==a?i[h]=l:i[h]=_a(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(i[h]=!0)}if(!Object.keys(i).length)return;if(this.options.attributesGroupName){let o={};return o[this.options.attributesGroupName]=i,o}return i}}var uE=function(e){e=e.replace(/\r\n?/g,`
10
+ `);let t=new ds("!xml"),n=t,r="",s="";for(let i=0;i<e.length;i++)if(e[i]==="<")if(e[i+1]==="/"){let c=Bn(e,">",i,"Closing Tag is not closed."),a=e.substring(i+2,c).trim();if(this.options.removeNSPrefix){let f=a.indexOf(":");f!==-1&&(a=a.substr(f+1))}this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&(r=this.saveTextToParentTag(r,n,s));let h=s.substring(s.lastIndexOf(".")+1);if(a&&this.options.unpairedTags.indexOf(a)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${a}>`);let l=0;h&&this.options.unpairedTags.indexOf(h)!==-1?(l=s.lastIndexOf(".",s.lastIndexOf(".")-1),this.tagsNodeStack.pop()):l=s.lastIndexOf("."),s=s.substring(0,l),n=this.tagsNodeStack.pop(),r="",i=c}else if(e[i+1]==="?"){let c=Ta(e,i,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(r=this.saveTextToParentTag(r,n,s),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){let a=new ds(c.tagName);a.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(a[":@"]=this.buildAttributesMap(c.tagExp,s,c.tagName)),this.addChild(n,a,s)}i=c.closeIndex+1}else if(e.substr(i+1,3)==="!--"){let c=Bn(e,"-->",i+4,"Comment is not closed.");if(this.options.commentPropName){let a=e.substring(i+4,c-2);r=this.saveTextToParentTag(r,n,s),n.add(this.options.commentPropName,[{[this.options.textNodeName]:a}])}i=c}else if(e.substr(i+1,2)==="!D"){let c=oE(e,i);this.docTypeEntities=c.entities,i=c.i}else if(e.substr(i+1,2)==="!["){let c=Bn(e,"]]>",i,"CDATA is not closed.")-2,a=e.substring(i+9,c);r=this.saveTextToParentTag(r,n,s);let h=this.parseTextData(a,n.tagname,s,!0,!1,!0,!0);h==null&&(h=""),this.options.cdataPropName?n.add(this.options.cdataPropName,[{[this.options.textNodeName]:a}]):n.add(this.options.textNodeName,h),i=c+2}else{let c=Ta(e,i,this.options.removeNSPrefix),a=c.tagName,h=c.rawTagName,l=c.tagExp,f=c.attrExpPresent,p=c.closeIndex;this.options.transformTagName&&(a=this.options.transformTagName(a)),n&&r&&n.tagname!=="!xml"&&(r=this.saveTextToParentTag(r,n,s,!1));let u=n;if(u&&this.options.unpairedTags.indexOf(u.tagname)!==-1&&(n=this.tagsNodeStack.pop(),s=s.substring(0,s.lastIndexOf("."))),a!==t.tagname&&(s+=s?"."+a:a),this.isItStopNode(this.options.stopNodes,s,a)){let d="";if(l.length>0&&l.lastIndexOf("/")===l.length-1)a[a.length-1]==="/"?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),l=a):l=l.substr(0,l.length-1),i=c.closeIndex;else if(this.options.unpairedTags.indexOf(a)!==-1)i=c.closeIndex;else{let m=this.readStopNodeData(e,h,p+1);if(!m)throw new Error(`Unexpected end of ${h}`);i=m.i,d=m.tagContent}let g=new ds(a);a!==l&&f&&(g[":@"]=this.buildAttributesMap(l,s,a)),d&&(d=this.parseTextData(d,a,s,!0,f,!0,!0)),s=s.substr(0,s.lastIndexOf(".")),g.add(this.options.textNodeName,d),this.addChild(n,g,s)}else{if(l.length>0&&l.lastIndexOf("/")===l.length-1){a[a.length-1]==="/"?(a=a.substr(0,a.length-1),s=s.substr(0,s.length-1),l=a):l=l.substr(0,l.length-1),this.options.transformTagName&&(a=this.options.transformTagName(a));let d=new ds(a);a!==l&&f&&(d[":@"]=this.buildAttributesMap(l,s,a)),this.addChild(n,d,s),s=s.substr(0,s.lastIndexOf("."))}else{let d=new ds(a);this.tagsNodeStack.push(n),a!==l&&f&&(d[":@"]=this.buildAttributesMap(l,s,a)),this.addChild(n,d,s),n=d}r="",i=p}}else r+=e[i];return t.child};function dE(e,t,n){let r=this.options.updateTag(t.tagname,n,t[":@"]);r===!1||(typeof r=="string"&&(t.tagname=r),e.addChild(t))}var mE=function(e){if(this.options.processEntities){for(let t in this.docTypeEntities){let n=this.docTypeEntities[t];e=e.replace(n.regx,n.val)}for(let t in this.lastEntities){let n=this.lastEntities[t];e=e.replace(n.regex,n.val)}if(this.options.htmlEntities)for(let t in this.htmlEntities){let n=this.htmlEntities[t];e=e.replace(n.regex,n.val)}e=e.replace(this.ampEntity.regex,this.ampEntity.val)}return e};function gE(e,t,n,r){return e&&(r===void 0&&(r=Object.keys(t.child).length===0),e=this.parseTextData(e,t.tagname,n,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,r),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function xE(e,t,n){let r="*."+n;for(let s in e){let i=e[s];if(r===i||t===i)return!0}return!1}function ME(e,t,n=">"){let r,s="";for(let i=t;i<e.length;i++){let o=e[i];if(r)o===r&&(r="");else if(o==='"'||o==="'")r=o;else if(o===n[0])if(n[1]){if(e[i+1]===n[1])return{data:s,index:i}}else return{data:s,index:i};else o===" "&&(o=" ");s+=o}}function Bn(e,t,n,r){let s=e.indexOf(t,n);if(s===-1)throw new Error(r);return s+t.length-1}function Ta(e,t,n,r=">"){let s=ME(e,t+1,r);if(!s)return;let i=s.data,o=s.index,c=i.search(/\s/),a=i,h=!0;c!==-1&&(a=i.substring(0,c),i=i.substring(c+1).trimStart());let l=a;if(n){let f=a.indexOf(":");f!==-1&&(a=a.substr(f+1),h=a!==s.data.substr(f+1))}return{tagName:a,tagExp:i,closeIndex:o,attrExpPresent:h,rawTagName:l}}function AE(e,t,n){let r=n,s=1;for(;n<e.length;n++)if(e[n]==="<")if(e[n+1]==="/"){let i=Bn(e,">",n,`${t} is not closed`);if(e.substring(n+2,i).trim()===t&&(s--,s===0))return{tagContent:e.substring(r,n),i};n=i}else if(e[n+1]==="?")n=Bn(e,"?>",n+1,"StopNode is not closed.");else if(e.substr(n+1,3)==="!--")n=Bn(e,"-->",n+3,"StopNode is not closed.");else if(e.substr(n+1,2)==="![")n=Bn(e,"]]>",n,"StopNode is not closed.")-2;else{let i=Ta(e,n,">");i&&((i&&i.tagName)===t&&i.tagExp[i.tagExp.length-1]!=="/"&&s++,n=i.closeIndex)}}function _a(e,t,n){if(t&&typeof e=="string"){let r=e.trim();return r==="true"?!0:r==="false"?!1:cE(e,n)}else return m1.isExist(e)?e:""}g1.exports=Ea});var y1=it(A1=>{"use strict";function yE(e,t){return M1(e,t)}function M1(e,t,n){let r,s={};for(let i=0;i<e.length;i++){let o=e[i],c=EE(o),a="";if(n===void 0?a=c:a=n+"."+c,c===t.textNodeName)r===void 0?r=o[c]:r+=""+o[c];else{if(c===void 0)continue;if(o[c]){let h=M1(o[c],t,a),l=_E(h,t);o[":@"]?TE(h,o[":@"],a,t):Object.keys(h).length===1&&h[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?h=h[t.textNodeName]:Object.keys(h).length===0&&(t.alwaysCreateTextNode?h[t.textNodeName]="":h=""),s[c]!==void 0&&s.hasOwnProperty(c)?(Array.isArray(s[c])||(s[c]=[s[c]]),s[c].push(h)):t.isArray(c,a,l)?s[c]=[h]:s[c]=h}}}return typeof r=="string"?r.length>0&&(s[t.textNodeName]=r):r!==void 0&&(s[t.textNodeName]=r),s}function EE(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(r!==":@")return r}}function TE(e,t,n,r){if(t){let s=Object.keys(t),i=s.length;for(let o=0;o<i;o++){let c=s[o];r.isArray(c,n+"."+c,!0,!0)?e[c]=[t[c]]:e[c]=t[c]}}}function _E(e,t){let{textNodeName:n}=t,r=Object.keys(e).length;return!!(r===0||r===1&&(e[n]||typeof e[n]=="boolean"||e[n]===0))}A1.prettify=yE});var T1=it((PF,E1)=>{var{buildOptions:SE}=a1(),BE=x1(),{prettify:CE}=y1(),LE=Ma(),Sa=class{constructor(t){this.externalEntities={},this.options=SE(t)}parse(t,n){if(typeof t!="string")if(t.toString)t=t.toString();else throw new Error("XML data is accepted in String or Bytes[] form.");if(n){n===!0&&(n={});let i=LE.validate(t,n);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}let r=new BE(this.options);r.addExternalEntities(this.externalEntities);let s=r.parseXml(t);return this.options.preserveOrder||s===void 0?s:CE(s,this.options)}addEntity(t,n){if(n.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(n==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=n}};E1.exports=Sa});var L1=it((NF,C1)=>{var RE=`
11
+ `;function wE(e,t){let n="";return t.format&&t.indentBy.length>0&&(n=RE),S1(e,t,"",n)}function S1(e,t,n,r){let s="",i=!1;for(let o=0;o<e.length;o++){let c=e[o],a=IE(c);if(a===void 0)continue;let h="";if(n.length===0?h=a:h=`${n}.${a}`,a===t.textNodeName){let d=c[a];bE(h,t)||(d=t.tagValueProcessor(a,d),d=B1(d,t)),i&&(s+=r),s+=d,i=!1;continue}else if(a===t.cdataPropName){i&&(s+=r),s+=`<![CDATA[${c[a][0][t.textNodeName]}]]>`,i=!1;continue}else if(a===t.commentPropName){s+=r+`<!--${c[a][0][t.textNodeName]}-->`,i=!0;continue}else if(a[0]==="?"){let d=_1(c[":@"],t),g=a==="?xml"?"":r,m=c[a][0][t.textNodeName];m=m.length!==0?" "+m:"",s+=g+`<${a}${m}${d}?>`,i=!0;continue}let l=r;l!==""&&(l+=t.indentBy);let f=_1(c[":@"],t),p=r+`<${a}${f}`,u=S1(c[a],t,h,l);t.unpairedTags.indexOf(a)!==-1?t.suppressUnpairedNode?s+=p+">":s+=p+"/>":(!u||u.length===0)&&t.suppressEmptyNode?s+=p+"/>":u&&u.endsWith(">")?s+=p+`>${u}${r}</${a}>`:(s+=p+">",u&&r!==""&&(u.includes("/>")||u.includes("</"))?s+=r+t.indentBy+u+r:s+=u,s+=`</${a}>`),i=!0}return s}function IE(e){let t=Object.keys(e);for(let n=0;n<t.length;n++){let r=t[n];if(e.hasOwnProperty(r)&&r!==":@")return r}}function _1(e,t){let n="";if(e&&!t.ignoreAttributes)for(let r in e){if(!e.hasOwnProperty(r))continue;let s=t.attributeValueProcessor(r,e[r]);s=B1(s,t),s===!0&&t.suppressBooleanAttributes?n+=` ${r.substr(t.attributeNamePrefix.length)}`:n+=` ${r.substr(t.attributeNamePrefix.length)}="${s}"`}return n}function bE(e,t){e=e.substr(0,e.length-t.textNodeName.length-1);let n=e.substr(e.lastIndexOf(".")+1);for(let r in t.stopNodes)if(t.stopNodes[r]===e||t.stopNodes[r]==="*."+n)return!0;return!1}function B1(e,t){if(e&&e.length>0&&t.processEntities)for(let n=0;n<t.entities.length;n++){let r=t.entities[n];e=e.replace(r.regex,r.val)}return e}C1.exports=wE});var w1=it((FF,R1)=>{"use strict";var OE=L1(),PE={attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,cdataPropName:!1,format:!1,indentBy:" ",suppressEmptyNode:!1,suppressUnpairedNode:!0,suppressBooleanAttributes:!0,tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},preserveOrder:!1,commentPropName:!1,unpairedTags:[],entities:[{regex:new RegExp("&","g"),val:"&amp;"},{regex:new RegExp(">","g"),val:"&gt;"},{regex:new RegExp("<","g"),val:"&lt;"},{regex:new RegExp("'","g"),val:"&apos;"},{regex:new RegExp('"',"g"),val:"&quot;"}],processEntities:!0,stopNodes:[],oneListGroup:!1};function Je(e){this.options=Object.assign({},PE,e),this.options.ignoreAttributes||this.options.attributesGroupName?this.isAttribute=function(){return!1}:(this.attrPrefixLen=this.options.attributeNamePrefix.length,this.isAttribute=vE),this.processTextOrObjNode=NE,this.options.format?(this.indentate=FE,this.tagEndChar=`>
12
12
  `,this.newLine=`
13
- `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}fe.prototype.build=function(e){return this.options.preserveOrder?f0(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};fe.prototype.j2x=function(e,t){let r="",n="";for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s))if(typeof e[s]>"u")this.isAttribute(s)&&(n+="");else if(e[s]===null)this.isAttribute(s)?n+="":s[0]==="?"?n+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(e[s]instanceof Date)n+=this.buildTextValNode(e[s],s,"",t);else if(typeof e[s]!="object"){let o=this.isAttribute(s);if(o)r+=this.buildAttrPairStr(o,""+e[s]);else if(s===this.options.textNodeName){let i=this.options.tagValueProcessor(s,""+e[s]);n+=this.replaceEntitiesValue(i)}else n+=this.buildTextValNode(e[s],s,"",t)}else if(Array.isArray(e[s])){let o=e[s].length,i="";for(let a=0;a<o;a++){let c=e[s][a];typeof c>"u"||(c===null?s[0]==="?"?n+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:n+=this.indentate(t)+"<"+s+"/"+this.tagEndChar:typeof c=="object"?this.options.oneListGroup?i+=this.j2x(c,t+1).val:i+=this.processTextOrObjNode(c,s,t):i+=this.buildTextValNode(c,s,"",t))}this.options.oneListGroup&&(i=this.buildObjectNode(i,s,"",t)),n+=i}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName){let o=Object.keys(e[s]),i=o.length;for(let a=0;a<i;a++)r+=this.buildAttrPairStr(o[a],""+e[s][o[a]])}else n+=this.processTextOrObjNode(e[s],s,t);return{attrStr:r,val:n}};fe.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function d0(e,t,r){let n=this.j2x(e,r+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,n.attrStr,r):this.buildObjectNode(n.val,t,n.attrStr,r)}fe.prototype.buildObjectNode=function(e,t,r,n){if(e==="")return t[0]==="?"?this.indentate(n)+"<"+t+r+"?"+this.tagEndChar:this.indentate(n)+"<"+t+r+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,o="";return t[0]==="?"&&(o="?",s=""),(r||r==="")&&e.indexOf("<")===-1?this.indentate(n)+"<"+t+r+o+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&o.length===0?this.indentate(n)+`<!--${e}-->`+this.newLine:this.indentate(n)+"<"+t+r+o+this.tagEndChar+e+this.indentate(n)+s}};fe.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};fe.prototype.buildTextValNode=function(e,t,r,n){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(n)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(n)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(n)+"<"+t+r+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(t,e);return s=this.replaceEntitiesValue(s),s===""?this.indentate(n)+"<"+t+r+this.closeTag(t)+this.tagEndChar:this.indentate(n)+"<"+t+r+">"+s+"</"+t+this.tagEndChar}};fe.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let r=this.options.entities[t];e=e.replace(r.regex,r.val)}return e};function p0(e){return this.options.indentBy.repeat(e)}function m0(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}Vl.exports=fe});var kl=tt((mb,zl)=>{"use strict";var g0=Xo(),A0=Ol(),x0=Hl();zl.exports={XMLParser:A0,XMLValidator:g0,XMLBuilder:x0}});var oa=tt((Df,hn)=>{(function(e,t){typeof define=="function"&&define.amd?define([],t):typeof cl=="function"&&typeof hn=="object"&&hn&&hn.exports?hn.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(Df,function(){"use strict";function e(T,m,M){this.low=T|0,this.high=m|0,this.unsigned=!!M}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function t(T){return(T&&T.__isLong__)===!0}e.isLong=t;var r={},n={};function s(T,m){var M,F,R;return m?(T>>>=0,(R=0<=T&&T<256)&&(F=n[T],F)?F:(M=i(T,(T|0)<0?-1:0,!0),R&&(n[T]=M),M)):(T|=0,(R=-128<=T&&T<128)&&(F=r[T],F)?F:(M=i(T,T<0?-1:0,!1),R&&(r[T]=M),M))}e.fromInt=s;function o(T,m){if(isNaN(T)||!isFinite(T))return m?y:g;if(m){if(T<0)return y;if(T>=d)return b}else{if(T<=-p)return w;if(T+1>=p)return S}return T<0?o(-T,m).neg():i(T%h|0,T/h|0,m)}e.fromNumber=o;function i(T,m,M){return new e(T,m,M)}e.fromBits=i;var a=Math.pow;function c(T,m,M){if(T.length===0)throw Error("empty string");if(T==="NaN"||T==="Infinity"||T==="+Infinity"||T==="-Infinity")return g;if(typeof m=="number"?(M=m,m=!1):m=!!m,M=M||10,M<2||36<M)throw RangeError("radix");var F;if((F=T.indexOf("-"))>0)throw Error("interior hyphen");if(F===0)return c(T.substring(1),m,M).neg();for(var R=o(a(M,8)),L=g,D=0;D<T.length;D+=8){var X=Math.min(8,T.length-D),H=parseInt(T.substring(D,D+X),M);if(X<8){var Q=o(a(M,X));L=L.mul(Q).add(o(H))}else L=L.mul(R),L=L.add(o(H))}return L.unsigned=m,L}e.fromString=c;function l(T){return T instanceof e?T:typeof T=="number"?o(T):typeof T=="string"?c(T):i(T.low,T.high,T.unsigned)}e.fromValue=l;var u=1<<16,f=1<<24,h=u*u,d=h*h,p=d/2,A=s(f),g=s(0);e.ZERO=g;var y=s(0,!0);e.UZERO=y;var E=s(1);e.ONE=E;var _=s(1,!0);e.UONE=_;var B=s(-1);e.NEG_ONE=B;var S=i(-1,2147483647,!1);e.MAX_VALUE=S;var b=i(-1,-1,!0);e.MAX_UNSIGNED_VALUE=b;var w=i(0,-2147483648,!1);e.MIN_VALUE=w;var C=e.prototype;return C.toInt=function(){return this.unsigned?this.low>>>0:this.low},C.toNumber=function(){return this.unsigned?(this.high>>>0)*h+(this.low>>>0):this.high*h+(this.low>>>0)},C.toString=function(m){if(m=m||10,m<2||36<m)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(w)){var M=o(m),F=this.div(M),R=F.mul(M).sub(this);return F.toString(m)+R.toInt().toString(m)}else return"-"+this.neg().toString(m);for(var L=o(a(m,6),this.unsigned),D=this,X="";;){var H=D.div(L),Q=D.sub(H.mul(L)).toInt()>>>0,j=Q.toString(m);if(D=H,D.isZero())return j+X;for(;j.length<6;)j="0"+j;X=""+j+X}},C.getHighBits=function(){return this.high},C.getHighBitsUnsigned=function(){return this.high>>>0},C.getLowBits=function(){return this.low},C.getLowBitsUnsigned=function(){return this.low>>>0},C.getNumBitsAbs=function(){if(this.isNegative())return this.eq(w)?64:this.neg().getNumBitsAbs();for(var m=this.high!=0?this.high:this.low,M=31;M>0&&!(m&1<<M);M--);return this.high!=0?M+33:M+1},C.isZero=function(){return this.high===0&&this.low===0},C.isNegative=function(){return!this.unsigned&&this.high<0},C.isPositive=function(){return this.unsigned||this.high>=0},C.isOdd=function(){return(this.low&1)===1},C.isEven=function(){return(this.low&1)===0},C.equals=function(m){return t(m)||(m=l(m)),this.unsigned!==m.unsigned&&this.high>>>31===1&&m.high>>>31===1?!1:this.high===m.high&&this.low===m.low},C.eq=C.equals,C.notEquals=function(m){return!this.eq(m)},C.neq=C.notEquals,C.lessThan=function(m){return this.comp(m)<0},C.lt=C.lessThan,C.lessThanOrEqual=function(m){return this.comp(m)<=0},C.lte=C.lessThanOrEqual,C.greaterThan=function(m){return this.comp(m)>0},C.gt=C.greaterThan,C.greaterThanOrEqual=function(m){return this.comp(m)>=0},C.gte=C.greaterThanOrEqual,C.compare=function(m){if(t(m)||(m=l(m)),this.eq(m))return 0;var M=this.isNegative(),F=m.isNegative();return M&&!F?-1:!M&&F?1:this.unsigned?m.high>>>0>this.high>>>0||m.high===this.high&&m.low>>>0>this.low>>>0?-1:1:this.sub(m).isNegative()?-1:1},C.comp=C.compare,C.negate=function(){return!this.unsigned&&this.eq(w)?w:this.not().add(E)},C.neg=C.negate,C.add=function(m){t(m)||(m=l(m));var M=this.high>>>16,F=this.high&65535,R=this.low>>>16,L=this.low&65535,D=m.high>>>16,X=m.high&65535,H=m.low>>>16,Q=m.low&65535,j=0,W=0,$=0,At=0;return At+=L+Q,$+=At>>>16,At&=65535,$+=R+H,W+=$>>>16,$&=65535,W+=F+X,j+=W>>>16,W&=65535,j+=M+D,j&=65535,i($<<16|At,j<<16|W,this.unsigned)},C.subtract=function(m){return t(m)||(m=l(m)),this.add(m.neg())},C.sub=C.subtract,C.multiply=function(m){if(this.isZero()||(t(m)||(m=l(m)),m.isZero()))return g;if(this.eq(w))return m.isOdd()?w:g;if(m.eq(w))return this.isOdd()?w:g;if(this.isNegative())return m.isNegative()?this.neg().mul(m.neg()):this.neg().mul(m).neg();if(m.isNegative())return this.mul(m.neg()).neg();if(this.lt(A)&&m.lt(A))return o(this.toNumber()*m.toNumber(),this.unsigned);var M=this.high>>>16,F=this.high&65535,R=this.low>>>16,L=this.low&65535,D=m.high>>>16,X=m.high&65535,H=m.low>>>16,Q=m.low&65535,j=0,W=0,$=0,At=0;return At+=L*Q,$+=At>>>16,At&=65535,$+=R*Q,W+=$>>>16,$&=65535,$+=L*H,W+=$>>>16,$&=65535,W+=F*Q,j+=W>>>16,W&=65535,W+=R*H,j+=W>>>16,W&=65535,W+=L*X,j+=W>>>16,W&=65535,j+=M*Q+F*H+R*X+L*D,j&=65535,i($<<16|At,j<<16|W,this.unsigned)},C.mul=C.multiply,C.divide=function(m){if(t(m)||(m=l(m)),m.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?y:g;var M,F,R;if(this.unsigned){if(m.unsigned||(m=m.toUnsigned()),m.gt(this))return y;if(m.gt(this.shru(1)))return _;R=y}else{if(this.eq(w)){if(m.eq(E)||m.eq(B))return w;if(m.eq(w))return E;var L=this.shr(1);return M=L.div(m).shl(1),M.eq(g)?m.isNegative()?E:B:(F=this.sub(m.mul(M)),R=M.add(F.div(m)),R)}else if(m.eq(w))return this.unsigned?y:g;if(this.isNegative())return m.isNegative()?this.neg().div(m.neg()):this.neg().div(m).neg();if(m.isNegative())return this.div(m.neg()).neg();R=g}for(F=this;F.gte(m);){M=Math.max(1,Math.floor(F.toNumber()/m.toNumber()));for(var D=Math.ceil(Math.log(M)/Math.LN2),X=D<=48?1:a(2,D-48),H=o(M),Q=H.mul(m);Q.isNegative()||Q.gt(F);)M-=X,H=o(M,this.unsigned),Q=H.mul(m);H.isZero()&&(H=E),R=R.add(H),F=F.sub(Q)}return R},C.div=C.divide,C.modulo=function(m){return t(m)||(m=l(m)),this.sub(this.div(m).mul(m))},C.mod=C.modulo,C.not=function(){return i(~this.low,~this.high,this.unsigned)},C.and=function(m){return t(m)||(m=l(m)),i(this.low&m.low,this.high&m.high,this.unsigned)},C.or=function(m){return t(m)||(m=l(m)),i(this.low|m.low,this.high|m.high,this.unsigned)},C.xor=function(m){return t(m)||(m=l(m)),i(this.low^m.low,this.high^m.high,this.unsigned)},C.shiftLeft=function(m){return t(m)&&(m=m.toInt()),(m&=63)===0?this:m<32?i(this.low<<m,this.high<<m|this.low>>>32-m,this.unsigned):i(0,this.low<<m-32,this.unsigned)},C.shl=C.shiftLeft,C.shiftRight=function(m){return t(m)&&(m=m.toInt()),(m&=63)===0?this:m<32?i(this.low>>>m|this.high<<32-m,this.high>>m,this.unsigned):i(this.high>>m-32,this.high>=0?0:-1,this.unsigned)},C.shr=C.shiftRight,C.shiftRightUnsigned=function(m){if(t(m)&&(m=m.toInt()),m&=63,m===0)return this;var M=this.high;if(m<32){var F=this.low;return i(F>>>m|M<<32-m,M>>>m,this.unsigned)}else return m===32?i(M,0,this.unsigned):i(M>>>m-32,0,this.unsigned)},C.shru=C.shiftRightUnsigned,C.toSigned=function(){return this.unsigned?i(this.low,this.high,!1):this},C.toUnsigned=function(){return this.unsigned?this:i(this.low,this.high,!0)},C.toBytes=function(T){return T?this.toBytesLE():this.toBytesBE()},C.toBytesLE=function(){var T=this.high,m=this.low;return[m&255,m>>>8&255,m>>>16&255,m>>>24&255,T&255,T>>>8&255,T>>>16&255,T>>>24&255]},C.toBytesBE=function(){var T=this.high,m=this.low;return[T>>>24&255,T>>>16&255,T>>>8&255,T&255,m>>>24&255,m>>>16&255,m>>>8&255,m&255]},e})});var Rs=tt((jR,gh)=>{gh.exports=globalThis.h3||{}});var xa=tt((e3,Eh)=>{Eh.exports=globalThis.luma});var Ds=tt((r3,Bh)=>{Bh.exports=globalThis.deck});var Sh=tt((n3,Ch)=>{Ch.exports=globalThis.luma});var yr=tt((X3,Zh)=>{Zh.exports=globalThis.loaders});var Am=tt((WG,gm)=>{gm.exports=globalThis.deck});var Mm=tt(Yc=>{Yc.read=function(e,t,r,n,s){var o,i,a=s*8-n-1,c=(1<<a)-1,l=c>>1,u=-7,f=r?s-1:0,h=r?-1:1,d=e[t+f];for(f+=h,o=d&(1<<-u)-1,d>>=-u,u+=a;u>0;o=o*256+e[t+f],f+=h,u-=8);for(i=o&(1<<-u)-1,o>>=-u,u+=n;u>0;i=i*256+e[t+f],f+=h,u-=8);if(o===0)o=1-l;else{if(o===c)return i?NaN:(d?-1:1)*(1/0);i=i+Math.pow(2,n),o=o-l}return(d?-1:1)*i*Math.pow(2,o-n)};Yc.write=function(e,t,r,n,s,o){var i,a,c,l=o*8-s-1,u=(1<<l)-1,f=u>>1,h=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,A=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,i=u):(i=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-i))<1&&(i--,c*=2),i+f>=1?t+=h/c:t+=h*Math.pow(2,1-f),t*c>=2&&(i++,c/=2),i+f>=u?(a=0,i=u):i+f>=1?(a=(t*c-1)*Math.pow(2,s),i=i+f):(a=t*Math.pow(2,f-1)*Math.pow(2,s),i=0));s>=8;e[r+d]=a&255,d+=p,a/=256,s-=8);for(i=i<<s|a,l+=s;l>0;e[r+d]=i&255,d+=p,i/=256,l-=8);e[r+d-p]|=A*128}});var Pm=tt((N4,Rm)=>{"use strict";Rm.exports=k;var Do=Mm();function k(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}k.Varint=0;k.Fixed64=1;k.Bytes=2;k.Fixed32=5;var Kc=(1<<16)*(1<<16),Im=1/Kc,nS=12,Fm=typeof TextDecoder>"u"?null:new TextDecoder("utf8");k.prototype={destroy:function(){this.buf=null},readFields:function(e,t,r){for(r=r||this.length;this.pos<r;){var n=this.readVarint(),s=n>>3,o=this.pos;this.type=n&7,e(s,t,this),this.pos===o&&this.skip(n)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=vo(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Lm(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=vo(this.buf,this.pos)+vo(this.buf,this.pos+4)*Kc;return this.pos+=8,e},readSFixed64:function(){var e=vo(this.buf,this.pos)+Lm(this.buf,this.pos+4)*Kc;return this.pos+=8,e},readFloat:function(){var e=Do.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=Do.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,r,n;return n=t[this.pos++],r=n&127,n<128||(n=t[this.pos++],r|=(n&127)<<7,n<128)||(n=t[this.pos++],r|=(n&127)<<14,n<128)||(n=t[this.pos++],r|=(n&127)<<21,n<128)?r:(n=t[this.pos],r|=(n&15)<<28,sS(r,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=nS&&Fm?xS(this.buf,t,e):AS(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==k.Bytes)return e.push(this.readVarint(t));var r=le(this);for(e=e||[];this.pos<r;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==k.Bytes)return e.push(this.readSVarint());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==k.Bytes)return e.push(this.readBoolean());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==k.Bytes)return e.push(this.readFloat());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==k.Bytes)return e.push(this.readDouble());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==k.Bytes)return e.push(this.readFixed32());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==k.Bytes)return e.push(this.readSFixed32());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==k.Bytes)return e.push(this.readFixed64());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==k.Bytes)return e.push(this.readSFixed64());var t=le(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===k.Varint)for(;this.buf[this.pos++]>127;);else if(t===k.Bytes)this.pos=this.readVarint()+this.pos;else if(t===k.Fixed32)this.pos+=4;else if(t===k.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var r=new Uint8Array(t);r.set(this.buf),this.buf=r,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),Gr(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),Gr(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),Gr(this.buf,e&-1,this.pos),Gr(this.buf,Math.floor(e*Im),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),Gr(this.buf,e&-1,this.pos),Gr(this.buf,Math.floor(e*Im),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){oS(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=yS(this.buf,e,this.pos);var r=this.pos-t;r>=128&&wm(t,r,this),this.pos=t-1,this.writeVarint(r),this.pos+=r},writeFloat:function(e){this.realloc(4),Do.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),Do.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var r=0;r<t;r++)this.buf[this.pos++]=e[r]},writeRawMessage:function(e,t){this.pos++;var r=this.pos;e(t,this);var n=this.pos-r;n>=128&&wm(r,n,this),this.pos=r-1,this.writeVarint(n),this.pos+=n},writeMessage:function(e,t,r){this.writeTag(e,k.Bytes),this.writeRawMessage(t,r)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,cS,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,lS,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,hS,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,uS,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,fS,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,dS,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,pS,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,mS,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,gS,t)},writeBytesField:function(e,t){this.writeTag(e,k.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,k.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,k.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,k.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,k.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,k.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,k.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,k.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,k.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,k.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function sS(e,t,r){var n=r.buf,s,o;if(o=n[r.pos++],s=(o&112)>>4,o<128||(o=n[r.pos++],s|=(o&127)<<3,o<128)||(o=n[r.pos++],s|=(o&127)<<10,o<128)||(o=n[r.pos++],s|=(o&127)<<17,o<128)||(o=n[r.pos++],s|=(o&127)<<24,o<128)||(o=n[r.pos++],s|=(o&1)<<31,o<128))return Ur(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function le(e){return e.type===k.Bytes?e.readVarint()+e.pos:e.pos+1}function Ur(e,t,r){return r?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function oS(e,t){var r,n;if(e>=0?(r=e%4294967296|0,n=e/4294967296|0):(r=~(-e%4294967296),n=~(-e/4294967296),r^4294967295?r=r+1|0:(r=0,n=n+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),iS(r,n,t),aS(n,t)}function iS(e,t,r){r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos++]=e&127|128,e>>>=7,r.buf[r.pos]=e&127}function aS(e,t){var r=(e&7)<<4;t.buf[t.pos++]|=r|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function wm(e,t,r){var n=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));r.realloc(n);for(var s=r.pos-1;s>=e;s--)r.buf[s+n]=r.buf[s]}function cS(e,t){for(var r=0;r<e.length;r++)t.writeVarint(e[r])}function lS(e,t){for(var r=0;r<e.length;r++)t.writeSVarint(e[r])}function uS(e,t){for(var r=0;r<e.length;r++)t.writeFloat(e[r])}function fS(e,t){for(var r=0;r<e.length;r++)t.writeDouble(e[r])}function hS(e,t){for(var r=0;r<e.length;r++)t.writeBoolean(e[r])}function dS(e,t){for(var r=0;r<e.length;r++)t.writeFixed32(e[r])}function pS(e,t){for(var r=0;r<e.length;r++)t.writeSFixed32(e[r])}function mS(e,t){for(var r=0;r<e.length;r++)t.writeFixed64(e[r])}function gS(e,t){for(var r=0;r<e.length;r++)t.writeSFixed64(e[r])}function vo(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function Gr(e,t,r){e[r]=t,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24}function Lm(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function AS(e,t,r){for(var n="",s=t;s<r;){var o=e[s],i=null,a=o>239?4:o>223?3:o>191?2:1;if(s+a>r)break;var c,l,u;a===1?o<128&&(i=o):a===2?(c=e[s+1],(c&192)===128&&(i=(o&31)<<6|c&63,i<=127&&(i=null))):a===3?(c=e[s+1],l=e[s+2],(c&192)===128&&(l&192)===128&&(i=(o&15)<<12|(c&63)<<6|l&63,(i<=2047||i>=55296&&i<=57343)&&(i=null))):a===4&&(c=e[s+1],l=e[s+2],u=e[s+3],(c&192)===128&&(l&192)===128&&(u&192)===128&&(i=(o&15)<<18|(c&63)<<12|(l&63)<<6|u&63,(i<=65535||i>=1114112)&&(i=null))),i===null?(i=65533,a=1):i>65535&&(i-=65536,n+=String.fromCharCode(i>>>10&1023|55296),i=56320|i&1023),n+=String.fromCharCode(i),s+=a}return n}function xS(e,t,r){return Fm.decode(e.subarray(t,r))}function yS(e,t,r){for(var n=0,s,o;n<t.length;n++){if(s=t.charCodeAt(n),s>55295&&s<57344)if(o)if(s<56320){e[r++]=239,e[r++]=191,e[r++]=189,o=s;continue}else s=o-55296<<10|s-56320|65536,o=null;else{s>56319||n+1===t.length?(e[r++]=239,e[r++]=191,e[r++]=189):o=s;continue}else o&&(e[r++]=239,e[r++]=191,e[r++]=189,o=null);s<128?e[r++]=s:(s<2048?e[r++]=s>>6|192:(s<65536?e[r++]=s>>12|224:(e[r++]=s>>18|240,e[r++]=s>>12&63|128),e[r++]=s>>6&63|128),e[r++]=s&63|128)}return r}});var Yn={};ut(Yn,{GeohashLayer:()=>tg,GreatCircleLayer:()=>Of,H3ClusterLayer:()=>_h,H3HexagonLayer:()=>Ns,MVTLayer:()=>Km,QuadkeyLayer:()=>Yf,S2Layer:()=>Xf,TerrainLayer:()=>mm,Tile3DLayer:()=>am,TileLayer:()=>qe,TripsLayer:()=>mh,_GeoCellLayer:()=>Yt,_Tile2DHeader:()=>ke,_Tileset2D:()=>Je,_WMSLayer:()=>Ar,_getURLFromTemplate:()=>Qt});var kt={},ul=N(Ot(),1);ue(kt,N(Ot(),1));if(!ul.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");ue(Yn,kt);var ze=N(Nt(),1),Rf=N(Ot(),1);function ug(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function Qn(e){if(Array.isArray(e))return e.map(t=>Qn(t));if(e&&typeof e=="object"){let t={};for(let[r,n]of Object.entries(e))t[ug(r)]=Qn(n);return t}return e}var Jl=N(kl(),1);function ti(e,t){if(t?._parser&&t._parser!=="fast-xml-parser")throw new Error(t?._parser);let r={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(s,o,i,a)=>Boolean(t?.arrayPaths?.some(l=>o===l)),...t?._fastXML},n=y0(e,r);return t?.uncapitalizeKeys?Qn(n):n}function y0(e,t){return new Jl.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var T0="4.2.0-beta.2",Dt={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:T0,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:_0,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>ti(new TextDecoder().decode(e),{...Dt.options.xml,...t?.xml}),parseTextSync:(e,t)=>ti(e,{...Dt.options.xml,...t?.xml})};function _0(e){return e.startsWith("<?xml")}async function Et(e,t,r,n){return n._parse(e,t,r,n)}function G(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var Jt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},E0=Jt.self||Jt.window||Jt.global||{},B0=Jt.window||Jt.self||Jt.global||{},C0=Jt.global||Jt.self||Jt.window||{},S0=Jt.document||{};var Jr=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var ql=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),b0=ql&&parseFloat(ql[1])||0;var $n=globalThis,M0=globalThis.document||{},ts=globalThis.process||{},I0=globalThis.console,Bb=globalThis.navigator||{};function jl(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,r=e||t;return Boolean(r&&r.indexOf("Electron")>=0)}function Fe(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||jl()}var ei="4.0.7";function L0(e){try{let t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch{return null}}var es=class{constructor(t,r,n="sessionStorage"){this.storage=L0(n),this.id=t,this.config=r,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let r=JSON.stringify(this.config);this.storage.setItem(this.id,r)}}_loadConfiguration(){let t={};if(this.storage){let r=this.storage.getItem(this.id);t=r?JSON.parse(r):{}}return Object.assign(this.config,t),this}};function Xl(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function Wl(e,t=8){let r=Math.max(t-e.length,0);return`${" ".repeat(r)}${e}`}var rs;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(rs||(rs={}));var F0=10;function Yl(e){return typeof e!="string"?e:(e=e.toUpperCase(),rs[e]||rs.WHITE)}function Kl(e,t,r){return!Fe&&typeof e=="string"&&(t&&(e=`\x1B[${Yl(t)}m${e}\x1B[39m`),r&&(e=`\x1B[${Yl(r)+F0}m${e}\x1B[49m`)),e}function Ql(e,t=["constructor"]){let r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r),s=e;for(let o of n){let i=s[o];typeof i=="function"&&(t.find(a=>o===a)||(s[o]=i.bind(e)))}}function qr(e,t){if(!e)throw new Error(t||"Assertion failed")}function Re(){let e;if(Fe()&&$n.performance)e=$n?.performance?.now?.();else if("hrtime"in ts){let t=ts?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var cr={debug:Fe()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},R0={enabled:!0,level:0};function lr(){}var Zl={},$l={once:!0},jr=class{constructor({id:t}={id:""}){this.VERSION=ei,this._startTs=Re(),this._deltaTs=Re(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new es(`__probe-${this.id}__`,R0),this.timeStamp(`${this.id} started`),Ql(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Re()-this._startTs).toPrecision(10))}getDelta(){return Number((Re()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,r){this._storage.setConfiguration({[t]:r})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,r){if(!t)throw new Error(r||"Assertion failed")}warn(t){return this._getLogFunction(0,t,cr.warn,arguments,$l)}error(t){return this._getLogFunction(0,t,cr.error,arguments)}deprecated(t,r){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${r}\` instead`)}removed(t,r){return this.error(`\`${t}\` has been removed. Use \`${r}\` instead`)}probe(t,r){return this._getLogFunction(t,r,cr.log,arguments,{time:!0,once:!0})}log(t,r){return this._getLogFunction(t,r,cr.debug,arguments)}info(t,r){return this._getLogFunction(t,r,console.info,arguments)}once(t,r){return this._getLogFunction(t,r,cr.debug||cr.info,arguments,$l)}table(t,r,n){return r?this._getLogFunction(t,r,console.table||lr,n&&[n],{tag:O0(r)}):lr}time(t,r){return this._getLogFunction(t,r,console.time?console.time:console.info)}timeEnd(t,r){return this._getLogFunction(t,r,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,r){return this._getLogFunction(t,r,console.timeStamp||lr)}group(t,r,n={collapsed:!1}){let s=tu({logLevel:t,message:r,opts:n}),{collapsed:o}=n;return s.method=(o?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(t,r,n={}){return this.group(t,r,Object.assign({},n,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||lr)}withGroup(t,r,n){this.group(t,r)();try{n()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=eu(t)}_getLogFunction(t,r,n,s,o){if(this._shouldLog(t)){o=tu({logLevel:t,message:r,args:s,opts:o}),n=n||o.method,qr(n),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=Re();let i=o.tag||o.message;if(o.once&&i)if(!Zl[i])Zl[i]=Re();else return lr;return r=P0(this.id,o.message,o),n.bind(console,r,...o.args)}return lr}};jr.VERSION=ei;function eu(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return qr(Number.isFinite(t)&&t>=0),t}function tu(e){let{logLevel:t,message:r}=e;e.logLevel=eu(t);let n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":r!==void 0&&n.unshift(r),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let s=typeof e.message;return qr(s==="string"||s==="object"),Object.assign(e,{args:n},e.opts)}function P0(e,t,r){if(typeof t=="string"){let n=r.time?Wl(Xl(r.total)):"";t=r.time?`${e}: ${n} ${t}`:`${e}: ${t}`,t=Kl(t,r.color,r.background)}return t}function O0(e){for(let t in e)for(let r in e[t])return r||"untitled";return"empty"}globalThis.probe={};var ri=new jr({id:"@probe.gl/log"});function ni(e,t){return ru(e||{},t)}function ru(e,t,r=0){if(r>3)return t;let n={...e};for(let[s,o]of Object.entries(t))o&&typeof o=="object"&&!Array.isArray(o)?n[s]=ru(n[s]||{},t[s],r+1):n[s]=t[s];return n}function si(e){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,e)}function oi(e){return globalThis.loaders?.modules?.[e]||null}function N0(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.0-beta.2"),globalThis._loadersgl_.version}var nu=N0();function su(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var qt={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},tM=qt.self||qt.window||qt.global||{},eM=qt.window||qt.self||qt.global||{},rM=qt.global||qt.self||qt.window||{},nM=qt.document||{};var ur=typeof process!="object"||String(process)!=="[object process]"||process.browser,ns=typeof importScripts=="function",sM=typeof window<"u"&&typeof window.orientation<"u",ou=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),oM=ou&&parseFloat(ou[1])||0;var ii={};async function jt(e,t=null,r={},n=null){return t&&(e=iu(e,t,r,n)),ii[e]=ii[e]||D0(e),await ii[e]}function iu(e,t,r={},n=null){if(!r.useLocalLibraries&&e.startsWith("http"))return e;n=n||e;let s=r.modules||{};return s[n]?s[n]:ur?r.CDN?(su(r.CDN.startsWith("http")),`${r.CDN}/${t}@${nu}/dist/libs/${n}`):ns?`../src/libs/${n}`:`modules/${t}/src/libs/${n}`:`modules/${t}/dist/libs/${n}`}async function D0(e){if(e.endsWith("wasm"))return await U0(e);if(!ur)try{let{requireFromFile:r}=globalThis.loaders||{};return await r?.(e)}catch(r){return console.error(r),null}if(ns)return importScripts(e);let t=await G0(e);return v0(t,e)}function v0(e,t){if(!ur){let{requireFromString:n}=globalThis.loaders||{};return n?.(e,t)}if(ns)return eval.call(globalThis,e),null;let r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch{r.text=e}return document.body.appendChild(r),null}async function U0(e){let{readFileAsArrayBuffer:t}=globalThis.loaders||{};return ur||!t||e.startsWith("http")?await(await fetch(e)).arrayBuffer():await t(e)}async function G0(e){let{readFileAsText:t}=globalThis.loaders||{};return ur||!t||e.startsWith("http")?await(await fetch(e)).text():await t(e)}function cu(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?au(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?au(e,0,t):""}function au(e,t,r){if(e.byteLength<=t+r)return"";let n=new DataView(e),s="";for(let o=0;o<r;o++)s+=String.fromCharCode(n.getUint8(t+o));return s}function ai(e){try{return JSON.parse(e)}catch{throw new Error(`Failed to parse JSON from data starting with "${cu(e)}"`)}}function Xr(...e){let t=e,r=t&&t.length>1&&t[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let n=t.reduce((i,a)=>i+a.length,0),s=new r(n),o=0;for(let i of t)s.set(i,o),o+=i.length;return s}function Pe(e,t,r){let n=r!==void 0?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}function he(e,t){return G(e>=0),G(t>0),e+(t-1)&~(t-1)}function ci(e,t,r){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{let s=e.byteOffset,o=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,s,o)}return t.set(n,r),r+he(n.byteLength,4)}function Wr(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var Oe=class{constructor(t,r){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=r,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Wr(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Wr()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var de=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,r="count"){return this._getOrCreate({name:t,type:r})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let r of Object.values(this.stats))t(r)}getTable(){let t={};return this.forEach(r=>{t[r.name]={time:r.time||0,count:r.count||0,average:r.getAverageTime()||0,hz:r.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(r=>this._getOrCreate(r))}_getOrCreate(t){let{name:r,type:n}=t,s=this.stats[r];return s||(t instanceof Oe?s=t:s=new Oe(r,n),this.stats[r]=s),s}};var V0="Queued Requests",H0="Active Requests",z0="Cancelled Requests",k0="Queued Requests Ever",J0="Active Requests Ever",q0={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},pe=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...q0,...t},this.stats=new de({id:this.props.id}),this.stats.get(V0),this.stats.get(H0),this.stats.get(z0),this.stats.get(k0),this.stats.get(J0)}scheduleRequest(t,r=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let n={handle:t,priority:0,getPriority:r},s=new Promise(o=>(n.resolve=o,n));return this.requestQueue.push(n),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:r,resolve:n}=t,s=!1,o=()=>{s||(s=!0,this.requestMap.delete(r),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({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;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let r=0;r<t;++r){let n=this.requestQueue.shift();n&&this._issueRequest(n)}}}_updateAllRequests(){let t=this.requestQueue;for(let r=0;r<t.length;++r){let n=t[r];this._updateRequest(n)||(t.splice(r,1),this.requestMap.delete(n.handle),r--)}t.sort((r,n)=>r.priority-n.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var me={};ut(me,{dirname:()=>X0,filename:()=>j0,join:()=>W0,resolve:()=>Y0});function lu(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function j0(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function X0(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function W0(...e){let t="/";return e=e.map((r,n)=>(n&&(r=r.replace(new RegExp(`^${t}`),"")),n!==e.length-1&&(r=r.replace(new RegExp(`${t}$`),"")),r)),e.join(t)}function Y0(...e){let t=[];for(let o=0;o<e.length;o++)t[o]=e[o];let r="",n=!1,s;for(let o=t.length-1;o>=-1&&!n;o--){let i;o>=0?i=t[o]:(s===void 0&&(s=lu()),i=s),i.length!==0&&(r=`${i}/${r}`,n=i.charCodeAt(0)===Yr)}return r=K0(r,!n),n?`/${r}`:r.length>0?r:"."}var Yr=47,li=46;function K0(e,t){let r="",n=-1,s=0,o,i=!1;for(let a=0;a<=e.length;++a){if(a<e.length)o=e.charCodeAt(a);else{if(o===Yr)break;o=Yr}if(o===Yr){if(!(n===a-1||s===1))if(n!==a-1&&s===2){if(r.length<2||!i||r.charCodeAt(r.length-1)!==li||r.charCodeAt(r.length-2)!==li){if(r.length>2){let c=r.length-1,l=c;for(;l>=0&&r.charCodeAt(l)!==Yr;--l);if(l!==c){r=l===-1?"":r.slice(0,l),n=a,s=0,i=!1;continue}}else if(r.length===2||r.length===1){r="",n=a,s=0,i=!1;continue}}t&&(r.length>0?r+="/..":r="..",i=!0)}else{let c=e.slice(n+1,a);r.length>0?r+=`/${c}`:r=c,i=!1}n=a,s=0}else o===li&&s!==-1?++s:s=-1}return r}var ss=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=Q0(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let r=this._needsRefresh;return t&&(this._needsRefresh=!1),r}};function Q0(e){let t=e?.fetch;if(t&&typeof t=="function")return(n,s)=>t(n,s);let r=e?.fetch;return r&&typeof r!="function"?n=>fetch(n,r):n=>fetch(n)}var bt=class extends ss{};ar(bt,"type","template"),ar(bt,"testURL",t=>!1);function uu(e,t){let r=Dt.parseTextSync?.(e,t),n=r?.ServiceExceptionReport?.ServiceException||r?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof n=="string"?n:n.value||n.code||"Unknown error"}var Z0="4.2.0-beta.2",Kr={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:Z0,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:$0,options:{wms:{throwOnError:!1}},parse:async(e,t)=>ui(new TextDecoder().decode(e),t),parseSync:(e,t)=>ui(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>ui(e,t)};function $0(e){return e.startsWith("<?xml")}function ui(e,t){let r={...Kr.options.wms,...t?.wms},n=uu(e,r),s=r.minimalErrors?n:`WMS Service error: ${n}`;if(r.throwOnError)throw new Error(s);return s}function Ne(e){return Array.isArray(e)?e:e?[e]:[]}function Qr(e){let t=Ne(e);return t.length>0&&t.every(r=>typeof r=="string")?t:[]}function Zr(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function os(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function De(e){switch(e){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function fi(e,t){let r=Dt.parseTextSync?.(e,t),n=r.WMT_MS_Capabilities||r.WMS_Capabilities||r,s=tA(n);if(t?.inheritedLayerProps)for(let o of s.layers)hu(o,null);return t?.includeRawJSON&&(s.json=n),t?.includeXMLText&&(s.xml=e),s}function tA(e){let t={version:String(e.version||""),name:String(e.Service?.Name||"unnamed"),title:e.Service?.Title?String(e.Service?.Title):void 0,abstract:e.Service?.Abstract?String(e.Service?.Abstract):void 0,keywords:Qr(e.Service?.KeywordList?.Keyword),fees:e.Service?.Fees?JSON.stringify(e.Service?.Fees):void 0,accessConstraints:e.Service?.AccessConstraints?JSON.stringify(e.Service?.AccessConstraints):void 0,layerLimit:os(e.Service?.LayerLimit),maxWidth:os(e.Service?.maxWidth),maxHeight:os(e.Service?.maxHeight),layers:[],requests:eA(e.Capability?.Request),exceptions:rA(e.Exception)},r=Ne(e.Capability?.Layer);for(let n of r)t.layers.push(fu(n));for(let[n,s]of Object.entries(t))s===void 0&&delete t[n];return t}function eA(e){let t={};for(let[r,n]of Object.entries(e||{})){let s=Qr(n?.Format);t[r]={mimeTypes:s}}return t}function rA(e){if(Ne(e?.Format).length>0)return{mimeTypes:Qr(e)}}function fu(e){let t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:Qr(e.KeywordList?.Keyword)},r=e?.CRS||e?.SRS;r&&Array.isArray(r)&&r.every(l=>typeof l=="string")&&(t.crs=r);let n=e?.EX_GeographicBoundingBox&&nA(e?.EX_GeographicBoundingBox);n&&(t.geographicBoundingBox=n),n=e?.LatLonBoundingBox&&sA(e?.LatLonBoundingBox),n&&(t.geographicBoundingBox=n);let s=e?.BoundingBox&&oA(e?.BoundingBox);s&&s.length>0&&(t.boundingBoxes=s);let i=Ne(e?.Dimension).map(l=>aA(l));i.length&&(t.dimensions=i),e?.opaque&&(t.opaque=De(e?.opaque)),e?.cascaded&&(t.cascaded=De(e?.cascaded)),e?.queryable&&(t.queryable=De(e?.queryable));let a=Ne(e?.Layer),c=[];for(let l of a)c.push(fu(l));c.length>0&&(t.layers=c);for(let[l,u]of Object.entries(t))u===void 0&&delete t[l];return t}function nA(e){let{westBoundLongitude:t,northBoundLatitude:r,eastBoundLongitude:n,southBoundLatitude:s}=e;return[[t,s],[n,r]]}function sA(e){let{minx:t,miny:r,maxx:n,maxy:s}=e;return[[t,r],[n,s]]}function oA(e){return Ne(e).map(r=>iA(r))}function iA(e){let{CRS:t,SRS:r,minx:n,miny:s,maxx:o,maxy:i,resx:a,resy:c}=e,l={crs:t||r,boundingBox:[[Zr(n),Zr(s)],[Zr(o),Zr(i)]]};return a&&(l.xResolution=a),c&&(l.yResolution=c),l}function aA(e){let{name:t,units:r,value:n}=e,s={name:t,units:r,extent:n};return e.unitSymbol&&(s.unitSymbol=e.unitSymbol),e.default&&(s.defaultValue=e.default),e.multipleValues&&(s.multipleValues=De(e.multipleValues)),e.nearestValue&&(s.nearestValue=De(e.nearestValue)),e.current&&(s.current=De(e.current)),s}function hu(e,t){t?.geographicBoundingBox&&!e.geographicBoundingBox&&(e.geographicBoundingBox=[...t.geographicBoundingBox]),t?.crs&&!e.crs&&(e.crs=[...t.crs]),t?.boundingBoxes&&!e.boundingBoxes&&(e.boundingBoxes=[...t.boundingBoxes]),t?.dimensions&&!e.dimensions&&(e.dimensions=[...t.dimensions]);for(let r of e.layers||[])hu(r,e)}var cA="4.2.0-beta.2",fr={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:cA,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:lA,options:{wms:{}},parse:async(e,t)=>fi(new TextDecoder().decode(e),t?.wms),parseTextSync:(e,t)=>fi(e,t?.wms)};function lA(e){return e.startsWith("<?xml")}function hi(e,t){let n=(Dt.parseTextSync?.(e,t)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(n)?n:[n]).map(o=>uA(o))}}function uA(e){return{attributes:e||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var du={...fr,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>hi(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>hi(e,t)};function di(e,t){return Dt.parseTextSync?.(e,t)}var pu={...fr,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>di(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>di(e,t)};function mu(e,t){let{type:r="auto"}=e,n=r==="auto"?hA(e.url,t):fA(r,t);if(!n)throw new Error("Not a valid image source type");return n.create(e)}function fA(e,t){for(let r of t)if(r.type===e)return r;return null}function hA(e,t){for(let r of t)if(r.testURL&&r.testURL(e))return r;return null}var gu="4.2.0-beta.2";var dA=globalThis.loaders?.parseImageNode,pi=typeof Image<"u",mi=typeof ImageBitmap<"u",pA=Boolean(dA),gi=Jr?!0:pA;function Au(e){switch(e){case"auto":return mi||pi||gi;case"imagebitmap":return mi;case"image":return pi;case"data":return gi;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function xu(){if(mi)return"imagebitmap";if(pi)return"image";if(gi)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function yu(e){let t=mA(e);if(!t)throw new Error("Not an image");return t}function $r(e){switch(yu(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),r=t.getContext("2d");if(!r)throw new Error("getImageData");return t.width=e.width,t.height=e.height,r.drawImage(e,0,0),r.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function mA(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var gA=/^data:image\/svg\+xml/,AA=/\.svg((\?|#).*)?$/;function is(e){return e&&(gA.test(e)||AA.test(e))}function Tu(e,t){if(is(t)){let n=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(n=unescape(encodeURIComponent(n)))}catch(o){throw new Error(o.message)}return`data:image/svg+xml;base64,${btoa(n)}`}return Ai(e,t)}function Ai(e,t){if(is(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function as(e,t,r){let n=Tu(e,r),s=self.URL||self.webkitURL,o=typeof n!="string"&&s.createObjectURL(n);try{return await xA(o||n,t)}finally{o&&s.revokeObjectURL(o)}}async function xA(e,t){let r=new Image;return r.src=e,t.image&&t.image.decode&&r.decode?(await r.decode(),r):await new Promise((n,s)=>{try{r.onload=()=>n(r),r.onerror=o=>{let i=o instanceof Error?o.message:"error";s(new Error(i))}}catch(o){s(o)}})}var yA={},_u=!0;async function Eu(e,t,r){let n;is(r)?n=await as(e,t,r):n=Ai(e,r);let s=t&&t.imagebitmap;return await TA(n,s)}async function TA(e,t=null){if((_A(t)||!_u)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(r){console.warn(r),_u=!1}return await createImageBitmap(e)}function _A(e){for(let t in e||yA)return!1;return!0}function Bu(e){return!SA(e,"ftyp",4)||!(e[8]&96)?null:EA(e)}function EA(e){switch(BA(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function BA(e,t,r){return String.fromCharCode(...e.slice(t,r))}function CA(e){return[...e].map(t=>t.charCodeAt(0))}function SA(e,t,r=0){let n=CA(t);for(let s=0;s<n.length;++s)if(n[s]!==e[s+r])return!1;return!0}var Xt=!1,tn=!0;function ve(e){let t=en(e);return MA(t)||LA(t)||IA(t)||wA(t)||bA(t)}function bA(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),r=Bu(t);return r?{mimeType:r.mimeType,width:0,height:0}:null}function MA(e){let t=en(e);return t.byteLength>=24&&t.getUint32(0,Xt)===2303741511?{mimeType:"image/png",width:t.getUint32(16,Xt),height:t.getUint32(20,Xt)}:null}function IA(e){let t=en(e);return t.byteLength>=10&&t.getUint32(0,Xt)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,tn),height:t.getUint16(8,tn)}:null}function wA(e){let t=en(e);return t.byteLength>=14&&t.getUint16(0,Xt)===16973&&t.getUint32(2,tn)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,tn),height:t.getUint32(22,tn)}:null}function LA(e){let t=en(e);if(!(t.byteLength>=3&&t.getUint16(0,Xt)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:n,sofMarkers:s}=FA(),o=2;for(;o+9<t.byteLength;){let i=t.getUint16(o,Xt);if(s.has(i))return{mimeType:"image/jpeg",height:t.getUint16(o+5,Xt),width:t.getUint16(o+7,Xt)};if(!n.has(i))return null;o+=2,o+=t.getUint16(o,Xt)}return null}function FA(){let e=new Set([65499,65476,65484,65501,65534]);for(let r=65504;r<65520;++r)e.add(r);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function en(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function Cu(e,t){let{mimeType:r}=ve(e)||{},n=globalThis.loaders?.parseImageNode;return G(n),await n(e,r)}async function Su(e,t,r){t=t||{};let s=(t.image||{}).type||"auto",{url:o}=r||{},i=RA(s),a;switch(i){case"imagebitmap":a=await Eu(e,t,o);break;case"image":a=await as(e,t,o);break;case"data":a=await Cu(e,t);break;default:G(!1)}return s==="data"&&(a=$r(a)),a}function RA(e){switch(e){case"auto":case"data":return xu();default:return Au(e),e}}var PA=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],OA=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],NA={image:{type:"auto",decode:!0}},ge={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:gu,mimeTypes:OA,extensions:PA,parse:Su,tests:[e=>Boolean(ve(new DataView(e)))],options:NA};var xi={};function yi(e){if(xi[e]===void 0){let t=Jr?vA(e):DA(e);xi[e]=t}return xi[e]}function DA(e){let t=["image/png","image/jpeg","image/gif"],r=globalThis.loaders?.imageFormatsNode||t,n=globalThis.loaders?.parseImageNode;return Boolean(n)&&r.includes(e)}function vA(e){switch(e){case"image/avif":case"image/webp":return UA(e);default:return!0}}function UA(e){try{return document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)===0}catch{return!1}}var bu={type:"wms",testURL:e=>e.toLowerCase().includes("wms"),create:e=>new Ti(e)},Ti=class extends bt{url;data;substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(t){super(t),this.url=t.url,this.data=t.url,this.substituteCRS84=t.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...t.wmsParameters},this.vendorParameters=t.vendorParameters||{}}async getMetadata(){let t=await this.getCapabilities();return this.normalizeMetadata(t)}async getImage(t){let{boundingBox:r,bbox:n,...s}=t,o={bbox:r?[...r[0],...r[1]]:n,...s};return await this.getMap(o)}normalizeMetadata(t){return t}async getCapabilities(t,r){let n=this.getCapabilitiesURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);let i=await fr.parse(o,this.loadOptions);return this.capabilities=i,i}async getMap(t,r){let n=this.getMapURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);try{return await ge.parse(o,this.loadOptions)}catch{throw this._parseError(o)}}async getFeatureInfo(t,r){let n=this.getFeatureInfoURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),await du.parse(o,this.loadOptions)}async getFeatureInfoText(t,r){let n=this.getFeatureInfoURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),new TextDecoder().decode(o)}async describeLayer(t,r){let n=this.describeLayerURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();return this._checkResponse(s,o),await pu.parse(o,this.loadOptions)}async getLegendGraphic(t,r){let n=this.getLegendGraphicURL(t,r),s=await this.fetch(n),o=await s.arrayBuffer();this._checkResponse(s,o);try{return await ge.parse(o,this.loadOptions)}catch{throw this._parseError(o)}}getCapabilitiesURL(t,r){let n={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetCapabilities",n,r)}getMapURL(t,r){t=this._getWMS130Parameters(t);let n={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...t};return this._getWMSUrl("GetMap",n,r)}getFeatureInfoURL(t,r){t=this._getWMS130Parameters(t);let{boundingBox:n,bbox:s}=t;t.bbox=n?[...n[0],...n[1]]:s;let o={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...t};return this._getWMSUrl("GetFeatureInfo",o,r)}describeLayerURL(t,r){let n={version:this.wmsParameters.version,...t};return this._getWMSUrl("DescribeLayer",n,r)}getLegendGraphicURL(t,r){let n={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetLegendGraphic",n,r)}_parseWMSUrl(t){let[r,n]=t.split("?"),s=n.split("&"),o={};for(let i of s){let[a,c]=i.split("=");o[a]=c}return{url:r,parameters:o}}_getWMSUrl(t,r,n){let s=this.url,o=!0,i={service:"WMS",version:r.version,request:t,...r,...this.vendorParameters,...n},a=["transparent","time","elevation"];for(let[c,l]of Object.entries(i))(!a.includes(c)||l)&&(s+=o?"?":"&",o=!1,s+=this._getURLParameter(c,l,r));return encodeURI(s)}_getWMS130Parameters(t){let r={...t};return r.srs&&(r.crs=r.crs||r.srs,delete r.srs),r}_getURLParameter(t,r,n){switch(t){case"crs":n.version!=="1.3.0"?t="srs":this.substituteCRS84&&r==="EPSG:4326"&&(r="CRS:84");break;case"srs":n.version==="1.3.0"&&(t="crs");break;case"bbox":let s=this._flipBoundingBox(r,n);s&&(r=s);break;case"x":n.version==="1.3.0"&&(t="i");break;case"y":n.version==="1.3.0"&&(t="j");break;default:}return t=t.toUpperCase(),Array.isArray(r)?`${t}=${r.join(",")}`:`${t}=${r?String(r):""}`}_flipBoundingBox(t,r){if(!Array.isArray(t)||t.length!==4)return null;let n=r.version==="1.3.0"&&this.flipCRS.includes(r.crs||"")&&!(this.substituteCRS84&&r.crs==="EPSG:4326"),s=t;return n?[s[1],s[0],s[3],s[2]]:s}async _fetchArrayBuffer(t){let r=await this.fetch(t),n=await r.arrayBuffer();return this._checkResponse(r,n),n}_checkResponse(t,r){let n=t.headers["content-type"];if(!t.ok||Kr.mimeTypes.includes(n)){let s=ni(this.loadOptions,{wms:{throwOnError:!0}}),o=Kr.parseSync?.(r,s);throw new Error(o)}}_parseError(t){let r=Kr.parseSync?.(t,this.loadOptions);return new Error(r)}};var hr=class extends bt{constructor(t){super(t)}async getMetadata(){throw new Error("ImageSource.getMetadata not implemented")}async getImage(t){let r=this.getGranularParameters(t),n=this.getURLFromTemplate(r),o=await(await this.fetch(n)).arrayBuffer();return await ge.parse(o)}getGranularParameters(t){let[[r,n],[s,o]]=t.boundingBox;return{...t,east:r,north:n,south:o,west:s}}getURLFromTemplate(t){let r=this.props.url;for(let[n,s]of Object.entries(t))r=r.replace(`\${${n}}`,String(s)),r=r.replace(`{${n}}`,String(s));return r}};ar(hr,"type","template"),ar(hr,"testURL",t=>t.toLowerCase().includes("{"));var _i=class extends hr{data;constructor(t){super(t),this.data=t.url}async getMetadata(){return await this.metadata()}async getImage(t){throw new Error("not implemented")}async metadata(){throw new Error("not implemented")}exportImage(t){throw new Error("not implemented")}metadataURL(t){return`${this.props.url}?f=pjson`}exportImageURL(t){let r=`bbox=${t.bbox[0]},${t.bbox[1]},${t.bbox[2]},${t.bbox[3]}`,n=`size=${t.width},${t.height}`,s={...t,bbox:r,size:n};return delete s.width,delete s.height,this.getUrl("exportImage",s)}getUrl(t,r,n){let s=`${this.props.url}/${t}`,o=!0;for(let[i,a]of Object.entries(r))s+=o?"?":"&",o=!1,Array.isArray(a)?s+=`${i.toUpperCase()}=${a.join(",")}`:s+=`${i.toUpperCase()}=${a?String(a):""}`;return s}async checkResponse(t){if(!t.ok)throw new Error("error")}},Mu={type:"arcgis-image-server",testURL:e=>e.toLowerCase().includes("ImageServer"),create:e=>new _i(e)};var GA=[bu,Mu];function Ei(e){return mu(e,GA)}var VA=1/Math.PI*180,HA=1/180*Math.PI,zA={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...zA}};var Y=globalThis.mathgl.config;function Bi(e,{precision:t=Y.precision}={}){return e=kA(e),`${parseFloat(e.toPrecision(t))}`}function Bt(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Ci(e){return Iu(e)}function Si(e){return Ct(e)}function Iu(e,t){return bi(e,r=>r*HA,t)}function Ct(e,t){return bi(e,r=>r*VA,t)}function cs(e,t,r){return bi(e,n=>Math.max(t,Math.min(r,n)))}function Ae(e,t,r){return Bt(e)?e.map((n,s)=>Ae(n,t[s],r)):r*t+(1-r)*e}function mt(e,t,r){let n=Y.EPSILON;r&&(Y.EPSILON=r);try{if(e===t)return!0;if(Bt(e)&&Bt(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!mt(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=Y.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{Y.EPSILON=n}}function kA(e){return Math.round(e/Y.EPSILON)*Y.EPSILON}function JA(e){return e.clone?e.clone():new Array(e.length)}function bi(e,t,r){if(Bt(e)){let n=e;r=r||JA(n);for(let s=0;s<r.length&&s<n.length;++s){let o=typeof e=="number"?e:e[s];r[s]=t(o,s,r)}return r}return t(e)}var xe=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,r=0){for(let n=0;n<this.ELEMENTS;++n)this[n]=t[n+r];return this.check()}toArray(t=[],r=0){for(let n=0;n<this.ELEMENTS;++n)t[r+n]=this[n];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Bt(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Y)}formatString(t){let r="";for(let n=0;n<this.ELEMENTS;++n)r+=(n>0?", ":"")+Bi(this[n],t);return`${t.printTypes?this.constructor.name:""}[${r}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(!mt(this[r],t[r]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let r=0;r<this.ELEMENTS;++r)if(this[r]!==t[r])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,r,n){if(n===void 0)return this.lerp(this,t,r);for(let s=0;s<this.ELEMENTS;++s){let o=t[s],i=typeof r=="number"?r:r[s];this[s]=o+n*(i-o)}return this.check()}min(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(t[r],this[r]);return this.check()}max(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.max(t[r],this[r]);return this.check()}clamp(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t[n]),r[n]);return this.check()}add(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]+=r[n];return this.check()}subtract(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]-=r[n];return this.check()}scale(t){if(typeof t=="number")for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;else for(let r=0;r<this.ELEMENTS&&r<t.length;++r)this[r]*=t[r];return this.check()}multiplyByScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}check(){if(Y.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let r=0;r<this.ELEMENTS;++r)t=t&&Number.isFinite(this[r]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]=t;return this.check()}addScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let r=0;r<this.ELEMENTS;++r)this[r]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,r){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(Math.max(this[n],t),r);return this.check()}get elements(){return this}};function qA(e,t){if(e.length!==t)return!1;for(let r=0;r<e.length;++r)if(!Number.isFinite(e[r]))return!1;return!0}function U(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function ye(e,t,r=""){if(Y.debug&&!qA(e,t))throw new Error(`math.gl: ${r} some fields set to invalid numbers'`);return e}function at(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Te=class extends xe{get x(){return this[0]}set x(t){this[0]=U(t)}get y(){return this[1]}set y(t){this[1]=U(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*this[r];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let r=0;for(let n=0;n<this.ELEMENTS;++n){let s=this[n]-t[n];r+=s*s}return U(r)}dot(t){let r=0;for(let n=0;n<this.ELEMENTS;++n)r+=this[n]*t[n];return U(r)}normalize(){let t=this.magnitude();if(t!==0)for(let r=0;r<this.ELEMENTS;++r)this[r]/=t;return this.check()}multiply(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]*=r[n];return this.check()}divide(...t){for(let r of t)for(let n=0;n<this.ELEMENTS;++n)this[n]/=r[n];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return at(t>=0&&t<this.ELEMENTS,"index is out of range"),U(this[t])}setComponent(t,r){return at(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=r,this.check()}addVectors(t,r){return this.copy(t).add(r)}subVectors(t,r){return this.copy(t).subtract(r)}multiplyVectors(t,r){return this.copy(t).multiply(r)}addScaledVector(t,r){return this.add(new this.constructor(t).multiplyScalar(r))}};var Z=typeof Float32Array<"u"?Float32Array:Array,rn=Math.random;function dr(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var G2=Math.PI/180;function jA(){let e=new Z(2);return Z!=Float32Array&&(e[0]=0,e[1]=0),e}function wu(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e}function Lu(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s+r[4],e[1]=r[1]*n+r[3]*s+r[5],e}function ls(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[3]*s+r[6],e[1]=r[1]*n+r[4]*s+r[7],e}function us(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[4]*s+r[12],e[1]=r[1]*n+r[5]*s+r[13],e}var V2=function(){let e=jA();return function(t,r,n,s,o,i){let a,c;for(r||(r=2),n||(n=0),s?c=Math.min(s*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],o(e,e,i),t[a]=e[0],t[a+1]=e[1];return t}}();function fs(e,t,r){let n=t[0],s=t[1],o=r[3]*n+r[7]*s||1;return e[0]=(r[0]*n+r[4]*s)/o,e[1]=(r[1]*n+r[5]*s)/o,e}function hs(e,t,r){let n=t[0],s=t[1],o=t[2],i=r[3]*n+r[7]*s+r[11]*o||1;return e[0]=(r[0]*n+r[4]*s+r[8]*o)/i,e[1]=(r[1]*n+r[5]*s+r[9]*o)/i,e[2]=(r[2]*n+r[6]*s+r[10]*o)/i,e}function Fu(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e[2]=t[2],e}function Ru(e,t,r){let n=t[0],s=t[1];return e[0]=r[0]*n+r[2]*s,e[1]=r[1]*n+r[3]*s,e[2]=t[2],e[3]=t[3],e}function ds(e,t,r){let n=t[0],s=t[1],o=t[2];return e[0]=r[0]*n+r[3]*s+r[6]*o,e[1]=r[1]*n+r[4]*s+r[7]*o,e[2]=r[2]*n+r[5]*s+r[8]*o,e[3]=t[3],e}var Ue=class extends Te{constructor(t=0,r=0){super(2),Bt(t)&&arguments.length===1?this.copy(t):(Y.debug&&(U(t),U(r)),this[0]=t,this[1]=r)}set(t,r){return this[0]=t,this[1]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return Y.debug&&(U(t.x),U(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return us(this,this,t),this.check()}transformAsVector(t){return fs(this,this,t),this.check()}transformByMatrix3(t){return ls(this,this,t),this.check()}transformByMatrix2x3(t){return Lu(this,this,t),this.check()}transformByMatrix2(t){return wu(this,this,t),this.check()}};var He={};ut(He,{add:()=>KA,angle:()=>Fi,bezier:()=>l1,ceil:()=>QA,clone:()=>XA,copy:()=>WA,create:()=>ps,cross:()=>Ge,dist:()=>x1,distance:()=>vu,div:()=>A1,divide:()=>Du,dot:()=>nn,equals:()=>p1,exactEquals:()=>d1,floor:()=>ZA,forEach:()=>_1,fromValues:()=>ms,hermite:()=>c1,inverse:()=>o1,len:()=>Ri,length:()=>Pu,lerp:()=>i1,max:()=>t1,min:()=>$A,mul:()=>g1,multiply:()=>Nu,negate:()=>s1,normalize:()=>Mi,random:()=>u1,rotateX:()=>Ii,rotateY:()=>wi,rotateZ:()=>Li,round:()=>e1,scale:()=>r1,scaleAndAdd:()=>n1,set:()=>YA,slerp:()=>a1,sqrDist:()=>y1,sqrLen:()=>T1,squaredDistance:()=>Uu,squaredLength:()=>Gu,str:()=>h1,sub:()=>m1,subtract:()=>Ou,transformMat3:()=>sn,transformMat4:()=>Ve,transformQuat:()=>on,zero:()=>f1});function ps(){let e=new Z(3);return Z!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function XA(e){let t=new Z(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Pu(e){let t=e[0],r=e[1],n=e[2];return Math.sqrt(t*t+r*r+n*n)}function ms(e,t,r){let n=new Z(3);return n[0]=e,n[1]=t,n[2]=r,n}function WA(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function YA(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function KA(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function Ou(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function Nu(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function Du(e,t,r){return e[0]=t[0]/r[0],e[1]=t[1]/r[1],e[2]=t[2]/r[2],e}function QA(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function ZA(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function $A(e,t,r){return e[0]=Math.min(t[0],r[0]),e[1]=Math.min(t[1],r[1]),e[2]=Math.min(t[2],r[2]),e}function t1(e,t,r){return e[0]=Math.max(t[0],r[0]),e[1]=Math.max(t[1],r[1]),e[2]=Math.max(t[2],r[2]),e}function e1(e,t){return e[0]=dr(t[0]),e[1]=dr(t[1]),e[2]=dr(t[2]),e}function r1(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function n1(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e}function vu(e,t){let r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(r*r+n*n+s*s)}function Uu(e,t){let r=t[0]-e[0],n=t[1]-e[1],s=t[2]-e[2];return r*r+n*n+s*s}function Gu(e){let t=e[0],r=e[1],n=e[2];return t*t+r*r+n*n}function s1(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function o1(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function Mi(e,t){let r=t[0],n=t[1],s=t[2],o=r*r+n*n+s*s;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function nn(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Ge(e,t,r){let n=t[0],s=t[1],o=t[2],i=r[0],a=r[1],c=r[2];return e[0]=s*c-o*a,e[1]=o*i-n*c,e[2]=n*a-s*i,e}function i1(e,t,r,n){let s=t[0],o=t[1],i=t[2];return e[0]=s+n*(r[0]-s),e[1]=o+n*(r[1]-o),e[2]=i+n*(r[2]-i),e}function a1(e,t,r,n){let s=Math.acos(Math.min(Math.max(nn(t,r),-1),1)),o=Math.sin(s),i=Math.sin((1-n)*s)/o,a=Math.sin(n*s)/o;return e[0]=i*t[0]+a*r[0],e[1]=i*t[1]+a*r[1],e[2]=i*t[2]+a*r[2],e}function c1(e,t,r,n,s,o){let i=o*o,a=i*(2*o-3)+1,c=i*(o-2)+o,l=i*(o-1),u=i*(3-2*o);return e[0]=t[0]*a+r[0]*c+n[0]*l+s[0]*u,e[1]=t[1]*a+r[1]*c+n[1]*l+s[1]*u,e[2]=t[2]*a+r[2]*c+n[2]*l+s[2]*u,e}function l1(e,t,r,n,s,o){let i=1-o,a=i*i,c=o*o,l=a*i,u=3*o*a,f=3*c*i,h=c*o;return e[0]=t[0]*l+r[0]*u+n[0]*f+s[0]*h,e[1]=t[1]*l+r[1]*u+n[1]*f+s[1]*h,e[2]=t[2]*l+r[2]*u+n[2]*f+s[2]*h,e}function u1(e,t){t=t===void 0?1:t;let r=rn()*2*Math.PI,n=rn()*2-1,s=Math.sqrt(1-n*n)*t;return e[0]=Math.cos(r)*s,e[1]=Math.sin(r)*s,e[2]=n*t,e}function Ve(e,t,r){let n=t[0],s=t[1],o=t[2],i=r[3]*n+r[7]*s+r[11]*o+r[15];return i=i||1,e[0]=(r[0]*n+r[4]*s+r[8]*o+r[12])/i,e[1]=(r[1]*n+r[5]*s+r[9]*o+r[13])/i,e[2]=(r[2]*n+r[6]*s+r[10]*o+r[14])/i,e}function sn(e,t,r){let n=t[0],s=t[1],o=t[2];return e[0]=n*r[0]+s*r[3]+o*r[6],e[1]=n*r[1]+s*r[4]+o*r[7],e[2]=n*r[2]+s*r[5]+o*r[8],e}function on(e,t,r){let n=r[0],s=r[1],o=r[2],i=r[3],a=t[0],c=t[1],l=t[2],u=s*l-o*c,f=o*a-n*l,h=n*c-s*a,d=s*h-o*f,p=o*u-n*h,A=n*f-s*u,g=i*2;return u*=g,f*=g,h*=g,d*=2,p*=2,A*=2,e[0]=a+u+d,e[1]=c+f+p,e[2]=l+h+A,e}function Ii(e,t,r,n){let s=[],o=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],o[0]=s[0],o[1]=s[1]*Math.cos(n)-s[2]*Math.sin(n),o[2]=s[1]*Math.sin(n)+s[2]*Math.cos(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function wi(e,t,r,n){let s=[],o=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],o[0]=s[2]*Math.sin(n)+s[0]*Math.cos(n),o[1]=s[1],o[2]=s[2]*Math.cos(n)-s[0]*Math.sin(n),e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Li(e,t,r,n){let s=[],o=[];return s[0]=t[0]-r[0],s[1]=t[1]-r[1],s[2]=t[2]-r[2],o[0]=s[0]*Math.cos(n)-s[1]*Math.sin(n),o[1]=s[0]*Math.sin(n)+s[1]*Math.cos(n),o[2]=s[2],e[0]=o[0]+r[0],e[1]=o[1]+r[1],e[2]=o[2]+r[2],e}function Fi(e,t){let r=e[0],n=e[1],s=e[2],o=t[0],i=t[1],a=t[2],c=Math.sqrt((r*r+n*n+s*s)*(o*o+i*i+a*a)),l=c&&nn(e,t)/c;return Math.acos(Math.min(Math.max(l,-1),1))}function f1(e){return e[0]=0,e[1]=0,e[2]=0,e}function h1(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function d1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function p1(e,t){let r=e[0],n=e[1],s=e[2],o=t[0],i=t[1],a=t[2];return Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(s-a)<=1e-6*Math.max(1,Math.abs(s),Math.abs(a))}var m1=Ou,g1=Nu,A1=Du,x1=vu,y1=Uu,Ri=Pu,T1=Gu,_1=function(){let e=ps();return function(t,r,n,s,o,i){let a,c;for(r||(r=3),n||(n=0),s?c=Math.min(s*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2];return t}}();var Pi=[0,0,0],gs,x=class extends Te{static get ZERO(){return gs||(gs=new x(0,0,0),Object.freeze(gs)),gs}constructor(t=0,r=0,n=0){super(-0,-0,-0),arguments.length===1&&Bt(t)?this.copy(t):(Y.debug&&(U(t),U(r),U(n)),this[0]=t,this[1]=r,this[2]=n)}set(t,r,n){return this[0]=t,this[1]=r,this[2]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return Y.debug&&(U(t.x),U(t.y),U(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=U(t)}angle(t){return Fi(this,t)}cross(t){return Ge(this,this,t),this.check()}rotateX({radians:t,origin:r=Pi}){return Ii(this,this,r,t),this.check()}rotateY({radians:t,origin:r=Pi}){return wi(this,this,r,t),this.check()}rotateZ({radians:t,origin:r=Pi}){return Li(this,this,r,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Ve(this,this,t),this.check()}transformAsVector(t){return hs(this,this,t),this.check()}transformByMatrix3(t){return sn(this,this,t),this.check()}transformByMatrix2(t){return Fu(this,this,t),this.check()}transformByQuaternion(t){return on(this,this,t),this.check()}};var As,mr=class extends Te{static get ZERO(){return As||(As=new mr(0,0,0,0),Object.freeze(As)),As}constructor(t=0,r=0,n=0,s=0){super(-0,-0,-0,-0),Bt(t)&&arguments.length===1?this.copy(t):(Y.debug&&(U(t),U(r),U(n),U(s)),this[0]=t,this[1]=r,this[2]=n,this[3]=s)}set(t,r,n,s){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,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 Y.debug&&(U(t.x),U(t.y),U(t.z),U(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]=U(t)}get w(){return this[3]}set w(t){this[3]=U(t)}transform(t){return Ve(this,this,t),this.check()}transformByMatrix3(t){return ds(this,this,t),this.check()}transformByMatrix2(t){return Ru(this,this,t),this.check()}transformByQuaternion(t){return on(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var gr=class extends xe{toString(){let t="[";if(Y.printRowMajor){t+="row-major:";for(let r=0;r<this.RANK;++r)for(let n=0;n<this.RANK;++n)t+=` ${this[n*this.RANK+r]}`}else{t+="column-major:";for(let r=0;r<this.ELEMENTS;++r)t+=` ${this[r]}`}return t+="]",t}getElementIndex(t,r){return r*this.RANK+t}getElement(t,r){return this[r*this.RANK+t]}setElement(t,r,n){return this[r*this.RANK+t]=U(n),this}getColumn(t,r=new Array(this.RANK).fill(-0)){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)r[s]=this[n+s];return r}setColumn(t,r){let n=t*this.RANK;for(let s=0;s<this.RANK;++s)this[n+s]=r[s];return this}};function Vu(){let e=new Z(9);return Z!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Hu(e,t){if(e===t){let r=t[1],n=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function zu(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=u*i-a*l,h=-u*o+a*c,d=l*o-i*c,p=r*f+n*h+s*d;return p?(p=1/p,e[0]=f*p,e[1]=(-u*n+s*l)*p,e[2]=(a*n-s*i)*p,e[3]=h*p,e[4]=(u*r-s*c)*p,e[5]=(-a*r+s*o)*p,e[6]=d*p,e[7]=(-l*r+n*c)*p,e[8]=(i*r-n*o)*p,e):null}function ku(e){let t=e[0],r=e[1],n=e[2],s=e[3],o=e[4],i=e[5],a=e[6],c=e[7],l=e[8];return t*(l*o-i*c)+r*(-l*s+i*a)+n*(c*s-o*a)}function Oi(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=r[0],d=r[1],p=r[2],A=r[3],g=r[4],y=r[5],E=r[6],_=r[7],B=r[8];return e[0]=h*n+d*i+p*l,e[1]=h*s+d*a+p*u,e[2]=h*o+d*c+p*f,e[3]=A*n+g*i+y*l,e[4]=A*s+g*a+y*u,e[5]=A*o+g*c+y*f,e[6]=E*n+_*i+B*l,e[7]=E*s+_*a+B*u,e[8]=E*o+_*c+B*f,e}function Ju(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=r[0],d=r[1];return e[0]=n,e[1]=s,e[2]=o,e[3]=i,e[4]=a,e[5]=c,e[6]=h*n+d*i+l,e[7]=h*s+d*a+u,e[8]=h*o+d*c+f,e}function qu(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=Math.sin(r),d=Math.cos(r);return e[0]=d*n+h*i,e[1]=d*s+h*a,e[2]=d*o+h*c,e[3]=d*i-h*n,e[4]=d*a-h*s,e[5]=d*c-h*o,e[6]=l,e[7]=u,e[8]=f,e}function Ni(e,t,r){let n=r[0],s=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function ju(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=r+r,a=n+n,c=s+s,l=r*i,u=n*i,f=n*a,h=s*i,d=s*a,p=s*c,A=o*i,g=o*a,y=o*c;return e[0]=1-f-p,e[3]=u-y,e[6]=h+g,e[1]=u+y,e[4]=1-l-p,e[7]=d-A,e[2]=h-g,e[5]=d+A,e[8]=1-l-f,e}var Di;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(Di||(Di={}));var B1=Object.freeze([1,0,0,0,1,0,0,0,1]),z=class extends gr{static get IDENTITY(){return S1()}static get ZERO(){return C1()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Di}constructor(t,...r){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):r.length>0?this.copy([t,...r]):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(B1)}fromObject(t){return this.check()}fromQuaternion(t){return ju(this,t),this.check()}set(t,r,n,s,o,i,a,c,l){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this.check()}setRowMajor(t,r,n,s,o,i,a,c,l){return this[0]=t,this[1]=s,this[2]=a,this[3]=r,this[4]=o,this[5]=c,this[6]=n,this[7]=i,this[8]=l,this.check()}determinant(){return ku(this)}transpose(){return Hu(this,this),this.check()}invert(){return zu(this,this),this.check()}multiplyLeft(t){return Oi(this,t,this),this.check()}multiplyRight(t){return Oi(this,this,t),this.check()}rotate(t){return qu(this,this,t),this.check()}scale(t){return Array.isArray(t)?Ni(this,this,t):Ni(this,this,[t,t]),this.check()}translate(t){return Ju(this,this,t),this.check()}transform(t,r){let n;switch(t.length){case 2:n=ls(r||[-0,-0],t,this);break;case 3:n=sn(r||[-0,-0,-0],t,this);break;case 4:n=ds(r||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(n,t.length),n}transformVector(t,r){return this.transform(t,r)}transformVector2(t,r){return this.transform(t,r)}transformVector3(t,r){return this.transform(t,r)}},xs,ys=null;function C1(){return xs||(xs=new z([0,0,0,0,0,0,0,0,0]),Object.freeze(xs)),xs}function S1(){return ys||(ys=new z,Object.freeze(ys)),ys}var cn={};ut(cn,{add:()=>K1,adjoint:()=>F1,clone:()=>M1,copy:()=>I1,create:()=>b1,decompose:()=>H1,determinant:()=>Gi,equals:()=>tx,exactEquals:()=>$1,frob:()=>Y1,fromQuat:()=>ji,fromQuat2:()=>U1,fromRotation:()=>O1,fromRotationTranslation:()=>Wu,fromRotationTranslationScale:()=>z1,fromRotationTranslationScaleOrigin:()=>k1,fromScaling:()=>P1,fromTranslation:()=>R1,fromValues:()=>w1,fromXRotation:()=>N1,fromYRotation:()=>D1,fromZRotation:()=>v1,frustum:()=>Xi,getRotation:()=>V1,getScaling:()=>Yu,getTranslation:()=>G1,identity:()=>Xu,invert:()=>Ui,lookAt:()=>Ki,mul:()=>ex,multiply:()=>an,multiplyScalar:()=>Q1,multiplyScalarAndAdd:()=>Z1,ortho:()=>Yi,orthoNO:()=>Qu,orthoZO:()=>j1,perspective:()=>Wi,perspectiveFromFieldOfView:()=>q1,perspectiveNO:()=>Ku,perspectiveZO:()=>J1,rotate:()=>zi,rotateX:()=>ki,rotateY:()=>Ji,rotateZ:()=>qi,scale:()=>Hi,set:()=>L1,str:()=>W1,sub:()=>rx,subtract:()=>Zu,targetTo:()=>X1,translate:()=>Vi,transpose:()=>vi});function b1(){let e=new Z(16);return Z!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function M1(e){let t=new Z(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function I1(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function w1(e,t,r,n,s,o,i,a,c,l,u,f,h,d,p,A){let g=new Z(16);return g[0]=e,g[1]=t,g[2]=r,g[3]=n,g[4]=s,g[5]=o,g[6]=i,g[7]=a,g[8]=c,g[9]=l,g[10]=u,g[11]=f,g[12]=h,g[13]=d,g[14]=p,g[15]=A,g}function L1(e,t,r,n,s,o,i,a,c,l,u,f,h,d,p,A,g){return e[0]=t,e[1]=r,e[2]=n,e[3]=s,e[4]=o,e[5]=i,e[6]=a,e[7]=c,e[8]=l,e[9]=u,e[10]=f,e[11]=h,e[12]=d,e[13]=p,e[14]=A,e[15]=g,e}function Xu(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vi(e,t){if(e===t){let r=t[1],n=t[2],s=t[3],o=t[6],i=t[7],a=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=r,e[6]=t[9],e[7]=t[13],e[8]=n,e[9]=o,e[11]=t[14],e[12]=s,e[13]=i,e[14]=a}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function Ui(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],A=t[13],g=t[14],y=t[15],E=r*a-n*i,_=r*c-s*i,B=r*l-o*i,S=n*c-s*a,b=n*l-o*a,w=s*l-o*c,C=u*A-f*p,T=u*g-h*p,m=u*y-d*p,M=f*g-h*A,F=f*y-d*A,R=h*y-d*g,L=E*R-_*F+B*M+S*m-b*T+w*C;return L?(L=1/L,e[0]=(a*R-c*F+l*M)*L,e[1]=(s*F-n*R-o*M)*L,e[2]=(A*w-g*b+y*S)*L,e[3]=(h*b-f*w-d*S)*L,e[4]=(c*m-i*R-l*T)*L,e[5]=(r*R-s*m+o*T)*L,e[6]=(g*B-p*w-y*_)*L,e[7]=(u*w-h*B+d*_)*L,e[8]=(i*F-a*m+l*C)*L,e[9]=(n*m-r*F-o*C)*L,e[10]=(p*b-A*B+y*E)*L,e[11]=(f*B-u*b-d*E)*L,e[12]=(a*T-i*M-c*C)*L,e[13]=(r*M-n*T+s*C)*L,e[14]=(A*_-p*S-g*E)*L,e[15]=(u*S-f*_+h*E)*L,e):null}function F1(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=t[4],a=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],p=t[12],A=t[13],g=t[14],y=t[15],E=r*a-n*i,_=r*c-s*i,B=r*l-o*i,S=n*c-s*a,b=n*l-o*a,w=s*l-o*c,C=u*A-f*p,T=u*g-h*p,m=u*y-d*p,M=f*g-h*A,F=f*y-d*A,R=h*y-d*g;return e[0]=a*R-c*F+l*M,e[1]=s*F-n*R-o*M,e[2]=A*w-g*b+y*S,e[3]=h*b-f*w-d*S,e[4]=c*m-i*R-l*T,e[5]=r*R-s*m+o*T,e[6]=g*B-p*w-y*_,e[7]=u*w-h*B+d*_,e[8]=i*F-a*m+l*C,e[9]=n*m-r*F-o*C,e[10]=p*b-A*B+y*E,e[11]=f*B-u*b-d*E,e[12]=a*T-i*M-c*C,e[13]=r*M-n*T+s*C,e[14]=A*_-p*S-g*E,e[15]=u*S-f*_+h*E,e}function Gi(e){let t=e[0],r=e[1],n=e[2],s=e[3],o=e[4],i=e[5],a=e[6],c=e[7],l=e[8],u=e[9],f=e[10],h=e[11],d=e[12],p=e[13],A=e[14],g=e[15],y=t*i-r*o,E=t*a-n*o,_=r*a-n*i,B=l*p-u*d,S=l*A-f*d,b=u*A-f*p,w=t*b-r*S+n*B,C=o*b-i*S+a*B,T=l*_-u*E+f*y,m=d*_-p*E+A*y;return c*w-s*C+g*T-h*m}function an(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=t[9],d=t[10],p=t[11],A=t[12],g=t[13],y=t[14],E=t[15],_=r[0],B=r[1],S=r[2],b=r[3];return e[0]=_*n+B*a+S*f+b*A,e[1]=_*s+B*c+S*h+b*g,e[2]=_*o+B*l+S*d+b*y,e[3]=_*i+B*u+S*p+b*E,_=r[4],B=r[5],S=r[6],b=r[7],e[4]=_*n+B*a+S*f+b*A,e[5]=_*s+B*c+S*h+b*g,e[6]=_*o+B*l+S*d+b*y,e[7]=_*i+B*u+S*p+b*E,_=r[8],B=r[9],S=r[10],b=r[11],e[8]=_*n+B*a+S*f+b*A,e[9]=_*s+B*c+S*h+b*g,e[10]=_*o+B*l+S*d+b*y,e[11]=_*i+B*u+S*p+b*E,_=r[12],B=r[13],S=r[14],b=r[15],e[12]=_*n+B*a+S*f+b*A,e[13]=_*s+B*c+S*h+b*g,e[14]=_*o+B*l+S*d+b*y,e[15]=_*i+B*u+S*p+b*E,e}function Vi(e,t,r){let n=r[0],s=r[1],o=r[2],i,a,c,l,u,f,h,d,p,A,g,y;return t===e?(e[12]=t[0]*n+t[4]*s+t[8]*o+t[12],e[13]=t[1]*n+t[5]*s+t[9]*o+t[13],e[14]=t[2]*n+t[6]*s+t[10]*o+t[14],e[15]=t[3]*n+t[7]*s+t[11]*o+t[15]):(i=t[0],a=t[1],c=t[2],l=t[3],u=t[4],f=t[5],h=t[6],d=t[7],p=t[8],A=t[9],g=t[10],y=t[11],e[0]=i,e[1]=a,e[2]=c,e[3]=l,e[4]=u,e[5]=f,e[6]=h,e[7]=d,e[8]=p,e[9]=A,e[10]=g,e[11]=y,e[12]=i*n+u*s+p*o+t[12],e[13]=a*n+f*s+A*o+t[13],e[14]=c*n+h*s+g*o+t[14],e[15]=l*n+d*s+y*o+t[15]),e}function Hi(e,t,r){let n=r[0],s=r[1],o=r[2];return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*o,e[9]=t[9]*o,e[10]=t[10]*o,e[11]=t[11]*o,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function zi(e,t,r,n){let s=n[0],o=n[1],i=n[2],a=Math.sqrt(s*s+o*o+i*i),c,l,u,f,h,d,p,A,g,y,E,_,B,S,b,w,C,T,m,M,F,R,L,D;return a<1e-6?null:(a=1/a,s*=a,o*=a,i*=a,l=Math.sin(r),c=Math.cos(r),u=1-c,f=t[0],h=t[1],d=t[2],p=t[3],A=t[4],g=t[5],y=t[6],E=t[7],_=t[8],B=t[9],S=t[10],b=t[11],w=s*s*u+c,C=o*s*u+i*l,T=i*s*u-o*l,m=s*o*u-i*l,M=o*o*u+c,F=i*o*u+s*l,R=s*i*u+o*l,L=o*i*u-s*l,D=i*i*u+c,e[0]=f*w+A*C+_*T,e[1]=h*w+g*C+B*T,e[2]=d*w+y*C+S*T,e[3]=p*w+E*C+b*T,e[4]=f*m+A*M+_*F,e[5]=h*m+g*M+B*F,e[6]=d*m+y*M+S*F,e[7]=p*m+E*M+b*F,e[8]=f*R+A*L+_*D,e[9]=h*R+g*L+B*D,e[10]=d*R+y*L+S*D,e[11]=p*R+E*L+b*D,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ki(e,t,r){let n=Math.sin(r),s=Math.cos(r),o=t[4],i=t[5],a=t[6],c=t[7],l=t[8],u=t[9],f=t[10],h=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=o*s+l*n,e[5]=i*s+u*n,e[6]=a*s+f*n,e[7]=c*s+h*n,e[8]=l*s-o*n,e[9]=u*s-i*n,e[10]=f*s-a*n,e[11]=h*s-c*n,e}function Ji(e,t,r){let n=Math.sin(r),s=Math.cos(r),o=t[0],i=t[1],a=t[2],c=t[3],l=t[8],u=t[9],f=t[10],h=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*s-l*n,e[1]=i*s-u*n,e[2]=a*s-f*n,e[3]=c*s-h*n,e[8]=o*n+l*s,e[9]=i*n+u*s,e[10]=a*n+f*s,e[11]=c*n+h*s,e}function qi(e,t,r){let n=Math.sin(r),s=Math.cos(r),o=t[0],i=t[1],a=t[2],c=t[3],l=t[4],u=t[5],f=t[6],h=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*s+l*n,e[1]=i*s+u*n,e[2]=a*s+f*n,e[3]=c*s+h*n,e[4]=l*s-o*n,e[5]=u*s-i*n,e[6]=f*s-a*n,e[7]=h*s-c*n,e}function R1(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function P1(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function O1(e,t,r){let n=r[0],s=r[1],o=r[2],i=Math.sqrt(n*n+s*s+o*o),a,c,l;return i<1e-6?null:(i=1/i,n*=i,s*=i,o*=i,c=Math.sin(t),a=Math.cos(t),l=1-a,e[0]=n*n*l+a,e[1]=s*n*l+o*c,e[2]=o*n*l-s*c,e[3]=0,e[4]=n*s*l-o*c,e[5]=s*s*l+a,e[6]=o*s*l+n*c,e[7]=0,e[8]=n*o*l+s*c,e[9]=s*o*l-n*c,e[10]=o*o*l+a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function N1(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=n,e[6]=r,e[7]=0,e[8]=0,e[9]=-r,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function D1(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=0,e[2]=-r,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=r,e[9]=0,e[10]=n,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function v1(e,t){let r=Math.sin(t),n=Math.cos(t);return e[0]=n,e[1]=r,e[2]=0,e[3]=0,e[4]=-r,e[5]=n,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Wu(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=n+n,c=s+s,l=o+o,u=n*a,f=n*c,h=n*l,d=s*c,p=s*l,A=o*l,g=i*a,y=i*c,E=i*l;return e[0]=1-(d+A),e[1]=f+E,e[2]=h-y,e[3]=0,e[4]=f-E,e[5]=1-(u+A),e[6]=p+g,e[7]=0,e[8]=h+y,e[9]=p-g,e[10]=1-(u+d),e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function U1(e,t){let r=new Z(3),n=-t[0],s=-t[1],o=-t[2],i=t[3],a=t[4],c=t[5],l=t[6],u=t[7],f=n*n+s*s+o*o+i*i;return f>0?(r[0]=(a*i+u*n+c*o-l*s)*2/f,r[1]=(c*i+u*s+l*n-a*o)*2/f,r[2]=(l*i+u*o+a*s-c*n)*2/f):(r[0]=(a*i+u*n+c*o-l*s)*2,r[1]=(c*i+u*s+l*n-a*o)*2,r[2]=(l*i+u*o+a*s-c*n)*2),Wu(e,t,r),e}function G1(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Yu(e,t){let r=t[0],n=t[1],s=t[2],o=t[4],i=t[5],a=t[6],c=t[8],l=t[9],u=t[10];return e[0]=Math.sqrt(r*r+n*n+s*s),e[1]=Math.sqrt(o*o+i*i+a*a),e[2]=Math.sqrt(c*c+l*l+u*u),e}function V1(e,t){let r=new Z(3);Yu(r,t);let n=1/r[0],s=1/r[1],o=1/r[2],i=t[0]*n,a=t[1]*s,c=t[2]*o,l=t[4]*n,u=t[5]*s,f=t[6]*o,h=t[8]*n,d=t[9]*s,p=t[10]*o,A=i+u+p,g=0;return A>0?(g=Math.sqrt(A+1)*2,e[3]=.25*g,e[0]=(f-d)/g,e[1]=(h-c)/g,e[2]=(a-l)/g):i>u&&i>p?(g=Math.sqrt(1+i-u-p)*2,e[3]=(f-d)/g,e[0]=.25*g,e[1]=(a+l)/g,e[2]=(h+c)/g):u>p?(g=Math.sqrt(1+u-i-p)*2,e[3]=(h-c)/g,e[0]=(a+l)/g,e[1]=.25*g,e[2]=(f+d)/g):(g=Math.sqrt(1+p-i-u)*2,e[3]=(a-l)/g,e[0]=(h+c)/g,e[1]=(f+d)/g,e[2]=.25*g),e}function H1(e,t,r,n){t[0]=n[12],t[1]=n[13],t[2]=n[14];let s=n[0],o=n[1],i=n[2],a=n[4],c=n[5],l=n[6],u=n[8],f=n[9],h=n[10];r[0]=Math.sqrt(s*s+o*o+i*i),r[1]=Math.sqrt(a*a+c*c+l*l),r[2]=Math.sqrt(u*u+f*f+h*h);let d=1/r[0],p=1/r[1],A=1/r[2],g=s*d,y=o*p,E=i*A,_=a*d,B=c*p,S=l*A,b=u*d,w=f*p,C=h*A,T=g+B+C,m=0;return T>0?(m=Math.sqrt(T+1)*2,e[3]=.25*m,e[0]=(S-w)/m,e[1]=(b-E)/m,e[2]=(y-_)/m):g>B&&g>C?(m=Math.sqrt(1+g-B-C)*2,e[3]=(S-w)/m,e[0]=.25*m,e[1]=(y+_)/m,e[2]=(b+E)/m):B>C?(m=Math.sqrt(1+B-g-C)*2,e[3]=(b-E)/m,e[0]=(y+_)/m,e[1]=.25*m,e[2]=(S+w)/m):(m=Math.sqrt(1+C-g-B)*2,e[3]=(y-_)/m,e[0]=(b+E)/m,e[1]=(S+w)/m,e[2]=.25*m),e}function z1(e,t,r,n){let s=t[0],o=t[1],i=t[2],a=t[3],c=s+s,l=o+o,u=i+i,f=s*c,h=s*l,d=s*u,p=o*l,A=o*u,g=i*u,y=a*c,E=a*l,_=a*u,B=n[0],S=n[1],b=n[2];return e[0]=(1-(p+g))*B,e[1]=(h+_)*B,e[2]=(d-E)*B,e[3]=0,e[4]=(h-_)*S,e[5]=(1-(f+g))*S,e[6]=(A+y)*S,e[7]=0,e[8]=(d+E)*b,e[9]=(A-y)*b,e[10]=(1-(f+p))*b,e[11]=0,e[12]=r[0],e[13]=r[1],e[14]=r[2],e[15]=1,e}function k1(e,t,r,n,s){let o=t[0],i=t[1],a=t[2],c=t[3],l=o+o,u=i+i,f=a+a,h=o*l,d=o*u,p=o*f,A=i*u,g=i*f,y=a*f,E=c*l,_=c*u,B=c*f,S=n[0],b=n[1],w=n[2],C=s[0],T=s[1],m=s[2],M=(1-(A+y))*S,F=(d+B)*S,R=(p-_)*S,L=(d-B)*b,D=(1-(h+y))*b,X=(g+E)*b,H=(p+_)*w,Q=(g-E)*w,j=(1-(h+A))*w;return e[0]=M,e[1]=F,e[2]=R,e[3]=0,e[4]=L,e[5]=D,e[6]=X,e[7]=0,e[8]=H,e[9]=Q,e[10]=j,e[11]=0,e[12]=r[0]+C-(M*C+L*T+H*m),e[13]=r[1]+T-(F*C+D*T+Q*m),e[14]=r[2]+m-(R*C+X*T+j*m),e[15]=1,e}function ji(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=r+r,a=n+n,c=s+s,l=r*i,u=n*i,f=n*a,h=s*i,d=s*a,p=s*c,A=o*i,g=o*a,y=o*c;return e[0]=1-f-p,e[1]=u+y,e[2]=h-g,e[3]=0,e[4]=u-y,e[5]=1-l-p,e[6]=d+A,e[7]=0,e[8]=h+g,e[9]=d-A,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Xi(e,t,r,n,s,o,i){let a=1/(r-t),c=1/(s-n),l=1/(o-i);return e[0]=o*2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o*2*c,e[6]=0,e[7]=0,e[8]=(r+t)*a,e[9]=(s+n)*c,e[10]=(i+o)*l,e[11]=-1,e[12]=0,e[13]=0,e[14]=i*o*2*l,e[15]=0,e}function Ku(e,t,r,n,s){let o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let i=1/(n-s);e[10]=(s+n)*i,e[14]=2*s*n*i}else e[10]=-1,e[14]=-2*n;return e}var Wi=Ku;function J1(e,t,r,n,s){let o=1/Math.tan(t/2);if(e[0]=o/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let i=1/(n-s);e[10]=s*i,e[14]=s*n*i}else e[10]=-1,e[14]=-n;return e}function q1(e,t,r,n){let s=Math.tan(t.upDegrees*Math.PI/180),o=Math.tan(t.downDegrees*Math.PI/180),i=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),c=2/(i+a),l=2/(s+o);return e[0]=c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=l,e[6]=0,e[7]=0,e[8]=-((i-a)*c*.5),e[9]=(s-o)*l*.5,e[10]=n/(r-n),e[11]=-1,e[12]=0,e[13]=0,e[14]=n*r/(r-n),e[15]=0,e}function Qu(e,t,r,n,s,o,i){let a=1/(t-r),c=1/(n-s),l=1/(o-i);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*c,e[14]=(i+o)*l,e[15]=1,e}var Yi=Qu;function j1(e,t,r,n,s,o,i){let a=1/(t-r),c=1/(n-s),l=1/(o-i);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*c,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=l,e[11]=0,e[12]=(t+r)*a,e[13]=(s+n)*c,e[14]=o*l,e[15]=1,e}function Ki(e,t,r,n){let s,o,i,a,c,l,u,f,h,d,p=t[0],A=t[1],g=t[2],y=n[0],E=n[1],_=n[2],B=r[0],S=r[1],b=r[2];return Math.abs(p-B)<1e-6&&Math.abs(A-S)<1e-6&&Math.abs(g-b)<1e-6?Xu(e):(f=p-B,h=A-S,d=g-b,s=1/Math.sqrt(f*f+h*h+d*d),f*=s,h*=s,d*=s,o=E*d-_*h,i=_*f-y*d,a=y*h-E*f,s=Math.sqrt(o*o+i*i+a*a),s?(s=1/s,o*=s,i*=s,a*=s):(o=0,i=0,a=0),c=h*a-d*i,l=d*o-f*a,u=f*i-h*o,s=Math.sqrt(c*c+l*l+u*u),s?(s=1/s,c*=s,l*=s,u*=s):(c=0,l=0,u=0),e[0]=o,e[1]=c,e[2]=f,e[3]=0,e[4]=i,e[5]=l,e[6]=h,e[7]=0,e[8]=a,e[9]=u,e[10]=d,e[11]=0,e[12]=-(o*p+i*A+a*g),e[13]=-(c*p+l*A+u*g),e[14]=-(f*p+h*A+d*g),e[15]=1,e)}function X1(e,t,r,n){let s=t[0],o=t[1],i=t[2],a=n[0],c=n[1],l=n[2],u=s-r[0],f=o-r[1],h=i-r[2],d=u*u+f*f+h*h;d>0&&(d=1/Math.sqrt(d),u*=d,f*=d,h*=d);let p=c*h-l*f,A=l*u-a*h,g=a*f-c*u;return d=p*p+A*A+g*g,d>0&&(d=1/Math.sqrt(d),p*=d,A*=d,g*=d),e[0]=p,e[1]=A,e[2]=g,e[3]=0,e[4]=f*g-h*A,e[5]=h*p-u*g,e[6]=u*A-f*p,e[7]=0,e[8]=u,e[9]=f,e[10]=h,e[11]=0,e[12]=s,e[13]=o,e[14]=i,e[15]=1,e}function W1(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function Y1(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function K1(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e[4]=t[4]+r[4],e[5]=t[5]+r[5],e[6]=t[6]+r[6],e[7]=t[7]+r[7],e[8]=t[8]+r[8],e[9]=t[9]+r[9],e[10]=t[10]+r[10],e[11]=t[11]+r[11],e[12]=t[12]+r[12],e[13]=t[13]+r[13],e[14]=t[14]+r[14],e[15]=t[15]+r[15],e}function Zu(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e[3]=t[3]-r[3],e[4]=t[4]-r[4],e[5]=t[5]-r[5],e[6]=t[6]-r[6],e[7]=t[7]-r[7],e[8]=t[8]-r[8],e[9]=t[9]-r[9],e[10]=t[10]-r[10],e[11]=t[11]-r[11],e[12]=t[12]-r[12],e[13]=t[13]-r[13],e[14]=t[14]-r[14],e[15]=t[15]-r[15],e}function Q1(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*r,e[5]=t[5]*r,e[6]=t[6]*r,e[7]=t[7]*r,e[8]=t[8]*r,e[9]=t[9]*r,e[10]=t[10]*r,e[11]=t[11]*r,e[12]=t[12]*r,e[13]=t[13]*r,e[14]=t[14]*r,e[15]=t[15]*r,e}function Z1(e,t,r,n){return e[0]=t[0]+r[0]*n,e[1]=t[1]+r[1]*n,e[2]=t[2]+r[2]*n,e[3]=t[3]+r[3]*n,e[4]=t[4]+r[4]*n,e[5]=t[5]+r[5]*n,e[6]=t[6]+r[6]*n,e[7]=t[7]+r[7]*n,e[8]=t[8]+r[8]*n,e[9]=t[9]+r[9]*n,e[10]=t[10]+r[10]*n,e[11]=t[11]+r[11]*n,e[12]=t[12]+r[12]*n,e[13]=t[13]+r[13]*n,e[14]=t[14]+r[14]*n,e[15]=t[15]+r[15]*n,e}function $1(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function tx(e,t){let r=e[0],n=e[1],s=e[2],o=e[3],i=e[4],a=e[5],c=e[6],l=e[7],u=e[8],f=e[9],h=e[10],d=e[11],p=e[12],A=e[13],g=e[14],y=e[15],E=t[0],_=t[1],B=t[2],S=t[3],b=t[4],w=t[5],C=t[6],T=t[7],m=t[8],M=t[9],F=t[10],R=t[11],L=t[12],D=t[13],X=t[14],H=t[15];return Math.abs(r-E)<=1e-6*Math.max(1,Math.abs(r),Math.abs(E))&&Math.abs(n-_)<=1e-6*Math.max(1,Math.abs(n),Math.abs(_))&&Math.abs(s-B)<=1e-6*Math.max(1,Math.abs(s),Math.abs(B))&&Math.abs(o-S)<=1e-6*Math.max(1,Math.abs(o),Math.abs(S))&&Math.abs(i-b)<=1e-6*Math.max(1,Math.abs(i),Math.abs(b))&&Math.abs(a-w)<=1e-6*Math.max(1,Math.abs(a),Math.abs(w))&&Math.abs(c-C)<=1e-6*Math.max(1,Math.abs(c),Math.abs(C))&&Math.abs(l-T)<=1e-6*Math.max(1,Math.abs(l),Math.abs(T))&&Math.abs(u-m)<=1e-6*Math.max(1,Math.abs(u),Math.abs(m))&&Math.abs(f-M)<=1e-6*Math.max(1,Math.abs(f),Math.abs(M))&&Math.abs(h-F)<=1e-6*Math.max(1,Math.abs(h),Math.abs(F))&&Math.abs(d-R)<=1e-6*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(p-L)<=1e-6*Math.max(1,Math.abs(p),Math.abs(L))&&Math.abs(A-D)<=1e-6*Math.max(1,Math.abs(A),Math.abs(D))&&Math.abs(g-X)<=1e-6*Math.max(1,Math.abs(g),Math.abs(X))&&Math.abs(y-H)<=1e-6*Math.max(1,Math.abs(y),Math.abs(H))}var ex=an,rx=Zu;function nx(){let e=new Z(4);return Z!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function $u(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e[3]=t[3]+r[3],e}function tf(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e}function ef(e){let t=e[0],r=e[1],n=e[2],s=e[3];return Math.sqrt(t*t+r*r+n*n+s*s)}function rf(e){let t=e[0],r=e[1],n=e[2],s=e[3];return t*t+r*r+n*n+s*s}function nf(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=r*r+n*n+s*s+o*o;return i>0&&(i=1/Math.sqrt(i)),e[0]=r*i,e[1]=n*i,e[2]=s*i,e[3]=o*i,e}function sf(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function of(e,t,r,n){let s=t[0],o=t[1],i=t[2],a=t[3];return e[0]=s+n*(r[0]-s),e[1]=o+n*(r[1]-o),e[2]=i+n*(r[2]-i),e[3]=a+n*(r[3]-a),e}function af(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3];return e[0]=r[0]*n+r[4]*s+r[8]*o+r[12]*i,e[1]=r[1]*n+r[5]*s+r[9]*o+r[13]*i,e[2]=r[2]*n+r[6]*s+r[10]*o+r[14]*i,e[3]=r[3]*n+r[7]*s+r[11]*o+r[15]*i,e}function cf(e,t,r){let n=t[0],s=t[1],o=t[2],i=r[0],a=r[1],c=r[2],l=r[3],u=l*n+a*o-c*s,f=l*s+c*n-i*o,h=l*o+i*s-a*n,d=-i*n-a*s-c*o;return e[0]=u*l+d*-i+f*-c-h*-a,e[1]=f*l+d*-a+h*-i-u*-c,e[2]=h*l+d*-c+u*-a-f*-i,e[3]=t[3],e}var xw=function(){let e=nx();return function(t,r,n,s,o,i){let a,c;for(r||(r=4),n||(n=0),s?c=Math.min(s*r+n,t.length):c=t.length,a=n;a<c;a+=r)e[0]=t[a],e[1]=t[a+1],e[2]=t[a+2],e[3]=t[a+3],o(e,e,i),t[a]=e[0],t[a+1]=e[1],t[a+2]=e[2],t[a+3]=e[3];return t}}();var $i;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})($i||($i={}));var ox=45*Math.PI/180,ix=1,Qi=.1,Zi=500,ax=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),P=class extends gr{static get IDENTITY(){return lx()}static get ZERO(){return cx()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return $i}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,r,n,s,o,i,a,c,l,u,f,h,d,p,A,g){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,this[4]=o,this[5]=i,this[6]=a,this[7]=c,this[8]=l,this[9]=u,this[10]=f,this[11]=h,this[12]=d,this[13]=p,this[14]=A,this[15]=g,this.check()}setRowMajor(t,r,n,s,o,i,a,c,l,u,f,h,d,p,A,g){return this[0]=t,this[1]=o,this[2]=l,this[3]=d,this[4]=r,this[5]=i,this[6]=u,this[7]=p,this[8]=n,this[9]=a,this[10]=f,this[11]=A,this[12]=s,this[13]=c,this[14]=h,this[15]=g,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(ax)}fromObject(t){return this.check()}fromQuaternion(t){return ji(this,t),this.check()}frustum(t){let{left:r,right:n,bottom:s,top:o,near:i=Qi,far:a=Zi}=t;return a===1/0?ux(this,r,n,s,o,i):Xi(this,r,n,s,o,i,a),this.check()}lookAt(t){let{eye:r,center:n=[0,0,0],up:s=[0,1,0]}=t;return Ki(this,r,n,s),this.check()}ortho(t){let{left:r,right:n,bottom:s,top:o,near:i=Qi,far:a=Zi}=t;return Yi(this,r,n,s,o,i,a),this.check()}orthographic(t){let{fovy:r=ox,aspect:n=ix,focalDistance:s=1,near:o=Qi,far:i=Zi}=t;lf(r);let a=r/2,c=s*Math.tan(a),l=c*n;return this.ortho({left:-l,right:l,bottom:-c,top:c,near:o,far:i})}perspective(t){let{fovy:r=45*Math.PI/180,aspect:n=1,near:s=.1,far:o=500}=t;return lf(r),Wi(this,r,n,s,o),this.check()}determinant(){return Gi(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],o=1/n[1],i=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*o,t[2]=this[2]*i,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*o,t[6]=this[6]*i,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*o,t[10]=this[10]*i,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,r){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],r=r||[-0,-0,-0];let n=this.getScale(r),s=1/n[0],o=1/n[1],i=1/n[2];return t[0]=this[0]*s,t[1]=this[1]*o,t[2]=this[2]*i,t[3]=this[4]*s,t[4]=this[5]*o,t[5]=this[6]*i,t[6]=this[8]*s,t[7]=this[9]*o,t[8]=this[10]*i,t}transpose(){return vi(this,this),this.check()}invert(){return Ui(this,this),this.check()}multiplyLeft(t){return an(this,t,this),this.check()}multiplyRight(t){return an(this,this,t),this.check()}rotateX(t){return ki(this,this,t),this.check()}rotateY(t){return Ji(this,this,t),this.check()}rotateZ(t){return qi(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,r){return zi(this,this,t,r),this.check()}scale(t){return Hi(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return Vi(this,this,t),this.check()}transform(t,r){return t.length===4?(r=af(r||[-0,-0,-0,-0],t,this),ye(r,4),r):this.transformAsPoint(t,r)}transformAsPoint(t,r){let{length:n}=t,s;switch(n){case 2:s=us(r||[-0,-0],t,this);break;case 3:s=Ve(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(s,t.length),s}transformAsVector(t,r){let n;switch(t.length){case 2:n=fs(r||[-0,-0],t,this);break;case 3:n=hs(r||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ye(n,t.length),n}transformPoint(t,r){return this.transformAsPoint(t,r)}transformVector(t,r){return this.transformAsPoint(t,r)}transformDirection(t,r){return this.transformAsVector(t,r)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,r,n){return this.identity().translate([t,r,n])}},Ts,_s;function cx(){return Ts||(Ts=new P([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ts)),Ts}function lx(){return _s||(_s=new P,Object.freeze(_s)),_s}function lf(e){if(e>Math.PI*2)throw Error("expected radians")}function ux(e,t,r,n,s,o){let i=2*o/(r-t),a=2*o/(s-n),c=(r+t)/(r-t),l=(s+n)/(s-n),u=-1,f=-1,h=-2*o;return e[0]=i,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=f,e[12]=0,e[13]=0,e[14]=h,e[15]=0,e}function uf(){let e=new Z(4);return Z!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function ff(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function ta(e,t,r){r=r*.5;let n=Math.sin(r);return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=Math.cos(r),e}function ea(e,t,r){let n=t[0],s=t[1],o=t[2],i=t[3],a=r[0],c=r[1],l=r[2],u=r[3];return e[0]=n*u+i*a+s*l-o*c,e[1]=s*u+i*c+o*a-n*l,e[2]=o*u+i*l+n*c-s*a,e[3]=i*u-n*a-s*c-o*l,e}function hf(e,t,r){r*=.5;let n=t[0],s=t[1],o=t[2],i=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+i*a,e[1]=s*c+o*a,e[2]=o*c-s*a,e[3]=i*c-n*a,e}function df(e,t,r){r*=.5;let n=t[0],s=t[1],o=t[2],i=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c-o*a,e[1]=s*c+i*a,e[2]=o*c+n*a,e[3]=i*c-s*a,e}function pf(e,t,r){r*=.5;let n=t[0],s=t[1],o=t[2],i=t[3],a=Math.sin(r),c=Math.cos(r);return e[0]=n*c+s*a,e[1]=s*c-n*a,e[2]=o*c+i*a,e[3]=i*c-o*a,e}function mf(e,t){let r=t[0],n=t[1],s=t[2];return e[0]=r,e[1]=n,e[2]=s,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-s*s)),e}function ln(e,t,r,n){let s=t[0],o=t[1],i=t[2],a=t[3],c=r[0],l=r[1],u=r[2],f=r[3],h,d,p,A,g;return h=s*c+o*l+i*u+a*f,h<0&&(h=-h,c=-c,l=-l,u=-u,f=-f),1-h>1e-6?(d=Math.acos(h),g=Math.sin(d),p=Math.sin((1-n)*d)/g,A=Math.sin(n*d)/g):(p=1-n,A=n),e[0]=p*s+A*c,e[1]=p*o+A*l,e[2]=p*i+A*u,e[3]=p*a+A*f,e}function gf(e,t){let r=t[0],n=t[1],s=t[2],o=t[3],i=r*r+n*n+s*s+o*o,a=i?1/i:0;return e[0]=-r*a,e[1]=-n*a,e[2]=-s*a,e[3]=o*a,e}function Af(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function ra(e,t){let r=t[0]+t[4]+t[8],n;if(r>0)n=Math.sqrt(r+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let o=(s+1)%3,i=(s+2)%3;n=Math.sqrt(t[s*3+s]-t[o*3+o]-t[i*3+i]+1),e[s]=.5*n,n=.5/n,e[3]=(t[o*3+i]-t[i*3+o])*n,e[o]=(t[o*3+s]+t[s*3+o])*n,e[i]=(t[i*3+s]+t[s*3+i])*n}return e}var xf=$u;var yf=tf,Tf=sf,_f=of,Ef=ef;var Bf=rf;var Cf=nf;var Sf=function(){let e=ps(),t=ms(1,0,0),r=ms(0,1,0);return function(n,s,o){let i=nn(s,o);return i<-.999999?(Ge(e,t,s),Ri(e)<1e-6&&Ge(e,r,s),Mi(e,e),ta(n,e,Math.PI),n):i>.999999?(n[0]=0,n[1]=0,n[2]=0,n[3]=1,n):(Ge(e,s,o),n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=1+i,Cf(n,n))}}(),Rw=function(){let e=uf(),t=uf();return function(r,n,s,o,i,a){return ln(e,n,i,a),ln(t,s,o,a),ln(r,e,t,2*a*(1-a)),r}}(),Pw=function(){let e=Vu();return function(t,r,n,s){return e[0]=n[0],e[3]=n[1],e[6]=n[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-r[0],e[5]=-r[1],e[8]=-r[2],Cf(t,ra(t,e))}}();var fx=[0,0,0,1],Wt=class extends xe{constructor(t=0,r=0,n=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,r,n,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,r,n,s){return this[0]=t,this[1]=r,this[2]=n,this[3]=s,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 ra(this,t),this.check()}fromAxisRotation(t,r){return ta(this,t,r),this.check()}identity(){return ff(this),this.check()}setAxisAngle(t,r){return this.fromAxisRotation(t,r)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=U(t)}get y(){return this[1]}set y(t){this[1]=U(t)}get z(){return this[2]}set z(t){this[2]=U(t)}get w(){return this[3]}set w(t){this[3]=U(t)}len(){return Ef(this)}lengthSquared(){return Bf(this)}dot(t){return Tf(this,t)}rotationTo(t,r){return Sf(this,t,r),this.check()}add(t){return xf(this,this,t),this.check()}calculateW(){return mf(this,this),this.check()}conjugate(){return Af(this,this),this.check()}invert(){return gf(this,this),this.check()}lerp(t,r,n){return n===void 0?this.lerp(this,t,r):(_f(this,t,r,n),this.check())}multiplyRight(t){return ea(this,this,t),this.check()}multiplyLeft(t){return ea(this,t,this),this.check()}normalize(){let t=this.len(),r=t>0?1/t:0;return this[0]=this[0]*r,this[1]=this[1]*r,this[2]=this[2]*r,this[3]=this[3]*r,t===0&&(this[3]=1),this.check()}rotateX(t){return hf(this,this,t),this.check()}rotateY(t){return df(this,this,t),this.check()}rotateZ(t){return pf(this,this,t),this.check()}scale(t){return yf(this,this,t),this.check()}slerp(t,r,n){let s,o,i;switch(arguments.length){case 1:({start:s=fx,target:o,ratio:i}=t);break;case 2:s=this,o=t,i=r;break;default:s=t,o=r,i=n}return ln(this,s,o,i),this.check()}transformVector4(t,r=new mr){return cf(r,t,this),ye(r,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,r){return this.setAxisAngle(t,r)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Mt={};ut(Mt,{EPSILON1:()=>hx,EPSILON10:()=>_x,EPSILON11:()=>Ex,EPSILON12:()=>Bx,EPSILON13:()=>Cx,EPSILON14:()=>Sx,EPSILON15:()=>bx,EPSILON16:()=>Mx,EPSILON17:()=>Ix,EPSILON18:()=>wx,EPSILON19:()=>Lx,EPSILON2:()=>dx,EPSILON20:()=>Fx,EPSILON3:()=>px,EPSILON4:()=>mx,EPSILON5:()=>gx,EPSILON6:()=>Ax,EPSILON7:()=>xx,EPSILON8:()=>yx,EPSILON9:()=>Tx,PI_OVER_FOUR:()=>Px,PI_OVER_SIX:()=>Ox,PI_OVER_TWO:()=>Rx,TWO_PI:()=>Nx});var hx=.1,dx=.01,px=.001,mx=1e-4,gx=1e-5,Ax=1e-6,xx=1e-7,yx=1e-8,Tx=1e-9,_x=1e-10,Ex=1e-11,Bx=1e-12,Cx=1e-13,Sx=1e-14,bx=1e-15,Mx=1e-16,Ix=1e-17,wx=1e-18,Lx=1e-19,Fx=1e-20,Rx=Math.PI/2,Px=Math.PI/4,Ox=Math.PI/6,Nx=Math.PI*2;function Es(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var vt=Math.PI,wf=vt/4,bf=vt/180,Mf=180/vt,Bs=512;function ee(e){let[t,r]=e;Es(Number.isFinite(t)),Es(Number.isFinite(r)&&r>=-90&&r<=90,"invalid latitude");let n=t*bf,s=r*bf,o=Bs*(n+vt)/(2*vt),i=Bs*(vt+Math.log(Math.tan(wf+s*.5)))/(2*vt);return[o,i]}function re(e){let[t,r]=e,n=t/Bs*(2*vt)-vt,s=2*(Math.atan(Math.exp(r/Bs*(2*vt)-vt))-wf);return[n*Mf,s*Mf]}var gL=Math.PI/180;var Ff=6378137*Math.PI;function na(e){let t=ee(e);return t[0]=(t[0]/256-1)*Ff,t[1]=(t[1]/256-1)*Ff,t}var Qx={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(e,t)=>console.error(t,e)}},Ar=class extends ze.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:t,props:r,oldProps:n}){let{viewport:s}=this.context;t.dataChanged||r.serviceType!==n.serviceType?(this.state.imageSource=this._createImageSource(r),this._loadMetadata(),this.debounce(()=>this.loadImage(s,"image source changed"),0)):(0,ze._deepEqual)(r.layers,n.layers,1)?t.viewportChanged&&this.debounce(()=>this.loadImage(s,"viewport changed")):this.debounce(()=>this.loadImage(s,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:t,image:r,lastRequestParameters:n}=this.state;return r&&new Rf.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:n.srs==="EPSG:4326"?ze.COORDINATE_SYSTEM.LNGLAT:ze.COORDINATE_SYSTEM.CARTESIAN,bounds:t,image:r})}async getFeatureInfoText(t,r){let{lastRequestParameters:n}=this.state;return n?await this.state.imageSource.getFeatureInfoText?.({...n,query_layers:n.layers,x:t,y:r,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(t){if(t.data instanceof bt)return t.data;if(typeof t.data=="string")return Ei({url:t.data,loadOptions:t.loadOptions,type:t.serviceType});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:t}=this.state;try{this.state.loadCounter++;let r=await t.getMetadata();this.state.imageSource===t&&this.getCurrentLayer()?.props.onMetadataLoad(r)}catch(r){this.getCurrentLayer()?.props.onMetadataLoadError(r)}finally{this.state.loadCounter--}}async loadImage(t,r){let{layers:n,serviceType:s}=this.props;if(s==="wms"&&n.length===0)return;let o=t.getBounds(),{width:i,height:a}=t,c=this.getRequestId(),{srs:l}=this.props;l==="auto"&&(l=t.resolution?"EPSG:4326":"EPSG:3857");let u={width:i,height:a,boundingBox:[[o[0],o[1]],[o[2],o[3]]],layers:n,crs:l};if(l==="EPSG:3857"){let f=na([o[0],o[1]]),h=na([o[2],o[3]]);u.boundingBox=[f,h]}try{this.state.loadCounter++,this.props.onImageLoadStart(c);let f=await this.state.imageSource.getImage(u);this.state.lastRequestId<c&&(this.getCurrentLayer()?.props.onImageLoad(c),this.setState({image:f,bounds:o,lastRequestParameters:u,lastRequestId:c}))}catch(f){this.raiseError(f,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(c,f)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(t,r=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>t(),r)}};Ar.layerName="WMSLayer";Ar.defaultProps=Qx;var Pf=N(Ot(),1),Zx={getHeight:{type:"accessor",value:0},greatCircle:!0},un=class extends Pf.ArcLayer{};un.layerName="GreatCircleLayer";un.defaultProps=Zx;var Of=un;var Nf=N(Nt(),1),sa=N(Ot(),1),$x={...sa.PolygonLayer.defaultProps},fn=class extends Nf.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:t,extruded:r,wireframe:n,filled:s,stroked:o,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:h,getElevation:d,getFillColor:p,getLineColor:A,getLineWidth:g}=this.props,{updateTriggers:y,material:E,transitions:_}=this.props,B=this.getSubLayerClass("cell",sa.PolygonLayer),{updateTriggers:S,...b}=this.indexToBounds()||{};return new B({filled:s,wireframe:n,extruded:r,elevationScale:t,stroked:o,lineWidthUnits:i,lineWidthScale:a,lineWidthMinPixels:c,lineWidthMaxPixels:l,lineJointRounded:u,lineMiterLimit:f,lineDashJustified:h,material:E,transitions:_,getElevation:d,getFillColor:p,getLineColor:A,getLineWidth:g},this.getSubLayerProps({id:"cell",updateTriggers:y&&{...S,getElevation:y.getElevation,getFillColor:y.getFillColor,getLineColor:y.getLineColor,getLineWidth:y.getLineWidth}}),b)}};fn.layerName="GeoCellLayer";fn.defaultProps=$x;var Yt=fn;var Cs=N(oa(),1),ty=3,ey=30,ry=2*ey+1,vf=180/Math.PI;function Gf(e,t,r){let n=1<<t;return[(e[0]+r[0])/n,(e[1]+r[1])/n]}function Uf(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Vf(e){return[Uf(e[0]),Uf(e[1])]}function Hf(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function zf([e,t,r]){let n=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*vf,n*vf]}function kf(e){let t=Cs.default.fromString(e,!0,10).toString(2);for(;t.length<ty+ry;)t="0"+t;let r=t.lastIndexOf("1"),n=t.substring(0,3),s=t.substring(3,r),o=s.length/2,i=Cs.default.fromString(n,!0,2).toString(10),a=Cs.default.fromString(s,!0,2).toString(4);for(;a.length<o;)a="0"+a;return`${i}/${a}`}function ny(e,t,r,n){if(n===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function Jf(e){let t=e.split("/"),r=parseInt(t[0],10),n=t[1],s=n.length,o=[0,0],i;for(let a=s-1;a>=0;a--){i=s-a;let c=n[a],l=0,u=0;c==="1"?u=1:c==="2"?(l=1,u=1):c==="3"&&(l=1);let f=Math.pow(2,i-1);ny(f,o,l,u),o[0]+=f*l,o[1]+=f*u}if(r%2===1){let a=o[0];o[0]=o[1],o[1]=a}return{face:r,ij:o,level:i}}var qf=N(oa(),1);function sy(e){let t=e.padEnd(16,"0");return qf.default.fromString(t,16)}var oy=100;function iy({face:e,ij:t,level:r}){let n=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(oy*Math.pow(2,-r))),o=new Float64Array(4*s*2+2),i=0,a=0;for(let c=0;c<4;c++){let l=n[c].slice(0),u=n[c+1],f=(u[0]-l[0])/s,h=(u[1]-l[1])/s;for(let d=0;d<s;d++){l[0]+=f,l[1]+=h;let p=Gf(t,r,l),A=Vf(p),g=Hf(e,A),y=zf(g);Math.abs(y[1])>89.999&&(y[0]=a);let E=y[0]-a;y[0]+=E>180?-360:E<-180?360:0,o[i++]=y[0],o[i++]=y[1],a=y[0]}}return o[i++]=o[0],o[i++]=o[1],o}function ay(e){if(typeof e=="string"){if(e.indexOf("/")>0)return e;e=sy(e)}return kf(e.toString())}function jf(e){let t=ay(e),r=Jf(t);return iy(r)}var cy={getS2Token:{type:"accessor",value:e=>e.token}},dn=class extends Yt{indexToBounds(){let{data:t,getS2Token:r}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(n,s)=>jf(r(n,s))}}};dn.layerName="S2Layer";dn.defaultProps=cy;var Xf=dn;var ia=512;function ly(e,t){let r=0,n=0,s=1<<e.length,o=s/ia;for(let i=0;i<e.length;i++){s>>=1;let a=parseInt(e[i]);a%2&&(r|=s),a>1&&(n|=s)}return[[r/o,ia-n/o],[(r+t)/o,ia-(n+t)/o]]}function Wf(e,t=1){let[r,n]=ly(e,t),[s,o]=re(r),[i,a]=re(n);return[i,o,i,a,s,a,s,o,i,o]}var uy={getQuadkey:{type:"accessor",value:e=>e.quadkey}},pn=class extends Yt{indexToBounds(){let{data:t,extruded:r,getQuadkey:n}=this.props,s=r?.99:1;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(o,i)=>Wf(n(o,i),s),updateTriggers:{getPolygon:s}}}};pn.layerName="QuadkeyLayer";pn.defaultProps=uy;var Yf=pn;var Fs=N(Nt(),1),dh=N(Ot(),1);var ke=class{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 Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let 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:r,onLoad:n,onError:s}){let{index:o,id:i,bbox:a,userData:c,zoom:l}=this,u=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,h=await r.scheduleRequest(this,A=>A.isSelected?1:-1);if(!h){this._isCancelled=!0;return}if(this._isCancelled){h.done();return}let d=null,p;try{d=await t({index:o,id:i,bbox:a,userData:c,zoom:l,signal:f})}catch(A){p=A||!0}finally{h.done()}if(u===this._loaderId){if(this._loader=void 0,this.content=d,this._isCancelled&&!d){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,p?s(p,this):n(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())}};var An=N(Nt(),1);var rt={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Kf=new x,fy=new x,_e=class{constructor(t=[0,0,0],r=[0,0,0],n){n=n||Kf.copy(t).add(r).scale(.5),this.center=new x(n),this.halfDiagonal=new x(r).subtract(this.center),this.minimum=new x(t),this.maximum=new x(r)}clone(){return new _e(this.minimum,this.maximum,this.center)}equals(t){return this===t||Boolean(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){let{halfDiagonal:r}=this,n=fy.from(t.normal),s=r.x*Math.abs(n.x)+r.y*Math.abs(n.y)+r.z*Math.abs(n.z),o=this.center.dot(n)+t.distance;return o-s>0?rt.INSIDE:o+s<0?rt.OUTSIDE:rt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=Kf.from(t).subtract(this.center),{halfDiagonal:n}=this,s=0,o;return o=Math.abs(r.x)-n.x,o>0&&(s+=o*o),o=Math.abs(r.y)-n.y,o>0&&(s+=o*o),o=Math.abs(r.z)-n.z,o>0&&(s+=o*o),s}};var mn=new x,Qf=new x,It=class{constructor(t=[0,0,0],r=0){this.radius=-0,this.center=new x,this.fromCenterRadius(t,r)}fromCenterRadius(t,r){return this.center.from(t),this.radius=r,this}fromCornerPoints(t,r){return r=mn.from(r),this.center=new x().from(t).add(r).scale(.5),this.radius=this.center.distance(r),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new It(this.center,this.radius)}union(t){let r=this.center,n=this.radius,s=t.center,o=t.radius,i=mn.copy(s).subtract(r),a=i.magnitude();if(n>=a+o)return this.clone();if(o>=a+n)return t.clone();let c=(n+a+o)*.5;return Qf.copy(i).scale((-n+c)/a).add(r),this.center.copy(Qf),this.radius=c,this}expand(t){let n=mn.from(t).subtract(this.center).magnitude();return n>this.radius&&(this.radius=n),this}transform(t){this.center.transform(t);let r=cn.getScaling(mn,t);return this.radius=Math.max(r[0],Math.max(r[1],r[2]))*this.radius,this}distanceSquaredTo(t){let r=this.distanceTo(t);return r*r}distanceTo(t){let n=mn.from(t).subtract(this.center);return Math.max(0,n.len()-this.radius)}intersectPlane(t){let r=this.center,n=this.radius,o=t.normal.dot(r)+t.distance;return o<-n?rt.OUTSIDE:o<n?rt.INTERSECTING:rt.INSIDE}};var hy=new x,dy=new x,Ss=new x,bs=new x,Ms=new x,py=new x,my=new x,ne={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Ut=class{constructor(t=[0,0,0],r=[0,0,0,0,0,0,0,0,0]){this.center=new x().from(t),this.halfAxes=new z(r)}get halfSize(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2);return[new x(t).len(),new x(r).len(),new x(n).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),r=this.halfAxes.getColumn(1),n=this.halfAxes.getColumn(2),s=new x(t).normalize(),o=new x(r).normalize(),i=new x(n).normalize();return new Wt().fromMatrix3(new z([...s,...o,...i]))}fromCenterHalfSizeQuaternion(t,r,n){let s=new Wt(n),o=new z().fromQuaternion(s);return o[0]=o[0]*r[0],o[1]=o[1]*r[0],o[2]=o[2]*r[0],o[3]=o[3]*r[1],o[4]=o[4]*r[1],o[5]=o[5]*r[1],o[6]=o[6]*r[2],o[7]=o[7]*r[2],o[8]=o[8]*r[2],this.center=new x().from(t),this.halfAxes=o,this}clone(){return new Ut(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new It){let r=this.halfAxes,n=r.getColumn(0,Ss),s=r.getColumn(1,bs),o=r.getColumn(2,Ms),i=hy.copy(n).add(s).add(o);return t.center.copy(this.center),t.radius=i.magnitude(),t}intersectPlane(t){let r=this.center,n=t.normal,s=this.halfAxes,o=n.x,i=n.y,a=n.z,c=Math.abs(o*s[ne.COLUMN0ROW0]+i*s[ne.COLUMN0ROW1]+a*s[ne.COLUMN0ROW2])+Math.abs(o*s[ne.COLUMN1ROW0]+i*s[ne.COLUMN1ROW1]+a*s[ne.COLUMN1ROW2])+Math.abs(o*s[ne.COLUMN2ROW0]+i*s[ne.COLUMN2ROW1]+a*s[ne.COLUMN2ROW2]),l=n.dot(r)+t.distance;return l<=-c?rt.OUTSIDE:l>=c?rt.INSIDE:rt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let r=dy.from(t).subtract(this.center),n=this.halfAxes,s=n.getColumn(0,Ss),o=n.getColumn(1,bs),i=n.getColumn(2,Ms),a=s.magnitude(),c=o.magnitude(),l=i.magnitude();s.normalize(),o.normalize(),i.normalize();let u=0,f;return f=Math.abs(r.dot(s))-a,f>0&&(u+=f*f),f=Math.abs(r.dot(o))-c,f>0&&(u+=f*f),f=Math.abs(r.dot(i))-l,f>0&&(u+=f*f),u}computePlaneDistances(t,r,n=[-0,-0]){let s=Number.POSITIVE_INFINITY,o=Number.NEGATIVE_INFINITY,i=this.center,a=this.halfAxes,c=a.getColumn(0,Ss),l=a.getColumn(1,bs),u=a.getColumn(2,Ms),f=py.copy(c).add(l).add(u).add(i),h=my.copy(f).subtract(t),d=r.dot(h);return s=Math.min(d,s),o=Math.max(d,o),f.copy(i).add(c).add(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),f.copy(i).add(c).subtract(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),f.copy(i).add(c).subtract(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(f).subtract(c).add(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(f).subtract(c).add(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(f).subtract(c).subtract(l).add(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),i.copy(f).subtract(c).subtract(l).subtract(u),h.copy(f).subtract(t),d=r.dot(h),s=Math.min(d,s),o=Math.max(d,o),n[0]=s,n[1]=o,n}transform(t){this.center.transformAsPoint(t);let r=this.halfAxes.getColumn(0,Ss);r.transformAsPoint(t);let n=this.halfAxes.getColumn(1,bs);n.transformAsPoint(t);let s=this.halfAxes.getColumn(2,Ms);return s.transformAsPoint(t),this.halfAxes=new z([...r,...n,...s]),this}getTransform(){throw new Error("not implemented")}};var Zf=new x,$f=new x,ct=class{constructor(t=[0,0,1],r=0){this.normal=new x,this.distance=-0,this.fromNormalDistance(t,r)}fromNormalDistance(t,r){return at(Number.isFinite(r)),this.normal.from(t).normalize(),this.distance=r,this}fromPointNormal(t,r){t=Zf.from(t),this.normal.from(r).normalize();let n=-this.normal.dot(t);return this.distance=n,this}fromCoefficients(t,r,n,s){return this.normal.set(t,r,n),at(mt(this.normal.len(),1)),this.distance=s,this}clone(){return new ct(this.normal,this.distance)}equals(t){return mt(this.distance,t.distance)&&mt(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let r=$f.copy(this.normal).transformAsVector(t).normalize(),n=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(n,r)}projectPointOntoPlane(t,r=[0,0,0]){let n=Zf.from(t),s=this.getPointDistance(n),o=$f.copy(this.normal).scale(s);return n.subtract(o).to(r)}};var th=[new x([1,0,0]),new x([0,1,0]),new x([0,0,1])],eh=new x,gy=new x,ot=class{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*th.length;let r=t.center,n=t.radius,s=0;for(let o of th){let i=this.planes[s],a=this.planes[s+1];i||(i=this.planes[s]=new ct),a||(a=this.planes[s+1]=new ct);let c=eh.copy(o).scale(-n).add(r);i.fromPointNormal(c,o);let l=eh.copy(o).scale(n).add(r),u=gy.copy(o).negate();a.fromPointNormal(l,u),s+=2}return this}computeVisibility(t){let r=rt.INSIDE;for(let n of this.planes)switch(t.intersectPlane(n)){case rt.OUTSIDE:return rt.OUTSIDE;case rt.INTERSECTING:r=rt.INTERSECTING;break;default:}return r}computeVisibilityWithPlaneMask(t,r){if(at(Number.isFinite(r),"parentPlaneMask is required."),r===ot.MASK_OUTSIDE||r===ot.MASK_INSIDE)return r;let n=ot.MASK_INSIDE,s=this.planes;for(let o=0;o<this.planes.length;++o){let i=o<31?1<<o:0;if(o<31&&!(r&i))continue;let a=s[o],c=t.intersectPlane(a);if(c===rt.OUTSIDE)return ot.MASK_OUTSIDE;c===rt.INTERSECTING&&(n|=i)}return n}};ot.MASK_OUTSIDE=4294967295;ot.MASK_INSIDE=0;ot.MASK_INDETERMINATE=2147483647;var OF=new x,NF=new x,DF=new x,vF=new x,UF=new x;var JF=new x,qF=new x,jF=new x,XF=new x,WF=new x,YF=new x,KF=new x,QF=new x,ZF=new x,$F=new x,tR=new x,eR=new x;var Kt=new z,xy=new z,yy=new z,Is=new z,rh=new z;function la(e,t={}){let r=Mt.EPSILON20,n=10,s=0,o=0,i=xy,a=yy;i.identity(),a.copy(e);let c=r*Ty(a);for(;o<n&&_y(a)>c;)Ey(a,Is),rh.copy(Is).transpose(),a.multiplyRight(Is),a.multiplyLeft(rh),i.multiplyRight(Is),++s>2&&(++o,s=0);return t.unitary=i.toTarget(t.unitary),t.diagonal=a.toTarget(t.diagonal),t}function Ty(e){let t=0;for(let r=0;r<9;++r){let n=e[r];t+=n*n}return Math.sqrt(t)}var aa=[1,0,0],ca=[2,2,1];function _y(e){let t=0;for(let r=0;r<3;++r){let n=e[Kt.getElementIndex(ca[r],aa[r])];t+=2*n*n}return Math.sqrt(t)}function Ey(e,t){let r=Mt.EPSILON15,n=0,s=1;for(let l=0;l<3;++l){let u=Math.abs(e[Kt.getElementIndex(ca[l],aa[l])]);u>n&&(s=l,n=u)}let o=aa[s],i=ca[s],a=1,c=0;if(Math.abs(e[Kt.getElementIndex(i,o)])>r){let l=e[Kt.getElementIndex(i,i)],u=e[Kt.getElementIndex(o,o)],f=e[Kt.getElementIndex(i,o)],h=(l-u)/2/f,d;h<0?d=-1/(-h+Math.sqrt(1+h*h)):d=1/(h+Math.sqrt(1+h*h)),a=1/Math.sqrt(1+d*d),c=d*a}return z.IDENTITY.to(t),t[Kt.getElementIndex(o,o)]=t[Kt.getElementIndex(i,i)]=a,t[Kt.getElementIndex(i,o)]=c,t[Kt.getElementIndex(o,i)]=-c,t}var Ee=new x,By=new x,Cy=new x,Sy=new x,by=new x,My=new z,Iy={diagonal:new z,unitary:new z};function gn(e,t=new Ut){if(!e||e.length===0)return t.halfAxes=new z([0,0,0,0,0,0,0,0,0]),t.center=new x,t;let r=e.length,n=new x(0,0,0);for(let T of e)n.add(T);let s=1/r;n.multiplyByScalar(s);let o=0,i=0,a=0,c=0,l=0,u=0;for(let T of e){let m=Ee.copy(T).subtract(n);o+=m.x*m.x,i+=m.x*m.y,a+=m.x*m.z,c+=m.y*m.y,l+=m.y*m.z,u+=m.z*m.z}o*=s,i*=s,a*=s,c*=s,l*=s,u*=s;let f=My;f[0]=o,f[1]=i,f[2]=a,f[3]=i,f[4]=c,f[5]=l,f[6]=a,f[7]=l,f[8]=u;let{unitary:h}=la(f,Iy),d=t.halfAxes.copy(h),p=d.getColumn(0,Cy),A=d.getColumn(1,Sy),g=d.getColumn(2,by),y=-Number.MAX_VALUE,E=-Number.MAX_VALUE,_=-Number.MAX_VALUE,B=Number.MAX_VALUE,S=Number.MAX_VALUE,b=Number.MAX_VALUE;for(let T of e)Ee.copy(T),y=Math.max(Ee.dot(p),y),E=Math.max(Ee.dot(A),E),_=Math.max(Ee.dot(g),_),B=Math.min(Ee.dot(p),B),S=Math.min(Ee.dot(A),S),b=Math.min(Ee.dot(g),b);p=p.multiplyByScalar(.5*(B+y)),A=A.multiplyByScalar(.5*(S+E)),g=g.multiplyByScalar(.5*(b+_)),t.center.copy(p).add(A).add(g);let w=By.set(y-B,E-S,_-b).multiplyByScalar(.5),C=new z([w[0],0,0,0,w[1],0,0,0,w[2]]);return t.halfAxes.multiplyRight(C),t}var xr=512,nh=3,sh=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],oh=sh.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),wy=oh.concat([[.25,.5],[.75,.5]]),Be=class{constructor(t,r,n){this.x=t,this.y=r,this.z=n}get children(){if(!this._children){let t=this.x*2,r=this.y*2,n=this.z+1;this._children=[new Be(t,r,n),new Be(t,r+1,n),new Be(t+1,r,n),new Be(t+1,r+1,n)]}return this._children}update(t){let{viewport:r,cullingVolume:n,elevationBounds:s,minZ:o,maxZ:i,bounds:a,offset:c,project:l}=t,u=this.getBoundingVolume(s,c,l);if(a&&!this.insideBounds(a)||n.computeVisibility(u)<0)return!1;if(!this.childVisible){let{z:h}=this;if(h<i&&h>=o){let d=u.distanceTo(r.cameraPosition)*r.scale/r.height;h+=Math.floor(Math.log2(d))}if(h>=i)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let h of this.children)h.update(t);return!0}getSelected(t=[]){if(this.selected&&t.push(this),this._children)for(let r of this._children)r.getSelected(t);return t}insideBounds([t,r,n,s]){let o=Math.pow(2,this.z),i=xr/o;return this.x*i<n&&this.y*i<s&&(this.x+1)*i>t&&(this.y+1)*i>r}getBoundingVolume(t,r,n){if(n){let c=this.z<1?wy:this.z<2?oh:sh,l=[];for(let u of c){let f=ws(this.x+u[0],this.y+u[1],this.z);f[2]=t[0],l.push(n(f)),t[0]!==t[1]&&(f[2]=t[1],l.push(n(f)))}return gn(l)}let s=Math.pow(2,this.z),o=xr/s,i=this.x*o+r*xr,a=xr-(this.y+1)*o;return new _e([i,a,t[0]],[i+o,a+o,t[1]])}};function ih(e,t,r,n){let s=e instanceof An._GlobeViewport&&e.resolution?e.projectPosition:null,o=Object.values(e.getFrustumPlanes()).map(({normal:d,distance:p})=>new ct(d.clone().negate(),p)),i=new ot(o),a=e.distanceScales.unitsPerMeter[2],c=r&&r[0]*a||0,l=r&&r[1]*a||0,u=e instanceof An.WebMercatorViewport&&e.pitch<=60?t:0;if(n){let[d,p,A,g]=n,y=ee([d,g]),E=ee([A,p]);n=[y[0],xr-y[1],E[0],xr-E[1]]}let f=new Be(0,0,0),h={viewport:e,project:s,cullingVolume:i,elevationBounds:[c,l],minZ:u,maxZ:t,bounds:n,offset:0};if(f.update(h),e instanceof An.WebMercatorViewport&&e.subViewports&&e.subViewports.length>1){for(h.offset=-1;f.update(h)&&!(--h.offset<-nh););for(h.offset=1;f.update(h)&&!(++h.offset>nh););}return f.getSelected()}var se=512,Ly=[-1/0,-1/0,1/0,1/0],Ce={type:"object",value:null,validate:(e,t)=>t.optional&&e===null||typeof e=="string"||Array.isArray(e)&&e.every(r=>typeof r=="string"),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;let r=e.length;if(r!==t.length)return!1;for(let n=0;n<r;n++)if(e[n]!==t[n])return!1;return!0}};function ch(e,t){let r=[t.transformAsPoint([e[0],e[1]]),t.transformAsPoint([e[2],e[1]]),t.transformAsPoint([e[0],e[3]]),t.transformAsPoint([e[2],e[3]])];return[Math.min(...r.map(s=>s[0])),Math.min(...r.map(s=>s[1])),Math.max(...r.map(s=>s[0])),Math.max(...r.map(s=>s[1]))]}function Fy(e){return Math.abs(e.split("").reduce((t,r)=>(t<<5)-t+r.charCodeAt(0)|0,0))}function Qt(e,t){if(!e||!e.length)return null;let{index:r,id:n}=t;if(Array.isArray(e)){let o=Fy(n)%e.length;e=e[o]}let s=e;for(let o of Object.keys(r)){let i=new RegExp(`{${o}}`,"g");s=s.replace(i,String(r[o]))}return Number.isInteger(r.y)&&Number.isInteger(r.z)&&(s=s.replace(/\{-y\}/g,String(Math.pow(2,r.z)-r.y-1))),s}function Ry(e,t,r){let n;if(t&&t.length===2){let[s,o]=t,i=e.getBounds({z:s}),a=e.getBounds({z:o});n=[Math.min(i[0],a[0]),Math.min(i[1],a[1]),Math.max(i[2],a[2]),Math.max(i[3],a[3])]}else n=e.getBounds();return e.isGeospatial?[Math.max(n[0],r[0]),Math.max(n[1],r[1]),Math.min(n[2],r[2]),Math.min(n[3],r[3])]:[Math.max(Math.min(n[0],r[2]),r[0]),Math.max(Math.min(n[1],r[3]),r[1]),Math.min(Math.max(n[2],r[0]),r[2]),Math.min(Math.max(n[3],r[1]),r[3])]}function lh({viewport:e,z:t,cullRect:r}){return(e.subViewports||[e]).map(s=>ua(s,t||0,r))}function ua(e,t,r){if(!Array.isArray(t)){let o=r.x-e.x,i=r.y-e.y,{width:a,height:c}=r,l={targetZ:t},u=e.unproject([o,i],l),f=e.unproject([o+a,i],l),h=e.unproject([o,i+c],l),d=e.unproject([o+a,i+c],l);return[Math.min(u[0],f[0],h[0],d[0]),Math.min(u[1],f[1],h[1],d[1]),Math.max(u[0],f[0],h[0],d[0]),Math.max(u[1],f[1],h[1],d[1])]}let n=ua(e,t[0],r),s=ua(e,t[1],r);return[Math.min(n[0],s[0]),Math.min(n[1],s[1]),Math.max(n[2],s[2]),Math.max(n[3],s[3])]}function Py(e,t,r){return r?ch(e,r).map(s=>s*t/se):e.map(n=>n*t/se)}function fa(e,t){return Math.pow(2,e)*se/t}function ws(e,t,r){let n=fa(r,se),s=e/n*360-180,o=Math.PI-2*Math.PI*t/n,i=180/Math.PI*Math.atan(.5*(Math.exp(o)-Math.exp(-o)));return[s,i]}function ah(e,t,r,n){let s=fa(r,n);return[e/s*se,t/s*se]}function ha(e,t,r,n,s=se){if(e.isGeospatial){let[l,u]=ws(t,r,n),[f,h]=ws(t+1,r+1,n);return{west:l,north:u,east:f,south:h}}let[o,i]=ah(t,r,n,s),[a,c]=ah(t+1,r+1,n,s);return{left:o,top:i,right:a,bottom:c}}function Oy(e,t,r,n,s){let o=Ry(e,null,n),i=fa(t,r),[a,c,l,u]=Py(o,i,s),f=[];for(let h=Math.floor(a);h<l;h++)for(let d=Math.floor(c);d<u;d++)f.push({x:h,y:d,z:t});return f}function da({viewport:e,maxZoom:t,minZoom:r,zRange:n,extent:s,tileSize:o=se,modelMatrix:i,modelMatrixInverse:a,zoomOffset:c=0}){let l=e.isGeospatial?Math.round(e.zoom+Math.log2(se/o))+c:Math.ceil(e.zoom)+c;if(typeof r=="number"&&Number.isFinite(r)&&l<r){if(!s)return[];l=r}typeof t=="number"&&Number.isFinite(t)&&l>t&&(l=t);let u=s;return i&&a&&s&&!e.isGeospatial&&(u=ch(s,i)),e.isGeospatial?ih(e,l,n,s):Oy(e,l,o,u||Ly,a)}function pa(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(e)}function ma(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}function uh(e){let t={},r;return n=>{for(let s in n)if(!Ny(n[s],t[s])){r=e(n),t=n;break}return r}}function Ny(e,t){if(e===t)return!0;if(Array.isArray(e)){let r=e.length;if(!t||t.length!==r)return!1;for(let n=0;n<r;n++)if(e[n]!==t[n])return!1;return!0}return!1}var fh=1,Ls=2,Dy="never",vy="no-overlap",xn="best-available",Uy=5,Gy={[xn]:Hy,[vy]:zy,[Dy]:()=>{}},Vy={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:()=>{}},Je=class{constructor(t){this._getCullBounds=uh(lh),this.opts={...Vy,...t},this.setOptions(this.opts),this.onTileLoad=r=>{this.opts.onTileLoad?.(r),this.opts.maxCacheByteSize!=null&&(this._cacheByteSize+=r.byteLength,this._resizeCache())},this._requestScheduler=new pe({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 P,this._modelMatrixInverse=new P}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(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let t of this._cache.keys()){let r=this._cache.get(t);!this._selectedTiles||!this._selectedTiles.includes(r)?this._cache.delete(t):r.setNeedsReload()}}update(t,{zRange:r,modelMatrix:n}={zRange:null,modelMatrix:null}){let s=n?new P(n):new P,o=!s.equals(this._modelMatrix);if(!this._viewport||!t.equals(this._viewport)||!mt(this._zRange,r)||o){o&&(this._modelMatrixInverse=s.clone().invert(),this._modelMatrix=s),this._viewport=t,this._zRange=r;let a=this.getTileIndices({viewport:t,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:r,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)));let i=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),i&&this._frameNumber++,this._frameNumber}isTileVisible(t,r){if(!t.isVisible)return!1;if(r&&this._viewport){let n=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:r}),{bbox:s}=t;for(let[o,i,a,c]of n){let l;if("west"in s)l=s.west<a&&s.east>o&&s.south<c&&s.north>i;else{let u=Math.min(s.top,s.bottom),f=Math.max(s.top,s.bottom);l=s.left<a&&s.right>o&&u<c&&f>i}if(l)return!0}return!1}return!0}getTileIndices({viewport:t,maxZoom:r,minZoom:n,zRange:s,modelMatrix:o,modelMatrixInverse:i}){let{tileSize:a,extent:c,zoomOffset:l}=this.opts;return da({viewport:t,maxZoom:r,minZoom:n,zRange:s,tileSize:a,extent:c,modelMatrix:o,modelMatrixInverse:i,zoomOffset:l})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){let{tileSize:r}=this.opts;return{bbox:ha(this._viewport,t.x,t.y,t.z,r)}}getParentIndex(t){let r=Math.floor(t.x/2),n=Math.floor(t.y/2),s=t.z-1;return{x:r,y:n,z:s}}updateTileStates(){let t=this.opts.refinementStrategy||xn,r=new Array(this._cache.size),n=0;for(let s of this._cache.values())r[n++]=s.isVisible,s.isSelected=!1,s.isVisible=!1;for(let s of this._selectedTiles)s.isSelected=!0,s.isVisible=!0;(typeof t=="function"?t:Gy[t])(Array.from(this._cache.values())),n=0;for(let s of this._cache.values())if(r[n++]!==s.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:t=0}=this.opts,r=[],n=0;for(let s of this._cache.values())s.isLoading&&(n++,!s.isSelected&&!s.isVisible&&r.push(s));for(;t>0&&n>t&&r.length>0;)r.shift().abort(),n--}_rebuildTree(){let{_cache:t}=this;for(let r of t.values())r.parent=null,r.children&&(r.children.length=0);for(let r of t.values()){let n=this._getNearestAncestor(r);r.parent=n,n?.children&&n.children.push(r)}}_resizeCache(){let{_cache:t,opts:r}=this,n=r.maxCacheSize??(r.maxCacheByteSize!=null?1/0:Uy*this.selectedTiles.length),s=r.maxCacheByteSize??1/0;if(t.size>n||this._cacheByteSize>s){for(let[i,a]of t)if(!a.isVisible&&!a.isSelected&&(this._cacheByteSize-=r.maxCacheByteSize!=null?a.byteLength:0,t.delete(i),this.opts.onTileUnload?.(a)),t.size<=n&&this._cacheByteSize<=s)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((i,a)=>i.zoom-a.zoom),this._dirty=!1)}_getTile(t,r){let n=this.getTileId(t),s=this._cache.get(n),o=!1;return!s&&r?(s=new ke(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:n,zoom:this.getTileZoom(s.index)}),o=!0,this._cache.set(n,s),this._dirty=!0):s&&s.needsReload&&(o=!0),s&&o&&s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),s}_getNearestAncestor(t){let{_minZoom:r=0}=this,n=t.index;for(;this.getTileZoom(n)>r;){n=this.getParentIndex(n);let s=this._getTile(n);if(s)return s}return null}};function Hy(e){for(let t of e)t.state=0;for(let t of e)t.isSelected&&!hh(t)&&ga(t);for(let t of e)t.isVisible=Boolean(t.state&Ls)}function zy(e){for(let r of e)r.state=0;for(let r of e)r.isSelected&&hh(r);let t=Array.from(e).sort((r,n)=>r.zoom-n.zoom);for(let r of t)if(r.isVisible=Boolean(r.state&Ls),r.children&&(r.isVisible||r.state&fh))for(let n of r.children)n.state=fh;else r.isSelected&&ga(r)}function hh(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=Ls,!0;t=t.parent}return!1}function ga(e){for(let t of e.children)t.isLoaded||t.content?t.state|=Ls:ga(t)}var ky={TilesetClass:Je,data:{type:"data",value:[]},dataComparator:Ce.equal,renderSubLayers:{type:"function",value:e=>new dh.GeoJsonLayer(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:xn,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},yn=class extends Fs.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(t=>t.isLoaded&&t.layers&&t.layers.every(r=>r.isLoaded)))}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({changeFlags:t}){let{tileset:r}=this.state,n=t.propsOrDataChanged||t.updateTriggersChanged,s=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getTileData);r?n&&(r.setOptions(this._getTilesetOptions()),s?r.reloadAll():r.tiles.forEach(o=>{o.layers=null})):(r=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:r})),this._updateTileset()}_getTilesetOptions(){let{tileSize:t,maxCacheSize:r,maxCacheByteSize:n,refinementStrategy:s,extent:o,maxZoom:i,minZoom:a,maxRequests:c,debounceTime:l,zoomOffset:u}=this.props;return{maxCacheSize:r,maxCacheByteSize:n,maxZoom:i,minZoom:a,tileSize:t,refinementStrategy:s,extent:o,maxRequests:c,debounceTime:l,zoomOffset:u,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let t=this.state.tileset,{zRange:r,modelMatrix:n}=this.props,s=t.update(this.context.viewport,{zRange:r,modelMatrix:n}),{isLoaded:o}=t,i=this.state.isLoaded!==o,a=this.state.frameNumber!==s;o&&(i||a)&&this._onViewportLoad(),a&&this.setState({frameNumber:s}),this.state.isLoaded=o}_onViewportLoad(){let{tileset:t}=this.state,{onViewportLoad:r}=this.props;r&&r(t.selectedTiles)}_onTileLoad(t){this.props.onTileLoad(t),t.layers=null,this.setNeedsUpdate()}_onTileError(t,r){this.props.onTileError(t),r.layers=null,this.setNeedsUpdate()}_onTileUnload(t){this.props.onTileUnload(t)}getTileData(t){let{data:r,getTileData:n,fetch:s}=this.props,{signal:o}=t;return t.url=typeof r=="string"||Array.isArray(r)?Qt(r,t):null,n?n(t):s&&t.url?s(t.url,{propName:"data",layer:this,signal:o}):null}renderSubLayers(t){return this.props.renderSubLayers(t)}getSubLayerPropsByTile(t){return null}getPickingInfo(t){let r=t.sourceLayer,n=r.props.tile,s=t.info;return s.picked&&(s.tile=n),s.sourceTile=n,s.sourceTileSubLayer=r,s}_updateAutoHighlight(t){t.sourceTileSubLayer.updateAutoHighlight(t)}renderLayers(){return this.state.tileset.tiles.map(t=>{let r=this.getSubLayerPropsByTile(t);if(!(!t.isLoaded&&!t.content))if(t.layers)r&&t.layers[0]&&Object.keys(r).some(n=>t.layers[0].props[n]!==r[n])&&(t.layers=t.layers.map(n=>n.clone(r)));else{let n=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:t.id,updateTriggers:this.props.updateTriggers}),data:t.content,_offset:0,tile:t});t.layers=(0,Fs._flatten)(n,Boolean).map(s=>s.clone({tile:t,...r}))}return t.layers})}filterSubLayer({layer:t,cullRect:r}){let{tile:n}=t.props;return this.state.tileset.isTileVisible(n,r)}};yn.defaultProps=ky;yn.layerName="TileLayer";var qe=yn;var ph=N(Ot(),1),Jy={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}},Tn=class extends ph.PathLayer{getShaders(){let t=super.getShaders();return t.inject={"vs:#decl":`uniform float trailLength;
14
- in float instanceTimestamps;
13
+ `):(this.indentate=function(){return""},this.tagEndChar=">",this.newLine="")}Je.prototype.build=function(e){return this.options.preserveOrder?OE(e,this.options):(Array.isArray(e)&&this.options.arrayNodeName&&this.options.arrayNodeName.length>1&&(e={[this.options.arrayNodeName]:e}),this.j2x(e,0).val)};Je.prototype.j2x=function(e,t){let n="",r="";for(let s in e)if(Object.prototype.hasOwnProperty.call(e,s))if(typeof e[s]>"u")this.isAttribute(s)&&(r+="");else if(e[s]===null)this.isAttribute(s)?r+="":s[0]==="?"?r+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(e[s]instanceof Date)r+=this.buildTextValNode(e[s],s,"",t);else if(typeof e[s]!="object"){let i=this.isAttribute(s);if(i)n+=this.buildAttrPairStr(i,""+e[s]);else if(s===this.options.textNodeName){let o=this.options.tagValueProcessor(s,""+e[s]);r+=this.replaceEntitiesValue(o)}else r+=this.buildTextValNode(e[s],s,"",t)}else if(Array.isArray(e[s])){let i=e[s].length,o="",c="";for(let a=0;a<i;a++){let h=e[s][a];if(!(typeof h>"u"))if(h===null)s[0]==="?"?r+=this.indentate(t)+"<"+s+"?"+this.tagEndChar:r+=this.indentate(t)+"<"+s+"/"+this.tagEndChar;else if(typeof h=="object")if(this.options.oneListGroup){let l=this.j2x(h,t+1);o+=l.val,this.options.attributesGroupName&&h.hasOwnProperty(this.options.attributesGroupName)&&(c+=l.attrStr)}else o+=this.processTextOrObjNode(h,s,t);else if(this.options.oneListGroup){let l=this.options.tagValueProcessor(s,h);l=this.replaceEntitiesValue(l),o+=l}else o+=this.buildTextValNode(h,s,"",t)}this.options.oneListGroup&&(o=this.buildObjectNode(o,s,c,t)),r+=o}else if(this.options.attributesGroupName&&s===this.options.attributesGroupName){let i=Object.keys(e[s]),o=i.length;for(let c=0;c<o;c++)n+=this.buildAttrPairStr(i[c],""+e[s][i[c]])}else r+=this.processTextOrObjNode(e[s],s,t);return{attrStr:n,val:r}};Je.prototype.buildAttrPairStr=function(e,t){return t=this.options.attributeValueProcessor(e,""+t),t=this.replaceEntitiesValue(t),this.options.suppressBooleanAttributes&&t==="true"?" "+e:" "+e+'="'+t+'"'};function NE(e,t,n){let r=this.j2x(e,n+1);return e[this.options.textNodeName]!==void 0&&Object.keys(e).length===1?this.buildTextValNode(e[this.options.textNodeName],t,r.attrStr,n):this.buildObjectNode(r.val,t,r.attrStr,n)}Je.prototype.buildObjectNode=function(e,t,n,r){if(e==="")return t[0]==="?"?this.indentate(r)+"<"+t+n+"?"+this.tagEndChar:this.indentate(r)+"<"+t+n+this.closeTag(t)+this.tagEndChar;{let s="</"+t+this.tagEndChar,i="";return t[0]==="?"&&(i="?",s=""),(n||n==="")&&e.indexOf("<")===-1?this.indentate(r)+"<"+t+n+i+">"+e+s:this.options.commentPropName!==!1&&t===this.options.commentPropName&&i.length===0?this.indentate(r)+`<!--${e}-->`+this.newLine:this.indentate(r)+"<"+t+n+i+this.tagEndChar+e+this.indentate(r)+s}};Je.prototype.closeTag=function(e){let t="";return this.options.unpairedTags.indexOf(e)!==-1?this.options.suppressUnpairedNode||(t="/"):this.options.suppressEmptyNode?t="/":t=`></${e}`,t};Je.prototype.buildTextValNode=function(e,t,n,r){if(this.options.cdataPropName!==!1&&t===this.options.cdataPropName)return this.indentate(r)+`<![CDATA[${e}]]>`+this.newLine;if(this.options.commentPropName!==!1&&t===this.options.commentPropName)return this.indentate(r)+`<!--${e}-->`+this.newLine;if(t[0]==="?")return this.indentate(r)+"<"+t+n+"?"+this.tagEndChar;{let s=this.options.tagValueProcessor(t,e);return s=this.replaceEntitiesValue(s),s===""?this.indentate(r)+"<"+t+n+this.closeTag(t)+this.tagEndChar:this.indentate(r)+"<"+t+n+">"+s+"</"+t+this.tagEndChar}};Je.prototype.replaceEntitiesValue=function(e){if(e&&e.length>0&&this.options.processEntities)for(let t=0;t<this.options.entities.length;t++){let n=this.options.entities[t];e=e.replace(n.regex,n.val)}return e};function FE(e){return this.options.indentBy.repeat(e)}function vE(e){return e.startsWith(this.options.attributeNamePrefix)&&e!==this.options.textNodeName?e.substr(this.attrPrefixLen):!1}R1.exports=Je});var b1=it((vF,I1)=>{"use strict";var DE=Ma(),UE=T1(),GE=w1();I1.exports={XMLParser:UE,XMLValidator:DE,XMLBuilder:GE}});var Sh=it((Su,Os)=>{(function(e,t){typeof define=="function"&&define.amd?define([],t):typeof K0=="function"&&typeof Os=="object"&&Os&&Os.exports?Os.exports=t():(e.dcodeIO=e.dcodeIO||{}).Long=t()})(Su,function(){"use strict";function e(S,x,R){this.low=S|0,this.high=x|0,this.unsigned=!!R}e.prototype.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1});function t(S){return(S&&S.__isLong__)===!0}e.isLong=t;var n={},r={};function s(S,x){var R,w,I;return x?(S>>>=0,(I=0<=S&&S<256)&&(w=r[S],w)?w:(R=o(S,(S|0)<0?-1:0,!0),I&&(r[S]=R),R)):(S|=0,(I=-128<=S&&S<128)&&(w=n[S],w)?w:(R=o(S,S<0?-1:0,!1),I&&(n[S]=R),R))}e.fromInt=s;function i(S,x){if(isNaN(S)||!isFinite(S))return x?M:m;if(x){if(S<0)return M;if(S>=u)return _}else{if(S<=-d)return L;if(S+1>=d)return T}return S<0?i(-S,x).neg():o(S%p|0,S/p|0,x)}e.fromNumber=i;function o(S,x,R){return new e(S,x,R)}e.fromBits=o;var c=Math.pow;function a(S,x,R){if(S.length===0)throw Error("empty string");if(S==="NaN"||S==="Infinity"||S==="+Infinity"||S==="-Infinity")return m;if(typeof x=="number"?(R=x,x=!1):x=!!x,R=R||10,R<2||36<R)throw RangeError("radix");var w;if((w=S.indexOf("-"))>0)throw Error("interior hyphen");if(w===0)return a(S.substring(1),x,R).neg();for(var I=i(c(R,8)),C=m,P=0;P<S.length;P+=8){var V=Math.min(8,S.length-P),G=parseInt(S.substring(P,P+V),R);if(V<8){var Q=i(c(R,V));C=C.mul(Q).add(i(G))}else C=C.mul(I),C=C.add(i(G))}return C.unsigned=x,C}e.fromString=a;function h(S){return S instanceof e?S:typeof S=="number"?i(S):typeof S=="string"?a(S):o(S.low,S.high,S.unsigned)}e.fromValue=h;var l=1<<16,f=1<<24,p=l*l,u=p*p,d=u/2,g=s(f),m=s(0);e.ZERO=m;var M=s(0,!0);e.UZERO=M;var E=s(1);e.ONE=E;var A=s(1,!0);e.UONE=A;var y=s(-1);e.NEG_ONE=y;var T=o(-1,2147483647,!1);e.MAX_VALUE=T;var _=o(-1,-1,!0);e.MAX_UNSIGNED_VALUE=_;var L=o(0,-2147483648,!1);e.MIN_VALUE=L;var B=e.prototype;return B.toInt=function(){return this.unsigned?this.low>>>0:this.low},B.toNumber=function(){return this.unsigned?(this.high>>>0)*p+(this.low>>>0):this.high*p+(this.low>>>0)},B.toString=function(x){if(x=x||10,x<2||36<x)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(L)){var R=i(x),w=this.div(R),I=w.mul(R).sub(this);return w.toString(x)+I.toInt().toString(x)}else return"-"+this.neg().toString(x);for(var C=i(c(x,6),this.unsigned),P=this,V="";;){var G=P.div(C),Q=P.sub(G.mul(C)).toInt()>>>0,q=Q.toString(x);if(P=G,P.isZero())return q+V;for(;q.length<6;)q="0"+q;V=""+q+V}},B.getHighBits=function(){return this.high},B.getHighBitsUnsigned=function(){return this.high>>>0},B.getLowBits=function(){return this.low},B.getLowBitsUnsigned=function(){return this.low>>>0},B.getNumBitsAbs=function(){if(this.isNegative())return this.eq(L)?64:this.neg().getNumBitsAbs();for(var x=this.high!=0?this.high:this.low,R=31;R>0&&!(x&1<<R);R--);return this.high!=0?R+33:R+1},B.isZero=function(){return this.high===0&&this.low===0},B.isNegative=function(){return!this.unsigned&&this.high<0},B.isPositive=function(){return this.unsigned||this.high>=0},B.isOdd=function(){return(this.low&1)===1},B.isEven=function(){return(this.low&1)===0},B.equals=function(x){return t(x)||(x=h(x)),this.unsigned!==x.unsigned&&this.high>>>31===1&&x.high>>>31===1?!1:this.high===x.high&&this.low===x.low},B.eq=B.equals,B.notEquals=function(x){return!this.eq(x)},B.neq=B.notEquals,B.lessThan=function(x){return this.comp(x)<0},B.lt=B.lessThan,B.lessThanOrEqual=function(x){return this.comp(x)<=0},B.lte=B.lessThanOrEqual,B.greaterThan=function(x){return this.comp(x)>0},B.gt=B.greaterThan,B.greaterThanOrEqual=function(x){return this.comp(x)>=0},B.gte=B.greaterThanOrEqual,B.compare=function(x){if(t(x)||(x=h(x)),this.eq(x))return 0;var R=this.isNegative(),w=x.isNegative();return R&&!w?-1:!R&&w?1:this.unsigned?x.high>>>0>this.high>>>0||x.high===this.high&&x.low>>>0>this.low>>>0?-1:1:this.sub(x).isNegative()?-1:1},B.comp=B.compare,B.negate=function(){return!this.unsigned&&this.eq(L)?L:this.not().add(E)},B.neg=B.negate,B.add=function(x){t(x)||(x=h(x));var R=this.high>>>16,w=this.high&65535,I=this.low>>>16,C=this.low&65535,P=x.high>>>16,V=x.high&65535,G=x.low>>>16,Q=x.low&65535,q=0,$=0,st=0,Ut=0;return Ut+=C+Q,st+=Ut>>>16,Ut&=65535,st+=I+G,$+=st>>>16,st&=65535,$+=w+V,q+=$>>>16,$&=65535,q+=R+P,q&=65535,o(st<<16|Ut,q<<16|$,this.unsigned)},B.subtract=function(x){return t(x)||(x=h(x)),this.add(x.neg())},B.sub=B.subtract,B.multiply=function(x){if(this.isZero()||(t(x)||(x=h(x)),x.isZero()))return m;if(this.eq(L))return x.isOdd()?L:m;if(x.eq(L))return this.isOdd()?L:m;if(this.isNegative())return x.isNegative()?this.neg().mul(x.neg()):this.neg().mul(x).neg();if(x.isNegative())return this.mul(x.neg()).neg();if(this.lt(g)&&x.lt(g))return i(this.toNumber()*x.toNumber(),this.unsigned);var R=this.high>>>16,w=this.high&65535,I=this.low>>>16,C=this.low&65535,P=x.high>>>16,V=x.high&65535,G=x.low>>>16,Q=x.low&65535,q=0,$=0,st=0,Ut=0;return Ut+=C*Q,st+=Ut>>>16,Ut&=65535,st+=I*Q,$+=st>>>16,st&=65535,st+=C*G,$+=st>>>16,st&=65535,$+=w*Q,q+=$>>>16,$&=65535,$+=I*G,q+=$>>>16,$&=65535,$+=C*V,q+=$>>>16,$&=65535,q+=R*Q+w*G+I*V+C*P,q&=65535,o(st<<16|Ut,q<<16|$,this.unsigned)},B.mul=B.multiply,B.divide=function(x){if(t(x)||(x=h(x)),x.isZero())throw Error("division by zero");if(this.isZero())return this.unsigned?M:m;var R,w,I;if(this.unsigned){if(x.unsigned||(x=x.toUnsigned()),x.gt(this))return M;if(x.gt(this.shru(1)))return A;I=M}else{if(this.eq(L)){if(x.eq(E)||x.eq(y))return L;if(x.eq(L))return E;var C=this.shr(1);return R=C.div(x).shl(1),R.eq(m)?x.isNegative()?E:y:(w=this.sub(x.mul(R)),I=R.add(w.div(x)),I)}else if(x.eq(L))return this.unsigned?M:m;if(this.isNegative())return x.isNegative()?this.neg().div(x.neg()):this.neg().div(x).neg();if(x.isNegative())return this.div(x.neg()).neg();I=m}for(w=this;w.gte(x);){R=Math.max(1,Math.floor(w.toNumber()/x.toNumber()));for(var P=Math.ceil(Math.log(R)/Math.LN2),V=P<=48?1:c(2,P-48),G=i(R),Q=G.mul(x);Q.isNegative()||Q.gt(w);)R-=V,G=i(R,this.unsigned),Q=G.mul(x);G.isZero()&&(G=E),I=I.add(G),w=w.sub(Q)}return I},B.div=B.divide,B.modulo=function(x){return t(x)||(x=h(x)),this.sub(this.div(x).mul(x))},B.mod=B.modulo,B.not=function(){return o(~this.low,~this.high,this.unsigned)},B.and=function(x){return t(x)||(x=h(x)),o(this.low&x.low,this.high&x.high,this.unsigned)},B.or=function(x){return t(x)||(x=h(x)),o(this.low|x.low,this.high|x.high,this.unsigned)},B.xor=function(x){return t(x)||(x=h(x)),o(this.low^x.low,this.high^x.high,this.unsigned)},B.shiftLeft=function(x){return t(x)&&(x=x.toInt()),(x&=63)===0?this:x<32?o(this.low<<x,this.high<<x|this.low>>>32-x,this.unsigned):o(0,this.low<<x-32,this.unsigned)},B.shl=B.shiftLeft,B.shiftRight=function(x){return t(x)&&(x=x.toInt()),(x&=63)===0?this:x<32?o(this.low>>>x|this.high<<32-x,this.high>>x,this.unsigned):o(this.high>>x-32,this.high>=0?0:-1,this.unsigned)},B.shr=B.shiftRight,B.shiftRightUnsigned=function(x){if(t(x)&&(x=x.toInt()),x&=63,x===0)return this;var R=this.high;if(x<32){var w=this.low;return o(w>>>x|R<<32-x,R>>>x,this.unsigned)}else return x===32?o(R,0,this.unsigned):o(R>>>x-32,0,this.unsigned)},B.shru=B.shiftRightUnsigned,B.toSigned=function(){return this.unsigned?o(this.low,this.high,!1):this},B.toUnsigned=function(){return this.unsigned?this:o(this.low,this.high,!0)},B.toBytes=function(S){return S?this.toBytesLE():this.toBytesBE()},B.toBytesLE=function(){var S=this.high,x=this.low;return[x&255,x>>>8&255,x>>>16&255,x>>>24&255,S&255,S>>>8&255,S>>>16&255,S>>>24&255]},B.toBytesBE=function(){var S=this.high,x=this.low;return[S>>>24&255,S>>>16&255,S>>>8&255,S&255,x>>>24&255,x>>>16&255,x>>>8&255,x&255]},e})});var oo=it((m9,od)=>{od.exports=globalThis.h3||{}});var Uh=it((S9,pd)=>{pd.exports=globalThis.luma});var lo=it((B9,ud)=>{ud.exports=globalThis.deck});var Gh=it((C9,dd)=>{dd.exports=globalThis.luma});var yr=it((Tz,Wd)=>{Wd.exports=globalThis.loaders});var Uy=it((Rtt,Dy)=>{Dy.exports=globalThis.deck});var Xy=it(D0=>{D0.read=function(e,t,n,r,s){var i,o,c=s*8-r-1,a=(1<<c)-1,h=a>>1,l=-7,f=n?s-1:0,p=n?-1:1,u=e[t+f];for(f+=p,i=u&(1<<-l)-1,u>>=-l,l+=c;l>0;i=i*256+e[t+f],f+=p,l-=8);for(o=i&(1<<-l)-1,i>>=-l,l+=r;l>0;o=o*256+e[t+f],f+=p,l-=8);if(i===0)i=1-h;else{if(i===a)return o?NaN:(u?-1:1)*(1/0);o=o+Math.pow(2,r),i=i-h}return(u?-1:1)*o*Math.pow(2,i-r)};D0.write=function(e,t,n,r,s,i){var o,c,a,h=i*8-s-1,l=(1<<h)-1,f=l>>1,p=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,u=r?0:i-1,d=r?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(a=Math.pow(2,-o))<1&&(o--,a*=2),o+f>=1?t+=p/a:t+=p*Math.pow(2,1-f),t*a>=2&&(o++,a/=2),o+f>=l?(c=0,o=l):o+f>=1?(c=(t*a-1)*Math.pow(2,s),o=o+f):(c=t*Math.pow(2,f-1)*Math.pow(2,s),o=0));s>=8;e[n+u]=c&255,u+=d,c/=256,s-=8);for(o=o<<s|c,h+=s;h>0;e[n+u]=o&255,u+=d,o/=256,h-=8);e[n+u-d]|=g*128}});var t3=it((get,$y)=>{"use strict";$y.exports=j;var ca=Xy();function j(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}j.Varint=0;j.Fixed64=1;j.Bytes=2;j.Fixed32=5;var U0=(1<<16)*(1<<16),jy=1/U0,S4=12,Qy=typeof TextDecoder>"u"?null:new TextDecoder("utf-8");j.prototype={destroy:function(){this.buf=null},readFields:function(e,t,n){for(n=n||this.length;this.pos<n;){var r=this.readVarint(),s=r>>3,i=this.pos;this.type=r&7,e(s,t,this),this.pos===i&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=aa(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Zy(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=aa(this.buf,this.pos)+aa(this.buf,this.pos+4)*U0;return this.pos+=8,e},readSFixed64:function(){var e=aa(this.buf,this.pos)+Zy(this.buf,this.pos+4)*U0;return this.pos+=8,e},readFloat:function(){var e=ca.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=ca.read(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t=this.buf,n,r;return r=t[this.pos++],n=r&127,r<128||(r=t[this.pos++],n|=(r&127)<<7,r<128)||(r=t[this.pos++],n|=(r&127)<<14,r<128)||(r=t[this.pos++],n|=(r&127)<<21,r<128)?n:(r=t[this.pos],n|=(r&15)<<28,B4(n,e,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2===1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=S4&&Qy?G4(this.buf,t,e):U4(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==j.Bytes)return e.push(this.readVarint(t));var n=Ye(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==j.Bytes)return e.push(this.readSVarint());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==j.Bytes)return e.push(this.readBoolean());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==j.Bytes)return e.push(this.readFloat());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==j.Bytes)return e.push(this.readDouble());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==j.Bytes)return e.push(this.readFixed32());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==j.Bytes)return e.push(this.readSFixed32());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==j.Bytes)return e.push(this.readFixed64());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==j.Bytes)return e.push(this.readSFixed64());var t=Ye(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===j.Varint)for(;this.buf[this.pos++]>127;);else if(t===j.Bytes)this.pos=this.readVarint()+this.pos;else if(t===j.Fixed32)this.pos+=4;else if(t===j.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+t)},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t<this.pos+e;)t*=2;if(t!==this.length){var n=new Uint8Array(t);n.set(this.buf),this.buf=n,this.length=t}},finish:function(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)},writeFixed32:function(e){this.realloc(4),ls(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ls(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ls(this.buf,e&-1,this.pos),ls(this.buf,Math.floor(e*jy),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ls(this.buf,e&-1,this.pos),ls(this.buf,Math.floor(e*jy),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){C4(e,this);return}this.realloc(4),this.buf[this.pos++]=e&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=(e>>>=7)&127|(e>127?128:0),!(e<=127)&&(this.buf[this.pos++]=e>>>7&127)))},writeSVarint:function(e){this.writeVarint(e<0?-e*2-1:e*2)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(e.length*4),this.pos++;var t=this.pos;this.pos=z4(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Ky(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),ca.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ca.write(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n<t;n++)this.buf[this.pos++]=e[n]},writeRawMessage:function(e,t){this.pos++;var n=this.pos;e(t,this);var r=this.pos-n;r>=128&&Ky(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,j.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,w4,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,I4,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,P4,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,b4,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,O4,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,N4,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,F4,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,v4,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,D4,t)},writeBytesField:function(e,t){this.writeTag(e,j.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,j.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,j.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,j.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,j.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,j.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,j.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,j.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,j.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,j.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};function B4(e,t,n){var r=n.buf,s,i;if(i=r[n.pos++],s=(i&112)>>4,i<128||(i=r[n.pos++],s|=(i&127)<<3,i<128)||(i=r[n.pos++],s|=(i&127)<<10,i<128)||(i=r[n.pos++],s|=(i&127)<<17,i<128)||(i=r[n.pos++],s|=(i&127)<<24,i<128)||(i=r[n.pos++],s|=(i&1)<<31,i<128))return hs(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function Ye(e){return e.type===j.Bytes?e.readVarint()+e.pos:e.pos+1}function hs(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function C4(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(n=~(-e%4294967296),r=~(-e/4294967296),n^4294967295?n=n+1|0:(n=0,r=r+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),L4(n,r,t),R4(r,t)}function L4(e,t,n){n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos++]=e&127|128,e>>>=7,n.buf[n.pos]=e&127}function R4(e,t){var n=(e&7)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=e&127)))))}function Ky(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(Math.LN2*7));n.realloc(r);for(var s=n.pos-1;s>=e;s--)n.buf[s+r]=n.buf[s]}function w4(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function I4(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function b4(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function O4(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function P4(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function N4(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function F4(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function v4(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function D4(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function aa(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ls(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Zy(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function U4(e,t,n){for(var r="",s=t;s<n;){var i=e[s],o=null,c=i>239?4:i>223?3:i>191?2:1;if(s+c>n)break;var a,h,l;c===1?i<128&&(o=i):c===2?(a=e[s+1],(a&192)===128&&(o=(i&31)<<6|a&63,o<=127&&(o=null))):c===3?(a=e[s+1],h=e[s+2],(a&192)===128&&(h&192)===128&&(o=(i&15)<<12|(a&63)<<6|h&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):c===4&&(a=e[s+1],h=e[s+2],l=e[s+3],(a&192)===128&&(h&192)===128&&(l&192)===128&&(o=(i&15)<<18|(a&63)<<12|(h&63)<<6|l&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,c=1):o>65535&&(o-=65536,r+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),r+=String.fromCharCode(o),s+=c}return r}function G4(e,t,n){return Qy.decode(e.subarray(t,n))}function z4(e,t,n){for(var r=0,s,i;r<t.length;r++){if(s=t.charCodeAt(r),s>55295&&s<57344)if(i)if(s<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=s;continue}else s=i-55296<<10|s-56320|65536,i=null;else{s>56319||r+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=s;continue}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);s<128?e[n++]=s:(s<2048?e[n++]=s>>6|192:(s<65536?e[n++]=s>>12|224:(e[n++]=s>>18|240,e[n++]=s>>12&63|128),e[n++]=s>>6&63|128),e[n++]=s&63|128)}return n}});var Li={};At(Li,{GeohashLayer:()=>E3,GreatCircleLayer:()=>Tu,H3ClusterLayer:()=>fd,H3HexagonLayer:()=>ho,MVTLayer:()=>x3,QuadkeyLayer:()=>Du,S2Layer:()=>Fu,TerrainLayer:()=>vy,Tile3DLayer:()=>Ry,TileLayer:()=>Dn,TripsLayer:()=>id,_GeoCellLayer:()=>ye,_Tile2DHeader:()=>Nn,_Tileset2D:()=>vn,_WMSLayer:()=>Mr,_getURLFromTemplate:()=>Te});var pe={},Q0=D(ee(),1);We(pe,D(ee(),1));if(!Q0.GeoJsonLayer)throw new Error("@deck.gl/layers is not found");We(Li,pe);var Pn=D(ne(),1),yu=D(ee(),1);function b3(e){return typeof e=="string"?e.charAt(0).toLowerCase()+e.slice(1):e}function wi(e){if(Array.isArray(e))return e.map(t=>wi(t));if(e&&typeof e=="object"){let t={};for(let[n,r]of Object.entries(e))t[b3(n)]=wi(r);return t}return e}var O1=D(b1(),1);function Ba(e,t){if(t?._parser&&t._parser!=="fast-xml-parser")throw new Error(t?._parser);let n={allowBooleanAttributes:!0,ignoreDeclaration:!0,removeNSPrefix:t?.removeNSPrefix,textNodeName:t?.textNodeName,isArray:(s,i,o,c)=>Boolean(t?.arrayPaths?.some(h=>i===h)),...t?._fastXML},r=zE(e,n);return t?.uncapitalizeKeys?wi(r):r}function zE(e,t){return new O1.XMLParser({ignoreAttributes:!1,attributeNamePrefix:"",...t}).parse(e)}var kE="4.2.1",re={dataType:null,batchType:null,name:"XML",id:"xml",module:"xml",version:kE,worker:!1,extensions:["xml"],mimeTypes:["application/xml","text/xml"],testText:VE,options:{xml:{_parser:"fast-xml-parser",uncapitalizeKeys:!1,removeNSPrefix:!1,textNodeName:"value",arrayPaths:[]}},parse:async(e,t)=>Ba(new TextDecoder().decode(e),{...re.options.xml,...t?.xml}),parseTextSync:(e,t)=>Ba(e,{...re.options.xml,...t?.xml})};function VE(e){return e.startsWith("<?xml")}async function qt(e,t,n,r){return r._parse(e,t,n,r)}function z(e,t){if(!e)throw new Error(t||"loader assertion failed.")}var ue={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},qE=ue.self||ue.window||ue.global||{},HE=ue.window||ue.self||ue.global||{},YE=ue.global||ue.self||ue.window||{},WE=ue.document||{};var ms=Boolean(typeof process!="object"||String(process)!=="[object process]"||process.browser);var P1=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),JE=P1&&parseFloat(P1[1])||0;var bi=globalThis,XE=globalThis.document||{},Oi=globalThis.process||{},jE=globalThis.console,HF=globalThis.navigator||{};function N1(e){if(typeof window<"u"&&window.process?.type==="renderer"||typeof process<"u"&&Boolean(process.versions?.electron))return!0;let t=typeof navigator<"u"&&navigator.userAgent,n=e||t;return Boolean(n&&n.indexOf("Electron")>=0)}function Cn(){return!(typeof process=="object"&&String(process)==="[object process]"&&!process?.browser)||N1()}var Ca="4.0.7";function ZE(e){try{let t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch{return null}}var Pi=class{constructor(t,n,r="sessionStorage"){this.storage=ZE(r),this.id=t,this.config=n,this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(t){if(Object.assign(this.config,t),this.storage){let n=JSON.stringify(this.config);this.storage.setItem(this.id,n)}}_loadConfiguration(){let t={};if(this.storage){let n=this.storage.getItem(this.id);t=n?JSON.parse(n):{}}return Object.assign(this.config,t),this}};function F1(e){let t;return e<10?t=`${e.toFixed(2)}ms`:e<100?t=`${e.toFixed(1)}ms`:e<1e3?t=`${e.toFixed(0)}ms`:t=`${(e/1e3).toFixed(2)}s`,t}function v1(e,t=8){let n=Math.max(t-e.length,0);return`${" ".repeat(n)}${e}`}var Ni;(function(e){e[e.BLACK=30]="BLACK",e[e.RED=31]="RED",e[e.GREEN=32]="GREEN",e[e.YELLOW=33]="YELLOW",e[e.BLUE=34]="BLUE",e[e.MAGENTA=35]="MAGENTA",e[e.CYAN=36]="CYAN",e[e.WHITE=37]="WHITE",e[e.BRIGHT_BLACK=90]="BRIGHT_BLACK",e[e.BRIGHT_RED=91]="BRIGHT_RED",e[e.BRIGHT_GREEN=92]="BRIGHT_GREEN",e[e.BRIGHT_YELLOW=93]="BRIGHT_YELLOW",e[e.BRIGHT_BLUE=94]="BRIGHT_BLUE",e[e.BRIGHT_MAGENTA=95]="BRIGHT_MAGENTA",e[e.BRIGHT_CYAN=96]="BRIGHT_CYAN",e[e.BRIGHT_WHITE=97]="BRIGHT_WHITE"})(Ni||(Ni={}));var QE=10;function D1(e){return typeof e!="string"?e:(e=e.toUpperCase(),Ni[e]||Ni.WHITE)}function U1(e,t,n){return!Cn&&typeof e=="string"&&(t&&(e=`\x1B[${D1(t)}m${e}\x1B[39m`),n&&(e=`\x1B[${D1(n)+QE}m${e}\x1B[49m`)),e}function G1(e,t=["constructor"]){let n=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(n),s=e;for(let i of r){let o=s[i];typeof o=="function"&&(t.find(c=>i===c)||(s[i]=o.bind(e)))}}function gs(e,t){if(!e)throw new Error(t||"Assertion failed")}function Ln(){let e;if(Cn()&&bi.performance)e=bi?.performance?.now?.();else if("hrtime"in Oi){let t=Oi?.hrtime?.();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var ir={debug:Cn()&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},$E={enabled:!0,level:0};function or(){}var z1={},k1={once:!0},xs=class{constructor({id:t}={id:""}){this.VERSION=Ca,this._startTs=Ln(),this._deltaTs=Ln(),this.userData={},this.LOG_THROTTLE_TIMEOUT=0,this.id=t,this.userData={},this._storage=new Pi(`__probe-${this.id}__`,$E),this.timeStamp(`${this.id} started`),G1(this),Object.seal(this)}set level(t){this.setLevel(t)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Ln()-this._startTs).toPrecision(10))}getDelta(){return Number((Ln()-this._deltaTs).toPrecision(10))}set priority(t){this.level=t}get priority(){return this.level}getPriority(){return this.level}enable(t=!0){return this._storage.setConfiguration({enabled:t}),this}setLevel(t){return this._storage.setConfiguration({level:t}),this}get(t){return this._storage.config[t]}set(t,n){this._storage.setConfiguration({[t]:n})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(t,n){if(!t)throw new Error(n||"Assertion failed")}warn(t){return this._getLogFunction(0,t,ir.warn,arguments,k1)}error(t){return this._getLogFunction(0,t,ir.error,arguments)}deprecated(t,n){return this.warn(`\`${t}\` is deprecated and will be removed in a later version. Use \`${n}\` instead`)}removed(t,n){return this.error(`\`${t}\` has been removed. Use \`${n}\` instead`)}probe(t,n){return this._getLogFunction(t,n,ir.log,arguments,{time:!0,once:!0})}log(t,n){return this._getLogFunction(t,n,ir.debug,arguments)}info(t,n){return this._getLogFunction(t,n,console.info,arguments)}once(t,n){return this._getLogFunction(t,n,ir.debug||ir.info,arguments,k1)}table(t,n,r){return n?this._getLogFunction(t,n,console.table||or,r&&[r],{tag:eT(n)}):or}time(t,n){return this._getLogFunction(t,n,console.time?console.time:console.info)}timeEnd(t,n){return this._getLogFunction(t,n,console.timeEnd?console.timeEnd:console.info)}timeStamp(t,n){return this._getLogFunction(t,n,console.timeStamp||or)}group(t,n,r={collapsed:!1}){let s=V1({logLevel:t,message:n,opts:r}),{collapsed:i}=r;return s.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(s)}groupCollapsed(t,n,r={}){return this.group(t,n,Object.assign({},r,{collapsed:!0}))}groupEnd(t){return this._getLogFunction(t,"",console.groupEnd||or)}withGroup(t,n,r){this.group(t,n)();try{r()}finally{this.groupEnd(t)()}}trace(){console.trace&&console.trace()}_shouldLog(t){return this.isEnabled()&&this.getLevel()>=q1(t)}_getLogFunction(t,n,r,s,i){if(this._shouldLog(t)){i=V1({logLevel:t,message:n,args:s,opts:i}),r=r||i.method,gs(r),i.total=this.getTotal(),i.delta=this.getDelta(),this._deltaTs=Ln();let o=i.tag||i.message;if(i.once&&o)if(!z1[o])z1[o]=Ln();else return or;return n=tT(this.id,i.message,i),r.bind(console,n,...i.args)}return or}};xs.VERSION=Ca;function q1(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return gs(Number.isFinite(t)&&t>=0),t}function V1(e){let{logLevel:t,message:n}=e;e.logLevel=q1(t);let r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(typeof t){case"string":case"function":n!==void 0&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t);break;default:}typeof e.message=="function"&&(e.message=e.message());let s=typeof e.message;return gs(s==="string"||s==="object"),Object.assign(e,{args:r},e.opts)}function tT(e,t,n){if(typeof t=="string"){let r=n.time?v1(F1(n.total)):"";t=n.time?`${e}: ${r} ${t}`:`${e}: ${t}`,t=U1(t,n.color,n.background)}return t}function eT(e){for(let t in e)for(let n in e[t])return n||"untitled";return"empty"}globalThis.probe={};var La=new xs({id:"@probe.gl/log"});function Ra(e,t){return H1(e||{},t)}function H1(e,t,n=0){if(n>3)return t;let r={...e};for(let[s,i]of Object.entries(t))i&&typeof i=="object"&&!Array.isArray(i)?r[s]=H1(r[s]||{},t[s],n+1):r[s]=t[s];return r}function wa(e){globalThis.loaders||={},globalThis.loaders.modules||={},Object.assign(globalThis.loaders.modules,e)}function Ia(e){return globalThis.loaders?.modules?.[e]||null}function nT(){return globalThis._loadersgl_?.version||(globalThis._loadersgl_=globalThis._loadersgl_||{},globalThis._loadersgl_.version="4.2.1"),globalThis._loadersgl_.version}var Y1=nT();function W1(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var de={self:typeof self<"u"&&self,window:typeof window<"u"&&window,global:typeof global<"u"&&global,document:typeof document<"u"&&document},Ev=de.self||de.window||de.global||{},Tv=de.window||de.self||de.global||{},_v=de.global||de.self||de.window||{},Sv=de.document||{};var cr=typeof process!="object"||String(process)!=="[object process]"||process.browser,Fi=typeof importScripts=="function",Bv=typeof window<"u"&&typeof window.orientation<"u",J1=typeof process<"u"&&process.version&&/v([0-9]*)/.exec(process.version),Cv=J1&&parseFloat(J1[1])||0;var ba={};async function me(e,t=null,n={},r=null){return t&&(e=X1(e,t,n,r)),ba[e]=ba[e]||rT(e),await ba[e]}function X1(e,t,n={},r=null){if(!n.useLocalLibraries&&e.startsWith("http"))return e;r=r||e;let s=n.modules||{};return s[r]?s[r]:cr?n.CDN?(W1(n.CDN.startsWith("http")),`${n.CDN}/${t}@${Y1}/dist/libs/${r}`):Fi?`../src/libs/${r}`:`modules/${t}/src/libs/${r}`:`modules/${t}/dist/libs/${r}`}async function rT(e){if(e.endsWith("wasm"))return await iT(e);if(!cr)try{let{requireFromFile:n}=globalThis.loaders||{};return await n?.(e)}catch(n){return console.error(n),null}if(Fi)return importScripts(e);let t=await oT(e);return sT(t,e)}function sT(e,t){if(!cr){let{requireFromString:r}=globalThis.loaders||{};return r?.(e,t)}if(Fi)return eval.call(globalThis,e),null;let n=document.createElement("script");n.id=t;try{n.appendChild(document.createTextNode(e))}catch{n.text=e}return document.body.appendChild(n),null}async function iT(e){let{readFileAsArrayBuffer:t}=globalThis.loaders||{};return cr||!t||e.startsWith("http")?await(await fetch(e)).arrayBuffer():await t(e)}async function oT(e){let{readFileAsText:t}=globalThis.loaders||{};return cr||!t||e.startsWith("http")?await(await fetch(e)).text():await t(e)}function K1(e,t=5){return typeof e=="string"?e.slice(0,t):ArrayBuffer.isView(e)?j1(e.buffer,e.byteOffset,t):e instanceof ArrayBuffer?j1(e,0,t):""}function j1(e,t,n){if(e.byteLength<=t+n)return"";let r=new DataView(e),s="";for(let i=0;i<n;i++)s+=String.fromCharCode(r.getUint8(t+i));return s}function Oa(e){try{return JSON.parse(e)}catch{throw new Error(`Failed to parse JSON from data starting with "${K1(e)}"`)}}function Ms(...e){let t=e,n=t&&t.length>1&&t[0].constructor||null;if(!n)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let r=t.reduce((o,c)=>o+c.length,0),s=new n(r),i=0;for(let o of t)s.set(o,i),i+=o.length;return s}function Rn(e,t,n){let r=n!==void 0?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function Xe(e,t){return z(e>=0),z(t>0),e+(t-1)&~(t-1)}function Pa(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{let s=e.byteOffset,i=e.byteLength;r=new Uint8Array(e.buffer||e.arrayBuffer,s,i)}return t.set(r,n),n+Xe(r.byteLength,4)}function As(){let e;if(typeof window<"u"&&window.performance)e=window.performance.now();else if(typeof process<"u"&&process.hrtime){let t=process.hrtime();e=t[0]*1e3+t[1]/1e6}else e=Date.now();return e}var wn=class{constructor(t,n){this.sampleSize=1,this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this.name=t,this.type=n,this.reset()}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}setSampleSize(t){return this.sampleSize=t,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(t){return this._count+=t,this._samples++,this._checkSampling(),this}subtractCount(t){return this._count-=t,this._samples++,this._checkSampling(),this}addTime(t){return this._time+=t,this.lastTiming=t,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=As(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(As()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}};var je=class{constructor(t){this.stats={},this.id=t.id,this.stats={},this._initializeStats(t.stats),Object.seal(this)}get(t,n="count"){return this._getOrCreate({name:t,type:n})}get size(){return Object.keys(this.stats).length}reset(){for(let t of Object.values(this.stats))t.reset();return this}forEach(t){for(let n of Object.values(this.stats))t(n)}getTable(){let t={};return this.forEach(n=>{t[n.name]={time:n.time||0,count:n.count||0,average:n.getAverageTime()||0,hz:n.getHz()||0}}),t}_initializeStats(t=[]){t.forEach(n=>this._getOrCreate(n))}_getOrCreate(t){let{name:n,type:r}=t,s=this.stats[n];return s||(t instanceof wn?s=t:s=new wn(n,r),this.stats[n]=s),s}};var cT="Queued Requests",aT="Active Requests",hT="Cancelled Requests",lT="Queued Requests Ever",fT="Active Requests Ever",pT={id:"request-scheduler",throttleRequests:!0,maxRequests:6,debounceTime:0},Ke=class{props;stats;activeRequestCount=0;requestQueue=[];requestMap=new Map;updateTimer=null;constructor(t={}){this.props={...pT,...t},this.stats=new je({id:this.props.id}),this.stats.get(cT),this.stats.get(aT),this.stats.get(hT),this.stats.get(lT),this.stats.get(fT)}scheduleRequest(t,n=()=>0){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(t))return this.requestMap.get(t);let r={handle:t,priority:0,getPriority:n},s=new Promise(i=>(r.resolve=i,r));return this.requestQueue.push(r),this.requestMap.set(t,s),this._issueNewRequests(),s}_issueRequest(t){let{handle:n,resolve:r}=t,s=!1,i=()=>{s||(s=!0,this.requestMap.delete(n),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({done:i}):Promise.resolve({done:i})}_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;let t=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(t!==0){this._updateAllRequests();for(let n=0;n<t;++n){let r=this.requestQueue.shift();r&&this._issueRequest(r)}}}_updateAllRequests(){let t=this.requestQueue;for(let n=0;n<t.length;++n){let r=t[n];this._updateRequest(r)||(t.splice(n,1),this.requestMap.delete(r.handle),n--)}t.sort((n,r)=>n.priority-r.priority)}_updateRequest(t){return t.priority=t.getPriority(t.handle),t.priority<0?(t.resolve(null),!1):!0}};var Ze={};At(Ze,{dirname:()=>dT,filename:()=>uT,join:()=>mT,resolve:()=>gT});function Z1(){if(typeof process<"u"&&typeof process.cwd<"u")return process.cwd();let e=window.location?.pathname;return e?.slice(0,e.lastIndexOf("/")+1)||""}function uT(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(t+1):""}function dT(e){let t=e?e.lastIndexOf("/"):-1;return t>=0?e.substr(0,t):""}function mT(...e){let t="/";return e=e.map((n,r)=>(r&&(n=n.replace(new RegExp(`^${t}`),"")),r!==e.length-1&&(n=n.replace(new RegExp(`${t}$`),"")),n)),e.join(t)}function gT(...e){let t=[];for(let i=0;i<e.length;i++)t[i]=e[i];let n="",r=!1,s;for(let i=t.length-1;i>=-1&&!r;i--){let o;i>=0?o=t[i]:(s===void 0&&(s=Z1()),o=s),o.length!==0&&(n=`${o}/${n}`,r=o.charCodeAt(0)===ys)}return n=xT(n,!r),r?`/${n}`:n.length>0?n:"."}var ys=47,Na=46;function xT(e,t){let n="",r=-1,s=0,i,o=!1;for(let c=0;c<=e.length;++c){if(c<e.length)i=e.charCodeAt(c);else{if(i===ys)break;i=ys}if(i===ys){if(!(r===c-1||s===1))if(r!==c-1&&s===2){if(n.length<2||!o||n.charCodeAt(n.length-1)!==Na||n.charCodeAt(n.length-2)!==Na){if(n.length>2){let a=n.length-1,h=a;for(;h>=0&&n.charCodeAt(h)!==ys;--h);if(h!==a){n=h===-1?"":n.slice(0,h),r=c,s=0,o=!1;continue}}else if(n.length===2||n.length===1){n="",r=c,s=0,o=!1;continue}}t&&(n.length>0?n+="/..":n="..",o=!0)}else{let a=e.slice(r+1,c);n.length>0?n+=`/${a}`:n=a,o=!1}r=c,s=0}else i===Na&&s!==-1?++s:s=-1}return n}var vi=class{fetch;loadOptions;_needsRefresh=!0;props;constructor(t){this.props={...t},this.loadOptions={...t.loadOptions},this.fetch=MT(this.loadOptions)}setProps(t){this.props=Object.assign(this.props,t),this.setNeedsRefresh()}setNeedsRefresh(){this._needsRefresh=!0}getNeedsRefresh(t=!0){let n=this._needsRefresh;return t&&(this._needsRefresh=!1),n}};function MT(e){let t=e?.fetch;if(t&&typeof t=="function")return(r,s)=>t(r,s);let n=e?.fetch;return n&&typeof n!="function"?r=>fetch(r,n):r=>fetch(r)}var Wt=class extends vi{};sr(Wt,"type","template"),sr(Wt,"testURL",t=>!1);function Q1(e,t){let n=re.parseTextSync?.(e,t),r=n?.ServiceExceptionReport?.ServiceException||n?.["ogc:ServiceExceptionReport"]?.["ogc:ServiceException"];return typeof r=="string"?r:r.value||r.code||"Unknown error"}var AT="4.2.1",Es={dataType:null,batchType:null,id:"wms-error",name:"WMS Error",module:"wms",version:AT,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.se_xml","application/xml","text/xml"],testText:yT,options:{wms:{throwOnError:!1}},parse:async(e,t)=>Fa(new TextDecoder().decode(e),t),parseSync:(e,t)=>Fa(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Fa(e,t)};function yT(e){return e.startsWith("<?xml")}function Fa(e,t){let n={...Es.options.wms,...t?.wms},r=Q1(e,n),s=n.minimalErrors?r:`WMS Service error: ${r}`;if(n.throwOnError)throw new Error(s);return s}function In(e){return Array.isArray(e)?e:e?[e]:[]}function Ts(e){let t=In(e);return t.length>0&&t.every(n=>typeof n=="string")?t:[]}function _s(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseFloat(e);default:return}}function Di(e,t=void 0){switch(typeof e){case"number":return e;case"string":return parseInt(e,10);default:return}}function bn(e){switch(e){case"true":return!0;case"false":return!1;case"1":return!0;case"0":return!1;default:return!1}}function va(e,t){let n=re.parseTextSync?.(e,t),r=n.WMT_MS_Capabilities||n.WMS_Capabilities||n,s=ET(r);if(t?.inheritedLayerProps)for(let i of s.layers)tp(i,null);return t?.includeRawJSON&&(s.json=r),t?.includeXMLText&&(s.xml=e),s}function ET(e){let t={version:String(e.version||""),name:String(e.Service?.Name||"unnamed"),title:e.Service?.Title?String(e.Service?.Title):void 0,abstract:e.Service?.Abstract?String(e.Service?.Abstract):void 0,keywords:Ts(e.Service?.KeywordList?.Keyword),fees:e.Service?.Fees?JSON.stringify(e.Service?.Fees):void 0,accessConstraints:e.Service?.AccessConstraints?JSON.stringify(e.Service?.AccessConstraints):void 0,layerLimit:Di(e.Service?.LayerLimit),maxWidth:Di(e.Service?.maxWidth),maxHeight:Di(e.Service?.maxHeight),layers:[],requests:TT(e.Capability?.Request),exceptions:_T(e.Exception)},n=In(e.Capability?.Layer);for(let r of n)t.layers.push($1(r));for(let[r,s]of Object.entries(t))s===void 0&&delete t[r];return t}function TT(e){let t={};for(let[n,r]of Object.entries(e||{})){let s=Ts(r?.Format);t[n]={mimeTypes:s}}return t}function _T(e){if(In(e?.Format).length>0)return{mimeTypes:Ts(e)}}function $1(e){let t={title:String(e?.Title||""),name:e?.Name&&String(e?.Name),abstract:e?.Name&&String(e?.Abstract),keywords:Ts(e.KeywordList?.Keyword)},n=e?.CRS||e?.SRS;n&&Array.isArray(n)&&n.every(h=>typeof h=="string")&&(t.crs=n);let r=e?.EX_GeographicBoundingBox&&ST(e?.EX_GeographicBoundingBox);r&&(t.geographicBoundingBox=r),r=e?.LatLonBoundingBox&&BT(e?.LatLonBoundingBox),r&&(t.geographicBoundingBox=r);let s=e?.BoundingBox&&CT(e?.BoundingBox);s&&s.length>0&&(t.boundingBoxes=s);let o=In(e?.Dimension).map(h=>RT(h));o.length&&(t.dimensions=o),e?.opaque&&(t.opaque=bn(e?.opaque)),e?.cascaded&&(t.cascaded=bn(e?.cascaded)),e?.queryable&&(t.queryable=bn(e?.queryable));let c=In(e?.Layer),a=[];for(let h of c)a.push($1(h));a.length>0&&(t.layers=a);for(let[h,l]of Object.entries(t))l===void 0&&delete t[h];return t}function ST(e){let{westBoundLongitude:t,northBoundLatitude:n,eastBoundLongitude:r,southBoundLatitude:s}=e;return[[t,s],[r,n]]}function BT(e){let{minx:t,miny:n,maxx:r,maxy:s}=e;return[[t,n],[r,s]]}function CT(e){return In(e).map(n=>LT(n))}function LT(e){let{CRS:t,SRS:n,minx:r,miny:s,maxx:i,maxy:o,resx:c,resy:a}=e,h={crs:t||n,boundingBox:[[_s(r),_s(s)],[_s(i),_s(o)]]};return c&&(h.xResolution=c),a&&(h.yResolution=a),h}function RT(e){let{name:t,units:n,value:r}=e,s={name:t,units:n,extent:r};return e.unitSymbol&&(s.unitSymbol=e.unitSymbol),e.default&&(s.defaultValue=e.default),e.multipleValues&&(s.multipleValues=bn(e.multipleValues)),e.nearestValue&&(s.nearestValue=bn(e.nearestValue)),e.current&&(s.current=bn(e.current)),s}function tp(e,t){t?.geographicBoundingBox&&!e.geographicBoundingBox&&(e.geographicBoundingBox=[...t.geographicBoundingBox]),t?.crs&&!e.crs&&(e.crs=[...t.crs]),t?.boundingBoxes&&!e.boundingBoxes&&(e.boundingBoxes=[...t.boundingBoxes]),t?.dimensions&&!e.dimensions&&(e.dimensions=[...t.dimensions]);for(let n of e.layers||[])tp(n,e)}var wT="4.2.1",ar={dataType:null,batchType:null,id:"wms-capabilities",name:"WMS Capabilities",module:"wms",version:wT,worker:!1,extensions:["xml"],mimeTypes:["application/vnd.ogc.wms_xml","application/xml","text/xml"],testText:IT,options:{wms:{}},parse:async(e,t)=>va(new TextDecoder().decode(e),t?.wms),parseTextSync:(e,t)=>va(e,t?.wms)};function IT(e){return e.startsWith("<?xml")}function Da(e,t){let r=(re.parseTextSync?.(e,t)).FeatureInfoResponse?.FIELDS||[];return{features:(Array.isArray(r)?r:[r]).map(i=>bT(i))}}function bT(e){return{attributes:e||{},type:"",bounds:{bottom:0,top:0,left:0,right:0}}}var ep={...ar,dataType:null,id:"wms-feature-info",name:"WMS FeatureInfo",parse:async(e,t)=>Da(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Da(e,t)};function Ua(e,t){return re.parseTextSync?.(e,t)}var np={...ar,dataType:null,id:"wms-layer-description",name:"WMS DescribeLayer",parse:async(e,t)=>Ua(new TextDecoder().decode(e),t),parseTextSync:(e,t)=>Ua(e,t)};function rp(e,t){let{type:n="auto"}=e,r=n==="auto"?PT(e.url,t):OT(n,t);if(!r)throw new Error("Not a valid image source type");return r.create(e)}function OT(e,t){for(let n of t)if(n.type===e)return n;return null}function PT(e,t){for(let n of t)if(n.testURL&&n.testURL(e))return n;return null}var sp="4.2.1";var NT=globalThis.loaders?.parseImageNode,Ga=typeof Image<"u",za=typeof ImageBitmap<"u",FT=Boolean(NT),ka=ms?!0:FT;function ip(e){switch(e){case"auto":return za||Ga||ka;case"imagebitmap":return za;case"image":return Ga;case"data":return ka;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}function op(){if(za)return"imagebitmap";if(Ga)return"image";if(ka)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}function cp(e){let t=vT(e);if(!t)throw new Error("Not an image");return t}function Ss(e){switch(cp(e)){case"data":return e;case"image":case"imagebitmap":let t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("getImageData");return t.width=e.width,t.height=e.height,n.drawImage(e,0,0),n.getImageData(0,0,e.width,e.height);default:throw new Error("getImageData")}}function vT(e){return typeof ImageBitmap<"u"&&e instanceof ImageBitmap?"imagebitmap":typeof Image<"u"&&e instanceof Image?"image":e&&typeof e=="object"&&e.data&&e.width&&e.height?"data":null}var DT=/^data:image\/svg\+xml/,UT=/\.svg((\?|#).*)?$/;function Ui(e){return e&&(DT.test(e)||UT.test(e))}function ap(e,t){if(Ui(t)){let r=new TextDecoder().decode(e);try{typeof unescape=="function"&&typeof encodeURIComponent=="function"&&(r=unescape(encodeURIComponent(r)))}catch(i){throw new Error(i.message)}return`data:image/svg+xml;base64,${btoa(r)}`}return Va(e,t)}function Va(e,t){if(Ui(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Gi(e,t,n){let r=ap(e,n),s=self.URL||self.webkitURL,i=typeof r!="string"&&s.createObjectURL(r);try{return await GT(i||r,t)}finally{i&&s.revokeObjectURL(i)}}async function GT(e,t){let n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((r,s)=>{try{n.onload=()=>r(n),n.onerror=i=>{let o=i instanceof Error?i.message:"error";s(new Error(o))}}catch(i){s(i)}})}var zT={},hp=!0;async function lp(e,t,n){let r;Ui(n)?r=await Gi(e,t,n):r=Va(e,n);let s=t&&t.imagebitmap;return await kT(r,s)}async function kT(e,t=null){if((VT(t)||!hp)&&(t=null),t)try{return await createImageBitmap(e,t)}catch(n){console.warn(n),hp=!1}return await createImageBitmap(e)}function VT(e){for(let t in e||zT)return!1;return!0}function fp(e){return!WT(e,"ftyp",4)||!(e[8]&96)?null:qT(e)}function qT(e){switch(HT(e,8,12).replace("\0"," ").trim()){case"avif":case"avis":return{extension:"avif",mimeType:"image/avif"};default:return null}}function HT(e,t,n){return String.fromCharCode(...e.slice(t,n))}function YT(e){return[...e].map(t=>t.charCodeAt(0))}function WT(e,t,n=0){let r=YT(t);for(let s=0;s<r.length;++s)if(r[s]!==e[s+n])return!1;return!0}var ge=!1,Bs=!0;function On(e){let t=Cs(e);return XT(t)||ZT(t)||jT(t)||KT(t)||JT(t)}function JT(e){let t=new Uint8Array(e instanceof DataView?e.buffer:e),n=fp(t);return n?{mimeType:n.mimeType,width:0,height:0}:null}function XT(e){let t=Cs(e);return t.byteLength>=24&&t.getUint32(0,ge)===2303741511?{mimeType:"image/png",width:t.getUint32(16,ge),height:t.getUint32(20,ge)}:null}function jT(e){let t=Cs(e);return t.byteLength>=10&&t.getUint32(0,ge)===1195984440?{mimeType:"image/gif",width:t.getUint16(6,Bs),height:t.getUint16(8,Bs)}:null}function KT(e){let t=Cs(e);return t.byteLength>=14&&t.getUint16(0,ge)===16973&&t.getUint32(2,Bs)===t.byteLength?{mimeType:"image/bmp",width:t.getUint32(18,Bs),height:t.getUint32(22,Bs)}:null}function ZT(e){let t=Cs(e);if(!(t.byteLength>=3&&t.getUint16(0,ge)===65496&&t.getUint8(2)===255))return null;let{tableMarkers:r,sofMarkers:s}=QT(),i=2;for(;i+9<t.byteLength;){let o=t.getUint16(i,ge);if(s.has(o))return{mimeType:"image/jpeg",height:t.getUint16(i+5,ge),width:t.getUint16(i+7,ge)};if(!r.has(o))return null;i+=2,i+=t.getUint16(i,ge)}return null}function QT(){let e=new Set([65499,65476,65484,65501,65534]);for(let n=65504;n<65520;++n)e.add(n);return{tableMarkers:e,sofMarkers:new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502])}}function Cs(e){if(e instanceof DataView)return e;if(ArrayBuffer.isView(e))return new DataView(e.buffer);if(e instanceof ArrayBuffer)return new DataView(e);throw new Error("toDataView")}async function pp(e,t){let{mimeType:n}=On(e)||{},r=globalThis.loaders?.parseImageNode;return z(r),await r(e,n)}async function up(e,t,n){t=t||{};let s=(t.image||{}).type||"auto",{url:i}=n||{},o=$T(s),c;switch(o){case"imagebitmap":c=await lp(e,t,i);break;case"image":c=await Gi(e,t,i);break;case"data":c=await pp(e,t);break;default:z(!1)}return s==="data"&&(c=Ss(c)),c}function $T(e){switch(e){case"auto":case"data":return op();default:return ip(e),e}}var t_=["png","jpg","jpeg","gif","webp","bmp","ico","svg","avif"],e_=["image/png","image/jpeg","image/gif","image/webp","image/avif","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],n_={image:{type:"auto",decode:!0}},Qe={dataType:null,batchType:null,id:"image",module:"images",name:"Images",version:sp,mimeTypes:e_,extensions:t_,parse:up,tests:[e=>Boolean(On(new DataView(e)))],options:n_};var qa={};function Ha(e){if(qa[e]===void 0){let t=ms?s_(e):r_(e);qa[e]=t}return qa[e]}function r_(e){let t=["image/png","image/jpeg","image/gif"],n=globalThis.loaders?.imageFormatsNode||t,r=globalThis.loaders?.parseImageNode;return Boolean(r)&&n.includes(e)}function s_(e){switch(e){case"image/avif":case"image/webp":return i_(e);default:return!0}}function i_(e){try{return document.createElement("canvas").toDataURL(e).indexOf(`data:${e}`)===0}catch{return!1}}var dp={type:"wms",testURL:e=>e.toLowerCase().includes("wms"),create:e=>new Ya(e)},Ya=class extends Wt{url;data;substituteCRS84;flipCRS;wmsParameters;vendorParameters;capabilities=null;constructor(t){super(t),this.url=t.url,this.data=t.url,this.substituteCRS84=t.substituteCRS84??!1,this.flipCRS=["EPSG:4326"],this.wmsParameters={layers:void 0,query_layers:void 0,styles:void 0,version:"1.3.0",crs:"EPSG:4326",format:"image/png",info_format:"text/plain",transparent:void 0,time:void 0,elevation:void 0,...t.wmsParameters},this.vendorParameters=t.vendorParameters||{}}async getMetadata(){let t=await this.getCapabilities();return this.normalizeMetadata(t)}async getImage(t){let{boundingBox:n,bbox:r,...s}=t,i={bbox:n?[...n[0],...n[1]]:r,...s};return await this.getMap(i)}normalizeMetadata(t){return t}async getCapabilities(t,n){let r=this.getCapabilitiesURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();this._checkResponse(s,i);let o=await ar.parse(i,this.loadOptions);return this.capabilities=o,o}async getMap(t,n){let r=this.getMapURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();this._checkResponse(s,i);try{return await Qe.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}async getFeatureInfo(t,n){let r=this.getFeatureInfoURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();return this._checkResponse(s,i),await ep.parse(i,this.loadOptions)}async getFeatureInfoText(t,n){let r=this.getFeatureInfoURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();return this._checkResponse(s,i),new TextDecoder().decode(i)}async describeLayer(t,n){let r=this.describeLayerURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();return this._checkResponse(s,i),await np.parse(i,this.loadOptions)}async getLegendGraphic(t,n){let r=this.getLegendGraphicURL(t,n),s=await this.fetch(r),i=await s.arrayBuffer();this._checkResponse(s,i);try{return await Qe.parse(i,this.loadOptions)}catch{throw this._parseError(i)}}getCapabilitiesURL(t,n){let r={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetCapabilities",r,n)}getMapURL(t,n){t=this._getWMS130Parameters(t);let r={version:this.wmsParameters.version,format:this.wmsParameters.format,transparent:this.wmsParameters.transparent,time:this.wmsParameters.time,elevation:this.wmsParameters.elevation,layers:this.wmsParameters.layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...t};return this._getWMSUrl("GetMap",r,n)}getFeatureInfoURL(t,n){t=this._getWMS130Parameters(t);let{boundingBox:r,bbox:s}=t;t.bbox=r?[...r[0],...r[1]]:s;let i={version:this.wmsParameters.version,info_format:this.wmsParameters.info_format,layers:this.wmsParameters.layers,query_layers:this.wmsParameters.query_layers,styles:this.wmsParameters.styles,crs:this.wmsParameters.crs,...t};return this._getWMSUrl("GetFeatureInfo",i,n)}describeLayerURL(t,n){let r={version:this.wmsParameters.version,...t};return this._getWMSUrl("DescribeLayer",r,n)}getLegendGraphicURL(t,n){let r={version:this.wmsParameters.version,...t};return this._getWMSUrl("GetLegendGraphic",r,n)}_parseWMSUrl(t){let[n,r]=t.split("?"),s=r.split("&"),i={};for(let o of s){let[c,a]=o.split("=");i[c]=a}return{url:n,parameters:i}}_getWMSUrl(t,n,r){let s=this.url,i=!0,o={service:"WMS",version:n.version,request:t,...n,...this.vendorParameters,...r},c=["transparent","time","elevation"];for(let[a,h]of Object.entries(o))(!c.includes(a)||h)&&(s+=i?"?":"&",i=!1,s+=this._getURLParameter(a,h,n));return encodeURI(s)}_getWMS130Parameters(t){let n={...t};return n.srs&&(n.crs=n.crs||n.srs,delete n.srs),n}_getURLParameter(t,n,r){switch(t){case"crs":r.version!=="1.3.0"?t="srs":this.substituteCRS84&&n==="EPSG:4326"&&(n="CRS:84");break;case"srs":r.version==="1.3.0"&&(t="crs");break;case"bbox":let s=this._flipBoundingBox(n,r);s&&(n=s);break;case"x":r.version==="1.3.0"&&(t="i");break;case"y":r.version==="1.3.0"&&(t="j");break;default:}return t=t.toUpperCase(),Array.isArray(n)?`${t}=${n.join(",")}`:`${t}=${n?String(n):""}`}_flipBoundingBox(t,n){if(!Array.isArray(t)||t.length!==4)return null;let r=n.version==="1.3.0"&&this.flipCRS.includes(n.crs||"")&&!(this.substituteCRS84&&n.crs==="EPSG:4326"),s=t;return r?[s[1],s[0],s[3],s[2]]:s}async _fetchArrayBuffer(t){let n=await this.fetch(t),r=await n.arrayBuffer();return this._checkResponse(n,r),r}_checkResponse(t,n){let r=t.headers["content-type"];if(!t.ok||Es.mimeTypes.includes(r)){let s=Ra(this.loadOptions,{wms:{throwOnError:!0}}),i=Es.parseSync?.(n,s);throw new Error(i)}}_parseError(t){let n=Es.parseSync?.(t,this.loadOptions);return new Error(n)}};var hr=class extends Wt{constructor(t){super(t)}async getMetadata(){throw new Error("ImageSource.getMetadata not implemented")}async getImage(t){let n=this.getGranularParameters(t),r=this.getURLFromTemplate(n),i=await(await this.fetch(r)).arrayBuffer();return await Qe.parse(i)}getGranularParameters(t){let[[n,r],[s,i]]=t.boundingBox;return{...t,east:n,north:r,south:i,west:s}}getURLFromTemplate(t){let n=this.props.url;for(let[r,s]of Object.entries(t))n=n.replace(`\${${r}}`,String(s)),n=n.replace(`{${r}}`,String(s));return n}};sr(hr,"type","template"),sr(hr,"testURL",t=>t.toLowerCase().includes("{"));var Wa=class extends hr{data;constructor(t){super(t),this.data=t.url}async getMetadata(){return await this.metadata()}async getImage(t){throw new Error("not implemented")}async metadata(){throw new Error("not implemented")}exportImage(t){throw new Error("not implemented")}metadataURL(t){return`${this.props.url}?f=pjson`}exportImageURL(t){let n=`bbox=${t.bbox[0]},${t.bbox[1]},${t.bbox[2]},${t.bbox[3]}`,r=`size=${t.width},${t.height}`,s={...t,bbox:n,size:r};return delete s.width,delete s.height,this.getUrl("exportImage",s)}getUrl(t,n,r){let s=`${this.props.url}/${t}`,i=!0;for(let[o,c]of Object.entries(n))s+=i?"?":"&",i=!1,Array.isArray(c)?s+=`${o.toUpperCase()}=${c.join(",")}`:s+=`${o.toUpperCase()}=${c?String(c):""}`;return s}async checkResponse(t){if(!t.ok)throw new Error("error")}},mp={type:"arcgis-image-server",testURL:e=>e.toLowerCase().includes("ImageServer"),create:e=>new Wa(e)};var o_=[dp,mp];function Ja(e){return rp(e,o_)}var K8=1/Math.PI*180,Z8=1/180*Math.PI,c_={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...c_}};var pt=globalThis.mathgl.config;function Xa(e,{precision:t=pt.precision}={}){return e=a_(e),`${parseFloat(e.toPrecision(t))}`}function xe(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function $e(e,t,n){return xe(e)?e.map((r,s)=>$e(r,t[s],n)):n*t+(1-n)*e}function Me(e,t,n){let r=pt.EPSILON;n&&(pt.EPSILON=n);try{if(e===t)return!0;if(xe(e)&&xe(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!Me(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=pt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{pt.EPSILON=r}}function a_(e){return Math.round(e/pt.EPSILON)*pt.EPSILON}var tn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:xe(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(pt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Xa(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!Me(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(pt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function h_(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function H(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function en(e,t,n=""){if(pt.debug&&!h_(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Ae(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var lr=class extends tn{get x(){return this[0]}set x(t){this[0]=H(t)}get y(){return this[1]}set y(t){this[1]=H(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return H(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return H(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Ae(t>=0&&t<this.ELEMENTS,"index is out of range"),H(this[t])}setComponent(t,n){return Ae(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var ot=typeof Float32Array<"u"?Float32Array:Array;var aD=Math.PI/180;function l_(){let e=new ot(2);return ot!=Float32Array&&(e[0]=0,e[1]=0),e}function Mp(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}function Ap(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var hD=function(){let e=l_();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function yp(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function zi(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Ep(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}function Tp(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function ki(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function ja(){let e=new ot(3);return ot!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function f_(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Ka(e,t,n){let r=new ot(3);return r[0]=e,r[1]=t,r[2]=n,r}function _p(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Za(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function pr(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function ur(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Vi(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function qi(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function Sp(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Bp(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Cp(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Lp(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&Za(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var Rp=f_;var pD=function(){let e=ja();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Qa=[0,0,0],Hi,O=class extends lr{static get ZERO(){return Hi||(Hi=new O(0,0,0),Object.freeze(Hi)),Hi}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&xe(t)?this.copy(t):(pt.debug&&(H(t),H(n),H(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return pt.debug&&(H(t.x),H(t.y),H(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=H(t)}angle(t){return Lp(this,t)}cross(t){return pr(this,this,t),this.check()}rotateX({radians:t,origin:n=Qa}){return Sp(this,this,n,t),this.check()}rotateY({radians:t,origin:n=Qa}){return Bp(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=Qa}){return Cp(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return ur(this,this,t),this.check()}transformAsVector(t){return zi(this,this,t),this.check()}transformByMatrix3(t){return Vi(this,this,t),this.check()}transformByMatrix2(t){return Ep(this,this,t),this.check()}transformByQuaternion(t){return qi(this,this,t),this.check()}};var Yi,dr=class extends lr{static get ZERO(){return Yi||(Yi=new dr(0,0,0,0),Object.freeze(Yi)),Yi}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),xe(t)&&arguments.length===1?this.copy(t):(pt.debug&&(H(t),H(n),H(r),H(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 pt.debug&&(H(t.x),H(t.y),H(t.z),H(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]=H(t)}get w(){return this[3]}set w(t){this[3]=H(t)}transform(t){return ur(this,this,t),this.check()}transformByMatrix3(t){return ki(this,this,t),this.check()}transformByMatrix2(t){return Tp(this,this,t),this.check()}transformByQuaternion(t){return qi(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var mr=class extends tn{toString(){let t="[";if(pt.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=H(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function wp(){let e=new ot(9);return ot!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function Ip(e,t){if(e===t){let n=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function bp(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=l*o-c*h,p=-l*i+c*a,u=h*i-o*a,d=n*f+r*p+s*u;return d?(d=1/d,e[0]=f*d,e[1]=(-l*r+s*h)*d,e[2]=(c*r-s*o)*d,e[3]=p*d,e[4]=(l*n-s*a)*d,e[5]=(-c*n+s*i)*d,e[6]=u*d,e[7]=(-h*n+r*a)*d,e[8]=(o*n-r*i)*d,e):null}function Op(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8];return t*(h*i-o*a)+n*(-h*s+o*c)+r*(a*s-i*c)}function $a(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1],d=n[2],g=n[3],m=n[4],M=n[5],E=n[6],A=n[7],y=n[8];return e[0]=p*r+u*o+d*h,e[1]=p*s+u*c+d*l,e[2]=p*i+u*a+d*f,e[3]=g*r+m*o+M*h,e[4]=g*s+m*c+M*l,e[5]=g*i+m*a+M*f,e[6]=E*r+A*o+y*h,e[7]=E*s+A*c+y*l,e[8]=E*i+A*a+y*f,e}function Pp(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1];return e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=c,e[5]=a,e[6]=p*r+u*o+h,e[7]=p*s+u*c+l,e[8]=p*i+u*a+f,e}function Np(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=Math.sin(n),u=Math.cos(n);return e[0]=u*r+p*o,e[1]=u*s+p*c,e[2]=u*i+p*a,e[3]=u*o-p*r,e[4]=u*c-p*s,e[5]=u*a-p*i,e[6]=h,e[7]=l,e[8]=f,e}function th(e,t,n){let r=n[0],s=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function Fp(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[3]=l-M,e[6]=p+m,e[1]=l+M,e[4]=1-h-d,e[7]=u-g,e[2]=p-m,e[5]=u+g,e[8]=1-h-f,e}var eh;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(eh||(eh={}));var d_=Object.freeze([1,0,0,0,1,0,0,0,1]),ct=class extends mr{static get IDENTITY(){return g_()}static get ZERO(){return m_()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return eh}constructor(t,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):n.length>0?this.copy([t,...n]):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(d_)}fromObject(t){return this.check()}fromQuaternion(t){return Fp(this,t),this.check()}set(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=i,this[5]=a,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return Op(this)}transpose(){return Ip(this,this),this.check()}invert(){return bp(this,this),this.check()}multiplyLeft(t){return $a(this,t,this),this.check()}multiplyRight(t){return $a(this,this,t),this.check()}rotate(t){return Np(this,this,t),this.check()}scale(t){return Array.isArray(t)?th(this,this,t):th(this,this,[t,t]),this.check()}translate(t){return Pp(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=Mp(n||[-0,-0],t,this);break;case 3:r=Vi(n||[-0,-0,-0],t,this);break;case 4:r=ki(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return en(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},Wi,Ji=null;function m_(){return Wi||(Wi=new ct([0,0,0,0,0,0,0,0,0]),Object.freeze(Wi)),Wi}function g_(){return Ji||(Ji=new ct,Object.freeze(Ji)),Ji}var Rs={};At(Rs,{add:()=>k_,adjoint:()=>T_,clone:()=>M_,copy:()=>A_,create:()=>x_,decompose:()=>O_,determinant:()=>sh,equals:()=>Y_,exactEquals:()=>H_,frob:()=>z_,fromQuat:()=>fh,fromQuat2:()=>w_,fromRotation:()=>B_,fromRotationTranslation:()=>Dp,fromRotationTranslationScale:()=>P_,fromRotationTranslationScaleOrigin:()=>N_,fromScaling:()=>S_,fromTranslation:()=>__,fromValues:()=>y_,fromXRotation:()=>C_,fromYRotation:()=>L_,fromZRotation:()=>R_,frustum:()=>ph,getRotation:()=>b_,getScaling:()=>Up,getTranslation:()=>I_,identity:()=>vp,invert:()=>rh,lookAt:()=>mh,mul:()=>W_,multiply:()=>Ls,multiplyScalar:()=>V_,multiplyScalarAndAdd:()=>q_,ortho:()=>dh,orthoNO:()=>zp,orthoZO:()=>D_,perspective:()=>uh,perspectiveFromFieldOfView:()=>v_,perspectiveNO:()=>Gp,perspectiveZO:()=>F_,rotate:()=>ch,rotateX:()=>ah,rotateY:()=>hh,rotateZ:()=>lh,scale:()=>oh,set:()=>E_,str:()=>G_,sub:()=>J_,subtract:()=>kp,targetTo:()=>U_,translate:()=>ih,transpose:()=>nh});function x_(){let e=new ot(16);return ot!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function M_(e){let t=new ot(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function A_(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function y_(e,t,n,r,s,i,o,c,a,h,l,f,p,u,d,g){let m=new ot(16);return m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=s,m[5]=i,m[6]=o,m[7]=c,m[8]=a,m[9]=h,m[10]=l,m[11]=f,m[12]=p,m[13]=u,m[14]=d,m[15]=g,m}function E_(e,t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=o,e[6]=c,e[7]=a,e[8]=h,e[9]=l,e[10]=f,e[11]=p,e[12]=u,e[13]=d,e[14]=g,e[15]=m,e}function vp(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function nh(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function rh(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m,C=E*I-A*w+y*R+T*x-_*S+L*B;return C?(C=1/C,e[0]=(c*I-a*w+h*R)*C,e[1]=(s*w-r*I-i*R)*C,e[2]=(g*L-m*_+M*T)*C,e[3]=(p*_-f*L-u*T)*C,e[4]=(a*x-o*I-h*S)*C,e[5]=(n*I-s*x+i*S)*C,e[6]=(m*y-d*L-M*A)*C,e[7]=(l*L-p*y+u*A)*C,e[8]=(o*w-c*x+h*B)*C,e[9]=(r*x-n*w-i*B)*C,e[10]=(d*_-g*y+M*E)*C,e[11]=(f*y-l*_-u*E)*C,e[12]=(c*S-o*R-a*B)*C,e[13]=(n*R-r*S+s*B)*C,e[14]=(g*A-d*T-m*E)*C,e[15]=(l*T-f*A+p*E)*C,e):null}function T_(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m;return e[0]=c*I-a*w+h*R,e[1]=s*w-r*I-i*R,e[2]=g*L-m*_+M*T,e[3]=p*_-f*L-u*T,e[4]=a*x-o*I-h*S,e[5]=n*I-s*x+i*S,e[6]=m*y-d*L-M*A,e[7]=l*L-p*y+u*A,e[8]=o*w-c*x+h*B,e[9]=r*x-n*w-i*B,e[10]=d*_-g*y+M*E,e[11]=f*y-l*_-u*E,e[12]=c*S-o*R-a*B,e[13]=n*R-r*S+s*B,e[14]=g*A-d*T-m*E,e[15]=l*T-f*A+p*E,e}function sh(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],p=e[11],u=e[12],d=e[13],g=e[14],m=e[15],M=t*o-n*i,E=t*c-r*i,A=n*c-r*o,y=h*d-l*u,T=h*g-f*u,_=l*g-f*d,L=t*_-n*T+r*y,B=i*_-o*T+c*y,S=h*A-l*E+f*M,x=u*A-d*E+g*M;return a*L-s*B+m*S-p*x}function Ls(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=t[9],u=t[10],d=t[11],g=t[12],m=t[13],M=t[14],E=t[15],A=n[0],y=n[1],T=n[2],_=n[3];return e[0]=A*r+y*c+T*f+_*g,e[1]=A*s+y*a+T*p+_*m,e[2]=A*i+y*h+T*u+_*M,e[3]=A*o+y*l+T*d+_*E,A=n[4],y=n[5],T=n[6],_=n[7],e[4]=A*r+y*c+T*f+_*g,e[5]=A*s+y*a+T*p+_*m,e[6]=A*i+y*h+T*u+_*M,e[7]=A*o+y*l+T*d+_*E,A=n[8],y=n[9],T=n[10],_=n[11],e[8]=A*r+y*c+T*f+_*g,e[9]=A*s+y*a+T*p+_*m,e[10]=A*i+y*h+T*u+_*M,e[11]=A*o+y*l+T*d+_*E,A=n[12],y=n[13],T=n[14],_=n[15],e[12]=A*r+y*c+T*f+_*g,e[13]=A*s+y*a+T*p+_*m,e[14]=A*i+y*h+T*u+_*M,e[15]=A*o+y*l+T*d+_*E,e}function ih(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,h,l,f,p,u,d,g,m,M;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],p=t[6],u=t[7],d=t[8],g=t[9],m=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=p,e[7]=u,e[8]=d,e[9]=g,e[10]=m,e[11]=M,e[12]=o*r+l*s+d*i+t[12],e[13]=c*r+f*s+g*i+t[13],e[14]=a*r+p*s+m*i+t[14],e[15]=h*r+u*s+M*i+t[15]),e}function oh(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function ch(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,h,l,f,p,u,d,g,m,M,E,A,y,T,_,L,B,S,x,R,w,I,C,P;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,h=Math.sin(n),a=Math.cos(n),l=1-a,f=t[0],p=t[1],u=t[2],d=t[3],g=t[4],m=t[5],M=t[6],E=t[7],A=t[8],y=t[9],T=t[10],_=t[11],L=s*s*l+a,B=i*s*l+o*h,S=o*s*l-i*h,x=s*i*l-o*h,R=i*i*l+a,w=o*i*l+s*h,I=s*o*l+i*h,C=i*o*l-s*h,P=o*o*l+a,e[0]=f*L+g*B+A*S,e[1]=p*L+m*B+y*S,e[2]=u*L+M*B+T*S,e[3]=d*L+E*B+_*S,e[4]=f*x+g*R+A*w,e[5]=p*x+m*R+y*w,e[6]=u*x+M*R+T*w,e[7]=d*x+E*R+_*w,e[8]=f*I+g*C+A*P,e[9]=p*I+m*C+y*P,e[10]=u*I+M*C+T*P,e[11]=d*I+E*C+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function ah(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+h*r,e[5]=o*s+l*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=h*s-i*r,e[9]=l*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function hh(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-h*r,e[1]=o*s-l*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+h*s,e[9]=o*r+l*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function lh(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+h*r,e[1]=o*s+l*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=h*s-i*r,e[5]=l*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function __(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function S_(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function B_(e,t,n){let r=n[0],s=n[1],i=n[2],o=Math.sqrt(r*r+s*s+i*i),c,a,h;return o<1e-6?null:(o=1/o,r*=o,s*=o,i*=o,a=Math.sin(t),c=Math.cos(t),h=1-c,e[0]=r*r*h+c,e[1]=s*r*h+i*a,e[2]=i*r*h-s*a,e[3]=0,e[4]=r*s*h-i*a,e[5]=s*s*h+c,e[6]=i*s*h+r*a,e[7]=0,e[8]=r*i*h+s*a,e[9]=s*i*h-r*a,e[10]=i*i*h+c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function C_(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=n,e[7]=0,e[8]=0,e[9]=-n,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function L_(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-n,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=n,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function R_(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=0,e[4]=-n,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function Dp(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=r+r,a=s+s,h=i+i,l=r*c,f=r*a,p=r*h,u=s*a,d=s*h,g=i*h,m=o*c,M=o*a,E=o*h;return e[0]=1-(u+g),e[1]=f+E,e[2]=p-M,e[3]=0,e[4]=f-E,e[5]=1-(l+g),e[6]=d+m,e[7]=0,e[8]=p+M,e[9]=d-m,e[10]=1-(l+u),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function w_(e,t){let n=new ot(3),r=-t[0],s=-t[1],i=-t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=r*r+s*s+i*i+o*o;return f>0?(n[0]=(c*o+l*r+a*i-h*s)*2/f,n[1]=(a*o+l*s+h*r-c*i)*2/f,n[2]=(h*o+l*i+c*s-a*r)*2/f):(n[0]=(c*o+l*r+a*i-h*s)*2,n[1]=(a*o+l*s+h*r-c*i)*2,n[2]=(h*o+l*i+c*s-a*r)*2),Dp(e,t,n),e}function I_(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function Up(e,t){let n=t[0],r=t[1],s=t[2],i=t[4],o=t[5],c=t[6],a=t[8],h=t[9],l=t[10];return e[0]=Math.sqrt(n*n+r*r+s*s),e[1]=Math.sqrt(i*i+o*o+c*c),e[2]=Math.sqrt(a*a+h*h+l*l),e}function b_(e,t){let n=new ot(3);Up(n,t);let r=1/n[0],s=1/n[1],i=1/n[2],o=t[0]*r,c=t[1]*s,a=t[2]*i,h=t[4]*r,l=t[5]*s,f=t[6]*i,p=t[8]*r,u=t[9]*s,d=t[10]*i,g=o+l+d,m=0;return g>0?(m=Math.sqrt(g+1)*2,e[3]=.25*m,e[0]=(f-u)/m,e[1]=(p-a)/m,e[2]=(c-h)/m):o>l&&o>d?(m=Math.sqrt(1+o-l-d)*2,e[3]=(f-u)/m,e[0]=.25*m,e[1]=(c+h)/m,e[2]=(p+a)/m):l>d?(m=Math.sqrt(1+l-o-d)*2,e[3]=(p-a)/m,e[0]=(c+h)/m,e[1]=.25*m,e[2]=(f+u)/m):(m=Math.sqrt(1+d-o-l)*2,e[3]=(c-h)/m,e[0]=(p+a)/m,e[1]=(f+u)/m,e[2]=.25*m),e}function O_(e,t,n,r){t[0]=r[12],t[1]=r[13],t[2]=r[14];let s=r[0],i=r[1],o=r[2],c=r[4],a=r[5],h=r[6],l=r[8],f=r[9],p=r[10];n[0]=Math.sqrt(s*s+i*i+o*o),n[1]=Math.sqrt(c*c+a*a+h*h),n[2]=Math.sqrt(l*l+f*f+p*p);let u=1/n[0],d=1/n[1],g=1/n[2],m=s*u,M=i*d,E=o*g,A=c*u,y=a*d,T=h*g,_=l*u,L=f*d,B=p*g,S=m+y+B,x=0;return S>0?(x=Math.sqrt(S+1)*2,e[3]=.25*x,e[0]=(T-L)/x,e[1]=(_-E)/x,e[2]=(M-A)/x):m>y&&m>B?(x=Math.sqrt(1+m-y-B)*2,e[3]=(T-L)/x,e[0]=.25*x,e[1]=(M+A)/x,e[2]=(_+E)/x):y>B?(x=Math.sqrt(1+y-m-B)*2,e[3]=(_-E)/x,e[0]=(M+A)/x,e[1]=.25*x,e[2]=(T+L)/x):(x=Math.sqrt(1+B-m-y)*2,e[3]=(M-A)/x,e[0]=(_+E)/x,e[1]=(T+L)/x,e[2]=.25*x),e}function P_(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=s+s,h=i+i,l=o+o,f=s*a,p=s*h,u=s*l,d=i*h,g=i*l,m=o*l,M=c*a,E=c*h,A=c*l,y=r[0],T=r[1],_=r[2];return e[0]=(1-(d+m))*y,e[1]=(p+A)*y,e[2]=(u-E)*y,e[3]=0,e[4]=(p-A)*T,e[5]=(1-(f+m))*T,e[6]=(g+M)*T,e[7]=0,e[8]=(u+E)*_,e[9]=(g-M)*_,e[10]=(1-(f+d))*_,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function N_(e,t,n,r,s){let i=t[0],o=t[1],c=t[2],a=t[3],h=i+i,l=o+o,f=c+c,p=i*h,u=i*l,d=i*f,g=o*l,m=o*f,M=c*f,E=a*h,A=a*l,y=a*f,T=r[0],_=r[1],L=r[2],B=s[0],S=s[1],x=s[2],R=(1-(g+M))*T,w=(u+y)*T,I=(d-A)*T,C=(u-y)*_,P=(1-(p+M))*_,V=(m+E)*_,G=(d+A)*L,Q=(m-E)*L,q=(1-(p+g))*L;return e[0]=R,e[1]=w,e[2]=I,e[3]=0,e[4]=C,e[5]=P,e[6]=V,e[7]=0,e[8]=G,e[9]=Q,e[10]=q,e[11]=0,e[12]=n[0]+B-(R*B+C*S+G*x),e[13]=n[1]+S-(w*B+P*S+Q*x),e[14]=n[2]+x-(I*B+V*S+q*x),e[15]=1,e}function fh(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[1]=l+M,e[2]=p-m,e[3]=0,e[4]=l-M,e[5]=1-h-d,e[6]=u+g,e[7]=0,e[8]=p+m,e[9]=u-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ph(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function Gp(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var uh=Gp;function F_(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=s*o,e[14]=s*r*o}else e[10]=-1,e[14]=-r;return e}function v_(e,t,n,r){let s=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),c=Math.tan(t.rightDegrees*Math.PI/180),a=2/(o+c),h=2/(s+i);return e[0]=a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=h,e[6]=0,e[7]=0,e[8]=-((o-c)*a*.5),e[9]=(s-i)*h*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e}function zp(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*h,e[15]=1,e}var dh=zp;function D_(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=i*h,e[15]=1,e}function mh(e,t,n,r){let s,i,o,c,a,h,l,f,p,u,d=t[0],g=t[1],m=t[2],M=r[0],E=r[1],A=r[2],y=n[0],T=n[1],_=n[2];return Math.abs(d-y)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(m-_)<1e-6?vp(e):(f=d-y,p=g-T,u=m-_,s=1/Math.sqrt(f*f+p*p+u*u),f*=s,p*=s,u*=s,i=E*u-A*p,o=A*f-M*u,c=M*p-E*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-u*o,h=u*i-f*c,l=f*o-p*i,s=Math.sqrt(a*a+h*h+l*l),s?(s=1/s,a*=s,h*=s,l*=s):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*d+o*g+c*m),e[13]=-(a*d+h*g+l*m),e[14]=-(f*d+p*g+u*m),e[15]=1,e)}function U_(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=r[0],a=r[1],h=r[2],l=s-n[0],f=i-n[1],p=o-n[2],u=l*l+f*f+p*p;u>0&&(u=1/Math.sqrt(u),l*=u,f*=u,p*=u);let d=a*p-h*f,g=h*l-c*p,m=c*f-a*l;return u=d*d+g*g+m*m,u>0&&(u=1/Math.sqrt(u),d*=u,g*=u,m*=u),e[0]=d,e[1]=g,e[2]=m,e[3]=0,e[4]=f*m-p*g,e[5]=p*d-l*m,e[6]=l*g-f*d,e[7]=0,e[8]=l,e[9]=f,e[10]=p,e[11]=0,e[12]=s,e[13]=i,e[14]=o,e[15]=1,e}function G_(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function z_(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function k_(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e}function kp(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e}function V_(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e}function q_(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e[9]=t[9]+n[9]*r,e[10]=t[10]+n[10]*r,e[11]=t[11]+n[11]*r,e[12]=t[12]+n[12]*r,e[13]=t[13]+n[13]*r,e[14]=t[14]+n[14]*r,e[15]=t[15]+n[15]*r,e}function H_(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function Y_(e,t){let n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=e[5],a=e[6],h=e[7],l=e[8],f=e[9],p=e[10],u=e[11],d=e[12],g=e[13],m=e[14],M=e[15],E=t[0],A=t[1],y=t[2],T=t[3],_=t[4],L=t[5],B=t[6],S=t[7],x=t[8],R=t[9],w=t[10],I=t[11],C=t[12],P=t[13],V=t[14],G=t[15];return Math.abs(n-E)<=1e-6*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(r-A)<=1e-6*Math.max(1,Math.abs(r),Math.abs(A))&&Math.abs(s-y)<=1e-6*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(i-T)<=1e-6*Math.max(1,Math.abs(i),Math.abs(T))&&Math.abs(o-_)<=1e-6*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(c-L)<=1e-6*Math.max(1,Math.abs(c),Math.abs(L))&&Math.abs(a-B)<=1e-6*Math.max(1,Math.abs(a),Math.abs(B))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(l-x)<=1e-6*Math.max(1,Math.abs(l),Math.abs(x))&&Math.abs(f-R)<=1e-6*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(p-w)<=1e-6*Math.max(1,Math.abs(p),Math.abs(w))&&Math.abs(u-I)<=1e-6*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(d-C)<=1e-6*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(g-P)<=1e-6*Math.max(1,Math.abs(g),Math.abs(P))&&Math.abs(m-V)<=1e-6*Math.max(1,Math.abs(m),Math.abs(V))&&Math.abs(M-G)<=1e-6*Math.max(1,Math.abs(M),Math.abs(G))}var W_=Ls,J_=kp;function X_(){let e=new ot(4);return ot!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Vp(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function qp(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function Hp(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function Yp(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function Wp(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function Jp(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Xp(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function jp(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function Kp(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],h=n[3],l=h*r+c*i-a*s,f=h*s+a*r-o*i,p=h*i+o*s-c*r,u=-o*r-c*s-a*i;return e[0]=l*h+u*-o+f*-a-p*-c,e[1]=f*h+u*-c+p*-o-l*-a,e[2]=p*h+u*-a+l*-c-f*-o,e[3]=t[3],e}var vD=function(){let e=X_();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var Mh;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Mh||(Mh={}));var K_=45*Math.PI/180,Z_=1,gh=.1,xh=500,Q_=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),Ht=class extends mr{static get IDENTITY(){return tS()}static get ZERO(){return $_()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Mh}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this[9]=l,this[10]=f,this[11]=p,this[12]=u,this[13]=d,this[14]=g,this[15]=m,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=i,this[2]=h,this[3]=u,this[4]=n,this[5]=o,this[6]=l,this[7]=d,this[8]=r,this[9]=c,this[10]=f,this[11]=g,this[12]=s,this[13]=a,this[14]=p,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(Q_)}fromObject(t){return this.check()}fromQuaternion(t){return fh(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=gh,far:c=xh}=t;return c===1/0?eS(this,n,r,s,i,o):ph(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return mh(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=gh,far:c=xh}=t;return dh(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=K_,aspect:r=Z_,focalDistance:s=1,near:i=gh,far:o=xh}=t;Zp(n);let c=n/2,a=s*Math.tan(c),h=a*r;return this.ortho({left:-h,right:h,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return Zp(n),uh(this,n,r,s,i),this.check()}determinant(){return sh(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return nh(this,this),this.check()}invert(){return rh(this,this),this.check()}multiplyLeft(t){return Ls(this,t,this),this.check()}multiplyRight(t){return Ls(this,this,t),this.check()}rotateX(t){return ah(this,this,t),this.check()}rotateY(t){return hh(this,this,t),this.check()}rotateZ(t){return lh(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return ch(this,this,t,n),this.check()}scale(t){return oh(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return ih(this,this,t),this.check()}transform(t,n){return t.length===4?(n=jp(n||[-0,-0,-0,-0],t,this),en(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=Ap(n||[-0,-0],t,this);break;case 3:s=ur(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return en(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=yp(n||[-0,-0],t,this);break;case 3:r=zi(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return en(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},Xi,ji;function $_(){return Xi||(Xi=new Ht([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Xi)),Xi}function tS(){return ji||(ji=new Ht,Object.freeze(ji)),ji}function Zp(e){if(e>Math.PI*2)throw Error("expected radians")}function eS(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),h=(s+r)/(s-r),l=-1,f=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}function Qp(){let e=new ot(4);return ot!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function $p(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Ah(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function yh(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],h=n[2],l=n[3];return e[0]=r*l+o*c+s*h-i*a,e[1]=s*l+o*a+i*c-r*h,e[2]=i*l+o*h+r*a-s*c,e[3]=o*l-r*c-s*a-i*h,e}function tu(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function eu(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function nu(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function ru(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function ws(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],h=n[1],l=n[2],f=n[3],p,u,d,g,m;return p=s*a+i*h+o*l+c*f,p<0&&(p=-p,a=-a,h=-h,l=-l,f=-f),1-p>1e-6?(u=Math.acos(p),m=Math.sin(u),d=Math.sin((1-r)*u)/m,g=Math.sin(r*u)/m):(d=1-r,g=r),e[0]=d*s+g*a,e[1]=d*i+g*h,e[2]=d*o+g*l,e[3]=d*c+g*f,e}function su(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function iu(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Eh(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var ou=Vp;var cu=qp,au=Jp,hu=Xp,lu=Hp;var fu=Yp;var pu=Wp;var uu=function(){let e=ja(),t=Ka(1,0,0),n=Ka(0,1,0);return function(r,s,i){let o=Za(s,i);return o<-.999999?(pr(e,t,s),Rp(e)<1e-6&&pr(e,n,s),_p(e,e),Ah(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(pr(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,pu(r,r))}}(),KD=function(){let e=Qp(),t=Qp();return function(n,r,s,i,o,c){return ws(e,r,o,c),ws(t,s,i,c),ws(n,e,t,2*c*(1-c)),n}}(),ZD=function(){let e=wp();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],pu(t,Eh(t,e))}}();var nS=[0,0,0,1],gr=class extends tn{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 Eh(this,t),this.check()}fromAxisRotation(t,n){return Ah(this,t,n),this.check()}identity(){return $p(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=H(t)}get y(){return this[1]}set y(t){this[1]=H(t)}get z(){return this[2]}set z(t){this[2]=H(t)}get w(){return this[3]}set w(t){this[3]=H(t)}len(){return lu(this)}lengthSquared(){return fu(this)}dot(t){return au(this,t)}rotationTo(t,n){return uu(this,t,n),this.check()}add(t){return ou(this,this,t),this.check()}calculateW(){return ru(this,this),this.check()}conjugate(){return iu(this,this),this.check()}invert(){return su(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(hu(this,t,n,r),this.check())}multiplyRight(t){return yh(this,this,t),this.check()}multiplyLeft(t){return yh(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return tu(this,this,t),this.check()}rotateY(t){return eu(this,this,t),this.check()}rotateZ(t){return nu(this,this,t),this.check()}scale(t){return cu(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=nS,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return ws(this,s,i,o),this.check()}transformVector4(t,n=new dr){return Kp(n,t,this),en(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var xr={};At(xr,{EPSILON1:()=>rS,EPSILON10:()=>pS,EPSILON11:()=>uS,EPSILON12:()=>dS,EPSILON13:()=>mS,EPSILON14:()=>gS,EPSILON15:()=>xS,EPSILON16:()=>MS,EPSILON17:()=>AS,EPSILON18:()=>yS,EPSILON19:()=>ES,EPSILON2:()=>sS,EPSILON20:()=>TS,EPSILON3:()=>iS,EPSILON4:()=>oS,EPSILON5:()=>cS,EPSILON6:()=>aS,EPSILON7:()=>hS,EPSILON8:()=>lS,EPSILON9:()=>fS,PI_OVER_FOUR:()=>SS,PI_OVER_SIX:()=>BS,PI_OVER_TWO:()=>_S,TWO_PI:()=>CS});var rS=.1,sS=.01,iS=.001,oS=1e-4,cS=1e-5,aS=1e-6,hS=1e-7,lS=1e-8,fS=1e-9,pS=1e-10,uS=1e-11,dS=1e-12,mS=1e-13,gS=1e-14,xS=1e-15,MS=1e-16,AS=1e-17,yS=1e-18,ES=1e-19,TS=1e-20,_S=Math.PI/2,SS=Math.PI/4,BS=Math.PI/6,CS=Math.PI*2;function Ki(e,t){if(!e)throw new Error(t||"@math.gl/web-mercator: assertion failed.")}var se=Math.PI,xu=se/4,du=se/180,mu=180/se,Zi=512;function Ie(e){let[t,n]=e;Ki(Number.isFinite(t)),Ki(Number.isFinite(n)&&n>=-90&&n<=90,"invalid latitude");let r=t*du,s=n*du,i=Zi*(r+se)/(2*se),o=Zi*(se+Math.log(Math.tan(xu+s*.5)))/(2*se);return[i,o]}function be(e){let[t,n]=e,r=t/Zi*(2*se)-se,s=2*(Math.atan(Math.exp(n/Zi*(2*se)-se))-xu);return[r*mu,s*mu]}var U6=Math.PI/180;var Au=6378137*Math.PI;function Th(e){let t=Ie(e);return t[0]=(t[0]/256-1)*Au,t[1]=(t[1]/256-1)*Au,t}var VS={id:"imagery-layer",data:"",serviceType:"auto",srs:"auto",layers:{type:"array",compare:!0,value:[]},onMetadataLoad:{type:"function",value:()=>{}},onMetadataLoadError:{type:"function",value:console.error},onImageLoadStart:{type:"function",value:()=>{}},onImageLoad:{type:"function",value:()=>{}},onImageLoadError:{type:"function",compare:!1,value:(e,t)=>console.error(t,e)}},Mr=class extends Pn.CompositeLayer{get isLoaded(){return this.state?.loadCounter===0&&super.isLoaded}shouldUpdateState(){return!0}initializeState(){this.state._nextRequestId=0,this.state.lastRequestId=-1,this.state.loadCounter=0}updateState({changeFlags:t,props:n,oldProps:r}){let{viewport:s}=this.context;t.dataChanged||n.serviceType!==r.serviceType?(this.state.imageSource=this._createImageSource(n),this._loadMetadata(),this.debounce(()=>this.loadImage(s,"image source changed"),0)):(0,Pn._deepEqual)(n.layers,r.layers,1)?t.viewportChanged&&this.debounce(()=>this.loadImage(s,"viewport changed")):this.debounce(()=>this.loadImage(s,"layers changed"),0)}finalizeState(){}renderLayers(){let{bounds:t,image:n,lastRequestParameters:r}=this.state;return n&&new yu.BitmapLayer({...this.getSubLayerProps({id:"bitmap"}),_imageCoordinateSystem:r.srs==="EPSG:4326"?Pn.COORDINATE_SYSTEM.LNGLAT:Pn.COORDINATE_SYSTEM.CARTESIAN,bounds:t,image:n})}async getFeatureInfoText(t,n){let{lastRequestParameters:r}=this.state;return r?await this.state.imageSource.getFeatureInfoText?.({...r,query_layers:r.layers,x:t,y:n,info_format:"application/vnd.ogc.gml"}):""}_createImageSource(t){if(t.data instanceof Wt)return t.data;if(typeof t.data=="string")return Ja({url:t.data,loadOptions:t.loadOptions,type:t.serviceType});throw new Error("invalid image source in props.data")}async _loadMetadata(){let{imageSource:t}=this.state;try{this.state.loadCounter++;let n=await t.getMetadata();this.state.imageSource===t&&this.getCurrentLayer()?.props.onMetadataLoad(n)}catch(n){this.getCurrentLayer()?.props.onMetadataLoadError(n)}finally{this.state.loadCounter--}}async loadImage(t,n){let{layers:r,serviceType:s}=this.props;if(s==="wms"&&r.length===0)return;let i=t.getBounds(),{width:o,height:c}=t,a=this.getRequestId(),{srs:h}=this.props;h==="auto"&&(h=t.resolution?"EPSG:4326":"EPSG:3857");let l={width:o,height:c,boundingBox:[[i[0],i[1]],[i[2],i[3]]],layers:r,crs:h};if(h==="EPSG:3857"){let f=Th([i[0],i[1]]),p=Th([i[2],i[3]]);l.boundingBox=[f,p]}try{this.state.loadCounter++,this.props.onImageLoadStart(a);let f=await this.state.imageSource.getImage(l);this.state.lastRequestId<a&&(this.getCurrentLayer()?.props.onImageLoad(a),this.setState({image:f,bounds:i,lastRequestParameters:l,lastRequestId:a}))}catch(f){this.raiseError(f,"Load image"),this.getCurrentLayer()?.props.onImageLoadError(a,f)}finally{this.state.loadCounter--}}getRequestId(){return this.state._nextRequestId++}debounce(t,n=500){clearTimeout(this.state._timeoutId),this.state._timeoutId=setTimeout(()=>t(),n)}};Mr.layerName="WMSLayer";Mr.defaultProps=VS;var Eu=D(ee(),1),qS={getHeight:{type:"accessor",value:0},greatCircle:!0},Is=class extends Eu.ArcLayer{};Is.layerName="GreatCircleLayer";Is.defaultProps=qS;var Tu=Is;var _u=D(ne(),1),_h=D(ee(),1),HS={..._h.PolygonLayer.defaultProps},bs=class extends _u.CompositeLayer{indexToBounds(){return null}renderLayers(){let{elevationScale:t,extruded:n,wireframe:r,filled:s,stroked:i,lineWidthUnits:o,lineWidthScale:c,lineWidthMinPixels:a,lineWidthMaxPixels:h,lineJointRounded:l,lineMiterLimit:f,lineDashJustified:p,getElevation:u,getFillColor:d,getLineColor:g,getLineWidth:m}=this.props,{updateTriggers:M,material:E,transitions:A}=this.props,y=this.getSubLayerClass("cell",_h.PolygonLayer),{updateTriggers:T,..._}=this.indexToBounds()||{};return new y({filled:s,wireframe:r,extruded:n,elevationScale:t,stroked:i,lineWidthUnits:o,lineWidthScale:c,lineWidthMinPixels:a,lineWidthMaxPixels:h,lineJointRounded:l,lineMiterLimit:f,lineDashJustified:p,material:E,transitions:A,getElevation:u,getFillColor:d,getLineColor:g,getLineWidth:m},this.getSubLayerProps({id:"cell",updateTriggers:M&&{...T,getElevation:M.getElevation,getFillColor:M.getFillColor,getLineColor:M.getLineColor,getLineWidth:M.getLineWidth}}),_)}};bs.layerName="GeoCellLayer";bs.defaultProps=HS;var ye=bs;var Qi=D(Sh(),1),YS=3,WS=30,JS=2*WS+1,Bu=180/Math.PI;function Lu(e,t,n){let r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function Cu(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Ru(e){return[Cu(e[0]),Cu(e[1])]}function wu(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function Iu([e,t,n]){let r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*Bu,r*Bu]}function bu(e){let t=Qi.default.fromString(e,!0,10).toString(2);for(;t.length<YS+JS;)t="0"+t;let n=t.lastIndexOf("1"),r=t.substring(0,3),s=t.substring(3,n),i=s.length/2,o=Qi.default.fromString(r,!0,2).toString(10),c=Qi.default.fromString(s,!0,2).toString(4);for(;c.length<i;)c="0"+c;return`${o}/${c}`}function XS(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function Ou(e){let t=e.split("/"),n=parseInt(t[0],10),r=t[1],s=r.length,i=[0,0],o;for(let c=s-1;c>=0;c--){o=s-c;let a=r[c],h=0,l=0;a==="1"?l=1:a==="2"?(h=1,l=1):a==="3"&&(h=1);let f=Math.pow(2,o-1);XS(f,i,h,l),i[0]+=f*h,i[1]+=f*l}if(n%2===1){let c=i[0];i[0]=i[1],i[1]=c}return{face:n,ij:i,level:o}}var Pu=D(Sh(),1);function jS(e){let t=e.padEnd(16,"0");return Pu.default.fromString(t,16)}var KS=100;function ZS({face:e,ij:t,level:n}){let r=[[0,0],[0,1],[1,1],[1,0],[0,0]],s=Math.max(1,Math.ceil(KS*Math.pow(2,-n))),i=new Float64Array(4*s*2+2),o=0,c=0;for(let a=0;a<4;a++){let h=r[a].slice(0),l=r[a+1],f=(l[0]-h[0])/s,p=(l[1]-h[1])/s;for(let u=0;u<s;u++){h[0]+=f,h[1]+=p;let d=Lu(t,n,h),g=Ru(d),m=wu(e,g),M=Iu(m);Math.abs(M[1])>89.999&&(M[0]=c);let E=M[0]-c;M[0]+=E>180?-360:E<-180?360:0,i[o++]=M[0],i[o++]=M[1],c=M[0]}}return i[o++]=i[0],i[o++]=i[1],i}function QS(e){if(typeof e=="string"){if(e.indexOf("/")>0)return e;e=jS(e)}return bu(e.toString())}function Nu(e){let t=QS(e),n=Ou(t);return ZS(n)}var $S={getS2Token:{type:"accessor",value:e=>e.token}},Ps=class extends ye{indexToBounds(){let{data:t,getS2Token:n}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(r,s)=>Nu(n(r,s))}}};Ps.layerName="S2Layer";Ps.defaultProps=$S;var Fu=Ps;var Bh=512;function tB(e,t){let n=0,r=0,s=1<<e.length,i=s/Bh;for(let o=0;o<e.length;o++){s>>=1;let c=parseInt(e[o]);c%2&&(n|=s),c>1&&(r|=s)}return[[n/i,Bh-r/i],[(n+t)/i,Bh-(r+t)/i]]}function vu(e,t=1){let[n,r]=tB(e,t),[s,i]=be(n),[o,c]=be(r);return[o,i,o,c,s,c,s,i,o,i]}var eB={getQuadkey:{type:"accessor",value:e=>e.quadkey}},Ns=class extends ye{indexToBounds(){let{data:t,extruded:n,getQuadkey:r}=this.props,s=n?.99:1;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(i,o)=>vu(r(i,o),s),updateTriggers:{getPolygon:s}}}};Ns.layerName="QuadkeyLayer";Ns.defaultProps=eB;var Du=Ns;var io=D(ne(),1),ed=D(ee(),1);var Nn=class{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 Boolean(this._loader)&&!this._isCancelled}get needsReload(){return this._needsReload||this._isCancelled}get byteLength(){let 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:n,onLoad:r,onError:s}){let{index:i,id:o,bbox:c,userData:a,zoom:h}=this,l=this._loaderId;this._abortController=new AbortController;let{signal:f}=this._abortController,p=await n.scheduleRequest(this,g=>g.isSelected?1:-1);if(!p){this._isCancelled=!0;return}if(this._isCancelled){p.done();return}let u=null,d;try{u=await t({index:i,id:o,bbox:c,userData:a,zoom:h,signal:f})}catch(g){d=g||!0}finally{p.done()}if(l===this._loaderId){if(this._loader=void 0,this.content=u,this._isCancelled&&!u){this._isLoaded=!1;return}this._isLoaded=!0,this._isCancelled=!1,d?s(d,this):r(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())}};var vs=D(ne(),1);var ut={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Uu=new O,nB=new O,nn=class{constructor(t=[0,0,0],n=[0,0,0],r){r=r||Uu.copy(t).add(n).scale(.5),this.center=new O(r),this.halfDiagonal=new O(n).subtract(this.center),this.minimum=new O(t),this.maximum=new O(n)}clone(){return new nn(this.minimum,this.maximum,this.center)}equals(t){return this===t||Boolean(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){let{halfDiagonal:n}=this,r=nB.from(t.normal),s=n.x*Math.abs(r.x)+n.y*Math.abs(r.y)+n.z*Math.abs(r.z),i=this.center.dot(r)+t.distance;return i-s>0?ut.INSIDE:i+s<0?ut.OUTSIDE:ut.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let n=Uu.from(t).subtract(this.center),{halfDiagonal:r}=this,s=0,i;return i=Math.abs(n.x)-r.x,i>0&&(s+=i*i),i=Math.abs(n.y)-r.y,i>0&&(s+=i*i),i=Math.abs(n.z)-r.z,i>0&&(s+=i*i),s}};var Fs=new O,Gu=new O,rn=class{constructor(t=[0,0,0],n=0){this.radius=-0,this.center=new O,this.fromCenterRadius(t,n)}fromCenterRadius(t,n){return this.center.from(t),this.radius=n,this}fromCornerPoints(t,n){return n=Fs.from(n),this.center=new O().from(t).add(n).scale(.5),this.radius=this.center.distance(n),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new rn(this.center,this.radius)}union(t){let n=this.center,r=this.radius,s=t.center,i=t.radius,o=Fs.copy(s).subtract(n),c=o.magnitude();if(r>=c+i)return this.clone();if(i>=c+r)return t.clone();let a=(r+c+i)*.5;return Gu.copy(o).scale((-r+a)/c).add(n),this.center.copy(Gu),this.radius=a,this}expand(t){let r=Fs.from(t).subtract(this.center).magnitude();return r>this.radius&&(this.radius=r),this}transform(t){this.center.transform(t);let n=Rs.getScaling(Fs,t);return this.radius=Math.max(n[0],Math.max(n[1],n[2]))*this.radius,this}distanceSquaredTo(t){let n=this.distanceTo(t);return n*n}distanceTo(t){let r=Fs.from(t).subtract(this.center);return Math.max(0,r.len()-this.radius)}intersectPlane(t){let n=this.center,r=this.radius,i=t.normal.dot(n)+t.distance;return i<-r?ut.OUTSIDE:i<r?ut.INTERSECTING:ut.INSIDE}};var rB=new O,sB=new O,$i=new O,to=new O,eo=new O,iB=new O,oB=new O,Oe={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},Fn=class{constructor(t=[0,0,0],n=[0,0,0,0,0,0,0,0,0]){this.center=new O().from(t),this.halfAxes=new ct(n)}get halfSize(){let t=this.halfAxes.getColumn(0),n=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new O(t).len(),new O(n).len(),new O(r).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),n=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),s=new O(t).normalize(),i=new O(n).normalize(),o=new O(r).normalize();return new gr().fromMatrix3(new ct([...s,...i,...o]))}fromCenterHalfSizeQuaternion(t,n,r){let s=new gr(r),i=new ct().fromQuaternion(s);return i[0]=i[0]*n[0],i[1]=i[1]*n[0],i[2]=i[2]*n[0],i[3]=i[3]*n[1],i[4]=i[4]*n[1],i[5]=i[5]*n[1],i[6]=i[6]*n[2],i[7]=i[7]*n[2],i[8]=i[8]*n[2],this.center=new O().from(t),this.halfAxes=i,this}clone(){return new Fn(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new rn){let n=this.halfAxes,r=n.getColumn(0,$i),s=n.getColumn(1,to),i=n.getColumn(2,eo),o=rB.copy(r).add(s).add(i);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let n=this.center,r=t.normal,s=this.halfAxes,i=r.x,o=r.y,c=r.z,a=Math.abs(i*s[Oe.COLUMN0ROW0]+o*s[Oe.COLUMN0ROW1]+c*s[Oe.COLUMN0ROW2])+Math.abs(i*s[Oe.COLUMN1ROW0]+o*s[Oe.COLUMN1ROW1]+c*s[Oe.COLUMN1ROW2])+Math.abs(i*s[Oe.COLUMN2ROW0]+o*s[Oe.COLUMN2ROW1]+c*s[Oe.COLUMN2ROW2]),h=r.dot(n)+t.distance;return h<=-a?ut.OUTSIDE:h>=a?ut.INSIDE:ut.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let n=sB.from(t).subtract(this.center),r=this.halfAxes,s=r.getColumn(0,$i),i=r.getColumn(1,to),o=r.getColumn(2,eo),c=s.magnitude(),a=i.magnitude(),h=o.magnitude();s.normalize(),i.normalize(),o.normalize();let l=0,f;return f=Math.abs(n.dot(s))-c,f>0&&(l+=f*f),f=Math.abs(n.dot(i))-a,f>0&&(l+=f*f),f=Math.abs(n.dot(o))-h,f>0&&(l+=f*f),l}computePlaneDistances(t,n,r=[-0,-0]){let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=this.center,c=this.halfAxes,a=c.getColumn(0,$i),h=c.getColumn(1,to),l=c.getColumn(2,eo),f=iB.copy(a).add(h).add(l).add(o),p=oB.copy(f).subtract(t),u=n.dot(p);return s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).add(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).subtract(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).subtract(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).add(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).add(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).subtract(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).subtract(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),r[0]=s,r[1]=i,r}transform(t){this.center.transformAsPoint(t);let n=this.halfAxes.getColumn(0,$i);n.transformAsPoint(t);let r=this.halfAxes.getColumn(1,to);r.transformAsPoint(t);let s=this.halfAxes.getColumn(2,eo);return s.transformAsPoint(t),this.halfAxes=new ct([...n,...r,...s]),this}getTransform(){throw new Error("not implemented")}};var zu=new O,ku=new O,ie=class{constructor(t=[0,0,1],n=0){this.normal=new O,this.distance=-0,this.fromNormalDistance(t,n)}fromNormalDistance(t,n){return Ae(Number.isFinite(n)),this.normal.from(t).normalize(),this.distance=n,this}fromPointNormal(t,n){t=zu.from(t),this.normal.from(n).normalize();let r=-this.normal.dot(t);return this.distance=r,this}fromCoefficients(t,n,r,s){return this.normal.set(t,n,r),Ae(Me(this.normal.len(),1)),this.distance=s,this}clone(){return new ie(this.normal,this.distance)}equals(t){return Me(this.distance,t.distance)&&Me(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let n=ku.copy(this.normal).transformAsVector(t).normalize(),r=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(r,n)}projectPointOntoPlane(t,n=[0,0,0]){let r=zu.from(t),s=this.getPointDistance(r),i=ku.copy(this.normal).scale(s);return r.subtract(i).to(n)}};var Vu=[new O([1,0,0]),new O([0,1,0]),new O([0,0,1])],qu=new O,cB=new O,Gt=class{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Vu.length;let n=t.center,r=t.radius,s=0;for(let i of Vu){let o=this.planes[s],c=this.planes[s+1];o||(o=this.planes[s]=new ie),c||(c=this.planes[s+1]=new ie);let a=qu.copy(i).scale(-r).add(n);o.fromPointNormal(a,i);let h=qu.copy(i).scale(r).add(n),l=cB.copy(i).negate();c.fromPointNormal(h,l),s+=2}return this}computeVisibility(t){let n=ut.INSIDE;for(let r of this.planes)switch(t.intersectPlane(r)){case ut.OUTSIDE:return ut.OUTSIDE;case ut.INTERSECTING:n=ut.INTERSECTING;break;default:}return n}computeVisibilityWithPlaneMask(t,n){if(Ae(Number.isFinite(n),"parentPlaneMask is required."),n===Gt.MASK_OUTSIDE||n===Gt.MASK_INSIDE)return n;let r=Gt.MASK_INSIDE,s=this.planes;for(let i=0;i<this.planes.length;++i){let o=i<31?1<<i:0;if(i<31&&!(n&o))continue;let c=s[i],a=t.intersectPlane(c);if(a===ut.OUTSIDE)return Gt.MASK_OUTSIDE;a===ut.INTERSECTING&&(r|=o)}return r}};Gt.MASK_OUTSIDE=4294967295;Gt.MASK_INSIDE=0;Gt.MASK_INDETERMINATE=2147483647;var eG=new O,nG=new O,rG=new O,sG=new O,iG=new O;var fG=new O,pG=new O,uG=new O,dG=new O,mG=new O,gG=new O,xG=new O,MG=new O,AG=new O,yG=new O,EG=new O,TG=new O;var Ee=new ct,hB=new ct,lB=new ct,no=new ct,Hu=new ct;function Rh(e,t={}){let n=xr.EPSILON20,r=10,s=0,i=0,o=hB,c=lB;o.identity(),c.copy(e);let a=n*fB(c);for(;i<r&&pB(c)>a;)uB(c,no),Hu.copy(no).transpose(),c.multiplyRight(no),c.multiplyLeft(Hu),o.multiplyRight(no),++s>2&&(++i,s=0);return t.unitary=o.toTarget(t.unitary),t.diagonal=c.toTarget(t.diagonal),t}function fB(e){let t=0;for(let n=0;n<9;++n){let r=e[n];t+=r*r}return Math.sqrt(t)}var Ch=[1,0,0],Lh=[2,2,1];function pB(e){let t=0;for(let n=0;n<3;++n){let r=e[Ee.getElementIndex(Lh[n],Ch[n])];t+=2*r*r}return Math.sqrt(t)}function uB(e,t){let n=xr.EPSILON15,r=0,s=1;for(let h=0;h<3;++h){let l=Math.abs(e[Ee.getElementIndex(Lh[h],Ch[h])]);l>r&&(s=h,r=l)}let i=Ch[s],o=Lh[s],c=1,a=0;if(Math.abs(e[Ee.getElementIndex(o,i)])>n){let h=e[Ee.getElementIndex(o,o)],l=e[Ee.getElementIndex(i,i)],f=e[Ee.getElementIndex(o,i)],p=(h-l)/2/f,u;p<0?u=-1/(-p+Math.sqrt(1+p*p)):u=1/(p+Math.sqrt(1+p*p)),c=1/Math.sqrt(1+u*u),a=u*c}return ct.IDENTITY.to(t),t[Ee.getElementIndex(i,i)]=t[Ee.getElementIndex(o,o)]=c,t[Ee.getElementIndex(o,i)]=a,t[Ee.getElementIndex(i,o)]=-a,t}var sn=new O,dB=new O,mB=new O,gB=new O,xB=new O,MB=new ct,AB={diagonal:new ct,unitary:new ct};function wh(e,t=new Fn){if(!e||e.length===0)return t.halfAxes=new ct([0,0,0,0,0,0,0,0,0]),t.center=new O,t;let n=e.length,r=new O(0,0,0);for(let S of e)r.add(S);let s=1/n;r.multiplyByScalar(s);let i=0,o=0,c=0,a=0,h=0,l=0;for(let S of e){let x=sn.copy(S).subtract(r);i+=x.x*x.x,o+=x.x*x.y,c+=x.x*x.z,a+=x.y*x.y,h+=x.y*x.z,l+=x.z*x.z}i*=s,o*=s,c*=s,a*=s,h*=s,l*=s;let f=MB;f[0]=i,f[1]=o,f[2]=c,f[3]=o,f[4]=a,f[5]=h,f[6]=c,f[7]=h,f[8]=l;let{unitary:p}=Rh(f,AB),u=t.halfAxes.copy(p),d=u.getColumn(0,mB),g=u.getColumn(1,gB),m=u.getColumn(2,xB),M=-Number.MAX_VALUE,E=-Number.MAX_VALUE,A=-Number.MAX_VALUE,y=Number.MAX_VALUE,T=Number.MAX_VALUE,_=Number.MAX_VALUE;for(let S of e)sn.copy(S),M=Math.max(sn.dot(d),M),E=Math.max(sn.dot(g),E),A=Math.max(sn.dot(m),A),y=Math.min(sn.dot(d),y),T=Math.min(sn.dot(g),T),_=Math.min(sn.dot(m),_);d=d.multiplyByScalar(.5*(y+M)),g=g.multiplyByScalar(.5*(T+E)),m=m.multiplyByScalar(.5*(_+A)),t.center.copy(d).add(g).add(m);let L=dB.set(M-y,E-T,A-_).multiplyByScalar(.5),B=new ct([L[0],0,0,0,L[1],0,0,0,L[2]]);return t.halfAxes.multiplyRight(B),t}var Ar=512,Yu=3,Wu=[[.5,.5],[0,0],[0,1],[1,0],[1,1]],Ju=Wu.concat([[0,.5],[.5,0],[1,.5],[.5,1]]),yB=Ju.concat([[.25,.5],[.75,.5]]),on=class{constructor(t,n,r){this.x=t,this.y=n,this.z=r}get children(){if(!this._children){let t=this.x*2,n=this.y*2,r=this.z+1;this._children=[new on(t,n,r),new on(t,n+1,r),new on(t+1,n,r),new on(t+1,n+1,r)]}return this._children}update(t){let{viewport:n,cullingVolume:r,elevationBounds:s,minZ:i,maxZ:o,bounds:c,offset:a,project:h}=t,l=this.getBoundingVolume(s,a,h);if(c&&!this.insideBounds(c)||r.computeVisibility(l)<0)return!1;if(!this.childVisible){let{z:p}=this;if(p<o&&p>=i){let u=l.distanceTo(n.cameraPosition)*n.scale/n.height;p+=Math.floor(Math.log2(u))}if(p>=o)return this.selected=!0,!0}this.selected=!1,this.childVisible=!0;for(let p of this.children)p.update(t);return!0}getSelected(t=[]){if(this.selected&&t.push(this),this._children)for(let n of this._children)n.getSelected(t);return t}insideBounds([t,n,r,s]){let i=Math.pow(2,this.z),o=Ar/i;return this.x*o<r&&this.y*o<s&&(this.x+1)*o>t&&(this.y+1)*o>n}getBoundingVolume(t,n,r){if(r){let a=this.z<1?yB:this.z<2?Ju:Wu,h=[];for(let l of a){let f=ro(this.x+l[0],this.y+l[1],this.z);f[2]=t[0],h.push(r(f)),t[0]!==t[1]&&(f[2]=t[1],h.push(r(f)))}return wh(h)}let s=Math.pow(2,this.z),i=Ar/s,o=this.x*i+n*Ar,c=Ar-(this.y+1)*i;return new nn([o,c,t[0]],[o+i,c+i,t[1]])}};function Xu(e,t,n,r){let s=e instanceof vs._GlobeViewport&&e.resolution?e.projectPosition:null,i=Object.values(e.getFrustumPlanes()).map(({normal:u,distance:d})=>new ie(u.clone().negate(),d)),o=new Gt(i),c=e.distanceScales.unitsPerMeter[2],a=n&&n[0]*c||0,h=n&&n[1]*c||0,l=e instanceof vs.WebMercatorViewport&&e.pitch<=60?t:0;if(r){let[u,d,g,m]=r,M=Ie([u,m]),E=Ie([g,d]);r=[M[0],Ar-M[1],E[0],Ar-E[1]]}let f=new on(0,0,0),p={viewport:e,project:s,cullingVolume:o,elevationBounds:[a,h],minZ:l,maxZ:t,bounds:r,offset:0};if(f.update(p),e instanceof vs.WebMercatorViewport&&e.subViewports&&e.subViewports.length>1){for(p.offset=-1;f.update(p)&&!(--p.offset<-Yu););for(p.offset=1;f.update(p)&&!(++p.offset>Yu););}return f.getSelected()}var Pe=512,EB=[-1/0,-1/0,1/0,1/0],cn={type:"object",value:null,validate:(e,t)=>t.optional&&e===null||typeof e=="string"||Array.isArray(e)&&e.every(n=>typeof n=="string"),equal:(e,t)=>{if(e===t)return!0;if(!Array.isArray(e)||!Array.isArray(t))return!1;let n=e.length;if(n!==t.length)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}};function Ku(e,t){let n=[t.transformAsPoint([e[0],e[1]]),t.transformAsPoint([e[2],e[1]]),t.transformAsPoint([e[0],e[3]]),t.transformAsPoint([e[2],e[3]])];return[Math.min(...n.map(s=>s[0])),Math.min(...n.map(s=>s[1])),Math.max(...n.map(s=>s[0])),Math.max(...n.map(s=>s[1]))]}function TB(e){return Math.abs(e.split("").reduce((t,n)=>(t<<5)-t+n.charCodeAt(0)|0,0))}function Te(e,t){if(!e||!e.length)return null;let{index:n,id:r}=t;if(Array.isArray(e)){let i=TB(r)%e.length;e=e[i]}let s=e;for(let i of Object.keys(n)){let o=new RegExp(`{${i}}`,"g");s=s.replace(o,String(n[i]))}return Number.isInteger(n.y)&&Number.isInteger(n.z)&&(s=s.replace(/\{-y\}/g,String(Math.pow(2,n.z)-n.y-1))),s}function _B(e,t,n){let r;if(t&&t.length===2){let[s,i]=t,o=e.getBounds({z:s}),c=e.getBounds({z:i});r=[Math.min(o[0],c[0]),Math.min(o[1],c[1]),Math.max(o[2],c[2]),Math.max(o[3],c[3])]}else r=e.getBounds();return e.isGeospatial?[Math.max(r[0],n[0]),Math.max(r[1],n[1]),Math.min(r[2],n[2]),Math.min(r[3],n[3])]:[Math.max(Math.min(r[0],n[2]),n[0]),Math.max(Math.min(r[1],n[3]),n[1]),Math.min(Math.max(r[2],n[0]),n[2]),Math.min(Math.max(r[3],n[1]),n[3])]}function Zu({viewport:e,z:t,cullRect:n}){return(e.subViewports||[e]).map(s=>Ih(s,t||0,n))}function Ih(e,t,n){if(!Array.isArray(t)){let i=n.x-e.x,o=n.y-e.y,{width:c,height:a}=n,h={targetZ:t},l=e.unproject([i,o],h),f=e.unproject([i+c,o],h),p=e.unproject([i,o+a],h),u=e.unproject([i+c,o+a],h);return[Math.min(l[0],f[0],p[0],u[0]),Math.min(l[1],f[1],p[1],u[1]),Math.max(l[0],f[0],p[0],u[0]),Math.max(l[1],f[1],p[1],u[1])]}let r=Ih(e,t[0],n),s=Ih(e,t[1],n);return[Math.min(r[0],s[0]),Math.min(r[1],s[1]),Math.max(r[2],s[2]),Math.max(r[3],s[3])]}function SB(e,t,n){return n?Ku(e,n).map(s=>s*t/Pe):e.map(r=>r*t/Pe)}function bh(e,t){return Math.pow(2,e)*Pe/t}function ro(e,t,n){let r=bh(n,Pe),s=e/r*360-180,i=Math.PI-2*Math.PI*t/r,o=180/Math.PI*Math.atan(.5*(Math.exp(i)-Math.exp(-i)));return[s,o]}function ju(e,t,n,r){let s=bh(n,r);return[e/s*Pe,t/s*Pe]}function Oh(e,t,n,r,s=Pe){if(e.isGeospatial){let[h,l]=ro(t,n,r),[f,p]=ro(t+1,n+1,r);return{west:h,north:l,east:f,south:p}}let[i,o]=ju(t,n,r,s),[c,a]=ju(t+1,n+1,r,s);return{left:i,top:o,right:c,bottom:a}}function BB(e,t,n,r,s){let i=_B(e,null,r),o=bh(t,n),[c,a,h,l]=SB(i,o,s),f=[];for(let p=Math.floor(c);p<h;p++)for(let u=Math.floor(a);u<l;u++)f.push({x:p,y:u,z:t});return f}function Ph({viewport:e,maxZoom:t,minZoom:n,zRange:r,extent:s,tileSize:i=Pe,modelMatrix:o,modelMatrixInverse:c,zoomOffset:a=0}){let h=e.isGeospatial?Math.round(e.zoom+Math.log2(Pe/i))+a:Math.ceil(e.zoom)+a;if(typeof n=="number"&&Number.isFinite(n)&&h<n){if(!s)return[];h=n}typeof t=="number"&&Number.isFinite(t)&&h>t&&(h=t);let l=s;return o&&c&&s&&!e.isGeospatial&&(l=Ku(s,o)),e.isGeospatial?Xu(e,h,r,s):BB(e,h,i,l||EB,c)}function Nh(e){return/(?=.*{z})(?=.*{x})(?=.*({y}|{-y}))/.test(e)}function Fh(e){return Number.isFinite(e.west)&&Number.isFinite(e.north)&&Number.isFinite(e.east)&&Number.isFinite(e.south)}function Qu(e){let t={},n;return r=>{for(let s in r)if(!CB(r[s],t[s])){n=e(r),t=r;break}return n}}function CB(e,t){if(e===t)return!0;if(Array.isArray(e)){let n=e.length;if(!t||t.length!==n)return!1;for(let r=0;r<n;r++)if(e[r]!==t[r])return!1;return!0}return!1}var $u=1,so=2,LB="never",RB="no-overlap",Ds="best-available",wB=5,IB={[Ds]:OB,[RB]:PB,[LB]:()=>{}},bB={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:()=>{}},vn=class{constructor(t){this._getCullBounds=Qu(Zu),this.opts={...bB,...t},this.setOptions(this.opts),this.onTileLoad=n=>{this.opts.onTileLoad?.(n),this.opts.maxCacheByteSize!=null&&(this._cacheByteSize+=n.byteLength,this._resizeCache())},this._requestScheduler=new Ke({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 Ht,this._modelMatrixInverse=new Ht}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(let t of this._cache.values())t.isLoading&&t.abort();this._cache.clear(),this._tiles=[],this._selectedTiles=null}reloadAll(){for(let t of this._cache.keys()){let n=this._cache.get(t);!this._selectedTiles||!this._selectedTiles.includes(n)?this._cache.delete(t):n.setNeedsReload()}}update(t,{zRange:n,modelMatrix:r}={zRange:null,modelMatrix:null}){let s=r?new Ht(r):new Ht,i=!s.equals(this._modelMatrix);if(!this._viewport||!t.equals(this._viewport)||!Me(this._zRange,n)||i){i&&(this._modelMatrixInverse=s.clone().invert(),this._modelMatrix=s),this._viewport=t,this._zRange=n;let c=this.getTileIndices({viewport:t,maxZoom:this._maxZoom,minZoom:this._minZoom,zRange:n,modelMatrix:this._modelMatrix,modelMatrixInverse:this._modelMatrixInverse});this._selectedTiles=c.map(a=>this._getTile(a,!0)),this._dirty&&this._rebuildTree()}else this.needsReload&&(this._selectedTiles=this._selectedTiles.map(c=>this._getTile(c.index,!0)));let o=this.updateTileStates();return this._pruneRequests(),this._dirty&&this._resizeCache(),o&&this._frameNumber++,this._frameNumber}isTileVisible(t,n){if(!t.isVisible)return!1;if(n&&this._viewport){let r=this._getCullBounds({viewport:this._viewport,z:this._zRange,cullRect:n}),{bbox:s}=t;for(let[i,o,c,a]of r){let h;if("west"in s)h=s.west<c&&s.east>i&&s.south<a&&s.north>o;else{let l=Math.min(s.top,s.bottom),f=Math.max(s.top,s.bottom);h=s.left<c&&s.right>i&&l<a&&f>o}if(h)return!0}return!1}return!0}getTileIndices({viewport:t,maxZoom:n,minZoom:r,zRange:s,modelMatrix:i,modelMatrixInverse:o}){let{tileSize:c,extent:a,zoomOffset:h}=this.opts;return Ph({viewport:t,maxZoom:n,minZoom:r,zRange:s,tileSize:c,extent:a,modelMatrix:i,modelMatrixInverse:o,zoomOffset:h})}getTileId(t){return`${t.x}-${t.y}-${t.z}`}getTileZoom(t){return t.z}getTileMetadata(t){let{tileSize:n}=this.opts;return{bbox:Oh(this._viewport,t.x,t.y,t.z,n)}}getParentIndex(t){let n=Math.floor(t.x/2),r=Math.floor(t.y/2),s=t.z-1;return{x:n,y:r,z:s}}updateTileStates(){let t=this.opts.refinementStrategy||Ds,n=new Array(this._cache.size),r=0;for(let s of this._cache.values())n[r++]=s.isVisible,s.isSelected=!1,s.isVisible=!1;for(let s of this._selectedTiles)s.isSelected=!0,s.isVisible=!0;(typeof t=="function"?t:IB[t])(Array.from(this._cache.values())),r=0;for(let s of this._cache.values())if(n[r++]!==s.isVisible)return!0;return!1}_pruneRequests(){let{maxRequests:t=0}=this.opts,n=[],r=0;for(let s of this._cache.values())s.isLoading&&(r++,!s.isSelected&&!s.isVisible&&n.push(s));for(;t>0&&r>t&&n.length>0;)n.shift().abort(),r--}_rebuildTree(){let{_cache:t}=this;for(let n of t.values())n.parent=null,n.children&&(n.children.length=0);for(let n of t.values()){let r=this._getNearestAncestor(n);n.parent=r,r?.children&&r.children.push(n)}}_resizeCache(){let{_cache:t,opts:n}=this,r=n.maxCacheSize??(n.maxCacheByteSize!=null?1/0:wB*this.selectedTiles.length),s=n.maxCacheByteSize??1/0;if(t.size>r||this._cacheByteSize>s){for(let[o,c]of t)if(!c.isVisible&&!c.isSelected&&(this._cacheByteSize-=n.maxCacheByteSize!=null?c.byteLength:0,t.delete(o),this.opts.onTileUnload?.(c)),t.size<=r&&this._cacheByteSize<=s)break;this._rebuildTree(),this._dirty=!0}this._dirty&&(this._tiles=Array.from(this._cache.values()).sort((o,c)=>o.zoom-c.zoom),this._dirty=!1)}_getTile(t,n){let r=this.getTileId(t),s=this._cache.get(r),i=!1;return!s&&n?(s=new Nn(t),Object.assign(s,this.getTileMetadata(s.index)),Object.assign(s,{id:r,zoom:this.getTileZoom(s.index)}),i=!0,this._cache.set(r,s),this._dirty=!0):s&&s.needsReload&&(i=!0),s&&i&&s.loadData({getData:this.opts.getTileData,requestScheduler:this._requestScheduler,onLoad:this.onTileLoad,onError:this.opts.onTileError}),s}_getNearestAncestor(t){let{_minZoom:n=0}=this,r=t.index;for(;this.getTileZoom(r)>n;){r=this.getParentIndex(r);let s=this._getTile(r);if(s)return s}return null}};function OB(e){for(let t of e)t.state=0;for(let t of e)t.isSelected&&!td(t)&&vh(t);for(let t of e)t.isVisible=Boolean(t.state&so)}function PB(e){for(let n of e)n.state=0;for(let n of e)n.isSelected&&td(n);let t=Array.from(e).sort((n,r)=>n.zoom-r.zoom);for(let n of t)if(n.isVisible=Boolean(n.state&so),n.children&&(n.isVisible||n.state&$u))for(let r of n.children)r.state=$u;else n.isSelected&&vh(n)}function td(e){let t=e;for(;t;){if(t.isLoaded||t.content)return t.state|=so,!0;t=t.parent}return!1}function vh(e){for(let t of e.children)t.isLoaded||t.content?t.state|=so:vh(t)}var NB={TilesetClass:vn,data:{type:"data",value:[]},dataComparator:cn.equal,renderSubLayers:{type:"function",value:e=>new ed.GeoJsonLayer(e)},getTileData:{type:"function",optional:!0,value:null},onViewportLoad:{type:"function",optional:!0,value:null},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:e=>console.error(e)},extent:{type:"array",optional:!0,value:null,compare:!0},tileSize:512,maxZoom:null,minZoom:0,maxCacheSize:null,maxCacheByteSize:null,refinementStrategy:Ds,zRange:null,maxRequests:6,debounceTime:0,zoomOffset:0},Us=class extends io.CompositeLayer{initializeState(){this.state={tileset:null,isLoaded:!1}}finalizeState(){this.state?.tileset?.finalize()}get isLoaded(){return Boolean(this.state?.tileset?.selectedTiles?.every(t=>t.isLoaded&&t.layers&&t.layers.every(n=>n.isLoaded)))}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({changeFlags:t}){let{tileset:n}=this.state,r=t.propsOrDataChanged||t.updateTriggersChanged,s=t.dataChanged||t.updateTriggersChanged&&(t.updateTriggersChanged.all||t.updateTriggersChanged.getTileData);n?r&&(n.setOptions(this._getTilesetOptions()),s?n.reloadAll():n.tiles.forEach(i=>{i.layers=null})):(n=new this.props.TilesetClass(this._getTilesetOptions()),this.setState({tileset:n})),this._updateTileset()}_getTilesetOptions(){let{tileSize:t,maxCacheSize:n,maxCacheByteSize:r,refinementStrategy:s,extent:i,maxZoom:o,minZoom:c,maxRequests:a,debounceTime:h,zoomOffset:l}=this.props;return{maxCacheSize:n,maxCacheByteSize:r,maxZoom:o,minZoom:c,tileSize:t,refinementStrategy:s,extent:i,maxRequests:a,debounceTime:h,zoomOffset:l,getTileData:this.getTileData.bind(this),onTileLoad:this._onTileLoad.bind(this),onTileError:this._onTileError.bind(this),onTileUnload:this._onTileUnload.bind(this)}}_updateTileset(){let t=this.state.tileset,{zRange:n,modelMatrix:r}=this.props,s=t.update(this.context.viewport,{zRange:n,modelMatrix:r}),{isLoaded:i}=t,o=this.state.isLoaded!==i,c=this.state.frameNumber!==s;i&&(o||c)&&this._onViewportLoad(),c&&this.setState({frameNumber:s}),this.state.isLoaded=i}_onViewportLoad(){let{tileset:t}=this.state,{onViewportLoad:n}=this.props;n&&n(t.selectedTiles)}_onTileLoad(t){this.props.onTileLoad(t),t.layers=null,this.setNeedsUpdate()}_onTileError(t,n){this.props.onTileError(t),n.layers=null,this.setNeedsUpdate()}_onTileUnload(t){this.props.onTileUnload(t)}getTileData(t){let{data:n,getTileData:r,fetch:s}=this.props,{signal:i}=t;return t.url=typeof n=="string"||Array.isArray(n)?Te(n,t):null,r?r(t):s&&t.url?s(t.url,{propName:"data",layer:this,signal:i}):null}renderSubLayers(t){return this.props.renderSubLayers(t)}getSubLayerPropsByTile(t){return null}getPickingInfo(t){let n=t.sourceLayer,r=n.props.tile,s=t.info;return s.picked&&(s.tile=r),s.sourceTile=r,s.sourceTileSubLayer=n,s}_updateAutoHighlight(t){t.sourceTileSubLayer.updateAutoHighlight(t)}renderLayers(){return this.state.tileset.tiles.map(t=>{let n=this.getSubLayerPropsByTile(t);if(!(!t.isLoaded&&!t.content))if(t.layers)n&&t.layers[0]&&Object.keys(n).some(r=>t.layers[0].props[r]!==n[r])&&(t.layers=t.layers.map(r=>r.clone(n)));else{let r=this.renderSubLayers({...this.props,...this.getSubLayerProps({id:t.id,updateTriggers:this.props.updateTriggers}),data:t.content,_offset:0,tile:t});t.layers=(0,io._flatten)(r,Boolean).map(s=>s.clone({tile:t,...n}))}return t.layers})}filterSubLayer({layer:t,cullRect:n}){let{tile:r}=t.props;return this.state.tileset.isTileVisible(r,n)}};Us.defaultProps=NB;Us.layerName="TileLayer";var Dn=Us;var sd=D(ee(),1);var nd=`uniform tripsUniforms {
14
+ bool fadeTrail;
15
+ float trailLength;
16
+ float currentTime;
17
+ } trips;
18
+ `,rd={name:"trips",vs:nd,fs:nd,uniformTypes:{fadeTrail:"f32",trailLength:"f32",currentTime:"f32"}};var FB={fadeTrail:!0,trailLength:{type:"number",value:120,min:0},currentTime:{type:"number",value:0,min:0},getTimestamps:{type:"accessor",value:e=>e.timestamps}},Gs=class extends sd.PathLayer{getShaders(){let t=super.getShaders();return t.inject={"vs:#decl":`in float instanceTimestamps;
15
19
  in float instanceNextTimestamps;
16
20
  out float vTime;
17
21
  `,"vs:#main-end":`vTime = instanceTimestamps + (instanceNextTimestamps - instanceTimestamps) * vPathPosition.y / vPathLength;
18
- `,"fs:#decl":`uniform bool fadeTrail;
19
- uniform float trailLength;
20
- uniform float currentTime;
21
- in float vTime;
22
- `,"fs:#main-start":`if(vTime > currentTime || (fadeTrail && (vTime < currentTime - trailLength))) {
22
+ `,"fs:#decl":`in float vTime;
23
+ `,"fs:#main-start":`if(vTime > trips.currentTime || (trips.fadeTrail && (vTime < trips.currentTime - trips.trailLength))) {
23
24
  discard;
24
25
  }
25
- `,"fs:DECKGL_FILTER_COLOR":`if(fadeTrail) {
26
- color.a *= 1.0 - (currentTime - vTime) / trailLength;
26
+ `,"fs:DECKGL_FILTER_COLOR":`if(trips.fadeTrail) {
27
+ color.a *= 1.0 - (trips.currentTime - vTime) / trips.trailLength;
27
28
  }
28
- `},t}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(t){let{fadeTrail:r,trailLength:n,currentTime:s}=this.props;t.uniforms={...t.uniforms,fadeTrail:r,trailLength:n,currentTime:s},super.draw(t)}};Tn.layerName="TripsLayer";Tn.defaultProps=Jy;var mh=Tn;var yh=N(Rs(),1),Th=N(Nt(),1);var wt=N(Rs(),1),Os=N(Nt(),1),En=N(Ot(),1);var _n=N(Rs(),1);function Ps(e,t){t=t===void 0?e[0][0]:t;for(let r of e){let n=r[0]-t;n>180?r[0]-=360:n<-180&&(r[0]+=360)}}function qy(e,t,r){let[n,s]=(0,_n.cellToLatLng)(e),o=t.length;Ps(t,s);let i=t[0]===t[o-1]?o-1:o;for(let a=0;a<i;a++)t[a][0]=Ae(s,t[a][0],r),t[a][1]=Ae(n,t[a][1],r)}function Ah(e,t,r){let n=e(t,r),[s,o]=(0,_n.cellToLatLng)(n);return[o,s]}function Aa(e,t=1){let r=(0,_n.cellToBoundary)(e,!0);return t!==1?qy(e,r,t):Ps(r),r}function xh(e){let t=new Float64Array(e.length*2),r=0;for(let n of e)t[r++]=n[0],t[r++]=n[1];return t}var jy=10;function Xy(e,t){let r;return e==null?r=t:typeof e=="object"?r={...e,coverage:t}:r={getHexagon:e,coverage:t},r}var Wy={...En.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0},Se=class extends Os.CompositeLayer{initializeState(){Se._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:t}){return this._shouldUseHighPrecision()?t.propsOrDataChanged:t.somethingChanged}updateState({props:t,changeFlags:r}){if(t.highPrecision!==!0&&(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagon)){let n=this._calculateH3DataProps();this.setState(n)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let t=-1,r=!1,n=!1,{iterable:s,objectInfo:o}=(0,Os.createIterable)(this.props.data);for(let i of s){o.index++;let a=this.props.getHexagon(i,o),c=(0,wt.getResolution)(a);if(t<0){if(t=c,!this.props.highPrecision)break}else if(t!==c){n=!0;break}if((0,wt.isPentagon)(a)){r=!0;break}}return{resolution:t,edgeLengthKM:t>=0?(0,wt.getHexagonEdgeLengthAvg)(t,"km"):0,hasMultipleRes:n,hasPentagon:r}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:t,hasPentagon:r,hasMultipleRes:n}=this.state,{viewport:s}=this.context;return Boolean(s?.resolution)||n||r||t>=0&&t<=5}return this.props.highPrecision}_updateVertices(t){if(this._shouldUseHighPrecision())return;let{resolution:r,edgeLengthKM:n,centerHex:s}=this.state;if(r<0)return;let o=this.props.centerHexagon||(0,wt.latLngToCell)(t.latitude,t.longitude,r);if(s===o)return;if(s)try{if((0,wt.gridDistance)(s,o)*n<jy)return}catch{}let{unitsPerMeter:i}=t.distanceScales,a=Aa(o),[c,l]=(0,wt.cellToLatLng)(o),[u,f]=t.projectFlat([l,c]);a=a.map(h=>{let d=t.projectFlat(h);return[(d[0]-u)/i[0],(d[1]-f)/i[1]]}),this.setState({centerHex:o,vertices:a})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:t,material:r,coverage:n,extruded:s,wireframe:o,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:u,lineWidthMaxPixels:f,getFillColor:h,getElevation:d,getLineColor:p,getLineWidth:A,transitions:g,updateTriggers:y}=this.props;return{elevationScale:t,extruded:s,coverage:n,wireframe:o,stroked:i,filled:a,lineWidthUnits:c,lineWidthScale:l,lineWidthMinPixels:u,lineWidthMaxPixels:f,material:r,getElevation:d,getFillColor:h,getLineColor:p,getLineWidth:A,transitions:g,updateTriggers:{getFillColor:y.getFillColor,getElevation:y.getElevation,getLineColor:y.getLineColor,getLineWidth:y.getLineWidth}}}_renderPolygonLayer(){let{data:t,getHexagon:r,updateTriggers:n,coverage:s}=this.props,o=this.getSubLayerClass("hexagon-cell-hifi",En.PolygonLayer),i=this._getForwardProps();return i.updateTriggers.getPolygon=Xy(n.getHexagon,s),new o(i,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:i.updateTriggers}),{data:t,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(a,c)=>{let l=r(a,c);return xh(Aa(l,s))}})}_renderColumnLayer(){let{data:t,getHexagon:r,updateTriggers:n}=this.props,s=this.getSubLayerClass("hexagon-cell",En.ColumnLayer),o=this._getForwardProps();return o.updateTriggers.getPosition=n.getHexagon,new s(o,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:o.updateTriggers}),{data:t,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:Ah.bind(null,r)})}};Se.defaultProps=Wy;Se.layerName="H3HexagonLayer";Se._checkH3Lib=()=>{};var Ns=Se;var Yy={getHexagons:{type:"accessor",value:e=>e.hexagons}},Bn=class extends Yt{initializeState(){Ns._checkH3Lib()}updateState({props:t,changeFlags:r}){if(r.dataChanged||r.updateTriggersChanged&&r.updateTriggersChanged.getHexagons){let{data:n,getHexagons:s}=t,o=[],{iterable:i,objectInfo:a}=(0,Th.createIterable)(n);for(let c of i){a.index++;let l=s(c,a),u=(0,yh.cellsToMultiPolygon)(l,!0);for(let f of u){for(let h of f)Ps(h);o.push(this.getSubLayerRow({polygon:f},c,a.index))}}this.setState({polygons:o})}}indexToBounds(){let{getElevation:t,getFillColor:r,getLineColor:n,getLineWidth:s}=this.props;return{data:this.state.polygons,getPolygon:o=>o.polygon,getElevation:this.getSubLayerAccessor(t),getFillColor:this.getSubLayerAccessor(r),getLineColor:this.getSubLayerAccessor(n),getLineWidth:this.getSubLayerAccessor(s)}}};Bn.layerName="H3ClusterLayer";Bn.defaultProps=Yy;var _h=Bn;var nm=N(xa(),1),we=N(Nt(),1),sm=N(Ot(),1),om=N(Ds(),1);var bh=N(Sh(),1),Gt;(function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(Gt||(Gt={}));function ya(e,t,r,n){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{u_Camera:[0,0,0],u_MetallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:o}=n;return o&&(s.bindings.u_DiffuseEnvSampler=o.diffuseEnvSampler,s.bindings.u_SpecularEnvSampler=o.specularEnvSampler,s.bindings.u_brdfLUT=o.brdfLutTexture,s.uniforms.u_ScaleIBLAmbient=[1,1]),n?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.u_ScaleDiffBaseMR=[0,0,0,0],s.uniforms.u_ScaleFGDSpec=[0,0,0,0]),r.NORMAL&&(s.defines.HAS_NORMALS=1),r.TANGENT&&n?.useTangents&&(s.defines.HAS_TANGENTS=1),r.TEXCOORD_0&&(s.defines.HAS_UV=1),n?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),n?.lights&&(s.defines.USE_LIGHTS=1),t&&Ky(e,t,s),s}function Ky(e,t,r){if(r.uniforms.pbr_uUnlit=Boolean(t.unlit),t.pbrMetallicRoughness&&Qy(e,t.pbrMetallicRoughness,r),t.normalTexture){Cn(e,t.normalTexture,"u_NormalSampler","HAS_NORMALMAP",r);let{scale:n=1}=t.normalTexture;r.uniforms.u_NormalScale=n}if(t.occlusionTexture){Cn(e,t.occlusionTexture,"u_OcclusionSampler","HAS_OCCLUSIONMAP",r);let{strength:n=1}=t.occlusionTexture;r.uniforms.u_OcclusionStrength=n}switch(t.emissiveTexture&&(Cn(e,t.emissiveTexture,"u_EmissiveSampler","HAS_EMISSIVEMAP",r),r.uniforms.u_EmissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:n=.5}=t;r.defines.ALPHA_CUTOFF=1,r.uniforms.u_AlphaCutoff=n;break;case"BLEND":bh.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),r.parameters.blendColorOperation="add",r.parameters.blendColorSrcFactor="src-alpha",r.parameters.blendColorDstFactor="one-minus-src-alpha",r.parameters.blendAlphaOperation="add",r.parameters.blendAlphaSrcFactor="one",r.parameters.blendAlphaDstFactor="one-minus-src-alpha",r.glParameters.blend=!0,r.glParameters.blendEquation=Gt.FUNC_ADD,r.glParameters.blendFunc=[Gt.SRC_ALPHA,Gt.ONE_MINUS_SRC_ALPHA,Gt.ONE,Gt.ONE_MINUS_SRC_ALPHA];break}}function Qy(e,t,r){t.baseColorTexture&&Cn(e,t.baseColorTexture,"u_BaseColorSampler","HAS_BASECOLORMAP",r),r.uniforms.u_BaseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&Cn(e,t.metallicRoughnessTexture,"u_MetallicRoughnessSampler","HAS_METALROUGHNESSMAP",r);let{metallicFactor:n=1,roughnessFactor:s=1}=t;r.uniforms.u_MetallicRoughnessValues=[n,s]}function Cn(e,t,r,n=null,s){let o=t?.texture?.sampler?.parameters||{},i=t.texture.source.image,a,c={};i.compressed?(a=i,c={[Gt.TEXTURE_MIN_FILTER]:i.data.length>1?Gt.LINEAR_MIPMAP_NEAREST:Gt.LINEAR}):a={data:i};let l=e.createTexture({id:t.uniformName||t.id,parameters:{...o,...c},pixelStore:{[Gt.UNPACK_FLIP_Y_WEBGL]:!1},...a});s.bindings[r]=l,n&&(s.defines[n]=1),s.generatedTextures.push(l)}var Mh="4.2.0-beta.2";var vs={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},Ih;async function _a(e){si(e.modules);let t=oi("basis");return t||(Ih||=Zy(e),await Ih)}async function Zy(e){let t=null,r=null;return[t,r]=await Promise.all([await jt(vs.TRANSCODER,"textures",e),await jt(vs.TRANSCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await $y(t,r)}function $y(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(n=>{e(r).then(s=>{let{BasisFile:o,initializeBasis:i}=s;i(),n({BasisFile:o})})})}var Ta;async function Ea(e){let t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Ta=Ta||tT(e),await Ta)}async function tT(e){let t=null,r=null;return[t,r]=await Promise.all([await jt(vs.ENCODER,"textures",e),await jt(vs.ENCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await eT(t,r)}function eT(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(n=>{e(r).then(s=>{let{BasisFile:o,KTX2File:i,initializeBasis:a,BasisEncoder:c}=s;a(),n({BasisFile:o,KTX2File:i,BasisEncoder:c})})})}var je={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919};var rT=["","WEBKIT_","MOZ_"],wh={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},Us=null;function Lh(e){if(!Us){e=e||nT()||void 0,Us=new Set;for(let t of rT)for(let r in wh)if(e&&e.getExtension(`${t}${r}`)){let n=wh[r];Us.add(n)}}return Us}function nT(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var f3=new Uint8Array([0]);var Fh,Rh,Ph,Oh,Nh,Dh,vh,Uh;(function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"})(Fh||(Fh={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Rh||(Rh={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Ph||(Ph={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Oh||(Oh={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Nh||(Nh={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Dh||(Dh={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(vh||(vh={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Uh||(Uh={}));var St=[171,75,84,88,32,50,48,187,13,10,26,10];function Gh(e){let t=new Uint8Array(e);return!(t.byteLength<St.length||t[0]!==St[0]||t[1]!==St[1]||t[2]!==St[2]||t[3]!==St[3]||t[4]!==St[4]||t[5]!==St[5]||t[6]!==St[6]||t[7]!==St[7]||t[8]!==St[8]||t[9]!==St[9]||t[10]!==St[10]||t[11]!==St[11])}var sT={etc1:{basisFormat:0,compressed:!0,format:je.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:je.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:je.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:je.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:je.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:je.COMPRESSED_RGBA_ASTC_4X4_KHR},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};async function Ca(e,t){if(t.basis.containerFormat==="auto"){if(Gh(e)){let n=await Ea(t);return Vh(n.KTX2File,e,t)}let{BasisFile:r}=await _a(t);return Ba(r,e,t)}switch(t.basis.module){case"encoder":let r=await Ea(t);switch(t.basis.containerFormat){case"ktx2":return Vh(r.KTX2File,e,t);case"basis":default:return Ba(r.BasisFile,e,t)}case"transcoder":default:let{BasisFile:n}=await _a(t);return Ba(n,e,t)}}function Ba(e,t,r){let n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");let s=n.getNumImages(),o=[];for(let i=0;i<s;i++){let a=n.getNumLevels(i),c=[];for(let l=0;l<a;l++)c.push(oT(n,i,l,r));o.push(c)}return o}finally{n.close(),n.delete()}}function oT(e,t,r,n){let s=e.getImageWidth(t,r),o=e.getImageHeight(t,r),i=e.getHasAlpha(),{compressed:a,format:c,basisFormat:l}=Hh(n,i),u=e.getImageTranscodedSizeInBytes(t,r,l),f=new Uint8Array(u);if(!e.transcodeImage(f,t,r,l,0,0))throw new Error("failed to start Basis transcoding");return{width:s,height:o,data:f,compressed:a,format:c,hasAlpha:i}}function Vh(e,t,r){let n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");let s=n.getLevels(),o=[];for(let i=0;i<s;i++){o.push(iT(n,i,r));break}return[o]}finally{n.close(),n.delete()}}function iT(e,t,r){let{alphaFlag:n,height:s,width:o}=e.getImageLevelInfo(t,0,0),{compressed:i,format:a,basisFormat:c}=Hh(r,n),l=e.getImageTranscodedSizeInBytes(t,0,0,c),u=new Uint8Array(l);if(!e.transcodeImage(u,t,0,0,c,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:o,height:s,data:u,compressed:i,levelSize:l,hasAlpha:n,format:a}}function Hh(e,t){let r=e&&e.basis&&e.basis.format;return r==="auto"&&(r=Gs()),typeof r=="object"&&(r=t?r.alpha:r.noAlpha),r=r.toLowerCase(),sT[r]}function Gs(){let e=Lh();return e.has("astc")?"astc-4x4":e.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:e.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:e.has("etc1")?"etc1":e.has("etc2")?"etc2":"rgb565"}var zh={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:Mh,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},Sa={...zh,parse:Ca};var ba=`#if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
29
+ `},t.modules=[...t.modules,rd],t}initializeState(){super.initializeState(),this.getAttributeManager().addInstanced({timestamps:{size:1,accessor:"getTimestamps",shaderAttributes:{instanceTimestamps:{vertexOffset:0},instanceNextTimestamps:{vertexOffset:1}}}})}draw(t){let{fadeTrail:n,trailLength:r,currentTime:s}=this.props,i={fadeTrail:n,trailLength:r,currentTime:s};this.state.model.shaderInputs.setProps({trips:i}),super.draw(t)}};Gs.layerName="TripsLayer";Gs.defaultProps=FB;var id=Gs;var hd=D(oo(),1),ld=D(ne(),1);var Jt=D(oo(),1),ao=D(ne(),1),ks=D(ee(),1);var zs=D(oo(),1);function co(e,t){t=t===void 0?e[0][0]:t;for(let n of e){let r=n[0]-t;r>180?n[0]-=360:r<-180&&(n[0]+=360)}}function vB(e,t,n){let[r,s]=(0,zs.cellToLatLng)(e),i=t.length;co(t,s);let o=t[0]===t[i-1]?i-1:i;for(let c=0;c<o;c++)t[c][0]=$e(s,t[c][0],n),t[c][1]=$e(r,t[c][1],n)}function cd(e,t,n){let r=e(t,n),[s,i]=(0,zs.cellToLatLng)(r);return[i,s]}function Dh(e,t=1){let n=(0,zs.cellToBoundary)(e,!0);return t!==1?vB(e,n,t):co(n),n}function ad(e){let t=new Float64Array(e.length*2),n=0;for(let r of e)t[n++]=r[0],t[n++]=r[1];return t}var DB=10;function UB(e,t){let n;return e==null?n=t:typeof e=="object"?n={...e,coverage:t}:n={getHexagon:e,coverage:t},n}var GB={...ks.PolygonLayer.defaultProps,highPrecision:"auto",coverage:{type:"number",min:0,max:1,value:1},centerHexagon:null,getHexagon:{type:"accessor",value:e=>e.hexagon},extruded:!0},an=class extends ao.CompositeLayer{initializeState(){an._checkH3Lib(),this.state={edgeLengthKM:0,resolution:-1}}shouldUpdateState({changeFlags:t}){return this._shouldUseHighPrecision()?t.propsOrDataChanged:t.somethingChanged}updateState({props:t,changeFlags:n}){if(t.highPrecision!==!0&&(n.dataChanged||n.updateTriggersChanged&&n.updateTriggersChanged.getHexagon)){let r=this._calculateH3DataProps();this.setState(r)}this._updateVertices(this.context.viewport)}_calculateH3DataProps(){let t=-1,n=!1,r=!1,{iterable:s,objectInfo:i}=(0,ao.createIterable)(this.props.data);for(let o of s){i.index++;let c=this.props.getHexagon(o,i),a=(0,Jt.getResolution)(c);if(t<0){if(t=a,!this.props.highPrecision)break}else if(t!==a){r=!0;break}if((0,Jt.isPentagon)(c)){n=!0;break}}return{resolution:t,edgeLengthKM:t>=0?(0,Jt.getHexagonEdgeLengthAvg)(t,"km"):0,hasMultipleRes:r,hasPentagon:n}}_shouldUseHighPrecision(){if(this.props.highPrecision==="auto"){let{resolution:t,hasPentagon:n,hasMultipleRes:r}=this.state,{viewport:s}=this.context;return Boolean(s?.resolution)||r||n||t>=0&&t<=5}return this.props.highPrecision}_updateVertices(t){if(this._shouldUseHighPrecision())return;let{resolution:n,edgeLengthKM:r,centerHex:s}=this.state;if(n<0)return;let i=this.props.centerHexagon||(0,Jt.latLngToCell)(t.latitude,t.longitude,n);if(s===i)return;if(s)try{if((0,Jt.gridDistance)(s,i)*r<DB)return}catch{}let{unitsPerMeter:o}=t.distanceScales,c=Dh(i),[a,h]=(0,Jt.cellToLatLng)(i),[l,f]=t.projectFlat([h,a]);c=c.map(p=>{let u=t.projectFlat(p);return[(u[0]-l)/o[0],(u[1]-f)/o[1]]}),this.setState({centerHex:i,vertices:c})}renderLayers(){return this._shouldUseHighPrecision()?this._renderPolygonLayer():this._renderColumnLayer()}_getForwardProps(){let{elevationScale:t,material:n,coverage:r,extruded:s,wireframe:i,stroked:o,filled:c,lineWidthUnits:a,lineWidthScale:h,lineWidthMinPixels:l,lineWidthMaxPixels:f,getFillColor:p,getElevation:u,getLineColor:d,getLineWidth:g,transitions:m,updateTriggers:M}=this.props;return{elevationScale:t,extruded:s,coverage:r,wireframe:i,stroked:o,filled:c,lineWidthUnits:a,lineWidthScale:h,lineWidthMinPixels:l,lineWidthMaxPixels:f,material:n,getElevation:u,getFillColor:p,getLineColor:d,getLineWidth:g,transitions:m,updateTriggers:{getFillColor:M.getFillColor,getElevation:M.getElevation,getLineColor:M.getLineColor,getLineWidth:M.getLineWidth}}}_renderPolygonLayer(){let{data:t,getHexagon:n,updateTriggers:r,coverage:s}=this.props,i=this.getSubLayerClass("hexagon-cell-hifi",ks.PolygonLayer),o=this._getForwardProps();return o.updateTriggers.getPolygon=UB(r.getHexagon,s),new i(o,this.getSubLayerProps({id:"hexagon-cell-hifi",updateTriggers:o.updateTriggers}),{data:t,_normalize:!1,_windingOrder:"CCW",positionFormat:"XY",getPolygon:(c,a)=>{let h=n(c,a);return ad(Dh(h,s))}})}_renderColumnLayer(){let{data:t,getHexagon:n,updateTriggers:r}=this.props,s=this.getSubLayerClass("hexagon-cell",ks.ColumnLayer),i=this._getForwardProps();return i.updateTriggers.getPosition=r.getHexagon,new s(i,this.getSubLayerProps({id:"hexagon-cell",flatShading:!0,updateTriggers:i.updateTriggers}),{data:t,diskResolution:6,radius:1,vertices:this.state.vertices,getPosition:cd.bind(null,n)})}};an.defaultProps=GB;an.layerName="H3HexagonLayer";an._checkH3Lib=()=>{};var ho=an;var zB={getHexagons:{type:"accessor",value:e=>e.hexagons}},Vs=class extends ye{initializeState(){ho._checkH3Lib()}updateState({props:t,changeFlags:n}){if(n.dataChanged||n.updateTriggersChanged&&n.updateTriggersChanged.getHexagons){let{data:r,getHexagons:s}=t,i=[],{iterable:o,objectInfo:c}=(0,ld.createIterable)(r);for(let a of o){c.index++;let h=s(a,c),l=(0,hd.cellsToMultiPolygon)(h,!0);for(let f of l){for(let p of f)co(p);i.push(this.getSubLayerRow({polygon:f},a,c.index))}}this.setState({polygons:i})}}indexToBounds(){let{getElevation:t,getFillColor:n,getLineColor:r,getLineWidth:s}=this.props;return{data:this.state.polygons,getPolygon:i=>i.polygon,getElevation:this.getSubLayerAccessor(t),getFillColor:this.getSubLayerAccessor(n),getLineColor:this.getSubLayerAccessor(r),getLineWidth:this.getSubLayerAccessor(s)}}};Vs.layerName="H3ClusterLayer";Vs.defaultProps=zB;var fd=Vs;var Sy=D(Uh(),1),Sn=D(ne(),1),By=D(ee(),1),Cy=D(lo(),1);var md=D(Gh(),1),oe;(function(e){e[e.FUNC_ADD=32774]="FUNC_ADD",e[e.ONE=1]="ONE",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",e[e.LINEAR=9729]="LINEAR",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL"})(oe||(oe={}));function zh(e,t,n,r){let s={defines:{MANUAL_SRGB:1,SRGB_FAST_APPROXIMATION:1},bindings:{},uniforms:{camera:[0,0,0],metallicRoughnessValues:[1,1]},parameters:{},glParameters:{},generatedTextures:[]};s.defines.USE_TEX_LOD=1;let{imageBasedLightingEnvironment:i}=r;return i&&(s.bindings.pbr_diffuseEnvSampler=i.diffuseEnvSampler.texture,s.bindings.pbr_specularEnvSampler=i.specularEnvSampler.texture,s.bindings.pbr_BrdfLUT=i.brdfLutTexture.texture,s.uniforms.scaleIBLAmbient=[1,1]),r?.pbrDebug&&(s.defines.PBR_DEBUG=1,s.uniforms.scaleDiffBaseMR=[0,0,0,0],s.uniforms.scaleFGDSpec=[0,0,0,0]),n.NORMAL&&(s.defines.HAS_NORMALS=1),n.TANGENT&&r?.useTangents&&(s.defines.HAS_TANGENTS=1),n.TEXCOORD_0&&(s.defines.HAS_UV=1),r?.imageBasedLightingEnvironment&&(s.defines.USE_IBL=1),r?.lights&&(s.defines.USE_LIGHTS=1),t&&kB(e,t,s),s}function kB(e,t,n){if(n.uniforms.unlit=Boolean(t.unlit),t.pbrMetallicRoughness&&VB(e,t.pbrMetallicRoughness,n),t.normalTexture){qs(e,t.normalTexture,"pbr_normalSampler","HAS_NORMALMAP",n);let{scale:r=1}=t.normalTexture;n.uniforms.normalScale=r}if(t.occlusionTexture){qs(e,t.occlusionTexture,"pbr_occlusionSampler","HAS_OCCLUSIONMAP",n);let{strength:r=1}=t.occlusionTexture;n.uniforms.occlusionStrength=r}switch(t.emissiveTexture&&(qs(e,t.emissiveTexture,"pbr_emissiveSampler","HAS_EMISSIVEMAP",n),n.uniforms.emissiveFactor=t.emissiveFactor||[0,0,0]),t.alphaMode){case"MASK":let{alphaCutoff:r=.5}=t;n.defines.ALPHA_CUTOFF=1,n.uniforms.alphaCutoff=r;break;case"BLEND":md.log.warn("glTF BLEND alphaMode might not work well because it requires mesh sorting")(),n.parameters.blendColorOperation="add",n.parameters.blendColorSrcFactor="src-alpha",n.parameters.blendColorDstFactor="one-minus-src-alpha",n.parameters.blendAlphaOperation="add",n.parameters.blendAlphaSrcFactor="one",n.parameters.blendAlphaDstFactor="one-minus-src-alpha",n.glParameters.blend=!0,n.glParameters.blendEquation=oe.FUNC_ADD,n.glParameters.blendFunc=[oe.SRC_ALPHA,oe.ONE_MINUS_SRC_ALPHA,oe.ONE,oe.ONE_MINUS_SRC_ALPHA];break}}function VB(e,t,n){t.baseColorTexture&&qs(e,t.baseColorTexture,"pbr_baseColorSampler","HAS_BASECOLORMAP",n),n.uniforms.baseColorFactor=t.baseColorFactor||[1,1,1,1],t.metallicRoughnessTexture&&qs(e,t.metallicRoughnessTexture,"pbr_metallicRoughnessSampler","HAS_METALROUGHNESSMAP",n);let{metallicFactor:r=1,roughnessFactor:s=1}=t;n.uniforms.metallicRoughnessValues=[r,s]}function qs(e,t,n,r=null,s){let i=t?.texture?.sampler?.parameters||{},o=t.texture.source.image,c,a={};o.compressed?(c=o,a={[oe.TEXTURE_MIN_FILTER]:o.data.length>1?oe.LINEAR_MIPMAP_NEAREST:oe.LINEAR}):c={data:o};let h=e.createTexture({id:t.uniformName||t.id,parameters:{...i,...a},pixelStore:{[oe.UNPACK_FLIP_Y_WEBGL]:!1},...c});s.bindings[n]=h,r&&(s.defines[r]=1),s.generatedTextures.push(h)}var gd="4.2.1";var fo={TRANSCODER:"basis_transcoder.js",TRANSCODER_WASM:"basis_transcoder.wasm",ENCODER:"basis_encoder.js",ENCODER_WASM:"basis_encoder.wasm"},xd;async function Vh(e){wa(e.modules);let t=Ia("basis");return t||(xd||=qB(e),await xd)}async function qB(e){let t=null,n=null;return[t,n]=await Promise.all([await me(fo.TRANSCODER,"textures",e),await me(fo.TRANSCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await HB(t,n)}function HB(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e(n).then(s=>{let{BasisFile:i,initializeBasis:o}=s;o(),r({BasisFile:i})})})}var kh;async function qh(e){let t=e.modules||{};return t.basisEncoder?t.basisEncoder:(kh=kh||YB(e),await kh)}async function YB(e){let t=null,n=null;return[t,n]=await Promise.all([await me(fo.ENCODER,"textures",e),await me(fo.ENCODER_WASM,"textures",e)]),t=t||globalThis.BASIS,await WB(t,n)}function WB(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e(n).then(s=>{let{BasisFile:i,KTX2File:o,initializeBasis:c,BasisEncoder:a}=s;c(),r({BasisFile:i,KTX2File:o,BasisEncoder:a})})})}var Un={COMPRESSED_RGB_S3TC_DXT1_EXT:33776,COMPRESSED_RGBA_S3TC_DXT1_EXT:33777,COMPRESSED_RGBA_S3TC_DXT3_EXT:33778,COMPRESSED_RGBA_S3TC_DXT5_EXT:33779,COMPRESSED_R11_EAC:37488,COMPRESSED_SIGNED_R11_EAC:37489,COMPRESSED_RG11_EAC:37490,COMPRESSED_SIGNED_RG11_EAC:37491,COMPRESSED_RGB8_ETC2:37492,COMPRESSED_RGBA8_ETC2_EAC:37493,COMPRESSED_SRGB8_ETC2:37494,COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:37495,COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:37496,COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:37497,COMPRESSED_RGB_PVRTC_4BPPV1_IMG:35840,COMPRESSED_RGBA_PVRTC_4BPPV1_IMG:35842,COMPRESSED_RGB_PVRTC_2BPPV1_IMG:35841,COMPRESSED_RGBA_PVRTC_2BPPV1_IMG:35843,COMPRESSED_RGB_ETC1_WEBGL:36196,COMPRESSED_RGB_ATC_WEBGL:35986,COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL:35987,COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL:34798,COMPRESSED_RGBA_ASTC_4X4_KHR:37808,COMPRESSED_RGBA_ASTC_5X4_KHR:37809,COMPRESSED_RGBA_ASTC_5X5_KHR:37810,COMPRESSED_RGBA_ASTC_6X5_KHR:37811,COMPRESSED_RGBA_ASTC_6X6_KHR:37812,COMPRESSED_RGBA_ASTC_8X5_KHR:37813,COMPRESSED_RGBA_ASTC_8X6_KHR:37814,COMPRESSED_RGBA_ASTC_8X8_KHR:37815,COMPRESSED_RGBA_ASTC_10X5_KHR:37816,COMPRESSED_RGBA_ASTC_10X6_KHR:37817,COMPRESSED_RGBA_ASTC_10X8_KHR:37818,COMPRESSED_RGBA_ASTC_10X10_KHR:37819,COMPRESSED_RGBA_ASTC_12X10_KHR:37820,COMPRESSED_RGBA_ASTC_12X12_KHR:37821,COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR:37840,COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR:37841,COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR:37842,COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR:37843,COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR:37844,COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR:37845,COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR:37846,COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR:37847,COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR:37848,COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR:37849,COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR:37850,COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR:37851,COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR:37852,COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR:37853,COMPRESSED_RED_RGTC1_EXT:36283,COMPRESSED_SIGNED_RED_RGTC1_EXT:36284,COMPRESSED_RED_GREEN_RGTC2_EXT:36285,COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT:36286,COMPRESSED_SRGB_S3TC_DXT1_EXT:35916,COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:35917,COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:35918,COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:35919};var JB=["","WEBKIT_","MOZ_"],Md={WEBGL_compressed_texture_s3tc:"dxt",WEBGL_compressed_texture_s3tc_srgb:"dxt-srgb",WEBGL_compressed_texture_etc1:"etc1",WEBGL_compressed_texture_etc:"etc2",WEBGL_compressed_texture_pvrtc:"pvrtc",WEBGL_compressed_texture_atc:"atc",WEBGL_compressed_texture_astc:"astc",EXT_texture_compression_rgtc:"rgtc"},po=null;function Ad(e){if(!po){e=e||XB()||void 0,po=new Set;for(let t of JB)for(let n in Md)if(e&&e.getExtension(`${t}${n}`)){let r=Md[n];po.add(r)}}return po}function XB(){try{return document.createElement("canvas").getContext("webgl")}catch{return null}}var N9=new Uint8Array([0]);var yd,Ed,Td,_d,Sd,Bd,Cd,Ld;(function(e){e[e.NONE=0]="NONE",e[e.BASISLZ=1]="BASISLZ",e[e.ZSTD=2]="ZSTD",e[e.ZLIB=3]="ZLIB"})(yd||(yd={})),function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Ed||(Ed={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Td||(Td={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(_d||(_d={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.LINEAR=1]="LINEAR",e[e.SRGB=2]="SRGB",e[e.ITU=3]="ITU",e[e.NTSC=4]="NTSC",e[e.SLOG=5]="SLOG",e[e.SLOG2=6]="SLOG2"}(Sd||(Sd={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Bd||(Bd={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Cd||(Cd={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Ld||(Ld={}));var Yt=[171,75,84,88,32,50,48,187,13,10,26,10];function Rd(e){let t=new Uint8Array(e);return!(t.byteLength<Yt.length||t[0]!==Yt[0]||t[1]!==Yt[1]||t[2]!==Yt[2]||t[3]!==Yt[3]||t[4]!==Yt[4]||t[5]!==Yt[5]||t[6]!==Yt[6]||t[7]!==Yt[7]||t[8]!==Yt[8]||t[9]!==Yt[9]||t[10]!==Yt[10]||t[11]!==Yt[11])}var jB={etc1:{basisFormat:0,compressed:!0,format:Un.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:Un.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:Un.COMPRESSED_RGBA_S3TC_DXT5_EXT},bc4:{basisFormat:4,compressed:!0},bc5:{basisFormat:5,compressed:!0},"bc7-m6-opaque-only":{basisFormat:6,compressed:!0},"bc7-m5":{basisFormat:7,compressed:!0},"pvrtc1-4-rgb":{basisFormat:8,compressed:!0,format:Un.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:Un.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:Un.COMPRESSED_RGBA_ASTC_4X4_KHR},"atc-rgb":{basisFormat:11,compressed:!0},"atc-rgba-interpolated-alpha":{basisFormat:12,compressed:!0},rgba32:{basisFormat:13,compressed:!1},rgb565:{basisFormat:14,compressed:!1},bgr565:{basisFormat:15,compressed:!1},rgba4444:{basisFormat:16,compressed:!1}};async function Yh(e,t){if(t.basis.containerFormat==="auto"){if(Rd(e)){let r=await qh(t);return wd(r.KTX2File,e,t)}let{BasisFile:n}=await Vh(t);return Hh(n,e,t)}switch(t.basis.module){case"encoder":let n=await qh(t);switch(t.basis.containerFormat){case"ktx2":return wd(n.KTX2File,e,t);case"basis":default:return Hh(n.BasisFile,e,t)}case"transcoder":default:let{BasisFile:r}=await Vh(t);return Hh(r,e,t)}}function Hh(e,t,n){let r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("Failed to start basis transcoding");let s=r.getNumImages(),i=[];for(let o=0;o<s;o++){let c=r.getNumLevels(o),a=[];for(let h=0;h<c;h++)a.push(KB(r,o,h,n));i.push(a)}return i}finally{r.close(),r.delete()}}function KB(e,t,n,r){let s=e.getImageWidth(t,n),i=e.getImageHeight(t,n),o=e.getHasAlpha(),{compressed:c,format:a,basisFormat:h}=Id(r,o),l=e.getImageTranscodedSizeInBytes(t,n,h),f=new Uint8Array(l);if(!e.transcodeImage(f,t,n,h,0,0))throw new Error("failed to start Basis transcoding");return{width:s,height:i,data:f,compressed:c,format:a,hasAlpha:o}}function wd(e,t,n){let r=new e(new Uint8Array(t));try{if(!r.startTranscoding())throw new Error("failed to start KTX2 transcoding");let s=r.getLevels(),i=[];for(let o=0;o<s;o++){i.push(ZB(r,o,n));break}return[i]}finally{r.close(),r.delete()}}function ZB(e,t,n){let{alphaFlag:r,height:s,width:i}=e.getImageLevelInfo(t,0,0),{compressed:o,format:c,basisFormat:a}=Id(n,r),h=e.getImageTranscodedSizeInBytes(t,0,0,a),l=new Uint8Array(h);if(!e.transcodeImage(l,t,0,0,a,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:i,height:s,data:l,compressed:o,levelSize:h,hasAlpha:r,format:c}}function Id(e,t){let n=e&&e.basis&&e.basis.format;return n==="auto"&&(n=uo()),typeof n=="object"&&(n=t?n.alpha:n.noAlpha),n=n.toLowerCase(),jB[n]}function uo(){let e=Ad();return e.has("astc")?"astc-4x4":e.has("dxt")?{alpha:"bc3",noAlpha:"bc1"}:e.has("pvrtc")?{alpha:"pvrtc1-4-rgba",noAlpha:"pvrtc1-4-rgb"}:e.has("etc1")?"etc1":e.has("etc2")?"etc2":"rgb565"}var bd={dataType:null,batchType:null,name:"Basis",id:"basis",module:"textures",version:gd,worker:!0,extensions:["basis","ktx2"],mimeTypes:["application/octet-stream","image/ktx2"],tests:["sB"],binary:!0,options:{basis:{format:"auto",libraryPath:"libs/",containerFormat:"auto",module:"transcoder"}}},Wh={...bd,parse:Yh};var Pd=D(Gh(),1);var Jh=`precision highp int;
30
+
31
+ // #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
29
32
  struct AmbientLight {
30
- vec3 color;
33
+ vec3 color;
31
34
  };
35
+
32
36
  struct PointLight {
33
- vec3 color;
34
- vec3 position;
35
- vec3 attenuation;
37
+ vec3 color;
38
+ vec3 position;
39
+ vec3 attenuation; // 2nd order x:Constant-y:Linear-z:Exponential
36
40
  };
41
+
37
42
  struct DirectionalLight {
38
- vec3 color;
39
- vec3 direction;
43
+ vec3 color;
44
+ vec3 direction;
40
45
  };
41
- uniform AmbientLight lighting_uAmbientLight;
42
- uniform PointLight lighting_uPointLight[MAX_LIGHTS];
43
- uniform DirectionalLight lighting_uDirectionalLight[MAX_LIGHTS];
44
- uniform int lighting_uPointLightCount;
45
- uniform int lighting_uDirectionalLightCount;
46
- uniform bool lighting_uEnabled;
46
+
47
+ uniform lightingUniforms {
48
+ int enabled;
49
+ int lightType;
50
+
51
+ int directionalLightCount;
52
+ int pointLightCount;
53
+
54
+ vec3 ambientColor;
55
+
56
+ vec3 lightColor0;
57
+ vec3 lightPosition0;
58
+ vec3 lightDirection0;
59
+ vec3 lightAttenuation0;
60
+
61
+ vec3 lightColor1;
62
+ vec3 lightPosition1;
63
+ vec3 lightDirection1;
64
+ vec3 lightAttenuation1;
65
+
66
+ vec3 lightColor2;
67
+ vec3 lightPosition2;
68
+ vec3 lightDirection2;
69
+ vec3 lightAttenuation2;
70
+ } lighting;
71
+
72
+ PointLight lighting_getPointLight(int index) {
73
+ switch (index) {
74
+ case 0:
75
+ return PointLight(lighting.lightColor0, lighting.lightPosition0, lighting.lightAttenuation0);
76
+ case 1:
77
+ return PointLight(lighting.lightColor1, lighting.lightPosition1, lighting.lightAttenuation1);
78
+ case 2:
79
+ default:
80
+ return PointLight(lighting.lightColor2, lighting.lightPosition2, lighting.lightAttenuation2);
81
+ }
82
+ }
83
+
84
+ DirectionalLight lighting_getDirectionalLight(int index) {
85
+ switch (index) {
86
+ case 0:
87
+ return DirectionalLight(lighting.lightColor0, lighting.lightDirection0);
88
+ case 1:
89
+ return DirectionalLight(lighting.lightColor1, lighting.lightDirection1);
90
+ case 2:
91
+ default:
92
+ return DirectionalLight(lighting.lightColor2, lighting.lightDirection2);
93
+ }
94
+ }
95
+
47
96
  float getPointLightAttenuation(PointLight pointLight, float distance) {
48
- return pointLight.attenuation.x
49
- + pointLight.attenuation.y * distance
50
- + pointLight.attenuation.z * distance * distance;
97
+ return pointLight.attenuation.x
98
+ + pointLight.attenuation.y * distance
99
+ + pointLight.attenuation.z * distance * distance;
51
100
  }
52
- #endif
53
- `;var aT={lightSources:{}};function Ma(e={}){let{color:t=[0,0,0],intensity:r=1}=e;return t.map(n=>n*r/255)}function cT({ambientLight:e,pointLights:t=[],directionalLights:r=[]}){let n={};return e?n["lighting_uAmbientLight.color"]=Ma(e):n["lighting_uAmbientLight.color"]=[0,0,0],t.forEach((s,o)=>{n[`lighting_uPointLight[${o}].color`]=Ma(s),n[`lighting_uPointLight[${o}].position`]=s.position,n[`lighting_uPointLight[${o}].attenuation`]=s.attenuation||[1,0,0]}),n.lighting_uPointLightCount=t.length,r.forEach((s,o)=>{n[`lighting_uDirectionalLight[${o}].color`]=Ma(s),n[`lighting_uDirectionalLight[${o}].direction`]=s.direction}),n.lighting_uDirectionalLightCount=r.length,n}function kh(e=aT){if("lightSources"in e){let{ambientLight:t,pointLights:r,directionalLights:n}=e.lightSources||{};return t||r&&r.length>0||n&&n.length>0?Object.assign({},cT({ambientLight:t,pointLights:r,directionalLights:n}),{lighting_uEnabled:!0}):{lighting_uEnabled:!1}}if("lights"in e){let t={pointLights:[],directionalLights:[]};for(let r of e.lights||[])switch(r.type){case"ambient":t.ambientLight=r;break;case"directional":t.directionalLights?.push(r);break;case"point":t.pointLights?.push(r);break;default:}return kh({lightSources:t})}return{}}var Jh={name:"lights",vs:ba,fs:ba,getUniforms:kh,defines:{MAX_LIGHTS:3}};var qh=`uniform mat4 u_MVPMatrix;
54
- uniform mat4 u_ModelMatrix;
55
- uniform mat4 u_NormalMatrix;
56
- out vec3 pbr_vPosition;
101
+
102
+ // #endif
103
+ `;var Od=`// #if (defined(SHADER_TYPE_FRAGMENT) && defined(LIGHTING_FRAGMENT)) || (defined(SHADER_TYPE_VERTEX) && defined(LIGHTING_VERTEX))
104
+ struct AmbientLight {
105
+ color: vec3<f32>,
106
+ };
107
+
108
+ struct PointLight {
109
+ color: vec3<f32>,
110
+ position: vec3<f32>,
111
+ attenuation: vec3<f32>, // 2nd order x:Constant-y:Linear-z:Exponential
112
+ };
113
+
114
+ struct DirectionalLight {
115
+ color: vec3<f32>,
116
+ direction: vec3<f32>,
117
+ };
118
+
119
+ struct lightingUniforms {
120
+ enabled: i32,
121
+ poightCount: i32,
122
+ directionalLightCount: i32,
123
+
124
+ ambientColor: vec3<f32>,
125
+
126
+ // TODO - support multiple lights by uncommenting arrays below
127
+ lightType: i32,
128
+ lightColor: vec3<f32>,
129
+ lightDirection: vec3<f32>,
130
+ lightPosition: vec3<f32>,
131
+ lightAttenuation: vec3<f32>,
132
+
133
+ // AmbientLight ambientLight;
134
+ // PointLight pointLight[MAX_LIGHTS];
135
+ // DirectionalLight directionalLight[MAX_LIGHTS];
136
+ };
137
+
138
+ // Binding 0:1 is reserved for lighting (Note: could go into separate bind group as it is stable across draw calls)
139
+ @binding(1) @group(0) var<uniform> lighting : lightingUniforms;
140
+
141
+ fn lighting_getPointLight(index: i32) -> PointLight {
142
+ return PointLight(lighting.lightColor, lighting.lightPosition, lighting.lightAttenuation);
143
+ }
144
+
145
+ fn lighting_getDirectionalLight(index: i32) -> DirectionalLight {
146
+ return DirectionalLight(lighting.lightColor, lighting.lightDirection);
147
+ }
148
+
149
+ fn getPointLightAttenuation(pointLight: PointLight, distance: f32) -> f32 {
150
+ return pointLight.attenuation.x
151
+ + pointLight.attenuation.y * distance
152
+ + pointLight.attenuation.z * distance * distance;
153
+ }
154
+ `;var Nd=3,QB=255,Ys;(function(e){e[e.POINT=0]="POINT",e[e.DIRECTIONAL=1]="DIRECTIONAL"})(Ys||(Ys={}));var Hs={props:{},uniforms:{},name:"lighting",defines:{MAX_LIGHTS:Nd},uniformTypes:{enabled:"i32",lightType:"i32",directionalLightCount:"i32",pointLightCount:"i32",ambientLightColor:"vec3<f32>",lightColor0:"vec3<f32>",lightPosition0:"vec3<f32>",lightDirection0:"vec3<f32>",lightAttenuation0:"vec3<f32>",lightColor1:"vec3<f32>",lightPosition1:"vec3<f32>",lightDirection1:"vec3<f32>",lightAttenuation1:"vec3<f32>",lightColor2:"vec3<f32>",lightPosition2:"vec3<f32>",lightDirection2:"vec3<f32>",lightAttenuation2:"vec3<f32>"},defaultUniforms:{enabled:1,lightType:Ys.POINT,directionalLightCount:0,pointLightCount:0,ambientLightColor:[.1,.1,.1],lightColor0:[1,1,1],lightPosition0:[1,1,2],lightDirection0:[1,1,1],lightAttenuation0:[1,0,0],lightColor1:[1,1,1],lightPosition1:[1,1,2],lightDirection1:[1,1,1],lightAttenuation1:[1,0,0],lightColor2:[1,1,1],lightPosition2:[1,1,2],lightDirection2:[1,1,1],lightAttenuation2:[1,0,0]},source:Od,vs:Jh,fs:Jh,getUniforms:$B};function $B(e,t={}){if(e=e&&{...e},!e)return{...Hs.defaultUniforms};e.lights&&(e={...e,...eC(e.lights),lights:void 0});let{ambientLight:n,pointLights:r,directionalLights:s}=e||{};if(!(n||r&&r.length>0||s&&s.length>0))return{...Hs.defaultUniforms,enabled:0};let o={...Hs.defaultUniforms,...t,...tC({ambientLight:n,pointLights:r,directionalLights:s})};return e.enabled!==void 0&&(o.enabled=e.enabled?1:0),o}function tC({ambientLight:e,pointLights:t=[],directionalLights:n=[]}){let r={};r.ambientLightColor=Xh(e);let s=0;for(let i of t){r.lightType=Ys.POINT;let o=s;r[`lightColor${o}`]=Xh(i),r[`lightPosition${o}`]=i.position,r[`lightAttenuation${o}`]=i.attenuation||[1,0,0],s++}for(let i of n){r.lightType=Ys.DIRECTIONAL;let o=s;r[`lightColor${o}`]=Xh(i),r[`lightDirection${o}`]=i.direction,s++}return s>Nd&&Pd.log.warn("MAX_LIGHTS exceeded")(),r.directionalLightCount=n.length,r.pointLightCount=t.length,r}function eC(e){let t={pointLights:[],directionalLights:[]};for(let n of e||[])switch(n.type){case"ambient":t.ambientLight=n;break;case"directional":t.directionalLights?.push(n);break;case"point":t.pointLights?.push(n);break;default:}return t}function Xh(e={}){let{color:t=[0,0,0],intensity:n=1}=e;return t.map(r=>r*n/QB)}var Fd=`out vec3 pbr_vPosition;
57
155
  out vec2 pbr_vUV;
156
+
58
157
  #ifdef HAS_NORMALS
59
158
  # ifdef HAS_TANGENTS
60
159
  out mat3 pbr_vTBN;
@@ -62,64 +161,92 @@ out mat3 pbr_vTBN;
62
161
  out vec3 pbr_vNormal;
63
162
  # endif
64
163
  #endif
164
+
65
165
  void pbr_setPositionNormalTangentUV(vec4 position, vec4 normal, vec4 tangent, vec2 uv)
66
166
  {
67
- vec4 pos = u_ModelMatrix * position;
68
- pbr_vPosition = vec3(pos.xyz) / pos.w;
167
+ vec4 pos = pbrProjection.modelMatrix * position;
168
+ pbr_vPosition = vec3(pos.xyz) / pos.w;
169
+
69
170
  #ifdef HAS_NORMALS
70
171
  #ifdef HAS_TANGENTS
71
- vec3 normalW = normalize(vec3(u_NormalMatrix * vec4(normal.xyz, 0.0)));
72
- vec3 tangentW = normalize(vec3(u_ModelMatrix * vec4(tangent.xyz, 0.0)));
73
- vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
74
- pbr_vTBN = mat3(tangentW, bitangentW, normalW);
75
- #else
76
- pbr_vNormal = normalize(vec3(u_ModelMatrix * vec4(normal.xyz, 0.0)));
172
+ vec3 normalW = normalize(vec3(pbrProjection.normalMatrix * vec4(normal.xyz, 0.0)));
173
+ vec3 tangentW = normalize(vec3(pbrProjection.modelMatrix * vec4(tangent.xyz, 0.0)));
174
+ vec3 bitangentW = cross(normalW, tangentW) * tangent.w;
175
+ pbr_vTBN = mat3(tangentW, bitangentW, normalW);
176
+ #else // HAS_TANGENTS != 1
177
+ pbr_vNormal = normalize(vec3(pbrProjection.modelMatrix * vec4(normal.xyz, 0.0)));
77
178
  #endif
78
179
  #endif
180
+
79
181
  #ifdef HAS_UV
80
- pbr_vUV = uv;
182
+ pbr_vUV = uv;
81
183
  #else
82
- pbr_vUV = vec2(0.,0.);
184
+ pbr_vUV = vec2(0.,0.);
83
185
  #endif
84
186
  }
85
- `;var jh=`precision highp float;
86
- uniform bool pbr_uUnlit;
87
- #ifdef USE_IBL
88
- uniform samplerCube u_DiffuseEnvSampler;
89
- uniform samplerCube u_SpecularEnvSampler;
90
- uniform sampler2D u_brdfLUT;
91
- uniform vec2 u_ScaleIBLAmbient;
92
- #endif
187
+ `;var vd=`precision highp float;
188
+
189
+ uniform pbrMaterialUniforms {
190
+ // Material is unlit
191
+ bool unlit;
192
+
193
+ // Base color map
194
+ bool baseColorMapEnabled;
195
+ vec4 baseColorFactor;
196
+
197
+ bool normalMapEnabled;
198
+ float normalScale; // #ifdef HAS_NORMALMAP
199
+
200
+ bool emissiveMapEnabled;
201
+ vec3 emissiveFactor; // #ifdef HAS_EMISSIVEMAP
202
+
203
+ vec2 metallicRoughnessValues;
204
+ bool metallicRoughnessMapEnabled;
205
+
206
+ bool occlusionMapEnabled;
207
+ float occlusionStrength; // #ifdef HAS_OCCLUSIONMAP
208
+
209
+ bool alphaCutoffEnabled;
210
+ float alphaCutoff; // #ifdef ALPHA_CUTOFF
211
+
212
+ // IBL
213
+ bool IBLenabled;
214
+ vec2 scaleIBLAmbient; // #ifdef USE_IBL
215
+
216
+ // debugging flags used for shader output of intermediate PBR variables
217
+ // #ifdef PBR_DEBUG
218
+ vec4 scaleDiffBaseMR;
219
+ vec4 scaleFGDSpec;
220
+ // #endif
221
+ } pbrMaterial;
222
+
223
+ // Samplers
93
224
  #ifdef HAS_BASECOLORMAP
94
- uniform sampler2D u_BaseColorSampler;
225
+ uniform sampler2D pbr_baseColorSampler;
95
226
  #endif
96
227
  #ifdef HAS_NORMALMAP
97
- uniform sampler2D u_NormalSampler;
98
- uniform float u_NormalScale;
228
+ uniform sampler2D pbr_normalSampler;
99
229
  #endif
100
230
  #ifdef HAS_EMISSIVEMAP
101
- uniform sampler2D u_EmissiveSampler;
102
- uniform vec3 u_EmissiveFactor;
231
+ uniform sampler2D pbr_emissiveSampler;
103
232
  #endif
104
233
  #ifdef HAS_METALROUGHNESSMAP
105
- uniform sampler2D u_MetallicRoughnessSampler;
234
+ uniform sampler2D pbr_metallicRoughnessSampler;
106
235
  #endif
107
236
  #ifdef HAS_OCCLUSIONMAP
108
- uniform sampler2D u_OcclusionSampler;
109
- uniform float u_OcclusionStrength;
237
+ uniform sampler2D pbr_occlusionSampler;
110
238
  #endif
111
- #ifdef ALPHA_CUTOFF
112
- uniform float u_AlphaCutoff;
113
- #endif
114
- uniform vec2 u_MetallicRoughnessValues;
115
- uniform vec4 u_BaseColorFactor;
116
- uniform vec3 u_Camera;
117
- #ifdef PBR_DEBUG
118
- uniform vec4 u_ScaleDiffBaseMR;
119
- uniform vec4 u_ScaleFGDSpec;
239
+ #ifdef USE_IBL
240
+ uniform samplerCube pbr_diffuseEnvSampler;
241
+ uniform samplerCube pbr_specularEnvSampler;
242
+ uniform sampler2D pbr_brdfLUT;
120
243
  #endif
244
+
245
+ // Inputs from vertex shader
246
+
121
247
  in vec3 pbr_vPosition;
122
248
  in vec2 pbr_vUV;
249
+
123
250
  #ifdef HAS_NORMALS
124
251
  #ifdef HAS_TANGENTS
125
252
  in mat3 pbr_vTBN;
@@ -127,235 +254,348 @@ in mat3 pbr_vTBN;
127
254
  in vec3 pbr_vNormal;
128
255
  #endif
129
256
  #endif
130
- struct PBRInfo
131
- {
132
- float NdotL;
133
- float NdotV;
134
- float NdotH;
135
- float LdotH;
136
- float VdotH;
137
- float perceptualRoughness;
138
- float metalness;
139
- vec3 reflectance0;
140
- vec3 reflectance90;
141
- float alphaRoughness;
142
- vec3 diffuseColor;
143
- vec3 specularColor;
144
- vec3 n;
145
- vec3 v;
257
+
258
+ // Encapsulate the various inputs used by the various functions in the shading equation
259
+ // We store values in this struct to simplify the integration of alternative implementations
260
+ // of the shading terms, outlined in the Readme.MD Appendix.
261
+ struct PBRInfo {
262
+ float NdotL; // cos angle between normal and light direction
263
+ float NdotV; // cos angle between normal and view direction
264
+ float NdotH; // cos angle between normal and half vector
265
+ float LdotH; // cos angle between light direction and half vector
266
+ float VdotH; // cos angle between view direction and half vector
267
+ float perceptualRoughness; // roughness value, as authored by the model creator (input to shader)
268
+ float metalness; // metallic value at the surface
269
+ vec3 reflectance0; // full reflectance color (normal incidence angle)
270
+ vec3 reflectance90; // reflectance color at grazing angle
271
+ float alphaRoughness; // roughness mapped to a more linear change in the roughness (proposed by [2])
272
+ vec3 diffuseColor; // color contribution from diffuse lighting
273
+ vec3 specularColor; // color contribution from specular lighting
274
+ vec3 n; // normal at surface point
275
+ vec3 v; // vector from surface point to camera
146
276
  };
277
+
147
278
  const float M_PI = 3.141592653589793;
148
279
  const float c_MinRoughness = 0.04;
280
+
149
281
  vec4 SRGBtoLINEAR(vec4 srgbIn)
150
282
  {
151
283
  #ifdef MANUAL_SRGB
152
284
  #ifdef SRGB_FAST_APPROXIMATION
153
- vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
154
- #else
155
- vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
156
- vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
157
- #endif
158
- return vec4(linOut,srgbIn.w);;
159
- #else
160
- return srgbIn;
161
- #endif
285
+ vec3 linOut = pow(srgbIn.xyz,vec3(2.2));
286
+ #else // SRGB_FAST_APPROXIMATION
287
+ vec3 bLess = step(vec3(0.04045),srgbIn.xyz);
288
+ vec3 linOut = mix( srgbIn.xyz/vec3(12.92), pow((srgbIn.xyz+vec3(0.055))/vec3(1.055),vec3(2.4)), bLess );
289
+ #endif //SRGB_FAST_APPROXIMATION
290
+ return vec4(linOut,srgbIn.w);;
291
+ #else //MANUAL_SRGB
292
+ return srgbIn;
293
+ #endif //MANUAL_SRGB
162
294
  }
295
+
296
+ // Find the normal for this fragment, pulling either from a predefined normal map
297
+ // or from the interpolated mesh normal and tangent attributes.
163
298
  vec3 getNormal()
164
299
  {
300
+ // Retrieve the tangent space matrix
165
301
  #ifndef HAS_TANGENTS
166
- vec3 pos_dx = dFdx(pbr_vPosition);
167
- vec3 pos_dy = dFdy(pbr_vPosition);
168
- vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));
169
- vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));
170
- vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
302
+ vec3 pos_dx = dFdx(pbr_vPosition);
303
+ vec3 pos_dy = dFdy(pbr_vPosition);
304
+ vec3 tex_dx = dFdx(vec3(pbr_vUV, 0.0));
305
+ vec3 tex_dy = dFdy(vec3(pbr_vUV, 0.0));
306
+ vec3 t = (tex_dy.t * pos_dx - tex_dx.t * pos_dy) / (tex_dx.s * tex_dy.t - tex_dy.s * tex_dx.t);
307
+
171
308
  #ifdef HAS_NORMALS
172
- vec3 ng = normalize(pbr_vNormal);
309
+ vec3 ng = normalize(pbr_vNormal);
173
310
  #else
174
- vec3 ng = cross(pos_dx, pos_dy);
311
+ vec3 ng = cross(pos_dx, pos_dy);
175
312
  #endif
176
- t = normalize(t - ng * dot(ng, t));
177
- vec3 b = normalize(cross(ng, t));
178
- mat3 tbn = mat3(t, b, ng);
179
- #else
180
- mat3 tbn = pbr_vTBN;
313
+
314
+ t = normalize(t - ng * dot(ng, t));
315
+ vec3 b = normalize(cross(ng, t));
316
+ mat3 tbn = mat3(t, b, ng);
317
+ #else // HAS_TANGENTS
318
+ mat3 tbn = pbr_vTBN;
181
319
  #endif
320
+
182
321
  #ifdef HAS_NORMALMAP
183
- vec3 n = texture(u_NormalSampler, pbr_vUV).rgb;
184
- n = normalize(tbn * ((2.0 * n - 1.0) * vec3(u_NormalScale, u_NormalScale, 1.0)));
322
+ vec3 n = texture(pbr_normalSampler, pbr_vUV).rgb;
323
+ n = normalize(tbn * ((2.0 * n - 1.0) * vec3(pbrMaterial.normalScale, pbrMaterial.normalScale, 1.0)));
185
324
  #else
186
- vec3 n = normalize(tbn[2].xyz);
325
+ // The tbn matrix is linearly interpolated, so we need to re-normalize
326
+ vec3 n = normalize(tbn[2].xyz);
187
327
  #endif
188
- return n;
328
+
329
+ return n;
189
330
  }
331
+
332
+ // Calculation of the lighting contribution from an optional Image Based Light source.
333
+ // Precomputed Environment Maps are required uniform inputs and are computed as outlined in [1].
334
+ // See our README.md on Environment Maps [3] for additional discussion.
190
335
  #ifdef USE_IBL
191
- vec3 getIBLContribution(PBRInfo pbrInputs, vec3 n, vec3 reflection)
336
+ vec3 getIBLContribution(PBRInfo pbrInfo, vec3 n, vec3 reflection)
192
337
  {
193
- float mipCount = 9.0;
194
- float lod = (pbrInputs.perceptualRoughness * mipCount);
195
- vec3 brdf = SRGBtoLINEAR(texture(u_brdfLUT,
196
- vec2(pbrInputs.NdotV, 1.0 - pbrInputs.perceptualRoughness))).rgb;
197
- vec3 diffuseLight = SRGBtoLINEAR(textureCube(u_DiffuseEnvSampler, n)).rgb;
338
+ float mipCount = 9.0; // resolution of 512x512
339
+ float lod = (pbrInfo.perceptualRoughness * mipCount);
340
+ // retrieve a scale and bias to F0. See [1], Figure 3
341
+ vec3 brdf = SRGBtoLINEAR(texture(pbr_brdfLUT,
342
+ vec2(pbrInfo.NdotV, 1.0 - pbrInfo.perceptualRoughness))).rgb;
343
+ vec3 diffuseLight = SRGBtoLINEAR(texture(pbr_diffuseEnvSampler, n)).rgb;
344
+
198
345
  #ifdef USE_TEX_LOD
199
- vec3 specularLight = SRGBtoLINEAR(textureCubeLod(u_SpecularEnvSampler, reflection, lod)).rgb;
346
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection, lod)).rgb;
200
347
  #else
201
- vec3 specularLight = SRGBtoLINEAR(textureCube(u_SpecularEnvSampler, reflection)).rgb;
202
- #endif
203
- vec3 diffuse = diffuseLight * pbrInputs.diffuseColor;
204
- vec3 specular = specularLight * (pbrInputs.specularColor * brdf.x + brdf.y);
205
- diffuse *= u_ScaleIBLAmbient.x;
206
- specular *= u_ScaleIBLAmbient.y;
207
- return diffuse + specular;
348
+ vec3 specularLight = SRGBtoLINEAR(texture(pbr_specularEnvSampler, reflection)).rgb;
349
+ #endif
350
+
351
+ vec3 diffuse = diffuseLight * pbrInfo.diffuseColor;
352
+ vec3 specular = specularLight * (pbrInfo.specularColor * brdf.x + brdf.y);
353
+
354
+ // For presentation, this allows us to disable IBL terms
355
+ diffuse *= pbrMaterial.scaleIBLAmbient.x;
356
+ specular *= pbrMaterial.scaleIBLAmbient.y;
357
+
358
+ return diffuse + specular;
208
359
  }
209
360
  #endif
210
- vec3 diffuse(PBRInfo pbrInputs)
361
+
362
+ // Basic Lambertian diffuse
363
+ // Implementation from Lambert's Photometria https://archive.org/details/lambertsphotome00lambgoog
364
+ // See also [1], Equation 1
365
+ vec3 diffuse(PBRInfo pbrInfo)
211
366
  {
212
- return pbrInputs.diffuseColor / M_PI;
367
+ return pbrInfo.diffuseColor / M_PI;
213
368
  }
214
- vec3 specularReflection(PBRInfo pbrInputs)
369
+
370
+ // The following equation models the Fresnel reflectance term of the spec equation (aka F())
371
+ // Implementation of fresnel from [4], Equation 15
372
+ vec3 specularReflection(PBRInfo pbrInfo)
215
373
  {
216
- return pbrInputs.reflectance0 +
217
- (pbrInputs.reflectance90 - pbrInputs.reflectance0) *
218
- pow(clamp(1.0 - pbrInputs.VdotH, 0.0, 1.0), 5.0);
374
+ return pbrInfo.reflectance0 +
375
+ (pbrInfo.reflectance90 - pbrInfo.reflectance0) *
376
+ pow(clamp(1.0 - pbrInfo.VdotH, 0.0, 1.0), 5.0);
219
377
  }
220
- float geometricOcclusion(PBRInfo pbrInputs)
378
+
379
+ // This calculates the specular geometric attenuation (aka G()),
380
+ // where rougher material will reflect less light back to the viewer.
381
+ // This implementation is based on [1] Equation 4, and we adopt their modifications to
382
+ // alphaRoughness as input as originally proposed in [2].
383
+ float geometricOcclusion(PBRInfo pbrInfo)
221
384
  {
222
- float NdotL = pbrInputs.NdotL;
223
- float NdotV = pbrInputs.NdotV;
224
- float r = pbrInputs.alphaRoughness;
225
- float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
226
- float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
227
- return attenuationL * attenuationV;
385
+ float NdotL = pbrInfo.NdotL;
386
+ float NdotV = pbrInfo.NdotV;
387
+ float r = pbrInfo.alphaRoughness;
388
+
389
+ float attenuationL = 2.0 * NdotL / (NdotL + sqrt(r * r + (1.0 - r * r) * (NdotL * NdotL)));
390
+ float attenuationV = 2.0 * NdotV / (NdotV + sqrt(r * r + (1.0 - r * r) * (NdotV * NdotV)));
391
+ return attenuationL * attenuationV;
228
392
  }
229
- float microfacetDistribution(PBRInfo pbrInputs)
393
+
394
+ // The following equation(s) model the distribution of microfacet normals across
395
+ // the area being drawn (aka D())
396
+ // Implementation from "Average Irregularity Representation of a Roughened Surface
397
+ // for Ray Reflection" by T. S. Trowbridge, and K. P. Reitz
398
+ // Follows the distribution function recommended in the SIGGRAPH 2013 course notes
399
+ // from EPIC Games [1], Equation 3.
400
+ float microfacetDistribution(PBRInfo pbrInfo)
230
401
  {
231
- float roughnessSq = pbrInputs.alphaRoughness * pbrInputs.alphaRoughness;
232
- float f = (pbrInputs.NdotH * roughnessSq - pbrInputs.NdotH) * pbrInputs.NdotH + 1.0;
233
- return roughnessSq / (M_PI * f * f);
402
+ float roughnessSq = pbrInfo.alphaRoughness * pbrInfo.alphaRoughness;
403
+ float f = (pbrInfo.NdotH * roughnessSq - pbrInfo.NdotH) * pbrInfo.NdotH + 1.0;
404
+ return roughnessSq / (M_PI * f * f);
234
405
  }
235
- void PBRInfo_setAmbientLight(inout PBRInfo pbrInputs) {
236
- pbrInputs.NdotL = 1.0;
237
- pbrInputs.NdotH = 0.0;
238
- pbrInputs.LdotH = 0.0;
239
- pbrInputs.VdotH = 1.0;
406
+
407
+ void PBRInfo_setAmbientLight(inout PBRInfo pbrInfo) {
408
+ pbrInfo.NdotL = 1.0;
409
+ pbrInfo.NdotH = 0.0;
410
+ pbrInfo.LdotH = 0.0;
411
+ pbrInfo.VdotH = 1.0;
240
412
  }
241
- void PBRInfo_setDirectionalLight(inout PBRInfo pbrInputs, vec3 lightDirection) {
242
- vec3 n = pbrInputs.n;
243
- vec3 v = pbrInputs.v;
244
- vec3 l = normalize(lightDirection);
245
- vec3 h = normalize(l+v);
246
- pbrInputs.NdotL = clamp(dot(n, l), 0.001, 1.0);
247
- pbrInputs.NdotH = clamp(dot(n, h), 0.0, 1.0);
248
- pbrInputs.LdotH = clamp(dot(l, h), 0.0, 1.0);
249
- pbrInputs.VdotH = clamp(dot(v, h), 0.0, 1.0);
413
+
414
+ void PBRInfo_setDirectionalLight(inout PBRInfo pbrInfo, vec3 lightDirection) {
415
+ vec3 n = pbrInfo.n;
416
+ vec3 v = pbrInfo.v;
417
+ vec3 l = normalize(lightDirection); // Vector from surface point to light
418
+ vec3 h = normalize(l+v); // Half vector between both l and v
419
+
420
+ pbrInfo.NdotL = clamp(dot(n, l), 0.001, 1.0);
421
+ pbrInfo.NdotH = clamp(dot(n, h), 0.0, 1.0);
422
+ pbrInfo.LdotH = clamp(dot(l, h), 0.0, 1.0);
423
+ pbrInfo.VdotH = clamp(dot(v, h), 0.0, 1.0);
250
424
  }
251
- void PBRInfo_setPointLight(inout PBRInfo pbrInputs, PointLight pointLight) {
252
- vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
253
- PBRInfo_setDirectionalLight(pbrInputs, light_direction);
425
+
426
+ void PBRInfo_setPointLight(inout PBRInfo pbrInfo, PointLight pointLight) {
427
+ vec3 light_direction = normalize(pointLight.position - pbr_vPosition);
428
+ PBRInfo_setDirectionalLight(pbrInfo, light_direction);
254
429
  }
255
- vec3 calculateFinalColor(PBRInfo pbrInputs, vec3 lightColor) {
256
- vec3 F = specularReflection(pbrInputs);
257
- float G = geometricOcclusion(pbrInputs);
258
- float D = microfacetDistribution(pbrInputs);
259
- vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInputs);
260
- vec3 specContrib = F * G * D / (4.0 * pbrInputs.NdotL * pbrInputs.NdotV);
261
- return pbrInputs.NdotL * lightColor * (diffuseContrib + specContrib);
430
+
431
+ vec3 calculateFinalColor(PBRInfo pbrInfo, vec3 lightColor) {
432
+ // Calculate the shading terms for the microfacet specular shading model
433
+ vec3 F = specularReflection(pbrInfo);
434
+ float G = geometricOcclusion(pbrInfo);
435
+ float D = microfacetDistribution(pbrInfo);
436
+
437
+ // Calculation of analytical lighting contribution
438
+ vec3 diffuseContrib = (1.0 - F) * diffuse(pbrInfo);
439
+ vec3 specContrib = F * G * D / (4.0 * pbrInfo.NdotL * pbrInfo.NdotV);
440
+ // Obtain final intensity as reflectance (BRDF) scaled by the energy of the light (cosine law)
441
+ return pbrInfo.NdotL * lightColor * (diffuseContrib + specContrib);
262
442
  }
443
+
263
444
  vec4 pbr_filterColor(vec4 colorUnused)
264
445
  {
446
+ // The albedo may be defined from a base texture or a flat color
265
447
  #ifdef HAS_BASECOLORMAP
266
- vec4 baseColor = SRGBtoLINEAR(texture(u_BaseColorSampler, pbr_vUV)) * u_BaseColorFactor;
448
+ vec4 baseColor = SRGBtoLINEAR(texture(pbr_baseColorSampler, pbr_vUV)) * pbrMaterial.baseColorFactor;
267
449
  #else
268
- vec4 baseColor = u_BaseColorFactor;
450
+ vec4 baseColor = pbrMaterial.baseColorFactor;
269
451
  #endif
452
+
270
453
  #ifdef ALPHA_CUTOFF
271
- if (baseColor.a < u_AlphaCutoff) {
272
- discard;
273
- }
274
- #endif
275
- vec3 color = vec3(0, 0, 0);
276
- if(pbr_uUnlit){
277
- color.rgb = baseColor.rgb;
278
- }
279
- else{
280
- float perceptualRoughness = u_MetallicRoughnessValues.y;
281
- float metallic = u_MetallicRoughnessValues.x;
454
+ if (baseColor.a < pbrMaterial.alphaCutoff) {
455
+ discard;
456
+ }
457
+ #endif
458
+
459
+ vec3 color = vec3(0, 0, 0);
460
+
461
+ if(pbrMaterial.unlit){
462
+ color.rgb = baseColor.rgb;
463
+ }
464
+ else{
465
+ // Metallic and Roughness material properties are packed together
466
+ // In glTF, these factors can be specified by fixed scalar values
467
+ // or from a metallic-roughness map
468
+ float perceptualRoughness = pbrMaterial.metallicRoughnessValues.y;
469
+ float metallic = pbrMaterial.metallicRoughnessValues.x;
282
470
  #ifdef HAS_METALROUGHNESSMAP
283
- vec4 mrSample = texture(u_MetallicRoughnessSampler, pbr_vUV);
284
- perceptualRoughness = mrSample.g * perceptualRoughness;
285
- metallic = mrSample.b * metallic;
286
- #endif
287
- perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
288
- metallic = clamp(metallic, 0.0, 1.0);
289
- float alphaRoughness = perceptualRoughness * perceptualRoughness;
290
- vec3 f0 = vec3(0.04);
291
- vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
292
- diffuseColor *= 1.0 - metallic;
293
- vec3 specularColor = mix(f0, baseColor.rgb, metallic);
294
- float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
295
- float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
296
- vec3 specularEnvironmentR0 = specularColor.rgb;
297
- vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
298
- vec3 n = getNormal();
299
- vec3 v = normalize(u_Camera - pbr_vPosition);
300
- float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
301
- vec3 reflection = -normalize(reflect(v, n));
302
- PBRInfo pbrInputs = PBRInfo(
303
- 0.0,
304
- NdotV,
305
- 0.0,
306
- 0.0,
307
- 0.0,
308
- perceptualRoughness,
309
- metallic,
310
- specularEnvironmentR0,
311
- specularEnvironmentR90,
312
- alphaRoughness,
313
- diffuseColor,
314
- specularColor,
315
- n,
316
- v
317
- );
471
+ // Roughness is stored in the 'g' channel, metallic is stored in the 'b' channel.
472
+ // This layout intentionally reserves the 'r' channel for (optional) occlusion map data
473
+ vec4 mrSample = texture(pbr_metallicRoughnessSampler, pbr_vUV);
474
+ perceptualRoughness = mrSample.g * perceptualRoughness;
475
+ metallic = mrSample.b * metallic;
476
+ #endif
477
+ perceptualRoughness = clamp(perceptualRoughness, c_MinRoughness, 1.0);
478
+ metallic = clamp(metallic, 0.0, 1.0);
479
+ // Roughness is authored as perceptual roughness; as is convention,
480
+ // convert to material roughness by squaring the perceptual roughness [2].
481
+ float alphaRoughness = perceptualRoughness * perceptualRoughness;
482
+
483
+ vec3 f0 = vec3(0.04);
484
+ vec3 diffuseColor = baseColor.rgb * (vec3(1.0) - f0);
485
+ diffuseColor *= 1.0 - metallic;
486
+ vec3 specularColor = mix(f0, baseColor.rgb, metallic);
487
+
488
+ // Compute reflectance.
489
+ float reflectance = max(max(specularColor.r, specularColor.g), specularColor.b);
490
+
491
+ // For typical incident reflectance range (between 4% to 100%) set the grazing
492
+ // reflectance to 100% for typical fresnel effect.
493
+ // For very low reflectance range on highly diffuse objects (below 4%),
494
+ // incrementally reduce grazing reflecance to 0%.
495
+ float reflectance90 = clamp(reflectance * 25.0, 0.0, 1.0);
496
+ vec3 specularEnvironmentR0 = specularColor.rgb;
497
+ vec3 specularEnvironmentR90 = vec3(1.0, 1.0, 1.0) * reflectance90;
498
+
499
+ vec3 n = getNormal(); // normal at surface point
500
+ vec3 v = normalize(pbrProjection.camera - pbr_vPosition); // Vector from surface point to camera
501
+
502
+ float NdotV = clamp(abs(dot(n, v)), 0.001, 1.0);
503
+ vec3 reflection = -normalize(reflect(v, n));
504
+
505
+ PBRInfo pbrInfo = PBRInfo(
506
+ 0.0, // NdotL
507
+ NdotV,
508
+ 0.0, // NdotH
509
+ 0.0, // LdotH
510
+ 0.0, // VdotH
511
+ perceptualRoughness,
512
+ metallic,
513
+ specularEnvironmentR0,
514
+ specularEnvironmentR90,
515
+ alphaRoughness,
516
+ diffuseColor,
517
+ specularColor,
518
+ n,
519
+ v
520
+ );
521
+
522
+
318
523
  #ifdef USE_LIGHTS
319
- PBRInfo_setAmbientLight(pbrInputs);
320
- color += calculateFinalColor(pbrInputs, lighting_uAmbientLight.color);
321
- for(int i = 0; i < lighting_uDirectionalLightCount; i++) {
322
- if (i < lighting_uDirectionalLightCount) {
323
- PBRInfo_setDirectionalLight(pbrInputs, lighting_uDirectionalLight[i].direction);
324
- color += calculateFinalColor(pbrInputs, lighting_uDirectionalLight[i].color);
325
- }
326
- }
327
- for(int i = 0; i < lighting_uPointLightCount; i++) {
328
- if (i < lighting_uPointLightCount) {
329
- PBRInfo_setPointLight(pbrInputs, lighting_uPointLight[i]);
330
- float attenuation = getPointLightAttenuation(lighting_uPointLight[i], distance(lighting_uPointLight[i].position, pbr_vPosition));
331
- color += calculateFinalColor(pbrInputs, lighting_uPointLight[i].color / attenuation);
332
- }
333
- }
334
- #endif
524
+ // Apply ambient light
525
+ PBRInfo_setAmbientLight(pbrInfo);
526
+ color += calculateFinalColor(pbrInfo, lighting.ambientColor);
527
+
528
+ // Apply directional light
529
+ for(int i = 0; i < lighting.directionalLightCount; i++) {
530
+ if (i < lighting.directionalLightCount) {
531
+ PBRInfo_setDirectionalLight(pbrInfo, lighting_getDirectionalLight(i).direction);
532
+ color += calculateFinalColor(pbrInfo, lighting_getDirectionalLight(i).color);
533
+ }
534
+ }
535
+
536
+ // Apply point light
537
+ for(int i = 0; i < lighting.pointLightCount; i++) {
538
+ if (i < lighting.pointLightCount) {
539
+ PBRInfo_setPointLight(pbrInfo, lighting_getPointLight(i));
540
+ float attenuation = getPointLightAttenuation(lighting_getPointLight(i), distance(lighting_getPointLight(i).position, pbr_vPosition));
541
+ color += calculateFinalColor(pbrInfo, lighting_getPointLight(i).color / attenuation);
542
+ }
543
+ }
544
+ #endif
545
+
546
+ // Calculate lighting contribution from image based lighting source (IBL)
335
547
  #ifdef USE_IBL
336
- color += getIBLContribution(pbrInputs, n, reflection);
548
+ if (pbrMaterial.IBLenabled) {
549
+ color += getIBLContribution(pbrInfo, n, reflection);
550
+ }
337
551
  #endif
552
+
553
+ // Apply optional PBR terms for additional (optional) shading
338
554
  #ifdef HAS_OCCLUSIONMAP
339
- float ao = texture(u_OcclusionSampler, pbr_vUV).r;
340
- color = mix(color, color * ao, u_OcclusionStrength);
555
+ if (pbrMaterial.occlusionMapEnabled) {
556
+ float ao = texture(pbr_occlusionSampler, pbr_vUV).r;
557
+ color = mix(color, color * ao, pbrMaterial.occlusionStrength);
558
+ }
341
559
  #endif
560
+
342
561
  #ifdef HAS_EMISSIVEMAP
343
- vec3 emissive = SRGBtoLINEAR(texture(u_EmissiveSampler, pbr_vUV)).rgb * u_EmissiveFactor;
344
- color += emissive;
345
- #endif
562
+ if (pbrMaterial.emissiveMapEnabled) {
563
+ vec3 emissive = SRGBtoLINEAR(texture(pbr_emissiveSampler, pbr_vUV)).rgb * pbrMaterial.emissiveFactor;
564
+ color += emissive;
565
+ }
566
+ #endif
567
+
568
+ // This section uses mix to override final color for reference app visualization
569
+ // of various parameters in the lighting equation.
346
570
  #ifdef PBR_DEBUG
347
- color = mix(color, baseColor.rgb, u_ScaleDiffBaseMR.y);
348
- color = mix(color, vec3(metallic), u_ScaleDiffBaseMR.z);
349
- color = mix(color, vec3(perceptualRoughness), u_ScaleDiffBaseMR.w);
350
- #endif
351
- }
352
- return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
571
+ // TODO: Figure out how to debug multiple lights
572
+
573
+ // color = mix(color, F, pbr_scaleFGDSpec.x);
574
+ // color = mix(color, vec3(G), pbr_scaleFGDSpec.y);
575
+ // color = mix(color, vec3(D), pbr_scaleFGDSpec.z);
576
+ // color = mix(color, specContrib, pbr_scaleFGDSpec.w);
577
+
578
+ // color = mix(color, diffuseContrib, pbr_scaleDiffBaseMR.x);
579
+ color = mix(color, baseColor.rgb, pbrMaterial.scaleDiffBaseMR.y);
580
+ color = mix(color, vec3(metallic), pbrMaterial.scaleDiffBaseMR.z);
581
+ color = mix(color, vec3(perceptualRoughness), pbrMaterial.scaleDiffBaseMR.w);
582
+ #endif
583
+
584
+ }
585
+
586
+ return vec4(pow(color,vec3(1.0/2.2)), baseColor.a);
353
587
  }
354
- `;var Ia={name:"pbr",vs:qh,fs:jh,defines:{LIGHTING_FRAGMENT:1},dependencies:[Jh]};var Yh=N(xa(),1),Kh=N(Ds(),1);var Xh=`#version 300 es
588
+ `;var Dd=`uniform pbrProjectionUniforms {
589
+ mat4 modelViewProjectionMatrix;
590
+ mat4 modelMatrix;
591
+ mat4 normalMatrix;
592
+ vec3 camera;
593
+ } pbrProjection;
594
+ `,Ud={name:"pbrProjection",vs:Dd,fs:Dd,getUniforms:e=>e,uniformTypes:{modelViewProjectionMatrix:"mat4x4<f32>",modelMatrix:"mat4x4<f32>",normalMatrix:"mat4x4<f32>",camera:"vec3<i32>"}};var jh={props:{},uniforms:{},name:"pbrMaterial",dependencies:[Hs,Ud],vs:Fd,fs:vd,defines:{LIGHTING_FRAGMENT:1},getUniforms:e=>e,uniformTypes:{unlit:"i32",baseColorMapEnabled:"i32",baseColorFactor:"vec4<f32>",normalMapEnabled:"i32",normalScale:"f32",emissiveMapEnabled:"i32",emissiveFactor:"vec3<f32>",metallicRoughnessValues:"vec2<f32>",metallicRoughnessMapEnabled:"i32",occlusionMapEnabled:"i32",occlusionStrength:"f32",alphaCutoffEnabled:"i32",alphaCutoff:"f32",IBLenabled:"i32",scaleIBLAmbient:"vec2<f32>",scaleDiffBaseMR:"vec4<f32>",scaleFGDSpec:"vec4<f32>"}};var qd=D(Uh(),1),Hd=D(lo(),1);var Gd=`uniform meshUniforms {
595
+ bool pickFeatureIds;
596
+ } mesh;
597
+ `,zd={name:"mesh",vs:Gd,fs:Gd,uniformTypes:{pickFeatureIds:"f32"}};var kd=`#version 300 es
355
598
  #define SHADER_NAME simple-mesh-layer-vs
356
- uniform float sizeScale;
357
- uniform bool composeModelMatrix;
358
- uniform bool pickFeatureIds;
359
599
  in vec3 positions;
360
600
  in vec3 normals;
361
601
  in vec3 colors;
@@ -382,16 +622,16 @@ return uv;
382
622
  void main(void) {
383
623
  vec2 uv = applyUVRegion(texCoords);
384
624
  geometry.uv = uv;
385
- if (pickFeatureIds) {
625
+ if (mesh.pickFeatureIds) {
386
626
  geometry.pickingColor = featureIdsPickingColors;
387
627
  } else {
388
628
  geometry.pickingColor = instancePickingColors;
389
629
  }
390
630
  mat3 instanceModelMatrix = mat3(instanceModelMatrixCol0, instanceModelMatrixCol1, instanceModelMatrixCol2);
391
631
  vTexCoord = uv;
392
- cameraPosition = project_uCameraPosition;
632
+ cameraPosition = project.cameraPosition;
393
633
  vColor = vec4(colors * instanceColors.rgb, instanceColors.a);
394
- vec3 pos = (instanceModelMatrix * positions) * sizeScale;
634
+ vec3 pos = (instanceModelMatrix * positions) * simpleMesh.sizeScale;
395
635
  vec3 projectedPosition = project_position(positions);
396
636
  position_commonspace = vec4(projectedPosition, 1.0);
397
637
  gl_Position = project_common_position_to_clipspace(position_commonspace);
@@ -399,7 +639,7 @@ geometry.position = position_commonspace;
399
639
  normals_commonspace = project_normal(instanceModelMatrix * normals);
400
640
  geometry.normal = normals_commonspace;
401
641
  DECKGL_FILTER_GL_POSITION(gl_Position, geometry);
402
- #ifdef MODULE_PBR
642
+ #ifdef MODULE_PBRMATERIAL
403
643
  pbr_vPosition = geometry.position.xyz;
404
644
  #ifdef HAS_NORMALS
405
645
  pbr_vNormal = geometry.normal;
@@ -413,13 +653,10 @@ geometry.uv = pbr_vUV;
413
653
  #endif
414
654
  DECKGL_FILTER_COLOR(vColor, geometry);
415
655
  }
416
- `;var Wh=`#version 300 es
656
+ `;var Vd=`#version 300 es
417
657
  #define SHADER_NAME simple-mesh-layer-fs
418
658
  precision highp float;
419
- uniform bool hasTexture;
420
659
  uniform sampler2D sampler;
421
- uniform bool flatShading;
422
- uniform float opacity;
423
660
  in vec2 vTexCoord;
424
661
  in vec3 cameraPosition;
425
662
  in vec3 normals_commonspace;
@@ -427,24 +664,57 @@ in vec4 position_commonspace;
427
664
  in vec4 vColor;
428
665
  out vec4 fragColor;
429
666
  void main(void) {
430
- #ifdef MODULE_PBR
667
+ #ifdef MODULE_PBRMATERIAL
431
668
  fragColor = vColor * pbr_filterColor(vec4(0));
432
669
  geometry.uv = pbr_vUV;
433
- fragColor.a *= opacity;
670
+ fragColor.a *= layer.opacity;
434
671
  #else
435
672
  geometry.uv = vTexCoord;
436
673
  vec3 normal;
437
- if (flatShading) {
674
+ if (simpleMesh.flatShading) {
438
675
  normal = normalize(cross(dFdx(position_commonspace.xyz), dFdy(position_commonspace.xyz)));
439
676
  } else {
440
677
  normal = normals_commonspace;
441
678
  }
442
- vec4 color = hasTexture ? texture(sampler, vTexCoord) : vColor;
679
+ vec4 color = simpleMesh.hasTexture ? texture(sampler, vTexCoord) : vColor;
443
680
  vec3 lightColor = lighting_getLightColor(color.rgb, cameraPosition, position_commonspace.xyz, normal);
444
- fragColor = vec4(lightColor, color.a * opacity);
681
+ fragColor = vec4(lightColor, color.a * layer.opacity);
445
682
  #endif
446
683
  DECKGL_FILTER_COLOR(fragColor, geometry);
447
684
  }
448
- `;function lT(e){let t=e.positions||e.POSITION,r=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(r*4).fill(255),normalized:!0})}var uT={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},Sn=class extends Kh.SimpleMeshLayer{getShaders(){let t=super.getShaders();return t.modules.push(Ia),{...t,vs:Xh,fs:Wh}}initializeState(){let{featureIds:t}=this.props;super.initializeState();let r=this.getAttributeManager();t&&r.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);let{props:r,oldProps:n}=t;r.pbrMaterial!==n.pbrMaterial&&this.updatePbrMaterialUniforms(r.pbrMaterial)}draw(t){let{featureIds:r}=this.props;this.state.model&&(this.state.model.setUniforms({u_Camera:this.state.model.uniforms.project_uCameraPosition,pickFeatureIds:Boolean(r)}),super.draw(t))}getModel(t){let{id:r,pbrMaterial:n}=this.props,s=this.parseMaterial(n,t);this.setState({parsedPBRMaterial:s});let o=this.getShaders();return lT(t.attributes),new Yh.Model(this.context.device,{...this.getShaders(),id:r,geometry:t,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...o.defines,...s?.defines,HAS_UV_REGIONS:t.attributes.uvRegions?1:0},parameters:s?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){let{model:r}=this.state;if(r){let{mesh:n}=this.props,s=this.parseMaterial(t,n);this.setState({parsedPBRMaterial:s}),r.setBindings(s.bindings),r.setUniforms(s.uniforms)}}parseMaterial(t,r){let n=Boolean(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return ya(this.context.device,{unlit:n,...t},{NORMAL:r.attributes.normals,TEXCOORD_0:r.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){let r=this.props.featureIds,n=new Uint8ClampedArray(r.length*t.size),s=[];for(let o=0;o<r.length;o++)this.encodePickingColor(r[o],s),n[o*3]=s[0],n[o*3+1]=s[1],n[o*3+2]=s[2];t.value=n}finalizeState(t){super.finalizeState(t),this.state.parsedPBRMaterial?.generatedTextures.forEach(r=>r.destroy()),this.setState({parsedPBRMaterial:null})}};Sn.layerName="MeshLayer";Sn.defaultProps=uT;var Qh=Sn;var im=N(yr(),1);var oe=6356752314245179e-9,fT={radii:[6378137,6378137,oe],radiiSquared:[6378137*6378137,6378137*6378137,oe*oe],oneOverRadii:[1/6378137,1/6378137,1/oe],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(oe*oe)],maximumRadius:Math.max(6378137,6378137,oe),centerToleranceSquared:.1};function Vs(e){return e}var Q3=new x;function hT(e,t=[],r=Vs){return"longitude"in e?(t[0]=r(e.longitude),t[1]=r(e.latitude),t[2]=e.height):"x"in e?(t[0]=r(e.x),t[1]=r(e.y),t[2]=e.z):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function $h(e,t=[]){return hT(e,t,Y._cartographicRadians?Vs:Ci)}function dT(e,t,r=Vs){return"longitude"in t?(t.longitude=r(e[0]),t.latitude=r(e[1]),t.height=e[2]):"x"in t?(t.x=r(e[0]),t.y=r(e[1]),t.z=e[2]):(t[0]=r(e[0]),t[1]=r(e[1]),t[2]=e[2]),t}function td(e,t){return dT(e,t,Y._cartographicRadians?Vs:Si)}var ed=1e-14,pT=new x,rd={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},wa={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},bn={east:new x,north:new x,up:new x,west:new x,south:new x,down:new x},mT=new x,gT=new x,AT=new x;function La(e,t,r,n,s,o){let i=rd[t]&&rd[t][r];at(i&&(!n||n===i));let a,c,l,u=pT.copy(s);if(mt(u.x,0,ed)&&mt(u.y,0,ed)){let h=Math.sign(u.z);a=mT.fromArray(wa[t]),t!=="east"&&t!=="west"&&a.scale(h),c=gT.fromArray(wa[r]),r!=="east"&&r!=="west"&&c.scale(h),l=AT.fromArray(wa[n]),n!=="east"&&n!=="west"&&l.scale(h)}else{let{up:h,east:d,north:p}=bn;d.set(-u.y,u.x,0).normalize(),e.geodeticSurfaceNormal(u,h),p.copy(h).cross(d);let{down:A,west:g,south:y}=bn;A.copy(h).scale(-1),g.copy(d).scale(-1),y.copy(p).scale(-1),a=bn[t],c=bn[r],l=bn[n]}return o[0]=a.x,o[1]=a.y,o[2]=a.z,o[3]=0,o[4]=c.x,o[5]=c.y,o[6]=c.z,o[7]=0,o[8]=l.x,o[9]=l.y,o[10]=l.z,o[11]=0,o[12]=u.x,o[13]=u.y,o[14]=u.z,o[15]=1,o}var Tr=new x,xT=new x,yT=new x;function nd(e,t,r=[]){let{oneOverRadii:n,oneOverRadiiSquared:s,centerToleranceSquared:o}=t;Tr.from(e);let i=Tr.x,a=Tr.y,c=Tr.z,l=n.x,u=n.y,f=n.z,h=i*i*l*l,d=a*a*u*u,p=c*c*f*f,A=h+d+p,g=Math.sqrt(1/A);if(!Number.isFinite(g))return;let y=xT;if(y.copy(e).scale(g),A<o)return y.to(r);let E=s.x,_=s.y,B=s.z,S=yT;S.set(y.x*E*2,y.y*_*2,y.z*B*2);let b=(1-g)*Tr.len()/(.5*S.len()),w=0,C,T,m,M;do{b-=w,C=1/(1+b*E),T=1/(1+b*_),m=1/(1+b*B);let F=C*C,R=T*T,L=m*m,D=F*C,X=R*T,H=L*m;M=h*F+d*R+p*L-1;let j=-2*(h*D*E+d*X*_+p*H*B);w=M/j}while(Math.abs(M)>Mt.EPSILON12);return Tr.scale([C,T,m]).to(r)}var Hs=new x,sd=new x,ET=new x,Vt=new x,BT=new x,zs=new x,v=class{constructor(t=0,r=0,n=0){this.centerToleranceSquared=Mt.EPSILON1,at(t>=0),at(r>=0),at(n>=0),this.radii=new x(t,r,n),this.radiiSquared=new x(t*t,r*r,n*n),this.radiiToTheFourth=new x(t*t*t*t,r*r*r*r,n*n*n*n),this.oneOverRadii=new x(t===0?0:1/t,r===0?0:1/r,n===0?0:1/n),this.oneOverRadiiSquared=new x(t===0?0:1/(t*t),r===0?0:1/(r*r),n===0?0:1/(n*n)),this.minimumRadius=Math.min(t,r,n),this.maximumRadius=Math.max(t,r,n),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,r=[0,0,0]){let n=sd,s=ET,[,,o]=t;this.geodeticSurfaceNormalCartographic(t,n),s.copy(this.radiiSquared).scale(n);let i=Math.sqrt(n.dot(s));return s.scale(1/i),n.scale(o),s.add(n),s.to(r)}cartesianToCartographic(t,r=[0,0,0]){zs.from(t);let n=this.scaleToGeodeticSurface(zs,Vt);if(!n)return;let s=this.geodeticSurfaceNormal(n,sd),o=BT;o.copy(zs).subtract(n);let i=Math.atan2(s.y,s.x),a=Math.asin(s.z),c=Math.sign(He.dot(o,zs))*He.length(o);return td([i,a,c],r)}eastNorthUpToFixedFrame(t,r=new P){return La(this,"east","north","up",t,r)}localFrameToFixedFrame(t,r,n,s,o=new P){return La(this,t,r,n,s,o)}geocentricSurfaceNormal(t,r=[0,0,0]){return Hs.from(t).normalize().to(r)}geodeticSurfaceNormalCartographic(t,r=[0,0,0]){let n=$h(t),s=n[0],o=n[1],i=Math.cos(o);return Hs.set(i*Math.cos(s),i*Math.sin(s),Math.sin(o)).normalize(),Hs.to(r)}geodeticSurfaceNormal(t,r=[0,0,0]){return Hs.from(t).scale(this.oneOverRadiiSquared).normalize().to(r)}scaleToGeodeticSurface(t,r){return nd(t,this,r)}scaleToGeocentricSurface(t,r=[0,0,0]){Vt.from(t);let n=Vt.x,s=Vt.y,o=Vt.z,i=this.oneOverRadiiSquared,a=1/Math.sqrt(n*n*i.x+s*s*i.y+o*o*i.z);return Vt.multiplyScalar(a).to(r)}transformPositionToScaledSpace(t,r=[0,0,0]){return Vt.from(t).scale(this.oneOverRadii).to(r)}transformPositionFromScaledSpace(t,r=[0,0,0]){return Vt.from(t).scale(this.radii).to(r)}getSurfaceNormalIntersectionWithZAxis(t,r=0,n=[0,0,0]){at(mt(this.radii.x,this.radii.y,Mt.EPSILON15)),at(this.radii.z>0),Vt.from(t);let s=Vt.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-r))return Vt.set(0,0,s).to(n)}};v.WGS84=new v(6378137,6378137,oe);var ks=class{item;previous;next;constructor(t,r,n){this.item=t,this.previous=r,this.next=n}};var Js=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let r=new ks(t,this.tail,null);return this.tail?(this.tail.next=r,this.tail=r):(this.head=r,this.tail=r),++this._length,r}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,r){t!==r&&(this.remove(r),this._insert(t,r))}_insert(t,r){let n=t.next;t.next=r,this.tail===t?this.tail=r:n.previous=r,r.next=n,r.previous=t,++this._length}};var qs=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Js,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let r=t._cacheNode;r&&this._list.splice(this._sentinel,r)}add(t,r,n){r._cacheNode||(r._cacheNode=this._list.add(r),n&&n(t,r))}unloadTile(t,r,n){let s=r._cacheNode;s&&(this._list.remove(s),r._cacheNode=null,n&&n(t,r))}unloadTiles(t,r){let n=this._trimTiles;this._trimTiles=!1;let s=this._list,o=t.maximumMemoryUsage*1024*1024,i=this._sentinel,a=s.head;for(;a!==i&&(t.gpuMemoryUsageInBytes>o||n);){let c=a.item;a=a.next,this.unloadTile(t,c,r)}}trim(){this._trimTiles=!0}};function od(e,t){G(e),G(t);let{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:s,boundingVolume:{center:o}}=e,i=new P(s);switch(r&&i.translate(r),n){case"Z":break;case"Y":let f=new P().rotateX(Math.PI/2);i=i.multiplyRight(f);break;case"X":let h=new P().rotateY(-Math.PI/2);i=i.multiplyRight(h);break;default:break}t.isQuantized&&i.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let a=new x(o);t.cartesianModelMatrix=i,t.cartesianOrigin=a;let c=v.WGS84.cartesianToCartographic(a,new x),u=v.WGS84.eastNorthUpToFixedFrame(a).invert();t.cartographicModelMatrix=u.multiplyRight(i),t.cartographicOrigin=c,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var id=new x,Fa=new x,Ra=new ot([new ct,new ct,new ct,new ct,new ct,new ct]);function cd(e,t){let{cameraDirection:r,cameraUp:n,height:s}=e,{metersPerUnit:o}=e.distanceScales,i=js(e,e.center),a=v.WGS84.eastNorthUpToFixedFrame(i),c=e.unprojectPosition(e.cameraPosition),l=v.WGS84.cartographicToCartesian(c,new x),u=new x(a.transformAsVector(new x(r).scale(o))).normalize(),f=new x(a.transformAsVector(new x(n).scale(o))).normalize();CT(e);let h=e.constructor,{longitude:d,latitude:p,width:A,bearing:g,zoom:y}=e,E=new h({longitude:d,latitude:p,height:s,width:A,bearing:g,zoom:y,pitch:0});return{camera:{position:l,direction:u,up:f},viewport:e,topDownViewport:E,height:s,cullingVolume:Ra,frameNumber:t,sseDenominator:1.15}}function ld(e,t,r){if(r===0||e.length<=r)return[e,[]];let n=[],{longitude:s,latitude:o}=t.viewport;for(let[l,u]of e.entries()){let[f,h]=u.header.mbs,d=Math.abs(s-f),p=Math.abs(o-h),A=Math.sqrt(p*p+d*d);n.push([l,A])}let i=n.sort((l,u)=>l[1]-u[1]),a=[];for(let l=0;l<r;l++)a.push(e[i[l][0]]);let c=[];for(let l=r;l<i.length;l++)c.push(e[i[l][0]]);return[a,c]}function CT(e){let t=e.getFrustumPlanes(),r=ad(t.near,e.cameraPosition),n=js(e,r),s=js(e,e.cameraPosition,Fa),o=0;Ra.planes[o++].fromPointNormal(n,id.copy(n).subtract(s));for(let i in t){if(i==="near")continue;let a=t[i],c=ad(a,r,Fa),l=js(e,c,Fa);Ra.planes[o++].fromPointNormal(l,id.copy(n).subtract(l))}}function ad(e,t,r=new x){let n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function js(e,t,r=new x){let n=e.unprojectPosition(t);return v.WGS84.cartographicToCartesian(n,r)}var ST=6378137,bT=6378137,Pa=6356752314245179e-9,_r=new x;function ud(e,t){if(e instanceof Ut){let{halfAxes:r}=e,n=MT(r);return Math.log2(Pa/(n+t[2]))}else if(e instanceof It){let{radius:r}=e;return Math.log2(Pa/(r+t[2]))}else if(e.width&&e.height){let{width:r,height:n}=e,s=Math.log2(ST/r),o=Math.log2(bT/n);return(s+o)/2}return 1}function Oa(e,t,r){v.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],_r);let n=Math.sqrt(Math.pow(_r[0]-r[0],2)+Math.pow(_r[1]-r[1],2)+Math.pow(_r[2]-r[2],2));return Math.log2(Pa/(n+t[2]))}function fd(e,t,r){let[n,s,o,i]=e;return Oa({xmin:n,xmax:o,ymin:s,ymax:i,zmin:0,zmax:0},t,r)}function MT(e){e.getColumn(0,_r);let t=e.getColumn(1),r=e.getColumn(2);return _r.add(t).add(r).len()}var Id=N(yr(),1);var gt={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},ft;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(ft||(ft={}));var Lt;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Lt||(Lt={}));var lt;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(lt||(lt={}));var ie;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(ie||(ie={}));var hd={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function gd(e){return e!=null}var ht=new x,Xs=new x,IT=new x,wT=new x,Xe=new x,dd=new x,pd=new x,md=new x;function Ws(e,t,r){if(G(e,"3D Tile: boundingVolume must be defined"),e.box)return xd(e.box,t,r);if(e.region)return FT(e.region);if(e.sphere)return LT(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function Ad(e,t){if(e.box)return RT(t);if(e.region){let[r,n,s,o,i,a]=e.region;return[[Ct(r),Ct(n),i],[Ct(s),Ct(o),a]]}if(e.sphere)return PT(t);throw new Error("Unkown boundingVolume type")}function xd(e,t,r){let n=new x(e[0],e[1],e[2]);t.transform(n,n);let s=[];if(e.length===10){let l=e.slice(3,6),u=new Wt;u.fromArray(e,6);let f=new x([1,0,0]),h=new x([0,1,0]),d=new x([0,0,1]);f.transformByQuaternion(u),f.scale(l[0]),h.transformByQuaternion(u),h.scale(l[1]),d.transformByQuaternion(u),d.scale(l[2]),s=[...f.toArray(),...h.toArray(),...d.toArray()]}else s=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let o=t.transformAsVector(s.slice(0,3)),i=t.transformAsVector(s.slice(3,6)),a=t.transformAsVector(s.slice(6,9)),c=new z([o[0],o[1],o[2],i[0],i[1],i[2],a[0],a[1],a[2]]);return gd(r)?(r.center=n,r.halfAxes=c,r):new Ut(n,c)}function LT(e,t,r){let n=new x(e[0],e[1],e[2]);t.transform(n,n);let s=t.getScale(Xs),o=Math.max(Math.max(s[0],s[1]),s[2]),i=e[3]*o;return gd(r)?(r.center=n,r.radius=i,r):new It(n,i)}function FT(e){let[t,r,n,s,o,i]=e,a=v.WGS84.cartographicToCartesian([Ct(t),Ct(s),o],IT),c=v.WGS84.cartographicToCartesian([Ct(n),Ct(r),i],wT),l=new x().addVectors(a,c).multiplyByScalar(.5);return v.WGS84.cartesianToCartographic(l,Xe),v.WGS84.cartographicToCartesian([Ct(n),Xe[1],Xe[2]],dd),v.WGS84.cartographicToCartesian([Xe[0],Ct(s),Xe[2]],pd),v.WGS84.cartographicToCartesian([Xe[0],Xe[1],i],md),xd([...l,...dd.subtract(l),...pd.subtract(l),...md.subtract(l)],new P)}function RT(e){let t=yd(),{halfAxes:r}=e,n=new x(r.getColumn(0)),s=new x(r.getColumn(1)),o=new x(r.getColumn(2));for(let i=0;i<2;i++){for(let a=0;a<2;a++){for(let c=0;c<2;c++)ht.copy(e.center),ht.add(n),ht.add(s),ht.add(o),Td(t,ht),o.negate();s.negate()}n.negate()}return t}function PT(e){let t=yd(),{center:r,radius:n}=e,s=v.WGS84.scaleToGeodeticSurface(r,ht),o;s?o=v.WGS84.geodeticSurfaceNormal(s):o=new x(0,0,1);let i=new x(o[2],-o[1],0);i.len()>0?i.normalize():i=new x(0,1,0);let a=i.clone().cross(o);for(let c of[i,a,o]){Xs.copy(c).scale(n);for(let l=0;l<2;l++)ht.copy(r),ht.add(Xs),Td(t,ht),Xs.negate()}return t}function yd(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Td(e,t){v.WGS84.cartesianToCartographic(t,ht),e[0][0]=Math.min(e[0][0],ht[0]),e[0][1]=Math.min(e[0][1],ht[1]),e[0][2]=Math.min(e[0][2],ht[2]),e[1][0]=Math.max(e[1][0],ht[0]),e[1][1]=Math.max(e[1][1],ht[1]),e[1][2]=Math.max(e[1][2],ht[2])}var vP=new x,UP=new x,GP=new P,VP=new x,HP=new x,zP=new x;function OT(e,t){let r=e*t;return 1-Math.exp(-(r*r))}function NT(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){let r=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return OT(t,r)*n}return 0}function _d(e,t,r){let n=e.tileset,s=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,o=r?s:e.lodMetricValue;if(o===0)return 0;let i=Math.max(e._distanceToCamera,1e-7),{height:a,sseDenominator:c}=t,{viewDistanceScale:l}=n.options,u=o*a*(l||1)/(i*c);return u-=NT(n,i),u}var Na=new x,Ed=new x,be=new x,Bd=new x,DT=new x,Da=new P,Cd=new P;function Sd(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";let r=2*va(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function va(e,t){let{topDownViewport:r}=t,n=e.header.mbs[1],s=e.header.mbs[0],o=e.header.mbs[2],i=e.header.mbs[3],a=[...e.boundingVolume.center],c=r.unprojectPosition(r.cameraPosition);v.WGS84.cartographicToCartesian(c,Na),Ed.copy(Na).subtract(a).normalize(),v.WGS84.eastNorthUpToFixedFrame(a,Da),Cd.copy(Da).invert(),be.copy(Na).transform(Cd);let l=Math.sqrt(be[0]*be[0]+be[1]*be[1]),u=l*l/be[2];Bd.copy([be[0],be[1],u]);let h=Bd.transform(Da).subtract(a).normalize(),p=Ed.cross(h).normalize().scale(i).add(a),A=v.WGS84.cartesianToCartographic(p),g=r.project([s,n,o]),y=r.project(A);return DT.copy(g).subtract(y).magnitude()}function bd(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}var Mn=class{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return G(t<this._array.length),this._array[t]}set(t,r){G(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=r,this._map.set(r,t)}delete(t){let r=this._map.get(t);r>=0&&(this._array.splice(r,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let r=this.length++;this._array[r]=t,this._map.set(t,r)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){G(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){G(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}};var vT={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Zt=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new Mn;_emptyTraversalStack=new Mn;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...vT,...t}}traverse(t,r,n){this.root=t,this.options={...this.options,...n},this.reset(),this.updateTile(t,r),this._frameNumber=r.frameNumber,this.executeTraversal(t,r)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,r){let n=this._traversalStack;for(t._selectionDepth=1,n.push(t);n.length>0;){let o=n.pop(),i=!1;this.canTraverse(o,r)&&(this.updateChildTiles(o,r),i=this.updateAndPushChildren(o,r,n,o.hasRenderContent?o._selectionDepth+1:o._selectionDepth));let a=o.parent,c=Boolean(!a||a._shouldRefine),l=!i;o.hasRenderContent?o.refine===ft.ADD?(this.loadTile(o,r),this.selectTile(o,r)):o.refine===ft.REPLACE&&(this.loadTile(o,r),l&&this.selectTile(o,r)):(this.emptyTiles[o.id]=o,this.loadTile(o,r),l&&this.selectTile(o,r)),this.touchTile(o,r),o._shouldRefine=i&&c}let s=new Date().getTime();(this.traversalFinished(r)||s-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=s,this.options.onTraversalEnd(r))}updateChildTiles(t,r){let n=t.children;for(let s of n)this.updateTile(s,r)}updateAndPushChildren(t,r,n,s){let{loadSiblings:o,skipLevelOfDetail:i}=this.options,a=t.children;a.sort(this.compareDistanceToCamera.bind(this));let c=t.refine===ft.REPLACE&&t.hasRenderContent&&!i,l=!1,u=!0;for(let f of a)if(f._selectionDepth=s,f.isVisibleAndInRequestVolume?(n.find(f)&&n.delete(f),n.push(f),l=!0):(c||o)&&(this.loadTile(f,r),this.touchTile(f,r)),c){let h;if(f._inRequestVolume?f.hasRenderContent?h=f.contentAvailable:h=this.executeEmptyTraversal(f,r):h=!1,u=u&&h,!u)return!1}return l||(u=!1),u}updateTile(t,r){this.updateTileVisibility(t,r)}selectTile(t,r){this.shouldSelectTile(t)&&(t._selectedFrame=r.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,r){this.shouldLoadTile(t)&&(t._requestedFrame=r.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,r){t.tileset._cache.touch(t),t._touchedFrame=r.frameNumber}canTraverse(t,r,n=!1,s=!1){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:!s&&!t.isVisibleAndInRequestVolume?!1:this.shouldRefine(t,r,n):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,r,n=!1){let s=t._screenSpaceError;return n&&(s=t.getScreenSpaceError(r,!0)),s>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,r){let n=[];if(this.options.viewportTraversersMap)for(let s in this.options.viewportTraversersMap)this.options.viewportTraversersMap[s]===r.viewport.id&&n.push(s);else n.push(r.viewport.id);t.updateVisibility(r,n)}compareDistanceToCamera(t,r){return t._distanceToCamera-r._distanceToCamera}anyChildrenVisible(t,r){let n=!1;for(let s of t.children)s.updateVisibility(r),n=n||s.isVisibleAndInRequestVolume;return n}executeEmptyTraversal(t,r){let n=!0,s=this._emptyTraversalStack;for(s.push(t);s.length>0;){let o=s.pop(),i=!o.hasRenderContent&&this.canTraverse(o,r,!1,!1),a=!o.hasRenderContent&&o.children.length===0;if(!i&&!o.contentAvailable&&!a&&(n=!1),this.updateTile(o,r),o.isVisibleAndInRequestVolume||(this.loadTile(o,r),this.touchTile(o,r)),i){let c=o.children;for(let l of c)s.push(l)}}return n}};var Md=new x;function UT(e){return e!=null}var We=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=gt.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new P;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Zt({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new P;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(t,r,n,s=""){this.header=r,this.tileset=t,this.id=s||r.id,this.url=r.url,this.parent=n,this.refine=this._getRefine(r.refine),this.type=r.type,this.contentUrl=r.contentUrl,this._initializeLodMetric(r),this._initializeTransforms(r),this._initializeBoundingVolumes(r),this._initializeContent(r),this._initializeRenderingState(r),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===gt.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===gt.UNLOADED}get contentExpired(){return this.contentState===gt.EXPIRED}get contentFailed(){return this.contentState===gt.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=Ad(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,r){switch(this.tileset.type){case lt.I3S:return va(this,t);case lt.TILES3D:return _d(this,t,r);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let t=this.tileset._traverser,{skipLevelOfDetail:r}=t.options,n=this.refine===ft.ADD||r;if(n&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===gt.UNLOADED)return-1;let s=this.parent,i=s&&(!n||this._screenSpaceError===0||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,a=t.root?t.root._screenSpaceError:0;return Math.max(a-i,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=gt.LOADING;let r=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!r)return this.contentState=gt.UNLOADED,!1;try{let n=this.tileset.getTileUrl(this.contentUrl),s=this.tileset.loader,o={...this.tileset.loadOptions,[s.id]:{...this.tileset.loadOptions[s.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(s.id)}};return this.content=await(0,Id.load)(n,s,o),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=gt.READY,this._onContentLoaded(),!0}catch(n){throw this.contentState=gt.FAILED,n}finally{r.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=gt.UNLOADED,!0}updateVisibility(t,r){if(this._frameNumber===t.frameNumber)return;let n=this.parent,s=n?n._visibilityPlaneMask:ot.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let o=n?n.computedTransform:this.tileset.modelMatrix;this._updateTransform(o)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,s),this._visible=this._visibilityPlaneMask!==ot.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=r}visibility(t,r){let{cullingVolume:n}=t,{boundingVolume:s}=this;return n.computeVisibilityWithPlaneMask(s,r)}contentVisibility(){return!0}distanceToTile(t){let r=this.boundingVolume;return Math.sqrt(Math.max(r.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let r=this.boundingVolume;return Md.subVectors(r.center,t.position),t.direction.dot(Md)}insideViewerRequestVolume(t){let r=this._viewerRequestVolume;return!r||r.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(UT(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=gt.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new P(t.transform):new P;let r=this.parent,n=this.tileset,s=r&&r.computedTransform?r.computedTransform.clone():n.modelMatrix.clone();this.computedTransform=new P(s).multiplyRight(this.transform);let o=r&&r._initialTransform?r._initialTransform.clone():new P;this._initialTransform=new P(o).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=gt.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=ot.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||ft.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(t){this.boundingVolume=Ws(t.boundingVolume,this.computedTransform,this.boundingVolume);let r=t.content;r&&(r.boundingVolume&&(this._contentBoundingVolume=Ws(r.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=Ws(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new P){let r=t.clone().multiplyRight(this.transform);r.equals(this.computedTransform)||(this.computedTransform=r,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return bd(this.tileset.tileset)}}};var Ys=class extends Zt{compareDistanceToCamera(t,r){return r._distanceToCamera===0&&t._distanceToCamera===0?r._centerZDepth-t._centerZDepth:r._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,r){if(super.updateTileVisibility(t,r),!t.isVisibleAndInRequestVolume)return;let n=t.children.length>0;if(t.hasTilesetContent&&n){let i=t.children[0];this.updateTileVisibility(i,r),t._visible=i._visible;return}if(this.meetsScreenSpaceErrorEarly(t,r)){t._visible=!1;return}let s=t.refine===ft.REPLACE,o=t._optimChildrenWithinParent===hd.USE_OPTIMIZATION;if(s&&o&&n&&!this.anyChildrenVisible(t,r)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,r){let{parent:n}=t;return!n||n.hasTilesetContent||n.refine!==ft.ADD?!1:!this.shouldRefine(t,r,!0)}};var wd=N(yr(),1);var Ks=class{frameNumberMap=new Map;register(t,r){let n=this.frameNumberMap.get(t)||new Map,s=n.get(r)||0;n.set(r,s+1),this.frameNumberMap.set(t,n)}deregister(t,r){let n=this.frameNumberMap.get(t);if(!n)return;let s=n.get(r)||1;n.set(r,s-1)}isZero(t,r){return(this.frameNumberMap.get(t)?.get(r)||0)===0}};var Ua={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},Qs=class{_statusMap;pendingTilesRegister=new Ks;constructor(){this._statusMap={}}add(t,r,n,s){if(!this._statusMap[r]){let{frameNumber:o,viewport:{id:i}}=s;this._statusMap[r]={request:t,callback:n,key:r,frameState:s,status:Ua.REQUESTED},this.pendingTilesRegister.register(i,o),t().then(a=>{this._statusMap[r].status=Ua.COMPLETED;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),this._statusMap[r].callback(a,s)}).catch(a=>{this._statusMap[r].status=Ua.ERROR;let{frameNumber:c,viewport:{id:l}}=this._statusMap[r].frameState;this.pendingTilesRegister.deregister(l,c),n(a)})}}update(t,r){if(this._statusMap[t]){let{frameNumber:n,viewport:{id:s}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(s,n);let{frameNumber:o,viewport:{id:i}}=r;this.pendingTilesRegister.register(i,o),this._statusMap[t].frameState=r}}find(t){return this._statusMap[t]}hasPendingTiles(t,r){return!this.pendingTilesRegister.isZero(t,r)}};var Zs=class extends Zt{_tileManager;constructor(t){super(t),this._tileManager=new Qs}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,r){return t._lodJudge=Sd(t,r),t._lodJudge==="DIG"}updateChildTiles(t,r){let n=t.header.children||[],s=t.children,o=t.tileset;for(let i of n){let a=`${i.id}-${r.viewport.id}`,c=s&&s.find(l=>l.id===a);if(c)c&&this.updateTile(c,r);else{let l=()=>this._loadTile(i.id,o);this._tileManager.find(a)?this._tileManager.update(a,r):(o.tileset.nodePages&&(l=()=>o.tileset.nodePagesTile.formTileFromNodePages(i.id)),this._tileManager.add(l,a,f=>this._onTileLoad(f,t,a),r))}}return!1}async _loadTile(t,r){let{loader:n}=r,s=r.getTileUrl(`${r.url}/nodes/${t}`),o={...r.loadOptions,i3s:{...r.loadOptions.i3s,isTileHeader:!0}};return await(0,wd.load)(s,n,o)}_onTileLoad(t,r,n){let s=new We(r.tileset,t,r,n);r.children.push(s);let o=this._tileManager.find(s.id).frameState;this.updateTile(s,o),this._frameNumber===o.frameNumber&&(this.traversalFinished(o)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(s,o)}};var GT={description:"",ellipsoid:v.WGS84,modelMatrix:new P,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},$s="Tiles In Tileset(s)",Ga="Tiles In Memory",Ld="Tiles In View",Fd="Tiles To Render",Rd="Tiles Loaded",Va="Tiles Loading",Pd="Tiles Unloaded",Od="Failed Tile Loads",Nd="Points/Vertices",Ha="Tile Memory Use",Dd="Maximum Screen Space Error",In=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new qs;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,r){this.options={...GT,...r},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||me.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new pe({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new de({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let n=t;return this.queryParams.length&&(n=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),n}hasExtension(t){return Boolean(this._extensionsUsed.indexOf(t)>-1)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(r=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),r(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let r=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=r.length;let n=[];for(let s of r){let o=s.id;this._needTraverse(o)?n.push(o):this.traverseCounter--}for(let s of r){let o=s.id;if(this.roots[o]||(this.roots[o]=this._initializeTileHeaders(this.tileset,null)),!n.includes(o))continue;let i=cd(s,this._frameNumber);this._traverser.traverse(this.roots[o],i,this.options)}}_needTraverse(t){let r=t;return this.options.viewportTraversersMap&&(r=this.options.viewportTraversersMap[t]),r===t}_onTraversalEnd(t){let r=t.viewport.id;this.frameStateData[r]||(this.frameStateData[r]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let n=this.frameStateData[r],s=Object.values(this._traverser.selectedTiles),[o,i]=ld(s,t,this.options.maximumTilesSelected);n.selectedTiles=o;for(let a of i)a.unselect();n._requestedTiles=Object.values(this._traverser.requestedTiles),n._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let t in this.frameStateData){let r=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(r.selectedTiles),this._requestedTiles=this._requestedTiles.concat(r._requestedTiles),this._emptyTiles=this._emptyTiles.concat(r._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,r){if(t.length!==r.length)return!0;let n=new Set(t.map(i=>i.id)),s=new Set(r.map(i=>i.id)),o=t.filter(i=>!s.has(i.id)).length>0;return o=o||r.filter(i=>!n.has(i.id)).length>0,o}_loadTiles(){for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,r)=>t._unloadTile(r))}_updateStats(){let t=0,r=0;for(let n of this.selectedTiles)n.contentAvailable&&n.content&&(t++,n.content.pointCount?r+=n.content.pointCount:r+=n.content.vertexCount);this.stats.get(Ld).count=this.selectedTiles.length,this.stats.get(Fd).count=t,this.stats.get(Nd).count=r,this.stats.get(Dd).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===lt.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===lt.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===lt.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let t=this.tileset.fullExtent;if(t){let{xmin:n,xmax:s,ymin:o,ymax:i,zmin:a,zmax:c}=t;this.cartographicCenter=new x(n+(s-n)/2,o+(i-o)/2,a+(c-a)/2),this.cartesianCenter=new x,v.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=Oa(t,this.cartographicCenter,this.cartesianCenter);return}let r=this.tileset.store?.extent;if(r){let[n,s,o,i]=r;this.cartographicCenter=new x(n+(o-n)/2,s+(i-s)/2,0),this.cartesianCenter=new x,v.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=fd(r,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new x,this.zoom=1}calculateViewPropsTiles3D(){let t=this.root,{center:r}=t.boundingVolume;if(!r){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new x,this.zoom=1;return}r[0]!==0||r[1]!==0||r[2]!==0?(this.cartographicCenter=new x,v.WGS84.cartesianToCartographic(r,this.cartographicCenter)):this.cartographicCenter=new x(0,0,-v.WGS84.radii[0]),this.cartesianCenter=r,this.zoom=ud(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get($s),this.stats.get(Va),this.stats.get(Ga),this.stats.get(Ld),this.stats.get(Fd),this.stats.get(Rd),this.stats.get(Pd),this.stats.get(Od),this.stats.get(Nd),this.stats.get(Ha,"memory"),this.stats.get(Dd)}_initializeTileHeaders(t,r){let n=new We(this,t.root,r);if(r&&(r.children.push(n),n.depth=r.depth+1),this.type===lt.TILES3D){let s=[];for(s.push(n);s.length>0;){let o=s.pop();this.stats.get($s).incrementCount();let i=o.header.children||[];for(let a of i){let c=new We(this,a,o);if(c.contentUrl?.includes("?session=")){let u=new URL(c.contentUrl).searchParams.get("session");u&&(this._queryParams.session=u)}o.children.push(c),c.depth=o.depth+1,s.push(c)}}}return n}_initializeTraverser(){let t;switch(this.type){case lt.TILES3D:t=Ys;break;case lt.I3S:t=Zs;break;default:t=Zt}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let r;try{this._onStartTileLoading(),r=await t.loadContent()}catch(n){this._onTileLoadError(t,n instanceof Error?n:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,r)}}_onTileLoadError(t,r){this.stats.get(Od).incrementCount();let n=r.message||r.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${n}`),this.options.onTileError(t,n,s)}_onTileLoad(t,r){if(r){if(this.type===lt.I3S){let n=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get($s).reset(),this.stats.get($s).addCount(n)}t&&t.content&&od(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===lt.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===lt.TILES3D){let{extensionsRemoved:r=[]}=t.content?.gltf||{};r.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),r.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),r.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(Va).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(Va).decrementCount()}_addTileToCache(t){this._cache.add(this,t,r=>r._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(Rd).incrementCount(),this.stats.get(Ga).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(Ha).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(Ga).decrementCount(),this.stats.get(Pd).incrementCount(),this.stats.get(Ha).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let r=t.pop();for(let n of r.children)t.push(n);this._destroyTile(r)}this.root=null}_destroySubtree(t){let r=t,n=[];for(n.push(r);n.length>0;){t=n.pop();for(let s of t.children)n.push(s);t!==r&&this._destroyTile(t)}r.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){let r=new URLSearchParams(t.queryString),n=Object.fromEntries(r.entries());this._queryParams={...this._queryParams,...n}}if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};var to="4.2.0-beta.2";var Ye={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},vO=Object.keys(Ye);function za(e,t,r){G(e instanceof ArrayBuffer);let n=new TextDecoder("utf8"),s=new Uint8Array(e,t,r);return n.decode(s)}function vd(e,t=0){let r=new DataView(e);return`${String.fromCharCode(r.getUint8(t+0))}${String.fromCharCode(r.getUint8(t+1))}${String.fromCharCode(r.getUint8(t+2))}${String.fromCharCode(r.getUint8(t+3))}`}var Ud="4.2.0-beta.2";var Gd={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:Ud,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function Vd(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function Ke(e){let t=1/0,r=1/0,n=1/0,s=-1/0,o=-1/0,i=-1/0,a=e.POSITION?e.POSITION.value:[],c=a&&a.length;for(let l=0;l<c;l+=3){let u=a[l],f=a[l+1],h=a[l+2];t=u<t?u:t,r=f<r?f:r,n=h<n?h:n,s=u>s?u:s,o=f>o?f:o,i=h>i?h:i}return[[t,r,n],[s,o,i]]}function ka(e,t,r){let n=Vd(t.value),s=r||Hd(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:n}]},nullable:!1,metadata:s}}function Hd(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}function kd(e,t,r){let n=Jd(t.metadata),s=[],o=VT(t.attributes);for(let i in e){let a=e[i],c=zd(i,a,o[i]);s.push(c)}if(r){let i=zd("indices",r);s.push(i)}return{fields:s,metadata:n}}function VT(e){let t={};for(let r in e){let n=e[r];t[n.name||"undefined"]=n}return t}function zd(e,t,r){let n=r?Jd(r.metadata):void 0;return ka(e,t,n)}function Jd(e){Object.entries(e);let t={};for(let r in e)t[`${r}.string`]=JSON.stringify(e[r]);return t}var qd={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},HT={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},zT=4,wn=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,r={}){let n=new this.draco.DecoderBuffer;n.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(r);let s=this.decoder.GetEncodedGeometryType(n),o=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let i;switch(s){case this.draco.TRIANGULAR_MESH:i=this.decoder.DecodeBufferToMesh(n,o);break;case this.draco.POINT_CLOUD:i=this.decoder.DecodeBufferToPointCloud(n,o);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!i.ok()||!o.ptr){let h=`DRACO decompression failed: ${i.error_msg()}`;throw new Error(h)}let a=this._getDracoLoaderData(o,s,r),c=this._getMeshData(o,a,r),l=Ke(c.attributes),u=kd(c.attributes,a,c.indices);return{loader:"draco",loaderData:a,header:{vertexCount:o.num_points(),boundingBox:l},...c,schema:u}}finally{this.draco.destroy(n),o&&this.draco.destroy(o)}}_getDracoLoaderData(t,r,n){let s=this._getTopLevelMetadata(t),o=this._getDracoAttributes(t,n);return{geometry_type:r,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:s,attributes:o}}_getDracoAttributes(t,r){let n={};for(let s=0;s<t.num_attributes();s++){let o=this.decoder.GetAttribute(t,s),i=this._getAttributeMetadata(t,s);n[o.unique_id()]={unique_id:o.unique_id(),attribute_type:o.attribute_type(),data_type:o.data_type(),num_components:o.num_components(),byte_offset:o.byte_offset(),byte_stride:o.byte_stride(),normalized:o.normalized(),attribute_index:s,metadata:i};let a=this._getQuantizationTransform(o,r);a&&(n[o.unique_id()].quantization_transform=a);let c=this._getOctahedronTransform(o,r);c&&(n[o.unique_id()].octahedron_transform=c)}return n}_getMeshData(t,r,n){let s=this._getMeshAttributes(r,t,n);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(n.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(t,r,n){let s={};for(let o of Object.values(t.attributes)){let i=this._deduceAttributeName(o,n);o.name=i;let a=this._getAttributeValues(r,o);if(a){let{value:c,size:l}=a;s[i]={value:c,size:l,byteOffset:o.byte_offset,byteStride:o.byte_stride,normalized:o.normalized}}}return s}_getTriangleListIndices(t){let n=t.num_faces()*3,s=n*zT,o=this.draco._malloc(s);try{return this.decoder.GetTrianglesUInt32Array(t,s,o),new Uint32Array(this.draco.HEAPF32.buffer,o,n).slice()}finally{this.draco._free(o)}}_getTriangleStripIndices(t){let r=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,r),qT(r)}finally{this.draco.destroy(r)}}_getAttributeValues(t,r){let n=HT[r.data_type];if(!n)return console.warn(`DRACO: Unsupported attribute type ${r.data_type}`),null;let s=r.num_components,i=t.num_points()*s,a=i*n.BYTES_PER_ELEMENT,c=kT(this.draco,n),l,u=this.draco._malloc(a);try{let f=this.decoder.GetAttribute(t,r.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,f,c,a,u),l=new n(this.draco.HEAPF32.buffer,u,i).slice()}finally{this.draco._free(u)}return{value:l,size:s}}_deduceAttributeName(t,r){let n=t.unique_id;for(let[i,a]of Object.entries(r.extraAttributes||{}))if(a===n)return i;let s=t.attribute_type;for(let i in qd)if(this.draco[i]===s)return qd[i];let o=r.attributeNameEntry||"name";return t.metadata[o]?t.metadata[o].string:`CUSTOM_ATTRIBUTE_${n}`}_getTopLevelMetadata(t){let r=this.decoder.GetMetadata(t);return this._getDracoMetadata(r)}_getAttributeMetadata(t,r){let n=this.decoder.GetAttributeMetadata(t,r);return this._getDracoMetadata(n)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let r={},n=this.metadataQuerier.NumEntries(t);for(let s=0;s<n;s++){let o=this.metadataQuerier.GetEntryName(t,s);r[o]=this._getDracoMetadataField(t,o)}return r}_getDracoMetadataField(t,r){let n=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,r,n);let s=JT(n);return{int:this.metadataQuerier.GetIntEntry(t,r),string:this.metadataQuerier.GetStringEntry(t,r),double:this.metadataQuerier.GetDoubleEntry(t,r),intArray:s}}finally{this.draco.destroy(n)}}_disableAttributeTransforms(t){let{quantizedAttributes:r=[],octahedronAttributes:n=[]}=t,s=[...r,...n];for(let o of s)this.decoder.SkipAttributeTransform(this.draco[o])}_getQuantizationTransform(t,r){let{quantizedAttributes:n=[]}=r,s=t.attribute_type();if(n.map(i=>this.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits(),range:i.range(),min_values:new Float32Array([1,2,3]).map(a=>i.min_value(a))}}finally{this.draco.destroy(i)}}return null}_getOctahedronTransform(t,r){let{octahedronAttributes:n=[]}=r,s=t.attribute_type();if(n.map(i=>this.decoder[i]).includes(s)){let i=new this.draco.AttributeQuantizationTransform;try{if(i.InitFromAttribute(t))return{quantization_bits:i.quantization_bits()}}finally{this.draco.destroy(i)}}return null}};function kT(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}function JT(e){let t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}function qT(e){let t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}var jT="1.5.6",XT="1.4.1",Ja=`https://www.gstatic.com/draco/versioned/decoders/${jT}`,yt={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},qa={[yt.DECODER]:`${Ja}/${yt.DECODER}`,[yt.DECODER_WASM]:`${Ja}/${yt.DECODER_WASM}`,[yt.FALLBACK_DECODER]:`${Ja}/${yt.FALLBACK_DECODER}`,[yt.ENCODER]:`https://raw.githubusercontent.com/google/draco/${XT}/javascript/${yt.ENCODER}`},ja;async function jd(e){let t=e.modules||{};return t.draco3d?ja||=t.draco3d.createDecoderModule({}).then(r=>({draco:r})):ja||=WT(e),await ja}async function WT(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await jt(qa[yt.FALLBACK_DECODER],"draco",e,yt.FALLBACK_DECODER);break;case"wasm":default:[t,r]=await Promise.all([await jt(qa[yt.DECODER],"draco",e,yt.DECODER),await jt(qa[yt.DECODER_WASM],"draco",e,yt.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await YT(t,r)}function YT(e,t){let r={};return t&&(r.wasmBinary=t),new Promise(n=>{e({...r,onModuleLoaded:s=>n({draco:s})})})}var eo={...Gd,parse:KT};async function KT(e,t){let{draco:r}=await jd(t),n=new wn(r);try{return n.parseSync(e,t?.draco)}finally{n.destroy()}}var QT={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},nt={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},O={...QT,...nt};var Xa={[nt.DOUBLE]:Float64Array,[nt.FLOAT]:Float32Array,[nt.UNSIGNED_SHORT]:Uint16Array,[nt.UNSIGNED_INT]:Uint32Array,[nt.UNSIGNED_BYTE]:Uint8Array,[nt.BYTE]:Int8Array,[nt.SHORT]:Int16Array,[nt.INT]:Int32Array},ZT={DOUBLE:nt.DOUBLE,FLOAT:nt.FLOAT,UNSIGNED_SHORT:nt.UNSIGNED_SHORT,UNSIGNED_INT:nt.UNSIGNED_INT,UNSIGNED_BYTE:nt.UNSIGNED_BYTE,BYTE:nt.BYTE,SHORT:nt.SHORT,INT:nt.INT},Wa="Failed to convert GL type",dt=class{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(let r in Xa)if(Xa[r]===t)return r;throw new Error(Wa)}static fromName(t){let r=ZT[t];if(!r)throw new Error(Wa);return r}static getArrayType(t){switch(t){case nt.UNSIGNED_SHORT_5_6_5:case nt.UNSIGNED_SHORT_4_4_4_4:case nt.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let r=Xa[t];if(!r)throw new Error(Wa);return r}}static getByteSize(t){return dt.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(dt.getArrayType(t))}static createTypedArray(t,r,n=0,s){s===void 0&&(s=(r.byteLength-n)/dt.getByteSize(t));let o=dt.getArrayType(t);return new o(r,n,s)}};function Xd(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}function Ya(e,t=[0,0,0]){let r=e>>11&31,n=e>>5&63,s=e&31;return t[0]=r<<3,t[1]=n<<2,t[2]=s<<3,t}var AN=1/256;var xN=new Ue,yN=new x,TN=new Ue,_N=new Ue,EN=new Uint8Array(1);function Wd(e,t=255){return cs(e,0,t)/t*2-1}function Yd(e){return e<0?-1:1}function Kd(e,t,r,n){if(Xd(n),e<0||e>r||t<0||t>r)throw new Error(`x and y must be unsigned normalized integers between 0 and ${r}`);if(n.x=Wd(e,r),n.y=Wd(t,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){let s=n.x;n.x=(1-Math.abs(n.y))*Yd(s),n.y=(1-Math.abs(s))*Yd(n.y)}return n.normalize()}function Ka(e,t,r){return Kd(e,t,255,r)}var ae=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(t,r){this.json=t,this.buffer=r}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return Boolean(this.json[t])}getGlobalProperty(t,r=O.UNSIGNED_INT,n=1){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?this._getTypedArrayFromBinary(t,r,n,1,s.byteOffset):s}getPropertyArray(t,r,n){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?("componentType"in s&&(r=dt.fromName(s.componentType)),this._getTypedArrayFromBinary(t,r,n,this.featuresLength,s.byteOffset)):this._getTypedArrayFromArray(t,r,s)}getProperty(t,r,n,s,o){let i=this.json[t];if(!i)return i;let a=this.getPropertyArray(t,r,n);if(n===1)return a[s];for(let c=0;c<n;++c)o[c]=a[n*s+c];return o}_getTypedArrayFromBinary(t,r,n,s,o){let i=this._cachedTypedArrays,a=i[t];return a||(a=dt.createTypedArray(r,this.buffer.buffer,this.buffer.byteOffset+o,s*n),i[t]=a),a}_getTypedArrayFromArray(t,r,n){let s=this._cachedTypedArrays,o=s[t];return o||(o=dt.createTypedArray(r,n),s[t]=o),o}};var $T={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},t_={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},e_={SCALAR:(e,t,r)=>{t[r]=e},VEC2:(e,t,r)=>{t[2*r+0]=e[0],t[2*r+1]=e[1]},VEC3:(e,t,r)=>{t[3*r+0]=e[0],t[3*r+1]=e[1],t[3*r+2]=e[2]},VEC4:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT2:(e,t,r)=>{t[4*r+0]=e[0],t[4*r+1]=e[1],t[4*r+2]=e[2],t[4*r+3]=e[3]},MAT3:(e,t,r)=>{t[9*r+0]=e[0],t[9*r+1]=e[1],t[9*r+2]=e[2],t[9*r+3]=e[3],t[9*r+4]=e[4],t[9*r+5]=e[5],t[9*r+6]=e[6],t[9*r+7]=e[7],t[9*r+8]=e[8],t[9*r+9]=e[9]},MAT4:(e,t,r)=>{t[16*r+0]=e[0],t[16*r+1]=e[1],t[16*r+2]=e[2],t[16*r+3]=e[3],t[16*r+4]=e[4],t[16*r+5]=e[5],t[16*r+6]=e[6],t[16*r+7]=e[7],t[16*r+8]=e[8],t[16*r+9]=e[9],t[16*r+10]=e[10],t[16*r+11]=e[11],t[16*r+12]=e[12],t[16*r+13]=e[13],t[16*r+14]=e[14],t[16*r+15]=e[15]}};function Qd(e,t,r,n){let{componentType:s}=e;G(e.componentType);let o=typeof s=="string"?dt.fromName(s):s,i=$T[e.type],a=t_[e.type],c=e_[e.type];return r+=e.byteOffset,{values:dt.createTypedArray(o,t,r,i*n),type:o,size:i,unpacker:a,packer:c}}var $t=e=>e!==void 0;function Zd(e,t,r){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy"),s=t.HIERARCHY;return s&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=s,n=s),n?r_(n,r):null}function r_(e,t){let r,n,s,o=e.instancesLength,i=e.classes,a=e.classIds,c=e.parentCounts,l=e.parentIds,u=o;$t(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,s=getBinaryAccessor(a),a=s.createArrayBufferView(t.buffer,t.byteOffset+a.byteOffset,o));let f;if($t(c))for($t(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,o)),f=new Uint16Array(o),u=0,r=0;r<o;++r)f[r]=u,u+=c[r];$t(l)&&$t(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,s=getBinaryAccessor(l),l=s.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,u));let h=i.length;for(r=0;r<h;++r){let g=i[r].length,y=i[r].instances,E=getBinaryProperties(g,y,t);i[r].instances=combine(E,y)}let d=new Array(h).fill(0),p=new Uint16Array(o);for(r=0;r<o;++r)n=a[r],p[r]=d[n],++d[n];let A={classes:i,classIds:a,classIndexes:p,parentCounts:c,parentIndexes:f,parentIds:l};return o_(A),A}function Er(e,t,r){if(!e)return;let n=e.parentCounts;return e.parentIds?r(e,t):n>0?n_(e,t,r):s_(e,t,r)}function n_(e,t,r){let n=e.classIds,s=e.parentCounts,o=e.parentIds,i=e.parentIndexes,a=n.length,c=scratchVisited;c.length=Math.max(c.length,a);let l=++marker,u=scratchStack;for(u.length=0,u.push(t);u.length>0;){if(t=u.pop(),c[t]===l)continue;c[t]=l;let f=r(e,t);if($t(f))return f;let h=s[t],d=i[t];for(let p=0;p<h;++p){let A=o[d+p];A!==t&&u.push(A)}}return null}function s_(e,t,r){let n=!0;for(;n;){let s=r(e,t);if($t(s))return s;let o=e.parentIds[t];n=o!==t,t=o}throw new Error("traverseHierarchySingleParent")}function o_(e){let t=[],n=e.classIds.length;for(let s=0;s<n;++s)$d(e,s,stack)}function $d(e,t,r){let n=e.parentCounts,s=e.parentIds,o=e.parentIndexes,a=e.classIds.length;if(!$t(s))return;assert(t<a,`Parent index ${t} exceeds the total number of instances: ${a}`),assert(r.indexOf(t)===-1,"Circular dependency detected in the batch table hierarchy."),r.push(t);let c=$t(n)?n[t]:1,l=$t(n)?o[t]:t;for(let u=0;u<c;++u){let f=s[l+u];f!==t&&$d(e,f,r)}r.pop(t)}function Tt(e){return e!=null}var ro=(e,t)=>e,i_={HIERARCHY:!0,extensions:!0,extras:!0},Qe=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(t,r,n,s={}){G(n>=0),this.json=t||{},this.binary=r,this.featureCount=n,this._extensions=this.json?.extensions||{},this._properties={};for(let o in this.json)i_[o]||(this._properties[o]=this.json[o]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Zd(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,r){if(this._checkBatchId(t),G(typeof r=="string",r),this._hierarchy){let n=Er(this._hierarchy,t,(s,o)=>{let i=s.classIds[o];return s.classes[i].name===r});return Tt(n)}return!1}isExactClass(t,r){return G(typeof r=="string",r),this.getExactClassName(t)===r}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){let r=this._hierarchy.classIds[t];return this._hierarchy.classes[r].name}}hasProperty(t,r){return this._checkBatchId(t),G(typeof r=="string",r),Tt(this._properties[r])||this._hasPropertyInHierarchy(t,r)}getPropertyNames(t,r){this._checkBatchId(t),r=Tt(r)?r:[],r.length=0;let n=Object.keys(this._properties);return r.push(...n),this._hierarchy&&this._getPropertyNamesInHierarchy(t,r),r}getProperty(t,r){if(this._checkBatchId(t),G(typeof r=="string",r),this._binaryProperties){let s=this._binaryProperties[r];if(Tt(s))return this._getBinaryProperty(s,t)}let n=this._properties[r];if(Tt(n))return ro(n[t],!0);if(this._hierarchy){let s=this._getHierarchyProperty(t,r);if(Tt(s))return s}}setProperty(t,r,n){let s=this.featureCount;if(this._checkBatchId(t),G(typeof r=="string",r),this._binaryProperties){let i=this._binaryProperties[r];if(i){this._setBinaryProperty(i,t,n);return}}if(this._hierarchy&&this._setHierarchyProperty(this,t,r,n))return;let o=this._properties[r];Tt(o)||(this._properties[r]=new Array(s),o=this._properties[r]),o[t]=ro(n,!0)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,r){return t.unpack(t.typedArray,r)}_setBinaryProperty(t,r,n){t.pack(n,t.typedArray,r)}_initializeBinaryProperties(){let t=null;for(let r in this._properties){let n=this._properties[r],s=this._initializeBinaryProperty(r,n);s&&(t=t||{},t[r]=s)}return t}_initializeBinaryProperty(t,r){if("byteOffset"in r){let n=r;G(this.binary,`Property ${t} requires a batch table binary.`),G(n.type,`Property ${t} requires a type.`);let s=Qd(n,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:s.values,componentCount:s.size,unpack:s.unpacker,pack:s.packer}}return null}_hasPropertyInHierarchy(t,r){if(!this._hierarchy)return!1;let n=Er(this._hierarchy,t,(s,o)=>{let i=s.classIds[o],a=s.classes[i].instances;return Tt(a[r])});return Tt(n)}_getPropertyNamesInHierarchy(t,r){Er(this._hierarchy,t,(n,s)=>{let o=n.classIds[s],i=n.classes[o].instances;for(let a in i)i.hasOwnProperty(a)&&r.indexOf(a)===-1&&r.push(a)})}_getHierarchyProperty(t,r){return Er(this._hierarchy,t,(n,s)=>{let o=n.classIds[s],i=n.classes[o],a=n.classIndexes[s],c=i.instances[r];return Tt(c)?Tt(c.typedArray)?this._getBinaryProperty(c,a):ro(c[a],!0):null})}_setHierarchyProperty(t,r,n,s){let o=Er(this._hierarchy,r,(i,a)=>{let c=i.classIds[a],l=i.classes[c],u=i.classIndexes[a],f=l.instances[n];return Tt(f)?(G(a===r,`Inherited property "${n}" is read-only.`),Tt(f.typedArray)?this._setBinaryProperty(f,u,s):f[u]=ro(s,!0),!0):!1});return Tt(o)}};function Me(e,t,r=0){let n=new DataView(t);if(e.magic=n.getUint32(r,!0),r+=4,e.version=n.getUint32(r,!0),r+=4,e.byteLength=n.getUint32(r,!0),r+=4,e.version!==1)throw new Error(`3D Tile Version ${e.version} not supported`);return r}var Br=4,tp="b3dm tile in legacy format.";function Cr(e,t,r){let n=new DataView(t),s;e.header=e.header||{};let o=n.getUint32(r,!0);r+=Br;let i=n.getUint32(r,!0);r+=Br;let a=n.getUint32(r,!0);r+=Br;let c=n.getUint32(r,!0);return r+=Br,a>=570425344?(r-=Br*2,s=o,a=i,c=0,o=0,i=0,console.warn(tp)):c>=570425344&&(r-=Br,s=a,a=o,c=i,o=0,i=0,console.warn(tp)),e.header.featureTableJsonByteLength=o,e.header.featureTableBinaryByteLength=i,e.header.batchTableJsonByteLength=a,e.header.batchTableBinaryByteLength=c,e.header.batchLength=s,r}function Sr(e,t,r,n){return r=a_(e,t,r,n),r=c_(e,t,r,n),r}function a_(e,t,r,n){let{featureTableJsonByteLength:s,featureTableBinaryByteLength:o,batchLength:i}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:i||0},s&&s>0){let a=za(t,r,s);e.featureTableJson=JSON.parse(a)}return r+=s||0,e.featureTableBinary=new Uint8Array(t,r,o),r+=o||0,r}function c_(e,t,r,n){let{batchTableJsonByteLength:s,batchTableBinaryByteLength:o}=e.header||{};if(s&&s>0){let i=za(t,r,s);e.batchTableJson=JSON.parse(i),r+=s,o&&o>0&&(e.batchTableBinary=new Uint8Array(t,r,o),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=o)}return r}function Qa(e,t,r){if(!t&&(!e||!e.batchIds||!r))return null;let{batchIds:n,isRGB565:s,pointCount:o=0}=e;if(n&&r){let i=new Uint8ClampedArray(o*3);for(let a=0;a<o;a++){let c=n[a],u=r.getProperty(c,"dimensions").map(f=>f*255);i[a*3]=u[0],i[a*3+1]=u[1],i[a*3+2]=u[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}if(t&&s){let i=new Uint8ClampedArray(o*3);for(let a=0;a<o;a++){let c=Ya(t[a]);i[a*3]=c[0],i[a*3+1]=c[1],i[a*3+2]=c[2]}return{type:O.UNSIGNED_BYTE,value:i,size:3,normalized:!0}}return t&&t.length===o*3?{type:O.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:O.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}var ep=new x;function rp(e,t){if(!t)return null;if(e.isOctEncoded16P){let r=new Float32Array((e.pointsLength||0)*3);for(let n=0;n<(e.pointsLength||0);n++)Ka(t[n*2],t[n*2+1],ep),ep.toArray(r,n*3);return{type:O.FLOAT,size:2,value:r}}return{type:O.FLOAT,size:2,value:t}}function np(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,l_(e,t)):{type:O.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}function l_(e,t){let r=new x,n=new Float32Array(e.pointCount*3);for(let s=0;s<e.pointCount;s++)r.set(t[s*3],t[s*3+1],t[s*3+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,s*3);return n}async function sp(e,t,r,n,s){r=Me(e,t,r),r=Cr(e,t,r),r=Sr(e,t,r,n),u_(e);let{featureTable:o,batchTable:i}=f_(e);return await g_(e,o,i,n,s),h_(e,o,n),d_(e,o,i),p_(e,o),r}function u_(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}function f_(e){let t=new ae(e.featureTableJson,e.featureTableBinary),r=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(r))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=r,e.featuresLength=r,e.pointsLength=r,e.pointCount=r,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let n=m_(e,t);return{featureTable:t,batchTable:n}}function h_(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions){if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",O.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){let n=t.getPropertyArray("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=(1<<16)-1,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=np(e,n,r)}}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function d_(e,t,r){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",O.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",O.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",O.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Qa(e,n,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",O.UNSIGNED_BYTE,4))}function p_(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",O.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",O.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=rp(e,r)}}function m_(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",O.UNSIGNED_SHORT,1),e.batchIds)){let n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:s,batchTableBinary:o}=e;r=new Qe(s,o,n)}return r}async function g_(e,t,r,n,s){let o,i,a,c=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];c&&(a=c.properties);let l=t.getExtension("3DTILES_draco_point_compression");if(l){i=l.properties;let f=l.byteOffset,h=l.byteLength;if(!i||!Number.isFinite(f)||!h)throw new Error("Draco properties, byteOffset, and byteLength must be defined");o=(e.featureTableBinary||[]).slice(f,f+h),e.hasPositions=Number.isFinite(i.POSITION),e.hasColors=Number.isFinite(i.RGB)||Number.isFinite(i.RGBA),e.hasNormals=Number.isFinite(i.NORMAL),e.hasBatchIds=Number.isFinite(i.BATCH_ID),e.isTranslucent=Number.isFinite(i.RGBA)}if(!o)return!0;let u={buffer:o,properties:{...i,...a},featureTableProperties:i,batchTableProperties:a,dequantizeInShader:!1};return await A_(e,u,n,s)}async function A_(e,t,r,n){if(!n)return;let s={...r,draco:{...r?.draco,extraAttributes:t.batchTableProperties||{}}};delete s["3d-tiles"];let o=await Et(t.buffer,eo,s,n),i=o.attributes.POSITION&&o.attributes.POSITION.value,a=o.attributes.COLOR_0&&o.attributes.COLOR_0.value,c=o.attributes.NORMAL&&o.attributes.NORMAL.value,l=o.attributes.BATCH_ID&&o.attributes.BATCH_ID.value,u=i&&o.attributes.POSITION.value.quantization,f=c&&o.attributes.NORMAL.value.quantization;if(u){let d=o.POSITION.data.quantization,p=d.range;e.quantizedVolumeScale=new x(p,p,p),e.quantizedVolumeOffset=new x(d.minValues),e.quantizedRange=(1<<d.quantizationBits)-1,e.isQuantizedDraco=!0}f&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);let h={};if(t.batchTableProperties)for(let d of Object.keys(t.batchTableProperties))o.attributes[d]&&o.attributes[d].value&&(h[d.toLowerCase()]=o.attributes[d].value);e.attributes={positions:i,colors:Qa(e,a,void 0),normals:c,batchIds:l,...h}}var Za={};ut(Za,{decode:()=>w_,name:()=>I_});function it(e,t){if(!e)throw new Error(t||"assert failed: gltf")}var no={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},so={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var x_=1.33,op=["SCALAR","VEC2","VEC3","VEC4"],y_=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],T_=new Map(y_),__={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},E_={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},B_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function oo(e){return op[e-1]||op[0]}function br(e){let t=T_.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function Mr(e,t){let r=B_[e.componentType],n=__[e.type],s=E_[e.componentType],o=e.count*n,i=e.count*n*s;it(i>=0&&i<=t.byteLength);let a=so[e.componentType],c=no[e.type];return{ArrayType:r,length:o,byteLength:i,componentByteSize:a,numberOfComponentsInElement:c}}function Ln(e){let{images:t,bufferViews:r}=e;t=t||[],r=r||[];let n=t.map(i=>i.bufferView);r=r.filter(i=>!n.includes(i));let s=r.reduce((i,a)=>i+a.byteLength,0),o=t.reduce((i,a)=>{let{width:c,height:l}=a.image;return i+c*l},0);return s+Math.ceil(4*o*x_)}function ip(e,t,r){let n=e.bufferViews[r];it(n);let s=n.buffer,o=t[s];it(o);let i=(n.byteOffset||0)+o.byteOffset;return new Uint8Array(o.arrayBuffer,i,n.byteLength)}function ap(e,t,r){let n=typeof r=="number"?e.accessors?.[r]:r;if(!n)throw new Error(`No gltf accessor ${JSON.stringify(r)}`);let s=e.bufferViews?.[n.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);let{arrayBuffer:o,byteOffset:i}=t[s.buffer],a=(i||0)+(n.byteOffset||0)+(s.byteOffset||0),{ArrayType:c,length:l,componentByteSize:u,numberOfComponentsInElement:f}=Mr(n,s),h=u*f,d=s.byteStride||h;if(typeof s.byteStride>"u"||s.byteStride===h)return new c(o,a,l);let p=new c(l);for(let A=0;A<n.count;A++){let g=new c(o,a+A*d,f);p.set(g,A*f)}return p}function C_(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var q=class{gltf;sourceBuffers;byteLength;constructor(t){this.gltf={json:t?.json||C_(),buffers:t?.buffers||[],images:t?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(t){return this.json[t]}getExtraData(t){return(this.json.extras||{})[t]}hasExtension(t){let r=this.getUsedExtensions().find(s=>s===t),n=this.getRequiredExtensions().find(s=>s===t);return typeof r=="string"||typeof n=="string"}getExtension(t){let r=this.getUsedExtensions().find(s=>s===t),n=this.json.extensions||{};return r?n[t]:null}getRequiredExtension(t){return this.getRequiredExtensions().find(n=>n===t)?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(t,r){return(t.extensions||{})[r]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,r){if(typeof r=="object")return r;let n=this.json[t]&&this.json[t][r];if(!n)throw new Error(`glTF file error: Could not find ${t}[${r}]`);return n}getTypedArrayForBufferView(t){t=this.getBufferView(t);let r=t.buffer,n=this.gltf.buffers[r];it(n);let s=(t.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,s,t.byteLength)}getTypedArrayForAccessor(t){let r=this.getAccessor(t);return ap(this.gltf.json,this.gltf.buffers,r)}getTypedArrayForImageData(t){t=this.getAccessor(t);let r=this.getBufferView(t.bufferView),s=this.getBuffer(r.buffer).data,o=r.byteOffset||0;return new Uint8Array(s,o,r.byteLength)}addApplicationData(t,r){return this.json[t]=r,this}addExtraData(t,r){return this.json.extras=this.json.extras||{},this.json.extras[t]=r,this}addObjectExtension(t,r,n){return t.extensions=t.extensions||{},t.extensions[r]=n,this.registerUsedExtension(r),this}setObjectExtension(t,r,n){let s=t.extensions||{};s[r]=n}removeObjectExtension(t,r){let n=t?.extensions||{};if(n[r]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let s=this.json.extensionsRemoved;s.includes(r)||s.push(r)}delete n[r]}addExtension(t,r={}){return it(r),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=r,this.registerUsedExtension(t),r}addRequiredExtension(t,r={}){return it(r),this.addExtension(t,r),this.registerRequiredExtension(t),r}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(r=>r===t)||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(r=>r===t)||this.json.extensionsRequired.push(t)}removeExtension(t){if(this.json.extensions?.[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let r=this.json.extensionsRemoved;r.includes(t)||r.push(t)}this.json.extensions&&delete this.json.extensions[t],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t)}setDefaultScene(t){this.json.scene=t}addScene(t){let{nodeIndices:r}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:r}),this.json.scenes.length-1}addNode(t){let{meshIndex:r,matrix:n}=t;this.json.nodes=this.json.nodes||[];let s={mesh:r};return n&&(s.matrix=n),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(t){let{attributes:r,indices:n,material:s,mode:o=4}=t,a={primitives:[{attributes:this._addAttributes(r),mode:o}]};if(n){let c=this._addIndices(n);a.primitives[0].indices=c}return Number.isFinite(s)&&(a.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(t){let n={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(t,r){let n=ve(t),s=r||n?.mimeType,i={bufferView:this.addBufferView(t),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(t,r=0,n=this.byteLength){let s=t.byteLength;it(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);let o={buffer:r,byteOffset:n,byteLength:s};return this.byteLength+=he(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(o),this.json.bufferViews.length-1}addAccessor(t,r){let n={bufferView:t,type:oo(r.size),componentType:r.componentType,count:r.count,max:r.max,min:r.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(t,r={size:3}){let n=this.addBufferView(t),s={min:r.min,max:r.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(t,r.size));let o={size:r.size,componentType:br(t),count:Math.round(t.length/r.size),min:s.min,max:s.max};return this.addAccessor(n,Object.assign(o,r))}addTexture(t){let{imageIndex:r}=t,n={source:r};return this.json.textures=this.json.textures||[],this.json.textures.push(n),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let t=this.byteLength,r=new ArrayBuffer(t),n=new Uint8Array(r),s=0;for(let o of this.sourceBuffers||[])s=ci(o,n,s);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=t:this.json.buffers=[{byteLength:t}],this.gltf.binary=r,this.sourceBuffers=[r]}_removeStringFromArray(t,r){let n=!0;for(;n;){let s=t.indexOf(r);s>-1?t.splice(s,1):n=!1}}_addAttributes(t={}){let r={};for(let n in t){let s=t[n],o=this._getGltfAttributeName(n),i=this.addBinaryBuffer(s.value,s);r[o]=i}return r}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return t}}_getAccessorMinMax(t,r){let n={min:null,max:null};if(t.length<r)return n;n.min=[],n.max=[];let s=t.subarray(0,r);for(let o of s)n.min.push(o),n.max.push(o);for(let o=r;o<t.length;o+=r)for(let i=0;i<r;i++)n.min[0+i]=Math.min(n.min[0+i],t[o+i]),n.max[0+i]=Math.max(n.max[0+i],t[o+i]);return n}};function cp(e){return(e%1+1)%1}var lp={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},S_={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},up={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function Fn(e,t){return up[t]*lp[e]}function Ir(e,t,r,n){if(r!=="UINT8"&&r!=="UINT16"&&r!=="UINT32"&&r!=="UINT64")return null;let s=e.getTypedArrayForBufferView(t),o=wr(s,"SCALAR",r,n+1);return o instanceof BigInt64Array||o instanceof BigUint64Array?null:o}function wr(e,t,r,n=1){let s=lp[t],o=S_[r],i=up[r],a=n*s,c=a*i,l=e.buffer,u=e.byteOffset;return u%i!==0&&(l=new Uint8Array(l).slice(u,u+c).buffer,u=0),new o(l,u,a)}function Lr(e,t,r){let n=`TEXCOORD_${t.texCoord||0}`,s=r.attributes[n],o=e.getTypedArrayForAccessor(s),i=e.gltf.json,a=t.index,c=i.textures?.[a]?.source;if(typeof c<"u"){let l=i.images?.[c]?.mimeType,u=e.gltf.images?.[c];if(u&&typeof u.width<"u"){let f=[];for(let h=0;h<o.length;h+=2){let d=b_(u,l,o,h,t.channels);f.push(d)}return f}}return[]}function io(e,t,r,n,s){if(!r?.length)return;let o=[];for(let u of r){let f=n.findIndex(h=>h===u);f===-1&&(f=n.push(u)-1),o.push(f)}let i=new Uint32Array(o),a=e.gltf.buffers.push({arrayBuffer:i.buffer,byteOffset:i.byteOffset,byteLength:i.byteLength})-1,c=e.addBufferView(i,a,0),l=e.addAccessor(c,{size:1,componentType:br(i),count:i.length});s.attributes[t]=l}function b_(e,t,r,n,s=[0]){let o={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},i=r[n],a=r[n+1],c=1;t&&(t.indexOf("image/jpeg")!==-1||t.indexOf("image/png")!==-1)&&(c=4);let l=M_(i,a,e,c),u=0;for(let f of s){let h=typeof f=="number"?Object.values(o)[f]:o[f],d=l+h.offset,p=$r(e);if(p.data.length<=d)throw new Error(`${p.data.length} <= ${d}`);let A=p.data[d];u|=A<<h.shift}return u}function M_(e,t,r,n=1){let s=r.width,o=cp(e)*(s-1),i=Math.round(o),a=r.height,c=cp(t)*(a-1),l=Math.round(c),u=r.components?r.components:n;return(l*s+i)*u}function ao(e,t,r,n,s){let o=[];for(let i=0;i<t;i++){let a=r[i],c=r[i+1]-r[i];if(c+a>n)break;let l=a/s,u=c/s;o.push(e.slice(l,l+u))}return o}function co(e,t,r){let n=[];for(let s=0;s<t;s++){let o=s*r;n.push(e.slice(o,o+r))}return n}function lo(e,t,r,n){if(r)throw new Error("Not implemented - arrayOffsets for strings is specified");if(n){let s=[],o=new TextDecoder("utf8"),i=0;for(let a=0;a<e;a++){let c=n[a+1]-n[a];if(c+i<=t.length){let l=t.subarray(i,c+i),u=o.decode(l);s.push(u),i+=c}}return s}return[]}var fp="EXT_mesh_features",I_=fp;async function w_(e,t){let r=new q(e);L_(r,t)}function L_(e,t){let r=e.gltf.json;if(r.meshes)for(let n of r.meshes)for(let s of n.primitives)F_(e,s,t)}function F_(e,t,r){if(!r?.gltf?.loadBuffers)return;let s=t.extensions?.[fp]?.featureIds;if(s)for(let o of s){let i;if(typeof o.attribute<"u"){let a=`_FEATURE_ID_${o.attribute}`,c=t.attributes[a];i=e.getTypedArrayForAccessor(c)}else typeof o.texture<"u"&&r?.gltf?.loadImages?i=Lr(e,o.texture,t):i=[];o.data=i}}var ec={};ut(ec,{decode:()=>P_,name:()=>R_});var $a="EXT_structural_metadata",R_=$a;async function P_(e,t){let r=new q(e);O_(r,t)}function O_(e,t){if(!t.gltf?.loadBuffers)return;let r=e.getExtension($a);r&&(t.gltf?.loadImages&&N_(e,r),D_(e,r))}function N_(e,t){let r=t.propertyTextures,n=e.gltf.json;if(r&&n.meshes)for(let s of n.meshes)for(let o of s.primitives)U_(e,r,o,t)}function D_(e,t){let r=t.schema;if(!r)return;let n=r.classes,s=t.propertyTables;if(n&&s)for(let o in n){let i=v_(s,o);i&&V_(e,r,i)}}function v_(e,t){for(let r of e)if(r.class===t)return r;return null}function U_(e,t,r,n){if(!t)return;let o=r.extensions?.[$a]?.propertyTextures;if(o)for(let i of o){let a=t[i];G_(e,a,r,n)}}function G_(e,t,r,n){if(!t.properties)return;n.dataAttributeNames||(n.dataAttributeNames=[]);let s=t.class;for(let o in t.properties){let i=`${s}_${o}`,a=t.properties?.[o];if(!a)continue;a.data||(a.data=[]);let c=a.data,l=Lr(e,a,r);l!==null&&(io(e,i,l,c,r),a.data=c,n.dataAttributeNames.push(i))}}function V_(e,t,r){let n=t.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let o in n.properties){let i=n.properties[o],a=r.properties?.[o];if(a){let c=H_(e,t,i,s,a);a.data=c}}}function H_(e,t,r,n,s){let o=[],i=s.values,a=e.getTypedArrayForBufferView(i),c=z_(e,r,s,n),l=k_(e,s,n);switch(r.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{o=J_(r,n,a,c);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${r.type}`);case"STRING":{o=lo(n,a,c,l);break}case"ENUM":{o=q_(t,r,n,a,c);break}default:throw new Error(`Unknown classProperty type ${r.type}`)}return o}function z_(e,t,r,n){return t.array&&typeof t.count>"u"&&typeof r.arrayOffsets<"u"?Ir(e,r.arrayOffsets,r.arrayOffsetType||"UINT32",n):null}function k_(e,t,r){return typeof t.stringOffsets<"u"?Ir(e,t.stringOffsets,t.stringOffsetType||"UINT32",r):null}function J_(e,t,r,n){let s=e.array,o=e.count,i=Fn(e.type,e.componentType),a=r.byteLength/i,c;return e.componentType?c=wr(r,e.type,e.componentType,a):c=r,s?n?ao(c,t,n,r.length,i):o?co(c,t,o):[]:c}function q_(e,t,r,n,s){let o=t.enumType;if(!o)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let i=e.enums?.[o];if(!i)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${o}`);let a=i.valueType||"UINT16",c=Fn(t.type,a),l=n.byteLength/c,u=wr(n,t.type,a,l);if(u||(u=n),t.array){if(s)return j_({valuesData:u,numberOfElements:r,arrayOffsets:s,valuesDataBytesLength:n.length,elementSize:c,enumEntry:i});let f=t.count;return f?X_(u,r,f,i):[]}return tc(u,0,r,i)}function j_(e){let{valuesData:t,numberOfElements:r,arrayOffsets:n,valuesDataBytesLength:s,elementSize:o,enumEntry:i}=e,a=[];for(let c=0;c<r;c++){let l=n[c],u=n[c+1]-n[c];if(u+l>s)break;let f=l/o,h=u/o,d=tc(t,f,h,i);a.push(d)}return a}function X_(e,t,r,n){let s=[];for(let o=0;o<t;o++){let i=r*o,a=tc(e,i,r,n);s.push(a)}return s}function tc(e,t,r,n){let s=[];for(let o=0;o<r;o++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)s.push("");else{let i=e[t+o],a=W_(n,i);a?s.push(a.name):s.push("")}return s}function W_(e,t){for(let r of e.values)if(r.value===t)return r;return null}var rc={};ut(rc,{decode:()=>K_,name:()=>Y_});var hp="EXT_feature_metadata",Y_=hp;async function K_(e,t){let r=new q(e);Q_(r,t)}function Q_(e,t){if(!t.gltf?.loadBuffers)return;let r=e.getExtension(hp);r&&(t.gltf?.loadImages&&Z_(e,r),$_(e,r))}function Z_(e,t){let r=t.schema;if(!r)return;let n=r.classes,{featureTextures:s}=t;if(n&&s)for(let o in n){let i=n[o],a=eE(s,o);a&&nE(e,a,i)}}function $_(e,t){let r=t.schema;if(!r)return;let n=r.classes,s=t.featureTables;if(n&&s)for(let o in n){let i=tE(s,o);i&&rE(e,r,i)}}function tE(e,t){for(let r in e){let n=e[r];if(n.class===t)return n}return null}function eE(e,t){for(let r in e){let n=e[r];if(n.class===t)return n}return null}function rE(e,t,r){if(!r.class)return;let n=t.classes?.[r.class];if(!n)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${r.class}`);let s=r.count;for(let o in n.properties){let i=n.properties[o],a=r.properties?.[o];if(a){let c=sE(e,t,i,s,a);a.data=c}}}function nE(e,t,r){let n=t.class;for(let s in r.properties){let o=t?.properties?.[s];if(o){let i=lE(e,o,n);o.data=i}}}function sE(e,t,r,n,s){let o=[],i=s.bufferView,a=e.getTypedArrayForBufferView(i),c=oE(e,r,s,n),l=iE(e,r,s,n);return r.type==="STRING"||r.componentType==="STRING"?o=lo(n,a,c,l):aE(r)&&(o=cE(r,n,a,c)),o}function oE(e,t,r,n){return t.type==="ARRAY"&&typeof t.componentCount>"u"&&typeof r.arrayOffsetBufferView<"u"?Ir(e,r.arrayOffsetBufferView,r.offsetType||"UINT32",n):null}function iE(e,t,r,n){return typeof r.stringOffsetBufferView<"u"?Ir(e,r.stringOffsetBufferView,r.offsetType||"UINT32",n):null}function aE(e){let t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||typeof e.componentType<"u"&&t.includes(e.componentType)}function cE(e,t,r,n){let s=e.type==="ARRAY",o=e.componentCount,i="SCALAR",a=e.componentType||e.type,c=Fn(i,a),l=r.byteLength/c,u=wr(r,i,a,l);return s?n?ao(u,t,n,r.length,c):o?co(u,t,o):[]:u}function lE(e,t,r){let n=e.gltf.json;if(!n.meshes)return[];let s=[];for(let o of n.meshes)for(let i of o.primitives)uE(e,r,t,s,i);return s}function uE(e,t,r,n,s){let o={channels:r.channels,...r.texture},i=Lr(e,o,s);i&&io(e,t,i,n,s)}var dp="4.2.0-beta.2";var Fr=!0,pp=1735152710,oc=12,uo=8,fE=1313821514,hE=5130562,dE=0,pE=0,mE=1;function gE(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}function mp(e,t=0,r={}){let n=new DataView(e),{magic:s=pp}=r,o=n.getUint32(t,!1);return o===s||o===pp}function gp(e,t,r=0,n={}){let s=new DataView(t),o=gE(s,r+0),i=s.getUint32(r+4,Fr),a=s.getUint32(r+8,Fr);switch(Object.assign(e,{header:{byteOffset:r,byteLength:a,hasBinChunk:!1},type:o,version:i,json:{},binChunks:[]}),r+=oc,e.version){case 1:return AE(e,s,r);case 2:return xE(e,s,r,n={});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function AE(e,t,r){G(e.header.byteLength>oc+uo);let n=t.getUint32(r+0,Fr),s=t.getUint32(r+4,Fr);return r+=uo,G(s===dE),nc(e,t,r,n),r+=n,r+=sc(e,t,r,e.header.byteLength),r}function xE(e,t,r,n){return G(e.header.byteLength>oc+uo),yE(e,t,r,n),r+e.header.byteLength}function yE(e,t,r,n){for(;r+8<=e.header.byteLength;){let s=t.getUint32(r+0,Fr),o=t.getUint32(r+4,Fr);switch(r+=uo,o){case fE:nc(e,t,r,s);break;case hE:sc(e,t,r,s);break;case pE:n.strict||nc(e,t,r,s);break;case mE:n.strict||sc(e,t,r,s);break;default:break}r+=he(s,4)}return r}function nc(e,t,r,n){let s=new Uint8Array(t.buffer,r,n),i=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(i),he(n,4)}function sc(e,t,r,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:t.buffer}),he(n,4)}function ic(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;let n=t.baseUri||t.uri;if(!n)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return n.substr(0,n.lastIndexOf("/")+1)+e}var cc={};ut(cc,{decode:()=>FE,name:()=>LE});var TE="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",_E="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",EE=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),BE=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),CE={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},SE={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function Ap(e,t,r,n,s,o="NONE"){let i=await bE();wE(i,i.exports[SE[s]],e,t,r,n,i.exports[CE[o||"NONE"]])}var ac;async function bE(){return ac||(ac=ME()),ac}async function ME(){let e=TE;WebAssembly.validate(EE)&&(e=_E,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let t=await WebAssembly.instantiate(IE(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}function IE(e){let t=new Uint8Array(e.length);for(let n=0;n<e.length;++n){let s=e.charCodeAt(n);t[n]=s>96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let r=0;for(let n=0;n<e.length;++n)t[r++]=t[n]<60?BE[t[n]]:(t[n]-60)*64+t[++n];return t.buffer.slice(0,r)}function wE(e,t,r,n,s,o,i){let a=e.exports.sbrk,c=n+3&-4,l=a(c*s),u=a(o.length),f=new Uint8Array(e.exports.memory.buffer);f.set(o,u);let h=t(l,n,s,u,o.length);if(h===0&&i&&i(l,c,s),r.set(f.subarray(l,l+n*s)),a(l-a(0)),h!==0)throw new Error(`Malformed buffer data: ${h}`)}var fo="EXT_meshopt_compression",LE=fo;async function FE(e,t){let r=new q(e);if(!t?.gltf?.decompressMeshes||!t.gltf?.loadBuffers)return;let n=[];for(let s of e.json.bufferViews||[])n.push(RE(r,s));await Promise.all(n),r.removeExtension(fo)}async function RE(e,t){let r=e.getObjectExtension(t,fo);if(r){let{byteOffset:n=0,byteLength:s=0,byteStride:o,count:i,mode:a,filter:c="NONE",buffer:l}=r,u=e.gltf.buffers[l],f=new Uint8Array(u.arrayBuffer,u.byteOffset+n,s),h=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);await Ap(h,i,o,f,a,c),e.removeObjectExtension(t,fo)}}var lc={};ut(lc,{name:()=>PE,preprocess:()=>OE});var Rr="EXT_texture_webp",PE=Rr;function OE(e,t){let r=new q(e);if(!yi("image/webp")){if(r.getRequiredExtensions().includes(Rr))throw new Error(`gltf: Required extension ${Rr} not supported by browser`);return}let{json:n}=r;for(let s of n.textures||[]){let o=r.getObjectExtension(s,Rr);o&&(s.source=o.source),r.removeObjectExtension(s,Rr)}r.removeExtension(Rr)}var uc={};ut(uc,{name:()=>NE,preprocess:()=>DE});var ho="KHR_texture_basisu",NE=ho;function DE(e,t){let r=new q(e),{json:n}=r;for(let s of n.textures||[]){let o=r.getObjectExtension(s,ho);o&&(s.source=o.source,r.removeObjectExtension(s,ho))}r.removeExtension(ho)}var hc={};ut(hc,{decode:()=>HE,encode:()=>zE,name:()=>GE,preprocess:()=>VE});function xp(e){let t={};for(let r in e){let n=e[r];if(r!=="indices"){let s=fc(n);t[r]=s}}return t}function fc(e){let{buffer:t,size:r,count:n}=vE(e);return{value:t,size:r,byteOffset:0,count:n,type:oo(r),componentType:br(t)}}function vE(e){let t=e,r=1,n=0;return e&&e.value&&(t=e.value,r=e.size||1),t&&(ArrayBuffer.isView(t)||(t=UE(t,Float32Array)),n=t.length/r),{buffer:t,size:r,count:n}}function UE(e,t,r=!1){return e?Array.isArray(e)?new t(e):r&&!(e instanceof t)?new t(e):e:null}var Ie="KHR_draco_mesh_compression",GE=Ie;function VE(e,t,r){let n=new q(e);for(let s of yp(n))n.getObjectExtension(s,Ie)}async function HE(e,t,r){if(!t?.gltf?.decompressMeshes)return;let n=new q(e),s=[];for(let o of yp(n))n.getObjectExtension(o,Ie)&&s.push(kE(n,o,t,r));await Promise.all(s),n.removeExtension(Ie)}function zE(e,t={}){let r=new q(e);for(let n of r.json.meshes||[])JE(n,t),r.addRequiredExtension(Ie)}async function kE(e,t,r,n){let s=e.getObjectExtension(t,Ie);if(!s)return;let o=e.getTypedArrayForBufferView(s.bufferView),i=Pe(o.buffer,o.byteOffset),a={...r};delete a["3d-tiles"];let c=await Et(i,eo,a,n),l=xp(c.attributes);for(let[u,f]of Object.entries(l))if(u in t.attributes){let h=t.attributes[u],d=e.getAccessor(h);d?.min&&d?.max&&(f.min=d.min,f.max=d.max)}t.attributes=l,c.indices&&(t.indices=fc(c.indices)),e.removeObjectExtension(t,Ie),qE(t)}function JE(e,t,r=4,n,s){if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let o=n.DracoWriter.encodeSync({attributes:e}),i=s?.parseSync?.({attributes:e}),a=n._addFauxAttributes(i.attributes),c=n.addBufferView(o);return{primitives:[{attributes:a,mode:r,extensions:{[Ie]:{bufferView:c,attributes:a}}}]}}function qE(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*yp(e){for(let t of e.json.meshes||[])for(let r of t.primitives)yield r}var dc={};ut(dc,{decode:()=>YE,name:()=>jE});var mo="KHR_texture_transform",jE=mo,po=new x,XE=new z,WE=new z;async function YE(e,t){if(!new q(e).hasExtension(mo)||!t.gltf?.loadBuffers)return;let s=e.json.materials||[];for(let o=0;o<s.length;o++)KE(o,e)}function KE(e,t){let r=t.json.materials?.[e],n=[r?.pbrMetallicRoughness?.baseColorTexture,r?.emissiveTexture,r?.normalTexture,r?.occlusionTexture,r?.pbrMetallicRoughness?.metallicRoughnessTexture],s=[];for(let o of n)o&&o?.extensions?.[mo]&&QE(t,e,o,s)}function QE(e,t,r,n){let s=ZE(r,n);if(!s)return;let o=e.json.meshes||[];for(let i of o)for(let a of i.primitives){let c=a.material;Number.isFinite(c)&&t===c&&$E(e,a,s)}}function ZE(e,t){let r=e.extensions?.[mo],{texCoord:n=0}=e,{texCoord:s=n}=r;if(!(t.findIndex(([i,a])=>i===n&&a===s)!==-1)){let i=rB(r);return n!==s&&(e.texCoord=s),t.push([n,s]),{originalTexCoord:n,texCoord:s,matrix:i}}return null}function $E(e,t,r){let{originalTexCoord:n,texCoord:s,matrix:o}=r,i=t.attributes[`TEXCOORD_${n}`];if(Number.isFinite(i)){let a=e.json.accessors?.[i];if(a&&a.bufferView){let c=e.json.bufferViews?.[a.bufferView];if(c){let{arrayBuffer:l,byteOffset:u}=e.buffers[c.buffer],f=(u||0)+(a.byteOffset||0)+(c.byteOffset||0),{ArrayType:h,length:d}=Mr(a,c),p=so[a.componentType],A=no[a.type],g=c.byteStride||p*A,y=new Float32Array(d);for(let E=0;E<a.count;E++){let _=new h(l,f+E*g,2);po.set(_[0],_[1],1),po.transformByMatrix3(o),y.set([po[0],po[1]],E*A)}n===s?tB(a,c,e.buffers,y):eB(s,a,t,e,y)}}}}function tB(e,t,r,n){e.componentType=5126,r.push({arrayBuffer:n.buffer,byteOffset:0,byteLength:n.buffer.byteLength}),t.buffer=r.length-1,t.byteLength=n.buffer.byteLength,t.byteOffset=0,delete t.byteStride}function eB(e,t,r,n,s){n.buffers.push({arrayBuffer:s.buffer,byteOffset:0,byteLength:s.buffer.byteLength});let o=n.json.bufferViews;if(!o)return;o.push({buffer:n.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});let i=n.json.accessors;i&&(i.push({bufferView:o?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),r.attributes[`TEXCOORD_${e}`]=i.length-1)}function rB(e){let{offset:t=[0,0],rotation:r=0,scale:n=[1,1]}=e,s=new z().set(1,0,0,0,1,0,t[0],t[1],1),o=XE.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),i=WE.set(n[0],0,0,0,n[1],0,0,0,1);return s.multiplyRight(o).multiplyRight(i)}var pc={};ut(pc,{decode:()=>sB,encode:()=>oB,name:()=>nB});var Ze="KHR_lights_punctual",nB=Ze;async function sB(e){let t=new q(e),{json:r}=t,n=t.getExtension(Ze);n&&(t.json.lights=n.lights,t.removeExtension(Ze));for(let s of r.nodes||[]){let o=t.getObjectExtension(s,Ze);o&&(s.light=o.light),t.removeObjectExtension(s,Ze)}}async function oB(e){let t=new q(e),{json:r}=t;if(r.lights){let n=t.addExtension(Ze);it(!n.lights),n.lights=r.lights,delete r.lights}if(t.json.lights){for(let n of t.json.lights){let s=n.node;t.addObjectExtension(s,Ze,n)}delete t.json.lights}}var mc={};ut(mc,{decode:()=>aB,encode:()=>cB,name:()=>iB});var Rn="KHR_materials_unlit",iB=Rn;async function aB(e){let t=new q(e),{json:r}=t;for(let n of r.materials||[])n.extensions&&n.extensions.KHR_materials_unlit&&(n.unlit=!0),t.removeObjectExtension(n,Rn);t.removeExtension(Rn)}function cB(e){let t=new q(e),{json:r}=t;if(t.materials)for(let n of r.materials||[])n.unlit&&(delete n.unlit,t.addObjectExtension(n,Rn,{}),t.addExtension(Rn))}var gc={};ut(gc,{decode:()=>uB,encode:()=>fB,name:()=>lB});var Pn="KHR_techniques_webgl",lB=Pn;async function uB(e){let t=new q(e),{json:r}=t,n=t.getExtension(Pn);if(n){let s=hB(n,t);for(let o of r.materials||[]){let i=t.getObjectExtension(o,Pn);i&&(o.technique=Object.assign({},i,s[i.technique]),o.technique.values=dB(o.technique,t)),t.removeObjectExtension(o,Pn)}t.removeExtension(Pn)}}async function fB(e,t){}function hB(e,t){let{programs:r=[],shaders:n=[],techniques:s=[]}=e,o=new TextDecoder;return n.forEach(i=>{if(Number.isFinite(i.bufferView))i.code=o.decode(t.getTypedArrayForBufferView(i.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),r.forEach(i=>{i.fragmentShader=n[i.fragmentShader],i.vertexShader=n[i.vertexShader]}),s.forEach(i=>{i.program=r[i.program]}),s}function dB(e,t){let r=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(n=>{e.uniforms[n].value&&!(n in r)&&(r[n]=e.uniforms[n].value)}),Object.keys(r).forEach(n=>{typeof r[n]=="object"&&r[n].index!==void 0&&(r[n].texture=t.getTexture(r[n].index))}),r}var Tp=[ec,Za,cc,lc,uc,hc,pc,mc,gc,dc,rc];function _p(e,t={},r){let n=Tp.filter(s=>Bp(s.name,t));for(let s of n)s.preprocess?.(e,t,r)}async function Ep(e,t={},r){let n=Tp.filter(s=>Bp(s.name,t));for(let s of n)await s.decode?.(e,t,r)}function Bp(e,t){let r=t?.gltf?.excludeExtensions||{};return!(e in r&&!r[e])}var Ac="KHR_binary_glTF";function Cp(e){let t=new q(e),{json:r}=t;for(let n of r.images||[]){let s=t.getObjectExtension(n,Ac);s&&Object.assign(n,s),t.removeObjectExtension(n,Ac)}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension(Ac)}var Sp={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},mB={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},xc=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(t,r){this.json=t.json;let n=t.json;switch(n.asset&&n.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${n.asset.version}`);return}if(!r.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(n),this._convertTopLevelObjectsToArrays(n),Cp(t),this._convertObjectIdsToArrayIndices(n),this._updateObjects(n),this._updateMaterial(n)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(let r in Sp)this._convertTopLevelObjectToArray(t,r)}_convertTopLevelObjectToArray(t,r){let n=t[r];if(!(!n||Array.isArray(n))){t[r]=[];for(let s in n){let o=n[s];o.id=o.id||s;let i=t[r].length;t[r].push(o),this.idToIndexMap[r][s]=i}}}_convertObjectIdsToArrayIndices(t){for(let r in Sp)this._convertIdsToIndices(t,r);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(let r of t.textures)this._convertTextureIds(r);for(let r of t.meshes)this._convertMeshIds(r);for(let r of t.nodes)this._convertNodeIds(r);for(let r of t.scenes)this._convertSceneIds(r)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(let r of t.primitives){let{attributes:n,indices:s,material:o}=r;for(let i in n)n[i]=this._convertIdToIndex(n[i],"accessor");s&&(r.indices=this._convertIdToIndex(s,"accessor")),o&&(r.material=this._convertIdToIndex(o,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map(r=>this._convertIdToIndex(r,"node"))),t.meshes&&(t.meshes=t.meshes.map(r=>this._convertIdToIndex(r,"mesh")))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map(r=>this._convertIdToIndex(r,"node")))}_convertIdsToIndices(t,r){t[r]||(console.warn(`gltf v1: json doesn't contain attribute ${r}`),t[r]=[]);for(let n of t[r])for(let s in n){let o=n[s],i=this._convertIdToIndex(o,s);n[s]=i}}_convertIdToIndex(t,r){let n=mB[r];if(n in this.idToIndexMap){let s=this.idToIndexMap[n][t];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${r} with id ${t}`);return s}return t}_updateObjects(t){for(let r of this.json.buffers)delete r.type}_updateMaterial(t){for(let r of t.materials){r.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let n=r.values?.tex||r.values?.texture2d_0||r.values?.diffuseTex,s=t.textures.findIndex(o=>o.id===n);s!==-1&&(r.pbrMetallicRoughness.baseColorTexture={index:s})}}};function bp(e,t={}){return new xc().normalize(e,t)}async function Mp(e,t,r=0,n,s){return gB(e,t,r,n),bp(e,{normalize:n?.gltf?.normalize}),_p(e,n,s),n?.gltf?.loadBuffers&&e.json.buffers&&await AB(e,n,s),n?.gltf?.loadImages&&await xB(e,n,s),await Ep(e,n,s),e}function gB(e,t,r,n){if(n.uri&&(e.baseUri=n.uri),t instanceof ArrayBuffer&&!mp(t,r,n)&&(t=new TextDecoder().decode(t)),typeof t=="string")e.json=ai(t);else if(t instanceof ArrayBuffer){let i={};r=gp(i,t,r,n.glb),it(i.type==="glTF",`Invalid GLB magic string ${i.type}`),e._glb=i,e.json=i.json}else it(!1,"GLTF: must be ArrayBuffer or string");let s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){let{binChunks:i}=e._glb;e.buffers[0]={arrayBuffer:i[0].arrayBuffer,byteOffset:i[0].byteOffset,byteLength:i[0].byteLength}}let o=e.json.images||[];e.images=new Array(o.length).fill({})}async function AB(e,t,r){let n=e.json.buffers||[];for(let s=0;s<n.length;++s){let o=n[s];if(o.uri){let{fetch:i}=r;it(i);let a=ic(o.uri,t),l=await(await r?.fetch?.(a))?.arrayBuffer?.();e.buffers[s]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete o.uri}else e.buffers[s]===null&&(e.buffers[s]={arrayBuffer:new ArrayBuffer(o.byteLength),byteOffset:0,byteLength:o.byteLength})}}async function xB(e,t,r){let n=yB(e),s=e.json.images||[],o=[];for(let i of n)o.push(TB(e,s[i],i,t,r));return await Promise.all(o)}function yB(e){let t=new Set,r=e.json.textures||[];for(let n of r)n.source!==void 0&&t.add(n.source);return Array.from(t).sort()}async function TB(e,t,r,n,s){let o;if(t.uri&&!t.hasOwnProperty("bufferView")){let a=ic(t.uri,n),{fetch:c}=s;o=await(await c(a)).arrayBuffer(),t.bufferView={data:o}}if(Number.isFinite(t.bufferView)){let a=ip(e.json,e.buffers,t.bufferView);o=Pe(a.buffer,a.byteOffset,a.byteLength)}it(o,"glTF image has no data");let i=await Et(o,[ge,Sa],{...n,mimeType:t.mimeType,basis:n.basis||{format:Gs()}},s);i&&i[0]&&(i={compressed:!0,mipmaps:!1,width:i[0].width,height:i[0].height,data:i[0]}),e.images=e.images||[],e.images[r]=i}var $e={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:dp,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:_B,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};async function _B(e,t={},r){t={...$e.options,...t},t.gltf={...$e.options.gltf,...t.gltf};let{byteOffset:n=0}=t;return await Mp({},e,n,t,r)}var EB={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},BB={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Ft={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},CB={magFilter:Ft.TEXTURE_MAG_FILTER,minFilter:Ft.TEXTURE_MIN_FILTER,wrapS:Ft.TEXTURE_WRAP_S,wrapT:Ft.TEXTURE_WRAP_T},SB={[Ft.TEXTURE_MAG_FILTER]:Ft.LINEAR,[Ft.TEXTURE_MIN_FILTER]:Ft.NEAREST_MIPMAP_LINEAR,[Ft.TEXTURE_WRAP_S]:Ft.REPEAT,[Ft.TEXTURE_WRAP_T]:Ft.REPEAT};function bB(){return{id:"default-sampler",parameters:SB}}function MB(e){return BB[e]}function IB(e){return EB[e]}var yc=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(t,r={}){let{json:n,buffers:s=[],images:o=[]}=t,{baseUri:i=""}=t;return it(n),this.baseUri=i,this.buffers=s,this.images=o,this.jsonUnprocessed=n,this.json=this._resolveTree(t.json,r),this.json}_resolveTree(t,r={}){let n={...t};return this.json=n,t.bufferViews&&(n.bufferViews=t.bufferViews.map((s,o)=>this._resolveBufferView(s,o))),t.images&&(n.images=t.images.map((s,o)=>this._resolveImage(s,o))),t.samplers&&(n.samplers=t.samplers.map((s,o)=>this._resolveSampler(s,o))),t.textures&&(n.textures=t.textures.map((s,o)=>this._resolveTexture(s,o))),t.accessors&&(n.accessors=t.accessors.map((s,o)=>this._resolveAccessor(s,o))),t.materials&&(n.materials=t.materials.map((s,o)=>this._resolveMaterial(s,o))),t.meshes&&(n.meshes=t.meshes.map((s,o)=>this._resolveMesh(s,o))),t.nodes&&(n.nodes=t.nodes.map((s,o)=>this._resolveNode(s,o)),n.nodes=n.nodes.map((s,o)=>this._resolveNodeChildren(s))),t.skins&&(n.skins=t.skins.map((s,o)=>this._resolveSkin(s,o))),t.scenes&&(n.scenes=t.scenes.map((s,o)=>this._resolveScene(s,o))),typeof this.json.scene=="number"&&n.scenes&&(n.scene=n.scenes[this.json.scene]),n}getScene(t){return this._get(this.json.scenes,t)}getNode(t){return this._get(this.json.nodes,t)}getSkin(t){return this._get(this.json.skins,t)}getMesh(t){return this._get(this.json.meshes,t)}getMaterial(t){return this._get(this.json.materials,t)}getAccessor(t){return this._get(this.json.accessors,t)}getCamera(t){return this._get(this.json.cameras,t)}getTexture(t){return this._get(this.json.textures,t)}getSampler(t){return this._get(this.json.samplers,t)}getImage(t){return this._get(this.json.images,t)}getBufferView(t){return this._get(this.json.bufferViews,t)}getBuffer(t){return this._get(this.json.buffers,t)}_get(t,r){if(typeof r=="object")return r;let n=t&&t[r];return n||console.warn(`glTF file error: Could not find ${t}[${r}]`),n}_resolveScene(t,r){return{...t,id:t.id||`scene-${r}`,nodes:(t.nodes||[]).map(n=>this.getNode(n))}}_resolveNode(t,r){let n={...t,id:t?.id||`node-${r}`};return t.mesh!==void 0&&(n.mesh=this.getMesh(t.mesh)),t.camera!==void 0&&(n.camera=this.getCamera(t.camera)),t.skin!==void 0&&(n.skin=this.getSkin(t.skin)),t.meshes!==void 0&&t.meshes.length&&(n.mesh=t.meshes.reduce((s,o)=>{let i=this.getMesh(o);return s.id=i.id,s.primitives=s.primitives.concat(i.primitives),s},{primitives:[]})),n}_resolveNodeChildren(t){return t.children&&(t.children=t.children.map(r=>this.getNode(r))),t}_resolveSkin(t,r){let n=typeof t.inverseBindMatrices=="number"?this.getAccessor(t.inverseBindMatrices):void 0;return{...t,id:t.id||`skin-${r}`,inverseBindMatrices:n}}_resolveMesh(t,r){let n={...t,id:t.id||`mesh-${r}`,primitives:[]};return t.primitives&&(n.primitives=t.primitives.map(s=>{let o={...s,attributes:{},indices:void 0,material:void 0},i=s.attributes;for(let a in i)o.attributes[a]=this.getAccessor(i[a]);return s.indices!==void 0&&(o.indices=this.getAccessor(s.indices)),s.material!==void 0&&(o.material=this.getMaterial(s.material)),o})),n}_resolveMaterial(t,r){let n={...t,id:t.id||`material-${r}`};if(n.normalTexture&&(n.normalTexture={...n.normalTexture},n.normalTexture.texture=this.getTexture(n.normalTexture.index)),n.occlusionTexture&&(n.occlusionTexture={...n.occlusionTexture},n.occlusionTexture.texture=this.getTexture(n.occlusionTexture.index)),n.emissiveTexture&&(n.emissiveTexture={...n.emissiveTexture},n.emissiveTexture.texture=this.getTexture(n.emissiveTexture.index)),n.emissiveFactor||(n.emissiveFactor=n.emissiveTexture?[1,1,1]:[0,0,0]),n.pbrMetallicRoughness){n.pbrMetallicRoughness={...n.pbrMetallicRoughness};let s=n.pbrMetallicRoughness;s.baseColorTexture&&(s.baseColorTexture={...s.baseColorTexture},s.baseColorTexture.texture=this.getTexture(s.baseColorTexture.index)),s.metallicRoughnessTexture&&(s.metallicRoughnessTexture={...s.metallicRoughnessTexture},s.metallicRoughnessTexture.texture=this.getTexture(s.metallicRoughnessTexture.index))}return n}_resolveAccessor(t,r){let n=MB(t.componentType),s=IB(t.type),o=n*s,i={...t,id:t.id||`accessor-${r}`,bytesPerComponent:n,components:s,bytesPerElement:o,value:void 0,bufferView:void 0,sparse:void 0};if(t.bufferView!==void 0&&(i.bufferView=this.getBufferView(t.bufferView)),i.bufferView){let a=i.bufferView.buffer,{ArrayType:c,byteLength:l}=Mr(i,i.bufferView),u=(i.bufferView.byteOffset||0)+(i.byteOffset||0)+a.byteOffset,f=a.arrayBuffer.slice(u,u+l);i.bufferView.byteStride&&(f=this._getValueFromInterleavedBuffer(a,u,i.bufferView.byteStride,i.bytesPerElement,i.count)),i.value=new c(f)}return i}_getValueFromInterleavedBuffer(t,r,n,s,o){let i=new Uint8Array(o*s);for(let a=0;a<o;a++){let c=r+a*n;i.set(new Uint8Array(t.arrayBuffer.slice(c,c+s)),a*s)}return i.buffer}_resolveTexture(t,r){return{...t,id:t.id||`texture-${r}`,sampler:typeof t.sampler=="number"?this.getSampler(t.sampler):bB(),source:typeof t.source=="number"?this.getImage(t.source):void 0}}_resolveSampler(t,r){let n={id:t.id||`sampler-${r}`,...t,parameters:{}};for(let s in n){let o=this._enumSamplerParameter(s);o!==void 0&&(n.parameters[o]=n[s])}return n}_enumSamplerParameter(t){return CB[t]}_resolveImage(t,r){let n={...t,id:t.id||`image-${r}`,image:null,bufferView:t.bufferView!==void 0?this.getBufferView(t.bufferView):void 0},s=this.images[r];return s&&(n.image=s),n}_resolveBufferView(t,r){let n=t.buffer,s=this.buffers[n].arrayBuffer,o=this.buffers[n].byteOffset||0;return t.byteOffset&&(o+=t.byteOffset),{id:`bufferView-${r}`,...t,buffer:this.buffers[n],data:new Uint8Array(s,o,t.byteLength)}}_resolveCamera(t,r){let n={...t,id:t.id||`camera-${r}`};return n.perspective,n.orthographic,n}};function On(e,t){return new yc().postProcess(e,t)}var go={URI:0,EMBEDDED:1};function Ao(e,t,r,n){e.rotateYtoZ=!0;let s=(e.byteOffset||0)+(e.byteLength||0)-r;if(s===0)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=n?.["3d-tiles"]&&n["3d-tiles"].assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=Pe(t,r,s),e.gltfByteOffset=0,e.gltfByteLength=s,r%4===0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function xo(e,t,r,n){let s=r?.["3d-tiles"]||{};if(wB(e,t,r),s.loadGLTF){if(!n)return;if(e.gltfUrl){let{fetch:o}=n,i=await o(e.gltfUrl,r);e.gltfArrayBuffer=await i.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){let o=await Et(e.gltfArrayBuffer,$e,r,n);e.gltf=On(o),e.gpuMemoryUsageInBytes=Ln(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}function wB(e,t,r){switch(t){case go.URI:if(e.gltfArrayBuffer){let n=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),o=new TextDecoder().decode(n);e.gltfUrl=o.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case go.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function Ip(e,t,r,n,s){r=LB(e,t,r,n,s),await xo(e,go.EMBEDDED,n,s);let o=e?.gltf?.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),r}function LB(e,t,r,n,s){r=Me(e,t,r),r=Cr(e,t,r),r=Sr(e,t,r,n),r=Ao(e,t,r,n);let o=new ae(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=o.getGlobalProperty("RTC_CENTER",O.FLOAT,3),r}async function wp(e,t,r,n,s){return r=FB(e,t,r,n,s),await xo(e,e.gltfFormat||0,n,s),r}function FB(e,t,r,n,s){if(r=Me(e,t,r),e.version!==1)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Cr(e,t,r);let o=new DataView(t);if(e.gltfFormat=o.getUint32(r,!0),r+=4,r=Sr(e,t,r,n),r=Ao(e,t,r,n),!e?.header?.featureTableJsonByteLength||e.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let i=new ae(e.featureTableJson,e.featureTableBinary),a=i.getGlobalProperty("INSTANCES_LENGTH");if(i.featuresLength=a,!Number.isFinite(a))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=i.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=i.getGlobalProperty("RTC_CENTER",O.FLOAT,3);let c=new Qe(e.batchTableJson,e.batchTableBinary,a);return RB(e,i,c,a),r}function RB(e,t,r,n){let s=new Array(n),o=new x,i=new x,a=new x,c=new x,l=new z,u=new Wt,f=new x,h={},d=new P,p=[],A=[],g=[],y=[];for(let E=0;E<n;E++){let _;if(t.hasProperty("POSITION"))_=t.getProperty("POSITION",O.FLOAT,3,E,o);else if(t.hasProperty("POSITION_QUANTIZED")){_=t.getProperty("POSITION_QUANTIZED",O.UNSIGNED_SHORT,3,E,o);let m=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",O.FLOAT,3);if(!m)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let M=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",O.FLOAT,3);if(!M)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let F=65535;for(let R=0;R<3;R++)_[R]=_[R]/F*M[R]+m[R]}if(!_)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");o.copy(_),h.translation=o,e.normalUp=t.getProperty("NORMAL_UP",O.FLOAT,3,E,p),e.normalRight=t.getProperty("NORMAL_RIGHT",O.FLOAT,3,E,A);let B=!1;if(e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",O.UNSIGNED_SHORT,2,E,p),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",O.UNSIGNED_SHORT,2,E,A),e.octNormalUp)throw e.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");e.eastNorthUp?(v.WGS84.eastNorthUpToFixedFrame(o,d),d.getRotationMatrix3(l)):l.identity()}B&&(c.copy(i).cross(a).normalize(),l.setColumn(0,i),l.setColumn(1,a),l.setColumn(2,c)),u.fromMatrix3(l),h.rotation=u,f.set(1,1,1);let S=t.getProperty("SCALE",O.FLOAT,1,E,g);Number.isFinite(S)&&f.multiplyByScalar(S);let b=t.getProperty("SCALE_NON_UNIFORM",O.FLOAT,3,E,p);b&&f.scale(b),h.scale=f;let w=t.getProperty("BATCH_ID",O.UNSIGNED_SHORT,1,E,y);w===void 0&&(w=E);let C=new P().fromQuaternion(h.rotation);d.identity(),d.translate(h.translation),d.multiplyRight(C),d.scale(h.scale);let T=d.clone();s[E]={modelMatrix:T,batchId:w}}e.instances=s}async function Lp(e,t,r,n,s,o){r=Me(e,t,r);let i=new DataView(t);for(e.tilesLength=i.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-r>12;){let a={shape:"tile3d"};e.tiles.push(a),r=await o(t,r,n,s,a)}return r}async function Fp(e,t,r,n){if(e.rotateYtoZ=!0,e.gltfUpAxis=r?.["3d-tiles"]?.assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",r?.["3d-tiles"]?.loadGLTF){if(!n)return t.byteLength;let s=await Et(t,$e,r,n);e.gltf=On(s),e.gpuMemoryUsageInBytes=Ln(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}async function Tc(e,t=0,r,n,s={shape:"tile3d"}){switch(s.byteOffset=t,s.type=vd(e,t),s.type){case Ye.COMPOSITE:return await Lp(s,e,t,r,n,Tc);case Ye.BATCHED_3D_MODEL:return await Ip(s,e,t,r,n);case Ye.GLTF:return await Fp(s,e,r,n);case Ye.INSTANCED_3D_MODEL:return await wp(s,e,t,r,n);case Ye.POINT_CLOUD:return await sp(s,e,t,r,n);default:throw new Error(`3DTileLoader: unknown type ${s.type}`)}}async function _c(e,t,r){if(new Uint32Array(e.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(e.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let o=Rp(e.slice(8,16)),i=new Uint8Array(e,24,o),c=new TextDecoder("utf8").decode(i),l=JSON.parse(c),u=Rp(e.slice(16,24)),f=new ArrayBuffer(0);if(u&&(f=e.slice(24+o)),await yo(l,l.tileAvailability,f,r),Array.isArray(l.contentAvailability))for(let h of l.contentAvailability)await yo(l,h,f,r);else await yo(l,l.contentAvailability,f,r);return await yo(l,l.childSubtreeAvailability,f,r),l}async function yo(e,t,r,n){let s=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if(typeof s!="number")return;let o=e.bufferViews[s],i=e.buffers[o.buffer];if(!n?.baseUrl)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(i.uri){let c=`${n?.baseUrl||""}/${i.uri}`,u=await(await n.fetch(c)).arrayBuffer();t.explicitBitstream=new Uint8Array(u,o.byteOffset,o.byteLength);return}let a=e.buffers.slice(0,o.buffer).reduce((c,l)=>c+l.byteLength,0);t.explicitBitstream=new Uint8Array(r.slice(a,a+i.byteLength),o.byteOffset,o.byteLength)}function Rp(e){let t=new DataView(e),r=t.getUint32(0,!0),n=t.getUint32(4,!0);return r+2**32*n}var To={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:to,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:_c,options:{}};var tm=N(yr(),1);var Kp=N(yr(),1);var Rt=null;try{Rt=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function K(e,t,r){this.low=e|0,this.high=t|0,this.unsigned=!!r}K.prototype.__isLong__;Object.defineProperty(K.prototype,"__isLong__",{value:!0});function pt(e){return(e&&e.__isLong__)===!0}function Pp(e){var t=Math.clz32(e&-e);return e?31-t:t}K.isLong=pt;var Op={},Np={};function tr(e,t){var r,n,s;return t?(e>>>=0,(s=0<=e&&e<256)&&(n=Np[e],n)?n:(r=V(e,0,!0),s&&(Np[e]=r),r)):(e|=0,(s=-128<=e&&e<128)&&(n=Op[e],n)?n:(r=V(e,e<0?-1:0,!1),s&&(Op[e]=r),r))}K.fromInt=tr;function Pt(e,t){if(isNaN(e))return t?ce:Ht;if(t){if(e<0)return ce;if(e>=Gp)return zp}else{if(e<=-vp)return _t;if(e+1>=vp)return Hp}return e<0?Pt(-e,t).neg():V(e%Or|0,e/Or|0,t)}K.fromNumber=Pt;function V(e,t,r){return new K(e,t,r)}K.fromBits=V;var _o=Math.pow;function Bc(e,t,r){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(r=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?ce:Ht;if(r=r||10,r<2||36<r)throw RangeError("radix");var n;if((n=e.indexOf("-"))>0)throw Error("interior hyphen");if(n===0)return Bc(e.substring(1),t,r).neg();for(var s=Pt(_o(r,8)),o=Ht,i=0;i<e.length;i+=8){var a=Math.min(8,e.length-i),c=parseInt(e.substring(i,i+a),r);if(a<8){var l=Pt(_o(r,a));o=o.mul(l).add(Pt(c))}else o=o.mul(s),o=o.add(Pt(c))}return o.unsigned=t,o}K.fromString=Bc;function zt(e,t){return typeof e=="number"?Pt(e,t):typeof e=="string"?Bc(e,t):V(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}K.fromValue=zt;var Dp=1<<16,PB=1<<24,Or=Dp*Dp,Gp=Or*Or,vp=Gp/2,Up=tr(PB),Ht=tr(0);K.ZERO=Ht;var ce=tr(0,!0);K.UZERO=ce;var Pr=tr(1);K.ONE=Pr;var Vp=tr(1,!0);K.UONE=Vp;var Ec=tr(-1);K.NEG_ONE=Ec;var Hp=V(-1,2147483647,!1);K.MAX_VALUE=Hp;var zp=V(-1,-1,!0);K.MAX_UNSIGNED_VALUE=zp;var _t=V(0,-2147483648,!1);K.MIN_VALUE=_t;var I=K.prototype;I.toInt=function(){return this.unsigned?this.low>>>0:this.low};I.toNumber=function(){return this.unsigned?(this.high>>>0)*Or+(this.low>>>0):this.high*Or+(this.low>>>0)};I.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(_t)){var r=Pt(t),n=this.div(r),s=n.mul(r).sub(this);return n.toString(t)+s.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var o=Pt(_o(t,6),this.unsigned),i=this,a="";;){var c=i.div(o),l=i.sub(c.mul(o)).toInt()>>>0,u=l.toString(t);if(i=c,i.isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}};I.getHighBits=function(){return this.high};I.getHighBitsUnsigned=function(){return this.high>>>0};I.getLowBits=function(){return this.low};I.getLowBitsUnsigned=function(){return this.low>>>0};I.getNumBitsAbs=function(){if(this.isNegative())return this.eq(_t)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,r=31;r>0&&!(t&1<<r);r--);return this.high!=0?r+33:r+1};I.isZero=function(){return this.high===0&&this.low===0};I.eqz=I.isZero;I.isNegative=function(){return!this.unsigned&&this.high<0};I.isPositive=function(){return this.unsigned||this.high>=0};I.isOdd=function(){return(this.low&1)===1};I.isEven=function(){return(this.low&1)===0};I.equals=function(t){return pt(t)||(t=zt(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};I.eq=I.equals;I.notEquals=function(t){return!this.eq(t)};I.neq=I.notEquals;I.ne=I.notEquals;I.lessThan=function(t){return this.comp(t)<0};I.lt=I.lessThan;I.lessThanOrEqual=function(t){return this.comp(t)<=0};I.lte=I.lessThanOrEqual;I.le=I.lessThanOrEqual;I.greaterThan=function(t){return this.comp(t)>0};I.gt=I.greaterThan;I.greaterThanOrEqual=function(t){return this.comp(t)>=0};I.gte=I.greaterThanOrEqual;I.ge=I.greaterThanOrEqual;I.compare=function(t){if(pt(t)||(t=zt(t)),this.eq(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};I.comp=I.compare;I.negate=function(){return!this.unsigned&&this.eq(_t)?_t:this.not().add(Pr)};I.neg=I.negate;I.add=function(t){pt(t)||(t=zt(t));var r=this.high>>>16,n=this.high&65535,s=this.low>>>16,o=this.low&65535,i=t.high>>>16,a=t.high&65535,c=t.low>>>16,l=t.low&65535,u=0,f=0,h=0,d=0;return d+=o+l,h+=d>>>16,d&=65535,h+=s+c,f+=h>>>16,h&=65535,f+=n+a,u+=f>>>16,f&=65535,u+=r+i,u&=65535,V(h<<16|d,u<<16|f,this.unsigned)};I.subtract=function(t){return pt(t)||(t=zt(t)),this.add(t.neg())};I.sub=I.subtract;I.multiply=function(t){if(this.isZero())return this;if(pt(t)||(t=zt(t)),Rt){var r=Rt.mul(this.low,this.high,t.low,t.high);return V(r,Rt.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?ce:Ht;if(this.eq(_t))return t.isOdd()?_t:Ht;if(t.eq(_t))return this.isOdd()?_t:Ht;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(Up)&&t.lt(Up))return Pt(this.toNumber()*t.toNumber(),this.unsigned);var n=this.high>>>16,s=this.high&65535,o=this.low>>>16,i=this.low&65535,a=t.high>>>16,c=t.high&65535,l=t.low>>>16,u=t.low&65535,f=0,h=0,d=0,p=0;return p+=i*u,d+=p>>>16,p&=65535,d+=o*u,h+=d>>>16,d&=65535,d+=i*l,h+=d>>>16,d&=65535,h+=s*u,f+=h>>>16,h&=65535,h+=o*l,f+=h>>>16,h&=65535,h+=i*c,f+=h>>>16,h&=65535,f+=n*u+s*l+o*c+i*a,f&=65535,V(d<<16|p,f<<16|h,this.unsigned)};I.mul=I.multiply;I.divide=function(t){if(pt(t)||(t=zt(t)),t.isZero())throw Error("division by zero");if(Rt){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var r=(this.unsigned?Rt.div_u:Rt.div_s)(this.low,this.high,t.low,t.high);return V(r,Rt.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?ce:Ht;var n,s,o;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return ce;if(t.gt(this.shru(1)))return Vp;o=ce}else{if(this.eq(_t)){if(t.eq(Pr)||t.eq(Ec))return _t;if(t.eq(_t))return Pr;var i=this.shr(1);return n=i.div(t).shl(1),n.eq(Ht)?t.isNegative()?Pr:Ec:(s=this.sub(t.mul(n)),o=n.add(s.div(t)),o)}else if(t.eq(_t))return this.unsigned?ce:Ht;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();o=Ht}for(s=this;s.gte(t);){n=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var a=Math.ceil(Math.log(n)/Math.LN2),c=a<=48?1:_o(2,a-48),l=Pt(n),u=l.mul(t);u.isNegative()||u.gt(s);)n-=c,l=Pt(n,this.unsigned),u=l.mul(t);l.isZero()&&(l=Pr),o=o.add(l),s=s.sub(u)}return o};I.div=I.divide;I.modulo=function(t){if(pt(t)||(t=zt(t)),Rt){var r=(this.unsigned?Rt.rem_u:Rt.rem_s)(this.low,this.high,t.low,t.high);return V(r,Rt.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};I.mod=I.modulo;I.rem=I.modulo;I.not=function(){return V(~this.low,~this.high,this.unsigned)};I.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};I.clz=I.countLeadingZeros;I.countTrailingZeros=function(){return this.low?Pp(this.low):Pp(this.high)+32};I.ctz=I.countTrailingZeros;I.and=function(t){return pt(t)||(t=zt(t)),V(this.low&t.low,this.high&t.high,this.unsigned)};I.or=function(t){return pt(t)||(t=zt(t)),V(this.low|t.low,this.high|t.high,this.unsigned)};I.xor=function(t){return pt(t)||(t=zt(t)),V(this.low^t.low,this.high^t.high,this.unsigned)};I.shiftLeft=function(t){return pt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?V(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):V(0,this.low<<t-32,this.unsigned)};I.shl=I.shiftLeft;I.shiftRight=function(t){return pt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?V(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):V(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};I.shr=I.shiftRight;I.shiftRightUnsigned=function(t){return pt(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?V(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?V(this.high,0,this.unsigned):V(this.high>>>t-32,0,this.unsigned)};I.shru=I.shiftRightUnsigned;I.shr_u=I.shiftRightUnsigned;I.rotateLeft=function(t){var r;return pt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?V(this.high,this.low,this.unsigned):t<32?(r=32-t,V(this.low<<t|this.high>>>r,this.high<<t|this.low>>>r,this.unsigned)):(t-=32,r=32-t,V(this.high<<t|this.low>>>r,this.low<<t|this.high>>>r,this.unsigned))};I.rotl=I.rotateLeft;I.rotateRight=function(t){var r;return pt(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?V(this.high,this.low,this.unsigned):t<32?(r=32-t,V(this.high<<r|this.low>>>t,this.low<<r|this.high>>>t,this.unsigned)):(t-=32,r=32-t,V(this.low<<r|this.high>>>t,this.high<<r|this.low>>>t,this.unsigned))};I.rotr=I.rotateRight;I.toSigned=function(){return this.unsigned?V(this.low,this.high,!1):this};I.toUnsigned=function(){return this.unsigned?this:V(this.low,this.high,!0)};I.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};I.toBytesLE=function(){var t=this.high,r=this.low;return[r&255,r>>>8&255,r>>>16&255,r>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};I.toBytesBE=function(){var t=this.high,r=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,r>>>24,r>>>16&255,r>>>8&255,r&255]};K.fromBytes=function(t,r,n){return n?K.fromBytesLE(t,r):K.fromBytesBE(t,r)};K.fromBytesLE=function(t,r){return new K(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,r)};K.fromBytesBE=function(t,r){return new K(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],r)};var Nr=K;var OB=16;function Nn(e){e==="X"&&(e="");let t=e.padEnd(OB,"0");return Nr.fromString(t,!0,16)}function Cc(e){if(e.isZero())return"X";let t=e.countTrailingZeros(),r=t%4;t=(t-r)/4;let n=t;t*=4;let o=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-n-o.length).join("0")+o}function Sc(e,t){let r=NB(e).shiftRightUnsigned(2);return e.add(Nr.fromNumber(2*t+1-4).multiply(r))}function NB(e){return e.and(e.not().add(1))}var DB=3,vB=30,UB=2*vB+1,kp=180/Math.PI;function qp(e){if(e.length===0)throw new Error(`Invalid Hilbert quad key ${e}`);let t=e.split("/"),r=parseInt(t[0],10),n=t[1],s=n.length,o=0,i=[0,0];for(let a=s-1;a>=0;a--){o=s-a;let c=n[a],l=0,u=0;c==="1"?u=1:c==="2"?(l=1,u=1):c==="3"&&(l=1);let f=Math.pow(2,o-1);GB(f,i,l,u),i[0]+=f*l,i[1]+=f*u}if(r%2===1){let a=i[0];i[0]=i[1],i[1]=a}return{face:r,ij:i,level:o}}function jp(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<DB+UB;)t="0"+t;let r=t.lastIndexOf("1"),n=t.substring(0,3),s=t.substring(3,r),o=s.length/2,i=Nr.fromString(n,!0,2).toString(10),a="";if(o!==0)for(a=Nr.fromString(s,!0,2).toString(4);a.length<o;)a="0"+a;return`${i}/${a}`}function bc(e,t,r){let n=1<<t;return[(e[0]+r[0])/n,(e[1]+r[1])/n]}function Jp(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function Mc(e){return[Jp(e[0]),Jp(e[1])]}function Ic(e,[t,r]){switch(e){case 0:return[1,t,r];case 1:return[-t,1,r];case 2:return[-t,-r,1];case 3:return[-1,-r,-t];case 4:return[r,-1,-t];case 5:return[r,t,-1];default:throw new Error("Invalid face")}}function wc([e,t,r]){let n=Math.atan2(r,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*kp,n*kp]}function GB(e,t,r,n){if(n===0){r===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function Xp(e){let t=bc(e.ij,e.level,[.5,.5]),r=Mc(t),n=Ic(e.face,r);return wc(n)}var VB=100;function Lc(e){let{face:t,ij:r,level:n}=e,s=[[0,0],[0,1],[1,1],[1,0],[0,0]],o=Math.max(1,Math.ceil(VB*Math.pow(2,-n))),i=new Float64Array(4*o*2+2),a=0,c=0;for(let l=0;l<4;l++){let u=s[l].slice(0),f=s[l+1],h=(f[0]-u[0])/o,d=(f[1]-u[1])/o;for(let p=0;p<o;p++){u[0]+=h,u[1]+=d;let A=bc(r,n,u),g=Mc(A),y=Ic(t,g),E=wc(y);Math.abs(E[1])>89.999&&(E[0]=c);let _=E[0]-c;E[0]+=_>180?-360:_<-180?360:0,i[a++]=E[0],i[a++]=E[1],c=E[0]}}return i[a++]=i[0],i[a++]=i[1],i}function Dr(e){let t=HB(e);return qp(t)}function HB(e){if(e.indexOf("/")>0)return e;let t=Nn(e);return jp(t)}function Fc(e){let t=Dr(e);return Xp(t)}function Yp(e){let t;if(e.face===2||e.face===5){let r=null,n=0;for(let s=0;s<4;s++){let o=`${e.face}/${s}`,i=Dr(o),a=Lc(i);(typeof r>"u"||r===null)&&(r=new Float64Array(4*a.length)),r.set(a,n),n+=a.length}t=Wp(r)}else{let r=Lc(e);t=Wp(r)}return t}function Wp(e){if(e.length%2!==0)throw new Error("Invalid corners");let t=[],r=[];for(let n=0;n<e.length;n+=2)t.push(e[n]),r.push(e[n+1]);return t.sort((n,s)=>n-s),r.sort((n,s)=>n-s),{west:t[0],east:t[t.length-1],north:r[r.length-1],south:r[0]}}function Rc(e,t){let r=t?.minimumHeight||0,n=t?.maximumHeight||0,s=Dr(e),o=Yp(s),i=o.west,a=o.south,c=o.east,l=o.north,u=[];return u.push(new x(i,l,r)),u.push(new x(c,l,r)),u.push(new x(c,a,r)),u.push(new x(i,a,r)),u.push(new x(i,l,n)),u.push(new x(c,l,n)),u.push(new x(c,a,n)),u.push(new x(i,a,n)),u}function Eo(e){let t=e.token,r={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},n=Rc(t,r),s=Fc(t),o=s[0],i=s[1],a=v.WGS84.cartographicToCartesian([o,i,r.maximumHeight]),c=new x(a[0],a[1],a[2]);n.push(c);let l=gn(n);return[...l.center,...l.halfAxes]}var zB=4,kB=8,JB={QUADTREE:zB,OCTREE:kB};function qB(e,t,r){if(e?.box){let n=Nn(e.s2VolumeInfo.token),s=Sc(n,t),o=Cc(s),i={...e.s2VolumeInfo};switch(i.token=o,r){case"OCTREE":let l=e.s2VolumeInfo,u=l.maximumHeight-l.minimumHeight,f=u/2,h=l.minimumHeight+u/2;l.minimumHeight=h-f,l.maximumHeight=h+f;break;default:break}return{box:Eo(i),s2VolumeInfo:i}}}async function Oc(e){let{implicitOptions:t,parentData:r={mortonIndex:0,x:0,y:0,z:0},childIndex:n=0,s2VolumeBox:s,loaderOptions:o}=e,{subtree:i,level:a=0,globalData:c={level:0,mortonIndex:0,x:0,y:0,z:0}}=e,{subdivisionScheme:l,subtreeLevels:u,maximumLevel:f,contentUrlTemplate:h,subtreesUriTemplate:d,basePath:p}=t,A={children:[],lodMetricValue:0,contentUrl:""};if(!f)return ri.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${h} won't be loaded...`),A;let g=a+c.level;if(g>f)return A;let y=JB[l],E=Math.log2(y),_=n&1,B=n>>1&1,S=n>>2&1,b=(y**a-1)/(y-1),w=er(r.mortonIndex,n,E),C=b+w,T=er(r.x,_,1),m=er(r.y,B,1),M=er(r.z,S,1),F=!1;a>=u&&(F=Pc(i.childSubtreeAvailability,w));let R=er(c.x,T,a),L=er(c.y,m,a),D=er(c.z,M,a);if(F){let W=`${p}/${d}`,$=Bo(W,g,R,L,D);i=await(0,Kp.load)($,To,o),c={mortonIndex:w,x:T,y:m,z:M,level:a},w=0,C=0,T=0,m=0,M=0,a=0}if(!Pc(i.tileAvailability,C))return A;Pc(i.contentAvailability,C)&&(A.contentUrl=Bo(h,g,R,L,D));let Q=a+1,j={mortonIndex:w,x:T,y:m,z:M};for(let W=0;W<y;W++){let $=qB(s,W,l),At=await Oc({subtree:i,implicitOptions:t,loaderOptions:o,parentData:j,childIndex:W,level:Q,globalData:{...c},s2VolumeBox:$});if(At.contentUrl||At.children.length){let eg=g+1,rg=jB(At,eg,{childTileX:T,childTileY:m,childTileZ:M},t,s);A.children.push(rg)}}return A}function Pc(e,t){let r;return Array.isArray(e)?(r=e[0],e.length>1&&ri.once('Not supported extension "3DTILES_multiple_contents" has been detected')):r=e,"constant"in r?Boolean(r.constant):r.explicitBitstream?YB(t,r.explicitBitstream):!1}function jB(e,t,r,n,s){let{basePath:o,refine:i,getRefine:a,lodMetricType:c,getTileType:l,rootLodMetricValue:u,rootBoundingVolume:f}=n,h=e.contentUrl&&e.contentUrl.replace(`${o}/`,""),d=u/2**t,p=s?.box?{box:s.box}:f,A=XB(t,p,r);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:a(i),type:l(e),lodMetricType:c,lodMetricValue:d,geometricError:d,transform:e.transform,boundingVolume:A}}function XB(e,t,r){if(t.region){let{childTileX:n,childTileY:s,childTileZ:o}=r,[i,a,c,l,u,f]=t.region,h=2**e,d=(c-i)/h,p=(l-a)/h,A=(f-u)/h,[g,y]=[i+d*n,i+d*(n+1)],[E,_]=[a+p*s,a+p*(s+1)],[B,S]=[u+A*o,u+A*(o+1)];return{region:[g,E,y,_,B,S]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function er(e,t,r){return(e<<r)+t}function Bo(e,t,r,n,s){let o=WB({level:t,x:r,y:n,z:s});return e.replace(/{level}|{x}|{y}|{z}/gi,i=>o[i])}function WB(e){let t={};for(let r in e)t[`{${r}}`]=e[r];return t}function YB(e,t){let r=Math.floor(e/8),n=e%8;return(t[r]>>n&1)===1}function Dc(e,t=""){if(!t)return Lt.EMPTY;let n=t.split("?")[0].split(".").pop();switch(n){case"pnts":return Lt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Lt.SCENEGRAPH;default:return n||Lt.EMPTY}}function vc(e){switch(e){case"REPLACE":case"replace":return ft.REPLACE;case"ADD":case"add":return ft.ADD;default:return e}}function Nc(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){let n=new URL(e,`${t}/`);return decodeURI(n.toString())}else if(e.startsWith("/"))return e;return me.resolve(t,e)}function Qp(e,t){if(!e)return null;let r;if(e.content){let s=e.content.uri||e.content?.url;typeof s<"u"&&(r=Nc(s,t))}return{...e,id:r,contentUrl:r,lodMetricType:ie.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Dc(e,r),refine:vc(e.refine)}}async function em(e,t,r){let n=null,s=$p(e.root);s&&e.root?n=await Zp(e.root,e,t,s,r):n=Qp(e.root,t);let o=[];for(o.push(n);o.length>0;){let i=o.pop()||{},a=i.children||[],c=[];for(let l of a){let u=$p(l),f;u?f=await Zp(l,e,t,u,r):f=Qp(l,t),f&&(c.push(f),o.push(f))}i.children=c}return n}async function Zp(e,t,r,n,s){let{subdivisionScheme:o,maximumLevel:i,availableLevels:a,subtreeLevels:c,subtrees:{uri:l}}=n,u=Bo(l,0,0,0,0),f=Nc(u,r),h=await(0,tm.load)(f,To,s),d=e.content?.uri,p=d?Nc(d,r):"",A=t?.root?.refine,g=e.geometricError,y=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(y){let S={box:Eo(y),s2VolumeInfo:y};e.boundingVolume=S}let E=e.boundingVolume,_={contentUrlTemplate:p,subtreesUriTemplate:l,subdivisionScheme:o,subtreeLevels:c,maximumLevel:Number.isFinite(a)?a-1:i,refine:A,basePath:r,lodMetricType:ie.GEOMETRIC_ERROR,rootLodMetricValue:g,rootBoundingVolume:E,getTileType:Dc,getRefine:vc};return await KB(e,r,h,_,s)}async function KB(e,t,r,n,s){if(!e)return null;let{children:o,contentUrl:i}=await Oc({subtree:r,implicitOptions:n,loaderOptions:s}),a,c=null;return i&&(a=i,c={uri:i.replace(`${t}/`,"")}),{...e,id:a,contentUrl:a,lodMetricType:ie.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:Dc(e,a),refine:vc(e.refine),content:c||e.content,children:o}}function $p(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}var Co={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:to,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:QB,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function QB(e,t={},r){let n=t["3d-tiles"]||{},s;return n.isTileset==="auto"?s=r?.url&&r.url.indexOf(".json")!==-1:s=n.isTileset,s?ZB(e,t,r):$B(e,t,r)}async function ZB(e,t,r){let n=JSON.parse(new TextDecoder().decode(e)),s=r?.url||"",o=tC(s),i=await em(n,o,t||{});return{...n,shape:"tileset3d",loader:Co,url:s,queryString:r?.queryString||"",basePath:o,root:i||n.root,type:lt.TILES3D,lodMetricType:ie.GEOMETRIC_ERROR,lodMetricValue:n.root?.geometricError||0}}async function $B(e,t,r){let n={content:{shape:"tile3d",featureIds:null}};return await Tc(e,0,t,r,n.content),n.content}function tC(e){return me.dirname(e)}var rm=[0],eC={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:Co,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,r)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}},Dn=class extends we.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&we.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:r,changeFlags:n}){if(t.data&&t.data!==r.data&&this._loadTileset(t.data),n.viewportChanged){let{activeViewports:s}=this.state;Object.keys(s).length&&(this._updateTileset(s),this.state.lastUpdatedViewports=s,this.state.activeViewports={})}if(n.propsChanged){let{layerMap:s}=this.state;for(let o in s)s[o].needsUpdate=!0}}activateViewport(t){let{activeViewports:r,lastUpdatedViewports:n}=this.state;this.internalState.viewport=t,r[t.id]=t;let s=n?.[t.id];(!s||!t.equals(s))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:r}){let n=r&&r.props.tile;return t.picked&&(t.object=n),t.sourceTile=n,t}filterSubLayer({layer:t,viewport:r}){let{tile:n}=t.props,{id:s}=r;return n.selected&&n.viewportIds.includes(s)}_updateAutoHighlight(t){let r=t.sourceTile,n=this.state.layerMap[r?.id];n&&n.layer&&n.layer.updateAutoHighlight(t)}async _loadTileset(t){let{loadOptions:r={}}=this.props,n=this.props.loader||this.props.loaders,s=Array.isArray(n)?n[0]:n,o={loadOptions:{...r}},i=t;if(s.preload){let l=await s.preload(t,r);l.url&&(i=l.url),l.headers&&(o.loadOptions.fetch={...o.loadOptions.fetch,headers:l.headers}),Object.assign(o,l)}let a=await(0,im.load)(i,s,o.loadOptions),c=new In(a,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...o});this.setState({tileset3d:c,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(c)}_onTileLoad(t){let{lastUpdatedViewports:r}=this.state;this.props.onTileLoad(t),this._updateTileset(r),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;let{tileset3d:r}=this.state,{timeline:n}=this.context,s=Object.keys(t).length;!n||!s||!r||r.selectTiles(Object.values(t)).then(o=>{this.state.frameNumber!==o&&this.setState({frameNumber:o})})}_getSubLayer(t,r){if(!t.content)return null;switch(t.type){case Lt.POINTCLOUD:return this._makePointCloudLayer(t,r);case Lt.SCENEGRAPH:return this._make3DModelLayer(t);case Lt.MESH:return this._makeSimpleMeshLayer(t,r);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${t.content.type}`)}}_makePointCloudLayer(t,r){let{attributes:n,pointCount:s,constantRGBA:o,cartographicOrigin:i,modelMatrix:a}=t.content,{positions:c,normals:l,colors:u}=n;if(!c)return null;let f=r&&r.props.data||{header:{vertexCount:s},attributes:{POSITION:c,NORMAL:l,COLOR_0:u}},{pointSize:h,getPointColor:d}=this.props,p=this.getSubLayerClass("pointcloud",sm.PointCloudLayer);return new p({pointSize:h},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${t.id}`,tile:t,data:f,coordinateSystem:we.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:i,modelMatrix:a,getColor:o||d,_offset:0})}_make3DModelLayer(t){let{gltf:r,instances:n,cartographicOrigin:s,modelMatrix:o}=t.content,i=this.getSubLayerClass("scenegraph",om.ScenegraphLayer);return new i({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${t.id}`,tile:t,data:n||rm,scenegraph:r,coordinateSystem:we.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:s,modelMatrix:o,getTransformMatrix:a=>a.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,r){let n=t.content,{attributes:s,indices:o,modelMatrix:i,cartographicOrigin:a,coordinateSystem:c=we.COORDINATE_SYSTEM.METER_OFFSETS,material:l,featureIds:u}=n,{_getMeshColor:f}=this.props,h=r&&r.props.mesh||new nm.Geometry({topology:"triangle-list",attributes:rC(s),indices:o}),d=this.getSubLayerClass("mesh",Qh);return new d(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${t.id}`,tile:t,mesh:h,data:rm,getColor:f(t),pbrMaterial:l,modelMatrix:i,coordinateOrigin:a,coordinateSystem:c,featureIds:u,_offset:0})}renderLayers(){let{tileset3d:t,layerMap:r}=this.state;return t?t.tiles.map(n=>{let s=r[n.id]=r[n.id]||{tile:n},{layer:o}=s;return n.selected&&(o?s.needsUpdate&&(o=this._getSubLayer(n,o),s.needsUpdate=!1):o=this._getSubLayer(n)),s.layer=o,o}).filter(Boolean):null}};Dn.defaultProps=eC;Dn.layerName="Tile3DLayer";var am=Dn;function rC(e){let t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}var wo=N(Nt(),1),zc=N(Ds(),1),pm=N(Nt(),1);var nC=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function Uc(e){return e>>1^-(e&1)}function sC(e){let t=0,r={};for(let[n,s]of nC){let o=s===8?e.getFloat64:e.getFloat32;r[n]=o.call(e,t,!0),t+=s}return{header:r,headerEndPosition:t}}function oC(e,t){let r=t,n=3,s=e.getUint32(r,!0),o=new Uint16Array(s*n);r+=Uint32Array.BYTES_PER_ELEMENT;let i=Uint16Array.BYTES_PER_ELEMENT,a=s*i,c=r,l=c+a,u=l+a,f=0,h=0,d=0;for(let p=0;p<s;p++)f+=Uc(e.getUint16(c+i*p,!0)),h+=Uc(e.getUint16(l+i*p,!0)),d+=Uc(e.getUint16(u+i*p,!0)),o[p]=f,o[p+s]=h,o[p+s*2]=d;return r+=a*3,{vertexData:o,vertexDataEndPosition:r}}function vn(e,t,r,n,s=!0){let o;if(n===2?o=new Uint16Array(e,t,r):o=new Uint32Array(e,t,r),!s)return o;let i=0;for(let a=0;a<o.length;++a){let c=o[a];o[a]=i-c,c===0&&++i}return o}function iC(e,t,r){let n=r,s=3,i=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%i!==0&&(n+=i-n%i);let a=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=a*3,l=vn(e.buffer,n,c,i);return n+=c*i,{triangleIndicesEndPosition:n,triangleIndices:l}}function aC(e,t,r){let n=r,s=3,i=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let c=vn(e.buffer,n,a,i,!1);n+=a*i;let l=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let u=vn(e.buffer,n,l,i,!1);n+=l*i;let f=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let h=vn(e.buffer,n,f,i,!1);n+=f*i;let d=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let p=vn(e.buffer,n,d,i,!1);return n+=d*i,{edgeIndicesEndPosition:n,westIndices:c,southIndices:u,eastIndices:h,northIndices:p}}function cC(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function lC(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function uC(e,t){let r={};if(e.byteLength<=t)return{extensions:r,extensionsEndPosition:t};let n=t;for(;n<e.byteLength;){let s=e.getUint8(n,!0);n+=Uint8Array.BYTES_PER_ELEMENT;let o=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;let i=new DataView(e.buffer,n,o);switch(s){case 1:{r.vertexNormals=cC(i);break}case 2:{r.waterMask=lC(i);break}default:}n+=o}return{extensions:r,extensionsEndPosition:n}}var rr={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},fC={maxDecodingStep:rr.extensions};function Gc(e,t){let r=Object.assign({},fC,t),n=new DataView(e),{header:s,headerEndPosition:o}=sC(n);if(r.maxDecodingStep<rr.vertices)return{header:s};let{vertexData:i,vertexDataEndPosition:a}=oC(n,o);if(r.maxDecodingStep<rr.triangleIndices)return{header:s,vertexData:i};let{triangleIndices:c,triangleIndicesEndPosition:l}=iC(n,i,a);if(r.maxDecodingStep<rr.edgeIndices)return{header:s,vertexData:i,triangleIndices:c};let{westIndices:u,southIndices:f,eastIndices:h,northIndices:d,edgeIndicesEndPosition:p}=aC(n,i,l);if(r.maxDecodingStep<rr.extensions)return{header:s,vertexData:i,triangleIndices:c,westIndices:u,northIndices:d,eastIndices:h,southIndices:f};let{extensions:A}=uC(n,p);return{header:s,vertexData:i,triangleIndices:c,westIndices:u,northIndices:d,eastIndices:h,southIndices:f,extensions:A}}function So(e,t,r,n){let s=n?dC(n,e.POSITION.value):hC(t),o=new e.POSITION.value.constructor(s.length*6),i=new e.TEXCOORD_0.value.constructor(s.length*4),a=new t.constructor(s.length*6);for(let l=0;l<s.length;l++){let u=s[l];pC({edge:u,edgeIndex:l,attributes:e,skirtHeight:r,newPosition:o,newTexcoord0:i,newTriangles:a})}e.POSITION.value=Xr(e.POSITION.value,o),e.TEXCOORD_0.value=Xr(e.TEXCOORD_0.value,i);let c=t instanceof Array?t.concat(a):Xr(t,a);return{attributes:e,triangles:c}}function hC(e){let t=[];for(let s=0;s<e.length;s+=3)t.push([e[s],e[s+1]]),t.push([e[s+1],e[s+2]]),t.push([e[s+2],e[s]]);t.sort((s,o)=>Math.min(...s)-Math.min(...o)||Math.max(...s)-Math.max(...o));let r=[],n=0;for(;n<t.length;)t[n][0]===t[n+1]?.[1]&&t[n][1]===t[n+1]?.[0]?n+=2:(r.push(t[n]),n++);return r}function dC(e,t){e.westIndices.sort((n,s)=>t[3*n+1]-t[3*s+1]),e.eastIndices.sort((n,s)=>t[3*s+1]-t[3*n+1]),e.southIndices.sort((n,s)=>t[3*s]-t[3*n]),e.northIndices.sort((n,s)=>t[3*n]-t[3*s]);let r=[];for(let n in e){let s=e[n];for(let o=0;o<s.length-1;o++)r.push([s[o],s[o+1]])}return r}function pC({edge:e,edgeIndex:t,attributes:r,skirtHeight:n,newPosition:s,newTexcoord0:o,newTriangles:i}){let a=r.POSITION.value.length,c=t*2,l=t*2+1;s.set(r.POSITION.value.subarray(e[0]*3,e[0]*3+3),c*3),s[c*3+2]=s[c*3+2]-n,s.set(r.POSITION.value.subarray(e[1]*3,e[1]*3+3),l*3),s[l*3+2]=s[l*3+2]-n,o.set(r.TEXCOORD_0.value.subarray(e[0]*2,e[0]*2+2),c*2),o.set(r.TEXCOORD_0.value.subarray(e[1]*2,e[1]*2+2),l*2);let u=t*2*3;i[u]=e[0],i[u+1]=a/3+l,i[u+2]=e[1],i[u+3]=a/3+l,i[u+4]=e[0],i[u+5]=a/3+c}function Vc(e,t={}){let{bounds:r}=t,{header:n,vertexData:s,triangleIndices:o,westIndices:i,northIndices:a,eastIndices:c,southIndices:l}=Gc(e,rr.triangleIndices),u=o,f=mC(s,n,r),h=Ke(f);if(t?.skirtHeight){let{attributes:d,triangles:p}=So(f,u,t.skirtHeight,{westIndices:i,northIndices:a,eastIndices:c,southIndices:l});f=d,u=p}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:h},schema:void 0,topology:"triangle-list",mode:4,indices:{value:u,size:1},attributes:f}}function mC(e,t,r){let{minHeight:n,maxHeight:s}=t,[o,i,a,c]=r||[0,0,1,1],l=a-o,u=c-i,f=s-n,h=e.length/3,d=new Float32Array(h*3),p=new Float32Array(h*2);for(let A=0;A<h;A++){let g=e[A]/32767,y=e[A+h]/32767,E=e[A+h*2]/32767;d[3*A+0]=g*l+o,d[3*A+1]=y*u+i,d[3*A+2]=E*f+n,p[2*A+0]=g,p[2*A+1]=y}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:p,size:2}}}var Un=class{constructor(t=257){this.gridSize=t;let r=t-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let n=0;n<this.numTriangles;n++){let s=n+2,o=0,i=0,a=0,c=0,l=0,u=0;for(s&1?a=c=l=r:o=i=u=r;(s>>=1)>1;){let h=o+a>>1,d=i+c>>1;s&1?(a=o,c=i,o=l,i=u):(o=a,i=c,a=l,c=u),l=h,u=d}let f=n*4;this.coords[f+0]=o,this.coords[f+1]=i,this.coords[f+2]=a,this.coords[f+3]=c}}createTile(t){return new Hc(t,this)}},Hc=class{constructor(t,r){let n=r.gridSize;if(t.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${t.length}.`);this.terrain=t,this.martini=r,this.errors=new Float32Array(t.length),this.update()}update(){let{numTriangles:t,numParentTriangles:r,coords:n,gridSize:s}=this.martini,{terrain:o,errors:i}=this;for(let a=t-1;a>=0;a--){let c=a*4,l=n[c+0],u=n[c+1],f=n[c+2],h=n[c+3],d=l+f>>1,p=u+h>>1,A=d+p-u,g=p+l-d,y=(o[u*s+l]+o[h*s+f])/2,E=p*s+d,_=Math.abs(y-o[E]);if(i[E]=Math.max(i[E],_),a<r){let B=(u+g>>1)*s+(l+A>>1),S=(h+g>>1)*s+(f+A>>1);i[E]=Math.max(i[E],i[B],i[S])}}}getMesh(t=0){let{gridSize:r,indices:n}=this.martini,{errors:s}=this,o=0,i=0,a=r-1;n.fill(0);function c(d,p,A,g,y,E){let _=d+A>>1,B=p+g>>1;Math.abs(d-y)+Math.abs(p-E)>1&&s[B*r+_]>t?(c(y,E,d,p,_,B),c(A,g,y,E,_,B)):(n[p*r+d]=n[p*r+d]||++o,n[g*r+A]=n[g*r+A]||++o,n[E*r+y]=n[E*r+y]||++o,i++)}c(0,0,a,a,a,0),c(a,a,0,0,0,a);let l=new Uint16Array(o*2),u=new Uint32Array(i*3),f=0;function h(d,p,A,g,y,E){let _=d+A>>1,B=p+g>>1;if(Math.abs(d-y)+Math.abs(p-E)>1&&s[B*r+_]>t)h(y,E,d,p,_,B),h(A,g,y,E,_,B);else{let S=n[p*r+d]-1,b=n[g*r+A]-1,w=n[E*r+y]-1;l[2*S]=d,l[2*S+1]=p,l[2*b]=A,l[2*b+1]=g,l[2*w]=y,l[2*w+1]=E,u[f++]=S,u[f++]=b,u[f++]=w}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:l,triangles:u}}};var Gn=class{constructor(t,r,n=r){this.data=t,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let s=r-1,o=n-1,i=this._addPoint(0,0),a=this._addPoint(s,0),c=this._addPoint(0,o),l=this._addPoint(s,o),u=this._addTriangle(l,i,c,-1,-1,-1);this._addTriangle(i,l,a,u,-1,-1),this._flush()}run(t=1){for(;this.getMaxError()>t;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(t,r){return this.data[this.width*r+t]}_flush(){let t=this.coords;for(let r=0;r<this._pendingLen;r++){let n=this._pending[r],s=2*this.triangles[n*3+0],o=2*this.triangles[n*3+1],i=2*this.triangles[n*3+2];this._findCandidate(t[s],t[s+1],t[o],t[o+1],t[i],t[i+1],n)}this._pendingLen=0}_findCandidate(t,r,n,s,o,i,a){let c=Math.min(t,n,o),l=Math.min(r,s,i),u=Math.max(t,n,o),f=Math.max(r,s,i),h=nr(n,s,o,i,c,l),d=nr(o,i,t,r,c,l),p=nr(t,r,n,s,c,l),A=s-r,g=t-n,y=i-s,E=n-o,_=r-i,B=o-t,S=nr(t,r,n,s,o,i),b=this.heightAt(t,r)/S,w=this.heightAt(n,s)/S,C=this.heightAt(o,i)/S,T=0,m=0,M=0,F=0;for(let R=l;R<=f;R++){let L=0;h<0&&y!==0&&(L=Math.max(L,Math.floor(-h/y))),d<0&&_!==0&&(L=Math.max(L,Math.floor(-d/_))),p<0&&A!==0&&(L=Math.max(L,Math.floor(-p/A)));let D=h+y*L,X=d+_*L,H=p+A*L,Q=!1;for(let j=c+L;j<=u;j++){if(D>=0&&X>=0&&H>=0){Q=!0;let W=b*D+w*X+C*H,$=Math.abs(W-this.heightAt(j,R));F+=$*$,$>T&&(T=$,m=j,M=R)}else if(Q)break;D+=y,X+=_,H+=A}h+=E,d+=B,p+=g}(m===t&&M===r||m===n&&M===s||m===o&&M===i)&&(T=0),this._candidates[2*a]=m,this._candidates[2*a+1]=M,this._rms[a]=F,this._queuePush(a,T,F)}_step(){let t=this._queuePop(),r=t*3+0,n=t*3+1,s=t*3+2,o=this.triangles[r],i=this.triangles[n],a=this.triangles[s],c=this.coords[2*o],l=this.coords[2*o+1],u=this.coords[2*i],f=this.coords[2*i+1],h=this.coords[2*a],d=this.coords[2*a+1],p=this._candidates[2*t],A=this._candidates[2*t+1],g=this._addPoint(p,A);if(nr(c,l,u,f,p,A)===0)this._handleCollinear(g,r);else if(nr(u,f,h,d,p,A)===0)this._handleCollinear(g,n);else if(nr(h,d,c,l,p,A)===0)this._handleCollinear(g,s);else{let y=this._halfedges[r],E=this._halfedges[n],_=this._halfedges[s],B=this._addTriangle(o,i,g,y,-1,-1,r),S=this._addTriangle(i,a,g,E,-1,B+1),b=this._addTriangle(a,o,g,_,B+2,S+1);this._legalize(B),this._legalize(S),this._legalize(b)}}_addPoint(t,r){let n=this.coords.length>>1;return this.coords.push(t,r),n}_addTriangle(t,r,n,s,o,i,a=this.triangles.length){let c=a/3;return this.triangles[a+0]=t,this.triangles[a+1]=r,this.triangles[a+2]=n,this._halfedges[a+0]=s,this._halfedges[a+1]=o,this._halfedges[a+2]=i,s>=0&&(this._halfedges[s]=a+0),o>=0&&(this._halfedges[o]=a+1),i>=0&&(this._halfedges[i]=a+2),this._candidates[2*c+0]=0,this._candidates[2*c+1]=0,this._queueIndices[c]=-1,this._rms[c]=0,this._pending[this._pendingLen++]=c,a}_legalize(t){let r=this._halfedges[t];if(r<0)return;let n=t-t%3,s=r-r%3,o=n+(t+1)%3,i=n+(t+2)%3,a=s+(r+2)%3,c=s+(r+1)%3,l=this.triangles[i],u=this.triangles[t],f=this.triangles[o],h=this.triangles[a],d=this.coords;if(!gC(d[2*l],d[2*l+1],d[2*u],d[2*u+1],d[2*f],d[2*f+1],d[2*h],d[2*h+1]))return;let p=this._halfedges[o],A=this._halfedges[i],g=this._halfedges[a],y=this._halfedges[c];this._queueRemove(n/3),this._queueRemove(s/3);let E=this._addTriangle(l,h,f,-1,g,p,n),_=this._addTriangle(h,l,u,E,A,y,s);this._legalize(E+1),this._legalize(_+2)}_handleCollinear(t,r){let n=r-r%3,s=n+(r+1)%3,o=n+(r+2)%3,i=this.triangles[o],a=this.triangles[r],c=this.triangles[s],l=this._halfedges[s],u=this._halfedges[o],f=this._halfedges[r];if(f<0){let b=this._addTriangle(t,i,a,-1,u,-1,n),w=this._addTriangle(i,t,c,b,-1,l);this._legalize(b+1),this._legalize(w+2);return}let h=f-f%3,d=h+(f+2)%3,p=h+(f+1)%3,A=this.triangles[d],g=this._halfedges[d],y=this._halfedges[p];this._queueRemove(h/3);let E=this._addTriangle(i,a,t,u,-1,-1,n),_=this._addTriangle(a,A,t,y,-1,E+1,h),B=this._addTriangle(A,c,t,g,-1,_+1),S=this._addTriangle(c,i,t,l,E+2,B+1);this._legalize(E),this._legalize(_),this._legalize(B),this._legalize(S)}_queuePush(t,r,n){let s=this._queue.length;this._queueIndices[t]=s,this._queue.push(t),this._errors.push(r),this._rmsSum+=n,this._queueUp(s)}_queuePop(){let t=this._queue.length-1;return this._queueSwap(0,t),this._queueDown(0,t),this._queuePopBack()}_queuePopBack(){let t=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[t],this._queueIndices[t]=-1,t}_queueRemove(t){let r=this._queueIndices[t];if(r<0){let s=this._pending.indexOf(t);if(s!==-1)this._pending[s]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let n=this._queue.length-1;n!==r&&(this._queueSwap(r,n),this._queueDown(r,n)||this._queueUp(r)),this._queuePopBack()}_queueLess(t,r){return this._errors[t]>this._errors[r]}_queueSwap(t,r){let n=this._queue[t],s=this._queue[r];this._queue[t]=s,this._queue[r]=n,this._queueIndices[n]=r,this._queueIndices[s]=t;let o=this._errors[t];this._errors[t]=this._errors[r],this._errors[r]=o}_queueUp(t){let r=t;for(;;){let n=r-1>>1;if(n===r||!this._queueLess(r,n))break;this._queueSwap(n,r),r=n}}_queueDown(t,r){let n=t;for(;;){let s=2*n+1;if(s>=r||s<0)break;let o=s+1,i=s;if(o<r&&this._queueLess(o,s)&&(i=o),!this._queueLess(i,n))break;this._queueSwap(n,i),n=i}return n>t}};function nr(e,t,r,n,s,o){return(r-s)*(t-o)-(n-o)*(e-s)}function gC(e,t,r,n,s,o,i,a){let c=e-i,l=t-a,u=r-i,f=n-a,h=s-i,d=o-a,p=c*c+l*l,A=u*u+f*f,g=h*h+d*d;return c*(f*g-A*d)-l*(u*g-A*h)+p*(u*d-f*h)<0}function um(e,t){let{meshMaxError:r,bounds:n,elevationDecoder:s}=t,{data:o,width:i,height:a}=e,c,l;switch(t.tesselator){case"martini":c=bo(o,i,a,s,t.tesselator),l=cm(r,i,c);break;case"delatin":c=bo(o,i,a,s,t.tesselator),l=lm(r,i,a,c);break;default:i===a&&!(a&i-1)?(c=bo(o,i,a,s,"martini"),l=cm(r,i,c)):(c=bo(o,i,a,s,"delatin"),l=lm(r,i,a,c));break}let{vertices:u}=l,{triangles:f}=l,h=AC(u,c,i,a,n),d=Ke(h);if(t.skirtHeight){let{attributes:p,triangles:A}=So(h,f,t.skirtHeight);h=p,f=A}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:d},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:h}}function cm(e,t,r){let n=t+1,o=new Un(n).createTile(r),{vertices:i,triangles:a}=o.getMesh(e);return{vertices:i,triangles:a}}function lm(e,t,r,n){let s=new Gn(n,t+1,r+1);s.run(e);let{coords:o,triangles:i}=s;return{vertices:o,triangles:i}}function bo(e,t,r,n,s){let{rScaler:o,bScaler:i,gScaler:a,offset:c}=n,l=new Float32Array((t+1)*(r+1));for(let u=0,f=0;f<r;f++)for(let h=0;h<t;h++,u++){let d=u*4,p=e[d+0],A=e[d+1],g=e[d+2];l[u+f]=p*o+A*a+g*i+c}if(s==="martini"){for(let u=(t+1)*t,f=0;f<t;f++,u++)l[u]=l[u-t-1];for(let u=r,f=0;f<r+1;f++,u+=r+1)l[u]=l[u-1]}return l}function AC(e,t,r,n,s){let o=r+1,i=e.length/2,a=new Float32Array(i*3),c=new Float32Array(i*2),[l,u,f,h]=s||[0,0,r,n],d=(f-l)/r,p=(h-u)/n;for(let A=0;A<i;A++){let g=e[A*2],y=e[A*2+1],E=y*o+g;a[3*A+0]=g*d+l,a[3*A+1]=-y*p+h,a[3*A+2]=t[E],c[2*A+0]=g/r,c[2*A+1]=y/n}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:c,size:2}}}var Mo="4.2.0-beta.2";var Io={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:Mo,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var fm={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:Mo,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var xC={...Io,parse:yC};async function yC(e,t,r){let n={...t,mimeType:"application/x.image",image:{...t?.image,type:"data"}},s=await Et(e,[],n,r),o={...xC.options.terrain,...t?.terrain};return um(s,o)}var zG={...fm,parseSync:(e,t)=>Vc(e,t?.["quantized-mesh"]),parse:async(e,t)=>Vc(e,t?.["quantized-mesh"])};var hm=[1],TC={...qe.defaultProps,elevationData:Ce,texture:{...Ce,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[Io]};function dm(e){return Array.isArray(e)?e.join(";"):e||""}var Vn=class extends wo.CompositeLayer{updateState({props:t,oldProps:r}){let n=t.elevationData!==r.elevationData;if(n){let{elevationData:o}=t,i=o&&(Array.isArray(o)||o.includes("{x}")&&o.includes("{y}"));this.setState({isTiled:i})}let s=n||t.meshMaxError!==r.meshMaxError||t.elevationDecoder!==r.elevationDecoder||t.bounds!==r.bounds;if(!this.state.isTiled&&s){let o=this.loadTerrain(t);this.setState({terrain:o})}t.workerUrl&&wo.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:t,bounds:r,elevationDecoder:n,meshMaxError:s,signal:o}){if(!t)return null;let i=this.getLoadOptions();i={...i,terrain:{skirtHeight:this.state.isTiled?s*2:0,...i?.terrain,bounds:r,meshMaxError:s,elevationDecoder:n}};let{fetch:a}=this.props;return a(t,{propName:"elevationData",layer:this,loadOptions:i,signal:o})}getTiledTerrainData(t){let{elevationData:r,fetch:n,texture:s,elevationDecoder:o,meshMaxError:i}=this.props,{viewport:a}=this.context,c=Qt(r,t),l=s&&Qt(s,t),{signal:u}=t,f=[0,0],h=[0,0];if(a.isGeospatial){let g=t.bbox;f=a.projectFlat([g.west,g.south]),h=a.projectFlat([g.east,g.north])}else{let g=t.bbox;f=[g.left,g.bottom],h=[g.right,g.top]}let d=[f[0],f[1],h[0],h[1]],p=this.loadTerrain({elevationData:c,bounds:d,elevationDecoder:o,meshMaxError:i,signal:u}),A=l?n(l,{propName:"texture",layer:this,loaders:[],signal:u}).catch(g=>null):Promise.resolve(null);return Promise.all([p,A])}renderSubLayers(t){let r=this.getSubLayerClass("mesh",zc.SimpleMeshLayer),{color:n,wireframe:s,material:o}=this.props,{data:i}=t;if(!i)return null;let[a,c]=i;return new r(t,{data:hm,mesh:a,texture:c,_instanced:!1,coordinateSystem:pm.COORDINATE_SYSTEM.CARTESIAN,getPosition:l=>[0,0,0],getColor:n,wireframe:s,material:o})}onViewportLoad(t){if(!t)return;let{zRange:r}=this.state,n=t.map(i=>i.content).filter(Boolean).map(i=>i[0].header.boundingBox.map(c=>c[2]));if(n.length===0)return;let s=Math.min(...n.map(i=>i[0])),o=Math.max(...n.map(i=>i[1]));(!r||s<r[0]||o>r[1])&&this.setState({zRange:[s,o]})}renderLayers(){let{color:t,material:r,elevationData:n,texture:s,wireframe:o,meshMaxError:i,elevationDecoder:a,tileSize:c,maxZoom:l,minZoom:u,extent:f,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:A,maxCacheSize:g,maxCacheByteSize:y,refinementStrategy:E}=this.props;if(this.state.isTiled)return new qe(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:dm(n),texture:dm(s),meshMaxError:i,elevationDecoder:a}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:c,maxZoom:l,minZoom:u,extent:f,maxRequests:h,onTileLoad:d,onTileUnload:p,onTileError:A,maxCacheSize:g,maxCacheByteSize:y,refinementStrategy:E});if(!n)return null;let _=this.getSubLayerClass("mesh",zc.SimpleMeshLayer);return new _(this.getSubLayerProps({id:"mesh"}),{data:hm,mesh:this.state.terrain,texture:s,_instanced:!1,getPosition:B=>[0,0,0],getColor:t,material:r,wireframe:o})}};Vn.defaultProps=TC;Vn.layerName="TerrainLayer";var mm=Vn;var qo=N(Nt(),1),al=N(Ot(),1),Ym=N(Am(),1);var Hn={x:0,y:1,z:2};function sr(e,t={}){let{start:r=0,end:n=e.length,plane:s="xy"}=t,o=t.size||2,i=0,a=Hn[s[0]],c=Hn[s[1]];for(let l=r,u=n-o;l<n;l+=o)i+=(e[l+a]-e[u+a])*(e[l+c]+e[u+c]),u=l;return i/2}function Jc(e,t,r=2,n,s="xy"){let o=t&&t.length,i=o?t[0]*r:e.length,a=ym(e,0,i,r,!0,n&&n[0],s),c=[];if(!a||a.next===a.prev)return c;let l,u,f,h,d,p,A;if(o&&(a=MC(e,t,a,r,n,s)),e.length>80*r){h=u=e[0],d=f=e[1];for(let g=r;g<i;g+=r)p=e[g],A=e[g+1],p<h&&(h=p),A<d&&(d=A),p>u&&(u=p),A>f&&(f=A);l=Math.max(u-h,f-d),l=l!==0?32767/l:0}return zn(a,c,r,h,d,l,0),c}function ym(e,t,r,n,s,o,i){let a,c;o===void 0&&(o=sr(e,{start:t,end:r,size:n,plane:i}));let l=Hn[i[0]],u=Hn[i[1]];if(s===o<0)for(a=t;a<r;a+=n)c=xm(a,e[a+l],e[a+u],c);else for(a=r-n;a>=t;a-=n)c=xm(a,e[a+l],e[a+u],c);return c&&Ro(c,c.next)&&(Jn(c),c=c.next),c}function or(e,t){if(!e)return e;t||(t=e);let r=e,n;do if(n=!1,!r.steiner&&(Ro(r,r.next)||et(r.prev,r,r.next)===0)){if(Jn(r),r=t=r.prev,r===r.next)break;n=!0}else r=r.next;while(n||r!==t);return t}function zn(e,t,r,n,s,o,i){if(!e)return;!i&&o&&RC(e,n,s,o);let a=e,c,l;for(;e.prev!==e.next;){if(c=e.prev,l=e.next,o?CC(e,n,s,o):BC(e)){t.push(c.i/r|0),t.push(e.i/r|0),t.push(l.i/r|0),Jn(e),e=l.next,a=l.next;continue}if(e=l,e===a){i?i===1?(e=SC(or(e),t,r),zn(e,t,r,n,s,o,2)):i===2&&bC(e,t,r,n,s,o):zn(or(e),t,r,n,s,o,1);break}}}function BC(e){let t=e.prev,r=e,n=e.next;if(et(t,r,n)>=0)return!1;let s=t.x,o=r.x,i=n.x,a=t.y,c=r.y,l=n.y,u=s<o?s<i?s:i:o<i?o:i,f=a<c?a<l?a:l:c<l?c:l,h=s>o?s>i?s:i:o>i?o:i,d=a>c?a>l?a:l:c>l?c:l,p=n.next;for(;p!==t;){if(p.x>=u&&p.x<=h&&p.y>=f&&p.y<=d&&vr(s,a,o,c,i,l,p.x,p.y)&&et(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function CC(e,t,r,n){let s=e.prev,o=e,i=e.next;if(et(s,o,i)>=0)return!1;let a=s.x,c=o.x,l=i.x,u=s.y,f=o.y,h=i.y,d=a<c?a<l?a:l:c<l?c:l,p=u<f?u<h?u:h:f<h?f:h,A=a>c?a>l?a:l:c>l?c:l,g=u>f?u>h?u:h:f>h?f:h,y=kc(d,p,t,r,n),E=kc(A,g,t,r,n),_=e.prevZ,B=e.nextZ;for(;_&&_.z>=y&&B&&B.z<=E;){if(_.x>=d&&_.x<=A&&_.y>=p&&_.y<=g&&_!==s&&_!==i&&vr(a,u,c,f,l,h,_.x,_.y)&&et(_.prev,_,_.next)>=0||(_=_.prevZ,B.x>=d&&B.x<=A&&B.y>=p&&B.y<=g&&B!==s&&B!==i&&vr(a,u,c,f,l,h,B.x,B.y)&&et(B.prev,B,B.next)>=0))return!1;B=B.nextZ}for(;_&&_.z>=y;){if(_.x>=d&&_.x<=A&&_.y>=p&&_.y<=g&&_!==s&&_!==i&&vr(a,u,c,f,l,h,_.x,_.y)&&et(_.prev,_,_.next)>=0)return!1;_=_.prevZ}for(;B&&B.z<=E;){if(B.x>=d&&B.x<=A&&B.y>=p&&B.y<=g&&B!==s&&B!==i&&vr(a,u,c,f,l,h,B.x,B.y)&&et(B.prev,B,B.next)>=0)return!1;B=B.nextZ}return!0}function SC(e,t,r){let n=e;do{let s=n.prev,o=n.next.next;!Ro(s,o)&&Tm(s,n,n.next,o)&&kn(s,o)&&kn(o,s)&&(t.push(s.i/r|0),t.push(n.i/r|0),t.push(o.i/r|0),Jn(n),Jn(n.next),n=e=o),n=n.next}while(n!==e);return or(n)}function bC(e,t,r,n,s,o){let i=e;do{let a=i.next.next;for(;a!==i.prev;){if(i.i!==a.i&&NC(i,a)){let c=_m(i,a);i=or(i,i.next),c=or(c,c.next),zn(i,t,r,n,s,o,0),zn(c,t,r,n,s,o,0);return}a=a.next}i=i.next}while(i!==e)}function MC(e,t,r,n,s,o){let i=[],a,c,l,u,f;for(a=0,c=t.length;a<c;a++)l=t[a]*n,u=a<c-1?t[a+1]*n:e.length,f=ym(e,l,u,n,!1,s&&s[a+1],o),f===f.next&&(f.steiner=!0),i.push(OC(f));for(i.sort(IC),a=0;a<i.length;a++)r=wC(i[a],r);return r}function IC(e,t){return e.x-t.x}function wC(e,t){let r=LC(e,t);if(!r)return t;let n=_m(r,e);return or(n,n.next),or(r,r.next)}function LC(e,t){let r=t,n=e.x,s=e.y,o=-1/0,i;do{if(s<=r.y&&s>=r.next.y&&r.next.y!==r.y){let h=r.x+(s-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(h<=n&&h>o&&(o=h,i=r.x<r.next.x?r:r.next,h===n))return i}r=r.next}while(r!==t);if(!i)return null;let a=i,c=i.x,l=i.y,u=1/0,f;r=i;do n>=r.x&&r.x>=c&&n!==r.x&&vr(s<l?n:o,s,c,l,s<l?o:n,s,r.x,r.y)&&(f=Math.abs(s-r.y)/(n-r.x),kn(r,e)&&(f<u||f===u&&(r.x>i.x||r.x===i.x&&FC(i,r)))&&(i=r,u=f)),r=r.next;while(r!==a);return i}function FC(e,t){return et(e.prev,e,t.prev)<0&&et(t.next,e,e.next)<0}function RC(e,t,r,n){let s=e;do s.z===0&&(s.z=kc(s.x,s.y,t,r,n)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,PC(s)}function PC(e){let t,r,n=1,s,o,i,a,c,l;do{for(o=e,e=null,l=null,s=0;o;){for(s++,a=o,i=0,r=0;r<n&&(i++,a=a.nextZ,!!a);r++);for(c=n;i>0||c>0&&a;)i!==0&&(c===0||!a||o.z<=a.z)?(t=o,o=o.nextZ,i--):(t=a,a=a.nextZ,c--),l?l.nextZ=t:e=t,t.prevZ=l,l=t;o=a}l.nextZ=null,n*=2}while(s>1);return e}function kc(e,t,r,n,s){return e=(e-r)*s|0,t=(t-n)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function OC(e){let t=e,r=e;do(t.x<r.x||t.x===r.x&&t.y<r.y)&&(r=t),t=t.next;while(t!==e);return r}function vr(e,t,r,n,s,o,i,a){return(s-i)*(t-a)>=(e-i)*(o-a)&&(e-i)*(n-a)>=(r-i)*(t-a)&&(r-i)*(o-a)>=(s-i)*(n-a)}function NC(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!DC(e,t)&&(kn(e,t)&&kn(t,e)&&vC(e,t)&&(et(e.prev,e,t.prev)||et(e,t.prev,t))||Ro(e,t)&&et(e.prev,e,e.next)>0&&et(t.prev,t,t.next)>0)}function et(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function Ro(e,t){return e.x===t.x&&e.y===t.y}function Tm(e,t,r,n){let s=Fo(et(e,t,r)),o=Fo(et(e,t,n)),i=Fo(et(r,n,e)),a=Fo(et(r,n,t));return!!(s!==o&&i!==a||s===0&&Lo(e,r,t)||o===0&&Lo(e,n,t)||i===0&&Lo(r,e,n)||a===0&&Lo(r,t,n))}function Lo(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function Fo(e){return e>0?1:e<0?-1:0}function DC(e,t){let r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&Tm(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}function kn(e,t){return et(e.prev,e,e.next)<0?et(e,t,e.next)>=0&&et(e,e.prev,t)>=0:et(e,t,e.prev)<0||et(e,e.next,t)<0}function vC(e,t){let r=e,n=!1,s=(e.x+t.x)/2,o=(e.y+t.y)/2;do r.y>o!=r.next.y>o&&r.next.y!==r.y&&s<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next;while(r!==e);return n}function _m(e,t){let r=new qn(e.i,e.x,e.y),n=new qn(t.i,t.x,t.y),s=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=s,s.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function xm(e,t,r,n){let s=new qn(e,t,r);return n?(s.next=n.next,s.prev=n,n.next.prev=s,n.next=s):(s.prev=s,s.next=s),s}function Jn(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var qn=class{constructor(t,r,n){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=r,this.y=n}};function Xc(e,t,r){let n=zC(e),s=Object.keys(n).filter(o=>n[o]!==Array);return kC(e,{propArrayTypes:n,...t},{numericPropKeys:r&&r.numericPropKeys||s,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function zC(e){let t={};for(let r of e)if(r.properties)for(let n in r.properties){let s=r.properties[n];t[n]=YC(s,t[n])}return t}function kC(e,t,r){let{pointPositionsCount:n,pointFeaturesCount:s,linePositionsCount:o,linePathsCount:i,lineFeaturesCount:a,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:f,propArrayTypes:h,coordLength:d}=t,{numericPropKeys:p=[],PositionDataType:A=Float32Array,triangulate:g=!0}=r,y=e[0]&&"id"in e[0],E=e.length>65535?Uint32Array:Uint16Array,_={type:"Point",positions:new A(n*d),globalFeatureIds:new E(n),featureIds:s>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:[],fields:[]},B={type:"LineString",pathIndices:o>65535?new Uint32Array(i+1):new Uint16Array(i+1),positions:new A(o*d),globalFeatureIds:new E(o),featureIds:a>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},S={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new A(c*d),globalFeatureIds:new E(c),featureIds:f>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};g&&(S.triangles=[]);for(let w of[_,B,S])for(let C of p){let T=h[C];w.numericProps[C]=new T(w.positions.length/d)}B.pathIndices[i]=o,S.polygonIndices[l]=c,S.primitivePolygonIndices[u]=c;let b={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let w of e){let C=w.geometry,T=w.properties||{};switch(C.type){case"Point":JC(C,_,b,d,T),_.properties.push(jc(T,p)),y&&_.fields.push({id:w.id}),b.pointFeature++;break;case"LineString":qC(C,B,b,d,T),B.properties.push(jc(T,p)),y&&B.fields.push({id:w.id}),b.lineFeature++;break;case"Polygon":jC(C,S,b,d,T),S.properties.push(jc(T,p)),y&&S.fields.push({id:w.id}),b.polygonFeature++;break;default:throw new Error("Invalid geometry type")}b.feature++}return WC(_,B,S,d)}function JC(e,t,r,n,s){t.positions.set(e.data,r.pointPosition*n);let o=e.data.length/n;Wc(t,s,r.pointPosition,o),t.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+o),t.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+o),r.pointPosition+=o}function qC(e,t,r,n,s){t.positions.set(e.data,r.linePosition*n);let o=e.data.length/n;Wc(t,s,r.linePosition,o),t.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+o),t.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+o);for(let i=0,a=e.indices.length;i<a;++i){let c=e.indices[i],l=i===a-1?e.data.length:e.indices[i+1];t.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/n}}function jC(e,t,r,n,s){t.positions.set(e.data,r.polygonPosition*n);let o=e.data.length/n;Wc(t,s,r.polygonPosition,o),t.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+o),t.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+o);for(let i=0,a=e.indices.length;i<a;++i){let c=r.polygonPosition;t.polygonIndices[r.polygonObject++]=c;let l=e.areas[i],u=e.indices[i],f=e.indices[i+1];for(let d=0,p=u.length;d<p;++d){let A=u[d],g=d===p-1?f===void 0?e.data.length:f[0]:u[d+1];t.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(g-A)/n}let h=r.polygonPosition;XC(t,l,u,{startPosition:c,endPosition:h,coordLength:n})}}function XC(e,t,r,{startPosition:n,endPosition:s,coordLength:o}){if(!e.triangles)return;let i=n*o,a=s*o,c=e.positions.subarray(i,a),l=r[0],u=r.slice(1).map(h=>(h-l)/o),f=Jc(c,u,o,t);for(let h=0,d=f.length;h<d;++h)e.triangles.push(n+f[h])}function qc(e,t){let r={};for(let n in e)r[n]={value:e[n],size:t};return r}function WC(e,t,r,n){let s={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:n},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:qc(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:n},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:qc(t.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:n},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:qc(r.numericProps,1)}};return s.polygons&&r.triangles&&(s.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),s}function Wc(e,t,r,n){for(let s in e.numericProps)if(s in t){let o=t[s];e.numericProps[s].fill(o,r,r+n)}}function jc(e,t){let r={};for(let n in e)t.includes(n)||(r[n]=e[n]);return r}function YC(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}function No(e,t){let r=t?.globalFeatureId;return r!==void 0?KC(e,r):QC(e,t?.type)}function KC(e,t){let r=Sm(e);for(let n of r){let s=0,o=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let a=n.featureIds.value[i];if(a!==o){if(t===n.globalFeatureIds.value[s])return Po(n,s,i);s=i,o=a}}if(t===n.globalFeatureIds.value[s])return Po(n,s,n.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}function QC(e,t){let r=Sm(e,t);return ZC(r)}function Cm(e,t,r){switch(e.type){case"Point":return rS(e,t,r);case"LineString":return eS(e,t,r);case"Polygon":return bm(e,t,r);default:let n=e;throw new Error(`Unsupported geometry type: ${n?.type}`)}}function Sm(e,t){let r=[];return e.points&&(e.points.type="Point",r.push(e.points)),e.lines&&(e.lines.type="LineString",r.push(e.lines)),e.polygons&&(e.polygons.type="Polygon",r.push(e.polygons)),r}function ZC(e){let t=[];for(let r of e){if(r.featureIds.value.length===0)continue;let n=0,s=r.featureIds.value[0];for(let o=0;o<r.featureIds.value.length;o++){let i=r.featureIds.value[o];i!==s&&(t.push(Po(r,n,o)),n=o,s=i)}t.push(Po(r,n,r.featureIds.value.length))}return t}function Po(e,t,r){let n=Cm(e,t,r),s=tS(e,t,r),o=$C(e,t,r);return{type:"Feature",geometry:n,properties:s,...o}}function $C(e,t=0,r){return e.fields&&e.fields[e.featureIds.value[t]]}function tS(e,t=0,r){let n=Object.assign({},e.properties[e.featureIds.value[t]]);for(let s in e.numericProps)n[s]=e.numericProps[s].value[t];return n}function bm(e,t=-1/0,r=1/0){let{positions:n}=e,s=e.polygonIndices.value.filter(c=>c>=t&&c<=r),o=e.primitivePolygonIndices.value.filter(c=>c>=t&&c<=r);if(!(s.length>2)){let c=[];for(let l=0;l<o.length-1;l++){let u=o[l],f=o[l+1],h=Oo(n,u,f);c.push(h)}return{type:"Polygon",coordinates:c}}let a=[];for(let c=0;c<s.length-1;c++){let l=s[c],u=s[c+1],f=bm(e,l,u).coordinates;a.push(f)}return{type:"MultiPolygon",coordinates:a}}function eS(e,t=-1/0,r=1/0){let{positions:n}=e,s=e.pathIndices.value.filter(a=>a>=t&&a<=r);if(!(s.length>2))return{type:"LineString",coordinates:Oo(n,s[0],s[1])};let i=[];for(let a=0;a<s.length-1;a++){let c=Oo(n,s[a],s[a+1]);i.push(c)}return{type:"MultiLineString",coordinates:i}}function rS(e,t,r){let{positions:n}=e,s=Oo(n,t,r);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function Oo(e,t,r){t=t||0,r=r||e.value.length/e.size;let n=[];for(let s=t;s<r;s++){let o=Array();for(let i=s*e.size;i<(s+1)*e.size;i++)o.push(Number(e.value[i]));n.push(o)}return n}var el=N(Pm(),1);function Om(e){let t=e.length;if(t<=1)return[e];let r=[],n,s;for(let o=0;o<t;o++){let i=TS(e[o]);i!==0&&(s===void 0&&(s=i<0),s===i<0?(n&&r.push(n),n=[e[o]]):n&&n.push(e[o]))}return n&&r.push(n),r}function TS(e){let t=0;for(let r=0,n=e.length-1,s,o;r<e.length;n=r++)s=e[r],o=e[n],t+=(o[0]-s[0])*(s[1]+o[1]);return t}function Nm(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?_S(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function _S(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let n=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[n]=s}}var Vr=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,r,n,s,o){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=o,t.readFields(Nm,this,r)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,s=0,o=0,i=0,a=[],c;for(;t.pos<r;){if(s<=0){let l=t.readVarint();n=l&7,s=l>>3}if(s--,n===1||n===2)o+=t.readSVarint(),i+=t.readSVarint(),n===1&&(c&&a.push(c),c=[]),c&&c.push([o,i]);else if(n===7)c&&c.push(c[0].slice());else throw new Error(`unknown command ${n}`)}return c&&a.push(c),a}bbox(){let t=this._pbf;t.pos=this._geometry;let r=t.readVarint()+t.pos,n=1,s=0,o=0,i=0,a=1/0,c=-1/0,l=1/0,u=-1/0;for(;t.pos<r;){if(s<=0){let f=t.readVarint();n=f&7,s=f>>3}if(s--,n===1||n===2)o+=t.readSVarint(),i+=t.readSVarint(),o<a&&(a=o),o>c&&(c=o),i<l&&(l=i),i>u&&(u=i);else if(n!==7)throw new Error(`unknown command ${n}`)}return[a,l,c,u]}_toGeoJSON(t){let r=this.loadGeometry(),n=Vr.types[this.type],s,o;switch(this.type){case 1:let a=[];for(s=0;s<r.length;s++)a[s]=r[s][0];r=a,t(r,this);break;case 2:for(s=0;s<r.length;s++)t(r[s],this);break;case 3:for(r=Om(r),s=0;s<r.length;s++)for(o=0;o<r[s].length;o++)t(r[s][o],this);break}r.length===1?r=r[0]:n=`Multi${n}`;let i={type:"Feature",geometry:{type:n,coordinates:r},properties:this.properties};return this.id!==null&&(i.id=this.id),i}toGeoJSON(t){if(typeof t=="function")return this._toGeoJSON(t);let{x:r,y:n,z:s}=t,o=this.extent*Math.pow(2,s),i=this.extent*r,a=this.extent*n;function c(l){for(let u=0;u<l.length;u++){let f=l[u];f[0]=(f[0]+i)*360/o-180;let h=180-(f[1]+a)*360/o;f[1]=360/Math.PI*Math.atan(Math.exp(h*Math.PI/180))-90}}return this._toGeoJSON(c)}};var Uo=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(ES,this,r),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new Vr(this._pbf,r,this.extent,this._keys,this._values)}};function ES(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(BS(r)))}function BS(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}return t}var Go=class{layers;constructor(t,r){this.layers=t.readFields(CS,{},r)}};function CS(e,t,r){if(e===3&&r){let n=new Uo(r,r.readVarint()+r.pos);n.length&&t&&(t[n.name]=n)}}function Dm(e){let t=e.indices.length,r="Polygon";if(t<=1)return{type:r,data:e.data,areas:[[sr(e.data)]],indices:[e.indices]};let n=[],s=[],o=[],i=[],a,c=0;for(let l,u=0,f;u<t;u++){f=e.indices[u]-c,l=e.indices[u+1]-c||e.data.length;let h=e.data.slice(f,l),d=sr(h);if(d===0){let p=e.data.slice(0,f),A=e.data.slice(l);e.data=p.concat(A),c+=l-f;continue}a===void 0&&(a=d<0),a===d<0?(i.length&&(n.push(o),s.push(i)),i=[f],o=[d]):(o.push(d),i.push(f))}return o&&n.push(o),i.length&&s.push(i),{type:r,areas:n,indices:s,data:e.data}}function vm(e,t,r,n){for(let s=0,o=e.length;s<o;s+=2){e[s]=(e[s]+t)*360/n-180;let i=180-(e[s+1]+r)*360/n;e[s+1]=360/Math.PI*Math.atan(Math.exp(i*Math.PI/180))-90}}function Um(e,t,r){t&&r&&(e===1?t.id=r.readVarint():e===2?SS(r,t):e===3?t.type=r.readVarint():e===4&&(t._geometry=r.pos))}function SS(e,t){let r=e.readVarint()+e.pos;for(;e.pos<r;){let n=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[n]=s}}var Gm,ir,Qc,Vo,Zc,$c,jn;var Ho=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,r,n,s,o,i){this.properties={},this.extent=n,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=o,this._geometryInfo=i,t.readFields(Um,this,r)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,Gm=t.readVarint()+t.pos,ir=1,Vo=0,Zc=0,$c=0,jn=0;let r=[],n=[];for(;t.pos<Gm;)if(Vo<=0&&(Qc=t.readVarint(),ir=Qc&7,Vo=Qc>>3),Vo--,ir===1||ir===2)Zc+=t.readSVarint(),$c+=t.readSVarint(),ir===1&&r.push(jn),n.push(Zc,$c),jn+=2;else if(ir===7){if(jn>0){let s=r[r.length-1];n.push(n[s],n[s+1]),jn+=2}}else throw new Error(`unknown command ${ir}`);return{data:n,indices:r}}_toBinaryCoordinates(t){let r=this.loadGeometry(),n;t(r.data,this);let s=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=r.indices.length,n={type:"Point",...r};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=r.indices.length,this._geometryInfo.linePositionsCount+=r.data.length/s,n={type:"LineString",...r};break;case 3:n=Dm(r),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=n.indices.length;for(let i of n.indices)this._geometryInfo.polygonRingsCount+=i.length;this._geometryInfo.polygonPositionsCount+=n.data.length/s;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let o={type:"Feature",geometry:n,properties:this.properties};return this.id!==null&&(o.id=this.id),o}toBinaryCoordinates(t){if(typeof t=="function")return this._toBinaryCoordinates(t);let{x:r,y:n,z:s}=t,o=this.extent*Math.pow(2,s),i=this.extent*r,a=this.extent*n;return this._toBinaryCoordinates(c=>vm(c,i,a,o))}};var zo=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,r){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(bS,this,r),this.length=this._features.length}feature(t,r){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new Ho(this._pbf,n,this.extent,this._keys,this._values,r)}};function bS(e,t,r){t&&r&&(e===15?t.version=r.readVarint():e===1?t.name=r.readString():e===5?t.extent=r.readVarint():e===2?t._features.push(r.pos):e===3?t._keys.push(r.readString()):e===4&&t._values.push(MS(r)))}function MS(e){let t=null,r=e.readVarint()+e.pos;for(;e.pos<r;){let n=e.readVarint()>>3;t=n===1?e.readString():n===2?e.readFloat():n===3?e.readDouble():n===4?e.readVarint64():n===5?e.readVarint():n===6?e.readSVarint():n===7?e.readBoolean():null}return t}var ko=class{layers;constructor(t,r){this.layers=t.readFields(IS,{},r)}};function IS(e,t,r){if(e===3&&r){let n=new zo(r,r.readVarint()+r.pos);n.length&&t&&(t[n.name]=n)}}function rl(e,t){let r=LS(t),n=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(n){case"columnar-table":return{shape:"columnar-table",data:tl(e,r)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:Vm(e,r)};case"geojson":return Vm(e,r);case"binary-geometry":return tl(e,r);case"binary":return tl(e,r);default:throw new Error(n||"undefined shape")}}function tl(e,t){let[r,n]=wS(e,t),s=Xc(r,n);return s.byteLength=e.byteLength,s}function wS(e,t){let r=[],n={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[r,n];let s=new ko(new el.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(s.layers)).forEach(i=>{let a=s.layers[i];if(a)for(let c=0;c<a.length;c++){let l=a.feature(c,n),u=RS(l,t,i);r.push(u)}}),[r,n]}function Vm(e,t){if(e.byteLength<=0)return[];let r=[],n=new Go(new el.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(n.layers)).forEach(o=>{let i=n.layers[o];if(i)for(let a=0;a<i.length;a++){let c=i.feature(a),l=FS(c,t,o);r.push(l)}}),r}function LS(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:r}=e.mvt,n=r&&Number.isFinite(r.x)&&Number.isFinite(r.y)&&Number.isFinite(r.z);if(t&&!n)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function FS(e,t,r){let n=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:PS);return t.layerProperty&&(n.properties[t.layerProperty]=r),n}function RS(e,t,r){let n=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:OS);return t.layerProperty&&n.properties&&(n.properties[t.layerProperty]=r),n}function PS(e,t){let{extent:r}=t;for(let n=0;n<e.length;n++){let s=e[n];s[0]/=r,s[1]/=r}}function OS(e,t){let{extent:r}=t;for(let n=0,s=e.length;n<s;++n)e[n]/=r}var NS="4.2.0-beta.2",Jo={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:NS,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:null}}},DS={...Jo,parse:async(e,t)=>rl(e,t),parseSync:rl,binary:!0};var vS={Point:Hm,MultiPoint:US,LineString:zm,MultiLineString:GS,Polygon:km,MultiPolygon:VS};function Hm([e,t],[r,n],s){let o=Ae(r[0],n[0],e),i=Ae(r[1],n[1],t);return s.unprojectFlat([o,i])}function nl(e,t,r){return e.map(n=>Hm(n,t,r))}function US(e,t,r){return nl(e,t,r)}function zm(e,t,r){return nl(e,t,r)}function GS(e,t,r){return e.map(n=>zm(n,t,r))}function km(e,t,r){return e.map(n=>nl(n,t,r))}function VS(e,t,r){return e.map(n=>km(n,t,r))}function Jm(e,t,r){let n=r.projectFlat([t.west,t.north]),s=r.projectFlat([t.east,t.south]),o=[n,s];return{...e,coordinates:vS[e.type](e.coordinates,o,r)}}var HS=["points","lines","polygons"];function sl(e,t,r,n){for(let s of HS){let o=e[s]&&zS(e[s],t,r,n);if(o>=0)return o}return-1}function zS(e,t,r,n){let s=e.featureIds.value;if(!s.length)return-1;let o=0,i=s[s.length-1]+1;if(n){let c=kS(e,n);if(c)o=c[0],i=c[1]+1;else return-1}let a=-1;if(t in e.numericProps){let c=e.numericProps[t].value.findIndex((l,u)=>l===r&&s[u]>=o&&s[u]<i);return c>=0?e.globalFeatureIds.value[c]:-1}else t?a=qm(e.properties,c=>c[t]===r,o,i):e.fields&&(a=qm(e.fields,c=>c.id===r,o,i));return a>=0?JS(e,a):-1}function kS(e,t){if(!e.__layers){let r={},{properties:n}=e;for(let s=0;s<n.length;s++){let{layerName:o}=n[s];o&&(r[o]?r[o][1]=s:r[o]=[s,s])}e.__layers=r}return e.__layers[t]}function JS(e,t){if(!e.__ids){let r=[],n=e.featureIds.value,s=e.globalFeatureIds.value;for(let o=0;o<n.length;o++)r[n[o]]=s[o];e.__ids=r}return e.__ids[t]}function qm(e,t,r,n){for(let s=r;s<n;s++)if(t(e[s],s))return s;return-1}var ol=512,qS={...al.GeoJsonLayer.defaultProps,data:Ce,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[Jo],binary:!0},Xn=class extends qe{initializeState(){super.initializeState();let t=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:t,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:t,oldProps:r,context:n,changeFlags:s}){s.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:t,oldProps:r,context:n,changeFlags:s}),this._setWGS84PropertyForTiles());let{highlightColor:o}=t;o!==r.highlightColor&&Array.isArray(o)&&this.setState({highlightColor:o})}async _updateTileData(){let t=this.props.data,r=null;if(typeof t=="string"&&!pa(t)){let{onDataLoad:n,fetch:s}=this.props;this.setState({data:null,tileJSON:null});try{r=await s(t,{propName:"data",layer:this,loaders:[]})}catch(o){this.raiseError(o,"loading TileJSON"),t=null}n&&n(r,{propName:"data",layer:this})}else t&&typeof t=="object"&&"tilejson"in t&&(r=t);r&&(t=r.tiles),this.setState({data:t,tileJSON:r})}_getTilesetOptions(){let t=super._getTilesetOptions(),r=this.state.tileJSON,{minZoom:n,maxZoom:s}=this.props;return r&&(Number.isFinite(r.minzoom)&&r.minzoom>n&&(t.minZoom=r.minzoom),Number.isFinite(r.maxzoom)&&(!Number.isFinite(s)||r.maxzoom<s)&&(t.maxZoom=r.maxzoom)),t}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(t){let{data:r,binary:n}=this.state,{index:s,signal:o}=t,i=Qt(r,t);if(!i)return Promise.reject("Invalid URL");let a=this.getLoadOptions(),{fetch:c}=this.props;return a={...a,mimeType:"application/x-protobuf",mvt:{...a?.mvt,coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:s},gis:n?{format:"binary"}:{}},c(i,{propName:"data",layer:this,loadOptions:a,signal:o})}renderSubLayers(t){let{x:r,y:n,z:s}=t.tile.index,o=Math.pow(2,s),i=ol/o,a=-i,c=ol*r/o,l=ol*(1-n/o),u=new P().scale([i,a,1]);t.autoHighlight=!1,this.context.viewport.resolution||(t.modelMatrix=u,t.coordinateOrigin=[c,l,0],t.coordinateSystem=qo.COORDINATE_SYSTEM.CARTESIAN,t.extensions=[...t.extensions||[],new Ym.ClipExtension]);let f=super.renderSubLayers(t);return this.state.binary&&!(f instanceof al.GeoJsonLayer)&&qo.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),f}_updateAutoHighlight(t){let{uniqueIdProperty:r}=this.props,{hoveredFeatureId:n,hoveredFeatureLayerName:s}=this.state,o=t.object,i=null,a=null;o&&(i=il(o,r),a=jm(o));let{highlightColor:c}=this.props;typeof c=="function"&&(c=c(t)),(n!==i||s!==a)&&this.setState({highlightColor:c,hoveredFeatureId:i,hoveredFeatureLayerName:a})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(t){let r=super.getPickingInfo(t);if(this.state.binary&&r.index!==-1){let{data:n}=t.sourceLayer.props;r.object=No(n,{globalFeatureId:r.index})}return r.object&&!this._isWGS84()&&(r.object=Wm(r.object,r.tile.bbox,this.context.viewport)),r}getSubLayerPropsByTile(t){return{highlightedObjectIndex:this.getHighlightedObjectIndex(t),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(t){let{hoveredFeatureId:r,hoveredFeatureLayerName:n,binary:s}=this.state,{uniqueIdProperty:o,highlightedFeatureId:i}=this.props,a=t.content,c=Xm(i);if(!(Xm(r)||c))return-1;let u=c?i:r;return Array.isArray(a)?a.findIndex(f=>{let h=il(f,o)===u,d=c||jm(f)===n;return h&&d}):a&&s?sl(a,o,u,c?"":n):-1}_pickObjects(t){let{deck:r,viewport:n}=this.context,s=n.width,o=n.height,i=n.x,a=n.y,c=[this.id];return r.pickObjects({x:i,y:a,width:s,height:o,layerIds:c,maxObjects:t})}getRenderedFeatures(t=null){let r=this._pickObjects(t),n=new Set,s=[];for(let o of r){let i=il(o.object,this.props.uniqueIdProperty);i===void 0?s.push(o.object):n.has(i)||(n.add(i),s.push(o.object))}return s}_setWGS84PropertyForTiles(){let t="dataInWGS84";this.state.tileset.selectedTiles.forEach(n=>{n.hasOwnProperty(t)||Object.defineProperty(n,t,{get:()=>{if(!n.content)return null;if(this.state.binary&&Array.isArray(n.content)&&!n.content.length)return[];let{bbox:s}=n;if(n._contentWGS84===void 0&&ma(s)){let o=this.state.binary?No(n.content):n.content;n._contentWGS84=o.map(i=>Wm(i,s,this.context.viewport))}return n._contentWGS84}})})}};Xn.layerName="MVTLayer";Xn.defaultProps=qS;var Km=Xn;function il(e,t){if(e.properties&&t)return e.properties[t];if("id"in e)return e.id}function jm(e){return e.properties?.layerName||null}function Xm(e){return e!=null&&e!==""}function Wm(e,t,r){let n={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(n.geometry,"coordinates",{get:()=>Jm(e.geometry,t,r).coordinates}),n}var Qm="0123456789bcdefghjkmnpqrstuvwxyz",Zm={};for(let e=0;e<Qm.length;e++)Zm[Qm.charAt(e)]=e;var jS=-90,XS=90,WS=-180,YS=180;function KS(e){let t=!0,r=XS,n=jS,s=YS,o=WS,i,a=0;for(let c=0,l=e.length;c<l;c++){let u=e[c].toLowerCase();a=Zm[u];for(let f=4;f>=0;f--){let h=a>>f&1;t?(i=(s+o)/2,h===1?o=i:s=i):(i=(r+n)/2,h===1?n=i:r=i),t=!t}}return[n,o,r,s]}function $m(e){let[t,r,n,s]=KS(e);return[s,n,s,t,r,t,r,n,s,n]}var QS={getGeohash:{type:"accessor",value:e=>e.geohash}},Wn=class extends Yt{indexToBounds(){let{data:t,getGeohash:r}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(n,s)=>$m(r(n,s))}}};Wn.layerName="GeohashLayer";Wn.defaultProps=QS;var tg=Wn;return lg(Yn);})();
685
+ `;function nC(e){let t=e.positions||e.POSITION,n=t.value.length/t.size;e.COLOR_0||e.colors||(e.colors={size:4,value:new Uint8Array(n*4).fill(255),normalized:!0})}var rC={pbrMaterial:{type:"object",value:null},featureIds:{type:"array",value:null,optional:!0}},Ws=class extends Hd.SimpleMeshLayer{getShaders(){let t=super.getShaders();return t.modules.push(jh,zd),{...t,vs:kd,fs:Vd}}initializeState(){let{featureIds:t}=this.props;super.initializeState();let n=this.getAttributeManager();t&&n.add({featureIdsPickingColors:{type:"uint8",size:3,noAlloc:!0,update:this.calculateFeatureIdsPickingColors}})}updateState(t){super.updateState(t);let{props:n,oldProps:r}=t;n.pbrMaterial!==r.pbrMaterial&&this.updatePbrMaterialUniforms(n.pbrMaterial)}draw(t){let{featureIds:n}=this.props,{model:r}=this.state;if(!r)return;let s={pickFeatureIds:Boolean(n)},i={camera:r.uniforms.cameraPosition};r.shaderInputs.setProps({pbrProjection:i,mesh:s}),super.draw(t)}getModel(t){let{id:n}=this.props,r=this.parseMaterial(this.props.pbrMaterial,t);this.setState({parsedPBRMaterial:r});let s=this.getShaders();return nC(t.attributes),new qd.Model(this.context.device,{...this.getShaders(),id:n,geometry:t,bufferLayout:this.getAttributeManager().getBufferLayouts(),defines:{...s.defines,...r?.defines,HAS_UV_REGIONS:t.attributes.uvRegions?1:0},parameters:r?.parameters,isInstanced:!0})}updatePbrMaterialUniforms(t){let{model:n}=this.state;if(n){let{mesh:r}=this.props,s=this.parseMaterial(t,r);this.setState({parsedPBRMaterial:s});let{pbr_baseColorSampler:i}=s.bindings,{emptyTexture:o}=this.state,c={sampler:i||o,hasTexture:Boolean(i)},{camera:a,...h}={...s.bindings,...s.uniforms};n.shaderInputs.setProps({simpleMesh:c,pbrMaterial:h})}}parseMaterial(t,n){let r=Boolean(t.pbrMetallicRoughness&&t.pbrMetallicRoughness.baseColorTexture);return zh(this.context.device,{unlit:r,...t},{NORMAL:n.attributes.normals,TEXCOORD_0:n.attributes.texCoords},{pbrDebug:!1,lights:!0,useTangents:!1})}calculateFeatureIdsPickingColors(t){let n=this.props.featureIds,r=new Uint8ClampedArray(n.length*t.size),s=[];for(let i=0;i<n.length;i++)this.encodePickingColor(n[i],s),r[i*3]=s[0],r[i*3+1]=s[1],r[i*3+2]=s[2];t.value=r}finalizeState(t){super.finalizeState(t),this.state.parsedPBRMaterial?.generatedTextures.forEach(n=>n.destroy()),this.setState({parsedPBRMaterial:null})}};Ws.layerName="MeshLayer";Ws.defaultProps=rC;var Yd=Ws;var Ly=D(yr(),1);var sC=1/Math.PI*180,_z=1/180*Math.PI,iC={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...iC}};var dt=globalThis.mathgl.config;function Kh(e,{precision:t=dt.precision}={}){return e=oC(e),`${parseFloat(e.toPrecision(t))}`}function _e(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Xt(e,t){return aC(e,n=>n*sC,t)}function mo(e,t,n){let r=dt.EPSILON;n&&(dt.EPSILON=n);try{if(e===t)return!0;if(_e(e)&&_e(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!mo(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=dt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{dt.EPSILON=r}}function oC(e){return Math.round(e/dt.EPSILON)*dt.EPSILON}function cC(e){return e.clone?e.clone():new Array(e.length)}function aC(e,t,n){if(_e(e)){let r=e;n=n||cC(r);for(let s=0;s<n.length&&s<r.length;++s){let i=typeof e=="number"?e:e[s];n[s]=t(i,s,n)}return n}return t(e)}var hn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:_e(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(dt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Kh(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!mo(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(dt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function hC(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function Y(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function ln(e,t,n=""){if(dt.debug&&!hC(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Zh(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Er=class extends hn{get x(){return this[0]}set x(t){this[0]=Y(t)}get y(){return this[1]}set y(t){this[1]=Y(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return Y(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return Y(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Zh(t>=0&&t<this.ELEMENTS,"index is out of range"),Y(this[t])}setComponent(t,n){return Zh(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var Lt=typeof Float32Array<"u"?Float32Array:Array;var Nz=Math.PI/180;function lC(){let e=new Lt(2);return Lt!=Float32Array&&(e[0]=0,e[1]=0),e}function jd(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}function Kd(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var Fz=function(){let e=lC();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Zd(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function go(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Qd(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}function $d(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function xo(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Qh(){let e=new Lt(3);return Lt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function fC(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function $h(e,t,n){let r=new Lt(3);return r[0]=e,r[1]=t,r[2]=n,r}function tm(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function tl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Tr(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function _r(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Mo(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function Ao(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function em(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function nm(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function rm(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function sm(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&tl(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var im=fC;var Uz=function(){let e=Qh();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var el=[0,0,0],yo,F=class extends Er{static get ZERO(){return yo||(yo=new F(0,0,0),Object.freeze(yo)),yo}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&_e(t)?this.copy(t):(dt.debug&&(Y(t),Y(n),Y(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return dt.debug&&(Y(t.x),Y(t.y),Y(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=Y(t)}angle(t){return sm(this,t)}cross(t){return Tr(this,this,t),this.check()}rotateX({radians:t,origin:n=el}){return em(this,this,n,t),this.check()}rotateY({radians:t,origin:n=el}){return nm(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=el}){return rm(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return _r(this,this,t),this.check()}transformAsVector(t){return go(this,this,t),this.check()}transformByMatrix3(t){return Mo(this,this,t),this.check()}transformByMatrix2(t){return Qd(this,this,t),this.check()}transformByQuaternion(t){return Ao(this,this,t),this.check()}};var Eo,Sr=class extends Er{static get ZERO(){return Eo||(Eo=new Sr(0,0,0,0),Object.freeze(Eo)),Eo}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),_e(t)&&arguments.length===1?this.copy(t):(dt.debug&&(Y(t),Y(n),Y(r),Y(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 dt.debug&&(Y(t.x),Y(t.y),Y(t.z),Y(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]=Y(t)}get w(){return this[3]}set w(t){this[3]=Y(t)}transform(t){return _r(this,this,t),this.check()}transformByMatrix3(t){return xo(this,this,t),this.check()}transformByMatrix2(t){return $d(this,this,t),this.check()}transformByQuaternion(t){return Ao(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var Br=class extends hn{toString(){let t="[";if(dt.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=Y(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function om(){let e=new Lt(9);return Lt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function cm(e,t){if(e===t){let n=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function am(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=l*o-c*h,p=-l*i+c*a,u=h*i-o*a,d=n*f+r*p+s*u;return d?(d=1/d,e[0]=f*d,e[1]=(-l*r+s*h)*d,e[2]=(c*r-s*o)*d,e[3]=p*d,e[4]=(l*n-s*a)*d,e[5]=(-c*n+s*i)*d,e[6]=u*d,e[7]=(-h*n+r*a)*d,e[8]=(o*n-r*i)*d,e):null}function hm(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8];return t*(h*i-o*a)+n*(-h*s+o*c)+r*(a*s-i*c)}function nl(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1],d=n[2],g=n[3],m=n[4],M=n[5],E=n[6],A=n[7],y=n[8];return e[0]=p*r+u*o+d*h,e[1]=p*s+u*c+d*l,e[2]=p*i+u*a+d*f,e[3]=g*r+m*o+M*h,e[4]=g*s+m*c+M*l,e[5]=g*i+m*a+M*f,e[6]=E*r+A*o+y*h,e[7]=E*s+A*c+y*l,e[8]=E*i+A*a+y*f,e}function lm(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1];return e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=c,e[5]=a,e[6]=p*r+u*o+h,e[7]=p*s+u*c+l,e[8]=p*i+u*a+f,e}function fm(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=Math.sin(n),u=Math.cos(n);return e[0]=u*r+p*o,e[1]=u*s+p*c,e[2]=u*i+p*a,e[3]=u*o-p*r,e[4]=u*c-p*s,e[5]=u*a-p*i,e[6]=h,e[7]=l,e[8]=f,e}function rl(e,t,n){let r=n[0],s=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function pm(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[3]=l-M,e[6]=p+m,e[1]=l+M,e[4]=1-h-d,e[7]=u-g,e[2]=p-m,e[5]=u+g,e[8]=1-h-f,e}var sl;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(sl||(sl={}));var dC=Object.freeze([1,0,0,0,1,0,0,0,1]),Gn=class extends Br{static get IDENTITY(){return gC()}static get ZERO(){return mC()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return sl}constructor(t,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):n.length>0?this.copy([t,...n]):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(dC)}fromObject(t){return this.check()}fromQuaternion(t){return pm(this,t),this.check()}set(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=i,this[5]=a,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return hm(this)}transpose(){return cm(this,this),this.check()}invert(){return am(this,this),this.check()}multiplyLeft(t){return nl(this,t,this),this.check()}multiplyRight(t){return nl(this,this,t),this.check()}rotate(t){return fm(this,this,t),this.check()}scale(t){return Array.isArray(t)?rl(this,this,t):rl(this,this,[t,t]),this.check()}translate(t){return lm(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=jd(n||[-0,-0],t,this);break;case 3:r=Mo(n||[-0,-0,-0],t,this);break;case 4:r=xo(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ln(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},To,_o=null;function mC(){return To||(To=new Gn([0,0,0,0,0,0,0,0,0]),Object.freeze(To)),To}function gC(){return _o||(_o=new Gn,Object.freeze(_o)),_o}function xC(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function um(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function dm(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m,C=E*I-A*w+y*R+T*x-_*S+L*B;return C?(C=1/C,e[0]=(c*I-a*w+h*R)*C,e[1]=(s*w-r*I-i*R)*C,e[2]=(g*L-m*_+M*T)*C,e[3]=(p*_-f*L-u*T)*C,e[4]=(a*x-o*I-h*S)*C,e[5]=(n*I-s*x+i*S)*C,e[6]=(m*y-d*L-M*A)*C,e[7]=(l*L-p*y+u*A)*C,e[8]=(o*w-c*x+h*B)*C,e[9]=(r*x-n*w-i*B)*C,e[10]=(d*_-g*y+M*E)*C,e[11]=(f*y-l*_-u*E)*C,e[12]=(c*S-o*R-a*B)*C,e[13]=(n*R-r*S+s*B)*C,e[14]=(g*A-d*T-m*E)*C,e[15]=(l*T-f*A+p*E)*C,e):null}function mm(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],p=e[11],u=e[12],d=e[13],g=e[14],m=e[15],M=t*o-n*i,E=t*c-r*i,A=n*c-r*o,y=h*d-l*u,T=h*g-f*u,_=l*g-f*d,L=t*_-n*T+r*y,B=i*_-o*T+c*y,S=h*A-l*E+f*M,x=u*A-d*E+g*M;return a*L-s*B+m*S-p*x}function il(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=t[9],u=t[10],d=t[11],g=t[12],m=t[13],M=t[14],E=t[15],A=n[0],y=n[1],T=n[2],_=n[3];return e[0]=A*r+y*c+T*f+_*g,e[1]=A*s+y*a+T*p+_*m,e[2]=A*i+y*h+T*u+_*M,e[3]=A*o+y*l+T*d+_*E,A=n[4],y=n[5],T=n[6],_=n[7],e[4]=A*r+y*c+T*f+_*g,e[5]=A*s+y*a+T*p+_*m,e[6]=A*i+y*h+T*u+_*M,e[7]=A*o+y*l+T*d+_*E,A=n[8],y=n[9],T=n[10],_=n[11],e[8]=A*r+y*c+T*f+_*g,e[9]=A*s+y*a+T*p+_*m,e[10]=A*i+y*h+T*u+_*M,e[11]=A*o+y*l+T*d+_*E,A=n[12],y=n[13],T=n[14],_=n[15],e[12]=A*r+y*c+T*f+_*g,e[13]=A*s+y*a+T*p+_*m,e[14]=A*i+y*h+T*u+_*M,e[15]=A*o+y*l+T*d+_*E,e}function gm(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,h,l,f,p,u,d,g,m,M;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],p=t[6],u=t[7],d=t[8],g=t[9],m=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=p,e[7]=u,e[8]=d,e[9]=g,e[10]=m,e[11]=M,e[12]=o*r+l*s+d*i+t[12],e[13]=c*r+f*s+g*i+t[13],e[14]=a*r+p*s+m*i+t[14],e[15]=h*r+u*s+M*i+t[15]),e}function xm(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Mm(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,h,l,f,p,u,d,g,m,M,E,A,y,T,_,L,B,S,x,R,w,I,C,P;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,h=Math.sin(n),a=Math.cos(n),l=1-a,f=t[0],p=t[1],u=t[2],d=t[3],g=t[4],m=t[5],M=t[6],E=t[7],A=t[8],y=t[9],T=t[10],_=t[11],L=s*s*l+a,B=i*s*l+o*h,S=o*s*l-i*h,x=s*i*l-o*h,R=i*i*l+a,w=o*i*l+s*h,I=s*o*l+i*h,C=i*o*l-s*h,P=o*o*l+a,e[0]=f*L+g*B+A*S,e[1]=p*L+m*B+y*S,e[2]=u*L+M*B+T*S,e[3]=d*L+E*B+_*S,e[4]=f*x+g*R+A*w,e[5]=p*x+m*R+y*w,e[6]=u*x+M*R+T*w,e[7]=d*x+E*R+_*w,e[8]=f*I+g*C+A*P,e[9]=p*I+m*C+y*P,e[10]=u*I+M*C+T*P,e[11]=d*I+E*C+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Am(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+h*r,e[5]=o*s+l*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=h*s-i*r,e[9]=l*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function ym(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-h*r,e[1]=o*s-l*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+h*s,e[9]=o*r+l*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function Em(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+h*r,e[1]=o*s+l*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=h*s-i*r,e[5]=l*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function Tm(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[1]=l+M,e[2]=p-m,e[3]=0,e[4]=l-M,e[5]=1-h-d,e[6]=u+g,e[7]=0,e[8]=p+m,e[9]=u-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function _m(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function MC(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Sm=MC;function AC(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*h,e[15]=1,e}var Bm=AC;function Cm(e,t,n,r){let s,i,o,c,a,h,l,f,p,u,d=t[0],g=t[1],m=t[2],M=r[0],E=r[1],A=r[2],y=n[0],T=n[1],_=n[2];return Math.abs(d-y)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(m-_)<1e-6?xC(e):(f=d-y,p=g-T,u=m-_,s=1/Math.sqrt(f*f+p*p+u*u),f*=s,p*=s,u*=s,i=E*u-A*p,o=A*f-M*u,c=M*p-E*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-u*o,h=u*i-f*c,l=f*o-p*i,s=Math.sqrt(a*a+h*h+l*l),s?(s=1/s,a*=s,h*=s,l*=s):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*d+o*g+c*m),e[13]=-(a*d+h*g+l*m),e[14]=-(f*d+p*g+u*m),e[15]=1,e)}function yC(){let e=new Lt(4);return Lt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Lm(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function Rm(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function wm(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function Im(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function bm(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function Om(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function Pm(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function Nm(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function Fm(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],h=n[3],l=h*r+c*i-a*s,f=h*s+a*r-o*i,p=h*i+o*s-c*r,u=-o*r-c*s-a*i;return e[0]=l*h+u*-o+f*-a-p*-c,e[1]=f*h+u*-c+p*-o-l*-a,e[2]=p*h+u*-a+l*-c-f*-o,e[3]=t[3],e}var hk=function(){let e=yC();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var al;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(al||(al={}));var TC=45*Math.PI/180,_C=1,ol=.1,cl=500,SC=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),et=class extends Br{static get IDENTITY(){return CC()}static get ZERO(){return BC()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return al}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this[9]=l,this[10]=f,this[11]=p,this[12]=u,this[13]=d,this[14]=g,this[15]=m,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=i,this[2]=h,this[3]=u,this[4]=n,this[5]=o,this[6]=l,this[7]=d,this[8]=r,this[9]=c,this[10]=f,this[11]=g,this[12]=s,this[13]=a,this[14]=p,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(SC)}fromObject(t){return this.check()}fromQuaternion(t){return Tm(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=ol,far:c=cl}=t;return c===1/0?LC(this,n,r,s,i,o):_m(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return Cm(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=ol,far:c=cl}=t;return Bm(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=TC,aspect:r=_C,focalDistance:s=1,near:i=ol,far:o=cl}=t;vm(n);let c=n/2,a=s*Math.tan(c),h=a*r;return this.ortho({left:-h,right:h,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return vm(n),Sm(this,n,r,s,i),this.check()}determinant(){return mm(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return um(this,this),this.check()}invert(){return dm(this,this),this.check()}multiplyLeft(t){return il(this,t,this),this.check()}multiplyRight(t){return il(this,this,t),this.check()}rotateX(t){return Am(this,this,t),this.check()}rotateY(t){return ym(this,this,t),this.check()}rotateZ(t){return Em(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return Mm(this,this,t,n),this.check()}scale(t){return xm(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return gm(this,this,t),this.check()}transform(t,n){return t.length===4?(n=Nm(n||[-0,-0,-0,-0],t,this),ln(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=Kd(n||[-0,-0],t,this);break;case 3:s=_r(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ln(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=Zd(n||[-0,-0],t,this);break;case 3:r=go(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return ln(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},So,Bo;function BC(){return So||(So=new et([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(So)),So}function CC(){return Bo||(Bo=new et,Object.freeze(Bo)),Bo}function vm(e){if(e>Math.PI*2)throw Error("expected radians")}function LC(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),h=(s+r)/(s-r),l=-1,f=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}function Dm(){let e=new Lt(4);return Lt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Um(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function hl(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function ll(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],h=n[2],l=n[3];return e[0]=r*l+o*c+s*h-i*a,e[1]=s*l+o*a+i*c-r*h,e[2]=i*l+o*h+r*a-s*c,e[3]=o*l-r*c-s*a-i*h,e}function Gm(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function zm(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function km(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function Vm(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function Xs(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],h=n[1],l=n[2],f=n[3],p,u,d,g,m;return p=s*a+i*h+o*l+c*f,p<0&&(p=-p,a=-a,h=-h,l=-l,f=-f),1-p>1e-6?(u=Math.acos(p),m=Math.sin(u),d=Math.sin((1-r)*u)/m,g=Math.sin(r*u)/m):(d=1-r,g=r),e[0]=d*s+g*a,e[1]=d*i+g*h,e[2]=d*o+g*l,e[3]=d*c+g*f,e}function qm(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function Hm(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function fl(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var Ym=Lm;var Wm=Rm,Jm=Om,Xm=Pm,jm=wm;var Km=Im;var Zm=bm;var Qm=function(){let e=Qh(),t=$h(1,0,0),n=$h(0,1,0);return function(r,s,i){let o=tl(s,i);return o<-.999999?(Tr(e,t,s),im(e)<1e-6&&Tr(e,n,s),tm(e,e),hl(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Tr(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,Zm(r,r))}}(),_k=function(){let e=Dm(),t=Dm();return function(n,r,s,i,o,c){return Xs(e,r,o,c),Xs(t,s,i,c),Xs(n,e,t,2*c*(1-c)),n}}(),Sk=function(){let e=om();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],Zm(t,fl(t,e))}}();var RC=[0,0,0,1],js=class extends hn{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 fl(this,t),this.check()}fromAxisRotation(t,n){return hl(this,t,n),this.check()}identity(){return Um(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=Y(t)}get y(){return this[1]}set y(t){this[1]=Y(t)}get z(){return this[2]}set z(t){this[2]=Y(t)}get w(){return this[3]}set w(t){this[3]=Y(t)}len(){return jm(this)}lengthSquared(){return Km(this)}dot(t){return Jm(this,t)}rotationTo(t,n){return Qm(this,t,n),this.check()}add(t){return Ym(this,this,t),this.check()}calculateW(){return Vm(this,this),this.check()}conjugate(){return Hm(this,this),this.check()}invert(){return qm(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(Xm(this,t,n,r),this.check())}multiplyRight(t){return ll(this,this,t),this.check()}multiplyLeft(t){return ll(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return Gm(this,this,t),this.check()}rotateY(t){return zm(this,this,t),this.check()}rotateZ(t){return km(this,this,t),this.check()}scale(t){return Wm(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=RC,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return Xs(this,s,i,o),this.check()}transformVector4(t,n=new Sr){return Fm(n,t,this),ln(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var IC=1/Math.PI*180,bC=1/180*Math.PI,OC={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...OC}};var mt=globalThis.mathgl.config;function pl(e,{precision:t=mt.precision}={}){return e=PC(e),`${parseFloat(e.toPrecision(t))}`}function fn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ul(e){return $m(e)}function dl(e){return tg(e)}function $m(e,t){return eg(e,n=>n*bC,t)}function tg(e,t){return eg(e,n=>n*IC,t)}function Fe(e,t,n){let r=mt.EPSILON;n&&(mt.EPSILON=n);try{if(e===t)return!0;if(fn(e)&&fn(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!Fe(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=mt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{mt.EPSILON=r}}function PC(e){return Math.round(e/mt.EPSILON)*mt.EPSILON}function NC(e){return e.clone?e.clone():new Array(e.length)}function eg(e,t,n){if(fn(e)){let r=e;n=n||NC(r);for(let s=0;s<n.length&&s<r.length;++s){let i=typeof e=="number"?e:e[s];n[s]=t(i,s,n)}return n}return t(e)}var Cr=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:fn(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(mt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+pl(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!Fe(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(mt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function FC(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function Rt(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Co(e,t,n=""){if(mt.debug&&!FC(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function jt(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Lo=class extends Cr{get x(){return this[0]}set x(t){this[0]=Rt(t)}get y(){return this[1]}set y(t){this[1]=Rt(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return Rt(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return Rt(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return jt(t>=0&&t<this.ELEMENTS,"index is out of range"),Rt(this[t])}setComponent(t,n){return jt(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var ce=typeof Float32Array<"u"?Float32Array:Array,Ks=Math.random;function Lr(e){return e>=0?Math.round(e):e%.5===0?Math.floor(e):Math.round(e)}var aV=Math.PI/180;function vC(){let e=new ce(2);return ce!=Float32Array&&(e[0]=0,e[1]=0),e}function ng(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var hV=function(){let e=vC();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function rg(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function Ro(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function sg(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}var Rr={};At(Rr,{add:()=>kC,angle:()=>_l,bezier:()=>eL,ceil:()=>VC,clone:()=>DC,copy:()=>GC,create:()=>ig,cross:()=>xl,dist:()=>lL,distance:()=>lg,div:()=>hL,divide:()=>hg,dot:()=>gl,equals:()=>oL,exactEquals:()=>iL,floor:()=>qC,forEach:()=>dL,fromValues:()=>UC,hermite:()=>tL,inverse:()=>KC,len:()=>pL,length:()=>og,lerp:()=>QC,max:()=>YC,min:()=>HC,mul:()=>aL,multiply:()=>ag,negate:()=>jC,normalize:()=>ZC,random:()=>nL,rotateX:()=>yl,rotateY:()=>El,rotateZ:()=>Tl,round:()=>WC,scale:()=>JC,scaleAndAdd:()=>XC,set:()=>zC,slerp:()=>$C,sqrDist:()=>fL,sqrLen:()=>uL,squaredDistance:()=>fg,squaredLength:()=>pg,str:()=>sL,sub:()=>cL,subtract:()=>cg,transformMat3:()=>Ml,transformMat4:()=>Zs,transformQuat:()=>Al,zero:()=>rL});function ig(){let e=new ce(3);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function DC(e){let t=new ce(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function og(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function UC(e,t,n){let r=new ce(3);return r[0]=e,r[1]=t,r[2]=n,r}function GC(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function zC(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e}function kC(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function cg(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function ag(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function hg(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e}function VC(e,t){return e[0]=Math.ceil(t[0]),e[1]=Math.ceil(t[1]),e[2]=Math.ceil(t[2]),e}function qC(e,t){return e[0]=Math.floor(t[0]),e[1]=Math.floor(t[1]),e[2]=Math.floor(t[2]),e}function HC(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function YC(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function WC(e,t){return e[0]=Lr(t[0]),e[1]=Lr(t[1]),e[2]=Lr(t[2]),e}function JC(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function XC(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e}function lg(e,t){let n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return Math.sqrt(n*n+r*r+s*s)}function fg(e,t){let n=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return n*n+r*r+s*s}function pg(e){let t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r}function jC(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function KC(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e}function ZC(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function gl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function xl(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function QC(e,t,n,r){let s=t[0],i=t[1],o=t[2];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e}function $C(e,t,n,r){let s=Math.acos(Math.min(Math.max(gl(t,n),-1),1)),i=Math.sin(s),o=Math.sin((1-r)*s)/i,c=Math.sin(r*s)/i;return e[0]=o*t[0]+c*n[0],e[1]=o*t[1]+c*n[1],e[2]=o*t[2]+c*n[2],e}function tL(e,t,n,r,s,i){let o=i*i,c=o*(2*i-3)+1,a=o*(i-2)+i,h=o*(i-1),l=o*(3-2*i);return e[0]=t[0]*c+n[0]*a+r[0]*h+s[0]*l,e[1]=t[1]*c+n[1]*a+r[1]*h+s[1]*l,e[2]=t[2]*c+n[2]*a+r[2]*h+s[2]*l,e}function eL(e,t,n,r,s,i){let o=1-i,c=o*o,a=i*i,h=c*o,l=3*i*c,f=3*a*o,p=a*i;return e[0]=t[0]*h+n[0]*l+r[0]*f+s[0]*p,e[1]=t[1]*h+n[1]*l+r[1]*f+s[1]*p,e[2]=t[2]*h+n[2]*l+r[2]*f+s[2]*p,e}function nL(e,t){t=t===void 0?1:t;let n=Ks()*2*Math.PI,r=Ks()*2-1,s=Math.sqrt(1-r*r)*t;return e[0]=Math.cos(n)*s,e[1]=Math.sin(n)*s,e[2]=r*t,e}function Zs(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Ml(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function Al(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function yl(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function El(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Tl(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function _l(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&gl(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}function rL(e){return e[0]=0,e[1]=0,e[2]=0,e}function sL(e){return`vec3(${e[0]}, ${e[1]}, ${e[2]})`}function iL(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function oL(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2];return Math.abs(n-i)<=1e-6*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-o)<=1e-6*Math.max(1,Math.abs(r),Math.abs(o))&&Math.abs(s-c)<=1e-6*Math.max(1,Math.abs(s),Math.abs(c))}var cL=cg,aL=ag,hL=hg,lL=lg,fL=fg,pL=og,uL=pg,dL=function(){let e=ig();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Sl=[0,0,0],wo,k=class extends Lo{static get ZERO(){return wo||(wo=new k(0,0,0),Object.freeze(wo)),wo}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&fn(t)?this.copy(t):(mt.debug&&(Rt(t),Rt(n),Rt(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return mt.debug&&(Rt(t.x),Rt(t.y),Rt(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=Rt(t)}angle(t){return _l(this,t)}cross(t){return xl(this,this,t),this.check()}rotateX({radians:t,origin:n=Sl}){return yl(this,this,n,t),this.check()}rotateY({radians:t,origin:n=Sl}){return El(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=Sl}){return Tl(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return Zs(this,this,t),this.check()}transformAsVector(t){return Ro(this,this,t),this.check()}transformByMatrix3(t){return Ml(this,this,t),this.check()}transformByMatrix2(t){return sg(this,this,t),this.check()}transformByQuaternion(t){return Al(this,this,t),this.check()}};var Io=class extends Cr{toString(){let t="[";if(mt.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=Rt(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function mL(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function ug(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function dg(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m,C=E*I-A*w+y*R+T*x-_*S+L*B;return C?(C=1/C,e[0]=(c*I-a*w+h*R)*C,e[1]=(s*w-r*I-i*R)*C,e[2]=(g*L-m*_+M*T)*C,e[3]=(p*_-f*L-u*T)*C,e[4]=(a*x-o*I-h*S)*C,e[5]=(n*I-s*x+i*S)*C,e[6]=(m*y-d*L-M*A)*C,e[7]=(l*L-p*y+u*A)*C,e[8]=(o*w-c*x+h*B)*C,e[9]=(r*x-n*w-i*B)*C,e[10]=(d*_-g*y+M*E)*C,e[11]=(f*y-l*_-u*E)*C,e[12]=(c*S-o*R-a*B)*C,e[13]=(n*R-r*S+s*B)*C,e[14]=(g*A-d*T-m*E)*C,e[15]=(l*T-f*A+p*E)*C,e):null}function mg(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],p=e[11],u=e[12],d=e[13],g=e[14],m=e[15],M=t*o-n*i,E=t*c-r*i,A=n*c-r*o,y=h*d-l*u,T=h*g-f*u,_=l*g-f*d,L=t*_-n*T+r*y,B=i*_-o*T+c*y,S=h*A-l*E+f*M,x=u*A-d*E+g*M;return a*L-s*B+m*S-p*x}function Bl(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=t[9],u=t[10],d=t[11],g=t[12],m=t[13],M=t[14],E=t[15],A=n[0],y=n[1],T=n[2],_=n[3];return e[0]=A*r+y*c+T*f+_*g,e[1]=A*s+y*a+T*p+_*m,e[2]=A*i+y*h+T*u+_*M,e[3]=A*o+y*l+T*d+_*E,A=n[4],y=n[5],T=n[6],_=n[7],e[4]=A*r+y*c+T*f+_*g,e[5]=A*s+y*a+T*p+_*m,e[6]=A*i+y*h+T*u+_*M,e[7]=A*o+y*l+T*d+_*E,A=n[8],y=n[9],T=n[10],_=n[11],e[8]=A*r+y*c+T*f+_*g,e[9]=A*s+y*a+T*p+_*m,e[10]=A*i+y*h+T*u+_*M,e[11]=A*o+y*l+T*d+_*E,A=n[12],y=n[13],T=n[14],_=n[15],e[12]=A*r+y*c+T*f+_*g,e[13]=A*s+y*a+T*p+_*m,e[14]=A*i+y*h+T*u+_*M,e[15]=A*o+y*l+T*d+_*E,e}function gg(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,h,l,f,p,u,d,g,m,M;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],p=t[6],u=t[7],d=t[8],g=t[9],m=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=p,e[7]=u,e[8]=d,e[9]=g,e[10]=m,e[11]=M,e[12]=o*r+l*s+d*i+t[12],e[13]=c*r+f*s+g*i+t[13],e[14]=a*r+p*s+m*i+t[14],e[15]=h*r+u*s+M*i+t[15]),e}function xg(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function Mg(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,h,l,f,p,u,d,g,m,M,E,A,y,T,_,L,B,S,x,R,w,I,C,P;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,h=Math.sin(n),a=Math.cos(n),l=1-a,f=t[0],p=t[1],u=t[2],d=t[3],g=t[4],m=t[5],M=t[6],E=t[7],A=t[8],y=t[9],T=t[10],_=t[11],L=s*s*l+a,B=i*s*l+o*h,S=o*s*l-i*h,x=s*i*l-o*h,R=i*i*l+a,w=o*i*l+s*h,I=s*o*l+i*h,C=i*o*l-s*h,P=o*o*l+a,e[0]=f*L+g*B+A*S,e[1]=p*L+m*B+y*S,e[2]=u*L+M*B+T*S,e[3]=d*L+E*B+_*S,e[4]=f*x+g*R+A*w,e[5]=p*x+m*R+y*w,e[6]=u*x+M*R+T*w,e[7]=d*x+E*R+_*w,e[8]=f*I+g*C+A*P,e[9]=p*I+m*C+y*P,e[10]=u*I+M*C+T*P,e[11]=d*I+E*C+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function Ag(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+h*r,e[5]=o*s+l*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=h*s-i*r,e[9]=l*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function yg(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-h*r,e[1]=o*s-l*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+h*s,e[9]=o*r+l*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function Eg(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+h*r,e[1]=o*s+l*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=h*s-i*r,e[5]=l*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function Tg(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[1]=l+M,e[2]=p-m,e[3]=0,e[4]=l-M,e[5]=1-h-d,e[6]=u+g,e[7]=0,e[8]=p+m,e[9]=u-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function _g(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function gL(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var Sg=gL;function xL(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*h,e[15]=1,e}var Bg=xL;function Cg(e,t,n,r){let s,i,o,c,a,h,l,f,p,u,d=t[0],g=t[1],m=t[2],M=r[0],E=r[1],A=r[2],y=n[0],T=n[1],_=n[2];return Math.abs(d-y)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(m-_)<1e-6?mL(e):(f=d-y,p=g-T,u=m-_,s=1/Math.sqrt(f*f+p*p+u*u),f*=s,p*=s,u*=s,i=E*u-A*p,o=A*f-M*u,c=M*p-E*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-u*o,h=u*i-f*c,l=f*o-p*i,s=Math.sqrt(a*a+h*h+l*l),s?(s=1/s,a*=s,h*=s,l*=s):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*d+o*g+c*m),e[13]=-(a*d+h*g+l*m),e[14]=-(f*d+p*g+u*m),e[15]=1,e)}function ML(){let e=new ce(4);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function Lg(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}var _V=function(){let e=ML();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var Rl;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(Rl||(Rl={}));var AL=45*Math.PI/180,yL=1,Cl=.1,Ll=500,EL=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),pn=class extends Io{static get IDENTITY(){return _L()}static get ZERO(){return TL()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Rl}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this[9]=l,this[10]=f,this[11]=p,this[12]=u,this[13]=d,this[14]=g,this[15]=m,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=i,this[2]=h,this[3]=u,this[4]=n,this[5]=o,this[6]=l,this[7]=d,this[8]=r,this[9]=c,this[10]=f,this[11]=g,this[12]=s,this[13]=a,this[14]=p,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(EL)}fromObject(t){return this.check()}fromQuaternion(t){return Tg(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Cl,far:c=Ll}=t;return c===1/0?SL(this,n,r,s,i,o):_g(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return Cg(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Cl,far:c=Ll}=t;return Bg(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=AL,aspect:r=yL,focalDistance:s=1,near:i=Cl,far:o=Ll}=t;Rg(n);let c=n/2,a=s*Math.tan(c),h=a*r;return this.ortho({left:-h,right:h,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return Rg(n),Sg(this,n,r,s,i),this.check()}determinant(){return mg(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return ug(this,this),this.check()}invert(){return dg(this,this),this.check()}multiplyLeft(t){return Bl(this,t,this),this.check()}multiplyRight(t){return Bl(this,this,t),this.check()}rotateX(t){return Ag(this,this,t),this.check()}rotateY(t){return yg(this,this,t),this.check()}rotateZ(t){return Eg(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return Mg(this,this,t,n),this.check()}scale(t){return xg(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return gg(this,this,t),this.check()}transform(t,n){return t.length===4?(n=Lg(n||[-0,-0,-0,-0],t,this),Co(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=ng(n||[-0,-0],t,this);break;case 3:s=Zs(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Co(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=rg(n||[-0,-0],t,this);break;case 3:r=Ro(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Co(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},bo,Oo;function TL(){return bo||(bo=new pn([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(bo)),bo}function _L(){return Oo||(Oo=new pn,Object.freeze(Oo)),Oo}function Rg(e){if(e>Math.PI*2)throw Error("expected radians")}function SL(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),h=(s+r)/(s-r),l=-1,f=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}var un={};At(un,{EPSILON1:()=>BL,EPSILON10:()=>NL,EPSILON11:()=>FL,EPSILON12:()=>vL,EPSILON13:()=>DL,EPSILON14:()=>UL,EPSILON15:()=>zL,EPSILON16:()=>kL,EPSILON17:()=>VL,EPSILON18:()=>qL,EPSILON19:()=>HL,EPSILON2:()=>CL,EPSILON20:()=>YL,EPSILON3:()=>LL,EPSILON4:()=>RL,EPSILON5:()=>wL,EPSILON6:()=>IL,EPSILON7:()=>bL,EPSILON8:()=>OL,EPSILON9:()=>PL,PI_OVER_FOUR:()=>JL,PI_OVER_SIX:()=>XL,PI_OVER_TWO:()=>WL,TWO_PI:()=>jL});var BL=.1,CL=.01,LL=.001,RL=1e-4,wL=1e-5,IL=1e-6,bL=1e-7,OL=1e-8,PL=1e-9,NL=1e-10,FL=1e-11,vL=1e-12,DL=1e-13,UL=1e-14,zL=1e-15,kL=1e-16,VL=1e-17,qL=1e-18,HL=1e-19,YL=1e-20,WL=Math.PI/2,JL=Math.PI/4,XL=Math.PI/6,jL=Math.PI*2;var De=6356752314245179e-9,KL={radii:[6378137,6378137,De],radiiSquared:[6378137*6378137,6378137*6378137,De*De],oneOverRadii:[1/6378137,1/6378137,1/De],oneOverRadiiSquared:[1/(6378137*6378137),1/(6378137*6378137),1/(De*De)],maximumRadius:Math.max(6378137,6378137,De),centerToleranceSquared:.1};function Po(e){return e}var $V=new k;function ZL(e,t=[],n=Po){return"longitude"in e?(t[0]=n(e.longitude),t[1]=n(e.latitude),t[2]=e.height):"x"in e?(t[0]=n(e.x),t[1]=n(e.y),t[2]=e.z):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}function wg(e,t=[]){return ZL(e,t,mt._cartographicRadians?Po:ul)}function QL(e,t,n=Po){return"longitude"in t?(t.longitude=n(e[0]),t.latitude=n(e[1]),t.height=e[2]):"x"in t?(t.x=n(e[0]),t.y=n(e[1]),t.z=e[2]):(t[0]=n(e[0]),t[1]=n(e[1]),t[2]=e[2]),t}function Ig(e,t){return QL(e,t,mt._cartographicRadians?Po:dl)}var bg=1e-14,$L=new k,Og={up:{south:"east",north:"west",west:"south",east:"north"},down:{south:"west",north:"east",west:"north",east:"south"},south:{up:"west",down:"east",west:"down",east:"up"},north:{up:"east",down:"west",west:"up",east:"down"},west:{up:"north",down:"south",north:"down",south:"up"},east:{up:"south",down:"north",north:"up",south:"down"}},wl={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},Qs={east:new k,north:new k,up:new k,west:new k,south:new k,down:new k},tR=new k,eR=new k,nR=new k;function Il(e,t,n,r,s,i){let o=Og[t]&&Og[t][n];jt(o&&(!r||r===o));let c,a,h,l=$L.copy(s);if(Fe(l.x,0,bg)&&Fe(l.y,0,bg)){let p=Math.sign(l.z);c=tR.fromArray(wl[t]),t!=="east"&&t!=="west"&&c.scale(p),a=eR.fromArray(wl[n]),n!=="east"&&n!=="west"&&a.scale(p),h=nR.fromArray(wl[r]),r!=="east"&&r!=="west"&&h.scale(p)}else{let{up:p,east:u,north:d}=Qs;u.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,p),d.copy(p).cross(u);let{down:g,west:m,south:M}=Qs;g.copy(p).scale(-1),m.copy(u).scale(-1),M.copy(d).scale(-1),c=Qs[t],a=Qs[n],h=Qs[r]}return i[0]=c.x,i[1]=c.y,i[2]=c.z,i[3]=0,i[4]=a.x,i[5]=a.y,i[6]=a.z,i[7]=0,i[8]=h.x,i[9]=h.y,i[10]=h.z,i[11]=0,i[12]=l.x,i[13]=l.y,i[14]=l.z,i[15]=1,i}var wr=new k,rR=new k,sR=new k;function Pg(e,t,n=[]){let{oneOverRadii:r,oneOverRadiiSquared:s,centerToleranceSquared:i}=t;wr.from(e);let o=wr.x,c=wr.y,a=wr.z,h=r.x,l=r.y,f=r.z,p=o*o*h*h,u=c*c*l*l,d=a*a*f*f,g=p+u+d,m=Math.sqrt(1/g);if(!Number.isFinite(m))return;let M=rR;if(M.copy(e).scale(m),g<i)return M.to(n);let E=s.x,A=s.y,y=s.z,T=sR;T.set(M.x*E*2,M.y*A*2,M.z*y*2);let _=(1-m)*wr.len()/(.5*T.len()),L=0,B,S,x,R;do{_-=L,B=1/(1+_*E),S=1/(1+_*A),x=1/(1+_*y);let w=B*B,I=S*S,C=x*x,P=w*B,V=I*S,G=C*x;R=p*w+u*I+d*C-1;let q=-2*(p*P*E+u*V*A+d*G*y);L=R/q}while(Math.abs(R)>un.EPSILON12);return wr.scale([B,S,x]).to(n)}var No=new k,Ng=new k,cR=new k,ae=new k,aR=new k,Fo=new k,U=class{constructor(t=0,n=0,r=0){this.centerToleranceSquared=un.EPSILON1,jt(t>=0),jt(n>=0),jt(r>=0),this.radii=new k(t,n,r),this.radiiSquared=new k(t*t,n*n,r*r),this.radiiToTheFourth=new k(t*t*t*t,n*n*n*n,r*r*r*r),this.oneOverRadii=new k(t===0?0:1/t,n===0?0:1/n,r===0?0:1/r),this.oneOverRadiiSquared=new k(t===0?0:1/(t*t),n===0?0:1/(n*n),r===0?0:1/(r*r)),this.minimumRadius=Math.min(t,n,r),this.maximumRadius=Math.max(t,n,r),this.radiiSquared.z!==0&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(t){return this===t||Boolean(t&&this.radii.equals(t.radii))}toString(){return this.radii.toString()}cartographicToCartesian(t,n=[0,0,0]){let r=Ng,s=cR,[,,i]=t;this.geodeticSurfaceNormalCartographic(t,r),s.copy(this.radiiSquared).scale(r);let o=Math.sqrt(r.dot(s));return s.scale(1/o),r.scale(i),s.add(r),s.to(n)}cartesianToCartographic(t,n=[0,0,0]){Fo.from(t);let r=this.scaleToGeodeticSurface(Fo,ae);if(!r)return;let s=this.geodeticSurfaceNormal(r,Ng),i=aR;i.copy(Fo).subtract(r);let o=Math.atan2(s.y,s.x),c=Math.asin(s.z),a=Math.sign(Rr.dot(i,Fo))*Rr.length(i);return Ig([o,c,a],n)}eastNorthUpToFixedFrame(t,n=new pn){return Il(this,"east","north","up",t,n)}localFrameToFixedFrame(t,n,r,s,i=new pn){return Il(this,t,n,r,s,i)}geocentricSurfaceNormal(t,n=[0,0,0]){return No.from(t).normalize().to(n)}geodeticSurfaceNormalCartographic(t,n=[0,0,0]){let r=wg(t),s=r[0],i=r[1],o=Math.cos(i);return No.set(o*Math.cos(s),o*Math.sin(s),Math.sin(i)).normalize(),No.to(n)}geodeticSurfaceNormal(t,n=[0,0,0]){return No.from(t).scale(this.oneOverRadiiSquared).normalize().to(n)}scaleToGeodeticSurface(t,n){return Pg(t,this,n)}scaleToGeocentricSurface(t,n=[0,0,0]){ae.from(t);let r=ae.x,s=ae.y,i=ae.z,o=this.oneOverRadiiSquared,c=1/Math.sqrt(r*r*o.x+s*s*o.y+i*i*o.z);return ae.multiplyScalar(c).to(n)}transformPositionToScaledSpace(t,n=[0,0,0]){return ae.from(t).scale(this.oneOverRadii).to(n)}transformPositionFromScaledSpace(t,n=[0,0,0]){return ae.from(t).scale(this.radii).to(n)}getSurfaceNormalIntersectionWithZAxis(t,n=0,r=[0,0,0]){jt(Fe(this.radii.x,this.radii.y,un.EPSILON15)),jt(this.radii.z>0),ae.from(t);let s=ae.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(s)>=this.radii.z-n))return ae.set(0,0,s).to(r)}};U.WGS84=new U(6378137,6378137,De);var vo=class{item;previous;next;constructor(t,n,r){this.item=t,this.previous=n,this.next=r}};var Do=class{head=null;tail=null;_length=0;get length(){return this._length}add(t){let n=new vo(t,this.tail,null);return this.tail?(this.tail.next=n,this.tail=n):(this.head=n,this.tail=n),++this._length,n}remove(t){t&&(t.previous&&t.next?(t.previous.next=t.next,t.next.previous=t.previous):t.previous?(t.previous.next=null,this.tail=t.previous):t.next?(t.next.previous=null,this.head=t.next):(this.head=null,this.tail=null),t.next=null,t.previous=null,--this._length)}splice(t,n){t!==n&&(this.remove(n),this._insert(t,n))}_insert(t,n){let r=t.next;t.next=n,this.tail===t?this.tail=n:r.previous=n,n.next=r,n.previous=t,++this._length}};var Uo=class{_list;_sentinel;_trimTiles;constructor(){this._list=new Do,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(t){let n=t._cacheNode;n&&this._list.splice(this._sentinel,n)}add(t,n,r){n._cacheNode||(n._cacheNode=this._list.add(n),r&&r(t,n))}unloadTile(t,n,r){let s=n._cacheNode;s&&(this._list.remove(s),n._cacheNode=null,r&&r(t,n))}unloadTiles(t,n){let r=this._trimTiles;this._trimTiles=!1;let s=this._list,i=t.maximumMemoryUsage*1024*1024,o=this._sentinel,c=s.head;for(;c!==o&&(t.gpuMemoryUsageInBytes>i||r);){let a=c.item;c=c.next,this.unloadTile(t,a,n)}}trim(){this._trimTiles=!0}};function Fg(e,t){z(e),z(t);let{rtcCenter:n,gltfUpAxis:r}=t,{computedTransform:s,boundingVolume:{center:i}}=e,o=new et(s);switch(n&&o.translate(n),r){case"Z":break;case"Y":let f=new et().rotateX(Math.PI/2);o=o.multiplyRight(f);break;case"X":let p=new et().rotateY(-Math.PI/2);o=o.multiplyRight(p);break;default:break}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);let c=new F(i);t.cartesianModelMatrix=o,t.cartesianOrigin=c;let a=U.WGS84.cartesianToCartographic(c,new F),l=U.WGS84.eastNorthUpToFixedFrame(c).invert();t.cartographicModelMatrix=l.multiplyRight(o),t.cartographicOrigin=a,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}var Tt={OUTSIDE:-1,INTERSECTING:0,INSIDE:1};var Bq=1/Math.PI*180,Cq=1/180*Math.PI,hR={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...hR}};var gt=globalThis.mathgl.config;function bl(e,{precision:t=gt.precision}={}){return e=lR(e),`${parseFloat(e.toPrecision(t))}`}function Ue(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function dn(e,t,n){let r=gt.EPSILON;n&&(gt.EPSILON=n);try{if(e===t)return!0;if(Ue(e)&&Ue(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!dn(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=gt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{gt.EPSILON=r}}function lR(e){return Math.round(e/gt.EPSILON)*gt.EPSILON}var mn=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Ue(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(gt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+bl(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!dn(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(gt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function fR(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function W(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function Go(e,t,n=""){if(gt.debug&&!fR(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Se(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Ir=class extends mn{get x(){return this[0]}set x(t){this[0]=W(t)}get y(){return this[1]}set y(t){this[1]=W(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return W(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return W(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Se(t>=0&&t<this.ELEMENTS,"index is out of range"),W(this[t])}setComponent(t,n){return Se(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var at=typeof Float32Array<"u"?Float32Array:Array;var Dq=Math.PI/180;function pR(){let e=new at(2);return at!=Float32Array&&(e[0]=0,e[1]=0),e}function Ug(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}var Uq=function(){let e=pR();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function Gg(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function zg(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}function kg(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function zo(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Ol(){let e=new at(3);return at!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function uR(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function Pl(e,t,n){let r=new at(3);return r[0]=e,r[1]=t,r[2]=n,r}function Vg(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Nl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Or(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function ko(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Vo(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function qo(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function qg(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Hg(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Yg(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function Wg(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&Nl(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var Jg=uR;var kq=function(){let e=Ol();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Fl=[0,0,0],Ho,N=class extends Ir{static get ZERO(){return Ho||(Ho=new N(0,0,0),Object.freeze(Ho)),Ho}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&Ue(t)?this.copy(t):(gt.debug&&(W(t),W(n),W(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return gt.debug&&(W(t.x),W(t.y),W(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=W(t)}angle(t){return Wg(this,t)}cross(t){return Or(this,this,t),this.check()}rotateX({radians:t,origin:n=Fl}){return qg(this,this,n,t),this.check()}rotateY({radians:t,origin:n=Fl}){return Hg(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=Fl}){return Yg(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return ko(this,this,t),this.check()}transformAsVector(t){return Gg(this,this,t),this.check()}transformByMatrix3(t){return Vo(this,this,t),this.check()}transformByMatrix2(t){return zg(this,this,t),this.check()}transformByQuaternion(t){return qo(this,this,t),this.check()}};var Yo,Pr=class extends Ir{static get ZERO(){return Yo||(Yo=new Pr(0,0,0,0),Object.freeze(Yo)),Yo}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),Ue(t)&&arguments.length===1?this.copy(t):(gt.debug&&(W(t),W(n),W(r),W(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 gt.debug&&(W(t.x),W(t.y),W(t.z),W(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]=W(t)}get w(){return this[3]}set w(t){this[3]=W(t)}transform(t){return ko(this,this,t),this.check()}transformByMatrix3(t){return zo(this,this,t),this.check()}transformByMatrix2(t){return kg(this,this,t),this.check()}transformByQuaternion(t){return qo(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var Wo=class extends mn{toString(){let t="[";if(gt.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=W(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function Xg(){let e=new at(9);return at!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function jg(e,t){if(e===t){let n=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function Kg(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=l*o-c*h,p=-l*i+c*a,u=h*i-o*a,d=n*f+r*p+s*u;return d?(d=1/d,e[0]=f*d,e[1]=(-l*r+s*h)*d,e[2]=(c*r-s*o)*d,e[3]=p*d,e[4]=(l*n-s*a)*d,e[5]=(-c*n+s*i)*d,e[6]=u*d,e[7]=(-h*n+r*a)*d,e[8]=(o*n-r*i)*d,e):null}function Zg(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8];return t*(h*i-o*a)+n*(-h*s+o*c)+r*(a*s-i*c)}function vl(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1],d=n[2],g=n[3],m=n[4],M=n[5],E=n[6],A=n[7],y=n[8];return e[0]=p*r+u*o+d*h,e[1]=p*s+u*c+d*l,e[2]=p*i+u*a+d*f,e[3]=g*r+m*o+M*h,e[4]=g*s+m*c+M*l,e[5]=g*i+m*a+M*f,e[6]=E*r+A*o+y*h,e[7]=E*s+A*c+y*l,e[8]=E*i+A*a+y*f,e}function Qg(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1];return e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=c,e[5]=a,e[6]=p*r+u*o+h,e[7]=p*s+u*c+l,e[8]=p*i+u*a+f,e}function $g(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=Math.sin(n),u=Math.cos(n);return e[0]=u*r+p*o,e[1]=u*s+p*c,e[2]=u*i+p*a,e[3]=u*o-p*r,e[4]=u*c-p*s,e[5]=u*a-p*i,e[6]=h,e[7]=l,e[8]=f,e}function Dl(e,t,n){let r=n[0],s=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function tx(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[3]=l-M,e[6]=p+m,e[1]=l+M,e[4]=1-h-d,e[7]=u-g,e[2]=p-m,e[5]=u+g,e[8]=1-h-f,e}var Ul;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(Ul||(Ul={}));var gR=Object.freeze([1,0,0,0,1,0,0,0,1]),ht=class extends Wo{static get IDENTITY(){return MR()}static get ZERO(){return xR()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Ul}constructor(t,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):n.length>0?this.copy([t,...n]):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(gR)}fromObject(t){return this.check()}fromQuaternion(t){return tx(this,t),this.check()}set(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=i,this[5]=a,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return Zg(this)}transpose(){return jg(this,this),this.check()}invert(){return Kg(this,this),this.check()}multiplyLeft(t){return vl(this,t,this),this.check()}multiplyRight(t){return vl(this,this,t),this.check()}rotate(t){return $g(this,this,t),this.check()}scale(t){return Array.isArray(t)?Dl(this,this,t):Dl(this,this,[t,t]),this.check()}translate(t){return Qg(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=Ug(n||[-0,-0],t,this);break;case 3:r=Vo(n||[-0,-0,-0],t,this);break;case 4:r=zo(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return Go(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},Jo,Xo=null;function xR(){return Jo||(Jo=new ht([0,0,0,0,0,0,0,0,0]),Object.freeze(Jo)),Jo}function MR(){return Xo||(Xo=new ht,Object.freeze(Xo)),Xo}var $s={};At($s,{add:()=>rw,adjoint:()=>CR,clone:()=>yR,copy:()=>ER,create:()=>AR,decompose:()=>qR,determinant:()=>LR,equals:()=>cw,exactEquals:()=>ow,frob:()=>nw,fromQuat:()=>WR,fromQuat2:()=>zR,fromRotation:()=>vR,fromRotationTranslation:()=>rx,fromRotationTranslationScale:()=>HR,fromRotationTranslationScaleOrigin:()=>YR,fromScaling:()=>FR,fromTranslation:()=>NR,fromValues:()=>TR,fromXRotation:()=>DR,fromYRotation:()=>UR,fromZRotation:()=>GR,frustum:()=>JR,getRotation:()=>VR,getScaling:()=>sx,getTranslation:()=>kR,identity:()=>ex,invert:()=>BR,lookAt:()=>$R,mul:()=>aw,multiply:()=>nx,multiplyScalar:()=>sw,multiplyScalarAndAdd:()=>iw,ortho:()=>ZR,orthoNO:()=>ox,orthoZO:()=>QR,perspective:()=>XR,perspectiveFromFieldOfView:()=>KR,perspectiveNO:()=>ix,perspectiveZO:()=>jR,rotate:()=>IR,rotateX:()=>bR,rotateY:()=>OR,rotateZ:()=>PR,scale:()=>wR,set:()=>_R,str:()=>ew,sub:()=>hw,subtract:()=>cx,targetTo:()=>tw,translate:()=>RR,transpose:()=>SR});function AR(){let e=new at(16);return at!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e}function yR(e){let t=new at(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}function ER(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function TR(e,t,n,r,s,i,o,c,a,h,l,f,p,u,d,g){let m=new at(16);return m[0]=e,m[1]=t,m[2]=n,m[3]=r,m[4]=s,m[5]=i,m[6]=o,m[7]=c,m[8]=a,m[9]=h,m[10]=l,m[11]=f,m[12]=p,m[13]=u,m[14]=d,m[15]=g,m}function _R(e,t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return e[0]=t,e[1]=n,e[2]=r,e[3]=s,e[4]=i,e[5]=o,e[6]=c,e[7]=a,e[8]=h,e[9]=l,e[10]=f,e[11]=p,e[12]=u,e[13]=d,e[14]=g,e[15]=m,e}function ex(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function SR(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function BR(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m,C=E*I-A*w+y*R+T*x-_*S+L*B;return C?(C=1/C,e[0]=(c*I-a*w+h*R)*C,e[1]=(s*w-r*I-i*R)*C,e[2]=(g*L-m*_+M*T)*C,e[3]=(p*_-f*L-u*T)*C,e[4]=(a*x-o*I-h*S)*C,e[5]=(n*I-s*x+i*S)*C,e[6]=(m*y-d*L-M*A)*C,e[7]=(l*L-p*y+u*A)*C,e[8]=(o*w-c*x+h*B)*C,e[9]=(r*x-n*w-i*B)*C,e[10]=(d*_-g*y+M*E)*C,e[11]=(f*y-l*_-u*E)*C,e[12]=(c*S-o*R-a*B)*C,e[13]=(n*R-r*S+s*B)*C,e[14]=(g*A-d*T-m*E)*C,e[15]=(l*T-f*A+p*E)*C,e):null}function CR(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m;return e[0]=c*I-a*w+h*R,e[1]=s*w-r*I-i*R,e[2]=g*L-m*_+M*T,e[3]=p*_-f*L-u*T,e[4]=a*x-o*I-h*S,e[5]=n*I-s*x+i*S,e[6]=m*y-d*L-M*A,e[7]=l*L-p*y+u*A,e[8]=o*w-c*x+h*B,e[9]=r*x-n*w-i*B,e[10]=d*_-g*y+M*E,e[11]=f*y-l*_-u*E,e[12]=c*S-o*R-a*B,e[13]=n*R-r*S+s*B,e[14]=g*A-d*T-m*E,e[15]=l*T-f*A+p*E,e}function LR(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],p=e[11],u=e[12],d=e[13],g=e[14],m=e[15],M=t*o-n*i,E=t*c-r*i,A=n*c-r*o,y=h*d-l*u,T=h*g-f*u,_=l*g-f*d,L=t*_-n*T+r*y,B=i*_-o*T+c*y,S=h*A-l*E+f*M,x=u*A-d*E+g*M;return a*L-s*B+m*S-p*x}function nx(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=t[9],u=t[10],d=t[11],g=t[12],m=t[13],M=t[14],E=t[15],A=n[0],y=n[1],T=n[2],_=n[3];return e[0]=A*r+y*c+T*f+_*g,e[1]=A*s+y*a+T*p+_*m,e[2]=A*i+y*h+T*u+_*M,e[3]=A*o+y*l+T*d+_*E,A=n[4],y=n[5],T=n[6],_=n[7],e[4]=A*r+y*c+T*f+_*g,e[5]=A*s+y*a+T*p+_*m,e[6]=A*i+y*h+T*u+_*M,e[7]=A*o+y*l+T*d+_*E,A=n[8],y=n[9],T=n[10],_=n[11],e[8]=A*r+y*c+T*f+_*g,e[9]=A*s+y*a+T*p+_*m,e[10]=A*i+y*h+T*u+_*M,e[11]=A*o+y*l+T*d+_*E,A=n[12],y=n[13],T=n[14],_=n[15],e[12]=A*r+y*c+T*f+_*g,e[13]=A*s+y*a+T*p+_*m,e[14]=A*i+y*h+T*u+_*M,e[15]=A*o+y*l+T*d+_*E,e}function RR(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,h,l,f,p,u,d,g,m,M;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],p=t[6],u=t[7],d=t[8],g=t[9],m=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=p,e[7]=u,e[8]=d,e[9]=g,e[10]=m,e[11]=M,e[12]=o*r+l*s+d*i+t[12],e[13]=c*r+f*s+g*i+t[13],e[14]=a*r+p*s+m*i+t[14],e[15]=h*r+u*s+M*i+t[15]),e}function wR(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function IR(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,h,l,f,p,u,d,g,m,M,E,A,y,T,_,L,B,S,x,R,w,I,C,P;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,h=Math.sin(n),a=Math.cos(n),l=1-a,f=t[0],p=t[1],u=t[2],d=t[3],g=t[4],m=t[5],M=t[6],E=t[7],A=t[8],y=t[9],T=t[10],_=t[11],L=s*s*l+a,B=i*s*l+o*h,S=o*s*l-i*h,x=s*i*l-o*h,R=i*i*l+a,w=o*i*l+s*h,I=s*o*l+i*h,C=i*o*l-s*h,P=o*o*l+a,e[0]=f*L+g*B+A*S,e[1]=p*L+m*B+y*S,e[2]=u*L+M*B+T*S,e[3]=d*L+E*B+_*S,e[4]=f*x+g*R+A*w,e[5]=p*x+m*R+y*w,e[6]=u*x+M*R+T*w,e[7]=d*x+E*R+_*w,e[8]=f*I+g*C+A*P,e[9]=p*I+m*C+y*P,e[10]=u*I+M*C+T*P,e[11]=d*I+E*C+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function bR(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+h*r,e[5]=o*s+l*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=h*s-i*r,e[9]=l*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function OR(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-h*r,e[1]=o*s-l*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+h*s,e[9]=o*r+l*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function PR(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+h*r,e[1]=o*s+l*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=h*s-i*r,e[5]=l*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function NR(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}function FR(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function vR(e,t,n){let r=n[0],s=n[1],i=n[2],o=Math.sqrt(r*r+s*s+i*i),c,a,h;return o<1e-6?null:(o=1/o,r*=o,s*=o,i*=o,a=Math.sin(t),c=Math.cos(t),h=1-c,e[0]=r*r*h+c,e[1]=s*r*h+i*a,e[2]=i*r*h-s*a,e[3]=0,e[4]=r*s*h-i*a,e[5]=s*s*h+c,e[6]=i*s*h+r*a,e[7]=0,e[8]=r*i*h+s*a,e[9]=s*i*h-r*a,e[10]=i*i*h+c,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function DR(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=n,e[7]=0,e[8]=0,e[9]=-n,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function UR(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=0,e[2]=-n,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=n,e[9]=0,e[10]=r,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function GR(e,t){let n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[2]=0,e[3]=0,e[4]=-n,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function rx(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=r+r,a=s+s,h=i+i,l=r*c,f=r*a,p=r*h,u=s*a,d=s*h,g=i*h,m=o*c,M=o*a,E=o*h;return e[0]=1-(u+g),e[1]=f+E,e[2]=p-M,e[3]=0,e[4]=f-E,e[5]=1-(l+g),e[6]=d+m,e[7]=0,e[8]=p+M,e[9]=d-m,e[10]=1-(l+u),e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function zR(e,t){let n=new at(3),r=-t[0],s=-t[1],i=-t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=r*r+s*s+i*i+o*o;return f>0?(n[0]=(c*o+l*r+a*i-h*s)*2/f,n[1]=(a*o+l*s+h*r-c*i)*2/f,n[2]=(h*o+l*i+c*s-a*r)*2/f):(n[0]=(c*o+l*r+a*i-h*s)*2,n[1]=(a*o+l*s+h*r-c*i)*2,n[2]=(h*o+l*i+c*s-a*r)*2),rx(e,t,n),e}function kR(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}function sx(e,t){let n=t[0],r=t[1],s=t[2],i=t[4],o=t[5],c=t[6],a=t[8],h=t[9],l=t[10];return e[0]=Math.sqrt(n*n+r*r+s*s),e[1]=Math.sqrt(i*i+o*o+c*c),e[2]=Math.sqrt(a*a+h*h+l*l),e}function VR(e,t){let n=new at(3);sx(n,t);let r=1/n[0],s=1/n[1],i=1/n[2],o=t[0]*r,c=t[1]*s,a=t[2]*i,h=t[4]*r,l=t[5]*s,f=t[6]*i,p=t[8]*r,u=t[9]*s,d=t[10]*i,g=o+l+d,m=0;return g>0?(m=Math.sqrt(g+1)*2,e[3]=.25*m,e[0]=(f-u)/m,e[1]=(p-a)/m,e[2]=(c-h)/m):o>l&&o>d?(m=Math.sqrt(1+o-l-d)*2,e[3]=(f-u)/m,e[0]=.25*m,e[1]=(c+h)/m,e[2]=(p+a)/m):l>d?(m=Math.sqrt(1+l-o-d)*2,e[3]=(p-a)/m,e[0]=(c+h)/m,e[1]=.25*m,e[2]=(f+u)/m):(m=Math.sqrt(1+d-o-l)*2,e[3]=(c-h)/m,e[0]=(p+a)/m,e[1]=(f+u)/m,e[2]=.25*m),e}function qR(e,t,n,r){t[0]=r[12],t[1]=r[13],t[2]=r[14];let s=r[0],i=r[1],o=r[2],c=r[4],a=r[5],h=r[6],l=r[8],f=r[9],p=r[10];n[0]=Math.sqrt(s*s+i*i+o*o),n[1]=Math.sqrt(c*c+a*a+h*h),n[2]=Math.sqrt(l*l+f*f+p*p);let u=1/n[0],d=1/n[1],g=1/n[2],m=s*u,M=i*d,E=o*g,A=c*u,y=a*d,T=h*g,_=l*u,L=f*d,B=p*g,S=m+y+B,x=0;return S>0?(x=Math.sqrt(S+1)*2,e[3]=.25*x,e[0]=(T-L)/x,e[1]=(_-E)/x,e[2]=(M-A)/x):m>y&&m>B?(x=Math.sqrt(1+m-y-B)*2,e[3]=(T-L)/x,e[0]=.25*x,e[1]=(M+A)/x,e[2]=(_+E)/x):y>B?(x=Math.sqrt(1+y-m-B)*2,e[3]=(_-E)/x,e[0]=(M+A)/x,e[1]=.25*x,e[2]=(T+L)/x):(x=Math.sqrt(1+B-m-y)*2,e[3]=(M-A)/x,e[0]=(_+E)/x,e[1]=(T+L)/x,e[2]=.25*x),e}function HR(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=s+s,h=i+i,l=o+o,f=s*a,p=s*h,u=s*l,d=i*h,g=i*l,m=o*l,M=c*a,E=c*h,A=c*l,y=r[0],T=r[1],_=r[2];return e[0]=(1-(d+m))*y,e[1]=(p+A)*y,e[2]=(u-E)*y,e[3]=0,e[4]=(p-A)*T,e[5]=(1-(f+m))*T,e[6]=(g+M)*T,e[7]=0,e[8]=(u+E)*_,e[9]=(g-M)*_,e[10]=(1-(f+d))*_,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function YR(e,t,n,r,s){let i=t[0],o=t[1],c=t[2],a=t[3],h=i+i,l=o+o,f=c+c,p=i*h,u=i*l,d=i*f,g=o*l,m=o*f,M=c*f,E=a*h,A=a*l,y=a*f,T=r[0],_=r[1],L=r[2],B=s[0],S=s[1],x=s[2],R=(1-(g+M))*T,w=(u+y)*T,I=(d-A)*T,C=(u-y)*_,P=(1-(p+M))*_,V=(m+E)*_,G=(d+A)*L,Q=(m-E)*L,q=(1-(p+g))*L;return e[0]=R,e[1]=w,e[2]=I,e[3]=0,e[4]=C,e[5]=P,e[6]=V,e[7]=0,e[8]=G,e[9]=Q,e[10]=q,e[11]=0,e[12]=n[0]+B-(R*B+C*S+G*x),e[13]=n[1]+S-(w*B+P*S+Q*x),e[14]=n[2]+x-(I*B+V*S+q*x),e[15]=1,e}function WR(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[1]=l+M,e[2]=p-m,e[3]=0,e[4]=l-M,e[5]=1-h-d,e[6]=u+g,e[7]=0,e[8]=p+m,e[9]=u-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function JR(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function ix(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var XR=ix;function jR(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=s*o,e[14]=s*r*o}else e[10]=-1,e[14]=-r;return e}function KR(e,t,n,r){let s=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),o=Math.tan(t.leftDegrees*Math.PI/180),c=Math.tan(t.rightDegrees*Math.PI/180),a=2/(o+c),h=2/(s+i);return e[0]=a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=h,e[6]=0,e[7]=0,e[8]=-((o-c)*a*.5),e[9]=(s-i)*h*.5,e[10]=r/(n-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*n/(n-r),e[15]=0,e}function ox(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*h,e[15]=1,e}var ZR=ox;function QR(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=i*h,e[15]=1,e}function $R(e,t,n,r){let s,i,o,c,a,h,l,f,p,u,d=t[0],g=t[1],m=t[2],M=r[0],E=r[1],A=r[2],y=n[0],T=n[1],_=n[2];return Math.abs(d-y)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(m-_)<1e-6?ex(e):(f=d-y,p=g-T,u=m-_,s=1/Math.sqrt(f*f+p*p+u*u),f*=s,p*=s,u*=s,i=E*u-A*p,o=A*f-M*u,c=M*p-E*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-u*o,h=u*i-f*c,l=f*o-p*i,s=Math.sqrt(a*a+h*h+l*l),s?(s=1/s,a*=s,h*=s,l*=s):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*d+o*g+c*m),e[13]=-(a*d+h*g+l*m),e[14]=-(f*d+p*g+u*m),e[15]=1,e)}function tw(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=r[0],a=r[1],h=r[2],l=s-n[0],f=i-n[1],p=o-n[2],u=l*l+f*f+p*p;u>0&&(u=1/Math.sqrt(u),l*=u,f*=u,p*=u);let d=a*p-h*f,g=h*l-c*p,m=c*f-a*l;return u=d*d+g*g+m*m,u>0&&(u=1/Math.sqrt(u),d*=u,g*=u,m*=u),e[0]=d,e[1]=g,e[2]=m,e[3]=0,e[4]=f*m-p*g,e[5]=p*d-l*m,e[6]=l*g-f*d,e[7]=0,e[8]=l,e[9]=f,e[10]=p,e[11]=0,e[12]=s,e[13]=i,e[14]=o,e[15]=1,e}function ew(e){return`mat4(${e[0]}, ${e[1]}, ${e[2]}, ${e[3]}, ${e[4]}, ${e[5]}, ${e[6]}, ${e[7]}, ${e[8]}, ${e[9]}, ${e[10]}, ${e[11]}, ${e[12]}, ${e[13]}, ${e[14]}, ${e[15]})`}function nw(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]+e[3]*e[3]+e[4]*e[4]+e[5]*e[5]+e[6]*e[6]+e[7]*e[7]+e[8]*e[8]+e[9]*e[9]+e[10]*e[10]+e[11]*e[11]+e[12]*e[12]+e[13]*e[13]+e[14]*e[14]+e[15]*e[15])}function rw(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e[4]=t[4]+n[4],e[5]=t[5]+n[5],e[6]=t[6]+n[6],e[7]=t[7]+n[7],e[8]=t[8]+n[8],e[9]=t[9]+n[9],e[10]=t[10]+n[10],e[11]=t[11]+n[11],e[12]=t[12]+n[12],e[13]=t[13]+n[13],e[14]=t[14]+n[14],e[15]=t[15]+n[15],e}function cx(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e[4]=t[4]-n[4],e[5]=t[5]-n[5],e[6]=t[6]-n[6],e[7]=t[7]-n[7],e[8]=t[8]-n[8],e[9]=t[9]-n[9],e[10]=t[10]-n[10],e[11]=t[11]-n[11],e[12]=t[12]-n[12],e[13]=t[13]-n[13],e[14]=t[14]-n[14],e[15]=t[15]-n[15],e}function sw(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e[4]=t[4]*n,e[5]=t[5]*n,e[6]=t[6]*n,e[7]=t[7]*n,e[8]=t[8]*n,e[9]=t[9]*n,e[10]=t[10]*n,e[11]=t[11]*n,e[12]=t[12]*n,e[13]=t[13]*n,e[14]=t[14]*n,e[15]=t[15]*n,e}function iw(e,t,n,r){return e[0]=t[0]+n[0]*r,e[1]=t[1]+n[1]*r,e[2]=t[2]+n[2]*r,e[3]=t[3]+n[3]*r,e[4]=t[4]+n[4]*r,e[5]=t[5]+n[5]*r,e[6]=t[6]+n[6]*r,e[7]=t[7]+n[7]*r,e[8]=t[8]+n[8]*r,e[9]=t[9]+n[9]*r,e[10]=t[10]+n[10]*r,e[11]=t[11]+n[11]*r,e[12]=t[12]+n[12]*r,e[13]=t[13]+n[13]*r,e[14]=t[14]+n[14]*r,e[15]=t[15]+n[15]*r,e}function ow(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function cw(e,t){let n=e[0],r=e[1],s=e[2],i=e[3],o=e[4],c=e[5],a=e[6],h=e[7],l=e[8],f=e[9],p=e[10],u=e[11],d=e[12],g=e[13],m=e[14],M=e[15],E=t[0],A=t[1],y=t[2],T=t[3],_=t[4],L=t[5],B=t[6],S=t[7],x=t[8],R=t[9],w=t[10],I=t[11],C=t[12],P=t[13],V=t[14],G=t[15];return Math.abs(n-E)<=1e-6*Math.max(1,Math.abs(n),Math.abs(E))&&Math.abs(r-A)<=1e-6*Math.max(1,Math.abs(r),Math.abs(A))&&Math.abs(s-y)<=1e-6*Math.max(1,Math.abs(s),Math.abs(y))&&Math.abs(i-T)<=1e-6*Math.max(1,Math.abs(i),Math.abs(T))&&Math.abs(o-_)<=1e-6*Math.max(1,Math.abs(o),Math.abs(_))&&Math.abs(c-L)<=1e-6*Math.max(1,Math.abs(c),Math.abs(L))&&Math.abs(a-B)<=1e-6*Math.max(1,Math.abs(a),Math.abs(B))&&Math.abs(h-S)<=1e-6*Math.max(1,Math.abs(h),Math.abs(S))&&Math.abs(l-x)<=1e-6*Math.max(1,Math.abs(l),Math.abs(x))&&Math.abs(f-R)<=1e-6*Math.max(1,Math.abs(f),Math.abs(R))&&Math.abs(p-w)<=1e-6*Math.max(1,Math.abs(p),Math.abs(w))&&Math.abs(u-I)<=1e-6*Math.max(1,Math.abs(u),Math.abs(I))&&Math.abs(d-C)<=1e-6*Math.max(1,Math.abs(d),Math.abs(C))&&Math.abs(g-P)<=1e-6*Math.max(1,Math.abs(g),Math.abs(P))&&Math.abs(m-V)<=1e-6*Math.max(1,Math.abs(m),Math.abs(V))&&Math.abs(M-G)<=1e-6*Math.max(1,Math.abs(M),Math.abs(G))}var aw=nx,hw=cx;function lw(){let e=new at(4);return at!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ax(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function hx(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function lx(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function fx(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function px(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function ux(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function dx(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function mx(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],h=n[3],l=h*r+c*i-a*s,f=h*s+a*r-o*i,p=h*i+o*s-c*r,u=-o*r-c*s-a*i;return e[0]=l*h+u*-o+f*-a-p*-c,e[1]=f*h+u*-c+p*-o-l*-a,e[2]=p*h+u*-a+l*-c-f*-o,e[3]=t[3],e}var f7=function(){let e=lw();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();function gx(){let e=new at(4);return at!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function xx(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Gl(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function zl(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],h=n[2],l=n[3];return e[0]=r*l+o*c+s*h-i*a,e[1]=s*l+o*a+i*c-r*h,e[2]=i*l+o*h+r*a-s*c,e[3]=o*l-r*c-s*a-i*h,e}function Mx(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function Ax(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function yx(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function Ex(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function ti(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],h=n[1],l=n[2],f=n[3],p,u,d,g,m;return p=s*a+i*h+o*l+c*f,p<0&&(p=-p,a=-a,h=-h,l=-l,f=-f),1-p>1e-6?(u=Math.acos(p),m=Math.sin(u),d=Math.sin((1-r)*u)/m,g=Math.sin(r*u)/m):(d=1-r,g=r),e[0]=d*s+g*a,e[1]=d*i+g*h,e[2]=d*o+g*l,e[3]=d*c+g*f,e}function Tx(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function _x(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function kl(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var Sx=ax;var Bx=hx,Cx=ux,Lx=dx,Rx=lx;var wx=fx;var Ix=px;var bx=function(){let e=Ol(),t=Pl(1,0,0),n=Pl(0,1,0);return function(r,s,i){let o=Nl(s,i);return o<-.999999?(Or(e,t,s),Jg(e)<1e-6&&Or(e,n,s),Vg(e,e),Gl(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(Or(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,Ix(r,r))}}(),x7=function(){let e=gx(),t=gx();return function(n,r,s,i,o,c){return ti(e,r,o,c),ti(t,s,i,c),ti(n,e,t,2*c*(1-c)),n}}(),M7=function(){let e=Xg();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],Ix(t,kl(t,e))}}();var pw=[0,0,0,1],Nr=class extends mn{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 kl(this,t),this.check()}fromAxisRotation(t,n){return Gl(this,t,n),this.check()}identity(){return xx(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=W(t)}get y(){return this[1]}set y(t){this[1]=W(t)}get z(){return this[2]}set z(t){this[2]=W(t)}get w(){return this[3]}set w(t){this[3]=W(t)}len(){return Rx(this)}lengthSquared(){return wx(this)}dot(t){return Cx(this,t)}rotationTo(t,n){return bx(this,t,n),this.check()}add(t){return Sx(this,this,t),this.check()}calculateW(){return Ex(this,this),this.check()}conjugate(){return _x(this,this),this.check()}invert(){return Tx(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(Lx(this,t,n,r),this.check())}multiplyRight(t){return zl(this,this,t),this.check()}multiplyLeft(t){return zl(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return Mx(this,this,t),this.check()}rotateY(t){return Ax(this,this,t),this.check()}rotateZ(t){return yx(this,this,t),this.check()}scale(t){return Bx(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=pw,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return ti(this,s,i,o),this.check()}transformVector4(t,n=new Pr){return mx(n,t,this),Go(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Fr={};At(Fr,{EPSILON1:()=>uw,EPSILON10:()=>Tw,EPSILON11:()=>_w,EPSILON12:()=>Sw,EPSILON13:()=>Bw,EPSILON14:()=>Cw,EPSILON15:()=>Lw,EPSILON16:()=>Rw,EPSILON17:()=>ww,EPSILON18:()=>Iw,EPSILON19:()=>bw,EPSILON2:()=>dw,EPSILON20:()=>Ow,EPSILON3:()=>mw,EPSILON4:()=>gw,EPSILON5:()=>xw,EPSILON6:()=>Mw,EPSILON7:()=>Aw,EPSILON8:()=>yw,EPSILON9:()=>Ew,PI_OVER_FOUR:()=>Nw,PI_OVER_SIX:()=>Fw,PI_OVER_TWO:()=>Pw,TWO_PI:()=>vw});var uw=.1,dw=.01,mw=.001,gw=1e-4,xw=1e-5,Mw=1e-6,Aw=1e-7,yw=1e-8,Ew=1e-9,Tw=1e-10,_w=1e-11,Sw=1e-12,Bw=1e-13,Cw=1e-14,Lw=1e-15,Rw=1e-16,ww=1e-17,Iw=1e-18,bw=1e-19,Ow=1e-20,Pw=Math.PI/2,Nw=Math.PI/4,Fw=Math.PI/6,vw=Math.PI*2;var K7=new N,Z7=new N;var ei=new N,Ox=new N,Kt=class{constructor(t=[0,0,0],n=0){this.radius=-0,this.center=new N,this.fromCenterRadius(t,n)}fromCenterRadius(t,n){return this.center.from(t),this.radius=n,this}fromCornerPoints(t,n){return n=ei.from(n),this.center=new N().from(t).add(n).scale(.5),this.radius=this.center.distance(n),this}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.radius===t.radius}clone(){return new Kt(this.center,this.radius)}union(t){let n=this.center,r=this.radius,s=t.center,i=t.radius,o=ei.copy(s).subtract(n),c=o.magnitude();if(r>=c+i)return this.clone();if(i>=c+r)return t.clone();let a=(r+c+i)*.5;return Ox.copy(o).scale((-r+a)/c).add(n),this.center.copy(Ox),this.radius=a,this}expand(t){let r=ei.from(t).subtract(this.center).magnitude();return r>this.radius&&(this.radius=r),this}transform(t){this.center.transform(t);let n=$s.getScaling(ei,t);return this.radius=Math.max(n[0],Math.max(n[1],n[2]))*this.radius,this}distanceSquaredTo(t){let n=this.distanceTo(t);return n*n}distanceTo(t){let r=ei.from(t).subtract(this.center);return Math.max(0,r.len()-this.radius)}intersectPlane(t){let n=this.center,r=this.radius,i=t.normal.dot(n)+t.distance;return i<-r?Tt.OUTSIDE:i<r?Tt.INTERSECTING:Tt.INSIDE}};var Dw=new N,Uw=new N,jo=new N,Ko=new N,Zo=new N,Gw=new N,zw=new N,Ge={COLUMN0ROW0:0,COLUMN0ROW1:1,COLUMN0ROW2:2,COLUMN1ROW0:3,COLUMN1ROW1:4,COLUMN1ROW2:5,COLUMN2ROW0:6,COLUMN2ROW1:7,COLUMN2ROW2:8},he=class{constructor(t=[0,0,0],n=[0,0,0,0,0,0,0,0,0]){this.center=new N().from(t),this.halfAxes=new ht(n)}get halfSize(){let t=this.halfAxes.getColumn(0),n=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new N(t).len(),new N(n).len(),new N(r).len()]}get quaternion(){let t=this.halfAxes.getColumn(0),n=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),s=new N(t).normalize(),i=new N(n).normalize(),o=new N(r).normalize();return new Nr().fromMatrix3(new ht([...s,...i,...o]))}fromCenterHalfSizeQuaternion(t,n,r){let s=new Nr(r),i=new ht().fromQuaternion(s);return i[0]=i[0]*n[0],i[1]=i[1]*n[0],i[2]=i[2]*n[0],i[3]=i[3]*n[1],i[4]=i[4]*n[1],i[5]=i[5]*n[1],i[6]=i[6]*n[2],i[7]=i[7]*n[2],i[8]=i[8]*n[2],this.center=new N().from(t),this.halfAxes=i,this}clone(){return new he(this.center,this.halfAxes)}equals(t){return this===t||Boolean(t)&&this.center.equals(t.center)&&this.halfAxes.equals(t.halfAxes)}getBoundingSphere(t=new Kt){let n=this.halfAxes,r=n.getColumn(0,jo),s=n.getColumn(1,Ko),i=n.getColumn(2,Zo),o=Dw.copy(r).add(s).add(i);return t.center.copy(this.center),t.radius=o.magnitude(),t}intersectPlane(t){let n=this.center,r=t.normal,s=this.halfAxes,i=r.x,o=r.y,c=r.z,a=Math.abs(i*s[Ge.COLUMN0ROW0]+o*s[Ge.COLUMN0ROW1]+c*s[Ge.COLUMN0ROW2])+Math.abs(i*s[Ge.COLUMN1ROW0]+o*s[Ge.COLUMN1ROW1]+c*s[Ge.COLUMN1ROW2])+Math.abs(i*s[Ge.COLUMN2ROW0]+o*s[Ge.COLUMN2ROW1]+c*s[Ge.COLUMN2ROW2]),h=r.dot(n)+t.distance;return h<=-a?Tt.OUTSIDE:h>=a?Tt.INSIDE:Tt.INTERSECTING}distanceTo(t){return Math.sqrt(this.distanceSquaredTo(t))}distanceSquaredTo(t){let n=Uw.from(t).subtract(this.center),r=this.halfAxes,s=r.getColumn(0,jo),i=r.getColumn(1,Ko),o=r.getColumn(2,Zo),c=s.magnitude(),a=i.magnitude(),h=o.magnitude();s.normalize(),i.normalize(),o.normalize();let l=0,f;return f=Math.abs(n.dot(s))-c,f>0&&(l+=f*f),f=Math.abs(n.dot(i))-a,f>0&&(l+=f*f),f=Math.abs(n.dot(o))-h,f>0&&(l+=f*f),l}computePlaneDistances(t,n,r=[-0,-0]){let s=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY,o=this.center,c=this.halfAxes,a=c.getColumn(0,jo),h=c.getColumn(1,Ko),l=c.getColumn(2,Zo),f=Gw.copy(a).add(h).add(l).add(o),p=zw.copy(f).subtract(t),u=n.dot(p);return s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).add(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).subtract(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),f.copy(o).add(a).subtract(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).add(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).add(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).subtract(h).add(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),o.copy(f).subtract(a).subtract(h).subtract(l),p.copy(f).subtract(t),u=n.dot(p),s=Math.min(u,s),i=Math.max(u,i),r[0]=s,r[1]=i,r}transform(t){this.center.transformAsPoint(t);let n=this.halfAxes.getColumn(0,jo);n.transformAsPoint(t);let r=this.halfAxes.getColumn(1,Ko);r.transformAsPoint(t);let s=this.halfAxes.getColumn(2,Zo);return s.transformAsPoint(t),this.halfAxes=new ht([...n,...r,...s]),this}getTransform(){throw new Error("not implemented")}};var Px=new N,Nx=new N,wt=class{constructor(t=[0,0,1],n=0){this.normal=new N,this.distance=-0,this.fromNormalDistance(t,n)}fromNormalDistance(t,n){return Se(Number.isFinite(n)),this.normal.from(t).normalize(),this.distance=n,this}fromPointNormal(t,n){t=Px.from(t),this.normal.from(n).normalize();let r=-this.normal.dot(t);return this.distance=r,this}fromCoefficients(t,n,r,s){return this.normal.set(t,n,r),Se(dn(this.normal.len(),1)),this.distance=s,this}clone(){return new wt(this.normal,this.distance)}equals(t){return dn(this.distance,t.distance)&&dn(this.normal,t.normal)}getPointDistance(t){return this.normal.dot(t)+this.distance}transform(t){let n=Nx.copy(this.normal).transformAsVector(t).normalize(),r=this.normal.scale(-this.distance).transform(t);return this.fromPointNormal(r,n)}projectPointOntoPlane(t,n=[0,0,0]){let r=Px.from(t),s=this.getPointDistance(r),i=Nx.copy(this.normal).scale(s);return r.subtract(i).to(n)}};var Fx=[new N([1,0,0]),new N([0,1,0]),new N([0,0,1])],vx=new N,kw=new N,_t=class{constructor(t=[]){this.planes=t}fromBoundingSphere(t){this.planes.length=2*Fx.length;let n=t.center,r=t.radius,s=0;for(let i of Fx){let o=this.planes[s],c=this.planes[s+1];o||(o=this.planes[s]=new wt),c||(c=this.planes[s+1]=new wt);let a=vx.copy(i).scale(-r).add(n);o.fromPointNormal(a,i);let h=vx.copy(i).scale(r).add(n),l=kw.copy(i).negate();c.fromPointNormal(h,l),s+=2}return this}computeVisibility(t){let n=Tt.INSIDE;for(let r of this.planes)switch(t.intersectPlane(r)){case Tt.OUTSIDE:return Tt.OUTSIDE;case Tt.INTERSECTING:n=Tt.INTERSECTING;break;default:}return n}computeVisibilityWithPlaneMask(t,n){if(Se(Number.isFinite(n),"parentPlaneMask is required."),n===_t.MASK_OUTSIDE||n===_t.MASK_INSIDE)return n;let r=_t.MASK_INSIDE,s=this.planes;for(let i=0;i<this.planes.length;++i){let o=i<31?1<<i:0;if(i<31&&!(n&o))continue;let c=s[i],a=t.intersectPlane(c);if(a===Tt.OUTSIDE)return _t.MASK_OUTSIDE;a===Tt.INTERSECTING&&(r|=o)}return r}};_t.MASK_OUTSIDE=4294967295;_t.MASK_INSIDE=0;_t.MASK_INDETERMINATE=2147483647;var gH=new N,xH=new N,MH=new N,AH=new N,yH=new N;var CH=new N,LH=new N,RH=new N,wH=new N,IH=new N,bH=new N,OH=new N,PH=new N,NH=new N,FH=new N,vH=new N,DH=new N;var Be=new ht,qw=new ht,Hw=new ht,Qo=new ht,Dx=new ht;function Hl(e,t={}){let n=Fr.EPSILON20,r=10,s=0,i=0,o=qw,c=Hw;o.identity(),c.copy(e);let a=n*Yw(c);for(;i<r&&Ww(c)>a;)Jw(c,Qo),Dx.copy(Qo).transpose(),c.multiplyRight(Qo),c.multiplyLeft(Dx),o.multiplyRight(Qo),++s>2&&(++i,s=0);return t.unitary=o.toTarget(t.unitary),t.diagonal=c.toTarget(t.diagonal),t}function Yw(e){let t=0;for(let n=0;n<9;++n){let r=e[n];t+=r*r}return Math.sqrt(t)}var Vl=[1,0,0],ql=[2,2,1];function Ww(e){let t=0;for(let n=0;n<3;++n){let r=e[Be.getElementIndex(ql[n],Vl[n])];t+=2*r*r}return Math.sqrt(t)}function Jw(e,t){let n=Fr.EPSILON15,r=0,s=1;for(let h=0;h<3;++h){let l=Math.abs(e[Be.getElementIndex(ql[h],Vl[h])]);l>r&&(s=h,r=l)}let i=Vl[s],o=ql[s],c=1,a=0;if(Math.abs(e[Be.getElementIndex(o,i)])>n){let h=e[Be.getElementIndex(o,o)],l=e[Be.getElementIndex(i,i)],f=e[Be.getElementIndex(o,i)],p=(h-l)/2/f,u;p<0?u=-1/(-p+Math.sqrt(1+p*p)):u=1/(p+Math.sqrt(1+p*p)),c=1/Math.sqrt(1+u*u),a=u*c}return ht.IDENTITY.to(t),t[Be.getElementIndex(i,i)]=t[Be.getElementIndex(o,o)]=c,t[Be.getElementIndex(o,i)]=a,t[Be.getElementIndex(i,o)]=-a,t}var gn=new N,jw=new N,Kw=new N,Zw=new N,Qw=new N,$w=new ht,tI={diagonal:new ht,unitary:new ht};function Yl(e,t=new he){if(!e||e.length===0)return t.halfAxes=new ht([0,0,0,0,0,0,0,0,0]),t.center=new N,t;let n=e.length,r=new N(0,0,0);for(let S of e)r.add(S);let s=1/n;r.multiplyByScalar(s);let i=0,o=0,c=0,a=0,h=0,l=0;for(let S of e){let x=gn.copy(S).subtract(r);i+=x.x*x.x,o+=x.x*x.y,c+=x.x*x.z,a+=x.y*x.y,h+=x.y*x.z,l+=x.z*x.z}i*=s,o*=s,c*=s,a*=s,h*=s,l*=s;let f=$w;f[0]=i,f[1]=o,f[2]=c,f[3]=o,f[4]=a,f[5]=h,f[6]=c,f[7]=h,f[8]=l;let{unitary:p}=Hl(f,tI),u=t.halfAxes.copy(p),d=u.getColumn(0,Kw),g=u.getColumn(1,Zw),m=u.getColumn(2,Qw),M=-Number.MAX_VALUE,E=-Number.MAX_VALUE,A=-Number.MAX_VALUE,y=Number.MAX_VALUE,T=Number.MAX_VALUE,_=Number.MAX_VALUE;for(let S of e)gn.copy(S),M=Math.max(gn.dot(d),M),E=Math.max(gn.dot(g),E),A=Math.max(gn.dot(m),A),y=Math.min(gn.dot(d),y),T=Math.min(gn.dot(g),T),_=Math.min(gn.dot(m),_);d=d.multiplyByScalar(.5*(y+M)),g=g.multiplyByScalar(.5*(T+E)),m=m.multiplyByScalar(.5*(_+A)),t.center.copy(d).add(g).add(m);let L=jw.set(M-y,E-T,A-_).multiplyByScalar(.5),B=new ht([L[0],0,0,0,L[1],0,0,0,L[2]]);return t.halfAxes.multiplyRight(B),t}var Ux=new F,Wl=new F,Jl=new _t([new wt,new wt,new wt,new wt,new wt,new wt]);function zx(e,t){let{cameraDirection:n,cameraUp:r,height:s}=e,{metersPerUnit:i}=e.distanceScales,o=$o(e,e.center),c=U.WGS84.eastNorthUpToFixedFrame(o),a=e.unprojectPosition(e.cameraPosition),h=U.WGS84.cartographicToCartesian(a,new F),l=new F(c.transformAsVector(new F(n).scale(i))).normalize(),f=new F(c.transformAsVector(new F(r).scale(i))).normalize();eI(e);let p=e.constructor,{longitude:u,latitude:d,width:g,bearing:m,zoom:M}=e,E=new p({longitude:u,latitude:d,height:s,width:g,bearing:m,zoom:M,pitch:0});return{camera:{position:h,direction:l,up:f},viewport:e,topDownViewport:E,height:s,cullingVolume:Jl,frameNumber:t,sseDenominator:1.15}}function kx(e,t,n){if(n===0||e.length<=n)return[e,[]];let r=[],{longitude:s,latitude:i}=t.viewport;for(let[h,l]of e.entries()){let[f,p]=l.header.mbs,u=Math.abs(s-f),d=Math.abs(i-p),g=Math.sqrt(d*d+u*u);r.push([h,g])}let o=r.sort((h,l)=>h[1]-l[1]),c=[];for(let h=0;h<n;h++)c.push(e[o[h][0]]);let a=[];for(let h=n;h<o.length;h++)a.push(e[o[h][0]]);return[c,a]}function eI(e){let t=e.getFrustumPlanes(),n=Gx(t.near,e.cameraPosition),r=$o(e,n),s=$o(e,e.cameraPosition,Wl),i=0;Jl.planes[i++].fromPointNormal(r,Ux.copy(r).subtract(s));for(let o in t){if(o==="near")continue;let c=t[o],a=Gx(c,n,Wl),h=$o(e,a,Wl);Jl.planes[i++].fromPointNormal(h,Ux.copy(r).subtract(h))}}function Gx(e,t,n=new F){let r=e.normal.dot(t);return n.copy(e.normal).scale(e.distance-r).add(t),n}function $o(e,t,n=new F){let r=e.unprojectPosition(t);return U.WGS84.cartographicToCartesian(r,n)}var nI=6378137,rI=6378137,Xl=6356752314245179e-9,vr=new F;function Vx(e,t){if(e instanceof he){let{halfAxes:n}=e,r=sI(n);return Math.log2(Xl/(r+t[2]))}else if(e instanceof Kt){let{radius:n}=e;return Math.log2(Xl/(n+t[2]))}else if(e.width&&e.height){let{width:n,height:r}=e,s=Math.log2(nI/n),i=Math.log2(rI/r);return(s+i)/2}return 1}function jl(e,t,n){U.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],vr);let r=Math.sqrt(Math.pow(vr[0]-n[0],2)+Math.pow(vr[1]-n[1],2)+Math.pow(vr[2]-n[2],2));return Math.log2(Xl/(r+t[2]))}function qx(e,t,n){let[r,s,i,o]=e;return jl({xmin:r,xmax:i,ymin:s,ymax:o,zmin:0,zmax:0},t,n)}function sI(e){e.getColumn(0,vr);let t=e.getColumn(1),n=e.getColumn(2);return vr.add(t).add(n).len()}var o2=D(yr(),1);var Dt={UNLOADED:0,LOADING:1,PROCESSING:2,READY:3,EXPIRED:4,FAILED:5},It;(function(e){e[e.ADD=1]="ADD",e[e.REPLACE=2]="REPLACE"})(It||(It={}));var Zt;(function(e){e.EMPTY="empty",e.SCENEGRAPH="scenegraph",e.POINTCLOUD="pointcloud",e.MESH="mesh"})(Zt||(Zt={}));var St;(function(e){e.I3S="I3S",e.TILES3D="TILES3D"})(St||(St={}));var ze;(function(e){e.GEOMETRIC_ERROR="geometricError",e.MAX_SCREEN_THRESHOLD="maxScreenThreshold"})(ze||(ze={}));var Hx={NOT_COMPUTED:-1,USE_OPTIMIZATION:1,SKIP_OPTIMIZATION:0};function Xx(e){return e!=null}var bt=new F,tc=new F,iI=new F,oI=new F,zn=new F,Yx=new F,Wx=new F,Jx=new F;function ec(e,t,n){if(z(e,"3D Tile: boundingVolume must be defined"),e.box)return Kx(e.box,t,n);if(e.region)return aI(e.region);if(e.sphere)return cI(e.sphere,t,n);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function jx(e,t){if(e.box)return hI(t);if(e.region){let[n,r,s,i,o,c]=e.region;return[[Xt(n),Xt(r),o],[Xt(s),Xt(i),c]]}if(e.sphere)return lI(t);throw new Error("Unkown boundingVolume type")}function Kx(e,t,n){let r=new F(e[0],e[1],e[2]);t.transform(r,r);let s=[];if(e.length===10){let h=e.slice(3,6),l=new js;l.fromArray(e,6);let f=new F([1,0,0]),p=new F([0,1,0]),u=new F([0,0,1]);f.transformByQuaternion(l),f.scale(h[0]),p.transformByQuaternion(l),p.scale(h[1]),u.transformByQuaternion(l),u.scale(h[2]),s=[...f.toArray(),...p.toArray(),...u.toArray()]}else s=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];let i=t.transformAsVector(s.slice(0,3)),o=t.transformAsVector(s.slice(3,6)),c=t.transformAsVector(s.slice(6,9)),a=new Gn([i[0],i[1],i[2],o[0],o[1],o[2],c[0],c[1],c[2]]);return Xx(n)?(n.center=r,n.halfAxes=a,n):new he(r,a)}function cI(e,t,n){let r=new F(e[0],e[1],e[2]);t.transform(r,r);let s=t.getScale(tc),i=Math.max(Math.max(s[0],s[1]),s[2]),o=e[3]*i;return Xx(n)?(n.center=r,n.radius=o,n):new Kt(r,o)}function aI(e){let[t,n,r,s,i,o]=e,c=U.WGS84.cartographicToCartesian([Xt(t),Xt(s),i],iI),a=U.WGS84.cartographicToCartesian([Xt(r),Xt(n),o],oI),h=new F().addVectors(c,a).multiplyByScalar(.5);return U.WGS84.cartesianToCartographic(h,zn),U.WGS84.cartographicToCartesian([Xt(r),zn[1],zn[2]],Yx),U.WGS84.cartographicToCartesian([zn[0],Xt(s),zn[2]],Wx),U.WGS84.cartographicToCartesian([zn[0],zn[1],o],Jx),Kx([...h,...Yx.subtract(h),...Wx.subtract(h),...Jx.subtract(h)],new et)}function hI(e){let t=Zx(),{halfAxes:n}=e,r=new F(n.getColumn(0)),s=new F(n.getColumn(1)),i=new F(n.getColumn(2));for(let o=0;o<2;o++){for(let c=0;c<2;c++){for(let a=0;a<2;a++)bt.copy(e.center),bt.add(r),bt.add(s),bt.add(i),Qx(t,bt),i.negate();s.negate()}r.negate()}return t}function lI(e){let t=Zx(),{center:n,radius:r}=e,s=U.WGS84.scaleToGeodeticSurface(n,bt),i;s?i=U.WGS84.geodeticSurfaceNormal(s):i=new F(0,0,1);let o=new F(i[2],-i[1],0);o.len()>0?o.normalize():o=new F(0,1,0);let c=o.clone().cross(i);for(let a of[o,c,i]){tc.copy(a).scale(r);for(let h=0;h<2;h++)bt.copy(n),bt.add(tc),Qx(t,bt),tc.negate()}return t}function Zx(){return[[1/0,1/0,1/0],[-1/0,-1/0,-1/0]]}function Qx(e,t){U.WGS84.cartesianToCartographic(t,bt),e[0][0]=Math.min(e[0][0],bt[0]),e[0][1]=Math.min(e[0][1],bt[1]),e[0][2]=Math.min(e[0][2],bt[2]),e[1][0]=Math.max(e[1][0],bt[0]),e[1][1]=Math.max(e[1][1],bt[1]),e[1][2]=Math.max(e[1][2],bt[2])}var TY=new F,_Y=new F,SY=new et,BY=new F,CY=new F,LY=new F;function fI(e,t){let n=e*t;return 1-Math.exp(-(n*n))}function pI(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){let n=e.dynamicScreenSpaceErrorComputedDensity,r=e.dynamicScreenSpaceErrorFactor;return fI(t,n)*r}return 0}function $x(e,t,n){let r=e.tileset,s=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,i=n?s:e.lodMetricValue;if(i===0)return 0;let o=Math.max(e._distanceToCamera,1e-7),{height:c,sseDenominator:a}=t,{viewDistanceScale:h}=r.options,l=i*c*(h||1)/(o*a);return l-=pI(r,o),l}var Kl=new F,t2=new F,xn=new F,e2=new F,uI=new F,Zl=new et,n2=new et;function r2(e,t){if(e.lodMetricValue===0||isNaN(e.lodMetricValue))return"DIG";let n=2*Ql(e,t);return n<2?"OUT":!e.header.children||n<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}function Ql(e,t){let{topDownViewport:n}=t,r=e.header.mbs[1],s=e.header.mbs[0],i=e.header.mbs[2],o=e.header.mbs[3],c=[...e.boundingVolume.center],a=n.unprojectPosition(n.cameraPosition);U.WGS84.cartographicToCartesian(a,Kl),t2.copy(Kl).subtract(c).normalize(),U.WGS84.eastNorthUpToFixedFrame(c,Zl),n2.copy(Zl).invert(),xn.copy(Kl).transform(n2);let h=Math.sqrt(xn[0]*xn[0]+xn[1]*xn[1]),l=h*h/xn[2];e2.copy([xn[0],xn[1],l]);let p=e2.transform(Zl).subtract(c).normalize(),d=t2.cross(p).normalize().scale(o).add(c),g=U.WGS84.cartesianToCartographic(d),m=n.project([s,r,i]),M=n.project(g);return uI.copy(m).subtract(M).magnitude()}function s2(e){return{assetGltfUpAxis:e.asset&&e.asset.gltfUpAxis||"Y"}}var ni=class{_map=new Map;_array;_length;constructor(t=0){this._array=new Array(t),this._length=t}get length(){return this._length}set length(t){this._length=t,t>this._array.length&&(this._array.length=t)}get values(){return this._array}get(t){return z(t<this._array.length),this._array[t]}set(t,n){z(t>=0),t>=this.length&&(this.length=t+1),this._map.has(this._array[t])&&this._map.delete(this._array[t]),this._array[t]=n,this._map.set(n,t)}delete(t){let n=this._map.get(t);n>=0&&(this._array.splice(n,1),this._map.delete(t),this.length--)}peek(){return this._array[this._length-1]}push(t){if(!this._map.has(t)){let n=this.length++;this._array[n]=t,this._map.set(t,n)}}pop(){let t=this._array[--this.length];return this._map.delete(t),t}reserve(t){z(t>=0),t>this._array.length&&(this._array.length=t)}resize(t){z(t>=0),this.length=t}trim(t){t==null&&(t=this.length),this._array.length=t}reset(){this._array=[],this._map=new Map,this._length=0}find(t){return this._map.has(t)}};var dI={loadSiblings:!1,skipLevelOfDetail:!1,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""},Ce=class{options;root=null;selectedTiles={};requestedTiles={};emptyTiles={};lastUpdate=new Date().getTime();updateDebounceTime=1e3;_traversalStack=new ni;_emptyTraversalStack=new ni;_frameNumber=null;traversalFinished(t){return!0}constructor(t){this.options={...dI,...t}}traverse(t,n,r){this.root=t,this.options={...this.options,...r},this.reset(),this.updateTile(t,n),this._frameNumber=n.frameNumber,this.executeTraversal(t,n)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(t,n){let r=this._traversalStack;for(t._selectionDepth=1,r.push(t);r.length>0;){let i=r.pop(),o=!1;this.canTraverse(i,n)&&(this.updateChildTiles(i,n),o=this.updateAndPushChildren(i,n,r,i.hasRenderContent?i._selectionDepth+1:i._selectionDepth));let c=i.parent,a=Boolean(!c||c._shouldRefine),h=!o;i.hasRenderContent?i.refine===It.ADD?(this.loadTile(i,n),this.selectTile(i,n)):i.refine===It.REPLACE&&(this.loadTile(i,n),h&&this.selectTile(i,n)):(this.emptyTiles[i.id]=i,this.loadTile(i,n),h&&this.selectTile(i,n)),this.touchTile(i,n),i._shouldRefine=o&&a}let s=new Date().getTime();(this.traversalFinished(n)||s-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=s,this.options.onTraversalEnd(n))}updateChildTiles(t,n){let r=t.children;for(let s of r)this.updateTile(s,n)}updateAndPushChildren(t,n,r,s){let{loadSiblings:i,skipLevelOfDetail:o}=this.options,c=t.children;c.sort(this.compareDistanceToCamera.bind(this));let a=t.refine===It.REPLACE&&t.hasRenderContent&&!o,h=!1,l=!0;for(let f of c)if(f._selectionDepth=s,f.isVisibleAndInRequestVolume?(r.find(f)&&r.delete(f),r.push(f),h=!0):(a||i)&&(this.loadTile(f,n),this.touchTile(f,n)),a){let p;if(f._inRequestVolume?f.hasRenderContent?p=f.contentAvailable:p=this.executeEmptyTraversal(f,n):p=!1,l=l&&p,!l)return!1}return h||(l=!1),l}updateTile(t,n){this.updateTileVisibility(t,n)}selectTile(t,n){this.shouldSelectTile(t)&&(t._selectedFrame=n.frameNumber,this.selectedTiles[t.id]=t)}loadTile(t,n){this.shouldLoadTile(t)&&(t._requestedFrame=n.frameNumber,t._priority=t._getPriority(),this.requestedTiles[t.id]=t)}touchTile(t,n){t.tileset._cache.touch(t),t._touchedFrame=n.frameNumber}canTraverse(t,n,r=!1,s=!1){return t.hasChildren?t.hasTilesetContent?!t.contentExpired:!s&&!t.isVisibleAndInRequestVolume?!1:this.shouldRefine(t,n,r):!1}shouldLoadTile(t){return t.hasUnloadedContent||t.contentExpired}shouldSelectTile(t){return t.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(t,n,r=!1){let s=t._screenSpaceError;return r&&(s=t.getScreenSpaceError(n,!0)),s>t.tileset.memoryAdjustedScreenSpaceError}updateTileVisibility(t,n){let r=[];if(this.options.viewportTraversersMap)for(let s in this.options.viewportTraversersMap)this.options.viewportTraversersMap[s]===n.viewport.id&&r.push(s);else r.push(n.viewport.id);t.updateVisibility(n,r)}compareDistanceToCamera(t,n){return t._distanceToCamera-n._distanceToCamera}anyChildrenVisible(t,n){let r=!1;for(let s of t.children)s.updateVisibility(n),r=r||s.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(t,n){let r=!0,s=this._emptyTraversalStack;for(s.push(t);s.length>0;){let i=s.pop(),o=!i.hasRenderContent&&this.canTraverse(i,n,!1,!1),c=!i.hasRenderContent&&i.children.length===0;if(!o&&!i.contentAvailable&&!c&&(r=!1),this.updateTile(i,n),i.isVisibleAndInRequestVolume||(this.loadTile(i,n),this.touchTile(i,n)),o){let a=i.children;for(let h of a)s.push(h)}}return r}};var i2=new F;function mI(e){return e!=null}var kn=class{tileset;header;id;url;parent;refine;type;contentUrl;lodMetricType="geometricError";lodMetricValue=0;boundingVolume=null;content=null;contentState=Dt.UNLOADED;gpuMemoryUsageInBytes=0;children=[];depth=0;viewportIds=[];transform=new et;extensions=null;implicitTiling=null;userData={};computedTransform;hasEmptyContent=!1;hasTilesetContent=!1;traverser=new Ce({});_cacheNode=null;_frameNumber=null;_expireDate=null;_expiredContent=null;_boundingBox=void 0;_distanceToCamera=0;_screenSpaceError=0;_visibilityPlaneMask;_visible=void 0;_contentBoundingVolume;_viewerRequestVolume;_initialTransform=new et;_priority=0;_selectedFrame=0;_requestedFrame=0;_selectionDepth=0;_touchedFrame=0;_centerZDepth=0;_shouldRefine=!1;_stackLength=0;_visitedFrame=0;_inRequestVolume=!1;_lodJudge=null;constructor(t,n,r,s=""){this.header=n,this.tileset=t,this.id=s||n.id,this.url=n.url,this.parent=r,this.refine=this._getRefine(n.refine),this.type=n.type,this.contentUrl=n.contentUrl,this._initializeLodMetric(n),this._initializeTransforms(n),this._initializeBoundingVolumes(n),this._initializeContent(n),this._initializeRenderingState(n),Object.seal(this)}destroy(){this.header=null}isDestroyed(){return this.header===null}get selected(){return this._selectedFrame===this.tileset._frameNumber}get isVisible(){return this._visible}get isVisibleAndInRequestVolume(){return this._visible&&this._inRequestVolume}get hasRenderContent(){return!this.hasEmptyContent&&!this.hasTilesetContent}get hasChildren(){return this.children.length>0||this.header.children&&this.header.children.length>0}get contentReady(){return this.contentState===Dt.READY||this.hasEmptyContent}get contentAvailable(){return Boolean(this.contentReady&&this.hasRenderContent||this._expiredContent&&!this.contentFailed)}get hasUnloadedContent(){return this.hasRenderContent&&this.contentUnloaded}get contentUnloaded(){return this.contentState===Dt.UNLOADED}get contentExpired(){return this.contentState===Dt.EXPIRED}get contentFailed(){return this.contentState===Dt.FAILED}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}get boundingBox(){return this._boundingBox||(this._boundingBox=jx(this.header.boundingVolume,this.boundingVolume)),this._boundingBox}getScreenSpaceError(t,n){switch(this.tileset.type){case St.I3S:return Ql(this,t);case St.TILES3D:return $x(this,t,n);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getGpuMemoryUsageInBytes(){return this.content.gpuMemoryUsageInBytes||this.content.byteLength||0}_getPriority(){let t=this.tileset._traverser,{skipLevelOfDetail:n}=t.options,r=this.refine===It.ADD||n;if(r&&!this.isVisible&&this._visible!==void 0||this.tileset._frameNumber-this._touchedFrame>=1||this.contentState===Dt.UNLOADED)return-1;let s=this.parent,o=s&&(!r||this._screenSpaceError===0||s.hasTilesetContent)?s._screenSpaceError:this._screenSpaceError,c=t.root?t.root._screenSpaceError:0;return Math.max(c-o,0)}async loadContent(){if(this.hasEmptyContent)return!1;if(this.content)return!0;this.contentExpired&&(this._expireDate=null),this.contentState=Dt.LOADING;let n=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!n)return this.contentState=Dt.UNLOADED,!1;try{let r=this.tileset.getTileUrl(this.contentUrl),s=this.tileset.loader,i={...this.tileset.loadOptions,[s.id]:{...this.tileset.loadOptions[s.id],isTileset:this.type==="json",...this._getLoaderSpecificOptions(s.id)}};return this.content=await(0,o2.load)(r,s,i),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=Dt.READY,this._onContentLoaded(),!0}catch(r){throw this.contentState=Dt.FAILED,r}finally{n.done()}}unloadContent(){return this.content&&this.content.destroy&&this.content.destroy(),this.content=null,this.header.content&&this.header.content.destroy&&this.header.content.destroy(),this.header.content=null,this.contentState=Dt.UNLOADED,!0}updateVisibility(t,n){if(this._frameNumber===t.frameNumber)return;let r=this.parent,s=r?r._visibilityPlaneMask:_t.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){let i=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(i)}this._distanceToCamera=this.distanceToTile(t),this._screenSpaceError=this.getScreenSpaceError(t,!1),this._visibilityPlaneMask=this.visibility(t,s),this._visible=this._visibilityPlaneMask!==_t.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(t),this._frameNumber=t.frameNumber,this.viewportIds=n}visibility(t,n){let{cullingVolume:r}=t,{boundingVolume:s}=this;return r.computeVisibilityWithPlaneMask(s,n)}contentVisibility(){return!0}distanceToTile(t){let n=this.boundingVolume;return Math.sqrt(Math.max(n.distanceSquaredTo(t.camera.position),0))}cameraSpaceZDepth({camera:t}){let n=this.boundingVolume;return i2.subVectors(n.center,t.position),t.direction.dot(i2)}insideViewerRequestVolume(t){let n=this._viewerRequestVolume;return!n||n.distanceSquaredTo(t.camera.position)<=0}updateExpiration(){if(mI(this._expireDate)&&this.contentReady&&!this.hasEmptyContent){let t=Date.now();Date.lessThan(this._expireDate,t)&&(this.contentState=Dt.EXPIRED,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(t){"lodMetricType"in t?this.lodMetricType=t.lodMetricType:(this.lodMetricType=this.parent&&this.parent.lodMetricType||this.tileset.lodMetricType,console.warn("3D Tile: Required prop lodMetricType is undefined. Using parent lodMetricType")),"lodMetricValue"in t?this.lodMetricValue=t.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(t){this.transform=t.transform?new et(t.transform):new et;let n=this.parent,r=this.tileset,s=n&&n.computedTransform?n.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new et(s).multiplyRight(this.transform);let i=n&&n._initialTransform?n._initialTransform.clone():new et;this._initialTransform=new et(i).multiplyRight(this.transform)}_initializeBoundingVolumes(t){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(t)}_initializeContent(t){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=Dt.UNLOADED,this.hasTilesetContent=!1,t.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(t){this.depth=t.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=_t.MASK_INDETERMINATE,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._frameNumber=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._priority=0}_getRefine(t){return t||this.parent&&this.parent.refine||It.REPLACE}_isTileset(){return this.contentUrl.indexOf(".json")!==-1}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0;break;default:}this._isTileset()?this.hasTilesetContent=!0:this.gpuMemoryUsageInBytes=this._getGpuMemoryUsageInBytes()}_updateBoundingVolume(t){this.boundingVolume=ec(t.boundingVolume,this.computedTransform,this.boundingVolume);let n=t.content;n&&(n.boundingVolume&&(this._contentBoundingVolume=ec(n.boundingVolume,this.computedTransform,this._contentBoundingVolume)),t.viewerRequestVolume&&(this._viewerRequestVolume=ec(t.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(t=new et){let n=t.clone().multiplyRight(this.transform);n.equals(this.computedTransform)||(this.computedTransform=n,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(t){switch(t){case"i3s":return{...this.tileset.options.i3s,_tileOptions:{attributeUrls:this.header.attributeUrls,textureUrl:this.header.textureUrl,textureFormat:this.header.textureFormat,textureLoaderOptions:this.header.textureLoaderOptions,materialDefinition:this.header.materialDefinition,isDracoGeometry:this.header.isDracoGeometry,mbs:this.header.mbs},_tilesetOptions:{store:this.tileset.tileset.store,attributeStorageInfo:this.tileset.tileset.attributeStorageInfo,fields:this.tileset.tileset.fields},isTileHeader:!1};case"3d-tiles":case"cesium-ion":default:return s2(this.tileset.tileset)}}};var nc=class extends Ce{compareDistanceToCamera(t,n){return n._distanceToCamera===0&&t._distanceToCamera===0?n._centerZDepth-t._centerZDepth:n._distanceToCamera-t._distanceToCamera}updateTileVisibility(t,n){if(super.updateTileVisibility(t,n),!t.isVisibleAndInRequestVolume)return;let r=t.children.length>0;if(t.hasTilesetContent&&r){let o=t.children[0];this.updateTileVisibility(o,n),t._visible=o._visible;return}if(this.meetsScreenSpaceErrorEarly(t,n)){t._visible=!1;return}let s=t.refine===It.REPLACE,i=t._optimChildrenWithinParent===Hx.USE_OPTIMIZATION;if(s&&i&&r&&!this.anyChildrenVisible(t,n)){t._visible=!1;return}}meetsScreenSpaceErrorEarly(t,n){let{parent:r}=t;return!r||r.hasTilesetContent||r.refine!==It.ADD?!1:!this.shouldRefine(t,n,!0)}};var c2=D(yr(),1);var rc=class{frameNumberMap=new Map;register(t,n){let r=this.frameNumberMap.get(t)||new Map,s=r.get(n)||0;r.set(n,s+1),this.frameNumberMap.set(t,r)}deregister(t,n){let r=this.frameNumberMap.get(t);if(!r)return;let s=r.get(n)||1;r.set(n,s-1)}isZero(t,n){return(this.frameNumberMap.get(t)?.get(n)||0)===0}};var $l={REQUESTED:"REQUESTED",COMPLETED:"COMPLETED",ERROR:"ERROR"},sc=class{_statusMap;pendingTilesRegister=new rc;constructor(){this._statusMap={}}add(t,n,r,s){if(!this._statusMap[n]){let{frameNumber:i,viewport:{id:o}}=s;this._statusMap[n]={request:t,callback:r,key:n,frameState:s,status:$l.REQUESTED},this.pendingTilesRegister.register(o,i),t().then(c=>{this._statusMap[n].status=$l.COMPLETED;let{frameNumber:a,viewport:{id:h}}=this._statusMap[n].frameState;this.pendingTilesRegister.deregister(h,a),this._statusMap[n].callback(c,s)}).catch(c=>{this._statusMap[n].status=$l.ERROR;let{frameNumber:a,viewport:{id:h}}=this._statusMap[n].frameState;this.pendingTilesRegister.deregister(h,a),r(c)})}}update(t,n){if(this._statusMap[t]){let{frameNumber:r,viewport:{id:s}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(s,r);let{frameNumber:i,viewport:{id:o}}=n;this.pendingTilesRegister.register(o,i),this._statusMap[t].frameState=n}}find(t){return this._statusMap[t]}hasPendingTiles(t,n){return!this.pendingTilesRegister.isZero(t,n)}};var ic=class extends Ce{_tileManager;constructor(t){super(t),this._tileManager=new sc}traversalFinished(t){return!this._tileManager.hasPendingTiles(t.viewport.id,this._frameNumber||0)}shouldRefine(t,n){return t._lodJudge=r2(t,n),t._lodJudge==="DIG"}updateChildTiles(t,n){let r=t.header.children||[],s=t.children,i=t.tileset;for(let o of r){let c=`${o.id}-${n.viewport.id}`,a=s&&s.find(h=>h.id===c);if(a)a&&this.updateTile(a,n);else{let h=()=>this._loadTile(o.id,i);this._tileManager.find(c)?this._tileManager.update(c,n):(i.tileset.nodePages&&(h=()=>i.tileset.nodePagesTile.formTileFromNodePages(o.id)),this._tileManager.add(h,c,f=>this._onTileLoad(f,t,c),n))}}return!1}async _loadTile(t,n){let{loader:r}=n,s=n.getTileUrl(`${n.url}/nodes/${t}`),i={...n.loadOptions,i3s:{...n.loadOptions.i3s,isTileHeader:!0}};return await(0,c2.load)(s,r,i)}_onTileLoad(t,n,r){let s=new kn(n.tileset,t,n,r);n.children.push(s);let i=this._tileManager.find(s.id).frameState;this.updateTile(s,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||new Date().getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(s,i)}};var gI={description:"",ellipsoid:U.WGS84,modelMatrix:new et,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,memoryCacheOverflow:1,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,memoryAdjustedScreenSpaceError:!1,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},oc="Tiles In Tileset(s)",tf="Tiles In Memory",a2="Tiles In View",h2="Tiles To Render",l2="Tiles Loaded",ef="Tiles Loading",f2="Tiles Unloaded",p2="Failed Tile Loads",u2="Points/Vertices",nf="Tile Memory Use",d2="Maximum Screen Space Error",ri=class{options;loadOptions;type;tileset;loader;url;basePath;modelMatrix;ellipsoid;lodMetricType;lodMetricValue;refine;root=null;roots={};asset={};description="";properties;extras=null;attributions={};credits={};stats;contentFormats={draco:!1,meshopt:!1,dds:!1,ktx2:!1};cartographicCenter=null;cartesianCenter=null;zoom=1;boundingVolume=null;dynamicScreenSpaceErrorComputedDensity=0;maximumMemoryUsage=32;gpuMemoryUsageInBytes=0;memoryAdjustedScreenSpaceError=0;_cacheBytes=0;_cacheOverflowBytes=0;_frameNumber=0;_queryParams={};_extensionsUsed=[];_tiles={};_pendingCount=0;selectedTiles=[];traverseCounter=0;geometricError=0;lastUpdatedVieports=null;_requestedTiles=[];_emptyTiles=[];frameStateData={};_traverser;_cache=new Uo;_requestScheduler;updatePromise=null;tilesetInitializationPromise;constructor(t,n){this.options={...gI,...n},this.tileset=t,this.loader=t.loader,this.type=t.type,this.url=t.url,this.basePath=t.basePath||Ze.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=t.lodMetricType,this.lodMetricValue=t.lodMetricValue,this.refine=t.root.refine,this.loadOptions=this.options.loadOptions||{},this._traverser=this._initializeTraverser(),this._requestScheduler=new Ke({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this.memoryAdjustedScreenSpaceError=this.options.maximumScreenSpaceError,this._cacheBytes=this.options.maximumMemoryUsage*1024*1024,this._cacheOverflowBytes=this.options.memoryCacheOverflow*1024*1024,this.stats=new je({id:this.url}),this._initializeStats(),this.tilesetInitializationPromise=this._initializeTileSet(t)}destroy(){this._destroy()}isLoaded(){return this._pendingCount===0&&this._frameNumber!==0&&this._requestedTiles.length===0}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return new URLSearchParams(this._queryParams).toString()}setProps(t){this.options={...this.options,...t}}getTileUrl(t){if(t.startsWith("data:"))return t;let r=t;return this.queryParams.length&&(r=`${t}${t.includes("?")?"&":"?"}${this.queryParams}`),r}hasExtension(t){return Boolean(this._extensionsUsed.indexOf(t)>-1)}update(t=null){this.tilesetInitializationPromise.then(()=>{!t&&this.lastUpdatedVieports?t=this.lastUpdatedVieports:this.lastUpdatedVieports=t,t&&this.doUpdate(t)})}async selectTiles(t=null){return await this.tilesetInitializationPromise,t&&(this.lastUpdatedVieports=t),this.updatePromise||(this.updatePromise=new Promise(n=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),n(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}adjustScreenSpaceError(){this.gpuMemoryUsageInBytes<this._cacheBytes?this.memoryAdjustedScreenSpaceError=Math.max(this.memoryAdjustedScreenSpaceError/1.02,this.options.maximumScreenSpaceError):this.gpuMemoryUsageInBytes>this._cacheBytes+this._cacheOverflowBytes&&(this.memoryAdjustedScreenSpaceError*=1.02)}doUpdate(t){if("loadTiles"in this.options&&!this.options.loadTiles||this.traverseCounter>0)return;let n=t instanceof Array?t:[t];this._cache.reset(),this._frameNumber++,this.traverseCounter=n.length;let r=[];for(let s of n){let i=s.id;this._needTraverse(i)?r.push(i):this.traverseCounter--}for(let s of n){let i=s.id;if(this.roots[i]||(this.roots[i]=this._initializeTileHeaders(this.tileset,null)),!r.includes(i))continue;let o=zx(s,this._frameNumber);this._traverser.traverse(this.roots[i],o,this.options)}}_needTraverse(t){let n=t;return this.options.viewportTraversersMap&&(n=this.options.viewportTraversersMap[t]),n===t}_onTraversalEnd(t){let n=t.viewport.id;this.frameStateData[n]||(this.frameStateData[n]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});let r=this.frameStateData[n],s=Object.values(this._traverser.selectedTiles),[i,o]=kx(s,t,this.options.maximumTilesSelected);r.selectedTiles=i;for(let c of o)c.unselect();r._requestedTiles=Object.values(this._traverser.requestedTiles),r._emptyTiles=Object.values(this._traverser.emptyTiles),this.traverseCounter--,!(this.traverseCounter>0)&&this._updateTiles()}_updateTiles(){this.selectedTiles=[],this._requestedTiles=[],this._emptyTiles=[];for(let t in this.frameStateData){let n=this.frameStateData[t];this.selectedTiles=this.selectedTiles.concat(n.selectedTiles),this._requestedTiles=this._requestedTiles.concat(n._requestedTiles),this._emptyTiles=this._emptyTiles.concat(n._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(let t of this.selectedTiles)this._tiles[t.id]=t;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(t,n){if(t.length!==n.length)return!0;let r=new Set(t.map(o=>o.id)),s=new Set(n.map(o=>o.id)),i=t.filter(o=>!s.has(o.id)).length>0;return i=i||n.filter(o=>!r.has(o.id)).length>0,i}_loadTiles(){for(let t of this._requestedTiles)t.contentUnloaded&&this._loadTile(t)}_unloadTiles(){this._cache.unloadTiles(this,(t,n)=>t._unloadTile(n))}_updateStats(){let t=0,n=0;for(let r of this.selectedTiles)r.contentAvailable&&r.content&&(t++,r.content.pointCount?n+=r.content.pointCount:n+=r.content.vertexCount);this.stats.get(a2).count=this.selectedTiles.length,this.stats.get(h2).count=t,this.stats.get(u2).count=n,this.stats.get(d2).count=this.memoryAdjustedScreenSpaceError}async _initializeTileSet(t){this.type===St.I3S&&(this.calculateViewPropsI3S(),t.root=await t.root),this.root=this._initializeTileHeaders(t,null),this.type===St.TILES3D&&(this._initializeTiles3DTileset(t),this.calculateViewPropsTiles3D()),this.type===St.I3S&&this._initializeI3STileset()}calculateViewPropsI3S(){let t=this.tileset.fullExtent;if(t){let{xmin:r,xmax:s,ymin:i,ymax:o,zmin:c,zmax:a}=t;this.cartographicCenter=new F(r+(s-r)/2,i+(o-i)/2,c+(a-c)/2),this.cartesianCenter=new F,U.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=jl(t,this.cartographicCenter,this.cartesianCenter);return}let n=this.tileset.store?.extent;if(n){let[r,s,i,o]=n;this.cartographicCenter=new F(r+(i-r)/2,s+(o-s)/2,0),this.cartesianCenter=new F,U.WGS84.cartographicToCartesian(this.cartographicCenter,this.cartesianCenter),this.zoom=qx(n,this.cartographicCenter,this.cartesianCenter);return}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new F,this.zoom=1}calculateViewPropsTiles3D(){let t=this.root,{center:n}=t.boundingVolume;if(!n){console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new F,this.zoom=1;return}n[0]!==0||n[1]!==0||n[2]!==0?(this.cartographicCenter=new F,U.WGS84.cartesianToCartographic(n,this.cartographicCenter)):this.cartographicCenter=new F(0,0,-U.WGS84.radii[0]),this.cartesianCenter=n,this.zoom=Vx(t.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(oc),this.stats.get(ef),this.stats.get(tf),this.stats.get(a2),this.stats.get(h2),this.stats.get(l2),this.stats.get(f2),this.stats.get(p2),this.stats.get(u2),this.stats.get(nf,"memory"),this.stats.get(d2)}_initializeTileHeaders(t,n){let r=new kn(this,t.root,n);if(n&&(n.children.push(r),r.depth=n.depth+1),this.type===St.TILES3D){let s=[];for(s.push(r);s.length>0;){let i=s.pop();this.stats.get(oc).incrementCount();let o=i.header.children||[];for(let c of o){let a=new kn(this,c,i);if(a.contentUrl?.includes("?session=")){let l=new URL(a.contentUrl).searchParams.get("session");l&&(this._queryParams.session=l)}i.children.push(a),a.depth=i.depth+1,s.push(a)}}}return r}_initializeTraverser(){let t;switch(this.type){case St.TILES3D:t=nc;break;case St.I3S:t=ic;break;default:t=Ce}return new t({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(t){this._destroySubtree(t)}async _loadTile(t){let n;try{this._onStartTileLoading(),n=await t.loadContent()}catch(r){this._onTileLoadError(t,r instanceof Error?r:new Error("load failed"))}finally{this._onEndTileLoading(),this._onTileLoad(t,n)}}_onTileLoadError(t,n){this.stats.get(p2).incrementCount();let r=n.message||n.toString(),s=t.url;console.error(`A 3D tile failed to load: ${t.url} ${r}`),this.options.onTileError(t,r,s)}_onTileLoad(t,n){if(n){if(this.type===St.I3S){let r=this.tileset?.nodePagesTile?.nodesInNodePages||0;this.stats.get(oc).reset(),this.stats.get(oc).addCount(r)}t&&t.content&&Fg(t,t.content),this.updateContentTypes(t),this._addTileToCache(t),this.options.onTileLoad(t)}}updateContentTypes(t){if(this.type===St.I3S)switch(t.header.isDracoGeometry&&(this.contentFormats.draco=!0),t.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0;break;default:}else if(this.type===St.TILES3D){let{extensionsRemoved:n=[]}=t.content?.gltf||{};n.includes("KHR_draco_mesh_compression")&&(this.contentFormats.draco=!0),n.includes("EXT_meshopt_compression")&&(this.contentFormats.meshopt=!0),n.includes("KHR_texture_basisu")&&(this.contentFormats.ktx2=!0)}}_onStartTileLoading(){this._pendingCount++,this.stats.get(ef).incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get(ef).decrementCount()}_addTileToCache(t){this._cache.add(this,t,n=>n._updateCacheStats(t))}_updateCacheStats(t){this.stats.get(l2).incrementCount(),this.stats.get(tf).incrementCount(),this.gpuMemoryUsageInBytes+=t.gpuMemoryUsageInBytes||0,this.stats.get(nf).count=this.gpuMemoryUsageInBytes,this.options.memoryAdjustedScreenSpaceError&&this.adjustScreenSpaceError()}_unloadTile(t){this.gpuMemoryUsageInBytes-=t.gpuMemoryUsageInBytes||0,this.stats.get(tf).decrementCount(),this.stats.get(f2).incrementCount(),this.stats.get(nf).count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(t),t.unloadContent()}_destroy(){let t=[];for(this.root&&t.push(this.root);t.length>0;){let n=t.pop();for(let r of n.children)t.push(r);this._destroyTile(n)}this.root=null}_destroySubtree(t){let n=t,r=[];for(r.push(n);r.length>0;){t=r.pop();for(let s of t.children)r.push(s);t!==n&&this._destroyTile(t)}n.children=[]}_destroyTile(t){this._cache.unloadTile(this,t),this._unloadTile(t),t.destroy()}_initializeTiles3DTileset(t){if(t.queryString){let n=new URLSearchParams(t.queryString),r=Object.fromEntries(n.entries());this._queryParams={...this._queryParams,...r}}if(this.asset=t.asset,!this.asset)throw new Error("Tileset must have an asset property.");if(this.asset.version!=="0.0"&&this.asset.version!=="1.0"&&this.asset.version!=="1.1")throw new Error("The tileset must be 3D Tiles version either 0.0 or 1.0 or 1.1.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=t.properties,this.geometricError=t.geometricError,this._extensionsUsed=t.extensionsUsed||[],this.extras=t.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}};var cc="4.2.1";var Vn={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"},TW=Object.keys(Vn);function rf(e,t,n){z(e instanceof ArrayBuffer);let r=new TextDecoder("utf8"),s=new Uint8Array(e,t,n);return r.decode(s)}function m2(e,t=0){let n=new DataView(e);return`${String.fromCharCode(n.getUint8(t+0))}${String.fromCharCode(n.getUint8(t+1))}${String.fromCharCode(n.getUint8(t+2))}${String.fromCharCode(n.getUint8(t+3))}`}var g2="4.2.1";var x2={dataType:null,batchType:null,name:"Draco",id:"draco",module:"draco",version:g2,worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:{draco:{decoderType:typeof WebAssembly=="object"?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}}};function M2(e){switch(e.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function qn(e){let t=1/0,n=1/0,r=1/0,s=-1/0,i=-1/0,o=-1/0,c=e.POSITION?e.POSITION.value:[],a=c&&c.length;for(let h=0;h<a;h+=3){let l=c[h],f=c[h+1],p=c[h+2];t=l<t?l:t,n=f<n?f:n,r=p<r?p:r,s=l>s?l:s,i=f>i?f:i,o=p>o?p:o}return[[t,n,r],[s,i,o]]}function sf(e,t,n){let r=M2(t.value),s=n||A2(t);return{name:e,type:{type:"fixed-size-list",listSize:t.size,children:[{name:"value",type:r}]},nullable:!1,metadata:s}}function A2(e){let t={};return"byteOffset"in e&&(t.byteOffset=e.byteOffset.toString(10)),"byteStride"in e&&(t.byteStride=e.byteStride.toString(10)),"normalized"in e&&(t.normalized=e.normalized.toString()),t}function E2(e,t,n){let r=T2(t.metadata),s=[],i=xI(t.attributes);for(let o in e){let c=e[o],a=y2(o,c,i[o]);s.push(a)}if(n){let o=y2("indices",n);s.push(o)}return{fields:s,metadata:r}}function xI(e){let t={};for(let n in e){let r=e[n];t[r.name||"undefined"]=r}return t}function y2(e,t,n){let r=n?T2(n.metadata):void 0;return sf(e,t,r)}function T2(e){Object.entries(e);let t={};for(let n in e)t[`${n}.string`]=JSON.stringify(e[n]);return t}var _2={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},MI={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array},AI=4,si=class{draco;decoder;metadataQuerier;constructor(t){this.draco=t,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(t,n={}){let r=new this.draco.DecoderBuffer;r.Init(new Int8Array(t),t.byteLength),this._disableAttributeTransforms(n);let s=this.decoder.GetEncodedGeometryType(r),i=s===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let o;switch(s){case this.draco.TRIANGULAR_MESH:o=this.decoder.DecodeBufferToMesh(r,i);break;case this.draco.POINT_CLOUD:o=this.decoder.DecodeBufferToPointCloud(r,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!o.ok()||!i.ptr){let p=`DRACO decompression failed: ${o.error_msg()}`;throw new Error(p)}let c=this._getDracoLoaderData(i,s,n),a=this._getMeshData(i,c,n),h=qn(a.attributes),l=E2(a.attributes,c,a.indices);return{loader:"draco",loaderData:c,header:{vertexCount:i.num_points(),boundingBox:h},...a,schema:l}}finally{this.draco.destroy(r),i&&this.draco.destroy(i)}}_getDracoLoaderData(t,n,r){let s=this._getTopLevelMetadata(t),i=this._getDracoAttributes(t,r);return{geometry_type:n,num_attributes:t.num_attributes(),num_points:t.num_points(),num_faces:t instanceof this.draco.Mesh?t.num_faces():0,metadata:s,attributes:i}}_getDracoAttributes(t,n){let r={};for(let s=0;s<t.num_attributes();s++){let i=this.decoder.GetAttribute(t,s),o=this._getAttributeMetadata(t,s);r[i.unique_id()]={unique_id:i.unique_id(),attribute_type:i.attribute_type(),data_type:i.data_type(),num_components:i.num_components(),byte_offset:i.byte_offset(),byte_stride:i.byte_stride(),normalized:i.normalized(),attribute_index:s,metadata:o};let c=this._getQuantizationTransform(i,n);c&&(r[i.unique_id()].quantization_transform=c);let a=this._getOctahedronTransform(i,n);a&&(r[i.unique_id()].octahedron_transform=a)}return r}_getMeshData(t,n,r){let s=this._getMeshAttributes(n,t,r);if(!s.POSITION)throw new Error("DRACO: No position attribute found.");if(t instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:s,indices:{value:this._getTriangleStripIndices(t),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:s,indices:{value:this._getTriangleListIndices(t),size:1}}}return{topology:"point-list",mode:0,attributes:s}}_getMeshAttributes(t,n,r){let s={};for(let i of Object.values(t.attributes)){let o=this._deduceAttributeName(i,r);i.name=o;let c=this._getAttributeValues(n,i);if(c){let{value:a,size:h}=c;s[o]={value:a,size:h,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}}return s}_getTriangleListIndices(t){let r=t.num_faces()*3,s=r*AI,i=this.draco._malloc(s);try{return this.decoder.GetTrianglesUInt32Array(t,s,i),new Uint32Array(this.draco.HEAPF32.buffer,i,r).slice()}finally{this.draco._free(i)}}_getTriangleStripIndices(t){let n=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(t,n),TI(n)}finally{this.draco.destroy(n)}}_getAttributeValues(t,n){let r=MI[n.data_type];if(!r)return console.warn(`DRACO: Unsupported attribute type ${n.data_type}`),null;let s=n.num_components,o=t.num_points()*s,c=o*r.BYTES_PER_ELEMENT,a=yI(this.draco,r),h,l=this.draco._malloc(c);try{let f=this.decoder.GetAttribute(t,n.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(t,f,a,c,l),h=new r(this.draco.HEAPF32.buffer,l,o).slice()}finally{this.draco._free(l)}return{value:h,size:s}}_deduceAttributeName(t,n){let r=t.unique_id;for(let[o,c]of Object.entries(n.extraAttributes||{}))if(c===r)return o;let s=t.attribute_type;for(let o in _2)if(this.draco[o]===s)return _2[o];let i=n.attributeNameEntry||"name";return t.metadata[i]?t.metadata[i].string:`CUSTOM_ATTRIBUTE_${r}`}_getTopLevelMetadata(t){let n=this.decoder.GetMetadata(t);return this._getDracoMetadata(n)}_getAttributeMetadata(t,n){let r=this.decoder.GetAttributeMetadata(t,n);return this._getDracoMetadata(r)}_getDracoMetadata(t){if(!t||!t.ptr)return{};let n={},r=this.metadataQuerier.NumEntries(t);for(let s=0;s<r;s++){let i=this.metadataQuerier.GetEntryName(t,s);n[i]=this._getDracoMetadataField(t,i)}return n}_getDracoMetadataField(t,n){let r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(t,n,r);let s=EI(r);return{int:this.metadataQuerier.GetIntEntry(t,n),string:this.metadataQuerier.GetStringEntry(t,n),double:this.metadataQuerier.GetDoubleEntry(t,n),intArray:s}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(t){let{quantizedAttributes:n=[],octahedronAttributes:r=[]}=t,s=[...n,...r];for(let i of s)this.decoder.SkipAttributeTransform(this.draco[i])}_getQuantizationTransform(t,n){let{quantizedAttributes:r=[]}=n,s=t.attribute_type();if(r.map(o=>this.decoder[o]).includes(s)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(t))return{quantization_bits:o.quantization_bits(),range:o.range(),min_values:new Float32Array([1,2,3]).map(c=>o.min_value(c))}}finally{this.draco.destroy(o)}}return null}_getOctahedronTransform(t,n){let{octahedronAttributes:r=[]}=n,s=t.attribute_type();if(r.map(o=>this.decoder[o]).includes(s)){let o=new this.draco.AttributeQuantizationTransform;try{if(o.InitFromAttribute(t))return{quantization_bits:o.quantization_bits()}}finally{this.draco.destroy(o)}}return null}};function yI(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32;default:return e.DT_INVALID}}function EI(e){let t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}function TI(e){let t=e.size(),n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=e.GetValue(r);return n}var _I="1.5.6",SI="1.4.1",of=`https://www.gstatic.com/draco/versioned/decoders/${_I}`,zt={DECODER:"draco_wasm_wrapper.js",DECODER_WASM:"draco_decoder.wasm",FALLBACK_DECODER:"draco_decoder.js",ENCODER:"draco_encoder.js"},cf={[zt.DECODER]:`${of}/${zt.DECODER}`,[zt.DECODER_WASM]:`${of}/${zt.DECODER_WASM}`,[zt.FALLBACK_DECODER]:`${of}/${zt.FALLBACK_DECODER}`,[zt.ENCODER]:`https://raw.githubusercontent.com/google/draco/${SI}/javascript/${zt.ENCODER}`},af;async function S2(e){let t=e.modules||{};return t.draco3d?af||=t.draco3d.createDecoderModule({}).then(n=>({draco:n})):af||=BI(e),await af}async function BI(e){let t,n;switch(e.draco&&e.draco.decoderType){case"js":t=await me(cf[zt.FALLBACK_DECODER],"draco",e,zt.FALLBACK_DECODER);break;case"wasm":default:[t,n]=await Promise.all([await me(cf[zt.DECODER],"draco",e,zt.DECODER),await me(cf[zt.DECODER_WASM],"draco",e,zt.DECODER_WASM)])}return t=t||globalThis.DracoDecoderModule,await CI(t,n)}function CI(e,t){let n={};return t&&(n.wasmBinary=t),new Promise(r=>{e({...n,onModuleLoaded:s=>r({draco:s})})})}var ac={...x2,parse:LI};async function LI(e,t){let{draco:n}=await S2(t),r=new si(n);try{return r.parseSync(e,t?.draco)}finally{r.destroy()}}var RI={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},xt={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},v={...RI,...xt};var hf={[xt.DOUBLE]:Float64Array,[xt.FLOAT]:Float32Array,[xt.UNSIGNED_SHORT]:Uint16Array,[xt.UNSIGNED_INT]:Uint32Array,[xt.UNSIGNED_BYTE]:Uint8Array,[xt.BYTE]:Int8Array,[xt.SHORT]:Int16Array,[xt.INT]:Int32Array},wI={DOUBLE:xt.DOUBLE,FLOAT:xt.FLOAT,UNSIGNED_SHORT:xt.UNSIGNED_SHORT,UNSIGNED_INT:xt.UNSIGNED_INT,UNSIGNED_BYTE:xt.UNSIGNED_BYTE,BYTE:xt.BYTE,SHORT:xt.SHORT,INT:xt.INT},lf="Failed to convert GL type",Ot=class{static fromTypedArray(t){t=ArrayBuffer.isView(t)?t.constructor:t;for(let n in hf)if(hf[n]===t)return n;throw new Error(lf)}static fromName(t){let n=wI[t];if(!n)throw new Error(lf);return n}static getArrayType(t){switch(t){case xt.UNSIGNED_SHORT_5_6_5:case xt.UNSIGNED_SHORT_4_4_4_4:case xt.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:let n=hf[t];if(!n)throw new Error(lf);return n}}static getByteSize(t){return Ot.getArrayType(t).BYTES_PER_ELEMENT}static validate(t){return Boolean(Ot.getArrayType(t))}static createTypedArray(t,n,r=0,s){s===void 0&&(s=(n.byteLength-r)/Ot.getByteSize(t));let i=Ot.getArrayType(t);return new i(n,r,s)}};var QW=1/Math.PI*180,$W=1/180*Math.PI,II={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...II}};var Bt=globalThis.mathgl.config;function ff(e,{precision:t=Bt.precision}={}){return e=bI(e),`${parseFloat(e.toPrecision(t))}`}function Le(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pf(e,t,n){return PI(e,r=>Math.max(t,Math.min(n,r)))}function hc(e,t,n){let r=Bt.EPSILON;n&&(Bt.EPSILON=n);try{if(e===t)return!0;if(Le(e)&&Le(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!hc(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=Bt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{Bt.EPSILON=r}}function bI(e){return Math.round(e/Bt.EPSILON)*Bt.EPSILON}function OI(e){return e.clone?e.clone():new Array(e.length)}function PI(e,t,n){if(Le(e)){let r=e;n=n||OI(r);for(let s=0;s<n.length&&s<r.length;++s){let i=typeof e=="number"?e:e[s];n[s]=t(i,s,n)}return n}return t(e)}var lc=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Le(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Bt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+ff(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!hc(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(Bt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function yt(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function uf(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Dr=class extends lc{get x(){return this[0]}set x(t){this[0]=yt(t)}get y(){return this[1]}set y(t){this[1]=yt(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return yt(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return yt(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return uf(t>=0&&t<this.ELEMENTS,"index is out of range"),yt(this[t])}setComponent(t,n){return uf(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var Ur=typeof Float32Array<"u"?Float32Array:Array;var hJ=Math.PI/180;function DI(){let e=new Ur(2);return Ur!=Float32Array&&(e[0]=0,e[1]=0),e}function C2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e}function L2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s+n[4],e[1]=n[1]*r+n[3]*s+n[5],e}function R2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}function w2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var lJ=function(){let e=DI();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function I2(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function b2(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function O2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}var Hn=class extends Dr{constructor(t=0,n=0){super(2),Le(t)&&arguments.length===1?this.copy(t):(Bt.debug&&(yt(t),yt(n)),this[0]=t,this[1]=n)}set(t,n){return this[0]=t,this[1]=n,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this.check()}fromObject(t){return Bt.debug&&(yt(t.x),yt(t.y)),this[0]=t.x,this[1]=t.y,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return w2(this,this,t),this.check()}transformAsVector(t){return I2(this,this,t),this.check()}transformByMatrix3(t){return R2(this,this,t),this.check()}transformByMatrix2x3(t){return L2(this,this,t),this.check()}transformByMatrix2(t){return C2(this,this,t),this.check()}};function UI(){let e=new Ur(3);return Ur!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function GI(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function P2(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function N2(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function F2(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function v2(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function D2(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function U2(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function G2(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function z2(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&GI(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var AJ=function(){let e=UI();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var df=[0,0,0],fc,Yn=class extends Dr{static get ZERO(){return fc||(fc=new Yn(0,0,0),Object.freeze(fc)),fc}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&Le(t)?this.copy(t):(Bt.debug&&(yt(t),yt(n),yt(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return Bt.debug&&(yt(t.x),yt(t.y),yt(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=yt(t)}angle(t){return z2(this,t)}cross(t){return P2(this,this,t),this.check()}rotateX({radians:t,origin:n=df}){return D2(this,this,n,t),this.check()}rotateY({radians:t,origin:n=df}){return U2(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=df}){return G2(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return N2(this,this,t),this.check()}transformAsVector(t){return b2(this,this,t),this.check()}transformByMatrix3(t){return F2(this,this,t),this.check()}transformByMatrix2(t){return O2(this,this,t),this.check()}transformByQuaternion(t){return v2(this,this,t),this.check()}};function k2(e,t){if(!e)throw new Error(`math.gl assertion failed. ${t}`)}function mf(e,t=[0,0,0]){let n=e>>11&31,r=e>>5&63,s=e&31;return t[0]=n<<3,t[1]=r<<2,t[2]=s<<3,t}var ZJ=1/256;var QJ=new Hn,$J=new Yn,tX=new Hn,eX=new Hn,nX=new Uint8Array(1);function V2(e,t=255){return pf(e,0,t)/t*2-1}function q2(e){return e<0?-1:1}function H2(e,t,n,r){if(k2(r),e<0||e>n||t<0||t>n)throw new Error(`x and y must be unsigned normalized integers between 0 and ${n}`);if(r.x=V2(e,n),r.y=V2(t,n),r.z=1-(Math.abs(r.x)+Math.abs(r.y)),r.z<0){let s=r.x;r.x=(1-Math.abs(r.y))*q2(s),r.y=(1-Math.abs(s))*q2(r.y)}return r.normalize()}function gf(e,t,n){return H2(e,t,255,n)}var TX=1/Math.PI*180,_X=1/180*Math.PI,zI={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...zI}};var Mt=globalThis.mathgl.config;function Y2(e,{precision:t=Mt.precision}={}){return e=kI(e),`${parseFloat(e.toPrecision(t))}`}function Mn(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function xf(e,t,n){let r=Mt.EPSILON;n&&(Mt.EPSILON=n);try{if(e===t)return!0;if(Mn(e)&&Mn(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!xf(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=Mt.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{Mt.EPSILON=r}}function kI(e){return Math.round(e/Mt.EPSILON)*Mt.EPSILON}var An=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:Mn(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Mt)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+Y2(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!xf(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(Mt.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function VI(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function J(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function yn(e,t,n=""){if(Mt.debug&&!VI(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Mf(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Gr=class extends An{get x(){return this[0]}set x(t){this[0]=J(t)}get y(){return this[1]}set y(t){this[1]=J(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return J(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return J(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Mf(t>=0&&t<this.ELEMENTS,"index is out of range"),J(this[t])}setComponent(t,n){return Mf(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var Pt=typeof Float32Array<"u"?Float32Array:Array;var NX=Math.PI/180;function qI(){let e=new Pt(2);return Pt!=Float32Array&&(e[0]=0,e[1]=0),e}function X2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}function j2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[4]*s+n[12],e[1]=n[1]*r+n[5]*s+n[13],e}var FX=function(){let e=qI();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function K2(e,t,n){let r=t[0],s=t[1],i=n[3]*r+n[7]*s||1;return e[0]=(n[0]*r+n[4]*s)/i,e[1]=(n[1]*r+n[5]*s)/i,e}function pc(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function Z2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}function Q2(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e[3]=t[3],e}function uc(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function Af(){let e=new Pt(3);return Pt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function HI(e){let t=e[0],n=e[1],r=e[2];return Math.sqrt(t*t+n*n+r*r)}function yf(e,t,n){let r=new Pt(3);return r[0]=e,r[1]=t,r[2]=n,r}function $2(e,t){let n=t[0],r=t[1],s=t[2],i=n*n+r*r+s*s;return i>0&&(i=1/Math.sqrt(i)),e[0]=t[0]*i,e[1]=t[1]*i,e[2]=t[2]*i,e}function Ef(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function zr(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function kr(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function dc(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function mc(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function tM(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function eM(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function nM(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function rM(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&Ef(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var sM=HI;var UX=function(){let e=Af();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Tf=[0,0,0],gc,Z=class extends Gr{static get ZERO(){return gc||(gc=new Z(0,0,0),Object.freeze(gc)),gc}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&Mn(t)?this.copy(t):(Mt.debug&&(J(t),J(n),J(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return Mt.debug&&(J(t.x),J(t.y),J(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=J(t)}angle(t){return rM(this,t)}cross(t){return zr(this,this,t),this.check()}rotateX({radians:t,origin:n=Tf}){return tM(this,this,n,t),this.check()}rotateY({radians:t,origin:n=Tf}){return eM(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=Tf}){return nM(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return kr(this,this,t),this.check()}transformAsVector(t){return pc(this,this,t),this.check()}transformByMatrix3(t){return dc(this,this,t),this.check()}transformByMatrix2(t){return Z2(this,this,t),this.check()}transformByQuaternion(t){return mc(this,this,t),this.check()}};var xc,Vr=class extends Gr{static get ZERO(){return xc||(xc=new Vr(0,0,0,0),Object.freeze(xc)),xc}constructor(t=0,n=0,r=0,s=0){super(-0,-0,-0,-0),Mn(t)&&arguments.length===1?this.copy(t):(Mt.debug&&(J(t),J(n),J(r),J(s)),this[0]=t,this[1]=n,this[2]=r,this[3]=s)}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 Mt.debug&&(J(t.x),J(t.y),J(t.z),J(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]=J(t)}get w(){return this[3]}set w(t){this[3]=J(t)}transform(t){return kr(this,this,t),this.check()}transformByMatrix3(t){return uc(this,this,t),this.check()}transformByMatrix2(t){return Q2(this,this,t),this.check()}transformByQuaternion(t){return mc(this,this,t),this.check()}applyMatrix4(t){return t.transform(this,this),this}};var qr=class extends An{toString(){let t="[";if(Mt.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=J(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function iM(){let e=new Pt(9);return Pt!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[5]=0,e[6]=0,e[7]=0),e[0]=1,e[4]=1,e[8]=1,e}function oM(e,t){if(e===t){let n=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function cM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=l*o-c*h,p=-l*i+c*a,u=h*i-o*a,d=n*f+r*p+s*u;return d?(d=1/d,e[0]=f*d,e[1]=(-l*r+s*h)*d,e[2]=(c*r-s*o)*d,e[3]=p*d,e[4]=(l*n-s*a)*d,e[5]=(-c*n+s*i)*d,e[6]=u*d,e[7]=(-h*n+r*a)*d,e[8]=(o*n-r*i)*d,e):null}function aM(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8];return t*(h*i-o*a)+n*(-h*s+o*c)+r*(a*s-i*c)}function _f(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1],d=n[2],g=n[3],m=n[4],M=n[5],E=n[6],A=n[7],y=n[8];return e[0]=p*r+u*o+d*h,e[1]=p*s+u*c+d*l,e[2]=p*i+u*a+d*f,e[3]=g*r+m*o+M*h,e[4]=g*s+m*c+M*l,e[5]=g*i+m*a+M*f,e[6]=E*r+A*o+y*h,e[7]=E*s+A*c+y*l,e[8]=E*i+A*a+y*f,e}function hM(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1];return e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=c,e[5]=a,e[6]=p*r+u*o+h,e[7]=p*s+u*c+l,e[8]=p*i+u*a+f,e}function lM(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=Math.sin(n),u=Math.cos(n);return e[0]=u*r+p*o,e[1]=u*s+p*c,e[2]=u*i+p*a,e[3]=u*o-p*r,e[4]=u*c-p*s,e[5]=u*a-p*i,e[6]=h,e[7]=l,e[8]=f,e}function Sf(e,t,n){let r=n[0],s=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function fM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[3]=l-M,e[6]=p+m,e[1]=l+M,e[4]=1-h-d,e[7]=u-g,e[2]=p-m,e[5]=u+g,e[8]=1-h-f,e}var Bf;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(Bf||(Bf={}));var JI=Object.freeze([1,0,0,0,1,0,0,0,1]),Wn=class extends qr{static get IDENTITY(){return jI()}static get ZERO(){return XI()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Bf}constructor(t,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):n.length>0?this.copy([t,...n]):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(JI)}fromObject(t){return this.check()}fromQuaternion(t){return fM(this,t),this.check()}set(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=i,this[5]=a,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return aM(this)}transpose(){return oM(this,this),this.check()}invert(){return cM(this,this),this.check()}multiplyLeft(t){return _f(this,t,this),this.check()}multiplyRight(t){return _f(this,this,t),this.check()}rotate(t){return lM(this,this,t),this.check()}scale(t){return Array.isArray(t)?Sf(this,this,t):Sf(this,this,[t,t]),this.check()}translate(t){return hM(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=X2(n||[-0,-0],t,this);break;case 3:r=dc(n||[-0,-0,-0],t,this);break;case 4:r=uc(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return yn(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},Mc,Ac=null;function XI(){return Mc||(Mc=new Wn([0,0,0,0,0,0,0,0,0]),Object.freeze(Mc)),Mc}function jI(){return Ac||(Ac=new Wn,Object.freeze(Ac)),Ac}function KI(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function pM(e,t){if(e===t){let n=t[1],r=t[2],s=t[3],i=t[6],o=t[7],c=t[11];e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=n,e[6]=t[9],e[7]=t[13],e[8]=r,e[9]=i,e[11]=t[14],e[12]=s,e[13]=o,e[14]=c}else e[0]=t[0],e[1]=t[4],e[2]=t[8],e[3]=t[12],e[4]=t[1],e[5]=t[5],e[6]=t[9],e[7]=t[13],e[8]=t[2],e[9]=t[6],e[10]=t[10],e[11]=t[14],e[12]=t[3],e[13]=t[7],e[14]=t[11],e[15]=t[15];return e}function uM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=t[9],p=t[10],u=t[11],d=t[12],g=t[13],m=t[14],M=t[15],E=n*c-r*o,A=n*a-s*o,y=n*h-i*o,T=r*a-s*c,_=r*h-i*c,L=s*h-i*a,B=l*g-f*d,S=l*m-p*d,x=l*M-u*d,R=f*m-p*g,w=f*M-u*g,I=p*M-u*m,C=E*I-A*w+y*R+T*x-_*S+L*B;return C?(C=1/C,e[0]=(c*I-a*w+h*R)*C,e[1]=(s*w-r*I-i*R)*C,e[2]=(g*L-m*_+M*T)*C,e[3]=(p*_-f*L-u*T)*C,e[4]=(a*x-o*I-h*S)*C,e[5]=(n*I-s*x+i*S)*C,e[6]=(m*y-d*L-M*A)*C,e[7]=(l*L-p*y+u*A)*C,e[8]=(o*w-c*x+h*B)*C,e[9]=(r*x-n*w-i*B)*C,e[10]=(d*_-g*y+M*E)*C,e[11]=(f*y-l*_-u*E)*C,e[12]=(c*S-o*R-a*B)*C,e[13]=(n*R-r*S+s*B)*C,e[14]=(g*A-d*T-m*E)*C,e[15]=(l*T-f*A+p*E)*C,e):null}function dM(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8],l=e[9],f=e[10],p=e[11],u=e[12],d=e[13],g=e[14],m=e[15],M=t*o-n*i,E=t*c-r*i,A=n*c-r*o,y=h*d-l*u,T=h*g-f*u,_=l*g-f*d,L=t*_-n*T+r*y,B=i*_-o*T+c*y,S=h*A-l*E+f*M,x=u*A-d*E+g*M;return a*L-s*B+m*S-p*x}function Cf(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=t[9],u=t[10],d=t[11],g=t[12],m=t[13],M=t[14],E=t[15],A=n[0],y=n[1],T=n[2],_=n[3];return e[0]=A*r+y*c+T*f+_*g,e[1]=A*s+y*a+T*p+_*m,e[2]=A*i+y*h+T*u+_*M,e[3]=A*o+y*l+T*d+_*E,A=n[4],y=n[5],T=n[6],_=n[7],e[4]=A*r+y*c+T*f+_*g,e[5]=A*s+y*a+T*p+_*m,e[6]=A*i+y*h+T*u+_*M,e[7]=A*o+y*l+T*d+_*E,A=n[8],y=n[9],T=n[10],_=n[11],e[8]=A*r+y*c+T*f+_*g,e[9]=A*s+y*a+T*p+_*m,e[10]=A*i+y*h+T*u+_*M,e[11]=A*o+y*l+T*d+_*E,A=n[12],y=n[13],T=n[14],_=n[15],e[12]=A*r+y*c+T*f+_*g,e[13]=A*s+y*a+T*p+_*m,e[14]=A*i+y*h+T*u+_*M,e[15]=A*o+y*l+T*d+_*E,e}function mM(e,t,n){let r=n[0],s=n[1],i=n[2],o,c,a,h,l,f,p,u,d,g,m,M;return t===e?(e[12]=t[0]*r+t[4]*s+t[8]*i+t[12],e[13]=t[1]*r+t[5]*s+t[9]*i+t[13],e[14]=t[2]*r+t[6]*s+t[10]*i+t[14],e[15]=t[3]*r+t[7]*s+t[11]*i+t[15]):(o=t[0],c=t[1],a=t[2],h=t[3],l=t[4],f=t[5],p=t[6],u=t[7],d=t[8],g=t[9],m=t[10],M=t[11],e[0]=o,e[1]=c,e[2]=a,e[3]=h,e[4]=l,e[5]=f,e[6]=p,e[7]=u,e[8]=d,e[9]=g,e[10]=m,e[11]=M,e[12]=o*r+l*s+d*i+t[12],e[13]=c*r+f*s+g*i+t[13],e[14]=a*r+p*s+m*i+t[14],e[15]=h*r+u*s+M*i+t[15]),e}function gM(e,t,n){let r=n[0],s=n[1],i=n[2];return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e[3]=t[3]*r,e[4]=t[4]*s,e[5]=t[5]*s,e[6]=t[6]*s,e[7]=t[7]*s,e[8]=t[8]*i,e[9]=t[9]*i,e[10]=t[10]*i,e[11]=t[11]*i,e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}function xM(e,t,n,r){let s=r[0],i=r[1],o=r[2],c=Math.sqrt(s*s+i*i+o*o),a,h,l,f,p,u,d,g,m,M,E,A,y,T,_,L,B,S,x,R,w,I,C,P;return c<1e-6?null:(c=1/c,s*=c,i*=c,o*=c,h=Math.sin(n),a=Math.cos(n),l=1-a,f=t[0],p=t[1],u=t[2],d=t[3],g=t[4],m=t[5],M=t[6],E=t[7],A=t[8],y=t[9],T=t[10],_=t[11],L=s*s*l+a,B=i*s*l+o*h,S=o*s*l-i*h,x=s*i*l-o*h,R=i*i*l+a,w=o*i*l+s*h,I=s*o*l+i*h,C=i*o*l-s*h,P=o*o*l+a,e[0]=f*L+g*B+A*S,e[1]=p*L+m*B+y*S,e[2]=u*L+M*B+T*S,e[3]=d*L+E*B+_*S,e[4]=f*x+g*R+A*w,e[5]=p*x+m*R+y*w,e[6]=u*x+M*R+T*w,e[7]=d*x+E*R+_*w,e[8]=f*I+g*C+A*P,e[9]=p*I+m*C+y*P,e[10]=u*I+M*C+T*P,e[11]=d*I+E*C+_*P,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e)}function MM(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[4],o=t[5],c=t[6],a=t[7],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[4]=i*s+h*r,e[5]=o*s+l*r,e[6]=c*s+f*r,e[7]=a*s+p*r,e[8]=h*s-i*r,e[9]=l*s-o*r,e[10]=f*s-c*r,e[11]=p*s-a*r,e}function AM(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[8],l=t[9],f=t[10],p=t[11];return t!==e&&(e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s-h*r,e[1]=o*s-l*r,e[2]=c*s-f*r,e[3]=a*s-p*r,e[8]=i*r+h*s,e[9]=o*r+l*s,e[10]=c*r+f*s,e[11]=a*r+p*s,e}function yM(e,t,n){let r=Math.sin(n),s=Math.cos(n),i=t[0],o=t[1],c=t[2],a=t[3],h=t[4],l=t[5],f=t[6],p=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=i*s+h*r,e[1]=o*s+l*r,e[2]=c*s+f*r,e[3]=a*s+p*r,e[4]=h*s-i*r,e[5]=l*s-o*r,e[6]=f*s-c*r,e[7]=p*s-a*r,e}function EM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[1]=l+M,e[2]=p-m,e[3]=0,e[4]=l-M,e[5]=1-h-d,e[6]=u+g,e[7]=0,e[8]=p+m,e[9]=u-g,e[10]=1-h-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function TM(e,t,n,r,s,i,o){let c=1/(n-t),a=1/(s-r),h=1/(i-o);return e[0]=i*2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i*2*a,e[6]=0,e[7]=0,e[8]=(n+t)*c,e[9]=(s+r)*a,e[10]=(o+i)*h,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*i*2*h,e[15]=0,e}function ZI(e,t,n,r,s){let i=1/Math.tan(t/2);if(e[0]=i/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=i,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,s!=null&&s!==1/0){let o=1/(r-s);e[10]=(s+r)*o,e[14]=2*s*r*o}else e[10]=-1,e[14]=-2*r;return e}var _M=ZI;function QI(e,t,n,r,s,i,o){let c=1/(t-n),a=1/(r-s),h=1/(i-o);return e[0]=-2*c,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*h,e[11]=0,e[12]=(t+n)*c,e[13]=(s+r)*a,e[14]=(o+i)*h,e[15]=1,e}var SM=QI;function BM(e,t,n,r){let s,i,o,c,a,h,l,f,p,u,d=t[0],g=t[1],m=t[2],M=r[0],E=r[1],A=r[2],y=n[0],T=n[1],_=n[2];return Math.abs(d-y)<1e-6&&Math.abs(g-T)<1e-6&&Math.abs(m-_)<1e-6?KI(e):(f=d-y,p=g-T,u=m-_,s=1/Math.sqrt(f*f+p*p+u*u),f*=s,p*=s,u*=s,i=E*u-A*p,o=A*f-M*u,c=M*p-E*f,s=Math.sqrt(i*i+o*o+c*c),s?(s=1/s,i*=s,o*=s,c*=s):(i=0,o=0,c=0),a=p*c-u*o,h=u*i-f*c,l=f*o-p*i,s=Math.sqrt(a*a+h*h+l*l),s?(s=1/s,a*=s,h*=s,l*=s):(a=0,h=0,l=0),e[0]=i,e[1]=a,e[2]=f,e[3]=0,e[4]=o,e[5]=h,e[6]=p,e[7]=0,e[8]=c,e[9]=l,e[10]=u,e[11]=0,e[12]=-(i*d+o*g+c*m),e[13]=-(a*d+h*g+l*m),e[14]=-(f*d+p*g+u*m),e[15]=1,e)}function $I(){let e=new Pt(4);return Pt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function CM(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function LM(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function RM(e){let t=e[0],n=e[1],r=e[2],s=e[3];return Math.sqrt(t*t+n*n+r*r+s*s)}function wM(e){let t=e[0],n=e[1],r=e[2],s=e[3];return t*t+n*n+r*r+s*s}function IM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i;return o>0&&(o=1/Math.sqrt(o)),e[0]=n*o,e[1]=r*o,e[2]=s*o,e[3]=i*o,e}function bM(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}function OM(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3];return e[0]=s+r*(n[0]-s),e[1]=i+r*(n[1]-i),e[2]=o+r*(n[2]-o),e[3]=c+r*(n[3]-c),e}function PM(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3];return e[0]=n[0]*r+n[4]*s+n[8]*i+n[12]*o,e[1]=n[1]*r+n[5]*s+n[9]*i+n[13]*o,e[2]=n[2]*r+n[6]*s+n[10]*i+n[14]*o,e[3]=n[3]*r+n[7]*s+n[11]*i+n[15]*o,e}function NM(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2],h=n[3],l=h*r+c*i-a*s,f=h*s+a*r-o*i,p=h*i+o*s-c*r,u=-o*r-c*s-a*i;return e[0]=l*h+u*-o+f*-a-p*-c,e[1]=f*h+u*-c+p*-o-l*-a,e[2]=p*h+u*-a+l*-c-f*-o,e[3]=t[3],e}var hj=function(){let e=$I();return function(t,n,r,s,i,o){let c,a;for(n||(n=4),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],e[3]=t[c+3],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2],t[c+3]=e[3];return t}}();var wf;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL0ROW3=3]="COL0ROW3",e[e.COL1ROW0=4]="COL1ROW0",e[e.COL1ROW1=5]="COL1ROW1",e[e.COL1ROW2=6]="COL1ROW2",e[e.COL1ROW3=7]="COL1ROW3",e[e.COL2ROW0=8]="COL2ROW0",e[e.COL2ROW1=9]="COL2ROW1",e[e.COL2ROW2=10]="COL2ROW2",e[e.COL2ROW3=11]="COL2ROW3",e[e.COL3ROW0=12]="COL3ROW0",e[e.COL3ROW1=13]="COL3ROW1",e[e.COL3ROW2=14]="COL3ROW2",e[e.COL3ROW3=15]="COL3ROW3"})(wf||(wf={}));var eb=45*Math.PI/180,nb=1,Lf=.1,Rf=500,rb=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]),En=class extends qr{static get IDENTITY(){return ib()}static get ZERO(){return sb()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return wf}constructor(t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):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[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15],this.check()}set(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this[9]=l,this[10]=f,this[11]=p,this[12]=u,this[13]=d,this[14]=g,this[15]=m,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h,l,f,p,u,d,g,m){return this[0]=t,this[1]=i,this[2]=h,this[3]=u,this[4]=n,this[5]=o,this[6]=l,this[7]=d,this[8]=r,this[9]=c,this[10]=f,this[11]=g,this[12]=s,this[13]=a,this[14]=p,this[15]=m,this.check()}toRowMajor(t){return t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15],t}identity(){return this.copy(rb)}fromObject(t){return this.check()}fromQuaternion(t){return EM(this,t),this.check()}frustum(t){let{left:n,right:r,bottom:s,top:i,near:o=Lf,far:c=Rf}=t;return c===1/0?ob(this,n,r,s,i,o):TM(this,n,r,s,i,o,c),this.check()}lookAt(t){let{eye:n,center:r=[0,0,0],up:s=[0,1,0]}=t;return BM(this,n,r,s),this.check()}ortho(t){let{left:n,right:r,bottom:s,top:i,near:o=Lf,far:c=Rf}=t;return SM(this,n,r,s,i,o,c),this.check()}orthographic(t){let{fovy:n=eb,aspect:r=nb,focalDistance:s=1,near:i=Lf,far:o=Rf}=t;FM(n);let c=n/2,a=s*Math.tan(c),h=a*r;return this.ortho({left:-h,right:h,bottom:-a,top:a,near:i,far:o})}perspective(t){let{fovy:n=45*Math.PI/180,aspect:r=1,near:s=.1,far:i=500}=t;return FM(n),_M(this,n,r,s,i),this.check()}determinant(){return dM(this)}getScale(t=[-0,-0,-0]){return t[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),t[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),t[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),t}getTranslation(t=[-0,-0,-0]){return t[0]=this[12],t[1]=this[13],t[2]=this[14],t}getRotation(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=0,t[4]=this[4]*s,t[5]=this[5]*i,t[6]=this[6]*o,t[7]=0,t[8]=this[8]*s,t[9]=this[9]*i,t[10]=this[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}getRotationMatrix3(t,n){t=t||[-0,-0,-0,-0,-0,-0,-0,-0,-0],n=n||[-0,-0,-0];let r=this.getScale(n),s=1/r[0],i=1/r[1],o=1/r[2];return t[0]=this[0]*s,t[1]=this[1]*i,t[2]=this[2]*o,t[3]=this[4]*s,t[4]=this[5]*i,t[5]=this[6]*o,t[6]=this[8]*s,t[7]=this[9]*i,t[8]=this[10]*o,t}transpose(){return pM(this,this),this.check()}invert(){return uM(this,this),this.check()}multiplyLeft(t){return Cf(this,t,this),this.check()}multiplyRight(t){return Cf(this,this,t),this.check()}rotateX(t){return MM(this,this,t),this.check()}rotateY(t){return AM(this,this,t),this.check()}rotateZ(t){return yM(this,this,t),this.check()}rotateXYZ(t){return this.rotateX(t[0]).rotateY(t[1]).rotateZ(t[2])}rotateAxis(t,n){return xM(this,this,t,n),this.check()}scale(t){return gM(this,this,Array.isArray(t)?t:[t,t,t]),this.check()}translate(t){return mM(this,this,t),this.check()}transform(t,n){return t.length===4?(n=PM(n||[-0,-0,-0,-0],t,this),yn(n,4),n):this.transformAsPoint(t,n)}transformAsPoint(t,n){let{length:r}=t,s;switch(r){case 2:s=j2(n||[-0,-0],t,this);break;case 3:s=kr(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return yn(s,t.length),s}transformAsVector(t,n){let r;switch(t.length){case 2:r=K2(n||[-0,-0],t,this);break;case 3:r=pc(n||[-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return yn(r,t.length),r}transformPoint(t,n){return this.transformAsPoint(t,n)}transformVector(t,n){return this.transformAsPoint(t,n)}transformDirection(t,n){return this.transformAsVector(t,n)}makeRotationX(t){return this.identity().rotateX(t)}makeTranslation(t,n,r){return this.identity().translate([t,n,r])}},yc,Ec;function sb(){return yc||(yc=new En([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(yc)),yc}function ib(){return Ec||(Ec=new En,Object.freeze(Ec)),Ec}function FM(e){if(e>Math.PI*2)throw Error("expected radians")}function ob(e,t,n,r,s,i){let o=2*i/(n-t),c=2*i/(s-r),a=(n+t)/(n-t),h=(s+r)/(s-r),l=-1,f=-1,p=-2*i;return e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=c,e[6]=0,e[7]=0,e[8]=a,e[9]=h,e[10]=l,e[11]=f,e[12]=0,e[13]=0,e[14]=p,e[15]=0,e}function vM(){let e=new Pt(4);return Pt!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function DM(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function If(e,t,n){n=n*.5;let r=Math.sin(n);return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=Math.cos(n),e}function bf(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=n[0],a=n[1],h=n[2],l=n[3];return e[0]=r*l+o*c+s*h-i*a,e[1]=s*l+o*a+i*c-r*h,e[2]=i*l+o*h+r*a-s*c,e[3]=o*l-r*c-s*a-i*h,e}function UM(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+o*c,e[1]=s*a+i*c,e[2]=i*a-s*c,e[3]=o*a-r*c,e}function GM(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a-i*c,e[1]=s*a+o*c,e[2]=i*a+r*c,e[3]=o*a-s*c,e}function zM(e,t,n){n*=.5;let r=t[0],s=t[1],i=t[2],o=t[3],c=Math.sin(n),a=Math.cos(n);return e[0]=r*a+s*c,e[1]=s*a-r*c,e[2]=i*a+o*c,e[3]=o*a-i*c,e}function kM(e,t){let n=t[0],r=t[1],s=t[2];return e[0]=n,e[1]=r,e[2]=s,e[3]=Math.sqrt(Math.abs(1-n*n-r*r-s*s)),e}function oi(e,t,n,r){let s=t[0],i=t[1],o=t[2],c=t[3],a=n[0],h=n[1],l=n[2],f=n[3],p,u,d,g,m;return p=s*a+i*h+o*l+c*f,p<0&&(p=-p,a=-a,h=-h,l=-l,f=-f),1-p>1e-6?(u=Math.acos(p),m=Math.sin(u),d=Math.sin((1-r)*u)/m,g=Math.sin(r*u)/m):(d=1-r,g=r),e[0]=d*s+g*a,e[1]=d*i+g*h,e[2]=d*o+g*l,e[3]=d*c+g*f,e}function VM(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n*n+r*r+s*s+i*i,c=o?1/o:0;return e[0]=-n*c,e[1]=-r*c,e[2]=-s*c,e[3]=i*c,e}function qM(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e}function Of(e,t){let n=t[0]+t[4]+t[8],r;if(n>0)r=Math.sqrt(n+1),e[3]=.5*r,r=.5/r,e[0]=(t[5]-t[7])*r,e[1]=(t[6]-t[2])*r,e[2]=(t[1]-t[3])*r;else{let s=0;t[4]>t[0]&&(s=1),t[8]>t[s*3+s]&&(s=2);let i=(s+1)%3,o=(s+2)%3;r=Math.sqrt(t[s*3+s]-t[i*3+i]-t[o*3+o]+1),e[s]=.5*r,r=.5/r,e[3]=(t[i*3+o]-t[o*3+i])*r,e[i]=(t[i*3+s]+t[s*3+i])*r,e[o]=(t[o*3+s]+t[s*3+o])*r}return e}var HM=CM;var YM=LM,WM=bM,JM=OM,XM=RM;var jM=wM;var KM=IM;var ZM=function(){let e=Af(),t=yf(1,0,0),n=yf(0,1,0);return function(r,s,i){let o=Ef(s,i);return o<-.999999?(zr(e,t,s),sM(e)<1e-6&&zr(e,n,s),$2(e,e),If(r,e,Math.PI),r):o>.999999?(r[0]=0,r[1]=0,r[2]=0,r[3]=1,r):(zr(e,s,i),r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=1+o,KM(r,r))}}(),_j=function(){let e=vM(),t=vM();return function(n,r,s,i,o,c){return oi(e,r,o,c),oi(t,s,i,c),oi(n,e,t,2*c*(1-c)),n}}(),Sj=function(){let e=iM();return function(t,n,r,s){return e[0]=r[0],e[3]=r[1],e[6]=r[2],e[1]=s[0],e[4]=s[1],e[7]=s[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],KM(t,Of(t,e))}}();var cb=[0,0,0,1],ci=class extends An{constructor(t=0,n=0,r=0,s=1){super(-0,-0,-0,-0),Array.isArray(t)&&arguments.length===1?this.copy(t):this.set(t,n,r,s)}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this.check()}set(t,n,r,s){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,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 Of(this,t),this.check()}fromAxisRotation(t,n){return If(this,t,n),this.check()}identity(){return DM(this),this.check()}setAxisAngle(t,n){return this.fromAxisRotation(t,n)}get ELEMENTS(){return 4}get x(){return this[0]}set x(t){this[0]=J(t)}get y(){return this[1]}set y(t){this[1]=J(t)}get z(){return this[2]}set z(t){this[2]=J(t)}get w(){return this[3]}set w(t){this[3]=J(t)}len(){return XM(this)}lengthSquared(){return jM(this)}dot(t){return WM(this,t)}rotationTo(t,n){return ZM(this,t,n),this.check()}add(t){return HM(this,this,t),this.check()}calculateW(){return kM(this,this),this.check()}conjugate(){return qM(this,this),this.check()}invert(){return VM(this,this),this.check()}lerp(t,n,r){return r===void 0?this.lerp(this,t,n):(JM(this,t,n,r),this.check())}multiplyRight(t){return bf(this,this,t),this.check()}multiplyLeft(t){return bf(this,t,this),this.check()}normalize(){let t=this.len(),n=t>0?1/t:0;return this[0]=this[0]*n,this[1]=this[1]*n,this[2]=this[2]*n,this[3]=this[3]*n,t===0&&(this[3]=1),this.check()}rotateX(t){return UM(this,this,t),this.check()}rotateY(t){return GM(this,this,t),this.check()}rotateZ(t){return zM(this,this,t),this.check()}scale(t){return YM(this,this,t),this.check()}slerp(t,n,r){let s,i,o;switch(arguments.length){case 1:({start:s=cb,target:i,ratio:o}=t);break;case 2:s=this,i=t,o=n;break;default:s=t,i=n,o=r}return oi(this,s,i,o),this.check()}transformVector4(t,n=new Vr){return NM(n,t,this),yn(n,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(t,n){return this.setAxisAngle(t,n)}premultiply(t){return this.multiplyLeft(t)}multiply(t){return this.multiplyRight(t)}};var Ve=class{json;buffer;featuresLength=0;_cachedTypedArrays={};constructor(t,n){this.json=t,this.buffer=n}getExtension(t){return this.json.extensions&&this.json.extensions[t]}hasProperty(t){return Boolean(this.json[t])}getGlobalProperty(t,n=v.UNSIGNED_INT,r=1){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?this._getTypedArrayFromBinary(t,n,r,1,s.byteOffset):s}getPropertyArray(t,n,r){let s=this.json[t];return s&&Number.isFinite(s.byteOffset)?("componentType"in s&&(n=Ot.fromName(s.componentType)),this._getTypedArrayFromBinary(t,n,r,this.featuresLength,s.byteOffset)):this._getTypedArrayFromArray(t,n,s)}getProperty(t,n,r,s,i){let o=this.json[t];if(!o)return o;let c=this.getPropertyArray(t,n,r);if(r===1)return c[s];for(let a=0;a<r;++a)i[a]=c[r*s+a];return i}_getTypedArrayFromBinary(t,n,r,s,i){let o=this._cachedTypedArrays,c=o[t];return c||(c=Ot.createTypedArray(n,this.buffer.buffer,this.buffer.byteOffset+i,s*r),o[t]=c),c}_getTypedArrayFromArray(t,n,r){let s=this._cachedTypedArrays,i=s[t];return i||(i=Ot.createTypedArray(n,r),s[t]=i),i}};var ab={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},hb={SCALAR:(e,t)=>e[t],VEC2:(e,t)=>[e[2*t+0],e[2*t+1]],VEC3:(e,t)=>[e[3*t+0],e[3*t+1],e[3*t+2]],VEC4:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT2:(e,t)=>[e[4*t+0],e[4*t+1],e[4*t+2],e[4*t+3]],MAT3:(e,t)=>[e[9*t+0],e[9*t+1],e[9*t+2],e[9*t+3],e[9*t+4],e[9*t+5],e[9*t+6],e[9*t+7],e[9*t+8]],MAT4:(e,t)=>[e[16*t+0],e[16*t+1],e[16*t+2],e[16*t+3],e[16*t+4],e[16*t+5],e[16*t+6],e[16*t+7],e[16*t+8],e[16*t+9],e[16*t+10],e[16*t+11],e[16*t+12],e[16*t+13],e[16*t+14],e[16*t+15]]},lb={SCALAR:(e,t,n)=>{t[n]=e},VEC2:(e,t,n)=>{t[2*n+0]=e[0],t[2*n+1]=e[1]},VEC3:(e,t,n)=>{t[3*n+0]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2]},VEC4:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT2:(e,t,n)=>{t[4*n+0]=e[0],t[4*n+1]=e[1],t[4*n+2]=e[2],t[4*n+3]=e[3]},MAT3:(e,t,n)=>{t[9*n+0]=e[0],t[9*n+1]=e[1],t[9*n+2]=e[2],t[9*n+3]=e[3],t[9*n+4]=e[4],t[9*n+5]=e[5],t[9*n+6]=e[6],t[9*n+7]=e[7],t[9*n+8]=e[8],t[9*n+9]=e[9]},MAT4:(e,t,n)=>{t[16*n+0]=e[0],t[16*n+1]=e[1],t[16*n+2]=e[2],t[16*n+3]=e[3],t[16*n+4]=e[4],t[16*n+5]=e[5],t[16*n+6]=e[6],t[16*n+7]=e[7],t[16*n+8]=e[8],t[16*n+9]=e[9],t[16*n+10]=e[10],t[16*n+11]=e[11],t[16*n+12]=e[12],t[16*n+13]=e[13],t[16*n+14]=e[14],t[16*n+15]=e[15]}};function QM(e,t,n,r){let{componentType:s}=e;z(e.componentType);let i=typeof s=="string"?Ot.fromName(s):s,o=ab[e.type],c=hb[e.type],a=lb[e.type];return n+=e.byteOffset,{values:Ot.createTypedArray(i,t,n,o*r),type:i,size:o,unpacker:c,packer:a}}var Re=e=>e!==void 0;function $M(e,t,n){if(!t)return null;let r=e.getExtension("3DTILES_batch_table_hierarchy"),s=t.HIERARCHY;return s&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=s,r=s),r?fb(r,n):null}function fb(e,t){let n,r,s,i=e.instancesLength,o=e.classes,c=e.classIds,a=e.parentCounts,h=e.parentIds,l=i;Re(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,s=getBinaryAccessor(c),c=s.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,i));let f;if(Re(a))for(Re(a.byteOffset)&&(a.componentType=defaultValue(a.componentType,GL.UNSIGNED_SHORT),a.type=AttributeType.SCALAR,s=getBinaryAccessor(a),a=s.createArrayBufferView(t.buffer,t.byteOffset+a.byteOffset,i)),f=new Uint16Array(i),l=0,n=0;n<i;++n)f[n]=l,l+=a[n];Re(h)&&Re(h.byteOffset)&&(h.componentType=defaultValue(h.componentType,GL.UNSIGNED_SHORT),h.type=AttributeType.SCALAR,s=getBinaryAccessor(h),h=s.createArrayBufferView(t.buffer,t.byteOffset+h.byteOffset,l));let p=o.length;for(n=0;n<p;++n){let m=o[n].length,M=o[n].instances,E=getBinaryProperties(m,M,t);o[n].instances=combine(E,M)}let u=new Array(p).fill(0),d=new Uint16Array(i);for(n=0;n<i;++n)r=c[n],d[n]=u[r],++u[r];let g={classes:o,classIds:c,classIndexes:d,parentCounts:a,parentIndexes:f,parentIds:h};return db(g),g}function Hr(e,t,n){if(!e)return;let r=e.parentCounts;return e.parentIds?n(e,t):r>0?pb(e,t,n):ub(e,t,n)}function pb(e,t,n){let r=e.classIds,s=e.parentCounts,i=e.parentIds,o=e.parentIndexes,c=r.length,a=scratchVisited;a.length=Math.max(a.length,c);let h=++marker,l=scratchStack;for(l.length=0,l.push(t);l.length>0;){if(t=l.pop(),a[t]===h)continue;a[t]=h;let f=n(e,t);if(Re(f))return f;let p=s[t],u=o[t];for(let d=0;d<p;++d){let g=i[u+d];g!==t&&l.push(g)}}return null}function ub(e,t,n){let r=!0;for(;r;){let s=n(e,t);if(Re(s))return s;let i=e.parentIds[t];r=i!==t,t=i}throw new Error("traverseHierarchySingleParent")}function db(e){let t=[],r=e.classIds.length;for(let s=0;s<r;++s)tA(e,s,stack)}function tA(e,t,n){let r=e.parentCounts,s=e.parentIds,i=e.parentIndexes,c=e.classIds.length;if(!Re(s))return;assert(t<c,`Parent index ${t} exceeds the total number of instances: ${c}`),assert(n.indexOf(t)===-1,"Circular dependency detected in the batch table hierarchy."),n.push(t);let a=Re(r)?r[t]:1,h=Re(r)?i[t]:t;for(let l=0;l<a;++l){let f=s[h+l];f!==t&&tA(e,f,n)}n.pop(t)}function kt(e){return e!=null}var Tc=(e,t)=>e,mb={HIERARCHY:!0,extensions:!0,extras:!0},Jn=class{json;binary;featureCount;_extensions;_properties;_binaryProperties;_hierarchy;constructor(t,n,r,s={}){z(r>=0),this.json=t||{},this.binary=n,this.featureCount=r,this._extensions=this.json?.extensions||{},this._properties={};for(let i in this.json)mb[i]||(this._properties[i]=this.json[i]);this._binaryProperties=this._initializeBinaryProperties(),s["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=$M(this,this.json,this.binary))}getExtension(t){return this.json&&this.json.extensions&&this.json.extensions[t]}memorySizeInBytes(){return 0}isClass(t,n){if(this._checkBatchId(t),z(typeof n=="string",n),this._hierarchy){let r=Hr(this._hierarchy,t,(s,i)=>{let o=s.classIds[i];return s.classes[o].name===n});return kt(r)}return!1}isExactClass(t,n){return z(typeof n=="string",n),this.getExactClassName(t)===n}getExactClassName(t){if(this._checkBatchId(t),this._hierarchy){let n=this._hierarchy.classIds[t];return this._hierarchy.classes[n].name}}hasProperty(t,n){return this._checkBatchId(t),z(typeof n=="string",n),kt(this._properties[n])||this._hasPropertyInHierarchy(t,n)}getPropertyNames(t,n){this._checkBatchId(t),n=kt(n)?n:[],n.length=0;let r=Object.keys(this._properties);return n.push(...r),this._hierarchy&&this._getPropertyNamesInHierarchy(t,n),n}getProperty(t,n){if(this._checkBatchId(t),z(typeof n=="string",n),this._binaryProperties){let s=this._binaryProperties[n];if(kt(s))return this._getBinaryProperty(s,t)}let r=this._properties[n];if(kt(r))return Tc(r[t],!0);if(this._hierarchy){let s=this._getHierarchyProperty(t,n);if(kt(s))return s}}setProperty(t,n,r){let s=this.featureCount;if(this._checkBatchId(t),z(typeof n=="string",n),this._binaryProperties){let o=this._binaryProperties[n];if(o){this._setBinaryProperty(o,t,r);return}}if(this._hierarchy&&this._setHierarchyProperty(this,t,n,r))return;let i=this._properties[n];kt(i)||(this._properties[n]=new Array(s),i=this._properties[n]),i[t]=Tc(r,!0)}_checkBatchId(t){if(!(t>=0&&t<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(t,n){return t.unpack(t.typedArray,n)}_setBinaryProperty(t,n,r){t.pack(r,t.typedArray,n)}_initializeBinaryProperties(){let t=null;for(let n in this._properties){let r=this._properties[n],s=this._initializeBinaryProperty(n,r);s&&(t=t||{},t[n]=s)}return t}_initializeBinaryProperty(t,n){if("byteOffset"in n){let r=n;z(this.binary,`Property ${t} requires a batch table binary.`),z(r.type,`Property ${t} requires a type.`);let s=QM(r,this.binary.buffer,this.binary.byteOffset|0,this.featureCount);return{typedArray:s.values,componentCount:s.size,unpack:s.unpacker,pack:s.packer}}return null}_hasPropertyInHierarchy(t,n){if(!this._hierarchy)return!1;let r=Hr(this._hierarchy,t,(s,i)=>{let o=s.classIds[i],c=s.classes[o].instances;return kt(c[n])});return kt(r)}_getPropertyNamesInHierarchy(t,n){Hr(this._hierarchy,t,(r,s)=>{let i=r.classIds[s],o=r.classes[i].instances;for(let c in o)o.hasOwnProperty(c)&&n.indexOf(c)===-1&&n.push(c)})}_getHierarchyProperty(t,n){return Hr(this._hierarchy,t,(r,s)=>{let i=r.classIds[s],o=r.classes[i],c=r.classIndexes[s],a=o.instances[n];return kt(a)?kt(a.typedArray)?this._getBinaryProperty(a,c):Tc(a[c],!0):null})}_setHierarchyProperty(t,n,r,s){let i=Hr(this._hierarchy,n,(o,c)=>{let a=o.classIds[c],h=o.classes[a],l=o.classIndexes[c],f=h.instances[r];return kt(f)?(z(c===n,`Inherited property "${r}" is read-only.`),kt(f.typedArray)?this._setBinaryProperty(f,l,s):f[l]=Tc(s,!0),!0):!1});return kt(i)}};function Tn(e,t,n=0){let r=new DataView(t);if(e.magic=r.getUint32(n,!0),n+=4,e.version=r.getUint32(n,!0),n+=4,e.byteLength=r.getUint32(n,!0),n+=4,e.version!==1)throw new Error(`3D Tile Version ${e.version} not supported`);return n}var Yr=4,eA="b3dm tile in legacy format.";function Wr(e,t,n){let r=new DataView(t),s;e.header=e.header||{};let i=r.getUint32(n,!0);n+=Yr;let o=r.getUint32(n,!0);n+=Yr;let c=r.getUint32(n,!0);n+=Yr;let a=r.getUint32(n,!0);return n+=Yr,c>=570425344?(n-=Yr*2,s=i,c=o,a=0,i=0,o=0,console.warn(eA)):a>=570425344&&(n-=Yr,s=c,c=i,a=o,i=0,o=0,console.warn(eA)),e.header.featureTableJsonByteLength=i,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=c,e.header.batchTableBinaryByteLength=a,e.header.batchLength=s,n}function Jr(e,t,n,r){return n=gb(e,t,n,r),n=xb(e,t,n,r),n}function gb(e,t,n,r){let{featureTableJsonByteLength:s,featureTableBinaryByteLength:i,batchLength:o}=e.header||{};if(e.featureTableJson={BATCH_LENGTH:o||0},s&&s>0){let c=rf(t,n,s);e.featureTableJson=JSON.parse(c)}return n+=s||0,e.featureTableBinary=new Uint8Array(t,n,i),n+=i||0,n}function xb(e,t,n,r){let{batchTableJsonByteLength:s,batchTableBinaryByteLength:i}=e.header||{};if(s&&s>0){let o=rf(t,n,s);e.batchTableJson=JSON.parse(o),n+=s,i&&i>0&&(e.batchTableBinary=new Uint8Array(t,n,i),e.batchTableBinary=new Uint8Array(e.batchTableBinary),n+=i)}return n}function Pf(e,t,n){if(!t&&(!e||!e.batchIds||!n))return null;let{batchIds:r,isRGB565:s,pointCount:i=0}=e;if(r&&n){let o=new Uint8ClampedArray(i*3);for(let c=0;c<i;c++){let a=r[c],l=n.getProperty(a,"dimensions").map(f=>f*255);o[c*3]=l[0],o[c*3+1]=l[1],o[c*3+2]=l[2]}return{type:v.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}if(t&&s){let o=new Uint8ClampedArray(i*3);for(let c=0;c<i;c++){let a=mf(t[c]);o[c*3]=a[0],o[c*3+1]=a[1],o[c*3+2]=a[2]}return{type:v.UNSIGNED_BYTE,value:o,size:3,normalized:!0}}return t&&t.length===i*3?{type:v.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:v.UNSIGNED_BYTE,value:t||new Uint8ClampedArray,size:4,normalized:!0}}var nA=new Z;function rA(e,t){if(!t)return null;if(e.isOctEncoded16P){let n=new Float32Array((e.pointsLength||0)*3);for(let r=0;r<(e.pointsLength||0);r++)gf(t[r*2],t[r*2+1],nA),nA.toArray(n,r*3);return{type:v.FLOAT,size:2,value:n}}return{type:v.FLOAT,size:2,value:t}}function sA(e,t,n){return e.isQuantized?n["3d-tiles"]&&n["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,Mb(e,t)):{type:v.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}function Mb(e,t){let n=new Z,r=new Float32Array(e.pointCount*3);for(let s=0;s<e.pointCount;s++)n.set(t[s*3],t[s*3+1],t[s*3+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(r,s*3);return r}async function iA(e,t,n,r,s){n=Tn(e,t,n),n=Wr(e,t,n),n=Jr(e,t,n,r),Ab(e);let{featureTable:i,batchTable:o}=yb(e);return await Bb(e,i,o,r,s),Eb(e,i,r),Tb(e,i,o),_b(e,i),n}function Ab(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}function yb(e){let t=new Ve(e.featureTableJson,e.featureTableBinary),n=t.getGlobalProperty("POINTS_LENGTH");if(!Number.isFinite(n))throw new Error("POINTS_LENGTH must be defined");t.featuresLength=n,e.featuresLength=n,e.pointsLength=n,e.pointCount=n,e.rtcCenter=t.getGlobalProperty("RTC_CENTER",v.FLOAT,3);let r=Sb(e,t);return{featureTable:t,batchTable:r}}function Eb(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.positions){if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",v.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){let r=t.getPropertyArray("POSITION_QUANTIZED",v.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=(1<<16)-1,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",v.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",v.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=sA(e,r,n)}}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}function Tb(e,t,n){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.colors){let r=null;t.hasProperty("RGBA")?(r=t.getPropertyArray("RGBA",v.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?r=t.getPropertyArray("RGB",v.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(r=t.getPropertyArray("RGB565",v.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Pf(e,r,n)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",v.UNSIGNED_BYTE,4))}function _b(e,t){if(e.attributes=e.attributes||{positions:null,colors:null,normals:null,batchIds:null},!e.attributes.normals){let n=null;t.hasProperty("NORMAL")?n=t.getPropertyArray("NORMAL",v.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(n=t.getPropertyArray("NORMAL_OCT16P",v.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=rA(e,n)}}function Sb(e,t){let n=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",v.UNSIGNED_SHORT,1),e.batchIds)){let r=t.getGlobalProperty("BATCH_LENGTH");if(!r)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");let{batchTableJson:s,batchTableBinary:i}=e;n=new Jn(s,i,r)}return n}async function Bb(e,t,n,r,s){let i,o,c,a=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];a&&(c=a.properties);let h=t.getExtension("3DTILES_draco_point_compression");if(h){o=h.properties;let f=h.byteOffset,p=h.byteLength;if(!o||!Number.isFinite(f)||!p)throw new Error("Draco properties, byteOffset, and byteLength must be defined");i=(e.featureTableBinary||[]).slice(f,f+p),e.hasPositions=Number.isFinite(o.POSITION),e.hasColors=Number.isFinite(o.RGB)||Number.isFinite(o.RGBA),e.hasNormals=Number.isFinite(o.NORMAL),e.hasBatchIds=Number.isFinite(o.BATCH_ID),e.isTranslucent=Number.isFinite(o.RGBA)}if(!i)return!0;let l={buffer:i,properties:{...o,...c},featureTableProperties:o,batchTableProperties:c,dequantizeInShader:!1};return await Cb(e,l,r,s)}async function Cb(e,t,n,r){if(!r)return;let s={...n,draco:{...n?.draco,extraAttributes:t.batchTableProperties||{}}};delete s["3d-tiles"];let i=await qt(t.buffer,ac,s,r),o=i.attributes.POSITION&&i.attributes.POSITION.value,c=i.attributes.COLOR_0&&i.attributes.COLOR_0.value,a=i.attributes.NORMAL&&i.attributes.NORMAL.value,h=i.attributes.BATCH_ID&&i.attributes.BATCH_ID.value,l=o&&i.attributes.POSITION.value.quantization,f=a&&i.attributes.NORMAL.value.quantization;if(l){let u=i.POSITION.data.quantization,d=u.range;e.quantizedVolumeScale=new Z(d,d,d),e.quantizedVolumeOffset=new Z(u.minValues),e.quantizedRange=(1<<u.quantizationBits)-1,e.isQuantizedDraco=!0}f&&(e.octEncodedRange=(1<<i.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);let p={};if(t.batchTableProperties)for(let u of Object.keys(t.batchTableProperties))i.attributes[u]&&i.attributes[u].value&&(p[u.toLowerCase()]=i.attributes[u].value);e.attributes={positions:o,colors:Pf(e,c,void 0),normals:a,batchIds:h,...p}}var Nf={};At(Nf,{decode:()=>Ub,name:()=>Db});function Et(e,t){if(!e)throw new Error(t||"assert failed: gltf")}var _c={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Sc={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};var Lb=1.33,oA=["SCALAR","VEC2","VEC3","VEC4"],Rb=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],wb=new Map(Rb),Ib={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},bb={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Ob={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bc(e){return oA[e-1]||oA[0]}function Xr(e){let t=wb.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function jr(e,t){let n=Ob[e.componentType],r=Ib[e.type],s=bb[e.componentType],i=e.count*r,o=e.count*r*s;Et(o>=0&&o<=t.byteLength);let c=Sc[e.componentType],a=_c[e.type];return{ArrayType:n,length:i,byteLength:o,componentByteSize:c,numberOfComponentsInElement:a}}function ai(e){let{images:t,bufferViews:n}=e;t=t||[],n=n||[];let r=t.map(o=>o.bufferView);n=n.filter(o=>!r.includes(o));let s=n.reduce((o,c)=>o+c.byteLength,0),i=t.reduce((o,c)=>{let{width:a,height:h}=c.image;return o+a*h},0);return s+Math.ceil(4*i*Lb)}function cA(e,t,n){let r=e.bufferViews[n];Et(r);let s=r.buffer,i=t[s];Et(i);let o=(r.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,o,r.byteLength)}function aA(e,t,n){let r=typeof n=="number"?e.accessors?.[n]:n;if(!r)throw new Error(`No gltf accessor ${JSON.stringify(n)}`);let s=e.bufferViews?.[r.bufferView||0];if(!s)throw new Error(`No gltf buffer view for accessor ${s}`);let{arrayBuffer:i,byteOffset:o}=t[s.buffer],c=(o||0)+(r.byteOffset||0)+(s.byteOffset||0),{ArrayType:a,length:h,componentByteSize:l,numberOfComponentsInElement:f}=jr(r,s),p=l*f,u=s.byteStride||p;if(typeof s.byteStride>"u"||s.byteStride===p)return new a(i,c,h);let d=new a(h);for(let g=0;g<r.count;g++){let m=new a(i,c+g*u,f);d.set(m,g*f)}return d}function Pb(){return{asset:{version:"2.0",generator:"loaders.gl"},buffers:[],extensions:{},extensionsRequired:[],extensionsUsed:[]}}var K=class{gltf;sourceBuffers;byteLength;constructor(t){this.gltf={json:t?.json||Pb(),buffers:t?.buffers||[],images:t?.images||[]},this.sourceBuffers=[],this.byteLength=0,this.gltf.buffers&&this.gltf.buffers[0]&&(this.byteLength=this.gltf.buffers[0].byteLength,this.sourceBuffers=[this.gltf.buffers[0]])}get json(){return this.gltf.json}getApplicationData(t){return this.json[t]}getExtraData(t){return(this.json.extras||{})[t]}hasExtension(t){let n=this.getUsedExtensions().find(s=>s===t),r=this.getRequiredExtensions().find(s=>s===t);return typeof n=="string"||typeof r=="string"}getExtension(t){let n=this.getUsedExtensions().find(s=>s===t),r=this.json.extensions||{};return n?r[t]:null}getRequiredExtension(t){return this.getRequiredExtensions().find(r=>r===t)?this.getExtension(t):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(t,n){return(t.extensions||{})[n]}getScene(t){return this.getObject("scenes",t)}getNode(t){return this.getObject("nodes",t)}getSkin(t){return this.getObject("skins",t)}getMesh(t){return this.getObject("meshes",t)}getMaterial(t){return this.getObject("materials",t)}getAccessor(t){return this.getObject("accessors",t)}getTexture(t){return this.getObject("textures",t)}getSampler(t){return this.getObject("samplers",t)}getImage(t){return this.getObject("images",t)}getBufferView(t){return this.getObject("bufferViews",t)}getBuffer(t){return this.getObject("buffers",t)}getObject(t,n){if(typeof n=="object")return n;let r=this.json[t]&&this.json[t][n];if(!r)throw new Error(`glTF file error: Could not find ${t}[${n}]`);return r}getTypedArrayForBufferView(t){t=this.getBufferView(t);let n=t.buffer,r=this.gltf.buffers[n];Et(r);let s=(t.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,t.byteLength)}getTypedArrayForAccessor(t){let n=this.getAccessor(t);return aA(this.gltf.json,this.gltf.buffers,n)}getTypedArrayForImageData(t){t=this.getAccessor(t);let n=this.getBufferView(t.bufferView),s=this.getBuffer(n.buffer).data,i=n.byteOffset||0;return new Uint8Array(s,i,n.byteLength)}addApplicationData(t,n){return this.json[t]=n,this}addExtraData(t,n){return this.json.extras=this.json.extras||{},this.json.extras[t]=n,this}addObjectExtension(t,n,r){return t.extensions=t.extensions||{},t.extensions[n]=r,this.registerUsedExtension(n),this}setObjectExtension(t,n,r){let s=t.extensions||{};s[n]=r}removeObjectExtension(t,n){let r=t?.extensions||{};if(r[n]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let s=this.json.extensionsRemoved;s.includes(n)||s.push(n)}delete r[n]}addExtension(t,n={}){return Et(n),this.json.extensions=this.json.extensions||{},this.json.extensions[t]=n,this.registerUsedExtension(t),n}addRequiredExtension(t,n={}){return Et(n),this.addExtension(t,n),this.registerRequiredExtension(t),n}registerUsedExtension(t){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(n=>n===t)||this.json.extensionsUsed.push(t)}registerRequiredExtension(t){this.registerUsedExtension(t),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(n=>n===t)||this.json.extensionsRequired.push(t)}removeExtension(t){if(this.json.extensions?.[t]){this.json.extensionsRemoved=this.json.extensionsRemoved||[];let n=this.json.extensionsRemoved;n.includes(t)||n.push(t)}this.json.extensions&&delete this.json.extensions[t],this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,t),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,t)}setDefaultScene(t){this.json.scene=t}addScene(t){let{nodeIndices:n}=t;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:n}),this.json.scenes.length-1}addNode(t){let{meshIndex:n,matrix:r}=t;this.json.nodes=this.json.nodes||[];let s={mesh:n};return r&&(s.matrix=r),this.json.nodes.push(s),this.json.nodes.length-1}addMesh(t){let{attributes:n,indices:r,material:s,mode:i=4}=t,c={primitives:[{attributes:this._addAttributes(n),mode:i}]};if(r){let a=this._addIndices(r);c.primitives[0].indices=a}return Number.isFinite(s)&&(c.primitives[0].material=s),this.json.meshes=this.json.meshes||[],this.json.meshes.push(c),this.json.meshes.length-1}addPointCloud(t){let r={primitives:[{attributes:this._addAttributes(t),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addImage(t,n){let r=On(t),s=n||r?.mimeType,o={bufferView:this.addBufferView(t),mimeType:s};return this.json.images=this.json.images||[],this.json.images.push(o),this.json.images.length-1}addBufferView(t,n=0,r=this.byteLength){let s=t.byteLength;Et(Number.isFinite(s)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(t);let i={buffer:n,byteOffset:r,byteLength:s};return this.byteLength+=Xe(s,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(i),this.json.bufferViews.length-1}addAccessor(t,n){let r={bufferView:t,type:Bc(n.size),componentType:n.componentType,count:n.count,max:n.max,min:n.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(t,n={size:3}){let r=this.addBufferView(t),s={min:n.min,max:n.max};(!s.min||!s.max)&&(s=this._getAccessorMinMax(t,n.size));let i={size:n.size,componentType:Xr(t),count:Math.round(t.length/n.size),min:s.min,max:s.max};return this.addAccessor(r,Object.assign(i,n))}addTexture(t){let{imageIndex:n}=t,r={source:n};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(t){return this.json.materials=this.json.materials||[],this.json.materials.push(t),this.json.materials.length-1}createBinaryChunk(){this.gltf.buffers=[];let t=this.byteLength,n=new ArrayBuffer(t),r=new Uint8Array(n),s=0;for(let i of this.sourceBuffers||[])s=Pa(i,r,s);this.json?.buffers?.[0]?this.json.buffers[0].byteLength=t:this.json.buffers=[{byteLength:t}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(t,n){let r=!0;for(;r;){let s=t.indexOf(n);s>-1?t.splice(s,1):r=!1}}_addAttributes(t={}){let n={};for(let r in t){let s=t[r],i=this._getGltfAttributeName(r),o=this.addBinaryBuffer(s.value,s);n[i]=o}return n}_addIndices(t){return this.addBinaryBuffer(t,{size:1})}_getGltfAttributeName(t){switch(t.toLowerCase()){case"position":case"positions":case"vertices":return"POSITION";case"normal":case"normals":return"NORMAL";case"color":case"colors":return"COLOR_0";case"texcoord":case"texcoords":return"TEXCOORD_0";default:return t}}_getAccessorMinMax(t,n){let r={min:null,max:null};if(t.length<n)return r;r.min=[],r.max=[];let s=t.subarray(0,n);for(let i of s)r.min.push(i),r.max.push(i);for(let i=n;i<t.length;i+=n)for(let o=0;o<n;o++)r.min[0+o]=Math.min(r.min[0+o],t[i+o]),r.max[0+o]=Math.max(r.max[0+o],t[i+o]);return r}};function hA(e){return(e%1+1)%1}var lA={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16,BOOLEAN:1,STRING:1,ENUM:1},Nb={INT8:Int8Array,UINT8:Uint8Array,INT16:Int16Array,UINT16:Uint16Array,INT32:Int32Array,UINT32:Uint32Array,INT64:BigInt64Array,UINT64:BigUint64Array,FLOAT32:Float32Array,FLOAT64:Float64Array},fA={INT8:1,UINT8:1,INT16:2,UINT16:2,INT32:4,UINT32:4,INT64:8,UINT64:8,FLOAT32:4,FLOAT64:8};function hi(e,t){return fA[t]*lA[e]}function Kr(e,t,n,r){if(n!=="UINT8"&&n!=="UINT16"&&n!=="UINT32"&&n!=="UINT64")return null;let s=e.getTypedArrayForBufferView(t),i=Zr(s,"SCALAR",n,r+1);return i instanceof BigInt64Array||i instanceof BigUint64Array?null:i}function Zr(e,t,n,r=1){let s=lA[t],i=Nb[n],o=fA[n],c=r*s,a=c*o,h=e.buffer,l=e.byteOffset;return l%o!==0&&(h=new Uint8Array(h).slice(l,l+a).buffer,l=0),new i(h,l,c)}function Qr(e,t,n){let r=`TEXCOORD_${t.texCoord||0}`,s=n.attributes[r],i=e.getTypedArrayForAccessor(s),o=e.gltf.json,c=t.index,a=o.textures?.[c]?.source;if(typeof a<"u"){let h=o.images?.[a]?.mimeType,l=e.gltf.images?.[a];if(l&&typeof l.width<"u"){let f=[];for(let p=0;p<i.length;p+=2){let u=Fb(l,h,i,p,t.channels);f.push(u)}return f}}return[]}function Cc(e,t,n,r,s){if(!n?.length)return;let i=[];for(let l of n){let f=r.findIndex(p=>p===l);f===-1&&(f=r.push(l)-1),i.push(f)}let o=new Uint32Array(i),c=e.gltf.buffers.push({arrayBuffer:o.buffer,byteOffset:o.byteOffset,byteLength:o.byteLength})-1,a=e.addBufferView(o,c,0),h=e.addAccessor(a,{size:1,componentType:Xr(o),count:o.length});s.attributes[t]=h}function Fb(e,t,n,r,s=[0]){let i={r:{offset:0,shift:0},g:{offset:1,shift:8},b:{offset:2,shift:16},a:{offset:3,shift:24}},o=n[r],c=n[r+1],a=1;t&&(t.indexOf("image/jpeg")!==-1||t.indexOf("image/png")!==-1)&&(a=4);let h=vb(o,c,e,a),l=0;for(let f of s){let p=typeof f=="number"?Object.values(i)[f]:i[f],u=h+p.offset,d=Ss(e);if(d.data.length<=u)throw new Error(`${d.data.length} <= ${u}`);let g=d.data[u];l|=g<<p.shift}return l}function vb(e,t,n,r=1){let s=n.width,i=hA(e)*(s-1),o=Math.round(i),c=n.height,a=hA(t)*(c-1),h=Math.round(a),l=n.components?n.components:r;return(h*s+o)*l}function Lc(e,t,n,r,s){let i=[];for(let o=0;o<t;o++){let c=n[o],a=n[o+1]-n[o];if(a+c>r)break;let h=c/s,l=a/s;i.push(e.slice(h,h+l))}return i}function Rc(e,t,n){let r=[];for(let s=0;s<t;s++){let i=s*n;r.push(e.slice(i,i+n))}return r}function wc(e,t,n,r){if(n)throw new Error("Not implemented - arrayOffsets for strings is specified");if(r){let s=[],i=new TextDecoder("utf8"),o=0;for(let c=0;c<e;c++){let a=r[c+1]-r[c];if(a+o<=t.length){let h=t.subarray(o,a+o),l=i.decode(h);s.push(l),o+=a}}return s}return[]}var pA="EXT_mesh_features",Db=pA;async function Ub(e,t){let n=new K(e);Gb(n,t)}function Gb(e,t){let n=e.gltf.json;if(n.meshes)for(let r of n.meshes)for(let s of r.primitives)zb(e,s,t)}function zb(e,t,n){if(!n?.gltf?.loadBuffers)return;let s=t.extensions?.[pA]?.featureIds;if(s)for(let i of s){let o;if(typeof i.attribute<"u"){let c=`_FEATURE_ID_${i.attribute}`,a=t.attributes[c];o=e.getTypedArrayForAccessor(a)}else typeof i.texture<"u"&&n?.gltf?.loadImages?o=Qr(e,i.texture,t):o=[];i.data=o}}var Df={};At(Df,{decode:()=>Vb,name:()=>kb});var Ff="EXT_structural_metadata",kb=Ff;async function Vb(e,t){let n=new K(e);qb(n,t)}function qb(e,t){if(!t.gltf?.loadBuffers)return;let n=e.getExtension(Ff);n&&(t.gltf?.loadImages&&Hb(e,n),Yb(e,n))}function Hb(e,t){let n=t.propertyTextures,r=e.gltf.json;if(n&&r.meshes)for(let s of r.meshes)for(let i of s.primitives)Jb(e,n,i,t)}function Yb(e,t){let n=t.schema;if(!n)return;let r=n.classes,s=t.propertyTables;if(r&&s)for(let i in r){let o=Wb(s,i);o&&jb(e,n,o)}}function Wb(e,t){for(let n of e)if(n.class===t)return n;return null}function Jb(e,t,n,r){if(!t)return;let i=n.extensions?.[Ff]?.propertyTextures;if(i)for(let o of i){let c=t[o];Xb(e,c,n,r)}}function Xb(e,t,n,r){if(!t.properties)return;r.dataAttributeNames||(r.dataAttributeNames=[]);let s=t.class;for(let i in t.properties){let o=`${s}_${i}`,c=t.properties?.[i];if(!c)continue;c.data||(c.data=[]);let a=c.data,h=Qr(e,c,n);h!==null&&(Cc(e,o,h,a,n),c.data=a,r.dataAttributeNames.push(o))}}function jb(e,t,n){let r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);let s=n.count;for(let i in r.properties){let o=r.properties[i],c=n.properties?.[i];if(c){let a=Kb(e,t,o,s,c);c.data=a}}}function Kb(e,t,n,r,s){let i=[],o=s.values,c=e.getTypedArrayForBufferView(o),a=Zb(e,n,s,r),h=Qb(e,s,r);switch(n.type){case"SCALAR":case"VEC2":case"VEC3":case"VEC4":case"MAT2":case"MAT3":case"MAT4":{i=$b(n,r,c,a);break}case"BOOLEAN":throw new Error(`Not implemented - classProperty.type=${n.type}`);case"STRING":{i=wc(r,c,a,h);break}case"ENUM":{i=tO(t,n,r,c,a);break}default:throw new Error(`Unknown classProperty type ${n.type}`)}return i}function Zb(e,t,n,r){return t.array&&typeof t.count>"u"&&typeof n.arrayOffsets<"u"?Kr(e,n.arrayOffsets,n.arrayOffsetType||"UINT32",r):null}function Qb(e,t,n){return typeof t.stringOffsets<"u"?Kr(e,t.stringOffsets,t.stringOffsetType||"UINT32",n):null}function $b(e,t,n,r){let s=e.array,i=e.count,o=hi(e.type,e.componentType),c=n.byteLength/o,a;return e.componentType?a=Zr(n,e.type,e.componentType,c):a=n,s?r?Lc(a,t,r,n.length,o):i?Rc(a,t,i):[]:a}function tO(e,t,n,r,s){let i=t.enumType;if(!i)throw new Error("Incorrect data in the EXT_structural_metadata extension: classProperty.enumType is not set for type ENUM");let o=e.enums?.[i];if(!o)throw new Error(`Incorrect data in the EXT_structural_metadata extension: schema.enums does't contain ${i}`);let c=o.valueType||"UINT16",a=hi(t.type,c),h=r.byteLength/a,l=Zr(r,t.type,c,h);if(l||(l=r),t.array){if(s)return eO({valuesData:l,numberOfElements:n,arrayOffsets:s,valuesDataBytesLength:r.length,elementSize:a,enumEntry:o});let f=t.count;return f?nO(l,n,f,o):[]}return vf(l,0,n,o)}function eO(e){let{valuesData:t,numberOfElements:n,arrayOffsets:r,valuesDataBytesLength:s,elementSize:i,enumEntry:o}=e,c=[];for(let a=0;a<n;a++){let h=r[a],l=r[a+1]-r[a];if(l+h>s)break;let f=h/i,p=l/i,u=vf(t,f,p,o);c.push(u)}return c}function nO(e,t,n,r){let s=[];for(let i=0;i<t;i++){let o=n*i,c=vf(e,o,n,r);s.push(c)}return s}function vf(e,t,n,r){let s=[];for(let i=0;i<n;i++)if(e instanceof BigInt64Array||e instanceof BigUint64Array)s.push("");else{let o=e[t+i],c=rO(r,o);c?s.push(c.name):s.push("")}return s}function rO(e,t){for(let n of e.values)if(n.value===t)return n;return null}var Uf={};At(Uf,{decode:()=>iO,name:()=>sO});var uA="EXT_feature_metadata",sO=uA;async function iO(e,t){let n=new K(e);oO(n,t)}function oO(e,t){if(!t.gltf?.loadBuffers)return;let n=e.getExtension(uA);n&&(t.gltf?.loadImages&&cO(e,n),aO(e,n))}function cO(e,t){let n=t.schema;if(!n)return;let r=n.classes,{featureTextures:s}=t;if(r&&s)for(let i in r){let o=r[i],c=lO(s,i);c&&pO(e,c,o)}}function aO(e,t){let n=t.schema;if(!n)return;let r=n.classes,s=t.featureTables;if(r&&s)for(let i in r){let o=hO(s,i);o&&fO(e,n,o)}}function hO(e,t){for(let n in e){let r=e[n];if(r.class===t)return r}return null}function lO(e,t){for(let n in e){let r=e[n];if(r.class===t)return r}return null}function fO(e,t,n){if(!n.class)return;let r=t.classes?.[n.class];if(!r)throw new Error(`Incorrect data in the EXT_structural_metadata extension: no schema class with name ${n.class}`);let s=n.count;for(let i in r.properties){let o=r.properties[i],c=n.properties?.[i];if(c){let a=uO(e,t,o,s,c);c.data=a}}}function pO(e,t,n){let r=t.class;for(let s in n.properties){let i=t?.properties?.[s];if(i){let o=MO(e,i,r);i.data=o}}}function uO(e,t,n,r,s){let i=[],o=s.bufferView,c=e.getTypedArrayForBufferView(o),a=dO(e,n,s,r),h=mO(e,n,s,r);return n.type==="STRING"||n.componentType==="STRING"?i=wc(r,c,a,h):gO(n)&&(i=xO(n,r,c,a)),i}function dO(e,t,n,r){return t.type==="ARRAY"&&typeof t.componentCount>"u"&&typeof n.arrayOffsetBufferView<"u"?Kr(e,n.arrayOffsetBufferView,n.offsetType||"UINT32",r):null}function mO(e,t,n,r){return typeof n.stringOffsetBufferView<"u"?Kr(e,n.stringOffsetBufferView,n.offsetType||"UINT32",r):null}function gO(e){let t=["UINT8","INT16","UINT16","INT32","UINT32","INT64","UINT64","FLOAT32","FLOAT64"];return t.includes(e.type)||typeof e.componentType<"u"&&t.includes(e.componentType)}function xO(e,t,n,r){let s=e.type==="ARRAY",i=e.componentCount,o="SCALAR",c=e.componentType||e.type,a=hi(o,c),h=n.byteLength/a,l=Zr(n,o,c,h);return s?r?Lc(l,t,r,n.length,a):i?Rc(l,t,i):[]:l}function MO(e,t,n){let r=e.gltf.json;if(!r.meshes)return[];let s=[];for(let i of r.meshes)for(let o of i.primitives)AO(e,n,t,s,o);return s}function AO(e,t,n,r,s){let i={channels:n.channels,...n.texture},o=Qr(e,i,s);o&&Cc(e,t,o,r,s)}var dA="4.2.1";var $r=!0,mA=1735152710,kf=12,Ic=8,yO=1313821514,EO=5130562,TO=0,_O=0,SO=1;function BO(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}function gA(e,t=0,n={}){let r=new DataView(e),{magic:s=mA}=n,i=r.getUint32(t,!1);return i===s||i===mA}function xA(e,t,n=0,r={}){let s=new DataView(t),i=BO(s,n+0),o=s.getUint32(n+4,$r),c=s.getUint32(n+8,$r);switch(Object.assign(e,{header:{byteOffset:n,byteLength:c,hasBinChunk:!1},type:i,version:o,json:{},binChunks:[]}),n+=kf,e.version){case 1:return CO(e,s,n);case 2:return LO(e,s,n,r={});default:throw new Error(`Invalid GLB version ${e.version}. Only supports version 1 and 2.`)}}function CO(e,t,n){z(e.header.byteLength>kf+Ic);let r=t.getUint32(n+0,$r),s=t.getUint32(n+4,$r);return n+=Ic,z(s===TO),Gf(e,t,n,r),n+=r,n+=zf(e,t,n,e.header.byteLength),n}function LO(e,t,n,r){return z(e.header.byteLength>kf+Ic),RO(e,t,n,r),n+e.header.byteLength}function RO(e,t,n,r){for(;n+8<=e.header.byteLength;){let s=t.getUint32(n+0,$r),i=t.getUint32(n+4,$r);switch(n+=Ic,i){case yO:Gf(e,t,n,s);break;case EO:zf(e,t,n,s);break;case _O:r.strict||Gf(e,t,n,s);break;case SO:r.strict||zf(e,t,n,s);break;default:break}n+=Xe(s,4)}return n}function Gf(e,t,n,r){let s=new Uint8Array(t.buffer,n,r),o=new TextDecoder("utf8").decode(s);return e.json=JSON.parse(o),Xe(r,4)}function zf(e,t,n,r){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer}),Xe(r,4)}function Vf(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;let r=t.baseUri||t.uri;if(!r)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return r.substr(0,r.lastIndexOf("/")+1)+e}var Hf={};At(Hf,{decode:()=>zO,name:()=>GO});var wO="B9h9z9tFBBBF8fL9gBB9gLaaaaaFa9gEaaaB9gFaFa9gEaaaFaEMcBFFFGGGEIIILF9wFFFLEFBFKNFaFCx/IFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBF8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBGy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBEn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBIi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBKI9z9iqlBOc+x8ycGBM/qQFTa8jUUUUBCU/EBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAGTkUUUBRNCUoBAG9uC/wgBZHKCUGAKCUG9JyRVAECFJRICBRcGXEXAcAF9PQFAVAFAclAcAVJAF9JyRMGXGXAG9FQBAMCbJHKC9wZRSAKCIrCEJCGrRQANCUGJRfCBRbAIRTEXGXAOATlAQ9PQBCBRISEMATAQJRIGXAS9FQBCBRtCBREEXGXAOAIlCi9PQBCBRISLMANCU/CBJAEJRKGXGXGXGXGXATAECKrJ2BBAtCKZrCEZfIBFGEBMAKhB83EBAKCNJhB83EBSEMAKAI2BIAI2BBHmCKrHYAYCE6HYy86BBAKCFJAICIJAYJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCGJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCEJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCIJAYAmJHY2BBAI2BFHmCKrHPAPCE6HPy86BBAKCLJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCKJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCOJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCNJAYAmJHY2BBAI2BGHmCKrHPAPCE6HPy86BBAKCVJAYAPJHY2BBAmCIrCEZHPAPCE6HPy86BBAKCcJAYAPJHY2BBAmCGrCEZHPAPCE6HPy86BBAKCMJAYAPJHY2BBAmCEZHmAmCE6Hmy86BBAKCSJAYAmJHm2BBAI2BEHICKrHYAYCE6HYy86BBAKCQJAmAYJHm2BBAICIrCEZHYAYCE6HYy86BBAKCfJAmAYJHm2BBAICGrCEZHYAYCE6HYy86BBAKCbJAmAYJHK2BBAICEZHIAICE6HIy86BBAKAIJRISGMAKAI2BNAI2BBHmCIrHYAYCb6HYy86BBAKCFJAICNJAYJHY2BBAmCbZHmAmCb6Hmy86BBAKCGJAYAmJHm2BBAI2BFHYCIrHPAPCb6HPy86BBAKCEJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCIJAmAYJHm2BBAI2BGHYCIrHPAPCb6HPy86BBAKCLJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCKJAmAYJHm2BBAI2BEHYCIrHPAPCb6HPy86BBAKCOJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCNJAmAYJHm2BBAI2BIHYCIrHPAPCb6HPy86BBAKCVJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCcJAmAYJHm2BBAI2BLHYCIrHPAPCb6HPy86BBAKCMJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCSJAmAYJHm2BBAI2BKHYCIrHPAPCb6HPy86BBAKCQJAmAPJHm2BBAYCbZHYAYCb6HYy86BBAKCfJAmAYJHm2BBAI2BOHICIrHYAYCb6HYy86BBAKCbJAmAYJHK2BBAICbZHIAICb6HIy86BBAKAIJRISFMAKAI8pBB83BBAKCNJAICNJ8pBB83BBAICTJRIMAtCGJRtAECTJHEAS9JQBMMGXAIQBCBRISEMGXAM9FQBANAbJ2BBRtCBRKAfREEXAEANCU/CBJAKJ2BBHTCFrCBATCFZl9zAtJHt86BBAEAGJREAKCFJHKAM9HQBMMAfCFJRfAIRTAbCFJHbAG9HQBMMABAcAG9sJANCUGJAMAG9sTkUUUBpANANCUGJAMCaJAG9sJAGTkUUUBpMAMCBAIyAcJRcAIQBMC9+RKSFMCBC99AOAIlAGCAAGCA9Ly6yRKMALCU/EBJ8kUUUUBAKM+OmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUFT+JUUUBpALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM+lLKFaF99GaG99FaG99GXGXAGCI9HQBAF9FQFEXGXGX9DBBB8/9DBBB+/ABCGJHG1BB+yAB1BBHE+yHI+L+TABCFJHL1BBHK+yHO+L+THN9DBBBB9gHVyAN9DBB/+hANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE86BBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG86BBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG86BBABCIJRBAFCaJHFQBSGMMAF9FQBEXGXGX9DBBB8/9DBBB+/ABCIJHG8uFB+yAB8uFBHE+yHI+L+TABCGJHL8uFBHK+yHO+L+THN9DBBBB9gHVyAN9DB/+g6ANAN+U9DBBBBANAVyHcAc+MHMAECa3yAI+SHIAI+UAcAMAKCa3yAO+SHcAc+U+S+S+R+VHO+U+SHN+L9DBBB9P9d9FQBAN+oRESFMCUUUU94REMAGAE87FBGXGX9DBBB8/9DBBB+/Ac9DBBBB9gyAcAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMALAG87FBGXGX9DBBB8/9DBBB+/AI9DBBBB9gyAIAO+U+SHN+L9DBBB9P9d9FQBAN+oRGSFMCUUUU94RGMABAG87FBABCNJRBAFCaJHFQBMMM/SEIEaE99EaF99GXAF9FQBCBREABRIEXGXGX9D/zI818/AICKJ8uFBHLCEq+y+VHKAI8uFB+y+UHO9DB/+g6+U9DBBB8/9DBBB+/AO9DBBBB9gy+SHN+L9DBBB9P9d9FQBAN+oRVSFMCUUUU94RVMAICIJ8uFBRcAICGJ8uFBRMABALCFJCEZAEqCFWJAV87FBGXGXAKAM+y+UHN9DB/+g6+U9DBBB8/9DBBB+/AN9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRMSFMCUUUU94RMMABALCGJCEZAEqCFWJAM87FBGXGXAKAc+y+UHK9DB/+g6+U9DBBB8/9DBBB+/AK9DBBBB9gy+SHS+L9DBBB9P9d9FQBAS+oRcSFMCUUUU94RcMABALCaJCEZAEqCFWJAc87FBGXGX9DBBU8/AOAO+U+TANAN+U+TAKAK+U+THO9DBBBBAO9DBBBB9gy+R9DB/+g6+U9DBBB8/+SHO+L9DBBB9P9d9FQBAO+oRcSFMCUUUU94RcMABALCEZAEqCFWJAc87FBAICNJRIAECIJREAFCaJHFQBMMM9JBGXAGCGrAF9sHF9FQBEXABAB8oGBHGCNWCN91+yAGCi91CnWCUUU/8EJ+++U84GBABCIJRBAFCaJHFQBMMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEM/lFFFaGXGXAFABqCEZ9FQBABRESFMGXGXAGCT9PQBABRESFMABREEXAEAF8oGBjGBAECIJAFCIJ8oGBjGBAECNJAFCNJ8oGBjGBAECSJAFCSJ8oGBjGBAECTJREAFCTJRFAGC9wJHGCb9LQBMMAGCI9JQBEXAEAF8oGBjGBAFCIJRFAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF2BB86BBAECFJREAFCFJRFAGCaJHGQBMMABMoFFGaGXGXABCEZ9FQBABRESFMAFCgFZC+BwsN9sRIGXGXAGCT9PQBABRESFMABREEXAEAIjGBAECSJAIjGBAECNJAIjGBAECIJAIjGBAECTJREAGC9wJHGCb9LQBMMAGCI9JQBEXAEAIjGBAECIJREAGC98JHGCE9LQBMMGXAG9FQBEXAEAF86BBAECFJREAGCaJHGQBMMABMMMFBCUNMIT9kBB",IO="B9h9z9tFBBBF8dL9gBB9gLaaaaaFa9gEaaaB9gGaaB9gFaFaEQSBBFBFFGEGEGIILF9wFFFLEFBFKNFaFCx/aFMO/LFVK9tv9t9vq95GBt9f9f939h9z9t9f9j9h9s9s9f9jW9vq9zBBp9tv9z9o9v9wW9f9kv9j9v9kv9WvqWv94h919m9mvqBG8Z9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv94h919m9mvqBIy9tv9z9o9v9wW9f9kv9j9v9kv9J9u9kv949TvZ91v9u9jvBLn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9P9jWBKi9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9R919hWBNn9tv9z9o9v9wW9f9kv9j9v9kv69p9sWvq9F949wBcI9z9iqlBMc/j9JSIBTEM9+FLa8jUUUUBCTlRBCBRFEXCBRGCBREEXABCNJAGJAECUaAFAGrCFZHIy86BBAEAIJREAGCFJHGCN9HQBMAFCx+YUUBJAE86BBAFCEWCxkUUBJAB8pEN83EBAFCFJHFCUG9HQBMMkRIbaG97FaK978jUUUUBCU/KBlHL8kUUUUBC9+RKGXAGCFJAI9LQBCaRKAE2BBC+gF9HQBALAEAIJHOAGlAG/8cBBCUoBAG9uC/wgBZHKCUGAKCUG9JyRNAECFJRKCBRVGXEXAVAF9PQFANAFAVlAVANJAF9JyRcGXGXAG9FQBAcCbJHIC9wZHMCE9sRSAMCFWRQAICIrCEJCGrRfCBRbEXAKRTCBRtGXEXGXAOATlAf9PQBCBRKSLMALCU/CBJAtAM9sJRmATAfJRKCBREGXAMCoB9JQBAOAKlC/gB9JQBCBRIEXAmAIJREGXGXGXGXGXATAICKrJ2BBHYCEZfIBFGEBMAECBDtDMIBSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIBAKCTJRKMGXGXGXGXGXAYCGrCEZfIBFGEBMAECBDtDMITSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMITAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMITAKCTJRKMGXGXGXGXGXAYCIrCEZfIBFGEBMAECBDtDMIASEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIAAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAEAKDBBBDMIAAKCTJRKMGXGXGXGXGXAYCKrfIBFGEBMAECBDtDMI8wSEMAEAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCIJAnDeBJAYCx+YUUBJ2BBJRKSGMAEAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBAYCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HYCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMI8wAKCNJAnDeBJAYCx+YUUBJ2BBJRKSFMAEAKDBBBDMI8wAKCTJRKMAICoBJREAICUFJAM9LQFAERIAOAKlC/fB9LQBMMGXAEAM9PQBAECErRIEXGXAOAKlCi9PQBCBRKSOMAmAEJRYGXGXGXGXGXATAECKrJ2BBAICKZrCEZfIBFGEBMAYCBDtDMIBSEMAYAKDBBIAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnHPCGD+MFAPDQBTFtGmEYIPLdKeOnC0+G+MiDtD9OHdCEDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCIJAnDeBJAeCx+YUUBJ2BBJRKSGMAYAKDBBNAKDBBBHPCID+MFAPDQBTFtGmEYIPLdKeOnC+P+e+8/4BDtD9OHdCbDbD8jHPD8dBhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBAeCx+YUUBJDBBBHnAnDQBBBBBBBBBBBBBBBBAPD8dFhUg/8/4/w/goB9+h84k7HeCEWCxkUUBJDBEBD9uDQBFGEILKOTtmYPdenDfAdAPD9SDMIBAKCNJAnDeBJAeCx+YUUBJ2BBJRKSFMAYAKDBBBDMIBAKCTJRKMAICGJRIAECTJHEAM9JQBMMGXAK9FQBAKRTAtCFJHtCI6QGSFMMCBRKSEMGXAM9FQBALCUGJAbJREALAbJDBGBRnCBRYEXAEALCU/CBJAYJHIDBIBHdCFD9tAdCFDbHPD9OD9hD9RHdAIAMJDBIBHiCFD9tAiAPD9OD9hD9RHiDQBTFtGmEYIPLdKeOnH8ZAIAQJDBIBHpCFD9tApAPD9OD9hD9RHpAIASJDBIBHyCFD9tAyAPD9OD9hD9RHyDQBTFtGmEYIPLdKeOnH8cDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGEAnD9uHnDyBjGBAEAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnA8ZA8cDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNiV8ZcpMyS8cQ8df8eb8fHdApAyDQNiV8ZcpMyS8cQ8df8eb8fHiDQBFTtGEmYILPdKOenHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJHIAnAdAiDQNVi8ZcMpySQ8c8dfb8e8fHPAPDQBFGEBFGEBFGEBFGED9uHnDyBjGBAIAGJHIAnAPAPDQILKOILKOILKOILKOD9uHnDyBjGBAIAGJHIAnAPAPDQNVcMNVcMNVcMNVcMD9uHnDyBjGBAIAGJHIAnAPAPDQSQfbSQfbSQfbSQfbD9uHnDyBjGBAIAGJREAYCTJHYAM9JQBMMAbCIJHbAG9JQBMMABAVAG9sJALCUGJAcAG9s/8cBBALALCUGJAcCaJAG9sJAG/8cBBMAcCBAKyAVJRVAKQBMC9+RKSFMCBC99AOAKlAGCAAGCA9Ly6yRKMALCU/KBJ8kUUUUBAKMNBT+BUUUBM+KmFTa8jUUUUBCoFlHL8kUUUUBC9+RKGXAFCE9uHOCtJAI9LQBCaRKAE2BBHNC/wFZC/gF9HQBANCbZHVCF9LQBALCoBJCgFCUF/8MBALC84Jha83EBALC8wJha83EBALC8oJha83EBALCAJha83EBALCiJha83EBALCTJha83EBALha83ENALha83EBAEAIJC9wJRcAECFJHNAOJRMGXAF9FQBCQCbAVCF6yRSABRECBRVCBRQCBRfCBRICBRKEXGXAMAcuQBC9+RKSEMGXGXAN2BBHOC/vF9LQBALCoBJAOCIrCa9zAKJCbZCEWJHb8oGIRTAb8oGBRtGXAOCbZHbAS9PQBALAOCa9zAIJCbZCGWJ8oGBAVAbyROAb9FRbGXGXAGCG9HQBABAt87FBABCIJAO87FBABCGJAT87FBSFMAEAtjGBAECNJAOjGBAECIJATjGBMAVAbJRVALCoBJAKCEWJHmAOjGBAmATjGIALAICGWJAOjGBALCoBJAKCFJCbZHKCEWJHTAtjGBATAOjGIAIAbJRIAKCFJRKSGMGXGXAbCb6QBAQAbJAbC989zJCFJRQSFMAM1BBHbCgFZROGXGXAbCa9MQBAMCFJRMSFMAM1BFHbCgBZCOWAOCgBZqROGXAbCa9MQBAMCGJRMSFMAM1BGHbCgBZCfWAOqROGXAbCa9MQBAMCEJRMSFMAM1BEHbCgBZCdWAOqROGXAbCa9MQBAMCIJRMSFMAM2BIC8cWAOqROAMCLJRMMAOCFrCBAOCFZl9zAQJRQMGXGXAGCG9HQBABAt87FBABCIJAQ87FBABCGJAT87FBSFMAEAtjGBAECNJAQjGBAECIJATjGBMALCoBJAKCEWJHOAQjGBAOATjGIALAICGWJAQjGBALCoBJAKCFJCbZHKCEWJHOAtjGBAOAQjGIAICFJRIAKCFJRKSFMGXAOCDF9LQBALAIAcAOCbZJ2BBHbCIrHTlCbZCGWJ8oGBAVCFJHtATyROALAIAblCbZCGWJ8oGBAtAT9FHmJHtAbCbZHTyRbAT9FRTGXGXAGCG9HQBABAV87FBABCIJAb87FBABCGJAO87FBSFMAEAVjGBAECNJAbjGBAECIJAOjGBMALAICGWJAVjGBALCoBJAKCEWJHYAOjGBAYAVjGIALAICFJHICbZCGWJAOjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAIAmJCbZHICGWJAbjGBALCoBJAKCGJCbZHKCEWJHOAVjGBAOAbjGIAKCFJRKAIATJRIAtATJRVSFMAVCBAM2BBHYyHTAOC/+F6HPJROAYCbZRtGXGXAYCIrHmQBAOCFJRbSFMAORbALAIAmlCbZCGWJ8oGBROMGXGXAtQBAbCFJRVSFMAbRVALAIAYlCbZCGWJ8oGBRbMGXGXAP9FQBAMCFJRYSFMAM1BFHYCgFZRTGXGXAYCa9MQBAMCGJRYSFMAM1BGHYCgBZCOWATCgBZqRTGXAYCa9MQBAMCEJRYSFMAM1BEHYCgBZCfWATqRTGXAYCa9MQBAMCIJRYSFMAM1BIHYCgBZCdWATqRTGXAYCa9MQBAMCLJRYSFMAMCKJRYAM2BLC8cWATqRTMATCFrCBATCFZl9zAQJHQRTMGXGXAmCb6QBAYRPSFMAY1BBHMCgFZROGXGXAMCa9MQBAYCFJRPSFMAY1BFHMCgBZCOWAOCgBZqROGXAMCa9MQBAYCGJRPSFMAY1BGHMCgBZCfWAOqROGXAMCa9MQBAYCEJRPSFMAY1BEHMCgBZCdWAOqROGXAMCa9MQBAYCIJRPSFMAYCLJRPAY2BIC8cWAOqROMAOCFrCBAOCFZl9zAQJHQROMGXGXAtCb6QBAPRMSFMAP1BBHMCgFZRbGXGXAMCa9MQBAPCFJRMSFMAP1BFHMCgBZCOWAbCgBZqRbGXAMCa9MQBAPCGJRMSFMAP1BGHMCgBZCfWAbqRbGXAMCa9MQBAPCEJRMSFMAP1BEHMCgBZCdWAbqRbGXAMCa9MQBAPCIJRMSFMAPCLJRMAP2BIC8cWAbqRbMAbCFrCBAbCFZl9zAQJHQRbMGXGXAGCG9HQBABAT87FBABCIJAb87FBABCGJAO87FBSFMAEATjGBAECNJAbjGBAECIJAOjGBMALCoBJAKCEWJHYAOjGBAYATjGIALAICGWJATjGBALCoBJAKCFJCbZCEWJHYAbjGBAYAOjGIALAICFJHICbZCGWJAOjGBALCoBJAKCGJCbZCEWJHOATjGBAOAbjGIALAIAm9FAmCb6qJHICbZCGWJAbjGBAIAt9FAtCb6qJRIAKCEJRKMANCFJRNABCKJRBAECSJREAKCbZRKAICbZRIAfCEJHfAF9JQBMMCBC99AMAc6yRKMALCoFJ8kUUUUBAKM/tIFGa8jUUUUBCTlRLC9+RKGXAFCLJAI9LQBCaRKAE2BBC/+FZC/QF9HQBALhB83ENAECFJRKAEAIJC98JREGXAF9FQBGXAGCG6QBEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMALCNJAICFZCGWqHGAICGrCBAICFrCFZl9zAG8oGBJHIjGBABAIjGBABCIJRBAFCaJHFQBSGMMEXGXAKAE9JQBC9+bMAK1BBHGCgFZRIGXGXAGCa9MQBAKCFJRKSFMAK1BFHGCgBZCOWAICgBZqRIGXAGCa9MQBAKCGJRKSFMAK1BGHGCgBZCfWAIqRIGXAGCa9MQBAKCEJRKSFMAK1BEHGCgBZCdWAIqRIGXAGCa9MQBAKCIJRKSFMAK2BIC8cWAIqRIAKCLJRKMABAICGrCBAICFrCFZl9zALCNJAICFZCGWqHI8oGBJHG87FBAIAGjGBABCGJRBAFCaJHFQBMMCBC99AKAE6yRKMAKM/xLGEaK978jUUUUBCAlHE8kUUUUBGXGXAGCI9HQBGXAFC98ZHI9FQBABRGCBRLEXAGAGDBBBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMBBAGCTJRGALCIJHLAI9JQBMMAIAF9PQFAEAFCEZHLCGWHGqCBCTAGl/8MBAEABAICGWJHIAG/8cBBGXAL9FQBAEAEDBIBHKCiD+rFCiD+sFD/6FHOAKCND+rFCiD+sFD/6FAOD/gFAKCTD+rFCiD+sFD/6FHND/gFD/kFD/lFHVCBDtD+2FHcAOCUUUU94DtHMD9OD9RD/kFHO9DBB/+hDYAOAOD/mFAVAVD/mFANAcANAMD9OD9RD/kFHOAOD/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHcD/kFCgFDtD9OAKCUUU94DtD9OD9QAOAND/mFAcD/kFCND+rFCU/+EDtD9OD9QAVAND/mFAcD/kFCTD+rFCUU/8ODtD9OD9QDMIBMAIAEAG/8cBBSFMABAFC98ZHGT+HUUUBAGAF9PQBAEAFCEZHICEWHLJCBCAALl/8MBAEABAGCEWJHGAL/8cBBAEAIT+HUUUBAGAEAL/8cBBMAECAJ8kUUUUBM+yEGGaO97GXAF9FQBCBRGEXABCTJHEAEDBBBHICBDtHLCUU98D8cFCUU98D8cEHKD9OABDBBBHOAIDQILKOSQfbPden8c8d8e8fCggFDtD9OD/6FAOAIDQBFGENVcMTtmYi8ZpyHICTD+sFD/6FHND/gFAICTD+rFCTD+sFD/6FHVD/gFD/kFD/lFHI9DB/+g6DYAVAIALD+2FHLAVCUUUU94DtHcD9OD9RD/kFHVAVD/mFAIAID/mFANALANAcD9OD9RD/kFHIAID/mFD/kFD/kFD/jFD/nFHND/mF9DBBX9LDYHLD/kFCTD+rFAVAND/mFALD/kFCggEDtD9OD9QHVAIAND/mFALD/kFCaDbCBDnGCBDnECBDnKCBDnOCBDncCBDnMCBDnfCBDnbD9OHIDQNVi8ZcMpySQ8c8dfb8e8fD9QDMBBABAOAKD9OAVAIDQBFTtGEmYILPdKOenD9QDMBBABCAJRBAGCIJHGAF9JQBMMM94FEa8jUUUUBCAlHE8kUUUUBABAFC98ZHIT+JUUUBGXAIAF9PQBAEAFCEZHLCEWHFJCBCAAFl/8MBAEABAICEWJHBAF/8cBBAEALT+JUUUBABAEAF/8cBBMAECAJ8kUUUUBM/hEIGaF97FaL978jUUUUBCTlRGGXAF9FQBCBREEXAGABDBBBHIABCTJHLDBBBHKDQILKOSQfbPden8c8d8e8fHOCTD+sFHNCID+rFDMIBAB9DBBU8/DY9D/zI818/DYANCEDtD9QD/6FD/nFHNAIAKDQBFGENVcMTtmYi8ZpyHICTD+rFCTD+sFD/6FD/mFHKAKD/mFANAICTD+sFD/6FD/mFHVAVD/mFANAOCTD+rFCTD+sFD/6FD/mFHOAOD/mFD/kFD/kFD/lFCBDtD+4FD/jF9DB/+g6DYHND/mF9DBBX9LDYHID/kFCggEDtHcD9OAVAND/mFAID/kFCTD+rFD9QHVAOAND/mFAID/kFCTD+rFAKAND/mFAID/kFAcD9OD9QHNDQBFTtGEmYILPdKOenHID8dBAGDBIBDyB+t+J83EBABCNJAID8dFAGDBIBDyF+t+J83EBALAVANDQNVi8ZcMpySQ8c8dfb8e8fHND8dBAGDBIBDyG+t+J83EBABCiJAND8dFAGDBIBDyE+t+J83EBABCAJRBAECIJHEAF9JQBMMM/3FGEaF978jUUUUBCoBlREGXAGCGrAF9sHIC98ZHL9FQBCBRGABRFEXAFAFDBBBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMBBAFCTJRFAGCIJHGAL9JQBMMGXALAI9PQBAEAICEZHGCGWHFqCBCoBAFl/8MBAEABALCGWJHLAF/8cBBGXAG9FQBAEAEDBIBHKCND+rFCND+sFD/6FAKCiD+sFCnD+rFCUUU/8EDtD+uFD/mFDMIBMALAEAF/8cBBMM9TFEaCBCB8oGUkUUBHFABCEJC98ZJHBjGUkUUBGXGXAB8/BCTWHGuQBCaREABAGlCggEJCTrXBCa6QFMAFREMAEMMMFBCUNMIT9tBB",bO=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),OO=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]),PO={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},NO={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};async function MA(e,t,n,r,s,i="NONE"){let o=await FO();UO(o,o.exports[NO[s]],e,t,n,r,o.exports[PO[i||"NONE"]])}var qf;async function FO(){return qf||(qf=vO()),qf}async function vO(){let e=wO;WebAssembly.validate(bO)&&(e=IO,console.log("Warning: meshopt_decoder is using experimental SIMD support"));let t=await WebAssembly.instantiate(DO(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}function DO(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r){let s=e.charCodeAt(r);t[r]=s>96?s-71:s>64?s-65:s>47?s+4:s>46?63:62}let n=0;for(let r=0;r<e.length;++r)t[n++]=t[r]<60?OO[t[r]]:(t[r]-60)*64+t[++r];return t.buffer.slice(0,n)}function UO(e,t,n,r,s,i,o){let c=e.exports.sbrk,a=r+3&-4,h=c(a*s),l=c(i.length),f=new Uint8Array(e.exports.memory.buffer);f.set(i,l);let p=t(h,r,s,l,i.length);if(p===0&&o&&o(h,a,s),n.set(f.subarray(h,h+r*s)),c(h-c(0)),p!==0)throw new Error(`Malformed buffer data: ${p}`)}var bc="EXT_meshopt_compression",GO=bc;async function zO(e,t){let n=new K(e);if(!t?.gltf?.decompressMeshes||!t.gltf?.loadBuffers)return;let r=[];for(let s of e.json.bufferViews||[])r.push(kO(n,s));await Promise.all(r),n.removeExtension(bc)}async function kO(e,t){let n=e.getObjectExtension(t,bc);if(n){let{byteOffset:r=0,byteLength:s=0,byteStride:i,count:o,mode:c,filter:a="NONE",buffer:h}=n,l=e.gltf.buffers[h],f=new Uint8Array(l.arrayBuffer,l.byteOffset+r,s),p=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);await MA(p,o,i,f,c,a),e.removeObjectExtension(t,bc)}}var Yf={};At(Yf,{name:()=>VO,preprocess:()=>qO});var ts="EXT_texture_webp",VO=ts;function qO(e,t){let n=new K(e);if(!Ha("image/webp")){if(n.getRequiredExtensions().includes(ts))throw new Error(`gltf: Required extension ${ts} not supported by browser`);return}let{json:r}=n;for(let s of r.textures||[]){let i=n.getObjectExtension(s,ts);i&&(s.source=i.source),n.removeObjectExtension(s,ts)}n.removeExtension(ts)}var Wf={};At(Wf,{name:()=>HO,preprocess:()=>YO});var Oc="KHR_texture_basisu",HO=Oc;function YO(e,t){let n=new K(e),{json:r}=n;for(let s of r.textures||[]){let i=n.getObjectExtension(s,Oc);i&&(s.source=i.source,n.removeObjectExtension(s,Oc))}n.removeExtension(Oc)}var Xf={};At(Xf,{decode:()=>KO,encode:()=>ZO,name:()=>XO,preprocess:()=>jO});function AA(e){let t={};for(let n in e){let r=e[n];if(n!=="indices"){let s=Jf(r);t[n]=s}}return t}function Jf(e){let{buffer:t,size:n,count:r}=WO(e);return{value:t,size:n,byteOffset:0,count:r,type:Bc(n),componentType:Xr(t)}}function WO(e){let t=e,n=1,r=0;return e&&e.value&&(t=e.value,n=e.size||1),t&&(ArrayBuffer.isView(t)||(t=JO(t,Float32Array)),r=t.length/n),{buffer:t,size:n,count:r}}function JO(e,t,n=!1){return e?Array.isArray(e)?new t(e):n&&!(e instanceof t)?new t(e):e:null}var _n="KHR_draco_mesh_compression",XO=_n;function jO(e,t,n){let r=new K(e);for(let s of yA(r))r.getObjectExtension(s,_n)}async function KO(e,t,n){if(!t?.gltf?.decompressMeshes)return;let r=new K(e),s=[];for(let i of yA(r))r.getObjectExtension(i,_n)&&s.push(QO(r,i,t,n));await Promise.all(s),r.removeExtension(_n)}function ZO(e,t={}){let n=new K(e);for(let r of n.json.meshes||[])$O(r,t),n.addRequiredExtension(_n)}async function QO(e,t,n,r){let s=e.getObjectExtension(t,_n);if(!s)return;let i=e.getTypedArrayForBufferView(s.bufferView),o=Rn(i.buffer,i.byteOffset),c={...n};delete c["3d-tiles"];let a=await qt(o,ac,c,r),h=AA(a.attributes);for(let[l,f]of Object.entries(h))if(l in t.attributes){let p=t.attributes[l],u=e.getAccessor(p);u?.min&&u?.max&&(f.min=u.min,f.max=u.max)}t.attributes=h,a.indices&&(t.indices=Jf(a.indices)),e.removeObjectExtension(t,_n),tP(t)}function $O(e,t,n=4,r,s){if(!r.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");let i=r.DracoWriter.encodeSync({attributes:e}),o=s?.parseSync?.({attributes:e}),c=r._addFauxAttributes(o.attributes),a=r.addBufferView(i);return{primitives:[{attributes:c,mode:n,extensions:{[_n]:{bufferView:a,attributes:c}}}]}}function tP(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}function*yA(e){for(let t of e.json.meshes||[])for(let n of t.primitives)yield n}var e0={};At(e0,{decode:()=>gP,name:()=>uP});var eZ=1/Math.PI*180,nZ=1/180*Math.PI,eP={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...eP}};var Ct=globalThis.mathgl.config;function EA(e,{precision:t=Ct.precision}={}){return e=nP(e),`${parseFloat(e.toPrecision(t))}`}function es(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function jf(e,t,n){let r=Ct.EPSILON;n&&(Ct.EPSILON=n);try{if(e===t)return!0;if(es(e)&&es(t)){if(e.length!==t.length)return!1;for(let s=0;s<e.length;++s)if(!jf(e[s],t[s]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):typeof e=="number"&&typeof t=="number"?Math.abs(e-t)<=Ct.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)):!1}finally{Ct.EPSILON=r}}function nP(e){return Math.round(e/Ct.EPSILON)*Ct.EPSILON}var ns=class extends Array{clone(){return new this.constructor().copy(this)}fromArray(t,n=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=t[r+n];return this.check()}toArray(t=[],n=0){for(let r=0;r<this.ELEMENTS;++r)t[n+r]=this[r];return t}toObject(t){return t}from(t){return Array.isArray(t)?this.copy(t):this.fromObject(t)}to(t){return t===this?this:es(t)?this.toArray(t):this.toObject(t)}toTarget(t){return t?this.to(t):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Ct)}formatString(t){let n="";for(let r=0;r<this.ELEMENTS;++r)n+=(r>0?", ":"")+EA(this[r],t);return`${t.printTypes?this.constructor.name:""}[${n}]`}equals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(!jf(this[n],t[n]))return!1;return!0}exactEquals(t){if(!t||this.length!==t.length)return!1;for(let n=0;n<this.ELEMENTS;++n)if(this[n]!==t[n])return!1;return!0}negate(){for(let t=0;t<this.ELEMENTS;++t)this[t]=-this[t];return this.check()}lerp(t,n,r){if(r===void 0)return this.lerp(this,t,n);for(let s=0;s<this.ELEMENTS;++s){let i=t[s],o=typeof n=="number"?n:n[s];this[s]=i+r*(o-i)}return this.check()}min(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.min(t[n],this[n]);return this.check()}max(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=Math.max(t[n],this[n]);return this.check()}clamp(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t[r]),n[r]);return this.check()}add(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]+=n[r];return this.check()}subtract(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]-=n[r];return this.check()}scale(t){if(typeof t=="number")for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;else for(let n=0;n<this.ELEMENTS&&n<t.length;++n)this[n]*=t[n];return this.check()}multiplyByScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}check(){if(Ct.debug&&!this.validate())throw new Error(`math.gl: ${this.constructor.name} some fields set to invalid numbers'`);return this}validate(){let t=this.length===this.ELEMENTS;for(let n=0;n<this.ELEMENTS;++n)t=t&&Number.isFinite(this[n]);return t}sub(t){return this.subtract(t)}setScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]=t;return this.check()}addScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]+=t;return this.check()}subScalar(t){return this.addScalar(-t)}multiplyScalar(t){for(let n=0;n<this.ELEMENTS;++n)this[n]*=t;return this.check()}divideScalar(t){return this.multiplyByScalar(1/t)}clampScalar(t,n){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],t),n);return this.check()}get elements(){return this}};function rP(e,t){if(e.length!==t)return!1;for(let n=0;n<e.length;++n)if(!Number.isFinite(e[n]))return!1;return!0}function Nt(e){if(!Number.isFinite(e))throw new Error(`Invalid number ${JSON.stringify(e)}`);return e}function TA(e,t,n=""){if(Ct.debug&&!rP(e,t))throw new Error(`math.gl: ${n} some fields set to invalid numbers'`);return e}function Kf(e,t){if(!e)throw new Error(`math.gl assertion ${t}`)}var Pc=class extends ns{get x(){return this[0]}set x(t){this[0]=Nt(t)}get y(){return this[1]}set y(t){this[1]=Nt(t)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let t=0;for(let n=0;n<this.ELEMENTS;++n)t+=this[n]*this[n];return t}magnitudeSquared(){return this.lengthSquared()}distance(t){return Math.sqrt(this.distanceSquared(t))}distanceSquared(t){let n=0;for(let r=0;r<this.ELEMENTS;++r){let s=this[r]-t[r];n+=s*s}return Nt(n)}dot(t){let n=0;for(let r=0;r<this.ELEMENTS;++r)n+=this[r]*t[r];return Nt(n)}normalize(){let t=this.magnitude();if(t!==0)for(let n=0;n<this.ELEMENTS;++n)this[n]/=t;return this.check()}multiply(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]*=n[r];return this.check()}divide(...t){for(let n of t)for(let r=0;r<this.ELEMENTS;++r)this[r]/=n[r];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(t){return this.distance(t)}distanceToSquared(t){return this.distanceSquared(t)}getComponent(t){return Kf(t>=0&&t<this.ELEMENTS,"index is out of range"),Nt(this[t])}setComponent(t,n){return Kf(t>=0&&t<this.ELEMENTS,"index is out of range"),this[t]=n,this.check()}addVectors(t,n){return this.copy(t).add(n)}subVectors(t,n){return this.copy(t).subtract(n)}multiplyVectors(t,n){return this.copy(t).multiply(n)}addScaledVector(t,n){return this.add(new this.constructor(t).multiplyScalar(n))}};var rs=typeof Float32Array<"u"?Float32Array:Array;var uZ=Math.PI/180;function cP(){let e=new rs(2);return rs!=Float32Array&&(e[0]=0,e[1]=0),e}function SA(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[3]*s+n[6],e[1]=n[1]*r+n[4]*s+n[7],e}var dZ=function(){let e=cP();return function(t,n,r,s,i,o){let c,a;for(n||(n=2),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],i(e,e,o),t[c]=e[0],t[c+1]=e[1];return t}}();function BA(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i||1;return e[0]=(n[0]*r+n[4]*s+n[8]*i)/o,e[1]=(n[1]*r+n[5]*s+n[9]*i)/o,e[2]=(n[2]*r+n[6]*s+n[10]*i)/o,e}function CA(e,t,n){let r=t[0],s=t[1];return e[0]=n[0]*r+n[2]*s,e[1]=n[1]*r+n[3]*s,e[2]=t[2],e}function LA(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=n[0]*r+n[3]*s+n[6]*i,e[1]=n[1]*r+n[4]*s+n[7]*i,e[2]=n[2]*r+n[5]*s+n[8]*i,e[3]=t[3],e}function aP(){let e=new rs(3);return rs!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function hP(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function RA(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[0],c=n[1],a=n[2];return e[0]=s*a-i*c,e[1]=i*o-r*a,e[2]=r*c-s*o,e}function wA(e,t,n){let r=t[0],s=t[1],i=t[2],o=n[3]*r+n[7]*s+n[11]*i+n[15];return o=o||1,e[0]=(n[0]*r+n[4]*s+n[8]*i+n[12])/o,e[1]=(n[1]*r+n[5]*s+n[9]*i+n[13])/o,e[2]=(n[2]*r+n[6]*s+n[10]*i+n[14])/o,e}function Nc(e,t,n){let r=t[0],s=t[1],i=t[2];return e[0]=r*n[0]+s*n[3]+i*n[6],e[1]=r*n[1]+s*n[4]+i*n[7],e[2]=r*n[2]+s*n[5]+i*n[8],e}function IA(e,t,n){let r=n[0],s=n[1],i=n[2],o=n[3],c=t[0],a=t[1],h=t[2],l=s*h-i*a,f=i*c-r*h,p=r*a-s*c,u=s*p-i*f,d=i*l-r*p,g=r*f-s*l,m=o*2;return l*=m,f*=m,p*=m,u*=2,d*=2,g*=2,e[0]=c+l+u,e[1]=a+f+d,e[2]=h+p+g,e}function bA(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0],i[1]=s[1]*Math.cos(r)-s[2]*Math.sin(r),i[2]=s[1]*Math.sin(r)+s[2]*Math.cos(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function OA(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[2]*Math.sin(r)+s[0]*Math.cos(r),i[1]=s[1],i[2]=s[2]*Math.cos(r)-s[0]*Math.sin(r),e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function PA(e,t,n,r){let s=[],i=[];return s[0]=t[0]-n[0],s[1]=t[1]-n[1],s[2]=t[2]-n[2],i[0]=s[0]*Math.cos(r)-s[1]*Math.sin(r),i[1]=s[0]*Math.sin(r)+s[1]*Math.cos(r),i[2]=s[2],e[0]=i[0]+n[0],e[1]=i[1]+n[1],e[2]=i[2]+n[2],e}function NA(e,t){let n=e[0],r=e[1],s=e[2],i=t[0],o=t[1],c=t[2],a=Math.sqrt((n*n+r*r+s*s)*(i*i+o*o+c*c)),h=a&&hP(e,t)/a;return Math.acos(Math.min(Math.max(h,-1),1))}var xZ=function(){let e=aP();return function(t,n,r,s,i,o){let c,a;for(n||(n=3),r||(r=0),s?a=Math.min(s*n+r,t.length):a=t.length,c=r;c<a;c+=n)e[0]=t[c],e[1]=t[c+1],e[2]=t[c+2],i(e,e,o),t[c]=e[0],t[c+1]=e[1],t[c+2]=e[2];return t}}();var Zf=[0,0,0],Fc,Xn=class extends Pc{static get ZERO(){return Fc||(Fc=new Xn(0,0,0),Object.freeze(Fc)),Fc}constructor(t=0,n=0,r=0){super(-0,-0,-0),arguments.length===1&&es(t)?this.copy(t):(Ct.debug&&(Nt(t),Nt(n),Nt(r)),this[0]=t,this[1]=n,this[2]=r)}set(t,n,r){return this[0]=t,this[1]=n,this[2]=r,this.check()}copy(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this.check()}fromObject(t){return Ct.debug&&(Nt(t.x),Nt(t.y),Nt(t.z)),this[0]=t.x,this[1]=t.y,this[2]=t.z,this.check()}toObject(t){return t.x=this[0],t.y=this[1],t.z=this[2],t}get ELEMENTS(){return 3}get z(){return this[2]}set z(t){this[2]=Nt(t)}angle(t){return NA(this,t)}cross(t){return RA(this,this,t),this.check()}rotateX({radians:t,origin:n=Zf}){return bA(this,this,n,t),this.check()}rotateY({radians:t,origin:n=Zf}){return OA(this,this,n,t),this.check()}rotateZ({radians:t,origin:n=Zf}){return PA(this,this,n,t),this.check()}transform(t){return this.transformAsPoint(t)}transformAsPoint(t){return wA(this,this,t),this.check()}transformAsVector(t){return BA(this,this,t),this.check()}transformByMatrix3(t){return Nc(this,this,t),this.check()}transformByMatrix2(t){return CA(this,this,t),this.check()}transformByQuaternion(t){return IA(this,this,t),this.check()}};var vc=class extends ns{toString(){let t="[";if(Ct.printRowMajor){t+="row-major:";for(let n=0;n<this.RANK;++n)for(let r=0;r<this.RANK;++r)t+=` ${this[r*this.RANK+n]}`}else{t+="column-major:";for(let n=0;n<this.ELEMENTS;++n)t+=` ${this[n]}`}return t+="]",t}getElementIndex(t,n){return n*this.RANK+t}getElement(t,n){return this[n*this.RANK+t]}setElement(t,n,r){return this[n*this.RANK+t]=Nt(r),this}getColumn(t,n=new Array(this.RANK).fill(-0)){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)n[s]=this[r+s];return n}setColumn(t,n){let r=t*this.RANK;for(let s=0;s<this.RANK;++s)this[r+s]=n[s];return this}};function FA(e,t){if(e===t){let n=t[1],r=t[2],s=t[5];e[1]=t[3],e[2]=t[6],e[3]=n,e[5]=t[7],e[6]=r,e[7]=s}else e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8];return e}function vA(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=t[4],c=t[5],a=t[6],h=t[7],l=t[8],f=l*o-c*h,p=-l*i+c*a,u=h*i-o*a,d=n*f+r*p+s*u;return d?(d=1/d,e[0]=f*d,e[1]=(-l*r+s*h)*d,e[2]=(c*r-s*o)*d,e[3]=p*d,e[4]=(l*n-s*a)*d,e[5]=(-c*n+s*i)*d,e[6]=u*d,e[7]=(-h*n+r*a)*d,e[8]=(o*n-r*i)*d,e):null}function DA(e){let t=e[0],n=e[1],r=e[2],s=e[3],i=e[4],o=e[5],c=e[6],a=e[7],h=e[8];return t*(h*i-o*a)+n*(-h*s+o*c)+r*(a*s-i*c)}function Qf(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1],d=n[2],g=n[3],m=n[4],M=n[5],E=n[6],A=n[7],y=n[8];return e[0]=p*r+u*o+d*h,e[1]=p*s+u*c+d*l,e[2]=p*i+u*a+d*f,e[3]=g*r+m*o+M*h,e[4]=g*s+m*c+M*l,e[5]=g*i+m*a+M*f,e[6]=E*r+A*o+y*h,e[7]=E*s+A*c+y*l,e[8]=E*i+A*a+y*f,e}function UA(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=n[0],u=n[1];return e[0]=r,e[1]=s,e[2]=i,e[3]=o,e[4]=c,e[5]=a,e[6]=p*r+u*o+h,e[7]=p*s+u*c+l,e[8]=p*i+u*a+f,e}function GA(e,t,n){let r=t[0],s=t[1],i=t[2],o=t[3],c=t[4],a=t[5],h=t[6],l=t[7],f=t[8],p=Math.sin(n),u=Math.cos(n);return e[0]=u*r+p*o,e[1]=u*s+p*c,e[2]=u*i+p*a,e[3]=u*o-p*r,e[4]=u*c-p*s,e[5]=u*a-p*i,e[6]=h,e[7]=l,e[8]=f,e}function $f(e,t,n){let r=n[0],s=n[1];return e[0]=r*t[0],e[1]=r*t[1],e[2]=r*t[2],e[3]=s*t[3],e[4]=s*t[4],e[5]=s*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}function zA(e,t){let n=t[0],r=t[1],s=t[2],i=t[3],o=n+n,c=r+r,a=s+s,h=n*o,l=r*o,f=r*c,p=s*o,u=s*c,d=s*a,g=i*o,m=i*c,M=i*a;return e[0]=1-f-d,e[3]=l-M,e[6]=p+m,e[1]=l+M,e[4]=1-h-d,e[7]=u-g,e[2]=p-m,e[5]=u+g,e[8]=1-h-f,e}var t0;(function(e){e[e.COL0ROW0=0]="COL0ROW0",e[e.COL0ROW1=1]="COL0ROW1",e[e.COL0ROW2=2]="COL0ROW2",e[e.COL1ROW0=3]="COL1ROW0",e[e.COL1ROW1=4]="COL1ROW1",e[e.COL1ROW2=5]="COL1ROW2",e[e.COL2ROW0=6]="COL2ROW0",e[e.COL2ROW1=7]="COL2ROW1",e[e.COL2ROW2=8]="COL2ROW2"})(t0||(t0={}));var lP=Object.freeze([1,0,0,0,1,0,0,0,1]),qe=class extends vc{static get IDENTITY(){return pP()}static get ZERO(){return fP()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return t0}constructor(t,...n){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),arguments.length===1&&Array.isArray(t)?this.copy(t):n.length>0?this.copy([t,...n]):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(lP)}fromObject(t){return this.check()}fromQuaternion(t){return zA(this,t),this.check()}set(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=n,this[2]=r,this[3]=s,this[4]=i,this[5]=o,this[6]=c,this[7]=a,this[8]=h,this.check()}setRowMajor(t,n,r,s,i,o,c,a,h){return this[0]=t,this[1]=s,this[2]=c,this[3]=n,this[4]=i,this[5]=a,this[6]=r,this[7]=o,this[8]=h,this.check()}determinant(){return DA(this)}transpose(){return FA(this,this),this.check()}invert(){return vA(this,this),this.check()}multiplyLeft(t){return Qf(this,t,this),this.check()}multiplyRight(t){return Qf(this,this,t),this.check()}rotate(t){return GA(this,this,t),this.check()}scale(t){return Array.isArray(t)?$f(this,this,t):$f(this,this,[t,t]),this.check()}translate(t){return UA(this,this,t),this.check()}transform(t,n){let r;switch(t.length){case 2:r=SA(n||[-0,-0],t,this);break;case 3:r=Nc(n||[-0,-0,-0],t,this);break;case 4:r=LA(n||[-0,-0,-0,-0],t,this);break;default:throw new Error("Illegal vector")}return TA(r,t.length),r}transformVector(t,n){return this.transform(t,n)}transformVector2(t,n){return this.transform(t,n)}transformVector3(t,n){return this.transform(t,n)}},Dc,Uc=null;function fP(){return Dc||(Dc=new qe([0,0,0,0,0,0,0,0,0]),Object.freeze(Dc)),Dc}function pP(){return Uc||(Uc=new qe,Object.freeze(Uc)),Uc}var zc="KHR_texture_transform",uP=zc,Gc=new Xn,dP=new qe,mP=new qe;async function gP(e,t){if(!new K(e).hasExtension(zc)||!t.gltf?.loadBuffers)return;let s=e.json.materials||[];for(let i=0;i<s.length;i++)xP(i,e)}function xP(e,t){let n=t.json.materials?.[e],r=[n?.pbrMetallicRoughness?.baseColorTexture,n?.emissiveTexture,n?.normalTexture,n?.occlusionTexture,n?.pbrMetallicRoughness?.metallicRoughnessTexture],s=[];for(let i of r)i&&i?.extensions?.[zc]&&MP(t,e,i,s)}function MP(e,t,n,r){let s=AP(n,r);if(!s)return;let i=e.json.meshes||[];for(let o of i)for(let c of o.primitives){let a=c.material;Number.isFinite(a)&&t===a&&yP(e,c,s)}}function AP(e,t){let n=e.extensions?.[zc],{texCoord:r=0}=e,{texCoord:s=r}=n;if(!(t.findIndex(([o,c])=>o===r&&c===s)!==-1)){let o=_P(n);return r!==s&&(e.texCoord=s),t.push([r,s]),{originalTexCoord:r,texCoord:s,matrix:o}}return null}function yP(e,t,n){let{originalTexCoord:r,texCoord:s,matrix:i}=n,o=t.attributes[`TEXCOORD_${r}`];if(Number.isFinite(o)){let c=e.json.accessors?.[o];if(c&&c.bufferView){let a=e.json.bufferViews?.[c.bufferView];if(a){let{arrayBuffer:h,byteOffset:l}=e.buffers[a.buffer],f=(l||0)+(c.byteOffset||0)+(a.byteOffset||0),{ArrayType:p,length:u}=jr(c,a),d=Sc[c.componentType],g=_c[c.type],m=a.byteStride||d*g,M=new Float32Array(u);for(let E=0;E<c.count;E++){let A=new p(h,f+E*m,2);Gc.set(A[0],A[1],1),Gc.transformByMatrix3(i),M.set([Gc[0],Gc[1]],E*g)}r===s?EP(c,a,e.buffers,M):TP(s,c,t,e,M)}}}}function EP(e,t,n,r){e.componentType=5126,n.push({arrayBuffer:r.buffer,byteOffset:0,byteLength:r.buffer.byteLength}),t.buffer=n.length-1,t.byteLength=r.buffer.byteLength,t.byteOffset=0,delete t.byteStride}function TP(e,t,n,r,s){r.buffers.push({arrayBuffer:s.buffer,byteOffset:0,byteLength:s.buffer.byteLength});let i=r.json.bufferViews;if(!i)return;i.push({buffer:r.buffers.length-1,byteLength:s.buffer.byteLength,byteOffset:0});let o=r.json.accessors;o&&(o.push({bufferView:i?.length-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),n.attributes[`TEXCOORD_${e}`]=o.length-1)}function _P(e){let{offset:t=[0,0],rotation:n=0,scale:r=[1,1]}=e,s=new qe().set(1,0,0,0,1,0,t[0],t[1],1),i=dP.set(Math.cos(n),Math.sin(n),0,-Math.sin(n),Math.cos(n),0,0,0,1),o=mP.set(r[0],0,0,0,r[1],0,0,0,1);return s.multiplyRight(i).multiplyRight(o)}var n0={};At(n0,{decode:()=>BP,encode:()=>CP,name:()=>SP});var jn="KHR_lights_punctual",SP=jn;async function BP(e){let t=new K(e),{json:n}=t,r=t.getExtension(jn);r&&(t.json.lights=r.lights,t.removeExtension(jn));for(let s of n.nodes||[]){let i=t.getObjectExtension(s,jn);i&&(s.light=i.light),t.removeObjectExtension(s,jn)}}async function CP(e){let t=new K(e),{json:n}=t;if(n.lights){let r=t.addExtension(jn);Et(!r.lights),r.lights=n.lights,delete n.lights}if(t.json.lights){for(let r of t.json.lights){let s=r.node;t.addObjectExtension(s,jn,r)}delete t.json.lights}}var r0={};At(r0,{decode:()=>RP,encode:()=>wP,name:()=>LP});var li="KHR_materials_unlit",LP=li;async function RP(e){let t=new K(e),{json:n}=t;for(let r of n.materials||[])r.extensions&&r.extensions.KHR_materials_unlit&&(r.unlit=!0),t.removeObjectExtension(r,li);t.removeExtension(li)}function wP(e){let t=new K(e),{json:n}=t;if(t.materials)for(let r of n.materials||[])r.unlit&&(delete r.unlit,t.addObjectExtension(r,li,{}),t.addExtension(li))}var s0={};At(s0,{decode:()=>bP,encode:()=>OP,name:()=>IP});var fi="KHR_techniques_webgl",IP=fi;async function bP(e){let t=new K(e),{json:n}=t,r=t.getExtension(fi);if(r){let s=PP(r,t);for(let i of n.materials||[]){let o=t.getObjectExtension(i,fi);o&&(i.technique=Object.assign({},o,s[o.technique]),i.technique.values=NP(i.technique,t)),t.removeObjectExtension(i,fi)}t.removeExtension(fi)}}async function OP(e,t){}function PP(e,t){let{programs:n=[],shaders:r=[],techniques:s=[]}=e,i=new TextDecoder;return r.forEach(o=>{if(Number.isFinite(o.bufferView))o.code=i.decode(t.getTypedArrayForBufferView(o.bufferView));else throw new Error("KHR_techniques_webgl: no shader code")}),n.forEach(o=>{o.fragmentShader=r[o.fragmentShader],o.vertexShader=r[o.vertexShader]}),s.forEach(o=>{o.program=n[o.program]}),s}function NP(e,t){let n=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(r=>{e.uniforms[r].value&&!(r in n)&&(n[r]=e.uniforms[r].value)}),Object.keys(n).forEach(r=>{typeof n[r]=="object"&&n[r].index!==void 0&&(n[r].texture=t.getTexture(n[r].index))}),n}var kA=[Df,Nf,Hf,Yf,Wf,Xf,n0,r0,s0,e0,Uf];function VA(e,t={},n){let r=kA.filter(s=>HA(s.name,t));for(let s of r)s.preprocess?.(e,t,n)}async function qA(e,t={},n){let r=kA.filter(s=>HA(s.name,t));for(let s of r)await s.decode?.(e,t,n)}function HA(e,t){let n=t?.gltf?.excludeExtensions||{};return!(e in n&&!n[e])}var i0="KHR_binary_glTF";function YA(e){let t=new K(e),{json:n}=t;for(let r of n.images||[]){let s=t.getObjectExtension(r,i0);s&&Object.assign(r,s),t.removeObjectExtension(r,i0)}n.buffers&&n.buffers[0]&&delete n.buffers[0].uri,t.removeExtension(i0)}var WA={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},vP={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"},o0=class{idToIndexMap={animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}};json;normalize(t,n){this.json=t.json;let r=t.json;switch(r.asset&&r.asset.version){case"2.0":return;case void 0:case"1.0":break;default:console.warn(`glTF: Unknown version ${r.asset.version}`);return}if(!n.normalize)throw new Error("glTF v1 is not supported.");console.warn("Converting glTF v1 to glTF v2 format. This is experimental and may fail."),this._addAsset(r),this._convertTopLevelObjectsToArrays(r),YA(t),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(t){t.asset=t.asset||{},t.asset.version="2.0",t.asset.generator=t.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(t){for(let n in WA)this._convertTopLevelObjectToArray(t,n)}_convertTopLevelObjectToArray(t,n){let r=t[n];if(!(!r||Array.isArray(r))){t[n]=[];for(let s in r){let i=r[s];i.id=i.id||s;let o=t[n].length;t[n].push(i),this.idToIndexMap[n][s]=o}}}_convertObjectIdsToArrayIndices(t){for(let n in WA)this._convertIdsToIndices(t,n);"scene"in t&&(t.scene=this._convertIdToIndex(t.scene,"scene"));for(let n of t.textures)this._convertTextureIds(n);for(let n of t.meshes)this._convertMeshIds(n);for(let n of t.nodes)this._convertNodeIds(n);for(let n of t.scenes)this._convertSceneIds(n)}_convertTextureIds(t){t.source&&(t.source=this._convertIdToIndex(t.source,"image"))}_convertMeshIds(t){for(let n of t.primitives){let{attributes:r,indices:s,material:i}=n;for(let o in r)r[o]=this._convertIdToIndex(r[o],"accessor");s&&(n.indices=this._convertIdToIndex(s,"accessor")),i&&(n.material=this._convertIdToIndex(i,"material"))}}_convertNodeIds(t){t.children&&(t.children=t.children.map(n=>this._convertIdToIndex(n,"node"))),t.meshes&&(t.meshes=t.meshes.map(n=>this._convertIdToIndex(n,"mesh")))}_convertSceneIds(t){t.nodes&&(t.nodes=t.nodes.map(n=>this._convertIdToIndex(n,"node")))}_convertIdsToIndices(t,n){t[n]||(console.warn(`gltf v1: json doesn't contain attribute ${n}`),t[n]=[]);for(let r of t[n])for(let s in r){let i=r[s],o=this._convertIdToIndex(i,s);r[s]=o}}_convertIdToIndex(t,n){let r=vP[n];if(r in this.idToIndexMap){let s=this.idToIndexMap[r][t];if(!Number.isFinite(s))throw new Error(`gltf v1: failed to resolve ${n} with id ${t}`);return s}return t}_updateObjects(t){for(let n of this.json.buffers)delete n.type}_updateMaterial(t){for(let n of t.materials){n.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};let r=n.values?.tex||n.values?.texture2d_0||n.values?.diffuseTex,s=t.textures.findIndex(i=>i.id===r);s!==-1&&(n.pbrMetallicRoughness.baseColorTexture={index:s})}}};function JA(e,t={}){return new o0().normalize(e,t)}async function XA(e,t,n=0,r,s){return DP(e,t,n,r),JA(e,{normalize:r?.gltf?.normalize}),VA(e,r,s),r?.gltf?.loadBuffers&&e.json.buffers&&await UP(e,r,s),r?.gltf?.loadImages&&await GP(e,r,s),await qA(e,r,s),e}function DP(e,t,n,r){if(r.uri&&(e.baseUri=r.uri),t instanceof ArrayBuffer&&!gA(t,n,r)&&(t=new TextDecoder().decode(t)),typeof t=="string")e.json=Oa(t);else if(t instanceof ArrayBuffer){let o={};n=xA(o,t,n,r.glb),Et(o.type==="glTF",`Invalid GLB magic string ${o.type}`),e._glb=o,e.json=o.json}else Et(!1,"GLTF: must be ArrayBuffer or string");let s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){let{binChunks:o}=e._glb;e.buffers[0]={arrayBuffer:o[0].arrayBuffer,byteOffset:o[0].byteOffset,byteLength:o[0].byteLength}}let i=e.json.images||[];e.images=new Array(i.length).fill({})}async function UP(e,t,n){let r=e.json.buffers||[];for(let s=0;s<r.length;++s){let i=r[s];if(i.uri){let{fetch:o}=n;Et(o);let c=Vf(i.uri,t),h=await(await n?.fetch?.(c))?.arrayBuffer?.();e.buffers[s]={arrayBuffer:h,byteOffset:0,byteLength:h.byteLength},delete i.uri}else e.buffers[s]===null&&(e.buffers[s]={arrayBuffer:new ArrayBuffer(i.byteLength),byteOffset:0,byteLength:i.byteLength})}}async function GP(e,t,n){let r=zP(e),s=e.json.images||[],i=[];for(let o of r)i.push(kP(e,s[o],o,t,n));return await Promise.all(i)}function zP(e){let t=new Set,n=e.json.textures||[];for(let r of n)r.source!==void 0&&t.add(r.source);return Array.from(t).sort()}async function kP(e,t,n,r,s){let i;if(t.uri&&!t.hasOwnProperty("bufferView")){let c=Vf(t.uri,r),{fetch:a}=s;i=await(await a(c)).arrayBuffer(),t.bufferView={data:i}}if(Number.isFinite(t.bufferView)){let c=cA(e.json,e.buffers,t.bufferView);i=Rn(c.buffer,c.byteOffset,c.byteLength)}Et(i,"glTF image has no data");let o=await qt(i,[Qe,Wh],{...r,mimeType:t.mimeType,basis:r.basis||{format:uo()}},s);o&&o[0]&&(o={compressed:!0,mipmaps:!1,width:o[0].width,height:o[0].height,data:o[0]}),e.images=e.images||[],e.images[n]=o}var Kn={dataType:null,batchType:null,name:"glTF",id:"gltf",module:"gltf",version:dA,extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:VP,options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0},log:console}};async function VP(e,t={},n){t={...Kn.options,...t},t.gltf={...Kn.options.gltf,...t.gltf};let{byteOffset:r=0}=t;return await XA({},e,r,t,n)}var qP={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},HP={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Qt={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},YP={magFilter:Qt.TEXTURE_MAG_FILTER,minFilter:Qt.TEXTURE_MIN_FILTER,wrapS:Qt.TEXTURE_WRAP_S,wrapT:Qt.TEXTURE_WRAP_T},WP={[Qt.TEXTURE_MAG_FILTER]:Qt.LINEAR,[Qt.TEXTURE_MIN_FILTER]:Qt.NEAREST_MIPMAP_LINEAR,[Qt.TEXTURE_WRAP_S]:Qt.REPEAT,[Qt.TEXTURE_WRAP_T]:Qt.REPEAT};function JP(){return{id:"default-sampler",parameters:WP}}function XP(e){return HP[e]}function jP(e){return qP[e]}var c0=class{baseUri="";jsonUnprocessed;json;buffers=[];images=[];postProcess(t,n={}){let{json:r,buffers:s=[],images:i=[]}=t,{baseUri:o=""}=t;return Et(r),this.baseUri=o,this.buffers=s,this.images=i,this.jsonUnprocessed=r,this.json=this._resolveTree(t.json,n),this.json}_resolveTree(t,n={}){let r={...t};return this.json=r,t.bufferViews&&(r.bufferViews=t.bufferViews.map((s,i)=>this._resolveBufferView(s,i))),t.images&&(r.images=t.images.map((s,i)=>this._resolveImage(s,i))),t.samplers&&(r.samplers=t.samplers.map((s,i)=>this._resolveSampler(s,i))),t.textures&&(r.textures=t.textures.map((s,i)=>this._resolveTexture(s,i))),t.accessors&&(r.accessors=t.accessors.map((s,i)=>this._resolveAccessor(s,i))),t.materials&&(r.materials=t.materials.map((s,i)=>this._resolveMaterial(s,i))),t.meshes&&(r.meshes=t.meshes.map((s,i)=>this._resolveMesh(s,i))),t.nodes&&(r.nodes=t.nodes.map((s,i)=>this._resolveNode(s,i)),r.nodes=r.nodes.map((s,i)=>this._resolveNodeChildren(s))),t.skins&&(r.skins=t.skins.map((s,i)=>this._resolveSkin(s,i))),t.scenes&&(r.scenes=t.scenes.map((s,i)=>this._resolveScene(s,i))),typeof this.json.scene=="number"&&r.scenes&&(r.scene=r.scenes[this.json.scene]),r}getScene(t){return this._get(this.json.scenes,t)}getNode(t){return this._get(this.json.nodes,t)}getSkin(t){return this._get(this.json.skins,t)}getMesh(t){return this._get(this.json.meshes,t)}getMaterial(t){return this._get(this.json.materials,t)}getAccessor(t){return this._get(this.json.accessors,t)}getCamera(t){return this._get(this.json.cameras,t)}getTexture(t){return this._get(this.json.textures,t)}getSampler(t){return this._get(this.json.samplers,t)}getImage(t){return this._get(this.json.images,t)}getBufferView(t){return this._get(this.json.bufferViews,t)}getBuffer(t){return this._get(this.json.buffers,t)}_get(t,n){if(typeof n=="object")return n;let r=t&&t[n];return r||console.warn(`glTF file error: Could not find ${t}[${n}]`),r}_resolveScene(t,n){return{...t,id:t.id||`scene-${n}`,nodes:(t.nodes||[]).map(r=>this.getNode(r))}}_resolveNode(t,n){let r={...t,id:t?.id||`node-${n}`};return t.mesh!==void 0&&(r.mesh=this.getMesh(t.mesh)),t.camera!==void 0&&(r.camera=this.getCamera(t.camera)),t.skin!==void 0&&(r.skin=this.getSkin(t.skin)),t.meshes!==void 0&&t.meshes.length&&(r.mesh=t.meshes.reduce((s,i)=>{let o=this.getMesh(i);return s.id=o.id,s.primitives=s.primitives.concat(o.primitives),s},{primitives:[]})),r}_resolveNodeChildren(t){return t.children&&(t.children=t.children.map(n=>this.getNode(n))),t}_resolveSkin(t,n){let r=typeof t.inverseBindMatrices=="number"?this.getAccessor(t.inverseBindMatrices):void 0;return{...t,id:t.id||`skin-${n}`,inverseBindMatrices:r}}_resolveMesh(t,n){let r={...t,id:t.id||`mesh-${n}`,primitives:[]};return t.primitives&&(r.primitives=t.primitives.map(s=>{let i={...s,attributes:{},indices:void 0,material:void 0},o=s.attributes;for(let c in o)i.attributes[c]=this.getAccessor(o[c]);return s.indices!==void 0&&(i.indices=this.getAccessor(s.indices)),s.material!==void 0&&(i.material=this.getMaterial(s.material)),i})),r}_resolveMaterial(t,n){let r={...t,id:t.id||`material-${n}`};if(r.normalTexture&&(r.normalTexture={...r.normalTexture},r.normalTexture.texture=this.getTexture(r.normalTexture.index)),r.occlusionTexture&&(r.occlusionTexture={...r.occlusionTexture},r.occlusionTexture.texture=this.getTexture(r.occlusionTexture.index)),r.emissiveTexture&&(r.emissiveTexture={...r.emissiveTexture},r.emissiveTexture.texture=this.getTexture(r.emissiveTexture.index)),r.emissiveFactor||(r.emissiveFactor=r.emissiveTexture?[1,1,1]:[0,0,0]),r.pbrMetallicRoughness){r.pbrMetallicRoughness={...r.pbrMetallicRoughness};let s=r.pbrMetallicRoughness;s.baseColorTexture&&(s.baseColorTexture={...s.baseColorTexture},s.baseColorTexture.texture=this.getTexture(s.baseColorTexture.index)),s.metallicRoughnessTexture&&(s.metallicRoughnessTexture={...s.metallicRoughnessTexture},s.metallicRoughnessTexture.texture=this.getTexture(s.metallicRoughnessTexture.index))}return r}_resolveAccessor(t,n){let r=XP(t.componentType),s=jP(t.type),i=r*s,o={...t,id:t.id||`accessor-${n}`,bytesPerComponent:r,components:s,bytesPerElement:i,value:void 0,bufferView:void 0,sparse:void 0};if(t.bufferView!==void 0&&(o.bufferView=this.getBufferView(t.bufferView)),o.bufferView){let c=o.bufferView.buffer,{ArrayType:a,byteLength:h}=jr(o,o.bufferView),l=(o.bufferView.byteOffset||0)+(o.byteOffset||0)+c.byteOffset,f=c.arrayBuffer.slice(l,l+h);o.bufferView.byteStride&&(f=this._getValueFromInterleavedBuffer(c,l,o.bufferView.byteStride,o.bytesPerElement,o.count)),o.value=new a(f)}return o}_getValueFromInterleavedBuffer(t,n,r,s,i){let o=new Uint8Array(i*s);for(let c=0;c<i;c++){let a=n+c*r;o.set(new Uint8Array(t.arrayBuffer.slice(a,a+s)),c*s)}return o.buffer}_resolveTexture(t,n){return{...t,id:t.id||`texture-${n}`,sampler:typeof t.sampler=="number"?this.getSampler(t.sampler):JP(),source:typeof t.source=="number"?this.getImage(t.source):void 0}}_resolveSampler(t,n){let r={id:t.id||`sampler-${n}`,...t,parameters:{}};for(let s in r){let i=this._enumSamplerParameter(s);i!==void 0&&(r.parameters[i]=r[s])}return r}_enumSamplerParameter(t){return YP[t]}_resolveImage(t,n){let r={...t,id:t.id||`image-${n}`,image:null,bufferView:t.bufferView!==void 0?this.getBufferView(t.bufferView):void 0},s=this.images[n];return s&&(r.image=s),r}_resolveBufferView(t,n){let r=t.buffer,s=this.buffers[r].arrayBuffer,i=this.buffers[r].byteOffset||0;return t.byteOffset&&(i+=t.byteOffset),{id:`bufferView-${n}`,...t,buffer:this.buffers[r],data:new Uint8Array(s,i,t.byteLength)}}_resolveCamera(t,n){let r={...t,id:t.id||`camera-${n}`};return r.perspective,r.orthographic,r}};function pi(e,t){return new c0().postProcess(e,t)}var kc={URI:0,EMBEDDED:1};function Vc(e,t,n,r){e.rotateYtoZ=!0;let s=(e.byteOffset||0)+(e.byteLength||0)-n;if(s===0)throw new Error("glTF byte length must be greater than 0.");return e.gltfUpAxis=r?.["3d-tiles"]&&r["3d-tiles"].assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y",e.gltfArrayBuffer=Rn(t,n,s),e.gltfByteOffset=0,e.gltfByteLength=s,n%4===0||console.warn(`${e.type}: embedded glb is not aligned to a 4-byte boundary.`),(e.byteOffset||0)+(e.byteLength||0)}async function qc(e,t,n,r){let s=n?.["3d-tiles"]||{};if(KP(e,t,n),s.loadGLTF){if(!r)return;if(e.gltfUrl){let{fetch:i}=r,o=await i(e.gltfUrl,n);e.gltfArrayBuffer=await o.arrayBuffer(),e.gltfByteOffset=0}if(e.gltfArrayBuffer){let i=await qt(e.gltfArrayBuffer,Kn,n,r);e.gltf=pi(i),e.gpuMemoryUsageInBytes=ai(e.gltf),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength}}}function KP(e,t,n){switch(t){case kc.URI:if(e.gltfArrayBuffer){let r=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),i=new TextDecoder().decode(r);e.gltfUrl=i.replace(/[\s\0]+$/,"")}delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case kc.EMBEDDED:break;default:throw new Error("b3dm: Illegal glTF format field")}}async function jA(e,t,n,r,s){n=ZP(e,t,n,r,s),await qc(e,kc.EMBEDDED,r,s);let i=e?.gltf?.extensions;return i&&i.CESIUM_RTC&&(e.rtcCenter=i.CESIUM_RTC.center),n}function ZP(e,t,n,r,s){n=Tn(e,t,n),n=Wr(e,t,n),n=Jr(e,t,n,r),n=Vc(e,t,n,r);let i=new Ve(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=i.getGlobalProperty("RTC_CENTER",v.FLOAT,3),n}async function KA(e,t,n,r,s){return n=QP(e,t,n,r,s),await qc(e,e.gltfFormat||0,r,s),n}function QP(e,t,n,r,s){if(n=Tn(e,t,n),e.version!==1)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);n=Wr(e,t,n);let i=new DataView(t);if(e.gltfFormat=i.getUint32(n,!0),n+=4,n=Jr(e,t,n,r),n=Vc(e,t,n,r),!e?.header?.featureTableJsonByteLength||e.header.featureTableJsonByteLength===0)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");let o=new Ve(e.featureTableJson,e.featureTableBinary),c=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=c,!Number.isFinite(c))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",v.FLOAT,3);let a=new Jn(e.batchTableJson,e.batchTableBinary,c);return $P(e,o,a,c),n}function $P(e,t,n,r){let s=new Array(r),i=new Z,o=new Z,c=new Z,a=new Z,h=new Wn,l=new ci,f=new Z,p={},u=new En,d=[],g=[],m=[],M=[];for(let E=0;E<r;E++){let A;if(t.hasProperty("POSITION"))A=t.getProperty("POSITION",v.FLOAT,3,E,i);else if(t.hasProperty("POSITION_QUANTIZED")){A=t.getProperty("POSITION_QUANTIZED",v.UNSIGNED_SHORT,3,E,i);let x=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",v.FLOAT,3);if(!x)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");let R=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",v.FLOAT,3);if(!R)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");let w=65535;for(let I=0;I<3;I++)A[I]=A[I]/w*R[I]+x[I]}if(!A)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");i.copy(A),p.translation=i,e.normalUp=t.getProperty("NORMAL_UP",v.FLOAT,3,E,d),e.normalRight=t.getProperty("NORMAL_RIGHT",v.FLOAT,3,E,g);let y=!1;if(e.normalUp){if(!e.normalRight)throw new Error("i3dm: Custom orientation requires both NORMAL_UP and NORMAL_RIGHT.");e.hasCustomOrientation=!0}else{if(e.octNormalUp=t.getProperty("NORMAL_UP_OCT32P",v.UNSIGNED_SHORT,2,E,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",v.UNSIGNED_SHORT,2,E,g),e.octNormalUp)throw e.octNormalRight?new Error("i3dm: oct-encoded orientation not implemented"):new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");e.eastNorthUp?(U.WGS84.eastNorthUpToFixedFrame(i,u),u.getRotationMatrix3(h)):h.identity()}y&&(a.copy(o).cross(c).normalize(),h.setColumn(0,o),h.setColumn(1,c),h.setColumn(2,a)),l.fromMatrix3(h),p.rotation=l,f.set(1,1,1);let T=t.getProperty("SCALE",v.FLOAT,1,E,m);Number.isFinite(T)&&f.multiplyByScalar(T);let _=t.getProperty("SCALE_NON_UNIFORM",v.FLOAT,3,E,d);_&&f.scale(_),p.scale=f;let L=t.getProperty("BATCH_ID",v.UNSIGNED_SHORT,1,E,M);L===void 0&&(L=E);let B=new En().fromQuaternion(p.rotation);u.identity(),u.translate(p.translation),u.multiplyRight(B),u.scale(p.scale);let S=u.clone();s[E]={modelMatrix:S,batchId:L}}e.instances=s}async function ZA(e,t,n,r,s,i){n=Tn(e,t,n);let o=new DataView(t);for(e.tilesLength=o.getUint32(n,!0),n+=4,e.tiles=[];e.tiles.length<e.tilesLength&&(e.byteLength||0)-n>12;){let c={shape:"tile3d"};e.tiles.push(c),n=await i(t,n,r,s,c)}return n}async function QA(e,t,n,r){if(e.rotateYtoZ=!0,e.gltfUpAxis=n?.["3d-tiles"]?.assetGltfUpAxis?n["3d-tiles"].assetGltfUpAxis:"Y",n?.["3d-tiles"]?.loadGLTF){if(!r)return t.byteLength;let s=await qt(t,Kn,n,r);e.gltf=pi(s),e.gpuMemoryUsageInBytes=ai(e.gltf)}else e.gltfArrayBuffer=t;return t.byteLength}async function a0(e,t=0,n,r,s={shape:"tile3d"}){switch(s.byteOffset=t,s.type=m2(e,t),s.type){case Vn.COMPOSITE:return await ZA(s,e,t,n,r,a0);case Vn.BATCHED_3D_MODEL:return await jA(s,e,t,n,r);case Vn.GLTF:return await QA(s,e,n,r);case Vn.INSTANCED_3D_MODEL:return await KA(s,e,t,n,r);case Vn.POINT_CLOUD:return await iA(s,e,t,n,r);default:throw new Error(`3DTileLoader: unknown type ${s.type}`)}}async function h0(e,t,n){if(new Uint32Array(e.slice(0,4))[0]!==1952609651)throw new Error("Wrong subtree file magic number");if(new Uint32Array(e.slice(4,8))[0]!==1)throw new Error("Wrong subtree file verson, must be 1");let i=$A(e.slice(8,16)),o=new Uint8Array(e,24,i),a=new TextDecoder("utf8").decode(o),h=JSON.parse(a),l=$A(e.slice(16,24)),f=new ArrayBuffer(0);if(l&&(f=e.slice(24+i)),await Hc(h,h.tileAvailability,f,n),Array.isArray(h.contentAvailability))for(let p of h.contentAvailability)await Hc(h,p,f,n);else await Hc(h,h.contentAvailability,f,n);return await Hc(h,h.childSubtreeAvailability,f,n),h}async function Hc(e,t,n,r){let s=Number.isFinite(t.bitstream)?t.bitstream:t.bufferView;if(typeof s!="number")return;let i=e.bufferViews[s],o=e.buffers[i.buffer];if(!r?.baseUrl)throw new Error("Url is not provided");if(!r.fetch)throw new Error("fetch is not provided");if(o.uri){let a=`${r?.baseUrl||""}/${o.uri}`,l=await(await r.fetch(a)).arrayBuffer();t.explicitBitstream=new Uint8Array(l,i.byteOffset,i.byteLength);return}let c=e.buffers.slice(0,i.buffer).reduce((a,h)=>a+h.byteLength,0);t.explicitBitstream=new Uint8Array(n.slice(c,c+o.byteLength),i.byteOffset,i.byteLength)}function $A(e){let t=new DataView(e),n=t.getUint32(0,!0),r=t.getUint32(4,!0);return n+2**32*r}var Yc={dataType:null,batchType:null,id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:cc,extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:h0,options:{}};var Ey=D(yr(),1);var xy=D(yr(),1);var $t=null;try{$t=new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([0,97,115,109,1,0,0,0,1,13,2,96,0,1,127,96,4,127,127,127,127,1,127,3,7,6,0,1,1,1,1,1,6,6,1,127,1,65,0,11,7,50,6,3,109,117,108,0,1,5,100,105,118,95,115,0,2,5,100,105,118,95,117,0,3,5,114,101,109,95,115,0,4,5,114,101,109,95,117,0,5,8,103,101,116,95,104,105,103,104,0,0,10,191,1,6,4,0,35,0,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,126,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,127,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,128,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,129,34,4,66,32,135,167,36,0,32,4,167,11,36,1,1,126,32,0,173,32,1,173,66,32,134,132,32,2,173,32,3,173,66,32,134,132,130,34,4,66,32,135,167,36,0,32,4,167,11])),{}).exports}catch{}function rt(e,t,n){this.low=e|0,this.high=t|0,this.unsigned=!!n}rt.prototype.__isLong__;Object.defineProperty(rt.prototype,"__isLong__",{value:!0});function Ft(e){return(e&&e.__isLong__)===!0}function ty(e){var t=Math.clz32(e&-e);return e?31-t:t}rt.isLong=Ft;var ey={},ny={};function Zn(e,t){var n,r,s;return t?(e>>>=0,(s=0<=e&&e<256)&&(r=ny[e],r)?r:(n=X(e,0,!0),s&&(ny[e]=n),n)):(e|=0,(s=-128<=e&&e<128)&&(r=ey[e],r)?r:(n=X(e,e<0?-1:0,!1),s&&(ey[e]=n),n))}rt.fromInt=Zn;function te(e,t){if(isNaN(e))return t?He:le;if(t){if(e<0)return He;if(e>=oy)return hy}else{if(e<=-sy)return Vt;if(e+1>=sy)return ay}return e<0?te(-e,t).neg():X(e%is|0,e/is|0,t)}rt.fromNumber=te;function X(e,t,n){return new rt(e,t,n)}rt.fromBits=X;var Wc=Math.pow;function f0(e,t,n){if(e.length===0)throw Error("empty string");if(typeof t=="number"?(n=t,t=!1):t=!!t,e==="NaN"||e==="Infinity"||e==="+Infinity"||e==="-Infinity")return t?He:le;if(n=n||10,n<2||36<n)throw RangeError("radix");var r;if((r=e.indexOf("-"))>0)throw Error("interior hyphen");if(r===0)return f0(e.substring(1),t,n).neg();for(var s=te(Wc(n,8)),i=le,o=0;o<e.length;o+=8){var c=Math.min(8,e.length-o),a=parseInt(e.substring(o,o+c),n);if(c<8){var h=te(Wc(n,c));i=i.mul(h).add(te(a))}else i=i.mul(s),i=i.add(te(a))}return i.unsigned=t,i}rt.fromString=f0;function fe(e,t){return typeof e=="number"?te(e,t):typeof e=="string"?f0(e,t):X(e.low,e.high,typeof t=="boolean"?t:e.unsigned)}rt.fromValue=fe;var ry=1<<16,tN=1<<24,is=ry*ry,oy=is*is,sy=oy/2,iy=Zn(tN),le=Zn(0);rt.ZERO=le;var He=Zn(0,!0);rt.UZERO=He;var ss=Zn(1);rt.ONE=ss;var cy=Zn(1,!0);rt.UONE=cy;var l0=Zn(-1);rt.NEG_ONE=l0;var ay=X(-1,2147483647,!1);rt.MAX_VALUE=ay;var hy=X(-1,-1,!0);rt.MAX_UNSIGNED_VALUE=hy;var Vt=X(0,-2147483648,!1);rt.MIN_VALUE=Vt;var b=rt.prototype;b.toInt=function(){return this.unsigned?this.low>>>0:this.low};b.toNumber=function(){return this.unsigned?(this.high>>>0)*is+(this.low>>>0):this.high*is+(this.low>>>0)};b.toString=function(t){if(t=t||10,t<2||36<t)throw RangeError("radix");if(this.isZero())return"0";if(this.isNegative())if(this.eq(Vt)){var n=te(t),r=this.div(n),s=r.mul(n).sub(this);return r.toString(t)+s.toInt().toString(t)}else return"-"+this.neg().toString(t);for(var i=te(Wc(t,6),this.unsigned),o=this,c="";;){var a=o.div(i),h=o.sub(a.mul(i)).toInt()>>>0,l=h.toString(t);if(o=a,o.isZero())return l+c;for(;l.length<6;)l="0"+l;c=""+l+c}};b.getHighBits=function(){return this.high};b.getHighBitsUnsigned=function(){return this.high>>>0};b.getLowBits=function(){return this.low};b.getLowBitsUnsigned=function(){return this.low>>>0};b.getNumBitsAbs=function(){if(this.isNegative())return this.eq(Vt)?64:this.neg().getNumBitsAbs();for(var t=this.high!=0?this.high:this.low,n=31;n>0&&!(t&1<<n);n--);return this.high!=0?n+33:n+1};b.isZero=function(){return this.high===0&&this.low===0};b.eqz=b.isZero;b.isNegative=function(){return!this.unsigned&&this.high<0};b.isPositive=function(){return this.unsigned||this.high>=0};b.isOdd=function(){return(this.low&1)===1};b.isEven=function(){return(this.low&1)===0};b.equals=function(t){return Ft(t)||(t=fe(t)),this.unsigned!==t.unsigned&&this.high>>>31===1&&t.high>>>31===1?!1:this.high===t.high&&this.low===t.low};b.eq=b.equals;b.notEquals=function(t){return!this.eq(t)};b.neq=b.notEquals;b.ne=b.notEquals;b.lessThan=function(t){return this.comp(t)<0};b.lt=b.lessThan;b.lessThanOrEqual=function(t){return this.comp(t)<=0};b.lte=b.lessThanOrEqual;b.le=b.lessThanOrEqual;b.greaterThan=function(t){return this.comp(t)>0};b.gt=b.greaterThan;b.greaterThanOrEqual=function(t){return this.comp(t)>=0};b.gte=b.greaterThanOrEqual;b.ge=b.greaterThanOrEqual;b.compare=function(t){if(Ft(t)||(t=fe(t)),this.eq(t))return 0;var n=this.isNegative(),r=t.isNegative();return n&&!r?-1:!n&&r?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.sub(t).isNegative()?-1:1};b.comp=b.compare;b.negate=function(){return!this.unsigned&&this.eq(Vt)?Vt:this.not().add(ss)};b.neg=b.negate;b.add=function(t){Ft(t)||(t=fe(t));var n=this.high>>>16,r=this.high&65535,s=this.low>>>16,i=this.low&65535,o=t.high>>>16,c=t.high&65535,a=t.low>>>16,h=t.low&65535,l=0,f=0,p=0,u=0;return u+=i+h,p+=u>>>16,u&=65535,p+=s+a,f+=p>>>16,p&=65535,f+=r+c,l+=f>>>16,f&=65535,l+=n+o,l&=65535,X(p<<16|u,l<<16|f,this.unsigned)};b.subtract=function(t){return Ft(t)||(t=fe(t)),this.add(t.neg())};b.sub=b.subtract;b.multiply=function(t){if(this.isZero())return this;if(Ft(t)||(t=fe(t)),$t){var n=$t.mul(this.low,this.high,t.low,t.high);return X(n,$t.get_high(),this.unsigned)}if(t.isZero())return this.unsigned?He:le;if(this.eq(Vt))return t.isOdd()?Vt:le;if(t.eq(Vt))return this.isOdd()?Vt:le;if(this.isNegative())return t.isNegative()?this.neg().mul(t.neg()):this.neg().mul(t).neg();if(t.isNegative())return this.mul(t.neg()).neg();if(this.lt(iy)&&t.lt(iy))return te(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,s=this.high&65535,i=this.low>>>16,o=this.low&65535,c=t.high>>>16,a=t.high&65535,h=t.low>>>16,l=t.low&65535,f=0,p=0,u=0,d=0;return d+=o*l,u+=d>>>16,d&=65535,u+=i*l,p+=u>>>16,u&=65535,u+=o*h,p+=u>>>16,u&=65535,p+=s*l,f+=p>>>16,p&=65535,p+=i*h,f+=p>>>16,p&=65535,p+=o*a,f+=p>>>16,p&=65535,f+=r*l+s*h+i*a+o*c,f&=65535,X(u<<16|d,f<<16|p,this.unsigned)};b.mul=b.multiply;b.divide=function(t){if(Ft(t)||(t=fe(t)),t.isZero())throw Error("division by zero");if($t){if(!this.unsigned&&this.high===-2147483648&&t.low===-1&&t.high===-1)return this;var n=(this.unsigned?$t.div_u:$t.div_s)(this.low,this.high,t.low,t.high);return X(n,$t.get_high(),this.unsigned)}if(this.isZero())return this.unsigned?He:le;var r,s,i;if(this.unsigned){if(t.unsigned||(t=t.toUnsigned()),t.gt(this))return He;if(t.gt(this.shru(1)))return cy;i=He}else{if(this.eq(Vt)){if(t.eq(ss)||t.eq(l0))return Vt;if(t.eq(Vt))return ss;var o=this.shr(1);return r=o.div(t).shl(1),r.eq(le)?t.isNegative()?ss:l0:(s=this.sub(t.mul(r)),i=r.add(s.div(t)),i)}else if(t.eq(Vt))return this.unsigned?He:le;if(this.isNegative())return t.isNegative()?this.neg().div(t.neg()):this.neg().div(t).neg();if(t.isNegative())return this.div(t.neg()).neg();i=le}for(s=this;s.gte(t);){r=Math.max(1,Math.floor(s.toNumber()/t.toNumber()));for(var c=Math.ceil(Math.log(r)/Math.LN2),a=c<=48?1:Wc(2,c-48),h=te(r),l=h.mul(t);l.isNegative()||l.gt(s);)r-=a,h=te(r,this.unsigned),l=h.mul(t);h.isZero()&&(h=ss),i=i.add(h),s=s.sub(l)}return i};b.div=b.divide;b.modulo=function(t){if(Ft(t)||(t=fe(t)),$t){var n=(this.unsigned?$t.rem_u:$t.rem_s)(this.low,this.high,t.low,t.high);return X(n,$t.get_high(),this.unsigned)}return this.sub(this.div(t).mul(t))};b.mod=b.modulo;b.rem=b.modulo;b.not=function(){return X(~this.low,~this.high,this.unsigned)};b.countLeadingZeros=function(){return this.high?Math.clz32(this.high):Math.clz32(this.low)+32};b.clz=b.countLeadingZeros;b.countTrailingZeros=function(){return this.low?ty(this.low):ty(this.high)+32};b.ctz=b.countTrailingZeros;b.and=function(t){return Ft(t)||(t=fe(t)),X(this.low&t.low,this.high&t.high,this.unsigned)};b.or=function(t){return Ft(t)||(t=fe(t)),X(this.low|t.low,this.high|t.high,this.unsigned)};b.xor=function(t){return Ft(t)||(t=fe(t)),X(this.low^t.low,this.high^t.high,this.unsigned)};b.shiftLeft=function(t){return Ft(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?X(this.low<<t,this.high<<t|this.low>>>32-t,this.unsigned):X(0,this.low<<t-32,this.unsigned)};b.shl=b.shiftLeft;b.shiftRight=function(t){return Ft(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?X(this.low>>>t|this.high<<32-t,this.high>>t,this.unsigned):X(this.high>>t-32,this.high>=0?0:-1,this.unsigned)};b.shr=b.shiftRight;b.shiftRightUnsigned=function(t){return Ft(t)&&(t=t.toInt()),(t&=63)===0?this:t<32?X(this.low>>>t|this.high<<32-t,this.high>>>t,this.unsigned):t===32?X(this.high,0,this.unsigned):X(this.high>>>t-32,0,this.unsigned)};b.shru=b.shiftRightUnsigned;b.shr_u=b.shiftRightUnsigned;b.rotateLeft=function(t){var n;return Ft(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?X(this.high,this.low,this.unsigned):t<32?(n=32-t,X(this.low<<t|this.high>>>n,this.high<<t|this.low>>>n,this.unsigned)):(t-=32,n=32-t,X(this.high<<t|this.low>>>n,this.low<<t|this.high>>>n,this.unsigned))};b.rotl=b.rotateLeft;b.rotateRight=function(t){var n;return Ft(t)&&(t=t.toInt()),(t&=63)===0?this:t===32?X(this.high,this.low,this.unsigned):t<32?(n=32-t,X(this.high<<n|this.low>>>t,this.low<<n|this.high>>>t,this.unsigned)):(t-=32,n=32-t,X(this.low<<n|this.high>>>t,this.high<<n|this.low>>>t,this.unsigned))};b.rotr=b.rotateRight;b.toSigned=function(){return this.unsigned?X(this.low,this.high,!1):this};b.toUnsigned=function(){return this.unsigned?this:X(this.low,this.high,!0)};b.toBytes=function(t){return t?this.toBytesLE():this.toBytesBE()};b.toBytesLE=function(){var t=this.high,n=this.low;return[n&255,n>>>8&255,n>>>16&255,n>>>24,t&255,t>>>8&255,t>>>16&255,t>>>24]};b.toBytesBE=function(){var t=this.high,n=this.low;return[t>>>24,t>>>16&255,t>>>8&255,t&255,n>>>24,n>>>16&255,n>>>8&255,n&255]};rt.fromBytes=function(t,n,r){return r?rt.fromBytesLE(t,n):rt.fromBytesBE(t,n)};rt.fromBytesLE=function(t,n){return new rt(t[0]|t[1]<<8|t[2]<<16|t[3]<<24,t[4]|t[5]<<8|t[6]<<16|t[7]<<24,n)};rt.fromBytesBE=function(t,n){return new rt(t[4]<<24|t[5]<<16|t[6]<<8|t[7],t[0]<<24|t[1]<<16|t[2]<<8|t[3],n)};var os=rt;var eN=16;function ui(e){e==="X"&&(e="");let t=e.padEnd(eN,"0");return os.fromString(t,!0,16)}function p0(e){if(e.isZero())return"X";let t=e.countTrailingZeros(),n=t%4;t=(t-n)/4;let r=t;t*=4;let i=e.shiftRightUnsigned(t).toString(16).replace(/0+$/,"");return Array(17-r-i.length).join("0")+i}function u0(e,t){let n=nN(e).shiftRightUnsigned(2);return e.add(os.fromNumber(2*t+1-4).multiply(n))}function nN(e){return e.and(e.not().add(1))}var rN=3,sN=30,iN=2*sN+1,ly=180/Math.PI;function py(e){if(e.length===0)throw new Error(`Invalid Hilbert quad key ${e}`);let t=e.split("/"),n=parseInt(t[0],10),r=t[1],s=r.length,i=0,o=[0,0];for(let c=s-1;c>=0;c--){i=s-c;let a=r[c],h=0,l=0;a==="1"?l=1:a==="2"?(h=1,l=1):a==="3"&&(h=1);let f=Math.pow(2,i-1);oN(f,o,h,l),o[0]+=f*h,o[1]+=f*l}if(n%2===1){let c=o[0];o[0]=o[1],o[1]=c}return{face:n,ij:o,level:i}}function uy(e){if(e.isZero())return"";let t=e.toString(2);for(;t.length<rN+iN;)t="0"+t;let n=t.lastIndexOf("1"),r=t.substring(0,3),s=t.substring(3,n),i=s.length/2,o=os.fromString(r,!0,2).toString(10),c="";if(i!==0)for(c=os.fromString(s,!0,2).toString(4);c.length<i;)c="0"+c;return`${o}/${c}`}function d0(e,t,n){let r=1<<t;return[(e[0]+n[0])/r,(e[1]+n[1])/r]}function fy(e){return e>=.5?1/3*(4*e*e-1):1/3*(1-4*(1-e)*(1-e))}function m0(e){return[fy(e[0]),fy(e[1])]}function g0(e,[t,n]){switch(e){case 0:return[1,t,n];case 1:return[-t,1,n];case 2:return[-t,-n,1];case 3:return[-1,-n,-t];case 4:return[n,-1,-t];case 5:return[n,t,-1];default:throw new Error("Invalid face")}}function x0([e,t,n]){let r=Math.atan2(n,Math.sqrt(e*e+t*t));return[Math.atan2(t,e)*ly,r*ly]}function oN(e,t,n,r){if(r===0){n===1&&(t[0]=e-1-t[0],t[1]=e-1-t[1]);let s=t[0];t[0]=t[1],t[1]=s}}function dy(e){let t=d0(e.ij,e.level,[.5,.5]),n=m0(t),r=g0(e.face,n);return x0(r)}var cN=100;function M0(e){let{face:t,ij:n,level:r}=e,s=[[0,0],[0,1],[1,1],[1,0],[0,0]],i=Math.max(1,Math.ceil(cN*Math.pow(2,-r))),o=new Float64Array(4*i*2+2),c=0,a=0;for(let h=0;h<4;h++){let l=s[h].slice(0),f=s[h+1],p=(f[0]-l[0])/i,u=(f[1]-l[1])/i;for(let d=0;d<i;d++){l[0]+=p,l[1]+=u;let g=d0(n,r,l),m=m0(g),M=g0(t,m),E=x0(M);Math.abs(E[1])>89.999&&(E[0]=a);let A=E[0]-a;E[0]+=A>180?-360:A<-180?360:0,o[c++]=E[0],o[c++]=E[1],a=E[0]}}return o[c++]=o[0],o[c++]=o[1],o}function cs(e){let t=aN(e);return py(t)}function aN(e){if(e.indexOf("/")>0)return e;let t=ui(e);return uy(t)}function A0(e){let t=cs(e);return dy(t)}function gy(e){let t;if(e.face===2||e.face===5){let n=null,r=0;for(let s=0;s<4;s++){let i=`${e.face}/${s}`,o=cs(i),c=M0(o);(typeof n>"u"||n===null)&&(n=new Float64Array(4*c.length)),n.set(c,r),r+=c.length}t=my(n)}else{let n=M0(e);t=my(n)}return t}function my(e){if(e.length%2!==0)throw new Error("Invalid corners");let t=[],n=[];for(let r=0;r<e.length;r+=2)t.push(e[r]),n.push(e[r+1]);return t.sort((r,s)=>r-s),n.sort((r,s)=>r-s),{west:t[0],east:t[t.length-1],north:n[n.length-1],south:n[0]}}function y0(e,t){let n=t?.minimumHeight||0,r=t?.maximumHeight||0,s=cs(e),i=gy(s),o=i.west,c=i.south,a=i.east,h=i.north,l=[];return l.push(new Z(o,h,n)),l.push(new Z(a,h,n)),l.push(new Z(a,c,n)),l.push(new Z(o,c,n)),l.push(new Z(o,h,r)),l.push(new Z(a,h,r)),l.push(new Z(a,c,r)),l.push(new Z(o,c,r)),l}function Jc(e){let t=e.token,n={minimumHeight:e.minimumHeight,maximumHeight:e.maximumHeight},r=y0(t,n),s=A0(t),i=s[0],o=s[1],c=U.WGS84.cartographicToCartesian([i,o,n.maximumHeight]),a=new Z(c[0],c[1],c[2]);r.push(a);let h=Yl(r);return[...h.center,...h.halfAxes]}var hN=4,lN=8,fN={QUADTREE:hN,OCTREE:lN};function pN(e,t,n){if(e?.box){let r=ui(e.s2VolumeInfo.token),s=u0(r,t),i=p0(s),o={...e.s2VolumeInfo};switch(o.token=i,n){case"OCTREE":let h=e.s2VolumeInfo,l=h.maximumHeight-h.minimumHeight,f=l/2,p=h.minimumHeight+l/2;h.minimumHeight=p-f,h.maximumHeight=p+f;break;default:break}return{box:Jc(o),s2VolumeInfo:o}}}async function T0(e){let{implicitOptions:t,parentData:n={mortonIndex:0,x:0,y:0,z:0},childIndex:r=0,s2VolumeBox:s,loaderOptions:i}=e,{subtree:o,level:c=0,globalData:a={level:0,mortonIndex:0,x:0,y:0,z:0}}=e,{subdivisionScheme:h,subtreeLevels:l,maximumLevel:f,contentUrlTemplate:p,subtreesUriTemplate:u,basePath:d}=t,g={children:[],lodMetricValue:0,contentUrl:""};if(!f)return La.once(`Missing 'maximumLevel' or 'availableLevels' property. The subtree ${p} won't be loaded...`),g;let m=c+a.level;if(m>f)return g;let M=fN[h],E=Math.log2(M),A=r&1,y=r>>1&1,T=r>>2&1,_=(M**c-1)/(M-1),L=Qn(n.mortonIndex,r,E),B=_+L,S=Qn(n.x,A,1),x=Qn(n.y,y,1),R=Qn(n.z,T,1),w=!1;c>=l&&(w=E0(o.childSubtreeAvailability,L));let I=Qn(a.x,S,c),C=Qn(a.y,x,c),P=Qn(a.z,R,c);if(w){let $=`${d}/${u}`,st=Xc($,m,I,C,P);o=await(0,xy.load)(st,Yc,i),a={mortonIndex:L,x:S,y:x,z:R,level:c},L=0,B=0,S=0,x=0,R=0,c=0}if(!E0(o.tileAvailability,B))return g;E0(o.contentAvailability,B)&&(g.contentUrl=Xc(p,m,I,C,P));let Q=c+1,q={mortonIndex:L,x:S,y:x,z:R};for(let $=0;$<M;$++){let st=pN(s,$,h),Ut=await T0({subtree:o,implicitOptions:t,loaderOptions:i,parentData:q,childIndex:$,level:Q,globalData:{...a},s2VolumeBox:st});if(Ut.contentUrl||Ut.children.length){let T3=m+1,_3=uN(Ut,T3,{childTileX:S,childTileY:x,childTileZ:R},t,s);g.children.push(_3)}}return g}function E0(e,t){let n;return Array.isArray(e)?(n=e[0],e.length>1&&La.once('Not supported extension "3DTILES_multiple_contents" has been detected')):n=e,"constant"in n?Boolean(n.constant):n.explicitBitstream?gN(t,n.explicitBitstream):!1}function uN(e,t,n,r,s){let{basePath:i,refine:o,getRefine:c,lodMetricType:a,getTileType:h,rootLodMetricValue:l,rootBoundingVolume:f}=r,p=e.contentUrl&&e.contentUrl.replace(`${i}/`,""),u=l/2**t,d=s?.box?{box:s.box}:f,g=dN(t,d,n);return{children:e.children,contentUrl:e.contentUrl,content:{uri:p},id:e.contentUrl,refine:c(o),type:h(e),lodMetricType:a,lodMetricValue:u,geometricError:u,transform:e.transform,boundingVolume:g}}function dN(e,t,n){if(t.region){let{childTileX:r,childTileY:s,childTileZ:i}=n,[o,c,a,h,l,f]=t.region,p=2**e,u=(a-o)/p,d=(h-c)/p,g=(f-l)/p,[m,M]=[o+u*r,o+u*(r+1)],[E,A]=[c+d*s,c+d*(s+1)],[y,T]=[l+g*i,l+g*(i+1)];return{region:[m,E,M,A,y,T]}}if(t.box)return t;throw new Error(`Unsupported bounding volume type ${JSON.stringify(t)}`)}function Qn(e,t,n){return(e<<n)+t}function Xc(e,t,n,r,s){let i=mN({level:t,x:n,y:r,z:s});return e.replace(/{level}|{x}|{y}|{z}/gi,o=>i[o])}function mN(e){let t={};for(let n in e)t[`{${n}}`]=e[n];return t}function gN(e,t){let n=Math.floor(e/8),r=e%8;return(t[n]>>r&1)===1}function S0(e,t=""){if(!t)return Zt.EMPTY;let r=t.split("?")[0].split(".").pop();switch(r){case"pnts":return Zt.POINTCLOUD;case"i3dm":case"b3dm":case"glb":case"gltf":return Zt.SCENEGRAPH;default:return r||Zt.EMPTY}}function B0(e){switch(e){case"REPLACE":case"replace":return It.REPLACE;case"ADD":case"add":return It.ADD;default:return e}}function _0(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){let r=new URL(e,`${t}/`);return decodeURI(r.toString())}else if(e.startsWith("/"))return e;return Ze.resolve(t,e)}function My(e,t){if(!e)return null;let n;if(e.content){let s=e.content.uri||e.content?.url;typeof s<"u"&&(n=_0(s,t))}return{...e,id:n,contentUrl:n,lodMetricType:ze.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:S0(e,n),refine:B0(e.refine)}}async function Ty(e,t,n){let r=null,s=yy(e.root);s&&e.root?r=await Ay(e.root,e,t,s,n):r=My(e.root,t);let i=[];for(i.push(r);i.length>0;){let o=i.pop()||{},c=o.children||[],a=[];for(let h of c){let l=yy(h),f;l?f=await Ay(h,e,t,l,n):f=My(h,t),f&&(a.push(f),i.push(f))}o.children=a}return r}async function Ay(e,t,n,r,s){let{subdivisionScheme:i,maximumLevel:o,availableLevels:c,subtreeLevels:a,subtrees:{uri:h}}=r,l=Xc(h,0,0,0,0),f=_0(l,n),p=await(0,Ey.load)(f,Yc,s),u=e.content?.uri,d=u?_0(u,n):"",g=t?.root?.refine,m=e.geometricError,M=e.boundingVolume.extensions?.["3DTILES_bounding_volume_S2"];if(M){let T={box:Jc(M),s2VolumeInfo:M};e.boundingVolume=T}let E=e.boundingVolume,A={contentUrlTemplate:d,subtreesUriTemplate:h,subdivisionScheme:i,subtreeLevels:a,maximumLevel:Number.isFinite(c)?c-1:o,refine:g,basePath:n,lodMetricType:ze.GEOMETRIC_ERROR,rootLodMetricValue:m,rootBoundingVolume:E,getTileType:S0,getRefine:B0};return await xN(e,n,p,A,s)}async function xN(e,t,n,r,s){if(!e)return null;let{children:i,contentUrl:o}=await T0({subtree:n,implicitOptions:r,loaderOptions:s}),c,a=null;return o&&(c=o,a={uri:o.replace(`${t}/`,"")}),{...e,id:c,contentUrl:c,lodMetricType:ze.GEOMETRIC_ERROR,lodMetricValue:e.geometricError,transformMatrix:e.transform,type:S0(e,c),refine:B0(e.refine),content:a||e.content,children:i}}function yy(e){return e?.extensions?.["3DTILES_implicit_tiling"]||e?.implicitTiling}var jc={dataType:null,batchType:null,id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:cc,extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:MN,options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function MN(e,t={},n){let r=t["3d-tiles"]||{},s;return r.isTileset==="auto"?s=n?.url&&n.url.indexOf(".json")!==-1:s=r.isTileset,s?AN(e,t,n):yN(e,t,n)}async function AN(e,t,n){let r=JSON.parse(new TextDecoder().decode(e)),s=n?.url||"",i=EN(s),o=await Ty(r,i,t||{});return{...r,shape:"tileset3d",loader:jc,url:s,queryString:n?.queryString||"",basePath:i,root:o||r.root,type:St.TILES3D,lodMetricType:ze.GEOMETRIC_ERROR,lodMetricValue:r.root?.geometricError||0}}async function yN(e,t,n){let r={content:{shape:"tile3d",featureIds:null}};return await a0(e,0,t,n,r.content),r.content}function EN(e){return Ze.dirname(e)}var _y=[0],TN={getPointColor:{type:"accessor",value:[0,0,0,255]},pointSize:1,data:"",loader:jc,onTilesetLoad:{type:"function",value:e=>{}},onTileLoad:{type:"function",value:e=>{}},onTileUnload:{type:"function",value:e=>{}},onTileError:{type:"function",value:(e,t,n)=>{}},_getMeshColor:{type:"function",value:e=>[255,255,255]}},di=class extends Sn.CompositeLayer{initializeState(){"onTileLoadFail"in this.props&&Sn.log.removed("onTileLoadFail","onTileError")(),this.state={layerMap:{},tileset3d:null,activeViewports:{},lastUpdatedViewports:null}}get isLoaded(){return Boolean(this.state?.tileset3d?.isLoaded()&&super.isLoaded)}shouldUpdateState({changeFlags:t}){return t.somethingChanged}updateState({props:t,oldProps:n,changeFlags:r}){if(t.data&&t.data!==n.data&&this._loadTileset(t.data),r.viewportChanged){let{activeViewports:s}=this.state;Object.keys(s).length&&(this._updateTileset(s),this.state.lastUpdatedViewports=s,this.state.activeViewports={})}if(r.propsChanged){let{layerMap:s}=this.state;for(let i in s)s[i].needsUpdate=!0}}activateViewport(t){let{activeViewports:n,lastUpdatedViewports:r}=this.state;this.internalState.viewport=t,n[t.id]=t;let s=r?.[t.id];(!s||!t.equals(s))&&(this.setChangeFlags({viewportChanged:!0}),this.setNeedsUpdate())}getPickingInfo({info:t,sourceLayer:n}){let r=n&&n.props.tile;return t.picked&&(t.object=r),t.sourceTile=r,t}filterSubLayer({layer:t,viewport:n}){let{tile:r}=t.props,{id:s}=n;return r.selected&&r.viewportIds.includes(s)}_updateAutoHighlight(t){let n=t.sourceTile,r=this.state.layerMap[n?.id];r&&r.layer&&r.layer.updateAutoHighlight(t)}async _loadTileset(t){let{loadOptions:n={}}=this.props,r=this.props.loader||this.props.loaders,s=Array.isArray(r)?r[0]:r,i={loadOptions:{...n}},o=t;if(s.preload){let h=await s.preload(t,n);h.url&&(o=h.url),h.headers&&(i.loadOptions.fetch={...i.loadOptions.fetch,headers:h.headers}),Object.assign(i,h)}let c=await(0,Ly.load)(o,s,i.loadOptions),a=new ri(c,{onTileLoad:this._onTileLoad.bind(this),onTileUnload:this._onTileUnload.bind(this),onTileError:this.props.onTileError,...i});this.setState({tileset3d:a,layerMap:{}}),this._updateTileset(this.state.activeViewports),this.props.onTilesetLoad(a)}_onTileLoad(t){let{lastUpdatedViewports:n}=this.state;this.props.onTileLoad(t),this._updateTileset(n),this.setNeedsUpdate()}_onTileUnload(t){delete this.state.layerMap[t.id],this.props.onTileUnload(t)}_updateTileset(t){if(!t)return;let{tileset3d:n}=this.state,{timeline:r}=this.context,s=Object.keys(t).length;!r||!s||!n||n.selectTiles(Object.values(t)).then(i=>{this.state.frameNumber!==i&&this.setState({frameNumber:i})})}_getSubLayer(t,n){if(!t.content)return null;switch(t.type){case Zt.POINTCLOUD:return this._makePointCloudLayer(t,n);case Zt.SCENEGRAPH:return this._make3DModelLayer(t);case Zt.MESH:return this._makeSimpleMeshLayer(t,n);default:throw new Error(`Tile3DLayer: Failed to render layer of type ${t.content.type}`)}}_makePointCloudLayer(t,n){let{attributes:r,pointCount:s,constantRGBA:i,cartographicOrigin:o,modelMatrix:c}=t.content,{positions:a,normals:h,colors:l}=r;if(!a)return null;let f=n&&n.props.data||{header:{vertexCount:s},attributes:{POSITION:a,NORMAL:h,COLOR_0:l}},{pointSize:p,getPointColor:u}=this.props,d=this.getSubLayerClass("pointcloud",By.PointCloudLayer);return new d({pointSize:p},this.getSubLayerProps({id:"pointcloud"}),{id:`${this.id}-pointcloud-${t.id}`,tile:t,data:f,coordinateSystem:Sn.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:o,modelMatrix:c,getColor:i||u,_offset:0})}_make3DModelLayer(t){let{gltf:n,instances:r,cartographicOrigin:s,modelMatrix:i}=t.content,o=this.getSubLayerClass("scenegraph",Cy.ScenegraphLayer);return new o({_lighting:"pbr"},this.getSubLayerProps({id:"scenegraph"}),{id:`${this.id}-scenegraph-${t.id}`,tile:t,data:r||_y,scenegraph:n,coordinateSystem:Sn.COORDINATE_SYSTEM.METER_OFFSETS,coordinateOrigin:s,modelMatrix:i,getTransformMatrix:c=>c.modelMatrix,getPosition:[0,0,0],_offset:0})}_makeSimpleMeshLayer(t,n){let r=t.content,{attributes:s,indices:i,modelMatrix:o,cartographicOrigin:c,coordinateSystem:a=Sn.COORDINATE_SYSTEM.METER_OFFSETS,material:h,featureIds:l}=r,{_getMeshColor:f}=this.props,p=n&&n.props.mesh||new Sy.Geometry({topology:"triangle-list",attributes:_N(s),indices:i}),u=this.getSubLayerClass("mesh",Yd);return new u(this.getSubLayerProps({id:"mesh"}),{id:`${this.id}-mesh-${t.id}`,tile:t,mesh:p,data:_y,getColor:f(t),pbrMaterial:h,modelMatrix:o,coordinateOrigin:c,coordinateSystem:a,featureIds:l,_offset:0})}renderLayers(){let{tileset3d:t,layerMap:n}=this.state;return t?t.tiles.map(r=>{let s=n[r.id]=n[r.id]||{tile:r},{layer:i}=s;return r.selected&&(i?s.needsUpdate&&(i=this._getSubLayer(r,i),s.needsUpdate=!1):i=this._getSubLayer(r)),s.layer=i,i}).filter(Boolean):null}};di.defaultProps=TN;di.layerName="Tile3DLayer";var Ry=di;function _N(e){let t={};return t.positions={...e.positions,value:new Float32Array(e.positions.value)},e.normals&&(t.normals=e.normals),e.texCoords&&(t.texCoords=e.texCoords),e.colors&&(t.colors=e.colors),e.uvRegions&&(t.uvRegions=e.uvRegions),t}var ta=D(ne(),1),I0=D(lo(),1),Fy=D(ne(),1);var SN=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function C0(e){return e>>1^-(e&1)}function BN(e){let t=0,n={};for(let[r,s]of SN){let i=s===8?e.getFloat64:e.getFloat32;n[r]=i.call(e,t,!0),t+=s}return{header:n,headerEndPosition:t}}function CN(e,t){let n=t,r=3,s=e.getUint32(n,!0),i=new Uint16Array(s*r);n+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,c=s*o,a=n,h=a+c,l=h+c,f=0,p=0,u=0;for(let d=0;d<s;d++)f+=C0(e.getUint16(a+o*d,!0)),p+=C0(e.getUint16(h+o*d,!0)),u+=C0(e.getUint16(l+o*d,!0)),i[d]=f,i[d+s]=p,i[d+s*2]=u;return n+=c*3,{vertexData:i,vertexDataEndPosition:n}}function mi(e,t,n,r,s=!0){let i;if(r===2?i=new Uint16Array(e,t,n):i=new Uint32Array(e,t,n),!s)return i;let o=0;for(let c=0;c<i.length;++c){let a=i[c];i[c]=o-a,a===0&&++o}return i}function LN(e,t,n){let r=n,s=3,o=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;r%o!==0&&(r+=o-r%o);let c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=c*3,h=mi(e.buffer,r,a,o);return r+=a*o,{triangleIndicesEndPosition:r,triangleIndices:h}}function RN(e,t,n){let r=n,s=3,o=t.length/s>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,c=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let a=mi(e.buffer,r,c,o,!1);r+=c*o;let h=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let l=mi(e.buffer,r,h,o,!1);r+=h*o;let f=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let p=mi(e.buffer,r,f,o,!1);r+=f*o;let u=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let d=mi(e.buffer,r,u,o,!1);return r+=u*o,{edgeIndicesEndPosition:r,westIndices:a,southIndices:l,eastIndices:p,northIndices:d}}function wN(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function IN(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function bN(e,t){let n={};if(e.byteLength<=t)return{extensions:n,extensionsEndPosition:t};let r=t;for(;r<e.byteLength;){let s=e.getUint8(r,!0);r+=Uint8Array.BYTES_PER_ELEMENT;let i=e.getUint32(r,!0);r+=Uint32Array.BYTES_PER_ELEMENT;let o=new DataView(e.buffer,r,i);switch(s){case 1:{n.vertexNormals=wN(o);break}case 2:{n.waterMask=IN(o);break}default:}r+=i}return{extensions:n,extensionsEndPosition:r}}var $n={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},ON={maxDecodingStep:$n.extensions};function L0(e,t){let n=Object.assign({},ON,t),r=new DataView(e),{header:s,headerEndPosition:i}=BN(r);if(n.maxDecodingStep<$n.vertices)return{header:s};let{vertexData:o,vertexDataEndPosition:c}=CN(r,i);if(n.maxDecodingStep<$n.triangleIndices)return{header:s,vertexData:o};let{triangleIndices:a,triangleIndicesEndPosition:h}=LN(r,o,c);if(n.maxDecodingStep<$n.edgeIndices)return{header:s,vertexData:o,triangleIndices:a};let{westIndices:l,southIndices:f,eastIndices:p,northIndices:u,edgeIndicesEndPosition:d}=RN(r,o,h);if(n.maxDecodingStep<$n.extensions)return{header:s,vertexData:o,triangleIndices:a,westIndices:l,northIndices:u,eastIndices:p,southIndices:f};let{extensions:g}=bN(r,d);return{header:s,vertexData:o,triangleIndices:a,westIndices:l,northIndices:u,eastIndices:p,southIndices:f,extensions:g}}function Kc(e,t,n,r){let s=r?NN(r,e.POSITION.value):PN(t),i=new e.POSITION.value.constructor(s.length*6),o=new e.TEXCOORD_0.value.constructor(s.length*4),c=new t.constructor(s.length*6);for(let h=0;h<s.length;h++){let l=s[h];FN({edge:l,edgeIndex:h,attributes:e,skirtHeight:n,newPosition:i,newTexcoord0:o,newTriangles:c})}e.POSITION.value=Ms(e.POSITION.value,i),e.TEXCOORD_0.value=Ms(e.TEXCOORD_0.value,o);let a=t instanceof Array?t.concat(c):Ms(t,c);return{attributes:e,triangles:a}}function PN(e){let t=[];for(let s=0;s<e.length;s+=3)t.push([e[s],e[s+1]]),t.push([e[s+1],e[s+2]]),t.push([e[s+2],e[s]]);t.sort((s,i)=>Math.min(...s)-Math.min(...i)||Math.max(...s)-Math.max(...i));let n=[],r=0;for(;r<t.length;)t[r][0]===t[r+1]?.[1]&&t[r][1]===t[r+1]?.[0]?r+=2:(n.push(t[r]),r++);return n}function NN(e,t){e.westIndices.sort((r,s)=>t[3*r+1]-t[3*s+1]),e.eastIndices.sort((r,s)=>t[3*s+1]-t[3*r+1]),e.southIndices.sort((r,s)=>t[3*s]-t[3*r]),e.northIndices.sort((r,s)=>t[3*r]-t[3*s]);let n=[];for(let r in e){let s=e[r];for(let i=0;i<s.length-1;i++)n.push([s[i],s[i+1]])}return n}function FN({edge:e,edgeIndex:t,attributes:n,skirtHeight:r,newPosition:s,newTexcoord0:i,newTriangles:o}){let c=n.POSITION.value.length,a=t*2,h=t*2+1;s.set(n.POSITION.value.subarray(e[0]*3,e[0]*3+3),a*3),s[a*3+2]=s[a*3+2]-r,s.set(n.POSITION.value.subarray(e[1]*3,e[1]*3+3),h*3),s[h*3+2]=s[h*3+2]-r,i.set(n.TEXCOORD_0.value.subarray(e[0]*2,e[0]*2+2),a*2),i.set(n.TEXCOORD_0.value.subarray(e[1]*2,e[1]*2+2),h*2);let l=t*2*3;o[l]=e[0],o[l+1]=c/3+h,o[l+2]=e[1],o[l+3]=c/3+h,o[l+4]=e[0],o[l+5]=c/3+a}function R0(e,t={}){let{bounds:n}=t,{header:r,vertexData:s,triangleIndices:i,westIndices:o,northIndices:c,eastIndices:a,southIndices:h}=L0(e,$n.triangleIndices),l=i,f=vN(s,r,n),p=qn(f);if(t?.skirtHeight){let{attributes:u,triangles:d}=Kc(f,l,t.skirtHeight,{westIndices:o,northIndices:c,eastIndices:a,southIndices:h});f=u,l=d}return{loaderData:{header:{}},header:{vertexCount:l.length,boundingBox:p},schema:void 0,topology:"triangle-list",mode:4,indices:{value:l,size:1},attributes:f}}function vN(e,t,n){let{minHeight:r,maxHeight:s}=t,[i,o,c,a]=n||[0,0,1,1],h=c-i,l=a-o,f=s-r,p=e.length/3,u=new Float32Array(p*3),d=new Float32Array(p*2);for(let g=0;g<p;g++){let m=e[g]/32767,M=e[g+p]/32767,E=e[g+p*2]/32767;u[3*g+0]=m*h+i,u[3*g+1]=M*l+o,u[3*g+2]=E*f+r,d[2*g+0]=m,d[2*g+1]=M}return{POSITION:{value:u,size:3},TEXCOORD_0:{value:d,size:2}}}var gi=class{constructor(t=257){this.gridSize=t;let n=t-1;if(n&n-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=n*n*2-2,this.numParentTriangles=this.numTriangles-n*n,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let r=0;r<this.numTriangles;r++){let s=r+2,i=0,o=0,c=0,a=0,h=0,l=0;for(s&1?c=a=h=n:i=o=l=n;(s>>=1)>1;){let p=i+c>>1,u=o+a>>1;s&1?(c=i,a=o,i=h,o=l):(i=c,o=a,c=h,a=l),h=p,l=u}let f=r*4;this.coords[f+0]=i,this.coords[f+1]=o,this.coords[f+2]=c,this.coords[f+3]=a}}createTile(t){return new w0(t,this)}},w0=class{constructor(t,n){let r=n.gridSize;if(t.length!==r*r)throw new Error(`Expected terrain data of length ${r*r} (${r} x ${r}), got ${t.length}.`);this.terrain=t,this.martini=n,this.errors=new Float32Array(t.length),this.update()}update(){let{numTriangles:t,numParentTriangles:n,coords:r,gridSize:s}=this.martini,{terrain:i,errors:o}=this;for(let c=t-1;c>=0;c--){let a=c*4,h=r[a+0],l=r[a+1],f=r[a+2],p=r[a+3],u=h+f>>1,d=l+p>>1,g=u+d-l,m=d+h-u,M=(i[l*s+h]+i[p*s+f])/2,E=d*s+u,A=Math.abs(M-i[E]);if(o[E]=Math.max(o[E],A),c<n){let y=(l+m>>1)*s+(h+g>>1),T=(p+m>>1)*s+(f+g>>1);o[E]=Math.max(o[E],o[y],o[T])}}}getMesh(t=0){let{gridSize:n,indices:r}=this.martini,{errors:s}=this,i=0,o=0,c=n-1;r.fill(0);function a(u,d,g,m,M,E){let A=u+g>>1,y=d+m>>1;Math.abs(u-M)+Math.abs(d-E)>1&&s[y*n+A]>t?(a(M,E,u,d,A,y),a(g,m,M,E,A,y)):(r[d*n+u]=r[d*n+u]||++i,r[m*n+g]=r[m*n+g]||++i,r[E*n+M]=r[E*n+M]||++i,o++)}a(0,0,c,c,c,0),a(c,c,0,0,0,c);let h=new Uint16Array(i*2),l=new Uint32Array(o*3),f=0;function p(u,d,g,m,M,E){let A=u+g>>1,y=d+m>>1;if(Math.abs(u-M)+Math.abs(d-E)>1&&s[y*n+A]>t)p(M,E,u,d,A,y),p(g,m,M,E,A,y);else{let T=r[d*n+u]-1,_=r[m*n+g]-1,L=r[E*n+M]-1;h[2*T]=u,h[2*T+1]=d,h[2*_]=g,h[2*_+1]=m,h[2*L]=M,h[2*L+1]=E,l[f++]=T,l[f++]=_,l[f++]=L}}return p(0,0,c,c,c,0),p(c,c,0,0,0,c),{vertices:h,triangles:l}}};var xi=class{constructor(t,n,r=n){this.data=t,this.width=n,this.height=r,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let s=n-1,i=r-1,o=this._addPoint(0,0),c=this._addPoint(s,0),a=this._addPoint(0,i),h=this._addPoint(s,i),l=this._addTriangle(h,o,a,-1,-1,-1);this._addTriangle(o,h,c,l,-1,-1),this._flush()}run(t=1){for(;this.getMaxError()>t;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(t,n){return this.data[this.width*n+t]}_flush(){let t=this.coords;for(let n=0;n<this._pendingLen;n++){let r=this._pending[n],s=2*this.triangles[r*3+0],i=2*this.triangles[r*3+1],o=2*this.triangles[r*3+2];this._findCandidate(t[s],t[s+1],t[i],t[i+1],t[o],t[o+1],r)}this._pendingLen=0}_findCandidate(t,n,r,s,i,o,c){let a=Math.min(t,r,i),h=Math.min(n,s,o),l=Math.max(t,r,i),f=Math.max(n,s,o),p=tr(r,s,i,o,a,h),u=tr(i,o,t,n,a,h),d=tr(t,n,r,s,a,h),g=s-n,m=t-r,M=o-s,E=r-i,A=n-o,y=i-t,T=tr(t,n,r,s,i,o),_=this.heightAt(t,n)/T,L=this.heightAt(r,s)/T,B=this.heightAt(i,o)/T,S=0,x=0,R=0,w=0;for(let I=h;I<=f;I++){let C=0;p<0&&M!==0&&(C=Math.max(C,Math.floor(-p/M))),u<0&&A!==0&&(C=Math.max(C,Math.floor(-u/A))),d<0&&g!==0&&(C=Math.max(C,Math.floor(-d/g)));let P=p+M*C,V=u+A*C,G=d+g*C,Q=!1;for(let q=a+C;q<=l;q++){if(P>=0&&V>=0&&G>=0){Q=!0;let $=_*P+L*V+B*G,st=Math.abs($-this.heightAt(q,I));w+=st*st,st>S&&(S=st,x=q,R=I)}else if(Q)break;P+=M,V+=A,G+=g}p+=E,u+=y,d+=m}(x===t&&R===n||x===r&&R===s||x===i&&R===o)&&(S=0),this._candidates[2*c]=x,this._candidates[2*c+1]=R,this._rms[c]=w,this._queuePush(c,S,w)}_step(){let t=this._queuePop(),n=t*3+0,r=t*3+1,s=t*3+2,i=this.triangles[n],o=this.triangles[r],c=this.triangles[s],a=this.coords[2*i],h=this.coords[2*i+1],l=this.coords[2*o],f=this.coords[2*o+1],p=this.coords[2*c],u=this.coords[2*c+1],d=this._candidates[2*t],g=this._candidates[2*t+1],m=this._addPoint(d,g);if(tr(a,h,l,f,d,g)===0)this._handleCollinear(m,n);else if(tr(l,f,p,u,d,g)===0)this._handleCollinear(m,r);else if(tr(p,u,a,h,d,g)===0)this._handleCollinear(m,s);else{let M=this._halfedges[n],E=this._halfedges[r],A=this._halfedges[s],y=this._addTriangle(i,o,m,M,-1,-1,n),T=this._addTriangle(o,c,m,E,-1,y+1),_=this._addTriangle(c,i,m,A,y+2,T+1);this._legalize(y),this._legalize(T),this._legalize(_)}}_addPoint(t,n){let r=this.coords.length>>1;return this.coords.push(t,n),r}_addTriangle(t,n,r,s,i,o,c=this.triangles.length){let a=c/3;return this.triangles[c+0]=t,this.triangles[c+1]=n,this.triangles[c+2]=r,this._halfedges[c+0]=s,this._halfedges[c+1]=i,this._halfedges[c+2]=o,s>=0&&(this._halfedges[s]=c+0),i>=0&&(this._halfedges[i]=c+1),o>=0&&(this._halfedges[o]=c+2),this._candidates[2*a+0]=0,this._candidates[2*a+1]=0,this._queueIndices[a]=-1,this._rms[a]=0,this._pending[this._pendingLen++]=a,c}_legalize(t){let n=this._halfedges[t];if(n<0)return;let r=t-t%3,s=n-n%3,i=r+(t+1)%3,o=r+(t+2)%3,c=s+(n+2)%3,a=s+(n+1)%3,h=this.triangles[o],l=this.triangles[t],f=this.triangles[i],p=this.triangles[c],u=this.coords;if(!DN(u[2*h],u[2*h+1],u[2*l],u[2*l+1],u[2*f],u[2*f+1],u[2*p],u[2*p+1]))return;let d=this._halfedges[i],g=this._halfedges[o],m=this._halfedges[c],M=this._halfedges[a];this._queueRemove(r/3),this._queueRemove(s/3);let E=this._addTriangle(h,p,f,-1,m,d,r),A=this._addTriangle(p,h,l,E,g,M,s);this._legalize(E+1),this._legalize(A+2)}_handleCollinear(t,n){let r=n-n%3,s=r+(n+1)%3,i=r+(n+2)%3,o=this.triangles[i],c=this.triangles[n],a=this.triangles[s],h=this._halfedges[s],l=this._halfedges[i],f=this._halfedges[n];if(f<0){let _=this._addTriangle(t,o,c,-1,l,-1,r),L=this._addTriangle(o,t,a,_,-1,h);this._legalize(_+1),this._legalize(L+2);return}let p=f-f%3,u=p+(f+2)%3,d=p+(f+1)%3,g=this.triangles[u],m=this._halfedges[u],M=this._halfedges[d];this._queueRemove(p/3);let E=this._addTriangle(o,c,t,l,-1,-1,r),A=this._addTriangle(c,g,t,M,-1,E+1,p),y=this._addTriangle(g,a,t,m,-1,A+1),T=this._addTriangle(a,o,t,h,E+2,y+1);this._legalize(E),this._legalize(A),this._legalize(y),this._legalize(T)}_queuePush(t,n,r){let s=this._queue.length;this._queueIndices[t]=s,this._queue.push(t),this._errors.push(n),this._rmsSum+=r,this._queueUp(s)}_queuePop(){let t=this._queue.length-1;return this._queueSwap(0,t),this._queueDown(0,t),this._queuePopBack()}_queuePopBack(){let t=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[t],this._queueIndices[t]=-1,t}_queueRemove(t){let n=this._queueIndices[t];if(n<0){let s=this._pending.indexOf(t);if(s!==-1)this._pending[s]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let r=this._queue.length-1;r!==n&&(this._queueSwap(n,r),this._queueDown(n,r)||this._queueUp(n)),this._queuePopBack()}_queueLess(t,n){return this._errors[t]>this._errors[n]}_queueSwap(t,n){let r=this._queue[t],s=this._queue[n];this._queue[t]=s,this._queue[n]=r,this._queueIndices[r]=n,this._queueIndices[s]=t;let i=this._errors[t];this._errors[t]=this._errors[n],this._errors[n]=i}_queueUp(t){let n=t;for(;;){let r=n-1>>1;if(r===n||!this._queueLess(n,r))break;this._queueSwap(r,n),n=r}}_queueDown(t,n){let r=t;for(;;){let s=2*r+1;if(s>=n||s<0)break;let i=s+1,o=s;if(i<n&&this._queueLess(i,s)&&(o=i),!this._queueLess(o,r))break;this._queueSwap(r,o),r=o}return r>t}};function tr(e,t,n,r,s,i){return(n-s)*(t-i)-(r-i)*(e-s)}function DN(e,t,n,r,s,i,o,c){let a=e-o,h=t-c,l=n-o,f=r-c,p=s-o,u=i-c,d=a*a+h*h,g=l*l+f*f,m=p*p+u*u;return a*(f*m-g*u)-h*(l*m-g*p)+d*(l*u-f*p)<0}function by(e,t){let{meshMaxError:n,bounds:r,elevationDecoder:s}=t,{data:i,width:o,height:c}=e,a,h;switch(t.tesselator){case"martini":a=Zc(i,o,c,s,t.tesselator),h=wy(n,o,a);break;case"delatin":a=Zc(i,o,c,s,t.tesselator),h=Iy(n,o,c,a);break;default:o===c&&!(c&o-1)?(a=Zc(i,o,c,s,"martini"),h=wy(n,o,a)):(a=Zc(i,o,c,s,"delatin"),h=Iy(n,o,c,a));break}let{vertices:l}=h,{triangles:f}=h,p=UN(l,a,o,c,r),u=qn(p);if(t.skirtHeight){let{attributes:d,triangles:g}=Kc(p,f,t.skirtHeight);p=d,f=g}return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:u},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:p}}function wy(e,t,n){let r=t+1,i=new gi(r).createTile(n),{vertices:o,triangles:c}=i.getMesh(e);return{vertices:o,triangles:c}}function Iy(e,t,n,r){let s=new xi(r,t+1,n+1);s.run(e);let{coords:i,triangles:o}=s;return{vertices:i,triangles:o}}function Zc(e,t,n,r,s){let{rScaler:i,bScaler:o,gScaler:c,offset:a}=r,h=new Float32Array((t+1)*(n+1));for(let l=0,f=0;f<n;f++)for(let p=0;p<t;p++,l++){let u=l*4,d=e[u+0],g=e[u+1],m=e[u+2];h[l+f]=d*i+g*c+m*o+a}if(s==="martini"){for(let l=(t+1)*t,f=0;f<t;f++,l++)h[l]=h[l-t-1];for(let l=n,f=0;f<n+1;f++,l+=n+1)h[l]=h[l-1]}return h}function UN(e,t,n,r,s){let i=n+1,o=e.length/2,c=new Float32Array(o*3),a=new Float32Array(o*2),[h,l,f,p]=s||[0,0,n,r],u=(f-h)/n,d=(p-l)/r;for(let g=0;g<o;g++){let m=e[g*2],M=e[g*2+1],E=M*i+m;c[3*g+0]=m*u+h,c[3*g+1]=-M*d+p,c[3*g+2]=t[E],a[2*g+0]=m/n,a[2*g+1]=M/r}return{POSITION:{value:c,size:3},TEXCOORD_0:{value:a,size:2}}}var Qc="4.2.1";var $c={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:Qc,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var Oy={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:Qc,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var GN={...$c,parse:zN};async function zN(e,t,n){let r={...t,mimeType:"application/x.image",image:{...t?.image,type:"data"}},s=await qt(e,[],r,n),i={...GN.options.terrain,...t?.terrain};return by(s,i)}var Ttt={...Oy,parseSync:(e,t)=>R0(e,t?.["quantized-mesh"]),parse:async(e,t)=>R0(e,t?.["quantized-mesh"])};var Py=[1],kN={...Dn.defaultProps,elevationData:cn,texture:{...cn,optional:!0},meshMaxError:{type:"number",value:4},bounds:{type:"array",value:null,optional:!0,compare:!0},color:{type:"color",value:[255,255,255]},elevationDecoder:{type:"object",value:{rScaler:1,gScaler:0,bScaler:0,offset:0}},workerUrl:"",wireframe:!1,material:!0,loaders:[$c]};function Ny(e){return Array.isArray(e)?e.join(";"):e||""}var Mi=class extends ta.CompositeLayer{updateState({props:t,oldProps:n}){let r=t.elevationData!==n.elevationData;if(r){let{elevationData:i}=t,o=i&&(Array.isArray(i)||i.includes("{x}")&&i.includes("{y}"));this.setState({isTiled:o})}let s=r||t.meshMaxError!==n.meshMaxError||t.elevationDecoder!==n.elevationDecoder||t.bounds!==n.bounds;if(!this.state.isTiled&&s){let i=this.loadTerrain(t);this.setState({terrain:i})}t.workerUrl&&ta.log.removed("workerUrl","loadOptions.terrain.workerUrl")()}loadTerrain({elevationData:t,bounds:n,elevationDecoder:r,meshMaxError:s,signal:i}){if(!t)return null;let o=this.getLoadOptions();o={...o,terrain:{skirtHeight:this.state.isTiled?s*2:0,...o?.terrain,bounds:n,meshMaxError:s,elevationDecoder:r}};let{fetch:c}=this.props;return c(t,{propName:"elevationData",layer:this,loadOptions:o,signal:i})}getTiledTerrainData(t){let{elevationData:n,fetch:r,texture:s,elevationDecoder:i,meshMaxError:o}=this.props,{viewport:c}=this.context,a=Te(n,t),h=s&&Te(s,t),{signal:l}=t,f=[0,0],p=[0,0];if(c.isGeospatial){let m=t.bbox;f=c.projectFlat([m.west,m.south]),p=c.projectFlat([m.east,m.north])}else{let m=t.bbox;f=[m.left,m.bottom],p=[m.right,m.top]}let u=[f[0],f[1],p[0],p[1]],d=this.loadTerrain({elevationData:a,bounds:u,elevationDecoder:i,meshMaxError:o,signal:l}),g=h?r(h,{propName:"texture",layer:this,loaders:[],signal:l}).catch(m=>null):Promise.resolve(null);return Promise.all([d,g])}renderSubLayers(t){let n=this.getSubLayerClass("mesh",I0.SimpleMeshLayer),{color:r,wireframe:s,material:i}=this.props,{data:o}=t;if(!o)return null;let[c,a]=o;return new n(t,{data:Py,mesh:c,texture:a,_instanced:!1,coordinateSystem:Fy.COORDINATE_SYSTEM.CARTESIAN,getPosition:h=>[0,0,0],getColor:r,wireframe:s,material:i})}onViewportLoad(t){if(!t)return;let{zRange:n}=this.state,r=t.map(o=>o.content).filter(Boolean).map(o=>o[0].header.boundingBox.map(a=>a[2]));if(r.length===0)return;let s=Math.min(...r.map(o=>o[0])),i=Math.max(...r.map(o=>o[1]));(!n||s<n[0]||i>n[1])&&this.setState({zRange:[s,i]})}renderLayers(){let{color:t,material:n,elevationData:r,texture:s,wireframe:i,meshMaxError:o,elevationDecoder:c,tileSize:a,maxZoom:h,minZoom:l,extent:f,maxRequests:p,onTileLoad:u,onTileUnload:d,onTileError:g,maxCacheSize:m,maxCacheByteSize:M,refinementStrategy:E}=this.props;if(this.state.isTiled)return new Dn(this.getSubLayerProps({id:"tiles"}),{getTileData:this.getTiledTerrainData.bind(this),renderSubLayers:this.renderSubLayers.bind(this),updateTriggers:{getTileData:{elevationData:Ny(r),texture:Ny(s),meshMaxError:o,elevationDecoder:c}},onViewportLoad:this.onViewportLoad.bind(this),zRange:this.state.zRange||null,tileSize:a,maxZoom:h,minZoom:l,extent:f,maxRequests:p,onTileLoad:u,onTileUnload:d,onTileError:g,maxCacheSize:m,maxCacheByteSize:M,refinementStrategy:E});if(!r)return null;let A=this.getSubLayerClass("mesh",I0.SimpleMeshLayer);return new A(this.getSubLayerProps({id:"mesh"}),{data:Py,mesh:this.state.terrain,texture:s,_instanced:!1,getPosition:y=>[0,0,0],getColor:t,material:n,wireframe:i})}};Mi.defaultProps=kN;Mi.layerName="TerrainLayer";var vy=Mi;var ga=D(ne(),1),j0=D(ee(),1),g3=D(Uy(),1);var Ai={x:0,y:1,z:2};function er(e,t={}){let{start:n=0,end:r=e.length,plane:s="xy"}=t,i=t.size||2,o=0,c=Ai[s[0]],a=Ai[s[1]];for(let h=n,l=r-i;h<r;h+=i)o+=(e[h+c]-e[l+c])*(e[h+a]+e[l+a]),l=h;return o/2}function O0(e,t,n=2,r,s="xy"){let i=t&&t.length,o=i?t[0]*n:e.length,c=zy(e,0,o,n,!0,r&&r[0],s),a=[];if(!c||c.next===c.prev)return a;let h,l,f,p,u,d,g;if(i&&(c=XN(e,t,c,n,r,s)),e.length>80*n){p=l=e[0],u=f=e[1];for(let m=n;m<o;m+=n)d=e[m],g=e[m+1],d<p&&(p=d),g<u&&(u=g),d>l&&(l=d),g>f&&(f=g);h=Math.max(l-p,f-u),h=h!==0?32767/h:0}return yi(c,a,n,p,u,h,0),a}function zy(e,t,n,r,s,i,o){let c,a;i===void 0&&(i=er(e,{start:t,end:n,size:r,plane:o}));let h=Ai[o[0]],l=Ai[o[1]];if(s===i<0)for(c=t;c<n;c+=r)a=Gy(c,e[c+h],e[c+l],a);else for(c=n-r;c>=t;c-=r)a=Gy(c,e[c+h],e[c+l],a);return a&&ra(a,a.next)&&(Ti(a),a=a.next),a}function nr(e,t){if(!e)return e;t||(t=e);let n=e,r;do if(r=!1,!n.steiner&&(ra(n,n.next)||lt(n.prev,n,n.next)===0)){if(Ti(n),n=t=n.prev,n===n.next)break;r=!0}else n=n.next;while(r||n!==t);return t}function yi(e,t,n,r,s,i,o){if(!e)return;!o&&i&&$N(e,r,s,i);let c=e,a,h;for(;e.prev!==e.next;){if(a=e.prev,h=e.next,i?YN(e,r,s,i):HN(e)){t.push(a.i/n|0),t.push(e.i/n|0),t.push(h.i/n|0),Ti(e),e=h.next,c=h.next;continue}if(e=h,e===c){o?o===1?(e=WN(nr(e),t,n),yi(e,t,n,r,s,i,2)):o===2&&JN(e,t,n,r,s,i):yi(nr(e),t,n,r,s,i,1);break}}}function HN(e){let t=e.prev,n=e,r=e.next;if(lt(t,n,r)>=0)return!1;let s=t.x,i=n.x,o=r.x,c=t.y,a=n.y,h=r.y,l=s<i?s<o?s:o:i<o?i:o,f=c<a?c<h?c:h:a<h?a:h,p=s>i?s>o?s:o:i>o?i:o,u=c>a?c>h?c:h:a>h?a:h,d=r.next;for(;d!==t;){if(d.x>=l&&d.x<=p&&d.y>=f&&d.y<=u&&as(s,c,i,a,o,h,d.x,d.y)&&lt(d.prev,d,d.next)>=0)return!1;d=d.next}return!0}function YN(e,t,n,r){let s=e.prev,i=e,o=e.next;if(lt(s,i,o)>=0)return!1;let c=s.x,a=i.x,h=o.x,l=s.y,f=i.y,p=o.y,u=c<a?c<h?c:h:a<h?a:h,d=l<f?l<p?l:p:f<p?f:p,g=c>a?c>h?c:h:a>h?a:h,m=l>f?l>p?l:p:f>p?f:p,M=b0(u,d,t,n,r),E=b0(g,m,t,n,r),A=e.prevZ,y=e.nextZ;for(;A&&A.z>=M&&y&&y.z<=E;){if(A.x>=u&&A.x<=g&&A.y>=d&&A.y<=m&&A!==s&&A!==o&&as(c,l,a,f,h,p,A.x,A.y)&&lt(A.prev,A,A.next)>=0||(A=A.prevZ,y.x>=u&&y.x<=g&&y.y>=d&&y.y<=m&&y!==s&&y!==o&&as(c,l,a,f,h,p,y.x,y.y)&&lt(y.prev,y,y.next)>=0))return!1;y=y.nextZ}for(;A&&A.z>=M;){if(A.x>=u&&A.x<=g&&A.y>=d&&A.y<=m&&A!==s&&A!==o&&as(c,l,a,f,h,p,A.x,A.y)&&lt(A.prev,A,A.next)>=0)return!1;A=A.prevZ}for(;y&&y.z<=E;){if(y.x>=u&&y.x<=g&&y.y>=d&&y.y<=m&&y!==s&&y!==o&&as(c,l,a,f,h,p,y.x,y.y)&&lt(y.prev,y,y.next)>=0)return!1;y=y.nextZ}return!0}function WN(e,t,n){let r=e;do{let s=r.prev,i=r.next.next;!ra(s,i)&&ky(s,r,r.next,i)&&Ei(s,i)&&Ei(i,s)&&(t.push(s.i/n|0),t.push(r.i/n|0),t.push(i.i/n|0),Ti(r),Ti(r.next),r=e=i),r=r.next}while(r!==e);return nr(r)}function JN(e,t,n,r,s,i){let o=e;do{let c=o.next.next;for(;c!==o.prev;){if(o.i!==c.i&&n4(o,c)){let a=Vy(o,c);o=nr(o,o.next),a=nr(a,a.next),yi(o,t,n,r,s,i,0),yi(a,t,n,r,s,i,0);return}c=c.next}o=o.next}while(o!==e)}function XN(e,t,n,r,s,i){let o=[],c,a,h,l,f;for(c=0,a=t.length;c<a;c++)h=t[c]*r,l=c<a-1?t[c+1]*r:e.length,f=zy(e,h,l,r,!1,s&&s[c+1],i),f===f.next&&(f.steiner=!0),o.push(e4(f));for(o.sort(jN),c=0;c<o.length;c++)n=KN(o[c],n);return n}function jN(e,t){return e.x-t.x}function KN(e,t){let n=ZN(e,t);if(!n)return t;let r=Vy(n,e);return nr(r,r.next),nr(n,n.next)}function ZN(e,t){let n=t,r=e.x,s=e.y,i=-1/0,o;do{if(s<=n.y&&s>=n.next.y&&n.next.y!==n.y){let p=n.x+(s-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(p<=r&&p>i&&(i=p,o=n.x<n.next.x?n:n.next,p===r))return o}n=n.next}while(n!==t);if(!o)return null;let c=o,a=o.x,h=o.y,l=1/0,f;n=o;do r>=n.x&&n.x>=a&&r!==n.x&&as(s<h?r:i,s,a,h,s<h?i:r,s,n.x,n.y)&&(f=Math.abs(s-n.y)/(r-n.x),Ei(n,e)&&(f<l||f===l&&(n.x>o.x||n.x===o.x&&QN(o,n)))&&(o=n,l=f)),n=n.next;while(n!==c);return o}function QN(e,t){return lt(e.prev,e,t.prev)<0&&lt(t.next,e,e.next)<0}function $N(e,t,n,r){let s=e;do s.z===0&&(s.z=b0(s.x,s.y,t,n,r)),s.prevZ=s.prev,s.nextZ=s.next,s=s.next;while(s!==e);s.prevZ.nextZ=null,s.prevZ=null,t4(s)}function t4(e){let t,n,r=1,s,i,o,c,a,h;do{for(i=e,e=null,h=null,s=0;i;){for(s++,c=i,o=0,n=0;n<r&&(o++,c=c.nextZ,!!c);n++);for(a=r;o>0||a>0&&c;)o!==0&&(a===0||!c||i.z<=c.z)?(t=i,i=i.nextZ,o--):(t=c,c=c.nextZ,a--),h?h.nextZ=t:e=t,t.prevZ=h,h=t;i=c}h.nextZ=null,r*=2}while(s>1);return e}function b0(e,t,n,r,s){return e=(e-n)*s|0,t=(t-r)*s|0,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e|t<<1}function e4(e){let t=e,n=e;do(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next;while(t!==e);return n}function as(e,t,n,r,s,i,o,c){return(s-o)*(t-c)>=(e-o)*(i-c)&&(e-o)*(r-c)>=(n-o)*(t-c)&&(n-o)*(i-c)>=(s-o)*(r-c)}function n4(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!r4(e,t)&&(Ei(e,t)&&Ei(t,e)&&s4(e,t)&&(lt(e.prev,e,t.prev)||lt(e,t.prev,t))||ra(e,t)&&lt(e.prev,e,e.next)>0&&lt(t.prev,t,t.next)>0)}function lt(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function ra(e,t){return e.x===t.x&&e.y===t.y}function ky(e,t,n,r){let s=na(lt(e,t,n)),i=na(lt(e,t,r)),o=na(lt(n,r,e)),c=na(lt(n,r,t));return!!(s!==i&&o!==c||s===0&&ea(e,n,t)||i===0&&ea(e,r,t)||o===0&&ea(n,e,r)||c===0&&ea(n,t,r))}function ea(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function na(e){return e>0?1:e<0?-1:0}function r4(e,t){let n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&ky(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}function Ei(e,t){return lt(e.prev,e,e.next)<0?lt(e,t,e.next)>=0&&lt(e,e.prev,t)>=0:lt(e,t,e.prev)<0||lt(e,e.next,t)<0}function s4(e,t){let n=e,r=!1,s=(e.x+t.x)/2,i=(e.y+t.y)/2;do n.y>i!=n.next.y>i&&n.next.y!==n.y&&s<(n.next.x-n.x)*(i-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next;while(n!==e);return r}function Vy(e,t){let n=new _i(e.i,e.x,e.y),r=new _i(t.i,t.x,t.y),s=e.next,i=t.prev;return e.next=t,t.prev=e,n.next=s,s.prev=n,r.next=n,n.prev=r,i.next=r,r.prev=i,r}function Gy(e,t,n,r){let s=new _i(e,t,n);return r?(s.next=r.next,s.prev=r,r.next.prev=s,r.next=s):(s.prev=s,s.next=s),s}function Ti(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}var _i=class{constructor(t,n,r){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=t,this.x=n,this.y=r}};function F0(e,t,n){let r=h4(e),s=Object.keys(r).filter(i=>r[i]!==Array);return l4(e,{propArrayTypes:r,...t},{numericPropKeys:n&&n.numericPropKeys||s,PositionDataType:n?n.PositionDataType:Float32Array,triangulate:n?n.triangulate:!0})}function h4(e){let t={};for(let n of e)if(n.properties)for(let r in n.properties){let s=n.properties[r];t[r]=g4(s,t[r])}return t}function l4(e,t,n){let{pointPositionsCount:r,pointFeaturesCount:s,linePositionsCount:i,linePathsCount:o,lineFeaturesCount:c,polygonPositionsCount:a,polygonObjectsCount:h,polygonRingsCount:l,polygonFeaturesCount:f,propArrayTypes:p,coordLength:u}=t,{numericPropKeys:d=[],PositionDataType:g=Float32Array,triangulate:m=!0}=n,M=e[0]&&"id"in e[0],E=e.length>65535?Uint32Array:Uint16Array,A={type:"Point",positions:new g(r*u),globalFeatureIds:new E(r),featureIds:s>65535?new Uint32Array(r):new Uint16Array(r),numericProps:{},properties:[],fields:[]},y={type:"LineString",pathIndices:i>65535?new Uint32Array(o+1):new Uint16Array(o+1),positions:new g(i*u),globalFeatureIds:new E(i),featureIds:c>65535?new Uint32Array(i):new Uint16Array(i),numericProps:{},properties:[],fields:[]},T={type:"Polygon",polygonIndices:a>65535?new Uint32Array(h+1):new Uint16Array(h+1),primitivePolygonIndices:a>65535?new Uint32Array(l+1):new Uint16Array(l+1),positions:new g(a*u),globalFeatureIds:new E(a),featureIds:f>65535?new Uint32Array(a):new Uint16Array(a),numericProps:{},properties:[],fields:[]};m&&(T.triangles=[]);for(let L of[A,y,T])for(let B of d){let S=p[B];L.numericProps[B]=new S(L.positions.length/u)}y.pathIndices[o]=i,T.polygonIndices[h]=a,T.primitivePolygonIndices[l]=a;let _={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let L of e){let B=L.geometry,S=L.properties||{};switch(B.type){case"Point":f4(B,A,_,u,S),A.properties.push(N0(S,d)),M&&A.fields.push({id:L.id}),_.pointFeature++;break;case"LineString":p4(B,y,_,u,S),y.properties.push(N0(S,d)),M&&y.fields.push({id:L.id}),_.lineFeature++;break;case"Polygon":u4(B,T,_,u,S),T.properties.push(N0(S,d)),M&&T.fields.push({id:L.id}),_.polygonFeature++;break;default:throw new Error("Invalid geometry type")}_.feature++}return m4(A,y,T,u)}function f4(e,t,n,r,s){t.positions.set(e.data,n.pointPosition*r);let i=e.data.length/r;v0(t,s,n.pointPosition,i),t.globalFeatureIds.fill(n.feature,n.pointPosition,n.pointPosition+i),t.featureIds.fill(n.pointFeature,n.pointPosition,n.pointPosition+i),n.pointPosition+=i}function p4(e,t,n,r,s){t.positions.set(e.data,n.linePosition*r);let i=e.data.length/r;v0(t,s,n.linePosition,i),t.globalFeatureIds.fill(n.feature,n.linePosition,n.linePosition+i),t.featureIds.fill(n.lineFeature,n.linePosition,n.linePosition+i);for(let o=0,c=e.indices.length;o<c;++o){let a=e.indices[o],h=o===c-1?e.data.length:e.indices[o+1];t.pathIndices[n.linePath++]=n.linePosition,n.linePosition+=(h-a)/r}}function u4(e,t,n,r,s){t.positions.set(e.data,n.polygonPosition*r);let i=e.data.length/r;v0(t,s,n.polygonPosition,i),t.globalFeatureIds.fill(n.feature,n.polygonPosition,n.polygonPosition+i),t.featureIds.fill(n.polygonFeature,n.polygonPosition,n.polygonPosition+i);for(let o=0,c=e.indices.length;o<c;++o){let a=n.polygonPosition;t.polygonIndices[n.polygonObject++]=a;let h=e.areas[o],l=e.indices[o],f=e.indices[o+1];for(let u=0,d=l.length;u<d;++u){let g=l[u],m=u===d-1?f===void 0?e.data.length:f[0]:l[u+1];t.primitivePolygonIndices[n.polygonRing++]=n.polygonPosition,n.polygonPosition+=(m-g)/r}let p=n.polygonPosition;d4(t,h,l,{startPosition:a,endPosition:p,coordLength:r})}}function d4(e,t,n,{startPosition:r,endPosition:s,coordLength:i}){if(!e.triangles)return;let o=r*i,c=s*i,a=e.positions.subarray(o,c),h=n[0],l=n.slice(1).map(p=>(p-h)/i),f=O0(a,l,i,t);for(let p=0,u=f.length;p<u;++p)e.triangles.push(r+f[p])}function P0(e,t){let n={};for(let r in e)n[r]={value:e[r],size:t};return n}function m4(e,t,n,r){let s={shape:"binary-feature-collection",points:{...e,positions:{value:e.positions,size:r},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:P0(e.numericProps,1)},lines:{...t,positions:{value:t.positions,size:r},pathIndices:{value:t.pathIndices,size:1},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:P0(t.numericProps,1)},polygons:{...n,positions:{value:n.positions,size:r},polygonIndices:{value:n.polygonIndices,size:1},primitivePolygonIndices:{value:n.primitivePolygonIndices,size:1},globalFeatureIds:{value:n.globalFeatureIds,size:1},featureIds:{value:n.featureIds,size:1},numericProps:P0(n.numericProps,1)}};return s.polygons&&n.triangles&&(s.polygons.triangles={value:new Uint32Array(n.triangles),size:1}),s}function v0(e,t,n,r){for(let s in e.numericProps)if(s in t){let i=t[s];e.numericProps[s].fill(i,n,n+r)}}function N0(e,t){let n={};for(let r in e)t.includes(r)||(n[r]=e[r]);return n}function g4(e,t){return t===Array||!Number.isFinite(e)?Array:t===Float64Array||Math.fround(e)!==e?Float64Array:Float32Array}function oa(e,t){let n=t?.globalFeatureId;return n!==void 0?x4(e,n):M4(e,t?.type)}function x4(e,t){let n=Wy(e);for(let r of n){let s=0,i=r.featureIds.value[0];for(let o=0;o<r.featureIds.value.length;o++){let c=r.featureIds.value[o];if(c!==i){if(t===r.globalFeatureIds.value[s])return sa(r,s,o);s=o,i=c}}if(t===r.globalFeatureIds.value[s])return sa(r,s,r.featureIds.value.length)}throw new Error(`featureId:${t} not found`)}function M4(e,t){let n=Wy(e,t);return A4(n)}function Yy(e,t,n){switch(e.type){case"Point":return _4(e,t,n);case"LineString":return T4(e,t,n);case"Polygon":return Jy(e,t,n);default:let r=e;throw new Error(`Unsupported geometry type: ${r?.type}`)}}function Wy(e,t){let n=[];return e.points&&(e.points.type="Point",n.push(e.points)),e.lines&&(e.lines.type="LineString",n.push(e.lines)),e.polygons&&(e.polygons.type="Polygon",n.push(e.polygons)),n}function A4(e){let t=[];for(let n of e){if(n.featureIds.value.length===0)continue;let r=0,s=n.featureIds.value[0];for(let i=0;i<n.featureIds.value.length;i++){let o=n.featureIds.value[i];o!==s&&(t.push(sa(n,r,i)),r=i,s=o)}t.push(sa(n,r,n.featureIds.value.length))}return t}function sa(e,t,n){let r=Yy(e,t,n),s=E4(e,t,n),i=y4(e,t,n);return{type:"Feature",geometry:r,properties:s,...i}}function y4(e,t=0,n){return e.fields&&e.fields[e.featureIds.value[t]]}function E4(e,t=0,n){let r=Object.assign({},e.properties[e.featureIds.value[t]]);for(let s in e.numericProps)r[s]=e.numericProps[s].value[t];return r}function Jy(e,t=-1/0,n=1/0){let{positions:r}=e,s=e.polygonIndices.value.filter(a=>a>=t&&a<=n),i=e.primitivePolygonIndices.value.filter(a=>a>=t&&a<=n);if(!(s.length>2)){let a=[];for(let h=0;h<i.length-1;h++){let l=i[h],f=i[h+1],p=ia(r,l,f);a.push(p)}return{type:"Polygon",coordinates:a}}let c=[];for(let a=0;a<s.length-1;a++){let h=s[a],l=s[a+1],f=Jy(e,h,l).coordinates;c.push(f)}return{type:"MultiPolygon",coordinates:c}}function T4(e,t=-1/0,n=1/0){let{positions:r}=e,s=e.pathIndices.value.filter(c=>c>=t&&c<=n);if(!(s.length>2))return{type:"LineString",coordinates:ia(r,s[0],s[1])};let o=[];for(let c=0;c<s.length-1;c++){let a=ia(r,s[c],s[c+1]);o.push(a)}return{type:"MultiLineString",coordinates:o}}function _4(e,t,n){let{positions:r}=e,s=ia(r,t,n);return s.length>1?{type:"MultiPoint",coordinates:s}:{type:"Point",coordinates:s[0]}}function ia(e,t,n){t=t||0,n=n||e.value.length/e.size;let r=[];for(let s=t;s<n;s++){let i=Array();for(let o=s*e.size;o<(s+1)*e.size;o++)i.push(Number(e.value[o]));r.push(i)}return r}var q0=D(t3(),1);function e3(e){let t=e.length;if(t<=1)return[e];let n=[],r,s;for(let i=0;i<t;i++){let o=k4(e[i]);o!==0&&(s===void 0&&(s=o<0),s===o<0?(r&&n.push(r),r=[e[i]]):r&&r.push(e[i]))}return r&&n.push(r),n}function k4(e){let t=0;for(let n=0,r=e.length-1,s,i;n<e.length;r=n++)s=e[n],i=e[r],t+=(i[0]-s[0])*(s[1]+i[1]);return t}function n3(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?V4(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function V4(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[r]=s}}var fs=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;static get types(){return["Unknown","Point","LineString","Polygon"]}constructor(t,n,r,s,i){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=i,t.readFields(n3,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,s=0,i=0,o=0,c=[],a;for(;t.pos<n;){if(s<=0){let h=t.readVarint();r=h&7,s=h>>3}if(s--,r===1||r===2)i+=t.readSVarint(),o+=t.readSVarint(),r===1&&(a&&c.push(a),a=[]),a&&a.push([i,o]);else if(r===7)a&&a.push(a[0].slice());else throw new Error(`unknown command ${r}`)}return a&&c.push(a),c}bbox(){let t=this._pbf;t.pos=this._geometry;let n=t.readVarint()+t.pos,r=1,s=0,i=0,o=0,c=1/0,a=-1/0,h=1/0,l=-1/0;for(;t.pos<n;){if(s<=0){let f=t.readVarint();r=f&7,s=f>>3}if(s--,r===1||r===2)i+=t.readSVarint(),o+=t.readSVarint(),i<c&&(c=i),i>a&&(a=i),o<h&&(h=o),o>l&&(l=o);else if(r!==7)throw new Error(`unknown command ${r}`)}return[c,h,a,l]}_toGeoJSON(t){let n=this.loadGeometry(),r=fs.types[this.type],s,i;switch(this.type){case 1:let c=[];for(s=0;s<n.length;s++)c[s]=n[s][0];n=c,t(n,this);break;case 2:for(s=0;s<n.length;s++)t(n[s],this);break;case 3:for(n=e3(n),s=0;s<n.length;s++)for(i=0;i<n[s].length;i++)t(n[s][i],this);break}n.length===1?n=n[0]:r=`Multi${r}`;let o={type:"Feature",geometry:{type:r,coordinates:n},properties:this.properties};return this.id!==null&&(o.id=this.id),o}toGeoJSON(t){if(typeof t=="function")return this._toGeoJSON(t);let{x:n,y:r,z:s}=t,i=this.extent*Math.pow(2,s),o=this.extent*n,c=this.extent*r;function a(h){for(let l=0;l<h.length;l++){let f=h[l];f[0]=(f[0]+o)*360/i-180;let p=180-(f[1]+c)*360/i;f[1]=360/Math.PI*Math.atan(Math.exp(p*Math.PI/180))-90}}return this._toGeoJSON(a)}};var ha=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(q4,this,n),this.length=this._features.length}feature(t){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let n=this._pbf.readVarint()+this._pbf.pos;return new fs(this._pbf,n,this.extent,this._keys,this._values)}};function q4(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(H4(n)))}function H4(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var la=class{layers;constructor(t,n){this.layers=t.readFields(Y4,{},n)}};function Y4(e,t,n){if(e===3&&n){let r=new ha(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function r3(e){let t=e.indices.length,n="Polygon";if(t<=1)return{type:n,data:e.data,areas:[[er(e.data)]],indices:[e.indices]};let r=[],s=[],i=[],o=[],c,a=0;for(let h,l=0,f;l<t;l++){f=e.indices[l]-a,h=e.indices[l+1]-a||e.data.length;let p=e.data.slice(f,h),u=er(p);if(u===0){let d=e.data.slice(0,f),g=e.data.slice(h);e.data=d.concat(g),a+=h-f;continue}c===void 0&&(c=u<0),c===u<0?(o.length&&(r.push(i),s.push(o)),o=[f],i=[u]):(i.push(u),o.push(f))}return i&&r.push(i),o.length&&s.push(o),{type:n,areas:r,indices:s,data:e.data}}function s3(e,t,n,r){for(let s=0,i=e.length;s<i;s+=2){e[s]=(e[s]+t)*360/r-180;let o=180-(e[s+1]+n)*360/r;e[s+1]=360/Math.PI*Math.atan(Math.exp(o*Math.PI/180))-90}}function i3(e,t,n){t&&n&&(e===1?t.id=n.readVarint():e===2?W4(n,t):e===3?t.type=n.readVarint():e===4&&(t._geometry=n.pos))}function W4(e,t){let n=e.readVarint()+e.pos;for(;e.pos<n;){let r=t._keys[e.readVarint()],s=t._values[e.readVarint()];t.properties[r]=s}}var o3,rr,G0,fa,z0,k0,Si;var pa=class{properties;extent;type;id;_pbf;_geometry;_keys;_values;_geometryInfo;constructor(t,n,r,s,i,o){this.properties={},this.extent=r,this.type=0,this.id=null,this._pbf=t,this._geometry=-1,this._keys=s,this._values=i,this._geometryInfo=o,t.readFields(i3,this,n)}loadGeometry(){let t=this._pbf;t.pos=this._geometry,o3=t.readVarint()+t.pos,rr=1,fa=0,z0=0,k0=0,Si=0;let n=[],r=[];for(;t.pos<o3;)if(fa<=0&&(G0=t.readVarint(),rr=G0&7,fa=G0>>3),fa--,rr===1||rr===2)z0+=t.readSVarint(),k0+=t.readSVarint(),rr===1&&n.push(Si),r.push(z0,k0),Si+=2;else if(rr===7){if(Si>0){let s=n[n.length-1];r.push(r[s],r[s+1]),Si+=2}}else throw new Error(`unknown command ${rr}`);return{data:r,indices:n}}_toBinaryCoordinates(t){let n=this.loadGeometry(),r;t(n.data,this);let s=2;switch(this.type){case 1:this._geometryInfo.pointFeaturesCount++,this._geometryInfo.pointPositionsCount+=n.indices.length,r={type:"Point",...n};break;case 2:this._geometryInfo.lineFeaturesCount++,this._geometryInfo.linePathsCount+=n.indices.length,this._geometryInfo.linePositionsCount+=n.data.length/s,r={type:"LineString",...n};break;case 3:r=r3(n),this._geometryInfo.polygonFeaturesCount++,this._geometryInfo.polygonObjectsCount+=r.indices.length;for(let o of r.indices)this._geometryInfo.polygonRingsCount+=o.length;this._geometryInfo.polygonPositionsCount+=r.data.length/s;break;default:throw new Error(`Invalid geometry type: ${this.type}`)}let i={type:"Feature",geometry:r,properties:this.properties};return this.id!==null&&(i.id=this.id),i}toBinaryCoordinates(t){if(typeof t=="function")return this._toBinaryCoordinates(t);let{x:n,y:r,z:s}=t,i=this.extent*Math.pow(2,s),o=this.extent*n,c=this.extent*r;return this._toBinaryCoordinates(a=>s3(a,o,c,i))}};var ua=class{version;name;extent;length;_pbf;_keys;_values;_features;constructor(t,n){this.version=1,this.name="",this.extent=4096,this.length=0,this._pbf=t,this._keys=[],this._values=[],this._features=[],t.readFields(J4,this,n),this.length=this._features.length}feature(t,n){if(t<0||t>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];let r=this._pbf.readVarint()+this._pbf.pos;return new pa(this._pbf,r,this.extent,this._keys,this._values,n)}};function J4(e,t,n){t&&n&&(e===15?t.version=n.readVarint():e===1?t.name=n.readString():e===5?t.extent=n.readVarint():e===2?t._features.push(n.pos):e===3?t._keys.push(n.readString()):e===4&&t._values.push(X4(n)))}function X4(e){let t=null,n=e.readVarint()+e.pos;for(;e.pos<n;){let r=e.readVarint()>>3;t=r===1?e.readString():r===2?e.readFloat():r===3?e.readDouble():r===4?e.readVarint64():r===5?e.readVarint():r===6?e.readSVarint():r===7?e.readBoolean():null}return t}var da=class{layers;constructor(t,n){this.layers=t.readFields(j4,{},n)}};function j4(e,t,n){if(e===3&&n){let r=new ua(n,n.readVarint()+n.pos);r.length&&t&&(t[r.name]=r)}}function H0(e,t){let n=Z4(t),r=t?.gis?.format||t?.mvt?.shape||t?.shape;switch(r){case"columnar-table":return{shape:"columnar-table",data:V0(e,n)};case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",features:c3(e,n)};case"geojson":return c3(e,n);case"binary-geometry":return V0(e,n);case"binary":return V0(e,n);default:throw new Error(r||"undefined shape")}}function V0(e,t){let[n,r]=K4(e,t),s=F0(n,r);return s.byteLength=e.byteLength,s}function K4(e,t){let n=[],r={coordLength:2,pointPositionsCount:0,pointFeaturesCount:0,linePositionsCount:0,linePathsCount:0,lineFeaturesCount:0,polygonPositionsCount:0,polygonObjectsCount:0,polygonRingsCount:0,polygonFeaturesCount:0};if(e.byteLength<=0)return[n,r];let s=new da(new q0.default(e));return(t&&Array.isArray(t.layers)?t.layers:Object.keys(s.layers)).forEach(o=>{let c=s.layers[o];if(c)for(let a=0;a<c.length;a++){let h=c.feature(a,r),l=$4(h,t,o);n.push(l)}}),[n,r]}function c3(e,t){if(e.byteLength<=0)return[];let n=[],r=new la(new q0.default(e));return(Array.isArray(t.layers)?t.layers:Object.keys(r.layers)).forEach(i=>{let o=r.layers[i];if(o)for(let c=0;c<o.length;c++){let a=o.feature(c),h=Q4(a,t,i);n.push(h)}}),n}function Z4(e){if(!e?.mvt)throw new Error("mvt options required");let t=e.mvt?.coordinates==="wgs84",{tileIndex:n}=e.mvt,r=n&&Number.isFinite(n.x)&&Number.isFinite(n.y)&&Number.isFinite(n.z);if(t&&!r)throw new Error("MVT Loader: WGS84 coordinates need tileIndex property");return e.mvt}function Q4(e,t,n){let r=e.toGeoJSON(t.coordinates==="wgs84"?t.tileIndex:tF);return t.layerProperty&&(r.properties[t.layerProperty]=n),r}function $4(e,t,n){let r=e.toBinaryCoordinates(t.coordinates==="wgs84"?t.tileIndex:eF);return t.layerProperty&&r.properties&&(r.properties[t.layerProperty]=n),r}function tF(e,t){let{extent:n}=t;for(let r=0;r<e.length;r++){let s=e[r];s[0]/=n,s[1]/=n}}function eF(e,t){let{extent:n}=t;for(let r=0,s=e.length;r<s;++r)e[r]/=n}var nF="4.2.1",ma={dataType:null,batchType:null,name:"Mapbox Vector Tile",id:"mvt",module:"mvt",version:nF,extensions:["mvt","pbf"],mimeTypes:["application/vnd.mapbox-vector-tile","application/x-protobuf"],worker:!0,category:"geometry",options:{mvt:{shape:"geojson",coordinates:"local",layerProperty:"layerName",layers:void 0,tileIndex:null}}},rF={...ma,parse:async(e,t)=>H0(e,t),parseSync:H0,binary:!0};var sF={Point:a3,MultiPoint:iF,LineString:h3,MultiLineString:oF,Polygon:l3,MultiPolygon:cF};function a3([e,t],[n,r],s){let i=$e(n[0],r[0],e),o=$e(n[1],r[1],t);return s.unprojectFlat([i,o])}function Y0(e,t,n){return e.map(r=>a3(r,t,n))}function iF(e,t,n){return Y0(e,t,n)}function h3(e,t,n){return Y0(e,t,n)}function oF(e,t,n){return e.map(r=>h3(r,t,n))}function l3(e,t,n){return e.map(r=>Y0(r,t,n))}function cF(e,t,n){return e.map(r=>l3(r,t,n))}function f3(e,t,n){let r=n.projectFlat([t.west,t.north]),s=n.projectFlat([t.east,t.south]),i=[r,s];return{...e,coordinates:sF[e.type](e.coordinates,i,n)}}var aF=["points","lines","polygons"];function W0(e,t,n,r){for(let s of aF){let i=e[s]&&hF(e[s],t,n,r);if(i>=0)return i}return-1}function hF(e,t,n,r){let s=e.featureIds.value;if(!s.length)return-1;let i=0,o=s[s.length-1]+1;if(r){let a=lF(e,r);if(a)i=a[0],o=a[1]+1;else return-1}let c=-1;if(t in e.numericProps){let a=e.numericProps[t].value.findIndex((h,l)=>h===n&&s[l]>=i&&s[l]<o);return a>=0?e.globalFeatureIds.value[a]:-1}else t?c=p3(e.properties,a=>a[t]===n,i,o):e.fields&&(c=p3(e.fields,a=>a.id===n,i,o));return c>=0?fF(e,c):-1}function lF(e,t){if(!e.__layers){let n={},{properties:r}=e;for(let s=0;s<r.length;s++){let{layerName:i}=r[s];i&&(n[i]?n[i][1]=s:n[i]=[s,s])}e.__layers=n}return e.__layers[t]}function fF(e,t){if(!e.__ids){let n=[],r=e.featureIds.value,s=e.globalFeatureIds.value;for(let i=0;i<r.length;i++)n[r[i]]=s[i];e.__ids=n}return e.__ids[t]}function p3(e,t,n,r){for(let s=n;s<r;s++)if(t(e[s],s))return s;return-1}var J0=512,pF={...j0.GeoJsonLayer.defaultProps,data:cn,onDataLoad:{type:"function",value:null,optional:!0,compare:!1},uniqueIdProperty:"",highlightedFeatureId:null,loaders:[ma],binary:!0},Bi=class extends Dn{initializeState(){super.initializeState();let t=this.context.viewport.resolution!==void 0?!1:this.props.binary;this.setState({binary:t,data:null,tileJSON:null,hoveredFeatureId:null,hoveredFeatureLayerName:null})}get isLoaded(){return Boolean(this.state?.data&&super.isLoaded)}updateState({props:t,oldProps:n,context:r,changeFlags:s}){s.dataChanged&&this._updateTileData(),this.state?.data&&(super.updateState({props:t,oldProps:n,context:r,changeFlags:s}),this._setWGS84PropertyForTiles());let{highlightColor:i}=t;i!==n.highlightColor&&Array.isArray(i)&&this.setState({highlightColor:i})}async _updateTileData(){let t=this.props.data,n=null;if(typeof t=="string"&&!Nh(t)){let{onDataLoad:r,fetch:s}=this.props;this.setState({data:null,tileJSON:null});try{n=await s(t,{propName:"data",layer:this,loaders:[]})}catch(i){this.raiseError(i,"loading TileJSON"),t=null}r&&r(n,{propName:"data",layer:this})}else t&&typeof t=="object"&&"tilejson"in t&&(n=t);n&&(t=n.tiles),this.setState({data:t,tileJSON:n})}_getTilesetOptions(){let t=super._getTilesetOptions(),n=this.state.tileJSON,{minZoom:r,maxZoom:s}=this.props;return n&&(Number.isFinite(n.minzoom)&&n.minzoom>r&&(t.minZoom=n.minzoom),Number.isFinite(n.maxzoom)&&(!Number.isFinite(s)||n.maxzoom<s)&&(t.maxZoom=n.maxzoom)),t}renderLayers(){return this.state?.data?super.renderLayers():null}getTileData(t){let{data:n,binary:r}=this.state,{index:s,signal:i}=t,o=Te(n,t);if(!o)return Promise.reject("Invalid URL");let c=this.getLoadOptions(),{fetch:a}=this.props;return c={...c,mimeType:"application/x-protobuf",mvt:{...c?.mvt,coordinates:this.context.viewport.resolution?"wgs84":"local",tileIndex:s},gis:r?{format:"binary"}:{}},a(o,{propName:"data",layer:this,loadOptions:c,signal:i})}renderSubLayers(t){let{x:n,y:r,z:s}=t.tile.index,i=Math.pow(2,s),o=J0/i,c=-o,a=J0*n/i,h=J0*(1-r/i),l=new Ht().scale([o,c,1]);t.autoHighlight=!1,this.context.viewport.resolution||(t.modelMatrix=l,t.coordinateOrigin=[a,h,0],t.coordinateSystem=ga.COORDINATE_SYSTEM.CARTESIAN,t.extensions=[...t.extensions||[],new g3.ClipExtension]);let f=super.renderSubLayers(t);return this.state.binary&&!(f instanceof j0.GeoJsonLayer)&&ga.log.warn("renderSubLayers() must return GeoJsonLayer when using binary:true")(),f}_updateAutoHighlight(t){let{uniqueIdProperty:n}=this.props,{hoveredFeatureId:r,hoveredFeatureLayerName:s}=this.state,i=t.object,o=null,c=null;i&&(o=X0(i,n),c=u3(i));let{highlightColor:a}=this.props;typeof a=="function"&&(a=a(t)),(r!==o||s!==c)&&this.setState({highlightColor:a,hoveredFeatureId:o,hoveredFeatureLayerName:c})}_isWGS84(){return Boolean(this.context.viewport.resolution)}getPickingInfo(t){let n=super.getPickingInfo(t);if(this.state.binary&&n.index!==-1){let{data:r}=t.sourceLayer.props;n.object=oa(r,{globalFeatureId:n.index})}return n.object&&!this._isWGS84()&&(n.object=m3(n.object,n.tile.bbox,this.context.viewport)),n}getSubLayerPropsByTile(t){return{highlightedObjectIndex:this.getHighlightedObjectIndex(t),highlightColor:this.state.highlightColor}}getHighlightedObjectIndex(t){let{hoveredFeatureId:n,hoveredFeatureLayerName:r,binary:s}=this.state,{uniqueIdProperty:i,highlightedFeatureId:o}=this.props,c=t.content,a=d3(o);if(!(d3(n)||a))return-1;let l=a?o:n;return Array.isArray(c)?c.findIndex(f=>{let p=X0(f,i)===l,u=a||u3(f)===r;return p&&u}):c&&s?W0(c,i,l,a?"":r):-1}_pickObjects(t){let{deck:n,viewport:r}=this.context,s=r.width,i=r.height,o=r.x,c=r.y,a=[this.id];return n.pickObjects({x:o,y:c,width:s,height:i,layerIds:a,maxObjects:t})}getRenderedFeatures(t=null){let n=this._pickObjects(t),r=new Set,s=[];for(let i of n){let o=X0(i.object,this.props.uniqueIdProperty);o===void 0?s.push(i.object):r.has(o)||(r.add(o),s.push(i.object))}return s}_setWGS84PropertyForTiles(){let t="dataInWGS84";this.state.tileset.selectedTiles.forEach(r=>{r.hasOwnProperty(t)||Object.defineProperty(r,t,{get:()=>{if(!r.content)return null;if(this.state.binary&&Array.isArray(r.content)&&!r.content.length)return[];let{bbox:s}=r;if(r._contentWGS84===void 0&&Fh(s)){let i=this.state.binary?oa(r.content):r.content;r._contentWGS84=i.map(o=>m3(o,s,this.context.viewport))}return r._contentWGS84}})})}};Bi.layerName="MVTLayer";Bi.defaultProps=pF;var x3=Bi;function X0(e,t){if(e.properties&&t)return e.properties[t];if("id"in e)return e.id}function u3(e){return e.properties?.layerName||null}function d3(e){return e!=null&&e!==""}function m3(e,t,n){let r={...e,geometry:{type:e.geometry.type}};return Object.defineProperty(r.geometry,"coordinates",{get:()=>f3(e.geometry,t,n).coordinates}),r}var M3="0123456789bcdefghjkmnpqrstuvwxyz",A3={};for(let e=0;e<M3.length;e++)A3[M3.charAt(e)]=e;var uF=-90,dF=90,mF=-180,gF=180;function xF(e){let t=!0,n=dF,r=uF,s=gF,i=mF,o,c=0;for(let a=0,h=e.length;a<h;a++){let l=e[a].toLowerCase();c=A3[l];for(let f=4;f>=0;f--){let p=c>>f&1;t?(o=(s+i)/2,p===1?i=o:s=o):(o=(n+r)/2,p===1?r=o:n=o),t=!t}}return[r,i,n,s]}function y3(e){let[t,n,r,s]=xF(e);return[s,r,s,t,n,t,n,r,s,r]}var MF={getGeohash:{type:"accessor",value:e=>e.geohash}},Ci=class extends ye{indexToBounds(){let{data:t,getGeohash:n}=this.props;return{data:t,_normalize:!1,positionFormat:"XY",getPolygon:(r,s)=>y3(n(r,s))}}};Ci.layerName="GeohashLayer";Ci.defaultProps=MF;var E3=Ci;return I3(Li);})();
686
+ /*! Bundled license information:
687
+
688
+ long/dist/long.js:
689
+ (**
690
+ * @license long.js (c) 2013 Daniel Wirtz <dcode@dcode.io>
691
+ * Released under the Apache License, Version 2.0
692
+ * see: https://github.com/dcodeIO/long.js for details
693
+ *)
694
+
695
+ ieee754/index.js:
696
+ (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *)
697
+
698
+ long/index.js:
699
+ (**
700
+ * @license
701
+ * Copyright 2009 The Closure Library Authors
702
+ * Copyright 2020 Daniel Wirtz / The long.js Authors.
703
+ *
704
+ * Licensed under the Apache License, Version 2.0 (the "License");
705
+ * you may not use this file except in compliance with the License.
706
+ * You may obtain a copy of the License at
707
+ *
708
+ * http://www.apache.org/licenses/LICENSE-2.0
709
+ *
710
+ * Unless required by applicable law or agreed to in writing, software
711
+ * distributed under the License is distributed on an "AS IS" BASIS,
712
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
713
+ * See the License for the specific language governing permissions and
714
+ * limitations under the License.
715
+ *
716
+ * SPDX-License-Identifier: Apache-2.0
717
+ *)
718
+ */
449
719
  return __exports__;
450
720
  });