3 lines
11 KiB
JavaScript
3 lines
11 KiB
JavaScript
import{j as u,M as P,r as M,a as q,b as I,c as z}from"./markdown-vendor-BC7Vi29N.js";import{r as p}from"./syntax-highlight-CQw1bBY6.js";import{A as H,C as _,c as h,F as T,a as k,i as j,b as $,E as B,d as v,f as U}from"./index-Ds4APFvF.js";import"./katex-BSBacQyE.js";const x=92,w=36,O=40,V=41,G=91,K=93,R=32,W=94,Q=95,Z=61,J=43,X=47,Y=60,ee=62,te=123,ne=125,re=124,ae={flow:{[x]:{tokenize:me,concrete:!0,name:"texMathFlow"}},text:{[x]:{tokenize:ce,name:"texMathText"},[w]:{tokenize:ue,name:"guardedDollarMathText"}}},ie=function(){const t=this.data();(t.micromarkExtensions||(t.micromarkExtensions=[])).push(ae)};function f(e){return e===-5||e===-4||e===-3}function oe(e){return e!==null&&e>=48&&e<=57}function se(e){return e===null||e===w||e===R||f(e)}function le(e){return e===x||e===W||e===Q||e===Z||e===J||e===X||e===Y||e===ee||e===te||e===ne||e===re}const F={tokenize:pe,partial:!0};function ue(e,t,r){let a=!1,o=!1,n=null,i=null;return c;function c(m){return e.enter("mathText"),e.enter("mathTextSequence"),e.consume(m),l}function l(m){return se(m)?r(m):(e.exit("mathTextSequence"),e.enter("mathTextData"),s(m))}function s(m){return m===null||f(m)?(e.exit("mathTextData"),r(m)):m===w?(e.exit("mathTextData"),e.enter("mathTextSequence"),e.consume(m),e.exit("mathTextSequence"),e.exit("mathText"),g):(b(m),m===x?d:s)}function d(m){return m===null||f(m)?(e.exit("mathTextData"),r(m)):(b(m),s)}function g(m){return!o||i===R||oe(n)&&!a?r(m):t(m)}function b(m){n??(n=m),o=!0,a||(a=le(m)),i=m,e.consume(m)}}function ce(e,t,r){let a;return o;function o(l){return e.enter("mathText"),e.enter("mathTextSequence"),e.consume(l),n}function n(l){return l!==O?r(l):(e.consume(l),e.exit("mathTextSequence"),e.enter("mathTextData"),i)}function i(l){return l===null?(e.exit("mathTextData"),r(l)):l===x?(e.exit("mathTextData"),a=e.enter("mathTextSequence"),e.consume(l),c):(e.consume(l),i)}function c(l){return l===V?(e.consume(l),e.exit("mathTextSequence"),e.exit("mathText"),t):(a&&(a.type="mathTextData"),i(l))}}function me(e,t,r){return a;function a(s){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(s),o}function o(s){return s!==G?r(s):(e.consume(s),e.exit("mathFlowFenceSequence"),e.exit("mathFlowFence"),n)}function n(s){return s===null?r(s):f(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n):s===x?e.attempt(F,l,c)(s):(e.enter("mathFlowValue"),i(s))}function i(s){return s===null?(e.exit("mathFlowValue"),r(s)):f(s)?(e.exit("mathFlowValue"),e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n):s===x?(e.exit("mathFlowValue"),e.attempt(F,l,c)(s)):(e.consume(s),i)}function c(s){return e.enter("mathFlowValue"),e.consume(s),i}function l(s){return e.exit("mathFlow"),t(s)}}function pe(e,t,r){return a;function a(n){return e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(n),o}function o(n){return n!==K?r(n):(e.consume(n),e.exit("mathFlowFenceSequence"),e.exit("mathFlowFence"),t)}}const he=new Set(["mark","sub","sup"]);function S(e){var n;const t=((n=e.split(/[?#]/,1)[0])==null?void 0:n.trim())??"",r=t.lastIndexOf("/"),a=r>=0?t.slice(r+1):t,o=a.lastIndexOf(".");return o>0?a.slice(o).toLowerCase():""}function xe(e,t){const r=$({url:e,name:t});return r!=="file"?r:S(t)||S(e)?"file":"image"}function de(e,t){return{type:`nanobotSafeHtml${e}`,data:{hName:e},children:t}}function ge(e){return{type:"text",value:e}}function E(e){if(e.type!=="html"||typeof e.value!="string")return null;const t=/^<\s*(\/?)\s*(mark|sub|sup)\s*>$/i.exec(e.value.trim());return t?{tag:t[2].toLowerCase(),closing:t[1]==="/"}:null}function y(e){const t=[];for(let r=0;r<e.length;r+=1){const a=e[r];a.children&&(a.children=y(a.children));const o=E(a);if(!o||o.closing||!he.has(o.tag)){t.push(a);continue}let n=-1;for(let i=r+1;i<e.length;i+=1){const c=E(e[i]);if(c!=null&&c.closing&&c.tag===o.tag){n=i;break}}if(n===-1){t.push(a);continue}t.push(de(o.tag,y(e.slice(r+1,n)))),r=n}return t}function fe(e){if(e.type!=="html"||typeof e.value!="string")return null;const t=e.value.trim(),r=/^<\s*details\s*>\s*<\s*summary\s*>([\s\S]*?)<\s*\/\s*summary\s*>$/i.exec(t);return r?{summary:r[1].trim()}:/^<\s*details\s*>$/i.test(t)?{summary:"Details"}:null}function be(e){return e.type==="html"&&typeof e.value=="string"&&/^<\s*\/\s*details\s*>$/i.test(e.value.trim())}function A(e){const t=[];for(let r=0;r<e.length;r+=1){const a=e[r],o=fe(a);if(!o){t.push(a);continue}const n=e.findIndex((c,l)=>l>r&&be(c));if(n===-1){t.push(a);continue}const i=y(A(e.slice(r+1,n)));t.push({type:"nanobotSafeHtmlDetails",data:{hName:"details"},children:[{type:"nanobotSafeHtmlSummary",data:{hName:"summary"},children:[ge(o.summary)]},...i]}),r=n}return t}function ye(){return e=>{e.children&&(e.children=y(A(e.children)))}}const ke=[q,I,[z,{singleDollarTextMath:!1}],ie,ye],we=[M];function C(e){return p.Children.toArray(e).map(t=>typeof t=="string"||typeof t=="number"?String(t):"").join("")}function L(e){var r,a;let t=e.trim();if(!t)return"";try{/^file:\/\//i.test(t)?t=decodeURIComponent(new URL(t).pathname):t=decodeURIComponent(t)}catch{}return t=((a=(r=t.split("?",1)[0])==null?void 0:r.split("#",1)[0])==null?void 0:a.trim())??"",/^[A-Za-z]:[\\/]/.test(t)||(t=t.replace(/:\d+(?::\d+)?$/,"")),t}function Te(e){return v(e)?!1:j(e)?!0:/^[a-z][a-z0-9+.-]*:\/\//i.test(e)||/[\\/]/.test(e)?!1:/^[^?#]+\.[a-z0-9][a-z0-9_-]{0,12}$/i.test(e)}function Fe(e){if(!e||/^https?:\/\//i.test(e)||e.startsWith("#"))return!1;const t=L(e);return!!(t&&v(t))}function Se(e){if(!e||/^https?:\/\//i.test(e)||e.startsWith("#"))return null;const t=L(e);return Te(t)?t:null}function D(e){let t="",r;for(const a of p.Children.toArray(e)){if(typeof a=="string"||typeof a=="number"){t+=String(a);continue}if(!p.isValidElement(a))continue;const o=a.props;!r&&typeof o.href=="string"&&/^https?:\/\//i.test(o.href)&&(r=o.href);const n=D(o.children);t+=n.text,r||(r=n.href)}return{text:t,href:r}}function N(e){return e.replace(/\s+/g," ").replace(/^[\s"'“”‘’]+|[\s"'“”‘’]+$/g,"").trim()}function Ee(e){const{text:t,href:r}=D(e);if(!r)return null;let a;try{a=new URL(r)}catch{return null}if(a.protocol!=="http:"&&a.protocol!=="https:")return null;const o=t.replace(/\s+/g," ").replace(r,"").replace(a.toString(),"").replace(/https?:\/\/\S+/i,"").trim();if(!o||o.length<4)return null;const n=/^(.*?)\s*(?:[—–]| - |:)\s*(.+)$/.exec(o),i=n!=null&&n[1]?N(n[1]):void 0,c=N((n==null?void 0:n[2])??o);return!c||/^https?:\/\//i.test(c)?null:{href:r,host:a.hostname,prefix:i,title:c}}function Ne({link:e}){const{favicon:t,onFaviconError:r}=je(e.host),a=e.prefix?`${e.prefix} — ${e.title}`:e.title;return u.jsxs("a",{href:e.href,target:"_blank",rel:"noreferrer noopener","aria-label":`Open link: ${a}`,className:h("not-prose inline-flex max-w-full items-center gap-2 align-baseline","text-blue-500 no-underline underline-offset-2 hover:underline dark:text-blue-300"),children:[u.jsx("span",{className:h("relative grid h-4 w-4 shrink-0 place-items-center overflow-hidden rounded-[4px]","border border-border/65 bg-background text-muted-foreground"),"aria-hidden":!0,children:t?u.jsx("img",{src:t,alt:"",className:"h-3 w-3 rounded-[2px] object-contain",loading:"lazy",onError:r}):u.jsx(B,{className:"h-3 w-3"})}),u.jsx("span",{className:"min-w-0 truncate leading-normal",children:a})]})}function je(e){const t=p.useMemo(()=>U(e),[e]),[r,a]=p.useState(0);p.useEffect(()=>{a(0)},[e]);const o=p.useCallback(()=>{a(n=>Math.min(n+1,t.length))},[t.length]);return{favicon:t[r]??null,onFaviconError:o}}function ve(e){if(!p.isValidElement(e))return!1;const t=e.props;return e.type===k||typeof t.code=="string"}function Re(e){var o;if(!p.isValidElement(e))return null;const t=e.props;if(!("children"in t))return null;const r=typeof t.className=="string"?t.className:"",a=(o=/language-([^\s]+)/.exec(r))==null?void 0:o[1];return{code:C(t.children).replace(/\n$/,""),language:a}}function Pe({children:e,className:t,highlightCode:r=!0,onOpenFilePreview:a}){const o=p.useMemo(()=>({code({className:n,children:i,...c}){const l=/language-(\w+)/.exec(n||"");if(l){const g=String(i).replace(/\n$/,"");return u.jsx(k,{language:l[1],code:g,className:"my-3",highlight:r})}const s=String(i).replace(/\n$/,"");return j(s)?u.jsx(T,{path:s,onOpen:a}):s.includes(`
|
|
`)||s.length>120?u.jsx("code",{className:h("block min-w-0 whitespace-pre bg-transparent p-0 font-mono text-[0.8125rem]","leading-snug text-inherit",n),...c,children:i}):u.jsx("code",{className:h("rounded bg-muted px-1 py-0.5 font-mono text-[0.85em]",n),...c,children:i})},pre({children:n}){const i=p.Children.toArray(n),c=i.length===1?i[0]:null;if(ve(c))return u.jsx(u.Fragment,{children:n});const l=Re(c);return l?u.jsx(k,{language:l.language||"text",code:l.code,className:"my-3",highlight:r}):u.jsx("pre",{className:h("my-3 overflow-x-auto rounded-lg border border-border/60 bg-muted/35","p-3 font-mono text-[0.8125rem] leading-snug text-foreground/90","whitespace-pre [overflow-wrap:normal]"),children:n})},a({href:n,children:i,...c}){const l=Se(n);if(l){const s=C(i).trim();return u.jsx(T,{path:s||l,tooltipPath:l,previewPath:l,onOpen:a})}return Fe(n)?u.jsx(u.Fragment,{children:i}):u.jsx("a",{href:n,target:"_blank",rel:"noreferrer noopener",className:"text-blue-500 underline underline-offset-2 hover:text-blue-600 dark:text-blue-300 dark:hover:text-blue-200",...c,children:i})},li({children:n,className:i}){const c=Ee(n);return c?u.jsx("li",{className:h("list-none pl-0",i),children:u.jsx(Ne,{link:c})}):u.jsx("li",{className:i,children:n})},input({type:n,checked:i}){return n!=="checkbox"?null:u.jsx("span",{"aria-hidden":!0,"data-testid":"markdown-task-checkbox",className:h("mr-2 inline-grid h-4 w-4 translate-y-[2px] place-items-center rounded-[4px]","border border-border/70 bg-muted/55 text-background",i&&"border-foreground/55 bg-foreground/65"),children:i?u.jsx(_,{className:"h-3 w-3 stroke-[3]"}):null})},mark({children:n}){return u.jsx("mark",{className:"rounded-[5px] bg-yellow-200/75 px-1 py-0.5 text-inherit dark:bg-yellow-300/25",children:n})},sub({children:n}){return u.jsx("sub",{className:"text-[0.72em] leading-none",children:n})},sup({children:n}){return u.jsx("sup",{className:"text-[0.72em] leading-none",children:n})},details({children:n}){return u.jsx("details",{className:"my-3 rounded-xl border border-border/65 bg-muted/25 px-4 py-3 open:pb-4",children:n})},summary({children:n}){return u.jsx("summary",{className:"cursor-pointer select-none text-sm font-medium text-foreground/88 marker:text-muted-foreground",children:n})},img({src:n,alt:i,node:c,className:l,...s}){const d=typeof n=="string"?n:"";if(!d)return null;const g=typeof i=="string"?i:"",b=xe(d,g);return u.jsx(H,{attachment:{kind:b,url:d,name:g},inline:!0})}}),[r,a]);return u.jsx("div",{className:h("markdown-content prose max-w-none dark:prose-invert","prose-headings:mt-4 prose-headings:mb-2 prose-headings:font-semibold prose-headings:tracking-tight","prose-h1:text-lg prose-h2:text-base prose-h3:text-sm prose-h4:text-[13px]","prose-p:my-2","prose-ul:my-2 prose-ol:my-2 prose-li:my-0.5","prose-blockquote:my-3 prose-blockquote:border-l-2 prose-blockquote:font-normal","prose-blockquote:not-italic prose-blockquote:text-foreground/80","prose-a:text-blue-500 prose-a:underline-offset-2 hover:prose-a:text-blue-600 dark:prose-a:text-blue-300 dark:hover:prose-a:text-blue-200","prose-hr:my-6","prose-pre:my-0 prose-pre:bg-transparent prose-pre:p-0","prose-code:before:content-none prose-code:after:content-none prose-code:font-normal","prose-table:my-3 prose-th:text-left prose-th:font-medium",t),style:{lineHeight:"var(--cjk-line-height)"},children:u.jsx(P,{remarkPlugins:ke,rehypePlugins:we,components:o,children:e})})}export{Pe as default};
|