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_with_holes(arr) {
    if (Array.isArray(arr)) return arr;
}
function _assert_this_initialized(self) {
    if (self === void 0) {
        throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
    }
    return self;
}
function _call_super(_this, derived, args) {
    derived = _get_prototype_of(derived);
    return _possible_constructor_return(_this, _is_native_reflect_construct() ? Reflect.construct(derived, args || [], _get_prototype_of(_this).constructor) : derived.apply(_this, args));
}
function _class_call_check(instance, Constructor) {
    if (!(instance instanceof Constructor)) {
        throw new TypeError("Cannot call a class as a function");
    }
}
function _defineProperties(target, props) {
    for(var i = 0; i < props.length; i++){
        var descriptor = props[i];
        descriptor.enumerable = descriptor.enumerable || false;
        descriptor.configurable = true;
        if ("value" in descriptor) descriptor.writable = true;
        Object.defineProperty(target, descriptor.key, descriptor);
    }
}
function _create_class(Constructor, protoProps, staticProps) {
    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
    if (staticProps) _defineProperties(Constructor, staticProps);
    return Constructor;
}
function _get(target, property, receiver) {
    if (typeof Reflect !== "undefined" && Reflect.get) {
        _get = Reflect.get;
    } else {
        _get = function get(target, property, receiver) {
            var base = _super_prop_base(target, property);
            if (!base) return;
            var desc = Object.getOwnPropertyDescriptor(base, property);
            if (desc.get) {
                return desc.get.call(receiver || target);
            }
            return desc.value;
        };
    }
    return _get(target, property, receiver || target);
}
function _get_prototype_of(o) {
    _get_prototype_of = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
        return o.__proto__ || Object.getPrototypeOf(o);
    };
    return _get_prototype_of(o);
}
function _inherits(subClass, superClass) {
    if (typeof superClass !== "function" && superClass !== null) {
        throw new TypeError("Super expression must either be null or a function");
    }
    subClass.prototype = Object.create(superClass && superClass.prototype, {
        constructor: {
            value: subClass,
            writable: true,
            configurable: true
        }
    });
    if (superClass) _set_prototype_of(subClass, superClass);
}
function _instanceof(left, right) {
    "@swc/helpers - instanceof";
    if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
        return !!right[Symbol.hasInstance](left);
    } else {
        return left instanceof right;
    }
}
function _iterable_to_array_limit(arr, i) {
    var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
    if (_i == null) return;
    var _arr = [];
    var _n = true;
    var _d = false;
    var _s, _e;
    try {
        for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
            _arr.push(_s.value);
            if (i && _arr.length === i) break;
        }
    } catch (err) {
        _d = true;
        _e = err;
    } finally{
        try {
            if (!_n && _i["return"] != null) _i["return"]();
        } finally{
            if (_d) throw _e;
        }
    }
    return _arr;
}
function _non_iterable_rest() {
    throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
function _possible_constructor_return(self, call) {
    if (call && (_type_of(call) === "object" || typeof call === "function")) {
        return call;
    }
    return _assert_this_initialized(self);
}
function _set_prototype_of(o, p) {
    _set_prototype_of = Object.setPrototypeOf || function setPrototypeOf(o, p) {
        o.__proto__ = p;
        return o;
    };
    return _set_prototype_of(o, p);
}
function _sliced_to_array(arr, i) {
    return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
}
function _super_prop_base(object, property) {
    while(!Object.prototype.hasOwnProperty.call(object, property)){
        object = _get_prototype_of(object);
        if (object === null) break;
    }
    return object;
}
function _type_of(obj) {
    "@swc/helpers - typeof";
    return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
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 _is_native_reflect_construct() {
    try {
        var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
    } catch (_) {}
    return (_is_native_reflect_construct = function() {
        return !!result;
    })();
}
import { extent, groups, max, min } from "d3-array";
import * as scales from "d3-scale";
import { assign, backgroundColor, elem } from "@d3plus/dom";
import { colorContrast } from "@d3plus/color";
import { addToQueue } from "@d3plus/data";
import * as shapes from "../shapes/index.js";
import { accessor, configPrep, constant } from "../utils/index.js";
import Viz from "./Viz.js";
var Rings = /*#__PURE__*/ function(Viz) {
    "use strict";
    _inherits(Rings, Viz);
    function Rings() {
        _class_call_check(this, Rings);
        var _this;
        _this = _call_super(this, Rings);
        _this._links = [];
        _this._linkSize = constant(1);
        _this._linkSizeMin = 1;
        _this._linkSizeScale = "sqrt";
        _this._noDataMessage = false;
        _this._nodes = [];
        _this._on.mouseenter = function() {};
        _this._on["mouseleave.shape"] = function() {
            _this.hover(false);
        };
        var defaultMouseMove = _this._on["mousemove.shape"];
        _this._on["mousemove.shape"] = function(d, i, x, event) {
            defaultMouseMove(d, i, x, event);
            if (_this._focus && _this._focus === d.id) {
                _this.hover(false);
                _this._on.mouseenter.bind(_this)(d, i, x, event);
                _this._focus = undefined;
            } else {
                var id = _this._nodeGroupBy && _this._nodeGroupBy[_this._drawDepth](d, i) ? _this._nodeGroupBy[_this._drawDepth](d, i) : _this._id(d, i), links = _this._linkLookup[id], node = _this._nodeLookup[id];
                var filterIds = [
                    node.id
                ];
                var xDomain = [
                    node.x - node.r,
                    node.x + node.r
                ], yDomain = [
                    node.y - node.r,
                    node.y + node.r
                ];
                links.forEach(function(l) {
                    filterIds.push(l.id);
                    if (l.x - l.r < xDomain[0]) xDomain[0] = l.x - l.r;
                    if (l.x + l.r > xDomain[1]) xDomain[1] = l.x + l.r;
                    if (l.y - l.r < yDomain[0]) yDomain[0] = l.y - l.r;
                    if (l.y + l.r > yDomain[1]) yDomain[1] = l.y + l.r;
                });
                _this.hover(function(h, x) {
                    if (h.source && h.target) return h.source.id === node.id || h.target.id === node.id;
                    else return filterIds.includes(_this._ids(h, x)[_this._drawDepth]);
                });
            }
        };
        _this._on["click.shape"] = function(d) {
            _this._center = d.id;
            // Need to resets margins and padding because we are
            // skipping over the default render method and using
            // _draw directly.
            _this._margin = {
                bottom: 0,
                left: 0,
                right: 0,
                top: 0
            };
            _this._padding = {
                bottom: 0,
                left: 0,
                right: 0,
                top: 0
            };
            _this._draw();
        };
        _this._sizeMin = 5;
        _this._sizeScale = "sqrt";
        _this._shape = constant("Circle");
        _this._shapeConfig = assign(_this._shapeConfig, {
            ariaLabel: function ariaLabel(d, i) {
                var validSize = _this._size ? ", ".concat(_this._size(d, i)) : "";
                return "".concat(_this._drawLabel(d, i)).concat(validSize, ".");
            },
            labelConfig: {
                duration: 0,
                fontMin: 1,
                fontResize: true,
                labelPadding: 0,
                textAnchor: "middle",
                verticalAlign: "middle"
            },
            Path: {
                fill: "none",
                label: false,
                stroke: "#eee",
                strokeWidth: 1
            }
        });
        return _this;
    }
    _create_class(Rings, [
        {
            /**
      Extends the draw behavior of the abstract Viz class.
      @private
*/ key: "_draw",
            value: function _draw(callback) {
                var _this = this;
                _get(_get_prototype_of(Rings.prototype), "_draw", this).call(this, callback);
                var data = this._filteredData.reduce(function(obj, d, i) {
                    obj[_this._id(d, i)] = d;
                    return obj;
                }, {});
                var nodes = this._nodes;
                if (!this._nodes.length && this._links.length) {
                    var nodeIds = Array.from(new Set(this._links.reduce(function(ids, link) {
                        return ids.concat([
                            link.source,
                            link.target
                        ]);
                    }, [])));
                    nodes = nodeIds.map(function(node) {
                        return (typeof node === "undefined" ? "undefined" : _type_of(node)) === "object" ? node : {
                            id: node
                        };
                    });
                }
                nodes = nodes.reduce(function(obj, d, i) {
                    obj[_this._nodeGroupBy ? _this._nodeGroupBy[_this._drawDepth](d, i) : _this._id(d, i)] = d;
                    return obj;
                }, {});
                nodes = Array.from(new Set(Object.keys(data).concat(Object.keys(nodes)))).map(function(id, i) {
                    var d = data[id], n = nodes[id];
                    if (n === undefined) return false;
                    return {
                        __d3plus__: true,
                        data: d || n,
                        i: i,
                        id: id,
                        node: n,
                        shape: d !== undefined && _this._shape(d) !== undefined ? _this._shape(d) : _this._shape(n)
                    };
                }).filter(function(n) {
                    return n;
                });
                var nodeLookup = this._nodeLookup = nodes.reduce(function(obj, d) {
                    obj[d.id] = d;
                    return obj;
                }, {});
                var links = this._links.map(function(link) {
                    var check = [
                        "source",
                        "target"
                    ];
                    var edge = check.reduce(function(result, check) {
                        result[check] = typeof link[check] === "number" ? nodes[link[check]] : nodeLookup[link[check].id || link[check]];
                        return result;
                    }, {});
                    edge.size = _this._linkSize(link);
                    return edge;
                });
                var linkMap = links.reduce(function(map, link) {
                    if (!map[link.source.id]) {
                        map[link.source.id] = [];
                    }
                    map[link.source.id].push(link);
                    if (!map[link.target.id]) {
                        map[link.target.id] = [];
                    }
                    map[link.target.id].push(link);
                    return map;
                }, {});
                var duration = this._duration, height = this._height - this._margin.top - this._margin.bottom, transform = "translate(".concat(this._margin.left, ", ").concat(this._margin.top, ")"), width = this._width - this._margin.left - this._margin.right;
                var edges = [], radius = (min([
                    height,
                    width
                ]) || 0) / 2, ringWidth = radius / 3;
                var primaryRing = ringWidth, secondaryRing = ringWidth * 2;
                var center = nodeLookup[this._center];
                center.x = width / 2;
                center.y = height / 2;
                center.r = this._sizeMin ? max([
                    this._sizeMin,
                    primaryRing * 0.65
                ]) : this._sizeMax ? min([
                    this._sizeMax,
                    primaryRing * 0.65
                ]) : primaryRing * 0.65;
                var claimed = [
                    center
                ], primaries = [];
                linkMap[this._center].forEach(function(edge) {
                    var node = edge.source.id === _this._center ? edge.target : edge.source;
                    node.edges = linkMap[node.id].filter(function(link) {
                        return link.source.id !== _this._center || link.target.id !== _this._center;
                    });
                    node.edge = edge;
                    claimed.push(node);
                    primaries.push(node);
                });
                primaries.sort(function(a, b) {
                    return a.edges.length - b.edges.length;
                });
                var secondaries = [];
                var totalEndNodes = 0;
                primaries.forEach(function(p) {
                    var primaryId = p.id;
                    p.edges = p.edges.filter(function(edge) {
                        return !claimed.includes(edge.source) && edge.target.id === primaryId || !claimed.includes(edge.target) && edge.source.id === primaryId;
                    });
                    totalEndNodes += p.edges.length || 1;
                    p.edges.forEach(function(edge) {
                        var source = edge.source, target = edge.target;
                        var claim = target.id === primaryId ? source : target;
                        claimed.push(claim);
                    });
                });
                var tau = Math.PI * 2;
                var offset = 0;
                primaries.forEach(function(p, i) {
                    var children = p.edges.length || 1;
                    var space = tau / totalEndNodes * children;
                    if (i === 0) {
                        offset -= space / 2;
                    }
                    var angle = offset + space / 2 - tau / 4;
                    p.radians = angle;
                    p.x = width / 2 + primaryRing * Math.cos(angle);
                    p.y = height / 2 + primaryRing * Math.sin(angle);
                    offset += space;
                    p.edges.forEach(function(edge, i) {
                        var node = edge.source.id === p.id ? edge.target : edge.source;
                        var s = tau / totalEndNodes;
                        var a = angle - s * children / 2 + s / 2 + s * i;
                        node.radians = a;
                        node.x = width / 2 + secondaryRing * Math.cos(a);
                        node.y = height / 2 + secondaryRing * Math.sin(a);
                        secondaries.push(node);
                    });
                });
                var primaryDistance = ringWidth / 2;
                var secondaryDistance = ringWidth / 4;
                var primaryMax = primaryDistance / 2 - 4;
                if (primaryDistance / 2 - 4 < 8) {
                    primaryMax = min([
                        primaryDistance / 2,
                        8
                    ]) || 0;
                }
                var secondaryMax = secondaryDistance / 2 - 4;
                if (secondaryDistance / 2 - 4 < 4) {
                    secondaryMax = min([
                        secondaryDistance / 2,
                        4
                    ]) || 0;
                }
                if (secondaryMax > ringWidth / 10) {
                    secondaryMax = ringWidth / 10;
                }
                if (secondaryMax > primaryMax && secondaryMax > 10) {
                    secondaryMax = primaryMax * 0.75;
                }
                if (primaryMax > secondaryMax * 1.5) {
                    primaryMax = secondaryMax * 1.5;
                }
                primaryMax = Math.floor(primaryMax);
                secondaryMax = Math.floor(secondaryMax);
                var radiusFn;
                if (this._size) {
                    var domain = extent(data, function(d) {
                        return d.size;
                    });
                    if (domain[0] === domain[1]) {
                        domain[0] = 0;
                    }
                    radiusFn = scales.scaleLinear().domain(domain).rangeRound([
                        3,
                        min([
                            primaryMax,
                            secondaryMax
                        ])
                    ]);
                    var val = center.size;
                    center.r = radiusFn(val);
                } else {
                    radiusFn = scales.scaleLinear().domain([
                        1,
                        2
                    ]).rangeRound([
                        primaryMax,
                        secondaryMax
                    ]);
                }
                secondaries.forEach(function(s) {
                    s.ring = 2;
                    var val = _this._size ? s.size : 2;
                    s.r = _this._sizeMin ? max([
                        _this._sizeMin,
                        radiusFn(val)
                    ]) : _this._sizeMax ? min([
                        _this._sizeMax,
                        radiusFn(val)
                    ]) : radiusFn(val);
                });
                primaries.forEach(function(p) {
                    p.ring = 1;
                    var val = _this._size ? p.size : 1;
                    p.r = _this._sizeMin ? max([
                        _this._sizeMin,
                        radiusFn(val)
                    ]) : _this._sizeMax ? min([
                        _this._sizeMax,
                        radiusFn(val)
                    ]) : radiusFn(val);
                });
                nodes = [
                    center
                ].concat(primaries).concat(secondaries);
                primaries.forEach(function(p) {
                    var check = [
                        "source",
                        "target"
                    ];
                    var edge = p.edge;
                    check.forEach(function(node) {
                        edge[node] = nodes.find(function(n) {
                            return n.id === edge[node].id;
                        });
                    });
                    edges.push(edge);
                    linkMap[p.id].forEach(function(edge) {
                        var node = edge.source.id === p.id ? edge.target : edge.source;
                        if (node.id !== center.id) {
                            var target = secondaries.find(function(s) {
                                return s.id === node.id;
                            });
                            if (!target) {
                                target = primaries.find(function(s) {
                                    return s.id === node.id;
                                });
                            }
                            if (target) {
                                edge.spline = true;
                                var centerX = width / 2;
                                var centerY = height / 2;
                                var middleRing = primaryRing + (secondaryRing - primaryRing) * 0.5;
                                var check = [
                                    "source",
                                    "target"
                                ];
                                check.forEach(function(node, i) {
                                    edge["".concat(node, "X")] = edge[node].x + Math.cos(edge[node].ring === 2 ? edge[node].radians + Math.PI : edge[node].radians) * edge[node].r;
                                    edge["".concat(node, "Y")] = edge[node].y + Math.sin(edge[node].ring === 2 ? edge[node].radians + Math.PI : edge[node].radians) * edge[node].r;
                                    edge["".concat(node, "BisectX")] = centerX + middleRing * Math.cos(edge[node].radians);
                                    edge["".concat(node, "BisectY")] = centerY + middleRing * Math.sin(edge[node].radians);
                                    edge[node] = nodes.find(function(n) {
                                        return n.id === edge[node].id;
                                    });
                                    if (edge[node].edges === undefined) edge[node].edges = {};
                                    var oppId = i === 0 ? edge.target.id : edge.source.id;
                                    if (edge[node].id === p.id) {
                                        edge[node].edges[oppId] = {
                                            angle: p.radians + Math.PI,
                                            radius: ringWidth / 2
                                        };
                                    } else {
                                        edge[node].edges[oppId] = {
                                            angle: target.radians,
                                            radius: ringWidth / 2
                                        };
                                    }
                                });
                                edges.push(edge);
                            }
                        }
                    });
                });
                nodes.forEach(function(node) {
                    if (node.id !== _this._center) {
                        var fontSize = _this._shapeConfig.labelConfig.fontSize && _this._shapeConfig.labelConfig.fontSize(node) || 11;
                        var lineHeight = fontSize * 1.4;
                        var height = lineHeight * 2;
                        var padding = 5;
                        var width = ringWidth - node.r;
                        var angle = node.radians * (180 / Math.PI);
                        var x = node.r + padding;
                        var textAnchor = "start";
                        if (angle < -90 || angle > 90) {
                            x = -node.r - width - padding;
                            textAnchor = "end";
                            angle += 180;
                        }
                        node.labelBounds = {
                            x: x,
                            y: -lineHeight / 2,
                            width: width,
                            height: height
                        };
                        node.rotate = angle;
                        node.textAnchor = textAnchor;
                    } else {
                        node.labelBounds = {
                            x: -primaryRing / 2,
                            y: -primaryRing / 2,
                            width: primaryRing,
                            height: primaryRing
                        };
                    }
                });
                this._linkLookup = links.reduce(function(obj, d) {
                    if (!obj[d.source.id]) obj[d.source.id] = [];
                    obj[d.source.id].push(d.target);
                    if (!obj[d.target.id]) obj[d.target.id] = [];
                    obj[d.target.id].push(d.source);
                    return obj;
                }, {});
                var strokeExtent = extent(links, function(d) {
                    return d.size;
                });
                if (strokeExtent[0] !== strokeExtent[1]) {
                    var radius1 = min(nodes, function(d) {
                        return d.r;
                    });
                    var strokeScale = scales["scale".concat(this._linkSizeScale.charAt(0).toUpperCase()).concat(this._linkSizeScale.slice(1))]().domain(strokeExtent).range([
                        this._linkSizeMin,
                        radius1
                    ]);
                    links.forEach(function(link) {
                        link.size = strokeScale(link.size);
                    });
                }
                var linkConfig = configPrep.bind(this)(this._shapeConfig, "edge", "Path");
                delete linkConfig.on;
                this._shapes.push(new shapes.Path().config(linkConfig).strokeWidth(function(d) {
                    return d.size;
                }).id(function(d) {
                    return "".concat(d.source.id, "_").concat(d.target.id);
                }).d(function(d) {
                    return d.spline ? "M".concat(d.sourceX, ",").concat(d.sourceY, "C").concat(d.sourceBisectX, ",").concat(d.sourceBisectY, " ").concat(d.targetBisectX, ",").concat(d.targetBisectY, " ").concat(d.targetX, ",").concat(d.targetY) : "M".concat(d.source.x, ",").concat(d.source.y, " ").concat(d.target.x, ",").concat(d.target.y);
                }).data(edges).select(elem("g.d3plus-rings-links", {
                    parent: this._select,
                    duration: duration,
                    enter: {
                        transform: transform
                    },
                    update: {
                        transform: transform
                    }
                }).node()).render());
                var that = this;
                var shapeConfig = {
                    label: function label(d) {
                        return nodes.length <= _this._dataCutoff || _this._hover && _this._hover(d) || _this._active && _this._active(d) ? _this._drawLabel(d.data || d.node, d.i) : false;
                    },
                    labelBounds: function labelBounds(d) {
                        return d.labelBounds;
                    },
                    labelConfig: {
                        fontColor: function fontColor(d) {
                            return d.id === _this._center ? configPrep.bind(that)(that._shapeConfig, "shape", d.key).labelConfig.fontColor(d) : colorContrast(_this._select ? backgroundColor(_this._select.node()) : "rgb(255, 255, 255)");
                        },
                        fontResize: function fontResize(d) {
                            return d.id === _this._center;
                        },
                        padding: 0,
                        textAnchor: function textAnchor(d) {
                            return nodeLookup[d.id].textAnchor || configPrep.bind(that)(that._shapeConfig, "shape", d.key).labelConfig.textAnchor;
                        },
                        verticalAlign: function verticalAlign(d) {
                            return d.id === _this._center ? "middle" : "top";
                        }
                    },
                    rotate: function rotate(d) {
                        return nodeLookup[d.id].rotate || 0;
                    },
                    select: elem("g.d3plus-rings-nodes", {
                        parent: this._select,
                        duration: duration,
                        enter: {
                            transform: transform
                        },
                        update: {
                            transform: transform
                        }
                    }).node()
                };
                groups(nodes, function(d) {
                    return d.shape;
                }).forEach(function(param) {
                    var _param = _sliced_to_array(param, 2), key = _param[0], values = _param[1];
                    _this._shapes.push(new shapes[key]().config(configPrep.bind(_this)(_this._shapeConfig, "shape", key)).config(shapeConfig).data(values).render());
                });
                return this;
            }
        },
        {
            /**
   The center node, specified by id.
*/ key: "center",
            value: function center(_) {
                return arguments.length ? (this._center = _, this) : this._center;
            }
        },
        {
            /**
      The hover callback function for highlighting shapes on mouseover.
*/ key: "hover",
            value: function hover(_) {
                this._hover = _;
                this._shapes.forEach(function(s) {
                    return s.hover(_);
                });
                if (this._legend) this._legendClass.hover(_);
                return this;
            }
        },
        {
            /**
      A predefined *Array* of edges that connect each object passed to the [node](#Rings.node) method. The `source` and `target` keys in each link need to map to the nodes in one of three ways:
1. The index of the node in the nodes array (as in [this](http://d3plus.org/examples/d3plus-network/getting-started/) example).
2. The actual node *Object* itself.
3. A *String* value matching the `id` of the node.

The value passed should either be an *Array* of data or a *String* representing a filepath or URL to be loaded. An optional formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final links *Array*.
    @param f Array of link objects or a URL to load links from.
*/ key: "links",
            value: function links(_, f) {
                if (arguments.length) {
                    addToQueue.bind(this)(_, f, "links");
                    return this;
                }
                return this._links;
            }
        },
        {
            /**
      Defines the thickness of the links connecting each node. The value provided can be either a pixel Number to be used for all links, or an accessor function that returns a specific data value to be used in an automatically calculated linear scale.
*/ key: "linkSize",
            value: function linkSize(_) {
                return arguments.length ? (this._linkSize = typeof _ === "function" ? _ : constant(_), this) : this._linkSize;
            }
        },
        {
            /**
      Defines the minimum pixel stroke width used in link sizing.
*/ key: "linkSizeMin",
            value: function linkSizeMin(_) {
                return arguments.length ? (this._linkSizeMin = _, this) : this._linkSizeMin;
            }
        },
        {
            /**
      The type of [continuous d3-scale](https://github.com/d3/d3-scale#continuous-scales) used when calculating the pixel size of links in the network.
*/ key: "linkSizeScale",
            value: function linkSizeScale(_) {
                return arguments.length ? (this._linkSizeScale = _, this) : this._linkSizeScale;
            }
        },
        {
            /**
      The node group accessor(s). This method overrides the default .groupBy() function from being used with the data passed to .nodes().
*/ key: "nodeGroupBy",
            value: function nodeGroupBy(_) {
                var _this = this;
                if (!arguments.length) return this._nodeGroupBy;
                if (!_instanceof(_, Array)) _ = [
                    _
                ];
                return this._nodeGroupBy = _.map(function(k) {
                    if (typeof k === "function") return k;
                    else {
                        if (!_this._aggs[k]) {
                            _this._aggs[k] = function(a, c) {
                                var v = Array.from(new Set(a.map(c)));
                                return v.length === 1 ? v[0] : v;
                            };
                        }
                        return accessor(k);
                    }
                }), this;
            }
        },
        {
            /**
      The list of nodes to be used for drawing the rings network. The value passed should either be an *Array* of data or a *String* representing a filepath or URL to be loaded.

Additionally, a custom formatting function can be passed as a second argument to this method. This custom function will be passed the data that has been loaded, as long as there are no errors. This function should return the final node *Array*.
    @param f Array of node objects or a URL to load nodes from.
*/ key: "nodes",
            value: function nodes(_, f) {
                if (arguments.length) {
                    addToQueue.bind(this)(_, f, "nodes");
                    return this;
                }
                return this._nodes;
            }
        },
        {
            /**
      The size accessor for each node in the rings layout.
*/ key: "size",
            value: function size(_) {
                return arguments.length ? (this._size = typeof _ === "function" || !_ ? _ : accessor(_), this) : this._size;
            }
        },
        {
            /**
      The size scale maximum. By default, the maximum size is determined by half the distance of the two closest nodes.
*/ key: "sizeMax",
            value: function sizeMax(_) {
                return arguments.length ? (this._sizeMax = _, this) : this._sizeMax;
            }
        },
        {
            /**
      The size scale minimum.
*/ key: "sizeMin",
            value: function sizeMin(_) {
                return arguments.length ? (this._sizeMin = _, this) : this._sizeMin;
            }
        },
        {
            /**
      The size scale.
*/ key: "sizeScale",
            value: function sizeScale(_) {
                return arguments.length ? (this._sizeScale = _, this) : this._sizeScale;
            }
        }
    ]);
    return Rings;
}(Viz);
/**
    Creates a ring visualization based on a defined set of nodes and edges. [Click here](http://d3plus.org/examples/d3plus-network/simple-rings/) for help getting started using the Rings class.
*/ export { Rings as default };
