|
| 1 | +var B = (e, n, t) => new Promise((i, c) => { |
| 2 | + var r = (l) => { |
| 3 | + try { |
| 4 | + a(t.next(l)); |
| 5 | + } catch (s) { |
| 6 | + c(s); |
| 7 | + } |
| 8 | + }, o = (l) => { |
| 9 | + try { |
| 10 | + a(t.throw(l)); |
| 11 | + } catch (s) { |
| 12 | + c(s); |
| 13 | + } |
| 14 | + }, a = (l) => l.done ? i(l.value) : Promise.resolve(l.value).then(r, o); |
| 15 | + a((t = t.apply(e, n)).next()); |
| 16 | +}); |
| 17 | +import { p as Q, d as M, s as X, D as U, a as Z, S as F, b as I, c as tt } from "./888e22ae.js"; |
| 18 | +import { G as et } from "./4504d077.js"; |
| 19 | +import { l as T, e as g, j as x, C as ot, k as st, m as w } from "./08856db2.js"; |
| 20 | +import { r as nt } from "./7ca39633.js"; |
| 21 | +import "./666097a3.js"; |
| 22 | +import "./289514c9.js"; |
| 23 | +import "./691304fa.js"; |
| 24 | +import "./f69b998c.js"; |
| 25 | +import "./8e8be6e8.js"; |
| 26 | +import "./2ff2c7a6.js"; |
| 27 | +import "./256b619e.js"; |
| 28 | +const h = "rect", C = "rectWithTitle", it = "start", ct = "end", rt = "divider", lt = "roundedWithTitle", at = "note", dt = "noteGroup", u = "statediagram", Et = "state", St = `${u}-${Et}`, V = "transition", Tt = "note", pt = "note-edge", _t = `${V} ${pt}`, ut = `${u}-${Tt}`, Dt = "cluster", bt = `${u}-${Dt}`, ft = "cluster-alt", At = `${u}-${ft}`, Y = "parent", m = "note", ht = "state", N = "----", yt = `${N}${m}`, H = `${N}${Y}`, W = "fill:none", z = "fill: #333", j = "c", q = "text", K = "normal"; |
| 29 | +let y = {}, S = 0; |
| 30 | +const gt = function(e) { |
| 31 | + const n = Object.keys(e); |
| 32 | + for (const t of n) |
| 33 | + e[t]; |
| 34 | +}, $t = function(e, n) { |
| 35 | + return n.db.extract(n.db.getRootDocV2()), n.db.getClasses(); |
| 36 | +}; |
| 37 | +function xt(e) { |
| 38 | + return e == null ? "" : e.classes ? e.classes.join(" ") : ""; |
| 39 | +} |
| 40 | +function R(e = "", n = 0, t = "", i = N) { |
| 41 | + const c = t !== null && t.length > 0 ? `${i}${t}` : ""; |
| 42 | + return `${ht}-${e}${c}-${n}`; |
| 43 | +} |
| 44 | +const A = (e, n, t, i, c, r) => { |
| 45 | + const o = t.id, a = xt(i[o]); |
| 46 | + if (o !== "root") { |
| 47 | + let l = h; |
| 48 | + t.start === !0 && (l = it), t.start === !1 && (l = ct), t.type !== U && (l = t.type), y[o] || (y[o] = { |
| 49 | + id: o, |
| 50 | + shape: l, |
| 51 | + description: w.sanitizeText(o, g()), |
| 52 | + classes: `${a} ${St}` |
| 53 | + }); |
| 54 | + const s = y[o]; |
| 55 | + t.description && (Array.isArray(s.description) ? (s.shape = C, s.description.push(t.description)) : s.description.length > 0 ? (s.shape = C, s.description === o ? s.description = [t.description] : s.description = [s.description, t.description]) : (s.shape = h, s.description = t.description), s.description = w.sanitizeTextOrArray(s.description, g())), s.description.length === 1 && s.shape === C && (s.shape = h), !s.type && t.doc && (T.info("Setting cluster for ", o, G(t)), s.type = "group", s.dir = G(t), s.shape = t.type === Z ? rt : lt, s.classes = s.classes + " " + bt + " " + (r ? At : "")); |
| 56 | + const _ = { |
| 57 | + labelStyle: "", |
| 58 | + shape: s.shape, |
| 59 | + labelText: s.description, |
| 60 | + // typeof newNode.description === 'object' |
| 61 | + // ? newNode.description[0] |
| 62 | + // : newNode.description, |
| 63 | + classes: s.classes, |
| 64 | + style: "", |
| 65 | + //styles.style, |
| 66 | + id: o, |
| 67 | + dir: s.dir, |
| 68 | + domId: R(o, S), |
| 69 | + type: s.type, |
| 70 | + padding: 15 |
| 71 | + //getConfig().flowchart.padding |
| 72 | + }; |
| 73 | + if (_.centerLabel = !0, t.note) { |
| 74 | + const d = { |
| 75 | + labelStyle: "", |
| 76 | + shape: at, |
| 77 | + labelText: t.note.text, |
| 78 | + classes: ut, |
| 79 | + // useHtmlLabels: false, |
| 80 | + style: "", |
| 81 | + // styles.style, |
| 82 | + id: o + yt + "-" + S, |
| 83 | + domId: R(o, S, m), |
| 84 | + type: s.type, |
| 85 | + padding: 15 |
| 86 | + //getConfig().flowchart.padding |
| 87 | + }, E = { |
| 88 | + labelStyle: "", |
| 89 | + shape: dt, |
| 90 | + labelText: t.note.text, |
| 91 | + classes: s.classes, |
| 92 | + style: "", |
| 93 | + // styles.style, |
| 94 | + id: o + H, |
| 95 | + domId: R(o, S, Y), |
| 96 | + type: "group", |
| 97 | + padding: 0 |
| 98 | + //getConfig().flowchart.padding |
| 99 | + }; |
| 100 | + S++; |
| 101 | + const D = o + H; |
| 102 | + e.setNode(D, E), e.setNode(d.id, d), e.setNode(o, _), e.setParent(o, D), e.setParent(d.id, D); |
| 103 | + let p = o, b = d.id; |
| 104 | + t.note.position === "left of" && (p = d.id, b = o), e.setEdge(p, b, { |
| 105 | + arrowhead: "none", |
| 106 | + arrowType: "", |
| 107 | + style: W, |
| 108 | + labelStyle: "", |
| 109 | + classes: _t, |
| 110 | + arrowheadStyle: z, |
| 111 | + labelpos: j, |
| 112 | + labelType: q, |
| 113 | + thickness: K |
| 114 | + }); |
| 115 | + } else |
| 116 | + e.setNode(o, _); |
| 117 | + } |
| 118 | + n && n.id !== "root" && (T.trace("Setting node ", o, " to be child of its parent ", n.id), e.setParent(o, n.id)), t.doc && (T.trace("Adding nodes children "), Ct(e, t, t.doc, i, c, !r)); |
| 119 | +}, Ct = (e, n, t, i, c, r) => { |
| 120 | + T.trace("items", t), t.forEach((o) => { |
| 121 | + switch (o.stmt) { |
| 122 | + case I: |
| 123 | + A(e, n, o, i, c, r); |
| 124 | + break; |
| 125 | + case U: |
| 126 | + A(e, n, o, i, c, r); |
| 127 | + break; |
| 128 | + case F: |
| 129 | + { |
| 130 | + A(e, n, o.state1, i, c, r), A(e, n, o.state2, i, c, r); |
| 131 | + const a = { |
| 132 | + id: "edge" + S, |
| 133 | + arrowhead: "normal", |
| 134 | + arrowTypeEnd: "arrow_barb", |
| 135 | + style: W, |
| 136 | + labelStyle: "", |
| 137 | + label: w.sanitizeText(o.description, g()), |
| 138 | + arrowheadStyle: z, |
| 139 | + labelpos: j, |
| 140 | + labelType: q, |
| 141 | + thickness: K, |
| 142 | + classes: V |
| 143 | + }; |
| 144 | + e.setEdge(o.state1.id, o.state2.id, a, S), S++; |
| 145 | + } |
| 146 | + break; |
| 147 | + } |
| 148 | + }); |
| 149 | +}, G = (e, n = tt) => { |
| 150 | + let t = n; |
| 151 | + if (e.doc) |
| 152 | + for (let i = 0; i < e.doc.length; i++) { |
| 153 | + const c = e.doc[i]; |
| 154 | + c.stmt === "dir" && (t = c.value); |
| 155 | + } |
| 156 | + return t; |
| 157 | +}, Rt = function(e, n, t, i) { |
| 158 | + return B(this, null, function* () { |
| 159 | + T.info("Drawing state diagram (v2)", n), y = {}, i.db.getDirection(); |
| 160 | + const { securityLevel: c, state: r } = g(), o = r.nodeSpacing || 50, a = r.rankSpacing || 50; |
| 161 | + T.info(i.db.getRootDocV2()), i.db.extract(i.db.getRootDocV2()), T.info(i.db.getRootDocV2()); |
| 162 | + const l = i.db.getStates(), s = new et({ |
| 163 | + multigraph: !0, |
| 164 | + compound: !0 |
| 165 | + }).setGraph({ |
| 166 | + rankdir: G(i.db.getRootDocV2()), |
| 167 | + nodesep: o, |
| 168 | + ranksep: a, |
| 169 | + marginx: 8, |
| 170 | + marginy: 8 |
| 171 | + }).setDefaultEdgeLabel(function() { |
| 172 | + return {}; |
| 173 | + }); |
| 174 | + A(s, void 0, i.db.getRootDocV2(), l, i.db, !0); |
| 175 | + let _; |
| 176 | + c === "sandbox" && (_ = x("#i" + n)); |
| 177 | + const d = c === "sandbox" ? x(_.nodes()[0].contentDocument.body) : x("body"), E = d.select(`[id="${n}"]`), D = d.select("#" + n + " g"); |
| 178 | + yield nt(D, s, ["barb"], u, n); |
| 179 | + const p = 8; |
| 180 | + ot.insertTitle(E, "statediagramTitleText", r.titleTopMargin, i.db.getDiagramTitle()); |
| 181 | + const b = E.node().getBBox(), L = b.width + p * 2, P = b.height + p * 2; |
| 182 | + E.attr("class", u); |
| 183 | + const O = E.node().getBBox(); |
| 184 | + st(E, P, L, r.useMaxWidth); |
| 185 | + const k = `${O.x - p} ${O.y - p} ${L} ${P}`; |
| 186 | + T.debug(`viewBox ${k}`), E.attr("viewBox", k); |
| 187 | + const J = document.querySelectorAll('[id="' + n + '"] .edgeLabel .label'); |
| 188 | + for (const $ of J) { |
| 189 | + const v = $.getBBox(), f = document.createElementNS("http://www.w3.org/2000/svg", h); |
| 190 | + f.setAttribute("rx", 0), f.setAttribute("ry", 0), f.setAttribute("width", v.width), f.setAttribute("height", v.height), $.insertBefore(f, $.firstChild); |
| 191 | + } |
| 192 | + }); |
| 193 | +}, wt = { |
| 194 | + setConf: gt, |
| 195 | + getClasses: $t, |
| 196 | + draw: Rt |
| 197 | +}, Yt = { |
| 198 | + parser: Q, |
| 199 | + db: M, |
| 200 | + renderer: wt, |
| 201 | + styles: X, |
| 202 | + init: (e) => { |
| 203 | + e.state || (e.state = {}), e.state.arrowMarkerAbsolute = e.arrowMarkerAbsolute, M.clear(); |
| 204 | + } |
| 205 | +}; |
| 206 | +export { |
| 207 | + Yt as diagram |
| 208 | +}; |
0 commit comments