@zombie-mermaid/mermaid-parser 3.2.0 → 4.0.0
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -1
- package/dist/index.d.ts +16 -1
- package/dist/index.js +6 -8
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/xychart-colors.test.ts +34 -0
- package/src/class/parser.ts +8 -13
- package/src/class/types.ts +13 -0
- package/src/sequence/types.ts +2 -0
- package/src/xychart/colors.ts +10 -4
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@zombie-mermaid/core");var t=String.raw`[\w-]+`,n=new RegExp(String.raw`^(group|service)\s+(${t})\s*(?:\(([^)]*)\))?\s*(?:\[([^\]]*)\])?(?:\s+in\s+(${t}))?$`),r=new RegExp(String.raw`^junction\s+(${t})(?:\s+in\s+(${t}))?$`),i=new RegExp(String.raw`^(${t})(\{group\})?:([LRTB])\s+(<)?--(>)?\s+([LRTB]):(${t})(\{group\})?$`),a=new RegExp(String.raw`^align\s+(?:row|column)\s+${t}(?:\s+${t})+$`);function o(e,t){throw Error(`Architecture diagram, line ${e.line}: ${t} — "${e.text}"`)}function s(e){return e?.trim().replace(/^"(.*)"$/,`$1`)||void 0}function c(t){let c={groups:[],services:[],junctions:[],edges:[]},l=new Map,u=[],d=[],f=(e,t,n,r)=>{l.has(t)&&o(e,`duplicate id "${t}"`),r===t&&o(e,`"${t}" cannot be inside itself`),l.set(t,n),r&&u.push({stmt:e,parent:r})};for(let l=1;l<t.length;l++){let u=t[l],p=u.text,m=p.match(n);if(m){let t=m[1],n=m[2],r=m[4],i=m[5];f(u,n,t,i);let a={id:n,icon:s(m[3]),title:r===void 0?n:(0,e.normalizeBrTags)(r.trim()),parent:i};t===`group`?c.groups.push(a):c.services.push(a);continue}let h=p.match(r);if(h){let e=h[1],t=h[2];f(u,e,`junction`,t),c.junctions.push({id:e,parent:t});continue}let g=p.match(i);if(g){d.push({stmt:u,edge:{source:g[1],sourceGroup:g[2]!==void 0,sourcePort:g[3],arrowStart:g[4]!==void 0,arrowEnd:g[5]!==void 0,targetPort:g[6],target:g[7],targetGroup:g[8]!==void 0}});continue}a.test(p)||o(u,`unrecognized statement`)}for(let{stmt:e,parent:t}of u)l.get(t)!==`group`&&o(e,`"in ${t}" must name a declared group`);let p=new Map;for(let e of c.groups)e.parent&&p.set(e.id,e.parent);for(let e of c.groups){let t=new Set([e.id]);for(let n=p.get(e.id);n;n=p.get(n)){if(t.has(n))throw Error(`Architecture diagram: group "${e.id}" is nested inside itself`);t.add(n)}}for(let{stmt:e,edge:t}of d){let n=[[t.source,t.sourceGroup],[t.target,t.targetGroup]];for(let[t,r]of n){let n=l.get(t);n||o(e,`unknown id "${t}"`),n===`group`&&o(e,`edges connect services or junctions, not the group "${t}"`);let i=[...c.services,...c.junctions].find(e=>e.id===t)?.parent;r&&!i&&o(e,`"{group}" needs "${t}" to be declared inside a group`)}c.edges.push(t)}return c}var l={database:`cylinder`,disk:`cylinder`,cloud:`stadium`,internet:`circle`},u=new Set([`L`,`R`]);function d(e){let t=0,n=0;for(let r of e)for(let e of[r.sourcePort,r.targetPort])u.has(e)?t++:n++;return n>t?`TB`:`LR`}function f(e,t){let[n,r]=t===`LR`||t===`RL`?[`L`,`R`]:[`T`,`B`];return e.sourcePort===r||e.targetPort===n?!1:e.sourcePort===n||e.targetPort===r}function p(e){let t=new Map,n=new Map;for(let r of e.services)t.set(r.id,{id:r.id,label:r.title,shape:r.icon&&l[r.icon]||`rectangle`}),n.set(r.id,r.parent);for(let r of e.junctions)t.set(r.id,{id:r.id,label:``,shape:`filled-circle`}),n.set(r.id,r.parent);let r=new Map;for(let t of e.groups)r.set(t.id,{id:t.id,label:t.title,nodeIds:[],children:[]});let i=[];for(let t of e.groups){let e=r.get(t.id),n=t.parent?r.get(t.parent):void 0;n?n.children.push(e):i.push(e)}for(let[e,t]of n)r.get(t??``)?.nodeIds.push(e);let a=d(e.edges);return{direction:a,nodes:t,edges:e.edges.map(e=>{let t=(e,t)=>(t?n.get(e):void 0)??e,r=!f(e,a),[i,o]=r?[t(e.source,e.sourceGroup),t(e.target,e.targetGroup)]:[t(e.target,e.targetGroup),t(e.source,e.sourceGroup)];return{source:i,target:o,style:`solid`,hasArrowStart:r?e.arrowStart:e.arrowEnd,hasArrowEnd:r?e.arrowEnd:e.arrowStart}}),subgraphs:i,classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map,interactions:new Map}}var m={c4context:`context`,c4container:`container`,c4component:`component`,c4dynamic:`dynamic`,c4deployment:`deployment`},h=/^(?:UpdateElementStyle|UpdateRelStyle|UpdateLayoutConfig|LAYOUT_[A-Z_]+|SHOW_LEGEND|SHOW_FLOATING_LEGEND|AddElementTag|AddRelTag|AddBoundaryTag|RoleTag)\b/,g=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/,_=/^(?:Boundary|Enterprise_Boundary|System_Boundary|Container_Boundary)$/,v=/^(?:Deployment_Node|Node|Node_L|Node_R)$/,y=/^(Rel|BiRel|Rel_U|Rel_Up|Rel_D|Rel_Down|Rel_L|Rel_Left|Rel_R|Rel_Right|Rel_Back|RelIndex)$/,b={Enterprise_Boundary:`ENTERPRISE`,System_Boundary:`SYSTEM`,Container_Boundary:`CONTAINER`},x={Rel_U:`up`,Rel_Up:`up`,Rel_D:`down`,Rel_Down:`down`,Rel_L:`left`,Rel_Left:`left`,Rel_R:`right`,Rel_Right:`right`};function S(t){let n=t.trim(),r=n.length>=2&&n.startsWith(`"`)&&n.endsWith(`"`)?n.slice(1,-1):n;return(0,e.normalizeBrTags)(r)}function C(e){let t=[],n=``,r=!1;for(let i of e)i===`"`&&(r=!r),i===`,`&&!r?(t.push(n),n=``):n+=i;return r?null:(t.push(n),t.map(e=>e.trim()).filter(e=>!e.startsWith(`$`)).map(S))}var ee=/^([A-Za-z_][A-Za-z0-9_]*)\s*\((.*)\)\s*(\{)?\s*$/;function w(e,t){throw Error(`C4 diagram, line ${e.line}: ${t} — "${e.text}"`)}function te(t){let n=m[t[0]?.text.trim().toLowerCase()??``];if(!n)throw Error(`C4 diagram: expected a header of C4Context, C4Container, C4Component, C4Dynamic or C4Deployment, got "${t[0]?.text??``}"`);let r={variant:n,elements:[],boundaries:[],relationships:[]},i=new Set,a=[],o,s=(e,t)=>(t||w(e,`missing alias (first argument)`),i.has(t)&&w(e,`duplicate alias "${t}"`),i.add(t),t);for(let n=1;n<t.length;n++){let i=t[n],c=i.text;if(c===`}`){a.length===0&&w(i,`unmatched "}"`),a.pop();continue}if(c===`{`){o||w(i,`unexpected "{"`),a.push(o),o=void 0;continue}o=void 0;let l=c.match(/^title(?:\s+(.*))?$/i);if(l){r.title=(0,e.normalizeBrTags)((l[1]??``).trim());continue}if(h.test(c))continue;let u=c.match(ee);u||w(i,`unrecognized statement`);let d=u[1],f=u[3]===`{`,p=C(u[2]);p||w(i,`unbalanced quotes`);let m=d.match(g);if(m){f&&w(i,`"${d}" cannot contain a block`);let e=m[1].toLowerCase(),t=m[2]===`Db`?`db`:m[2]===`Queue`?`queue`:`default`,n=e===`container`||e===`component`,o=s(i,p[0]),c={alias:o,kind:e,shape:t,external:m[3]!==void 0,label:p[1]||o},l=n?p[2]:void 0,u=n?p[3]:p[2];l&&(c.technology=l),u&&(c.description=u),r.elements.push(c),a.at(-1)?.elementAliases.push(o);continue}if(_.test(d)||v.test(d)){let e=v.test(d),t=s(i,p[0]),n={alias:t,label:p[1]||t,elementAliases:[],children:[]};n.type=b[d]||(p[2]&&(e||d===`Boundary`)?p[2]:e?`node`:`system`),e&&p[3]&&(n.description=p[3]);let c=a.at(-1);c?c.children.push(n):r.boundaries.push(n),f?a.push(n):o=n;continue}if(d.match(y)){let e=d===`RelIndex`?p.slice(1):p;(!e[0]||!e[1])&&w(i,`a relationship needs "from" and "to" aliases`);let t={from:e[0],to:e[1],label:e[2]??``,bidirectional:d===`BiRel`};e[3]&&(t.technology=e[3]),d===`Rel_Back`&&(t.reversed=!0);let n=x[d];n&&(t.layout=n),r.relationships.push(t);continue}w(i,`unknown C4 macro "${d}"`)}if(a.length>0)throw Error(`C4 diagram: boundary "${a.at(-1).alias}" is missing its closing "}"`);r.variant===`dynamic`&&r.relationships.forEach((e,t)=>{e.index=String(t+1)});for(let e of r.relationships)for(let t of[e.from,e.to])if(!i.has(t))throw Error(`C4 diagram: relationship refers to undeclared alias "${t}"`);return r}function ne(e,t){let n=[];for(let r of e.split(`
|
|
2
|
-
`)){let e=``;for(let i of r.split(/\s+/).filter(Boolean))e&&e.length+1+i.length>t?(n.push(e),e=i):e=e?`${e} ${i}`:i;n.push(e)}return n}var re={person:`Person`,system:`Software System`,container:`Container`,component:`Component`};function ie(e){let t=(e.kind===`container`||e.kind===`component`)&&e.technology?`: ${e.technology}`:``;return`[${re[e.kind]}${t}]`}function ae(e){return e.type?`[${e.type}]`:void 0}function oe(e){let t=[],n=[e.index?`${e.index}:`:``,e.label].filter(Boolean).join(` `);return n&&t.push(n),e.technology&&t.push(`[${e.technology}]`),t}function T(e){switch(e.layout){case`up`:return{source:e.to,target:e.from,axis:`vertical`,explicit:!0};case`left`:return{source:e.to,target:e.from,axis:`horizontal`,explicit:!0};case`right`:return{source:e.from,target:e.to,axis:`horizontal`,explicit:!0};case`down`:return{source:e.from,target:e.to,axis:`vertical`,explicit:!0};default:return{source:e.from,target:e.to,axis:`vertical`,explicit:!1}}}var E=`<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--`,se=new RegExp(E);function ce(t){let n={classes:[],relationships:[],namespaces:[],interactions:new Map,classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,notes:[]},r=new Map,i=null,a=null,o=0,s;for(let l=1;l<t.length;l++){let u=t[l],d=u.text;if(a&&o>0){if(d===`}`){o--,o===0&&(a=null,s=void 0);continue}let e=d.match(/^<<(\w+)>>$/);if(e){a.annotation=e[1];continue}if(d.startsWith(`<<`))throw Error(`Line ${u.line}: Malformed class annotation "${d}" — expected "<<name>>" (e.g. "<<interface>>").`);D(a,d,u.line);continue}if(/^click\s+/i.test(d)){(0,e.applyClickStatement)(d,n.interactions);continue}let f=d.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);if(f){let t=f[1];n.notes.push({text:(0,e.normalizeBrTags)(f[2]),...t?{forClass:t}:{}});continue}if((0,e.tryApplyClassDef)(d,n)||(0,e.tryApplyStyleStatement)(d,n)||(0,e.tryApplyCssClass)(d,n)||(0,e.tryApplyClassAssignment)(d,n))continue;let p=d.match(/^namespace\s+(\S+)\s*\{$/);if(p){i={name:p[1],classIds:[]};continue}if(d===`}`&&i){n.namespaces.push(i),i=null;continue}let m=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(m){let e=c(m[1],m[2]);a=r.get(e)??null,o=1,s=u.line;continue}let h=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(h){c(h[1],h[2]);continue}let g=d.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);if(g){let e=c(g[1],void 0),t=r.get(e),n=g[2],i=n.match(/^<<(\w+)>>$/);if(t&&i)t.annotation=i[1];else if(t&&n.startsWith(`<<`))throw Error(`Line ${u.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);else t&&n&&D(t,n,u.line);continue}let _=d.match(/^(\S+?)\s*:\s*(.+)$/);if(_){let e=_[2];if(!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){D(O(r,_[1]),e,u.line);continue}}let v=de(d);if(v){v.from=c(v.from,void 0,!1),v.to=c(v.to,void 0,!1),n.relationships.push(v);continue}if(se.test(d))throw Error(`Line ${u.line}: Malformed class-diagram relationship "${d}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`)}if(a!==null)throw Error(`Line ${s}: Unclosed class body for "${a.id}" — expected a closing "}" before the diagram ends.`);return n.classes=[...r.values()],n;function c(t,a,o=!0){let{id:s,className:c}=(0,e.splitClassShorthand)(t),l=s,u=a;if(!u){let e=s.match(/^(.+?)~(\w+)~$/);e&&(l=e[1],u=e[2])}let d=O(r,l);return u&&(d.label=`${l}<${u}>`),c&&n.classAssignments.set(l,c),o&&i&&i.classIds.push(l),l}}function D(e,t,n){let r=ue(t,n);r&&(r.isMethod?e.methods.push(r.member):e.attributes.push(r.member))}function O(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function k(e,t){return Math.max(0,e.split(t).length-1)}function le(e){let t=k(e,`~`);if(t<=1)return e;let n=e,r=!1;t%2!=0&&n.startsWith(`~`)&&(n=n.slice(1),r=!0);let i=[...n],a=i.indexOf(`~`),o=i.lastIndexOf(`~`);for(;a!==-1&&o!==-1&&a!==o;)i[a]=`<`,i[o]=`>`,a=i.indexOf(`~`),o=i.lastIndexOf(`~`);return r&&i.unshift(`~`),i.join(``)}function A(e){let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===`,`&&e>0&&e+1<t.length){let i=t[e-1],a=t[e+1];k(i,`~`)===1&&k(a,`~`)===1&&(r=`${i},${a}`,e++,n.pop())}n.push(le(r))}return n.join(``)}function ue(e,t){let n=e.trim().replace(/;$/,``);if(!n)return null;let r=``,i=n,a=i[0];if((a===`+`||a===`-`||a===`#`||a===`~`)&&(r=a,i=i.slice(1).trim()),i.includes(`(`)&&!i.includes(`)`))throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);let o=i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){let e=A(o[1].trim()),t=o[2]?.trim(),n=t?A(t):void 0,a=o[3]?.trim(),s=a?A(a):void 0,c=e.endsWith(`$`)||i.includes(`$`),l=e.endsWith(`*`)||i.includes(`*`);return{member:{visibility:r,name:e.replace(/[$*]$/,``),type:s||void 0,isStatic:c,isAbstract:l,isMethod:!0,params:n},isMethod:!0}}let s=A(i).split(/\s+/),c,l;s.length>=2?(l=s[0],c=s.slice(1).join(` `)):c=s[0]??i;let u=c.endsWith(`$`),d=c.endsWith(`*`);return{member:{visibility:r,name:c.replace(/[$*]$/,``),type:l||void 0,isStatic:u,isAbstract:d,isMethod:!1},isMethod:!1}}function de(t){let n=t.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${E})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));if(!n)return null;let r=n[1],i=n[2],a=i?(0,e.normalizeBrTags)(i):void 0,o=n[3].trim(),s=n[4],c=s?(0,e.normalizeBrTags)(s):void 0,l=n[6]?`${n[5]}:::${n[6]}`:n[5],u=n[7]?.trim(),d=u?(0,e.normalizeBrTags)(u):void 0,f=fe(o);return f?{from:r,to:l,type:f.type,markerAt:f.markerAt,label:d,fromCardinality:a,toCardinality:c}:null}function fe(e){switch(e.trim()){case`<|--`:return{type:`inheritance`,markerAt:`from`};case`--|>`:return{type:`inheritance`,markerAt:`to`};case`<|..`:return{type:`realization`,markerAt:`from`};case`..|>`:return{type:`realization`,markerAt:`to`};case`*--`:return{type:`composition`,markerAt:`from`};case`--*`:return{type:`composition`,markerAt:`to`};case`o--`:return{type:`aggregation`,markerAt:`from`};case`--o`:return{type:`aggregation`,markerAt:`to`};case`-->`:return{type:`association`,markerAt:`to`};case`<--`:return{type:`association`,markerAt:`from`};case`..>`:return{type:`dependency`,markerAt:`to`};case`<..`:return{type:`dependency`,markerAt:`from`};case`--`:return{type:`association`,markerAt:`to`};default:return null}}function pe(e){return`${e.visibility?`${e.visibility} `:``}${e.isMethod?`${e.name}(${e.params||``})`:e.name}${e.type?`: ${e.type}`:``}`}function me(t){let n={entities:[],relationships:[]},r=new Map,i=null;for(let a=1;a<t.length;a++){let o=t[a],s=o.text;if(i){if(s===`}`){i=null;continue}let e=M(s);e&&i.attributes.push(e);continue}let c=s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.direction=(0,e.toDirection)(c[1]);continue}let l=s.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);if(l){let t=l[1],n=l[2],a=j(r,t,n===void 0?void 0:(0,e.normalizeBrTags)(n.trim().replace(/^["']|["']$/g,``))),o=l[3].trim(),s=o.endsWith(`}`),c=s?o.slice(0,-1).trim():o;for(let e of c.split(`;`).map(e=>e.trim()).filter(Boolean)){let t=M(e);t&&a.attributes.push(t)}s||(i=a);continue}let u=he(s,o.line);if(u){j(r,u.entity1),j(r,u.entity2),n.relationships.push(u);continue}}return n.entities=[...r.values()],n}function j(e,t,n){let r=e.get(t);return r?n!==void 0&&(r.label=n):(r={id:t,label:n??t,attributes:[]},e.set(t,r)),r}function M(t){let n=t.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!n)return null;let r=n[1],i=n[2],a=n[3]?.trim()??``,o=[],s,c=a.match(/"([^"]*)"/);c&&(s=(0,e.normalizeBrTags)(c[1]));let l=a.replace(/"[^"]*"/,``).trim();for(let e of l.split(/\s+/)){let t=e.toUpperCase();(t===`PK`||t===`FK`||t===`UK`)&&o.push(t)}return{type:r,name:i,keys:o,comment:s}}function he(t,n){let r=t.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);if(!r)return null;let i=r[1],a=r[2],o=r[3],s=r[4]!==void 0,c=r[4]?.trim()??``,l=a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/),u=l?ge(l[1]):null,d=l?_e(l[3]):null;if(!u||!d)throw Error(`Line ${n}: Invalid ER relationship cardinality "${a}" in "${t}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);if(!s||c.length===0)throw Error(`Line ${n}: ER relationship "${i} ${a} ${o}" is missing a ": label" — expected e.g. "${i} ${a} ${o} : label".`);return{entity1:i,entity2:o,cardinality1:u,cardinality2:d,label:(0,e.normalizeBrTags)(c.replace(/^["']|["']$/g,``)),identifying:l[2]===`--`}}function ge(e){return e===`||`?`one`:e===`|o`?`zero-one`:e===`}|`?`many`:e===`}o`?`zero-many`:null}function _e(e){return e===`||`?`one`:e===`o|`?`zero-one`:e===`|{`?`many`:e===`o{`?`zero-many`:null}var N=new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen`.split(` `)),P=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,F=/^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;function I(e){return N.has(e.toLowerCase())||P.test(e)||F.test(e)}function L(e){let t=e.trim(),n=t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/),r=n?.[1]??``,i=n?.[2]?.trim()??``;return r.toLowerCase()===`transparent`?{label:i}:r!==``&&I(r)?{color:r,label:i}:{label:t}}function R(e){return e===`loop`||e===`alt`||e===`opt`||e===`par`||e===`critical`||e===`break`||e===`rect`}function z(e){if(!R(e))throw Error(`Invalid block type: "${e}"`);return e}var ve=/^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/,ye=/^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;function B(t){let n={actors:[],messages:[],blocks:[],notes:[],activations:[],boxes:[]},r={open:void 0,membership:new Map},i=0,a,o=new Set,s=[],c={enabled:!1,next:1,step:1},l,u;for(let d=1;d<t.length;d++){let f=t[d],p=f.text,m=p.match(/^box(?:\s+(.*))?$/);if(m){if(r.open!==void 0)throw Error(`Line ${f.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);let{color:t,label:o}=L(m[1]??``),c={label:(0,e.normalizeBrTags)(o),actorIds:[]};t!==void 0&&(c.color=t),n.boxes.push(c),r.open=n.boxes.length-1,i=s.length,a=f.line;continue}let h=p.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(h){let t=h[1]===`actor`?`actor`:`participant`,i=h[2];if(o.has(i))throw Error(`Line ${f.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);o.add(i),n.actors.push({id:i,label:(0,e.normalizeBrTags)(h[3]?.trim()??i),type:t}),U(n,r,i,f.line),l=i;continue}let g=p.match(/^destroy\s+(.+)$/);if(g){let e=g[1].trim();H(n,o,r,e,f.line),u=e;continue}let _=p.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);if(_){let e=_[1],t=_[2];e===`off`?c.enabled=!1:(c.enabled=!0,c.next=e===void 0?1:Number(e),c.step=t===void 0?1:Number(t));continue}let v=p.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(v){let t=v[1]===`actor`?`actor`:`participant`,i=v[2],a=v[3]?.trim()??i,s=(0,e.normalizeBrTags)(a);o.has(i)||(o.add(i),n.actors.push({id:i,label:s,type:t})),U(n,r,i,f.line);continue}let y=p.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(y){let t=y[1].toLowerCase(),i=y[2].trim(),a=(0,e.normalizeBrTags)(y[3].trim()),s=i.split(`,`).map(e=>e.trim());for(let e of s)H(n,o,r,e,f.line);let c=`over`;t===`left of`?c=`left`:t===`right of`&&(c=`right`),n.notes.push({actorIds:s,text:a,position:c,afterIndex:n.messages.length-1});continue}let b=p.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(b){let t=z(b[1]),r=b[2]?.trim()??``,i=(0,e.normalizeBrTags)(r);s.push({type:t,label:i,startIndex:n.messages.length,dividers:[],line:f.line});continue}let x=p.match(/^(else|and)\s*(.*)$/);if(x&&s.length>0){let t=x[2]?.trim()??``,r=(0,e.normalizeBrTags)(t);s[s.length-1].dividers.push({index:n.messages.length,label:r});continue}if(p===`end`&&r.open!==void 0&&s.length===i){r.open=void 0,a=void 0;continue}if(p===`end`&&s.length>0){let e=s.pop();n.blocks.push({type:e.type,label:e.label,startIndex:e.startIndex,endIndex:Math.max(n.messages.length-1,e.startIndex),dividers:e.dividers});continue}if(p===`end`)throw Error(`Line ${f.line}: Sequence diagram: "end" does not match any open block ("loop"/"alt"/"opt"/"par"/"critical"/"break"/"rect") or "box" — nothing is currently open to close.`);let S=p.match(/^(activate|deactivate)\s+(.+)$/);if(S){let e=S[2].trim();H(n,o,r,e,f.line),n.activations.push({actorId:e,kind:S[1]===`activate`?`start`:`end`,afterIndex:n.messages.length-1});continue}let C=p.match(ve)??p.match(ye);if(C){let e=C[2],t=C[4][0];if(t===`>`||t===`)`)throw Error(`Line ${f.line}: Malformed sequence-diagram arrow in "${p}" — "${e}${t}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);be(n,o,r,c,C[1],C[2],C[3],C[4],C[5],f.line);let i=n.messages.length-1,a=n.messages[i];if(l!==void 0){if(a.to!==l)throw Error(`Line ${f.line}: The created participant ${l} does not have an associated creating message after its declaration. Please check the sequence diagram.`);V(n,l).createdAt=i,l=void 0}if(u!==void 0){if(a.from!==u&&a.to!==u)throw Error(`Line ${f.line}: The destroyed participant ${u} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);V(n,u).destroyedAt=i,u=void 0}continue}}if(s.length>0){let e=s[s.length-1];throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`)}if(r.open!==void 0){let e=n.boxes[r.open];throw Error(`Line ${a}: Sequence diagram: unclosed "box${e.label?` ${e.label}`:``}" — expected a matching "end" before the diagram ends.`)}return n}function V(e,t){let n=e.actors.find(e=>e.id===t);if(n===void 0)throw Error(`Sequence diagram: unknown actor "${t}"`);return n}function H(e,t,n,r,i){t.has(r)||(t.add(r),e.actors.push({id:r,label:r,type:`participant`})),U(e,n,r,i)}function U(e,t,n,r){let i=t.open;if(i===void 0)return;let a=t.membership.get(n);if(a!==i){if(a!==void 0){let t=e.boxes[a].label,o=e.boxes[i].label;throw Error(`Line ${r}: A same participant should only be defined in one Box: ${n} can't be in '${t}' and in '${o}' at the same time.`)}t.membership.set(n,i),e.boxes[i].actorIds.push(n)}}function be(t,n,r,i,a,o,s,c,l,u){H(t,n,r,a,u),H(t,n,r,c,u);let d=o===`<<->>`||o===`<<-->>`,f=d?o===`<<-->>`?`dashed`:`solid`:o.startsWith(`--`)?`dashed`:`solid`,p=o.includes(`>>`)||o.includes(`x`)?`filled`:`open`,m=o.includes(`x`),h={from:a,to:c,label:(0,e.normalizeBrTags)(l.trim()),lineStyle:f,arrowHead:p};m&&(h.isLost=!0),d&&(h.bidirectional=!0),s===`+`&&(h.activate=!0),s===`-`&&(h.deactivate=!0),i.enabled&&(h.seqNumber=i.next,i.next=Math.round((i.next+i.step)*100)/100),t.messages.push(h)}function W(e,t){if(t<0)return`before the first message`;let n=e.messages[t];if(!n)return`at an unresolved position`;let r=n.label?`: ${n.label}`:``;return`after message ${t+1} ("${n.from} -> ${n.to}${r}")`}function G(e){let t=new Map;for(let n of e.activations){let e=t.get(n.afterIndex)??[];e.push(n),t.set(n.afterIndex,e)}let n=[];function r(e){for(let r of t.get(e)??[])n.push({actorId:r.actorId,kind:r.kind,afterIndex:e})}r(-1);for(let t=0;t<e.messages.length;t++){let i=e.messages[t];i.activate&&n.push({actorId:i.to,kind:`start`,afterIndex:t}),i.deactivate&&n.push({actorId:i.from,kind:`end`,afterIndex:t}),r(t)}let i=new Map,a=[];for(let t of n){let n=i.get(t.actorId)??[];if(i.set(t.actorId,n),t.kind===`start`){n.push(t.afterIndex);continue}n.pop()===void 0&&a.push({code:`UNMATCHED_DEACTIVATION`,actorId:t.actorId,message:`"deactivate ${t.actorId}" ${W(e,t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`})}for(let[t,n]of i)for(let r of n)a.push({code:`DANGLING_ACTIVATION`,actorId:t,message:`"activate ${t}" opened ${W(e,r)} is never closed with a matching "deactivate ${t}".`});return{ok:a.length===0,issues:a}}function xe(t){let n=(0,e.detectDiagramType)(t);if(n!==`sequence`)throw Error(`fixActivationBalance only supports sequence diagrams (source must start with "sequenceDiagram"); detected diagram type: "${n}".`);let r=G(B((0,e.splitStatements)(t)));if(r.ok)return{ok:!0,originalDiagram:t,fixedDiagram:t,fixesApplied:[],remainingIssues:[]};let i=r.issues.filter(e=>e.code===`DANGLING_ACTIVATION`),a=r.issues.filter(e=>e.code!==`DANGLING_ACTIVATION`),o=i.map(e=>` deactivate ${e.actorId}`).join(`
|
|
3
|
-
`),s=i.length===0?t:`${t.replace(/\s+$/,``)}\n${o}`,c=i.map(e=>`Appended "deactivate ${e.actorId}" to close: ${e.message}`);return{ok:a.length===0,originalDiagram:t,fixedDiagram:s,fixesApplied:c,remainingIssues:a}}function Se(e){let t={},n={},r=[],i,a=!1;for(let o of e){let e=o.text;if(/^xychart(-beta)?\b/i.test(e)){/\bhorizontal\b/i.test(e)&&(a=!0);continue}let s=e.match(/^title\s+"([^"]+)"/);if(s){i=s[1];continue}let c=e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(t.title=c[1]),t.categories=Ce(c[2]).map(e=>we(e.trim()));continue}let l=e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(t.title=l[1]),t.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}let u=e.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(u){u[1]&&(n.title=u[1]),n.range={min:parseFloat(u[2]),max:parseFloat(u[3])};continue}let d=e.match(/^y-axis\s+"([^"]+)"\s*$/);if(d){n.title=d[1];continue}let f=e.match(/^bar\s+\[([^\]]+)\]/);if(f){r.push({type:`bar`,data:K(f[1],`bar`,e,o.line)});continue}let p=e.match(/^line\s+\[([^\]]+)\]/);if(p){r.push({type:`line`,data:K(p[1],`line`,e,o.line)});continue}let m=e.match(/^(x-axis|y-axis|bar|line|title)\b/i);if(m)throw Ee(m[1].toLowerCase(),e,o.line)}if(!n.range&&r.length>0){let e=r.flatMap(e=>e.data),t=Math.min(...e),i=Math.max(...e),a=i-t||1;t-=a*.1,i+=a*.1,t>0&&t<a*.5&&(t=0),n.range={min:t,max:i}}return n.range||={min:0,max:100},{title:i,horizontal:a,xAxis:t,yAxis:n,series:r}}function Ce(e){let t=[],n=``,r=!1;for(let i of e)i===`"`?(r=!r,n+=i):i===`,`&&!r?(t.push(n),n=``):n+=i;return t.push(n),t}function we(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function K(e,t,n,r){return e.split(`,`).map((e,i)=>{let a=e.trim(),o=parseFloat(a);if(a.length===0||Number.isNaN(o))throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i+1} in "${n}". Every value in a ${t} [...] list must be a number.`);return o})}var Te={"x-axis":`x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title`,"y-axis":`y-axis 0 --> 100 (numeric range) or y-axis "Title" (title only), optionally preceded by a quoted title before a range`,bar:`bar [10, 20, 30] — a comma-separated numeric array in square brackets`,line:`line [10, 20, 30] — a comma-separated numeric array in square brackets`,title:`title "Chart Title" — a double-quoted string`};function Ee(e,t,n){let r=Te[e]??e;return Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`)}var q=`#3b82f6`;function J(e){let t=e.replace(`#`,``),n=parseInt(t.substring(0,2),16)/255,r=parseInt(t.substring(2,4),16)/255,i=parseInt(t.substring(4,6),16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)return[0,0,s*100];let c=a-o,l=s>.5?c/(2-a-o):c/(a+o),u;return u=a===n?((r-i)/c+(r<i?6:0))/6:a===r?((i-n)/c+2)/6:((n-r)/c+4)/6,[u*360,l*100,s*100]}function De(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,c,l,u;e<60?(c=a,l=o,u=0):e<120?(c=o,l=a,u=0):e<180?(c=0,l=a,u=o):e<240?(c=0,l=o,u=a):e<300?(c=o,l=0,u=a):(c=a,l=0,u=o);let d=e=>Math.round((e+s)*255).toString(16).padStart(2,`0`);return`#${d(c)}${d(l)}${d(u)}`}function Y(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function X(e){return J(e)[2]<50}function Oe(e,t,n){if(e===0)return t;let r=Y(t)?t:q,i=n&&Y(n)?n:void 0,[a,o]=J(r),s=Math.max(55,Math.min(85,o)),c=Math.ceil(e/2),l=e%2==1,u=i&&X(i)?!l:l,d=u?Math.max(25,48-c*13):Math.min(78,55+c*11);return De(((a+(u?-8
|
|
2
|
+
`)){let e=``;for(let i of r.split(/\s+/).filter(Boolean))e&&e.length+1+i.length>t?(n.push(e),e=i):e=e?`${e} ${i}`:i;n.push(e)}return n}var re={person:`Person`,system:`Software System`,container:`Container`,component:`Component`};function ie(e){let t=(e.kind===`container`||e.kind===`component`)&&e.technology?`: ${e.technology}`:``;return`[${re[e.kind]}${t}]`}function ae(e){return e.type?`[${e.type}]`:void 0}function oe(e){let t=[],n=[e.index?`${e.index}:`:``,e.label].filter(Boolean).join(` `);return n&&t.push(n),e.technology&&t.push(`[${e.technology}]`),t}function T(e){switch(e.layout){case`up`:return{source:e.to,target:e.from,axis:`vertical`,explicit:!0};case`left`:return{source:e.to,target:e.from,axis:`horizontal`,explicit:!0};case`right`:return{source:e.from,target:e.to,axis:`horizontal`,explicit:!0};case`down`:return{source:e.from,target:e.to,axis:`vertical`,explicit:!0};default:return{source:e.from,target:e.to,axis:`vertical`,explicit:!1}}}var E=`<\\|--|<\\|\\.\\.|\\*--|o--|-->|--\\*|--o|--\\|>|\\.\\.>|\\.\\.\\|>|<--|<\\.\\.?|--`,se=new RegExp(E);function ce(t){let n={classes:[],relationships:[],namespaces:[],interactions:new Map,classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,notes:[]},r=new Map,i=null,a=null,o=0,s;for(let l=1;l<t.length;l++){let u=t[l],d=u.text;if(a&&o>0){if(d===`}`){o--,o===0&&(a=null,s=void 0);continue}let e=d.match(/^<<(\w+)>>$/);if(e){a.annotation=e[1];continue}if(d.startsWith(`<<`))throw Error(`Line ${u.line}: Malformed class annotation "${d}" — expected "<<name>>" (e.g. "<<interface>>").`);D(a,d,u.line);continue}if(/^click\s+/i.test(d)){(0,e.applyClickStatement)(d,n.interactions);continue}let f=d.match(/^note\s+(?:for\s+(\S+)\s+)?"([^"]*)"\s*$/);if(f){let t=f[1];n.notes.push({text:(0,e.normalizeBrTags)(f[2]),...t?{forClass:t}:{}});continue}if((0,e.tryApplyClassDef)(d,n)||(0,e.tryApplyStyleStatement)(d,n)||(0,e.tryApplyCssClass)(d,n)||(0,e.tryApplyClassAssignment)(d,n))continue;let p=d.match(/^namespace\s+(\S+)\s*\{$/);if(p){i={name:p[1],classIds:[]};continue}if(d===`}`&&i){n.namespaces.push(i),i=null;continue}let m=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*\{$/);if(m){let e=c(m[1],m[2]);a=r.get(e)??null,o=1,s=u.line;continue}let h=d.match(/^class\s+(\S+?)(?:\s*~(\w+)~)?\s*$/);if(h){c(h[1],h[2]);continue}let g=d.match(/^class\s+(\S+?)\s*\{\s*(.*?)\s*\}$/);if(g){let e=c(g[1],void 0),t=r.get(e),n=g[2],i=n.match(/^<<(\w+)>>$/);if(t&&i)t.annotation=i[1];else if(t&&n.startsWith(`<<`))throw Error(`Line ${u.line}: Malformed class annotation "${n}" — expected "<<name>>" (e.g. "<<interface>>").`);else t&&n&&D(t,n,u.line);continue}let _=d.match(/^(\S+?)\s*:\s*(.+)$/);if(_){let e=_[2];if(!e.match(/<\|--|--|\*--|o--|-->|\.\.>|\.\.\|>/)){D(O(r,_[1]),e,u.line);continue}}let v=de(d);if(v){v.from=c(v.from,void 0,!1),v.to=c(v.to,void 0,!1),n.relationships.push(v);continue}if(se.test(d))throw Error(`Line ${u.line}: Malformed class-diagram relationship "${d}". Expected "FROM ARROW TO" (optionally with cardinalities and a ": label"), e.g. "Animal <|-- Dog" or 'A "1" --> "*" B : label'. ARROW must be one of <|--, <|.., *--, o--, -->, --*, --o, --|>, ..>, ..|>, <--, <.., or --.`)}if(a!==null)throw Error(`Line ${s}: Unclosed class body for "${a.id}" — expected a closing "}" before the diagram ends.`);return n.classes=[...r.values()],n;function c(t,a,o=!0){let{id:s,className:c}=(0,e.splitClassShorthand)(t),l=s,u=a;if(!u){let e=s.match(/^(.+?)~(\w+)~$/);e&&(l=e[1],u=e[2])}let d=O(r,l);return u&&(d.label=`${l}<${u}>`),c&&n.classAssignments.set(l,c),o&&i&&i.classIds.push(l),l}}function D(e,t,n){let r=ue(t,n);r&&(r.isMethod?e.methods.push(r.member):e.attributes.push(r.member))}function O(e,t){let n=e.get(t);return n||(n={id:t,label:t,attributes:[],methods:[]},e.set(t,n)),n}function k(e,t){return Math.max(0,e.split(t).length-1)}function le(e){let t=k(e,`~`);if(t<=1)return e;let n=e,r=!1;t%2!=0&&n.startsWith(`~`)&&(n=n.slice(1),r=!0);let i=[...n],a=i.indexOf(`~`),o=i.lastIndexOf(`~`);for(;a!==-1&&o!==-1&&a!==o;)i[a]=`<`,i[o]=`>`,a=i.indexOf(`~`),o=i.lastIndexOf(`~`);return r&&i.unshift(`~`),i.join(``)}function A(e){let t=e.split(/(,)/),n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r===`,`&&e>0&&e+1<t.length){let i=t[e-1],a=t[e+1];k(i,`~`)===1&&k(a,`~`)===1&&(r=`${i},${a}`,e++,n.pop())}n.push(le(r))}return n.join(``)}function ue(e,t){let n=e.trim().replace(/;$/,``);if(!n)return null;let r=``,i=n,a=i[0];if((a===`+`||a===`-`||a===`#`||a===`~`)&&(r=a,i=i.slice(1).trim()),i.includes(`(`)&&!i.includes(`)`))throw Error(`Line ${t}: Malformed class member "${n}" — unclosed "(" in a method signature. Expected e.g. "+eat() void" or "+eat(Food f) void".`);let o=i.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){let e=A(o[1].trim()),t=o[2]?.trim(),n=t?A(t):void 0,a=o[3]?.trim(),s=a?A(a):void 0,c=e.endsWith(`$`)||i.includes(`$`),l=e.endsWith(`*`)||i.includes(`*`);return{member:{visibility:r,name:e.replace(/[$*]$/,``),type:s||void 0,isStatic:c,isAbstract:l,isMethod:!0,params:n},isMethod:!0}}let s=A(i),c=s.endsWith(`$`),l=s.endsWith(`*`);return{member:{visibility:r,name:s.replace(/[$*]$/,``),type:void 0,isStatic:c,isAbstract:l,isMethod:!1},isMethod:!1}}function de(t){let n=t.match(RegExp(`^(\\S+?)\\s+(?:"([^"]*?)"\\s+)?(${E})\\s+(?:"([^"]*?)"\\s+)?(\\S+?)(?::::([\\w][\\w-]*))?(?:\\s*:\\s*(.+))?$`));if(!n)return null;let r=n[1],i=n[2],a=i?(0,e.normalizeBrTags)(i):void 0,o=n[3].trim(),s=n[4],c=s?(0,e.normalizeBrTags)(s):void 0,l=n[6]?`${n[5]}:::${n[6]}`:n[5],u=n[7]?.trim(),d=u?(0,e.normalizeBrTags)(u):void 0,f=fe(o);return f?{from:r,to:l,type:f.type,markerAt:f.markerAt,label:d,fromCardinality:a,toCardinality:c}:null}function fe(e){switch(e.trim()){case`<|--`:return{type:`inheritance`,markerAt:`from`};case`--|>`:return{type:`inheritance`,markerAt:`to`};case`<|..`:return{type:`realization`,markerAt:`from`};case`..|>`:return{type:`realization`,markerAt:`to`};case`*--`:return{type:`composition`,markerAt:`from`};case`--*`:return{type:`composition`,markerAt:`to`};case`o--`:return{type:`aggregation`,markerAt:`from`};case`--o`:return{type:`aggregation`,markerAt:`to`};case`-->`:return{type:`association`,markerAt:`to`};case`<--`:return{type:`association`,markerAt:`from`};case`..>`:return{type:`dependency`,markerAt:`to`};case`<..`:return{type:`dependency`,markerAt:`from`};case`--`:return{type:`association`,markerAt:`to`};default:return null}}function pe(e){return`${e.visibility?`${e.visibility} `:``}${e.isMethod?`${e.name}(${e.params||``})`:e.name}${e.type?`: ${e.type}`:``}`}function me(t){let n={entities:[],relationships:[]},r=new Map,i=null;for(let a=1;a<t.length;a++){let o=t[a],s=o.text;if(i){if(s===`}`){i=null;continue}let e=M(s);e&&i.attributes.push(e);continue}let c=s.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(c){n.direction=(0,e.toDirection)(c[1]);continue}let l=s.match(/^(\S+?)(?:\[(.+)\])?\s*\{(.*)$/);if(l){let t=l[1],n=l[2],a=j(r,t,n===void 0?void 0:(0,e.normalizeBrTags)(n.trim().replace(/^["']|["']$/g,``))),o=l[3].trim(),s=o.endsWith(`}`),c=s?o.slice(0,-1).trim():o;for(let e of c.split(`;`).map(e=>e.trim()).filter(Boolean)){let t=M(e);t&&a.attributes.push(t)}s||(i=a);continue}let u=he(s,o.line);if(u){j(r,u.entity1),j(r,u.entity2),n.relationships.push(u);continue}}return n.entities=[...r.values()],n}function j(e,t,n){let r=e.get(t);return r?n!==void 0&&(r.label=n):(r={id:t,label:n??t,attributes:[]},e.set(t,r)),r}function M(t){let n=t.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!n)return null;let r=n[1],i=n[2],a=n[3]?.trim()??``,o=[],s,c=a.match(/"([^"]*)"/);c&&(s=(0,e.normalizeBrTags)(c[1]));let l=a.replace(/"[^"]*"/,``).trim();for(let e of l.split(/\s+/)){let t=e.toUpperCase();(t===`PK`||t===`FK`||t===`UK`)&&o.push(t)}return{type:r,name:i,keys:o,comment:s}}function he(t,n){let r=t.match(/^(\S+)\s+(\S*(?:--|\.\.)\S*)\s+(\S+)\s*(?::\s*(.*))?$/);if(!r)return null;let i=r[1],a=r[2],o=r[3],s=r[4]!==void 0,c=r[4]?.trim()??``,l=a.match(/^([|o}{]*)(--|\.\.?)([|o}{]*)$/),u=l?ge(l[1]):null,d=l?_e(l[3]):null;if(!u||!d)throw Error(`Line ${n}: Invalid ER relationship cardinality "${a}" in "${t}". Left side must be one of ||, |o, }|, }o; right side must be one of ||, o|, |{, o{ (e.g. "||--o{").`);if(!s||c.length===0)throw Error(`Line ${n}: ER relationship "${i} ${a} ${o}" is missing a ": label" — expected e.g. "${i} ${a} ${o} : label".`);return{entity1:i,entity2:o,cardinality1:u,cardinality2:d,label:(0,e.normalizeBrTags)(c.replace(/^["']|["']$/g,``)),identifying:l[2]===`--`}}function ge(e){return e===`||`?`one`:e===`|o`?`zero-one`:e===`}|`?`many`:e===`}o`?`zero-many`:null}function _e(e){return e===`||`?`one`:e===`o|`?`zero-one`:e===`|{`?`many`:e===`o{`?`zero-many`:null}var N=new Set(`aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple rebeccapurple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen`.split(` `)),P=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,F=/^(?:rgba?|hsla?)\(\s*[\d.%]+(?:[\s,/]+[\d.%]+){2,3}\s*\)$/i;function I(e){return N.has(e.toLowerCase())||P.test(e)||F.test(e)}function L(e){let t=e.trim(),n=t.match(/^((?:rgba?|hsla?)\s*\([^)]*\)|#[0-9a-fA-F]+|\S+)?(.*)$/),r=n?.[1]??``,i=n?.[2]?.trim()??``;return r.toLowerCase()===`transparent`?{label:i}:r!==``&&I(r)?{color:r,label:i}:{label:t}}function R(e){return e===`loop`||e===`alt`||e===`opt`||e===`par`||e===`critical`||e===`break`||e===`rect`}function z(e){if(!R(e))throw Error(`Invalid block type: "${e}"`);return e}var ve=/^(.+?)\s*(<<->>|<<-->>|--?>?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/,ye=/^(.+?)\s*(<<->>|<<-->>|--?>?>|--?[)x]|--?>>|--?>)\s*([+-]?)(.+?)\s*:\s*(.+)$/;function B(t){let n={actors:[],messages:[],blocks:[],notes:[],activations:[],boxes:[]},r={open:void 0,membership:new Map},i=0,a,o=new Set,s=[],c={enabled:!1,next:1,step:1},l,u;for(let d=1;d<t.length;d++){let f=t[d],p=f.text,m=p.match(/^box(?:\s+(.*))?$/);if(m){if(r.open!==void 0)throw Error(`Line ${f.line}: Sequence diagram: a box cannot be nested inside another box — close the open box with "end" first`);let{color:t,label:o}=L(m[1]??``),c={label:(0,e.normalizeBrTags)(o),actorIds:[]};t!==void 0&&(c.color=t),n.boxes.push(c),r.open=n.boxes.length-1,i=s.length,a=f.line;continue}let h=p.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(h){let t=h[1]===`actor`?`actor`:`participant`,i=h[2];if(o.has(i))throw Error(`Line ${f.line}: It is not possible to have actors with the same id, even if one is destroyed before the next is created. Use 'AS' aliases to simulate the behavior`);o.add(i),n.actors.push({id:i,label:(0,e.normalizeBrTags)(h[3]?.trim()??i),type:t}),U(n,r,i,f.line),l=i;continue}let g=p.match(/^destroy\s+(.+)$/);if(g){let e=g[1].trim();H(n,o,r,e,f.line),u=e;continue}let _=p.match(/^autonumber(?:\s+(off|\d+(?:\.\d{1,2})?)(?:\s+(\d+(?:\.\d{1,2})?))?)?$/);if(_){let e=_[1],t=_[2];e===`off`?c.enabled=!1:(c.enabled=!0,c.next=e===void 0?1:Number(e),c.step=t===void 0?1:Number(t));continue}let v=p.match(/^(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/);if(v){let t=v[1]===`actor`?`actor`:`participant`,i=v[2],a=v[3]?.trim()??i,s=(0,e.normalizeBrTags)(a);o.has(i)||(o.add(i),n.actors.push({id:i,label:s,type:t})),U(n,r,i,f.line);continue}let y=p.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.+)$/i);if(y){let t=y[1].toLowerCase(),i=y[2].trim(),a=(0,e.normalizeBrTags)(y[3].trim()),s=i.split(`,`).map(e=>e.trim());for(let e of s)H(n,o,r,e,f.line);let c=`over`;t===`left of`?c=`left`:t===`right of`&&(c=`right`),n.notes.push({actorIds:s,text:a,position:c,afterIndex:n.messages.length-1});continue}let b=p.match(/^(loop|alt|opt|par|critical|break|rect)\s*(.*)$/);if(b){let t=z(b[1]),r=b[2]?.trim()??``,i=(0,e.normalizeBrTags)(r);s.push({type:t,label:i,startIndex:n.messages.length,dividers:[],line:f.line});continue}let x=p.match(/^(else|and)\s*(.*)$/);if(x&&s.length>0){let t=x[2]?.trim()??``,r=(0,e.normalizeBrTags)(t);s[s.length-1].dividers.push({index:n.messages.length,label:r});continue}if(p===`end`&&r.open!==void 0&&s.length===i){r.open=void 0,a=void 0;continue}if(p===`end`&&s.length>0){let e=s.pop();n.blocks.push({type:e.type,label:e.label,startIndex:e.startIndex,endIndex:Math.max(n.messages.length-1,e.startIndex),dividers:e.dividers});continue}if(p===`end`)throw Error(`Line ${f.line}: Sequence diagram: "end" does not match any open block ("loop"/"alt"/"opt"/"par"/"critical"/"break"/"rect") or "box" — nothing is currently open to close.`);let S=p.match(/^(activate|deactivate)\s+(.+)$/);if(S){let e=S[2].trim();H(n,o,r,e,f.line),n.activations.push({actorId:e,kind:S[1]===`activate`?`start`:`end`,afterIndex:n.messages.length-1});continue}let C=p.match(ve)??p.match(ye);if(C){let e=C[2],t=C[4][0];if(t===`>`||t===`)`)throw Error(`Line ${f.line}: Malformed sequence-diagram arrow in "${p}" — "${e}${t}" is not a recognized arrow. Expected one of: ->, -->, ->>, -->>, -x, --x, -), --), <<->>, <<-->>.`);be(n,o,r,c,C[1],C[2],C[3],C[4],C[5],f.line);let i=n.messages.length-1,a=n.messages[i];if(l!==void 0){if(a.to!==l)throw Error(`Line ${f.line}: The created participant ${l} does not have an associated creating message after its declaration. Please check the sequence diagram.`);V(n,l).createdAt=i,l=void 0}if(u!==void 0){if(a.from!==u&&a.to!==u)throw Error(`Line ${f.line}: The destroyed participant ${u} does not have an associated destroying message after its declaration. Please check the sequence diagram.`);V(n,u).destroyedAt=i,u=void 0}continue}}if(s.length>0){let e=s[s.length-1];throw Error(`Line ${e.line}: Sequence diagram: unclosed "${e.type}" block — expected a matching "end" before the diagram ends.`)}if(r.open!==void 0){let e=n.boxes[r.open];throw Error(`Line ${a}: Sequence diagram: unclosed "box${e.label?` ${e.label}`:``}" — expected a matching "end" before the diagram ends.`)}return n}function V(e,t){let n=e.actors.find(e=>e.id===t);if(n===void 0)throw Error(`Sequence diagram: unknown actor "${t}"`);return n}function H(e,t,n,r,i){t.has(r)||(t.add(r),e.actors.push({id:r,label:r,type:`participant`})),U(e,n,r,i)}function U(e,t,n,r){let i=t.open;if(i===void 0)return;let a=t.membership.get(n);if(a!==i){if(a!==void 0){let t=e.boxes[a].label,o=e.boxes[i].label;throw Error(`Line ${r}: A same participant should only be defined in one Box: ${n} can't be in '${t}' and in '${o}' at the same time.`)}t.membership.set(n,i),e.boxes[i].actorIds.push(n)}}function be(t,n,r,i,a,o,s,c,l,u){H(t,n,r,a,u),H(t,n,r,c,u);let d=o===`<<->>`||o===`<<-->>`,f=d?o===`<<-->>`?`dashed`:`solid`:o.startsWith(`--`)?`dashed`:`solid`,p=o.includes(`>>`)||o.includes(`x`)?`filled`:`open`,m=o.includes(`x`),h={from:a,to:c,label:(0,e.normalizeBrTags)(l.trim()),lineStyle:f,arrowHead:p};m&&(h.isLost=!0),d&&(h.bidirectional=!0),s===`+`&&(h.activate=!0),s===`-`&&(h.deactivate=!0),i.enabled&&(h.seqNumber=i.next,i.next=Math.round((i.next+i.step)*100)/100),t.messages.push(h)}function W(e,t){if(t<0)return`before the first message`;let n=e.messages[t];if(!n)return`at an unresolved position`;let r=n.label?`: ${n.label}`:``;return`after message ${t+1} ("${n.from} -> ${n.to}${r}")`}function G(e){let t=new Map;for(let n of e.activations){let e=t.get(n.afterIndex)??[];e.push(n),t.set(n.afterIndex,e)}let n=[];function r(e){for(let r of t.get(e)??[])n.push({actorId:r.actorId,kind:r.kind,afterIndex:e})}r(-1);for(let t=0;t<e.messages.length;t++){let i=e.messages[t];i.activate&&n.push({actorId:i.to,kind:`start`,afterIndex:t}),i.deactivate&&n.push({actorId:i.from,kind:`end`,afterIndex:t}),r(t)}let i=new Map,a=[];for(let t of n){let n=i.get(t.actorId)??[];if(i.set(t.actorId,n),t.kind===`start`){n.push(t.afterIndex);continue}n.pop()===void 0&&a.push({code:`UNMATCHED_DEACTIVATION`,actorId:t.actorId,message:`"deactivate ${t.actorId}" ${W(e,t.afterIndex)} has no matching "activate ${t.actorId}" open at that point.`})}for(let[t,n]of i)for(let r of n)a.push({code:`DANGLING_ACTIVATION`,actorId:t,message:`"activate ${t}" opened ${W(e,r)} is never closed with a matching "deactivate ${t}".`});return{ok:a.length===0,issues:a}}function xe(t){let n=(0,e.detectDiagramType)(t);if(n!==`sequence`)throw Error(`fixActivationBalance only supports sequence diagrams (source must start with "sequenceDiagram"); detected diagram type: "${n}".`);let r=G(B((0,e.splitStatements)(t)));if(r.ok)return{ok:!0,originalDiagram:t,fixedDiagram:t,fixesApplied:[],remainingIssues:[]};let i=r.issues.filter(e=>e.code===`DANGLING_ACTIVATION`),a=r.issues.filter(e=>e.code!==`DANGLING_ACTIVATION`),o=i.map(e=>` deactivate ${e.actorId}`).join(`
|
|
3
|
+
`),s=i.length===0?t:`${t.replace(/\s+$/,``)}\n${o}`,c=i.map(e=>`Appended "deactivate ${e.actorId}" to close: ${e.message}`);return{ok:a.length===0,originalDiagram:t,fixedDiagram:s,fixesApplied:c,remainingIssues:a}}function Se(e){let t={},n={},r=[],i,a=!1;for(let o of e){let e=o.text;if(/^xychart(-beta)?\b/i.test(e)){/\bhorizontal\b/i.test(e)&&(a=!0);continue}let s=e.match(/^title\s+"([^"]+)"/);if(s){i=s[1];continue}let c=e.match(/^x-axis\s+(?:"([^"]*)"\s*)?\[([^\]]+)\]/);if(c){c[1]&&(t.title=c[1]),t.categories=Ce(c[2]).map(e=>we(e.trim()));continue}let l=e.match(/^x-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(l){l[1]&&(t.title=l[1]),t.range={min:parseFloat(l[2]),max:parseFloat(l[3])};continue}let u=e.match(/^y-axis\s+(?:"([^"]*)"\s+)?(-?\d+(?:\.\d+)?)\s*-->\s*(-?\d+(?:\.\d+)?)/);if(u){u[1]&&(n.title=u[1]),n.range={min:parseFloat(u[2]),max:parseFloat(u[3])};continue}let d=e.match(/^y-axis\s+"([^"]+)"\s*$/);if(d){n.title=d[1];continue}let f=e.match(/^bar\s+\[([^\]]+)\]/);if(f){r.push({type:`bar`,data:K(f[1],`bar`,e,o.line)});continue}let p=e.match(/^line\s+\[([^\]]+)\]/);if(p){r.push({type:`line`,data:K(p[1],`line`,e,o.line)});continue}let m=e.match(/^(x-axis|y-axis|bar|line|title)\b/i);if(m)throw Ee(m[1].toLowerCase(),e,o.line)}if(!n.range&&r.length>0){let e=r.flatMap(e=>e.data),t=Math.min(...e),i=Math.max(...e),a=i-t||1;t-=a*.1,i+=a*.1,t>0&&t<a*.5&&(t=0),n.range={min:t,max:i}}return n.range||={min:0,max:100},{title:i,horizontal:a,xAxis:t,yAxis:n,series:r}}function Ce(e){let t=[],n=``,r=!1;for(let i of e)i===`"`?(r=!r,n+=i):i===`,`&&!r?(t.push(n),n=``):n+=i;return t.push(n),t}function we(e){return e.length>=2&&e.startsWith(`"`)&&e.endsWith(`"`)?e.slice(1,-1):e}function K(e,t,n,r){return e.split(`,`).map((e,i)=>{let a=e.trim(),o=parseFloat(a);if(a.length===0||Number.isNaN(o))throw Error(`Line ${r}: Invalid numeric value ${JSON.stringify(a)} at position ${i+1} in "${n}". Every value in a ${t} [...] list must be a number.`);return o})}var Te={"x-axis":`x-axis [A, B, C] (categories) or x-axis 0 --> 100 (numeric range), either optionally preceded by a quoted title`,"y-axis":`y-axis 0 --> 100 (numeric range) or y-axis "Title" (title only), optionally preceded by a quoted title before a range`,bar:`bar [10, 20, 30] — a comma-separated numeric array in square brackets`,line:`line [10, 20, 30] — a comma-separated numeric array in square brackets`,title:`title "Chart Title" — a double-quoted string`};function Ee(e,t,n){let r=Te[e]??e;return Error(`Line ${n}: Malformed xychart-beta "${e}" directive: "${t}". Expected: ${r}.`)}var q=`#3b82f6`;function J(e){let t=e.replace(`#`,``),n=parseInt(t.substring(0,2),16)/255,r=parseInt(t.substring(2,4),16)/255,i=parseInt(t.substring(4,6),16)/255,a=Math.max(n,r,i),o=Math.min(n,r,i),s=(a+o)/2;if(a===o)return[0,0,s*100];let c=a-o,l=s>.5?c/(2-a-o):c/(a+o),u;return u=a===n?((r-i)/c+(r<i?6:0))/6:a===r?((i-n)/c+2)/6:((n-r)/c+4)/6,[u*360,l*100,s*100]}function De(e,t,n){let r=t/100,i=n/100,a=(1-Math.abs(2*i-1))*r,o=a*(1-Math.abs(e/60%2-1)),s=i-a/2,c,l,u;e<60?(c=a,l=o,u=0):e<120?(c=o,l=a,u=0):e<180?(c=0,l=a,u=o):e<240?(c=0,l=o,u=a):e<300?(c=o,l=0,u=a):(c=a,l=0,u=o);let d=e=>Math.round((e+s)*255).toString(16).padStart(2,`0`);return`#${d(c)}${d(l)}${d(u)}`}function Y(e){return/^#[0-9a-fA-F]{6}$/.test(e)}function X(e){return J(e)[2]<50}function Oe(e,t,n){if(e===0)return t;let r=Y(t)?t:q,i=n&&Y(n)?n:void 0,[a,o]=J(r),s=Math.max(55,Math.min(85,o)),c=Math.ceil(e/2),l=e%2==1,u=i&&X(i)?!l:l,d=u?Math.max(25,48-c*13):Math.min(78,55+c*11);return De(((a+(u?-8:-12)*c)%360+360)%360,s,d)}var Z={rect:`rectangle`,rectangle:`rectangle`,proc:`rectangle`,process:`rectangle`,"normal-rect":`rectangle`,rounded:`rounded`,event:`rounded`,"rounded-rect":`rounded`,stadium:`stadium`,pill:`stadium`,terminal:`stadium`,subproc:`subroutine`,subprocess:`subroutine`,subroutine:`subroutine`,"framed-rectangle":`subroutine`,"fr-rect":`subroutine`,cyl:`cylinder`,cylinder:`cylinder`,db:`cylinder`,database:`cylinder`,"h-cyl":`cylinder`,das:`cylinder`,"horizontal-cylinder":`cylinder`,"lin-cyl":`cylinder`,"lined-cylinder":`cylinder`,disk:`cylinder`,circ:`circle`,circle:`circle`,start:`circle`,"dbl-circ":`doublecircle`,"double-circle":`doublecircle`,stop:`doublecircle`,"f-circ":`filled-circle`,"filled-circle":`filled-circle`,junction:`filled-circle`,"cross-circ":`crossed-circle`,"crossed-circle":`crossed-circle`,summary:`crossed-circle`,diam:`diamond`,diamond:`diamond`,decision:`diamond`,question:`diamond`,hex:`hexagon`,hexagon:`hexagon`,prepare:`hexagon`,odd:`asymmetric`,"rect-left-inv-arrow":`asymmetric`,"lean-r":`parallelogram`,"lean-right":`parallelogram`,"in-out":`parallelogram`,"lean-l":`parallelogram-alt`,"lean-left":`parallelogram-alt`,"out-in":`parallelogram-alt`,"trap-b":`trapezoid`,"trapezoid-bottom":`trapezoid`,priority:`trapezoid`,"trap-t":`trapezoid-alt`,"trapezoid-top":`trapezoid-alt`,manual:`trapezoid-alt`,"curv-trap":`trapezoid-alt`,"curved-trapezoid":`trapezoid-alt`,display:`trapezoid-alt`,doc:`document`,document:`document`,"lin-doc":`document`,"lined-document":`document`,"tag-doc":`document`,"tagged-document":`document`,docs:`stacked-document`,documents:`stacked-document`,"st-doc":`stacked-document`,"stacked-document":`stacked-document`,"notch-rect":`card`,card:`card`,"notched-rectangle":`card`,"lin-rect":`lined-process`,"lined-rectangle":`lined-process`,"lin-proc":`lined-process`,"shaded-process":`lined-process`,"div-rect":`divided-process`,"divided-rectangle":`divided-process`,"div-proc":`divided-process`,"tag-rect":`rectangle`,"tagged-rectangle":`rectangle`,"tag-proc":`rectangle`,procs:`stacked-process`,processes:`stacked-process`,"st-rect":`stacked-process`,"stacked-rectangle":`stacked-process`,tri:`triangle`,triangle:`triangle`,extract:`triangle`,"flip-tri":`flipped-triangle`,"flipped-triangle":`flipped-triangle`,"manual-file":`flipped-triangle`,"win-pane":`window-pane`,"window-pane":`window-pane`,"internal-storage":`window-pane`,fork:`fork-join`,join:`fork-join`,"long-rect":`fork-join`,"notch-pent":`notched-pentagon`,"loop-limit":`notched-pentagon`,"notched-pentagon":`notched-pentagon`,"sl-rect":`sloped-rectangle`,"sloped-rectangle":`sloped-rectangle`,"manual-input":`sloped-rectangle`,flag:`flag`,"paper-tape":`flag`,"bow-rect":`bow-tie-rectangle`,"bow-tie-rectangle":`bow-tie-rectangle`,"stored-data":`bow-tie-rectangle`,delay:`half-rounded-rectangle`,"half-rounded-rectangle":`half-rounded-rectangle`,brace:`brace`,"brace-l":`brace`,comment:`brace`,"brace-r":`brace-right`,braces:`braces`,bolt:`bolt`,"com-link":`bolt`,"lightning-bolt":`bolt`,text:`text`,anchor:`anchor`};function ke(e){return Z[e.trim().toLowerCase()]}function Ae(){return Object.keys(Z).sort()}function je(e){let t={};for(let n of Q(e,`,`)){let e=n.trim();if(e.length===0)continue;let r=Me(e,`:`);if(r===-1){t.shape??=$(e);continue}let i=e.slice(0,r).trim().toLowerCase(),a=$(e.slice(r+1).trim());i.length>0&&(t[i]=a)}return t}function Q(e,t){let n=[],r=``,i=null;for(let a of e){if(i!==null){r+=a,a===i&&(i=null);continue}if(a===`"`||a===`'`){i=a,r+=a;continue}if(a===t){n.push(r),r=``;continue}r+=a}return n.push(r),n}function Me(e,t){let n=null;for(let r=0;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===t)return r}return-1}function $(e){return e.length>=2&&(e.startsWith(`"`)&&e.endsWith(`"`)||e.startsWith(`'`)&&e.endsWith(`'`))?e.slice(1,-1):e}function Ne(e){if(!e.startsWith(`@{`))return;let t=0,n=null;for(let r=1;r<e.length;r++){let i=e[r];if(n!==null){i===n&&(n=null);continue}if(i===`"`||i===`'`){n=i;continue}if(i===`{`){t++;continue}if(i===`}`&&(t--,t===0))return{body:e.slice(2,r),length:r+1}}}exports.CHART_ACCENT_FALLBACK=q,exports.architectureToGraph=p,exports.c4BoundaryTypeLine=ae,exports.c4Placement=T,exports.c4RelLabelLines=oe,exports.c4TypeLine=ie,exports.checkActivationBalance=G,exports.fixActivationBalance=xe,exports.formatClassMember=pe,exports.getSeriesColor=Oe,exports.isBlockType=R,exports.isCssColor=I,exports.isDarkBackground=X,exports.isValidHex=Y,exports.knownShapeNames=Ae,exports.matchExpandedBlock=Ne,exports.parseArchitecture=c,exports.parseBoxHeader=L,exports.parseC4Diagram=te,exports.parseClassDiagram=ce,exports.parseErDiagram=me,exports.parseExpandedMeta=je,exports.parseGenericTypes=A,exports.parseSequenceDiagram=B,exports.parseXYChart=Se,exports.resolveShapeName=ke,exports.toBlockType=z,exports.wrapC4Text=ne;
|
|
4
4
|
//# sourceMappingURL=index.cjs.map
|