igniteui-react-core
Version:
Ignite UI React Core.
1,548 lines • 61 kB
JavaScript
/*
THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE:
https://www.infragistics.com/legal/license/igultimate-la
https://www.infragistics.com/legal/license/igultimate-eula
GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company.
*/
import { __extends, __values } from "tslib";
import { Base, fromEnum, runOn, Point_$type, markType } from "./type";
import { List$1 } from "./List$1";
import { LabelCollisionPlacementPositions_$type } from "./LabelCollisionPlacementPositions";
import { QuadTree } from "./QuadTree";
import { Rect } from "./Rect";
import { LinkedList$1 } from "./LinkedList$1";
import { LabelCollisionInfo } from "./LabelCollisionInfo";
import { TestRandomness } from "./TestRandomness";
import { Random } from "./Random";
import { DefaultRandomnessSource } from "./DefaultRandomnessSource";
import { QuadTreeBoundingBox } from "./QuadTreeBoundingBox";
import { HashSet$1 } from "./HashSet$1";
import { MathUtil } from "./MathUtil";
import { GeometryUtil } from "./GeometryUtil";
import { truncate, isNaN_ } from "./number";
/**
* @hidden
*/
var LabelCollisionManager = /** @class */ /*@__PURE__*/ (function (_super) {
__extends(LabelCollisionManager, _super);
function LabelCollisionManager(a, b, c, d, e, f, g, h, i, j, k) {
var _this = _super.call(this) || this;
_this.r = false;
_this.a = new Array(8);
_this.an = null;
_this.labelsMoved = null;
_this.p = null;
_this.k = null;
_this.j = 0;
_this.e = null;
_this.am = null;
_this.a0 = 0;
_this.a8 = 0;
_this.a7 = 0;
_this.b0 = null;
_this.a2 = 0;
_this.az = 0;
_this.v = false;
_this.ak = new LinkedList$1(LabelCollisionInfo.$);
_this.a4 = 0;
_this.al = new List$1(LabelCollisionInfo.$, 0);
_this.t = false;
_this.s = false;
_this.a6 = 0;
_this.a3 = 0;
_this.ao = 0;
_this.ap = 0;
_this.f = null;
_this.a5 = 0;
_this.u = false;
_this.q = false;
_this.b = null;
_this.bd = null;
_this.bb = null;
_this.aq = 0;
_this.ar = 0;
_this.f = _this.g();
_this.r = k != null;
_this.b0 = c;
_this.a2 = a;
_this.az = b;
_this.k = new QuadTree(a, b, 8, 8);
_this.j = f;
_this.e = d;
_this.am = new List$1(LabelCollisionPlacementPositions_$type, 0);
_this.am.add(0);
_this.am.add(5);
_this.am.add(7);
_this.am.add(2);
_this.am.add(3);
_this.am.add(6);
_this.am.add(1);
_this.am.add(4);
var l = 0;
for (var m = 0; m < g.length; m++) {
if (_this.am.contains(g[m])) {
_this.am.remove(g[m]);
_this.am.insert(l, g[m]);
l++;
}
}
if (k != null) {
_this.an = new List$1(LabelCollisionPlacementPositions_$type, 0);
for (var n = 0; n < _this.a.length; n++) {
_this.a[n] = false;
}
for (var o = 0; o < k.length; o++) {
_this.a[k[o]] = true;
_this.an.add(k[o]);
}
_this.b = k;
}
else {
_this.an = new List$1(LabelCollisionPlacementPositions_$type, 0);
_this.an.add(0);
_this.an.add(5);
_this.an.add(7);
_this.an.add(2);
_this.an.add(3);
_this.an.add(6);
_this.an.add(1);
_this.an.add(4);
if (_this.ah(_this.j)) {
_this.an = new List$1(LabelCollisionPlacementPositions_$type, 0);
_this.an.add(10);
_this.an.add(11);
_this.an.add(8);
_this.an.add(9);
}
var p = 0;
for (var q = 0; q < g.length; q++) {
if (_this.an.contains(g[q])) {
_this.an.remove(g[q]);
_this.an.insert(p, g[q]);
p++;
}
}
}
_this.a0 = e;
_this.a8 = h;
_this.a7 = i;
_this.q = j;
return _this;
}
LabelCollisionManager.prototype.h = function () {
if (TestRandomness.instance.testRandomnessSource != null) {
return TestRandomness.instance.testRandomnessSource;
}
return new DefaultRandomnessSource(1, LabelCollisionManager.bc);
};
LabelCollisionManager.prototype.g = function () {
var a = this.h();
return a.getGenerator("LabelCollision");
};
LabelCollisionManager.prototype.o = function (a, b, c, d, e) {
var f = 0;
var g = 0;
switch (b) {
case 0:
f = a.s;
g = (((a.t - a.q) - a.o) - this.a0 - d);
break;
case 4:
f = (((a.s - a.r) - a.p) - this.a0) - c;
g = (((a.t - a.q) - a.o) - this.a0) - d;
break;
case 5:
f = (((a.s + a.r) + a.p) + this.a0) + c;
g = (((a.t - a.q) - a.o) - this.a0) - d;
break;
case 1:
f = (((a.s - a.r) - a.p) - this.a0) - c;
g = a.t;
break;
case 2:
f = (((a.s + a.r) + a.p) + this.a0) + c;
g = a.t;
break;
case 3:
f = a.s;
g = (((a.t + a.q) + a.o) + this.a0) + d;
break;
case 6:
f = (((a.s - a.r) - a.p) - this.a0) - c;
g = (((a.t + a.q) + a.o) + this.a0) + d;
break;
case 7:
f = (((a.s + a.r) + a.p) + this.a0) + c;
g = (((a.t + a.q) + a.o) + this.a0) - d;
break;
case 8:
{
var h = this.l(a);
if (h != null) {
a.b = 8;
f = h.d;
g = h.e;
}
else {
return null;
}
break;
}
case 9:
{
var i = this.m(a);
if (i != null) {
a.b = 9;
f = i.d;
g = i.e;
}
else {
return null;
}
break;
}
case 10:
{
var j = this.n(a);
if (j != null) {
a.b = 10;
f = j.d;
g = j.e;
}
else {
return null;
}
break;
}
case 11:
{
var k = this.l(a);
if (k != null) {
a.b = 8;
f = k.d;
g = k.e;
}
else {
var l = this.m(a);
if (l != null) {
f = l.d;
g = l.e;
}
else {
var m = this.m(a);
if (m != null) {
f = m.d;
g = m.e;
}
else {
return null;
}
}
}
break;
}
}
var n = new QuadTreeBoundingBox();
n.d = f;
n.e = g;
n.g = a.p;
n.f = a.o;
n.i = a;
if (this.ab(n) && !e) {
return null;
}
return n;
};
LabelCollisionManager.prototype.ab = function (a) {
var b = a.d - a.g;
var c = a.d + a.g;
var d = a.e - a.f;
var e = a.e + a.f;
var f = this.b0;
if (b < f.left || c > f.right || d < f.top || e > f.bottom) {
return true;
}
return false;
};
LabelCollisionManager.prototype.as = function (a) {
var b = a.d - a.g;
var c = a.d + a.g;
var d = a.e - a.f;
var e = a.e + a.f;
var f = this.b0;
if (b < f.left) {
return f.left - b;
}
return 0;
};
LabelCollisionManager.prototype.at = function (a) {
var b = a.d - a.g;
var c = a.d + a.g;
var d = a.e - a.f;
var e = a.e + a.f;
var f = this.b0;
if (c > f.right) {
return c - f.right;
}
return 0;
};
LabelCollisionManager.prototype.be = function (a) {
this.a4++;
this.ak.f(a);
a.i = this.ak.d;
if (a.e == null) {
a.e = new QuadTreeBoundingBox();
a.e.d = a.s;
a.e.e = a.t;
a.e.g = a.r;
a.e.f = a.q;
a.e.i = a;
this.k.c(a.e);
}
if (a.a != null) {
if (a.d == null) {
a.d = QuadTreeBoundingBox.a(a.a.boundingBox);
a.d.i = a;
this.k.c(a.d);
}
}
};
LabelCollisionManager.prototype.br = function (a) {
if (a.e != null) {
this.k.d(a.e);
a.e = null;
}
if (a.d != null) {
this.k.d(a.d);
a.d = null;
}
if (a.c != null) {
this.k.d(a.c);
a.c = null;
}
if (a.i != null) {
this.ak.h(a.i);
a.i = null;
}
this.a4--;
};
LabelCollisionManager.prototype.bo = function (a) {
if (a.e != null && a.e.d == a.s && a.e.e == a.t) {
return;
}
if (a.e != null) {
this.k.d(a.e);
}
if (a.d != null) {
this.k.d(a.d);
a.d = null;
}
var b = NaN;
var c = NaN;
if (a.e == null) {
a.e = new QuadTreeBoundingBox();
a.e.i = a;
}
else {
if (a.c != null) {
b = a.c.d - a.e.d;
c = a.c.e - a.e.e;
}
}
a.e.d = a.s;
a.e.e = a.t;
a.e.g = a.r;
a.e.f = a.q;
this.k.c(a.e);
if (a.a != null) {
if (a.d == null) {
a.d = QuadTreeBoundingBox.a(a.a.boundingBox);
a.d.i = a;
this.k.c(a.d);
}
}
if (a.c != null) {
this.k.d(a.c);
if (a.b == 8 || a.b == 9 || a.b == 10) {
b = NaN;
}
if (!isNaN_(b)) {
a.c = new QuadTreeBoundingBox();
a.c.d = a.e.d + b;
a.c.e = a.e.e + c;
a.c.i = a;
a.c.g = a.p;
a.c.f = a.o;
a.k = a.c.d;
a.l = a.c.e;
this.k.c(a.c);
}
else {
a.c = this.o(a, a.b, 0, 0, true);
if (a.c != null) {
this.bm(a);
a.k = a.c.d;
a.l = a.c.e;
this.k.c(a.c);
}
else {
this.bl(a);
}
}
}
};
LabelCollisionManager.prototype.bn = function (a) {
this.k.d(a.c);
a.c.d = a.k;
a.c.e = a.l;
a.c.g = a.p;
a.c.f = a.o;
this.k.c(a.c);
};
LabelCollisionManager.prototype.bv = function () {
this.s = false;
{
var a = this.ak.c;
while (a != null) {
a.c.h = false;
if (a.c.c != null) {
this.k.d(a.c.c);
a.c.c = null;
if (a.c.j != null) {
a.c.j.clear();
}
}
a = a.a;
}
this.a5 = 0;
}
this.a3 = 0;
this.ao = 0.4;
this.ap = 0.4;
var b = truncate(Math.ceil((this.a7 / 150) * this.a8));
this.a6 = b;
this.bi();
};
LabelCollisionManager.prototype.bg = function () {
this.al.clear();
};
LabelCollisionManager.prototype.bf = function () {
this.s = true;
};
LabelCollisionManager.prototype.bk = function () {
this.t = false;
if (this.s) {
return;
}
this.bi();
};
LabelCollisionManager.prototype.bi = function () {
var e_1, _a;
this.al.clear();
this.bp(false);
if (this.j == 0) {
for (var a = 0; a < this.a8; a++) {
this.ap = this.ao * (this.a6 - this.a3) / this.a6;
this.bj();
this.a3++;
if (this.a3 > this.a6) {
if (this.p != null) {
this.p();
}
return;
}
}
if (this.labelsMoved != null) {
try {
for (var _b = __values(fromEnum(this.al)), _c = _b.next(); !_c.done; _c = _b.next()) {
var b = _c.value;
}
}
catch (e_1_1) {
e_1 = { error: e_1_1 };
}
finally {
try {
if (_c && !_c.done && (_a = _b.return))
_a.call(_b);
}
finally {
if (e_1)
throw e_1.error;
}
}
this.labelsMoved(this.al);
}
if (this.a5 > 0) {
if (!this.t) {
this.t = true;
this.e.executeDelayed(runOn(this, this.bk), 150);
}
}
else {
if (this.p != null) {
this.p();
}
}
}
else {
if (this.j == 2) {
var c = this.ak.c;
this.k.k();
while (c != null) {
var d = c.c;
if (d.c != null) {
this.k.d(d.c);
d.c = null;
d.f = false;
d.j = null;
}
c = c.a;
}
this.a5 = 0;
this.bp(true);
}
if (this.labelsMoved != null) {
this.labelsMoved(this.al);
}
}
};
LabelCollisionManager.prototype.bj = function () {
var a = truncate(Math.round((this.a4 - 1) * this.f.nextDouble()));
var b = 0;
var c = this.ak.c;
var d = this.ay(null);
var e = 30;
var f = 60;
while (c != null) {
var g = c.c;
var h = 0;
var i = 0;
if (this.q) {
h = this.f.nextDouble() * g.p * 2;
i = this.f.nextDouble() * g.o * 2;
}
if (b == a) {
var j = truncate(Math.round((this.an.count - 1) * this.f.nextDouble()));
while (this.an._inner[j] == g.b) {
j = truncate(Math.round((this.an.count - 1) * this.f.nextDouble()));
}
var k = g.c;
var l = this.o(g, this.an._inner[j], h, i, false);
var m = 0;
while (l == null) {
if (m >= e) {
h = 0;
i = 0;
}
if (m >= f) {
break;
}
j = truncate(Math.round((this.an.count - 1) * this.f.nextDouble()));
l = this.o(g, this.an._inner[j], h, i, false);
m++;
}
g.c = l;
if (k != null) {
this.k.d(k);
}
if (l != null) {
this.k.c(l);
var n = this.ay(g);
var o = d > n;
if (!o) {
var p = Math.exp(-(n - d) / this.ap);
if (this.f.nextDouble() < p) {
o = true;
}
}
if (!o && k != null) {
this.k.d(l);
this.k.c(k);
g.c = k;
if (!this.u) {
this.ay(g);
}
}
else {
g.b = this.an._inner[j];
g.k = g.c.d;
g.l = g.c.e;
this.al.add(g);
}
}
else {
if (!this.u) {
this.ay(g);
}
g.f = false;
this.al.add(g);
}
break;
}
b++;
c = c.a;
}
};
LabelCollisionManager.prototype.z = function (a, b) {
return this.aa(a, b);
};
LabelCollisionManager.prototype.aa = function (a, b) {
if (!a.c(b)) {
return false;
}
if (a.i == null) {
return true;
}
var c = a.i;
if (c.a == null) {
if (b.i != null) {
var d = b.i;
if (d.d == b) {
var e = d.a;
return e.e(a.j());
}
else {
return true;
}
}
}
var f = c.a;
if (c.d == a) {
return f.e(b.j());
}
if (b.i != null) {
var g = b.i;
if (g.d == b) {
if (this.ah(this.j)) {
return false;
}
var h = g.a;
return h.e(a.j());
}
else {
return true;
}
}
return true;
};
LabelCollisionManager.prototype.ay = function (a) {
if (this.u) {
var b = 0;
var c = this.ak.c;
while (c != null) {
var d = c.c;
var e = d.f;
d.f = false;
if (d.c != null) {
var f = this.k.e(d.c);
for (var g = 0; g < f.count; g++) {
var h = f._inner[g].l.c;
while (h != null) {
var i = h.c;
if (this.ai(i, d)) {
h = h.a;
continue;
}
if (this.z(d.c, i)) {
d.f = true;
b += d.c.h(i);
}
h = h.a;
}
}
if (d.f != e) {
this.al.add(d);
}
}
c = c.a;
}
return b;
}
else {
if (a != null) {
var j = new HashSet$1(LabelCollisionInfo.$, 0);
var k = new HashSet$1(LabelCollisionInfo.$, 0);
var l = new HashSet$1(LabelCollisionInfo.$, 0);
var m = new List$1(LabelCollisionInfo.$, 0);
if (a.j != null) {
for (var n = 0; n < a.j.count; n++) {
j.add_1(a.j._inner[n]);
k.add_1(a.j._inner[n]);
}
}
var o = a.f;
a.f = false;
if (a.c != null) {
var p = this.k.e(a.c);
for (var q = 0; q < p.count; q++) {
var r = p._inner[q].l.c;
while (r != null) {
var s = r.c;
if (this.ai(s, a)) {
r = r.a;
continue;
}
if (this.z(a.c, s) && !l.contains(s.i)) {
a.f = true;
l.add_1(s.i);
m.add(s.i);
}
r = r.a;
}
}
p = this.k.e(a.e);
for (var t = 0; t < p.count; t++) {
var u = p._inner[t].l.c;
while (u != null) {
var v = u.c;
if (this.ai(v, a)) {
u = u.a;
continue;
}
if (this.w(a.e, v)) {
u = u.a;
continue;
}
if (this.z(a.e, v) && !l.contains(v.i)) {
a.f = true;
l.add_1(v.i);
m.add(v.i);
}
u = u.a;
}
}
if (a.f != o) {
this.al.add(a);
}
if (a.j != null) {
for (var w = a.j.count - 1; w >= 0; w--) {
if (!l.contains(a.j._inner[w])) {
var x = a.j._inner[w];
var y = false;
if (x != a) {
y = x.j.remove(a);
}
else {
}
a.j.removeAt(w);
if (x.j.count == 0 && y) {
this.a5--;
}
var z = j.remove(x);
if (j.count == 0 && z) {
this.a5--;
}
}
}
}
for (var aa = 0; aa < m.count; aa++) {
var ab = m._inner[aa];
if (!j.contains(ab)) {
if (a.j == null) {
a.j = new List$1(LabelCollisionInfo.$, 0);
}
a.j.add(ab);
if (j.count == 0) {
this.a5++;
}
j.add_1(ab);
if (ab != a) {
if (ab.j == null) {
ab.j = new List$1(LabelCollisionInfo.$, 0);
}
if (ab.j.count == 0) {
this.a5++;
}
ab.j.add(a);
}
}
}
}
}
return this.a5;
}
};
LabelCollisionManager.prototype.w = function (a, b) {
if ((((a.i != null) && a.i.e == a) || ((a.i != null) && a.i.d == a)) && (((a.i != null) && a.i.e == b) || ((a.i != null) && a.i.d == b))) {
return true;
}
return false;
};
Object.defineProperty(LabelCollisionManager.prototype, "a9", {
get: function () {
return this.a5;
},
enumerable: false,
configurable: true
});
LabelCollisionManager.prototype.bs = function (a, b, c) {
this.b0 = c;
var d = new QuadTree(a, b, this.k.i, this.k.f);
var e = this.ak.c;
while (e != null) {
d.c(e.c.e);
if (e.c.d != null) {
d.c(e.c.d);
}
if (e.c.c != null) {
d.c(e.c.c);
}
e = e.a;
}
this.k = d;
this.a2 = a;
this.az = b;
};
LabelCollisionManager.prototype.af = function () {
var a = this.ak.c;
while (a != null) {
a.c.f = false;
if (a.c.c != null) {
if (this.ab(a.c.c)) {
return true;
}
}
a = a.a;
}
return false;
};
LabelCollisionManager.prototype.x = function () {
var a = this.ak.c;
var b = this.an;
while (a != null) {
if (a.c.c != null) {
if (this.ab(a.c.c)) {
var c = a.c;
for (var d = 0; d < b.count; d++) {
var e = this.o(c, b._inner[d], 0, 0, false);
if (e != null) {
return true;
}
}
}
}
a = a.a;
}
return false;
};
LabelCollisionManager.prototype.ba = function () {
var a = this.ak.c;
while (a != null) {
a.c.f = false;
a = a.a;
}
a = this.ak.c;
while (a != null) {
var b = a.c.c;
var c = a.c.e;
var d = this.k.e(c);
for (var e = 0; e < d.count; e++) {
var f = d._inner[e].l.c;
while (f != null) {
var g = f.c;
if (this.w(c, g)) {
f = f.a;
continue;
}
if (this.z(c, g)) {
var h = f.c.i;
if (!this.ai(f.c, a.c)) {
h.f = true;
a.c.f = true;
}
}
f = f.a;
}
}
if (b == null) {
return -1;
}
d = this.k.e(b);
for (var i = 0; i < d.count; i++) {
var j = d._inner[i].l.c;
while (j != null) {
var k = j.c;
if (this.z(b, k)) {
var l = j.c.i;
if (!this.ai(j.c, a.c)) {
l.f = true;
a.c.f = true;
}
}
j = j.a;
}
}
a = a.a;
}
var m = 0;
var n = 1.7976931348623157E+308;
var o = -1.7976931348623157E+308;
var p = 1.7976931348623157E+308;
var q = -1.7976931348623157E+308;
a = this.ak.c;
while (a != null) {
if (a.c.f) {
m++;
if (!isNaN_(a.c.s) && !isNaN_(a.c.t)) {
n = Math.min(n, a.c.s);
o = Math.max(o, a.c.s);
p = Math.min(p, a.c.t);
q = Math.max(q, a.c.t);
}
}
a = a.a;
}
this.aq = Math.abs(o - n);
this.ar = Math.abs(q - p);
return m;
};
LabelCollisionManager.prototype.bp = function (a) {
var b = this.ak.c;
if (this.ah(this.j)) {
this.bq();
return;
}
while (b != null) {
var c = b.c;
if (c.c == null || a) {
var d = false;
if (a) {
var e = this.k.a(c.s, c.t, 1.5);
var f = this.c(e);
if (f != null) {
for (var g = 0; g < f.length; g++) {
var h = f[g];
var i = this.o(c, h, 0, 0, false);
if (i == null) {
continue;
}
var j = this.k.e(i);
d = true;
for (var k = 0; k < j.count; k++) {
var l = j._inner[k].l.c;
while (l != null) {
var m = l.c;
if (this.z(i, m)) {
d = false;
break;
}
l = l.a;
}
}
if (d) {
c.c = i;
c.b = h;
c.k = c.c.d;
c.l = c.c.e;
this.k.c(c.c);
this.al.add(c);
break;
}
}
}
}
if (!d) {
d = this.ad(c, false);
}
if (!d) {
if (c.c == null) {
this.ad(c, true);
}
}
}
b = b.a;
}
};
LabelCollisionManager.prototype.bq = function () {
var a = this.ak.c;
var b = new List$1(LabelCollisionInfo.$, 0);
var c = new List$1(LabelCollisionInfo.$, 0);
var d = new List$1(LabelCollisionInfo.$, 0);
var e = new List$1(LabelCollisionInfo.$, 0);
var f = this.j;
while (a != null) {
var g = a.c;
var h = g.a;
if (g.a == null || h.type != 2) {
g.h = true;
this.al.add(g);
a = a.a;
continue;
}
var i = h;
var j = this.bz(i);
var k = g;
var l = k.p + k.p;
var m = k.o + k.o;
var n = (i.startAngle + i.endAngle) / 2;
n = MathUtil.f(n);
var o = Rect.empty;
if (f == 3 || f == 7) {
var p = this.l(k);
if (p != null) {
if (this.y(p, g)) {
if (f == 7) {
this.bl(k);
a = a.a;
continue;
}
}
else {
k.b = 8;
this.bw(k, p);
d.add(k);
this.al.add(k);
this.k.c(p);
a = a.a;
continue;
}
}
if (k.h) {
a = a.a;
continue;
}
}
if (f == 5 || f == 3) {
var q = this.m(k);
if (q != null) {
if (this.y(q, g)) {
if (f == 5) {
this.bl(k);
a = a.a;
continue;
}
}
else {
k.b = 9;
e.add(k);
this.bw(k, q);
this.al.add(k);
this.k.c(q);
a = a.a;
continue;
}
}
if (k.h) {
a = a.a;
continue;
}
}
var r = this.n(k);
if (r != null) {
k.b = 10;
this.bw(k, r);
this.al.add(k);
this.k.c(k.c);
if (k.c.d < j.x) {
c.add(k);
}
else {
b.add(k);
}
}
else {
this.bl(k);
}
a = a.a;
}
this.bu(b);
this.bt(b);
this.bu(c);
this.bt(c);
};
LabelCollisionManager.prototype.bw = function (a, b) {
var c = new List$1(LabelCollisionInfo.$, 0);
var d = new HashSet$1(LabelCollisionInfo.$, 0);
if (!this.u) {
c = new List$1(LabelCollisionInfo.$, 0);
}
this.bh(a, b, c, d);
var e = a.e;
if (e == null) {
e = new QuadTreeBoundingBox();
e.i = a;
e.d = a.s;
e.e = a.t;
e.g = a.r;
e.f = a.q;
this.k.c(e);
a.e = e;
}
this.bh(a, e, c, d);
this.aj(a, c);
a.c = b;
a.k = a.c.d;
a.l = a.c.e;
};
LabelCollisionManager.prototype.bh = function (a, b, c, d) {
if (this.y(b, a)) {
var e = this.k.e(b);
for (var f = 0; f < e.count; f++) {
var g = e._inner[f].l.c;
while (g != null) {
var h = g.c;
if (this.z(b, h)) {
if (!this.u) {
if (!d.contains(h.i)) {
c.add(h.i);
d.add_1(h.i);
}
}
}
g = g.a;
}
}
}
};
LabelCollisionManager.prototype.n = function (a) {
var b = null;
var c = a.a;
if (c == null) {
return null;
}
var d = this.bz(c);
var e = a.p + a.p;
var f = a.o + a.o;
var g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
var h = GeometryUtil.u(d, g, c.radius + this.a0);
a.b = 10;
this.bm(a);
var i = LabelCollisionManager.av(d, c.radius, c, a);
var j = GeometryUtil.u(d, g, i);
var k = new Rect(0, j.x - e / 2, j.y - f / 2, e, f);
g = GeometryUtil.n(g);
if (g < 90 && g >= 0) {
k = new Rect(0, h.x, h.y, e, f);
}
else if (g < 180 && g >= 90) {
k = new Rect(0, h.x - e, h.y, e, f);
}
else if (g < 270 && g >= 180) {
k = new Rect(0, h.x - e, h.y - f, e, f);
}
else {
k = new Rect(0, h.x, h.y - f, e, f);
}
if (k.y < 0) {
k = new Rect(0, k.x, 0, k.width, k.height);
}
if (k.bottom > this.b0.bottom) {
k = new Rect(0, k.x, this.b0.bottom - k.height, k.width, k.height);
}
b = ((function () {
var $ret = new QuadTreeBoundingBox();
$ret.d = k.left + k.width / 2;
$ret.e = k.top + k.height / 2;
$ret.g = k.width / 2;
$ret.f = k.height / 2;
$ret.i = a;
return $ret;
})());
return b;
};
LabelCollisionManager.prototype.bm = function (a) {
if (a == null) {
return;
}
var b = !a.h;
if (b) {
return;
}
a.h = false;
this.al.add(a);
};
LabelCollisionManager.prototype.bl = function (a) {
if (a == null) {
return;
}
var b = !a.h;
if (!b) {
return;
}
a.h = true;
this.al.add(a);
};
LabelCollisionManager.prototype.m = function (a) {
var b = null;
var c = a.a;
if (c == null) {
return null;
}
var d = this.bz(c);
var e = a.p + a.p;
var f = a.o + a.o;
var g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
var h = LabelCollisionManager.av(d, c.radius, c, a);
var i = GeometryUtil.u(d, g, h);
var j = new Rect(0, i.x - e / 2, i.y - f / 2, e, f);
var k = this.ae(c, j, a, d);
if (k || this.j == 5) {
a.b = 9;
if (!k && this.j == 5) {
this.bl(a);
}
else {
b = ((function () {
var $ret = new QuadTreeBoundingBox();
$ret.d = j.left + j.width / 2;
$ret.e = j.top + j.height / 2;
$ret.g = j.width / 2;
$ret.f = j.height / 2;
$ret.i = a;
return $ret;
})());
this.bm(a);
return b;
}
}
return b;
};
LabelCollisionManager.prototype.l = function (a) {
var b = null;
var c = a.a;
if (c == null) {
return null;
}
var d = this.bz(c);
var e = a.p + a.p;
var f = a.o + a.o;
var g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
var h = c.innerRadius;
var i = GeometryUtil.u(d, g, c.radius - (c.radius - h) / 2);
var j = new Rect(0, i.x - a.p, i.y - a.o, e, f);
var k = this.ae(c, j, a, i);
if (k || this.j == 7) {
a.b = 8;
if (!k && this.j == 7) {
this.bl(a);
}
else {
this.bm(a);
b = ((function () {
var $ret = new QuadTreeBoundingBox();
$ret.d = j.left + j.width / 2;
$ret.e = j.top + j.height / 2;
$ret.g = j.width / 2;
$ret.f = j.height / 2;
$ret.i = a;
return $ret;
})());
return b;
}
}
return b;
};
LabelCollisionManager.av = function (a, b, c, d) {
var e = (c.startAngle + c.endAngle / 2);
e = MathUtil.f(e);
var f = e * Math.PI / 180;
var g = 1;
var h = GeometryUtil.u({ $type: Point_$type, x: 0, y: 0 }, e, g);
var i = LabelCollisionManager.by(c, d);
var j = Math.sqrt(i.x * i.x + i.y * i.y);
var k = { $type: Point_$type, x: i.x / j, y: i.y / j };
var l = LabelCollisionManager.aw(h, k);
var m = j / b;
var n = l * m;
var o = n;
var p = GeometryUtil.j({ $type: Point_$type, x: 0, y: 0 }, h);
var q = GeometryUtil.j({ $type: Point_$type, x: 0, y: 0 }, k);
if (q < p) {
o = -o;
}
var r = GeometryUtil.u(a, (f + o) * 180 / Math.PI, b);
var s = LabelCollisionManager.bx(c, d, r);
var t = Math.sqrt((s.x - a.x) * (s.x - a.x) + (s.y - a.y) * (s.y - a.y));
var u = t - 5;
return u;
};
LabelCollisionManager.bx = function (a, b, c) {
var d = (a.startAngle + a.endAngle / 2);
d = MathUtil.f(d);
var e = GeometryUtil.n(d);
var f = b.p;
var g = b.o;
if (e >= 0 && e <= 90) {
return { $type: Point_$type, x: c.x - f, y: c.y - g };
}
if (e >= 90 && e <= 180) {
return { $type: Point_$type, x: c.x + f, y: c.y - g };
}
if (e >= 180 && e <= 270) {
return { $type: Point_$type, x: c.x + f, y: c.y + g };
}
return { $type: Point_$type, x: c.x - f, y: c.y + g };
};
LabelCollisionManager.aw = function (a, b) {
var c = a.x * b.x + a.y * b.y;
var d = Math.sqrt(a.x * a.x + a.y * a.y);
var e = Math.sqrt(b.x * b.x + b.y * b.y);
var f = Math.acos(c / (d * e));
return f;
};
LabelCollisionManager.by = function (a, b) {
var c = (a.startAngle + a.endAngle / 2);
c = MathUtil.f(c);
var d = GeometryUtil.n(c);
var e = b.p;
var f = b.o;
if (d >= 0 && d <= 90) {
return { $type: Point_$type, x: e, y: f };
}
if (d >= 90 && d <= 180) {
return { $type: Point_$type, x: -e, y: f };
}
if (d >= 180 && d <= 270) {
return { $type: Point_$type, x: -e, y: -f };
}
return { $type: Point_$type, x: e, y: -f };
};
LabelCollisionManager.au = function (a, b, c, d) {
var e = MathUtil.g(a - b, c - d);
var f = Math.asin((c - d) / e) * 180 / Math.PI;
if (a < b) {
f = 180 - f;
}
if (a > b) {
f = 360 + f;
}
if (f == 360) {
f = 0;
}
return GeometryUtil.n(f);
};
LabelCollisionManager.prototype.bu = function (a) {
var b = new Array(a.count);
for (var c = 0; c < a.count; c++) {
var d = a._inner[c];
var e = d.a;
var f = this.bz(e);
var g = (e.startAngle + e.endAngle) / 2;
g = MathUtil.f(g);
var h = GeometryUtil.u(f, g, e.radius);
b[c] = h.y;
}
for (var i = 0; i < a.count; i++) {
for (var j = i + 1; j < a.count; j++) {
if (b[i] >= b[j]) {
var k = a._inner[i];
a._inner[i] = a._inner[j];
a._inner[j] = k;
var l = b[i];
b[i] = b[j];
b[j] = l;
}
}
}
};
LabelCollisionManager.prototype.bt = function (a) {
var e_2, _a, e_3, _b;
if (a.count == 0) {
return;
}
var b = this.b0.width;
var c = this.b0.height;
var d = a.count;
var e = a._inner[0].a;
var f = e.radius;
var g = this.bz(e);
var h = true;
var i = 0;
var j = Number.POSITIVE_INFINITY;
var k = Number.NEGATIVE_INFINITY;
i = this.ba();
var l = 0;
try {
for (var _c = __values(fromEnum(a)), _d = _c.next(); !_d.done; _d = _c.next()) {
var m = _d.value;
j = Math.min(j, m.o + m.o);
k = Math.max(k, m.o + m.o);
l += m.o + m.o;
}
}
catch (e_2_1) {
e_2 = { error: e_2_1 };
}
finally {
try {
if (_d && !_d.done && (_a = _c.return))
_a.call(_c);
}
finally {
if (e_2)
throw e_2.error;
}
}
if (l > c) {
h = false;
}
if (h && i > 0) {
for (var n = 0; n < d - 1; n++) {
var _loop_1 = function (o) {
var p = a._inner[n];
var q = a._inner[o];
if (p.c.c(q.c)) {
var r_1 = q.c;
var s = r_1.e - r_1.f;
var t = r_1.g + r_1.g;
var u = MathUtil.f(this_1.ax(q));
var v_1 = Math.min(p.c.e + p.c.f + 0.01, c - j);
var w = this_1.a0 + f;
var x = Math.abs(g.y - (s + j / 2));
var y = Math.sqrt(Math.abs(w * w - x * x));
var z = GeometryUtil.n(u);
if (z > 90 && z < 270) {
y = (t + y) * -1;
}
var aa_1 = g.x + y;
var ab = ((function () {
var $ret = new QuadTreeBoundingBox();
$ret.d = aa_1 + r_1.g;
$ret.e = v_1 + r_1.f;
$ret.g = r_1.g;
$ret.f = r_1.f;
$ret.i = q;
return $ret;
})());
if (q.c != null) {
this_1.k.d(q.c);
}
this_1.bw(q, ab);
this_1.k.c(q.c);
}
};
var this_1 = this;
for (var o = n + 1; o < d; o++) {
_loop_1(o);
}
}
for (var ac = d - 1; ac > 0; ac--) {
var _loop_2 = function (ad) {
var ae = a._inner[ac];
var af = a._inner[ad];
if (ae.c.c(af.c)) {
var ag_1 = af.c;
var ah = ag_1.e - ag_1.f;
var ai = ag_1.g + ag_1.g;
var aj_1 = Math.max((ae.c.e - ae.c.f) - j - 0.01, 0);
var ak = this_2.a0 + f;
var al = Math.abs(g.y - (ah + j / 2));
var am = Math.sqrt(Math.abs(ak * ak - al * al));
var an = GeometryUtil.n(MathUtil.f(this_2.ax(af)));
if (an > 90 && an < 270) {
am = (ai + am) * -1;
}
var ao_1 = g.x + am;
var ap = ((function () {
var $ret = new QuadTreeBoundingBox();
$ret.d = ao_1 + ag_1.g;
$ret.e = aj_1 + ag_1.f;
$ret.g = ag_1.g;
$ret.f = ag_1.f;
$ret.i = af;
return $ret;
})());
if (af.c != null) {
this_2.k.d(af.c);
}
this_2.bw(af, ap);
this_2.k.c(af.c);
}
};
var this_2 = this;
for (var ad = ac - 1; ad >= 0; ad--) {
_loop_2(ad);
}
}
}
try {
for (var _e = __values(fromEnum(a)), _f = _e.next(); !_f.done; _f = _e.next()) {
var aq = _f.value;
var ar = aq.c.j();
if (ar.left > b || ar.right < 0) {
this.bl(aq);
if (aq.c != null) {
this.k.d(aq.c);
}
this.aj(aq, null);
aq.c = null;
}
else if (ar.left < 0) {
if (!this.v) {
this.bl(aq);
if (aq.c != null) {
this.k.d(aq.c);
}
this.aj(aq, null);
aq.c = null;
}
}
else if (ar.right > b) {
if (!this.v) {
this.bl(aq);
if (aq.c != null) {
this.k.d(aq.c);
}
this.aj(aq, null);
aq.c = null;
}
}
}
}
catch (e_3_1) {
e_3 = { error: e_3_1 };
}
finally {
try {
if (_f && !_f.done && (_b = _e.return))
_b.call(_e);
}
finally {
if (e_3)
throw e_3.error;
}
}
};
LabelCollisionManager.prototype.ax = function (a) {
var b = a.a;
return (b.startAngle + b.endAngle) / 2;
};
LabelCollisionManager.a1 = function (a) {
var b = Math.round(a * Math.pow(10, 5)) / Math.pow(10, 5);
return b;
};
LabelCollisionManager.prototype.ag = function (a) {
return LabelCollisionManager.a1(MathUtil.f(Math.abs(a.endAngle - a.startAngle))) == 360;
};
LabelCollisionManager.prototype.ae = function (a, b, c, d) {
if (a == null) {
return false;
}
var e = this.bz(a);
var f = Math.min(a.startAngle, a.endAngle);
var g = Math.max(a.startAngle, a.endAngle);
f = MathUtil.f(f);
g = MathUtil.f(g);
var h = false;
var i = false;
var j = GeometryUtil.u(e, f, a.radius);
var k = GeometryUtil.u(e, g, a.radius);
f = LabelCollisionManager.au(j.x, e.x, j.y, e.y);
g = LabelCollisionManager.au(k.x, e.x, k.y, e.y);
if (this.ag(a)) {
i = true;
}
var l;
l = MathUtil.g(b.right - e.x, b.top - e.y);
if (l > a.radius) {
return false;
}
l = MathUtil.g(b.right - e.x, b.bottom - e.y);
if (l > a.radius) {
return false;
}
l = MathUtil.g(b.left - e.x, b.top - e