'use strict';

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

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

var _extends3 = _interopRequireDefault(_extends2);

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

var _baseProps = require('../baseProps');

var _baseProps2 = _interopRequireDefault(_baseProps);

var _baseMixin = require('../baseMixin');

var _baseMixin2 = _interopRequireDefault(_baseMixin);

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

// 默认Attribution控件的位置
var defaultAttributionPosition = exports.defaultAttributionPosition = 'bottom-right'; /**
                                                                                       * @文件说明: Controls.Attribution - (属性/署名)信息控件
                                                                                       * @创建人: pjtools@vip.qq.com
                                                                                       * @创建时间: 2020-03-31 12:42:04
                                                                                       */

var Attribution = {
  name: 'PjMap.Controls.Attribution',
  inheritAttrs: false,
  mixins: [_baseMixin2['default']],
  props: (0, _antdv.initDefaultProps)((0, _extends3['default'])({}, (0, _baseProps2['default'])(), {
    // 控件的内容
    content: _antdv.PropTypes.string
  }), {
    position: defaultAttributionPosition,
    offset: [0, 0],
    content: '\u7248\u6743\u6240\u6709\uFF1A\xA9 PJtools <a href="https://www.mapbox.com/about/maps/" target="_blank">\xA9 Mapbox</a> <a href="http://www.geostar.com.cn/" target="_blank">\xA9 GeoStar</a>'
  }),
  computed: {
    slotsVNode: function slotsVNode() {
      var $slots = this.mapProvider.$slots;

      return $slots && $slots['controls.attribution'] ? (0, _antdv.filterEmpty)($slots['controls.attribution']) : null;
    }
  },
  methods: {
    /**
     * 更新当前Content内容，不包括Slots插槽模式的更新；
     * @param {string} content 待更新的内容
     */
    setContent: function setContent(content) {
      if (!this.slotsVNode) {
        this.$emit('update:content', content);
      }
    }
  },
  render: function render() {
    var h = arguments[0];
    var id = this.id,
        classes = this.classes,
        ctrlStyles = this.ctrlStyles,
        slotsVNode = this.slotsVNode;


    return slotsVNode ? h(
      'div',
      {
        attrs: { 'data-id': id },
        'class': classes, style: ctrlStyles },
      [slotsVNode]
    ) : h('div', {
      attrs: { 'data-id': id },
      'class': classes, style: ctrlStyles, domProps: {
        'innerHTML': this.content
      }
    });
  }
};

exports['default'] = Attribution;