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

'use strict';

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

var vue = require('vue');
var isString = require('lodash/isString');
var hooks_useConfig = require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('lodash/cloneDeep');
require('lodash/isFunction');
require('../config-provider/context.js');
require('lodash/mergeWith');
require('lodash/merge');
require('lodash/isArray');
require('../_common/js/global-config/default-config.js');
require('../_common/js/global-config/locale/zh_CN.js');
require('@babel/runtime/helpers/typeof');
require('../_chunks/dep-f4db2590.js');
require('dayjs');

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

var isString__default = /*#__PURE__*/_interopDefaultLegacy(isString);

var _HighlightOption = vue.defineComponent({
  name: "THighlightOption",
  props: {
    content: String,
    keyword: String
  },
  setup: function setup(props) {
    var classPrefix = hooks_useConfig.usePrefixClass();
    var words = vue.computed(function () {
      var _content$match;
      var content = props.content,
        keyword = props.keyword;
      if (!content) return {
        list: []
      };
      if (!isString__default["default"](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 vue.createVNode("div", {
        "class": "".concat(classPrefix.value, "-select-option__highlight-item")
      }, [list.map(function (item, index) {
        if (!index) return item;
        return [vue.createVNode("b", {
          "class": "".concat(classPrefix.value, "-is-highlight"),
          "key": item + keyword
        }, [keyword]), item];
      })]);
    };
  }
});

exports["default"] = _HighlightOption;
//# sourceMappingURL=highlight-option.js.map
