define(["./Check-7b2a090c","./RuntimeError-4a5c8994","./when-b60132fc","./pako_inflate-f73548c4","./createTaskProcessorWorker"],(function(r,t,e,n,i){"use strict";functiona(r,e){if(a.passThroughDataForTesting)returne;varn=r.byteLength;if(0===n||n%4!=0)thrownewt.RuntimeError("The length of key must be greater than 0 and a multiple of 4.");vari=newDataView(e),o=i.getUint32(0,!0);if(1953029805===o||2917034100===o)returne;for(vars,u=newDataView(r),f=0,h=e.byteLength,v=h-h%8,c=n,g=8;f<v;)for(s=g=(g+8)%24;f<v&&s<c;)i.setUint32(f,i.getUint32(f,!0)^u.getUint32(s,!0),!0),i.setUint32(f+4,i.getUint32(f+4,!0)^u.getUint32(s+4,!0),!0),f+=8,s+=24;if(f<h)for(s>=c&&(s=g=(g+8)%24);f<h;)i.setUint8(f,i.getUint8(f)^u.getUint8(s)),f++,s++}functiono(r,t){return0!=(r&t)}a.passThroughDataForTesting=!1;vars=[1,2,4,8];functionu(r,t,e,n,i,a){this._bits=r,this.cnodeVersion=t,this.imageryVersion=e,this.terrainVersion=n,this.imageryProvider=i,this.terrainProvider=a,this.ancestorHasTerrain=!1,this.terrainState=void0}u.clone=function(r,t){returne.defined(t)?(t._bits=r._bits,t.cnodeVersion=r.cnodeVersion,t.imageryVersion=r.imageryVersion,t.terrainVersion=r.terrainVersion,t.imageryProvider=r.imageryProvider,t.terrainProvider=r.terrainProvider):t=newu(r._bits,r.cnodeVersion,r.imageryVersion,r.terrainVersion,r.imageryProvider,r.terrainProvider),t.ancestorHasTerrain=r.ancestorHasTerrain,t.terrainState=r.terrainState,t},u.prototype.setParent=function(r){this.ancestorHasTerrain=r.ancestorHasTerrain||this.hasTerrain()},u.prototype.hasSubtree=function(){returno(this._bits,16)},u.prototype.hasImagery=function(){returno(this._bits,64)},u.prototype.hasTerrain=function(){returno(this._bits,128)},u.prototype.hasChildren=function(){returno(this._bits,15)},u.prototype.hasChild=function(r){returno(this._bits,s[r])},u.prototype.getChildBitmask=function(){return15&this._bits};varf=Uint16Array.BYTES_PER_ELEMENT,h=Int32Array.BYTES_PER_ELEMENT,v=Uint32Array.BYTES_PER_ELEMENT,c={METADATA:0,TERRAIN:1,DBROOT:2};c.fromString=function(r){return"Metadata"===r?c.METADATA:"Terrain"===r?c.TERRAIN:"DbRoot"===r?c.DBROOT:void0};varg=1953029805,d=2917034100;returni((function(r,e){vari=c.fromString(r.type),o=r.buffer;a(r.key,o);vars=function(r){vare=newDataView(r),i=0,a=e.getUint32(i,!0);if(i+=v,a!==g&&a!==d)thrownewt.RuntimeError("Invalid magic");varo=e.getUint32(i,a===g);i+=v;vars=newUint8Array(r,i),u=n.pako.inflate(s);if(u.length!==o)thrownewt.RuntimeError("Size of packet doesn't match header");returnu}(o);o=s.buffer;varT=s.length;switch(i){casec.METADATA:returnfunction(r,e,n){vari=newDataView(r),a=0,o=i.getUint32(a,!0);if(a+=v,32301!==o)thrownewt.RuntimeError("Invalid magic");vars=i.getUint32(a,!0);if(a+=v,1!==s)thrownewt.RuntimeError("Invalid data type. Must be 1 for QuadTreePacket");varc=i.getUint32(a,!0);if(a+=v,2!==c)thrownewt.RuntimeError("Invalid QuadTreePacket version. Only version 2 is supported.");varg=i.getInt32(a,!0);a+=h;vard=i.getInt32(a,!0);if(a+=h,32!==d)thrownewt.RuntimeError("Invalid instance size.");varT=i.getInt32(a,!0);a+=h;varw=i.getInt32(a,!0);a+=h;varE=i.getInt32(a,!0);if(T!==g*d+(a+=h))thrownewt.RuntimeError("Invalid dataBufferOffset");if(T+w+E!==e)thrownewt.RuntimeError("Invalid packet offsets");for(varl=[],p=0;p<g;++p){varm=i.getUint8(a);++a,++a;vary=i.getUint16(a,!0);a+=f;varU=i.getUint16(a,!0);a+=f;varb=i.getUint16(a,!0);a+=f,a+=f,a+=f,a+=h,a+=h,a+=8;varR=i.getUint8(a++),I=i.getUint8(a++);a+=f,l.push(newu(m,y,U,b,R,I))}varV=[],_=0;functionA(r,t,e){varn=!1;if(4===e){if(t.hasSubtree())return;n=!0}for(vari=0;i<4;++i){vara=r+i.toString();if(n)V[a]=null;elseif(e<4)if(t.hasChild(i)){if(_===g)returnvoidconsole.log("Incorrect number of instances");varo=l[_++];V[a]=o,A(a,o,e+1)}elseV[a]=null}}varP=0,D=l[_++];""===n?++P:V[n]=D;returnA(n,D,P),V}(o,T,r.quadKey);casec.TERRAIN:returnfunction(r,t,e){varn=newDataView(r),i=0,a=[];for(;i<t;){for(varo=i,s=0;s<4;++s){varu=n.getUint32(i,!0);i+=v,i+=u}varf=r.slice(o,i);e.push(f),a.push(f)}returna}(o,T,e);casec.DBROOT:returne.push(o),{buff