chunk-D5UVUJIX.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. import {
  2. a
  3. } from "./chunk-IIAN3QNN.js";
  4. import {
  5. l
  6. } from "./chunk-2Z2TG5CU.js";
  7. import {
  8. b,
  9. x as x2
  10. } from "./chunk-2TIUKVZN.js";
  11. import {
  12. x
  13. } from "./chunk-YXWMMD76.js";
  14. // node_modules/@arcgis/core/core/libs/rbush/PooledRBush.js
  15. var h = class {
  16. constructor(t = 9, i) {
  17. this._compareMinX = l2, this._compareMinY = c, this._toBBox = (t2) => t2, this._maxEntries = Math.max(4, t || 9), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), i && ("function" == typeof i ? this._toBBox = i : this._initFormat(i)), this.clear();
  18. }
  19. destroy() {
  20. this.clear(), g.prune(), M.prune(), X.prune(), Y.prune();
  21. }
  22. all(t) {
  23. this._all(this._data, t);
  24. }
  25. search(t, i) {
  26. let n = this._data;
  27. const e = this._toBBox;
  28. if (f(t, n))
  29. for (g.clear(); n; ) {
  30. for (let s = 0, h2 = n.children.length; s < h2; s++) {
  31. const h3 = n.children[s], a3 = n.leaf ? e(h3) : h3;
  32. f(t, a3) && (n.leaf ? i(h3) : x3(t, a3) ? this._all(h3, i) : g.push(h3));
  33. }
  34. n = g.pop();
  35. }
  36. }
  37. collides(t) {
  38. let i = this._data;
  39. const n = this._toBBox;
  40. if (!f(t, i))
  41. return false;
  42. for (g.clear(); i; ) {
  43. for (let e = 0, s = i.children.length; e < s; e++) {
  44. const s2 = i.children[e], h2 = i.leaf ? n(s2) : s2;
  45. if (f(t, h2)) {
  46. if (i.leaf || x3(t, h2))
  47. return true;
  48. g.push(s2);
  49. }
  50. }
  51. i = g.pop();
  52. }
  53. return false;
  54. }
  55. load(t) {
  56. if (!t.length)
  57. return this;
  58. if (t.length < this._minEntries) {
  59. for (let i2 = 0, n = t.length; i2 < n; i2++)
  60. this.insert(t[i2]);
  61. return this;
  62. }
  63. let i = this._build(t.slice(0, t.length), 0, t.length - 1, 0);
  64. if (this._data.children.length)
  65. if (this._data.height === i.height)
  66. this._splitRoot(this._data, i);
  67. else {
  68. if (this._data.height < i.height) {
  69. const t2 = this._data;
  70. this._data = i, i = t2;
  71. }
  72. this._insert(i, this._data.height - i.height - 1, true);
  73. }
  74. else
  75. this._data = i;
  76. return this;
  77. }
  78. insert(t) {
  79. return t && this._insert(t, this._data.height - 1), this;
  80. }
  81. clear() {
  82. return this._data = new b2([]), this;
  83. }
  84. remove(i) {
  85. var _a;
  86. if (!i)
  87. return this;
  88. let e, s = this._data, h2 = null, a3 = 0, r2 = false;
  89. const o2 = this._toBBox(i);
  90. for (X.clear(), Y.clear(); s || X.length > 0; ) {
  91. if (s || (s = x(X.pop()), h2 = X.data[X.length - 1], a3 = (_a = Y.pop()) != null ? _a : 0, r2 = true), s.leaf && (e = b(s.children, i, s.children.length, s.indexHint), -1 !== e))
  92. return s.children.splice(e, 1), X.push(s), this._condense(X), this;
  93. r2 || s.leaf || !x3(s, o2) ? h2 ? (a3++, s = h2.children[a3], r2 = false) : s = null : (X.push(s), Y.push(a3), a3 = 0, h2 = s, s = s.children[0]);
  94. }
  95. return this;
  96. }
  97. toJSON() {
  98. return this._data;
  99. }
  100. fromJSON(t) {
  101. return this._data = t, this;
  102. }
  103. _all(t, i) {
  104. var _a;
  105. let n = t;
  106. for (M.clear(); n; ) {
  107. if (true === n.leaf)
  108. for (const t2 of n.children)
  109. i(t2);
  110. else
  111. M.pushArray(n.children);
  112. n = (_a = M.pop()) != null ? _a : null;
  113. }
  114. }
  115. _build(t, i, n, e) {
  116. const s = n - i + 1;
  117. let h2 = this._maxEntries;
  118. if (s <= h2) {
  119. const e2 = new b2(t.slice(i, n + 1));
  120. return a2(e2, this._toBBox), e2;
  121. }
  122. e || (e = Math.ceil(Math.log(s) / Math.log(h2)), h2 = Math.ceil(s / h2 ** (e - 1)));
  123. const r2 = new j([]);
  124. r2.height = e;
  125. const o2 = Math.ceil(s / h2), l3 = o2 * Math.ceil(Math.sqrt(h2));
  126. p(t, i, n, l3, this._compareMinX);
  127. for (let a3 = i; a3 <= n; a3 += l3) {
  128. const i2 = Math.min(a3 + l3 - 1, n);
  129. p(t, a3, i2, o2, this._compareMinY);
  130. for (let n2 = a3; n2 <= i2; n2 += o2) {
  131. const s2 = Math.min(n2 + o2 - 1, i2);
  132. r2.children.push(this._build(t, n2, s2, e - 1));
  133. }
  134. }
  135. return a2(r2, this._toBBox), r2;
  136. }
  137. _chooseSubtree(t, i, n, e) {
  138. for (; e.push(i), true !== i.leaf && e.length - 1 !== n; ) {
  139. let n2, e2 = 1 / 0, s = 1 / 0;
  140. for (let h2 = 0, a3 = i.children.length; h2 < a3; h2++) {
  141. const a4 = i.children[h2], r2 = m(a4), o2 = u(t, a4) - r2;
  142. o2 < s ? (s = o2, e2 = r2 < e2 ? r2 : e2, n2 = a4) : o2 === s && r2 < e2 && (e2 = r2, n2 = a4);
  143. }
  144. i = n2 || i.children[0];
  145. }
  146. return i;
  147. }
  148. _insert(t, i, n) {
  149. const e = this._toBBox, s = n ? t : e(t);
  150. X.clear();
  151. const h2 = this._chooseSubtree(s, this._data, i, X);
  152. for (h2.children.push(t), o(h2, s); i >= 0 && X.data[i].children.length > this._maxEntries; )
  153. this._split(X, i), i--;
  154. this._adjustParentBBoxes(s, X, i);
  155. }
  156. _split(t, i) {
  157. const n = t.data[i], e = n.children.length, s = this._minEntries;
  158. this._chooseSplitAxis(n, s, e);
  159. const h2 = this._chooseSplitIndex(n, s, e);
  160. if (!h2)
  161. return void console.log(" Error: assertion failed at PooledRBush._split: no valid split index");
  162. const r2 = n.children.splice(h2, n.children.length - h2), o2 = n.leaf ? new b2(r2) : new j(r2);
  163. o2.height = n.height, a2(n, this._toBBox), a2(o2, this._toBBox), i ? t.data[i - 1].children.push(o2) : this._splitRoot(n, o2);
  164. }
  165. _splitRoot(t, i) {
  166. this._data = new j([t, i]), this._data.height = t.height + 1, a2(this._data, this._toBBox);
  167. }
  168. _chooseSplitIndex(t, i, n) {
  169. let e, s, h2;
  170. e = s = 1 / 0;
  171. for (let a3 = i; a3 <= n - i; a3++) {
  172. const i2 = r(t, 0, a3, this._toBBox), o2 = r(t, a3, n, this._toBBox), l3 = _(i2, o2), c2 = m(i2) + m(o2);
  173. l3 < e ? (e = l3, h2 = a3, s = c2 < s ? c2 : s) : l3 === e && c2 < s && (s = c2, h2 = a3);
  174. }
  175. return h2;
  176. }
  177. _chooseSplitAxis(t, i, n) {
  178. const e = t.leaf ? this._compareMinX : l2, s = t.leaf ? this._compareMinY : c;
  179. this._allDistMargin(t, i, n, e) < this._allDistMargin(t, i, n, s) && t.children.sort(e);
  180. }
  181. _allDistMargin(t, i, n, e) {
  182. t.children.sort(e);
  183. const s = this._toBBox, h2 = r(t, 0, i, s), a3 = r(t, n - i, n, s);
  184. let l3 = d(h2) + d(a3);
  185. for (let r2 = i; r2 < n - i; r2++) {
  186. const i2 = t.children[r2];
  187. o(h2, t.leaf ? s(i2) : i2), l3 += d(h2);
  188. }
  189. for (let r2 = n - i - 1; r2 >= i; r2--) {
  190. const i2 = t.children[r2];
  191. o(a3, t.leaf ? s(i2) : i2), l3 += d(a3);
  192. }
  193. return l3;
  194. }
  195. _adjustParentBBoxes(t, i, n) {
  196. for (let e = n; e >= 0; e--)
  197. o(i.data[e], t);
  198. }
  199. _condense(i) {
  200. for (let n = i.length - 1; n >= 0; n--) {
  201. const e = i.data[n];
  202. if (0 === e.children.length)
  203. if (n > 0) {
  204. const s = i.data[n - 1], h2 = s.children;
  205. h2.splice(b(h2, e, h2.length, s.indexHint), 1);
  206. } else
  207. this.clear();
  208. else
  209. a2(e, this._toBBox);
  210. }
  211. }
  212. _initFormat(t) {
  213. const i = ["return a", " - b", ";"];
  214. this._compareMinX = new Function("a", "b", i.join(t[0])), this._compareMinY = new Function("a", "b", i.join(t[1])), this._toBBox = new Function("a", "return {minX: a" + t[0] + ", minY: a" + t[1] + ", maxX: a" + t[2] + ", maxY: a" + t[3] + "};");
  215. }
  216. };
  217. function a2(t, i) {
  218. r(t, 0, t.children.length, i, t);
  219. }
  220. function r(t, i, n, e, s) {
  221. s || (s = new b2([])), s.minX = 1 / 0, s.minY = 1 / 0, s.maxX = -1 / 0, s.maxY = -1 / 0;
  222. for (let h2, a3 = i; a3 < n; a3++)
  223. h2 = t.children[a3], o(s, t.leaf ? e(h2) : h2);
  224. return s;
  225. }
  226. function o(t, i) {
  227. t.minX = Math.min(t.minX, i.minX), t.minY = Math.min(t.minY, i.minY), t.maxX = Math.max(t.maxX, i.maxX), t.maxY = Math.max(t.maxY, i.maxY);
  228. }
  229. function l2(t, i) {
  230. return t.minX - i.minX;
  231. }
  232. function c(t, i) {
  233. return t.minY - i.minY;
  234. }
  235. function m(t) {
  236. return (t.maxX - t.minX) * (t.maxY - t.minY);
  237. }
  238. function d(t) {
  239. return t.maxX - t.minX + (t.maxY - t.minY);
  240. }
  241. function u(t, i) {
  242. return (Math.max(i.maxX, t.maxX) - Math.min(i.minX, t.minX)) * (Math.max(i.maxY, t.maxY) - Math.min(i.minY, t.minY));
  243. }
  244. function _(t, i) {
  245. const n = Math.max(t.minX, i.minX), e = Math.max(t.minY, i.minY), s = Math.min(t.maxX, i.maxX), h2 = Math.min(t.maxY, i.maxY);
  246. return Math.max(0, s - n) * Math.max(0, h2 - e);
  247. }
  248. function x3(t, i) {
  249. return t.minX <= i.minX && t.minY <= i.minY && i.maxX <= t.maxX && i.maxY <= t.maxY;
  250. }
  251. function f(t, i) {
  252. return i.minX <= t.maxX && i.minY <= t.maxY && i.maxX >= t.minX && i.maxY >= t.minY;
  253. }
  254. function p(t, i, e, h2, a3) {
  255. const r2 = [i, e];
  256. for (; r2.length; ) {
  257. const i2 = x(r2.pop()), e2 = x(r2.pop());
  258. if (i2 - e2 <= h2)
  259. continue;
  260. const o2 = e2 + Math.ceil((i2 - e2) / h2 / 2) * h2;
  261. a(t, o2, e2, i2, a3), r2.push(e2, o2, o2, i2);
  262. }
  263. }
  264. var g = new l();
  265. var M = new l();
  266. var X = new l();
  267. var Y = new l({ deallocator: void 0 });
  268. var B = class {
  269. constructor() {
  270. this.minX = 1 / 0, this.minY = 1 / 0, this.maxX = -1 / 0, this.maxY = -1 / 0;
  271. }
  272. };
  273. var w = class extends B {
  274. constructor() {
  275. super(...arguments), this.height = 1, this.indexHint = new x2();
  276. }
  277. };
  278. var b2 = class extends w {
  279. constructor(t) {
  280. super(), this.children = t, this.leaf = true;
  281. }
  282. };
  283. var j = class extends w {
  284. constructor(t) {
  285. super(), this.children = t, this.leaf = false;
  286. }
  287. };
  288. export {
  289. h
  290. };
  291. //# sourceMappingURL=chunk-D5UVUJIX.js.map