/**
 * tdesign v0.32.0
 * (c) 2021 tdesign
 * @license MIT
 */

'use strict';

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

var helper = require('../_chunks/dep-44e6bdf6.js');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var Vue = require('vue');
var config = require('../config.js');
var tooltip_props = require('./props.js');
var popup_props = require('../popup/props.js');
var popup_popup = require('../popup/popup.js');
var utils_renderTnode = require('../utils/render-tnode.js');
require('@babel/runtime/helpers/typeof');
require('@popperjs/core');
require('../_chunks/dep-939cdc39.js');
require('../utils/classnames.js');
require('../utils/dom.js');
require('raf');
require('lodash/isString');
require('../utils/easing.js');
require('../utils/set-style.js');

function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultLegacy(_defineProperty);
var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);

function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }

function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty__default["default"](target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
var _Tooltip = Vue__default["default"].extend({
  name: "TTooltip",
  components: {
    Popup: popup_popup["default"]
  },
  props: _objectSpread(_objectSpread({}, popup_props["default"]), tooltip_props["default"]),
  data: function data() {
    return {
      timer: null,
      tooltipVisible: false
    };
  },
  computed: {
    tooltipOverlayClassName: function tooltipOverlayClassName() {
      return ["".concat(config.prefix, "-tooltip"), _defineProperty__default["default"]({}, "".concat(config.prefix, "-tooltip--").concat(this.theme), this.theme), this.overlayClassName];
    }
  },
  watch: {
    visible: function visible(_visible) {
      if (this.timer && !_visible) {
        clearTimeout(this.timer);
        this.timer = null;
      }
    }
  },
  created: function created() {
    var _this = this;

    if (this.duration && this.visible) {
      this.timer = setTimeout(function () {
        _this.$emit("visible-change", false);

        clearTimeout(_this.timer);
        _this.timer = null;
      }, this.duration);
    }
  },
  methods: {
    onTipVisibleChange: function onTipVisibleChange(val, ctx) {
      if (this.timer && (ctx === null || ctx === void 0 ? void 0 : ctx.trigger) !== "document") return;
      this.$emit("visible-change", val);
    },
    getPopupProps: function getPopupProps() {
      var _this2 = this;

      var r = _objectSpread(_objectSpread({
        showArrow: true
      }, this.$props), {}, {
        content: function content() {
          return utils_renderTnode.renderTNodeJSX(_this2, "content");
        },
        "default": function _default() {
          return utils_renderTnode.renderContent(_this2, "default", "triggerElement");
        },
        overlayClassName: this.tooltipOverlayClassName
      });

      return r;
    }
  },
  render: function render() {
    var h = arguments[0];
    return h(popup_popup["default"], helper.helper([{
      "attrs": {
        "visible": this.visible,
        "showArrow": this.showArrow
      }
    }, {
      "props": this.getPopupProps()
    }, {}, {
      "on": {
        "visible-change": this.onTipVisibleChange
      }
    }]));
  }
});

exports["default"] = _Tooltip;
//# sourceMappingURL=tooltip.js.map
