import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{crt as t,srt as n}from"./app-initial-BHB6SClA.js";import{i as r,n as i,r as a}from"./chunk-AGHRB4JF-D33xM56t.js";import{L as o,O as s,P as c,k as l,s as u,y as d}from"./chunk-ABZYJK2D-Tlzh0RIf.js";import{r as f,t as p}from"./src-D1Kyl_w4.js";import{i as m,u as h}from"./chunk-S3R3BYOJ-TWL1uuTy.js";import{c as g,i as _,n as v,p as y,r as b,s as x,t as S,u as C}from"./esm-B1fsB5y-.js";function w(e,{markdownAutoWrap:t}){let n=S(e.replace(/<br\/>/g,`
`).replace(/\n{2,}/g,`
`));return t===!1?n.replace(/ /g,`&nbsp;`):n}function T(e,n={}){let r=w(e,n),a=t.lexer(r),o=[[]],s=0;function c(e,t=`normal`){e.type===`text`?e.text.split(`
`).forEach((e,n)=>{n!==0&&(s++,o.push([])),e.split(` `).forEach(e=>{e=e.replace(/&#39;/g,`'`),e&&o[s].push({content:e,type:t})})}):e.type===`strong`||e.type===`em`?e.tokens.forEach(t=>{c(t,e.type)}):e.type===`html`&&o[s].push({content:e.text,type:`normal`})}return i(c,`processNode`),a.forEach(e=>{e.type===`paragraph`?e.tokens?.forEach(e=>{c(e)}):e.type===`html`?o[s].push({content:e.text,type:`normal`}):o[s].push({content:e.raw,type:`normal`})}),o}function E(e,{markdownAutoWrap:n}={}){let a=t.lexer(e);function o(e){return e.type===`text`?n===!1?e.text.replace(/\n */g,`<br/>`).replace(/ /g,`&nbsp;`):e.text.replace(/\n */g,`<br/>`):e.type===`strong`?`<strong>${e.tokens?.map(o).join(``)}</strong>`:e.type===`em`?`<em>${e.tokens?.map(o).join(``)}</em>`:e.type===`paragraph`?`<p>${e.tokens?.map(o).join(``)}</p>`:e.type===`space`?``:e.type===`html`?`${e.text}`:e.type===`escape`?e.text:(r.warn(`Unsupported markdown: ${e.type}`),e.raw)}return i(o,`output`),a.map(o).join(``)}function D(e){return Intl.Segmenter?[...new Intl.Segmenter().segment(e)].map(e=>e.segment):[...e]}function O(e,t){return k(e,[],D(t.content),t.type)}function k(e,t,n,r){if(n.length===0)return[{content:t.join(``),type:r},{content:``,type:r}];let[i,...a]=n,o=[...t,i];return e([{content:o.join(``),type:r}])?k(e,o,a,r):(t.length===0&&i&&(t.push(i),n.shift()),[{content:t.join(``),type:r},{content:n.join(``),type:r}])}function A(e,t){if(e.some(({content:e})=>e.includes(`
`)))throw Error(`splitLineToFitWidth does not support newlines in the line`);return j(e,t)}function j(e,t,n=[],r=[]){if(e.length===0)return r.length>0&&n.push(r),n.length>0?n:[];let i=``;e[0].content===` `&&(i=` `,e.shift());let a=e.shift()??{content:` `,type:`normal`},o=[...r];if(i!==``&&o.push({content:i,type:`normal`}),o.push(a),t(o))return j(e,t,n,o);if(r.length>0)n.push(r),e.unshift(a);else if(a.content){let[r,i]=O(t,a);n.push([r]),i.content&&e.unshift(i)}return j(e,t,n)}function M(e,t){t&&e.attr(`style`,t)}async function N(e,t,n,r,i=!1,a=d()){let l=e.append(`foreignObject`);l.attr(`width`,`${10*n}px`),l.attr(`height`,`${10*n}px`);let f=l.append(`xhtml:div`),p=s(t.label)?await c(t.label.replace(u.lineBreakRegex,`
`),a):o(t.label,a),m=t.isNode?`nodeLabel`:`edgeLabel`,h=f.append(`span`);h.html(p),M(h,t.labelStyle),h.attr(`class`,`${m} ${r}`),M(f,t.labelStyle),f.style(`display`,`table-cell`),f.style(`white-space`,`nowrap`),f.style(`line-height`,`1.5`),f.style(`max-width`,n+`px`),f.style(`text-align`,`center`),f.attr(`xmlns`,`http://www.w3.org/1999/xhtml`),i&&f.attr(`class`,`labelBkg`);let g=f.node().getBoundingClientRect();return g.width===n&&(f.style(`display`,`table`),f.style(`white-space`,`break-spaces`),f.style(`width`,n+`px`),g=f.node().getBoundingClientRect()),l.node()}function P(e,t,n){return e.append(`tspan`).attr(`class`,`text-outer-tspan`).attr(`x`,0).attr(`y`,t*n-.1+`em`).attr(`dy`,n+`em`)}function F(e,t,n){let r=e.append(`text`),i=P(r,1,t);R(i,n);let a=i.node().getComputedTextLength();return r.remove(),a}function I(e,t,n){let r=e.append(`text`),i=P(r,1,t);R(i,[{content:n,type:`normal`}]);let a=i.node()?.getBoundingClientRect();return a&&r.remove(),a}function L(e,t,n,r=!1){let a=1.1,o=t.append(`g`),s=o.insert(`rect`).attr(`class`,`background`).attr(`style`,`stroke: none`),c=o.append(`text`).attr(`y`,`-10.1`),l=0;for(let t of n){let n=i(t=>F(o,a,t)<=e,`checkWidth`),r=n(t)?[t]:A(t,n);for(let e of r)R(P(c,l,a),e),l++}if(r){let e=c.node().getBBox();return s.attr(`x`,e.x-2).attr(`y`,e.y-2).attr(`width`,e.width+4).attr(`height`,e.height+4),o.node()}else return c.node()}function R(e,t){e.text(``),t.forEach((t,n)=>{let r=e.append(`tspan`).attr(`font-style`,t.type===`em`?`italic`:`normal`).attr(`class`,`text-inner-tspan`).attr(`font-weight`,t.type===`strong`?`bold`:`normal`);n===0?r.text(t.content):r.text(` `+t.content)})}async function z(e,t={}){let n=[];e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,(e,r,i)=>(n.push((async()=>{let n=`${r}:${i}`;return await G(n)?await K(n,void 0,{class:`label-icon`}):`<i class='${o(e,t).replace(`:`,` `)}'></i>`})()),e));let r=await Promise.all(n);return e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,()=>r.shift()??``)}var B,V,H,U,W,G,K,q,J=e((()=>{h(),l(),a(),b(),p(),n(),v(),B={body:`<g><rect width="80" height="80" style="fill: #087ebf; stroke-width: 0px;"/><text transform="translate(21.16 64.67)" style="fill: #fff; font-family: ArialMT, Arial; font-size: 67.75px;"><tspan x="0" y="0">?</tspan></text></g>`,height:80,width:80},V=new Map,H=new Map,U=i(e=>{for(let t of e){if(!t.name)throw Error(`Invalid icon loader. Must have a "name" property with non-empty string value.`);if(r.debug(`Registering icon pack:`,t.name),`loader`in t)H.set(t.name,t.loader);else if(`icons`in t)V.set(t.name,t.icons);else throw r.error(`Invalid icon loader:`,t),Error(`Invalid icon loader. Must have either "icons" or "loader" property.`)}},`registerIconPacks`),W=i(async(e,t)=>{let n=y(e,!0,t!==void 0);if(!n)throw Error(`Invalid icon name: ${e}`);let i=n.prefix||t;if(!i)throw Error(`Icon name must contain a prefix: ${e}`);let a=V.get(i);if(!a){let e=H.get(i);if(!e)throw Error(`Icon set not found: ${n.prefix}`);try{a={...await e(),prefix:i},V.set(i,a)}catch(e){throw r.error(e),Error(`Failed to load icon set: ${n.prefix}`)}}let o=C(a,n.name);if(!o)throw Error(`Icon not found: ${e}`);return o},`getRegisteredIconData`),G=i(async e=>{try{return await W(e),!0}catch{return!1}},`isIconAvailable`),K=i(async(e,t,n)=>{let i;try{i=await W(e,t?.fallbackPrefix)}catch(e){r.error(e),i=B}let a=g(i,t);return o(_(x(a.body),{...a.attributes,...n}),d())},`getIconSVG`),i(w,`preprocessMarkdown`),i(T,`markdownToLines`),i(E,`markdownToHTML`),i(D,`splitTextToChars`),i(O,`splitWordToFitWidth`),i(k,`splitWordToFitWidthRecursion`),i(A,`splitLineToFitWidth`),i(j,`splitLineToFitWidthRecursion`),i(M,`applyStyle`),i(N,`addHtmlSpan`),i(P,`createTspan`),i(F,`computeWidthOfText`),i(I,`computeDimensionOfText`),i(L,`createFormattedText`),i(R,`updateTextContentAndStyles`),i(z,`replaceIconSubstring`),q=i(async(e,t=``,{style:n=``,isTitle:i=!1,classes:a=``,useHtmlLabels:o=!0,isNode:c=!0,width:l=200,addSvgBackground:u=!1}={},d)=>{if(r.debug(`XYZ createText`,t,n,i,a,o,c,`addSvgBackground: `,u),o){let r=await z(m(E(t,d)),d),i=t.replace(/\\\\/g,`\\`);return await N(e,{isNode:c,label:s(t)?i:r,labelStyle:n.replace(`fill:`,`color:`)},l,a,u,d)}else{let r=L(l,e,T(t.replace(/<br\s*\/?>/g,`<br/>`).replace(`<br>`,`<br/>`),d),t?u:!1);if(c){/stroke:/.exec(n)&&(n=n.replace(`stroke:`,`lineColor:`));let e=n.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);f(r).attr(`style`,e)}else{let e=n.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/background:/g,`fill:`);f(r).select(`rect`).attr(`style`,e.replace(/background:/g,`fill:`));let t=n.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);f(r).select(`text`).attr(`style`,t)}return r}},`createText`)}));export{U as a,J as i,q as n,z as o,K as r,B as s,I as t};
//# sourceMappingURL=chunk-JA3XYJ7Z-B2k1biQX.js.map