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

'use strict';

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

var VueCompositionAPI = require('@vue/composition-api');
var hooks_useConfig = require('../hooks/useConfig.js');
require('../config-provider/useConfig.js');
require('../config-provider/context.js');
require('lodash/merge');
require('lodash/mergeWith');
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-7c884501.js');
require('dayjs');

var _HighlightOption = VueCompositionAPI.defineComponent({
  name: "HighlightOption",
  props: {
    content: String,
    keyword: String
  },
  setup: function setup(props) {
    var classPrefix = hooks_useConfig.usePrefixClass();
    var words = VueCompositionAPI.computed(function () {
      var _content$match;
      var content = props.content,
        keyword = props.keyword;
      if (!content) return {
        list: []
      };
      if (typeof content !== "string" || !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 {
      words: words,
      classPrefix: classPrefix
    };
  },
  render: function render() {
    var _this = this;
    var h = arguments[0];
    var _this$words = this.words,
      list = _this$words.list,
      keyword = _this$words.keyword;
    return h("div", {
      "class": "".concat(this.classPrefix, "-select-option__highlight-item")
    }, [list.map(function (item, index) {
      if (!index) return item;
      return [h("b", {
        "class": "".concat(_this.classPrefix, "-is-highlight"),
        "key": item + keyword
      }, [keyword]), item];
    })]);
  }
});

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