import{i as e}from"./chunk-S3R3BYOJ-DfDjEEj9.js";import{t}from"./src-BHeH9bp0.js";import{n,r}from"./chunk-AGHRB4JF-CwjJfTB_.js";import{I as i,N as a,O as o,s,y as c}from"./chunk-ABZYJK2D-waC_LI3S.js";import{a as l,i as u,n as d,o as f,r as p,t as m}from"./esm-D3bORTFC.js";import{n as h}from"./marked.esm-BR-H6018.js";var g={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},_=new Map,v=new Map,y=n(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)v.set(t.name,t.loader);else if(`icons`in t)_.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`),b=n(async(e,t)=>{let n=f(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=_.get(i);if(!a){let e=v.get(i);if(!e)throw Error(`Icon set not found: ${n.prefix}`);try{a={...await e(),prefix:i},_.set(i,a)}catch(e){throw r.error(e),Error(`Failed to load icon set: ${n.prefix}`)}}let o=l(a,n.name);if(!o)throw Error(`Icon not found: ${e}`);return o},`getRegisteredIconData`),x=n(async e=>{try{return await b(e),!0}catch{return!1}},`isIconAvailable`),S=n(async(e,t,n)=>{let a;try{a=await b(e,t?.fallbackPrefix)}catch(e){r.error(e),a=g}let o=u(a,t);return i(d(p(o.body),{...o.attributes,...n}),c())},`getIconSVG`);function C(e,{markdownAutoWrap:t}){let n=m(e.replace(/<br\/>/g,`
`).replace(/\n{2,}/g,`
`));return t===!1?n.replace(/ /g,`&nbsp;`):n}n(C,`preprocessMarkdown`);function w(e,t={}){let r=C(e,t),i=h.lexer(r),a=[[]],o=0;function s(e,t=`normal`){e.type===`text`?e.text.split(`
`).forEach((e,n)=>{n!==0&&(o++,a.push([])),e.split(` `).forEach(e=>{e=e.replace(/&#39;/g,`'`),e&&a[o].push({content:e,type:t})})}):e.type===`strong`||e.type===`em`?e.tokens.forEach(t=>{s(t,e.type)}):e.type===`html`&&a[o].push({content:e.text,type:`normal`})}return n(s,`processNode`),i.forEach(e=>{e.type===`paragraph`?e.tokens?.forEach(e=>{s(e)}):e.type===`html`?a[o].push({content:e.text,type:`normal`}):a[o].push({content:e.raw,type:`normal`})}),a}n(w,`markdownToLines`);function T(e,{markdownAutoWrap:t}={}){let i=h.lexer(e);function a(e){return e.type===`text`?t===!1?e.text.replace(/\n */g,`<br/>`).replace(/ /g,`&nbsp;`):e.text.replace(/\n */g,`<br/>`):e.type===`strong`?`<strong>${e.tokens?.map(a).join(``)}</strong>`:e.type===`em`?`<em>${e.tokens?.map(a).join(``)}</em>`:e.type===`paragraph`?`<p>${e.tokens?.map(a).join(``)}</p>`:e.type===`space`?``:e.type===`html`?`${e.text}`:e.type===`escape`?e.text:(r.warn(`Unsupported markdown: ${e.type}`),e.raw)}return n(a,`output`),i.map(a).join(``)}n(T,`markdownToHTML`);function E(e){return Intl.Segmenter?[...new Intl.Segmenter().segment(e)].map(e=>e.segment):[...e]}n(E,`splitTextToChars`);function D(e,t){return O(e,[],E(t.content),t.type)}n(D,`splitWordToFitWidth`);function O(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}])?O(e,o,a,r):(t.length===0&&i&&(t.push(i),n.shift()),[{content:t.join(``),type:r},{content:n.join(``),type:r}])}n(O,`splitWordToFitWidthRecursion`);function k(e,t){if(e.some(({content:e})=>e.includes(`
`)))throw Error(`splitLineToFitWidth does not support newlines in the line`);return A(e,t)}n(k,`splitLineToFitWidth`);function A(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 A(e,t,n,o);if(r.length>0)n.push(r),e.unshift(a);else if(a.content){let[r,i]=D(t,a);n.push([r]),i.content&&e.unshift(i)}return A(e,t,n)}n(A,`splitLineToFitWidthRecursion`);function j(e,t){t&&e.attr(`style`,t)}n(j,`applyStyle`);async function M(e,t,n,r,l=!1,u=c()){let d=e.append(`foreignObject`);d.attr(`width`,`${10*n}px`),d.attr(`height`,`${10*n}px`);let f=d.append(`xhtml:div`),p=o(t.label)?await a(t.label.replace(s.lineBreakRegex,`
`),u):i(t.label,u),m=t.isNode?`nodeLabel`:`edgeLabel`,h=f.append(`span`);h.html(p),j(h,t.labelStyle),h.attr(`class`,`${m} ${r}`),j(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`),l&&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()),d.node()}n(M,`addHtmlSpan`);function N(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`)}n(N,`createTspan`);function P(e,t,n){let r=e.append(`text`),i=N(r,1,t);L(i,n);let a=i.node().getComputedTextLength();return r.remove(),a}n(P,`computeWidthOfText`);function F(e,t,n){let r=e.append(`text`),i=N(r,1,t);L(i,[{content:n,type:`normal`}]);let a=i.node()?.getBoundingClientRect();return a&&r.remove(),a}n(F,`computeDimensionOfText`);function I(e,t,r,i=!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 r){let r=n(t=>P(o,a,t)<=e,`checkWidth`),i=r(t)?[t]:k(t,r);for(let e of i)L(N(c,l,a),e),l++}if(i){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()}n(I,`createFormattedText`);function L(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)})}n(L,`updateTextContentAndStyles`);async function R(e,t={}){let n=[];e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,(e,r,a)=>(n.push((async()=>{let n=`${r}:${a}`;return await x(n)?await S(n,void 0,{class:`label-icon`}):`<i class='${i(e,t).replace(`:`,` `)}'></i>`})()),e));let r=await Promise.all(n);return e.replace(/(fa[bklrs]?):fa-([\w-]+)/g,()=>r.shift()??``)}n(R,`replaceIconSubstring`);var z=n(async(n,i=``,{style:a=``,isTitle:s=!1,classes:c=``,useHtmlLabels:l=!0,isNode:u=!0,width:d=200,addSvgBackground:f=!1}={},p)=>{if(r.debug(`XYZ createText`,i,a,s,c,l,u,`addSvgBackground: `,f),l){let t=await R(e(T(i,p)),p),r=i.replace(/\\\\/g,`\\`);return await M(n,{isNode:u,label:o(i)?r:t,labelStyle:a.replace(`fill:`,`color:`)},d,c,f,p)}else{let e=I(d,n,w(i.replace(/<br\s*\/?>/g,`<br/>`).replace(`<br>`,`<br/>`),p),i?f:!1);if(u){/stroke:/.exec(a)&&(a=a.replace(`stroke:`,`lineColor:`));let n=a.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);t(e).attr(`style`,n)}else{let n=a.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/background:/g,`fill:`);t(e).select(`rect`).attr(`style`,n.replace(/background:/g,`fill:`));let r=a.replace(/stroke:[^;]+;?/g,``).replace(/stroke-width:[^;]+;?/g,``).replace(/fill:[^;]+;?/g,``).replace(/color:/g,`fill:`);t(e).select(`text`).attr(`style`,r)}return e}},`createText`);export{R as a,y as i,z as n,g as o,S as r,F as t};
//# sourceMappingURL=chunk-JA3XYJ7Z-DcuPILh7.js.map