import { v, Z as Ze } from './graph-0ee63739.esm.js';
import { m as m$1, Y as Yt } from './layout-fd473db2.esm.js';
import { a } from './clone-afc2f047.esm.js';
import { h as hr, f as fr, d as dr, x as xr, t as tr, p as pr, u as ur, g as gr, o as or, m as m$2, y as yr, B as Bt, R } from './edges-16357fde.esm.js';
import { a as L, V as Vn, e as La, b as bt$1 } from './index.esm2.js';
import { U as Ur } from './createText-03b82060.esm.js';

function _array_like_to_array(arr, len) {
    if (len == null || len > arr.length) len = arr.length;
    for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
    return arr2;
}
function _array_without_holes(arr) {
    if (Array.isArray(arr)) return _array_like_to_array(arr);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
    try {
        var info = gen[key](arg);
        var value = info.value;
    } catch (error) {
        reject(error);
        return;
    }
    if (info.done) {
        resolve(value);
    } else {
        Promise.resolve(value).then(_next, _throw);
    }
}
function _async_to_generator(fn) {
    return function() {
        var self = this, args = arguments;
        return new Promise(function(resolve, reject) {
            var gen = fn.apply(self, args);
            function _next(value) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
            }
            function _throw(err) {
                asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
            }
            _next(undefined);
        });
    };
}
function _iterable_to_array(iter) {
    if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
}
function _non_iterable_spread() {
    throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _to_consumable_array(arr) {
    return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
}
function _unsupported_iterable_to_array(o, minLen) {
    if (!o) return;
    if (typeof o === "string") return _array_like_to_array(o, minLen);
    var n = Object.prototype.toString.call(o).slice(8, -1);
    if (n === "Object" && o.constructor) n = o.constructor.name;
    if (n === "Map" || n === "Set") return Array.from(n);
    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
}
function _ts_generator(thisArg, body) {
    var f, y, t, g, _ = {
        label: 0,
        sent: function() {
            if (t[0] & 1) throw t[1];
            return t[1];
        },
        trys: [],
        ops: []
    };
    return g = {
        next: verb(0),
        "throw": verb(1),
        "return": verb(2)
    }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
        return this;
    }), g;
    function verb(n) {
        return function(v) {
            return step([
                n,
                v
            ]);
        };
    }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while(_)try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [
                op[0] & 2,
                t.value
            ];
            switch(op[0]){
                case 0:
                case 1:
                    t = op;
                    break;
                case 4:
                    _.label++;
                    return {
                        value: op[1],
                        done: false
                    };
                case 5:
                    _.label++;
                    y = op[1];
                    op = [
                        0
                    ];
                    continue;
                case 7:
                    op = _.ops.pop();
                    _.trys.pop();
                    continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                        _ = 0;
                        continue;
                    }
                    if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                        _.label = op[1];
                        break;
                    }
                    if (op[0] === 6 && _.label < t[1]) {
                        _.label = t[1];
                        t = op;
                        break;
                    }
                    if (t && _.label < t[2]) {
                        _.label = t[2];
                        _.ops.push(op);
                        break;
                    }
                    if (t[2]) _.ops.pop();
                    _.trys.pop();
                    continue;
            }
            op = body.call(thisArg, _);
        } catch (e) {
            op = [
                6,
                e
            ];
            y = 0;
        } finally{
            f = t = 0;
        }
        if (op[0] & 5) throw op[1];
        return {
            value: op[0] ? op[1] : void 0,
            done: true
        };
    }
}
function m(e) {
    var t = {
        options: {
            directed: e.isDirected(),
            multigraph: e.isMultigraph(),
            compound: e.isCompound()
        },
        nodes: tt(e),
        edges: et(e)
    };
    return v(e.graph()) || (t.value = a(e.graph())), t;
}
function tt(e) {
    return m$1(e.nodes(), function(t) {
        var n = e.node(t), r = e.parent(t), i = {
            v: t
        };
        return v(n) || (i.value = n), v(r) || (i.parent = r), i;
    });
}
function et(e) {
    return m$1(e.edges(), function(t) {
        var n = e.edge(t), r = {
            v: t.v,
            w: t.w
        };
        return v(t.name) || (r.name = t.name), v(n) || (r.value = n), r;
    });
}
var l = {}, g = {}, P = {};
var nt = function() {
    g = {}, P = {}, l = {};
}, B = function(e, t) {
    return L.trace("In isDescendant", t, " ", e, " = ", g[t].includes(e)), !!g[t].includes(e);
}, it = function(e, t) {
    return L.info("Descendants of ", t, " is ", g[t]), L.info("Edge is ", e), e.v === t || e.w === t ? false : g[t] ? g[t].includes(e.v) || B(e.v, t) || B(e.w, t) || g[t].includes(e.w) : (L.debug("Tilt, ", t, ",not in descendants"), false);
}, k = function(e, t, n, r) {
    L.warn("Copying children of ", e, "root", r, "data", t.node(e), r);
    var i = t.children(e) || [];
    e !== r && i.push(e), L.warn("Copying (nodes) clusterId", e, "nodes", i), i.forEach(function(a) {
        if (t.children(a).length > 0) k(a, t, n, r);
        else {
            var d = t.node(a);
            L.info("cp ", a, " to ", r, " with parent ", e), n.setNode(a, d), r !== t.parent(a) && (L.warn("Setting parent", a, t.parent(a)), n.setParent(a, t.parent(a))), e !== r && a !== e ? (L.debug("Setting parent", a, e), n.setParent(a, e)) : (L.info("In copy ", e, "root", r, "data", t.node(e), r), L.debug("Not Setting parent for node=", a, "cluster!==rootId", e !== r, "node!==clusterId", a !== e));
            var u = t.edges(a);
            L.debug("Copying Edges", u), u.forEach(function(f) {
                L.info("Edge", f);
                var h = t.edge(f.v, f.w, f.name);
                L.info("Edge data", h, r);
                try {
                    it(f, r) ? (L.info("Copying as ", f.v, f.w, h, f.name), n.setEdge(f.v, f.w, h, f.name), L.info("newGraph edges ", n.edges(), n.edge(n.edges()[0]))) : L.info("Skipping copy of edge ", f.v, "-->", f.w, " rootId: ", r, " clusterId:", e);
                } catch (w) {
                    L.error(w);
                }
            });
        }
        L.debug("Removing node", a), t.removeNode(a);
    });
}, $ = function(e, t) {
    var n = t.children(e);
    var r = _to_consumable_array(n);
    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
    try {
        for(var _iterator = n[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
            var i = _step.value;
            P[i] = e, r = _to_consumable_array(r).concat(_to_consumable_array($(i, t)));
        }
    } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
                _iterator.return();
            }
        } finally{
            if (_didIteratorError) {
                throw _iteratorError;
            }
        }
    }
    return r;
}, C = function(e, t) {
    L.trace("Searching", e);
    var n = t.children(e);
    if (L.trace("Searching children of id ", e, n), n.length < 1) return L.trace("This is a valid node", e), e;
    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
    try {
        for(var _iterator = n[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
            var r = _step.value;
            var i = C(r, t);
            if (i) return L.trace("Found replacement for", e, " => ", i), i;
        }
    } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
                _iterator.return();
            }
        } finally{
            if (_didIteratorError) {
                throw _iteratorError;
            }
        }
    }
}, X = function(e) {
    return !l[e] || !l[e].externalConnections ? e : l[e] ? l[e].id : e;
}, st = function(e, t) {
    if (!e || t > 10) {
        L.debug("Opting out, no graph ");
        return;
    } else L.debug("Opting in, graph ");
    e.nodes().forEach(function(n) {
        e.children(n).length > 0 && (L.warn("Cluster identified", n, " Replacement id in edges: ", C(n, e)), g[n] = $(n, e), l[n] = {
            id: C(n, e),
            clusterData: e.node(n)
        });
    }), e.nodes().forEach(function(n) {
        var r = e.children(n), i = e.edges();
        r.length > 0 ? (L.debug("Cluster identified", n, g), i.forEach(function(a) {
            if (a.v !== n && a.w !== n) {
                var d = B(a.v, n), u = B(a.w, n);
                d ^ u && (L.warn("Edge: ", a, " leaves cluster ", n), L.warn("Descendants of XXX ", n, ": ", g[n]), l[n].externalConnections = true);
            }
        })) : L.debug("Not a cluster ", n, g);
    });
    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
    try {
        for(var _iterator = Object.keys(l)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
            var n = _step.value;
            var r = l[n].id, i = e.parent(r);
            i !== n && l[i] && !l[i].externalConnections && (l[n].id = i);
        }
    } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
                _iterator.return();
            }
        } finally{
            if (_didIteratorError) {
                throw _iteratorError;
            }
        }
    }
    e.edges().forEach(function(n) {
        var r = e.edge(n);
        L.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(n)), L.warn("Edge " + n.v + " -> " + n.w + ": " + JSON.stringify(e.edge(n)));
        var i = n.v, a = n.w;
        if (L.warn("Fix XXX", l, "ids:", n.v, n.w, "Translating: ", l[n.v], " --- ", l[n.w]), l[n.v] && l[n.w] && l[n.v] === l[n.w]) {
            L.warn("Fixing and trixing link to self - removing XXX", n.v, n.w, n.name), L.warn("Fixing and trixing - removing XXX", n.v, n.w, n.name), i = X(n.v), a = X(n.w), e.removeEdge(n.v, n.w, n.name);
            var d = n.w + "---" + n.v;
            e.setNode(d, {
                domId: d,
                id: d,
                labelStyle: "",
                labelText: r.label,
                padding: 0,
                shape: "labelRect",
                style: ""
            });
            var u = structuredClone(r), f = structuredClone(r);
            u.label = "", u.arrowTypeEnd = "none", f.label = "", u.fromCluster = n.v, f.toCluster = n.v, e.setEdge(i, d, u, n.name + "-cyclic-special"), e.setEdge(d, a, f, n.name + "-cyclic-special");
        } else if (l[n.v] || l[n.w]) {
            if (L.warn("Fixing and trixing - removing XXX", n.v, n.w, n.name), i = X(n.v), a = X(n.w), e.removeEdge(n.v, n.w, n.name), i !== n.v) {
                var d1 = e.parent(i);
                l[d1].externalConnections = true, r.fromCluster = n.v;
            }
            if (a !== n.w) {
                var d2 = e.parent(a);
                l[d2].externalConnections = true, r.toCluster = n.w;
            }
            L.warn("Fix Replacing with XXX", i, a, n.name), e.setEdge(i, a, r, n.name);
        }
    }), L.warn("Adjusted Graph", m(e)), F(e, 0), L.trace(l);
}, F = function(e, t) {
    if (L.warn("extractor - ", t, m(e), e.children("D")), t > 10) {
        L.error("Bailing out");
        return;
    }
    var n = e.nodes(), r = false;
    var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
    try {
        for(var _iterator = n[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
            var i = _step.value;
            var a = e.children(i);
            r = r || a.length > 0;
        }
    } catch (err) {
        _didIteratorError = true;
        _iteratorError = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion && _iterator.return != null) {
                _iterator.return();
            }
        } finally{
            if (_didIteratorError) {
                throw _iteratorError;
            }
        }
    }
    if (!r) {
        L.debug("Done, no node has children", e.nodes());
        return;
    }
    L.debug("Nodes = ", n, t);
    var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
    try {
        for(var _iterator1 = n[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
            var i1 = _step1.value;
            if (L.debug("Extracting node", i1, l, l[i1] && !l[i1].externalConnections, !e.parent(i1), e.node(i1), e.children("D"), " Depth ", t), !l[i1]) L.debug("Not a cluster", i1, t);
            else if (!l[i1].externalConnections && // !graph.parent(node) &&
            e.children(i1) && e.children(i1).length > 0) {
                L.warn("Cluster without external connections, without a parent and with children", i1, t);
                var d = e.graph().rankdir === "TB" ? "LR" : "TB";
                l[i1] && l[i1].clusterData && l[i1].clusterData.dir && (d = l[i1].clusterData.dir, L.warn("Fixing dir", l[i1].clusterData.dir, d));
                var u = new Ze({
                    multigraph: !0,
                    compound: !0
                }).setGraph({
                    rankdir: d,
                    // Todo: set proper spacing
                    nodesep: 50,
                    ranksep: 50,
                    marginx: 8,
                    marginy: 8
                }).setDefaultEdgeLabel(function() {
                    return {};
                });
                L.warn("Old graph before copy", m(e)), k(i1, e, u, i1), e.setNode(i1, {
                    clusterNode: !0,
                    id: i1,
                    clusterData: l[i1].clusterData,
                    labelText: l[i1].labelText,
                    graph: u
                }), L.warn("New graph after copy node: (", i1, ")", m(u)), L.debug("Old graph after copy", m(e));
            } else L.warn("Cluster ** ", i1, " **not meeting the criteria !externalConnections:", !l[i1].externalConnections, " no parent: ", !e.parent(i1), " children ", e.children(i1) && e.children(i1).length > 0, e.children("D"), t), L.debug(l);
        }
    } catch (err) {
        _didIteratorError1 = true;
        _iteratorError1 = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
                _iterator1.return();
            }
        } finally{
            if (_didIteratorError1) {
                throw _iteratorError1;
            }
        }
    }
    n = e.nodes(), L.warn("New list of nodes", n);
    var _iteratorNormalCompletion2 = true, _didIteratorError2 = false, _iteratorError2 = undefined;
    try {
        for(var _iterator2 = n[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true){
            var i2 = _step2.value;
            var a1 = e.node(i2);
            L.warn(" Now next level", i2, a1), a1.clusterNode && F(a1.graph, t + 1);
        }
    } catch (err) {
        _didIteratorError2 = true;
        _iteratorError2 = err;
    } finally{
        try {
            if (!_iteratorNormalCompletion2 && _iterator2.return != null) {
                _iterator2.return();
            }
        } finally{
            if (_didIteratorError2) {
                throw _iteratorError2;
            }
        }
    }
}, G = function(e, t) {
    if (t.length === 0) return [];
    var n = Object.assign(t);
    return t.forEach(function(r) {
        var i = e.children(r), a = G(e, i);
        n = _to_consumable_array(n).concat(_to_consumable_array(a));
    }), n;
}, rt = function(e) {
    return G(e, e.children());
}, at = function(e, t) {
    L.info("Creating subgraph rect for ", t.id, t);
    var n = Vn(), r = e.insert("g").attr("class", "cluster" + (t.class ? " " + t.class : "")).attr("id", t.id), i = r.insert("rect", ":first-child"), a = La(n.flowchart.htmlLabels), d = r.insert("g").attr("class", "cluster-label"), u = t.labelType === "markdown" ? Ur(d, t.labelText, {
        style: t.labelStyle,
        useHtmlLabels: a
    }) : d.node().appendChild(R(t.labelText, t.labelStyle, void 0, true));
    var f = u.getBBox();
    if (La(n.flowchart.htmlLabels)) {
        var c = u.children[0], o = bt$1(u);
        f = c.getBoundingClientRect(), o.attr("width", f.width), o.attr("height", f.height);
    }
    var h = 0 * t.padding, w = h / 2, x = t.width <= f.width + h ? f.width + h : t.width;
    t.width <= f.width + h ? t.diff = (f.width - t.width) / 2 - t.padding / 2 : t.diff = -t.padding / 2, L.trace("Data ", t, JSON.stringify(t)), i.attr("style", t.style).attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - x / 2).attr("y", t.y - t.height / 2 - w).attr("width", x).attr("height", t.height + h);
    var _D = tr(n), v = _D.subGraphTitleTopMargin;
    a ? d.attr("transform", // This puts the label on top of the box instead of inside it
    "translate(".concat(t.x - f.width / 2, ", ").concat(t.y - t.height / 2 + v, ")")) : d.attr("transform", // This puts the label on top of the box instead of inside it
    "translate(".concat(t.x, ", ").concat(t.y - t.height / 2 + v, ")"));
    var y = i.node().getBBox();
    return t.width = y.width, t.height = y.height, t.intersect = function at(c) {
        return Bt(t, c);
    }, r;
}, ct = function(e, t) {
    var n = e.insert("g").attr("class", "note-cluster").attr("id", t.id), r = n.insert("rect", ":first-child"), i = 0 * t.padding, a = i / 2;
    r.attr("rx", t.rx).attr("ry", t.ry).attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2 - a).attr("width", t.width + i).attr("height", t.height + i).attr("fill", "none");
    var d = r.node().getBBox();
    return t.width = d.width, t.height = d.height, t.intersect = function ct(u) {
        return Bt(t, u);
    }, n;
}, ot = function(e, t) {
    var n = Vn(), r = e.insert("g").attr("class", t.classes).attr("id", t.id), i = r.insert("rect", ":first-child"), a = r.insert("g").attr("class", "cluster-label"), d = r.append("rect"), u = a.node().appendChild(R(t.labelText, t.labelStyle, void 0, true));
    var f = u.getBBox();
    if (La(n.flowchart.htmlLabels)) {
        var c = u.children[0], o = bt$1(u);
        f = c.getBoundingClientRect(), o.attr("width", f.width), o.attr("height", f.height);
    }
    f = u.getBBox();
    var h = 0 * t.padding, w = h / 2, x = t.width <= f.width + t.padding ? f.width + t.padding : t.width;
    t.width <= f.width + t.padding ? t.diff = (f.width + t.padding * 0 - t.width) / 2 : t.diff = -t.padding / 2, i.attr("class", "outer").attr("x", t.x - x / 2 - w).attr("y", t.y - t.height / 2 - w).attr("width", x + h).attr("height", t.height + h), d.attr("class", "inner").attr("x", t.x - x / 2 - w).attr("y", t.y - t.height / 2 - w + f.height - 1).attr("width", x + h).attr("height", t.height + h - f.height - 3);
    var _D = tr(n), v = _D.subGraphTitleTopMargin;
    a.attr("transform", "translate(".concat(t.x - f.width / 2, ", ").concat(t.y - t.height / 2 - t.padding / 3 + (La(n.flowchart.htmlLabels) ? 5 : 3) + v, ")"));
    var y = i.node().getBBox();
    return t.height = y.height, t.intersect = function ot(c) {
        return Bt(t, c);
    }, r;
}, lt = function(e, t) {
    var n = e.insert("g").attr("class", t.classes).attr("id", t.id), r = n.insert("rect", ":first-child"), i = 0 * t.padding, a = i / 2;
    r.attr("class", "divider").attr("x", t.x - t.width / 2 - a).attr("y", t.y - t.height / 2).attr("width", t.width + i).attr("height", t.height + i);
    var d = r.node().getBBox();
    return t.width = d.width, t.height = d.height, t.diff = -t.padding / 2, t.intersect = function lt(u) {
        return Bt(t, u);
    }, n;
}, ft = {
    rect: at,
    roundedWithTitle: ot,
    noteGroup: ct,
    divider: lt
};
var j = {};
var dt = function(e, t) {
    L.trace("Inserting cluster");
    var n = t.shape || "rect";
    j[t.id] = ft[n](e, t);
}, ut = function() {
    j = {};
}, M = function() {
    var _ref = _async_to_generator(function(e, t, n, r, i, a) {
        var d, u, f, h, w, x, v, _D, y;
        return _ts_generator(this, function(_state) {
            switch(_state.label){
                case 0:
                    L.info("Graph in recursive render: XXX", m(t), i);
                    d = t.graph().rankdir;
                    L.trace("Dir in recursive render - dir:", d);
                    u = e.insert("g").attr("class", "root");
                    t.nodes() ? L.info("Recursive render XXX", t.nodes()) : L.info("No nodes found for", t), t.edges().length > 0 && L.trace("Recursive edges", t.edge(t.edges()[0]));
                    f = u.insert("g").attr("class", "clusters"), h = u.insert("g").attr("class", "edgePaths"), w = u.insert("g").attr("class", "edgeLabels"), x = u.insert("g").attr("class", "nodes");
                    return [
                        4,
                        Promise.all(t.nodes().map(function() {
                            var _ref = _async_to_generator(function(c) {
                                var o, b, b1, E;
                                return _ts_generator(this, function(_state) {
                                    switch(_state.label){
                                        case 0:
                                            o = t.node(c);
                                            if (i !== void 0) {
                                                b = JSON.parse(JSON.stringify(i.clusterData));
                                                L.info("Setting data for cluster XXX (", c, ") ", b, i), t.setNode(i.id, b), t.parent(c) || (L.trace("Setting parent", c, i.id), t.setParent(c, i.id, b));
                                            }
                                            if (!(L.info("(Insert) Node XXX" + c + ": " + JSON.stringify(t.node(c))), o && o.clusterNode)) return [
                                                3,
                                                2
                                            ];
                                            L.info("Cluster identified", c, o.width, t.node(c));
                                            return [
                                                4,
                                                M(x, o.graph, n, r, t.node(c), a)
                                            ];
                                        case 1:
                                            b1 = _state.sent(), E = b1.elem;
                                            m$2(o, E), o.diff = b1.diff || 0, L.info("Node bounds (abc123)", c, o, o.width, o.x, o.y), yr(E, o), L.warn("Recursive render complete ", E, o);
                                            return [
                                                3,
                                                6
                                            ];
                                        case 2:
                                            if (!(t.children(c).length > 0)) return [
                                                3,
                                                3
                                            ];
                                            (L.info("Cluster - the non recursive path XXX", c, o.id, o, t), L.info(C(o.id, t)), l[o.id] = {
                                                id: C(o.id, t),
                                                node: o
                                            });
                                            return [
                                                3,
                                                5
                                            ];
                                        case 3:
                                            L.info("Node - the non recursive path", c, o.id, o);
                                            return [
                                                4,
                                                or(x, t.node(c), d)
                                            ];
                                        case 4:
                                            _state.sent();
                                            _state.label = 5;
                                        case 5:
                                            _state.label = 6;
                                        case 6:
                                            return [
                                                2
                                            ];
                                    }
                                });
                            });
                            return function(c) {
                                return _ref.apply(this, arguments);
                            };
                        }()))
                    ];
                case 1:
                    _state.sent(), t.edges().forEach(function(c) {
                        var o = t.edge(c.v, c.w, c.name);
                        L.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c)), L.info("Edge " + c.v + " -> " + c.w + ": ", c, " ", JSON.stringify(t.edge(c))), L.info("Fix", l, "ids:", c.v, c.w, "Translating: ", l[c.v], l[c.w]), xr(w, o);
                    }), t.edges().forEach(function(c) {
                        L.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(c));
                    }), L.info("#############################################"), L.info("###                Layout                 ###"), L.info("#############################################"), L.info(t), Yt(t), L.info("Graph after layout:", m(t));
                    v = 0;
                    _D = tr(a), y = _D.subGraphTitleTotalMargin;
                    return [
                        2,
                        (rt(t).forEach(function(c) {
                            var o = t.node(c);
                            L.info("Position " + c + ": " + JSON.stringify(t.node(c))), L.info("Position " + c + ": (" + o.x, "," + o.y, ") width: ", o.width, " height: ", o.height), o && o.clusterNode ? (o.y += y, pr(o)) : t.children(c).length > 0 ? (o.height += y, dt(f, o), l[o.id].node = o) : (o.y += y / 2, pr(o));
                        }), t.edges().forEach(function(c) {
                            var o = t.edge(c);
                            L.info("Edge " + c.v + " -> " + c.w + ": " + JSON.stringify(o), o), o.points.forEach(function(E) {
                                return E.y += y / 2;
                            });
                            var b = ur(h, c, o, l, n, t, r);
                            gr(o, b);
                        }), t.nodes().forEach(function(c) {
                            var o = t.node(c);
                            L.info(c, o.type, o.diff), o.type === "group" && (v = o.diff);
                        }), {
                            elem: u,
                            diff: v
                        })
                    ];
            }
        });
    });
    return function M(e, t, n, r, i, a) {
        return _ref.apply(this, arguments);
    };
}(), bt = function() {
    var _ref = _async_to_generator(function(e, t, n, r, i) {
        var a;
        return _ts_generator(this, function(_state) {
            switch(_state.label){
                case 0:
                    hr(e, n, r, i), fr(), dr(), ut(), nt(), L.warn("Graph at first:", JSON.stringify(m(t))), st(t), L.warn("Graph after:", JSON.stringify(m(t)));
                    a = Vn();
                    return [
                        4,
                        M(e, t, r, i, void 0, a)
                    ];
                case 1:
                    _state.sent();
                    return [
                        2
                    ];
            }
        });
    });
    return function bt(e, t, n, r, i) {
        return _ref.apply(this, arguments);
    };
}();

export { bt as b };
