'use strict';

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

var _extends2 = require('babel-runtime/helpers/extends');

var _extends3 = _interopRequireDefault(_extends2);

var _antdv = require('../../_util/antdv');

var _methodsUtil = require('../../_util/methods-util');

var _mouseTooltip = require('./mouse-tooltip');

var _mouseTooltip2 = _interopRequireDefault(_mouseTooltip);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var Interactions = {
  name: 'PjMap.Interactions',
  props: {
    data: _antdv.PropTypes.array
  },
  data: function data() {
    return {
      interactions: {}
    };
  },

  inject: {
    mapProvider: { 'default': function _default() {} }
  },
  methods: {
    // 动态渲染地图交互式组件
    renderInteractionsComponents: function renderInteractionsComponents() {
      var _this = this;

      var h = this.$createElement;
      var data = this.data;

      return data && (0, _methodsUtil.isNotEmptyArray)(data) && data.map(function (item, idx) {
        var attrs = (0, _extends3['default'])({}, item);
        !attrs.props && (attrs.props = {});
        attrs.props.key = item.id || String(idx);
        attrs.props.id = attrs.props.key;

        var component = null;
        switch (item.type) {
          case 'MouseTooltip':
            {
              component = h(_mouseTooltip2['default'], attrs);
              break;
            }
        }
        _this.interactions[item.id] = component;
        return component;
      });
    }
  },
  render: function render() {
    var h = arguments[0];

    return h(
      'section',
      {
        attrs: { 'data-type': 'interaction' }
      },
      [this.renderInteractionsComponents()]
    );
  }
}; /**
    * @文件说明: Map.Interactions - 地图交互组件
    * @创建人: pjtools@vip.qq.com
    * @创建时间: 2020-05-18 13:56:44
    */

exports['default'] = Interactions;