md2x 0.7.0 → 0.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -4
- package/dist/chunks/{chunk-XTD75532.js → chunk-A4XDJ35P.js} +241 -42
- package/dist/index.js +1 -1
- package/dist/md2x.js +1 -1
- package/dist/renderer/puppeteer-render-worker.js +56 -56
- package/dist/templates/svelte/example.svelte +18 -0
- package/dist/types/node/src/host/node-exporter.d.ts +11 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{c as It}from"./chunk-EFKQH5UR.js";import*as ne from"fs";import*as F from"path";import{createRequire as un}from"module";import{fileURLToPath as He,pathToFileURL as we}from"url";import*as X from"fs";import*as
|
|
2
|
-
Run \`npm run node\` to build the CLI (it generates node/dist/renderer/*).`);r=a();let
|
|
1
|
+
import{c as It}from"./chunk-EFKQH5UR.js";import*as ne from"fs";import*as F from"path";import{createRequire as un}from"module";import{fileURLToPath as He,pathToFileURL as we}from"url";import*as X from"fs";import*as Dt from"os";import*as V from"path";import{fileURLToPath as rn,pathToFileURL as Ze}from"url";function nn(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:V.dirname(rn(import.meta.url))}var gt=null;function Rt(e){if(typeof e=="string"){let t=e.trim();return t||null}if(Array.isArray(e)){let t=e.filter(r=>typeof r=="string").map(r=>r.trim()).filter(Boolean);return t.length?t.join(", "):null}return null}function on(){let e=nn();return V.join(e,"renderer","puppeteer-render.html")}function an(e){switch(e){case"Letter":return{widthIn:8.5,heightIn:11};case"Legal":return{widthIn:8.5,heightIn:14};case"A3":return{widthIn:11.69,heightIn:16.54};case"A5":return{widthIn:5.83,heightIn:8.27};case"A4":default:return{widthIn:8.27,heightIn:11.69}}}function ln(e){switch(e){case"A3":return{top:"25mm",bottom:"25mm",left:"20mm",right:"20mm"};case"A5":return{top:"15mm",bottom:"15mm",left:"12mm",right:"12mm"};case"Legal":return{top:"25mm",bottom:"25mm",left:"20mm",right:"20mm"};case"Letter":case"A4":default:return{top:"20mm",bottom:"20mm",left:"15mm",right:"15mm"}}}function et(e){if(typeof e=="number")return e/96;let t=String(e??"").trim();if(!t)return null;let r=t.match(/^(-?\d+(?:\.\d+)?)(px|in|mm|cm)$/i);if(!r)return null;let i=parseFloat(r[1]);if(!Number.isFinite(i))return null;let n=r[2].toLowerCase();return n==="in"?i:n==="cm"?i/2.54:n==="mm"?i/25.4:n==="px"?i/96:null}async function Pe(){try{gt=await import("puppeteer")}catch{return console.warn("Puppeteer dependency not found. Diagrams/HTML/SVG will be skipped."),console.warn("If you are using the published CLI, run via `npx md2x ...` (it installs Puppeteer automatically)."),console.warn("If you are running from this repo, install CLI deps first: `npm -C node i` (or `pnpm -C node i`)."),null}let e=null,t=null,r=null,i=[],n=c=>{i.push(c),i.length>60&&i.shift()},a=()=>{let c=[V.join(process.cwd(),".md2x-"),V.join(Dt.tmpdir(),"md2x-")];for(let m of c)try{return X.mkdirSync(V.dirname(m),{recursive:!0}),X.mkdtempSync(m)}catch{}throw new Error("Unable to create a writable temp directory for Chromium runtime files")},o=async c=>{if(!t||!c)return;let m=Ze(c+V.sep).href;await t.evaluate(s=>{let u=window;if(typeof u.__md2xSetBaseHref=="function"){u.__md2xSetBaseHref(s);return}let f=document.querySelector("base");f||(f=document.createElement("base"),document.head.appendChild(f)),f.href=s},m)};return{async initialize(){if(!gt)return;let c=on();if(!X.existsSync(c))throw new Error(`Missing renderer assets: ${c}
|
|
2
|
+
Run \`npm run node\` to build the CLI (it generates node/dist/renderer/*).`);r=a();let m=V.join(r,"chrome-profile");X.mkdirSync(m,{recursive:!0}),e=await gt.launch({headless:!0,userDataDir:m,env:{...process.env,HOME:r,XDG_CACHE_HOME:V.join(r,"xdg-cache"),XDG_CONFIG_HOME:V.join(r,"xdg-config"),XDG_DATA_HOME:V.join(r,"xdg-data")},args:["--no-sandbox","--disable-setuid-sandbox","--disable-web-security","--allow-file-access-from-files","--disable-crashpad","--no-crashpad",`--crash-dumps-dir=${V.join(r,"crashpad")}`,`--user-data-dir=${m}`,"--disable-breakpad","--disable-crash-reporter","--disable-features=Crashpad","--no-first-run","--no-default-browser-check"]}),t=await e.newPage(),t.on("console",s=>{n(`[console.${s.type()}] ${s.text()}`)}),t.on("pageerror",s=>{let u=s instanceof Error?s.message:String(s);n(`[pageerror] ${u}`)}),t.on("requestfailed",s=>{let u=s.failure();n(`[requestfailed] ${s.url()} ${u?.errorText??""}`.trim())}),await t.setViewport({width:2e3,height:2e3}),await t.goto(Ze(c).href,{waitUntil:"domcontentloaded"});try{await t.waitForFunction(()=>window.__md2xRenderReady===!0,{timeout:3e4})}catch(s){let u=`Renderer page did not become ready within 30s.
|
|
3
3
|
Common causes:
|
|
4
4
|
- \`puppeteer-render.html\` has a <base> that breaks relative script loading
|
|
5
5
|
- missing/broken \`node/dist/renderer/puppeteer-render-worker.js\`
|
|
@@ -8,27 +8,27 @@ Common causes:
|
|
|
8
8
|
Last browser logs:
|
|
9
9
|
${i.join(`
|
|
10
10
|
`)}
|
|
11
|
-
`:"",
|
|
12
|
-
Original error: ${
|
|
11
|
+
`:"",d=s instanceof Error?s.message:String(s);throw new Error(`${u}
|
|
12
|
+
Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return await o(s),await t.evaluate(async(d,p,h)=>{let b=window.__md2xRender;if(typeof b!="function")throw new Error("Renderer function not available on page");return await b(d,p,h)},c,m,u??null)}catch(f){let d=f instanceof Error?f.message:String(f);return console.warn(`Failed to render ${c}: ${d}`),null}},async exportToPdf(c,m,s={},u){if(!t)throw new Error("Browser not initialized");let f=await e.newPage(),d=null;try{let h=`<!DOCTYPE html>
|
|
13
13
|
<html>
|
|
14
14
|
<head>
|
|
15
15
|
<meta charset="UTF-8">
|
|
16
16
|
<title>${s.title||"Document"}</title>
|
|
17
|
-
<style>${
|
|
17
|
+
<style>${m}</style>
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
20
20
|
<div id="markdown-content">${c}</div>
|
|
21
21
|
</body>
|
|
22
|
-
</html>`;u?(
|
|
22
|
+
</html>`;u?(d=V.join(u,`__md2x_temp_${Date.now()}.html`),X.writeFileSync(d,h,"utf-8"),await f.goto(Ze(d).href,{waitUntil:"networkidle0"})):await f.setContent(h,{waitUntil:"networkidle0"});try{await f.evaluate(()=>typeof window.__md2xLiveDone<"u")&&await f.waitForFunction(()=>window.__md2xLiveDone===!0,{timeout:6e4})}catch{}try{await f.evaluate(async()=>{let g=document.fonts?.ready;g&&typeof g.then=="function"&&await g;let v=Array.from(document.images||[]);await Promise.all(v.map(M=>M.complete?null:new Promise(j=>{M.addEventListener("load",()=>j(),{once:!0}),M.addEventListener("error",()=>j(),{once:!0})})))})}catch{}let x=s.format||"A4",b=s.landscape||!1,w=s.scale||1,{widthIn:Y,heightIn:S}=an(x),L=b?Y:S,C=ln(x),G=et(s.margin?.top??C.top)??et(C.top),Ce=et(s.margin?.bottom??C.bottom)??et(C.bottom),Me=(L-G-Ce)*96/w;await f.evaluate(g=>{let v=document.getElementById("markdown-content");if(!v)return;let M=window.getComputedStyle(v),j=parseFloat(M.paddingTop||"0")||0,T=parseFloat(M.paddingBottom||"0")||0,k=Math.max(0,g-j-T);v.querySelectorAll(".md2x-diagram img.md2x-diagram, img.md2x-diagram").forEach(P=>{let B=P,_=B.getBoundingClientRect().height||B.naturalHeight||0;_&&(_<=k+.5||(B.style.maxHeight=`${k}px`,B.style.height="auto",B.style.width="auto",B.style.maxWidth="100%",B.style.objectFit="contain"))})},Me),await f.evaluate(()=>{let g=document.getElementById("markdown-content");if(!g)return;let v=g.clientWidth;if(!v)return;g.querySelectorAll(':scope > div[style*="width"]').forEach(j=>{let T=j,k=T.style.width?.match(/^(\d+(?:\.\d+)?)px$/);if(!k)return;let O=parseFloat(k[1]);if(!Number.isFinite(O)||O<=0)return;let P=Math.min(1,v/O);P>=.999||(T.style.transformOrigin="top left",T.style.transform=`scale(${P})`)})});let te={printBackground:s.printBackground!==!1,scale:s.scale||1,displayHeaderFooter:s.displayHeaderFooter||!1,headerTemplate:s.headerTemplate||"",footerTemplate:s.footerTemplate||"",margin:{top:s.margin?.top??C.top,bottom:s.margin?.bottom??C.bottom,left:s.margin?.left??C.left,right:s.margin?.right??C.right}};s.width&&s.height?(te.width=s.width,te.height=s.height):(te.format=s.format||"A4",te.landscape=s.landscape||!1);let Ie=await f.pdf(te);return Buffer.from(Ie)}finally{if(await f.close(),d)try{X.unlinkSync(d)}catch{}}},async exportToImage(c,m,s={},u){let f=await this.exportToImageParts(c,m,{...s,split:!1},u);if(f.length!==1)throw new Error("exportToImage() received multiple image parts. Use exportToImageParts() instead.");return f[0]},async exportToImageParts(c,m,s={},u){if(!t)throw new Error("Browser not initialized");let f=await e.newPage(),d=null;try{let p=s.viewport??{};await f.setViewport({width:Math.max(320,Math.floor(p.width??1200)),height:Math.max(240,Math.floor(p.height??800)),deviceScaleFactor:Math.max(.25,p.deviceScaleFactor??1)});let h=`<!DOCTYPE html>
|
|
23
23
|
<html>
|
|
24
24
|
<head>
|
|
25
25
|
<meta charset="UTF-8">
|
|
26
|
-
<style>${
|
|
26
|
+
<style>${m}</style>
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="markdown-content">${c}</div>
|
|
30
30
|
</body>
|
|
31
|
-
</html>`;u?(m=U.join(u,`__md2x_temp_${Date.now()}.html`),X.writeFileSync(m,h,"utf-8"),await f.goto(Ze(m).href,{waitUntil:"networkidle0"})):await f.setContent(h,{waitUntil:"networkidle0"});try{await f.evaluate(async()=>{let g=document.fonts?.ready;g&&typeof g.then=="function"&&await g;let v=Array.from(document.images||[]);await Promise.all(v.map(A=>A.complete?null:new Promise(L=>{A.addEventListener("load",()=>L(),{once:!0}),A.addEventListener("error",()=>L(),{once:!0})})))})}catch{}if(typeof s.scrollToLoad=="boolean"?s.scrollToLoad:!s.selector&&s.fullPage!==!1){let g=s.scroll??{},v=typeof g.delayMs=="number"&&Number.isFinite(g.delayMs)?Math.max(0,g.delayMs):250,A=typeof g.maxSteps=="number"&&Number.isFinite(g.maxSteps)?Math.max(1,Math.floor(g.maxSteps)):40,L=typeof g.maxTimeMs=="number"&&Number.isFinite(g.maxTimeMs)?Math.max(100,Math.floor(g.maxTimeMs)):1e4,T=typeof g.stepPx=="number"&&Number.isFinite(g.stepPx)?Math.max(1,g.stepPx):0;try{await f.evaluate(async k=>{let O=$=>new Promise(R=>setTimeout(R,$)),P=document.scrollingElement||document.documentElement,j=Date.now(),fe=()=>k.stepPx>0?k.stepPx:Math.max(1,Math.floor(window.innerHeight*.85)),_=-1,K=0;for(let $=0;$<k.maxSteps;$++){let R=fe();P.scrollTop=Math.min(P.scrollTop+R,P.scrollHeight),await O(k.delayMs);let Z=P.scrollTop;if(Z===_?K++:K=0,_=Z,Z+window.innerHeight>=P.scrollHeight-2||K>=2||Date.now()-j>k.maxTimeMs)break}P.scrollTop=0,await O(Math.min(250,k.delayMs))},{delayMs:v,maxSteps:A,maxTimeMs:L,stepPx:T}),await f.evaluate(async()=>{let k=Array.from(document.images||[]);await Promise.all(k.map(O=>O.complete?null:new Promise(P=>{O.addEventListener("load",()=>P(),{once:!0}),O.addEventListener("error",()=>P(),{once:!0})})))})}catch{}try{await f.waitForNetworkIdle?.({idleTime:500,timeout:5e3})}catch{}}try{await f.evaluate(()=>typeof window.__md2xLiveDone<"u")&&(await f.waitForFunction(()=>window.__md2xLiveDone===!0,{timeout:6e4}),await f.waitForNetworkIdle?.({idleTime:500,timeout:1e4}).catch(()=>{}))}catch{}let b=typeof s.maxPixelWidth=="number"&&Number.isFinite(s.maxPixelWidth)?s.maxPixelWidth:2e3;if(b>0)try{let g=await f.evaluate(v=>{if(v){let L=Array.from(document.querySelectorAll(v));if(!L.length)return 0;let T=1/0,k=-1/0;for(let P of L){let j=P.getBoundingClientRect();T=Math.min(T,j.left),k=Math.max(k,j.right)}let O=k-T;return Number.isFinite(O)?O:0}let A=document.documentElement;return Math.max(A.scrollWidth,A.clientWidth)||0},Dt(s.selector));if(g>0){let v=f.viewport(),A=v?.deviceScaleFactor??1,L=Math.min(A,b/g),T=Math.max(.25,L);Math.abs(T-A)>=.01&&await f.setViewport({width:v?.width??Math.max(320,Math.floor(p.width??1200)),height:v?.height??Math.max(240,Math.floor(p.height??800)),deviceScaleFactor:T})}}catch{}let w=s.type??"png",q=s.fullPage!==!1,S={type:w};if((w==="jpeg"||w==="webp")&&typeof s.quality=="number"){let g=Math.max(0,Math.min(100,Math.round(s.quality)));S.quality=g}typeof s.fromSurface=="boolean"&&(S.fromSurface=s.fromSurface);let B=async g=>{let v=await f.screenshot(g);return Buffer.isBuffer(v)?v:Buffer.from(v)},C=async()=>{try{return await f.evaluate(()=>{let g=document.documentElement,v=document.body;return{width:Math.max(g.scrollWidth,v?.scrollWidth??0,g.clientWidth),height:Math.max(g.scrollHeight,v?.scrollHeight??0,g.clientHeight),dpr:window.devicePixelRatio||1}})}catch{return{width:0,height:0,dpr:1}}};if(s.selector){let g=Dt(s.selector);if(!g)throw new Error("image.selector is empty");await f.waitForSelector(g,{timeout:3e4});let v=await f.$$(g);if(!v.length)throw new Error(`Element not found for selector: ${g}`);let A=s.selectorMode??"stitch",L=A==="first"?[v[0]]:v,T=typeof s.selectorPadding=="number"&&Number.isFinite(s.selectorPadding)?Math.max(0,s.selectorPadding):0;if(A==="stitch"){let M=typeof s.selectorGap=="number"&&Number.isFinite(s.selectorGap)?Math.max(0,Math.floor(s.selectorGap)):0,E="#__md2x_selector_stitch__",ee=async()=>{try{await f.evaluate(()=>{let I="__md2xSelectorStitchState",oe=window[I];if(!oe)return;let ae=Array.isArray(oe.moves)?oe.moves:[];for(let le of ae)try{let ye=le&&le.el,me=le&&le.ph;if(!ye||!me)continue;let pe=me.parentNode;if(!pe)continue;pe.insertBefore(ye,me),me.remove?.()}catch{}try{oe.container?.remove?.()}catch{}try{delete window[I]}catch{}})}catch{}};await ee();try{await f.evaluate((he,Je)=>{let Qe="__md2xSelectorStitchState",Ne=window[Qe];if(Ne&&Ne.container)try{Ne.container.remove()}catch{}let en=document.getElementById("markdown-content")||document.body,se=document.createElement("div");se.id="__md2x_selector_stitch__",se.style.display="flex",se.style.flexDirection="column",se.style.alignItems="stretch",se.style.gap=String(Je)+"px",se.style.maxWidth="100%",se.style.boxSizing="border-box",en.appendChild(se);let tn=Array.from(document.querySelectorAll(he)).filter(Ee=>{let Te=Ee.parentElement;for(;Te;){try{if(Te.matches(he))return!1}catch{}Te=Te.parentElement}return!0}),Bt=[];for(let Ee of tn){let Te=Ee.parentNode;if(!Te)continue;let jt=document.createComment("md2x-stitch");Te.insertBefore(jt,Ee);let Me=document.createElement("div");Me.style.display="flex",Me.style.justifyContent="center",Me.style.alignItems="flex-start",Me.style.width="100%",Me.style.boxSizing="border-box",Me.appendChild(Ee),se.appendChild(Me),Bt.push({el:Ee,ph:jt})}window[Qe]={container:se,moves:Bt}},g,M),await f.waitForSelector(E,{timeout:5e3});let I=await f.$(E);if(!I)throw new Error(`Unable to create stitch container for selector: ${g}`);try{await f.evaluate(()=>new Promise(he=>requestAnimationFrame(()=>he())))}catch{}let oe=await f.evaluate(()=>{let he=document.documentElement,Je=document.body,Qe=Math.max(he.scrollWidth,Je?.scrollWidth??0,he.clientWidth),Ne=Math.max(he.scrollHeight,Je?.scrollHeight??0,he.clientHeight);return{width:Qe,height:Ne}}),ae=await I.boundingBox();if(!ae)throw new Error(`Unable to determine bounding box for selector: ${g}`);let le=Math.max(0,ae.x-T),ye=Math.max(0,ae.y-T),me=Math.min(oe.width-le,ae.width+T*2),pe=Math.min(oe.height-ye,ae.height+T*2);if(!(me>0)||!(pe>0))throw new Error(`Unable to determine bounding box for selector: ${g}`);let Zr={...S,clip:{x:le,y:ye,width:me,height:pe},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await B(Zr)]}finally{await ee()}}let k=await f.evaluate(()=>{let M=document.documentElement,E=document.body,ee=Math.max(M.scrollWidth,E?.scrollWidth??0,M.clientWidth),I=Math.max(M.scrollHeight,E?.scrollHeight??0,M.clientHeight);return{width:ee,height:I}}),O=async()=>{let M=[],E=0;for(let ee of L){try{await ee.evaluate(pe=>{pe.scrollIntoView({block:"start",inline:"nearest"})})}catch{}let I=await ee.boundingBox();if(!I)continue;let oe=Math.max(0,I.x-T),ae=Math.max(0,I.y-T),le=Math.min(k.width-oe,I.width+T*2),ye=Math.min(k.height-ae,I.height+T*2);if(!(le>0)||!(ye>0))continue;let me={...S,clip:{x:oe,y:ae,width:le,height:ye},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};E>0&&await new Promise(pe=>setTimeout(pe,40)),M.push(await B(me)),E++}return M};if(A==="each"){let M=await O();if(!M.length)throw new Error(`Unable to determine bounding box for selector: ${g}`);return M}let P=1/0,j=1/0,fe=-1/0,_=-1/0,K=[];for(let M of L){let E=await M.boundingBox();E&&(P=Math.min(P,E.x),j=Math.min(j,E.y),fe=Math.max(fe,E.x+E.width),_=Math.max(_,E.y+E.height),K.push(Math.round(E.y+E.height)))}if(!Number.isFinite(P)||!Number.isFinite(j)||!Number.isFinite(fe)||!Number.isFinite(_))throw new Error(`Unable to determine bounding box for selector: ${g}`);let $=Math.max(0,P-T),R=Math.max(0,j-T),Z=Math.min(k.width,fe+T),N=Math.min(k.height,_+T),de=Math.max(1,Z-$),re=Math.max(1,N-R),xe=s.split??"auto",De=Math.max(.25,await f.evaluate(()=>window.devicePixelRatio||1).catch(()=>1)),qr=Math.ceil(re*De);if(!(xe===!0||xe==="auto"&&qr>3e4)){let M={...S,clip:{x:$,y:R,width:de,height:re},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await B(M)]}let Gr=typeof s.splitMaxPixelHeight=="number"&&Number.isFinite(s.splitMaxPixelHeight)?Math.max(500,Math.floor(s.splitMaxPixelHeight)):14e3,Kr=typeof s.splitOverlapPx=="number"&&Number.isFinite(s.splitOverlapPx)?Math.max(0,Math.floor(s.splitOverlapPx)):0,Ot=Math.max(200,Math.floor(Gr/De)),Xr=Math.min(400,Math.floor(Ot*.25)),Jr=Array.from(new Set([...K,Math.round(N)])).filter(M=>Number.isFinite(M)).map(M=>Math.max(0,Math.round(M))).sort((M,E)=>M-E),Qr=M=>{let E=Math.min(N,M+Ot);if(E>=N)return N;let ee=-1;for(let I of Jr)if(!(I<=M+1)){if(I>E)break;I-M<Xr||(ee=I)}return ee>0?ee:Math.max(M+1,E)},Lt=[],Re=R,ht=0;for(;Re<N&&ht<1e4;){let M=Qr(Re),E=Math.max(1,M-Re),ee={...S,clip:{x:$,y:Re,width:de,height:E},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};if(ht>0&&await new Promise(I=>setTimeout(I,40)),Lt.push(await B(ee)),M>=N)break;Re=Math.max(R,M-Kr),ht++}return Lt}if(!q)return S.fullPage=!1,S.captureBeyondViewport=!1,S.omitBackground=s.omitBackground??!1,[await B(S)];let G=await C(),Ce=Math.max(.25,G.dpr||1),Ae=Math.ceil((G.height||0)*Ce),te=s.split??"auto";if(te===!0||te==="auto"&&Ae>3e4){let g=typeof s.splitMaxPixelHeight=="number"&&Number.isFinite(s.splitMaxPixelHeight)?Math.max(500,Math.floor(s.splitMaxPixelHeight)):14e3,v=typeof s.splitOverlapPx=="number"&&Number.isFinite(s.splitOverlapPx)?Math.max(0,Math.floor(s.splitOverlapPx)):0,A=Math.max(200,Math.floor(g/Ce)),L=Math.max(1,G.width||(f.viewport()?.width??1200)),T=Math.max(1,G.height||(f.viewport()?.height??800)),k=[],O=0,P=0,j=await f.evaluate(()=>{let _=document.getElementById("markdown-content"),K=document.scrollingElement||document.documentElement;K.scrollTop=0;let $=[0],R=de=>{let xe=de.getBoundingClientRect().bottom+(window.scrollY||0);Number.isFinite(xe)&&$.push(Math.round(xe))};_&&Array.from(_.children).forEach(re=>{let xe=re.tagName.toLowerCase();if(xe==="ul"||xe==="ol"){let De=Array.from(re.querySelectorAll(":scope > li"));if(De.length>0){De.forEach(R);return}}R(re)});let Z=Math.max(K.scrollHeight,document.documentElement.scrollHeight);$.push(Math.round(Z)),$.sort((de,re)=>de-re);let N=[];for(let de of $){let re=Math.max(0,de);(!N.length||N[N.length-1]!==re)&&N.push(re)}return N}),fe=_=>{let K=Math.min(T,_+A);if(K>=T)return T;let $=Math.min(400,Math.floor(A*.25)),R=-1;for(let Z=0;Z<j.length;Z++){let N=j[Z];if(!(N<=_+1)){if(N>K)break;N-_<$||(R=N)}}return R>0?R:Math.max(_+1,K)};for(;O<T&&P<1e4;){let _=fe(O),K=Math.max(1,_-O),$={...S,clip:{x:0,y:O,width:L,height:K},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};try{await f.evaluate(R=>{let Z=document.scrollingElement||document.documentElement;Z.scrollTop=Math.max(0,R)},O)}catch{}if(P>0&&await new Promise(R=>setTimeout(R,80)),k.push(await B($)),_>=T)break;O=Math.max(0,_-v),P++}try{await f.evaluate(()=>{let _=document.scrollingElement||document.documentElement;_.scrollTop=0})}catch{}return k}S.fullPage=!0,S.captureBeyondViewport=typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!1,S.omitBackground=s.omitBackground??!1,S.captureBeyondViewport===!1&&(G.width&&G.width>16e3||G.height&&G.height>16e3)&&(S.captureBeyondViewport=!0);try{return[await B(S)]}catch(g){let v=g instanceof Error?g.message:String(g);if(S.fromSurface===!1){let A={...S};delete A.fromSurface;try{return[await B(A)]}catch{}}if(S.fullPage&&typeof S.captureBeyondViewport=="boolean"){let A={...S,captureBeyondViewport:!S.captureBeyondViewport};A.fromSurface===!1&&delete A.fromSurface;try{return[await B(A)]}catch{}}throw new Error(`Unable to capture screenshot. ${v}`)}}finally{if(await f.close(),m)try{X.unlinkSync(m)}catch{}}},async close(){if(e&&(await e.close(),e=null,t=null),r){try{X.rmSync(r,{recursive:!0,force:!0})}catch{}r=null}}}}import*as ie from"fs";import*as V from"path";import{pathToFileURL as Nt}from"url";function sn(e){if(ie.existsSync(V.join(e,"themes")))return e;let t=V.resolve(e,"../../src");if(ie.existsSync(V.join(t,"themes")))return t;let r=V.resolve(process.cwd(),"src");if(ie.existsSync(V.join(r,"themes")))return r;throw new Error("Unable to locate themes assets (expected themes/ directory).")}function cn(e){ie.mkdirSync(V.dirname(e),{recursive:!0})}var xt=class{constructor(){this.documentPath="";this.documentDir="";this.baseUrl="";this.needsUriRewrite=!1}setDocumentPath(t,r){this.documentPath=t,this.documentDir=V.dirname(t),this.baseUrl=r??Nt(this.documentDir+V.sep).href,this.needsUriRewrite=!1}resolvePath(t){return t.startsWith("file://")?new URL(t).pathname:V.isAbsolute(t)?t:V.resolve(this.documentDir||process.cwd(),t)}toResourceUrl(t){return Nt(t).href}async readFile(t,r){let i=await ie.promises.readFile(t);return r?.binary?i.toString("base64"):i.toString("utf8")}async readRelativeFile(t,r){let i=this.resolvePath(t);return await this.readFile(i,r)}async fetchRemote(t){let r=await fetch(t,{signal:AbortSignal.timeout(15e3)});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.arrayBuffer();return new Uint8Array(i)}};function _e(e){let t=sn(e.moduleDir),r=new Map;r.set("selectedTheme",e.selectedThemeId),e.settings&&r.set("markdownViewerSettings",e.settings);let i=null,n=new xt;return n.setDocumentPath(V.join(process.cwd(),"__md2x__.md")),{platform:{platform:"node",cache:{async init(){},async calculateHash(){return""},async generateKey(){return""},async get(){return null},async set(){return!1},async clear(){return!0},async getStats(){return null}},renderer:{async init(){},setThemeConfig(){},getThemeConfig(){return null},async render(){throw new Error("RendererService not available in Node platform")}},storage:{async get(o){let l={};for(let c of o)r.has(c)&&(l[c]=r.get(c));return l},async set(o){for(let[l,c]of Object.entries(o))r.set(l,c)},async remove(o){for(let l of o)r.delete(l)}},file:{async download(o,l,c){let d=typeof o=="string"?Buffer.from(o,"base64"):Buffer.from(await o.arrayBuffer());if(c?.onProgress&&c.onProgress({uploaded:d.length,total:d.length}),e.output.kind==="buffer"){i=d;return}cn(l),await ie.promises.writeFile(l,d)}},resource:{async fetch(o){let l=o;if(l.startsWith("file://")){let d=new URL(l);return await ie.promises.readFile(d.pathname,"utf8")}l.startsWith("./")&&(l=l.slice(2)),l.startsWith("/")&&(l=l.slice(1));let c=V.join(t,l);return await ie.promises.readFile(c,"utf8")},getURL(o){return`./${o}`}},i18n:{translate(o){return o},getUILanguage(){return"en"}},message:{async send(){return null},addListener(){}},document:n},getCapturedBuffer:()=>i}}function be(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:F.dirname(He(import.meta.url))}function $e(){typeof globalThis.atob!="function"&&(globalThis.atob=e=>Buffer.from(e,"base64").toString("binary")),typeof globalThis.btoa!="function"&&(globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"))}async function Ve(e){let r=await globalThis.platform.resource.fetch(`themes/presets/${e}.json`),i=JSON.parse(r),n=i?.fontScheme?.body?.fontFamily,a=i?.fontScheme?.body?.fontSize?parseFloat(i.fontScheme.body.fontSize):void 0;return{fontFamily:typeof n=="string"?n:void 0,fontSize:typeof a=="number"&&Number.isFinite(a)?a:void 0}}function fn(e,t,r,i,n){return e?{async render(a,o){let l=a==="md2x"&&typeof o=="string"?{code:o,templateFiles:i??{},cdn:{vue:n?.vue,vueSfcLoader:n?.vueSfcLoader}}:o,c=await e.render(a,l,t,r);return c||null}}:null}function tt(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(///g,"/").replace(/</gi,"<").replace(/>/gi,">").replace(/&/gi,"&").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function ze(e,t,r){let i=new RegExp('<pre><code class="[^"]*\\blanguage-md2x\\b[^"]*">([\\s\\S]*?)<\\/code><\\/pre>',"gi"),n=[...e.matchAll(i)],a={},o=(d,s)=>(d.match(new RegExp(`\\b${s}\\s*:\\s*(['"])([^\\n\\r]*?)\\1`,"i"))?.[2]??"").trim(),l=(d,s)=>{let u=String(d||"").trim().toLowerCase(),f=String(s||"").trim();return!u||!f||f.includes("/")||f.includes("\\")||f.includes("://")||f.startsWith("file://")?f:`${u}/${f}`},c=()=>r?(Array.isArray(r)?r:[r]).map(s=>String(s||"").trim()).filter(Boolean):[];for(let d of n){let s=d[1]??"",u=Ht(String(s||"").replace(/<[^>]*>/g,"")),f=o(u,"type"),m=o(u,"template"),p=l(f,m);if(!p)continue;let x=(b=>{try{if(String(b).toLowerCase().startsWith("file://")){let C=He(b);return ne.existsSync(C)?C:null}if(F.isAbsolute(b))return ne.existsSync(b)?b:null;let w=be(),q=c().map(C=>{try{if(String(C).toLowerCase().startsWith("file://"))return He(C)}catch{}return F.isAbsolute(C)?C:F.join(t,C)}),S=[];for(let C of q)S.push(F.join(C,b));let B=[F.join(t,b),...S,F.join(w,"templates",b),F.join(w,"..","templates",b),F.join(w,"..","src","templates",b)];for(let C of B)if(ne.existsSync(C))return C;return null}catch{return null}})(p);if(x)try{let b=ne.readFileSync(x,"utf-8"),w=we(x).href;a[w]=b,a[p]=b,m&&(a[m]=b)}catch{}}return a}function dn(e,t,r){let i=/```md2x[^\n\r]*[\r\n]([\s\S]*?)```/gi,n=[...String(e||"").matchAll(i)],a={},o=(s,u)=>(s.match(new RegExp(`\\b${u}\\s*:\\s*(['"])([^\\n\\r]*?)\\1`,"i"))?.[2]??"").trim(),l=(s,u)=>{let f=String(s||"").trim().toLowerCase(),m=String(u||"").trim();return!f||!m||m.includes("/")||m.includes("\\")||m.includes("://")||m.startsWith("file://")?m:`${f}/${m}`},c=()=>r?(Array.isArray(r)?r:[r]).map(u=>String(u||"").trim()).filter(Boolean):[],d=s=>{try{if(String(s).toLowerCase().startsWith("file://")){let h=He(s);return ne.existsSync(h)?h:null}if(F.isAbsolute(s))return ne.existsSync(s)?s:null;let u=be(),f=c().map(h=>{try{if(String(h).toLowerCase().startsWith("file://"))return He(h)}catch{}return F.isAbsolute(h)?h:F.join(t,h)}),m=[];for(let h of f)m.push(F.join(h,s));let p=[F.join(t,s),...m,F.join(u,"templates",s),F.join(u,"..","templates",s),F.join(u,"..","src","templates",s)];for(let h of p)if(ne.existsSync(h))return h;return null}catch{return null}};for(let s of n){let u=String(s[1]??""),f=o(u,"type"),m=o(u,"template"),p=l(f,m);if(!p)continue;let h=d(p);if(h)try{let x=ne.readFileSync(h,"utf-8"),b=we(h).href;a[b]=x,a[p]=x,m&&(a[m]=x)}catch{}}return a}async function mn(e,t,r,i,n,a,o){if(n!=="img"||!t)return e;let l=ze(e,r,a),c=It.filter(m=>m.nodeSelector.includes("code")).map(m=>m.language).filter(m=>m!==null),d=["graphviz","gv","vegalite"],s=[...c,...d].join("|");if(!s)return e;let u=new RegExp(`<pre><code class="(?:hljs )?language-(${s})">([\\s\\S]*?)<\\/code><\\/pre>`,"gi"),f=[...e.matchAll(u)];for(let m of f){let[p,h,x]=m,b=Ht(String(x||"").replace(/<[^>]*>/g,"")),w=h.toLowerCase();(w==="graphviz"||w==="gv")&&(w="dot"),w==="vegalite"&&(w="vega-lite");try{let q=w==="md2x"?{code:b,templateFiles:l,cdn:{vue:o?.vue,vueSfcLoader:o?.vueSfcLoader}}:b,S=await t.render(w,q,r,i);if(S&&S.base64){let B=tt(w),C=`<div class="md2x-diagram" data-md2x-diagram-kind="${B}"><img class="md2x-diagram" data-md2x-diagram-kind="${B}" src="data:image/${S.format};base64,${S.base64}" alt="${tt(`${h} diagram`)}" style="max-width: 100%;" /></div>`;e=e.replace(p,C)}}catch(q){console.warn(`Failed to render ${h} diagram:`,q)}}return e}async function rt(e,t,r,i,n,a,o){let{unified:l}=await import("./unified-PU53JLVJ.js"),c=(await import("./remark-parse-QC7TSXTK.js")).default,d=(await import("./remark-gfm-BUZ4SLP3.js")).default,s=(await import("./remark-math-HEZQAPFK.js")).default,u=(await import("./remark-super-sub-EP2AQS54.js")).default,f=(await import("./remark-rehype-C2LX643P.js")).default,m=(await import("./rehype-katex-FXTCTSUE.js")).default,p=(await import("./rehype-highlight-Y4Q4RX67.js")).default,h=(await import("./rehype-stringify-4CQSSRDL.js")).default,{visit:x}=await import("./unist-util-visit-SBSD62C6.js");function b(){return B=>{x(B,"element",C=>{if(C.tagName!=="p")return;let G=C.children||[];if(G.length===0)return;let Ce=0,Ae=-1,te=!1,Ie=!1;for(let g=0;g<G.length;g++){let v=G[g];v.type==="element"&&v.tagName==="img"?(Ce++,Ae=g,Ie=!0):Ie&&(v.type==="text"&&v.value.trim()!==""||v.type==="element"&&v.tagName!=="br")&&(te=!0)}if(Ce===1&&!te&&Ae>=0){let g=G[Ae];g.properties=g.properties||{};let v=g.properties.className||[];g.properties.className=Array.isArray(v)?[...v,"block-image"]:[v,"block-image"]}})}}let q=await l().use(c).use(d,{singleTilde:!1}).use(s).use(u).use(f,{allowDangerousHtml:!0}).use(m).use(p).use(b).use(h,{allowDangerousHtml:!0}).process(e),S=String(q);return S=await mn(S,t,r,i,n,a,o),S}function nt(e,t,r,i){let n=l=>JSON.stringify(l).replace(/</g,"\\u003c"),a={mermaid:"https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js",vizGlobal:"https://cdn.jsdelivr.net/npm/@viz-js/viz@3.24.0/dist/viz-global.js",viz:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.js",vizRender:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/full.render.js",infographic:"https://cdn.jsdelivr.net/npm/@antv/infographic@0.2.7/dist/infographic.min.js",vue:"https://unpkg.com/vue@3/dist/vue.global.js",vueSfcLoader:"https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"},o={5:{vega:"https://cdn.jsdelivr.net/npm/vega@5/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@5/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@6/build/vega-embed.min.js"},6:{vega:"https://cdn.jsdelivr.net/npm/vega@6/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@6/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@7/build/vega-embed.min.js"}};return`
|
|
31
|
+
</html>`;u?(d=V.join(u,`__md2x_temp_${Date.now()}.html`),X.writeFileSync(d,h,"utf-8"),await f.goto(Ze(d).href,{waitUntil:"networkidle0"})):await f.setContent(h,{waitUntil:"networkidle0"});try{await f.evaluate(async()=>{let g=document.fonts?.ready;g&&typeof g.then=="function"&&await g;let v=Array.from(document.images||[]);await Promise.all(v.map(M=>M.complete?null:new Promise(j=>{M.addEventListener("load",()=>j(),{once:!0}),M.addEventListener("error",()=>j(),{once:!0})})))})}catch{}if(typeof s.scrollToLoad=="boolean"?s.scrollToLoad:!s.selector&&s.fullPage!==!1){let g=s.scroll??{},v=typeof g.delayMs=="number"&&Number.isFinite(g.delayMs)?Math.max(0,g.delayMs):250,M=typeof g.maxSteps=="number"&&Number.isFinite(g.maxSteps)?Math.max(1,Math.floor(g.maxSteps)):40,j=typeof g.maxTimeMs=="number"&&Number.isFinite(g.maxTimeMs)?Math.max(100,Math.floor(g.maxTimeMs)):1e4,T=typeof g.stepPx=="number"&&Number.isFinite(g.stepPx)?Math.max(1,g.stepPx):0;try{await f.evaluate(async k=>{let O=$=>new Promise(D=>setTimeout(D,$)),P=document.scrollingElement||document.documentElement,B=Date.now(),fe=()=>k.stepPx>0?k.stepPx:Math.max(1,Math.floor(window.innerHeight*.85)),_=-1,K=0;for(let $=0;$<k.maxSteps;$++){let D=fe();P.scrollTop=Math.min(P.scrollTop+D,P.scrollHeight),await O(k.delayMs);let Z=P.scrollTop;if(Z===_?K++:K=0,_=Z,Z+window.innerHeight>=P.scrollHeight-2||K>=2||Date.now()-B>k.maxTimeMs)break}P.scrollTop=0,await O(Math.min(250,k.delayMs))},{delayMs:v,maxSteps:M,maxTimeMs:j,stepPx:T}),await f.evaluate(async()=>{let k=Array.from(document.images||[]);await Promise.all(k.map(O=>O.complete?null:new Promise(P=>{O.addEventListener("load",()=>P(),{once:!0}),O.addEventListener("error",()=>P(),{once:!0})})))})}catch{}try{await f.waitForNetworkIdle?.({idleTime:500,timeout:5e3})}catch{}}try{await f.evaluate(()=>typeof window.__md2xLiveDone<"u")&&(await f.waitForFunction(()=>window.__md2xLiveDone===!0,{timeout:6e4}),await f.waitForNetworkIdle?.({idleTime:500,timeout:1e4}).catch(()=>{}))}catch{}let b=typeof s.maxPixelWidth=="number"&&Number.isFinite(s.maxPixelWidth)?s.maxPixelWidth:2e3;if(b>0)try{let g=await f.evaluate(v=>{if(v){let j=Array.from(document.querySelectorAll(v));if(!j.length)return 0;let T=1/0,k=-1/0;for(let P of j){let B=P.getBoundingClientRect();T=Math.min(T,B.left),k=Math.max(k,B.right)}let O=k-T;return Number.isFinite(O)?O:0}let M=document.documentElement;return Math.max(M.scrollWidth,M.clientWidth)||0},Rt(s.selector));if(g>0){let v=f.viewport(),M=v?.deviceScaleFactor??1,j=Math.min(M,b/g),T=Math.max(.25,j);Math.abs(T-M)>=.01&&await f.setViewport({width:v?.width??Math.max(320,Math.floor(p.width??1200)),height:v?.height??Math.max(240,Math.floor(p.height??800)),deviceScaleFactor:T})}}catch{}let w=s.type??"png",Y=s.fullPage!==!1,S={type:w};if((w==="jpeg"||w==="webp")&&typeof s.quality=="number"){let g=Math.max(0,Math.min(100,Math.round(s.quality)));S.quality=g}typeof s.fromSurface=="boolean"&&(S.fromSurface=s.fromSurface);let L=async g=>{let v=await f.screenshot(g);return Buffer.isBuffer(v)?v:Buffer.from(v)},C=async()=>{try{return await f.evaluate(()=>{let g=document.documentElement,v=document.body;return{width:Math.max(g.scrollWidth,v?.scrollWidth??0,g.clientWidth),height:Math.max(g.scrollHeight,v?.scrollHeight??0,g.clientHeight),dpr:window.devicePixelRatio||1}})}catch{return{width:0,height:0,dpr:1}}};if(s.selector){let g=Rt(s.selector);if(!g)throw new Error("image.selector is empty");await f.waitForSelector(g,{timeout:3e4});let v=await f.$$(g);if(!v.length)throw new Error(`Element not found for selector: ${g}`);let M=s.selectorMode??"stitch",j=M==="first"?[v[0]]:v,T=typeof s.selectorPadding=="number"&&Number.isFinite(s.selectorPadding)?Math.max(0,s.selectorPadding):0;if(M==="stitch"){let A=typeof s.selectorGap=="number"&&Number.isFinite(s.selectorGap)?Math.max(0,Math.floor(s.selectorGap)):0,E="#__md2x_selector_stitch__",ee=async()=>{try{await f.evaluate(()=>{let I="__md2xSelectorStitchState",oe=window[I];if(!oe)return;let ae=Array.isArray(oe.moves)?oe.moves:[];for(let le of ae)try{let ye=le&&le.el,de=le&&le.ph;if(!ye||!de)continue;let pe=de.parentNode;if(!pe)continue;pe.insertBefore(ye,de),de.remove?.()}catch{}try{oe.container?.remove?.()}catch{}try{delete window[I]}catch{}})}catch{}};await ee();try{await f.evaluate((he,Je)=>{let Qe="__md2xSelectorStitchState",Ne=window[Qe];if(Ne&&Ne.container)try{Ne.container.remove()}catch{}let en=document.getElementById("markdown-content")||document.body,se=document.createElement("div");se.id="__md2x_selector_stitch__",se.style.display="flex",se.style.flexDirection="column",se.style.alignItems="stretch",se.style.gap=String(Je)+"px",se.style.maxWidth="100%",se.style.boxSizing="border-box",en.appendChild(se);let tn=Array.from(document.querySelectorAll(he)).filter(Ee=>{let Te=Ee.parentElement;for(;Te;){try{if(Te.matches(he))return!1}catch{}Te=Te.parentElement}return!0}),Lt=[];for(let Ee of tn){let Te=Ee.parentNode;if(!Te)continue;let Bt=document.createComment("md2x-stitch");Te.insertBefore(Bt,Ee);let Ae=document.createElement("div");Ae.style.display="flex",Ae.style.justifyContent="center",Ae.style.alignItems="flex-start",Ae.style.width="100%",Ae.style.boxSizing="border-box",Ae.appendChild(Ee),se.appendChild(Ae),Lt.push({el:Ee,ph:Bt})}window[Qe]={container:se,moves:Lt}},g,A),await f.waitForSelector(E,{timeout:5e3});let I=await f.$(E);if(!I)throw new Error(`Unable to create stitch container for selector: ${g}`);try{await f.evaluate(()=>new Promise(he=>requestAnimationFrame(()=>he())))}catch{}let oe=await f.evaluate(()=>{let he=document.documentElement,Je=document.body,Qe=Math.max(he.scrollWidth,Je?.scrollWidth??0,he.clientWidth),Ne=Math.max(he.scrollHeight,Je?.scrollHeight??0,he.clientHeight);return{width:Qe,height:Ne}}),ae=await I.boundingBox();if(!ae)throw new Error(`Unable to determine bounding box for selector: ${g}`);let le=Math.max(0,ae.x-T),ye=Math.max(0,ae.y-T),de=Math.min(oe.width-le,ae.width+T*2),pe=Math.min(oe.height-ye,ae.height+T*2);if(!(de>0)||!(pe>0))throw new Error(`Unable to determine bounding box for selector: ${g}`);let Zr={...S,clip:{x:le,y:ye,width:de,height:pe},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await L(Zr)]}finally{await ee()}}let k=await f.evaluate(()=>{let A=document.documentElement,E=document.body,ee=Math.max(A.scrollWidth,E?.scrollWidth??0,A.clientWidth),I=Math.max(A.scrollHeight,E?.scrollHeight??0,A.clientHeight);return{width:ee,height:I}}),O=async()=>{let A=[],E=0;for(let ee of j){try{await ee.evaluate(pe=>{pe.scrollIntoView({block:"start",inline:"nearest"})})}catch{}let I=await ee.boundingBox();if(!I)continue;let oe=Math.max(0,I.x-T),ae=Math.max(0,I.y-T),le=Math.min(k.width-oe,I.width+T*2),ye=Math.min(k.height-ae,I.height+T*2);if(!(le>0)||!(ye>0))continue;let de={...S,clip:{x:oe,y:ae,width:le,height:ye},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};E>0&&await new Promise(pe=>setTimeout(pe,40)),A.push(await L(de)),E++}return A};if(M==="each"){let A=await O();if(!A.length)throw new Error(`Unable to determine bounding box for selector: ${g}`);return A}let P=1/0,B=1/0,fe=-1/0,_=-1/0,K=[];for(let A of j){let E=await A.boundingBox();E&&(P=Math.min(P,E.x),B=Math.min(B,E.y),fe=Math.max(fe,E.x+E.width),_=Math.max(_,E.y+E.height),K.push(Math.round(E.y+E.height)))}if(!Number.isFinite(P)||!Number.isFinite(B)||!Number.isFinite(fe)||!Number.isFinite(_))throw new Error(`Unable to determine bounding box for selector: ${g}`);let $=Math.max(0,P-T),D=Math.max(0,B-T),Z=Math.min(k.width,fe+T),N=Math.min(k.height,_+T),me=Math.max(1,Z-$),re=Math.max(1,N-D),xe=s.split??"auto",Re=Math.max(.25,await f.evaluate(()=>window.devicePixelRatio||1).catch(()=>1)),Yr=Math.ceil(re*Re);if(!(xe===!0||xe==="auto"&&Yr>3e4)){let A={...S,clip:{x:$,y:D,width:me,height:re},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await L(A)]}let Gr=typeof s.splitMaxPixelHeight=="number"&&Number.isFinite(s.splitMaxPixelHeight)?Math.max(500,Math.floor(s.splitMaxPixelHeight)):14e3,Kr=typeof s.splitOverlapPx=="number"&&Number.isFinite(s.splitOverlapPx)?Math.max(0,Math.floor(s.splitOverlapPx)):0,Ot=Math.max(200,Math.floor(Gr/Re)),Xr=Math.min(400,Math.floor(Ot*.25)),Jr=Array.from(new Set([...K,Math.round(N)])).filter(A=>Number.isFinite(A)).map(A=>Math.max(0,Math.round(A))).sort((A,E)=>A-E),Qr=A=>{let E=Math.min(N,A+Ot);if(E>=N)return N;let ee=-1;for(let I of Jr)if(!(I<=A+1)){if(I>E)break;I-A<Xr||(ee=I)}return ee>0?ee:Math.max(A+1,E)},jt=[],De=D,ht=0;for(;De<N&&ht<1e4;){let A=Qr(De),E=Math.max(1,A-De),ee={...S,clip:{x:$,y:De,width:me,height:E},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};if(ht>0&&await new Promise(I=>setTimeout(I,40)),jt.push(await L(ee)),A>=N)break;De=Math.max(D,A-Kr),ht++}return jt}if(!Y)return S.fullPage=!1,S.captureBeyondViewport=!1,S.omitBackground=s.omitBackground??!1,[await L(S)];let G=await C(),Ce=Math.max(.25,G.dpr||1),Me=Math.ceil((G.height||0)*Ce),te=s.split??"auto";if(te===!0||te==="auto"&&Me>3e4){let g=typeof s.splitMaxPixelHeight=="number"&&Number.isFinite(s.splitMaxPixelHeight)?Math.max(500,Math.floor(s.splitMaxPixelHeight)):14e3,v=typeof s.splitOverlapPx=="number"&&Number.isFinite(s.splitOverlapPx)?Math.max(0,Math.floor(s.splitOverlapPx)):0,M=Math.max(200,Math.floor(g/Ce)),j=Math.max(1,G.width||(f.viewport()?.width??1200)),T=Math.max(1,G.height||(f.viewport()?.height??800)),k=[],O=0,P=0,B=await f.evaluate(()=>{let _=document.getElementById("markdown-content"),K=document.scrollingElement||document.documentElement;K.scrollTop=0;let $=[0],D=me=>{let xe=me.getBoundingClientRect().bottom+(window.scrollY||0);Number.isFinite(xe)&&$.push(Math.round(xe))};_&&Array.from(_.children).forEach(re=>{let xe=re.tagName.toLowerCase();if(xe==="ul"||xe==="ol"){let Re=Array.from(re.querySelectorAll(":scope > li"));if(Re.length>0){Re.forEach(D);return}}D(re)});let Z=Math.max(K.scrollHeight,document.documentElement.scrollHeight);$.push(Math.round(Z)),$.sort((me,re)=>me-re);let N=[];for(let me of $){let re=Math.max(0,me);(!N.length||N[N.length-1]!==re)&&N.push(re)}return N}),fe=_=>{let K=Math.min(T,_+M);if(K>=T)return T;let $=Math.min(400,Math.floor(M*.25)),D=-1;for(let Z=0;Z<B.length;Z++){let N=B[Z];if(!(N<=_+1)){if(N>K)break;N-_<$||(D=N)}}return D>0?D:Math.max(_+1,K)};for(;O<T&&P<1e4;){let _=fe(O),K=Math.max(1,_-O),$={...S,clip:{x:0,y:O,width:j,height:K},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};try{await f.evaluate(D=>{let Z=document.scrollingElement||document.documentElement;Z.scrollTop=Math.max(0,D)},O)}catch{}if(P>0&&await new Promise(D=>setTimeout(D,80)),k.push(await L($)),_>=T)break;O=Math.max(0,_-v),P++}try{await f.evaluate(()=>{let _=document.scrollingElement||document.documentElement;_.scrollTop=0})}catch{}return k}S.fullPage=!0,S.captureBeyondViewport=typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!1,S.omitBackground=s.omitBackground??!1,S.captureBeyondViewport===!1&&(G.width&&G.width>16e3||G.height&&G.height>16e3)&&(S.captureBeyondViewport=!0);try{return[await L(S)]}catch(g){let v=g instanceof Error?g.message:String(g);if(S.fromSurface===!1){let M={...S};delete M.fromSurface;try{return[await L(M)]}catch{}}if(S.fullPage&&typeof S.captureBeyondViewport=="boolean"){let M={...S,captureBeyondViewport:!S.captureBeyondViewport};M.fromSurface===!1&&delete M.fromSurface;try{return[await L(M)]}catch{}}throw new Error(`Unable to capture screenshot. ${v}`)}}finally{if(await f.close(),d)try{X.unlinkSync(d)}catch{}}},async close(){if(e&&(await e.close(),e=null,t=null),r){try{X.rmSync(r,{recursive:!0,force:!0})}catch{}r=null}}}}import*as ie from"fs";import*as U from"path";import{pathToFileURL as Nt}from"url";function sn(e){if(ie.existsSync(U.join(e,"themes")))return e;let t=U.resolve(e,"../../src");if(ie.existsSync(U.join(t,"themes")))return t;let r=U.resolve(process.cwd(),"src");if(ie.existsSync(U.join(r,"themes")))return r;throw new Error("Unable to locate themes assets (expected themes/ directory).")}function cn(e){ie.mkdirSync(U.dirname(e),{recursive:!0})}var xt=class{constructor(){this.documentPath="";this.documentDir="";this.baseUrl="";this.needsUriRewrite=!1}setDocumentPath(t,r){this.documentPath=t,this.documentDir=U.dirname(t),this.baseUrl=r??Nt(this.documentDir+U.sep).href,this.needsUriRewrite=!1}resolvePath(t){return t.startsWith("file://")?new URL(t).pathname:U.isAbsolute(t)?t:U.resolve(this.documentDir||process.cwd(),t)}toResourceUrl(t){return Nt(t).href}async readFile(t,r){let i=await ie.promises.readFile(t);return r?.binary?i.toString("base64"):i.toString("utf8")}async readRelativeFile(t,r){let i=this.resolvePath(t);return await this.readFile(i,r)}async fetchRemote(t){let r=await fetch(t,{signal:AbortSignal.timeout(15e3)});if(!r.ok)throw new Error(`HTTP ${r.status}: ${r.statusText}`);let i=await r.arrayBuffer();return new Uint8Array(i)}};function _e(e){let t=sn(e.moduleDir),r=new Map;r.set("selectedTheme",e.selectedThemeId),e.settings&&r.set("markdownViewerSettings",e.settings);let i=null,n=new xt;return n.setDocumentPath(U.join(process.cwd(),"__md2x__.md")),{platform:{platform:"node",cache:{async init(){},async calculateHash(){return""},async generateKey(){return""},async get(){return null},async set(){return!1},async clear(){return!0},async getStats(){return null}},renderer:{async init(){},setThemeConfig(){},getThemeConfig(){return null},async render(){throw new Error("RendererService not available in Node platform")}},storage:{async get(o){let l={};for(let c of o)r.has(c)&&(l[c]=r.get(c));return l},async set(o){for(let[l,c]of Object.entries(o))r.set(l,c)},async remove(o){for(let l of o)r.delete(l)}},file:{async download(o,l,c){let m=typeof o=="string"?Buffer.from(o,"base64"):Buffer.from(await o.arrayBuffer());if(c?.onProgress&&c.onProgress({uploaded:m.length,total:m.length}),e.output.kind==="buffer"){i=m;return}cn(l),await ie.promises.writeFile(l,m)}},resource:{async fetch(o){let l=o;if(l.startsWith("file://")){let m=new URL(l);return await ie.promises.readFile(m.pathname,"utf8")}l.startsWith("./")&&(l=l.slice(2)),l.startsWith("/")&&(l=l.slice(1));let c=U.join(t,l);return await ie.promises.readFile(c,"utf8")},getURL(o){return`./${o}`}},i18n:{translate(o){return o},getUILanguage(){return"en"}},message:{async send(){return null},addListener(){}},document:n},getCapturedBuffer:()=>i}}function be(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:F.dirname(He(import.meta.url))}function $e(){typeof globalThis.atob!="function"&&(globalThis.atob=e=>Buffer.from(e,"base64").toString("binary")),typeof globalThis.btoa!="function"&&(globalThis.btoa=e=>Buffer.from(e,"binary").toString("base64"))}async function Ue(e){let r=await globalThis.platform.resource.fetch(`themes/presets/${e}.json`),i=JSON.parse(r),n=i?.fontScheme?.body?.fontFamily,a=i?.fontScheme?.body?.fontSize?parseFloat(i.fontScheme.body.fontSize):void 0;return{fontFamily:typeof n=="string"?n:void 0,fontSize:typeof a=="number"&&Number.isFinite(a)?a:void 0}}function fn(e,t,r,i,n){return e?{async render(a,o){let l=a==="md2x"&&typeof o=="string"?{code:o,templateFiles:i??{},cdn:{vue:n?.vue,vueSfcLoader:n?.vueSfcLoader,svelteCompiler:n?.svelteCompiler,svelteBase:n?.svelteBase}}:o,c=await e.render(a,l,t,r);return c||null}}:null}function tt(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Ht(e){return e.replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&").replace(/"/g,'"').replace(/'/g,"'").replace(/'/g,"'").replace(///g,"/").replace(/</gi,"<").replace(/>/gi,">").replace(/&/gi,"&").replace(/</g,"<").replace(/>/g,">").replace(/&/g,"&")}function ze(e,t,r){let i=new RegExp('<pre><code class="[^"]*\\blanguage-md2x\\b[^"]*">([\\s\\S]*?)<\\/code><\\/pre>',"gi"),n=[...e.matchAll(i)],a={},o=(m,s)=>(m.match(new RegExp(`\\b${s}\\s*:\\s*(['"])([^\\n\\r]*?)\\1`,"i"))?.[2]??"").trim(),l=(m,s)=>{let u=String(m||"").trim().toLowerCase(),f=String(s||"").trim();return!u||!f||f.includes("/")||f.includes("\\")||f.includes("://")||f.startsWith("file://")?f:`${u}/${f}`},c=()=>r?(Array.isArray(r)?r:[r]).map(s=>String(s||"").trim()).filter(Boolean):[];for(let m of n){let s=m[1]??"",u=Ht(String(s||"").replace(/<[^>]*>/g,"")),f=o(u,"type"),d=o(u,"template"),p=l(f,d);if(!p)continue;let x=(b=>{try{if(String(b).toLowerCase().startsWith("file://")){let C=He(b);return ne.existsSync(C)?C:null}if(F.isAbsolute(b))return ne.existsSync(b)?b:null;let w=be(),Y=c().map(C=>{try{if(String(C).toLowerCase().startsWith("file://"))return He(C)}catch{}return F.isAbsolute(C)?C:F.join(t,C)}),S=[];for(let C of Y)S.push(F.join(C,b));let L=[F.join(t,b),...S,F.join(w,"templates",b),F.join(w,"..","templates",b),F.join(w,"..","src","templates",b)];for(let C of L)if(ne.existsSync(C))return C;return null}catch{return null}})(p);if(x)try{let b=ne.readFileSync(x,"utf-8"),w=we(x).href;a[w]=b,a[p]=b,d&&(a[d]=b)}catch{}}return a}function mn(e,t,r){let i=/```md2x[^\n\r]*[\r\n]([\s\S]*?)```/gi,n=[...String(e||"").matchAll(i)],a={},o=(s,u)=>(s.match(new RegExp(`\\b${u}\\s*:\\s*(['"])([^\\n\\r]*?)\\1`,"i"))?.[2]??"").trim(),l=(s,u)=>{let f=String(s||"").trim().toLowerCase(),d=String(u||"").trim();return!f||!d||d.includes("/")||d.includes("\\")||d.includes("://")||d.startsWith("file://")?d:`${f}/${d}`},c=()=>r?(Array.isArray(r)?r:[r]).map(u=>String(u||"").trim()).filter(Boolean):[],m=s=>{try{if(String(s).toLowerCase().startsWith("file://")){let h=He(s);return ne.existsSync(h)?h:null}if(F.isAbsolute(s))return ne.existsSync(s)?s:null;let u=be(),f=c().map(h=>{try{if(String(h).toLowerCase().startsWith("file://"))return He(h)}catch{}return F.isAbsolute(h)?h:F.join(t,h)}),d=[];for(let h of f)d.push(F.join(h,s));let p=[F.join(t,s),...d,F.join(u,"templates",s),F.join(u,"..","templates",s),F.join(u,"..","src","templates",s)];for(let h of p)if(ne.existsSync(h))return h;return null}catch{return null}};for(let s of n){let u=String(s[1]??""),f=o(u,"type"),d=o(u,"template"),p=l(f,d);if(!p)continue;let h=m(p);if(h)try{let x=ne.readFileSync(h,"utf-8"),b=we(h).href;a[b]=x,a[p]=x,d&&(a[d]=x)}catch{}}return a}async function dn(e,t,r,i,n,a,o){if(n!=="img"||!t)return e;let l=ze(e,r,a),c=It.filter(d=>d.nodeSelector.includes("code")).map(d=>d.language).filter(d=>d!==null),m=["graphviz","gv","vegalite"],s=[...c,...m].join("|");if(!s)return e;let u=new RegExp(`<pre><code class="(?:hljs )?language-(${s})">([\\s\\S]*?)<\\/code><\\/pre>`,"gi"),f=[...e.matchAll(u)];for(let d of f){let[p,h,x]=d,b=Ht(String(x||"").replace(/<[^>]*>/g,"")),w=h.toLowerCase();(w==="graphviz"||w==="gv")&&(w="dot"),w==="vegalite"&&(w="vega-lite");try{let Y=w==="md2x"?{code:b,templateFiles:l,cdn:{vue:o?.vue,vueSfcLoader:o?.vueSfcLoader,svelteCompiler:o?.svelteCompiler,svelteBase:o?.svelteBase}}:b,S=await t.render(w,Y,r,i);if(S&&S.base64){let L=tt(w),C=`<div class="md2x-diagram" data-md2x-diagram-kind="${L}"><img class="md2x-diagram" data-md2x-diagram-kind="${L}" src="data:image/${S.format};base64,${S.base64}" alt="${tt(`${h} diagram`)}" style="max-width: 100%;" /></div>`;e=e.replace(p,C)}}catch(Y){console.warn(`Failed to render ${h} diagram:`,Y)}}return e}async function rt(e,t,r,i,n,a,o){let{unified:l}=await import("./unified-PU53JLVJ.js"),c=(await import("./remark-parse-QC7TSXTK.js")).default,m=(await import("./remark-gfm-BUZ4SLP3.js")).default,s=(await import("./remark-math-HEZQAPFK.js")).default,u=(await import("./remark-super-sub-EP2AQS54.js")).default,f=(await import("./remark-rehype-C2LX643P.js")).default,d=(await import("./rehype-katex-FXTCTSUE.js")).default,p=(await import("./rehype-highlight-Y4Q4RX67.js")).default,h=(await import("./rehype-stringify-4CQSSRDL.js")).default,{visit:x}=await import("./unist-util-visit-SBSD62C6.js");function b(){return L=>{x(L,"element",C=>{if(C.tagName!=="p")return;let G=C.children||[];if(G.length===0)return;let Ce=0,Me=-1,te=!1,Ie=!1;for(let g=0;g<G.length;g++){let v=G[g];v.type==="element"&&v.tagName==="img"?(Ce++,Me=g,Ie=!0):Ie&&(v.type==="text"&&v.value.trim()!==""||v.type==="element"&&v.tagName!=="br")&&(te=!0)}if(Ce===1&&!te&&Me>=0){let g=G[Me];g.properties=g.properties||{};let v=g.properties.className||[];g.properties.className=Array.isArray(v)?[...v,"block-image"]:[v,"block-image"]}})}}let Y=await l().use(c).use(m,{singleTilde:!1}).use(s).use(u).use(f,{allowDangerousHtml:!0}).use(d).use(p).use(b).use(h,{allowDangerousHtml:!0}).process(e),S=String(Y);return S=await dn(S,t,r,i,n,a,o),S}function nt(e,t,r,i){let n=l=>JSON.stringify(l).replace(/</g,"\\u003c"),a={mermaid:"https://cdn.jsdelivr.net/npm/mermaid@11.12.2/dist/mermaid.min.js",vizGlobal:"https://cdn.jsdelivr.net/npm/@viz-js/viz@3.24.0/dist/viz-global.js",viz:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/viz.js",vizRender:"https://cdn.jsdelivr.net/npm/viz.js@2.1.2/full.render.js",infographic:"https://cdn.jsdelivr.net/npm/@antv/infographic@0.2.7/dist/infographic.min.js",vue:"https://unpkg.com/vue@3/dist/vue.global.js",vueSfcLoader:"https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js",svelteCompiler:"https://esm.sh/svelte@5/compiler",svelteBase:"https://esm.sh/svelte@5/"},o={5:{vega:"https://cdn.jsdelivr.net/npm/vega@5/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@5/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@6/build/vega-embed.min.js"},6:{vega:"https://cdn.jsdelivr.net/npm/vega@6/build/vega.min.js",vegaLite:"https://cdn.jsdelivr.net/npm/vega-lite@6/build/vega-lite.min.js",vegaEmbed:"https://cdn.jsdelivr.net/npm/vega-embed@7/build/vega-embed.min.js"}};return`
|
|
32
32
|
<!-- md2x live diagram renderer (CDN) -->
|
|
33
33
|
<script>
|
|
34
34
|
(function () {
|
|
@@ -52,6 +52,79 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
let __md2xSvelteCompilerPromise = null;
|
|
56
|
+
|
|
57
|
+
function getCdnValue(key) {
|
|
58
|
+
try {
|
|
59
|
+
if (cdnOverrides && Object.prototype.hasOwnProperty.call(cdnOverrides, key) && cdnOverrides[key]) return cdnOverrides[key];
|
|
60
|
+
} catch {}
|
|
61
|
+
return cdnBaseDefaults[key];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function normalizeUrlBase(base) {
|
|
65
|
+
const b = String(base || '').trim();
|
|
66
|
+
if (!b) return b;
|
|
67
|
+
return b.endsWith('/') ? b : (b + '/');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizePkgEntryUrl(base) {
|
|
71
|
+
const b = String(base || '').trim();
|
|
72
|
+
if (!b) return b;
|
|
73
|
+
return b.endsWith('/') ? b.slice(0, -1) : b;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function rewriteSvelteModuleSpecifiers(code, svelteBase) {
|
|
77
|
+
const base = normalizeUrlBase(svelteBase);
|
|
78
|
+
if (!base) return String(code || '');
|
|
79
|
+
|
|
80
|
+
const resolve = (p) => {
|
|
81
|
+
try { return new URL(p, base).href; } catch { return base + p; }
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const isEsmSh = base.indexOf('esm.sh/') !== -1;
|
|
85
|
+
const entry = normalizePkgEntryUrl(base);
|
|
86
|
+
|
|
87
|
+
const map = {
|
|
88
|
+
// Svelte 5 runtime imports:
|
|
89
|
+
'svelte': isEsmSh ? entry : resolve('src/runtime/index.js'),
|
|
90
|
+
'svelte/internal': isEsmSh ? resolve('internal') : resolve('src/runtime/internal/index.js'),
|
|
91
|
+
'svelte/internal/client': isEsmSh ? resolve('internal/client') : resolve('src/runtime/internal/client/index.js'),
|
|
92
|
+
'svelte/internal/server': isEsmSh ? resolve('internal/server') : resolve('src/runtime/internal/server/index.js'),
|
|
93
|
+
'svelte/internal/disclose-version': isEsmSh
|
|
94
|
+
? resolve('internal/disclose-version')
|
|
95
|
+
: resolve('src/runtime/internal/disclose-version/index.js'),
|
|
96
|
+
'svelte/store': isEsmSh ? resolve('store') : resolve('src/runtime/store/index.js'),
|
|
97
|
+
'svelte/animate': isEsmSh ? resolve('animate') : resolve('src/runtime/animate/index.js'),
|
|
98
|
+
'svelte/easing': isEsmSh ? resolve('easing') : resolve('src/runtime/easing/index.js'),
|
|
99
|
+
'svelte/motion': isEsmSh ? resolve('motion') : resolve('src/runtime/motion/index.js'),
|
|
100
|
+
'svelte/transition': isEsmSh ? resolve('transition') : resolve('src/runtime/transition/index.js'),
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
let out = String(code || '');
|
|
104
|
+
for (const k in map) {
|
|
105
|
+
const v = map[k];
|
|
106
|
+
out = out.split("'" + k + "'").join("'" + v + "'");
|
|
107
|
+
out = out.split('"' + k + '"').join('"' + v + '"');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Catch-all for any remaining Svelte subpath imports like:
|
|
111
|
+
// "svelte/internal/flags/legacy"
|
|
112
|
+
// "svelte/internal/client"
|
|
113
|
+
// We only support esm.sh, so rewrite bare "svelte/<...>" to absolute URLs.
|
|
114
|
+
if (isEsmSh && entry) {
|
|
115
|
+
out = out.split("'svelte/").join("'" + entry + '/');
|
|
116
|
+
out = out.split('"svelte/').join('"' + entry + '/');
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
async function loadSvelteCompilerModule() {
|
|
122
|
+
if (__md2xSvelteCompilerPromise) return __md2xSvelteCompilerPromise;
|
|
123
|
+
const url = getCdnValue('svelteCompiler');
|
|
124
|
+
__md2xSvelteCompilerPromise = import(url);
|
|
125
|
+
return __md2xSvelteCompilerPromise;
|
|
126
|
+
}
|
|
127
|
+
|
|
55
128
|
function getLangFromCodeClass(codeEl) {
|
|
56
129
|
const cls = (codeEl && codeEl.className) ? String(codeEl.className) : '';
|
|
57
130
|
const m = cls.match(/\\blanguage-([a-z0-9-]+)\\b/i);
|
|
@@ -159,6 +232,7 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
159
232
|
infographic: false,
|
|
160
233
|
md2xVue: false,
|
|
161
234
|
md2xHtml: false,
|
|
235
|
+
md2xSvelte: false,
|
|
162
236
|
};
|
|
163
237
|
|
|
164
238
|
for (const codeEl of blocks) {
|
|
@@ -175,6 +249,7 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
175
249
|
const cfg = parseMd2xConfig(text);
|
|
176
250
|
if (cfg && cfg.type === 'vue') out.md2xVue = true;
|
|
177
251
|
if (cfg && cfg.type === 'html') out.md2xHtml = true;
|
|
252
|
+
if (cfg && cfg.type === 'svelte') out.md2xSvelte = true;
|
|
178
253
|
}
|
|
179
254
|
}
|
|
180
255
|
|
|
@@ -221,6 +296,12 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
221
296
|
await loadScript(cdn.vueSfcLoader);
|
|
222
297
|
} catch {}
|
|
223
298
|
}
|
|
299
|
+
if (kinds.md2xSvelte) {
|
|
300
|
+
try {
|
|
301
|
+
// Warm up the compiler module so rendering multiple blocks is faster.
|
|
302
|
+
await import(cdn.svelteCompiler);
|
|
303
|
+
} catch {}
|
|
304
|
+
}
|
|
224
305
|
}
|
|
225
306
|
|
|
226
307
|
function replacePreWithContainer(preEl, kind) {
|
|
@@ -387,7 +468,7 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
387
468
|
const type = (cfg.type != null) ? String(cfg.type).toLowerCase() : '';
|
|
388
469
|
const template = (cfg.template != null) ? String(cfg.template) : '';
|
|
389
470
|
const data = cfg.data;
|
|
390
|
-
if (type !== 'vue' && type !== 'html') return null;
|
|
471
|
+
if (type !== 'vue' && type !== 'html' && type !== 'svelte') return null;
|
|
391
472
|
if (!template) return null;
|
|
392
473
|
return { type, template, data };
|
|
393
474
|
}
|
|
@@ -553,6 +634,122 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
553
634
|
} catch {}
|
|
554
635
|
}
|
|
555
636
|
|
|
637
|
+
async function renderMd2xSvelte(cfg, mount) {
|
|
638
|
+
const templateRef = normalizeMd2xTemplateRef(cfg.type, cfg.template);
|
|
639
|
+
const rootHref = resolveHref(templateRef, baseHref || undefined);
|
|
640
|
+
const rootSource = md2xTemplateFiles[rootHref] || md2xTemplateFiles[templateRef] || md2xTemplateFiles[cfg.template];
|
|
641
|
+
if (typeof rootSource !== 'string' || !rootSource) {
|
|
642
|
+
mount.textContent = 'Missing md2x svelte template: ' + templateRef;
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
const json = (() => {
|
|
647
|
+
try {
|
|
648
|
+
const j = JSON.stringify(cfg.data ?? null);
|
|
649
|
+
// IMPORTANT: avoid including the literal closing script tag sequence in this bootstrap source code.
|
|
650
|
+
return j.split('</').join('<\\/');
|
|
651
|
+
} catch {
|
|
652
|
+
return 'null';
|
|
653
|
+
}
|
|
654
|
+
})();
|
|
655
|
+
const patchedSource = rootSource.split('templateData').join('(' + json + ')');
|
|
656
|
+
|
|
657
|
+
let compilerMod;
|
|
658
|
+
try {
|
|
659
|
+
compilerMod = await loadSvelteCompilerModule();
|
|
660
|
+
} catch (e) {
|
|
661
|
+
mount.textContent = 'Svelte compiler unavailable: ' + ((e && e.message) ? e.message : String(e));
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
const compile =
|
|
666
|
+
(compilerMod && compilerMod.compile) ||
|
|
667
|
+
(compilerMod && compilerMod.default && compilerMod.default.compile);
|
|
668
|
+
if (typeof compile !== 'function') {
|
|
669
|
+
mount.textContent = 'Svelte compiler not available (missing compile()).';
|
|
670
|
+
return;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
let compiled;
|
|
674
|
+
try {
|
|
675
|
+
// Svelte 5 uses generate: "client" (Svelte 4 used generate: "dom"). We only support Svelte 5 here,
|
|
676
|
+
// but keep a fallback for older compiler builds.
|
|
677
|
+
try {
|
|
678
|
+
compiled = compile(patchedSource, { filename: rootHref || templateRef || 'md2x.svelte', generate: 'client' });
|
|
679
|
+
} catch {
|
|
680
|
+
compiled = compile(patchedSource, { filename: rootHref || templateRef || 'md2x.svelte', generate: 'dom' });
|
|
681
|
+
}
|
|
682
|
+
} catch (e) {
|
|
683
|
+
mount.textContent = 'Failed to compile Svelte template: ' + cfg.template;
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
const jsCode = compiled && compiled.js && compiled.js.code ? String(compiled.js.code) : '';
|
|
688
|
+
const cssCode = compiled && compiled.css && compiled.css.code ? String(compiled.css.code) : '';
|
|
689
|
+
if (!jsCode.trim()) {
|
|
690
|
+
mount.textContent = 'Svelte compile returned no JS output.';
|
|
691
|
+
return;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
const svelteBase = getCdnValue('svelteBase');
|
|
695
|
+
const moduleCode = rewriteSvelteModuleSpecifiers(jsCode, svelteBase);
|
|
696
|
+
|
|
697
|
+
let blobUrl = '';
|
|
698
|
+
try {
|
|
699
|
+
blobUrl = URL.createObjectURL(new Blob([moduleCode], { type: 'text/javascript' }));
|
|
700
|
+
} catch (e) {
|
|
701
|
+
mount.textContent = 'Unable to create Blob URL for Svelte module.';
|
|
702
|
+
return;
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
try {
|
|
706
|
+
let mod;
|
|
707
|
+
try {
|
|
708
|
+
mod = await import(blobUrl);
|
|
709
|
+
} catch (e) {
|
|
710
|
+
mount.textContent = 'Failed to load compiled Svelte module: ' + ((e && e.message) ? e.message : String(e));
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
const Comp = mod && mod.default;
|
|
715
|
+
if (typeof Comp !== 'function') {
|
|
716
|
+
mount.textContent = 'Compiled Svelte module has no default component export.';
|
|
717
|
+
return;
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
const svelteEntry = normalizePkgEntryUrl(svelteBase);
|
|
721
|
+
let runtime;
|
|
722
|
+
try {
|
|
723
|
+
runtime = await import(svelteEntry);
|
|
724
|
+
} catch (e) {
|
|
725
|
+
mount.textContent = 'Failed to load Svelte runtime: ' + ((e && e.message) ? e.message : String(e));
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
const mountFn = runtime && runtime.mount;
|
|
730
|
+
if (typeof mountFn !== 'function') {
|
|
731
|
+
mount.textContent = 'Svelte runtime mount() not available.';
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
if (cssCode && cssCode.trim()) {
|
|
736
|
+
const style = document.createElement('style');
|
|
737
|
+
style.textContent = cssCode;
|
|
738
|
+
mount.appendChild(style);
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
try {
|
|
742
|
+
// NOTE: keep mounted for printing/PDF.
|
|
743
|
+
mountFn(Comp, { target: mount });
|
|
744
|
+
} catch (e) {
|
|
745
|
+
mount.textContent = 'Failed to mount Svelte component: ' + ((e && e.message) ? e.message : String(e));
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
} finally {
|
|
749
|
+
try { URL.revokeObjectURL(blobUrl); } catch {}
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
|
|
556
753
|
async function main() {
|
|
557
754
|
try {
|
|
558
755
|
if (baseHref) {
|
|
@@ -603,6 +800,8 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
603
800
|
await renderMd2xVue(cfg, mount);
|
|
604
801
|
} else if (cfg.type === 'html') {
|
|
605
802
|
await renderMd2xHtml(cfg, mount);
|
|
803
|
+
} else if (cfg.type === 'svelte') {
|
|
804
|
+
await renderMd2xSvelte(cfg, mount);
|
|
606
805
|
}
|
|
607
806
|
}
|
|
608
807
|
} catch {}
|
|
@@ -617,7 +816,7 @@ Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{return
|
|
|
617
816
|
main();
|
|
618
817
|
}
|
|
619
818
|
})();
|
|
620
|
-
</script>`}var it=class{async exportToBuffer(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o,getCapturedBuffer:l}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"},settings:{docxHrAsPageBreak:r.hrAsPageBreak??!0}}),c=globalThis.platform;globalThis.platform=o;let
|
|
819
|
+
</script>`}var it=class{async exportToBuffer(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o,getCapturedBuffer:l}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"},settings:{docxHrAsPageBreak:r.hrAsPageBreak??!0}}),c=globalThis.platform;globalThis.platform=o;let m=F.join(n,"__md2x__.md"),s=null;try{s=await Pe(),s&&await s.initialize();let u=await Ue(i),f=mn(t,n,r.templatesDir),d=fn(s,n,u,f),{default:p}=await import("./docx-exporter-ZZ76JXFU.js"),h=new p(d);h.setBaseUrl?.(we(m).href);let x=await h.exportToDocx(t,"__md2x__.docx",null);if(!x.success)throw new Error(x.error||"DOCX export failed");let b=l();if(!b)throw new Error("DOCX export produced no output buffer");return b}finally{try{s&&await s.close()}finally{globalThis.platform=c}}}};async function ot(e){let t=globalThis.platform;await(await import("./theme-manager-AZBU2SLL.js")).default.initialize();let i=await t.resource.fetch(`themes/presets/${e}.json`),n=JSON.parse(i),a=await t.resource.fetch(`themes/layout-schemes/${n.layoutScheme}.json`),o=JSON.parse(a),l=await t.resource.fetch(`themes/color-schemes/${n.colorScheme}.json`),c=JSON.parse(l),m=await t.resource.fetch(`themes/table-styles/${n.tableStyle}.json`),s=JSON.parse(m),u=await t.resource.fetch(`themes/code-themes/${n.codeTheme}.json`),f=JSON.parse(u),{themeToCSS:d}=await import("./theme-to-css-GLV3WYDU.js");return d(n,o,c,s,f)}async function at(e=!0){return`
|
|
621
820
|
/* Base PDF Styles */
|
|
622
821
|
* {
|
|
623
822
|
box-sizing: border-box;
|
|
@@ -960,19 +1159,19 @@ hr {
|
|
|
960
1159
|
background-color: #e1e4e8;
|
|
961
1160
|
border: 0;
|
|
962
1161
|
}`}
|
|
963
|
-
`}function lt(){let e=be(),t=F.join(e,"vendor","katex","katex.min.css"),r=t;ne.existsSync(t)||(r=un(import.meta.url).resolve("katex/dist/katex.min.css"));let i=F.dirname(r),n=we(F.join(i,"fonts")+F.sep).href,a=ne.readFileSync(r,"utf-8");return a=a.replace(/url\((['"]?)(?:\.\/)?fonts\//g,`url($1${n}`),a}var st=class{async exportToBuffer(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),l=globalThis.platform;globalThis.platform=o;let c=null;try{if(c=await Pe(),!c)throw new Error("Failed to create browser renderer. Puppeteer is required for PDF export.");await c.initialize();let
|
|
964
|
-
`+nt(
|
|
965
|
-
`+
|
|
966
|
-
`+p;return await c.exportToPdf(u,h,r.pdf,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}},
|
|
967
|
-
`+nt(
|
|
968
|
-
`+
|
|
969
|
-
`+p;return await c.exportToImage(u,h,r.image,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}async exportToBuffers(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),l=globalThis.platform;globalThis.platform=o;let c=null;try{if(c=await Pe(),!c)throw new Error("Failed to create browser renderer. Puppeteer is required for image export.");await c.initialize();let
|
|
970
|
-
`+nt(
|
|
971
|
-
`+
|
|
972
|
-
`+p;return await c.exportToImageParts(u,h,r.image,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}},We=class{async exportToString(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),o=r.diagramMode||"live",{platform:l}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),c=globalThis.platform;globalThis.platform=l;let
|
|
1162
|
+
`}function lt(){let e=be(),t=F.join(e,"vendor","katex","katex.min.css"),r=t;ne.existsSync(t)||(r=un(import.meta.url).resolve("katex/dist/katex.min.css"));let i=F.dirname(r),n=we(F.join(i,"fonts")+F.sep).href,a=ne.readFileSync(r,"utf-8");return a=a.replace(/url\((['"]?)(?:\.\/)?fonts\//g,`url($1${n}`),a}var st=class{async exportToBuffer(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),l=globalThis.platform;globalThis.platform=o;let c=null;try{if(c=await Pe(),!c)throw new Error("Failed to create browser renderer. Puppeteer is required for PDF export.");await c.initialize();let m=await Ue(i),s=r.diagramMode??"img",u=await rt(t,c,n,m,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+F.sep).href,b=ze(u,n,r.templatesDir);u=u+`
|
|
1163
|
+
`+nt(m??null,x,r.cdn,b)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for PDF export:",x)}let d=await at(r.hrAsPageBreak??!0),p="";try{p=await ot(i)}catch(x){console.warn("Failed to load theme CSS, using base styles only:",x)}let h=f+`
|
|
1164
|
+
`+d+`
|
|
1165
|
+
`+p;return await c.exportToPdf(u,h,r.pdf,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}},Ve=class{async exportToBuffer(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),l=globalThis.platform;globalThis.platform=o;let c=null;try{if(c=await Pe(),!c)throw new Error("Failed to create browser renderer. Puppeteer is required for image export.");await c.initialize();let m=await Ue(i),s=r.diagramMode??"live",u=await rt(t,c,n,m,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+F.sep).href,b=ze(u,n,r.templatesDir);u=u+`
|
|
1166
|
+
`+nt(m??null,x,r.cdn,b)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for image export:",x)}let d=await at(r.hrAsPageBreak??!1),p="";try{p=await ot(i)}catch(x){console.warn("Failed to load theme CSS, using base styles only:",x)}let h=f+`
|
|
1167
|
+
`+d+`
|
|
1168
|
+
`+p;return await c.exportToImage(u,h,r.image,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}async exportToBuffers(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),{platform:o}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),l=globalThis.platform;globalThis.platform=o;let c=null;try{if(c=await Pe(),!c)throw new Error("Failed to create browser renderer. Puppeteer is required for image export.");await c.initialize();let m=await Ue(i),s=r.diagramMode??"live",u=await rt(t,c,n,m,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+F.sep).href,b=ze(u,n,r.templatesDir);u=u+`
|
|
1169
|
+
`+nt(m??null,x,r.cdn,b)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for image export:",x)}let d=await at(r.hrAsPageBreak??!1),p="";try{p=await ot(i)}catch(x){console.warn("Failed to load theme CSS, using base styles only:",x)}let h=f+`
|
|
1170
|
+
`+d+`
|
|
1171
|
+
`+p;return await c.exportToImageParts(u,h,r.image,n)}finally{try{c&&await c.close()}finally{globalThis.platform=l}}}},We=class{async exportToString(t,r={}){$e();let i=r.theme||"default",n=r.basePath??process.cwd(),a=be(),o=r.diagramMode||"live",{platform:l}=_e({moduleDir:a,selectedThemeId:i,output:{kind:"buffer"}}),c=globalThis.platform;globalThis.platform=l;let m=null;try{let s=await Ue(i);o==="img"&&(m=await Pe(),m&&await m.initialize());let u=await rt(t,m,n,s,o,r.templatesDir,r.cdn);if(!(r.standalone!==!1))return u;let d="";try{d=lt()}catch(C){console.warn("Failed to load KaTeX CSS for HTML export:",C)}let p=await at(r.hrAsPageBreak??!1),h="";try{h=await ot(i)}catch(C){console.warn("Failed to load theme CSS for HTML export, using base styles only:",C)}let x=d+`
|
|
973
1172
|
`+p+`
|
|
974
|
-
`+h,b=r.title||"Document",
|
|
975
|
-
`:"",
|
|
1173
|
+
`+h,b=r.title||"Document",Y=r.baseTag!==!1&&!!n?we(n+F.sep).href:"",S=Y?` <base href="${tt(Y)}" />
|
|
1174
|
+
`:"",L=o==="live"?nt(s??null,Y,r.cdn,ze(u,n,r.templatesDir)):"";return`<!DOCTYPE html>
|
|
976
1175
|
<html lang="en">
|
|
977
1176
|
<head>
|
|
978
1177
|
<meta charset="UTF-8" />
|
|
@@ -982,40 +1181,40 @@ ${S} <title>${tt(b)}</title>
|
|
|
982
1181
|
</head>
|
|
983
1182
|
<body>
|
|
984
1183
|
<div id="markdown-content" class="markdown-body">${u}</div>
|
|
985
|
-
${
|
|
1184
|
+
${L}
|
|
986
1185
|
</body>
|
|
987
|
-
</html>`}finally{try{
|
|
988
|
-
|
|
989
|
-
`+e.mark.snippet),i+" "+r):i}function
|
|
990
|
-
`+l;for(
|
|
991
|
-
`,l+=H.repeat("-",t.indent+s+3+
|
|
992
|
-
`,c=1;c<=t.linesAfter&&!(o+c>=n.length);c++)
|
|
993
|
-
`;return l.replace(/\n$/,"")}var
|
|
994
|
-
\r`;function ei(e){if(e===null)return!1;var t,r,i=0,n=e.length,a=
|
|
995
|
-
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function vi(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Fr(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[t]=r}var kr=new Array(256),Er=new Array(256);for(Fe=0;Fe<256;Fe++)kr[Fe]=
|
|
996
|
-
`,t-1))}function Ci(e,t,r){var i,n,a,o,l,c,
|
|
1186
|
+
</html>`}finally{try{m&&await m.close()}finally{globalThis.platform=c}}}async exportToBuffer(t,r={}){let i=await this.exportToString(t,r);return Buffer.from(i,"utf8")}};import*as ue from"fs";import*as q from"path";function rr(e){return typeof e>"u"||e===null}function pn(e){return typeof e=="object"&&e!==null}function hn(e){return Array.isArray(e)?e:rr(e)?[]:[e]}function gn(e,t){var r,i,n,a;if(t)for(a=Object.keys(t),r=0,i=a.length;r<i;r+=1)n=a[r],e[n]=t[n];return e}function xn(e,t){var r="",i;for(i=0;i<t;i+=1)r+=e;return r}function yn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var wn=rr,bn=pn,vn=hn,Sn=xn,Cn=yn,Mn=gn,H={isNothing:wn,isObject:bn,toArray:vn,repeat:Sn,isNegativeZero:Cn,extend:Mn};function nr(e,t){var r="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(r+=`
|
|
1187
|
+
|
|
1188
|
+
`+e.mark.snippet),i+" "+r):i}function Ye(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=nr(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Ye.prototype=Object.create(Error.prototype);Ye.prototype.constructor=Ye;Ye.prototype.toString=function(t){return this.name+": "+nr(this,t)};var J=Ye;function yt(e,t,r,i,n){var a="",o="",l=Math.floor(n/2)-1;return i-t>l&&(a=" ... ",t=i-l+a.length),r-i>l&&(o=" ...",r=i+l-o.length),{str:a+e.slice(t,r).replace(/\t/g,"\u2192")+o,pos:i-t+a.length}}function wt(e,t){return H.repeat(" ",t-e.length)+e}function Tn(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var r=/\r?\n|\r|\0/g,i=[0],n=[],a,o=-1;a=r.exec(e.buffer);)n.push(a.index),i.push(a.index+a[0].length),e.position<=a.index&&o<0&&(o=i.length-2);o<0&&(o=i.length-1);var l="",c,m,s=Math.min(e.line+t.linesAfter,n.length).toString().length,u=t.maxLength-(t.indent+s+3);for(c=1;c<=t.linesBefore&&!(o-c<0);c++)m=yt(e.buffer,i[o-c],n[o-c],e.position-(i[o]-i[o-c]),u),l=H.repeat(" ",t.indent)+wt((e.line-c+1).toString(),s)+" | "+m.str+`
|
|
1189
|
+
`+l;for(m=yt(e.buffer,i[o],n[o],e.position,u),l+=H.repeat(" ",t.indent)+wt((e.line+1).toString(),s)+" | "+m.str+`
|
|
1190
|
+
`,l+=H.repeat("-",t.indent+s+3+m.pos)+`^
|
|
1191
|
+
`,c=1;c<=t.linesAfter&&!(o+c>=n.length);c++)m=yt(e.buffer,i[o+c],n[o+c],e.position-(i[o]-i[o+c]),u),l+=H.repeat(" ",t.indent)+wt((e.line+c+1).toString(),s)+" | "+m.str+`
|
|
1192
|
+
`;return l.replace(/\n$/,"")}var An=Tn,Fn=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],kn=["scalar","sequence","mapping"];function En(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){t[String(i)]=r})}),t}function Pn(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(Fn.indexOf(r)===-1)throw new J('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=En(t.styleAliases||null),kn.indexOf(this.kind)===-1)throw new J('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var z=Pn;function $t(e,t){var r=[];return e[t].forEach(function(i){var n=r.length;r.forEach(function(a,o){a.tag===i.tag&&a.kind===i.kind&&a.multi===i.multi&&(n=o)}),r[n]=i}),r}function _n(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,r;function i(n){n.multi?(e.multi[n.kind].push(n),e.multi.fallback.push(n)):e[n.kind][n.tag]=e.fallback[n.tag]=n}for(t=0,r=arguments.length;t<r;t+=1)arguments[t].forEach(i);return e}function vt(e){return this.extend(e)}vt.prototype.extend=function(t){var r=[],i=[];if(t instanceof z)i.push(t);else if(Array.isArray(t))i=i.concat(t);else if(t&&(Array.isArray(t.implicit)||Array.isArray(t.explicit)))t.implicit&&(r=r.concat(t.implicit)),t.explicit&&(i=i.concat(t.explicit));else throw new J("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(a){if(!(a instanceof z))throw new J("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new J("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(a.multi)throw new J("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),i.forEach(function(a){if(!(a instanceof z))throw new J("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var n=Object.create(vt.prototype);return n.implicit=(this.implicit||[]).concat(r),n.explicit=(this.explicit||[]).concat(i),n.compiledImplicit=$t(n,"implicit"),n.compiledExplicit=$t(n,"explicit"),n.compiledTypeMap=_n(n.compiledImplicit,n.compiledExplicit),n};var ir=vt,or=new z("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ar=new z("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),lr=new z("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),sr=new ir({explicit:[or,ar,lr]});function On(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function jn(){return null}function Ln(e){return e===null}var cr=new z("tag:yaml.org,2002:null",{kind:"scalar",resolve:On,construct:jn,predicate:Ln,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Bn(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function In(e){return e==="true"||e==="True"||e==="TRUE"}function Rn(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var ur=new z("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Bn,construct:In,predicate:Rn,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function Dn(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function Nn(e){return 48<=e&&e<=55}function Hn(e){return 48<=e&&e<=57}function $n(e){if(e===null)return!1;var t=e.length,r=0,i=!1,n;if(!t)return!1;if(n=e[r],(n==="-"||n==="+")&&(n=e[++r]),n==="0"){if(r+1===t)return!0;if(n=e[++r],n==="b"){for(r++;r<t;r++)if(n=e[r],n!=="_"){if(n!=="0"&&n!=="1")return!1;i=!0}return i&&n!=="_"}if(n==="x"){for(r++;r<t;r++)if(n=e[r],n!=="_"){if(!Dn(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}if(n==="o"){for(r++;r<t;r++)if(n=e[r],n!=="_"){if(!Nn(e.charCodeAt(r)))return!1;i=!0}return i&&n!=="_"}}if(n==="_")return!1;for(;r<t;r++)if(n=e[r],n!=="_"){if(!Hn(e.charCodeAt(r)))return!1;i=!0}return!(!i||n==="_")}function Un(e){var t=e,r=1,i;if(t.indexOf("_")!==-1&&(t=t.replace(/_/g,"")),i=t[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),t=t.slice(1),i=t[0]),t==="0")return 0;if(i==="0"){if(t[1]==="b")return r*parseInt(t.slice(2),2);if(t[1]==="x")return r*parseInt(t.slice(2),16);if(t[1]==="o")return r*parseInt(t.slice(2),8)}return r*parseInt(t,10)}function zn(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!H.isNegativeZero(e)}var fr=new z("tag:yaml.org,2002:int",{kind:"scalar",resolve:$n,construct:Un,predicate:zn,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),Vn=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function Wn(e){return!(e===null||!Vn.test(e)||e[e.length-1]==="_")}function qn(e){var t,r;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:r*parseFloat(t,10)}var Yn=/^[-+]?[0-9]+e/;function Gn(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(H.isNegativeZero(e))return"-0.0";return r=e.toString(10),Yn.test(r)?r.replace("e",".e"):r}function Kn(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||H.isNegativeZero(e))}var mr=new z("tag:yaml.org,2002:float",{kind:"scalar",resolve:Wn,construct:qn,predicate:Kn,represent:Gn,defaultStyle:"lowercase"}),dr=sr.extend({implicit:[cr,ur,fr,mr]}),pr=dr,hr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),gr=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Xn(e){return e===null?!1:hr.exec(e)!==null||gr.exec(e)!==null}function Jn(e){var t,r,i,n,a,o,l,c=0,m=null,s,u,f;if(t=hr.exec(e),t===null&&(t=gr.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],i=+t[2]-1,n=+t[3],!t[4])return new Date(Date.UTC(r,i,n));if(a=+t[4],o=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(s=+t[10],u=+(t[11]||0),m=(s*60+u)*6e4,t[9]==="-"&&(m=-m)),f=new Date(Date.UTC(r,i,n,a,o,l,c)),m&&f.setTime(f.getTime()-m),f}function Qn(e){return e.toISOString()}var xr=new z("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Xn,construct:Jn,instanceOf:Date,represent:Qn});function Zn(e){return e==="<<"||e===null}var yr=new z("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Zn}),At=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
1193
|
+
\r`;function ei(e){if(e===null)return!1;var t,r,i=0,n=e.length,a=At;for(r=0;r<n;r++)if(t=a.indexOf(e.charAt(r)),!(t>64)){if(t<0)return!1;i+=6}return i%8===0}function ti(e){var t,r,i=e.replace(/[\r\n=]/g,""),n=i.length,a=At,o=0,l=[];for(t=0;t<n;t++)t%4===0&&t&&(l.push(o>>16&255),l.push(o>>8&255),l.push(o&255)),o=o<<6|a.indexOf(i.charAt(t));return r=n%4*6,r===0?(l.push(o>>16&255),l.push(o>>8&255),l.push(o&255)):r===18?(l.push(o>>10&255),l.push(o>>2&255)):r===12&&l.push(o>>4&255),new Uint8Array(l)}function ri(e){var t="",r=0,i,n,a=e.length,o=At;for(i=0;i<a;i++)i%3===0&&i&&(t+=o[r>>18&63],t+=o[r>>12&63],t+=o[r>>6&63],t+=o[r&63]),r=(r<<8)+e[i];return n=a%3,n===0?(t+=o[r>>18&63],t+=o[r>>12&63],t+=o[r>>6&63],t+=o[r&63]):n===2?(t+=o[r>>10&63],t+=o[r>>4&63],t+=o[r<<2&63],t+=o[64]):n===1&&(t+=o[r>>2&63],t+=o[r<<4&63],t+=o[64],t+=o[64]),t}function ni(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var wr=new z("tag:yaml.org,2002:binary",{kind:"scalar",resolve:ei,construct:ti,predicate:ni,represent:ri}),ii=Object.prototype.hasOwnProperty,oi=Object.prototype.toString;function ai(e){if(e===null)return!0;var t=[],r,i,n,a,o,l=e;for(r=0,i=l.length;r<i;r+=1){if(n=l[r],o=!1,oi.call(n)!=="[object Object]")return!1;for(a in n)if(ii.call(n,a))if(!o)o=!0;else return!1;if(!o)return!1;if(t.indexOf(a)===-1)t.push(a);else return!1}return!0}function li(e){return e!==null?e:[]}var br=new z("tag:yaml.org,2002:omap",{kind:"sequence",resolve:ai,construct:li}),si=Object.prototype.toString;function ci(e){if(e===null)return!0;var t,r,i,n,a,o=e;for(a=new Array(o.length),t=0,r=o.length;t<r;t+=1){if(i=o[t],si.call(i)!=="[object Object]"||(n=Object.keys(i),n.length!==1))return!1;a[t]=[n[0],i[n[0]]]}return!0}function ui(e){if(e===null)return[];var t,r,i,n,a,o=e;for(a=new Array(o.length),t=0,r=o.length;t<r;t+=1)i=o[t],n=Object.keys(i),a[t]=[n[0],i[n[0]]];return a}var vr=new z("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:ci,construct:ui}),fi=Object.prototype.hasOwnProperty;function mi(e){if(e===null)return!0;var t,r=e;for(t in r)if(fi.call(r,t)&&r[t]!==null)return!1;return!0}function di(e){return e!==null?e:{}}var Sr=new z("tag:yaml.org,2002:set",{kind:"mapping",resolve:mi,construct:di}),Ft=pr.extend({implicit:[xr,yr],explicit:[wr,br,vr,Sr]}),Se=Object.prototype.hasOwnProperty,ct=1,Cr=2,Mr=3,ut=4,bt=1,pi=2,Ut=3,hi=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,gi=/[\x85\u2028\u2029]/,xi=/[,\[\]\{\}]/,Tr=/^(?:!|!!|![a-z\-]+!)$/i,Ar=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function zt(e){return Object.prototype.toString.call(e)}function ce(e){return e===10||e===13}function ke(e){return e===9||e===32}function Q(e){return e===9||e===32||e===10||e===13}function je(e){return e===44||e===91||e===93||e===123||e===125}function yi(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function wi(e){return e===120?2:e===117?4:e===85?8:0}function bi(e){return 48<=e&&e<=57?e-48:-1}function Vt(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
1194
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function vi(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function Fr(e,t,r){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[t]=r}var kr=new Array(256),Er=new Array(256);for(Fe=0;Fe<256;Fe++)kr[Fe]=Vt(Fe)?1:0,Er[Fe]=Vt(Fe);var Fe;function Si(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||Ft,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function Pr(e,t){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=An(r),new J(t,r)}function y(e,t){throw Pr(e,t)}function ft(e,t){e.onWarning&&e.onWarning.call(null,Pr(e,t))}var Wt={YAML:function(t,r,i){var n,a,o;t.version!==null&&y(t,"duplication of %YAML directive"),i.length!==1&&y(t,"YAML directive accepts exactly one argument"),n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),n===null&&y(t,"ill-formed argument of the YAML directive"),a=parseInt(n[1],10),o=parseInt(n[2],10),a!==1&&y(t,"unacceptable YAML version of the document"),t.version=i[0],t.checkLineBreaks=o<2,o!==1&&o!==2&&ft(t,"unsupported YAML version of the document")},TAG:function(t,r,i){var n,a;i.length!==2&&y(t,"TAG directive accepts exactly two arguments"),n=i[0],a=i[1],Tr.test(n)||y(t,"ill-formed tag handle (first argument) of the TAG directive"),Se.call(t.tagMap,n)&&y(t,'there is a previously declared suffix for "'+n+'" tag handle'),Ar.test(a)||y(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{y(t,"tag prefix is malformed: "+a)}t.tagMap[n]=a}};function ve(e,t,r,i){var n,a,o,l;if(t<r){if(l=e.input.slice(t,r),i)for(n=0,a=l.length;n<a;n+=1)o=l.charCodeAt(n),o===9||32<=o&&o<=1114111||y(e,"expected valid JSON character");else hi.test(l)&&y(e,"the stream contains non-printable characters");e.result+=l}}function qt(e,t,r,i){var n,a,o,l;for(H.isObject(r)||y(e,"cannot merge mappings; the provided source object is unacceptable"),n=Object.keys(r),o=0,l=n.length;o<l;o+=1)a=n[o],Se.call(t,a)||(Fr(t,a,r[a]),i[a]=!0)}function Le(e,t,r,i,n,a,o,l,c){var m,s;if(Array.isArray(n))for(n=Array.prototype.slice.call(n),m=0,s=n.length;m<s;m+=1)Array.isArray(n[m])&&y(e,"nested arrays are not supported inside keys"),typeof n=="object"&&zt(n[m])==="[object Object]"&&(n[m]="[object Object]");if(typeof n=="object"&&zt(n)==="[object Object]"&&(n="[object Object]"),n=String(n),t===null&&(t={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(m=0,s=a.length;m<s;m+=1)qt(e,t,a[m],r);else qt(e,t,a,r);else!e.json&&!Se.call(r,n)&&Se.call(t,n)&&(e.line=o||e.line,e.lineStart=l||e.lineStart,e.position=c||e.position,y(e,"duplicated mapping key")),Fr(t,n,a),delete r[n];return t}function kt(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):y(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function R(e,t,r){for(var i=0,n=e.input.charCodeAt(e.position);n!==0;){for(;ke(n);)n===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),n=e.input.charCodeAt(++e.position);if(t&&n===35)do n=e.input.charCodeAt(++e.position);while(n!==10&&n!==13&&n!==0);if(ce(n))for(kt(e),n=e.input.charCodeAt(e.position),i++,e.lineIndent=0;n===32;)e.lineIndent++,n=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&ft(e,"deficient indentation"),i}function pt(e){var t=e.position,r;return r=e.input.charCodeAt(t),!!((r===45||r===46)&&r===e.input.charCodeAt(t+1)&&r===e.input.charCodeAt(t+2)&&(t+=3,r=e.input.charCodeAt(t),r===0||Q(r)))}function Et(e,t){t===1?e.result+=" ":t>1&&(e.result+=H.repeat(`
|
|
1195
|
+
`,t-1))}function Ci(e,t,r){var i,n,a,o,l,c,m,s,u=e.kind,f=e.result,d;if(d=e.input.charCodeAt(e.position),Q(d)||je(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(n=e.input.charCodeAt(e.position+1),Q(n)||r&&je(n)))return!1;for(e.kind="scalar",e.result="",a=o=e.position,l=!1;d!==0;){if(d===58){if(n=e.input.charCodeAt(e.position+1),Q(n)||r&&je(n))break}else if(d===35){if(i=e.input.charCodeAt(e.position-1),Q(i))break}else{if(e.position===e.lineStart&&pt(e)||r&&je(d))break;if(ce(d))if(c=e.line,m=e.lineStart,s=e.lineIndent,R(e,!1,-1),e.lineIndent>=t){l=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=o,e.line=c,e.lineStart=m,e.lineIndent=s;break}}l&&(ve(e,a,o,!1),Et(e,e.line-c),a=o=e.position,l=!1),ke(d)||(o=e.position+1),d=e.input.charCodeAt(++e.position)}return ve(e,a,o,!1),e.result?!0:(e.kind=u,e.result=f,!1)}function Mi(e,t){var r,i,n;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,i=n=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(ve(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,n=e.position;else return!0;else ce(r)?(ve(e,i,n,!0),Et(e,R(e,!1,t)),i=n=e.position):e.position===e.lineStart&&pt(e)?y(e,"unexpected end of the document within a single quoted scalar"):(e.position++,n=e.position);y(e,"unexpected end of the stream within a single quoted scalar")}function Ti(e,t){var r,i,n,a,o,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return ve(e,r,e.position,!0),e.position++,!0;if(l===92){if(ve(e,r,e.position,!0),l=e.input.charCodeAt(++e.position),ce(l))R(e,!1,t);else if(l<256&&kr[l])e.result+=Er[l],e.position++;else if((o=wi(l))>0){for(n=o,a=0;n>0;n--)l=e.input.charCodeAt(++e.position),(o=yi(l))>=0?a=(a<<4)+o:y(e,"expected hexadecimal character");e.result+=vi(a),e.position++}else y(e,"unknown escape sequence");r=i=e.position}else ce(l)?(ve(e,r,i,!0),Et(e,R(e,!1,t)),r=i=e.position):e.position===e.lineStart&&pt(e)?y(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}y(e,"unexpected end of the stream within a double quoted scalar")}function Ai(e,t){var r=!0,i,n,a,o=e.tag,l,c=e.anchor,m,s,u,f,d,p=Object.create(null),h,x,b,w;if(w=e.input.charCodeAt(e.position),w===91)s=93,d=!1,l=[];else if(w===123)s=125,d=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(R(e,!0,t),w=e.input.charCodeAt(e.position),w===s)return e.position++,e.tag=o,e.anchor=c,e.kind=d?"mapping":"sequence",e.result=l,!0;r?w===44&&y(e,"expected the node content, but found ','"):y(e,"missed comma between flow collection entries"),x=h=b=null,u=f=!1,w===63&&(m=e.input.charCodeAt(e.position+1),Q(m)&&(u=f=!0,e.position++,R(e,!0,t))),i=e.line,n=e.lineStart,a=e.position,Be(e,t,ct,!1,!0),x=e.tag,h=e.result,R(e,!0,t),w=e.input.charCodeAt(e.position),(f||e.line===i)&&w===58&&(u=!0,w=e.input.charCodeAt(++e.position),R(e,!0,t),Be(e,t,ct,!1,!0),b=e.result),d?Le(e,l,p,x,h,b,i,n,a):u?l.push(Le(e,null,p,x,h,b,i,n,a)):l.push(h),R(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(r=!0,w=e.input.charCodeAt(++e.position)):r=!1}y(e,"unexpected end of the stream within a flow collection")}function Fi(e,t){var r,i,n=bt,a=!1,o=!1,l=t,c=0,m=!1,s,u;if(u=e.input.charCodeAt(e.position),u===124)i=!1;else if(u===62)i=!0;else return!1;for(e.kind="scalar",e.result="";u!==0;)if(u=e.input.charCodeAt(++e.position),u===43||u===45)bt===n?n=u===43?Ut:pi:y(e,"repeat of a chomping mode identifier");else if((s=bi(u))>=0)s===0?y(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):o?y(e,"repeat of an indentation width identifier"):(l=t+s-1,o=!0);else break;if(ke(u)){do u=e.input.charCodeAt(++e.position);while(ke(u));if(u===35)do u=e.input.charCodeAt(++e.position);while(!ce(u)&&u!==0)}for(;u!==0;){for(kt(e),e.lineIndent=0,u=e.input.charCodeAt(e.position);(!o||e.lineIndent<l)&&u===32;)e.lineIndent++,u=e.input.charCodeAt(++e.position);if(!o&&e.lineIndent>l&&(l=e.lineIndent),ce(u)){c++;continue}if(e.lineIndent<l){n===Ut?e.result+=H.repeat(`
|
|
997
1196
|
`,a?1+c:c):n===bt&&a&&(e.result+=`
|
|
998
|
-
`);break}for(i?ke(u)?(
|
|
999
|
-
`,a?1+c:c)):
|
|
1197
|
+
`);break}for(i?ke(u)?(m=!0,e.result+=H.repeat(`
|
|
1198
|
+
`,a?1+c:c)):m?(m=!1,e.result+=H.repeat(`
|
|
1000
1199
|
`,c+1)):c===0?a&&(e.result+=" "):e.result+=H.repeat(`
|
|
1001
1200
|
`,c):e.result+=H.repeat(`
|
|
1002
|
-
`,a?1+c:c),a=!0,o=!0,c=0,r=e.position;!ce(u)&&u!==0;)u=e.input.charCodeAt(++e.position);ve(e,r,e.position,!1)}return!0}function
|
|
1003
|
-
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Si(e,t),i=e.indexOf("\0");for(i!==-1&&(r.position=i,y(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)Oi(r);return r.documents}function
|
|
1201
|
+
`,a?1+c:c),a=!0,o=!0,c=0,r=e.position;!ce(u)&&u!==0;)u=e.input.charCodeAt(++e.position);ve(e,r,e.position,!1)}return!0}function Yt(e,t){var r,i=e.tag,n=e.anchor,a=[],o,l=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,y(e,"tab characters must not be used in indentation")),!(c!==45||(o=e.input.charCodeAt(e.position+1),!Q(o))));){if(l=!0,e.position++,R(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(r=e.line,Be(e,t,Mr,!1,!0),a.push(e.result),R(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&c!==0)y(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=i,e.anchor=n,e.kind="sequence",e.result=a,!0):!1}function ki(e,t,r){var i,n,a,o,l,c,m=e.tag,s=e.anchor,u={},f=Object.create(null),d=null,p=null,h=null,x=!1,b=!1,w;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=u),w=e.input.charCodeAt(e.position);w!==0;){if(!x&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,y(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),a=e.line,(w===63||w===58)&&Q(i))w===63?(x&&(Le(e,u,f,d,p,null,o,l,c),d=p=h=null),b=!0,x=!0,n=!0):x?(x=!1,n=!0):y(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,w=i;else{if(o=e.line,l=e.lineStart,c=e.position,!Be(e,r,Cr,!1,!0))break;if(e.line===a){for(w=e.input.charCodeAt(e.position);ke(w);)w=e.input.charCodeAt(++e.position);if(w===58)w=e.input.charCodeAt(++e.position),Q(w)||y(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(Le(e,u,f,d,p,null,o,l,c),d=p=h=null),b=!0,x=!1,n=!1,d=e.tag,p=e.result;else if(b)y(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=m,e.anchor=s,!0}else if(b)y(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=m,e.anchor=s,!0}if((e.line===a||e.lineIndent>t)&&(x&&(o=e.line,l=e.lineStart,c=e.position),Be(e,t,ut,!0,n)&&(x?p=e.result:h=e.result),x||(Le(e,u,f,d,p,h,o,l,c),d=p=h=null),R(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&w!==0)y(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return x&&Le(e,u,f,d,p,null,o,l,c),b&&(e.tag=m,e.anchor=s,e.kind="mapping",e.result=u),b}function Ei(e){var t,r=!1,i=!1,n,a,o;if(o=e.input.charCodeAt(e.position),o!==33)return!1;if(e.tag!==null&&y(e,"duplication of a tag property"),o=e.input.charCodeAt(++e.position),o===60?(r=!0,o=e.input.charCodeAt(++e.position)):o===33?(i=!0,n="!!",o=e.input.charCodeAt(++e.position)):n="!",t=e.position,r){do o=e.input.charCodeAt(++e.position);while(o!==0&&o!==62);e.position<e.length?(a=e.input.slice(t,e.position),o=e.input.charCodeAt(++e.position)):y(e,"unexpected end of the stream within a verbatim tag")}else{for(;o!==0&&!Q(o);)o===33&&(i?y(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),Tr.test(n)||y(e,"named tag handle cannot contain such characters"),i=!0,t=e.position+1)),o=e.input.charCodeAt(++e.position);a=e.input.slice(t,e.position),xi.test(a)&&y(e,"tag suffix cannot contain flow indicator characters")}a&&!Ar.test(a)&&y(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{y(e,"tag name is malformed: "+a)}return r?e.tag=a:Se.call(e.tagMap,n)?e.tag=e.tagMap[n]+a:n==="!"?e.tag="!"+a:n==="!!"?e.tag="tag:yaml.org,2002:"+a:y(e,'undeclared tag handle "'+n+'"'),!0}function Pi(e){var t,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;for(e.anchor!==null&&y(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!Q(r)&&!je(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&y(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function _i(e){var t,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;for(i=e.input.charCodeAt(++e.position),t=e.position;i!==0&&!Q(i)&&!je(i);)i=e.input.charCodeAt(++e.position);return e.position===t&&y(e,"name of an alias node must contain at least one character"),r=e.input.slice(t,e.position),Se.call(e.anchorMap,r)||y(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],R(e,!0,-1),!0}function Be(e,t,r,i,n){var a,o,l,c=1,m=!1,s=!1,u,f,d,p,h,x;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,a=o=l=ut===r||Mr===r,i&&R(e,!0,-1)&&(m=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;Ei(e)||Pi(e);)R(e,!0,-1)?(m=!0,l=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=m||n),(c===1||ut===r)&&(ct===r||Cr===r?h=t:h=t+1,x=e.position-e.lineStart,c===1?l&&(Yt(e,x)||ki(e,x,h))||Ai(e,h)?s=!0:(o&&Fi(e,h)||Mi(e,h)||Ti(e,h)?s=!0:_i(e)?(s=!0,(e.tag!==null||e.anchor!==null)&&y(e,"alias node should not have any properties")):Ci(e,h,ct===r)&&(s=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(s=l&&Yt(e,x))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&y(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),u=0,f=e.implicitTypes.length;u<f;u+=1)if(p=e.implicitTypes[u],p.resolve(e.result)){e.result=p.construct(e.result),e.tag=p.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(Se.call(e.typeMap[e.kind||"fallback"],e.tag))p=e.typeMap[e.kind||"fallback"][e.tag];else for(p=null,d=e.typeMap.multi[e.kind||"fallback"],u=0,f=d.length;u<f;u+=1)if(e.tag.slice(0,d[u].tag.length)===d[u].tag){p=d[u];break}p||y(e,"unknown tag !<"+e.tag+">"),e.result!==null&&p.kind!==e.kind&&y(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+p.kind+'", not "'+e.kind+'"'),p.resolve(e.result,e.tag)?(e.result=p.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):y(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||s}function Oi(e){var t=e.position,r,i,n,a=!1,o;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(o=e.input.charCodeAt(e.position))!==0&&(R(e,!0,-1),o=e.input.charCodeAt(e.position),!(e.lineIndent>0||o!==37));){for(a=!0,o=e.input.charCodeAt(++e.position),r=e.position;o!==0&&!Q(o);)o=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),n=[],i.length<1&&y(e,"directive name must not be less than one character in length");o!==0;){for(;ke(o);)o=e.input.charCodeAt(++e.position);if(o===35){do o=e.input.charCodeAt(++e.position);while(o!==0&&!ce(o));break}if(ce(o))break;for(r=e.position;o!==0&&!Q(o);)o=e.input.charCodeAt(++e.position);n.push(e.input.slice(r,e.position))}o!==0&&kt(e),Se.call(Wt,i)?Wt[i](e,i,n):ft(e,'unknown document directive "'+i+'"')}if(R(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,R(e,!0,-1)):a&&y(e,"directives end mark is expected"),Be(e,e.lineIndent-1,ut,!1,!0),R(e,!0,-1),e.checkLineBreaks&&gi.test(e.input.slice(t,e.position))&&ft(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&pt(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,R(e,!0,-1));return}if(e.position<e.length-1)y(e,"end of the stream or a document separator is expected");else return}function _r(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
|
|
1202
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Si(e,t),i=e.indexOf("\0");for(i!==-1&&(r.position=i,y(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)Oi(r);return r.documents}function ji(e,t,r){t!==null&&typeof t=="object"&&typeof r>"u"&&(r=t,t=null);var i=_r(e,r);if(typeof t!="function")return i;for(var n=0,a=i.length;n<a;n+=1)t(i[n])}function Li(e,t){var r=_r(e,t);if(r.length!==0){if(r.length===1)return r[0];throw new J("expected a single document in the stream, but found more")}}var Bi=ji,Ii=Li,Or={loadAll:Bi,load:Ii},jr=Object.prototype.toString,Lr=Object.prototype.hasOwnProperty,Pt=65279,Ri=9,Ge=10,Di=13,Ni=32,Hi=33,$i=34,St=35,Ui=37,zi=38,Vi=39,Wi=42,Br=44,qi=45,mt=58,Yi=61,Gi=62,Ki=63,Xi=64,Ir=91,Rr=93,Ji=96,Dr=123,Qi=124,Nr=125,W={};W[0]="\\0";W[7]="\\a";W[8]="\\b";W[9]="\\t";W[10]="\\n";W[11]="\\v";W[12]="\\f";W[13]="\\r";W[27]="\\e";W[34]='\\"';W[92]="\\\\";W[133]="\\N";W[160]="\\_";W[8232]="\\L";W[8233]="\\P";var Zi=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],eo=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function to(e,t){var r,i,n,a,o,l,c;if(t===null)return{};for(r={},i=Object.keys(t),n=0,a=i.length;n<a;n+=1)o=i[n],l=String(t[o]),o.slice(0,2)==="!!"&&(o="tag:yaml.org,2002:"+o.slice(2)),c=e.compiledTypeMap.fallback[o],c&&Lr.call(c.styleAliases,l)&&(l=c.styleAliases[l]),r[o]=l;return r}function ro(e){var t,r,i;if(t=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new J("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+H.repeat("0",i-t.length)+t}var no=1,Ke=2;function io(e){this.schema=e.schema||Ft,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=H.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=to(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Ke:no,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Gt(e,t){for(var r=H.repeat(" ",t),i=0,n=-1,a="",o,l=e.length;i<l;)n=e.indexOf(`
|
|
1004
1203
|
`,i),n===-1?(o=e.slice(i),i=l):(o=e.slice(i,n+1),i=n+1),o.length&&o!==`
|
|
1005
1204
|
`&&(a+=r),a+=o;return a}function Ct(e,t){return`
|
|
1006
|
-
`+H.repeat(" ",e.indent*t)}function oo(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return!0;return!1}function
|
|
1205
|
+
`+H.repeat(" ",e.indent*t)}function oo(e,t){var r,i,n;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(n=e.implicitTypes[r],n.resolve(t))return!0;return!1}function dt(e){return e===Ni||e===Ri}function Xe(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Pt||65536<=e&&e<=1114111}function Kt(e){return Xe(e)&&e!==Pt&&e!==Di&&e!==Ge}function Xt(e,t,r){var i=Kt(e),n=i&&!dt(e);return(r?i:i&&e!==Br&&e!==Ir&&e!==Rr&&e!==Dr&&e!==Nr)&&e!==St&&!(t===mt&&!n)||Kt(t)&&!dt(t)&&e===St||t===mt&&n}function ao(e){return Xe(e)&&e!==Pt&&!dt(e)&&e!==qi&&e!==Ki&&e!==mt&&e!==Br&&e!==Ir&&e!==Rr&&e!==Dr&&e!==Nr&&e!==St&&e!==zi&&e!==Wi&&e!==Hi&&e!==Qi&&e!==Yi&&e!==Gi&&e!==Vi&&e!==$i&&e!==Ui&&e!==Xi&&e!==Ji}function lo(e){return!dt(e)&&e!==mt}function qe(e,t){var r=e.charCodeAt(t),i;return r>=55296&&r<=56319&&t+1<e.length&&(i=e.charCodeAt(t+1),i>=56320&&i<=57343)?(r-55296)*1024+i-56320+65536:r}function Hr(e){var t=/^\n* /;return t.test(e)}var $r=1,Mt=2,Ur=3,zr=4,Oe=5;function so(e,t,r,i,n,a,o,l){var c,m=0,s=null,u=!1,f=!1,d=i!==-1,p=-1,h=ao(qe(e,0))&&lo(qe(e,e.length-1));if(t||o)for(c=0;c<e.length;m>=65536?c+=2:c++){if(m=qe(e,c),!Xe(m))return Oe;h=h&&Xt(m,s,l),s=m}else{for(c=0;c<e.length;m>=65536?c+=2:c++){if(m=qe(e,c),m===Ge)u=!0,d&&(f=f||c-p-1>i&&e[p+1]!==" ",p=c);else if(!Xe(m))return Oe;h=h&&Xt(m,s,l),s=m}f=f||d&&c-p-1>i&&e[p+1]!==" "}return!u&&!f?h&&!o&&!n(e)?$r:a===Ke?Oe:Mt:r>9&&Hr(e)?Oe:o?a===Ke?Oe:Mt:f?zr:Ur}function co(e,t,r,i,n){e.dump=(function(){if(t.length===0)return e.quotingType===Ke?'""':"''";if(!e.noCompatMode&&(Zi.indexOf(t)!==-1||eo.test(t)))return e.quotingType===Ke?'"'+t+'"':"'"+t+"'";var a=e.indent*Math.max(1,r),o=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-a),l=i||e.flowLevel>-1&&r>=e.flowLevel;function c(m){return oo(e,m)}switch(so(t,l,e.indent,o,c,e.quotingType,e.forceQuotes&&!i,n)){case $r:return t;case Mt:return"'"+t.replace(/'/g,"''")+"'";case Ur:return"|"+Jt(t,e.indent)+Qt(Gt(t,a));case zr:return">"+Jt(t,e.indent)+Qt(Gt(uo(t,o),a));case Oe:return'"'+fo(t)+'"';default:throw new J("impossible error: invalid scalar style")}})()}function Jt(e,t){var r=Hr(e)?String(t):"",i=e[e.length-1]===`
|
|
1007
1206
|
`,n=i&&(e[e.length-2]===`
|
|
1008
1207
|
`||e===`
|
|
1009
1208
|
`),a=n?"+":i?"":"-";return r+a+`
|
|
1010
1209
|
`}function Qt(e){return e[e.length-1]===`
|
|
1011
|
-
`?e.slice(0,-1):e}function uo(e,t){for(var r=/(\n+)([^\n]*)/g,i=(function(){var
|
|
1012
|
-
`);return
|
|
1210
|
+
`?e.slice(0,-1):e}function uo(e,t){for(var r=/(\n+)([^\n]*)/g,i=(function(){var m=e.indexOf(`
|
|
1211
|
+
`);return m=m!==-1?m:e.length,r.lastIndex=m,Zt(e.slice(0,m),t)})(),n=e[0]===`
|
|
1013
1212
|
`||e[0]===" ",a,o;o=r.exec(e);){var l=o[1],c=o[2];a=c[0]===" ",i+=l+(!n&&!a&&c!==""?`
|
|
1014
1213
|
`:"")+Zt(c,t),n=a}return i}function Zt(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,n=0,a,o=0,l=0,c="";i=r.exec(e);)l=i.index,l-n>t&&(a=o>n?o:l,c+=`
|
|
1015
1214
|
`+e.slice(n,a),n=a+1),o=l;return c+=`
|
|
1016
1215
|
`,e.length-n>t&&o>n?c+=e.slice(n,o)+`
|
|
1017
|
-
`+e.slice(o+1):c+=e.slice(n),c.slice(1)}function fo(e){for(var t="",r=0,i,n=0;n<e.length;r>=65536?n+=2:n++)r=
|
|
1018
|
-
`:""}var yo=xo,wo={dump:yo};function _t(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var bo=z,vo=ir,So=sr,Co=
|
|
1216
|
+
`+e.slice(o+1):c+=e.slice(n),c.slice(1)}function fo(e){for(var t="",r=0,i,n=0;n<e.length;r>=65536?n+=2:n++)r=qe(e,n),i=W[r],!i&&Xe(r)?(t+=e[n],r>=65536&&(t+=e[n+1])):t+=i||ro(r);return t}function mo(e,t,r){var i="",n=e.tag,a,o,l;for(a=0,o=r.length;a<o;a+=1)l=r[a],e.replacer&&(l=e.replacer.call(r,String(a),l)),(ge(e,t,l,!1,!1)||typeof l>"u"&&ge(e,t,null,!1,!1))&&(i!==""&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=n,e.dump="["+i+"]"}function er(e,t,r,i){var n="",a=e.tag,o,l,c;for(o=0,l=r.length;o<l;o+=1)c=r[o],e.replacer&&(c=e.replacer.call(r,String(o),c)),(ge(e,t+1,c,!0,!0,!1,!0)||typeof c>"u"&&ge(e,t+1,null,!0,!0,!1,!0))&&((!i||n!=="")&&(n+=Ct(e,t)),e.dump&&Ge===e.dump.charCodeAt(0)?n+="-":n+="- ",n+=e.dump);e.tag=a,e.dump=n||"[]"}function po(e,t,r){var i="",n=e.tag,a=Object.keys(r),o,l,c,m,s;for(o=0,l=a.length;o<l;o+=1)s="",i!==""&&(s+=", "),e.condenseFlow&&(s+='"'),c=a[o],m=r[c],e.replacer&&(m=e.replacer.call(r,c,m)),ge(e,t,c,!1,!1)&&(e.dump.length>1024&&(s+="? "),s+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ge(e,t,m,!1,!1)&&(s+=e.dump,i+=s));e.tag=n,e.dump="{"+i+"}"}function ho(e,t,r,i){var n="",a=e.tag,o=Object.keys(r),l,c,m,s,u,f;if(e.sortKeys===!0)o.sort();else if(typeof e.sortKeys=="function")o.sort(e.sortKeys);else if(e.sortKeys)throw new J("sortKeys must be a boolean or a function");for(l=0,c=o.length;l<c;l+=1)f="",(!i||n!=="")&&(f+=Ct(e,t)),m=o[l],s=r[m],e.replacer&&(s=e.replacer.call(r,m,s)),ge(e,t+1,m,!0,!0,!0)&&(u=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,u&&(e.dump&&Ge===e.dump.charCodeAt(0)?f+="?":f+="? "),f+=e.dump,u&&(f+=Ct(e,t)),ge(e,t+1,s,!0,u)&&(e.dump&&Ge===e.dump.charCodeAt(0)?f+=":":f+=": ",f+=e.dump,n+=f));e.tag=a,e.dump=n||"{}"}function tr(e,t,r){var i,n,a,o,l,c;for(n=r?e.explicitTypes:e.implicitTypes,a=0,o=n.length;a<o;a+=1)if(l=n[a],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(r?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(c=e.styleMap[l.tag]||l.defaultStyle,jr.call(l.represent)==="[object Function]")i=l.represent(t,c);else if(Lr.call(l.represent,c))i=l.represent[c](t,c);else throw new J("!<"+l.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function ge(e,t,r,i,n,a,o){e.tag=null,e.dump=r,tr(e,r,!1)||tr(e,r,!0);var l=jr.call(e.dump),c=i,m;i&&(i=e.flowLevel<0||e.flowLevel>t);var s=l==="[object Object]"||l==="[object Array]",u,f;if(s&&(u=e.duplicates.indexOf(r),f=u!==-1),(e.tag!==null&&e.tag!=="?"||f||e.indent!==2&&t>0)&&(n=!1),f&&e.usedDuplicates[u])e.dump="*ref_"+u;else{if(s&&f&&!e.usedDuplicates[u]&&(e.usedDuplicates[u]=!0),l==="[object Object]")i&&Object.keys(e.dump).length!==0?(ho(e,t,e.dump,n),f&&(e.dump="&ref_"+u+e.dump)):(po(e,t,e.dump),f&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object Array]")i&&e.dump.length!==0?(e.noArrayIndent&&!o&&t>0?er(e,t-1,e.dump,n):er(e,t,e.dump,n),f&&(e.dump="&ref_"+u+e.dump)):(mo(e,t,e.dump),f&&(e.dump="&ref_"+u+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&co(e,e.dump,t,a,c);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new J("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(m=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?m="!"+m:m.slice(0,18)==="tag:yaml.org,2002:"?m="!!"+m.slice(18):m="!<"+m+">",e.dump=m+" "+e.dump)}return!0}function go(e,t){var r=[],i=[],n,a;for(Tt(e,r,i),n=0,a=i.length;n<a;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=new Array(a)}function Tt(e,t,r){var i,n,a;if(e!==null&&typeof e=="object")if(n=t.indexOf(e),n!==-1)r.indexOf(n)===-1&&r.push(n);else if(t.push(e),Array.isArray(e))for(n=0,a=e.length;n<a;n+=1)Tt(e[n],t,r);else for(i=Object.keys(e),n=0,a=i.length;n<a;n+=1)Tt(e[i[n]],t,r)}function xo(e,t){t=t||{};var r=new io(t);r.noRefs||go(e,r);var i=e;return r.replacer&&(i=r.replacer.call({"":i},"",i)),ge(r,0,i,!0,!0)?r.dump+`
|
|
1217
|
+
`:""}var yo=xo,wo={dump:yo};function _t(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var bo=z,vo=ir,So=sr,Co=dr,Mo=pr,To=Ft,Ao=Or.load,Fo=Or.loadAll,ko=wo.dump,Eo=J,Po={binary:wr,float:mr,map:lr,null:cr,pairs:vr,set:Sr,timestamp:xr,bool:ur,int:fr,merge:yr,omap:br,seq:ar,str:or},_o=_t("safeLoad","load"),Oo=_t("safeLoadAll","loadAll"),jo=_t("safeDump","dump"),Vr={Type:bo,Schema:vo,FAILSAFE_SCHEMA:So,JSON_SCHEMA:Co,CORE_SCHEMA:Mo,DEFAULT_SCHEMA:To,load:Ao,loadAll:Fo,dump:ko,YAMLException:Eo,types:Po,safeLoad:_o,safeLoadAll:Oo,safeDump:jo};function Lo(e){let r=String(e).match(/^---\s*[\r\n]([\s\S]*?)[\r\n](?:---|\.\.\.)\s*(?:[\r\n]([\s\S]*))?$/);if(!r)return{content:e,data:{},hasFrontMatter:!1};try{let i=Vr.load(r[1]),n=r[2]||"",a=Object.keys(i).length>0;return{content:n,data:i,hasFrontMatter:a}}catch{return{content:e,data:{},hasFrontMatter:!1}}}function Bo(e){let t={};if(typeof e.theme=="string"&&(t.theme=e.theme),typeof e.hrAsPageBreak=="boolean"&&(t.hrAsPageBreak=e.hrAsPageBreak),typeof e.format=="string"){let r=e.format.toLowerCase();(r==="pdf"||r==="docx"||r==="html"||r==="png"||r==="jpg"||r==="jpeg"||r==="webp")&&(t.format=r)}if(e.image&&typeof e.image=="object"){let r=e.image,i={};if(typeof r.type=="string"){let n=r.type.toLowerCase();(n==="png"||n==="jpeg"||n==="webp")&&(i.type=n),n==="jpg"&&(i.type="jpeg")}if(typeof r.quality=="number"&&Number.isFinite(r.quality)&&(i.quality=r.quality),typeof r.maxPixelWidth=="number"&&Number.isFinite(r.maxPixelWidth)&&(i.maxPixelWidth=r.maxPixelWidth),typeof r.split=="boolean"?i.split=r.split:typeof r.split=="string"&&r.split.toLowerCase()==="auto"&&(i.split="auto"),typeof r.splitMaxPixelHeight=="number"&&Number.isFinite(r.splitMaxPixelHeight)&&(i.splitMaxPixelHeight=r.splitMaxPixelHeight),typeof r.splitOverlapPx=="number"&&Number.isFinite(r.splitOverlapPx)&&(i.splitOverlapPx=r.splitOverlapPx),typeof r.fullPage=="boolean"&&(i.fullPage=r.fullPage),typeof r.selector=="string"?i.selector=r.selector:Array.isArray(r.selector)&&(i.selector=r.selector.filter(n=>typeof n=="string")),typeof r.selectorMode=="string"){let n=r.selectorMode.toLowerCase();(n==="first"||n==="each"||n==="union"||n==="stitch")&&(i.selectorMode=n)}if(typeof r.selectorPadding=="number"&&Number.isFinite(r.selectorPadding)&&(i.selectorPadding=r.selectorPadding),typeof r.selectorGap=="number"&&Number.isFinite(r.selectorGap)&&(i.selectorGap=r.selectorGap),typeof r.scrollToLoad=="boolean"&&(i.scrollToLoad=r.scrollToLoad),r.scroll&&typeof r.scroll=="object"){let n=r.scroll,a={};typeof n.stepPx=="number"&&Number.isFinite(n.stepPx)&&(a.stepPx=n.stepPx),typeof n.delayMs=="number"&&Number.isFinite(n.delayMs)&&(a.delayMs=n.delayMs),typeof n.maxSteps=="number"&&Number.isFinite(n.maxSteps)&&(a.maxSteps=n.maxSteps),typeof n.maxTimeMs=="number"&&Number.isFinite(n.maxTimeMs)&&(a.maxTimeMs=n.maxTimeMs),Object.keys(a).length>0&&(i.scroll=a)}if(typeof r.omitBackground=="boolean"&&(i.omitBackground=r.omitBackground),typeof r.fromSurface=="boolean"&&(i.fromSurface=r.fromSurface),typeof r.captureBeyondViewport=="boolean"&&(i.captureBeyondViewport=r.captureBeyondViewport),r.viewport&&typeof r.viewport=="object"){let n=r.viewport,a={};typeof n.width=="number"&&Number.isFinite(n.width)&&(a.width=n.width),typeof n.height=="number"&&Number.isFinite(n.height)&&(a.height=n.height),typeof n.deviceScaleFactor=="number"&&Number.isFinite(n.deviceScaleFactor)&&(a.deviceScaleFactor=n.deviceScaleFactor),Object.keys(a).length>0&&(i.viewport=a)}Object.keys(i).length>0&&(t.image=i)}if(typeof e.title=="string"&&(t.title=e.title),typeof e.standalone=="boolean"&&(t.standalone=e.standalone),typeof e.baseTag=="boolean"&&(t.baseTag=e.baseTag),typeof e.diagramMode=="string"){let r=e.diagramMode.toLowerCase();(r==="img"||r==="live"||r==="none")&&(t.diagramMode=r)}return e.cdn&&typeof e.cdn=="object"&&(t.cdn=e.cdn),typeof e.templatesDir=="string"?t.templatesDir=e.templatesDir:Array.isArray(e.templatesDir)&&(t.templatesDir=e.templatesDir.filter(r=>typeof r=="string")),e.pdf&&typeof e.pdf=="object"&&(t.pdf=e.pdf),t}function Wr(e){switch(e){case"pdf":return".pdf";case"docx":return".docx";case"html":return".html";case"png":return".png";case"webp":return".webp";case"jpeg":return".jpeg";case"jpg":return".jpg";default:return".pdf"}}async function Io(e,t={}){return new it().exportToBuffer(e,t)}async function Ro(e,t={}){return new st().exportToBuffer(e,t)}async function ia(e,t={}){return new We().exportToString(e,t)}async function Do(e,t={}){return new We().exportToBuffer(e,t)}async function oa(e,t={}){return new Ve().exportToBuffer(e,t)}async function No(e,t={}){return new Ve().exportToBuffers(e,t)}function Ho(e){let t=q.extname(e).toLowerCase();return t===".pdf"?"pdf":t===".docx"?"docx":t===".html"||t===".htm"?"html":t===".png"?"png":t===".jpg"?"jpg":t===".jpeg"?"jpeg":t===".webp"?"webp":null}function qr(e){return e==="png"||e==="jpg"||e==="jpeg"||e==="webp"}function $o(e){return e==="jpg"?"jpeg":e}async function Uo(e,t={}){let r=t.skipFrontMatter?{content:e,data:{},hasFrontMatter:!1}:Lo(e),i=r.hasFrontMatter?Bo(r.data):{},n=t.format??i.format??"pdf",a=t.theme??i.theme??"default",o=n==="pdf"?"img":"live",l=t.diagramMode??i.diagramMode??o,c=t.hrAsPageBreak??i.hrAsPageBreak??!(n==="html"||qr(n)),m=t.basePath??process.cwd(),s=r.content,u,f;if(n==="pdf")u=await Ro(s,{theme:a,basePath:m,hrAsPageBreak:c,diagramMode:l,cdn:t.cdn??i.cdn,pdf:{...t.pdf,...i.pdf,title:t.title??i.title??"Document"},templatesDir:t.templatesDir??i.templatesDir});else if(n==="docx")u=await Io(s,{theme:a,basePath:m,hrAsPageBreak:c,templatesDir:t.templatesDir??i.templatesDir});else if(n==="html")u=await Do(s,{theme:a,basePath:m,diagramMode:l,hrAsPageBreak:c,title:t.title??i.title??"Document",standalone:t.standalone??i.standalone,baseTag:t.baseTag??i.baseTag,cdn:t.cdn??i.cdn,templatesDir:t.templatesDir??i.templatesDir});else{let d=t.image??i.image,p=d?.type?d:{...d??{},type:$o(n)};if(f=await No(s,{theme:a,basePath:m,hrAsPageBreak:c,image:p,diagramMode:l,cdn:t.cdn??i.cdn,templatesDir:t.templatesDir??i.templatesDir}),!f.length)throw new Error("Image conversion produced no output");u=f[0]}return{buffer:u,format:n,buffers:f&&f.length>1?f:void 0}}async function aa(e,t,r={}){let i=q.resolve(e);if(!ue.existsSync(i))throw new Error(`Input file not found: ${i}`);let n=ue.readFileSync(i,"utf-8"),a=r.format;!a&&t&&(a=Ho(t)??void 0);let o=q.basename(i,q.extname(i)),l=await Uo(n,{...r,format:a,basePath:r.basePath??q.dirname(i),title:r.title??o}),c;if(t)c=q.resolve(t);else{let s=q.dirname(i),u=q.basename(i,q.extname(i)),f=Wr(l.format);c=q.join(s,`${u}${f}`)}let m=q.dirname(c);if(ue.existsSync(m)||ue.mkdirSync(m,{recursive:!0}),qr(l.format)&&l.buffers&&l.buffers.length>1){let s=l.buffers,u=Wr(l.format),f=c.endsWith(u)?c.slice(0,-u.length):c,d=[];for(let p=0;p<s.length;p++){let h=String(p+1).padStart(3,"0"),x=`${f}.part-${h}${u}`;ue.writeFileSync(x,s[p]),d.push(x)}return{buffer:s[0],buffers:s,outputPath:d[0],outputPaths:d,format:l.format}}return ue.writeFileSync(c,l.buffer),{buffer:l.buffer,outputPath:c,format:l.format}}export{it as a,st as b,Ve as c,We as d,Lo as e,Bo as f,Wr as g,Io as h,Ro as i,ia as j,Do as k,oa as l,No as m,Uo as n,aa as o};
|
|
1019
1218
|
/*! Bundled license information:
|
|
1020
1219
|
|
|
1021
1220
|
js-yaml/dist/js-yaml.mjs:
|