/** * Cesium - https://github.com/CesiumGS/cesium * * Copyright 2011-2020 Cesium Contributors * * 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. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/master/LICENSE.md for full licensing details. */ define(["exports","./when-8d13db60","./Check-70bec281","./RuntimeError-ba10bc3e"],function(e,b,w,R){function f(e){if(e instanceof f)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=r.exec(e);this.scheme=t[1],this.authority=t[2],this.path=t[3],this.query=t[4],this.fragment=t[5]}}f.prototype.scheme=null,f.prototype.authority=null,f.prototype.path="",f.prototype.query=null,f.prototype.fragment=null;var r=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?$");f.prototype.getScheme=function(){return this.scheme},f.prototype.getAuthority=function(){return this.authority},f.prototype.getPath=function(){return this.path},f.prototype.getQuery=function(){return this.query},f.prototype.getFragment=function(){return this.fragment},f.prototype.isAbsolute=function(){return!!this.scheme&&!this.fragment},f.prototype.isSameDocumentAs=function(e){return e.scheme==this.scheme&&e.authority==this.authority&&e.path==this.path&&e.query==this.query},f.prototype.equals=function(e){return this.isSameDocumentAs(e)&&e.fragment==this.fragment},f.prototype.normalize=function(){this.removeDotSegments(),this.scheme&&(this.scheme=this.scheme.toLowerCase()),this.authority&&(this.authority=this.authority.replace(i,s).replace(t,o)),this.path&&(this.path=this.path.replace(t,o)),this.query&&(this.query=this.query.replace(t,o)),this.fragment&&(this.fragment=this.fragment.replace(t,o))};var t=/%[0-9a-z]{2}/gi,n=/[a-zA-Z0-9\-\._~]/,i=/(.*@)?([^@:]*)(:.*)?/;function o(e){var t=unescape(e);return n.test(t)?t:e.toUpperCase()}function s(e,t,r,n){return(t||"")+r.toLowerCase()+(n||"")}function u(e,t){if(null===e||"object"!=typeof e)return e;t=b.defaultValue(t,!1);var r=new e.constructor;for(var n in e)if(e.hasOwnProperty(n)){var i=e[n];t&&(i=u(i,t)),r[n]=i}return r}function d(e,t,r){r=b.defaultValue(r,!1);var n,i,o,s={},u=b.defined(e),a=b.defined(t);if(u)for(n in e)e.hasOwnProperty(n)&&(i=e[n],a&&r&&"object"==typeof i&&t.hasOwnProperty(n)?(o=t[n],s[n]="object"==typeof o?d(i,o,r):i):s[n]=i);if(a)for(n in t)t.hasOwnProperty(n)&&!s.hasOwnProperty(n)&&(o=t[n],s[n]=o);return s}function a(e,t){var r;return"undefined"!=typeof document&&(r=document),a._implementation(e,t,r)}f.prototype.resolve=function(e){var t=new f;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: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},f.prototype.removeDotSegments=function(){var e,t=this.path.split("/"),r=[],n=""==t[0];n&&t.shift();for(""==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("/")},f.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},a._implementation=function(e,t,r){if(!b.defined(e))throw new w.DeveloperError("relative uri is required.");if(!b.defined(t)){if(void 0===r)return e;t=b.defaultValue(r.baseURI,r.location.href)}var n=new f(t);return new f(e).resolve(n).toString()};var c,p=/^blob:/i;function h(e){return w.Check.typeOf.string("uri",e),p.test(e)}var l=/^data:/i;function m(e){return w.Check.typeOf.string("uri",e),l.test(e)}var y=Object.freeze({UNISSUED:0,ISSUED:1,ACTIVE:2,RECEIVED:3,CANCELLED:4,FAILED:5}),v=Object.freeze({TERRAIN:0,IMAGERY:1,TILES3D:2,OTHER:3,PACK:4,BLOCK:5,BLOCKPACK:6});function g(e){e=b.defaultValue(e,b.defaultValue.EMPTY_OBJECT);var t=b.defaultValue(e.throttleByServer,!1),r=b.defaultValue(e.throttle,!1);this.url=e.url,this.requestFunction=e.requestFunction,this.cancelFunction=e.cancelFunction,this.priorityFunction=e.priorityFunction,this.priority=b.defaultValue(e.priority,0),this.throttle=r,this.throttleByServer=t,this.type=b.defaultValue(e.type,v.OTHER),this.serverKey=void 0,this.state=y.UNISSUED,this.deferred=void 0,this.cancelled=!1}function A(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;ne&&0i&&(t=r[i],r.pop(),this._length=i),t},_.prototype.pop=function(e){if(e=b.defaultValue(e,0),0!==this._length){w.Check.typeOf.number.lessThan("index",e,this._length);var t=this._array,r=t[e];return E(t,e,--this._length),t[this._length]=void 0,this.heapify(e),r}};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 k={numberOfAttemptedRequests:0,numberOfActiveRequests:0,numberOfCancelledRequests:0,numberOfCancelledActiveRequests:0,numberOfFailedRequests:0,numberOfActiveRequestsEver:0,lastNumberOfActiveRequests:0,totalRequestTime:0},T=20,S=new _({comparator:I});S.maximumLength=T,S.reserve(T);var U=[],x={},P="undefined"!=typeof document?new f(document.location.href):new f,B=new q;function D(){}function L(e){b.defined(e.priorityFunction)&&(e.priority=e.priorityFunction())}function K(e){var t=b.defaultValue(D.requestsByServer[e],D.maximumRequestsPerServer);return x[e]e;){X(S.pop())}T=e,S.maximumLength=e,S.reserve(e)}}}),D.packRequestGroup={},D.packRequestPromise={},D.packRequestQuadKey={},D.quadKeyIndex={},D.packRequestHeap={},D.blockDefer={},D.blockRequest={},D.update=function(){var e,t,r=0,n=U.length;for(e=0;e=D.maximumRequests)){var i,o,s;if(L(e),e.type===v.PACK||e.type===v.BLOCKPACK){var u=(o=j(e),s=D.packRequestHeap[o],b.defined(s)||((s=D.packRequestHeap[o]=new _({comparator:I})).maximumLength=D.perPacketCount,s.reserve(T)),s),a=!0;if(e.type===v.BLOCKPACK)for(var f=0;f=this.retryAttempts)return b.when(!1);var r=this;return b.when(t(this,e)).then(function(e){return++r._retryCount,e})},oe.prototype.clone=function(e){return b.defined(e)||(e=new oe({url:this._url})),e._url=this._url,e._queryParameters=u(this._queryParameters),e._templateValues=u(this._templateValues),e.headers=u(this.headers),e.proxy=this.proxy,e.retryCallback=this.retryCallback,e.retryAttempts=this.retryAttempts,e._retryCount=0,e.request=this.request.clone(),e},oe.prototype.getBaseUri=function(e){return function(e,t){if(!b.defined(e))throw new w.DeveloperError("uri is required.");var r="",n=e.lastIndexOf("/");return-1!==n&&(r=e.substring(0,n+1)),t&&(e=new f(e),b.defined(e.query)&&(r+="?"+e.query),b.defined(e.fragment)&&(r+="#"+e.fragment)),r}(this.getUrlComponent(e),e)},oe.prototype.appendForwardSlash=function(){var e;this._url=(0!==(e=this._url).length&&"/"===e[e.length-1]||(e+="/"),e)},oe.prototype.fetchArrayBuffer=function(){return this.fetch({responseType:"arraybuffer"})},oe.fetchArrayBuffer=function(e){return new oe(e).fetchArrayBuffer()},oe.prototype.fetchBlob=function(){return this.fetch({responseType:"blob"})},oe.fetchBlob=function(e){return new oe(e).fetchBlob()},oe.prototype.fetchImage=function(e){e=b.defaultValue(e,b.defaultValue.EMPTY_OBJECT);var t=b.defaultValue(e.preferImageBitmap,!1),r=b.defaultValue(e.preferBlob,!1),n=b.defaultValue(e.flipY,!1);if(ne(this.request),!Z||this.isDataUri||this.isBlobUri||!this.hasHeaders&&!r)return se({resource:this,flipY:n,preferImageBitmap:t});var i,o,s,u=this.fetchBlob();return b.defined(u)?oe.supportsImageBitmapOptions().then(function(e){return i=e&&t,u}).then(function(e){if(b.defined(e)){if(s=e,i)return oe.createImageBitmapFromBlob(e,{flipY:n,premultiplyAlpha:!1});var t=window.URL.createObjectURL(e);return se({resource:o=new oe({url:t}),flipY:n,preferImageBitmap:!1})}}).then(function(e){if(b.defined(e))return e.blob=s,i||window.URL.revokeObjectURL(o.url),e}).otherwise(function(e){return b.defined(o)&&window.URL.revokeObjectURL(o.url),e.blob=s,b.when.reject(e)}):void 0},oe.fetchImage=function(e){return new oe(e).fetchImage({flipY:e.flipY,preferBlob:e.preferBlob,preferImageBitmap:e.preferImageBitmap})},oe.prototype.fetchText=function(){return this.fetch({responseType:"text"})},oe.fetchText=function(e){return new oe(e).fetchText()},oe.prototype.fetchJson=function(){var e=this.fetch({responseType:"text",headers:{Accept:"application/json,*/*;q=0.01"}});if(b.defined(e))return e.then(function(e){if(b.defined(e))return JSON.parse(e)})},oe.fetchJson=function(e){return new oe(e).fetchJson()},oe.prototype.fetchXML=function(){return this.fetch({responseType:"document",overrideMimeType:"text/xml"})},oe.fetchXML=function(e){return new oe(e).fetchXML()},oe.prototype.fetchJsonp=function(e){var t;for(e=b.defaultValue(e,"callback"),ne(this.request);t="loadJsonp"+Math.random().toString().substring(2,8),b.defined(window[t]););return function r(n,i,o){var e={};e[i]=o;n.setQueryParameters(e);var s=n.request;s.url=n.url;s.requestFunction=function(){var t=b.when.defer();return window[o]=function(e){t.resolve(e);try{delete window[o]}catch(e){window[o]=void 0}},oe._Implementations.loadAndExecuteScript(n.url,o,t),t.promise};var t=D.request(s);if(!b.defined(t))return;return t.otherwise(function(t){return s.state!==y.FAILED?b.when.reject(t):n.retryOnError(t).then(function(e){return e?(s.state=y.UNISSUED,s.deferred=void 0,r(n,i,o)):b.when.reject(t)})})}(this,e,t)},oe.fetchJsonp=function(e){return new oe(e).fetchJsonp(e.callbackParameterName)},oe.prototype._makeRequest=function(f){var c=this;ne(c.request);var p=c.request;p.url=c.url,p.requestFunction=function(e){var t=f.responseType,r=d(f.headers,c.headers),n=f.overrideMimeType,i=f.method,o=f.data,s=b.when.defer(),u=b.defined(e)?e:c.url,a=oe._Implementations.loadWithXhr(u,t,i,o,r,s,n);return b.defined(a)&&b.defined(a.abort)&&(p.cancelFunction=function(){a.abort()}),s.promise};var e=D.request(p);if(b.defined(e))return e.then(function(e){return e}).otherwise(function(t){return p.state!==y.FAILED?b.when.reject(t):c.retryOnError(t).then(function(e){return e?(p.state=y.UNISSUED,p.deferred=void 0,c.fetch(f)):b.when.reject(t)})})};var ue=/^data:(.*?)(;base64)?,(.*)$/;function ae(e,t){var r=decodeURIComponent(t);return e?atob(r):r}function fe(e,t){for(var r=ae(e,t),n=new ArrayBuffer(r.length),i=new Uint8Array(n),o=0;o