/**
 * ldesign v0.3.13
 * (c) 2023 ldesign
 * @license MIT
 */

import { defineComponent, computed, createVNode } from 'vue';
import isString from 'lodash/isString';
import { usePrefixClass } from '../hooks/useConfig.js';
import '../config-provider/useConfig.js';
import 'lodash/cloneDeep';
import 'lodash/isFunction';
import '../config-provider/context.js';
import 'lodash/mergeWith';
import 'lodash/merge';
import 'lodash/isArray';
import '../_common/js/global-config/default-config.js';
import '../_common/js/global-config/locale/zh_CN.js';
import '@babel/runtime/helpers/typeof';
import '../_chunks/dep-512eb181.js';
import 'dayjs';
import '../_chunks/dep-ac28b67c.js';
import '../config-provider/type.js';

var _HighlightOption = defineComponent({
  name: "THighlightOption",
  props: {
    content: String,
    keyword: String
  },
  setup: function setup(props) {
    var classPrefix = usePrefixClass();
    var words = computed(function () {
      var _content$match;
      var content = props.content,
        keyword = props.keyword;
      if (!content) return {
        list: []
      };
      if (!isString(content) || !keyword) return {
        list: [content]
      };
      var regExp = new RegExp(keyword, "i");
      var splitKeyword = (_content$match = content.match(regExp)) === null || _content$match === void 0 ? void 0 : _content$match[0];
      return {
        list: content.split(splitKeyword),
        keyword: splitKeyword
      };
    });
    return function () {
      var _words$value = words.value,
        list = _words$value.list,
        keyword = _words$value.keyword;
      return createVNode("div", {
        "class": "".concat(classPrefix.value, "-select-option__highlight-item")
      }, [list.map(function (item, index) {
        if (!index) return item;
        return [createVNode("b", {
          "class": "".concat(classPrefix.value, "-is-highlight"),
          "key": item + keyword
        }, [keyword]), item];
      })]);
    };
  }
});

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