"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue");require("../config-provider/index.js");const k=require("./style/index.js"),g=require("../config-provider/hooks/use-namespace.js"),m={key:1},y=e.defineComponent({name:"Highlight",__name:"index",props:{content:{},keywords:{},ignoreCase:{type:Boolean}},setup(a){const o=a,{b:c,e:i}=g.useNamespace("highlight"),u=k.default("highlight"),s=e.computed(()=>{const t=o.keywords;if(!t)return null;let n=Array.isArray(t)?t:[t];return n=n.sort((r,l)=>l.length-r.length),new RegExp(`(${n.join("|")})`,`${o.ignoreCase?"i":""}g`)}),d=e.computed(()=>{const t=o.content;return!s.value||!t?[{keywords:!1,text:t}]:t.split(s.value).map(n=>({keywords:s.value.test(n),text:n}))});return(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass([e.unref(c)(),e.unref(u)])},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,({text:r,keywords:l},p)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:p},[l?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(e.unref(i)("keywords"))},[e.renderSlot(t.$slots,"keywords",{text:r},()=>[e.createTextVNode(e.toDisplayString(r),1)])],2)):(e.openBlock(),e.createElementBlock("span",m,[e.renderSlot(t.$slots,"default",{text:r},()=>[e.createTextVNode(e.toDisplayString(r),1)])]))],64))),128))],2))}});exports.default=y;
