import"./chunk-Bj-mKKzh.js";import{t as e}from"./react-CClhXMB2.js";import{t}from"./jsx-runtime-CyI9ICYU.js";import{S as n,a as r,i,n as a,o,r as s,t as c}from"./lib--QVjyxmL.js";var l=t();e();var u=[],d={allowDangerousHtml:!0},f=/^(https?|ircs?|mailto|xmpp)$/i,p=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function m(e){let t=h(e),n=g(e);return _(t.runSync(t.parse(n),n),e)}function h(e){let t=e.rehypePlugins||u,n=e.remarkPlugins||u,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...d}:d;return c().use(i).use(n).use(s,r).use(t)}function g(e){let t=e.children||``,n=new a;return typeof t==`string`?n.value=t:``+t,n}function _(e,t){let i=t.allowedElements,a=t.allowElement,s=t.components,c=t.disallowedElements,u=t.skipHtml,d=t.unwrapDisallowed,f=t.urlTransform||v;for(let e of p)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return n(e,m),o(e,{Fragment:l.Fragment,components:s,ignoreInvalidStyle:!0,jsx:l.jsx,jsxs:l.jsxs,passKeys:!0,passNode:!0});function m(e,t,n){if(e.type===`raw`&&n&&typeof t==`number`)return u?n.children.splice(t,1):n.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in r)if(Object.hasOwn(r,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],i=r[t];(i===null||i.includes(e.tagName))&&(e.properties[t]=f(String(n||``),t,e))}}if(e.type===`element`){let r=i?!i.includes(e.tagName):c?c.includes(e.tagName):!1;if(!r&&a&&typeof t==`number`&&(r=!a(e,t,n)),r&&n&&typeof t==`number`)return d&&e.children?n.children.splice(t,1,...e.children):n.children.splice(t,1),t}}}function v(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||f.test(e.slice(0,t))?e:``}export{m as t};