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

import { Icon } from '@ldesign/icons-vue';
import { renderContent, renderLNodeJSX } from '../../utils/render-node.js';
import { getClassPrefixMixins } from '../config-provider/config-receiver.js';
import mixins from '../../utils/mixins.js';
import props from './props.js';
import 'vue';
import 'lodash';
import 'lodash/mergeWith';
import '../config-provider/context.js';
import '../../chunks/zh_CN.js';
import '../config-provider/type.js';

var _Link = mixins(getClassPrefixMixins("link")).extend({
  name: "LLink",
  props: {
    ...props
  },
  components: {
    LIcon: 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 = renderContent(this, "default", "content");
    const prefixContent = this.isStringIcon("prefixIcon") ? h("l-icon", {
      "attrs": {
        "name": this.prefixIcon
      }
    }) : renderLNodeJSX(this, "prefixIcon");
    const suffixContent = this.isStringIcon("suffixIcon") ? h("l-icon", {
      "attrs": {
        "name": this.suffixIcon
      }
    }) : 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])]);
  }
});

export { _Link as default };
//# sourceMappingURL=link.js.map
