/**
 * ldesign v0.2.22
 * (c) 2022/12/7 16:21 built by swimly
 * @license MIT
 */

import { defineComponent, computed } from '@vue/composition-api';
import { usePrefixClass } from '../../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import '../config-provider/context.js';
import 'lodash/merge';
import 'lodash/mergeWith';
import '../../_chunks/dep-b4fd1955.js';

var _HighlightOption = defineComponent({
  name: "HighlightOption",
  props: {
    content: String,
    keyword: String
  },
  setup(props) {
    const classPrefix = usePrefixClass();
    const words = computed(() => {
      const {
        content,
        keyword
      } = props;
      if (!content) return {
        list: []
      };
      if (typeof content !== "string" || !keyword) return {
        list: [content]
      };
      const regExp = new RegExp(keyword, "i");
      const splitKeyword = content.match(regExp)?.[0];
      return {
        list: content.split(splitKeyword),
        keyword: splitKeyword
      };
    });
    return {
      words,
      classPrefix
    };
  },
  render() {
    const h = arguments[0];
    const {
      list,
      keyword
    } = this.words;
    return h("div", {
      "class": `${this.classPrefix}-select-option__highlight-item`
    }, [list.map((item, index) => {
      if (!index) return item;
      return [h("b", {
        "class": `${this.classPrefix}-is-highlight`,
        "key": item + keyword
      }, [keyword]), item];
    })]);
  }
});

export { _HighlightOption as default };
//# sourceMappingURL=highlight-option.js.map
