import{t as e}from"./jsx-runtime-CutOxEx1.js";var t=e(),n=e=>e.split(/(\*\*.*?\*\*|\*.*?\*|`[^`]+`)/g).map((e,n)=>e.startsWith(`**`)&&e.endsWith(`**`)?(0,t.jsx)(`strong`,{className:`ed-bold`,children:e.slice(2,-2)},n):e.startsWith(`*`)&&e.endsWith(`*`)?(0,t.jsx)(`em`,{className:`ed-em`,children:e.slice(1,-1)},n):e.startsWith("`")&&e.endsWith("`")?(0,t.jsx)(`code`,{className:`ed-code`,children:e.slice(1,-1)},n):(0,t.jsx)(`span`,{children:e},n)),r=e=>e.startsWith(`|`)&&e.endsWith(`|`)&&e.includes(`|`),i=e=>/^[-*_]{3,}\s*$/.test(e.trim()),a=e=>/^#{1,4}\s+/.test(e.trim()),o=e=>{let t=e.split(`
`).filter(e=>e.trim());return t.length<2?!1:t.every(e=>r(e.trim()))};function s(e,r){let o=e.trim();return i(o)?(0,t.jsx)(`hr`,{className:`ed-divider`},r):a(o)?(0,t.jsx)(`p`,{className:`ed-paragraph`,children:(0,t.jsx)(`strong`,{className:`ed-bold`,children:n(o.replace(/^#+\s+/,``))})},r):/^[-*•]\s/.test(o)?(0,t.jsxs)(`div`,{className:`ed-list-item`,children:[(0,t.jsx)(`span`,{className:`ed-bullet`}),(0,t.jsx)(`span`,{children:n(o.replace(/^[-*•]\s+/,``))})]},r):/^\d+[.)]\s/.test(o)?(0,t.jsxs)(`div`,{className:`ed-numbered-item`,children:[(0,t.jsx)(`span`,{className:`ed-number`,children:o.match(/^(\d+)[.)]\s/)?.[1]||`${r+1}`}),(0,t.jsx)(`span`,{children:n(o.replace(/^\d+[.)]\s+/,``))})]},r):(0,t.jsx)(`span`,{children:n(e)},r)}var c=e=>{let t=e.split(`
`),n=[],o=[],s=!1,c=()=>{if(!o.length)return;let e=o.join(`
`).trim();e&&n.push(e),o=[]};for(let e=0;e<t.length;e++){let l=t[e],u=l.trim();if(r(u)){s||=(c(),!0),o.push(l);continue}if(s&&=(c(),!1),i(u)){c(),n.push(u);continue}if(a(u)){c(),o.push(l);continue}if(!u){c();continue}o.push(l)}return c(),n};function l({text:e,className:n}){let r=String(e||``).trim();if(!r)return null;let i=c(r);return(0,t.jsx)(`article`,{className:`editorial-md ${n||``}`,children:i.map((e,n)=>{let r=e.split(`
`).map(e=>e.trim()).filter(Boolean),i=r[0]||``;if(o(e)){let t=h(e,n);if(t)return t}if(i.startsWith(`> `))return d(r,n);let a=i.match(/^(#{1,4})\s+(.*)$/);if(a)return u(a[1].length,a[2],r.slice(1),n);if(i.startsWith(`---`)&&i.replace(/-/g,``).trim()===``)return(0,t.jsx)(`hr`,{className:`ed-divider`},n);if(r.filter(e=>/^[-*•]\s/.test(e)).length>=Math.max(2,r.length-1))return f(r,n);if(r.filter(e=>/^\d+[.)]\s/.test(e)).length>=Math.max(2,r.length-1))return p(r,n);let c=i.match(/^([^：:]{1,20})[：:]\s*(.*)$/);return c&&r.length<=3?m(c[1],[c[2],...r.slice(1)].filter(Boolean).join(` `),n):(0,t.jsx)(`p`,{className:`ed-paragraph`,children:r.map((e,n)=>(0,t.jsxs)(`span`,{children:[s(e,n),n<r.length-1&&(0,t.jsx)(`br`,{})]},n))},n)})})}function u(e,r,i,a){let o=`h${e}`;return(0,t.jsxs)(`section`,{className:`ed-section ed-section-${e}`,children:[(0,t.jsx)(o,{className:`ed-heading ed-h${e}`,children:n(r)}),i.length>0&&(0,t.jsx)(`div`,{className:`ed-section-body`,children:i.map((e,r)=>/^[-*•]\s/.test(e)?(0,t.jsxs)(`div`,{className:`ed-list-item`,children:[(0,t.jsx)(`span`,{className:`ed-bullet`}),(0,t.jsx)(`span`,{children:n(e.replace(/^[-*•]\s+/,``))})]},r):(0,t.jsx)(`p`,{className:`ed-paragraph`,children:n(e)},r))})]},a)}function d(e,r){return(0,t.jsx)(`blockquote`,{className:`ed-blockquote`,children:n(e.map(e=>e.replace(/^>\s?/,``)).join(`
`))},r)}function f(e,r){let i=/^[-*•]\s/.test(e[0])?``:e[0],a=i?e.slice(1):e;return(0,t.jsxs)(`div`,{className:`ed-list-block`,children:[i&&(0,t.jsx)(`div`,{className:`ed-list-head`,children:n(i)}),(0,t.jsx)(`ul`,{className:`ed-list`,children:a.map((e,r)=>(0,t.jsxs)(`li`,{className:`ed-list-item`,children:[(0,t.jsx)(`span`,{className:`ed-bullet`}),(0,t.jsx)(`span`,{children:n(e.replace(/^[-*•]\s+/,``))})]},r))})]},r)}function p(e,r){let i=/^\d+[.)]\s/.test(e[0])?``:e[0],a=i?e.slice(1):e;return(0,t.jsxs)(`div`,{className:`ed-list-block`,children:[i&&(0,t.jsx)(`div`,{className:`ed-list-head`,children:n(i)}),(0,t.jsx)(`ol`,{className:`ed-numbered-list`,children:a.map((e,r)=>(0,t.jsxs)(`li`,{className:`ed-numbered-item`,children:[(0,t.jsx)(`span`,{className:`ed-number`,children:r+1}),(0,t.jsx)(`span`,{children:n(e.replace(/^\d+[.)]\s+/,``))})]},r))})]},r)}function m(e,r,i){return(0,t.jsxs)(`div`,{className:`ed-label-value`,children:[(0,t.jsx)(`dt`,{className:`ed-label`,children:n(e)}),(0,t.jsx)(`dd`,{className:`ed-value`,children:n(r)})]},i)}function h(e,r){let i=e.split(`
`).map(e=>e.trim()).filter(Boolean).map(e=>e.split(`|`).filter((e,t,n)=>t>0&&t<n.length-1).map(e=>e.trim()));if(i.length<2)return null;let a=i.findIndex(e=>e.every(e=>/^[\s:|-]+$/.test(e)&&e.replace(/[\s:|-]/g,``)===``)),o=a>0&&i.slice(0,a).flat().length?i[a-1]:i[0],s=a>=0?i.slice(a+1):i.slice(1);return s.length?(0,t.jsx)(`div`,{className:`ed-table-wrap`,children:(0,t.jsxs)(`table`,{className:`ed-table`,children:[(0,t.jsx)(`thead`,{children:(0,t.jsx)(`tr`,{children:o.map((e,r)=>(0,t.jsx)(`th`,{children:n(e)},r))})}),(0,t.jsx)(`tbody`,{children:s.map((e,r)=>(0,t.jsx)(`tr`,{children:e.map((e,r)=>(0,t.jsx)(`td`,{children:n(e)},r))},r))})]})},r):null}export{l as t};