import{l as At,v as zt}from"./intro.stories-824e97fd.js";import{d as It}from"./index-356e4a49.js";const Tt={};function Bt(n,r){const t=r||Tt,e=typeof t.includeImageAlt=="boolean"?t.includeImageAlt:!0,i=typeof t.includeHtml=="boolean"?t.includeHtml:!0;return nt(n,e,i)}function nt(n,r,t){if(Lt(n)){if("value"in n)return n.type==="html"&&!t?"":n.value;if(r&&"alt"in n&&n.alt)return n.alt;if("children"in n)return Hn(n.children,r,t)}return Array.isArray(n)?Hn(n,r,t):""}function Hn(n,r,t){const e=[];let i=-1;for(;++ii?0:i+r:r=r>i?i:r,t=t>0?t:0,e.length<1e4)u=Array.from(e),u.unshift(r,t),[].splice.apply(n,u);else for(t&&[].splice.apply(n,[r,t]);l0?(en(n,n.length,0,r),n):r}const Nn={}.hasOwnProperty;function Ot(n){const r={};let t=-1;for(;++tu))return;const P=r.events.length;let j=P,R,V;for(;j--;)if(r.events[j][0]==="exit"&&r.events[j][1].type==="chunkFlow"){if(R){V=r.events[j][1].end;break}R=!0}for(y(e),d=P;dF;){const O=t[L];r.containerState=O[1],O[0].exit.call(r,n)}t.length=F}function _(){i.write([null]),l=void 0,i=void 0,r.containerState._closeFlow=void 0}}function Qt(n,r,t){return T(n,n.attempt(this.parser.constructs.document,r,t),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function Qn(n){if(n===null||Y(n)||Rt(n))return 1;if(qt(n))return 2}function Ln(n,r,t){const e=[];let i=-1;for(;++i1&&n[t][1].end.offset-n[t][1].start.offset>1?2:1;const x=Object.assign({},n[e][1].end),g=Object.assign({},n[t][1].start);Un(x,-c),Un(g,c),u={type:c>1?"strongSequence":"emphasisSequence",start:x,end:Object.assign({},n[e][1].end)},a={type:c>1?"strongSequence":"emphasisSequence",start:Object.assign({},n[t][1].start),end:g},l={type:c>1?"strongText":"emphasisText",start:Object.assign({},n[e][1].end),end:Object.assign({},n[t][1].start)},i={type:c>1?"strong":"emphasis",start:Object.assign({},u.start),end:Object.assign({},a.end)},n[e][1].end=Object.assign({},u.start),n[t][1].start=Object.assign({},a.end),p=[],n[e][1].end.offset-n[e][1].start.offset&&(p=Z(p,[["enter",n[e][1],r],["exit",n[e][1],r]])),p=Z(p,[["enter",i,r],["enter",u,r],["exit",u,r],["enter",l,r]]),p=Z(p,Ln(r.parser.constructs.insideSpan.null,n.slice(e+1,t),r)),p=Z(p,[["exit",l,r],["enter",a,r],["exit",a,r],["exit",i,r]]),n[t][1].end.offset-n[t][1].start.offset?(h=2,p=Z(p,[["enter",n[t][1],r],["exit",n[t][1],r]])):h=0,en(n,e-1,t-e+3,p),t=e+p.length-h-2;break}}for(t=-1;++t=4?u(p):t(p)}function u(p){return p===null?c(p):C(p)?n.attempt(ee,u,c)(p):(n.enter("codeFlowValue"),a(p))}function a(p){return p===null||C(p)?(n.exit("codeFlowValue"),u(p)):(n.consume(p),a)}function c(p){return n.exit("codeIndented"),r(p)}}function ie(n,r,t){const e=this;return i;function i(u){return e.parser.lazy[e.now().line]?t(u):C(u)?(n.enter("lineEnding"),n.consume(u),n.exit("lineEnding"),i):T(n,l,"linePrefix",4+1)(u)}function l(u){const a=e.events[e.events.length-1];return a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?r(u):C(u)?i(u):t(u)}}const ue={name:"codeText",tokenize:oe,resolve:le,previous:ae};function le(n){let r=n.length-4,t=3,e,i;if((n[t][1].type==="lineEnding"||n[t][1].type==="space")&&(n[r][1].type==="lineEnding"||n[r][1].type==="space")){for(e=t;++e=4?r(u):n.interrupt(e.parser.constructs.flow,t,r)(u)}}function ut(n,r,t,e,i,l,u,a,c){const p=c||Number.POSITIVE_INFINITY;let h=0;return x;function x(y){return y===60?(n.enter(e),n.enter(i),n.enter(l),n.consume(y),n.exit(l),g):y===null||y===41||zn(y)?t(y):(n.enter(e),n.enter(u),n.enter(a),n.enter("chunkString",{contentType:"string"}),B(y))}function g(y){return y===62?(n.enter(l),n.consume(y),n.exit(l),n.exit(i),n.exit(e),r):(n.enter(a),n.enter("chunkString",{contentType:"string"}),f(y))}function f(y){return y===62?(n.exit("chunkString"),n.exit(a),g(y)):y===null||y===60||C(y)?t(y):(n.consume(y),y===92?k:f)}function k(y){return y===60||y===62||y===92?(n.consume(y),f):f(y)}function B(y){return y===40?++h>p?t(y):(n.consume(y),B):y===41?h--?(n.consume(y),B):(n.exit("chunkString"),n.exit(a),n.exit(u),n.exit(e),r(y)):y===null||Y(y)?h?t(y):(n.exit("chunkString"),n.exit(a),n.exit(u),n.exit(e),r(y)):zn(y)?t(y):(n.consume(y),y===92?D:B)}function D(y){return y===40||y===41||y===92?(n.consume(y),B):B(y)}}function lt(n,r,t,e,i,l){const u=this;let a=0,c;return p;function p(f){return n.enter(e),n.enter(i),n.consume(f),n.exit(i),n.enter(l),h}function h(f){return f===null||f===91||f===93&&!c||f===94&&!a&&"_hiddenFootnoteSupport"in u.parser.constructs||a>999?t(f):f===93?(n.exit(l),n.enter(i),n.consume(f),n.exit(i),n.exit(e),r):C(f)?(n.enter("lineEnding"),n.consume(f),n.exit("lineEnding"),h):(n.enter("chunkString",{contentType:"string"}),x(f))}function x(f){return f===null||f===91||f===93||C(f)||a++>999?(n.exit("chunkString"),h(f)):(n.consume(f),c=c||!q(f),f===92?g:x)}function g(f){return f===91||f===92||f===93?(n.consume(f),a++,x):x(f)}}function at(n,r,t,e,i,l){let u;return a;function a(g){return n.enter(e),n.enter(i),n.consume(g),n.exit(i),u=g===40?41:g,c}function c(g){return g===u?(n.enter(i),n.consume(g),n.exit(i),n.exit(e),r):(n.enter(l),p(g))}function p(g){return g===u?(n.exit(l),c(u)):g===null?t(g):C(g)?(n.enter("lineEnding"),n.consume(g),n.exit("lineEnding"),T(n,p,"linePrefix")):(n.enter("chunkString",{contentType:"string"}),h(g))}function h(g){return g===u||g===null||C(g)?(n.exit("chunkString"),p(g)):(n.consume(g),g===92?x:h)}function x(g){return g===u||g===92?(n.consume(g),h):h(g)}}function dn(n,r){let t;return e;function e(i){return C(i)?(n.enter("lineEnding"),n.consume(i),n.exit("lineEnding"),t=!0,e):q(i)?T(n,e,t?"linePrefix":"lineSuffix")(i):r(i)}}function fn(n){return n.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const xe={name:"definition",tokenize:ke},ge={tokenize:de,partial:!0};function ke(n,r,t){const e=this;let i;return l;function l(c){return n.enter("definition"),lt.call(e,n,u,t,"definitionLabel","definitionLabelMarker","definitionLabelString")(c)}function u(c){return i=fn(e.sliceSerialize(e.events[e.events.length-1][1]).slice(1,-1)),c===58?(n.enter("definitionMarker"),n.consume(c),n.exit("definitionMarker"),dn(n,ut(n,n.attempt(ge,T(n,a,"whitespace"),T(n,a,"whitespace")),t,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString"))):t(c)}function a(c){return c===null||C(c)?(n.exit("definition"),e.parser.defined.includes(i)||e.parser.defined.push(i),r(c)):t(c)}}function de(n,r,t){return e;function e(u){return Y(u)?dn(n,i)(u):t(u)}function i(u){return u===34||u===39||u===40?at(n,T(n,l,"whitespace"),t,"definitionTitle","definitionTitleMarker","definitionTitleString")(u):t(u)}function l(u){return u===null||C(u)?r(u):t(u)}}const be={name:"hardBreakEscape",tokenize:ye};function ye(n,r,t){return e;function e(l){return n.enter("hardBreakEscape"),n.enter("escapeMarker"),n.consume(l),i}function i(l){return C(l)?(n.exit("escapeMarker"),n.exit("hardBreakEscape"),r(l)):t(l)}}const Se={name:"headingAtx",tokenize:Ee,resolve:Fe};function Fe(n,r){let t=n.length-2,e=3,i,l;return n[e][1].type==="whitespace"&&(e+=2),t-2>e&&n[t][1].type==="whitespace"&&(t-=2),n[t][1].type==="atxHeadingSequence"&&(e===t-1||t-4>e&&n[t-2][1].type==="whitespace")&&(t-=e+1===t?2:4),t>e&&(i={type:"atxHeadingText",start:n[e][1].start,end:n[t][1].end},l={type:"chunkText",start:n[e][1].start,end:n[t][1].end,contentType:"text"},en(n,e,t-e+1,[["enter",i,r],["enter",l,r],["exit",l,r],["exit",i,r]])),n}function Ee(n,r,t){const e=this;let i=0;return l;function l(h){return n.enter("atxHeading"),n.enter("atxHeadingSequence"),u(h)}function u(h){return h===35&&i++<6?(n.consume(h),u):h===null||Y(h)?(n.exit("atxHeadingSequence"),e.interrupt?r(h):a(h)):t(h)}function a(h){return h===35?(n.enter("atxHeadingSequence"),c(h)):h===null||C(h)?(n.exit("atxHeading"),r(h)):q(h)?T(n,a,"whitespace")(h):(n.enter("atxHeadingText"),p(h))}function c(h){return h===35?(n.consume(h),c):(n.exit("atxHeadingSequence"),a(h))}function p(h){return h===null||h===35||Y(h)?(n.exit("atxHeadingText"),a(h)):(n.consume(h),p)}}const we=["address","article","aside","base","basefont","blockquote","body","caption","center","col","colgroup","dd","details","dialog","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hr","html","iframe","legend","li","link","main","menu","menuitem","nav","noframes","ol","optgroup","option","p","param","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],Yn=["pre","script","style","textarea"],Ce={name:"htmlFlow",tokenize:Ie,resolveTo:ze,concrete:!0},Ae={tokenize:Te,partial:!0};function ze(n){let r=n.length;for(;r--&&!(n[r][0]==="enter"&&n[r][1].type==="htmlFlow"););return r>1&&n[r-2][1].type==="linePrefix"&&(n[r][1].start=n[r-2][1].start,n[r+1][1].start=n[r-2][1].start,n.splice(r-2,2)),n}function Ie(n,r,t){const e=this;let i,l,u,a,c;return p;function p(o){return n.enter("htmlFlow"),n.enter("htmlFlowData"),n.consume(o),h}function h(o){return o===33?(n.consume(o),x):o===47?(n.consume(o),k):o===63?(n.consume(o),i=3,e.interrupt?r:U):tn(o)?(n.consume(o),u=String.fromCharCode(o),l=!0,B):t(o)}function x(o){return o===45?(n.consume(o),i=2,g):o===91?(n.consume(o),i=5,u="CDATA[",a=0,f):tn(o)?(n.consume(o),i=4,e.interrupt?r:U):t(o)}function g(o){return o===45?(n.consume(o),e.interrupt?r:U):t(o)}function f(o){return o===u.charCodeAt(a++)?(n.consume(o),a===u.length?e.interrupt?r:S:f):t(o)}function k(o){return tn(o)?(n.consume(o),u=String.fromCharCode(o),B):t(o)}function B(o){return o===null||o===47||o===62||Y(o)?o!==47&&l&&Yn.includes(u.toLowerCase())?(i=1,e.interrupt?r(o):S(o)):we.includes(u.toLowerCase())?(i=6,o===47?(n.consume(o),D):e.interrupt?r(o):S(o)):(i=7,e.interrupt&&!e.parser.lazy[e.now().line]?t(o):l?_(o):y(o)):o===45||v(o)?(n.consume(o),u+=String.fromCharCode(o),B):t(o)}function D(o){return o===62?(n.consume(o),e.interrupt?r:S):t(o)}function y(o){return q(o)?(n.consume(o),y):R(o)}function _(o){return o===47?(n.consume(o),R):o===58||o===95||tn(o)?(n.consume(o),F):q(o)?(n.consume(o),_):R(o)}function F(o){return o===45||o===46||o===58||o===95||v(o)?(n.consume(o),F):L(o)}function L(o){return o===61?(n.consume(o),O):q(o)?(n.consume(o),L):_(o)}function O(o){return o===null||o===60||o===61||o===62||o===96?t(o):o===34||o===39?(n.consume(o),c=o,d):q(o)?(n.consume(o),O):(c=null,P(o))}function d(o){return o===null||C(o)?t(o):o===c?(n.consume(o),j):(n.consume(o),d)}function P(o){return o===null||o===34||o===39||o===60||o===61||o===62||o===96||Y(o)?L(o):(n.consume(o),P)}function j(o){return o===47||o===62||q(o)?_(o):t(o)}function R(o){return o===62?(n.consume(o),V):t(o)}function V(o){return q(o)?(n.consume(o),V):o===null||C(o)?S(o):t(o)}function S(o){return o===45&&i===2?(n.consume(o),G):o===60&&i===1?(n.consume(o),nn):o===62&&i===4?(n.consume(o),H):o===63&&i===3?(n.consume(o),U):o===93&&i===5?(n.consume(o),W):C(o)&&(i===6||i===7)?n.check(Ae,H,E)(o):o===null||C(o)?E(o):(n.consume(o),S)}function E(o){return n.exit("htmlFlowData"),A(o)}function A(o){return o===null?s(o):C(o)?n.attempt({tokenize:Q,partial:!0},A,s)(o):(n.enter("htmlFlowData"),S(o))}function Q(o,cn,xn){return hn;function hn(K){return o.enter("lineEnding"),o.consume(K),o.exit("lineEnding"),N}function N(K){return e.parser.lazy[e.now().line]?xn(K):cn(K)}}function G(o){return o===45?(n.consume(o),U):S(o)}function nn(o){return o===47?(n.consume(o),u="",J):S(o)}function J(o){return o===62&&Yn.includes(u.toLowerCase())?(n.consume(o),H):tn(o)&&u.length<8?(n.consume(o),u+=String.fromCharCode(o),J):S(o)}function W(o){return o===93?(n.consume(o),U):S(o)}function U(o){return o===62?(n.consume(o),H):o===45&&i===2?(n.consume(o),U):S(o)}function H(o){return o===null||C(o)?(n.exit("htmlFlowData"),s(o)):(n.consume(o),H)}function s(o){return n.exit("htmlFlow"),r(o)}}function Te(n,r,t){return e;function e(i){return n.exit("htmlFlowData"),n.enter("lineEndingBlank"),n.consume(i),n.exit("lineEndingBlank"),n.attempt(Sn,r,t)}}const Be={name:"htmlText",tokenize:Le};function Le(n,r,t){const e=this;let i,l,u,a;return c;function c(s){return n.enter("htmlText"),n.enter("htmlTextData"),n.consume(s),p}function p(s){return s===33?(n.consume(s),h):s===47?(n.consume(s),P):s===63?(n.consume(s),O):tn(s)?(n.consume(s),V):t(s)}function h(s){return s===45?(n.consume(s),x):s===91?(n.consume(s),l="CDATA[",u=0,D):tn(s)?(n.consume(s),L):t(s)}function x(s){return s===45?(n.consume(s),g):t(s)}function g(s){return s===null||s===62?t(s):s===45?(n.consume(s),f):k(s)}function f(s){return s===null||s===62?t(s):k(s)}function k(s){return s===null?t(s):s===45?(n.consume(s),B):C(s)?(a=k,W(s)):(n.consume(s),k)}function B(s){return s===45?(n.consume(s),H):k(s)}function D(s){return s===l.charCodeAt(u++)?(n.consume(s),u===l.length?y:D):t(s)}function y(s){return s===null?t(s):s===93?(n.consume(s),_):C(s)?(a=y,W(s)):(n.consume(s),y)}function _(s){return s===93?(n.consume(s),F):y(s)}function F(s){return s===62?H(s):s===93?(n.consume(s),F):y(s)}function L(s){return s===null||s===62?H(s):C(s)?(a=L,W(s)):(n.consume(s),L)}function O(s){return s===null?t(s):s===63?(n.consume(s),d):C(s)?(a=O,W(s)):(n.consume(s),O)}function d(s){return s===62?H(s):O(s)}function P(s){return tn(s)?(n.consume(s),j):t(s)}function j(s){return s===45||v(s)?(n.consume(s),j):R(s)}function R(s){return C(s)?(a=R,W(s)):q(s)?(n.consume(s),R):H(s)}function V(s){return s===45||v(s)?(n.consume(s),V):s===47||s===62||Y(s)?S(s):t(s)}function S(s){return s===47?(n.consume(s),H):s===58||s===95||tn(s)?(n.consume(s),E):C(s)?(a=S,W(s)):q(s)?(n.consume(s),S):H(s)}function E(s){return s===45||s===46||s===58||s===95||v(s)?(n.consume(s),E):A(s)}function A(s){return s===61?(n.consume(s),Q):C(s)?(a=A,W(s)):q(s)?(n.consume(s),A):S(s)}function Q(s){return s===null||s===60||s===61||s===62||s===96?t(s):s===34||s===39?(n.consume(s),i=s,G):C(s)?(a=Q,W(s)):q(s)?(n.consume(s),Q):(n.consume(s),i=void 0,J)}function G(s){return s===i?(n.consume(s),nn):s===null?t(s):C(s)?(a=G,W(s)):(n.consume(s),G)}function nn(s){return s===62||s===47||Y(s)?S(s):t(s)}function J(s){return s===null||s===34||s===39||s===60||s===61||s===96?t(s):s===62||Y(s)?S(s):(n.consume(s),J)}function W(s){return n.exit("htmlTextData"),n.enter("lineEnding"),n.consume(s),n.exit("lineEnding"),T(n,U,"linePrefix",e.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function U(s){return n.enter("htmlTextData"),a(s)}function H(s){return s===62?(n.consume(s),n.exit("htmlTextData"),n.exit("htmlText"),r):t(s)}}const Dn={name:"labelEnd",tokenize:je,resolveTo:Me,resolveAll:_e},Oe={tokenize:Re},De={tokenize:qe},Pe={tokenize:He};function _e(n){let r=-1,t;for(;++r-1&&(u[0]=u[0].slice(e)),l>0&&u.push(n[i].slice(0,l))),u}function cr(n,r){let t=-1;const e=[];let i;for(;++t13&&t<32||t>126&&t<160||t>55295&&t<57344||t>64975&&t<65008||(t&65535)===65535||(t&65535)===65534||t>1114111?"�":String.fromCharCode(t)}const wr=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Cr(n){return n.replace(wr,Ar)}function Ar(n,r,t){if(r)return r;if(t.charCodeAt(0)===35){const i=t.charCodeAt(1),l=i===120||i===88;return ct(t.slice(l?2:1),l?16:10)}return On(t)||n}function yn(n){return!n||typeof n!="object"?"":"position"in n||"type"in n?Kn(n.position):"start"in n||"end"in n?Kn(n):"line"in n||"column"in n?Tn(n):""}function Tn(n){return Xn(n&&n.line)+":"+Xn(n&&n.column)}function Kn(n){return Tn(n&&n.start)+"-"+Tn(n&&n.end)}function Xn(n){return n&&typeof n=="number"?n:1}const ht={}.hasOwnProperty,pt=function(n,r,t){return typeof r!="string"&&(t=r,r=void 0),zr(t)(Er(Sr(t).document().write(Fr()(n,r,!0))))};function zr(n){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(Rn),autolinkProtocol:S,autolinkEmail:S,atxHeading:a(_n),blockQuote:a(Fn),characterEscape:S,characterReference:S,codeFenced:a(Pn),codeFencedFenceInfo:c,codeFencedFenceMeta:c,codeIndented:a(Pn,c),codeText:a(kt,c),codeTextData:S,data:S,codeFlowValue:S,definition:a(dt),definitionDestinationString:c,definitionLabelString:c,definitionTitleString:c,emphasis:a(bt),hardBreakEscape:a(Mn),hardBreakTrailing:a(Mn),htmlFlow:a(jn,c),htmlFlowData:S,htmlText:a(jn,c),htmlTextData:S,image:a(yt),label:c,link:a(Rn),listItem:a(St),listItemValue:k,listOrdered:a(qn,f),listUnordered:a(qn),paragraph:a(Ft),reference:hn,referenceString:c,resourceDestinationString:c,resourceTitleString:c,setextHeading:a(_n),strong:a(Et),thematicBreak:a(Ct)},exit:{atxHeading:h(),atxHeadingSequence:P,autolink:h(),autolinkEmail:mn,autolinkProtocol:pn,blockQuote:h(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:K,characterReferenceMarkerNumeric:K,characterReferenceValue:ln,codeFenced:h(_),codeFencedFence:y,codeFencedFenceInfo:B,codeFencedFenceMeta:D,codeFlowValue:E,codeIndented:h(F),codeText:h(J),codeTextData:E,data:E,definition:h(),definitionDestinationString:d,definitionLabelString:L,definitionTitleString:O,emphasis:h(),hardBreakEscape:h(Q),hardBreakTrailing:h(Q),htmlFlow:h(G),htmlFlowData:E,htmlText:h(nn),htmlTextData:E,image:h(U),label:s,labelText:H,lineEnding:A,link:h(W),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:N,resourceDestinationString:o,resourceTitleString:cn,resource:xn,setextHeading:h(V),setextHeadingLineSequence:R,setextHeadingText:j,strong:h(),thematicBreak:h()}};mt(r,(n||{}).mdastExtensions||[]);const t={};return e;function e(m){let b={type:"root",children:[]};const w={stack:[b],tokenStack:[],config:r,enter:p,exit:x,buffer:c,resume:g,setData:l,getData:u},z=[];let I=-1;for(;++I0){const X=w.tokenStack[w.tokenStack.length-1];(X[1]||vn).call(w,void 0,X[0])}for(b.position={start:on(m.length>0?m[0][1].start:{line:1,column:1,offset:0}),end:on(m.length>0?m[m.length-2][1].end:{line:1,column:1,offset:0})},I=-1;++I{h!==0&&(i++,e.push([])),p.split(" ").forEach(x=>{x&&e[i].push({content:x,type:a})})}):(u.type==="strong"||u.type==="emphasis")&&u.children.forEach(c=>{l(c,u.type)})}return t.forEach(u=>{u.type==="paragraph"&&u.children.forEach(a=>{l(a)})}),e}function Lr(n){const{children:r}=pt(n);function t(e){return e.type==="text"?e.value.replace(/\n/g,"
"):e.type==="strong"?`${e.children.map(t).join("")}`:e.type==="emphasis"?`${e.children.map(t).join("")}`:e.type==="paragraph"?`

${e.children.map(t).join("")}

`:`Unsupported markdown: ${e.type}`}return r.map(t).join("")}function Or(n){return Intl.Segmenter?[...new Intl.Segmenter().segment(n)].map(r=>r.segment):[...n]}function Dr(n,r){const t=Or(r.content);return ft(n,[],t,r.type)}function ft(n,r,t,e){if(t.length===0)return[{content:r.join(""),type:e},{content:"",type:e}];const[i,...l]=t,u=[...r,i];return n([{content:u.join(""),type:e}])?ft(n,u,l,e):(r.length===0&&i&&(r.push(i),t.shift()),[{content:r.join(""),type:e},{content:t.join(""),type:e}])}function Pr(n,r){if(n.some(({content:t})=>t.includes(` `)))throw new Error("splitLineToFitWidth does not support newlines in the line");return Bn(n,r)}function Bn(n,r,t=[],e=[]){if(n.length===0)return e.length>0&&t.push(e),t.length>0?t:[];let i="";n[0].content===" "&&(i=" ",n.shift());const l=n.shift()??{content:" ",type:"normal"},u=[...e];if(i!==""&&u.push({content:i,type:"normal"}),u.push(l),r(u))return Bn(n,r,t,u);if(e.length>0)t.push(e),n.unshift(l);else if(l.content){const[a,c]=Dr(r,l);t.push([a]),c.content&&n.unshift(c)}return Bn(n,r,t)}function _r(n,r){r&&n.attr("style",r)}function Mr(n,r,t,e,i=!1){const l=n.append("foreignObject"),u=l.append("xhtml:div"),a=r.label,c=r.isNode?"nodeLabel":"edgeLabel";u.html(` "+a+""),_r(u,r.labelStyle),u.style("display","table-cell"),u.style("white-space","nowrap"),u.style("max-width",t+"px"),u.attr("xmlns","http://www.w3.org/1999/xhtml"),i&&u.attr("class","labelBkg");let p=u.node().getBoundingClientRect();return p.width===t&&(u.style("display","table"),u.style("white-space","break-spaces"),u.style("width",t+"px"),p=u.node().getBoundingClientRect()),l.style("width",p.width),l.style("height",p.height),l.node()}function xt(n,r,t){return n.append("tspan").attr("class","text-outer-tspan").attr("x",0).attr("y",r*t-.1+"em").attr("dy",t+"em")}function jr(n,r,t){const e=n.append("text"),i=xt(e,1,r);gt(i,t);const l=i.node().getComputedTextLength();return e.remove(),l}function Rr(n,r,t,e=!1){const l=r.append("g"),u=l.insert("rect").attr("class","background"),a=l.append("text").attr("y","-10.1");let c=0;for(const p of t){const h=g=>jr(l,1.1,g)<=n,x=h(p)?[p]:Pr(p,h);for(const g of x){const f=xt(a,c,1.1);gt(f,g),c++}}if(e){const p=a.node().getBBox(),h=2;return u.attr("x",-h).attr("y",-h).attr("width",p.width+2*h).attr("height",p.height+2*h),l.node()}else return a.node()}function gt(n,r){n.text(""),r.forEach((t,e)=>{const i=n.append("tspan").attr("font-style",t.type==="emphasis"?"italic":"normal").attr("class","text-inner-tspan").attr("font-weight",t.type==="strong"?"bold":"normal");e===0?i.text(t.content):i.text(" "+t.content)})}const Nr=(n,r="",{style:t="",isTitle:e=!1,classes:i="",useHtmlLabels:l=!0,isNode:u=!0,width:a=200,addSvgBackground:c=!1}={})=>{if(At.info("createText",r,t,e,i,l,u,c),l){const p=Lr(r),h={isNode:u,label:zt(p).replace(/fa[blrs]?:fa-[\w-]+/g,g=>``),labelStyle:t.replace("fill:","color:")};return Mr(n,h,a,i,c)}else{const p=Br(r);return Rr(a,n,p,c)}};export{Nr as c}; //# sourceMappingURL=createText-285e50b4-59d2d7f5.js.map