/**
 * vue-cesium - https://github.com/zouyaoji/vue-cesium
 * Vue 2.x components for CesiumJS.
 *
 * @package VueCesium
 * @author zouyaoji <370681295@qq.com>
 * @version 2.2.8
 * @license MIT
 * @homepage https://zouyaoji.top/vue-cesium
 * @copyright (c) 2018-2021, zouyaoji <370681295@qq.com>
 */
import _Object$defineProperties from '@babel/runtime-corejs2/core-js/object/define-properties';
import _regeneratorRuntime from '@babel/runtime-corejs2/regenerator';
import cmp from '../virtualCmp';
import mixinPickEvent from '../event/mixinPickEvent';

var methods = {
  /**
   * 重写 createCesiumObject 方法。
   */
  createCesiumObject: function createCesiumObject() {
    var $props, transformProps, primitives, options;
    return _regeneratorRuntime.async(function createCesiumObject$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            $props = this.$props, transformProps = this.transformProps, primitives = this.primitives;
            options = transformProps($props);
            return _context.abrupt("return", primitives && primitives.add(options));

          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, null, this);
  },
  mount: function mount() {
    var primitives, primitive, registerEvents;
    return _regeneratorRuntime.async(function mount$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            primitives = this.primitives, primitive = this.primitive, registerEvents = this.registerEvents;
            registerEvents(true);
            return _context2.abrupt("return", primitives && primitives.contains(primitive));

          case 3:
          case "end":
            return _context2.stop();
        }
      }
    }, null, this);
  },
  unmount: function unmount() {
    var primitives, primitive, registerEvents;
    return _regeneratorRuntime.async(function unmount$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            primitives = this.primitives, primitive = this.primitive, registerEvents = this.registerEvents;
            registerEvents(false);
            return _context3.abrupt("return", primitives && !primitives.isDestroyed() && primitives.remove(primitive));

          case 3:
          case "end":
            return _context3.stop();
        }
      }
    }, null, this);
  }
};
var mixinPrimitiveCollectionItem = {
  props: {
    enableEvent: {
      type: Boolean,
      default: true
    }
  },
  mixins: [cmp, mixinPickEvent],
  methods: methods,
  stubVNode: {
    empty: function empty() {
      return this.$options.name;
    }
  },
  created: function created() {
    var _this = this;

    this.index = 0;

    _Object$defineProperties(this, {
      primitive: {
        enumerable: true,
        get: function get() {
          return _this.cesiumObject;
        }
      },
      primitives: {
        enumerable: true,
        get: function get() {
          return _this.$services && _this.$services.primitives;
        }
      }
    });
  }
};

export default mixinPrimitiveCollectionItem;
