'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
var composables = require('../composables');
var cesiumProps = require('../utils/cesium-props');
var util = require('../utils/util');
var coordtransform = require('../utils/coordtransform');
var cesiumHelpers = require('../utils/cesium-helpers');
var vm = require('../utils/private/vm');

var VcProviderImageryArcgis = vue.defineComponent({
    name: 'VcProviderImageryArcgis',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ url: {
            type: String,
            default: 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer'
        } }, cesiumProps.token), cesiumProps.tileDiscardPolicy), { usePreCachedTilesIfAvailable: {
            type: Boolean,
            default: true
        } }), cesiumProps.layers), cesiumProps.enablePickFeatures), cesiumProps.rectangle), cesiumProps.tilingScheme), cesiumProps.ellipsoid), cesiumProps.credit), cesiumProps.tileWidth), cesiumProps.tileHeight), cesiumProps.maximumLevel),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'ArcGisMapServerImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

/*! *****************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

class Point {
    constructor(lng, lat) {
        if (isNaN(lng)) {
            lng = isNaN(lng) ? 0 : lng;
        }
        if (util.isString(lng)) {
            lng = parseFloat(lng);
        }
        if (isNaN(lat)) {
            lat = isNaN(lat) ? 0 : lat;
        }
        if (util.isString(lat)) {
            lat = parseFloat(lat);
        }
        this.lng = lng;
        this.lat = lat;
    }
    equals(other) {
        return other && this.lat === other.lat && this.lng === other.lng;
    }
}
Point.isInRange = function (pt) {
    return pt && pt.lng <= 180 && pt.lng >= -180 && pt.lat <= 74 && pt.lat >= -74;
};

class Pixel {
    constructor(x, y) {
        this.x = x || 0;
        this.y = y || 0;
    }
    equals(other) {
        return other && other.x === this.x && other.y === this.y;
    }
}

class BaiduMapMercatorProjection {
    lngLatToMercator(point, curCity) {
        return BaiduMapMercatorProjection.convertLL2MC(point);
    }
    lngLatToPoint(point) {
        const mercator = BaiduMapMercatorProjection.convertLL2MC(point);
        return new Pixel(mercator.lng, mercator.lat);
    }
    mercatorToLngLat(point, curCity) {
        return BaiduMapMercatorProjection.convertMC2LL(point);
    }
    pointToLngLat(point) {
        const mercator = new Point(point.x, point.y);
        return BaiduMapMercatorProjection.convertMC2LL(mercator);
    }
    pointToPixel(point, zoom, mapCenter, mapSize, curCity) {
        if (!point) {
            return;
        }
        point = this.lngLatToMercator(point, curCity);
        mapCenter = this.lngLatToMercator(mapCenter);
        const zoomUnits = this.getZoomUnits(zoom);
        const x = Math.round((point.lng - mapCenter.lng) / zoomUnits + mapSize.width / 2);
        const y = Math.round((mapCenter.lat - point.lat) / zoomUnits + mapSize.height / 2);
        return new Pixel(x, y);
    }
    pixelToPoint(pixel, zoom, mapCenter, mapSize, curCity) {
        if (!pixel) {
            return;
        }
        const zoomUnits = this.getZoomUnits(zoom);
        const lng = mapCenter.lng + zoomUnits * (pixel.x - mapSize.width / 2);
        const lat = mapCenter.lat - zoomUnits * (pixel.y - mapSize.height / 2);
        const point = new Point(lng, lat);
        return this.mercatorToLngLat(point, curCity);
    }
    getZoomUnits(zoom) {
        return Math.pow(2, 18 - zoom);
    }
}
BaiduMapMercatorProjection.EARTHRADIUS = 6370996.81;
BaiduMapMercatorProjection.MCBAND = [12890594.86, 8362377.87, 5591021, 3481989.83, 1678043.12, 0];
BaiduMapMercatorProjection.LLBAND = [75, 60, 45, 30, 15, 0];
BaiduMapMercatorProjection.MC2LL = [
    [
        1.410526172116255e-8,
        8.98305509648872e-6,
        -1.9939833816331,
        2.009824383106796e2,
        -1.872403703815547e2,
        91.6087516669843,
        -23.38765649603339,
        2.57121317296198,
        -0.03801003308653,
        1.73379812e7
    ],
    [
        -7.435856389565537e-9,
        8.983055097726239e-6,
        -0.78625201886289,
        96.32687599759846,
        -1.85204757529826,
        -59.36935905485877,
        47.40033549296737,
        -16.50741931063887,
        2.28786674699375,
        1.026014486e7
    ],
    [
        -3.030883460898826e-8,
        8.98305509983578e-6,
        0.30071316287616,
        59.74293618442277,
        7.357984074871,
        -25.38371002664745,
        13.45380521110908,
        -3.29883767235584,
        0.32710905363475,
        6.85681737e6
    ],
    [
        -1.981981304930552e-8,
        8.983055099779535e-6,
        0.03278182852591,
        40.31678527705744,
        0.65659298677277,
        -4.44255534477492,
        0.85341911805263,
        0.12923347998204,
        -0.04625736007561,
        4.48277706e6
    ],
    [
        3.09191371068437e-9,
        8.983055096812155e-6,
        0.00006995724062,
        23.10934304144901,
        -0.00023663490511,
        -0.6321817810242,
        -0.00663494467273,
        0.03430082397953,
        -0.00466043876332,
        2.5551644e6
    ],
    [
        2.890871144776878e-9,
        8.983055095805407e-6,
        -0.00000003068298,
        7.47137025468032,
        -0.00000353937994,
        -0.02145144861037,
        -0.00001234426596,
        0.00010322952773,
        -0.00000323890364,
        8.260885e5
    ]
];
BaiduMapMercatorProjection.LL2MC = [
    [
        -0.0015702102444,
        1.113207020616939e5,
        1.704480524535203e15,
        -1.033898737604234e16,
        2.611266785660388e16,
        -3.51496691766537e16,
        2.659570071840392e16,
        -1.072501245418824e16,
        1.800819912950474e15,
        82.5
    ],
    [
        8.277824516172526e-4,
        1.113207020463578e5,
        6.477955746671608e8,
        -4.082003173641316e9,
        1.077490566351142e10,
        -1.517187553151559e10,
        1.205306533862167e10,
        -5.124939663577472e9,
        9.133119359512032e8,
        67.5
    ],
    [
        0.00337398766765,
        1.113207020202162e5,
        4.481351045890365e6,
        -2.339375119931662e7,
        7.968221547186455e7,
        -1.159649932797253e8,
        9.723671115602145e7,
        -4.366194633752821e7,
        8.477230501135234e6,
        52.5
    ],
    [
        0.00220636496208,
        1.113207020209128e5,
        5.175186112841131e4,
        3.796837749470245e6,
        9.920137397791013e5,
        -1.22195221711287e6,
        1.340652697009075e6,
        -6.209436990984312e5,
        1.444169293806241e5,
        37.5
    ],
    [
        -3.441963504368392e-4,
        1.113207020576856e5,
        2.782353980772752e2,
        2.485758690035394e6,
        6.070750963243378e3,
        5.482118345352118e4,
        9.540606633304236e3,
        -2.71055326746645e3,
        1.405483844121726e3,
        22.5
    ],
    [
        -3.218135878613132e-4,
        1.113207020701615e5,
        0.00369383431289,
        8.237256402795718e5,
        0.46104986909093,
        2.351343141331292e3,
        1.58060784298199,
        8.77738589078284,
        0.37238884252424,
        7.45
    ]
];
BaiduMapMercatorProjection.getDistanceByMC = function (point1, point2) {
    if (!point1 || !point2)
        return 0;
    point1 = this.convertMC2LL(point1);
    if (!point1)
        return 0;
    const x1 = this.toRadians(point1.lng);
    const y1 = this.toRadians(point1.lat);
    point2 = this.convertMC2LL(point2);
    if (!point2)
        return 0;
    const x2 = this.toRadians(point2.lng);
    const y2 = this.toRadians(point2.lat);
    return this.getDistance(x1, x2, y1, y2);
};
BaiduMapMercatorProjection.getDistanceByLL = function (point1, point2) {
    if (!point1 || !point2)
        return 0;
    point1.lng = this.getLoop(point1.lng, -180, 180);
    point1.lat = this.getRange(point1.lat, -74, 74);
    point2.lng = this.getLoop(point2.lng, -180, 180);
    point2.lat = this.getRange(point2.lat, -74, 74);
    const x1 = this.toRadians(point1.lng);
    const y1 = this.toRadians(point1.lat);
    const x2 = this.toRadians(point2.lng);
    const y2 = this.toRadians(point2.lat);
    return this.getDistance(x1, x2, y1, y2);
};
BaiduMapMercatorProjection.convertMC2LL = function (point) {
    let factor;
    const temp = new Point(Math.abs(point.lng), Math.abs(point.lat));
    for (let i = 0; i < this.MCBAND.length; i++) {
        if (temp.lat >= this.MCBAND[i]) {
            factor = this.MC2LL[i];
            break;
        }
    }
    const lnglat = this.convertor(point, factor);
    return new Point(lnglat.lng.toFixed(6), lnglat.lat.toFixed(6));
};
BaiduMapMercatorProjection.convertLL2MC = function (point) {
    let factor;
    point.lng = this.getLoop(point.lng, -180, 180);
    point.lat = this.getRange(point.lat, -74, 74);
    const temp = new Point(point.lng, point.lat);
    for (let i = 0; i < this.LLBAND.length; i++) {
        if (temp.lat >= this.LLBAND[i]) {
            factor = this.LL2MC[i];
            break;
        }
    }
    if (!factor) {
        for (let i = this.LLBAND.length - 1; i >= 0; i--) {
            if (temp.lat <= -this.LLBAND[i]) {
                factor = this.LL2MC[i];
                break;
            }
        }
    }
    const mc = this.convertor(point, factor);
    return new Point(mc.lng.toFixed(2), mc.lat.toFixed(2));
};
BaiduMapMercatorProjection.convertor = function (fromPoint, factor) {
    if (!fromPoint || !factor) {
        return;
    }
    let x = factor[0] + factor[1] * Math.abs(fromPoint.lng);
    const temp = Math.abs(fromPoint.lat) / factor[9];
    let y = factor[2] +
        factor[3] * temp +
        factor[4] * temp * temp +
        factor[5] * temp * temp * temp +
        factor[6] * temp * temp * temp * temp +
        factor[7] * temp * temp * temp * temp * temp +
        factor[8] * temp * temp * temp * temp * temp * temp;
    x *= fromPoint.lng < 0 ? -1 : 1;
    y *= fromPoint.lat < 0 ? -1 : 1;
    return new Point(x, y);
};
BaiduMapMercatorProjection.getDistance = function (x1, x2, y1, y2) {
    return this.EARTHRADIUS * Math.acos(Math.sin(y1) * Math.sin(y2) + Math.cos(y1) * Math.cos(y2) * Math.cos(x2 - x1));
};
BaiduMapMercatorProjection.toRadians = function (angdeg) {
    return (Math.PI * angdeg) / 180;
};
BaiduMapMercatorProjection.toDegrees = function (angrad) {
    return (180 * angrad) / Math.PI;
};
BaiduMapMercatorProjection.getRange = function (v, a, b) {
    if (a != null) {
        v = Math.max(v, a);
    }
    if (b != null) {
        v = Math.min(v, b);
    }
    return v;
};
BaiduMapMercatorProjection.getLoop = function (v, a, b) {
    while (v > b) {
        v -= b - a;
    }
    while (v < a) {
        v += b - a;
    }
    return v;
};

class BaiduMapMercatorTilingScheme {
    constructor(options) {
        const { defaultValue, Ellipsoid, WebMercatorProjection, Cartesian2, Cartographic, Math: CesiumMath, Rectangle } = Cesium;
        options = options || {};
        this._ellipsoid = defaultValue(options.ellipsoid, Ellipsoid.WGS84);
        this._projection = new WebMercatorProjection(this._ellipsoid);
        const projection = new BaiduMapMercatorProjection();
        this._projection.project = function (cartographic, result) {
            result = result || {};
            if (options.toWGS84) {
                result = coordtransform.wgs84togcj02(CesiumMath.toDegrees(cartographic.longitude), CesiumMath.toDegrees(cartographic.latitude));
                result = coordtransform.gcj02tobd09(result[0], result[1]);
            }
            else {
                result = coordtransform.gcj02tobd09(CesiumMath.toDegrees(cartographic.longitude), CesiumMath.toDegrees(cartographic.latitude));
            }
            result[0] = Math.min(result[0], 180);
            result[0] = Math.max(result[0], -180);
            result[1] = Math.min(result[1], 74.000022);
            result[1] = Math.max(result[1], -71.988531);
            result = projection.lngLatToPoint(new Point(result[0], result[1]));
            return new Cartesian2(result.x, result.y);
        };
        this._projection.unproject = function (cartographic, result) {
            result = result || {};
            result = projection.mercatorToLngLat(new Point(cartographic.x, cartographic.y));
            result[0] = ((result[0] + 180) % 360) - 180;
            if (options.toWGS84) {
                result = coordtransform.bd09togcj02(result.lng, result.lat);
                result = coordtransform.gcj02towgs84(result[0], result[1]);
            }
            else {
                result = coordtransform.bd09togcj02(result.lng, result.lat);
            }
            return new Cartographic(Cesium.Math.toRadians(result[0]), Cesium.Math.toRadians(result[1]));
        };
        this._rectangleSouthwestInMeters = new Cartesian2(-20037726.37, -12474104.17);
        this._rectangleNortheastInMeters = new Cartesian2(20037726.37, 12474104.17);
        const rectangleSouthwestInMeters = this._projection.unproject(this._rectangleSouthwestInMeters);
        const rectangleNortheastInMeters = this._projection.unproject(this._rectangleNortheastInMeters);
        this._rectangle = new Rectangle(rectangleSouthwestInMeters.longitude, rectangleSouthwestInMeters.latitude, rectangleNortheastInMeters.longitude, rectangleNortheastInMeters.latitude);
        this.resolutions = [];
        for (let i = 0; i < 19; i++) {
            this.resolutions[i] = 256 * Math.pow(2, 18 - i);
        }
    }
    getNumberOfXTilesAtLevel(level) {
        return 1 << level;
    }
    getNumberOfYTilesAtLevel(level) {
        return 1 << level;
    }
    rectangleToNativeRectangle(rectangle, result) {
        const { defined, Rectangle } = Cesium;
        const projection = this._projection;
        const southwest = projection.project(Rectangle.southwest(rectangle));
        const northeast = projection.project(Rectangle.northeast(rectangle));
        if (!defined(result)) {
            return new Rectangle(southwest.x, southwest.y, northeast.x, northeast.y);
        }
        result.west = southwest.x;
        result.south = southwest.y;
        result.east = northeast.x;
        result.north = northeast.y;
        return result;
    }
    tileXYToNativeRectangle(x, y, level, result) {
        const { defined, Rectangle } = Cesium;
        const tileWidth = this.resolutions[level];
        const west = x * tileWidth;
        const east = (x + 1) * tileWidth;
        const north = ((y = -y) + 1) * tileWidth;
        const south = y * tileWidth;
        if (!defined(result)) {
            return new Rectangle(west, south, east, north);
        }
        result.west = west;
        result.south = south;
        result.east = east;
        result.north = north;
        return result;
    }
    tileXYToRectangle(x, y, level, result) {
        const { Cartesian2 } = Cesium;
        const nativeRectangle = this.tileXYToNativeRectangle(x, y, level, result);
        const projection = this._projection;
        const southwest = projection.unproject(new Cartesian2(nativeRectangle.west, nativeRectangle.south));
        const northeast = projection.unproject(new Cartesian2(nativeRectangle.east, nativeRectangle.north));
        nativeRectangle.west = southwest.longitude;
        nativeRectangle.south = southwest.latitude;
        nativeRectangle.east = northeast.longitude;
        nativeRectangle.north = northeast.latitude;
        return nativeRectangle;
    }
    positionToTileXY(position, level, result) {
        const { Rectangle, defined, Cartesian2 } = Cesium;
        const rectangle = this._rectangle;
        if (!Rectangle.contains(rectangle, position)) {
            return undefined;
        }
        const projection = this._projection;
        const webMercatorPosition = projection.project(position);
        if (!defined(webMercatorPosition)) {
            return undefined;
        }
        const tileWidth = this.resolutions[level];
        const xTileCoordinate = Math.floor(webMercatorPosition.x / tileWidth);
        const yTileCoordinate = -Math.floor(webMercatorPosition.y / tileWidth);
        if (!defined(result)) {
            return new Cartesian2(xTileCoordinate, yTileCoordinate);
        }
        result.x = xTileCoordinate;
        result.y = yTileCoordinate;
        return result;
    }
    get ellipsoid() {
        return this._ellipsoid;
    }
    get rectangle() {
        return this._rectangle;
    }
    get projection() {
        return this._projection;
    }
}

class BaiduMapImageryProvider {
    constructor(options) {
        const { Resource, defaultValue, Credit, when, Event } = Cesium;
        this._url = options.url || `${options.protocol}://{s}.map.bdimg.com/onlinelabel/?qt=tile&styles=pl&x={x}&y={y}&z={z}`;
        const resource = Resource.createIfNeeded(this._url);
        resource.appendForwardSlash();
        this._ready = false;
        this._resource = resource;
        this._tileDiscardPolicy = options.tileDiscardPolicy;
        this._tileWidth = 256;
        this._tileHeight = 256;
        this._minimumLevel = options.maximumLevel || 0;
        this._maximumLevel = options.maximumLevel || 18;
        this._tilingScheme = new BaiduMapMercatorTilingScheme(options);
        this._rectangle = defaultValue(options.rectangle, this._tilingScheme.rectangle);
        let credit = options.credit;
        if (typeof credit === 'string') {
            credit = new Credit(credit);
        }
        this._credit = credit;
        this.enablePickFeatures = defaultValue(options.enablePickFeatures, false);
        this._hasAlphaChannel = defaultValue(options.hasAlphaChannel, true);
        this._subdomains = defaultValue(options.subdomains, ['online0', 'online1', 'online2', 'online3', 'online4', 'online5', 'online6', 'online7', 'online8', 'online9']);
        this._errorEvent = new Event();
        this._readyPromise = when.defer();
        this._ready = true;
        this._readyPromise.resolve(true);
    }
    get url() {
        return this._resource._url;
    }
    get proxy() {
        return this._resource.proxy;
    }
    get tileWidth() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tileWidth must not be called before the imagery provider is ready.');
        }
        return this._tileWidth;
    }
    get tileHeight() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tileHeight must not be called before the imagery provider is ready.');
        }
        return this._tileHeight;
    }
    get maximumLevel() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('maximumLevel must not be called before the imagery provider is ready.');
        }
        return this._maximumLevel;
    }
    get minimumLevel() {
        if (!this.ready) {
            throw new Cesium.DeveloperError('minimumLevel must not be called before the imagery provider is ready.');
        }
        return this._minimumLevel;
    }
    get tilingScheme() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tilingScheme must not be called before the imagery provider is ready.');
        }
        return this._tilingScheme;
    }
    get rectangle() {
        if (!this.ready) {
            throw new Cesium.DeveloperError('rectangle must not be called before the imagery provider is ready.');
        }
        return this._rectangle;
    }
    get tileDiscardPolicy() {
        if (!this.ready) {
            throw new Cesium.DeveloperError('tileDiscardPolicy must not be called before the imagery provider is ready.');
        }
        return this._tileDiscardPolicy;
    }
    get errorEvent() {
        return this._errorEvent;
    }
    get ready() {
        return this._ready;
    }
    get readyPromise() {
        return this._readyPromise.promise;
    }
    get credit() {
        if (!this.ready) {
            throw new Cesium.DeveloperError('credit must not be called before the imagery provider is ready.');
        }
        return this._credit;
    }
    get hasAlphaChannel() {
        if (!this.ready) {
            throw new Cesium.DeveloperError('hasAlphaChannel must not be called before the imagery provider is ready.');
        }
        return this._hasAlphaChannel;
    }
    getTileCredits(x, y, level) {
        if (!this.ready) {
            throw new Cesium.DeveloperError('getTileCredits must not be called before the imagery provider is ready.');
        }
        return undefined;
    }
    requestImage(x, y, level, request) {
        if (!this.ready) {
            throw new Cesium.DeveloperError('requestImage must not be called before the imagery provider is ready.');
        }
        return Cesium.ImageryProvider.loadImage(this, buildImageResource.call(this, x, y, level, request));
    }
}
function buildImageResource(x, y, level, request) {
    let url = this._url;
    const subdomains = this._subdomains;
    url = url.replace('{s}', subdomains[(x + y + level) % subdomains.length]).replace('{x}', x).replace('{y}', -y).replace('{z}', level);
    const resource = this._resource.getDerivedResource({
        url: url,
        request: request
    });
    return resource;
}

var VcProviderImageryBaidumap = vue.defineComponent({
    name: 'VcProviderImageryBaidumap',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.rectangle), cesiumProps.ellipsoid), cesiumProps.tileDiscardPolicy), cesiumProps.credit), cesiumProps.minimumLevel), cesiumProps.maximumLevel), { protocol: {
            type: String,
            default: 'http'
        }, projectionTransforms: {
            type: [Boolean, Object],
            default: () => {
                return {
                    from: 'BD09',
                    to: 'WGS84'
                };
            }
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'BaiduMapImageryProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            Cesium.BaiduMapImageryProvider = Cesium.BaiduMapImageryProvider || BaiduMapImageryProvider;
            if (providersState.unwatchFns.length === 0) {
                providersState.setPropsWatcher(true);
            }
            const options = providersState.transformProps(props);
            return new Cesium.BaiduMapImageryProvider(options);
        });
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryBingmaps = vue.defineComponent({
    name: 'VcProviderImageryBingmaps',
    props: Object.assign(Object.assign({ url: {
            type: String,
            default: 'https://dev.virtualearth.net'
        }, bmKey: String, tileProtocol: String, mapStyle: {
            type: String,
            default: 'Aerial'
        }, culture: {
            type: String,
            default: ''
        } }, cesiumProps.ellipsoid), cesiumProps.tileDiscardPolicy),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'BingMapsImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryGoogle = vue.defineComponent({
    name: 'VcProviderImageryGoogle',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.ellipsoid), cesiumProps.tileDiscardPolicy), cesiumProps.credit), { metadata: Object }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'GoogleEarthEnterpriseImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryGrid = vue.defineComponent({
    name: 'VcProviderImageryGrid',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.tilingScheme), cesiumProps.ellipsoid), { cells: {
            type: Number,
            default: 8
        }, color: {
            type: [String, Object, Array],
            default: () => [1.0, 1.0, 1.0, 0.4],
            watcherOptions: {
                cesiumObjectBuilder: cesiumHelpers.makeColor
            }
        } }), cesiumProps.glowColor), { glowWidth: {
            type: Number,
            default: 6
        }, backgroundColor: {
            type: [String, Array, Object],
            default: () => [0.0, 0.5, 0.0, 0.2],
            watcherOptions: {
                cesiumObjectBuilder: cesiumHelpers.makeColor
            }
        } }), cesiumProps.tileWidth), cesiumProps.tileHeight), { canvasSize: {
            type: Number,
            default: 256
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'GridImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryIon = vue.defineComponent({
    name: 'VcProviderImageryIon',
    props: Object.assign(Object.assign({ assetId: Number }, cesiumProps.accessToken), { server: [String, Object] }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'IonImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryMapbox = vue.defineComponent({
    name: 'VcProviderImageryMapbox',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ url: {
            type: String,
            default: 'https://api.mapbox.com/styles/v1/'
        }, username: {
            type: String,
            default: 'mapbox'
        }, styleId: String }, cesiumProps.accessToken), { tilesize: {
            type: Number,
            default: 512
        }, scaleFactor: Boolean }), cesiumProps.ellipsoid), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.rectangle), cesiumProps.credit),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'MapboxStyleImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryOsm = vue.defineComponent({
    name: 'VcProviderImageryOsm',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ url: {
            type: String,
            default: 'https://a.tile.openstreetmap.org'
        } }, cesiumProps.fileExtension), cesiumProps.rectangle), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.ellipsoid), { credit: {
            type: [String, Object],
            default: 'MapQuest, Open Street Map and contributors, CC-BY-SA'
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'OpenStreetMapImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImagerySingletile = vue.defineComponent({
    name: 'VcProviderImagerySingletile',
    props: Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.rectangle), cesiumProps.credit), cesiumProps.ellipsoid),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'SingleTileImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

const Status = {
    NONE: 0,
    STORING: 1,
    STORED: 2,
    FAILED: 3
};
class IndexedDBScheduler {
    constructor(options) {
        if (!Cesium.defined(options.name)) {
            throw new Cesium.DeveloperError('options.name is required.');
        }
        const deferred = Cesium.when.defer();
        this.dbname = options.name;
        const dbRequest = window.indexedDB.open(this.dbname);
        const that = this;
        dbRequest.onsuccess = event => {
            that.db = event.target.result;
            that.version = that.db.version;
            that.cachestatus = that.cachestatus || {};
            deferred.resolve(that);
        };
        dbRequest.onupgradeneeded = event => {
            that.db = event.target.result;
            that.version = that.db.version;
            deferred.resolve(that);
        };
        dbRequest.onerror = event => {
            that.db = null;
            deferred.reject('create database fail, error code : ' + event.target.errorcode);
        };
        this.layer = options.layer || null;
        this.storageType = options.storageType || 'arrayBuffer';
        this.creatingTable = !1;
        this.cachestatus = {};
        return deferred.promise;
    }
    checkObjectStoreExist(storeName) {
        return Cesium.defined(this.db) ? this.db.objectStoreNames.contains(storeName) : false;
    }
    createObjectStore(storeName) {
        const deferred = Cesium.when.defer();
        if (this.creatingTable) {
            deferred.reject(false);
        }
        else {
            if (this.db.objectStoreNames.contains(storeName)) {
                deferred.reject(false);
                return deferred.promise;
            }
            this.creatingTable = true;
            const version = parseInt(this.db.version);
            this.db.close();
            const that = this;
            const dbRequest = window.indexedDB.open(this.dbname, version + 1);
            dbRequest.onupgradeneeded = event => {
                const db = event.target.result;
                that.db = db;
                const objectStore = db.createObjectStore(storeName, {
                    keyPath: 'id'
                });
                if (Cesium.defined(objectStore)) {
                    objectStore.createIndex('value', 'value', {
                        unique: false
                    });
                    that.creatingTable = false;
                    that.cachestatus = that.cachestatus || {};
                    that.cachestatus[storeName] = {};
                    that.db.close();
                    const dbRequest = window.indexedDB.open(that.dbname);
                    dbRequest.onsuccess = event => {
                        that.db = event.target.result;
                        deferred.resolve(true);
                    };
                }
                else {
                    that.creatingTable = false;
                    deferred.resolve(false);
                }
            };
            dbRequest.onsuccess = event => {
                event.target.result.close();
                deferred.resolve(true);
            };
            dbRequest.onerror = event => {
                that.creatingTable = false;
                deferred.reject(false);
            };
        }
        return deferred.promise;
    }
    putElementInDB(storeName, id, value) {
        const deferred = Cesium.when.defer();
        if (!Cesium.defined(this.db)) {
            deferred.reject(false);
            return deferred.promise;
        }
        const { cachestatus, db } = this;
        if (Cesium.defined(cachestatus[storeName]) && Cesium.defined(cachestatus[storeName][id] &&
            (cachestatus[storeName][id] === Status.STORING || cachestatus[storeName][id] === Status.STORED))) {
            deferred.resolve(false);
            return deferred.promise;
        }
        if (db.objectStoreNames.contains(storeName)) {
            cachestatus[storeName] = cachestatus[storeName] || {};
            try {
                const request = db.transaction([storeName], 'readwrite').objectStore(storeName).add({
                    id: id,
                    value: value
                });
                cachestatus[storeName][id] = Status.STORING;
                request.onsuccess = event => {
                    cachestatus[storeName][id] = Status.STORED;
                    deferred.resolve(true);
                };
                request.onerror = event => {
                    cachestatus[storeName][id] = Status.FAILED;
                    deferred.resolve(false);
                };
            }
            catch (error) {
                deferred.reject(null);
                return deferred.promise;
            }
        }
        else {
            this.createObjectStore(storeName).then(() => {
                const request = db.transaction([storeName], 'readwrite').objectStore(storeName).add({
                    id: id,
                    value: value
                });
                request.onsuccess = function (e) {
                    deferred.resolve(true);
                };
                request.onerror = function (e) {
                    deferred.reject(false);
                };
            }, () => {
                deferred.reject(false);
            });
        }
        return deferred.promise;
    }
    getElementFromDB(storeName, id) {
        const deferred = Cesium.when.defer();
        const { db } = this;
        if (!Cesium.defined(db)) {
            return null;
        }
        if (!db.objectStoreNames.contains(storeName)) {
            return null;
        }
        try {
            const transaction = db.transaction([storeName]);
            const objectStore = transaction.objectStore(storeName);
            const request = objectStore.get(id);
            request.onsuccess = e => {
                return Cesium.defined(e.target.result) ? deferred.resolve(e.target.result.value) : deferred.reject(null);
            };
            request.onerror = e => {
                deferred.reject(null);
            };
        }
        catch (error) {
            deferred.reject(null);
        }
        return deferred.promise;
    }
    updateElementInDB(storeName, id, value) {
        const deferred = Cesium.when.defer();
        const { db } = this;
        if (!Cesium.defined(db)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        if (!db.objectStoreNames.contains(storeName)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        try {
            const request = db.transaction([storeName], 'readwrite')
                .objectStore(storeName)
                .put({ id: id, value: value });
            request.onsuccess = () => {
                deferred.resolve(true);
            };
            request.onerror = () => {
                deferred.resolve(false);
            };
        }
        catch (e) {
            deferred.resolve(false);
        }
        return deferred.promise;
    }
    removeElementFromDB(storeName, id) {
        const deferred = Cesium.when.defer();
        const { db } = this;
        if (!Cesium.defined(db)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        if (!db.objectStoreNames.contains(storeName)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        try {
            const request = db.transaction([storeName], 'readwrite')
                .objectStore(storeName)
                .delete(id);
            request.onsuccess = () => {
                deferred.resolve(true);
            };
            request.onerror = () => {
                deferred.resolve(false);
            };
        }
        catch (e) {
            deferred.resolve(false);
        }
        return deferred.promise;
    }
    clear(storeName) {
        const deferred = Cesium.when.defer();
        const { db } = this;
        if (!Cesium.defined(db)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        if (!db.objectStoreNames.contains(storeName)) {
            deferred.resolve(false);
            return deferred.promise;
        }
        try {
            const request = db.transaction([storeName], 'readwrite')
                .objectStore(storeName)
                .clear();
            request.onsuccess = () => {
                deferred.resolve(true);
            };
            request.onerror = () => {
                deferred.resolve(false);
            };
        }
        catch (e) {
            deferred.resolve(false);
        }
        return deferred.promise;
    }
}

class SuperMapImageryProvider {
    constructor(options) {
        const { appendForwardSlash, Credit, defaultValue, defined, DeveloperError, Event, Resource, when, Math } = Cesium;
        options = defaultValue(options, {});
        const { url } = options;
        if (!defined(url)) {
            throw new DeveloperError('options.url is required.');
        }
        const rootNodeUrlRealspace3D = url.substring(0, url.indexOf('datas'));
        this.tablename = url.substring(0, url.indexOf('datas/') + 6, url.length);
        const that = this;
        const dbPromise = new IndexedDBScheduler({
            name: rootNodeUrlRealspace3D + this.tablename
        });
        dbPromise.then(e => {
            that._indexedDBScheduler = e;
        });
        this._indexedDBSetting = {
            isOpen: false,
            clear: () => {
                that._indexedDBScheduler.clear(that.tablename);
            }
        };
        this.isSci = false;
        this.isTileMap = false;
        const forwardSlashUrl = appendForwardSlash(url);
        if (forwardSlashUrl.indexOf('rest/maps') > -1) {
            this.isTileMap = true;
            this.layersID = options.layersID;
        }
        else {
            if (!(forwardSlashUrl.indexOf('rest/realspace') > -1)) {
                throw new DeveloperError('The url type is not supported!');
            }
            this.isSci = true;
        }
        this._url = forwardSlashUrl;
        this._resource = Resource.createIfNeeded(forwardSlashUrl);
        this._transparent = defaultValue(options.transparent, true);
        this._name = options.name || '';
        this._urlTemplate = undefined;
        this._errorEvent = new Event();
        this._fileExtension = 'png';
        this._tileWidth = 256;
        this._tileHeight = 256;
        this._minimumLevel = defaultValue(options.minimumLevel, 0);
        this._maximumLevel = options.maximumLevel;
        this._rectangle = undefined;
        this._tilingScheme = undefined;
        this._tileDiscardPolicy = options.tileDiscardPolicy;
        this._fRatio = defaultValue(options.ratio, Math.DEGREES_PER_RADIAN / 6378137.0);
        this._scales = [];
        this._coordUnit = 'DEGREE';
        let credit = defaultValue(options.credit, new Credit('MapQuest, SuperMap iServer Imagery'));
        if (typeof credit === 'string') {
            credit = new Credit(credit);
        }
        this._credit = credit;
        this._ready = false;
        this._readyPromise = when.defer();
        this._options = options;
        init.call(this);
    }
    get url() {
        return this._url;
    }
    get name() {
        return this._name;
    }
    set name(val) {
        this._name = val;
    }
    get tileWidth() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tileWidth must not be called before the imagery provider is ready.');
        }
        return this._tileWidth;
    }
    get tileHeight() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tileHeight must not be called before the imagery provider is ready.');
        }
        return this._tileHeight;
    }
    get maximumLevel() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('maximumLevel must not be called before the imagery provider is ready.');
        }
        return this._maximumLevel;
    }
    get minimumLevel() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('minimumLevel must not be called before the imagery provider is ready.');
        }
        return this._minimumLevel;
    }
    get tilingScheme() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('tilingScheme must not be called before the imagery provider is ready.');
        }
        return this._tilingScheme;
    }
    get rectangle() {
        if (!this._ready) {
            throw new Cesium.DeveloperError('rectangle must not be called before the imagery provider is ready.');
        }
        return this._rectangle;
    }
    get errorEvent() {
        return this._errorEvent;
    }
    get ready() {
        return this._ready;
    }
    get credit() {
        return this._credit;
    }
    get hasAlphaChannel() {
        return true;
    }
    get readyPromise() {
        return this._readyPromise;
    }
    get ratio() {
        return this._fRatio;
    }
    set ratio(val) {
        this._fRatio = val;
    }
    get tileDiscardPolicy() {
        return this._tileDiscardPolicy;
    }
    getTileCredits(x, y, level) {
        if (!this.ready) {
            throw new Cesium.DeveloperError('getTileCredits must not be called before the imagery provider is ready.');
        }
        return undefined;
    }
    requestImage(x, y, level, request) {
        const { defined, DeveloperError, ImageryProvider, when } = Cesium;
        if (!this.ready) {
            throw new DeveloperError('requestImage must not be called before the imagery provider is ready.');
        }
        const url = buildImageResource$1.call(this, x, y, level);
        const resource = this._resource.getDerivedResource({
            url: url,
            request: request
        });
        const that = this;
        if (this._indexedDBSetting.isOpen) {
            if (defined(this._indexedDBScheduler)) {
                const promise = this._indexedDBScheduler.getElementFromDB(this.tablename, url);
                return defined(promise)
                    ? when(promise, value => {
                        if (defined(value)) {
                            const image = new Image();
                            image.src = value;
                            return image;
                        }
                        return ImageryProvider.loadImage(that, resource);
                    }, e => {
                        return ImageryProvider.loadImage(that, resource);
                    })
                    : ImageryProvider.loadImage(that, resource);
            }
        }
        return ImageryProvider.loadImage(this, resource);
    }
    pickFeatures() {
    }
}
let previousError = {};
const ScaleTexts = [
    '1.690163571602655E-9',
    '3.3803271432053056E-9',
    '6.760654286410611E-9',
    '1.3521308572821242E-8',
    '2.7042617145642484E-8',
    '5.408523429128511E-8',
    '1.0817046858256998E-7',
    '2.1634093716513974E-7',
    '4.3268187433028044E-7',
    '8.653637486605571E-7',
    '1.7307274973211203E-6',
    '3.4614549946422405E-6',
    '6.9229099892844565E-6',
    '1.3845819978568952E-5',
    '2.7691639957137904E-5',
    '5.53832799142758E-5',
    '1.107665598285516E-4',
    '2.215331196571032E-4',
    '4.430662393142064E-4',
    '8.861324786284128E-4',
    '1.772264957256826E-3',
    '3.544529914513652E-3'
];
const Scales = [
    1.690163571602655e-9,
    3.3803271432053056e-9,
    6.760654286410611e-9,
    1.3521308572821242e-8,
    2.7042617145642484e-8,
    5.408523429128511e-8,
    1.0817046858256998e-7,
    2.1634093716513974e-7,
    4.3268187433028044e-7,
    8.653637486605571e-7,
    0.0000017307274973211203,
    0.0000034614549946422405,
    0.0000069229099892844565,
    0.000013845819978568952,
    0.000027691639957137904,
    0.0000553832799142758,
    0.0001107665598285516,
    0.0002215331196571032,
    0.0004430662393142064,
    0.0008861324786284128,
    0.001772264957256826,
    0.003544529914513652
];
function buildImageResource$1(x, y, level) {
    let url;
    if (this.isTileMap) {
        if (this._coordUnit === 'DEGREE') {
            const scaleText = ScaleTexts[level + 1] || ScaleTexts[level];
            url = this._urlTemplate
                .replace('{x}', x)
                .replace('{y}', y)
                .replace('{scale}', scaleText);
        }
        else if (this._coordUnit === 'METER') {
            const scaleText = ScaleTexts[level];
            url = this._urlTemplate
                .replace('{x}', x)
                .replace('{y}', y)
                .replace('{scale}', scaleText);
        }
    }
    else {
        url = this._urlTemplate
            .replace('{x}', x)
            .replace('{y}', y)
            .replace('{level}', level)
            .replace('{fileExtension}', this._fileExtension);
    }
    return url;
}
function init() {
    const { Resource, when } = Cesium;
    if (this.isTileMap) {
        const promise = Resource.fetchJsonp({
            url: this._options.url + '.jsonp',
            queryParameters: {
                f: 'json'
            }
        });
        when(promise, onFulfilledTileMap.bind(this), onRejected.bind(this));
    }
    else {
        when(Resource.fetchText({
            url: this.url + 'config'
        }), onFulfilledRest3D.bind(this), onRejected.bind(this));
    }
}
function getMaximumLevelbyScale(scale) {
    for (let t = Scales.length; t--;) {
        if (scale[t] <= scale) {
            return t;
        }
    }
}
function onFulfilledRest3D(xmlText) {
    const options = parseConfigFromXmlText.call(this, xmlText);
    const { defaultValue, defined, GeographicTilingScheme, Math, Rectangle } = Cesium;
    this._fileExtension = defaultValue(options.fileExtentName, 'png');
    this._tileWidth = defaultValue(options.imageSizeWidth, 256);
    this._tileHeight = defaultValue(options.imageSizeHeight, 256);
    const levels = options.levels;
    const length = levels.length;
    this._minimumLevel = defaultValue(levels[0], 0);
    this._maximumLevel = defaultValue(levels[length - 1], length - 1);
    if (!defined(this._tilingScheme)) {
        this._tilingScheme = new GeographicTilingScheme({
            ellipsoid: this._options.ellipsoid
        });
    }
    if (!defined(this._rectangle)) {
        if (options.left && options.right && options.top && options.bottom) {
            const left = Math.toRadians(options.left);
            const right = Math.toRadians(options.right);
            const bottom = Math.toRadians(options.bottom);
            const top = Math.toRadians(options.top);
            this._rectangle = new Rectangle(left, bottom, right, top);
        }
    }
    const tilingScheme = this._tilingScheme;
    this._rectangle.west < tilingScheme.rectangle.west && (this._rectangle.west = tilingScheme.rectangle.west);
    this._rectangle.east > tilingScheme.rectangle.east && (this._rectangle.east = tilingScheme.rectangle.east);
    this._rectangle.south < tilingScheme.rectangle.south && (this._rectangle.south = tilingScheme.rectangle.south);
    this._rectangle.north > tilingScheme.rectangle.north && (this._rectangle.north = tilingScheme.rectangle.north);
    const swTile = tilingScheme.positionToTileXY(Rectangle.southwest(this._rectangle), this._minimumLevel);
    const neTile = tilingScheme.positionToTileXY(Rectangle.northeast(this._rectangle), this._minimumLevel);
    const tileCount = (window.Math.abs(neTile.x - swTile.x) + 1) * (window.Math.abs(neTile.y - swTile.y) + 1);
    tileCount > 4 && (this._minimumLevel = 0);
    this._tilingScheme = tilingScheme;
    this._urlTemplate = this._url + 'data/index/{y}/{x}.{fileExtension}?level={level}';
    this._ready = true;
    this._readyPromise.resolve(true);
}
function parseConfigFromXmlText(xmlText) {
    const domParser = new DOMParser();
    xmlText = domParser.parseFromString(xmlText, 'application/xml');
    const namespaceURI = 'http://www.supermap.com/SuperMapCache/sci3d';
    const rootNode = xmlText.childNodes[0];
    const levelsNode = queryFirstNode(rootNode, 'Levels', namespaceURI);
    const levelsNodes = queryNodes(levelsNode, 'Level', namespaceURI);
    const levels = [];
    for (let i = 0; i < levelsNodes.length; i++) {
        levels.push(parseInt(levelsNodes[i].textContent, 10));
    }
    const boundsNode = queryFirstNode(rootNode, 'Bounds', namespaceURI);
    const left = queryNumericAttribute(boundsNode, 'Left', namespaceURI);
    const right = queryNumericAttribute(boundsNode, 'Right', namespaceURI);
    const top = queryNumericAttribute(boundsNode, 'Top', namespaceURI);
    const bottom = queryNumericAttribute(boundsNode, 'Bottom', namespaceURI);
    const fileExtentName = queryStringValue(rootNode, 'FileExtentName', namespaceURI);
    const cellWidth = queryNumericAttribute(rootNode, 'CellWidth', namespaceURI);
    const cellHeight = queryNumericAttribute(rootNode, 'CellHeight', namespaceURI);
    const cacheName = queryStringValue(rootNode, 'CacheName', namespaceURI);
    this._name = cacheName || '';
    return {
        left: left,
        right: right,
        top: top,
        bottom: bottom,
        fileExtentName: fileExtentName,
        levels: levels,
        imageSizeWidth: cellWidth,
        imageSizeHeight: cellHeight
    };
}
function queryStringValue(xmlNode, attribute, namespaceURI) {
    const node = queryFirstNode(xmlNode, attribute, namespaceURI);
    return Cesium.defined(node) ? node.textContent.trim() : undefined;
}
function queryNumericAttribute(xmlNode, attribute, namespaceURI) {
    const node = queryFirstNode(xmlNode, attribute, namespaceURI);
    if (Cesium.defined(node)) {
        const number = parseFloat(node.textContent);
        return isNaN(number) ? undefined : number;
    }
}
function queryFirstNode(xmlNode, attribute, namespaceURI) {
    if (Cesium.defined(xmlNode)) {
        const nodes = xmlNode.childNodes;
        const length = nodes.length;
        for (let i = 0; i < length; i++) {
            const node = nodes[i];
            if (node.localName === attribute && namespaceURI.indexOf(node.namespaceURI) !== -1) {
                return node;
            }
        }
    }
}
function queryNodes(xmlNode, attribute, namespaceURI) {
    if (Cesium.defined(xmlNode)) {
        const nodes = [];
        const nodeList = xmlNode.getElementsByTagNameNS('*', attribute);
        const length = nodeList.length;
        for (let i = 0; i < length; i++) {
            const node = nodeList[i];
            node.localName === attribute && namespaceURI.indexOf(node.namespaceURI) !== -1 && nodes.push(node);
        }
        return nodes;
    }
}
function onFulfilledTileMap(response) {
    const { Cartesian3, defaultValue, defined, GeographicTilingScheme, Math: CesiumMath, Rectangle, WebMercatorTilingScheme } = Cesium;
    const coordUnit = response.prjCoordSys.coordUnit;
    this._coordUnit = coordUnit;
    const bounds = response.bounds;
    const visibleScales = response.visibleScales;
    if (defined(visibleScales) && visibleScales.length > 1 && defined(this._maximumLevel)) {
        const lastVisibleScale = visibleScales[visibleScales.length - 1];
        this._maximumLevel = getMaximumLevelbyScale(lastVisibleScale);
    }
    if (coordUnit === 'DEGREE') {
        this._tilingScheme = new GeographicTilingScheme();
        bounds.left = CesiumMath.clamp(bounds.left, -180, 180);
        bounds.bottom = CesiumMath.clamp(bounds.bottom, -90, 90);
        bounds.right = CesiumMath.clamp(bounds.right, -180, 180);
        bounds.top = CesiumMath.clamp(bounds.top, -90, 90);
        this._rectangle = Rectangle.fromDegrees(bounds.left, bounds.bottom, bounds.right, bounds.top);
        this._urlTemplate =
            this._url +
                'tileImage.png?transparent={transparent}&cacheEnabled=true&width=256&height=256&x={x}&y={y}&scale={scale}&redirect=false&overlapDisplayed=false&origin={"x":-180,"y":90}';
    }
    else {
        const pointLB = new Cartesian3(bounds.left, bounds.bottom, 0);
        pointLB.x = Math.max(-20037508.342789244, pointLB.x);
        pointLB.y = Math.max(-20037508.342789244, pointLB.y);
        const pointRT = new Cartesian3(bounds.right, bounds.top, 0);
        pointRT.x = Math.min(20037508.342789244, pointRT.x);
        pointRT.y = Math.min(20037508.342789244, pointRT.y);
        this._tilingScheme = new WebMercatorTilingScheme();
        const f = this._tilingScheme.projection.unproject(pointLB);
        const p = this._tilingScheme.projection.unproject(pointRT);
        this._rectangle = new Rectangle(f.longitude, f.latitude, p.longitude, p.latitude);
        this._urlTemplate =
            this._url +
                'tileImage.png?transparent={transparent}&cacheEnabled=true&width=256&height=256&x={x}&y={y}&scale={scale}&redirect=false&overlapDisplayed=false&origin={"x":-20037508.342789248 ,"y":20037508.342789095}';
    }
    this._urlTemplate = this._urlTemplate.replace('{transparent}', this._transparent);
    this.layersID && (this._urlTemplate = this._urlTemplate + '&layersID=' + this.layersID);
    this._rectangle || (this._rectangle = defaultValue(this._options.rectangle, this._tilingScheme.rectangle));
    this._ready = true;
    this._readyPromise.resolve(true);
}
function onRejected() {
    const { TileProviderError, RuntimeError } = Cesium;
    const message = 'An error occurred while accessing ' + this._url + '.';
    previousError = TileProviderError.handleError(previousError, this, this._errorEvent, message, undefined, undefined, undefined, init.bind(this));
    this._readyPromise.reject(new RuntimeError(message));
}

var VcProviderImagerySupermap = vue.defineComponent({
    name: 'VcProviderImagerySupermap',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.minimumLevel), cesiumProps.maximumLevel), { name: String, transparent: {
            type: Boolean,
            default: true
        }, credit: {
            type: String,
            default: 'MapQuest, SuperMap iServer Imagery'
        } }), cesiumProps.projectionTransforms),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'SuperMapImageryProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            Cesium.SuperMapImageryProvider = Cesium.SuperMapImageryProvider || SuperMapImageryProvider;
            if (providersState.unwatchFns.length === 0) {
                providersState.setPropsWatcher(true);
            }
            const options = providersState.transformProps(props);
            return new Cesium.SuperMapImageryProvider(options);
        });
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

const TiandituMapsStyle = {
    IMG_W: 'img_w',
    IMG_C: 'img_c',
    CIA_W: 'cia_w',
    CIA_C: 'cia_c',
    VEC_W: 'vec_w',
    VEC_C: 'vec_c',
    TER_W: 'ter_w',
    TER_C: 'ter_c',
    CVA_W: 'cva_w',
    CVA_C: 'cva_c',
    CTA_W: 'cta_w',
    CTA_C: 'cta_c',
    EIA_W: 'eia_w',
    EIA_C: 'eia_c',
    EVA_W: 'eva_w',
    EVA_C: 'eva_c',
    IBO_C: 'ibo_c',
    IBO_W: 'ibo_w'
};

const TiandituMapsStyleUrl = {};
const TiandituMapsStyleLayer = {};
const TiandituMapsStyleID = {};
const TiandituMapsStyleFormat = {};
const TiandituMapsStyleEPSG = {};
const TiandituMapsStyleLabels = {};
class TiandituImageryProvider {
    constructor(options) {
        Object.keys(TiandituMapsStyle).forEach(key => {
            TiandituMapsStyleUrl[TiandituMapsStyle[key]] = options.protocol + '://{s}.tianditu.gov.cn/' + TiandituMapsStyle[key] + '/wmts';
            TiandituMapsStyleLayer[TiandituMapsStyle[key]] = TiandituMapsStyle[key].slice(0, 3);
            TiandituMapsStyleID[TiandituMapsStyle[key]] = TiandituMapsStyle[key].slice(4);
            TiandituMapsStyleFormat[TiandituMapsStyle[key]] = 'tiles';
            if (TiandituMapsStyleID[TiandituMapsStyle[key]] === 'w') {
                TiandituMapsStyleEPSG[TiandituMapsStyle[key]] = '900913';
            }
            else {
                TiandituMapsStyleEPSG[TiandituMapsStyle[key]] = '4490';
            }
            switch (TiandituMapsStyle[key]) {
                case 'img_w':
                case 'img_c':
                case 'cia_w':
                case 'cia_c':
                case 'cta_w':
                case 'cta_c':
                    TiandituMapsStyleLabels[TiandituMapsStyle[key]] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18'];
                    break;
                case 'vec_w':
                case 'vec_c':
                case 'cva_w':
                case 'cva_c':
                    TiandituMapsStyleLabels[TiandituMapsStyle[key]] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19'];
                    break;
                case 'ter_w':
                case 'ter_c':
                    TiandituMapsStyleLabels[TiandituMapsStyle[key]] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14'];
                    break;
                case 'eia_w':
                case 'eia_c':
                case 'eva_w':
                case 'eva_c':
                case 'ibo_c':
                case 'ibo_w':
                    TiandituMapsStyleLabels[TiandituMapsStyle[key]] = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'];
                    break;
            }
        });
        const { Credit, defaultValue, Event, GeographicTilingScheme, WebMercatorTilingScheme, when } = Cesium;
        options = defaultValue(options, {});
        this._mapStyle = defaultValue(options.mapStyle, TiandituMapsStyle.IMG_W);
        this._url = options.url || defaultValue(options.url, TiandituMapsStyleUrl[this._mapStyle]);
        this._token = options.token;
        this._layer = defaultValue(options.layer, TiandituMapsStyleLayer[this._mapStyle]);
        this._style = defaultValue(options.style, 'default');
        this._tileMatrixSetID = defaultValue(options.tileMatrixSetID, TiandituMapsStyleID[this._mapStyle]);
        this._tileMatrixLabels = defaultValue(options.tileMatrixLabels, TiandituMapsStyleLabels[this._mapStyle]);
        this._format = defaultValue(options.format, TiandituMapsStyleFormat[this._mapStyle]);
        this._epsgCode = TiandituMapsStyleEPSG[this._mapStyle];
        this._tilingScheme = this._epsgCode === '900913' ? new WebMercatorTilingScheme() : new GeographicTilingScheme();
        this._tileWidth = defaultValue(options.tileWidth, 256);
        this._tileHeight = defaultValue(options.tileHeight, 256);
        this._minimumLevel = defaultValue(options.minimumLevel, 0);
        this._maximumLevel = defaultValue(options.maximumLevel, TiandituMapsStyleLabels[this._mapStyle].length);
        this._rectangle = defaultValue(options.rectangle, this.tilingScheme.rectangle);
        this._readyPromise = when.resolve(true);
        this._errorEvent = new Event();
        const credit = defaultValue(options.credit, '天地图全球影像服务');
        this._credit = typeof credit === 'string' ? new Credit(credit) : credit;
        this._subdomains = defaultValue(options.subdomains, ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7']);
        this._tileDiscardPolicy = options.tileDiscardPolicy;
    }
    requestImage(x, y, level) {
        const url = buildImageResource$2.call(this, x, y, level);
        return Cesium.ImageryProvider.loadImage(this, url);
    }
    pickFeatures() {
    }
    get url() {
        return this._url;
    }
    get mapStyle() {
        return this._mapStyle;
    }
    get tileWidth() {
        return this._tileWidth;
    }
    get tileHeight() {
        return this._tileHeight;
    }
    get maximumLevel() {
        return this._maximumLevel;
    }
    get minimumLevel() {
        return this._minimumLevel;
    }
    get tilingScheme() {
        return this._tilingScheme;
    }
    get rectangle() {
        return this._rectangle;
    }
    get errorEvent() {
        return this._errorEvent;
    }
    get ready() {
        return true;
    }
    get readyPromise() {
        return this._readyPromise;
    }
    get credit() {
        return this._credit;
    }
    get hasAlphaChannel() {
        return true;
    }
    get tileDiscardPolicy() {
        return this._tileDiscardPolicy;
    }
}
function buildImageResource$2(x, y, level) {
    const { combine, defined, defaultValue, queryToObject, objectToQuery, Uri } = Cesium;
    const freezeObject = Object.freeze;
    const options = freezeObject({
        service: 'WMTS',
        version: '1.0.0',
        request: 'GetTile'
    });
    this._epsgCode === '900913' && (level -= 1);
    const tileMatrixLabels = this._tileMatrixLabels;
    const tileMatrixLabel = defined(tileMatrixLabels) ? tileMatrixLabels[level] : level.toString();
    const subdomains = this._subdomains;
    let url = this._url.replace('{s}', subdomains[(x + y + level) % subdomains.length]);
    const uri = new Uri(url);
    let obj = queryToObject(defaultValue(uri.query, ''));
    obj = combine(options, obj);
    obj.tilematrix = tileMatrixLabel;
    obj.layer = this._layer;
    obj.style = this._style;
    obj.tilerow = y;
    obj.tilecol = x;
    obj.tilematrixset = this._tileMatrixSetID;
    obj.format = this._format;
    uri.query = objectToQuery(obj);
    url = uri.toString();
    defined(this._proxy) && (url = this._proxy.getURL(url));
    defined(this._token) && (url += '&tk=' + this._token);
    return url;
}

var VcProviderImageryTianditu = vue.defineComponent({
    name: 'VcProviderImageryTianditu',
    props: Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.rectangle), { mapStyle: String, token: String, protocol: {
            type: String,
            default: 'https'
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'TiandituImageryProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            Cesium.TiandituImageryProvider = Cesium.TiandituImageryProvider || TiandituImageryProvider;
            if (providersState.unwatchFns.length === 0) {
                providersState.setPropsWatcher(true);
            }
            const options = providersState.transformProps(props);
            return new Cesium.TiandituImageryProvider(options);
        });
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryTileCoordinates = vue.defineComponent({
    name: 'VcProviderImageryTileCoordinates',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.tilingScheme), cesiumProps.ellipsoid), { color: {
            type: [Object, String, Array],
            default: 'YELLOW'
        } }), cesiumProps.tileWidth), cesiumProps.tileHeight),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'TileCoordinatesImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryTms = vue.defineComponent({
    name: 'VcProviderImageryTms',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.fileExtension), cesiumProps.credit), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.rectangle), cesiumProps.tilingScheme), cesiumProps.ellipsoid), cesiumProps.tileWidth), cesiumProps.tileHeight), { flipXY: Boolean }), cesiumProps.projectionTransforms),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'TileMapServiceImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryTiledcache = vue.defineComponent({
    name: 'VcProviderImageryTiledcache',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.format), cesiumProps.credit), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.rectangle), cesiumProps.tilingScheme), cesiumProps.ellipsoid), cesiumProps.tileWidth), cesiumProps.tileHeight), { dir: {
            type: String,
            reqiured: true
        }, scales: {
            type: Array,
            default: () => {
                return [
                    1 / 295829355,
                    1 / 147914678,
                    1 / 73957339,
                    1 / 36978669,
                    1 / 18489335,
                    1 / 9244667,
                    1 / 4622334,
                    1 / 2311167,
                    1 / 1155583,
                    1 / 577792,
                    1 / 288896,
                    1 / 144448,
                    1 / 72224,
                    1 / 36112,
                    1 / 18056,
                    1 / 9026,
                    1 / 4514
                ];
            }
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'UrlTemplateImageryProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            const options = providersState.transformProps(props);
            const { Credit, defined, defaultValue, DeveloperError, Ellipsoid, GeographicTilingScheme, Rectangle, Resource, UrlTemplateImageryProvider } = Cesium;
            const { url, dir, format } = options;
            if (!defined(url)) {
                throw new DeveloperError('options.url is required.');
            }
            if (!defined(dir)) {
                throw new DeveloperError('options.dir is required.');
            }
            const resource = Resource.createIfNeeded(url);
            resource.url += `?dir=${dir}&scale={scale}&col={x}&row={y}&format=${format}`;
            const tilingScheme = defaultValue(options.tilingScheme, new GeographicTilingScheme({
                ellipsoid: defaultValue(options.ellipsoid, Ellipsoid.WGS84),
                numberOfLevelZeroTilesX: 2,
                numberOfLevelZeroTilesY: 1
            }));
            const tileWidth = defaultValue(options.tileWidth, 256);
            const tileHeight = defaultValue(options.tileHeight, 256);
            const maximumLevel = options.maximumLevel;
            const minimumLevel = defaultValue(options.minimumLevel, 0);
            const rectangle = defaultValue(options.rectangle, tilingScheme.rectangle);
            const swTile = tilingScheme.positionToTileXY(Rectangle.southwest(rectangle), minimumLevel);
            const neTile = tilingScheme.positionToTileXY(Rectangle.northeast(rectangle), minimumLevel);
            const tileCount = (Math.abs(neTile.x - swTile.x) + 1) * (Math.abs(neTile.y - swTile.y) + 1);
            if (tileCount > 4) {
                throw new DeveloperError('The rectangle and minimumLevel indicate that there are ' +
                    tileCount +
                    ' tiles at the minimum level. Imagery providers with more than four tiles at the minimum level are not supported.');
            }
            let credit = defaultValue(options.credit, '');
            if (typeof credit === 'string') {
                credit = new Credit(credit);
            }
            return new UrlTemplateImageryProvider({
                url: resource,
                credit: credit,
                tilingScheme: tilingScheme,
                tileWidth: tileWidth,
                tileHeight: tileHeight,
                minimumLevel: minimumLevel,
                maximumLevel: maximumLevel,
                rectangle: rectangle,
                customTags: {
                    scale: (imageryProvider, x, y, level) => {
                        const s = 1 / props.scales[level];
                        return padWithZerosIfNecessary(imageryProvider, '{scale}', s);
                    }
                }
            });
        });
        const padWithZerosIfNecessary = (imageryProvider, key, value) => {
            if (imageryProvider && imageryProvider.urlSchemeZeroPadding && Object.prototype.hasOwnProperty.call(imageryProvider.urlSchemeZeroPadding, key)) {
                const paddingTemplate = imageryProvider.urlSchemeZeroPadding[key];
                if (typeof paddingTemplate === 'string') {
                    const paddingTemplateWidth = paddingTemplate.length;
                    if (paddingTemplateWidth > 1) {
                        value =
                            value.length >= paddingTemplateWidth
                                ? value
                                : new Array(paddingTemplateWidth - value.toString().length + 1).join('0') + value;
                    }
                }
            }
            return value;
        };
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryUrltemplate = vue.defineComponent({
    name: 'VcProviderImageryUrltemplate',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), { pickFeaturesUrl: [String, Object], urlSchemeZeroPadding: Object }), cesiumProps.subdomains), cesiumProps.credit), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.rectangle), cesiumProps.tilingScheme), cesiumProps.ellipsoid), cesiumProps.tileWidth), cesiumProps.tileHeight), { hasAlphaChannel: {
            type: Boolean,
            default: true
        } }), cesiumProps.getFeatureInfoFormats), cesiumProps.enablePickFeatures), { customTags: Object }), cesiumProps.projectionTransforms),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'UrlTemplateImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryWms = vue.defineComponent({
    name: 'VcProviderImageryWms',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.layers), { parameters: Object, getFeatureInfoParameters: Object }), cesiumProps.enablePickFeatures), cesiumProps.getFeatureInfoFormats), cesiumProps.rectangle), cesiumProps.tilingScheme), cesiumProps.ellipsoid), cesiumProps.tileWidth), cesiumProps.tileHeight), cesiumProps.minimumLevel), cesiumProps.maximumLevel), { crs: String, srs: String }), cesiumProps.credit), cesiumProps.subdomains), cesiumProps.clock), cesiumProps.times),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'WebMapServiceImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderImageryWmts = vue.defineComponent({
    name: 'VcProviderImageryWmts',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.url), cesiumProps.format), { layer: String, wmtsStyle: String, tileMatrixSetID: String, tileMatrixLabels: Array }), cesiumProps.clock), cesiumProps.times), cesiumProps.dimensions), cesiumProps.tileWidth), cesiumProps.tileHeight), cesiumProps.tilingScheme), cesiumProps.rectangle), cesiumProps.minimumLevel), cesiumProps.maximumLevel), cesiumProps.ellipsoid), cesiumProps.credit), cesiumProps.subdomains),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'WebMapTileServiceImageryProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderTerrainCesium = vue.defineComponent({
    name: 'VcProviderTerrainCesium',
    props: Object.assign(Object.assign({ url: [String, Object], requestVertexNormals: {
            type: Boolean,
            default: false
        }, requestWaterMask: {
            type: Boolean,
            default: false
        }, requestMetadata: {
            type: Boolean,
            default: true
        } }, cesiumProps.ellipsoid), cesiumProps.credit),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'CesiumTerrainProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            if (providersState.unwatchFns.length === 0) {
                providersState.setPropsWatcher(true);
            }
            const options = providersState.transformProps(props);
            return Cesium.defined(options.url)
                ? new Cesium.CesiumTerrainProvider(options)
                : Cesium.createWorldTerrain({ requestVertexNormals: options.requestVertexNormals, requestWaterMask: options.requestWaterMask });
        });
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderTerrainArcgis = vue.defineComponent({
    name: 'VcProviderTerrainArcgis',
    props: Object.assign(Object.assign({ url: {
            type: [String, Object],
            default: 'https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer'
        } }, cesiumProps.ellipsoid), cesiumProps.token),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'ArcGISTiledElevationTerrainProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderTerrainVrTheworld = vue.defineComponent({
    name: 'VcProviderTerrainVrTheworld',
    props: Object.assign(Object.assign({ url: {
            type: [String, Object],
            default: 'https://www.vr-theworld.com/vr-theworld/tiles1.0.0/73/'
        } }, cesiumProps.ellipsoid), cesiumProps.credit),
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'VRTheWorldTerrainProvider';
        composables.useProviders(props, ctx, instance);
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcProviderTerrainTianditu = vue.defineComponent({
    name: 'VcProviderTerrainTianditu',
    props: {
        url: {
            type: String,
            default: 'https://{s}.tianditu.gov.cn/'
        },
        subdomains: {
            type: Array,
            default: () => ['t0', 't1', 't2', 't3', 't4', 't5', 't6', 't7']
        },
        pluginPath: {
            type: String,
            default: 'https://api.tianditu.gov.cn/cdn/plugins/cesium/cesiumTdt.js'
        },
        dataType: {
            type: String,
            default: 'int',
            validator: (v) => ['int', 'float'].includes(v)
        },
        tileType: {
            type: String,
            default: 'heightmap',
            validator: (v) => ['heightmap', 'quantized-mesh'].includes(v)
        },
        token: String
    },
    emits: ['beforeLoad', 'ready', 'destroyed', 'readyPromise'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'GeoTerrainProvider';
        const providersState = composables.useProviders(props, ctx, instance);
        const vc = composables.useVueCesium();
        let $script;
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => {
                $script = document.createElement('script');
                global.document.body.appendChild($script);
                $script.src = props.pluginPath;
                $script.onload = () => {
                    if (providersState.unwatchFns.length === 0) {
                        providersState.setPropsWatcher(true);
                    }
                    const terrainUrls = [];
                    for (let i = 0; i < props.subdomains.length; i++) {
                        const url = props.url.replace('{s}', props.subdomains[i]) + 'mapservice/swdx?tk=' + props.token;
                        terrainUrls.push(url);
                    }
                    resolve(new Cesium.GeoTerrainProvider({
                        urls: terrainUrls
                    }));
                };
            });
        });
        instance.unmount = () => __awaiter(this, void 0, void 0, function* () {
            const terrainProvider = new Cesium.EllipsoidTerrainProvider();
            terrainProvider.readyPromise.then(() => {
                const listener = vm.getInstanceListener(instance, 'readyPromise');
                listener && ctx.emit('readyPromise', terrainProvider, vc.viewer, instance.proxy);
            });
            vc.viewer.terrainProvider = terrainProvider;
            $script === null || $script === void 0 ? void 0 : $script.parentNode.removeChild($script);
            return true;
        });
        return () => vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

const components = [
    VcProviderImageryArcgis,
    VcProviderImageryBaidumap,
    VcProviderImageryBingmaps,
    VcProviderImageryGoogle,
    VcProviderImageryGrid,
    VcProviderImageryIon,
    VcProviderImageryMapbox,
    VcProviderImageryOsm,
    VcProviderImagerySingletile,
    VcProviderImagerySupermap,
    VcProviderImageryTianditu,
    VcProviderImageryTileCoordinates,
    VcProviderImageryTms,
    VcProviderImageryTiledcache,
    VcProviderImageryUrltemplate,
    VcProviderImageryWms,
    VcProviderImageryWmts,
    VcProviderTerrainCesium,
    VcProviderTerrainArcgis,
    VcProviderTerrainVrTheworld,
    VcProviderTerrainTianditu
];
const install = (app) => {
    components.forEach(cmp => {
        app.component(cmp.name, cmp);
    });
};
var index = {
    install
};

exports.VcProviderImageryArcgis = VcProviderImageryArcgis;
exports.VcProviderImageryBaidumap = VcProviderImageryBaidumap;
exports.VcProviderImageryBingmaps = VcProviderImageryBingmaps;
exports.VcProviderImageryGoogle = VcProviderImageryGoogle;
exports.VcProviderImageryGrid = VcProviderImageryGrid;
exports.VcProviderImageryIon = VcProviderImageryIon;
exports.VcProviderImageryMapbox = VcProviderImageryMapbox;
exports.VcProviderImageryOsm = VcProviderImageryOsm;
exports.VcProviderImagerySingletile = VcProviderImagerySingletile;
exports.VcProviderImagerySupermap = VcProviderImagerySupermap;
exports.VcProviderImageryTianditu = VcProviderImageryTianditu;
exports.VcProviderImageryTileCoordinates = VcProviderImageryTileCoordinates;
exports.VcProviderImageryTiledcache = VcProviderImageryTiledcache;
exports.VcProviderImageryTms = VcProviderImageryTms;
exports.VcProviderImageryUrltemplate = VcProviderImageryUrltemplate;
exports.VcProviderImageryWms = VcProviderImageryWms;
exports.VcProviderImageryWmts = VcProviderImageryWmts;
exports.VcProviderTerrainArcgis = VcProviderTerrainArcgis;
exports.VcProviderTerrainCesium = VcProviderTerrainCesium;
exports.VcProviderTerrainTianditu = VcProviderTerrainTianditu;
exports.VcProviderTerrainVrTheworld = VcProviderTerrainVrTheworld;
exports.default = index;
