'use strict';

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

var _typeof2 = require('babel-runtime/helpers/typeof');

var _typeof3 = _interopRequireDefault(_typeof2);

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

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

var _antDesignVue = require('ant-design-vue');

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

var DefaultPopup = {
  props: {
    // 地图iMapApi实例对象
    iMapApi: _antdv.PropTypes.any,
    // Popup对象
    popup: _antdv.PropTypes.any,
    // Popup对象的参数选项
    options: _antdv.PropTypes.object.def({}),
    // Slot插槽传递的数据
    data: _antdv.PropTypes.any
  },
  computed: {
    slotContent: function slotContent() {
      return this.$scopedSlots && this.$scopedSlots['default'] ? this.$scopedSlots['default']() : null;
    }
  },
  methods: {
    // 根据Slots插槽渲染Popup标注内容
    renderPopupContent: function renderPopupContent(h) {
      var iMapApi = this.iMapApi,
          popup = this.popup,
          data = this.data,
          slots = this.options.slots;


      if ((0, _methodsUtil.isFunction)(slots)) {
        return h(
          'div',
          { 'class': 'popup-inner-content' },
          [slots(h)]
        );
      } else if ((typeof slots === 'undefined' ? 'undefined' : (0, _typeof3['default'])(slots)) === 'object' && slots instanceof HTMLElement) {
        return h('div', { 'class': 'popup-inner-content', domProps: {
            'innerHTML': slots.outerHTML
          }
        });
      } else if ((0, _methodsUtil.isString)(slots)) {
        var slotNodes = (0, _antdv.getComponentFromProp)(iMapApi.component, 'popup.' + slots, {}, false);
        return h(
          'div',
          { 'class': 'popup-inner-content' },
          [slotNodes ? (0, _antdv.filterEmpty)(slotNodes({ iMapApi: iMapApi, popup: popup, data: data })) : slots]
        );
      }
      return h('div', { 'class': 'popup-inner-content' });
    },


    // 执行Popup气泡弹窗的关闭按钮单击Click事件
    handlePopupClose: function handlePopupClose() {
      this.popup && this.popup.remove();
    }
  },
  render: function render(h) {
    var options = this.options;


    return h('div', [options.anchor && options.anchor === 'center' || (0, _methodsUtil.isBooleanFlase)(options.defaultSkin) ? null : h('div', { 'class': 'popup-arrow' }), h(
      'div',
      { 'class': 'popup-inner' },
      [(0, _methodsUtil.isBooleanFlase)(options.closeButton) || (0, _methodsUtil.isBooleanFlase)(options.defaultSkin) ? null : h(
        'div',
        { 'class': 'popup-inner-close', on: {
            'click': this.handlePopupClose
          }
        },
        [h(_antDesignVue.Icon, {
          attrs: { type: 'close' }
        })]
      ), this.renderPopupContent(h)]
    )]);
  }
}; /**
    * @文件说明: 定义默认Popup气泡弹窗组件
    * @创建人: pjtools@vip.qq.com
    * @创建时间: 2020-06-15 14:43:53
    */

exports['default'] = DefaultPopup;