// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later
// @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c
import{r as e}from"./lib-DhF-PQbN.js";var t=/https?:\/\//i,n=/[\s([{\u2018\u201c\u2013\u2014]/;function r(e){return e.replace(/---/g,`—`).replace(/--/g,`–`)}function i(e){return e.replace(/\.\.\./g,`…`).replace(/\. \. \./g,`…`)}function a(e){let t=``;for(let r=0;r<e.length;r++){let i=e[r];if(i!==`"`){t+=i;continue}let a=r>0?e[r-1]:``,o=a===``||n.test(a);t+=o?`“`:`”`}return t}function o(e){let t=``;for(let r=0;r<e.length;r++){let i=e[r];if(i!==`'`){t+=i;continue}let a=r>0?e[r-1]:``,o=r<e.length-1?e[r+1]:``;if(/[A-Za-z0-9]/.test(a)){t+=`’`;continue}if((a===``||n.test(a))&&/[A-Za-z0-9]/.test(o)){/[0-9]/.test(o)||/^(tis|twas|cause|em|n|round|bout)\b/i.test(e.slice(r+1))?t+=`’`:t+=`‘`;continue}t+=`’`}return t}function s(){return n=>{e(n,`text`,(e,n,s)=>{if(s&&s.type===`link`||t.test(e.value))return;let c=e.value;c=i(c),c=r(c),c=a(c),c=o(c),e.value=c})}}export{s as t};
// @license-end
