@loaders.gl/tile-converter 3.3.0 → 3.3.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.
@@ -292,4 +292,4 @@ var n=r(16),i=r(518),a=r(64),o=function(e){if(!(this instanceof o))return new o(
292
292
  * @license [MIT]{@link https://github.com/archiverjs/node-archiver/blob/master/LICENSE}
293
293
  * @copyright (c) 2012-2014 Chris Talkington, contributors.
294
294
  */
295
- var n=r(1).inherits,i=r(215).Transform,a=r(237),o=r(64),s=function(e){if(!(this instanceof s))return new s(e);e=this.options=o.defaults(e,{}),i.call(this,e),this.supports={directory:!0,symlink:!0},this.files=[]};n(s,i),s.prototype._transform=function(e,t,r){r(null,e)},s.prototype._writeStringified=function(){var e=JSON.stringify(this.files);this.write(e)},s.prototype.append=function(e,t,r){var n=this;function i(e,i){e?r(e):(t.size=i.length||0,t.crc32=a.unsigned(i),n.files.push(t),r(null,t))}t.crc32=0,"buffer"===t.sourceType?i(null,e):"stream"===t.sourceType&&o.collectStream(e,i)},s.prototype.finalize=function(){this._writeStringified(),this.end()},e.exports=s},function(e,t,r){const n=r(80).get,i=r(80).set,a=r(80).has,o=r(80).isUndefined,s=(e,t,r)=>{const s=Object.keys(t).reduce((r,s)=>{const u=Array.isArray(t[s].path)?t[s].path.filter(t=>a(e,t))[0]:t[s].path,c=u?n(e,u):void 0;return((e,t,r,n,a)=>{const s=e[t].default,u=e[t].transform,c=e[t].omitValues||[];let l=u?u(r,n,a):r;return o(l)&&!o(s)&&(l=s),-1==c.indexOf(l)?i(Object.assign({},n),t,l):n})(t,s,c,r,e)},{});return r?r(s,e):s},u=(e,t,r)=>Array.isArray(e)?((e,t,r)=>e.map(e=>{const n=u(e,t);return r?r(n,e):n}))(e,t,r):s(e,t,r);e.exports=u},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},function(e,t){function r(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=540},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"filename",(function(){return bo})),r.d(n,"dirname",(function(){return vo})),r.d(n,"join",(function(){return wo}));var i={};r.r(i),r.d(i,"readdir",(function(){return ko})),r.d(i,"stat",(function(){return xo})),r.d(i,"readFile",(function(){return Eo})),r.d(i,"readFileSync",(function(){return So})),r.d(i,"writeFile",(function(){return Ao})),r.d(i,"writeFileSync",(function(){return jo})),r.d(i,"open",(function(){return Co})),r.d(i,"close",(function(){return To})),r.d(i,"read",(function(){return Bo})),r.d(i,"fstat",(function(){return Ro})),r.d(i,"createWriteStream",(function(){return Oo})),r.d(i,"isSupported",(function(){return Io})),r.d(i,"_readToArrayBuffer",(function(){return Do}));var a={};r.r(a),r.d(a,"name",(function(){return Og})),r.d(a,"decode",(function(){return Ig}));var o={};r.r(o),r.d(o,"name",(function(){return Lg})),r.d(o,"preprocess",(function(){return Ng}));var s={};r.r(s),r.d(s,"name",(function(){return zg})),r.d(s,"preprocess",(function(){return Ug}));var u={};r.r(u),r.d(u,"name",(function(){return Hg})),r.d(u,"preprocess",(function(){return Gg})),r.d(u,"decode",(function(){return Wg})),r.d(u,"encode",(function(){return Vg}));var c={};r.r(c),r.d(c,"name",(function(){return Xg})),r.d(c,"decode",(function(){return ry}));var l={};r.r(l),r.d(l,"name",(function(){return oy})),r.d(l,"decode",(function(){return sy})),r.d(l,"encode",(function(){return uy}));var h={};r.r(h),r.d(h,"name",(function(){return cy})),r.d(h,"decode",(function(){return ly})),r.d(h,"encode",(function(){return hy}));var p={};r.r(p),r.d(p,"name",(function(){return py})),r.d(p,"decode",(function(){return fy})),r.d(p,"encode",(function(){return dy}));var f={};r.r(f),r.d(f,"name",(function(){return gy})),r.d(f,"decode",(function(){return yy}));var d=r(119);const m="object"!=typeof process||"[object process]"!==String(process)||process.browser,g={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global},y=g.global||g.self||g.window;function b(e,t,r){return t<=e&&e<=r}global["encoding-indexes"]={ibm866:[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160],"iso-8859-2":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,728,321,164,317,346,167,168,352,350,356,377,173,381,379,176,261,731,322,180,318,347,711,184,353,351,357,378,733,382,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],"iso-8859-3":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,294,728,163,164,null,292,167,168,304,350,286,308,173,null,379,176,295,178,179,180,181,293,183,184,305,351,287,309,189,null,380,192,193,194,null,196,266,264,199,200,201,202,203,204,205,206,207,null,209,210,211,212,288,214,215,284,217,218,219,220,364,348,223,224,225,226,null,228,267,265,231,232,233,234,235,236,237,238,239,null,241,242,243,244,289,246,247,285,249,250,251,252,365,349,729],"iso-8859-4":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,312,342,164,296,315,167,168,352,274,290,358,173,381,175,176,261,731,343,180,297,316,711,184,353,275,291,359,330,382,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,298,272,325,332,310,212,213,214,215,216,370,218,219,220,360,362,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,299,273,326,333,311,244,245,246,247,248,371,250,251,252,361,363,729],"iso-8859-5":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,173,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,8470,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,167,1118,1119],"iso-8859-6":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,null,null,164,null,null,null,null,null,null,null,1548,173,null,null,null,null,null,null,null,null,null,null,null,null,null,1563,null,null,null,1567,null,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,null,null,null,null,null,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,null,null,null,null,null,null,null,null,null,null,null,null,null],"iso-8859-7":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8216,8217,163,8364,8367,166,167,168,169,890,171,172,173,null,8213,176,177,178,179,900,901,902,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],"iso-8859-8":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,162,163,164,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,8215,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],"iso-8859-10":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,274,290,298,296,310,167,315,272,352,358,381,173,362,330,176,261,275,291,299,297,311,183,316,273,353,359,382,8213,363,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,207,208,325,332,211,212,213,214,360,216,370,218,219,220,221,222,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,239,240,326,333,243,244,245,246,361,248,371,250,251,252,253,254,312],"iso-8859-13":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8221,162,163,164,8222,166,167,216,169,342,171,172,173,174,198,176,177,178,179,8220,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,8217],"iso-8859-14":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,7682,7683,163,266,267,7690,167,7808,169,7810,7691,7922,173,174,376,7710,7711,288,289,7744,7745,182,7766,7809,7767,7811,7776,7923,7812,7813,7777,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,372,209,210,211,212,213,214,7786,216,217,218,219,220,221,374,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,373,241,242,243,244,245,246,7787,248,249,250,251,252,253,375,255],"iso-8859-15":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,8364,165,352,167,353,169,170,171,172,173,174,175,176,177,178,179,381,181,182,183,382,185,186,187,338,339,376,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],"iso-8859-16":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,261,321,8364,8222,352,167,353,169,536,171,377,173,378,379,176,177,268,322,381,8221,182,183,382,269,537,187,338,339,376,380,192,193,194,258,196,262,198,199,200,201,202,203,204,205,206,207,272,323,210,211,212,336,214,346,368,217,218,219,220,280,538,223,224,225,226,259,228,263,230,231,232,233,234,235,236,237,238,239,273,324,242,243,244,337,246,347,369,249,250,251,252,281,539,255],"koi8-r":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,1025,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],"koi8-u":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,1118,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,1038,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],macintosh:[196,197,199,201,209,214,220,225,224,226,228,227,229,231,233,232,234,235,237,236,238,239,241,243,242,244,246,245,250,249,251,252,8224,176,162,163,167,8226,182,223,174,169,8482,180,168,8800,198,216,8734,177,8804,8805,165,181,8706,8721,8719,960,8747,170,186,937,230,248,191,161,172,8730,402,8776,8710,171,187,8230,160,192,195,213,338,339,8211,8212,8220,8221,8216,8217,247,9674,255,376,8260,8364,8249,8250,64257,64258,8225,183,8218,8222,8240,194,202,193,203,200,205,206,207,204,211,212,63743,210,218,219,217,305,710,732,175,728,729,730,184,733,731,711],"windows-874":[8364,129,130,131,132,8230,134,135,136,137,138,139,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,153,154,155,156,157,158,159,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,null,null,null,null,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,null,null,null,null],"windows-1250":[8364,129,8218,131,8222,8230,8224,8225,136,8240,352,8249,346,356,381,377,144,8216,8217,8220,8221,8226,8211,8212,152,8482,353,8250,347,357,382,378,160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379,176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],"windows-1251":[1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039,1106,8216,8217,8220,8221,8226,8211,8212,152,8482,1113,8250,1114,1116,1115,1119,160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031,176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103],"windows-1252":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],"windows-1253":[8364,129,8218,402,8222,8230,8224,8225,136,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,157,158,159,160,901,902,163,164,165,166,167,168,169,null,171,172,173,174,8213,176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],"windows-1254":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255],"windows-1255":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,156,157,158,159,160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1520,1521,1522,1523,1524,null,null,null,null,null,null,null,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],"windows-1256":[8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672,1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722,160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567,1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603,224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239,1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746],"windows-1257":[8364,129,8218,131,8222,8230,8224,8225,136,8240,138,8249,140,168,711,184,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,175,731,159,160,null,162,163,164,null,166,167,216,169,342,171,172,173,174,198,176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729],"windows-1258":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207,272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223,224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239,273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255],"x-mac-cyrillic":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,8224,176,1168,163,167,8226,182,1030,174,169,8482,1026,1106,8800,1027,1107,8734,177,8804,8805,1110,181,1169,1032,1028,1108,1031,1111,1033,1113,1034,1114,1112,1029,172,8730,402,8776,8710,171,187,8230,160,1035,1115,1036,1116,1109,8211,8212,8220,8221,8216,8217,247,8222,1038,1118,1039,1119,8470,1025,1105,1103,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,8364]}||{};var v=Math.floor;function w(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}function _(e){return 0<=e&&e<=127}var k=_;function x(e){this.tokens=[].slice.call(e),this.tokens.reverse()}x.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():-1},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.pop());else this.tokens.push(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.shift());else this.tokens.unshift(e)}};function E(e,t){if(e)throw TypeError("Decoder error");return t||65533}function S(e){throw TypeError("The code point "+e+" could not be encoded.")}function A(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(C,e)?C[e]:null}var j=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],C={};j.forEach((function(e){e.encodings.forEach((function(e){e.labels.forEach((function(t){C[t]=e}))}))}));var T,B,R={},O={};function I(e,t){return t&&t[e]||null}function P(e,t){var r=t.indexOf(e);return-1===r?null:r}function D(e){if(!("encoding-indexes"in global))throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");return global["encoding-indexes"][e]}function M(e,t){if(!(this instanceof M))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0!==e?String(e):"utf-8",t=w(t),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var r=A(e);if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!O[r.name])throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");return this._encoding=r,Boolean(t.fatal)&&(this._error_mode="fatal"),Boolean(t.ignoreBOM)&&(this._ignoreBOM=!0),Object.defineProperty||(this.encoding=this._encoding.name.toLowerCase(),this.fatal="fatal"===this._error_mode,this.ignoreBOM=this._ignoreBOM),this}function F(e,t){if(!(this instanceof F))throw TypeError("Called as a function. Did you forget 'new'?");t=w(t),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=Boolean(t.fatal)?"fatal":"replacement";if(Boolean(t.NONSTANDARD_allowLegacyEncoding)){var r=A(e=void 0!==e?String(e):"utf-8");if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!R[r.name])throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");this._encoding=r}else this._encoding=A("utf-8"),void 0!==e&&"console"in global&&console.warn("TextEncoder constructor called with encoding label, which is ignored.");return Object.defineProperty||(this.encoding=this._encoding.name.toLowerCase()),this}function L(e){var t=e.fatal,r=0,n=0,i=0,a=128,o=191;this.handler=function(e,s){if(-1===s&&0!==i)return i=0,E(t);if(-1===s)return-1;if(0===i){if(b(s,0,127))return s;if(b(s,194,223))i=1,r=31&s;else if(b(s,224,239))224===s&&(a=160),237===s&&(o=159),i=2,r=15&s;else{if(!b(s,240,244))return E(t);240===s&&(a=144),244===s&&(o=143),i=3,r=7&s}return null}if(!b(s,a,o))return r=i=n=0,a=128,o=191,e.prepend(s),E(t);if(a=128,o=191,r=r<<6|63&s,(n+=1)!==i)return null;var u=r;return r=i=n=0,u}}function N(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r,n;b(t,128,2047)?(r=1,n=192):b(t,2048,65535)?(r=2,n=224):b(t,65536,1114111)&&(r=3,n=240);for(var i=[(t>>6*r)+n];r>0;){var a=t>>6*(r-1);i.push(128|63&a),r-=1}return i}}function z(e,t){var r=t.fatal;this.handler=function(t,n){if(-1===n)return-1;if(_(n))return n;var i=e[n-128];return null===i?E(r):i}}function U(e,t){t.fatal;this.handler=function(t,r){if(-1===r)return-1;if(k(r))return r;var n=P(r,e);return null===n&&S(r),n+128}}function q(e){var t=e.fatal,r=0,n=0,i=0;this.handler=function(e,a){if(-1===a&&0===r&&0===n&&0===i)return-1;var o;if(-1!==a||0===r&&0===n&&0===i||(r=0,n=0,i=0,E(t)),0!==i){o=null,b(a,48,57)&&(o=function(e){if(e>39419&&e<189e3||e>1237575)return null;if(7457===e)return 59335;var t,r=0,n=0,i=D("gb18030-ranges");for(t=0;t<i.length;++t){var a=i[t];if(!(a[0]<=e))break;r=a[0],n=a[1]}return n+e-r}(10*(126*(10*(r-129)+n-48)+i-129)+a-48));var s=[n,i,a];return r=0,n=0,i=0,null===o?(e.prepend(s),E(t)):o}if(0!==n)return b(a,129,254)?(i=a,null):(e.prepend([n,a]),r=0,n=0,E(t));if(0!==r){if(b(a,48,57))return n=a,null;var u=r,c=null;r=0;var l=a<127?64:65;return(b(a,64,126)||b(a,128,254))&&(c=190*(u-129)+(a-l)),null===(o=null===c?null:I(c,D("gb18030")))&&_(a)&&e.prepend(a),null===o?E(t):o}return _(a)?a:128===a?8364:b(a,129,254)?(r=a,null):E(t)}}function H(e,t){e.fatal;this.handler=function(e,r){if(-1===r)return-1;if(k(r))return r;if(58853===r)return S(r);if(t&&8364===r)return 128;var n=P(r,D("gb18030"));if(null!==n){var i=n%190;return[v(n/190)+129,i+(i<63?64:65)]}if(t)return S(r);n=function(e){if(59335===e)return 7457;var t,r=0,n=0,i=D("gb18030-ranges");for(t=0;t<i.length;++t){var a=i[t];if(!(a[1]<=e))break;r=a[1],n=a[0]}return n+e-r}(r);var a=v(n/10/126/10),o=v((n-=10*a*126*10)/10/126),s=v((n-=10*o*126)/10);return[a+129,o+48,s+129,n-10*s+48]}}function G(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0;var o=n<127?64:98;switch((b(n,64,126)||b(n,161,254))&&(a=157*(i-129)+(n-o)),a){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var s=null===a?null:I(a,D("big5"));return null===s&&_(n)&&e.prepend(n),null===s?E(t):s}return _(n)?n:b(n,129,254)?(r=n,null):E(t)}}function W(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r=function(e){var t=B=B||D("big5").map((function(e,t){return t<5024?null:e}));return 9552===e||9566===e||9569===e||9578===e||21313===e||21317===e?t.lastIndexOf(e):P(e,t)}(t);if(null===r)return S(t);var n=v(r/157)+129;if(n<161)return S(t);var i=r%157;return[n,i+(i<63?64:98)]}}function V(e){var t=e.fatal,r=!1,n=0;this.handler=function(e,i){if(-1===i&&0!==n)return n=0,E(t);if(-1===i&&0===n)return-1;if(142===n&&b(i,161,223))return n=0,65216+i;if(143===n&&b(i,161,254))return r=!0,n=i,null;if(0!==n){var a=n;n=0;var o=null;return b(a,161,254)&&b(i,161,254)&&(o=I(94*(a-161)+(i-161),D(r?"jis0212":"jis0208"))),r=!1,b(i,161,254)||e.prepend(i),null===o?E(t):o}return _(i)?i:142===i||143===i||b(i,161,254)?(n=i,null):E(t)}}function K(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;if(165===t)return 92;if(8254===t)return 126;if(b(t,65377,65439))return[142,t-65377+161];8722===t&&(t=65293);var r=P(t,D("jis0208"));return null===r?S(t):[v(r/94)+161,r%94+161]}}function J(e){var t=e.fatal,r=0,n=1,i=2,a=3,o=4,s=5,u=6,c=r,l=r,h=0,p=!1;this.handler=function(e,f){switch(c){default:case r:return 27===f?(c=s,null):b(f,0,127)&&14!==f&&15!==f&&27!==f?(p=!1,f):-1===f?-1:(p=!1,E(t));case n:return 27===f?(c=s,null):92===f?(p=!1,165):126===f?(p=!1,8254):b(f,0,127)&&14!==f&&15!==f&&27!==f&&92!==f&&126!==f?(p=!1,f):-1===f?-1:(p=!1,E(t));case i:return 27===f?(c=s,null):b(f,33,95)?(p=!1,65344+f):-1===f?-1:(p=!1,E(t));case a:return 27===f?(c=s,null):b(f,33,126)?(p=!1,h=f,c=o,null):-1===f?-1:(p=!1,E(t));case o:if(27===f)return c=s,E(t);if(b(f,33,126)){c=a;var d=I(94*(h-33)+f-33,D("jis0208"));return null===d?E(t):d}return-1===f?(c=a,e.prepend(f),E(t)):(c=a,E(t));case s:return 36===f||40===f?(h=f,c=u,null):(e.prepend(f),p=!1,c=l,E(t));case u:var m=h;h=0;var g=null;if(40===m&&66===f&&(g=r),40===m&&74===f&&(g=n),40===m&&73===f&&(g=i),36!==m||64!==f&&66!==f||(g=a),null!==g){c=c=g;var y=p;return p=!0,y?E(t):null}return e.prepend([m,f]),p=!1,c=l,E(t)}}}function Q(e){e.fatal;var t=0,r=1,n=2,i=t;this.handler=function(e,a){if(-1===a&&i!==t)return e.prepend(a),i=t,[27,40,66];if(-1===a&&i===t)return-1;if(!(i!==t&&i!==r||14!==a&&15!==a&&27!==a))return S(65533);if(i===t&&k(a))return a;if(i===r&&(k(a)&&92!==a&&126!==a||165==a||8254==a)){if(k(a))return a;if(165===a)return 92;if(8254===a)return 126}if(k(a)&&i!==t)return e.prepend(a),i=t,[27,40,66];if((165===a||8254===a)&&i!==r)return e.prepend(a),i=r,[27,40,74];8722===a&&(a=65293);var o=P(a,D("jis0208"));return null===o?S(a):i!==n?(e.prepend(a),i=n,[27,36,66]):[v(o/94)+33,o%94+33]}}function $(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0;var o=n<127?64:65,s=i<160?129:193;if((b(n,64,126)||b(n,128,252))&&(a=188*(i-s)+n-o),b(a,8836,10715))return 48508+a;var u=null===a?null:I(a,D("jis0208"));return null===u&&_(n)&&e.prepend(n),null===u?E(t):u}return _(n)||128===n?n:b(n,161,223)?65216+n:b(n,129,159)||b(n,224,252)?(r=n,null):E(t)}}function Y(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t)||128===t)return t;if(165===t)return 92;if(8254===t)return 126;if(b(t,65377,65439))return t-65377+161;8722===t&&(t=65293);var r=function(e){return(T=T||D("jis0208").map((function(e,t){return b(t,8272,8835)?null:e}))).indexOf(e)}(t);if(null===r)return S(t);var n=v(r/188),i=r%188;return[n+(n<31?129:193),i+(i<63?64:65)]}}function X(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0,b(n,65,254)&&(a=190*(i-129)+(n-65));var o=null===a?null:I(a,D("euc-kr"));return null===a&&_(n)&&e.prepend(n),null===o?E(t):o}return _(n)?n:b(n,129,254)?(r=n,null):E(t)}}function Z(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r=P(t,D("euc-kr"));return null===r?S(t):[v(r/190)+129,r%190+65]}}function ee(e,t){var r=e>>8,n=255&e;return t?[r,n]:[n,r]}function te(e,t){var r=t.fatal,n=null,i=null;this.handler=function(t,a){if(-1===a&&(null!==n||null!==i))return E(r);if(-1===a&&null===n&&null===i)return-1;if(null===n)return n=a,null;var o;if(o=e?(n<<8)+a:(a<<8)+n,n=null,null!==i){var s=i;return i=null,b(o,56320,57343)?65536+1024*(s-55296)+(o-56320):(t.prepend(ee(o,e)),E(r))}return b(o,55296,56319)?(i=o,null):b(o,56320,57343)?E(r):o}}function re(e,t){t.fatal;this.handler=function(t,r){if(-1===r)return-1;if(b(r,0,65535))return ee(r,e);var n=ee(55296+(r-65536>>10),e),i=ee(56320+(r-65536&1023),e);return n.concat(i)}}function ne(e){e.fatal;this.handler=function(e,t){return-1===t?-1:_(t)?t:63360+t-128}}function ie(e){e.fatal;this.handler=function(e,t){return-1===t?-1:k(t)?t:b(t,63360,63487)?t-63360+128:S(t)}}Object.defineProperty&&(Object.defineProperty(M.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(M.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(M.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),M.prototype.decode=function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=w(t),this._do_not_flush||(this._decoder=O[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(t.stream);for(var n,i=new x(r),a=[];;){var o=i.read();if(-1===o)break;if(-1===(n=this._decoder.handler(i,o)))break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}if(!this._do_not_flush){do{if(-1===(n=this._decoder.handler(i,i.read())))break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}while(!i.endOfStream());this._decoder=null}return function(e){var t,r;return t=["UTF-8","UTF-16LE","UTF-16BE"],r=this._encoding.name,-1===t.indexOf(r)||this._ignoreBOM||this._BOMseen||(e.length>0&&65279===e[0]?(this._BOMseen=!0,e.shift()):e.length>0&&(this._BOMseen=!0)),function(e){for(var t="",r=0;r<e.length;++r){var n=e[r];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return t}(e)}.call(this,a)},Object.defineProperty&&Object.defineProperty(F.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),F.prototype.encode=function(e,t){e=void 0===e?"":String(e),t=w(t),this._do_not_flush||(this._encoder=R[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(t.stream);for(var r,n=new x(function(e){for(var t=String(e),r=t.length,n=0,i=[];n<r;){var a=t.charCodeAt(n);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(n===r-1)i.push(65533);else{var o=t.charCodeAt(n+1);if(56320<=o&&o<=57343){var s=1023&a,u=1023&o;i.push(65536+(s<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(e)),i=[];;){var a=n.read();if(-1===a)break;if(-1===(r=this._encoder.handler(n,a)))break;Array.isArray(r)?i.push.apply(i,r):i.push(r)}if(!this._do_not_flush){for(;-1!==(r=this._encoder.handler(n,n.read()));)Array.isArray(r)?i.push.apply(i,r):i.push(r);this._encoder=null}return new Uint8Array(i)},R["UTF-8"]=function(e){return new N(e)},O["UTF-8"]=function(e){return new L(e)},"encoding-indexes"in global&&j.forEach((function(e){"Legacy single-byte encodings"===e.heading&&e.encodings.forEach((function(e){var t=e.name,r=D(t.toLowerCase());O[t]=function(e){return new z(r,e)},R[t]=function(e){return new U(r,e)}}))})),O.GBK=function(e){return new q(e)},R.GBK=function(e){return new H(e,!0)},R.gb18030=function(e){return new H(e)},O.gb18030=function(e){return new q(e)},R.Big5=function(e){return new W(e)},O.Big5=function(e){return new G(e)},R["EUC-JP"]=function(e){return new K(e)},O["EUC-JP"]=function(e){return new V(e)},R["ISO-2022-JP"]=function(e){return new Q(e)},O["ISO-2022-JP"]=function(e){return new J(e)},R.Shift_JIS=function(e){return new Y(e)},O.Shift_JIS=function(e){return new $(e)},R["EUC-KR"]=function(e){return new Z(e)},O["EUC-KR"]=function(e){return new X(e)},R["UTF-16BE"]=function(e){return new re(!0,e)},O["UTF-16BE"]=function(e){return new te(!0,e)},R["UTF-16LE"]=function(e){return new re(!1,e)},O["UTF-16LE"]=function(e){return new te(!1,e)},R["x-user-defined"]=function(e){return new ie(e)},O["x-user-defined"]=function(e){return new ne(e)};function ae(e){return Buffer.from(e).toString("base64")}function oe(e){return Buffer.from(e,"base64").toString("ascii")}let se;se=Symbol.iterator;class ue{constructor(e){var t,r,n;n=void 0,(r="map")in(t=this)?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,this.map={},e instanceof ue?e.forEach((e,t)=>this.append(t,e)):Array.isArray(e)?e.forEach(e=>this.append(e[0],e[1])):e&&Object.getOwnPropertyNames(e).forEach(t=>this.append(t,e[t]))}append(e,t){e=ce(e),t=le(t);const r=this.map[e];this.map[e]=r?`${r}, ${t}`:t}delete(e){delete this.map[ce(e)]}get(e){return e=ce(e),this.has(e)?this.map[e]:null}has(e){return this.map.hasOwnProperty(ce(e))}set(e,t){this.map[ce(e)]=le(t)}forEach(e,t=null){for(const r in this.map)this.map.hasOwnProperty(r)&&(t?e.call(t,this.map[r],r,this):e(this.map[r],r,this))}keys(){const e=[];return this.forEach((function(t,r){e.push(r)})),he(e)}values(){const e=[];return this.forEach((function(t){e.push(t)})),he(e)}entries(){const e=[];return this.forEach((function(t,r){e.push([r,t])})),he(e)}*[se](){yield*this.entries()}}function ce(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function le(e){return"string"!=typeof e&&(e=String(e)),e}function he(e){const t={next(){const t=e.shift();return{done:void 0===t,value:t}}};return t[Symbol.iterator]=function(){return t},t}function pe(e,t){if(!e)throw new Error("@loaders.gl/polyfills assertion "+t)}var fe=r(16),de=r.n(fe);function me(e){if((t=e)&&t instanceof ArrayBuffer)return e;var t;if((e=>e&&e instanceof Buffer)(e)){return new Uint8Array(e).buffer}if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error(`toArrayBuffer(${JSON.stringify(e,null,2).slice(10)})`)}async function ge(e){const t=[];return await new Promise((r,n)=>{e.on("error",e=>n(e)),e.on("readable",()=>e.read()),e.on("data",e=>{"string"==typeof e&&n(new Error("Read stream not binary")),t.push(me(e))}),e.on("end",()=>{const e=function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),r=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(r);let i=0;for(const e of t)n.set(e,i),i+=e.byteLength;return n.buffer}(t);r(e)})})}var ye=r(5);function be(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ve=e=>"function"==typeof e,we=e=>(e=>null!==e&&"object"==typeof e)(e)&&ve(e.read)&&ve(e.pipe)&&(e=>"boolean"==typeof e)(e.readable);class _e{constructor(e,t){be(this,"ok",void 0),be(this,"status",void 0),be(this,"statusText",void 0),be(this,"headers",void 0),be(this,"url",void 0),be(this,"bodyUsed",!1),be(this,"_body",void 0);const{headers:r,status:n=200,statusText:i="OK",url:a}=t||{};this.url=a,this.ok=200===n,this.status=n,this.statusText=i,this.headers=new ue((null==t?void 0:t.headers)||{}),we(e)?this._body=function(e,t){switch(t.get("content-encoding")){case"br":return e.pipe(de.a.createBrotliDecompress());case"gzip":return e.pipe(de.a.createGunzip());case"deflate":return e.pipe(de.a.createDeflate());default:return e}}(e,r):this._body="string"==typeof e?ye.Readable.from([(new TextEncoder).encode(e)]):ye.Readable.from([e||new ArrayBuffer(0)])}get body(){return pe(!this.bodyUsed),pe(we(this._body)),this.bodyUsed=!0,this._body}async arrayBuffer(){if(!we(this._body))return this._body||new ArrayBuffer(0);return await ge(this._body)}async text(){const e=await this.arrayBuffer();return(new TextDecoder).decode(e)}async json(){const e=await this.text();return JSON.parse(e)}async blob(){if("undefined"==typeof Blob)throw new Error("Blob polyfill not installed");return new Blob([await this.arrayBuffer()])}}var ke=r(40),xe=r.n(ke),Ee=r(51),Se=r.n(Ee),Ae=r(3),je=r.n(Ae);async function Ce(e,t){const r=e.split("?")[0];try{const t=await new Promise((e,t)=>{const n=je.a.createReadStream(r,{encoding:null});n.once("readable",()=>e(n)),n.on("error",e=>t(e))}),n=200,i="OK",a=function(e){const t={};if(!t["content-length"]){const r=je.a.statSync(e);t["content-length"]=r.size}e.endsWith(".gz")&&(e=e.slice(0,-3),t["content-encoding"]="gzip");return new ue(t)}(r);return new _e(t,{headers:a,status:n,statusText:i,url:e})}catch(t){const r=400,n=t.message,i={};return new _e(t.message,{headers:i,status:r,statusText:n,url:e})}}const Te=e=>e.startsWith("data:");async function Be(e,t){try{if(!(e=>e.startsWith("http:")||e.startsWith("https:"))(e)&&!Te(e))return await Ce(e);if(Te(e)){const{arrayBuffer:t,mimeType:r}=function(e){const t=e.indexOf(",");let r,n;return";base64"===e.slice(t-7,t)?(r=Buffer.from(e.slice(t+1),"base64"),n=e.slice(5,t-7).trim()):(r=Buffer.from(decodeURIComponent(e.slice(t+1))),n=e.slice(5,t).trim()),n?n.startsWith(";")&&(n="text/plain"+n):n="text/plain;charset=US-ASCII",{arrayBuffer:me(r),mimeType:n}}(e);return new _e(t,{headers:{"content-type":r},url:e})}const r={},n=e;e.endsWith(".gz")&&(e=e.slice(0,-3),r["content-encoding"]="gzip");const i=await async function(e,t){return await new Promise((r,n)=>{const i=function(e,t){const r=(null==t?void 0:t.headers)||{},n={};for(const e of Object.keys(r))n[e.toLowerCase()]=r[e];n["accept-encoding"]=n["accept-encoding"]||"gzip,br,deflate";const i=new URL(e);return{hostname:i.hostname,path:i.pathname,method:"GET",...t,...null==t?void 0:t.fetch,headers:n,port:i.port}}(e,t),a=e.startsWith("https:")?Se.a.request(i,e=>r(e)):xe.a.request(i,e=>r(e));a.on("error",e=>n(e)),a.end()})}(n,t),a=function(e,t,r={}){const n={};if(t&&t.headers){const e=t.headers;for(const t in e){const r=e[t];n[t.toLowerCase()]=String(r)}}if(!n["content-length"]){const t=function(e){return Te(e)?e.length-"data:".length:null}(e);Number.isFinite(t)&&(n["content-length"]=t)}return Object.assign(n,r),new ue(n)}(e,i,r),{status:o,statusText:s}=function(e){if(e.statusCode)return{status:e.statusCode,statusText:e.statusMessage||"NA"};return{status:200,statusText:"OK"}}(i),u=!t||t.followRedirect||void 0===t.followRedirect;if(o>=300&&o<400&&a.has("location")&&u){const r=function(e,t){if(t.startsWith("http"))return t;const r=new URL(e);return r.pathname=t,r.href}(e,a.get("location"));return await Be(r,t)}return new _e(i,{headers:a,status:o,statusText:s,url:e})}catch(t){return new _e(null,{status:400,statusText:String(t),url:e})}}var Re=r(263),Oe=r.n(Re),Ie=r(65),Pe=r.n(Ie);function De(e,t){const r=function(e,t){const r=t.type?t.type.replace("image/",""):"jpeg",n=Pe()(e.data,[e.width,e.height,4],[4,4*e.width,1],0);return Oe()(n,r,t)}(e,t);return new Promise(e=>{const t=[];r.on("data",e=>t.push(e)),r.on("end",()=>{const r=Buffer.concat(t);e(function(e){if(Buffer.isBuffer(e)){return new Uint8Array(e).buffer}return e}(r))})})}var Me=r(264),Fe=r.n(Me);async function Le(e,t){if(!t)throw new Error("MIMEType is required to parse image under Node.js");const r=e instanceof Buffer?e:Buffer.from(e);return await function(e,t){return new Promise(r=>Fe()(e,t,(e,t)=>{if(e)throw e;const n=[...t.shape],i=4===t.shape.length?t.shape.shift():1,a=t.data instanceof Buffer?new Uint8Array(t.data):t.data;r({shape:n,data:a,width:t.shape[0],height:t.shape[1],components:t.shape[2],layers:i?[i]:[]})}))}(r,t)}var Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:function(e){return"Symbol("+e+")"};function ze(){}var Ue="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;function qe(e){return"object"==typeof e&&null!==e||"function"==typeof e}var He=ze,Ge=Promise,We=Promise.prototype.then,Ve=Promise.resolve.bind(Ge),Ke=Promise.reject.bind(Ge);function Je(e){return new Ge(e)}function Qe(e){return Ve(e)}function $e(e){return Ke(e)}function Ye(e,t,r){return We.call(e,t,r)}function Xe(e,t,r){Ye(Ye(e,t,r),void 0,He)}function Ze(e,t){Xe(e,t)}function et(e,t){Xe(e,void 0,t)}function tt(e,t,r){return Ye(e,t,r)}function rt(e){Ye(e,void 0,He)}var nt=function(){var e=Ue&&Ue.queueMicrotask;if("function"==typeof e)return e;var t=Qe(void 0);return function(e){return Ye(t,e)}}();function it(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function at(e,t,r){try{return Qe(it(e,t,r))}catch(e){return $e(e)}}var ot=function(){function e(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}return Object.defineProperty(e.prototype,"length",{get:function(){return this._size},enumerable:!1,configurable:!0}),e.prototype.push=function(e){var t=this._back,r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size},e.prototype.shift=function(){var e=this._front,t=e,r=this._cursor,n=r+1,i=e._elements,a=i[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),i[r]=void 0,a},e.prototype.forEach=function(e){for(var t=this._cursor,r=this._front,n=r._elements;!(t===n.length&&void 0===r._next||t===n.length&&(t=0,0===(n=(r=r._next)._elements).length));)e(n[t]),++t},e.prototype.peek=function(){var e=this._front,t=this._cursor;return e._elements[t]},e}();function st(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ht(e):"closed"===t._state?function(e){ht(e),dt(e)}(e):pt(e,t._storedError)}function ut(e,t){return ci(e._ownerReadableStream,t)}function ct(e){"readable"===e._ownerReadableStream._state?ft(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){pt(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function lt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function ht(e){e._closedPromise=Je((function(t,r){e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function pt(e,t){ht(e),ft(e,t)}function ft(e,t){void 0!==e._closedPromise_reject&&(rt(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function dt(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}var mt=Ne("[[AbortSteps]]"),gt=Ne("[[ErrorSteps]]"),yt=Ne("[[CancelSteps]]"),bt=Ne("[[PullSteps]]"),vt=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},wt=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function _t(e,t){if(void 0!==e&&("object"!=typeof(r=e)&&"function"!=typeof r))throw new TypeError(t+" is not an object.");var r}function kt(e,t){if("function"!=typeof e)throw new TypeError(t+" is not a function.")}function xt(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(t+" is not an object.")}function Et(e,t,r){if(void 0===e)throw new TypeError("Parameter "+t+" is required in '"+r+"'.")}function St(e,t,r){if(void 0===e)throw new TypeError(t+" is required in '"+r+"'.")}function At(e){return Number(e)}function jt(e){return 0===e?0:e}function Ct(e,t){var r=Number.MAX_SAFE_INTEGER,n=Number(e);if(n=jt(n),!vt(n))throw new TypeError(t+" is not a finite number");if((n=function(e){return jt(wt(e))}(n))<0||n>r)throw new TypeError(t+" is outside the accepted range of 0 to "+r+", inclusive");return vt(n)&&0!==n?n:0}function Tt(e,t){if(!si(e))throw new TypeError(t+" is not a ReadableStream.")}function Bt(e){return new Ft(e)}function Rt(e,t){e._reader._readRequests.push(t)}function Ot(e,t,r){var n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function It(e){return e._reader._readRequests.length}function Pt(e){var t=e._reader;return void 0!==t&&!!Lt(t)}var Dt,Mt,Ft=function(){function e(e){if(Et(e,1,"ReadableStreamDefaultReader"),Tt(e,"First parameter"),ui(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");st(this,e),this._readRequests=new ot}return Object.defineProperty(e.prototype,"closed",{get:function(){return Lt(this)?this._closedPromise:$e(zt("closed"))},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),Lt(this)?void 0===this._ownerReadableStream?$e(lt("cancel")):ut(this,e):$e(zt("cancel"))},e.prototype.read=function(){if(!Lt(this))return $e(zt("read"));if(void 0===this._ownerReadableStream)return $e(lt("read from"));var e,t,r=Je((function(r,n){e=r,t=n}));return Nt(this,{_chunkSteps:function(t){return e({value:t,done:!1})},_closeSteps:function(){return e({value:void 0,done:!0})},_errorSteps:function(e){return t(e)}}),r},e.prototype.releaseLock=function(){if(!Lt(this))throw zt("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ct(this)}},e}();function Lt(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Ft)}function Nt(e,t){var r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[bt](t)}function zt(e){return new TypeError("ReadableStreamDefaultReader.prototype."+e+" can only be used on a ReadableStreamDefaultReader")}Object.defineProperties(Ft.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Ft.prototype,Ne.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0}),"symbol"==typeof Ne.asyncIterator&&((Dt={})[Ne.asyncIterator]=function(){return this},Mt=Dt,Object.defineProperty(Mt,Ne.asyncIterator,{enumerable:!1}));var Ut=function(){function e(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}return e.prototype.next=function(){var e=this,t=function(){return e._nextSteps()};return this._ongoingPromise=this._ongoingPromise?tt(this._ongoingPromise,t,t):t(),this._ongoingPromise},e.prototype.return=function(e){var t=this,r=function(){return t._returnSteps(e)};return this._ongoingPromise?tt(this._ongoingPromise,r,r):r()},e.prototype._nextSteps=function(){var e=this;if(this._isFinished)return Promise.resolve({value:void 0,done:!0});var t,r,n=this._reader;if(void 0===n._ownerReadableStream)return $e(lt("iterate"));var i=Je((function(e,n){t=e,r=n}));return Nt(n,{_chunkSteps:function(r){e._ongoingPromise=void 0,nt((function(){return t({value:r,done:!1})}))},_closeSteps:function(){e._ongoingPromise=void 0,e._isFinished=!0,ct(n),t({value:void 0,done:!0})},_errorSteps:function(t){e._ongoingPromise=void 0,e._isFinished=!0,ct(n),r(t)}}),i},e.prototype._returnSteps=function(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;var t=this._reader;if(void 0===t._ownerReadableStream)return $e(lt("finish iterating"));if(!this._preventCancel){var r=ut(t,e);return ct(t),tt(r,(function(){return{value:e,done:!0}}))}return ct(t),Qe({value:e,done:!0})},e}(),qt={next:function(){return Ht(this)?this._asyncIteratorImpl.next():$e(Gt("next"))},return:function(e){return Ht(this)?this._asyncIteratorImpl.return(e):$e(Gt("return"))}};function Ht(e){if(!qe(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Ut}catch(e){return!1}}function Gt(e){return new TypeError("ReadableStreamAsyncIterator."+e+" can only be used on a ReadableSteamAsyncIterator")}void 0!==Mt&&Object.setPrototypeOf(qt,Mt);var Wt=Number.isNaN||function(e){return e!=e};function Vt(e){return e.slice()}function Kt(e,t,r,n,i){new Uint8Array(e).set(new Uint8Array(r,n,i),t)}function Jt(e,t,r){if(e.slice)return e.slice(t,r);var n=r-t,i=new ArrayBuffer(n);return Kt(i,0,e,t,n),i}function Qt(e){var t=Jt(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function $t(e){var t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Yt(e,t,r){if("number"!=typeof(n=r)||Wt(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Xt(e){e._queue=new ot,e._queueTotalSize=0}var Zt=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"view",{get:function(){if(!rr(this))throw Er("view");return this._view},enumerable:!1,configurable:!0}),e.prototype.respond=function(e){if(!rr(this))throw Er("respond");if(Et(e,1,"respond"),e=Ct(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,_r(this._associatedReadableByteStreamController,e)},e.prototype.respondWithNewView=function(e){if(!rr(this))throw Er("respondWithNewView");if(Et(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");e.buffer,kr(this._associatedReadableByteStreamController,e)},e}();Object.defineProperties(Zt.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Zt.prototype,Ne.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});var er=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"byobRequest",{get:function(){if(!tr(this))throw Sr("byobRequest");return vr(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!tr(this))throw Sr("desiredSize");return wr(this)},enumerable:!1,configurable:!0}),e.prototype.close=function(){if(!tr(this))throw Sr("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");var e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError("The stream (in "+e+" state) is not in the readable state and cannot be closed");gr(this)},e.prototype.enqueue=function(e){if(!tr(this))throw Sr("enqueue");if(Et(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");var t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError("The stream (in "+t+" state) is not in the readable state and cannot be enqueued to");yr(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!tr(this))throw Sr("error");br(this,e)},e.prototype[yt]=function(e){ir(this),Xt(this);var t=this._cancelAlgorithm(e);return mr(this),t},e.prototype[bt]=function(e){var t=this._controlledReadableByteStream;if(this._queueTotalSize>0){var r=this._queue.shift();this._queueTotalSize-=r.byteLength,lr(this);var n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);e._chunkSteps(n)}else{var i=this._autoAllocateChunkSize;if(void 0!==i){var a=void 0;try{a=new ArrayBuffer(i)}catch(t){return void e._errorSteps(t)}var o={buffer:a,bufferByteLength:i,byteOffset:0,byteLength:i,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}Rt(t,e),nr(this)}},e}();function tr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof er)}function rr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Zt)}function nr(e){(function(e){var t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(e._closeRequested)return!1;if(!e._started)return!1;if(Pt(t)&&It(t)>0)return!0;if(Tr(t)&&Cr(t)>0)return!0;if(wr(e)>0)return!0;return!1})(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,Xe(e._pullAlgorithm(),(function(){e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,nr(e))}),(function(t){br(e,t)}))))}function ir(e){hr(e),e._pendingPullIntos=new ot}function ar(e,t){var r=!1;"closed"===e._state&&(r=!0);var n=or(t);"default"===t.readerType?Ot(e,n,r):function(e,t,r){var n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function or(e){var t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function sr(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function ur(e,t){var r=t.elementSize,n=t.bytesFilled-t.bytesFilled%r,i=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),a=t.bytesFilled+i,o=a-a%r,s=i,u=!1;o>n&&(s=o-t.bytesFilled,u=!0);for(var c=e._queue;s>0;){var l=c.peek(),h=Math.min(s,l.byteLength),p=t.byteOffset+t.bytesFilled;Kt(t.buffer,p,l.buffer,l.byteOffset,h),l.byteLength===h?c.shift():(l.byteOffset+=h,l.byteLength-=h),e._queueTotalSize-=h,cr(e,h,t),s-=h}return u}function cr(e,t,r){r.bytesFilled+=t}function lr(e){0===e._queueTotalSize&&e._closeRequested?(mr(e),li(e._controlledReadableByteStream)):nr(e)}function hr(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function pr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;var t=e._pendingPullIntos.peek();ur(e,t)&&(dr(e),ar(e._controlledReadableByteStream,t))}}function fr(e,t){var r=e._pendingPullIntos.peek();hr(e),"closed"===e._controlledReadableByteStream._state?function(e,t){var r=e._controlledReadableByteStream;if(Tr(r))for(;Cr(r)>0;){ar(r,dr(e))}}(e):function(e,t,r){if(cr(0,t,r),!(r.bytesFilled<r.elementSize)){dr(e);var n=r.bytesFilled%r.elementSize;if(n>0){var i=r.byteOffset+r.bytesFilled,a=Jt(r.buffer,i-n,i);sr(e,a,0,a.byteLength)}r.bytesFilled-=n,ar(e._controlledReadableByteStream,r),pr(e)}}(e,t,r),nr(e)}function dr(e){return e._pendingPullIntos.shift()}function mr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function gr(e){var t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0)if(e._pendingPullIntos.peek().bytesFilled>0){var r=new TypeError("Insufficient bytes to fill elements in the given buffer");throw br(e,r),r}mr(e),li(t)}}function yr(e,t){var r=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===r._state){var n=t.buffer,i=t.byteOffset,a=t.byteLength,o=n;if(e._pendingPullIntos.length>0){var s=e._pendingPullIntos.peek();s.buffer,0,s.buffer=s.buffer}if(hr(e),Pt(r))if(0===It(r))sr(e,o,i,a);else e._pendingPullIntos.length>0&&dr(e),Ot(r,new Uint8Array(o,i,a),!1);else Tr(r)?(sr(e,o,i,a),pr(e)):sr(e,o,i,a);nr(e)}}function br(e,t){var r=e._controlledReadableByteStream;"readable"===r._state&&(ir(e),Xt(e),mr(e),hi(r,t))}function vr(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){var t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(Zt.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function wr(e){var t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function _r(e,t){var r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=r.buffer,fr(e,t)}function kr(e,t){var r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");var n=t.byteLength;r.buffer=t.buffer,fr(e,n)}function xr(e,t,r,n,i,a,o){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Xt(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,t._autoAllocateChunkSize=o,t._pendingPullIntos=new ot,e._readableStreamController=t,Xe(Qe(r()),(function(){t._started=!0,nr(t)}),(function(e){br(t,e)}))}function Er(e){return new TypeError("ReadableStreamBYOBRequest.prototype."+e+" can only be used on a ReadableStreamBYOBRequest")}function Sr(e){return new TypeError("ReadableByteStreamController.prototype."+e+" can only be used on a ReadableByteStreamController")}function Ar(e){return new Br(e)}function jr(e,t){e._reader._readIntoRequests.push(t)}function Cr(e){return e._reader._readIntoRequests.length}function Tr(e){var t=e._reader;return void 0!==t&&!!Rr(t)}Object.defineProperties(er.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(er.prototype,Ne.toStringTag,{value:"ReadableByteStreamController",configurable:!0});var Br=function(){function e(e){if(Et(e,1,"ReadableStreamBYOBReader"),Tt(e,"First parameter"),ui(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!tr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");st(this,e),this._readIntoRequests=new ot}return Object.defineProperty(e.prototype,"closed",{get:function(){return Rr(this)?this._closedPromise:$e(Ir("closed"))},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),Rr(this)?void 0===this._ownerReadableStream?$e(lt("cancel")):ut(this,e):$e(Ir("cancel"))},e.prototype.read=function(e){if(!Rr(this))return $e(Ir("read"));if(!ArrayBuffer.isView(e))return $e(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return $e(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return $e(new TypeError("view's buffer must have non-zero byteLength"));if(e.buffer,void 0===this._ownerReadableStream)return $e(lt("read from"));var t,r,n=Je((function(e,n){t=e,r=n}));return Or(this,e,{_chunkSteps:function(e){return t({value:e,done:!1})},_closeSteps:function(e){return t({value:e,done:!0})},_errorSteps:function(e){return r(e)}}),n},e.prototype.releaseLock=function(){if(!Rr(this))throw Ir("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ct(this)}},e}();function Rr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Br)}function Or(e,t,r){var n=e._ownerReadableStream;n._disturbed=!0,"errored"===n._state?r._errorSteps(n._storedError):function(e,t,r){var n=e._controlledReadableByteStream,i=1;t.constructor!==DataView&&(i=t.constructor.BYTES_PER_ELEMENT);var a=t.constructor,o=t.buffer,s={buffer:o,bufferByteLength:o.byteLength,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:i,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(s),void jr(n,r);if("closed"!==n._state){if(e._queueTotalSize>0){if(ur(e,s)){var u=or(s);return lr(e),void r._chunkSteps(u)}if(e._closeRequested){var c=new TypeError("Insufficient bytes to fill elements in the given buffer");return br(e,c),void r._errorSteps(c)}}e._pendingPullIntos.push(s),jr(n,r),nr(e)}else{var l=new a(s.buffer,s.byteOffset,0);r._closeSteps(l)}}(n._readableStreamController,t,r)}function Ir(e){return new TypeError("ReadableStreamBYOBReader.prototype."+e+" can only be used on a ReadableStreamBYOBReader")}function Pr(e,t){var r=e.highWaterMark;if(void 0===r)return t;if(Wt(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Dr(e){var t=e.size;return t||function(){return 1}}function Mr(e,t){_t(e,t);var r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:At(r),size:void 0===n?void 0:Fr(n,t+" has member 'size' that")}}function Fr(e,t){return kt(e,t),function(t){return At(e(t))}}function Lr(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Nr(e,t,r){return kt(e,r),function(){return at(e,t,[])}}function zr(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function Ur(e,t,r){return kt(e,r),function(r,n){return at(e,t,[r,n])}}function qr(e,t){if(!Kr(e))throw new TypeError(t+" is not a WritableStream.")}Object.defineProperties(Br.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Br.prototype,Ne.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});var Hr="function"==typeof AbortController;var Gr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),void 0===e?e=null:xt(e,"First parameter");var r=Mr(t,"Second parameter"),n=function(e,t){_t(e,t);var r=null==e?void 0:e.abort,n=null==e?void 0:e.close,i=null==e?void 0:e.start,a=null==e?void 0:e.type,o=null==e?void 0:e.write;return{abort:void 0===r?void 0:Lr(r,e,t+" has member 'abort' that"),close:void 0===n?void 0:Nr(n,e,t+" has member 'close' that"),start:void 0===i?void 0:zr(i,e,t+" has member 'start' that"),write:void 0===o?void 0:Ur(o,e,t+" has member 'write' that"),type:a}}(e,"First parameter");if(Vr(this),void 0!==n.type)throw new RangeError("Invalid type is specified");var i=Dr(r);!function(e,t,r,n){var i=Object.create(pn.prototype),a=function(){},o=function(){return Qe(void 0)},s=function(){return Qe(void 0)},u=function(){return Qe(void 0)};void 0!==t.start&&(a=function(){return t.start(i)});void 0!==t.write&&(o=function(e){return t.write(e,i)});void 0!==t.close&&(s=function(){return t.close()});void 0!==t.abort&&(u=function(e){return t.abort(e)});dn(e,i,a,o,s,u,r,n)}(this,n,Pr(r,1),i)}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!Kr(this))throw _n("locked");return Jr(this)},enumerable:!1,configurable:!0}),e.prototype.abort=function(e){return void 0===e&&(e=void 0),Kr(this)?Jr(this)?$e(new TypeError("Cannot abort a stream that already has a writer")):Qr(this,e):$e(_n("abort"))},e.prototype.close=function(){return Kr(this)?Jr(this)?$e(new TypeError("Cannot close a stream that already has a writer")):en(this)?$e(new TypeError("Cannot close an already-closing stream")):$r(this):$e(_n("close"))},e.prototype.getWriter=function(){if(!Kr(this))throw _n("getWriter");return Wr(this)},e}();function Wr(e){return new nn(e)}function Vr(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new ot,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Kr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Gr)}function Jr(e){return void 0!==e._writer}function Qr(e,t){var r;if("closed"===e._state||"errored"===e._state)return Qe(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort();var n=e._state;if("closed"===n||"errored"===n)return Qe(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;var i=!1;"erroring"===n&&(i=!0,t=void 0);var a=Je((function(r,n){e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:i}}));return e._pendingAbortRequest._promise=a,i||Xr(e,t),a}function $r(e){var t=e._state;if("closed"===t||"errored"===t)return $e(new TypeError("The stream (in "+t+" state) is not in the writable state and cannot be closed"));var r,n=Je((function(t,r){var n={_resolve:t,_reject:r};e._closeRequest=n})),i=e._writer;return void 0!==i&&e._backpressure&&"writable"===t&&In(i),Yt(r=e._writableStreamController,hn,0),yn(r),n}function Yr(e,t){"writable"!==e._state?Zr(e):Xr(e,t)}function Xr(e,t){var r=e._writableStreamController;e._state="erroring",e._storedError=t;var n=e._writer;void 0!==n&&un(n,t),!function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&r._started&&Zr(e)}function Zr(e){e._state="errored",e._writableStreamController[gt]();var t=e._storedError;if(e._writeRequests.forEach((function(e){e._reject(t)})),e._writeRequests=new ot,void 0!==e._pendingAbortRequest){var r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void tn(e);Xe(e._writableStreamController[mt](r._reason),(function(){r._resolve(),tn(e)}),(function(t){r._reject(t),tn(e)}))}else tn(e)}function en(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function tn(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);var t=e._writer;void 0!==t&&jn(t,e._storedError)}function rn(e,t){var r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){Tn(e)}(r):In(r)),e._backpressure=t}Object.defineProperties(Gr.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Gr.prototype,Ne.toStringTag,{value:"WritableStream",configurable:!0});var nn=function(){function e(e){if(Et(e,1,"WritableStreamDefaultWriter"),qr(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;var t,r=e._state;if("writable"===r)!en(e)&&e._backpressure?Tn(this):Rn(this),Sn(this);else if("erroring"===r)Bn(this,e._storedError),Sn(this);else if("closed"===r)Rn(this),Sn(t=this),Cn(t);else{var n=e._storedError;Bn(this,n),An(this,n)}}return Object.defineProperty(e.prototype,"closed",{get:function(){return an(this)?this._closedPromise:$e(xn("closed"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!an(this))throw xn("desiredSize");if(void 0===this._ownerWritableStream)throw En("desiredSize");return function(e){var t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return gn(t._writableStreamController)}(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get:function(){return an(this)?this._readyPromise:$e(xn("ready"))},enumerable:!1,configurable:!0}),e.prototype.abort=function(e){return void 0===e&&(e=void 0),an(this)?void 0===this._ownerWritableStream?$e(En("abort")):function(e,t){return Qr(e._ownerWritableStream,t)}(this,e):$e(xn("abort"))},e.prototype.close=function(){if(!an(this))return $e(xn("close"));var e=this._ownerWritableStream;return void 0===e?$e(En("close")):en(e)?$e(new TypeError("Cannot close an already-closing stream")):on(this)},e.prototype.releaseLock=function(){if(!an(this))throw xn("releaseLock");void 0!==this._ownerWritableStream&&cn(this)},e.prototype.write=function(e){return void 0===e&&(e=void 0),an(this)?void 0===this._ownerWritableStream?$e(En("write to")):ln(this,e):$e(xn("write"))},e}();function an(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof nn)}function on(e){return $r(e._ownerWritableStream)}function sn(e,t){"pending"===e._closedPromiseState?jn(e,t):function(e,t){An(e,t)}(e,t)}function un(e,t){"pending"===e._readyPromiseState?On(e,t):function(e,t){Bn(e,t)}(e,t)}function cn(e){var t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");un(e,r),sn(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function ln(e,t){var r=e._ownerWritableStream,n=r._writableStreamController,i=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return bn(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return $e(En("write to"));var a=r._state;if("errored"===a)return $e(r._storedError);if(en(r)||"closed"===a)return $e(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return $e(r._storedError);var o=function(e){return Je((function(t,r){var n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{Yt(e,t,r)}catch(t){return void bn(e,t)}var n=e._controlledWritableStream;if(!en(n)&&"writable"===n._state){var i=vn(e);rn(n,i)}yn(e)}(n,t,i),o}Object.defineProperties(nn.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(nn.prototype,Ne.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});var hn={},pn=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"abortReason",{get:function(){if(!fn(this))throw kn("abortReason");return this._abortReason},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"signal",{get:function(){if(!fn(this))throw kn("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal},enumerable:!1,configurable:!0}),e.prototype.error=function(e){if(void 0===e&&(e=void 0),!fn(this))throw kn("error");"writable"===this._controlledWritableStream._state&&wn(this,e)},e.prototype[mt]=function(e){var t=this._abortAlgorithm(e);return mn(this),t},e.prototype[gt]=function(){Xt(this)},e}();function fn(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof pn)}function dn(e,t,r,n,i,a,o,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Xt(t),t._abortReason=void 0,t._abortController=function(){if(Hr)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=o,t._writeAlgorithm=n,t._closeAlgorithm=i,t._abortAlgorithm=a;var u=vn(t);rn(e,u),Xe(Qe(r()),(function(){t._started=!0,yn(t)}),(function(r){t._started=!0,Yr(e,r)}))}function mn(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function gn(e){return e._strategyHWM-e._queueTotalSize}function yn(e){var t=e._controlledWritableStream;if(e._started&&void 0===t._inFlightWriteRequest)if("erroring"!==t._state){if(0!==e._queue.length){var r=e._queue.peek().value;r===hn?function(e){var t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),$t(e);var r=e._closeAlgorithm();mn(e),Xe(r,(function(){!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";var t=e._writer;void 0!==t&&Cn(t)}(t)}),(function(e){!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Yr(e,t)}(t,e)}))}(e):function(e,t){var r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),Xe(e._writeAlgorithm(t),(function(){!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);var t=r._state;if($t(e),!en(r)&&"writable"===t){var n=vn(e);rn(r,n)}yn(e)}),(function(t){"writable"===r._state&&mn(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Yr(e,t)}(r,t)}))}(e,r)}}else Zr(t)}function bn(e,t){"writable"===e._controlledWritableStream._state&&wn(e,t)}function vn(e){return gn(e)<=0}function wn(e,t){var r=e._controlledWritableStream;mn(e),Xr(r,t)}function _n(e){return new TypeError("WritableStream.prototype."+e+" can only be used on a WritableStream")}function kn(e){return new TypeError("WritableStreamDefaultController.prototype."+e+" can only be used on a WritableStreamDefaultController")}function xn(e){return new TypeError("WritableStreamDefaultWriter.prototype."+e+" can only be used on a WritableStreamDefaultWriter")}function En(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Sn(e){e._closedPromise=Je((function(t,r){e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function An(e,t){Sn(e),jn(e,t)}function jn(e,t){void 0!==e._closedPromise_reject&&(rt(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Cn(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function Tn(e){e._readyPromise=Je((function(t,r){e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Bn(e,t){Tn(e),On(e,t)}function Rn(e){Tn(e),In(e)}function On(e,t){void 0!==e._readyPromise_reject&&(rt(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function In(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(pn.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(pn.prototype,Ne.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});var Pn="undefined"!=typeof DOMException?DOMException:void 0;var Dn,Mn=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(Pn)?Pn:((Dn=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}).prototype=Object.create(Error.prototype),Object.defineProperty(Dn.prototype,"constructor",{value:Dn,writable:!0,configurable:!0}),Dn);function Fn(e,t,r,n,i,a){var o=Bt(e),s=Wr(t);e._disturbed=!0;var u=!1,c=Qe(void 0);return Je((function(l,h){var p,f,d,m;if(void 0!==a){if(p=function(){var r=new Mn("Aborted","AbortError"),a=[];n||a.push((function(){return"writable"===t._state?Qr(t,r):Qe(void 0)})),i||a.push((function(){return"readable"===e._state?ci(e,r):Qe(void 0)})),v((function(){return Promise.all(a.map((function(e){return e()})))}),!0,r)},a.aborted)return void p();a.addEventListener("abort",p)}if(b(e,o._closedPromise,(function(e){n?w(!0,e):v((function(){return Qr(t,e)}),!0,e)})),b(t,s._closedPromise,(function(t){i?w(!0,t):v((function(){return ci(e,t)}),!0,t)})),f=e,d=o._closedPromise,m=function(){r?w():v((function(){return function(e){var t=e._ownerWritableStream,r=t._state;return en(t)||"closed"===r?Qe(void 0):"errored"===r?$e(t._storedError):on(e)}(s)}))},"closed"===f._state?m():Ze(d,m),en(t)||"closed"===t._state){var g=new TypeError("the destination writable stream closed before all data could be piped to it");i?w(!0,g):v((function(){return ci(e,g)}),!0,g)}function y(){var e=c;return Ye(c,(function(){return e!==c?y():void 0}))}function b(e,t,r){"errored"===e._state?r(e._storedError):et(t,r)}function v(e,r,n){function i(){Xe(e(),(function(){return _(r,n)}),(function(e){return _(!0,e)}))}u||(u=!0,"writable"!==t._state||en(t)?i():Ze(y(),i))}function w(e,r){u||(u=!0,"writable"!==t._state||en(t)?_(e,r):Ze(y(),(function(){return _(e,r)})))}function _(e,t){cn(s),ct(o),void 0!==a&&a.removeEventListener("abort",p),e?h(t):l(void 0)}rt(Je((function(e,t){!function r(n){n?e():Ye(u?Qe(!0):Ye(s._readyPromise,(function(){return Je((function(e,t){Nt(o,{_chunkSteps:function(t){c=Ye(ln(s,t),void 0,ze),e(!1)},_closeSteps:function(){return e(!0)},_errorSteps:t})}))})),r,t)}(!1)})))}))}var Ln=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!Nn(this))throw Qn("desiredSize");return Vn(this)},enumerable:!1,configurable:!0}),e.prototype.close=function(){if(!Nn(this))throw Qn("close");if(!Kn(this))throw new TypeError("The stream is not in a state that permits close");Hn(this)},e.prototype.enqueue=function(e){if(void 0===e&&(e=void 0),!Nn(this))throw Qn("enqueue");if(!Kn(this))throw new TypeError("The stream is not in a state that permits enqueue");return Gn(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!Nn(this))throw Qn("error");Wn(this,e)},e.prototype[yt]=function(e){Xt(this);var t=this._cancelAlgorithm(e);return qn(this),t},e.prototype[bt]=function(e){var t=this._controlledReadableStream;if(this._queue.length>0){var r=$t(this);this._closeRequested&&0===this._queue.length?(qn(this),li(t)):zn(this),e._chunkSteps(r)}else Rt(t,e),zn(this)},e}();function Nn(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof Ln)}function zn(e){Un(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,Xe(e._pullAlgorithm(),(function(){e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,zn(e))}),(function(t){Wn(e,t)}))))}function Un(e){var t=e._controlledReadableStream;return!!Kn(e)&&(!!e._started&&(!!(ui(t)&&It(t)>0)||Vn(e)>0))}function qn(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Hn(e){if(Kn(e)){var t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(qn(e),li(t))}}function Gn(e,t){if(Kn(e)){var r=e._controlledReadableStream;if(ui(r)&&It(r)>0)Ot(r,t,!1);else{var n=void 0;try{n=e._strategySizeAlgorithm(t)}catch(t){throw Wn(e,t),t}try{Yt(e,t,n)}catch(t){throw Wn(e,t),t}}zn(e)}}function Wn(e,t){var r=e._controlledReadableStream;"readable"===r._state&&(Xt(e),qn(e),hi(r,t))}function Vn(e){var t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Kn(e){var t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Jn(e,t,r,n,i,a,o){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Xt(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=o,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,e._readableStreamController=t,Xe(Qe(r()),(function(){t._started=!0,zn(t)}),(function(e){Wn(t,e)}))}function Qn(e){return new TypeError("ReadableStreamDefaultController.prototype."+e+" can only be used on a ReadableStreamDefaultController")}function $n(e,t){return tr(e._readableStreamController)?function(e){var t,r,n,i,a,o=Bt(e),s=!1,u=!1,c=!1,l=!1,h=!1,p=Je((function(e){a=e}));function f(e){et(e._closedPromise,(function(t){e===o&&(br(n._readableStreamController,t),br(i._readableStreamController,t),l&&h||a(void 0))}))}function d(){Rr(o)&&(ct(o),f(o=Bt(e))),Nt(o,{_chunkSteps:function(t){nt((function(){u=!1,c=!1;var r=t,o=t;if(!l&&!h)try{o=Qt(t)}catch(t){return br(n._readableStreamController,t),br(i._readableStreamController,t),void a(ci(e,t))}l||yr(n._readableStreamController,r),h||yr(i._readableStreamController,o),s=!1,u?g():c&&y()}))},_closeSteps:function(){s=!1,l||gr(n._readableStreamController),h||gr(i._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&_r(n._readableStreamController,0),i._readableStreamController._pendingPullIntos.length>0&&_r(i._readableStreamController,0),l&&h||a(void 0)},_errorSteps:function(){s=!1}})}function m(t,r){Lt(o)&&(ct(o),f(o=Ar(e)));var p=r?i:n,d=r?n:i;Or(o,t,{_chunkSteps:function(t){nt((function(){u=!1,c=!1;var n=r?h:l;if(r?l:h)n||kr(p._readableStreamController,t);else{var i=void 0;try{i=Qt(t)}catch(t){return br(p._readableStreamController,t),br(d._readableStreamController,t),void a(ci(e,t))}n||kr(p._readableStreamController,t),yr(d._readableStreamController,i)}s=!1,u?g():c&&y()}))},_closeSteps:function(e){s=!1;var t=r?h:l,n=r?l:h;t||gr(p._readableStreamController),n||gr(d._readableStreamController),void 0!==e&&(t||kr(p._readableStreamController,e),!n&&d._readableStreamController._pendingPullIntos.length>0&&_r(d._readableStreamController,0)),t&&n||a(void 0)},_errorSteps:function(){s=!1}})}function g(){if(s)return u=!0,Qe(void 0);s=!0;var e=vr(n._readableStreamController);return null===e?d():m(e._view,!1),Qe(void 0)}function y(){if(s)return c=!0,Qe(void 0);s=!0;var e=vr(i._readableStreamController);return null===e?d():m(e._view,!0),Qe(void 0)}function b(n){if(l=!0,t=n,h){var i=Vt([t,r]),o=ci(e,i);a(o)}return p}function v(n){if(h=!0,r=n,l){var i=Vt([t,r]),o=ci(e,i);a(o)}return p}function w(){}return n=ai(w,g,b),i=ai(w,y,v),f(o),[n,i]}(e):function(e,t){var r,n,i,a,o,s=Bt(e),u=!1,c=!1,l=!1,h=!1,p=Je((function(e){o=e}));function f(){return u?(c=!0,Qe(void 0)):(u=!0,Nt(s,{_chunkSteps:function(e){nt((function(){c=!1;var t=e,r=e;l||Gn(i._readableStreamController,t),h||Gn(a._readableStreamController,r),u=!1,c&&f()}))},_closeSteps:function(){u=!1,l||Hn(i._readableStreamController),h||Hn(a._readableStreamController),l&&h||o(void 0)},_errorSteps:function(){u=!1}}),Qe(void 0))}function d(t){if(l=!0,r=t,h){var i=Vt([r,n]),a=ci(e,i);o(a)}return p}function m(t){if(h=!0,n=t,l){var i=Vt([r,n]),a=ci(e,i);o(a)}return p}function g(){}return i=ii(g,f,d),a=ii(g,f,m),et(s._closedPromise,(function(e){Wn(i._readableStreamController,e),Wn(a._readableStreamController,e),l&&h||o(void 0)})),[i,a]}(e)}function Yn(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Xn(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Zn(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function ei(e,t){if("bytes"!==(e=""+e))throw new TypeError(t+" '"+e+"' is not a valid enumeration value for ReadableStreamType");return e}function ti(e,t){if("byob"!==(e=""+e))throw new TypeError(t+" '"+e+"' is not a valid enumeration value for ReadableStreamReaderMode");return e}function ri(e,t){_t(e,t);var r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,i=null==e?void 0:e.preventClose,a=null==e?void 0:e.signal;return void 0!==a&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(t+" is not an AbortSignal.")}(a,t+" has member 'signal' that"),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(i),signal:a}}Object.defineProperties(Ln.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Ln.prototype,Ne.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});var ni=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),void 0===e?e=null:xt(e,"First parameter");var r=Mr(t,"Second parameter"),n=function(e,t){_t(e,t);var r=e,n=null==r?void 0:r.autoAllocateChunkSize,i=null==r?void 0:r.cancel,a=null==r?void 0:r.pull,o=null==r?void 0:r.start,s=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:Ct(n,t+" has member 'autoAllocateChunkSize' that"),cancel:void 0===i?void 0:Yn(i,r,t+" has member 'cancel' that"),pull:void 0===a?void 0:Xn(a,r,t+" has member 'pull' that"),start:void 0===o?void 0:Zn(o,r,t+" has member 'start' that"),type:void 0===s?void 0:ei(s,t+" has member 'type' that")}}(e,"First parameter");if(oi(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){var n=Object.create(er.prototype),i=function(){},a=function(){return Qe(void 0)},o=function(){return Qe(void 0)};void 0!==t.start&&(i=function(){return t.start(n)}),void 0!==t.pull&&(a=function(){return t.pull(n)}),void 0!==t.cancel&&(o=function(e){return t.cancel(e)});var s=t.autoAllocateChunkSize;if(0===s)throw new TypeError("autoAllocateChunkSize must be greater than 0");xr(e,n,i,a,o,r,s)}(this,n,Pr(r,0))}else{var i=Dr(r);!function(e,t,r,n){var i=Object.create(Ln.prototype),a=function(){},o=function(){return Qe(void 0)},s=function(){return Qe(void 0)};void 0!==t.start&&(a=function(){return t.start(i)}),void 0!==t.pull&&(o=function(){return t.pull(i)}),void 0!==t.cancel&&(s=function(e){return t.cancel(e)}),Jn(e,i,a,o,s,r,n)}(this,n,Pr(r,1),i)}}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!si(this))throw pi("locked");return ui(this)},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),si(this)?ui(this)?$e(new TypeError("Cannot cancel a stream that already has a reader")):ci(this,e):$e(pi("cancel"))},e.prototype.getReader=function(e){if(void 0===e&&(e=void 0),!si(this))throw pi("getReader");return void 0===function(e,t){_t(e,t);var r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ti(r,t+" has member 'mode' that")}}(e,"First parameter").mode?Bt(this):Ar(this)},e.prototype.pipeThrough=function(e,t){if(void 0===t&&(t={}),!si(this))throw pi("pipeThrough");Et(e,1,"pipeThrough");var r=function(e,t){_t(e,t);var r=null==e?void 0:e.readable;St(r,"readable","ReadableWritablePair"),Tt(r,t+" has member 'readable' that");var n=null==e?void 0:e.writable;return St(n,"writable","ReadableWritablePair"),qr(n,t+" has member 'writable' that"),{readable:r,writable:n}}(e,"First parameter"),n=ri(t,"Second parameter");if(ui(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Jr(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return rt(Fn(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable},e.prototype.pipeTo=function(e,t){if(void 0===t&&(t={}),!si(this))return $e(pi("pipeTo"));if(void 0===e)return $e("Parameter 1 is required in 'pipeTo'.");if(!Kr(e))return $e(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));var r;try{r=ri(t,"Second parameter")}catch(e){return $e(e)}return ui(this)?$e(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Jr(e)?$e(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Fn(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)},e.prototype.tee=function(){if(!si(this))throw pi("tee");return Vt($n(this))},e.prototype.values=function(e){if(void 0===e&&(e=void 0),!si(this))throw pi("values");var t,r,n,i,a,o=function(e,t){_t(e,t);var r=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(r)}}(e,"First parameter");return t=this,r=o.preventCancel,n=Bt(t),i=new Ut(n,r),(a=Object.create(qt))._asyncIteratorImpl=i,a},e}();function ii(e,t,r,n,i){void 0===n&&(n=1),void 0===i&&(i=function(){return 1});var a=Object.create(ni.prototype);return oi(a),Jn(a,Object.create(Ln.prototype),e,t,r,n,i),a}function ai(e,t,r){var n=Object.create(ni.prototype);return oi(n),xr(n,Object.create(er.prototype),e,t,r,0,void 0),n}function oi(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function si(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof ni)}function ui(e){return void 0!==e._reader}function ci(e,t){if(e._disturbed=!0,"closed"===e._state)return Qe(void 0);if("errored"===e._state)return $e(e._storedError);li(e);var r=e._reader;return void 0!==r&&Rr(r)&&(r._readIntoRequests.forEach((function(e){e._closeSteps(void 0)})),r._readIntoRequests=new ot),tt(e._readableStreamController[yt](t),ze)}function li(e){e._state="closed";var t=e._reader;void 0!==t&&(dt(t),Lt(t)&&(t._readRequests.forEach((function(e){e._closeSteps()})),t._readRequests=new ot))}function hi(e,t){e._state="errored",e._storedError=t;var r=e._reader;void 0!==r&&(ft(r,t),Lt(r)?(r._readRequests.forEach((function(e){e._errorSteps(t)})),r._readRequests=new ot):(r._readIntoRequests.forEach((function(e){e._errorSteps(t)})),r._readIntoRequests=new ot))}function pi(e){return new TypeError("ReadableStream.prototype."+e+" can only be used on a ReadableStream")}function fi(e,t){_t(e,t);var r=null==e?void 0:e.highWaterMark;return St(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:At(r)}}Object.defineProperties(ni.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(ni.prototype,Ne.toStringTag,{value:"ReadableStream",configurable:!0}),"symbol"==typeof Ne.asyncIterator&&Object.defineProperty(ni.prototype,Ne.asyncIterator,{value:ni.prototype.values,writable:!0,configurable:!0});var di=function(e){return e.byteLength};try{Object.defineProperty(di,"name",{value:"size",configurable:!0})}catch(Dt){}var mi=function(){function e(e){Et(e,1,"ByteLengthQueuingStrategy"),e=fi(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}return Object.defineProperty(e.prototype,"highWaterMark",{get:function(){if(!yi(this))throw gi("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){if(!yi(this))throw gi("size");return di},enumerable:!1,configurable:!0}),e}();function gi(e){return new TypeError("ByteLengthQueuingStrategy.prototype."+e+" can only be used on a ByteLengthQueuingStrategy")}function yi(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof mi)}Object.defineProperties(mi.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(mi.prototype,Ne.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});var bi=function(){return 1};try{Object.defineProperty(bi,"name",{value:"size",configurable:!0})}catch(Dt){}var vi=function(){function e(e){Et(e,1,"CountQueuingStrategy"),e=fi(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}return Object.defineProperty(e.prototype,"highWaterMark",{get:function(){if(!_i(this))throw wi("highWaterMark");return this._countQueuingStrategyHighWaterMark},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){if(!_i(this))throw wi("size");return bi},enumerable:!1,configurable:!0}),e}();function wi(e){return new TypeError("CountQueuingStrategy.prototype."+e+" can only be used on a CountQueuingStrategy")}function _i(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof vi)}function ki(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function xi(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function Ei(e,t,r){return kt(e,r),function(r,n){return at(e,t,[r,n])}}Object.defineProperties(vi.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(vi.prototype,Ne.toStringTag,{value:"CountQueuingStrategy",configurable:!0});var Si=function(){function e(e,t,r){void 0===e&&(e={}),void 0===t&&(t={}),void 0===r&&(r={}),void 0===e&&(e=null);var n=Mr(t,"Second parameter"),i=Mr(r,"Third parameter"),a=function(e,t){_t(e,t);var r=null==e?void 0:e.flush,n=null==e?void 0:e.readableType,i=null==e?void 0:e.start,a=null==e?void 0:e.transform,o=null==e?void 0:e.writableType;return{flush:void 0===r?void 0:ki(r,e,t+" has member 'flush' that"),readableType:n,start:void 0===i?void 0:xi(i,e,t+" has member 'start' that"),transform:void 0===a?void 0:Ei(a,e,t+" has member 'transform' that"),writableType:o}}(e,"First parameter");if(void 0!==a.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==a.writableType)throw new RangeError("Invalid writableType specified");var o,s=Pr(i,0),u=Dr(i),c=Pr(n,1),l=Dr(n);!function(e,t,r,n,i,a){function o(){return t}e._writable=function(e,t,r,n,i,a){void 0===i&&(i=1),void 0===a&&(a=function(){return 1});var o=Object.create(Gr.prototype);return Vr(o),dn(o,Object.create(pn.prototype),e,t,r,n,i,a),o}(o,(function(t){return function(e,t){var r=e._transformStreamController;if(e._backpressure){return tt(e._backpressureChangePromise,(function(){var n=e._writable;if("erroring"===n._state)throw n._storedError;return Pi(r,t)}))}return Pi(r,t)}(e,t)}),(function(){return function(e){var t=e._readable,r=e._transformStreamController,n=r._flushAlgorithm();return Oi(r),tt(n,(function(){if("errored"===t._state)throw t._storedError;Hn(t._readableStreamController)}),(function(r){throw ji(e,r),t._storedError}))}(e)}),(function(t){return function(e,t){return ji(e,t),Qe(void 0)}(e,t)}),r,n),e._readable=ii(o,(function(){return function(e){return Ti(e,!1),e._backpressureChangePromise}(e)}),(function(t){return Ci(e,t),Qe(void 0)}),i,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Ti(e,!0),e._transformStreamController=void 0}(this,Je((function(e){o=e})),c,l,s,u),function(e,t){var r=Object.create(Bi.prototype),n=function(e){try{return Ii(r,e),Qe(void 0)}catch(e){return $e(e)}},i=function(){return Qe(void 0)};void 0!==t.transform&&(n=function(e){return t.transform(e,r)});void 0!==t.flush&&(i=function(){return t.flush(r)});!function(e,t,r,n){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n}(e,r,n,i)}(this,a),void 0!==a.start?o(a.start(this._transformStreamController)):o(void 0)}return Object.defineProperty(e.prototype,"readable",{get:function(){if(!Ai(this))throw Mi("readable");return this._readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){if(!Ai(this))throw Mi("writable");return this._writable},enumerable:!1,configurable:!0}),e}();function Ai(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof Si)}function ji(e,t){Wn(e._readable._readableStreamController,t),Ci(e,t)}function Ci(e,t){Oi(e._transformStreamController),bn(e._writable._writableStreamController,t),e._backpressure&&Ti(e,!1)}function Ti(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=Je((function(t){e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(Si.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Si.prototype,Ne.toStringTag,{value:"TransformStream",configurable:!0});var Bi=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!Ri(this))throw Di("desiredSize");return Vn(this._controlledTransformStream._readable._readableStreamController)},enumerable:!1,configurable:!0}),e.prototype.enqueue=function(e){if(void 0===e&&(e=void 0),!Ri(this))throw Di("enqueue");Ii(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!Ri(this))throw Di("error");var t;t=e,ji(this._controlledTransformStream,t)},e.prototype.terminate=function(){if(!Ri(this))throw Di("terminate");!function(e){var t=e._controlledTransformStream;Hn(t._readable._readableStreamController);var r=new TypeError("TransformStream terminated");Ci(t,r)}(this)},e}();function Ri(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof Bi)}function Oi(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Ii(e,t){var r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Kn(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Gn(n,t)}catch(e){throw Ci(r,e),r._readable._storedError}(function(e){return!Un(e)})(n)!==r._backpressure&&Ti(r,!0)}function Pi(e,t){return tt(e._transformAlgorithm(t),void 0,(function(t){throw ji(e._controlledTransformStream,t),t}))}function Di(e){return new TypeError("TransformStreamDefaultController.prototype."+e+" can only be used on a TransformStreamDefaultController")}function Mi(e){return new TypeError("TransformStream.prototype."+e+" can only be used on a TransformStream")}Object.defineProperties(Bi.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Bi.prototype,Ne.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var Fi={ReadableStream:ni,ReadableStreamDefaultController:Ln,ReadableByteStreamController:er,ReadableStreamBYOBRequest:Zt,ReadableStreamDefaultReader:Ft,ReadableStreamBYOBReader:Br,WritableStream:Gr,WritableStreamDefaultController:pn,WritableStreamDefaultWriter:nn,ByteLengthQueuingStrategy:mi,CountQueuingStrategy:vi,TransformStream:Si,TransformStreamDefaultController:Bi};if(void 0!==Ue)for(var Li in Fi)Object.prototype.hasOwnProperty.call(Fi,Li)&&Object.defineProperty(Ue,Li,{value:Fi[Li],writable:!0,configurable:!0});delete global.ReadableStream;let Ni,zi,Ui;Ni=Symbol.asyncIterator;zi=Symbol.toStringTag;Ui=Symbol.toStringTag;(!m||!("TextEncoder"in y))&&(y.TextEncoder=F);(!m||!("TextDecoder"in y))&&(y.TextDecoder=M),m||"atob"in y||!ae||(y.atob=ae),m||"btoa"in y||!oe||(y.btoa=oe),m||"Headers"in y||!ue||(y.Headers=ue),m||"Response"in y||!_e||(y.Response=_e),m||"fetch"in y||!Be||(y.fetch=Be),m||"DOMParser"in y||!d.DOMParser||(y.DOMParser=d.DOMParser),m||"_encodeImageNode"in y||!De||(y._encodeImageNode=De),m||"_parseImageNode"in y||!Le||(y._parseImageNode=Le),"allSettled"in Promise||(Promise.allSettled=function(e){const t=e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e})));return Promise.all(t)});var qi=r(2),Hi=r(23),Gi=r.n(Hi),Wi=r(6),Vi=r.n(Wi);"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;const Ki=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Ji="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),Qi=(Ji&&parseFloat(Ji[1]),e=>"boolean"==typeof e),$i=e=>"function"==typeof e,Yi=e=>null!==e&&"object"==typeof e,Xi=e=>Yi(e)&&e.constructor==={}.constructor,Zi=e=>e&&"function"==typeof e[Symbol.iterator],ea=e=>e&&"function"==typeof e[Symbol.asyncIterator],ta=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,ra=e=>"undefined"!=typeof Blob&&e instanceof Blob,na=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Yi(e)&&$i(e.tee)&&$i(e.cancel)&&$i(e.getReader))(e)||(e=>Yi(e)&&$i(e.read)&&$i(e.pipe)&&Qi(e.readable))(e);function ia(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function aa(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function oa(e){var t,r;let n;return ia(e,"null loader"),ia(aa(e),"invalid loader"),Array.isArray(e)&&(n=e[1],e=e[0],e={...e,options:{...e.options,...n}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(r=e)&&void 0!==r&&r.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}let sa="";const ua={};function ca(e){for(const t in ua)if(e.startsWith(t)){const r=ua[t];e=e.replace(t,r)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${sa}${e}`),e}const la=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ha=/^([-\w.]+\/[-\w.+]+)/;function pa(e){const t=ha.exec(e);return t?t[1]:e}function fa(e){const t=la.exec(e);return t?t[1]:""}const da=/\?.*/;function ma(e){if(ta(e)){const t=ga(e.url||"");return{url:t,type:pa(e.headers.get("content-type")||"")||fa(t)}}return ra(e)?{url:ga(e.name||""),type:e.type||""}:"string"==typeof e?{url:ga(e),type:fa(e)}:{url:"",type:""}}function ga(e){return e.replace(da,"")}async function ya(e){if(ta(e))return e;const t={},r=function(e){return ta(e)?e.headers["content-length"]||-1:ra(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);r>=0&&(t["content-length"]=String(r));const{url:n,type:i}=ma(e);i&&(t["content-type"]=i);const a=await async function(e){if("string"==typeof e)return"data:,"+e.slice(0,5);if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const r=new FileReader;r.onload=t=>{var r;return e(null==t||null===(r=t.target)||void 0===r?void 0:r.result)},r.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const t=e.slice(0,5);return"data:base64,"+function(e){let t="";const r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)t+=String.fromCharCode(r[e]);return btoa(t)}(t)}return null}(e);a&&(t["x-first-bytes"]=a),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:n}),o}async function ba(e){if(!e.ok){const t=await async function(e){let t=`Failed to fetch resource ${e.url} (${e.status}): `;try{const r=e.headers.get("Content-Type");let n=e.statusText;r.includes("application/json")&&(n+=" "+await e.text()),t+=n,t=t.length>60?t.slice(0,60)+"...":t}catch(e){}return t}(e);throw new Error(t)}}async function va(e,t){if("string"==typeof e){e=ca(e);let r=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(r=t.fetch),await fetch(e,r)}return await ya(e)}var wa=r(550);const _a=new wa.a({id:"loaders.gl"});class ka{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const xa={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){var e,t,r;r=void 0,(t="console")in(e=this)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Ki,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Ea={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Sa(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const Aa=()=>{const e=Sa();return e.globalOptions=e.globalOptions||{...xa},e.globalOptions};function ja(e,t,r,n){return r=r||[],function(e,t){Ta(e,null,xa,Ea,t);for(const r of t){const n=e&&e[r.id]||{},i=r.options&&r.options[r.id]||{},a=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Ta(n,r.id,i,a,t)}}(e,r=Array.isArray(r)?r:[r]),Ra(t,e,n)}function Ca(e,t){const r=Aa(),n=e||r;return"function"==typeof n.fetch?n.fetch:Yi(n.fetch)?e=>va(e,n):null!=t&&t.fetch?null==t?void 0:t.fetch:va}function Ta(e,t,r,n,i){const a=t||"Top level",o=t?t+".":"";for(const s in e){const u=!t&&Yi(e[s]),c="baseUri"===s&&!t,l="workerUrl"===s&&t;if(!(s in r)&&!c&&!l)if(s in n)_a.warn(`${a} loader option '${o}${s}' no longer supported, use '${n[s]}'`)();else if(!u){const e=Ba(s,i);_a.warn(`${a} loader option '${o}${s}' not recognized. ${e}`)()}}}function Ba(e,t){const r=e.toLowerCase();let n="";for(const i of t)for(const t in i.options){if(e===t)return`Did you mean '${i.id}.${t}'?`;const a=t.toLowerCase();(r.startsWith(a)||a.startsWith(r))&&(n=n||`Did you mean '${i.id}.${t}'?`)}return n}function Ra(e,t,r){const n={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(n,r),null===n.log&&(n.log=new ka),Oa(n,Aa()),Oa(n,t),n}function Oa(e,t){for(const r in t)if(r in t){const n=t[r];Xi(n)&&Xi(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function Ia(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const Pa={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},Da=Pa.global||Pa.self||Pa.window||{},Ma="object"!=typeof process||"[object process]"!==String(process)||process.browser,Fa="function"==typeof importScripts,La="undefined"!=typeof window&&void 0!==window.orientation,Na="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Na&&parseFloat(Na[1]);var za=r(84);const Ua=new Map;function qa(e){Ia(e.source&&!e.url||!e.source&&e.url);let t=Ua.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Ha((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),Ua.set(e.url,t)),e.source&&(t=Ha(e.source),Ua.set(e.source,t))),Ia(t),t}function Ha(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Ga(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}function Wa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Va=()=>{};class Ka{static isSupported(){return"undefined"!=typeof Worker&&Ma||void 0!==za.NodeWorker&&!Ma}constructor(e){Wa(this,"name",void 0),Wa(this,"source",void 0),Wa(this,"url",void 0),Wa(this,"terminated",!1),Wa(this,"worker",void 0),Wa(this,"onMessage",void 0),Wa(this,"onError",void 0),Wa(this,"_loadableURL","");const{name:t,source:r,url:n}=e;Ia(r||n),this.name=t,this.source=r,this.url=n,this.onMessage=Va,this.onError=e=>console.log(e),this.worker=Ma?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Va,this.onError=Va,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||function e(t,r=!0,n){const i=n||new Set;if(t){if(Ga(t))i.add(t);else if(Ga(t.buffer))i.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"==typeof t)for(const n in t)e(t[n],r,i)}else;return void 0===n?Array.from(i):[]}(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=e.message+" in "),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=qa({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./"+this.url;e=new za.NodeWorker(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new za.NodeWorker(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}function Ja(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Qa{constructor(e,t){Ja(this,"name",void 0),Ja(this,"workerThread",void 0),Ja(this,"isRunning",!0),Ja(this,"result",void 0),Ja(this,"_resolve",()=>{}),Ja(this,"_reject",()=>{}),this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Ia(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Ia(this.isRunning),this.isRunning=!1,this._reject(e)}}function $a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Ya{static isSupported(){return Ka.isSupported()}constructor(e){$a(this,"name","unnamed"),$a(this,"source",void 0),$a(this,"url",void 0),$a(this,"maxConcurrency",1),$a(this,"maxMobileConcurrency",1),$a(this,"onDebug",()=>{}),$a(this,"reuseWorkers",!0),$a(this,"props",{}),$a(this,"jobQueue",[]),$a(this,"idleQueue",[]),$a(this,"count",0),$a(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,r)=>e.done(r)),r=((e,t)=>e.error(t))){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:r,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const r=new Qa(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ka({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return La?this.maxMobileConcurrency:this.maxConcurrency}}function Xa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Za={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class eo{static isSupported(){return Ka.isSupported()}static getWorkerFarm(e={}){return eo._workerFarm=eo._workerFarm||new eo({}),eo._workerFarm.setProps(e),eo._workerFarm}constructor(e){Xa(this,"props",void 0),Xa(this,"workerPools",new Map),this.props={...Za},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:r,url:n}=e;let i=this.workerPools.get(t);return i||(i=new Ya({name:t,source:r,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}Xa(eo,"_workerFarm",void 0);function to(e,t={}){const r=t[e.id]||{},n=e.id+"-worker.js";let i=r.workerUrl;if(i||"compression"!==e.id||(i=t.workerUrl),"test"===t._workerType&&(i=`modules/${e.module}/dist/${n}`),!i){let t=e.version;"latest"===t&&(t="beta");const r=t?"@"+t:"";i=`https://unpkg.com/@loaders.gl/${e.module}${r}/dist/${n}`}return Ia(i),i}async function ro(e,t,r,n,i){const a=e.id,o=to(e,r),s=eo.getWorkerFarm(r).getWorkerPool({name:a,url:o});r=JSON.parse(JSON.stringify(r)),n=JSON.parse(JSON.stringify(n||{}));const u=await s.startJob("process-on-worker",no.bind(null,i));u.postMessage("process",{input:t,options:r,context:n});const c=await u.result;return await c.result}async function no(e,t,r,n){switch(r){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:i,input:a,options:o}=n;try{const r=await e(a,o);t.postMessage("done",{id:i,result:r})}catch(e){const r=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:i,error:r})}break;default:console.warn("parse-with-worker unknown message "+r)}}function io(...e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),r=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(r);let i=0;for(const e of t)n.set(e,i),i+=e.byteLength;return n.buffer}function ao(...e){const 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');const n=new r(t.reduce((e,t)=>e+t.length,0));let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}function oo(e,t,r){const n=void 0!==r?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}async function so(e){const t=[];for await(const r of e)t.push(r);return io(...t)}const uo=262144;function co(e){if(Buffer.isBuffer(e)){return new Uint8Array(e.buffer,e.byteOffset,e.length).slice().buffer}return e}function lo(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e)&&(e=e.buffer),"undefined"!=typeof Buffer&&e instanceof ArrayBuffer)return Buffer.from(e);throw new Error("toBuffer")}function ho(e){return lo?lo(e):e}function po(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return co(e);var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function fo(e,t){return Ki?async function*(e,t){const r=e.getReader();let n;try{for(;;){const e=n||r.read();null!=t&&t._streamReadAhead&&(n=r.read());const{done:i,value:a}=await e;if(i)return;yield po(a)}}catch(e){r.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield po(t)}(e)}function mo(e,t){if("string"==typeof e)return function*(e,t){const r=(null==t?void 0:t.chunkSize)||262144;let n=0;const i=new TextEncoder;for(;n<e.length;){const t=Math.min(e.length-n,r),a=e.slice(n,n+t);n+=t,yield i.encode(a)}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:r=uo}=t;let n=0;for(;n<e.byteLength;){const t=Math.min(e.byteLength-n,r),i=new ArrayBuffer(t),a=new Uint8Array(e,n,t);new Uint8Array(i).set(a),n+=t,yield i}}(e,t);if(ra(e))return async function*(e,t){const r=(null==t?void 0:t.chunkSize)||1048576;let n=0;for(;n<e.size;){const t=n+r,i=await e.slice(n,t).arrayBuffer();n=t,yield i}}(e,t);if(na(e))return fo(e,t);if(ta(e)){return fo(e.body,t)}throw new Error("makeIterator")}const go="Cannot convert supplied data type";async function yo(e,t,r){const n=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return function(e,t,r){if(t.text&&"string"==typeof e)return e;var n;if((n=e)&&"object"==typeof n&&n.isBuffer&&(e=e.buffer),e instanceof ArrayBuffer){const r=e;if(t.text&&!t.binary){return new TextDecoder("utf8").decode(r)}return r}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary){return new TextDecoder("utf8").decode(e)}let r=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===r.byteLength||(r=r.slice(e.byteOffset,e.byteOffset+n)),r}throw new Error(go)}(e,t);if(ra(e)&&(e=await ya(e)),ta(e)){const r=e;return await ba(r),t.binary?await r.arrayBuffer():await r.text()}if(na(e)&&(e=mo(e,r)),Zi(e)||ea(e))return so(e);throw new Error(go)}function bo(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}function vo(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(0,t):""}function wo(...e){return(e=e.map((t,r)=>(r&&(t=t.replace(new RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(new RegExp("/$"),"")),t))).join("/")}function _o(e){return(t,r)=>new Promise((n,i)=>e(t,r,(e,t)=>e?i(e):n(t)))}let ko,xo,Eo,So,Ao,jo,Co,To,Bo,Ro,Oo,Io=Boolean(je.a);try{ko=_o(je.a.readdir),xo=_o(je.a.stat),Eo=je.a.readFile,So=je.a.readFileSync,Po=je.a.writeFile,Ao=(e,t,r)=>new Promise((n,i)=>Po(e,t,r,(e,t)=>e?i(e):n(t))),jo=je.a.writeFileSync,Co=je.a.open,To=e=>new Promise((t,r)=>je.a.close(e,e=>e?r(e):t())),Bo=je.a.read,Ro=je.a.fstat,Oo=je.a.createWriteStream,Io=Boolean(je.a)}catch{}var Po;async function Do(e,t,r){const n=Buffer.alloc(r),{bytesRead:i}=await Bo(e,n,0,r,t);if(i!==r)throw new Error("fs.read failed");return co(n)}const Mo=new wa.a({id:"loaders.gl"}),Fo=()=>{const e=Sa();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const Lo=/\.([^.]+)$/;function No(e,t=[],r,n){if(!zo(e))return null;if(t&&!Array.isArray(t))return oa(t);let i=[];t&&(i=i.concat(t)),null!=r&&r.ignoreRegisteredLoaders||i.push(...Fo()),function(e){for(const t of e)oa(t)}(i);const a=function(e,t,r,n){const{url:i,type:a}=ma(e),o=i||(null==n?void 0:n.url);let s=null,u="";null!=r&&r.mimeType&&(s=qo(t,null==r?void 0:r.mimeType),u="match forced by supplied MIME type "+(null==r?void 0:r.mimeType));var c;s=s||function(e,t){const r=t&&Lo.exec(t),n=r&&r[1];return n?function(e,t){t=t.toLowerCase();for(const r of e)for(const e of r.extensions)if(e.toLowerCase()===t)return r;return null}(e,n):null}(t,o),u=u||(s?"matched url "+o:""),s=s||qo(t,a),u=u||(s?"matched MIME type "+a:""),s=s||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(Ho(t,r))return r}else if(ArrayBuffer.isView(t)){if(Go(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(Go(t,0,r))return r}return null}(t,e),u=u||(s?"matched initial data "+Wo(e):""),s=s||qo(t,null==r?void 0:r.fallbackMimeType),u=u||(s?"matched fallback MIME type "+a:""),u&&Mo.log(1,`selectLoader selected ${null===(c=s)||void 0===c?void 0:c.name}: ${u}.`);return s}(e,i,r,n);if(!(a||null!=r&&r.nothrow))throw new Error(Uo(e));return a}function zo(e){return!(e instanceof Response&&204===e.status)}function Uo(e){const{url:t,type:r}=ma(e);let i="No valid loader found (";i+=t?n.filename(t)+", ":"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;const a=e?Wo(e):"";return i+=a?` first bytes: "${a}"`:"first bytes: not available",i+=")",i}function qo(e,t){for(const r of e){if(r.mimeTypes&&r.mimeTypes.includes(t))return r;if(t==="application/x."+r.id)return r}return null}function Ho(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Go(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>function(e,t,r,n){if(n instanceof ArrayBuffer)return function(e,t,r){if(r=r||e.byteLength,e.byteLength<r||t.byteLength<r)return!1;const n=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<n.length;++e)if(n[e]!==i[e])return!1;return!0}(n,e,n.byteLength);switch(typeof n){case"function":return n(e,r);case"string":const i=Vo(e,t,n.length);return n===i;default:return!1}}(e,t,r,n))}function Wo(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Vo(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Vo(e,0,t)}return""}function Vo(e,t,r){if(e.byteLength<t+r)return"";const n=new DataView(e);let i="";for(let e=0;e<r;e++)i+=String.fromCharCode(n.getUint8(t+e));return i}async function Ko(e,t,r,n){Ia(!n||"object"==typeof n),!t||Array.isArray(t)||aa(t)||(n=void 0,r=t,t=void 0),e=await e,r=r||{};const{url:i}=ma(e),a=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...e]:e}return r&&r.length?r:null}(t,n),o=await async function(e,t=[],r,n){if(!zo(e))return null;let i=No(e,t,{...r,nothrow:!0},n);if(i)return i;if(ra(e)&&(i=No(e=await e.slice(0,10).arrayBuffer(),t,r,n)),!(i||null!=r&&r.nothrow))throw new Error(Uo(e));return i}(e,a,r);return o?(n=function(e,t,r=null){if(r)return r;const n={fetch:Ca(t,e),...e};return Array.isArray(n.loaders)||(n.loaders=null),n}({url:i,parse:Ko,loaders:a},r=ja(r,o,a,i),n),await async function(e,t,r,n){if(function(e,t="3.3.0"){Ia(e,"no worker provided");const r=e.version}(e),ta(t)){const e=t,{ok:r,redirected:i,status:a,statusText:o,type:s,url:u}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:r,redirected:i,status:a,statusText:o,type:s,url:u}}if(t=await yo(t,e,r),e.parseTextSync&&"string"==typeof t)return r.dataType="text",e.parseTextSync(t,r,n,e);if(function(e,t){return!!eo.isSupported()&&(!!(Ma||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}(e,r))return await ro(e,t,r,n,Ko);if(e.parseText&&"string"==typeof t)return await e.parseText(t,r,n,e);if(e.parse)return await e.parse(t,r,n,e);throw Ia(!e.parseSync),new Error(e.id+" loader - no parser found and worker is disabled")}(o,e,r,n)):null}async function Jo(e,t,r,n){Array.isArray(t)||aa(t)||(void 0,r=t,t=void 0);const i=Ca(r);let a=e;return"string"==typeof e&&(a=await i(e)),ra(e)&&(a=await i(e)),await Ko(a,t,r)}function Qo(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}const $o=1/Math.PI*180,Yo=1/180*Math.PI,Xo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function Zo(e,{precision:t=Xo.precision}={}){return e=function(e){return Math.round(e/Xo.EPSILON)*Xo.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function es(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ts(e){return function(e,t){return os(e,e=>e*Yo,t)}(e)}function rs(e){return ns(e)}function ns(e,t){return os(e,e=>e*$o,t)}function is(e,t,r){return os(e,e=>Math.max(t,Math.min(r,e)))}function as(e,t,r){const n=Xo.EPSILON;r&&(Xo.EPSILON=r);try{if(e===t)return!0;if(es(e)&&es(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!as(e[r],t[r]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=Xo.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{Xo.EPSILON=n}}function os(e,t,r){if(es(e)){const n=e;r=r||function(e){return e.clone?e.clone():new Array(e.length)}(n);for(let i=0;i<r.length&&i<n.length;++i)r[i]=t(e[i],i,r);return r}return t(e)}class ss extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:es(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Xo)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+Zo(this[r],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!as(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(void 0===r)return this.lerp(this,e,t);for(let n=0;n<this.ELEMENTS;++n){const i=e[n];this[n]=i+r*(t[n]-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(Xo.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}}function us(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function cs(e,t,r=""){if(Xo.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return e}class ls extends ss{get x(){return this[0]}set x(e){this[0]=us(e)}get y(){return this[1]}set y(e){this[1]=us(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const n=this[r]-e[r];t+=n*n}return us(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return us(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Qo(e>=0&&e<this.ELEMENTS,"index is out of range"),us(this[e])}setComponent(e,t){return Qo(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}var hs=1e-6,ps="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function fs(){var e=new ps(3);return ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ds(e){var t=e[0],r=e[1],n=e[2];return Math.hypot(t,r,n)}function ms(e,t,r){var n=new ps(3);return n[0]=e,n[1]=t,n[2]=r,n}function gs(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ys(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2];return e[0]=i*u-a*s,e[1]=a*o-n*u,e[2]=n*s-i*o,e}function bs(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e}function vs(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e}function ws(e,t,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=t[0],u=t[1],c=t[2],l=i*c-a*u,h=a*s-n*c,p=n*u-i*s,f=i*p-a*h,d=a*l-n*p,m=n*h-i*l,g=2*o;return l*=g,h*=g,p*=g,f*=2,d*=2,m*=2,e[0]=s+l+f,e[1]=u+h+d,e[2]=c+p+m,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var _s,ks=ds;_s=fs();function xs(e,t,r){const n=t[0],i=t[1],a=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/a,e[1]=(r[1]*n+r[5]*i)/a,e}function Es(e,t,r){const n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a||1;return e[0]=(r[0]*n+r[4]*i+r[8]*a)/o,e[1]=(r[1]*n+r[5]*i+r[9]*a)/o,e[2]=(r[2]*n+r[6]*i+r[10]*a)/o,e}function Ss(e,t,r){const n=t[0],i=t[1],a=t[2];return e[0]=r[0]*n+r[3]*i+r[6]*a,e[1]=r[1]*n+r[4]*i+r[7]*a,e[2]=r[2]*n+r[5]*i+r[8]*a,e[3]=t[3],e}const As=[0,0,0];let js;class Cs extends ls{static get ZERO(){return js||(js=new Cs(0,0,0),Object.freeze(js)),js}constructor(e=0,t=0,r=0){super(-0,-0,-0),1===arguments.length&&es(e)?this.copy(e):(Xo.debug&&(us(e),us(t),us(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y),us(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=us(e)}angle(e){return r=e,n=(t=this)[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],c=Math.sqrt(n*n+i*i+a*a)*Math.sqrt(o*o+s*s+u*u),l=c&&gs(t,r)/c,Math.acos(Math.min(Math.max(l,-1),1));var t,r,n,i,a,o,s,u,c,l}cross(e){return ys(this,this,e),this.check()}rotateX({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[0],s[1]=o[1]*Math.cos(a)-o[2]*Math.sin(a),s[2]=o[1]*Math.sin(a)+o[2]*Math.cos(a),r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}rotateY({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[2]*Math.sin(a)+o[0]*Math.cos(a),s[1]=o[1],s[2]=o[2]*Math.cos(a)-o[0]*Math.sin(a),r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}rotateZ({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[0]*Math.cos(a)-o[1]*Math.sin(a),s[1]=o[0]*Math.sin(a)+o[1]*Math.cos(a),s[2]=o[2],r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return bs(this,this,e),this.check()}transformAsVector(e){return Es(this,this,e),this.check()}transformByMatrix3(e){return vs(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return ws(this,this,e),this.check()}}class Ts extends ss{toString(){let e="[";if(Xo.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=" ".concat(this[r*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=us(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[r+e];return t}setColumn(e,t){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)this[r+e]=t[e];return this}}function Bs(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],h=t[8],p=t[9],f=t[10],d=t[11],m=t[12],g=t[13],y=t[14],b=t[15],v=r[0],w=r[1],_=r[2],k=r[3];return e[0]=v*n+w*s+_*h+k*m,e[1]=v*i+w*u+_*p+k*g,e[2]=v*a+w*c+_*f+k*y,e[3]=v*o+w*l+_*d+k*b,v=r[4],w=r[5],_=r[6],k=r[7],e[4]=v*n+w*s+_*h+k*m,e[5]=v*i+w*u+_*p+k*g,e[6]=v*a+w*c+_*f+k*y,e[7]=v*o+w*l+_*d+k*b,v=r[8],w=r[9],_=r[10],k=r[11],e[8]=v*n+w*s+_*h+k*m,e[9]=v*i+w*u+_*p+k*g,e[10]=v*a+w*c+_*f+k*y,e[11]=v*o+w*l+_*d+k*b,v=r[12],w=r[13],_=r[14],k=r[15],e[12]=v*n+w*s+_*h+k*m,e[13]=v*i+w*u+_*p+k*g,e[14]=v*a+w*c+_*f+k*y,e[15]=v*o+w*l+_*d+k*b,e}function Rs(e,t){var r=t[0],n=t[1],i=t[2],a=t[4],o=t[5],s=t[6],u=t[8],c=t[9],l=t[10];return e[0]=Math.hypot(r,n,i),e[1]=Math.hypot(a,o,s),e[2]=Math.hypot(u,c,l),e}var Os=function(e,t,r,n,i){var a,o=1/Math.tan(t/2);return 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,null!=i&&i!==1/0?(a=1/(n-i),e[10]=(i+n)*a,e[14]=2*i*n*a):(e[10]=-1,e[14]=-2*n),e};var Is=function(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),c=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*c,e[15]=1,e};function Ps(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e}function Ds(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}!function(){var e,t=(e=new ps(2),ps!=Float32Array&&(e[0]=0,e[1]=0),e)}();function Ms(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.hypot(t,r,n,i)}function Fs(e){var t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i}var Ls;!function(){var e,t=(e=new ps(4),ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();!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"}(Ls||(Ls={}));const Ns=45*Math.PI/180,zs=1,Us=.1,qs=500,Hs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Gs extends Ts{static get IDENTITY(){return function(){Vs||(Vs=new Gs,Object.freeze(Vs));return Vs}()}static get ZERO(){return function(){Ws||(Ws=new Gs([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ws));return Ws}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ls}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this[9]=c,this[10]=l,this[11]=h,this[12]=p,this[13]=f,this[14]=d,this[15]=m,this.check()}setRowMajor(e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m){return this[0]=e,this[1]=i,this[2]=u,this[3]=p,this[4]=t,this[5]=a,this[6]=c,this[7]=f,this[8]=r,this[9]=o,this[10]=l,this[11]=d,this[12]=n,this[13]=s,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Hs)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,c=r*o,l=n*o,h=n*s,p=i*o,f=i*s,d=i*u,m=a*o,g=a*s,y=a*u;e[0]=1-h-d,e[1]=l+y,e[2]=p-g,e[3]=0,e[4]=l-y,e[5]=1-c-d,e[6]=f+m,e[7]=0,e[8]=p+g,e[9]=f-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:r,bottom:n,top:i,near:a=Us,far:o=qs}=e;return o===1/0?function(e,t,r,n,i,a){const o=2*a/(r-t),s=2*a/(i-n),u=(r+t)/(r-t),c=(i+n)/(i-n),l=-2*a;e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=u,e[9]=c,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=l,e[15]=0}(this,t,r,n,i,a):function(e,t,r,n,i,a,o){var s=1/(r-t),u=1/(i-n),c=1/(a-o);e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*c,e[15]=0}(this,t,r,n,i,a,o),this.check()}lookAt(e){const{eye:t,center:r=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,r,n){var i,a,o,s,u,c,l,h,p,f,d=t[0],m=t[1],g=t[2],y=n[0],b=n[1],v=n[2],w=r[0],_=r[1],k=r[2];Math.abs(d-w)<hs&&Math.abs(m-_)<hs&&Math.abs(g-k)<hs?function(e){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):(l=d-w,h=m-_,p=g-k,i=b*(p*=f=1/Math.hypot(l,h,p))-v*(h*=f),a=v*(l*=f)-y*p,o=y*h-b*l,(f=Math.hypot(i,a,o))?(i*=f=1/f,a*=f,o*=f):(i=0,a=0,o=0),s=h*o-p*a,u=p*i-l*o,c=l*a-h*i,(f=Math.hypot(s,u,c))?(s*=f=1/f,u*=f,c*=f):(s=0,u=0,c=0),e[0]=i,e[1]=s,e[2]=l,e[3]=0,e[4]=a,e[5]=u,e[6]=h,e[7]=0,e[8]=o,e[9]=c,e[10]=p,e[11]=0,e[12]=-(i*d+a*m+o*g),e[13]=-(s*d+u*m+c*g),e[14]=-(l*d+h*m+p*g),e[15]=1)}(this,t,r,n),this.check()}ortho(e){const{left:t,right:r,bottom:n,top:i,near:a=Us,far:o=qs}=e;return Is(this,t,r,n,i,a,o),this.check()}orthographic(e){const{fovy:t=Ns,aspect:r=zs,focalDistance:n=1,near:i=Us,far:a=qs}=e;Ks(t);const o=t/2,s=n*Math.tan(o),u=s*r;return this.ortho({left:-u,right:u,bottom:-s,top:s,near:i,far:a})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:r=1,near:n=.1,far:i=500}=e;return Ks(t),Os(this,t,r,n,i),this.check()}determinant(){return t=(e=this)[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],p=e[11],f=e[12],d=e[13],m=e[14],g=e[15],(t*o-r*a)*(h*g-p*m)-(t*s-n*a)*(l*g-p*d)+(t*u-i*a)*(l*m-h*d)+(r*s-n*o)*(c*g-p*f)-(r*u-i*o)*(c*m-h*f)+(n*u-i*s)*(c*d-l*f);var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),n=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*n,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*n,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),n=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*n,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*n,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],a=t[6],o=t[7],s=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]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}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]}(this,this),this.check()}invert(){var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g,y,b,v,w,_,k,x,E,S,A,j,C,T,B;return e=this,r=(t=this)[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],h=t[9],p=t[10],f=t[11],d=t[12],m=t[13],g=t[14],y=t[15],(B=(b=r*s-n*o)*(T=p*y-f*g)-(v=r*u-i*o)*(C=h*y-f*m)+(w=r*c-a*o)*(j=h*g-p*m)+(_=n*u-i*s)*(A=l*y-f*d)-(k=n*c-a*s)*(S=l*g-p*d)+(x=i*c-a*u)*(E=l*m-h*d))&&(B=1/B,e[0]=(s*T-u*C+c*j)*B,e[1]=(i*C-n*T-a*j)*B,e[2]=(m*x-g*k+y*_)*B,e[3]=(p*k-h*x-f*_)*B,e[4]=(u*A-o*T-c*S)*B,e[5]=(r*T-i*A+a*S)*B,e[6]=(g*w-d*x-y*v)*B,e[7]=(l*x-p*w+f*v)*B,e[8]=(o*C-s*A+c*E)*B,e[9]=(n*A-r*C-a*E)*B,e[10]=(d*k-m*w+y*b)*B,e[11]=(h*w-l*k-f*b)*B,e[12]=(s*S-o*j-u*E)*B,e[13]=(r*j-n*S+i*E)*B,e[14]=(m*v-d*_-g*b)*B,e[15]=(l*_-h*v+p*b)*B),this.check()}multiplyLeft(e){return Bs(this,e,this),this.check()}multiplyRight(e){return Bs(this,this,e),this.check()}rotateX(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[4],s=r[5],u=r[6],c=r[7],l=r[8],h=r[9],p=r[10],f=r[11],r!==t&&(t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[4]=o*a+l*i,t[5]=s*a+h*i,t[6]=u*a+p*i,t[7]=c*a+f*i,t[8]=l*a-o*i,t[9]=h*a-s*i,t[10]=p*a-u*i,t[11]=f*a-c*i,this.check()}rotateY(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[0],s=r[1],u=r[2],c=r[3],l=r[8],h=r[9],p=r[10],f=r[11],r!==t&&(t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[0]=o*a-l*i,t[1]=s*a-h*i,t[2]=u*a-p*i,t[3]=c*a-f*i,t[8]=o*i+l*a,t[9]=s*i+h*a,t[10]=u*i+p*a,t[11]=c*i+f*a,this.check()}rotateZ(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[0],s=r[1],u=r[2],c=r[3],l=r[4],h=r[5],p=r[6],f=r[7],r!==t&&(t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[0]=o*a+l*i,t[1]=s*a+h*i,t[2]=u*a+p*i,t[3]=c*a+f*i,t[4]=l*a-o*i,t[5]=h*a-s*i,t[6]=p*a-u*i,t[7]=f*a-c*i,this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,r,n){var i,a,o,s,u,c,l,h,p,f,d,m,g,y,b,v,w,_,k,x,E,S,A,j,C=n[0],T=n[1],B=n[2],R=Math.hypot(C,T,B);R<hs||(C*=R=1/R,T*=R,B*=R,i=Math.sin(r),o=1-(a=Math.cos(r)),s=t[0],u=t[1],c=t[2],l=t[3],h=t[4],p=t[5],f=t[6],d=t[7],m=t[8],g=t[9],y=t[10],b=t[11],v=C*C*o+a,w=T*C*o+B*i,_=B*C*o-T*i,k=C*T*o-B*i,x=T*T*o+a,E=B*T*o+C*i,S=C*B*o+T*i,A=T*B*o-C*i,j=B*B*o+a,e[0]=s*v+h*w+m*_,e[1]=u*v+p*w+g*_,e[2]=c*v+f*w+y*_,e[3]=l*v+d*w+b*_,e[4]=s*k+h*x+m*E,e[5]=u*k+p*x+g*E,e[6]=c*k+f*x+y*E,e[7]=l*k+d*x+b*E,e[8]=s*S+h*A+m*j,e[9]=u*S+p*A+g*j,e[10]=c*S+f*A+y*j,e[11]=l*S+d*A+b*j,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){var t,r,n,i,a,o;return t=this,r=this,n=Array.isArray(e)?e:[e,e,e],i=n[0],a=n[1],o=n[2],t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=r[3]*i,t[4]=r[4]*a,t[5]=r[5]*a,t[6]=r[6]*a,t[7]=r[7]*a,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=r[11]*o,t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this.check()}translate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g,y,b;return t=this,r=this,g=(n=e)[0],y=n[1],b=n[2],r===t?(t[12]=r[0]*g+r[4]*y+r[8]*b+r[12],t[13]=r[1]*g+r[5]*y+r[9]*b+r[13],t[14]=r[2]*g+r[6]*y+r[10]*b+r[14],t[15]=r[3]*g+r[7]*y+r[11]*b+r[15]):(i=r[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=r[9],d=r[10],m=r[11],t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=u,t[5]=c,t[6]=l,t[7]=h,t[8]=p,t[9]=f,t[10]=d,t[11]=m,t[12]=i*g+u*y+p*b+r[12],t[13]=a*g+c*y+f*b+r[13],t[14]=o*g+l*y+d*b+r[14],t[15]=s*g+h*y+m*b+r[15]),this.check()}transform(e,t){return 4===e.length?(r=t||[-0,-0,-0,-0],i=this,a=(n=e)[0],o=n[1],s=n[2],u=n[3],r[0]=i[0]*a+i[4]*o+i[8]*s+i[12]*u,r[1]=i[1]*a+i[5]*o+i[9]*s+i[13]*u,r[2]=i[2]*a+i[6]*o+i[10]*s+i[14]*u,r[3]=i[3]*a+i[7]*o+i[11]*s+i[15]*u,cs(t=r,4),t):this.transformAsPoint(e,t);var r,n,i,a,o,s,u}transformAsPoint(e,t){const{length:r}=e;let n;switch(r){case 2:n=Ds(t||[-0,-0],e,this);break;case 3:n=bs(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(n,e.length),n}transformAsVector(e,t){let r;switch(e.length){case 2:r=xs(t||[-0,-0],e,this);break;case 3:r=Es(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}}let Ws,Vs;function Ks(e){if(e>2*Math.PI)throw Error("expected radians")}var Js=r(0),Qs=.1,$s=1e-12,Ys=1e-15,Xs=1e-20;Math.PI,Math.PI,Math.PI,Math.PI;Math.max(6378137,6378137,6356752.314245179);function Zs(e){return e}new Cs;function eu(e,t=[],r=Zs){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 tu(e,t,r=Zs){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}const ru=new Cs,nu=new Cs,iu=new Cs;const au=new Cs,ou={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"}},su={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},uu={east:new Cs,north:new Cs,up:new Cs,west:new Cs,south:new Cs,down:new Cs},cu=new Cs,lu=new Cs,hu=new Cs;function pu(e,t,r,n,i,a){const o=ou[t]&&ou[t][r];let s,u,c;Qo(o&&(!n||n===o));const l=au.copy(i);if(as(l.x,0,1e-14)&&as(l.y,0,1e-14)){const e=Math.sign(l.z);s=cu.fromArray(su[t]),"east"!==t&&"west"!==t&&s.scale(e),u=lu.fromArray(su[r]),"east"!==r&&"west"!==r&&u.scale(e),c=hu.fromArray(su[n]),"east"!==n&&"west"!==n&&c.scale(e)}else{const{up:i,east:a,north:o}=uu;a.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,i),o.copy(i).cross(a);const{down:h,west:p,south:f}=uu;h.copy(i).scale(-1),p.copy(a).scale(-1),f.copy(o).scale(-1),s=uu[t],u=uu[r],c=uu[n]}return a[0]=s.x,a[1]=s.y,a[2]=s.z,a[3]=0,a[4]=u.x,a[5]=u.y,a[6]=u.z,a[7]=0,a[8]=c.x,a[9]=c.y,a[10]=c.z,a[11]=0,a[12]=l.x,a[13]=l.y,a[14]=l.z,a[15]=1,a}const fu=new Cs,du=new Cs,mu=new Cs,gu=new Cs,yu=new Cs,bu=new Cs;class vu{constructor(e=0,t=0,r=0){Object(Js.a)(this,"radii",void 0),Object(Js.a)(this,"radiiSquared",void 0),Object(Js.a)(this,"radiiToTheFourth",void 0),Object(Js.a)(this,"oneOverRadii",void 0),Object(Js.a)(this,"oneOverRadiiSquared",void 0),Object(Js.a)(this,"minimumRadius",void 0),Object(Js.a)(this,"maximumRadius",void 0),Object(Js.a)(this,"centerToleranceSquared",Qs),Object(Js.a)(this,"squaredXOverSquaredZ",void 0),Qo(e>=0),Qo(t>=0),Qo(r>=0),this.radii=new Cs(e,t,r),this.radiiSquared=new Cs(e*e,t*t,r*r),this.radiiToTheFourth=new Cs(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new Cs(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new Cs(0===e?0:1/(e*e),0===t?0:1/(t*t),0===r?0:1/(r*r)),this.minimumRadius=Math.min(e,t,r),this.maximumRadius=Math.max(e,t,r),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const r=du,n=mu,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,r),n.copy(this.radiiSquared).scale(r);const a=Math.sqrt(r.dot(n));return n.scale(1/a),r.scale(i),n.add(r),n.to(t)}cartesianToCartographic(e,t=[0,0,0]){bu.from(e);const r=this.scaleToGeodeticSurface(bu,gu);if(!r)return;const n=this.geodeticSurfaceNormal(r,du),i=yu;i.copy(bu).subtract(r);const a=Math.atan2(n.y,n.x),o=Math.asin(n.z),s=Math.sign(gs(i,bu))*ds(i);return tu([a,o,s],t,Xo._cartographicRadians?Zs:rs)}eastNorthUpToFixedFrame(e,t=new Gs){return pu(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,n,i=new Gs){return pu(this,e,t,r,n,i)}geocentricSurfaceNormal(e,t=[0,0,0]){return fu.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const r=function(e,t=[]){return eu(e,t,Xo._cartographicRadians?Zs:ts)}(e),n=r[0],i=r[1],a=Math.cos(i);return fu.set(a*Math.cos(n),a*Math.sin(n),Math.sin(i)).normalize(),fu.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return fu.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,r=[]){const{oneOverRadii:n,oneOverRadiiSquared:i,centerToleranceSquared:a}=t;ru.from(e);const o=ru.x,s=ru.y,u=ru.z,c=n.x,l=n.y,h=n.z,p=o*o*c*c,f=s*s*l*l,d=u*u*h*h,m=p+f+d,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const y=nu;if(y.copy(e).scale(g),m<a)return y.to(r);const b=i.x,v=i.y,w=i.z,_=iu;_.set(y.x*b*2,y.y*v*2,y.z*w*2);let k,x,E,S,A=(1-g)*ru.len()/(.5*_.len()),j=0;do{A-=j,k=1/(1+A*b),x=1/(1+A*v),E=1/(1+A*w);const e=k*k,t=x*x,r=E*E;S=p*e+f*t+d*r-1;j=S/(-2*(p*(e*k)*b+f*(t*x)*v+d*(r*E)*w))}while(Math.abs(S)>$s);return ru.scale([k,x,E]).to(r)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){gu.from(e);const r=gu.x,n=gu.y,i=gu.z,a=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*a.x+n*n*a.y+i*i*a.z);return gu.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return gu.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return gu.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){Qo(as(this.radii.x,this.radii.y,Ys)),Qo(this.radii.z>0),gu.from(e);const n=gu.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-t))return gu.set(0,0,n).to(r)}}Object(Js.a)(vu,"WGS84",new vu(6378137,6378137,6356752.314245179));const{_parseImageNode:wu}=globalThis,_u="undefined"!=typeof Image,ku="undefined"!=typeof ImageBitmap,xu=Boolean(wu),Eu=!!Ki||xu;function Su(e){const t=ju(e);if(!t)throw new Error("Not an image");return t}function Au(e){switch(Su(e)){case"data":return e;case"image":case"imagebitmap":const 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 ju(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}const Cu=/^data:image\/svg\+xml/,Tu=/\.svg((\?|#).*)?$/;function Bu(e){return e&&(Cu.test(e)||Tu.test(e))}function Ru(e,t){if(Bu(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ou(e,t,r){const n=function(e,t){if(Bu(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return"data:image/svg+xml;base64,"+btoa(t)}return Ru(e,t)}(e,r),i=self.URL||self.webkitURL,a="string"!=typeof n&&i.createObjectURL(n);try{return await async function(e,t){const r=new Image;if(r.src=e,t.image&&t.image.decode&&r.decode)return await r.decode(),r;return await new Promise((t,n)=>{try{r.onload=()=>t(r),r.onerror=t=>n(new Error(`Could not load image ${e}: ${t}`))}catch(e){n(e)}})}(a||n,t)}finally{a&&i.revokeObjectURL(a)}}const Iu={};let Pu=!0;async function Du(e,t,r){let n;if(Bu(r)){n=await Ou(e,t,r)}else n=Ru(e,r);const i=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Iu)return!1;return!0}(t)&&Pu||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Pu=!1}return await createImageBitmap(e)}(n,i)}function Mu(e){const t=Fu(e);return function(e){const t=Fu(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,!1)))return null;return{mimeType:"image/png",width:t.getUint32(16,!1),height:t.getUint32(20,!1)}}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,!1)&&255===t.getUint8(2)))return null;const{tableMarkers:r,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let i=2;for(;i+9<t.byteLength;){const e=t.getUint16(i,!1);if(n.has(e))return{mimeType:"image/jpeg",height:t.getUint16(i+5,!1),width:t.getUint16(i+7,!1)};if(!r.has(e))return null;i+=2,i+=t.getUint16(i,!1)}return null}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=10&&1195984440===t.getUint32(0,!1)))return null;return{mimeType:"image/gif",width:t.getUint16(6,!0),height:t.getUint16(8,!0)}}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,!1)&&t.getUint32(2,!0)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,!0),height:t.getUint32(22,!0)}}(t)}function Fu(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")}const Lu={id:"image",module:"images",name:"Images",version:"3.3.0",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,r){const n=((t=t||{}).image||{}).type||"auto",{url:i}=r||{};let a;switch(function(e){switch(e){case"auto":case"data":return function(){if(ku)return"imagebitmap";if(_u)return"image";if(Eu)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ku||_u||Eu;case"imagebitmap":return ku;case"image":return _u;case"data":return Eu;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n)){case"imagebitmap":a=await Du(e,t,i);break;case"image":a=await Ou(e,t,i);break;case"data":a=await async function(e,t){const{mimeType:r}=Mu(e)||{},n=globalThis._parseImageNode;return ia(n),await n(e,r)}(e);break;default:ia(!1)}return"data"===n&&(a=Au(a)),a},tests:[e=>Boolean(Mu(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Nu={draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},zu={name:"Draco",id:Ma?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:"3.3.0",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:Nu};function Uu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class qu{constructor(e,t){Uu(this,"fields",void 0),Uu(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const r of e)t[r.name]&&console.warn("Schema: duplicated field name",r.name,r),t[r.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(...e){const t=Object.create(null);for(const r of e)t[r]=!0;const r=this.fields.filter(e=>t[e.name]);return new qu(r,this.metadata)}selectAt(...e){const t=e.map(e=>this.fields[e]).filter(Boolean);return new qu(t,this.metadata)}assign(e){let t,r=this.metadata;if(e instanceof qu){const n=e;t=n.fields,r=Hu(Hu(new Map,this.metadata),n.metadata)}else t=e;const n=Object.create(null);for(const e of this.fields)n[e.name]=e;for(const e of t)n[e.name]=e;const i=Object.values(n);return new qu(i,r)}}function Hu(e,t){return new Map([...e||new Map,...t||new Map])}function Gu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Wu{constructor(e,t,r=!1,n=new Map){Gu(this,"name",void 0),Gu(this,"type",void 0),Gu(this,"nullable",void 0),Gu(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=r,this.metadata=n}get typeId(){return this.type&&this.type.typeId}clone(){return new Wu(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?", metadata: "+this.metadata:""}`}}let Vu,Ku,Ju,Qu,$u,Yu,Xu,Zu,ec;function tc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(Vu||(Vu={}));class rc{static isNull(e){return e&&e.typeId===Vu.Null}static isInt(e){return e&&e.typeId===Vu.Int}static isFloat(e){return e&&e.typeId===Vu.Float}static isBinary(e){return e&&e.typeId===Vu.Binary}static isUtf8(e){return e&&e.typeId===Vu.Utf8}static isBool(e){return e&&e.typeId===Vu.Bool}static isDecimal(e){return e&&e.typeId===Vu.Decimal}static isDate(e){return e&&e.typeId===Vu.Date}static isTime(e){return e&&e.typeId===Vu.Time}static isTimestamp(e){return e&&e.typeId===Vu.Timestamp}static isInterval(e){return e&&e.typeId===Vu.Interval}static isList(e){return e&&e.typeId===Vu.List}static isStruct(e){return e&&e.typeId===Vu.Struct}static isUnion(e){return e&&e.typeId===Vu.Union}static isFixedSizeBinary(e){return e&&e.typeId===Vu.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===Vu.FixedSizeList}static isMap(e){return e&&e.typeId===Vu.Map}static isDictionary(e){return e&&e.typeId===Vu.Dictionary}get typeId(){return Vu.NONE}compareTo(e){return this===e}}Symbol.toStringTag;Symbol.toStringTag;Ku=Symbol.toStringTag;class nc extends rc{constructor(e,t){super(),tc(this,"isSigned",void 0),tc(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return Vu.Int}get[Ku](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class ic extends nc{constructor(){super(!0,8)}}class ac extends nc{constructor(){super(!0,16)}}class oc extends nc{constructor(){super(!0,32)}}class sc extends nc{constructor(){super(!1,8)}}class uc extends nc{constructor(){super(!1,16)}}class cc extends nc{constructor(){super(!1,32)}}const lc=32,hc=64;Ju=Symbol.toStringTag;class pc extends rc{constructor(e){super(),tc(this,"precision",void 0),this.precision=e}get typeId(){return Vu.Float}get[Ju](){return"Float"}toString(){return"Float"+this.precision}}class fc extends pc{constructor(){super(lc)}}class dc extends pc{constructor(){super(hc)}}Symbol.toStringTag;Symbol.toStringTag;Qu=Symbol.toStringTag;$u=Symbol.toStringTag;Yu=Symbol.toStringTag;Xu=Symbol.toStringTag;Zu=Symbol.toStringTag;class mc extends rc{constructor(e,t){super(),tc(this,"listSize",void 0),tc(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return Vu.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Zu](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ec=Symbol.toStringTag;function gc(e,t,r){const n=function(e){switch(e.constructor){case Int8Array:return new ic;case Uint8Array:return new sc;case Int16Array:return new ac;case Uint16Array:return new uc;case Int32Array:return new oc;case Uint32Array:return new cc;case Float32Array:return new fc;case Float64Array:return new dc;default:throw new Error("array type not supported")}}(t.value),i=r||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new Wu(e,new mc(t.size,new Wu("value",n)),!1,i)}function yc(e,t,r){return gc(e,t,r?bc(r.metadata):void 0)}function bc(e){const t=new Map;for(const r in e)t.set(r+".string",JSON.stringify(e[r]));return t}function vc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const wc={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},_c={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class kc{constructor(e){vc(this,"draco",void 0),vc(this,"decoder",void 0),vc(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const r=new this.draco.DecoderBuffer;r.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const n=this.decoder.GetEncodedGeometryType(r),i=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(n){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(r,i);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(r,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!i.ptr){const t="DRACO decompression failed: "+e.error_msg();throw new Error(t)}const a=this._getDracoLoaderData(i,n,t),o=this._getMeshData(i,a,t),s=function(e){let t=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],u=s&&s.length;for(let e=0;e<u;e+=3){const u=s[e],c=s[e+1],l=s[e+2];t=u<t?u:t,r=c<r?c:r,n=l<n?l:n,i=u>i?u:i,a=c>a?c:a,o=l>o?l:o}return[[t,r,n],[i,a,o]]}(o.attributes),u=function(e,t,r){const n=bc(t.metadata),i=[],a=function(e){const t={};for(const r in e){const n=e[r];t[n.name||"undefined"]=n}return t}(t.attributes);for(const t in e){const r=yc(t,e[t],a[t]);i.push(r)}if(r){const e=yc("indices",r);i.push(e)}return new qu(i,n)}(o.attributes,a,o.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:s},...o,schema:u}}finally{this.draco.destroy(r),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,t,r){const n=this._getTopLevelMetadata(e),i=this._getDracoAttributes(e,r);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:i}}_getDracoAttributes(e,t){const r={};for(let n=0;n<e.num_attributes();n++){const i=this.decoder.GetAttribute(e,n),a=this._getAttributeMetadata(e,n);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:n,metadata:a};const o=this._getQuantizationTransform(i,t);o&&(r[i.unique_id()].quantization_transform=o);const s=this._getOctahedronTransform(i,t);s&&(r[i.unique_id()].octahedron_transform=s)}return r}_getMeshData(e,t,r){const n=this._getMeshAttributes(t,e,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(e,t,r){const n={};for(const i of Object.values(e.attributes)){const e=this._deduceAttributeName(i,r);i.name=e;const{value:a,size:o}=this._getAttributeValues(t,i);n[e]={value:a,size:o,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}return n}_getTriangleListIndices(e){const t=3*e.num_faces(),r=4*t,n=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(e,r,n),new Uint32Array(this.draco.HEAPF32.buffer,n,t).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const r=_c[t.data_type],n=t.num_components,i=e.num_points()*n,a=i*r.BYTES_PER_ELEMENT,o=function(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}}(this.draco,r);let s;const u=this.draco._malloc(a);try{const n=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,n,o,a,u),s=new r(this.draco.HEAPF32.buffer,u,i).slice()}finally{this.draco._free(u)}return{value:s,size:n}}_deduceAttributeName(e,t){const r=e.unique_id;for(const[e,n]of Object.entries(t.extraAttributes||{}))if(n===r)return e;const n=e.attribute_type;for(const e in wc){if(this.draco[e]===n)return wc[e]}const i=t.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].string:"CUSTOM_ATTRIBUTE_"+r}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const r=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(r)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},r=this.metadataQuerier.NumEntries(e);for(let n=0;n<r;n++){const r=this.metadataQuerier.GetEntryName(e,n);t[r]=this._getDracoMetadataField(e,r)}return t}_getDracoMetadataField(e,t){const r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,r);const n=function(e){const t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}(r);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:r=[]}=e,n=[...t,...r];for(const e of n)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:r=[]}=t,n=e.attribute_type();if(r.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:r=[]}=t,n=e.attribute_type();if(r.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}var xc=r(52);const Ec={};async function Sc(e,t=null,r={}){return t&&(e=function(e,t,r){if(e.startsWith("http"))return e;const n=r.modules||{};if(n[e])return n[e];if(!Ma)return`modules/${t}/dist/libs/${e}`;if(r.CDN)return Ia(r.CDN.startsWith("http")),`${r.CDN}/${t}@3.3.0/dist/libs/${e}`;if(Fa)return"../src/libs/"+e;return`modules/${t}/src/libs/${e}`}(e,t,r)),Ec[e]=Ec[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!Ma)try{return xc&&xc.requireFromFile&&await xc.requireFromFile(e)}catch{return null}if(Fa)return importScripts(e);const t=await fetch(e);return function(e,t){if(!Ma)return xc.requireFromString&&xc.requireFromString(e,t);if(Fa)return eval.call(Da,e),null;const r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch(t){r.text=e}return document.body.appendChild(r),null}(await t.text(),e)}(e),await Ec[e]}let Ac;async function jc(e){const t=e.modules||{};return Ac=t.draco3d?Ac||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):Ac||async function(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_decoder.js","draco",e);break;case"wasm":default:[t,r]=await Promise.all([await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_wasm_wrapper.js","draco",e),await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_decoder.wasm","draco",e)])}return t=t||globalThis.DracoDecoderModule,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e({...r,onModuleLoaded:e=>t({draco:e})})})}(t,r)}(e),await Ac}const Cc={id:Ma?"draco-writer":"draco-writer-nodejs",name:"Draco compressed geometry writer",module:"draco",version:"3.3.0",worker:!0,options:{draco:{},source:null}},Tc={...zu,parse:async function(e,t){const{draco:r}=await jc(t),n=new kc(r);try{return n.parseSync(e,null==t?void 0:t.draco)}finally{n.destroy()}}};new Uint8Array([0]);const Bc=[171,75,84,88,32,50,48,187,13,10,26,10];var Rc,Oc,Ic,Pc,Dc,Mc,Fc,Lc,Nc;(Nc=Rc||(Rc={}))[Nc.NONE=0]="NONE",Nc[Nc.BASISLZ=1]="BASISLZ",Nc[Nc.ZSTD=2]="ZSTD",Nc[Nc.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Oc||(Oc={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Ic||(Ic={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Pc||(Pc={})),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"}(Dc||(Dc={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Mc||(Mc={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Fc||(Fc={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Lc||(Lc={}));class zc{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=Rc.NONE,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:Oc.BASICFORMAT,versionNumber:2,descriptorBlockSize:40,colorModel:Ic.UNSPECIFIED,colorPrimaries:Pc.SRGB,transferFunction:Pc.SRGB,flags:Mc.ALPHA_STRAIGHT,texelBlockDimension:{x:4,y:4,z:1,w:1},bytesPlane:[],samples:[]}],this.keyValue={},this.globalData=null}}class Uc{constructor(e,t,r,n){this._dataView=new DataView(e.buffer,e.byteOffset+t,r),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const r=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)}}function qc(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Buffer.from(e).toString("utf8")}function Hc(e,t){const r=new Array(t.mipMapLevels);let n=t.width,i=t.height,a=0;for(let o=0;o<t.mipMapLevels;++o){const s=Wc(t,n,i,e,o),u=Gc(e,o,a,s);r[o]={compressed:!0,format:t.internalFormat,data:u,width:n,height:i,levelSize:s},n=Math.max(1,n>>1),i=Math.max(1,i>>1),a+=s}return r}function Gc(e,t,r,n){return Array.isArray(e)?e[t].levelData:new Uint8Array(e.buffer,e.byteOffset+r,n)}function Wc(e,t,r,n,i){return Array.isArray(n)?e.sizeFunction(n[i]):e.sizeFunction(t,r)}const Vc={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},Kc={131:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT,132:Vc.COMPRESSED_SRGB_S3TC_DXT1_EXT,133:Vc.COMPRESSED_RGBA_S3TC_DXT1_EXT,134:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,135:Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT,136:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,137:Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT,138:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,139:Vc.COMPRESSED_RED_RGTC1_EXT,140:Vc.COMPRESSED_SIGNED_RED_RGTC1_EXT,141:Vc.COMPRESSED_RED_GREEN_RGTC2_EXT,142:Vc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,147:Vc.COMPRESSED_RGB8_ETC2,148:Vc.COMPRESSED_SRGB8_ETC2,149:Vc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,150:Vc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,151:Vc.COMPRESSED_RGBA8_ETC2_EAC,152:Vc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,153:Vc.COMPRESSED_R11_EAC,154:Vc.COMPRESSED_SIGNED_R11_EAC,155:Vc.COMPRESSED_RG11_EAC,156:Vc.COMPRESSED_SIGNED_RG11_EAC,157:Vc.COMPRESSED_RGBA_ASTC_4x4_KHR,158:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,159:Vc.COMPRESSED_RGBA_ASTC_5x4_KHR,160:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,161:Vc.COMPRESSED_RGBA_ASTC_5x5_KHR,162:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,163:Vc.COMPRESSED_RGBA_ASTC_6x5_KHR,164:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,165:Vc.COMPRESSED_RGBA_ASTC_6x6_KHR,166:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,167:Vc.COMPRESSED_RGBA_ASTC_8x5_KHR,168:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,169:Vc.COMPRESSED_RGBA_ASTC_8x6_KHR,170:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,171:Vc.COMPRESSED_RGBA_ASTC_8x8_KHR,172:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,173:Vc.COMPRESSED_RGBA_ASTC_10x5_KHR,174:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,175:Vc.COMPRESSED_RGBA_ASTC_10x6_KHR,176:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,177:Vc.COMPRESSED_RGBA_ASTC_10x8_KHR,178:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,179:Vc.COMPRESSED_RGBA_ASTC_10x10_KHR,180:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,181:Vc.COMPRESSED_RGBA_ASTC_12x10_KHR,182:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,183:Vc.COMPRESSED_RGBA_ASTC_12x12_KHR,184:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,1000054e3:Vc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,1000054001:Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,1000066e3:Vc.COMPRESSED_RGBA_ASTC_4x4_KHR,1000066001:Vc.COMPRESSED_RGBA_ASTC_5x4_KHR,1000066002:Vc.COMPRESSED_RGBA_ASTC_5x5_KHR,1000066003:Vc.COMPRESSED_RGBA_ASTC_6x5_KHR,1000066004:Vc.COMPRESSED_RGBA_ASTC_6x6_KHR,1000066005:Vc.COMPRESSED_RGBA_ASTC_8x5_KHR,1000066006:Vc.COMPRESSED_RGBA_ASTC_8x6_KHR,1000066007:Vc.COMPRESSED_RGBA_ASTC_8x8_KHR,1000066008:Vc.COMPRESSED_RGBA_ASTC_10x5_KHR,1000066009:Vc.COMPRESSED_RGBA_ASTC_10x6_KHR,1000066010:Vc.COMPRESSED_RGBA_ASTC_10x8_KHR,1000066011:Vc.COMPRESSED_RGBA_ASTC_10x10_KHR,1000066012:Vc.COMPRESSED_RGBA_ASTC_12x10_KHR,1000066013:Vc.COMPRESSED_RGBA_ASTC_12x12_KHR};const Jc=[171,75,84,88,32,50,48,187,13,10,26,10];function Qc(e){const t=new Uint8Array(e);return!(t.byteLength<Jc.length||t[0]!==Jc[0]||t[1]!==Jc[1]||t[2]!==Jc[2]||t[3]!==Jc[3]||t[4]!==Jc[4]||t[5]!==Jc[5]||t[6]!==Jc[6]||t[7]!==Jc[7]||t[8]!==Jc[8]||t[9]!==Jc[9]||t[10]!==Jc[10]||t[11]!==Jc[11])}function $c(e){const t=function(e){const t=new Uint8Array(e.buffer,e.byteOffset,Bc.length);if(t[0]!==Bc[0]||t[1]!==Bc[1]||t[2]!==Bc[2]||t[3]!==Bc[3]||t[4]!==Bc[4]||t[5]!==Bc[5]||t[6]!==Bc[6]||t[7]!==Bc[7]||t[8]!==Bc[8]||t[9]!==Bc[9]||t[10]!==Bc[10]||t[11]!==Bc[11])throw new Error("Missing KTX 2.0 identifier.");const r=new zc,n=17*Uint32Array.BYTES_PER_ELEMENT,i=new Uc(e,Bc.length,n,!0);r.vkFormat=i._nextUint32(),r.typeSize=i._nextUint32(),r.pixelWidth=i._nextUint32(),r.pixelHeight=i._nextUint32(),r.pixelDepth=i._nextUint32(),r.layerCount=i._nextUint32(),r.faceCount=i._nextUint32();const a=i._nextUint32();r.supercompressionScheme=i._nextUint32();const o=i._nextUint32(),s=i._nextUint32(),u=i._nextUint32(),c=i._nextUint32(),l=i._nextUint64(),h=i._nextUint64(),p=new Uc(e,Bc.length+n,3*a*8,!0);for(let t=0;t<a;t++)r.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const f=new Uc(e,o,s,!0),d={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:{x:f._nextUint8()+1,y:f._nextUint8()+1,z:f._nextUint8()+1,w:f._nextUint8()+1},bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},m=(d.descriptorBlockSize/4-6)/4;for(let e=0;e<m;e++)d.samples[e]={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelID:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:f._nextUint32(),sampleUpper:f._nextUint32()};r.dataFormatDescriptor.length=0,r.dataFormatDescriptor.push(d);const g=new Uc(e,u,c,!0);for(;g._offset<c;){const e=g._nextUint32(),t=g._scan(e),n=qc(t),i=g._scan(e-t.byteLength);r.keyValue[n]=n.match(/^ktx/i)?qc(i):i,e%4&&g._skip(4-e%4)}if(h<=0)return r;const y=new Uc(e,l,h,!0),b=y._nextUint16(),v=y._nextUint16(),w=y._nextUint32(),_=y._nextUint32(),k=y._nextUint32(),x=y._nextUint32(),E=[];for(let e=0;e<a;e++)E.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});const S=l+y._offset,A=S+w,j=A+_,C=j+k,T=new Uint8Array(e.buffer,e.byteOffset+S,w),B=new Uint8Array(e.buffer,e.byteOffset+A,_),R=new Uint8Array(e.buffer,e.byteOffset+j,k),O=new Uint8Array(e.buffer,e.byteOffset+C,x);return r.globalData={endpointCount:b,selectorCount:v,imageDescs:E,endpointsData:T,selectorsData:B,tablesData:R,extendedData:O},r}(new Uint8Array(e)),r=Math.max(1,t.levels.length),n=t.pixelWidth,i=t.pixelHeight,a=(o=t.vkFormat,Kc[o]);var o;return Hc(t.levels,{mipMapLevels:r,width:n,height:i,sizeFunction:e=>e.uncompressedByteLength,internalFormat:a})}const Yc=542327876,Xc=31,Zc=0,el=1,tl=2,rl=3,nl=4,il=7,al=20,ol=21,sl=131072,ul=4,cl={DXT1:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT,DXT3:Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT,DXT5:Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT,"ATC ":Vc.COMPRESSED_RGB_ATC_WEBGL,ATCA:Vc.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,ATCI:Vc.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL},ll={DXT1:pl,DXT3:fl,DXT5:fl,"ATC ":pl,ATCA:fl,ATCI:fl};function hl(e){const t=new Int32Array(e,0,Xc),r=t[ol];ia(Boolean(t[al]&ul),"DDS: Unsupported format, must contain a FourCC code");const n=(i=r,String.fromCharCode(255&i,i>>8&255,i>>16&255,i>>24&255));var i;const a=cl[n],o=ll[n];ia(a&&o,"DDS: Unknown pixel format "+r);let s=1;t[tl]&sl&&(s=Math.max(1,t[il]));const u=t[nl],c=t[rl],l=t[el]+4;return Hc(new Uint8Array(e,l),{mipMapLevels:s,width:u,height:c,sizeFunction:o,internalFormat:a})}function pl(e,t){return(e+3>>2)*(t+3>>2)*8}function fl(e,t){return(e+3>>2)*(t+3>>2)*16}const dl=55727696,ml=1347834371,gl=13,yl=52,bl=0,vl=2,wl=4,_l=6,kl=7,xl=11,El=12,Sl={0:[Vc.COMPRESSED_RGB_PVRTC_2BPPV1_IMG],1:[Vc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],2:[Vc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG],3:[Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],6:[Vc.COMPRESSED_RGB_ETC1_WEBGL],7:[Vc.COMPRESSED_RGB_S3TC_DXT1_EXT],9:[Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT],11:[Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT],22:[Vc.COMPRESSED_RGB8_ETC2],23:[Vc.COMPRESSED_RGBA8_ETC2_EAC],24:[Vc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],25:[Vc.COMPRESSED_R11_EAC],26:[Vc.COMPRESSED_RG11_EAC],27:[Vc.COMPRESSED_RGBA_ASTC_4X4_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR],28:[Vc.COMPRESSED_RGBA_ASTC_5X4_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR],29:[Vc.COMPRESSED_RGBA_ASTC_5X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR],30:[Vc.COMPRESSED_RGBA_ASTC_6X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR],31:[Vc.COMPRESSED_RGBA_ASTC_6X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR],32:[Vc.COMPRESSED_RGBA_ASTC_8X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR],33:[Vc.COMPRESSED_RGBA_ASTC_8X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR],34:[Vc.COMPRESSED_RGBA_ASTC_8X8_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR],35:[Vc.COMPRESSED_RGBA_ASTC_10X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR],36:[Vc.COMPRESSED_RGBA_ASTC_10X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR],37:[Vc.COMPRESSED_RGBA_ASTC_10X8_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR],38:[Vc.COMPRESSED_RGBA_ASTC_10X10_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR],39:[Vc.COMPRESSED_RGBA_ASTC_12X10_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR],40:[Vc.COMPRESSED_RGBA_ASTC_12X12_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR]},Al={0:jl,1:jl,2:Cl,3:Cl,6:Tl,7:Tl,9:Bl,11:Bl,22:Tl,23:Bl,24:Tl,25:Tl,26:Bl,27:Bl,28:function(e,t){return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16},29:function(e,t){return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16},30:function(e,t){return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16},31:function(e,t){return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16},32:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16},33:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16},34:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16},35:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16},36:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16},37:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16},38:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16},39:function(e,t){return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16},40:function(e,t){return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16}};function jl(e,t){return(e=Math.max(e,16))*(t=Math.max(t,8))/4}function Cl(e,t){return(e=Math.max(e,8))*(t=Math.max(t,8))/2}function Tl(e,t){return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8}function Bl(e,t){return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16}function Rl(e){if(Qc(e))return $c(e);if(function(e){return new Uint32Array(e,0,Xc)[Zc]===Yc}(e))return hl(e);if(function(e){const t=new Uint32Array(e,0,gl)[bl];return t===dl||t===ml}(e))return function(e){const t=new Uint32Array(e,0,gl),r=t[vl],n=t[wl],i=Sl[r]||[],a=i.length>1&&n?i[1]:i[0],o=Al[r],s=t[xl],u=t[kl],c=t[_l],l=yl+t[El];return Hc(new Uint8Array(e,l),{mipMapLevels:s,width:u,height:c,sizeFunction:o,internalFormat:a})}(e);throw new Error("Texture container format not recognized")}let Ol,Il;async function Pl(e){const t=e.modules||{};return t.basis?t.basis:(Ol=Ol||async function(e){let t=null,r=null;return[t,r]=await Promise.all([await Sc("basis_transcoder.js","textures",e),await Sc("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e(r).then(e=>{const{BasisFile:r,initializeBasis:n}=e;n(),t({BasisFile:r})})})}(t,r)}(e),await Ol)}async function Dl(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Il=Il||async function(e){let t=null,r=null;return[t,r]=await Promise.all([await Sc("https://unpkg.com/@loaders.gl/textures@3.3.0/dist/libs/basis_encoder.js","textures",e),await Sc("https://unpkg.com/@loaders.gl/textures@3.3.0/dist/libs/basis_encoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e(r).then(e=>{const{BasisFile:r,KTX2File:n,initializeBasis:i,BasisEncoder:a}=e;i(),t({BasisFile:r,KTX2File:n,BasisEncoder:a})})})}(t,r)}(e),await Il)}const Ml=["","WEBKIT_","MOZ_"],Fl={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"};let Ll=null;function Nl(e){if(!Ll){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Ll=new Set;for(const t of Ml)for(const r in Fl)if(e&&e.getExtension(`${t}${r}`)){const e=Fl[r];Ll.add(e)}}return Ll}const zl={etc1:{basisFormat:0,compressed:!0,format:Vc.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:Vc.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:Vc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:Vc.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 Ul(e,t){if("auto"===t.basis.containerFormat){if(Qc(e)){return Gl((await Dl(t)).KTX2File,e,t)}const{BasisFile:r}=await Pl(t);return ql(r,e,t)}switch(t.basis.module){case"encoder":const r=await Dl(t);switch(t.basis.containerFormat){case"ktx2":return Gl(r.KTX2File,e,t);case"basis":default:return ql(r.BasisFile,e,t)}case"transcoder":default:const{BasisFile:n}=await Pl(t);return ql(n,e,t)}}function ql(e,t,r){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");const e=n.getNumImages(),t=[];for(let i=0;i<e;i++){const e=n.getNumLevels(i),a=[];for(let t=0;t<e;t++)a.push(Hl(n,i,t,r));t.push(a)}return t}finally{n.close(),n.delete()}}function Hl(e,t,r,n){const i=e.getImageWidth(t,r),a=e.getImageHeight(t,r),o=e.getHasAlpha(),{compressed:s,format:u,basisFormat:c}=Vl(n,o),l=e.getImageTranscodedSizeInBytes(t,r,c),h=new Uint8Array(l);if(!e.transcodeImage(h,t,r,c,0,0))throw new Error("failed to start Basis transcoding");return{width:i,height:a,data:h,compressed:s,format:u,hasAlpha:o}}function Gl(e,t,r){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=n.getLevels(),t=[];for(let i=0;i<e;i++){t.push(Wl(n,i,r));break}return[t]}finally{n.close(),n.delete()}}function Wl(e,t,r){const{alphaFlag:n,height:i,width:a}=e.getImageLevelInfo(t,0,0),{compressed:o,format:s,basisFormat:u}=Vl(r,n),c=e.getImageTranscodedSizeInBytes(t,0,0,u),l=new Uint8Array(c);if(!e.transcodeImage(l,t,0,0,u,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:a,height:i,data:l,compressed:o,levelSize:c,hasAlpha:n,format:s}}function Vl(e,t){let r=e&&e.basis&&e.basis.format;return"auto"===r&&(r=Kl()),"object"==typeof r&&(r=t?r.alpha:r.noAlpha),r=r.toLowerCase(),zl[r]}function Kl(){const e=Nl();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"}const Jl={name:"Texture Containers",id:"compressed-texture",module:"textures",version:"3.3.0",worker:!0,extensions:["ktx","ktx2","dds","pvr"],mimeTypes:["image/ktx2","image/ktx","image/vnd-ms.dds","image/x-dds","application/octet-stream"],binary:!0,options:{"compressed-texture":{libraryPath:"libs/",useBasis:!1}}},Ql={...Jl,parse:async(e,t)=>t["compressed-texture"].useBasis?(t.basis={format:{alpha:"BC3",noAlpha:"BC1"},...t.basis,containerFormat:"ktx2",module:"encoder"},(await Ul(e,t))[0]):Rl(e)},$l={name:"Basis",id:Ma?"basis":"basis-nodejs",module:"textures",version:"3.3.0",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"}}},Yl={...$l,parse:Ul};let Xl,Zl;function eh(e,t=null){return t?`${e}?token=${t}`:e}!function(e){e.UInt8="UInt8",e.UInt16="UInt16",e.UInt32="UInt32",e.UInt64="UInt64",e.Int16="Int16",e.Int32="Int32",e.Int64="Int64",e.Float32="Float32",e.Float64="Float64"}(Xl||(Xl={})),function(e){e.vertexCount="vertexCount",e.featureCount="featureCount"}(Zl||(Zl={}));var th=5121,rh=5123,nh=5125,ih=5126,ah=5130;function oh(e){switch(e){case Xl.UInt8:return Uint8Array;case Xl.UInt16:return Uint16Array;case Xl.UInt32:return Uint32Array;case Xl.Float32:return Float32Array;case Xl.UInt64:return Float64Array;default:throw new Error("parse i3s tile content: unknown type of data: "+e)}}const sh={UInt8:th,UInt16:rh,Float32:ih,UInt32:nh,UInt64:ah};function uh(e){switch(e){case Xl.UInt8:return 1;case Xl.UInt16:case Xl.Int16:return 2;case Xl.UInt32:case Xl.Int32:case Xl.Float32:return 4;case Xl.UInt64:case Xl.Int64:case Xl.Float64:return 8;default:throw new Error("parse i3s tile content: unknown size of data: "+e)}}let ch;async function lh(e,t){const{attributeName:r,attributeType:n}=t;return r?{[r]:n?hh(n,e):null}:{}}function hh(e,t){switch(e){case"String":return function(e){const t=[];try{const r=new DataView(e,0,4).getUint32(0,!0),n=new Uint32Array(e,8,r);let i=8+4*r;for(const r of n){const n=new TextDecoder("utf-8"),a=new Uint8Array(e,i,r);t.push(n.decode(a)),i+=r}}catch(e){console.error("Parse string attribute error: ",e.message)}return t}(t);case"Oid32":return ph(t);case"Float64":return function(e){return new Float64Array(e,8)}(t);case"Int16":return function(e){return new Int16Array(e,4)}(t);default:return ph(t)}}function ph(e){return new Uint32Array(e,4)}!function(e){e[e.DEFAULT=-1]="DEFAULT",e[e.LNGLAT=1]="LNGLAT",e[e.METER_OFFSETS=2]="METER_OFFSETS",e[e.LNGLAT_OFFSETS=3]="LNGLAT_OFFSETS",e[e.CARTESIAN=0]="CARTESIAN"}(ch||(ch={}));const fh={name:"I3S Attribute",id:"i3s-attribute",module:"i3s",version:"3.3.0",mimeTypes:["application/binary"],parse:async function(e,t){return e=lh(e,t)},extensions:["bin"],options:{},binary:!0};function dh(e){return e.hasOwnProperty("objectIds")?"Oid32":e.hasOwnProperty("attributeValues")?e.attributeValues.valueType:""}function mh(e,t){var r;if(null==t||null===(r=t.i3s)||void 0===r||!r.colorsByAttribute)return[255,255,255,255];const{minValue:n,maxValue:i,minColor:a,maxColor:o}=t.i3s.colorsByAttribute,s=(e-n)/(i-n),u=[255,255,255,255];for(let e=0;e<a.length;e++)u[e]=Math.round((o[e]-a[e])*s+a[e]);return u}async function gh(e,{attributeUrls:t},{attributeStorageInfo:r},n){var i;const a=r.findIndex(({name:t})=>e===t);if(-1===a)return null;const o=eh(t[a],null==n||null===(i=n.i3s)||void 0===i?void 0:i.token),s=dh(r[a]);return await Jo(o,fh,{attributeName:e,attributeType:s})}const yh=new Cs([0,0,0]);async function bh(e,t,r,n,i){const a={attributes:{},indices:null,featureIds:[],vertexCount:0,modelMatrix:new Gs,coordinateSystem:0,byteLength:0,texture:null};if(t.textureUrl){var o;const e=eh(t.textureUrl,null==n||null===(o=n.i3s)||void 0===o?void 0:o.token),r=function(e){switch(e){case"ktx-etc2":case"dds":return Ql;case"ktx2":return Yl;case"jpg":case"png":default:return Lu}}(t.textureFormat),s=await fetch(e,null==n?void 0:n.fetch),u=await s.arrayBuffer();if(null!=n&&n.i3s.decodeTextures){if(r===Lu){const e={...t.textureLoaderOptions,image:{type:"data"}};try{a.texture=await i.parse(u,e)}catch(t){a.texture=await Ko(u,r,e)}}else if(r===Ql||r===Yl){let e=await Jo(u,r,t.textureLoaderOptions);r===Yl&&(e=e[0]),a.texture={compressed:!0,mipmaps:!1,width:e[0].width,height:e[0].height,data:e}}}else a.texture=u}return a.material=function(e,t){let r;e?r={...e,pbrMetallicRoughness:e.pbrMetallicRoughness?{...e.pbrMetallicRoughness}:{baseColorFactor:[255,255,255,255]}}:(r={pbrMetallicRoughness:{}},t?r.pbrMetallicRoughness.baseColorTexture={texCoord:0}:r.pbrMetallicRoughness.baseColorFactor=[255,255,255,255]);r.alphaCutoff=r.alphaCutoff||.25,r.alphaMode&&(r.alphaMode=r.alphaMode.toUpperCase());r.emissiveFactor&&(r.emissiveFactor=kh(r.emissiveFactor));r.pbrMetallicRoughness&&r.pbrMetallicRoughness.baseColorFactor&&(r.pbrMetallicRoughness.baseColorFactor=kh(r.pbrMetallicRoughness.baseColorFactor));t&&function(e,t){const r={source:{image:t}};e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture?e.pbrMetallicRoughness.baseColorTexture={...e.pbrMetallicRoughness.baseColorTexture,texture:r}:e.emissiveTexture?e.emissiveTexture={...e.emissiveTexture,texture:r}:e.pbrMetallicRoughness&&e.pbrMetallicRoughness.metallicRoughnessTexture?e.pbrMetallicRoughness.metallicRoughnessTexture={...e.pbrMetallicRoughness.metallicRoughnessTexture,texture:r}:e.normalTexture?e.normalTexture={...e.normalTexture,texture:r}:e.occlusionTexture&&(e.occlusionTexture={...e.occlusionTexture,texture:r})}(r,t);return r}(t.materialDefinition,a.texture),a.material&&(a.texture=null),await async function(e,t,r,n,i){var a;const o=e.byteLength;let s,u,c,l=0,h=0;if(r.isDracoGeometry){var p;const t=await Ko(e,Tc,{draco:{attributeNameEntry:"i3s-attribute-type"}});u=t.header.vertexCount,c=null===(p=t.indices)||void 0===p?void 0:p.value;const{POSITION:r,NORMAL:n,COLOR_0:i,TEXCOORD_0:a,"feature-index":o,"uv-region":l}=t.attributes;s={position:r,normal:n,color:i,uv0:a,uvRegion:l,id:o},function(e,t){for(const r in t.loaderData.attributes){const n=t.loaderData.attributes[r];switch(n.name){case"POSITION":e.position.metadata=n.metadata;break;case"feature-index":e.id.metadata=n.metadata}}}(s,t);const h=function(e){var t,r;return null==e||null===(t=e.metadata)||void 0===t||null===(r=t["i3s-feature-ids"])||void 0===r?void 0:r.intArray}(o);h&&function(e,t){const r=e.id.value,n=new Float32Array(r.length);for(let e=0;e<r.length;e++)n[e]=t[r[e]];e.id.value=n}(s,h)}else{const{vertexAttributes:t,ordering:r,featureAttributes:i,featureAttributeOrder:a}=n.store.defaultGeometrySchema,o=function(e,t){let r=0,n=0,i=0;for(const{property:a,type:o}of t.store.defaultGeometrySchema.header){const t=oh(o);switch(a){case Zl.vertexCount:n=new t(e,0,4)[0],r+=uh(o);break;case Zl.featureCount:i=new t(e,4,4)[0],r+=uh(o)}}return{vertexCount:n,featureCount:i,byteOffset:r}}(e,n);l=o.byteOffset,u=o.vertexCount,h=o.featureCount;const{attributes:c,byteOffset:p}=wh(e,l,t,u,r),{attributes:f}=wh(e,p,i,h,a);!function(e){const{id:t,faceRange:r}=e;if(!t||!r)return;const n=t.value,i=r.value,a=i[i.length-1]+1,o=new Uint32Array(3*a);let s=0,u=0;for(let e=1;e<i.length;e+=2){const t=Number(n[s]),r=i[e],a=i[e-1],c=u+3*(r-a+1);o.fill(t,u,c),s++,u=c}e.id.value=o}(f),s=function(e,t){return{...e,...t}}(c,f)}if(null!=i&&null!==(a=i.i3s)&&void 0!==a&&a.coordinateSystem&&i.i3s.coordinateSystem!==ch.METER_OFFSETS)t.modelMatrix=function(e){var t,r;const n=e.metadata,i=(null==n||null===(t=n["i3s-scale_x"])||void 0===t?void 0:t.double)||1,a=(null==n||null===(r=n["i3s-scale_y"])||void 0===r?void 0:r.double)||1,o=new Gs;return o[0]=i,o[5]=a,o}(s.position),t.coordinateSystem=ch.LNGLAT_OFFSETS;else{const e=function(e,t){const r=t.mbs,n=e.value,i=e.metadata,a=new Gs,o=new Cs(r[0],r[1],r[2]),s=new Cs;return vu.WGS84.cartographicToCartesian(o,s),vu.WGS84.eastNorthUpToFixedFrame(s,a),e.value=function(e,t={},r){const n=new Float64Array(e.length),i=t["i3s-scale_x"]&&t["i3s-scale_x"].double||1,a=t["i3s-scale_y"]&&t["i3s-scale_y"].double||1;for(let t=0;t<n.length;t+=3)n[t]=e[t]*i+r.x,n[t+1]=e[t+1]*a+r.y,n[t+2]=e[t+2]+r.z;for(let e=0;e<n.length;e+=3)vu.WGS84.cartographicToCartesian(n.subarray(e,e+3),yh),n[e]=yh.x,n[e+1]=yh.y,n[e+2]=yh.z;return n}(n,i,o),a}(s.position,r);t.modelMatrix=e.invert(),t.coordinateSystem=ch.METER_OFFSETS}s.color=await async function(e,t,r,n,i){var a;if(null==i||null===(a=i.i3s)||void 0===a||!a.colorsByAttribute)return e;const o=n.fields.find(({name:e})=>{var t,r;return e===(null==i||null===(t=i.i3s)||void 0===t||null===(r=t.colorsByAttribute)||void 0===r?void 0:r.attributeName)});if(!o||!["esriFieldTypeDouble","esriFieldTypeInteger","esriFieldTypeSmallInteger"].includes(o.type))return e;const s=await gh(o.name,r,n,i);if(!s)return e;const u=n.fields.find(({type:e})=>"esriFieldTypeOID"===e);if(!u)return e;const c=await gh(u.name,r,n,i);if(!c)return e;const l={};for(let e=0;e<c[u.name].length;e++)l[c[u.name][e]]=mh(s[o.name][e],i);for(let r=0;r<t.value.length;r++){const n=l[t.value[r]];n&&e.value.set(n,4*r)}return e}(s.color,s.id,r,n,i),t.attributes={positions:s.position,normals:s.normal,colors:vh(s.color),texCoords:s.uv0,uvRegions:vh(s.uvRegion||s.region)},t.indices=c||null,s.id&&s.id.value&&(t.featureIds=s.id.value);for(const e in t.attributes)t.attributes[e]||delete t.attributes[e];return t.vertexCount=u,t.byteLength=o,t}(e,a,t,r,n)}function vh(e){return e?(e.normalized=!0,e):e}function wh(e,t,r,n,i){const a={};for(const o of i)if(r[o]){const{valueType:i,valuesPerElement:s}=r[o];if(t+n*s*uh(i)<=e.byteLength){const r=e.slice(t);let u;if("UInt64"===i)u=_h(r,n*s,uh(i));else{u=new(oh(i))(r,0,n*s)}switch(a[o]={value:u,type:sh[i],size:s},o){case"color":a.color.normalized=!0}t+=n*s*uh(i)}else if("uv0"!==o)break}return{attributes:a,byteOffset:t}}function _h(e,t,r){const n=[],i=new DataView(e);let a=0;for(let e=0;e<t;e++){const e=i.getUint32(a,!0)+2**32*i.getUint32(a+4,!0);n.push(e),a+=r}return new Uint32Array(n)}function kh(e){const t=[...e];for(let r=0;r<e.length;r++)t[r]=e[r]/255;return t}const xh={name:"I3S Content (Indexed Scene Layers)",id:Ma?"i3s-content":"i3s-content-nodejs",module:"i3s",worker:!0,version:"3.3.0",mimeTypes:["application/octet-stream"],parse:async function(e,t,r){const{tile:n,_tileOptions:i,tileset:a,_tilesetOptions:o}=(null==t?void 0:t.i3s)||{},s=i||n,u=o||a;if(!s||!u)return null;return await bh(e,s,u,t,r)},extensions:["bin"],options:{"i3s-content":{}}};const Eh=-1,Sh=0,Ah=1;new Cs,new Cs;const jh=new Cs,Ch=new Cs;class Th{constructor(e=[0,0,0],t=0){Object(Js.a)(this,"center",void 0),Object(Js.a)(this,"radius",void 0),this.radius=-0,this.center=new Cs,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=jh.from(t),this.center=(new Cs).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Th(this.center,this.radius)}union(e){const t=this.center,r=this.radius,n=e.center,i=e.radius,a=jh.copy(n).subtract(t),o=a.magnitude();if(r>=o+i)return this.clone();if(i>=o+r)return e.clone();const s=.5*(r+o+i);return Ch.copy(a).scale((-r+s)/o).add(t),this.center.copy(Ch),this.radius=s,this}expand(e){const t=jh.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=Rs(jh,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=jh.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,r=this.radius,n=e.normal.dot(t)+e.distance;return n<-r?Eh:n<r?Sh:Ah}}function Bh(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],h=t[8],p=r[0],f=r[1],d=r[2],m=r[3],g=r[4],y=r[5],b=r[6],v=r[7],w=r[8];return e[0]=p*n+f*o+d*c,e[1]=p*i+f*s+d*l,e[2]=p*a+f*u+d*h,e[3]=m*n+g*o+y*c,e[4]=m*i+g*s+y*l,e[5]=m*a+g*u+y*h,e[6]=b*n+v*o+w*c,e[7]=b*i+v*s+w*l,e[8]=b*a+v*u+w*h,e}function Rh(e,t,r){var n=r[0],i=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var Oh;!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"}(Oh||(Oh={}));const Ih=Object.freeze([1,0,0,0,1,0,0,0,1]);class Ph extends Ts{static get IDENTITY(){return function(){Mh||(Mh=new Ph,Object.freeze(Mh));return Mh}()}static get ZERO(){return function(){Dh||(Dh=new Ph([0,0,0,0,0,0,0,0,0]),Object.freeze(Dh));return Dh}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Oh}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Ih)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,c=r*o,l=n*o,h=n*s,p=i*o,f=i*s,d=i*u,m=a*o,g=a*s,y=a*u;e[0]=1-h-d,e[3]=l-y,e[6]=p+g,e[1]=l+y,e[4]=1-c-d,e[7]=f-m,e[2]=p-g,e[5]=f+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,r,n,i,a,o,s,u){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this.check()}setRowMajor(e,t,r,n,i,a,o,s,u){return this[0]=e,this[1]=n,this[2]=o,this[3]=t,this[4]=i,this[5]=s,this[6]=r,this[7]=a,this[8]=u,this.check()}determinant(){return t=(e=this)[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],t*(c*a-o*u)+r*(-c*i+o*s)+n*(u*i-a*s);var e,t,r,n,i,a,o,s,u,c}transpose(){return function(e,t){if(e===t){var r=t[1],n=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,e[7]=i}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]}(this,this),this.check()}invert(){var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d;return e=this,r=(t=this)[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],(d=r*(h=l*o-s*c)+n*(p=-l*a+s*u)+i*(f=c*a-o*u))&&(d=1/d,e[0]=h*d,e[1]=(-l*n+i*c)*d,e[2]=(s*n-i*o)*d,e[3]=p*d,e[4]=(l*r-i*u)*d,e[5]=(-s*r+i*a)*d,e[6]=f*d,e[7]=(-c*r+n*u)*d,e[8]=(o*r-n*a)*d),this.check()}multiplyLeft(e){return Bh(this,e,this),this.check()}multiplyRight(e){return Bh(this,this,e),this.check()}rotate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d;return t=this,n=e,i=(r=this)[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=Math.sin(n),d=Math.cos(n),t[0]=d*i+f*s,t[1]=d*a+f*u,t[2]=d*o+f*c,t[3]=d*s-f*i,t[4]=d*u-f*a,t[5]=d*c-f*o,t[6]=l,t[7]=h,t[8]=p,this.check()}scale(e){return Array.isArray(e)?Rh(this,this,e):Rh(this,this,[e,e]),this.check()}translate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d;return t=this,n=e,i=(r=this)[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=n[0],d=n[1],t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=u,t[5]=c,t[6]=f*i+d*s+l,t[7]=f*a+d*u+h,t[8]=f*o+d*c+p,this.check()}transform(e,t){let r;switch(e.length){case 2:r=Ps(t||[-0,-0],e,this);break;case 3:r=vs(t||[-0,-0,-0],e,this);break;case 4:r=Ss(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Dh,Mh,Fh;class Lh extends ls{static get ZERO(){return Fh||(Fh=new Lh(0,0,0,0),Object.freeze(Fh)),Fh}constructor(e=0,t=0,r=0,n=0){super(-0,-0,-0,-0),es(e)&&1===arguments.length?this.copy(e):(Xo.debug&&(us(e),us(t),us(r),us(n)),this[0]=e,this[1]=t,this[2]=r,this[3]=n)}set(e,t,r,n){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y),us(e.z),us(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=us(e)}get w(){return this[3]}set w(e){this[3]=us(e)}transform(e){return bs(this,this,e),this.check()}transformByMatrix3(e){return Ss(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e[3]=t[3]}(this,this,e),this.check()}transformByQuaternion(e){return ws(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function Nh(){var e=new ps(4);return ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function zh(e,t,r){r*=.5;var 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 Uh(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],c=r[2],l=r[3];return e[0]=n*l+o*s+i*c-a*u,e[1]=i*l+o*u+a*s-n*c,e[2]=a*l+o*c+n*u-i*s,e[3]=o*l-n*s-i*u-a*c,e}function qh(e,t,r,n){var i,a,o,s,u,c=t[0],l=t[1],h=t[2],p=t[3],f=r[0],d=r[1],m=r[2],g=r[3];return(a=c*f+l*d+h*m+p*g)<0&&(a=-a,f=-f,d=-d,m=-m,g=-g),1-a>hs?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*c+u*f,e[1]=s*l+u*d,e[2]=s*h+u*m,e[3]=s*p+u*g,e}function Hh(e,t){var r,n=t[0]+t[4]+t[8];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{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e}var Gh,Wh,Vh,Kh,Jh,Qh,$h,Yh=function(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},Xh=function(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},Zh=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ep=function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e[3]=s+n*(r[3]-s),e},tp=Ms,rp=Fs,np=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o,e},ip=(Gh=fs(),Wh=ms(1,0,0),Vh=ms(0,1,0),function(e,t,r){var n=gs(t,r);return n<-.999999?(ys(Gh,Wh,t),ks(Gh)<1e-6&&ys(Gh,Vh,t),function(e,t){var r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a}(Gh,Gh),zh(e,Gh,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(ys(Gh,t,r),e[0]=Gh[0],e[1]=Gh[1],e[2]=Gh[2],e[3]=1+n,np(e,e))});Kh=Nh(),Jh=Nh(),Qh=new ps(9),ps!=Float32Array&&(Qh[1]=0,Qh[2]=0,Qh[3]=0,Qh[5]=0,Qh[6]=0,Qh[7]=0),Qh[0]=1,Qh[4]=1,Qh[8]=1,$h=Qh;const ap=[0,0,0,1];class op extends ss{constructor(e=0,t=0,r=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,r,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,r,n){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return Hh(this,e),this.check()}fromAxisRotation(e,t){return zh(this,e,t),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=us(e)}get y(){return this[1]}set y(e){this[1]=us(e)}get z(){return this[2]}set z(e){this[2]=us(e)}get w(){return this[3]}set w(e){this[3]=us(e)}len(){return tp(this)}lengthSquared(){return rp(this)}dot(e){return Zh(this,e)}rotationTo(e,t){return ip(this,e,t),this.check()}add(e){return Yh(this,this,e),this.check()}calculateW(){return function(e,t){var r=t[0],n=t[1],i=t[2];e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s}(this,this),this.check()}lerp(e,t,r){return void 0===r?this.lerp(this,e,t):(ep(this,e,t,r),this.check())}multiplyRight(e){return Uh(this,this,e),this.check()}multiplyLeft(e){return Uh(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s}(this,this,e),this.check()}rotateY(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s}(this,this,e),this.check()}rotateZ(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s}(this,this,e),this.check()}scale(e){return Xh(this,this,e),this.check()}slerp(e,t,r){let n,i,a;switch(arguments.length){case 1:({start:n=ap,target:i,ratio:a}=e);break;case 2:n=this,i=e,a=t;break;default:n=e,i=t,a=r}return qh(this,n,i,a),this.check()}transformVector4(e,t=new Lh){return function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],c=r[3],l=c*n+s*a-u*i,h=c*i+u*n-o*a,p=c*a+o*i-s*n,f=-o*n-s*i-u*a;e[0]=l*c+f*-o+h*-u-p*-s,e[1]=h*c+f*-s+p*-o-l*-u,e[2]=p*c+f*-u+l*-s-h*-o,e[3]=t[3]}(t,e,this),cs(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const sp=new Cs,up=new Cs,cp=new Cs,lp=new Cs,hp=new Cs,pp=new Cs,fp=new Cs,dp=0,mp=1,gp=2,yp=3,bp=4,vp=5,wp=6,_p=7,kp=8;class xp{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){Object(Js.a)(this,"center",void 0),Object(Js.a)(this,"halfAxes",void 0),this.center=(new Cs).from(e),this.halfAxes=new Ph(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new Cs(e).len(),new Cs(t).len(),new Cs(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),n=new Cs(e).normalize(),i=new Cs(t).normalize(),a=new Cs(r).normalize();return(new op).fromMatrix3(new Ph([...n,...i,...a]))}fromCenterHalfSizeQuaternion(e,t,r){const n=new op(r),i=(new Ph).fromQuaternion(n);return i[0]=i[0]*t[0],i[1]=i[1]*t[0],i[2]=i[2]*t[0],i[3]=i[3]*t[1],i[4]=i[4]*t[1],i[5]=i[5]*t[1],i[6]=i[6]*t[2],i[7]=i[7]*t[2],i[8]=i[8]*t[2],this.center=(new Cs).from(e),this.halfAxes=i,this}clone(){return new xp(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Th){const t=this.halfAxes,r=t.getColumn(0,cp),n=t.getColumn(1,lp),i=t.getColumn(2,hp),a=sp.copy(r).add(n).add(i);return e.center.copy(this.center),e.radius=a.magnitude(),e}intersectPlane(e){const t=this.center,r=e.normal,n=this.halfAxes,i=r.x,a=r.y,o=r.z,s=Math.abs(i*n[dp]+a*n[mp]+o*n[gp])+Math.abs(i*n[yp]+a*n[bp]+o*n[vp])+Math.abs(i*n[wp]+a*n[_p]+o*n[kp]),u=r.dot(t)+e.distance;return u<=-s?Eh:u>=s?Ah:Sh}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=up.from(e).subtract(this.center),r=this.halfAxes,n=r.getColumn(0,cp),i=r.getColumn(1,lp),a=r.getColumn(2,hp),o=n.magnitude(),s=i.magnitude(),u=a.magnitude();n.normalize(),i.normalize(),a.normalize();let c,l=0;return c=Math.abs(t.dot(n))-o,c>0&&(l+=c*c),c=Math.abs(t.dot(i))-s,c>0&&(l+=c*c),c=Math.abs(t.dot(a))-u,c>0&&(l+=c*c),l}computePlaneDistances(e,t,r=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const a=this.center,o=this.halfAxes,s=o.getColumn(0,cp),u=o.getColumn(1,lp),c=o.getColumn(2,hp),l=pp.copy(s).add(u).add(c).add(a),h=fp.copy(l).subtract(e);let p=t.dot(h);return n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).add(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).subtract(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).subtract(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).add(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).add(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).subtract(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).subtract(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),r[0]=n,r[1]=i,r}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,cp);t.transformAsPoint(e);const r=this.halfAxes.getColumn(1,lp);r.transformAsPoint(e);const n=this.halfAxes.getColumn(2,hp);return n.transformAsPoint(e),this.halfAxes=new Ph([...t,...r,...n]),this}getTransform(){throw new Error("not implemented")}}const Ep=new Cs,Sp=new Cs;class Ap{constructor(e=[0,0,1],t=0){Object(Js.a)(this,"normal",void 0),Object(Js.a)(this,"distance",void 0),this.normal=new Cs,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Qo(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Ep.from(e),this.normal.from(t).normalize();const r=-this.normal.dot(e);return this.distance=r,this}fromCoefficients(e,t,r,n){return this.normal.set(e,t,r),Qo(as(this.normal.len(),1)),this.distance=n,this}clone(){return new Ap(this.normal,this.distance)}equals(e){return as(this.distance,e.distance)&&as(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Sp.copy(this.normal).transformAsVector(e).normalize(),r=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(r,t)}projectPointOntoPlane(e,t=[0,0,0]){e=Ep.from(e);const r=this.getPointDistance(e),n=Sp.copy(this.normal).scale(r);return e.subtract(n).to(t)}}const jp=[new Cs([1,0,0]),new Cs([0,1,0]),new Cs([0,0,1])],Cp=new Cs,Tp=new Cs;new Ap(new Cs(1,0,0),0);class Bp{constructor(e=[]){Object(Js.a)(this,"planes",void 0),this.planes=e}fromBoundingSphere(e){this.planes.length=2*jp.length;const t=e.center,r=e.radius;let n=0;for(const e of jp){let i=this.planes[n],a=this.planes[n+1];i||(i=this.planes[n]=new Ap),a||(a=this.planes[n+1]=new Ap);const o=Cp.copy(e).scale(-r).add(t);e.dot(o);i.fromPointNormal(o,e);const s=Cp.copy(e).scale(r).add(t),u=Tp.copy(e).negate();u.dot(s);a.fromPointNormal(s,u),n+=2}return this}computeVisibility(e){let t=Ah;for(const r of this.planes){switch(e.intersectPlane(r)){case Eh:return Eh;case Sh:t=Sh}}return t}computeVisibilityWithPlaneMask(e,t){if(Qo(Number.isFinite(t),"parentPlaneMask is required."),t===Bp.MASK_OUTSIDE||t===Bp.MASK_INSIDE)return t;let r=Bp.MASK_INSIDE;const n=this.planes;for(let i=0;i<this.planes.length;++i){const a=i<31?1<<i:0;if(i<31&&0==(t&a))continue;const o=n[i],s=e.intersectPlane(o);if(s===Eh)return Bp.MASK_OUTSIDE;s===Sh&&(r|=a)}return r}}Object(Js.a)(Bp,"MASK_OUTSIDE",4294967295),Object(Js.a)(Bp,"MASK_INSIDE",0),Object(Js.a)(Bp,"MASK_INDETERMINATE",2147483647);new Cs,new Cs,new Cs,new Cs,new Cs;class Rp extends ls{constructor(e=0,t=0){super(2),es(e)&&1===arguments.length?this.copy(e):(Xo.debug&&(us(e),us(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Ds(this,this,e),this.check()}transformAsVector(e){return xs(this,this,e),this.check()}transformByMatrix3(e){return Ps(this,this,e),this.check()}transformByMatrix2x3(e){return function(e,t,r){var n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){var n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i}(this,this,e),this.check()}}const Op=new Cs,Ip=new Cs,Pp=new Cs,Dp=new Cs,Mp=new Cs,Fp=new Cs,Lp=new Cs,Np=new Cs,zp=new Cs,Up=new Cs,qp=new Cs,Hp=new Cs;Math.PI;const Gp=new Ph,Wp=new Ph,Vp=new Ph,Kp=new Ph,Jp=new Ph;function Qp(e,t={}){const r=Xs;let n=0,i=0;const a=Wp,o=Vp;a.identity(),o.copy(e);const s=r*function(e){let t=0;for(let r=0;r<9;++r){const n=e[r];t+=n*n}return Math.sqrt(t)}(o);for(;i<10&&Xp(o)>s;)Zp(o,Kp),Jp.copy(Kp).transpose(),o.multiplyRight(Kp),o.multiplyLeft(Jp),a.multiplyRight(Kp),++n>2&&(++i,n=0);return t.unitary=a.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const $p=[1,0,0],Yp=[2,2,1];function Xp(e){let t=0;for(let r=0;r<3;++r){const n=e[Gp.getElementIndex(Yp[r],$p[r])];t+=2*n*n}return Math.sqrt(t)}function Zp(e,t){const r=Ys;let n=0,i=1;for(let t=0;t<3;++t){const r=Math.abs(e[Gp.getElementIndex(Yp[t],$p[t])]);r>n&&(i=t,n=r)}const a=$p[i],o=Yp[i];let s=1,u=0;if(Math.abs(e[Gp.getElementIndex(o,a)])>r){const t=(e[Gp.getElementIndex(o,o)]-e[Gp.getElementIndex(a,a)])/2/e[Gp.getElementIndex(o,a)];let r;r=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),s=1/Math.sqrt(1+r*r),u=r*s}return Ph.IDENTITY.to(t),t[Gp.getElementIndex(a,a)]=t[Gp.getElementIndex(o,o)]=s,t[Gp.getElementIndex(o,a)]=u,t[Gp.getElementIndex(a,o)]=-u,t}const ef=new Cs,tf=new Cs,rf=new Cs,nf=new Cs,af=new Cs,of=new Ph,sf={diagonal:new Ph,unitary:new Ph};const uf=0,cf=1,lf=3,hf=4,pf=5,ff=1,df=2,mf="empty",gf="scenegraph",yf="pointcloud",bf="mesh",vf="I3S",wf="TILES3D",_f="geometricError",kf=1;async function xf(e){return JSON.parse((new TextDecoder).decode(e))}const Ef={name:"I3S Node Page",id:"i3s-node-page",module:"i3s",version:"3.3.0",mimeTypes:["application/json"],parse:async function(e){return e=xf(e)},extensions:["json"],options:{}};function Sf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Af{constructor(e,t){var r,n;Sf(this,"tileset",void 0),Sf(this,"nodePages",[]),Sf(this,"pendingNodePages",[]),Sf(this,"nodesPerPage",void 0),Sf(this,"options",void 0),Sf(this,"lodSelectionMetricType",void 0),Sf(this,"textureDefinitionsSelectedFormats",[]),Sf(this,"nodesInNodePages",void 0),Sf(this,"textureLoaderOptions",{}),this.tileset={...e},this.nodesPerPage=(null===(r=e.nodePages)||void 0===r?void 0:r.nodesPerPage)||64,this.lodSelectionMetricType=null===(n=e.nodePages)||void 0===n?void 0:n.lodSelectionMetricType,this.options=t,this.nodesInNodePages=0,this.initSelectedFormatsForTextureDefinitions(e)}async getNodeById(e){const t=Math.floor(e/this.nodesPerPage);if(!this.nodePages[t]&&!this.pendingNodePages[t]){var r;const e=eh(`${this.tileset.url}/nodepages/${t}`,null===(r=this.options.i3s)||void 0===r?void 0:r.token);this.pendingNodePages[t]={status:"Pending",promise:Jo(e,Ef,this.options)},this.nodePages[t]=await this.pendingNodePages[t].promise,this.nodesInNodePages+=this.nodePages[t].nodes.length,this.pendingNodePages[t].status="Done"}"Pending"===this.pendingNodePages[t].status&&(this.nodePages[t]=await this.pendingNodePages[t].promise);const n=e%this.nodesPerPage;return this.nodePages[t].nodes[n]}async formTileFromNodePages(e){const t=await this.getNodeById(e),r=[],n=[];for(const e of t.children||[])n.push(this.getNodeById(e));const i=await Promise.all(n);for(const e of i)r.push({id:e.index.toString(),obb:e.obb});let a,o,s,u="jpg",c=[],l=!1;if(t&&t.mesh){const{url:e,isDracoGeometry:r}=t.mesh.geometry&&this.getContentUrl(t.mesh.geometry)||{isDracoGeometry:!1};a=e,l=r;const{textureData:n,materialDefinition:i}=this.getInformationFromMaterial(t.mesh.material);s=i,u=n.format||u,n.name&&(o=`${this.tileset.url}/nodes/${t.mesh.material.resource}/textures/${n.name}`),this.tileset.attributeStorageInfo&&(c=function(e,t){const r=[],{attributeStorageInfo:n,url:i}=e;for(let e=0;e<n.length;e++){const a=n[e].key;r.push(`${i}/nodes/${t}/attributes/${a}/0`)}return r}(this.tileset,t.mesh.attribute.resource))}const h=this.getLodSelection(t);return jf({id:e.toString(),lodSelection:h,obb:t.obb,contentUrl:a,textureUrl:o,attributeUrls:c,materialDefinition:s,textureFormat:u,textureLoaderOptions:this.textureLoaderOptions,children:r,isDracoGeometry:l})}getContentUrl(e){let t=null;const r=this.tileset.geometryDefinitions[e.definition];let n=-1;if(this.options.i3s&&this.options.i3s.useDracoGeometry&&(n=r.geometryBuffers.findIndex(e=>e.compressedAttributes&&"draco"===e.compressedAttributes.encoding)),-1===n&&(n=r.geometryBuffers.findIndex(e=>!e.compressedAttributes)),-1!==n){const i=Boolean(r.geometryBuffers[n].compressedAttributes);t={url:`${this.tileset.url}/nodes/${e.resource}/geometries/${n}`,isDracoGeometry:i}}return t}getLodSelection(e){const t=[];return"maxScreenThresholdSQ"===this.lodSelectionMetricType&&t.push({metricType:"maxScreenThreshold",maxError:Math.sqrt(e.lodThreshold/(.25*Math.PI))}),t.push({metricType:this.lodSelectionMetricType,maxError:e.lodThreshold}),t}getInformationFromMaterial(e){const t={textureData:{name:null}};if(e){var r;const a=null===(r=this.tileset.materialDefinitions)||void 0===r?void 0:r[e.definition];if(a){var n,i;t.materialDefinition=a;const e=null==a||null===(n=a.pbrMetallicRoughness)||void 0===n||null===(i=n.baseColorTexture)||void 0===i?void 0:i.textureSetDefinitionId;"number"==typeof e&&(t.textureData=this.textureDefinitionsSelectedFormats[e]||t.textureData)}}return t}initSelectedFormatsForTextureDefinitions(e){this.textureDefinitionsSelectedFormats=[];const t=this.getSupportedTextureFormats(),r=e.textureSetDefinitions||[];for(const e of r){const r=e&&e.formats||[];let n=null;for(const e of t){const t=r.find(t=>t.format===e);if(t){n=t;break}}n&&"ktx2"===n.format&&(this.textureLoaderOptions.basis={format:Kl(),containerFormat:"ktx2",module:"encoder"}),this.textureDefinitionsSelectedFormats.push(n)}}getSupportedTextureFormats(){const e=[];if(!this.options.i3s||this.options.i3s.useCompressedTextures){const t=Nl();t.has("etc2")&&e.push("ktx-etc2"),t.has("dxt")&&e.push("dds"),e.push("ktx2")}return e.push("jpg"),e.push("png"),e}}function jf(e){var t,r;const n={};let i=[0,0,0,1];if(e.mbs)i=e.mbs,n.sphere=[...vu.WGS84.cartographicToCartesian(e.mbs.slice(0,3)),e.mbs[3]];else if(e.obb){n.box=[...vu.WGS84.cartographicToCartesian(e.obb.center),...e.obb.halfSize,...e.obb.quaternion];const t=(new xp).fromCenterHalfSizeQuaternion(n.box.slice(0,3),e.obb.halfSize,e.obb.quaternion).getBoundingSphere();n.sphere=[...t.center,t.radius],i=[...e.obb.center,t.radius]}const a=null===(t=e.lodSelection)||void 0===t?void 0:t[0].metricType,o=null===(r=e.lodSelection)||void 0===r?void 0:r[0].maxError,s=e.transform,u=bf,c=df;return{...e,mbs:i,boundingVolume:n,lodMetricType:a,lodMetricValue:o,transformMatrix:s,type:u,refine:c}}const Cf=/layers\/[0-9]+$/,Tf=/nodes\/([0-9-]+|root)$/,Bf={name:"I3S (Indexed Scene Layers)",id:"i3s",module:"i3s",version:"3.3.0",mimeTypes:["application/octet-stream"],parse:async function(e,t={},r){const n=r.url;t.i3s=t.i3s||{};if("504b0304"===function(e){if(e instanceof ArrayBuffer)return[...new Uint8Array(e,0,4)].map(e=>e.toString(16).padStart(2,"0")).join("");return null}(e))throw new Error("Files with .slpk extention currently are not supported by I3SLoader");let i,a;i="auto"===t.i3s.isTileset?Cf.test(n):t.i3s.isTileset;a="auto"===t.isTileHeader?Tf.test(n):t.i3s.isTileHeader;e=i?await async function(e,t,r){const n=JSON.parse((new TextDecoder).decode(e));if("PointCloud"===(null==n?void 0:n.layerType))throw new Error("Point Cloud layers currently are not supported by I3SLoader");return n.loader=Bf,await async function(e,t,r){if(e.url=r.url,e.nodePages)e.nodePagesTile=new Af(e,t),e.root=e.nodePagesTile.formTileFromNodePages(0);else{var n;const r=eh(e.url+"/nodes/root",null===(n=t.i3s)||void 0===n?void 0:n.token);e.root=await Jo(r,e.loader,{...t,i3s:{...t.i3s,loadContent:!1,isTileHeader:!0,isTileset:!1}})}e.basePath=e.url,e.type=vf,e.lodMetricType=e.root.lodMetricType,e.lodMetricValue=e.root.lodMetricValue}(n,t,r),n}(e,t,r):a?await async function(e,t){return function(e,t){const r=t.url||"";let n,i,a;return e.geometryData&&(n=`${r}/${e.geometryData[0].href}`),e.textureData&&(i=`${r}/${e.textureData[0].href}`),e.attributeData&&(a=function(e,t){const{attributeData:r=[]}=t,n=[];for(let t=0;t<r.length;t++){const i=r[t].href.replace("./","");n.push(`${e}/${i}`)}return n}(r,e)),jf({...e,url:r,contentUrl:n,textureUrl:i,attributeUrls:a,isDracoGeometry:!1})}(e=JSON.parse((new TextDecoder).decode(e)),t)}(e,r):await async function(e,t){return await Ko(e,xh,t)}(e,t);return e},extensions:["bin"],options:{i3s:{token:null,isTileset:"auto",isTileHeader:"auto",tile:null,tileset:null,_tileOptions:null,_tilesetOptions:null,useDracoGeometry:!0,useCompressedTextures:!0,decodeTextures:!0,coordinateSystem:ch.METER_OFFSETS,colorsByAttribute:null}}};function Rf(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Of{constructor(e,t){Object(Js.a)(this,"name",void 0),Object(Js.a)(this,"type",void 0),Object(Js.a)(this,"sampleSize",1),Object(Js.a)(this,"time",void 0),Object(Js.a)(this,"count",void 0),Object(Js.a)(this,"samples",void 0),Object(Js.a)(this,"lastTiming",void 0),Object(Js.a)(this,"lastSampleTime",void 0),Object(Js.a)(this,"lastSampleCount",void 0),Object(Js.a)(this,"_count",0),Object(Js.a)(this,"_time",0),Object(Js.a)(this,"_samples",0),Object(Js.a)(this,"_startTime",0),Object(Js.a)(this,"_timerPending",!1),this.name=e,this.type=t,this.reset()}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Rf(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Rf()-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}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}_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)}}class If{constructor(e){Object(Js.a)(this,"id",void 0),Object(Js.a)(this,"stats",{}),this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e in this.stats)this.stats[e].reset();return this}forEach(e){for(const t in this.stats)e(this.stats[t])}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(e){if(!e||!e.name)return null;const{name:t,type:r}=e;return this.stats[t]||(this.stats[t]=e instanceof Of?e:new Of(t,r)),this.stats[t]}}function Pf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Df={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class Mf{constructor(e={}){Pf(this,"props",void 0),Pf(this,"stats",void 0),Pf(this,"activeRequestCount",0),Pf(this,"requestQueue",[]),Pf(this,"requestMap",new Map),Pf(this,"deferredUpdate",null),this.props={...Df,...e},this.stats=new If({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const r={handle:e,priority:0,getPriority:t},n=new Promise(e=>(r.resolve=e,r));return this.requestQueue.push(r),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:r}=e;let n=!1;const i=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({done:i}):Promise.resolve({done:i})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const r=e[t];this._updateRequest(r)||(e.splice(t,1),this.requestMap.delete(r.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}function Ff(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Lf{constructor(e,t,r){Ff(this,"item",void 0),Ff(this,"previous",void 0),Ff(this,"next",void 0),this.item=e,this.previous=t,this.next=r}}function Nf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class zf{constructor(){Nf(this,"head",null),Nf(this,"tail",null),Nf(this,"_length",0)}get length(){return this._length}add(e){const t=new Lf(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const r=e.next;e.next=t,this.tail===e?this.tail=t:r.previous=t,t.next=r,t.previous=e,++this._length}}function Uf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qf(e){return null!=e}class Hf{constructor(){Uf(this,"_list",void 0),Uf(this,"_sentinel",void 0),Uf(this,"_trimTiles",void 0),this._list=new zf,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;qf(t)&&this._list.splice(this._sentinel,t)}add(e,t,r){qf(t._cacheNode)||(t._cacheNode=this._list.add(t),r&&r(e,t))}unloadTile(e,t,r){const n=t._cacheNode;qf(n)&&(this._list.remove(n),t._cacheNode=void 0,r&&r(e,t))}unloadTiles(e,t){const r=this._trimTiles;this._trimTiles=!1;const n=this._list,i=1024*e.maximumMemoryUsage*1024,a=this._sentinel;let o=n.head;for(;o!==a&&(e.gpuMemoryUsageInBytes>i||r);){const r=o.item;o=o.next,this.unloadTile(e,r,t)}}trim(){this._trimTiles=!0}}const Gf=new Cs,Wf=new Cs,Vf=new Bp([new Ap,new Ap,new Ap,new Ap,new Ap,new Ap]);function Kf(e,t){const{cameraDirection:r,cameraUp:n,height:i}=e,{metersPerUnit:a}=e.distanceScales,o=Qf(e,e.center),s=vu.WGS84.eastNorthUpToFixedFrame(o),u=e.unprojectPosition(e.cameraPosition),c=vu.WGS84.cartographicToCartesian(u,new Cs),l=new Cs(s.transformAsVector(new Cs(r).scale(a))).normalize(),h=new Cs(s.transformAsVector(new Cs(n).scale(a))).normalize();!function(e){const t=e.getFrustumPlanes(),r=Jf(t.near,e.cameraPosition),n=Qf(e,r),i=Qf(e,e.cameraPosition,Wf);let a=0;Vf.planes[a++].fromPointNormal(n,Gf.copy(n).subtract(i));for(const i in t){if("near"===i)continue;const o=Jf(t[i],r,Wf),s=Qf(e,o,Wf);Vf.planes[a++].fromPointNormal(s,Gf.copy(n).subtract(s))}}(e);const p=e.constructor,{longitude:f,latitude:d,width:m,bearing:g,zoom:y}=e;return{camera:{position:c,direction:l,up:h},viewport:e,topDownViewport:new p({longitude:f,latitude:d,height:i,width:m,bearing:g,zoom:y,pitch:0}),height:i,cullingVolume:Vf,frameNumber:t,sseDenominator:1.15}}function Jf(e,t,r=new Cs){const n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function Qf(e,t,r=new Cs){const n=e.unprojectPosition(t);return vu.WGS84.cartographicToCartesian(n,r)}const $f=new Cs;function Yf(e,t){if(e instanceof xp){const{halfAxes:r}=e,n=function(e){e.getColumn(0,$f);const t=e.getColumn(1),r=e.getColumn(2),n=$f.add(t).add(r);return n.len()}(r);return Math.log2(6356752.314245179/(n+t[2]))}if(e instanceof Th){const{radius:r}=e;return Math.log2(6356752.314245179/(r+t[2]))}if(e.width&&e.height){const{width:t,height:r}=e;return(Math.log2(6378137/t)+Math.log2(6378137/r))/2}return 1}function Xf(e,t,r){const n=vu.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],new Cs),i=Math.sqrt(Math.pow(n[0]-r[0],2)+Math.pow(n[1]-r[1],2)+Math.pow(n[2]-r[2],2));return Math.log2(6356752.314245179/(i+t[2]))}function Zf(e){return null!=e}const ed=new Cs,td=new Cs,rd=new Cs;function nd(e,t,r){if(ia(e,"3D Tile: boundingVolume must be defined"),e.box)return function(e,t,r){const n=new Cs(e[0],e[1],e[2]);t.transform(n,n);let i=[];if(10===e.length){const t=e.slice(3,6),r=new op;r.fromArray(e,6);const n=new Cs([1,0,0]),a=new Cs([0,1,0]),o=new Cs([0,0,1]);n.transformByQuaternion(r),n.scale(t[0]),a.transformByQuaternion(r),a.scale(t[1]),o.transformByQuaternion(r),o.scale(t[2]),i=[...n.toArray(),...a.toArray(),...o.toArray()]}else i=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const a=t.transformAsVector(i.slice(0,3)),o=t.transformAsVector(i.slice(3,6)),s=t.transformAsVector(i.slice(6,9)),u=new Ph([a[0],a[1],a[2],o[0],o[1],o[2],s[0],s[1],s[2]]);if(Zf(r))return r.center=n,r.halfAxes=u,r;return new xp(n,u)}(e.box,t,r);if(e.region){const[t,r,n,i,a,o]=e.region,s=vu.WGS84.cartographicToCartesian([ns(t),ns(i),a],td),u=vu.WGS84.cartographicToCartesian([ns(n),ns(r),o],rd),c=(new Cs).addVectors(s,u).multiplyScalar(.5),l=(new Cs).subVectors(s,u).len()/2;return id([c[0],c[1],c[2],l],new Gs)}if(e.sphere)return id(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function id(e,t,r){const n=new Cs(e[0],e[1],e[2]);t.transform(n,n);const i=t.getScale(ed),a=Math.max(Math.max(i[0],i[1]),i[2]),o=e[3]*a;return Zf(r)?(r.center=n,r.radius=o,r):new Th(n,o)}new Cs,new Cs,new Gs,new Cs,new Cs,new Cs;function ad(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const r=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return function(e,t){const r=e*t;return 1-Math.exp(-r*r)}(t,r)*n}return 0}const od=new Cs,sd=new Cs,ud=new Cs,cd=new Cs,ld=new Cs,hd=new Gs,pd=new Gs;function fd(e,t){const{topDownViewport:r}=t,n=e.header.mbs[1],i=e.header.mbs[0],a=e.header.mbs[2],o=e.header.mbs[3],s=[...e.boundingVolume.center],u=r.unprojectPosition(r.cameraPosition);vu.WGS84.cartographicToCartesian(u,od),sd.copy(od).subtract(s).normalize(),vu.WGS84.eastNorthUpToFixedFrame(s,hd),pd.copy(hd).invert(),ud.copy(od).transform(pd);const c=Math.sqrt(ud[0]*ud[0]+ud[1]*ud[1]),l=c*c/ud[2];cd.copy([ud[0],ud[1],l]);const h=cd.transform(hd).subtract(s).normalize(),p=sd.cross(h).normalize().scale(o).add(s),f=vu.WGS84.cartesianToCartographic(p),d=r.project([i,n,a]),m=r.project(f);return ld.copy(d).subtract(m).magnitude()}function dd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class md{constructor(e=0){dd(this,"_map",new Map),dd(this,"_array",void 0),dd(this,"_length",void 0),this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return ia(e<this._array.length),this._array[e]}set(e,t){ia(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){ia(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){ia(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}function gd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const yd={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class bd{traversalFinished(e){return!0}constructor(e){gd(this,"options",void 0),gd(this,"root",void 0),gd(this,"requestedTiles",void 0),gd(this,"selectedTiles",void 0),gd(this,"emptyTiles",void 0),gd(this,"lastUpdate",(new Date).getTime()),gd(this,"updateDebounceTime",1e3),gd(this,"_traversalStack",void 0),gd(this,"_emptyTraversalStack",void 0),gd(this,"_frameNumber",void 0),this.options={...yd,...e},this._traversalStack=new md,this._emptyTraversalStack=new md,this._frameNumber=null,this.root=null,this.selectedTiles={},this.requestedTiles={},this.emptyTiles={}}traverse(e,t,r){this.root=e,this.options={...this.options,...r},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const r=this._traversalStack;for(e._selectionDepth=1,r.push(e);r.length>0;){const e=r.pop();let n=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),n=this.updateAndPushChildren(e,t,r,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const i=e.parent,a=Boolean(!i||i._shouldRefine),o=!n;e.hasRenderContent?e.refine===ff?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===df&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=n&&a}const n=(new Date).getTime();(this.traversalFinished(t)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const r=e.children;for(const e of r)this.updateTile(e,t);return!0}updateAndPushChildren(e,t,r,n){const{loadSiblings:i,skipLevelOfDetail:a}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const s=e.refine===df&&e.hasRenderContent&&!a;let u=!1,c=!0;for(const e of o)if(e._selectionDepth=n,e.isVisibleAndInRequestVolume?(r.find(e)&&r.delete(e),r.push(e),u=!0):(s||i)&&(this.loadTile(e,t),this.touchTile(e,t)),s){let r;if(r=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&r,!c)return!1}return u||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t,r=!1,n=!1){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:!(!n&&!e.isVisibleAndInRequestVolume)&&this.shouldRefine(e,t,r))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,r){let n=e._screenSpaceError;return r&&(n=e.getScreenSpaceError(t,!0)),n>this.options.maximumScreenSpaceError}updateTileVisibility(e,t){const r=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&r.push(e)}else r.push(t.viewport.id);e.updateVisibility(t,r)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let r=!1;for(const n of e.children)n.updateVisibility(t),r=r||n.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(e,t){let r=!0;const n=this._emptyTraversalStack;for(n.push(e);n.length>0&&r;){const e=n.pop();this.updateTile(e,t),e.isVisibleAndInRequestVolume||this.loadTile(e,t),this.touchTile(e,t);if(!e.hasRenderContent&&this.canTraverse(e,t,!1,!0)){const t=e.children;for(const e of t)n.find(e)&&n.delete(e),n.push(e)}else e.contentAvailable||(r=!1)}return r}}function vd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const wd=new Cs;class _d{constructor(e,t,r,n=""){vd(this,"tileset",void 0),vd(this,"header",void 0),vd(this,"id",void 0),vd(this,"url",void 0),vd(this,"parent",void 0),vd(this,"refine",void 0),vd(this,"type",void 0),vd(this,"contentUrl",void 0),vd(this,"lodMetricType",void 0),vd(this,"lodMetricValue",void 0),vd(this,"boundingVolume",void 0),vd(this,"content",void 0),vd(this,"contentState",void 0),vd(this,"gpuMemoryUsageInBytes",void 0),vd(this,"children",void 0),vd(this,"depth",void 0),vd(this,"viewportIds",void 0),vd(this,"transform",void 0),vd(this,"extensions",void 0),vd(this,"implicitTiling",void 0),vd(this,"userData",void 0),vd(this,"computedTransform",void 0),vd(this,"hasEmptyContent",void 0),vd(this,"hasTilesetContent",void 0),vd(this,"traverser",void 0),vd(this,"_cacheNode",void 0),vd(this,"_frameNumber",void 0),vd(this,"_lodJudge",void 0),vd(this,"_expireDate",void 0),vd(this,"_expiredContent",void 0),vd(this,"_shouldRefine",void 0),vd(this,"_distanceToCamera",void 0),vd(this,"_centerZDepth",void 0),vd(this,"_screenSpaceError",void 0),vd(this,"_visibilityPlaneMask",void 0),vd(this,"_visible",void 0),vd(this,"_inRequestVolume",void 0),vd(this,"_stackLength",void 0),vd(this,"_selectionDepth",void 0),vd(this,"_touchedFrame",void 0),vd(this,"_visitedFrame",void 0),vd(this,"_selectedFrame",void 0),vd(this,"_requestedFrame",void 0),vd(this,"_priority",void 0),vd(this,"_contentBoundingVolume",void 0),vd(this,"_viewerRequestVolume",void 0),vd(this,"_initialTransform",void 0),this.header=t,this.tileset=e,this.id=n||t.id,this.url=t.url,this.parent=r,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this.lodMetricType="geometricError",this.lodMetricValue=0,this.boundingVolume=null,this.content=null,this.contentState=uf,this.gpuMemoryUsageInBytes=0,this.children=[],this.hasEmptyContent=!1,this.hasTilesetContent=!1,this.depth=0,this.viewportIds=[],this.userData={},this.extensions=null,this._priority=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._screenSpaceError=0,this._cacheNode=null,this._frameNumber=null,this._cacheNode=null,this.traverser=new bd({}),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._initialTransform=new Gs,this.transform=new Gs,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),this._lodJudge=null,this._expireDate=null,this._expiredContent=null,this.implicitTiling=null,Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}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===lf||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===uf}get contentExpired(){return this.contentState===hf}get contentFailed(){return this.contentState===pf}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}getScreenSpaceError(e,t){switch(this.tileset.type){case vf:return fd(this,e);case wf:return function(e,t,r){const n=e.tileset,i=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,a=r?i:e.lodMetricValue;if(0===a)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:s,sseDenominator:u}=t,{viewDistanceScale:c}=n.options;let l=a*s*(c||1)/(o*u);return l-=ad(n,o),l}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,r=this.refine===ff||t;if(r&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===uf)return-1;const n=this.parent,i=n&&(!r||0===this._screenSpaceError||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,a=e.root?e.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=cf;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=uf,!1;try{const t=this.tileset.getTileUrl(this.contentUrl),r=this.tileset.loader,n={...this.tileset.loadOptions,[r.id]:{...this.tileset.loadOptions[r.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(r.id)}};return this.content=await Jo(t,r,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=lf,this._onContentLoaded(),!0}catch(e){throw this.contentState=pf,e}finally{e.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=uf,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const r=this.parent,n=r?r._visibilityPlaneMask:Bp.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==Bp.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:r}=e,{boundingVolume:n}=this;return r.computeVisibilityWithPlaneMask(n,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return wd.subVectors(t.center,e.position),e.direction.dot(wd)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=hf,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.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 e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new Gs(e.transform):new Gs;const t=this.parent,r=this.tileset,n=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new Gs(n).multiplyRight(this.transform);const i=t&&t._initialTransform?t._initialTransform.clone():new Gs;this._initialTransform=new Gs(i).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=uf,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Bp.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(e){return e||this.parent&&this.parent.refine||df}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()&&(this.hasTilesetContent=!0)}_updateBoundingVolume(e){this.boundingVolume=nd(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=nd(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=nd(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new Gs){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){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{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"}}var t}}class kd extends bd{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const r=e.children.length>0;if(e.hasTilesetContent&&r){const r=e.children[0];return this.updateTileVisibility(r,t),void(e._visible=r._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const n=e.refine===df,i=e._optimChildrenWithinParent===kf;n&&i&&r&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:r}=e;return!(!r||r.hasTilesetContent||r.refine!==ff)&&!this.shouldRefine(e,t,!0)}}class xd{constructor(){var e,t,r;e=this,t="frameNumberMap",r=new Map,t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}register(e,t){const r=this.frameNumberMap.get(e)||new Map,n=r.get(t)||0;r.set(t,n+1),this.frameNumberMap.set(e,r)}deregister(e,t){const r=this.frameNumberMap.get(e);if(!r)return;const n=r.get(t)||1;r.set(t,n-1)}isZero(e,t){var r;return 0===((null===(r=this.frameNumberMap.get(e))||void 0===r?void 0:r.get(t))||0)}}function Ed(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Sd="REQUESTED",Ad="COMPLETED",jd="ERROR";class Cd{constructor(){Ed(this,"_statusMap",void 0),Ed(this,"pendingTilesRegister",new xd),this._statusMap={}}add(e,t,r,n){if(!this._statusMap[t]){const{frameNumber:i,viewport:{id:a}}=n;this._statusMap[t]={request:e,callback:r,key:t,frameState:n,status:Sd},this.pendingTilesRegister.register(a,i),e().then(e=>{this._statusMap[t].status=Ad;const{frameNumber:r,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,r),this._statusMap[t].callback(e,n)}).catch(e=>{this._statusMap[t].status=jd;const{frameNumber:n,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,n),r(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:r,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,r);const{frameNumber:i,viewport:{id:a}}=t;this.pendingTilesRegister.register(a,i),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class Td extends bd{constructor(e){var t,r,n;super(e),n=void 0,(r="_tileManager")in(t=this)?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,this._tileManager=new Cd}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const r=2*fd(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const r=e.header.children||[],n=e.children,i=e.tileset;for(const a of r){const r=`${a.id}-${t.viewport.id}`,o=n&&n.find(e=>e.id===r);if(o)o&&this.updateTile(o,t);else{let n=()=>this._loadTile(a.id,i);this._tileManager.find(r)?this._tileManager.update(r,t):(i.tileset.nodePages&&(n=()=>i.tileset.nodePagesTile.formTileFromNodePages(a.id)),this._tileManager.add(n,r,t=>this._onTileLoad(t,e,r),t))}}return!1}async _loadTile(e,t){const{loader:r}=t,n=t.getTileUrl(`${t.url}/nodes/${e}`),i={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await Jo(n,r,i)}_onTileLoad(e,t,r){const n=new _d(t.tileset,e,t,r);t.children.push(n);const i=this._tileManager.find(n.id).frameState;this.updateTile(n,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,i)}}function Bd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Rd={description:"",ellipsoid:vu.WGS84,modelMatrix:new Gs,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},Od="Tiles In Tileset(s)";class Id{constructor(e,t){Bd(this,"options",void 0),Bd(this,"loadOptions",void 0),Bd(this,"type",void 0),Bd(this,"tileset",void 0),Bd(this,"loader",void 0),Bd(this,"url",void 0),Bd(this,"basePath",void 0),Bd(this,"modelMatrix",void 0),Bd(this,"ellipsoid",void 0),Bd(this,"lodMetricType",void 0),Bd(this,"lodMetricValue",void 0),Bd(this,"refine",void 0),Bd(this,"root",void 0),Bd(this,"roots",void 0),Bd(this,"asset",void 0),Bd(this,"description",void 0),Bd(this,"properties",void 0),Bd(this,"extras",void 0),Bd(this,"attributions",void 0),Bd(this,"credits",void 0),Bd(this,"stats",void 0),Bd(this,"contentFormats",{draco:!1,meshopt:!1,dds:!1,ktx2:!1}),Bd(this,"traverseCounter",void 0),Bd(this,"geometricError",void 0),Bd(this,"selectedTiles",void 0),Bd(this,"updatePromise",null),Bd(this,"tilesetInitializationPromise",void 0),Bd(this,"cartographicCenter",void 0),Bd(this,"cartesianCenter",void 0),Bd(this,"zoom",void 0),Bd(this,"boundingVolume",void 0),Bd(this,"gpuMemoryUsageInBytes",void 0),Bd(this,"dynamicScreenSpaceErrorComputedDensity",void 0),Bd(this,"_traverser",void 0),Bd(this,"_cache",void 0),Bd(this,"_requestScheduler",void 0),Bd(this,"_frameNumber",void 0),Bd(this,"_queryParamsString",void 0),Bd(this,"_queryParams",void 0),Bd(this,"_extensionsUsed",void 0),Bd(this,"_tiles",void 0),Bd(this,"_pendingCount",void 0),Bd(this,"lastUpdatedVieports",void 0),Bd(this,"_requestedTiles",void 0),Bd(this,"_emptyTiles",void 0),Bd(this,"frameStateData",void 0),Bd(this,"maximumMemoryUsage",void 0),ia(e),this.options={...Rd,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||n.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this.root=null,this.roots={},this.cartographicCenter=null,this.cartesianCenter=null,this.zoom=1,this.boundingVolume=null,this.traverseCounter=0,this.geometricError=0,this._traverser=this._initializeTraverser(),this._cache=new Hf,this._requestScheduler=new Mf({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this._frameNumber=0,this._pendingCount=0,this._tiles={},this.selectedTiles=[],this._emptyTiles=[],this._requestedTiles=[],this.frameStateData={},this.lastUpdatedVieports=null,this._queryParams={},this._queryParamsString="",this.maximumMemoryUsage=this.options.maximumMemoryUsage||32,this.gpuMemoryUsageInBytes=0,this.stats=new If({id:this.url}),this._initializeStats(),this._extensionsUsed=void 0,this.dynamicScreenSpaceErrorComputedDensity=0,this.extras=null,this.asset={},this.credits={},this.description=this.options.description||"",this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return this._queryParamsString||(this._queryParamsString=function(e){const t=[];for(const r of Object.keys(e))t.push(`${r}=${e[r]}`);switch(t.length){case 0:return"";case 1:return"?"+t[0];default:return"?"+t.join("&")}}(this._queryParams)),this._queryParamsString}setProps(e){this.options={...this.options,...e}}setOptions(e){this.options={...this.options,...e}}getTileUrl(e){return e.startsWith("data:")?e:`${e}${this.queryParams}`}hasExtension(e){return Boolean(this._extensionsUsed&&this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const r=[];for(const e of t){const t=e.id;this._needTraverse(t)?r.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!r.includes(t))continue;const n=Kf(e,this._frameNumber);this._traverser.traverse(this.roots[t],n,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const r=this.frameStateData[t],n=Object.values(this._traverser.selectedTiles),[i,a]=function(e,t,r){if(0===r||e.length<=r)return[e,[]];const n=[],{longitude:i,latitude:a}=t.viewport;for(const[t,r]of e.entries()){const[e,o]=r.header.mbs,s=Math.abs(i-e),u=Math.abs(a-o),c=Math.sqrt(u*u+s*s);n.push([t,c])}const o=n.sort((e,t)=>e[1]-t[1]),s=[];for(let t=0;t<r;t++)s.push(e[o[t][0]]);const u=[];for(let t=r;t<o.length;t++)u.push(e[o[t][0]]);return[s,u]}(n,e,this.options.maximumTilesSelected);r.selectedTiles=i;for(const e of a)e.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(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const r=new Set(e.map(e=>e.id)),n=new Set(t.map(e=>e.id));let i=e.filter(e=>!n.has(e.id)).length>0;return i=i||t.filter(e=>!r.has(e.id)).length>0,i}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const r of this.selectedTiles)r.contentAvailable&&r.content&&(e++,r.content.pointCount?t+=r.content.pointCount:t+=r.content.vertexCount);this.stats.get("Tiles In View").count=this.selectedTiles.length,this.stats.get("Tiles To Render").count=e,this.stats.get("Points/Vertices").count=t}async _initializeTileSet(e){this.type===vf&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===wf&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===vf&&this._initializeI3STileset()}calculateViewPropsI3S(){var e;const t=this.tileset.fullExtent;if(t){const{xmin:e,xmax:r,ymin:n,ymax:i,zmin:a,zmax:o}=t;return this.cartographicCenter=new Cs(e+(r-e)/2,n+(i-n)/2,a+(o-a)/2),this.cartesianCenter=vu.WGS84.cartographicToCartesian(this.cartographicCenter,new Cs),void(this.zoom=Xf(t,this.cartographicCenter,this.cartesianCenter))}const r=null===(e=this.tileset.store)||void 0===e?void 0:e.extent;if(r){const[e,t,n,i]=r;return this.cartographicCenter=new Cs(e+(n-e)/2,t+(i-t)/2,0),this.cartesianCenter=vu.WGS84.cartographicToCartesian(this.cartographicCenter,new Cs),void(this.zoom=function(e,t,r){const[n,i,a,o]=e;return Xf({xmin:n,xmax:a,ymin:i,ymax:o,zmin:0,zmax:0},t,r)}(r,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new Cs,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root;ia(e);const{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Cs,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?this.cartographicCenter=vu.WGS84.cartesianToCartographic(t,new Cs):this.cartographicCenter=new Cs(0,0,-vu.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=Yf(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Od),this.stats.get("Tiles Loading"),this.stats.get("Tiles In Memory"),this.stats.get("Tiles In View"),this.stats.get("Tiles To Render"),this.stats.get("Tiles Loaded"),this.stats.get("Tiles Unloaded"),this.stats.get("Failed Tile Loads"),this.stats.get("Points/Vertices"),this.stats.get("Tile Memory Use","memory")}_initializeTileHeaders(e,t){const r=new _d(this,e.root,t);if(t&&(t.children.push(r),r.depth=t.depth+1),this.type===wf){const e=[];for(e.push(r);e.length>0;){const t=e.pop();this.stats.get(Od).incrementCount();const r=t.header.children||[];for(const n of r){const r=new _d(this,n,t);t.children.push(r),r.depth=t.depth+1,e.push(r)}}}return r}_initializeTraverser(){let e;switch(this.type){case wf:e=kd;break;case vf:e=Td;break;default:e=bd}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t)}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get("Failed Tile Loads").incrementCount();const r=t.message||t.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${r}`),this.options.onTileError(e,r,n)}_onTileLoad(e,t){if(t){if(this.type===vf){var r,n;const e=(null===(r=this.tileset)||void 0===r||null===(n=r.nodePagesTile)||void 0===n?void 0:n.nodesInNodePages)||0;this.stats.get(Od).reset(),this.stats.get(Od).addCount(e)}e&&e.content&&function(e,t){ia(e),ia(t);const{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:i,boundingVolume:{center:a}}=e;let o=new Gs(i);switch(r&&o.translate(r),n){case"Z":break;case"Y":const e=(new Gs).rotateX(Math.PI/2);o=o.multiplyRight(e);break;case"X":const t=(new Gs).rotateY(-Math.PI/2);o=o.multiplyRight(t)}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const s=new Cs(a);t.cartesianModelMatrix=o,t.cartesianOrigin=s;const u=vu.WGS84.cartesianToCartographic(s,new Cs),c=vu.WGS84.eastNorthUpToFixedFrame(s).invert();t.cartographicModelMatrix=c.multiplyRight(o),t.cartographicOrigin=u,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===vf)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===wf){var t;const{extensionsRemoved:r=[]}=(null===(t=e.content)||void 0===t?void 0:t.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("Tiles Loading").incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get("Tiles Loading").decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get("Tiles Loaded").incrementCount(),this.stats.get("Tiles In Memory").incrementCount(),this.gpuMemoryUsageInBytes+=e.content.byteLength||0,this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.content&&e.content.byteLength||0,this.stats.get("Tiles In Memory").decrementCount(),this.stats.get("Tiles Unloaded").incrementCount(),this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const r of t.children)e.push(r);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,r=[];for(r.push(t);r.length>0;){e=r.pop();for(const t of e.children)r.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed,this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const Pd=[9,-18,-88,0,96,90,0,0,-60,-20,-9,18,8,0,-96,30,0,0,60,-20,9,-88,-18,90,96,0,-20,-60,0,0,186,-42,-42,-150,-96,-150,60,60,60,60,54,162,-78,30,-24,-90,-60,60,-60,60,-9,-32,18,30,24,0,20,-60,0,0,-9,8,18,30,-96,0,-20,60,0,0,54,-78,162,-90,-24,30,60,-60,60,-60,-54,78,78,90,144,90,-60,-60,-60,-60,9,-8,-18,-30,-24,0,20,60,0,0,-9,18,-32,0,24,30,0,0,-60,20,9,-18,-8,0,-24,-30,0,0,60,20],Dd=[0,0,-131,0,138,144,0,0,-102,-31,0,0,7,0,-138,42,0,0,102,-31,62,0,-31,0,0,-62,0,0,0,31,124,0,-62,0,0,-124,0,0,0,62,124,0,-62,0,0,-124,0,0,0,62,62,0,-31,0,0,-62,0,0,0,31,0,0,45,0,-183,-9,0,93,18,0,0,0,216,0,33,87,0,-93,12,-93,0,0,156,0,153,99,0,-93,-12,-93,0,0,-45,0,-3,9,0,93,-18,0,0,0,-55,0,48,42,0,0,-84,31,0,0,-7,0,-48,-42,0,0,84,31],Md=[18,-36,-122,0,120,135,0,0,-84,-31,-18,36,-2,0,-120,51,0,0,84,-31,36,-165,-27,93,147,-9,0,-93,18,0,210,45,-111,-93,-57,-192,0,93,12,93,162,141,-75,-93,-129,-180,0,93,-12,93,-36,-21,27,93,39,9,0,-93,-18,0,0,0,62,0,0,31,0,0,0,-31,0,0,124,0,0,62,0,0,0,-62,0,0,124,0,0,62,0,0,0,-62,0,0,62,0,0,31,0,0,0,-31,-18,36,-64,0,66,51,0,0,-102,31,18,-36,2,0,-66,-51,0,0,102,31];class Fd{constructor(e){Object(Js.a)(this,"_v00",0),Object(Js.a)(this,"_v01",0),Object(Js.a)(this,"_v10",0),Object(Js.a)(this,"_v11",0),Object(Js.a)(this,"_t",[]),Object(Js.a)(this,"_ix",void 0),Object(Js.a)(this,"_iy",void 0),Object(Js.a)(this,"options",void 0),this.options=e,this._ix=this.options._width,this._iy=this.options._height}getHeight(e,t){if(e=Math.abs(e)>90?NaN:e,isNaN(e)||isNaN(t))return NaN;const r=function(e,t){t=Math.abs(t);let r=Ld(e,t);2*Math.abs(r)===t?r-=Ld(e,2*t)-r:2*Math.abs(r)>t&&(r+=r<0?t:-t);return r}(t,360);let n=(t=-180!==r?r:180)*this.options._rlonres,i=-e*this.options._rlatres,a=Math.floor(n),o=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(i));n-=a,i-=o,o+=(this.options._height-1)/2,a+=a<0?this.options._width:a>=this.options._width?-this.options._width:0;let s=0,u=0,c=0,l=0,h=new Array(10);if(a!==this._ix||o!==this._iy)if(this.options.cubic){const e=[this._rawval(a,o-1),this._rawval(a+1,o-1),this._rawval(a-1,o),this._rawval(a,o),this._rawval(a+1,o),this._rawval(a+2,o),this._rawval(a-1,o+1),this._rawval(a,o+1),this._rawval(a+1,o+1),this._rawval(a+2,o+1),this._rawval(a,o+2),this._rawval(a+1,o+2)];let t=Dd;0!==o&&(t=o===this.options._height-2?Md:Pd);let r=372;0!==o&&(r=o===this.options._height-2?372:240);for(let n=0;n<10;++n){h[n]=0;for(let r=0;r<12;++r)h[n]+=e[r]*t[10*r+n];h[n]/=r}}else s=this._rawval(a,o),u=this._rawval(a+1,o),c=this._rawval(a,o+1),l=this._rawval(a+1,o+1);else this.options.cubic?h=this._t:(s=this._v00,u=this._v01,c=this._v10,l=this._v11);if(!this.options.cubic){const e=(1-i)*((1-n)*s+n*u)+i*((1-n)*c+n*l),t=this.options._offset+this.options._scale*e;return this._ix=a,this._iy=o,this._v00=s,this._v01=u,this._v10=c,this._v11=l,t}let p=h[0]+n*(h[1]+n*(h[3]+n*h[6]))+i*(h[2]+n*(h[4]+n*h[7])+i*(h[5]+n*h[8]+i*h[9]));return p=this.options._offset+this.options._scale*p,this._ix=a,this._iy=o,this._t=h,p}_rawval(e,t){e<0?e+=this.options._width:e>=this.options._width&&(e-=this.options._width),(t<0||t>=this.options._height)&&(t=t<0?-t:2*(this.options._height-1)-t,e+=(e<this.options._width/2?1:-1)*this.options._width/2);const r=this.options._datastart+2*(t*this.options._swidth+e);return this.options.data[r]<<8|this.options.data[r+1]}}function Ld(e,t){return e-Math.floor(e/t)*t}function Nd(e,t){const r=function*(e){let t=0;do{const r=e.indexOf(10,t);if(-1!==r){const n=e.subarray(t,r);t=r+1,yield{offset:t,line:zd(n)}}else{const r=e.subarray(t,e.length);t=e.length,yield{offset:t,line:zd(r)}}}while(t<e.length);return{offset:t,line:""}}(e);let n=r.next();if(n.done||"P5"!==n.value.line)throw new Error("Geoid model file: File not in PGM format");let i=Number.MAX_VALUE,a=0,o=-1,s=-1,u="NONE",c="UNKNOWN",l=0,h=0,p=null,f=null;do{n=r.next();const e=n.value.line;if(e.length){if("#"!==e[0]){let t=e.split(" ");if(t=t.filter(e=>""!==e),l=parseInt(t[0],10),h=parseInt(t[1],10),!l||!h)throw new Error("Geoid model file: Error reading raster size");break}{const r=e.split(" "),n=r[0],l=r[1];if("#"!==n||!l)continue;const h=r.length>2?r.slice(2):[];if("Description"===l)u=h.join(" ");else if("DateTime"===l)c=h.join(" ");else if("Offset"===l){if(!r[2])throw new Error("Geoid model file: Error reading offset");i=parseInt(r[2],10)}else if("Scale"===l){if(!r[2])throw new Error("Geoid model file: Error reading scale");a=parseFloat(r[2])}else l===(t.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(r[2]))&&(o=parseFloat(r[2])):l===(t.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(r[2]))&&(s=parseFloat(r[2]))}}}while(!n.done);n=r.next();const d=parseInt(n.value.line,10);if(n.done)throw new Error("Geoid model file: Error reading maxval");if(65535!==d)throw new Error("Geoid model file: Incorrect value of maxval");if(p=n.value.offset,f=l,i===Number.MAX_VALUE)throw new Error("Geoid model file: Offset not set");if(0===a)throw new Error("Geoid model file: Scale not set");if(a<0)throw new Error("Geoid model file: Scale must be positive");if(h<2||l<2)throw new Error("Geoid model file: Raster size too small");if(1&l)throw new Error("Geoid model file: Raster width is odd");if(!(1&h))throw new Error("Geoid model file: Raster height is even");const m=l/360,g=(h-1)/180;return new Fd({cubic:t.cubic,_width:l,_height:h,_rlonres:m,_rlatres:g,_offset:i,_scale:a,_swidth:f,_datastart:p,_maxerror:o,_rmserror:s,_description:u,_datetime:c,data:e})}function zd(e){let t="";for(const r of e)t+=String.fromCharCode(r);return t}const Ud={name:"PGM - Netpbm grayscale image format",id:"pgm",module:"tile-converter",version:"3.3.0",mimeTypes:["image/x-portable-graymap"],parse:async(e,t)=>Nd(new Uint8Array(e),t),extensions:["pgm"],options:{cubic:!1}};function qd(e,t){const r=[e.center[0],e.center[1],e.center[2]+t.getHeight(e.center[1],e.center[0])],n=vu.WGS84.cartographicToCartesian(r,new Cs),i=(new xp).fromCenterHalfSizeQuaternion(n,e.halfSize,e.quaternion);return[...i.center,...i.halfAxes.toArray()]}function Hd(e,t){const r=[],n=e.boundingVolume,i=e.lodMetricValue||.1,a={metricType:"maxScreenThreshold",maxError:2*t.mbs[3]*16/i},o={metricType:"maxScreenThresholdSQ",maxError:.25*Math.PI*a.maxError*a.maxError};return"OrientedBoundingBox"===n.constructor.name?(r.push(o),r.push(a)):(r.push(a),r.push(o)),r}function Gd(e){let t=(e.header.lodSelection.maxScreenThreshold||{}).maxError;if(!t){const r=e.header.lodSelection.maxScreenThresholdSQ;r&&(t=Math.sqrt(r.maxError/(.25*Math.PI)))}return t||(t=16),2*e.header.mbs[3]*16/t}const Wd={name:"JSON",id:"json",module:"json",version:"3.3.0",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:Vd,parse:async e=>Vd((new TextDecoder).decode(e)),options:{}};function Vd(e){return JSON.parse(e)}r(265);var Kd=r(83),Jd=r.n(Kd);function Qd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const $d={command:"",arguments:[],port:5e3,autoPort:!0,wait:2e3,onSuccess:e=>{console.log("Started "+e.props.command)}};class Yd{constructor({id:e="browser-driver"}={}){Qd(this,"id",void 0),Qd(this,"props",{...$d}),Qd(this,"childProcess",null),Qd(this,"port",0),Qd(this,"successTimer",void 0),this.id=e}async start(e){e={...$d,...e},this.props=e;const t=[...e.arguments];return this.port=Number(e.port),e.portArg&&(e.autoPort&&(this.port=await function(e=3e3){return new Promise(t=>{Jd.a.exec("lsof -i -P -n | grep LISTEN",(r,n)=>{if(r)return void t(e);const i=[],a=/:(\d+) \(LISTEN\)/;n.split("\n").forEach(e=>{const t=a.exec(e);t&&i.push(Number(t[1]))});let o=e;for(;i.includes(o);)o++;t(o)})})}(e.port)),t.push(e.portArg,String(this.port))),await new Promise((r,n)=>{try{this._setTimeout(()=>{e.onSuccess&&e.onSuccess(this),r({})}),console.log(`Spawning ${e.command} ${e.arguments.join(" ")}`);const i=Kd.spawn(e.command,t,e.spawn);this.childProcess=i,i.stdout.on("data",e=>{console.log(e.toString())}),i.stderr.on("data",e=>{console.log(`Child process wrote to stderr: "${e}".`),this._clearTimeout(),n(new Error(e))}),i.on("error",e=>{console.log("Child process errored with "+e),this._clearTimeout(),n(e)}),i.on("close",e=>{console.log("Child process exited with "+e),this.childProcess=null,this._clearTimeout(),r({})})}catch(e){n(e)}})}async stop(){this.childProcess&&(this.childProcess.kill(),this.childProcess=null)}async exit(e=0){try{await this.stop(),process.exit(e)}catch(e){console.error(e.message||e),process.exit(1)}}_setTimeout(e){Number(this.props.wait)>0&&(this.successTimer=setTimeout(e,this.props.wait))}_clearTimeout(){this.successTimer&&clearTimeout(this.successTimer)}}var Xd=r(82),Zd=r.n(Xd);const em="function"==typeof atob?atob:"function"==typeof Buffer?function(e){return Buffer.from(e,"base64").toString("binary")}:nm,tm=em("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"),rm=!(!WebAssembly||em===nm)&&function(e){var t,r,n,i=-1;t=e.length-1,r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(;t>i++;)n[i]=e.charCodeAt(i);return n}(tm).buffer;Math.floor(1048576.00032768);function nm(e){return e}rm||console.log("WebAssembly not available or WASM module could not be decoded; md5WASM will fall back to JavaScript");r(118);function im(e){const t=e+".gz",r=Object(fe.createGzip)(),n=Object(Ae.createReadStream)(e),i=Object(Ae.createWriteStream)(t);return new Promise((e,a)=>{n.on("end",()=>{console.log(t+" compressed and saved."),e(t)}),n.on("error",e=>{console.log(t+": compression error!"),a(e)}),n.pipe(r).pipe(i)})}async function am(e,t,r,n,i){"win32"===process.platform?await async function(e,t,r=0,n=Object(qi.join)(".","*"),i){"@"===n[0]&&(n="*"+n.substr(1));const a=hm(t),o=["a","-tzip","-mx="+r,a,n],s=new Yd;await s.start({command:i,arguments:o,spawn:{cwd:""+e},wait:0})}(e,t,r,n,i):await async function(e,t,r=0,n="."){const i=hm(t),a=["-"+r,"-r",i,n],o=new Yd;await o.start({command:"zip",arguments:a,spawn:{cwd:e},wait:0})}(e,t,r,n)}async function om(e,t,r="index.json"){let n;n=t instanceof Promise?new Uint8Array(await t):t instanceof ArrayBuffer?new Uint8Array(t):t,await Ae.promises.mkdir(e,{recursive:!0});const i=Object(qi.join)(e,r);try{await Ae.promises.writeFile(i,n)}catch(e){throw e}return console.log(i+" saved."),i}async function sm(e,t,r="index.json",n=!0,i){const a=await om(e,t,r);if(n){if(i)return i.includes(a)?null:(i.push(a),a+".gz");{const e=await im(a);return await lm(a),e}}return a}async function um(e,t){return new Promise((r,n)=>{let i=0;console.log(`load ${e}/${t}.`);const a=setInterval(()=>{Jo(Object(qi.join)(e,t),Wd).then(e=>{clearInterval(a),r(e)}).catch(()=>{i++,i>100&&(clearInterval(a),n(new Error(`Cannon load ${e}/${t}.`)))})},200)})}function cm(e){return Ae.promises.rmdir(e,{recursive:!0})}function lm(e){return Ae.promises.unlink(e)}function hm(e){return Object(qi.isAbsolute)(e)?e:Object(qi.join)(process.cwd(),e)}function pm(e){let t=e[0];const r=Math.floor(t/3600);t-=3600*r;const n=Math.floor(t/60);t-=60*n;const i=Math.floor(t),a=e[1]/1e6;let o="";return r&&(o+=r+"h "),n&&(o+=n+"m "),i&&(o+=i+"s"),o||(o+=a+"ms"),o}async function fm(e){const{slpk:t,outputPath:r,tilesetName:n}=e,i=hm(r);try{if(t){const e=Object(qi.join)(i,n+".slpk");return(await Ae.promises.stat(e)).size}const e=Object(qi.join)(i,n);return await async function e(t){let r=0;const n=await Ae.promises.readdir(t);for(const i of n){const n=await Ae.promises.stat(Object(qi.join)(t,i));n.isDirectory()?r+=await e(Object(qi.join)(t,i)):r+=n.size}return r}(e)}catch(e){return console.log("Calculate file sizes error: ",e),null}}const dm=()=>({boundingVolume:{path:"boundingVolume"},geometricError:{path:"geometricError"},content:{path:"content"},children:{path:"children",transform:e=>e.map(e=>Vi()(e,dm()))}});function mm(e,t){let r,n,i;const a=e.boundingVolume,o=vu.WGS84.cartesianToCartographic(a.center,new Cs);return o[2]=o[2]-t.getHeight(o[1],o[0]),a instanceof xp?(n=a.halfSize,r=new Cs(n[0],n[1],n[2]).len(),i=a.quaternion):(r=e.boundingVolume.radius,n=[r,r,r],i=(new op).fromMatrix3(new Ph([n[0],0,0,0,n[1],0,0,0,n[2]])).normalize()),{mbs:[o[0],o[1],o[2],r],obb:{center:[o[0],o[1],o[2]],halfSize:n,quaternion:i}}}function gm(e,t){const r=function(e){const t=[];for(let r=0;r<e.length;r+=3){const n=new Cs([e[r],e[r+1],e[r+2]]);t.push(n)}return t}(e),n=function(e,t=new xp){if(!e||0===e.length)return t.halfAxes=new Ph([0,0,0,0,0,0,0,0,0]),t.center=new Cs,t;const r=e.length,n=new Cs(0,0,0);for(const t of e)n.add(t);const i=1/r;n.multiplyByScalar(i);let a=0,o=0,s=0,u=0,c=0,l=0;for(const t of e){const e=ef.copy(t).subtract(n);a+=e.x*e.x,o+=e.x*e.y,s+=e.x*e.z,u+=e.y*e.y,c+=e.y*e.z,l+=e.z*e.z}a*=i,o*=i,s*=i,u*=i,c*=i,l*=i;const h=of;h[0]=a,h[1]=o,h[2]=s,h[3]=o,h[4]=u,h[5]=c,h[6]=s,h[7]=c,h[8]=l;const{unitary:p}=Qp(h,sf),f=t.halfAxes.copy(p);let d=f.getColumn(0,rf),m=f.getColumn(1,nf),g=f.getColumn(2,af),y=-Number.MAX_VALUE,b=-Number.MAX_VALUE,v=-Number.MAX_VALUE,w=Number.MAX_VALUE,_=Number.MAX_VALUE,k=Number.MAX_VALUE;for(const t of e)ef.copy(t),y=Math.max(ef.dot(d),y),b=Math.max(ef.dot(m),b),v=Math.max(ef.dot(g),v),w=Math.min(ef.dot(d),w),_=Math.min(ef.dot(m),_),k=Math.min(ef.dot(g),k);d=d.multiplyByScalar(.5*(w+y)),m=m.multiplyByScalar(.5*(_+b)),g=g.multiplyByScalar(.5*(k+v)),t.center.copy(d).add(m).add(g);const x=tf.set(y-w,b-_,v-k).multiplyByScalar(.5),E=new Ph([x[0],0,0,0,x[1],0,0,0,x[2]]);return t.halfAxes.multiplyRight(E),t}(r),i=function(e,t=new Th){if(!e||0===e.length)return t.fromCenterRadius([0,0,0],0);const r=Lp.copy(e[0]),n=Op.copy(r),i=Ip.copy(r),a=Pp.copy(r),o=Dp.copy(r),s=Mp.copy(r),u=Fp.copy(r);for(const t of e){r.copy(t);const e=r.x,c=r.y,l=r.z;e<n.x&&n.copy(r),e>o.x&&o.copy(r),c<i.y&&i.copy(r),c>s.y&&s.copy(r),l<a.z&&a.copy(r),l>u.z&&u.copy(r)}const c=Np.copy(o).subtract(n).magnitudeSquared(),l=Np.copy(s).subtract(i).magnitudeSquared(),h=Np.copy(u).subtract(a).magnitudeSquared();let p=n,f=o,d=c;l>d&&(d=l,p=i,f=s),h>d&&(d=h,p=a,f=u);const m=zp;m.x=.5*(p.x+f.x),m.y=.5*(p.y+f.y),m.z=.5*(p.z+f.z);let g=Np.copy(f).subtract(m).magnitudeSquared(),y=Math.sqrt(g);const b=Up;b.x=n.x,b.y=i.y,b.z=a.z;const v=qp;v.x=o.x,v.y=s.y,v.z=u.z;const w=Hp.copy(b).add(v).multiplyByScalar(.5);let _=0;for(const t of e){r.copy(t);const e=Np.copy(r).subtract(w).magnitude();e>_&&(_=e);const n=Np.copy(r).subtract(m).magnitudeSquared();if(n>g){const e=Math.sqrt(n);y=.5*(y+e),g=y*y;const t=e-y;m.x=(y*m.x+t*r.x)/e,m.y=(y*m.y+t*r.y)/e,m.z=(y*m.z+t*r.z)/e}}return y<_?(m.to(t.center),t.radius=y):(w.to(t.center),t.radius=_),t}(r);let a=vu.WGS84.cartesianToCartographic(i.center,new Cs),o=vu.WGS84.cartesianToCartographic(n.center,new Cs);return a[2]=a[2]-t.getHeight(a[1],a[0]),o[2]=o[2]-t.getHeight(o[1],o[0]),{mbs:[a[0],a[1],a[2],i.radius],obb:{center:o,halfSize:n.halfSize,quaternion:n.quaternion}}}function ym(e){const t=e[3],r=new Cs(e[0],e[1],e[2]),n=new Ph([t,0,0,0,t,0,0,0,t]);return new xp(r,n)}async function bm(e,t,r={},n={}){const i=function(e){const t="3.3.0"!==e.version?" (worker-utils@3.3.0)":"";return`${e.name}@${e.version}${t}`}(e),a=eo.getWorkerFarm(r),{source:o}=r,s={name:i,source:o};o||(s.url=to(e,r));const u=a.getWorkerPool(s),c=r.jobName||e.name,l=await u.startJob(c,vm.bind(null,n)),h=function e(t){if(null===t)return{};const r=Object.assign({},t);return Object.keys(r).forEach(n=>{"object"!=typeof t[n]||ArrayBuffer.isView(t[n])||t[n]instanceof Array?"function"==typeof r[n]||r[n]instanceof RegExp?r[n]={}:r[n]=t[n]:r[n]=e(t[n])}),r}(r);l.postMessage("process",{input:t,options:h});return(await l.result).result}async function vm(e,t,r,n){switch(r){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:i,input:a,options:o}=n;try{if(!e.process)return void t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});const r=await e.process(a,o);t.postMessage("done",{id:i,result:r})}catch(e){const r=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:i,error:r})}break;default:console.warn("process-on-worker: unknown message "+r)}}const wm={id:"3d-tiles-attributes",name:"3DTiles Attributes Worker",module:"tile-converter",version:"3.3.0",options:{featureAttributes:null}};const _m="Tile converter does not work in browser, only in node js environment";function km(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class xm{constructor(){km(this,"options",void 0),km(this,"tilesetPath",void 0),km(this,"vertexCounter",void 0),km(this,"conversionStartTime",void 0),km(this,"geoidHeightModel",void 0),km(this,"sourceTileset",void 0),km(this,"attributeStorageInfo",void 0),km(this,"workerSource",{}),this.options={},this.tilesetPath="",this.vertexCounter=0,this.conversionStartTime=[0,0],this.geoidHeightModel=null,this.sourceTileset=null,this.attributeStorageInfo=null,this.workerSource={}}async convert(e){if(Ki)return console.log(_m),_m;const{inputUrl:t,outputPath:r,tilesetName:n,maxDepth:i,egmFilePath:a}=e;this.conversionStartTime=Gi.a.hrtime(),this.options={maxDepth:i},console.log("Loading egm file..."),this.geoidHeightModel=await Jo(a,Ud),console.log("Loading egm file completed!"),await this.loadWorkers();const o=await Jo(t,Bf,{});this.sourceTileset=new Id(o,{loadOptions:{_nodeWorkers:!0,reuseWorkers:!0,"i3s-content-nodejs":{workerUrl:"./modules/i3s/dist/i3s-content-nodejs-worker.js"},i3s:{coordinateSystem:ch.LNGLAT_OFFSETS,decodeTextures:!1}}}),await this.sourceTileset.tilesetInitializationPromise;const s=this.sourceTileset.root;s.header.obb||(s.header.obb=ym(s.header.mbs)),this.tilesetPath=Object(qi.join)(""+r,""+n),this.attributeStorageInfo=o.attributeStorageInfo;try{await cm(this.tilesetPath)}catch(e){}const u={boundingVolume:{box:qd(s.header.obb,this.geoidHeightModel)},geometricError:Gd(s),children:[]};await this._addChildren(s,u,1);const c=Vi()({root:u},{asset:{path:"asset",transform:e=>Vi()(e,{version:{path:"version",default:"1.0"}})},geometricError:{path:"root",transform:e=>e.geometricError},root:{path:"root",transform:e=>Vi()(e,dm())}});await om(this.tilesetPath,JSON.stringify(c),"tileset.json"),this._finishConversion({slpk:!1,outputPath:r,tilesetName:n});eo.getWorkerFarm({}).destroy()}async convertChildNode(e,t,r,n){const i=await this._loadChildNode(e,n);if(e.children.push(i),i.contentUrl){var a;await this.sourceTileset._loadTile(i),this.vertexCounter+=i.content.vertexCount;let e=null;this.attributeStorageInfo&&(e=await this._loadChildAttributes(i,this.attributeStorageInfo)),i.header.obb||(i.header.obb=ym(i.header.mbs));const n={box:qd(i.header.obb,this.geoidHeightModel)},o={boundingVolume:n,geometricError:Gd(i),children:[]},s={tileContent:i.content,textureFormat:null==i||null===(a=i.header)||void 0===a?void 0:a.textureFormat},u=await function(e,t){return bm(wm,e,t)}(s,{source:this.workerSource.tile3dWorkerSource,featureAttributes:e});o.content={uri:i.id+".b3dm",boundingVolume:n},await om(this.tilesetPath,new Uint8Array(u),i.id+".b3dm"),t.children.push(o),i.unloadContent(),await this._addChildren(i,o,r+1)}else await this._addChildren(i,t,r+1)}async _addChildren(e,t,r){if(this.options.maxDepth&&r>this.options.maxDepth)return;const n=[];for(const i of e.header.children||[])n.push(this.convertChildNode(e,t,r,i));await Promise.all(n)}async _loadChildNode(e,t){let r;if(this.sourceTileset.tileset.nodePages)console.log("Node conversion: "+t.id),r=await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(t.id);else{const{loader:n}=this.sourceTileset,i=this._relativeUrlToFullUrl(e.url,t.href),a={i3s:{...this.sourceTileset.loadOptions,isTileHeader:!0,loadContent:!1}};console.log("Node conversion: "+i),r=await Jo(i,n,a)}return new _d(this.sourceTileset,r,e)}_relativeUrlToFullUrl(e,t){let r=e.split("/");const n=t.split("/");for(const e of n)switch(e){case".":continue;case"..":r=r.slice(0,-1);break;default:r.push(e)}return r.join("/")}async _loadChildAttributes(e,t){const r=[],{attributeUrls:n}=e.header;for(let e=0;e<n.length;e++){const i=n[e],a=t[e],o={attributeName:a.name,attributeType:this._getAttributeType(a)};r.push(Jo(i,fh,o))}const i=await Promise.all(r);return this._replaceNestedArrays(i),Object.assign({},...i)}_getAttributeType(e){return e.attributeValues?e.attributeValues.valueType:e.objectIds?"Oid32":""}_replaceNestedArrays(e){for(let t=0;t<e.length;t++){const r=e[t];for(const e in r)r[e]=Array.from(r[e])}}async _finishConversion(e){const t=await fm(e),r=pm(Gi.a.hrtime(this.conversionStartTime));console.log("------------------------------------------------"),console.log("Finish conversion of I3S"),console.log("Total conversion time: "+r),console.log("Vertex count: ",this.vertexCounter),console.log("File(s) size: ",t," bytes"),console.log("------------------------------------------------")}async loadWorkers(){console.log("Loading workers source...");const e=to(wm,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.tile3dWorkerSource=r,console.log("Loading workers source completed!")}}async function Em(e,t,r){if(function(e,t){return!!eo.isSupported()&&(!!(Ki||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}(t,r={...Aa(),...r}))return await bm(t,e,r);if(t.encode)return await t.encode(e,r);if(t.encodeSync)return t.encodeSync(e,r);if(t.encodeText)return(new TextEncoder).encode(await t.encodeText(e,r));if(t.encodeInBatches){const n=function(e,t,r){if(t.encodeInBatches){const n=function(e){return[{table:e,start:0,end:e.length}]}(e);return t.encodeInBatches(n,r)}throw new Error("Writer could not encode data in batches")}(e,t,r),i=[];for await(const e of n)i.push(e);return io(...i)}if(!Ki&&t.encodeURLtoURL){const n=Sm("input");await async function(e,t,r){e=ca(e),Ki||await i.writeFile(e,ho(t),{flag:"w"}),ia(!1)}(n,e);const a=Sm("output"),o=await async function(e,t,r,n){if(e=ca(e),t=ca(t),Ki||!r.encodeURLtoURL)throw new Error;return await r.encodeURLtoURL(e,t,n)}(n,a,t,r);return(await va(o)).arrayBuffer()}throw new Error("Writer could not encode data")}function Sm(e){return"/tmp/"+e}const Am={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(Am);function jm(e,t,r){ia(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),i=new Uint8Array(e,t,r);return n.decode(i)}const Cm={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Tm={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Cm},Bm={[Cm.DOUBLE]:Float64Array,[Cm.FLOAT]:Float32Array,[Cm.UNSIGNED_SHORT]:Uint16Array,[Cm.UNSIGNED_INT]:Uint32Array,[Cm.UNSIGNED_BYTE]:Uint8Array,[Cm.BYTE]:Int8Array,[Cm.SHORT]:Int16Array,[Cm.INT]:Int32Array},Rm={DOUBLE:Cm.DOUBLE,FLOAT:Cm.FLOAT,UNSIGNED_SHORT:Cm.UNSIGNED_SHORT,UNSIGNED_INT:Cm.UNSIGNED_INT,UNSIGNED_BYTE:Cm.UNSIGNED_BYTE,BYTE:Cm.BYTE,SHORT:Cm.SHORT,INT:Cm.INT};class Om{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Bm){if(Bm[t]===e)return t}throw new Error("Failed to convert GL type")}static fromName(e){const t=Rm[e];if(!t)throw new Error("Failed to convert GL type");return t}static getArrayType(e){switch(e){case Cm.UNSIGNED_SHORT_5_6_5:case Cm.UNSIGNED_SHORT_4_4_4_4:case Cm.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Bm[e];if(!t)throw new Error("Failed to convert GL type");return t}}static getByteSize(e){return Om.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Om.getArrayType(e))}static createTypedArray(e,t,r=0,n){void 0===n&&(n=(t.byteLength-r)/Om.getByteSize(e));return new(Om.getArrayType(e))(t,r,n)}}function Im(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Pm{constructor(e,t){Im(this,"json",void 0),Im(this,"buffer",void 0),Im(this,"featuresLength",0),Im(this,"_cachedTypedArrays",{}),this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Tm.UNSIGNED_INT,r=1){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,t,r,1,n.byteOffset):n}getPropertyArray(e,t,r){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(t=Om.fromName(n.componentType)),this._getTypedArrayFromBinary(e,t,r,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,t,n)}getProperty(e,t,r,n,i){const a=this.json[e];if(!a)return a;const o=this.getPropertyArray(e,t,r);if(1===r)return o[n];for(let e=0;e<r;++e)i[e]=o[r*n+e];return i}_getTypedArrayFromBinary(e,t,r,n,i){const a=this._cachedTypedArrays;let o=a[e];return o||(o=Om.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+i,n*r),a[e]=o),o}_getTypedArrayFromArray(e,t,r){const n=this._cachedTypedArrays;let i=n[e];return i||(i=Om.createTypedArray(t,r),n[e]=i),i}}const Dm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Mm={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]]},Fm={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]}};const Lm=e=>void 0!==e;function Nm(e,t,r){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const i=t.HIERARCHY;return i&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=i,n=i),n?function(e,t){let r,n,i;const a=e.instancesLength,o=e.classes;let s,u=e.classIds,c=e.parentCounts,l=e.parentIds,h=a;Lm(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,i=getBinaryAccessor(u),u=i.createArrayBufferView(t.buffer,t.byteOffset+u.byteOffset,a));if(Lm(c))for(Lm(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,i=getBinaryAccessor(c),c=i.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,a)),s=new Uint16Array(a),h=0,r=0;r<a;++r)s[r]=h,h+=c[r];Lm(l)&&Lm(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,i=getBinaryAccessor(l),l=i.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,h));const p=o.length;for(r=0;r<p;++r){const e=o[r].length,n=o[r].instances,i=getBinaryProperties(e,n,t);o[r].instances=combine(i,n)}const f=new Array(p).fill(0),d=new Uint16Array(a);for(r=0;r<a;++r)n=u[r],d[r]=f[n],++f[n];const m={classes:o,classIds:u,classIndexes:d,parentCounts:c,parentIndexes:s,parentIds:l};return function(e){const t=e.classIds.length;for(let r=0;r<t;++r)Um(e,r,stack)}(m),m}(n,r):null}function zm(e,t,r){if(!e)return;const n=e.parentCounts;return e.parentIds?r(e,t):n>0?function(e,t,r){const n=e.classIds,i=e.parentCounts,a=e.parentIds,o=e.parentIndexes,s=n.length,u=scratchVisited;u.length=Math.max(u.length,s);const c=++marker,l=scratchStack;l.length=0,l.push(t);for(;l.length>0;){if(t=l.pop(),u[t]===c)continue;u[t]=c;const n=r(e,t);if(Lm(n))return n;const s=i[t],h=o[t];for(let e=0;e<s;++e){const r=a[h+e];r!==t&&l.push(r)}}return null}(e,t,r):function(e,t,r){let n=!0;for(;n;){const i=r(e,t);if(Lm(i))return i;const a=e.parentIds[t];n=a!==t,t=a}throw new Error("traverseHierarchySingleParent")}(e,t,r)}function Um(e,t,r){const n=e.parentCounts,i=e.parentIds,a=e.parentIndexes,o=e.classIds.length;if(!Lm(i))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===r.indexOf(t),"Circular dependency detected in the batch table hierarchy."),r.push(t);const s=Lm(n)?n[t]:1,u=Lm(n)?a[t]:t;for(let n=0;n<s;++n){const a=i[u+n];a!==t&&Um(e,a,r)}r.pop(t)}function qm(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hm(e){return null!=e}const Gm=(e,t)=>e,Wm={HIERARCHY:!0,extensions:!0,extras:!0};class Vm{constructor(e,t,r,n={}){var i;qm(this,"json",void 0),qm(this,"binary",void 0),qm(this,"featureCount",void 0),qm(this,"_extensions",void 0),qm(this,"_properties",void 0),qm(this,"_binaryProperties",void 0),qm(this,"_hierarchy",void 0),ia(r>=0),this.json=e||{},this.binary=t,this.featureCount=r,this._extensions=(null===(i=this.json)||void 0===i?void 0:i.extensions)||{},this._properties={};for(const e in this.json)Wm[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Nm(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),ia("string"==typeof t,t),this._hierarchy){return Hm(zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r];return e.classes[n].name===t}))}return!1}isExactClass(e,t){return ia("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),ia("string"==typeof t,t),Hm(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Hm(t)?t:[]).length=0;const r=Object.keys(this._properties);return t.push(...r),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),ia("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(Hm(r))return this._getBinaryProperty(r,e)}const r=this._properties[t];if(Hm(r))return Gm(r[e]);if(this._hierarchy){const r=this._getHierarchyProperty(e,t);if(Hm(r))return r}}setProperty(e,t,r){const n=this.featureCount;if(this._checkBatchId(e),ia("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,r)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,r))return;let i=this._properties[t];Hm(i)||(this._properties[t]=new Array(n),i=this._properties[t]),i[e]=Gm(r)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,r){e.pack(r,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const r=this._properties[t],n=this._initializeBinaryProperty(t,r);n&&(e=e||{},e[t]=n)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const r=t;ia(this.binary,`Property ${e} requires a batch table binary.`),ia(r.type,`Property ${e} requires a type.`);const n=function(e,t,r,n){const{componentType:i}=e;ia(e.componentType);const a="string"==typeof i?Om.fromName(i):i,o=Dm[e.type],s=Mm[e.type],u=Fm[e.type];return r+=e.byteOffset,{values:Om.createTypedArray(a,t,r,o*n),type:a,size:o,unpacker:s,packer:u}}(r,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const r=zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r];return Hm(e.classes[n].instances[t])});return Hm(r)}_getPropertyNamesInHierarchy(e,t){zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r],i=e.classes[n].instances;for(const e in i)i.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r],i=e.classes[n],a=e.classIndexes[r],o=i.instances[t];return Hm(o)?Hm(o.typedArray)?this._getBinaryProperty(o,a):Gm(o[a]):null})}_setHierarchyProperty(e,t,r,n){const i=zm(this._hierarchy,t,(e,i)=>{const a=e.classIds[i],o=e.classes[a],s=e.classIndexes[i],u=o.instances[r];return!!Hm(u)&&(ia(i===t,`Inherited property "${r}" is read-only.`),Hm(u.typedArray)?this._setBinaryProperty(u,s,n):u[s]=Gm(n),!0)});return Hm(i)}}function Km(e,t,r=0){const 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,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return r}function Jm(e,t,r){const n=new DataView(t);let i;e.header=e.header||{};let a=n.getUint32(r,!0);r+=4;let o=n.getUint32(r,!0);r+=4;let s=n.getUint32(r,!0);r+=4;let u=n.getUint32(r,!0);return r+=4,s>=570425344?(r-=8,i=a,s=o,u=0,a=0,o=0,console.warn("b3dm tile in legacy format.")):u>=570425344&&(r-=4,i=s,s=a,u=o,a=0,o=0,console.warn("b3dm tile in legacy format.")),e.header.featureTableJsonByteLength=a,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=s,e.header.batchTableBinaryByteLength=u,e.header.batchLength=i,r}function Qm(e,t,r,n){return r=function(e,t,r,n){const{featureTableJsonByteLength:i,featureTableBinaryByteLength:a,batchLength:o}=e.header;if(e.featureTableJson={BATCH_LENGTH:o||0},i>0){const n=jm(t,r,i);e.featureTableJson=JSON.parse(n)}return r+=i,e.featureTableBinary=new Uint8Array(t,r,a),r+=a}(e,t,r),r=function(e,t,r,n){const{batchTableJsonByteLength:i,batchTableBinaryByteLength:a}=e.header;if(i>0){const n=jm(t,r,i);e.batchTableJson=JSON.parse(n),r+=i,a>0&&(e.batchTableBinary=new Uint8Array(t,r,a),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=a)}return r}(e,t,r)}function $m(e,t=[0,0,0]){const r=e>>11&31,n=e>>5&63,i=31&e;return t[0]=r<<3,t[1]=n<<2,t[2]=i<<3,t}function Ym(e,t,r){if(!(t||e&&e.batchIds&&r))return null;const{batchIds:n,isRGB565:i,pointCount:a}=e;if(n&&r){const e=new Uint8ClampedArray(3*a);for(let t=0;t<a;t++){const i=n[t],a=r.getProperty(i,"dimensions").map(e=>255*e);e[3*t]=a[0],e[3*t+1]=a[1],e[3*t+2]=a[2]}return{type:Tm.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(i){const e=new Uint8ClampedArray(3*a);for(let r=0;r<a;r++){const n=$m(t[r]);e[3*r]=n[0],e[3*r+1]=n[1],e[3*r+2]=n[2]}return{type:Tm.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*a?{type:Tm.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Tm.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}function Xm(e,t){if(!e)throw new Error("math.gl assertion failed. "+t)}new Rp,new Cs,new Rp,new Rp,new Uint8Array(1);function Zm(e,t=255){return is(e,0,t)/t*2-1}function eg(e){return e<0?-1:1}function tg(e,t,r,n){if(Xm(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=Zm(e,r),n.y=Zm(t,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const e=n.x;n.x=(1-Math.abs(n.y))*eg(e),n.y=(1-Math.abs(e))*eg(n.y)}return n.normalize()}function rg(e,t,r){return tg(e,t,255,r)}const ng=new Cs;function ig(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new Cs,n=new Float32Array(3*e.pointCount);for(let i=0;i<e.pointCount;i++)r.set(t[3*i],t[3*i+1],t[3*i+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,3*i);return n}(e,t)):{type:Tm.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function ag(e,t,r,n,i){r=Qm(e,t,r=Jm(e,t,r=Km(e,t,r))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:a,batchTable:o}=function(e){const t=new Pm(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",Tm.FLOAT,3);const n=function(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Tm.UNSIGNED_SHORT,1),e.batchIds)){const n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:i,batchTableBinary:a}=e;r=new Vm(i,a,n)}return r}(e,t);return{featureTable:t,batchTable:n}}(e);return await async function(e,t,r,n,i){let a,o,s;const u=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];u&&(s=u.properties);const c=t.getExtension("3DTILES_draco_point_compression");if(c){o=c.properties;const t=c.byteOffset,r=c.byteLength;if(!o||!Number.isFinite(t)||!r)throw new Error("Draco properties, byteOffset, and byteLength must be defined");a=e.featureTableBinary.slice(t,t+r),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(!a)return!0;const l={buffer:a,properties:{...o,...s},featureTableProperties:o,batchTableProperties:s,dequantizeInShader:!1};return await async function(e,t,r,n){const{parse:i}=n,a={...r,draco:{...r.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const o=await i(t.buffer,Tc,a),s=o.attributes.POSITION&&o.attributes.POSITION.value,u=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,h=s&&o.attributes.POSITION.value.quantization,p=c&&o.attributes.NORMAL.value.quantization;if(h){const t=o.POSITION.data.quantization,r=t.range;e.quantizedVolumeScale=new Cs(r,r,r),e.quantizedVolumeOffset=new Cs(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}p&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const f={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))o.attributes[e]&&o.attributes[e].value&&(f[e.toLowerCase()]=o.attributes[e].value);e.attributes={positions:s,colors:Ym(e,u,void 0),normals:c,batchIds:l,...f}}(e,l,n,i)}(e,a,0,n,i),function(e,t,r){if(!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",Tm.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const n=t.getPropertyArray("POSITION_QUANTIZED",Tm.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Tm.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Tm.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=ig(e,n,r)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,a,n),function(e,t,r){if(!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",Tm.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",Tm.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",Tm.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Ym(e,n,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Tm.UNSIGNED_BYTE,4))}(e,a,o),function(e,t){if(!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",Tm.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",Tm.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const r=new Float32Array(3*e.pointsLength);for(let n=0;n<e.pointsLength;n++)rg(t[2*n],t[2*n+1],ng),ng.toArray(r,3*n);return{type:Tm.FLOAT,size:2,value:r}}return{type:Tm.FLOAT,size:2,value:t}}(e,r)}}(e,a),r}function og(e,t,r){if(e.byteLength<=t+r)return"";const n=new DataView(e);let i="";for(let e=0;e<r;e++)i+=String.fromCharCode(n.getUint8(t+e));return i}function sg(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return og(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return og(e,0,t)}return""}(e)}"`)}}function ug(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function cg(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const 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}function lg(e,t,r){const n=e.bufferViews[r];ug(n);const i=t[n.buffer];ug(i);const a=(n.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,a,n.byteLength)}function hg(e,t){return ia(e>=0),ia(t>0),e+(t-1)&~(t-1)}function pg(e,t,r){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,r)}return t.set(n,r),r+hg(n.byteLength,4)}const fg=["SCALAR","VEC2","VEC3","VEC4"],dg=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],mg=new Map(dg),gg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yg={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},bg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function vg(e){return fg[e-1]||fg[0]}function wg(e){const t=mg.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function _g(e,t){const r=bg[e.componentType],n=gg[e.type],i=yg[e.componentType],a=e.count*n,o=e.count*n*i;return ug(o>=0&&o<=t.byteLength),{ArrayType:r,length:a,byteLength:o}}function kg(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const xg={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Eg{constructor(e){kg(this,"gltf",void 0),kg(this,"sourceBuffers",void 0),kg(this,"byteLength",void 0),this.gltf=e||{json:{...xg},buffers:[]},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(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),r=this.json.extensions||{};return t?r[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];if(!r)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return r}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,r=this.gltf.buffers[t];ug(r);const n=(e.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,{ArrayType:n,length:i}=_g(e,t);return new n(r,t.byteOffset+e.byteOffset,i)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,n=t.byteOffset||0;return new Uint8Array(r,n,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,r){return e.extensions=e.extensions||{},e.extensions[t]=r,this.registerUsedExtension(t),this}setObjectExtension(e,t,r){(e.extensions||{})[t]=r}removeObjectExtension(e,t){const r=e.extensions||{},n=r[t];return delete r[t],n}addExtension(e,t={}){return ug(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return ug(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(!this.getExtension(e))return;this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e],Array.isArray(this.json.extensionsRemoved)||(this.json.extensionsRemoved=[]);const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:r}=e;this.json.nodes=this.json.nodes||[];const n={mesh:t};return r&&(n.matrix=r),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:r,material:n,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(t),mode:i}]};if(r){const e=this._addIndices(r);a.primitives[0].indices=e}return Number.isFinite(n)&&(a.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const r=Mu(e),n=t||(null==r?void 0:r.mimeType),i={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e){const t=e.byteLength;ug(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=hg(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const r={bufferView:e,type:vg(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const r=this.addBufferView(e);let n={min:t.min,max:t.max};n.min&&n.max||(n=this._getAccessorMinMax(e,t.size));const i={size:t.size,componentType:wg(e),count:Math.round(e.length/t.size),min:n.min,max:n.max};return this.addAccessor(r,Object.assign(i,t))}addTexture(e){const{imageIndex:t}=e,r={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const r=this.byteLength,n=new ArrayBuffer(r),i=new Uint8Array(n);let a=0;for(const e of this.sourceBuffers||[])a=pg(e,i,a);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=r:this.json.buffers=[{byteLength:r}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(e,t){let r=!0;for(;r;){const n=e.indexOf(t);n>-1?e.splice(n,1):r=!1}}_addAttributes(e={}){const t={};for(const r in e){const n=e[r],i=this._getGltfAttributeName(r),a=this.addBinaryBuffer(n.value,n);t[i]=a}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.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 e}}_getAccessorMinMax(e,t){const r={min:null,max:null};if(e.length<t)return r;r.min=[],r.max=[];const n=e.subarray(0,t);for(const e of n)r.min.push(e),r.max.push(e);for(let n=t;n<e.length;n+=t)for(let i=0;i<t;i++)r.min[0+i]=Math.min(r.min[0+i],e[n+i]),r.max[0+i]=Math.max(r.max[0+i],e[n+i]);return r}}const Sg=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]),Ag=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]),jg={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Cg={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};let Tg;async function Bg(){return Tg||(Tg=async function(){let e="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";WebAssembly.validate(Sg)&&(e="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",console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t[r]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let n=0;n<e.length;++n)t[r++]=t[n]<60?Ag[t[n]]:64*(t[n]-60)+t[++n];return t.buffer.slice(0,r)}(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}()),Tg}function Rg(e,t,r,n,i,a,o){const s=e.exports.sbrk,u=n+3&-4,c=s(u*i),l=s(a.length),h=new Uint8Array(e.exports.memory.buffer);h.set(a,l);const p=t(c,n,i,l,a.length);if(0===p&&o&&o(c,u,i),r.set(h.subarray(c,c+n*i)),s(c-s(0)),0!==p)throw new Error("Malformed buffer data: "+p)}const Og="EXT_meshopt_compression";async function Ig(e,t){var r;const n=new Eg(e);if(null==t||null===(r=t.gltf)||void 0===r||!r.decompressMeshes)return;const i=[];for(const t of e.json.bufferViews||[])i.push(Pg(n,t));await Promise.all(i),n.removeExtension("EXT_meshopt_compression")}async function Pg(e,t){const r=e.getObjectExtension(t,"EXT_meshopt_compression");if(r){const{byteOffset:n=0,byteLength:i=0,byteStride:a,count:o,mode:s,filter:u="NONE",buffer:c}=r,l=e.gltf.buffers[c],h=new Uint8Array(l.arrayBuffer,l.byteOffset+n,i),p=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);return await async function(e,t,r,n,i,a="NONE"){const o=await Bg();Rg(o,o.exports[Cg[i]],e,t,r,n,o.exports[jg[a||"NONE"]])}(p,o,a,h,s,u),p}return null}const Dg=["image/png","image/jpeg","image/gif"],Mg={};function Fg(e){return void 0===Mg[e]&&(Mg[e]=function(e){switch(e){case"image/webp":return function(){if(!Ki)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return Ki;default:if(!Ki){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Dg.includes(e)}return!0}}(e)),Mg[e]}const Lg="EXT_texture_webp";function Ng(e,t){const r=new Eg(e);if(!Fg("image/webp")){if(r.getRequiredExtensions().includes("EXT_texture_webp"))throw new Error("gltf: Required extension EXT_texture_webp not supported by browser");return}const{json:n}=r;for(const e of n.textures||[]){const t=r.getObjectExtension(e,"EXT_texture_webp");t&&(e.source=t.source),r.removeObjectExtension(e,"EXT_texture_webp")}r.removeExtension("EXT_texture_webp")}const zg="KHR_texture_basisu";function Ug(e,t){const r=new Eg(e),{json:n}=r;for(const e of n.textures||[]){const t=r.getObjectExtension(e,"KHR_texture_basisu");t&&(e.source=t.source),r.removeObjectExtension(e,"KHR_texture_basisu")}r.removeExtension("KHR_texture_basisu")}function qg(e){const{buffer:t,size:r,count:n}=function(e){let t=e,r=1,n=0;e&&e.value&&(t=e.value,r=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,r=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(r&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),n=t.length/r);return{buffer:t,size:r,count:n}}(e);return{value:t,size:r,byteOffset:0,count:n,type:vg(r),componentType:wg(t)}}const Hg="KHR_draco_mesh_compression";function Gg(e,t,r){const n=new Eg(e);for(const e of Qg(n))n.getObjectExtension(e,"KHR_draco_mesh_compression")}async function Wg(e,t,r){var n;if(null==t||null===(n=t.gltf)||void 0===n||!n.decompressMeshes)return;const i=new Eg(e),a=[];for(const e of Qg(i))i.getObjectExtension(e,"KHR_draco_mesh_compression")&&a.push(Kg(i,e,t,r));await Promise.all(a),i.removeExtension("KHR_draco_mesh_compression")}function Vg(e,t={}){const r=new Eg(e);for(const e of r.json.meshes||[])Jg(e,t),r.addRequiredExtension("KHR_draco_mesh_compression")}async function Kg(e,t,r,n){const i=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!i)return;const a=e.getTypedArrayForBufferView(i.bufferView),o=oo(a.buffer,a.byteOffset),{parse:s}=n,u={...r};delete u["3d-tiles"];const c=await s(o,Tc,u,n),l=function(e){const t={};for(const r in e){const n=e[r];if("indices"!==r){const e=qg(n);t[r]=e}}return t}(c.attributes);for(const[r,n]of Object.entries(l))if(r in t.attributes){const i=t.attributes[r],a=e.getAccessor(i);null!=a&&a.min&&null!=a&&a.max&&(n.min=a.min,n.max=a.max)}t.attributes=l,c.indices&&(t.indices=qg(c.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Jg(e,t,r=4,n,i){var a;if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=n.DracoWriter.encodeSync({attributes:e}),s=null==i||null===(a=i.parseSync)||void 0===a?void 0:a.call(i,{attributes:e}),u=n._addFauxAttributes(s.attributes);return{primitives:[{attributes:u,mode:r,extensions:{KHR_draco_mesh_compression:{bufferView:n.addBufferView(o),attributes:u}}}]}}function*Qg(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}const $g={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yg={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};const Xg="KHR_texture_transform",Zg=new Cs,ey=new Ph,ty=new Ph;async function ry(e,t){if(!new Eg(e).getExtension("KHR_texture_transform"))return;const r=e.json.materials||[];for(let t=0;t<r.length;t++)ny(t,e)}function ny(e,t){var r,n,i;const a=[],o=null===(r=t.json.materials)||void 0===r?void 0:r[e],s=null==o||null===(n=o.pbrMetallicRoughness)||void 0===n?void 0:n.baseColorTexture;s&&iy(t,e,s,a);const u=null==o?void 0:o.emissiveTexture;u&&iy(t,e,u,a);const c=null==o?void 0:o.normalTexture;c&&iy(t,e,c,a);const l=null==o?void 0:o.occlusionTexture;l&&iy(t,e,l,a);const h=null==o||null===(i=o.pbrMetallicRoughness)||void 0===i?void 0:i.metallicRoughnessTexture;h&&iy(t,e,h,a)}function iy(e,t,r,n){const i=function(e,t){var r;const n=null===(r=e.extensions)||void 0===r?void 0:r.KHR_texture_transform,{texCoord:i=0}=e,{texCoord:a=i}=n;if(-1===t.findIndex(([e,t])=>e===i&&t===a)){const r=function(e){const{offset:t=[0,0],rotation:r=0,scale:n=[1,1]}=e,i=(new Ph).set(1,0,0,0,1,0,t[0],t[1],1),a=ey.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),o=ty.set(n[0],0,0,0,n[1],0,0,0,1);return i.multiplyRight(a).multiplyRight(o)}(n);return i!==a&&(e.texCoord=a),t.push([i,a]),{originalTexCoord:i,texCoord:a,matrix:r}}return null}(r,n);if(!i)return;const a=e.json.meshes||[];for(const r of a)for(const n of r.primitives){const r=n.material;Number.isFinite(r)&&t===r&&ay(e,n,i)}}function ay(e,t,r){const{originalTexCoord:n,texCoord:i,matrix:a}=r,o=t.attributes["TEXCOORD_"+n];if(Number.isFinite(o)){var s;const r=null===(s=e.json.accessors)||void 0===s?void 0:s[o];if(r&&r.bufferView){var u;const o=null===(u=e.json.bufferViews)||void 0===u?void 0:u[r.bufferView];if(o){const{arrayBuffer:s,byteOffset:u}=e.buffers[o.buffer],c=(u||0)+(r.byteOffset||0)+(o.byteOffset||0),{ArrayType:l,length:h}=_g(r,o),p=Yg[r.componentType],f=$g[r.type],d=o.byteStride||p*f,m=new Float32Array(h);for(let e=0;e<r.count;e++){const t=new l(s,c+e*d,2);Zg.set(t[0],t[1],1),Zg.transformByMatrix3(a),m.set([Zg[0],Zg[1]],e*f)}n===i?function(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}(r,o,e.buffers,m):function(e,t,r,n,i){n.buffers.push({arrayBuffer:i.buffer,byteOffset:0,byteLength:i.buffer.byteLength});const a=n.json.bufferViews;if(!a)return;a.push({buffer:n.buffers.length-1,byteLength:i.buffer.byteLength,byteOffset:0});const o=n.json.accessors;if(!o)return;o.push({bufferView:(null==a?void 0:a.length)-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),r.attributes["TEXCOORD_"+e]=o.length-1}(i,r,t,e,m)}}}}const oy="KHR_lights_punctual";async function sy(e){const t=new Eg(e),{json:r}=t,n=t.getExtension("KHR_lights_punctual");n&&(t.json.lights=n.lights,t.removeExtension("KHR_lights_punctual"));for(const e of r.nodes||[]){const r=t.getObjectExtension(e,"KHR_lights_punctual");r&&(e.light=r.light),t.removeObjectExtension(e,"KHR_lights_punctual")}}async function uy(e){const t=new Eg(e),{json:r}=t;if(r.lights){const e=t.addExtension("KHR_lights_punctual");ug(!e.lights),e.lights=r.lights,delete r.lights}if(t.json.lights){for(const e of t.json.lights){const r=e.node;t.addObjectExtension(r,"KHR_lights_punctual",e)}delete t.json.lights}}const cy="KHR_materials_unlit";async function ly(e){const t=new Eg(e),{json:r}=t;for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}t.removeExtension("KHR_materials_unlit")}function hy(e){const t=new Eg(e),{json:r}=t;if(t.materials)for(const e of r.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}const py="KHR_techniques_webgl";async function fy(e){const t=new Eg(e),{json:r}=t,n=t.getExtension("KHR_techniques_webgl");if(n){const e=function(e,t){const{programs:r=[],shaders:n=[],techniques:i=[]}=e,a=new TextDecoder;return n.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=a.decode(t.getTypedArrayForBufferView(e.bufferView))}),r.forEach(e=>{e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]}),i.forEach(e=>{e.program=r[e.program]}),i}(n,t);for(const n of r.materials||[]){const r=t.getObjectExtension(n,"KHR_techniques_webgl");r&&(n.technique=Object.assign({},r,e[r.technique]),n.technique.values=my(n.technique,t)),t.removeObjectExtension(n,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}}async function dy(e,t){}function my(e,t){const r=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in r)&&(r[t]=e.uniforms[t].value)}),Object.keys(r).forEach(e=>{"object"==typeof r[e]&&void 0!==r[e].index&&(r[e].texture=t.getTexture(r[e].index))}),r}const gy="EXT_feature_metadata";async function yy(e){!function(e){var t;const r=e.getExtension("EXT_feature_metadata"),n=null==r||null===(t=r.schema)||void 0===t?void 0:t.classes,i=null==r?void 0:r.featureTables;(null==r?void 0:r.featureTextures)&&console.warn('featureTextures is not yet supported in the "EXT_feature_metadata" extension.');if(n&&i)for(const t in n){const r=n[t],a=wy(i,t);a&&by(e,a,r)}}(new Eg(e))}function by(e,t,r){for(const i in r.properties){var n;const a=r.properties[i],o=null==t||null===(n=t.properties)||void 0===n?void 0:n[i],s=t.count;if(o){const t=vy(e,a,s,o);o.data=t}}}function vy(e,t,r,n){const i=n.bufferView;let a=e.getTypedArrayForBufferView(i);switch(t.type){case"STRING":{const t=n.stringOffsetBufferView;a=function(e,t,r){const n=[],i=new TextDecoder("utf8");let a=0;for(let o=0;o<r;o++){const r=t[4*(o+1)]-t[4*o],s=e.subarray(a,r+a),u=i.decode(s);n.push(u),a+=r}return n}(a,e.getTypedArrayForBufferView(t),r);break}}return a}function wy(e,t){for(const r in e){const n=e[r];if(n.class===t)return n}return null}const _y=[a,o,s,u,l,h,p,c,f];function ky(e,t){var r;const n=(null==t||null===(r=t.gltf)||void 0===r?void 0:r.excludeExtensions)||{};return!(e in n&&!n[e])}function xy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Ey={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Sy={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Ay{constructor(){xy(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),xy(this,"json",void 0)}normalize(e,t){this.json=e.json;const r=e.json;switch(r.asset&&r.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version "+r.asset.version)}if(!t.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),function(e){const t=new Eg(e),{json:r}=t;for(const e of r.images||[]){const r=t.getObjectExtension(e,"KHR_binary_glTF");r&&Object.assign(e,r),t.removeObjectExtension(e,"KHR_binary_glTF")}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Ey)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const r=e[t];if(r&&!Array.isArray(r)){e[t]=[];for(const n in r){const i=r[n];i.id=i.id||n;const a=e[t].length;e[t].push(i),this.idToIndexMap[t][n]=a}}}_convertObjectIdsToArrayIndices(e){for(const t in Ey)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:r,material:n}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");r&&(t.indices=this._convertIdToIndex(r,"accessor")),n&&(t.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute "+t),e[t]=[]);for(const r of e[t])for(const e in r){const t=r[e],n=this._convertIdToIndex(t,e);r[e]=n}}_convertIdToIndex(e,t){const r=Sy[t];if(r in this.idToIndexMap){const n=this.idToIndexMap[r][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return n}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const i of e.materials){var t,r,n;i.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const a=(null===(t=i.values)||void 0===t?void 0:t.tex)||(null===(r=i.values)||void 0===r?void 0:r.texture2d_0)||(null===(n=i.values)||void 0===n?void 0:n.diffuseTex),o=e.textures.findIndex(e=>e.id===a);-1!==o&&(i.pbrMetallicRoughness.baseColorTexture={index:o})}}}function jy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Cy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ty={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},By=10240,Ry=10241,Oy=10242,Iy=10243,Py=10497,Dy={magFilter:By,minFilter:Ry,wrapS:Oy,wrapT:Iy},My={[By]:9729,[Ry]:9986,[Oy]:Py,[Iy]:Py};class Fy{constructor(){jy(this,"baseUri",""),jy(this,"json",{}),jy(this,"buffers",[]),jy(this,"images",[])}postProcess(e,t={}){const{json:r,buffers:n=[],images:i=[],baseUri:a=""}=e;return ug(r),this.baseUri=a,this.json=r,this.buffers=n,this.images=i,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(e.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(e.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(e.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(e.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(e.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(e.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t))),e.skins&&(e.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(e.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){return e.id=e.id||"scene-"+t,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return e.id=e.id||"node-"+t,e.children&&(e.children=e.children.map(e=>this.getNode(e))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((e,t)=>{const r=this.getMesh(t);return e.id=r.id,e.primitives=e.primitives.concat(r.primitives),e},{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-"+t,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-"+t,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const r in t)e.attributes[r]=this.getAccessor(t[r]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e})),e}_resolveMaterial(e,t){if(e.id=e.id||"material-"+t,e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var r,n;if(e.id=e.id||"accessor-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(r=e.componentType,Ty[r]),e.components=(n=e.type,Cy[n]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:r,byteLength:n}=_g(e,e.bufferView),i=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let a=t.arrayBuffer.slice(i,i+n);e.bufferView.byteStride&&(a=this._getValueFromInterleavedBuffer(t,i,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new r(a)}return e}_getValueFromInterleavedBuffer(e,t,r,n,i){const a=new Uint8Array(i*n);for(let o=0;o<i;o++){const i=t+o*r;a.set(new Uint8Array(e.arrayBuffer.slice(i,i+n)),o*n)}return a.buffer}_resolveTexture(e,t){return e.id=e.id||"texture-"+t,e.sampler="sampler"in e?this.getSampler(e.sampler):My,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||"sampler-"+t,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}return e}_enumSamplerParameter(e){return Dy[e]}_resolveImage(e,t){e.id=e.id||"image-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const r=this.images[t];return r&&(e.image=r),e}_resolveBufferView(e,t){const r=e.buffer,n={id:"bufferView-"+t,...e,buffer:this.buffers[r]},i=this.buffers[r].arrayBuffer;let a=this.buffers[r].byteOffset||0;return"byteOffset"in e&&(a+=e.byteOffset),n.data=new Uint8Array(i,a,e.byteLength),n}_resolveCamera(e,t){return e.id=e.id||"camera-"+t,e.perspective,e.orthographic,e}}const Ly=1735152710;function Ny(e,t=0,r={}){const n=new DataView(e),{magic:i=Ly}=r,a=n.getUint32(t,!1);return a===i||a===Ly}function zy(e,t,r=0,n={}){const i=new DataView(t),a=function(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))}`}(i,r+0),o=i.getUint32(r+4,!0),s=i.getUint32(r+8,!0);switch(Object.assign(e,{header:{byteOffset:r,byteLength:s,hasBinChunk:!1},type:a,version:o,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){ia(e.header.byteLength>20);const n=t.getUint32(r+0,!0),i=t.getUint32(r+4,!0);return r+=8,ia(0===i),Uy(e,t,r,n),r+=n,r+=qy(e,t,r,e.header.byteLength)}(e,i,r);case 2:return function(e,t,r,n){return ia(e.header.byteLength>20),function(e,t,r,n){for(;r+8<=e.header.byteLength;){const i=t.getUint32(r+0,!0),a=t.getUint32(r+4,!0);switch(r+=8,a){case 1313821514:Uy(e,t,r,i);break;case 5130562:qy(e,t,r,i);break;case 0:n.strict||Uy(e,t,r,i);break;case 1:n.strict||qy(e,t,r,i)}r+=hg(i,4)}}(e,t,r,n),r+e.header.byteLength}(e,i,r,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports v1 and v2.`)}}function Uy(e,t,r,n){const i=new Uint8Array(t.buffer,r,n),a=new TextDecoder("utf8").decode(i);return e.json=JSON.parse(a),hg(n,4)}function qy(e,t,r,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:t.buffer}),hg(n,4)}async function Hy(e,t,r=0,n,i){var a,o,s,u;!function(e,t,r,n){n.uri&&(e.baseUri=n.uri);if(t instanceof ArrayBuffer&&!Ny(t,r,n)){const e=new TextDecoder;t=e.decode(t)}if("string"==typeof t)e.json=sg(t);else if(t instanceof ArrayBuffer){const i={};r=zy(i,t,r,n.glb),ug("glTF"===i.type,"Invalid GLB magic string "+i.type),e._glb=i,e.json=i.json}else ug(!1,"GLTF: must be ArrayBuffer or string");const i=e.json.buffers||[];if(e.buffers=new Array(i.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const a=e.json.images||[];e.images=new Array(a.length).fill({})}(e,t,r,n),function(e,t={}){(new Ay).normalize(e,t)}(e,{normalize:null==n||null===(a=n.gltf)||void 0===a?void 0:a.normalize}),function(e,t={},r){const n=_y.filter(e=>ky(e.name,t));for(const a of n){var i;null===(i=a.preprocess)||void 0===i||i.call(a,e,t,r)}}(e,n,i);const c=[];if(null!=n&&null!==(o=n.gltf)&&void 0!==o&&o.loadBuffers&&e.json.buffers&&await async function(e,t,r){const n=e.json.buffers||[];for(let o=0;o<n.length;++o){const s=n[o];if(s.uri){var i,a;const{fetch:n}=r;ug(n);const u=cg(s.uri,t),c=await(null==r||null===(i=r.fetch)||void 0===i?void 0:i.call(r,u)),l=await(null==c||null===(a=c.arrayBuffer)||void 0===a?void 0:a.call(c));e.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else null===e.buffers[o]&&(e.buffers[o]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}(e,n,i),null!=n&&null!==(s=n.gltf)&&void 0!==s&&s.loadImages){const t=async function(e,t,r){const n=function(e){const t=new Set,r=e.json.textures||[];for(const e of r)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),i=e.json.images||[],a=[];for(const o of n)a.push(Gy(e,i[o],o,t,r));return await Promise.all(a)}(e,n,i);c.push(t)}const l=async function(e,t={},r){const n=_y.filter(e=>ky(e.name,t));for(const a of n){var i;await(null===(i=a.decode)||void 0===i?void 0:i.call(a,e,t,r))}}(e,n,i);return c.push(l),await Promise.all(c),null!=n&&null!==(u=n.gltf)&&void 0!==u&&u.postProcess?function(e,t){return(new Fy).postProcess(e,t)}(e,n):e}async function Gy(e,t,r,n,i){const{fetch:a,parse:o}=i;let s;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=cg(t.uri,n),r=await a(e);s=await r.arrayBuffer(),t.bufferView={data:s}}if(Number.isFinite(t.bufferView)){const r=lg(e.json,e.buffers,t.bufferView);s=oo(r.buffer,r.byteOffset,r.byteLength)}ug(s,"glTF image has no data");let u=await o(s,[Lu,Yl],{mimeType:t.mimeType,basis:n.basis||{format:Kl()}},i);u&&u[0]&&(u={compressed:!0,mipmaps:!1,width:u[0].width,height:u[0].height,data:u[0]}),e.images=e.images||[],e.images[r]=u}const Wy={name:"glTF",id:"gltf",module:"gltf",version:"3.3.0",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},r){(t={...Wy.options,...t}).gltf={...Wy.options.gltf,...t.gltf};const{byteOffset:n=0}=t;return await Hy({},e,n,t,r)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};const Vy=0,Ky=1;function Jy(e,t,r,n){e.rotateYtoZ=!0;const i=e.byteOffset+e.byteLength-r;if(0===i)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=oo(t,r,i),e.gltfByteOffset=0,e.gltfByteLength=i,r%4==0||console.warn(e.type+": embedded glb is not aligned to a 4-byte boundary."),e.byteOffset+e.byteLength}async function Qy(e,t,r,n){const i=r["3d-tiles"]||{};if(function(e,t,r){switch(t){case Vy:const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),r=(new TextDecoder).decode(t);e.gltfUrl=r.replace(/[\s\0]+$/,""),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Ky:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),i.loadGLTF){const{parse:t,fetch:i}=n;e.gltfUrl&&(e.gltfArrayBuffer=await i(e.gltfUrl,r),e.gltfByteOffset=0),e.gltfArrayBuffer&&(e.gltf=await t(e.gltfArrayBuffer,Wy,r,n),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function $y(e,t,r,n,i){var a;r=function(e,t,r,n,i){r=Km(e,t,r),r=Jm(e,t,r),r=Qm(e,t,r),r=Jy(e,t,r,n);const a=new Pm(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=a.getGlobalProperty("RTC_CENTER",Tm.FLOAT,3),r}(e,t,r,n),await Qy(e,Ky,n,i);const o=null==e||null===(a=e.gltf)||void 0===a?void 0:a.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),r}async function Yy(e,t,r,n,i){return r=function(e,t,r,n,i){if(r=Km(e,t,r),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Jm(e,t,r);const a=new DataView(t);if(e.gltfFormat=a.getUint32(r,!0),r=Qm(e,t,r+=4),r=Jy(e,t,r,n),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new Pm(e.featureTableJson,e.featureTableBinary),s=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=s,!Number.isFinite(s))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",Tm.FLOAT,3);new Vm(e.batchTableJson,e.batchTableBinary,s);return function(e,t,r,n){const i=[new Array(n),e._batchTable][0],a=new Cs,o=new Cs,s=new Cs,u=new Cs,c=new Ph,l=new op,h=new Cs,p={},f=new Gs,d=[],m=[],g=new Cs,y=new Cs;for(let r=0;r<n;r++){let n;if(t.hasProperty("POSITION"))n=t.getProperty("POSITION",Tm.FLOAT,3,r,a);else if(t.hasProperty("POSITION_QUANTIZED")){n=t.getProperty("POSITION_QUANTIZED",Tm.UNSIGNED_SHORT,3,r,a);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Tm.FLOAT,3,g);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const i=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Tm.FLOAT,3,y);if(!i)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const o=65535;for(let t=0;t<3;t++)n[t]=n[t]/o*i[t]+e[t]}if(!n)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");a.copy(n),p.translation=a,e.normalUp=t.getProperty("NORMAL_UP",Tm.FLOAT,3,r,d),e.normalRight=t.getProperty("NORMAL_RIGHT",Tm.FLOAT,3,r,m);const 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",Tm.UNSIGNED_SHORT,2,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Tm.UNSIGNED_SHORT,2,m),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(vu.WGS84.eastNorthUpToFixedFrame(a,f),f.getRotationMatrix3(c)):c.identity()}b&&(u.copy(o).cross(s).normalize(),c.setColumn(0,o),c.setColumn(1,s),c.setColumn(2,u)),l.fromMatrix3(c),p.rotation=l,h.set(1,1,1);const v=t.getProperty("SCALE",Tm.FLOAT,1,r);Number.isFinite(v)&&h.multiplyByScalar(v);const w=t.getProperty("SCALE_NON_UNIFORM",Tm.FLOAT,3,r,d);w&&h.scale(w),p.scale=h;let _=t.getProperty("BATCH_ID",Tm.UNSIGNED_SHORT,1,r);void 0===_&&(_=r);const k=(new Gs).fromQuaternion(p.rotation);f.identity(),f.translate(p.translation),f.multiplyRight(k),f.scale(p.scale);const x=f.clone();i[r]={modelMatrix:x,batchId:_}}e.instances=i}(e,o,0,s),r}(e,t,r,n),await Qy(e,e.gltfFormat,n,i),r}async function Xy(e,t=0,r,n,i={}){switch(i.byteOffset=t,i.type=function(e,t=0){const 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))}`}(e,t),i.type){case Am.COMPOSITE:return await async function(e,t,r,n,i,a){r=Km(e,t,r);const o=new DataView(t);for(e.tilesLength=o.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&e.byteLength-r>12;){const o={};e.tiles.push(o),r=await a(t,r,n,i,o)}return r}(i,e,t,r,n,Xy);case Am.BATCHED_3D_MODEL:return await $y(i,e,t,r,n);case Am.GLTF:return await async function(e,t,r,n){e.rotateYtoZ=!0,e.gltfUpAxis=r["3d-tiles"]&&r["3d-tiles"].assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y";const{parse:i}=n;e.gltf=await i(t,Wy,r,n)}(i,e,r,n);case Am.INSTANCED_3D_MODEL:return await Yy(i,e,t,r,n);case Am.POINT_CLOUD:return await ag(i,e,t,r,n);default:throw new Error("3DTileLoader: unknown type "+i.type)}}async function Zy(e,t,r,n){const i=e[t].bufferView,a=e.bufferViews[i],o=e.buffers[a.buffer];if(null==n||!n.url||!n.fetch)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(o.uri){const e=function(e,t){if(t.startsWith("http")){const r=new URL(e,t);return decodeURI(r.toString())}const r=new URL(e,"http://"+t);return`/${r.host}${r.pathname}`}(o.uri,null==n?void 0:n.url),t=await n.fetch(e),r=await t.arrayBuffer();return new Uint8Array(r,a.byteOffset,a.byteLength)}return new Uint8Array(r,a.byteOffset,a.byteLength)}function eb(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const tb={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:"3.3.0",extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,r){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const n=eb(e.slice(8,16)),i=new Uint8Array(e,24,n),a=new TextDecoder("utf8").decode(i),o=JSON.parse(a),s=eb(e.slice(16,24));let u=new ArrayBuffer(0);return s&&(u=e.slice(24+n)),"bufferView"in o.tileAvailability&&(o.tileAvailability.explicitBitstream=await Zy(o,"tileAvailability",u,r)),"bufferView"in o.contentAvailability&&(o.contentAvailability.explicitBitstream=await Zy(o,"contentAvailability",u,r)),"bufferView"in o.childSubtreeAvailability&&(o.childSubtreeAvailability.explicitBitstream=await Zy(o,"childSubtreeAvailability",u,r)),o},options:{}},rb={QUADTREE:4,OCTREE:8};function nb(e,t){return"constant"in e?Boolean(e.constant):!!e.explicitBitstream&&function(e,t){const r=Math.floor(e/8),n=e%8;return 1==(t[r]>>n&1)}(t,e.explicitBitstream)}function ib(e,t,r,n){const{basePath:i,refine:a,getRefine:o,lodMetricType:s,getTileType:u,rootLodMetricValue:c,rootBoundingVolume:l}=n,h=e.contentUrl&&e.contentUrl.replace(i+"/",""),p=c/2**t,f=function(e,t,r){if(t.region){const{childTileX:n,childTileY:i,childTileZ:a}=r,[o,s,u,c,l,h]=t.region,p=2**e,f=(u-o)/p,d=(c-s)/p,m=(h-l)/p,[g,y]=[o+f*n,o+f*(n+1)],[b,v]=[s+d*i,s+d*(i+1)],[w,_]=[l+m*a,l+m*(a+1)];return{region:[g,b,y,v,w,_]}}return console.warn("Unsupported bounding volume type: ",t),null}(t,l,r);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:o(a),type:u(e),lodMetricType:s,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function ab(e,t){return parseInt(e.toString(2)+t.toString(2),2)}function ob(e,t,r,n,i){const a=function(e){const t={};for(const r in e)t[`{${r}}`]=e[r];return t}({level:t,x:r,y:n,z:i});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>a[e])}function sb(e){if(!e.contentUrl)return mf;const t=e.contentUrl.split(".").pop();switch(t){case"pnts":return yf;case"i3dm":case"b3dm":case"glb":case"gltf":return gf;default:return t}}function ub(e){switch(e){case"REPLACE":case"replace":return df;case"ADD":case"add":return ff;default:return e}}function cb(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const r=new URL(e,t+"/");return decodeURI(r.toString())}return e.startsWith("/")?e:`${t}/${e}`}function lb(e,t){if(!e)return null;if(e.content){const r=e.content.uri||e.content.url;e.contentUrl=cb(r,t.basePath)}return e.id=e.contentUrl,e.lodMetricType=_f,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=sb(e),e.refine=ub(e.refine),e}async function hb(e,t,r,n){var i;const a=t.basePath,{subdivisionScheme:o,maximumLevel:s,subtreeLevels:u,subtrees:{uri:c}}=r,l=cb(ob(c,0,0,0,0),a),h=await Jo(l,tb,n),p=cb(e.content.uri,a),f=null==t||null===(i=t.root)||void 0===i?void 0:i.refine,d=e.geometricError,m=e.boundingVolume,g={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:u,maximumLevel:s,refine:f,basePath:a,lodMetricType:_f,rootLodMetricValue:d,rootBoundingVolume:m,getTileType:sb,getRefine:ub};return await async function(e,t,r){if(!e)return null;e.lodMetricType=_f,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform;const{children:n,contentUrl:i}=await async function e(t){const{options:r,parentData:n={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,globalData:a={level:0,mortonIndex:0,x:0,y:0,z:0}}=t;let{subtree:o,level:s=0}=t;const{subdivisionScheme:u,subtreeLevels:c,maximumLevel:l,contentUrlTemplate:h,subtreesUriTemplate:p,basePath:f}=r,d={children:[],lodMetricValue:0,contentUrl:""},m=rb[u],g=1&i,y=i>>1&1,b=i>>2&1,v=(m**s-1)/(m-1);let w=ab(n.mortonIndex,i),_=v+w,k=ab(n.x,g),x=ab(n.y,y),E=ab(n.z,b),S=!1;s+1>c&&(S=nb(o.childSubtreeAvailability,w));const A=ab(a.x,k),j=ab(a.y,x),C=ab(a.z,E),T=s+a.level;if(S){const e=ob(`${f}/${p}`,T,A,j,C);o=await Jo(e,tb),a.mortonIndex=w,a.x=k,a.y=x,a.z=E,a.level=s,w=0,_=0,k=0,x=0,E=0,s=0}if(!nb(o.tileAvailability,_)||s>l)return d;nb(o.contentAvailability,_)&&(d.contentUrl=ob(h,T,A,j,C));const B=s+1,R={mortonIndex:w,x:k,y:x,z:E};for(let t=0;t<m;t++){const n=await e({subtree:o,options:r,parentData:R,childIndex:t,level:B,globalData:a});if(n.contentUrl||n.children.length){const e=ib(n,T+1,{childTileX:k,childTileY:x,childTileZ:E},r);d.children.push(e)}}return d}({subtree:t,options:r});i&&(e.contentUrl=i,e.content={uri:i.replace(r.basePath+"/","")});return e.refine=ub(e.refine),e.type=sb(e),e.children=n,e.id=e.contentUrl,e}(e,h,g)}function pb(e){var t;return(null==e||null===(t=e.extensions)||void 0===t?void 0:t["3DTILES_implicit_tiling"])||(null==e?void 0:e.implicitTiling)}const fb={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:"3.3.0",extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t,r){const i=t["3d-tiles"]||{};let a;a="auto"===i.isTileset?r.url&&-1!==r.url.indexOf(".json"):i.isTileset;e=a?await async function(e,t,r){var i;const a=JSON.parse((new TextDecoder).decode(e));return a.loader=t.loader||fb,a.url=r.url,a.basePath=function(e){return n.dirname(e.url)}(a),a.root=await async function(e,t){const r=e.basePath;let n;const i=pb(null==e?void 0:e.root);n=i&&e.root?await hb(e.root,e,i,t):lb(e.root,e);const a=[];for(a.push(n);a.length>0;){const n=(a.pop()||{}).children||[];for(let i of n){const n=pb(i);n?i=await hb(i,e,n,t):lb(i,{basePath:r}),a.push(i)}}return n}(a,t),a.type=wf,a.lodMetricType=_f,a.lodMetricValue=(null===(i=a.root)||void 0===i?void 0:i.lodMetricValue)||0,a}(e,t,r):await async function(e,t,r){const n={content:{featureIds:null}};return await Xy(e,0,t,r,n.content),n.content}(e,t,r);return e},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function db(e,t){if(!t){const r=await async function(e){ia(e);const t={Authorization:"Bearer "+e},r=await va("https://api.cesium.com/v1/assets",{fetch:{headers:t}});if(!r.ok)throw new Error(r.statusText);return await r.json()}(e);for(const e of r.items)"3DTILES"===e.type&&(t=e.id)}const r=await async function(e,t){ia(e,t);const r={Authorization:"Bearer "+e},n="https://api.cesium.com/v1/assets/"+t;let i=await va(""+n,{fetch:{headers:r}});if(!i.ok)throw new Error(i.statusText);let a=await i.json();if(i=await va(n+"/endpoint",{fetch:{headers:r}}),!i.ok)throw new Error(i.statusText);const o=await i.json();return a={...a,...o},a}(e,t),{type:n,url:i}=r;return ia("3DTILES"===n&&i),r.headers={Authorization:"Bearer "+r.accessToken},r}const mb={...fb,id:"cesium-ion",name:"Cesium Ion",preload:async function(e,t={}){t=t["cesium-ion"]||{};const{accessToken:r}=t;let n=t.assetId;if(!Number.isFinite(n)){const t=e.match(/\/([0-9]+)\/tileset.json/);n=t&&t[1]}return db(r,n)},parse:async(e,t,r)=>((t={...t})["3d-tiles"]=t["cesium-ion"],t.loader=mb,fb.parse(e,t,r)),options:{"cesium-ion":{...fb.options["3d-tiles"],accessToken:null}}};var gb=r(11),yb=r.n(gb);const bb=new Uint8Array(256);let vb=bb.length;function wb(){return vb>bb.length-16&&(yb.a.randomFillSync(bb),vb=0),bb.slice(vb,vb+=16)}var _b=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;var kb=function(e){return"string"==typeof e&&_b.test(e)};const xb=[];for(let e=0;e<256;++e)xb.push((e+256).toString(16).substr(1));var Eb=function(e,t=0){const r=(xb[e[t+0]]+xb[e[t+1]]+xb[e[t+2]]+xb[e[t+3]]+"-"+xb[e[t+4]]+xb[e[t+5]]+"-"+xb[e[t+6]]+xb[e[t+7]]+"-"+xb[e[t+8]]+xb[e[t+9]]+"-"+xb[e[t+10]]+xb[e[t+11]]+xb[e[t+12]]+xb[e[t+13]]+xb[e[t+14]]+xb[e[t+15]]).toLowerCase();if(!kb(r))throw TypeError("Stringified UUID is invalid");return r};var Sb=function(e,t,r){const n=(e=e||{}).random||(e.rng||wb)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return Eb(n)},Ab=r(66),jb=r.n(Ab);function Cb(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Tb{constructor(e,t,r){Cb(this,"nodesPerPage",void 0),Cb(this,"nodesCounter",void 0),Cb(this,"writeFile",void 0),Cb(this,"converter",void 0),Cb(this,"nodePages",void 0),Cb(this,"length",0),this.nodesPerPage=t,this.nodesCounter=0,this.nodePages=[{}],this.nodePages[0].nodes=[],this.writeFile=e,this.converter=r,this.length=0}useWriteFunction(e){this.writeFile=e}getNodePageFileName(e){let t,r;return this.converter.options.slpk?(t=Object(qi.join)(this.converter.layers0Path,"nodepages"),r=e.toString()+".json"):(t=Object(qi.join)(this.converter.layers0Path,"nodepages",e.toString()),r="index.json"),{filePath:t,fileName:r}}async loadNodePage(e){const{filePath:t,fileName:r}=this.getNodePageFileName(e),n=Object(qi.join)(t,r);return await async function(e){try{return await Ae.promises.stat(e),!0}catch{return!1}}(n)?(console.log(`load ${n}.`),await um(t,r)):{nodes:[]}}getPageIndexByNodeId(e){return Math.floor(e/this.nodesPerPage)}async getPageByNodeId(e){const t=this.getPageIndexByNodeId(e);return this.converter.options.instantNodeWriting?await this.loadNodePage(t):this.nodePages[t]}async getNodeById(e,t){const r=e%this.nodesPerPage;return(t=t||await this.getPageByNodeId(e)).nodes[r]}async addChildRelation(e,t){var r;if(null==e)return;const n=await this.getNodeById(e);null===(r=n.children)||void 0===r||r.push(t),await this.saveNode(n)}async push(e,t){if(e.index=this.nodesCounter++,!this.converter.options.instantNodeWriting){let t=this.nodePages[this.nodePages.length-1];t.nodes.length===this.nodesPerPage&&(t={nodes:[]},this.nodePages.push(t)),t.nodes.push(e)}return await this.addChildRelation(t,e.index),Tb.updateResourceInMesh(e),await this.saveNode(e),e}async saveNode(e){if(this.converter.options.instantNodeWriting){const t=this.getPageIndexByNodeId(e.index),r=await this.getPageByNodeId(e.index),{filePath:n,fileName:i}=this.getNodePageFileName(t),a=await this.getNodeById(e.index,r);a?Tb.updateAll(a,e):r.nodes.push(e);const o=JSON.stringify(r);this.converter.options.slpk?await this.converter.writeQueue.enqueue({archiveKey:`nodePages/${t.toString()}.json.gz`,writePromise:()=>this.writeFile(n,o,i,!0,this.converter.compressList)},!0):await this.converter.writeQueue.enqueue({writePromise:()=>this.writeFile(n,o)},!0)}}async saveMetadata(){const e=Vi()({nodeCount:this.nodesCounter},{folderPattern:{path:"folderPattern",default:"BASIC"},archiveCompressionType:{path:"archiveCompressionType",default:"STORE"},resourceCompressionType:{path:"resourceCompressionType",default:"GZIP"},I3SVersion:{path:"I3SVersion",default:"1.8"},nodeCount:{path:"nodeCount"}});await this.converter.writeQueue.enqueue({archiveKey:"metadata.json",writePromise:()=>this.writeFile(this.converter.layers0Path,JSON.stringify(e),"metadata.json",!1)})}async save(){if(this.converter.options.instantNodeWriting)await this.saveMetadata();else if(this.converter.options.slpk){for(const[e,t]of this.nodePages.entries()){const r=JSON.stringify(t),n=Object(qi.join)(this.converter.layers0Path,"nodepages");await this.converter.writeQueue.enqueue({archiveKey:`nodePages/${e.toString()}.json.gz`,writePromise:()=>this.writeFile(n,r,e.toString()+".json")})}await this.saveMetadata()}else for(const[e,t]of this.nodePages.entries()){const r=JSON.stringify(t),n=Object(qi.join)(this.converter.layers0Path,"nodepages",e.toString());await this.converter.writeQueue.enqueue({writePromise:()=>this.writeFile(n,r)})}}static updateResourceInMesh(e){e.mesh&&isFinite(e.index)&&(e.mesh.geometry.resource=e.index)}static updateAll(e,t){return Object.assign(e,t,{index:e.index}),Tb.updateResourceInMesh(e),e}static updateMaterialByNodeId(e,t){e.mesh&&(e.mesh.material={definition:t,resource:e.index})}static updateVertexCountByNodeId(e,t){e.mesh&&(e.mesh.geometry.vertexCount=t)}static updateNodeAttributeByNodeId(e){e.mesh&&e.index&&(e.mesh.attribute.resource=e.index)}static updateFeatureCountByNodeId(e,t){e.mesh&&(e.mesh.geometry.featureCount=t)}static updateTexelCountHintByNodeId(e,t){e.mesh&&e.mesh.material&&(e.mesh.material.texelCountHint=t)}}function Bb(e){const{positions:t,normals:r,texCoords:n,colors:i,uvRegions:a,featureIndices:o}=e,s=t.length/9;if(!o.length)return{faceRange:new Uint32Array([0,s-1]),featureIds:[0],featureCount:1,positions:t,normals:r,texCoords:n,colors:i,uvRegions:a};const u=function(e){let t=1,r=1,n=Rb(e.slice(0,3));const i=[],a=[],o=[n];i[0]=0,a[0]=n;for(let s=3;s<e.length;s+=3){const u=Rb(e.slice(s,s+3));n!==u&&(i[t]=s/3-1,i[t+1]=s/3,a[r]=u,o.includes(u)||o.push(u),t+=2,r+=1),n=u}i[t]=e.length/3-1;const s=new Uint32Array(i),u=o.length;return{faceRange:s,featureCount:u,featureIds:a}}(o);return function(e,t){const r=e[0],n=[r.featureId||0];let i=new Float32Array(r.positions),a=new Float32Array(r.normals),o=new Uint8Array(r.colors),s=new Uint16Array(r.uvRegions),u=new Float32Array(r.texCoords);const c=[0];let l=0,h=0;for(let t=1;t<e.length;t++){const r=e[t];n.push(r.featureId||0),i=ao(i,r.positions),a=ao(a,r.normals),o=ao(o,r.colors),s=ao(s,r.uvRegions),u=ao(u,r.texCoords);const p=e[l];c.push(p.positions.length/9-1+h),c.push(p.positions.length/9+h),h+=p.positions.length/9,l+=1}c.push(i.length/9-1);return{faceRange:new Uint32Array(c),featureIds:n,positions:i,normals:a,colors:o,uvRegions:s,texCoords:u,featureCount:t}}(function(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r],i=t.find(e=>e.featureId===n.featureId);i?(i.positions=ao(i.positions,n.positions),i.normals=ao(i.normals,n.normals),i.colors=ao(i.colors,n.colors),i.texCoords=ao(i.texCoords,n.texCoords)):t.push(n)}return t}(function(e){const{featureIds:t,positions:r,normals:n,colors:i,uvRegions:a,texCoords:o,faceRange:s=new Uint32Array(0)}=e,u=[];let c=new Float32Array(r),l=new Float32Array(n),h=new Uint8Array(i),p=new Float32Array(o),f=new Uint16Array(a);for(let e=0;e<t.length;e++){const r=s[2*e],n=s[2*e+1],i=Ob("positions",r,n),a=Ob("normals",r,n),o=Ob("colors",r,n),d=Ob("uvRegions",r,n),m=Ob("texCoords",r,n);u.push({featureId:t[e],positions:c.slice(0,i),normals:l.slice(0,a),colors:h.slice(0,o),uvRegions:f.slice(0,d),texCoords:p.slice(0,m)}),c=c.slice(i),l=l.slice(a),h=h.slice(o),f=f.slice(d),p=p.slice(m)}return u.sort((e,t)=>e.featureId-t.featureId)}({...u,...e})),u.featureCount)}function Rb(e){const t={};let r=e[0],n=1;for(const i of e)t[i]=(t[i]||0)+1,n=n>t[i]?n:t[i],r=n>t[i]?r:i;return r}function Ob(e,t,r){const n=r-t+1,i=3*n;switch(e){case"positions":case"normals":return 9*n;case"colors":case"uvRegions":return 4*i;case"texCoords":return 2*i;default:return 0}}function Ib(e){const t={};for(const r in e)t[r]={value:e[r].value};return t}function Pb(e){var t,r,n,i,a,o,s,u;let c=(null===(t=e.gltf)||void 0===t||null===(r=t.scene)||void 0===r?void 0:r.nodes)||(null===(n=e.gltf)||void 0===n||null===(i=n.scenes)||void 0===i||null===(a=i[0])||void 0===a?void 0:a.nodes)||(null===(o=e.gltf)||void 0===o?void 0:o.nodes)||[];const l=(null===(s=e.gltf)||void 0===s||null===(u=s.images)||void 0===u?void 0:u.map(e=>{var t;if(null!=e&&null!==(t=e.image)&&void 0!==t&&t.compressed)return{data:null,compressed:!0};{var r;const t=null==e||null===(r=e.image)||void 0===r?void 0:r.data,n=new Uint8Array(t.length);return n.set(t),{data:n,compressed:!1,height:e.image.height,width:e.image.width,components:e.image.components,mimeType:e.mimeType}}}))||[];!function e(t){for(let n=0;n<t.length;n++){const i=t[n];var r;if(i.mesh)t[n]={...i,mesh:{...i.mesh,primitives:null===(r=i.mesh)||void 0===r?void 0:r.primitives.map(e=>{var t,r,n;return{...e,indices:{value:null==e||null===(t=e.indices)||void 0===t?void 0:t.value},attributes:Ib(e.attributes),material:{id:null==e||null===(r=e.material)||void 0===r?void 0:r.id,uniqueId:null==e||null===(n=e.material)||void 0===n?void 0:n.uniqueId}}})}};i.children&&e(i.children)}}(c);return{nodes:c,images:l,cartographicOrigin:e.cartographicOrigin,cartesianModelMatrix:e.cartesianModelMatrix}}function Db(e,t,r){var n,i,a,o;const s=null==t||null===(n=t.featureIdAttributes)||void 0===n?void 0:n[0];if(null!=s&&null!==(i=s.featureIds)&&void 0!==i&&i.attribute){return e[s.featureIds.attribute].value}if(null!=s&&null!==(a=s.featureIds)&&void 0!==a&&a.hasOwnProperty("constant")&&null!=s&&null!==(o=s.featureIds)&&void 0!==o&&o.hasOwnProperty("divisor")){var u;return function(e,t=0,r=0){let n=[];if(r>0){let i=t,a=r;for(let t=0;t<e;t++)n.push(i),a-=1,0===a&&(i++,a=r)}else n=Array(e).fill(t,0,e);return n}((null==e||null===(u=e.POSITIONS)||void 0===u?void 0:u.value.length)/3||0,s.featureIds.constant,s.featureIds.divisor)}const c=(null==t?void 0:t.featureIdTextures)&&(null==t?void 0:t.featureIdTextures[0]);if(c){var l,h;return function(e,t,r){var n,i,a;if(null==r||!r.length)return[];const o=null==e||null===(n=e.featureIds)||void 0===n||null===(i=n.texture)||void 0===i?void 0:i.index,s=null==e||null===(a=e.featureIds)||void 0===a?void 0:a.channels;if(!s||void 0===o)return[];const u=r[o],c=[],l={r:0,g:1,b:2,a:3}[s];if(u.compressed)console.warn(`Can't get batch Ids from ${u.mimeType} compressed texture`);else for(let e=0;e<t.length;e+=2){const r=t[e],n=t[e+1],i=Math.min(Mb(r)*u.width|0,u.width-1),a=(Math.min(Mb(n)*u.height|0,u.height-1)*u.width+i)*u.components+l,o=new Uint8Array(u.data)[a];c.push(o)}return c}(c,e["TEXCOORD_"+((null==c||null===(l=c.featureIds)||void 0===l||null===(h=l.texture)||void 0===h?void 0:h.texCoord)||0)].value,r)}return(null==t?void 0:t.featureTextures)&&(null==t?void 0:t.featureTextures[0])?(console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive"),[]):[]}function Mb(e){return(e%1+1)%1}function Fb(e,t){const r=[];for(const n of t){const t=e[n]||null;r.push(t)}return r}function Lb(e,t){return"OBJECTID"===e?"OBJECTID":"string"==typeof t?"string":"number"==typeof t?Number.isInteger(t)?"Int32":"double":"string"}function Nb(e,t,r){const n={key:"f_"+e,name:t,ordering:["attributeValues"],header:[{property:"count",valueType:"UInt32"}],attributeValues:{valueType:"Int32",valuesPerElement:1}};switch(r){case"OBJECTID":!function(e){e.attributeValues={valueType:"Oid32",valuesPerElement:1}}(n);break;case"string":Hb(n);break;case"double":!function(e){e.attributeValues={valueType:"Float64",valuesPerElement:1}}(n);break;case"Int32":break;default:Hb(n)}return n}function zb(e){switch(e){case"OBJECTID":return"esriFieldTypeOID";case"string":return"esriFieldTypeString";case"Int32":return"esriFieldTypeInteger";case"double":return"esriFieldTypeDouble";default:return"esriFieldTypeString"}}function Ub(e,t){return{name:e,type:t,alias:e}}function qb(e){const t=[],r=[];for(const r in e)t.push({fieldName:r,visible:!0,isEditable:!1,label:r});return r.push({fieldInfos:t,type:"fields"}),{title:"{OBJECTID}",mediaInfos:[],popupElements:r,fieldInfos:t,expressionInfos:[]}}function Hb(e){e.ordering.unshift("attributeByteCounts"),e.header.push({property:"attributeValuesByteCount",valueType:"UInt32"}),e.attributeValues={valueType:"String",encoding:"UTF-8",valuesPerElement:1},e.attributeByteCounts={valueType:"UInt32",valuesPerElement:1}}const Gb=["CUSTOM_ATTRIBUTE_2","_BATCHID","BATCHID"];let Wb=new Cs;async function Vb(e,t,r,n,i,a,o,s,u,c){var l;const h=o,p=await async function(e=[],t){let r=[];for(const t of e)r.push(av(t));t&&(r=await async function(e){const t=[];for(;e.length>0;){let i=e.splice(0,1)[0];const a=[];for(let t=0;t<e.length;t++){const r=e[t];(i.texture&&r.texture||!i.texture&&!r.texture)&&(i=await iv(i,r),a.push(t))}if(i.texture&&a.length){var r,n;const e=null===(r=i.mergedMaterials)||void 0===r?void 0:r.reduce((e,{textureSize:t})=>e+((null==t?void 0:t.width)||0),0),t=null===(n=i.mergedMaterials)||void 0===n?void 0:n.reduce((e,{textureSize:t})=>Math.max(e,(null==t?void 0:t.height)||0),0);let a=-1;for(const r of i.mergedMaterials)if(r.textureSize){const n=a+1+r.textureSize.width/e*2**(8*Uint16Array.BYTES_PER_ELEMENT)-1;r.uvRegion=new Uint16Array([a+1,0,n,r.textureSize.height/t*2**(8*Uint16Array.BYTES_PER_ELEMENT)-1]),a=n}i.texture.image.width=e,i.texture.image.height=t}for(const t of a.reverse())e.splice(t,1);t.push(i)}t.length||t.push({material:{alphaMode:"opaque",pbrMetallicRoughness:{metallicFactor:1,roughnessFactor:1}},mergedMaterials:[{originalMaterialId:"default"}]});return t}(r));return r}(null===(l=e.gltf)||void 0===l?void 0:l.materials,s),f=Pb(e),d=await async function(e,t,r){const{nodes:n,images:i,cartographicOrigin:a,cartesianModelMatrix:o}=e,s=new Map;for(const e of t){const t={positions:new Float32Array(0),normals:new Float32Array(0),texCoords:new Float32Array(0),colors:new Uint8Array(0),uvRegions:new Uint16Array(0),featureIndicesGroups:[],featureIndices:[],boundingVolumes:null,mergedMaterials:e.mergedMaterials};for(const r of e.mergedMaterials)s.set(r.originalMaterialId,t)}Jb(n,i,a,o,s,r);for(const e of s.keys()){const t=s.get(e);t&&(0!==t.positions.length?t.featureIndicesGroups&&(t.featureIndices=t.featureIndicesGroups.reduce((e,t)=>e.concat(t)),delete t.featureIndicesGroups):s.delete(e))}return s}(f,p,h);o&&function(e,t){for(const r of e.values()){const e=gm(r.positions,t);r.boundingVolumes=e;const n=e.obb.center;for(let e=0;e<r.positions.length;e+=3){const i=r.positions.subarray(e,e+3);vu.WGS84.cartesianToCartographic(Array.from(i),Wb),Wb[2]=Wb[2]-t.getHeight(Wb[1],Wb[0]),Wb=Wb.subtract(n),r.positions.set(Wb,e)}}}(d,u);const m=[];for(const o of p){const s=o.mergedMaterials[0].originalMaterialId;if(!d.has(s))continue;const u=d.get(s);if(!u)continue;const{material:l,texture:h}=o,p=await t();m.push(await Kb({convertedAttributes:u,material:l,texture:h,tileContent:e,nodeId:p,featuresHashArray:n,propertyTable:r,attributeStorageInfo:i,draco:a,workerSource:c}))}return m.length?m:null}async function Kb({convertedAttributes:e,material:t,texture:r,tileContent:n,nodeId:i,featuresHashArray:a,propertyTable:o,attributeStorageInfo:s,draco:u,workerSource:c}){var l;const h=e.boundingVolumes,p=e.positions.length/3,{faceRange:f,featureIds:d,positions:m,normals:g,colors:y,uvRegions:b,texCoords:v,featureCount:w}=Bb(e);n.batchTableJson&&function(e,t,r,n){const i=function(e,t,r){const n={};for(let i=0;i<e.length;i++){const a=e[i],o=hv(i,t,r);n[a.toString()]=o}return n}(e,n,r);pv(t,i),pv(e,i)}(d,e.featureIndices,a,n.batchTableJson);const _=new Uint32Array(2),k=function(e){const t=new BigUint64Array(e.length);for(let r=0;r<e.length;r++)t[r]=BigInt(e[r]);return t}(d);_.set([p,w],0);const x=new Uint8Array(io(_.buffer,m.buffer,g.buffer,r?v.buffer:new ArrayBuffer(0),y.buffer,b,k.buffer,f.buffer)),E=u?async function(e,t,r,n){const{positions:i,normals:a,texCoords:o,colors:s,uvRegions:u,featureIds:c,faceRange:l}=r,h=new Uint32Array(e);for(let e=0;e<h.length;e++)h.set([e],e);const p=function(e,t){const r=new Uint32Array(e.length);let n=0,i=0;for(let e=1;e<t.length;e+=2){const a=3*(t[e]+1);r.fill(n,i,a),n++,i=a+1}return r}(new Uint32Array(t.featureIndices.length?t.featureIndices:e),l),f={positions:i,normals:a,colors:s,"feature-index":p};o.length&&(f.texCoords=o);const d={"feature-index":{"i3s-attribute-type":"feature-index","i3s-feature-ids":new Int32Array(c)}};u.length&&(f["uv-region"]=u,d["uv-region"]={"i3s-attribute-type":"uv-region"});return Em({attributes:f,indices:h},Cc,{...Cc.options,source:n,reuseWorkers:!0,_nodeWorkers:!0,draco:{method:"MESH_SEQUENTIAL_ENCODING",attributesMetadata:d}})}(p,e,{positions:m,normals:g,texCoords:r?v:new Float32Array(0),colors:y,uvRegions:b,featureIds:d,faceRange:f},c.draco):null;let S=[];return s&&o&&(S=function(e,t,r){const n=[],i=function(e,t){let r=!1;for(const n of Object.values(t))e.length!==n.length&&(r=!0);return r}(e,t)?function(e,t){const r={};for(const n in t){const i=t[n];r[n]=Fb(i,e)}return r}(e,t):t,a={OBJECTID:e,...i};for(const e in a){const t=dv(e,r),i=a[e],o=fv(t,i);n.push(o)}return n}(d,o,s)),{nodeId:i,geometry:x,compressedGeometry:E,texture:r,hasUvRegions:Boolean(b.length),sharedResources:sv((null===(l=n.gltf)||void 0===l?void 0:l.materials)||[],i),meshMaterial:t,vertexCount:p,attributes:S,featureCount:w,boundingVolumes:h}}function Jb(e,t,r,n,i,a,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){if(e)for(const s of e)Qb(s,t,r,n,i,a,o)}function Qb(e,t,r,n,i,a,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){const s=function(e,t){let r=t;const{matrix:n,rotation:i,scale:a,translation:o}=e;return n&&(r=t.multiplyRight(n)),o&&(r=r.translate(o)),i&&(r=r.rotateXYZ(i)),a&&(r=r.scale(a)),r}(e,o),u=e.mesh;u&&function(e,t,r,n,i,a=!1,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){for(const m of e.primitives){var s,u,c,l,h;let e,g=null;var p,f;if(m.material)g=i.get(m.material.uniqueId),e=null===(p=g)||void 0===p||null===(f=p.mergedMaterials.find(({originalMaterialId:e})=>{var t;return e===(null===(t=m.material)||void 0===t?void 0:t.uniqueId)}))||void 0===f?void 0:f.uvRegion;else i.has("default")&&(g=i.get("default"));ia(null!==g,"Primitive - material mapping failed");const y=m.attributes;if(g){var d;if(g.positions=ao(g.positions,$b({vertices:y.POSITION.value,cartographicOrigin:r,cartesianModelMatrix:n,nodeMatrix:o,indices:null===(s=m.indices)||void 0===s?void 0:s.value,attributeSpecificTransformation:Yb,useCartesianPositions:a})),g.normals=ao(g.normals,$b({vertices:y.NORMAL&&y.NORMAL.value,cartographicOrigin:r,cartesianModelMatrix:n,nodeMatrix:o,indices:null===(u=m.indices)||void 0===u?void 0:u.value,attributeSpecificTransformation:Xb,useCartesianPositions:!1})),g.texCoords=ao(g.texCoords,Zb(y.TEXCOORD_0&&y.TEXCOORD_0.value,null===(c=m.indices)||void 0===c?void 0:c.value)),g.colors=ao(g.colors,ev(y.COLOR_0,null===(l=m.indices)||void 0===l?void 0:l.value)),e)g.uvRegions=ao(g.uvRegions,tv(e,null===(d=m.indices)||void 0===d?void 0:d.value));g.featureIndicesGroups=g.featureIndicesGroups||[],g.featureIndicesGroups.push(rv(nv(y,m,t),null===(h=m.indices)||void 0===h?void 0:h.value))}}}(u,t,r,n,i,a,s),Jb(e.children||[],t,r,n,i,a,s)}function $b(e){const{vertices:t,indices:r,attributeSpecificTransformation:n}=e,i=new Float32Array(3*r.length);if(!t)return i;for(let a=0;a<r.length;a++){const o=3*r[a],s=t.subarray(o,o+3);let u=new Cs(Array.from(s));u=n(u,e),i[3*a]=u.x,i[3*a+1]=u.y,i[3*a+2]=u.z}return i}function Yb(e,t){const{cartesianModelMatrix:r,cartographicOrigin:n,nodeMatrix:i,useCartesianPositions:a}=t;return i&&(e=e.transform(i)),e=e.transform(r),a?e:(vu.WGS84.cartesianToCartographic([e[0],e[1],e[2]],e),e=e.subtract(n))}function Xb(e,t){const{cartesianModelMatrix:r,nodeMatrix:n}=t;return n&&(e=e.transformAsVector(n)),e=e.transformAsVector(r)}function Zb(e,t){const r=new Float32Array(2*t.length);if(!e)return r.fill(1),r;for(let n=0;n<t.length;n++){const i=2*t[n],a=e.subarray(i,i+2);r[2*n]=a[0],r[2*n+1]=a[1]}return r}function ev(e,t){const r=(null==e?void 0:e.components)||4,n=new Uint8Array(t.length*r);if(!e)return n.fill(255),n;const i=e.value;for(let e=0;e<t.length;e++){const a=t[e]*r,o=i.subarray(a,a+r),s=new Uint8Array(r);for(let e=0;e<o.length;e++)s[e]=255*o[e];n.set(s,e*r)}return n}function tv(e,t){const r=new Uint16Array(4*t.length);for(let t=0;t<r.length;t+=4)r.set(e,t);return r}function rv(e,t){if(!e.length||!t.length)return[];const r=[];for(let n=0;n<t.length;n++){const i=t[n];r.push(e[i])}return r}function nv(e,t,r){const n=function(e,t,r){const n=null==t?void 0:t.extensions;if(!n)return[];for(const[t,i]of Object.entries(n||{}))switch(t){case"EXT_feature_metadata":return Db(e,i,r);case"EXT_mesh_features":return console.warn("EXT_mesh_features extension is not supported yet"),[];default:return[]}return[]}(e,t,r);if(n.length)return n;for(let t=0;t<Gb.length;t++){const r=Gb[t];if(e[r]&&e[r].value)return e[r].value}return[]}async function iv(e,t){var n,i;if(null!==(n=e.texture)&&void 0!==n&&n.bufferView&&null!==(i=t.texture)&&void 0!==i&&i.bufferView&&e.mergedMaterials&&t.mergedMaterials){const n=Buffer.from(e.texture.bufferView.data),i=Buffer.from(t.texture.bufferView.data);try{const{joinImages:t}=await Promise.resolve().then(r.t.bind(null,549,7)),a=await t([n,i],{direction:"horizontal"});e.texture.bufferView.data=await a.toFormat("image/png"===e.texture.mimeType?"png":"jpeg").toBuffer()}catch(e){throw console.log("Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)"),e}e.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId=1}return e.mergedMaterials=e.mergedMaterials.concat(t.mergedMaterials),e}function av(e){var t,r,n,i;const a={doubleSided:e.doubleSided,emissiveFactor:null===(t=e.emissiveFactor)||void 0===t?void 0:t.map(e=>Math.round(255*e)),alphaMode:ov(e.alphaMode),pbrMetallicRoughness:{roughnessFactor:(null==e||null===(r=e.pbrMetallicRoughness)||void 0===r?void 0:r.roughnessFactor)||1,metallicFactor:(null==e||null===(n=e.pbrMetallicRoughness)||void 0===n?void 0:n.metallicFactor)||1}};let o;null!=e&&null!==(i=e.pbrMetallicRoughness)&&void 0!==i&&i.baseColorTexture?(o=e.pbrMetallicRoughness.baseColorTexture.texture.source,a.pbrMetallicRoughness.baseColorTexture={textureSetDefinitionId:0}):e.emissiveTexture&&(o=e.emissiveTexture.texture.source,a.pbrMetallicRoughness.baseColorTexture={textureSetDefinitionId:0});const s=Sb();e.uniqueId=s;let u=[{originalMaterialId:s}];if(o)u[0].textureSize={width:o.image.width,height:o.image.height};else{var c;const t=null==e||null===(c=e.pbrMetallicRoughness)||void 0===c?void 0:c.baseColorFactor;a.pbrMetallicRoughness.baseColorFactor=t&&t.map(e=>Math.round(255*e))||void 0}return{material:a,texture:o,mergedMaterials:u}}function ov(e){switch(e){case"OPAQUE":return"opaque";case"MASK":return"mask";case"BLEND":return"blend";default:return"opaque"}}function sv(e,t){const r={};if(!e||!e.length)return r;r.materialDefinitionInfos=[];for(const n of e){const{materialDefinitionInfo:e,textureDefinitionInfo:i}=uv(n,t);r.materialDefinitionInfos.push(e),i&&(r.textureDefinitionInfos=r.textureDefinitionInfos||[],r.textureDefinitionInfos.push(i))}return r}function uv(e,t){var r;const n=(null==e||null===(r=e.pbrMetallicRoughness)||void 0===r?void 0:r.baseColorTexture)||e.emissiveTexture;let i=null;n&&(i=function(e,t){var r,n,i;return{encoding:null!=e&&null!==(r=e.source)&&void 0!==r&&r.mimeType?[e.source.mimeType]:void 0,images:[{id:lv(e,t),size:null===(n=e.source)||void 0===n?void 0:n.image.width,length:[null===(i=e.source)||void 0===i?void 0:i.image.data.length]}]}}(n.texture,t));const{baseColorFactor:a,metallicFactor:o}=(null==e?void 0:e.pbrMetallicRoughness)||{};let s=a;return a&&0!==a[3]||!e.emissiveFactor||(s=e.emissiveFactor,s[3]=s[3]||1),{materialDefinitionInfo:cv(s||[1,1,1,1],o),textureDefinitionInfo:i}}function cv(e,t=1){const r=new Lh(0,0,0,1),n=new Lh(1,1,1,1),i=new Lh(.04/255,.04/255,.04/255,0),a=new Lh(e),o=n.subtract(i).multiply(a),s=o.lerp(o,r,t);i[3]=1;const u=i.lerp(i,a,t);return{params:{diffuse:s.toArray(),specular:u.toArray(),renderMode:"solid"}}}function lv(e,t){var r;const{width:n,height:i}=null===(r=e.source)||void 0===r?void 0:r.image,a=t+1,o=32-a.toString(2).length,s="0".repeat(o).concat(a.toString(2));return BigInt(`0b${(268435456+(n-1<<12)+(i-1<<0)).toString(2)}${s}`).toString()}function hv(e,t,r){const n=function(e,t){let r="";for(const n in e)r+=e[n][t];return r}(t,e),i=jb()(n);return r.includes(i)?r.indexOf(i):r.push(i)-1}function pv(e,t){for(let r=0;r<e.length;r++)e[r]=t[e[r]]}function fv(e,t){let r;switch(e){case"Oid32":case"Int32":r=function(e){const t=new Uint32Array([e.length]),r=new Uint32Array(e);return io(t.buffer,r.buffer)}(t);break;case"Float64":r=function(e){const t=new Uint32Array([e.length]),r=new Uint8Array(4),n=new Float64Array(e);return io(t.buffer,r.buffer,n.buffer)}(t);break;case"string":r=mv(t);break;default:r=mv(t)}return r}function dv(e,t){return t.find(t=>t.name===e).attributeValues.valueType}function mv(e){const t=new Uint32Array([e.length]);let r=0;const n=new Uint32Array(e.length),i=[];for(let t=0;t<e.length;t++){const a=String(e[t])+"\0",o=Buffer.from(a),s=o.length;r+=s,n[t]=s,i.push(o)}const a=new Uint32Array([r]);return io(t.buffer,a.buffer,n.buffer,...i)}function gv(e){const t=null==e?void 0:e.batchTableJson;if(t)return t;const{extensionName:r,extension:n}=function(e){var t,r,n;const i=["EXT_feature_metadata","EXT_mesh_features"];if(!(null==e||null===(t=e.gltf)||void 0===t?void 0:t.extensionsUsed))return{extensionName:null,extension:null};let a="";for(const t of(null==e||null===(o=e.gltf)||void 0===o?void 0:o.extensionsUsed)||[]){var o;if(i.includes(t)){a=t;break}}const s=null==e||null===(r=e.gltf)||void 0===r||null===(n=r.extensions)||void 0===n?void 0:n[a];return{extensionName:a,extension:s}}(e);switch(r){case"EXT_mesh_features":return console.warn("The I3S converter does not yet support the EXT_mesh_features extension"),null;case"EXT_feature_metadata":return function(e){if(null!=e&&e.featureTextures)return console.warn("The I3S converter does not yet support the EXT_feature_metadata feature textures"),null;if(null!=e&&e.featureTables){var t;const r=null===(t=Object.keys(e.featureTables))||void 0===t?void 0:t[0];if(r){const t=null==e?void 0:e.featureTables[r],n={};for(const e in t.properties)n[e]=t.properties[e].data;return n}}return console.warn("The I3S converter couldn't handle EXT_feature_metadata extension"),null}(n);default:return null}}const yv={id:{path:"id",transform:e=>e.toUpperCase()},profile:{path:"profile",default:"meshpyramids"},version:{path:"version",default:"1.8"},resourcePattern:{path:"resourcePattern",default:["3dNodeIndexDocument","Attributes","SharedResource","Geometry"]},rootNode:{path:"rootNode",default:"./nodes/root"},extent:{path:"extent"},indexCRS:{path:"indexCRS",default:"http://www.opengis.net/def/crs/EPSG/0/4326"},vertexCRS:{path:"vertexCRS",default:"http://www.opengis.net/def/crs/EPSG/0/4326"},normalReferenceFrame:{path:"normalReferenceFrame",default:"east-north-up"},attributeEncoding:{path:"attributeEncoding",default:"application/octet-stream; version=1.6"},textureEncoding:{path:"textureEncoding",default:["image/jpeg","image/ktx2"]},lodType:{path:"lodType",default:"MeshPyramid"},lodModel:{path:"lodModel",default:"node-switching"},defaultGeometrySchema:{path:"defaultGeometrySchema",default:{geometryType:"triangles",header:[{property:"vertexCount",type:"UInt32"},{property:"featureCount",type:"UInt32"}],topology:"PerAttributeArray",ordering:["position","normal","uv0","color"],vertexAttributes:{position:{valueType:"Float32",valuesPerElement:3},normal:{valueType:"Float32",valuesPerElement:3},uv0:{valueType:"Float32",valuesPerElement:2},color:{valueType:"UInt8",valuesPerElement:4}},featureAttributeOrder:["id","faceRange"],featureAttributes:{id:{valueType:"UInt64",valuesPerElement:1},faceRange:{valueType:"UInt32",valuesPerElement:2}}}}};function bv(e,t,r){const n={};for(const[t,i]of e.entries())n[`Mat${r.nodePath}${t}`]=Vi()(i,{name:{path:"name",default:"standard"},type:{path:"type",default:"standard"},params:{path:"params",transform:(e,t,r)=>Vi()(r,{renderMode:{path:"renderMode",default:"solid"},shininess:{path:"shininess",default:1},reflectivity:{path:"reflectivity",default:0},ambient:{path:"ambient",default:[1,1,1]},diffuse:{path:"diffuse",default:[1,1,1]},specular:{path:"specular",default:[0,0,0]},useVertexColorAlpha:{path:"useVertexColorAlpha",default:!1},vertexRegions:{path:"vertexRegions",default:!1},vertexColors:{path:"vertexColors",default:!0}})}});return n}function vv(e,t,r){if(!e)return null;const n={};for(const[t,i]of e.entries()){const e=`${r.nodePath}${t}`;i.imageIndex=e,n[e]=Vi()(i,{encoding:{path:"encoding"},wrap:{path:"wrap",default:["none"]},atlas:{path:"atlas",default:!1},uvSet:{path:"uvSet",default:"uv0"},channels:{path:"channels",default:"rgb"},images:{path:"images",transform:(e,t,r)=>e.map(e=>Vi()(e,{id:{path:"id"},size:{path:"size"},href:{path:"href",default:["../textures/0"]},length:{path:"length"}}))}})}return n}function wv(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const _v={};function kv(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";_v[e]=_v[e]||1;const t=_v[e]++;return"".concat(e,"-").concat(t)}const xv={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};const Ev=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),Sv=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),Av=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),jv=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Cv={POSITION:{size:3,value:new Float32Array(Sv)},NORMAL:{size:3,value:new Float32Array(Av)},TEXCOORD_0:{size:2,value:new Float32Array(jv)}};class Tv extends class{static get DRAW_MODE(){return xv}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t=kv("geometry"),drawMode:r=xv.TRIANGLES,attributes:n={},indices:i=null,vertexCount:a=null}=e;this.id=t,this.drawMode=0|r,this.attributes={},this.userData={},this._setAttributes(n,i),this.vertexCount=a||this._calculateVertexCount(this.attributes,this.indices)}get mode(){return this.drawMode}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return"Geometry ".concat(this.id," attribute ").concat(e)}_setAttributes(e,t){t&&(this.indices=ArrayBuffer.isView(t)?{value:t,size:1}:t);for(const t in e){let r=e[t];r=ArrayBuffer.isView(r)?{value:r}:r,wv(ArrayBuffer.isView(r.value),"".concat(this._print(t),": must be typed array or object with value as typed array")),"POSITION"!==t&&"positions"!==t||r.size||(r.size=3),"indices"===t?(wv(!this.indices),this.indices=r):this.attributes[t]=r}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}_calculateVertexCount(e,t){if(t)return t.value.length;let r=1/0;for(const t in e){const n=e[t],{value:i,size:a,constant:o}=n;!o&&i&&a>=1&&(r=Math.min(r,i.length/a))}return wv(Number.isFinite(r)),r}}{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t=kv("cube-geometry")}=e;super({...e,id:t,indices:{size:1,value:new Uint16Array(Ev)},attributes:{...Cv,...e.attributes}})}}function Bv(e){var t,r;if(null==e||null===(t=e.parentNode)||void 0===t||!t.obb||null==e||null===(r=e.parentNode)||void 0===r||!r.mbs)return[];const n=[];return function(e,t){var r;const n=function(e){const{center:t,halfSize:r,quaternion:n}=e;return(new xp).fromCenterHalfSizeQuaternion(t,r,n)}(t.parentNode.obb),i=function(e){const t=new Tv,r=e.obb.halfSize,n=t.getAttributes(),i=new Float32Array(n.POSITION.value),a=vu.WGS84.cartographicToCartesian(e.obb.center);let o=[];for(let t=0;t<i.length;t+=3){const n=new Cs(i[t]*=r[0],i[t+1]*=r[1],i[t+2]*=r[2]).transformByQuaternion(e.obb.quaternion).add(a);o=o.concat(n)}return o}(t);if(function(e,t){let r=!0;for(let n=0;n<t.length/3;n+=3){const i=[t[n],t[n+1],t[n+2]],a=vu.WGS84.cartesianToCartographic(i);if(e.distanceTo(a)>0){r=!1;break}}return r}(n,i))return;const a=`OBB of Tile (${t.id}) doesn't fit into Parent (${null===(r=t.parentNode)||void 0===r?void 0:r.id}) tile OBB`;e.push(a)}(n,e),function(e,t){const r=Rv(t.mbs),n=Rv(t.parentNode.mbs);if(r.center.distanceTo(n.center)+r.radius>n.radius){var i;const r=`MBS of Tile (${t.id}) doesn't fit into Parent (${null===(i=t.parentNode)||void 0===i?void 0:i.id}) tile MBS`;e.push(r)}}(n,e),n}function Rv(e){return new Th([e[0],e[1],e[2]],e[3])}const Ov={name:"Basis Universal Supercompressed GPU Texture",id:Ki?"ktx2-basis-writer":"ktx2-basis-writer-nodejs",module:"textures",version:"3.3.0",extensions:["ktx2"],worker:!0,options:{useSRGB:!1,qualityLevel:10,encodeUASTC:!1,mipmaps:!1}},{_encodeImageNode:Iv}=globalThis;let Pv=!0;const Dv={name:"Images",id:"image",module:"images",version:"3.3.0",extensions:["jpeg"],options:{image:{mimeType:"image/png",jpegQuality:null}},encode:async function(e,t){return(t=t||{}).image=t.image||{},Iv?Iv(e,{type:t.image.mimeType}):async function(e,t){const{mimeType:r,jpegQuality:n}=t.image,{width:i,height:a}=function(e){return Au(e)}(e),o=document.createElement("canvas");o.width=i,o.height=a,function(e,t,r=0,n=0){if(0===r&&0===n&&"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t.getContext("bitmaprenderer");if(r)return r.transferFromImageBitmap(e),t}const i=t.getContext("2d");if(e.data){const r=new Uint8ClampedArray(e.data),n=new ImageData(r,e.width,e.height);return i.putImageData(n,0,0),t}i.drawImage(e,0,0)}(e,o);const s=await new Promise(e=>{if(n&&Pv)try{return void o.toBlob(e,r,n)}catch(e){Pv=!1}o.toBlob(e,r)});if(!s)throw new Error("image encoding failed");return await s.arrayBuffer()}(e,t)}};class Mv extends Array{enqueue(e){this.push(e)}dequeue(){return this.shift()}peek(){return this[0]}isEmpty(){return 0===this.length}}function Fv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Lv extends Mv{constructor(e=2e3,t=400){super(),Fv(this,"intervalId",void 0),Fv(this,"writePromise",null),Fv(this,"fileMap",{}),Fv(this,"listeningInterval",void 0),Fv(this,"writeConcurrency",void 0),this.listeningInterval=e,this.writeConcurrency=t}async enqueue(e,t=!1){if(t){const{archiveKey:t,writePromise:r}=e,n=await r();t&&n&&(this.fileMap[t]=n)}else super.enqueue(e),Gi.a.memoryUsage().rss>4294967296&&await this.startWrite()}startListening(){this.intervalId=setInterval(this.startWrite.bind(this),this.listeningInterval)}stopListening(){this.intervalId&&clearInterval(this.intervalId)}async startWrite(){this.writePromise||(this.writePromise=this.doWrite()),await this.writePromise,this.writePromise=null}async finalize(){this.stopListening(),await this.startWrite()}async doWrite(){for(;this.length;){const e=[],t=[];for(let r=0;r<this.writeConcurrency;r++){const r=this.dequeue();if(!r)break;const{archiveKey:n,writePromise:i}=r;t.push(n);const a=i();e.push(a)}const r=await Promise.allSettled(e);this.updateFileMap(t,r)}}updateFileMap(e,t){for(let r=0;r<e.length;r++){const n=e[r];n&&"value"in t[r]&&(this.fileMap[n]=t[r].value)}}}const Nv={id:"i3s-attributes",name:"I3S Attributes Worker",module:"tile-converter",version:"3.3.0",options:{useCartesianPositions:!1}};const zv=()=>({version:{path:"version"},id:{path:"id"},path:{path:"path"},level:{path:"level"},mbs:{path:"mbs"},obb:{path:"obb"},lodSelection:{path:"lodSelection",default:[{metricType:"maxScreenThresholdSQ",maxError:196349.54374999998},{metricType:"maxScreenThreshold",maxError:999.9999999999999}]},children:{path:"children",default:null},neighbors:{path:"neighbors",default:null},parentNode:{path:"parentNode",transform:e=>Vi()(e,{id:{path:"id"},href:{path:"href"},mbs:{path:"mbs"},obb:{path:"obb"}}),default:null},sharedResource:{path:"sharedResource",default:null},featureData:{path:"featureData",default:null},geometryData:{path:"geometryData",default:null},textureData:{path:"textureData",default:null},attributeData:{path:"attributeData",default:null}});function Uv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class qv{constructor(e,t){Uv(this,"id",void 0),Uv(this,"inPageId",void 0),Uv(this,"data",null),Uv(this,"children",[]),Uv(this,"converter",void 0),this.inPageId=e,this.id=0===e?"root":e.toString(),this.converter=t}async addData(e){return this.converter.options.instantNodeWriting?await this.write(e):this.data=e,this}async addChildren(e){const t=[];for(const r of e){const e=await r.load();t.push({id:r.id,href:"../"+r.id,obb:e.obb,mbs:e.mbs})}this.children=this.children.concat(e);let r=this.data;var n;(this.converter.options.instantNodeWriting&&(r=await this.load()),r)&&(r.children=null!==(n=r.children)&&void 0!==n?n:[],r.children=r.children.concat(t));this.converter.options.instantNodeWriting&&r&&await this.write(r)}async addNeighbors(){const e=await this.load();for(const n of this.children){var t,r;const i=await n.load();if(i.neighbors=null!==(t=i.neighbors)&&void 0!==t?t:[],Number(null==e||null===(r=e.children)||void 0===r?void 0:r.length)<1e3)for(const t of e.children||[])n.id!==t.id&&i.neighbors.push({...t});else console.warn(`Node ${n.id}: neighbors attribute is omited because of large number of neigbors`),delete i.neighbors;this.converter.options.instantNodeWriting&&i&&await n.write(i),await n.save(),n.flush()}}async save(){this.data&&await this.write(this.data)}async write(e){const t=Object(qi.join)(this.converter.layers0Path,"nodes",this.id);this.converter.options.slpk?await this.converter.writeQueue.enqueue({archiveKey:`nodes/${this.id}/3dNodeIndexDocument.json.gz`,writePromise:()=>sm(t,JSON.stringify(e),"3dNodeIndexDocument.json",!0,this.converter.compressList)},!0):await this.converter.writeQueue.enqueue({writePromise:()=>om(t,JSON.stringify(e))},!0)}async load(){if(this.data)return this.data;const e=this.id,t=Object(qi.join)(this.converter.layers0Path,"nodes",e);let r="index.json";return this.converter.options.slpk&&(r="3dNodeIndexDocument.json"),await um(t,r)}flush(){this.data=null}static async createRootNode(e,t){const r=qv.createRootNodeIndexDocument(e);return await new qv(0,t).addData(r)}static async createNode(e,t,r,n,i,a){const o=await qv.createNodeIndexDocument(e,t,r,n,i);return await new qv(n.index,a).addData(o)}static createRootNodeIndexDocument(e){const t={version:`{${Sb().toUpperCase()}}`,id:"root",level:0,lodSelection:[{metricType:"maxScreenThresholdSQ",maxError:0},{metricType:"maxScreenThreshold",maxError:0}],...e,children:[]};return Vi()(t,zv())}static async createNodeIndexDocument(e,t,r,n,i){const{texture:a,attributes:o}=i,s=n.index,u=await e.load(),c={version:u.version,id:s.toString(),level:u.level+1,...t,lodSelection:r,parentNode:{id:e.id,href:"../"+e.id,mbs:u.mbs,obb:u.obb},children:[],neighbors:[]},l=Vi()(c,zv());var h,p;if(n.mesh&&(l.geometryData=[{href:"./geometries/0"}],l.sharedResource={href:"./shared"},a&&(l.textureData=[{href:"./textures/0"},{href:"./textures/1"}]),o&&o.length&&null!==(h=e.converter.layers0)&&void 0!==h&&null!==(p=h.attributeStorageInfo)&&void 0!==p&&p.length)){l.attributeData=[];for(let t=0;t<o.length;t++){const r=e.converter.layers0.attributeStorageInfo[t].key;l.attributeData.push({href:`./attributes/${r}/0`})}}return l}}var Hv;function Gv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Wv=(null===(Hv=Gi.a.env)||void 0===Hv?void 0:Hv.IonToken)||"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ";class Vv{constructor(){Gv(this,"nodePages",void 0),Gv(this,"options",void 0),Gv(this,"layers0Path",void 0),Gv(this,"materialMap",void 0),Gv(this,"materialDefinitions",void 0),Gv(this,"geometryMap",void 0),Gv(this,"geometryConfigs",void 0),Gv(this,"vertexCounter",void 0),Gv(this,"layers0",void 0),Gv(this,"featuresHashArray",void 0),Gv(this,"refinementCounter",void 0),Gv(this,"validate",void 0),Gv(this,"boundingVolumeWarnings",[]),Gv(this,"conversionStartTime",[0,0]),Gv(this,"refreshTokenTime",[0,0]),Gv(this,"sourceTileset",null),Gv(this,"geoidHeightModel",null),Gv(this,"Loader",fb),Gv(this,"generateTextures",void 0),Gv(this,"generateBoundingVolumes",void 0),Gv(this,"layersHasTexture",void 0),Gv(this,"workerSource",{}),Gv(this,"writeQueue",new Lv),Gv(this,"compressList",null),this.nodePages=new Tb(om,64,this),this.options={},this.layers0Path="",this.materialMap=new Map,this.materialDefinitions=[],this.geometryMap=new Map,this.geometryConfigs=[],this.vertexCounter=0,this.layers0=null,this.featuresHashArray=[],this.refinementCounter={tilesCount:0,tilesWithAddRefineCount:0},this.validate=!1,this.generateTextures=!1,this.generateBoundingVolumes=!1,this.layersHasTexture=!1,this.compressList=null}async convert(e){if(Ki)return console.log(_m),_m;this.conversionStartTime=Gi.a.hrtime();const{tilesetName:t,slpk:r,egmFilePath:n,inputUrl:i,validate:a,outputPath:o,draco:s=!0,sevenZipExe:u,maxDepth:c,token:l,generateTextures:h,generateBoundingVolumes:p,instantNodeWriting:f=!1,mergeMaterials:d=!0}=e;this.options={maxDepth:c,slpk:r,sevenZipExe:u,egmFilePath:n,draco:s,token:l,inputUrl:i,instantNodeWriting:f,mergeMaterials:d},this.compressList=this.options.instantNodeWriting&&[]||null,this.validate=Boolean(a),this.Loader=-1!==i.indexOf("https://")?mb:fb,this.generateTextures=Boolean(h),this.generateBoundingVolumes=Boolean(p),this.writeQueue=new Lv,this.writeQueue.startListening(),console.log("Loading egm file..."),this.geoidHeightModel=await Jo(n,Ud),console.log("Loading egm file completed!"),r&&this.nodePages.useWriteFunction(sm),await this.loadWorkers();try{var m,g;const e=await this._fetchPreloadOptions(),n={loadOptions:{_nodeWorkers:!0,reuseWorkers:!0,basis:{format:"rgba32"},"basis-nodejs":{format:"rgba32",workerUrl:"./modules/textures/dist/basis-nodejs-worker.js"},"draco-nodejs":{workerUrl:"./modules/draco/dist/draco-nodejs-worker.js"}}};e.headers&&(n.loadOptions.fetch={headers:e.headers}),Object.assign(n,e);const a=await Jo(i,this.Loader,n.loadOptions);return this.sourceTileset=new Id(a,n),await this._createAndSaveTileset(o,t,null==a||null===(m=a.root)||void 0===m||null===(g=m.boundingVolume)||void 0===g?void 0:g.region),await this._finishConversion({slpk:Boolean(r),outputPath:o,tilesetName:t}),a}catch(e){throw e}finally{eo.getWorkerFarm({}).destroy()}}async _createAndSaveTileset(e,t,r){const n=Object(qi.join)(""+e,""+t);try{await cm(n)}catch(e){}this.layers0Path=Object(qi.join)(n,"SceneServer","layers","0"),this._formLayers0(t,r),this.materialDefinitions=[],this.materialMap=new Map;const i=this.sourceTileset.root,a=mm(i,this.geoidHeightModel);await this.nodePages.push({index:0,lodThreshold:0,obb:a.obb,children:[]});const o=await qv.createRootNode(a,this);await this._convertNodesTree(o,i),this.layers0.materialDefinitions=this.materialDefinitions,this.layers0.geometryDefinitions=Vi()(this.geometryConfigs.map(e=>({geometryConfig:{...e,draco:this.options.draco}})),{geometryBuffers:{path:"geometryConfig",transform:e=>{const t=[Vi()(e,{offset:{default:8},position:{default:{type:"Float32",component:3}},normal:{default:{type:"Float32",component:3}},uv0:{path:"hasTexture",transform:e=>e&&{type:"Float32",component:2}||!1,omitValues:[!1]},color:{default:{type:"UInt8",component:4}},uvRegion:{path:"hasUvRegions",transform:e=>e&&{type:"UInt16",component:4}||!1,omitValues:[!1]},featureId:{default:{binding:"per-feature",type:"UInt64",component:1}},faceRange:{default:{binding:"per-feature",type:"UInt32",component:2}}})];return e.draco&&t.push(Vi()({geometryConfig:e},{"compressedAttributes.encoding":{default:"draco"},"compressedAttributes.attributes":{path:"geometryConfig",transform:e=>{const t=["position","normal"];return e.hasTexture&&t.push("uv0"),t.push("color"),e.hasUvRegions&&t.push("uv-region"),t.push("feature-index"),t}}})),t}}}),!1===this.layersHasTexture&&(this.layers0.store.defaultGeometrySchema.ordering=this.layers0.store.defaultGeometrySchema.ordering.filter(e=>"uv0"!==e)),await this._writeLayers0(),async function(e,t,r){const n={serviceItemId:Sb().replace(/-/gi,""),layerName:e,layers0:t},i=Vi()(n,{serviceItemId:{path:"serviceItemId"},serviceName:{path:"layerName"},name:{path:"layerName"},currentVersion:{path:"currentVersion",default:10.7},serviceVersion:{path:"serviceVersion",default:"1.8"},supportedBindings:{path:"supportedBindings",default:["REST"]},layers:{path:"layers0",transform:e=>[e]}}),a=Object(qi.join)(r,"SceneServer");await om(a,JSON.stringify(i))}(t,this.layers0,n);for(const e of this.compressList||[])await im(e),await lm(e);await this.nodePages.save(),await this.writeQueue.finalize(),await this._createSlpk(n)}_formLayers0(e,t){var r,n,i;const a=function(e){let t;t=e instanceof Th?e:e.getBoundingSphere();const r=t.center,n=t.radius,i=vu.WGS84.cartesianToCartographic(new Cs(r[0]+n,r[1]+n,r[2]+n),new Cs),a=vu.WGS84.cartesianToCartographic(new Cs(r[0]-n,r[1]-n,r[2]-n),new Cs);return{xmin:Math.min(a[0],i[0]),xmax:Math.max(a[0],i[0]),ymin:Math.min(a[1],i[1]),ymax:Math.max(a[1],i[1]),zmin:Math.min(a[2],i[2]),zmax:Math.max(a[2],i[2])}}((null===(r=this.sourceTileset)||void 0===r?void 0:r.boundingVolume)||(null===(n=this.sourceTileset)||void 0===n||null===(i=n.root)||void 0===i?void 0:i.boundingVolume));t&&(a.zmin=t[4],a.zmax=t[5]);const o=[a.xmin,a.ymin,a.xmax,a.ymax],s={version:`{${Sb().toUpperCase()}}`,id:0,name:e,href:"./layers/0",store:{id:`{${Sb().toUpperCase()}}`,extent:o},nodePages:{nodesPerPage:64},compressGeometry:this.options.draco,fullExtent:a};this.layers0=Vi()(s,{version:{path:"version",transform:e=>e.toUpperCase()},id:{path:"id",default:0},name:{path:"name"},href:{path:"href",default:"./layers/0"},layerType:{path:"layerType",default:"IntegratedMesh"},spatialReference:{path:"spatialReference",transform:e=>Vi()(e,{wkid:{path:"wkid",default:4326},latestWkid:{path:"latestWkid",default:4326},vcsWkid:{path:"vcsWkid",default:5773},latestVcsWkid:{path:"latestVcsWkid",default:5773}})},capabilities:{path:"capabilities",default:["View","Query"]},store:{path:"store",transform:e=>Vi()(e,yv)},fullExtent:{path:"fullExtent",transform:e=>Vi()(e,{xmin:{path:"xmin"},ymin:{path:"ymin"},xmax:{path:"xmax"},ymax:{path:"ymax"},zmin:{path:"zmin"},zmax:{path:"zmax"}})},heightModelInfo:{path:"heightModelInfo",transform:e=>Vi()(e,{heightModel:{path:"heightModel",default:"gravity_related_height"},vertCRS:{path:"vertCRS",default:"EGM96_Geoid"},heightUnit:{path:"heightUnit",default:"meter"}})},nodePages:{path:"nodePages",transform:e=>Vi()(e,{nodesPerPage:{path:"nodesPerPage"},lodSelectionMetricType:{path:"lodSelectionMetricType",default:"maxScreenThresholdSQ"}})},materialDefinitions:{path:"materialDefinitions",default:[]},textureSetDefinitions:{path:"textureSetDefinitions",default:[]},geometryDefinitions:{path:"geometryDefinitions",default:[]},attributeStorageInfo:{path:"attributeStorageInfo",default:[]},fields:{path:"fields",default:[]},popupInfo:{path:"popupInfo",default:null}})}async _convertNodesTree(e,t){if(await this.sourceTileset._loadTile(t),this.isContentSupported(t)){const r=await this._createNode(e,t,0);for(const e of r)await e.save();await e.addChildren(r)}else await this._addChildrenWithNeighborsAndWriteFile({parentNode:e,sourceTiles:t.children,level:1});await t.unloadContent(),await e.save()}async _writeLayers0(){this.options.slpk?await this.writeQueue.enqueue({archiveKey:"3dSceneLayer.json.gz",writePromise:()=>sm(this.layers0Path,JSON.stringify(this.layers0),"3dSceneLayer.json")}):await this.writeQueue.enqueue({writePromise:()=>om(this.layers0Path,JSON.stringify(this.layers0))})}async _createSlpk(e){if(this.options.slpk){const t=Object(qi.join)(e,"SceneServer","layers","0"),r=e+".slpk";await am(t,r,0,".",this.options.sevenZipExe);try{await cm(e)}catch(e){}}}async _addChildrenWithNeighborsAndWriteFile(e){await this._addChildren(e),await e.parentNode.addNeighbors()}async convertNestedTileset({parentNode:e,sourceTile:t,level:r}){await this.sourceTileset._loadTile(t),await this._addChildren({parentNode:e,sourceTiles:t.children,level:r+1}),await t.unloadContent()}async convertNode({parentNode:e,sourceTile:t,level:r}){const n=await this._createNode(e,t,r);await e.addChildren(n)}async _addChildren(e){const{sourceTiles:t,parentNode:r,level:n}=e;if(!(this.options.maxDepth&&n>this.options.maxDepth))for(const e of t)"json"===e.type?await this.convertNestedTileset({parentNode:r,sourceTile:e,level:n}):await this.convertNode({parentNode:r,sourceTile:e,level:n}),e.id&&console.log(e.id)}async _createNode(e,t,r){var n,i;this._checkAddRefinementTypeForTile(t),await this._updateTilesetOptions(),await this.sourceTileset._loadTile(t);let a=mm(t,this.geoidHeightModel);const o=gv(t.content);!o||null!==(n=this.layers0)&&void 0!==n&&null!==(i=n.attributeStorageInfo)&&void 0!==i&&i.length||this._convertPropertyTableToNodeAttributes(o);const s=await this._convertResources(t,e.inPageId,o),u=[],c=[],l=[],h={geometry:null,compressedGeometry:null,texture:null,hasUvRegions:!1,sharedResources:null,meshMaterial:null,vertexCount:null,attributes:null,featureCount:null,boundingVolumes:null};for(const r of s||[h]){this.layersHasTexture=this.layersHasTexture||Boolean(r.texture),this.generateBoundingVolumes&&r.boundingVolumes&&(a=r.boundingVolumes);const n=Hd(t,a),i=n.find(e=>"maxScreenThresholdSQ"===e.metricType)||{maxError:0},o=await this._updateNodeInNodePages(i,a,t,e.inPageId,r),s=await qv.createNodeIndexDocument(e,a,n,o,r),h=await new qv(o.index,this).addData(s);u.push(h),o.mesh&&await this._writeResources(r,h.id),this.validate&&(this.boundingVolumeWarnings=Bv(s),this.boundingVolumeWarnings&&this.boundingVolumeWarnings.length&&console.warn("Bounding Volume Warnings: ",...this.boundingVolumeWarnings)),c.push(o.index),l.push(o)}return t.unloadContent(),await this._addChildrenWithNeighborsAndWriteFile({parentNode:u[0],sourceTiles:t.children,level:r+1}),u}async _convertResources(e,t,r){var n;if(!this.isContentSupported(e))return null;const i={center:[],halfSize:[],quaternion:[]};return await Vb(e.content,async()=>(await this.nodePages.push({index:0,obb:i},t)).index,r,this.featuresHashArray,null===(n=this.layers0)||void 0===n?void 0:n.attributeStorageInfo,this.options.draco,this.generateBoundingVolumes,this.options.mergeMaterials,this.geoidHeightModel,this.workerSource)}async _updateNodeInNodePages(e,t,r,n,i){const{meshMaterial:a,texture:o,vertexCount:s,featureCount:u,geometry:c,hasUvRegions:l}=i,h={index:0,lodThreshold:e.maxError,obb:t.obb,children:[]};c&&this.isContentSupported(r)&&(h.mesh={geometry:{definition:this.findOrCreateGeometryDefinition(Boolean(o),l),resource:0},attribute:{resource:0},material:{definition:0}});let p,f=i.nodeId;if(p=f?await this.nodePages.getNodeById(f):await this.nodePages.push(h,n),Tb.updateAll(p,h),a&&Tb.updateMaterialByNodeId(p,this._findOrCreateMaterial(a)),o){const e=o.image.height*o.image.width;Tb.updateTexelCountHintByNodeId(p,e)}return s&&(this.vertexCounter+=s,Tb.updateVertexCountByNodeId(p,s)),Tb.updateNodeAttributeByNodeId(p),u&&Tb.updateFeatureCountByNodeId(p,u),this.nodePages.saveNode(p),p}async _writeResources(e,t){const{geometry:r,compressedGeometry:n,texture:i,sharedResources:a,attributes:o}=e,s=Object(qi.join)(this.layers0Path,"nodes",t),u=Object(qi.join)("nodes",t);await this._writeGeometries(r,n,s,u),await this._writeShared(a,s,u,t),await this._writeTexture(i,s,u),await this._writeAttributes(o,s,u)}async _writeGeometries(e,t,r,n){if(this.options.slpk){const t=Object(qi.join)(r,"geometries");await this.writeQueue.enqueue({archiveKey:n+"/geometries/0.bin.gz",writePromise:()=>sm(t,e,"0.bin")})}else{const t=Object(qi.join)(r,"geometries/0/");await this.writeQueue.enqueue({writePromise:()=>om(t,e,"index.bin")})}if(this.options.draco)if(this.options.slpk){const e=Object(qi.join)(r,"geometries");await this.writeQueue.enqueue({archiveKey:n+"/geometries/1.bin.gz",writePromise:()=>sm(e,t,"1.bin")})}else{const e=Object(qi.join)(r,"geometries/1/");await this.writeQueue.enqueue({writePromise:()=>om(e,t,"index.bin")})}}async _writeShared(e,t,r,n){if(!e)return;e.nodePath=n;const i=Vi()(e,{materialDefinitions:{path:"materialDefinitionInfos",transform:bv},textureDefinitions:{path:"textureDefinitionInfos",transform:vv}}),a=JSON.stringify(i);if(this.options.slpk){const e=Object(qi.join)(t,"shared");await this.writeQueue.enqueue({archiveKey:r+"/shared/sharedResource.json.gz",writePromise:()=>sm(e,a,"sharedResource.json")})}else{const e=Object(qi.join)(t,"shared/");await this.writeQueue.enqueue({writePromise:()=>om(e,a)})}}async _writeTexture(e,t,r){if(e){const n=this._getFormatByMimeType(null==e?void 0:e.mimeType),i=[],a=e.bufferView.data;switch(n){case"jpg":case"png":if(i.push({name:"0",format:n}),await this.writeTextureFile(a,"0",n,t,r),this.generateTextures){i.push({name:"1",format:"ktx2"});const n=e.image.data.subarray(),a=new Uint8Array(n),o=Em({...e.image,data:a},Ov,{...Ov.options,source:this.workerSource.ktx2,reuseWorkers:!0,_nodeWorkers:!0});await this.writeTextureFile(o,"1","ktx2",t,r)}break;case"ktx2":if(i.push({name:"1",format:n}),await this.writeTextureFile(a,"1",n,t,r),this.generateTextures){i.push({name:"0",format:"jpg"});const n=Em(e.image.data[0],Dv);await this.writeTextureFile(n,"0","jpg",t,r)}}this.layers0.textureSetDefinitions.length||(this.layers0.textureSetDefinitions.push({formats:i}),this.layers0.textureSetDefinitions.push({formats:i,atlas:!0}))}}async writeTextureFile(e,t,r,n,i){if(this.options.slpk){const a=Object(qi.join)(n,"textures"),o=!1;await this.writeQueue.enqueue({archiveKey:`${i}/textures/${t}.${r}`,writePromise:()=>sm(a,e,`${t}.${r}`,o)})}else{const i=Object(qi.join)(n,`textures/${t}/`);await this.writeQueue.enqueue({writePromise:()=>om(i,e,"index."+r)})}}async _writeAttributes(e=[],t,r){var n,i;if(null!=e&&e.length&&null!==(n=this.layers0)&&void 0!==n&&null!==(i=n.attributeStorageInfo)&&void 0!==i&&i.length)for(let n=0;n<e.length;n++){const i=this.layers0.attributeStorageInfo[n].key,a=new Uint8Array(e[n]);if(this.options.slpk){const e=Object(qi.join)(t,"attributes",i);await this.writeQueue.enqueue({archiveKey:`${r}/attributes/${i}.bin.gz`,writePromise:()=>sm(e,a,"0.bin")})}else{const e=Object(qi.join)(t,`attributes/${i}/0`);await this.writeQueue.enqueue({writePromise:()=>om(e,a,"index.bin")})}}}_getFormatByMimeType(e){switch(e){case"image/jpeg":return"jpg";case"image/png":return"png";case"image/ktx2":return"ktx2";default:return"jpg"}}_findOrCreateMaterial(e){const t=jb()(JSON.stringify(e));if(this.materialMap.has(t))return this.materialMap.get(t)||0;const r=this.materialDefinitions.push(e)-1;return this.materialMap.set(t,r),r}findOrCreateGeometryDefinition(e,t){const r={hasTexture:e,hasUvRegions:t},n=jb()(JSON.stringify(r));if(this.geometryMap.has(n))return this.geometryMap.get(n)||0;const i=this.geometryConfigs.push(r)-1;return this.geometryMap.set(n,i),i}_convertPropertyTableToNodeAttributes(e){let t=0;const r={OBJECTID:[0],...e};for(const e in r){const n=Lb(e,r[e][0]),i=Nb(t,e,n),a=Ub(e,zb(n)),o=qb(r);this.layers0.attributeStorageInfo.push(i),this.layers0.fields.push(a),this.layers0.popupInfo=o,this.layers0.layerType="3DObject",t+=1}}async _finishConversion(e){const{tilesCount:t,tilesWithAddRefineCount:r}=this.refinementCounter,n=r?r/t*100:0,i=await fm(e),a=pm(Gi.a.hrtime(this.conversionStartTime));console.log("------------------------------------------------"),console.log("Finishing conversion of 3DTILES"),console.log("Total conversion time: "+a),console.log("Vertex count: ",this.vertexCounter),console.log("File(s) size: ",i," bytes"),console.log('Percentage of tiles with "ADD" refinement type:',n,"%"),console.log("------------------------------------------------")}async _fetchPreloadOptions(){if(!this.Loader.preload)return{};const e={"cesium-ion":{accessToken:this.options.token||Wv}},t=await this.Loader.preload(this.options.inputUrl,e);return this.refreshTokenTime=Gi.a.hrtime(),{...e,...t}}async _updateTilesetOptions(){if(Gi.a.hrtime(this.refreshTokenTime)[0]<1800)return;this.refreshTokenTime=Gi.a.hrtime();const e=await this._fetchPreloadOptions();this.sourceTileset.options={...this.sourceTileset.options,...e},e.headers&&(this.sourceTileset.loadOptions.fetch={...this.sourceTileset.loadOptions.fetch,headers:e.headers},console.log("Authorization Bearer token has been updated"))}_checkAddRefinementTypeForTile(e){1===e.refine&&(this.refinementCounter.tilesWithAddRefineCount+=1,console.warn('This tile uses "ADD" type of refinement')),this.refinementCounter.tilesCount+=1}isContentSupported(e){var t;return["b3dm","glTF"].includes(null==e||null===(t=e.content)||void 0===t?void 0:t.type)}async loadWorkers(){if(console.log("Loading workers source..."),this.options.draco){const e=to(Cc,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.draco=r}if(this.generateTextures){const e=to(Ov,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.ktx2=r}const e=to(Nv,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.I3SAttributes=r,console.log("Loading workers source completed!")}}const Kv={id:"zip",module:"zip",name:"Zip Archive",version:"3.3.0",extensions:["zip"],mimeTypes:["application/zip"],category:"archive",tests:["PK"],options:{},parse:async function(e,t={}){const r=[],n={};try{const i=new Zd.a;return(await i.loadAsync(e,t)).forEach((e,a)=>{const o=a.name,s=async function(e,t,r={}){try{return await e.file(t).async(r.dataType||"arraybuffer")}catch(e){return r.log.error(`Unable to read ${t} from zip archive: ${e}`),e}}(i,o,t).then(t=>{n[e]=t});r.push(s)}),await Promise.all(r),n}catch(e){throw t.log.error("Unable to read zip archive: "+e),e}}};class Jv{async install(e="",t=""){console.log('Installing "EGM2008-5" model...');const r=await Jo("https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip",Kv,{});let n=process.cwd();e&&(n=Object(qi.join)(n,e)),await om(n,new Uint8Array(r["geoids/egm2008-5.pgm"]),"egm2008-5.pgm"),console.log('Installing "I3S Content Loader worker"'),await this.installWorker("i3s","i3s-content-nodejs-worker.js",t),console.log('Installing "Draco Loader worker"'),await this.installWorker("draco","draco-nodejs-worker.js",t),console.log('Installing "Basis Loader worker"'),await this.installWorker("textures","basis-nodejs-worker.js",t),console.log('Installing "join-images" npm package');const i=new Yd;await i.start({command:"npm",arguments:["install","sharp","join-images"],wait:0}),console.log("All dependencies were installed succesfully.")}async installWorker(e,t,r){const n=await va(`https://unpkg.com/@loaders.gl/${e}@3.3.0/dist/${t}`),i=await n.arrayBuffer();if(!i)return;const a=Object(qi.join)(process.cwd(),r,"modules",e,"dist");await om(a,i,t)}}const Qv={I3S:"I3S",_3DTILES:"3DTILES"};function $v(){console.log("cli: converter 3dTiles to I3S or I3S to 3dTiles..."),console.log('--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]'),console.log("--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]"),console.log("--name [Tileset name]"),console.log('--output [Output folder, default: "data" folder]'),console.log("--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]"),console.log("--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]"),console.log("--slpk [Generate slpk (Scene Layer Packages) I3S output file]"),console.log("--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]"),console.log("--input-type [tileset input type: I3S or 3DTILES]"),console.log('--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]'),console.log('--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"'),console.log("--token [Token for Cesium ION tilesets authentication]"),console.log("--no-draco [Disable draco compression for geometry]"),console.log("--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]"),console.log("--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]"),console.log("--validate [Enable validation]"),process.exit(0)}function Yv(e,t){if(e+1>=t.length)return"";const r=t[e+1];return 0===r.indexOf("--")?"":r}function Xv(e,t){const r=Yv(e,t).toLowerCase().trim();return!(["--no-draco","--split-nodes"].includes(t[e])&&!r)&&(!r||"true"===r)}(async function(){const[,,...e]=process.argv;0===e.length&&$v();const t=function(e){const t={output:"data",instantNodeWriting:!1,mergeMaterials:!0,sevenZipExe:"C:\\Program Files\\7-Zip\\7z.exe",egm:Object(qi.join)(process.cwd(),"deps","egm2008-5.pgm"),draco:!0,installDependencies:!1,generateTextures:!1,generateBoundingVolumes:!1,validate:!1,slpk:!1};return e.forEach((r,n)=>{if(0===r.indexOf("--"))switch(r){case"--input-type":t.inputType=Yv(n,e);break;case"--tileset":t.tileset=function(e,t){const r=Yv(e,t);return console.log("Input tileset value: "+r),console.log("Modified tileset value: "+r.replace(/\\/g,"/")),r.replace(/\\/g,"/")}(n,e);break;case"--name":t.name=Yv(n,e);break;case"--output":t.output=Yv(n,e);break;case"--instant-node-writing":t.instantNodeWriting=Xv(n,e);break;case"--split-nodes":t.mergeMaterials=Xv(n,e);break;case"--max-depth":t.maxDepth=function(e,t){const r=Yv(e,t),n=Number.parseInt(r);if(isFinite(n))return n;return NaN}(n,e);break;case"--slpk":t.slpk=Xv(n,e);break;case"--7zExe":t.sevenZipExe=Yv(n,e);break;case"--egm":t.egm=Yv(n,e);break;case"--token":t.token=Yv(n,e);break;case"--no-draco":t.draco=Xv(n,e);break;case"--validate":t.validate=Xv(n,e);break;case"--install-dependencies":t.installDependencies=Xv(n,e);break;case"--generate-textures":t.generateTextures=Xv(n,e);break;case"--generate-bounding-volumes":t.generateBoundingVolumes=Xv(n,e);break;case"--help":$v();break;default:console.warn("Unknown option "+r),process.exit(0)}}),t}(function(e){return e.reduce((e,t)=>{const r=t.indexOf("="),n=t.slice(0,r),i=t.slice(r+1,t.length);return t.includes("=")&&t.startsWith("--")&&i?e.concat(n,i):e.concat(t)},[])}(e));if(t.installDependencies){return void(new Jv).install("deps")}const r=function(e){const t={name:()=>console.log("Missed: --name [Tileset name]"),output:()=>console.log("Missed: --output [Output path name]"),sevenZipExe:()=>console.log("Missed: --7zExe [7z archiver executable path]"),egm:()=>console.log("Missed: --egm [*.pgm earth gravity model file path]"),tileset:()=>console.log("Missed: --tileset [tileset.json file]"),inputType:()=>console.log("Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]")},r=[];for(const n in t){const i=e[n],a=Boolean(i)&&"inputType"===n&&!Object.values(Qv).includes(i.toUpperCase());i&&!a||r.push(t[n])}r.length&&(r.forEach(e=>e()),process.exit(1));return e}(t);await async function(e){console.log("------------------------------------------------"),console.log("Starting conversion of "+e.inputType),console.log("------------------------------------------------");switch(e.inputType.toUpperCase()){case Qv.I3S:(new xm).convert({inputUrl:e.tileset,outputPath:e.output,tilesetName:e.name,maxDepth:e.maxDepth,egmFilePath:e.egm});break;case Qv._3DTILES:const t=new Vv;await t.convert({inputUrl:e.tileset,outputPath:e.output,tilesetName:e.name,maxDepth:e.maxDepth,slpk:e.slpk,sevenZipExe:e.sevenZipExe,egmFilePath:e.egm,token:e.token,draco:e.draco,mergeMaterials:e.mergeMaterials,generateTextures:e.generateTextures,generateBoundingVolumes:e.generateBoundingVolumes,validate:e.validate,instantNodeWriting:e.instantNodeWriting});break;default:$v()}}(r)})().catch(e=>{console.log(e),process.exit(1)})},,,,,,,,function(e,t){e.exports=require("join-images")},function(e,t,r){"use strict";r.d(t,"a",(function(){return w}));var n=r(0),i=r(266);const a="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";Object(i.a)();class o{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";Object(n.a)(this,"storage",void 0),Object(n.a)(this,"id",void 0),Object(n.a)(this,"config",{}),this.storage=function(e){try{const t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch(e){return null}}(r),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function s(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const i=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>n&&(r=Math.min(r,n/e.width));const a=e.width*r,o=e.height*r,s=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(a/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(i,");"),"background-size:".concat(a,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),s]}let u;function c(e){return"string"==typeof e?u[e.toUpperCase()]||u.WHITE:e}function l(e,t){if(!e)throw new Error(t||"Assertion failed")}!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"}(u||(u={}));const h={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},p=(globalThis,h.window||h.self||h.global),f=h.process||{};console;function d(){let e;var t,r;if(i.a&&"performance"in p)e=null==p||null===(t=p.performance)||void 0===t||null===(r=t.now)||void 0===r?void 0:r.call(t);else if("hrtime"in f){var n;const t=null==f||null===(n=f.hrtime)||void 0===n?void 0:n.call(f);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const m={debug:i.a&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},g={enabled:!0,level:0};function y(){}const b={},v={once:!0};class w{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};Object(n.a)(this,"id",void 0),Object(n.a)(this,"VERSION",a),Object(n.a)(this,"_startTs",d()),Object(n.a)(this,"_deltaTs",d()),Object(n.a)(this,"_storage",void 0),Object(n.a)(this,"userData",{}),Object(n.a)(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new o("__probe-".concat(this.id,"__"),g),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r);for(const r of n)"function"==typeof e[r]&&(t.find(e=>r===e)||(e[r]=e[r].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((d()-this._startTs).toPrecision(10))}getDelta(){return Number((d()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){l(e,t)}warn(e){return this._getLogFunction(0,e,m.warn,arguments,v)}error(e){return this._getLogFunction(0,e,m.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,m.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,m.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return this._getLogFunction(e,t,m.debug||m.info,arguments,v)}table(e,t,r){return t?this._getLogFunction(e,t,console.table||y,r&&[r],{tag:x(t)}):y}image(e){let{logLevel:t,priority:n,image:a,message:o="",scale:u=1}=e;return this._shouldLog(t||n)?i.a?function(e){let{image:t,message:r="",scale:n=1}=e;if("string"==typeof t){const e=new Image;return e.onload=()=>{const t=s(e,r,n);console.log(...t)},e.src=t,y}const i=t.nodeName||"";if("img"===i.toLowerCase())return console.log(...s(t,r,n)),y;if("canvas"===i.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...s(e,r,n)),e.src=t.toDataURL(),y}return y}({image:a,message:o,scale:u}):function(e){let{image:t,message:n="",scale:i=1}=e;return function(e){let{image:t,message:n="",scale:i=1}=e,a=null;try{a=r(!function(){var e=new Error("Cannot find module 'asciify-image'");throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}({image:t,message:n,scale:i}),y}({image:a,message:o,scale:u}):y}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||y)}group(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const n=k({logLevel:e,message:t,opts:r}),{collapsed:i}=r;return n.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},r,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||y)}withGroup(e,t,r){this.group(e,t)();try{r()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=_(e)}_getLogFunction(e,t,r,n,a){if(this._shouldLog(e)){a=k({logLevel:e,message:t,args:n,opts:a}),l(r=r||a.method),a.total=this.getTotal(),a.delta=this.getDelta(),this._deltaTs=d();const o=a.tag||a.message;if(a.once){if(b[o])return y;b[o]=d()}return t=function(e,t,r){if("string"==typeof t){const s=r.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const r=Math.max(t-e.length,0);return"".concat(" ".repeat(r)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(r.total)):"";t=r.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),n=t,a=r.color,o=r.background,i.a||"string"!=typeof n||(a&&(a=c(a),n="[".concat(a,"m").concat(n,"")),o&&(a=c(o),n="[".concat(o+10,"m").concat(n,""))),t=n}var n,a,o;return t}(this.id,a.message,a),r.bind(console,t,...a.args)}return y}}function _(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 l(Number.isFinite(t)&&t>=0),t}function k(e){const{logLevel:t,message:r}=e;e.logLevel=_(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":void 0!==r&&n.unshift(r),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const i=typeof e.message;return l("string"===i||"object"===i),Object.assign(e,{args:n},e.opts)}function x(e){for(const t in e)for(const r in e[t])return r||"untitled";return"empty"}Object(n.a)(w,"VERSION",a)}]);
295
+ var n=r(1).inherits,i=r(215).Transform,a=r(237),o=r(64),s=function(e){if(!(this instanceof s))return new s(e);e=this.options=o.defaults(e,{}),i.call(this,e),this.supports={directory:!0,symlink:!0},this.files=[]};n(s,i),s.prototype._transform=function(e,t,r){r(null,e)},s.prototype._writeStringified=function(){var e=JSON.stringify(this.files);this.write(e)},s.prototype.append=function(e,t,r){var n=this;function i(e,i){e?r(e):(t.size=i.length||0,t.crc32=a.unsigned(i),n.files.push(t),r(null,t))}t.crc32=0,"buffer"===t.sourceType?i(null,e):"stream"===t.sourceType&&o.collectStream(e,i)},s.prototype.finalize=function(){this._writeStringified(),this.end()},e.exports=s},function(e,t,r){const n=r(80).get,i=r(80).set,a=r(80).has,o=r(80).isUndefined,s=(e,t,r)=>{const s=Object.keys(t).reduce((r,s)=>{const u=Array.isArray(t[s].path)?t[s].path.filter(t=>a(e,t))[0]:t[s].path,c=u?n(e,u):void 0;return((e,t,r,n,a)=>{const s=e[t].default,u=e[t].transform,c=e[t].omitValues||[];let l=u?u(r,n,a):r;return o(l)&&!o(s)&&(l=s),-1==c.indexOf(l)?i(Object.assign({},n),t,l):n})(t,s,c,r,e)},{});return r?r(s,e):s},u=(e,t,r)=>Array.isArray(e)?((e,t,r)=>e.map(e=>{const n=u(e,t);return r?r(n,e):n}))(e,t,r):s(e,t,r);e.exports=u},function(e,t){e.exports=function(e){if(!e.webpackPolyfill){var t=Object.create(e);t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),Object.defineProperty(t,"exports",{enumerable:!0}),t.webpackPolyfill=1}return t}},function(e,t){function r(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}r.keys=function(){return[]},r.resolve=r,e.exports=r,r.id=540},function(e,t,r){"use strict";r.r(t);var n={};r.r(n),r.d(n,"filename",(function(){return bo})),r.d(n,"dirname",(function(){return vo})),r.d(n,"join",(function(){return wo}));var i={};r.r(i),r.d(i,"readdir",(function(){return ko})),r.d(i,"stat",(function(){return xo})),r.d(i,"readFile",(function(){return Eo})),r.d(i,"readFileSync",(function(){return So})),r.d(i,"writeFile",(function(){return Ao})),r.d(i,"writeFileSync",(function(){return jo})),r.d(i,"open",(function(){return Co})),r.d(i,"close",(function(){return To})),r.d(i,"read",(function(){return Bo})),r.d(i,"fstat",(function(){return Ro})),r.d(i,"createWriteStream",(function(){return Oo})),r.d(i,"isSupported",(function(){return Io})),r.d(i,"_readToArrayBuffer",(function(){return Do}));var a={};r.r(a),r.d(a,"name",(function(){return Og})),r.d(a,"decode",(function(){return Ig}));var o={};r.r(o),r.d(o,"name",(function(){return Lg})),r.d(o,"preprocess",(function(){return Ng}));var s={};r.r(s),r.d(s,"name",(function(){return zg})),r.d(s,"preprocess",(function(){return Ug}));var u={};r.r(u),r.d(u,"name",(function(){return Hg})),r.d(u,"preprocess",(function(){return Gg})),r.d(u,"decode",(function(){return Wg})),r.d(u,"encode",(function(){return Vg}));var c={};r.r(c),r.d(c,"name",(function(){return Xg})),r.d(c,"decode",(function(){return ry}));var l={};r.r(l),r.d(l,"name",(function(){return oy})),r.d(l,"decode",(function(){return sy})),r.d(l,"encode",(function(){return uy}));var h={};r.r(h),r.d(h,"name",(function(){return cy})),r.d(h,"decode",(function(){return ly})),r.d(h,"encode",(function(){return hy}));var p={};r.r(p),r.d(p,"name",(function(){return py})),r.d(p,"decode",(function(){return fy})),r.d(p,"encode",(function(){return dy}));var f={};r.r(f),r.d(f,"name",(function(){return gy})),r.d(f,"decode",(function(){return yy}));var d=r(119);const m="object"!=typeof process||"[object process]"!==String(process)||process.browser,g={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global},y=g.global||g.self||g.window;function b(e,t,r){return t<=e&&e<=r}global["encoding-indexes"]={ibm866:[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,9617,9618,9619,9474,9508,9569,9570,9558,9557,9571,9553,9559,9565,9564,9563,9488,9492,9524,9516,9500,9472,9532,9566,9567,9562,9556,9577,9574,9568,9552,9580,9575,9576,9572,9573,9561,9560,9554,9555,9579,9578,9496,9484,9608,9604,9612,9616,9600,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,1025,1105,1028,1108,1031,1111,1038,1118,176,8729,183,8730,8470,164,9632,160],"iso-8859-2":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,728,321,164,317,346,167,168,352,350,356,377,173,381,379,176,261,731,322,180,318,347,711,184,353,351,357,378,733,382,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],"iso-8859-3":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,294,728,163,164,null,292,167,168,304,350,286,308,173,null,379,176,295,178,179,180,181,293,183,184,305,351,287,309,189,null,380,192,193,194,null,196,266,264,199,200,201,202,203,204,205,206,207,null,209,210,211,212,288,214,215,284,217,218,219,220,364,348,223,224,225,226,null,228,267,265,231,232,233,234,235,236,237,238,239,null,241,242,243,244,289,246,247,285,249,250,251,252,365,349,729],"iso-8859-4":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,312,342,164,296,315,167,168,352,274,290,358,173,381,175,176,261,731,343,180,297,316,711,184,353,275,291,359,330,382,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,298,272,325,332,310,212,213,214,215,216,370,218,219,220,360,362,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,299,273,326,333,311,244,245,246,247,248,371,250,251,252,361,363,729],"iso-8859-5":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,1025,1026,1027,1028,1029,1030,1031,1032,1033,1034,1035,1036,173,1038,1039,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103,8470,1105,1106,1107,1108,1109,1110,1111,1112,1113,1114,1115,1116,167,1118,1119],"iso-8859-6":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,null,null,164,null,null,null,null,null,null,null,1548,173,null,null,null,null,null,null,null,null,null,null,null,null,null,1563,null,null,null,1567,null,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,1591,1592,1593,1594,null,null,null,null,null,1600,1601,1602,1603,1604,1605,1606,1607,1608,1609,1610,1611,1612,1613,1614,1615,1616,1617,1618,null,null,null,null,null,null,null,null,null,null,null,null,null],"iso-8859-7":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8216,8217,163,8364,8367,166,167,168,169,890,171,172,173,null,8213,176,177,178,179,900,901,902,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],"iso-8859-8":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,null,162,163,164,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,8215,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],"iso-8859-10":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,274,290,298,296,310,167,315,272,352,358,381,173,362,330,176,261,275,291,299,297,311,183,316,273,353,359,382,8213,363,331,256,193,194,195,196,197,198,302,268,201,280,203,278,205,206,207,208,325,332,211,212,213,214,360,216,370,218,219,220,221,222,223,257,225,226,227,228,229,230,303,269,233,281,235,279,237,238,239,240,326,333,243,244,245,246,361,248,371,250,251,252,253,254,312],"iso-8859-13":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,8221,162,163,164,8222,166,167,216,169,342,171,172,173,174,198,176,177,178,179,8220,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,8217],"iso-8859-14":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,7682,7683,163,266,267,7690,167,7808,169,7810,7691,7922,173,174,376,7710,7711,288,289,7744,7745,182,7766,7809,7767,7811,7776,7923,7812,7813,7777,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,372,209,210,211,212,213,214,7786,216,217,218,219,220,221,374,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,373,241,242,243,244,245,246,7787,248,249,250,251,252,253,375,255],"iso-8859-15":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,8364,165,352,167,353,169,170,171,172,173,174,175,176,177,178,179,381,181,182,183,382,185,186,187,338,339,376,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],"iso-8859-16":[128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,260,261,321,8364,8222,352,167,353,169,536,171,377,173,378,379,176,177,268,322,381,8221,182,183,382,269,537,187,338,339,376,380,192,193,194,258,196,262,198,199,200,201,202,203,204,205,206,207,272,323,210,211,212,336,214,346,368,217,218,219,220,280,538,223,224,225,226,259,228,263,230,231,232,233,234,235,236,237,238,239,273,324,242,243,244,337,246,347,369,249,250,251,252,281,539,255],"koi8-r":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,9555,9556,9557,9558,9559,9560,9561,9562,9563,9564,9565,9566,9567,9568,9569,1025,9570,9571,9572,9573,9574,9575,9576,9577,9578,9579,9580,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],"koi8-u":[9472,9474,9484,9488,9492,9496,9500,9508,9516,9524,9532,9600,9604,9608,9612,9616,9617,9618,9619,8992,9632,8729,8730,8776,8804,8805,160,8993,176,178,183,247,9552,9553,9554,1105,1108,9556,1110,1111,9559,9560,9561,9562,9563,1169,1118,9566,9567,9568,9569,1025,1028,9571,1030,1031,9574,9575,9576,9577,9578,1168,1038,169,1102,1072,1073,1094,1076,1077,1092,1075,1093,1080,1081,1082,1083,1084,1085,1086,1087,1103,1088,1089,1090,1091,1078,1074,1100,1099,1079,1096,1101,1097,1095,1098,1070,1040,1041,1062,1044,1045,1060,1043,1061,1048,1049,1050,1051,1052,1053,1054,1055,1071,1056,1057,1058,1059,1046,1042,1068,1067,1047,1064,1069,1065,1063,1066],macintosh:[196,197,199,201,209,214,220,225,224,226,228,227,229,231,233,232,234,235,237,236,238,239,241,243,242,244,246,245,250,249,251,252,8224,176,162,163,167,8226,182,223,174,169,8482,180,168,8800,198,216,8734,177,8804,8805,165,181,8706,8721,8719,960,8747,170,186,937,230,248,191,161,172,8730,402,8776,8710,171,187,8230,160,192,195,213,338,339,8211,8212,8220,8221,8216,8217,247,9674,255,376,8260,8364,8249,8250,64257,64258,8225,183,8218,8222,8240,194,202,193,203,200,205,206,207,204,211,212,63743,210,218,219,217,305,710,732,175,728,729,730,184,733,731,711],"windows-874":[8364,129,130,131,132,8230,134,135,136,137,138,139,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,153,154,155,156,157,158,159,160,3585,3586,3587,3588,3589,3590,3591,3592,3593,3594,3595,3596,3597,3598,3599,3600,3601,3602,3603,3604,3605,3606,3607,3608,3609,3610,3611,3612,3613,3614,3615,3616,3617,3618,3619,3620,3621,3622,3623,3624,3625,3626,3627,3628,3629,3630,3631,3632,3633,3634,3635,3636,3637,3638,3639,3640,3641,3642,null,null,null,null,3647,3648,3649,3650,3651,3652,3653,3654,3655,3656,3657,3658,3659,3660,3661,3662,3663,3664,3665,3666,3667,3668,3669,3670,3671,3672,3673,3674,3675,null,null,null,null],"windows-1250":[8364,129,8218,131,8222,8230,8224,8225,136,8240,352,8249,346,356,381,377,144,8216,8217,8220,8221,8226,8211,8212,152,8482,353,8250,347,357,382,378,160,711,728,321,164,260,166,167,168,169,350,171,172,173,174,379,176,177,731,322,180,181,182,183,184,261,351,187,317,733,318,380,340,193,194,258,196,313,262,199,268,201,280,203,282,205,206,270,272,323,327,211,212,336,214,215,344,366,218,368,220,221,354,223,341,225,226,259,228,314,263,231,269,233,281,235,283,237,238,271,273,324,328,243,244,337,246,247,345,367,250,369,252,253,355,729],"windows-1251":[1026,1027,8218,1107,8222,8230,8224,8225,8364,8240,1033,8249,1034,1036,1035,1039,1106,8216,8217,8220,8221,8226,8211,8212,152,8482,1113,8250,1114,1116,1115,1119,160,1038,1118,1032,164,1168,166,167,1025,169,1028,171,172,173,174,1031,176,177,1030,1110,1169,181,182,183,1105,8470,1108,187,1112,1029,1109,1111,1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,1103],"windows-1252":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,381,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,382,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255],"windows-1253":[8364,129,8218,402,8222,8230,8224,8225,136,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,157,158,159,160,901,902,163,164,165,166,167,168,169,null,171,172,173,174,8213,176,177,178,179,900,181,182,183,904,905,906,187,908,189,910,911,912,913,914,915,916,917,918,919,920,921,922,923,924,925,926,927,928,929,null,931,932,933,934,935,936,937,938,939,940,941,942,943,944,945,946,947,948,949,950,951,952,953,954,955,956,957,958,959,960,961,962,963,964,965,966,967,968,969,970,971,972,973,974,null],"windows-1254":[8364,129,8218,402,8222,8230,8224,8225,710,8240,352,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,353,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,286,209,210,211,212,213,214,215,216,217,218,219,220,304,350,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,287,241,242,243,244,245,246,247,248,249,250,251,252,305,351,255],"windows-1255":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,140,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,156,157,158,159,160,161,162,163,8362,165,166,167,168,169,215,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,247,187,188,189,190,191,1456,1457,1458,1459,1460,1461,1462,1463,1464,1465,1466,1467,1468,1469,1470,1471,1472,1473,1474,1475,1520,1521,1522,1523,1524,null,null,null,null,null,null,null,1488,1489,1490,1491,1492,1493,1494,1495,1496,1497,1498,1499,1500,1501,1502,1503,1504,1505,1506,1507,1508,1509,1510,1511,1512,1513,1514,null,null,8206,8207,null],"windows-1256":[8364,1662,8218,402,8222,8230,8224,8225,710,8240,1657,8249,338,1670,1688,1672,1711,8216,8217,8220,8221,8226,8211,8212,1705,8482,1681,8250,339,8204,8205,1722,160,1548,162,163,164,165,166,167,168,169,1726,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,1563,187,188,189,190,1567,1729,1569,1570,1571,1572,1573,1574,1575,1576,1577,1578,1579,1580,1581,1582,1583,1584,1585,1586,1587,1588,1589,1590,215,1591,1592,1593,1594,1600,1601,1602,1603,224,1604,226,1605,1606,1607,1608,231,232,233,234,235,1609,1610,238,239,1611,1612,1613,1614,244,1615,1616,247,1617,249,1618,251,252,8206,8207,1746],"windows-1257":[8364,129,8218,131,8222,8230,8224,8225,136,8240,138,8249,140,168,711,184,144,8216,8217,8220,8221,8226,8211,8212,152,8482,154,8250,156,175,731,159,160,null,162,163,164,null,166,167,216,169,342,171,172,173,174,198,176,177,178,179,180,181,182,183,248,185,343,187,188,189,190,230,260,302,256,262,196,197,280,274,268,201,377,278,290,310,298,315,352,323,325,211,332,213,214,215,370,321,346,362,220,379,381,223,261,303,257,263,228,229,281,275,269,233,378,279,291,311,299,316,353,324,326,243,333,245,246,247,371,322,347,363,252,380,382,729],"windows-1258":[8364,129,8218,402,8222,8230,8224,8225,710,8240,138,8249,338,141,142,143,144,8216,8217,8220,8221,8226,8211,8212,732,8482,154,8250,339,157,158,376,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,258,196,197,198,199,200,201,202,203,768,205,206,207,272,209,777,211,212,416,214,215,216,217,218,219,220,431,771,223,224,225,226,259,228,229,230,231,232,233,234,235,769,237,238,239,273,241,803,243,244,417,246,247,248,249,250,251,252,432,8363,255],"x-mac-cyrillic":[1040,1041,1042,1043,1044,1045,1046,1047,1048,1049,1050,1051,1052,1053,1054,1055,1056,1057,1058,1059,1060,1061,1062,1063,1064,1065,1066,1067,1068,1069,1070,1071,8224,176,1168,163,167,8226,182,1030,174,169,8482,1026,1106,8800,1027,1107,8734,177,8804,8805,1110,181,1169,1032,1028,1108,1031,1111,1033,1113,1034,1114,1112,1029,172,8730,402,8776,8710,171,187,8230,160,1035,1115,1036,1116,1109,8211,8212,8220,8221,8216,8217,247,8222,1038,1118,1039,1119,8470,1025,1105,1103,1072,1073,1074,1075,1076,1077,1078,1079,1080,1081,1082,1083,1084,1085,1086,1087,1088,1089,1090,1091,1092,1093,1094,1095,1096,1097,1098,1099,1100,1101,1102,8364]}||{};var v=Math.floor;function w(e){if(void 0===e)return{};if(e===Object(e))return e;throw TypeError("Could not convert argument to dictionary")}function _(e){return 0<=e&&e<=127}var k=_;function x(e){this.tokens=[].slice.call(e),this.tokens.reverse()}x.prototype={endOfStream:function(){return!this.tokens.length},read:function(){return this.tokens.length?this.tokens.pop():-1},prepend:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.push(t.pop());else this.tokens.push(e)},push:function(e){if(Array.isArray(e))for(var t=e;t.length;)this.tokens.unshift(t.shift());else this.tokens.unshift(e)}};function E(e,t){if(e)throw TypeError("Decoder error");return t||65533}function S(e){throw TypeError("The code point "+e+" could not be encoded.")}function A(e){return e=String(e).trim().toLowerCase(),Object.prototype.hasOwnProperty.call(C,e)?C[e]:null}var j=[{encodings:[{labels:["unicode-1-1-utf-8","utf-8","utf8"],name:"UTF-8"}],heading:"The Encoding"},{encodings:[{labels:["866","cp866","csibm866","ibm866"],name:"IBM866"},{labels:["csisolatin2","iso-8859-2","iso-ir-101","iso8859-2","iso88592","iso_8859-2","iso_8859-2:1987","l2","latin2"],name:"ISO-8859-2"},{labels:["csisolatin3","iso-8859-3","iso-ir-109","iso8859-3","iso88593","iso_8859-3","iso_8859-3:1988","l3","latin3"],name:"ISO-8859-3"},{labels:["csisolatin4","iso-8859-4","iso-ir-110","iso8859-4","iso88594","iso_8859-4","iso_8859-4:1988","l4","latin4"],name:"ISO-8859-4"},{labels:["csisolatincyrillic","cyrillic","iso-8859-5","iso-ir-144","iso8859-5","iso88595","iso_8859-5","iso_8859-5:1988"],name:"ISO-8859-5"},{labels:["arabic","asmo-708","csiso88596e","csiso88596i","csisolatinarabic","ecma-114","iso-8859-6","iso-8859-6-e","iso-8859-6-i","iso-ir-127","iso8859-6","iso88596","iso_8859-6","iso_8859-6:1987"],name:"ISO-8859-6"},{labels:["csisolatingreek","ecma-118","elot_928","greek","greek8","iso-8859-7","iso-ir-126","iso8859-7","iso88597","iso_8859-7","iso_8859-7:1987","sun_eu_greek"],name:"ISO-8859-7"},{labels:["csiso88598e","csisolatinhebrew","hebrew","iso-8859-8","iso-8859-8-e","iso-ir-138","iso8859-8","iso88598","iso_8859-8","iso_8859-8:1988","visual"],name:"ISO-8859-8"},{labels:["csiso88598i","iso-8859-8-i","logical"],name:"ISO-8859-8-I"},{labels:["csisolatin6","iso-8859-10","iso-ir-157","iso8859-10","iso885910","l6","latin6"],name:"ISO-8859-10"},{labels:["iso-8859-13","iso8859-13","iso885913"],name:"ISO-8859-13"},{labels:["iso-8859-14","iso8859-14","iso885914"],name:"ISO-8859-14"},{labels:["csisolatin9","iso-8859-15","iso8859-15","iso885915","iso_8859-15","l9"],name:"ISO-8859-15"},{labels:["iso-8859-16"],name:"ISO-8859-16"},{labels:["cskoi8r","koi","koi8","koi8-r","koi8_r"],name:"KOI8-R"},{labels:["koi8-ru","koi8-u"],name:"KOI8-U"},{labels:["csmacintosh","mac","macintosh","x-mac-roman"],name:"macintosh"},{labels:["dos-874","iso-8859-11","iso8859-11","iso885911","tis-620","windows-874"],name:"windows-874"},{labels:["cp1250","windows-1250","x-cp1250"],name:"windows-1250"},{labels:["cp1251","windows-1251","x-cp1251"],name:"windows-1251"},{labels:["ansi_x3.4-1968","ascii","cp1252","cp819","csisolatin1","ibm819","iso-8859-1","iso-ir-100","iso8859-1","iso88591","iso_8859-1","iso_8859-1:1987","l1","latin1","us-ascii","windows-1252","x-cp1252"],name:"windows-1252"},{labels:["cp1253","windows-1253","x-cp1253"],name:"windows-1253"},{labels:["cp1254","csisolatin5","iso-8859-9","iso-ir-148","iso8859-9","iso88599","iso_8859-9","iso_8859-9:1989","l5","latin5","windows-1254","x-cp1254"],name:"windows-1254"},{labels:["cp1255","windows-1255","x-cp1255"],name:"windows-1255"},{labels:["cp1256","windows-1256","x-cp1256"],name:"windows-1256"},{labels:["cp1257","windows-1257","x-cp1257"],name:"windows-1257"},{labels:["cp1258","windows-1258","x-cp1258"],name:"windows-1258"},{labels:["x-mac-cyrillic","x-mac-ukrainian"],name:"x-mac-cyrillic"}],heading:"Legacy single-byte encodings"},{encodings:[{labels:["chinese","csgb2312","csiso58gb231280","gb2312","gb_2312","gb_2312-80","gbk","iso-ir-58","x-gbk"],name:"GBK"},{labels:["gb18030"],name:"gb18030"}],heading:"Legacy multi-byte Chinese (simplified) encodings"},{encodings:[{labels:["big5","big5-hkscs","cn-big5","csbig5","x-x-big5"],name:"Big5"}],heading:"Legacy multi-byte Chinese (traditional) encodings"},{encodings:[{labels:["cseucpkdfmtjapanese","euc-jp","x-euc-jp"],name:"EUC-JP"},{labels:["csiso2022jp","iso-2022-jp"],name:"ISO-2022-JP"},{labels:["csshiftjis","ms932","ms_kanji","shift-jis","shift_jis","sjis","windows-31j","x-sjis"],name:"Shift_JIS"}],heading:"Legacy multi-byte Japanese encodings"},{encodings:[{labels:["cseuckr","csksc56011987","euc-kr","iso-ir-149","korean","ks_c_5601-1987","ks_c_5601-1989","ksc5601","ksc_5601","windows-949"],name:"EUC-KR"}],heading:"Legacy multi-byte Korean encodings"},{encodings:[{labels:["csiso2022kr","hz-gb-2312","iso-2022-cn","iso-2022-cn-ext","iso-2022-kr"],name:"replacement"},{labels:["utf-16be"],name:"UTF-16BE"},{labels:["utf-16","utf-16le"],name:"UTF-16LE"},{labels:["x-user-defined"],name:"x-user-defined"}],heading:"Legacy miscellaneous encodings"}],C={};j.forEach((function(e){e.encodings.forEach((function(e){e.labels.forEach((function(t){C[t]=e}))}))}));var T,B,R={},O={};function I(e,t){return t&&t[e]||null}function P(e,t){var r=t.indexOf(e);return-1===r?null:r}function D(e){if(!("encoding-indexes"in global))throw Error("Indexes missing. Did you forget to include encoding-indexes.js first?");return global["encoding-indexes"][e]}function M(e,t){if(!(this instanceof M))throw TypeError("Called as a function. Did you forget 'new'?");e=void 0!==e?String(e):"utf-8",t=w(t),this._encoding=null,this._decoder=null,this._ignoreBOM=!1,this._BOMseen=!1,this._error_mode="replacement",this._do_not_flush=!1;var r=A(e);if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!O[r.name])throw Error("Decoder not present. Did you forget to include encoding-indexes.js first?");return this._encoding=r,Boolean(t.fatal)&&(this._error_mode="fatal"),Boolean(t.ignoreBOM)&&(this._ignoreBOM=!0),Object.defineProperty||(this.encoding=this._encoding.name.toLowerCase(),this.fatal="fatal"===this._error_mode,this.ignoreBOM=this._ignoreBOM),this}function F(e,t){if(!(this instanceof F))throw TypeError("Called as a function. Did you forget 'new'?");t=w(t),this._encoding=null,this._encoder=null,this._do_not_flush=!1,this._fatal=Boolean(t.fatal)?"fatal":"replacement";if(Boolean(t.NONSTANDARD_allowLegacyEncoding)){var r=A(e=void 0!==e?String(e):"utf-8");if(null===r||"replacement"===r.name)throw RangeError("Unknown encoding: "+e);if(!R[r.name])throw Error("Encoder not present. Did you forget to include encoding-indexes.js first?");this._encoding=r}else this._encoding=A("utf-8"),void 0!==e&&"console"in global&&console.warn("TextEncoder constructor called with encoding label, which is ignored.");return Object.defineProperty||(this.encoding=this._encoding.name.toLowerCase()),this}function L(e){var t=e.fatal,r=0,n=0,i=0,a=128,o=191;this.handler=function(e,s){if(-1===s&&0!==i)return i=0,E(t);if(-1===s)return-1;if(0===i){if(b(s,0,127))return s;if(b(s,194,223))i=1,r=31&s;else if(b(s,224,239))224===s&&(a=160),237===s&&(o=159),i=2,r=15&s;else{if(!b(s,240,244))return E(t);240===s&&(a=144),244===s&&(o=143),i=3,r=7&s}return null}if(!b(s,a,o))return r=i=n=0,a=128,o=191,e.prepend(s),E(t);if(a=128,o=191,r=r<<6|63&s,(n+=1)!==i)return null;var u=r;return r=i=n=0,u}}function N(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r,n;b(t,128,2047)?(r=1,n=192):b(t,2048,65535)?(r=2,n=224):b(t,65536,1114111)&&(r=3,n=240);for(var i=[(t>>6*r)+n];r>0;){var a=t>>6*(r-1);i.push(128|63&a),r-=1}return i}}function z(e,t){var r=t.fatal;this.handler=function(t,n){if(-1===n)return-1;if(_(n))return n;var i=e[n-128];return null===i?E(r):i}}function U(e,t){t.fatal;this.handler=function(t,r){if(-1===r)return-1;if(k(r))return r;var n=P(r,e);return null===n&&S(r),n+128}}function q(e){var t=e.fatal,r=0,n=0,i=0;this.handler=function(e,a){if(-1===a&&0===r&&0===n&&0===i)return-1;var o;if(-1!==a||0===r&&0===n&&0===i||(r=0,n=0,i=0,E(t)),0!==i){o=null,b(a,48,57)&&(o=function(e){if(e>39419&&e<189e3||e>1237575)return null;if(7457===e)return 59335;var t,r=0,n=0,i=D("gb18030-ranges");for(t=0;t<i.length;++t){var a=i[t];if(!(a[0]<=e))break;r=a[0],n=a[1]}return n+e-r}(10*(126*(10*(r-129)+n-48)+i-129)+a-48));var s=[n,i,a];return r=0,n=0,i=0,null===o?(e.prepend(s),E(t)):o}if(0!==n)return b(a,129,254)?(i=a,null):(e.prepend([n,a]),r=0,n=0,E(t));if(0!==r){if(b(a,48,57))return n=a,null;var u=r,c=null;r=0;var l=a<127?64:65;return(b(a,64,126)||b(a,128,254))&&(c=190*(u-129)+(a-l)),null===(o=null===c?null:I(c,D("gb18030")))&&_(a)&&e.prepend(a),null===o?E(t):o}return _(a)?a:128===a?8364:b(a,129,254)?(r=a,null):E(t)}}function H(e,t){e.fatal;this.handler=function(e,r){if(-1===r)return-1;if(k(r))return r;if(58853===r)return S(r);if(t&&8364===r)return 128;var n=P(r,D("gb18030"));if(null!==n){var i=n%190;return[v(n/190)+129,i+(i<63?64:65)]}if(t)return S(r);n=function(e){if(59335===e)return 7457;var t,r=0,n=0,i=D("gb18030-ranges");for(t=0;t<i.length;++t){var a=i[t];if(!(a[1]<=e))break;r=a[1],n=a[0]}return n+e-r}(r);var a=v(n/10/126/10),o=v((n-=10*a*126*10)/10/126),s=v((n-=10*o*126)/10);return[a+129,o+48,s+129,n-10*s+48]}}function G(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0;var o=n<127?64:98;switch((b(n,64,126)||b(n,161,254))&&(a=157*(i-129)+(n-o)),a){case 1133:return[202,772];case 1135:return[202,780];case 1164:return[234,772];case 1166:return[234,780]}var s=null===a?null:I(a,D("big5"));return null===s&&_(n)&&e.prepend(n),null===s?E(t):s}return _(n)?n:b(n,129,254)?(r=n,null):E(t)}}function W(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r=function(e){var t=B=B||D("big5").map((function(e,t){return t<5024?null:e}));return 9552===e||9566===e||9569===e||9578===e||21313===e||21317===e?t.lastIndexOf(e):P(e,t)}(t);if(null===r)return S(t);var n=v(r/157)+129;if(n<161)return S(t);var i=r%157;return[n,i+(i<63?64:98)]}}function V(e){var t=e.fatal,r=!1,n=0;this.handler=function(e,i){if(-1===i&&0!==n)return n=0,E(t);if(-1===i&&0===n)return-1;if(142===n&&b(i,161,223))return n=0,65216+i;if(143===n&&b(i,161,254))return r=!0,n=i,null;if(0!==n){var a=n;n=0;var o=null;return b(a,161,254)&&b(i,161,254)&&(o=I(94*(a-161)+(i-161),D(r?"jis0212":"jis0208"))),r=!1,b(i,161,254)||e.prepend(i),null===o?E(t):o}return _(i)?i:142===i||143===i||b(i,161,254)?(n=i,null):E(t)}}function K(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;if(165===t)return 92;if(8254===t)return 126;if(b(t,65377,65439))return[142,t-65377+161];8722===t&&(t=65293);var r=P(t,D("jis0208"));return null===r?S(t):[v(r/94)+161,r%94+161]}}function J(e){var t=e.fatal,r=0,n=1,i=2,a=3,o=4,s=5,u=6,c=r,l=r,h=0,p=!1;this.handler=function(e,f){switch(c){default:case r:return 27===f?(c=s,null):b(f,0,127)&&14!==f&&15!==f&&27!==f?(p=!1,f):-1===f?-1:(p=!1,E(t));case n:return 27===f?(c=s,null):92===f?(p=!1,165):126===f?(p=!1,8254):b(f,0,127)&&14!==f&&15!==f&&27!==f&&92!==f&&126!==f?(p=!1,f):-1===f?-1:(p=!1,E(t));case i:return 27===f?(c=s,null):b(f,33,95)?(p=!1,65344+f):-1===f?-1:(p=!1,E(t));case a:return 27===f?(c=s,null):b(f,33,126)?(p=!1,h=f,c=o,null):-1===f?-1:(p=!1,E(t));case o:if(27===f)return c=s,E(t);if(b(f,33,126)){c=a;var d=I(94*(h-33)+f-33,D("jis0208"));return null===d?E(t):d}return-1===f?(c=a,e.prepend(f),E(t)):(c=a,E(t));case s:return 36===f||40===f?(h=f,c=u,null):(e.prepend(f),p=!1,c=l,E(t));case u:var m=h;h=0;var g=null;if(40===m&&66===f&&(g=r),40===m&&74===f&&(g=n),40===m&&73===f&&(g=i),36!==m||64!==f&&66!==f||(g=a),null!==g){c=c=g;var y=p;return p=!0,y?E(t):null}return e.prepend([m,f]),p=!1,c=l,E(t)}}}function Q(e){e.fatal;var t=0,r=1,n=2,i=t;this.handler=function(e,a){if(-1===a&&i!==t)return e.prepend(a),i=t,[27,40,66];if(-1===a&&i===t)return-1;if(!(i!==t&&i!==r||14!==a&&15!==a&&27!==a))return S(65533);if(i===t&&k(a))return a;if(i===r&&(k(a)&&92!==a&&126!==a||165==a||8254==a)){if(k(a))return a;if(165===a)return 92;if(8254===a)return 126}if(k(a)&&i!==t)return e.prepend(a),i=t,[27,40,66];if((165===a||8254===a)&&i!==r)return e.prepend(a),i=r,[27,40,74];8722===a&&(a=65293);var o=P(a,D("jis0208"));return null===o?S(a):i!==n?(e.prepend(a),i=n,[27,36,66]):[v(o/94)+33,o%94+33]}}function $(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0;var o=n<127?64:65,s=i<160?129:193;if((b(n,64,126)||b(n,128,252))&&(a=188*(i-s)+n-o),b(a,8836,10715))return 48508+a;var u=null===a?null:I(a,D("jis0208"));return null===u&&_(n)&&e.prepend(n),null===u?E(t):u}return _(n)||128===n?n:b(n,161,223)?65216+n:b(n,129,159)||b(n,224,252)?(r=n,null):E(t)}}function Y(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t)||128===t)return t;if(165===t)return 92;if(8254===t)return 126;if(b(t,65377,65439))return t-65377+161;8722===t&&(t=65293);var r=function(e){return(T=T||D("jis0208").map((function(e,t){return b(t,8272,8835)?null:e}))).indexOf(e)}(t);if(null===r)return S(t);var n=v(r/188),i=r%188;return[n+(n<31?129:193),i+(i<63?64:65)]}}function X(e){var t=e.fatal,r=0;this.handler=function(e,n){if(-1===n&&0!==r)return r=0,E(t);if(-1===n&&0===r)return-1;if(0!==r){var i=r,a=null;r=0,b(n,65,254)&&(a=190*(i-129)+(n-65));var o=null===a?null:I(a,D("euc-kr"));return null===a&&_(n)&&e.prepend(n),null===o?E(t):o}return _(n)?n:b(n,129,254)?(r=n,null):E(t)}}function Z(e){e.fatal;this.handler=function(e,t){if(-1===t)return-1;if(k(t))return t;var r=P(t,D("euc-kr"));return null===r?S(t):[v(r/190)+129,r%190+65]}}function ee(e,t){var r=e>>8,n=255&e;return t?[r,n]:[n,r]}function te(e,t){var r=t.fatal,n=null,i=null;this.handler=function(t,a){if(-1===a&&(null!==n||null!==i))return E(r);if(-1===a&&null===n&&null===i)return-1;if(null===n)return n=a,null;var o;if(o=e?(n<<8)+a:(a<<8)+n,n=null,null!==i){var s=i;return i=null,b(o,56320,57343)?65536+1024*(s-55296)+(o-56320):(t.prepend(ee(o,e)),E(r))}return b(o,55296,56319)?(i=o,null):b(o,56320,57343)?E(r):o}}function re(e,t){t.fatal;this.handler=function(t,r){if(-1===r)return-1;if(b(r,0,65535))return ee(r,e);var n=ee(55296+(r-65536>>10),e),i=ee(56320+(r-65536&1023),e);return n.concat(i)}}function ne(e){e.fatal;this.handler=function(e,t){return-1===t?-1:_(t)?t:63360+t-128}}function ie(e){e.fatal;this.handler=function(e,t){return-1===t?-1:k(t)?t:b(t,63360,63487)?t-63360+128:S(t)}}Object.defineProperty&&(Object.defineProperty(M.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),Object.defineProperty(M.prototype,"fatal",{get:function(){return"fatal"===this._error_mode}}),Object.defineProperty(M.prototype,"ignoreBOM",{get:function(){return this._ignoreBOM}})),M.prototype.decode=function(e,t){var r;r="object"==typeof e&&e instanceof ArrayBuffer?new Uint8Array(e):"object"==typeof e&&"buffer"in e&&e.buffer instanceof ArrayBuffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(0),t=w(t),this._do_not_flush||(this._decoder=O[this._encoding.name]({fatal:"fatal"===this._error_mode}),this._BOMseen=!1),this._do_not_flush=Boolean(t.stream);for(var n,i=new x(r),a=[];;){var o=i.read();if(-1===o)break;if(-1===(n=this._decoder.handler(i,o)))break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}if(!this._do_not_flush){do{if(-1===(n=this._decoder.handler(i,i.read())))break;null!==n&&(Array.isArray(n)?a.push.apply(a,n):a.push(n))}while(!i.endOfStream());this._decoder=null}return function(e){var t,r;return t=["UTF-8","UTF-16LE","UTF-16BE"],r=this._encoding.name,-1===t.indexOf(r)||this._ignoreBOM||this._BOMseen||(e.length>0&&65279===e[0]?(this._BOMseen=!0,e.shift()):e.length>0&&(this._BOMseen=!0)),function(e){for(var t="",r=0;r<e.length;++r){var n=e[r];n<=65535?t+=String.fromCharCode(n):(n-=65536,t+=String.fromCharCode(55296+(n>>10),56320+(1023&n)))}return t}(e)}.call(this,a)},Object.defineProperty&&Object.defineProperty(F.prototype,"encoding",{get:function(){return this._encoding.name.toLowerCase()}}),F.prototype.encode=function(e,t){e=void 0===e?"":String(e),t=w(t),this._do_not_flush||(this._encoder=R[this._encoding.name]({fatal:"fatal"===this._fatal})),this._do_not_flush=Boolean(t.stream);for(var r,n=new x(function(e){for(var t=String(e),r=t.length,n=0,i=[];n<r;){var a=t.charCodeAt(n);if(a<55296||a>57343)i.push(a);else if(56320<=a&&a<=57343)i.push(65533);else if(55296<=a&&a<=56319)if(n===r-1)i.push(65533);else{var o=t.charCodeAt(n+1);if(56320<=o&&o<=57343){var s=1023&a,u=1023&o;i.push(65536+(s<<10)+u),n+=1}else i.push(65533)}n+=1}return i}(e)),i=[];;){var a=n.read();if(-1===a)break;if(-1===(r=this._encoder.handler(n,a)))break;Array.isArray(r)?i.push.apply(i,r):i.push(r)}if(!this._do_not_flush){for(;-1!==(r=this._encoder.handler(n,n.read()));)Array.isArray(r)?i.push.apply(i,r):i.push(r);this._encoder=null}return new Uint8Array(i)},R["UTF-8"]=function(e){return new N(e)},O["UTF-8"]=function(e){return new L(e)},"encoding-indexes"in global&&j.forEach((function(e){"Legacy single-byte encodings"===e.heading&&e.encodings.forEach((function(e){var t=e.name,r=D(t.toLowerCase());O[t]=function(e){return new z(r,e)},R[t]=function(e){return new U(r,e)}}))})),O.GBK=function(e){return new q(e)},R.GBK=function(e){return new H(e,!0)},R.gb18030=function(e){return new H(e)},O.gb18030=function(e){return new q(e)},R.Big5=function(e){return new W(e)},O.Big5=function(e){return new G(e)},R["EUC-JP"]=function(e){return new K(e)},O["EUC-JP"]=function(e){return new V(e)},R["ISO-2022-JP"]=function(e){return new Q(e)},O["ISO-2022-JP"]=function(e){return new J(e)},R.Shift_JIS=function(e){return new Y(e)},O.Shift_JIS=function(e){return new $(e)},R["EUC-KR"]=function(e){return new Z(e)},O["EUC-KR"]=function(e){return new X(e)},R["UTF-16BE"]=function(e){return new re(!0,e)},O["UTF-16BE"]=function(e){return new te(!0,e)},R["UTF-16LE"]=function(e){return new re(!1,e)},O["UTF-16LE"]=function(e){return new te(!1,e)},R["x-user-defined"]=function(e){return new ie(e)},O["x-user-defined"]=function(e){return new ne(e)};function ae(e){return Buffer.from(e).toString("base64")}function oe(e){return Buffer.from(e,"base64").toString("ascii")}let se;se=Symbol.iterator;class ue{constructor(e){var t,r,n;n=void 0,(r="map")in(t=this)?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,this.map={},e instanceof ue?e.forEach((e,t)=>this.append(t,e)):Array.isArray(e)?e.forEach(e=>this.append(e[0],e[1])):e&&Object.getOwnPropertyNames(e).forEach(t=>this.append(t,e[t]))}append(e,t){e=ce(e),t=le(t);const r=this.map[e];this.map[e]=r?`${r}, ${t}`:t}delete(e){delete this.map[ce(e)]}get(e){return e=ce(e),this.has(e)?this.map[e]:null}has(e){return this.map.hasOwnProperty(ce(e))}set(e,t){this.map[ce(e)]=le(t)}forEach(e,t=null){for(const r in this.map)this.map.hasOwnProperty(r)&&(t?e.call(t,this.map[r],r,this):e(this.map[r],r,this))}keys(){const e=[];return this.forEach((function(t,r){e.push(r)})),he(e)}values(){const e=[];return this.forEach((function(t){e.push(t)})),he(e)}entries(){const e=[];return this.forEach((function(t,r){e.push([r,t])})),he(e)}*[se](){yield*this.entries()}}function ce(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function le(e){return"string"!=typeof e&&(e=String(e)),e}function he(e){const t={next(){const t=e.shift();return{done:void 0===t,value:t}}};return t[Symbol.iterator]=function(){return t},t}function pe(e,t){if(!e)throw new Error("@loaders.gl/polyfills assertion "+t)}var fe=r(16),de=r.n(fe);function me(e){if((t=e)&&t instanceof ArrayBuffer)return e;var t;if((e=>e&&e instanceof Buffer)(e)){return new Uint8Array(e).buffer}if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error(`toArrayBuffer(${JSON.stringify(e,null,2).slice(10)})`)}async function ge(e){const t=[];return await new Promise((r,n)=>{e.on("error",e=>n(e)),e.on("readable",()=>e.read()),e.on("data",e=>{"string"==typeof e&&n(new Error("Read stream not binary")),t.push(me(e))}),e.on("end",()=>{const e=function(e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),r=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(r);let i=0;for(const e of t)n.set(e,i),i+=e.byteLength;return n.buffer}(t);r(e)})})}var ye=r(5);function be(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const ve=e=>"function"==typeof e,we=e=>(e=>null!==e&&"object"==typeof e)(e)&&ve(e.read)&&ve(e.pipe)&&(e=>"boolean"==typeof e)(e.readable);class _e{constructor(e,t){be(this,"ok",void 0),be(this,"status",void 0),be(this,"statusText",void 0),be(this,"headers",void 0),be(this,"url",void 0),be(this,"bodyUsed",!1),be(this,"_body",void 0);const{headers:r,status:n=200,statusText:i="OK",url:a}=t||{};this.url=a,this.ok=200===n,this.status=n,this.statusText=i,this.headers=new ue((null==t?void 0:t.headers)||{}),we(e)?this._body=function(e,t){switch(t.get("content-encoding")){case"br":return e.pipe(de.a.createBrotliDecompress());case"gzip":return e.pipe(de.a.createGunzip());case"deflate":return e.pipe(de.a.createDeflate());default:return e}}(e,r):this._body="string"==typeof e?ye.Readable.from([(new TextEncoder).encode(e)]):ye.Readable.from([e||new ArrayBuffer(0)])}get body(){return pe(!this.bodyUsed),pe(we(this._body)),this.bodyUsed=!0,this._body}async arrayBuffer(){if(!we(this._body))return this._body||new ArrayBuffer(0);return await ge(this._body)}async text(){const e=await this.arrayBuffer();return(new TextDecoder).decode(e)}async json(){const e=await this.text();return JSON.parse(e)}async blob(){if("undefined"==typeof Blob)throw new Error("Blob polyfill not installed");return new Blob([await this.arrayBuffer()])}}var ke=r(40),xe=r.n(ke),Ee=r(51),Se=r.n(Ee),Ae=r(3),je=r.n(Ae);async function Ce(e,t){const r=e.split("?")[0];try{const t=await new Promise((e,t)=>{const n=je.a.createReadStream(r,{encoding:null});n.once("readable",()=>e(n)),n.on("error",e=>t(e))}),n=200,i="OK",a=function(e){const t={};if(!t["content-length"]){const r=je.a.statSync(e);t["content-length"]=r.size}e.endsWith(".gz")&&(e=e.slice(0,-3),t["content-encoding"]="gzip");return new ue(t)}(r);return new _e(t,{headers:a,status:n,statusText:i,url:e})}catch(t){const r=400,n=t.message,i={};return new _e(t.message,{headers:i,status:r,statusText:n,url:e})}}const Te=e=>e.startsWith("data:");async function Be(e,t){try{if(!(e=>e.startsWith("http:")||e.startsWith("https:"))(e)&&!Te(e))return await Ce(e);if(Te(e)){const{arrayBuffer:t,mimeType:r}=function(e){const t=e.indexOf(",");let r,n;return";base64"===e.slice(t-7,t)?(r=Buffer.from(e.slice(t+1),"base64"),n=e.slice(5,t-7).trim()):(r=Buffer.from(decodeURIComponent(e.slice(t+1))),n=e.slice(5,t).trim()),n?n.startsWith(";")&&(n="text/plain"+n):n="text/plain;charset=US-ASCII",{arrayBuffer:me(r),mimeType:n}}(e);return new _e(t,{headers:{"content-type":r},url:e})}const r={},n=e;e.endsWith(".gz")&&(e=e.slice(0,-3),r["content-encoding"]="gzip");const i=await async function(e,t){return await new Promise((r,n)=>{const i=function(e,t){const r=(null==t?void 0:t.headers)||{},n={};for(const e of Object.keys(r))n[e.toLowerCase()]=r[e];n["accept-encoding"]=n["accept-encoding"]||"gzip,br,deflate";const i=new URL(e);return{hostname:i.hostname,path:i.pathname,method:"GET",...t,...null==t?void 0:t.fetch,headers:n,port:i.port}}(e,t),a=e.startsWith("https:")?Se.a.request(i,e=>r(e)):xe.a.request(i,e=>r(e));a.on("error",e=>n(e)),a.end()})}(n,t),a=function(e,t,r={}){const n={};if(t&&t.headers){const e=t.headers;for(const t in e){const r=e[t];n[t.toLowerCase()]=String(r)}}if(!n["content-length"]){const t=function(e){return Te(e)?e.length-"data:".length:null}(e);Number.isFinite(t)&&(n["content-length"]=t)}return Object.assign(n,r),new ue(n)}(e,i,r),{status:o,statusText:s}=function(e){if(e.statusCode)return{status:e.statusCode,statusText:e.statusMessage||"NA"};return{status:200,statusText:"OK"}}(i),u=!t||t.followRedirect||void 0===t.followRedirect;if(o>=300&&o<400&&a.has("location")&&u){const r=function(e,t){if(t.startsWith("http"))return t;const r=new URL(e);return r.pathname=t,r.href}(e,a.get("location"));return await Be(r,t)}return new _e(i,{headers:a,status:o,statusText:s,url:e})}catch(t){return new _e(null,{status:400,statusText:String(t),url:e})}}var Re=r(263),Oe=r.n(Re),Ie=r(65),Pe=r.n(Ie);function De(e,t){const r=function(e,t){const r=t.type?t.type.replace("image/",""):"jpeg",n=Pe()(e.data,[e.width,e.height,4],[4,4*e.width,1],0);return Oe()(n,r,t)}(e,t);return new Promise(e=>{const t=[];r.on("data",e=>t.push(e)),r.on("end",()=>{const r=Buffer.concat(t);e(function(e){if(Buffer.isBuffer(e)){return new Uint8Array(e).buffer}return e}(r))})})}var Me=r(264),Fe=r.n(Me);async function Le(e,t){if(!t)throw new Error("MIMEType is required to parse image under Node.js");const r=e instanceof Buffer?e:Buffer.from(e);return await function(e,t){return new Promise(r=>Fe()(e,t,(e,t)=>{if(e)throw e;const n=[...t.shape],i=4===t.shape.length?t.shape.shift():1,a=t.data instanceof Buffer?new Uint8Array(t.data):t.data;r({shape:n,data:a,width:t.shape[0],height:t.shape[1],components:t.shape[2],layers:i?[i]:[]})}))}(r,t)}var Ne="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?Symbol:function(e){return"Symbol("+e+")"};function ze(){}var Ue="undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:void 0;function qe(e){return"object"==typeof e&&null!==e||"function"==typeof e}var He=ze,Ge=Promise,We=Promise.prototype.then,Ve=Promise.resolve.bind(Ge),Ke=Promise.reject.bind(Ge);function Je(e){return new Ge(e)}function Qe(e){return Ve(e)}function $e(e){return Ke(e)}function Ye(e,t,r){return We.call(e,t,r)}function Xe(e,t,r){Ye(Ye(e,t,r),void 0,He)}function Ze(e,t){Xe(e,t)}function et(e,t){Xe(e,void 0,t)}function tt(e,t,r){return Ye(e,t,r)}function rt(e){Ye(e,void 0,He)}var nt=function(){var e=Ue&&Ue.queueMicrotask;if("function"==typeof e)return e;var t=Qe(void 0);return function(e){return Ye(t,e)}}();function it(e,t,r){if("function"!=typeof e)throw new TypeError("Argument is not a function");return Function.prototype.apply.call(e,t,r)}function at(e,t,r){try{return Qe(it(e,t,r))}catch(e){return $e(e)}}var ot=function(){function e(){this._cursor=0,this._size=0,this._front={_elements:[],_next:void 0},this._back=this._front,this._cursor=0,this._size=0}return Object.defineProperty(e.prototype,"length",{get:function(){return this._size},enumerable:!1,configurable:!0}),e.prototype.push=function(e){var t=this._back,r=t;16383===t._elements.length&&(r={_elements:[],_next:void 0}),t._elements.push(e),r!==t&&(this._back=r,t._next=r),++this._size},e.prototype.shift=function(){var e=this._front,t=e,r=this._cursor,n=r+1,i=e._elements,a=i[r];return 16384===n&&(t=e._next,n=0),--this._size,this._cursor=n,e!==t&&(this._front=t),i[r]=void 0,a},e.prototype.forEach=function(e){for(var t=this._cursor,r=this._front,n=r._elements;!(t===n.length&&void 0===r._next||t===n.length&&(t=0,0===(n=(r=r._next)._elements).length));)e(n[t]),++t},e.prototype.peek=function(){var e=this._front,t=this._cursor;return e._elements[t]},e}();function st(e,t){e._ownerReadableStream=t,t._reader=e,"readable"===t._state?ht(e):"closed"===t._state?function(e){ht(e),dt(e)}(e):pt(e,t._storedError)}function ut(e,t){return ci(e._ownerReadableStream,t)}function ct(e){"readable"===e._ownerReadableStream._state?ft(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")):function(e,t){pt(e,t)}(e,new TypeError("Reader was released and can no longer be used to monitor the stream's closedness")),e._ownerReadableStream._reader=void 0,e._ownerReadableStream=void 0}function lt(e){return new TypeError("Cannot "+e+" a stream using a released reader")}function ht(e){e._closedPromise=Je((function(t,r){e._closedPromise_resolve=t,e._closedPromise_reject=r}))}function pt(e,t){ht(e),ft(e,t)}function ft(e,t){void 0!==e._closedPromise_reject&&(rt(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}function dt(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0)}var mt=Ne("[[AbortSteps]]"),gt=Ne("[[ErrorSteps]]"),yt=Ne("[[CancelSteps]]"),bt=Ne("[[PullSteps]]"),vt=Number.isFinite||function(e){return"number"==typeof e&&isFinite(e)},wt=Math.trunc||function(e){return e<0?Math.ceil(e):Math.floor(e)};function _t(e,t){if(void 0!==e&&("object"!=typeof(r=e)&&"function"!=typeof r))throw new TypeError(t+" is not an object.");var r}function kt(e,t){if("function"!=typeof e)throw new TypeError(t+" is not a function.")}function xt(e,t){if(!function(e){return"object"==typeof e&&null!==e||"function"==typeof e}(e))throw new TypeError(t+" is not an object.")}function Et(e,t,r){if(void 0===e)throw new TypeError("Parameter "+t+" is required in '"+r+"'.")}function St(e,t,r){if(void 0===e)throw new TypeError(t+" is required in '"+r+"'.")}function At(e){return Number(e)}function jt(e){return 0===e?0:e}function Ct(e,t){var r=Number.MAX_SAFE_INTEGER,n=Number(e);if(n=jt(n),!vt(n))throw new TypeError(t+" is not a finite number");if((n=function(e){return jt(wt(e))}(n))<0||n>r)throw new TypeError(t+" is outside the accepted range of 0 to "+r+", inclusive");return vt(n)&&0!==n?n:0}function Tt(e,t){if(!si(e))throw new TypeError(t+" is not a ReadableStream.")}function Bt(e){return new Ft(e)}function Rt(e,t){e._reader._readRequests.push(t)}function Ot(e,t,r){var n=e._reader._readRequests.shift();r?n._closeSteps():n._chunkSteps(t)}function It(e){return e._reader._readRequests.length}function Pt(e){var t=e._reader;return void 0!==t&&!!Lt(t)}var Dt,Mt,Ft=function(){function e(e){if(Et(e,1,"ReadableStreamDefaultReader"),Tt(e,"First parameter"),ui(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");st(this,e),this._readRequests=new ot}return Object.defineProperty(e.prototype,"closed",{get:function(){return Lt(this)?this._closedPromise:$e(zt("closed"))},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),Lt(this)?void 0===this._ownerReadableStream?$e(lt("cancel")):ut(this,e):$e(zt("cancel"))},e.prototype.read=function(){if(!Lt(this))return $e(zt("read"));if(void 0===this._ownerReadableStream)return $e(lt("read from"));var e,t,r=Je((function(r,n){e=r,t=n}));return Nt(this,{_chunkSteps:function(t){return e({value:t,done:!1})},_closeSteps:function(){return e({value:void 0,done:!0})},_errorSteps:function(e){return t(e)}}),r},e.prototype.releaseLock=function(){if(!Lt(this))throw zt("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ct(this)}},e}();function Lt(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readRequests")&&e instanceof Ft)}function Nt(e,t){var r=e._ownerReadableStream;r._disturbed=!0,"closed"===r._state?t._closeSteps():"errored"===r._state?t._errorSteps(r._storedError):r._readableStreamController[bt](t)}function zt(e){return new TypeError("ReadableStreamDefaultReader.prototype."+e+" can only be used on a ReadableStreamDefaultReader")}Object.defineProperties(Ft.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Ft.prototype,Ne.toStringTag,{value:"ReadableStreamDefaultReader",configurable:!0}),"symbol"==typeof Ne.asyncIterator&&((Dt={})[Ne.asyncIterator]=function(){return this},Mt=Dt,Object.defineProperty(Mt,Ne.asyncIterator,{enumerable:!1}));var Ut=function(){function e(e,t){this._ongoingPromise=void 0,this._isFinished=!1,this._reader=e,this._preventCancel=t}return e.prototype.next=function(){var e=this,t=function(){return e._nextSteps()};return this._ongoingPromise=this._ongoingPromise?tt(this._ongoingPromise,t,t):t(),this._ongoingPromise},e.prototype.return=function(e){var t=this,r=function(){return t._returnSteps(e)};return this._ongoingPromise?tt(this._ongoingPromise,r,r):r()},e.prototype._nextSteps=function(){var e=this;if(this._isFinished)return Promise.resolve({value:void 0,done:!0});var t,r,n=this._reader;if(void 0===n._ownerReadableStream)return $e(lt("iterate"));var i=Je((function(e,n){t=e,r=n}));return Nt(n,{_chunkSteps:function(r){e._ongoingPromise=void 0,nt((function(){return t({value:r,done:!1})}))},_closeSteps:function(){e._ongoingPromise=void 0,e._isFinished=!0,ct(n),t({value:void 0,done:!0})},_errorSteps:function(t){e._ongoingPromise=void 0,e._isFinished=!0,ct(n),r(t)}}),i},e.prototype._returnSteps=function(e){if(this._isFinished)return Promise.resolve({value:e,done:!0});this._isFinished=!0;var t=this._reader;if(void 0===t._ownerReadableStream)return $e(lt("finish iterating"));if(!this._preventCancel){var r=ut(t,e);return ct(t),tt(r,(function(){return{value:e,done:!0}}))}return ct(t),Qe({value:e,done:!0})},e}(),qt={next:function(){return Ht(this)?this._asyncIteratorImpl.next():$e(Gt("next"))},return:function(e){return Ht(this)?this._asyncIteratorImpl.return(e):$e(Gt("return"))}};function Ht(e){if(!qe(e))return!1;if(!Object.prototype.hasOwnProperty.call(e,"_asyncIteratorImpl"))return!1;try{return e._asyncIteratorImpl instanceof Ut}catch(e){return!1}}function Gt(e){return new TypeError("ReadableStreamAsyncIterator."+e+" can only be used on a ReadableSteamAsyncIterator")}void 0!==Mt&&Object.setPrototypeOf(qt,Mt);var Wt=Number.isNaN||function(e){return e!=e};function Vt(e){return e.slice()}function Kt(e,t,r,n,i){new Uint8Array(e).set(new Uint8Array(r,n,i),t)}function Jt(e,t,r){if(e.slice)return e.slice(t,r);var n=r-t,i=new ArrayBuffer(n);return Kt(i,0,e,t,n),i}function Qt(e){var t=Jt(e.buffer,e.byteOffset,e.byteOffset+e.byteLength);return new Uint8Array(t)}function $t(e){var t=e._queue.shift();return e._queueTotalSize-=t.size,e._queueTotalSize<0&&(e._queueTotalSize=0),t.value}function Yt(e,t,r){if("number"!=typeof(n=r)||Wt(n)||n<0||r===1/0)throw new RangeError("Size must be a finite, non-NaN, non-negative number.");var n;e._queue.push({value:t,size:r}),e._queueTotalSize+=r}function Xt(e){e._queue=new ot,e._queueTotalSize=0}var Zt=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"view",{get:function(){if(!rr(this))throw Er("view");return this._view},enumerable:!1,configurable:!0}),e.prototype.respond=function(e){if(!rr(this))throw Er("respond");if(Et(e,1,"respond"),e=Ct(e,"First parameter"),void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");this._view.buffer,_r(this._associatedReadableByteStreamController,e)},e.prototype.respondWithNewView=function(e){if(!rr(this))throw Er("respondWithNewView");if(Et(e,1,"respondWithNewView"),!ArrayBuffer.isView(e))throw new TypeError("You can only respond with array buffer views");if(void 0===this._associatedReadableByteStreamController)throw new TypeError("This BYOB request has been invalidated");e.buffer,kr(this._associatedReadableByteStreamController,e)},e}();Object.defineProperties(Zt.prototype,{respond:{enumerable:!0},respondWithNewView:{enumerable:!0},view:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Zt.prototype,Ne.toStringTag,{value:"ReadableStreamBYOBRequest",configurable:!0});var er=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"byobRequest",{get:function(){if(!tr(this))throw Sr("byobRequest");return vr(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!tr(this))throw Sr("desiredSize");return wr(this)},enumerable:!1,configurable:!0}),e.prototype.close=function(){if(!tr(this))throw Sr("close");if(this._closeRequested)throw new TypeError("The stream has already been closed; do not close it again!");var e=this._controlledReadableByteStream._state;if("readable"!==e)throw new TypeError("The stream (in "+e+" state) is not in the readable state and cannot be closed");gr(this)},e.prototype.enqueue=function(e){if(!tr(this))throw Sr("enqueue");if(Et(e,1,"enqueue"),!ArrayBuffer.isView(e))throw new TypeError("chunk must be an array buffer view");if(0===e.byteLength)throw new TypeError("chunk must have non-zero byteLength");if(0===e.buffer.byteLength)throw new TypeError("chunk's buffer must have non-zero byteLength");if(this._closeRequested)throw new TypeError("stream is closed or draining");var t=this._controlledReadableByteStream._state;if("readable"!==t)throw new TypeError("The stream (in "+t+" state) is not in the readable state and cannot be enqueued to");yr(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!tr(this))throw Sr("error");br(this,e)},e.prototype[yt]=function(e){ir(this),Xt(this);var t=this._cancelAlgorithm(e);return mr(this),t},e.prototype[bt]=function(e){var t=this._controlledReadableByteStream;if(this._queueTotalSize>0){var r=this._queue.shift();this._queueTotalSize-=r.byteLength,lr(this);var n=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);e._chunkSteps(n)}else{var i=this._autoAllocateChunkSize;if(void 0!==i){var a=void 0;try{a=new ArrayBuffer(i)}catch(t){return void e._errorSteps(t)}var o={buffer:a,bufferByteLength:i,byteOffset:0,byteLength:i,bytesFilled:0,elementSize:1,viewConstructor:Uint8Array,readerType:"default"};this._pendingPullIntos.push(o)}Rt(t,e),nr(this)}},e}();function tr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableByteStream")&&e instanceof er)}function rr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_associatedReadableByteStreamController")&&e instanceof Zt)}function nr(e){(function(e){var t=e._controlledReadableByteStream;if("readable"!==t._state)return!1;if(e._closeRequested)return!1;if(!e._started)return!1;if(Pt(t)&&It(t)>0)return!0;if(Tr(t)&&Cr(t)>0)return!0;if(wr(e)>0)return!0;return!1})(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,Xe(e._pullAlgorithm(),(function(){e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,nr(e))}),(function(t){br(e,t)}))))}function ir(e){hr(e),e._pendingPullIntos=new ot}function ar(e,t){var r=!1;"closed"===e._state&&(r=!0);var n=or(t);"default"===t.readerType?Ot(e,n,r):function(e,t,r){var n=e._reader._readIntoRequests.shift();r?n._closeSteps(t):n._chunkSteps(t)}(e,n,r)}function or(e){var t=e.bytesFilled,r=e.elementSize;return new e.viewConstructor(e.buffer,e.byteOffset,t/r)}function sr(e,t,r,n){e._queue.push({buffer:t,byteOffset:r,byteLength:n}),e._queueTotalSize+=n}function ur(e,t){var r=t.elementSize,n=t.bytesFilled-t.bytesFilled%r,i=Math.min(e._queueTotalSize,t.byteLength-t.bytesFilled),a=t.bytesFilled+i,o=a-a%r,s=i,u=!1;o>n&&(s=o-t.bytesFilled,u=!0);for(var c=e._queue;s>0;){var l=c.peek(),h=Math.min(s,l.byteLength),p=t.byteOffset+t.bytesFilled;Kt(t.buffer,p,l.buffer,l.byteOffset,h),l.byteLength===h?c.shift():(l.byteOffset+=h,l.byteLength-=h),e._queueTotalSize-=h,cr(e,h,t),s-=h}return u}function cr(e,t,r){r.bytesFilled+=t}function lr(e){0===e._queueTotalSize&&e._closeRequested?(mr(e),li(e._controlledReadableByteStream)):nr(e)}function hr(e){null!==e._byobRequest&&(e._byobRequest._associatedReadableByteStreamController=void 0,e._byobRequest._view=null,e._byobRequest=null)}function pr(e){for(;e._pendingPullIntos.length>0;){if(0===e._queueTotalSize)return;var t=e._pendingPullIntos.peek();ur(e,t)&&(dr(e),ar(e._controlledReadableByteStream,t))}}function fr(e,t){var r=e._pendingPullIntos.peek();hr(e),"closed"===e._controlledReadableByteStream._state?function(e,t){var r=e._controlledReadableByteStream;if(Tr(r))for(;Cr(r)>0;){ar(r,dr(e))}}(e):function(e,t,r){if(cr(0,t,r),!(r.bytesFilled<r.elementSize)){dr(e);var n=r.bytesFilled%r.elementSize;if(n>0){var i=r.byteOffset+r.bytesFilled,a=Jt(r.buffer,i-n,i);sr(e,a,0,a.byteLength)}r.bytesFilled-=n,ar(e._controlledReadableByteStream,r),pr(e)}}(e,t,r),nr(e)}function dr(e){return e._pendingPullIntos.shift()}function mr(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0}function gr(e){var t=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===t._state)if(e._queueTotalSize>0)e._closeRequested=!0;else{if(e._pendingPullIntos.length>0)if(e._pendingPullIntos.peek().bytesFilled>0){var r=new TypeError("Insufficient bytes to fill elements in the given buffer");throw br(e,r),r}mr(e),li(t)}}function yr(e,t){var r=e._controlledReadableByteStream;if(!e._closeRequested&&"readable"===r._state){var n=t.buffer,i=t.byteOffset,a=t.byteLength,o=n;if(e._pendingPullIntos.length>0){var s=e._pendingPullIntos.peek();s.buffer,0,s.buffer=s.buffer}if(hr(e),Pt(r))if(0===It(r))sr(e,o,i,a);else e._pendingPullIntos.length>0&&dr(e),Ot(r,new Uint8Array(o,i,a),!1);else Tr(r)?(sr(e,o,i,a),pr(e)):sr(e,o,i,a);nr(e)}}function br(e,t){var r=e._controlledReadableByteStream;"readable"===r._state&&(ir(e),Xt(e),mr(e),hi(r,t))}function vr(e){if(null===e._byobRequest&&e._pendingPullIntos.length>0){var t=e._pendingPullIntos.peek(),r=new Uint8Array(t.buffer,t.byteOffset+t.bytesFilled,t.byteLength-t.bytesFilled),n=Object.create(Zt.prototype);!function(e,t,r){e._associatedReadableByteStreamController=t,e._view=r}(n,e,r),e._byobRequest=n}return e._byobRequest}function wr(e){var t=e._controlledReadableByteStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function _r(e,t){var r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t)throw new TypeError("bytesWritten must be 0 when calling respond() on a closed stream")}else{if(0===t)throw new TypeError("bytesWritten must be greater than 0 when calling respond() on a readable stream");if(r.bytesFilled+t>r.byteLength)throw new RangeError("bytesWritten out of range")}r.buffer=r.buffer,fr(e,t)}function kr(e,t){var r=e._pendingPullIntos.peek();if("closed"===e._controlledReadableByteStream._state){if(0!==t.byteLength)throw new TypeError("The view's length must be 0 when calling respondWithNewView() on a closed stream")}else if(0===t.byteLength)throw new TypeError("The view's length must be greater than 0 when calling respondWithNewView() on a readable stream");if(r.byteOffset+r.bytesFilled!==t.byteOffset)throw new RangeError("The region specified by view does not match byobRequest");if(r.bufferByteLength!==t.buffer.byteLength)throw new RangeError("The buffer of view has different capacity than byobRequest");if(r.bytesFilled+t.byteLength>r.byteLength)throw new RangeError("The region specified by view is larger than byobRequest");var n=t.byteLength;r.buffer=t.buffer,fr(e,n)}function xr(e,t,r,n,i,a,o){t._controlledReadableByteStream=e,t._pullAgain=!1,t._pulling=!1,t._byobRequest=null,t._queue=t._queueTotalSize=void 0,Xt(t),t._closeRequested=!1,t._started=!1,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,t._autoAllocateChunkSize=o,t._pendingPullIntos=new ot,e._readableStreamController=t,Xe(Qe(r()),(function(){t._started=!0,nr(t)}),(function(e){br(t,e)}))}function Er(e){return new TypeError("ReadableStreamBYOBRequest.prototype."+e+" can only be used on a ReadableStreamBYOBRequest")}function Sr(e){return new TypeError("ReadableByteStreamController.prototype."+e+" can only be used on a ReadableByteStreamController")}function Ar(e){return new Br(e)}function jr(e,t){e._reader._readIntoRequests.push(t)}function Cr(e){return e._reader._readIntoRequests.length}function Tr(e){var t=e._reader;return void 0!==t&&!!Rr(t)}Object.defineProperties(er.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},byobRequest:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(er.prototype,Ne.toStringTag,{value:"ReadableByteStreamController",configurable:!0});var Br=function(){function e(e){if(Et(e,1,"ReadableStreamBYOBReader"),Tt(e,"First parameter"),ui(e))throw new TypeError("This stream has already been locked for exclusive reading by another reader");if(!tr(e._readableStreamController))throw new TypeError("Cannot construct a ReadableStreamBYOBReader for a stream not constructed with a byte source");st(this,e),this._readIntoRequests=new ot}return Object.defineProperty(e.prototype,"closed",{get:function(){return Rr(this)?this._closedPromise:$e(Ir("closed"))},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),Rr(this)?void 0===this._ownerReadableStream?$e(lt("cancel")):ut(this,e):$e(Ir("cancel"))},e.prototype.read=function(e){if(!Rr(this))return $e(Ir("read"));if(!ArrayBuffer.isView(e))return $e(new TypeError("view must be an array buffer view"));if(0===e.byteLength)return $e(new TypeError("view must have non-zero byteLength"));if(0===e.buffer.byteLength)return $e(new TypeError("view's buffer must have non-zero byteLength"));if(e.buffer,void 0===this._ownerReadableStream)return $e(lt("read from"));var t,r,n=Je((function(e,n){t=e,r=n}));return Or(this,e,{_chunkSteps:function(e){return t({value:e,done:!1})},_closeSteps:function(e){return t({value:e,done:!0})},_errorSteps:function(e){return r(e)}}),n},e.prototype.releaseLock=function(){if(!Rr(this))throw Ir("releaseLock");if(void 0!==this._ownerReadableStream){if(this._readIntoRequests.length>0)throw new TypeError("Tried to release a reader lock when that reader has pending read() calls un-settled");ct(this)}},e}();function Rr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readIntoRequests")&&e instanceof Br)}function Or(e,t,r){var n=e._ownerReadableStream;n._disturbed=!0,"errored"===n._state?r._errorSteps(n._storedError):function(e,t,r){var n=e._controlledReadableByteStream,i=1;t.constructor!==DataView&&(i=t.constructor.BYTES_PER_ELEMENT);var a=t.constructor,o=t.buffer,s={buffer:o,bufferByteLength:o.byteLength,byteOffset:t.byteOffset,byteLength:t.byteLength,bytesFilled:0,elementSize:i,viewConstructor:a,readerType:"byob"};if(e._pendingPullIntos.length>0)return e._pendingPullIntos.push(s),void jr(n,r);if("closed"!==n._state){if(e._queueTotalSize>0){if(ur(e,s)){var u=or(s);return lr(e),void r._chunkSteps(u)}if(e._closeRequested){var c=new TypeError("Insufficient bytes to fill elements in the given buffer");return br(e,c),void r._errorSteps(c)}}e._pendingPullIntos.push(s),jr(n,r),nr(e)}else{var l=new a(s.buffer,s.byteOffset,0);r._closeSteps(l)}}(n._readableStreamController,t,r)}function Ir(e){return new TypeError("ReadableStreamBYOBReader.prototype."+e+" can only be used on a ReadableStreamBYOBReader")}function Pr(e,t){var r=e.highWaterMark;if(void 0===r)return t;if(Wt(r)||r<0)throw new RangeError("Invalid highWaterMark");return r}function Dr(e){var t=e.size;return t||function(){return 1}}function Mr(e,t){_t(e,t);var r=null==e?void 0:e.highWaterMark,n=null==e?void 0:e.size;return{highWaterMark:void 0===r?void 0:At(r),size:void 0===n?void 0:Fr(n,t+" has member 'size' that")}}function Fr(e,t){return kt(e,t),function(t){return At(e(t))}}function Lr(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Nr(e,t,r){return kt(e,r),function(){return at(e,t,[])}}function zr(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function Ur(e,t,r){return kt(e,r),function(r,n){return at(e,t,[r,n])}}function qr(e,t){if(!Kr(e))throw new TypeError(t+" is not a WritableStream.")}Object.defineProperties(Br.prototype,{cancel:{enumerable:!0},read:{enumerable:!0},releaseLock:{enumerable:!0},closed:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Br.prototype,Ne.toStringTag,{value:"ReadableStreamBYOBReader",configurable:!0});var Hr="function"==typeof AbortController;var Gr=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),void 0===e?e=null:xt(e,"First parameter");var r=Mr(t,"Second parameter"),n=function(e,t){_t(e,t);var r=null==e?void 0:e.abort,n=null==e?void 0:e.close,i=null==e?void 0:e.start,a=null==e?void 0:e.type,o=null==e?void 0:e.write;return{abort:void 0===r?void 0:Lr(r,e,t+" has member 'abort' that"),close:void 0===n?void 0:Nr(n,e,t+" has member 'close' that"),start:void 0===i?void 0:zr(i,e,t+" has member 'start' that"),write:void 0===o?void 0:Ur(o,e,t+" has member 'write' that"),type:a}}(e,"First parameter");if(Vr(this),void 0!==n.type)throw new RangeError("Invalid type is specified");var i=Dr(r);!function(e,t,r,n){var i=Object.create(pn.prototype),a=function(){},o=function(){return Qe(void 0)},s=function(){return Qe(void 0)},u=function(){return Qe(void 0)};void 0!==t.start&&(a=function(){return t.start(i)});void 0!==t.write&&(o=function(e){return t.write(e,i)});void 0!==t.close&&(s=function(){return t.close()});void 0!==t.abort&&(u=function(e){return t.abort(e)});dn(e,i,a,o,s,u,r,n)}(this,n,Pr(r,1),i)}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!Kr(this))throw _n("locked");return Jr(this)},enumerable:!1,configurable:!0}),e.prototype.abort=function(e){return void 0===e&&(e=void 0),Kr(this)?Jr(this)?$e(new TypeError("Cannot abort a stream that already has a writer")):Qr(this,e):$e(_n("abort"))},e.prototype.close=function(){return Kr(this)?Jr(this)?$e(new TypeError("Cannot close a stream that already has a writer")):en(this)?$e(new TypeError("Cannot close an already-closing stream")):$r(this):$e(_n("close"))},e.prototype.getWriter=function(){if(!Kr(this))throw _n("getWriter");return Wr(this)},e}();function Wr(e){return new nn(e)}function Vr(e){e._state="writable",e._storedError=void 0,e._writer=void 0,e._writableStreamController=void 0,e._writeRequests=new ot,e._inFlightWriteRequest=void 0,e._closeRequest=void 0,e._inFlightCloseRequest=void 0,e._pendingAbortRequest=void 0,e._backpressure=!1}function Kr(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_writableStreamController")&&e instanceof Gr)}function Jr(e){return void 0!==e._writer}function Qr(e,t){var r;if("closed"===e._state||"errored"===e._state)return Qe(void 0);e._writableStreamController._abortReason=t,null===(r=e._writableStreamController._abortController)||void 0===r||r.abort();var n=e._state;if("closed"===n||"errored"===n)return Qe(void 0);if(void 0!==e._pendingAbortRequest)return e._pendingAbortRequest._promise;var i=!1;"erroring"===n&&(i=!0,t=void 0);var a=Je((function(r,n){e._pendingAbortRequest={_promise:void 0,_resolve:r,_reject:n,_reason:t,_wasAlreadyErroring:i}}));return e._pendingAbortRequest._promise=a,i||Xr(e,t),a}function $r(e){var t=e._state;if("closed"===t||"errored"===t)return $e(new TypeError("The stream (in "+t+" state) is not in the writable state and cannot be closed"));var r,n=Je((function(t,r){var n={_resolve:t,_reject:r};e._closeRequest=n})),i=e._writer;return void 0!==i&&e._backpressure&&"writable"===t&&In(i),Yt(r=e._writableStreamController,hn,0),yn(r),n}function Yr(e,t){"writable"!==e._state?Zr(e):Xr(e,t)}function Xr(e,t){var r=e._writableStreamController;e._state="erroring",e._storedError=t;var n=e._writer;void 0!==n&&un(n,t),!function(e){if(void 0===e._inFlightWriteRequest&&void 0===e._inFlightCloseRequest)return!1;return!0}(e)&&r._started&&Zr(e)}function Zr(e){e._state="errored",e._writableStreamController[gt]();var t=e._storedError;if(e._writeRequests.forEach((function(e){e._reject(t)})),e._writeRequests=new ot,void 0!==e._pendingAbortRequest){var r=e._pendingAbortRequest;if(e._pendingAbortRequest=void 0,r._wasAlreadyErroring)return r._reject(t),void tn(e);Xe(e._writableStreamController[mt](r._reason),(function(){r._resolve(),tn(e)}),(function(t){r._reject(t),tn(e)}))}else tn(e)}function en(e){return void 0!==e._closeRequest||void 0!==e._inFlightCloseRequest}function tn(e){void 0!==e._closeRequest&&(e._closeRequest._reject(e._storedError),e._closeRequest=void 0);var t=e._writer;void 0!==t&&jn(t,e._storedError)}function rn(e,t){var r=e._writer;void 0!==r&&t!==e._backpressure&&(t?function(e){Tn(e)}(r):In(r)),e._backpressure=t}Object.defineProperties(Gr.prototype,{abort:{enumerable:!0},close:{enumerable:!0},getWriter:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Gr.prototype,Ne.toStringTag,{value:"WritableStream",configurable:!0});var nn=function(){function e(e){if(Et(e,1,"WritableStreamDefaultWriter"),qr(e,"First parameter"),Jr(e))throw new TypeError("This stream has already been locked for exclusive writing by another writer");this._ownerWritableStream=e,e._writer=this;var t,r=e._state;if("writable"===r)!en(e)&&e._backpressure?Tn(this):Rn(this),Sn(this);else if("erroring"===r)Bn(this,e._storedError),Sn(this);else if("closed"===r)Rn(this),Sn(t=this),Cn(t);else{var n=e._storedError;Bn(this,n),An(this,n)}}return Object.defineProperty(e.prototype,"closed",{get:function(){return an(this)?this._closedPromise:$e(xn("closed"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!an(this))throw xn("desiredSize");if(void 0===this._ownerWritableStream)throw En("desiredSize");return function(e){var t=e._ownerWritableStream,r=t._state;if("errored"===r||"erroring"===r)return null;if("closed"===r)return 0;return gn(t._writableStreamController)}(this)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ready",{get:function(){return an(this)?this._readyPromise:$e(xn("ready"))},enumerable:!1,configurable:!0}),e.prototype.abort=function(e){return void 0===e&&(e=void 0),an(this)?void 0===this._ownerWritableStream?$e(En("abort")):function(e,t){return Qr(e._ownerWritableStream,t)}(this,e):$e(xn("abort"))},e.prototype.close=function(){if(!an(this))return $e(xn("close"));var e=this._ownerWritableStream;return void 0===e?$e(En("close")):en(e)?$e(new TypeError("Cannot close an already-closing stream")):on(this)},e.prototype.releaseLock=function(){if(!an(this))throw xn("releaseLock");void 0!==this._ownerWritableStream&&cn(this)},e.prototype.write=function(e){return void 0===e&&(e=void 0),an(this)?void 0===this._ownerWritableStream?$e(En("write to")):ln(this,e):$e(xn("write"))},e}();function an(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_ownerWritableStream")&&e instanceof nn)}function on(e){return $r(e._ownerWritableStream)}function sn(e,t){"pending"===e._closedPromiseState?jn(e,t):function(e,t){An(e,t)}(e,t)}function un(e,t){"pending"===e._readyPromiseState?On(e,t):function(e,t){Bn(e,t)}(e,t)}function cn(e){var t=e._ownerWritableStream,r=new TypeError("Writer was released and can no longer be used to monitor the stream's closedness");un(e,r),sn(e,r),t._writer=void 0,e._ownerWritableStream=void 0}function ln(e,t){var r=e._ownerWritableStream,n=r._writableStreamController,i=function(e,t){try{return e._strategySizeAlgorithm(t)}catch(t){return bn(e,t),1}}(n,t);if(r!==e._ownerWritableStream)return $e(En("write to"));var a=r._state;if("errored"===a)return $e(r._storedError);if(en(r)||"closed"===a)return $e(new TypeError("The stream is closing or closed and cannot be written to"));if("erroring"===a)return $e(r._storedError);var o=function(e){return Je((function(t,r){var n={_resolve:t,_reject:r};e._writeRequests.push(n)}))}(r);return function(e,t,r){try{Yt(e,t,r)}catch(t){return void bn(e,t)}var n=e._controlledWritableStream;if(!en(n)&&"writable"===n._state){var i=vn(e);rn(n,i)}yn(e)}(n,t,i),o}Object.defineProperties(nn.prototype,{abort:{enumerable:!0},close:{enumerable:!0},releaseLock:{enumerable:!0},write:{enumerable:!0},closed:{enumerable:!0},desiredSize:{enumerable:!0},ready:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(nn.prototype,Ne.toStringTag,{value:"WritableStreamDefaultWriter",configurable:!0});var hn={},pn=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"abortReason",{get:function(){if(!fn(this))throw kn("abortReason");return this._abortReason},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"signal",{get:function(){if(!fn(this))throw kn("signal");if(void 0===this._abortController)throw new TypeError("WritableStreamDefaultController.prototype.signal is not supported");return this._abortController.signal},enumerable:!1,configurable:!0}),e.prototype.error=function(e){if(void 0===e&&(e=void 0),!fn(this))throw kn("error");"writable"===this._controlledWritableStream._state&&wn(this,e)},e.prototype[mt]=function(e){var t=this._abortAlgorithm(e);return mn(this),t},e.prototype[gt]=function(){Xt(this)},e}();function fn(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledWritableStream")&&e instanceof pn)}function dn(e,t,r,n,i,a,o,s){t._controlledWritableStream=e,e._writableStreamController=t,t._queue=void 0,t._queueTotalSize=void 0,Xt(t),t._abortReason=void 0,t._abortController=function(){if(Hr)return new AbortController}(),t._started=!1,t._strategySizeAlgorithm=s,t._strategyHWM=o,t._writeAlgorithm=n,t._closeAlgorithm=i,t._abortAlgorithm=a;var u=vn(t);rn(e,u),Xe(Qe(r()),(function(){t._started=!0,yn(t)}),(function(r){t._started=!0,Yr(e,r)}))}function mn(e){e._writeAlgorithm=void 0,e._closeAlgorithm=void 0,e._abortAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function gn(e){return e._strategyHWM-e._queueTotalSize}function yn(e){var t=e._controlledWritableStream;if(e._started&&void 0===t._inFlightWriteRequest)if("erroring"!==t._state){if(0!==e._queue.length){var r=e._queue.peek().value;r===hn?function(e){var t=e._controlledWritableStream;(function(e){e._inFlightCloseRequest=e._closeRequest,e._closeRequest=void 0})(t),$t(e);var r=e._closeAlgorithm();mn(e),Xe(r,(function(){!function(e){e._inFlightCloseRequest._resolve(void 0),e._inFlightCloseRequest=void 0,"erroring"===e._state&&(e._storedError=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._resolve(),e._pendingAbortRequest=void 0)),e._state="closed";var t=e._writer;void 0!==t&&Cn(t)}(t)}),(function(e){!function(e,t){e._inFlightCloseRequest._reject(t),e._inFlightCloseRequest=void 0,void 0!==e._pendingAbortRequest&&(e._pendingAbortRequest._reject(t),e._pendingAbortRequest=void 0),Yr(e,t)}(t,e)}))}(e):function(e,t){var r=e._controlledWritableStream;(function(e){e._inFlightWriteRequest=e._writeRequests.shift()})(r),Xe(e._writeAlgorithm(t),(function(){!function(e){e._inFlightWriteRequest._resolve(void 0),e._inFlightWriteRequest=void 0}(r);var t=r._state;if($t(e),!en(r)&&"writable"===t){var n=vn(e);rn(r,n)}yn(e)}),(function(t){"writable"===r._state&&mn(e),function(e,t){e._inFlightWriteRequest._reject(t),e._inFlightWriteRequest=void 0,Yr(e,t)}(r,t)}))}(e,r)}}else Zr(t)}function bn(e,t){"writable"===e._controlledWritableStream._state&&wn(e,t)}function vn(e){return gn(e)<=0}function wn(e,t){var r=e._controlledWritableStream;mn(e),Xr(r,t)}function _n(e){return new TypeError("WritableStream.prototype."+e+" can only be used on a WritableStream")}function kn(e){return new TypeError("WritableStreamDefaultController.prototype."+e+" can only be used on a WritableStreamDefaultController")}function xn(e){return new TypeError("WritableStreamDefaultWriter.prototype."+e+" can only be used on a WritableStreamDefaultWriter")}function En(e){return new TypeError("Cannot "+e+" a stream using a released writer")}function Sn(e){e._closedPromise=Je((function(t,r){e._closedPromise_resolve=t,e._closedPromise_reject=r,e._closedPromiseState="pending"}))}function An(e,t){Sn(e),jn(e,t)}function jn(e,t){void 0!==e._closedPromise_reject&&(rt(e._closedPromise),e._closedPromise_reject(t),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="rejected")}function Cn(e){void 0!==e._closedPromise_resolve&&(e._closedPromise_resolve(void 0),e._closedPromise_resolve=void 0,e._closedPromise_reject=void 0,e._closedPromiseState="resolved")}function Tn(e){e._readyPromise=Je((function(t,r){e._readyPromise_resolve=t,e._readyPromise_reject=r})),e._readyPromiseState="pending"}function Bn(e,t){Tn(e),On(e,t)}function Rn(e){Tn(e),In(e)}function On(e,t){void 0!==e._readyPromise_reject&&(rt(e._readyPromise),e._readyPromise_reject(t),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="rejected")}function In(e){void 0!==e._readyPromise_resolve&&(e._readyPromise_resolve(void 0),e._readyPromise_resolve=void 0,e._readyPromise_reject=void 0,e._readyPromiseState="fulfilled")}Object.defineProperties(pn.prototype,{abortReason:{enumerable:!0},signal:{enumerable:!0},error:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(pn.prototype,Ne.toStringTag,{value:"WritableStreamDefaultController",configurable:!0});var Pn="undefined"!=typeof DOMException?DOMException:void 0;var Dn,Mn=function(e){if("function"!=typeof e&&"object"!=typeof e)return!1;try{return new e,!0}catch(e){return!1}}(Pn)?Pn:((Dn=function(e,t){this.message=e||"",this.name=t||"Error",Error.captureStackTrace&&Error.captureStackTrace(this,this.constructor)}).prototype=Object.create(Error.prototype),Object.defineProperty(Dn.prototype,"constructor",{value:Dn,writable:!0,configurable:!0}),Dn);function Fn(e,t,r,n,i,a){var o=Bt(e),s=Wr(t);e._disturbed=!0;var u=!1,c=Qe(void 0);return Je((function(l,h){var p,f,d,m;if(void 0!==a){if(p=function(){var r=new Mn("Aborted","AbortError"),a=[];n||a.push((function(){return"writable"===t._state?Qr(t,r):Qe(void 0)})),i||a.push((function(){return"readable"===e._state?ci(e,r):Qe(void 0)})),v((function(){return Promise.all(a.map((function(e){return e()})))}),!0,r)},a.aborted)return void p();a.addEventListener("abort",p)}if(b(e,o._closedPromise,(function(e){n?w(!0,e):v((function(){return Qr(t,e)}),!0,e)})),b(t,s._closedPromise,(function(t){i?w(!0,t):v((function(){return ci(e,t)}),!0,t)})),f=e,d=o._closedPromise,m=function(){r?w():v((function(){return function(e){var t=e._ownerWritableStream,r=t._state;return en(t)||"closed"===r?Qe(void 0):"errored"===r?$e(t._storedError):on(e)}(s)}))},"closed"===f._state?m():Ze(d,m),en(t)||"closed"===t._state){var g=new TypeError("the destination writable stream closed before all data could be piped to it");i?w(!0,g):v((function(){return ci(e,g)}),!0,g)}function y(){var e=c;return Ye(c,(function(){return e!==c?y():void 0}))}function b(e,t,r){"errored"===e._state?r(e._storedError):et(t,r)}function v(e,r,n){function i(){Xe(e(),(function(){return _(r,n)}),(function(e){return _(!0,e)}))}u||(u=!0,"writable"!==t._state||en(t)?i():Ze(y(),i))}function w(e,r){u||(u=!0,"writable"!==t._state||en(t)?_(e,r):Ze(y(),(function(){return _(e,r)})))}function _(e,t){cn(s),ct(o),void 0!==a&&a.removeEventListener("abort",p),e?h(t):l(void 0)}rt(Je((function(e,t){!function r(n){n?e():Ye(u?Qe(!0):Ye(s._readyPromise,(function(){return Je((function(e,t){Nt(o,{_chunkSteps:function(t){c=Ye(ln(s,t),void 0,ze),e(!1)},_closeSteps:function(){return e(!0)},_errorSteps:t})}))})),r,t)}(!1)})))}))}var Ln=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!Nn(this))throw Qn("desiredSize");return Vn(this)},enumerable:!1,configurable:!0}),e.prototype.close=function(){if(!Nn(this))throw Qn("close");if(!Kn(this))throw new TypeError("The stream is not in a state that permits close");Hn(this)},e.prototype.enqueue=function(e){if(void 0===e&&(e=void 0),!Nn(this))throw Qn("enqueue");if(!Kn(this))throw new TypeError("The stream is not in a state that permits enqueue");return Gn(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!Nn(this))throw Qn("error");Wn(this,e)},e.prototype[yt]=function(e){Xt(this);var t=this._cancelAlgorithm(e);return qn(this),t},e.prototype[bt]=function(e){var t=this._controlledReadableStream;if(this._queue.length>0){var r=$t(this);this._closeRequested&&0===this._queue.length?(qn(this),li(t)):zn(this),e._chunkSteps(r)}else Rt(t,e),zn(this)},e}();function Nn(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledReadableStream")&&e instanceof Ln)}function zn(e){Un(e)&&(e._pulling?e._pullAgain=!0:(e._pulling=!0,Xe(e._pullAlgorithm(),(function(){e._pulling=!1,e._pullAgain&&(e._pullAgain=!1,zn(e))}),(function(t){Wn(e,t)}))))}function Un(e){var t=e._controlledReadableStream;return!!Kn(e)&&(!!e._started&&(!!(ui(t)&&It(t)>0)||Vn(e)>0))}function qn(e){e._pullAlgorithm=void 0,e._cancelAlgorithm=void 0,e._strategySizeAlgorithm=void 0}function Hn(e){if(Kn(e)){var t=e._controlledReadableStream;e._closeRequested=!0,0===e._queue.length&&(qn(e),li(t))}}function Gn(e,t){if(Kn(e)){var r=e._controlledReadableStream;if(ui(r)&&It(r)>0)Ot(r,t,!1);else{var n=void 0;try{n=e._strategySizeAlgorithm(t)}catch(t){throw Wn(e,t),t}try{Yt(e,t,n)}catch(t){throw Wn(e,t),t}}zn(e)}}function Wn(e,t){var r=e._controlledReadableStream;"readable"===r._state&&(Xt(e),qn(e),hi(r,t))}function Vn(e){var t=e._controlledReadableStream._state;return"errored"===t?null:"closed"===t?0:e._strategyHWM-e._queueTotalSize}function Kn(e){var t=e._controlledReadableStream._state;return!e._closeRequested&&"readable"===t}function Jn(e,t,r,n,i,a,o){t._controlledReadableStream=e,t._queue=void 0,t._queueTotalSize=void 0,Xt(t),t._started=!1,t._closeRequested=!1,t._pullAgain=!1,t._pulling=!1,t._strategySizeAlgorithm=o,t._strategyHWM=a,t._pullAlgorithm=n,t._cancelAlgorithm=i,e._readableStreamController=t,Xe(Qe(r()),(function(){t._started=!0,zn(t)}),(function(e){Wn(t,e)}))}function Qn(e){return new TypeError("ReadableStreamDefaultController.prototype."+e+" can only be used on a ReadableStreamDefaultController")}function $n(e,t){return tr(e._readableStreamController)?function(e){var t,r,n,i,a,o=Bt(e),s=!1,u=!1,c=!1,l=!1,h=!1,p=Je((function(e){a=e}));function f(e){et(e._closedPromise,(function(t){e===o&&(br(n._readableStreamController,t),br(i._readableStreamController,t),l&&h||a(void 0))}))}function d(){Rr(o)&&(ct(o),f(o=Bt(e))),Nt(o,{_chunkSteps:function(t){nt((function(){u=!1,c=!1;var r=t,o=t;if(!l&&!h)try{o=Qt(t)}catch(t){return br(n._readableStreamController,t),br(i._readableStreamController,t),void a(ci(e,t))}l||yr(n._readableStreamController,r),h||yr(i._readableStreamController,o),s=!1,u?g():c&&y()}))},_closeSteps:function(){s=!1,l||gr(n._readableStreamController),h||gr(i._readableStreamController),n._readableStreamController._pendingPullIntos.length>0&&_r(n._readableStreamController,0),i._readableStreamController._pendingPullIntos.length>0&&_r(i._readableStreamController,0),l&&h||a(void 0)},_errorSteps:function(){s=!1}})}function m(t,r){Lt(o)&&(ct(o),f(o=Ar(e)));var p=r?i:n,d=r?n:i;Or(o,t,{_chunkSteps:function(t){nt((function(){u=!1,c=!1;var n=r?h:l;if(r?l:h)n||kr(p._readableStreamController,t);else{var i=void 0;try{i=Qt(t)}catch(t){return br(p._readableStreamController,t),br(d._readableStreamController,t),void a(ci(e,t))}n||kr(p._readableStreamController,t),yr(d._readableStreamController,i)}s=!1,u?g():c&&y()}))},_closeSteps:function(e){s=!1;var t=r?h:l,n=r?l:h;t||gr(p._readableStreamController),n||gr(d._readableStreamController),void 0!==e&&(t||kr(p._readableStreamController,e),!n&&d._readableStreamController._pendingPullIntos.length>0&&_r(d._readableStreamController,0)),t&&n||a(void 0)},_errorSteps:function(){s=!1}})}function g(){if(s)return u=!0,Qe(void 0);s=!0;var e=vr(n._readableStreamController);return null===e?d():m(e._view,!1),Qe(void 0)}function y(){if(s)return c=!0,Qe(void 0);s=!0;var e=vr(i._readableStreamController);return null===e?d():m(e._view,!0),Qe(void 0)}function b(n){if(l=!0,t=n,h){var i=Vt([t,r]),o=ci(e,i);a(o)}return p}function v(n){if(h=!0,r=n,l){var i=Vt([t,r]),o=ci(e,i);a(o)}return p}function w(){}return n=ai(w,g,b),i=ai(w,y,v),f(o),[n,i]}(e):function(e,t){var r,n,i,a,o,s=Bt(e),u=!1,c=!1,l=!1,h=!1,p=Je((function(e){o=e}));function f(){return u?(c=!0,Qe(void 0)):(u=!0,Nt(s,{_chunkSteps:function(e){nt((function(){c=!1;var t=e,r=e;l||Gn(i._readableStreamController,t),h||Gn(a._readableStreamController,r),u=!1,c&&f()}))},_closeSteps:function(){u=!1,l||Hn(i._readableStreamController),h||Hn(a._readableStreamController),l&&h||o(void 0)},_errorSteps:function(){u=!1}}),Qe(void 0))}function d(t){if(l=!0,r=t,h){var i=Vt([r,n]),a=ci(e,i);o(a)}return p}function m(t){if(h=!0,n=t,l){var i=Vt([r,n]),a=ci(e,i);o(a)}return p}function g(){}return i=ii(g,f,d),a=ii(g,f,m),et(s._closedPromise,(function(e){Wn(i._readableStreamController,e),Wn(a._readableStreamController,e),l&&h||o(void 0)})),[i,a]}(e)}function Yn(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Xn(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function Zn(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function ei(e,t){if("bytes"!==(e=""+e))throw new TypeError(t+" '"+e+"' is not a valid enumeration value for ReadableStreamType");return e}function ti(e,t){if("byob"!==(e=""+e))throw new TypeError(t+" '"+e+"' is not a valid enumeration value for ReadableStreamReaderMode");return e}function ri(e,t){_t(e,t);var r=null==e?void 0:e.preventAbort,n=null==e?void 0:e.preventCancel,i=null==e?void 0:e.preventClose,a=null==e?void 0:e.signal;return void 0!==a&&function(e,t){if(!function(e){if("object"!=typeof e||null===e)return!1;try{return"boolean"==typeof e.aborted}catch(e){return!1}}(e))throw new TypeError(t+" is not an AbortSignal.")}(a,t+" has member 'signal' that"),{preventAbort:Boolean(r),preventCancel:Boolean(n),preventClose:Boolean(i),signal:a}}Object.defineProperties(Ln.prototype,{close:{enumerable:!0},enqueue:{enumerable:!0},error:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Ln.prototype,Ne.toStringTag,{value:"ReadableStreamDefaultController",configurable:!0});var ni=function(){function e(e,t){void 0===e&&(e={}),void 0===t&&(t={}),void 0===e?e=null:xt(e,"First parameter");var r=Mr(t,"Second parameter"),n=function(e,t){_t(e,t);var r=e,n=null==r?void 0:r.autoAllocateChunkSize,i=null==r?void 0:r.cancel,a=null==r?void 0:r.pull,o=null==r?void 0:r.start,s=null==r?void 0:r.type;return{autoAllocateChunkSize:void 0===n?void 0:Ct(n,t+" has member 'autoAllocateChunkSize' that"),cancel:void 0===i?void 0:Yn(i,r,t+" has member 'cancel' that"),pull:void 0===a?void 0:Xn(a,r,t+" has member 'pull' that"),start:void 0===o?void 0:Zn(o,r,t+" has member 'start' that"),type:void 0===s?void 0:ei(s,t+" has member 'type' that")}}(e,"First parameter");if(oi(this),"bytes"===n.type){if(void 0!==r.size)throw new RangeError("The strategy for a byte stream cannot have a size function");!function(e,t,r){var n=Object.create(er.prototype),i=function(){},a=function(){return Qe(void 0)},o=function(){return Qe(void 0)};void 0!==t.start&&(i=function(){return t.start(n)}),void 0!==t.pull&&(a=function(){return t.pull(n)}),void 0!==t.cancel&&(o=function(e){return t.cancel(e)});var s=t.autoAllocateChunkSize;if(0===s)throw new TypeError("autoAllocateChunkSize must be greater than 0");xr(e,n,i,a,o,r,s)}(this,n,Pr(r,0))}else{var i=Dr(r);!function(e,t,r,n){var i=Object.create(Ln.prototype),a=function(){},o=function(){return Qe(void 0)},s=function(){return Qe(void 0)};void 0!==t.start&&(a=function(){return t.start(i)}),void 0!==t.pull&&(o=function(){return t.pull(i)}),void 0!==t.cancel&&(s=function(e){return t.cancel(e)}),Jn(e,i,a,o,s,r,n)}(this,n,Pr(r,1),i)}}return Object.defineProperty(e.prototype,"locked",{get:function(){if(!si(this))throw pi("locked");return ui(this)},enumerable:!1,configurable:!0}),e.prototype.cancel=function(e){return void 0===e&&(e=void 0),si(this)?ui(this)?$e(new TypeError("Cannot cancel a stream that already has a reader")):ci(this,e):$e(pi("cancel"))},e.prototype.getReader=function(e){if(void 0===e&&(e=void 0),!si(this))throw pi("getReader");return void 0===function(e,t){_t(e,t);var r=null==e?void 0:e.mode;return{mode:void 0===r?void 0:ti(r,t+" has member 'mode' that")}}(e,"First parameter").mode?Bt(this):Ar(this)},e.prototype.pipeThrough=function(e,t){if(void 0===t&&(t={}),!si(this))throw pi("pipeThrough");Et(e,1,"pipeThrough");var r=function(e,t){_t(e,t);var r=null==e?void 0:e.readable;St(r,"readable","ReadableWritablePair"),Tt(r,t+" has member 'readable' that");var n=null==e?void 0:e.writable;return St(n,"writable","ReadableWritablePair"),qr(n,t+" has member 'writable' that"),{readable:r,writable:n}}(e,"First parameter"),n=ri(t,"Second parameter");if(ui(this))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked ReadableStream");if(Jr(r.writable))throw new TypeError("ReadableStream.prototype.pipeThrough cannot be used on a locked WritableStream");return rt(Fn(this,r.writable,n.preventClose,n.preventAbort,n.preventCancel,n.signal)),r.readable},e.prototype.pipeTo=function(e,t){if(void 0===t&&(t={}),!si(this))return $e(pi("pipeTo"));if(void 0===e)return $e("Parameter 1 is required in 'pipeTo'.");if(!Kr(e))return $e(new TypeError("ReadableStream.prototype.pipeTo's first argument must be a WritableStream"));var r;try{r=ri(t,"Second parameter")}catch(e){return $e(e)}return ui(this)?$e(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked ReadableStream")):Jr(e)?$e(new TypeError("ReadableStream.prototype.pipeTo cannot be used on a locked WritableStream")):Fn(this,e,r.preventClose,r.preventAbort,r.preventCancel,r.signal)},e.prototype.tee=function(){if(!si(this))throw pi("tee");return Vt($n(this))},e.prototype.values=function(e){if(void 0===e&&(e=void 0),!si(this))throw pi("values");var t,r,n,i,a,o=function(e,t){_t(e,t);var r=null==e?void 0:e.preventCancel;return{preventCancel:Boolean(r)}}(e,"First parameter");return t=this,r=o.preventCancel,n=Bt(t),i=new Ut(n,r),(a=Object.create(qt))._asyncIteratorImpl=i,a},e}();function ii(e,t,r,n,i){void 0===n&&(n=1),void 0===i&&(i=function(){return 1});var a=Object.create(ni.prototype);return oi(a),Jn(a,Object.create(Ln.prototype),e,t,r,n,i),a}function ai(e,t,r){var n=Object.create(ni.prototype);return oi(n),xr(n,Object.create(er.prototype),e,t,r,0,void 0),n}function oi(e){e._state="readable",e._reader=void 0,e._storedError=void 0,e._disturbed=!1}function si(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_readableStreamController")&&e instanceof ni)}function ui(e){return void 0!==e._reader}function ci(e,t){if(e._disturbed=!0,"closed"===e._state)return Qe(void 0);if("errored"===e._state)return $e(e._storedError);li(e);var r=e._reader;return void 0!==r&&Rr(r)&&(r._readIntoRequests.forEach((function(e){e._closeSteps(void 0)})),r._readIntoRequests=new ot),tt(e._readableStreamController[yt](t),ze)}function li(e){e._state="closed";var t=e._reader;void 0!==t&&(dt(t),Lt(t)&&(t._readRequests.forEach((function(e){e._closeSteps()})),t._readRequests=new ot))}function hi(e,t){e._state="errored",e._storedError=t;var r=e._reader;void 0!==r&&(ft(r,t),Lt(r)?(r._readRequests.forEach((function(e){e._errorSteps(t)})),r._readRequests=new ot):(r._readIntoRequests.forEach((function(e){e._errorSteps(t)})),r._readIntoRequests=new ot))}function pi(e){return new TypeError("ReadableStream.prototype."+e+" can only be used on a ReadableStream")}function fi(e,t){_t(e,t);var r=null==e?void 0:e.highWaterMark;return St(r,"highWaterMark","QueuingStrategyInit"),{highWaterMark:At(r)}}Object.defineProperties(ni.prototype,{cancel:{enumerable:!0},getReader:{enumerable:!0},pipeThrough:{enumerable:!0},pipeTo:{enumerable:!0},tee:{enumerable:!0},values:{enumerable:!0},locked:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(ni.prototype,Ne.toStringTag,{value:"ReadableStream",configurable:!0}),"symbol"==typeof Ne.asyncIterator&&Object.defineProperty(ni.prototype,Ne.asyncIterator,{value:ni.prototype.values,writable:!0,configurable:!0});var di=function(e){return e.byteLength};try{Object.defineProperty(di,"name",{value:"size",configurable:!0})}catch(Dt){}var mi=function(){function e(e){Et(e,1,"ByteLengthQueuingStrategy"),e=fi(e,"First parameter"),this._byteLengthQueuingStrategyHighWaterMark=e.highWaterMark}return Object.defineProperty(e.prototype,"highWaterMark",{get:function(){if(!yi(this))throw gi("highWaterMark");return this._byteLengthQueuingStrategyHighWaterMark},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){if(!yi(this))throw gi("size");return di},enumerable:!1,configurable:!0}),e}();function gi(e){return new TypeError("ByteLengthQueuingStrategy.prototype."+e+" can only be used on a ByteLengthQueuingStrategy")}function yi(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_byteLengthQueuingStrategyHighWaterMark")&&e instanceof mi)}Object.defineProperties(mi.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(mi.prototype,Ne.toStringTag,{value:"ByteLengthQueuingStrategy",configurable:!0});var bi=function(){return 1};try{Object.defineProperty(bi,"name",{value:"size",configurable:!0})}catch(Dt){}var vi=function(){function e(e){Et(e,1,"CountQueuingStrategy"),e=fi(e,"First parameter"),this._countQueuingStrategyHighWaterMark=e.highWaterMark}return Object.defineProperty(e.prototype,"highWaterMark",{get:function(){if(!_i(this))throw wi("highWaterMark");return this._countQueuingStrategyHighWaterMark},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){if(!_i(this))throw wi("size");return bi},enumerable:!1,configurable:!0}),e}();function wi(e){return new TypeError("CountQueuingStrategy.prototype."+e+" can only be used on a CountQueuingStrategy")}function _i(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_countQueuingStrategyHighWaterMark")&&e instanceof vi)}function ki(e,t,r){return kt(e,r),function(r){return at(e,t,[r])}}function xi(e,t,r){return kt(e,r),function(r){return it(e,t,[r])}}function Ei(e,t,r){return kt(e,r),function(r,n){return at(e,t,[r,n])}}Object.defineProperties(vi.prototype,{highWaterMark:{enumerable:!0},size:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(vi.prototype,Ne.toStringTag,{value:"CountQueuingStrategy",configurable:!0});var Si=function(){function e(e,t,r){void 0===e&&(e={}),void 0===t&&(t={}),void 0===r&&(r={}),void 0===e&&(e=null);var n=Mr(t,"Second parameter"),i=Mr(r,"Third parameter"),a=function(e,t){_t(e,t);var r=null==e?void 0:e.flush,n=null==e?void 0:e.readableType,i=null==e?void 0:e.start,a=null==e?void 0:e.transform,o=null==e?void 0:e.writableType;return{flush:void 0===r?void 0:ki(r,e,t+" has member 'flush' that"),readableType:n,start:void 0===i?void 0:xi(i,e,t+" has member 'start' that"),transform:void 0===a?void 0:Ei(a,e,t+" has member 'transform' that"),writableType:o}}(e,"First parameter");if(void 0!==a.readableType)throw new RangeError("Invalid readableType specified");if(void 0!==a.writableType)throw new RangeError("Invalid writableType specified");var o,s=Pr(i,0),u=Dr(i),c=Pr(n,1),l=Dr(n);!function(e,t,r,n,i,a){function o(){return t}e._writable=function(e,t,r,n,i,a){void 0===i&&(i=1),void 0===a&&(a=function(){return 1});var o=Object.create(Gr.prototype);return Vr(o),dn(o,Object.create(pn.prototype),e,t,r,n,i,a),o}(o,(function(t){return function(e,t){var r=e._transformStreamController;if(e._backpressure){return tt(e._backpressureChangePromise,(function(){var n=e._writable;if("erroring"===n._state)throw n._storedError;return Pi(r,t)}))}return Pi(r,t)}(e,t)}),(function(){return function(e){var t=e._readable,r=e._transformStreamController,n=r._flushAlgorithm();return Oi(r),tt(n,(function(){if("errored"===t._state)throw t._storedError;Hn(t._readableStreamController)}),(function(r){throw ji(e,r),t._storedError}))}(e)}),(function(t){return function(e,t){return ji(e,t),Qe(void 0)}(e,t)}),r,n),e._readable=ii(o,(function(){return function(e){return Ti(e,!1),e._backpressureChangePromise}(e)}),(function(t){return Ci(e,t),Qe(void 0)}),i,a),e._backpressure=void 0,e._backpressureChangePromise=void 0,e._backpressureChangePromise_resolve=void 0,Ti(e,!0),e._transformStreamController=void 0}(this,Je((function(e){o=e})),c,l,s,u),function(e,t){var r=Object.create(Bi.prototype),n=function(e){try{return Ii(r,e),Qe(void 0)}catch(e){return $e(e)}},i=function(){return Qe(void 0)};void 0!==t.transform&&(n=function(e){return t.transform(e,r)});void 0!==t.flush&&(i=function(){return t.flush(r)});!function(e,t,r,n){t._controlledTransformStream=e,e._transformStreamController=t,t._transformAlgorithm=r,t._flushAlgorithm=n}(e,r,n,i)}(this,a),void 0!==a.start?o(a.start(this._transformStreamController)):o(void 0)}return Object.defineProperty(e.prototype,"readable",{get:function(){if(!Ai(this))throw Mi("readable");return this._readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){if(!Ai(this))throw Mi("writable");return this._writable},enumerable:!1,configurable:!0}),e}();function Ai(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_transformStreamController")&&e instanceof Si)}function ji(e,t){Wn(e._readable._readableStreamController,t),Ci(e,t)}function Ci(e,t){Oi(e._transformStreamController),bn(e._writable._writableStreamController,t),e._backpressure&&Ti(e,!1)}function Ti(e,t){void 0!==e._backpressureChangePromise&&e._backpressureChangePromise_resolve(),e._backpressureChangePromise=Je((function(t){e._backpressureChangePromise_resolve=t})),e._backpressure=t}Object.defineProperties(Si.prototype,{readable:{enumerable:!0},writable:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Si.prototype,Ne.toStringTag,{value:"TransformStream",configurable:!0});var Bi=function(){function e(){throw new TypeError("Illegal constructor")}return Object.defineProperty(e.prototype,"desiredSize",{get:function(){if(!Ri(this))throw Di("desiredSize");return Vn(this._controlledTransformStream._readable._readableStreamController)},enumerable:!1,configurable:!0}),e.prototype.enqueue=function(e){if(void 0===e&&(e=void 0),!Ri(this))throw Di("enqueue");Ii(this,e)},e.prototype.error=function(e){if(void 0===e&&(e=void 0),!Ri(this))throw Di("error");var t;t=e,ji(this._controlledTransformStream,t)},e.prototype.terminate=function(){if(!Ri(this))throw Di("terminate");!function(e){var t=e._controlledTransformStream;Hn(t._readable._readableStreamController);var r=new TypeError("TransformStream terminated");Ci(t,r)}(this)},e}();function Ri(e){return!!qe(e)&&(!!Object.prototype.hasOwnProperty.call(e,"_controlledTransformStream")&&e instanceof Bi)}function Oi(e){e._transformAlgorithm=void 0,e._flushAlgorithm=void 0}function Ii(e,t){var r=e._controlledTransformStream,n=r._readable._readableStreamController;if(!Kn(n))throw new TypeError("Readable side is not in a state that permits enqueue");try{Gn(n,t)}catch(e){throw Ci(r,e),r._readable._storedError}(function(e){return!Un(e)})(n)!==r._backpressure&&Ti(r,!0)}function Pi(e,t){return tt(e._transformAlgorithm(t),void 0,(function(t){throw ji(e._controlledTransformStream,t),t}))}function Di(e){return new TypeError("TransformStreamDefaultController.prototype."+e+" can only be used on a TransformStreamDefaultController")}function Mi(e){return new TypeError("TransformStream.prototype."+e+" can only be used on a TransformStream")}Object.defineProperties(Bi.prototype,{enqueue:{enumerable:!0},error:{enumerable:!0},terminate:{enumerable:!0},desiredSize:{enumerable:!0}}),"symbol"==typeof Ne.toStringTag&&Object.defineProperty(Bi.prototype,Ne.toStringTag,{value:"TransformStreamDefaultController",configurable:!0});var Fi={ReadableStream:ni,ReadableStreamDefaultController:Ln,ReadableByteStreamController:er,ReadableStreamBYOBRequest:Zt,ReadableStreamDefaultReader:Ft,ReadableStreamBYOBReader:Br,WritableStream:Gr,WritableStreamDefaultController:pn,WritableStreamDefaultWriter:nn,ByteLengthQueuingStrategy:mi,CountQueuingStrategy:vi,TransformStream:Si,TransformStreamDefaultController:Bi};if(void 0!==Ue)for(var Li in Fi)Object.prototype.hasOwnProperty.call(Fi,Li)&&Object.defineProperty(Ue,Li,{value:Fi[Li],writable:!0,configurable:!0});delete global.ReadableStream;let Ni,zi,Ui;Ni=Symbol.asyncIterator;zi=Symbol.toStringTag;Ui=Symbol.toStringTag;(!m||!("TextEncoder"in y))&&(y.TextEncoder=F);(!m||!("TextDecoder"in y))&&(y.TextDecoder=M),m||"atob"in y||!ae||(y.atob=ae),m||"btoa"in y||!oe||(y.btoa=oe),m||"Headers"in y||!ue||(y.Headers=ue),m||"Response"in y||!_e||(y.Response=_e),m||"fetch"in y||!Be||(y.fetch=Be),m||"DOMParser"in y||!d.DOMParser||(y.DOMParser=d.DOMParser),m||"_encodeImageNode"in y||!De||(y._encodeImageNode=De),m||"_parseImageNode"in y||!Le||(y._parseImageNode=Le),"allSettled"in Promise||(Promise.allSettled=function(e){const t=e.map(e=>e.then(e=>({status:"fulfilled",value:e})).catch(e=>({status:"rejected",reason:e})));return Promise.all(t)});var qi=r(2),Hi=r(23),Gi=r.n(Hi),Wi=r(6),Vi=r.n(Wi);"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof global&&global,"undefined"!=typeof document&&document;const Ki=Boolean("object"!=typeof process||"[object process]"!==String(process)||process.browser),Ji="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version),Qi=(Ji&&parseFloat(Ji[1]),e=>"boolean"==typeof e),$i=e=>"function"==typeof e,Yi=e=>null!==e&&"object"==typeof e,Xi=e=>Yi(e)&&e.constructor==={}.constructor,Zi=e=>e&&"function"==typeof e[Symbol.iterator],ea=e=>e&&"function"==typeof e[Symbol.asyncIterator],ta=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,ra=e=>"undefined"!=typeof Blob&&e instanceof Blob,na=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||Yi(e)&&$i(e.tee)&&$i(e.cancel)&&$i(e.getReader))(e)||(e=>Yi(e)&&$i(e.read)&&$i(e.pipe)&&Qi(e.readable))(e);function ia(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function aa(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function oa(e){var t,r;let n;return ia(e,"null loader"),ia(aa(e),"invalid loader"),Array.isArray(e)&&(n=e[1],e=e[0],e={...e,options:{...e.options,...n}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(r=e)&&void 0!==r&&r.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}let sa="";const ua={};function ca(e){for(const t in ua)if(e.startsWith(t)){const r=ua[t];e=e.replace(t,r)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${sa}${e}`),e}const la=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,ha=/^([-\w.]+\/[-\w.+]+)/;function pa(e){const t=ha.exec(e);return t?t[1]:e}function fa(e){const t=la.exec(e);return t?t[1]:""}const da=/\?.*/;function ma(e){if(ta(e)){const t=ga(e.url||"");return{url:t,type:pa(e.headers.get("content-type")||"")||fa(t)}}return ra(e)?{url:ga(e.name||""),type:e.type||""}:"string"==typeof e?{url:ga(e),type:fa(e)}:{url:"",type:""}}function ga(e){return e.replace(da,"")}async function ya(e){if(ta(e))return e;const t={},r=function(e){return ta(e)?e.headers["content-length"]||-1:ra(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);r>=0&&(t["content-length"]=String(r));const{url:n,type:i}=ma(e);i&&(t["content-type"]=i);const a=await async function(e){if("string"==typeof e)return"data:,"+e.slice(0,5);if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const r=new FileReader;r.onload=t=>{var r;return e(null==t||null===(r=t.target)||void 0===r?void 0:r.result)},r.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const t=e.slice(0,5);return"data:base64,"+function(e){let t="";const r=new Uint8Array(e);for(let e=0;e<r.byteLength;e++)t+=String.fromCharCode(r[e]);return btoa(t)}(t)}return null}(e);a&&(t["x-first-bytes"]=a),"string"==typeof e&&(e=(new TextEncoder).encode(e));const o=new Response(e,{headers:t});return Object.defineProperty(o,"url",{value:n}),o}async function ba(e){if(!e.ok){const t=await async function(e){let t=`Failed to fetch resource ${e.url} (${e.status}): `;try{const r=e.headers.get("Content-Type");let n=e.statusText;r.includes("application/json")&&(n+=" "+await e.text()),t+=n,t=t.length>60?t.slice(0,60)+"...":t}catch(e){}return t}(e);throw new Error(t)}}async function va(e,t){if("string"==typeof e){e=ca(e);let r=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(r=t.fetch),await fetch(e,r)}return await ya(e)}var wa=r(550);const _a=new wa.a({id:"loaders.gl"});class ka{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const xa={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){var e,t,r;r=void 0,(t="console")in(e=this)?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:Ki,_nodeWorkers:!1,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},Ea={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function Sa(){globalThis.loaders=globalThis.loaders||{};const{loaders:e}=globalThis;return e._state=e._state||{},e._state}const Aa=()=>{const e=Sa();return e.globalOptions=e.globalOptions||{...xa},e.globalOptions};function ja(e,t,r,n){return r=r||[],function(e,t){Ta(e,null,xa,Ea,t);for(const r of t){const n=e&&e[r.id]||{},i=r.options&&r.options[r.id]||{},a=r.deprecatedOptions&&r.deprecatedOptions[r.id]||{};Ta(n,r.id,i,a,t)}}(e,r=Array.isArray(r)?r:[r]),Ra(t,e,n)}function Ca(e,t){const r=Aa(),n=e||r;return"function"==typeof n.fetch?n.fetch:Yi(n.fetch)?e=>va(e,n):null!=t&&t.fetch?null==t?void 0:t.fetch:va}function Ta(e,t,r,n,i){const a=t||"Top level",o=t?t+".":"";for(const s in e){const u=!t&&Yi(e[s]),c="baseUri"===s&&!t,l="workerUrl"===s&&t;if(!(s in r)&&!c&&!l)if(s in n)_a.warn(`${a} loader option '${o}${s}' no longer supported, use '${n[s]}'`)();else if(!u){const e=Ba(s,i);_a.warn(`${a} loader option '${o}${s}' not recognized. ${e}`)()}}}function Ba(e,t){const r=e.toLowerCase();let n="";for(const i of t)for(const t in i.options){if(e===t)return`Did you mean '${i.id}.${t}'?`;const a=t.toLowerCase();(r.startsWith(a)||a.startsWith(r))&&(n=n||`Did you mean '${i.id}.${t}'?`)}return n}function Ra(e,t,r){const n={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(n,r),null===n.log&&(n.log=new ka),Oa(n,Aa()),Oa(n,t),n}function Oa(e,t){for(const r in t)if(r in t){const n=t[r];Xi(n)&&Xi(e[r])?e[r]={...e[r],...t[r]}:e[r]=t[r]}}function Ia(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}const Pa={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document},Da=Pa.global||Pa.self||Pa.window||{},Ma="object"!=typeof process||"[object process]"!==String(process)||process.browser,Fa="function"==typeof importScripts,La="undefined"!=typeof window&&void 0!==window.orientation,Na="undefined"!=typeof process&&process.version&&/v([0-9]*)/.exec(process.version);Na&&parseFloat(Na[1]);var za=r(84);const Ua=new Map;function qa(e){Ia(e.source&&!e.url||!e.source&&e.url);let t=Ua.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Ha((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),Ua.set(e.url,t)),e.source&&(t=Ha(e.source),Ua.set(e.source,t))),Ia(t),t}function Ha(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function Ga(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}function Wa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Va=()=>{};class Ka{static isSupported(){return"undefined"!=typeof Worker&&Ma||void 0!==za.NodeWorker&&!Ma}constructor(e){Wa(this,"name",void 0),Wa(this,"source",void 0),Wa(this,"url",void 0),Wa(this,"terminated",!1),Wa(this,"worker",void 0),Wa(this,"onMessage",void 0),Wa(this,"onError",void 0),Wa(this,"_loadableURL","");const{name:t,source:r,url:n}=e;Ia(r||n),this.name=t,this.source=r,this.url=n,this.onMessage=Va,this.onError=e=>console.log(e),this.worker=Ma?this._createBrowserWorker():this._createNodeWorker()}destroy(){this.onMessage=Va,this.onError=Va,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||function e(t,r=!0,n){const i=n||new Set;if(t){if(Ga(t))i.add(t);else if(Ga(t.buffer))i.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"==typeof t)for(const n in t)e(t[n],r,i)}else;return void 0===n?Array.from(i):[]}(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=e.message+" in "),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=qa({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}_createNodeWorker(){let e;if(this.url){const t=this.url.includes(":/")||this.url.startsWith("/")?this.url:"./"+this.url;e=new za.NodeWorker(t,{eval:!1})}else{if(!this.source)throw new Error("no worker");e=new za.NodeWorker(this.source,{eval:!0})}return e.on("message",e=>{this.onMessage(e)}),e.on("error",e=>{this.onError(e)}),e.on("exit",e=>{}),e}}function Ja(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Qa{constructor(e,t){Ja(this,"name",void 0),Ja(this,"workerThread",void 0),Ja(this,"isRunning",!0),Ja(this,"result",void 0),Ja(this,"_resolve",()=>{}),Ja(this,"_reject",()=>{}),this.name=e,this.workerThread=t,this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Ia(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Ia(this.isRunning),this.isRunning=!1,this._reject(e)}}function $a(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Ya{static isSupported(){return Ka.isSupported()}constructor(e){$a(this,"name","unnamed"),$a(this,"source",void 0),$a(this,"url",void 0),$a(this,"maxConcurrency",1),$a(this,"maxMobileConcurrency",1),$a(this,"onDebug",()=>{}),$a(this,"reuseWorkers",!0),$a(this,"props",{}),$a(this,"jobQueue",[]),$a(this,"idleQueue",[]),$a(this,"count",0),$a(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,r)=>e.done(r)),r=((e,t)=>e.error(t))){const n=new Promise(n=>(this.jobQueue.push({name:e,onMessage:t,onError:r,onStart:n}),this));return this._startQueuedJob(),await n}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const r=new Qa(t.name,e);e.onMessage=e=>t.onMessage(r,e.type,e.payload),e.onError=e=>t.onError(r,e),t.onStart(r);try{await r.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ka({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return La?this.maxMobileConcurrency:this.maxConcurrency}}function Xa(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Za={maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,onDebug:()=>{}};class eo{static isSupported(){return Ka.isSupported()}static getWorkerFarm(e={}){return eo._workerFarm=eo._workerFarm||new eo({}),eo._workerFarm.setProps(e),eo._workerFarm}constructor(e){Xa(this,"props",void 0),Xa(this,"workerPools",new Map),this.props={...Za},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy();this.workerPools=new Map}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:r,url:n}=e;let i=this.workerPools.get(t);return i||(i=new Ya({name:t,source:r,url:n}),i.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,i)),i}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}Xa(eo,"_workerFarm",void 0);function to(e,t={}){const r=t[e.id]||{},n=e.id+"-worker.js";let i=r.workerUrl;if(i||"compression"!==e.id||(i=t.workerUrl),"test"===t._workerType&&(i=`modules/${e.module}/dist/${n}`),!i){let t=e.version;"latest"===t&&(t="latest");const r=t?"@"+t:"";i=`https://unpkg.com/@loaders.gl/${e.module}${r}/dist/${n}`}return Ia(i),i}async function ro(e,t,r,n,i){const a=e.id,o=to(e,r),s=eo.getWorkerFarm(r).getWorkerPool({name:a,url:o});r=JSON.parse(JSON.stringify(r)),n=JSON.parse(JSON.stringify(n||{}));const u=await s.startJob("process-on-worker",no.bind(null,i));u.postMessage("process",{input:t,options:r,context:n});const c=await u.result;return await c.result}async function no(e,t,r,n){switch(r){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:i,input:a,options:o}=n;try{const r=await e(a,o);t.postMessage("done",{id:i,result:r})}catch(e){const r=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:i,error:r})}break;default:console.warn("parse-with-worker unknown message "+r)}}function io(...e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),r=t.reduce((e,t)=>e+t.byteLength,0),n=new Uint8Array(r);let i=0;for(const e of t)n.set(e,i),i+=e.byteLength;return n.buffer}function ao(...e){const 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');const n=new r(t.reduce((e,t)=>e+t.length,0));let i=0;for(const e of t)n.set(e,i),i+=e.length;return n}function oo(e,t,r){const n=void 0!==r?new Uint8Array(e).subarray(t,t+r):new Uint8Array(e).subarray(t);return new Uint8Array(n).buffer}async function so(e){const t=[];for await(const r of e)t.push(r);return io(...t)}const uo=262144;function co(e){if(Buffer.isBuffer(e)){return new Uint8Array(e.buffer,e.byteOffset,e.length).slice().buffer}return e}function lo(e){if(Buffer.isBuffer(e))return e;if(ArrayBuffer.isView(e)&&(e=e.buffer),"undefined"!=typeof Buffer&&e instanceof ArrayBuffer)return Buffer.from(e);throw new Error("toBuffer")}function ho(e){return lo?lo(e):e}function po(e){if((t=e)&&"object"==typeof t&&t.isBuffer)return co(e);var t;if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function fo(e,t){return Ki?async function*(e,t){const r=e.getReader();let n;try{for(;;){const e=n||r.read();null!=t&&t._streamReadAhead&&(n=r.read());const{done:i,value:a}=await e;if(i)return;yield po(a)}}catch(e){r.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield po(t)}(e)}function mo(e,t){if("string"==typeof e)return function*(e,t){const r=(null==t?void 0:t.chunkSize)||262144;let n=0;const i=new TextEncoder;for(;n<e.length;){const t=Math.min(e.length-n,r),a=e.slice(n,n+t);n+=t,yield i.encode(a)}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:r=uo}=t;let n=0;for(;n<e.byteLength;){const t=Math.min(e.byteLength-n,r),i=new ArrayBuffer(t),a=new Uint8Array(e,n,t);new Uint8Array(i).set(a),n+=t,yield i}}(e,t);if(ra(e))return async function*(e,t){const r=(null==t?void 0:t.chunkSize)||1048576;let n=0;for(;n<e.size;){const t=n+r,i=await e.slice(n,t).arrayBuffer();n=t,yield i}}(e,t);if(na(e))return fo(e,t);if(ta(e)){return fo(e.body,t)}throw new Error("makeIterator")}const go="Cannot convert supplied data type";async function yo(e,t,r){const n=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return function(e,t,r){if(t.text&&"string"==typeof e)return e;var n;if((n=e)&&"object"==typeof n&&n.isBuffer&&(e=e.buffer),e instanceof ArrayBuffer){const r=e;if(t.text&&!t.binary){return new TextDecoder("utf8").decode(r)}return r}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary){return new TextDecoder("utf8").decode(e)}let r=e.buffer;const n=e.byteLength||e.length;return 0===e.byteOffset&&n===r.byteLength||(r=r.slice(e.byteOffset,e.byteOffset+n)),r}throw new Error(go)}(e,t);if(ra(e)&&(e=await ya(e)),ta(e)){const r=e;return await ba(r),t.binary?await r.arrayBuffer():await r.text()}if(na(e)&&(e=mo(e,r)),Zi(e)||ea(e))return so(e);throw new Error(go)}function bo(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(t+1):""}function vo(e){const t=e&&e.lastIndexOf("/");return t>=0?e.substr(0,t):""}function wo(...e){return(e=e.map((t,r)=>(r&&(t=t.replace(new RegExp("^/"),"")),r!==e.length-1&&(t=t.replace(new RegExp("/$"),"")),t))).join("/")}function _o(e){return(t,r)=>new Promise((n,i)=>e(t,r,(e,t)=>e?i(e):n(t)))}let ko,xo,Eo,So,Ao,jo,Co,To,Bo,Ro,Oo,Io=Boolean(je.a);try{ko=_o(je.a.readdir),xo=_o(je.a.stat),Eo=je.a.readFile,So=je.a.readFileSync,Po=je.a.writeFile,Ao=(e,t,r)=>new Promise((n,i)=>Po(e,t,r,(e,t)=>e?i(e):n(t))),jo=je.a.writeFileSync,Co=je.a.open,To=e=>new Promise((t,r)=>je.a.close(e,e=>e?r(e):t())),Bo=je.a.read,Ro=je.a.fstat,Oo=je.a.createWriteStream,Io=Boolean(je.a)}catch{}var Po;async function Do(e,t,r){const n=Buffer.alloc(r),{bytesRead:i}=await Bo(e,n,0,r,t);if(i!==r)throw new Error("fs.read failed");return co(n)}const Mo=new wa.a({id:"loaders.gl"}),Fo=()=>{const e=Sa();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};const Lo=/\.([^.]+)$/;function No(e,t=[],r,n){if(!zo(e))return null;if(t&&!Array.isArray(t))return oa(t);let i=[];t&&(i=i.concat(t)),null!=r&&r.ignoreRegisteredLoaders||i.push(...Fo()),function(e){for(const t of e)oa(t)}(i);const a=function(e,t,r,n){const{url:i,type:a}=ma(e),o=i||(null==n?void 0:n.url);let s=null,u="";null!=r&&r.mimeType&&(s=qo(t,null==r?void 0:r.mimeType),u="match forced by supplied MIME type "+(null==r?void 0:r.mimeType));var c;s=s||function(e,t){const r=t&&Lo.exec(t),n=r&&r[1];return n?function(e,t){t=t.toLowerCase();for(const r of e)for(const e of r.extensions)if(e.toLowerCase()===t)return r;return null}(e,n):null}(t,o),u=u||(s?"matched url "+o:""),s=s||qo(t,a),u=u||(s?"matched MIME type "+a:""),s=s||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(Ho(t,r))return r}else if(ArrayBuffer.isView(t)){if(Go(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(Go(t,0,r))return r}return null}(t,e),u=u||(s?"matched initial data "+Wo(e):""),s=s||qo(t,null==r?void 0:r.fallbackMimeType),u=u||(s?"matched fallback MIME type "+a:""),u&&Mo.log(1,`selectLoader selected ${null===(c=s)||void 0===c?void 0:c.name}: ${u}.`);return s}(e,i,r,n);if(!(a||null!=r&&r.nothrow))throw new Error(Uo(e));return a}function zo(e){return!(e instanceof Response&&204===e.status)}function Uo(e){const{url:t,type:r}=ma(e);let i="No valid loader found (";i+=t?n.filename(t)+", ":"no url provided, ",i+=`MIME type: ${r?`"${r}"`:"not provided"}, `;const a=e?Wo(e):"";return i+=a?` first bytes: "${a}"`:"first bytes: not available",i+=")",i}function qo(e,t){for(const r of e){if(r.mimeTypes&&r.mimeTypes.includes(t))return r;if(t==="application/x."+r.id)return r}return null}function Ho(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Go(e,t,r){return(Array.isArray(r.tests)?r.tests:[r.tests]).some(n=>function(e,t,r,n){if(n instanceof ArrayBuffer)return function(e,t,r){if(r=r||e.byteLength,e.byteLength<r||t.byteLength<r)return!1;const n=new Uint8Array(e),i=new Uint8Array(t);for(let e=0;e<n.length;++e)if(n[e]!==i[e])return!1;return!0}(n,e,n.byteLength);switch(typeof n){case"function":return n(e,r);case"string":const i=Vo(e,t,n.length);return n===i;default:return!1}}(e,t,r,n))}function Wo(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Vo(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Vo(e,0,t)}return""}function Vo(e,t,r){if(e.byteLength<t+r)return"";const n=new DataView(e);let i="";for(let e=0;e<r;e++)i+=String.fromCharCode(n.getUint8(t+e));return i}async function Ko(e,t,r,n){Ia(!n||"object"==typeof n),!t||Array.isArray(t)||aa(t)||(n=void 0,r=t,t=void 0),e=await e,r=r||{};const{url:i}=ma(e),a=function(e,t){if(!t&&e&&!Array.isArray(e))return e;let r;if(e&&(r=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];r=r?[...r,...e]:e}return r&&r.length?r:null}(t,n),o=await async function(e,t=[],r,n){if(!zo(e))return null;let i=No(e,t,{...r,nothrow:!0},n);if(i)return i;if(ra(e)&&(i=No(e=await e.slice(0,10).arrayBuffer(),t,r,n)),!(i||null!=r&&r.nothrow))throw new Error(Uo(e));return i}(e,a,r);return o?(n=function(e,t,r=null){if(r)return r;const n={fetch:Ca(t,e),...e};return Array.isArray(n.loaders)||(n.loaders=null),n}({url:i,parse:Ko,loaders:a},r=ja(r,o,a,i),n),await async function(e,t,r,n){if(function(e,t="3.3.1"){Ia(e,"no worker provided");const r=e.version}(e),ta(t)){const e=t,{ok:r,redirected:i,status:a,statusText:o,type:s,url:u}=e,c=Object.fromEntries(e.headers.entries());n.response={headers:c,ok:r,redirected:i,status:a,statusText:o,type:s,url:u}}if(t=await yo(t,e,r),e.parseTextSync&&"string"==typeof t)return r.dataType="text",e.parseTextSync(t,r,n,e);if(function(e,t){return!!eo.isSupported()&&(!!(Ma||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}(e,r))return await ro(e,t,r,n,Ko);if(e.parseText&&"string"==typeof t)return await e.parseText(t,r,n,e);if(e.parse)return await e.parse(t,r,n,e);throw Ia(!e.parseSync),new Error(e.id+" loader - no parser found and worker is disabled")}(o,e,r,n)):null}async function Jo(e,t,r,n){Array.isArray(t)||aa(t)||(void 0,r=t,t=void 0);const i=Ca(r);let a=e;return"string"==typeof e&&(a=await i(e)),ra(e)&&(a=await i(e)),await Ko(a,t,r)}function Qo(e,t){if(!e)throw new Error("math.gl assertion ".concat(t))}const $o=1/Math.PI*180,Yo=1/180*Math.PI,Xo={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0};function Zo(e,{precision:t=Xo.precision}={}){return e=function(e){return Math.round(e/Xo.EPSILON)*Xo.EPSILON}(e),"".concat(parseFloat(e.toPrecision(t)))}function es(e){return Array.isArray(e)||ArrayBuffer.isView(e)&&!(e instanceof DataView)}function ts(e){return function(e,t){return os(e,e=>e*Yo,t)}(e)}function rs(e){return ns(e)}function ns(e,t){return os(e,e=>e*$o,t)}function is(e,t,r){return os(e,e=>Math.max(t,Math.min(r,e)))}function as(e,t,r){const n=Xo.EPSILON;r&&(Xo.EPSILON=r);try{if(e===t)return!0;if(es(e)&&es(t)){if(e.length!==t.length)return!1;for(let r=0;r<e.length;++r)if(!as(e[r],t[r]))return!1;return!0}return e&&e.equals?e.equals(t):t&&t.equals?t.equals(e):"number"==typeof e&&"number"==typeof t&&Math.abs(e-t)<=Xo.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))}finally{Xo.EPSILON=n}}function os(e,t,r){if(es(e)){const n=e;r=r||function(e){return e.clone?e.clone():new Array(e.length)}(n);for(let i=0;i<r.length&&i<n.length;++i)r[i]=t(e[i],i,r);return r}return t(e)}class ss extends(function(e){function t(){var t=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(t,Object.getPrototypeOf(this)),t}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}(Array)){clone(){return(new this.constructor).copy(this)}fromArray(e,t=0){for(let r=0;r<this.ELEMENTS;++r)this[r]=e[r+t];return this.check()}toArray(e=[],t=0){for(let r=0;r<this.ELEMENTS;++r)e[t+r]=this[r];return e}from(e){return Array.isArray(e)?this.copy(e):this.fromObject(e)}to(e){return e===this?this:es(e)?this.toArray(e):this.toObject(e)}toTarget(e){return e?this.to(e):this}toFloat32Array(){return new Float32Array(this)}toString(){return this.formatString(Xo)}formatString(e){let t="";for(let r=0;r<this.ELEMENTS;++r)t+=(r>0?", ":"")+Zo(this[r],e);return"".concat(e.printTypes?this.constructor.name:"","[").concat(t,"]")}equals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(!as(this[t],e[t]))return!1;return!0}exactEquals(e){if(!e||this.length!==e.length)return!1;for(let t=0;t<this.ELEMENTS;++t)if(this[t]!==e[t])return!1;return!0}negate(){for(let e=0;e<this.ELEMENTS;++e)this[e]=-this[e];return this.check()}lerp(e,t,r){if(void 0===r)return this.lerp(this,e,t);for(let n=0;n<this.ELEMENTS;++n){const i=e[n];this[n]=i+r*(t[n]-i)}return this.check()}min(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.min(e[t],this[t]);return this.check()}max(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=Math.max(e[t],this[t]);return this.check()}clamp(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e[r]),t[r]);return this.check()}add(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]+=t[e];return this.check()}subtract(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]-=t[e];return this.check()}scale(e){if("number"==typeof e)for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;else for(let t=0;t<this.ELEMENTS&&t<e.length;++t)this[t]*=e[t];return this.check()}multiplyByScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}check(){if(Xo.debug&&!this.validate())throw new Error("math.gl: ".concat(this.constructor.name," some fields set to invalid numbers'"));return this}validate(){let e=this.length===this.ELEMENTS;for(let t=0;t<this.ELEMENTS;++t)e=e&&Number.isFinite(this[t]);return e}sub(e){return this.subtract(e)}setScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]=e;return this.check()}addScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]+=e;return this.check()}subScalar(e){return this.addScalar(-e)}multiplyScalar(e){for(let t=0;t<this.ELEMENTS;++t)this[t]*=e;return this.check()}divideScalar(e){return this.multiplyByScalar(1/e)}clampScalar(e,t){for(let r=0;r<this.ELEMENTS;++r)this[r]=Math.min(Math.max(this[r],e),t);return this.check()}get elements(){return this}}function us(e){if(!Number.isFinite(e))throw new Error("Invalid number ".concat(e));return e}function cs(e,t,r=""){if(Xo.debug&&!function(e,t){if(e.length!==t)return!1;for(let t=0;t<e.length;++t)if(!Number.isFinite(e[t]))return!1;return!0}(e,t))throw new Error("math.gl: ".concat(r," some fields set to invalid numbers'"));return e}class ls extends ss{get x(){return this[0]}set x(e){this[0]=us(e)}get y(){return this[1]}set y(e){this[1]=us(e)}len(){return Math.sqrt(this.lengthSquared())}magnitude(){return this.len()}lengthSquared(){let e=0;for(let t=0;t<this.ELEMENTS;++t)e+=this[t]*this[t];return e}magnitudeSquared(){return this.lengthSquared()}distance(e){return Math.sqrt(this.distanceSquared(e))}distanceSquared(e){let t=0;for(let r=0;r<this.ELEMENTS;++r){const n=this[r]-e[r];t+=n*n}return us(t)}dot(e){let t=0;for(let r=0;r<this.ELEMENTS;++r)t+=this[r]*e[r];return us(t)}normalize(){const e=this.magnitude();if(0!==e)for(let t=0;t<this.ELEMENTS;++t)this[t]/=e;return this.check()}multiply(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]*=t[e];return this.check()}divide(...e){for(const t of e)for(let e=0;e<this.ELEMENTS;++e)this[e]/=t[e];return this.check()}lengthSq(){return this.lengthSquared()}distanceTo(e){return this.distance(e)}distanceToSquared(e){return this.distanceSquared(e)}getComponent(e){return Qo(e>=0&&e<this.ELEMENTS,"index is out of range"),us(this[e])}setComponent(e,t){return Qo(e>=0&&e<this.ELEMENTS,"index is out of range"),this[e]=t,this.check()}addVectors(e,t){return this.copy(e).add(t)}subVectors(e,t){return this.copy(e).subtract(t)}multiplyVectors(e,t){return this.copy(e).multiply(t)}addScaledVector(e,t){return this.add(new this.constructor(e).multiplyScalar(t))}}var hs=1e-6,ps="undefined"!=typeof Float32Array?Float32Array:Array;Math.random;Math.PI;function fs(){var e=new ps(3);return ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ds(e){var t=e[0],r=e[1],n=e[2];return Math.hypot(t,r,n)}function ms(e,t,r){var n=new ps(3);return n[0]=e,n[1]=t,n[2]=r,n}function gs(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ys(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2];return e[0]=i*u-a*s,e[1]=a*o-n*u,e[2]=n*s-i*o,e}function bs(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a+r[15];return o=o||1,e[0]=(r[0]*n+r[4]*i+r[8]*a+r[12])/o,e[1]=(r[1]*n+r[5]*i+r[9]*a+r[13])/o,e[2]=(r[2]*n+r[6]*i+r[10]*a+r[14])/o,e}function vs(e,t,r){var n=t[0],i=t[1],a=t[2];return e[0]=n*r[0]+i*r[3]+a*r[6],e[1]=n*r[1]+i*r[4]+a*r[7],e[2]=n*r[2]+i*r[5]+a*r[8],e}function ws(e,t,r){var n=r[0],i=r[1],a=r[2],o=r[3],s=t[0],u=t[1],c=t[2],l=i*c-a*u,h=a*s-n*c,p=n*u-i*s,f=i*p-a*h,d=a*l-n*p,m=n*h-i*l,g=2*o;return l*=g,h*=g,p*=g,f*=2,d*=2,m*=2,e[0]=s+l+f,e[1]=u+h+d,e[2]=c+p+m,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var _s,ks=ds;_s=fs();function xs(e,t,r){const n=t[0],i=t[1],a=r[3]*n+r[7]*i||1;return e[0]=(r[0]*n+r[4]*i)/a,e[1]=(r[1]*n+r[5]*i)/a,e}function Es(e,t,r){const n=t[0],i=t[1],a=t[2],o=r[3]*n+r[7]*i+r[11]*a||1;return e[0]=(r[0]*n+r[4]*i+r[8]*a)/o,e[1]=(r[1]*n+r[5]*i+r[9]*a)/o,e[2]=(r[2]*n+r[6]*i+r[10]*a)/o,e}function Ss(e,t,r){const n=t[0],i=t[1],a=t[2];return e[0]=r[0]*n+r[3]*i+r[6]*a,e[1]=r[1]*n+r[4]*i+r[7]*a,e[2]=r[2]*n+r[5]*i+r[8]*a,e[3]=t[3],e}const As=[0,0,0];let js;class Cs extends ls{static get ZERO(){return js||(js=new Cs(0,0,0),Object.freeze(js)),js}constructor(e=0,t=0,r=0){super(-0,-0,-0),1===arguments.length&&es(e)?this.copy(e):(Xo.debug&&(us(e),us(t),us(r)),this[0]=e,this[1]=t,this[2]=r)}set(e,t,r){return this[0]=e,this[1]=t,this[2]=r,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y),us(e.z)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e}get ELEMENTS(){return 3}get z(){return this[2]}set z(e){this[2]=us(e)}angle(e){return r=e,n=(t=this)[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],c=Math.sqrt(n*n+i*i+a*a)*Math.sqrt(o*o+s*s+u*u),l=c&&gs(t,r)/c,Math.acos(Math.min(Math.max(l,-1),1));var t,r,n,i,a,o,s,u,c,l}cross(e){return ys(this,this,e),this.check()}rotateX({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[0],s[1]=o[1]*Math.cos(a)-o[2]*Math.sin(a),s[2]=o[1]*Math.sin(a)+o[2]*Math.cos(a),r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}rotateY({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[2]*Math.sin(a)+o[0]*Math.cos(a),s[1]=o[1],s[2]=o[2]*Math.cos(a)-o[0]*Math.sin(a),r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}rotateZ({radians:e,origin:t=As}){var r,n,i,a,o,s;return r=this,i=t,a=e,s=[],(o=[])[0]=(n=this)[0]-i[0],o[1]=n[1]-i[1],o[2]=n[2]-i[2],s[0]=o[0]*Math.cos(a)-o[1]*Math.sin(a),s[1]=o[0]*Math.sin(a)+o[1]*Math.cos(a),s[2]=o[2],r[0]=s[0]+i[0],r[1]=s[1]+i[1],r[2]=s[2]+i[2],this.check()}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return bs(this,this,e),this.check()}transformAsVector(e){return Es(this,this,e),this.check()}transformByMatrix3(e){return vs(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2]}(this,this,e),this.check()}transformByQuaternion(e){return ws(this,this,e),this.check()}}class Ts extends ss{toString(){let e="[";if(Xo.printRowMajor){e+="row-major:";for(let t=0;t<this.RANK;++t)for(let r=0;r<this.RANK;++r)e+=" ".concat(this[r*this.RANK+t])}else{e+="column-major:";for(let t=0;t<this.ELEMENTS;++t)e+=" ".concat(this[t])}return e+="]",e}getElementIndex(e,t){return t*this.RANK+e}getElement(e,t){return this[t*this.RANK+e]}setElement(e,t,r){return this[t*this.RANK+e]=us(r),this}getColumn(e,t=new Array(this.RANK).fill(-0)){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)t[e]=this[r+e];return t}setColumn(e,t){const r=e*this.RANK;for(let e=0;e<this.RANK;++e)this[r+e]=t[e];return this}}function Bs(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],h=t[8],p=t[9],f=t[10],d=t[11],m=t[12],g=t[13],y=t[14],b=t[15],v=r[0],w=r[1],_=r[2],k=r[3];return e[0]=v*n+w*s+_*h+k*m,e[1]=v*i+w*u+_*p+k*g,e[2]=v*a+w*c+_*f+k*y,e[3]=v*o+w*l+_*d+k*b,v=r[4],w=r[5],_=r[6],k=r[7],e[4]=v*n+w*s+_*h+k*m,e[5]=v*i+w*u+_*p+k*g,e[6]=v*a+w*c+_*f+k*y,e[7]=v*o+w*l+_*d+k*b,v=r[8],w=r[9],_=r[10],k=r[11],e[8]=v*n+w*s+_*h+k*m,e[9]=v*i+w*u+_*p+k*g,e[10]=v*a+w*c+_*f+k*y,e[11]=v*o+w*l+_*d+k*b,v=r[12],w=r[13],_=r[14],k=r[15],e[12]=v*n+w*s+_*h+k*m,e[13]=v*i+w*u+_*p+k*g,e[14]=v*a+w*c+_*f+k*y,e[15]=v*o+w*l+_*d+k*b,e}function Rs(e,t){var r=t[0],n=t[1],i=t[2],a=t[4],o=t[5],s=t[6],u=t[8],c=t[9],l=t[10];return e[0]=Math.hypot(r,n,i),e[1]=Math.hypot(a,o,s),e[2]=Math.hypot(u,c,l),e}var Os=function(e,t,r,n,i){var a,o=1/Math.tan(t/2);return 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,null!=i&&i!==1/0?(a=1/(n-i),e[10]=(i+n)*a,e[14]=2*i*n*a):(e[10]=-1,e[14]=-2*n),e};var Is=function(e,t,r,n,i,a,o){var s=1/(t-r),u=1/(n-i),c=1/(a-o);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*u,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+r)*s,e[13]=(i+n)*u,e[14]=(o+a)*c,e[15]=1,e};function Ps(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[3]*i+r[6],e[1]=r[1]*n+r[4]*i+r[7],e}function Ds(e,t,r){var n=t[0],i=t[1];return e[0]=r[0]*n+r[4]*i+r[12],e[1]=r[1]*n+r[5]*i+r[13],e}!function(){var e,t=(e=new ps(2),ps!=Float32Array&&(e[0]=0,e[1]=0),e)}();function Ms(e){var t=e[0],r=e[1],n=e[2],i=e[3];return Math.hypot(t,r,n,i)}function Fs(e){var t=e[0],r=e[1],n=e[2],i=e[3];return t*t+r*r+n*n+i*i}var Ls;!function(){var e,t=(e=new ps(4),ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();!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"}(Ls||(Ls={}));const Ns=45*Math.PI/180,zs=1,Us=.1,qs=500,Hs=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);class Gs extends Ts{static get IDENTITY(){return function(){Vs||(Vs=new Gs,Object.freeze(Vs));return Vs}()}static get ZERO(){return function(){Ws||(Ws=new Gs([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),Object.freeze(Ws));return Ws}()}get ELEMENTS(){return 16}get RANK(){return 4}get INDICES(){return Ls}constructor(e){super(-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this[9]=e[9],this[10]=e[10],this[11]=e[11],this[12]=e[12],this[13]=e[13],this[14]=e[14],this[15]=e[15],this.check()}set(e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this[9]=c,this[10]=l,this[11]=h,this[12]=p,this[13]=f,this[14]=d,this[15]=m,this.check()}setRowMajor(e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m){return this[0]=e,this[1]=i,this[2]=u,this[3]=p,this[4]=t,this[5]=a,this[6]=c,this[7]=f,this[8]=r,this[9]=o,this[10]=l,this[11]=d,this[12]=n,this[13]=s,this[14]=h,this[15]=m,this.check()}toRowMajor(e){return e[0]=this[0],e[1]=this[4],e[2]=this[8],e[3]=this[12],e[4]=this[1],e[5]=this[5],e[6]=this[9],e[7]=this[13],e[8]=this[2],e[9]=this[6],e[10]=this[10],e[11]=this[14],e[12]=this[3],e[13]=this[7],e[14]=this[11],e[15]=this[15],e}identity(){return this.copy(Hs)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,c=r*o,l=n*o,h=n*s,p=i*o,f=i*s,d=i*u,m=a*o,g=a*s,y=a*u;e[0]=1-h-d,e[1]=l+y,e[2]=p-g,e[3]=0,e[4]=l-y,e[5]=1-c-d,e[6]=f+m,e[7]=0,e[8]=p+g,e[9]=f-m,e[10]=1-c-h,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1}(this,e),this.check()}frustum(e){const{left:t,right:r,bottom:n,top:i,near:a=Us,far:o=qs}=e;return o===1/0?function(e,t,r,n,i,a){const o=2*a/(r-t),s=2*a/(i-n),u=(r+t)/(r-t),c=(i+n)/(i-n),l=-2*a;e[0]=o,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=s,e[6]=0,e[7]=0,e[8]=u,e[9]=c,e[10]=-1,e[11]=-1,e[12]=0,e[13]=0,e[14]=l,e[15]=0}(this,t,r,n,i,a):function(e,t,r,n,i,a,o){var s=1/(r-t),u=1/(i-n),c=1/(a-o);e[0]=2*a*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=2*a*u,e[6]=0,e[7]=0,e[8]=(r+t)*s,e[9]=(i+n)*u,e[10]=(o+a)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=o*a*2*c,e[15]=0}(this,t,r,n,i,a,o),this.check()}lookAt(e){const{eye:t,center:r=[0,0,0],up:n=[0,1,0]}=e;return function(e,t,r,n){var i,a,o,s,u,c,l,h,p,f,d=t[0],m=t[1],g=t[2],y=n[0],b=n[1],v=n[2],w=r[0],_=r[1],k=r[2];Math.abs(d-w)<hs&&Math.abs(m-_)<hs&&Math.abs(g-k)<hs?function(e){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):(l=d-w,h=m-_,p=g-k,i=b*(p*=f=1/Math.hypot(l,h,p))-v*(h*=f),a=v*(l*=f)-y*p,o=y*h-b*l,(f=Math.hypot(i,a,o))?(i*=f=1/f,a*=f,o*=f):(i=0,a=0,o=0),s=h*o-p*a,u=p*i-l*o,c=l*a-h*i,(f=Math.hypot(s,u,c))?(s*=f=1/f,u*=f,c*=f):(s=0,u=0,c=0),e[0]=i,e[1]=s,e[2]=l,e[3]=0,e[4]=a,e[5]=u,e[6]=h,e[7]=0,e[8]=o,e[9]=c,e[10]=p,e[11]=0,e[12]=-(i*d+a*m+o*g),e[13]=-(s*d+u*m+c*g),e[14]=-(l*d+h*m+p*g),e[15]=1)}(this,t,r,n),this.check()}ortho(e){const{left:t,right:r,bottom:n,top:i,near:a=Us,far:o=qs}=e;return Is(this,t,r,n,i,a,o),this.check()}orthographic(e){const{fovy:t=Ns,aspect:r=zs,focalDistance:n=1,near:i=Us,far:a=qs}=e;Ks(t);const o=t/2,s=n*Math.tan(o),u=s*r;return this.ortho({left:-u,right:u,bottom:-s,top:s,near:i,far:a})}perspective(e){const{fovy:t=45*Math.PI/180,aspect:r=1,near:n=.1,far:i=500}=e;return Ks(t),Os(this,t,r,n,i),this.check()}determinant(){return t=(e=this)[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],p=e[11],f=e[12],d=e[13],m=e[14],g=e[15],(t*o-r*a)*(h*g-p*m)-(t*s-n*a)*(l*g-p*d)+(t*u-i*a)*(l*m-h*d)+(r*s-n*o)*(c*g-p*f)-(r*u-i*o)*(c*m-h*f)+(n*u-i*s)*(c*d-l*f);var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g}getScale(e=[-0,-0,-0]){return e[0]=Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]),e[1]=Math.sqrt(this[4]*this[4]+this[5]*this[5]+this[6]*this[6]),e[2]=Math.sqrt(this[8]*this[8]+this[9]*this[9]+this[10]*this[10]),e}getTranslation(e=[-0,-0,-0]){return e[0]=this[12],e[1]=this[13],e[2]=this[14],e}getRotation(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),n=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=0,e[4]=this[4]*n,e[5]=this[5]*i,e[6]=this[6]*a,e[7]=0,e[8]=this[8]*n,e[9]=this[9]*i,e[10]=this[10]*a,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}getRotationMatrix3(e,t){e=e||[-0,-0,-0,-0,-0,-0,-0,-0,-0],t=t||[-0,-0,-0];const r=this.getScale(t),n=1/r[0],i=1/r[1],a=1/r[2];return e[0]=this[0]*n,e[1]=this[1]*i,e[2]=this[2]*a,e[3]=this[4]*n,e[4]=this[5]*i,e[5]=this[6]*a,e[6]=this[8]*n,e[7]=this[9]*i,e[8]=this[10]*a,e}transpose(){return function(e,t){if(e===t){var r=t[1],n=t[2],i=t[3],a=t[6],o=t[7],s=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]=a,e[11]=t[14],e[12]=i,e[13]=o,e[14]=s}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]}(this,this),this.check()}invert(){var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g,y,b,v,w,_,k,x,E,S,A,j,C,T,B;return e=this,r=(t=this)[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],h=t[9],p=t[10],f=t[11],d=t[12],m=t[13],g=t[14],y=t[15],(B=(b=r*s-n*o)*(T=p*y-f*g)-(v=r*u-i*o)*(C=h*y-f*m)+(w=r*c-a*o)*(j=h*g-p*m)+(_=n*u-i*s)*(A=l*y-f*d)-(k=n*c-a*s)*(S=l*g-p*d)+(x=i*c-a*u)*(E=l*m-h*d))&&(B=1/B,e[0]=(s*T-u*C+c*j)*B,e[1]=(i*C-n*T-a*j)*B,e[2]=(m*x-g*k+y*_)*B,e[3]=(p*k-h*x-f*_)*B,e[4]=(u*A-o*T-c*S)*B,e[5]=(r*T-i*A+a*S)*B,e[6]=(g*w-d*x-y*v)*B,e[7]=(l*x-p*w+f*v)*B,e[8]=(o*C-s*A+c*E)*B,e[9]=(n*A-r*C-a*E)*B,e[10]=(d*k-m*w+y*b)*B,e[11]=(h*w-l*k-f*b)*B,e[12]=(s*S-o*j-u*E)*B,e[13]=(r*j-n*S+i*E)*B,e[14]=(m*v-d*_-g*b)*B,e[15]=(l*_-h*v+p*b)*B),this.check()}multiplyLeft(e){return Bs(this,e,this),this.check()}multiplyRight(e){return Bs(this,this,e),this.check()}rotateX(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[4],s=r[5],u=r[6],c=r[7],l=r[8],h=r[9],p=r[10],f=r[11],r!==t&&(t[0]=r[0],t[1]=r[1],t[2]=r[2],t[3]=r[3],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[4]=o*a+l*i,t[5]=s*a+h*i,t[6]=u*a+p*i,t[7]=c*a+f*i,t[8]=l*a-o*i,t[9]=h*a-s*i,t[10]=p*a-u*i,t[11]=f*a-c*i,this.check()}rotateY(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[0],s=r[1],u=r[2],c=r[3],l=r[8],h=r[9],p=r[10],f=r[11],r!==t&&(t[4]=r[4],t[5]=r[5],t[6]=r[6],t[7]=r[7],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[0]=o*a-l*i,t[1]=s*a-h*i,t[2]=u*a-p*i,t[3]=c*a-f*i,t[8]=o*i+l*a,t[9]=s*i+h*a,t[10]=u*i+p*a,t[11]=c*i+f*a,this.check()}rotateZ(e){var t,r,n,i,a,o,s,u,c,l,h,p,f;return t=this,r=this,n=e,i=Math.sin(n),a=Math.cos(n),o=r[0],s=r[1],u=r[2],c=r[3],l=r[4],h=r[5],p=r[6],f=r[7],r!==t&&(t[8]=r[8],t[9]=r[9],t[10]=r[10],t[11]=r[11],t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15]),t[0]=o*a+l*i,t[1]=s*a+h*i,t[2]=u*a+p*i,t[3]=c*a+f*i,t[4]=l*a-o*i,t[5]=h*a-s*i,t[6]=p*a-u*i,t[7]=f*a-c*i,this.check()}rotateXYZ(e){return this.rotateX(e[0]).rotateY(e[1]).rotateZ(e[2])}rotateAxis(e,t){return function(e,t,r,n){var i,a,o,s,u,c,l,h,p,f,d,m,g,y,b,v,w,_,k,x,E,S,A,j,C=n[0],T=n[1],B=n[2],R=Math.hypot(C,T,B);R<hs||(C*=R=1/R,T*=R,B*=R,i=Math.sin(r),o=1-(a=Math.cos(r)),s=t[0],u=t[1],c=t[2],l=t[3],h=t[4],p=t[5],f=t[6],d=t[7],m=t[8],g=t[9],y=t[10],b=t[11],v=C*C*o+a,w=T*C*o+B*i,_=B*C*o-T*i,k=C*T*o-B*i,x=T*T*o+a,E=B*T*o+C*i,S=C*B*o+T*i,A=T*B*o-C*i,j=B*B*o+a,e[0]=s*v+h*w+m*_,e[1]=u*v+p*w+g*_,e[2]=c*v+f*w+y*_,e[3]=l*v+d*w+b*_,e[4]=s*k+h*x+m*E,e[5]=u*k+p*x+g*E,e[6]=c*k+f*x+y*E,e[7]=l*k+d*x+b*E,e[8]=s*S+h*A+m*j,e[9]=u*S+p*A+g*j,e[10]=c*S+f*A+y*j,e[11]=l*S+d*A+b*j,t!==e&&(e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]))}(this,this,e,t),this.check()}scale(e){var t,r,n,i,a,o;return t=this,r=this,n=Array.isArray(e)?e:[e,e,e],i=n[0],a=n[1],o=n[2],t[0]=r[0]*i,t[1]=r[1]*i,t[2]=r[2]*i,t[3]=r[3]*i,t[4]=r[4]*a,t[5]=r[5]*a,t[6]=r[6]*a,t[7]=r[7]*a,t[8]=r[8]*o,t[9]=r[9]*o,t[10]=r[10]*o,t[11]=r[11]*o,t[12]=r[12],t[13]=r[13],t[14]=r[14],t[15]=r[15],this.check()}translate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d,m,g,y,b;return t=this,r=this,g=(n=e)[0],y=n[1],b=n[2],r===t?(t[12]=r[0]*g+r[4]*y+r[8]*b+r[12],t[13]=r[1]*g+r[5]*y+r[9]*b+r[13],t[14]=r[2]*g+r[6]*y+r[10]*b+r[14],t[15]=r[3]*g+r[7]*y+r[11]*b+r[15]):(i=r[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=r[9],d=r[10],m=r[11],t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=u,t[5]=c,t[6]=l,t[7]=h,t[8]=p,t[9]=f,t[10]=d,t[11]=m,t[12]=i*g+u*y+p*b+r[12],t[13]=a*g+c*y+f*b+r[13],t[14]=o*g+l*y+d*b+r[14],t[15]=s*g+h*y+m*b+r[15]),this.check()}transform(e,t){return 4===e.length?(r=t||[-0,-0,-0,-0],i=this,a=(n=e)[0],o=n[1],s=n[2],u=n[3],r[0]=i[0]*a+i[4]*o+i[8]*s+i[12]*u,r[1]=i[1]*a+i[5]*o+i[9]*s+i[13]*u,r[2]=i[2]*a+i[6]*o+i[10]*s+i[14]*u,r[3]=i[3]*a+i[7]*o+i[11]*s+i[15]*u,cs(t=r,4),t):this.transformAsPoint(e,t);var r,n,i,a,o,s,u}transformAsPoint(e,t){const{length:r}=e;let n;switch(r){case 2:n=Ds(t||[-0,-0],e,this);break;case 3:n=bs(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(n,e.length),n}transformAsVector(e,t){let r;switch(e.length){case 2:r=xs(t||[-0,-0],e,this);break;case 3:r=Es(t||[-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(r,e.length),r}transformPoint(e,t){return this.transformAsPoint(e,t)}transformVector(e,t){return this.transformAsPoint(e,t)}transformDirection(e,t){return this.transformAsVector(e,t)}makeRotationX(e){return this.identity().rotateX(e)}makeTranslation(e,t,r){return this.identity().translate([e,t,r])}}let Ws,Vs;function Ks(e){if(e>2*Math.PI)throw Error("expected radians")}var Js=r(0),Qs=.1,$s=1e-12,Ys=1e-15,Xs=1e-20;Math.PI,Math.PI,Math.PI,Math.PI;Math.max(6378137,6378137,6356752.314245179);function Zs(e){return e}new Cs;function eu(e,t=[],r=Zs){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 tu(e,t,r=Zs){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}const ru=new Cs,nu=new Cs,iu=new Cs;const au=new Cs,ou={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"}},su={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},uu={east:new Cs,north:new Cs,up:new Cs,west:new Cs,south:new Cs,down:new Cs},cu=new Cs,lu=new Cs,hu=new Cs;function pu(e,t,r,n,i,a){const o=ou[t]&&ou[t][r];let s,u,c;Qo(o&&(!n||n===o));const l=au.copy(i);if(as(l.x,0,1e-14)&&as(l.y,0,1e-14)){const e=Math.sign(l.z);s=cu.fromArray(su[t]),"east"!==t&&"west"!==t&&s.scale(e),u=lu.fromArray(su[r]),"east"!==r&&"west"!==r&&u.scale(e),c=hu.fromArray(su[n]),"east"!==n&&"west"!==n&&c.scale(e)}else{const{up:i,east:a,north:o}=uu;a.set(-l.y,l.x,0).normalize(),e.geodeticSurfaceNormal(l,i),o.copy(i).cross(a);const{down:h,west:p,south:f}=uu;h.copy(i).scale(-1),p.copy(a).scale(-1),f.copy(o).scale(-1),s=uu[t],u=uu[r],c=uu[n]}return a[0]=s.x,a[1]=s.y,a[2]=s.z,a[3]=0,a[4]=u.x,a[5]=u.y,a[6]=u.z,a[7]=0,a[8]=c.x,a[9]=c.y,a[10]=c.z,a[11]=0,a[12]=l.x,a[13]=l.y,a[14]=l.z,a[15]=1,a}const fu=new Cs,du=new Cs,mu=new Cs,gu=new Cs,yu=new Cs,bu=new Cs;class vu{constructor(e=0,t=0,r=0){Object(Js.a)(this,"radii",void 0),Object(Js.a)(this,"radiiSquared",void 0),Object(Js.a)(this,"radiiToTheFourth",void 0),Object(Js.a)(this,"oneOverRadii",void 0),Object(Js.a)(this,"oneOverRadiiSquared",void 0),Object(Js.a)(this,"minimumRadius",void 0),Object(Js.a)(this,"maximumRadius",void 0),Object(Js.a)(this,"centerToleranceSquared",Qs),Object(Js.a)(this,"squaredXOverSquaredZ",void 0),Qo(e>=0),Qo(t>=0),Qo(r>=0),this.radii=new Cs(e,t,r),this.radiiSquared=new Cs(e*e,t*t,r*r),this.radiiToTheFourth=new Cs(e*e*e*e,t*t*t*t,r*r*r*r),this.oneOverRadii=new Cs(0===e?0:1/e,0===t?0:1/t,0===r?0:1/r),this.oneOverRadiiSquared=new Cs(0===e?0:1/(e*e),0===t?0:1/(t*t),0===r?0:1/(r*r)),this.minimumRadius=Math.min(e,t,r),this.maximumRadius=Math.max(e,t,r),0!==this.radiiSquared.z&&(this.squaredXOverSquaredZ=this.radiiSquared.x/this.radiiSquared.z),Object.freeze(this)}equals(e){return this===e||Boolean(e&&this.radii.equals(e.radii))}toString(){return this.radii.toString()}cartographicToCartesian(e,t=[0,0,0]){const r=du,n=mu,[,,i]=e;this.geodeticSurfaceNormalCartographic(e,r),n.copy(this.radiiSquared).scale(r);const a=Math.sqrt(r.dot(n));return n.scale(1/a),r.scale(i),n.add(r),n.to(t)}cartesianToCartographic(e,t=[0,0,0]){bu.from(e);const r=this.scaleToGeodeticSurface(bu,gu);if(!r)return;const n=this.geodeticSurfaceNormal(r,du),i=yu;i.copy(bu).subtract(r);const a=Math.atan2(n.y,n.x),o=Math.asin(n.z),s=Math.sign(gs(i,bu))*ds(i);return tu([a,o,s],t,Xo._cartographicRadians?Zs:rs)}eastNorthUpToFixedFrame(e,t=new Gs){return pu(this,"east","north","up",e,t)}localFrameToFixedFrame(e,t,r,n,i=new Gs){return pu(this,e,t,r,n,i)}geocentricSurfaceNormal(e,t=[0,0,0]){return fu.from(e).normalize().to(t)}geodeticSurfaceNormalCartographic(e,t=[0,0,0]){const r=function(e,t=[]){return eu(e,t,Xo._cartographicRadians?Zs:ts)}(e),n=r[0],i=r[1],a=Math.cos(i);return fu.set(a*Math.cos(n),a*Math.sin(n),Math.sin(i)).normalize(),fu.to(t)}geodeticSurfaceNormal(e,t=[0,0,0]){return fu.from(e).scale(this.oneOverRadiiSquared).normalize().to(t)}scaleToGeodeticSurface(e,t){return function(e,t,r=[]){const{oneOverRadii:n,oneOverRadiiSquared:i,centerToleranceSquared:a}=t;ru.from(e);const o=ru.x,s=ru.y,u=ru.z,c=n.x,l=n.y,h=n.z,p=o*o*c*c,f=s*s*l*l,d=u*u*h*h,m=p+f+d,g=Math.sqrt(1/m);if(!Number.isFinite(g))return;const y=nu;if(y.copy(e).scale(g),m<a)return y.to(r);const b=i.x,v=i.y,w=i.z,_=iu;_.set(y.x*b*2,y.y*v*2,y.z*w*2);let k,x,E,S,A=(1-g)*ru.len()/(.5*_.len()),j=0;do{A-=j,k=1/(1+A*b),x=1/(1+A*v),E=1/(1+A*w);const e=k*k,t=x*x,r=E*E;S=p*e+f*t+d*r-1;j=S/(-2*(p*(e*k)*b+f*(t*x)*v+d*(r*E)*w))}while(Math.abs(S)>$s);return ru.scale([k,x,E]).to(r)}(e,this,t)}scaleToGeocentricSurface(e,t=[0,0,0]){gu.from(e);const r=gu.x,n=gu.y,i=gu.z,a=this.oneOverRadiiSquared,o=1/Math.sqrt(r*r*a.x+n*n*a.y+i*i*a.z);return gu.multiplyScalar(o).to(t)}transformPositionToScaledSpace(e,t=[0,0,0]){return gu.from(e).scale(this.oneOverRadii).to(t)}transformPositionFromScaledSpace(e,t=[0,0,0]){return gu.from(e).scale(this.radii).to(t)}getSurfaceNormalIntersectionWithZAxis(e,t=0,r=[0,0,0]){Qo(as(this.radii.x,this.radii.y,Ys)),Qo(this.radii.z>0),gu.from(e);const n=gu.z*(1-this.squaredXOverSquaredZ);if(!(Math.abs(n)>=this.radii.z-t))return gu.set(0,0,n).to(r)}}Object(Js.a)(vu,"WGS84",new vu(6378137,6378137,6356752.314245179));const{_parseImageNode:wu}=globalThis,_u="undefined"!=typeof Image,ku="undefined"!=typeof ImageBitmap,xu=Boolean(wu),Eu=!!Ki||xu;function Su(e){const t=ju(e);if(!t)throw new Error("Not an image");return t}function Au(e){switch(Su(e)){case"data":return e;case"image":case"imagebitmap":const 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 ju(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"image":e&&"object"==typeof e&&e.data&&e.width&&e.height?"data":null}const Cu=/^data:image\/svg\+xml/,Tu=/\.svg((\?|#).*)?$/;function Bu(e){return e&&(Cu.test(e)||Tu.test(e))}function Ru(e,t){if(Bu(t))throw new Error("SVG cannot be parsed directly to imagebitmap");return new Blob([new Uint8Array(e)])}async function Ou(e,t,r){const n=function(e,t){if(Bu(t)){let t=(new TextDecoder).decode(e);try{"function"==typeof unescape&&"function"==typeof encodeURIComponent&&(t=unescape(encodeURIComponent(t)))}catch(e){throw new Error(e.message)}return"data:image/svg+xml;base64,"+btoa(t)}return Ru(e,t)}(e,r),i=self.URL||self.webkitURL,a="string"!=typeof n&&i.createObjectURL(n);try{return await async function(e,t){const r=new Image;if(r.src=e,t.image&&t.image.decode&&r.decode)return await r.decode(),r;return await new Promise((t,n)=>{try{r.onload=()=>t(r),r.onerror=t=>n(new Error(`Could not load image ${e}: ${t}`))}catch(e){n(e)}})}(a||n,t)}finally{a&&i.revokeObjectURL(a)}}const Iu={};let Pu=!0;async function Du(e,t,r){let n;if(Bu(r)){n=await Ou(e,t,r)}else n=Ru(e,r);const i=t&&t.imagebitmap;return await async function(e,t=null){!function(e){for(const t in e||Iu)return!1;return!0}(t)&&Pu||(t=null);if(t)try{return await createImageBitmap(e,t)}catch(e){console.warn(e),Pu=!1}return await createImageBitmap(e)}(n,i)}function Mu(e){const t=Fu(e);return function(e){const t=Fu(e);if(!(t.byteLength>=24&&2303741511===t.getUint32(0,!1)))return null;return{mimeType:"image/png",width:t.getUint32(16,!1),height:t.getUint32(20,!1)}}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=3&&65496===t.getUint16(0,!1)&&255===t.getUint8(2)))return null;const{tableMarkers:r,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let i=2;for(;i+9<t.byteLength;){const e=t.getUint16(i,!1);if(n.has(e))return{mimeType:"image/jpeg",height:t.getUint16(i+5,!1),width:t.getUint16(i+7,!1)};if(!r.has(e))return null;i+=2,i+=t.getUint16(i,!1)}return null}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=10&&1195984440===t.getUint32(0,!1)))return null;return{mimeType:"image/gif",width:t.getUint16(6,!0),height:t.getUint16(8,!0)}}(t)||function(e){const t=Fu(e);if(!(t.byteLength>=14&&16973===t.getUint16(0,!1)&&t.getUint32(2,!0)===t.byteLength))return null;return{mimeType:"image/bmp",width:t.getUint32(18,!0),height:t.getUint32(22,!0)}}(t)}function Fu(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")}const Lu={id:"image",module:"images",name:"Images",version:"3.3.1",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vnd.microsoft.icon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,r){const n=((t=t||{}).image||{}).type||"auto",{url:i}=r||{};let a;switch(function(e){switch(e){case"auto":case"data":return function(){if(ku)return"imagebitmap";if(_u)return"image";if(Eu)return"data";throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js")}();default:return function(e){switch(e){case"auto":return ku||_u||Eu;case"imagebitmap":return ku;case"image":return _u;case"data":return Eu;default:throw new Error(`@loaders.gl/images: image ${e} not supported in this environment`)}}(e),e}}(n)){case"imagebitmap":a=await Du(e,t,i);break;case"image":a=await Ou(e,t,i);break;case"data":a=await async function(e,t){const{mimeType:r}=Mu(e)||{},n=globalThis._parseImageNode;return ia(n),await n(e,r)}(e);break;default:ia(!1)}return"data"===n&&(a=Au(a)),a},tests:[e=>Boolean(Mu(new DataView(e)))],options:{image:{type:"auto",decode:!0}}},Nu={draco:{decoderType:"object"==typeof WebAssembly?"wasm":"js",libraryPath:"libs/",extraAttributes:{},attributeNameEntry:void 0}},zu={name:"Draco",id:Ma?"draco":"draco-nodejs",module:"draco",shapes:["mesh"],version:"3.3.1",worker:!0,extensions:["drc"],mimeTypes:["application/octet-stream"],binary:!0,tests:["DRACO"],options:Nu};function Uu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class qu{constructor(e,t){Uu(this,"fields",void 0),Uu(this,"metadata",void 0),function(e,t){if(!e)throw new Error(t||"loader assertion failed.")}(Array.isArray(e)),function(e){const t={};for(const r of e)t[r.name]&&console.warn("Schema: duplicated field name",r.name,r),t[r.name]=!0}(e),this.fields=e,this.metadata=t||new Map}compareTo(e){if(this.metadata!==e.metadata)return!1;if(this.fields.length!==e.fields.length)return!1;for(let t=0;t<this.fields.length;++t)if(!this.fields[t].compareTo(e.fields[t]))return!1;return!0}select(...e){const t=Object.create(null);for(const r of e)t[r]=!0;const r=this.fields.filter(e=>t[e.name]);return new qu(r,this.metadata)}selectAt(...e){const t=e.map(e=>this.fields[e]).filter(Boolean);return new qu(t,this.metadata)}assign(e){let t,r=this.metadata;if(e instanceof qu){const n=e;t=n.fields,r=Hu(Hu(new Map,this.metadata),n.metadata)}else t=e;const n=Object.create(null);for(const e of this.fields)n[e.name]=e;for(const e of t)n[e.name]=e;const i=Object.values(n);return new qu(i,r)}}function Hu(e,t){return new Map([...e||new Map,...t||new Map])}function Gu(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Wu{constructor(e,t,r=!1,n=new Map){Gu(this,"name",void 0),Gu(this,"type",void 0),Gu(this,"nullable",void 0),Gu(this,"metadata",void 0),this.name=e,this.type=t,this.nullable=r,this.metadata=n}get typeId(){return this.type&&this.type.typeId}clone(){return new Wu(this.name,this.type,this.nullable,this.metadata)}compareTo(e){return this.name===e.name&&this.type===e.type&&this.nullable===e.nullable&&this.metadata===e.metadata}toString(){return`${this.type}${this.nullable?", nullable":""}${this.metadata?", metadata: "+this.metadata:""}`}}let Vu,Ku,Ju,Qu,$u,Yu,Xu,Zu,ec;function tc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}!function(e){e[e.NONE=0]="NONE",e[e.Null=1]="Null",e[e.Int=2]="Int",e[e.Float=3]="Float",e[e.Binary=4]="Binary",e[e.Utf8=5]="Utf8",e[e.Bool=6]="Bool",e[e.Decimal=7]="Decimal",e[e.Date=8]="Date",e[e.Time=9]="Time",e[e.Timestamp=10]="Timestamp",e[e.Interval=11]="Interval",e[e.List=12]="List",e[e.Struct=13]="Struct",e[e.Union=14]="Union",e[e.FixedSizeBinary=15]="FixedSizeBinary",e[e.FixedSizeList=16]="FixedSizeList",e[e.Map=17]="Map",e[e.Dictionary=-1]="Dictionary",e[e.Int8=-2]="Int8",e[e.Int16=-3]="Int16",e[e.Int32=-4]="Int32",e[e.Int64=-5]="Int64",e[e.Uint8=-6]="Uint8",e[e.Uint16=-7]="Uint16",e[e.Uint32=-8]="Uint32",e[e.Uint64=-9]="Uint64",e[e.Float16=-10]="Float16",e[e.Float32=-11]="Float32",e[e.Float64=-12]="Float64",e[e.DateDay=-13]="DateDay",e[e.DateMillisecond=-14]="DateMillisecond",e[e.TimestampSecond=-15]="TimestampSecond",e[e.TimestampMillisecond=-16]="TimestampMillisecond",e[e.TimestampMicrosecond=-17]="TimestampMicrosecond",e[e.TimestampNanosecond=-18]="TimestampNanosecond",e[e.TimeSecond=-19]="TimeSecond",e[e.TimeMillisecond=-20]="TimeMillisecond",e[e.TimeMicrosecond=-21]="TimeMicrosecond",e[e.TimeNanosecond=-22]="TimeNanosecond",e[e.DenseUnion=-23]="DenseUnion",e[e.SparseUnion=-24]="SparseUnion",e[e.IntervalDayTime=-25]="IntervalDayTime",e[e.IntervalYearMonth=-26]="IntervalYearMonth"}(Vu||(Vu={}));class rc{static isNull(e){return e&&e.typeId===Vu.Null}static isInt(e){return e&&e.typeId===Vu.Int}static isFloat(e){return e&&e.typeId===Vu.Float}static isBinary(e){return e&&e.typeId===Vu.Binary}static isUtf8(e){return e&&e.typeId===Vu.Utf8}static isBool(e){return e&&e.typeId===Vu.Bool}static isDecimal(e){return e&&e.typeId===Vu.Decimal}static isDate(e){return e&&e.typeId===Vu.Date}static isTime(e){return e&&e.typeId===Vu.Time}static isTimestamp(e){return e&&e.typeId===Vu.Timestamp}static isInterval(e){return e&&e.typeId===Vu.Interval}static isList(e){return e&&e.typeId===Vu.List}static isStruct(e){return e&&e.typeId===Vu.Struct}static isUnion(e){return e&&e.typeId===Vu.Union}static isFixedSizeBinary(e){return e&&e.typeId===Vu.FixedSizeBinary}static isFixedSizeList(e){return e&&e.typeId===Vu.FixedSizeList}static isMap(e){return e&&e.typeId===Vu.Map}static isDictionary(e){return e&&e.typeId===Vu.Dictionary}get typeId(){return Vu.NONE}compareTo(e){return this===e}}Symbol.toStringTag;Symbol.toStringTag;Ku=Symbol.toStringTag;class nc extends rc{constructor(e,t){super(),tc(this,"isSigned",void 0),tc(this,"bitWidth",void 0),this.isSigned=e,this.bitWidth=t}get typeId(){return Vu.Int}get[Ku](){return"Int"}toString(){return`${this.isSigned?"I":"Ui"}nt${this.bitWidth}`}}class ic extends nc{constructor(){super(!0,8)}}class ac extends nc{constructor(){super(!0,16)}}class oc extends nc{constructor(){super(!0,32)}}class sc extends nc{constructor(){super(!1,8)}}class uc extends nc{constructor(){super(!1,16)}}class cc extends nc{constructor(){super(!1,32)}}const lc=32,hc=64;Ju=Symbol.toStringTag;class pc extends rc{constructor(e){super(),tc(this,"precision",void 0),this.precision=e}get typeId(){return Vu.Float}get[Ju](){return"Float"}toString(){return"Float"+this.precision}}class fc extends pc{constructor(){super(lc)}}class dc extends pc{constructor(){super(hc)}}Symbol.toStringTag;Symbol.toStringTag;Qu=Symbol.toStringTag;$u=Symbol.toStringTag;Yu=Symbol.toStringTag;Xu=Symbol.toStringTag;Zu=Symbol.toStringTag;class mc extends rc{constructor(e,t){super(),tc(this,"listSize",void 0),tc(this,"children",void 0),this.listSize=e,this.children=[t]}get typeId(){return Vu.FixedSizeList}get valueType(){return this.children[0].type}get valueField(){return this.children[0]}get[Zu](){return"FixedSizeList"}toString(){return`FixedSizeList[${this.listSize}]<${this.valueType}>`}}ec=Symbol.toStringTag;function gc(e,t,r){const n=function(e){switch(e.constructor){case Int8Array:return new ic;case Uint8Array:return new sc;case Int16Array:return new ac;case Uint16Array:return new uc;case Int32Array:return new oc;case Uint32Array:return new cc;case Float32Array:return new fc;case Float64Array:return new dc;default:throw new Error("array type not supported")}}(t.value),i=r||function(e){const t=new Map;"byteOffset"in e&&t.set("byteOffset",e.byteOffset.toString(10));"byteStride"in e&&t.set("byteStride",e.byteStride.toString(10));"normalized"in e&&t.set("normalized",e.normalized.toString());return t}(t);return new Wu(e,new mc(t.size,new Wu("value",n)),!1,i)}function yc(e,t,r){return gc(e,t,r?bc(r.metadata):void 0)}function bc(e){const t=new Map;for(const r in e)t.set(r+".string",JSON.stringify(e[r]));return t}function vc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const wc={POSITION:"POSITION",NORMAL:"NORMAL",COLOR:"COLOR_0",TEX_COORD:"TEXCOORD_0"},_c={1:Int8Array,2:Uint8Array,3:Int16Array,4:Uint16Array,5:Int32Array,6:Uint32Array,9:Float32Array};class kc{constructor(e){vc(this,"draco",void 0),vc(this,"decoder",void 0),vc(this,"metadataQuerier",void 0),this.draco=e,this.decoder=new this.draco.Decoder,this.metadataQuerier=new this.draco.MetadataQuerier}destroy(){this.draco.destroy(this.decoder),this.draco.destroy(this.metadataQuerier)}parseSync(e,t={}){const r=new this.draco.DecoderBuffer;r.Init(new Int8Array(e),e.byteLength),this._disableAttributeTransforms(t);const n=this.decoder.GetEncodedGeometryType(r),i=n===this.draco.TRIANGULAR_MESH?new this.draco.Mesh:new this.draco.PointCloud;try{let e;switch(n){case this.draco.TRIANGULAR_MESH:e=this.decoder.DecodeBufferToMesh(r,i);break;case this.draco.POINT_CLOUD:e=this.decoder.DecodeBufferToPointCloud(r,i);break;default:throw new Error("DRACO: Unknown geometry type.")}if(!e.ok()||!i.ptr){const t="DRACO decompression failed: "+e.error_msg();throw new Error(t)}const a=this._getDracoLoaderData(i,n,t),o=this._getMeshData(i,a,t),s=function(e){let t=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0;const s=e.POSITION?e.POSITION.value:[],u=s&&s.length;for(let e=0;e<u;e+=3){const u=s[e],c=s[e+1],l=s[e+2];t=u<t?u:t,r=c<r?c:r,n=l<n?l:n,i=u>i?u:i,a=c>a?c:a,o=l>o?l:o}return[[t,r,n],[i,a,o]]}(o.attributes),u=function(e,t,r){const n=bc(t.metadata),i=[],a=function(e){const t={};for(const r in e){const n=e[r];t[n.name||"undefined"]=n}return t}(t.attributes);for(const t in e){const r=yc(t,e[t],a[t]);i.push(r)}if(r){const e=yc("indices",r);i.push(e)}return new qu(i,n)}(o.attributes,a,o.indices);return{loader:"draco",loaderData:a,header:{vertexCount:i.num_points(),boundingBox:s},...o,schema:u}}finally{this.draco.destroy(r),i&&this.draco.destroy(i)}}_getDracoLoaderData(e,t,r){const n=this._getTopLevelMetadata(e),i=this._getDracoAttributes(e,r);return{geometry_type:t,num_attributes:e.num_attributes(),num_points:e.num_points(),num_faces:e instanceof this.draco.Mesh?e.num_faces():0,metadata:n,attributes:i}}_getDracoAttributes(e,t){const r={};for(let n=0;n<e.num_attributes();n++){const i=this.decoder.GetAttribute(e,n),a=this._getAttributeMetadata(e,n);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:n,metadata:a};const o=this._getQuantizationTransform(i,t);o&&(r[i.unique_id()].quantization_transform=o);const s=this._getOctahedronTransform(i,t);s&&(r[i.unique_id()].octahedron_transform=s)}return r}_getMeshData(e,t,r){const n=this._getMeshAttributes(t,e,r);if(!n.POSITION)throw new Error("DRACO: No position attribute found.");if(e instanceof this.draco.Mesh)switch(r.topology){case"triangle-strip":return{topology:"triangle-strip",mode:4,attributes:n,indices:{value:this._getTriangleStripIndices(e),size:1}};case"triangle-list":default:return{topology:"triangle-list",mode:5,attributes:n,indices:{value:this._getTriangleListIndices(e),size:1}}}return{topology:"point-list",mode:0,attributes:n}}_getMeshAttributes(e,t,r){const n={};for(const i of Object.values(e.attributes)){const e=this._deduceAttributeName(i,r);i.name=e;const{value:a,size:o}=this._getAttributeValues(t,i);n[e]={value:a,size:o,byteOffset:i.byte_offset,byteStride:i.byte_stride,normalized:i.normalized}}return n}_getTriangleListIndices(e){const t=3*e.num_faces(),r=4*t,n=this.draco._malloc(r);try{return this.decoder.GetTrianglesUInt32Array(e,r,n),new Uint32Array(this.draco.HEAPF32.buffer,n,t).slice()}finally{this.draco._free(n)}}_getTriangleStripIndices(e){const t=new this.draco.DracoInt32Array;try{return this.decoder.GetTriangleStripsFromMesh(e,t),function(e){const t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}(t)}finally{this.draco.destroy(t)}}_getAttributeValues(e,t){const r=_c[t.data_type],n=t.num_components,i=e.num_points()*n,a=i*r.BYTES_PER_ELEMENT,o=function(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}}(this.draco,r);let s;const u=this.draco._malloc(a);try{const n=this.decoder.GetAttribute(e,t.attribute_index);this.decoder.GetAttributeDataArrayForAllPoints(e,n,o,a,u),s=new r(this.draco.HEAPF32.buffer,u,i).slice()}finally{this.draco._free(u)}return{value:s,size:n}}_deduceAttributeName(e,t){const r=e.unique_id;for(const[e,n]of Object.entries(t.extraAttributes||{}))if(n===r)return e;const n=e.attribute_type;for(const e in wc){if(this.draco[e]===n)return wc[e]}const i=t.attributeNameEntry||"name";return e.metadata[i]?e.metadata[i].string:"CUSTOM_ATTRIBUTE_"+r}_getTopLevelMetadata(e){const t=this.decoder.GetMetadata(e);return this._getDracoMetadata(t)}_getAttributeMetadata(e,t){const r=this.decoder.GetAttributeMetadata(e,t);return this._getDracoMetadata(r)}_getDracoMetadata(e){if(!e||!e.ptr)return{};const t={},r=this.metadataQuerier.NumEntries(e);for(let n=0;n<r;n++){const r=this.metadataQuerier.GetEntryName(e,n);t[r]=this._getDracoMetadataField(e,r)}return t}_getDracoMetadataField(e,t){const r=new this.draco.DracoInt32Array;try{this.metadataQuerier.GetIntEntryArray(e,t,r);const n=function(e){const t=e.size(),r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=e.GetValue(n);return r}(r);return{int:this.metadataQuerier.GetIntEntry(e,t),string:this.metadataQuerier.GetStringEntry(e,t),double:this.metadataQuerier.GetDoubleEntry(e,t),intArray:n}}finally{this.draco.destroy(r)}}_disableAttributeTransforms(e){const{quantizedAttributes:t=[],octahedronAttributes:r=[]}=e,n=[...t,...r];for(const e of n)this.decoder.SkipAttributeTransform(this.draco[e])}_getQuantizationTransform(e,t){const{quantizedAttributes:r=[]}=t,n=e.attribute_type();if(r.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits(),range:t.range(),min_values:new Float32Array([1,2,3]).map(e=>t.min_value(e))}}finally{this.draco.destroy(t)}}return null}_getOctahedronTransform(e,t){const{octahedronAttributes:r=[]}=t,n=e.attribute_type();if(r.map(e=>this.decoder[e]).includes(n)){const t=new this.draco.AttributeQuantizationTransform;try{if(t.InitFromAttribute(e))return{quantization_bits:t.quantization_bits()}}finally{this.draco.destroy(t)}}return null}}var xc=r(52);const Ec={};async function Sc(e,t=null,r={}){return t&&(e=function(e,t,r){if(e.startsWith("http"))return e;const n=r.modules||{};if(n[e])return n[e];if(!Ma)return`modules/${t}/dist/libs/${e}`;if(r.CDN)return Ia(r.CDN.startsWith("http")),`${r.CDN}/${t}@3.3.1/dist/libs/${e}`;if(Fa)return"../src/libs/"+e;return`modules/${t}/src/libs/${e}`}(e,t,r)),Ec[e]=Ec[e]||async function(e){if(e.endsWith("wasm")){const t=await fetch(e);return await t.arrayBuffer()}if(!Ma)try{return xc&&xc.requireFromFile&&await xc.requireFromFile(e)}catch{return null}if(Fa)return importScripts(e);const t=await fetch(e);return function(e,t){if(!Ma)return xc.requireFromString&&xc.requireFromString(e,t);if(Fa)return eval.call(Da,e),null;const r=document.createElement("script");r.id=t;try{r.appendChild(document.createTextNode(e))}catch(t){r.text=e}return document.body.appendChild(r),null}(await t.text(),e)}(e),await Ec[e]}let Ac;async function jc(e){const t=e.modules||{};return Ac=t.draco3d?Ac||t.draco3d.createDecoderModule({}).then(e=>({draco:e})):Ac||async function(e){let t,r;switch(e.draco&&e.draco.decoderType){case"js":t=await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_decoder.js","draco",e);break;case"wasm":default:[t,r]=await Promise.all([await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_wasm_wrapper.js","draco",e),await Sc("https://www.gstatic.com/draco/versioned/decoders/1.5.5/draco_decoder.wasm","draco",e)])}return t=t||globalThis.DracoDecoderModule,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e({...r,onModuleLoaded:e=>t({draco:e})})})}(t,r)}(e),await Ac}const Cc={id:Ma?"draco-writer":"draco-writer-nodejs",name:"Draco compressed geometry writer",module:"draco",version:"3.3.1",worker:!0,options:{draco:{},source:null}},Tc={...zu,parse:async function(e,t){const{draco:r}=await jc(t),n=new kc(r);try{return n.parseSync(e,null==t?void 0:t.draco)}finally{n.destroy()}}};new Uint8Array([0]);const Bc=[171,75,84,88,32,50,48,187,13,10,26,10];var Rc,Oc,Ic,Pc,Dc,Mc,Fc,Lc,Nc;(Nc=Rc||(Rc={}))[Nc.NONE=0]="NONE",Nc[Nc.BASISLZ=1]="BASISLZ",Nc[Nc.ZSTD=2]="ZSTD",Nc[Nc.ZLIB=3]="ZLIB",function(e){e[e.BASICFORMAT=0]="BASICFORMAT"}(Oc||(Oc={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.ETC1S=163]="ETC1S",e[e.UASTC=166]="UASTC"}(Ic||(Ic={})),function(e){e[e.UNSPECIFIED=0]="UNSPECIFIED",e[e.SRGB=1]="SRGB"}(Pc||(Pc={})),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"}(Dc||(Dc={})),function(e){e[e.ALPHA_STRAIGHT=0]="ALPHA_STRAIGHT",e[e.ALPHA_PREMULTIPLIED=1]="ALPHA_PREMULTIPLIED"}(Mc||(Mc={})),function(e){e[e.RGB=0]="RGB",e[e.RRR=3]="RRR",e[e.GGG=4]="GGG",e[e.AAA=15]="AAA"}(Fc||(Fc={})),function(e){e[e.RGB=0]="RGB",e[e.RGBA=3]="RGBA",e[e.RRR=4]="RRR",e[e.RRRG=5]="RRRG"}(Lc||(Lc={}));class zc{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=Rc.NONE,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:Oc.BASICFORMAT,versionNumber:2,descriptorBlockSize:40,colorModel:Ic.UNSPECIFIED,colorPrimaries:Pc.SRGB,transferFunction:Pc.SRGB,flags:Mc.ALPHA_STRAIGHT,texelBlockDimension:{x:4,y:4,z:1,w:1},bytesPlane:[],samples:[]}],this.keyValue={},this.globalData=null}}class Uc{constructor(e,t,r,n){this._dataView=new DataView(e.buffer,e.byteOffset+t,r),this._littleEndian=n,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,e}_skip(e){return this._offset+=e,this}_scan(e,t=0){const r=this._offset;let n=0;for(;this._dataView.getUint8(this._offset)!==t&&n<e;)n++,this._offset++;return n<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,n)}}function qc(e){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(e):Buffer.from(e).toString("utf8")}function Hc(e,t){const r=new Array(t.mipMapLevels);let n=t.width,i=t.height,a=0;for(let o=0;o<t.mipMapLevels;++o){const s=Wc(t,n,i,e,o),u=Gc(e,o,a,s);r[o]={compressed:!0,format:t.internalFormat,data:u,width:n,height:i,levelSize:s},n=Math.max(1,n>>1),i=Math.max(1,i>>1),a+=s}return r}function Gc(e,t,r,n){return Array.isArray(e)?e[t].levelData:new Uint8Array(e.buffer,e.byteOffset+r,n)}function Wc(e,t,r,n,i){return Array.isArray(n)?e.sizeFunction(n[i]):e.sizeFunction(t,r)}const Vc={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},Kc={131:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT,132:Vc.COMPRESSED_SRGB_S3TC_DXT1_EXT,133:Vc.COMPRESSED_RGBA_S3TC_DXT1_EXT,134:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,135:Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT,136:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT,137:Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT,138:Vc.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT,139:Vc.COMPRESSED_RED_RGTC1_EXT,140:Vc.COMPRESSED_SIGNED_RED_RGTC1_EXT,141:Vc.COMPRESSED_RED_GREEN_RGTC2_EXT,142:Vc.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT,147:Vc.COMPRESSED_RGB8_ETC2,148:Vc.COMPRESSED_SRGB8_ETC2,149:Vc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2,150:Vc.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2,151:Vc.COMPRESSED_RGBA8_ETC2_EAC,152:Vc.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC,153:Vc.COMPRESSED_R11_EAC,154:Vc.COMPRESSED_SIGNED_R11_EAC,155:Vc.COMPRESSED_RG11_EAC,156:Vc.COMPRESSED_SIGNED_RG11_EAC,157:Vc.COMPRESSED_RGBA_ASTC_4x4_KHR,158:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR,159:Vc.COMPRESSED_RGBA_ASTC_5x4_KHR,160:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR,161:Vc.COMPRESSED_RGBA_ASTC_5x5_KHR,162:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR,163:Vc.COMPRESSED_RGBA_ASTC_6x5_KHR,164:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR,165:Vc.COMPRESSED_RGBA_ASTC_6x6_KHR,166:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR,167:Vc.COMPRESSED_RGBA_ASTC_8x5_KHR,168:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR,169:Vc.COMPRESSED_RGBA_ASTC_8x6_KHR,170:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR,171:Vc.COMPRESSED_RGBA_ASTC_8x8_KHR,172:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR,173:Vc.COMPRESSED_RGBA_ASTC_10x5_KHR,174:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR,175:Vc.COMPRESSED_RGBA_ASTC_10x6_KHR,176:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR,177:Vc.COMPRESSED_RGBA_ASTC_10x8_KHR,178:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR,179:Vc.COMPRESSED_RGBA_ASTC_10x10_KHR,180:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR,181:Vc.COMPRESSED_RGBA_ASTC_12x10_KHR,182:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR,183:Vc.COMPRESSED_RGBA_ASTC_12x12_KHR,184:Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR,1000054e3:Vc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG,1000054001:Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG,1000066e3:Vc.COMPRESSED_RGBA_ASTC_4x4_KHR,1000066001:Vc.COMPRESSED_RGBA_ASTC_5x4_KHR,1000066002:Vc.COMPRESSED_RGBA_ASTC_5x5_KHR,1000066003:Vc.COMPRESSED_RGBA_ASTC_6x5_KHR,1000066004:Vc.COMPRESSED_RGBA_ASTC_6x6_KHR,1000066005:Vc.COMPRESSED_RGBA_ASTC_8x5_KHR,1000066006:Vc.COMPRESSED_RGBA_ASTC_8x6_KHR,1000066007:Vc.COMPRESSED_RGBA_ASTC_8x8_KHR,1000066008:Vc.COMPRESSED_RGBA_ASTC_10x5_KHR,1000066009:Vc.COMPRESSED_RGBA_ASTC_10x6_KHR,1000066010:Vc.COMPRESSED_RGBA_ASTC_10x8_KHR,1000066011:Vc.COMPRESSED_RGBA_ASTC_10x10_KHR,1000066012:Vc.COMPRESSED_RGBA_ASTC_12x10_KHR,1000066013:Vc.COMPRESSED_RGBA_ASTC_12x12_KHR};const Jc=[171,75,84,88,32,50,48,187,13,10,26,10];function Qc(e){const t=new Uint8Array(e);return!(t.byteLength<Jc.length||t[0]!==Jc[0]||t[1]!==Jc[1]||t[2]!==Jc[2]||t[3]!==Jc[3]||t[4]!==Jc[4]||t[5]!==Jc[5]||t[6]!==Jc[6]||t[7]!==Jc[7]||t[8]!==Jc[8]||t[9]!==Jc[9]||t[10]!==Jc[10]||t[11]!==Jc[11])}function $c(e){const t=function(e){const t=new Uint8Array(e.buffer,e.byteOffset,Bc.length);if(t[0]!==Bc[0]||t[1]!==Bc[1]||t[2]!==Bc[2]||t[3]!==Bc[3]||t[4]!==Bc[4]||t[5]!==Bc[5]||t[6]!==Bc[6]||t[7]!==Bc[7]||t[8]!==Bc[8]||t[9]!==Bc[9]||t[10]!==Bc[10]||t[11]!==Bc[11])throw new Error("Missing KTX 2.0 identifier.");const r=new zc,n=17*Uint32Array.BYTES_PER_ELEMENT,i=new Uc(e,Bc.length,n,!0);r.vkFormat=i._nextUint32(),r.typeSize=i._nextUint32(),r.pixelWidth=i._nextUint32(),r.pixelHeight=i._nextUint32(),r.pixelDepth=i._nextUint32(),r.layerCount=i._nextUint32(),r.faceCount=i._nextUint32();const a=i._nextUint32();r.supercompressionScheme=i._nextUint32();const o=i._nextUint32(),s=i._nextUint32(),u=i._nextUint32(),c=i._nextUint32(),l=i._nextUint64(),h=i._nextUint64(),p=new Uc(e,Bc.length+n,3*a*8,!0);for(let t=0;t<a;t++)r.levels.push({levelData:new Uint8Array(e.buffer,e.byteOffset+p._nextUint64(),p._nextUint64()),uncompressedByteLength:p._nextUint64()});const f=new Uc(e,o,s,!0),d={vendorId:f._skip(4)._nextUint16(),descriptorType:f._nextUint16(),versionNumber:f._nextUint16(),descriptorBlockSize:f._nextUint16(),colorModel:f._nextUint8(),colorPrimaries:f._nextUint8(),transferFunction:f._nextUint8(),flags:f._nextUint8(),texelBlockDimension:{x:f._nextUint8()+1,y:f._nextUint8()+1,z:f._nextUint8()+1,w:f._nextUint8()+1},bytesPlane:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],samples:[]},m=(d.descriptorBlockSize/4-6)/4;for(let e=0;e<m;e++)d.samples[e]={bitOffset:f._nextUint16(),bitLength:f._nextUint8(),channelID:f._nextUint8(),samplePosition:[f._nextUint8(),f._nextUint8(),f._nextUint8(),f._nextUint8()],sampleLower:f._nextUint32(),sampleUpper:f._nextUint32()};r.dataFormatDescriptor.length=0,r.dataFormatDescriptor.push(d);const g=new Uc(e,u,c,!0);for(;g._offset<c;){const e=g._nextUint32(),t=g._scan(e),n=qc(t),i=g._scan(e-t.byteLength);r.keyValue[n]=n.match(/^ktx/i)?qc(i):i,e%4&&g._skip(4-e%4)}if(h<=0)return r;const y=new Uc(e,l,h,!0),b=y._nextUint16(),v=y._nextUint16(),w=y._nextUint32(),_=y._nextUint32(),k=y._nextUint32(),x=y._nextUint32(),E=[];for(let e=0;e<a;e++)E.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});const S=l+y._offset,A=S+w,j=A+_,C=j+k,T=new Uint8Array(e.buffer,e.byteOffset+S,w),B=new Uint8Array(e.buffer,e.byteOffset+A,_),R=new Uint8Array(e.buffer,e.byteOffset+j,k),O=new Uint8Array(e.buffer,e.byteOffset+C,x);return r.globalData={endpointCount:b,selectorCount:v,imageDescs:E,endpointsData:T,selectorsData:B,tablesData:R,extendedData:O},r}(new Uint8Array(e)),r=Math.max(1,t.levels.length),n=t.pixelWidth,i=t.pixelHeight,a=(o=t.vkFormat,Kc[o]);var o;return Hc(t.levels,{mipMapLevels:r,width:n,height:i,sizeFunction:e=>e.uncompressedByteLength,internalFormat:a})}const Yc=542327876,Xc=31,Zc=0,el=1,tl=2,rl=3,nl=4,il=7,al=20,ol=21,sl=131072,ul=4,cl={DXT1:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT,DXT3:Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT,DXT5:Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT,"ATC ":Vc.COMPRESSED_RGB_ATC_WEBGL,ATCA:Vc.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL,ATCI:Vc.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL},ll={DXT1:pl,DXT3:fl,DXT5:fl,"ATC ":pl,ATCA:fl,ATCI:fl};function hl(e){const t=new Int32Array(e,0,Xc),r=t[ol];ia(Boolean(t[al]&ul),"DDS: Unsupported format, must contain a FourCC code");const n=(i=r,String.fromCharCode(255&i,i>>8&255,i>>16&255,i>>24&255));var i;const a=cl[n],o=ll[n];ia(a&&o,"DDS: Unknown pixel format "+r);let s=1;t[tl]&sl&&(s=Math.max(1,t[il]));const u=t[nl],c=t[rl],l=t[el]+4;return Hc(new Uint8Array(e,l),{mipMapLevels:s,width:u,height:c,sizeFunction:o,internalFormat:a})}function pl(e,t){return(e+3>>2)*(t+3>>2)*8}function fl(e,t){return(e+3>>2)*(t+3>>2)*16}const dl=55727696,ml=1347834371,gl=13,yl=52,bl=0,vl=2,wl=4,_l=6,kl=7,xl=11,El=12,Sl={0:[Vc.COMPRESSED_RGB_PVRTC_2BPPV1_IMG],1:[Vc.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG],2:[Vc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG],3:[Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG],6:[Vc.COMPRESSED_RGB_ETC1_WEBGL],7:[Vc.COMPRESSED_RGB_S3TC_DXT1_EXT],9:[Vc.COMPRESSED_RGBA_S3TC_DXT3_EXT],11:[Vc.COMPRESSED_RGBA_S3TC_DXT5_EXT],22:[Vc.COMPRESSED_RGB8_ETC2],23:[Vc.COMPRESSED_RGBA8_ETC2_EAC],24:[Vc.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2],25:[Vc.COMPRESSED_R11_EAC],26:[Vc.COMPRESSED_RG11_EAC],27:[Vc.COMPRESSED_RGBA_ASTC_4X4_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_4X4_KHR],28:[Vc.COMPRESSED_RGBA_ASTC_5X4_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X4_KHR],29:[Vc.COMPRESSED_RGBA_ASTC_5X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_5X5_KHR],30:[Vc.COMPRESSED_RGBA_ASTC_6X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6X5_KHR],31:[Vc.COMPRESSED_RGBA_ASTC_6X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_6X6_KHR],32:[Vc.COMPRESSED_RGBA_ASTC_8X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X5_KHR],33:[Vc.COMPRESSED_RGBA_ASTC_8X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X6_KHR],34:[Vc.COMPRESSED_RGBA_ASTC_8X8_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_8X8_KHR],35:[Vc.COMPRESSED_RGBA_ASTC_10X5_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X5_KHR],36:[Vc.COMPRESSED_RGBA_ASTC_10X6_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X6_KHR],37:[Vc.COMPRESSED_RGBA_ASTC_10X8_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X8_KHR],38:[Vc.COMPRESSED_RGBA_ASTC_10X10_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_10X10_KHR],39:[Vc.COMPRESSED_RGBA_ASTC_12X10_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12X10_KHR],40:[Vc.COMPRESSED_RGBA_ASTC_12X12_KHR,Vc.COMPRESSED_SRGB8_ALPHA8_ASTC_12X12_KHR]},Al={0:jl,1:jl,2:Cl,3:Cl,6:Tl,7:Tl,9:Bl,11:Bl,22:Tl,23:Bl,24:Tl,25:Tl,26:Bl,27:Bl,28:function(e,t){return Math.floor((e+4)/5)*Math.floor((t+3)/4)*16},29:function(e,t){return Math.floor((e+4)/5)*Math.floor((t+4)/5)*16},30:function(e,t){return Math.floor((e+5)/6)*Math.floor((t+4)/5)*16},31:function(e,t){return Math.floor((e+5)/6)*Math.floor((t+5)/6)*16},32:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+4)/5)*16},33:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+5)/6)*16},34:function(e,t){return Math.floor((e+7)/8)*Math.floor((t+7)/8)*16},35:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+4)/5)*16},36:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+5)/6)*16},37:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+7)/8)*16},38:function(e,t){return Math.floor((e+9)/10)*Math.floor((t+9)/10)*16},39:function(e,t){return Math.floor((e+11)/12)*Math.floor((t+9)/10)*16},40:function(e,t){return Math.floor((e+11)/12)*Math.floor((t+11)/12)*16}};function jl(e,t){return(e=Math.max(e,16))*(t=Math.max(t,8))/4}function Cl(e,t){return(e=Math.max(e,8))*(t=Math.max(t,8))/2}function Tl(e,t){return Math.floor((e+3)/4)*Math.floor((t+3)/4)*8}function Bl(e,t){return Math.floor((e+3)/4)*Math.floor((t+3)/4)*16}function Rl(e){if(Qc(e))return $c(e);if(function(e){return new Uint32Array(e,0,Xc)[Zc]===Yc}(e))return hl(e);if(function(e){const t=new Uint32Array(e,0,gl)[bl];return t===dl||t===ml}(e))return function(e){const t=new Uint32Array(e,0,gl),r=t[vl],n=t[wl],i=Sl[r]||[],a=i.length>1&&n?i[1]:i[0],o=Al[r],s=t[xl],u=t[kl],c=t[_l],l=yl+t[El];return Hc(new Uint8Array(e,l),{mipMapLevels:s,width:u,height:c,sizeFunction:o,internalFormat:a})}(e);throw new Error("Texture container format not recognized")}let Ol,Il;async function Pl(e){const t=e.modules||{};return t.basis?t.basis:(Ol=Ol||async function(e){let t=null,r=null;return[t,r]=await Promise.all([await Sc("basis_transcoder.js","textures",e),await Sc("basis_transcoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e(r).then(e=>{const{BasisFile:r,initializeBasis:n}=e;n(),t({BasisFile:r})})})}(t,r)}(e),await Ol)}async function Dl(e){const t=e.modules||{};return t.basisEncoder?t.basisEncoder:(Il=Il||async function(e){let t=null,r=null;return[t,r]=await Promise.all([await Sc("https://unpkg.com/@loaders.gl/textures@3.3.1/dist/libs/basis_encoder.js","textures",e),await Sc("https://unpkg.com/@loaders.gl/textures@3.3.1/dist/libs/basis_encoder.wasm","textures",e)]),t=t||globalThis.BASIS,await function(e,t){const r={};t&&(r.wasmBinary=t);return new Promise(t=>{e(r).then(e=>{const{BasisFile:r,KTX2File:n,initializeBasis:i,BasisEncoder:a}=e;i(),t({BasisFile:r,KTX2File:n,BasisEncoder:a})})})}(t,r)}(e),await Il)}const Ml=["","WEBKIT_","MOZ_"],Fl={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"};let Ll=null;function Nl(e){if(!Ll){e=e||function(){try{return document.createElement("canvas").getContext("webgl")}catch(e){return null}}()||void 0,Ll=new Set;for(const t of Ml)for(const r in Fl)if(e&&e.getExtension(`${t}${r}`)){const e=Fl[r];Ll.add(e)}}return Ll}const zl={etc1:{basisFormat:0,compressed:!0,format:Vc.COMPRESSED_RGB_ETC1_WEBGL},etc2:{basisFormat:1,compressed:!0},bc1:{basisFormat:2,compressed:!0,format:Vc.COMPRESSED_RGB_S3TC_DXT1_EXT},bc3:{basisFormat:3,compressed:!0,format:Vc.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:Vc.COMPRESSED_RGB_PVRTC_4BPPV1_IMG},"pvrtc1-4-rgba":{basisFormat:9,compressed:!0,format:Vc.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG},"astc-4x4":{basisFormat:10,compressed:!0,format:Vc.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 Ul(e,t){if("auto"===t.basis.containerFormat){if(Qc(e)){return Gl((await Dl(t)).KTX2File,e,t)}const{BasisFile:r}=await Pl(t);return ql(r,e,t)}switch(t.basis.module){case"encoder":const r=await Dl(t);switch(t.basis.containerFormat){case"ktx2":return Gl(r.KTX2File,e,t);case"basis":default:return ql(r.BasisFile,e,t)}case"transcoder":default:const{BasisFile:n}=await Pl(t);return ql(n,e,t)}}function ql(e,t,r){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("Failed to start basis transcoding");const e=n.getNumImages(),t=[];for(let i=0;i<e;i++){const e=n.getNumLevels(i),a=[];for(let t=0;t<e;t++)a.push(Hl(n,i,t,r));t.push(a)}return t}finally{n.close(),n.delete()}}function Hl(e,t,r,n){const i=e.getImageWidth(t,r),a=e.getImageHeight(t,r),o=e.getHasAlpha(),{compressed:s,format:u,basisFormat:c}=Vl(n,o),l=e.getImageTranscodedSizeInBytes(t,r,c),h=new Uint8Array(l);if(!e.transcodeImage(h,t,r,c,0,0))throw new Error("failed to start Basis transcoding");return{width:i,height:a,data:h,compressed:s,format:u,hasAlpha:o}}function Gl(e,t,r){const n=new e(new Uint8Array(t));try{if(!n.startTranscoding())throw new Error("failed to start KTX2 transcoding");const e=n.getLevels(),t=[];for(let i=0;i<e;i++){t.push(Wl(n,i,r));break}return[t]}finally{n.close(),n.delete()}}function Wl(e,t,r){const{alphaFlag:n,height:i,width:a}=e.getImageLevelInfo(t,0,0),{compressed:o,format:s,basisFormat:u}=Vl(r,n),c=e.getImageTranscodedSizeInBytes(t,0,0,u),l=new Uint8Array(c);if(!e.transcodeImage(l,t,0,0,u,0,-1,-1))throw new Error("Failed to transcode KTX2 image");return{width:a,height:i,data:l,compressed:o,levelSize:c,hasAlpha:n,format:s}}function Vl(e,t){let r=e&&e.basis&&e.basis.format;return"auto"===r&&(r=Kl()),"object"==typeof r&&(r=t?r.alpha:r.noAlpha),r=r.toLowerCase(),zl[r]}function Kl(){const e=Nl();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"}const Jl={name:"Texture Containers",id:"compressed-texture",module:"textures",version:"3.3.1",worker:!0,extensions:["ktx","ktx2","dds","pvr"],mimeTypes:["image/ktx2","image/ktx","image/vnd-ms.dds","image/x-dds","application/octet-stream"],binary:!0,options:{"compressed-texture":{libraryPath:"libs/",useBasis:!1}}},Ql={...Jl,parse:async(e,t)=>t["compressed-texture"].useBasis?(t.basis={format:{alpha:"BC3",noAlpha:"BC1"},...t.basis,containerFormat:"ktx2",module:"encoder"},(await Ul(e,t))[0]):Rl(e)},$l={name:"Basis",id:Ma?"basis":"basis-nodejs",module:"textures",version:"3.3.1",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"}}},Yl={...$l,parse:Ul};let Xl,Zl;function eh(e,t=null){return t?`${e}?token=${t}`:e}!function(e){e.UInt8="UInt8",e.UInt16="UInt16",e.UInt32="UInt32",e.UInt64="UInt64",e.Int16="Int16",e.Int32="Int32",e.Int64="Int64",e.Float32="Float32",e.Float64="Float64"}(Xl||(Xl={})),function(e){e.vertexCount="vertexCount",e.featureCount="featureCount"}(Zl||(Zl={}));var th=5121,rh=5123,nh=5125,ih=5126,ah=5130;function oh(e){switch(e){case Xl.UInt8:return Uint8Array;case Xl.UInt16:return Uint16Array;case Xl.UInt32:return Uint32Array;case Xl.Float32:return Float32Array;case Xl.UInt64:return Float64Array;default:throw new Error("parse i3s tile content: unknown type of data: "+e)}}const sh={UInt8:th,UInt16:rh,Float32:ih,UInt32:nh,UInt64:ah};function uh(e){switch(e){case Xl.UInt8:return 1;case Xl.UInt16:case Xl.Int16:return 2;case Xl.UInt32:case Xl.Int32:case Xl.Float32:return 4;case Xl.UInt64:case Xl.Int64:case Xl.Float64:return 8;default:throw new Error("parse i3s tile content: unknown size of data: "+e)}}let ch;async function lh(e,t){const{attributeName:r,attributeType:n}=t;return r?{[r]:n?hh(n,e):null}:{}}function hh(e,t){switch(e){case"String":return function(e){const t=[];try{const r=new DataView(e,0,4).getUint32(0,!0),n=new Uint32Array(e,8,r);let i=8+4*r;for(const r of n){const n=new TextDecoder("utf-8"),a=new Uint8Array(e,i,r);t.push(n.decode(a)),i+=r}}catch(e){console.error("Parse string attribute error: ",e.message)}return t}(t);case"Oid32":return ph(t);case"Float64":return function(e){return new Float64Array(e,8)}(t);case"Int16":return function(e){return new Int16Array(e,4)}(t);default:return ph(t)}}function ph(e){return new Uint32Array(e,4)}!function(e){e[e.DEFAULT=-1]="DEFAULT",e[e.LNGLAT=1]="LNGLAT",e[e.METER_OFFSETS=2]="METER_OFFSETS",e[e.LNGLAT_OFFSETS=3]="LNGLAT_OFFSETS",e[e.CARTESIAN=0]="CARTESIAN"}(ch||(ch={}));const fh={name:"I3S Attribute",id:"i3s-attribute",module:"i3s",version:"3.3.1",mimeTypes:["application/binary"],parse:async function(e,t){return e=lh(e,t)},extensions:["bin"],options:{},binary:!0};function dh(e){return e.hasOwnProperty("objectIds")?"Oid32":e.hasOwnProperty("attributeValues")?e.attributeValues.valueType:""}function mh(e,t){var r;if(null==t||null===(r=t.i3s)||void 0===r||!r.colorsByAttribute)return[255,255,255,255];const{minValue:n,maxValue:i,minColor:a,maxColor:o}=t.i3s.colorsByAttribute,s=(e-n)/(i-n),u=[255,255,255,255];for(let e=0;e<a.length;e++)u[e]=Math.round((o[e]-a[e])*s+a[e]);return u}async function gh(e,{attributeUrls:t},{attributeStorageInfo:r},n){var i;const a=r.findIndex(({name:t})=>e===t);if(-1===a)return null;const o=eh(t[a],null==n||null===(i=n.i3s)||void 0===i?void 0:i.token),s=dh(r[a]);return await Jo(o,fh,{attributeName:e,attributeType:s})}const yh=new Cs([0,0,0]);async function bh(e,t,r,n,i){const a={attributes:{},indices:null,featureIds:[],vertexCount:0,modelMatrix:new Gs,coordinateSystem:0,byteLength:0,texture:null};if(t.textureUrl){var o;const e=eh(t.textureUrl,null==n||null===(o=n.i3s)||void 0===o?void 0:o.token),r=function(e){switch(e){case"ktx-etc2":case"dds":return Ql;case"ktx2":return Yl;case"jpg":case"png":default:return Lu}}(t.textureFormat),s=await fetch(e,null==n?void 0:n.fetch),u=await s.arrayBuffer();if(null!=n&&n.i3s.decodeTextures){if(r===Lu){const e={...t.textureLoaderOptions,image:{type:"data"}};try{a.texture=await i.parse(u,e)}catch(t){a.texture=await Ko(u,r,e)}}else if(r===Ql||r===Yl){let e=await Jo(u,r,t.textureLoaderOptions);r===Yl&&(e=e[0]),a.texture={compressed:!0,mipmaps:!1,width:e[0].width,height:e[0].height,data:e}}}else a.texture=u}return a.material=function(e,t){let r;e?r={...e,pbrMetallicRoughness:e.pbrMetallicRoughness?{...e.pbrMetallicRoughness}:{baseColorFactor:[255,255,255,255]}}:(r={pbrMetallicRoughness:{}},t?r.pbrMetallicRoughness.baseColorTexture={texCoord:0}:r.pbrMetallicRoughness.baseColorFactor=[255,255,255,255]);r.alphaCutoff=r.alphaCutoff||.25,r.alphaMode&&(r.alphaMode=r.alphaMode.toUpperCase());r.emissiveFactor&&(r.emissiveFactor=kh(r.emissiveFactor));r.pbrMetallicRoughness&&r.pbrMetallicRoughness.baseColorFactor&&(r.pbrMetallicRoughness.baseColorFactor=kh(r.pbrMetallicRoughness.baseColorFactor));t&&function(e,t){const r={source:{image:t}};e.pbrMetallicRoughness&&e.pbrMetallicRoughness.baseColorTexture?e.pbrMetallicRoughness.baseColorTexture={...e.pbrMetallicRoughness.baseColorTexture,texture:r}:e.emissiveTexture?e.emissiveTexture={...e.emissiveTexture,texture:r}:e.pbrMetallicRoughness&&e.pbrMetallicRoughness.metallicRoughnessTexture?e.pbrMetallicRoughness.metallicRoughnessTexture={...e.pbrMetallicRoughness.metallicRoughnessTexture,texture:r}:e.normalTexture?e.normalTexture={...e.normalTexture,texture:r}:e.occlusionTexture&&(e.occlusionTexture={...e.occlusionTexture,texture:r})}(r,t);return r}(t.materialDefinition,a.texture),a.material&&(a.texture=null),await async function(e,t,r,n,i){var a;const o=e.byteLength;let s,u,c,l=0,h=0;if(r.isDracoGeometry){var p;const t=await Ko(e,Tc,{draco:{attributeNameEntry:"i3s-attribute-type"}});u=t.header.vertexCount,c=null===(p=t.indices)||void 0===p?void 0:p.value;const{POSITION:r,NORMAL:n,COLOR_0:i,TEXCOORD_0:a,"feature-index":o,"uv-region":l}=t.attributes;s={position:r,normal:n,color:i,uv0:a,uvRegion:l,id:o},function(e,t){for(const r in t.loaderData.attributes){const n=t.loaderData.attributes[r];switch(n.name){case"POSITION":e.position.metadata=n.metadata;break;case"feature-index":e.id.metadata=n.metadata}}}(s,t);const h=function(e){var t,r;return null==e||null===(t=e.metadata)||void 0===t||null===(r=t["i3s-feature-ids"])||void 0===r?void 0:r.intArray}(o);h&&function(e,t){const r=e.id.value,n=new Float32Array(r.length);for(let e=0;e<r.length;e++)n[e]=t[r[e]];e.id.value=n}(s,h)}else{const{vertexAttributes:t,ordering:r,featureAttributes:i,featureAttributeOrder:a}=n.store.defaultGeometrySchema,o=function(e,t){let r=0,n=0,i=0;for(const{property:a,type:o}of t.store.defaultGeometrySchema.header){const t=oh(o);switch(a){case Zl.vertexCount:n=new t(e,0,4)[0],r+=uh(o);break;case Zl.featureCount:i=new t(e,4,4)[0],r+=uh(o)}}return{vertexCount:n,featureCount:i,byteOffset:r}}(e,n);l=o.byteOffset,u=o.vertexCount,h=o.featureCount;const{attributes:c,byteOffset:p}=wh(e,l,t,u,r),{attributes:f}=wh(e,p,i,h,a);!function(e){const{id:t,faceRange:r}=e;if(!t||!r)return;const n=t.value,i=r.value,a=i[i.length-1]+1,o=new Uint32Array(3*a);let s=0,u=0;for(let e=1;e<i.length;e+=2){const t=Number(n[s]),r=i[e],a=i[e-1],c=u+3*(r-a+1);o.fill(t,u,c),s++,u=c}e.id.value=o}(f),s=function(e,t){return{...e,...t}}(c,f)}if(null!=i&&null!==(a=i.i3s)&&void 0!==a&&a.coordinateSystem&&i.i3s.coordinateSystem!==ch.METER_OFFSETS)t.modelMatrix=function(e){var t,r;const n=e.metadata,i=(null==n||null===(t=n["i3s-scale_x"])||void 0===t?void 0:t.double)||1,a=(null==n||null===(r=n["i3s-scale_y"])||void 0===r?void 0:r.double)||1,o=new Gs;return o[0]=i,o[5]=a,o}(s.position),t.coordinateSystem=ch.LNGLAT_OFFSETS;else{const e=function(e,t){const r=t.mbs,n=e.value,i=e.metadata,a=new Gs,o=new Cs(r[0],r[1],r[2]),s=new Cs;return vu.WGS84.cartographicToCartesian(o,s),vu.WGS84.eastNorthUpToFixedFrame(s,a),e.value=function(e,t={},r){const n=new Float64Array(e.length),i=t["i3s-scale_x"]&&t["i3s-scale_x"].double||1,a=t["i3s-scale_y"]&&t["i3s-scale_y"].double||1;for(let t=0;t<n.length;t+=3)n[t]=e[t]*i+r.x,n[t+1]=e[t+1]*a+r.y,n[t+2]=e[t+2]+r.z;for(let e=0;e<n.length;e+=3)vu.WGS84.cartographicToCartesian(n.subarray(e,e+3),yh),n[e]=yh.x,n[e+1]=yh.y,n[e+2]=yh.z;return n}(n,i,o),a}(s.position,r);t.modelMatrix=e.invert(),t.coordinateSystem=ch.METER_OFFSETS}s.color=await async function(e,t,r,n,i){var a;if(null==i||null===(a=i.i3s)||void 0===a||!a.colorsByAttribute)return e;const o=n.fields.find(({name:e})=>{var t,r;return e===(null==i||null===(t=i.i3s)||void 0===t||null===(r=t.colorsByAttribute)||void 0===r?void 0:r.attributeName)});if(!o||!["esriFieldTypeDouble","esriFieldTypeInteger","esriFieldTypeSmallInteger"].includes(o.type))return e;const s=await gh(o.name,r,n,i);if(!s)return e;const u=n.fields.find(({type:e})=>"esriFieldTypeOID"===e);if(!u)return e;const c=await gh(u.name,r,n,i);if(!c)return e;const l={};for(let e=0;e<c[u.name].length;e++)l[c[u.name][e]]=mh(s[o.name][e],i);for(let r=0;r<t.value.length;r++){const n=l[t.value[r]];n&&e.value.set(n,4*r)}return e}(s.color,s.id,r,n,i),t.attributes={positions:s.position,normals:s.normal,colors:vh(s.color),texCoords:s.uv0,uvRegions:vh(s.uvRegion||s.region)},t.indices=c||null,s.id&&s.id.value&&(t.featureIds=s.id.value);for(const e in t.attributes)t.attributes[e]||delete t.attributes[e];return t.vertexCount=u,t.byteLength=o,t}(e,a,t,r,n)}function vh(e){return e?(e.normalized=!0,e):e}function wh(e,t,r,n,i){const a={};for(const o of i)if(r[o]){const{valueType:i,valuesPerElement:s}=r[o];if(t+n*s*uh(i)<=e.byteLength){const r=e.slice(t);let u;if("UInt64"===i)u=_h(r,n*s,uh(i));else{u=new(oh(i))(r,0,n*s)}switch(a[o]={value:u,type:sh[i],size:s},o){case"color":a.color.normalized=!0}t+=n*s*uh(i)}else if("uv0"!==o)break}return{attributes:a,byteOffset:t}}function _h(e,t,r){const n=[],i=new DataView(e);let a=0;for(let e=0;e<t;e++){const e=i.getUint32(a,!0)+2**32*i.getUint32(a+4,!0);n.push(e),a+=r}return new Uint32Array(n)}function kh(e){const t=[...e];for(let r=0;r<e.length;r++)t[r]=e[r]/255;return t}const xh={name:"I3S Content (Indexed Scene Layers)",id:Ma?"i3s-content":"i3s-content-nodejs",module:"i3s",worker:!0,version:"3.3.1",mimeTypes:["application/octet-stream"],parse:async function(e,t,r){const{tile:n,_tileOptions:i,tileset:a,_tilesetOptions:o}=(null==t?void 0:t.i3s)||{},s=i||n,u=o||a;if(!s||!u)return null;return await bh(e,s,u,t,r)},extensions:["bin"],options:{"i3s-content":{}}};const Eh=-1,Sh=0,Ah=1;new Cs,new Cs;const jh=new Cs,Ch=new Cs;class Th{constructor(e=[0,0,0],t=0){Object(Js.a)(this,"center",void 0),Object(Js.a)(this,"radius",void 0),this.radius=-0,this.center=new Cs,this.fromCenterRadius(e,t)}fromCenterRadius(e,t){return this.center.from(e),this.radius=t,this}fromCornerPoints(e,t){return t=jh.from(t),this.center=(new Cs).from(e).add(t).scale(.5),this.radius=this.center.distance(t),this}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.radius===e.radius}clone(){return new Th(this.center,this.radius)}union(e){const t=this.center,r=this.radius,n=e.center,i=e.radius,a=jh.copy(n).subtract(t),o=a.magnitude();if(r>=o+i)return this.clone();if(i>=o+r)return e.clone();const s=.5*(r+o+i);return Ch.copy(a).scale((-r+s)/o).add(t),this.center.copy(Ch),this.radius=s,this}expand(e){const t=jh.from(e).subtract(this.center).magnitude();return t>this.radius&&(this.radius=t),this}transform(e){this.center.transform(e);const t=Rs(jh,e);return this.radius=Math.max(t[0],Math.max(t[1],t[2]))*this.radius,this}distanceSquaredTo(e){const t=this.distanceTo(e);return t*t}distanceTo(e){const t=jh.from(e).subtract(this.center);return Math.max(0,t.len()-this.radius)}intersectPlane(e){const t=this.center,r=this.radius,n=e.normal.dot(t)+e.distance;return n<-r?Eh:n<r?Sh:Ah}}function Bh(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=t[4],u=t[5],c=t[6],l=t[7],h=t[8],p=r[0],f=r[1],d=r[2],m=r[3],g=r[4],y=r[5],b=r[6],v=r[7],w=r[8];return e[0]=p*n+f*o+d*c,e[1]=p*i+f*s+d*l,e[2]=p*a+f*u+d*h,e[3]=m*n+g*o+y*c,e[4]=m*i+g*s+y*l,e[5]=m*a+g*u+y*h,e[6]=b*n+v*o+w*c,e[7]=b*i+v*s+w*l,e[8]=b*a+v*u+w*h,e}function Rh(e,t,r){var n=r[0],i=r[1];return e[0]=n*t[0],e[1]=n*t[1],e[2]=n*t[2],e[3]=i*t[3],e[4]=i*t[4],e[5]=i*t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e}var Oh;!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"}(Oh||(Oh={}));const Ih=Object.freeze([1,0,0,0,1,0,0,0,1]);class Ph extends Ts{static get IDENTITY(){return function(){Mh||(Mh=new Ph,Object.freeze(Mh));return Mh}()}static get ZERO(){return function(){Dh||(Dh=new Ph([0,0,0,0,0,0,0,0,0]),Object.freeze(Dh));return Dh}()}get ELEMENTS(){return 9}get RANK(){return 3}get INDICES(){return Oh}constructor(e,...t){super(-0,-0,-0,-0,-0,-0,-0,-0,-0),1===arguments.length&&Array.isArray(e)?this.copy(e):t.length>0?this.copy([e,...t]):this.identity()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this[4]=e[4],this[5]=e[5],this[6]=e[6],this[7]=e[7],this[8]=e[8],this.check()}identity(){return this.copy(Ih)}fromObject(e){return this.check()}fromQuaternion(e){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r+r,s=n+n,u=i+i,c=r*o,l=n*o,h=n*s,p=i*o,f=i*s,d=i*u,m=a*o,g=a*s,y=a*u;e[0]=1-h-d,e[3]=l-y,e[6]=p+g,e[1]=l+y,e[4]=1-c-d,e[7]=f-m,e[2]=p-g,e[5]=f+m,e[8]=1-c-h}(this,e),this.check()}set(e,t,r,n,i,a,o,s,u){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this[4]=i,this[5]=a,this[6]=o,this[7]=s,this[8]=u,this.check()}setRowMajor(e,t,r,n,i,a,o,s,u){return this[0]=e,this[1]=n,this[2]=o,this[3]=t,this[4]=i,this[5]=s,this[6]=r,this[7]=a,this[8]=u,this.check()}determinant(){return t=(e=this)[0],r=e[1],n=e[2],i=e[3],a=e[4],o=e[5],s=e[6],u=e[7],c=e[8],t*(c*a-o*u)+r*(-c*i+o*s)+n*(u*i-a*s);var e,t,r,n,i,a,o,s,u,c}transpose(){return function(e,t){if(e===t){var r=t[1],n=t[2],i=t[5];e[1]=t[3],e[2]=t[6],e[3]=r,e[5]=t[7],e[6]=n,e[7]=i}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]}(this,this),this.check()}invert(){var e,t,r,n,i,a,o,s,u,c,l,h,p,f,d;return e=this,r=(t=this)[0],n=t[1],i=t[2],a=t[3],o=t[4],s=t[5],u=t[6],c=t[7],l=t[8],(d=r*(h=l*o-s*c)+n*(p=-l*a+s*u)+i*(f=c*a-o*u))&&(d=1/d,e[0]=h*d,e[1]=(-l*n+i*c)*d,e[2]=(s*n-i*o)*d,e[3]=p*d,e[4]=(l*r-i*u)*d,e[5]=(-s*r+i*a)*d,e[6]=f*d,e[7]=(-c*r+n*u)*d,e[8]=(o*r-n*a)*d),this.check()}multiplyLeft(e){return Bh(this,e,this),this.check()}multiplyRight(e){return Bh(this,this,e),this.check()}rotate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d;return t=this,n=e,i=(r=this)[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=Math.sin(n),d=Math.cos(n),t[0]=d*i+f*s,t[1]=d*a+f*u,t[2]=d*o+f*c,t[3]=d*s-f*i,t[4]=d*u-f*a,t[5]=d*c-f*o,t[6]=l,t[7]=h,t[8]=p,this.check()}scale(e){return Array.isArray(e)?Rh(this,this,e):Rh(this,this,[e,e]),this.check()}translate(e){var t,r,n,i,a,o,s,u,c,l,h,p,f,d;return t=this,n=e,i=(r=this)[0],a=r[1],o=r[2],s=r[3],u=r[4],c=r[5],l=r[6],h=r[7],p=r[8],f=n[0],d=n[1],t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=u,t[5]=c,t[6]=f*i+d*s+l,t[7]=f*a+d*u+h,t[8]=f*o+d*c+p,this.check()}transform(e,t){let r;switch(e.length){case 2:r=Ps(t||[-0,-0],e,this);break;case 3:r=vs(t||[-0,-0,-0],e,this);break;case 4:r=Ss(t||[-0,-0,-0,-0],e,this);break;default:throw new Error("Illegal vector")}return cs(r,e.length),r}transformVector(e,t){return this.transform(e,t)}transformVector2(e,t){return this.transform(e,t)}transformVector3(e,t){return this.transform(e,t)}}let Dh,Mh,Fh;class Lh extends ls{static get ZERO(){return Fh||(Fh=new Lh(0,0,0,0),Object.freeze(Fh)),Fh}constructor(e=0,t=0,r=0,n=0){super(-0,-0,-0,-0),es(e)&&1===arguments.length?this.copy(e):(Xo.debug&&(us(e),us(t),us(r),us(n)),this[0]=e,this[1]=t,this[2]=r,this[3]=n)}set(e,t,r,n){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y),us(e.z),us(e.w)),this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this}toObject(e){return e.x=this[0],e.y=this[1],e.z=this[2],e.w=this[3],e}get ELEMENTS(){return 4}get z(){return this[2]}set z(e){this[2]=us(e)}get w(){return this[3]}set w(e){this[3]=us(e)}transform(e){return bs(this,this,e),this.check()}transformByMatrix3(e){return Ss(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){const n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i,e[2]=t[2],e[3]=t[3]}(this,this,e),this.check()}transformByQuaternion(e){return ws(this,this,e),this.check()}applyMatrix4(e){return e.transform(this,this),this}}function Nh(){var e=new ps(4);return ps!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function zh(e,t,r){r*=.5;var 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 Uh(e,t,r){var n=t[0],i=t[1],a=t[2],o=t[3],s=r[0],u=r[1],c=r[2],l=r[3];return e[0]=n*l+o*s+i*c-a*u,e[1]=i*l+o*u+a*s-n*c,e[2]=a*l+o*c+n*u-i*s,e[3]=o*l-n*s-i*u-a*c,e}function qh(e,t,r,n){var i,a,o,s,u,c=t[0],l=t[1],h=t[2],p=t[3],f=r[0],d=r[1],m=r[2],g=r[3];return(a=c*f+l*d+h*m+p*g)<0&&(a=-a,f=-f,d=-d,m=-m,g=-g),1-a>hs?(i=Math.acos(a),o=Math.sin(i),s=Math.sin((1-n)*i)/o,u=Math.sin(n*i)/o):(s=1-n,u=n),e[0]=s*c+u*f,e[1]=s*l+u*d,e[2]=s*h+u*m,e[3]=s*p+u*g,e}function Hh(e,t){var r,n=t[0]+t[4]+t[8];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{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var a=(i+1)%3,o=(i+2)%3;r=Math.sqrt(t[3*i+i]-t[3*a+a]-t[3*o+o]+1),e[i]=.5*r,r=.5/r,e[3]=(t[3*a+o]-t[3*o+a])*r,e[a]=(t[3*a+i]+t[3*i+a])*r,e[o]=(t[3*o+i]+t[3*i+o])*r}return e}var Gh,Wh,Vh,Kh,Jh,Qh,$h,Yh=function(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},Xh=function(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},Zh=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},ep=function(e,t,r,n){var i=t[0],a=t[1],o=t[2],s=t[3];return e[0]=i+n*(r[0]-i),e[1]=a+n*(r[1]-a),e[2]=o+n*(r[2]-o),e[3]=s+n*(r[3]-s),e},tp=Ms,rp=Fs,np=function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=r*o,e[1]=n*o,e[2]=i*o,e[3]=a*o,e},ip=(Gh=fs(),Wh=ms(1,0,0),Vh=ms(0,1,0),function(e,t,r){var n=gs(t,r);return n<-.999999?(ys(Gh,Wh,t),ks(Gh)<1e-6&&ys(Gh,Vh,t),function(e,t){var r=t[0],n=t[1],i=t[2],a=r*r+n*n+i*i;a>0&&(a=1/Math.sqrt(a)),e[0]=t[0]*a,e[1]=t[1]*a,e[2]=t[2]*a}(Gh,Gh),zh(e,Gh,Math.PI),e):n>.999999?(e[0]=0,e[1]=0,e[2]=0,e[3]=1,e):(ys(Gh,t,r),e[0]=Gh[0],e[1]=Gh[1],e[2]=Gh[2],e[3]=1+n,np(e,e))});Kh=Nh(),Jh=Nh(),Qh=new ps(9),ps!=Float32Array&&(Qh[1]=0,Qh[2]=0,Qh[3]=0,Qh[5]=0,Qh[6]=0,Qh[7]=0),Qh[0]=1,Qh[4]=1,Qh[8]=1,$h=Qh;const ap=[0,0,0,1];class op extends ss{constructor(e=0,t=0,r=0,n=1){super(-0,-0,-0,-0),Array.isArray(e)&&1===arguments.length?this.copy(e):this.set(e,t,r,n)}copy(e){return this[0]=e[0],this[1]=e[1],this[2]=e[2],this[3]=e[3],this.check()}set(e,t,r,n){return this[0]=e,this[1]=t,this[2]=r,this[3]=n,this.check()}fromObject(e){return this[0]=e.x,this[1]=e.y,this[2]=e.z,this[3]=e.w,this.check()}fromMatrix3(e){return Hh(this,e),this.check()}fromAxisRotation(e,t){return zh(this,e,t),this.check()}identity(){return function(e){e[0]=0,e[1]=0,e[2]=0,e[3]=1}(this),this.check()}setAxisAngle(e,t){return this.fromAxisRotation(e,t)}get ELEMENTS(){return 4}get x(){return this[0]}set x(e){this[0]=us(e)}get y(){return this[1]}set y(e){this[1]=us(e)}get z(){return this[2]}set z(e){this[2]=us(e)}get w(){return this[3]}set w(e){this[3]=us(e)}len(){return tp(this)}lengthSquared(){return rp(this)}dot(e){return Zh(this,e)}rotationTo(e,t){return ip(this,e,t),this.check()}add(e){return Yh(this,this,e),this.check()}calculateW(){return function(e,t){var r=t[0],n=t[1],i=t[2];e[0]=r,e[1]=n,e[2]=i,e[3]=Math.sqrt(Math.abs(1-r*r-n*n-i*i))}(this,this),this.check()}conjugate(){return function(e,t){e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3]}(this,this),this.check()}invert(){return function(e,t){var r=t[0],n=t[1],i=t[2],a=t[3],o=r*r+n*n+i*i+a*a,s=o?1/o:0;e[0]=-r*s,e[1]=-n*s,e[2]=-i*s,e[3]=a*s}(this,this),this.check()}lerp(e,t,r){return void 0===r?this.lerp(this,e,t):(ep(this,e,t,r),this.check())}multiplyRight(e){return Uh(this,this,e),this.check()}multiplyLeft(e){return Uh(this,e,this),this.check()}normalize(){const e=this.len(),t=e>0?1/e:0;return this[0]=this[0]*t,this[1]=this[1]*t,this[2]=this[2]*t,this[3]=this[3]*t,0===e&&(this[3]=1),this.check()}rotateX(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u+o*s,e[1]=i*u+a*s,e[2]=a*u-i*s,e[3]=o*u-n*s}(this,this,e),this.check()}rotateY(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u-a*s,e[1]=i*u+o*s,e[2]=a*u+n*s,e[3]=o*u-i*s}(this,this,e),this.check()}rotateZ(e){return function(e,t,r){r*=.5;var n=t[0],i=t[1],a=t[2],o=t[3],s=Math.sin(r),u=Math.cos(r);e[0]=n*u+i*s,e[1]=i*u-n*s,e[2]=a*u+o*s,e[3]=o*u-a*s}(this,this,e),this.check()}scale(e){return Xh(this,this,e),this.check()}slerp(e,t,r){let n,i,a;switch(arguments.length){case 1:({start:n=ap,target:i,ratio:a}=e);break;case 2:n=this,i=e,a=t;break;default:n=e,i=t,a=r}return qh(this,n,i,a),this.check()}transformVector4(e,t=new Lh){return function(e,t,r){var n=t[0],i=t[1],a=t[2],o=r[0],s=r[1],u=r[2],c=r[3],l=c*n+s*a-u*i,h=c*i+u*n-o*a,p=c*a+o*i-s*n,f=-o*n-s*i-u*a;e[0]=l*c+f*-o+h*-u-p*-s,e[1]=h*c+f*-s+p*-o-l*-u,e[2]=p*c+f*-u+l*-s-h*-o,e[3]=t[3]}(t,e,this),cs(t,4)}lengthSq(){return this.lengthSquared()}setFromAxisAngle(e,t){return this.setAxisAngle(e,t)}premultiply(e){return this.multiplyLeft(e)}multiply(e){return this.multiplyRight(e)}}const sp=new Cs,up=new Cs,cp=new Cs,lp=new Cs,hp=new Cs,pp=new Cs,fp=new Cs,dp=0,mp=1,gp=2,yp=3,bp=4,vp=5,wp=6,_p=7,kp=8;class xp{constructor(e=[0,0,0],t=[0,0,0,0,0,0,0,0,0]){Object(Js.a)(this,"center",void 0),Object(Js.a)(this,"halfAxes",void 0),this.center=(new Cs).from(e),this.halfAxes=new Ph(t)}get halfSize(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2);return[new Cs(e).len(),new Cs(t).len(),new Cs(r).len()]}get quaternion(){const e=this.halfAxes.getColumn(0),t=this.halfAxes.getColumn(1),r=this.halfAxes.getColumn(2),n=new Cs(e).normalize(),i=new Cs(t).normalize(),a=new Cs(r).normalize();return(new op).fromMatrix3(new Ph([...n,...i,...a]))}fromCenterHalfSizeQuaternion(e,t,r){const n=new op(r),i=(new Ph).fromQuaternion(n);return i[0]=i[0]*t[0],i[1]=i[1]*t[0],i[2]=i[2]*t[0],i[3]=i[3]*t[1],i[4]=i[4]*t[1],i[5]=i[5]*t[1],i[6]=i[6]*t[2],i[7]=i[7]*t[2],i[8]=i[8]*t[2],this.center=(new Cs).from(e),this.halfAxes=i,this}clone(){return new xp(this.center,this.halfAxes)}equals(e){return this===e||Boolean(e)&&this.center.equals(e.center)&&this.halfAxes.equals(e.halfAxes)}getBoundingSphere(e=new Th){const t=this.halfAxes,r=t.getColumn(0,cp),n=t.getColumn(1,lp),i=t.getColumn(2,hp),a=sp.copy(r).add(n).add(i);return e.center.copy(this.center),e.radius=a.magnitude(),e}intersectPlane(e){const t=this.center,r=e.normal,n=this.halfAxes,i=r.x,a=r.y,o=r.z,s=Math.abs(i*n[dp]+a*n[mp]+o*n[gp])+Math.abs(i*n[yp]+a*n[bp]+o*n[vp])+Math.abs(i*n[wp]+a*n[_p]+o*n[kp]),u=r.dot(t)+e.distance;return u<=-s?Eh:u>=s?Ah:Sh}distanceTo(e){return Math.sqrt(this.distanceSquaredTo(e))}distanceSquaredTo(e){const t=up.from(e).subtract(this.center),r=this.halfAxes,n=r.getColumn(0,cp),i=r.getColumn(1,lp),a=r.getColumn(2,hp),o=n.magnitude(),s=i.magnitude(),u=a.magnitude();n.normalize(),i.normalize(),a.normalize();let c,l=0;return c=Math.abs(t.dot(n))-o,c>0&&(l+=c*c),c=Math.abs(t.dot(i))-s,c>0&&(l+=c*c),c=Math.abs(t.dot(a))-u,c>0&&(l+=c*c),l}computePlaneDistances(e,t,r=[-0,-0]){let n=Number.POSITIVE_INFINITY,i=Number.NEGATIVE_INFINITY;const a=this.center,o=this.halfAxes,s=o.getColumn(0,cp),u=o.getColumn(1,lp),c=o.getColumn(2,hp),l=pp.copy(s).add(u).add(c).add(a),h=fp.copy(l).subtract(e);let p=t.dot(h);return n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).add(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).subtract(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),l.copy(a).add(s).subtract(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).add(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).add(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).subtract(u).add(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),a.copy(l).subtract(s).subtract(u).subtract(c),h.copy(l).subtract(e),p=t.dot(h),n=Math.min(p,n),i=Math.max(p,i),r[0]=n,r[1]=i,r}transform(e){this.center.transformAsPoint(e);const t=this.halfAxes.getColumn(0,cp);t.transformAsPoint(e);const r=this.halfAxes.getColumn(1,lp);r.transformAsPoint(e);const n=this.halfAxes.getColumn(2,hp);return n.transformAsPoint(e),this.halfAxes=new Ph([...t,...r,...n]),this}getTransform(){throw new Error("not implemented")}}const Ep=new Cs,Sp=new Cs;class Ap{constructor(e=[0,0,1],t=0){Object(Js.a)(this,"normal",void 0),Object(Js.a)(this,"distance",void 0),this.normal=new Cs,this.distance=-0,this.fromNormalDistance(e,t)}fromNormalDistance(e,t){return Qo(Number.isFinite(t)),this.normal.from(e).normalize(),this.distance=t,this}fromPointNormal(e,t){e=Ep.from(e),this.normal.from(t).normalize();const r=-this.normal.dot(e);return this.distance=r,this}fromCoefficients(e,t,r,n){return this.normal.set(e,t,r),Qo(as(this.normal.len(),1)),this.distance=n,this}clone(){return new Ap(this.normal,this.distance)}equals(e){return as(this.distance,e.distance)&&as(this.normal,e.normal)}getPointDistance(e){return this.normal.dot(e)+this.distance}transform(e){const t=Sp.copy(this.normal).transformAsVector(e).normalize(),r=this.normal.scale(-this.distance).transform(e);return this.fromPointNormal(r,t)}projectPointOntoPlane(e,t=[0,0,0]){e=Ep.from(e);const r=this.getPointDistance(e),n=Sp.copy(this.normal).scale(r);return e.subtract(n).to(t)}}const jp=[new Cs([1,0,0]),new Cs([0,1,0]),new Cs([0,0,1])],Cp=new Cs,Tp=new Cs;new Ap(new Cs(1,0,0),0);class Bp{constructor(e=[]){Object(Js.a)(this,"planes",void 0),this.planes=e}fromBoundingSphere(e){this.planes.length=2*jp.length;const t=e.center,r=e.radius;let n=0;for(const e of jp){let i=this.planes[n],a=this.planes[n+1];i||(i=this.planes[n]=new Ap),a||(a=this.planes[n+1]=new Ap);const o=Cp.copy(e).scale(-r).add(t);e.dot(o);i.fromPointNormal(o,e);const s=Cp.copy(e).scale(r).add(t),u=Tp.copy(e).negate();u.dot(s);a.fromPointNormal(s,u),n+=2}return this}computeVisibility(e){let t=Ah;for(const r of this.planes){switch(e.intersectPlane(r)){case Eh:return Eh;case Sh:t=Sh}}return t}computeVisibilityWithPlaneMask(e,t){if(Qo(Number.isFinite(t),"parentPlaneMask is required."),t===Bp.MASK_OUTSIDE||t===Bp.MASK_INSIDE)return t;let r=Bp.MASK_INSIDE;const n=this.planes;for(let i=0;i<this.planes.length;++i){const a=i<31?1<<i:0;if(i<31&&0==(t&a))continue;const o=n[i],s=e.intersectPlane(o);if(s===Eh)return Bp.MASK_OUTSIDE;s===Sh&&(r|=a)}return r}}Object(Js.a)(Bp,"MASK_OUTSIDE",4294967295),Object(Js.a)(Bp,"MASK_INSIDE",0),Object(Js.a)(Bp,"MASK_INDETERMINATE",2147483647);new Cs,new Cs,new Cs,new Cs,new Cs;class Rp extends ls{constructor(e=0,t=0){super(2),es(e)&&1===arguments.length?this.copy(e):(Xo.debug&&(us(e),us(t)),this[0]=e,this[1]=t)}set(e,t){return this[0]=e,this[1]=t,this.check()}copy(e){return this[0]=e[0],this[1]=e[1],this.check()}fromObject(e){return Xo.debug&&(us(e.x),us(e.y)),this[0]=e.x,this[1]=e.y,this.check()}toObject(e){return e.x=this[0],e.y=this[1],e}get ELEMENTS(){return 2}horizontalAngle(){return Math.atan2(this.y,this.x)}verticalAngle(){return Math.atan2(this.x,this.y)}transform(e){return this.transformAsPoint(e)}transformAsPoint(e){return Ds(this,this,e),this.check()}transformAsVector(e){return xs(this,this,e),this.check()}transformByMatrix3(e){return Ps(this,this,e),this.check()}transformByMatrix2x3(e){return function(e,t,r){var n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i+r[4],e[1]=r[1]*n+r[3]*i+r[5]}(this,this,e),this.check()}transformByMatrix2(e){return function(e,t,r){var n=t[0],i=t[1];e[0]=r[0]*n+r[2]*i,e[1]=r[1]*n+r[3]*i}(this,this,e),this.check()}}const Op=new Cs,Ip=new Cs,Pp=new Cs,Dp=new Cs,Mp=new Cs,Fp=new Cs,Lp=new Cs,Np=new Cs,zp=new Cs,Up=new Cs,qp=new Cs,Hp=new Cs;Math.PI;const Gp=new Ph,Wp=new Ph,Vp=new Ph,Kp=new Ph,Jp=new Ph;function Qp(e,t={}){const r=Xs;let n=0,i=0;const a=Wp,o=Vp;a.identity(),o.copy(e);const s=r*function(e){let t=0;for(let r=0;r<9;++r){const n=e[r];t+=n*n}return Math.sqrt(t)}(o);for(;i<10&&Xp(o)>s;)Zp(o,Kp),Jp.copy(Kp).transpose(),o.multiplyRight(Kp),o.multiplyLeft(Jp),a.multiplyRight(Kp),++n>2&&(++i,n=0);return t.unitary=a.toTarget(t.unitary),t.diagonal=o.toTarget(t.diagonal),t}const $p=[1,0,0],Yp=[2,2,1];function Xp(e){let t=0;for(let r=0;r<3;++r){const n=e[Gp.getElementIndex(Yp[r],$p[r])];t+=2*n*n}return Math.sqrt(t)}function Zp(e,t){const r=Ys;let n=0,i=1;for(let t=0;t<3;++t){const r=Math.abs(e[Gp.getElementIndex(Yp[t],$p[t])]);r>n&&(i=t,n=r)}const a=$p[i],o=Yp[i];let s=1,u=0;if(Math.abs(e[Gp.getElementIndex(o,a)])>r){const t=(e[Gp.getElementIndex(o,o)]-e[Gp.getElementIndex(a,a)])/2/e[Gp.getElementIndex(o,a)];let r;r=t<0?-1/(-t+Math.sqrt(1+t*t)):1/(t+Math.sqrt(1+t*t)),s=1/Math.sqrt(1+r*r),u=r*s}return Ph.IDENTITY.to(t),t[Gp.getElementIndex(a,a)]=t[Gp.getElementIndex(o,o)]=s,t[Gp.getElementIndex(o,a)]=u,t[Gp.getElementIndex(a,o)]=-u,t}const ef=new Cs,tf=new Cs,rf=new Cs,nf=new Cs,af=new Cs,of=new Ph,sf={diagonal:new Ph,unitary:new Ph};const uf=0,cf=1,lf=3,hf=4,pf=5,ff=1,df=2,mf="empty",gf="scenegraph",yf="pointcloud",bf="mesh",vf="I3S",wf="TILES3D",_f="geometricError",kf=1;async function xf(e){return JSON.parse((new TextDecoder).decode(e))}const Ef={name:"I3S Node Page",id:"i3s-node-page",module:"i3s",version:"3.3.1",mimeTypes:["application/json"],parse:async function(e){return e=xf(e)},extensions:["json"],options:{}};function Sf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Af{constructor(e,t){var r,n;Sf(this,"tileset",void 0),Sf(this,"nodePages",[]),Sf(this,"pendingNodePages",[]),Sf(this,"nodesPerPage",void 0),Sf(this,"options",void 0),Sf(this,"lodSelectionMetricType",void 0),Sf(this,"textureDefinitionsSelectedFormats",[]),Sf(this,"nodesInNodePages",void 0),Sf(this,"textureLoaderOptions",{}),this.tileset={...e},this.nodesPerPage=(null===(r=e.nodePages)||void 0===r?void 0:r.nodesPerPage)||64,this.lodSelectionMetricType=null===(n=e.nodePages)||void 0===n?void 0:n.lodSelectionMetricType,this.options=t,this.nodesInNodePages=0,this.initSelectedFormatsForTextureDefinitions(e)}async getNodeById(e){const t=Math.floor(e/this.nodesPerPage);if(!this.nodePages[t]&&!this.pendingNodePages[t]){var r;const e=eh(`${this.tileset.url}/nodepages/${t}`,null===(r=this.options.i3s)||void 0===r?void 0:r.token);this.pendingNodePages[t]={status:"Pending",promise:Jo(e,Ef,this.options)},this.nodePages[t]=await this.pendingNodePages[t].promise,this.nodesInNodePages+=this.nodePages[t].nodes.length,this.pendingNodePages[t].status="Done"}"Pending"===this.pendingNodePages[t].status&&(this.nodePages[t]=await this.pendingNodePages[t].promise);const n=e%this.nodesPerPage;return this.nodePages[t].nodes[n]}async formTileFromNodePages(e){const t=await this.getNodeById(e),r=[],n=[];for(const e of t.children||[])n.push(this.getNodeById(e));const i=await Promise.all(n);for(const e of i)r.push({id:e.index.toString(),obb:e.obb});let a,o,s,u="jpg",c=[],l=!1;if(t&&t.mesh){const{url:e,isDracoGeometry:r}=t.mesh.geometry&&this.getContentUrl(t.mesh.geometry)||{isDracoGeometry:!1};a=e,l=r;const{textureData:n,materialDefinition:i}=this.getInformationFromMaterial(t.mesh.material);s=i,u=n.format||u,n.name&&(o=`${this.tileset.url}/nodes/${t.mesh.material.resource}/textures/${n.name}`),this.tileset.attributeStorageInfo&&(c=function(e,t){const r=[],{attributeStorageInfo:n,url:i}=e;for(let e=0;e<n.length;e++){const a=n[e].key;r.push(`${i}/nodes/${t}/attributes/${a}/0`)}return r}(this.tileset,t.mesh.attribute.resource))}const h=this.getLodSelection(t);return jf({id:e.toString(),lodSelection:h,obb:t.obb,contentUrl:a,textureUrl:o,attributeUrls:c,materialDefinition:s,textureFormat:u,textureLoaderOptions:this.textureLoaderOptions,children:r,isDracoGeometry:l})}getContentUrl(e){let t=null;const r=this.tileset.geometryDefinitions[e.definition];let n=-1;if(this.options.i3s&&this.options.i3s.useDracoGeometry&&(n=r.geometryBuffers.findIndex(e=>e.compressedAttributes&&"draco"===e.compressedAttributes.encoding)),-1===n&&(n=r.geometryBuffers.findIndex(e=>!e.compressedAttributes)),-1!==n){const i=Boolean(r.geometryBuffers[n].compressedAttributes);t={url:`${this.tileset.url}/nodes/${e.resource}/geometries/${n}`,isDracoGeometry:i}}return t}getLodSelection(e){const t=[];return"maxScreenThresholdSQ"===this.lodSelectionMetricType&&t.push({metricType:"maxScreenThreshold",maxError:Math.sqrt(e.lodThreshold/(.25*Math.PI))}),t.push({metricType:this.lodSelectionMetricType,maxError:e.lodThreshold}),t}getInformationFromMaterial(e){const t={textureData:{name:null}};if(e){var r;const a=null===(r=this.tileset.materialDefinitions)||void 0===r?void 0:r[e.definition];if(a){var n,i;t.materialDefinition=a;const e=null==a||null===(n=a.pbrMetallicRoughness)||void 0===n||null===(i=n.baseColorTexture)||void 0===i?void 0:i.textureSetDefinitionId;"number"==typeof e&&(t.textureData=this.textureDefinitionsSelectedFormats[e]||t.textureData)}}return t}initSelectedFormatsForTextureDefinitions(e){this.textureDefinitionsSelectedFormats=[];const t=this.getSupportedTextureFormats(),r=e.textureSetDefinitions||[];for(const e of r){const r=e&&e.formats||[];let n=null;for(const e of t){const t=r.find(t=>t.format===e);if(t){n=t;break}}n&&"ktx2"===n.format&&(this.textureLoaderOptions.basis={format:Kl(),containerFormat:"ktx2",module:"encoder"}),this.textureDefinitionsSelectedFormats.push(n)}}getSupportedTextureFormats(){const e=[];if(!this.options.i3s||this.options.i3s.useCompressedTextures){const t=Nl();t.has("etc2")&&e.push("ktx-etc2"),t.has("dxt")&&e.push("dds"),e.push("ktx2")}return e.push("jpg"),e.push("png"),e}}function jf(e){var t,r;const n={};let i=[0,0,0,1];if(e.mbs)i=e.mbs,n.sphere=[...vu.WGS84.cartographicToCartesian(e.mbs.slice(0,3)),e.mbs[3]];else if(e.obb){n.box=[...vu.WGS84.cartographicToCartesian(e.obb.center),...e.obb.halfSize,...e.obb.quaternion];const t=(new xp).fromCenterHalfSizeQuaternion(n.box.slice(0,3),e.obb.halfSize,e.obb.quaternion).getBoundingSphere();n.sphere=[...t.center,t.radius],i=[...e.obb.center,t.radius]}const a=null===(t=e.lodSelection)||void 0===t?void 0:t[0].metricType,o=null===(r=e.lodSelection)||void 0===r?void 0:r[0].maxError,s=e.transform,u=bf,c=df;return{...e,mbs:i,boundingVolume:n,lodMetricType:a,lodMetricValue:o,transformMatrix:s,type:u,refine:c}}const Cf=/layers\/[0-9]+$/,Tf=/nodes\/([0-9-]+|root)$/,Bf={name:"I3S (Indexed Scene Layers)",id:"i3s",module:"i3s",version:"3.3.1",mimeTypes:["application/octet-stream"],parse:async function(e,t={},r){const n=r.url;t.i3s=t.i3s||{};if("504b0304"===function(e){if(e instanceof ArrayBuffer)return[...new Uint8Array(e,0,4)].map(e=>e.toString(16).padStart(2,"0")).join("");return null}(e))throw new Error("Files with .slpk extention currently are not supported by I3SLoader");let i,a;i="auto"===t.i3s.isTileset?Cf.test(n):t.i3s.isTileset;a="auto"===t.isTileHeader?Tf.test(n):t.i3s.isTileHeader;e=i?await async function(e,t,r){const n=JSON.parse((new TextDecoder).decode(e));if("PointCloud"===(null==n?void 0:n.layerType))throw new Error("Point Cloud layers currently are not supported by I3SLoader");return n.loader=Bf,await async function(e,t,r){if(e.url=r.url,e.nodePages)e.nodePagesTile=new Af(e,t),e.root=e.nodePagesTile.formTileFromNodePages(0);else{var n;const r=eh(e.url+"/nodes/root",null===(n=t.i3s)||void 0===n?void 0:n.token);e.root=await Jo(r,e.loader,{...t,i3s:{...t.i3s,loadContent:!1,isTileHeader:!0,isTileset:!1}})}e.basePath=e.url,e.type=vf,e.lodMetricType=e.root.lodMetricType,e.lodMetricValue=e.root.lodMetricValue}(n,t,r),n}(e,t,r):a?await async function(e,t){return function(e,t){const r=t.url||"";let n,i,a;return e.geometryData&&(n=`${r}/${e.geometryData[0].href}`),e.textureData&&(i=`${r}/${e.textureData[0].href}`),e.attributeData&&(a=function(e,t){const{attributeData:r=[]}=t,n=[];for(let t=0;t<r.length;t++){const i=r[t].href.replace("./","");n.push(`${e}/${i}`)}return n}(r,e)),jf({...e,url:r,contentUrl:n,textureUrl:i,attributeUrls:a,isDracoGeometry:!1})}(e=JSON.parse((new TextDecoder).decode(e)),t)}(e,r):await async function(e,t){return await Ko(e,xh,t)}(e,t);return e},extensions:["bin"],options:{i3s:{token:null,isTileset:"auto",isTileHeader:"auto",tile:null,tileset:null,_tileOptions:null,_tilesetOptions:null,useDracoGeometry:!0,useCompressedTextures:!0,decodeTextures:!0,coordinateSystem:ch.METER_OFFSETS,colorsByAttribute:null}}};function Rf(){let e;if("undefined"!=typeof window&&window.performance)e=window.performance.now();else if("undefined"!=typeof process&&process.hrtime){const t=process.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}class Of{constructor(e,t){Object(Js.a)(this,"name",void 0),Object(Js.a)(this,"type",void 0),Object(Js.a)(this,"sampleSize",1),Object(Js.a)(this,"time",void 0),Object(Js.a)(this,"count",void 0),Object(Js.a)(this,"samples",void 0),Object(Js.a)(this,"lastTiming",void 0),Object(Js.a)(this,"lastSampleTime",void 0),Object(Js.a)(this,"lastSampleCount",void 0),Object(Js.a)(this,"_count",0),Object(Js.a)(this,"_time",0),Object(Js.a)(this,"_samples",0),Object(Js.a)(this,"_startTime",0),Object(Js.a)(this,"_timerPending",!1),this.name=e,this.type=t,this.reset()}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Rf(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Rf()-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}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}_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)}}class If{constructor(e){Object(Js.a)(this,"id",void 0),Object(Js.a)(this,"stats",{}),this.id=e.id,this.stats={},this._initializeStats(e.stats),Object.seal(this)}get(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"count";return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e in this.stats)this.stats[e].reset();return this}forEach(e){for(const t in this.stats)e(this.stats[t])}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(){(arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]).forEach(e=>this._getOrCreate(e))}_getOrCreate(e){if(!e||!e.name)return null;const{name:t,type:r}=e;return this.stats[t]||(this.stats[t]=e instanceof Of?e:new Of(t,r)),this.stats[t]}}function Pf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Df={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class Mf{constructor(e={}){Pf(this,"props",void 0),Pf(this,"stats",void 0),Pf(this,"activeRequestCount",0),Pf(this,"requestQueue",[]),Pf(this,"requestMap",new Map),Pf(this,"deferredUpdate",null),this.props={...Df,...e},this.stats=new If({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const r={handle:e,priority:0,getPriority:t},n=new Promise(e=>(r.resolve=e,r));return this.requestQueue.push(r),this.requestMap.set(e,n),this._issueNewRequests(),n}_issueRequest(e){const{handle:t,resolve:r}=e;let n=!1;const i=()=>{n||(n=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,r?r({done:i}):Promise.resolve({done:i})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const r=e[t];this._updateRequest(r)||(e.splice(t,1),this.requestMap.delete(r.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}function Ff(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Lf{constructor(e,t,r){Ff(this,"item",void 0),Ff(this,"previous",void 0),Ff(this,"next",void 0),this.item=e,this.previous=t,this.next=r}}function Nf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class zf{constructor(){Nf(this,"head",null),Nf(this,"tail",null),Nf(this,"_length",0)}get length(){return this._length}add(e){const t=new Lf(e,this.tail,null);return this.tail?(this.tail.next=t,this.tail=t):(this.head=t,this.tail=t),++this._length,t}remove(e){e&&(e.previous&&e.next?(e.previous.next=e.next,e.next.previous=e.previous):e.previous?(e.previous.next=null,this.tail=e.previous):e.next?(e.next.previous=null,this.head=e.next):(this.head=null,this.tail=null),e.next=null,e.previous=null,--this._length)}splice(e,t){e!==t&&(this.remove(t),this._insert(e,t))}_insert(e,t){const r=e.next;e.next=t,this.tail===e?this.tail=t:r.previous=t,t.next=r,t.previous=e,++this._length}}function Uf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function qf(e){return null!=e}class Hf{constructor(){Uf(this,"_list",void 0),Uf(this,"_sentinel",void 0),Uf(this,"_trimTiles",void 0),this._list=new zf,this._sentinel=this._list.add("sentinel"),this._trimTiles=!1}reset(){this._list.splice(this._list.tail,this._sentinel)}touch(e){const t=e._cacheNode;qf(t)&&this._list.splice(this._sentinel,t)}add(e,t,r){qf(t._cacheNode)||(t._cacheNode=this._list.add(t),r&&r(e,t))}unloadTile(e,t,r){const n=t._cacheNode;qf(n)&&(this._list.remove(n),t._cacheNode=void 0,r&&r(e,t))}unloadTiles(e,t){const r=this._trimTiles;this._trimTiles=!1;const n=this._list,i=1024*e.maximumMemoryUsage*1024,a=this._sentinel;let o=n.head;for(;o!==a&&(e.gpuMemoryUsageInBytes>i||r);){const r=o.item;o=o.next,this.unloadTile(e,r,t)}}trim(){this._trimTiles=!0}}const Gf=new Cs,Wf=new Cs,Vf=new Bp([new Ap,new Ap,new Ap,new Ap,new Ap,new Ap]);function Kf(e,t){const{cameraDirection:r,cameraUp:n,height:i}=e,{metersPerUnit:a}=e.distanceScales,o=Qf(e,e.center),s=vu.WGS84.eastNorthUpToFixedFrame(o),u=e.unprojectPosition(e.cameraPosition),c=vu.WGS84.cartographicToCartesian(u,new Cs),l=new Cs(s.transformAsVector(new Cs(r).scale(a))).normalize(),h=new Cs(s.transformAsVector(new Cs(n).scale(a))).normalize();!function(e){const t=e.getFrustumPlanes(),r=Jf(t.near,e.cameraPosition),n=Qf(e,r),i=Qf(e,e.cameraPosition,Wf);let a=0;Vf.planes[a++].fromPointNormal(n,Gf.copy(n).subtract(i));for(const i in t){if("near"===i)continue;const o=Jf(t[i],r,Wf),s=Qf(e,o,Wf);Vf.planes[a++].fromPointNormal(s,Gf.copy(n).subtract(s))}}(e);const p=e.constructor,{longitude:f,latitude:d,width:m,bearing:g,zoom:y}=e;return{camera:{position:c,direction:l,up:h},viewport:e,topDownViewport:new p({longitude:f,latitude:d,height:i,width:m,bearing:g,zoom:y,pitch:0}),height:i,cullingVolume:Vf,frameNumber:t,sseDenominator:1.15}}function Jf(e,t,r=new Cs){const n=e.normal.dot(t);return r.copy(e.normal).scale(e.distance-n).add(t),r}function Qf(e,t,r=new Cs){const n=e.unprojectPosition(t);return vu.WGS84.cartographicToCartesian(n,r)}const $f=new Cs;function Yf(e,t){if(e instanceof xp){const{halfAxes:r}=e,n=function(e){e.getColumn(0,$f);const t=e.getColumn(1),r=e.getColumn(2),n=$f.add(t).add(r);return n.len()}(r);return Math.log2(6356752.314245179/(n+t[2]))}if(e instanceof Th){const{radius:r}=e;return Math.log2(6356752.314245179/(r+t[2]))}if(e.width&&e.height){const{width:t,height:r}=e;return(Math.log2(6378137/t)+Math.log2(6378137/r))/2}return 1}function Xf(e,t,r){const n=vu.WGS84.cartographicToCartesian([e.xmax,e.ymax,e.zmax],new Cs),i=Math.sqrt(Math.pow(n[0]-r[0],2)+Math.pow(n[1]-r[1],2)+Math.pow(n[2]-r[2],2));return Math.log2(6356752.314245179/(i+t[2]))}function Zf(e){return null!=e}const ed=new Cs,td=new Cs,rd=new Cs;function nd(e,t,r){if(ia(e,"3D Tile: boundingVolume must be defined"),e.box)return function(e,t,r){const n=new Cs(e[0],e[1],e[2]);t.transform(n,n);let i=[];if(10===e.length){const t=e.slice(3,6),r=new op;r.fromArray(e,6);const n=new Cs([1,0,0]),a=new Cs([0,1,0]),o=new Cs([0,0,1]);n.transformByQuaternion(r),n.scale(t[0]),a.transformByQuaternion(r),a.scale(t[1]),o.transformByQuaternion(r),o.scale(t[2]),i=[...n.toArray(),...a.toArray(),...o.toArray()]}else i=[...e.slice(3,6),...e.slice(6,9),...e.slice(9,12)];const a=t.transformAsVector(i.slice(0,3)),o=t.transformAsVector(i.slice(3,6)),s=t.transformAsVector(i.slice(6,9)),u=new Ph([a[0],a[1],a[2],o[0],o[1],o[2],s[0],s[1],s[2]]);if(Zf(r))return r.center=n,r.halfAxes=u,r;return new xp(n,u)}(e.box,t,r);if(e.region){const[t,r,n,i,a,o]=e.region,s=vu.WGS84.cartographicToCartesian([ns(t),ns(i),a],td),u=vu.WGS84.cartographicToCartesian([ns(n),ns(r),o],rd),c=(new Cs).addVectors(s,u).multiplyScalar(.5),l=(new Cs).subVectors(s,u).len()/2;return id([c[0],c[1],c[2],l],new Gs)}if(e.sphere)return id(e.sphere,t,r);throw new Error("3D Tile: boundingVolume must contain a sphere, region, or box")}function id(e,t,r){const n=new Cs(e[0],e[1],e[2]);t.transform(n,n);const i=t.getScale(ed),a=Math.max(Math.max(i[0],i[1]),i[2]),o=e[3]*a;return Zf(r)?(r.center=n,r.radius=o,r):new Th(n,o)}new Cs,new Cs,new Gs,new Cs,new Cs,new Cs;function ad(e,t){if(e.dynamicScreenSpaceError&&e.dynamicScreenSpaceErrorComputedDensity){const r=e.dynamicScreenSpaceErrorComputedDensity,n=e.dynamicScreenSpaceErrorFactor;return function(e,t){const r=e*t;return 1-Math.exp(-r*r)}(t,r)*n}return 0}const od=new Cs,sd=new Cs,ud=new Cs,cd=new Cs,ld=new Cs,hd=new Gs,pd=new Gs;function fd(e,t){const{topDownViewport:r}=t,n=e.header.mbs[1],i=e.header.mbs[0],a=e.header.mbs[2],o=e.header.mbs[3],s=[...e.boundingVolume.center],u=r.unprojectPosition(r.cameraPosition);vu.WGS84.cartographicToCartesian(u,od),sd.copy(od).subtract(s).normalize(),vu.WGS84.eastNorthUpToFixedFrame(s,hd),pd.copy(hd).invert(),ud.copy(od).transform(pd);const c=Math.sqrt(ud[0]*ud[0]+ud[1]*ud[1]),l=c*c/ud[2];cd.copy([ud[0],ud[1],l]);const h=cd.transform(hd).subtract(s).normalize(),p=sd.cross(h).normalize().scale(o).add(s),f=vu.WGS84.cartesianToCartographic(p),d=r.project([i,n,a]),m=r.project(f);return ld.copy(d).subtract(m).magnitude()}function dd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class md{constructor(e=0){dd(this,"_map",new Map),dd(this,"_array",void 0),dd(this,"_length",void 0),this._array=new Array(e),this._length=e}get length(){return this._length}set length(e){this._length=e,e>this._array.length&&(this._array.length=e)}get values(){return this._array}get(e){return ia(e<this._array.length),this._array[e]}set(e,t){ia(e>=0),e>=this.length&&(this.length=e+1),this._map.has(this._array[e])&&this._map.delete(this._array[e]),this._array[e]=t,this._map.set(t,e)}delete(e){const t=this._map.get(e);t>=0&&(this._array.splice(t,1),this._map.delete(e),this.length--)}peek(){return this._array[this._length-1]}push(e){if(!this._map.has(e)){const t=this.length++;this._array[t]=e,this._map.set(e,t)}}pop(){const e=this._array[--this.length];return this._map.delete(e),e}reserve(e){ia(e>=0),e>this._array.length&&(this._array.length=e)}resize(e){ia(e>=0),this.length=e}trim(e){null==e&&(e=this.length),this._array.length=e}reset(){this._array=[],this._map=new Map,this._length=0}find(e){return this._map.has(e)}}function gd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const yd={loadSiblings:!1,skipLevelOfDetail:!1,maximumScreenSpaceError:2,updateTransforms:!0,onTraversalEnd:()=>{},viewportTraversersMap:{},basePath:""};class bd{traversalFinished(e){return!0}constructor(e){gd(this,"options",void 0),gd(this,"root",void 0),gd(this,"requestedTiles",void 0),gd(this,"selectedTiles",void 0),gd(this,"emptyTiles",void 0),gd(this,"lastUpdate",(new Date).getTime()),gd(this,"updateDebounceTime",1e3),gd(this,"_traversalStack",void 0),gd(this,"_emptyTraversalStack",void 0),gd(this,"_frameNumber",void 0),this.options={...yd,...e},this._traversalStack=new md,this._emptyTraversalStack=new md,this._frameNumber=null,this.root=null,this.selectedTiles={},this.requestedTiles={},this.emptyTiles={}}traverse(e,t,r){this.root=e,this.options={...this.options,...r},this.reset(),this.updateTile(e,t),this._frameNumber=t.frameNumber,this.executeTraversal(e,t)}reset(){this.requestedTiles={},this.selectedTiles={},this.emptyTiles={},this._traversalStack.reset(),this._emptyTraversalStack.reset()}executeTraversal(e,t){const r=this._traversalStack;for(e._selectionDepth=1,r.push(e);r.length>0;){const e=r.pop();let n=!1;this.canTraverse(e,t)&&(this.updateChildTiles(e,t),n=this.updateAndPushChildren(e,t,r,e.hasRenderContent?e._selectionDepth+1:e._selectionDepth));const i=e.parent,a=Boolean(!i||i._shouldRefine),o=!n;e.hasRenderContent?e.refine===ff?(this.loadTile(e,t),this.selectTile(e,t)):e.refine===df&&(this.loadTile(e,t),o&&this.selectTile(e,t)):(this.emptyTiles[e.id]=e,this.loadTile(e,t),o&&this.selectTile(e,t)),this.touchTile(e,t),e._shouldRefine=n&&a}const n=(new Date).getTime();(this.traversalFinished(t)||n-this.lastUpdate>this.updateDebounceTime)&&(this.lastUpdate=n,this.options.onTraversalEnd(t))}updateChildTiles(e,t){const r=e.children;for(const e of r)this.updateTile(e,t);return!0}updateAndPushChildren(e,t,r,n){const{loadSiblings:i,skipLevelOfDetail:a}=this.options,o=e.children;o.sort(this.compareDistanceToCamera.bind(this));const s=e.refine===df&&e.hasRenderContent&&!a;let u=!1,c=!0;for(const e of o)if(e._selectionDepth=n,e.isVisibleAndInRequestVolume?(r.find(e)&&r.delete(e),r.push(e),u=!0):(s||i)&&(this.loadTile(e,t),this.touchTile(e,t)),s){let r;if(r=!!e._inRequestVolume&&(e.hasRenderContent?e.contentAvailable:this.executeEmptyTraversal(e,t)),c=c&&r,!c)return!1}return u||(c=!1),c}updateTile(e,t){this.updateTileVisibility(e,t)}selectTile(e,t){this.shouldSelectTile(e)&&(e._selectedFrame=t.frameNumber,this.selectedTiles[e.id]=e)}loadTile(e,t){this.shouldLoadTile(e)&&(e._requestedFrame=t.frameNumber,e._priority=e._getPriority(),this.requestedTiles[e.id]=e)}touchTile(e,t){e.tileset._cache.touch(e),e._touchedFrame=t.frameNumber}canTraverse(e,t,r=!1,n=!1){return!!e.hasChildren&&(e.hasTilesetContent?!e.contentExpired:!(!n&&!e.isVisibleAndInRequestVolume)&&this.shouldRefine(e,t,r))}shouldLoadTile(e){return e.hasUnloadedContent||e.contentExpired}shouldSelectTile(e){return e.contentAvailable&&!this.options.skipLevelOfDetail}shouldRefine(e,t,r){let n=e._screenSpaceError;return r&&(n=e.getScreenSpaceError(t,!0)),n>this.options.maximumScreenSpaceError}updateTileVisibility(e,t){const r=[];if(this.options.viewportTraversersMap)for(const e in this.options.viewportTraversersMap){this.options.viewportTraversersMap[e]===t.viewport.id&&r.push(e)}else r.push(t.viewport.id);e.updateVisibility(t,r)}compareDistanceToCamera(e,t){return e._distanceToCamera-t._distanceToCamera}anyChildrenVisible(e,t){let r=!1;for(const n of e.children)n.updateVisibility(t),r=r||n.isVisibleAndInRequestVolume;return r}executeEmptyTraversal(e,t){let r=!0;const n=this._emptyTraversalStack;for(n.push(e);n.length>0&&r;){const e=n.pop();this.updateTile(e,t),e.isVisibleAndInRequestVolume||this.loadTile(e,t),this.touchTile(e,t);if(!e.hasRenderContent&&this.canTraverse(e,t,!1,!0)){const t=e.children;for(const e of t)n.find(e)&&n.delete(e),n.push(e)}else e.contentAvailable||(r=!1)}return r}}function vd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const wd=new Cs;class _d{constructor(e,t,r,n=""){vd(this,"tileset",void 0),vd(this,"header",void 0),vd(this,"id",void 0),vd(this,"url",void 0),vd(this,"parent",void 0),vd(this,"refine",void 0),vd(this,"type",void 0),vd(this,"contentUrl",void 0),vd(this,"lodMetricType",void 0),vd(this,"lodMetricValue",void 0),vd(this,"boundingVolume",void 0),vd(this,"content",void 0),vd(this,"contentState",void 0),vd(this,"gpuMemoryUsageInBytes",void 0),vd(this,"children",void 0),vd(this,"depth",void 0),vd(this,"viewportIds",void 0),vd(this,"transform",void 0),vd(this,"extensions",void 0),vd(this,"implicitTiling",void 0),vd(this,"userData",void 0),vd(this,"computedTransform",void 0),vd(this,"hasEmptyContent",void 0),vd(this,"hasTilesetContent",void 0),vd(this,"traverser",void 0),vd(this,"_cacheNode",void 0),vd(this,"_frameNumber",void 0),vd(this,"_lodJudge",void 0),vd(this,"_expireDate",void 0),vd(this,"_expiredContent",void 0),vd(this,"_shouldRefine",void 0),vd(this,"_distanceToCamera",void 0),vd(this,"_centerZDepth",void 0),vd(this,"_screenSpaceError",void 0),vd(this,"_visibilityPlaneMask",void 0),vd(this,"_visible",void 0),vd(this,"_inRequestVolume",void 0),vd(this,"_stackLength",void 0),vd(this,"_selectionDepth",void 0),vd(this,"_touchedFrame",void 0),vd(this,"_visitedFrame",void 0),vd(this,"_selectedFrame",void 0),vd(this,"_requestedFrame",void 0),vd(this,"_priority",void 0),vd(this,"_contentBoundingVolume",void 0),vd(this,"_viewerRequestVolume",void 0),vd(this,"_initialTransform",void 0),this.header=t,this.tileset=e,this.id=n||t.id,this.url=t.url,this.parent=r,this.refine=this._getRefine(t.refine),this.type=t.type,this.contentUrl=t.contentUrl,this.lodMetricType="geometricError",this.lodMetricValue=0,this.boundingVolume=null,this.content=null,this.contentState=uf,this.gpuMemoryUsageInBytes=0,this.children=[],this.hasEmptyContent=!1,this.hasTilesetContent=!1,this.depth=0,this.viewportIds=[],this.userData={},this.extensions=null,this._priority=0,this._touchedFrame=0,this._visitedFrame=0,this._selectedFrame=0,this._requestedFrame=0,this._screenSpaceError=0,this._cacheNode=null,this._frameNumber=null,this._cacheNode=null,this.traverser=new bd({}),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._visible=void 0,this._inRequestVolume=!1,this._stackLength=0,this._selectionDepth=0,this._initialTransform=new Gs,this.transform=new Gs,this._initializeLodMetric(t),this._initializeTransforms(t),this._initializeBoundingVolumes(t),this._initializeContent(t),this._initializeRenderingState(t),this._lodJudge=null,this._expireDate=null,this._expiredContent=null,this.implicitTiling=null,Object.seal(this)}destroy(){this.header=null}isDestroyed(){return null===this.header}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===lf||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===uf}get contentExpired(){return this.contentState===hf}get contentFailed(){return this.contentState===pf}get distanceToCamera(){return this._distanceToCamera}get screenSpaceError(){return this._screenSpaceError}getScreenSpaceError(e,t){switch(this.tileset.type){case vf:return fd(this,e);case wf:return function(e,t,r){const n=e.tileset,i=e.parent&&e.parent.lodMetricValue||e.lodMetricValue,a=r?i:e.lodMetricValue;if(0===a)return 0;const o=Math.max(e._distanceToCamera,1e-7),{height:s,sseDenominator:u}=t,{viewDistanceScale:c}=n.options;let l=a*s*(c||1)/(o*u);return l-=ad(n,o),l}(this,e,t);default:throw new Error("Unsupported tileset type")}}unselect(){this._selectedFrame=0}_getPriority(){const e=this.tileset._traverser,{skipLevelOfDetail:t}=e.options,r=this.refine===ff||t;if(r&&!this.isVisible&&void 0!==this._visible)return-1;if(this.tileset._frameNumber-this._touchedFrame>=1)return-1;if(this.contentState===uf)return-1;const n=this.parent,i=n&&(!r||0===this._screenSpaceError||n.hasTilesetContent)?n._screenSpaceError:this._screenSpaceError,a=e.root?e.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=cf;const e=await this.tileset._requestScheduler.scheduleRequest(this.id,this._getPriority.bind(this));if(!e)return this.contentState=uf,!1;try{const t=this.tileset.getTileUrl(this.contentUrl),r=this.tileset.loader,n={...this.tileset.loadOptions,[r.id]:{...this.tileset.loadOptions[r.id],isTileset:"json"===this.type,...this._getLoaderSpecificOptions(r.id)}};return this.content=await Jo(t,r,n),this.tileset.options.contentLoader&&await this.tileset.options.contentLoader(this),this._isTileset()&&this.tileset._initializeTileHeaders(this.content,this),this.contentState=lf,this._onContentLoaded(),!0}catch(e){throw this.contentState=pf,e}finally{e.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=uf,!0}updateVisibility(e,t){if(this._frameNumber===e.frameNumber)return;const r=this.parent,n=r?r._visibilityPlaneMask:Bp.MASK_INDETERMINATE;if(this.tileset._traverser.options.updateTransforms){const e=r?r.computedTransform:this.tileset.modelMatrix;this._updateTransform(e)}this._distanceToCamera=this.distanceToTile(e),this._screenSpaceError=this.getScreenSpaceError(e,!1),this._visibilityPlaneMask=this.visibility(e,n),this._visible=this._visibilityPlaneMask!==Bp.MASK_OUTSIDE,this._inRequestVolume=this.insideViewerRequestVolume(e),this._frameNumber=e.frameNumber,this.viewportIds=t}visibility(e,t){const{cullingVolume:r}=e,{boundingVolume:n}=this;return r.computeVisibilityWithPlaneMask(n,t)}contentVisibility(){return!0}distanceToTile(e){const t=this.boundingVolume;return Math.sqrt(Math.max(t.distanceSquaredTo(e.camera.position),0))}cameraSpaceZDepth({camera:e}){const t=this.boundingVolume;return wd.subVectors(t.center,e.position),e.direction.dot(wd)}insideViewerRequestVolume(e){const t=this._viewerRequestVolume;return!t||t.distanceSquaredTo(e.camera.position)<=0}updateExpiration(){if(null!=this._expireDate&&this.contentReady&&!this.hasEmptyContent){const e=Date.now();Date.lessThan(this._expireDate,e)&&(this.contentState=hf,this._expiredContent=this.content)}}get extras(){return this.header.extras}_initializeLodMetric(e){"lodMetricType"in e?this.lodMetricType=e.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 e?this.lodMetricValue=e.lodMetricValue:(this.lodMetricValue=this.parent&&this.parent.lodMetricValue||this.tileset.lodMetricValue,console.warn("3D Tile: Required prop lodMetricValue is undefined. Using parent lodMetricValue"))}_initializeTransforms(e){this.transform=e.transform?new Gs(e.transform):new Gs;const t=this.parent,r=this.tileset,n=t&&t.computedTransform?t.computedTransform.clone():r.modelMatrix.clone();this.computedTransform=new Gs(n).multiplyRight(this.transform);const i=t&&t._initialTransform?t._initialTransform.clone():new Gs;this._initialTransform=new Gs(i).multiplyRight(this.transform)}_initializeBoundingVolumes(e){this._contentBoundingVolume=null,this._viewerRequestVolume=null,this._updateBoundingVolume(e)}_initializeContent(e){this.content={_tileset:this.tileset,_tile:this},this.hasEmptyContent=!0,this.contentState=uf,this.hasTilesetContent=!1,e.contentUrl&&(this.content=null,this.hasEmptyContent=!1)}_initializeRenderingState(e){this.depth=e.level||(this.parent?this.parent.depth+1:0),this._shouldRefine=!1,this._distanceToCamera=0,this._centerZDepth=0,this._screenSpaceError=0,this._visibilityPlaneMask=Bp.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(e){return e||this.parent&&this.parent.refine||df}_isTileset(){return-1!==this.contentUrl.indexOf(".json")}_onContentLoaded(){switch(this.content&&this.content.type){case"vctr":case"geom":this.tileset._traverser.disableSkipLevelOfDetail=!0}this._isTileset()&&(this.hasTilesetContent=!0)}_updateBoundingVolume(e){this.boundingVolume=nd(e.boundingVolume,this.computedTransform,this.boundingVolume);const t=e.content;t&&(t.boundingVolume&&(this._contentBoundingVolume=nd(t.boundingVolume,this.computedTransform,this._contentBoundingVolume)),e.viewerRequestVolume&&(this._viewerRequestVolume=nd(e.viewerRequestVolume,this.computedTransform,this._viewerRequestVolume)))}_updateTransform(e=new Gs){const t=e.clone().multiplyRight(this.transform);!t.equals(this.computedTransform)&&(this.computedTransform=t,this._updateBoundingVolume(this.header))}_getLoaderSpecificOptions(e){switch(e){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{assetGltfUpAxis:(t=this.tileset.tileset).asset&&t.asset.gltfUpAxis||"Y"}}var t}}class kd extends bd{compareDistanceToCamera(e,t){return 0===t._distanceToCamera&&0===e._distanceToCamera?t._centerZDepth-e._centerZDepth:t._distanceToCamera-e._distanceToCamera}updateTileVisibility(e,t){if(super.updateTileVisibility(e,t),!e.isVisibleAndInRequestVolume)return;const r=e.children.length>0;if(e.hasTilesetContent&&r){const r=e.children[0];return this.updateTileVisibility(r,t),void(e._visible=r._visible)}if(this.meetsScreenSpaceErrorEarly(e,t))return void(e._visible=!1);const n=e.refine===df,i=e._optimChildrenWithinParent===kf;n&&i&&r&&!this.anyChildrenVisible(e,t)&&(e._visible=!1)}meetsScreenSpaceErrorEarly(e,t){const{parent:r}=e;return!(!r||r.hasTilesetContent||r.refine!==ff)&&!this.shouldRefine(e,t,!0)}}class xd{constructor(){var e,t,r;e=this,t="frameNumberMap",r=new Map,t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r}register(e,t){const r=this.frameNumberMap.get(e)||new Map,n=r.get(t)||0;r.set(t,n+1),this.frameNumberMap.set(e,r)}deregister(e,t){const r=this.frameNumberMap.get(e);if(!r)return;const n=r.get(t)||1;r.set(t,n-1)}isZero(e,t){var r;return 0===((null===(r=this.frameNumberMap.get(e))||void 0===r?void 0:r.get(t))||0)}}function Ed(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Sd="REQUESTED",Ad="COMPLETED",jd="ERROR";class Cd{constructor(){Ed(this,"_statusMap",void 0),Ed(this,"pendingTilesRegister",new xd),this._statusMap={}}add(e,t,r,n){if(!this._statusMap[t]){const{frameNumber:i,viewport:{id:a}}=n;this._statusMap[t]={request:e,callback:r,key:t,frameState:n,status:Sd},this.pendingTilesRegister.register(a,i),e().then(e=>{this._statusMap[t].status=Ad;const{frameNumber:r,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,r),this._statusMap[t].callback(e,n)}).catch(e=>{this._statusMap[t].status=jd;const{frameNumber:n,viewport:{id:i}}=this._statusMap[t].frameState;this.pendingTilesRegister.deregister(i,n),r(e)})}}update(e,t){if(this._statusMap[e]){const{frameNumber:r,viewport:{id:n}}=this._statusMap[e].frameState;this.pendingTilesRegister.deregister(n,r);const{frameNumber:i,viewport:{id:a}}=t;this.pendingTilesRegister.register(a,i),this._statusMap[e].frameState=t}}find(e){return this._statusMap[e]}hasPendingTiles(e,t){return!this.pendingTilesRegister.isZero(e,t)}}class Td extends bd{constructor(e){var t,r,n;super(e),n=void 0,(r="_tileManager")in(t=this)?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n,this._tileManager=new Cd}traversalFinished(e){return!this._tileManager.hasPendingTiles(e.viewport.id,this._frameNumber||0)}shouldRefine(e,t){return e._lodJudge=function(e,t){if(0===e.lodMetricValue||isNaN(e.lodMetricValue))return"DIG";const r=2*fd(e,t);return r<2?"OUT":!e.header.children||r<=e.lodMetricValue?"DRAW":e.header.children?"DIG":"OUT"}(e,t),"DIG"===e._lodJudge}updateChildTiles(e,t){const r=e.header.children||[],n=e.children,i=e.tileset;for(const a of r){const r=`${a.id}-${t.viewport.id}`,o=n&&n.find(e=>e.id===r);if(o)o&&this.updateTile(o,t);else{let n=()=>this._loadTile(a.id,i);this._tileManager.find(r)?this._tileManager.update(r,t):(i.tileset.nodePages&&(n=()=>i.tileset.nodePagesTile.formTileFromNodePages(a.id)),this._tileManager.add(n,r,t=>this._onTileLoad(t,e,r),t))}}return!1}async _loadTile(e,t){const{loader:r}=t,n=t.getTileUrl(`${t.url}/nodes/${e}`),i={...t.loadOptions,i3s:{...t.loadOptions.i3s,isTileHeader:!0}};return await Jo(n,r,i)}_onTileLoad(e,t,r){const n=new _d(t.tileset,e,t,r);t.children.push(n);const i=this._tileManager.find(n.id).frameState;this.updateTile(n,i),this._frameNumber===i.frameNumber&&(this.traversalFinished(i)||(new Date).getTime()-this.lastUpdate>this.updateDebounceTime)&&this.executeTraversal(n,i)}}function Bd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Rd={description:"",ellipsoid:vu.WGS84,modelMatrix:new Gs,throttleRequests:!0,maxRequests:64,maximumMemoryUsage:32,maximumTilesSelected:0,debounceTime:0,onTileLoad:()=>{},onTileUnload:()=>{},onTileError:()=>{},onTraversalComplete:e=>e,contentLoader:void 0,viewDistanceScale:1,maximumScreenSpaceError:8,loadTiles:!0,updateTransforms:!0,viewportTraversersMap:null,loadOptions:{fetch:{}},attributions:[],basePath:"",i3s:{}},Od="Tiles In Tileset(s)";class Id{constructor(e,t){Bd(this,"options",void 0),Bd(this,"loadOptions",void 0),Bd(this,"type",void 0),Bd(this,"tileset",void 0),Bd(this,"loader",void 0),Bd(this,"url",void 0),Bd(this,"basePath",void 0),Bd(this,"modelMatrix",void 0),Bd(this,"ellipsoid",void 0),Bd(this,"lodMetricType",void 0),Bd(this,"lodMetricValue",void 0),Bd(this,"refine",void 0),Bd(this,"root",void 0),Bd(this,"roots",void 0),Bd(this,"asset",void 0),Bd(this,"description",void 0),Bd(this,"properties",void 0),Bd(this,"extras",void 0),Bd(this,"attributions",void 0),Bd(this,"credits",void 0),Bd(this,"stats",void 0),Bd(this,"contentFormats",{draco:!1,meshopt:!1,dds:!1,ktx2:!1}),Bd(this,"traverseCounter",void 0),Bd(this,"geometricError",void 0),Bd(this,"selectedTiles",void 0),Bd(this,"updatePromise",null),Bd(this,"tilesetInitializationPromise",void 0),Bd(this,"cartographicCenter",void 0),Bd(this,"cartesianCenter",void 0),Bd(this,"zoom",void 0),Bd(this,"boundingVolume",void 0),Bd(this,"gpuMemoryUsageInBytes",void 0),Bd(this,"dynamicScreenSpaceErrorComputedDensity",void 0),Bd(this,"_traverser",void 0),Bd(this,"_cache",void 0),Bd(this,"_requestScheduler",void 0),Bd(this,"_frameNumber",void 0),Bd(this,"_queryParamsString",void 0),Bd(this,"_queryParams",void 0),Bd(this,"_extensionsUsed",void 0),Bd(this,"_tiles",void 0),Bd(this,"_pendingCount",void 0),Bd(this,"lastUpdatedVieports",void 0),Bd(this,"_requestedTiles",void 0),Bd(this,"_emptyTiles",void 0),Bd(this,"frameStateData",void 0),Bd(this,"maximumMemoryUsage",void 0),ia(e),this.options={...Rd,...t},this.tileset=e,this.loader=e.loader,this.type=e.type,this.url=e.url,this.basePath=e.basePath||n.dirname(this.url),this.modelMatrix=this.options.modelMatrix,this.ellipsoid=this.options.ellipsoid,this.lodMetricType=e.lodMetricType,this.lodMetricValue=e.lodMetricValue,this.refine=e.root.refine,this.loadOptions=this.options.loadOptions||{},this.root=null,this.roots={},this.cartographicCenter=null,this.cartesianCenter=null,this.zoom=1,this.boundingVolume=null,this.traverseCounter=0,this.geometricError=0,this._traverser=this._initializeTraverser(),this._cache=new Hf,this._requestScheduler=new Mf({throttleRequests:this.options.throttleRequests,maxRequests:this.options.maxRequests}),this._frameNumber=0,this._pendingCount=0,this._tiles={},this.selectedTiles=[],this._emptyTiles=[],this._requestedTiles=[],this.frameStateData={},this.lastUpdatedVieports=null,this._queryParams={},this._queryParamsString="",this.maximumMemoryUsage=this.options.maximumMemoryUsage||32,this.gpuMemoryUsageInBytes=0,this.stats=new If({id:this.url}),this._initializeStats(),this._extensionsUsed=void 0,this.dynamicScreenSpaceErrorComputedDensity=0,this.extras=null,this.asset={},this.credits={},this.description=this.options.description||"",this.tilesetInitializationPromise=this._initializeTileSet(e)}destroy(){this._destroy()}isLoaded(){return 0===this._pendingCount&&0!==this._frameNumber&&0===this._requestedTiles.length}get tiles(){return Object.values(this._tiles)}get frameNumber(){return this._frameNumber}get queryParams(){return this._queryParamsString||(this._queryParamsString=function(e){const t=[];for(const r of Object.keys(e))t.push(`${r}=${e[r]}`);switch(t.length){case 0:return"";case 1:return"?"+t[0];default:return"?"+t.join("&")}}(this._queryParams)),this._queryParamsString}setProps(e){this.options={...this.options,...e}}setOptions(e){this.options={...this.options,...e}}getTileUrl(e){return e.startsWith("data:")?e:`${e}${this.queryParams}`}hasExtension(e){return Boolean(this._extensionsUsed&&this._extensionsUsed.indexOf(e)>-1)}update(e=null){this.tilesetInitializationPromise.then(()=>{!e&&this.lastUpdatedVieports?e=this.lastUpdatedVieports:this.lastUpdatedVieports=e,e&&this.doUpdate(e)})}async selectTiles(e=null){return await this.tilesetInitializationPromise,e&&(this.lastUpdatedVieports=e),this.updatePromise||(this.updatePromise=new Promise(e=>{setTimeout(()=>{this.lastUpdatedVieports&&this.doUpdate(this.lastUpdatedVieports),e(this._frameNumber),this.updatePromise=null},this.options.debounceTime)})),this.updatePromise}doUpdate(e){if("loadTiles"in this.options&&!this.options.loadTiles)return;if(this.traverseCounter>0)return;const t=e instanceof Array?e:[e];this._cache.reset(),this._frameNumber++,this.traverseCounter=t.length;const r=[];for(const e of t){const t=e.id;this._needTraverse(t)?r.push(t):this.traverseCounter--}for(const e of t){const t=e.id;if(this.roots[t]||(this.roots[t]=this._initializeTileHeaders(this.tileset,null)),!r.includes(t))continue;const n=Kf(e,this._frameNumber);this._traverser.traverse(this.roots[t],n,this.options)}}_needTraverse(e){let t=e;return this.options.viewportTraversersMap&&(t=this.options.viewportTraversersMap[e]),t===e}_onTraversalEnd(e){const t=e.viewport.id;this.frameStateData[t]||(this.frameStateData[t]={selectedTiles:[],_requestedTiles:[],_emptyTiles:[]});const r=this.frameStateData[t],n=Object.values(this._traverser.selectedTiles),[i,a]=function(e,t,r){if(0===r||e.length<=r)return[e,[]];const n=[],{longitude:i,latitude:a}=t.viewport;for(const[t,r]of e.entries()){const[e,o]=r.header.mbs,s=Math.abs(i-e),u=Math.abs(a-o),c=Math.sqrt(u*u+s*s);n.push([t,c])}const o=n.sort((e,t)=>e[1]-t[1]),s=[];for(let t=0;t<r;t++)s.push(e[o[t][0]]);const u=[];for(let t=r;t<o.length;t++)u.push(e[o[t][0]]);return[s,u]}(n,e,this.options.maximumTilesSelected);r.selectedTiles=i;for(const e of a)e.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(const e in this.frameStateData){const t=this.frameStateData[e];this.selectedTiles=this.selectedTiles.concat(t.selectedTiles),this._requestedTiles=this._requestedTiles.concat(t._requestedTiles),this._emptyTiles=this._emptyTiles.concat(t._emptyTiles)}this.selectedTiles=this.options.onTraversalComplete(this.selectedTiles);for(const e of this.selectedTiles)this._tiles[e.id]=e;this._loadTiles(),this._unloadTiles(),this._updateStats()}_tilesChanged(e,t){if(e.length!==t.length)return!0;const r=new Set(e.map(e=>e.id)),n=new Set(t.map(e=>e.id));let i=e.filter(e=>!n.has(e.id)).length>0;return i=i||t.filter(e=>!r.has(e.id)).length>0,i}_loadTiles(){for(const e of this._requestedTiles)e.contentUnloaded&&this._loadTile(e)}_unloadTiles(){this._cache.unloadTiles(this,(e,t)=>e._unloadTile(t))}_updateStats(){let e=0,t=0;for(const r of this.selectedTiles)r.contentAvailable&&r.content&&(e++,r.content.pointCount?t+=r.content.pointCount:t+=r.content.vertexCount);this.stats.get("Tiles In View").count=this.selectedTiles.length,this.stats.get("Tiles To Render").count=e,this.stats.get("Points/Vertices").count=t}async _initializeTileSet(e){this.type===vf&&(this.calculateViewPropsI3S(),e.root=await e.root),this.root=this._initializeTileHeaders(e,null),this.type===wf&&(this._initializeTiles3DTileset(e),this.calculateViewPropsTiles3D()),this.type===vf&&this._initializeI3STileset()}calculateViewPropsI3S(){var e;const t=this.tileset.fullExtent;if(t){const{xmin:e,xmax:r,ymin:n,ymax:i,zmin:a,zmax:o}=t;return this.cartographicCenter=new Cs(e+(r-e)/2,n+(i-n)/2,a+(o-a)/2),this.cartesianCenter=vu.WGS84.cartographicToCartesian(this.cartographicCenter,new Cs),void(this.zoom=Xf(t,this.cartographicCenter,this.cartesianCenter))}const r=null===(e=this.tileset.store)||void 0===e?void 0:e.extent;if(r){const[e,t,n,i]=r;return this.cartographicCenter=new Cs(e+(n-e)/2,t+(i-t)/2,0),this.cartesianCenter=vu.WGS84.cartographicToCartesian(this.cartographicCenter,new Cs),void(this.zoom=function(e,t,r){const[n,i,a,o]=e;return Xf({xmin:n,xmax:a,ymin:i,ymax:o,zmin:0,zmax:0},t,r)}(r,this.cartographicCenter,this.cartesianCenter))}console.warn("Extent is not defined in the tileset header"),this.cartographicCenter=new Cs,this.zoom=1}calculateViewPropsTiles3D(){const e=this.root;ia(e);const{center:t}=e.boundingVolume;if(!t)return console.warn("center was not pre-calculated for the root tile"),this.cartographicCenter=new Cs,void(this.zoom=1);0!==t[0]||0!==t[1]||0!==t[2]?this.cartographicCenter=vu.WGS84.cartesianToCartographic(t,new Cs):this.cartographicCenter=new Cs(0,0,-vu.WGS84.radii[0]),this.cartesianCenter=t,this.zoom=Yf(e.boundingVolume,this.cartographicCenter)}_initializeStats(){this.stats.get(Od),this.stats.get("Tiles Loading"),this.stats.get("Tiles In Memory"),this.stats.get("Tiles In View"),this.stats.get("Tiles To Render"),this.stats.get("Tiles Loaded"),this.stats.get("Tiles Unloaded"),this.stats.get("Failed Tile Loads"),this.stats.get("Points/Vertices"),this.stats.get("Tile Memory Use","memory")}_initializeTileHeaders(e,t){const r=new _d(this,e.root,t);if(t&&(t.children.push(r),r.depth=t.depth+1),this.type===wf){const e=[];for(e.push(r);e.length>0;){const t=e.pop();this.stats.get(Od).incrementCount();const r=t.header.children||[];for(const n of r){const r=new _d(this,n,t);t.children.push(r),r.depth=t.depth+1,e.push(r)}}}return r}_initializeTraverser(){let e;switch(this.type){case wf:e=kd;break;case vf:e=Td;break;default:e=bd}return new e({basePath:this.basePath,onTraversalEnd:this._onTraversalEnd.bind(this)})}_destroyTileHeaders(e){this._destroySubtree(e)}async _loadTile(e){let t;try{this._onStartTileLoading(),t=await e.loadContent()}catch(t){this._onTileLoadError(e,t)}finally{this._onEndTileLoading(),this._onTileLoad(e,t)}}_onTileLoadError(e,t){this.stats.get("Failed Tile Loads").incrementCount();const r=t.message||t.toString(),n=e.url;console.error(`A 3D tile failed to load: ${e.url} ${r}`),this.options.onTileError(e,r,n)}_onTileLoad(e,t){if(t){if(this.type===vf){var r,n;const e=(null===(r=this.tileset)||void 0===r||null===(n=r.nodePagesTile)||void 0===n?void 0:n.nodesInNodePages)||0;this.stats.get(Od).reset(),this.stats.get(Od).addCount(e)}e&&e.content&&function(e,t){ia(e),ia(t);const{rtcCenter:r,gltfUpAxis:n}=t,{computedTransform:i,boundingVolume:{center:a}}=e;let o=new Gs(i);switch(r&&o.translate(r),n){case"Z":break;case"Y":const e=(new Gs).rotateX(Math.PI/2);o=o.multiplyRight(e);break;case"X":const t=(new Gs).rotateY(-Math.PI/2);o=o.multiplyRight(t)}t.isQuantized&&o.translate(t.quantizedVolumeOffset).scale(t.quantizedVolumeScale);const s=new Cs(a);t.cartesianModelMatrix=o,t.cartesianOrigin=s;const u=vu.WGS84.cartesianToCartographic(s,new Cs),c=vu.WGS84.eastNorthUpToFixedFrame(s).invert();t.cartographicModelMatrix=c.multiplyRight(o),t.cartographicOrigin=u,t.coordinateSystem||(t.modelMatrix=t.cartographicModelMatrix)}(e,e.content),this.updateContentTypes(e),this._addTileToCache(e),this.options.onTileLoad(e)}}updateContentTypes(e){if(this.type===vf)switch(e.header.isDracoGeometry&&(this.contentFormats.draco=!0),e.header.textureFormat){case"dds":this.contentFormats.dds=!0;break;case"ktx2":this.contentFormats.ktx2=!0}else if(this.type===wf){var t;const{extensionsRemoved:r=[]}=(null===(t=e.content)||void 0===t?void 0:t.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("Tiles Loading").incrementCount()}_onEndTileLoading(){this._pendingCount--,this.stats.get("Tiles Loading").decrementCount()}_addTileToCache(e){this._cache.add(this,e,t=>t._updateCacheStats(e))}_updateCacheStats(e){this.stats.get("Tiles Loaded").incrementCount(),this.stats.get("Tiles In Memory").incrementCount(),this.gpuMemoryUsageInBytes+=e.content.byteLength||0,this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes}_unloadTile(e){this.gpuMemoryUsageInBytes-=e.content&&e.content.byteLength||0,this.stats.get("Tiles In Memory").decrementCount(),this.stats.get("Tiles Unloaded").incrementCount(),this.stats.get("Tile Memory Use").count=this.gpuMemoryUsageInBytes,this.options.onTileUnload(e),e.unloadContent()}_destroy(){const e=[];for(this.root&&e.push(this.root);e.length>0;){const t=e.pop();for(const r of t.children)e.push(r);this._destroyTile(t)}this.root=null}_destroySubtree(e){const t=e,r=[];for(r.push(t);r.length>0;){e=r.pop();for(const t of e.children)r.push(t);e!==t&&this._destroyTile(e)}t.children=[]}_destroyTile(e){this._cache.unloadTile(this,e),this._unloadTile(e),e.destroy()}_initializeTiles3DTileset(e){if(this.asset=e.asset,!this.asset)throw new Error("Tileset must have an asset property.");if("0.0"!==this.asset.version&&"1.0"!==this.asset.version)throw new Error("The tileset must be 3D Tiles version 0.0 or 1.0.");"tilesetVersion"in this.asset&&(this._queryParams.v=this.asset.tilesetVersion),this.credits={attributions:this.options.attributions||[]},this.description=this.options.description||"",this.properties=e.properties,this.geometricError=e.geometricError,this._extensionsUsed=e.extensionsUsed,this.extras=e.extras}_initializeI3STileset(){this.loadOptions.i3s&&"token"in this.loadOptions.i3s&&(this._queryParams.token=this.loadOptions.i3s.token)}}const Pd=[9,-18,-88,0,96,90,0,0,-60,-20,-9,18,8,0,-96,30,0,0,60,-20,9,-88,-18,90,96,0,-20,-60,0,0,186,-42,-42,-150,-96,-150,60,60,60,60,54,162,-78,30,-24,-90,-60,60,-60,60,-9,-32,18,30,24,0,20,-60,0,0,-9,8,18,30,-96,0,-20,60,0,0,54,-78,162,-90,-24,30,60,-60,60,-60,-54,78,78,90,144,90,-60,-60,-60,-60,9,-8,-18,-30,-24,0,20,60,0,0,-9,18,-32,0,24,30,0,0,-60,20,9,-18,-8,0,-24,-30,0,0,60,20],Dd=[0,0,-131,0,138,144,0,0,-102,-31,0,0,7,0,-138,42,0,0,102,-31,62,0,-31,0,0,-62,0,0,0,31,124,0,-62,0,0,-124,0,0,0,62,124,0,-62,0,0,-124,0,0,0,62,62,0,-31,0,0,-62,0,0,0,31,0,0,45,0,-183,-9,0,93,18,0,0,0,216,0,33,87,0,-93,12,-93,0,0,156,0,153,99,0,-93,-12,-93,0,0,-45,0,-3,9,0,93,-18,0,0,0,-55,0,48,42,0,0,-84,31,0,0,-7,0,-48,-42,0,0,84,31],Md=[18,-36,-122,0,120,135,0,0,-84,-31,-18,36,-2,0,-120,51,0,0,84,-31,36,-165,-27,93,147,-9,0,-93,18,0,210,45,-111,-93,-57,-192,0,93,12,93,162,141,-75,-93,-129,-180,0,93,-12,93,-36,-21,27,93,39,9,0,-93,-18,0,0,0,62,0,0,31,0,0,0,-31,0,0,124,0,0,62,0,0,0,-62,0,0,124,0,0,62,0,0,0,-62,0,0,62,0,0,31,0,0,0,-31,-18,36,-64,0,66,51,0,0,-102,31,18,-36,2,0,-66,-51,0,0,102,31];class Fd{constructor(e){Object(Js.a)(this,"_v00",0),Object(Js.a)(this,"_v01",0),Object(Js.a)(this,"_v10",0),Object(Js.a)(this,"_v11",0),Object(Js.a)(this,"_t",[]),Object(Js.a)(this,"_ix",void 0),Object(Js.a)(this,"_iy",void 0),Object(Js.a)(this,"options",void 0),this.options=e,this._ix=this.options._width,this._iy=this.options._height}getHeight(e,t){if(e=Math.abs(e)>90?NaN:e,isNaN(e)||isNaN(t))return NaN;const r=function(e,t){t=Math.abs(t);let r=Ld(e,t);2*Math.abs(r)===t?r-=Ld(e,2*t)-r:2*Math.abs(r)>t&&(r+=r<0?t:-t);return r}(t,360);let n=(t=-180!==r?r:180)*this.options._rlonres,i=-e*this.options._rlatres,a=Math.floor(n),o=Math.min(Math.round((this.options._height-1)/2-1),Math.floor(i));n-=a,i-=o,o+=(this.options._height-1)/2,a+=a<0?this.options._width:a>=this.options._width?-this.options._width:0;let s=0,u=0,c=0,l=0,h=new Array(10);if(a!==this._ix||o!==this._iy)if(this.options.cubic){const e=[this._rawval(a,o-1),this._rawval(a+1,o-1),this._rawval(a-1,o),this._rawval(a,o),this._rawval(a+1,o),this._rawval(a+2,o),this._rawval(a-1,o+1),this._rawval(a,o+1),this._rawval(a+1,o+1),this._rawval(a+2,o+1),this._rawval(a,o+2),this._rawval(a+1,o+2)];let t=Dd;0!==o&&(t=o===this.options._height-2?Md:Pd);let r=372;0!==o&&(r=o===this.options._height-2?372:240);for(let n=0;n<10;++n){h[n]=0;for(let r=0;r<12;++r)h[n]+=e[r]*t[10*r+n];h[n]/=r}}else s=this._rawval(a,o),u=this._rawval(a+1,o),c=this._rawval(a,o+1),l=this._rawval(a+1,o+1);else this.options.cubic?h=this._t:(s=this._v00,u=this._v01,c=this._v10,l=this._v11);if(!this.options.cubic){const e=(1-i)*((1-n)*s+n*u)+i*((1-n)*c+n*l),t=this.options._offset+this.options._scale*e;return this._ix=a,this._iy=o,this._v00=s,this._v01=u,this._v10=c,this._v11=l,t}let p=h[0]+n*(h[1]+n*(h[3]+n*h[6]))+i*(h[2]+n*(h[4]+n*h[7])+i*(h[5]+n*h[8]+i*h[9]));return p=this.options._offset+this.options._scale*p,this._ix=a,this._iy=o,this._t=h,p}_rawval(e,t){e<0?e+=this.options._width:e>=this.options._width&&(e-=this.options._width),(t<0||t>=this.options._height)&&(t=t<0?-t:2*(this.options._height-1)-t,e+=(e<this.options._width/2?1:-1)*this.options._width/2);const r=this.options._datastart+2*(t*this.options._swidth+e);return this.options.data[r]<<8|this.options.data[r+1]}}function Ld(e,t){return e-Math.floor(e/t)*t}function Nd(e,t){const r=function*(e){let t=0;do{const r=e.indexOf(10,t);if(-1!==r){const n=e.subarray(t,r);t=r+1,yield{offset:t,line:zd(n)}}else{const r=e.subarray(t,e.length);t=e.length,yield{offset:t,line:zd(r)}}}while(t<e.length);return{offset:t,line:""}}(e);let n=r.next();if(n.done||"P5"!==n.value.line)throw new Error("Geoid model file: File not in PGM format");let i=Number.MAX_VALUE,a=0,o=-1,s=-1,u="NONE",c="UNKNOWN",l=0,h=0,p=null,f=null;do{n=r.next();const e=n.value.line;if(e.length){if("#"!==e[0]){let t=e.split(" ");if(t=t.filter(e=>""!==e),l=parseInt(t[0],10),h=parseInt(t[1],10),!l||!h)throw new Error("Geoid model file: Error reading raster size");break}{const r=e.split(" "),n=r[0],l=r[1];if("#"!==n||!l)continue;const h=r.length>2?r.slice(2):[];if("Description"===l)u=h.join(" ");else if("DateTime"===l)c=h.join(" ");else if("Offset"===l){if(!r[2])throw new Error("Geoid model file: Error reading offset");i=parseInt(r[2],10)}else if("Scale"===l){if(!r[2])throw new Error("Geoid model file: Error reading scale");a=parseFloat(r[2])}else l===(t.cubic?"MaxCubicError":"MaxBilinearError")?isFinite(parseFloat(r[2]))&&(o=parseFloat(r[2])):l===(t.cubic?"RMSCubicError":"RMSBilinearError")&&isFinite(parseFloat(r[2]))&&(s=parseFloat(r[2]))}}}while(!n.done);n=r.next();const d=parseInt(n.value.line,10);if(n.done)throw new Error("Geoid model file: Error reading maxval");if(65535!==d)throw new Error("Geoid model file: Incorrect value of maxval");if(p=n.value.offset,f=l,i===Number.MAX_VALUE)throw new Error("Geoid model file: Offset not set");if(0===a)throw new Error("Geoid model file: Scale not set");if(a<0)throw new Error("Geoid model file: Scale must be positive");if(h<2||l<2)throw new Error("Geoid model file: Raster size too small");if(1&l)throw new Error("Geoid model file: Raster width is odd");if(!(1&h))throw new Error("Geoid model file: Raster height is even");const m=l/360,g=(h-1)/180;return new Fd({cubic:t.cubic,_width:l,_height:h,_rlonres:m,_rlatres:g,_offset:i,_scale:a,_swidth:f,_datastart:p,_maxerror:o,_rmserror:s,_description:u,_datetime:c,data:e})}function zd(e){let t="";for(const r of e)t+=String.fromCharCode(r);return t}const Ud={name:"PGM - Netpbm grayscale image format",id:"pgm",module:"tile-converter",version:"3.3.1",mimeTypes:["image/x-portable-graymap"],parse:async(e,t)=>Nd(new Uint8Array(e),t),extensions:["pgm"],options:{cubic:!1}};function qd(e,t){const r=[e.center[0],e.center[1],e.center[2]+t.getHeight(e.center[1],e.center[0])],n=vu.WGS84.cartographicToCartesian(r,new Cs),i=(new xp).fromCenterHalfSizeQuaternion(n,e.halfSize,e.quaternion);return[...i.center,...i.halfAxes.toArray()]}function Hd(e,t){const r=[],n=e.boundingVolume,i=e.lodMetricValue||.1,a={metricType:"maxScreenThreshold",maxError:2*t.mbs[3]*16/i},o={metricType:"maxScreenThresholdSQ",maxError:.25*Math.PI*a.maxError*a.maxError};return"OrientedBoundingBox"===n.constructor.name?(r.push(o),r.push(a)):(r.push(a),r.push(o)),r}function Gd(e){let t=(e.header.lodSelection.maxScreenThreshold||{}).maxError;if(!t){const r=e.header.lodSelection.maxScreenThresholdSQ;r&&(t=Math.sqrt(r.maxError/(.25*Math.PI)))}return t||(t=16),2*e.header.mbs[3]*16/t}const Wd={name:"JSON",id:"json",module:"json",version:"3.3.1",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:Vd,parse:async e=>Vd((new TextDecoder).decode(e)),options:{}};function Vd(e){return JSON.parse(e)}r(265);var Kd=r(83),Jd=r.n(Kd);function Qd(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const $d={command:"",arguments:[],port:5e3,autoPort:!0,wait:2e3,onSuccess:e=>{console.log("Started "+e.props.command)}};class Yd{constructor({id:e="browser-driver"}={}){Qd(this,"id",void 0),Qd(this,"props",{...$d}),Qd(this,"childProcess",null),Qd(this,"port",0),Qd(this,"successTimer",void 0),this.id=e}async start(e){e={...$d,...e},this.props=e;const t=[...e.arguments];return this.port=Number(e.port),e.portArg&&(e.autoPort&&(this.port=await function(e=3e3){return new Promise(t=>{Jd.a.exec("lsof -i -P -n | grep LISTEN",(r,n)=>{if(r)return void t(e);const i=[],a=/:(\d+) \(LISTEN\)/;n.split("\n").forEach(e=>{const t=a.exec(e);t&&i.push(Number(t[1]))});let o=e;for(;i.includes(o);)o++;t(o)})})}(e.port)),t.push(e.portArg,String(this.port))),await new Promise((r,n)=>{try{this._setTimeout(()=>{e.onSuccess&&e.onSuccess(this),r({})}),console.log(`Spawning ${e.command} ${e.arguments.join(" ")}`);const i=Kd.spawn(e.command,t,e.spawn);this.childProcess=i,i.stdout.on("data",e=>{console.log(e.toString())}),i.stderr.on("data",e=>{console.log(`Child process wrote to stderr: "${e}".`),this._clearTimeout(),n(new Error(e))}),i.on("error",e=>{console.log("Child process errored with "+e),this._clearTimeout(),n(e)}),i.on("close",e=>{console.log("Child process exited with "+e),this.childProcess=null,this._clearTimeout(),r({})})}catch(e){n(e)}})}async stop(){this.childProcess&&(this.childProcess.kill(),this.childProcess=null)}async exit(e=0){try{await this.stop(),process.exit(e)}catch(e){console.error(e.message||e),process.exit(1)}}_setTimeout(e){Number(this.props.wait)>0&&(this.successTimer=setTimeout(e,this.props.wait))}_clearTimeout(){this.successTimer&&clearTimeout(this.successTimer)}}var Xd=r(82),Zd=r.n(Xd);const em="function"==typeof atob?atob:"function"==typeof Buffer?function(e){return Buffer.from(e,"base64").toString("binary")}:nm,tm=em("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"),rm=!(!WebAssembly||em===nm)&&function(e){var t,r,n,i=-1;t=e.length-1,r=new ArrayBuffer(e.length),n=new Uint8Array(r);for(;t>i++;)n[i]=e.charCodeAt(i);return n}(tm).buffer;Math.floor(1048576.00032768);function nm(e){return e}rm||console.log("WebAssembly not available or WASM module could not be decoded; md5WASM will fall back to JavaScript");r(118);function im(e){const t=e+".gz",r=Object(fe.createGzip)(),n=Object(Ae.createReadStream)(e),i=Object(Ae.createWriteStream)(t);return new Promise((e,a)=>{n.on("end",()=>{console.log(t+" compressed and saved."),e(t)}),n.on("error",e=>{console.log(t+": compression error!"),a(e)}),n.pipe(r).pipe(i)})}async function am(e,t,r,n,i){"win32"===process.platform?await async function(e,t,r=0,n=Object(qi.join)(".","*"),i){"@"===n[0]&&(n="*"+n.substr(1));const a=hm(t),o=["a","-tzip","-mx="+r,a,n],s=new Yd;await s.start({command:i,arguments:o,spawn:{cwd:""+e},wait:0})}(e,t,r,n,i):await async function(e,t,r=0,n="."){const i=hm(t),a=["-"+r,"-r",i,n],o=new Yd;await o.start({command:"zip",arguments:a,spawn:{cwd:e},wait:0})}(e,t,r,n)}async function om(e,t,r="index.json"){let n;n=t instanceof Promise?new Uint8Array(await t):t instanceof ArrayBuffer?new Uint8Array(t):t,await Ae.promises.mkdir(e,{recursive:!0});const i=Object(qi.join)(e,r);try{await Ae.promises.writeFile(i,n)}catch(e){throw e}return console.log(i+" saved."),i}async function sm(e,t,r="index.json",n=!0,i){const a=await om(e,t,r);if(n){if(i)return i.includes(a)?null:(i.push(a),a+".gz");{const e=await im(a);return await lm(a),e}}return a}async function um(e,t){return new Promise((r,n)=>{let i=0;console.log(`load ${e}/${t}.`);const a=setInterval(()=>{Jo(Object(qi.join)(e,t),Wd).then(e=>{clearInterval(a),r(e)}).catch(()=>{i++,i>100&&(clearInterval(a),n(new Error(`Cannon load ${e}/${t}.`)))})},200)})}function cm(e){return Ae.promises.rmdir(e,{recursive:!0})}function lm(e){return Ae.promises.unlink(e)}function hm(e){return Object(qi.isAbsolute)(e)?e:Object(qi.join)(process.cwd(),e)}function pm(e){let t=e[0];const r=Math.floor(t/3600);t-=3600*r;const n=Math.floor(t/60);t-=60*n;const i=Math.floor(t),a=e[1]/1e6;let o="";return r&&(o+=r+"h "),n&&(o+=n+"m "),i&&(o+=i+"s"),o||(o+=a+"ms"),o}async function fm(e){const{slpk:t,outputPath:r,tilesetName:n}=e,i=hm(r);try{if(t){const e=Object(qi.join)(i,n+".slpk");return(await Ae.promises.stat(e)).size}const e=Object(qi.join)(i,n);return await async function e(t){let r=0;const n=await Ae.promises.readdir(t);for(const i of n){const n=await Ae.promises.stat(Object(qi.join)(t,i));n.isDirectory()?r+=await e(Object(qi.join)(t,i)):r+=n.size}return r}(e)}catch(e){return console.log("Calculate file sizes error: ",e),null}}const dm=()=>({boundingVolume:{path:"boundingVolume"},geometricError:{path:"geometricError"},content:{path:"content"},children:{path:"children",transform:e=>e.map(e=>Vi()(e,dm()))}});function mm(e,t){let r,n,i;const a=e.boundingVolume,o=vu.WGS84.cartesianToCartographic(a.center,new Cs);return o[2]=o[2]-t.getHeight(o[1],o[0]),a instanceof xp?(n=a.halfSize,r=new Cs(n[0],n[1],n[2]).len(),i=a.quaternion):(r=e.boundingVolume.radius,n=[r,r,r],i=(new op).fromMatrix3(new Ph([n[0],0,0,0,n[1],0,0,0,n[2]])).normalize()),{mbs:[o[0],o[1],o[2],r],obb:{center:[o[0],o[1],o[2]],halfSize:n,quaternion:i}}}function gm(e,t){const r=function(e){const t=[];for(let r=0;r<e.length;r+=3){const n=new Cs([e[r],e[r+1],e[r+2]]);t.push(n)}return t}(e),n=function(e,t=new xp){if(!e||0===e.length)return t.halfAxes=new Ph([0,0,0,0,0,0,0,0,0]),t.center=new Cs,t;const r=e.length,n=new Cs(0,0,0);for(const t of e)n.add(t);const i=1/r;n.multiplyByScalar(i);let a=0,o=0,s=0,u=0,c=0,l=0;for(const t of e){const e=ef.copy(t).subtract(n);a+=e.x*e.x,o+=e.x*e.y,s+=e.x*e.z,u+=e.y*e.y,c+=e.y*e.z,l+=e.z*e.z}a*=i,o*=i,s*=i,u*=i,c*=i,l*=i;const h=of;h[0]=a,h[1]=o,h[2]=s,h[3]=o,h[4]=u,h[5]=c,h[6]=s,h[7]=c,h[8]=l;const{unitary:p}=Qp(h,sf),f=t.halfAxes.copy(p);let d=f.getColumn(0,rf),m=f.getColumn(1,nf),g=f.getColumn(2,af),y=-Number.MAX_VALUE,b=-Number.MAX_VALUE,v=-Number.MAX_VALUE,w=Number.MAX_VALUE,_=Number.MAX_VALUE,k=Number.MAX_VALUE;for(const t of e)ef.copy(t),y=Math.max(ef.dot(d),y),b=Math.max(ef.dot(m),b),v=Math.max(ef.dot(g),v),w=Math.min(ef.dot(d),w),_=Math.min(ef.dot(m),_),k=Math.min(ef.dot(g),k);d=d.multiplyByScalar(.5*(w+y)),m=m.multiplyByScalar(.5*(_+b)),g=g.multiplyByScalar(.5*(k+v)),t.center.copy(d).add(m).add(g);const x=tf.set(y-w,b-_,v-k).multiplyByScalar(.5),E=new Ph([x[0],0,0,0,x[1],0,0,0,x[2]]);return t.halfAxes.multiplyRight(E),t}(r),i=function(e,t=new Th){if(!e||0===e.length)return t.fromCenterRadius([0,0,0],0);const r=Lp.copy(e[0]),n=Op.copy(r),i=Ip.copy(r),a=Pp.copy(r),o=Dp.copy(r),s=Mp.copy(r),u=Fp.copy(r);for(const t of e){r.copy(t);const e=r.x,c=r.y,l=r.z;e<n.x&&n.copy(r),e>o.x&&o.copy(r),c<i.y&&i.copy(r),c>s.y&&s.copy(r),l<a.z&&a.copy(r),l>u.z&&u.copy(r)}const c=Np.copy(o).subtract(n).magnitudeSquared(),l=Np.copy(s).subtract(i).magnitudeSquared(),h=Np.copy(u).subtract(a).magnitudeSquared();let p=n,f=o,d=c;l>d&&(d=l,p=i,f=s),h>d&&(d=h,p=a,f=u);const m=zp;m.x=.5*(p.x+f.x),m.y=.5*(p.y+f.y),m.z=.5*(p.z+f.z);let g=Np.copy(f).subtract(m).magnitudeSquared(),y=Math.sqrt(g);const b=Up;b.x=n.x,b.y=i.y,b.z=a.z;const v=qp;v.x=o.x,v.y=s.y,v.z=u.z;const w=Hp.copy(b).add(v).multiplyByScalar(.5);let _=0;for(const t of e){r.copy(t);const e=Np.copy(r).subtract(w).magnitude();e>_&&(_=e);const n=Np.copy(r).subtract(m).magnitudeSquared();if(n>g){const e=Math.sqrt(n);y=.5*(y+e),g=y*y;const t=e-y;m.x=(y*m.x+t*r.x)/e,m.y=(y*m.y+t*r.y)/e,m.z=(y*m.z+t*r.z)/e}}return y<_?(m.to(t.center),t.radius=y):(w.to(t.center),t.radius=_),t}(r);let a=vu.WGS84.cartesianToCartographic(i.center,new Cs),o=vu.WGS84.cartesianToCartographic(n.center,new Cs);return a[2]=a[2]-t.getHeight(a[1],a[0]),o[2]=o[2]-t.getHeight(o[1],o[0]),{mbs:[a[0],a[1],a[2],i.radius],obb:{center:o,halfSize:n.halfSize,quaternion:n.quaternion}}}function ym(e){const t=e[3],r=new Cs(e[0],e[1],e[2]),n=new Ph([t,0,0,0,t,0,0,0,t]);return new xp(r,n)}async function bm(e,t,r={},n={}){const i=function(e){const t="3.3.1"!==e.version?" (worker-utils@3.3.1)":"";return`${e.name}@${e.version}${t}`}(e),a=eo.getWorkerFarm(r),{source:o}=r,s={name:i,source:o};o||(s.url=to(e,r));const u=a.getWorkerPool(s),c=r.jobName||e.name,l=await u.startJob(c,vm.bind(null,n)),h=function e(t){if(null===t)return{};const r=Object.assign({},t);return Object.keys(r).forEach(n=>{"object"!=typeof t[n]||ArrayBuffer.isView(t[n])||t[n]instanceof Array?"function"==typeof r[n]||r[n]instanceof RegExp?r[n]={}:r[n]=t[n]:r[n]=e(t[n])}),r}(r);l.postMessage("process",{input:t,options:h});return(await l.result).result}async function vm(e,t,r,n){switch(r){case"done":t.done(n);break;case"error":t.error(new Error(n.error));break;case"process":const{id:i,input:a,options:o}=n;try{if(!e.process)return void t.postMessage("error",{id:i,error:"Worker not set up to process on main thread"});const r=await e.process(a,o);t.postMessage("done",{id:i,result:r})}catch(e){const r=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:i,error:r})}break;default:console.warn("process-on-worker: unknown message "+r)}}const wm={id:"3d-tiles-attributes",name:"3DTiles Attributes Worker",module:"tile-converter",version:"3.3.1",options:{featureAttributes:null}};const _m="Tile converter does not work in browser, only in node js environment";function km(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class xm{constructor(){km(this,"options",void 0),km(this,"tilesetPath",void 0),km(this,"vertexCounter",void 0),km(this,"conversionStartTime",void 0),km(this,"geoidHeightModel",void 0),km(this,"sourceTileset",void 0),km(this,"attributeStorageInfo",void 0),km(this,"workerSource",{}),this.options={},this.tilesetPath="",this.vertexCounter=0,this.conversionStartTime=[0,0],this.geoidHeightModel=null,this.sourceTileset=null,this.attributeStorageInfo=null,this.workerSource={}}async convert(e){if(Ki)return console.log(_m),_m;const{inputUrl:t,outputPath:r,tilesetName:n,maxDepth:i,egmFilePath:a}=e;this.conversionStartTime=Gi.a.hrtime(),this.options={maxDepth:i},console.log("Loading egm file..."),this.geoidHeightModel=await Jo(a,Ud),console.log("Loading egm file completed!"),await this.loadWorkers();const o=await Jo(t,Bf,{});this.sourceTileset=new Id(o,{loadOptions:{_nodeWorkers:!0,reuseWorkers:!0,"i3s-content-nodejs":{workerUrl:"./modules/i3s/dist/i3s-content-nodejs-worker.js"},i3s:{coordinateSystem:ch.LNGLAT_OFFSETS,decodeTextures:!1}}}),await this.sourceTileset.tilesetInitializationPromise;const s=this.sourceTileset.root;s.header.obb||(s.header.obb=ym(s.header.mbs)),this.tilesetPath=Object(qi.join)(""+r,""+n),this.attributeStorageInfo=o.attributeStorageInfo;try{await cm(this.tilesetPath)}catch(e){}const u={boundingVolume:{box:qd(s.header.obb,this.geoidHeightModel)},geometricError:Gd(s),children:[]};await this._addChildren(s,u,1);const c=Vi()({root:u},{asset:{path:"asset",transform:e=>Vi()(e,{version:{path:"version",default:"1.0"}})},geometricError:{path:"root",transform:e=>e.geometricError},root:{path:"root",transform:e=>Vi()(e,dm())}});await om(this.tilesetPath,JSON.stringify(c),"tileset.json"),this._finishConversion({slpk:!1,outputPath:r,tilesetName:n});eo.getWorkerFarm({}).destroy()}async convertChildNode(e,t,r,n){const i=await this._loadChildNode(e,n);if(e.children.push(i),i.contentUrl){var a;await this.sourceTileset._loadTile(i),this.vertexCounter+=i.content.vertexCount;let e=null;this.attributeStorageInfo&&(e=await this._loadChildAttributes(i,this.attributeStorageInfo)),i.header.obb||(i.header.obb=ym(i.header.mbs));const n={box:qd(i.header.obb,this.geoidHeightModel)},o={boundingVolume:n,geometricError:Gd(i),children:[]},s={tileContent:i.content,textureFormat:null==i||null===(a=i.header)||void 0===a?void 0:a.textureFormat},u=await function(e,t){return bm(wm,e,t)}(s,{source:this.workerSource.tile3dWorkerSource,featureAttributes:e});o.content={uri:i.id+".b3dm",boundingVolume:n},await om(this.tilesetPath,new Uint8Array(u),i.id+".b3dm"),t.children.push(o),i.unloadContent(),await this._addChildren(i,o,r+1)}else await this._addChildren(i,t,r+1)}async _addChildren(e,t,r){if(this.options.maxDepth&&r>this.options.maxDepth)return;const n=[];for(const i of e.header.children||[])n.push(this.convertChildNode(e,t,r,i));await Promise.all(n)}async _loadChildNode(e,t){let r;if(this.sourceTileset.tileset.nodePages)console.log("Node conversion: "+t.id),r=await this.sourceTileset.tileset.nodePagesTile.formTileFromNodePages(t.id);else{const{loader:n}=this.sourceTileset,i=this._relativeUrlToFullUrl(e.url,t.href),a={i3s:{...this.sourceTileset.loadOptions,isTileHeader:!0,loadContent:!1}};console.log("Node conversion: "+i),r=await Jo(i,n,a)}return new _d(this.sourceTileset,r,e)}_relativeUrlToFullUrl(e,t){let r=e.split("/");const n=t.split("/");for(const e of n)switch(e){case".":continue;case"..":r=r.slice(0,-1);break;default:r.push(e)}return r.join("/")}async _loadChildAttributes(e,t){const r=[],{attributeUrls:n}=e.header;for(let e=0;e<n.length;e++){const i=n[e],a=t[e],o={attributeName:a.name,attributeType:this._getAttributeType(a)};r.push(Jo(i,fh,o))}const i=await Promise.all(r);return this._replaceNestedArrays(i),Object.assign({},...i)}_getAttributeType(e){return e.attributeValues?e.attributeValues.valueType:e.objectIds?"Oid32":""}_replaceNestedArrays(e){for(let t=0;t<e.length;t++){const r=e[t];for(const e in r)r[e]=Array.from(r[e])}}async _finishConversion(e){const t=await fm(e),r=pm(Gi.a.hrtime(this.conversionStartTime));console.log("------------------------------------------------"),console.log("Finish conversion of I3S"),console.log("Total conversion time: "+r),console.log("Vertex count: ",this.vertexCounter),console.log("File(s) size: ",t," bytes"),console.log("------------------------------------------------")}async loadWorkers(){console.log("Loading workers source...");const e=to(wm,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.tile3dWorkerSource=r,console.log("Loading workers source completed!")}}async function Em(e,t,r){if(function(e,t){return!!eo.isSupported()&&(!!(Ki||null!=t&&t._nodeWorkers)&&(e.worker&&(null==t?void 0:t.worker)))}(t,r={...Aa(),...r}))return await bm(t,e,r);if(t.encode)return await t.encode(e,r);if(t.encodeSync)return t.encodeSync(e,r);if(t.encodeText)return(new TextEncoder).encode(await t.encodeText(e,r));if(t.encodeInBatches){const n=function(e,t,r){if(t.encodeInBatches){const n=function(e){return[{table:e,start:0,end:e.length}]}(e);return t.encodeInBatches(n,r)}throw new Error("Writer could not encode data in batches")}(e,t,r),i=[];for await(const e of n)i.push(e);return io(...i)}if(!Ki&&t.encodeURLtoURL){const n=Sm("input");await async function(e,t,r){e=ca(e),Ki||await i.writeFile(e,ho(t),{flag:"w"}),ia(!1)}(n,e);const a=Sm("output"),o=await async function(e,t,r,n){if(e=ca(e),t=ca(t),Ki||!r.encodeURLtoURL)throw new Error;return await r.encodeURLtoURL(e,t,n)}(n,a,t,r);return(await va(o)).arrayBuffer()}throw new Error("Writer could not encode data")}function Sm(e){return"/tmp/"+e}const Am={COMPOSITE:"cmpt",POINT_CLOUD:"pnts",BATCHED_3D_MODEL:"b3dm",INSTANCED_3D_MODEL:"i3dm",GEOMETRY:"geom",VECTOR:"vect",GLTF:"glTF"};Object.keys(Am);function jm(e,t,r){ia(e instanceof ArrayBuffer);const n=new TextDecoder("utf8"),i=new Uint8Array(e,t,r);return n.decode(i)}const Cm={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DOUBLE:5130},Tm={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,...Cm},Bm={[Cm.DOUBLE]:Float64Array,[Cm.FLOAT]:Float32Array,[Cm.UNSIGNED_SHORT]:Uint16Array,[Cm.UNSIGNED_INT]:Uint32Array,[Cm.UNSIGNED_BYTE]:Uint8Array,[Cm.BYTE]:Int8Array,[Cm.SHORT]:Int16Array,[Cm.INT]:Int32Array},Rm={DOUBLE:Cm.DOUBLE,FLOAT:Cm.FLOAT,UNSIGNED_SHORT:Cm.UNSIGNED_SHORT,UNSIGNED_INT:Cm.UNSIGNED_INT,UNSIGNED_BYTE:Cm.UNSIGNED_BYTE,BYTE:Cm.BYTE,SHORT:Cm.SHORT,INT:Cm.INT};class Om{static fromTypedArray(e){e=ArrayBuffer.isView(e)?e.constructor:e;for(const t in Bm){if(Bm[t]===e)return t}throw new Error("Failed to convert GL type")}static fromName(e){const t=Rm[e];if(!t)throw new Error("Failed to convert GL type");return t}static getArrayType(e){switch(e){case Cm.UNSIGNED_SHORT_5_6_5:case Cm.UNSIGNED_SHORT_4_4_4_4:case Cm.UNSIGNED_SHORT_5_5_5_1:return Uint16Array;default:const t=Bm[e];if(!t)throw new Error("Failed to convert GL type");return t}}static getByteSize(e){return Om.getArrayType(e).BYTES_PER_ELEMENT}static validate(e){return Boolean(Om.getArrayType(e))}static createTypedArray(e,t,r=0,n){void 0===n&&(n=(t.byteLength-r)/Om.getByteSize(e));return new(Om.getArrayType(e))(t,r,n)}}function Im(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Pm{constructor(e,t){Im(this,"json",void 0),Im(this,"buffer",void 0),Im(this,"featuresLength",0),Im(this,"_cachedTypedArrays",{}),this.json=e,this.buffer=t}getExtension(e){return this.json.extensions&&this.json.extensions[e]}hasProperty(e){return Boolean(this.json[e])}getGlobalProperty(e,t=Tm.UNSIGNED_INT,r=1){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?this._getTypedArrayFromBinary(e,t,r,1,n.byteOffset):n}getPropertyArray(e,t,r){const n=this.json[e];return n&&Number.isFinite(n.byteOffset)?("componentType"in n&&(t=Om.fromName(n.componentType)),this._getTypedArrayFromBinary(e,t,r,this.featuresLength,n.byteOffset)):this._getTypedArrayFromArray(e,t,n)}getProperty(e,t,r,n,i){const a=this.json[e];if(!a)return a;const o=this.getPropertyArray(e,t,r);if(1===r)return o[n];for(let e=0;e<r;++e)i[e]=o[r*n+e];return i}_getTypedArrayFromBinary(e,t,r,n,i){const a=this._cachedTypedArrays;let o=a[e];return o||(o=Om.createTypedArray(t,this.buffer.buffer,this.buffer.byteOffset+i,n*r),a[e]=o),o}_getTypedArrayFromArray(e,t,r){const n=this._cachedTypedArrays;let i=n[e];return i||(i=Om.createTypedArray(t,r),n[e]=i),i}}const Dm={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Mm={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]]},Fm={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]}};const Lm=e=>void 0!==e;function Nm(e,t,r){if(!t)return null;let n=e.getExtension("3DTILES_batch_table_hierarchy");const i=t.HIERARCHY;return i&&(console.warn("3D Tile Parser: HIERARCHY is deprecated. Use 3DTILES_batch_table_hierarchy."),t.extensions=t.extensions||{},t.extensions["3DTILES_batch_table_hierarchy"]=i,n=i),n?function(e,t){let r,n,i;const a=e.instancesLength,o=e.classes;let s,u=e.classIds,c=e.parentCounts,l=e.parentIds,h=a;Lm(u.byteOffset)&&(u.componentType=defaultValue(u.componentType,GL.UNSIGNED_SHORT),u.type=AttributeType.SCALAR,i=getBinaryAccessor(u),u=i.createArrayBufferView(t.buffer,t.byteOffset+u.byteOffset,a));if(Lm(c))for(Lm(c.byteOffset)&&(c.componentType=defaultValue(c.componentType,GL.UNSIGNED_SHORT),c.type=AttributeType.SCALAR,i=getBinaryAccessor(c),c=i.createArrayBufferView(t.buffer,t.byteOffset+c.byteOffset,a)),s=new Uint16Array(a),h=0,r=0;r<a;++r)s[r]=h,h+=c[r];Lm(l)&&Lm(l.byteOffset)&&(l.componentType=defaultValue(l.componentType,GL.UNSIGNED_SHORT),l.type=AttributeType.SCALAR,i=getBinaryAccessor(l),l=i.createArrayBufferView(t.buffer,t.byteOffset+l.byteOffset,h));const p=o.length;for(r=0;r<p;++r){const e=o[r].length,n=o[r].instances,i=getBinaryProperties(e,n,t);o[r].instances=combine(i,n)}const f=new Array(p).fill(0),d=new Uint16Array(a);for(r=0;r<a;++r)n=u[r],d[r]=f[n],++f[n];const m={classes:o,classIds:u,classIndexes:d,parentCounts:c,parentIndexes:s,parentIds:l};return function(e){const t=e.classIds.length;for(let r=0;r<t;++r)Um(e,r,stack)}(m),m}(n,r):null}function zm(e,t,r){if(!e)return;const n=e.parentCounts;return e.parentIds?r(e,t):n>0?function(e,t,r){const n=e.classIds,i=e.parentCounts,a=e.parentIds,o=e.parentIndexes,s=n.length,u=scratchVisited;u.length=Math.max(u.length,s);const c=++marker,l=scratchStack;l.length=0,l.push(t);for(;l.length>0;){if(t=l.pop(),u[t]===c)continue;u[t]=c;const n=r(e,t);if(Lm(n))return n;const s=i[t],h=o[t];for(let e=0;e<s;++e){const r=a[h+e];r!==t&&l.push(r)}}return null}(e,t,r):function(e,t,r){let n=!0;for(;n;){const i=r(e,t);if(Lm(i))return i;const a=e.parentIds[t];n=a!==t,t=a}throw new Error("traverseHierarchySingleParent")}(e,t,r)}function Um(e,t,r){const n=e.parentCounts,i=e.parentIds,a=e.parentIndexes,o=e.classIds.length;if(!Lm(i))return;assert(t<o,`Parent index ${t} exceeds the total number of instances: ${o}`),assert(-1===r.indexOf(t),"Circular dependency detected in the batch table hierarchy."),r.push(t);const s=Lm(n)?n[t]:1,u=Lm(n)?a[t]:t;for(let n=0;n<s;++n){const a=i[u+n];a!==t&&Um(e,a,r)}r.pop(t)}function qm(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Hm(e){return null!=e}const Gm=(e,t)=>e,Wm={HIERARCHY:!0,extensions:!0,extras:!0};class Vm{constructor(e,t,r,n={}){var i;qm(this,"json",void 0),qm(this,"binary",void 0),qm(this,"featureCount",void 0),qm(this,"_extensions",void 0),qm(this,"_properties",void 0),qm(this,"_binaryProperties",void 0),qm(this,"_hierarchy",void 0),ia(r>=0),this.json=e||{},this.binary=t,this.featureCount=r,this._extensions=(null===(i=this.json)||void 0===i?void 0:i.extensions)||{},this._properties={};for(const e in this.json)Wm[e]||(this._properties[e]=this.json[e]);this._binaryProperties=this._initializeBinaryProperties(),n["3DTILES_batch_table_hierarchy"]&&(this._hierarchy=Nm(this,this.json,this.binary))}getExtension(e){return this.json&&this.json.extensions&&this.json.extensions[e]}memorySizeInBytes(){return 0}isClass(e,t){if(this._checkBatchId(e),ia("string"==typeof t,t),this._hierarchy){return Hm(zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r];return e.classes[n].name===t}))}return!1}isExactClass(e,t){return ia("string"==typeof t,t),this.getExactClassName(e)===t}getExactClassName(e){if(this._checkBatchId(e),this._hierarchy){const t=this._hierarchy.classIds[e];return this._hierarchy.classes[t].name}}hasProperty(e,t){return this._checkBatchId(e),ia("string"==typeof t,t),Hm(this._properties[t])||this._hasPropertyInHierarchy(e,t)}getPropertyNames(e,t){this._checkBatchId(e),(t=Hm(t)?t:[]).length=0;const r=Object.keys(this._properties);return t.push(...r),this._hierarchy&&this._getPropertyNamesInHierarchy(e,t),t}getProperty(e,t){if(this._checkBatchId(e),ia("string"==typeof t,t),this._binaryProperties){const r=this._binaryProperties[t];if(Hm(r))return this._getBinaryProperty(r,e)}const r=this._properties[t];if(Hm(r))return Gm(r[e]);if(this._hierarchy){const r=this._getHierarchyProperty(e,t);if(Hm(r))return r}}setProperty(e,t,r){const n=this.featureCount;if(this._checkBatchId(e),ia("string"==typeof t,t),this._binaryProperties){const n=this._binaryProperties[t];if(n)return void this._setBinaryProperty(n,e,r)}if(this._hierarchy&&this._setHierarchyProperty(this,e,t,r))return;let i=this._properties[t];Hm(i)||(this._properties[t]=new Array(n),i=this._properties[t]),i[e]=Gm(r)}_checkBatchId(e){if(!(e>=0&&e<this.featureCount))throw new Error("batchId not in range [0, featureCount - 1].")}_getBinaryProperty(e,t){return e.unpack(e.typedArray,t)}_setBinaryProperty(e,t,r){e.pack(r,e.typedArray,t)}_initializeBinaryProperties(){let e=null;for(const t in this._properties){const r=this._properties[t],n=this._initializeBinaryProperty(t,r);n&&(e=e||{},e[t]=n)}return e}_initializeBinaryProperty(e,t){if("byteOffset"in t){const r=t;ia(this.binary,`Property ${e} requires a batch table binary.`),ia(r.type,`Property ${e} requires a type.`);const n=function(e,t,r,n){const{componentType:i}=e;ia(e.componentType);const a="string"==typeof i?Om.fromName(i):i,o=Dm[e.type],s=Mm[e.type],u=Fm[e.type];return r+=e.byteOffset,{values:Om.createTypedArray(a,t,r,o*n),type:a,size:o,unpacker:s,packer:u}}(r,this.binary.buffer,0|this.binary.byteOffset,this.featureCount);return{typedArray:n.values,componentCount:n.size,unpack:n.unpacker,pack:n.packer}}return null}_hasPropertyInHierarchy(e,t){if(!this._hierarchy)return!1;const r=zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r];return Hm(e.classes[n].instances[t])});return Hm(r)}_getPropertyNamesInHierarchy(e,t){zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r],i=e.classes[n].instances;for(const e in i)i.hasOwnProperty(e)&&-1===t.indexOf(e)&&t.push(e)})}_getHierarchyProperty(e,t){return zm(this._hierarchy,e,(e,r)=>{const n=e.classIds[r],i=e.classes[n],a=e.classIndexes[r],o=i.instances[t];return Hm(o)?Hm(o.typedArray)?this._getBinaryProperty(o,a):Gm(o[a]):null})}_setHierarchyProperty(e,t,r,n){const i=zm(this._hierarchy,t,(e,i)=>{const a=e.classIds[i],o=e.classes[a],s=e.classIndexes[i],u=o.instances[r];return!!Hm(u)&&(ia(i===t,`Inherited property "${r}" is read-only.`),Hm(u.typedArray)?this._setBinaryProperty(u,s,n):u[s]=Gm(n),!0)});return Hm(i)}}function Km(e,t,r=0){const 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,1!==e.version)throw new Error(`3D Tile Version ${e.version} not supported`);return r}function Jm(e,t,r){const n=new DataView(t);let i;e.header=e.header||{};let a=n.getUint32(r,!0);r+=4;let o=n.getUint32(r,!0);r+=4;let s=n.getUint32(r,!0);r+=4;let u=n.getUint32(r,!0);return r+=4,s>=570425344?(r-=8,i=a,s=o,u=0,a=0,o=0,console.warn("b3dm tile in legacy format.")):u>=570425344&&(r-=4,i=s,s=a,u=o,a=0,o=0,console.warn("b3dm tile in legacy format.")),e.header.featureTableJsonByteLength=a,e.header.featureTableBinaryByteLength=o,e.header.batchTableJsonByteLength=s,e.header.batchTableBinaryByteLength=u,e.header.batchLength=i,r}function Qm(e,t,r,n){return r=function(e,t,r,n){const{featureTableJsonByteLength:i,featureTableBinaryByteLength:a,batchLength:o}=e.header;if(e.featureTableJson={BATCH_LENGTH:o||0},i>0){const n=jm(t,r,i);e.featureTableJson=JSON.parse(n)}return r+=i,e.featureTableBinary=new Uint8Array(t,r,a),r+=a}(e,t,r),r=function(e,t,r,n){const{batchTableJsonByteLength:i,batchTableBinaryByteLength:a}=e.header;if(i>0){const n=jm(t,r,i);e.batchTableJson=JSON.parse(n),r+=i,a>0&&(e.batchTableBinary=new Uint8Array(t,r,a),e.batchTableBinary=new Uint8Array(e.batchTableBinary),r+=a)}return r}(e,t,r)}function $m(e,t=[0,0,0]){const r=e>>11&31,n=e>>5&63,i=31&e;return t[0]=r<<3,t[1]=n<<2,t[2]=i<<3,t}function Ym(e,t,r){if(!(t||e&&e.batchIds&&r))return null;const{batchIds:n,isRGB565:i,pointCount:a}=e;if(n&&r){const e=new Uint8ClampedArray(3*a);for(let t=0;t<a;t++){const i=n[t],a=r.getProperty(i,"dimensions").map(e=>255*e);e[3*t]=a[0],e[3*t+1]=a[1],e[3*t+2]=a[2]}return{type:Tm.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}if(i){const e=new Uint8ClampedArray(3*a);for(let r=0;r<a;r++){const n=$m(t[r]);e[3*r]=n[0],e[3*r+1]=n[1],e[3*r+2]=n[2]}return{type:Tm.UNSIGNED_BYTE,value:e,size:3,normalized:!0}}return t&&t.length===3*a?{type:Tm.UNSIGNED_BYTE,value:t,size:3,normalized:!0}:{type:Tm.UNSIGNED_BYTE,value:t,size:4,normalized:!0}}function Xm(e,t){if(!e)throw new Error("math.gl assertion failed. "+t)}new Rp,new Cs,new Rp,new Rp,new Uint8Array(1);function Zm(e,t=255){return is(e,0,t)/t*2-1}function eg(e){return e<0?-1:1}function tg(e,t,r,n){if(Xm(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=Zm(e,r),n.y=Zm(t,r),n.z=1-(Math.abs(n.x)+Math.abs(n.y)),n.z<0){const e=n.x;n.x=(1-Math.abs(n.y))*eg(e),n.y=(1-Math.abs(e))*eg(n.y)}return n.normalize()}function rg(e,t,r){return tg(e,t,255,r)}const ng=new Cs;function ig(e,t,r){return e.isQuantized?r["3d-tiles"]&&r["3d-tiles"].decodeQuantizedPositions?(e.isQuantized=!1,function(e,t){const r=new Cs,n=new Float32Array(3*e.pointCount);for(let i=0;i<e.pointCount;i++)r.set(t[3*i],t[3*i+1],t[3*i+2]).scale(1/e.quantizedRange).multiply(e.quantizedVolumeScale).add(e.quantizedVolumeOffset).toArray(n,3*i);return n}(e,t)):{type:Tm.UNSIGNED_SHORT,value:t,size:3,normalized:!0}:t}async function ag(e,t,r,n,i){r=Qm(e,t,r=Jm(e,t,r=Km(e,t,r))),function(e){e.attributes={positions:null,colors:null,normals:null,batchIds:null},e.isQuantized=!1,e.isTranslucent=!1,e.isRGB565=!1,e.isOctEncoded16P=!1}(e);const{featureTable:a,batchTable:o}=function(e){const t=new Pm(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",Tm.FLOAT,3);const n=function(e,t){let r=null;if(!e.batchIds&&t.hasProperty("BATCH_ID")&&(e.batchIds=t.getPropertyArray("BATCH_ID",Tm.UNSIGNED_SHORT,1),e.batchIds)){const n=t.getGlobalProperty("BATCH_LENGTH");if(!n)throw new Error("Global property: BATCH_LENGTH must be defined when BATCH_ID is defined.");const{batchTableJson:i,batchTableBinary:a}=e;r=new Vm(i,a,n)}return r}(e,t);return{featureTable:t,batchTable:n}}(e);return await async function(e,t,r,n,i){let a,o,s;const u=e.batchTableJson&&e.batchTableJson.extensions&&e.batchTableJson.extensions["3DTILES_draco_point_compression"];u&&(s=u.properties);const c=t.getExtension("3DTILES_draco_point_compression");if(c){o=c.properties;const t=c.byteOffset,r=c.byteLength;if(!o||!Number.isFinite(t)||!r)throw new Error("Draco properties, byteOffset, and byteLength must be defined");a=e.featureTableBinary.slice(t,t+r),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(!a)return!0;const l={buffer:a,properties:{...o,...s},featureTableProperties:o,batchTableProperties:s,dequantizeInShader:!1};return await async function(e,t,r,n){const{parse:i}=n,a={...r,draco:{...r.draco,extraAttributes:t.batchTableProperties||{}}};delete a["3d-tiles"];const o=await i(t.buffer,Tc,a),s=o.attributes.POSITION&&o.attributes.POSITION.value,u=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,h=s&&o.attributes.POSITION.value.quantization,p=c&&o.attributes.NORMAL.value.quantization;if(h){const t=o.POSITION.data.quantization,r=t.range;e.quantizedVolumeScale=new Cs(r,r,r),e.quantizedVolumeOffset=new Cs(t.minValues),e.quantizedRange=(1<<t.quantizationBits)-1,e.isQuantizedDraco=!0}p&&(e.octEncodedRange=(1<<o.NORMAL.data.quantization.quantizationBits)-1,e.isOctEncodedDraco=!0);const f={};if(t.batchTableProperties)for(const e of Object.keys(t.batchTableProperties))o.attributes[e]&&o.attributes[e].value&&(f[e.toLowerCase()]=o.attributes[e].value);e.attributes={positions:s,colors:Ym(e,u,void 0),normals:c,batchIds:l,...f}}(e,l,n,i)}(e,a,0,n,i),function(e,t,r){if(!e.attributes.positions)if(t.hasProperty("POSITION"))e.attributes.positions=t.getPropertyArray("POSITION",Tm.FLOAT,3);else if(t.hasProperty("POSITION_QUANTIZED")){const n=t.getPropertyArray("POSITION_QUANTIZED",Tm.UNSIGNED_SHORT,3);if(e.isQuantized=!0,e.quantizedRange=65535,e.quantizedVolumeScale=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Tm.FLOAT,3),!e.quantizedVolumeScale)throw new Error("QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");if(e.quantizedVolumeOffset=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Tm.FLOAT,3),!e.quantizedVolumeOffset)throw new Error("QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");e.attributes.positions=ig(e,n,r)}if(!e.attributes.positions)throw new Error("Either POSITION or POSITION_QUANTIZED must be defined.")}(e,a,n),function(e,t,r){if(!e.attributes.colors){let n=null;t.hasProperty("RGBA")?(n=t.getPropertyArray("RGBA",Tm.UNSIGNED_BYTE,4),e.isTranslucent=!0):t.hasProperty("RGB")?n=t.getPropertyArray("RGB",Tm.UNSIGNED_BYTE,3):t.hasProperty("RGB565")&&(n=t.getPropertyArray("RGB565",Tm.UNSIGNED_SHORT,1),e.isRGB565=!0),e.attributes.colors=Ym(e,n,r)}t.hasProperty("CONSTANT_RGBA")&&(e.constantRGBA=t.getGlobalProperty("CONSTANT_RGBA",Tm.UNSIGNED_BYTE,4))}(e,a,o),function(e,t){if(!e.attributes.normals){let r=null;t.hasProperty("NORMAL")?r=t.getPropertyArray("NORMAL",Tm.FLOAT,3):t.hasProperty("NORMAL_OCT16P")&&(r=t.getPropertyArray("NORMAL_OCT16P",Tm.UNSIGNED_BYTE,2),e.isOctEncoded16P=!0),e.attributes.normals=function(e,t){if(!t)return null;if(e.isOctEncoded16P){const r=new Float32Array(3*e.pointsLength);for(let n=0;n<e.pointsLength;n++)rg(t[2*n],t[2*n+1],ng),ng.toArray(r,3*n);return{type:Tm.FLOAT,size:2,value:r}}return{type:Tm.FLOAT,size:2,value:t}}(e,r)}}(e,a),r}function og(e,t,r){if(e.byteLength<=t+r)return"";const n=new DataView(e);let i="";for(let e=0;e<r;e++)i+=String.fromCharCode(n.getUint8(t+e));return i}function sg(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return og(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return og(e,0,t)}return""}(e)}"`)}}function ug(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function cg(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const 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}function lg(e,t,r){const n=e.bufferViews[r];ug(n);const i=t[n.buffer];ug(i);const a=(n.byteOffset||0)+i.byteOffset;return new Uint8Array(i.arrayBuffer,a,n.byteLength)}function hg(e,t){return ia(e>=0),ia(t>0),e+(t-1)&~(t-1)}function pg(e,t,r){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;n=new Uint8Array(e.buffer||e.arrayBuffer,t,r)}return t.set(n,r),r+hg(n.byteLength,4)}const fg=["SCALAR","VEC2","VEC3","VEC4"],dg=[[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126],[Float64Array,5130]],mg=new Map(dg),gg={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},yg={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},bg={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function vg(e){return fg[e-1]||fg[0]}function wg(e){const t=mg.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function _g(e,t){const r=bg[e.componentType],n=gg[e.type],i=yg[e.componentType],a=e.count*n,o=e.count*n*i;return ug(o>=0&&o<=t.byteLength),{ArrayType:r,length:a,byteLength:o}}function kg(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const xg={asset:{version:"2.0",generator:"loaders.gl"},buffers:[]};class Eg{constructor(e){kg(this,"gltf",void 0),kg(this,"sourceBuffers",void 0),kg(this,"byteLength",void 0),this.gltf=e||{json:{...xg},buffers:[]},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(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),r=this.json.extensions||{};return t?r[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getRemovedExtensions(){return this.json.extensionsRemoved||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];if(!r)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return r}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,r=this.gltf.buffers[t];ug(r);const n=(e.byteOffset||0)+r.byteOffset;return new Uint8Array(r.arrayBuffer,n,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,{ArrayType:n,length:i}=_g(e,t);return new n(r,t.byteOffset+e.byteOffset,i)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),r=this.getBuffer(t.buffer).data,n=t.byteOffset||0;return new Uint8Array(r,n,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addObjectExtension(e,t,r){return e.extensions=e.extensions||{},e.extensions[t]=r,this.registerUsedExtension(t),this}setObjectExtension(e,t,r){(e.extensions||{})[t]=r}removeObjectExtension(e,t){const r=e.extensions||{},n=r[t];return delete r[t],n}addExtension(e,t={}){return ug(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),t}addRequiredExtension(e,t={}){return ug(t),this.addExtension(e,t),this.registerRequiredExtension(e),t}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){if(!this.getExtension(e))return;this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e],Array.isArray(this.json.extensionsRemoved)||(this.json.extensionsRemoved=[]);const t=this.json.extensionsRemoved;t.includes(e)||t.push(e)}setDefaultScene(e){this.json.scene=e}addScene(e){const{nodeIndices:t}=e;return this.json.scenes=this.json.scenes||[],this.json.scenes.push({nodes:t}),this.json.scenes.length-1}addNode(e){const{meshIndex:t,matrix:r}=e;this.json.nodes=this.json.nodes||[];const n={mesh:t};return r&&(n.matrix=r),this.json.nodes.push(n),this.json.nodes.length-1}addMesh(e){const{attributes:t,indices:r,material:n,mode:i=4}=e,a={primitives:[{attributes:this._addAttributes(t),mode:i}]};if(r){const e=this._addIndices(r);a.primitives[0].indices=e}return Number.isFinite(n)&&(a.primitives[0].material=n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){const r=Mu(e),n=t||(null==r?void 0:r.mimeType),i={bufferView:this.addBufferView(e),mimeType:n};return this.json.images=this.json.images||[],this.json.images.push(i),this.json.images.length-1}addBufferView(e){const t=e.byteLength;ug(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=hg(t,4),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const r={bufferView:e,type:vg(t.size),componentType:t.componentType,count:t.count,max:t.max,min:t.min};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const r=this.addBufferView(e);let n={min:t.min,max:t.max};n.min&&n.max||(n=this._getAccessorMinMax(e,t.size));const i={size:t.size,componentType:wg(e),count:Math.round(e.length/t.size),min:n.min,max:n.max};return this.addAccessor(r,Object.assign(i,t))}addTexture(e){const{imageIndex:t}=e,r={source:t};return this.json.textures=this.json.textures||[],this.json.textures.push(r),this.json.textures.length-1}addMaterial(e){return this.json.materials=this.json.materials||[],this.json.materials.push(e),this.json.materials.length-1}createBinaryChunk(){var e,t;this.gltf.buffers=[];const r=this.byteLength,n=new ArrayBuffer(r),i=new Uint8Array(n);let a=0;for(const e of this.sourceBuffers||[])a=pg(e,i,a);null!==(e=this.json)&&void 0!==e&&null!==(t=e.buffers)&&void 0!==t&&t[0]?this.json.buffers[0].byteLength=r:this.json.buffers=[{byteLength:r}],this.gltf.binary=n,this.sourceBuffers=[n]}_removeStringFromArray(e,t){let r=!0;for(;r;){const n=e.indexOf(t);n>-1?e.splice(n,1):r=!1}}_addAttributes(e={}){const t={};for(const r in e){const n=e[r],i=this._getGltfAttributeName(r),a=this.addBinaryBuffer(n.value,n);t[i]=a}return t}_addIndices(e){return this.addBinaryBuffer(e,{size:1})}_getGltfAttributeName(e){switch(e.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 e}}_getAccessorMinMax(e,t){const r={min:null,max:null};if(e.length<t)return r;r.min=[],r.max=[];const n=e.subarray(0,t);for(const e of n)r.min.push(e),r.max.push(e);for(let n=t;n<e.length;n+=t)for(let i=0;i<t;i++)r.min[0+i]=Math.min(r.min[0+i],e[n+i]),r.max[0+i]=Math.max(r.max[0+i],e[n+i]);return r}}const Sg=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]),Ag=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]),jg={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},Cg={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};let Tg;async function Bg(){return Tg||(Tg=async function(){let e="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";WebAssembly.validate(Sg)&&(e="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",console.log("Warning: meshopt_decoder is using experimental SIMD support"));const t=await WebAssembly.instantiate(function(e){const t=new Uint8Array(e.length);for(let r=0;r<e.length;++r){const n=e.charCodeAt(r);t[r]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let n=0;n<e.length;++n)t[r++]=t[n]<60?Ag[t[n]]:64*(t[n]-60)+t[++n];return t.buffer.slice(0,r)}(e),{});return await t.instance.exports.__wasm_call_ctors(),t.instance}()),Tg}function Rg(e,t,r,n,i,a,o){const s=e.exports.sbrk,u=n+3&-4,c=s(u*i),l=s(a.length),h=new Uint8Array(e.exports.memory.buffer);h.set(a,l);const p=t(c,n,i,l,a.length);if(0===p&&o&&o(c,u,i),r.set(h.subarray(c,c+n*i)),s(c-s(0)),0!==p)throw new Error("Malformed buffer data: "+p)}const Og="EXT_meshopt_compression";async function Ig(e,t){var r;const n=new Eg(e);if(null==t||null===(r=t.gltf)||void 0===r||!r.decompressMeshes)return;const i=[];for(const t of e.json.bufferViews||[])i.push(Pg(n,t));await Promise.all(i),n.removeExtension("EXT_meshopt_compression")}async function Pg(e,t){const r=e.getObjectExtension(t,"EXT_meshopt_compression");if(r){const{byteOffset:n=0,byteLength:i=0,byteStride:a,count:o,mode:s,filter:u="NONE",buffer:c}=r,l=e.gltf.buffers[c],h=new Uint8Array(l.arrayBuffer,l.byteOffset+n,i),p=new Uint8Array(e.gltf.buffers[t.buffer].arrayBuffer,t.byteOffset,t.byteLength);return await async function(e,t,r,n,i,a="NONE"){const o=await Bg();Rg(o,o.exports[Cg[i]],e,t,r,n,o.exports[jg[a||"NONE"]])}(p,o,a,h,s,u),p}return null}const Dg=["image/png","image/jpeg","image/gif"],Mg={};function Fg(e){return void 0===Mg[e]&&(Mg[e]=function(e){switch(e){case"image/webp":return function(){if(!Ki)return!1;try{return 0===document.createElement("canvas").toDataURL("image/webp").indexOf("data:image/webp")}catch{return!1}}();case"image/svg":return Ki;default:if(!Ki){const{_parseImageNode:t}=globalThis;return Boolean(t)&&Dg.includes(e)}return!0}}(e)),Mg[e]}const Lg="EXT_texture_webp";function Ng(e,t){const r=new Eg(e);if(!Fg("image/webp")){if(r.getRequiredExtensions().includes("EXT_texture_webp"))throw new Error("gltf: Required extension EXT_texture_webp not supported by browser");return}const{json:n}=r;for(const e of n.textures||[]){const t=r.getObjectExtension(e,"EXT_texture_webp");t&&(e.source=t.source),r.removeObjectExtension(e,"EXT_texture_webp")}r.removeExtension("EXT_texture_webp")}const zg="KHR_texture_basisu";function Ug(e,t){const r=new Eg(e),{json:n}=r;for(const e of n.textures||[]){const t=r.getObjectExtension(e,"KHR_texture_basisu");t&&(e.source=t.source),r.removeObjectExtension(e,"KHR_texture_basisu")}r.removeExtension("KHR_texture_basisu")}function qg(e){const{buffer:t,size:r,count:n}=function(e){let t=e,r=1,n=0;e&&e.value&&(t=e.value,r=e.size||1);t&&(ArrayBuffer.isView(t)||(t=function(e,t,r=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(r&&!(e instanceof t))return new t(e);return e}(t,Float32Array)),n=t.length/r);return{buffer:t,size:r,count:n}}(e);return{value:t,size:r,byteOffset:0,count:n,type:vg(r),componentType:wg(t)}}const Hg="KHR_draco_mesh_compression";function Gg(e,t,r){const n=new Eg(e);for(const e of Qg(n))n.getObjectExtension(e,"KHR_draco_mesh_compression")}async function Wg(e,t,r){var n;if(null==t||null===(n=t.gltf)||void 0===n||!n.decompressMeshes)return;const i=new Eg(e),a=[];for(const e of Qg(i))i.getObjectExtension(e,"KHR_draco_mesh_compression")&&a.push(Kg(i,e,t,r));await Promise.all(a),i.removeExtension("KHR_draco_mesh_compression")}function Vg(e,t={}){const r=new Eg(e);for(const e of r.json.meshes||[])Jg(e,t),r.addRequiredExtension("KHR_draco_mesh_compression")}async function Kg(e,t,r,n){const i=e.getObjectExtension(t,"KHR_draco_mesh_compression");if(!i)return;const a=e.getTypedArrayForBufferView(i.bufferView),o=oo(a.buffer,a.byteOffset),{parse:s}=n,u={...r};delete u["3d-tiles"];const c=await s(o,Tc,u,n),l=function(e){const t={};for(const r in e){const n=e[r];if("indices"!==r){const e=qg(n);t[r]=e}}return t}(c.attributes);for(const[r,n]of Object.entries(l))if(r in t.attributes){const i=t.attributes[r],a=e.getAccessor(i);null!=a&&a.min&&null!=a&&a.max&&(n.min=a.min,n.max=a.max)}t.attributes=l,c.indices&&(t.indices=qg(c.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("glTF: Empty primitive detected: Draco decompression failure?")}(t)}function Jg(e,t,r=4,n,i){var a;if(!n.DracoWriter)throw new Error("options.gltf.DracoWriter not provided");const o=n.DracoWriter.encodeSync({attributes:e}),s=null==i||null===(a=i.parseSync)||void 0===a?void 0:a.call(i,{attributes:e}),u=n._addFauxAttributes(s.attributes);return{primitives:[{attributes:u,mode:r,extensions:{KHR_draco_mesh_compression:{bufferView:n.addBufferView(o),attributes:u}}}]}}function*Qg(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}const $g={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Yg={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};const Xg="KHR_texture_transform",Zg=new Cs,ey=new Ph,ty=new Ph;async function ry(e,t){if(!new Eg(e).getExtension("KHR_texture_transform"))return;const r=e.json.materials||[];for(let t=0;t<r.length;t++)ny(t,e)}function ny(e,t){var r,n,i;const a=[],o=null===(r=t.json.materials)||void 0===r?void 0:r[e],s=null==o||null===(n=o.pbrMetallicRoughness)||void 0===n?void 0:n.baseColorTexture;s&&iy(t,e,s,a);const u=null==o?void 0:o.emissiveTexture;u&&iy(t,e,u,a);const c=null==o?void 0:o.normalTexture;c&&iy(t,e,c,a);const l=null==o?void 0:o.occlusionTexture;l&&iy(t,e,l,a);const h=null==o||null===(i=o.pbrMetallicRoughness)||void 0===i?void 0:i.metallicRoughnessTexture;h&&iy(t,e,h,a)}function iy(e,t,r,n){const i=function(e,t){var r;const n=null===(r=e.extensions)||void 0===r?void 0:r.KHR_texture_transform,{texCoord:i=0}=e,{texCoord:a=i}=n;if(-1===t.findIndex(([e,t])=>e===i&&t===a)){const r=function(e){const{offset:t=[0,0],rotation:r=0,scale:n=[1,1]}=e,i=(new Ph).set(1,0,0,0,1,0,t[0],t[1],1),a=ey.set(Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1),o=ty.set(n[0],0,0,0,n[1],0,0,0,1);return i.multiplyRight(a).multiplyRight(o)}(n);return i!==a&&(e.texCoord=a),t.push([i,a]),{originalTexCoord:i,texCoord:a,matrix:r}}return null}(r,n);if(!i)return;const a=e.json.meshes||[];for(const r of a)for(const n of r.primitives){const r=n.material;Number.isFinite(r)&&t===r&&ay(e,n,i)}}function ay(e,t,r){const{originalTexCoord:n,texCoord:i,matrix:a}=r,o=t.attributes["TEXCOORD_"+n];if(Number.isFinite(o)){var s;const r=null===(s=e.json.accessors)||void 0===s?void 0:s[o];if(r&&r.bufferView){var u;const o=null===(u=e.json.bufferViews)||void 0===u?void 0:u[r.bufferView];if(o){const{arrayBuffer:s,byteOffset:u}=e.buffers[o.buffer],c=(u||0)+(r.byteOffset||0)+(o.byteOffset||0),{ArrayType:l,length:h}=_g(r,o),p=Yg[r.componentType],f=$g[r.type],d=o.byteStride||p*f,m=new Float32Array(h);for(let e=0;e<r.count;e++){const t=new l(s,c+e*d,2);Zg.set(t[0],t[1],1),Zg.transformByMatrix3(a),m.set([Zg[0],Zg[1]],e*f)}n===i?function(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}(r,o,e.buffers,m):function(e,t,r,n,i){n.buffers.push({arrayBuffer:i.buffer,byteOffset:0,byteLength:i.buffer.byteLength});const a=n.json.bufferViews;if(!a)return;a.push({buffer:n.buffers.length-1,byteLength:i.buffer.byteLength,byteOffset:0});const o=n.json.accessors;if(!o)return;o.push({bufferView:(null==a?void 0:a.length)-1,byteOffset:0,componentType:5126,count:t.count,type:"VEC2"}),r.attributes["TEXCOORD_"+e]=o.length-1}(i,r,t,e,m)}}}}const oy="KHR_lights_punctual";async function sy(e){const t=new Eg(e),{json:r}=t,n=t.getExtension("KHR_lights_punctual");n&&(t.json.lights=n.lights,t.removeExtension("KHR_lights_punctual"));for(const e of r.nodes||[]){const r=t.getObjectExtension(e,"KHR_lights_punctual");r&&(e.light=r.light),t.removeObjectExtension(e,"KHR_lights_punctual")}}async function uy(e){const t=new Eg(e),{json:r}=t;if(r.lights){const e=t.addExtension("KHR_lights_punctual");ug(!e.lights),e.lights=r.lights,delete r.lights}if(t.json.lights){for(const e of t.json.lights){const r=e.node;t.addObjectExtension(r,"KHR_lights_punctual",e)}delete t.json.lights}}const cy="KHR_materials_unlit";async function ly(e){const t=new Eg(e),{json:r}=t;for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),t.removeObjectExtension(e,"KHR_materials_unlit")}t.removeExtension("KHR_materials_unlit")}function hy(e){const t=new Eg(e),{json:r}=t;if(t.materials)for(const e of r.materials||[])e.unlit&&(delete e.unlit,t.addObjectExtension(e,"KHR_materials_unlit",{}),t.addExtension("KHR_materials_unlit"))}const py="KHR_techniques_webgl";async function fy(e){const t=new Eg(e),{json:r}=t,n=t.getExtension("KHR_techniques_webgl");if(n){const e=function(e,t){const{programs:r=[],shaders:n=[],techniques:i=[]}=e,a=new TextDecoder;return n.forEach(e=>{if(!Number.isFinite(e.bufferView))throw new Error("KHR_techniques_webgl: no shader code");e.code=a.decode(t.getTypedArrayForBufferView(e.bufferView))}),r.forEach(e=>{e.fragmentShader=n[e.fragmentShader],e.vertexShader=n[e.vertexShader]}),i.forEach(e=>{e.program=r[e.program]}),i}(n,t);for(const n of r.materials||[]){const r=t.getObjectExtension(n,"KHR_techniques_webgl");r&&(n.technique=Object.assign({},r,e[r.technique]),n.technique.values=my(n.technique,t)),t.removeObjectExtension(n,"KHR_techniques_webgl")}t.removeExtension("KHR_techniques_webgl")}}async function dy(e,t){}function my(e,t){const r=Object.assign({},e.values);return Object.keys(e.uniforms||{}).forEach(t=>{e.uniforms[t].value&&!(t in r)&&(r[t]=e.uniforms[t].value)}),Object.keys(r).forEach(e=>{"object"==typeof r[e]&&void 0!==r[e].index&&(r[e].texture=t.getTexture(r[e].index))}),r}const gy="EXT_feature_metadata";async function yy(e){!function(e){var t;const r=e.getExtension("EXT_feature_metadata"),n=null==r||null===(t=r.schema)||void 0===t?void 0:t.classes,i=null==r?void 0:r.featureTables;(null==r?void 0:r.featureTextures)&&console.warn('featureTextures is not yet supported in the "EXT_feature_metadata" extension.');if(n&&i)for(const t in n){const r=n[t],a=wy(i,t);a&&by(e,a,r)}}(new Eg(e))}function by(e,t,r){for(const i in r.properties){var n;const a=r.properties[i],o=null==t||null===(n=t.properties)||void 0===n?void 0:n[i],s=t.count;if(o){const t=vy(e,a,s,o);o.data=t}}}function vy(e,t,r,n){const i=n.bufferView;let a=e.getTypedArrayForBufferView(i);switch(t.type){case"STRING":{const t=n.stringOffsetBufferView;a=function(e,t,r){const n=[],i=new TextDecoder("utf8");let a=0;for(let o=0;o<r;o++){const r=t[4*(o+1)]-t[4*o],s=e.subarray(a,r+a),u=i.decode(s);n.push(u),a+=r}return n}(a,e.getTypedArrayForBufferView(t),r);break}}return a}function wy(e,t){for(const r in e){const n=e[r];if(n.class===t)return n}return null}const _y=[a,o,s,u,l,h,p,c,f];function ky(e,t){var r;const n=(null==t||null===(r=t.gltf)||void 0===r?void 0:r.excludeExtensions)||{};return!(e in n&&!n[e])}function xy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Ey={accessors:"accessor",animations:"animation",buffers:"buffer",bufferViews:"bufferView",images:"image",materials:"material",meshes:"mesh",nodes:"node",samplers:"sampler",scenes:"scene",skins:"skin",textures:"texture"},Sy={accessor:"accessors",animations:"animation",buffer:"buffers",bufferView:"bufferViews",image:"images",material:"materials",mesh:"meshes",node:"nodes",sampler:"samplers",scene:"scenes",skin:"skins",texture:"textures"};class Ay{constructor(){xy(this,"idToIndexMap",{animations:{},accessors:{},buffers:{},bufferViews:{},images:{},materials:{},meshes:{},nodes:{},samplers:{},scenes:{},skins:{},textures:{}}),xy(this,"json",void 0)}normalize(e,t){this.json=e.json;const r=e.json;switch(r.asset&&r.asset.version){case"2.0":return;case void 0:case"1.0":break;default:return void console.warn("glTF: Unknown version "+r.asset.version)}if(!t.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),function(e){const t=new Eg(e),{json:r}=t;for(const e of r.images||[]){const r=t.getObjectExtension(e,"KHR_binary_glTF");r&&Object.assign(e,r),t.removeObjectExtension(e,"KHR_binary_glTF")}r.buffers&&r.buffers[0]&&delete r.buffers[0].uri,t.removeExtension("KHR_binary_glTF")}(e),this._convertObjectIdsToArrayIndices(r),this._updateObjects(r),this._updateMaterial(r)}_addAsset(e){e.asset=e.asset||{},e.asset.version="2.0",e.asset.generator=e.asset.generator||"Normalized to glTF 2.0 by loaders.gl"}_convertTopLevelObjectsToArrays(e){for(const t in Ey)this._convertTopLevelObjectToArray(e,t)}_convertTopLevelObjectToArray(e,t){const r=e[t];if(r&&!Array.isArray(r)){e[t]=[];for(const n in r){const i=r[n];i.id=i.id||n;const a=e[t].length;e[t].push(i),this.idToIndexMap[t][n]=a}}}_convertObjectIdsToArrayIndices(e){for(const t in Ey)this._convertIdsToIndices(e,t);"scene"in e&&(e.scene=this._convertIdToIndex(e.scene,"scene"));for(const t of e.textures)this._convertTextureIds(t);for(const t of e.meshes)this._convertMeshIds(t);for(const t of e.nodes)this._convertNodeIds(t);for(const t of e.scenes)this._convertSceneIds(t)}_convertTextureIds(e){e.source&&(e.source=this._convertIdToIndex(e.source,"image"))}_convertMeshIds(e){for(const t of e.primitives){const{attributes:e,indices:r,material:n}=t;for(const t in e)e[t]=this._convertIdToIndex(e[t],"accessor");r&&(t.indices=this._convertIdToIndex(r,"accessor")),n&&(t.material=this._convertIdToIndex(n,"material"))}}_convertNodeIds(e){e.children&&(e.children=e.children.map(e=>this._convertIdToIndex(e,"node"))),e.meshes&&(e.meshes=e.meshes.map(e=>this._convertIdToIndex(e,"mesh")))}_convertSceneIds(e){e.nodes&&(e.nodes=e.nodes.map(e=>this._convertIdToIndex(e,"node")))}_convertIdsToIndices(e,t){e[t]||(console.warn("gltf v1: json doesn't contain attribute "+t),e[t]=[]);for(const r of e[t])for(const e in r){const t=r[e],n=this._convertIdToIndex(t,e);r[e]=n}}_convertIdToIndex(e,t){const r=Sy[t];if(r in this.idToIndexMap){const n=this.idToIndexMap[r][e];if(!Number.isFinite(n))throw new Error(`gltf v1: failed to resolve ${t} with id ${e}`);return n}return e}_updateObjects(e){for(const e of this.json.buffers)delete e.type}_updateMaterial(e){for(const i of e.materials){var t,r,n;i.pbrMetallicRoughness={baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1};const a=(null===(t=i.values)||void 0===t?void 0:t.tex)||(null===(r=i.values)||void 0===r?void 0:r.texture2d_0)||(null===(n=i.values)||void 0===n?void 0:n.diffuseTex),o=e.textures.findIndex(e=>e.id===a);-1!==o&&(i.pbrMetallicRoughness.baseColorTexture={index:o})}}}function jy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Cy={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ty={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},By=10240,Ry=10241,Oy=10242,Iy=10243,Py=10497,Dy={magFilter:By,minFilter:Ry,wrapS:Oy,wrapT:Iy},My={[By]:9729,[Ry]:9986,[Oy]:Py,[Iy]:Py};class Fy{constructor(){jy(this,"baseUri",""),jy(this,"json",{}),jy(this,"buffers",[]),jy(this,"images",[])}postProcess(e,t={}){const{json:r,buffers:n=[],images:i=[],baseUri:a=""}=e;return ug(r),this.baseUri=a,this.json=r,this.buffers=n,this.images=i,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,t)=>this._resolveImage(e,t))),e.samplers&&(e.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(e.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(e.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(e.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(e.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(e.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t))),e.skins&&(e.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(e.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene])}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const r=this.json[e]&&this.json[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){return e.id=e.id||"scene-"+t,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return e.id=e.id||"node-"+t,e.children&&(e.children=e.children.map(e=>this.getNode(e))),void 0!==e.mesh?e.mesh=this.getMesh(e.mesh):void 0!==e.meshes&&e.meshes.length&&(e.mesh=e.meshes.reduce((e,t)=>{const r=this.getMesh(t);return e.id=r.id,e.primitives=e.primitives.concat(r.primitives),e},{primitives:[]})),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return e.id=e.id||"skin-"+t,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||"mesh-"+t,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const r in t)e.attributes[r]=this.getAccessor(t[r]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e})),e}_resolveMaterial(e,t){if(e.id=e.id||"material-"+t,e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.emissiveFactor||(e.emissiveFactor=e.emmisiveTexture?[1,1,1]:[0,0,0]),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var r,n;if(e.id=e.id||"accessor-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(r=e.componentType,Ty[r]),e.components=(n=e.type,Cy[n]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:r,byteLength:n}=_g(e,e.bufferView),i=(e.bufferView.byteOffset||0)+(e.byteOffset||0)+t.byteOffset;let a=t.arrayBuffer.slice(i,i+n);e.bufferView.byteStride&&(a=this._getValueFromInterleavedBuffer(t,i,e.bufferView.byteStride,e.bytesPerElement,e.count)),e.value=new r(a)}return e}_getValueFromInterleavedBuffer(e,t,r,n,i){const a=new Uint8Array(i*n);for(let o=0;o<i;o++){const i=t+o*r;a.set(new Uint8Array(e.arrayBuffer.slice(i,i+n)),o*n)}return a.buffer}_resolveTexture(e,t){return e.id=e.id||"texture-"+t,e.sampler="sampler"in e?this.getSampler(e.sampler):My,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||"sampler-"+t,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}return e}_enumSamplerParameter(e){return Dy[e]}_resolveImage(e,t){e.id=e.id||"image-"+t,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const r=this.images[t];return r&&(e.image=r),e}_resolveBufferView(e,t){const r=e.buffer,n={id:"bufferView-"+t,...e,buffer:this.buffers[r]},i=this.buffers[r].arrayBuffer;let a=this.buffers[r].byteOffset||0;return"byteOffset"in e&&(a+=e.byteOffset),n.data=new Uint8Array(i,a,e.byteLength),n}_resolveCamera(e,t){return e.id=e.id||"camera-"+t,e.perspective,e.orthographic,e}}const Ly=1735152710;function Ny(e,t=0,r={}){const n=new DataView(e),{magic:i=Ly}=r,a=n.getUint32(t,!1);return a===i||a===Ly}function zy(e,t,r=0,n={}){const i=new DataView(t),a=function(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))}`}(i,r+0),o=i.getUint32(r+4,!0),s=i.getUint32(r+8,!0);switch(Object.assign(e,{header:{byteOffset:r,byteLength:s,hasBinChunk:!1},type:a,version:o,json:{},binChunks:[]}),r+=12,e.version){case 1:return function(e,t,r){ia(e.header.byteLength>20);const n=t.getUint32(r+0,!0),i=t.getUint32(r+4,!0);return r+=8,ia(0===i),Uy(e,t,r,n),r+=n,r+=qy(e,t,r,e.header.byteLength)}(e,i,r);case 2:return function(e,t,r,n){return ia(e.header.byteLength>20),function(e,t,r,n){for(;r+8<=e.header.byteLength;){const i=t.getUint32(r+0,!0),a=t.getUint32(r+4,!0);switch(r+=8,a){case 1313821514:Uy(e,t,r,i);break;case 5130562:qy(e,t,r,i);break;case 0:n.strict||Uy(e,t,r,i);break;case 1:n.strict||qy(e,t,r,i)}r+=hg(i,4)}}(e,t,r,n),r+e.header.byteLength}(e,i,r,{});default:throw new Error(`Invalid GLB version ${e.version}. Only supports v1 and v2.`)}}function Uy(e,t,r,n){const i=new Uint8Array(t.buffer,r,n),a=new TextDecoder("utf8").decode(i);return e.json=JSON.parse(a),hg(n,4)}function qy(e,t,r,n){return e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:n,arrayBuffer:t.buffer}),hg(n,4)}async function Hy(e,t,r=0,n,i){var a,o,s,u;!function(e,t,r,n){n.uri&&(e.baseUri=n.uri);if(t instanceof ArrayBuffer&&!Ny(t,r,n)){const e=new TextDecoder;t=e.decode(t)}if("string"==typeof t)e.json=sg(t);else if(t instanceof ArrayBuffer){const i={};r=zy(i,t,r,n.glb),ug("glTF"===i.type,"Invalid GLB magic string "+i.type),e._glb=i,e.json=i.json}else ug(!1,"GLTF: must be ArrayBuffer or string");const i=e.json.buffers||[];if(e.buffers=new Array(i.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const a=e.json.images||[];e.images=new Array(a.length).fill({})}(e,t,r,n),function(e,t={}){(new Ay).normalize(e,t)}(e,{normalize:null==n||null===(a=n.gltf)||void 0===a?void 0:a.normalize}),function(e,t={},r){const n=_y.filter(e=>ky(e.name,t));for(const a of n){var i;null===(i=a.preprocess)||void 0===i||i.call(a,e,t,r)}}(e,n,i);const c=[];if(null!=n&&null!==(o=n.gltf)&&void 0!==o&&o.loadBuffers&&e.json.buffers&&await async function(e,t,r){const n=e.json.buffers||[];for(let o=0;o<n.length;++o){const s=n[o];if(s.uri){var i,a;const{fetch:n}=r;ug(n);const u=cg(s.uri,t),c=await(null==r||null===(i=r.fetch)||void 0===i?void 0:i.call(r,u)),l=await(null==c||null===(a=c.arrayBuffer)||void 0===a?void 0:a.call(c));e.buffers[o]={arrayBuffer:l,byteOffset:0,byteLength:l.byteLength},delete s.uri}else null===e.buffers[o]&&(e.buffers[o]={arrayBuffer:new ArrayBuffer(s.byteLength),byteOffset:0,byteLength:s.byteLength})}}(e,n,i),null!=n&&null!==(s=n.gltf)&&void 0!==s&&s.loadImages){const t=async function(e,t,r){const n=function(e){const t=new Set,r=e.json.textures||[];for(const e of r)void 0!==e.source&&t.add(e.source);return Array.from(t).sort()}(e),i=e.json.images||[],a=[];for(const o of n)a.push(Gy(e,i[o],o,t,r));return await Promise.all(a)}(e,n,i);c.push(t)}const l=async function(e,t={},r){const n=_y.filter(e=>ky(e.name,t));for(const a of n){var i;await(null===(i=a.decode)||void 0===i?void 0:i.call(a,e,t,r))}}(e,n,i);return c.push(l),await Promise.all(c),null!=n&&null!==(u=n.gltf)&&void 0!==u&&u.postProcess?function(e,t){return(new Fy).postProcess(e,t)}(e,n):e}async function Gy(e,t,r,n,i){const{fetch:a,parse:o}=i;let s;if(t.uri&&!t.hasOwnProperty("bufferView")){const e=cg(t.uri,n),r=await a(e);s=await r.arrayBuffer(),t.bufferView={data:s}}if(Number.isFinite(t.bufferView)){const r=lg(e.json,e.buffers,t.bufferView);s=oo(r.buffer,r.byteOffset,r.byteLength)}ug(s,"glTF image has no data");let u=await o(s,[Lu,Yl],{mimeType:t.mimeType,basis:n.basis||{format:Kl()}},i);u&&u[0]&&(u={compressed:!0,mipmaps:!1,width:u[0].width,height:u[0].height,data:u[0]}),e.images=e.images||[],e.images[r]=u}const Wy={name:"glTF",id:"gltf",module:"gltf",version:"3.3.1",extensions:["gltf","glb"],mimeTypes:["model/gltf+json","model/gltf-binary"],text:!0,binary:!0,tests:["glTF"],parse:async function(e,t={},r){(t={...Wy.options,...t}).gltf={...Wy.options.gltf,...t.gltf};const{byteOffset:n=0}=t;return await Hy({},e,n,t,r)},options:{gltf:{normalize:!0,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},log:console},deprecatedOptions:{fetchImages:"gltf.loadImages",createImages:"gltf.loadImages",decompress:"gltf.decompressMeshes",postProcess:"gltf.postProcess",gltf:{decompress:"gltf.decompressMeshes"}}};const Vy=0,Ky=1;function Jy(e,t,r,n){e.rotateYtoZ=!0;const i=e.byteOffset+e.byteLength-r;if(0===i)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=oo(t,r,i),e.gltfByteOffset=0,e.gltfByteLength=i,r%4==0||console.warn(e.type+": embedded glb is not aligned to a 4-byte boundary."),e.byteOffset+e.byteLength}async function Qy(e,t,r,n){const i=r["3d-tiles"]||{};if(function(e,t,r){switch(t){case Vy:const t=new Uint8Array(e.gltfArrayBuffer,e.gltfByteOffset),r=(new TextDecoder).decode(t);e.gltfUrl=r.replace(/[\s\0]+$/,""),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength;break;case Ky:break;default:throw new Error("b3dm: Illegal glTF format field")}}(e,t),i.loadGLTF){const{parse:t,fetch:i}=n;e.gltfUrl&&(e.gltfArrayBuffer=await i(e.gltfUrl,r),e.gltfByteOffset=0),e.gltfArrayBuffer&&(e.gltf=await t(e.gltfArrayBuffer,Wy,r,n),delete e.gltfArrayBuffer,delete e.gltfByteOffset,delete e.gltfByteLength)}}async function $y(e,t,r,n,i){var a;r=function(e,t,r,n,i){r=Km(e,t,r),r=Jm(e,t,r),r=Qm(e,t,r),r=Jy(e,t,r,n);const a=new Pm(e.featureTableJson,e.featureTableBinary);return e.rtcCenter=a.getGlobalProperty("RTC_CENTER",Tm.FLOAT,3),r}(e,t,r,n),await Qy(e,Ky,n,i);const o=null==e||null===(a=e.gltf)||void 0===a?void 0:a.extensions;return o&&o.CESIUM_RTC&&(e.rtcCenter=o.CESIUM_RTC.center),r}async function Yy(e,t,r,n,i){return r=function(e,t,r,n,i){if(r=Km(e,t,r),1!==e.version)throw new Error(`Instanced 3D Model version ${e.version} is not supported`);r=Jm(e,t,r);const a=new DataView(t);if(e.gltfFormat=a.getUint32(r,!0),r=Qm(e,t,r+=4),r=Jy(e,t,r,n),0===e.featureTableJsonByteLength)throw new Error("i3dm parser: featureTableJsonByteLength is zero.");const o=new Pm(e.featureTableJson,e.featureTableBinary),s=o.getGlobalProperty("INSTANCES_LENGTH");if(o.featuresLength=s,!Number.isFinite(s))throw new Error("i3dm parser: INSTANCES_LENGTH must be defined");e.eastNorthUp=o.getGlobalProperty("EAST_NORTH_UP"),e.rtcCenter=o.getGlobalProperty("RTC_CENTER",Tm.FLOAT,3);new Vm(e.batchTableJson,e.batchTableBinary,s);return function(e,t,r,n){const i=[new Array(n),e._batchTable][0],a=new Cs,o=new Cs,s=new Cs,u=new Cs,c=new Ph,l=new op,h=new Cs,p={},f=new Gs,d=[],m=[],g=new Cs,y=new Cs;for(let r=0;r<n;r++){let n;if(t.hasProperty("POSITION"))n=t.getProperty("POSITION",Tm.FLOAT,3,r,a);else if(t.hasProperty("POSITION_QUANTIZED")){n=t.getProperty("POSITION_QUANTIZED",Tm.UNSIGNED_SHORT,3,r,a);const e=t.getGlobalProperty("QUANTIZED_VOLUME_OFFSET",Tm.FLOAT,3,g);if(!e)throw new Error("i3dm parser: QUANTIZED_VOLUME_OFFSET must be defined for quantized positions.");const i=t.getGlobalProperty("QUANTIZED_VOLUME_SCALE",Tm.FLOAT,3,y);if(!i)throw new Error("i3dm parser: QUANTIZED_VOLUME_SCALE must be defined for quantized positions.");const o=65535;for(let t=0;t<3;t++)n[t]=n[t]/o*i[t]+e[t]}if(!n)throw new Error("i3dm: POSITION or POSITION_QUANTIZED must be defined for each instance.");a.copy(n),p.translation=a,e.normalUp=t.getProperty("NORMAL_UP",Tm.FLOAT,3,r,d),e.normalRight=t.getProperty("NORMAL_RIGHT",Tm.FLOAT,3,r,m);const 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",Tm.UNSIGNED_SHORT,2,d),e.octNormalRight=t.getProperty("NORMAL_RIGHT_OCT32P",Tm.UNSIGNED_SHORT,2,m),e.octNormalUp){if(!e.octNormalRight)throw new Error("i3dm: oct-encoded orientation requires NORMAL_UP_OCT32P and NORMAL_RIGHT_OCT32P");throw new Error("i3dm: oct-encoded orientation not implemented")}e.eastNorthUp?(vu.WGS84.eastNorthUpToFixedFrame(a,f),f.getRotationMatrix3(c)):c.identity()}b&&(u.copy(o).cross(s).normalize(),c.setColumn(0,o),c.setColumn(1,s),c.setColumn(2,u)),l.fromMatrix3(c),p.rotation=l,h.set(1,1,1);const v=t.getProperty("SCALE",Tm.FLOAT,1,r);Number.isFinite(v)&&h.multiplyByScalar(v);const w=t.getProperty("SCALE_NON_UNIFORM",Tm.FLOAT,3,r,d);w&&h.scale(w),p.scale=h;let _=t.getProperty("BATCH_ID",Tm.UNSIGNED_SHORT,1,r);void 0===_&&(_=r);const k=(new Gs).fromQuaternion(p.rotation);f.identity(),f.translate(p.translation),f.multiplyRight(k),f.scale(p.scale);const x=f.clone();i[r]={modelMatrix:x,batchId:_}}e.instances=i}(e,o,0,s),r}(e,t,r,n),await Qy(e,e.gltfFormat,n,i),r}async function Xy(e,t=0,r,n,i={}){switch(i.byteOffset=t,i.type=function(e,t=0){const 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))}`}(e,t),i.type){case Am.COMPOSITE:return await async function(e,t,r,n,i,a){r=Km(e,t,r);const o=new DataView(t);for(e.tilesLength=o.getUint32(r,!0),r+=4,e.tiles=[];e.tiles.length<e.tilesLength&&e.byteLength-r>12;){const o={};e.tiles.push(o),r=await a(t,r,n,i,o)}return r}(i,e,t,r,n,Xy);case Am.BATCHED_3D_MODEL:return await $y(i,e,t,r,n);case Am.GLTF:return await async function(e,t,r,n){e.rotateYtoZ=!0,e.gltfUpAxis=r["3d-tiles"]&&r["3d-tiles"].assetGltfUpAxis?r["3d-tiles"].assetGltfUpAxis:"Y";const{parse:i}=n;e.gltf=await i(t,Wy,r,n)}(i,e,r,n);case Am.INSTANCED_3D_MODEL:return await Yy(i,e,t,r,n);case Am.POINT_CLOUD:return await ag(i,e,t,r,n);default:throw new Error("3DTileLoader: unknown type "+i.type)}}async function Zy(e,t,r,n){const i=e[t].bufferView,a=e.bufferViews[i],o=e.buffers[a.buffer];if(null==n||!n.url||!n.fetch)throw new Error("Url is not provided");if(!n.fetch)throw new Error("fetch is not provided");if(o.uri){const e=function(e,t){if(t.startsWith("http")){const r=new URL(e,t);return decodeURI(r.toString())}const r=new URL(e,"http://"+t);return`/${r.host}${r.pathname}`}(o.uri,null==n?void 0:n.url),t=await n.fetch(e),r=await t.arrayBuffer();return new Uint8Array(r,a.byteOffset,a.byteLength)}return new Uint8Array(r,a.byteOffset,a.byteLength)}function eb(e){const t=new DataView(e);return t.getUint32(0,!0)+2**32*t.getUint32(4,!0)}const tb={id:"3d-tiles-subtree",name:"3D Tiles Subtree",module:"3d-tiles",version:"3.3.1",extensions:["subtree"],mimeTypes:["application/octet-stream"],tests:["subtree"],parse:async function(e,t,r){if(1952609651!==new Uint32Array(e.slice(0,4))[0])throw new Error("Wrong subtree file magic number");if(1!==new Uint32Array(e.slice(4,8))[0])throw new Error("Wrong subtree file verson, must be 1");const n=eb(e.slice(8,16)),i=new Uint8Array(e,24,n),a=new TextDecoder("utf8").decode(i),o=JSON.parse(a),s=eb(e.slice(16,24));let u=new ArrayBuffer(0);return s&&(u=e.slice(24+n)),"bufferView"in o.tileAvailability&&(o.tileAvailability.explicitBitstream=await Zy(o,"tileAvailability",u,r)),"bufferView"in o.contentAvailability&&(o.contentAvailability.explicitBitstream=await Zy(o,"contentAvailability",u,r)),"bufferView"in o.childSubtreeAvailability&&(o.childSubtreeAvailability.explicitBitstream=await Zy(o,"childSubtreeAvailability",u,r)),o},options:{}},rb={QUADTREE:4,OCTREE:8};function nb(e,t){return"constant"in e?Boolean(e.constant):!!e.explicitBitstream&&function(e,t){const r=Math.floor(e/8),n=e%8;return 1==(t[r]>>n&1)}(t,e.explicitBitstream)}function ib(e,t,r,n){const{basePath:i,refine:a,getRefine:o,lodMetricType:s,getTileType:u,rootLodMetricValue:c,rootBoundingVolume:l}=n,h=e.contentUrl&&e.contentUrl.replace(i+"/",""),p=c/2**t,f=function(e,t,r){if(t.region){const{childTileX:n,childTileY:i,childTileZ:a}=r,[o,s,u,c,l,h]=t.region,p=2**e,f=(u-o)/p,d=(c-s)/p,m=(h-l)/p,[g,y]=[o+f*n,o+f*(n+1)],[b,v]=[s+d*i,s+d*(i+1)],[w,_]=[l+m*a,l+m*(a+1)];return{region:[g,b,y,v,w,_]}}return console.warn("Unsupported bounding volume type: ",t),null}(t,l,r);return{children:e.children,contentUrl:e.contentUrl,content:{uri:h},id:e.contentUrl,refine:o(a),type:u(e),lodMetricType:s,lodMetricValue:p,geometricError:p,transform:e.transform,boundingVolume:f}}function ab(e,t){return parseInt(e.toString(2)+t.toString(2),2)}function ob(e,t,r,n,i){const a=function(e){const t={};for(const r in e)t[`{${r}}`]=e[r];return t}({level:t,x:r,y:n,z:i});return e.replace(/{level}|{x}|{y}|{z}/gi,e=>a[e])}function sb(e){if(!e.contentUrl)return mf;const t=e.contentUrl.split(".").pop();switch(t){case"pnts":return yf;case"i3dm":case"b3dm":case"glb":case"gltf":return gf;default:return t}}function ub(e){switch(e){case"REPLACE":case"replace":return df;case"ADD":case"add":return ff;default:return e}}function cb(e,t){if(/^[a-z][0-9a-z+.-]*:/i.test(t)){const r=new URL(e,t+"/");return decodeURI(r.toString())}return e.startsWith("/")?e:`${t}/${e}`}function lb(e,t){if(!e)return null;if(e.content){const r=e.content.uri||e.content.url;e.contentUrl=cb(r,t.basePath)}return e.id=e.contentUrl,e.lodMetricType=_f,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform,e.type=sb(e),e.refine=ub(e.refine),e}async function hb(e,t,r,n){var i;const a=t.basePath,{subdivisionScheme:o,maximumLevel:s,subtreeLevels:u,subtrees:{uri:c}}=r,l=cb(ob(c,0,0,0,0),a),h=await Jo(l,tb,n),p=cb(e.content.uri,a),f=null==t||null===(i=t.root)||void 0===i?void 0:i.refine,d=e.geometricError,m=e.boundingVolume,g={contentUrlTemplate:p,subtreesUriTemplate:c,subdivisionScheme:o,subtreeLevels:u,maximumLevel:s,refine:f,basePath:a,lodMetricType:_f,rootLodMetricValue:d,rootBoundingVolume:m,getTileType:sb,getRefine:ub};return await async function(e,t,r){if(!e)return null;e.lodMetricType=_f,e.lodMetricValue=e.geometricError,e.transformMatrix=e.transform;const{children:n,contentUrl:i}=await async function e(t){const{options:r,parentData:n={mortonIndex:0,x:0,y:0,z:0},childIndex:i=0,globalData:a={level:0,mortonIndex:0,x:0,y:0,z:0}}=t;let{subtree:o,level:s=0}=t;const{subdivisionScheme:u,subtreeLevels:c,maximumLevel:l,contentUrlTemplate:h,subtreesUriTemplate:p,basePath:f}=r,d={children:[],lodMetricValue:0,contentUrl:""},m=rb[u],g=1&i,y=i>>1&1,b=i>>2&1,v=(m**s-1)/(m-1);let w=ab(n.mortonIndex,i),_=v+w,k=ab(n.x,g),x=ab(n.y,y),E=ab(n.z,b),S=!1;s+1>c&&(S=nb(o.childSubtreeAvailability,w));const A=ab(a.x,k),j=ab(a.y,x),C=ab(a.z,E),T=s+a.level;if(S){const e=ob(`${f}/${p}`,T,A,j,C);o=await Jo(e,tb),a.mortonIndex=w,a.x=k,a.y=x,a.z=E,a.level=s,w=0,_=0,k=0,x=0,E=0,s=0}if(!nb(o.tileAvailability,_)||s>l)return d;nb(o.contentAvailability,_)&&(d.contentUrl=ob(h,T,A,j,C));const B=s+1,R={mortonIndex:w,x:k,y:x,z:E};for(let t=0;t<m;t++){const n=await e({subtree:o,options:r,parentData:R,childIndex:t,level:B,globalData:a});if(n.contentUrl||n.children.length){const e=ib(n,T+1,{childTileX:k,childTileY:x,childTileZ:E},r);d.children.push(e)}}return d}({subtree:t,options:r});i&&(e.contentUrl=i,e.content={uri:i.replace(r.basePath+"/","")});return e.refine=ub(e.refine),e.type=sb(e),e.children=n,e.id=e.contentUrl,e}(e,h,g)}function pb(e){var t;return(null==e||null===(t=e.extensions)||void 0===t?void 0:t["3DTILES_implicit_tiling"])||(null==e?void 0:e.implicitTiling)}const fb={id:"3d-tiles",name:"3D Tiles",module:"3d-tiles",version:"3.3.1",extensions:["cmpt","pnts","b3dm","i3dm"],mimeTypes:["application/octet-stream"],tests:["cmpt","pnts","b3dm","i3dm"],parse:async function(e,t,r){const i=t["3d-tiles"]||{};let a;a="auto"===i.isTileset?r.url&&-1!==r.url.indexOf(".json"):i.isTileset;e=a?await async function(e,t,r){var i;const a=JSON.parse((new TextDecoder).decode(e));return a.loader=t.loader||fb,a.url=r.url,a.basePath=function(e){return n.dirname(e.url)}(a),a.root=await async function(e,t){const r=e.basePath;let n;const i=pb(null==e?void 0:e.root);n=i&&e.root?await hb(e.root,e,i,t):lb(e.root,e);const a=[];for(a.push(n);a.length>0;){const n=(a.pop()||{}).children||[];for(let i of n){const n=pb(i);n?i=await hb(i,e,n,t):lb(i,{basePath:r}),a.push(i)}}return n}(a,t),a.type=wf,a.lodMetricType=_f,a.lodMetricValue=(null===(i=a.root)||void 0===i?void 0:i.lodMetricValue)||0,a}(e,t,r):await async function(e,t,r){const n={content:{featureIds:null}};return await Xy(e,0,t,r,n.content),n.content}(e,t,r);return e},options:{"3d-tiles":{loadGLTF:!0,decodeQuantizedPositions:!1,isTileset:"auto",assetGltfUpAxis:null}}};async function db(e,t){if(!t){const r=await async function(e){ia(e);const t={Authorization:"Bearer "+e},r=await va("https://api.cesium.com/v1/assets",{fetch:{headers:t}});if(!r.ok)throw new Error(r.statusText);return await r.json()}(e);for(const e of r.items)"3DTILES"===e.type&&(t=e.id)}const r=await async function(e,t){ia(e,t);const r={Authorization:"Bearer "+e},n="https://api.cesium.com/v1/assets/"+t;let i=await va(""+n,{fetch:{headers:r}});if(!i.ok)throw new Error(i.statusText);let a=await i.json();if(i=await va(n+"/endpoint",{fetch:{headers:r}}),!i.ok)throw new Error(i.statusText);const o=await i.json();return a={...a,...o},a}(e,t),{type:n,url:i}=r;return ia("3DTILES"===n&&i),r.headers={Authorization:"Bearer "+r.accessToken},r}const mb={...fb,id:"cesium-ion",name:"Cesium Ion",preload:async function(e,t={}){t=t["cesium-ion"]||{};const{accessToken:r}=t;let n=t.assetId;if(!Number.isFinite(n)){const t=e.match(/\/([0-9]+)\/tileset.json/);n=t&&t[1]}return db(r,n)},parse:async(e,t,r)=>((t={...t})["3d-tiles"]=t["cesium-ion"],t.loader=mb,fb.parse(e,t,r)),options:{"cesium-ion":{...fb.options["3d-tiles"],accessToken:null}}};var gb=r(11),yb=r.n(gb);const bb=new Uint8Array(256);let vb=bb.length;function wb(){return vb>bb.length-16&&(yb.a.randomFillSync(bb),vb=0),bb.slice(vb,vb+=16)}var _b=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;var kb=function(e){return"string"==typeof e&&_b.test(e)};const xb=[];for(let e=0;e<256;++e)xb.push((e+256).toString(16).substr(1));var Eb=function(e,t=0){const r=(xb[e[t+0]]+xb[e[t+1]]+xb[e[t+2]]+xb[e[t+3]]+"-"+xb[e[t+4]]+xb[e[t+5]]+"-"+xb[e[t+6]]+xb[e[t+7]]+"-"+xb[e[t+8]]+xb[e[t+9]]+"-"+xb[e[t+10]]+xb[e[t+11]]+xb[e[t+12]]+xb[e[t+13]]+xb[e[t+14]]+xb[e[t+15]]).toLowerCase();if(!kb(r))throw TypeError("Stringified UUID is invalid");return r};var Sb=function(e,t,r){const n=(e=e||{}).random||(e.rng||wb)();if(n[6]=15&n[6]|64,n[8]=63&n[8]|128,t){r=r||0;for(let e=0;e<16;++e)t[r+e]=n[e];return t}return Eb(n)},Ab=r(66),jb=r.n(Ab);function Cb(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Tb{constructor(e,t,r){Cb(this,"nodesPerPage",void 0),Cb(this,"nodesCounter",void 0),Cb(this,"writeFile",void 0),Cb(this,"converter",void 0),Cb(this,"nodePages",void 0),Cb(this,"length",0),this.nodesPerPage=t,this.nodesCounter=0,this.nodePages=[{}],this.nodePages[0].nodes=[],this.writeFile=e,this.converter=r,this.length=0}useWriteFunction(e){this.writeFile=e}getNodePageFileName(e){let t,r;return this.converter.options.slpk?(t=Object(qi.join)(this.converter.layers0Path,"nodepages"),r=e.toString()+".json"):(t=Object(qi.join)(this.converter.layers0Path,"nodepages",e.toString()),r="index.json"),{filePath:t,fileName:r}}async loadNodePage(e){const{filePath:t,fileName:r}=this.getNodePageFileName(e),n=Object(qi.join)(t,r);return await async function(e){try{return await Ae.promises.stat(e),!0}catch{return!1}}(n)?(console.log(`load ${n}.`),await um(t,r)):{nodes:[]}}getPageIndexByNodeId(e){return Math.floor(e/this.nodesPerPage)}async getPageByNodeId(e){const t=this.getPageIndexByNodeId(e);return this.converter.options.instantNodeWriting?await this.loadNodePage(t):this.nodePages[t]}async getNodeById(e,t){const r=e%this.nodesPerPage;return(t=t||await this.getPageByNodeId(e)).nodes[r]}async addChildRelation(e,t){var r;if(null==e)return;const n=await this.getNodeById(e);null===(r=n.children)||void 0===r||r.push(t),await this.saveNode(n)}async push(e,t){if(e.index=this.nodesCounter++,!this.converter.options.instantNodeWriting){let t=this.nodePages[this.nodePages.length-1];t.nodes.length===this.nodesPerPage&&(t={nodes:[]},this.nodePages.push(t)),t.nodes.push(e)}return await this.addChildRelation(t,e.index),Tb.updateResourceInMesh(e),await this.saveNode(e),e}async saveNode(e){if(this.converter.options.instantNodeWriting){const t=this.getPageIndexByNodeId(e.index),r=await this.getPageByNodeId(e.index),{filePath:n,fileName:i}=this.getNodePageFileName(t),a=await this.getNodeById(e.index,r);a?Tb.updateAll(a,e):r.nodes.push(e);const o=JSON.stringify(r);this.converter.options.slpk?await this.converter.writeQueue.enqueue({archiveKey:`nodePages/${t.toString()}.json.gz`,writePromise:()=>this.writeFile(n,o,i,!0,this.converter.compressList)},!0):await this.converter.writeQueue.enqueue({writePromise:()=>this.writeFile(n,o)},!0)}}async saveMetadata(){const e=Vi()({nodeCount:this.nodesCounter},{folderPattern:{path:"folderPattern",default:"BASIC"},archiveCompressionType:{path:"archiveCompressionType",default:"STORE"},resourceCompressionType:{path:"resourceCompressionType",default:"GZIP"},I3SVersion:{path:"I3SVersion",default:"1.8"},nodeCount:{path:"nodeCount"}});await this.converter.writeQueue.enqueue({archiveKey:"metadata.json",writePromise:()=>this.writeFile(this.converter.layers0Path,JSON.stringify(e),"metadata.json",!1)})}async save(){if(this.converter.options.instantNodeWriting)await this.saveMetadata();else if(this.converter.options.slpk){for(const[e,t]of this.nodePages.entries()){const r=JSON.stringify(t),n=Object(qi.join)(this.converter.layers0Path,"nodepages");await this.converter.writeQueue.enqueue({archiveKey:`nodePages/${e.toString()}.json.gz`,writePromise:()=>this.writeFile(n,r,e.toString()+".json")})}await this.saveMetadata()}else for(const[e,t]of this.nodePages.entries()){const r=JSON.stringify(t),n=Object(qi.join)(this.converter.layers0Path,"nodepages",e.toString());await this.converter.writeQueue.enqueue({writePromise:()=>this.writeFile(n,r)})}}static updateResourceInMesh(e){e.mesh&&isFinite(e.index)&&(e.mesh.geometry.resource=e.index)}static updateAll(e,t){return Object.assign(e,t,{index:e.index}),Tb.updateResourceInMesh(e),e}static updateMaterialByNodeId(e,t){e.mesh&&(e.mesh.material={definition:t,resource:e.index})}static updateVertexCountByNodeId(e,t){e.mesh&&(e.mesh.geometry.vertexCount=t)}static updateNodeAttributeByNodeId(e){e.mesh&&e.index&&(e.mesh.attribute.resource=e.index)}static updateFeatureCountByNodeId(e,t){e.mesh&&(e.mesh.geometry.featureCount=t)}static updateTexelCountHintByNodeId(e,t){e.mesh&&e.mesh.material&&(e.mesh.material.texelCountHint=t)}}function Bb(e){const{positions:t,normals:r,texCoords:n,colors:i,uvRegions:a,featureIndices:o}=e,s=t.length/9;if(!o.length)return{faceRange:new Uint32Array([0,s-1]),featureIds:[0],featureCount:1,positions:t,normals:r,texCoords:n,colors:i,uvRegions:a};const u=function(e){let t=1,r=1,n=Rb(e.slice(0,3));const i=[],a=[],o=[n];i[0]=0,a[0]=n;for(let s=3;s<e.length;s+=3){const u=Rb(e.slice(s,s+3));n!==u&&(i[t]=s/3-1,i[t+1]=s/3,a[r]=u,o.includes(u)||o.push(u),t+=2,r+=1),n=u}i[t]=e.length/3-1;const s=new Uint32Array(i),u=o.length;return{faceRange:s,featureCount:u,featureIds:a}}(o);return function(e,t){const r=e[0],n=[r.featureId||0];let i=new Float32Array(r.positions),a=new Float32Array(r.normals),o=new Uint8Array(r.colors),s=new Uint16Array(r.uvRegions),u=new Float32Array(r.texCoords);const c=[0];let l=0,h=0;for(let t=1;t<e.length;t++){const r=e[t];n.push(r.featureId||0),i=ao(i,r.positions),a=ao(a,r.normals),o=ao(o,r.colors),s=ao(s,r.uvRegions),u=ao(u,r.texCoords);const p=e[l];c.push(p.positions.length/9-1+h),c.push(p.positions.length/9+h),h+=p.positions.length/9,l+=1}c.push(i.length/9-1);return{faceRange:new Uint32Array(c),featureIds:n,positions:i,normals:a,colors:o,uvRegions:s,texCoords:u,featureCount:t}}(function(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r],i=t.find(e=>e.featureId===n.featureId);i?(i.positions=ao(i.positions,n.positions),i.normals=ao(i.normals,n.normals),i.colors=ao(i.colors,n.colors),i.texCoords=ao(i.texCoords,n.texCoords)):t.push(n)}return t}(function(e){const{featureIds:t,positions:r,normals:n,colors:i,uvRegions:a,texCoords:o,faceRange:s=new Uint32Array(0)}=e,u=[];let c=new Float32Array(r),l=new Float32Array(n),h=new Uint8Array(i),p=new Float32Array(o),f=new Uint16Array(a);for(let e=0;e<t.length;e++){const r=s[2*e],n=s[2*e+1],i=Ob("positions",r,n),a=Ob("normals",r,n),o=Ob("colors",r,n),d=Ob("uvRegions",r,n),m=Ob("texCoords",r,n);u.push({featureId:t[e],positions:c.slice(0,i),normals:l.slice(0,a),colors:h.slice(0,o),uvRegions:f.slice(0,d),texCoords:p.slice(0,m)}),c=c.slice(i),l=l.slice(a),h=h.slice(o),f=f.slice(d),p=p.slice(m)}return u.sort((e,t)=>e.featureId-t.featureId)}({...u,...e})),u.featureCount)}function Rb(e){const t={};let r=e[0],n=1;for(const i of e)t[i]=(t[i]||0)+1,n=n>t[i]?n:t[i],r=n>t[i]?r:i;return r}function Ob(e,t,r){const n=r-t+1,i=3*n;switch(e){case"positions":case"normals":return 9*n;case"colors":case"uvRegions":return 4*i;case"texCoords":return 2*i;default:return 0}}function Ib(e){const t={};for(const r in e)t[r]={value:e[r].value};return t}function Pb(e){var t,r,n,i,a,o,s,u;let c=(null===(t=e.gltf)||void 0===t||null===(r=t.scene)||void 0===r?void 0:r.nodes)||(null===(n=e.gltf)||void 0===n||null===(i=n.scenes)||void 0===i||null===(a=i[0])||void 0===a?void 0:a.nodes)||(null===(o=e.gltf)||void 0===o?void 0:o.nodes)||[];const l=(null===(s=e.gltf)||void 0===s||null===(u=s.images)||void 0===u?void 0:u.map(e=>{var t;if(null!=e&&null!==(t=e.image)&&void 0!==t&&t.compressed)return{data:null,compressed:!0};{var r;const t=null==e||null===(r=e.image)||void 0===r?void 0:r.data,n=new Uint8Array(t.length);return n.set(t),{data:n,compressed:!1,height:e.image.height,width:e.image.width,components:e.image.components,mimeType:e.mimeType}}}))||[];!function e(t){for(let n=0;n<t.length;n++){const i=t[n];var r;if(i.mesh)t[n]={...i,mesh:{...i.mesh,primitives:null===(r=i.mesh)||void 0===r?void 0:r.primitives.map(e=>{var t,r,n;return{...e,indices:{value:null==e||null===(t=e.indices)||void 0===t?void 0:t.value},attributes:Ib(e.attributes),material:{id:null==e||null===(r=e.material)||void 0===r?void 0:r.id,uniqueId:null==e||null===(n=e.material)||void 0===n?void 0:n.uniqueId}}})}};i.children&&e(i.children)}}(c);return{nodes:c,images:l,cartographicOrigin:e.cartographicOrigin,cartesianModelMatrix:e.cartesianModelMatrix}}function Db(e,t,r){var n,i,a,o;const s=null==t||null===(n=t.featureIdAttributes)||void 0===n?void 0:n[0];if(null!=s&&null!==(i=s.featureIds)&&void 0!==i&&i.attribute){return e[s.featureIds.attribute].value}if(null!=s&&null!==(a=s.featureIds)&&void 0!==a&&a.hasOwnProperty("constant")&&null!=s&&null!==(o=s.featureIds)&&void 0!==o&&o.hasOwnProperty("divisor")){var u;return function(e,t=0,r=0){let n=[];if(r>0){let i=t,a=r;for(let t=0;t<e;t++)n.push(i),a-=1,0===a&&(i++,a=r)}else n=Array(e).fill(t,0,e);return n}((null==e||null===(u=e.POSITIONS)||void 0===u?void 0:u.value.length)/3||0,s.featureIds.constant,s.featureIds.divisor)}const c=(null==t?void 0:t.featureIdTextures)&&(null==t?void 0:t.featureIdTextures[0]);if(c){var l,h;return function(e,t,r){var n,i,a;if(null==r||!r.length)return[];const o=null==e||null===(n=e.featureIds)||void 0===n||null===(i=n.texture)||void 0===i?void 0:i.index,s=null==e||null===(a=e.featureIds)||void 0===a?void 0:a.channels;if(!s||void 0===o)return[];const u=r[o],c=[],l={r:0,g:1,b:2,a:3}[s];if(u.compressed)console.warn(`Can't get batch Ids from ${u.mimeType} compressed texture`);else for(let e=0;e<t.length;e+=2){const r=t[e],n=t[e+1],i=Math.min(Mb(r)*u.width|0,u.width-1),a=(Math.min(Mb(n)*u.height|0,u.height-1)*u.width+i)*u.components+l,o=new Uint8Array(u.data)[a];c.push(o)}return c}(c,e["TEXCOORD_"+((null==c||null===(l=c.featureIds)||void 0===l||null===(h=l.texture)||void 0===h?void 0:h.texCoord)||0)].value,r)}return(null==t?void 0:t.featureTextures)&&(null==t?void 0:t.featureTextures[0])?(console.warn("EXT_feature_metadata doesn't yet support featureTextures in primitive"),[]):[]}function Mb(e){return(e%1+1)%1}function Fb(e,t){const r=[];for(const n of t){const t=e[n]||null;r.push(t)}return r}function Lb(e,t){return"OBJECTID"===e?"OBJECTID":"string"==typeof t?"string":"number"==typeof t?Number.isInteger(t)?"Int32":"double":"string"}function Nb(e,t,r){const n={key:"f_"+e,name:t,ordering:["attributeValues"],header:[{property:"count",valueType:"UInt32"}],attributeValues:{valueType:"Int32",valuesPerElement:1}};switch(r){case"OBJECTID":!function(e){e.attributeValues={valueType:"Oid32",valuesPerElement:1}}(n);break;case"string":Hb(n);break;case"double":!function(e){e.attributeValues={valueType:"Float64",valuesPerElement:1}}(n);break;case"Int32":break;default:Hb(n)}return n}function zb(e){switch(e){case"OBJECTID":return"esriFieldTypeOID";case"string":return"esriFieldTypeString";case"Int32":return"esriFieldTypeInteger";case"double":return"esriFieldTypeDouble";default:return"esriFieldTypeString"}}function Ub(e,t){return{name:e,type:t,alias:e}}function qb(e){const t=[],r=[];for(const r in e)t.push({fieldName:r,visible:!0,isEditable:!1,label:r});return r.push({fieldInfos:t,type:"fields"}),{title:"{OBJECTID}",mediaInfos:[],popupElements:r,fieldInfos:t,expressionInfos:[]}}function Hb(e){e.ordering.unshift("attributeByteCounts"),e.header.push({property:"attributeValuesByteCount",valueType:"UInt32"}),e.attributeValues={valueType:"String",encoding:"UTF-8",valuesPerElement:1},e.attributeByteCounts={valueType:"UInt32",valuesPerElement:1}}const Gb=["CUSTOM_ATTRIBUTE_2","_BATCHID","BATCHID"];let Wb=new Cs;async function Vb(e,t,r,n,i,a,o,s,u,c){var l;const h=o,p=await async function(e=[],t){let r=[];for(const t of e)r.push(av(t));t&&(r=await async function(e){const t=[];for(;e.length>0;){let i=e.splice(0,1)[0];const a=[];for(let t=0;t<e.length;t++){const r=e[t];(i.texture&&r.texture||!i.texture&&!r.texture)&&(i=await iv(i,r),a.push(t))}if(i.texture&&a.length){var r,n;const e=null===(r=i.mergedMaterials)||void 0===r?void 0:r.reduce((e,{textureSize:t})=>e+((null==t?void 0:t.width)||0),0),t=null===(n=i.mergedMaterials)||void 0===n?void 0:n.reduce((e,{textureSize:t})=>Math.max(e,(null==t?void 0:t.height)||0),0);let a=-1;for(const r of i.mergedMaterials)if(r.textureSize){const n=a+1+r.textureSize.width/e*2**(8*Uint16Array.BYTES_PER_ELEMENT)-1;r.uvRegion=new Uint16Array([a+1,0,n,r.textureSize.height/t*2**(8*Uint16Array.BYTES_PER_ELEMENT)-1]),a=n}i.texture.image.width=e,i.texture.image.height=t}for(const t of a.reverse())e.splice(t,1);t.push(i)}t.length||t.push({material:{alphaMode:"opaque",pbrMetallicRoughness:{metallicFactor:1,roughnessFactor:1}},mergedMaterials:[{originalMaterialId:"default"}]});return t}(r));return r}(null===(l=e.gltf)||void 0===l?void 0:l.materials,s),f=Pb(e),d=await async function(e,t,r){const{nodes:n,images:i,cartographicOrigin:a,cartesianModelMatrix:o}=e,s=new Map;for(const e of t){const t={positions:new Float32Array(0),normals:new Float32Array(0),texCoords:new Float32Array(0),colors:new Uint8Array(0),uvRegions:new Uint16Array(0),featureIndicesGroups:[],featureIndices:[],boundingVolumes:null,mergedMaterials:e.mergedMaterials};for(const r of e.mergedMaterials)s.set(r.originalMaterialId,t)}Jb(n,i,a,o,s,r);for(const e of s.keys()){const t=s.get(e);t&&(0!==t.positions.length?t.featureIndicesGroups&&(t.featureIndices=t.featureIndicesGroups.reduce((e,t)=>e.concat(t)),delete t.featureIndicesGroups):s.delete(e))}return s}(f,p,h);o&&function(e,t){for(const r of e.values()){const e=gm(r.positions,t);r.boundingVolumes=e;const n=e.obb.center;for(let e=0;e<r.positions.length;e+=3){const i=r.positions.subarray(e,e+3);vu.WGS84.cartesianToCartographic(Array.from(i),Wb),Wb[2]=Wb[2]-t.getHeight(Wb[1],Wb[0]),Wb=Wb.subtract(n),r.positions.set(Wb,e)}}}(d,u);const m=[];for(const o of p){const s=o.mergedMaterials[0].originalMaterialId;if(!d.has(s))continue;const u=d.get(s);if(!u)continue;const{material:l,texture:h}=o,p=await t();m.push(await Kb({convertedAttributes:u,material:l,texture:h,tileContent:e,nodeId:p,featuresHashArray:n,propertyTable:r,attributeStorageInfo:i,draco:a,workerSource:c}))}return m.length?m:null}async function Kb({convertedAttributes:e,material:t,texture:r,tileContent:n,nodeId:i,featuresHashArray:a,propertyTable:o,attributeStorageInfo:s,draco:u,workerSource:c}){var l;const h=e.boundingVolumes,p=e.positions.length/3,{faceRange:f,featureIds:d,positions:m,normals:g,colors:y,uvRegions:b,texCoords:v,featureCount:w}=Bb(e);n.batchTableJson&&function(e,t,r,n){const i=function(e,t,r){const n={};for(let i=0;i<e.length;i++){const a=e[i],o=hv(i,t,r);n[a.toString()]=o}return n}(e,n,r);pv(t,i),pv(e,i)}(d,e.featureIndices,a,n.batchTableJson);const _=new Uint32Array(2),k=function(e){const t=new BigUint64Array(e.length);for(let r=0;r<e.length;r++)t[r]=BigInt(e[r]);return t}(d);_.set([p,w],0);const x=new Uint8Array(io(_.buffer,m.buffer,g.buffer,r?v.buffer:new ArrayBuffer(0),y.buffer,b,k.buffer,f.buffer)),E=u?async function(e,t,r,n){const{positions:i,normals:a,texCoords:o,colors:s,uvRegions:u,featureIds:c,faceRange:l}=r,h=new Uint32Array(e);for(let e=0;e<h.length;e++)h.set([e],e);const p=function(e,t){const r=new Uint32Array(e.length);let n=0,i=0;for(let e=1;e<t.length;e+=2){const a=3*(t[e]+1);r.fill(n,i,a),n++,i=a+1}return r}(new Uint32Array(t.featureIndices.length?t.featureIndices:e),l),f={positions:i,normals:a,colors:s,"feature-index":p};o.length&&(f.texCoords=o);const d={"feature-index":{"i3s-attribute-type":"feature-index","i3s-feature-ids":new Int32Array(c)}};u.length&&(f["uv-region"]=u,d["uv-region"]={"i3s-attribute-type":"uv-region"});return Em({attributes:f,indices:h},Cc,{...Cc.options,source:n,reuseWorkers:!0,_nodeWorkers:!0,draco:{method:"MESH_SEQUENTIAL_ENCODING",attributesMetadata:d}})}(p,e,{positions:m,normals:g,texCoords:r?v:new Float32Array(0),colors:y,uvRegions:b,featureIds:d,faceRange:f},c.draco):null;let S=[];return s&&o&&(S=function(e,t,r){const n=[],i=function(e,t){let r=!1;for(const n of Object.values(t))e.length!==n.length&&(r=!0);return r}(e,t)?function(e,t){const r={};for(const n in t){const i=t[n];r[n]=Fb(i,e)}return r}(e,t):t,a={OBJECTID:e,...i};for(const e in a){const t=dv(e,r),i=a[e],o=fv(t,i);n.push(o)}return n}(d,o,s)),{nodeId:i,geometry:x,compressedGeometry:E,texture:r,hasUvRegions:Boolean(b.length),sharedResources:sv((null===(l=n.gltf)||void 0===l?void 0:l.materials)||[],i),meshMaterial:t,vertexCount:p,attributes:S,featureCount:w,boundingVolumes:h}}function Jb(e,t,r,n,i,a,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){if(e)for(const s of e)Qb(s,t,r,n,i,a,o)}function Qb(e,t,r,n,i,a,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){const s=function(e,t){let r=t;const{matrix:n,rotation:i,scale:a,translation:o}=e;return n&&(r=t.multiplyRight(n)),o&&(r=r.translate(o)),i&&(r=r.rotateXYZ(i)),a&&(r=r.scale(a)),r}(e,o),u=e.mesh;u&&function(e,t,r,n,i,a=!1,o=new Gs([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])){for(const m of e.primitives){var s,u,c,l,h;let e,g=null;var p,f;if(m.material)g=i.get(m.material.uniqueId),e=null===(p=g)||void 0===p||null===(f=p.mergedMaterials.find(({originalMaterialId:e})=>{var t;return e===(null===(t=m.material)||void 0===t?void 0:t.uniqueId)}))||void 0===f?void 0:f.uvRegion;else i.has("default")&&(g=i.get("default"));ia(null!==g,"Primitive - material mapping failed");const y=m.attributes;if(g){var d;if(g.positions=ao(g.positions,$b({vertices:y.POSITION.value,cartographicOrigin:r,cartesianModelMatrix:n,nodeMatrix:o,indices:null===(s=m.indices)||void 0===s?void 0:s.value,attributeSpecificTransformation:Yb,useCartesianPositions:a})),g.normals=ao(g.normals,$b({vertices:y.NORMAL&&y.NORMAL.value,cartographicOrigin:r,cartesianModelMatrix:n,nodeMatrix:o,indices:null===(u=m.indices)||void 0===u?void 0:u.value,attributeSpecificTransformation:Xb,useCartesianPositions:!1})),g.texCoords=ao(g.texCoords,Zb(y.TEXCOORD_0&&y.TEXCOORD_0.value,null===(c=m.indices)||void 0===c?void 0:c.value)),g.colors=ao(g.colors,ev(y.COLOR_0,null===(l=m.indices)||void 0===l?void 0:l.value)),e)g.uvRegions=ao(g.uvRegions,tv(e,null===(d=m.indices)||void 0===d?void 0:d.value));g.featureIndicesGroups=g.featureIndicesGroups||[],g.featureIndicesGroups.push(rv(nv(y,m,t),null===(h=m.indices)||void 0===h?void 0:h.value))}}}(u,t,r,n,i,a,s),Jb(e.children||[],t,r,n,i,a,s)}function $b(e){const{vertices:t,indices:r,attributeSpecificTransformation:n}=e,i=new Float32Array(3*r.length);if(!t)return i;for(let a=0;a<r.length;a++){const o=3*r[a],s=t.subarray(o,o+3);let u=new Cs(Array.from(s));u=n(u,e),i[3*a]=u.x,i[3*a+1]=u.y,i[3*a+2]=u.z}return i}function Yb(e,t){const{cartesianModelMatrix:r,cartographicOrigin:n,nodeMatrix:i,useCartesianPositions:a}=t;return i&&(e=e.transform(i)),e=e.transform(r),a?e:(vu.WGS84.cartesianToCartographic([e[0],e[1],e[2]],e),e=e.subtract(n))}function Xb(e,t){const{cartesianModelMatrix:r,nodeMatrix:n}=t;return n&&(e=e.transformAsVector(n)),e=e.transformAsVector(r)}function Zb(e,t){const r=new Float32Array(2*t.length);if(!e)return r.fill(1),r;for(let n=0;n<t.length;n++){const i=2*t[n],a=e.subarray(i,i+2);r[2*n]=a[0],r[2*n+1]=a[1]}return r}function ev(e,t){const r=(null==e?void 0:e.components)||4,n=new Uint8Array(t.length*r);if(!e)return n.fill(255),n;const i=e.value;for(let e=0;e<t.length;e++){const a=t[e]*r,o=i.subarray(a,a+r),s=new Uint8Array(r);for(let e=0;e<o.length;e++)s[e]=255*o[e];n.set(s,e*r)}return n}function tv(e,t){const r=new Uint16Array(4*t.length);for(let t=0;t<r.length;t+=4)r.set(e,t);return r}function rv(e,t){if(!e.length||!t.length)return[];const r=[];for(let n=0;n<t.length;n++){const i=t[n];r.push(e[i])}return r}function nv(e,t,r){const n=function(e,t,r){const n=null==t?void 0:t.extensions;if(!n)return[];for(const[t,i]of Object.entries(n||{}))switch(t){case"EXT_feature_metadata":return Db(e,i,r);case"EXT_mesh_features":return console.warn("EXT_mesh_features extension is not supported yet"),[];default:return[]}return[]}(e,t,r);if(n.length)return n;for(let t=0;t<Gb.length;t++){const r=Gb[t];if(e[r]&&e[r].value)return e[r].value}return[]}async function iv(e,t){var n,i;if(null!==(n=e.texture)&&void 0!==n&&n.bufferView&&null!==(i=t.texture)&&void 0!==i&&i.bufferView&&e.mergedMaterials&&t.mergedMaterials){const n=Buffer.from(e.texture.bufferView.data),i=Buffer.from(t.texture.bufferView.data);try{const{joinImages:t}=await Promise.resolve().then(r.t.bind(null,549,7)),a=await t([n,i],{direction:"horizontal"});e.texture.bufferView.data=await a.toFormat("image/png"===e.texture.mimeType?"png":"jpeg").toBuffer()}catch(e){throw console.log("Join images into a texture atlas has failed. Consider usage `--split-nodes` option. (See documentation https://loaders.gl/modules/tile-converter/docs/cli-reference/tile-converter)"),e}e.material.pbrMetallicRoughness.baseColorTexture.textureSetDefinitionId=1}return e.mergedMaterials=e.mergedMaterials.concat(t.mergedMaterials),e}function av(e){var t,r,n,i;const a={doubleSided:e.doubleSided,emissiveFactor:null===(t=e.emissiveFactor)||void 0===t?void 0:t.map(e=>Math.round(255*e)),alphaMode:ov(e.alphaMode),pbrMetallicRoughness:{roughnessFactor:(null==e||null===(r=e.pbrMetallicRoughness)||void 0===r?void 0:r.roughnessFactor)||1,metallicFactor:(null==e||null===(n=e.pbrMetallicRoughness)||void 0===n?void 0:n.metallicFactor)||1}};let o;null!=e&&null!==(i=e.pbrMetallicRoughness)&&void 0!==i&&i.baseColorTexture?(o=e.pbrMetallicRoughness.baseColorTexture.texture.source,a.pbrMetallicRoughness.baseColorTexture={textureSetDefinitionId:0}):e.emissiveTexture&&(o=e.emissiveTexture.texture.source,a.pbrMetallicRoughness.baseColorTexture={textureSetDefinitionId:0});const s=Sb();e.uniqueId=s;let u=[{originalMaterialId:s}];if(o)u[0].textureSize={width:o.image.width,height:o.image.height};else{var c;const t=null==e||null===(c=e.pbrMetallicRoughness)||void 0===c?void 0:c.baseColorFactor;a.pbrMetallicRoughness.baseColorFactor=t&&t.map(e=>Math.round(255*e))||void 0}return{material:a,texture:o,mergedMaterials:u}}function ov(e){switch(e){case"OPAQUE":return"opaque";case"MASK":return"mask";case"BLEND":return"blend";default:return"opaque"}}function sv(e,t){const r={};if(!e||!e.length)return r;r.materialDefinitionInfos=[];for(const n of e){const{materialDefinitionInfo:e,textureDefinitionInfo:i}=uv(n,t);r.materialDefinitionInfos.push(e),i&&(r.textureDefinitionInfos=r.textureDefinitionInfos||[],r.textureDefinitionInfos.push(i))}return r}function uv(e,t){var r;const n=(null==e||null===(r=e.pbrMetallicRoughness)||void 0===r?void 0:r.baseColorTexture)||e.emissiveTexture;let i=null;n&&(i=function(e,t){var r,n,i;return{encoding:null!=e&&null!==(r=e.source)&&void 0!==r&&r.mimeType?[e.source.mimeType]:void 0,images:[{id:lv(e,t),size:null===(n=e.source)||void 0===n?void 0:n.image.width,length:[null===(i=e.source)||void 0===i?void 0:i.image.data.length]}]}}(n.texture,t));const{baseColorFactor:a,metallicFactor:o}=(null==e?void 0:e.pbrMetallicRoughness)||{};let s=a;return a&&0!==a[3]||!e.emissiveFactor||(s=e.emissiveFactor,s[3]=s[3]||1),{materialDefinitionInfo:cv(s||[1,1,1,1],o),textureDefinitionInfo:i}}function cv(e,t=1){const r=new Lh(0,0,0,1),n=new Lh(1,1,1,1),i=new Lh(.04/255,.04/255,.04/255,0),a=new Lh(e),o=n.subtract(i).multiply(a),s=o.lerp(o,r,t);i[3]=1;const u=i.lerp(i,a,t);return{params:{diffuse:s.toArray(),specular:u.toArray(),renderMode:"solid"}}}function lv(e,t){var r;const{width:n,height:i}=null===(r=e.source)||void 0===r?void 0:r.image,a=t+1,o=32-a.toString(2).length,s="0".repeat(o).concat(a.toString(2));return BigInt(`0b${(268435456+(n-1<<12)+(i-1<<0)).toString(2)}${s}`).toString()}function hv(e,t,r){const n=function(e,t){let r="";for(const n in e)r+=e[n][t];return r}(t,e),i=jb()(n);return r.includes(i)?r.indexOf(i):r.push(i)-1}function pv(e,t){for(let r=0;r<e.length;r++)e[r]=t[e[r]]}function fv(e,t){let r;switch(e){case"Oid32":case"Int32":r=function(e){const t=new Uint32Array([e.length]),r=new Uint32Array(e);return io(t.buffer,r.buffer)}(t);break;case"Float64":r=function(e){const t=new Uint32Array([e.length]),r=new Uint8Array(4),n=new Float64Array(e);return io(t.buffer,r.buffer,n.buffer)}(t);break;case"string":r=mv(t);break;default:r=mv(t)}return r}function dv(e,t){return t.find(t=>t.name===e).attributeValues.valueType}function mv(e){const t=new Uint32Array([e.length]);let r=0;const n=new Uint32Array(e.length),i=[];for(let t=0;t<e.length;t++){const a=String(e[t])+"\0",o=Buffer.from(a),s=o.length;r+=s,n[t]=s,i.push(o)}const a=new Uint32Array([r]);return io(t.buffer,a.buffer,n.buffer,...i)}function gv(e){const t=null==e?void 0:e.batchTableJson;if(t)return t;const{extensionName:r,extension:n}=function(e){var t,r,n;const i=["EXT_feature_metadata","EXT_mesh_features"];if(!(null==e||null===(t=e.gltf)||void 0===t?void 0:t.extensionsUsed))return{extensionName:null,extension:null};let a="";for(const t of(null==e||null===(o=e.gltf)||void 0===o?void 0:o.extensionsUsed)||[]){var o;if(i.includes(t)){a=t;break}}const s=null==e||null===(r=e.gltf)||void 0===r||null===(n=r.extensions)||void 0===n?void 0:n[a];return{extensionName:a,extension:s}}(e);switch(r){case"EXT_mesh_features":return console.warn("The I3S converter does not yet support the EXT_mesh_features extension"),null;case"EXT_feature_metadata":return function(e){if(null!=e&&e.featureTextures)return console.warn("The I3S converter does not yet support the EXT_feature_metadata feature textures"),null;if(null!=e&&e.featureTables){var t;const r=null===(t=Object.keys(e.featureTables))||void 0===t?void 0:t[0];if(r){const t=null==e?void 0:e.featureTables[r],n={};for(const e in t.properties)n[e]=t.properties[e].data;return n}}return console.warn("The I3S converter couldn't handle EXT_feature_metadata extension"),null}(n);default:return null}}const yv={id:{path:"id",transform:e=>e.toUpperCase()},profile:{path:"profile",default:"meshpyramids"},version:{path:"version",default:"1.8"},resourcePattern:{path:"resourcePattern",default:["3dNodeIndexDocument","Attributes","SharedResource","Geometry"]},rootNode:{path:"rootNode",default:"./nodes/root"},extent:{path:"extent"},indexCRS:{path:"indexCRS",default:"http://www.opengis.net/def/crs/EPSG/0/4326"},vertexCRS:{path:"vertexCRS",default:"http://www.opengis.net/def/crs/EPSG/0/4326"},normalReferenceFrame:{path:"normalReferenceFrame",default:"east-north-up"},attributeEncoding:{path:"attributeEncoding",default:"application/octet-stream; version=1.6"},textureEncoding:{path:"textureEncoding",default:["image/jpeg","image/ktx2"]},lodType:{path:"lodType",default:"MeshPyramid"},lodModel:{path:"lodModel",default:"node-switching"},defaultGeometrySchema:{path:"defaultGeometrySchema",default:{geometryType:"triangles",header:[{property:"vertexCount",type:"UInt32"},{property:"featureCount",type:"UInt32"}],topology:"PerAttributeArray",ordering:["position","normal","uv0","color"],vertexAttributes:{position:{valueType:"Float32",valuesPerElement:3},normal:{valueType:"Float32",valuesPerElement:3},uv0:{valueType:"Float32",valuesPerElement:2},color:{valueType:"UInt8",valuesPerElement:4}},featureAttributeOrder:["id","faceRange"],featureAttributes:{id:{valueType:"UInt64",valuesPerElement:1},faceRange:{valueType:"UInt32",valuesPerElement:2}}}}};function bv(e,t,r){const n={};for(const[t,i]of e.entries())n[`Mat${r.nodePath}${t}`]=Vi()(i,{name:{path:"name",default:"standard"},type:{path:"type",default:"standard"},params:{path:"params",transform:(e,t,r)=>Vi()(r,{renderMode:{path:"renderMode",default:"solid"},shininess:{path:"shininess",default:1},reflectivity:{path:"reflectivity",default:0},ambient:{path:"ambient",default:[1,1,1]},diffuse:{path:"diffuse",default:[1,1,1]},specular:{path:"specular",default:[0,0,0]},useVertexColorAlpha:{path:"useVertexColorAlpha",default:!1},vertexRegions:{path:"vertexRegions",default:!1},vertexColors:{path:"vertexColors",default:!0}})}});return n}function vv(e,t,r){if(!e)return null;const n={};for(const[t,i]of e.entries()){const e=`${r.nodePath}${t}`;i.imageIndex=e,n[e]=Vi()(i,{encoding:{path:"encoding"},wrap:{path:"wrap",default:["none"]},atlas:{path:"atlas",default:!1},uvSet:{path:"uvSet",default:"uv0"},channels:{path:"channels",default:"rgb"},images:{path:"images",transform:(e,t,r)=>e.map(e=>Vi()(e,{id:{path:"id"},size:{path:"size"},href:{path:"href",default:["../textures/0"]},length:{path:"length"}}))}})}return n}function wv(e,t){if(!e)throw new Error(t||"luma.gl: assertion failed.")}const _v={};function kv(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"id";_v[e]=_v[e]||1;const t=_v[e]++;return"".concat(e,"-").concat(t)}const xv={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};const Ev=new Uint16Array([0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]),Sv=new Float32Array([-1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1,1,1,1,1,1,1,1,-1,-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1]),Av=new Float32Array([0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0]),jv=new Float32Array([0,0,1,0,1,1,0,1,1,0,1,1,0,1,0,0,0,1,0,0,1,0,1,1,1,1,0,1,0,0,1,0,1,0,1,1,0,1,0,0,0,0,1,0,1,1,0,1]),Cv={POSITION:{size:3,value:new Float32Array(Sv)},NORMAL:{size:3,value:new Float32Array(Av)},TEXCOORD_0:{size:2,value:new Float32Array(jv)}};class Tv extends class{static get DRAW_MODE(){return xv}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t=kv("geometry"),drawMode:r=xv.TRIANGLES,attributes:n={},indices:i=null,vertexCount:a=null}=e;this.id=t,this.drawMode=0|r,this.attributes={},this.userData={},this._setAttributes(n,i),this.vertexCount=a||this._calculateVertexCount(this.attributes,this.indices)}get mode(){return this.drawMode}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return"Geometry ".concat(this.id," attribute ").concat(e)}_setAttributes(e,t){t&&(this.indices=ArrayBuffer.isView(t)?{value:t,size:1}:t);for(const t in e){let r=e[t];r=ArrayBuffer.isView(r)?{value:r}:r,wv(ArrayBuffer.isView(r.value),"".concat(this._print(t),": must be typed array or object with value as typed array")),"POSITION"!==t&&"positions"!==t||r.size||(r.size=3),"indices"===t?(wv(!this.indices),this.indices=r):this.attributes[t]=r}return this.indices&&void 0!==this.indices.isIndexed&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this}_calculateVertexCount(e,t){if(t)return t.value.length;let r=1/0;for(const t in e){const n=e[t],{value:i,size:a,constant:o}=n;!o&&i&&a>=1&&(r=Math.min(r,i.length/a))}return wv(Number.isFinite(r)),r}}{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const{id:t=kv("cube-geometry")}=e;super({...e,id:t,indices:{size:1,value:new Uint16Array(Ev)},attributes:{...Cv,...e.attributes}})}}function Bv(e){var t,r;if(null==e||null===(t=e.parentNode)||void 0===t||!t.obb||null==e||null===(r=e.parentNode)||void 0===r||!r.mbs)return[];const n=[];return function(e,t){var r;const n=function(e){const{center:t,halfSize:r,quaternion:n}=e;return(new xp).fromCenterHalfSizeQuaternion(t,r,n)}(t.parentNode.obb),i=function(e){const t=new Tv,r=e.obb.halfSize,n=t.getAttributes(),i=new Float32Array(n.POSITION.value),a=vu.WGS84.cartographicToCartesian(e.obb.center);let o=[];for(let t=0;t<i.length;t+=3){const n=new Cs(i[t]*=r[0],i[t+1]*=r[1],i[t+2]*=r[2]).transformByQuaternion(e.obb.quaternion).add(a);o=o.concat(n)}return o}(t);if(function(e,t){let r=!0;for(let n=0;n<t.length/3;n+=3){const i=[t[n],t[n+1],t[n+2]],a=vu.WGS84.cartesianToCartographic(i);if(e.distanceTo(a)>0){r=!1;break}}return r}(n,i))return;const a=`OBB of Tile (${t.id}) doesn't fit into Parent (${null===(r=t.parentNode)||void 0===r?void 0:r.id}) tile OBB`;e.push(a)}(n,e),function(e,t){const r=Rv(t.mbs),n=Rv(t.parentNode.mbs);if(r.center.distanceTo(n.center)+r.radius>n.radius){var i;const r=`MBS of Tile (${t.id}) doesn't fit into Parent (${null===(i=t.parentNode)||void 0===i?void 0:i.id}) tile MBS`;e.push(r)}}(n,e),n}function Rv(e){return new Th([e[0],e[1],e[2]],e[3])}const Ov={name:"Basis Universal Supercompressed GPU Texture",id:Ki?"ktx2-basis-writer":"ktx2-basis-writer-nodejs",module:"textures",version:"3.3.1",extensions:["ktx2"],worker:!0,options:{useSRGB:!1,qualityLevel:10,encodeUASTC:!1,mipmaps:!1}},{_encodeImageNode:Iv}=globalThis;let Pv=!0;const Dv={name:"Images",id:"image",module:"images",version:"3.3.1",extensions:["jpeg"],options:{image:{mimeType:"image/png",jpegQuality:null}},encode:async function(e,t){return(t=t||{}).image=t.image||{},Iv?Iv(e,{type:t.image.mimeType}):async function(e,t){const{mimeType:r,jpegQuality:n}=t.image,{width:i,height:a}=function(e){return Au(e)}(e),o=document.createElement("canvas");o.width=i,o.height=a,function(e,t,r=0,n=0){if(0===r&&0===n&&"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap){const r=t.getContext("bitmaprenderer");if(r)return r.transferFromImageBitmap(e),t}const i=t.getContext("2d");if(e.data){const r=new Uint8ClampedArray(e.data),n=new ImageData(r,e.width,e.height);return i.putImageData(n,0,0),t}i.drawImage(e,0,0)}(e,o);const s=await new Promise(e=>{if(n&&Pv)try{return void o.toBlob(e,r,n)}catch(e){Pv=!1}o.toBlob(e,r)});if(!s)throw new Error("image encoding failed");return await s.arrayBuffer()}(e,t)}};class Mv extends Array{enqueue(e){this.push(e)}dequeue(){return this.shift()}peek(){return this[0]}isEmpty(){return 0===this.length}}function Fv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class Lv extends Mv{constructor(e=2e3,t=400){super(),Fv(this,"intervalId",void 0),Fv(this,"writePromise",null),Fv(this,"fileMap",{}),Fv(this,"listeningInterval",void 0),Fv(this,"writeConcurrency",void 0),this.listeningInterval=e,this.writeConcurrency=t}async enqueue(e,t=!1){if(t){const{archiveKey:t,writePromise:r}=e,n=await r();t&&n&&(this.fileMap[t]=n)}else super.enqueue(e),Gi.a.memoryUsage().rss>4294967296&&await this.startWrite()}startListening(){this.intervalId=setInterval(this.startWrite.bind(this),this.listeningInterval)}stopListening(){this.intervalId&&clearInterval(this.intervalId)}async startWrite(){this.writePromise||(this.writePromise=this.doWrite()),await this.writePromise,this.writePromise=null}async finalize(){this.stopListening(),await this.startWrite()}async doWrite(){for(;this.length;){const e=[],t=[];for(let r=0;r<this.writeConcurrency;r++){const r=this.dequeue();if(!r)break;const{archiveKey:n,writePromise:i}=r;t.push(n);const a=i();e.push(a)}const r=await Promise.allSettled(e);this.updateFileMap(t,r)}}updateFileMap(e,t){for(let r=0;r<e.length;r++){const n=e[r];n&&"value"in t[r]&&(this.fileMap[n]=t[r].value)}}}const Nv={id:"i3s-attributes",name:"I3S Attributes Worker",module:"tile-converter",version:"3.3.1",options:{useCartesianPositions:!1}};const zv=()=>({version:{path:"version"},id:{path:"id"},path:{path:"path"},level:{path:"level"},mbs:{path:"mbs"},obb:{path:"obb"},lodSelection:{path:"lodSelection",default:[{metricType:"maxScreenThresholdSQ",maxError:196349.54374999998},{metricType:"maxScreenThreshold",maxError:999.9999999999999}]},children:{path:"children",default:null},neighbors:{path:"neighbors",default:null},parentNode:{path:"parentNode",transform:e=>Vi()(e,{id:{path:"id"},href:{path:"href"},mbs:{path:"mbs"},obb:{path:"obb"}}),default:null},sharedResource:{path:"sharedResource",default:null},featureData:{path:"featureData",default:null},geometryData:{path:"geometryData",default:null},textureData:{path:"textureData",default:null},attributeData:{path:"attributeData",default:null}});function Uv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class qv{constructor(e,t){Uv(this,"id",void 0),Uv(this,"inPageId",void 0),Uv(this,"data",null),Uv(this,"children",[]),Uv(this,"converter",void 0),this.inPageId=e,this.id=0===e?"root":e.toString(),this.converter=t}async addData(e){return this.converter.options.instantNodeWriting?await this.write(e):this.data=e,this}async addChildren(e){const t=[];for(const r of e){const e=await r.load();t.push({id:r.id,href:"../"+r.id,obb:e.obb,mbs:e.mbs})}this.children=this.children.concat(e);let r=this.data;var n;(this.converter.options.instantNodeWriting&&(r=await this.load()),r)&&(r.children=null!==(n=r.children)&&void 0!==n?n:[],r.children=r.children.concat(t));this.converter.options.instantNodeWriting&&r&&await this.write(r)}async addNeighbors(){const e=await this.load();for(const n of this.children){var t,r;const i=await n.load();if(i.neighbors=null!==(t=i.neighbors)&&void 0!==t?t:[],Number(null==e||null===(r=e.children)||void 0===r?void 0:r.length)<1e3)for(const t of e.children||[])n.id!==t.id&&i.neighbors.push({...t});else console.warn(`Node ${n.id}: neighbors attribute is omited because of large number of neigbors`),delete i.neighbors;this.converter.options.instantNodeWriting&&i&&await n.write(i),await n.save(),n.flush()}}async save(){this.data&&await this.write(this.data)}async write(e){const t=Object(qi.join)(this.converter.layers0Path,"nodes",this.id);this.converter.options.slpk?await this.converter.writeQueue.enqueue({archiveKey:`nodes/${this.id}/3dNodeIndexDocument.json.gz`,writePromise:()=>sm(t,JSON.stringify(e),"3dNodeIndexDocument.json",!0,this.converter.compressList)},!0):await this.converter.writeQueue.enqueue({writePromise:()=>om(t,JSON.stringify(e))},!0)}async load(){if(this.data)return this.data;const e=this.id,t=Object(qi.join)(this.converter.layers0Path,"nodes",e);let r="index.json";return this.converter.options.slpk&&(r="3dNodeIndexDocument.json"),await um(t,r)}flush(){this.data=null}static async createRootNode(e,t){const r=qv.createRootNodeIndexDocument(e);return await new qv(0,t).addData(r)}static async createNode(e,t,r,n,i,a){const o=await qv.createNodeIndexDocument(e,t,r,n,i);return await new qv(n.index,a).addData(o)}static createRootNodeIndexDocument(e){const t={version:`{${Sb().toUpperCase()}}`,id:"root",level:0,lodSelection:[{metricType:"maxScreenThresholdSQ",maxError:0},{metricType:"maxScreenThreshold",maxError:0}],...e,children:[]};return Vi()(t,zv())}static async createNodeIndexDocument(e,t,r,n,i){const{texture:a,attributes:o}=i,s=n.index,u=await e.load(),c={version:u.version,id:s.toString(),level:u.level+1,...t,lodSelection:r,parentNode:{id:e.id,href:"../"+e.id,mbs:u.mbs,obb:u.obb},children:[],neighbors:[]},l=Vi()(c,zv());var h,p;if(n.mesh&&(l.geometryData=[{href:"./geometries/0"}],l.sharedResource={href:"./shared"},a&&(l.textureData=[{href:"./textures/0"},{href:"./textures/1"}]),o&&o.length&&null!==(h=e.converter.layers0)&&void 0!==h&&null!==(p=h.attributeStorageInfo)&&void 0!==p&&p.length)){l.attributeData=[];for(let t=0;t<o.length;t++){const r=e.converter.layers0.attributeStorageInfo[t].key;l.attributeData.push({href:`./attributes/${r}/0`})}}return l}}var Hv;function Gv(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Wv=(null===(Hv=Gi.a.env)||void 0===Hv?void 0:Hv.IonToken)||"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJlYWMxMzcyYy0zZjJkLTQwODctODNlNi01MDRkZmMzMjIxOWIiLCJpZCI6OTYyMCwic2NvcGVzIjpbImFzbCIsImFzciIsImdjIl0sImlhdCI6MTU2Mjg2NjI3M30.1FNiClUyk00YH_nWfSGpiQAjR5V2OvREDq1PJ5QMjWQ";class Vv{constructor(){Gv(this,"nodePages",void 0),Gv(this,"options",void 0),Gv(this,"layers0Path",void 0),Gv(this,"materialMap",void 0),Gv(this,"materialDefinitions",void 0),Gv(this,"geometryMap",void 0),Gv(this,"geometryConfigs",void 0),Gv(this,"vertexCounter",void 0),Gv(this,"layers0",void 0),Gv(this,"featuresHashArray",void 0),Gv(this,"refinementCounter",void 0),Gv(this,"validate",void 0),Gv(this,"boundingVolumeWarnings",[]),Gv(this,"conversionStartTime",[0,0]),Gv(this,"refreshTokenTime",[0,0]),Gv(this,"sourceTileset",null),Gv(this,"geoidHeightModel",null),Gv(this,"Loader",fb),Gv(this,"generateTextures",void 0),Gv(this,"generateBoundingVolumes",void 0),Gv(this,"layersHasTexture",void 0),Gv(this,"workerSource",{}),Gv(this,"writeQueue",new Lv),Gv(this,"compressList",null),this.nodePages=new Tb(om,64,this),this.options={},this.layers0Path="",this.materialMap=new Map,this.materialDefinitions=[],this.geometryMap=new Map,this.geometryConfigs=[],this.vertexCounter=0,this.layers0=null,this.featuresHashArray=[],this.refinementCounter={tilesCount:0,tilesWithAddRefineCount:0},this.validate=!1,this.generateTextures=!1,this.generateBoundingVolumes=!1,this.layersHasTexture=!1,this.compressList=null}async convert(e){if(Ki)return console.log(_m),_m;this.conversionStartTime=Gi.a.hrtime();const{tilesetName:t,slpk:r,egmFilePath:n,inputUrl:i,validate:a,outputPath:o,draco:s=!0,sevenZipExe:u,maxDepth:c,token:l,generateTextures:h,generateBoundingVolumes:p,instantNodeWriting:f=!1,mergeMaterials:d=!0}=e;this.options={maxDepth:c,slpk:r,sevenZipExe:u,egmFilePath:n,draco:s,token:l,inputUrl:i,instantNodeWriting:f,mergeMaterials:d},this.compressList=this.options.instantNodeWriting&&[]||null,this.validate=Boolean(a),this.Loader=-1!==i.indexOf("https://")?mb:fb,this.generateTextures=Boolean(h),this.generateBoundingVolumes=Boolean(p),this.writeQueue=new Lv,this.writeQueue.startListening(),console.log("Loading egm file..."),this.geoidHeightModel=await Jo(n,Ud),console.log("Loading egm file completed!"),r&&this.nodePages.useWriteFunction(sm),await this.loadWorkers();try{var m,g;const e=await this._fetchPreloadOptions(),n={loadOptions:{_nodeWorkers:!0,reuseWorkers:!0,basis:{format:"rgba32"},"basis-nodejs":{format:"rgba32",workerUrl:"./modules/textures/dist/basis-nodejs-worker.js"},"draco-nodejs":{workerUrl:"./modules/draco/dist/draco-nodejs-worker.js"}}};e.headers&&(n.loadOptions.fetch={headers:e.headers}),Object.assign(n,e);const a=await Jo(i,this.Loader,n.loadOptions);return this.sourceTileset=new Id(a,n),await this._createAndSaveTileset(o,t,null==a||null===(m=a.root)||void 0===m||null===(g=m.boundingVolume)||void 0===g?void 0:g.region),await this._finishConversion({slpk:Boolean(r),outputPath:o,tilesetName:t}),a}catch(e){throw e}finally{eo.getWorkerFarm({}).destroy()}}async _createAndSaveTileset(e,t,r){const n=Object(qi.join)(""+e,""+t);try{await cm(n)}catch(e){}this.layers0Path=Object(qi.join)(n,"SceneServer","layers","0"),this._formLayers0(t,r),this.materialDefinitions=[],this.materialMap=new Map;const i=this.sourceTileset.root,a=mm(i,this.geoidHeightModel);await this.nodePages.push({index:0,lodThreshold:0,obb:a.obb,children:[]});const o=await qv.createRootNode(a,this);await this._convertNodesTree(o,i),this.layers0.materialDefinitions=this.materialDefinitions,this.layers0.geometryDefinitions=Vi()(this.geometryConfigs.map(e=>({geometryConfig:{...e,draco:this.options.draco}})),{geometryBuffers:{path:"geometryConfig",transform:e=>{const t=[Vi()(e,{offset:{default:8},position:{default:{type:"Float32",component:3}},normal:{default:{type:"Float32",component:3}},uv0:{path:"hasTexture",transform:e=>e&&{type:"Float32",component:2}||!1,omitValues:[!1]},color:{default:{type:"UInt8",component:4}},uvRegion:{path:"hasUvRegions",transform:e=>e&&{type:"UInt16",component:4}||!1,omitValues:[!1]},featureId:{default:{binding:"per-feature",type:"UInt64",component:1}},faceRange:{default:{binding:"per-feature",type:"UInt32",component:2}}})];return e.draco&&t.push(Vi()({geometryConfig:e},{"compressedAttributes.encoding":{default:"draco"},"compressedAttributes.attributes":{path:"geometryConfig",transform:e=>{const t=["position","normal"];return e.hasTexture&&t.push("uv0"),t.push("color"),e.hasUvRegions&&t.push("uv-region"),t.push("feature-index"),t}}})),t}}}),!1===this.layersHasTexture&&(this.layers0.store.defaultGeometrySchema.ordering=this.layers0.store.defaultGeometrySchema.ordering.filter(e=>"uv0"!==e)),await this._writeLayers0(),async function(e,t,r){const n={serviceItemId:Sb().replace(/-/gi,""),layerName:e,layers0:t},i=Vi()(n,{serviceItemId:{path:"serviceItemId"},serviceName:{path:"layerName"},name:{path:"layerName"},currentVersion:{path:"currentVersion",default:10.7},serviceVersion:{path:"serviceVersion",default:"1.8"},supportedBindings:{path:"supportedBindings",default:["REST"]},layers:{path:"layers0",transform:e=>[e]}}),a=Object(qi.join)(r,"SceneServer");await om(a,JSON.stringify(i))}(t,this.layers0,n);for(const e of this.compressList||[])await im(e),await lm(e);await this.nodePages.save(),await this.writeQueue.finalize(),await this._createSlpk(n)}_formLayers0(e,t){var r,n,i;const a=function(e){let t;t=e instanceof Th?e:e.getBoundingSphere();const r=t.center,n=t.radius,i=vu.WGS84.cartesianToCartographic(new Cs(r[0]+n,r[1]+n,r[2]+n),new Cs),a=vu.WGS84.cartesianToCartographic(new Cs(r[0]-n,r[1]-n,r[2]-n),new Cs);return{xmin:Math.min(a[0],i[0]),xmax:Math.max(a[0],i[0]),ymin:Math.min(a[1],i[1]),ymax:Math.max(a[1],i[1]),zmin:Math.min(a[2],i[2]),zmax:Math.max(a[2],i[2])}}((null===(r=this.sourceTileset)||void 0===r?void 0:r.boundingVolume)||(null===(n=this.sourceTileset)||void 0===n||null===(i=n.root)||void 0===i?void 0:i.boundingVolume));t&&(a.zmin=t[4],a.zmax=t[5]);const o=[a.xmin,a.ymin,a.xmax,a.ymax],s={version:`{${Sb().toUpperCase()}}`,id:0,name:e,href:"./layers/0",store:{id:`{${Sb().toUpperCase()}}`,extent:o},nodePages:{nodesPerPage:64},compressGeometry:this.options.draco,fullExtent:a};this.layers0=Vi()(s,{version:{path:"version",transform:e=>e.toUpperCase()},id:{path:"id",default:0},name:{path:"name"},href:{path:"href",default:"./layers/0"},layerType:{path:"layerType",default:"IntegratedMesh"},spatialReference:{path:"spatialReference",transform:e=>Vi()(e,{wkid:{path:"wkid",default:4326},latestWkid:{path:"latestWkid",default:4326},vcsWkid:{path:"vcsWkid",default:5773},latestVcsWkid:{path:"latestVcsWkid",default:5773}})},capabilities:{path:"capabilities",default:["View","Query"]},store:{path:"store",transform:e=>Vi()(e,yv)},fullExtent:{path:"fullExtent",transform:e=>Vi()(e,{xmin:{path:"xmin"},ymin:{path:"ymin"},xmax:{path:"xmax"},ymax:{path:"ymax"},zmin:{path:"zmin"},zmax:{path:"zmax"}})},heightModelInfo:{path:"heightModelInfo",transform:e=>Vi()(e,{heightModel:{path:"heightModel",default:"gravity_related_height"},vertCRS:{path:"vertCRS",default:"EGM96_Geoid"},heightUnit:{path:"heightUnit",default:"meter"}})},nodePages:{path:"nodePages",transform:e=>Vi()(e,{nodesPerPage:{path:"nodesPerPage"},lodSelectionMetricType:{path:"lodSelectionMetricType",default:"maxScreenThresholdSQ"}})},materialDefinitions:{path:"materialDefinitions",default:[]},textureSetDefinitions:{path:"textureSetDefinitions",default:[]},geometryDefinitions:{path:"geometryDefinitions",default:[]},attributeStorageInfo:{path:"attributeStorageInfo",default:[]},fields:{path:"fields",default:[]},popupInfo:{path:"popupInfo",default:null}})}async _convertNodesTree(e,t){if(await this.sourceTileset._loadTile(t),this.isContentSupported(t)){const r=await this._createNode(e,t,0);for(const e of r)await e.save();await e.addChildren(r)}else await this._addChildrenWithNeighborsAndWriteFile({parentNode:e,sourceTiles:t.children,level:1});await t.unloadContent(),await e.save()}async _writeLayers0(){this.options.slpk?await this.writeQueue.enqueue({archiveKey:"3dSceneLayer.json.gz",writePromise:()=>sm(this.layers0Path,JSON.stringify(this.layers0),"3dSceneLayer.json")}):await this.writeQueue.enqueue({writePromise:()=>om(this.layers0Path,JSON.stringify(this.layers0))})}async _createSlpk(e){if(this.options.slpk){const t=Object(qi.join)(e,"SceneServer","layers","0"),r=e+".slpk";await am(t,r,0,".",this.options.sevenZipExe);try{await cm(e)}catch(e){}}}async _addChildrenWithNeighborsAndWriteFile(e){await this._addChildren(e),await e.parentNode.addNeighbors()}async convertNestedTileset({parentNode:e,sourceTile:t,level:r}){await this.sourceTileset._loadTile(t),await this._addChildren({parentNode:e,sourceTiles:t.children,level:r+1}),await t.unloadContent()}async convertNode({parentNode:e,sourceTile:t,level:r}){const n=await this._createNode(e,t,r);await e.addChildren(n)}async _addChildren(e){const{sourceTiles:t,parentNode:r,level:n}=e;if(!(this.options.maxDepth&&n>this.options.maxDepth))for(const e of t)"json"===e.type?await this.convertNestedTileset({parentNode:r,sourceTile:e,level:n}):await this.convertNode({parentNode:r,sourceTile:e,level:n}),e.id&&console.log(e.id)}async _createNode(e,t,r){var n,i;this._checkAddRefinementTypeForTile(t),await this._updateTilesetOptions(),await this.sourceTileset._loadTile(t);let a=mm(t,this.geoidHeightModel);const o=gv(t.content);!o||null!==(n=this.layers0)&&void 0!==n&&null!==(i=n.attributeStorageInfo)&&void 0!==i&&i.length||this._convertPropertyTableToNodeAttributes(o);const s=await this._convertResources(t,e.inPageId,o),u=[],c=[],l=[],h={geometry:null,compressedGeometry:null,texture:null,hasUvRegions:!1,sharedResources:null,meshMaterial:null,vertexCount:null,attributes:null,featureCount:null,boundingVolumes:null};for(const r of s||[h]){this.layersHasTexture=this.layersHasTexture||Boolean(r.texture),this.generateBoundingVolumes&&r.boundingVolumes&&(a=r.boundingVolumes);const n=Hd(t,a),i=n.find(e=>"maxScreenThresholdSQ"===e.metricType)||{maxError:0},o=await this._updateNodeInNodePages(i,a,t,e.inPageId,r),s=await qv.createNodeIndexDocument(e,a,n,o,r),h=await new qv(o.index,this).addData(s);u.push(h),o.mesh&&await this._writeResources(r,h.id),this.validate&&(this.boundingVolumeWarnings=Bv(s),this.boundingVolumeWarnings&&this.boundingVolumeWarnings.length&&console.warn("Bounding Volume Warnings: ",...this.boundingVolumeWarnings)),c.push(o.index),l.push(o)}return t.unloadContent(),await this._addChildrenWithNeighborsAndWriteFile({parentNode:u[0],sourceTiles:t.children,level:r+1}),u}async _convertResources(e,t,r){var n;if(!this.isContentSupported(e))return null;const i={center:[],halfSize:[],quaternion:[]};return await Vb(e.content,async()=>(await this.nodePages.push({index:0,obb:i},t)).index,r,this.featuresHashArray,null===(n=this.layers0)||void 0===n?void 0:n.attributeStorageInfo,this.options.draco,this.generateBoundingVolumes,this.options.mergeMaterials,this.geoidHeightModel,this.workerSource)}async _updateNodeInNodePages(e,t,r,n,i){const{meshMaterial:a,texture:o,vertexCount:s,featureCount:u,geometry:c,hasUvRegions:l}=i,h={index:0,lodThreshold:e.maxError,obb:t.obb,children:[]};c&&this.isContentSupported(r)&&(h.mesh={geometry:{definition:this.findOrCreateGeometryDefinition(Boolean(o),l),resource:0},attribute:{resource:0},material:{definition:0}});let p,f=i.nodeId;if(p=f?await this.nodePages.getNodeById(f):await this.nodePages.push(h,n),Tb.updateAll(p,h),a&&Tb.updateMaterialByNodeId(p,this._findOrCreateMaterial(a)),o){const e=o.image.height*o.image.width;Tb.updateTexelCountHintByNodeId(p,e)}return s&&(this.vertexCounter+=s,Tb.updateVertexCountByNodeId(p,s)),Tb.updateNodeAttributeByNodeId(p),u&&Tb.updateFeatureCountByNodeId(p,u),this.nodePages.saveNode(p),p}async _writeResources(e,t){const{geometry:r,compressedGeometry:n,texture:i,sharedResources:a,attributes:o}=e,s=Object(qi.join)(this.layers0Path,"nodes",t),u=Object(qi.join)("nodes",t);await this._writeGeometries(r,n,s,u),await this._writeShared(a,s,u,t),await this._writeTexture(i,s,u),await this._writeAttributes(o,s,u)}async _writeGeometries(e,t,r,n){if(this.options.slpk){const t=Object(qi.join)(r,"geometries");await this.writeQueue.enqueue({archiveKey:n+"/geometries/0.bin.gz",writePromise:()=>sm(t,e,"0.bin")})}else{const t=Object(qi.join)(r,"geometries/0/");await this.writeQueue.enqueue({writePromise:()=>om(t,e,"index.bin")})}if(this.options.draco)if(this.options.slpk){const e=Object(qi.join)(r,"geometries");await this.writeQueue.enqueue({archiveKey:n+"/geometries/1.bin.gz",writePromise:()=>sm(e,t,"1.bin")})}else{const e=Object(qi.join)(r,"geometries/1/");await this.writeQueue.enqueue({writePromise:()=>om(e,t,"index.bin")})}}async _writeShared(e,t,r,n){if(!e)return;e.nodePath=n;const i=Vi()(e,{materialDefinitions:{path:"materialDefinitionInfos",transform:bv},textureDefinitions:{path:"textureDefinitionInfos",transform:vv}}),a=JSON.stringify(i);if(this.options.slpk){const e=Object(qi.join)(t,"shared");await this.writeQueue.enqueue({archiveKey:r+"/shared/sharedResource.json.gz",writePromise:()=>sm(e,a,"sharedResource.json")})}else{const e=Object(qi.join)(t,"shared/");await this.writeQueue.enqueue({writePromise:()=>om(e,a)})}}async _writeTexture(e,t,r){if(e){const n=this._getFormatByMimeType(null==e?void 0:e.mimeType),i=[],a=e.bufferView.data;switch(n){case"jpg":case"png":if(i.push({name:"0",format:n}),await this.writeTextureFile(a,"0",n,t,r),this.generateTextures){i.push({name:"1",format:"ktx2"});const n=e.image.data.subarray(),a=new Uint8Array(n),o=Em({...e.image,data:a},Ov,{...Ov.options,source:this.workerSource.ktx2,reuseWorkers:!0,_nodeWorkers:!0});await this.writeTextureFile(o,"1","ktx2",t,r)}break;case"ktx2":if(i.push({name:"1",format:n}),await this.writeTextureFile(a,"1",n,t,r),this.generateTextures){i.push({name:"0",format:"jpg"});const n=Em(e.image.data[0],Dv);await this.writeTextureFile(n,"0","jpg",t,r)}}this.layers0.textureSetDefinitions.length||(this.layers0.textureSetDefinitions.push({formats:i}),this.layers0.textureSetDefinitions.push({formats:i,atlas:!0}))}}async writeTextureFile(e,t,r,n,i){if(this.options.slpk){const a=Object(qi.join)(n,"textures"),o=!1;await this.writeQueue.enqueue({archiveKey:`${i}/textures/${t}.${r}`,writePromise:()=>sm(a,e,`${t}.${r}`,o)})}else{const i=Object(qi.join)(n,`textures/${t}/`);await this.writeQueue.enqueue({writePromise:()=>om(i,e,"index."+r)})}}async _writeAttributes(e=[],t,r){var n,i;if(null!=e&&e.length&&null!==(n=this.layers0)&&void 0!==n&&null!==(i=n.attributeStorageInfo)&&void 0!==i&&i.length)for(let n=0;n<e.length;n++){const i=this.layers0.attributeStorageInfo[n].key,a=new Uint8Array(e[n]);if(this.options.slpk){const e=Object(qi.join)(t,"attributes",i);await this.writeQueue.enqueue({archiveKey:`${r}/attributes/${i}.bin.gz`,writePromise:()=>sm(e,a,"0.bin")})}else{const e=Object(qi.join)(t,`attributes/${i}/0`);await this.writeQueue.enqueue({writePromise:()=>om(e,a,"index.bin")})}}}_getFormatByMimeType(e){switch(e){case"image/jpeg":return"jpg";case"image/png":return"png";case"image/ktx2":return"ktx2";default:return"jpg"}}_findOrCreateMaterial(e){const t=jb()(JSON.stringify(e));if(this.materialMap.has(t))return this.materialMap.get(t)||0;const r=this.materialDefinitions.push(e)-1;return this.materialMap.set(t,r),r}findOrCreateGeometryDefinition(e,t){const r={hasTexture:e,hasUvRegions:t},n=jb()(JSON.stringify(r));if(this.geometryMap.has(n))return this.geometryMap.get(n)||0;const i=this.geometryConfigs.push(r)-1;return this.geometryMap.set(n,i),i}_convertPropertyTableToNodeAttributes(e){let t=0;const r={OBJECTID:[0],...e};for(const e in r){const n=Lb(e,r[e][0]),i=Nb(t,e,n),a=Ub(e,zb(n)),o=qb(r);this.layers0.attributeStorageInfo.push(i),this.layers0.fields.push(a),this.layers0.popupInfo=o,this.layers0.layerType="3DObject",t+=1}}async _finishConversion(e){const{tilesCount:t,tilesWithAddRefineCount:r}=this.refinementCounter,n=r?r/t*100:0,i=await fm(e),a=pm(Gi.a.hrtime(this.conversionStartTime));console.log("------------------------------------------------"),console.log("Finishing conversion of 3DTILES"),console.log("Total conversion time: "+a),console.log("Vertex count: ",this.vertexCounter),console.log("File(s) size: ",i," bytes"),console.log('Percentage of tiles with "ADD" refinement type:',n,"%"),console.log("------------------------------------------------")}async _fetchPreloadOptions(){if(!this.Loader.preload)return{};const e={"cesium-ion":{accessToken:this.options.token||Wv}},t=await this.Loader.preload(this.options.inputUrl,e);return this.refreshTokenTime=Gi.a.hrtime(),{...e,...t}}async _updateTilesetOptions(){if(Gi.a.hrtime(this.refreshTokenTime)[0]<1800)return;this.refreshTokenTime=Gi.a.hrtime();const e=await this._fetchPreloadOptions();this.sourceTileset.options={...this.sourceTileset.options,...e},e.headers&&(this.sourceTileset.loadOptions.fetch={...this.sourceTileset.loadOptions.fetch,headers:e.headers},console.log("Authorization Bearer token has been updated"))}_checkAddRefinementTypeForTile(e){1===e.refine&&(this.refinementCounter.tilesWithAddRefineCount+=1,console.warn('This tile uses "ADD" type of refinement')),this.refinementCounter.tilesCount+=1}isContentSupported(e){var t;return["b3dm","glTF"].includes(null==e||null===(t=e.content)||void 0===t?void 0:t.type)}async loadWorkers(){if(console.log("Loading workers source..."),this.options.draco){const e=to(Cc,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.draco=r}if(this.generateTextures){const e=to(Ov,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.ktx2=r}const e=to(Nv,{...Aa()}),t=await va(e),r=await t.text();this.workerSource.I3SAttributes=r,console.log("Loading workers source completed!")}}const Kv={id:"zip",module:"zip",name:"Zip Archive",version:"3.3.1",extensions:["zip"],mimeTypes:["application/zip"],category:"archive",tests:["PK"],options:{},parse:async function(e,t={}){const r=[],n={};try{const i=new Zd.a;return(await i.loadAsync(e,t)).forEach((e,a)=>{const o=a.name,s=async function(e,t,r={}){try{return await e.file(t).async(r.dataType||"arraybuffer")}catch(e){return r.log.error(`Unable to read ${t} from zip archive: ${e}`),e}}(i,o,t).then(t=>{n[e]=t});r.push(s)}),await Promise.all(r),n}catch(e){throw t.log.error("Unable to read zip archive: "+e),e}}};class Jv{async install(e="",t=""){console.log('Installing "EGM2008-5" model...');const r=await Jo("https://raw.githubusercontent.com/visgl/deck.gl-data/master/egm/egm2008-5.zip",Kv,{});let n=process.cwd();e&&(n=Object(qi.join)(n,e)),await om(n,new Uint8Array(r["geoids/egm2008-5.pgm"]),"egm2008-5.pgm"),console.log('Installing "I3S Content Loader worker"'),await this.installWorker("i3s","i3s-content-nodejs-worker.js",t),console.log('Installing "Draco Loader worker"'),await this.installWorker("draco","draco-nodejs-worker.js",t),console.log('Installing "Basis Loader worker"'),await this.installWorker("textures","basis-nodejs-worker.js",t),console.log('Installing "join-images" npm package');const i=new Yd;await i.start({command:"npm",arguments:["install","sharp","join-images"],wait:0}),console.log("All dependencies were installed succesfully.")}async installWorker(e,t,r){const n=await va(`https://unpkg.com/@loaders.gl/${e}@3.3.1/dist/${t}`),i=await n.arrayBuffer();if(!i)return;const a=Object(qi.join)(process.cwd(),r,"modules",e,"dist");await om(a,i,t)}}const Qv={I3S:"I3S",_3DTILES:"3DTILES"};function $v(){console.log("cli: converter 3dTiles to I3S or I3S to 3dTiles..."),console.log('--install-dependencies [Run the script for installing dependencies. Run this options separate from others. Now "*.pgm" file installation is implemented]'),console.log("--max-depth [Maximal depth of hierarchical tiles tree traversal, default: infinite]"),console.log("--name [Tileset name]"),console.log('--output [Output folder, default: "data" folder]'),console.log("--instant-node-writing [Keep created 3DNodeIndexDocument files on disk instead of memory. This option reduce memory usage but decelerates conversion speed]"),console.log("--split-nodes [Prevent to merge similar materials that could lead to incorrect visualization (I3S to 3DTiles conversion only)]"),console.log("--slpk [Generate slpk (Scene Layer Packages) I3S output file]"),console.log("--tileset [tileset.json file (3DTiles) / http://..../SceneServer/layers/0 resource (I3S)]"),console.log("--input-type [tileset input type: I3S or 3DTILES]"),console.log('--7zExe [location of 7z.exe archiver to create slpk on Windows, default: "C:\\Program Files\\7-Zip\\7z.exe"]'),console.log('--egm [location of Earth Gravity Model *.pgm file to convert heights from ellipsoidal to gravity-related format. A model file can be loaded from GeographicLib https://geographiclib.sourceforge.io/html/geoid.html], default: "./deps/egm2008-5.zip"'),console.log("--token [Token for Cesium ION tilesets authentication]"),console.log("--no-draco [Disable draco compression for geometry]"),console.log("--generate-textures [Enable KTX2 textures generation if only one of (JPG, PNG) texture is provided or generate JPG texture if only KTX2 is provided]"),console.log("--generate-bounding-volumes [Will generate obb and mbs bounding volumes from geometry]"),console.log("--validate [Enable validation]"),process.exit(0)}function Yv(e,t){if(e+1>=t.length)return"";const r=t[e+1];return 0===r.indexOf("--")?"":r}function Xv(e,t){const r=Yv(e,t).toLowerCase().trim();return!(["--no-draco","--split-nodes"].includes(t[e])&&!r)&&(!r||"true"===r)}(async function(){const[,,...e]=process.argv;0===e.length&&$v();const t=function(e){const t={output:"data",instantNodeWriting:!1,mergeMaterials:!0,sevenZipExe:"C:\\Program Files\\7-Zip\\7z.exe",egm:Object(qi.join)(process.cwd(),"deps","egm2008-5.pgm"),draco:!0,installDependencies:!1,generateTextures:!1,generateBoundingVolumes:!1,validate:!1,slpk:!1};return e.forEach((r,n)=>{if(0===r.indexOf("--"))switch(r){case"--input-type":t.inputType=Yv(n,e);break;case"--tileset":t.tileset=function(e,t){const r=Yv(e,t);return console.log("Input tileset value: "+r),console.log("Modified tileset value: "+r.replace(/\\/g,"/")),r.replace(/\\/g,"/")}(n,e);break;case"--name":t.name=Yv(n,e);break;case"--output":t.output=Yv(n,e);break;case"--instant-node-writing":t.instantNodeWriting=Xv(n,e);break;case"--split-nodes":t.mergeMaterials=Xv(n,e);break;case"--max-depth":t.maxDepth=function(e,t){const r=Yv(e,t),n=Number.parseInt(r);if(isFinite(n))return n;return NaN}(n,e);break;case"--slpk":t.slpk=Xv(n,e);break;case"--7zExe":t.sevenZipExe=Yv(n,e);break;case"--egm":t.egm=Yv(n,e);break;case"--token":t.token=Yv(n,e);break;case"--no-draco":t.draco=Xv(n,e);break;case"--validate":t.validate=Xv(n,e);break;case"--install-dependencies":t.installDependencies=Xv(n,e);break;case"--generate-textures":t.generateTextures=Xv(n,e);break;case"--generate-bounding-volumes":t.generateBoundingVolumes=Xv(n,e);break;case"--help":$v();break;default:console.warn("Unknown option "+r),process.exit(0)}}),t}(function(e){return e.reduce((e,t)=>{const r=t.indexOf("="),n=t.slice(0,r),i=t.slice(r+1,t.length);return t.includes("=")&&t.startsWith("--")&&i?e.concat(n,i):e.concat(t)},[])}(e));if(t.installDependencies){return void(new Jv).install("deps")}const r=function(e){const t={name:()=>console.log("Missed: --name [Tileset name]"),output:()=>console.log("Missed: --output [Output path name]"),sevenZipExe:()=>console.log("Missed: --7zExe [7z archiver executable path]"),egm:()=>console.log("Missed: --egm [*.pgm earth gravity model file path]"),tileset:()=>console.log("Missed: --tileset [tileset.json file]"),inputType:()=>console.log("Missed/Incorrect: --input-type [tileset input type: I3S or 3DTILES]")},r=[];for(const n in t){const i=e[n],a=Boolean(i)&&"inputType"===n&&!Object.values(Qv).includes(i.toUpperCase());i&&!a||r.push(t[n])}r.length&&(r.forEach(e=>e()),process.exit(1));return e}(t);await async function(e){console.log("------------------------------------------------"),console.log("Starting conversion of "+e.inputType),console.log("------------------------------------------------");switch(e.inputType.toUpperCase()){case Qv.I3S:(new xm).convert({inputUrl:e.tileset,outputPath:e.output,tilesetName:e.name,maxDepth:e.maxDepth,egmFilePath:e.egm});break;case Qv._3DTILES:const t=new Vv;await t.convert({inputUrl:e.tileset,outputPath:e.output,tilesetName:e.name,maxDepth:e.maxDepth,slpk:e.slpk,sevenZipExe:e.sevenZipExe,egmFilePath:e.egm,token:e.token,draco:e.draco,mergeMaterials:e.mergeMaterials,generateTextures:e.generateTextures,generateBoundingVolumes:e.generateBoundingVolumes,validate:e.validate,instantNodeWriting:e.instantNodeWriting});break;default:$v()}}(r)})().catch(e=>{console.log(e),process.exit(1)})},,,,,,,,function(e,t){e.exports=require("join-images")},function(e,t,r){"use strict";r.d(t,"a",(function(){return w}));var n=r(0),i=r(266);const a="undefined"!=typeof __VERSION__?__VERSION__:"untranspiled source";Object(i.a)();class o{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"sessionStorage";Object(n.a)(this,"storage",void 0),Object(n.a)(this,"id",void 0),Object(n.a)(this,"config",{}),this.storage=function(e){try{const t=window[e],r="__storage_test__";return t.setItem(r,r),t.removeItem(r),t}catch(e){return null}}(r),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function s(e,t,r){let n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:600;const i=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>n&&(r=Math.min(r,n/e.width));const a=e.width*r,o=e.height*r,s=["font-size:1px;","padding:".concat(Math.floor(o/2),"px ").concat(Math.floor(a/2),"px;"),"line-height:".concat(o,"px;"),"background:url(".concat(i,");"),"background-size:".concat(a,"px ").concat(o,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),s]}let u;function c(e){return"string"==typeof e?u[e.toUpperCase()]||u.WHITE:e}function l(e,t){if(!e)throw new Error(t||"Assertion failed")}!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"}(u||(u={}));const h={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:"undefined"!=typeof global&&global,document:"undefined"!=typeof document&&document,process:"object"==typeof process&&process},p=(globalThis,h.window||h.self||h.global),f=h.process||{};console;function d(){let e;var t,r;if(i.a&&"performance"in p)e=null==p||null===(t=p.performance)||void 0===t||null===(r=t.now)||void 0===r?void 0:r.call(t);else if("hrtime"in f){var n;const t=null==f||null===(n=f.hrtime)||void 0===n?void 0:n.call(f);e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const m={debug:i.a&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},g={enabled:!0,level:0};function y(){}const b={},v={once:!0};class w{constructor(){let{id:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{id:""};Object(n.a)(this,"id",void 0),Object(n.a)(this,"VERSION",a),Object(n.a)(this,"_startTs",d()),Object(n.a)(this,"_deltaTs",d()),Object(n.a)(this,"_storage",void 0),Object(n.a)(this,"userData",{}),Object(n.a)(this,"LOG_THROTTLE_TIMEOUT",0),this.id=e,this._storage=new o("__probe-".concat(this.id,"__"),g),this.userData={},this.timeStamp("".concat(this.id," started")),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:["constructor"];const r=Object.getPrototypeOf(e),n=Object.getOwnPropertyNames(r);for(const r of n)"function"==typeof e[r]&&(t.find(e=>r===e)||(e[r]=e[r].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((d()-this._startTs).toPrecision(10))}getDelta(){return Number((d()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}assert(e,t){l(e,t)}warn(e){return this._getLogFunction(0,e,m.warn,arguments,v)}error(e){return this._getLogFunction(0,e,m.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,m.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,m.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i<r;i++)n[i-2]=arguments[i];return this._getLogFunction(e,t,m.debug||m.info,arguments,v)}table(e,t,r){return t?this._getLogFunction(e,t,console.table||y,r&&[r],{tag:x(t)}):y}image(e){let{logLevel:t,priority:n,image:a,message:o="",scale:u=1}=e;return this._shouldLog(t||n)?i.a?function(e){let{image:t,message:r="",scale:n=1}=e;if("string"==typeof t){const e=new Image;return e.onload=()=>{const t=s(e,r,n);console.log(...t)},e.src=t,y}const i=t.nodeName||"";if("img"===i.toLowerCase())return console.log(...s(t,r,n)),y;if("canvas"===i.toLowerCase()){const e=new Image;return e.onload=()=>console.log(...s(e,r,n)),e.src=t.toDataURL(),y}return y}({image:a,message:o,scale:u}):function(e){let{image:t,message:n="",scale:i=1}=e;return function(e){let{image:t,message:n="",scale:i=1}=e,a=null;try{a=r(!function(){var e=new Error("Cannot find module 'asciify-image'");throw e.code="MODULE_NOT_FOUND",e}())}catch(e){}}({image:t,message:n,scale:i}),y}({image:a,message:o,scale:u}):y}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||y)}group(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{collapsed:!1};const n=k({logLevel:e,message:t,opts:r}),{collapsed:i}=r;return n.method=(i?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.group(e,t,Object.assign({},r,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||y)}withGroup(e,t,r){this.group(e,t)();try{r()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=_(e)}_getLogFunction(e,t,r,n,a){if(this._shouldLog(e)){a=k({logLevel:e,message:t,args:n,opts:a}),l(r=r||a.method),a.total=this.getTotal(),a.delta=this.getDelta(),this._deltaTs=d();const o=a.tag||a.message;if(a.once){if(b[o])return y;b[o]=d()}return t=function(e,t,r){if("string"==typeof t){const s=r.time?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;const r=Math.max(t-e.length,0);return"".concat(" ".repeat(r)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(r.total)):"";t=r.time?"".concat(e,": ").concat(s," ").concat(t):"".concat(e,": ").concat(t),n=t,a=r.color,o=r.background,i.a||"string"!=typeof n||(a&&(a=c(a),n="[".concat(a,"m").concat(n,"")),o&&(a=c(o),n="[".concat(o+10,"m").concat(n,""))),t=n}var n,a,o;return t}(this.id,a.message,a),r.bind(console,t,...a.args)}return y}}function _(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 l(Number.isFinite(t)&&t>=0),t}function k(e){const{logLevel:t,message:r}=e;e.logLevel=_(t);const n=e.args?Array.from(e.args):[];for(;n.length&&n.shift()!==r;);switch(typeof t){case"string":case"function":void 0!==r&&n.unshift(r),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const i=typeof e.message;return l("string"===i||"object"===i),Object.assign(e,{args:n},e.opts)}function x(e){for(const t in e)for(const r in e[t])return r||"untitled";return"empty"}Object(n.a)(w,"VERSION",a)}]);