define(["exports","./when-b60132fc","./Check-7b2a090c","./RuntimeError-4a5c8994"],(function(e,t,r,n){"use strict";
/**
	 * @license
	 *
	 * Grauw URI utilities
	 *
	 * See: http://hg.grauw.nl/grauw-lib/file/tip/src/uri.js
	 *
	 * @author Laurens Holst (http://www.grauw.nl/)
	 *
	 *   Copyright 2012 Laurens Holst
	 *
	 *   Licensed under the Apache License, Version 2.0 (the "License");
	 *   you may not use this file except in compliance with the License.
	 *   You may obtain a copy of the License at
	 *
	 *       http://www.apache.org/licenses/LICENSE-2.0
	 *
	 *   Unless required by applicable law or agreed to in writing, software
	 *   distributed under the License is distributed on an "AS IS" BASIS,
	 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	 *   See the License for the specific language governing permissions and
	 *   limitations under the License.
	 *
	 */function i(e){if(e instanceof i)this.scheme=e.scheme,this.authority=e.authority,this.path=e.path,this.query=e.query,this.fragment=e.fragment;else if(e){var t=o.exec(e);this.scheme=t[1],this.authority=t[2],this.path=t[3],this.query=t[4],this.fragment=t[5]}}i.prototype.scheme=null,i.prototype.authority=null,i.prototype.path="",i.prototype.query=null,i.prototype.fragment=null;var o=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$");i.prototype.getScheme=function(){return this.scheme},i.prototype.getAuthority=function(){return this.authority},i.prototype.getPath=function(){return this.path},i.prototype.getQuery=function(){return this.query},i.prototype.getFragment=function(){return this.fragment},i.prototype.isAbsolute=function(){return!!this.scheme&&!this.fragment},i.prototype.isSameDocumentAs=function(e){return e.scheme==this.scheme&&e.authority==this.authority&&e.path==this.path&&e.query==this.query},i.prototype.equals=function(e){return this.isSameDocumentAs(e)&&e.fragment==this.fragment},i.prototype.normalize=function(){this.removeDotSegments(),this.scheme&&(this.scheme=this.scheme.toLowerCase()),this.authority&&(this.authority=this.authority.replace(a,c).replace(s,f)),this.path&&(this.path=this.path.replace(s,f)),this.query&&(this.query=this.query.replace(s,f)),this.fragment&&(this.fragment=this.fragment.replace(s,f))};var s=/%[0-9a-z]{2}/gi,u=/[a-zA-Z0-9\-\._~]/,a=/(.*@)?([^@:]*)(:.*)?/;function f(e){var t=unescape(e);return u.test(t)?t:e.toUpperCase()}function c(e,t,r,n){return(t||"")+r.toLowerCase()+(n||"")}function p(e,r){if(null===e||"object"!=typeof e)return e;r=t.defaultValue(r,!1);var n=new e.constructor;for(var i in e)if(e.hasOwnProperty(i)){var o=e[i];r&&(o=p(o,r)),n[i]=o}return n}function l(e,r,n){n=t.defaultValue(n,!1);var i,o,s,u={},a=t.defined(e),f=t.defined(r);if(a)for(i in e)e.hasOwnProperty(i)&&(o=e[i],f&&n&&"object"==typeof o&&r.hasOwnProperty(i)?(s=r[i],u[i]="object"==typeof s?l(o,s,n):o):u[i]=o);if(f)for(i in r)r.hasOwnProperty(i)&&!u.hasOwnProperty(i)&&(s=r[i],u[i]=s);return u}function h(e,t){var r;return"undefined"!=typeof document&&(r=document),h._implementation(e,t,r)}i.prototype.resolve=function(e){var t=new i;return this.scheme?(t.scheme=this.scheme,t.authority=this.authority,t.path=this.path,t.query=this.query):(t.scheme=e.scheme,this.authority?(t.authority=this.authority,t.path=this.path,t.query=this.query):(t.authority=e.authority,""==this.path?(t.path=e.path,t.query=this.query||e.query):("/"==this.path.charAt(0)?(t.path=this.path,t.removeDotSegments()):(e.authority&&""==e.path?t.path="/"+this.path:t.path=e.path.substring(0,e.path.lastIndexOf("/")+1)+this.path,t.removeDotSegments()),t.query=this.query))),t.fragment=this.fragment,t},i.prototype.removeDotSegments=function(){var e,t=this.path.split("/"),r=[],n=""==t[0];for(n&&t.shift(),""==t[0]&&t.shift();t.length;)".."==(e=t.shift())?r.pop():"."!=e&&r.push(e);"."!=e&&".."!=e||r.push(""),n&&r.unshift(""),this.path=r.join("/")},i.prototype.toString=function(){var e="";return this.scheme&&(e+=this.scheme+":"),this.authority&&(e+="//"+this.authority),e+=this.path,this.query&&(e+="?"+this.query),this.fragment&&(e+="#"+this.fragment),e},h._implementation=function(e,r,n){if(!t.defined(r)){if(void 0===n)return e;r=t.defaultValue(n.baseURI,n.location.href)}var o=new i(r);return new i(e).resolve(o).toString()};var d,m=/^blob:/i;function y(e){return m.test(e)}var v=/^data:/i;function g(e){return v.test(e)}var q=Object.freeze({UNISSUED:0,ISSUED:1,ACTIVE:2,RECEIVED:3,CANCELLED:4,FAILED:5}),b=Object.freeze({TERRAIN:0,IMAGERY:1,TILES3D:2,OTHER:3,PACK:4,BLOCK:5,BLOCKPACK:6});function R(e){e=t.defaultValue(e,t.defaultValue.EMPTY_OBJECT);var r=t.defaultValue(e.throttleByServer,!1),n=t.defaultValue(e.throttle,!1);this.url=e.url,this.requestFunction=e.requestFunction,this.cancelFunction=e.cancelFunction,this.priorityFunction=e.priorityFunction,this.priority=t.defaultValue(e.priority,0),this.throttle=n,this.throttleByServer=r,this.type=t.defaultValue(e.type,b.OTHER),this.serverKey=void 0,this.state=q.UNISSUED,this.deferred=void 0,this.cancelled=!1}function w(e,t,r){this.statusCode=e,this.response=t,this.responseHeaders=r,"string"==typeof this.responseHeaders&&(this.responseHeaders=function(e){var t={};if(!e)return t;for(var r=e.split("\r\n"),n=0;n<r.length;++n){var i=r[n],o=i.indexOf(": ");if(o>0){var s=i.substring(0,o),u=i.substring(o+2);t[s]=u}}return t}(this.responseHeaders))}function A(){this._listeners=[],this._scopes=[],this._toRemove=[],this._insideRaiseEvent=!1}function _(e,t){return t-e}function O(e){this._comparator=e.comparator,this._array=[],this._length=0,this._maximumLength=void 0}function E(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}R.prototype.cancel=function(){this.cancelled=!0},R.prototype.clone=function(e){return t.defined(e)?(e.url=this.url,e.requestFunction=this.requestFunction,e.cancelFunction=this.cancelFunction,e.priorityFunction=this.priorityFunction,e.priority=this.priority,e.throttle=this.throttle,e.throttleByServer=this.throttleByServer,e.type=this.type,e.serverKey=this.serverKey,e.state=this.RequestState.UNISSUED,e.deferred=void 0,e.cancelled=!1,e):new R(this)},w.prototype.toString=function(){var e="Request has failed.";return t.defined(this.statusCode)&&(e+=" Status Code: "+this.statusCode),e},Object.defineProperties(A.prototype,{numberOfListeners:{get:function(){return this._listeners.length-this._toRemove.length}}}),A.prototype.addEventListener=function(e,t){this._listeners.push(e),this._scopes.push(t);var r=this;return function(){r.removeEventListener(e,t)}},A.prototype.removeEventListener=function(e,t){for(var r=this._listeners,n=this._scopes,i=-1,o=0;o<r.length;o++)if(r[o]===e&&n[o]===t){i=o;break}return-1!==i&&(this._insideRaiseEvent?(this._toRemove.push(i),r[i]=void 0,n[i]=void 0):(r.splice(i,1),n.splice(i,1)),!0)},A.prototype.raiseEvent=function(){var e;this._insideRaiseEvent=!0;var r=this._listeners,n=this._scopes,i=r.length;for(e=0;e<i;e++){var o=r[e];t.defined(o)&&r[e].apply(n[e],arguments)}var s=this._toRemove;if((i=s.length)>0){for(s.sort(_),e=0;e<i;e++){var u=s[e];r.splice(u,1),n.splice(u,1)}s.length=0}this._insideRaiseEvent=!1},Object.defineProperties(O.prototype,{length:{get:function(){return this._length}},internalArray:{get:function(){return this._array}},maximumLength:{get:function(){return this._maximumLength},set:function(e){this._maximumLength=e,this._length>e&&e>0&&(this._length=e,this._array.length=e)}},comparator:{get:function(){return this._comparator}}}),O.prototype.reserve=function(e){e=t.defaultValue(e,this._length),this._array.length=e},O.prototype.heapify=function(e){e=t.defaultValue(e,0);for(var r=this._length,n=this._comparator,i=this._array,o=-1,s=!0;s;){var u=2*(e+1),a=u-1;o=a<r&&n(i[a],i[e])<0?a:e,u<r&&n(i[u],i[o])<0&&(o=u),o!==e?(E(i,o,e),e=o):s=!1}},O.prototype.resort=function(){for(var e=this._length,t=Math.ceil(e/2);t>=0;--t)this.heapify(t)},O.prototype.insert=function(e){var r,n=this._array,i=this._comparator,o=this._maximumLength,s=this._length++;for(s<n.length?n[s]=e:n.push(e);0!==s;){var u=Math.floor((s-1)/2);if(!(i(n[s],n[u])<0))break;E(n,s,u),s=u}return t.defined(o)&&this._length>o&&(r=n[o],n.pop(),this._length=o),r},O.prototype.pop=function(e){if(e=t.defaultValue(e,0),0!==this._length){var r=this._array,n=r[e];return E(r,e,--this._length),r[this._length]=void 0,this.heapify(e),n}};var C="undefined"!=typeof performance&&"function"==typeof performance.now&&isFinite(performance.now())?function(){return performance.now()}:function(){return Date.now()};function I(e,t){return e.priority-t.priority}var T={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0,totalRequestTime:0},S=20,k=new O({comparator:I});k.maximumLength=S,k.reserve(S);var U=[],x={},P="undefined"!=typeof document?new i(document.location.href):new i,B=new A;function L(){}function D(e){t.defined(e.priorityFunction)&&(e.priority=e.priorityFunction())}function K(e){var r=t.defaultValue(L.requestsByServer[e],L.maximumRequestsPerServer);return x[e]<r}function V(e){return t.defined(e.packKey)||(e.packKey=e.serverKey+"_"+e.providerName),e.packKey}function j(e){return t.defined(e.blockKey)||(e.blockKey=e.serverKey+"_"+e.providerName+"_"+e.quadKey+e.url.substring(e.url.indexOf("dataVersion"))),e.blockKey}function F(e){var r=V(e);return t.defined(L.packRequestGroup[r])||(L.packRequestGroup[r]=[]),t.defined(L.packRequestQuadKey[r])||(L.packRequestQuadKey[r]=""),t.defined(L.packRequestPromise[r])||(L.packRequestPromise[r]=t.when.defer()),t.defined(L.quadKeyIndex[r])||(L.quadKeyIndex[r]=0),e.quadKeyIndex=L.quadKeyIndex[r]++,e.deferred=L.packRequestPromise[r],e.state=q.ISSUED,L.packRequestGroup[r].push(e),e.deferred.promise}function M(e){for(var t=0,r=e.length;t<r;t++){e[t].state=q.CANCELLED}}function N(e){for(var t=[],r={},n=0,i=e.length;n<i;n++){var o=e[n];if(!o.cancelled){var s=o.quadKey;r[s]||(r[s]=!0,t.push(s))}}return t}function H(){var e=L.packRequestGroup;for(var r in e)if(e.hasOwnProperty(r)){var n=e[r];if(n.length<1)continue;var o=n[0].clone(),s=-1!==o.url.indexOf("rest/maps");o.serverKey=n[0].serverKey,o.state=n[0].state;var u=o.url,a=N(n);if(a.length<1)continue;L.packRequestQuadKey[r]=s?a.join(","):a.join(";");var f=L.packRequestQuadKey[r];if(o.throttleByServer&&!K(o.serverKey)){M(n),L.packRequestPromise[r].reject();continue}o.deferred=L.packRequestPromise[r];var c=new i(u);c.query=s?t.defined(c.query)?c.query+"&tiles="+f:"tiles="+f:t.defined(c.query)?c.query+"&extratiles="+f:"extratiles="+f,o.url=c.toString(),X(o,o.url)}L.packRequestGroup={},L.packRequestPromise={},L.packRequestQuadKey={},L.quadKeyIndex={}}function Y(){var e=L.blockRequest;for(var t in e){if(e.hasOwnProperty(t))X(e[t])}L.blockRequest={}}function J(e){if(e.state===q.UNISSUED)if(e.state=q.ISSUED,e.type===b.PACK||e.type===b.BLOCKPACK){var r=V(e);t.defined(L.packRequestPromise[r])||(L.packRequestPromise[r]=t.when.defer()),e.deferred=L.packRequestPromise[r]}else e.deferred=t.when.defer();return e.deferred.promise}function X(e,r){var n=J(e);return e.state=q.ACTIVE,U.push(e),++T.numberOfActiveRequests,++T.numberOfActiveRequestsEver,++x[e.serverKey],e.startTime=C(),e.requestFunction(r).then(function(e){return function(r){if(e.state!==q.CANCELLED&&(--T.numberOfActiveRequests,--x[e.serverKey],B.raiseEvent(),e.state=q.RECEIVED,e.deferred.resolve(r),e.endTime=C(),(L.statisticRequestTime>0||e.type!==b.OTHER)&&(T.totalRequestTime+=e.endTime-e.startTime),e.type===b.BLOCK||e.type===b.BLOCKPACK)){var n=j(e);t.defined(L.blockDefer[n])&&(L.blockDefer[n]=void 0,delete L.blockDefer[n])}}}(e)).otherwise(function(e){return function(t){e.state!==q.CANCELLED&&(++T.numberOfFailedRequests,--T.numberOfActiveRequests,--x[e.serverKey],B.raiseEvent(t),e.state=q.FAILED,e.deferred.reject(t))}}(e)),n}function z(e){var r=e.state===q.ACTIVE;e.state=q.CANCELLED,++T.numberOfCancelledRequests,e.deferred.reject(),r&&(--T.numberOfActiveRequests,--x[e.serverKey],++T.numberOfCancelledActiveRequests),t.defined(e.cancelFunction)&&e.cancelFunction()}L.TIMEOUT=5e3,L.CANCLE_COUNT=3,L.statisticRequestTime=-1,L.maximumRequests=50,L.maximumRequestsPerServer=6,L.perPacketCount=20,L.requestsByServer={"api.cesium.com:443":18,"assets.cesium.com:443":18},L.throttleRequests=!0,L.debugShowStatistics=!1,L.requestCompletedEvent=B,Object.defineProperties(L,{activeRequestLength:{get:function(){return U.length}},statistics:{get:function(){return T}},priorityHeapLength:{get:function(){return S},set:function(e){if(e<S)for(;k.length>e;){z(k.pop())}S=e,k.maximumLength=e,k.reserve(e)}}}),L.packRequestGroup={},L.packRequestPromise={},L.packRequestQuadKey={},L.quadKeyIndex={},L.packRequestHeap={},L.blockDefer={},L.blockRequest={},L.update=function(){var e,t,r=0,n=U.length;for(e=0;e<n;++e)(t=U[e]).cancelled&&z(t),t.state===q.ACTIVE?r>0&&(U[e-r]=t):++r;U.length-=r;var i=k.internalArray,o=k.length;for(e=0;e<o;++e)D(i[e]);k.resort(),function(){for(var e in L.packRequestHeap)if(L.packRequestHeap.hasOwnProperty(e)){for(var t=L.packRequestHeap[e],r=t.internalArray,n=t.length,i=0;i<n;++i)D(r[i]);t.resort()}}(),Y(),function(){for(var e in L.packRequestHeap)if(L.packRequestHeap.hasOwnProperty(e))for(var t=L.packRequestHeap[e];t.length>0;){var r=t.pop();r.cancelled?z(r):F(r)}H()}();for(var s=Math.max(L.maximumRequests-U.length,0),u=0;u<s&&k.length>0;)(t=k.pop()).cancelled?z(t):!t.throttleByServer||K(t.serverKey)?(X(t),++u):z(t);!function(){if(!L.debugShowStatistics)return;0===T.numberOfActiveRequests&&T.lastNumberOfActiveRequests>0&&(T.numberOfAttemptedRequests>0&&(console.log("Number of attempted requests: "+T.numberOfAttemptedRequests),T.numberOfAttemptedRequests=0),T.numberOfCancelledRequests>0&&(console.log("Number of cancelled requests: "+T.numberOfCancelledRequests),T.numberOfCancelledRequests=0),T.numberOfCancelledActiveRequests>0&&(console.log("Number of cancelled active requests: "+T.numberOfCancelledActiveRequests),T.numberOfCancelledActiveRequests=0),T.numberOfFailedRequests>0&&(console.log("Number of failed requests: "+T.numberOfFailedRequests),T.numberOfFailedRequests=0));T.lastNumberOfActiveRequests=T.numberOfActiveRequests}()},L.getServerKey=function(e){var r=new i(e).resolve(P);r.normalize();var n=r.authority;/:/.test(n)||(n=n+":"+("https"===r.scheme?"443":"80"));var o=x[n];return t.defined(o)||(x[n]=0),n},L.request=function(e){if(g(e.url)||y(e.url))return B.raiseEvent(),e.state=q.RECEIVED,e.requestFunction();if(++T.numberOfAttemptedRequests,t.defined(e.serverKey)||(e.serverKey=L.getServerKey(e.url)),e.type===b.BLOCK)return function(e){var r=j(e),n=L.blockDefer[r];return t.defined(n)||(n=L.blockDefer[r]=t.when.defer(),L.blockRequest[r]=e),e.deferred=n,e.state=q.ISSUED,e.deferred.promise}(e);if(!e.throttleByServer||K(e.serverKey)){if(!L.throttleRequests||!e.throttle)return X(e);if(!(U.length>=L.maximumRequests)){var r;if(D(e),e.type===b.PACK||e.type===b.BLOCKPACK){var n=function(e){var r=V(e),n=L.packRequestHeap[r];return t.defined(n)||((n=L.packRequestHeap[r]=new O({comparator:I})).maximumLength=L.perPacketCount,n.reserve(S)),n}(e),i=!0;if(e.type===b.BLOCKPACK)for(var o=0;o<n.length;o++)if(n._array[o].quadKey===e.quadKey){e.blockRequest=n._array[o],i=!1;break}i&&(r=n.insert(e))}else r=k.insert(e);if(t.defined(r)){if(r===e)return;z(r)}return J(e)}}},L.clearForSpecs=function(){for(;k.length>0;){z(k.pop())}for(var e=U.length,t=0;t<e;++t)z(U[t]);U.length=0,x={},T.numberOfAttemptedRequests=0,T.numberOfActiveRequests=0,T.numberOfCancelledRequests=0,T.numberOfCancelledActiveRequests=0,T.numberOfFailedRequests=0,T.numberOfActiveRequestsEver=0,T.lastNumberOfActiveRequests=0,T.totalRequestTime=0},L.numberOfActiveRequestsByServer=function(e){return x[e]},L.requestHeap=k;var Q={},G={};Q.add=function(e,r){var n=e.toLowerCase()+":"+r;t.defined(G[n])||(G[n]=!0)},Q.remove=function(e,r){var n=e.toLowerCase()+":"+r;t.defined(G[n])&&delete G[n]},Q.contains=function(e){var r=function(e){var r=new i(e);r.normalize();var n=r.getAuthority();if(t.defined(n)){if(-1!==n.indexOf("@")){var o=n.split("@");n=o[1]}if(-1===n.indexOf(":")){var s=r.getScheme();if(t.defined(s)||(s=(s=window.location.protocol).substring(0,s.length-1)),"http"===s)n+=":80";else{if("https"!==s)return;n+=":443"}}return n}}(e);return!(!t.defined(r)||!t.defined(G[r]))},Q.clear=function(){G={}};var W={};function $(e,r){t.defined(W[e])||(W[e]=!0,console.warn(t.defaultValue(r,e)))}$.geometryOutlines="Entity geometry outlines are unsupported on terrain. Outlines will be disabled. To enable outlines, disable geometry terrain clamping by explicitly setting height to 0.",$.geometryZIndex="Entity geometry with zIndex are unsupported when height or extrudedHeight are defined.  zIndex will be ignored",$.geometryHeightReference="Entity corridor, ellipse, polygon or rectangle with heightReference must also have a defined height.  heightReference will be ignored",$.geometryExtrudedHeightReference="Entity corridor, ellipse, polygon or rectangle with extrudedHeightReference must also have a defined extrudedHeight.  extrudedHeightReference will be ignored";var Z,ee=function(){try{var e=new XMLHttpRequest;return e.open("GET","#",!0),e.responseType="blob","blob"===e.responseType}catch(e){return!1}}();function te(e,r,n,i){var o,s=e.query;if(!t.defined(s)||0===s.length)return{};if(-1===s.indexOf("=")){var u={};u[s]=void 0,o=u}else o=function(e){var r={};if(""===e)return r;for(var n=e.replace(/\+/g,"%20").split(/[&;]/),i=0,o=n.length;i<o;++i){var s=n[i].split("=");if(s.length>2){var u=n[i].indexOf("=");s=[n[i].substring(0,u),n[i].substring(u+1,n[i].length)]}var a=decodeURIComponent(s[0]),f=s[1];f=t.defined(f)?decodeURIComponent(f):"";var c=r[a];"string"==typeof c?r[a]=[c,f]:Array.isArray(c)?c.push(f):r[a]=f}return r}(s);r._queryParameters=n?oe(o,r._queryParameters,i):o,e.query=void 0}function re(e,r){var n=r._queryParameters,i=Object.keys(n);1!==i.length||t.defined(n[i[0]])?e.query=function(e,t){var r="";for(var n in e)if(e.hasOwnProperty(n)){var i=e[n],o=encodeURIComponent(n)+"=";if(Array.isArray(i))for(var s=0,u=i.length;s<u;++s)r+=!0===t?o+encodeURI(i[s])+"&":o+encodeURIComponent(i[s])+"&";else r+=!0===t?o+encodeURI(i)+"&":o+encodeURIComponent(i)+"&"}return r.slice(0,-1)}(n):e.query=i[0]}function ne(e,r){return t.defined(e)?t.defined(e.clone)?e.clone():p(e):r}function ie(e){if(e.state===q.ISSUED||e.state===q.ACTIVE)throw new n.RuntimeError("The Resource is already being fetched.");e.state=q.UNISSUED,e.deferred=void 0}function oe(e,r,n){if(!n)return l(e,r);var i=p(e,!0);for(var o in r)if(r.hasOwnProperty(o)){var s=i[o],u=r[o];t.defined(s)?(Array.isArray(s)||(s=i[o]=[s]),i[o]=s.concat(u)):i[o]=Array.isArray(u)?u.slice():u}return i}function se(e){"string"==typeof(e=t.defaultValue(e,t.defaultValue.EMPTY_OBJECT))&&(e={url:e}),this._url=void 0,this._templateValues=ne(e.templateValues,{}),this._queryParameters=ne(e.queryParameters,{}),this.headers=ne(e.headers,{}),this.request=t.defaultValue(e.request,new R),this.proxy=e.proxy,this.retryCallback=e.retryCallback,this.retryAttempts=t.defaultValue(e.retryAttempts,0),this._retryCount=0;var r=new i(e.url);te(r,this,!0,!0),r.fragment=void 0,this._url=r.toString()}function ue(e){var r=e.resource,n=e.flipY,i=e.preferImageBitmap,o=r.request;o.url=r.url,o.requestFunction=function(){var e=!1;r.isDataUri||r.isBlobUri||(e=r.isCrossOriginUrl);var s=t.when.defer();return se._Implementations.createImage(o,e,s,n,i),s.promise};var s=L.request(o);if(t.defined(s))return s.otherwise((function(e){return o.state!==q.FAILED?t.when.reject(e):r.retryOnError(e).then((function(s){return s?(o.state=q.UNISSUED,o.deferred=void 0,ue({resource:r,flipY:n,preferImageBitmap:i})):t.when.reject(e)}))}))}function ae(e,r,n){var i={};i[r]=n,e.setQueryParameters(i);var o=e.request;o.url=e.url,o.requestFunction=function(){var r=t.when.defer();return window[n]=function(e){r.resolve(e);try{delete window[n]}catch(e){window[n]=void 0}},se._Implementations.loadAndExecuteScript(e.url,n,r),r.promise};var s=L.request(o);if(t.defined(s))return s.otherwise((function(i){return o.state!==q.FAILED?t.when.reject(i):e.retryOnError(i).then((function(s){return s?(o.state=q.UNISSUED,o.deferred=void 0,ae(e,r,n)):t.when.reject(i)}))}))}se.createIfNeeded=function(e){return e instanceof se?e.getDerivedResource({request:e.request}):"string"!=typeof e?e:new se({url:e})},se.supportsImageBitmapOptions=function(){if(t.defined(Z))return Z;if("function"!=typeof createImageBitmap)return Z=t.when.resolve(!1);return Z=se.fetchBlob({url:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWP4////fwAJ+wP9CNHoHgAAAABJRU5ErkJggg=="}).then((function(e){return createImageBitmap(e,{imageOrientation:"flipY",premultiplyAlpha:"none"})})).then((function(e){return!0})).otherwise((function(){return!1}))},Object.defineProperties(se,{isBlobSupported:{get:function(){return ee}}}),Object.defineProperties(se.prototype,{queryParameters:{get:function(){return this._queryParameters}},templateValues:{get:function(){return this._templateValues}},url:{get:function(){return this.getUrlComponent(!0,!0)},set:function(e){var t=new i(e);te(t,this,!1),t.fragment=void 0,this._url=t.toString()}},extension:{get:function(){return function(e){var t=new i(e);t.normalize();var r=t.path,n=r.lastIndexOf("/");return-1!==n&&(r=r.substr(n+1)),n=r.lastIndexOf("."),-1===n?"":r.substr(n+1)}(this._url)}},isDataUri:{get:function(){return g(this._url)}},isBlobUri:{get:function(){return y(this._url)}},isCrossOriginUrl:{get:function(){return function(e){t.defined(d)||(d=document.createElement("a")),d.href=window.location.href;var r=d.host,n=d.protocol;return d.href=e,d.href=d.href,n!==d.protocol||r!==d.host}(this._url)}},hasHeaders:{get:function(){return Object.keys(this.headers).length>0}}}),se.prototype.getUrlComponent=function(e,r){if(this.isDataUri)return this._url;var n=new i(this._url);e&&re(n,this);var o=n.toString().replace(/%7B/g,"{").replace(/%7D/g,"}"),s=this._templateValues;return o=o.replace(/{(.*?)}/g,(function(e,r){var n=s[r];return t.defined(n)?encodeURIComponent(n):e})),r&&t.defined(this.proxy)&&(o=this.proxy.getURL(o)),o},se.prototype.setQueryParameters=function(e,t){this._queryParameters=t?oe(this._queryParameters,e,!1):oe(e,this._queryParameters,!1)},se.prototype.appendQueryParameters=function(e){this._queryParameters=oe(e,this._queryParameters,!0)},se.prototype.setTemplateValues=function(e,t){this._templateValues=t?l(this._templateValues,e):l(e,this._templateValues)},se.prototype.getDerivedResource=function(e){var r=this.clone();if(r._retryCount=0,t.defined(e.url)){var n=new i(e.url);te(n,r,!0,t.defaultValue(e.preserveQueryParameters,!1)),n.fragment=void 0,r._url=n.resolve(new i(h(this._url))).toString()}return t.defined(e.queryParameters)&&(r._queryParameters=l(e.queryParameters,r._queryParameters)),t.defined(e.templateValues)&&(r._templateValues=l(e.templateValues,r.templateValues)),t.defined(e.headers)&&(r.headers=l(e.headers,r.headers)),t.defined(e.proxy)&&(r.proxy=e.proxy),t.defined(e.request)&&(r.request=e.request),t.defined(e.retryCallback)&&(r.retryCallback=e.retryCallback),t.defined(e.retryAttempts)&&(r.retryAttempts=e.retryAttempts),r},se.prototype.retryOnError=function(e){var r=this.retryCallback;if("function"!=typeof r||this._retryCount>=this.retryAttempts)return t.when(!1);var n=this;return t.when(r(this,e)).then((function(e){return++n._retryCount,e}))},se.prototype.clone=function(e){return t.defined(e)||(e=new se({url:this._url})),e._url=this._url,e._queryParameters=p(this._queryParameters),e._templateValues=p(this._templateValues),e.headers=p(this.headers),e.proxy=this.proxy,e.retryCallback=this.retryCallback,e.retryAttempts=this.retryAttempts,e._retryCount=0,e.request=this.request.clone(),e},se.prototype.getBaseUri=function(e){return function(e,r){var n="",o=e.lastIndexOf("/");return-1!==o&&(n=e.substring(0,o+1)),r?(e=new i(e),t.defined(e.query)&&(n+="?"+e.query),t.defined(e.fragment)&&(n+="#"+e.fragment),n):n}(this.getUrlComponent(e),e)},se.prototype.appendForwardSlash=function(){var e;this._url=(0!==(e=this._url).length&&"/"===e[e.length-1]||(e+="/"),e)},se.prototype.fetchArrayBuffer=function(){return this.fetch({responseType:"arraybuffer"})},se.fetchArrayBuffer=function(e){return new se(e).fetchArrayBuffer()},se.prototype.fetchBlob=function(){return this.fetch({responseType:"blob"})},se.fetchBlob=function(e){return new se(e).fetchBlob()},se.prototype.fetchImage=function(e){e=t.defaultValue(e,t.defaultValue.EMPTY_OBJECT);var r=t.defaultValue(e.preferImageBitmap,!1),n=t.defaultValue(e.preferBlob,!1),i=t.defaultValue(e.flipY,!1);if(ie(this.request),!ee||this.isDataUri||this.isBlobUri||!this.hasHeaders&&!n)return ue({resource:this,flipY:i,preferImageBitmap:r});var o,s,u,a=this.fetchBlob();return t.defined(a)?se.supportsImageBitmapOptions().then((function(e){return o=e&&r,a})).then((function(e){if(t.defined(e)){if(u=e,o)return se.createImageBitmapFromBlob(e,{flipY:i,premultiplyAlpha:!1});var r=window.URL.createObjectURL(e);return ue({resource:s=new se({url:r}),flipY:i,preferImageBitmap:!1})}})).then((function(e){if(t.defined(e))return e.blob=u,o||window.URL.revokeObjectURL(s.url),e})).otherwise((function(e){return t.defined(s)&&window.URL.revokeObjectURL(s.url),e.blob=u,t.when.reject(e)})):void 0},se.fetchImage=function(e){return new se(e).fetchImage({flipY:e.flipY,preferBlob:e.preferBlob,preferImageBitmap:e.preferImageBitmap})},se.prototype.fetchText=function(){return this.fetch({responseType:"text"})},se.fetchText=function(e){return new se(e).fetchText()},se.prototype.fetchJson=function(){var e=this.fetch({responseType:"text",headers:{Accept:"application/json,*/*;q=0.01"}});if(t.defined(e))return e.then((function(e){if(t.defined(e))return JSON.parse(e)}))},se.fetchJson=function(e){return new se(e).fetchJson()},se.prototype.fetchXML=function(){return this.fetch({responseType:"document",overrideMimeType:"text/xml"})},se.fetchXML=function(e){return new se(e).fetchXML()},se.prototype.fetchJsonp=function(e){var r;e=t.defaultValue(e,"callback"),ie(this.request);do{r="loadJsonp"+Math.random().toString().substring(2,8)}while(t.defined(window[r]));return ae(this,e,r)},se.fetchJsonp=function(e){return new se(e).fetchJsonp(e.callbackParameterName)},se.prototype._makeRequest=function(e){var r=this;ie(r.request);var n=r.request;n.url=r.url,n.requestFunction=function(i){var o=e.responseType,s=l(e.headers,r.headers),u=e.overrideMimeType,a=e.method,f=e.data,c=t.when.defer(),p=t.defined(i)?i:r.url,h=se._Implementations.loadWithXhr(p,o,a,f,s,c,u);return t.defined(h)&&t.defined(h.abort)&&(n.cancelFunction=function(){h.abort()}),c.promise};var i=L.request(n);if(t.defined(i))return i.then((function(e){return e})).otherwise((function(i){return n.state!==q.FAILED?t.when.reject(i):r.retryOnError(i).then((function(o){return o?(n.state=q.UNISSUED,n.deferred=void 0,r.fetch(e)):t.when.reject(i)}))}))};var fe=/^data:(.*?)(;base64)?,(.*)$/;function ce(e,t){var r=decodeURIComponent(t);return e?atob(r):r}function pe(e,t){for(var r=ce(e,t),n=new ArrayBuffer(r.length),i=new Uint8Array(n),o=0;o<r.length;o++)i[o]=r.charCodeAt(o);return n}function le(e,t){switch(t){case"text":return e.toString("utf8");case"json":return JSON.parse(e.toString("utf8"));default:return new Uint8Array(e).buffer}}se.prototype.fetch=function(e){return(e=ne(e,{})).method="GET",this._makeRequest(e)},se.fetch=function(e){return new se(e).fetch({responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se.prototype.delete=function(e){return(e=ne(e,{})).method="DELETE",this._makeRequest(e)},se.delete=function(e){return new se(e).delete({responseType:e.responseType,overrideMimeType:e.overrideMimeType,data:e.data})},se.prototype.head=function(e){return(e=ne(e,{})).method="HEAD",this._makeRequest(e)},se.head=function(e){return new se(e).head({responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se.prototype.options=function(e){return(e=ne(e,{})).method="OPTIONS",this._makeRequest(e)},se.options=function(e){return new se(e).options({responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se.prototype.post=function(e,t){return r.Check.defined("data",e),(t=ne(t,{})).method="POST",t.data=e,this._makeRequest(t)},se.post=function(e){return new se(e).post(e.data,{responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se.prototype.put=function(e,t){return r.Check.defined("data",e),(t=ne(t,{})).method="PUT",t.data=e,this._makeRequest(t)},se.put=function(e){return new se(e).put(e.data,{responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se.prototype.patch=function(e,t){return r.Check.defined("data",e),(t=ne(t,{})).method="PATCH",t.data=e,this._makeRequest(t)},se.patch=function(e){return new se(e).patch(e.data,{responseType:e.responseType,overrideMimeType:e.overrideMimeType})},se._Implementations={},se._Implementations.createImage=function(e,r,i,o,s){var u=e.url;se.supportsImageBitmapOptions().then((function(a){if(a&&s){var f=t.when.defer(),c=se._Implementations.loadWithXhr(u,"blob","GET",void 0,void 0,f,void 0,void 0,void 0);return t.defined(c)&&t.defined(c.abort)&&(e.cancelFunction=function(){c.abort()}),f.promise.then((function(e){if(t.defined(e))return se.createImageBitmapFromBlob(e,{flipY:o,premultiplyAlpha:!1});i.reject(new n.RuntimeError("Successfully retrieved "+u+" but it contained no content."))})).then(i.resolve)}!function(e,t,r){var n=new Image;n.onload=function(){r.resolve(n)},n.onerror=function(e){r.reject(e)},t&&(Q.contains(e)?n.crossOrigin="use-credentials":n.crossOrigin=""),n.src=e}(u,r,i)})).otherwise(i.reject)},se.createImageBitmapFromBlob=function(e,t){return r.Check.defined("options",t),r.Check.typeOf.bool("options.flipY",t.flipY),r.Check.typeOf.bool("options.premultiplyAlpha",t.premultiplyAlpha),createImageBitmap(e,{imageOrientation:t.flipY?"flipY":"none",premultiplyAlpha:t.premultiplyAlpha?"premultiply":"none"})};var he="undefined"==typeof XMLHttpRequest;se._Implementations.loadWithXhr=function(e,r,i,o,s,u,a){var f=fe.exec(e);if(null===f){if(!he){var c=new XMLHttpRequest;if(Q.contains(e)&&(c.withCredentials=!0),e=e.replace(/{/g,"%7B").replace(/}/g,"%7D"),c.open(i,e,!0),t.defined(a)&&t.defined(c.overrideMimeType)&&c.overrideMimeType(a),t.defined(s))for(var p in s)s.hasOwnProperty(p)&&c.setRequestHeader(p,s[p]);t.defined(r)&&(c.responseType=r);var l=!1;return"string"==typeof e&&(l=0===e.indexOf("file://")||"undefined"!=typeof window&&"file://"===window.location.origin),c.onload=function(){if(!(c.status<200||c.status>=300)||l&&0===c.status){var e=c.response,o=c.responseType;if("HEAD"===i||"OPTIONS"===i){var s=c.getAllResponseHeaders().trim().split(/[\r\n]+/),a={};return s.forEach((function(e){var t=e.split(": "),r=t.shift();a[r]=t.join(": ")})),void u.resolve(a)}if(204===c.status)u.resolve();else if(!t.defined(e)||t.defined(r)&&o!==r)if("json"===r&&"string"==typeof e)try{u.resolve(JSON.parse(e))}catch(e){u.reject(e)}else(""===o||"document"===o)&&t.defined(c.responseXML)&&c.responseXML.hasChildNodes()?u.resolve(c.responseXML):""!==o&&"text"!==o||!t.defined(c.responseText)?u.reject(new n.RuntimeError("Invalid XMLHttpRequest response type.")):u.resolve(c.responseText);else u.resolve(e)}else u.reject(new w(c.status,c.response,c.getAllResponseHeaders()))},c.onerror=function(e){u.reject(new w)},c.send(o),c}!function(e,t,r,i,o,s,u){var a=require("url").parse(e),f="https:"===a.protocol?require("https"):require("http"),c=require("zlib"),p={protocol:a.protocol,hostname:a.hostname,port:a.port,path:a.path,query:a.query,method:r,headers:o};f.request(p).on("response",(function(e){if(e.statusCode<200||e.statusCode>=300)s.reject(new w(e.statusCode,e,e.headers));else{var r=[];e.on("data",(function(e){r.push(e)})),e.on("end",(function(){var i=Buffer.concat(r);"gzip"===e.headers["content-encoding"]?c.gunzip(i,(function(e,r){e?s.reject(new n.RuntimeError("Error decompressing response.")):s.resolve(le(r,t))})):s.resolve(le(i,t))}))}})).on("error",(function(e){s.reject(new w)})).end()}(e,r,i,0,s,u)}else u.resolve(function(e,r){r=t.defaultValue(r,"");var n=e[1],i=!!e[2],o=e[3];switch(r){case"":case"text":return ce(i,o);case"arraybuffer":return pe(i,o);case"blob":var s=pe(i,o);return new Blob([s],{type:n});case"document":return(new DOMParser).parseFromString(ce(i,o),n);case"json":return JSON.parse(ce(i,o))}}(f,r))},se._Implementations.loadAndExecuteScript=function(e,r,n){return function(e){var r=t.when.defer(),n=document.createElement("script");n.async=!0,n.src=e;var i=document.getElementsByTagName("head")[0];return n.onload=function(){n.onload=void 0,i.removeChild(n),r.resolve()},n.onerror=function(e){r.reject(e)},i.appendChild(n),r.promise}(e).otherwise(n.reject)},se._DefaultImplementations={},se._DefaultImplementations.createImage=se._Implementations.createImage,se._DefaultImplementations.loadWithXhr=se._Implementations.loadWithXhr,se._DefaultImplementations.loadAndExecuteScript=se._Implementations.loadAndExecuteScript,se.DEFAULT=Object.freeze(new se({url:"undefined"==typeof document?"":document.location.href.split("?")[0]}));var de,me,ye,ve=/((?:.*\/)|^)Cesium\.js$/;function ge(e){return"undefined"==typeof document?e:(t.defined(de)||(de=document.createElement("a")),de.href=e,de.href=de.href,de.href)}function qe(){return t.defined(me)||(e="undefined"!=typeof CESIUM_BASE_URL?CESIUM_BASE_URL:"object"==typeof define&&t.defined(define.amd)&&!define.amd.toUrlUndefined&&t.defined(require.toUrl)?h("..",we("Core/buildModuleUrl.js")):function(){for(var e=document.getElementsByTagName("script"),t=0,r=e.length;t<r;++t){var n=e[t].getAttribute("src"),i=ve.exec(n);if(null!==i)return i[1]}}(),(me=new se({url:ge(e)})).appendForwardSlash()),me;var e}function be(e){return ge(require.toUrl("../"+e))}function Re(e){return qe().getDerivedResource({url:e}).url}function we(e){return t.defined(ye)||(ye="object"==typeof define&&t.defined(define.amd)&&!define.amd.toUrlUndefined&&t.defined(require.toUrl)?be:Re),ye(e)}we._cesiumScriptRegex=ve,we._buildModuleUrlFromBaseUrl=Re,we._clearBaseResource=function(){me=void 0},we.setBaseUrl=function(e){me=se.DEFAULT.getDerivedResource({url:e})},we.getCesiumBaseUrl=qe,e.Resource=se,e.buildModuleUrl=we,e.oneTimeWarning=$}));
