import "./message.css";
/* script */
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
import { componentMixin, createComponentName } from '../../utils/base';
import Portal from '../portal';
import Icon from '../icon';
import popupManager from '../../utils/popup-manager';
const __vue_script__ = {
  name: createComponentName('message'),
  components: {
    Portal,
    Icon
  },
  mixins: [componentMixin],
  props: {
    top: {
      type: String,
      default: '25vh'
    },
    delay: {
      type: Number,
      default: 2000
    },
    showClose: {
      type: Boolean,
      default: true
    },
    onClose: {
      type: [Function, undefined]
    }
  },

  data() {
    return {
      visible: false,
      zIndex: 0
    };
  },

  watch: {
    visible(value, old) {
      if (value && value !== old) {
        this.zIndex = popupManager.getZindex();
      }
    }

  },

  mounted() {
    this.autoClose();
  },

  methods: {
    autoClose() {
      if (this.delay) {
        this.timer = setTimeout(() => {
          this.visible = false;
        }, this.delay);
      }
    },

    clearAutoClose() {
      clearTimeout(this.timer);
    }

  }
};
/* template */

var __vue_render__ = function () {
  var _vm = this;

  var _h = _vm.$createElement;

  var _c = _vm._self._c || _h;

  return _c("Portal", [_vm.visible ? _c("transition", {
    attrs: {
      name: "gd-message-fade"
    },
    on: {
      "after-leave": _vm.onClose
    }
  }, [_c("div", {
    class: _vm.bem(),
    style: {
      zIndex: _vm.zIndex,
      top: _vm.top
    },
    on: {
      mouseover: _vm.clearAutoClose,
      mouseout: _vm.autoClose
    }
  }, [_c("div", {
    class: _vm.bem("content")
  }, [_vm._t("default", [_vm._v(_vm._s(_vm.message))])], 2), _vm._v(" "), _vm.showClose ? _c("icon", {
    class: _vm.bem("close"),
    attrs: {
      name: "close",
      color: "#AAA"
    },
    nativeOn: {
      click: function ($event) {
        _vm.visible = false;
      }
    }
  }) : _vm._e()], 1)]) : _vm._e()], 1);
};

var __vue_staticRenderFns__ = [];
__vue_render__._withStripped = true;
/* style */

const __vue_inject_styles__ = undefined;
/* scoped */

const __vue_scope_id__ = undefined;
/* module identifier */

const __vue_module_identifier__ = undefined;
/* functional template */

const __vue_is_functional_template__ = false;
/* component normalizer */

import __vue_normalize__ from '../../utils/vue-normalize-component.js';
/* style inject */

/* style inject SSR */

export default __vue_normalize__({
  render: __vue_render__,
  staticRenderFns: __vue_staticRenderFns__
}, __vue_inject_styles__, __vue_script__, __vue_scope_id__, __vue_is_functional_template__, __vue_module_identifier__, undefined, undefined);