md2x 0.7.1 → 0.7.3
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 +53 -48
- package/dist/chunks/{chunk-A4XDJ35P.js → chunk-RLHZRADD.js} +219 -50
- package/dist/index.js +1 -1
- package/dist/md2x.js +1 -1
- package/dist/renderer/puppeteer-render-worker.js +132 -129
- package/dist/templates/vue/mapLibre.vue +371 -0
- 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
|
|
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 k from"path";import{createRequire as un}from"module";import{fileURLToPath as He,pathToFileURL as we}from"url";import*as J from"fs";import*as Dt from"os";import*as q from"path";import{fileURLToPath as rn,pathToFileURL as Ze}from"url";function nn(){return globalThis.__md2x_module_dir__?globalThis.__md2x_module_dir__:q.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 q.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=[q.join(process.cwd(),".md2x-"),q.join(Dt.tmpdir(),"md2x-")];for(let d of c)try{return J.mkdirSync(q.dirname(d),{recursive:!0}),J.mkdtempSync(d)}catch{}throw new Error("Unable to create a writable temp directory for Chromium runtime files")},o=async c=>{if(!t||!c)return;let d=Ze(c+q.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},d)};return{async initialize(){if(!gt)return;let c=on();if(!J.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 d=q.join(r,"chrome-profile");J.mkdirSync(d,{recursive:!0}),e=await gt.launch({headless:!0,userDataDir:d,env:{...process.env,HOME:r,XDG_CACHE_HOME:q.join(r,"xdg-cache"),XDG_CONFIG_HOME:q.join(r,"xdg-config"),XDG_DATA_HOME:q.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=${q.join(r,"crashpad")}`,`--user-data-dir=${d}`,"--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
|
+
`:"",m=s instanceof Error?s.message:String(s);throw new Error(`${u}
|
|
12
|
+
Original error: ${m}${f}`)}},async render(c,d,s,u){if(!t)return null;try{if(await o(s),c==="md2x"){let m=v=>{let C=v?.fontSize??12,B=14/16*(C/12)*4;return Math.max(1,Math.min(4,B))};try{let v=m(u??null),A=t.viewport();(!A||A.deviceScaleFactor!==v)&&await t.setViewport({width:A?.width??2e3,height:A?.height??2e3,deviceScaleFactor:v})}catch{}let p=await t.evaluate(async(v,A)=>{let B=window.__md2xRenderToDom;if(typeof B!="function")throw new Error("__md2xRenderToDom is not available on page");return await B(v,A)},d,u??null);try{await t.waitForSelector(`#${p}`,{timeout:3e4})}catch{}try{await t.waitForNetworkIdle?.({idleTime:500,timeout:15e3})}catch{}let h=await t.$(`#${p}`);if(!h)throw new Error(`md2x screenshot element not found: #${p}`);let x=await h.boundingBox(),y=await t.evaluate(()=>window.devicePixelRatio||1).catch(()=>1),w=await h.screenshot({type:"png",omitBackground:!0,captureBeyondViewport:!0});try{await t.evaluate(v=>{let A=window;typeof A.__md2xCleanupDom=="function"&&A.__md2xCleanupDom(v)},p)}catch{}return{base64:(Buffer.isBuffer(w)?w:Buffer.from(w)).toString("base64"),width:Math.max(1,Math.round((x?.width??1)*(typeof y=="number"&&Number.isFinite(y)?y:1))),height:Math.max(1,Math.round((x?.height??1)*(typeof y=="number"&&Number.isFinite(y)?y:1))),format:"png"}}return await t.evaluate(async(m,p,h)=>{let y=window.__md2xRender;if(typeof y!="function")throw new Error("Renderer function not available on page");return await y(m,p,h)},c,d,u??null)}catch(f){let m=f instanceof Error?f.message:String(f);return console.warn(`Failed to render ${c}: ${m}`),null}},async exportToPdf(c,d,s={},u){if(!t)throw new Error("Browser not initialized");let f=await e.newPage(),m=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>${d}</style>
|
|
18
18
|
</head>
|
|
19
19
|
<body>
|
|
20
20
|
<div id="markdown-content">${c}</div>
|
|
21
21
|
</body>
|
|
22
|
-
</html>`;u?(
|
|
22
|
+
</html>`;u?(m=q.join(u,`__md2x_temp_${Date.now()}.html`),J.writeFileSync(m,h,"utf-8"),await f.goto(Ze(m).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 S=Array.from(document.images||[]);await Promise.all(S.map(T=>T.complete?null:new Promise(L=>{T.addEventListener("load",()=>L(),{once:!0}),T.addEventListener("error",()=>L(),{once:!0})})))})}catch{}let x=s.format||"A4",y=s.landscape||!1,w=s.scale||1,{widthIn:W,heightIn:v}=an(x),A=y?W:v,C=ln(x),B=et(s.margin?.top??C.top)??et(C.top),Ce=et(s.margin?.bottom??C.bottom)??et(C.bottom),Te=(A-B-Ce)*96/w;await f.evaluate(g=>{let S=document.getElementById("markdown-content");if(!S)return;let T=window.getComputedStyle(S),L=parseFloat(T.paddingTop||"0")||0,M=parseFloat(T.paddingBottom||"0")||0,E=Math.max(0,g-L-M);S.querySelectorAll(".md2x-diagram img.md2x-diagram, img.md2x-diagram").forEach(_=>{let I=_,O=I.getBoundingClientRect().height||I.naturalHeight||0;O&&(O<=E+.5||(I.style.maxHeight=`${E}px`,I.style.height="auto",I.style.width="auto",I.style.maxWidth="100%",I.style.objectFit="contain"))})},Te),await f.evaluate(()=>{let g=document.getElementById("markdown-content");if(!g)return;let S=g.clientWidth;if(!S)return;g.querySelectorAll(':scope > div[style*="width"]').forEach(L=>{let M=L,E=M.style.width?.match(/^(\d+(?:\.\d+)?)px$/);if(!E)return;let j=parseFloat(E[1]);if(!Number.isFinite(j)||j<=0)return;let _=Math.min(1,S/j);_>=.999||(M.style.transformOrigin="top left",M.style.transform=`scale(${_})`)})});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(),m)try{J.unlinkSync(m)}catch{}}},async exportToImage(c,d,s={},u){let f=await this.exportToImageParts(c,d,{...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,d,s={},u){if(!t)throw new Error("Browser not initialized");let f=await e.newPage(),m=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>${d}</style>
|
|
27
27
|
</head>
|
|
28
28
|
<body>
|
|
29
29
|
<div id="markdown-content">${c}</div>
|
|
30
30
|
</body>
|
|
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`
|
|
31
|
+
</html>`;u?(m=q.join(u,`__md2x_temp_${Date.now()}.html`),J.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 S=Array.from(document.images||[]);await Promise.all(S.map(T=>T.complete?null:new Promise(L=>{T.addEventListener("load",()=>L(),{once:!0}),T.addEventListener("error",()=>L(),{once:!0})})))})}catch{}if(typeof s.scrollToLoad=="boolean"?s.scrollToLoad:!s.selector&&s.fullPage!==!1){let g=s.scroll??{},S=typeof g.delayMs=="number"&&Number.isFinite(g.delayMs)?Math.max(0,g.delayMs):250,T=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,M=typeof g.stepPx=="number"&&Number.isFinite(g.stepPx)?Math.max(1,g.stepPx):0;try{await f.evaluate(async E=>{let j=z=>new Promise(N=>setTimeout(N,z)),_=document.scrollingElement||document.documentElement,I=Date.now(),fe=()=>E.stepPx>0?E.stepPx:Math.max(1,Math.floor(window.innerHeight*.85)),O=-1,K=0;for(let z=0;z<E.maxSteps;z++){let N=fe();_.scrollTop=Math.min(_.scrollTop+N,_.scrollHeight),await j(E.delayMs);let Z=_.scrollTop;if(Z===O?K++:K=0,O=Z,Z+window.innerHeight>=_.scrollHeight-2||K>=2||Date.now()-I>E.maxTimeMs)break}_.scrollTop=0,await j(Math.min(250,E.delayMs))},{delayMs:S,maxSteps:T,maxTimeMs:L,stepPx:M}),await f.evaluate(async()=>{let E=Array.from(document.images||[]);await Promise.all(E.map(j=>j.complete?null:new Promise(_=>{j.addEventListener("load",()=>_(),{once:!0}),j.addEventListener("error",()=>_(),{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 y=typeof s.maxPixelWidth=="number"&&Number.isFinite(s.maxPixelWidth)?s.maxPixelWidth:2e3;if(y>0)try{let g=await f.evaluate(S=>{if(S){let L=Array.from(document.querySelectorAll(S));if(!L.length)return 0;let M=1/0,E=-1/0;for(let _ of L){let I=_.getBoundingClientRect();M=Math.min(M,I.left),E=Math.max(E,I.right)}let j=E-M;return Number.isFinite(j)?j:0}let T=document.documentElement;return Math.max(T.scrollWidth,T.clientWidth)||0},Rt(s.selector));if(g>0){let S=f.viewport(),T=S?.deviceScaleFactor??1,L=Math.min(T,y/g),M=Math.max(.25,L);Math.abs(M-T)>=.01&&await f.setViewport({width:S?.width??Math.max(320,Math.floor(p.width??1200)),height:S?.height??Math.max(240,Math.floor(p.height??800)),deviceScaleFactor:M})}}catch{}let w=s.type??"png",W=s.fullPage!==!1,v={type:w};if((w==="jpeg"||w==="webp")&&typeof s.quality=="number"){let g=Math.max(0,Math.min(100,Math.round(s.quality)));v.quality=g}typeof s.fromSurface=="boolean"&&(v.fromSurface=s.fromSurface);let A=async g=>{let S=await f.screenshot(g);return Buffer.isBuffer(S)?S:Buffer.from(S)},C=async()=>{try{return await f.evaluate(()=>{let g=document.documentElement,S=document.body;return{width:Math.max(g.scrollWidth,S?.scrollWidth??0,g.clientWidth),height:Math.max(g.scrollHeight,S?.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 S=await f.$$(g);if(!S.length)throw new Error(`Element not found for selector: ${g}`);let T=s.selectorMode??"stitch",L=T==="first"?[S[0]]:S,M=typeof s.selectorPadding=="number"&&Number.isFinite(s.selectorPadding)?Math.max(0,s.selectorPadding):0;if(T==="stitch"){let F=typeof s.selectorGap=="number"&&Number.isFinite(s.selectorGap)?Math.max(0,Math.floor(s.selectorGap)):0,P="#__md2x_selector_stitch__",ee=async()=>{try{await f.evaluate(()=>{let R="__md2xSelectorStitchState",oe=window[R];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[R]}catch{}})}catch{}};await ee();try{await f.evaluate((he,Xe)=>{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(Xe)+"px",se.style.maxWidth="100%",se.style.boxSizing="border-box",en.appendChild(se);let tn=Array.from(document.querySelectorAll(he)).filter(Ee=>{let Me=Ee.parentElement;for(;Me;){try{if(Me.matches(he))return!1}catch{}Me=Me.parentElement}return!0}),Lt=[];for(let Ee of tn){let Me=Ee.parentNode;if(!Me)continue;let Bt=document.createComment("md2x-stitch");Me.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,F),await f.waitForSelector(P,{timeout:5e3});let R=await f.$(P);if(!R)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,Xe=document.body,Qe=Math.max(he.scrollWidth,Xe?.scrollWidth??0,he.clientWidth),Ne=Math.max(he.scrollHeight,Xe?.scrollHeight??0,he.clientHeight);return{width:Qe,height:Ne}}),ae=await R.boundingBox();if(!ae)throw new Error(`Unable to determine bounding box for selector: ${g}`);let le=Math.max(0,ae.x-M),ye=Math.max(0,ae.y-M),me=Math.min(oe.width-le,ae.width+M*2),pe=Math.min(oe.height-ye,ae.height+M*2);if(!(me>0)||!(pe>0))throw new Error(`Unable to determine bounding box for selector: ${g}`);let Zr={...v,clip:{x:le,y:ye,width:me,height:pe},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await A(Zr)]}finally{await ee()}}let E=await f.evaluate(()=>{let F=document.documentElement,P=document.body,ee=Math.max(F.scrollWidth,P?.scrollWidth??0,F.clientWidth),R=Math.max(F.scrollHeight,P?.scrollHeight??0,F.clientHeight);return{width:ee,height:R}}),j=async()=>{let F=[],P=0;for(let ee of L){try{await ee.evaluate(pe=>{pe.scrollIntoView({block:"start",inline:"nearest"})})}catch{}let R=await ee.boundingBox();if(!R)continue;let oe=Math.max(0,R.x-M),ae=Math.max(0,R.y-M),le=Math.min(E.width-oe,R.width+M*2),ye=Math.min(E.height-ae,R.height+M*2);if(!(le>0)||!(ye>0))continue;let me={...v,clip:{x:oe,y:ae,width:le,height:ye},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};P>0&&await new Promise(pe=>setTimeout(pe,40)),F.push(await A(me)),P++}return F};if(T==="each"){let F=await j();if(!F.length)throw new Error(`Unable to determine bounding box for selector: ${g}`);return F}let _=1/0,I=1/0,fe=-1/0,O=-1/0,K=[];for(let F of L){let P=await F.boundingBox();P&&(_=Math.min(_,P.x),I=Math.min(I,P.y),fe=Math.max(fe,P.x+P.width),O=Math.max(O,P.y+P.height),K.push(Math.round(P.y+P.height)))}if(!Number.isFinite(_)||!Number.isFinite(I)||!Number.isFinite(fe)||!Number.isFinite(O))throw new Error(`Unable to determine bounding box for selector: ${g}`);let z=Math.max(0,_-M),N=Math.max(0,I-M),Z=Math.min(E.width,fe+M),H=Math.min(E.height,O+M),de=Math.max(1,Z-z),re=Math.max(1,H-N),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 F={...v,clip:{x:z,y:N,width:de,height:re},captureBeyondViewport:typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};return[await A(F)]}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)),Jr=Math.min(400,Math.floor(Ot*.25)),Xr=Array.from(new Set([...K,Math.round(H)])).filter(F=>Number.isFinite(F)).map(F=>Math.max(0,Math.round(F))).sort((F,P)=>F-P),Qr=F=>{let P=Math.min(H,F+Ot);if(P>=H)return H;let ee=-1;for(let R of Xr)if(!(R<=F+1)){if(R>P)break;R-F<Jr||(ee=R)}return ee>0?ee:Math.max(F+1,P)},jt=[],De=N,ht=0;for(;De<H&&ht<1e4;){let F=Qr(De),P=Math.max(1,F-De),ee={...v,clip:{x:z,y:De,width:de,height:P},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};if(ht>0&&await new Promise(R=>setTimeout(R,40)),jt.push(await A(ee)),F>=H)break;De=Math.max(N,F-Kr),ht++}return jt}if(!W)return v.fullPage=!1,v.captureBeyondViewport=!1,v.omitBackground=s.omitBackground??!1,[await A(v)];let B=await C(),Ce=Math.max(.25,B.dpr||1),Te=Math.ceil((B.height||0)*Ce),te=s.split??"auto";if(te===!0||te==="auto"&&Te>3e4){let g=typeof s.splitMaxPixelHeight=="number"&&Number.isFinite(s.splitMaxPixelHeight)?Math.max(500,Math.floor(s.splitMaxPixelHeight)):14e3,S=typeof s.splitOverlapPx=="number"&&Number.isFinite(s.splitOverlapPx)?Math.max(0,Math.floor(s.splitOverlapPx)):0,T=Math.max(200,Math.floor(g/Ce)),L=Math.max(1,B.width||(f.viewport()?.width??1200)),M=Math.max(1,B.height||(f.viewport()?.height??800)),E=[],j=0,_=0,I=await f.evaluate(()=>{let O=document.getElementById("markdown-content"),K=document.scrollingElement||document.documentElement;K.scrollTop=0;let z=[0],N=de=>{let xe=de.getBoundingClientRect().bottom+(window.scrollY||0);Number.isFinite(xe)&&z.push(Math.round(xe))};O&&Array.from(O.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(N);return}}N(re)});let Z=Math.max(K.scrollHeight,document.documentElement.scrollHeight);z.push(Math.round(Z)),z.sort((de,re)=>de-re);let H=[];for(let de of z){let re=Math.max(0,de);(!H.length||H[H.length-1]!==re)&&H.push(re)}return H}),fe=O=>{let K=Math.min(M,O+T);if(K>=M)return M;let z=Math.min(400,Math.floor(T*.25)),N=-1;for(let Z=0;Z<I.length;Z++){let H=I[Z];if(!(H<=O+1)){if(H>K)break;H-O<z||(N=H)}}return N>0?N:Math.max(O+1,K)};for(;j<M&&_<1e4;){let O=fe(j),K=Math.max(1,O-j),z={...v,clip:{x:0,y:j,width:L,height:K},captureBeyondViewport:!0,omitBackground:s.omitBackground??!1};try{await f.evaluate(N=>{let Z=document.scrollingElement||document.documentElement;Z.scrollTop=Math.max(0,N)},j)}catch{}if(_>0&&await new Promise(N=>setTimeout(N,80)),E.push(await A(z)),O>=M)break;j=Math.max(0,O-S),_++}try{await f.evaluate(()=>{let O=document.scrollingElement||document.documentElement;O.scrollTop=0})}catch{}return E}v.fullPage=!0,v.captureBeyondViewport=typeof s.captureBeyondViewport=="boolean"?s.captureBeyondViewport:!1,v.omitBackground=s.omitBackground??!1,v.captureBeyondViewport===!1&&(B.width&&B.width>16e3||B.height&&B.height>16e3)&&(v.captureBeyondViewport=!0);try{return[await A(v)]}catch(g){let S=g instanceof Error?g.message:String(g);if(v.fromSurface===!1){let T={...v};delete T.fromSurface;try{return[await A(T)]}catch{}}if(v.fullPage&&typeof v.captureBeyondViewport=="boolean"){let T={...v,captureBeyondViewport:!v.captureBeyondViewport};T.fromSurface===!1&&delete T.fromSurface;try{return[await A(T)]}catch{}}throw new Error(`Unable to capture screenshot. ${S}`)}}finally{if(await f.close(),m)try{J.unlinkSync(m)}catch{}}},async close(){if(e&&(await e.close(),e=null,t=null),r){try{J.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 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=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__:k.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 ze(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 Ue(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=(y=>{try{if(String(y).toLowerCase().startsWith("file://")){let C=He(y);return ne.existsSync(C)?C:null}if(k.isAbsolute(y))return ne.existsSync(y)?y:null;let w=be(),W=c().map(C=>{try{if(String(C).toLowerCase().startsWith("file://"))return He(C)}catch{}return k.isAbsolute(C)?C:k.join(t,C)}),v=[];for(let C of W)v.push(k.join(C,y));let A=[k.join(t,y),...v,k.join(w,"templates",y),k.join(w,"..","templates",y),k.join(w,"..","src","templates",y)];for(let C of A)if(ne.existsSync(C))return C;return null}catch{return null}})(p);if(x)try{let y=ne.readFileSync(x,"utf-8"),w=we(x).href;a[w]=y,a[p]=y,m&&(a[m]=y)}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(k.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 k.isAbsolute(h)?h:k.join(t,h)}),m=[];for(let h of f)m.push(k.join(h,s));let p=[k.join(t,s),...m,k.join(u,"templates",s),k.join(u,"..","templates",s),k.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"),y=we(h).href;a[y]=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=Ue(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,y=Ht(String(x||"").replace(/<[^>]*>/g,"")),w=h.toLowerCase();(w==="graphviz"||w==="gv")&&(w="dot"),w==="vegalite"&&(w="vega-lite");try{let W=w==="md2x"?{code:y,templateFiles:l,cdn:{vue:o?.vue,vueSfcLoader:o?.vueSfcLoader,svelteCompiler:o?.svelteCompiler,svelteBase:o?.svelteBase}}:y,v=await t.render(w,W,r,i);if(v&&v.base64){let A=tt(w),C=`<div class="md2x-diagram" data-md2x-diagram-kind="${A}"><img class="md2x-diagram" data-md2x-diagram-kind="${A}" src="data:image/${v.format};base64,${v.base64}" alt="${tt(`${h} diagram`)}" style="max-width: 100%;" /></div>`;e=e.replace(p,C)}}catch(W){console.warn(`Failed to render ${h} diagram:`,W)}}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 y(){return A=>{x(A,"element",C=>{if(C.tagName!=="p")return;let B=C.children||[];if(B.length===0)return;let Ce=0,Te=-1,te=!1,Ie=!1;for(let g=0;g<B.length;g++){let S=B[g];S.type==="element"&&S.tagName==="img"?(Ce++,Te=g,Ie=!0):Ie&&(S.type==="text"&&S.value.trim()!==""||S.type==="element"&&S.tagName!=="br")&&(te=!0)}if(Ce===1&&!te&&Te>=0){let g=B[Te];g.properties=g.properties||{};let S=g.properties.className||[];g.properties.className=Array.isArray(S)?[...S,"block-image"]:[S,"block-image"]}})}}let W=await l().use(c).use(d,{singleTilde:!1}).use(s).use(u).use(f,{allowDangerousHtml:!0}).use(m).use(p).use(y).use(h,{allowDangerousHtml:!0}).process(e),v=String(W);return v=await mn(v,t,r,i,n,a,o),v}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 () {
|
|
@@ -46,12 +46,134 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
46
46
|
const s = document.createElement('script');
|
|
47
47
|
s.src = src;
|
|
48
48
|
s.async = false;
|
|
49
|
-
s.onload = () => resolve();
|
|
50
|
-
s.onerror = () => reject(new Error('Failed to load script: ' + src));
|
|
49
|
+
s.onload = () => { try { s.__md2xLoaded = true; } catch {} resolve(); };
|
|
50
|
+
s.onerror = () => { try { s.__md2xLoaded = true; } catch {} reject(new Error('Failed to load script: ' + src)); };
|
|
51
51
|
document.head.appendChild(s);
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
function normalizeStringList(value) {
|
|
56
|
+
if (!Array.isArray(value)) return [];
|
|
57
|
+
const out = [];
|
|
58
|
+
const seen = new Set();
|
|
59
|
+
for (const v of value) {
|
|
60
|
+
if (typeof v !== 'string') continue;
|
|
61
|
+
const s = v.trim();
|
|
62
|
+
if (!s) continue;
|
|
63
|
+
if (seen.has(s)) continue;
|
|
64
|
+
seen.add(s);
|
|
65
|
+
out.push(s);
|
|
66
|
+
}
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizeTemplateConfig(value) {
|
|
71
|
+
if (!value || typeof value !== 'object') return null;
|
|
72
|
+
const assets = value.assets;
|
|
73
|
+
if (!assets || typeof assets !== 'object') return null;
|
|
74
|
+
const scripts = normalizeStringList(assets.scripts);
|
|
75
|
+
const styles = normalizeStringList(assets.styles);
|
|
76
|
+
if (!scripts.length && !styles.length) return null;
|
|
77
|
+
return { assets: { scripts, styles } };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function extractTemplateConfigFromHead(source) {
|
|
81
|
+
const raw = String(source || '');
|
|
82
|
+
if (!raw) return { source: raw, templateConfig: null };
|
|
83
|
+
|
|
84
|
+
let i = 0;
|
|
85
|
+
// BOM
|
|
86
|
+
if (raw.charCodeAt(0) === 0xfeff) i = 1;
|
|
87
|
+
// leading whitespace/newlines
|
|
88
|
+
while (i < raw.length) {
|
|
89
|
+
const ch = raw[i];
|
|
90
|
+
if (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '\\r') i++;
|
|
91
|
+
else break;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (raw.slice(i, i + 4) !== '<!--') return { source: raw, templateConfig: null };
|
|
95
|
+
const end = raw.indexOf('-->', i + 4);
|
|
96
|
+
if (end === -1) return { source: raw, templateConfig: null };
|
|
97
|
+
|
|
98
|
+
const commentBody = raw.slice(i + 4, end).trim();
|
|
99
|
+
const prefix = 'TemplateConfig:';
|
|
100
|
+
if (commentBody.slice(0, prefix.length) !== prefix) return { source: raw, templateConfig: null };
|
|
101
|
+
|
|
102
|
+
const jsonText = commentBody.slice(prefix.length).trim();
|
|
103
|
+
|
|
104
|
+
// Strip the header comment even if parsing fails (so SFC/Svelte compilers won't choke on it).
|
|
105
|
+
let after = raw.slice(end + 3);
|
|
106
|
+
if (after.slice(0, 2) === '\\r\\n') after = after.slice(2);
|
|
107
|
+
else if (after[0] === '\\n' || after[0] === '\\r') after = after.slice(1);
|
|
108
|
+
const cleaned = raw.slice(0, i) + after;
|
|
109
|
+
|
|
110
|
+
if (!jsonText) return { source: cleaned, templateConfig: null };
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
const parsed = JSON.parse(jsonText);
|
|
114
|
+
return { source: cleaned, templateConfig: normalizeTemplateConfig(parsed) };
|
|
115
|
+
} catch (e) {
|
|
116
|
+
const msg = (e && e.message) ? e.message : String(e);
|
|
117
|
+
return { source: cleaned, templateConfig: null, error: msg };
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function loadCssOnce(href) {
|
|
122
|
+
const url = resolveHref(href, baseHref || undefined);
|
|
123
|
+
if (!url) return Promise.resolve();
|
|
124
|
+
const esc = (window.CSS && typeof window.CSS.escape === 'function') ? window.CSS.escape(url) : String(url).replace(/"/g, '\\\\"');
|
|
125
|
+
const existing = document.querySelector('link[rel="stylesheet"][href="' + esc + '"]');
|
|
126
|
+
if (existing) return Promise.resolve();
|
|
127
|
+
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
const link = document.createElement('link');
|
|
130
|
+
link.rel = 'stylesheet';
|
|
131
|
+
link.href = url;
|
|
132
|
+
link.onload = () => resolve();
|
|
133
|
+
link.onerror = () => resolve();
|
|
134
|
+
document.head.appendChild(link);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function loadScriptOnce(src, globalName) {
|
|
139
|
+
if (globalName) {
|
|
140
|
+
try {
|
|
141
|
+
if (window[globalName]) return Promise.resolve();
|
|
142
|
+
} catch {}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const url = resolveHref(src, baseHref || undefined);
|
|
146
|
+
if (!url) return Promise.resolve();
|
|
147
|
+
|
|
148
|
+
const esc = (window.CSS && typeof window.CSS.escape === 'function') ? window.CSS.escape(url) : String(url).replace(/"/g, '\\\\"');
|
|
149
|
+
const existing = document.querySelector('script[src="' + esc + '"]');
|
|
150
|
+
if (existing) {
|
|
151
|
+
if (existing.__md2xLoaded) return Promise.resolve();
|
|
152
|
+
return new Promise((resolve, reject) => {
|
|
153
|
+
existing.addEventListener('load', () => { try { existing.__md2xLoaded = true; } catch {} resolve(); }, { once: true });
|
|
154
|
+
existing.addEventListener('error', () => reject(new Error('Failed to load script: ' + url)), { once: true });
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return loadScript(url).then(() => {
|
|
159
|
+
try {
|
|
160
|
+
const el = document.querySelector('script[src="' + esc + '"]');
|
|
161
|
+
if (el) el.__md2xLoaded = true;
|
|
162
|
+
} catch {}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async function loadTemplateAssets(templateConfig) {
|
|
167
|
+
const scripts = normalizeStringList(templateConfig && templateConfig.assets ? templateConfig.assets.scripts : null);
|
|
168
|
+
const styles = normalizeStringList(templateConfig && templateConfig.assets ? templateConfig.assets.styles : null);
|
|
169
|
+
for (const href of styles) {
|
|
170
|
+
await loadCssOnce(href);
|
|
171
|
+
}
|
|
172
|
+
for (const src of scripts) {
|
|
173
|
+
await loadScriptOnce(src);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
55
177
|
let __md2xSvelteCompilerPromise = null;
|
|
56
178
|
|
|
57
179
|
function getCdnValue(key) {
|
|
@@ -468,9 +590,13 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
468
590
|
const type = (cfg.type != null) ? String(cfg.type).toLowerCase() : '';
|
|
469
591
|
const template = (cfg.template != null) ? String(cfg.template) : '';
|
|
470
592
|
const data = cfg.data;
|
|
593
|
+
const allowTemplateAssets =
|
|
594
|
+
(typeof cfg.allowTemplateAssets === 'boolean')
|
|
595
|
+
? cfg.allowTemplateAssets
|
|
596
|
+
: ((typeof cfg.allowCdn === 'boolean') ? cfg.allowCdn : false);
|
|
471
597
|
if (type !== 'vue' && type !== 'html' && type !== 'svelte') return null;
|
|
472
598
|
if (!template) return null;
|
|
473
|
-
return { type, template, data };
|
|
599
|
+
return { type, template, data, allowTemplateAssets };
|
|
474
600
|
}
|
|
475
601
|
|
|
476
602
|
async function renderMd2xHtml(cfg, mount) {
|
|
@@ -483,6 +609,20 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
483
609
|
return;
|
|
484
610
|
}
|
|
485
611
|
|
|
612
|
+
const extracted = extractTemplateConfigFromHead(tpl);
|
|
613
|
+
if (cfg.allowTemplateAssets) {
|
|
614
|
+
if (extracted.error) {
|
|
615
|
+
mount.textContent = 'Invalid TemplateConfig JSON: ' + extracted.error;
|
|
616
|
+
return;
|
|
617
|
+
}
|
|
618
|
+
try {
|
|
619
|
+
await loadTemplateAssets(extracted.templateConfig);
|
|
620
|
+
} catch (e) {
|
|
621
|
+
mount.textContent = 'Failed to load TemplateConfig assets.';
|
|
622
|
+
return;
|
|
623
|
+
}
|
|
624
|
+
}
|
|
625
|
+
|
|
486
626
|
// Same data-injection approach as md2x Vue templates: replace the templateData placeholder.
|
|
487
627
|
const json = (() => {
|
|
488
628
|
try {
|
|
@@ -494,7 +634,7 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
494
634
|
return 'null';
|
|
495
635
|
}
|
|
496
636
|
})();
|
|
497
|
-
mount.innerHTML =
|
|
637
|
+
mount.innerHTML = extracted.source.split('templateData').join('(' + json + ')');
|
|
498
638
|
|
|
499
639
|
// Browsers treat <script> tags inserted via innerHTML as inert (they won't execute).
|
|
500
640
|
// Re-create them in-place to allow "script + markup in one HTML file" templates.
|
|
@@ -559,6 +699,21 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
559
699
|
return;
|
|
560
700
|
}
|
|
561
701
|
|
|
702
|
+
const extracted = extractTemplateConfigFromHead(rootSource);
|
|
703
|
+
if (cfg.allowTemplateAssets) {
|
|
704
|
+
if (extracted.error) {
|
|
705
|
+
mount.textContent = 'Invalid TemplateConfig JSON: ' + extracted.error;
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
try {
|
|
709
|
+
// Load after Vue runtime is available (common for Vue plugin UMDs).
|
|
710
|
+
await loadTemplateAssets(extracted.templateConfig);
|
|
711
|
+
} catch (e) {
|
|
712
|
+
mount.textContent = 'Failed to load TemplateConfig assets.';
|
|
713
|
+
return;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
|
|
562
717
|
// Inject md2x data into the template by replacing the templateData placeholder.
|
|
563
718
|
// This avoids fetch() and also avoids having to require every user template to define props.
|
|
564
719
|
const json = (() => {
|
|
@@ -573,7 +728,7 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
573
728
|
}
|
|
574
729
|
})();
|
|
575
730
|
// NOTE: avoid \\b in this template-literal-generated script (it would become a backspace character).
|
|
576
|
-
const rootPatchedSource =
|
|
731
|
+
const rootPatchedSource = extracted.source.split('templateData').join('(' + json + ')');
|
|
577
732
|
|
|
578
733
|
const options = {
|
|
579
734
|
moduleCache: { vue: Vue },
|
|
@@ -643,6 +798,20 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
643
798
|
return;
|
|
644
799
|
}
|
|
645
800
|
|
|
801
|
+
const extracted = extractTemplateConfigFromHead(rootSource);
|
|
802
|
+
if (cfg.allowTemplateAssets) {
|
|
803
|
+
if (extracted.error) {
|
|
804
|
+
mount.textContent = 'Invalid TemplateConfig JSON: ' + extracted.error;
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
await loadTemplateAssets(extracted.templateConfig);
|
|
809
|
+
} catch (e) {
|
|
810
|
+
mount.textContent = 'Failed to load TemplateConfig assets.';
|
|
811
|
+
return;
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
|
|
646
815
|
const json = (() => {
|
|
647
816
|
try {
|
|
648
817
|
const j = JSON.stringify(cfg.data ?? null);
|
|
@@ -652,7 +821,7 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
652
821
|
return 'null';
|
|
653
822
|
}
|
|
654
823
|
})();
|
|
655
|
-
const patchedSource =
|
|
824
|
+
const patchedSource = extracted.source.split('templateData').join('(' + json + ')');
|
|
656
825
|
|
|
657
826
|
let compilerMod;
|
|
658
827
|
try {
|
|
@@ -816,7 +985,7 @@ Original error: ${d}${f}`)}},async render(c,m,s,u){if(!t)return null;try{return
|
|
|
816
985
|
main();
|
|
817
986
|
}
|
|
818
987
|
})();
|
|
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
|
|
988
|
+
</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 d=k.join(n,"__md2x__.md"),s=null;try{s=await Pe(),s&&await s.initialize();let u=await ze(i),f=dn(t,n,r.templatesDir),m=fn(s,n,u,f),{default:p}=await import("./docx-exporter-ZZ76JXFU.js"),h=new p(m);h.setBaseUrl?.(we(d).href);let x=await h.exportToDocx(t,"__md2x__.docx",null);if(!x.success)throw new Error(x.error||"DOCX export failed");let y=l();if(!y)throw new Error("DOCX export produced no output buffer");return y}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),d=await t.resource.fetch(`themes/table-styles/${n.tableStyle}.json`),s=JSON.parse(d),u=await t.resource.fetch(`themes/code-themes/${n.codeTheme}.json`),f=JSON.parse(u),{themeToCSS:m}=await import("./theme-to-css-GLV3WYDU.js");return m(n,o,c,s,f)}async function at(e=!0){return`
|
|
820
989
|
/* Base PDF Styles */
|
|
821
990
|
* {
|
|
822
991
|
box-sizing: border-box;
|
|
@@ -1159,62 +1328,62 @@ hr {
|
|
|
1159
1328
|
background-color: #e1e4e8;
|
|
1160
1329
|
border: 0;
|
|
1161
1330
|
}`}
|
|
1162
|
-
`}function lt(){let e=be(),t=
|
|
1163
|
-
`+nt(
|
|
1164
|
-
`+
|
|
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
|
|
1166
|
-
`+nt(
|
|
1167
|
-
`+
|
|
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
|
|
1169
|
-
`+nt(
|
|
1170
|
-
`+
|
|
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
|
|
1331
|
+
`}function lt(){let e=be(),t=k.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=k.dirname(r),n=we(k.join(i,"fonts")+k.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 d=await ze(i),s=r.diagramMode??"img",u=await rt(t,c,n,d,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+k.sep).href,y=Ue(u,n,r.templatesDir);u=u+`
|
|
1332
|
+
`+nt(d??null,x,r.cdn,y)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for PDF export:",x)}let m=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+`
|
|
1333
|
+
`+m+`
|
|
1334
|
+
`+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 d=await ze(i),s=r.diagramMode??"live",u=await rt(t,c,n,d,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+k.sep).href,y=Ue(u,n,r.templatesDir);u=u+`
|
|
1335
|
+
`+nt(d??null,x,r.cdn,y)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for image export:",x)}let m=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+`
|
|
1336
|
+
`+m+`
|
|
1337
|
+
`+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 d=await ze(i),s=r.diagramMode??"live",u=await rt(t,c,n,d,s,r.templatesDir,r.cdn);if(s==="live"){let x=we(n+k.sep).href,y=Ue(u,n,r.templatesDir);u=u+`
|
|
1338
|
+
`+nt(d??null,x,r.cdn,y)}let f="";try{f=lt()}catch(x){console.warn("Failed to load KaTeX CSS for image export:",x)}let m=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+`
|
|
1339
|
+
`+m+`
|
|
1340
|
+
`+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 d=null;try{let s=await ze(i);o==="img"&&(d=await Pe(),d&&await d.initialize());let u=await rt(t,d,n,s,o,r.templatesDir,r.cdn);if(!(r.standalone!==!1))return u;let m="";try{m=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=m+`
|
|
1172
1341
|
`+p+`
|
|
1173
|
-
`+h,
|
|
1174
|
-
`:"",
|
|
1342
|
+
`+h,y=r.title||"Document",W=r.baseTag!==!1&&!!n?we(n+k.sep).href:"",v=W?` <base href="${tt(W)}" />
|
|
1343
|
+
`:"",A=o==="live"?nt(s??null,W,r.cdn,Ue(u,n,r.templatesDir)):"";return`<!DOCTYPE html>
|
|
1175
1344
|
<html lang="en">
|
|
1176
1345
|
<head>
|
|
1177
1346
|
<meta charset="UTF-8" />
|
|
1178
1347
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
1179
|
-
${
|
|
1348
|
+
${v} <title>${tt(y)}</title>
|
|
1180
1349
|
<style>${x}</style>
|
|
1181
1350
|
</head>
|
|
1182
1351
|
<body>
|
|
1183
1352
|
<div id="markdown-content" class="markdown-body">${u}</div>
|
|
1184
|
-
${
|
|
1353
|
+
${A}
|
|
1185
1354
|
</body>
|
|
1186
|
-
</html>`}finally{try{
|
|
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
|
|
1189
|
-
`+l;for(
|
|
1190
|
-
`,l
|
|
1191
|
-
`,c=1;c<=t.linesAfter&&!(o+c>=n.length);c++)
|
|
1192
|
-
`;return l.replace(/\n$/,"")}var An=
|
|
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
|
|
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
|
|
1195
|
-
`,t-1))}function Ci(e,t,r){var i,n,a,o,l,c,
|
|
1355
|
+
</html>`}finally{try{d&&await d.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 G 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,Tn=gn,$={isNothing:wn,isObject:bn,toArray:vn,repeat:Sn,isNegativeZero:Cn,extend:Tn};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+=`
|
|
1356
|
+
|
|
1357
|
+
`+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 X=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 $.repeat(" ",t-e.length)+e}function Mn(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,d,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++)d=yt(e.buffer,i[o-c],n[o-c],e.position-(i[o]-i[o-c]),u),l=$.repeat(" ",t.indent)+wt((e.line-c+1).toString(),s)+" | "+d.str+`
|
|
1358
|
+
`+l;for(d=yt(e.buffer,i[o],n[o],e.position,u),l+=$.repeat(" ",t.indent)+wt((e.line+1).toString(),s)+" | "+d.str+`
|
|
1359
|
+
`,l+=$.repeat("-",t.indent+s+3+d.pos)+`^
|
|
1360
|
+
`,c=1;c<=t.linesAfter&&!(o+c>=n.length);c++)d=yt(e.buffer,i[o+c],n[o+c],e.position-(i[o]-i[o+c]),u),l+=$.repeat(" ",t.indent)+wt((e.line+c+1).toString(),s)+" | "+d.str+`
|
|
1361
|
+
`;return l.replace(/\n$/,"")}var An=Mn,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 X('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 X('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var V=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 V)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 X("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(a){if(!(a instanceof V))throw new X("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(a.loadKind&&a.loadKind!=="scalar")throw new X("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 X("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 V))throw new X("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 V("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),ar=new V("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),lr=new V("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 V("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 V("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 zn(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 Un(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!$.isNegativeZero(e)}var fr=new V("tag:yaml.org,2002:int",{kind:"scalar",resolve:$n,construct:zn,predicate:Un,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($.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||$.isNegativeZero(e))}var dr=new V("tag:yaml.org,2002:float",{kind:"scalar",resolve:Wn,construct:qn,predicate:Kn,represent:Gn,defaultStyle:"lowercase"}),mr=sr.extend({implicit:[cr,ur,fr,dr]}),pr=mr,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 Jn(e){return e===null?!1:hr.exec(e)!==null||gr.exec(e)!==null}function Xn(e){var t,r,i,n,a,o,l,c=0,d=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),d=(s*60+u)*6e4,t[9]==="-"&&(d=-d)),f=new Date(Date.UTC(r,i,n,a,o,l,c)),d&&f.setTime(f.getTime()-d),f}function Qn(e){return e.toISOString()}var xr=new V("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Jn,construct:Xn,instanceOf:Date,represent:Qn});function Zn(e){return e==="<<"||e===null}var yr=new V("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Zn}),At=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
1362
|
+
\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 V("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 V("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 V("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:ci,construct:ui}),fi=Object.prototype.hasOwnProperty;function di(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 mi(e){return e!==null?e:{}}var Sr=new V("tag:yaml.org,2002:set",{kind:"mapping",resolve:di,construct:mi}),Ft=pr.extend({implicit:[xr,yr],explicit:[wr,br,vr,Sr]}),Se=Object.prototype.hasOwnProperty,ct=1,Cr=2,Tr=3,ut=4,bt=1,pi=2,zt=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=/[,\[\]\{\}]/,Mr=/^(?:!|!!|![a-z\-]+!)$/i,Ar=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Ut(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?`
|
|
1363
|
+
`: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 X(t,r)}function b(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&&b(t,"duplication of %YAML directive"),i.length!==1&&b(t,"YAML directive accepts exactly one argument"),n=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),n===null&&b(t,"ill-formed argument of the YAML directive"),a=parseInt(n[1],10),o=parseInt(n[2],10),a!==1&&b(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&&b(t,"TAG directive accepts exactly two arguments"),n=i[0],a=i[1],Mr.test(n)||b(t,"ill-formed tag handle (first argument) of the TAG directive"),Se.call(t.tagMap,n)&&b(t,'there is a previously declared suffix for "'+n+'" tag handle'),Ar.test(a)||b(t,"ill-formed tag prefix (second argument) of the TAG directive");try{a=decodeURIComponent(a)}catch{b(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||b(e,"expected valid JSON character");else hi.test(l)&&b(e,"the stream contains non-printable characters");e.result+=l}}function qt(e,t,r,i){var n,a,o,l;for($.isObject(r)||b(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 d,s;if(Array.isArray(n))for(n=Array.prototype.slice.call(n),d=0,s=n.length;d<s;d+=1)Array.isArray(n[d])&&b(e,"nested arrays are not supported inside keys"),typeof n=="object"&&Ut(n[d])==="[object Object]"&&(n[d]="[object Object]");if(typeof n=="object"&&Ut(n)==="[object Object]"&&(n="[object Object]"),n=String(n),t===null&&(t={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(a))for(d=0,s=a.length;d<s;d+=1)qt(e,t,a[d],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,b(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++):b(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function D(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+=$.repeat(`
|
|
1364
|
+
`,t-1))}function Ci(e,t,r){var i,n,a,o,l,c,d,s,u=e.kind,f=e.result,m;if(m=e.input.charCodeAt(e.position),Q(m)||je(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===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;m!==0;){if(m===58){if(n=e.input.charCodeAt(e.position+1),Q(n)||r&&je(n))break}else if(m===35){if(i=e.input.charCodeAt(e.position-1),Q(i))break}else{if(e.position===e.lineStart&&pt(e)||r&&je(m))break;if(ce(m))if(c=e.line,d=e.lineStart,s=e.lineIndent,D(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=o,e.line=c,e.lineStart=d,e.lineIndent=s;break}}l&&(ve(e,a,o,!1),Et(e,e.line-c),a=o=e.position,l=!1),ke(m)||(o=e.position+1),m=e.input.charCodeAt(++e.position)}return ve(e,a,o,!1),e.result?!0:(e.kind=u,e.result=f,!1)}function Ti(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,D(e,!1,t)),i=n=e.position):e.position===e.lineStart&&pt(e)?b(e,"unexpected end of the document within a single quoted scalar"):(e.position++,n=e.position);b(e,"unexpected end of the stream within a single quoted scalar")}function Mi(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))D(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:b(e,"expected hexadecimal character");e.result+=vi(a),e.position++}else b(e,"unknown escape sequence");r=i=e.position}else ce(l)?(ve(e,r,i,!0),Et(e,D(e,!1,t)),r=i=e.position):e.position===e.lineStart&&pt(e)?b(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}b(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,d,s,u,f,m,p=Object.create(null),h,x,y,w;if(w=e.input.charCodeAt(e.position),w===91)s=93,m=!1,l=[];else if(w===123)s=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),w=e.input.charCodeAt(++e.position);w!==0;){if(D(e,!0,t),w=e.input.charCodeAt(e.position),w===s)return e.position++,e.tag=o,e.anchor=c,e.kind=m?"mapping":"sequence",e.result=l,!0;r?w===44&&b(e,"expected the node content, but found ','"):b(e,"missed comma between flow collection entries"),x=h=y=null,u=f=!1,w===63&&(d=e.input.charCodeAt(e.position+1),Q(d)&&(u=f=!0,e.position++,D(e,!0,t))),i=e.line,n=e.lineStart,a=e.position,Be(e,t,ct,!1,!0),x=e.tag,h=e.result,D(e,!0,t),w=e.input.charCodeAt(e.position),(f||e.line===i)&&w===58&&(u=!0,w=e.input.charCodeAt(++e.position),D(e,!0,t),Be(e,t,ct,!1,!0),y=e.result),m?Le(e,l,p,x,h,y,i,n,a):u?l.push(Le(e,null,p,x,h,y,i,n,a)):l.push(h),D(e,!0,t),w=e.input.charCodeAt(e.position),w===44?(r=!0,w=e.input.charCodeAt(++e.position)):r=!1}b(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,d=!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?zt:pi:b(e,"repeat of a chomping mode identifier");else if((s=bi(u))>=0)s===0?b(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):o?b(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===zt?e.result+=$.repeat(`
|
|
1196
1365
|
`,a?1+c:c):n===bt&&a&&(e.result+=`
|
|
1197
|
-
`);break}for(i?ke(u)?(
|
|
1198
|
-
`,a?1+c:c)):
|
|
1199
|
-
`,c+1)):c===0?a&&(e.result+=" "):e.result
|
|
1200
|
-
`,c):e.result
|
|
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,
|
|
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,
|
|
1366
|
+
`);break}for(i?ke(u)?(d=!0,e.result+=$.repeat(`
|
|
1367
|
+
`,a?1+c:c)):d?(d=!1,e.result+=$.repeat(`
|
|
1368
|
+
`,c+1)):c===0?a&&(e.result+=" "):e.result+=$.repeat(`
|
|
1369
|
+
`,c):e.result+=$.repeat(`
|
|
1370
|
+
`,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,b(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++,D(e,!0,-1)&&e.lineIndent<=t){a.push(null),c=e.input.charCodeAt(e.position);continue}if(r=e.line,Be(e,t,Tr,!1,!0),a.push(e.result),D(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>t)&&c!==0)b(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,d=e.tag,s=e.anchor,u={},f=Object.create(null),m=null,p=null,h=null,x=!1,y=!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,b(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,m,p,null,o,l,c),m=p=h=null),y=!0,x=!0,n=!0):x?(x=!1,n=!0):b(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)||b(e,"a whitespace character is expected after the key-value separator within a block mapping"),x&&(Le(e,u,f,m,p,null,o,l,c),m=p=h=null),y=!0,x=!1,n=!1,m=e.tag,p=e.result;else if(y)b(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=s,!0}else if(y)b(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,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,m,p,h,o,l,c),m=p=h=null),D(e,!0,-1),w=e.input.charCodeAt(e.position)),(e.line===a||e.lineIndent>t)&&w!==0)b(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return x&&Le(e,u,f,m,p,null,o,l,c),y&&(e.tag=d,e.anchor=s,e.kind="mapping",e.result=u),y}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&&b(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)):b(e,"unexpected end of the stream within a verbatim tag")}else{for(;o!==0&&!Q(o);)o===33&&(i?b(e,"tag suffix cannot contain exclamation marks"):(n=e.input.slice(t-1,e.position+1),Mr.test(n)||b(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)&&b(e,"tag suffix cannot contain flow indicator characters")}a&&!Ar.test(a)&&b(e,"tag name cannot contain such characters: "+a);try{a=decodeURIComponent(a)}catch{b(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:b(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&&b(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&&b(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&&b(e,"name of an alias node must contain at least one character"),r=e.input.slice(t,e.position),Se.call(e.anchorMap,r)||b(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],D(e,!0,-1),!0}function Be(e,t,r,i,n){var a,o,l,c=1,d=!1,s=!1,u,f,m,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||Tr===r,i&&D(e,!0,-1)&&(d=!0,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)),c===1)for(;Ei(e)||Pi(e);)D(e,!0,-1)?(d=!0,l=a,e.lineIndent>t?c=1:e.lineIndent===t?c=0:e.lineIndent<t&&(c=-1)):l=!1;if(l&&(l=d||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)||Ti(e,h)||Mi(e,h)?s=!0:_i(e)?(s=!0,(e.tag!==null||e.anchor!==null)&&b(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"&&b(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,m=e.typeMap.multi[e.kind||"fallback"],u=0,f=m.length;u<f;u+=1)if(e.tag.slice(0,m[u].tag.length)===m[u].tag){p=m[u];break}p||b(e,"unknown tag !<"+e.tag+">"),e.result!==null&&p.kind!==e.kind&&b(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)):b(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&&(D(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&&b(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(D(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,D(e,!0,-1)):a&&b(e,"directives end mark is expected"),Be(e,e.lineIndent-1,ut,!1,!0),D(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,D(e,!0,-1));return}if(e.position<e.length-1)b(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+=`
|
|
1371
|
+
`),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Si(e,t),i=e.indexOf("\0");for(i!==-1&&(r.position=i,b(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 X("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,zi=37,Ui=38,Vi=39,Wi=42,Br=44,qi=45,dt=58,Yi=61,Gi=62,Ki=63,Ji=64,Ir=91,Rr=93,Xi=96,Dr=123,Qi=124,Nr=125,Y={};Y[0]="\\0";Y[7]="\\a";Y[8]="\\b";Y[9]="\\t";Y[10]="\\n";Y[11]="\\v";Y[12]="\\f";Y[13]="\\r";Y[27]="\\e";Y[34]='\\"';Y[92]="\\\\";Y[133]="\\N";Y[160]="\\_";Y[8232]="\\L";Y[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 X("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+$.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=$.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=$.repeat(" ",t),i=0,n=-1,a="",o,l=e.length;i<l;)n=e.indexOf(`
|
|
1203
1372
|
`,i),n===-1?(o=e.slice(i),i=l):(o=e.slice(i,n+1),i=n+1),o.length&&o!==`
|
|
1204
1373
|
`&&(a+=r),a+=o;return a}function Ct(e,t){return`
|
|
1205
|
-
|
|
1374
|
+
`+$.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 mt(e){return e===Ni||e===Ri}function Je(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 Je(e)&&e!==Pt&&e!==Di&&e!==Ge}function Jt(e,t,r){var i=Kt(e),n=i&&!mt(e);return(r?i:i&&e!==Br&&e!==Ir&&e!==Rr&&e!==Dr&&e!==Nr)&&e!==St&&!(t===dt&&!n)||Kt(t)&&!mt(t)&&e===St||t===dt&&n}function ao(e){return Je(e)&&e!==Pt&&!mt(e)&&e!==qi&&e!==Ki&&e!==dt&&e!==Br&&e!==Ir&&e!==Rr&&e!==Dr&&e!==Nr&&e!==St&&e!==Ui&&e!==Wi&&e!==Hi&&e!==Qi&&e!==Yi&&e!==Gi&&e!==Vi&&e!==$i&&e!==zi&&e!==Ji&&e!==Xi}function lo(e){return!mt(e)&&e!==dt}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,Tt=2,zr=3,Ur=4,Oe=5;function so(e,t,r,i,n,a,o,l){var c,d=0,s=null,u=!1,f=!1,m=i!==-1,p=-1,h=ao(qe(e,0))&&lo(qe(e,e.length-1));if(t||o)for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=qe(e,c),!Je(d))return Oe;h=h&&Jt(d,s,l),s=d}else{for(c=0;c<e.length;d>=65536?c+=2:c++){if(d=qe(e,c),d===Ge)u=!0,m&&(f=f||c-p-1>i&&e[p+1]!==" ",p=c);else if(!Je(d))return Oe;h=h&&Jt(d,s,l),s=d}f=f||m&&c-p-1>i&&e[p+1]!==" "}return!u&&!f?h&&!o&&!n(e)?$r:a===Ke?Oe:Tt:r>9&&Hr(e)?Oe:o?a===Ke?Oe:Tt:f?Ur:zr}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(d){return oo(e,d)}switch(so(t,l,e.indent,o,c,e.quotingType,e.forceQuotes&&!i,n)){case $r:return t;case Tt:return"'"+t.replace(/'/g,"''")+"'";case zr:return"|"+Xt(t,e.indent)+Qt(Gt(t,a));case Ur:return">"+Xt(t,e.indent)+Qt(Gt(uo(t,o),a));case Oe:return'"'+fo(t)+'"';default:throw new X("impossible error: invalid scalar style")}})()}function Xt(e,t){var r=Hr(e)?String(t):"",i=e[e.length-1]===`
|
|
1206
1375
|
`,n=i&&(e[e.length-2]===`
|
|
1207
1376
|
`||e===`
|
|
1208
1377
|
`),a=n?"+":i?"":"-";return r+a+`
|
|
1209
1378
|
`}function Qt(e){return e[e.length-1]===`
|
|
1210
|
-
`?e.slice(0,-1):e}function uo(e,t){for(var r=/(\n+)([^\n]*)/g,i=(function(){var
|
|
1211
|
-
`);return
|
|
1379
|
+
`?e.slice(0,-1):e}function uo(e,t){for(var r=/(\n+)([^\n]*)/g,i=(function(){var d=e.indexOf(`
|
|
1380
|
+
`);return d=d!==-1?d:e.length,r.lastIndex=d,Zt(e.slice(0,d),t)})(),n=e[0]===`
|
|
1212
1381
|
`||e[0]===" ",a,o;o=r.exec(e);){var l=o[1],c=o[2];a=c[0]===" ",i+=l+(!n&&!a&&c!==""?`
|
|
1213
1382
|
`:"")+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+=`
|
|
1214
1383
|
`+e.slice(n,a),n=a+1),o=l;return c+=`
|
|
1215
1384
|
`,e.length-n>t&&o>n?c+=e.slice(n,o)+`
|
|
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=
|
|
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=
|
|
1385
|
+
`+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=Y[r],!i&&Je(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,d,s;for(o=0,l=a.length;o<l;o+=1)s="",i!==""&&(s+=", "),e.condenseFlow&&(s+='"'),c=a[o],d=r[c],e.replacer&&(d=e.replacer.call(r,c,d)),ge(e,t,c,!1,!1)&&(e.dump.length>1024&&(s+="? "),s+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),ge(e,t,d,!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,d,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 X("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)),d=o[l],s=r[d],e.replacer&&(s=e.replacer.call(r,d,s)),ge(e,t+1,d,!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 X("!<"+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,d;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 X("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function go(e,t){var r=[],i=[],n,a;for(Mt(e,r,i),n=0,a=i.length;n<a;n+=1)t.duplicates.push(r[i[n]]);t.usedDuplicates=new Array(a)}function Mt(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)Mt(e[n],t,r);else for(i=Object.keys(e),n=0,a=i.length;n<a;n+=1)Mt(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+`
|
|
1386
|
+
`:""}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=V,vo=ir,So=sr,Co=mr,To=pr,Mo=Ft,Ao=Or.load,Fo=Or.loadAll,ko=wo.dump,Eo=X,Po={binary:wr,float:dr,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:To,DEFAULT_SCHEMA:Mo,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=G.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 zo(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)),d=t.basePath??process.cwd(),s=r.content,u,f;if(n==="pdf")u=await Ro(s,{theme:a,basePath:d,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:d,hrAsPageBreak:c,templatesDir:t.templatesDir??i.templatesDir});else if(n==="html")u=await Do(s,{theme:a,basePath:d,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 m=t.image??i.image,p=m?.type?m:{...m??{},type:$o(n)};if(f=await No(s,{theme:a,basePath:d,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=G.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=G.basename(i,G.extname(i)),l=await zo(n,{...r,format:a,basePath:r.basePath??G.dirname(i),title:r.title??o}),c;if(t)c=G.resolve(t);else{let s=G.dirname(i),u=G.basename(i,G.extname(i)),f=Wr(l.format);c=G.join(s,`${u}${f}`)}let d=G.dirname(c);if(ue.existsSync(d)||ue.mkdirSync(d,{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,m=[];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]),m.push(x)}return{buffer:s[0],buffers:s,outputPath:m[0],outputPaths:m,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,zo as n,aa as o};
|
|
1218
1387
|
/*! Bundled license information:
|
|
1219
1388
|
|
|
1220
1389
|
js-yaml/dist/js-yaml.mjs:
|