@maptalks/3dtiles 0.124.4 → 0.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
1
  /*!
2
- * @maptalks/3dtiles v0.124.4
2
+ * @maptalks/3dtiles v0.125.0
3
3
  * LICENSE : UNLICENSED
4
4
  * (c) 2016-2026 maptalks.org
5
5
  */
6
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).maptalks=t.maptalks||{},t.maptalks,t.maptalks)}(this,(function(t,e,n){"use strict";function r(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var i=r(e),s=r(n);const o="${",a=`function(t){\n/*!\n * @maptalks/gl v0.124.4\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst e=function(){if("undefined"!=typeof undefinedThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},n=e(),r=n.gl_trans__coders=n.gl_trans__coders||{};function a(){return e().maptalks_gltf_loader}r.inject=function(t){const r=t.toString(),a=r.indexOf("{")+1,o=r.substring(0,a),i=n.gl_trans__coders=n.gl_trans__coders||{};let s=\`${o}o}\\n const _____getGlobal = ${o}e.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\\n;");return s+="\\n("+e().maptalks_gltf_loader_bundle.toString()+")({});\\n",s+="\\n"+r.substring(o.length),s},r.registerTranscoder=function(t,e){r[t]=e},r.getTranscoder=function(t){return r[t]};var o="undefined"!=typeof Float32Array?Float32Array:Array;function i(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}function s(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],s=e[4],c=e[5],u=e[6],l=e[7],f=e[8],h=e[9],y=e[10],d=e[11],b=e[12],m=e[13],p=e[14],g=e[15],v=n[0],w=n[1],M=n[2],T=n[3];return t[0]=v*r+w*s+M*f+T*b,t[1]=v*a+w*c+M*h+T*m,t[2]=v*o+w*u+M*y+T*p,t[3]=v*i+w*l+M*d+T*g,v=n[4],w=n[5],M=n[6],T=n[7],t[4]=v*r+w*s+M*f+T*b,t[5]=v*a+w*c+M*h+T*m,t[6]=v*o+w*u+M*y+T*p,t[7]=v*i+w*l+M*d+T*g,v=n[8],w=n[9],M=n[10],T=n[11],t[8]=v*r+w*s+M*f+T*b,t[9]=v*a+w*c+M*h+T*m,t[10]=v*o+w*u+M*y+T*p,t[11]=v*i+w*l+M*d+T*g,v=n[12],w=n[13],M=n[14],T=n[15],t[12]=v*r+w*s+M*f+T*b,t[13]=v*a+w*c+M*h+T*m,t[14]=v*o+w*u+M*y+T*p,t[15]=v*i+w*l+M*d+T*g,t}function c(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]}function u(){var t=new o(3);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function l(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function f(t,e,n){var r=new o(3);return r[0]=t,r[1]=e,r[2]=n,r}function h(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function y(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function d(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}function b(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return o>0&&(o=1/Math.sqrt(o)),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o,t}function m(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function p(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var g=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t},v=function(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t},w=l;function M(){var t=new o(4);return o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}u(),function(){var t,e=(t=new o(4),o!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var T;function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}u(),f(1,0,0),f(0,1,0),M(),M(),T=new o(9),o!=Float32Array&&(T[1]=0,T[2]=0,T[3]=0,T[5]=0,T[6]=0,T[7]=0),T[0]=1,T[4]=1,T[8]=1;var k={exports:{}},_={exports:{}},O=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},S=Array.prototype.concat,x=Array.prototype.slice,F=_.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var a=t[n];O(a)?e=S.call(e,x.call(a)):e.push(a)}return e};F.wrap=function(t){return function(){return t(F(arguments))}};var I=_.exports,C={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=I,U=Object.hasOwnProperty,N=Object.create(null);for(var z in C)U.call(C,z)&&(N[C[z]]=z);var L=k.exports={to:{},get:{}};function j(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}L.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=L.get.hsl(t),n="hsl";break;case"hwb":e=L.get.hwb(t),n="hwb";break;default:e=L.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},L.get.rgb=function(t){if(!t)return null;var e,n,r,a=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var o=2*n;a[n]=parseInt(e.slice(o,o+2),16)}r&&(a[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)a[n]=parseInt(e[n]+e[n],16);r&&(a[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(n=0;n<3;n++)a[n]=parseInt(e[n+1],0);e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(e=t.match(/^(\\w+)$/))?"transparent"===e[1]?[0,0,0,0]:U.call(C,e[1])?((a=C[e[1]])[3]=1,a):null:null;for(n=0;n<3;n++)a[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?a[3]=.01*parseFloat(e[4]):a[3]=parseFloat(e[4]))}for(n=0;n<3;n++)a[n]=j(a[n],0,255);return a[3]=j(a[3],0,1),a},L.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,j(parseFloat(e[2]),0,100),j(parseFloat(e[3]),0,100),j(isNaN(n)?1:n,0,1)]}return null},L.to.hex=function(){var t=E(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},L.to.rgb=function(){var t=E(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},L.to.rgb.percent=function(){var t=E(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},L.to.hsl=function(){var t=E(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},L.to.hwb=function(){var t=E(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},L.to.keyword=function(t){return N[t.slice(0,3)]};var P=k.exports,B={exports:{}},q={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R={};for(var V in q)q.hasOwnProperty(V)&&(R[q[V]]=V);var G=B.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in G)if(G.hasOwnProperty($)){if(!("channels"in G[$]))throw new Error("missing channels property: "+$);if(!("labels"in G[$]))throw new Error("missing channel labels property: "+$);if(G[$].labels.length!==G[$].channels)throw new Error("channel and label counts mismatch: "+$);var X=G[$].channels,H=G[$].labels;delete G[$].channels,delete G[$].labels,Object.defineProperty(G[$],"channels",{value:X}),Object.defineProperty(G[$],"labels",{value:H})}G.rgb.hsl=function(t){var e,n,r=t[0]/255,a=t[1]/255,o=t[2]/255,i=Math.min(r,a,o),s=Math.max(r,a,o),c=s-i;return s===i?e=0:r===s?e=(a-o)/c:a===s?e=2+(o-r)/c:o===s&&(e=4+(r-a)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(i+s)/2,[e,100*(s===i?0:n<=.5?c/(s+i):c/(2-s-i)),100*n]},G.rgb.hsv=function(t){var e,n,r,a,o,i=t[0]/255,s=t[1]/255,c=t[2]/255,u=Math.max(i,s,c),l=u-Math.min(i,s,c),f=function(t){return(u-t)/6/l+.5};return 0===l?a=o=0:(o=l/u,e=f(i),n=f(s),r=f(c),i===u?a=r-n:s===u?a=1/3+e-r:c===u&&(a=2/3+n-e),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*u]},G.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[G.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},G.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-a)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-a-e)/(1-e)||0),100*e]},G.rgb.keyword=function(t){var e=R[t];if(e)return e;var n,r,a,o=1/0;for(var i in q)if(q.hasOwnProperty(i)){var s=q[i],c=(r=t,a=s,Math.pow(r[0]-a[0],2)+Math.pow(r[1]-a[1],2)+Math.pow(r[2]-a[2],2));c<o&&(o=c,n=i)}return n},G.keyword.rgb=function(t){return q[t]},G.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},G.rgb.lab=function(t){var e=G.rgb.xyz(t),n=e[0],r=e[1],a=e[2];return r/=100,a/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},G.hsl.rgb=function(t){var e,n,r,a,o,i=t[0]/360,s=t[1]/100,c=t[2]/100;if(0===s)return[o=255*c,o,o];e=2*c-(n=c<.5?c*(1+s):c+s-c*s),a=[0,0,0];for(var u=0;u<3;u++)(r=i+1/3*-(u-1))<0&&r++,r>1&&r--,o=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,a[u]=255*o;return a},G.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,a=n,o=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,a*=o<=1?o:2-o,[e,100*(0===r?2*a/(o+a):2*n/(r+n)),100*((r+n)/2)]},G.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,a=Math.floor(e)%6,o=e-Math.floor(e),i=255*r*(1-n),s=255*r*(1-n*o),c=255*r*(1-n*(1-o));switch(r*=255,a){case 0:return[r,c,i];case 1:return[s,r,i];case 2:return[i,r,c];case 3:return[i,s,r];case 4:return[c,i,r];case 5:return[r,i,s]}},G.hsv.hsl=function(t){var e,n,r,a=t[0],o=t[1]/100,i=t[2]/100,s=Math.max(i,.01);return r=(2-o)*i,n=o*s,[a,100*(n=(n/=(e=(2-o)*s)<=1?e:2-e)||0),100*(r/=2)]},G.hwb.rgb=function(t){var e,n,r,a,o,i,s,c=t[0]/360,u=t[1]/100,l=t[2]/100,f=u+l;switch(f>1&&(u/=f,l/=f),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),a=u+r*((n=1-l)-u),e){default:case 6:case 0:o=n,i=a,s=u;break;case 1:o=a,i=n,s=u;break;case 2:o=u,i=n,s=a;break;case 3:o=u,i=a,s=n;break;case 4:o=a,i=u,s=n;break;case 5:o=n,i=u,s=a}return[255*o,255*i,255*s]},G.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,a=t[3]/100;return[255*(1-Math.min(1,e*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a))]},G.xyz.rgb=function(t){var e,n,r,a=t[0]/100,o=t[1]/100,i=t[2]/100;return n=-.9689*a+1.8758*o+.0415*i,r=.0557*a+-.204*o+1.057*i,e=(e=3.2406*a+-1.5372*o+-.4986*i)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},G.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},G.lab.xyz=function(t){var e,n,r,a=t[0];e=t[1]/500+(n=(a+16)/116),r=n-t[2]/200;var o=Math.pow(n,3),i=Math.pow(e,3),s=Math.pow(r,3);return n=o>.008856?o:(n-16/116)/7.787,e=i>.008856?i:(e-16/116)/7.787,r=s>.008856?s:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},G.lab.lch=function(t){var e,n=t[0],r=t[1],a=t[2];return(e=360*Math.atan2(a,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+a*a),e]},G.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},G.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],a=1 in arguments?arguments[1]:G.rgb.hsv(t)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===a&&(o+=60),o},G.hsv.ansi16=function(t){return G.rgb.ansi16(G.hsv.rgb(t),t[2])},G.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},G.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},G.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},G.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},G.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},G.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,a=t[2]/255,o=Math.max(Math.max(n,r),a),i=Math.min(Math.min(n,r),a),s=o-i;return e=s<=0?0:o===n?(r-a)/s%6:o===r?2+(a-n)/s:4+(n-r)/s+4,e/=6,[360*(e%=1),100*s,100*(s<1?i/(1-s):0)]},G.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,a=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(a=(n-.5*r)/(1-r)),[t[0],100*r,100*a]},G.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var a,o=[0,0,0],i=e%1*6,s=i%1,c=1-s;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-n)*r,[255*(n*o[0]+a),255*(n*o[1]+a),255*(n*o[2]+a)]},G.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},G.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},G.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},G.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,a=0;return r<1&&(a=(n-r)/(1-r)),[t[0],100*r,100*a]},G.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},G.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},G.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},G.gray.hsl=G.gray.hsv=function(t){return[0,0,t[0]]},G.gray.hwb=function(t){return[0,100,t[0]]},G.gray.cmyk=function(t){return[0,0,0,t[0]]},G.gray.lab=function(t){return[t[0],0,0]},G.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},G.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var J=B.exports,Y=J;function K(t){var e=function(){for(var t={},e=Object.keys(Y),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),a=Object.keys(Y[r]),o=a.length,i=0;i<o;i++){var s=a[i],c=e[s];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(s))}return e}function Q(t,e){return function(n){return e(t(n))}}function Z(t,e){for(var n=[e[t].parent,t],r=Y[e[t].parent][t],a=e[t].parent;e[a].parent;)n.unshift(e[a].parent),r=Q(Y[e[a].parent][a],r),a=e[a].parent;return r.conversion=n,r}var W=J,tt=function(t){for(var e=K(t),n={},r=Object.keys(e),a=r.length,o=0;o<a;o++){var i=r[o];null!==e[i].parent&&(n[i]=Z(i,e))}return n},et={};Object.keys(W).forEach((function(t){et[t]={},Object.defineProperty(et[t],"channels",{value:W[t].channels}),Object.defineProperty(et[t],"labels",{value:W[t].labels});var e=tt(t);Object.keys(e).forEach((function(n){var r=e[n];et[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,a=0;a<r;a++)n[a]=Math.round(n[a]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),et[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var nt=P,rt=et,at=[].slice,ot=["keyword","gray","hex"],it={};Object.keys(rt).forEach((function(t){it[at.call(rt[t].labels).sort().join("")]=t}));var st={};function ct(t,e){if(!(this instanceof ct))return new ct(t,e);if(e&&e in ot&&(e=null),e&&!(e in rt))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ct)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var a=nt.get(t);if(null===a)throw new Error("Unable to parse color from string: "+t);this.model=a.model,r=rt[this.model].channels,this.color=a.value.slice(0,r),this.valpha="number"==typeof a.value[r]?a.value[r]:1}else if(t.length){this.model=e||"rgb",r=rt[this.model].channels;var o=at.call(t,0,r);this.color=ft(o,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var i=Object.keys(t);"alpha"in t&&(i.splice(i.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var s=i.sort().join("");if(!(s in it))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=it[s];var c=rt[this.model].labels,u=[];for(n=0;n<c.length;n++)u.push(t[c[n]]);this.color=ft(u)}if(st[this.model])for(r=rt[this.model].channels,n=0;n<r;n++){var l=st[this.model][n];l&&(this.color[n]=l(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ut(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(st[t]||(st[t]=[]))[e]=n})),t=t[0],function(r){var a;return arguments.length?(n&&(r=n(r)),(a=this[t]()).color[e]=r,a):(a=this[t]().color[e],n&&(a=n(a)),a)}}function lt(t){return function(e){return Math.max(0,Math.min(t,e))}}function ft(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}function ht(t){return null==t}function yt(t){return"object"==typeof t&&!!t}function dt(t){return t/Math.PI*180}ct.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in nt.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return nt.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return nt.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=rt[this.model].channels,n=rt[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ct(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ct(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ut("rgb",0,lt(255)),green:ut("rgb",1,lt(255)),blue:ut("rgb",2,lt(255)),hue:ut(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ut("hsl",1,lt(100)),lightness:ut("hsl",2,lt(100)),saturationv:ut("hsv",1,lt(100)),value:ut("hsv",2,lt(100)),chroma:ut("hcg",1,lt(100)),gray:ut("hcg",2,lt(100)),white:ut("hwb",1,lt(100)),wblack:ut("hwb",2,lt(100)),cyan:ut("cmyk",0,lt(100)),magenta:ut("cmyk",1,lt(100)),yellow:ut("cmyk",2,lt(100)),black:ut("cmyk",3,lt(100)),x:ut("xyz",0,lt(100)),y:ut("xyz",1,lt(100)),z:ut("xyz",2,lt(100)),l:ut("lab",0,lt(100)),a:ut("lab",1),b:ut("lab",2),keyword:function(t){return arguments.length?new ct(t):rt[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ct(t):nt.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ct.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),a=void 0===e?.5:e,o=2*a-1,i=n.alpha()-r.alpha(),s=((o*i==-1?o:(o+i)/(1+o*i))+1)/2,c=1-s;return ct.rgb(s*n.red()+c*r.red(),s*n.green()+c*r.green(),s*n.blue()+c*r.blue(),n.alpha()*a+r.alpha()*(1-a))}},Object.keys(rt).forEach((function(t){if(-1===ot.indexOf(t)){var e=rt[t].channels;ct.prototype[t]=function(){if(this.model===t)return new ct(this);if(arguments.length)return new ct(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ct((n=rt[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ct[t]=function(n){return"number"==typeof n&&(n=ft(at.call(arguments),e)),new ct(n,t)}}}));const bt=[1,1,1,1,2,2,3,0];function mt(t){const e=t.length;let n="";for(let r=0;r<e;){let a=t[r++];if(128&a){let n=bt[a>>3&7];if(!(64&a)||!n||r+n>e)return null;for(a&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;a=a<<6|63&e}}n+=String.fromCharCode(a)}return n}new Array(3),new Array(3);const pt=[1/6378137,1/6378137,1/6356752.314245179],gt=[1/40680631590769,1/40680631590769,1/40408299984661.445],vt=new Array(3),wt=new Array(3),Mt=new Array(3);function Tt(t,e){const n=gt,r=function(t,e,n,r,a){const o=e[0],i=e[1],s=e[2],c=n[0],u=n[1],l=n[2],f=o*o*c*c,h=i*i*u*u,y=s*s*l*l,d=f+h+y,b=Math.sqrt(1/d),m=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}(At,e,b);if(d<a)return isFinite(b)?m:void 0;const p=r[0],g=r[1],v=r[2],w=kt;w[0]=m[0]*p*2,w[1]=m[1]*g*2,w[2]=m[2]*v*2;let M,T,A,k,_,O,S,x,F,I,C,E=(1-b)*Ot(e)/(.5*Ot(w)),U=0;do{E-=U,A=1/(1+E*p),k=1/(1+E*g),_=1/(1+E*v),O=A*A,S=k*k,x=_*_,F=O*A,I=S*k,C=x*_,M=f*O+h*S+y*x-1,T=f*F*p+h*I*g+y*C*v;U=M/(-2*T)}while(Math.abs(M)>_t);return t[0]=o*A,t[1]=i*k,t[2]=s*_,t}(vt,e,pt,n,.1);let a=v(wt,r,n);a=function(t,e){const n=e[0],r=e[1],a=e[2];let o=n*n+r*r+a*a;o>0&&(o=Math.sqrt(o),t[0]=e[0]/o,t[1]=e[1]/o,t[2]=e[2]/o);return t}(a,a);const o=g(Mt,e,r),i=Math.atan2(a[1],a[0]),s=Math.asin(a[2]),c=(u=m(o,e),(Math.sign?Math.sign(u):0==(u=+u)||isNaN(u)?Number(u):u>0?1:-1)*Ot(o));var u;return t[0]=dt(i),t[1]=dt(s),t[2]=c,t}const At=new Array(3),kt=new Array(3),_t=1e-12;function Ot(t){return l(t)}function St(t,e){let n="";for(let r=0;r<4;r++){const a=t.getUint8(e+r);n+=String.fromCharCode(a)}return n}const xt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Ft(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function It(t,e,n){const r=new Uint8Array(t,e,n);return xt?JSON.parse(xt.decode(r)):JSON.parse(mt(r))}function Ct(t,e,n){return{offset:e,byteLength:n}}function Et(t,e,n,r){const{byteOffset:a,componentType:o,type:i}=t,{ctor:s,type:c}=function(t){return zt[t]}(o||"UNSIGNED_SHORT"),u=function(t){if(!t)return 1;return Nt[t]}(i);return{byteStride:0,byteOffset:a+n,itemSize:u,count:r*u,componentType:c,array:new s(e,n+a,r*u)}}function Ut(t,e,n,r){const a=Et(t,e,n,r);return a.array.buffer.byteLength!==e.byteLength&&(a.array=a.array.slice()),a}const Nt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const zt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Lt(t){for(const e in zt)if(t===zt[e].ctor)return zt[e].type;throw new Error("unrecognized ctor:"+t)}function jt(t,e,n,r){const a=t,o=e.length/3;for(let t=0;t<o;t++)a[3*t]=e[3*t]/65535*r[0]+n[0],a[3*t+1]=e[3*t+1]/65535*r[1]+n[1],a[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return a}function Dt(t,e,n){const r=t.getUint32(12,!0),a=t.getUint32(16,!0),o=t.getUint32(20,!0),i=t.getUint32(24,!0),s=t.buffer;let c,u={},l={},f=null;r>0&&(u=Ft(s,e,r),e+=r),a>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,a),e+=a),o>0&&(l=It(s,e,o),e+=o);const h=Ct(0,e,i);return f=s.slice(h.offset,h.offset+h.byteLength),n.push(f),{featureTable:u,featureTableBin:c,batchTable:l,batchTableBin:f}}const Pt={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function Bt(t){for(const e in Pt)if(t===Pt[e])return+e;throw new Error("unrecognized ctor:"+t)}let qt=null;function Rt(){return qt||(qt={"image/crn":r.crn&&r.crn(),"image/ktx2":r.ktx2&&r.ktx2(),"image/cttf":r.ktx2&&r.ktx2(),"draco":r.draco&&r.draco()}),qt}const{Ajax:Vt,GLTFLoader:Gt}=a();class $t{constructor(t,e,n){this.o=t,this.i=e||Gt,this.u=n,this.h=Rt()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Vt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){const o=a&&a.maxTextureSize,i=this.p(e,n,r,t);if(i.error)return Promise.resolve(i);const s=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.i(s,i.glb,{transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=\`${o}t}-${o}n}-${o}r}\`;const a=c.transferables;for(let t=0;t<i.transferables.length;t++)a.indexOf(i.transferables[t])<0&&a.push(i.transferables[t]);return{magic:"b3dm",count:i.count,transferables:a,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,gltf:e}}))}p(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported b3dm version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let i,s=a.getUint32(12,!0),c=a.getUint32(16,!0),u=a.getUint32(20,!0),l=a.getUint32(24,!0),f=28+e;u>=570425344?(f-=8,i=s,u=c,l=0,s=0,c=0):l>=570425344&&(f-=4,i=u,u=s,l=c,s=0,c=0);const h=[t];let y,d,b;if(s>0?(y=Ft(t,f,s),f+=s,i=y.BATCH_LENGTH):y={"BATCH_LENGTH":i},c>0&&(f+=c),u>0&&(d=It(t,f,u),f+=u,l>0)){const e=Ct(0,f,l);b=t.slice(e.offset,e.offset+e.byteLength),f+=l,h.push(b)}const m=y.BATCH_LENGTH,p={};if(y&&y.BATCH_ID){p.BATCH_ID=Ut(y.BATCH_ID,t,undefined.offset,m);const e=p.BATCH_ID.array&&p.BATCH_ID.array.buffer;e&&h.indexOf(e)<0&&h.push(e)}return{count:i,transferables:h,featureTable:y,batchTable:d,batchTableBin:b,b3dm:p,glb:{buffer:t,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}v(){return null}}const{Ajax:Xt,GLTFLoader:Ht}=a();class Jt{constructor(t,e,n,r){this.o=t,this.i=e||Ht,this.u=n,this.h=Rt(),this.M=r}load(t,e,n=0,r=0,a){return e?(r||(r=e.byteLength),this.m(t,e,n,r,a)):Xt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r,a){return this.T(t,e,n,r,a).then((({gltf:a,transferables:o})=>{const i=this.A(e,n,r,t);if(i.error)return Promise.resolve(i);for(let t=0;t<o.length;t++)-1===i.transferables.indexOf(o[t])&&i.transferables.push(o[t]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:i.count,transferables:i.transferables,featureTable:i.featureTable,batchTable:i.batchTable,batchTableBin:i.batchTableBin,i3dm:i.i3dm,gltf:a})}))}T(t,e,n,r,a){const o=a&&a.maxTextureSize,i={transferable:!0,requestImage:this.o,decoders:this.h,supportedFormats:this.u,maxTextureSize:o},s=new DataView(e,n,r),c=32+s.getUint32(12,!0)+s.getUint32(16,!0)+s.getUint32(20,!0)+s.getUint32(24,!0);if(0===s.getUint32(28,!0)){let r=mt(new Uint8Array(e,c+n,s.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Xt.getArrayBuffer(r,{}).then((t=>this.k(r,{buffer:t.data,byteOffset:0},i))):Xt.getJSON(r,{}).then((t=>this.k(r,t,i)))}{const r={buffer:e,byteOffset:c+n,byteLength:s.byteLength-c};return this.k(t,r,i)}}k(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),a=new this.i(r,e,n);return a.load({skipAttributeTransform:!0}).then((n=>{let r=0,o=0;return e.buffer&&(r=e.byteOffset||0,o=e.byteLength||0),n.url=\`${o}t}-${o}r}-${o}o}\`,{transferables:a.transferables,gltf:n}}))}A(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,32+e,i),f={},h=s.INSTANCES_LENGTH;if(s.POSITION){const{byteOffset:e}=s.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.POSITION.array.buffer)}else if(s.POSITION_QUANTIZED){const e=s.QUANTIZED_VOLUME_OFFSET,n=s.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=s.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._(new Uint16Array(t,r+c.offset,3*h),e,n)},i.push(f.POSITION.array.buffer)}if(s.BATCH_ID){f.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,h);const e=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}if(s.NORMAL_UP){let{byteOffset:e}=s.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.NORMAL_RIGHT.array.buffer)}else if(s.NORMAL_UP_OCT32P){let{byteOffset:e}=s.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_UP.array.buffer),e=s.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this.O(new Uint16Array(t,e+c.offset,2*h))},i.push(f.NORMAL_RIGHT.array.buffer)}if(s.SCALE){const{byteOffset:e}=s.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,h).slice()},i.push(f.SCALE.array.buffer)}else if(s.SCALE_NON_UNIFORM){const{byteOffset:e}=s.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(t,e+c.offset,3*h).slice()},i.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:u,batchTableBin:l,featureTable:s,i3dm:f,transferables:i}}O(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let a=0;a<e;a++)Yt(r,t[2*a],t[2*a+1],65535),n[3*a]=r[0],n[3*a+1]=r[1],n[3*a+2]=r[2];return n}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function Yt(t,e,n,r){if(t[0]=Kt(e,r),t[1]=Kt(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Qt(e),t[1]=(1-Math.abs(e))*Qt(t[1])}return b(t,t)}function Kt(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Qt(t){return t<0?-1:1}const{Ajax:Zt}=a();class Wt{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.m(t,e,n,r)):Zt.getArrayBuffer(t,{}).then((e=>{const a=e.data;return r||(r=a.byteLength),this.m(t,a,n,r)}))}m(t,e,n,r){return this.S(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}S(t,e,n,r){const a=new DataView(t,e,n),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported pnts version: "+o+", url:"+r;return console.warn(t),{error:t}}if(a.getUint32(8,!0)!==a.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const i=[t],{featureTable:s,featureTableBin:c,batchTable:u,batchTableBin:l}=Dt(a,e+28,i),f=s.QUANTIZED_VOLUME_OFFSET,h=s.QUANTIZED_VOLUME_SCALE,y=s.POINTS_LENGTH;let d,b={};if(s.extensions&&s.extensions["3DTILES_draco_point_compression"]){b=s.extensions["3DTILES_draco_point_compression"],d=new DataView(t,b.byteOffset+c.offset,b.byteLength);const e={attributes:b.properties,useUniqueIDs:!1};return this.F||(this.F=Rt().draco),this.F(d,e).then((e=>{const n=e.attributes;!s.POSITION&&!s.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=s.POSITION,n.POSITION_QUANTIZED=s.POSITION_QUANTIZED),!(s.RGB||s.RGBA||s.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=s.RGB,n.RGBA=s.RGBA,n.RGB565=s.RGB565),!s.NORMAL&&!s.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=s.NORMAL,n.NORMAL_OCT16P=s.NORMAL_OCT16P);const r=this.I(t,e.attributes,c.offset,y,i,f,h);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Lt(t.constructor),array:t},i.push(t.buffer)}else if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?r.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):r.BATCH_ID=te(y);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return{count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:r,transferables:i}}))}const m=this.I(t,s,c.offset,y,i,f,h);if(s.BATCH_ID||Object.keys(u).length){s.BATCH_ID?m.BATCH_ID=Ut(s.BATCH_ID,t,c.offset,y):m.BATCH_ID=te(y);const e=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;e&&i.indexOf(e)<0&&i.push(e)}return Promise.resolve({count:y,batchTable:u,batchTableBin:l,featureTable:s,pnts:m,transferables:i})}I(t,e,n,r,a,o,i){const s={};if(e.POSITION){let{byteOffset:o,array:i}=e.POSITION;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:u}=e.POSITION_QUANTIZED;c=c||0;const l=u?0:n;s.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this._(u||new Uint16Array(t,c+l,3*r),o,i)},a.push(s.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:o,array:i}=e.RGBA;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+4*r);i=new Uint8Array(e)}s.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB){let{byteOffset:o,array:i}=e.RGB;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r);i=new Uint8Array(e)}s.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:i},a.push(i.buffer)}else if(e.RGB565){let{byteOffset:o,array:i}=e.RGB565;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint16Array(e)}s.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:i},a.push(i.buffer)}if(e.NORMAL){let{byteOffset:o,array:i}=e.NORMAL;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+3*r*4);i=new Float32Array(e)}s.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:i},a.push(i.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:o,array:i}=e.NORMAL_OCT16P;o=o||0;const c=i?0:n;if(!i){const e=t.slice(o+c,o+c+2*r);i=new Uint8Array(e)}s.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:i},a.push(i.buffer)}return s}_(t,e,n){return jt(new Float32Array(t.length),t,e,n)}v(){return null}}function te(t){const e=(n=t)<256?Uint8Array:n<65536?Uint16Array:Uint32Array;var n;const r=new e(t);for(let e=0;e<t;e++)r[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Lt(e),array:r}}const{Ajax:ee,GLTFLoader:ne}=a();class re{constructor(t,e,n,r){this.u=n,this.o=t,this.i=e||ne,this.M=r}load(t,e,n=0,r=0,a){return e?this.m(t,e,n,r,a):ee.getArrayBuffer(t,{}).then((e=>{const a=e.data;return this.m(t,a,n,r)}))}m(t,e,n,r,a){r||(r=e.byteLength);const o=this.C(e,t,n,r),i=[];for(let n=0;n<o.length;n++){let r;if("b3dm"===o[n].magic)r=new $t(this.o,this.i,this.u);else if("i3dm"===o[n].magic)r=new Jt(this.o,this.i,this.u,this.M);else if("pnts"===o[n].magic)r=new Wt;else{if("cmpt"!==o[n].magic){console.warn("Unsupported magic in CMPT tile:",o[n].magic);continue}r=new re(this.o,this.i,this.u,this.M)}i.push(r.load(t,e,o[n].offset,o[n].byteLength,a).then((t=>t)))}return Promise.all(i).then((t=>({magic:"cmpt",tiles:t})))}C(t,e,n,r){const a=new DataView(t,n,r),o=a.getUint32(4,!0);if(1!==o){const t="Unsupported cmpt version: "+o+", url:"+e;return console.warn(t),{error:t}}if(16===a.byteLength)return[];const i=[],s=a.getUint32(12,!0);let c=16;for(let e=0;e<s;e++){const e=St(a,c),r=a.getUint32(c+8,!0);i.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return i}}const{GLTFLoader:ae}=a();function oe(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,a=r.length;n<a;n++){const a=[];he(r[n],a,t,e)}}}const ie=[],se=[],ce=[],ue=[0,0,0],le=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),fe=[1,1,1];function he(t,e,n,r){const a=e.slice(0);if(t.matrix)a.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(ie,t.translation||ue),n=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,s=r+r,c=a+a,u=n*i,l=r*i,f=r*s,h=a*i,y=a*s,d=a*c,b=o*i,m=o*s,p=o*c;return t[0]=1-f-d,t[1]=l+p,t[2]=h-m,t[3]=0,t[4]=l-p,t[5]=1-u-d,t[6]=y+b,t[7]=0,t[8]=h+m,t[9]=y-b,t[10]=1-u-f,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(se,t.rotation||le),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(ce,t.scale||fe);s(r,n,r);const o=s([],e,r);a.push(o)}if(t.children&&t.children.length)for(let e=0,o=t.children.length;e<o;e++)he(t.children[e],a,n,r);if(void 0!==t.mesh){const e=t.mesh,o=n.meshes[e];if(o){const t=a.slice(0),i=o.primitives;for(let a=0,o=i.length;a<o;a++){const o=i[a];o&&(o.matrices=t,r(o,e,a,n))}}}}function ye(t,e){let{byteOffset:n,byteStride:r,count:a}=t;const{componentType:o,itemSize:i}=t,s=t.array.buffer,c=o?ae.getTypedArrayCtor(o):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,a=a||t.array.length/i,(!r||r===i*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(s,n,a*i);for(let r=0;r<a*i;r+=i){e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,i),r/i)}return}const u=new Uint8Array(i*c.BYTES_PER_ELEMENT);r||(r=i*c.BYTES_PER_ELEMENT);for(let t=0;t<a;t++){const a=new Uint8Array(s,r*t+n,i*c.BYTES_PER_ELEMENT);u.set(a);e(new c(u.buffer),t),a.set(u)}}var de=ge("DXT1"),be=ge("DXT3"),me=ge("DXT5"),pe=ge("DX10");function ge(t){return t.charCodeAt(0)+(t.charCodeAt(1)<<8)+(t.charCodeAt(2)<<16)+(t.charCodeAt(3)<<24)}var ve=A((function(t){var e,n,r=new Int32Array(t,0,31);if(542327876!==r[0])throw new Error("Invalid magic number in DDS header");if(4&!r[20])throw new Error("Unsupported format, must contain a FourCC code");var a=r[21];switch(a){case de:e=8,n="dxt1";break;case be:e=16,n="dxt3";break;case me:e=16,n="dxt5";break;case 116:n="rgba32f";break;case pe:var o=new Uint32Array(t.slice(128,148));n=o[0];var i=o[1];if(o[2],o[3],o[4],3!==i||2!==n)throw new Error("Unsupported DX10 texture format "+n);n="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(s=a,String.fromCharCode(255&s,s>>8&255,s>>16&255,s>>24&255)))}var s;var c=r[2],u=1;131072&c&&(u=Math.max(1,r[7]));var l=!1;512&r[28]&&(l=!0);var f,h=r[4],y=r[3],d=r[1]+4,b=h,m=y,p=[];a===pe&&(d+=20);if(l)for(var g=0;g<6;g++){if("rgba32f"!==n)throw new Error("Only RGBA32f cubemaps are supported");h=b,y=m;for(var v=Math.log(h)/Math.log(2)+1,w=0;w<v;w++)f=h*y*16,p.push({offset:d,length:f,shape:[h,y]}),w<u&&(d+=f),h=Math.floor(h/2),y=Math.floor(y/2)}else for(w=0;w<u;w++)f=Math.max(4,h)/4*Math.max(4,y)/4*e,p.push({offset:d,length:f,shape:[h,y]}),d+=f,h=Math.floor(h/2),y=Math.floor(y/2);return{shape:[b,m],images:p,format:n,flags:c,cubemap:l}})),we=Math.abs,Me=Math.sin,Te=Math.cos,Ae=Math.tan,ke=Math.atan,_e=Math.atan2,Oe=Math.sqrt,Se=Math.log,xe=Math.hypot,Fe=Math.sinh,Ie=Math.cosh,Ce=1/0;function Ee(t){var e,n,r,a,o,i,s=[],c=[],u=[],l=[];function f(t,e){for(var n,r=2*Te(2*e),a=t.length-1,o=t[a],i=0;--a>=0;)n=r*o-i+t[a],i=o,o=n;return e+n*Me(2*e)}function h(t,e,n){for(var r,a,o=Me(e),i=Te(e),s=Fe(n),c=Ie(n),u=2*i*c,l=-2*o*s,f=t.length-1,h=t[f],y=0,d=0,b=0;--f>=0;)r=d,a=y,h=u*(d=h)-r-l*(y=b)+t[f],b=l*d-a+u*y;return[(u=o*c)*h-(l=i*s)*b,u*b+l*h]}t.es,o=a=(r=t.es/(1+Oe(1-t.es)))/(2-r),s[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,s[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,s[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,s[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,s[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,s[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,e=t.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),u[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),l[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),u[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),l[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,u[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),l[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,u[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),l[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,u[4]=o*(-4583/161280+a*(108847/3991680)),l[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,u[5]=o*(-20648693/638668800),l[5]=.6650675310896665*o,i=f(c,t.phi0),n=-e*(i+function(t,e){var n,r=2*Te(e),a=t.length-1,o=t[a],i=0;for(;--a>=0;)n=r*o-i+t[a],i=o,o=n;return Me(e)*n}(l,2*i)),t.fwd=function(t,r){var a,o,i,s,u,y=t.phi,d=t.lam;y=f(c,y),a=Me(y),o=Te(y),s=Me(d),i=Te(d),y=_e(a,i*o),d=_e(s*o,xe(a,o*i)),d=function(t){var e=we(t);return e=function(t){var e=1+t,n=e-1;return 0===n?t:t*Se(e)/n}(e*(1+e/(xe(1,e)+1))),t<0?-e:e}(Ae(d)),u=h(l,2*y,2*d),y+=u[0],d+=u[1],we(d)<=2.623395162778?(r.y=e*y+n,r.x=e*d):r.x=r.y=Ce},t.inv=function(t,r){var a,o,i,c,l,y=t.y,d=t.x;y=(y-n)/e,we(d/=e)<=2.623395162778?(y+=(l=h(u,2*y,2*d))[0],d+=l[1],d=ke(Fe(d)),a=Me(y),o=Te(y),c=Me(d),i=Te(d),d=_e(c,i*o),y=_e(a*i,xe(c,i*o)),r.phi=f(s,y),r.lam=d):r.phi=r.lam=Ce}}const Ue=Math.PI/180,Ne=6378137*Math.PI/180,ze=85.0511287798,Le={};function je(t,e,n,r){if("EPSG:3857"===n)return function(t,e){const n=ze,r=e[0],a=Math.max(Math.min(n,e[1]),-n);let o;o=0===a?0:Math.log(Math.tan((90+a)*Ue/2))/Ue;return t[0]=r*Ne,t[1]=o*Ne,t}(t,e);if(!n||"EPSG:9807"!==n.code&&"Traverse_Mercator"!==n.code){if("EPSG:4326"===n||"EPSG:4490"===n||"identity"===n)return De(t,e);if("baidu"===n)return De(t,e);throw new Error("unsupported projection:"+n)}{if(!(!r||4326===r.wkid))return function(t,e){return t[0]=e[0],t[1]=e[1],t}(t,e);const a=JSON.stringify(n);let o=Le[a];return o||(o=Le[a]=function(t){const e={a:Be,es:qe,x0:ht(t.falseEasting)?5e5:t.falseEasting,y0:ht(t.falseNorthing)?0:t.falseNorthing,k0:t.scaleFactor||.9996,lam0:(t.centralMeridian||0)*Pe,phi0:(t.latitudeOfOrigin||0)*Pe,originLam0:t.startLongtitude||0,originPhi0:t.startLatitude||0};Ee(e);const n={lam:0,phi:0},r={};let a=0,o=0;(e.originLam0||e.originPhi0)&&(n.lam=e.originLam0*Pe-e.lam0,n.phi=e.originPhi0*Pe,e.fwd(n,r),a=e.a*r.x+e.x0,o=e.a*r.y+e.y0);return{project:function(t,i){n.lam=t[0]*Pe-e.lam0,n.phi=t[1]*Pe,e.fwd(n,r);const s=e.a*r.x+e.x0-a,c=e.a*r.y+e.y0-o;return i[0]=s,i[1]=c,i}}}(n)),o.project(e,t)}}function De(t,e){return t[0]=e[0],t[1]=e[1],t}const Pe=.017453292519943295,Be=6378137,qe=.0066943799901413165;const{Ajax:Re}=a(),Ve=i([]),Ge=Rt().draco,$e=Rt().ktx2,Xe={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},He={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Je(t,e,n,r,a,o){const s=[],c=[],u=[];for(let e=0;e<t.meshes.length;e++){const{geometry:n,material:r}=t.meshes[e],a=Re.getArrayBuffer(n.url,o);a.xhr.url=n.url,u.push(a.xhr);const i=a.then((t=>({buffer:t})));s.push(i);const l=[];if(nn(r,l),l.length){const t=l.map((t=>{const e=Re.getArrayBuffer(t.url,o);return e.xhr.url=t.url,u.push(e.xhr),e.then((e=>e&&e.status?null:{buffer:e,mimeType:t.mimeType,format:t.format}))}));s.push(...t)}c[e]=l.length}const l=Promise.all(s).then((o=>{for(let t=0;t<o.length;t++)if(!o[t]||!o[t].buffer)return Promise.resolve(null);const s=[];let u=0;for(let t=0;t<c.length;t++){const e=c[t];s.push({geoBuffer:{data:o[u].buffer.data},textureBuffers:o.slice(u+1,e+u+1).map((t=>({data:t.buffer.data,mimeType:t.mimeType,format:t.format})))}),u+=1+e}const l=function(t,e,n,r,a,o){const s={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let u=0;u<t.meshes.length;u++){let{material:l}=t.meshes[u];const{geometry:f}=t.meshes[u];let h;const y=e[u].geoBuffer.data;if(!y)continue;h=un(y)?Ke(s,u,f,y,t.transform,t.center,a,o):Ze(s,u,f,y,t.transform,t.center,a,o),c.push(h),s.nodes[u]={mesh:u,nodeIndex:u,matrix:i([])},s.scenes[0].nodes[u]=s.nodes[u],l||(l=Xe);const d=tn(u,s,l,e[u].textureBuffers,n,r);c.push(d)}return Promise.all(c).then((()=>({gltf:s,featureTable:{BATCH_LENGTH:0},transferables:s.transferables})))}(t,s,e,a,n,r);return l}));return l.xhr=u,l}const Ye={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Ke(t,e,n,r,a,o,i,s){const c=n.info.compressedAttributes.attributes.reduce(((t,e,n)=>{const r=He[e];if(!r)return t;return t[r.name||e]=n,t}),{});return Ge(r,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((n=>We(n,t,e,a,o,i,s)))}const Qe={position:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.position={array:a,componentType:5126,itemSize:3,count:r/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},n+=4*r},normal:function(t,e,n){const r=3*t.vertexCount,a=new Float32Array(e,n,r);return t.normal={array:a,componentType:5126,itemSize:3,count:r/3,type:"VEC3"},n+=4*r},uv0:function(t,e,n){const r=2*t.vertexCount,a=new Float32Array(e,n,r);return t.uv0={array:a,componentType:5126,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},color:function(t,e,n){const r=4*t.vertexCount,a=new Uint8Array(e,n,r);return t.color={array:a,componentType:5121,itemSize:4,count:r/4,type:"VEC4"},n+=r},featureId:function(t,e,n){return n+=8*t.featureCount},id:function(t,e,n){return n+=8*t.featureCount},faceRange:function(t,e,n){const r=2*t.featureCount,a=new Uint32Array(e,n,r);return t.faceRange={array:a,componentType:5125,itemSize:2,count:r/2,type:"VEC2"},n+=4*r},uvRegion:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r},region:function(t,e,n){const r=4*t.vertexCount,a=new Uint16Array(e,n,r);return t["uv-region"]={array:a,componentType:5123,itemSize:4,count:r/4,type:"VEC4"},n+=2*r}};function Ze(t,e,n,r,a,o,i,s){const c={vertexCount:0},u=new DataView(r);try{let t=0;c.vertexCount=u.getUint32(t,1),t+=4,c.featureCount=u.getUint32(t,1),t+=4;const e=n.info.ordering?null:n.info;if(e){const n=[];for(const t in e)"offset"!==t&&""!==t&&n.push(t);for(let e=0;e<n.length;e++)Qe[n[e]]?t=Qe[n[e]](c,r,t):console.error("Unknown decoder for",n[e])}else{const e=n.info;let a=e.ordering,o=e.featureAttributeOrder;const i=null;i&&i.geometryData&&i.geometryData[0]&&i.geometryData[0].params;for(let e=0;e<a.length;e++){const n=Qe[a[e]];n||console.log(a[e]),t=n(c,r,t)}for(let e=0;e<o.length;e++){const n=Qe[o[e]];n||console.log(o[e]),t=n(c,r,t)}}}catch(t){}c.scale_x=1,c.scale_y=1;const l={};for(const t in c){const e=He[t]&&He[t].name;e&&(l[e]=c[t])}if(c.faceRange){const t=c.faceRange.array,e=t.length/2,n=(f=e)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,r=new n(l.POSITION.array.length/3);for(let e=0;e<t.length-1;e+=2){const n=e/2,a=t[e],o=t[e+1];for(let t=a;t<=o;t++)r[3*t]=n,r[3*t+1]=n,r[3*t+2]=n}l._BATCHID={componentType:Bt(n),array:r,itemSize:1,count:r.length,type:"SCALAR"}}var f;return We({attributes:l},t,e,a,o,i,s)}function We(t,e,n,r,a,o,i){const s={attributes:t.attributes,material:n,indices:t.indices,mode:4};!function(t){const e=t.array,n=t.meta&&t.meta["i3s-scale_x"],r=t.meta&&t.meta["i3s-scale_y"];if(n&&r&&(1!==n||1!==r))for(let t=0;t<e.length;t+=3)e[t]*=n.value,e[t+1]*=r.value}(t.attributes.POSITION);const u=function(t,e,n,r,a){let o,i=[0,0,0,1];const s=[0,0],u=je([],n,r,a);u[2]=n[2];const l=e&&c(Ve,e);return ye(t,(t=>(i[0]=t[0],i[1]=t[1],i[2]=t[2],l||(i=p(i,i,e)),n&&d(i,i,n),je(s,i,r,a),o=i[2],t[0]=s[0]-u[0],t[1]=s[1]-u[1],t[2]=o-u[2],t))),u}(t.attributes.POSITION,r,a,o,i);e.meshes[n]={primitives:[s],index:n},e.extensions.MAPTALKS_RTC={projCenter:u},e.extensions.CESIUM_RTC={rtcCoord:a};for(const n in t.attributes)cn(e.transferables,t.attributes[n].array.buffer);return t.indices&&cn(e.transferables,t.indices.array.buffer),s}function tn(t,e,n,r,a,o){const i=r.map((t=>function(t,e,n,r,a){if("dds"===e){const e=ve(t),r=e.images.map((e=>new Uint8Array(t,e.offset,e.length))),a="dxt1"===e.format?33777:33779;return Promise.resolve({image:{mipmap:r,width:e.shape[0],height:e.shape[1],mimeType:n},sampler:Ye,format:a})}if("png"===e||"jpg"===e)return function(t,e){rn||(rn=new OffscreenCanvas(2,2),an=rn.getContext("2d",{willReadFrequently:!0}));const n=new Blob([new Uint8Array(t)]);return createImageBitmap(n).then((t=>{let{width:n,height:r}=t;on(n)||(n=sn(n)),on(r)||(r=sn(r));const a=e;a&&(n=Math.min(a,n),r=Math.min(a,r)),rn.width=n,rn.height=r,an.drawImage(t,0,0,n,r),t.close();const o=an.getImageData(0,0,n,r);return{width:n,height:r,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(t,a).then((t=>{t.mimeType=n;return{image:t,sampler:Ye,format:6408}}));if("ktx2"===e)return $e(t,r).then((t=>(t.mimeType=n,{image:t,sampler:Ye,format:t.format})));return null}(t.data,t.format,t.mimeType,a,o).then((t=>{if(t.image)if(t.image.array)cn(e.transferables,t.image.array.buffer);else if(t.image.mipmap)for(let n=0;n<t.image.mipmap.length;n++)cn(e.transferables,t.image.mipmap[n].buffer);return t}))));return Promise.all(i).then((r=>{en(t,e,n,r)}))}function en(t,e,n,r){const a=JSON.parse(JSON.stringify(n)),o=e.textures;r.ptr||(r.ptr=0);for(const t in n)n[t]&&n[t].url?(o.push(r[r.ptr++]),a[t]={index:o.length-1},void 0!==n[t].factor&&(a[t].scale=n[t].factor)):yt(n[t])&&(a[t]=en(-1,e,n[t],r));return t>=0&&(e.materials[t]=a),a}function nn(t,e){for(const n in t)t[n]&&t[n].url?e.push({url:t[n].url,mimeType:t[n].mimeType,format:t[n].format}):yt(t[n])&&nn(t[n],e)}let rn,an;function on(t){return!(t&t-1)&&0!==t}function sn(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}function cn(t,e){e&&(t.indexOf(e)>=0||t.push(e))}function un(t){const e=new Uint8Array(t,0,5);return e[0]==="D".charCodeAt()&&e[1]==="R".charCodeAt()&&e[2]==="A".charCodeAt()&&e[3]==="C".charCodeAt()&&e[4]==="O".charCodeAt()}var ln="undefined"!=typeof Float32Array?Float32Array:Array;function fn(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}var hn=function(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t};!function(){var t=function(){var t=new ln(3);return ln!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}()}();const yn=[];const dn=[],bn=[],mn=[],pn=[],gn=[],vn=[],wn=[];function Mn(t,e,n,r,a,o){fn(pn,t[3*e],t[3*e+1],t[3*e+2]),fn(gn,t[3*n],t[3*n+1],t[3*n+2]),fn(vn,t[3*r],t[3*r+1],t[3*r+2]);const i=hn(dn,vn,gn),s=hn(bn,pn,gn),c=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],s=n[1],c=n[2];return t[0]=a*c-o*s,t[1]=o*i-r*c,t[2]=r*s-a*i,t}(mn,i,s);!function(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;o>0&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o)}(wn,c),a[3*e]=a[3*e]||0,a[3*n]=a[3*n]||0,a[3*r]=a[3*r]||0,a[3*e+1]=a[3*e+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*e+2]=a[3*e+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*e]+=wn[0],a[3*n]+=wn[0],a[3*r]+=wn[0],a[3*e+1]+=wn[1],a[3*n+1]+=wn[1],a[3*r+1]+=wn[1],a[3*e+2]+=wn[2],a[3*n+2]+=wn[2],a[3*r+2]+=wn[2],o[e]+=1,o[n]+=1,o[r]+=1}const{Ajax:Tn,GLTFLoader:An}=a(),kn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],_n=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],On=2*Math.PI*6378137/360,Sn="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xn,Fn,In=!1;if("undefined"!=typeof OffscreenCanvas){try{Fn=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(t){}Fn&&"undefined"!=typeof createImageBitmap&&(In=!0)}const Cn=i([]),En=[0,0,0],Un=[],Nn=[],zn=[],Ln=[],jn={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Dn={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Pn;class Bn{constructor(t,e,n,r){this.id=t,this.options=e,this.U=(...t)=>this.requestImage.call(this,...t),this.N=n,this.L={},r(null,{},[])}j(t){this.D||(this.u=t,this.P=new Wt,this.D=new $t(this.U,An,t),this.B=new Jt(this.U,An,t))}requestImage(t,e){In?fetch(t).then((t=>t.arrayBuffer())).then((t=>{const e=new self.Blob([new Uint8Array(t)]);return createImageBitmap(e)})).then((t=>{xn.width=t.width,xn.height=t.height,Fn.drawImage(t,0,0);const n=Fn.getImageData(0,0,xn.width,xn.height);t.close(),e(null,{width:t.width,height:t.height,data:new Uint8Array(n.data)})})):this.N("requestImage",{url:t},null,e)}loadTile(t,e){this.j(t.supportedFormats);const{service:n,url:r,arraybuffer:a}=t,o=n.fetchOptions||{};if(o.referrer=t.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(t){return t.indexOf("i3s:")>=0}(r)){const a=t.i3sInfo,i=n.maxTextureSize||0,s=Je(a,t.supportedFormats,this.options.projection,t.projection,i,o);return s.then((t=>{if(delete this.L[r],!t)return void e({status:404,url:r,i3sInfo:a});if(!Object.keys(t.gltf.meshes).length)return void e({status:404,url:r,i3sInfo:a});t.gltf.url=r;const{transferables:o}=t;t.magic="b3dm",n.createNormalIfMissed&&this.q(t.gltf),Yn(n)&&this.R(t.gltf),e(null,t,o)})),void(this.L[r]=s.xhr)}if(a){delete this.L[r];const n=St(new DataView(a),0);if("{"===n[0]||" "===n[0]||"<"===n[0]){const n=function(t,e,n){if(Sn){const r=new Uint8Array(t,e,n);return Sn.decode(r)}return mt(new Uint8Array(t,e,n))}(a,0,a.byteLength),o=JSON.parse(n);o.accessors?this.V(o,r,t,"gltf",e):this.G(t.rootIdx,o,a,r,e)}else this.V(a,r,t,n,e)}else{let a=n.urlParams;a&&(a=(r.indexOf("?")>0?"&":"?")+a);const i=r.replace(/\\+/g,"%2B");let s=Tn.getArrayBuffer(i+(a||""),o);const c=s.xhr;s=s.then((n=>{delete this.L[r],n&&n.status?e(n):(t.arraybuffer=n&&n.data,this.loadTile(t,e))})).catch((t=>{delete this.L[r],e(t)})),this.L[r]=c}}V(t,e,n,r,a){r=r&&r.toLowerCase();const{service:o}=n;if("b3dm"===r){this.D.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{if(t.error)return void a(t);const{content:e,transferables:r}=this.$(t,n);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,r)})).catch((t=>{a(t)}))}else if("pnts"===r){const r=n.transform||Cn;this.P.load(e,t).then((t=>{const{content:e,transferables:o}=this.X(t,r,n.rootIdx);this.H(e),a(null,e,o)}))}else if("i3dm"===r){const r=n.transform||Cn;this.B.load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:i}=this.J(t,r,n.rootIdx);o.createNormalIfMissed&&this.q(e.gltf),Yn(o)&&this.R(e.gltf),a(null,e,i)}))}else if("cmpt"===r){new re(this.U,An,this.u,o.maxTextureSize||0).load(e,t,0,0,{maxTextureSize:o.maxTextureSize||0}).then((t=>{const{content:e,transferables:r}=this.Y(t,n);this.K(e,o),Yn(o)&&this.Z(e),a(null,e,r)})).catch((t=>{a(t)}))}else if("gltf"===r){this.h||(this.h=Rt());const r=e.substring(0,e.lastIndexOf("/")),i=t instanceof ArrayBuffer&&{buffer:t,byteOffset:0,byteLength:t.byteLength}||t;let s;try{s=new An(r,i,{transferable:!0,requestImage:this.U,decoders:this.h,supportedFormats:this.u,maxTextureSize:o.maxTextureSize||0})}catch(t){a(t)}s.load({skipAttributeTransform:!1}).then((t=>{t.url=e,this.W(t,null,n),o.createNormalIfMissed&&this.q(t),Yn(o)&&this.R(t),a(null,{magic:"gltf",gltf:t},s.transferables)}))}else a(new Error("unsupported tile format: "+r))}K(t,e){t.content?t.content.forEach((t=>{this.K(t,e)})):e.createNormalIfMissed&&this.q(t.gltf)}Z(t){t.content?t.content.forEach((t=>{this.Z(t)})):this.R(t.gltf)}tt(t,e){if(this.et(t,e)&&!t.attributes.NORMAL){const e=t.attributes.POSITION.array,n=e.length,r=this.nt()?Pn.subarray(0,n):e,a=function(t,e,n){const r=n||[];r.setLength&&r.setLength(t.length);const a=yn;a.length<t.length/3&&(a.length=t.length/3),a.fill(0,0,t.length/3);const o=void 0===e.length?e:e.length;for(let n=0;n<o/3;n++)void 0===e.length?Mn(t,3*n,3*n+1,3*n+2,r,a):Mn(t,e[3*n],e[3*n+1],e[3*n+2],r,a);for(let t=0;t<r.length;t+=3){const e=a[t/3];0!==e?(r[t]/=e,r[t+1]/=e,r[t+2]/=e):(r[t]=0,r[t+1]=0,r[t+2]=0)}return r}(r,t.indices.array,new Float32Array(r.length));t.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}R(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const t in e){e[t].primitives.forEach((t=>{t.compressed_int16_params={};const e=t.attributes;for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const a=Xn(e[n].array,r,e[n].min,e[n].max,n);if(!a)continue;const{array:o,range:i}=a;e[n].componentType=5124,e[n].array=o,t.compressed_int16_params[n]=i}}))}}q(t){if(!t||!t.meshes||t.extensionsUsed&&t.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(t.asset&&t.asset.sharePosition)return;const e=t.meshes;for(const n in e){e[n].primitives.forEach((e=>{this.tt(e,t)}))}}H(t){if(!t||!t.pnts)return;const e=t.pnts;t.compressed_int16_params={};for(const n in e)if(jn[n]&&e[n].array&&e[n].array instanceof Float32Array){let r=1;this.nt()&&"POSITION"===n&&(r=On,t.compressed_int16_params.compressed_ratio=r);const{array:a,range:o}=Xn(e[n].array,r,e[n].min,e[n].max,n);e[n].array=a,t.compressed_int16_params[n]=o}}rt(t){const e=[];for(let n=0;n<t.length;n++){const r=t[n];if(!r.childTile)continue;const a={boundingVolume:{sphere:[r.boundingSphere.center.x,r.boundingSphere.center.y,r.boundingSphere.center.z,r.boundingSphere.radius]},content:{uri:r.childTile},geometricError:r.boundingSphere.radius/r.rangeList*16,refine:"REPLACE"};e.push(a)}return e}G(t,e,n,r,a){return e.capabilities,void a(null,e)}Y(t,e){const{tiles:n}=t,r={magic:"cmpt",content:[]},a=[];for(let t=0;t<n.length;t++){const{magic:o}=n[t];if("b3dm"===o){const{content:o,transferables:i}=this.$(n[t],e);Gn(a,i),r.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.J(n[t],o,i);Gn(a,c),r.content.push(s)}else if("pnts"===o){const{transform:o,rootIdx:i}=e,{content:s,transferables:c}=this.X(n[t],o,i);Gn(a,c),r.content.push(s)}else if("cmpt"===o){const{content:o,transferables:i}=this.Y(n[t],e);Gn(a,i),r.content.push(o)}}return{content:r,transferables:a}}$(t,e){const{gltf:n,transferables:r,featureTable:a}=t;return this.W(n,a,e),delete t.transferables,{content:t,transferables:r}}W(t,e,n){const r=function(t){if(!t||!t.meshes)return!1;if(t.extensions&&t.extensions.KHR_techniques_webgl)return!0;const e="visited";let n=1;const r=[];for(const a in t.meshes){const o=t.meshes[a],{primitives:i}=o;if(i)for(let t=0;t<i.length;t++){const a=i[t].attributes&&i[t].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[e]||(a.array.buffer[e]=n++);const o=n-1+"-"+(a.byteOffset||0);if(r.indexOf(o)>=0)return!0;r.push(o)}}return!1}(t);this.ot(t);n.service.createNormalIfMissed||this.it(t),t.asset||(t.asset={}),r?(t.asset.sharePosition=!0,this.st(t,e,n.upAxis,n.transform)):this.ct(t,e,n.upAxis,n.transform)}J(t,e,n){const{featureTable:r}=t,a=t.i3dm,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,Cn,u);const l=Vn(u);e&&!s&&p(l,l,e);const f=this.ut(l),d=[];je(d,f,i),d[2]=f[2];const b=h([],l),m=[0,0,0],g=[0,0,0],v=[0,0],M=[1/0,1/0,1/0],T=[-1/0,-1/0,-1/0];ye(a.POSITION,(t=>{m[0]=t[0]+o[0],m[1]=t[1]+o[1],m[2]=t[2]+o[2],e&&!s&&p(m,m,e),0===w(m)?y(g,0,0,-6378137):Tt(g,m),je(v,g,i),t[0]=v[0]-d[0],t[1]=v[1]-d[1],t[2]=g[2]-d[2],t[0]<M[0]&&(M[0]=t[0]),t[1]<M[1]&&(M[1]=t[1]),t[2]<M[2]&&(M[2]=t[2]),t[0]>T[0]&&(T[0]=t[0]),t[1]>T[1]&&(T[1]=t[1]),t[2]>T[2]&&(T[2]=t[2])})),a.POSITION.min=M,a.POSITION.max=T,e&&p(l,l,e),t.rtcCenter=b,t.rtcCoord=f,t.projCenter=d,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}X(t,e,n){const{featureTable:r}=t,a=t.pnts,o=r&&r.RTC_CENTER||[0,0,0],i=this.options.projection,s=e&&c(Cn,e),u={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Rn(a.POSITION.array,3,o,e,u);const l=Vn(u),f=this.lt(l),d=h([],l),b=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];let g=[0,0,0,1];const v=[0,0,0],M=[0,0];ye(a.POSITION,(t=>(g[0]=t[0]+o[0],g[1]=t[1]+o[1],g[2]=t[2]+o[2],e&&!s&&(g=p(g,g,e)),0===w(g)?y(v,0,0,-6378137):Tt(v,g),je(M,v,i),t[0]=M[0]-f[0],t[1]=M[1]-f[1],t[2]=v[2]-f[2],t[0]<b[0]&&(b[0]=t[0]),t[1]<b[1]&&(b[1]=t[1]),t[2]<b[2]&&(b[2]=t[2]),t[0]>m[0]&&(m[0]=t[0]),t[1]>m[1]&&(m[1]=t[1]),t[2]>m[2]&&(m[2]=t[2]),t))),a.POSITION.min=b,a.POSITION.max=m,e&&p(l,l,e);const T=this.ut(l);t.rtcCenter=d,t.projCenter=f,t.rtcCoord=T,t.rootIdx=n;const A=t.transferables;return delete t.transferables,{content:t,transferables:A}}ot(t){if(!Array.isArray(t.textures))return;const e=t.textures;for(let t=0;t<e.length;t++){const n=e[t]&&e[t].image&&e[t].image.array;if(n&&n.length){const r=n[0],a=n[1],o=n[2],i=n[3];let s=!0;for(let t=4;t<n.length;t+=4)if(n[t]!==r||n[t+1]!==a||n[t+2]!==o||n[t+3]!==i){s=!1;break}s&&(e[t].image.color=[r/255,a/255,o/255,i/255],delete e[t].image.array)}}}it(t){const e=t.meshes;for(const n in e){const r=e[n];if(!r)continue;const a=r.primitives;if(a)for(let e=0;e<a.length;e++){if(!a[e])continue;if(!a[e].attributes||a[e].attributes.NORMAL)continue;const n=a[e].material;if(!ht(n)){const e=t.materials[n];if(!e)continue;e.extensions||(e.extensions={}),e.extensions.KHR_materials_unlit={}}}}}abortTileLoading(t,e){const n=this.L[t.url];if(Array.isArray(n))for(let t=0;t<n.length;t++)n[t].abort();else n&&n.abort&&n.abort();delete this.L[t.url],e(null)}ft(t,e,n,r){const a=e&&e.RTC_CENTER||t.extensions&&t.extensions.CESIUM_RTC&&t.extensions.CESIUM_RTC.center;let o=kn;"X"===(n=n&&n.toUpperCase())?o=_n:"Z"===n&&(o=Cn),t.extensions=t.extensions||{},t.extensions.CESIUM_RTC||(t.extensions.CESIUM_RTC={}),a&&(t.extensions.CESIUM_RTC.center=a),t.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};oe(t,(t=>{if(!(t.attributes&&t.attributes.POSITION))return;const e=i(Un);t.matrices&&$n(e,t.matrices);const n=t.attributes.POSITION.array,u=t.attributes.POSITION.itemSize;s(e,o,e),r&&s(e,r,e),Rn(n,u,a||En,e,c,t.compressUniforms)}));const u=Vn(c);return{rtcCenter:a,modelCenter:u,upAxisTransform:o}}st(t,e,n,r){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this.ft(t,e,n),u=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=u,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a);const l=h([],a);r&&p(a,a,r),t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),c||(oe(t,(t=>{if(t.attributes&&t.attributes.POSITION){const e=t.attributes.POSITION;if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return;const n=i(Un);t.matrices&&$n(n,t.matrices),s(n,o,n);const r=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],s=e[5],c=e[6],u=e[7],l=e[8],f=e[9],h=e[10],y=e[11],d=e[12],b=e[13],m=e[14],p=e[15],g=n*s-r*i,v=n*c-a*i,w=n*u-o*i,M=r*c-a*s,T=r*u-o*s,A=a*u-o*c,k=l*b-f*d,_=l*m-h*d,O=l*p-y*d,S=f*m-h*b,x=f*p-y*b,F=h*p-y*m,I=g*F-v*x+w*S+M*O-T*_+A*k;return I?(I=1/I,t[0]=(s*F-c*x+u*S)*I,t[1]=(a*x-r*F-o*S)*I,t[2]=(b*A-m*T+p*M)*I,t[3]=(h*T-f*A-y*M)*I,t[4]=(c*O-i*F-u*_)*I,t[5]=(n*F-a*O+o*_)*I,t[6]=(m*w-d*A-p*v)*I,t[7]=(l*A-h*w+y*v)*I,t[8]=(i*x-s*O+u*k)*I,t[9]=(r*O-n*x-o*k)*I,t[10]=(d*T-b*w+p*g)*I,t[11]=(f*w-l*T-y*g)*I,t[12]=(s*_-i*S-c*k)*I,t[13]=(n*S-r*_+a*k)*I,t[14]=(b*v-d*M-m*g)*I,t[15]=(l*M-f*v+h*g)*I,t):null}(Nn,n),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];ye(e,(t=>{p(t,t,n),t[0]=t[0]-l[0],t[1]=t[1]-l[1],t[2]=t[2]-l[2],p(t,t,r),t[0]<a[0]&&(a[0]=t[0]),t[1]<a[1]&&(a[1]=t[1]),t[2]<a[2]&&(a[2]=t[2]),t[0]>c[0]&&(c[0]=t[0]),t[1]>c[1]&&(c[1]=t[1]),t[2]>c[2]&&(c[2]=t[2])})),e.min=a,e.max=c,e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1}})),t.extensions.CESIUM_RTC.center=l)}ct(t,e,n,r){const{modelCenter:a,rtcCenter:o}=this.ft(t,e,n,r),i=this.lt(a);t.extensions.MAPTALKS_RTC.projCenter=i,t.extensions.MAPTALKS_RTC.rtcCoord=t.extensions.CESIUM_RTC.rtcCoord=this.ut(a),oe(t,(e=>{if(e.attributes&&e.attributes.POSITION){const a=this.et(e,t);if(a){const t=e.attributes.POSITION.array.length;(!Pn||Pn.length<t)&&(Pn=new Float32Array(t))}e.attributes.NORMAL&&this.ht(e.attributes.NORMAL,e.matrices,n),e.attributes.TANGENT&&this.ht(e.attributes.TANGENT,e.matrices,n);const{newPositions:i}=this.yt(e.attributes.POSITION,e.matrices,o,t.extensions.MAPTALKS_RTC,n,r,e.compressUniforms,a),{componentType:s}=e.attributes.POSITION;5126!==s&&(e.attributes.POSITION.array=new Float32Array(i))}}));for(const e in t.nodes){t.nodes[e].matrix=Cn}}lt(t){const e=this.options.projection;"identity"===e?h(zn,t):0===w(t)?y(zn,0,0,-6378137):Tt(zn,t),je(Ln,zn,e);const n=zn[2],r=[];return r[0]=Ln[0],r[1]=Ln[1],r[2]=n,r}ht(t,e,n){let r;r="Y"===n?kn:"X"===n?_n:Cn;const a=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t}([],r);if($n(a,e),c(a,Cn))return;const o=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}([],a),i=[];ye(t,(t=>(function(t,e,n){var r=e[0],a=e[1],o=e[2];t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8]}(i,t,o),b(i,i),h(t,i),i)))}yt(t,e,n,r,a,o,s,u){if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return null;const l=i([]);$n(l,e);const f=this.options.projection;a=a&&a.toUpperCase();const h=n;let b=null;"Y"===a?b=kn:"X"===a&&(b=_n);let m=[0,0,0,1];const g=[0,0,0],v=[0,0],M=r.projCenter,T=je([],r.rtcCoord,"EPSG:3857"),A=o&&c(Cn,o),k=t.min=t.min||[],_=t.max=t.max||[];y(k,1/0,1/0,1/0),y(_,-1/0,-1/0,-1/0);const O=s||{},{decode_position_min:S,decode_position_normConstant:x}=O;let F=[0,0,0,0],I=1;S&&(F=S),x&&(I=x);const C=[];return ye(t,((e,n)=>{if(m[0]=e[0]*I+F[0],m[1]=e[1]*I+F[1],m[2]=e[2]*I+F[2],m=p(m,m,l),b&&(m=p(m,m,b)),h&&d(m,m,h),o&&!A&&(m=p(m,m,o)),0===w(m)?y(g,0,0,-6378137):Tt(g,m),u){const t=Pn;je(v,g,f),t[3*n]=v[0]-T[0],t[3*n+1]=v[0]-T[1],t[3*n+2]=v[0]-T[2]}if(je(v,g,f),e instanceof Float32Array)e[0]=v[0]-M[0],e[1]=v[1]-M[1],e[2]=g[2]-M[2];else{const n=v[0]-M[0],r=v[1]-M[1],a=g[2]-M[2];5126!==t.componentType&&(C.push(n),C.push(r),C.push(a),C.push(e[3]))}return e[0]<k[0]&&(k[0]=e[0]),e[1]<k[1]&&(k[1]=e[1]),e[2]<k[2]&&(k[2]=e[2]),e[0]>_[0]&&(_[0]=e[0]),e[1]>_[1]&&(_[1]=e[1]),e[2]>_[2]&&(_[2]=e[2]),e})),t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1,{projCenter:M,newPositions:C}}ut(t){return 0===w(t)?y([],0,0,-6378137):Tt([],t)}onRemove(){}nt(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}et(t,e){if(!t.attributes.POSITION||function(t,e){const n=e.materials[t.material],r=n&&n.extensions&&n.extensions.KHR_materials_unlit;return r}(t,e))return!1;return!t.attributes.TANGENT}}const qn=[];function Rn(t,e,n,r,a,o){const i=o||{},{decode_position_min:s,decode_position_normConstant:c}=i;let u=[0,0,0,0],l=1;s&&(u=s),c&&(l=c);for(let o=0,i=t.length;o<i;o+=e){const{xmin:i,ymin:s,xmax:c,ymax:f,hmin:h,hmax:b}=a;y(qn,t[o]*l+u[0],t[o+1]*l+u[1],t[o+2]*l+u[2]),p(qn,qn,r);const m=d(qn,n,qn);m[0]<i&&(a.xmin=m[0]),m[0]>c&&(a.xmax=m[0]),m[1]<s&&(a.ymin=m[1]),m[1]>f&&(a.ymax=m[1]),e>2&&(m[2]<h&&(a.hmin=m[2]),m[2]>b&&(a.hmax=m[2]))}}function Vn(t){const{xmax:e,ymax:n,xmin:r,ymin:a,hmin:o,hmax:i}=t,s=[(r+e)/2,(a+n)/2,(o+i)/2];return e===-1/0&&(s[0]=0),n===-1/0&&(s[1]=0),i===-1/0&&(s[2]=0),isNaN(s[2])&&(s[2]=0),s}function Gn(t,e){for(let n=0;n<e.length;n++)t.indexOf(e[n])<0&&t.push(e[n])}function $n(t,e){const n=t;for(let t=e.length-1;t>=0;t--)s(n,e[t],n);return n}function Xn(t,e,n,r,a){if(e&&e>1)for(let n=0;n<t.length;n++)(n+1)%3!=0&&(t[n]*=e);let o,i;if(n&&r&&1===e)o=Math.min(...n),i=Math.max(...r);else{const{min:e,max:n}=function(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++)t[r]>n&&(n=t[r]),t[r]<e&&(e=t[r]);return{min:e,max:n}}(t);o=e,i=n}return!function(t,e,n,r){for(let a=0;a<t.length;a++){const o=Hn(Jn(t[a],e,n),e,n);if(Math.abs(o-t[a])>Dn[r])return!1}return!0}(t,o,i,a)&&Dn[a]?null:function(t,e,n){const r=new Int16Array(t.length);for(let a=0;a<t.length;a++)r[a]=Jn(t[a],e,n);return{array:r,range:[e,n]}}(t,o,i)}function Hn(t,e,n){return((t>=32768?-(65536-t)/32768:t/32767)+1)*(n-e)/2+e}function Jn(t,e,n){const r=2*(t-e)/(n-e)-1,a=Math.max(-1,Math.min(1,r));return a<0?32768*a:32767*a}function Yn(t){return void 0===t.compressGeometry||t.compressGeometry}let Kn=0;class Qn{constructor(t){this.workerId=t,this.workers={},this.dt={}}addLayer({actorId:t,mapId:e,layerId:n,params:r},a){if(this.bt(e,n))return;const o=this.gt(e,n),i=r.options;this.workers[o]=new Bn(n,i,((...e)=>this.send.call(this,t,...e)),a)}removeLayer({mapId:t,layerId:e},n){const r=this.bt(t,e),a=this.gt(t,e);delete this.workers[a],r&&r.onRemove(n)}loadTile({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.loadTile(n,r)}abortTileLoading({mapId:t,layerId:e,params:n},r){const a=this.bt(t,e);a&&a.abortTileLoading(n,r)}receive(t){const e=t.callback,n=this.dt[e];delete this.dt[e],n&&t.error?n(new Error(t.error)):n&&n(null,t.data)}send(t,e,n,r,a){const o=a?\`${o}t}-${o}Kn++}\`:null;a&&(this.dt[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:t,command:e,params:n,callback:String(o)},r||[])}gt(t,e){return\`${o}t}-${o}e}\`}bt(t,e){const n=this.gt(t,e);return this.workers[n]}}t.initialize=function(){},t.onmessage=function(t,e){const n=t.data;this.dispatcher||(this.dispatcher=new Qn(t.workerId)),"<response>"===t.type?this.dispatcher.workerId===t.workerId&&this.dispatcher.receive(t):this.dispatcher[n.command]({actorId:n.actorId,mapId:n.mapId,layerId:n.layerId,params:n.params},((t,n,r)=>{t&&404!==t.status&&204!==t.status&&console.error(t),t instanceof Error&&(t={message:t.message}),e(t,n,r)}))}}`
6
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("maptalks"),require("@maptalks/gl")):"function"==typeof define&&define.amd?define(["exports","maptalks","@maptalks/gl"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).maptalks=e.maptalks||{},e.maptalks,e.maptalks)}(this,(function(e,t,r){"use strict";function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var o=n(t),s=n(r);const a="${",i=`function(e){\n/*!\n * @maptalks/gl v0.125.0\n * LICENSE : UNLICENSED\n * (c) 2016-2026 maptalks.com\n */\nconst t=function(){if("undefined"!=typeof undefinedThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof undefined)return global;throw new Error("unable to locate global object")},r=t(),n=r.gl_trans__coders=r.gl_trans__coders||{};function a(){return t().maptalks_gltf_loader}n.inject=function(e){const n=e.toString(),a=n.indexOf("{")+1,o=n.substring(0,a),s=r.gl_trans__coders=r.gl_trans__coders||{};let i=\`${a}o}\\n const _____getGlobal = ${a}t.toString()};\\n const g___lobals = _____getGlobal()\\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};\`;for(const e in s)"inject"!==e&&"getTranscoder"!==e&&"registerTranscoder"!==e&&(i+='tran_____scoders["'+e+'"] ='+s[e].toString()+"\\n;");return i+="\\n("+t().maptalks_gltf_loader_bundle.toString()+")({});\\n",i+="\\n"+n.substring(o.length),i},n.registerTranscoder=function(e,t){n[e]=t},n.getTranscoder=function(e){return n[e]};var o="undefined"!=typeof Float32Array?Float32Array:Array;function s(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function i(e,t,r){var n=t[0],a=t[1],o=t[2],s=t[3],i=t[4],c=t[5],l=t[6],u=t[7],f=t[8],h=t[9],d=t[10],m=t[11],p=t[12],b=t[13],g=t[14],y=t[15],_=r[0],T=r[1],v=r[2],w=r[3];return e[0]=_*n+T*i+v*f+w*p,e[1]=_*a+T*c+v*h+w*b,e[2]=_*o+T*l+v*d+w*g,e[3]=_*s+T*u+v*m+w*y,_=r[4],T=r[5],v=r[6],w=r[7],e[4]=_*n+T*i+v*f+w*p,e[5]=_*a+T*c+v*h+w*b,e[6]=_*o+T*l+v*d+w*g,e[7]=_*s+T*u+v*m+w*y,_=r[8],T=r[9],v=r[10],w=r[11],e[8]=_*n+T*i+v*f+w*p,e[9]=_*a+T*c+v*h+w*b,e[10]=_*o+T*l+v*d+w*g,e[11]=_*s+T*u+v*m+w*y,_=r[12],T=r[13],v=r[14],w=r[15],e[12]=_*n+T*i+v*f+w*p,e[13]=_*a+T*c+v*h+w*b,e[14]=_*o+T*l+v*d+w*g,e[15]=_*s+T*u+v*m+w*y,e}function c(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]&&e[3]===t[3]&&e[4]===t[4]&&e[5]===t[5]&&e[6]===t[6]&&e[7]===t[7]&&e[8]===t[8]&&e[9]===t[9]&&e[10]===t[10]&&e[11]===t[11]&&e[12]===t[12]&&e[13]===t[13]&&e[14]===t[14]&&e[15]===t[15]}function l(){var e=new o(3);return o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function u(e){var t=e[0],r=e[1],n=e[2];return Math.hypot(t,r,n)}function f(e,t,r){var n=new o(3);return n[0]=e,n[1]=t,n[2]=r,n}function h(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function d(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function m(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}function p(e,t){var r=t[0],n=t[1],a=t[2],o=r*r+n*n+a*a;return o>0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function b(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function g(e,t,r){var n=t[0],a=t[1],o=t[2],s=r[3]*n+r[7]*a+r[11]*o+r[15];return s=s||1,e[0]=(r[0]*n+r[4]*a+r[8]*o+r[12])/s,e[1]=(r[1]*n+r[5]*a+r[9]*o+r[13])/s,e[2]=(r[2]*n+r[6]*a+r[10]*o+r[14])/s,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var y=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e},_=function(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e},T=u;function v(){var e=new o(4);return o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}l(),function(){var e,t=(e=new o(4),o!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var w;function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}l(),f(1,0,0),f(0,1,0),v(),v(),w=new o(9),o!=Float32Array&&(w[1]=0,w[2]=0,w[3]=0,w[5]=0,w[6]=0,w[7]=0),w[0]=1,w[4]=1,w[8]=1;var A={exports:{}},I={exports:{}},M=function(e){return!(!e||"string"==typeof e)&&(e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&"String"!==e.constructor.name))},x=Array.prototype.concat,C=Array.prototype.slice,S=I.exports=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var a=e[r];M(a)?t=x.call(t,C.call(a)):t.push(a)}return t};S.wrap=function(e){return function(){return e(S(arguments))}};var N=I.exports,L={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},E=N,k=Object.hasOwnProperty,P=Object.create(null);for(var U in L)k.call(L,U)&&(P[L[U]]=U);var R=A.exports={to:{},get:{}};function B(e,t,r){return Math.min(Math.max(t,e),r)}function F(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}R.get=function(e){var t,r;switch(e.substring(0,3).toLowerCase()){case"hsl":t=R.get.hsl(e),r="hsl";break;case"hwb":t=R.get.hwb(e),r="hwb";break;default:t=R.get.rgb(e),r="rgb"}return t?{model:r,value:t}:null},R.get.rgb=function(e){if(!e)return null;var t,r,n,a=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(n=t[2],t=t[1],r=0;r<3;r++){var o=2*r;a[r]=parseInt(t.slice(o,o+2),16)}n&&(a[3]=parseInt(n,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(n=(t=t[1])[3],r=0;r<3;r++)a[r]=parseInt(t[r]+t[r],16);n&&(a[3]=parseInt(n+n,16)/255)}else if(t=e.match(/^rgba?\\(\\s*([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)(?=[\\s,])\\s*(?:,\\s*)?([+-]?\\d+)\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)){for(r=0;r<3;r++)a[r]=parseInt(t[r+1],0);t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\\(\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*,?\\s*([+-]?[\\d\\.]+)\\%\\s*(?:[,|\\/]\\s*([+-]?[\\d\\.]+)(%?)\\s*)?\\)$/)))return(t=e.match(/^(\\w+)$/))?"transparent"===t[1]?[0,0,0,0]:k.call(L,t[1])?((a=L[t[1]])[3]=1,a):null:null;for(r=0;r<3;r++)a[r]=Math.round(2.55*parseFloat(t[r+1]));t[4]&&(t[5]?a[3]=.01*parseFloat(t[4]):a[3]=parseFloat(t[4]))}for(r=0;r<3;r++)a[r]=B(a[r],0,255);return a[3]=B(a[3],0,1),a},R.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\\(\\s*([+-]?(?:\\d{0,3}\\.)?\\d+)(?:deg)?\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*,?\\s*([+-]?[\\d\\.]+)%\\s*(?:[,|\\/]\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(t){var r=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,B(parseFloat(t[2]),0,100),B(parseFloat(t[3]),0,100),B(isNaN(r)?1:r,0,1)]}return null},R.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\\(\\s*([+-]?\\d{0,3}(?:\\.\\d+)?)(?:deg)?\\s*,\\s*([+-]?[\\d\\.]+)%\\s*,\\s*([+-]?[\\d\\.]+)%\\s*(?:,\\s*([+-]?(?=\\.\\d|\\d)(?:0|[1-9]\\d*)?(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)\\s*)?\\)$/);if(t){var r=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,B(parseFloat(t[2]),0,100),B(parseFloat(t[3]),0,100),B(isNaN(r)?1:r,0,1)]}return null},R.to.hex=function(){var e=E(arguments);return"#"+F(e[0])+F(e[1])+F(e[2])+(e[3]<1?F(Math.round(255*e[3])):"")},R.to.rgb=function(){var e=E(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},R.to.rgb.percent=function(){var e=E(arguments),t=Math.round(e[0]/255*100),r=Math.round(e[1]/255*100),n=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+r+"%, "+n+"%)":"rgba("+t+"%, "+r+"%, "+n+"%, "+e[3]+")"},R.to.hsl=function(){var e=E(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},R.to.hwb=function(){var e=E(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},R.to.keyword=function(e){return P[e.slice(0,3)]};var D=A.exports,j={exports:{}},G={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},z={};for(var q in G)G.hasOwnProperty(q)&&(z[G[q]]=q);var H=j.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var V in H)if(H.hasOwnProperty(V)){if(!("channels"in H[V]))throw new Error("missing channels property: "+V);if(!("labels"in H[V]))throw new Error("missing channel labels property: "+V);if(H[V].labels.length!==H[V].channels)throw new Error("channel and label counts mismatch: "+V);var $=H[V].channels,Q=H[V].labels;delete H[V].channels,delete H[V].labels,Object.defineProperty(H[V],"channels",{value:$}),Object.defineProperty(H[V],"labels",{value:Q})}H.rgb.hsl=function(e){var t,r,n=e[0]/255,a=e[1]/255,o=e[2]/255,s=Math.min(n,a,o),i=Math.max(n,a,o),c=i-s;return i===s?t=0:n===i?t=(a-o)/c:a===i?t=2+(o-n)/c:o===i&&(t=4+(n-a)/c),(t=Math.min(60*t,360))<0&&(t+=360),r=(s+i)/2,[t,100*(i===s?0:r<=.5?c/(i+s):c/(2-i-s)),100*r]},H.rgb.hsv=function(e){var t,r,n,a,o,s=e[0]/255,i=e[1]/255,c=e[2]/255,l=Math.max(s,i,c),u=l-Math.min(s,i,c),f=function(e){return(l-e)/6/u+.5};return 0===u?a=o=0:(o=u/l,t=f(s),r=f(i),n=f(c),s===l?a=n-r:i===l?a=1/3+t-n:c===l&&(a=2/3+r-t),a<0?a+=1:a>1&&(a-=1)),[360*a,100*o,100*l]},H.rgb.hwb=function(e){var t=e[0],r=e[1],n=e[2];return[H.rgb.hsl(e)[0],100*(1/255*Math.min(t,Math.min(r,n))),100*(n=1-1/255*Math.max(t,Math.max(r,n)))]},H.rgb.cmyk=function(e){var t,r=e[0]/255,n=e[1]/255,a=e[2]/255;return[100*((1-r-(t=Math.min(1-r,1-n,1-a)))/(1-t)||0),100*((1-n-t)/(1-t)||0),100*((1-a-t)/(1-t)||0),100*t]},H.rgb.keyword=function(e){var t=z[e];if(t)return t;var r,n,a,o=1/0;for(var s in G)if(G.hasOwnProperty(s)){var i=G[s],c=(n=e,a=i,Math.pow(n[0]-a[0],2)+Math.pow(n[1]-a[1],2)+Math.pow(n[2]-a[2],2));c<o&&(o=c,r=s)}return r},H.keyword.rgb=function(e){return G[e]},H.rgb.xyz=function(e){var t=e[0]/255,r=e[1]/255,n=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)+.1805*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},H.rgb.lab=function(e){var t=H.rgb.xyz(e),r=t[0],n=t[1],a=t[2];return n/=100,a/=108.883,r=(r/=95.047)>.008856?Math.pow(r,1/3):7.787*r+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(r-n),200*(n-(a=a>.008856?Math.pow(a,1/3):7.787*a+16/116))]},H.hsl.rgb=function(e){var t,r,n,a,o,s=e[0]/360,i=e[1]/100,c=e[2]/100;if(0===i)return[o=255*c,o,o];t=2*c-(r=c<.5?c*(1+i):c+i-c*i),a=[0,0,0];for(var l=0;l<3;l++)(n=s+1/3*-(l-1))<0&&n++,n>1&&n--,o=6*n<1?t+6*(r-t)*n:2*n<1?r:3*n<2?t+(r-t)*(2/3-n)*6:t,a[l]=255*o;return a},H.hsl.hsv=function(e){var t=e[0],r=e[1]/100,n=e[2]/100,a=r,o=Math.max(n,.01);return r*=(n*=2)<=1?n:2-n,a*=o<=1?o:2-o,[t,100*(0===n?2*a/(o+a):2*r/(n+r)),100*((n+r)/2)]},H.hsv.rgb=function(e){var t=e[0]/60,r=e[1]/100,n=e[2]/100,a=Math.floor(t)%6,o=t-Math.floor(t),s=255*n*(1-r),i=255*n*(1-r*o),c=255*n*(1-r*(1-o));switch(n*=255,a){case 0:return[n,c,s];case 1:return[i,n,s];case 2:return[s,n,c];case 3:return[s,i,n];case 4:return[c,s,n];case 5:return[n,s,i]}},H.hsv.hsl=function(e){var t,r,n,a=e[0],o=e[1]/100,s=e[2]/100,i=Math.max(s,.01);return n=(2-o)*s,r=o*i,[a,100*(r=(r/=(t=(2-o)*i)<=1?t:2-t)||0),100*(n/=2)]},H.hwb.rgb=function(e){var t,r,n,a,o,s,i,c=e[0]/360,l=e[1]/100,u=e[2]/100,f=l+u;switch(f>1&&(l/=f,u/=f),n=6*c-(t=Math.floor(6*c)),1&t&&(n=1-n),a=l+n*((r=1-u)-l),t){default:case 6:case 0:o=r,s=a,i=l;break;case 1:o=a,s=r,i=l;break;case 2:o=l,s=r,i=a;break;case 3:o=l,s=a,i=r;break;case 4:o=a,s=l,i=r;break;case 5:o=r,s=l,i=a}return[255*o,255*s,255*i]},H.cmyk.rgb=function(e){var t=e[0]/100,r=e[1]/100,n=e[2]/100,a=e[3]/100;return[255*(1-Math.min(1,t*(1-a)+a)),255*(1-Math.min(1,r*(1-a)+a)),255*(1-Math.min(1,n*(1-a)+a))]},H.xyz.rgb=function(e){var t,r,n,a=e[0]/100,o=e[1]/100,s=e[2]/100;return r=-.9689*a+1.8758*o+.0415*s,n=.0557*a+-.204*o+1.057*s,t=(t=3.2406*a+-1.5372*o+-.4986*s)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,[255*(t=Math.min(Math.max(0,t),1)),255*(r=Math.min(Math.max(0,r),1)),255*(n=Math.min(Math.max(0,n),1))]},H.xyz.lab=function(e){var t=e[0],r=e[1],n=e[2];return r/=100,n/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(t-r),200*(r-(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116))]},H.lab.xyz=function(e){var t,r,n,a=e[0];t=e[1]/500+(r=(a+16)/116),n=r-e[2]/200;var o=Math.pow(r,3),s=Math.pow(t,3),i=Math.pow(n,3);return r=o>.008856?o:(r-16/116)/7.787,t=s>.008856?s:(t-16/116)/7.787,n=i>.008856?i:(n-16/116)/7.787,[t*=95.047,r*=100,n*=108.883]},H.lab.lch=function(e){var t,r=e[0],n=e[1],a=e[2];return(t=360*Math.atan2(a,n)/2/Math.PI)<0&&(t+=360),[r,Math.sqrt(n*n+a*a),t]},H.lch.lab=function(e){var t,r=e[0],n=e[1];return t=e[2]/360*2*Math.PI,[r,n*Math.cos(t),n*Math.sin(t)]},H.rgb.ansi16=function(e){var t=e[0],r=e[1],n=e[2],a=1 in arguments?arguments[1]:H.rgb.hsv(e)[2];if(0===(a=Math.round(a/50)))return 30;var o=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(t/255));return 2===a&&(o+=60),o},H.hsv.ansi16=function(e){return H.rgb.ansi16(H.hsv.rgb(e),e[2])},H.rgb.ansi256=function(e){var t=e[0],r=e[1],n=e[2];return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},H.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];var r=.5*(1+~~(e>50));return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},H.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}var r;return e-=16,[Math.floor(e/36)/5*255,Math.floor((r=e%36)/6)/5*255,r%6/5*255]},H.rgb.hex=function(e){var t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},H.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var r=t[0];3===t[0].length&&(r=r.split("").map((function(e){return e+e})).join(""));var n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},H.rgb.hcg=function(e){var t,r=e[0]/255,n=e[1]/255,a=e[2]/255,o=Math.max(Math.max(r,n),a),s=Math.min(Math.min(r,n),a),i=o-s;return t=i<=0?0:o===r?(n-a)/i%6:o===n?2+(a-r)/i:4+(r-n)/i+4,t/=6,[360*(t%=1),100*i,100*(i<1?s/(1-i):0)]},H.hsl.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=1,a=0;return(n=r<.5?2*t*r:2*t*(1-r))<1&&(a=(r-.5*n)/(1-n)),[e[0],100*n,100*a]},H.hsv.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=t*r,a=0;return n<1&&(a=(r-n)/(1-n)),[e[0],100*n,100*a]},H.hcg.rgb=function(e){var t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];var a,o=[0,0,0],s=t%1*6,i=s%1,c=1-i;switch(Math.floor(s)){case 0:o[0]=1,o[1]=i,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=i;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=i,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return a=(1-r)*n,[255*(r*o[0]+a),255*(r*o[1]+a),255*(r*o[2]+a)]},H.hcg.hsv=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t),n=0;return r>0&&(n=t/r),[e[0],100*n,100*r]},H.hcg.hsl=function(e){var t=e[1]/100,r=e[2]/100*(1-t)+.5*t,n=0;return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},H.hcg.hwb=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t);return[e[0],100*(r-t),100*(1-r)]},H.hwb.hcg=function(e){var t=e[1]/100,r=1-e[2]/100,n=r-t,a=0;return n<1&&(a=(r-n)/(1-n)),[e[0],100*n,100*a]},H.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},H.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},H.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},H.gray.hsl=H.gray.hsv=function(e){return[0,0,e[0]]},H.gray.hwb=function(e){return[0,100,e[0]]},H.gray.cmyk=function(e){return[0,0,0,e[0]]},H.gray.lab=function(e){return[e[0],0,0]},H.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r},H.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};var K=j.exports,Z=K;function X(e){var t=function(){for(var e={},t=Object.keys(Z),r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null};return e}(),r=[e];for(t[e].distance=0;r.length;)for(var n=r.pop(),a=Object.keys(Z[n]),o=a.length,s=0;s<o;s++){var i=a[s],c=t[i];-1===c.distance&&(c.distance=t[n].distance+1,c.parent=n,r.unshift(i))}return t}function Y(e,t){return function(r){return t(e(r))}}function J(e,t){for(var r=[t[e].parent,e],n=Z[t[e].parent][e],a=t[e].parent;t[a].parent;)r.unshift(t[a].parent),n=Y(Z[t[a].parent][a],n),a=t[a].parent;return n.conversion=r,n}var W=K,ee=function(e){for(var t=X(e),r={},n=Object.keys(t),a=n.length,o=0;o<a;o++){var s=n[o];null!==t[s].parent&&(r[s]=J(s,t))}return r},te={};Object.keys(W).forEach((function(e){te[e]={},Object.defineProperty(te[e],"channels",{value:W[e].channels}),Object.defineProperty(te[e],"labels",{value:W[e].labels});var t=ee(e);Object.keys(t).forEach((function(r){var n=t[r];te[e][r]=function(e){var t=function(t){if(null==t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var r=e(t);if("object"==typeof r)for(var n=r.length,a=0;a<n;a++)r[a]=Math.round(r[a]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}(n),te[e][r].raw=function(e){var t=function(t){return null==t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))}));var re=D,ne=te,ae=[].slice,oe=["keyword","gray","hex"],se={};Object.keys(ne).forEach((function(e){se[ae.call(ne[e].labels).sort().join("")]=e}));var ie={};function ce(e,t){if(!(this instanceof ce))return new ce(e,t);if(t&&t in oe&&(t=null),t&&!(t in ne))throw new Error("Unknown model: "+t);var r,n;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof ce)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if("string"==typeof e){var a=re.get(e);if(null===a)throw new Error("Unable to parse color from string: "+e);this.model=a.model,n=ne[this.model].channels,this.color=a.value.slice(0,n),this.valpha="number"==typeof a.value[n]?a.value[n]:1}else if(e.length){this.model=t||"rgb",n=ne[this.model].channels;var o=ae.call(e,0,n);this.color=fe(o,n),this.valpha="number"==typeof e[n]?e[n]:1}else if("number"==typeof e)e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;var s=Object.keys(e);"alpha"in e&&(s.splice(s.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);var i=s.sort().join("");if(!(i in se))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=se[i];var c=ne[this.model].labels,l=[];for(r=0;r<c.length;r++)l.push(e[c[r]]);this.color=fe(l)}if(ie[this.model])for(n=ne[this.model].channels,r=0;r<n;r++){var u=ie[this.model][r];u&&(this.color[r]=u(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function le(e,t,r){return(e=Array.isArray(e)?e:[e]).forEach((function(e){(ie[e]||(ie[e]=[]))[t]=r})),e=e[0],function(n){var a;return arguments.length?(r&&(n=r(n)),(a=this[e]()).color[t]=n,a):(a=this[e]().color[t],r&&(a=r(a)),a)}}function ue(e){return function(t){return Math.max(0,Math.min(e,t))}}function fe(e,t){for(var r=0;r<t;r++)"number"!=typeof e[r]&&(e[r]=0);return e}function he(e){return null==e}function de(e){return"object"==typeof e&&!!e}function me(e){return e/Math.PI*180}ce.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var t=this.model in re.to?this:this.rgb(),r=1===(t=t.round("number"==typeof e?e:1)).valpha?t.color:t.color.concat(this.valpha);return re.to[t.model](r)},percentString:function(e){var t=this.rgb().round("number"==typeof e?e:1),r=1===t.valpha?t.color:t.color.concat(this.valpha);return re.to.rgb.percent(r)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},t=ne[this.model].channels,r=ne[this.model].labels,n=0;n<t;n++)e[r[n]]=this.color[n];return 1!==this.valpha&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,1!==this.valpha&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,1!==this.valpha&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new ce(this.color.map(function(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new ce(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:le("rgb",0,ue(255)),green:le("rgb",1,ue(255)),blue:le("rgb",2,ue(255)),hue:le(["hsl","hsv","hsl","hwb","hcg"],0,(function(e){return(e%360+360)%360})),saturationl:le("hsl",1,ue(100)),lightness:le("hsl",2,ue(100)),saturationv:le("hsv",1,ue(100)),value:le("hsv",2,ue(100)),chroma:le("hcg",1,ue(100)),gray:le("hcg",2,ue(100)),white:le("hwb",1,ue(100)),wblack:le("hwb",2,ue(100)),cyan:le("cmyk",0,ue(100)),magenta:le("cmyk",1,ue(100)),yellow:le("cmyk",2,ue(100)),black:le("cmyk",3,ue(100)),x:le("xyz",0,ue(100)),y:le("xyz",1,ue(100)),z:le("xyz",2,ue(100)),l:le("lab",0,ue(100)),a:le("lab",1),b:le("lab",2),keyword:function(e){return arguments.length?new ce(e):ne[this.model].keyword(this.color)},hex:function(e){return arguments.length?new ce(e):re.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity:function(){for(var e=this.rgb().color,t=[],r=0;r<e.length;r++){var n=e[r]/255;t[r]=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast:function(e){var t=this.luminosity(),r=e.luminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},level:function(e){var t=this.contrast(e);return t>=7.1?"AAA":t>=4.5?"AA":""},isDark:function(){var e=this.rgb().color;return(299*e[0]+587*e[1]+114*e[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten:function(e){var t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken:function(e){var t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate:function(e){var t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate:function(e){var t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten:function(e){var t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken:function(e){var t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale:function(){var e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return ce.rgb(t,t,t)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var t=this.hsl(),r=t.color[0];return r=(r=(r+e)%360)<0?360+r:r,t.color[0]=r,t},mix:function(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var r=e.rgb(),n=this.rgb(),a=void 0===t?.5:t,o=2*a-1,s=r.alpha()-n.alpha(),i=((o*s==-1?o:(o+s)/(1+o*s))+1)/2,c=1-i;return ce.rgb(i*r.red()+c*n.red(),i*r.green()+c*n.green(),i*r.blue()+c*n.blue(),r.alpha()*a+n.alpha()*(1-a))}},Object.keys(ne).forEach((function(e){if(-1===oe.indexOf(e)){var t=ne[e].channels;ce.prototype[e]=function(){if(this.model===e)return new ce(this);if(arguments.length)return new ce(arguments,e);var r,n="number"==typeof arguments[t]?t:this.valpha;return new ce((r=ne[this.model][e].raw(this.color),Array.isArray(r)?r:[r]).concat(n),e)},ce[e]=function(r){return"number"==typeof r&&(r=fe(ae.call(arguments),t)),new ce(r,e)}}}));const pe=[1,1,1,1,2,2,3,0];function be(e){const t=e.length;let r="";for(let n=0;n<t;){let a=e[n++];if(128&a){let r=pe[a>>3&7];if(!(64&a)||!r||n+r>t)return null;for(a&=63>>r;r>0;r-=1){const t=e[n++];if(128!=(192&t))return null;a=a<<6|63&t}}r+=String.fromCharCode(a)}return r}new Array(3),new Array(3);const ge=[1/6378137,1/6378137,1/6356752.314245179],ye=[1/40680631590769,1/40680631590769,1/40408299984661.445],_e=new Array(3),Te=new Array(3),ve=new Array(3);function we(e,t){const r=ye,n=function(e,t,r,n,a){const o=t[0],s=t[1],i=t[2],c=r[0],l=r[1],u=r[2],f=o*o*c*c,h=s*s*l*l,d=i*i*u*u,m=f+h+d,p=Math.sqrt(1/m),b=function(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}(Oe,t,p);if(m<a)return isFinite(p)?b:void 0;const g=n[0],y=n[1],_=n[2],T=Ae;T[0]=b[0]*g*2,T[1]=b[1]*y*2,T[2]=b[2]*_*2;let v,w,O,A,I,M,x,C,S,N,L,E=(1-p)*Me(t)/(.5*Me(T)),k=0;do{E-=k,O=1/(1+E*g),A=1/(1+E*y),I=1/(1+E*_),M=O*O,x=A*A,C=I*I,S=M*O,N=x*A,L=C*I,v=f*M+h*x+d*C-1,w=f*S*g+h*N*y+d*L*_;k=v/(-2*w)}while(Math.abs(v)>Ie);return e[0]=o*O,e[1]=s*A,e[2]=i*I,e}(_e,t,ge,r,.1);let a=_(Te,n,r);a=function(e,t){const r=t[0],n=t[1],a=t[2];let o=r*r+n*n+a*a;o>0&&(o=Math.sqrt(o),e[0]=t[0]/o,e[1]=t[1]/o,e[2]=t[2]/o);return e}(a,a);const o=y(ve,t,n),s=Math.atan2(a[1],a[0]),i=Math.asin(a[2]),c=(l=b(o,t),(Math.sign?Math.sign(l):0==(l=+l)||isNaN(l)?Number(l):l>0?1:-1)*Me(o));var l;return e[0]=me(s),e[1]=me(i),e[2]=c,e}const Oe=new Array(3),Ae=new Array(3),Ie=1e-12;function Me(e){return u(e)}function xe(e,t){let r="";for(let n=0;n<4;n++){const a=e.getUint8(t+n);r+=String.fromCharCode(a)}return r}const Ce="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function Se(e,t,r){const n=new Uint8Array(e,t,r);return Ce?JSON.parse(Ce.decode(n)):JSON.parse(be(n))}function Ne(e,t,r){const n=new Uint8Array(e,t,r);return Ce?JSON.parse(Ce.decode(n)):JSON.parse(be(n))}function Le(e,t,r){return{offset:t,byteLength:r}}function Ee(e,t,r,n){const{byteOffset:a,componentType:o,type:s}=e,{ctor:i,type:c}=function(e){return Ue[e]}(o||"UNSIGNED_SHORT"),l=function(e){if(!e)return 1;return Pe[e]}(s);return{byteStride:0,byteOffset:a+r,itemSize:l,count:n*l,componentType:c,array:new i(t,r+a,n*l)}}function ke(e,t,r,n){const a=Ee(e,t,r,n);return a.array.buffer.byteLength!==t.byteLength&&(a.array=a.array.slice()),a}const Pe={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};const Ue={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Re(e){for(const t in Ue)if(e===Ue[t].ctor)return Ue[t].type;throw new Error("unrecognized ctor:"+e)}function Be(e,t,r,n){const a=e,o=t.length/3;for(let e=0;e<o;e++)a[3*e]=t[3*e]/65535*n[0]+r[0],a[3*e+1]=t[3*e+1]/65535*n[1]+r[1],a[3*e+2]=t[3*e+2]/65535*n[2]+r[2];return a}function Fe(e,t,r){const n=e.getUint32(12,!0),a=e.getUint32(16,!0),o=e.getUint32(20,!0),s=e.getUint32(24,!0),i=e.buffer;let c,l={},u={},f=null;n>0&&(l=Se(i,t,n),t+=n),a>0&&(c=function(e,t,r){return{offset:t,byteLength:r}}(0,t,a),t+=a),o>0&&(u=Ne(i,t,o),t+=o);const h=Le(0,t,s);return f=i.slice(h.offset,h.offset+h.byteLength),r.push(f),{featureTable:l,featureTableBin:c,batchTable:u,batchTableBin:f}}const De={5120:Int8Array,5122:Int16Array,5124:Int32Array,5121:Uint8Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function je(e){for(const t in De)if(e===De[t])return+t;throw new Error("unrecognized ctor:"+e)}let Ge=null;function ze(){return Ge||(Ge={"image/crn":n.crn&&n.crn(),"image/ktx2":n.ktx2&&n.ktx2(),"image/cttf":n.ktx2&&n.ktx2(),"draco":n.draco&&n.draco()}),Ge}const{Ajax:qe,GLTFLoader:He}=a();class Ve{constructor(e,t,r){this._requestImage=e,this._loaderCtor=t||He,this._supportedFormats=r,this._decoders=ze()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(e,t,r=0,n=0,a){return t?(n||(n=t.byteLength),this._parse(e,t,r,n,a)):qe.getArrayBuffer(e,{}).then((t=>{const a=t.data;return n||(n=a.byteLength),this._parse(e,a,r,n)}))}_parse(e,t,r,n,a){const o=a&&a.maxTextureSize,s=this._readB3DM(t,r,n,e);if(s.error)return Promise.resolve(s);const i=e.substring(0,e.lastIndexOf("/"));let c;try{c=new this._loaderCtor(i,s.glb,{transferable:!0,requestImage:this._requestImage,decoders:this._decoders,supportedFormats:this._supportedFormats,maxTextureSize:o})}catch(e){return Promise.resolve({error:e})}return c.load({skipAttributeTransform:!1}).then((t=>{t.url=\`${a}e}-${a}r}-${a}n}\`;const a=c.transferables;for(let e=0;e<s.transferables.length;e++)a.indexOf(s.transferables[e])<0&&a.push(s.transferables[e]);return{magic:"b3dm",count:s.count,transferables:a,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,gltf:t}}))}_readB3DM(e,t,r,n){const a=new DataView(e,t,r),o=a.getUint32(4,!0);if(1!==o){const e="Unsupported b3dm version: "+o+", url:"+n;return console.warn(e),{error:e}}if(a.getUint32(8,!0)!==a.byteLength){const e="Length in b3dm header is inconsistent with b3dm's byte length, url: "+n;return console.warn(e),{error:e}}let s,i=a.getUint32(12,!0),c=a.getUint32(16,!0),l=a.getUint32(20,!0),u=a.getUint32(24,!0),f=28+t;l>=570425344?(f-=8,s=i,l=c,u=0,i=0,c=0):u>=570425344&&(f-=4,s=l,l=i,u=c,i=0,c=0);const h=[e];let d,m,p;if(i>0?(d=Se(e,f,i),f+=i,s=d.BATCH_LENGTH):d={"BATCH_LENGTH":s},c>0&&(f+=c),l>0&&(m=Ne(e,f,l),f+=l,u>0)){const t=Le(0,f,u);p=e.slice(t.offset,t.offset+t.byteLength),f+=u,h.push(p)}const b=d.BATCH_LENGTH,g={};if(d&&d.BATCH_ID){g.BATCH_ID=ke(d.BATCH_ID,e,undefined.offset,b);const t=g.BATCH_ID.array&&g.BATCH_ID.array.buffer;t&&h.indexOf(t)<0&&h.push(t)}return{count:s,transferables:h,featureTable:d,batchTable:m,batchTableBin:p,b3dm:g,glb:{buffer:e,byteOffset:f,byteLength:a.byteLength+a.byteOffset-f}}}_readBatchTable(){return null}}const{Ajax:$e,GLTFLoader:Qe}=a();class Ke{constructor(e,t,r,n){this._requestImage=e,this._loaderCtor=t||Qe,this._supportedFormats=r,this._decoders=ze(),this._maxTextureSize=n}load(e,t,r=0,n=0,a){return t?(n||(n=t.byteLength),this._parse(e,t,r,n,a)):$e.getArrayBuffer(e,{}).then((t=>{const a=t.data;return n||(n=a.byteLength),this._parse(e,a,r,n)}))}_parse(e,t,r,n,a){return this._parseGLTF(e,t,r,n,a).then((({gltf:a,transferables:o})=>{const s=this._readI3DM(t,r,n,e);if(s.error)return Promise.resolve(s);for(let e=0;e<o.length;e++)-1===s.transferables.indexOf(o[e])&&s.transferables.push(o[e]);return delete a.transferables,Promise.resolve({magic:"i3dm",count:s.count,transferables:s.transferables,featureTable:s.featureTable,batchTable:s.batchTable,batchTableBin:s.batchTableBin,i3dm:s.i3dm,gltf:a})}))}_parseGLTF(e,t,r,n,a){const o=a&&a.maxTextureSize,s={transferable:!0,requestImage:this._requestImage,decoders:this._decoders,supportedFormats:this._supportedFormats,maxTextureSize:o},i=new DataView(t,r,n),c=32+i.getUint32(12,!0)+i.getUint32(16,!0)+i.getUint32(20,!0)+i.getUint32(24,!0);if(0===i.getUint32(28,!0)){let n=be(new Uint8Array(t,c+r,i.byteLength-c));-1==n.indexOf("://")&&(n=e.substring(0,e.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?$e.getArrayBuffer(n,{}).then((e=>this._createGLTFLoader(n,{buffer:e.data,byteOffset:0},s))):$e.getJSON(n,{}).then((e=>this._createGLTFLoader(n,e,s)))}{const n={buffer:t,byteOffset:c+r,byteLength:i.byteLength-c};return this._createGLTFLoader(e,n,s)}}_createGLTFLoader(e,t,r){const n=e.substring(0,e.lastIndexOf("/")),a=new this._loaderCtor(n,t,r);return a.load({skipAttributeTransform:!0}).then((r=>{let n=0,o=0;return t.buffer&&(n=t.byteOffset||0,o=t.byteLength||0),r.url=\`${a}e}-${a}n}-${a}o}\`,{transferables:a.transferables,gltf:r}}))}_readI3DM(e,t,r,n){const a=new DataView(e,t,r),o=a.getUint32(4,!0);if(1!==o){const e="Unsupported pnts version: "+o+", url:"+n;return console.warn(e),{error:e}}if(a.getUint32(8,!0)!==a.byteLength){const e="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(e),{error:e}}const s=[e],{featureTable:i,featureTableBin:c,batchTable:l,batchTableBin:u}=Fe(a,32+t,s),f={},h=i.INSTANCES_LENGTH;if(i.POSITION){const{byteOffset:t}=i.POSITION;f.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(e,t+c.offset,3*h).slice()},s.push(f.POSITION.array.buffer)}else if(i.POSITION_QUANTIZED){const t=i.QUANTIZED_VOLUME_OFFSET,r=i.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=i.POSITION_QUANTIZED;f.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._convertQuantizedPosition(new Uint16Array(e,n+c.offset,3*h),t,r)},s.push(f.POSITION.array.buffer)}if(i.BATCH_ID){f.BATCH_ID=ke(i.BATCH_ID,e,c.offset,h);const t=f.BATCH_ID.array&&f.BATCH_ID.array.buffer;t&&s.indexOf(t)<0&&s.push(t)}if(i.NORMAL_UP){let{byteOffset:t}=i.NORMAL_UP;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(e,t+c.offset,3*h).slice()},s.push(f.NORMAL_UP.array.buffer),t=i.NORMAL_RIGHT.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(e,t+c.offset,3*h).slice()},s.push(f.NORMAL_RIGHT.array.buffer)}else if(i.NORMAL_UP_OCT32P){let{byteOffset:t}=i.NORMAL_UP_OCT32P;f.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._decodeOCT32p(new Uint16Array(e,t+c.offset,2*h))},s.push(f.NORMAL_UP.array.buffer),t=i.NORMAL_RIGHT_OCT32P.byteOffset,f.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:this._decodeOCT32p(new Uint16Array(e,t+c.offset,2*h))},s.push(f.NORMAL_RIGHT.array.buffer)}if(i.SCALE){const{byteOffset:t}=i.SCALE;f.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:h,componentType:5126,array:new Float32Array(e,t+c.offset,h).slice()},s.push(f.SCALE.array.buffer)}else if(i.SCALE_NON_UNIFORM){const{byteOffset:t}=i.SCALE_NON_UNIFORM;f.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:h,componentType:5126,array:new Float32Array(e,t+c.offset,3*h).slice()},s.push(f.SCALE_NON_UNIFORM.array.buffer)}return{count:h,batchTable:l,batchTableBin:u,featureTable:i,i3dm:f,transferables:s}}_decodeOCT32p(e){const t=e.length/2,r=new Float32Array(3*t),n=[];for(let a=0;a<t;a++)Ze(n,e[2*a],e[2*a+1],65535),r[3*a]=n[0],r[3*a+1]=n[1],r[3*a+2]=n[2];return r}_convertQuantizedPosition(e,t,r){return Be(new Float32Array(e.length),e,t,r)}_readBatchTable(){return null}}function Ze(e,t,r,n){if(e[0]=Xe(t,n),e[1]=Xe(r,n),e[2]=1-(Math.abs(e[0])+Math.abs(e[1])),e[2]<0){const t=e[0];e[0]=(1-Math.abs(e[1]))*Ye(t),e[1]=(1-Math.abs(t))*Ye(e[1])}return p(e,e)}function Xe(e,t){return function(e,t,r){return e<t?t:e>r?r:e}(e,0,t=function(e,t){if(null!=e)return e;return t}(t,255))/t*2-1}function Ye(e){return e<0?-1:1}const{Ajax:Je}=a();class We{constructor(){}load(e,t,r=0,n=0){return t?(n||(n=t.byteLength),this._parse(e,t,r,n)):Je.getArrayBuffer(e,{}).then((t=>{const a=t.data;return n||(n=a.byteLength),this._parse(e,a,r,n)}))}_parse(e,t,r,n){return this._readPNTS(t,r,n,e).then((e=>e.error?e:{magic:"pnts",count:e.count,transferables:e.transferables,featureTable:e.featureTable,batchTable:e.batchTable,batchTableBin:e.batchTableBin,pnts:e.pnts}))}_readPNTS(e,t,r,n){const a=new DataView(e,t,r),o=a.getUint32(4,!0);if(1!==o){const e="Unsupported pnts version: "+o+", url:"+n;return console.warn(e),{error:e}}if(a.getUint32(8,!0)!==a.byteLength){const e="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(e),{error:e}}const s=[e],{featureTable:i,featureTableBin:c,batchTable:l,batchTableBin:u}=Fe(a,t+28,s),f=i.QUANTIZED_VOLUME_OFFSET,h=i.QUANTIZED_VOLUME_SCALE,d=i.POINTS_LENGTH;let m,p={};if(i.extensions&&i.extensions["3DTILES_draco_point_compression"]){p=i.extensions["3DTILES_draco_point_compression"],m=new DataView(e,p.byteOffset+c.offset,p.byteLength);const t={attributes:p.properties,useUniqueIDs:!1};return this._draco||(this._draco=ze().draco),this._draco(m,t).then((t=>{const r=t.attributes;!i.POSITION&&!i.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=i.POSITION,r.POSITION_QUANTIZED=i.POSITION_QUANTIZED),!(i.RGB||i.RGBA||i.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=i.RGB,r.RGBA=i.RGBA,r.RGB565=i.RGB565),!i.NORMAL&&!i.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=i.NORMAL,r.NORMAL_OCT16P=i.NORMAL_OCT16P);const n=this._readAttributes(e,t.attributes,c.offset,d,s,f,h);if(t.attributes.BATCH_ID){const e=t.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:e.length,componentType:Re(e.constructor),array:e},s.push(e.buffer)}else if(i.BATCH_ID||Object.keys(l).length){i.BATCH_ID?n.BATCH_ID=ke(i.BATCH_ID,e,c.offset,d):n.BATCH_ID=et(d);const t=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;t&&s.indexOf(t)<0&&s.push(t)}return{count:d,batchTable:l,batchTableBin:u,featureTable:i,pnts:n,transferables:s}}))}const b=this._readAttributes(e,i,c.offset,d,s,f,h);if(i.BATCH_ID||Object.keys(l).length){i.BATCH_ID?b.BATCH_ID=ke(i.BATCH_ID,e,c.offset,d):b.BATCH_ID=et(d);const t=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;t&&s.indexOf(t)<0&&s.push(t)}return Promise.resolve({count:d,batchTable:l,batchTableBin:u,featureTable:i,pnts:b,transferables:s})}_readAttributes(e,t,r,n,a,o,s){const i={};if(t.POSITION){let{byteOffset:o,array:s}=t.POSITION;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+3*n*4);s=new Float32Array(t)}i.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:s},a.push(s.buffer)}else if(t.POSITION_QUANTIZED){let{byteOffset:c}=t.POSITION_QUANTIZED;const{array:l}=t.POSITION_QUANTIZED;c=c||0;const u=l?0:r;i.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this._convertQuantizedPosition(l||new Uint16Array(e,c+u,3*n),o,s)},a.push(i.POSITION.array.buffer)}if(t.RGBA){let{byteOffset:o,array:s}=t.RGBA;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+4*n);s=new Uint8Array(t)}i.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:s},a.push(s.buffer)}else if(t.RGB){let{byteOffset:o,array:s}=t.RGB;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+3*n);s=new Uint8Array(t)}i.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:s},a.push(s.buffer)}else if(t.RGB565){let{byteOffset:o,array:s}=t.RGB565;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+2*n);s=new Uint16Array(t)}i.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:s},a.push(s.buffer)}if(t.NORMAL){let{byteOffset:o,array:s}=t.NORMAL;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+3*n*4);s=new Float32Array(t)}i.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:s},a.push(s.buffer)}else if(t.NORMAL_OCT16P){let{byteOffset:o,array:s}=t.NORMAL_OCT16P;o=o||0;const c=s?0:r;if(!s){const t=e.slice(o+c,o+c+2*n);s=new Uint8Array(t)}i.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:s},a.push(s.buffer)}return i}_convertQuantizedPosition(e,t,r){return Be(new Float32Array(e.length),e,t,r)}_readBatchTable(){return null}}function et(e){const t=(r=e)<256?Uint8Array:r<65536?Uint16Array:Uint32Array;var r;const n=new t(e);for(let t=0;t<e;t++)n[t]=t;return{byteStride:0,byteOffset:0,itemSize:1,count:e,componentType:Re(t),array:n}}const{Ajax:tt,GLTFLoader:rt}=a();class nt{constructor(e,t,r,n){this._supportedFormats=r,this._requestImage=e,this._loaderCtor=t||rt,this._maxTextureSize=n}load(e,t,r=0,n=0,a){return t?this._parse(e,t,r,n,a):tt.getArrayBuffer(e,{}).then((t=>{const a=t.data;return this._parse(e,a,r,n)}))}_parse(e,t,r,n,a){n||(n=t.byteLength);const o=this._readCMPT(t,e,r,n),s=[];for(let r=0;r<o.length;r++){let n;if("b3dm"===o[r].magic)n=new Ve(this._requestImage,this._loaderCtor,this._supportedFormats);else if("i3dm"===o[r].magic)n=new Ke(this._requestImage,this._loaderCtor,this._supportedFormats,this._maxTextureSize);else if("pnts"===o[r].magic)n=new We;else{if("cmpt"!==o[r].magic){console.warn("Unsupported magic in CMPT tile:",o[r].magic);continue}n=new nt(this._requestImage,this._loaderCtor,this._supportedFormats,this._maxTextureSize)}s.push(n.load(e,t,o[r].offset,o[r].byteLength,a).then((e=>e)))}return Promise.all(s).then((e=>({magic:"cmpt",tiles:e})))}_readCMPT(e,t,r,n){const a=new DataView(e,r,n),o=a.getUint32(4,!0);if(1!==o){const e="Unsupported cmpt version: "+o+", url:"+t;return console.warn(e),{error:e}}if(16===a.byteLength)return[];const s=[],i=a.getUint32(12,!0);let c=16;for(let t=0;t<i;t++){const t=xe(a,c),n=a.getUint32(c+8,!0);s.push({magic:t,buffer:e,offset:c+r,byteLength:n}),c+=n}return s}}const{GLTFLoader:at}=a();function ot(e,t){if(e.scenes&&e.scenes.length)for(let r=0,n=e.scenes.length;r<n;r++){const n=e.scenes[r].nodes;for(let r=0,a=n.length;r<a;r++){const a=[];ht(n[r],a,e,t)}}}const st=[],it=[],ct=[],lt=[0,0,0],ut=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}([]),ft=[1,1,1];function ht(e,t,r,n){const a=t.slice(0);if(e.matrix)a.push(e.matrix);else if(e.rotation||e.translation||e.scale){const t=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(st,e.translation||lt),r=function(e,t){var r=t[0],n=t[1],a=t[2],o=t[3],s=r+r,i=n+n,c=a+a,l=r*s,u=n*s,f=n*i,h=a*s,d=a*i,m=a*c,p=o*s,b=o*i,g=o*c;return e[0]=1-f-m,e[1]=u+g,e[2]=h-b,e[3]=0,e[4]=u-g,e[5]=1-l-m,e[6]=d+p,e[7]=0,e[8]=h+b,e[9]=d-p,e[10]=1-l-f,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(it,e.rotation||ut),n=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(ct,e.scale||ft);i(n,r,n);const o=i([],t,n);a.push(o)}if(e.children&&e.children.length)for(let t=0,o=e.children.length;t<o;t++)ht(e.children[t],a,r,n);if(void 0!==e.mesh){const t=e.mesh,o=r.meshes[t];if(o){const e=a.slice(0),s=o.primitives;for(let a=0,o=s.length;a<o;a++){const o=s[a];o&&(o.matrices=e,n(o,t,a,r))}}}}function dt(e,t){let{byteOffset:r,byteStride:n,count:a}=e;const{componentType:o,itemSize:s}=e,i=e.array.buffer,c=o?at.getTypedArrayCtor(o):e.array.constructor;r=void 0===r?e.array.byteOffset:r,n=n||0,a=a||e.array.length/s;const l=Math.min(i.byteLength-r,a*s*c.BYTES_PER_ELEMENT);if(a=Math.floor(l/(s*c.BYTES_PER_ELEMENT)),(!n||n===s*c.BYTES_PER_ELEMENT)&&r%c.BYTES_PER_ELEMENT==0){const e=new c(i,r,a*s);for(let n=0;n<a*s;n+=s){t(new c(e.buffer,r+n*c.BYTES_PER_ELEMENT,s),n/s)}return}const u=new Uint8Array(s*c.BYTES_PER_ELEMENT);n||(n=s*c.BYTES_PER_ELEMENT);for(let e=0;e<a;e++){const a=new Uint8Array(i,n*e+r,s*c.BYTES_PER_ELEMENT);u.set(a);t(new c(u.buffer),e),a.set(u)}}var mt=yt("DXT1"),pt=yt("DXT3"),bt=yt("DXT5"),gt=yt("DX10");function yt(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var _t=O((function(e){var t,r,n=new Int32Array(e,0,31);if(542327876!==n[0])throw new Error("Invalid magic number in DDS header");if(4&!n[20])throw new Error("Unsupported format, must contain a FourCC code");var a=n[21];switch(a){case mt:t=8,r="dxt1";break;case pt:t=16,r="dxt3";break;case bt:t=16,r="dxt5";break;case 116:r="rgba32f";break;case gt:var o=new Uint32Array(e.slice(128,148));r=o[0];var s=o[1];if(o[2],o[3],o[4],3!==s||2!==r)throw new Error("Unsupported DX10 texture format "+r);r="rgba32f";break;default:throw new Error("Unsupported FourCC code: "+(i=a,String.fromCharCode(255&i,i>>8&255,i>>16&255,i>>24&255)))}var i;var c=n[2],l=1;131072&c&&(l=Math.max(1,n[7]));var u=!1;512&n[28]&&(u=!0);var f,h=n[4],d=n[3],m=n[1]+4,p=h,b=d,g=[];a===gt&&(m+=20);if(u)for(var y=0;y<6;y++){if("rgba32f"!==r)throw new Error("Only RGBA32f cubemaps are supported");h=p,d=b;for(var _=Math.log(h)/Math.log(2)+1,T=0;T<_;T++)f=h*d*16,g.push({offset:m,length:f,shape:[h,d]}),T<l&&(m+=f),h=Math.floor(h/2),d=Math.floor(d/2)}else for(T=0;T<l;T++)f=Math.max(4,h)/4*Math.max(4,d)/4*t,g.push({offset:m,length:f,shape:[h,d]}),m+=f,h=Math.floor(h/2),d=Math.floor(d/2);return{shape:[p,b],images:g,format:r,flags:c,cubemap:u}})),Tt=Math.abs,vt=Math.sin,wt=Math.cos,Ot=Math.tan,At=Math.atan,It=Math.atan2,Mt=Math.sqrt,xt=Math.log,Ct=Math.hypot,St=Math.sinh,Nt=Math.cosh,Lt=1/0;function Et(e){var t,r,n,a,o,s,i=[],c=[],l=[],u=[];function f(e,t){for(var r,n=2*wt(2*t),a=e.length-1,o=e[a],s=0;--a>=0;)r=n*o-s+e[a],s=o,o=r;return t+r*vt(2*t)}function h(e,t,r){for(var n,a,o=vt(t),s=wt(t),i=St(r),c=Nt(r),l=2*s*c,u=-2*o*i,f=e.length-1,h=e[f],d=0,m=0,p=0;--f>=0;)n=m,a=d,h=l*(m=h)-n-u*(d=p)+e[f],p=u*m-a+l*d;return[(l=o*c)*h-(u=s*i)*p,l*p+u*h]}e.es,o=a=(n=e.es/(1+Mt(1-e.es)))/(2-n),i[0]=a*(2+a*(-2/3+a*(a*(116/45+a*(26/45+a*(-2854/675)))-2))),c[0]=a*(a*(2/3+a*(4/3+a*(-82/45+a*(32/45+a*(4642/4725)))))-2),o*=a,i[1]=o*(7/3+a*(a*(-227/45+a*(2704/315+a*(2323/945)))-1.6)),c[1]=o*(5/3+a*(-16/15+a*(-13/9+a*(904/315+a*(-1522/945))))),o*=a,i[2]=o*(56/15+a*(-136/35+a*(-1262/105+a*(73814/2835)))),c[2]=o*(-26/15+a*(34/21+a*(1.6+a*(-12686/2835)))),o*=a,i[3]=o*(4279/630+a*(-332/35+a*(-399572/14175))),c[3]=o*(1237/630+a*(a*(-24832/14175)-2.4)),o*=a,i[4]=o*(4174/315+a*(-144838/6237)),c[4]=o*(-734/315+a*(109598/31185)),o*=a,i[5]=o*(601676/22275),c[5]=o*(444337/155925),o=a*a,t=e.k0/(1+a)*(1+o*(1/4+o*(1/64+o/256))),l[0]=a*(a*(2/3+a*(-37/96+a*(1/360+a*(81/512+a*(-96199/604800)))))-.5),u[0]=a*(.5+a*(-2/3+a*(5/16+a*(41/180+a*(-127/288+a*(7891/37800)))))),l[1]=o*(-1/48+a*(-1/15+a*(437/1440+a*(-46/105+a*(1118711/3870720))))),u[1]=o*(13/48+a*(a*(557/1440+a*(281/630+a*(-1983433/1935360)))-.6)),o*=a,l[2]=o*(-17/480+a*(37/840+a*(209/4480+a*(-5569/90720)))),u[2]=o*(61/240+a*(-103/140+a*(15061/26880+a*(167603/181440)))),o*=a,l[3]=o*(-4397/161280+a*(11/504+a*(830251/7257600))),u[3]=o*(49561/161280+a*(-179/168+a*(6601661/7257600))),o*=a,l[4]=o*(-4583/161280+a*(108847/3991680)),u[4]=o*(34729/80640+a*(-3418889/1995840)),o*=a,l[5]=o*(-20648693/638668800),u[5]=.6650675310896665*o,s=f(c,e.phi0),r=-t*(s+function(e,t){var r,n=2*wt(t),a=e.length-1,o=e[a],s=0;for(;--a>=0;)r=n*o-s+e[a],s=o,o=r;return vt(t)*r}(u,2*s)),e.fwd=function(e,n){var a,o,s,i,l,d=e.phi,m=e.lam;d=f(c,d),a=vt(d),o=wt(d),i=vt(m),s=wt(m),d=It(a,s*o),m=It(i*o,Ct(a,o*s)),m=function(e){var t=Tt(e);return t=function(e){var t=1+e,r=t-1;return 0===r?e:e*xt(t)/r}(t*(1+t/(Ct(1,t)+1))),e<0?-t:t}(Ot(m)),l=h(u,2*d,2*m),d+=l[0],m+=l[1],Tt(m)<=2.623395162778?(n.y=t*d+r,n.x=t*m):n.x=n.y=Lt},e.inv=function(e,n){var a,o,s,c,u,d=e.y,m=e.x;d=(d-r)/t,Tt(m/=t)<=2.623395162778?(d+=(u=h(l,2*d,2*m))[0],m+=u[1],m=At(St(m)),a=vt(d),o=wt(d),c=vt(m),s=wt(m),m=It(c,s*o),d=It(a*s,Ct(c,s*o)),n.phi=f(i,d),n.lam=m):n.phi=n.lam=Lt}}const kt=Math.PI/180,Pt=6378137*Math.PI/180,Ut=85.0511287798,Rt={};function Bt(e,t,r,n){if("EPSG:3857"===r)return function(e,t){const r=Ut,n=t[0],a=Math.max(Math.min(r,t[1]),-r);let o;o=0===a?0:Math.log(Math.tan((90+a)*kt/2))/kt;return e[0]=n*Pt,e[1]=o*Pt,e}(e,t);if(!r||"EPSG:9807"!==r.code&&"Traverse_Mercator"!==r.code){if("EPSG:4326"===r||"EPSG:4490"===r||"identity"===r)return Ft(e,t);if("baidu"===r)return Ft(e,t);throw new Error("unsupported projection:"+r)}{if(!(!n||4326===n.wkid))return function(e,t){return e[0]=t[0],e[1]=t[1],e}(e,t);const a=JSON.stringify(r);let o=Rt[a];return o||(o=Rt[a]=function(e){const t={a:jt,es:Gt,x0:he(e.falseEasting)?5e5:e.falseEasting,y0:he(e.falseNorthing)?0:e.falseNorthing,k0:e.scaleFactor||.9996,lam0:(e.centralMeridian||0)*Dt,phi0:(e.latitudeOfOrigin||0)*Dt,originLam0:e.startLongtitude||0,originPhi0:e.startLatitude||0};Et(t);const r={lam:0,phi:0},n={};let a=0,o=0;(t.originLam0||t.originPhi0)&&(r.lam=t.originLam0*Dt-t.lam0,r.phi=t.originPhi0*Dt,t.fwd(r,n),a=t.a*n.x+t.x0,o=t.a*n.y+t.y0);return{project:function(e,s){r.lam=e[0]*Dt-t.lam0,r.phi=e[1]*Dt,t.fwd(r,n);const i=t.a*n.x+t.x0-a,c=t.a*n.y+t.y0-o;return s[0]=i,s[1]=c,s}}}(r)),o.project(t,e)}}function Ft(e,t){return e[0]=t[0],e[1]=t[1],e}const Dt=.017453292519943295,jt=6378137,Gt=.0066943799901413165;const{Ajax:zt}=a(),qt=s([]),Ht=ze().draco,Vt=ze().ktx2,$t={"pbrMetallicRoughness":{"baseColorFactor":[.5,.5,.5,1],"metallicFactor":0,"roughnessFactor":.5}},Qt={"position":{name:"POSITION",accessor:{"componentType":5126,"type":"VEC3"}},"normal":{name:"NORMAL",accessor:{"componentType":5126,"type":"VEC3"}},"uv0":{name:"TEXCOORD_0",accessor:{"componentType":5126,"type":"VEC2"}},"color":{name:"COLOR_0",accessor:{"componentType":5121,"type":"VEC4"}},"uv-region":{name:"uvRegion",accessor:{"componentType":5123,"type":"VEC4"}},"feature-index":{name:"_BATCHID",accessor:{"componentType":5125,"type":"SCALAR"}},"faceRange":{name:"faceRange",accessor:{"componentType":5125,"type":"VEC2"}}};function Kt(e,t,r,n,a,o){const i=[],c=[],l=[];for(let t=0;t<e.meshes.length;t++){const{geometry:r,material:n}=e.meshes[t],a=zt.getArrayBuffer(r.url,o);a.xhr.url=r.url,l.push(a.xhr);const s=a.then((e=>({buffer:e})));i.push(s);const u=[];if(rr(n,u),u.length){const e=u.map((e=>{const t=zt.getArrayBuffer(e.url,o);return t.xhr.url=e.url,l.push(t.xhr),t.then((t=>t&&t.status?null:{buffer:t,mimeType:e.mimeType,format:e.format}))}));i.push(...e)}c[t]=u.length}const u=Promise.all(i).then((o=>{for(let e=0;e<o.length;e++)if(!o[e]||!o[e].buffer)return Promise.resolve(null);const i=[];let l=0;for(let e=0;e<c.length;e++){const t=c[e];i.push({geoBuffer:{data:o[l].buffer.data},textureBuffers:o.slice(l+1,t+l+1).map((e=>({data:e.buffer.data,mimeType:e.mimeType,format:e.format})))}),l+=1+t}const u=function(e,t,r,n,a,o){const i={asset:{generator:"i3s",version:"2.0"},extensions:{},scene:0,scenes:[{nodes:[]}],nodes:{},meshes:{},materials:[],skins:[],animations:null,textures:[],transferables:[]},c=[];for(let l=0;l<e.meshes.length;l++){let{material:u}=e.meshes[l];const{geometry:f}=e.meshes[l];let h;const d=t[l].geoBuffer.data;if(!d)continue;h=cr(d)?Xt(i,l,f,d,e.transform,e.center,a,o):Jt(i,l,f,d,e.transform,e.center,a,o),c.push(h),i.nodes[l]={mesh:l,nodeIndex:l,matrix:s([])},i.scenes[0].nodes[l]=i.nodes[l],u||(u=$t);const m=er(l,i,u,t[l].textureBuffers,r,n);c.push(m)}return Promise.all(c).then((()=>({gltf:i,featureTable:{BATCH_LENGTH:0},transferables:i.transferables})))}(e,i,t,a,r,n);return u}));return u.xhr=l,u}const Zt={"magFilter":9728,"minFilter":9728,"wrapR":33071,"wrapS":33071,"wrapT":33071};function Xt(e,t,r,n,a,o,s,i){const c=r.info.compressedAttributes.attributes.reduce(((e,t,r)=>{const n=Qt[t];if(!n)return e;return e[n.name||t]=r,e}),{});return Ht(n,{attributes:c,metadatas:{"POSITION":[{name:"i3s-scale_x",type:"double"},{name:"i3s-scale_y",type:"double"}]},useUniqueIDs:!1,skipAttributeTransform:!1}).then((r=>Wt(r,e,t,a,o,s,i)))}const Yt={position:function(e,t,r){const n=3*e.vertexCount,a=new Float32Array(t,r,n);return e.position={array:a,componentType:5126,itemSize:3,count:n/3,meta:{"i3s-scale_x":1,"i3s-scale_y":1},type:"VEC3"},r+=4*n},normal:function(e,t,r){const n=3*e.vertexCount,a=new Float32Array(t,r,n);return e.normal={array:a,componentType:5126,itemSize:3,count:n/3,type:"VEC3"},r+=4*n},uv0:function(e,t,r){const n=2*e.vertexCount,a=new Float32Array(t,r,n);return e.uv0={array:a,componentType:5126,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},color:function(e,t,r){const n=4*e.vertexCount,a=new Uint8Array(t,r,n);return e.color={array:a,componentType:5121,itemSize:4,count:n/4,type:"VEC4"},r+=n},featureId:function(e,t,r){return r+=8*e.featureCount},id:function(e,t,r){return r+=8*e.featureCount},faceRange:function(e,t,r){const n=2*e.featureCount,a=new Uint32Array(t,r,n);return e.faceRange={array:a,componentType:5125,itemSize:2,count:n/2,type:"VEC2"},r+=4*n},uvRegion:function(e,t,r){const n=4*e.vertexCount,a=new Uint16Array(t,r,n);return e["uv-region"]={array:a,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n},region:function(e,t,r){const n=4*e.vertexCount,a=new Uint16Array(t,r,n);return e["uv-region"]={array:a,componentType:5123,itemSize:4,count:n/4,type:"VEC4"},r+=2*n}};function Jt(e,t,r,n,a,o,s,i){const c={vertexCount:0},l=new DataView(n);try{let e=0;c.vertexCount=l.getUint32(e,1),e+=4,c.featureCount=l.getUint32(e,1),e+=4;const t=r.info.ordering?null:r.info;if(t){const r=[];for(const e in t)"offset"!==e&&""!==e&&r.push(e);for(let t=0;t<r.length;t++)Yt[r[t]]?e=Yt[r[t]](c,n,e):console.error("Unknown decoder for",r[t])}else{const t=r.info;let a=t.ordering,o=t.featureAttributeOrder;const s=null;s&&s.geometryData&&s.geometryData[0]&&s.geometryData[0].params;for(let t=0;t<a.length;t++){const r=Yt[a[t]];r||console.log(a[t]),e=r(c,n,e)}for(let t=0;t<o.length;t++){const r=Yt[o[t]];r||console.log(o[t]),e=r(c,n,e)}}}catch(e){}c.scale_x=1,c.scale_y=1;const u={};for(const e in c){const t=Qt[e]&&Qt[e].name;t&&(u[t]=c[e])}if(c.faceRange){const e=c.faceRange.array,t=e.length/2,r=(f=t)<=255?Uint8Array:f<=65535?Uint16Array:Uint32Array,n=new r(u.POSITION.array.length/3);for(let t=0;t<e.length-1;t+=2){const r=t/2,a=e[t],o=e[t+1];for(let e=a;e<=o;e++)n[3*e]=r,n[3*e+1]=r,n[3*e+2]=r}u._BATCHID={componentType:je(r),array:n,itemSize:1,count:n.length,type:"SCALAR"}}var f;return Wt({attributes:u},e,t,a,o,s,i)}function Wt(e,t,r,n,a,o,s){const i={attributes:e.attributes,material:r,indices:e.indices,mode:4};!function(e){const t=e.array,r=e.meta&&e.meta["i3s-scale_x"],n=e.meta&&e.meta["i3s-scale_y"];if(r&&n&&(1!==r||1!==n))for(let e=0;e<t.length;e+=3)t[e]*=r.value,t[e+1]*=n.value}(e.attributes.POSITION);const l=function(e,t,r,n,a){let o,s=[0,0,0,1];const i=[0,0],l=Bt([],r,n,a);l[2]=r[2];const u=t&&c(qt,t);return dt(e,(e=>(s[0]=e[0],s[1]=e[1],s[2]=e[2],u||(s=g(s,s,t)),r&&m(s,s,r),Bt(i,s,n,a),o=s[2],e[0]=i[0]-l[0],e[1]=i[1]-l[1],e[2]=o-l[2],e))),l}(e.attributes.POSITION,n,a,o,s);t.meshes[r]={primitives:[i],index:r},t.extensions.MAPTALKS_RTC={projCenter:l},t.extensions.CESIUM_RTC={rtcCoord:a};for(const r in e.attributes)ir(t.transferables,e.attributes[r].array.buffer);return e.indices&&ir(t.transferables,e.indices.array.buffer),i}function er(e,t,r,n,a,o){const s=n.map((e=>function(e,t,r,n,a){if("dds"===t){const t=_t(e),n=t.images.map((t=>new Uint8Array(e,t.offset,t.length))),a="dxt1"===t.format?33777:33779;return Promise.resolve({image:{mipmap:n,width:t.shape[0],height:t.shape[1],mimeType:r},sampler:Zt,format:a})}if("png"===t||"jpg"===t)return function(e,t){nr||(nr=new OffscreenCanvas(2,2),ar=nr.getContext("2d",{willReadFrequently:!0}));const r=new Blob([new Uint8Array(e)]);return createImageBitmap(r).then((e=>{let{width:r,height:n}=e;or(r)||(r=sr(r)),or(n)||(n=sr(n));const a=t;a&&(r=Math.min(a,r),n=Math.min(a,n)),nr.width=r,nr.height=n,ar.drawImage(e,0,0,r,n),e.close();const o=ar.getImageData(0,0,r,n);return{width:r,height:n,array:new Uint8Array(o.data)}})).catch((()=>({width:2,height:2,array:new Uint8Array(4)})))}(e,a).then((e=>{e.mimeType=r;return{image:e,sampler:Zt,format:6408}}));if("ktx2"===t)return Vt(e,n).then((e=>(e.mimeType=r,{image:e,sampler:Zt,format:e.format})));return null}(e.data,e.format,e.mimeType,a,o).then((e=>{if(e.image)if(e.image.array)ir(t.transferables,e.image.array.buffer);else if(e.image.mipmap)for(let r=0;r<e.image.mipmap.length;r++)ir(t.transferables,e.image.mipmap[r].buffer);return e}))));return Promise.all(s).then((n=>{tr(e,t,r,n)}))}function tr(e,t,r,n){const a=JSON.parse(JSON.stringify(r)),o=t.textures;n.ptr||(n.ptr=0);for(const e in r)r[e]&&r[e].url?(o.push(n[n.ptr++]),a[e]={index:o.length-1},void 0!==r[e].factor&&(a[e].scale=r[e].factor)):de(r[e])&&(a[e]=tr(-1,t,r[e],n));return e>=0&&(t.materials[e]=a),a}function rr(e,t){for(const r in e)e[r]&&e[r].url?t.push({url:e[r].url,mimeType:e[r].mimeType,format:e[r].format}):de(e[r])&&rr(e[r],t)}let nr,ar;function or(e){return!(e&e-1)&&0!==e}function sr(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}function ir(e,t){t&&(e.indexOf(t)>=0||e.push(t))}function cr(e){const t=new Uint8Array(e,0,5);return t[0]==="D".charCodeAt()&&t[1]==="R".charCodeAt()&&t[2]==="A".charCodeAt()&&t[3]==="C".charCodeAt()&&t[4]==="O".charCodeAt()}var lr="undefined"!=typeof Float32Array?Float32Array:Array;function ur(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}var fr=function(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e};!function(){var e=function(){var e=new lr(3);return lr!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}()}();const hr=[];const dr=[],mr=[],pr=[],br=[],gr=[],yr=[],_r=[];function Tr(e,t,r,n,a,o){ur(br,e[3*t],e[3*t+1],e[3*t+2]),ur(gr,e[3*r],e[3*r+1],e[3*r+2]),ur(yr,e[3*n],e[3*n+1],e[3*n+2]);const s=fr(dr,yr,gr),i=fr(mr,br,gr),c=function(e,t,r){var n=t[0],a=t[1],o=t[2],s=r[0],i=r[1],c=r[2];return e[0]=a*c-o*i,e[1]=o*s-n*c,e[2]=n*i-a*s,e}(pr,s,i);!function(e,t){var r=t[0],n=t[1],a=t[2],o=r*r+n*n+a*a;o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o)}(_r,c),a[3*t]=a[3*t]||0,a[3*r]=a[3*r]||0,a[3*n]=a[3*n]||0,a[3*t+1]=a[3*t+1]||0,a[3*r+1]=a[3*r+1]||0,a[3*n+1]=a[3*n+1]||0,a[3*t+2]=a[3*t+2]||0,a[3*r+2]=a[3*r+2]||0,a[3*n+2]=a[3*n+2]||0,a[3*t]+=_r[0],a[3*r]+=_r[0],a[3*n]+=_r[0],a[3*t+1]+=_r[1],a[3*r+1]+=_r[1],a[3*n+1]+=_r[1],a[3*t+2]+=_r[2],a[3*r+2]+=_r[2],a[3*n+2]+=_r[2],o[t]+=1,o[r]+=1,o[n]+=1}const{Ajax:vr,GLTFLoader:wr}=a(),Or=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Ar=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],Ir=2*Math.PI*6378137/360,Mr="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;let xr,Cr,Sr=!1;if("undefined"!=typeof OffscreenCanvas){try{Cr=new OffscreenCanvas(2,2).getContext("2d",{willReadFrequently:!0})}catch(e){}Cr&&"undefined"!=typeof createImageBitmap&&(Sr=!0)}const Nr=s([]),Lr=[0,0,0],Er=[],kr=[],Pr=[],Ur=[],Rr={"POSITION":1,"TEXCOORD_0":1,"TEXCOORD_1":1,"NORMAL":1,"TANGENT":1},Br={"TEXCOORD_0":1e-4,"TEXCOORD_1":1e-4};let Fr;class Dr{constructor(e,t,r,n){this.id=e,this.options=t,this._bindedRequestImage=(...e)=>this.requestImage.call(this,...e),this._uploader=r,this._requests={},n(null,{},[])}_createLoaders(e){this._b3dmLoader||(this._supportedFormats=e,this._pntsLoader=new We,this._b3dmLoader=new Ve(this._bindedRequestImage,wr,e),this._i3dmLoader=new Ke(this._bindedRequestImage,wr,e))}requestImage(e,t){Sr?fetch(e).then((e=>e.arrayBuffer())).then((e=>{const t=new self.Blob([new Uint8Array(e)]);return createImageBitmap(t)})).then((e=>{xr.width=e.width,xr.height=e.height,Cr.drawImage(e,0,0);const r=Cr.getImageData(0,0,xr.width,xr.height);e.close(),t(null,{width:e.width,height:e.height,data:new Uint8Array(r.data)})})):this._uploader("requestImage",{url:e},null,t)}loadTile(e,t){this._createLoaders(e.supportedFormats);const{service:r,url:n,arraybuffer:a}=e,o=r.fetchOptions||{};if(o.referrer=e.referrer,o.referrerPolicy=o.referrerPolicy||"origin",function(e){return e.indexOf("i3s:")>=0}(n)){const a=e.i3sInfo,s=r.maxTextureSize||0,i=Kt(a,e.supportedFormats,this.options.projection,e.projection,s,o);return i.then((e=>{if(delete this._requests[n],!e)return void t({status:404,url:n,i3sInfo:a});if(!Object.keys(e.gltf.meshes).length)return void t({status:404,url:n,i3sInfo:a});e.gltf.url=n;const{transferables:o}=e;e.magic="b3dm",r.createNormalIfMissed&&this._createGLTFMissedAttrs(e.gltf),Kr(r)&&this._compressAttrFloat32ToInt16(e.gltf),t(null,e,o)})),void(this._requests[n]=i.xhr)}if(a){delete this._requests[n];const r=xe(new DataView(a),0);if("{"===r[0]||" "===r[0]||"<"===r[0]){const r=function(e,t,r){if(Mr){const n=new Uint8Array(e,t,r);return Mr.decode(n)}return be(new Uint8Array(e,t,r))}(a,0,a.byteLength),o=JSON.parse(r);o.accessors?this._read3DTile(o,n,e,"gltf",t):this._checkAndConvert(e.rootIdx,o,a,n,t)}else this._read3DTile(a,n,e,r,t)}else{let a=r.urlParams;a&&(a=(n.indexOf("?")>0?"&":"?")+a);const s=n.replace(/\\+/g,"%2B");let i=vr.getArrayBuffer(s+(a||""),o);const c=i.xhr;i=i.then((r=>{delete this._requests[n],r&&r.status?t(r):(e.arraybuffer=r&&r.data,this.loadTile(e,t))})).catch((e=>{delete this._requests[n],t(e)})),this._requests[n]=c}}_read3DTile(e,t,r,n,a){n=n&&n.toLowerCase();const{service:o}=r;if("b3dm"===n){this._b3dmLoader.load(t,e,0,0,{maxTextureSize:o.maxTextureSize||0}).then((e=>{if(e.error)return void a(e);const{content:t,transferables:n}=this._processB3DM(e,r);o.createNormalIfMissed&&this._createGLTFMissedAttrs(t.gltf),Kr(o)&&this._compressAttrFloat32ToInt16(t.gltf),a(null,t,n)})).catch((e=>{a(e)}))}else if("pnts"===n){const n=r.transform||Nr;this._pntsLoader.load(t,e).then((e=>{const{content:t,transferables:o}=this._loadPNTS(e,n,r.rootIdx);this._compressPNTSFloat32ToInt16(t),a(null,t,o)}))}else if("i3dm"===n){const n=r.transform||Nr;this._i3dmLoader.load(t,e,0,0,{maxTextureSize:o.maxTextureSize||0}).then((e=>{const{content:t,transferables:s}=this._loadI3DM(e,n,r.rootIdx);o.createNormalIfMissed&&this._createGLTFMissedAttrs(t.gltf),Kr(o)&&this._compressAttrFloat32ToInt16(t.gltf),a(null,t,s)}))}else if("cmpt"===n){new nt(this._bindedRequestImage,wr,this._supportedFormats,o.maxTextureSize||0).load(t,e,0,0,{maxTextureSize:o.maxTextureSize||0}).then((e=>{const{content:t,transferables:n}=this._processCMPT(e,r);this._createCMPTMissedAttrs(t,o),Kr(o)&&this._compressCMPTContent(t),a(null,t,n)})).catch((e=>{a(e)}))}else if("gltf"===n){this._decoders||(this._decoders=ze());const n=t.substring(0,t.lastIndexOf("/")),s=e instanceof ArrayBuffer&&{buffer:e,byteOffset:0,byteLength:e.byteLength}||e;let i;try{i=new wr(n,s,{transferable:!0,requestImage:this._bindedRequestImage,decoders:this._decoders,supportedFormats:this._supportedFormats,maxTextureSize:o.maxTextureSize||0})}catch(e){a(e)}i.load({skipAttributeTransform:!1}).then((e=>{e.url=t,this._processGLTF(e,null,r),o.createNormalIfMissed&&this._createGLTFMissedAttrs(e),Kr(o)&&this._compressAttrFloat32ToInt16(e),a(null,{magic:"gltf",gltf:e},i.transferables)}))}else a(new Error("unsupported tile format: "+n))}_createCMPTMissedAttrs(e,t){e.content?e.content.forEach((e=>{this._createCMPTMissedAttrs(e,t)})):t.createNormalIfMissed&&this._createGLTFMissedAttrs(e.gltf)}_compressCMPTContent(e){e.content?e.content.forEach((e=>{this._compressCMPTContent(e)})):this._compressAttrFloat32ToInt16(e.gltf)}_createMissedAttrs(e,t){if(this._needCreateMissedAttrs(e,t)&&!e.attributes.NORMAL){const t=e.attributes.POSITION.array,r=t.length,n=this._is4326()?Fr.subarray(0,r):t,a=function(e,t,r){const n=r||[];n.setLength&&n.setLength(e.length);const a=hr;a.length<e.length/3&&(a.length=e.length/3),a.fill(0,0,e.length/3);const o=void 0===t.length?t:t.length;for(let r=0;r<o/3;r++)void 0===t.length?Tr(e,3*r,3*r+1,3*r+2,n,a):Tr(e,t[3*r],t[3*r+1],t[3*r+2],n,a);for(let e=0;e<n.length;e+=3){const t=a[e/3];0!==t?(n[e]/=t,n[e+1]/=t,n[e+2]/=t):(n[e]=0,n[e+1]=0,n[e+2]=0)}return n}(n,e.indices.array,new Float32Array(n.length));e.attributes.NORMAL={array:a,byteLength:a.byteLength,byteOffset:0,byteStride:0,componentType:5126,count:a.length/3,itemSize:3,name:"NORMAL",type:"VEC3"}}}_compressAttrFloat32ToInt16(e){if(!e||!e.meshes||e.extensionsUsed&&e.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(e.asset&&e.asset.sharePosition)return;const t=e.meshes;for(const e in t){t[e].primitives.forEach((e=>{e.compressed_int16_params={};const t=e.attributes;for(const r in t)if(Rr[r]&&t[r].array&&t[r].array instanceof Float32Array){let n=1;this._is4326()&&"POSITION"===r&&(n=Ir,e.compressed_int16_params.compressed_ratio=n);const a=Vr(t[r].array,n,t[r].min,t[r].max,r);if(!a)continue;const{array:o,range:s}=a;t[r].componentType=5124,t[r].array=o,e.compressed_int16_params[r]=s}}))}}_createGLTFMissedAttrs(e){if(!e||!e.meshes||e.extensionsUsed&&e.extensionsUsed.indexOf("KHR_techniques_webgl")>-1)return;if(e.asset&&e.asset.sharePosition)return;const t=e.meshes;for(const r in t){t[r].primitives.forEach((t=>{this._createMissedAttrs(t,e)}))}}_compressPNTSFloat32ToInt16(e){if(!e||!e.pnts)return;const t=e.pnts;e.compressed_int16_params={};for(const r in t)if(Rr[r]&&t[r].array&&t[r].array instanceof Float32Array){let n=1;this._is4326()&&"POSITION"===r&&(n=Ir,e.compressed_int16_params.compressed_ratio=n);const{array:a,range:o}=Vr(t[r].array,n,t[r].min,t[r].max,r);t[r].array=a,e.compressed_int16_params[r]=o}}_convertPageLoads(e){const t=[];for(let r=0;r<e.length;r++){const n=e[r];if(!n.childTile)continue;const a={boundingVolume:{sphere:[n.boundingSphere.center.x,n.boundingSphere.center.y,n.boundingSphere.center.z,n.boundingSphere.radius]},content:{uri:n.childTile},geometricError:n.boundingSphere.radius/n.rangeList*16,refine:"REPLACE"};t.push(a)}return t}_checkAndConvert(e,t,r,n,a){return t.capabilities,void a(null,t)}_processCMPT(e,t){const{tiles:r}=e,n={magic:"cmpt",content:[]},a=[];for(let e=0;e<r.length;e++){const{magic:o}=r[e];if("b3dm"===o){const{content:o,transferables:s}=this._processB3DM(r[e],t);qr(a,s),n.content.push(o)}else if("i3dm"===o){const{transform:o,rootIdx:s}=t,{content:i,transferables:c}=this._loadI3DM(r[e],o,s);qr(a,c),n.content.push(i)}else if("pnts"===o){const{transform:o,rootIdx:s}=t,{content:i,transferables:c}=this._loadPNTS(r[e],o,s);qr(a,c),n.content.push(i)}else if("cmpt"===o){const{content:o,transferables:s}=this._processCMPT(r[e],t);qr(a,s),n.content.push(o)}}return{content:n,transferables:a}}_processB3DM(e,t){const{gltf:r,transferables:n,featureTable:a}=e;return this._processGLTF(r,a,t),delete e.transferables,{content:e,transferables:n}}_processGLTF(e,t,r){const n=function(e){if(!e||!e.meshes)return!1;if(e.extensions&&e.extensions.KHR_techniques_webgl)return!0;const t="visited";let r=1;const n=[];for(const a in e.meshes){const o=e.meshes[a],{primitives:s}=o;if(s)for(let e=0;e<s.length;e++){const a=s[e].attributes&&s[e].attributes.POSITION;if(!a||!a.array)continue;a.array.buffer[t]||(a.array.buffer[t]=r++);const o=r-1+"-"+(a.byteOffset||0);if(n.indexOf(o)>=0)return!0;n.push(o)}}return!1}(e);this._markTextures(e);r.service.createNormalIfMissed||this._markUnlit(e),e.asset||(e.asset={}),n?(e.asset.sharePosition=!0,this._convertCoordinates(e,t,r.upAxis,r.transform)):this._projectCoordinates(e,t,r.upAxis,r.transform)}_loadI3DM(e,t,r){const{featureTable:n}=e,a=e.i3dm,o=n&&n.RTC_CENTER||[0,0,0],s=this.options.projection,i=t&&c(Nr,t),l={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Gr(a.POSITION.array,3,o,Nr,l);const u=zr(l);t&&!i&&g(u,u,t);const f=this._getCoordiate(u),m=[];Bt(m,f,s),m[2]=f[2];const p=h([],u),b=[0,0,0],y=[0,0,0],_=[0,0],v=[1/0,1/0,1/0],w=[-1/0,-1/0,-1/0];dt(a.POSITION,(e=>{b[0]=e[0]+o[0],b[1]=e[1]+o[1],b[2]=e[2]+o[2],t&&!i&&g(b,b,t),0===T(b)?d(y,0,0,-6378137):we(y,b),Bt(_,y,s),e[0]=_[0]-m[0],e[1]=_[1]-m[1],e[2]=y[2]-m[2],e[0]<v[0]&&(v[0]=e[0]),e[1]<v[1]&&(v[1]=e[1]),e[2]<v[2]&&(v[2]=e[2]),e[0]>w[0]&&(w[0]=e[0]),e[1]>w[1]&&(w[1]=e[1]),e[2]>w[2]&&(w[2]=e[2])})),a.POSITION.min=v,a.POSITION.max=w,t&&g(u,u,t),e.rtcCenter=p,e.rtcCoord=f,e.projCenter=m,e.rootIdx=r;const O=e.transferables;return delete e.transferables,{content:e,transferables:O}}_loadPNTS(e,t,r){const{featureTable:n}=e,a=e.pnts,o=n&&n.RTC_CENTER||[0,0,0],s=this.options.projection,i=t&&c(Nr,t),l={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};Gr(a.POSITION.array,3,o,t,l);const u=zr(l),f=this._getProjCenter(u),m=h([],u),p=[1/0,1/0,1/0],b=[-1/0,-1/0,-1/0];let y=[0,0,0,1];const _=[0,0,0],v=[0,0];dt(a.POSITION,(e=>(y[0]=e[0]+o[0],y[1]=e[1]+o[1],y[2]=e[2]+o[2],t&&!i&&(y=g(y,y,t)),0===T(y)?d(_,0,0,-6378137):we(_,y),Bt(v,_,s),e[0]=v[0]-f[0],e[1]=v[1]-f[1],e[2]=_[2]-f[2],e[0]<p[0]&&(p[0]=e[0]),e[1]<p[1]&&(p[1]=e[1]),e[2]<p[2]&&(p[2]=e[2]),e[0]>b[0]&&(b[0]=e[0]),e[1]>b[1]&&(b[1]=e[1]),e[2]>b[2]&&(b[2]=e[2]),e))),a.POSITION.min=p,a.POSITION.max=b,t&&g(u,u,t);const w=this._getCoordiate(u);e.rtcCenter=m,e.projCenter=f,e.rtcCoord=w,e.rootIdx=r;const O=e.transferables;return delete e.transferables,{content:e,transferables:O}}_markTextures(e){if(!Array.isArray(e.textures))return;const t=e.textures;for(let e=0;e<t.length;e++){const r=t[e]&&t[e].image&&t[e].image.array;if(r&&r.length){const n=r[0],a=r[1],o=r[2],s=r[3];let i=!0;for(let e=4;e<r.length;e+=4)if(r[e]!==n||r[e+1]!==a||r[e+2]!==o||r[e+3]!==s){i=!1;break}i&&(t[e].image.color=[n/255,a/255,o/255,s/255],delete t[e].image.array)}}}_markUnlit(e){const t=e.meshes;for(const r in t){const n=t[r];if(!n)continue;const a=n.primitives;if(a)for(let t=0;t<a.length;t++){if(!a[t])continue;if(!a[t].attributes||a[t].attributes.NORMAL)continue;const r=a[t].material;if(!he(r)){const t=e.materials[r];if(!t)continue;t.extensions||(t.extensions={}),t.extensions.KHR_materials_unlit={}}}}}abortTileLoading(e,t){const r=this._requests[e.url];if(Array.isArray(r))for(let e=0;e<r.length;e++)r[e].abort();else r&&r.abort&&r.abort();delete this._requests[e.url],t(null)}_getModelCenter(e,t,r,n){const a=t&&t.RTC_CENTER||e.extensions&&e.extensions.CESIUM_RTC&&e.extensions.CESIUM_RTC.center;let o=Or;"X"===(r=r&&r.toUpperCase())?o=Ar:"Z"===r&&(o=Nr),e.extensions=e.extensions||{},e.extensions.CESIUM_RTC||(e.extensions.CESIUM_RTC={}),a&&(e.extensions.CESIUM_RTC.center=a),e.extensions.MAPTALKS_RTC={};const c={xmin:1/0,xmax:-1/0,ymin:1/0,ymax:-1/0,hmin:1/0,hmax:-1/0};ot(e,(e=>{if(!(e.attributes&&e.attributes.POSITION))return;const t=s(Er);e.matrices&&Hr(t,e.matrices);const r=e.attributes.POSITION.array,l=e.attributes.POSITION.itemSize;i(t,o,t),n&&i(t,n,t),Gr(r,l,a||Lr,t,c,e.compressUniforms)}));const l=zr(c);return{rtcCenter:a,modelCenter:l,upAxisTransform:o}}_convertCoordinates(e,t,r,n){const{modelCenter:a,upAxisTransform:o,rtcCenter:c}=this._getModelCenter(e,t,r),l=this._getProjCenter(a);e.extensions.MAPTALKS_RTC.projCenter=l,e.extensions.MAPTALKS_RTC.rtcCoord=e.extensions.CESIUM_RTC.rtcCoord=this._getCoordiate(a);const u=h([],a);n&&g(a,a,n),e.extensions.CESIUM_RTC.rtcCoord=this._getCoordiate(a),c||(ot(e,(e=>{if(e.attributes&&e.attributes.POSITION){const t=e.attributes.POSITION;if(t.array.buffer.projected&&t.array.buffer.projected[t.byteOffset])return;const r=s(Er);e.matrices&&Hr(r,e.matrices),i(r,o,r);const n=function(e,t){var r=t[0],n=t[1],a=t[2],o=t[3],s=t[4],i=t[5],c=t[6],l=t[7],u=t[8],f=t[9],h=t[10],d=t[11],m=t[12],p=t[13],b=t[14],g=t[15],y=r*i-n*s,_=r*c-a*s,T=r*l-o*s,v=n*c-a*i,w=n*l-o*i,O=a*l-o*c,A=u*p-f*m,I=u*b-h*m,M=u*g-d*m,x=f*b-h*p,C=f*g-d*p,S=h*g-d*b,N=y*S-_*C+T*x+v*M-w*I+O*A;return N?(N=1/N,e[0]=(i*S-c*C+l*x)*N,e[1]=(a*C-n*S-o*x)*N,e[2]=(p*O-b*w+g*v)*N,e[3]=(h*w-f*O-d*v)*N,e[4]=(c*M-s*S-l*I)*N,e[5]=(r*S-a*M+o*I)*N,e[6]=(b*T-m*O-g*_)*N,e[7]=(u*O-h*T+d*_)*N,e[8]=(s*C-i*M+l*A)*N,e[9]=(n*M-r*C-o*A)*N,e[10]=(m*w-p*T+g*y)*N,e[11]=(f*T-u*w-d*y)*N,e[12]=(i*I-s*x-c*A)*N,e[13]=(r*x-n*I+a*A)*N,e[14]=(p*_-m*v-b*y)*N,e[15]=(u*v-f*_+h*y)*N,e):null}(kr,r),a=[1/0,1/0,1/0],c=[-1/0,-1/0,-1/0];dt(t,(e=>{g(e,e,r),e[0]=e[0]-u[0],e[1]=e[1]-u[1],e[2]=e[2]-u[2],g(e,e,n),e[0]<a[0]&&(a[0]=e[0]),e[1]<a[1]&&(a[1]=e[1]),e[2]<a[2]&&(a[2]=e[2]),e[0]>c[0]&&(c[0]=e[0]),e[1]>c[1]&&(c[1]=e[1]),e[2]>c[2]&&(c[2]=e[2])})),t.min=a,t.max=c,t.array.buffer.projected||(t.array.buffer.projected={}),t.array.buffer.projected[t.byteOffset]=1}})),e.extensions.CESIUM_RTC.center=u)}_projectCoordinates(e,t,r,n){const{modelCenter:a,rtcCenter:o}=this._getModelCenter(e,t,r,n),s=this._getProjCenter(a);e.extensions.MAPTALKS_RTC.projCenter=s,e.extensions.MAPTALKS_RTC.rtcCoord=e.extensions.CESIUM_RTC.rtcCoord=this._getCoordiate(a),ot(e,(t=>{if(t.attributes&&t.attributes.POSITION){const a=this._needCreateMissedAttrs(t,e);if(a){const e=t.attributes.POSITION.array.length;(!Fr||Fr.length<e)&&(Fr=new Float32Array(e))}t.attributes.NORMAL&&this._transformNormalOrTangent(t.attributes.NORMAL,t.matrices,r),t.attributes.TANGENT&&this._transformNormalOrTangent(t.attributes.TANGENT,t.matrices,r);const{newPositions:s}=this._projVertices(t.attributes.POSITION,t.matrices,o,e.extensions.MAPTALKS_RTC,r,n,t.compressUniforms,a),{componentType:i}=t.attributes.POSITION;5126!==i&&(t.attributes.POSITION.array=new Float32Array(s))}}));for(const t in e.nodes){e.nodes[t].matrix=Nr}}_getProjCenter(e){const t=this.options.projection;"identity"===t?h(Pr,e):0===T(e)?d(Pr,0,0,-6378137):we(Pr,e),Bt(Ur,Pr,t);const r=Pr[2],n=[];return n[0]=Ur[0],n[1]=Ur[1],n[2]=r,n}_transformNormalOrTangent(e,t,r){let n;n="Y"===r?Or:"X"===r?Ar:Nr;const a=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e}([],n);if(Hr(a,t),c(a,Nr))return;const o=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}([],a),s=[];dt(e,(e=>(function(e,t,r){var n=t[0],a=t[1],o=t[2];e[0]=n*r[0]+a*r[3]+o*r[6],e[1]=n*r[1]+a*r[4]+o*r[7],e[2]=n*r[2]+a*r[5]+o*r[8]}(s,e,o),p(s,s),h(e,s),s)))}_projVertices(e,t,r,n,a,o,i,l){if(e.array.buffer.projected&&e.array.buffer.projected[e.byteOffset])return null;const u=s([]);Hr(u,t);const f=this.options.projection;a=a&&a.toUpperCase();const h=r;let p=null;"Y"===a?p=Or:"X"===a&&(p=Ar);let b=[0,0,0,1];const y=[0,0,0],_=[0,0],v=n.projCenter,w=Bt([],n.rtcCoord,"EPSG:3857"),O=o&&c(Nr,o),A=e.min=e.min||[],I=e.max=e.max||[];d(A,1/0,1/0,1/0),d(I,-1/0,-1/0,-1/0);const M=i||{},{decode_position_min:x,decode_position_normConstant:C}=M;let S=[0,0,0,0],N=1;x&&(S=x),C&&(N=C);const L=[];return dt(e,((t,r)=>{if(b[0]=t[0]*N+S[0],b[1]=t[1]*N+S[1],b[2]=t[2]*N+S[2],b=g(b,b,u),p&&(b=g(b,b,p)),h&&m(b,b,h),o&&!O&&(b=g(b,b,o)),0===T(b)?d(y,0,0,-6378137):we(y,b),l){const e=Fr;Bt(_,y,f),e[3*r]=_[0]-w[0],e[3*r+1]=_[0]-w[1],e[3*r+2]=_[0]-w[2]}if(Bt(_,y,f),t instanceof Float32Array)t[0]=_[0]-v[0],t[1]=_[1]-v[1],t[2]=y[2]-v[2];else{const r=_[0]-v[0],n=_[1]-v[1],a=y[2]-v[2];5126!==e.componentType&&(L.push(r),L.push(n),L.push(a),L.push(t[3]))}return t[0]<A[0]&&(A[0]=t[0]),t[1]<A[1]&&(A[1]=t[1]),t[2]<A[2]&&(A[2]=t[2]),t[0]>I[0]&&(I[0]=t[0]),t[1]>I[1]&&(I[1]=t[1]),t[2]>I[2]&&(I[2]=t[2]),t})),e.array.buffer.projected||(e.array.buffer.projected={}),e.array.buffer.projected[e.byteOffset]=1,{projCenter:v,newPositions:L}}_getCoordiate(e){return 0===T(e)?d([],0,0,-6378137):we([],e)}onRemove(){}_is4326(){return"EPSG:4326"===this.options.projection||"EPSG:4490"===this.options.projection}_needCreateMissedAttrs(e,t){if(!e.attributes.POSITION||function(e,t){const r=t.materials[e.material],n=r&&r.extensions&&r.extensions.KHR_materials_unlit;return n}(e,t))return!1;return!e.attributes.TANGENT}}const jr=[];function Gr(e,t,r,n,a,o){const s=o||{},{decode_position_min:i,decode_position_normConstant:c}=s;let l=[0,0,0,0],u=1;i&&(l=i),c&&(u=c);for(let o=0,s=e.length;o<s;o+=t){const{xmin:s,ymin:i,xmax:c,ymax:f,hmin:h,hmax:p}=a;d(jr,e[o]*u+l[0],e[o+1]*u+l[1],e[o+2]*u+l[2]),g(jr,jr,n);const b=m(jr,r,jr);b[0]<s&&(a.xmin=b[0]),b[0]>c&&(a.xmax=b[0]),b[1]<i&&(a.ymin=b[1]),b[1]>f&&(a.ymax=b[1]),t>2&&(b[2]<h&&(a.hmin=b[2]),b[2]>p&&(a.hmax=b[2]))}}function zr(e){const{xmax:t,ymax:r,xmin:n,ymin:a,hmin:o,hmax:s}=e,i=[(n+t)/2,(a+r)/2,(o+s)/2];return t===-1/0&&(i[0]=0),r===-1/0&&(i[1]=0),s===-1/0&&(i[2]=0),isNaN(i[2])&&(i[2]=0),i}function qr(e,t){for(let r=0;r<t.length;r++)e.indexOf(t[r])<0&&e.push(t[r])}function Hr(e,t){const r=e;for(let e=t.length-1;e>=0;e--)i(r,t[e],r);return r}function Vr(e,t,r,n,a){if(t&&t>1)for(let r=0;r<e.length;r++)(r+1)%3!=0&&(e[r]*=t);let o,s;if(r&&n&&1===t)o=Math.min(...r),s=Math.max(...n);else{const{min:t,max:r}=function(e){let t=1/0,r=-1/0;for(let n=0;n<e.length;n++)e[n]>r&&(r=e[n]),e[n]<t&&(t=e[n]);return{min:t,max:r}}(e);o=t,s=r}return!function(e,t,r,n){for(let a=0;a<e.length;a++){const o=$r(Qr(e[a],t,r),t,r);if(Math.abs(o-e[a])>Br[n])return!1}return!0}(e,o,s,a)&&Br[a]?null:function(e,t,r){const n=new Int16Array(e.length);for(let a=0;a<e.length;a++)n[a]=Qr(e[a],t,r);return{array:n,range:[t,r]}}(e,o,s)}function $r(e,t,r){return((e>=32768?-(65536-e)/32768:e/32767)+1)*(r-t)/2+t}function Qr(e,t,r){const n=2*(e-t)/(r-t)-1,a=Math.max(-1,Math.min(1,n));return a<0?32768*a:32767*a}function Kr(e){return void 0===e.compressGeometry||e.compressGeometry}let Zr=0;class Xr{constructor(e){this.workerId=e,this.workers={},this._callbacks={}}addLayer({actorId:e,mapId:t,layerId:r,params:n},a){if(this._getLayerById(t,r))return;const o=this._genKey(t,r),s=n.options;this.workers[o]=new Dr(r,s,((...t)=>this.send.call(this,e,...t)),a)}removeLayer({mapId:e,layerId:t},r){const n=this._getLayerById(e,t),a=this._genKey(e,t);delete this.workers[a],n&&n.onRemove(r)}loadTile({mapId:e,layerId:t,params:r},n){const a=this._getLayerById(e,t);a&&a.loadTile(r,n)}abortTileLoading({mapId:e,layerId:t,params:r},n){const a=this._getLayerById(e,t);a&&a.abortTileLoading(r,n)}receive(e){const t=e.callback,r=this._callbacks[t];delete this._callbacks[t],r&&e.error?r(new Error(e.error)):r&&r(null,e.data)}send(e,t,r,n,a){const o=a?\`${a}e}-${a}Zr++}\`:null;a&&(this._callbacks[o]=a),postMessage({type:"<request>",workerId:this.workerId,actorId:e,command:t,params:r,callback:String(o)},n||[])}_genKey(e,t){return\`${a}e}-${a}t}\`}_getLayerById(e,t){const r=this._genKey(e,t);return this.workers[r]}}e.initialize=function(){},e.onmessage=function(e,t){const r=e.data;this.dispatcher||(this.dispatcher=new Xr(e.workerId)),"<response>"===e.type?this.dispatcher.workerId===e.workerId&&this.dispatcher.receive(e):this.dispatcher[r.command]({actorId:r.actorId,mapId:r.mapId,layerId:r.layerId,params:r.params},((e,r,n)=>{e&&404!==e.status&&204!==e.status&&console.error(e),e instanceof Error&&(e={message:e.message}),t(e,r,n)}))}}`
7
7
  /*!
8
8
  * Contains code from THREE.js
9
9
  * MIT License
10
10
  * https://github.com/mrdoob/three.js
11
- */;for(var c=[],l=0;l<6;l++)c[l]=[];var u=[];function h(t,e,n){M(t);for(var r=0;r<6;r++){var i=c[r];if(u[0]=i[0]>0?e[1][0]:e[0][0],u[1]=i[1]>0?e[1][1]:e[0][1],u[2]=i[2]>0?e[1][2]:e[0][2],O(i,u)<0)return!1}return!0}var f=3,d=4,m=5,p=6,y=7,b=8,g=9,v=10,w=11;function T(t,e){var n=e,r=t,i=e,s=r[0],o=r[1],a=r[2],c=Math.abs(s*i[f]+o*i[d]+a*i[m])+Math.abs(s*i[p]+o*i[y]+a*i[b])+Math.abs(s*i[g]+o*i[v]+a*i[w]),l=O(t,n);return!(l<=-c)}function M(t){var e=t,n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],l=e[6],u=e[7],h=e[8],f=e[9],d=e[10],m=e[11],p=e[12],y=e[13],b=e[14],g=e[15];_(c[0],s-n,u-o,m-h,g-p),_(c[1],s+n,u+o,m+h,g+p),_(c[2],s+r,u+a,m+f,g+y),_(c[3],s-r,u-a,m-f,g-y),_(c[4],s-i,u-l,m-d,g-b),_(c[5],s+i,u+l,m+d,g+b)}function _(t,e,n,r,i){var s=1/Math.sqrt(e*e+n*n+r*r);return t[0]=e*s,t[1]=n*s,t[2]=r*s,t[3]=i*s,t}function O(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]}function A(t){return t&&t.t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var x={exports:{}},I={exports:{}},S=function(t){return!(!t||"string"==typeof t)&&(t instanceof Array||Array.isArray(t)||t.length>=0&&(t.splice instanceof Function||Object.getOwnPropertyDescriptor(t,t.length-1)&&"String"!==t.constructor.name))},C=Array.prototype.concat,k=Array.prototype.slice,N=I.exports=function(t){for(var e=[],n=0,r=t.length;n<r;n++){var i=t[n];S(i)?e=C.call(e,k.call(i)):e.push(i)}return e};N.wrap=function(t){return function(){return t(N(arguments))}};var L=I.exports,E={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},R=L,P=Object.hasOwnProperty,U=Object.create(null);for(var B in E)P.call(E,B)&&(U[E[B]]=B);var F=x.exports={to:{},get:{}};function G(t,e,n){return Math.min(Math.max(e,t),n)}function D(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}F.get=function(t){var e,n;switch(t.substring(0,3).toLowerCase()){case"hsl":e=F.get.hsl(t),n="hsl";break;case"hwb":e=F.get.hwb(t),n="hwb";break;default:e=F.get.rgb(t),n="rgb"}return e?{model:n,value:e}:null},F.get.rgb=function(t){if(!t)return null;var e,n,r,i=[0,0,0,1];if(e=t.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(r=e[2],e=e[1],n=0;n<3;n++){var s=2*n;i[n]=parseInt(e.slice(s,s+2),16)}r&&(i[3]=parseInt(r,16)/255)}else if(e=t.match(/^#([a-f0-9]{3,4})$/i)){for(r=(e=e[1])[3],n=0;n<3;n++)i[n]=parseInt(e[n]+e[n],16);r&&(i[3]=parseInt(r+r,16)/255)}else if(e=t.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(n=0;n<3;n++)i[n]=parseInt(e[n+1],0);e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}else{if(!(e=t.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(e=t.match(/^(\w+)$/))?"transparent"===e[1]?[0,0,0,0]:P.call(E,e[1])?((i=E[e[1]])[3]=1,i):null:null;for(n=0;n<3;n++)i[n]=Math.round(2.55*parseFloat(e[n+1]));e[4]&&(e[5]?i[3]=.01*parseFloat(e[4]):i[3]=parseFloat(e[4]))}for(n=0;n<3;n++)i[n]=G(i[n],0,255);return i[3]=G(i[3],0,1),i},F.get.hsl=function(t){if(!t)return null;var e=t.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,G(parseFloat(e[2]),0,100),G(parseFloat(e[3]),0,100),G(isNaN(n)?1:n,0,1)]}return null},F.get.hwb=function(t){if(!t)return null;var e=t.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(e){var n=parseFloat(e[4]);return[(parseFloat(e[1])%360+360)%360,G(parseFloat(e[2]),0,100),G(parseFloat(e[3]),0,100),G(isNaN(n)?1:n,0,1)]}return null},F.to.hex=function(){var t=R(arguments);return"#"+D(t[0])+D(t[1])+D(t[2])+(t[3]<1?D(Math.round(255*t[3])):"")},F.to.rgb=function(){var t=R(arguments);return t.length<4||1===t[3]?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"},F.to.rgb.percent=function(){var t=R(arguments),e=Math.round(t[0]/255*100),n=Math.round(t[1]/255*100),r=Math.round(t[2]/255*100);return t.length<4||1===t[3]?"rgb("+e+"%, "+n+"%, "+r+"%)":"rgba("+e+"%, "+n+"%, "+r+"%, "+t[3]+")"},F.to.hsl=function(){var t=R(arguments);return t.length<4||1===t[3]?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"},F.to.hwb=function(){var t=R(arguments),e="";return t.length>=4&&1!==t[3]&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"},F.to.keyword=function(t){return U[t.slice(0,3)]};var j=x.exports,z={exports:{}},H={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},q={};for(var $ in H)H.hasOwnProperty($)&&(q[H[$]]=$);var V=z.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var J in V)if(V.hasOwnProperty(J)){if(!("channels"in V[J]))throw new Error("missing channels property: "+J);if(!("labels"in V[J]))throw new Error("missing channel labels property: "+J);if(V[J].labels.length!==V[J].channels)throw new Error("channel and label counts mismatch: "+J);var Y=V[J].channels,Z=V[J].labels;delete V[J].channels,delete V[J].labels,Object.defineProperty(V[J],"channels",{value:Y}),Object.defineProperty(V[J],"labels",{value:Z})}V.rgb.hsl=function(t){var e,n,r=t[0]/255,i=t[1]/255,s=t[2]/255,o=Math.min(r,i,s),a=Math.max(r,i,s),c=a-o;return a===o?e=0:r===a?e=(i-s)/c:i===a?e=2+(s-r)/c:s===a&&(e=4+(r-i)/c),(e=Math.min(60*e,360))<0&&(e+=360),n=(o+a)/2,[e,100*(a===o?0:n<=.5?c/(a+o):c/(2-a-o)),100*n]},V.rgb.hsv=function(t){var e,n,r,i,s,o=t[0]/255,a=t[1]/255,c=t[2]/255,l=Math.max(o,a,c),u=l-Math.min(o,a,c),h=function(t){return(l-t)/6/u+.5};return 0===u?i=s=0:(s=u/l,e=h(o),n=h(a),r=h(c),o===l?i=r-n:a===l?i=1/3+e-r:c===l&&(i=2/3+n-e),i<0?i+=1:i>1&&(i-=1)),[360*i,100*s,100*l]},V.rgb.hwb=function(t){var e=t[0],n=t[1],r=t[2];return[V.rgb.hsl(t)[0],100*(1/255*Math.min(e,Math.min(n,r))),100*(r=1-1/255*Math.max(e,Math.max(n,r)))]},V.rgb.cmyk=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255;return[100*((1-n-(e=Math.min(1-n,1-r,1-i)))/(1-e)||0),100*((1-r-e)/(1-e)||0),100*((1-i-e)/(1-e)||0),100*e]},V.rgb.keyword=function(t){var e=q[t];if(e)return e;var n,r,i,s=1/0;for(var o in H)if(H.hasOwnProperty(o)){var a=H[o],c=(r=t,i=a,Math.pow(r[0]-i[0],2)+Math.pow(r[1]-i[1],2)+Math.pow(r[2]-i[2],2));c<s&&(s=c,n=o)}return n},V.keyword.rgb=function(t){return H[t]},V.rgb.xyz=function(t){var e=t[0]/255,n=t[1]/255,r=t[2]/255;return[100*(.4124*(e=e>.04045?Math.pow((e+.055)/1.055,2.4):e/12.92)+.3576*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)+.1805*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)),100*(.2126*e+.7152*n+.0722*r),100*(.0193*e+.1192*n+.9505*r)]},V.rgb.lab=function(t){var e=V.rgb.xyz(t),n=e[0],r=e[1],i=e[2];return r/=100,i/=108.883,n=(n/=95.047)>.008856?Math.pow(n,1/3):7.787*n+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(n-r),200*(r-(i=i>.008856?Math.pow(i,1/3):7.787*i+16/116))]},V.hsl.rgb=function(t){var e,n,r,i,s,o=t[0]/360,a=t[1]/100,c=t[2]/100;if(0===a)return[s=255*c,s,s];e=2*c-(n=c<.5?c*(1+a):c+a-c*a),i=[0,0,0];for(var l=0;l<3;l++)(r=o+1/3*-(l-1))<0&&r++,r>1&&r--,s=6*r<1?e+6*(n-e)*r:2*r<1?n:3*r<2?e+(n-e)*(2/3-r)*6:e,i[l]=255*s;return i},V.hsl.hsv=function(t){var e=t[0],n=t[1]/100,r=t[2]/100,i=n,s=Math.max(r,.01);return n*=(r*=2)<=1?r:2-r,i*=s<=1?s:2-s,[e,100*(0===r?2*i/(s+i):2*n/(r+n)),100*((r+n)/2)]},V.hsv.rgb=function(t){var e=t[0]/60,n=t[1]/100,r=t[2]/100,i=Math.floor(e)%6,s=e-Math.floor(e),o=255*r*(1-n),a=255*r*(1-n*s),c=255*r*(1-n*(1-s));switch(r*=255,i){case 0:return[r,c,o];case 1:return[a,r,o];case 2:return[o,r,c];case 3:return[o,a,r];case 4:return[c,o,r];case 5:return[r,o,a]}},V.hsv.hsl=function(t){var e,n,r,i=t[0],s=t[1]/100,o=t[2]/100,a=Math.max(o,.01);return r=(2-s)*o,n=s*a,[i,100*(n=(n/=(e=(2-s)*a)<=1?e:2-e)||0),100*(r/=2)]},V.hwb.rgb=function(t){var e,n,r,i,s,o,a,c=t[0]/360,l=t[1]/100,u=t[2]/100,h=l+u;switch(h>1&&(l/=h,u/=h),r=6*c-(e=Math.floor(6*c)),1&e&&(r=1-r),i=l+r*((n=1-u)-l),e){default:case 6:case 0:s=n,o=i,a=l;break;case 1:s=i,o=n,a=l;break;case 2:s=l,o=n,a=i;break;case 3:s=l,o=i,a=n;break;case 4:s=i,o=l,a=n;break;case 5:s=n,o=l,a=i}return[255*s,255*o,255*a]},V.cmyk.rgb=function(t){var e=t[0]/100,n=t[1]/100,r=t[2]/100,i=t[3]/100;return[255*(1-Math.min(1,e*(1-i)+i)),255*(1-Math.min(1,n*(1-i)+i)),255*(1-Math.min(1,r*(1-i)+i))]},V.xyz.rgb=function(t){var e,n,r,i=t[0]/100,s=t[1]/100,o=t[2]/100;return n=-.9689*i+1.8758*s+.0415*o,r=.0557*i+-.204*s+1.057*o,e=(e=3.2406*i+-1.5372*s+-.4986*o)>.0031308?1.055*Math.pow(e,1/2.4)-.055:12.92*e,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,[255*(e=Math.min(Math.max(0,e),1)),255*(n=Math.min(Math.max(0,n),1)),255*(r=Math.min(Math.max(0,r),1))]},V.xyz.lab=function(t){var e=t[0],n=t[1],r=t[2];return n/=100,r/=108.883,e=(e/=95.047)>.008856?Math.pow(e,1/3):7.787*e+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(e-n),200*(n-(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116))]},V.lab.xyz=function(t){var e,n,r,i=t[0];e=t[1]/500+(n=(i+16)/116),r=n-t[2]/200;var s=Math.pow(n,3),o=Math.pow(e,3),a=Math.pow(r,3);return n=s>.008856?s:(n-16/116)/7.787,e=o>.008856?o:(e-16/116)/7.787,r=a>.008856?a:(r-16/116)/7.787,[e*=95.047,n*=100,r*=108.883]},V.lab.lch=function(t){var e,n=t[0],r=t[1],i=t[2];return(e=360*Math.atan2(i,r)/2/Math.PI)<0&&(e+=360),[n,Math.sqrt(r*r+i*i),e]},V.lch.lab=function(t){var e,n=t[0],r=t[1];return e=t[2]/360*2*Math.PI,[n,r*Math.cos(e),r*Math.sin(e)]},V.rgb.ansi16=function(t){var e=t[0],n=t[1],r=t[2],i=1 in arguments?arguments[1]:V.rgb.hsv(t)[2];if(0===(i=Math.round(i/50)))return 30;var s=30+(Math.round(r/255)<<2|Math.round(n/255)<<1|Math.round(e/255));return 2===i&&(s+=60),s},V.hsv.ansi16=function(t){return V.rgb.ansi16(V.hsv.rgb(t),t[2])},V.rgb.ansi256=function(t){var e=t[0],n=t[1],r=t[2];return e===n&&n===r?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},V.ansi16.rgb=function(t){var e=t%10;if(0===e||7===e)return t>50&&(e+=3.5),[e=e/10.5*255,e,e];var n=.5*(1+~~(t>50));return[(1&e)*n*255,(e>>1&1)*n*255,(e>>2&1)*n*255]},V.ansi256.rgb=function(t){if(t>=232){var e=10*(t-232)+8;return[e,e,e]}var n;return t-=16,[Math.floor(t/36)/5*255,Math.floor((n=t%36)/6)/5*255,n%6/5*255]},V.rgb.hex=function(t){var e=(((255&Math.round(t[0]))<<16)+((255&Math.round(t[1]))<<8)+(255&Math.round(t[2]))).toString(16).toUpperCase();return"000000".substring(e.length)+e},V.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var n=e[0];3===e[0].length&&(n=n.split("").map((function(t){return t+t})).join(""));var r=parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},V.rgb.hcg=function(t){var e,n=t[0]/255,r=t[1]/255,i=t[2]/255,s=Math.max(Math.max(n,r),i),o=Math.min(Math.min(n,r),i),a=s-o;return e=a<=0?0:s===n?(r-i)/a%6:s===r?2+(i-n)/a:4+(n-r)/a+4,e/=6,[360*(e%=1),100*a,100*(a<1?o/(1-a):0)]},V.hsl.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=1,i=0;return(r=n<.5?2*e*n:2*e*(1-n))<1&&(i=(n-.5*r)/(1-r)),[t[0],100*r,100*i]},V.hsv.hcg=function(t){var e=t[1]/100,n=t[2]/100,r=e*n,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},V.hcg.rgb=function(t){var e=t[0]/360,n=t[1]/100,r=t[2]/100;if(0===n)return[255*r,255*r,255*r];var i,s=[0,0,0],o=e%1*6,a=o%1,c=1-a;switch(Math.floor(o)){case 0:s[0]=1,s[1]=a,s[2]=0;break;case 1:s[0]=c,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=a;break;case 3:s[0]=0,s[1]=c,s[2]=1;break;case 4:s[0]=a,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=c}return i=(1-n)*r,[255*(n*s[0]+i),255*(n*s[1]+i),255*(n*s[2]+i)]},V.hcg.hsv=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e),r=0;return n>0&&(r=e/n),[t[0],100*r,100*n]},V.hcg.hsl=function(t){var e=t[1]/100,n=t[2]/100*(1-e)+.5*e,r=0;return n>0&&n<.5?r=e/(2*n):n>=.5&&n<1&&(r=e/(2*(1-n))),[t[0],100*r,100*n]},V.hcg.hwb=function(t){var e=t[1]/100,n=e+t[2]/100*(1-e);return[t[0],100*(n-e),100*(1-n)]},V.hwb.hcg=function(t){var e=t[1]/100,n=1-t[2]/100,r=n-e,i=0;return r<1&&(i=(n-r)/(1-r)),[t[0],100*r,100*i]},V.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]},V.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]},V.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]},V.gray.hsl=V.gray.hsv=function(t){return[0,0,t[0]]},V.gray.hwb=function(t){return[0,100,t[0]]},V.gray.cmyk=function(t){return[0,0,0,t[0]]},V.gray.lab=function(t){return[t[0],0,0]},V.gray.hex=function(t){var e=255&Math.round(t[0]/100*255),n=((e<<16)+(e<<8)+e).toString(16).toUpperCase();return"000000".substring(n.length)+n},V.rgb.gray=function(t){return[(t[0]+t[1]+t[2])/3/255*100]};var K=z.exports,X=K;function W(t){var e=function(){for(var t={},e=Object.keys(X),n=e.length,r=0;r<n;r++)t[e[r]]={distance:-1,parent:null};return t}(),n=[t];for(e[t].distance=0;n.length;)for(var r=n.pop(),i=Object.keys(X[r]),s=i.length,o=0;o<s;o++){var a=i[o],c=e[a];-1===c.distance&&(c.distance=e[r].distance+1,c.parent=r,n.unshift(a))}return e}function Q(t,e){return function(n){return e(t(n))}}function tt(t,e){for(var n=[e[t].parent,t],r=X[e[t].parent][t],i=e[t].parent;e[i].parent;)n.unshift(e[i].parent),r=Q(X[e[i].parent][i],r),i=e[i].parent;return r.conversion=n,r}var et=K,nt=function(t){for(var e=W(t),n={},r=Object.keys(e),i=r.length,s=0;s<i;s++){var o=r[s];null!==e[o].parent&&(n[o]=tt(o,e))}return n},rt={};Object.keys(et).forEach((function(t){rt[t]={},Object.defineProperty(rt[t],"channels",{value:et[t].channels}),Object.defineProperty(rt[t],"labels",{value:et[t].labels});var e=nt(t);Object.keys(e).forEach((function(n){var r=e[n];rt[t][n]=function(t){var e=function(e){if(null==e)return e;arguments.length>1&&(e=Array.prototype.slice.call(arguments));var n=t(e);if("object"==typeof n)for(var r=n.length,i=0;i<r;i++)n[i]=Math.round(n[i]);return n};return"conversion"in t&&(e.conversion=t.conversion),e}(r),rt[t][n].raw=function(t){var e=function(e){return null==e?e:(arguments.length>1&&(e=Array.prototype.slice.call(arguments)),t(e))};return"conversion"in t&&(e.conversion=t.conversion),e}(r)}))}));var it=j,st=rt,ot=[].slice,at=["keyword","gray","hex"],ct={};Object.keys(st).forEach((function(t){ct[ot.call(st[t].labels).sort().join("")]=t}));var lt={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in at&&(e=null),e&&!(e in st))throw new Error("Unknown model: "+e);var n,r;if(null==t)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if("string"==typeof t){var i=it.get(t);if(null===i)throw new Error("Unable to parse color from string: "+t);this.model=i.model,r=st[this.model].channels,this.color=i.value.slice(0,r),this.valpha="number"==typeof i.value[r]?i.value[r]:1}else if(t.length){this.model=e||"rgb",r=st[this.model].channels;var s=ot.call(t,0,r);this.color=dt(s,r),this.valpha="number"==typeof t[r]?t[r]:1}else if("number"==typeof t)t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,255&t],this.valpha=1;else{this.valpha=1;var o=Object.keys(t);"alpha"in t&&(o.splice(o.indexOf("alpha"),1),this.valpha="number"==typeof t.alpha?t.alpha:0);var a=o.sort().join("");if(!(a in ct))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=ct[a];var c=st[this.model].labels,l=[];for(n=0;n<c.length;n++)l.push(t[c[n]]);this.color=dt(l)}if(lt[this.model])for(r=st[this.model].channels,n=0;n<r;n++){var u=lt[this.model][n];u&&(this.color[n]=u(this.color[n]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ht(t,e,n){return(t=Array.isArray(t)?t:[t]).forEach((function(t){(lt[t]||(lt[t]=[]))[e]=n})),t=t[0],function(r){var i;return arguments.length?(n&&(r=n(r)),(i=this[t]()).color[e]=r,i):(i=this[t]().color[e],n&&(i=n(i)),i)}}function ft(t){return function(e){return Math.max(0,Math.min(t,e))}}function dt(t,e){for(var n=0;n<e;n++)"number"!=typeof t[n]&&(t[n]=0);return t}ut.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(t){var e=this.model in it.to?this:this.rgb(),n=1===(e=e.round("number"==typeof t?t:1)).valpha?e.color:e.color.concat(this.valpha);return it.to[e.model](n)},percentString:function(t){var e=this.rgb().round("number"==typeof t?t:1),n=1===e.valpha?e.color:e.color.concat(this.valpha);return it.to.rgb.percent(n)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var t={},e=st[this.model].channels,n=st[this.model].labels,r=0;r<e;r++)t[n[r]]=this.color[r];return 1!==this.valpha&&(t.alpha=this.valpha),t},unitArray:function(){var t=this.rgb().color;return t[0]/=255,t[1]/=255,t[2]/=255,1!==this.valpha&&t.push(this.valpha),t},unitObject:function(){var t=this.rgb().object();return t.r/=255,t.g/=255,t.b/=255,1!==this.valpha&&(t.alpha=this.valpha),t},round:function(t){return t=Math.max(t||0,0),new ut(this.color.map(function(t){return function(e){return function(t,e){return Number(t.toFixed(e))}(e,t)}}(t)).concat(this.valpha),this.model)},alpha:function(t){return arguments.length?new ut(this.color.concat(Math.max(0,Math.min(1,t))),this.model):this.valpha},red:ht("rgb",0,ft(255)),green:ht("rgb",1,ft(255)),blue:ht("rgb",2,ft(255)),hue:ht(["hsl","hsv","hsl","hwb","hcg"],0,(function(t){return(t%360+360)%360})),saturationl:ht("hsl",1,ft(100)),lightness:ht("hsl",2,ft(100)),saturationv:ht("hsv",1,ft(100)),value:ht("hsv",2,ft(100)),chroma:ht("hcg",1,ft(100)),gray:ht("hcg",2,ft(100)),white:ht("hwb",1,ft(100)),wblack:ht("hwb",2,ft(100)),cyan:ht("cmyk",0,ft(100)),magenta:ht("cmyk",1,ft(100)),yellow:ht("cmyk",2,ft(100)),black:ht("cmyk",3,ft(100)),x:ht("xyz",0,ft(100)),y:ht("xyz",1,ft(100)),z:ht("xyz",2,ft(100)),l:ht("lab",0,ft(100)),a:ht("lab",1),b:ht("lab",2),keyword:function(t){return arguments.length?new ut(t):st[this.model].keyword(this.color)},hex:function(t){return arguments.length?new ut(t):it.to.hex(this.rgb().round().color)},rgbNumber:function(){var t=this.rgb().color;return(255&t[0])<<16|(255&t[1])<<8|255&t[2]},luminosity:function(){for(var t=this.rgb().color,e=[],n=0;n<t.length;n++){var r=t[n]/255;e[n]=r<=.03928?r/12.92:Math.pow((r+.055)/1.055,2.4)}return.2126*e[0]+.7152*e[1]+.0722*e[2]},contrast:function(t){var e=this.luminosity(),n=t.luminosity();return e>n?(e+.05)/(n+.05):(n+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color;return(299*t[0]+587*t[1]+114*t[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=.3*t[0]+.59*t[1]+.11*t[2];return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),n=e.color[0];return n=(n=(n+t)%360)<0?360+n:n,e.color[0]=n,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var n=t.rgb(),r=this.rgb(),i=void 0===e?.5:e,s=2*i-1,o=n.alpha()-r.alpha(),a=((s*o==-1?s:(s+o)/(1+s*o))+1)/2,c=1-a;return ut.rgb(a*n.red()+c*r.red(),a*n.green()+c*r.green(),a*n.blue()+c*r.blue(),n.alpha()*i+r.alpha()*(1-i))}},Object.keys(st).forEach((function(t){if(-1===at.indexOf(t)){var e=st[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var n,r="number"==typeof arguments[e]?e:this.valpha;return new ut((n=st[this.model][t].raw(this.color),Array.isArray(n)?n:[n]).concat(r),t)},ut[t]=function(n){return"number"==typeof n&&(n=dt(ot.call(arguments),e)),new ut(n,t)}}}));var mt=A(ut);function pt(t){return null==t}function yt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];for(const e in n)t[e]=n[e]}return t}function bt(t){return null!=t&&("function"==typeof t||null!==t.constructor&&t.constructor===Function)}function gt(t){return"object"==typeof t&&!!t}function vt(t){return"number"==typeof t&&!isNaN(t)}function wt(t){return t*Math.PI/180}function Tt(t){return t/Math.PI*180}function Mt(t){let e=document.createElement("a");return e.href=t,t=e.href,e=null,t}function _t(t){return Math.sign?Math.sign(t):0===(t=+t)||isNaN(t)?Number(t):t>0?1:-1}const Ot=[1,1,1,1,2,2,3,0];function At(t){const e=t.length;let n="";for(let r=0;r<e;){let i=t[r++];if(128&i){let n=Ot[i>>3&7];if(!(64&i)||!n||r+n>e)return null;for(i&=63>>n;n>0;n-=1){const e=t[r++];if(128!=(192&e))return null;i=i<<6|63&e}}n+=String.fromCharCode(i)}return n}function xt(t,e,n){return t[3*n]=e[0],t[3*n+1]=e[1],t[3*n+2]=e[2],t}function It(t){return t.flat?t.flat(1/0):t.reduce(((t,e)=>t.concat(e)),[])}function St(t){return t<256?Uint8Array:t<65536?Uint16Array:Uint32Array}function Ct(t){return 0===t.indexOf("data:")}function kt(t){const e=t.indexOf("base64,"),n=t.substring(e+7),r=window.atob(n),i=r.length,s=new Uint8Array(i);for(let t=0;t<i;t++)s[t]=r.charCodeAt(t);return s.buffer}function Nt(t){for(let e=1;e<arguments.length;e++){const n=arguments[e];if(n)for(let e=0,r=n.length;e<r;e++)t.push(n[e])}return t.length}const Lt={};function Et(t,e){if(!Array.isArray(e)){const t=e;e=Lt[t]=Lt[t]||mt(e).array().map((t=>t/255))}for(let n=0;n<e.length;n++)t[n]=e[n];return 3===e.length&&(t[3]=1),t}var Rt=Object.freeze({__proto__:null,base64URLToArrayBuffer:kt,extend:yt,flatArr:It,getAbsoluteURL:Mt,getBatchIdArrayType:St,isBase64:Ct,isFunction:bt,isNil:pt,isNumber:vt,isObject:gt,normalizeColor:Et,pushIn:Nt,setColumn3:xt,sign:_t,stringFromUTF8Array:At,toDegree:Tt,toRadian:wt});function Pt(t){return-1===t.indexOf("http://")&&-1===t.indexOf("https://")&&-1===t.indexOf("file://")}function Ut(t){return(t=t||{}).referrerPolicy=t.referrerPolicy||"origin",t.referrer=window&&window.location.href,t}const Bt=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Ft=Bt(),Gt=Ft.gl_trans__coders=Ft.gl_trans__coders||{};
11
+ */;for(var l=[],c=0;c<6;c++)l[c]=[];var h=[];function u(e,t,r){M(e);for(var n=0;n<6;n++){var o=l[n];if(h[0]=o[0]>0?t[1][0]:t[0][0],h[1]=o[1]>0?t[1][1]:t[0][1],h[2]=o[2]>0?t[1][2]:t[0][2],x(o,h)<0)return!1}return!0}var f=3,d=4,p=5,g=6,m=7,_=8,b=9,y=10,T=11;function v(e,t){var r=t,n=e,o=t,s=n[0],a=n[1],i=n[2],l=Math.abs(s*o[f]+a*o[d]+i*o[p])+Math.abs(s*o[g]+a*o[m]+i*o[_])+Math.abs(s*o[b]+a*o[y]+i*o[T]),c=x(e,r);return!(c<=-l)}function M(e){var t=e,r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],i=t[5],c=t[6],h=t[7],u=t[8],f=t[9],d=t[10],p=t[11],g=t[12],m=t[13],_=t[14],b=t[15];w(l[0],s-r,h-a,p-u,b-g),w(l[1],s+r,h+a,p+u,b+g),w(l[2],s+n,h+i,p+f,b+m),w(l[3],s-n,h-i,p-f,b-m),w(l[4],s-o,h-c,p-d,b-_),w(l[5],s+o,h+c,p+d,b+_)}function w(e,t,r,n,o){var s=1/Math.sqrt(t*t+r*r+n*n);return e[0]=t*s,e[1]=r*s,e[2]=n*s,e[3]=o*s,e}function x(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]}function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={exports:{}},I={exports:{}},A=function(e){return!(!e||"string"==typeof e)&&(e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&"String"!==e.constructor.name))},C=Array.prototype.concat,N=Array.prototype.slice,R=I.exports=function(e){for(var t=[],r=0,n=e.length;r<n;r++){var o=e[r];A(o)?t=C.call(t,N.call(o)):t.push(o)}return t};R.wrap=function(e){return function(){return e(R(arguments))}};var L=I.exports,E={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},P=L,k=Object.hasOwnProperty,B=Object.create(null);for(var D in E)k.call(E,D)&&(B[E[D]]=D);var U=S.exports={to:{},get:{}};function F(e,t,r){return Math.min(Math.max(t,e),r)}function H(e){var t=Math.round(e).toString(16).toUpperCase();return t.length<2?"0"+t:t}U.get=function(e){var t,r;switch(e.substring(0,3).toLowerCase()){case"hsl":t=U.get.hsl(e),r="hsl";break;case"hwb":t=U.get.hwb(e),r="hwb";break;default:t=U.get.rgb(e),r="rgb"}return t?{model:r,value:t}:null},U.get.rgb=function(e){if(!e)return null;var t,r,n,o=[0,0,0,1];if(t=e.match(/^#([a-f0-9]{6})([a-f0-9]{2})?$/i)){for(n=t[2],t=t[1],r=0;r<3;r++){var s=2*r;o[r]=parseInt(t.slice(s,s+2),16)}n&&(o[3]=parseInt(n,16)/255)}else if(t=e.match(/^#([a-f0-9]{3,4})$/i)){for(n=(t=t[1])[3],r=0;r<3;r++)o[r]=parseInt(t[r]+t[r],16);n&&(o[3]=parseInt(n+n,16)/255)}else if(t=e.match(/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)){for(r=0;r<3;r++)o[r]=parseInt(t[r+1],0);t[4]&&(t[5]?o[3]=.01*parseFloat(t[4]):o[3]=parseFloat(t[4]))}else{if(!(t=e.match(/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/)))return(t=e.match(/^(\w+)$/))?"transparent"===t[1]?[0,0,0,0]:k.call(E,t[1])?((o=E[t[1]])[3]=1,o):null:null;for(r=0;r<3;r++)o[r]=Math.round(2.55*parseFloat(t[r+1]));t[4]&&(t[5]?o[3]=.01*parseFloat(t[4]):o[3]=parseFloat(t[4]))}for(r=0;r<3;r++)o[r]=F(o[r],0,255);return o[3]=F(o[3],0,1),o},U.get.hsl=function(e){if(!e)return null;var t=e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var r=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,F(parseFloat(t[2]),0,100),F(parseFloat(t[3]),0,100),F(isNaN(r)?1:r,0,1)]}return null},U.get.hwb=function(e){if(!e)return null;var t=e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);if(t){var r=parseFloat(t[4]);return[(parseFloat(t[1])%360+360)%360,F(parseFloat(t[2]),0,100),F(parseFloat(t[3]),0,100),F(isNaN(r)?1:r,0,1)]}return null},U.to.hex=function(){var e=P(arguments);return"#"+H(e[0])+H(e[1])+H(e[2])+(e[3]<1?H(Math.round(255*e[3])):"")},U.to.rgb=function(){var e=P(arguments);return e.length<4||1===e[3]?"rgb("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+")":"rgba("+Math.round(e[0])+", "+Math.round(e[1])+", "+Math.round(e[2])+", "+e[3]+")"},U.to.rgb.percent=function(){var e=P(arguments),t=Math.round(e[0]/255*100),r=Math.round(e[1]/255*100),n=Math.round(e[2]/255*100);return e.length<4||1===e[3]?"rgb("+t+"%, "+r+"%, "+n+"%)":"rgba("+t+"%, "+r+"%, "+n+"%, "+e[3]+")"},U.to.hsl=function(){var e=P(arguments);return e.length<4||1===e[3]?"hsl("+e[0]+", "+e[1]+"%, "+e[2]+"%)":"hsla("+e[0]+", "+e[1]+"%, "+e[2]+"%, "+e[3]+")"},U.to.hwb=function(){var e=P(arguments),t="";return e.length>=4&&1!==e[3]&&(t=", "+e[3]),"hwb("+e[0]+", "+e[1]+"%, "+e[2]+"%"+t+")"},U.to.keyword=function(e){return B[e.slice(0,3)]};var G=S.exports,j={exports:{}},z={"aliceblue":[240,248,255],"antiquewhite":[250,235,215],"aqua":[0,255,255],"aquamarine":[127,255,212],"azure":[240,255,255],"beige":[245,245,220],"bisque":[255,228,196],"black":[0,0,0],"blanchedalmond":[255,235,205],"blue":[0,0,255],"blueviolet":[138,43,226],"brown":[165,42,42],"burlywood":[222,184,135],"cadetblue":[95,158,160],"chartreuse":[127,255,0],"chocolate":[210,105,30],"coral":[255,127,80],"cornflowerblue":[100,149,237],"cornsilk":[255,248,220],"crimson":[220,20,60],"cyan":[0,255,255],"darkblue":[0,0,139],"darkcyan":[0,139,139],"darkgoldenrod":[184,134,11],"darkgray":[169,169,169],"darkgreen":[0,100,0],"darkgrey":[169,169,169],"darkkhaki":[189,183,107],"darkmagenta":[139,0,139],"darkolivegreen":[85,107,47],"darkorange":[255,140,0],"darkorchid":[153,50,204],"darkred":[139,0,0],"darksalmon":[233,150,122],"darkseagreen":[143,188,143],"darkslateblue":[72,61,139],"darkslategray":[47,79,79],"darkslategrey":[47,79,79],"darkturquoise":[0,206,209],"darkviolet":[148,0,211],"deeppink":[255,20,147],"deepskyblue":[0,191,255],"dimgray":[105,105,105],"dimgrey":[105,105,105],"dodgerblue":[30,144,255],"firebrick":[178,34,34],"floralwhite":[255,250,240],"forestgreen":[34,139,34],"fuchsia":[255,0,255],"gainsboro":[220,220,220],"ghostwhite":[248,248,255],"gold":[255,215,0],"goldenrod":[218,165,32],"gray":[128,128,128],"green":[0,128,0],"greenyellow":[173,255,47],"grey":[128,128,128],"honeydew":[240,255,240],"hotpink":[255,105,180],"indianred":[205,92,92],"indigo":[75,0,130],"ivory":[255,255,240],"khaki":[240,230,140],"lavender":[230,230,250],"lavenderblush":[255,240,245],"lawngreen":[124,252,0],"lemonchiffon":[255,250,205],"lightblue":[173,216,230],"lightcoral":[240,128,128],"lightcyan":[224,255,255],"lightgoldenrodyellow":[250,250,210],"lightgray":[211,211,211],"lightgreen":[144,238,144],"lightgrey":[211,211,211],"lightpink":[255,182,193],"lightsalmon":[255,160,122],"lightseagreen":[32,178,170],"lightskyblue":[135,206,250],"lightslategray":[119,136,153],"lightslategrey":[119,136,153],"lightsteelblue":[176,196,222],"lightyellow":[255,255,224],"lime":[0,255,0],"limegreen":[50,205,50],"linen":[250,240,230],"magenta":[255,0,255],"maroon":[128,0,0],"mediumaquamarine":[102,205,170],"mediumblue":[0,0,205],"mediumorchid":[186,85,211],"mediumpurple":[147,112,219],"mediumseagreen":[60,179,113],"mediumslateblue":[123,104,238],"mediumspringgreen":[0,250,154],"mediumturquoise":[72,209,204],"mediumvioletred":[199,21,133],"midnightblue":[25,25,112],"mintcream":[245,255,250],"mistyrose":[255,228,225],"moccasin":[255,228,181],"navajowhite":[255,222,173],"navy":[0,0,128],"oldlace":[253,245,230],"olive":[128,128,0],"olivedrab":[107,142,35],"orange":[255,165,0],"orangered":[255,69,0],"orchid":[218,112,214],"palegoldenrod":[238,232,170],"palegreen":[152,251,152],"paleturquoise":[175,238,238],"palevioletred":[219,112,147],"papayawhip":[255,239,213],"peachpuff":[255,218,185],"peru":[205,133,63],"pink":[255,192,203],"plum":[221,160,221],"powderblue":[176,224,230],"purple":[128,0,128],"rebeccapurple":[102,51,153],"red":[255,0,0],"rosybrown":[188,143,143],"royalblue":[65,105,225],"saddlebrown":[139,69,19],"salmon":[250,128,114],"sandybrown":[244,164,96],"seagreen":[46,139,87],"seashell":[255,245,238],"sienna":[160,82,45],"silver":[192,192,192],"skyblue":[135,206,235],"slateblue":[106,90,205],"slategray":[112,128,144],"slategrey":[112,128,144],"snow":[255,250,250],"springgreen":[0,255,127],"steelblue":[70,130,180],"tan":[210,180,140],"teal":[0,128,128],"thistle":[216,191,216],"tomato":[255,99,71],"turquoise":[64,224,208],"violet":[238,130,238],"wheat":[245,222,179],"white":[255,255,255],"whitesmoke":[245,245,245],"yellow":[255,255,0],"yellowgreen":[154,205,50]},q={};for(var V in z)z.hasOwnProperty(V)&&(q[z[V]]=V);var Z=j.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(var $ in Z)if(Z.hasOwnProperty($)){if(!("channels"in Z[$]))throw new Error("missing channels property: "+$);if(!("labels"in Z[$]))throw new Error("missing channel labels property: "+$);if(Z[$].labels.length!==Z[$].channels)throw new Error("channel and label counts mismatch: "+$);var Q=Z[$].channels,W=Z[$].labels;delete Z[$].channels,delete Z[$].labels,Object.defineProperty(Z[$],"channels",{value:Q}),Object.defineProperty(Z[$],"labels",{value:W})}Z.rgb.hsl=function(e){var t,r,n=e[0]/255,o=e[1]/255,s=e[2]/255,a=Math.min(n,o,s),i=Math.max(n,o,s),l=i-a;return i===a?t=0:n===i?t=(o-s)/l:o===i?t=2+(s-n)/l:s===i&&(t=4+(n-o)/l),(t=Math.min(60*t,360))<0&&(t+=360),r=(a+i)/2,[t,100*(i===a?0:r<=.5?l/(i+a):l/(2-i-a)),100*r]},Z.rgb.hsv=function(e){var t,r,n,o,s,a=e[0]/255,i=e[1]/255,l=e[2]/255,c=Math.max(a,i,l),h=c-Math.min(a,i,l),u=function(e){return(c-e)/6/h+.5};return 0===h?o=s=0:(s=h/c,t=u(a),r=u(i),n=u(l),a===c?o=n-r:i===c?o=1/3+t-n:l===c&&(o=2/3+r-t),o<0?o+=1:o>1&&(o-=1)),[360*o,100*s,100*c]},Z.rgb.hwb=function(e){var t=e[0],r=e[1],n=e[2];return[Z.rgb.hsl(e)[0],100*(1/255*Math.min(t,Math.min(r,n))),100*(n=1-1/255*Math.max(t,Math.max(r,n)))]},Z.rgb.cmyk=function(e){var t,r=e[0]/255,n=e[1]/255,o=e[2]/255;return[100*((1-r-(t=Math.min(1-r,1-n,1-o)))/(1-t)||0),100*((1-n-t)/(1-t)||0),100*((1-o-t)/(1-t)||0),100*t]},Z.rgb.keyword=function(e){var t=q[e];if(t)return t;var r,n,o,s=1/0;for(var a in z)if(z.hasOwnProperty(a)){var i=z[a],l=(n=e,o=i,Math.pow(n[0]-o[0],2)+Math.pow(n[1]-o[1],2)+Math.pow(n[2]-o[2],2));l<s&&(s=l,r=a)}return r},Z.keyword.rgb=function(e){return z[e]},Z.rgb.xyz=function(e){var t=e[0]/255,r=e[1]/255,n=e[2]/255;return[100*(.4124*(t=t>.04045?Math.pow((t+.055)/1.055,2.4):t/12.92)+.3576*(r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92)+.1805*(n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92)),100*(.2126*t+.7152*r+.0722*n),100*(.0193*t+.1192*r+.9505*n)]},Z.rgb.lab=function(e){var t=Z.rgb.xyz(e),r=t[0],n=t[1],o=t[2];return n/=100,o/=108.883,r=(r/=95.047)>.008856?Math.pow(r,1/3):7.787*r+16/116,[116*(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116)-16,500*(r-n),200*(n-(o=o>.008856?Math.pow(o,1/3):7.787*o+16/116))]},Z.hsl.rgb=function(e){var t,r,n,o,s,a=e[0]/360,i=e[1]/100,l=e[2]/100;if(0===i)return[s=255*l,s,s];t=2*l-(r=l<.5?l*(1+i):l+i-l*i),o=[0,0,0];for(var c=0;c<3;c++)(n=a+1/3*-(c-1))<0&&n++,n>1&&n--,s=6*n<1?t+6*(r-t)*n:2*n<1?r:3*n<2?t+(r-t)*(2/3-n)*6:t,o[c]=255*s;return o},Z.hsl.hsv=function(e){var t=e[0],r=e[1]/100,n=e[2]/100,o=r,s=Math.max(n,.01);return r*=(n*=2)<=1?n:2-n,o*=s<=1?s:2-s,[t,100*(0===n?2*o/(s+o):2*r/(n+r)),100*((n+r)/2)]},Z.hsv.rgb=function(e){var t=e[0]/60,r=e[1]/100,n=e[2]/100,o=Math.floor(t)%6,s=t-Math.floor(t),a=255*n*(1-r),i=255*n*(1-r*s),l=255*n*(1-r*(1-s));switch(n*=255,o){case 0:return[n,l,a];case 1:return[i,n,a];case 2:return[a,n,l];case 3:return[a,i,n];case 4:return[l,a,n];case 5:return[n,a,i]}},Z.hsv.hsl=function(e){var t,r,n,o=e[0],s=e[1]/100,a=e[2]/100,i=Math.max(a,.01);return n=(2-s)*a,r=s*i,[o,100*(r=(r/=(t=(2-s)*i)<=1?t:2-t)||0),100*(n/=2)]},Z.hwb.rgb=function(e){var t,r,n,o,s,a,i,l=e[0]/360,c=e[1]/100,h=e[2]/100,u=c+h;switch(u>1&&(c/=u,h/=u),n=6*l-(t=Math.floor(6*l)),1&t&&(n=1-n),o=c+n*((r=1-h)-c),t){default:case 6:case 0:s=r,a=o,i=c;break;case 1:s=o,a=r,i=c;break;case 2:s=c,a=r,i=o;break;case 3:s=c,a=o,i=r;break;case 4:s=o,a=c,i=r;break;case 5:s=r,a=c,i=o}return[255*s,255*a,255*i]},Z.cmyk.rgb=function(e){var t=e[0]/100,r=e[1]/100,n=e[2]/100,o=e[3]/100;return[255*(1-Math.min(1,t*(1-o)+o)),255*(1-Math.min(1,r*(1-o)+o)),255*(1-Math.min(1,n*(1-o)+o))]},Z.xyz.rgb=function(e){var t,r,n,o=e[0]/100,s=e[1]/100,a=e[2]/100;return r=-.9689*o+1.8758*s+.0415*a,n=.0557*o+-.204*s+1.057*a,t=(t=3.2406*o+-1.5372*s+-.4986*a)>.0031308?1.055*Math.pow(t,1/2.4)-.055:12.92*t,r=r>.0031308?1.055*Math.pow(r,1/2.4)-.055:12.92*r,n=n>.0031308?1.055*Math.pow(n,1/2.4)-.055:12.92*n,[255*(t=Math.min(Math.max(0,t),1)),255*(r=Math.min(Math.max(0,r),1)),255*(n=Math.min(Math.max(0,n),1))]},Z.xyz.lab=function(e){var t=e[0],r=e[1],n=e[2];return r/=100,n/=108.883,t=(t/=95.047)>.008856?Math.pow(t,1/3):7.787*t+16/116,[116*(r=r>.008856?Math.pow(r,1/3):7.787*r+16/116)-16,500*(t-r),200*(r-(n=n>.008856?Math.pow(n,1/3):7.787*n+16/116))]},Z.lab.xyz=function(e){var t,r,n,o=e[0];t=e[1]/500+(r=(o+16)/116),n=r-e[2]/200;var s=Math.pow(r,3),a=Math.pow(t,3),i=Math.pow(n,3);return r=s>.008856?s:(r-16/116)/7.787,t=a>.008856?a:(t-16/116)/7.787,n=i>.008856?i:(n-16/116)/7.787,[t*=95.047,r*=100,n*=108.883]},Z.lab.lch=function(e){var t,r=e[0],n=e[1],o=e[2];return(t=360*Math.atan2(o,n)/2/Math.PI)<0&&(t+=360),[r,Math.sqrt(n*n+o*o),t]},Z.lch.lab=function(e){var t,r=e[0],n=e[1];return t=e[2]/360*2*Math.PI,[r,n*Math.cos(t),n*Math.sin(t)]},Z.rgb.ansi16=function(e){var t=e[0],r=e[1],n=e[2],o=1 in arguments?arguments[1]:Z.rgb.hsv(e)[2];if(0===(o=Math.round(o/50)))return 30;var s=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(t/255));return 2===o&&(s+=60),s},Z.hsv.ansi16=function(e){return Z.rgb.ansi16(Z.hsv.rgb(e),e[2])},Z.rgb.ansi256=function(e){var t=e[0],r=e[1],n=e[2];return t===r&&r===n?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5)},Z.ansi16.rgb=function(e){var t=e%10;if(0===t||7===t)return e>50&&(t+=3.5),[t=t/10.5*255,t,t];var r=.5*(1+~~(e>50));return[(1&t)*r*255,(t>>1&1)*r*255,(t>>2&1)*r*255]},Z.ansi256.rgb=function(e){if(e>=232){var t=10*(e-232)+8;return[t,t,t]}var r;return e-=16,[Math.floor(e/36)/5*255,Math.floor((r=e%36)/6)/5*255,r%6/5*255]},Z.rgb.hex=function(e){var t=(((255&Math.round(e[0]))<<16)+((255&Math.round(e[1]))<<8)+(255&Math.round(e[2]))).toString(16).toUpperCase();return"000000".substring(t.length)+t},Z.hex.rgb=function(e){var t=e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!t)return[0,0,0];var r=t[0];3===t[0].length&&(r=r.split("").map((function(e){return e+e})).join(""));var n=parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},Z.rgb.hcg=function(e){var t,r=e[0]/255,n=e[1]/255,o=e[2]/255,s=Math.max(Math.max(r,n),o),a=Math.min(Math.min(r,n),o),i=s-a;return t=i<=0?0:s===r?(n-o)/i%6:s===n?2+(o-r)/i:4+(r-n)/i+4,t/=6,[360*(t%=1),100*i,100*(i<1?a/(1-i):0)]},Z.hsl.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=1,o=0;return(n=r<.5?2*t*r:2*t*(1-r))<1&&(o=(r-.5*n)/(1-n)),[e[0],100*n,100*o]},Z.hsv.hcg=function(e){var t=e[1]/100,r=e[2]/100,n=t*r,o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},Z.hcg.rgb=function(e){var t=e[0]/360,r=e[1]/100,n=e[2]/100;if(0===r)return[255*n,255*n,255*n];var o,s=[0,0,0],a=t%1*6,i=a%1,l=1-i;switch(Math.floor(a)){case 0:s[0]=1,s[1]=i,s[2]=0;break;case 1:s[0]=l,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=i;break;case 3:s[0]=0,s[1]=l,s[2]=1;break;case 4:s[0]=i,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=l}return o=(1-r)*n,[255*(r*s[0]+o),255*(r*s[1]+o),255*(r*s[2]+o)]},Z.hcg.hsv=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t),n=0;return r>0&&(n=t/r),[e[0],100*n,100*r]},Z.hcg.hsl=function(e){var t=e[1]/100,r=e[2]/100*(1-t)+.5*t,n=0;return r>0&&r<.5?n=t/(2*r):r>=.5&&r<1&&(n=t/(2*(1-r))),[e[0],100*n,100*r]},Z.hcg.hwb=function(e){var t=e[1]/100,r=t+e[2]/100*(1-t);return[e[0],100*(r-t),100*(1-r)]},Z.hwb.hcg=function(e){var t=e[1]/100,r=1-e[2]/100,n=r-t,o=0;return n<1&&(o=(r-n)/(1-n)),[e[0],100*n,100*o]},Z.apple.rgb=function(e){return[e[0]/65535*255,e[1]/65535*255,e[2]/65535*255]},Z.rgb.apple=function(e){return[e[0]/255*65535,e[1]/255*65535,e[2]/255*65535]},Z.gray.rgb=function(e){return[e[0]/100*255,e[0]/100*255,e[0]/100*255]},Z.gray.hsl=Z.gray.hsv=function(e){return[0,0,e[0]]},Z.gray.hwb=function(e){return[0,100,e[0]]},Z.gray.cmyk=function(e){return[0,0,0,e[0]]},Z.gray.lab=function(e){return[e[0],0,0]},Z.gray.hex=function(e){var t=255&Math.round(e[0]/100*255),r=((t<<16)+(t<<8)+t).toString(16).toUpperCase();return"000000".substring(r.length)+r},Z.rgb.gray=function(e){return[(e[0]+e[1]+e[2])/3/255*100]};var K=j.exports,X=K;function J(e){var t=function(){for(var e={},t=Object.keys(X),r=t.length,n=0;n<r;n++)e[t[n]]={distance:-1,parent:null};return e}(),r=[e];for(t[e].distance=0;r.length;)for(var n=r.pop(),o=Object.keys(X[n]),s=o.length,a=0;a<s;a++){var i=o[a],l=t[i];-1===l.distance&&(l.distance=t[n].distance+1,l.parent=n,r.unshift(i))}return t}function Y(e,t){return function(r){return t(e(r))}}function ee(e,t){for(var r=[t[e].parent,e],n=X[t[e].parent][e],o=t[e].parent;t[o].parent;)r.unshift(t[o].parent),n=Y(X[t[o].parent][o],n),o=t[o].parent;return n.conversion=r,n}var te=K,re=function(e){for(var t=J(e),r={},n=Object.keys(t),o=n.length,s=0;s<o;s++){var a=n[s];null!==t[a].parent&&(r[a]=ee(a,t))}return r},ne={};Object.keys(te).forEach((function(e){ne[e]={},Object.defineProperty(ne[e],"channels",{value:te[e].channels}),Object.defineProperty(ne[e],"labels",{value:te[e].labels});var t=re(e);Object.keys(t).forEach((function(r){var n=t[r];ne[e][r]=function(e){var t=function(t){if(null==t)return t;arguments.length>1&&(t=Array.prototype.slice.call(arguments));var r=e(t);if("object"==typeof r)for(var n=r.length,o=0;o<n;o++)r[o]=Math.round(r[o]);return r};return"conversion"in e&&(t.conversion=e.conversion),t}(n),ne[e][r].raw=function(e){var t=function(t){return null==t?t:(arguments.length>1&&(t=Array.prototype.slice.call(arguments)),e(t))};return"conversion"in e&&(t.conversion=e.conversion),t}(n)}))}));var oe=G,se=ne,ae=[].slice,ie=["keyword","gray","hex"],le={};Object.keys(se).forEach((function(e){le[ae.call(se[e].labels).sort().join("")]=e}));var ce={};function he(e,t){if(!(this instanceof he))return new he(e,t);if(t&&t in ie&&(t=null),t&&!(t in se))throw new Error("Unknown model: "+t);var r,n;if(null==e)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(e instanceof he)this.model=e.model,this.color=e.color.slice(),this.valpha=e.valpha;else if("string"==typeof e){var o=oe.get(e);if(null===o)throw new Error("Unable to parse color from string: "+e);this.model=o.model,n=se[this.model].channels,this.color=o.value.slice(0,n),this.valpha="number"==typeof o.value[n]?o.value[n]:1}else if(e.length){this.model=t||"rgb",n=se[this.model].channels;var s=ae.call(e,0,n);this.color=de(s,n),this.valpha="number"==typeof e[n]?e[n]:1}else if("number"==typeof e)e&=16777215,this.model="rgb",this.color=[e>>16&255,e>>8&255,255&e],this.valpha=1;else{this.valpha=1;var a=Object.keys(e);"alpha"in e&&(a.splice(a.indexOf("alpha"),1),this.valpha="number"==typeof e.alpha?e.alpha:0);var i=a.sort().join("");if(!(i in le))throw new Error("Unable to parse color from object: "+JSON.stringify(e));this.model=le[i];var l=se[this.model].labels,c=[];for(r=0;r<l.length;r++)c.push(e[l[r]]);this.color=de(c)}if(ce[this.model])for(n=se[this.model].channels,r=0;r<n;r++){var h=ce[this.model][r];h&&(this.color[r]=h(this.color[r]))}this.valpha=Math.max(0,Math.min(1,this.valpha)),Object.freeze&&Object.freeze(this)}function ue(e,t,r){return(e=Array.isArray(e)?e:[e]).forEach((function(e){(ce[e]||(ce[e]=[]))[t]=r})),e=e[0],function(n){var o;return arguments.length?(r&&(n=r(n)),(o=this[e]()).color[t]=n,o):(o=this[e]().color[t],r&&(o=r(o)),o)}}function fe(e){return function(t){return Math.max(0,Math.min(e,t))}}function de(e,t){for(var r=0;r<t;r++)"number"!=typeof e[r]&&(e[r]=0);return e}he.prototype={toString:function(){return this.string()},toJSON:function(){return this[this.model]()},string:function(e){var t=this.model in oe.to?this:this.rgb(),r=1===(t=t.round("number"==typeof e?e:1)).valpha?t.color:t.color.concat(this.valpha);return oe.to[t.model](r)},percentString:function(e){var t=this.rgb().round("number"==typeof e?e:1),r=1===t.valpha?t.color:t.color.concat(this.valpha);return oe.to.rgb.percent(r)},array:function(){return 1===this.valpha?this.color.slice():this.color.concat(this.valpha)},object:function(){for(var e={},t=se[this.model].channels,r=se[this.model].labels,n=0;n<t;n++)e[r[n]]=this.color[n];return 1!==this.valpha&&(e.alpha=this.valpha),e},unitArray:function(){var e=this.rgb().color;return e[0]/=255,e[1]/=255,e[2]/=255,1!==this.valpha&&e.push(this.valpha),e},unitObject:function(){var e=this.rgb().object();return e.r/=255,e.g/=255,e.b/=255,1!==this.valpha&&(e.alpha=this.valpha),e},round:function(e){return e=Math.max(e||0,0),new he(this.color.map(function(e){return function(t){return function(e,t){return Number(e.toFixed(t))}(t,e)}}(e)).concat(this.valpha),this.model)},alpha:function(e){return arguments.length?new he(this.color.concat(Math.max(0,Math.min(1,e))),this.model):this.valpha},red:ue("rgb",0,fe(255)),green:ue("rgb",1,fe(255)),blue:ue("rgb",2,fe(255)),hue:ue(["hsl","hsv","hsl","hwb","hcg"],0,(function(e){return(e%360+360)%360})),saturationl:ue("hsl",1,fe(100)),lightness:ue("hsl",2,fe(100)),saturationv:ue("hsv",1,fe(100)),value:ue("hsv",2,fe(100)),chroma:ue("hcg",1,fe(100)),gray:ue("hcg",2,fe(100)),white:ue("hwb",1,fe(100)),wblack:ue("hwb",2,fe(100)),cyan:ue("cmyk",0,fe(100)),magenta:ue("cmyk",1,fe(100)),yellow:ue("cmyk",2,fe(100)),black:ue("cmyk",3,fe(100)),x:ue("xyz",0,fe(100)),y:ue("xyz",1,fe(100)),z:ue("xyz",2,fe(100)),l:ue("lab",0,fe(100)),a:ue("lab",1),b:ue("lab",2),keyword:function(e){return arguments.length?new he(e):se[this.model].keyword(this.color)},hex:function(e){return arguments.length?new he(e):oe.to.hex(this.rgb().round().color)},rgbNumber:function(){var e=this.rgb().color;return(255&e[0])<<16|(255&e[1])<<8|255&e[2]},luminosity:function(){for(var e=this.rgb().color,t=[],r=0;r<e.length;r++){var n=e[r]/255;t[r]=n<=.03928?n/12.92:Math.pow((n+.055)/1.055,2.4)}return.2126*t[0]+.7152*t[1]+.0722*t[2]},contrast:function(e){var t=this.luminosity(),r=e.luminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)},level:function(e){var t=this.contrast(e);return t>=7.1?"AAA":t>=4.5?"AA":""},isDark:function(){var e=this.rgb().color;return(299*e[0]+587*e[1]+114*e[2])/1e3<128},isLight:function(){return!this.isDark()},negate:function(){for(var e=this.rgb(),t=0;t<3;t++)e.color[t]=255-e.color[t];return e},lighten:function(e){var t=this.hsl();return t.color[2]+=t.color[2]*e,t},darken:function(e){var t=this.hsl();return t.color[2]-=t.color[2]*e,t},saturate:function(e){var t=this.hsl();return t.color[1]+=t.color[1]*e,t},desaturate:function(e){var t=this.hsl();return t.color[1]-=t.color[1]*e,t},whiten:function(e){var t=this.hwb();return t.color[1]+=t.color[1]*e,t},blacken:function(e){var t=this.hwb();return t.color[2]+=t.color[2]*e,t},grayscale:function(){var e=this.rgb().color,t=.3*e[0]+.59*e[1]+.11*e[2];return he.rgb(t,t,t)},fade:function(e){return this.alpha(this.valpha-this.valpha*e)},opaquer:function(e){return this.alpha(this.valpha+this.valpha*e)},rotate:function(e){var t=this.hsl(),r=t.color[0];return r=(r=(r+e)%360)<0?360+r:r,t.color[0]=r,t},mix:function(e,t){if(!e||!e.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof e);var r=e.rgb(),n=this.rgb(),o=void 0===t?.5:t,s=2*o-1,a=r.alpha()-n.alpha(),i=((s*a==-1?s:(s+a)/(1+s*a))+1)/2,l=1-i;return he.rgb(i*r.red()+l*n.red(),i*r.green()+l*n.green(),i*r.blue()+l*n.blue(),r.alpha()*o+n.alpha()*(1-o))}},Object.keys(se).forEach((function(e){if(-1===ie.indexOf(e)){var t=se[e].channels;he.prototype[e]=function(){if(this.model===e)return new he(this);if(arguments.length)return new he(arguments,e);var r,n="number"==typeof arguments[t]?t:this.valpha;return new he((r=se[this.model][e].raw(this.color),Array.isArray(r)?r:[r]).concat(n),e)},he[e]=function(r){return"number"==typeof r&&(r=de(ae.call(arguments),t)),new he(r,e)}}}));var pe=O(he);function ge(e){return null==e}function me(e){for(let t=1;t<arguments.length;t++){const r=arguments[t];for(const t in r)e[t]=r[t]}return e}function _e(e){return null!=e&&("function"==typeof e||null!==e.constructor&&e.constructor===Function)}function be(e){return"object"==typeof e&&!!e}function ye(e){return"number"==typeof e&&!isNaN(e)}function Te(e){return e*Math.PI/180}function ve(e){return e/Math.PI*180}function Me(e){let t=document.createElement("a");return t.href=e,e=t.href,t=null,e}function we(e){return Math.sign?Math.sign(e):0===(e=+e)||isNaN(e)?Number(e):e>0?1:-1}const xe=[1,1,1,1,2,2,3,0];function Oe(e){const t=e.length;let r="";for(let n=0;n<t;){let o=e[n++];if(128&o){let r=xe[o>>3&7];if(!(64&o)||!r||n+r>t)return null;for(o&=63>>r;r>0;r-=1){const t=e[n++];if(128!=(192&t))return null;o=o<<6|63&t}}r+=String.fromCharCode(o)}return r}function Se(e,t,r){return e[3*r]=t[0],e[3*r+1]=t[1],e[3*r+2]=t[2],e}function Ie(e){return e.flat?e.flat(1/0):e.reduce(((e,t)=>e.concat(t)),[])}function Ae(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}function Ce(e){return 0===e.indexOf("data:")}function Ne(e){const t=e.indexOf("base64,"),r=e.substring(t+7),n=window.atob(r),o=n.length,s=new Uint8Array(o);for(let e=0;e<o;e++)s[e]=n.charCodeAt(e);return s.buffer}function Re(e){for(let t=1;t<arguments.length;t++){const r=arguments[t];if(r)for(let t=0,n=r.length;t<n;t++)e.push(r[t])}return e.length}const Le={};function Ee(e,t){if(!Array.isArray(t)){const e=t;t=Le[e]=Le[e]||pe(t).array().map((e=>e/255))}for(let r=0;r<t.length;r++)e[r]=t[r];return 3===t.length&&(e[3]=1),e}var Pe=Object.freeze({__proto__:null,base64URLToArrayBuffer:Ne,extend:me,flatArr:Ie,getAbsoluteURL:Me,getBatchIdArrayType:Ae,isBase64:Ce,isFunction:_e,isNil:ge,isNumber:ye,isObject:be,normalizeColor:Ee,pushIn:Re,setColumn3:Se,sign:we,stringFromUTF8Array:Oe,toDegree:ve,toRadian:Te});function ke(e){return-1===e.indexOf("http://")&&-1===e.indexOf("https://")&&-1===e.indexOf("file://")}function Be(e){return(e=e||{}).referrerPolicy=e.referrerPolicy||"origin",e.referrer=window&&window.location.href,e}const De=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")},Ue=De(),Fe=Ue.gl_trans__coders=Ue.gl_trans__coders||{};
12
12
  /*!
13
- * @maptalks/gl v0.124.4
13
+ * @maptalks/gl v0.125.0
14
14
  * LICENSE : UNLICENSED
15
15
  * (c) 2016-2026 maptalks.com
16
- */function Dt(){return Bt().maptalks_gltf_loader}Gt.inject=function(t){const e=t.toString(),n=e.indexOf("{")+1,r=e.substring(0,n),i=Ft.gl_trans__coders=Ft.gl_trans__coders||{};let s=`${r}\n const _____getGlobal = ${Bt.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const t in i)"inject"!==t&&"getTranscoder"!==t&&"registerTranscoder"!==t&&(s+='tran_____scoders["'+t+'"] ='+i[t].toString()+"\n;");return s+="\n("+Bt().maptalks_gltf_loader_bundle.toString()+")({});\n",s+="\n"+e.substring(r.length),s},Gt.registerTranscoder=function(t,e){Gt[t]=e},Gt.getTranscoder=function(t){return Gt[t]};const jt="undefined"==typeof document?null:document.createElement("canvas");class zt extends i.worker.Actor{constructor(t,e,n){super(t),this.mapId=e,this.i=n}initialize(t){t(null)}loadTile(t,e,n){let r=null;e&&e.arraybuffer&&(r=[e.arraybuffer]);const i={mapId:this.mapId,layerId:t,command:"loadTile",params:e};this.send(i,r,n)}abortTileLoading(t,e,n){const r={mapId:this.mapId,layerId:t,command:"abortTileLoading",params:{url:e}};this.broadcast(r,null,n)}addLayer(t,e,n){const r={actorId:this.actorId,mapId:this.mapId,layerId:t,command:"addLayer",params:{options:e}};this.broadcast(r,null,n)}removeLayer(t,e){const n={mapId:this.mapId,layerId:t,command:"removeLayer"};this.broadcast(n,null,e)}requestImage({url:t},e){const n=new Image;n.onload=()=>{if(!this.isActive())return;if(!jt)return void e(new Error("There is no canvas to draw image!"));const t=this.i?n:function(t){if(Ht(t.width)&&Ht(t.height))return t;let e=t.width,n=t.height;Ht(e)||(e=qt(e));Ht(n)||(n=qt(n));const r=document.createElement("canvas");r.width=e,r.height=n,r.getContext("2d").drawImage(t,0,0,e,n);const i=t.src,s=i.lastIndexOf("/")+1,o=i.substring(s);return console.warn(`Texture(${o})'s size is not power of two, resize from (${t.width}, ${t.height}) to (${e}, ${n})`),r}(n);jt.width=t.width,jt.height=t.height;const r=jt.getContext("2d",{willReadFrequently:!0});r.drawImage(t,0,0,t.width,t.height);const i=r.getImageData(0,0,t.width,t.height),s={width:t.width,height:t.height,data:new Uint8Array(i.data)};e(null,s,[s.data.buffer])},n.onerror=function(t){e(t)},n.src=t}}function Ht(t){return!(t&t-1)&&0!==t}function qt(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))}var $t=1e-6,Vt="undefined"!=typeof Float32Array?Float32Array:Array;function Jt(t,e,n){var r=e[0],i=e[1],s=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],h=e[8],f=e[9],d=e[10],m=e[11],p=e[12],y=e[13],b=e[14],g=e[15],v=n[0],w=n[1],T=n[2],M=n[3];return t[0]=v*r+w*a+T*h+M*p,t[1]=v*i+w*c+T*f+M*y,t[2]=v*s+w*l+T*d+M*b,t[3]=v*o+w*u+T*m+M*g,v=n[4],w=n[5],T=n[6],M=n[7],t[4]=v*r+w*a+T*h+M*p,t[5]=v*i+w*c+T*f+M*y,t[6]=v*s+w*l+T*d+M*b,t[7]=v*o+w*u+T*m+M*g,v=n[8],w=n[9],T=n[10],M=n[11],t[8]=v*r+w*a+T*h+M*p,t[9]=v*i+w*c+T*f+M*y,t[10]=v*s+w*l+T*d+M*b,t[11]=v*o+w*u+T*m+M*g,v=n[12],w=n[13],T=n[14],M=n[15],t[12]=v*r+w*a+T*h+M*p,t[13]=v*i+w*c+T*f+M*y,t[14]=v*s+w*l+T*d+M*b,t[15]=v*o+w*u+T*m+M*g,t}function Yt(){var t=new Vt(3);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t}function Zt(t){var e=t[0],n=t[1],r=t[2];return Math.hypot(e,n,r)}function Kt(t,e,n){var r=new Vt(3);return r[0]=t,r[1]=e,r[2]=n,r}function Xt(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function Wt(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t}function Qt(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function te(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function ee(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t}function ne(t,e){var n=e[0],r=e[1],i=e[2],s=n*n+r*r+i*i;return s>0&&(s=1/Math.sqrt(s)),t[0]=e[0]*s,t[1]=e[1]*s,t[2]=e[2]*s,t}function re(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}function ie(t,e,n){var r=e[0],i=e[1],s=e[2],o=n[0],a=n[1],c=n[2];return t[0]=i*c-s*a,t[1]=s*o-r*c,t[2]=r*a-i*o,t}Math.hypot||(Math.hypot=function(){for(var t=0,e=arguments.length;e--;)t+=arguments[e]*arguments[e];return Math.sqrt(t)});var se=Qt,oe=te,ae=Zt;function ce(){var t=new Vt(4);return Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0),t[3]=1,t}Yt(),function(){var t,e=(t=new Vt(4),Vt!=Float32Array&&(t[0]=0,t[1]=0,t[2]=0,t[3]=0),t)}();var le;Yt(),Kt(1,0,0),Kt(0,1,0),ce(),ce(),le=new Vt(9),Vt!=Float32Array&&(le[1]=0,le[2]=0,le[3]=0,le[5]=0,le[6]=0,le[7]=0),le[0]=1,le[4]=1,le[8]=1;const{GLTFLoader:ue}=Dt();function he(t,e){if(t.scenes&&t.scenes.length)for(let n=0,r=t.scenes.length;n<r;n++){const r=t.scenes[n].nodes;for(let n=0,i=r.length;n<i;n++){const i=[];ge(r[n],i,t,e)}}}const fe=[],de=[],me=[],pe=[0,0,0],ye=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}([]),be=[1,1,1];function ge(t,e,n,r){const i=e.slice(0);if(t.matrix)i.push(t.matrix);else if(t.rotation||t.translation||t.scale){const e=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t}(fe,t.translation||pe),n=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,p=s*o,y=s*a,b=s*c;return t[0]=1-h-m,t[1]=u+b,t[2]=f-y,t[3]=0,t[4]=u-b,t[5]=1-l-m,t[6]=d+p,t[7]=0,t[8]=f+y,t[9]=d-p,t[10]=1-l-h,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(de,t.rotation||ye),r=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}(me,t.scale||be);Jt(r,n,r);const s=Jt([],e,r);i.push(s)}if(t.children&&t.children.length)for(let e=0,s=t.children.length;e<s;e++)ge(t.children[e],i,n,r);if(void 0!==t.mesh){const e=t.mesh,s=n.meshes[e];if(s){const t=i.slice(0),o=s.primitives;for(let i=0,s=o.length;i<s;i++){const s=o[i];s&&(s.matrices=t,r(s,e,i,n))}}}}function ve(t,e,n){let{byteOffset:r,byteStride:i}=e;const{componentType:s,itemSize:o}=e,a=e.array.buffer,c=s?ue.getTypedArrayCtor(s):e.array.constructor;if(r=void 0===r?e.array.byteOffset:r,i=i||0,!i||i===o*c.BYTES_PER_ELEMENT&&r%c.BYTES_PER_ELEMENT==0){const e=new c(a,r+n*o*c.BYTES_PER_ELEMENT,o);return t.set(e),t}i||(i=o*c.BYTES_PER_ELEMENT);const l=new Uint8Array(a,i*n+r,o*c.BYTES_PER_ELEMENT);return new Uint8Array(t.buffer).set(l),t}function we(t,e,n,r){t[4*e]=n[r],t[4*e+1]=n[r+4],t[4*e+2]=n[r+8],t[4*e+3]=n[r+12]}var Te="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const Me=new Array(3),_e=new Array(3),Oe=[40680631590769,40680631590769,40408299984661.445];function Ae(t,e,n,r){const i=Oe,s=Math.cos(n);Me[0]=s*Math.cos(e),Me[1]=s*Math.sin(e),Me[2]=Math.sin(n),Ue(Me,Me),te(_e,i,Me);const o=Math.sqrt(re(Me,_e));var a,c,l;return c=_e,l=o,(a=_e)[0]=c[0]/l,a[1]=c[1]/l,a[2]=c[2]/l,ee(Me,Me,r),function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t}(t,_e,Me)}const xe=[1/6378137,1/6378137,1/6356752.314245179],Ie=[1/40680631590769,1/40680631590769,1/40408299984661.445],Se=new Array(3),Ce=new Array(3),ke=new Array(3);function Ne(t,e){const n=Ie,r=function(t,e,n,r,i){const s=e[0],o=e[1],a=e[2],c=n[0],l=n[1],u=n[2],h=s*s*c*c,f=o*o*l*l,d=a*a*u*u,m=h+f+d,p=Math.sqrt(1/m),y=ee(Le,e,p);if(m<i)return isFinite(p)?y:void 0;const b=r[0],g=r[1],v=r[2],w=Ee;w[0]=y[0]*b*2,w[1]=y[1]*g*2,w[2]=y[2]*v*2;let T,M,_,O,A,x,I,S,C,k,N,L=(1-p)*Pe(e)/(.5*Pe(w)),E=0;do{L-=E,_=1/(1+L*b),O=1/(1+L*g),A=1/(1+L*v),x=_*_,I=O*O,S=A*A,C=x*_,k=I*O,N=S*A,T=h*x+f*I+d*S-1,M=h*C*b+f*k*g+d*N*v;E=T/(-2*M)}while(Math.abs(T)>Re);return t[0]=s*_,t[1]=o*O,t[2]=a*A,t}(Se,e,xe,n,.1);let i=oe(Ce,r,n);i=Ue(i,i);const s=se(ke,e,r),o=Math.atan2(i[1],i[0]),a=Math.asin(i[2]),c=_t(re(s,e))*Pe(s);return t[0]=Tt(o),t[1]=Tt(a),t[2]=c,t}const Le=new Array(3),Ee=new Array(3),Re=1e-12;function Pe(t){return Zt(t)}function Ue(t,e){const n=e[0],r=e[1],i=e[2];let s=n*n+r*r+i*i;return s>0&&(s=Math.sqrt(s),t[0]=e[0]/s,t[1]=e[1]/s,t[2]=e[2]/s),t}function Be(t,e){return te(e,t,Ie),ne(e,e)}function Fe(t,e){const n=t[0],r=t[1],i=Math.cos(r),s=i*Math.cos(n),o=i*Math.sin(n),a=Math.sin(r);return e.x=s,e.y=o,e.z=a,ne(e,e)}var Ge=Object.freeze({__proto__:null,cartesian3ToDegree:Ne,geodeticSurfaceNormal:Be,geodeticSurfaceNormalCartographic:Fe,normalizeCartesian:Ue,radianToCartesian3:Ae});function De(t,e,n,r){n=n||0,r=r||n;const i=Math.abs(t-e);return i<=r||i<=n*Math.max(Math.abs(t),Math.abs(e))}function je(t,e){let n="";for(let r=0;r<4;r++){const i=t.getUint8(e+r);n+=String.fromCharCode(i)}return n}const ze="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function He(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function qe(t,e,n){const r=new Uint8Array(t,e,n);return ze?JSON.parse(ze.decode(r)):JSON.parse(At(r))}function $e(t,e,n){return{offset:e,byteLength:n}}function Ve(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a,type:c}=We(s||"UNSIGNED_SHORT"),l=Ke(o);return{byteStride:0,byteOffset:i+n,itemSize:l,count:r*l,componentType:c,array:new a(e,n+i,r*l)}}function Je(t,e,n,r){const i=Ve(t,e,n,r);return i.array.buffer.byteLength!==e.byteLength&&(i.array=i.array.slice()),i}function Ye(t,e,n,r){const{byteOffset:i,componentType:s,type:o}=t,{ctor:a}=We(s||"UNSIGNED_SHORT"),c=Ke(o),l=new a(e,i,n*c);return 1===c?l[r]:l.subarray(r*c,r*c+c)}const Ze={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Ke(t){return t?Ze[t]:1}const Xe={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function We(t){return Xe[t]}function Qe(t){for(const e in Xe)if(t===Xe[e].ctor)return Xe[e].type;throw new Error("unrecognized ctor:"+t)}function tn(t,e,n,r){const i=t,s=e.length/3;for(let t=0;t<s;t++)i[3*t]=e[3*t]/65535*r[0]+n[0],i[3*t+1]=e[3*t+1]/65535*r[1]+n[1],i[3*t+2]=e[3*t+2]/65535*r[2]+n[2];return i}function en(t,e,n){const r=t.getUint32(12,!0),i=t.getUint32(16,!0),s=t.getUint32(20,!0),o=t.getUint32(24,!0),a=t.buffer;let c,l={},u={},h=null;r>0&&(l=He(a,e,r),e+=r),i>0&&(c=function(t,e,n){return{offset:e,byteLength:n}}(0,e,i),e+=i),s>0&&(u=qe(a,e,s),e+=s);const f=$e(0,e,o);return h=a.slice(f.offset,f.offset+f.byteLength),n.push(h),{featureTable:l,featureTableBin:c,batchTable:u,batchTableBin:h}}const nn={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"}},rn={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},sn={},on={east:[],north:[],up:[],west:[],south:[],down:[]};let an=[],cn=[],ln=[];const un=[0,0,0];function hn(t,e,n){return n[0]=t[0],n[1]=t[1],n[2]=t[2],n[3]=t[3],n[4]=t[4],n[5]=t[5],n[6]=t[6],n[7]=t[7],n[8]=t[8],n[9]=t[9],n[10]=t[10],n[11]=t[11],n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=t[15],n}const fn=function(t,e){const n=nn[t][e];let r;const i=t+e;return sn[i]?r=sn[i]:(r=function(r,i,s){if(a=un,c=(o=r)[0],l=o[1],u=o[2],h=a[0],f=a[1],d=a[2],Math.abs(c-h)<=$t*Math.max(1,Math.abs(c),Math.abs(h))&&Math.abs(l-f)<=$t*Math.max(1,Math.abs(l),Math.abs(f))&&Math.abs(u-d)<=$t*Math.max(1,Math.abs(u),Math.abs(d)))Xt(an,rn[t]),Xt(cn,rn[e]),Xt(ln,rn[n]);else if(De(r[0],0,1e-14)&&De(r[1],0,1e-14)){const i=_t(r[2]);Xt(an,rn[t]),Xt(cn,rn[e]),ee(cn,cn,i),Xt(ln,rn[n]),ee(ln,ln,i)}else{Be(r,on.up);const i=on.up,s=on.east;s[0]=-r[1],s[1]=r[0],s[2]=0,ne(on.east,s),ie(on.north,i,s),ee(on.down,on.up,-1),ee(on.west,on.east,-1),ee(on.south,on.north,-1),an=on[t],cn=on[e],ln=on[n]}var o,a,c,l,u,h,f,d;return s[0]=an[0],s[1]=an[1],s[2]=an[2],s[3]=0,s[4]=cn[0],s[5]=cn[1],s[6]=cn[2],s[7]=0,s[8]=ln[0],s[9]=ln[1],s[10]=ln[2],s[11]=0,s[12]=r[0],s[13]=r[1],s[14]=r[2],s[15]=1,s},sn[i]=r),r}("east","north"),dn=[],mn=[],pn=[],yn=[],bn=[],gn=[],vn=[],wn={x:0,y:0},Tn={x:0,y:0},Mn=Math.PI/180;let _n;const On={width:100,height:10};let An=!1;try{const t=new OffscreenCanvas(1,1);t.getContext("2d").fillText("hello",0,0),An=!0}catch(t){An=!1}function xn(){if(!_n){const{width:t,height:e}=On;An?_n=new OffscreenCanvas(t,e):(_n=document.createElement("canvas"),_n.width=t,_n.height=e)}return _n}class In{constructor(t,e={}){if(!Array.isArray(t))return void console.error("colors is not array");if(t.length<2)return void console.error("colors.length should >1");this.colors=t;let n=1/0,r=-1/0;for(let e=0,i=t.length;e<i;e++){const i=t[e][0];n=Math.min(i,n),r=Math.max(i,r)}this.min=n,this.max=r,this.valueOffset=this.max-this.min,this.options=Object.assign({},On,e),this.o()}getImageData(){return this.imgData}o(){const t=xn(),{width:e,height:n}=this.options;t.width=e,t.height=n;const r=t.getContext("2d");r.clearRect(0,0,t.width,t.height);const i=r.createLinearGradient(0,0,t.width,0),{colors:s,valueOffset:o}=this;for(let t=0,e=s.length;t<e;t++){const[e,n]=s[t],r=(e-this.min)/o;i.addColorStop(r,n)}r.fillStyle=i,r.fillRect(0,0,t.width,t.height),this.imgData=r.getImageData(0,0,t.width,t.height)}getColor(t){t=Math.max(this.min,t);const e=((t=Math.min(t,this.max))-this.min)/this.valueOffset;let n=Math.round(e*this.imgData.width);n=Math.min(n,this.imgData.width-1);const r=4*n;return[this.imgData.data[r],this.imgData.data[r+1],this.imgData.data[r+2],this.imgData.data[r+3]]}}var Sn;function Cn(t){return null==t}function kn(t){return!Cn(t)}function Nn(t){return""===t}function Ln(t,e){var n,r,i;if(zn(t)){var s,o=t.stops&&"object"==typeof t.stops[0][0],a=o||kn(t.property),c=o||!a,l=t.type||e||"exponential";if("exponential"===l)s=Pn;else if("interval"===l)s=Rn;else if("categorical"===l)s=En;else if("identity"===l)s=Fn;else if("color-interpolate"===l)s=Bn;else{if("calculate-expression"!==l)throw new Error('Unknown function type "'+l+'"');s=Gn}if(o){var u={},h=[];for(let e=0;e<t.stops.length;e++){var f=t.stops[e];void 0===u[f[0].zoom]&&(u[f[0].zoom]={zoom:f[0].zoom,type:t.type,property:t.property,default:t.default,stops:[]}),u[f[0].zoom].stops.push([f[0].value,f[1]])}for(let t in u)h.push([u[t].zoom,Ln(u[t])]);n=function(e,n){const r=Pn({stops:h,base:t.base},e)(e,n);return"function"==typeof r?r(e,n):r},r=!1,i=!1}else c?(n=function(e){const n=s(t,e);return"function"==typeof n?n(e):n},r=!0,i=!1):(n=function(e,n){const r=s(t,n?n[t.property]:null);return"function"==typeof r?r(e,n):r},r=!1,i=!0)}else n=function(){return t},r=!0,i=!0;return n.isZoomConstant=i,n.isFeatureConstant=r,n}function En(t,e){for(let n=0;n<t.stops.length;n++)if(e===t.stops[n][0])return t.stops[n][1];return t.default}function Rn(t,e){for(var n=0;n<t.stops.length&&!(e<t.stops[n][0]);n++);return t.stops[Math.max(n-1,0)][1]}function Pn(t,e){for(var n=kn(t.base)&&!Nn(t.base)?t.base:1,r=0;!(r>=t.stops.length||e<=t.stops[r][0]);)r++;return 0===r?t.stops[r][1]:r===t.stops.length?t.stops[r-1][1]:Dn(e,n,t.stops[r-1][0],t.stops[r][0],t.stops[r-1][1],t.stops[r][1])}"function"==typeof Map&&(Sn=new Map);const Un={width:100,height:1};function Bn(t,e){const n=t.stops;if(n&&n.length>1){let t;if(Sn){const e=JSON.stringify(n);if(!Sn.has(e)){const t=new In(n,Un);Sn.set(e,t)}t=Sn.get(e)}else t=new In(n,Un);const[r,i,s,o]=t.getColor(e);return[r/255,i/255,s/255,o/255]}return n&&1===n.length?n[0][1]:null}function Fn(t,e){return n=e,r=t.default,kn(n)?n:kn(r)?r:kn(i)?i:null;var n,r,i}function Gn(t,e){const n=String(t.property),r=t.expression,i=e;function s(e){return Cn(e)||Nn(e)||isNaN(e)?t.default:e}if(!kn(e)||Nn(e)||isNaN(e)||e<0)return s(t.default);{const e=function t(e,n,r){const i=Number(r),s=String(n);return Array.isArray(e)?e.map((e=>t(e,s,i))):e===s?i:e}(r,n,i);return s(function e(n){if(!Array.isArray(n)){if("number"==typeof n)return n;throw new Error("Invalid expression format")}{const r=n[0];if(!["+","-","*","/"].includes(r))throw new Error(`Unknown operator: ${r}`);const i=n.slice(1).map((t=>e(t)));switch(r){case"+":return i.reduce(((t,e)=>t+e),0);case"-":return i.reduce(((t,e)=>t-e));case"*":return i.reduce(((t,e)=>t*e),1);case"/":return i.some((t=>0===t))?t.default:i.reduce(((t,e)=>t/e));default:throw new Error(`Unsupported operator: ${r}`)}}}(e))}}function Dn(t,e,n,r,i,s){return"function"==typeof i?function(){var o=i.apply(void 0,arguments),a=s.apply(void 0,arguments);return Dn(t,e,n,r,o,a)}:i.length?function(t,e,n,r,i,s){var o=[];for(let a=0;a<i.length;a++)o[a]=jn(t,e,n,r,i[a],s[a]);return o}(t,e,n,r,i,s):jn(t,e,n,r,i,s)}function jn(t,e,n,r,i,s){var o,a=r-n,c=t-n;return i*(1-(o=1===e?c/a:(Math.pow(e,c)-1)/(Math.pow(e,a)-1)))+s*o}function zn(t){return t&&"object"==typeof t&&(t.stops||t.property&&"identity"===t.type||t.expression&&"calculate-expression"===t.type)}function Hn(t){return qn(t,"exponential")}function qn(t,e){if(!zn(t))return function(){return t};let n=!0,r=!0;const i=(t=JSON.parse(JSON.stringify(t))).stops;if(i)for(let t=0;t<i.length;t++)if(zn(i[t][1])){const s=qn(i[t][1],e);n=n&&s.isZoomConstant,r=r&&s.isFeatureConstant,i[t]=[i[t][0],s]}const s=Ln(t,e);return s.isZoomConstant=n&&s.isZoomConstant,s.isFeatureConstant=r&&s.isFeatureConstant,s}const{getTextureMagFilter:$n,getTextureMinFilter:Vn,getTextureWrap:Jn,getMaterialType:Yn,getMaterialFormat:Zn,getPrimitive:Kn,getUniqueREGLBuffer:Xn,getArrayType:Wn}=n.reshader.REGLHelper,Qn=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],tr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:er,logoutIBLResOnCanvas:nr,getIBLResOnCanvas:rr,getPBRUniforms:ir}=n.reshader.pbr.PBRUtils,sr={factor:0,units:0},or=[1,1,1,1],ar=[0,0,0],cr={specularStrength:0,materialShininess:1},lr=[1,1,1],ur=n.mat4.identity([]),hr=[0,0,0],fr=[0,0],dr=[],mr=t=>t.material instanceof n.reshader.PhongMaterial,pr=t=>t.material instanceof n.reshader.pbr.StandardMaterial,yr=[],br=new i.Coordinate(0,0),gr=new i.Point(0,0),vr=new i.Point(0,0),wr=new i.Point(0,0),Tr=[],Mr=[],_r=[],Or=[],Ar=[],xr=[],Ir=[],Sr=[],Cr=[],kr=[],Nr=[],Lr=[],Er=[],Rr=[],Pr={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Ur=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Br=function(t,e){const n=2*Math.PI/t,r=[],i=[];for(let i=0;i<=t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=s,r[3*i+2]=o}for(let i=t;i<=2*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=o,r[3*i+1]=t,r[3*i+2]=s}for(let i=2*t;i<=3*t;i++){const t=Math.cos(n*i)*e,s=Math.sin(n*i)*e,o=0;r[3*i]=t,r[3*i+1]=o,r[3*i+2]=s}const s=r.length/3-1;for(let e=0;e<s;e++)e!==t-1&&e!==2*t-1&&(i[2*e]=e,i[2*e+1]=e+1);return r.push(0,0,0),r.push(e,0,0),r.push(0,e,0),r.push(0,0,e),i.push(s+1,s+2),i.push(s+1,s+3),i.push(s+1,s+4),{vertices:r,indices:i}}(100,1),Fr=[0,0,0,1],Gr=[1,1,1];class Dr{constructor(t,e){this.u=e,this.h=e.getRenderer().canvas,this.pickingFBO=e.getRenderer().pickingFBO,this.m=t,this.p=new n.reshader.Renderer(t),this.v={},this.T={},this.M={},this._={},this.O={},this.A={},this.I=new n.reshader.Scene,this.S=new n.reshader.Scene,this.C=new n.reshader.Scene,this.k=new n.reshader.Scene,this.N=new n.reshader.ResourceLoader(t.texture(2)),this.L=(...t)=>this.R.call(this,...t),this.P=new n.reshader.KHRTechniquesWebglManager(this.m,this.U(),this.N);const r=this.getMap();this.B=r.altitudeToPoint(100,r.getGLRes())/100}getI3DMMeshes(){return this._}getPNTSMeshes(){return this.M}getB3DMMeshes(){return this.T}getPaintedMeshes(){return this.F}getMap(){return this.u.getMap()}paint(t,e,r){const i=r&&r.renderTarget,s=r&&r.sceneFilter,o=this.getMap();if(!t.length||!o)return null;const a=this.G(),c=o.projViewMatrix,l=[],u=[],f=[],d=[],m=[];for(let e=0,i=t.length;e<i;e++){const i=t[e].data.node;let s=this.D(i);if(!s)continue;const o=this.u.j(i.H),a=o.debugNodes,p=o.heightOffset||0,y=o.coordOffset||fr;this.O[i.id]&&(s=this.O[i.id],s=It(s));let b=o.polygonOffset||sr;bt(b)&&(b=b()),Array.isArray(s)||(l[0]=s,s=l);for(let l=0,g=s.length;l<g;l++){if(!s[l]||!s[l].isValid||!s[l].isValid())continue;const g=s[l].properties.magic;if(s[l].properties.heightOffset===p&&s[l].properties.coordOffset[0]===y[0]&&s[l].properties.coordOffset[1]===y[1]||(this.q(s[l]),s[l].$=n.mat4.copy([],s[l].localTransform)),s[l].V=i,"b3dm"===g){if(s[l].getBoundingBox&&!h(c,s[l].getBoundingBox()))continue;const{batchIdData:t,batchIdMap:e}=s[l].geometry.properties;if(t&&e){const t=s[l].properties.node.H;this.J&&this.J[t]?n.HighlightUtil.highlightMesh(this.m,s[l],this.J[t],this.Y,e):this.J&&this.J[t]||n.HighlightUtil.highlightMesh(this.m,s[l],null,this.Y,e),n.HighlightUtil.showOnly(this.m,s[l],this.Z&&this.Z[t],this.K,e)}if(a&&a.length&&a.indexOf(s[l].V.id)<0)continue;r&&r.bloom&&s[l].properties.hlBloomMesh&&(s[l].properties.hlBloomMesh.properties.depthFunc="always",f.push(s[l].properties.hlBloomMesh)),f.push(s[l])}else"pnts"===g?d.push(s[l]):"i3dm"===g&&m.push(s[l]);s[l].properties.isLeaf=t[e].leave,s[l].properties.branchRootId=t[e].branchRootId;const v=255-t[e].selectionDepth;s[l].properties.selectionDepth=v,s[l].properties.polygonOffset=b;const w=void 0===o.cullFace||!!o.cullFace;s[l].properties.cullFace=w;const T=s[l].properties.hlBloomMesh;if(T){const n=T.properties;n.branchRootId=t[e].branchRootId,n.selectionDepth=v,n.polygonOffset=b,n.cullFace=w}t[e].leave||u.push(s[l]),this.X(s[l]),this.W(s[l],i)}}let p=0;const y=this.P.getExcludeFilter();n.ContextUtil.setIncludeUniformValues(a,r),p+=this.tt(this.et,a,[s,mr,y],i,u,f,m),p+=this.tt(this.nt,a,[s,pr,y],i,u,f,m),this.P.forEachShader(((t,e,n)=>{const r=this.G(n);p+=this.tt(t,r,[s,e],i,u,f,m)})),this.S.setMeshes(d);const b=this.rt();return p+=this.p.render(this.it,b,this.S,i&&i.fbo),this.F={pntsMeshes:d,i3dmMeshes:m,b3dmMeshes:f},this.k.setMeshes(e),this.p.render(this.st,a,this.k,i&&i.fbo),p}prepareRender(t){this.ot(t)}ot(t){t&&t.states&&t.states.includesChanged&&(this.nt.dispose(),delete this.nt,this.et.dispose(),delete this.et),this.ct(t)}tt(t,e,n,r,i,s,o){t.filter=n.filter((t=>!!t)),e.stencilEnable=!1,e.cullFace="back";const a=r&&r.fbo;let c=0;const l=[],u=[];let h=!1,f=s[0]&&s[0].properties.branchRootId;for(let n=0;n<s.length;n++){const{branchRootId:r}=s[n].properties;r!==f&&(h?(u.length&&(c+=this.lt(t,e,a,!1,u),u.length=0),c+=this.lt(t,e,a,h,l)):Nt(u,l),f=r,h=!1,l.length=0),l.push(s[n]),s[n].properties.selectionDepth<255&&(h=!0),n===s.length-1&&(h||(Nt(u,l),l.length=0),u.length&&(c+=this.lt(t,e,a,!1,u)),c+=this.lt(t,e,a,h,l))}return this.I.setMeshes(s.filter((t=>t.properties.isLeaf))),this.C.setMeshes(o),c+=this.p.render(t,e,this.C,r&&r.fbo),c}lt(t,e,n,r,i){return i.length?(this.I.setMeshes(i),e.stencilEnable=!1,r&&(this.ut(n),e.stencilEnable=!1,e.cullFace="front",this.p.render(t,e,this.I,n),e.cullFace="back",e.stencilEnable=!0),this.p.render(t,e,this.I,n)):0}ut(t){this.m.clear({stencil:255,framebuffer:t})}getCurrentB3DMMeshes(){return this.I.getMeshes()}getCurrentI3DMMeshes(){return this.C.getMeshes()}ht(t,e){return e.V.ft-t.V.ft}deleteTile(t){const e=t.node;e.dt&&(e.dt.geometry.dispose(),e.dt.dispose(),delete e.dt);const n=e.id;this.yt(n)}yt(t){const e=this.T[t]||this.M[t]||this._[t]||this.O[t]||this.v[t];this.O[t]?this.bt(t):e&&(this.gt(e),delete this.T[t],delete this.M[t],delete this._[t],delete this.v[t])}bt(t){let e=this.O[t];e=It(e);for(let t=0;t<e.length;t++){const{id:n}=e[t].properties;this.yt(n)}delete this.O[t]}gt(t){if(Array.isArray(t))for(let e=0,n=t.length;e<n;e++)this.gt(t[e]);else{n.HighlightUtil.showOnly(this.m,t),n.HighlightUtil.highlightMesh(this.m,t);const e=t.geometry.properties.url;if(e){const n=this.A[e];n&&n.refMeshes&&(n.refMeshes.delete(t.uuid),n.refMeshes.size||(n.geometry.dispose(),n.material.dispose(),delete this.A[e]))}else t.geometry.dispose(),t.material&&t.material.dispose();t.dispose()}}remove(){const t=this.u;nr(t.getRenderer().canvas,t.getMap());for(const t in this.O)this.bt(t);this.O={};for(const t in this.T)this.yt(t);this.T={};for(const t in this.M)this.yt(t);this.M={};for(const t in this._)this.yt(t);this._={};for(const t in this.v)this.yt(t);this.v={},this.et&&(this.et.dispose(),delete this.et),this.nt&&(this.nt.dispose(),delete this.nt),this.it&&(this.it.dispose(),delete this.it),this.st&&(this.st.dispose(),delete this.st),this.P.dispose(),this.picking&&this.picking.dispose()}D(t){return this.T[t.id]||this.M[t.id]||this._[t.id]||this.O[t.id]}has(t){return this.D(t)||this.v[t.id]}q(t){const e=t.properties.magic;"b3dm"===e?this.vt(t):"i3dm"===e?this.wt(t):"pnts"===e&&this.Tt(t)}createPntsMesh(t,e,r,i){if(this.M[e]){const t=this.M[e];return console.warn(`pnts mesh with id(${e}) was already created.`),i(null,{id:e,mesh:t}),t}const{pnts:s,featureTable:o,rootIdx:a,compressed_int16_params:c}=t,l=o.POINTS_LENGTH;s.BATCH_ID||(s.BATCH_ID=new Uint8Array(l),s.BATCH_ID.fill(0));const u=new n.reshader.Geometry(s,null,l,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});u.generateBuffers(this.m);const h={};s.POSITION?h.HAS_POSITION=1:s.POSITION_QUANTIZED&&(h.HAS_POSITION_QUANTIZED=1),s.RGB?h.HAS_RGB=1:s.RGBA?h.HAS_RGBA=1:s.RGB565&&(h.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(h.HAS_NORMAL=1,s.NORMAL_OCT16P&&(h.HAS_NORMAL_OCT16P=1)),this.Mt(h,c),t.featureTable.CONSTANT_RGBA&&(t.featureTable.CONSTANT_RGBA=t.featureTable.CONSTANT_RGBA.map((t=>t/255)));const{rtcCenter:f,rtcCoord:d,projCenter:m}=t,p=this.u.j(a),y=new n.reshader.Mesh(u);y.properties.magic="pnts",y.properties.id=e,y.properties.node=r,y.properties.count=l,y.properties.batchTable=t.batchTable,y.properties.batchTableBin=t.batchTableBin,y.properties.serviceIndex=a,y.properties.rtcCoord=d,y.properties.rtcCenter=f,y.properties.projCenter=m,y.setDefines(h),y.setFunctionUniform("pointColor",(function(){return t.featureTable.CONSTANT_RGBA?t.featureTable.CONSTANT_RGBA:p&&p.pointColor||[1,1,1,1]}));const b=this.getMap();let g=null,v=null;y.setFunctionUniform("pointSize",(function(){if(!p)return 2;if(zn(p.pointSize)){const t=JSON.stringify(p.pointSize);t!==g&&(v=Hn(p.pointSize),g=t);return v(b.getZoom())}return p.pointSize||2}));let w=null,T=null;return y.setFunctionUniform("pointOpacity",(function(){if(!p)return 1;if(zn(p.pointOpacity)){const t=JSON.stringify(p.pointOpacity);t!==w&&(T=Hn(p.pointOpacity),w=t);return T(b.getZoom())}return p.pointOpacity||1})),this._t(y,c),this.Tt(y),y.$=n.mat4.copy([],y.localTransform),this.M[e]=y,i(null,{id:e,mesh:[y]}),[y]}Tt(t){const e=t.localTransform||[],{rtcCoord:n,node:r,projCenter:i}=t.properties;this.Ot(e,n,i,r.H),t.setLocalTransform(e)}createI3DMMesh(t,e,r,i){if(this._[e]){const t=this._[e];return console.warn(`i3dm mesh with id(${e}) was already created.`),this.v[e]||i(null,{id:e,mesh:t}),t}const s=this.u.j(r.H),o=this.At(r.xt),{i3dm:a,featureTable:c,gltf:l,batchTable:u,batchTableBin:h,count:f}=t,d=c.INSTANCES_LENGTH,{rtcCenter:m,rtcCoord:p,projCenter:y}=t,b=this.It(Or,r,m,p);hn(b,hr,b);const g=n.mat4.getRotation(Ar,b);n.quat.normalize(g,g);const v=n.mat4.getScaling(xr,b),w=n.mat4.fromScaling(Ir,v),T=this.St(Sr,y,r),M=this.Ct(Nr),_=this.kt(Lr,p),O=n.vec3.div(Er,_,M),A=n.mat4.fromScaling(Rr,O),{POSITION:x,NORMAL_UP:I,NORMAL_RIGHT:S,SCALE:C,SCALE_NON_UNIFORM:k}=a,N=this.getMap().getRenderer().isWebGPU()?Float32Array:Uint16Array,L={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new N(d)};for(let t=0;t<d;t++)L.aPickingId[t]=t;const E=new Float32Array(3),R=new Float32Array(3),P=[],U=new Float32Array(1),B=new Float32Array(3),F=[],G=[],D=[],j=[];!function(t,e){let{byteOffset:n,byteStride:r,count:i}=t;const{componentType:s,itemSize:o}=t,a=t.array.buffer,c=s?ue.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,r=r||0,i=i||t.array.length/o,(!r||r===o*c.BYTES_PER_ELEMENT)&&n%c.BYTES_PER_ELEMENT==0){const t=new c(a,n,i*o);for(let r=0;r<i*o;r+=o)e(new c(t.buffer,n+r*c.BYTES_PER_ELEMENT,o),r/o);return}const l=new Uint8Array(o*c.BYTES_PER_ELEMENT);r||(r=o*c.BYTES_PER_ELEMENT);for(let t=0;t<i;t++){const i=new Uint8Array(a,r*t+n,o*c.BYTES_PER_ELEMENT);l.set(i),e(new c(l.buffer),t),i.set(l)}}(x,((t,e)=>{I?(ve(R,S,e),ve(E,I,e),n.vec3.cross(P,R,E),n.vec3.normalize(P,P),xt(F,R,0),xt(F,E,1),xt(F,P,2),n.quat.fromMat3(G,F),n.quat.normalize(G,G),n.quat.multiply(G,g,G)):n.quat.identity(G),C?(ve(U,C,e),n.vec3.set(D,U[0],U[0],U[0])):k?(ve(B,k,e),n.vec3.set(D,...B)):n.vec3.set(D,1,1,1),n.mat4.fromRotationTranslationScale(j,G,t,D),we(L.instance_vectorA,e,j,0),we(L.instance_vectorB,e,j,1),we(L.instance_vectorC,e,j,2)}));const z={};for(const t in L)z[t]={buffer:this.m.buffer({dimension:L[t].length/d,data:L[t],name:t}),divisor:1};const H=s.shader||"pbr";let q=0,$=!0;const V=[],J=[];return he(l,((t,i,s,a)=>{const l=this.Nt(t,i,s,a,r,!0,H,J),{geometry:g,material:v}=l;v&&!v.isReady()&&($=!1,q++);const M=new n.reshader.InstancedMesh(z,d,g,v);l.refMeshes||(l.refMeshes=new Set,l.refMeshes.add(M.uuid)),M.properties.magic="i3dm",M.properties.id=e,M.properties.count=f,M.properties.batchTable=u,M.properties.batchTableBin=h,M.properties.serviceIndex=r.H,M.properties.rtcCoord=p,M.properties.rtcCenter=m,M.properties.projCenter=y,M.properties.node=r;const _=this.Lt(t,g,v,r.H,a);_.MESH_ENV_EXPO=1,t.compressed_int16_params&&this._t(M,t.compressed_int16_params),this.Et(M,t.attributes);const O=n.mat4.identity([]);if(t.matrices&&t.matrices.length)for(let e=0;e<t.matrices.length;e++)n.mat4.multiply(O,O,t.matrices[e]);n.mat4.multiply(O,o,O),n.mat4.multiply(O,A,O),c.EAST_NORTH_UP||I?n.mat4.multiply(O,w,O):n.mat4.multiply(O,b,O),M.setPositionMatrix(O),this.wt(M,T),M.setDefines(_),M.properties.polygonOffset={offset:0,factor:0},V.push(M),delete t.attributes,M.$=n.mat4.copy([],M.localTransform)})),jr(J),$?(this._[e]=V,i(null,{id:e,mesh:V})):(this.v[e]={meshes:V,count:q},V.Rt=i),V}wt(t,e){const{rtcCoord:r,node:i,projCenter:s}=t.properties;e||(e=this.St(Sr,s,i));const o=this.u.j(i.H),a=t.localTransform||[];if(o.coordOffset){const t=this.Pt(Or,i.H,r);n.mat4.multiply(a,t,e)}else n.mat4.copy(a,e);t.setLocalTransform(a),t.properties.heightOffset=o.heightOffset||0,t.properties.coordOffset=o.coordOffset&&o.coordOffset.slice(0)||fr}St(t,e,r){n.mat4.fromScaling(t,this.Ct(Nr));const i=this.Ut(Mr,e,r.H);return n.mat4.multiply(t,n.mat4.fromTranslation(Cr,i),t),t}createB3DMMesh(t,e,r,s){if(t.gltf&&(t.gltf.transferables=null),this.T[e]||this.v[e]){const t=this.T[e];return console.warn(`mesh with id(${e}) was already created.`),this.v[e]||s(null,{id:e,mesh:t}),t}let o;if(r.maxExtent){const t=new i.Extent(r.maxExtent).convertTo((t=>this._pointToPrj(t)));o=[t.xmin,t.ymin,t.xmax,t.ymax]}const a=t.gltf,{projCenter:c}=a.extensions.MAPTALKS_RTC,{rtcCoord:l,center:u}=a.extensions.CESIUM_RTC,h=a.asset.sharePosition,f=this.At(r.xt),d=this.Bt(Sr,h,l,u,c,r),m=this.u.j(r.H);let p=m.shader||"pbr";if(m.unlit)p="phong";else if(a.materials)for(let t=0;t<a.materials.length;t++)if(a.materials[t]&&a.materials[t].extensions&&a.materials[t].extensions.KHR_materials_unlit){p="phong";break}const y=[],b=[];let g=0,v=!0;return he(a,((i,s,a,w)=>{const T=this.Nt(i,s,a,w,r,!1,p,y),{geometry:M,material:_}=T;_&&!_.isReady()&&(v=!1,g++);const O=new n.reshader.Mesh(M,_);T.refMeshes||(T.refMeshes=new Set,T.refMeshes.add(O.uuid)),O.properties.magic="b3dm",O.properties.id=e,O.properties.node=r,t.batchTable&&(O.properties.batchTable=t.batchTable,O.properties.batchTableBin=t.batchTableBin),O.properties.count=t.featureTable&&t.featureTable.BATCH_LENGTH||0,O.properties.serviceIndex=r.H;const A=this.Lt(i,M,_,r.H,w);O.setDefines(A);const x=i.compressUniforms;if(x)for(const t in x)O.setUniform(t,x[t]);i.compressed_int16_params&&this._t(O,i.compressed_int16_params),this.Et(O,i.attributes),o&&(A.USE_MAX_EXTENT=1,O.setUniform("maxPrjExtent",o)),O.hasFunctionUniform("polygonOpacity")||O.setFunctionUniform("polygonOpacity",(function(){return vt(m.opacity)?m.opacity:1})),O.hasFunctionUniform("polygonFill")||O.setFunctionUniform("polygonFill",(function(){return Et([],m.polygonFill||or)})),O.material.hasFunctionUniform("hsv")||O.material.setFunctionUniform("hsv",(function(){return m.hsv||ar}));const I=n.mat4.identity([]);if(h&&i.matrices&&i.matrices.length)for(let t=0;t<i.matrices.length;t++)n.mat4.multiply(I,I,i.matrices[t]);h&&n.mat4.multiply(I,f,I),O.properties.node=r,O.properties.projCenter=c,O.properties.nodeMatrix=I,O.properties.isSharedPosition=h,O.properties.rtcCoord=l,O.properties.rtcCenter=u,this.vt(O,d),b.push(O),delete i.attributes,O.$=n.mat4.copy([],O.localTransform)})),jr(y),v?(this.T[e]=b,s(null,{id:e,mesh:b})):(this.v[e]={meshes:b,count:g},b.Rt=s),b}Ft(t){const e=this.u.Gt(t.id);if(!e||t.dt)return;let r,i,s,o;if(e.obbox)r=e.boxPosition,i=Ur,s=e.boxCenter,o=Gr;else if(e.sphereBox){const t=e.sphereBox[0],n=e.sphereBox[1];r=Br.vertices,i=Br.indices,s=t,o=[n,n,n]}const a=new n.reshader.Geometry({POSITION:r},i,0,{primitive:"lines",positionAttribute:"POSITION"}),c=new n.reshader.Mesh(a,new n.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),l=[];n.mat4.fromRotationTranslationScale(l,Fr,s,o),c.localTransform=l,c.$=n.mat4.copy([],l),c.properties.node=t,t.dt=c}Dt(t){t.dt&&(t.dt.geometry.dispose(),t.dt.dispose(),delete t.dt)}_t(t,e){e.POSITION&&t.setUniform("compressedPositionRange",e.POSITION),e.TEXCOORD_0&&t.setUniform("compressedTexcoordRange_0",e.TEXCOORD_0),e.TEXCOORD_1&&t.setUniform("compressedTexcoordRange_1",e.TEXCOORD_0),e.NORMAL&&t.setUniform("compressedNormalRange",e.NORMAL),e.TANGENT&&t.setUniform("compressedTangentRange",e.TANGENT),e.compressed_ratio&&t.setUniform("compressed_ratio",e.compressed_ratio)}vt(t,e){const{isSharedPosition:r,rtcCoord:i,rtcCenter:s,projCenter:o,nodeMatrix:a,node:c}=t.properties;e||(e=this.Bt(e||Sr,r,i,s,o,c));const l=t.localTransform||n.mat4.identity([]);n.mat4.multiply(l,e,a);const u=this.u.j(c.H);if(u.coordOffset){const t=this.Pt(Or,c.H,i);n.mat4.multiply(l,t,l)}t.setLocalTransform(l),t.properties.heightOffset=u.heightOffset||0,t.properties.coordOffset=u.coordOffset&&u.coordOffset.slice(0)||fr}Bt(t,e,r,i,s,o){if(e){const e=this.kt(Lr,r),s=n.mat4.fromScaling(_r,e),a=this.It(Or,o,i,r);n.mat4.multiply(t,a,s)}else this.Ot(t,r,s,o.H);return t}Et(t,e){if(e&&e.TEXCOORD_0&&e.TEXCOORD_0.extensions&&e.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const n=e.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;t.setUniform("decodeMatrix",n)}}It(t,e,r,i){const s=this.getMap(),o=this.u.j(e.H).heightOffset||0,a=e.matrix?n.mat4.copy(t,e.matrix):n.mat4.identity(t);if(r){hn(a,n.vec3.transformMat4(yr,r,a),a)}const c=function(t,e,n,r,i,s,o){e=Xt(dn,e);const a=Ae(dn,e[0]*Mn,e[1]*Mn,e[2]),c=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t}(mn,n),l=r.ellipsoid;let u;u=0===ae(c)?Wt(pn,0,0,-6378137):Ne(pn,c),wn.x=u[0],wn.y=u[1];const h=r.project(wn,Tn);yn[0]=h.x/i,yn[1]=h.y/i,yn[2]=(u[2]+o)*s;const f=fn(a,l,bn),d=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],h=e[9],f=e[10],d=e[11],m=e[12],p=e[13],y=e[14],b=e[15],g=n*a-r*o,v=n*c-i*o,w=n*l-s*o,T=r*c-i*a,M=r*l-s*a,_=i*l-s*c,O=u*p-h*m,A=u*y-f*m,x=u*b-d*m,I=h*y-f*p,S=h*b-d*p,C=f*b-d*y,k=g*C-v*S+w*I+T*x-M*A+_*O;return k?(k=1/k,t[0]=(a*C-c*S+l*I)*k,t[1]=(i*S-r*C-s*I)*k,t[2]=(p*_-y*M+b*T)*k,t[3]=(f*M-h*_-d*T)*k,t[4]=(c*x-o*C-l*A)*k,t[5]=(n*C-i*x+s*A)*k,t[6]=(y*w-m*_-b*v)*k,t[7]=(u*_-f*w+d*v)*k,t[8]=(o*S-a*x+l*O)*k,t[9]=(r*x-n*S-s*O)*k,t[10]=(m*M-p*w+b*g)*k,t[11]=(h*w-u*M-d*g)*k,t[12]=(a*A-o*I-c*O)*k,t[13]=(n*I-r*A+i*O)*k,t[14]=(p*v-m*T-y*g)*k,t[15]=(u*T-h*v+f*g)*k,t):null}(gn,f),m=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t}(vn,n);return hn(function(t,e,n){const r=t[0],i=t[1],s=t[2],o=t[4],a=t[5],c=t[6],l=t[8],u=t[9],h=t[10],f=e[0],d=e[1],m=e[2],p=e[3],y=e[4],b=e[5],g=e[6],v=e[7],w=e[8],T=r*f+o*d+l*m,M=i*f+a*d+u*m,_=s*f+c*d+h*m,O=r*p+o*y+l*b,A=i*p+a*y+u*b,x=s*p+c*y+h*b,I=r*g+o*v+l*w,S=i*g+a*v+u*w,C=s*g+c*v+h*w;return n[0]=T,n[1]=M,n[2]=_,n[3]=0,n[4]=O,n[5]=A,n[6]=x,n[7]=0,n[8]=I,n[9]=S,n[10]=C,n[11]=0,n[12]=t[12],n[13]=t[13],n[14]=t[14],n[15]=t[15],n}(d,m,t),yn,t),t}(a,i,a,s.getProjection(),s.getGLRes(),this.B,o),l=function(t,e){return Wt(t,e[12],e[13],e[14]),t}(Mr,c);let u=this.u.options.offset;if(bt(u)){const t=this.u.Gt(e.id).boxCoord;u=u.call(this.u,t)}return n.vec3.set(Tr,u[0],u[1],0),n.vec3.sub(l,l,Tr),hn(c,l,c),c}Pt(t,e,r){const i=this.u.j(e);if(!i.coordOffset)return null;const s=this.getMap(),o=s.getGLRes();br.set(r[0],r[1]);const a=s.coordToPointAtRes(br,o,vr),c=i.coordOffset,l=br.set(r[0]+c[0],r[1]+c[1]),u=s.coordToPointAtRes(l,o,wr),h=u.x-a.x,f=u.y-a.y,d=this.B,m=n.vec3.set(Tr,h,f,(c[2]||0)*d);return n.mat4.fromTranslation(t,m)}createCMPTMesh(t,e,n,r){if(this.O[e]){const t=this.O[e];return console.warn(`mesh with id(${e}) was already created.`),r(null,{id:e,mesh:t}),t}const{content:i}=t,s=[];for(let t=0;t<i.length;t++){const{magic:r}=i[t],o=e+"."+t;"b3dm"===r?this.createB3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"i3dm"===r?this.createI3DMMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"pnts"===r?this.createPntsMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)})):"cmpt"===r&&this.createCMPTMesh(i[t],o,n,((t,{mesh:e})=>{s.push(e)}))}return this.O[e]=s,r(null,{id:e,mesh:s}),s}Lt(t,e,n,r,i){const s=("phong"===(this.u.j(r).shader||"pbr")?this.et:this.nt).getGeometryDefines(e);i.asset&&"S3M"===i.asset.generator&&this.jt(s,e),e.data.uvRegion&&(s.HAS_I3S_UVREGION=1),e.data[e.desc.normalAttribute]&&(s.VertexNormal=1),e.data[e.desc.color0Attribute]&&(s.VertexColor=1),e.data[e.desc.uv0Attribute]&&(s.TexCoord=1),e.data[e.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),n.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),n.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this.u.zt&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),t.attributes&&t.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===t.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,this.Mt(s,t.compressed_int16_params);return yt(s,t.compressDefines),s}Mt(t,e){e&&Object.keys(e).length>0&&(t.HAS_COMPRESSED_INT16=1,e.POSITION&&(t.HAS_COMPRESSED_INT16_POSITION=1),e.TEXCOORD_0&&(t.HAS_COMPRESSED_INT16_TEXCOORD_0=1),e.TEXCOORD_1&&(t.HAS_COMPRESSED_INT16_TEXCOORD_1=1),e.NORMAL&&(t.HAS_COMPRESSED_INT16_NORMAL=1),e.TANGENT&&(t.HAS_COMPRESSED_INT16_TANGENT=1),e.compressed_ratio&&(t.HAS_COMPRESSED_INT16_RATIO=1))}X(t){const e=this.u.getRenderer();e&&e.updateMaskDefines(t)}jt(t,e){e.data.aNormal&&(t.VertexNormal=1),e.data.instanceId&&(t.Instance=1),e.data.aTexCoord0&&(t.TexCoord=1),e.data.aColor&&(t.VertexColor=1),e.data.aTexCoord1&&(t.TexCoord2=1),e.data.uv2&&(t.InstanceBim=1)}Nt(t,e,r,i,s,o,a,c){let l=!1;i.asset&&"S3M"===i.asset.generator&&(l=!0,i.extensions=i.extensions||{});const u=i.url+"-"+e+"-"+r;if(this.A[u])return this.A[u];let h,f;c.push(t);const d=i.materials&&i.materials[t.material],m=i.extensions&&i.extensions.KHR_techniques_webgl,p=this.u.j(s.H);if(m&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const e=this.Ht(t,i,o,l);h=e.material,f=e.geometry,p.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this.qt(t,o,Pr);const e=p.material;h=this.$t(t.material,i,a,e||cr,c,p)}h&&(h.setFunctionUniform("alphaTest",(function(){const t=p.alphaTest;return pt(t)?.1:t})),h.setFunctionUniform("environmentExposure",(()=>{const t=p.ambientLight;let e=p.environmentExposure;const n=this.getMap().getLightManager(),r=n&&n.getAmbientLight();if(t&&(!r||r.color)&&void 0===e){const n=r&&r.color?r.color[0]:.2;e=t[0]/n}return e||1}))),h&&!h.isReady()?h.Vt=s.id:h||(h=new n.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const y={geometry:f,material:h};return f.properties.url=u,this.A[u]=y,y}Ht(t,e,n,r){const{geometry:i,material:s}=this.P.createMesh(t,e,n,r);return{geometry:i,material:s}}qt(t,e,r){const i=this.getMap().getRenderer().isWebGPU(),s=t.attributes,o="COLOR_0";let a=s._BATCHID&&s._BATCHID.array;if(a&&a.byteOffset&&(a=new a.constructor(a),!i||a instanceof Float32Array||(a=new Float32Array(a))),s[o]){const t=s[o].array||s[o];if(t instanceof Float32Array){const e=new Uint8Array(t.length);for(let n=0;n<e.length;n++)e[n]=Math.round(255*t[n]);s[o].array?(s[o].array=e,s[o].componentType=5121):s[o]=e}}const c={};let l=0,u=0;for(const t in s){const e=r[t]||t,o=e===r.POSITION;i&&n.reshader.Geometry.padGPUGLTFAttribute(s[t]),o&&(l=s[t].itemSize);const a=Xn(this.m,s[t],{dimension:s[t].itemSize,name:t});c[e]=yt({},s[t]),c[e].buffer=a,c[e].type=Wn(c[e].array),delete c[e].array,e===r.POSITION&&(c[e].array=s[t].array,u=s[t].array.length/3)}const h=r._BATCHID;if(!c[h]&&!e){const t=new(i?Float32Array:Uint8Array)(u);c[h]=t}const f=t.indices?t.indices.array?t.indices.array.slice():t.indices:null,d=new n.reshader.Geometry(c,f,0,{positionSize:l,positionAttribute:r.POSITION,normalAttribute:r.NORMAL,uv0Attribute:r.TEXCOORD_0,uv1Attribute:r.TEXCOORD_1,color0Attribute:r.COLOR_0,tangentAttribute:r.TANGENT,pickingIdAttribute:r._BATCHID,primitive:void 0===t.mode?"triangles":Kn(t.mode)});return a&&f&&(d.properties.batchIdData=a,d.properties.batchIdMap=function(t,e){if(!e)return null;const n=new Map;for(let r=0;r<e.length;r++){const i=e[r],s=t[i];let o=n.get(s);o||(o=[],n.set(s,o)),o.push(i)}return n}(a,f)),d.generateBuffers(this.m,{excludeElementsInVAO:e}),d}Ot(t,e,r,i){const s=n.mat4.identity(t),o=this.Ct(lr);return this.Ut(Mr,r,i),n.mat4.translate(s,s,Mr),n.mat4.scale(s,s,o),s}Ut(t,e,r){const i=this.B;br.x=e[0],br.y=e[1];const s=this._prjToPoint(br);let o=this.u.options.offset;bt(o)&&(o=o.call(this.u,br));const a=this.u.j(r).heightOffset||0;return n.vec3.set(t,s.x-o[0],s.y-o[1],i*e[2]+i*a),t}W(t,e){const r=this.u.Jt(kr,e);t.localTransform=n.mat4.multiply(t.localTransform,r,t.$)}kt(t,e){const r=this.getMap();br.x=e[0],br.y=e[1];const i=r.distanceToPointAtRes(100,100,r.getGLRes(),br),s=this.B;return n.vec3.set(t,i.x/100,i.y/100,s),t}ct(t){if(this.nt)return;const e={x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},r=[],i=[];this.it=new n.reshader.MeshShader({vert:Te,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",uniforms:[{name:"projViewModelMatrix",type:"function",fn:(t,e)=>n.mat4.multiply(i,e.projViewMatrix,e.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(t,e)=>n.mat3.fromMat4(r,e.modelMatrix)}],extraCommandProps:{viewport:e,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const s={},o=[];n.ContextUtil.fillIncludes(s,o,t);const a=this.U();this.et=new n.reshader.PhongShader({uniforms:o,defines:s,extraCommandProps:a}),this.nt=new n.reshader.pbr.StandardShader({uniforms:o,defines:s,extraCommandProps:a}),this.st=new n.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const c=this.u;er(c.getRenderer().canvas,this.m,c.getMap()),this.picking=new n.reshader.FBORayPicking(this.p,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:n.getWGSLSource("layer_3dtiles_picking_vert"),extraCommandProps:a,uniforms:this.nt.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this.Yt=new n.reshader.FBORayPicking(this.p,{vert:Te,extraCommandProps:a,uniforms:this.it.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}U(){return{viewport:{x:0,y:0,width:()=>this.h?this.h.width:1,height:()=>this.h?this.h.height:1},cull:{enable:(t,e)=>e.meshProperties.cullFace,face:(t,e)=>e.cullFace||"back"},stencil:{enable:(t,e)=>e.stencilEnable,func:{cmp:"<=",ref:(t,e)=>e.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(t,e)=>e.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(t,e)=>e.meshProperties.polygonOffset}}}rt(t){const e=this.getMap(),r=e.getLightManager(),i=(r&&r.getDirectionalLight()||{}).direction||[1,1,-1],s=t&&t.pointOpacity||1;let o=this.u.options.opacity;return o=pt(o)?1:o,{projViewMatrix:e.projViewMatrix,pointOpacity:s,lightDir:n.vec3.normalize(dr,i),layerOpacity:o}}G(){const t=this.getMap(),e=this.u,n=e.getRenderer().canvas,{iblTexes:r,dfgLUT:i}=rr(n),s=ir(t,r,i),o=this.u.getRenderer().getMaskUniforms();s.minAltitude=e.options.altitude||0;let a=e.options.opacity;return a=pt(a)?1:a,s.layerOpacity=a,yt(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:t.viewMatrix,projMatrix:t.projMatrix,projViewMatrix:t.projViewMatrix,outSize:[n.width,n.height],polygonFill:[1,1,1,1],polygonOpacity:1}),s.ambientColor||(s.ambientColor=[.2,.2,.2]),yt(s,o),s}$t(t,e,r,i,s,o){const a=e.materials&&e.materials[t];if(!a||!a.baseColorTexture&&!a.pbrMetallicRoughness)return null;const c=yt({},i);if(a.baseColorTexture){const t=e.textures[a.baseColorTexture.index];let n;t&&!t.image.color&&(n=this.Zt(t,s)),c.baseColorFactor=t&&t.image.color||a.baseColorFactor||[1,1,1,1],n&&(c.baseColorTexture=n)}else{if(a.normalTexture){const t=this.Zt(e.textures[a.normalTexture.index],s);if(t){const e=a.normalTexture.scale||1;c.normalTexture=t,c.normalMapFactor=e}}if(a.occlusionTexture){const t=this.Zt(e.textures[a.occlusionTexture.index],s);if(t){const e=a.occlusionTexture.strength||1;c.occlusionTexture=t,c.occlusionFactor=e}}if(a.emissiveTexture){const t=this.Zt(e.textures[a.emissiveTexture.index],s);t&&(c.emissiveTexture=t)}a.emissiveFactor&&(c.emissiveFactor=a.emissiveFactor);const t=a.pbrMetallicRoughness;if(t){if(t.baseColorFactor&&(c.baseColorFactor=t.baseColorFactor),t.baseColorTexture&&void 0!==t.baseColorTexture.index){const r=e.textures[t.baseColorTexture.index];if(r&&r.image&&r.image.color)c.baseColorFactor=c.baseColorFactor?n.vec4.multiply(c.baseColorFactor,c.baseColorFactor,r.image.color):r.image.color;else{const t=this.Zt(r,s);t&&(c.baseColorTexture=t,c.baseColorTexture.getREGLTexture(this.m))}}if(pt(t.metallicFactor)||(c.metallicFactor=t.metallicFactor),pt(t.roughnessFactor)||(c.roughnessFactor=t.roughnessFactor),a.metallicRoughnessTexture){const t=this.Zt(e.textures[a.metallicRoughnessTexture.index],s);t&&(c.metallicRoughnessTexture=t)}}}if(a.s3mMaterial)return new n.reshader.Material(c);if(o.unlit||a.extensions&&a.extensions.KHR_materials_unlit){const t=new n.reshader.PhongMaterial(c);return t.unlit=void 0===o.unlit||!!o.unlit,t}let l=new n.reshader.pbr.StandardMaterial(c);"phong"===r&&(l=n.reshader.PhongMaterial.convertFrom(l));const u=a.pbrMetallicRoughness,h=u&&u.baseColorTexture&&u.baseColorTexture.extensions;return h&&h.KHR_texture_transform&&(l.set("khr_offset",h.KHR_texture_transform.offset||[0,0]),l.set("khr_rotation",h.KHR_texture_transform.rotation||0),l.set("khr_scale",h.KHR_texture_transform.scale||[1,1])),l.doubleSided=!(!o.doubleSided&&!a.doubleSided),l.once("complete",this.L),l}Zt(t,e){if(!t)return null;const r={type:t.type?Yn(t.type):"uint8",format:t.format?Zn(t.format):"rgba",flipY:!!t.flipY},i=t.image;if(e.push(i),i.array?r.data=i.array:i.mipmap&&(r.mipmap=i.mipmap),!r.data&&!r.mipmap)return null;if(r.width=i.width,r.height=i.height,r.mipmap&&(r.width<4||r.height<4))return null;const s=t.sampler||t.texture&&t.texture.sampler;return s&&(s.magFilter&&(r.mag=$n(s.magFilter)),s.minFilter&&(r.min=Vn(s.minFilter)),s.wrapS&&(r.wrapS=Jn(s.wrapS)),s.wrapT&&(r.wrapT=Jn(s.wrapT))),new n.reshader.Texture2D(r,this.N)}R({target:t}){const e=t.Vt,n=this.v[e];if(n.count--,!n.count){const t=n.meshes;this.T[e]=t,delete this.v[e];const r=t.Rt;delete t.Rt,r(null,{mesh:n.meshes,id:e})}}Ct(t){const e=1/this.getMap().getGLRes(),n=this.B;return t[0]=t[1]=e,t[2]=n,t}Kt(t){return this.u.Kt(t)}_pointToPrj(t){const e=this.getMap();return e.getGLZoom?e._pointToPrj(t,e.getGLZoom()):e._pointToPrjAtRes(t,e.getGLRes())}_prjToPoint(t){const e=this.getMap();return e.getGLZoom?e._prjToPoint(t,e.getGLZoom()):e._prjToPointAtRes(t,e.getGLRes(),gr)}At(t){return"Y"===t?Qn:"X"===t?tr:ur}pick(t,e,n=3){const r=this.u;if(!r||!r.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const i=[],s=this.G(),o=this.Xt(this.picking,s,this.I,t,e,n);o&&i.push(o);const a=this.Xt(this.picking,s,this.C,t,e,n);a&&i.push(a);const c=this.rt(),l=this.Xt(this.Yt,c,this.S,t,e,n);return l&&i.push(l),i}Xt(t,e,n,r,i,s){if(!n.getMeshes().length)return null;const o=this.u,a=this.getMap();t.render(n.getMeshes().filter((t=>!t.bloom)),e,!0);let c={};t.getRenderedMeshes().length&&(c=t.pick(r,i,s,e,{viewMatrix:a.viewMatrix,projMatrix:a.projMatrix,returnPoint:o.options.pickingPoint}));const{meshId:l,pickingId:u,point:h,coordinate:f}=c,d=(0===l||l)&&t.getMeshAt(l);if(!d||!d.geometry)return null;const m=d.properties;h&&h.length&&(h[0]=Math.round(1e5*h[0])/1e5,h[1]=Math.round(1e5*h[1])/1e5,h[2]=Math.round(1e5*h[2])/1e5);const p={batchId:u},y=o.options.services,b=y&&y[d.properties.serviceIndex];if(b&&b.debug&&(p.debugInfo=m),m&&m.batchTable){const{batchTable:t,batchTableBin:e,count:n}=m,r=u;for(const i in t)void 0!==t[i].byteOffset?p[i]=Ye(t[i],e,n,r):p[i]=t[i][r]}return{service:d.properties.serviceIndex,data:p,point:h,coordinate:f}}highlight(t){this.J=t;const e=this.u.getRenderer();this.Y=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelAllHighlight(){this.J=null;const t=this.u.getRenderer();this.Y=t.getFrameTimestamp(),t.setToRedraw(!0)}showOnly(t){this.Z=t;const e=this.u.getRenderer();this.K=e.getFrameTimestamp(),e.setToRedraw(!0)}cancelShowOnly(){this.Z=null;const t=this.u.getRenderer();this.K=t.getFrameTimestamp(),t.setToRedraw(!0)}Wt(){if(!this.F)return[];const t={},e=[];for(const n in this.F){const r=this.F[n];if(r)for(let n=0;n<r.length;n++){const i=r[n],s=i&&i.geometry;if(!i||!s)continue;const o=i.properties.serviceIndex;t[o]||(t[o]=new Set);const a=s.properties.batchIdData;if(a)for(let n=0;n<a.length;n++)t[o].has(a[n])||(e.push({id:a[n],service:o}),t[o].add(a[n]))}}return e}hasIBL(){const t=this.getMap().getLightManager();return!!(t&&t.getAmbientResource())}}function jr(t){for(let e=0;e<t.length;e++)t[e]&&(t[e].array&&(t[e].array=null),t[e].mipmap&&(t[e].mipmap=null),t[e].indices&&(t[e].indices=null))}function zr(t,e){if(e)for(let n=0;n<e.length;n++){t[e[n].id||e[n].index]=e[n]}}const Hr=[];class qr{constructor(t,e,n,r,i){this.u=r,this.Qt=t,this.H=e,this.te=i,this.ee=n.version,t.indexOf("i3s:tileset:")<0?(this.ee<=1.6?this.ne="root":this.ne=0,n.version=this.ee):(this.ne=t.substring(12),this.ee>1.6&&(this.ne=parseInt(this.ne))),this.Qt=t,this.re=n}load(){const t=this.re,e=t.layerScene.baseUrl;if(this.ee<=1.6)return t[this.ne]&&t[this.ne].lodSelection?(this.ie=t[this.ne],this.se()):new Promise((n=>{let r=e+"/nodes/"+this.ne;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{this.ie=t[this.ne],n(this.se())}))}));if(this.ee>=1.7){if(t[this.ne])return this.ie=t[this.ne],this.se();const n=Math.floor(this.ne/t.nodesPerPage);return new Promise((r=>{let i=e+"/nodepages/"+n;t.layerScene.eslpk&&(i+=".json"),this.te(this.H,i,(()=>{this.ie=t[this.ne],r(this.se())}))}))}return null}getTileset(){return this.oe}getChildrenURL(){return this.ae}se(){const t=this.re,e=t.layerScene.baseUrl,n=this.ie.children,r=[],i={};if(n)for(let s=0;s<n.length;s++)if(this.ee<=1.6){const o=n[s].id;if(t[o])continue;const a=o;i[a]||(i[a]=new Promise((n=>{let r=e+"/nodes/"+a;t.layerScene.eslpk&&(r+="/3dNodeIndexDocument.json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}else{const o=n[s];if(t[o])continue;const a=Math.floor(o/t.nodesPerPage);i[a]||(i[a]=new Promise((n=>{let r=e+"/nodepages/"+a;t.layerScene.eslpk&&(r+=".json"),this.te(this.H,r,(()=>{n()}))})),r.push(i[a]))}return r.length?Promise.all(r).then((()=>this.ce())):this.ce()}ce(){return Promise.resolve(this.le())}ue(t){zr(this.re,t)}le(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this.he(this.ie,!0)}}he(t){const e=this.u.getRenderer(),n=this.re.projection,r=!n||n&&4326===n.wkid,i=this.ee,s=this.re,o=t,a=o.obb,c=o.mbs,l={};let u;if(c)u=Wt([],c[0],c[1],c[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]),l.sphere=[...u,c[3]];else if(a){u=Wt([],a.center[0],a.center[1],a.center[2]),r||(u=e.fe(u,u)),u=$r([],u[0],u[1],u[2]);const t=function(t,e,n){const r=function(t,e){var n=e[0],r=e[1],i=e[2],s=e[3],o=n+n,a=r+r,c=i+i,l=n*o,u=r*o,h=r*a,f=i*o,d=i*a,m=i*c,p=s*o,y=s*a,b=s*c;return t[0]=1-h-m,t[3]=u-b,t[6]=f+y,t[1]=u+b,t[4]=1-l-m,t[7]=d-p,t[2]=f-y,t[5]=d+p,t[8]=1-l-h,t}([],n);return r[0]=r[0]*e[0],r[1]=r[1]*e[0],r[2]=r[2]*e[0],r[3]=r[3]*e[1],r[4]=r[4]*e[1],r[5]=r[5]*e[1],r[6]=r[6]*e[2],r[7]=r[7]*e[2],r[8]=r[8]*e[2],[...t,...r]}(u,a.halfSize,a.quaternion),n=t[3]+t[6]+t[9],i=t[4]+t[7]+t[10],s=t[5]+t[8]+t[11];Wt(Hr,n,i,s);const o=ae(Hr);l.sphere=[...u,o]}let h=1/0,f=0;if(o.mbs?f=o.mbs[3]:o.obb&&(f=Math.max(Math.max(o.obb.halfSize[0],o.obb.halfSize[1]),o.obb.halfSize[2])),void 0!==o.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){h=f/(Math.sqrt(o.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==o.lodSelection)for(let t=0;t<o.lodSelection.length;t++)"maxScreenThreshold"===o.lodSelection[t].metricType&&(h=f/o.lodSelection[t].maxError);(h===1/0||isNaN(h))&&(h=1e5);const d=16*h,m=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}([]),p=m,y=o.children;let b;if(y){b=[];const t=this.re;for(let e=0;e<y.length;e++){const n=i<=1.6?y[e].id:y[e];if(!t[n]){b=null;break}b.push(this.he(t[n]))}}const g={refine:"REPLACE",boundingVolume:l,transform:p,geometricError:d};return i<=1.6?t.lodSelection?t.geometryData&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}):g.content={uri:"i3s:tileset:"+(t.id||t.index)}:y&&y.length&&!b?g.content={uri:"i3s:tileset:"+(t.id||t.index)}:o.mesh&&(g.content={uri:"i3s:mesh:"+(t.id||t.index)}),b&&b.length&&(g.children=b),g}getJSON(){return this.ie}}function $r(t,e,n,r){return Ae(t,wt(e),wt(n),r)}const Vr=!!Gt.ktx2,Jr=n.mat4.identity([]),Yr=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const t=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(t instanceof WebAssembly.Module)return new WebAssembly.Instance(t)instanceof WebAssembly.Instance}}catch(t){}return!1})();function Zr(t){return t.indexOf("i3s:mesh")>=0}const Kr=9;function Xr(t,e,n,r,i){const s=e.layerScene.eslpk,o=function(t,e){const n=e.substring(Kr);return t>=1.7?parseInt(n):n}(e.version,t),a=e[o],c=e.layerScene.baseUrl,l=[];let u=!1;const h=Jr;let f,d;if(e.version<=1.6){if(!a.geometryData)return null;const t=a.geometryData.length;if(!t)return null;let n=c+`/nodes/${a.id}/`+a.geometryData[t-1].href;s&&(n+=".bin");const r={geometry:{url:n,info:e.layerScene.store.defaultGeometrySchema}};let i=a.textureData&&a.textureData[0]&&a.textureData[0].href;if(i){const t=e.layerScene.store.textureEncoding[0];let n;n="image/jpeg"===t?"jpg":"png",s&&(i+="."+n);const o={pbrMetallicRoughness:{baseColorTexture:{url:c+`/nodes/${a.id}/`+i,factor:1,format:n,mimeType:t},metallicFactor:0}};r.material=o}l.push(r)}else{f=a.mesh.geometry,d=a.mesh.material;const t=e.layerScene.geometryDefinitions,o=(e.layerScene.store||{}).textureEncoding,h=t[f.definition],{geometryBuffers:m}=h;u=r&&2===m.length;const p=Gt.draco&&u?m[1]:m[0],y=Gt.draco&&u?1:0;let b=c+`/nodes/${f.resource}/geometries/`+y;s&&(b+=".bin");const g={geometry:{url:b,info:p}};if(i&&Yr&&u&&!Gt.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const v=e.layerScene.materialDefinitions,w=e.layerScene.textureSetDefinitions;let T,M=0;if(d&&(M=v[d.definition]),v){T=function(t,e,n,r,i,s,o){const a=JSON.parse(JSON.stringify(e));return Wr(t,a,n,r,i,s,o),a}(o,M,w,c,d.resource,n,e.layerScene.eslpk)}else T={pbrMetallicRoughness:{metallicFactor:0}};g.material=T,l.push(g)}return{dracoCompression:u,meshes:l,nodeIndex:o,center:a.obb&&a.obb.center||a.mbs&&[a.mbs[0],a.mbs[1],a.mbs[2]],transform:h}}function Wr(t,e,n,r,i,s,o){for(const a in e)if(e[a]&&e[a].textureSetDefinitionId>=0){const c=n[e[a].textureSetDefinitionId],l="images/"+c.formats[0].format,u=ti(c.formats,s,t),h={url:r+`/nodes/${i}/textures/${u.name}`,factor:void 0===e[a].factor?1:e[a].factor,format:u.format,mimeType:l};if(o){let t="";switch(u.format){case"dds":t="bin.dds";break;case"jpg":case"png":t=u.format}h.url+="."+t}e[a]=h}else gt(e[a])&&Wr(t,e[a],n,r,i,s,o)}const Qr={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function ti(t,e,n){if(n&&n.length){const e=n[n.length-1],r=Qr[e];if(r)for(let e=0,n=t.length;e<n;e++){if(t[e].format===r)return t[e]}else console.error("i3s not find texture format type from:",Qr,"current textureEncoding:",e)}for(let n=0;n<=t.length;n++){const r=t[n].format;if("dds"===r&&e.hasExtension("WEBGL_compressed_texture_s3tc"))return t[n];if("jpg"===r||"png"===r)return t[n];if("ktx2"===r&&Vr)return t[n]}return null}const{Ajax:ei}=Dt(),ni=new i.Coordinate(0,0),ri=new i.Coordinate(0,0),ii=new Set,si=[],oi=new class{constructor(t,e){this.max=t,this.currentSize=0,this.data=new Map,this.onRemove=e}reset(t){if(this.data){const e=this.data.keys();for(const n of e){const e=this.data.get(n);t&&t!==e.renderer||this.de(n,e)}}return t||(this.data=new Map,this.currentSize=0),this}clear(t){this.reset(t)}add(t,e){if(!e)return this;if(e.node&&e.node.memorySize&&(this.currentSize+=e.node.memorySize),this.has(t)){const n=this.data.get(t);n&&n.node&&n.node.memorySize&&(this.currentSize-=n.node.memorySize),this.data.delete(t),this.data.set(t,e)}else this.data.set(t,e);return this}shrink(){if(this.currentSize>this.max){const t=this.data.keys();let e=t.next();for(;this.currentSize>this.max&&void 0!==e.value;){this.data.get(e.value).current&&i.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough, one or more current tiles will be discarded.`);const n=this.getAndRemove(e.value);n&&this.onRemove(n),e=t.next()}}}has(t){return this.data.has(t)}keys(){const t=new Array(this.data.size);let e=0;const n=this.data.keys();for(const r of n)t[e++]=r;return t}getAndRemove(t){if(!this.has(t))return null;const e=this.data.get(t);return e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),e}get(t){if(!this.has(t))return null;const e=this.data.get(t);return this.data.delete(t),this.data.set(t,e),e}remove(t){if(!this.has(t))return this;const e=this.data.get(t);return this.de(t,e),this}de(t,e){e.node&&e.node.memorySize&&(this.currentSize-=e.node.memorySize),this.data.delete(t),this.onRemove(e)}setMaxSize(t){return this.max=t,this.shrink(),this}getMemorySize(){let t=0;const e=this.data.values();for(const n of e){const e=n&&n.node;e&&e.memorySize&&(t+=e.memorySize)}return t}markAll(t,e){const n=this.data.values();for(const r of n)t&&r.renderer!==t||(r.current=e)}}(1024*(i.Browser.mobile?32:1024)*1024,(t=>{const e=t.renderer;delete t.renderer,e.deleteTile(t)}));let ai=0;class ci extends(n.MaskRendererMixin(n.CanvasCompatible(i.renderer.LayerAbstractRenderer))){constructor(t){super(t);const e=1024*t.options.maxGPUMemory*1024;e>oi.max&&oi.setMaxSize(e),this.tileCache=oi,ai++,this.tilesLoading={},this.me={},this.pe=[],this.te=(...t)=>this.ye.call(this,...t)}getAnalysisMeshes(){if(!this.painter)return si;const t=this.painter.getPaintedMeshes();if(!t)return si;const e=[],{b3dmMeshes:n,pntsMeshes:r,i3dmMeshes:i}=t;return n.length&&Nt(e,n.filter((t=>!(!t||!t.geometry)))),r.length&&Nt(e,r.filter((t=>!(!t||!t.geometry)))),i.length&&Nt(e,i.filter((t=>!(!t||!t.geometry)))),e}needToRedraw(){return!!this.getMap().isInteracting()||(!!this.pe.length||super.needToRedraw())}getFrameTimestamp(){return this.be}drawOnInteracting(t,e,n){this.draw(e,n)}draw(t,e){this.be=t;const n=this.prepareCanvas();if(n&&!n.intersects(this.canvasExtent2D))return void this.completeRender();const{root:r,tiles:i}=this.layer.getTiles(),s=i.length;if(!i||!s)return void this.completeRender();this.painter.prepareRender(e),this.ge(),this.ve(e);const{selectedTiles:o,requests:a}=this.we(r,i);a.length&&this.loadTiles(a),this.Te(o,e),this.Me(),a.length||this.completeRender()}we(t,e){let n=[];this._e();let r=0;const i=this.Oe(),s={};let o=!1,a=!1;for(let t=0;t<e.length;t++){const i=e[t],c=i.node;if(s[c.id])continue;s[c.id]=1;let l=!1;const u=this.getCachedTile(c.id);if(this.Ae(c.id)?(r++,l=a=!0,this.tilesLoading[c.id].current=!0):u?(this.getTileOpacity(u)<1&&(l=a=!0),o=!0,i.selected=!0,i.data=u):this.painter.has(c)||(l=a=!0,n.push(c)),!l)continue;if(this.xe(i))o=!0;else{this.Ie(i).length&&(o=!0)}}const c=o?this.Se(t):[];if(n.length>1&&(n.sort(li),i)){const t=i-r;n=t>0?n.slice(0,t):[]}return{loading:a,requests:n,selectedTiles:c}}Se(t){const e=[];let n,r;const i=[t],s=[];for(;i.length>0||s.length>0;){if(s.length>0){const t=s[s.length-1];if(t.Ce===i.length){s.pop(),t===n&&(t.leave=!0),t.branchRootId=r,e.push(t),0===s.length&&(r=null);continue}}const t=i.pop(),o=t.children;if(t.selected)if("add"===t.node.refine)t.leave=!0,t.selectionDepth=s.length,t.branchRootId=r,e.push(t);else{if(t.selectionDepth=s.length,n=t,0===o.length){t.leave=!0,t.branchRootId=r,e.push(t);continue}0===s.length&&(r=t.node.id),s.push(t),t.Ce=i.length}for(let t=0;t<o.length;t++)i.push(o[t])}return e}xe(t){if(!t.parent)return null;let e=t.parent;for(;e&&e.level>=0;){const t=e.node.id;if(this.tileCache.has(t))return e.selected=!0,e.data=this.tileCache.get(t),e;e=e.parent}return null}Ie(t){const e=[];if(!t.node.children||!t.node.children.length)return e;const n=t.ke+1,r=[t.node];for(;r.length>0;){const i=r.pop().children;for(let s=0,o=i.length;s<o;s++){if((!i[s].content||!i[s].content.url)&&i[s].children&&i[s].children.length){r.push(i[s]);continue}const o=i[s].id;if(this.tileCache.has(o)){const n=this.layer.Ne(i[s],t);n.selected=!0,n.data=this.tileCache.get(o),t.children.push(n),e.push(n)}else i[s].ke<=n&&r.push(i[s])}}return e}Te(t,e){this.tileCache.markAll(this,!1);const n=[];for(let e=0,r=t.length;e<r;e++){const r=t[e].data;r.current=!0,r.renderer=this,this.tileCache.add(t[e].node.id,r);const i=r.node,s=this.layer.j(i.H);i.dt&&s.debug&&!Array.isArray(s.debug)&&n.push(i.dt)}const r=this.layer.options.services;for(let t=0;t<r.length;t++){const e=r[t],i=Array.isArray(e.debug)&&e.debug;if(i)for(const t of i){const e=this.layer.Gt(t),r=e&&e.node;r&&r.dt&&n.push(r.dt)}}const i={tiles:t};this.onDrawTileStart(i);const s=this.painter.paint(t,n,e);this.layer.fire("drawtiles",{count:s}),this.onDrawTileEnd(i),s&&this.layer.fire("canvasisdirty",{renderCount:s}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(t){for(let e=0,n=t.length;e<n;e++){const n=t[e];this.tilesLoading[n.id]={current:!0,node:n},this.loadTile(n)}}loadTile(t){let e=t.content.url;if(Ct(e)){const n=kt(e);return this.Le(e,n,t),null}if(function(t){return t.indexOf("i3s:tileset")>=0}(e)){const n=t.H,r=this.Ee[n];return new qr(e,n,r,this.layer,this.te).load().then((n=>{this.onTilesetLoad(n,t,e)}))}return t&&Pt(e)&&!Zr(e)&&(e=t.baseUrl+e),this.Le(e,null,t),null}Le(t,e,r){let i=this.Re;i||(i=n.reshader.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this.Re=i);const s=this.layer.j(r.H);s.isSuperMapiServer&&(t=function(t,e){const n=t.substring(e.length),r=n.split("/"),i=[];for(let t=0;t<r.length;t++)i.push(encodeURIComponent(r[t]));return e+i.join("/")}(t,r.baseUrl));const o={url:this.layer.getTileUrl(t,this.layer.Pe[r.H]),arraybuffer:e,rootIdx:r.H,upAxis:r.xt,transform:r.matrix,supportedFormats:i};if(Zr(t)){const e=this.Ee[r.H];if(o.projection=e.projection,o.i3sInfo=Xr(t,e,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!o.i3sInfo)return void this.onTileError({status:404},r,t)}o.service=yt({},s),s.offset&&delete o.service.offset,o.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),o,((e,n)=>{if(e)return void this.onTileError(e,r,t);const{magic:i}=n;"b3dm"===i||"pnts"===i||"i3dm"===i||"cmpt"===i||"gltf"===i?this.pe.push({data:n,tile:r}):this.onTilesetLoad(n,r,t)}))}Ft(t){this.painter&&this.painter.Ft(t)}Dt(t){this.painter&&this.painter.Dt(t)}ve(){const t=this.getMap(),e=this.layer.options.meshLimitPerFrame;let n=0;for(;this.pe.length&&(n<e||!t.isInteracting());){const{data:t,tile:e}=this.pe.shift(),{magic:r}=t;"b3dm"===r||"gltf"===r?this.painter.createB3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"pnts"===r?this.painter.createPntsMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"i3dm"===r?this.painter.createI3DMMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})):"cmpt"===r&&this.painter.createCMPTMesh(t,e.id,e,((n,{mesh:r})=>{this.Ue(t,e,n,r)})),n++}}Ue(t,e,n,r){if(this.Be(r),n)this.onTileError(n,e);else{const n=this.Fe(r);e.memorySize=n,this.onTileLoad(t,e)}}Be(t){if(Array.isArray(t)){for(let e=0;e<t.length;e++)if(t[e])if(Array.isArray(t[e]))this.Be(t[e]);else{const n=t[e].defines||{};n.HAS_LAYER_OPACITY=1,t[e].setDefines(n)}}else if(t)if(Array.isArray(t))this.Be(t);else{const e=t.defines||{};e.HAS_LAYER_OPACITY=1,t.setDefines(e)}}Fe(t){let e=0;if(Array.isArray(t))for(let n=0;n<t.length;n++)t[n]&&(e+=this.Fe(t[n]));else t&&(e+=t.getMemorySize());return e}onTileLoad(t,e){this.layer&&(delete this.tilesLoading[e.id],this.layer.onTileLoad(t,e),this.Ge(e),this.setToRedraw(),this.layer.fire("tileload",{node:e}))}onTilesetLoad(t,e,n){this.layer&&(this.layer.zt=t.extensions&&t.extensions["s3m:VertexCompressionType"],t.capabilities||t.layers&&t.layers[0]&&t.layers[0].capabilities?this.De(t,e,n):(delete this.tilesLoading[e.id],this.layer.onTilesetLoad(t,e,n)))}onTileError(t,e,n){if(!this.layer)return;const r=n||e.content.url,s=t&&t.message||t;t&&(404===t.status||204===t.status)||ii.has(s)||(console.warn("failed to load 3d tile: "+r),console.warn(t),ii.add(s)),delete this.tilesLoading[e.id],(!this.layer.options.onlyCacheNoContentTileWhenError||t&&!i.Util.isNoContentHttpCode(t.status))&&this.je(e,t),this.layer.fire("tileerror",{node:e,error:t})}getCachedTile(t){return this.tileCache.get(t)}getShadowMeshes(){if(!this.painter)return[];const t=[],e=this.painter.getCurrentB3DMMeshes();for(const n in e)e[n]&&e[n].isValid&&e[n].isValid()&&t.push(e[n]);const n=this.painter.getCurrentI3DMMeshes();for(const e in n)n[e]&&n[e].isValid&&n[e].isValid()&&t.push(n[e]);return t}je(t,e){const n={loadTime:i.Util.now(),current:!0,error:e,node:t};n.renderer=this,this.tileCache.add(t.id,n)}Ge(t){const e={loadTime:i.Util.now(),current:!0,node:t};e.renderer=this,this.tileCache.add(t.id,e)}abortTileLoading(t){if(!t||!this.workerConn)return;const e=t.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),e),delete this.me[e]}_e(){if(this.tilesLoading)for(const t in this.tilesLoading)this.tilesLoading[t].current=!1}deleteTile(t){this.painter.deleteTile(t)}initContext(){super.initContext();const t=this.layer,{regl:e,reglGL:n,device:r}=this.context;this.regl=e,this.device=r,this.gl=n;const i=e||r;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||i.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Dr(i,t),this.layer.ze(),this.layer.fire("contextcreate",{regl:e,device:r})}prepareWorker(){const t=this.getMap();this.workerConn||(this.workerConn=new zt("@maptalks/3dtiles",t.id,n.reshader.Util.supportNPOT(this.regl||this.device)));const e=this.workerConn;if(!e.isActive())return;let r=this.layer.options||{};r=yt({},r),delete r.offset;const i=t.options.spatialReference;r.projection=i&&i.coordType||i&&i.projection||t.getSpatialReference().getProjection().code;const s=this.layer.getId();e.addLayer(s,r,(t=>{if(t)throw t;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(t=>{if(t)throw t})),this.workerConn.remove(),delete this.workerConn),ai--,ai||oi.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this.Me(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}Me(t){this.He||(this.He=Date.now());const e=Date.now();if(!t&&e-this.He<this.layer.options.retireInterval)return;this.He=e;const n=[];for(const e in this.tilesLoading){const r=this.tilesLoading[e];!t&&r.current||(n.push(e),this.abortTileLoading(r))}for(let t=0;t<n.length;t++)delete this.tilesLoading[n[t]]}Oe(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}qe(t,e){const n=["webgl","experimental-webgl"];let r=null;for(let i=0;i<n.length;++i){try{r=t.getContext(n[i],e)}catch(t){}if(r)break}return r}Ae(t){return!!this.tilesLoading[t]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(t,e,n){return Ve(t,e,0,n)}ge(){if(!this.$e)return;const t=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let e=0;const n=[];for(const r in this.$e){const i=this.$e[r];if("pending"===i.status)continue;i.status="pending";const s=i.rootIdx,o=Ut(this.layer.j(s).fetchOptions);if(n.push(ei.getJSON(r,o).then((t=>{delete this.$e[r];const e=this.Ee[s];if(e){t.nodes?zr(e,t.nodes):(e[t.id]=t,zr(e,t.children));for(let t=0;t<i.length;t++)i[t]();this.setToRedraw()}else this.setToRedraw()}))),e++,e>=t)break}n.length&&Promise.all(n)}ye(t,e,n){this.$e||(this.$e={}),this.$e[e]=this.$e[e]||[],this.$e[e].rootIdx=t,this.$e[e].push(n),this.setToRedraw()}De(t,e,n){this.Ee||(this.Ee=[]);const r=e.H;this.Ee[r]||(this.Ee[r]={});const i=this.Ee[r],s=this.layer.j(r);t.layers&&(t=t.layers[0],"/"!==n[n.length-1]&&(n+="/"),n+="layers/0"),i.version=+(s.i3sVersion||t.store.version),!t.spatialReference||t.spatialReference.wkid&&4326===t.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",t.spatialReference),t.spatialReference&&4490===t.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),t.spatialReference.wkid=4326),i.projection=t.spatialReference,function(t,e,n,r,i,s,o){if(!s.layerScene){s.layerScene=e,s.nodesPerPage=e.nodePages&&e.nodePages.nodesPerPage||64,s.lodSelectionMetricType=e.nodePages&&e.nodePages.lodSelectionMetricType;let t=i;if(s.layerScene.eslpk=t.indexOf("3dSceneLayer.json")>=0,t.endsWith(".json")){const e=i.lastIndexOf("/");t=e<0?"./":i.substring(0,e)}s.layerScene.baseUrl=function(t){return t.split("?")[0]}(t)}return new qr(i,n,s,t,o).load()}(this.layer,t,r,0,n,i,this.te).then((t=>{this.onTilesetLoad(t,e,n)}))}pick(t,e,n){if(!this.painter)return[];const r=this.pickingFBO,{width:i,height:s}=this.canvas;return!this.pickingFBO||r.width===i&&r.height===s||r.resize(i,s),this.painter.pick(t,e,n&&n.tolerance)}highlight(t){if(this.J||(this.J=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.J[n];r||(r=this.J[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.J[e];n||(n=this.J[e]=new Map),n.set(t.id,t)}this.painter.highlight(this.J)}cancelHighlight(t,e){if(!this.J)return;const n=this.J[t];if(n){if(Array.isArray(e))for(let t=0;t<e.length;t++)n.delete(e[t]);else n.delete(e);n.size||(this.J[t]=null),this.painter.highlight(this.J)}}cancelAllHighlight(){delete this.J,this.painter.cancelAllHighlight()}showOnly(t){if(this.Z||(this.Z=[]),Array.isArray(t))for(let e=0;e<t.length;e++){const n=t[e].service||0;let r=this.Z[n];r||(r=this.Z[n]=new Map),r.set(t[e].id,t[e])}else{const e=t.service||0;let n=this.Z[e];n||(n=this.Z[e]=new Map),n.set(t.id,t)}this.painter.showOnly(this.Z)}cancelShowOnly(){delete this.Z,this.painter.cancelShowOnly()}Wt(){return this.painter?this.painter.Wt():[]}fe(t,e){const n=this.getMap();if("identity"===n.getProjection().code.toLowerCase()){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}return ni.set(e[0],e[1]),n.getProjection().unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Je(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.project(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ye(t,e){const n=this.Ve();return ni.set(e[0],e[1]),n.unproject(ni,ri),t[0]=ri.x,t[1]=ri.y,t}Ve(){const t=this.getMap().options.spatialReference.coordType;if(!t)throw new Error("Missing coordType in map spatialReference.");return this.Ze||(this.Ze=i.SpatialReference.getProjectionInstance(t)),this.Ze}}function li(t,e){return t.ft-e.ft}function ui(t,e,n){return t[0]=e[n],t[1]=e[n+3],t[2]=e[n+6],t}function hi(t,e,n){return Math.sqrt(function(t,e,n){const r=Qt(fi,n,t),i=ui(di,e,0),s=ui(mi,e,1),o=ui(pi,e,2),a=ae(i),c=ae(s),l=ae(o);ne(i,i),ne(s,s),ne(o,o);const u=yi;u[0]=re(r,i),u[1]=re(r,s),u[2]=re(r,o);let h,f=0;u[0]<-a?(h=u[0]+a,f+=h*h):u[0]>a&&(h=u[0]-a,f+=h*h);u[1]<-c?(h=u[1]+c,f+=h*h):u[1]>c&&(h=u[1]-c,f+=h*h);u[2]<-l?(h=u[2]+l,f+=h*h):u[2]>l&&(h=u[2]-l,f+=h*h);return f}(t,e,n))}const fi=[],di=[],mi=[],pi=[],yi=[];const bi=2*Math.PI;class gi{constructor(t,e,n,r){this.west=t,this.south=e,this.east=n,this.north=r}static contains(t,e){let n=e[0];const r=e[1],i=t.west;let s=t.east;return s<i&&(s+=bi,n<0&&(n+=bi)),(n>i||De(n,i,1e-14))&&(n<s||De(n,s,1e-14))&&r>=t.south&&r<=t.north}static southwest(t,e){return e[0]=t.west,e[1]=t.south,e[2]=0,e}static northeast(t,e){return e[0]=t.east,e[1]=t.north,e[2]=0,e}static southeast(t,e){return e[0]=t.east,e[1]=t.south,e[2]=0,e}static northwest(t,e){return e[0]=t.west,e[1]=t.north,e[2]=0,e}}const vi=[0,0,1];function wi(t,e){return Ae(e,t[0],t[1],t[2])}class Ti{constructor(t,e){this.normal=n.vec3.copy([],t),this.distance=e}static fromPointNormal(t,e,r){const i=-n.vec3.dot(e,t);return n.vec3.copy(r.normal,e),r.distance=i,r}}const Mi=[],_i=[],Oi=[],Ai=[],xi=[],Ii=[],Si=[],Ci=[],ki=[],Ni=[],Li=new Ti([1,0,0],0),Ei=[];class Ri{constructor(t){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new gi(...t),this.minimumHeight=t[4],this.maximumHeight=t[5],this.computeBox(this.rectangle)}distanceToCamera(t,e){let r=0;if(!gi.contains(this.rectangle,e)){const e=this.southwestCornerCartesian,i=this.northeastCornerCartesian,s=this.westNormal,o=this.southNormal,a=this.eastNormal,c=this.northNormal,l=n.vec3.subtract(Ei,t,e),u=n.vec3.dot(l,s),h=n.vec3.dot(l,o),f=n.vec3.subtract(Ei,t,i),d=n.vec3.dot(f,a),m=n.vec3.dot(f,c);u>0?r+=u*u:d>0&&(r+=d*d),h>0?r+=h*h:m>0&&(r+=m*m)}const i=e[2],s=this.minimumHeight,o=this.maximumHeight;if(i>o){const t=i-o;r+=t*t}else if(i<s){const t=s-i;r+=t*t}return Math.sqrt(r)}computeBox(t){const e=this;wi(gi.southwest(t,_i),e.southwestCornerCartesian),wi(gi.northeast(t,_i),e.northeastCornerCartesian),Mi[0]=t.west,Mi[1]=.5*(t.south+t.north),Mi[2]=0;const r=wi(Mi,Oi),i=n.vec3.cross(xi,r,vi);n.vec3.normalize(e.westNormal,i),Mi[0]=t.east;const s=wi(Mi,Ci),o=n.vec3.cross(xi,vi,s);n.vec3.normalize(e.eastNormal,o);const a=n.vec3.subtract(xi,r,s),c=n.vec3.normalize(Ai,a),l=t.south;let u;if(l>0){Mi[0]=.5*(t.west+t.east),Mi[1]=l;const r=wi(Mi,ki);n.vec3.copy(Ni,c);const i=Ti.fromPointNormal(e.southwestCornerCartesian,e.westNormal,Li);Pi(ki,Ni,i,e.southwestCornerCartesian),u=Be(r,Ii)}else u=Fe(gi.southeast(t,_i),Ii);const h=n.vec3.cross(Si,u,a);n.vec3.normalize(e.southNormal,h);const f=t.north;let d;if(f<0){Mi[0]=.5*(t.west+t.east),Mi[1]=f;const r=wi(Mi,ki);n.vec3.scale(Ni,c,-1);const i=Ti.fromPointNormal(e.northeastCornerCartesian,e.eastNormal,Li);Pi(ki,Ni,i,e.northeastCornerCartesian),d=Be(r,Ii)}else d=Fe(gi.northwest(t,_i),Ii);const m=n.vec3.cross(Si,a,d);n.vec3.normalize(e.northNormal,m)}}function Pi(t,e,r,i){const s=t,o=e,a=r.normal,c=n.vec3.dot(a,o);if(Math.abs(c)<1e-15)return;const l=(-r.distance-n.vec3.dot(a,s))/c;return l<0?void 0:(i=n.vec3.scale(i,o,l),n.vec3.add(i,s,i))}function Ui(t){return[t.xmin,t.ymin,t.xmax,t.ymax]}const Bi=i.BBOXUtil,Fi={"services":[],"maxGPUMemory":i.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},Gi=[0,0,0],Di=[0,0,0],ji=[0,0,0],zi=[0,0,0],Hi=[0,0,0],qi=[0,0,0],$i=[0,0,0],Vi=[1,1,1],Ji=[1,1,1],Yi=[0,0,0,0],Zi=[],Ki=new i.Coordinate(0,0),Xi=new i.Point(0,0),Wi=[0,0,0,0,0,0,0,0,0],Qi=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ts=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],es=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ns=new i.Point(0,0),rs=n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),is=[0,0],ss=[0,0,0],os=[1,1,1],as=[0,0,0],cs=[0,0,0],ls=[0,0,0,0],us=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class hs extends(n.MaskLayerMixin(i.Layer)){static fromJSON(t){return t&&"Geo3DTilesLayer"===t.type?new hs(t.id,t.options):null}static getEnuTransform(t,e=[1,1,1],r=[0,0,0]){const i=Ae([],t[0]*Math.PI/180,t[1]*Math.PI/180,t[2]||0),s=fn(i,null,[]),o=n.quat.fromEuler([0,0,0,0],...r),a=n.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],o,[0,0,0],e);return n.mat4.multiply(a,s,a)}constructor(t,e){super(t,e),this.isGeo3DTilesLayer=!0,this.Ke(),this.Xe=new Map}Ke(){const t=this.options.services.map((t=>t.url));this.We=this.We||{},this.Pe=this.Pe||[];for(let e=0;e<t.length;e++){const n=t[e];let r=this.We[n];void 0===r&&(r=this.We[n]=this.Pe.length),this.Pe[r]=ms(n,r,this.options.services[e])}this.fire("rootready",{roots:this.Pe.slice(0)})}showService(t){return this.updateService(t,{visible:!0}),this}hideService(t){return this.updateService(t,{visible:!1}),this}setToRedraw(){return this.Qe(),this}addService(t){return this.options.services=this.options.services||[],this.options.services.push(t),this.Ke(),this.Qe(),this}updateService(t,e){if(!e)return this;const n=this.options.services;let r=!1;n&&n[t]&&(r=!(bs(n[t].coordOffset,e.coordOffset)&&bs(n[t].heightOffset,e.heightOffset)&&bs(n[t].scale,e.scale)&&bs(n[t].rotation,e.rotation)),yt(n[t],e));const i=n[t].url,s=this.We[i],o=this.Pe&&this.Pe[s];return o&&(pt(e.visible)||(o.visible=e.visible),r&&o.version++),this.Qe(),this}removeService(t){const e=this.options.services;if(e&&e[t]){const n=e[t].url,r=this.We[n];this.Pe[r]&&(this.Pe[r]=null),delete this.We[n],e.splice(t,1)}return this.Qe(),this}getTileUrl(t,e){const n=e&&e.service&&e.service.subdomains;if(n&&e.domainKey){const r=n.length;if(r){const i=[...t].reduce(((t,e)=>t+e.charCodeAt(0)),0)%r;return t.replace(e.domainKey,n[i])}}return t}getExtent(t){if(!t&&0!==t){const t=new i.Extent;for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(n&&n.boundingVolume){const e=this.boundingVolumeToExtent(n);t._combine(e)}}return t}const e=this.Pe[t];return e&&e.boundingVolume?this.boundingVolumeToExtent(e):null}boundingVolumeToExtent(t){const e=t.boundingVolume.tn?rs:t.matrix,r=this.getMap(),s="identity"===r.getProjection().code.toLowerCase(),o=this.getRenderer();if(t.boundingVolume.region){const e=t.boundingVolume.region;return new i.Extent(Tt(e[0]),Tt(e[1]),Tt(e[2]),Tt(e[3]))}if(t.boundingVolume.sphere){const a=t.boundingVolume.sphere,c=Ne([],n.vec3.transformMat4([0,0,0],a,e));s&&o.Je(c,c);const l=a[3],u=r.locate(c,-l,l),h=r.locate(c,l,-l);return new i.Extent(u,h)}if(t.boundingVolume.box){const a=t.boundingVolume.box,c=n.vec3.transformMat4([0,0,0],a,e),l=new i.Coordinate(Ne([],c));s&&o.Je(l,l);const u=a.slice(3);n.mat3.multiply(u,n.mat3.fromMat4([0,0,0,0,0,0,0,0,0],t.matrix),u);const h=n.vec3.length(u.slice(0,3)),f=n.vec3.length(u.slice(3,6)),d=n.vec3.length(u.slice(6,9)),m=Math.max(h,f,d),p=r.locate(l,-m,m),y=r.locate(l,m,-m);return new i.Extent(p,y)}return null}getRootTiles(){return this.Pe}getTiles(){const t=this.getRenderer();if(!t.ready)return this.Qe(),{tiles:Zi};const e=this.getMap(),r=e.cameraPosition,i=e.pointAtResToDistance(r[2],0,e.getGLRes()),s=this.nn(r);this.rn=this.rn||[0,0,0],n.vec3.set(this.rn,wt(s.x),wt(s.y),i),this.sn=Ae(this.sn||[],this.rn[0],this.rn[1],this.rn[2]),this.an=2*Math.tan(.5*wt(e.getFov()));const o=e.projViewMatrix;let a;if(e.getPitch()<=80){const t=e.getExtent(),n=t.getWidth()/2,r=t.getHeight()/2;t.xmin-=n,t.ymin-=r,t.xmax+=n,t.ymax+=r,a=Ui(t)}const c=(this.getMasks()||[]).filter((t=>t&&t instanceof n.ClipOutsideMask));c.forEach((t=>{if(!t.maskGeoJSON&&t.toGeoJSON)try{t.maskGeoJSON=t.toGeoJSON();const e=t.getExtent();t.maskGeoJSON.bbox=Ui(e)}catch(t){console.error(t)}}));const l={children:[],level:-1};let u=l;const h=[];for(let e=0;e<this.Pe.length;e++){const n=this.Pe[e];if(!n||!n.visible)continue;const r=n.service,i=[n],s=this.cn(e);for(;i.length>0;){const e=i.pop();for(e.id||this.ln(e);u.level>=e.ke;)u=u.parent;const n=this.un(e,s,o,a,c);if(e.service=r,!(n===gs.VISIBLE||n!==gs.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&ys(e))){let t=u;for(;t&&!t.content;)t=t.parent;n===gs.SCREEN_ERROR_TOO_SMALL&&t&&t.content&&this.hn(h,t);continue}e.ft<1/0&&this.dn(e);const l=this.Ne(e,u);u.children.push(l);const f=e.children,d=f&&f.length,m=l.content;if(m&&(!d||n===gs.SCREEN_ERROR_TOO_SMALL)&&this.hn(h,l),n!==gs.SCREEN_ERROR_TOO_SMALL&&d){m&&"add"===e.refine&&this.hn(h,l),u=l;const n=f[0].parent;let r=!1;for(let s=0,o=f.length;s<o;s++){if(n){const e=t.getCachedTile(f[s].id);if(e&&e.error&&404!==e.error.status)continue;r=!0}else{r=!0,f[s].parent=e,f[s].xt=e.xt,f[s].baseUrl=e.baseUrl;const t=f[s].content&&(f[s].content.url||f[s].content.uri);t&&(Ct(t)||t.indexOf("i3s:")>=0?f[s].baseUrl=e.baseUrl:Pt(t)?f[s].content.url=e.baseUrl+t:f[s].baseUrl=t.substring(0,t.lastIndexOf("/")+1))}i.push(f[s])}!r&&m&&this.hn(h,l)}}}return{root:l,tiles:h}}hn(t,e){const{viewerRequestVolume:n,matrix:r}=e.node;n&&!function(t,e,n,r){if(n.region){const e=n.region;if(t[0]>=e[0]&&t[0]<=e[2]&&t[1]>=e[1]&&t[1]<=e[3])return!0}else{if(n.sphere)return fs(n,e,r)<=0;if(n.box)return 0===ds(n,e,r)}return!1}(this.rn,this.sn,n,r)||t.push(e)}Ne(t,e){return{id:t.id,node:t,children:[],level:t.ke,parent:e,content:t.content&&t.content.url}}ln(t){const e=this.getId();t.id=e+":"+i.Util.GUID(),t.matrix=t.transform||n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),t.mn=this.pn(t),t.parent&&(function(t){return t.content&&t.content.uri&&t.content.uri.indexOf("i3s:")>=0}(t)||(t.matrix=n.mat4.multiply(t.matrix,t.parent.matrix,t.matrix)),t.H=t.parent.H,void 0===t.ke&&(t.ke=t.parent.ke+1),t.maxExtent=t.parent.maxExtent),t.refine=t.refine&&t.refine.toLowerCase()||"replace",t.content&&!t.content.url&&t.content.uri&&(t.content.url=t.content.uri)}j(t){return this.Pe[t].service}yn(t){const e=t.boundingVolume;if(!e||e.tn&&!this.bn(t))return;const r=this.j(t.H),i=r.heightOffset||0,s=this.options.offset,o=bt(s)||s[0]||s[1],a=r.coordOffset||is;if(!Array.isArray(a))throw new Error("service.coordOffset must be an array");if(!e.tn&&(!t.boundingVolume||!i&&0!==i&&n.mat4.exactEquals(t.matrix,rs)&&!o&&a===is))return;e.box&&e.region&&delete e.region;const{region:c,box:l,sphere:u}=e;if(e.coordOffset=[a[0],a[1]],e.heightOffset=i,c){e.originalVolume||(e.originalVolume=c.slice(0));const t=e.originalVolume,n=this.gn([Tt(t[0]),Tt(t[1])]);c[0]=wt(n.x+a[0]),c[1]=wt(n.y+a[1]);const r=this.gn([Tt(t[2]),Tt(t[3])]);c[2]=wt(r.x+a[0]),c[3]=wt(r.y+a[1]),c[4]=t[4]+i+(a[2]||0),c[5]=t[5]+i+(a[2]||0)}else if(l||u){e.originalVolume||(e.originalVolume=(l||u).slice(0));const r=l||u,s=e.originalVolume,o=n.vec3.transformMat4(Gi,s,t.matrix),c=Ne(Di,o),h=this.gn([c[0]+a[0],c[1]+a[1]]);c[0]=h.x,c[1]=h.y,c[2]+=i+(a[2]||0),Ae(r,wt(c[0]),wt(c[1]),c[2])}e.tn=!0;try{t.extent=this.boundingVolumeToExtent(t)}catch(t){console.error(t)}}bn(t){const e=t.boundingVolume,n=this.j(t.H),r=n.heightOffset||0,i=n.coordOffset||is;return e.coordOffset[0]!==i[0]||e.coordOffset[1]!==i[1]||e.heightOffset!==r}pn(t){return void 0===t.geometricError||!t.boundingVolume}dn(t){let e=t.parent;for(;e&&e.mn&&!(e.ft<=t.ft);)e.ft=t.ft,e=t.parent}onTileLoad(t,e){if(t.children&&(!e.children||!e.children.length)){e.children=t.children;const n=e.content.url;e.baseUrl=n.substring(0,n.lastIndexOf("/")+1),this.Qe()}}onTilesetLoad(t,e,r){if(!t)return void console.warn("invalid tileset at : "+r);const i=(t.asset&&t.asset.gltfUpAxis||e&&e.xt||"Y").toUpperCase();t.root.baseUrl=r.substring(0,r.lastIndexOf("/")+1);const s=r.indexOf("realspace/")>-1;0===e.ke&&t.asset&&t.asset.s3mType&&s&&(t.root.baseUrl+="data/path/");const o=t.asset.i3s;if(t.root.xt=i,e){const r=e.boundingVolume,i=e.vn;i&&delete e.vn,yt(e,t.root),e.refine=e.refine&&e.refine.toLowerCase()||"replace",r&&(e.boundingVolume=r);let s=t.root.transform;if(i){const t=this.j(e.H);t.ecefTransform&&(s=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.ecefTransform,s||rs))}s&&(e.parent?o||(e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.parent.matrix,s)):e.matrix=n.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.matrix,s)),delete e.content,t.root.content&&(e.content=t.root.content),e.mn=this.pn(e);const a=e.content&&(e.content.url||e.content.uri);a&&e.content.uri&&(e.content.url=e.content.uri,delete e.content.uri),!o&&a&&!Ct(a)&&Pt(a)&&(e.content.url=e.baseUrl+a),t.root&&!e.parent&&this.wn(e)}this.Qe(),this.fire("loadtileset",{tileset:t,index:e&&e.H,url:r})}Tn(t,e,n){if(!t.extent||!Bi)return!0;const r=t.extent;if(ls[0]=r.xmin,ls[1]=r.ymin,ls[2]=r.xmax,ls[3]=r.ymax,e){if(!Bi.bboxIntersect(ls,e))return!1}if(n.length){for(let t=0,e=n.length;t<e;t++){const e=n[t].maskGeoJSON;if(!e||!e.bbox||Bi.bboxInMask(ls,e))return!0}return!1}return!0}un(t,e,n,r,i){if(t.ft=1/0,0===t.ke||t.mn)return this.wn(t),gs.VISIBLE;if(this.yn(t),!this.Tn(t,r,i))return gs.OUT_OF_FRUSTUM;if(!this.Mn(t,e,n))return gs.OUT_OF_FRUSTUM;if(0===t.geometricError)return gs.VISIBLE;let s=this.j(t.H).maximumScreenSpaceError;null==s&&(s=16);let o=this._n(t);return 0===o&&t.parent&&(o=.5*(t.parent.On||0)),o>=s?gs.VISIBLE:gs.SCREEN_ERROR_TOO_SMALL}Kt(t,e){e||(e=new i.Point(0,0));const n=this.getMap();return n.coordToPointAtRes(t,n.getGLRes(),e)}Mn(t,e,n){const r=this.getRenderer(),i=t.id,{boundingVolume:s}=t,o=s.sphere,a=this.An(t);this.j(t.H).debug&&(this.Xe.get(i).node=t,r.Ft(t));const l=a.obbox;return l?function(t,e,n){M(t);for(var r=0;r<6;r++)if(!T(c[r],e))return!1;return!0}(n,l):!!o&&function(t,e,n){M(t);for(var r=e[0],i=-e[1],s=0;s<6;s++)if(O(c[s],r)<i)return!1;return!0}(n,a.sphereBox)}An(t){const e=t.id;let n=this.Xe.get(e);const{boundingVolume:r}=t,i=r.region,s=r.box,o=r.sphere,a=this.xn(t.H);if((!n||n.version!==a.version)&&(i?n=this.In(t):s?n=this.Sn(t):o&&(n=this.Cn(t)),n&&this.Xe.set(e,n),n.version=a.version,t.dt)){this.getRenderer().Dt(t.dt),delete t.dt}return n}In(t){const e=this.getMap(),r=e.getGLRes(),s=t.boundingVolume.region;let{ws:o,en:a}=function(t){const e=t[0],n=t[1],r=t[2],i=t[3],s=t[4],o=t[5],a=Ae([],e,n,s),c=Ae([],r,i,o),l=Ne(a,a),u=Ne(c,c);return{ws:l,en:u}}(s);o=new i.Coordinate(o),a=new i.Coordinate(a);const c=e.coordToPointAtRes(o,r);c.z=e.altitudeToPoint(o.z,r);const l=e.coordToPointAtRes(a,r);l.z=e.altitudeToPoint(a.z,r);const u=[l.x,c.y,l.z,l.x,l.y,l.z,c.x,l.y,l.z,c.x,c.y,l.z,l.x,c.y,c.z,l.x,l.y,c.z,c.x,l.y,c.z,c.x,c.y,c.z],h=[(u[0]+u[18])/2,(u[1]+u[19])/2,(u[2]+u[20])/2],f=this.xn(t.H);t!==f||f.kn||(f.kn=h);const d=this.Jt([],t),m=n.mat4.exactEquals(rs,d);if(!m){n.vec3.transformMat4(h,h,d);const t=Gi;for(let e=0;e<u.length;e+=3){let r=n.vec3.set(t,u[e],u[e+1],u[e+2]);m||(r=n.vec3.transformMat4(r,r,d)),u[e]=r[0],u[e+1]=r[1],u[e+2]=r[2]}}const p=e.pointAtResToCoord(new i.Point(h),r);p.z=(o.z+a.z)/2;const y=this.Nn(u,h);for(let t=0;t<u.length;t++)u[t]-=h[t%3];return{obbox:y,boxPosition:u,boxCenter:h,boxCoord:p}}Sn(t){const e=this.getRenderer(),r=this.getMap(),i="identity"===r.getProjection().code.toLowerCase(),s=r.getGLRes(),{boxCenter:o,boxCoord:a}=this.Ln(t),c=t.boundingVolume.box,l=function(t,e,n){return function(t,e,n,r,i,s,o,a,c,l,u,h,f,d,m,p,y){return t[0]=e||0,t[1]=s||0,t[2]=l||0,t[3]=0,t[4]=n||0,t[5]=o||0,t[6]=u||0,t[7]=0,t[8]=r||0,t[9]=a||0,t[10]=h||0,t[11]=0,t[12]=i||0,t[13]=c||0,t[14]=f||0,t[15]=y,t}(t,e[0],e[3],e[6],n[0],e[1],e[4],e[7],n[1],e[2],e[5],e[8],n[2],0,0,0,1)}([],this.En(c,t.matrix),c),u=this.Jt([],t),h=n.mat4.exactEquals(rs,u);h||n.vec3.transformMat4(o,o,u);const f=[],d=Gi;for(let t=0;t<us.length;t+=3){d[0]=us[t],d[1]=us[t+1],d[2]=us[t+2],n.vec3.transformMat4(d,d,l),Ne(d,d),i&&e.Je(d,d);const o=Ki.set(d[0],d[1],d[2]);r.coordToPointAtRes(o,s,Xi);let a=n.vec3.set(d,Xi.x,Xi.y,r.altitudeToPoint(o.z,s));h||(a=n.vec3.transformMat4(a,a,u)),f[t]=a[0],f[t+1]=a[1],f[t+2]=a[2]}const m=this.Nn(f,o);for(let t=0;t<f.length;t++)f[t]-=o[t%3];return{obbox:m,boxPosition:f,boxCenter:o,boxCoord:a}}Cn(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=t.boundingVolume.sphere,o=s;let a=Gi;0===o[0]&&0===o[1]&&0===o[2]?a=[0,0,-6378137]:Ne(a,o),r&&n.Je(a,a);const c=new i.Coordinate(a),l=this.Kt(c,Xi).toArray();l[2]=e.altitudeToPoint(c.z,e.getGLRes());const u=this.Rn(c);return{boxCenter:l,boxCoord:c,sphereBox:[l,s[3]*u[2]]}}Nn(t,e){const r=ps(Hi,t,0,1,4,5),i=ps(qi,t,0,3,4,7),s=ps($i,t,0,1,2,3);return[...e,...n.vec3.sub(Gi,r,e),...n.vec3.sub(Di,i,e),...n.vec3.sub(ji,s,e)]}Ln(t){const e=this.getMap(),n=this.getRenderer(),r="identity"===e.getProjection().code.toLowerCase(),s=e.getGLRes(),o=t.boundingVolume.box.slice(0,3);Ne(o,o),r&&n.Je(o,o);const a=new i.Coordinate(o),c=e.coordToPointAtRes(a,s);return{boxCenter:[c.x,c.y,e.altitudeToPoint(a.z,s)],boxCoord:a}}Jt(t,e){const r=this.xn(e.H),i=this.j(e.H),s=r.kn,o=n.mat4.fromTranslation(Qi,n.vec3.set(Gi,-s[0],-s[1],-s[2])),a=n.mat4.fromTranslation(ts,s),c=i.rotation||ss,l=n.quat.fromEuler(Yi,...c),u=i.scale;let h;h=Array.isArray(u)?n.vec3.set(as,u[0],u[1],u[2]):u&&n.vec3.set(as,u,u,u)||os;const f=n.mat4.fromRotationTranslationScale(es,l,cs,h);return t=n.mat4.multiply(t,f,o),n.mat4.multiply(t,a,t)}wn(t){const e=this.j(t.H);if(!t.boundingVolume||this.Pn(t,e))return;const n=t.boundingVolume.box,r=t.boundingVolume.region,i=t.boundingVolume.sphere;let s=null;n?s=this.Un(t).boxCenter:r?s=this.Bn(t).boxCenter:i&&(s=this.Cn(t).boxCenter);const o=e.heightOffset||0,a=e.coordOffset||[0,0];t.Fn=[a[0]||0,a[1]||0],t.Gn=o,t.kn=s}Pn(t,e){if(!t.Fn)return!1;const n=e.coordOffset||is;return t.Fn[0]===n[0]&&t.Fn[1]===n[1]&&t.Gn===(e.heightOffset||0)}Bn(t){return this.yn(t),this.In(t)}Un(t){return this.yn(t),this.Ln(t)}En(t,e){let r=t.slice(3,12);const i=n.mat3.fromMat4(Wi,e);return r=n.mat3.multiply(r,i,r),r}Rn(t){const e=this.getMap(),r=e.distanceToPointAtRes(100,100,e.getGLRes(),t);let i;return i=e.altitudeToPoint?e.altitudeToPoint(100,e.getGLRes())/100:r.y/100,n.vec3.set(Vi,r.x/100*1.01,r.y/100*1.01,i),Vi}gn(t){Array.isArray(t)&&(t=new i.Coordinate(t));let e=this.options.offset;if(bt(e)&&(e=e.call(this,Array.isArray(t)?new i.Coordinate(t):t)),e[0]||e[1]){const n=this.getMap(),r=n.getGLRes(),i=n.coordToPointAtRes(t,r);return Xi.set(e[0],e[1]),i._sub(Xi),n.pointAtResToCoord(i,r)}return t}xn(t){return this.Pe[t]}cn(t){const e=this.j(t).maxExtent;if(!e)return null;const n=this.Pe[t];return n.maxExtent||(n.maxExtent=new i.Extent(e).convertTo((t=>this.Kt(t)))),n.maxExtent}_n(t){const e=this.an,r=t.geometricError;if(0===r)return t.On=0,0;const i=this.j(t.H);let s=i.scale||1;if(Array.isArray(s)&&(s=n.vec3.length(s)),i.ecefTransform){const t=n.mat4.getScaling(Ji,i.ecefTransform);s*=n.vec3.len(t)}const o=this.getMap();let a;t.boundingVolume.region?a=function(t,e,n){t.Dn||(t.Dn=new Ri(t.boundingVolume.region));return t.Dn.distanceToCamera(e,n)}(t,this.sn,this.rn):t.boundingVolume.sphere?a=fs(t.boundingVolume,this.sn):t.boundingVolume.box&&(a=ds(t.boundingVolume,this.sn));const c=Math.max(Math.abs(a),1e-7),l=r*s*o.height/(c*e);return t.ft=a,t.On=l,l}Qe(){const t=this.getRenderer();t&&t.setToRedraw()}Gt(t){return this.Xe.get(t)}identify(t,e={}){const n=this.getMap(),r=this.getRenderer();if(!n||!r)return[];Array.isArray(t)&&(t=new i.Coordinate(t));const s=n.coordToContainerPoint(t);return this.identifyAtPoint(s,e)}identifyAtPoint(t,e={}){const n=[];if(!e.excludeMasks){const r=this.identifyMask(t,e);r&&r.length&&Nt(n,r)}const r=this.getMap(),i=this.getRenderer();if(!r||!i)return[];const s=r.getDevicePixelRatio();return Nt(n,i.pick(t.x*s,t.y*s,e)),e&&e.filter&&!e.excludeMasks?n.filter((t=>e.filter(t))):n}getCurrentBatchIDs(){const t=this.getMap(),e=this.getRenderer();return t&&e?e.Wt():[]}highlight(t){const e=this.getRenderer();return Array.isArray(t)||(t=[t]),e?(e.highlight(t),this):(this.J||(this.J=[]),this.J.push(t),this)}ze(){if(this.J){for(let t=0;t<this.J.length;t++)this.highlight(this.J[t]);delete this.J}}cancelHighlight(t,e){const n=this.getRenderer();return n?(n.cancelHighlight(t,e),this):this}cancelAllHighlight(){const t=this.getRenderer();return t?(t.cancelAllHighlight(),this):this}showOnly(t){const e=this.getRenderer();return e?(e.showOnly(t),this):(this.Z||(this.Z=[]),this.Z.push(t),this)}jn(){if(this.Z){for(let t=0;t<this.Z.length;t++)this.showOnly(this.Z[t]);delete this.Z}}cancelShowOnly(t){const e=this.getRenderer();return e?(e.cancelShowOnly(t),this):this}setServiceOpacity(t,e){const n=this.options.services[t];n&&(n.opacity=e);return this.getRenderer()?(this.Qe(),this):this}setServiceDebug(t,e){const n=this.options.services[t];n&&(n.debug=e);return this.getRenderer()?(this.Qe(),this):this}nn(t){const e=this.getMap(),n=e.getGLRes();ns.set(t[0],t[1]);const r=e.pointAtResToCoord(ns,n);return"identity"===e.getProjection().code.toLowerCase()?(Di[0]=r.x,Di[1]=r.y,this.getRenderer().Ye(Gi,Di),r.set(Gi[0],Gi[1]),r):r}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function fs(t,e,r){let i=t.sphere;r&&(i=n.vec3.transformMat4([0,0,0],i,r));const s=n.vec3.dist(i,e),o=t.sphere[3];return s<o?0:s-o}function ds(t,e,r){const i=t.box;let s=n.vec3.set(Gi,i[0],i[1],i[2]);r&&(s=n.vec3.transformMat4([0,0,0],s,r));return hi(s,n.mat3.set(Wi,i[3],i[4],i[5],i[6],i[7],i[8],i[9],i[10],i[11]),e)}function ms(t,e,r){const i=(t=Mt(t)).indexOf("{s}")>=0?"{s}":t.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,mn:!0,service:r,visible:!!pt(r.visible)||r.visible,baseUrl:t.substring(0,t.lastIndexOf("/"))+"/",content:{url:t},refine:"replace",matrix:n.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),H:e,ke:0,vn:!0,domainKey:i}}function ps(t,e,r,i,s,o){const a=n.vec3.set(Gi,e[3*r],e[3*r+1],e[3*r+2]),c=n.vec3.set(Di,e[3*i],e[3*i+1],e[3*i+2]),l=n.vec3.set(ji,e[3*s],e[3*s+1],e[3*s+2]),u=n.vec3.set(zi,e[3*o],e[3*o+1],e[3*o+2]);return t[0]=(a[0]+c[0]+l[0]+u[0])/4,t[1]=(a[1]+c[1]+l[1]+u[1])/4,t[2]=(a[2]+c[2]+l[2]+u[2])/4,t}function ys(t){if(!t.content||t.hasParentContent)return!1;let e=t.parent;if(e&&(e.content||e.hasParentContent))return t.hasParentContent||(t.hasParentContent=!0),!1;for(;e;){if(e.content||e.hasParentContent)return t.hasParentContent||(t.hasParentContent=!0),!1;e=e.parent}return!0}function bs(t,e){return Array.isArray(t)&&Array.isArray(e)?2===t.length?n.vec2.exactEquals(t,e):n.vec3.exactEquals(t,e):t===e}var gs;hs.mergeOptions(Fi),hs.registerRenderer("gl",ci),hs.registerRenderer("gpu",ci),hs.registerJSONType("Geo3DTilesLayer"),function(t){t[t.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",t[t.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",t[t.VISIBLE=2]="VISIBLE"}(gs||(gs={}));let vs=null;function ws(){return vs||(vs={"image/crn":Gt.crn&&Gt.crn(),"image/ktx2":Gt.ktx2&&Gt.ktx2(),"image/cttf":Gt.ktx2&&Gt.ktx2(),"draco":Gt.draco&&Gt.draco()}),vs}const{Ajax:Ts,GLTFLoader:Ms}=Dt();class _s{constructor(t,e,n){this.zn=t,this.Hn=e||Ms,this.Re=n,this.qn=ws()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.$n(t,e,n,r,i)):Ts.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.$n(t,i,n,r)}))}$n(t,e,n,r,i){const s=i&&i.maxTextureSize,o=this.Vn(e,n,r,t);if(o.error)return Promise.resolve(o);const a=t.substring(0,t.lastIndexOf("/"));let c;try{c=new this.Hn(a,o.glb,{transferable:!0,requestImage:this.zn,decoders:this.qn,supportedFormats:this.Re,maxTextureSize:s})}catch(t){return Promise.resolve({error:t})}return c.load({skipAttributeTransform:!1}).then((e=>{e.url=`${t}-${n}-${r}`;const i=c.transferables;for(let t=0;t<o.transferables.length;t++)i.indexOf(o.transferables[t])<0&&i.push(o.transferables[t]);return{magic:"b3dm",count:o.count,transferables:i,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,gltf:e}}))}Vn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported b3dm version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in b3dm header is inconsistent with b3dm's byte length, url: "+r;return console.warn(t),{error:t}}let o,a=i.getUint32(12,!0),c=i.getUint32(16,!0),l=i.getUint32(20,!0),u=i.getUint32(24,!0),h=28+e;l>=570425344?(h-=8,o=a,l=c,u=0,a=0,c=0):u>=570425344&&(h-=4,o=l,l=a,u=c,a=0,c=0);const f=[t];let d,m,p;if(a>0?(d=He(t,h,a),h+=a,o=d.BATCH_LENGTH):d={"BATCH_LENGTH":o},c>0&&(h+=c),l>0&&(m=qe(t,h,l),h+=l,u>0)){const e=$e(0,h,u);p=t.slice(e.offset,e.offset+e.byteLength),h+=u,f.push(p)}const y=d.BATCH_LENGTH,b={};if(d&&d.BATCH_ID){b.BATCH_ID=Je(d.BATCH_ID,t,undefined.offset,y);const e=b.BATCH_ID.array&&b.BATCH_ID.array.buffer;e&&f.indexOf(e)<0&&f.push(e)}return{count:o,transferables:f,featureTable:d,batchTable:m,batchTableBin:p,b3dm:b,glb:{buffer:t,byteOffset:h,byteLength:i.byteLength+i.byteOffset-h}}}Jn(){return null}}const{Ajax:Os,GLTFLoader:As}=Dt();class xs{constructor(t,e,n,r){this.zn=t,this.Hn=e||As,this.Re=n,this.qn=ws(),this.Yn=r}load(t,e,n=0,r=0,i){return e?(r||(r=e.byteLength),this.$n(t,e,n,r,i)):Os.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.$n(t,i,n,r)}))}$n(t,e,n,r,i){return this.Zn(t,e,n,r,i).then((({gltf:i,transferables:s})=>{const o=this.Kn(e,n,r,t);if(o.error)return Promise.resolve(o);for(let t=0;t<s.length;t++)-1===o.transferables.indexOf(s[t])&&o.transferables.push(s[t]);return delete i.transferables,Promise.resolve({magic:"i3dm",count:o.count,transferables:o.transferables,featureTable:o.featureTable,batchTable:o.batchTable,batchTableBin:o.batchTableBin,i3dm:o.i3dm,gltf:i})}))}Zn(t,e,n,r,i){const s=i&&i.maxTextureSize,o={transferable:!0,requestImage:this.zn,decoders:this.qn,supportedFormats:this.Re,maxTextureSize:s},a=new DataView(e,n,r),c=32+a.getUint32(12,!0)+a.getUint32(16,!0)+a.getUint32(20,!0)+a.getUint32(24,!0);if(0===a.getUint32(28,!0)){let r=At(new Uint8Array(e,c+n,a.byteLength-c));-1==r.indexOf("://")&&(r=t.substring(0,t.lastIndexOf("/"))+"/"+r);return r.indexOf(".glb")>0?Os.getArrayBuffer(r,{}).then((t=>this.Xn(r,{buffer:t.data,byteOffset:0},o))):Os.getJSON(r,{}).then((t=>this.Xn(r,t,o)))}{const r={buffer:e,byteOffset:c+n,byteLength:a.byteLength-c};return this.Xn(t,r,o)}}Xn(t,e,n){const r=t.substring(0,t.lastIndexOf("/")),i=new this.Hn(r,e,n);return i.load({skipAttributeTransform:!0}).then((n=>{let r=0,s=0;return e.buffer&&(r=e.byteOffset||0,s=e.byteLength||0),n.url=`${t}-${r}-${s}`,{transferables:i.transferables,gltf:n}}))}Kn(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,32+e,o),h={},f=a.INSTANCES_LENGTH;if(a.POSITION){const{byteOffset:e}=a.POSITION;h.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.POSITION.array.buffer)}else if(a.POSITION_QUANTIZED){const e=a.QUANTIZED_VOLUME_OFFSET,n=a.QUANTIZED_VOLUME_SCALE,{byteOffset:r}=a.POSITION_QUANTIZED;h.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Wn(new Uint16Array(t,r+c.offset,3*f),e,n)},o.push(h.POSITION.array.buffer)}if(a.BATCH_ID){h.BATCH_ID=Je(a.BATCH_ID,t,c.offset,f);const e=h.BATCH_ID.array&&h.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}if(a.NORMAL_UP){let{byteOffset:e}=a.NORMAL_UP;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.NORMAL_RIGHT.array.buffer)}else if(a.NORMAL_UP_OCT32P){let{byteOffset:e}=a.NORMAL_UP_OCT32P;h.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Qn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_UP.array.buffer),e=a.NORMAL_RIGHT_OCT32P.byteOffset,h.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this.Qn(new Uint16Array(t,e+c.offset,2*f))},o.push(h.NORMAL_RIGHT.array.buffer)}if(a.SCALE){const{byteOffset:e}=a.SCALE;h.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,f).slice()},o.push(h.SCALE.array.buffer)}else if(a.SCALE_NON_UNIFORM){const{byteOffset:e}=a.SCALE_NON_UNIFORM;h.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(t,e+c.offset,3*f).slice()},o.push(h.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:l,batchTableBin:u,featureTable:a,i3dm:h,transferables:o}}Qn(t){const e=t.length/2,n=new Float32Array(3*e),r=[];for(let i=0;i<e;i++)Is(r,t[2*i],t[2*i+1],65535),n[3*i]=r[0],n[3*i+1]=r[1],n[3*i+2]=r[2];return n}Wn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Jn(){return null}}function Is(t,e,n,r){if(t[0]=Ss(e,r),t[1]=Ss(n,r),t[2]=1-(Math.abs(t[0])+Math.abs(t[1])),t[2]<0){const e=t[0];t[0]=(1-Math.abs(t[1]))*Cs(e),t[1]=(1-Math.abs(e))*Cs(t[1])}return ne(t,t)}function Ss(t,e){return function(t,e,n){return t<e?e:t>n?n:t}(t,0,e=function(t,e){if(null!=t)return t;return e}(e,255))/e*2-1}function Cs(t){return t<0?-1:1}const{Ajax:ks}=Dt();class Ns{constructor(){}load(t,e,n=0,r=0){return e?(r||(r=e.byteLength),this.$n(t,e,n,r)):ks.getArrayBuffer(t,{}).then((e=>{const i=e.data;return r||(r=i.byteLength),this.$n(t,i,n,r)}))}$n(t,e,n,r){return this.tr(e,n,r,t).then((t=>t.error?t:{magic:"pnts",count:t.count,transferables:t.transferables,featureTable:t.featureTable,batchTable:t.batchTable,batchTableBin:t.batchTableBin,pnts:t.pnts}))}tr(t,e,n,r){const i=new DataView(t,e,n),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported pnts version: "+s+", url:"+r;return console.warn(t),{error:t}}if(i.getUint32(8,!0)!==i.byteLength){const t="Length in pnts header is inconsistent with pnts's byte length, url: "+r;return console.warn(t),{error:t}}const o=[t],{featureTable:a,featureTableBin:c,batchTable:l,batchTableBin:u}=en(i,e+28,o),h=a.QUANTIZED_VOLUME_OFFSET,f=a.QUANTIZED_VOLUME_SCALE,d=a.POINTS_LENGTH;let m,p={};if(a.extensions&&a.extensions["3DTILES_draco_point_compression"]){p=a.extensions["3DTILES_draco_point_compression"],m=new DataView(t,p.byteOffset+c.offset,p.byteLength);const e={attributes:p.properties,useUniqueIDs:!1};return this.er||(this.er=ws().draco),this.er(m,e).then((e=>{const n=e.attributes;!a.POSITION&&!a.POSITION_QUANTIZED||n.POSITION||n.POSITION_QUANTIZED||(n.POSITION=a.POSITION,n.POSITION_QUANTIZED=a.POSITION_QUANTIZED),!(a.RGB||a.RGBA||a.RGB565)||n.RGB||n.RGBA||n.RGB565||(n.RGB=a.RGB,n.RGBA=a.RGBA,n.RGB565=a.RGB565),!a.NORMAL&&!a.NORMAL_OCT16P||n.NORMAL||n.NORMAL_OCT16P||(n.NORMAL=a.NORMAL,n.NORMAL_OCT16P=a.NORMAL_OCT16P);const r=this.nr(t,e.attributes,c.offset,d,o,h,f);if(e.attributes.BATCH_ID){const t=e.attributes.BATCH_ID.array;r.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:t.length,componentType:Qe(t.constructor),array:t},o.push(t.buffer)}else if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?r.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):r.BATCH_ID=Ls(d);const e=r.BATCH_ID.array&&r.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return{count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:r,transferables:o}}))}const y=this.nr(t,a,c.offset,d,o,h,f);if(a.BATCH_ID||Object.keys(l).length){a.BATCH_ID?y.BATCH_ID=Je(a.BATCH_ID,t,c.offset,d):y.BATCH_ID=Ls(d);const e=y.BATCH_ID.array&&y.BATCH_ID.array.buffer;e&&o.indexOf(e)<0&&o.push(e)}return Promise.resolve({count:d,batchTable:l,batchTableBin:u,featureTable:a,pnts:y,transferables:o})}nr(t,e,n,r,i,s,o){const a={};if(e.POSITION){let{byteOffset:s,array:o}=e.POSITION;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.POSITION_QUANTIZED){let{byteOffset:c}=e.POSITION_QUANTIZED;const{array:l}=e.POSITION_QUANTIZED;c=c||0;const u=l?0:n;a.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:this.Wn(l||new Uint16Array(t,c+u,3*r),s,o)},i.push(a.POSITION.array.buffer)}if(e.RGBA){let{byteOffset:s,array:o}=e.RGBA;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+4*r);o=new Uint8Array(e)}a.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB){let{byteOffset:s,array:o}=e.RGB;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r);o=new Uint8Array(e)}a.RGB={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5121,array:o},i.push(o.buffer)}else if(e.RGB565){let{byteOffset:s,array:o}=e.RGB565;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint16Array(e)}a.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:r,componentType:5123,array:o},i.push(o.buffer)}if(e.NORMAL){let{byteOffset:s,array:o}=e.NORMAL;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+3*r*4);o=new Float32Array(e)}a.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:r,componentType:5126,array:o},i.push(o.buffer)}else if(e.NORMAL_OCT16P){let{byteOffset:s,array:o}=e.NORMAL_OCT16P;s=s||0;const c=o?0:n;if(!o){const e=t.slice(s+c,s+c+2*r);o=new Uint8Array(e)}a.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:r,componentType:5121,array:o},i.push(o.buffer)}return a}Wn(t,e,n){return tn(new Float32Array(t.length),t,e,n)}Jn(){return null}}function Ls(t){const e=St(t),n=new e(t);for(let e=0;e<t;e++)n[e]=e;return{byteStride:0,byteOffset:0,itemSize:1,count:t,componentType:Qe(e),array:n}}const{Ajax:Es,GLTFLoader:Rs}=Dt();class Ps{constructor(t,e,n,r){this.Re=n,this.zn=t,this.Hn=e||Rs,this.Yn=r}load(t,e,n=0,r=0,i){return e?this.$n(t,e,n,r,i):Es.getArrayBuffer(t,{}).then((e=>{const i=e.data;return this.$n(t,i,n,r)}))}$n(t,e,n,r,i){r||(r=e.byteLength);const s=this.rr(e,t,n,r),o=[];for(let n=0;n<s.length;n++){let r;if("b3dm"===s[n].magic)r=new _s(this.zn,this.Hn,this.Re);else if("i3dm"===s[n].magic)r=new xs(this.zn,this.Hn,this.Re,this.Yn);else if("pnts"===s[n].magic)r=new Ns;else{if("cmpt"!==s[n].magic){console.warn("Unsupported magic in CMPT tile:",s[n].magic);continue}r=new Ps(this.zn,this.Hn,this.Re,this.Yn)}o.push(r.load(t,e,s[n].offset,s[n].byteLength,i).then((t=>t)))}return Promise.all(o).then((t=>({magic:"cmpt",tiles:t})))}rr(t,e,n,r){const i=new DataView(t,n,r),s=i.getUint32(4,!0);if(1!==s){const t="Unsupported cmpt version: "+s+", url:"+e;return console.warn(t),{error:t}}if(16===i.byteLength)return[];const o=[],a=i.getUint32(12,!0);let c=16;for(let e=0;e<a;e++){const e=je(i,c),r=i.getUint32(c+8,!0);o.push({magic:e,buffer:t,offset:c+n,byteLength:r}),c+=r}return o}}if(s.transcoders){const t=i.Map.VERSION;if(t.indexOf("1.0.0-beta")>=0||t.indexOf("1.0.0-alpha")>=0){const t=s.transcoders.inject(a);i.registerWorkerAdapter("@maptalks/3dtiles",t)}else i.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(a)}))}else i.registerWorkerAdapter("@maptalks/3dtiles",a);t.B3DMLoader=_s,t.CMPTLoader=Ps,t.Geo3DTilesLayer=hs,t.Geo3DTilesUtil=Rt,t.Geo3DTransform=Ge,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.124.4")}));
16
+ */function He(){return De().maptalks_gltf_loader}Fe.inject=function(e){const t=e.toString(),r=t.indexOf("{")+1,n=t.substring(0,r),o=Ue.gl_trans__coders=Ue.gl_trans__coders||{};let s=`${n}\n const _____getGlobal = ${De.toString()};\n const g___lobals = _____getGlobal()\n const tran_____scoders = g___lobals['gl_trans__coders'] = g___lobals['gl_trans__coders'] || {};`;for(const e in o)"inject"!==e&&"getTranscoder"!==e&&"registerTranscoder"!==e&&(s+='tran_____scoders["'+e+'"] ='+o[e].toString()+"\n;");return s+="\n("+De().maptalks_gltf_loader_bundle.toString()+")({});\n",s+="\n"+t.substring(n.length),s},Fe.registerTranscoder=function(e,t){Fe[e]=t},Fe.getTranscoder=function(e){return Fe[e]};const Ge="undefined"==typeof document?null:document.createElement("canvas");class je extends o.worker.Actor{constructor(e,t,r){super(e),this.mapId=t,this._supportNPOT=r}initialize(e){e(null)}loadTile(e,t,r){let n=null;t&&t.arraybuffer&&(n=[t.arraybuffer]);const o={mapId:this.mapId,layerId:e,command:"loadTile",params:t};this.send(o,n,r)}abortTileLoading(e,t,r){const n={mapId:this.mapId,layerId:e,command:"abortTileLoading",params:{url:t}};this.broadcast(n,null,r)}addLayer(e,t,r){const n={actorId:this.actorId,mapId:this.mapId,layerId:e,command:"addLayer",params:{options:t}};this.broadcast(n,null,r)}removeLayer(e,t){const r={mapId:this.mapId,layerId:e,command:"removeLayer"};this.broadcast(r,null,t)}requestImage({url:e},t){const r=new Image;r.onload=()=>{if(!this.isActive())return;if(!Ge)return void t(new Error("There is no canvas to draw image!"));const e=this._supportNPOT?r:function(e){if(ze(e.width)&&ze(e.height))return e;let t=e.width,r=e.height;ze(t)||(t=qe(t));ze(r)||(r=qe(r));const n=document.createElement("canvas");n.width=t,n.height=r,n.getContext("2d").drawImage(e,0,0,t,r);const o=e.src,s=o.lastIndexOf("/")+1,a=o.substring(s);return console.warn(`Texture(${a})'s size is not power of two, resize from (${e.width}, ${e.height}) to (${t}, ${r})`),n}(r);Ge.width=e.width,Ge.height=e.height;const n=Ge.getContext("2d",{willReadFrequently:!0});n.drawImage(e,0,0,e.width,e.height);const o=n.getImageData(0,0,e.width,e.height),s={width:e.width,height:e.height,data:new Uint8Array(o.data)};t(null,s,[s.data.buffer])},r.onerror=function(e){t(e)},r.src=e}}function ze(e){return!(e&e-1)&&0!==e}function qe(e){return Math.pow(2,Math.floor(Math.log(e)/Math.LN2))}var Ve=1e-6,Ze="undefined"!=typeof Float32Array?Float32Array:Array;function $e(e,t,r){var n=t[0],o=t[1],s=t[2],a=t[3],i=t[4],l=t[5],c=t[6],h=t[7],u=t[8],f=t[9],d=t[10],p=t[11],g=t[12],m=t[13],_=t[14],b=t[15],y=r[0],T=r[1],v=r[2],M=r[3];return e[0]=y*n+T*i+v*u+M*g,e[1]=y*o+T*l+v*f+M*m,e[2]=y*s+T*c+v*d+M*_,e[3]=y*a+T*h+v*p+M*b,y=r[4],T=r[5],v=r[6],M=r[7],e[4]=y*n+T*i+v*u+M*g,e[5]=y*o+T*l+v*f+M*m,e[6]=y*s+T*c+v*d+M*_,e[7]=y*a+T*h+v*p+M*b,y=r[8],T=r[9],v=r[10],M=r[11],e[8]=y*n+T*i+v*u+M*g,e[9]=y*o+T*l+v*f+M*m,e[10]=y*s+T*c+v*d+M*_,e[11]=y*a+T*h+v*p+M*b,y=r[12],T=r[13],v=r[14],M=r[15],e[12]=y*n+T*i+v*u+M*g,e[13]=y*o+T*l+v*f+M*m,e[14]=y*s+T*c+v*d+M*_,e[15]=y*a+T*h+v*p+M*b,e}function Qe(){var e=new Ze(3);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function We(e){var t=e[0],r=e[1],n=e[2];return Math.hypot(t,r,n)}function Ke(e,t,r){var n=new Ze(3);return n[0]=e,n[1]=t,n[2]=r,n}function Xe(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function Je(e,t,r,n){return e[0]=t,e[1]=r,e[2]=n,e}function Ye(e,t,r){return e[0]=t[0]-r[0],e[1]=t[1]-r[1],e[2]=t[2]-r[2],e}function et(e,t,r){return e[0]=t[0]*r[0],e[1]=t[1]*r[1],e[2]=t[2]*r[2],e}function tt(e,t,r){return e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r,e}function rt(e,t){var r=t[0],n=t[1],o=t[2],s=r*r+n*n+o*o;return s>0&&(s=1/Math.sqrt(s)),e[0]=t[0]*s,e[1]=t[1]*s,e[2]=t[2]*s,e}function nt(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function ot(e,t,r){var n=t[0],o=t[1],s=t[2],a=r[0],i=r[1],l=r[2];return e[0]=o*l-s*i,e[1]=s*a-n*l,e[2]=n*i-o*a,e}Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});var st=Ye,at=et,it=We;function lt(){var e=new Ze(4);return Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}Qe(),function(){var e,t=(e=new Ze(4),Ze!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e)}();var ct;Qe(),Ke(1,0,0),Ke(0,1,0),lt(),lt(),ct=new Ze(9),Ze!=Float32Array&&(ct[1]=0,ct[2]=0,ct[3]=0,ct[5]=0,ct[6]=0,ct[7]=0),ct[0]=1,ct[4]=1,ct[8]=1;const{GLTFLoader:ht}=He();function ut(e,t){if(e.scenes&&e.scenes.length)for(let r=0,n=e.scenes.length;r<n;r++){const n=e.scenes[r].nodes;for(let r=0,o=n.length;r<o;r++){const o=[];bt(n[r],o,e,t)}}}const ft=[],dt=[],pt=[],gt=[0,0,0],mt=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}([]),_t=[1,1,1];function bt(e,t,r,n){const o=t.slice(0);if(e.matrix)o.push(e.matrix);else if(e.rotation||e.translation||e.scale){const t=function(e,t){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=t[0],e[13]=t[1],e[14]=t[2],e[15]=1,e}(ft,e.translation||gt),r=function(e,t){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,i=n+n,l=o+o,c=r*a,h=n*a,u=n*i,f=o*a,d=o*i,p=o*l,g=s*a,m=s*i,_=s*l;return e[0]=1-u-p,e[1]=h+_,e[2]=f-m,e[3]=0,e[4]=h-_,e[5]=1-c-p,e[6]=d+g,e[7]=0,e[8]=f+m,e[9]=d-g,e[10]=1-c-u,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(dt,e.rotation||mt),n=function(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}(pt,e.scale||_t);$e(n,r,n);const s=$e([],t,n);o.push(s)}if(e.children&&e.children.length)for(let t=0,s=e.children.length;t<s;t++)bt(e.children[t],o,r,n);if(void 0!==e.mesh){const t=e.mesh,s=r.meshes[t];if(s){const e=o.slice(0),a=s.primitives;for(let o=0,s=a.length;o<s;o++){const s=a[o];s&&(s.matrices=e,n(s,t,o,r))}}}}function yt(e,t,r){let{byteOffset:n,byteStride:o}=t;const{componentType:s,itemSize:a}=t,i=t.array.buffer,l=s?ht.getTypedArrayCtor(s):t.array.constructor;if(n=void 0===n?t.array.byteOffset:n,o=o||0,!o||o===a*l.BYTES_PER_ELEMENT&&n%l.BYTES_PER_ELEMENT==0){const t=new l(i,n+r*a*l.BYTES_PER_ELEMENT,a);return e.set(t),e}o||(o=a*l.BYTES_PER_ELEMENT);const c=new Uint8Array(i,o*r+n,a*l.BYTES_PER_ELEMENT);return new Uint8Array(e.buffer).set(c),e}function Tt(e,t,r,n){e[4*t]=r[n],e[4*t+1]=r[n+4],e[4*t+2]=r[n+8],e[4*t+3]=r[n+12]}var vt="#include <gl2_vert>\nconst float SHIFT_RIGHT_11 = 1.0 / 2048.0;\nconst float SHIFT_RIGHT_5 = 1.0 / 32.0;\nconst float SHIFT_LEFT_11 = 2048.0;\nconst float SHIFT_LEFT_5 = 32.0;\nconst float NORMALIZE_6 = 1.0 / 64.0;\nconst float NORMALIZE_5 = 1.0 / 32.0;\n#ifdef HAS_POSITION\n attribute vec3 POSITION;\n#endif\n#if defined(HAS_RGB)\n attribute vec3 RGB;\n#elif defined(HAS_RGBA)\n attribute vec4 RGBA;\n#elif defined(HAS_RGB565)\n attribute float RGB565;\n#endif\nuniform vec4 pointColor;\nuniform float pointSize;\nuniform mat4 projViewModelMatrix;\nuniform float pointOpacity;\nvarying vec4 vColor;\n#ifdef HAS_NORMAL\n #ifdef HAS_NORMAL_OCT16P\n attribute vec2 NORMAL_OCT16P;\n float signNotZero(float value) {\n return value >= 0.0 ? 1.0 : -1.0;\n }\n vec2 signNotZero(vec2 value) {\n return vec2(signNotZero(value.x), signNotZero(value.y));\n }\n vec3 octDecode(vec2 encoded, float range) {\n if (encoded.x == 0.0 && encoded.y == 0.0) {\n return vec3(0.0, 0.0, 0.0);\n }\n encoded = encoded / range * 2.0 - 1.0;\n vec3 v = vec3(encoded.x, encoded.y, 1.0 - abs(encoded.x) - abs(encoded.y));\n if (v.z < 0.0) {\n v.xy = (1.0 - abs(v.yx)) * signNotZero(v.xy);\n }\n return normalize(v);\n }\n vec3 octDecode(vec2 encoded) {\n return octDecode(encoded, 255.0);\n }\n #else\n attribute vec3 NORMAL;\n #endif\n uniform vec3 lightDir;\n uniform mat3 modelNormalMatrix;\n uniform mat4 positionMatrix;\n float getLambertDiffuse(vec3 lightDir, vec3 normal) {\n return max(dot(-lightDir, normal), 0.0);\n }\n#endif\n#ifdef PICKING_MODE\n #include <fbo_picking_vert>\n#endif\n#include <draco_decode_vert>\nvoid main() {\n #ifdef HAS_POSITION\n vec3 localPos = decode_getPosition(POSITION);\n #endif\n gl_Position = projViewModelMatrix * vec4(localPos, 1.0);\n gl_PointSize = pointSize;\n #ifdef PICKING_MODE\n fbo_picking_setData(gl_Position.w, true);\n #else\n #if defined(HAS_RGB)\n vColor = vec4(RGB / 255.0, 1.0) * pointOpacity;\n #elif defined(HAS_RGBA)\n vColor = RGBA / 255.0 * pointOpacity;\n #elif defined(HAS_RGB565)\n float compressed = RGB565;\n float r = floor(compressed * SHIFT_RIGHT_11);\n compressed -= r * SHIFT_LEFT_11;\n float g = floor(compressed * SHIFT_RIGHT_5);\n compressed -= g * SHIFT_LEFT_5;\n float b = compressed;\n vec3 rgb = vec3(r * NORMALIZE_5, g * NORMALIZE_6, b * NORMALIZE_5);\n vColor = vec4(rgb, 1.0);\n #else\n vColor = pointColor;\n #endif\n #ifdef HAS_NORMAL\n mat3 positionNormalMatrix = mat3(positionMatrix);\n mat3 normalMatrix = modelNormalMatrix * positionNormalMatrix;\n #ifdef HAS_NORMAL_OCT16P\n vec3 localNormal = octDecode(NORMAL_OCT16P);\n #else\n vec3 localNormal = NORMAL;\n #endif\n vec3 normal = normalize(normalMatrix * localNormal);\n float colorStrength = getLambertDiffuse(lightDir, normal);\n colorStrength = max(colorStrength, 0.5);\n vColor *= colorStrength;\n #endif\n #endif\n}\n";const Mt=new Array(3),wt=new Array(3),xt=[40680631590769,40680631590769,40408299984661.445];function Ot(e,t,r,n){const o=xt,s=Math.cos(r);Mt[0]=s*Math.cos(t),Mt[1]=s*Math.sin(t),Mt[2]=Math.sin(r),Bt(Mt,Mt),et(wt,o,Mt);const a=Math.sqrt(nt(Mt,wt));var i,l,c;return l=wt,c=a,(i=wt)[0]=l[0]/c,i[1]=l[1]/c,i[2]=l[2]/c,tt(Mt,Mt,n),function(e,t,r){return e[0]=t[0]+r[0],e[1]=t[1]+r[1],e[2]=t[2]+r[2],e}(e,wt,Mt)}const St=[1/6378137,1/6378137,1/6356752.314245179],It=[1/40680631590769,1/40680631590769,1/40408299984661.445],At=new Array(3),Ct=new Array(3),Nt=new Array(3);function Rt(e,t){const r=It,n=function(e,t,r,n,o){const s=t[0],a=t[1],i=t[2],l=r[0],c=r[1],h=r[2],u=s*s*l*l,f=a*a*c*c,d=i*i*h*h,p=u+f+d,g=Math.sqrt(1/p),m=tt(Lt,t,g);if(p<o)return isFinite(g)?m:void 0;const _=n[0],b=n[1],y=n[2],T=Et;T[0]=m[0]*_*2,T[1]=m[1]*b*2,T[2]=m[2]*y*2;let v,M,w,x,O,S,I,A,C,N,R,L=(1-g)*kt(t)/(.5*kt(T)),E=0;do{L-=E,w=1/(1+L*_),x=1/(1+L*b),O=1/(1+L*y),S=w*w,I=x*x,A=O*O,C=S*w,N=I*x,R=A*O,v=u*S+f*I+d*A-1,M=u*C*_+f*N*b+d*R*y;E=v/(-2*M)}while(Math.abs(v)>Pt);return e[0]=s*w,e[1]=a*x,e[2]=i*O,e}(At,t,St,r,.1);let o=at(Ct,n,r);o=Bt(o,o);const s=st(Nt,t,n),a=Math.atan2(o[1],o[0]),i=Math.asin(o[2]),l=we(nt(s,t))*kt(s);return e[0]=ve(a),e[1]=ve(i),e[2]=l,e}const Lt=new Array(3),Et=new Array(3),Pt=1e-12;function kt(e){return We(e)}function Bt(e,t){const r=t[0],n=t[1],o=t[2];let s=r*r+n*n+o*o;return s>0&&(s=Math.sqrt(s),e[0]=t[0]/s,e[1]=t[1]/s,e[2]=t[2]/s),e}function Dt(e,t){return et(t,e,It),rt(t,t)}function Ut(e,t){const r=e[0],n=e[1],o=Math.cos(n),s=o*Math.cos(r),a=o*Math.sin(r),i=Math.sin(n);return t.x=s,t.y=a,t.z=i,rt(t,t)}var Ft=Object.freeze({__proto__:null,cartesian3ToDegree:Rt,geodeticSurfaceNormal:Dt,geodeticSurfaceNormalCartographic:Ut,normalizeCartesian:Bt,radianToCartesian3:Ot});function Ht(e,t,r,n){r=r||0,n=n||r;const o=Math.abs(e-t);return o<=n||o<=r*Math.max(Math.abs(e),Math.abs(t))}function Gt(e,t){let r="";for(let n=0;n<4;n++){const o=e.getUint8(t+n);r+=String.fromCharCode(o)}return r}const jt="undefined"!=typeof TextDecoder?new TextDecoder("utf-8"):null;function zt(e,t,r){const n=new Uint8Array(e,t,r);return jt?JSON.parse(jt.decode(n)):JSON.parse(Oe(n))}function qt(e,t,r){const n=new Uint8Array(e,t,r);return jt?JSON.parse(jt.decode(n)):JSON.parse(Oe(n))}function Vt(e,t,r){return{offset:t,byteLength:r}}function Zt(e,t,r,n){const{byteOffset:o,componentType:s,type:a}=e,{ctor:i,type:l}=Jt(s||"UNSIGNED_SHORT"),c=Kt(a);return{byteStride:0,byteOffset:o+r,itemSize:c,count:n*c,componentType:l,array:new i(t,r+o,n*c)}}function $t(e,t,r,n){const o=Zt(e,t,r,n);return o.array.buffer.byteLength!==t.byteLength&&(o.array=o.array.slice()),o}function Qt(e,t,r,n){const{byteOffset:o,componentType:s,type:a}=e,{ctor:i}=Jt(s||"UNSIGNED_SHORT"),l=Kt(a),c=new i(t,o,r*l);return 1===l?c[n]:c.subarray(n*l,n*l+l)}const Wt={"SCALAR":1,"VEC2":2,"VEC3":3,"VEC4":4};function Kt(e){return e?Wt[e]:1}const Xt={"BYTE":{ctor:Int8Array,type:5120,name:"Int8Array"},"UNSIGNED_BYTE":{ctor:Uint8Array,type:5121,name:"Uint8Array"},"SHORT":{ctor:Int16Array,type:5122,name:"Int16Array"},"UNSIGNED_SHORT":{ctor:Uint16Array,type:5123,name:"Uint16Array"},"INT":{ctor:Int32Array,type:5124,name:"Int32Array"},"UNSIGNED_INT":{ctor:Uint32Array,type:5125,name:"Uint32Array"},"FLOAT":{ctor:Float32Array,type:5126,name:"Float32Array"},"DOUBLE":{ctor:Float64Array,type:5126,name:"Float64Array"}};function Jt(e){return Xt[e]}function Yt(e){for(const t in Xt)if(e===Xt[t].ctor)return Xt[t].type;throw new Error("unrecognized ctor:"+e)}function er(e,t,r,n){const o=e,s=t.length/3;for(let e=0;e<s;e++)o[3*e]=t[3*e]/65535*n[0]+r[0],o[3*e+1]=t[3*e+1]/65535*n[1]+r[1],o[3*e+2]=t[3*e+2]/65535*n[2]+r[2];return o}function tr(e,t,r){const n=e.getUint32(12,!0),o=e.getUint32(16,!0),s=e.getUint32(20,!0),a=e.getUint32(24,!0),i=e.buffer;let l,c={},h={},u=null;n>0&&(c=zt(i,t,n),t+=n),o>0&&(l=function(e,t,r){return{offset:t,byteLength:r}}(0,t,o),t+=o),s>0&&(h=qt(i,t,s),t+=s);const f=Vt(0,t,a);return u=i.slice(f.offset,f.offset+f.byteLength),r.push(u),{featureTable:c,featureTableBin:l,batchTable:h,batchTableBin:u}}const rr={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"}},nr={north:[-1,0,0],east:[0,1,0],up:[0,0,1],south:[1,0,0],west:[0,-1,0],down:[0,0,-1]},or={},sr={east:[],north:[],up:[],west:[],south:[],down:[]};let ar=[],ir=[],lr=[];const cr=[0,0,0];function hr(e,t,r){return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=e[15],r}const ur=function(e,t){const r=rr[e][t];let n;const o=e+t;return or[o]?n=or[o]:(n=function(n,o,s){if(i=cr,l=(a=n)[0],c=a[1],h=a[2],u=i[0],f=i[1],d=i[2],Math.abs(l-u)<=Ve*Math.max(1,Math.abs(l),Math.abs(u))&&Math.abs(c-f)<=Ve*Math.max(1,Math.abs(c),Math.abs(f))&&Math.abs(h-d)<=Ve*Math.max(1,Math.abs(h),Math.abs(d)))Xe(ar,nr[e]),Xe(ir,nr[t]),Xe(lr,nr[r]);else if(Ht(n[0],0,1e-14)&&Ht(n[1],0,1e-14)){const o=we(n[2]);Xe(ar,nr[e]),Xe(ir,nr[t]),tt(ir,ir,o),Xe(lr,nr[r]),tt(lr,lr,o)}else{Dt(n,sr.up);const o=sr.up,s=sr.east;s[0]=-n[1],s[1]=n[0],s[2]=0,rt(sr.east,s),ot(sr.north,o,s),tt(sr.down,sr.up,-1),tt(sr.west,sr.east,-1),tt(sr.south,sr.north,-1),ar=sr[e],ir=sr[t],lr=sr[r]}var a,i,l,c,h,u,f,d;return s[0]=ar[0],s[1]=ar[1],s[2]=ar[2],s[3]=0,s[4]=ir[0],s[5]=ir[1],s[6]=ir[2],s[7]=0,s[8]=lr[0],s[9]=lr[1],s[10]=lr[2],s[11]=0,s[12]=n[0],s[13]=n[1],s[14]=n[2],s[15]=1,s},or[o]=n),n}("east","north"),fr=[],dr=[],pr=[],gr=[],mr=[],_r=[],br=[],yr={x:0,y:0},Tr={x:0,y:0},vr=Math.PI/180;let Mr;const wr={width:100,height:10};let xr=!1;try{const e=new OffscreenCanvas(1,1);e.getContext("2d").fillText("hello",0,0),xr=!0}catch(e){xr=!1}function Or(){if(!Mr){const{width:e,height:t}=wr;xr?Mr=new OffscreenCanvas(e,t):(Mr=document.createElement("canvas"),Mr.width=e,Mr.height=t)}return Mr}class Sr{constructor(e,t={}){if(!Array.isArray(e))return void console.error("colors is not array");if(e.length<2)return void console.error("colors.length should >1");this.colors=e;let r=1/0,n=-1/0;for(let t=0,o=e.length;t<o;t++){const o=e[t][0];r=Math.min(o,r),n=Math.max(o,n)}this.min=r,this.max=n,this.valueOffset=this.max-this.min,this.options=Object.assign({},wr,t),this._initImgData()}getImageData(){return this.imgData}_initImgData(){const e=Or(),{width:t,height:r}=this.options;e.width=t,e.height=r;const n=e.getContext("2d");n.clearRect(0,0,e.width,e.height);const o=n.createLinearGradient(0,0,e.width,0),{colors:s,valueOffset:a}=this;for(let e=0,t=s.length;e<t;e++){const[t,r]=s[e],n=(t-this.min)/a;o.addColorStop(n,r)}n.fillStyle=o,n.fillRect(0,0,e.width,e.height),this.imgData=n.getImageData(0,0,e.width,e.height)}getColor(e){e=Math.max(this.min,e);const t=((e=Math.min(e,this.max))-this.min)/this.valueOffset;let r=Math.round(t*this.imgData.width);r=Math.min(r,this.imgData.width-1);const n=4*r;return[this.imgData.data[n],this.imgData.data[n+1],this.imgData.data[n+2],this.imgData.data[n+3]]}}var Ir;function Ar(e){return null==e}function Cr(e){return!Ar(e)}function Nr(e){return""===e}function Rr(e,t){var r,n,o;if(Gr(e)){var s,a=e.stops&&"object"==typeof e.stops[0][0],i=a||Cr(e.property),l=a||!i,c=e.type||t||"exponential";if("exponential"===c)s=Pr;else if("interval"===c)s=Er;else if("categorical"===c)s=Lr;else if("identity"===c)s=Dr;else if("color-interpolate"===c)s=Br;else{if("calculate-expression"!==c)throw new Error('Unknown function type "'+c+'"');s=Ur}if(a){var h={},u=[];for(let t=0;t<e.stops.length;t++){var f=e.stops[t];void 0===h[f[0].zoom]&&(h[f[0].zoom]={zoom:f[0].zoom,type:e.type,property:e.property,default:e.default,stops:[]}),h[f[0].zoom].stops.push([f[0].value,f[1]])}for(let e in h)u.push([h[e].zoom,Rr(h[e])]);r=function(t,r){const n=Pr({stops:u,base:e.base},t)(t,r);return"function"==typeof n?n(t,r):n},n=!1,o=!1}else l?(r=function(t){const r=s(e,t);return"function"==typeof r?r(t):r},n=!0,o=!1):(r=function(t,r){const n=s(e,r?r[e.property]:null);return"function"==typeof n?n(t,r):n},n=!1,o=!0)}else r=function(){return e},n=!0,o=!0;return r.isZoomConstant=o,r.isFeatureConstant=n,r}function Lr(e,t){for(let r=0;r<e.stops.length;r++)if(t===e.stops[r][0])return e.stops[r][1];return e.default}function Er(e,t){for(var r=0;r<e.stops.length&&!(t<e.stops[r][0]);r++);return e.stops[Math.max(r-1,0)][1]}function Pr(e,t){for(var r=Cr(e.base)&&!Nr(e.base)?e.base:1,n=0;!(n>=e.stops.length||t<=e.stops[n][0]);)n++;return 0===n?e.stops[n][1]:n===e.stops.length?e.stops[n-1][1]:Fr(t,r,e.stops[n-1][0],e.stops[n][0],e.stops[n-1][1],e.stops[n][1])}"function"==typeof Map&&(Ir=new Map);const kr={width:100,height:1};function Br(e,t){const r=e.stops;if(r&&r.length>1){let e;if(Ir){const t=JSON.stringify(r);if(!Ir.has(t)){const e=new Sr(r,kr);Ir.set(t,e)}e=Ir.get(t)}else e=new Sr(r,kr);const[n,o,s,a]=e.getColor(t);return[n/255,o/255,s/255,a/255]}return r&&1===r.length?r[0][1]:null}function Dr(e,t){return r=t,n=e.default,Cr(r)?r:Cr(n)?n:Cr(o)?o:null;var r,n,o}function Ur(e,t){const r=String(e.property),n=e.expression,o=t;function s(t){return Ar(t)||Nr(t)||isNaN(t)?e.default:t}if(!Cr(t)||Nr(t)||isNaN(t)||t<0)return s(e.default);{const t=function e(t,r,n){const o=Number(n),s=String(r);return Array.isArray(t)?t.map((t=>e(t,s,o))):t===s?o:t}(n,r,o);return s(function t(r){if(!Array.isArray(r)){if("number"==typeof r)return r;throw new Error("Invalid expression format")}{const n=r[0];if(!["+","-","*","/"].includes(n))throw new Error(`Unknown operator: ${n}`);const o=r.slice(1).map((e=>t(e)));switch(n){case"+":return o.reduce(((e,t)=>e+t),0);case"-":return o.reduce(((e,t)=>e-t));case"*":return o.reduce(((e,t)=>e*t),1);case"/":return o.some((e=>0===e))?e.default:o.reduce(((e,t)=>e/t));default:throw new Error(`Unsupported operator: ${n}`)}}}(t))}}function Fr(e,t,r,n,o,s){return"function"==typeof o?function(){var a=o.apply(void 0,arguments),i=s.apply(void 0,arguments);return Fr(e,t,r,n,a,i)}:o.length?function(e,t,r,n,o,s){var a=[];for(let i=0;i<o.length;i++)a[i]=Hr(e,t,r,n,o[i],s[i]);return a}(e,t,r,n,o,s):Hr(e,t,r,n,o,s)}function Hr(e,t,r,n,o,s){var a,i=n-r,l=e-r;return o*(1-(a=1===t?l/i:(Math.pow(t,l)-1)/(Math.pow(t,i)-1)))+s*a}function Gr(e){return e&&"object"==typeof e&&(e.stops||e.property&&"identity"===e.type||e.expression&&"calculate-expression"===e.type)}function jr(e){return zr(e,"exponential")}function zr(e,t){if(!Gr(e))return function(){return e};let r=!0,n=!0;const o=(e=JSON.parse(JSON.stringify(e))).stops;if(o)for(let e=0;e<o.length;e++)if(Gr(o[e][1])){const s=zr(o[e][1],t);r=r&&s.isZoomConstant,n=n&&s.isFeatureConstant,o[e]=[o[e][0],s]}const s=Rr(e,t);return s.isZoomConstant=r&&s.isZoomConstant,s.isFeatureConstant=n&&s.isFeatureConstant,s}const{getTextureMagFilter:qr,getTextureMinFilter:Vr,getTextureWrap:Zr,getMaterialType:$r,getMaterialFormat:Qr,getPrimitive:Wr,getUniqueREGLBuffer:Kr,getArrayType:Xr}=r.reshader.REGLHelper,Jr=[1,0,0,0,0,0,1,0,0,-1,0,0,0,0,0,1],Yr=[0,0,1,0,0,1,0,0,-1,0,0,0,0,0,0,1],{loginIBLResOnCanvas:en,logoutIBLResOnCanvas:tn,getIBLResOnCanvas:rn,getPBRUniforms:nn}=r.reshader.pbr.PBRUtils,on={factor:0,units:0},sn=[1,1,1,1],an=[0,0,0],ln={specularStrength:0,materialShininess:1},cn=[1,1,1],hn=r.mat4.identity([]),un=[0,0,0],fn=[0,0],dn=[],pn=e=>e.material instanceof r.reshader.PhongMaterial,gn=e=>e.material instanceof r.reshader.pbr.StandardMaterial,mn=[],_n=new o.Coordinate(0,0),bn=new o.Point(0,0),yn=new o.Point(0,0),Tn=new o.Point(0,0),vn=[],Mn=[],wn=[],xn=[],On=[],Sn=[],In=[],An=[],Cn=[],Nn=[],Rn=[],Ln=[],En=[],Pn=[],kn={"POSITION":"POSITION","NORMAL":"NORMAL","TEXCOORD_0":"TEXCOORD_0","TEXCOORD_1":"TEXCOORD_1","COLOR_0":"COLOR_0","TANGENT":"TANGENT","_BATCHID":"_BATCHID"},Bn=[0,1,1,2,2,3,3,0,0,4,1,5,2,6,3,7,4,5,5,6,6,7,7,4],Dn=function(e,t){const r=2*Math.PI/e,n=[],o=[];for(let o=0;o<=e;o++){const e=Math.cos(r*o)*t,s=Math.sin(r*o)*t,a=0;n[3*o]=e,n[3*o+1]=s,n[3*o+2]=a}for(let o=e;o<=2*e;o++){const e=Math.cos(r*o)*t,s=Math.sin(r*o)*t,a=0;n[3*o]=a,n[3*o+1]=e,n[3*o+2]=s}for(let o=2*e;o<=3*e;o++){const e=Math.cos(r*o)*t,s=Math.sin(r*o)*t,a=0;n[3*o]=e,n[3*o+1]=a,n[3*o+2]=s}const s=n.length/3-1;for(let t=0;t<s;t++)t!==e-1&&t!==2*e-1&&(o[2*t]=t,o[2*t+1]=t+1);return n.push(0,0,0),n.push(t,0,0),n.push(0,t,0),n.push(0,0,t),o.push(s+1,s+2),o.push(s+1,s+3),o.push(s+1,s+4),{vertices:n,indices:o}}(100,1),Un=[0,0,0,1],Fn=[1,1,1];class Hn{constructor(e,t){this._layer=t,this._canvas=t.getRenderer().canvas,this.pickingFBO=t.getRenderer().pickingFBO,this._regl=e,this._renderer=new r.reshader.Renderer(e),this._loading={},this._modelMeshes={},this._pntsMeshes={},this._i3dmMeshes={},this._cmptMeshes={},this._cachedGLTF={},this._modelScene=new r.reshader.Scene,this._pntsScene=new r.reshader.Scene,this._i3dmScene=new r.reshader.Scene,this._boxScene=new r.reshader.Scene,this._resLoader=new r.reshader.ResourceLoader(e.texture(2)),this._bindedListener=(...e)=>this._onResourceLoad.call(this,...e),this._khrTechniqueWebglManager=new r.reshader.KHRTechniquesWebglManager(this._regl,this._getExtraCommandProps(),this._resLoader);const n=this.getMap();this._heightScale=n.altitudeToPoint(100,n.getGLRes())/100}getI3DMMeshes(){return this._i3dmMeshes}getPNTSMeshes(){return this._pntsMeshes}getB3DMMeshes(){return this._modelMeshes}getPaintedMeshes(){return this._paintedMeshes}getMap(){return this._layer.getMap()}getTilesInfo(){return this._tiles}paint(e,t,n){const o=n&&n.renderTarget,s=n&&n.sceneFilter,a=this.getMap();if(!e.length||!a)return null;this._tiles=e;const i=this._getUniformValues(),l=a.projViewMatrix,c=[],h=[],f=[],d=[],p=[];for(let t=0,o=e.length;t<o;t++){const o=e[t].data.node;let s=this._getMesh(o);if(!s)continue;const a=this._layer._getNodeService(o._rootIdx),i=a.debugNodes,g=a.heightOffset||0,m=a.coordOffset||fn;this._cmptMeshes[o.id]&&(s=this._cmptMeshes[o.id],s=Ie(s));let _=a.polygonOffset||on;_e(_)&&(_=_()),Array.isArray(s)||(c[0]=s,s=c);for(let c=0,b=s.length;c<b;c++){if(!s[c]||!s[c].isValid||!s[c].isValid())continue;const b=s[c].properties.magic;if(s[c].properties.heightOffset===g&&s[c].properties.coordOffset[0]===m[0]&&s[c].properties.coordOffset[1]===m[1]||(this._updateMeshLocalTransform(s[c]),s[c]._originLocalTransform=r.mat4.copy([],s[c].localTransform)),s[c]._node=o,"b3dm"===b){if(s[c].getBoundingBox&&!u(l,s[c].getBoundingBox()))continue;const{batchIdData:e,batchIdMap:t}=s[c].geometry.properties;if(e&&t){const e=s[c].properties.node._rootIdx;this._highlighted&&this._highlighted[e]?r.HighlightUtil.highlightMesh(this._regl,s[c],this._highlighted[e],this._highlightTimestamp,t):this._highlighted&&this._highlighted[e]||r.HighlightUtil.highlightMesh(this._regl,s[c],null,this._highlightTimestamp,t),r.HighlightUtil.showOnly(this._regl,s[c],this._showOnlys&&this._showOnlys[e],this._showOnlyTimeStamp,t)}if(i&&i.length&&i.indexOf(s[c]._node.id)<0)continue;n&&n.bloom&&s[c].properties.hlBloomMesh&&(s[c].properties.hlBloomMesh.properties.depthFunc="always",f.push(s[c].properties.hlBloomMesh)),f.push(s[c])}else"pnts"===b?d.push(s[c]):"i3dm"===b&&p.push(s[c]);s[c].properties.isLeaf=e[t].leave,s[c].properties.branchRootId=e[t].branchRootId;const y=255-e[t].selectionDepth;s[c].properties.selectionDepth=y,s[c].properties.polygonOffset=_;const T=void 0===a.cullFace||!!a.cullFace;s[c].properties.cullFace=T;const v=s[c].properties.hlBloomMesh;if(v){const r=v.properties;r.branchRootId=e[t].branchRootId,r.selectionDepth=y,r.polygonOffset=_,r.cullFace=T}e[t].leave||h.push(s[c]),this._updateMaskDefines(s[c]),this._updateServiceMatrix(s[c],o)}}let g=0;const m=this._khrTechniqueWebglManager.getExcludeFilter();r.ContextUtil.setIncludeUniformValues(i,n),g+=this._callShader(this._phongShader,i,[s,pn,m],o,h,f,p),g+=this._callShader(this._standardShader,i,[s,gn,m],o,h,f,p),this._khrTechniqueWebglManager.forEachShader(((e,t,r)=>{const n=this._getUniformValues(r);g+=this._callShader(e,n,[s,t],o,h,f,p)})),this._pntsScene.setMeshes(d);const _=this._getPntsUniforms();return g+=this._renderer.render(this._pntsShader,_,this._pntsScene,o&&o.fbo),this._paintedMeshes={pntsMeshes:d,i3dmMeshes:p,b3dmMeshes:f},this._boxScene.setMeshes(t),this._renderer.render(this._edgeShader,i,this._boxScene,o&&o.fbo),g}prepareRender(e){this._prepareShaders(e)}_prepareShaders(e){e&&e.states&&e.states.includesChanged&&(this._standardShader.dispose(),delete this._standardShader,this._phongShader.dispose(),delete this._phongShader),this._createShaders(e)}_callShader(e,t,r,n,o,s,a){e.filter=r.filter((e=>!!e)),t.stencilEnable=!1,t.cullFace="back";const i=n&&n.fbo;let l=0;const c=[],h=[];let u=!1,f=s[0]&&s[0].properties.branchRootId;for(let r=0;r<s.length;r++){const{branchRootId:n}=s[r].properties;n!==f&&(u?(h.length&&(l+=this._drawBranchMeshes(e,t,i,!1,h),h.length=0),l+=this._drawBranchMeshes(e,t,i,u,c)):Re(h,c),f=n,u=!1,c.length=0),c.push(s[r]),s[r].properties.selectionDepth<255&&(u=!0),r===s.length-1&&(u||(Re(h,c),c.length=0),h.length&&(l+=this._drawBranchMeshes(e,t,i,!1,h)),l+=this._drawBranchMeshes(e,t,i,u,c))}return this._modelScene.setMeshes(s.filter((e=>e.properties.isLeaf))),this._i3dmScene.setMeshes(a),l+=this._renderer.render(e,t,this._i3dmScene,n&&n.fbo),l}_drawBranchMeshes(e,t,r,n,o){return o.length?(this._modelScene.setMeshes(o),t.stencilEnable=!1,n&&(this._clearStencil(r),t.stencilEnable=!1,t.cullFace="front",this._renderer.render(e,t,this._modelScene,r),t.cullFace="back",t.stencilEnable=!0),this._renderer.render(e,t,this._modelScene,r)):0}_clearStencil(e){this._regl.clear({stencil:255,framebuffer:e})}getCurrentB3DMMeshes(){return this._modelScene.getMeshes()}getCurrentI3DMMeshes(){return this._i3dmScene.getMeshes()}_sort(e,t){return t._node._cameraDistance-e._node._cameraDistance}deleteTile(e){const t=e.node;t._boxMesh&&(t._boxMesh.geometry.dispose(),t._boxMesh.dispose(),delete t._boxMesh);const r=t.id;this._disposeMesh(r)}_disposeMesh(e){const t=this._modelMeshes[e]||this._pntsMeshes[e]||this._i3dmMeshes[e]||this._cmptMeshes[e]||this._loading[e];this._cmptMeshes[e]?this._disposeCMPT(e):t&&(this._deleteOne(t),delete this._modelMeshes[e],delete this._pntsMeshes[e],delete this._i3dmMeshes[e],delete this._loading[e])}_disposeCMPT(e){let t=this._cmptMeshes[e];t=Ie(t);for(let e=0;e<t.length;e++){const{id:r}=t[e].properties;this._disposeMesh(r)}delete this._cmptMeshes[e]}_deleteOne(e){if(Array.isArray(e))for(let t=0,r=e.length;t<r;t++)this._deleteOne(e[t]);else{r.HighlightUtil.showOnly(this._regl,e),r.HighlightUtil.highlightMesh(this._regl,e);const t=e.geometry.properties.url;if(t){const r=this._cachedGLTF[t];r&&r.refMeshes&&(r.refMeshes.delete(e.uuid),r.refMeshes.size||(r.geometry.dispose(),r.material.dispose(),delete this._cachedGLTF[t]))}else e.geometry.dispose(),e.material&&e.material.dispose();e.dispose()}}remove(){const e=this._layer;tn(e.getRenderer().canvas,e.getMap());for(const e in this._cmptMeshes)this._disposeCMPT(e);this._cmptMeshes={};for(const e in this._modelMeshes)this._disposeMesh(e);this._modelMeshes={};for(const e in this._pntsMeshes)this._disposeMesh(e);this._pntsMeshes={};for(const e in this._i3dmMeshes)this._disposeMesh(e);this._i3dmMeshes={};for(const e in this._loading)this._disposeMesh(e);this._loading={},this._phongShader&&(this._phongShader.dispose(),delete this._phongShader),this._standardShader&&(this._standardShader.dispose(),delete this._standardShader),this._pntsShader&&(this._pntsShader.dispose(),delete this._pntsShader),this._edgeShader&&(this._edgeShader.dispose(),delete this._edgeShader),this._khrTechniqueWebglManager.dispose(),this.picking&&this.picking.dispose()}_getMesh(e){return this._modelMeshes[e.id]||this._pntsMeshes[e.id]||this._i3dmMeshes[e.id]||this._cmptMeshes[e.id]}has(e){return this._getMesh(e)||this._loading[e.id]}_updateMeshLocalTransform(e){const t=e.properties.magic;"b3dm"===t?this._updateB3DMLocalMatrix(e):"i3dm"===t?this._updateI3DMLocalTransform(e):"pnts"===t&&this._updatePNTSLocalTransform(e)}createPntsMesh(e,t,n,o){if(this._pntsMeshes[t]){const e=this._pntsMeshes[t];return console.warn(`pnts mesh with id(${t}) was already created.`),o(null,{id:t,mesh:e}),e}const{pnts:s,featureTable:a,rootIdx:i,compressed_int16_params:l}=e,c=a.POINTS_LENGTH;s.BATCH_ID||(s.BATCH_ID=new Uint8Array(c),s.BATCH_ID.fill(0));const h=new r.reshader.Geometry(s,null,c,{static:!0,primitive:"points",positionAttribute:"POSITION",pickingIdAttribute:"BATCH_ID"});h.generateBuffers(this._regl);const u={},f=h.data.POSITION||h.data.POSITION_QUANTIZED,d=f&&f.buffer&&f.buffer.itemType;d&&(d.startsWith("sint")?u.POSITION_IS_INT=1:d.startsWith("uint")&&(u.POSITION_IS_UINT=1)),s.POSITION?u.HAS_POSITION=1:s.POSITION_QUANTIZED&&(u.HAS_POSITION_QUANTIZED=1),s.RGB?u.HAS_RGB=1:s.RGBA?u.HAS_RGBA=1:s.RGB565&&(u.HAS_RGB565=1),(s.NORMAL||s.NORMAL_OCT16P)&&(u.HAS_NORMAL=1,s.NORMAL_OCT16P&&(u.HAS_NORMAL_OCT16P=1)),this._setCompressedInt16Defines(u,l),e.featureTable.CONSTANT_RGBA&&(e.featureTable.CONSTANT_RGBA=e.featureTable.CONSTANT_RGBA.map((e=>e/255)));const{rtcCenter:p,rtcCoord:g,projCenter:m}=e,_=this._layer._getNodeService(i),b=new r.reshader.Mesh(h);b.properties.magic="pnts",b.properties.id=t,b.properties.node=n,b.properties.count=c,b.properties.batchTable=e.batchTable,b.properties.batchTableBin=e.batchTableBin,b.properties.serviceIndex=i,b.properties.rtcCoord=g,b.properties.rtcCenter=p,b.properties.projCenter=m,b.setDefines(u),b.setFunctionUniform("pointColor",(function(){return e.featureTable.CONSTANT_RGBA?e.featureTable.CONSTANT_RGBA:_&&_.pointColor||[1,1,1,1]}));const y=this.getMap();let T=null,v=null;b.setFunctionUniform("pointSize",(function(){if(!_)return 2;if(Gr(_.pointSize)){const e=JSON.stringify(_.pointSize);e!==T&&(v=jr(_.pointSize),T=e);return v(y.getZoom())}return _.pointSize||2}));let M=null,w=null;return b.setFunctionUniform("pointOpacity",(function(){if(!_)return 1;if(Gr(_.pointOpacity)){const e=JSON.stringify(_.pointOpacity);e!==M&&(w=jr(_.pointOpacity),M=e);return w(y.getZoom())}return _.pointOpacity||1})),this._setCompressedInt16Uniforms(b,l),this._updatePNTSLocalTransform(b),b._originLocalTransform=r.mat4.copy([],b.localTransform),this._pntsMeshes[t]=b,o(null,{id:t,mesh:[b]}),[b]}_updatePNTSLocalTransform(e){const t=e.localTransform||[],{rtcCoord:r,node:n,projCenter:o}=e.properties;this._getB3DMTransform(t,r,o,n._rootIdx),e.setLocalTransform(t)}createI3DMMesh(e,t,n,o){if(this._i3dmMeshes[t]){const e=this._i3dmMeshes[t];return console.warn(`i3dm mesh with id(${t}) was already created.`),this._loading[t]||o(null,{id:t,mesh:e}),e}const s=this._layer._getNodeService(n._rootIdx),a=this._getUpAxisTransform(n._upAxis),{i3dm:i,featureTable:l,gltf:c,batchTable:h,batchTableBin:u,count:f}=e,d=l.INSTANCES_LENGTH,{rtcCenter:p,rtcCoord:g,projCenter:m}=e,_=this._computeProjectedTransform(xn,n,p,g);hr(_,un,_);const b=r.mat4.getRotation(On,_);r.quat.normalize(b,b);const y=r.mat4.getScaling(Sn,_),T=r.mat4.fromScaling(In,y),v=this._getI3DMTileTransform(An,m,n),M=this._getProjScale(Rn),w=this._getDistanceScale(Ln,g),x=r.vec3.div(En,w,M),O=r.mat4.fromScaling(Pn,x),{POSITION:S,NORMAL_UP:I,NORMAL_RIGHT:A,SCALE:C,SCALE_NON_UNIFORM:N}=i,R=this.getMap().getRenderer().isWebGPU()?Uint32Array:Uint16Array,L={"instance_vectorA":new Float32Array(4*d),"instance_vectorB":new Float32Array(4*d),"instance_vectorC":new Float32Array(4*d),"aPickingId":new R(d)};for(let e=0;e<d;e++)L.aPickingId[e]=e;const E=new Float32Array(3),P=new Float32Array(3),k=[],B=new Float32Array(1),D=new Float32Array(3),U=[],F=[],H=[],G=[];!function(e,t){let{byteOffset:r,byteStride:n,count:o}=e;const{componentType:s,itemSize:a}=e,i=e.array.buffer,l=s?ht.getTypedArrayCtor(s):e.array.constructor;r=void 0===r?e.array.byteOffset:r,n=n||0,o=o||e.array.length/a;const c=Math.min(i.byteLength-r,o*a*l.BYTES_PER_ELEMENT);if(o=Math.floor(c/(a*l.BYTES_PER_ELEMENT)),(!n||n===a*l.BYTES_PER_ELEMENT)&&r%l.BYTES_PER_ELEMENT==0){const e=new l(i,r,o*a);for(let n=0;n<o*a;n+=a)t(new l(e.buffer,r+n*l.BYTES_PER_ELEMENT,a),n/a);return}const h=new Uint8Array(a*l.BYTES_PER_ELEMENT);n||(n=a*l.BYTES_PER_ELEMENT);for(let e=0;e<o;e++){const o=new Uint8Array(i,n*e+r,a*l.BYTES_PER_ELEMENT);h.set(o),t(new l(h.buffer),e),o.set(h)}}(S,((e,t)=>{I?(yt(P,A,t),yt(E,I,t),r.vec3.cross(k,P,E),r.vec3.normalize(k,k),Se(U,P,0),Se(U,E,1),Se(U,k,2),r.quat.fromMat3(F,U),r.quat.normalize(F,F),r.quat.multiply(F,b,F)):r.quat.identity(F),C?(yt(B,C,t),r.vec3.set(H,B[0],B[0],B[0])):N?(yt(D,N,t),r.vec3.set(H,...D)):r.vec3.set(H,1,1,1),r.mat4.fromRotationTranslationScale(G,F,e,H),Tt(L.instance_vectorA,t,G,0),Tt(L.instance_vectorB,t,G,1),Tt(L.instance_vectorC,t,G,2)}));const j={};for(const e in L)j[e]={buffer:this._regl.buffer({dimension:L[e].length/d,data:L[e],name:e}),divisor:1};const z=s.shader||"pbr";let q=0,V=!0;const Z=[],$=[];return ut(c,((e,o,s,i)=>{const c=this._processGLTF(e,o,s,i,n,!0,z,$),{geometry:b,material:y}=c;y&&!y.isReady()&&(V=!1,q++);const M=new r.reshader.InstancedMesh(j,d,b,y);c.refMeshes||(c.refMeshes=new Set,c.refMeshes.add(M.uuid)),M.properties.magic="i3dm",M.properties.id=t,M.properties.count=f,M.properties.batchTable=h,M.properties.batchTableBin=u,M.properties.serviceIndex=n._rootIdx,M.properties.rtcCoord=g,M.properties.rtcCenter=p,M.properties.projCenter=m,M.properties.node=n;const w=this._getGLTFMeshDefines(e,b,y,n._rootIdx,i);w.MESH_ENV_EXPO=1,e.compressed_int16_params&&this._setCompressedInt16Uniforms(M,e.compressed_int16_params),this._setWEB3DDecodeUniforms(M,e.attributes);const x=r.mat4.identity([]);if(e.matrices&&e.matrices.length)for(let t=0;t<e.matrices.length;t++)r.mat4.multiply(x,x,e.matrices[t]);r.mat4.multiply(x,a,x),r.mat4.multiply(x,O,x),l.EAST_NORTH_UP||I?r.mat4.multiply(x,T,x):r.mat4.multiply(x,_,x),M.setPositionMatrix(x),this._updateI3DMLocalTransform(M,v),M.setDefines(w),M.properties.polygonOffset={offset:0,factor:0},Z.push(M),delete e.attributes,M._originLocalTransform=r.mat4.copy([],M.localTransform)})),Gn($),V?(this._i3dmMeshes[t]=Z,o(null,{id:t,mesh:Z})):(this._loading[t]={meshes:Z,count:q},Z._callback=o),Z}_updateI3DMLocalTransform(e,t){const{rtcCoord:n,node:o,projCenter:s}=e.properties;t||(t=this._getI3DMTileTransform(An,s,o));const a=this._layer._getNodeService(o._rootIdx),i=e.localTransform||[];if(a.coordOffset){const e=this._computeCoordOffsetMatrix(xn,o._rootIdx,n);r.mat4.multiply(i,e,t)}else r.mat4.copy(i,t);e.setLocalTransform(i),e.properties.heightOffset=a.heightOffset||0,e.properties.coordOffset=a.coordOffset&&a.coordOffset.slice(0)||fn}_getI3DMTileTransform(e,t,n){r.mat4.fromScaling(e,this._getProjScale(Rn));const o=this._getCenterTranslation(Mn,t,n._rootIdx);return r.mat4.multiply(e,r.mat4.fromTranslation(Cn,o),e),e}createB3DMMesh(e,t,n,s){if(e.gltf&&(e.gltf.transferables=null),this._modelMeshes[t]||this._loading[t]){const e=this._modelMeshes[t];return console.warn(`mesh with id(${t}) was already created.`),this._loading[t]||s(null,{id:t,mesh:e}),e}let a;if(n.maxExtent){const e=new o.Extent(n.maxExtent).convertTo((e=>this._pointToPrj(e)));a=[e.xmin,e.ymin,e.xmax,e.ymax]}const i=e.gltf,{projCenter:l}=i.extensions.MAPTALKS_RTC,{rtcCoord:c,center:h}=i.extensions.CESIUM_RTC,u=i.asset.sharePosition,f=this._getUpAxisTransform(n._upAxis),d=this._getB3DMTileTransform(An,u,c,h,l,n),p=this._layer._getNodeService(n._rootIdx);let g=p.shader||"pbr";if(p.unlit)g="phong";else if(i.materials)for(let e=0;e<i.materials.length;e++)if(i.materials[e]&&i.materials[e].extensions&&i.materials[e].extensions.KHR_materials_unlit){g="phong";break}const m=[],_=[];let b=0,y=!0;return ut(i,((o,s,i,T)=>{const v=this._processGLTF(o,s,i,T,n,!1,g,m),{geometry:M,material:w}=v;w&&!w.isReady()&&(y=!1,b++);const x=new r.reshader.Mesh(M,w);v.refMeshes||(v.refMeshes=new Set,v.refMeshes.add(x.uuid)),x.properties.magic="b3dm",x.properties.id=t,x.properties.node=n,e.batchTable&&(x.properties.batchTable=e.batchTable,x.properties.batchTableBin=e.batchTableBin),x.properties.count=e.featureTable&&e.featureTable.BATCH_LENGTH||0,x.properties.serviceIndex=n._rootIdx;const O=this._getGLTFMeshDefines(o,M,w,n._rootIdx,T);O.MESH_ENV_EXPO=1,x.setDefines(O);const S=o.compressUniforms;if(S)for(const e in S)x.setUniform(e,S[e]);o.compressed_int16_params&&this._setCompressedInt16Uniforms(x,o.compressed_int16_params),this._setWEB3DDecodeUniforms(x,o.attributes),a&&(O.USE_MAX_EXTENT=1,x.setUniform("maxPrjExtent",a)),x.hasFunctionUniform("polygonOpacity")||x.setFunctionUniform("polygonOpacity",(function(){return ye(p.opacity)?p.opacity:1})),x.hasFunctionUniform("polygonFill")||x.setFunctionUniform("polygonFill",(function(){return Ee([],p.polygonFill||sn)})),x.material.hasFunctionUniform("hsv")||x.material.setFunctionUniform("hsv",(function(){return p.hsv||an}));const I=r.mat4.identity([]);if(u&&o.matrices&&o.matrices.length)for(let e=0;e<o.matrices.length;e++)r.mat4.multiply(I,I,o.matrices[e]);u&&r.mat4.multiply(I,f,I),x.properties.node=n,x.properties.projCenter=l,x.properties.nodeMatrix=I,x.properties.isSharedPosition=u,x.properties.rtcCoord=c,x.properties.rtcCenter=h,this._updateB3DMLocalMatrix(x,d),_.push(x),delete o.attributes,x._originLocalTransform=r.mat4.copy([],x.localTransform)})),Gn(m),y?(this._modelMeshes[t]=_,s(null,{id:t,mesh:_})):(this._loading[t]={meshes:_,count:b},_._callback=s),_}_createBoxMesh(e){const t=this._layer._getNodeBox(e.id);if(!t||e._boxMesh)return;let n,o,s,a;if(t.obbox)n=t.boxPosition,o=Bn,s=t.boxCenter,a=Fn;else if(t.sphereBox){const e=t.sphereBox[0],r=t.sphereBox[1];n=Dn.vertices,o=Dn.indices,s=e,a=[r,r,r]}const i=new r.reshader.Geometry({POSITION:n},o,0,{primitive:"lines",positionAttribute:"POSITION"}),l=new r.reshader.Mesh(i,new r.reshader.Material({lineColor:[.8,.8,.1,1],lineOpacity:1})),c=[];r.mat4.fromRotationTranslationScale(c,Un,s,a),l.localTransform=c,l._originLocalTransform=r.mat4.copy([],c),l.properties.node=e,e._boxMesh=l}_deleteBoxMesh(e){e._boxMesh&&(e._boxMesh.geometry.dispose(),e._boxMesh.dispose(),delete e._boxMesh)}_setCompressedInt16Uniforms(e,t){t.POSITION&&e.setUniform("compressedPositionRange",t.POSITION),t.TEXCOORD_0&&e.setUniform("compressedTexcoordRange_0",t.TEXCOORD_0),t.TEXCOORD_1&&e.setUniform("compressedTexcoordRange_1",t.TEXCOORD_0),t.NORMAL&&e.setUniform("compressedNormalRange",t.NORMAL),t.TANGENT&&e.setUniform("compressedTangentRange",t.TANGENT),t.compressed_ratio&&e.setUniform("compressed_ratio",t.compressed_ratio)}_updateB3DMLocalMatrix(e,t){const{isSharedPosition:n,rtcCoord:o,rtcCenter:s,projCenter:a,nodeMatrix:i,node:l}=e.properties;t||(t=this._getB3DMTileTransform(t||An,n,o,s,a,l));const c=e.localTransform||r.mat4.identity([]);r.mat4.multiply(c,t,i);const h=this._layer._getNodeService(l._rootIdx);if(h.coordOffset){const e=this._computeCoordOffsetMatrix(xn,l._rootIdx,o);r.mat4.multiply(c,e,c)}e.setLocalTransform(c),e.properties.heightOffset=h.heightOffset||0,e.properties.coordOffset=h.coordOffset&&h.coordOffset.slice(0)||fn}_getB3DMTileTransform(e,t,n,o,s,a){if(t){const t=this._getDistanceScale(Ln,n),s=r.mat4.fromScaling(wn,t),i=this._computeProjectedTransform(xn,a,o,n);r.mat4.multiply(e,i,s)}else this._getB3DMTransform(e,n,s,a._rootIdx);return e}_setWEB3DDecodeUniforms(e,t){if(t&&t.TEXCOORD_0&&t.TEXCOORD_0.extensions&&t.TEXCOORD_0.extensions.WEB3D_quantized_attributes){const r=t.TEXCOORD_0.extensions.WEB3D_quantized_attributes.decodeMatrix;e.setUniform("decodeMatrix",r)}}_computeProjectedTransform(e,t,n,o){const s=this.getMap(),a=this._layer._getNodeService(t._rootIdx).heightOffset||0,i=t.matrix?r.mat4.copy(e,t.matrix):r.mat4.identity(e);if(n){hr(i,r.vec3.transformMat4(mn,n,i),i)}const l=function(e,t,r,n,o,s,a){t=Xe(fr,t);const i=Ot(fr,t[0]*vr,t[1]*vr,t[2]),l=function(e,t){return e[0]=t[12],e[1]=t[13],e[2]=t[14],e}(dr,r),c=n.ellipsoid;let h;h=0===it(l)?Je(pr,0,0,-6378137):Rt(pr,l),yr.x=h[0],yr.y=h[1];const u=n.project(yr,Tr);gr[0]=u.x/o,gr[1]=u.y/o,gr[2]=(h[2]+a)*s;const f=ur(i,c,mr),d=function(e,t){var r=t[0],n=t[1],o=t[2],s=t[3],a=t[4],i=t[5],l=t[6],c=t[7],h=t[8],u=t[9],f=t[10],d=t[11],p=t[12],g=t[13],m=t[14],_=t[15],b=r*i-n*a,y=r*l-o*a,T=r*c-s*a,v=n*l-o*i,M=n*c-s*i,w=o*c-s*l,x=h*g-u*p,O=h*m-f*p,S=h*_-d*p,I=u*m-f*g,A=u*_-d*g,C=f*_-d*m,N=b*C-y*A+T*I+v*S-M*O+w*x;return N?(N=1/N,e[0]=(i*C-l*A+c*I)*N,e[1]=(o*A-n*C-s*I)*N,e[2]=(g*w-m*M+_*v)*N,e[3]=(f*M-u*w-d*v)*N,e[4]=(l*S-a*C-c*O)*N,e[5]=(r*C-o*S+s*O)*N,e[6]=(m*T-p*w-_*y)*N,e[7]=(h*w-f*T+d*y)*N,e[8]=(a*A-i*S+c*x)*N,e[9]=(n*S-r*A-s*x)*N,e[10]=(p*M-g*T+_*b)*N,e[11]=(u*T-h*M-d*b)*N,e[12]=(i*O-a*I-l*x)*N,e[13]=(r*I-n*O+o*x)*N,e[14]=(g*y-p*v-m*b)*N,e[15]=(h*v-u*y+f*b)*N,e):null}(_r,f),p=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[4],e[4]=t[5],e[5]=t[6],e[6]=t[8],e[7]=t[9],e[8]=t[10],e}(br,r);return hr(function(e,t,r){const n=e[0],o=e[1],s=e[2],a=e[4],i=e[5],l=e[6],c=e[8],h=e[9],u=e[10],f=t[0],d=t[1],p=t[2],g=t[3],m=t[4],_=t[5],b=t[6],y=t[7],T=t[8],v=n*f+a*d+c*p,M=o*f+i*d+h*p,w=s*f+l*d+u*p,x=n*g+a*m+c*_,O=o*g+i*m+h*_,S=s*g+l*m+u*_,I=n*b+a*y+c*T,A=o*b+i*y+h*T,C=s*b+l*y+u*T;return r[0]=v,r[1]=M,r[2]=w,r[3]=0,r[4]=x,r[5]=O,r[6]=S,r[7]=0,r[8]=I,r[9]=A,r[10]=C,r[11]=0,r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r}(d,p,e),gr,e),e}(i,o,i,s.getProjection(),s.getGLRes(),this._heightScale,a),c=function(e,t){return Je(e,t[12],t[13],t[14]),e}(Mn,l);let h=this._layer.options.offset;if(_e(h)){const e=this._layer._getNodeBox(t.id).boxCoord;h=h.call(this._layer,e)}return r.vec3.set(vn,h[0],h[1],0),r.vec3.sub(c,c,vn),hr(l,c,l),l}_computeCoordOffsetMatrix(e,t,n){const o=this._layer._getNodeService(t);if(!o.coordOffset)return null;const s=this.getMap(),a=s.getGLRes();_n.set(n[0],n[1]);const i=s.coordToPointAtRes(_n,a,yn),l=o.coordOffset,c=_n.set(n[0]+l[0],n[1]+l[1]),h=s.coordToPointAtRes(c,a,Tn),u=h.x-i.x,f=h.y-i.y,d=this._heightScale,p=r.vec3.set(vn,u,f,(l[2]||0)*d);return r.mat4.fromTranslation(e,p)}createCMPTMesh(e,t,r,n){if(this._cmptMeshes[t]){const e=this._cmptMeshes[t];return console.warn(`mesh with id(${t}) was already created.`),n(null,{id:t,mesh:e}),e}const{content:o}=e,s=[];for(let e=0;e<o.length;e++){const{magic:n}=o[e],a=t+"."+e;"b3dm"===n?this.createB3DMMesh(o[e],a,r,((e,{mesh:t})=>{s.push(t)})):"i3dm"===n?this.createI3DMMesh(o[e],a,r,((e,{mesh:t})=>{s.push(t)})):"pnts"===n?this.createPntsMesh(o[e],a,r,((e,{mesh:t})=>{s.push(t)})):"cmpt"===n&&this.createCMPTMesh(o[e],a,r,((e,{mesh:t})=>{s.push(t)}))}return this._cmptMeshes[t]=s,n(null,{id:t,mesh:s}),s}_getGLTFMeshDefines(e,t,r,n,o){const s=("phong"===(this._layer._getNodeService(n).shader||"pbr")?this._phongShader:this._standardShader).getGeometryDefines(t);o.asset&&"S3M"===o.asset.generator&&this._appendS3MDefines(s,t),t.data.uvRegion&&(s.HAS_I3S_UVREGION=1),t.data[t.desc.normalAttribute]&&(s.VertexNormal=1),t.data[t.desc.color0Attribute]&&(s.VertexColor=1),t.data[t.desc.uv0Attribute]&&(s.TexCoord=1),t.data[t.desc.textureCoordMatrixAttribute]&&(s.HAS_TextureCoordMatrix=1),r.get("uTexture")&&(s.COMPUTE_TEXCOORD=1),r.get("uTexture2")&&(s.TexCoord2=1),"MESHOPT"===this._layer._vertexCompressionType&&(s.MeshOPT_Compress=1),this.hasIBL()&&(s.HAS_IBL_LIGHTING=1),e.attributes&&e.attributes.TEXCOORD_0&&"WEB3D_quantized_attributes"===e.attributes.TEXCOORD_0.extensions&&(s.HAS_WEB3D_quantized_attributes_TEXCOORD=1),s.HAS_MIN_ALTITUDE=1,this._setCompressedInt16Defines(s,e.compressed_int16_params);return me(s,e.compressDefines),s}_setCompressedInt16Defines(e,t){t&&Object.keys(t).length>0&&(e.HAS_COMPRESSED_INT16=1,t.POSITION&&(e.HAS_COMPRESSED_INT16_POSITION=1),t.TEXCOORD_0&&(e.HAS_COMPRESSED_INT16_TEXCOORD_0=1),t.TEXCOORD_1&&(e.HAS_COMPRESSED_INT16_TEXCOORD_1=1),t.NORMAL&&(e.HAS_COMPRESSED_INT16_NORMAL=1),t.TANGENT&&(e.HAS_COMPRESSED_INT16_TANGENT=1),t.compressed_ratio&&(e.HAS_COMPRESSED_INT16_RATIO=1))}_updateMaskDefines(e){const t=this._layer.getRenderer();t&&t.updateMaskDefines(e)}_appendS3MDefines(e,t){t.data.aNormal&&(e.VertexNormal=1),t.data.instanceId&&(e.Instance=1),t.data.aTexCoord0&&(e.TexCoord=1),t.data.aColor&&(e.VertexColor=1),t.data.aTexCoord1&&(e.TexCoord2=1),t.data.uv2&&(e.InstanceBim=1)}_processGLTF(e,t,n,o,s,a,i,l){let c=!1;o.asset&&"S3M"===o.asset.generator&&(c=!0,o.extensions=o.extensions||{});const h=o.url+"-"+t+"-"+n;if(this._cachedGLTF[h])return this._cachedGLTF[h];let u,f;l.push(e);const d=o.materials&&o.materials[e.material],p=o.extensions&&o.extensions.KHR_techniques_webgl,g=this._layer._getNodeService(s._rootIdx);if(p&&d.extensions&&d.extensions.KHR_techniques_webgl){if(this.getMap().getRenderer().isWebGPU())throw new Error("3dtiles with KHR_techniques_webgl extension is not supported in webgpu");const t=this._createTechniqueMesh(e,o,a,c);u=t.material,f=t.geometry,g.fillEmptyDataInMissingAttribute&&(f.desc.fillEmptyDataInMissingAttribute=!0)}else{f=this._createGeometry(e,a,kn);const t=g.material;u=this._createMaterial(e.material,o,i,t||ln,l,g)}u&&(u.setFunctionUniform("alphaTest",(function(){const e=g.alphaTest;return ge(e)?.1:e})),u.setFunctionUniform("environmentExposure",(()=>{const e=g.ambientLight;let t=g.environmentExposure;const r=this.getMap().getLightManager(),n=r&&r.getAmbientLight();if(e&&(!n||n.color)&&void 0===t){const r=n&&n.color?n.color[0]:.2;t=e[0]/r}return t||1}))),u&&!u.isReady()?u._nodeId=s.id:u||(u=new r.reshader.PhongMaterial({"baseColorFactor":[1,1,1,1]}));const m={geometry:f,material:u};return f.properties.url=h,this._cachedGLTF[h]=m,m}_createTechniqueMesh(e,t,r,n){const{geometry:o,material:s}=this._khrTechniqueWebglManager.createMesh(e,t,r,n);return{geometry:o,material:s}}_createGeometry(e,t,n){const o=this.getMap().getRenderer().isWebGPU(),s=e.attributes,a="COLOR_0";let i=s._BATCHID&&s._BATCHID.array;if(i&&i.byteOffset&&(i=new i.constructor(i),!o||i instanceof Uint32Array||(i=new Uint32Array(i))),s[a]){const e=s[a].array||s[a];if(e instanceof Float32Array){const t=new Uint8Array(e.length);for(let r=0;r<t.length;r++)t[r]=Math.round(255*e[r]);s[a].array?(s[a].array=t,s[a].componentType=5121):s[a]=t}}const l={};let c=0,h=0;for(const e in s){const t=n[e]||e,a=t===n.POSITION;o&&r.reshader.Geometry.padGPUGLTFAttribute(s[e]),a&&(c=s[e].itemSize);const i=Kr(this._regl,s[e],{dimension:s[e].itemSize,name:e});l[t]=me({},s[e]),l[t].buffer=i,l[t].type=Xr(l[t].array),delete l[t].array,t===n.POSITION&&(l[t].array=s[e].array,h=s[e].array.length/3)}const u=n._BATCHID;if(!l[u]&&!t){const e=new(o?Uint32Array:Uint8Array)(h);l[u]=e}const f=e.indices?e.indices.array?e.indices.array.slice():e.indices:null,d=new r.reshader.Geometry(l,f,0,{positionSize:c,positionAttribute:n.POSITION,normalAttribute:n.NORMAL,uv0Attribute:n.TEXCOORD_0,uv1Attribute:n.TEXCOORD_1,color0Attribute:n.COLOR_0,tangentAttribute:n.TANGENT,pickingIdAttribute:n._BATCHID,primitive:void 0===e.mode?"triangles":Wr(e.mode)});return i&&f&&(d.properties.batchIdData=i,d.properties.batchIdMap=function(e,t){if(!t)return null;const r=new Map;for(let n=0;n<t.length;n++){const o=t[n],s=e[o];let a=r.get(s);a||(a=[],r.set(s,a)),a.push(o)}return r}(i,f)),d.generateBuffers(this._regl,{excludeElementsInVAO:t}),d}_getB3DMTransform(e,t,n,o){const s=r.mat4.identity(e),a=this._getProjScale(cn);return this._getCenterTranslation(Mn,n,o),r.mat4.translate(s,s,Mn),r.mat4.scale(s,s,a),s}_getCenterTranslation(e,t,n){const o=this._heightScale;_n.x=t[0],_n.y=t[1];const s=this._prjToPoint(_n);let a=this._layer.options.offset;_e(a)&&(a=a.call(this._layer,_n));const i=this._layer._getNodeService(n).heightOffset||0;return r.vec3.set(e,s.x-a[0],s.y-a[1],o*t[2]+o*i),e}_updateServiceMatrix(e,t){const n=this._layer._getServiceTransform(Nn,t);e.localTransform=r.mat4.multiply(e.localTransform,n,e._originLocalTransform)}_getDistanceScale(e,t){const n=this.getMap();_n.x=t[0],_n.y=t[1];const o=n.distanceToPointAtRes(100,100,n.getGLRes(),_n),s=this._heightScale;return r.vec3.set(e,o.x/100,o.y/100,s),e}_createShaders(e){if(this._standardShader)return;const t={x:0,y:0,width:()=>this._canvas?this._canvas.width:1,height:()=>this._canvas?this._canvas.height:1},n=[],o=[];this._pntsShader=new r.reshader.MeshShader({name:"3dtiles-pnts-shader",vert:vt,frag:"#define SHADER_NAME PNTS\nprecision mediump float;\nuniform float layerOpacity;\nvarying vec4 vColor;\nvoid main() {\n vec2 circCoord = 2.0 * gl_PointCoord - 1.0;\n if (dot(circCoord, circCoord) > 1.0) {\n discard;\n } else {\n gl_FragColor = vColor;\n }\n #ifdef HAS_LAYER_OPACITY\n gl_FragColor *= layerOpacity;\n #endif\n}\n",wgslVert:r.getWGSLSource("layer_3dtiles_pnts_vert"),wgslFrag:r.getWGSLSource("layer_3dtiles_pnts_frag"),uniforms:[{name:"projViewModelMatrix",type:"function",fn:(e,t)=>r.mat4.multiply(o,t.projViewMatrix,t.modelMatrix)},{name:"modelNormalMatrix",type:"function",fn:(e,t)=>r.mat3.fromMat4(n,t.modelMatrix)}],extraCommandProps:{viewport:t,blend:{enable:!0,func:{src:"one",dst:"one minus src alpha"},equation:"add"},depth:{enable:!0,func:"<"}}});const s={},a=[];r.ContextUtil.fillIncludes(s,a,e);const i=this._getExtraCommandProps();this._phongShader=new r.reshader.PhongShader({uniforms:a,defines:s,extraCommandProps:i}),this._standardShader=new r.reshader.pbr.StandardShader({uniforms:a,defines:s,extraCommandProps:i}),this._edgeShader=new r.reshader.EdgeShader({extraCommandProps:{viewport:{x:0,y:0,width:()=>this._canvas?this._canvas.width:1,height:()=>this._canvas?this._canvas.height:1},blend:{enable:!0,func:{srcRGB:"src alpha",srcAlpha:1,dstRGB:"one minus src alpha",dstAlpha:"one minus src alpha"},equation:"add"}}});const l=this._layer;en(l.getRenderer().canvas,this._regl,l.getMap()),this.picking=new r.reshader.FBORayPicking(this._renderer,{vert:"#include <gl2_vert>\n#define SHADER_NAME GEO_3DTILES_PICKING\nattribute vec3 aPosition;\n#if defined(HAS_COLOR)\n attribute vec4 aColor;\n#endif\n#if defined(HAS_COLOR0)\n #if COLOR0_SIZE == 3\n attribute vec3 aColor0;\n varying vec3 vColor0;\n #else\n attribute vec4 aColor0;\n varying vec4 vColor0;\n #endif\n#endif\nuniform mat4 modelMatrix;\nuniform mat4 modelViewMatrix;\nuniform mat4 positionMatrix;\nuniform mat4 projMatrix;\n#include <line_extrusion_vert>\n#include <get_output>\n#include <fbo_picking_vert>\nvoid main() {\n mat4 localPositionMatrix = getPositionMatrix();\n vec4 localVertex = getPosition(aPosition);\n vec4 position = localPositionMatrix * localVertex;\n vec4 viewVertex = modelViewMatrix * position;\n #ifdef HAS_MASK_EXTENT\n gl_Position = projMatrix * getMaskPosition(position, modelMatrix);\n #else\n gl_Position = projMatrix * viewVertex;\n #endif\n float alpha = 1.0;\n #if defined(HAS_COLOR)\n alpha *= aColor.a;\n #endif\n #if defined(HAS_COLOR0) && COLOR0_SIZE == 4\n alpha *= aColor0.a;\n #endif\n fbo_picking_setData(gl_Position.w, alpha != 0.0);\n}\n",wgslVert:r.getWGSLSource("layer_3dtiles_picking_vert"),extraCommandProps:i,uniforms:this._standardShader.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap()),this._pntsPicking=new r.reshader.FBORayPicking(this._renderer,{vert:vt,wgslVert:r.getWGSLSource("layer_3dtiles_pnts_vert"),extraCommandProps:i,uniforms:this._pntsShader.uniforms,defines:{"PICKING_MODE":1,"ENABLE_PICKING":1,"HAS_PICKING_ID":1}},this.pickingFBO,this.getMap())}_getExtraCommandProps(){return{viewport:{x:0,y:0,width:()=>this._canvas?this._canvas.width:1,height:()=>this._canvas?this._canvas.height:1},cull:{enable:(e,t)=>!!t.meshProperties.cullFace,face:(e,t)=>t.cullFace||"back"},stencil:{enable:(e,t)=>t.stencilEnable,func:{cmp:"<=",ref:(e,t)=>t.meshProperties.selectionDepth},op:{fail:"keep",zfail:"keep",zpass:"replace"}},depth:{enable:!0,func:(e,t)=>t.meshProperties.depthFunc||"<="},blend:{enable:!0,func:{src:1,dst:"one minus src alpha"},equation:"add"},polygonOffset:{enable:!0,offset:(e,t)=>t.meshProperties.polygonOffset}}}_getPntsUniforms(e){const t=this.getMap(),n=t.getLightManager(),o=(n&&n.getDirectionalLight()||{}).direction||[1,1,-1],s=e&&e.pointOpacity||1;let a=this._layer.options.opacity;return a=ge(a)?1:a,{projViewMatrix:t.projViewMatrix,pointOpacity:s,lightDir:r.vec3.normalize(dn,o),layerOpacity:a}}_getUniformValues(){const e=this.getMap(),t=this._layer,r=t.getRenderer().canvas,{iblTexes:n,dfgLUT:o}=rn(r),s=nn(e,n,o),a=this._layer.getRenderer().getMaskUniforms();s.minAltitude=t.options.altitude/100||0;let i=t.options.opacity;return i=ge(i)?1:i,s.layerOpacity=i,me(s,{czm_lightDirectionEC:s.light0_viewDirection,lightSpecular:[1,1,1],viewMatrix:e.viewMatrix,projMatrix:e.projMatrix,projViewMatrix:e.projViewMatrix,outSize:[r.width,r.height],polygonFill:[1,1,1,1],polygonOpacity:1}),s.ambientColor||(s.ambientColor=[.2,.2,.2]),me(s,a),s}_createMaterial(e,t,n,o,s,a){const i=t.materials&&t.materials[e];if(!i||!i.baseColorTexture&&!i.pbrMetallicRoughness)return null;const l=me({},o);if(i.baseColorTexture){const e=t.textures[i.baseColorTexture.index];let r;e&&!e.image.color&&(r=this._getTexture(e,s)),l.baseColorFactor=e&&e.image.color||i.baseColorFactor||[1,1,1,1],r&&(l.baseColorTexture=r)}else{if(i.normalTexture){const e=this._getTexture(t.textures[i.normalTexture.index],s);if(e){const t=i.normalTexture.scale||1;l.normalTexture=e,l.normalMapFactor=t}}if(i.occlusionTexture){const e=this._getTexture(t.textures[i.occlusionTexture.index],s);if(e){const t=i.occlusionTexture.strength||1;l.occlusionTexture=e,l.occlusionFactor=t}}if(i.emissiveTexture){const e=this._getTexture(t.textures[i.emissiveTexture.index],s);e&&(l.emissiveTexture=e)}i.emissiveFactor&&(l.emissiveFactor=i.emissiveFactor);const e=i.pbrMetallicRoughness;if(e){if(e.baseColorFactor&&(l.baseColorFactor=e.baseColorFactor),e.baseColorTexture&&void 0!==e.baseColorTexture.index){const n=t.textures[e.baseColorTexture.index];if(n&&n.image&&n.image.color)l.baseColorFactor=l.baseColorFactor?r.vec4.multiply(l.baseColorFactor,l.baseColorFactor,n.image.color):n.image.color;else{const e=this._getTexture(n,s);e&&(l.baseColorTexture=e,l.baseColorTexture.getREGLTexture(this._regl))}}if(ge(e.metallicFactor)||(l.metallicFactor=e.metallicFactor),ge(e.roughnessFactor)||(l.roughnessFactor=e.roughnessFactor),i.metallicRoughnessTexture){const e=this._getTexture(t.textures[i.metallicRoughnessTexture.index],s);e&&(l.metallicRoughnessTexture=e)}}}if(i.s3mMaterial)return new r.reshader.Material(l);if(a.unlit||i.extensions&&i.extensions.KHR_materials_unlit){const e=new r.reshader.PhongMaterial(l);return e.unlit=void 0===a.unlit||!!a.unlit,e}let c=new r.reshader.pbr.StandardMaterial(l);"phong"===n&&(c=r.reshader.PhongMaterial.convertFrom(c));const h=i.pbrMetallicRoughness,u=h&&h.baseColorTexture&&h.baseColorTexture.extensions;return u&&u.KHR_texture_transform&&(c.set("khr_offset",u.KHR_texture_transform.offset||[0,0]),c.set("khr_rotation",u.KHR_texture_transform.rotation||0),c.set("khr_scale",u.KHR_texture_transform.scale||[1,1])),c.doubleSided=!(!a.doubleSided&&!i.doubleSided),c.once("complete",this._bindedListener),c}_getTexture(e,t){if(!e)return null;const n={type:e.type?$r(e.type):"uint8",format:e.format?Qr(e.format):"rgba",flipY:!!e.flipY},o=e.image;if(t.push(o),o.array?n.data=o.array:o.mipmap&&(n.mipmap=o.mipmap),!n.data&&!n.mipmap)return null;if(n.width=o.width,n.height=o.height,n.mipmap&&(n.width<4||n.height<4))return null;const s=e.sampler||e.texture&&e.texture.sampler;return s&&(s.magFilter&&(n.mag=qr(s.magFilter)),s.minFilter&&(n.min=Vr(s.minFilter)),s.wrapS&&(n.wrapS=Zr(s.wrapS)),s.wrapT&&(n.wrapT=Zr(s.wrapT))),new r.reshader.Texture2D(n,this._resLoader)}_onResourceLoad({target:e}){const t=e._nodeId,r=this._loading[t];if(r.count--,!r.count){const e=r.meshes;this._modelMeshes[t]=e,delete this._loading[t];const n=e._callback;delete e._callback,n(null,{mesh:r.meshes,id:t})}}_getProjScale(e){const t=1/this.getMap().getGLRes(),r=this._heightScale;return e[0]=e[1]=t,e[2]=r,e}_coordToPoint(e){return this._layer._coordToPoint(e)}_pointToPrj(e){const t=this.getMap();return t.getGLZoom?t._pointToPrj(e,t.getGLZoom()):t._pointToPrjAtRes(e,t.getGLRes())}_prjToPoint(e){const t=this.getMap();return t.getGLZoom?t._prjToPoint(e,t.getGLZoom()):t._prjToPointAtRes(e,t.getGLRes(),bn)}_getUpAxisTransform(e){return"Y"===e?Jr:"X"===e?Yr:hn}pick(e,t,r=3){const n=this._layer;if(!n||!n.options.picking)return[];if(!this.pickingFBO||!this.picking)return[];const o=[],s=this._getUniformValues(),a=this._pickMesh(this.picking,s,this._modelScene,e,t,r);a&&o.push(a);const i=this._pickMesh(this.picking,s,this._i3dmScene,e,t,r);i&&o.push(i);const l=this._getPntsUniforms(),c=this._pickMesh(this._pntsPicking,l,this._pntsScene,e,t,r);return c&&o.push(c),o}_pickMesh(e,t,r,n,o,s){if(!r.getMeshes().length)return null;const a=this._layer,i=this.getMap();e.render(r.getMeshes().filter((e=>!e.bloom)),t,!0);let l={};e.getRenderedMeshes().length&&(l=e.pick(n,o,s,t,{viewMatrix:i.viewMatrix,projMatrix:i.projMatrix,returnPoint:a.options.pickingPoint}));const{meshId:c,pickingId:h,point:u,coordinate:f}=l,d=(0===c||c)&&e.getMeshAt(c);if(!d||!d.geometry)return null;const p=d.properties;u&&u.length&&(u[0]=Math.round(1e5*u[0])/1e5,u[1]=Math.round(1e5*u[1])/1e5,u[2]=Math.round(1e5*u[2])/1e5);const g={batchId:h},m=a.options.services,_=m&&m[d.properties.serviceIndex];if(_&&_.debug&&(g.debugInfo=p),p&&p.batchTable){const{batchTable:e,batchTableBin:t,count:r}=p,n=h;for(const o in e)void 0!==e[o].byteOffset?g[o]=Qt(e[o],t,r,n):g[o]=e[o][n]}return{service:d.properties.serviceIndex,data:g,point:u,coordinate:f}}highlight(e){this._highlighted=e;const t=this._layer.getRenderer();this._highlightTimestamp=t.getFrameTimestamp(),t.setToRedraw(!0)}cancelAllHighlight(){this._highlighted=null;const e=this._layer.getRenderer();this._highlightTimestamp=e.getFrameTimestamp(),e.setToRedraw(!0)}showOnly(e){this._showOnlys=e;const t=this._layer.getRenderer();this._showOnlyTimeStamp=t.getFrameTimestamp(),t.setToRedraw(!0)}cancelShowOnly(){this._showOnlys=null;const e=this._layer.getRenderer();this._showOnlyTimeStamp=e.getFrameTimestamp(),e.setToRedraw(!0)}_getCurrentBatchIDs(){if(!this._paintedMeshes)return[];const e={},t=[];for(const r in this._paintedMeshes){const n=this._paintedMeshes[r];if(n)for(let r=0;r<n.length;r++){const o=n[r],s=o&&o.geometry;if(!o||!s)continue;const a=o.properties.serviceIndex;e[a]||(e[a]=new Set);const i=s.properties.batchIdData;if(i)for(let r=0;r<i.length;r++)e[a].has(i[r])||(t.push({id:i[r],service:a}),e[a].add(i[r]))}}return t}hasIBL(){const e=this.getMap().getLightManager();return!!(e&&e.getAmbientResource())}}function Gn(e){for(let t=0;t<e.length;t++)e[t]&&(e[t].array&&(e[t].array=null),e[t].mipmap&&(e[t].mipmap=null),e[t].indices&&(e[t].indices=null))}function jn(e,t){if(t)for(let r=0;r<t.length;r++){e[t[r].id||t[r].index]=t[r]}}const zn=[];class qn{constructor(e,t,r,n,o){this._layer=n,this._url=e,this._rootIdx=t,this._fnFetchNodepages=o,this._version=r.version,e.indexOf("i3s:tileset:")<0?(this._version<=1.6?this._index="root":this._index=0,r.version=this._version):(this._index=e.substring(12),this._version>1.6&&(this._index=parseInt(this._index))),this._url=e,this._nodeCache=r}load(){const e=this._nodeCache,t=e.layerScene.baseUrl;if(this._version<=1.6)return e[this._index]&&e[this._index].lodSelection?(this._nodeJSON=e[this._index],this._loadNode()):new Promise((r=>{let n=t+"/nodes/"+this._index;e.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this._fnFetchNodepages(this._rootIdx,n,(()=>{this._nodeJSON=e[this._index],r(this._loadNode())}))}));if(this._version>=1.7){if(e[this._index])return this._nodeJSON=e[this._index],this._loadNode();const r=Math.floor(this._index/e.nodesPerPage);return new Promise((n=>{let o=t+"/nodepages/"+r;e.layerScene.eslpk&&(o+=".json"),this._fnFetchNodepages(this._rootIdx,o,(()=>{this._nodeJSON=e[this._index],n(this._loadNode())}))}))}return null}getTileset(){return this._tileset}getChildrenURL(){return this._childrenURL}_loadNode(){const e=this._nodeCache,t=e.layerScene.baseUrl,r=this._nodeJSON.children,n=[],o={};if(r)for(let s=0;s<r.length;s++)if(this._version<=1.6){const a=r[s].id;if(e[a])continue;const i=a;o[i]||(o[i]=new Promise((r=>{let n=t+"/nodes/"+i;e.layerScene.eslpk&&(n+="/3dNodeIndexDocument.json"),this._fnFetchNodepages(this._rootIdx,n,(()=>{r()}))})),n.push(o[i]))}else{const a=r[s];if(e[a])continue;const i=Math.floor(a/e.nodesPerPage);o[i]||(o[i]=new Promise((r=>{let n=t+"/nodepages/"+i;e.layerScene.eslpk&&(n+=".json"),this._fnFetchNodepages(this._rootIdx,n,(()=>{r()}))})),n.push(o[i]))}return n.length?Promise.all(n).then((()=>this._loadContent())):this._loadContent()}_loadContent(){return Promise.resolve(this._createTileset())}_fillCache(e){jn(this._nodeCache,e)}_createTileset(){return{asset:{i3s:!0,version:"1.0",gltfUpAxis:"Z"},geometricError:Number.MAX_VALUE,root:this._convertNode(this._nodeJSON,!0)}}_convertNode(e){const t=this._layer.getRenderer(),r=this._nodeCache.projection,n=!r||r&&4326===r.wkid,o=this._version,s=this._nodeCache,a=e,i=a.obb,l=a.mbs,c={};let h;if(l)h=Je([],l[0],l[1],l[2]),n||(h=t._tileCoordToLngLat(h,h)),h=Vn([],h[0],h[1],h[2]),c.sphere=[...h,l[3]];else if(i){h=Je([],i.center[0],i.center[1],i.center[2]),n||(h=t._tileCoordToLngLat(h,h)),h=Vn([],h[0],h[1],h[2]);const e=function(e,t,r){const n=function(e,t){var r=t[0],n=t[1],o=t[2],s=t[3],a=r+r,i=n+n,l=o+o,c=r*a,h=n*a,u=n*i,f=o*a,d=o*i,p=o*l,g=s*a,m=s*i,_=s*l;return e[0]=1-u-p,e[3]=h-_,e[6]=f+m,e[1]=h+_,e[4]=1-c-p,e[7]=d-g,e[2]=f-m,e[5]=d+g,e[8]=1-c-u,e}([],r);return n[0]=n[0]*t[0],n[1]=n[1]*t[0],n[2]=n[2]*t[0],n[3]=n[3]*t[1],n[4]=n[4]*t[1],n[5]=n[5]*t[1],n[6]=n[6]*t[2],n[7]=n[7]*t[2],n[8]=n[8]*t[2],[...e,...n]}(h,i.halfSize,i.quaternion),r=e[3]+e[6]+e[9],o=e[4]+e[7]+e[10],s=e[5]+e[8]+e[11];Je(zn,r,o,s);const a=it(zn);c.sphere=[...h,a]}let u=1/0,f=0;if(a.mbs?f=a.mbs[3]:a.obb&&(f=Math.max(Math.max(a.obb.halfSize[0],a.obb.halfSize[1]),a.obb.halfSize[2])),void 0!==a.lodThreshold)if("maxScreenThresholdSQ"===s.lodSelectionMetricType){u=f/(Math.sqrt(a.lodThreshold)/(.25*Math.PI))}else console.error("Unsupported lodSelectionMetricType in Layer");else if(void 0!==a.lodSelection)for(let e=0;e<a.lodSelection.length;e++)"maxScreenThreshold"===a.lodSelection[e].metricType&&(u=f/a.lodSelection[e].maxError);(u===1/0||isNaN(u))&&(u=1e5);const d=16*u,p=function(e){return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}([]),g=p,m=a.children;let _;if(m){_=[];const e=this._nodeCache;for(let t=0;t<m.length;t++){const r=o<=1.6?m[t].id:m[t];if(!e[r]){_=null;break}_.push(this._convertNode(e[r]))}}const b={refine:"REPLACE",boundingVolume:c,transform:g,geometricError:d};return o<=1.6?e.lodSelection?e.geometryData&&(b.content={uri:"i3s:mesh:"+(e.id||e.index)}):b.content={uri:"i3s:tileset:"+(e.id||e.index)}:m&&m.length&&!_?b.content={uri:"i3s:tileset:"+(e.id||e.index)}:a.mesh&&(b.content={uri:"i3s:mesh:"+(e.id||e.index)}),_&&_.length&&(b.children=_),b}getJSON(){return this._nodeJSON}}function Vn(e,t,r,n){return Ot(e,Te(t),Te(r),n)}const Zn=!!Fe.ktx2,$n=r.mat4.identity([]),Qn=(()=>{try{if("object"==typeof WebAssembly&&"function"==typeof WebAssembly.instantiate){const e=new WebAssembly.Module(Uint8Array.of(0,97,115,109,1,0,0,0));if(e instanceof WebAssembly.Module)return new WebAssembly.Instance(e)instanceof WebAssembly.Instance}}catch(e){}return!1})();function Wn(e){return e.indexOf("i3s:mesh")>=0}const Kn=9;function Xn(e,t,r,n,o){const s=t.layerScene.eslpk,a=function(e,t){const r=t.substring(Kn);return e>=1.7?parseInt(r):r}(t.version,e),i=t[a],l=t.layerScene.baseUrl,c=[];let h=!1;const u=$n;let f,d;if(t.version<=1.6){if(!i.geometryData)return null;const e=i.geometryData.length;if(!e)return null;let r=l+`/nodes/${i.id}/`+i.geometryData[e-1].href;s&&(r+=".bin");const n={geometry:{url:r,info:t.layerScene.store.defaultGeometrySchema}};let o=i.textureData&&i.textureData[0]&&i.textureData[0].href;if(o){const e=t.layerScene.store.textureEncoding[0];let r;r="image/jpeg"===e?"jpg":"png",s&&(o+="."+r);const a={pbrMetallicRoughness:{baseColorTexture:{url:l+`/nodes/${i.id}/`+o,factor:1,format:r,mimeType:e},metallicFactor:0}};n.material=a}c.push(n)}else{f=i.mesh.geometry,d=i.mesh.material;const e=t.layerScene.geometryDefinitions,a=(t.layerScene.store||{}).textureEncoding,u=e[f.definition],{geometryBuffers:p}=u;h=n&&2===p.length;const g=Fe.draco&&h?p[1]:p[0],m=Fe.draco&&h?1:0;let _=l+`/nodes/${f.resource}/geometries/`+m;s&&(_+=".bin");const b={geometry:{url:_,info:g}};if(o&&Qn&&h&&!Fe.draco)throw new Error("Must import @maptalks/transcoder.draco to load i3s draco compressed geometry");const y=t.layerScene.materialDefinitions,T=t.layerScene.textureSetDefinitions;let v,M=0;if(d&&(M=y[d.definition]),y){v=function(e,t,r,n,o,s,a){const i=JSON.parse(JSON.stringify(t));return Jn(e,i,r,n,o,s,a),i}(a,M,T,l,d.resource,r,t.layerScene.eslpk)}else v={pbrMetallicRoughness:{metallicFactor:0}};b.material=v,c.push(b)}return{dracoCompression:h,meshes:c,nodeIndex:a,center:i.obb&&i.obb.center||i.mbs&&[i.mbs[0],i.mbs[1],i.mbs[2]],transform:u}}function Jn(e,t,r,n,o,s,a){for(const i in t)if(t[i]&&t[i].textureSetDefinitionId>=0){const l=r[t[i].textureSetDefinitionId],c="images/"+l.formats[0].format,h=eo(l.formats,s,e),u={url:n+`/nodes/${o}/textures/${h.name}`,factor:void 0===t[i].factor?1:t[i].factor,format:h.format,mimeType:c};if(a){let e="";switch(h.format){case"dds":e="bin.dds";break;case"jpg":case"png":e=h.format}u.url+="."+e}t[i]=u}else be(t[i])&&Jn(e,t[i],r,n,o,s,a)}const Yn={"image/jpeg":"jpg","image/jpg":"jpg","image/png":"jpg","image/vnd-ms.dds":"dds","image/ktx":"jpg"};function eo(e,t,r){if(r&&r.length){const t=r[r.length-1],n=Yn[t];if(n)for(let t=0,r=e.length;t<r;t++){if(e[t].format===n)return e[t]}else console.error("i3s not find texture format type from:",Yn,"current textureEncoding:",t)}for(let r=0;r<=e.length;r++){const n=e[r].format;if("dds"===n&&t.hasExtension("WEBGL_compressed_texture_s3tc"))return e[r];if("jpg"===n||"png"===n)return e[r];if("ktx2"===n&&Zn)return e[r]}return null}const{Ajax:to}=He(),ro=new o.Coordinate(0,0),no=new o.Coordinate(0,0),oo=new Set,so=[],ao=new class{constructor(e,t){this.max=e,this.currentSize=0,this.data=new Map,this.onRemove=t}reset(e){if(this.data){const t=this.data.keys();for(const r of t){const t=this.data.get(r);e&&e!==t.renderer||this._remove(r,t)}}return e||(this.data=new Map,this.currentSize=0),this}clear(e){this.reset(e)}add(e,t){if(!t)return this;if(t.node&&t.node.memorySize&&(this.currentSize+=t.node.memorySize),this.has(e)){const r=this.data.get(e);r&&r.node&&r.node.memorySize&&(this.currentSize-=r.node.memorySize),this.data.delete(e),this.data.set(e,t)}else this.data.set(e,t);return this}shrink(){if(this.currentSize>this.max){const e=this.data.keys();let t=e.next();for(;this.currentSize>this.max&&void 0!==t.value;){const r=this.data.get(t.value);let n;r.current&&o.Util.warnOnce(`current maxGPUMemory(${this.max/1024/1024}) for Geo3DTilesLayer is not enough.`),r.current||(n=this.getAndRemove(t.value)),n&&this.onRemove(n),t=e.next()}}}has(e){return this.data.has(e)}keys(){const e=new Array(this.data.size);let t=0;const r=this.data.keys();for(const n of r)e[t++]=n;return e}getAndRemove(e){if(!this.has(e))return null;const t=this.data.get(e);return t.node&&t.node.memorySize&&(this.currentSize-=t.node.memorySize),this.data.delete(e),t}get(e){if(!this.has(e))return null;const t=this.data.get(e);return this.data.delete(e),this.data.set(e,t),t}remove(e){if(!this.has(e))return this;const t=this.data.get(e);return this._remove(e,t),this}_remove(e,t){t.node&&t.node.memorySize&&(this.currentSize-=t.node.memorySize),this.data.delete(e),this.onRemove(t)}setMaxSize(e){return this.max=e,this.shrink(),this}getMemorySize(){let e=0;const t=this.data.values();for(const r of t){const t=r&&r.node;t&&t.memorySize&&(e+=t.memorySize)}return e}markAll(e,t){const r=this.data.values();for(const n of r)e&&n.renderer!==e||(n.current=t)}}(1024*(o.Browser.mobile?32:1024)*1024,(e=>{const t=e.renderer;delete e.renderer,t.deleteTile(e)}));let io=0;class lo extends(r.MaskRendererMixin(r.CanvasCompatible(o.renderer.LayerAbstractRenderer))){constructor(e){super(e);const t=1024*e.options.maxGPUMemory*1024;t>ao.max&&ao.setMaxSize(t),this.tileCache=ao,io++,this.tilesLoading={},this._requests={},this._modelQueue=[],this._fnFetchNodepages=(...e)=>this._fetchI3DNodepages.call(this,...e)}getTilesInfo(){return this.painter.getTilesInfo()}getAnalysisMeshes(){if(!this.painter)return so;const e=this.painter.getPaintedMeshes();if(!e)return so;const t=[],{b3dmMeshes:r,pntsMeshes:n,i3dmMeshes:o}=e;return r.length&&Re(t,r.filter((e=>!(!e||!e.geometry)))),n.length&&Re(t,n.filter((e=>!(!e||!e.geometry)))),o.length&&Re(t,o.filter((e=>!(!e||!e.geometry)))),t}needToRedraw(){return!!this.getMap().isInteracting()||(!!this._modelQueue.length||super.needToRedraw())}getFrameTimestamp(){return this._timestamp}drawOnInteracting(e,t,r){this.draw(t,r)}draw(e,t){this._timestamp=e;const r=this.prepareCanvas();if(r&&!r.intersects(this.canvasExtent2D))return void this.completeRender();const{root:n,tiles:o}=this.layer.getTiles(),s=o.length;if(!o||!s)return void this.completeRender();this.painter.prepareRender(t),this._consumeI3SQueue(),this._consumeModelQueue(t);const{selectedTiles:a,requests:i}=this._selectTiles(n,o);i.length&&this.loadTiles(i),this._drawTiles(a,t),this._abortUnusedTiles(),i.length||this.completeRender()}_selectTiles(e,t){let r=[];this._markTiles();let n=0;const o=this._getLoadLimit(),s={};let a=!1,i=!1;for(let e=0;e<t.length;e++){const o=t[e],l=o.node;if(s[l.id])continue;s[l.id]=1;let c=!1;const h=this.getCachedTile(l.id);if(this._isLoadingTile(l.id)?(n++,c=i=!0,this.tilesLoading[l.id].current=!0):h?(this.getTileOpacity(h)<1&&(c=i=!0),a=!0,o.selected=!0,o.data=h):this.painter.has(l)||(c=i=!0,this.tileCache.currentSize<this.tileCache.max&&r.push(l)),!c)continue;if(this._selectParentTile(o))a=!0;else{this._selectChildTile(o).length&&(a=!0)}}const l=a?this._sortTiles(e):[];if(r.length>1&&(r.sort(co),o)){const e=o-n;r=e>0?r.slice(0,e):[]}return{loading:i,requests:r,selectedTiles:l}}_sortTiles(e){const t=[];let r,n;const o=[e],s=[];for(;o.length>0||s.length>0;){if(s.length>0){const e=s[s.length-1];if(e._stackLength===o.length){s.pop(),e===r&&(e.leave=!0),e.branchRootId=n,t.push(e),0===s.length&&(n=null);continue}}const e=o.pop(),a=e.children;if(e.selected)if("add"===e.node.refine)e.leave=!0,e.selectionDepth=s.length,e.branchRootId=n,t.push(e);else{if(e.selectionDepth=s.length,r=e,0===a.length){e.leave=!0,e.branchRootId=n,t.push(e);continue}0===s.length&&(n=e.node.id),s.push(e),e._stackLength=o.length}for(let e=0;e<a.length;e++)o.push(a[e])}return t}_selectParentTile(e){if(!e.parent)return null;let t=e.parent;for(;t&&t.level>=0;){const e=t.node.id;if(this.tileCache.has(e))return t.selected=!0,t.data=this.tileCache.get(e),t;t=t.parent}return null}_selectChildTile(e){const t=[];if(!e.node.children||!e.node.children.length)return t;const r=e._level+1,n=[e.node];for(;n.length>0;){const o=n.pop().children;for(let s=0,a=o.length;s<a;s++){if((!o[s].content||!o[s].content.url)&&o[s].children&&o[s].children.length){n.push(o[s]);continue}const a=o[s].id;if(this.tileCache.has(a)){const r=this.layer._createCandidate(o[s],e);r.selected=!0,r.data=this.tileCache.get(a),e.children.push(r),t.push(r)}else o[s]._level<=r&&n.push(o[s])}}return t}_drawTiles(e,t){this.tileCache.markAll(this,!1);const r=[];for(let t=0,n=e.length;t<n;t++){const n=e[t].data;n.current=!0,n.renderer=this,this.tileCache.add(e[t].node.id,n);const o=n.node,s=this.layer._getNodeService(o._rootIdx);o._boxMesh&&s.debug&&!Array.isArray(s.debug)&&r.push(o._boxMesh)}const n=this.layer.options.services;for(let e=0;e<n.length;e++){const t=n[e],o=Array.isArray(t.debug)&&t.debug;if(o)for(const e of o){const t=this.layer._getNodeBox(e),n=t&&t.node;n&&n._boxMesh&&r.push(n._boxMesh)}}const o={tiles:e};this.onDrawTileStart(o);const s=this.painter.paint(e,r,t);this.layer.fire("drawtiles",{count:s}),this.onDrawTileEnd(o),s&&this.layer.fire("canvasisdirty",{renderCount:s}),this.tileCache.shrink()}onDrawTileStart(){}onDrawTileEnd(){}loadTiles(e){for(let t=0,r=e.length;t<r;t++){const r=e[t];this.tilesLoading[r.id]={current:!0,node:r},this.loadTile(r)}}loadTile(e){let t=e.content.url;if(Ce(t)){const r=Ne(t);return this._loadTileContent(t,r,e),null}if(function(e){return e.indexOf("i3s:tileset")>=0}(t)){const r=e._rootIdx,n=this._i3sNodeCache[r];return new qn(t,r,n,this.layer,this._fnFetchNodepages).load().then((r=>{this.onTilesetLoad(r,e,t)}))}return e&&ke(t)&&!Wn(t)&&(t=e.baseUrl+t),this._loadTileContent(t,null,e),null}_loadTileContent(e,t,n){let o=this._supportedFormats;o||(o=r.reshader.Util.getSupportedFormats(this.gl||this.device&&this.device.wgpu),this._supportedFormats=o);const s=this.layer._getNodeService(n._rootIdx);s.isSuperMapiServer&&(e=function(e,t){const r=e.substring(t.length),n=r.split("/"),o=[];for(let e=0;e<n.length;e++)o.push(encodeURIComponent(n[e]));return t+o.join("/")}(e,n.baseUrl));const a={url:this.layer.getTileUrl(e,this.layer._roots[n._rootIdx]),arraybuffer:t,rootIdx:n._rootIdx,upAxis:n._upAxis,transform:n.matrix,supportedFormats:o};if(Wn(e)){const t=this._i3sNodeCache[n._rootIdx];if(a.projection=t.projection,a.i3sInfo=Xn(e,t,this.regl||this.device,this.layer.options.enableI3SCompressedGeometry,this.layer.options.forceI3SCompressedGeometry),!a.i3sInfo)return void this.onTileError({status:404},n,e)}a.service=me({},s),s.offset&&delete a.service.offset,a.referrer=window&&window.location.href,this.workerConn.loadTile(this.layer.getId(),a,((t,r)=>{if(t)return void this.onTileError(t,n,e);const{magic:o}=r;"b3dm"===o||"pnts"===o||"i3dm"===o||"cmpt"===o||"gltf"===o?this._modelQueue.push({data:r,tile:n}):this.onTilesetLoad(r,n,e)}))}_createBoxMesh(e){this.painter&&this.painter._createBoxMesh(e)}_deleteBoxMesh(e){this.painter&&this.painter._deleteBoxMesh(e)}_consumeModelQueue(){const e=this.getMap(),t=this.layer.options.meshLimitPerFrame;let r=0;for(;this._modelQueue.length&&(r<t||!e.isInteracting());){const{data:e,tile:t}=this._modelQueue.shift(),{magic:n}=e;"b3dm"===n||"gltf"===n?this.painter.createB3DMMesh(e,t.id,t,((r,{mesh:n})=>{this._onMeshCreated(e,t,r,n)})):"pnts"===n?this.painter.createPntsMesh(e,t.id,t,((r,{mesh:n})=>{this._onMeshCreated(e,t,r,n)})):"i3dm"===n?this.painter.createI3DMMesh(e,t.id,t,((r,{mesh:n})=>{this._onMeshCreated(e,t,r,n)})):"cmpt"===n&&this.painter.createCMPTMesh(e,t.id,t,((r,{mesh:n})=>{this._onMeshCreated(e,t,r,n)})),r++}}_onMeshCreated(e,t,r,n){if(this._enableLayerOpacity(n),r)this.onTileError(r,t);else{const r=this._getMeshSize(n);t.memorySize=r,this.onTileLoad(e,t)}}_enableLayerOpacity(e){if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(e[t])if(Array.isArray(e[t]))this._enableLayerOpacity(e[t]);else{const r=e[t].defines||{};r.HAS_LAYER_OPACITY=1,e[t].setDefines(r)}}else if(e)if(Array.isArray(e))this._enableLayerOpacity(e);else{const t=e.defines||{};t.HAS_LAYER_OPACITY=1,e.setDefines(t)}}_getMeshSize(e){let t=0;if(Array.isArray(e))for(let r=0;r<e.length;r++)e[r]&&(t+=this._getMeshSize(e[r]));else e&&(t+=e.getMemorySize());return t}onTileLoad(e,t){this.layer&&(delete this.tilesLoading[t.id],this.layer.onTileLoad(e,t),this._addTileToCache(t),this.setToRedraw(),this.layer.fire("tileload",{node:t}))}onTilesetLoad(e,t,r){this.layer&&(this.layer._vertexCompressionType=e.extensions&&e.extensions["s3m:VertexCompressionType"],e.capabilities||e.layers&&e.layers[0]&&e.layers[0].capabilities?this._parseI3SSceneLayer(e,t,r):(delete this.tilesLoading[t.id],this.layer.onTilesetLoad(e,t,r)))}onTileError(e,t,r){if(!this.layer)return;const n=r||t.content.url,s=e&&e.message||e;e&&(404===e.status||204===e.status)||oo.has(s)||(console.warn("failed to load 3d tile: "+n),console.warn(e),oo.add(s)),delete this.tilesLoading[t.id],(!this.layer.options.onlyCacheNoContentTileWhenError||e&&!o.Util.isNoContentHttpCode(e.status))&&this._addErrorToCache(t,e),this.layer.fire("tileerror",{node:t,error:e})}getCachedTile(e){return this.tileCache.get(e)}getShadowMeshes(){if(!this.painter)return[];const e=[],t=this.painter.getCurrentB3DMMeshes();for(const r in t)t[r]&&t[r].isValid&&t[r].isValid()&&e.push(t[r]);const r=this.painter.getCurrentI3DMMeshes();for(const t in r)r[t]&&r[t].isValid&&r[t].isValid()&&e.push(r[t]);return e}_addErrorToCache(e,t){const r={loadTime:o.Util.now(),current:!0,error:t,node:e};r.renderer=this,this.tileCache.add(e.id,r)}_addTileToCache(e){const t={loadTime:o.Util.now(),current:!0,node:e};t.renderer=this,this.tileCache.add(e.id,t)}abortTileLoading(e){if(!e||!this.workerConn)return;const t=e.node.content.url;this.workerConn.abortTileLoading(this.layer.getId(),t),delete this._requests[t]}_markTiles(){if(this.tilesLoading)for(const e in this.tilesLoading)this.tilesLoading[e].current=!1}deleteTile(e){this.painter.deleteTile(e)}initContext(){super.initContext();const e=this.layer,{regl:t,reglGL:r,device:n}=this.context;this.regl=t,this.device=n,this.gl=r;const o=t||n;this.prepareWorker(),this.canvas.pickingFBO=this.canvas.pickingFBO||o.framebuffer(this.canvas.width,this.canvas.height),this.pickingFBO=this.canvas.pickingFBO||o.framebuffer(this.canvas.width,this.canvas.height),this.painter=new Hn(o,e),this.layer._resumeHighlights(),this.layer.fire("contextcreate",{regl:t,device:n})}prepareWorker(){const e=this.getMap();this.workerConn||(this.workerConn=new je("@maptalks/3dtiles",e.id,r.reshader.Util.supportNPOT(this.regl||this.device)));const t=this.workerConn;if(!t.isActive())return;let n=this.layer.options||{};n=me({},n),delete n.offset;const o=e.options.spatialReference;n.projection=o&&o.coordType||o&&o.projection||e.getSpatialReference().getProjection().code;const s=this.layer.getId();t.addLayer(s,n,(e=>{if(e)throw e;this.layer&&(this.ready=!0,this.layer.fire("workerready"))}))}onRemove(){this.painter&&this.painter.remove(),this.pickingFBO&&(this.canvas.pickingFBO||this.pickingFBO.destroy(),delete this.pickingFBO),this.workerConn&&(this.workerConn.removeLayer(this.layer.getId(),(e=>{if(e)throw e})),this.workerConn.remove(),delete this.workerConn),io--,io||ao.reset(),this.clear(),delete this.tileCache,delete this.gl,delete this.regl,super.onRemove()}clear(){this._abortUnusedTiles(!0),this.tileCache.reset(this),this.tilesLoading={},super.clear()}getTileOpacity(){return 1}getStencilValue(){return 0}_abortUnusedTiles(e){this._preRetireTime||(this._preRetireTime=Date.now());const t=Date.now();if(!e&&t-this._preRetireTime<this.layer.options.retireInterval)return;this._preRetireTime=t;const r=[];for(const t in this.tilesLoading){const n=this.tilesLoading[t];!e&&n.current||(r.push(t),this.abortTileLoading(n))}for(let e=0;e<r.length;e++)delete this.tilesLoading[r[e]]}_getLoadLimit(){return this.getMap().isInteracting()?this.layer.options.loadingLimitOnInteracting:this.layer.options.loadingLimit}_createGLContext(e,t){const r=["webgl","experimental-webgl"];let n=null;for(let o=0;o<r.length;++o){try{n=e.getContext(r[o],t)}catch(e){}if(n)break}return n}_isLoadingTile(e){return!!this.tilesLoading[e]}getI3DMMeshes(){return this.painter.getI3DMMeshes()}getPNTSMeshes(){return this.painter.getPNTSMeshes()}getB3DMMeshes(){return this.painter.getB3DMMeshes()}readBatchData(e,t,r){return Zt(e,t,0,r)}_consumeI3SQueue(){if(!this._i3sRequests)return;const e=this.layer.options.i3sNodepageLimitPerFrame||Number.MAX_VALUE;let t=0;const r=[];for(const n in this._i3sRequests){const o=this._i3sRequests[n];if("pending"===o.status)continue;o.status="pending";const s=o.rootIdx,a=Be(this.layer._getNodeService(s).fetchOptions);if(r.push(to.getJSON(n,a).then((e=>{delete this._i3sRequests[n];const t=this._i3sNodeCache[s];if(t){e.nodes?jn(t,e.nodes):(t[e.id]=e,jn(t,e.children));for(let e=0;e<o.length;e++)o[e]();this.setToRedraw()}else this.setToRedraw()}))),t++,t>=e)break}r.length&&Promise.all(r)}_fetchI3DNodepages(e,t,r){this._i3sRequests||(this._i3sRequests={}),this._i3sRequests[t]=this._i3sRequests[t]||[],this._i3sRequests[t].rootIdx=e,this._i3sRequests[t].push(r),this.setToRedraw()}_parseI3SSceneLayer(e,t,r){this._i3sNodeCache||(this._i3sNodeCache=[]);const n=t._rootIdx;this._i3sNodeCache[n]||(this._i3sNodeCache[n]={});const o=this._i3sNodeCache[n],s=this.layer._getNodeService(n);e.layers&&(e=e.layers[0],"/"!==r[r.length-1]&&(r+="/"),r+="layers/0"),o.version=+(s.i3sVersion||e.store.version),!e.spatialReference||e.spatialReference.wkid&&4326===e.spatialReference.wkid||console.warn("i3s has a spatialReference other than 4326.",e.spatialReference),e.spatialReference&&4490===e.spatialReference.wkid&&(console.warn("i3s spatialReference is 4490,auto set spatialReference to 4326,This may cause some location issues, please ensure that your service is 4326"),e.spatialReference.wkid=4326),o.projection=e.spatialReference,function(e,t,r,n,o,s,a){if(!s.layerScene){s.layerScene=t,s.nodesPerPage=t.nodePages&&t.nodePages.nodesPerPage||64,s.lodSelectionMetricType=t.nodePages&&t.nodePages.lodSelectionMetricType;let e=o;if(s.layerScene.eslpk=e.indexOf("3dSceneLayer.json")>=0,e.endsWith(".json")){const t=o.lastIndexOf("/");e=t<0?"./":o.substring(0,t)}s.layerScene.baseUrl=function(e){return e.split("?")[0]}(e)}return new qn(o,r,s,e,a).load()}(this.layer,e,n,0,r,o,this._fnFetchNodepages).then((e=>{this.onTilesetLoad(e,t,r)}))}pick(e,t,r){if(!this.painter)return[];const n=this.pickingFBO,{width:o,height:s}=this.canvas;return!this.pickingFBO||n.width===o&&n.height===s||n.resize(o,s),this.painter.pick(e,t,r&&r.tolerance)}highlight(e){if(this._highlighted||(this._highlighted=[]),Array.isArray(e))for(let t=0;t<e.length;t++){const r=e[t].service||0;let n=this._highlighted[r];n||(n=this._highlighted[r]=new Map),n.set(e[t].id,e[t])}else{const t=e.service||0;let r=this._highlighted[t];r||(r=this._highlighted[t]=new Map),r.set(e.id,e)}this.painter.highlight(this._highlighted)}cancelHighlight(e,t){if(!this._highlighted)return;const r=this._highlighted[e];if(r){if(Array.isArray(t))for(let e=0;e<t.length;e++)r.delete(t[e]);else r.delete(t);r.size||(this._highlighted[e]=null),this.painter.highlight(this._highlighted)}}cancelAllHighlight(){delete this._highlighted,this.painter.cancelAllHighlight()}showOnly(e){if(this._showOnlys||(this._showOnlys=[]),Array.isArray(e))for(let t=0;t<e.length;t++){const r=e[t].service||0;let n=this._showOnlys[r];n||(n=this._showOnlys[r]=new Map),n.set(e[t].id,e[t])}else{const t=e.service||0;let r=this._showOnlys[t];r||(r=this._showOnlys[t]=new Map),r.set(e.id,e)}this.painter.showOnly(this._showOnlys)}cancelShowOnly(){delete this._showOnlys,this.painter.cancelShowOnly()}_getCurrentBatchIDs(){return this.painter?this.painter._getCurrentBatchIDs():[]}_tileCoordToLngLat(e,t){const r=this.getMap();if("identity"===r.getProjection().code.toLowerCase()){const r=this._getCoordProjection();return ro.set(t[0],t[1]),r.unproject(ro,no),e[0]=no.x,e[1]=no.y,e}return ro.set(t[0],t[1]),r.getProjection().unproject(ro,no),e[0]=no.x,e[1]=no.y,e}_lngLatToIdentityCoord(e,t){const r=this._getCoordProjection();return ro.set(t[0],t[1]),r.project(ro,no),e[0]=no.x,e[1]=no.y,e}_identityCoordToLngLat(e,t){const r=this._getCoordProjection();return ro.set(t[0],t[1]),r.unproject(ro,no),e[0]=no.x,e[1]=no.y,e}_getCoordProjection(){const e=this.getMap().options.spatialReference.coordType;if(!e)throw new Error("Missing coordType in map spatialReference.");return this._centerProjection||(this._centerProjection=o.SpatialReference.getProjectionInstance(e)),this._centerProjection}}function co(e,t){return e._cameraDistance-t._cameraDistance}function ho(e,t,r){return e[0]=t[r],e[1]=t[r+3],e[2]=t[r+6],e}function uo(e,t,r){return Math.sqrt(function(e,t,r){const n=Ye(fo,r,e),o=ho(po,t,0),s=ho(go,t,1),a=ho(mo,t,2),i=it(o),l=it(s),c=it(a);rt(o,o),rt(s,s),rt(a,a);const h=_o;h[0]=nt(n,o),h[1]=nt(n,s),h[2]=nt(n,a);let u,f=0;h[0]<-i?(u=h[0]+i,f+=u*u):h[0]>i&&(u=h[0]-i,f+=u*u);h[1]<-l?(u=h[1]+l,f+=u*u):h[1]>l&&(u=h[1]-l,f+=u*u);h[2]<-c?(u=h[2]+c,f+=u*u):h[2]>c&&(u=h[2]-c,f+=u*u);return f}(e,t,r))}const fo=[],po=[],go=[],mo=[],_o=[];const bo=2*Math.PI;class yo{constructor(e,t,r,n){this.west=e,this.south=t,this.east=r,this.north=n}static contains(e,t){let r=t[0];const n=t[1],o=e.west;let s=e.east;return s<o&&(s+=bo,r<0&&(r+=bo)),(r>o||Ht(r,o,1e-14))&&(r<s||Ht(r,s,1e-14))&&n>=e.south&&n<=e.north}static southwest(e,t){return t[0]=e.west,t[1]=e.south,t[2]=0,t}static northeast(e,t){return t[0]=e.east,t[1]=e.north,t[2]=0,t}static southeast(e,t){return t[0]=e.east,t[1]=e.south,t[2]=0,t}static northwest(e,t){return t[0]=e.west,t[1]=e.north,t[2]=0,t}}const To=[0,0,1];function vo(e,t){return Ot(t,e[0],e[1],e[2])}class Mo{constructor(e,t){this.normal=r.vec3.copy([],e),this.distance=t}static fromPointNormal(e,t,n){const o=-r.vec3.dot(t,e);return r.vec3.copy(n.normal,t),n.distance=o,n}}const wo=[],xo=[],Oo=[],So=[],Io=[],Ao=[],Co=[],No=[],Ro=[],Lo=[],Eo=new Mo([1,0,0],0),Po=[];class ko{constructor(e){this.southwestCornerCartesian=[],this.northeastCornerCartesian=[],this.westNormal=[],this.eastNormal=[],this.southNormal=[],this.northNormal=[],this.rectangle=new yo(...e),this.minimumHeight=e[4],this.maximumHeight=e[5],this.computeBox(this.rectangle)}distanceToCamera(e,t){let n=0;if(!yo.contains(this.rectangle,t)){const t=this.southwestCornerCartesian,o=this.northeastCornerCartesian,s=this.westNormal,a=this.southNormal,i=this.eastNormal,l=this.northNormal,c=r.vec3.subtract(Po,e,t),h=r.vec3.dot(c,s),u=r.vec3.dot(c,a),f=r.vec3.subtract(Po,e,o),d=r.vec3.dot(f,i),p=r.vec3.dot(f,l);h>0?n+=h*h:d>0&&(n+=d*d),u>0?n+=u*u:p>0&&(n+=p*p)}const o=t[2],s=this.minimumHeight,a=this.maximumHeight;if(o>a){const e=o-a;n+=e*e}else if(o<s){const e=s-o;n+=e*e}return Math.sqrt(n)}computeBox(e){const t=this;vo(yo.southwest(e,xo),t.southwestCornerCartesian),vo(yo.northeast(e,xo),t.northeastCornerCartesian),wo[0]=e.west,wo[1]=.5*(e.south+e.north),wo[2]=0;const n=vo(wo,Oo),o=r.vec3.cross(Io,n,To);r.vec3.normalize(t.westNormal,o),wo[0]=e.east;const s=vo(wo,No),a=r.vec3.cross(Io,To,s);r.vec3.normalize(t.eastNormal,a);const i=r.vec3.subtract(Io,n,s),l=r.vec3.normalize(So,i),c=e.south;let h;if(c>0){wo[0]=.5*(e.west+e.east),wo[1]=c;const n=vo(wo,Ro);r.vec3.copy(Lo,l);const o=Mo.fromPointNormal(t.southwestCornerCartesian,t.westNormal,Eo);Bo(Ro,Lo,o,t.southwestCornerCartesian),h=Dt(n,Ao)}else h=Ut(yo.southeast(e,xo),Ao);const u=r.vec3.cross(Co,h,i);r.vec3.normalize(t.southNormal,u);const f=e.north;let d;if(f<0){wo[0]=.5*(e.west+e.east),wo[1]=f;const n=vo(wo,Ro);r.vec3.scale(Lo,l,-1);const o=Mo.fromPointNormal(t.northeastCornerCartesian,t.eastNormal,Eo);Bo(Ro,Lo,o,t.northeastCornerCartesian),d=Dt(n,Ao)}else d=Ut(yo.northwest(e,xo),Ao);const p=r.vec3.cross(Co,i,d);r.vec3.normalize(t.northNormal,p)}}function Bo(e,t,n,o){const s=e,a=t,i=n.normal,l=r.vec3.dot(i,a);if(Math.abs(l)<1e-15)return;const c=(-n.distance-r.vec3.dot(i,s))/l;return c<0?void 0:(o=r.vec3.scale(o,a,c),r.vec3.add(o,s,o))}function Do(e){return[e.xmin,e.ymin,e.xmax,e.ymax]}const Uo=o.BBOXUtil,Fo={"services":[],"maxGPUMemory":o.Browser.mobile?32:1536,"retireInterval":2e3,"loadingLimitOnInteracting":5,"loadingLimit":10,"debug":!1,"meshLimitPerFrame":2,"i3sNodepageLimitPerFrame":1,"enableI3SCompressedGeometry":!0,"forceI3SCompressedGeometry":!0,"onlyCacheNoContentTileWhenError":!0,"picking":!0,"pickingPoint":!0,"geometryEvents":!1,"alwaysShowTopTiles":!0,"antialias":!1,"offset":[0,0],"renderer":"gl","forceRenderOnZooming":!0,"forceRenderOnRotating":!0,"forceRenderOnMoving":!0,"optionalExtensions":["ANGLE_instanced_arrays","OES_element_index_uint","OES_standard_derivatives","OES_vertex_array_object","OES_texture_half_float","OES_texture_half_float_linear","OES_texture_float","OES_texture_float_linear","WEBGL_depth_texture","EXT_shader_texture_lod","WEBGL_compressed_texture_astc","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb"]},Ho=[0,0,0],Go=[0,0,0],jo=[0,0,0],zo=[0,0,0],qo=[0,0,0],Vo=[0,0,0],Zo=[0,0,0],$o=[1,1,1],Qo=[1,1,1],Wo=[0,0,0,0],Ko=[],Xo=new o.Coordinate(0,0),Jo=new o.Point(0,0),Yo=[0,0,0,0,0,0,0,0,0],es=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ts=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],rs=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],ns=new o.Point(0,0),os=r.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),ss=[0,0],as=[0,0,0],is=[1,1,1],ls=[0,0,0],cs=[0,0,0],hs=[0,0,0,0],us=[1,1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,-1,-1,-1,-1,-1,-1,1,-1];class fs extends(r.MaskLayerMixin(o.Layer)){static fromJSON(e){return e&&"Geo3DTilesLayer"===e.type?new fs(e.id,e.options):null}static getEnuTransform(e,t=[1,1,1],n=[0,0,0]){const o=Ot([],e[0]*Math.PI/180,e[1]*Math.PI/180,e[2]||0),s=ur(o,null,[]),a=r.quat.fromEuler([0,0,0,0],...n),i=r.mat4.fromRotationTranslationScale([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],a,[0,0,0],t);return r.mat4.multiply(i,s,i)}constructor(e,t){super(e,t),this.isGeo3DTilesLayer=!0,this._initRoots(),this._nodeBoxes=new Map}_initRoots(){const e=this.options.services.map((e=>e.url));this._rootMap=this._rootMap||{},this._roots=this._roots||[];for(let t=0;t<e.length;t++){const r=e[t];let n=this._rootMap[r];void 0===n&&(n=this._rootMap[r]=this._roots.length),this._roots[n]=gs(r,n,this.options.services[t])}this.fire("rootready",{roots:this._roots.slice(0)})}showService(e){return this.updateService(e,{visible:!0}),this}hideService(e){return this.updateService(e,{visible:!1}),this}setToRedraw(){return this._setToRedraw(),this}addService(e){return this.options.services=this.options.services||[],this.options.services.push(e),this._initRoots(),this._setToRedraw(),this}updateService(e,t){if(!t)return this;const r=this.options.services;let n=!1;r&&r[e]&&(n=!(bs(r[e].coordOffset,t.coordOffset)&&bs(r[e].heightOffset,t.heightOffset)&&bs(r[e].scale,t.scale)&&bs(r[e].rotation,t.rotation)),me(r[e],t));const o=r[e].url,s=this._rootMap[o],a=this._roots&&this._roots[s];return a&&(ge(t.visible)||(a.visible=t.visible),n&&a.version++),this._setToRedraw(),this}removeService(e){const t=this.options.services;if(t&&t[e]){const r=t[e].url,n=this._rootMap[r];this._roots[n]&&(this._roots[n]=null),delete this._rootMap[r],t.splice(e,1)}return this._setToRedraw(),this}_getTilesInfo(){const e=this.getRenderer();return e&&e.getTilesInfo()}getTileUrl(e,t){const r=t&&t.service&&t.service.subdomains;if(r&&t.domainKey){const n=r.length;if(n){const o=[...e].reduce(((e,t)=>e+t.charCodeAt(0)),0)%n;return e.replace(t.domainKey,r[o])}}return e}getExtent(e){if(!e&&0!==e){const e=new o.Extent;for(let t=0;t<this._roots.length;t++){const r=this._roots[t];if(r&&r.boundingVolume){const t=this.boundingVolumeToExtent(r);e._combine(t)}}return e}const t=this._roots[e];return t&&t.boundingVolume?this.boundingVolumeToExtent(t):null}boundingVolumeToExtent(e){const t=e.boundingVolume._centerTransformed?os:e.matrix,n=this.getMap(),s="identity"===n.getProjection().code.toLowerCase(),a=this.getRenderer();if(e.boundingVolume.region){const t=e.boundingVolume.region;return new o.Extent(ve(t[0]),ve(t[1]),ve(t[2]),ve(t[3]))}if(e.boundingVolume.sphere){const i=e.boundingVolume.sphere,l=Rt([],r.vec3.transformMat4([0,0,0],i,t));s&&a._lngLatToIdentityCoord(l,l);const c=i[3],h=n.locate(l,-c,c),u=n.locate(l,c,-c);return new o.Extent(h,u)}if(e.boundingVolume.box){const i=e.boundingVolume.box,l=r.vec3.transformMat4([0,0,0],i,t),c=new o.Coordinate(Rt([],l));s&&a._lngLatToIdentityCoord(c,c);const h=i.slice(3);r.mat3.multiply(h,r.mat3.fromMat4([0,0,0,0,0,0,0,0,0],e.matrix),h);const u=r.vec3.length(h.slice(0,3)),f=r.vec3.length(h.slice(3,6)),d=r.vec3.length(h.slice(6,9)),p=Math.max(u,f,d),g=n.locate(c,-p,p),m=n.locate(c,p,-p);return new o.Extent(g,m)}return null}getRootTiles(){return this._roots}getTiles(){const e=this.getRenderer();if(!e.ready)return this._setToRedraw(),{tiles:Ko};const t=this.getMap(),n=t.cameraPosition,o=t.pointAtResToDistance(n[2],0,t.getGLRes()),s=this._getCameraLonLat(n);this._cameraLocation=this._cameraLocation||[0,0,0],r.vec3.set(this._cameraLocation,Te(s.x),Te(s.y),o),this._cameraCartesian3=Ot(this._cameraCartesian3||[],this._cameraLocation[0],this._cameraLocation[1],this._cameraLocation[2]),this._fovDenominator=2*Math.tan(.5*Te(t.getFov()));const a=t.projViewMatrix;let i;if(t.getPitch()<=80){const e=t.getExtent(),r=e.getWidth()/2,n=e.getHeight()/2;e.xmin-=r,e.ymin-=n,e.xmax+=r,e.ymax+=n,i=Do(e)}const l=(this.getMasks()||[]).filter((e=>e&&e instanceof r.ClipOutsideMask));l.forEach((e=>{if(!e.maskGeoJSON&&e.toGeoJSON)try{e.maskGeoJSON=e.toGeoJSON();const t=e.getExtent();e.maskGeoJSON.bbox=Do(t)}catch(e){console.error(e)}}));const c={children:[],level:-1},h=[];for(let t=0;t<this._roots.length;t++){const r=this._roots[t];if(!r||!r.visible)continue;const n=r.service,o=[r],s=this._getRootMaxExtent(t);for(;o.length>0;){const t=o.pop();t.id||this._initNode(t);const r=this._isVisible(t,s,a,i,l);t.service=n;let u=t.parent;for(;u&&!u.content&&u.parent;)u=u.parent;const f=u&&u._candidateNode||c;if(!(r===ys.VISIBLE||r!==ys.OUT_OF_FRUSTUM&&this.options.alwaysShowTopTiles&&_s(t))){r===ys.SCREEN_ERROR_TOO_SMALL&&u&&f.content&&this._addCandidateNode(h,f);continue}t._cameraDistance<1/0&&this._updateParentDistance(t);const d=this._createCandidate(t,f);f.children.push(d);const p=t.children,g=p&&p.length,m=d.content;if(m&&(!g||r===ys.SCREEN_ERROR_TOO_SMALL)&&this._addCandidateNode(h,d),r!==ys.SCREEN_ERROR_TOO_SMALL&&g){m&&"add"===t.refine&&this._addCandidateNode(h,d);const r=p[0].parent;let n=!1;for(let s=0,a=p.length;s<a;s++){if(r){const t=e.getCachedTile(p[s].id);if(t&&t.error&&404!==t.error.status)continue;n=!0}else{n=!0,p[s].parent=t,p[s]._upAxis=t._upAxis,p[s].baseUrl=t.baseUrl;const e=p[s].content&&(p[s].content.url||p[s].content.uri);e&&(Ce(e)||e.indexOf("i3s:")>=0?p[s].baseUrl=t.baseUrl:ke(e)?p[s].content.url=t.baseUrl+e:p[s].baseUrl=e.substring(0,e.lastIndexOf("/")+1))}o.push(p[s])}!n&&m&&this._addCandidateNode(h,d)}}}return{root:c,tiles:h}}_addCandidateNode(e,t){const{viewerRequestVolume:r,matrix:n}=t.node;r&&!function(e,t,r,n){if(r.region){const t=r.region;if(e[0]>=t[0]&&e[0]<=t[2]&&e[1]>=t[1]&&e[1]<=t[3])return!0}else{if(r.sphere)return ds(r,t,n)<=0;if(r.box)return 0===ps(r,t,n)}return!1}(this._cameraLocation,this._cameraCartesian3,r,n)||e.push(t)}_createCandidate(e,t){const r={id:e.id,node:e,children:[],level:e._level,parent:t,content:e.content&&e.content.url};return e._candidateNode=r,r}_initNode(e){const t=this.getId();e.id=t+":"+o.Util.GUID(),e.matrix=e.transform||r.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),e._empty=this._isEmpty(e),e.parent&&(function(e){return e.content&&e.content.uri&&e.content.uri.indexOf("i3s:")>=0}(e)||(e.matrix=r.mat4.multiply(e.matrix,e.parent.matrix,e.matrix)),e._rootIdx=e.parent._rootIdx,void 0===e._level&&(e._level=e.parent._level+1),e.maxExtent=e.parent.maxExtent),e.refine=e.refine&&e.refine.toLowerCase()||"replace",e.content&&!e.content.url&&e.content.uri&&(e.content.url=e.content.uri)}_getNodeService(e){return this._roots[e].service}_offsetBoundingVolume(e){const t=e.boundingVolume;if(!t||t._centerTransformed&&!this._offsetChanged(e))return;const n=this._getNodeService(e._rootIdx),o=n.heightOffset||0,s=this.options.offset,a=_e(s)||s[0]||s[1],i=n.coordOffset||ss;if(!Array.isArray(i))throw new Error("service.coordOffset must be an array");if(!t._centerTransformed&&(!e.boundingVolume||!o&&0!==o&&r.mat4.exactEquals(e.matrix,os)&&!a&&i===ss))return;t.box&&t.region&&delete t.region;const{region:l,box:c,sphere:h}=t;if(t.coordOffset=[i[0],i[1]],t.heightOffset=o,l){t.originalVolume||(t.originalVolume=l.slice(0));const e=t.originalVolume,r=this._offsetCenter([ve(e[0]),ve(e[1])]);l[0]=Te(r.x+i[0]),l[1]=Te(r.y+i[1]);const n=this._offsetCenter([ve(e[2]),ve(e[3])]);l[2]=Te(n.x+i[0]),l[3]=Te(n.y+i[1]),l[4]=e[4]+o+(i[2]||0),l[5]=e[5]+o+(i[2]||0)}else if(c||h){t.originalVolume||(t.originalVolume=(c||h).slice(0));const n=c||h,s=t.originalVolume,a=r.vec3.transformMat4(Ho,s,e.matrix),l=Rt(Go,a),u=this._offsetCenter([l[0]+i[0],l[1]+i[1]]);l[0]=u.x,l[1]=u.y,l[2]+=o+(i[2]||0),Ot(n,Te(l[0]),Te(l[1]),l[2])}t._centerTransformed=!0;try{e.extent=this.boundingVolumeToExtent(e)}catch(e){console.error(e)}}_offsetChanged(e){const t=e.boundingVolume,r=this._getNodeService(e._rootIdx),n=r.heightOffset||0,o=r.coordOffset||ss;return t.coordOffset[0]!==o[0]||t.coordOffset[1]!==o[1]||t.heightOffset!==n}_isEmpty(e){return void 0===e.geometricError||!e.boundingVolume}_updateParentDistance(e){let t=e.parent;for(;t&&t._empty&&!(t._cameraDistance<=e._cameraDistance);)t._cameraDistance=e._cameraDistance,t=t.parent}onTileLoad(e,t){if(e.children&&(!t.children||!t.children.length)){t.children=e.children;const r=t.content.url;t.baseUrl=r.substring(0,r.lastIndexOf("/")+1),this._setToRedraw()}}onTilesetLoad(e,t,n){if(!e)return void console.warn("invalid tileset at : "+n);const o=(e.asset&&e.asset.gltfUpAxis||t&&t._upAxis||"Y").toUpperCase();e.root.baseUrl=n.substring(0,n.lastIndexOf("/")+1);const s=n.indexOf("realspace/")>-1;0===t._level&&e.asset&&e.asset.s3mType&&s&&(e.root.baseUrl+="data/path/");const a=e.asset.i3s;if(e.root._upAxis=o,t){const n=t.boundingVolume,o=t._notLoaded;o&&delete t._notLoaded,me(t,e.root),t.refine=t.refine&&t.refine.toLowerCase()||"replace",n&&(t.boundingVolume=n);let s=e.root.transform;if(o){const e=this._getNodeService(t._rootIdx);e.ecefTransform&&(s=r.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],e.ecefTransform,s||os))}s&&(t.parent?a||(t.matrix=r.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.parent.matrix,s)):t.matrix=r.mat4.multiply([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],t.matrix,s)),delete t.content,e.root.content&&(t.content=e.root.content),t._empty=this._isEmpty(t);const i=t.content&&(t.content.url||t.content.uri);i&&t.content.uri&&(t.content.url=t.content.uri,delete t.content.uri),!a&&i&&!Ce(i)&&ke(i)&&(t.content.url=t.baseUrl+i),e.root&&!t.parent&&this._updateRootCenter(t)}this._setToRedraw(),this.fire("loadtileset",{tileset:e,index:t&&t._rootIdx,url:n})}_isTileInMasks(e,t,r){if(!e.extent||!Uo)return!0;const n=e.extent;if(hs[0]=n.xmin,hs[1]=n.ymin,hs[2]=n.xmax,hs[3]=n.ymax,t){if(!Uo.bboxIntersect(hs,t))return!1}if(r.length){for(let e=0,t=r.length;e<t;e++){const t=r[e].maskGeoJSON;if(!t||!t.bbox||Uo.bboxInMask(hs,t))return!0}return!1}return!0}_isVisible(e,t,r,n,o){if(e._cameraDistance=1/0,0===e._level||e._empty)return this._updateRootCenter(e),ys.VISIBLE;if(this._offsetBoundingVolume(e),!this._isTileInMasks(e,n,o))return ys.OUT_OF_FRUSTUM;if(!this._isTileInFrustum(e,t,r))return ys.OUT_OF_FRUSTUM;if(0===e.geometricError)return ys.VISIBLE;let s=this._getNodeService(e._rootIdx).maximumScreenSpaceError;null==s&&(s=16);let a=this._getScreenSpaceError(e);return 0===a&&e.parent&&(a=.5*(e.parent._error||0)),a>=s?ys.VISIBLE:ys.SCREEN_ERROR_TOO_SMALL}_coordToPoint(e,t){t||(t=new o.Point(0,0));const r=this.getMap();return r.coordToPointAtRes(e,r.getGLRes(),t)}_isTileInFrustum(e,t,r){const n=this.getRenderer(),o=e.id,{boundingVolume:s}=e,a=s.sphere,i=this._updateNodeBoxIfNeeded(e);this._getNodeService(e._rootIdx).debug&&(this._nodeBoxes.get(o).node=e,n._createBoxMesh(e));const c=i.obbox;return c?function(e,t,r){M(e);for(var n=0;n<6;n++)if(!v(l[n],t))return!1;return!0}(r,c):!!a&&function(e,t,r){M(e);for(var n=t[0],o=-t[1],s=0;s<6;s++)if(x(l[s],n)<o)return!1;return!0}(r,i.sphereBox)}_updateNodeBoxIfNeeded(e){const t=e.id;let r=this._nodeBoxes.get(t);const{boundingVolume:n}=e,o=n.region,s=n.box,a=n.sphere,i=this._getRootNode(e._rootIdx);if((!r||r.version!==i.version)&&(o?r=this._createRegionBox(e):s?r=this._createBBox(e):a&&(r=this._createSphere(e)),r&&this._nodeBoxes.set(t,r),r.version=i.version,e._boxMesh)){this.getRenderer()._deleteBoxMesh(e._boxMesh),delete e._boxMesh}return r}_createRegionBox(e){const t=this.getMap(),n=t.getGLRes(),s=e.boundingVolume.region;let{ws:a,en:i}=function(e){const t=e[0],r=e[1],n=e[2],o=e[3],s=e[4],a=e[5],i=Ot([],t,r,s),l=Ot([],n,o,a),c=Rt(i,i),h=Rt(l,l);return{ws:c,en:h}}(s);a=new o.Coordinate(a),i=new o.Coordinate(i);const l=t.coordToPointAtRes(a,n);l.z=t.altitudeToPoint(a.z,n);const c=t.coordToPointAtRes(i,n);c.z=t.altitudeToPoint(i.z,n);const h=[c.x,l.y,c.z,c.x,c.y,c.z,l.x,c.y,c.z,l.x,l.y,c.z,c.x,l.y,l.z,c.x,c.y,l.z,l.x,c.y,l.z,l.x,l.y,l.z],u=[(h[0]+h[18])/2,(h[1]+h[19])/2,(h[2]+h[20])/2],f=this._getRootNode(e._rootIdx);e!==f||f._bboxCenter||(f._bboxCenter=u);const d=this._getServiceTransform([],e),p=r.mat4.exactEquals(os,d);if(!p){r.vec3.transformMat4(u,u,d);const e=Ho;for(let t=0;t<h.length;t+=3){let n=r.vec3.set(e,h[t],h[t+1],h[t+2]);p||(n=r.vec3.transformMat4(n,n,d)),h[t]=n[0],h[t+1]=n[1],h[t+2]=n[2]}}const g=t.pointAtResToCoord(new o.Point(u),n);g.z=(a.z+i.z)/2;const m=this._generateOBBox(h,u);for(let e=0;e<h.length;e++)h[e]-=u[e%3];return{obbox:m,boxPosition:h,boxCenter:u,boxCoord:g}}_createBBox(e){const t=this.getRenderer(),n=this.getMap(),o="identity"===n.getProjection().code.toLowerCase(),s=n.getGLRes(),{boxCenter:a,boxCoord:i}=this._calBoxCenter(e),l=e.boundingVolume.box,c=function(e,t,r){return function(e,t,r,n,o,s,a,i,l,c,h,u,f,d,p,g,m){return e[0]=t||0,e[1]=s||0,e[2]=c||0,e[3]=0,e[4]=r||0,e[5]=a||0,e[6]=h||0,e[7]=0,e[8]=n||0,e[9]=i||0,e[10]=u||0,e[11]=0,e[12]=o||0,e[13]=l||0,e[14]=f||0,e[15]=m,e}(e,t[0],t[3],t[6],r[0],t[1],t[4],t[7],r[1],t[2],t[5],t[8],r[2],0,0,0,1)}([],this._createHalfAxes(l,e.matrix),l),h=this._getServiceTransform([],e),u=r.mat4.exactEquals(os,h);u||r.vec3.transformMat4(a,a,h);const f=[],d=Ho;for(let e=0;e<us.length;e+=3){d[0]=us[e],d[1]=us[e+1],d[2]=us[e+2],r.vec3.transformMat4(d,d,c),Rt(d,d),o&&t._lngLatToIdentityCoord(d,d);const a=Xo.set(d[0],d[1],d[2]);n.coordToPointAtRes(a,s,Jo);let i=r.vec3.set(d,Jo.x,Jo.y,n.altitudeToPoint(a.z,s));u||(i=r.vec3.transformMat4(i,i,h)),f[e]=i[0],f[e+1]=i[1],f[e+2]=i[2]}const p=this._generateOBBox(f,a);for(let e=0;e<f.length;e++)f[e]-=a[e%3];return{obbox:p,boxPosition:f,boxCenter:a,boxCoord:i}}_createSphere(e){const t=this.getMap(),r=this.getRenderer(),n="identity"===t.getProjection().code.toLowerCase(),s=e.boundingVolume.sphere,a=s;let i=Ho;0===a[0]&&0===a[1]&&0===a[2]?i=[0,0,-6378137]:Rt(i,a),n&&r._lngLatToIdentityCoord(i,i);const l=new o.Coordinate(i),c=this._coordToPoint(l,Jo).toArray();c[2]=t.altitudeToPoint(l.z,t.getGLRes());const h=this._getBoxScale(l);return{boxCenter:c,boxCoord:l,sphereBox:[c,s[3]*h[2]]}}_generateOBBox(e,t){const n=ms(qo,e,0,1,4,5),o=ms(Vo,e,0,3,4,7),s=ms(Zo,e,0,1,2,3);return[...t,...r.vec3.sub(Ho,n,t),...r.vec3.sub(Go,o,t),...r.vec3.sub(jo,s,t)]}_calBoxCenter(e){const t=this.getMap(),r=this.getRenderer(),n="identity"===t.getProjection().code.toLowerCase(),s=t.getGLRes(),a=e.boundingVolume.box.slice(0,3);Rt(a,a),n&&r._lngLatToIdentityCoord(a,a);const i=new o.Coordinate(a),l=t.coordToPointAtRes(i,s);return{boxCenter:[l.x,l.y,t.altitudeToPoint(i.z,s)],boxCoord:i}}_getServiceTransform(e,t){const n=this._getRootNode(t._rootIdx),o=this._getNodeService(t._rootIdx),s=n._bboxCenter,a=r.mat4.fromTranslation(es,r.vec3.set(Ho,-s[0],-s[1],-s[2])),i=r.mat4.fromTranslation(ts,s),l=o.rotation||as,c=r.quat.fromEuler(Wo,...l),h=o.scale;let u;u=Array.isArray(h)?r.vec3.set(ls,h[0],h[1],h[2]):h&&r.vec3.set(ls,h,h,h)||is;const f=r.mat4.fromRotationTranslationScale(rs,c,cs,u);return e=r.mat4.multiply(e,f,a),r.mat4.multiply(e,i,e)}_updateRootCenter(e){const t=this._getNodeService(e._rootIdx);if(!e.boundingVolume||this._equalsOffsets(e,t))return;const r=e.boundingVolume.box,n=e.boundingVolume.region,o=e.boundingVolume.sphere;let s=null;r?s=this._updateRootBBoxCenter(e).boxCenter:n?s=this._updateRootRegionCenter(e).boxCenter:o&&(s=this._createSphere(e).boxCenter);const a=t.heightOffset||0,i=t.coordOffset||[0,0];e._originCoordOffset=[i[0]||0,i[1]||0],e._originHeightOffset=a,e._bboxCenter=s}_equalsOffsets(e,t){if(!e._originCoordOffset)return!1;const r=t.coordOffset||ss;return e._originCoordOffset[0]===r[0]&&e._originCoordOffset[1]===r[1]&&e._originHeightOffset===(t.heightOffset||0)}_updateRootRegionCenter(e){return this._offsetBoundingVolume(e),this._createRegionBox(e)}_updateRootBBoxCenter(e){return this._offsetBoundingVolume(e),this._calBoxCenter(e)}_createHalfAxes(e,t){let n=e.slice(3,12);const o=r.mat3.fromMat4(Yo,t);return n=r.mat3.multiply(n,o,n),n}_getBoxScale(e){const t=this.getMap(),n=t.distanceToPointAtRes(100,100,t.getGLRes(),e);let o;return o=t.altitudeToPoint?t.altitudeToPoint(100,t.getGLRes())/100:n.y/100,r.vec3.set($o,n.x/100*1.01,n.y/100*1.01,o),$o}_offsetCenter(e){Array.isArray(e)&&(e=new o.Coordinate(e));let t=this.options.offset;if(_e(t)&&(t=t.call(this,Array.isArray(e)?new o.Coordinate(e):e)),t[0]||t[1]){const r=this.getMap(),n=r.getGLRes(),o=r.coordToPointAtRes(e,n);return Jo.set(t[0],t[1]),o._sub(Jo),r.pointAtResToCoord(o,n)}return e}_getRootNode(e){return this._roots[e]}_getRootMaxExtent(e){const t=this._getNodeService(e).maxExtent;if(!t)return null;const r=this._roots[e];return r.maxExtent||(r.maxExtent=new o.Extent(t).convertTo((e=>this._coordToPoint(e)))),r.maxExtent}_getScreenSpaceError(e){const t=this._fovDenominator,n=e.geometricError;if(0===n)return e._error=0,0;const o=this._getNodeService(e._rootIdx);let s=o.scale||1;if(Array.isArray(s)&&(s=r.vec3.length(s)),o.ecefTransform){const e=r.mat4.getScaling(Qo,o.ecefTransform);s*=r.vec3.len(e)}const a=this.getMap();let i;e.boundingVolume.region?i=function(e,t,r){e._tileRegion||(e._tileRegion=new ko(e.boundingVolume.region));return e._tileRegion.distanceToCamera(t,r)}(e,this._cameraCartesian3,this._cameraLocation):e.boundingVolume.sphere?i=ds(e.boundingVolume,this._cameraCartesian3):e.boundingVolume.box&&(i=ps(e.boundingVolume,this._cameraCartesian3));const l=Math.max(Math.abs(i),1e-7),c=n*s*a.height/(l*t);return e._cameraDistance=i,e._error=c,c}_setToRedraw(){const e=this.getRenderer();e&&e.setToRedraw()}_getNodeBox(e){return this._nodeBoxes.get(e)}identify(e,t={}){const r=this.getMap(),n=this.getRenderer();if(!r||!n)return[];Array.isArray(e)&&(e=new o.Coordinate(e));const s=r.coordToContainerPoint(e);return this.identifyAtPoint(s,t)}identifyAtPoint(e,t={}){const r=[];if(!t.excludeMasks){const n=this.identifyMask(e,t);n&&n.length&&Re(r,n)}const n=this.getMap(),o=this.getRenderer();if(!n||!o)return[];const s=n.getDevicePixelRatio();return Re(r,o.pick(e.x*s,e.y*s,t)),t&&t.filter&&!t.excludeMasks?r.filter((e=>t.filter(e))):r}getCurrentBatchIDs(){const e=this.getMap(),t=this.getRenderer();return e&&t?t._getCurrentBatchIDs():[]}highlight(e){const t=this.getRenderer();return Array.isArray(e)||(e=[e]),t?(t.highlight(e),this):(this._highlighted||(this._highlighted=[]),this._highlighted.push(e),this)}_resumeHighlights(){if(this._highlighted){for(let e=0;e<this._highlighted.length;e++)this.highlight(this._highlighted[e]);delete this._highlighted}}cancelHighlight(e,t){const r=this.getRenderer();return r?(r.cancelHighlight(e,t),this):this}cancelAllHighlight(){const e=this.getRenderer();return e?(e.cancelAllHighlight(),this):this}showOnly(e){const t=this.getRenderer();return t?(t.showOnly(e),this):(this._showOnlys||(this._showOnlys=[]),this._showOnlys.push(e),this)}_resumeShowOnly(){if(this._showOnlys){for(let e=0;e<this._showOnlys.length;e++)this.showOnly(this._showOnlys[e]);delete this._showOnlys}}cancelShowOnly(e){const t=this.getRenderer();return t?(t.cancelShowOnly(e),this):this}setServiceOpacity(e,t){const r=this.options.services[e];r&&(r.opacity=t);return this.getRenderer()?(this._setToRedraw(),this):this}setServiceDebug(e,t){const r=this.options.services[e];r&&(r.debug=t);return this.getRenderer()?(this._setToRedraw(),this):this}_getCameraLonLat(e){const t=this.getMap(),r=t.getGLRes();ns.set(e[0],e[1]);const n=t.pointAtResToCoord(ns,r);return"identity"===t.getProjection().code.toLowerCase()?(Go[0]=n.x,Go[1]=n.y,this.getRenderer()._identityCoordToLngLat(Ho,Go),n.set(Ho[0],Ho[1]),n):n}toJSON(){return{"type":this.getJSONType(),"id":this.getId(),"options":this.config()}}}function ds(e,t,n){let o=e.sphere;n&&(o=r.vec3.transformMat4([0,0,0],o,n));const s=r.vec3.dist(o,t),a=e.sphere[3];return s<a?0:s-a}function ps(e,t,n){const o=e.box;let s=r.vec3.set(Ho,o[0],o[1],o[2]);n&&(s=r.vec3.transformMat4([0,0,0],s,n));return uo(s,r.mat3.set(Yo,o[3],o[4],o[5],o[6],o[7],o[8],o[9],o[10],o[11]),t)}function gs(e,t,n){const o=(e=Me(e)).indexOf("{s}")>=0?"{s}":e.indexOf("%7Bs%7D")>=0?"%7Bs%7D":null;return{version:0,_empty:!0,service:n,visible:!!ge(n.visible)||n.visible,baseUrl:e.substring(0,e.lastIndexOf("/"))+"/",content:{url:e},refine:"replace",matrix:r.mat4.identity([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),_rootIdx:t,_level:0,_notLoaded:!0,domainKey:o}}function ms(e,t,n,o,s,a){const i=r.vec3.set(Ho,t[3*n],t[3*n+1],t[3*n+2]),l=r.vec3.set(Go,t[3*o],t[3*o+1],t[3*o+2]),c=r.vec3.set(jo,t[3*s],t[3*s+1],t[3*s+2]),h=r.vec3.set(zo,t[3*a],t[3*a+1],t[3*a+2]);return e[0]=(i[0]+l[0]+c[0]+h[0])/4,e[1]=(i[1]+l[1]+c[1]+h[1])/4,e[2]=(i[2]+l[2]+c[2]+h[2])/4,e}function _s(e){if(!e.content||e.hasParentContent)return!1;let t=e.parent;if(t&&(t.content||t.hasParentContent))return e.hasParentContent||(e.hasParentContent=!0),!1;for(;t;){if(t.content||t.hasParentContent)return e.hasParentContent||(e.hasParentContent=!0),!1;t=t.parent}return!0}function bs(e,t){return Array.isArray(e)&&Array.isArray(t)?2===e.length?r.vec2.exactEquals(e,t):r.vec3.exactEquals(e,t):e===t}var ys;fs.mergeOptions(Fo),fs.registerRenderer("gl",lo),fs.registerRenderer("gpu",lo),fs.registerJSONType("Geo3DTilesLayer"),function(e){e[e.OUT_OF_FRUSTUM=0]="OUT_OF_FRUSTUM",e[e.SCREEN_ERROR_TOO_SMALL=1]="SCREEN_ERROR_TOO_SMALL",e[e.VISIBLE=2]="VISIBLE"}(ys||(ys={}));let Ts=null;function vs(){return Ts||(Ts={"image/crn":Fe.crn&&Fe.crn(),"image/ktx2":Fe.ktx2&&Fe.ktx2(),"image/cttf":Fe.ktx2&&Fe.ktx2(),"draco":Fe.draco&&Fe.draco()}),Ts}const{Ajax:Ms,GLTFLoader:ws}=He();class xs{constructor(e,t,r){this._requestImage=e,this._loaderCtor=t||ws,this._supportedFormats=r,this._decoders=vs()}static createEmptyB3DM(){return{featureTable:null,batchTable:null,gltf:{}}}load(e,t,r=0,n=0,o){return t?(n||(n=t.byteLength),this._parse(e,t,r,n,o)):Ms.getArrayBuffer(e,{}).then((t=>{const o=t.data;return n||(n=o.byteLength),this._parse(e,o,r,n)}))}_parse(e,t,r,n,o){const s=o&&o.maxTextureSize,a=this._readB3DM(t,r,n,e);if(a.error)return Promise.resolve(a);const i=e.substring(0,e.lastIndexOf("/"));let l;try{l=new this._loaderCtor(i,a.glb,{transferable:!0,requestImage:this._requestImage,decoders:this._decoders,supportedFormats:this._supportedFormats,maxTextureSize:s})}catch(e){return Promise.resolve({error:e})}return l.load({skipAttributeTransform:!1}).then((t=>{t.url=`${e}-${r}-${n}`;const o=l.transferables;for(let e=0;e<a.transferables.length;e++)o.indexOf(a.transferables[e])<0&&o.push(a.transferables[e]);return{magic:"b3dm",count:a.count,transferables:o,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,gltf:t}}))}_readB3DM(e,t,r,n){const o=new DataView(e,t,r),s=o.getUint32(4,!0);if(1!==s){const e="Unsupported b3dm version: "+s+", url:"+n;return console.warn(e),{error:e}}if(o.getUint32(8,!0)!==o.byteLength){const e="Length in b3dm header is inconsistent with b3dm's byte length, url: "+n;return console.warn(e),{error:e}}let a,i=o.getUint32(12,!0),l=o.getUint32(16,!0),c=o.getUint32(20,!0),h=o.getUint32(24,!0),u=28+t;c>=570425344?(u-=8,a=i,c=l,h=0,i=0,l=0):h>=570425344&&(u-=4,a=c,c=i,h=l,i=0,l=0);const f=[e];let d,p,g;if(i>0?(d=zt(e,u,i),u+=i,a=d.BATCH_LENGTH):d={"BATCH_LENGTH":a},l>0&&(u+=l),c>0&&(p=qt(e,u,c),u+=c,h>0)){const t=Vt(0,u,h);g=e.slice(t.offset,t.offset+t.byteLength),u+=h,f.push(g)}const m=d.BATCH_LENGTH,_={};if(d&&d.BATCH_ID){_.BATCH_ID=$t(d.BATCH_ID,e,undefined.offset,m);const t=_.BATCH_ID.array&&_.BATCH_ID.array.buffer;t&&f.indexOf(t)<0&&f.push(t)}return{count:a,transferables:f,featureTable:d,batchTable:p,batchTableBin:g,b3dm:_,glb:{buffer:e,byteOffset:u,byteLength:o.byteLength+o.byteOffset-u}}}_readBatchTable(){return null}}const{Ajax:Os,GLTFLoader:Ss}=He();class Is{constructor(e,t,r,n){this._requestImage=e,this._loaderCtor=t||Ss,this._supportedFormats=r,this._decoders=vs(),this._maxTextureSize=n}load(e,t,r=0,n=0,o){return t?(n||(n=t.byteLength),this._parse(e,t,r,n,o)):Os.getArrayBuffer(e,{}).then((t=>{const o=t.data;return n||(n=o.byteLength),this._parse(e,o,r,n)}))}_parse(e,t,r,n,o){return this._parseGLTF(e,t,r,n,o).then((({gltf:o,transferables:s})=>{const a=this._readI3DM(t,r,n,e);if(a.error)return Promise.resolve(a);for(let e=0;e<s.length;e++)-1===a.transferables.indexOf(s[e])&&a.transferables.push(s[e]);return delete o.transferables,Promise.resolve({magic:"i3dm",count:a.count,transferables:a.transferables,featureTable:a.featureTable,batchTable:a.batchTable,batchTableBin:a.batchTableBin,i3dm:a.i3dm,gltf:o})}))}_parseGLTF(e,t,r,n,o){const s=o&&o.maxTextureSize,a={transferable:!0,requestImage:this._requestImage,decoders:this._decoders,supportedFormats:this._supportedFormats,maxTextureSize:s},i=new DataView(t,r,n),l=32+i.getUint32(12,!0)+i.getUint32(16,!0)+i.getUint32(20,!0)+i.getUint32(24,!0);if(0===i.getUint32(28,!0)){let n=Oe(new Uint8Array(t,l+r,i.byteLength-l));-1==n.indexOf("://")&&(n=e.substring(0,e.lastIndexOf("/"))+"/"+n);return n.indexOf(".glb")>0?Os.getArrayBuffer(n,{}).then((e=>this._createGLTFLoader(n,{buffer:e.data,byteOffset:0},a))):Os.getJSON(n,{}).then((e=>this._createGLTFLoader(n,e,a)))}{const n={buffer:t,byteOffset:l+r,byteLength:i.byteLength-l};return this._createGLTFLoader(e,n,a)}}_createGLTFLoader(e,t,r){const n=e.substring(0,e.lastIndexOf("/")),o=new this._loaderCtor(n,t,r);return o.load({skipAttributeTransform:!0}).then((r=>{let n=0,s=0;return t.buffer&&(n=t.byteOffset||0,s=t.byteLength||0),r.url=`${e}-${n}-${s}`,{transferables:o.transferables,gltf:r}}))}_readI3DM(e,t,r,n){const o=new DataView(e,t,r),s=o.getUint32(4,!0);if(1!==s){const e="Unsupported pnts version: "+s+", url:"+n;return console.warn(e),{error:e}}if(o.getUint32(8,!0)!==o.byteLength){const e="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(e),{error:e}}const a=[e],{featureTable:i,featureTableBin:l,batchTable:c,batchTableBin:h}=tr(o,32+t,a),u={},f=i.INSTANCES_LENGTH;if(i.POSITION){const{byteOffset:t}=i.POSITION;u.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(e,t+l.offset,3*f).slice()},a.push(u.POSITION.array.buffer)}else if(i.POSITION_QUANTIZED){const t=i.QUANTIZED_VOLUME_OFFSET,r=i.QUANTIZED_VOLUME_SCALE,{byteOffset:n}=i.POSITION_QUANTIZED;u.POSITION={byteStride:12,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this._convertQuantizedPosition(new Uint16Array(e,n+l.offset,3*f),t,r)},a.push(u.POSITION.array.buffer)}if(i.BATCH_ID){u.BATCH_ID=$t(i.BATCH_ID,e,l.offset,f);const t=u.BATCH_ID.array&&u.BATCH_ID.array.buffer;t&&a.indexOf(t)<0&&a.push(t)}if(i.NORMAL_UP){let{byteOffset:t}=i.NORMAL_UP;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(e,t+l.offset,3*f).slice()},a.push(u.NORMAL_UP.array.buffer),t=i.NORMAL_RIGHT.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(e,t+l.offset,3*f).slice()},a.push(u.NORMAL_RIGHT.array.buffer)}else if(i.NORMAL_UP_OCT32P){let{byteOffset:t}=i.NORMAL_UP_OCT32P;u.NORMAL_UP={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this._decodeOCT32p(new Uint16Array(e,t+l.offset,2*f))},a.push(u.NORMAL_UP.array.buffer),t=i.NORMAL_RIGHT_OCT32P.byteOffset,u.NORMAL_RIGHT={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:this._decodeOCT32p(new Uint16Array(e,t+l.offset,2*f))},a.push(u.NORMAL_RIGHT.array.buffer)}if(i.SCALE){const{byteOffset:t}=i.SCALE;u.SCALE={byteStride:0,byteOffset:0,itemSize:1,count:f,componentType:5126,array:new Float32Array(e,t+l.offset,f).slice()},a.push(u.SCALE.array.buffer)}else if(i.SCALE_NON_UNIFORM){const{byteOffset:t}=i.SCALE_NON_UNIFORM;u.SCALE_NON_UNIFORM={byteStride:0,byteOffset:0,itemSize:3,count:f,componentType:5126,array:new Float32Array(e,t+l.offset,3*f).slice()},a.push(u.SCALE_NON_UNIFORM.array.buffer)}return{count:f,batchTable:c,batchTableBin:h,featureTable:i,i3dm:u,transferables:a}}_decodeOCT32p(e){const t=e.length/2,r=new Float32Array(3*t),n=[];for(let o=0;o<t;o++)As(n,e[2*o],e[2*o+1],65535),r[3*o]=n[0],r[3*o+1]=n[1],r[3*o+2]=n[2];return r}_convertQuantizedPosition(e,t,r){return er(new Float32Array(e.length),e,t,r)}_readBatchTable(){return null}}function As(e,t,r,n){if(e[0]=Cs(t,n),e[1]=Cs(r,n),e[2]=1-(Math.abs(e[0])+Math.abs(e[1])),e[2]<0){const t=e[0];e[0]=(1-Math.abs(e[1]))*Ns(t),e[1]=(1-Math.abs(t))*Ns(e[1])}return rt(e,e)}function Cs(e,t){return function(e,t,r){return e<t?t:e>r?r:e}(e,0,t=function(e,t){if(null!=e)return e;return t}(t,255))/t*2-1}function Ns(e){return e<0?-1:1}const{Ajax:Rs}=He();class Ls{constructor(){}load(e,t,r=0,n=0){return t?(n||(n=t.byteLength),this._parse(e,t,r,n)):Rs.getArrayBuffer(e,{}).then((t=>{const o=t.data;return n||(n=o.byteLength),this._parse(e,o,r,n)}))}_parse(e,t,r,n){return this._readPNTS(t,r,n,e).then((e=>e.error?e:{magic:"pnts",count:e.count,transferables:e.transferables,featureTable:e.featureTable,batchTable:e.batchTable,batchTableBin:e.batchTableBin,pnts:e.pnts}))}_readPNTS(e,t,r,n){const o=new DataView(e,t,r),s=o.getUint32(4,!0);if(1!==s){const e="Unsupported pnts version: "+s+", url:"+n;return console.warn(e),{error:e}}if(o.getUint32(8,!0)!==o.byteLength){const e="Length in pnts header is inconsistent with pnts's byte length, url: "+n;return console.warn(e),{error:e}}const a=[e],{featureTable:i,featureTableBin:l,batchTable:c,batchTableBin:h}=tr(o,t+28,a),u=i.QUANTIZED_VOLUME_OFFSET,f=i.QUANTIZED_VOLUME_SCALE,d=i.POINTS_LENGTH;let p,g={};if(i.extensions&&i.extensions["3DTILES_draco_point_compression"]){g=i.extensions["3DTILES_draco_point_compression"],p=new DataView(e,g.byteOffset+l.offset,g.byteLength);const t={attributes:g.properties,useUniqueIDs:!1};return this._draco||(this._draco=vs().draco),this._draco(p,t).then((t=>{const r=t.attributes;!i.POSITION&&!i.POSITION_QUANTIZED||r.POSITION||r.POSITION_QUANTIZED||(r.POSITION=i.POSITION,r.POSITION_QUANTIZED=i.POSITION_QUANTIZED),!(i.RGB||i.RGBA||i.RGB565)||r.RGB||r.RGBA||r.RGB565||(r.RGB=i.RGB,r.RGBA=i.RGBA,r.RGB565=i.RGB565),!i.NORMAL&&!i.NORMAL_OCT16P||r.NORMAL||r.NORMAL_OCT16P||(r.NORMAL=i.NORMAL,r.NORMAL_OCT16P=i.NORMAL_OCT16P);const n=this._readAttributes(e,t.attributes,l.offset,d,a,u,f);if(t.attributes.BATCH_ID){const e=t.attributes.BATCH_ID.array;n.BATCH_ID={byteStride:0,byteOffset:0,itemSize:1,count:e.length,componentType:Yt(e.constructor),array:e},a.push(e.buffer)}else if(i.BATCH_ID||Object.keys(c).length){i.BATCH_ID?n.BATCH_ID=$t(i.BATCH_ID,e,l.offset,d):n.BATCH_ID=Es(d);const t=n.BATCH_ID.array&&n.BATCH_ID.array.buffer;t&&a.indexOf(t)<0&&a.push(t)}return{count:d,batchTable:c,batchTableBin:h,featureTable:i,pnts:n,transferables:a}}))}const m=this._readAttributes(e,i,l.offset,d,a,u,f);if(i.BATCH_ID||Object.keys(c).length){i.BATCH_ID?m.BATCH_ID=$t(i.BATCH_ID,e,l.offset,d):m.BATCH_ID=Es(d);const t=m.BATCH_ID.array&&m.BATCH_ID.array.buffer;t&&a.indexOf(t)<0&&a.push(t)}return Promise.resolve({count:d,batchTable:c,batchTableBin:h,featureTable:i,pnts:m,transferables:a})}_readAttributes(e,t,r,n,o,s,a){const i={};if(t.POSITION){let{byteOffset:s,array:a}=t.POSITION;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+3*n*4);a=new Float32Array(t)}i.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},o.push(a.buffer)}else if(t.POSITION_QUANTIZED){let{byteOffset:l}=t.POSITION_QUANTIZED;const{array:c}=t.POSITION_QUANTIZED;l=l||0;const h=c?0:r;i.POSITION={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:this._convertQuantizedPosition(c||new Uint16Array(e,l+h,3*n),s,a)},o.push(i.POSITION.array.buffer)}if(t.RGBA){let{byteOffset:s,array:a}=t.RGBA;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+4*n);a=new Uint8Array(t)}i.RGBA={byteStride:0,byteOffset:0,itemSize:4,count:n,componentType:5121,array:a},o.push(a.buffer)}else if(t.RGB){let{byteOffset:s,array:a}=t.RGB;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+3*n);a=new Uint8Array(t)}i.RGB={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5121,array:a},o.push(a.buffer)}else if(t.RGB565){let{byteOffset:s,array:a}=t.RGB565;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+2*n);a=new Uint16Array(t)}i.RGB565={byteStride:0,byteOffset:0,itemSize:1,count:n,componentType:5123,array:a},o.push(a.buffer)}if(t.NORMAL){let{byteOffset:s,array:a}=t.NORMAL;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+3*n*4);a=new Float32Array(t)}i.NORMAL={byteStride:0,byteOffset:0,itemSize:3,count:n,componentType:5126,array:a},o.push(a.buffer)}else if(t.NORMAL_OCT16P){let{byteOffset:s,array:a}=t.NORMAL_OCT16P;s=s||0;const l=a?0:r;if(!a){const t=e.slice(s+l,s+l+2*n);a=new Uint8Array(t)}i.NORMAL_OCT16P={byteStride:0,byteOffset:0,itemSize:2,count:n,componentType:5121,array:a},o.push(a.buffer)}return i}_convertQuantizedPosition(e,t,r){return er(new Float32Array(e.length),e,t,r)}_readBatchTable(){return null}}function Es(e){const t=Ae(e),r=new t(e);for(let t=0;t<e;t++)r[t]=t;return{byteStride:0,byteOffset:0,itemSize:1,count:e,componentType:Yt(t),array:r}}const{Ajax:Ps,GLTFLoader:ks}=He();class Bs{constructor(e,t,r,n){this._supportedFormats=r,this._requestImage=e,this._loaderCtor=t||ks,this._maxTextureSize=n}load(e,t,r=0,n=0,o){return t?this._parse(e,t,r,n,o):Ps.getArrayBuffer(e,{}).then((t=>{const o=t.data;return this._parse(e,o,r,n)}))}_parse(e,t,r,n,o){n||(n=t.byteLength);const s=this._readCMPT(t,e,r,n),a=[];for(let r=0;r<s.length;r++){let n;if("b3dm"===s[r].magic)n=new xs(this._requestImage,this._loaderCtor,this._supportedFormats);else if("i3dm"===s[r].magic)n=new Is(this._requestImage,this._loaderCtor,this._supportedFormats,this._maxTextureSize);else if("pnts"===s[r].magic)n=new Ls;else{if("cmpt"!==s[r].magic){console.warn("Unsupported magic in CMPT tile:",s[r].magic);continue}n=new Bs(this._requestImage,this._loaderCtor,this._supportedFormats,this._maxTextureSize)}a.push(n.load(e,t,s[r].offset,s[r].byteLength,o).then((e=>e)))}return Promise.all(a).then((e=>({magic:"cmpt",tiles:e})))}_readCMPT(e,t,r,n){const o=new DataView(e,r,n),s=o.getUint32(4,!0);if(1!==s){const e="Unsupported cmpt version: "+s+", url:"+t;return console.warn(e),{error:e}}if(16===o.byteLength)return[];const a=[],i=o.getUint32(12,!0);let l=16;for(let t=0;t<i;t++){const t=Gt(o,l),n=o.getUint32(l+8,!0);a.push({magic:t,buffer:e,offset:l+r,byteLength:n}),l+=n}return a}}if(s.transcoders){const e=o.Map.VERSION;if(e.indexOf("1.0.0-beta")>=0||e.indexOf("1.0.0-alpha")>=0){const e=s.transcoders.inject(i);o.registerWorkerAdapter("@maptalks/3dtiles",e)}else o.registerWorkerAdapter("@maptalks/3dtiles",(function(){return s.transcoders.inject(i)}))}else o.registerWorkerAdapter("@maptalks/3dtiles",i);e.B3DMLoader=xs,e.CMPTLoader=Bs,e.Geo3DTilesLayer=fs,e.Geo3DTilesUtil=Pe,e.Geo3DTransform=Ft,"undefined"!=typeof console&&console.log("@maptalks/3dtiles v0.125.0")}));
17
17
  //# sourceMappingURL=maptalks.3dtiles.js.map