import { defineComponent, getCurrentInstance, provide, h, createCommentVNode } from 'vue';
import useViewer from './useViewer.mjs';
import defaultProps from './defaultProps.mjs';
import { vcKey } from '../../../utils/config.mjs';
import { emits, viewerEvents } from './events.mjs';
import { VcSkeleton } from '../../ui/index.mjs';
import { hSlot } from '../../../utils/private/render.mjs';
import { kebabCase } from '../../../utils/util.mjs';
import { isPlainObject } from '@vue/shared';

var Viewer = defineComponent({
  name: "VcViewer",
  props: defaultProps,
  emits,
  setup(props, ctx) {
    const instance = getCurrentInstance();
    instance.cesiumEvents = ["selectedEntityChanged", "trackedEntityChanged"];
    instance.cesiumMembersEvents = viewerEvents;
    const viewerStates = useViewer(props, ctx, instance);
    provide(vcKey, viewerStates.getServices());
    Object.assign(instance.proxy, {
      createPromise: viewerStates.createPromise,
      load: viewerStates.load,
      unload: viewerStates.unload,
      reload: viewerStates.reload,
      cesiumObject: instance.cesiumObject,
      getCesiumObject: () => instance.cesiumObject
    });
    return () => {
      var _a;
      const children = [];
      if (isPlainObject(props.skeleton) && !viewerStates.isReady.value) {
        children.push(h(VcSkeleton, {
          ...props.skeleton,
          style: { background: props.skeleton.color, width: "100%", height: "100%" }
        }));
      } else {
        children.push(createCommentVNode("v-if"));
      }
      children.push(createCommentVNode("vc-viewer"), h("div", {
        ref: viewerStates.viewerRef,
        class: kebabCase(((_a = instance.proxy) == null ? void 0 : _a.$options.name) || ""),
        id: ctx.attrs.id || "cesiumContainer",
        style: ctx.attrs.style || { width: "100%", height: "100%" }
      }, hSlot(ctx.slots.default)));
      return children;
    };
  }
});

export { Viewer as default };
//# sourceMappingURL=index.mjs.map
