import{A as x}from"./vc-shell-vendor-cheerio88029.js";const y=/\ud83c[\udffb-\udfff](?=\ud83c[\udffb-\udfff])|(?:[^\ud800-\udfff][\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]?|[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff]|[\ud800-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe23\u20d0-\u20f0]|\ud83c[\udffb-\udfff])?)*/g,h={stripTags:!1,ellipsis:"...",decodeEntities:!1,byWords:!1,excludes:"",customNodeStrategy:e=>e,reserveLastWord:!1,trimTheOnlyWord:!1,keepWhitespaces:!1};let v=h;function j(e,t,r){const u=k(t,r);if(!e||isNaN(u.length)||u.length<1||u.length===1/0)return b(e)?e.html()||"":e;let n;b(e)?n=e:n=x.load(`${e}`,{decodeEntities:u.decodeEntities},!1);const o=n.root();if(u.excludes&&o.find(u.excludes).remove(),u.stripTags)return p(o.text(),u);const s=function(d,f=!0){const i=d.contents(),l=i.length-1;return i.each(function(m){const g=this.type,c=n(this);if(g==="text"){if(!u.limit){c.remove();return}this.data=p(c.text(),u,f&&m===l);return}if(g==="tag"){if(!u.limit){c.remove();return}const a=u.customNodeStrategy(c);if(a==="remove"){c.remove();return}if(a==="keep")return;s(a||c,f&&m===l);return}c.remove()})};return s(o),o.html()||""}j.setup=function(e){v=W(e,h)};function p(e,t,r){t.keepWhitespaces||(e=e.replace(/\s+/g," "));const u=t.byWords,n=e.match(y);if(!n)return"";const o=n.length;let s=0,d=0,f=u,i=!1;for(;s<o;)if(i=T(n[s++]),!(u&&f===i)){if(d===t.limit){if(f&&i){f=i;continue}--s;break}u?i||++d:i&&f||++d,f=i}if(t.limit-=d,t.limit)return e;const l=u?n.slice(0,s).join(""):L(n,s,t);return l===e?r?e:e+t.ellipsis:l+t.ellipsis}function L(e,t,r){const u=e.slice(0,t).join("");if(!r.reserveLastWord||e.length===t)return u;const n=e.slice(t-1,t+1).join("");if(/\W/.test(n))return u;if(typeof r.reserveLastWord=="number"&&r.reserveLastWord<0){const f=u.replace(/\w+$/,"");if(!(f.length===0&&u.length===r.length))return f;if(r.trimTheOnlyWord)return u}const o=r.reserveLastWord!==!0&&r.reserveLastWord>0?r.reserveLastWord:10,s=e.slice(t).join("").match(/(\w+)/),d=s?s[1]:"";return u+d.substring(0,o)}function k(e,t){switch(typeof e){case"object":t=e;break;case"number":typeof t=="object"?t.length=e:t={length:e}}t&&t.excludes&&(Array.isArray(t.excludes)||(t.excludes=[t.excludes]),t.excludes=t.excludes.join(","));const r=W(Object.assign({},v,t),h);return r.limit=r.length,r}function T(e){return e===" "||e==="\f"||e===`
`||e==="\r"||e==="	"||e==="\v"||e===" "||e==="\u2028"||e==="\u2029"}function W(e,t){e==null&&(e={});for(const r in t){const u=t[r];e[r]==null&&(e[r]=u)}return e}function b(e){return e&&e.contains&&e.html&&e.parseHTML&&!0}export{j};
