import { createVNode as _createVNode } from "vue";
import { createTextVNode as _createTextVNode } from "vue";
import { Fragment as _Fragment } from "vue";
import { computed, defineComponent } from 'vue';
import { withInstall } from '../utils';

/**
 * 版权组件
 */
var Copyright = defineComponent({
  name: 'Copyright',
  props: {
    prefix: {
      type: [String, Number, Array],
      default: '©'
    },
    year: {
      type: [Number, Array],
      default: new Date().getFullYear()
    },
    copyright: [Object, Function],
    defaultCopyright: {
      default: '安徽晶奇科技网络股份有限公司 - 技术研究中心'
    }
  },
  setup: function setup(props, _ref) {
    var slots = _ref.slots;

    /* 是否隐藏年份 */
    var hiddenYear = computed(function () {
      return !!slots.prefix;
    });
    /* 计算年份或年份范围 */

    var yearStr = computed(function () {
      var year = props.year;

      if (typeof year === 'number' || typeof year === 'string') {
        return year;
      } else if (Array.isArray(year)) {
        var y1 = Number(year[0]);
        var y2 = Number(year[1]);
        return "".concat(Math.min(y1, y2), " - ").concat(Math.max(y1, y2));
      }

      return year;
    });
    return function () {
      var _slots$default;

      var prefix = props.prefix,
          copyright = props.copyright,
          defaultCopyright = props.defaultCopyright,
          className = props.className,
          style = props.style;
      var realPrefix = slots.prefix && slots.prefix() || prefix;
      return _createVNode("div", {
        "class": "copyright",
        "style": style
      }, [realPrefix && _createVNode(_Fragment, null, [_createVNode("span", {
        "class": 'copyright-prefix'
      }, [realPrefix, _createTextVNode(" ")]), !hiddenYear.value && _createVNode("span", {
        "class": 'copyright-year'
      }, [yearStr.value, _createTextVNode(" ")])]), _createVNode("span", {
        "class": 'copyright-name'
      }, [((_slots$default = slots.default) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)) || copyright || defaultCopyright])]);
    };
  }
});
export default withInstall(Copyright);