UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 1.23 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Cc as t,wc as n}from"./_4____________________________.js";import{ki as r}from"./deferred-ui-support-DZEPWjAk.js";import{v as i,y as a}from"./markdown-runtime-CtlJb8xA.js";function o(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.querySelectorAll(`script, style, template`).forEach(e=>e.remove()),t.content.querySelectorAll(`p, div, br, hr, li, tr, h1, h2, h3, h4, h5, h6, blockquote, pre`).forEach(e=>e.after(document.createTextNode(` `))),t.content.textContent??``}function s(e){return o(e.map(e=>e.type===`text`||e.type===`code_inline`?r(e.content):e.type===`html_inline`?e.content:e.type===`image`?r(s(e.children??[])):e.type===`softbreak`||e.type===`hardbreak`?` `:``).join(``))}function c(e,t=!0){return e.map(e=>{if(e.type===`inline`)return s(e.children??[]);if(e.type===`code_block`||e.type===`fence`)return e.content;if(e.type===`html_block`){let n=o(e.content);return t?c(u.parse(n,{}),!1):n}return``}).filter(Boolean).join(` `)}function l(e){let t=c(u.parse(e,{})).replace(/\s+/gu,` `).trim(),r=n(t,30);return r.length<t.length?`${r}…`:r}var u;function d(){return(d=e((()=>{a(),t(),u=i()})))()}d();export{l as derivePastedTextExcerpt};