/**
 * ldesign v0.2.14
 * (c) 2022/11/2 16:16 built by swimly
 * @license MIT
 */

'use strict';

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

var iconsVue = require('@ldesign/icons-vue');
var utils_renderNode = require('../../utils/render-node.js');
var components_configProvider_configReceiver = require('../config-provider/config-receiver.js');
var utils_mixins = require('../../utils/mixins.js');
var components_link_props = require('./props.js');
require('vue');
require('lodash');
require('lodash/mergeWith');
require('../config-provider/context.js');
require('../../chunks/zh_CN.js');

var _Link = utils_mixins["default"](components_configProvider_configReceiver.getClassPrefixMixins("link")).extend({
  name: "LLink",
  props: {
    ...components_link_props["default"]
  },
  components: {
    LIcon: iconsVue.Icon
  },
  methods: {
    handleClick(e) {
      var _this$onClick;
      if (this.disabled) return;
      this.$emit("click", e);
      (_this$onClick = this.onClick) === null || _this$onClick === void 0 ? void 0 : _this$onClick.call(this, e);
    }
  },
  computed: {
    isStringIcon() {
      return name => typeof this[name] === "string" && this[name];
    }
  },
  render() {
    const h = arguments[0];
    const {
      componentName: NAME,
      classPrefix: PREFIX,
      commonSizeClassName: SIZE,
      commonStatusClassName: STATUS
    } = this;
    const linkContent = utils_renderNode.renderContent(this, "default", "content");
    const prefixContent = this.isStringIcon("prefixIcon") ? h("l-icon", {
      "attrs": {
        "name": this.prefixIcon
      }
    }) : utils_renderNode.renderLNodeJSX(this, "prefixIcon");
    const suffixContent = this.isStringIcon("suffixIcon") ? h("l-icon", {
      "attrs": {
        "name": this.suffixIcon
      }
    }) : utils_renderNode.renderLNodeJSX(this, "suffixIcon");
    const classes = [NAME, SIZE[this.size], `${NAME}--theme-${this.theme}`, {
      [STATUS.disabled]: this.disabled,
      [`${PREFIX}-is-underline`]: this.underline,
      [`${NAME}--hover-${this.hover}`]: !this.disabled
    }];
    return h("a", {
      "class": classes,
      "attrs": {
        "href": this.disabled || !this.href ? void 0 : this.href,
        "target": this.target
      },
      "on": {
        "click": this.handleClick
      }
    }, [prefixContent && h("span", {
      "class": `${NAME}__prefix-icon`
    }, [prefixContent]), linkContent, suffixContent && h("span", {
      "class": `${NAME}__suffix-icon`
    }, [suffixContent])]);
  }
});

exports["default"] = _Link;
//# sourceMappingURL=link.js.map
