igniteui-react-core
Version:
Ignite UI React Core.
1,436 lines • 63.7 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 { 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
*/
export let LabelCollisionManager = /*@__PURE__*/ (() => {
class LabelCollisionManager extends Base {
constructor(a, b, c, d, e, f, g, h, i, j, k) {
super();
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);
let l = 0;
for (let 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 (let n = 0; n < this.a.length; n++) {
this.a[n] = false;
}
for (let 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);
}
let p = 0;
for (let 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;
}
h() {
if (TestRandomness.instance.testRandomnessSource != null) {
return TestRandomness.instance.testRandomnessSource;
}
return new DefaultRandomnessSource(1, LabelCollisionManager.bc);
}
g() {
let a = this.h();
return a.getGenerator("LabelCollision");
}
o(a, b, c, d, e) {
let f = 0;
let 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:
{
let h = this.l(a);
if (h != null) {
a.b = 8;
f = h.d;
g = h.e;
}
else {
return null;
}
break;
}
case 9:
{
let i = this.m(a);
if (i != null) {
a.b = 9;
f = i.d;
g = i.e;
}
else {
return null;
}
break;
}
case 10:
{
let j = this.n(a);
if (j != null) {
a.b = 10;
f = j.d;
g = j.e;
}
else {
return null;
}
break;
}
case 11:
{
let k = this.l(a);
if (k != null) {
a.b = 8;
f = k.d;
g = k.e;
}
else {
let l = this.m(a);
if (l != null) {
f = l.d;
g = l.e;
}
else {
let m = this.m(a);
if (m != null) {
f = m.d;
g = m.e;
}
else {
return null;
}
}
}
break;
}
}
let 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;
}
ab(a) {
let b = a.d - a.g;
let c = a.d + a.g;
let d = a.e - a.f;
let e = a.e + a.f;
let f = this.b0;
if (b < f.left || c > f.right || d < f.top || e > f.bottom) {
return true;
}
return false;
}
as(a) {
let b = a.d - a.g;
let c = a.d + a.g;
let d = a.e - a.f;
let e = a.e + a.f;
let f = this.b0;
if (b < f.left) {
return f.left - b;
}
return 0;
}
at(a) {
let b = a.d - a.g;
let c = a.d + a.g;
let d = a.e - a.f;
let e = a.e + a.f;
let f = this.b0;
if (c > f.right) {
return c - f.right;
}
return 0;
}
be(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);
}
}
}
br(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--;
}
bo(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;
}
let b = NaN;
let 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);
}
}
}
}
bn(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);
}
bv() {
this.s = false;
{
let 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;
let b = truncate(Math.ceil((this.a7 / 150) * this.a8));
this.a6 = b;
this.bi();
}
bg() {
this.al.clear();
}
bf() {
this.s = true;
}
bk() {
this.t = false;
if (this.s) {
return;
}
this.bi();
}
bi() {
this.al.clear();
this.bp(false);
if (this.j == 0) {
for (let 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) {
for (let b of fromEnum(this.al)) {
}
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) {
let c = this.ak.c;
this.k.k();
while (c != null) {
let 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);
}
}
}
bj() {
let a = truncate(Math.round((this.a4 - 1) * this.f.nextDouble()));
let b = 0;
let c = this.ak.c;
let d = this.ay(null);
let e = 30;
let f = 60;
while (c != null) {
let g = c.c;
let h = 0;
let i = 0;
if (this.q) {
h = this.f.nextDouble() * g.p * 2;
i = this.f.nextDouble() * g.o * 2;
}
if (b == a) {
let 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()));
}
let k = g.c;
let l = this.o(g, this.an._inner[j], h, i, false);
let 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);
let n = this.ay(g);
let o = d > n;
if (!o) {
let 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;
}
}
z(a, b) {
return this.aa(a, b);
}
aa(a, b) {
if (!a.c(b)) {
return false;
}
if (a.i == null) {
return true;
}
let c = a.i;
if (c.a == null) {
if (b.i != null) {
let d = b.i;
if (d.d == b) {
let e = d.a;
return e.e(a.j());
}
else {
return true;
}
}
}
let f = c.a;
if (c.d == a) {
return f.e(b.j());
}
if (b.i != null) {
let g = b.i;
if (g.d == b) {
if (this.ah(this.j)) {
return false;
}
let h = g.a;
return h.e(a.j());
}
else {
return true;
}
}
return true;
}
ay(a) {
if (this.u) {
let b = 0;
let c = this.ak.c;
while (c != null) {
let d = c.c;
let e = d.f;
d.f = false;
if (d.c != null) {
let f = this.k.e(d.c);
for (let g = 0; g < f.count; g++) {
let h = f._inner[g].l.c;
while (h != null) {
let 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) {
let j = new HashSet$1(LabelCollisionInfo.$, 0);
let k = new HashSet$1(LabelCollisionInfo.$, 0);
let l = new HashSet$1(LabelCollisionInfo.$, 0);
let m = new List$1(LabelCollisionInfo.$, 0);
if (a.j != null) {
for (let n = 0; n < a.j.count; n++) {
j.add_1(a.j._inner[n]);
k.add_1(a.j._inner[n]);
}
}
let o = a.f;
a.f = false;
if (a.c != null) {
let p = this.k.e(a.c);
for (let q = 0; q < p.count; q++) {
let r = p._inner[q].l.c;
while (r != null) {
let 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 (let t = 0; t < p.count; t++) {
let u = p._inner[t].l.c;
while (u != null) {
let 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 (let w = a.j.count - 1; w >= 0; w--) {
if (!l.contains(a.j._inner[w])) {
let x = a.j._inner[w];
let y = false;
if (x != a) {
y = x.j.remove(a);
}
else {
}
a.j.removeAt(w);
if (x.j.count == 0 && y) {
this.a5--;
}
let z = j.remove(x);
if (j.count == 0 && z) {
this.a5--;
}
}
}
}
for (let aa = 0; aa < m.count; aa++) {
let 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;
}
}
w(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;
}
get a9() {
return this.a5;
}
bs(a, b, c) {
this.b0 = c;
let d = new QuadTree(a, b, this.k.i, this.k.f);
let 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;
}
af() {
let 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;
}
x() {
let a = this.ak.c;
let b = this.an;
while (a != null) {
if (a.c.c != null) {
if (this.ab(a.c.c)) {
let c = a.c;
for (let d = 0; d < b.count; d++) {
let e = this.o(c, b._inner[d], 0, 0, false);
if (e != null) {
return true;
}
}
}
}
a = a.a;
}
return false;
}
ba() {
let a = this.ak.c;
while (a != null) {
a.c.f = false;
a = a.a;
}
a = this.ak.c;
while (a != null) {
let b = a.c.c;
let c = a.c.e;
let d = this.k.e(c);
for (let e = 0; e < d.count; e++) {
let f = d._inner[e].l.c;
while (f != null) {
let g = f.c;
if (this.w(c, g)) {
f = f.a;
continue;
}
if (this.z(c, g)) {
let 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 (let i = 0; i < d.count; i++) {
let j = d._inner[i].l.c;
while (j != null) {
let k = j.c;
if (this.z(b, k)) {
let l = j.c.i;
if (!this.ai(j.c, a.c)) {
l.f = true;
a.c.f = true;
}
}
j = j.a;
}
}
a = a.a;
}
let m = 0;
let n = 1.7976931348623157E+308;
let o = -1.7976931348623157E+308;
let p = 1.7976931348623157E+308;
let 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;
}
bp(a) {
let b = this.ak.c;
if (this.ah(this.j)) {
this.bq();
return;
}
while (b != null) {
let c = b.c;
if (c.c == null || a) {
let d = false;
if (a) {
let e = this.k.a(c.s, c.t, 1.5);
let f = this.c(e);
if (f != null) {
for (let g = 0; g < f.length; g++) {
let h = f[g];
let i = this.o(c, h, 0, 0, false);
if (i == null) {
continue;
}
let j = this.k.e(i);
d = true;
for (let k = 0; k < j.count; k++) {
let l = j._inner[k].l.c;
while (l != null) {
let 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;
}
}
bq() {
let a = this.ak.c;
let b = new List$1(LabelCollisionInfo.$, 0);
let c = new List$1(LabelCollisionInfo.$, 0);
let d = new List$1(LabelCollisionInfo.$, 0);
let e = new List$1(LabelCollisionInfo.$, 0);
let f = this.j;
while (a != null) {
let g = a.c;
let h = g.a;
if (g.a == null || h.type != 2) {
g.h = true;
this.al.add(g);
a = a.a;
continue;
}
let i = h;
let j = this.bz(i);
let k = g;
let l = k.p + k.p;
let m = k.o + k.o;
let n = (i.startAngle + i.endAngle) / 2;
n = MathUtil.f(n);
let o = Rect.empty;
if (f == 3 || f == 7) {
let 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) {
let 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;
}
}
let 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);
}
bw(a, b) {
let c = new List$1(LabelCollisionInfo.$, 0);
let d = new HashSet$1(LabelCollisionInfo.$, 0);
if (!this.u) {
c = new List$1(LabelCollisionInfo.$, 0);
}
this.bh(a, b, c, d);
let 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;
}
bh(a, b, c, d) {
if (this.y(b, a)) {
let e = this.k.e(b);
for (let f = 0; f < e.count; f++) {
let g = e._inner[f].l.c;
while (g != null) {
let 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;
}
}
}
}
n(a) {
let b = null;
let c = a.a;
if (c == null) {
return null;
}
let d = this.bz(c);
let e = a.p + a.p;
let f = a.o + a.o;
let g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
let h = GeometryUtil.u(d, g, c.radius + this.a0);
a.b = 10;
this.bm(a);
let i = LabelCollisionManager.av(d, c.radius, c, a);
let j = GeometryUtil.u(d, g, i);
let 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 = ((() => {
let $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;
}
bm(a) {
if (a == null) {
return;
}
let b = !a.h;
if (b) {
return;
}
a.h = false;
this.al.add(a);
}
bl(a) {
if (a == null) {
return;
}
let b = !a.h;
if (!b) {
return;
}
a.h = true;
this.al.add(a);
}
m(a) {
let b = null;
let c = a.a;
if (c == null) {
return null;
}
let d = this.bz(c);
let e = a.p + a.p;
let f = a.o + a.o;
let g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
let h = LabelCollisionManager.av(d, c.radius, c, a);
let i = GeometryUtil.u(d, g, h);
let j = new Rect(0, i.x - e / 2, i.y - f / 2, e, f);
let 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 = ((() => {
let $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;
}
l(a) {
let b = null;
let c = a.a;
if (c == null) {
return null;
}
let d = this.bz(c);
let e = a.p + a.p;
let f = a.o + a.o;
let g = (c.startAngle + c.endAngle) / 2;
g = MathUtil.f(g);
let h = c.innerRadius;
let i = GeometryUtil.u(d, g, c.radius - (c.radius - h) / 2);
let j = new Rect(0, i.x - a.p, i.y - a.o, e, f);
let 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 = ((() => {
let $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;
}
static av(a, b, c, d) {
let e = (c.startAngle + c.endAngle / 2);
e = MathUtil.f(e);
let f = e * Math.PI / 180;
let g = 1;
let h = GeometryUtil.u({ $type: Point_$type, x: 0, y: 0 }, e, g);
let i = LabelCollisionManager.by(c, d);
let j = Math.sqrt(i.x * i.x + i.y * i.y);
let k = { $type: Point_$type, x: i.x / j, y: i.y / j };
let l = LabelCollisionManager.aw(h, k);
let m = j / b;
let n = l * m;
let o = n;
let p = GeometryUtil.j({ $type: Point_$type, x: 0, y: 0 }, h);
let q = GeometryUtil.j({ $type: Point_$type, x: 0, y: 0 }, k);
if (q < p) {
o = -o;
}
let r = GeometryUtil.u(a, (f + o) * 180 / Math.PI, b);
let s = LabelCollisionManager.bx(c, d, r);
let t = Math.sqrt((s.x - a.x) * (s.x - a.x) + (s.y - a.y) * (s.y - a.y));
let u = t - 5;
return u;
}
static bx(a, b, c) {
let d = (a.startAngle + a.endAngle / 2);
d = MathUtil.f(d);
let e = GeometryUtil.n(d);
let f = b.p;
let 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 };
}
static aw(a, b) {
let c = a.x * b.x + a.y * b.y;
let d = Math.sqrt(a.x * a.x + a.y * a.y);
let e = Math.sqrt(b.x * b.x + b.y * b.y);
let f = Math.acos(c / (d * e));
return f;
}
static by(a, b) {
let c = (a.startAngle + a.endAngle / 2);
c = MathUtil.f(c);
let d = GeometryUtil.n(c);
let e = b.p;
let 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 };
}
static au(a, b, c, d) {
let e = MathUtil.g(a - b, c - d);
let 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);
}
bu(a) {
let b = new Array(a.count);
for (let c = 0; c < a.count; c++) {
let d = a._inner[c];
let e = d.a;
let f = this.bz(e);
let g = (e.startAngle + e.endAngle) / 2;
g = MathUtil.f(g);
let h = GeometryUtil.u(f, g, e.radius);
b[c] = h.y;
}
for (let i = 0; i < a.count; i++) {
for (let j = i + 1; j < a.count; j++) {
if (b[i] >= b[j]) {
let k = a._inner[i];
a._inner[i] = a._inner[j];
a._inner[j] = k;
let l = b[i];
b[i] = b[j];
b[j] = l;
}
}
}
}
bt(a) {
if (a.count == 0) {
return;
}
let b = this.b0.width;
let c = this.b0.height;
let d = a.count;
let e = a._inner[0].a;
let f = e.radius;
let g = this.bz(e);
let h = true;
let i = 0;
let j = Number.POSITIVE_INFINITY;
let k = Number.NEGATIVE_INFINITY;
i = this.ba();
let l = 0;
for (let m of fromEnum(a)) {
j = Math.min(j, m.o + m.o);
k = Math.max(k, m.o + m.o);
l += m.o + m.o;
}
if (l > c) {
h = false;
}
if (h && i > 0) {
for (let n = 0; n < d - 1; n++) {
for (let o = n + 1; o < d; o++) {
let p = a._inner[n];
let q = a._inner[o];
if (p.c.c(q.c)) {
let r = q.c;
let s = r.e - r.f;
let t = r.g + r.g;
let u = MathUtil.f(this.ax(q));
let v = Math.min(p.c.e + p.c.f + 0.01, c - j);
let w = this.a0 + f;
let x = Math.abs(g.y - (s + j / 2));
let y = Math.sqrt(Math.abs(w * w - x * x));
let z = GeometryUtil.n(u);
if (z > 90 && z < 270) {
y = (t + y) * -1;
}
let aa = g.x + y;
let ab = ((() => {
let $ret = new QuadTreeBoundingBox();
$ret.d = aa + r.g;
$ret.e = v + r.f;
$ret.g = r.g;
$ret.f = r.f;
$ret.i = q;
return $ret;
})());
if (q.c != null) {
this.k.d(q.c);
}
this.bw(q, ab);
this.k.c(q.c);
}
}
}
for (let ac = d - 1; ac > 0; ac--) {
for (let ad = ac - 1; ad >= 0; ad--) {
let ae = a._inner[ac];
let af = a._inner[ad];
if (ae.c.c(af.c)) {
let ag = af.c;
let ah = ag.e - ag.f;
let ai = ag.g + ag.g;
let aj = Math.max((ae.c.e - ae.c.f) - j - 0.01, 0);
let ak = this.a0 + f;
let al = Math.abs(g.y - (ah + j / 2));
let am = Math.sqrt(Math.abs(ak * ak - al * al));
let an = GeometryUtil.n(MathUtil.f(this.ax(af)));
if (an > 90 && an < 270) {
am = (ai + am) * -1;
}
let ao = g.x + am;
let ap = ((() => {
let $ret = new QuadTreeBoundingBox();
$ret.d = ao + ag.g;
$ret.e = aj + ag.f;
$ret.g = ag.g;
$ret.f = ag.f;
$ret.i = af;
return $ret;
})());
if (af.c != null) {
this.k.d(af.c);
}
this.bw(af, ap);
this.k.c(af.c);
}
}
}
}
for (let aq of fromEnum(a)) {
let 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