'use strict';

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

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

/*! *****************************************************************************
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());
    });
}

var VcDatasourceCustom = vue.defineComponent({
    name: 'VcDatasourceCustom',
    props: Object.assign(Object.assign(Object.assign({}, cesiumProps.show), cesiumProps.enableMouseEvent), { entities: {
            type: Array,
            default: () => []
        }, name: String, destroy: {
            type: Boolean,
            default: false
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'definitionChanged', 'clusterEvent', 'collectionChanged', 'changedEvent', 'errorEvent', 'loadingEvent'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'CustomDataSource';
        composables.useDatasources(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            return new Cesium.CustomDataSource(props.name);
        });
        return () => ctx.slots.default ? (vue.h('i', {
            class: util.kebabCase(instance.proxy.$options.name),
            style: { display: 'none !important' }
        }, render.hSlot(ctx.slots.default))) : vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcDatasourceCzml = vue.defineComponent({
    name: 'VcDatasourceCzml',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.show), cesiumProps.enableMouseEvent), { entities: {
            type: Array,
            default: () => []
        }, czml: {
            type: [String, Object],
            required: true
        } }), cesiumProps.sourceUri), cesiumProps.credit), { destroy: {
            type: Boolean,
            default: false
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'definitionChanged', 'clusterEvent', 'collectionChanged', 'changedEvent', 'errorEvent', 'loadingEvent'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'CzmlDataSource';
        const datasourcesState = composables.useDatasources(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            const options = datasourcesState.transformProps(props);
            return Cesium.CzmlDataSource.load(props.czml, options);
        });
        return () => ctx.slots.default ? (vue.h('i', {
            class: util.kebabCase(instance.proxy.$options.name),
            style: { display: 'none !important' }
        }, render.hSlot(ctx.slots.default))) : vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcDatasourceGeojson = vue.defineComponent({
    name: 'VcDatasourceGeojson',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.show), cesiumProps.enableMouseEvent), { entities: {
            type: Array,
            default: () => []
        } }), cesiumProps.data), cesiumProps.sourceUri), { describe: [Function, Object], markerSize: {
            type: Number,
            default: 48
        }, markerSymbol: String, markerColor: {
            type: [Object, String, Array],
            default: () => ({ x: 0.2549019607843137, y: 0.4117647058823529, z: 0.8823529411764706 }),
            watcherOptions: {
                cesiumObjectBuilder: cesiumHelpers.makeColor
            }
        }, stroke: {
            type: [Object, String, Array],
            default: () => ({ x: 1, y: 1, z: 0 }),
            watcherOptions: {
                cesiumObjectBuilder: cesiumHelpers.makeColor
            }
        }, strokeWidth: {
            type: Number,
            default: 2
        }, fill: {
            type: [Object, String, Array],
            default: () => ({ x: 1, y: 1, z: 0, w: 0.39215686274509803 }),
            watcherOptions: {
                cesiumObjectBuilder: cesiumHelpers.makeColor
            }
        } }), cesiumProps.clampToGround), cesiumProps.credit), { destroy: {
            type: Boolean,
            default: false
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'definitionChanged', 'clusterEvent', 'collectionChanged', 'changedEvent', 'errorEvent', 'loadingEvent'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'GeoJsonDataSource';
        const datasourcesState = composables.useDatasources(props, ctx, instance);
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            const options = datasourcesState.transformProps(props);
            return Cesium.GeoJsonDataSource.load(props.data, options);
        });
        return () => ctx.slots.default ? (vue.h('i', {
            class: util.kebabCase(instance.proxy.$options.name),
            style: { display: 'none !important' }
        }, render.hSlot(ctx.slots.default))) : vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

var VcDatasourceKml = vue.defineComponent({
    name: 'VcDatasourceKml',
    props: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, cesiumProps.show), cesiumProps.enableMouseEvent), { entities: {
            type: Array,
            default: () => []
        } }), cesiumProps.data), { camera: Object, canvas: HTMLCanvasElement }), cesiumProps.sourceUri), cesiumProps.clampToGround), cesiumProps.ellipsoid), cesiumProps.credit), { destroy: {
            type: Boolean,
            default: false
        } }),
    emits: ['beforeLoad', 'ready', 'destroyed', 'definitionChanged', 'clusterEvent', 'collectionChanged',
        'changedEvent', 'errorEvent', 'loadingEvent', 'refreshEvent', 'unsupportedNodeEvent'],
    setup(props, ctx) {
        const instance = vue.getCurrentInstance();
        instance.cesiumClass = 'KmlDataSource';
        const datasourcesState = composables.useDatasources(props, ctx, instance);
        const vc = composables.useVueCesium();
        instance.createCesiumObject = () => __awaiter(this, void 0, void 0, function* () {
            const options = datasourcesState.transformProps(props);
            if (!options.camera) {
                options.camera = vc.viewer.camera;
            }
            if (!options.canvas) {
                options.canvas = vc.viewer.canvas;
            }
            return Cesium.KmlDataSource.load(props.data, options);
        });
        return () => ctx.slots.default ? (vue.h('i', {
            class: util.kebabCase(instance.proxy.$options.name),
            style: { display: 'none !important' }
        }, render.hSlot(ctx.slots.default))) : vue.createCommentVNode(util.kebabCase(instance.proxy.$options.name));
    }
});

const components = [
    VcDatasourceCustom,
    VcDatasourceCzml,
    VcDatasourceGeojson,
    VcDatasourceKml
];
const install = (app) => {
    components.forEach(cmp => {
        app.component(cmp.name, cmp);
    });
};
var index = {
    install
};

exports.VcDatasourceCustom = VcDatasourceCustom;
exports.VcDatasourceCzml = VcDatasourceCzml;
exports.VcDatasourceGeojson = VcDatasourceGeojson;
exports.VcDatasourceKml = VcDatasourceKml;
exports.default = index;
