@thibezer/ui-components-kit 2.17.1 → 2.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/camadas.cjs +80 -83
  3. package/dist/camadas.js +1131 -869
  4. package/dist/components/ui-camadas/camadas-arvore-renderer.d.ts +1 -0
  5. package/dist/components/ui-camadas/camadas-atualizacao-incremental.d.ts +1 -0
  6. package/dist/components/ui-camadas/camadas-colecao.d.ts +1 -0
  7. package/dist/components/ui-camadas/camadas-drag-drop.d.ts +2 -0
  8. package/dist/components/ui-camadas/camadas-drop-ops.d.ts +34 -0
  9. package/dist/components/ui-camadas/camadas-lembranca.d.ts +2 -1
  10. package/dist/components/ui-camadas/camadas-persistencia.d.ts +3 -0
  11. package/dist/components/ui-camadas/ui-camadas.d.ts +1 -0
  12. package/dist/custom-elements.json +4531 -4079
  13. package/dist/tipos-elementos.d.ts +3 -0
  14. package/dist/tipos-vue.d.ts +3 -0
  15. package/package.json +1 -1
  16. package/dist/form-validacao-BIOXxt-1.js +0 -140
  17. package/dist/form-validacao-ytRYSF3E.cjs +0 -1
  18. package/dist/gerencigeo-canvas/layer_defaults.d.ts +0 -3
  19. package/dist/gerencigeo-canvas/layer_instance_ops.d.ts +0 -6
  20. package/dist/gerencigeo-canvas/layer_state_ops.d.ts +0 -6
  21. package/dist/leaflet-DcO7uRC-.cjs +0 -1
  22. package/dist/leaflet-PPDKB6Dd.js +0 -69
  23. package/dist/motor-BCWqlv3e.cjs +0 -1
  24. package/dist/motor-CXjQjVba.js +0 -1386
  25. package/dist/svg-seguro-BsbNQqpd.js +0 -50
  26. package/dist/svg-seguro-C76iLlAZ.cjs +0 -1
  27. package/dist/ui-badge-1UU8vT-b.js +0 -198
  28. package/dist/ui-badge-B5J_c5P5.js +0 -197
  29. package/dist/ui-badge-BxT-sDmV.cjs +0 -28
  30. package/dist/ui-badge-C0eKBI8E.js +0 -183
  31. package/dist/ui-badge-CKKKPdt8.cjs +0 -28
  32. package/dist/ui-badge-DC4y6Dik.cjs +0 -28
  33. package/dist/ui-botao-BOOnP8ds.cjs +0 -12
  34. package/dist/ui-botao-D24oXySA.cjs +0 -12
  35. package/dist/ui-botao-DfqSivHl.js +0 -165
  36. package/dist/ui-botao-Dsj08jjw.js +0 -165
  37. package/dist/ui-botao-OGJV6Vfk.js +0 -165
  38. package/dist/ui-botao-bU_bf6SU.js +0 -166
  39. package/dist/ui-botao-psS1juof.cjs +0 -12
  40. package/dist/ui-botao-xTbH5mpH.cjs +0 -12
  41. package/dist/ui-campo-texto-19tIrmBK.js +0 -377
  42. package/dist/ui-campo-texto-CH8mzX61.cjs +0 -16
  43. package/dist/ui-campo-texto-Cnn2UAkS.cjs +0 -16
  44. package/dist/ui-campo-texto-DVU_sWV1.cjs +0 -16
  45. package/dist/ui-campo-texto-Uu2dJE_0.js +0 -379
  46. package/dist/ui-campo-texto-W5M0gNE4.js +0 -377
  47. package/dist/ui-card-0wu4rjEX.cjs +0 -20
  48. package/dist/ui-card-B86lJXTP.cjs +0 -20
  49. package/dist/ui-card-BYyYxxY1.cjs +0 -20
  50. package/dist/ui-card-C_o5_0cB.js +0 -111
  51. package/dist/ui-card-CojoGXaT.js +0 -144
  52. package/dist/ui-card-DRtpOo3l.js +0 -143
  53. package/dist/ui-controle-cores-B4R6ct4I.js +0 -291
  54. package/dist/ui-controle-cores-BS0WYPdi.js +0 -572
  55. package/dist/ui-controle-cores-Bq_XUrIQ.cjs +0 -32
  56. package/dist/ui-controle-cores-BtA6yzu3.js +0 -291
  57. package/dist/ui-controle-cores-C8um-If9.cjs +0 -32
  58. package/dist/ui-controle-cores-CHMKGemo.cjs +0 -141
  59. package/dist/ui-controle-cores-C_cVXxCn.js +0 -291
  60. package/dist/ui-controle-cores-CuDFS8Y8.cjs +0 -32
  61. package/dist/ui-controle-cores-Dog7ERYv.js +0 -697
  62. package/dist/ui-controle-cores-Er6ZcQ7U.cjs +0 -111
  63. package/dist/ui-linha-BxhEBn27.js +0 -749
  64. package/dist/ui-linha-C306zxWG.cjs +0 -19
  65. package/dist/ui-linha-C_azWkcG.js +0 -517
  66. package/dist/ui-linha-CcalUBDw.cjs +0 -38
  67. package/dist/ui-linha-DAz6DBcl.cjs +0 -38
  68. package/dist/ui-linha-DkxwMhD-.js +0 -749
  69. package/dist/ui-modal-4nU-tXjO.cjs +0 -18
  70. package/dist/ui-modal-BkYvNP0G.js +0 -214
  71. package/dist/ui-modal-BwB9fksp.js +0 -214
  72. package/dist/ui-modal-CUNbpbZ1.cjs +0 -18
  73. package/dist/ui-modal-CvGFGh1h.cjs +0 -18
  74. package/dist/ui-modal-DBOtSTbR.js +0 -238
  75. package/dist/ui-paleta-ferramentas-BXXrI1Y7.js +0 -1233
  76. package/dist/ui-paleta-ferramentas-CEZYcN4J.js +0 -624
  77. package/dist/ui-paleta-ferramentas-CU4icLl0.js +0 -1171
  78. package/dist/ui-paleta-ferramentas-Ccmo-rB5.cjs +0 -21
  79. package/dist/ui-paleta-ferramentas-CsPMTY0G.cjs +0 -21
  80. package/dist/ui-paleta-ferramentas-DLwZHIDv.cjs +0 -21
  81. package/dist/ui-paleta-ferramentas-DNN5i6nL.js +0 -860
  82. package/dist/ui-paleta-ferramentas-Dbj1kBS9.cjs +0 -18
  83. package/dist/ui-paleta-ferramentas-DbwdWVtT.js +0 -1173
  84. package/dist/ui-paleta-ferramentas-bvqxj1Yd.cjs +0 -21
  85. package/dist/ui-segmented-D6b6zxVs.cjs +0 -19
  86. package/dist/ui-segmented-DyF5YLsV.js +0 -418
  87. package/dist/ui-segmented-rn9RxRGM.cjs +0 -19
  88. package/dist/ui-segmented-wUraId2e.js +0 -412
  89. package/dist/ui-seletor-cor-C4U2eqxY.cjs +0 -82
  90. package/dist/ui-seletor-cor-D2_C6Aor.js +0 -391
  91. package/dist/ui-seletor-cor-DPKqf5wb.cjs +0 -82
  92. package/dist/ui-seletor-cor-FYtRccnK.js +0 -396
  93. package/dist/ui-skeleton-B2Rgrv8o.js +0 -648
  94. package/dist/ui-skeleton-DEHwpDqa.js +0 -648
  95. package/dist/ui-skeleton-DI4_9WOX.js +0 -428
  96. package/dist/ui-skeleton-DiOxTBZK.cjs +0 -52
  97. package/dist/ui-skeleton-SPYqku8P.cjs +0 -52
  98. package/dist/ui-skeleton-W9uwIceA.js +0 -585
  99. package/dist/ui-skeleton-elhKIh2B.cjs +0 -33
  100. package/dist/ui-skeleton-sIphhOSx.cjs +0 -52
  101. package/dist/ui-switch-BL-x_-SM.js +0 -1202
  102. package/dist/ui-switch-BcOqOkiV.js +0 -856
  103. package/dist/ui-switch-C0i_3QXu.cjs +0 -66
  104. package/dist/ui-switch-D7iPKDj-.cjs +0 -53
  105. package/dist/ui-switch-DAIgOhqr.cjs +0 -66
  106. package/dist/ui-switch-_F8yubdX.js +0 -1203
  107. package/dist/ui-tabela-propriedades-2bq2nX-b.js +0 -3202
  108. package/dist/ui-tabela-propriedades-8IAYmk3P.cjs +0 -142
  109. package/dist/ui-tabela-propriedades-B8AwlpqL.cjs +0 -141
  110. package/dist/ui-tabela-propriedades-BBr5sqki.cjs +0 -145
  111. package/dist/ui-tabela-propriedades-BecPqC-e.cjs +0 -141
  112. package/dist/ui-tabela-propriedades-BoYXzP5Z.js +0 -3191
  113. package/dist/ui-tabela-propriedades-BokvDD3b.js +0 -2648
  114. package/dist/ui-tabela-propriedades-Boy7I5yW.js +0 -2412
  115. package/dist/ui-tabela-propriedades-C-PeuW1i.cjs +0 -141
  116. package/dist/ui-tabela-propriedades-C5YYnod1.js +0 -3053
  117. package/dist/ui-tabela-propriedades-CnfW9DZG.cjs +0 -142
  118. package/dist/ui-tabela-propriedades-CyPyKXtB.js +0 -3013
  119. package/dist/ui-tabela-propriedades-DWOKznMN.cjs +0 -142
  120. package/dist/ui-tabela-propriedades-Df9ajC6M.js +0 -2648
  121. package/dist/ui-tabela-propriedades-DqvPilK_.cjs +0 -142
  122. package/dist/ui-tabela-propriedades-DuaC4sFX.js +0 -2767
  123. package/dist/ui-toast-Bp_NlM5G.js +0 -156
  124. package/dist/ui-toast-DGTZKne5.cjs +0 -20
  125. package/dist/zero-js-triggers-C_KrvFOQ.js +0 -244
  126. package/dist/zero-js-triggers-C_gtaojZ.cjs +0 -1
@@ -1,1386 +0,0 @@
1
- var Nt = Object.defineProperty;
2
- var wt = (o, t, a) => t in o ? Nt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[t] = a;
3
- var M = (o, t, a) => wt(o, typeof t != "symbol" ? t + "" : t, a);
4
- function F(o) {
5
- return o.partes && o.partes.length > 1 ? o.partes : [o.coordenadas];
6
- }
7
- function Ta(o) {
8
- return o.tipo === "LineString" && !!o.partes && o.partes.length > 1;
9
- }
10
- function Et(o) {
11
- return o.length > 1 ? { tipo: "LineString", coordenadas: o[0], partes: o } : { tipo: "LineString", coordenadas: o[0] };
12
- }
13
- const T = 6378137, k = 1 / 298.257222101, W = k * (2 - k), D = (o) => o * Math.PI / 180;
14
- function Q(o) {
15
- const t = Math.sin(D(o)), a = 1 - W * t * t;
16
- return { N: T / Math.sqrt(a), M: T * (1 - W) / (a * Math.sqrt(a)) };
17
- }
18
- function Fa(o) {
19
- const { M: t, N: a } = Q(o);
20
- return { lat: D(1) * t, lng: D(1) * a * Math.cos(D(o)) };
21
- }
22
- function Tt(o, t) {
23
- const a = T * (1 - k), e = k, i = D(t[1] - o[1]), n = Math.atan((1 - e) * Math.tan(D(o[0]))), s = Math.atan((1 - e) * Math.tan(D(t[0]))), r = Math.sin(n), c = Math.cos(n), l = Math.sin(s), d = Math.cos(s);
24
- let h = i, u = 0, g = 0, L = 0, f = 0, m = 0;
25
- for (let v = 0; v < 100; v++) {
26
- const p = Math.sin(h), P = Math.cos(h);
27
- if (u = Math.hypot(d * p, c * l - r * d * P), u === 0) return 0;
28
- g = r * l + c * d * P, L = Math.atan2(u, g);
29
- const A = c * d * p / u;
30
- f = 1 - A * A, m = f === 0 ? 0 : g - 2 * r * l / f;
31
- const C = e / 16 * f * (4 + e * (4 - 3 * f)), j = h;
32
- if (h = i + (1 - C) * e * A * (L + C * u * (m + C * g * (-1 + 2 * m * m))), Math.abs(h - j) < 1e-12) break;
33
- }
34
- const x = f * (T * T - a * a) / (a * a), w = 1 + x / 16384 * (4096 + x * (-768 + x * (320 - 175 * x))), S = x / 1024 * (256 + x * (-128 + x * (74 - 47 * x))), y = S * u * (m + S / 4 * (g * (-1 + 2 * m * m) - S / 6 * m * (-3 + 4 * u * u) * (-3 + 4 * m * m)));
35
- return a * w * (L - y);
36
- }
37
- function tt(o, t) {
38
- const a = t[0] - o[0], e = t[1] - o[1];
39
- if (Math.abs(a) < 0.1 && Math.abs(e) < 0.1) {
40
- const { M: i, N: n } = Q((o[0] + t[0]) / 2), s = D(a) * i, r = D(e) * n * Math.cos(D((o[0] + t[0]) / 2));
41
- return Math.hypot(r, s);
42
- }
43
- return Tt(o, t);
44
- }
45
- function at(o, t = !1) {
46
- let a = 0;
47
- for (let e = 1; e < o.length; e++) a += tt(o[e - 1], o[e]);
48
- return t && o.length > 2 && (a += tt(o[o.length - 1], o[0])), a;
49
- }
50
- function ot(o) {
51
- const t = o.length;
52
- if (t < 3) return 0;
53
- let a = 0, e = 0;
54
- for (let r = 0; r < t; r++) {
55
- const c = o[(r - 1 + t) % t], l = o[r], d = o[(r + 1) % t];
56
- a += D(d[1] - c[1]) * Math.sin(D(l[0])), e += l[0];
57
- }
58
- const { M: i, N: n } = Q(e / t), s = Math.abs(a * i * n / 2);
59
- return Number.isFinite(s) ? s : 0;
60
- }
61
- function Ft(o) {
62
- const [t, ...a] = o;
63
- return t ? Math.max(0, ot(t) - a.reduce((e, i) => e + ot(i), 0)) : 0;
64
- }
65
- const Rt = new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 4, maximumFractionDigits: 4 }), et = new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
66
- function zt(o) {
67
- return `${Rt.format(o / 1e4)} ha`;
68
- }
69
- function _t(o) {
70
- return o >= 1e3 ? `${et.format(o / 1e3)} km` : `${et.format(o)} m`;
71
- }
72
- function $t(o) {
73
- return o.tipo === "Polygon" ? Ft(o.aneis) : o.tipo === "Circle" ? Math.PI * o.raioMetros ** 2 : null;
74
- }
75
- function Bt(o) {
76
- return o.tipo === "LineString" ? F(o).reduce((t, a) => t + at(a), 0) : o.tipo === "Polygon" ? at(o.aneis[0] ?? [], !0) : o.tipo === "Circle" ? 2 * Math.PI * o.raioMetros : null;
77
- }
78
- function kt(o, t) {
79
- var i;
80
- const a = t ?? "name";
81
- if (a === "area") {
82
- const n = $t(o.geometria);
83
- return n === null ? "" : zt(n);
84
- }
85
- if (a === "extensao") {
86
- const n = Bt(o.geometria);
87
- return n === null ? "" : _t(n);
88
- }
89
- if (a === "id") return o.id;
90
- const e = (i = o.propriedades) == null ? void 0 : i[a];
91
- return e != null && e !== "" ? String(e) : t ? "" : o.id;
92
- }
93
- function qt(o) {
94
- let t;
95
- switch (o.tipo) {
96
- case "Point":
97
- case "Text":
98
- t = [o.coordenada];
99
- break;
100
- case "LineString":
101
- t = F(o).flat();
102
- break;
103
- case "Polygon":
104
- t = o.aneis.flat();
105
- break;
106
- case "Circle": {
107
- const i = o.raioMetros / 111320, n = i / Math.max(0.01, Math.cos(D(o.centro[0])));
108
- t = [[o.centro[0] - i, o.centro[1] - n], [o.centro[0] + i, o.centro[1] + n]];
109
- break;
110
- }
111
- }
112
- const a = t.map((i) => i[0]), e = t.map((i) => i[1]);
113
- return [[Math.min(...a), Math.min(...e)], [Math.max(...a), Math.max(...e)]];
114
- }
115
- const R = 16, Ut = 256;
116
- function it(o) {
117
- const [[t, a], [e, i]] = qt(o.geometria);
118
- return { minLon: a, minLat: t, maxLon: i, maxLat: e };
119
- }
120
- function $(o, t) {
121
- return o.minLon <= t.maxLon && o.maxLon >= t.minLon && o.minLat <= t.maxLat && o.maxLat >= t.minLat;
122
- }
123
- function nt(o) {
124
- let t = 1 / 0, a = 1 / 0, e = -1 / 0, i = -1 / 0;
125
- for (const n of o)
126
- n.minLon < t && (t = n.minLon), n.minLat < a && (a = n.minLat), n.maxLon > e && (e = n.maxLon), n.maxLat > i && (i = n.maxLat);
127
- return { minLon: t, minLat: a, maxLon: e, maxLat: i };
128
- }
129
- function st(o) {
130
- const t = o.length, a = Math.ceil(t / R), i = Math.ceil(Math.sqrt(a)) * R, n = [...o].sort((r, c) => r.minLon + r.maxLon - (c.minLon + c.maxLon)), s = [];
131
- for (let r = 0; r < t; r += i) {
132
- const c = n.slice(r, r + i).sort((l, d) => l.minLat + l.maxLat - (d.minLat + d.maxLat));
133
- for (let l = 0; l < c.length; l += R) s.push(c.slice(l, l + R));
134
- }
135
- return s;
136
- }
137
- function Vt(o) {
138
- if (o.length === 0) return null;
139
- let t = st(o).map((a) => ({ ...nt(a), folhas: a }));
140
- for (; t.length > 1; )
141
- t = st(t).map((a) => ({ ...nt(a), filhos: a }));
142
- return t[0];
143
- }
144
- class Xt {
145
- constructor() {
146
- M(this, "raiz", null);
147
- /** Itens vivos: a fonte da verdade (a árvore pode conter itens já removidos/atualizados). */
148
- M(this, "itens", /* @__PURE__ */ new Map());
149
- /** Itens que entraram ou mudaram depois da última montagem. */
150
- M(this, "delta", /* @__PURE__ */ new Map());
151
- /** Ids que estão na árvore mas foram removidos ou substituídos. */
152
- M(this, "obsoletos", /* @__PURE__ */ new Set());
153
- }
154
- get tamanho() {
155
- return this.itens.size;
156
- }
157
- construir(t) {
158
- this.itens.clear();
159
- for (const a of t)
160
- a.excluida || this.itens.set(a.id, { id: a.id, ...it(a) });
161
- this.remontar();
162
- }
163
- inserir(t) {
164
- this.atualizar(t);
165
- }
166
- /** Insere ou substitui; feição `excluida` sai do índice. */
167
- atualizar(t) {
168
- if (t.excluida) {
169
- this.remover(t.id);
170
- return;
171
- }
172
- const a = { id: t.id, ...it(t) };
173
- this.itens.has(t.id) && this.obsoletos.add(t.id), this.itens.set(t.id, a), this.delta.set(t.id, a), this.compactarSeNecessario();
174
- }
175
- remover(t) {
176
- this.itens.delete(t) && (this.obsoletos.add(t), this.delta.delete(t), this.compactarSeNecessario());
177
- }
178
- limpar() {
179
- this.itens.clear(), this.remontar();
180
- }
181
- /** Ids das feições cujo envelope toca `caixa`. */
182
- consultar(t) {
183
- const a = [], e = this.raiz ? [this.raiz] : [];
184
- for (; e.length > 0; ) {
185
- const i = e.pop();
186
- if ($(i, t))
187
- if (i.folhas)
188
- for (const n of i.folhas)
189
- !this.obsoletos.has(n.id) && $(n, t) && a.push(n.id);
190
- else i.filhos && e.push(...i.filhos);
191
- }
192
- for (const i of this.delta.values()) $(i, t) && a.push(i.id);
193
- return a;
194
- }
195
- intersecta(t) {
196
- return this.consultar(t).length > 0;
197
- }
198
- /** Envelope da feição indexada, se houver. */
199
- caixaDe(t) {
200
- return this.itens.get(t);
201
- }
202
- compactarSeNecessario() {
203
- this.delta.size + this.obsoletos.size > Math.max(Ut, this.itens.size * 0.1) && this.remontar();
204
- }
205
- remontar() {
206
- this.raiz = Vt([...this.itens.values()]), this.delta.clear(), this.obsoletos.clear();
207
- }
208
- }
209
- const At = 17, J = 9, Gt = 1.2;
210
- function Zt(o) {
211
- return !Number.isFinite(o) || o >= At ? 0 : 360 / (256 * 2 ** o) * Gt;
212
- }
213
- function rt(o) {
214
- return Number.isFinite(o) ? 1 / Math.max(0.05, Math.cos(Math.max(-85, Math.min(85, o)) * Math.PI / 180)) : 1;
215
- }
216
- function Ht(o, t, a, e) {
217
- const i = a[1] - t[1], n = (a[0] - t[0]) * e, s = i * i + n * n, r = (o[0] - t[0]) * e;
218
- let c = s === 0 ? 0 : ((o[1] - t[1]) * i + r * n) / s;
219
- return c = Math.max(0, Math.min(1, c)), Math.hypot(o[1] - (t[1] + c * i), r - c * n);
220
- }
221
- function Dt(o, t, a = 1) {
222
- if (!(t > 0) || o.length < 3) return o;
223
- const e = Number.isFinite(a) && a > 0 ? a : 1, i = new Uint8Array(o.length);
224
- i[0] = 1, i[o.length - 1] = 1;
225
- const n = [[0, o.length - 1]];
226
- for (; n.length > 0; ) {
227
- const [s, r] = n.pop();
228
- let c = 0, l = -1;
229
- for (let d = s + 1; d < r; d++) {
230
- const h = Ht(o[d], o[s], o[r], e);
231
- h > c && (c = h, l = d);
232
- }
233
- l !== -1 && c > t && (i[l] = 1, n.push([s, l], [l, r]));
234
- }
235
- return o.filter((s, r) => i[r] === 1);
236
- }
237
- function Jt(o, t, a = 1) {
238
- if (!(t > 0) || o.length < 4) return o;
239
- const e = [...o, o[0]], i = Dt(e, t, a);
240
- return i.pop(), i.length >= 3 ? i : o;
241
- }
242
- function Yt(o) {
243
- return (o.tipo === "LineString" || o.tipo === "Polygon") && o.curva ? 0 : o.tipo === "LineString" ? F(o).reduce((t, a) => t + a.length, 0) : o.tipo === "Polygon" ? o.aneis.reduce((t, a) => t + a.length, 0) : 0;
244
- }
245
- function Ra(o, t) {
246
- var e, i, n, s;
247
- const a = Zt(t);
248
- if (a === 0 || Yt(o) < J) return o;
249
- if (o.tipo === "LineString") {
250
- const r = F(o), c = rt(((i = (e = r[0]) == null ? void 0 : e[0]) == null ? void 0 : i[0]) ?? NaN);
251
- return Et(r.map((l) => Dt(l, a, c)));
252
- }
253
- if (o.tipo === "Polygon") {
254
- const r = rt(((s = (n = o.aneis[0]) == null ? void 0 : n[0]) == null ? void 0 : s[0]) ?? NaN);
255
- return { tipo: "Polygon", aneis: o.aneis.map((c) => Jt(c, a, r)) };
256
- }
257
- return o;
258
- }
259
- const Qt = /* @__PURE__ */ new Set(["previa", "prévia", "preview", "rascunho", "draft", "proposta"]);
260
- function b(o) {
261
- var a, e;
262
- const t = [o.status, (a = o.propriedades) == null ? void 0 : a.status, (e = o.propriedades) == null ? void 0 : e.tipo_geometria];
263
- for (const i of t)
264
- if (typeof i == "string" && Qt.has(i.trim().toLowerCase())) return "previa";
265
- return "oficial";
266
- }
267
- function O(o) {
268
- var a;
269
- const t = o.entidadeId ?? ((a = o.propriedades) == null ? void 0 : a.entidadeId);
270
- return typeof t == "string" || typeof t == "number" ? String(t) : o.id;
271
- }
272
- const G = (o, t) => `${o}\0${t}`;
273
- class za {
274
- constructor() {
275
- /** Mostra as prévias de todas as entidades. */
276
- M(this, "global", !1);
277
- M(this, "individuais", /* @__PURE__ */ new Set());
278
- }
279
- alternarIndividual(t, a) {
280
- const e = G(t, a);
281
- return this.individuais.has(e) ? this.individuais.delete(e) : this.individuais.add(e), this.individuais.has(e);
282
- }
283
- definirIndividual(t, a, e) {
284
- const i = G(t, a);
285
- e ? this.individuais.add(i) : this.individuais.delete(i);
286
- }
287
- individualAtiva(t, a) {
288
- return this.individuais.has(G(t, a));
289
- }
290
- /** Entidades da camada que têm geometria oficial. */
291
- static oficiais(t) {
292
- const a = /* @__PURE__ */ new Set();
293
- for (const e of t) !e.excluida && b(e) === "oficial" && a.add(O(e));
294
- return a;
295
- }
296
- /** A feição aparece? `comOficial` = entidades da camada com geometria oficial (ver `oficiais`). */
297
- visivel(t, a) {
298
- if (b(t) === "oficial") return !0;
299
- const e = O(t);
300
- return this.global || !a.has(e) || this.individualAtiva(t.camadaId, e);
301
- }
302
- /** A prévia está sendo mostrada por pedido (global ou individual), e não só por falta de oficial? */
303
- previaSolicitada(t) {
304
- return this.global || this.individualAtiva(t.camadaId, O(t));
305
- }
306
- }
307
- const Kt = 24, Wt = 2, ct = (o) => typeof o == "number" && Number.isFinite(o), Z = (o) => Array.isArray(o) && o.length === 2 && ct(o[0]) && ct(o[1]);
308
- function _a(o, t) {
309
- return [2 * o[0] - t[0], 2 * o[1] - t[1]];
310
- }
311
- function ta(o) {
312
- return o.some((t) => t.entrada !== void 0 || t.saida !== void 0);
313
- }
314
- function yt(o, t) {
315
- return [o.saida ?? o.ponto, t.entrada ?? t.ponto];
316
- }
317
- function Ct(o, t) {
318
- const a = [];
319
- for (let e = 0; e < o - 1; e++) a.push([e, e + 1]);
320
- return t && o > 2 && a.push([o - 1, 0]), a;
321
- }
322
- function aa(o, t, a, e, i) {
323
- const n = 1 - i, s = n * n * n, r = 3 * n * n * i, c = 3 * n * i * i, l = i * i * i;
324
- return [s * o[0] + r * t[0] + c * a[0] + l * e[0], s * o[1] + r * t[1] + c * a[1] + l * e[1]];
325
- }
326
- function $a(o, t = !1, a = Kt) {
327
- if (o.length === 0) return [];
328
- const e = [[o[0].ponto[0], o[0].ponto[1]]];
329
- for (const [i, n] of Ct(o.length, t)) {
330
- const s = o[i], r = o[n];
331
- if (!(s.saida === void 0 && r.entrada === void 0)) {
332
- const [l, d] = yt(s, r);
333
- for (let h = 1; h < a; h++) e.push(aa(s.ponto, l, d, r.ponto, h / a));
334
- }
335
- n !== 0 && e.push([r.ponto[0], r.ponto[1]]);
336
- }
337
- return e;
338
- }
339
- function oa(o, t) {
340
- if (o.length === 0) return [];
341
- const a = [{ cmd: "M", pts: [o[0].ponto] }];
342
- for (const [e, i] of Ct(o.length, t)) {
343
- const n = o[e], s = o[i];
344
- if (n.saida === void 0 && s.entrada === void 0)
345
- a.push({ cmd: "L", pts: [s.ponto] });
346
- else {
347
- const [r, c] = yt(n, s);
348
- a.push({ cmd: "C", pts: [r, c, s.ponto] });
349
- }
350
- }
351
- return a;
352
- }
353
- function Ba(o, t, a) {
354
- const e = (n) => String(Math.round(n * 100) / 100), i = oa(o, t).map((n) => n.cmd + n.pts.map((s) => {
355
- const r = a(s);
356
- return `${e(r.x)} ${e(r.y)}`;
357
- }).join(" ")).join("");
358
- return i && t ? `${i}Z` : i;
359
- }
360
- function ka(o, t = Wt) {
361
- if (!Array.isArray(o) || o.length < t) return null;
362
- const a = [];
363
- for (const e of o) {
364
- if (!e || typeof e != "object" || !Z(e.ponto)) return null;
365
- const i = e, n = { ponto: [i.ponto[0], i.ponto[1]] };
366
- Z(i.entrada) && (n.entrada = [i.entrada[0], i.entrada[1]]), Z(i.saida) && (n.saida = [i.saida[0], i.saida[1]]), a.push(n);
367
- }
368
- return ta(a) ? a : null;
369
- }
370
- function qa(o, t) {
371
- return o.map((a) => {
372
- const e = { ponto: t(a.ponto) };
373
- return a.entrada && (e.entrada = t(a.entrada)), a.saida && (e.saida = t(a.saida)), e;
374
- });
375
- }
376
- function dt(o) {
377
- return o.tipo === "LineString" ? o.curva && o.curva.length >= 2 && !(o.partes && o.partes.length > 1) ? o.curva : null : o.tipo === "Polygon" && o.curva && o.curva.length >= 3 && o.aneis.length === 1 ? o.curva : null;
378
- }
379
- const q = 55, ea = 17, ia = 8;
380
- function St(o, t) {
381
- return t < ea && o > ia;
382
- }
383
- function na(o) {
384
- let t = 0, a = 0;
385
- for (const e of o)
386
- t += e.coordenada[0], a += e.coordenada[1];
387
- return [t / o.length, a / o.length];
388
- }
389
- function Ua(o, t, a) {
390
- if (!St(o.length, t)) return { clusters: [], isolados: o };
391
- const e = /* @__PURE__ */ new Map();
392
- for (const s of o) {
393
- const { x: r, y: c } = a(s.coordenada), l = `${t}:${Math.floor(r / q)}:${Math.floor(c / q)}`, d = e.get(l);
394
- d ? d.push(s) : e.set(l, [s]);
395
- }
396
- const i = [], n = [];
397
- for (const [s, r] of e)
398
- r.length === 1 ? n.push(r[0]) : i.push({ chave: s, coordenada: na(r), membros: r });
399
- return { clusters: i, isolados: n };
400
- }
401
- class sa {
402
- constructor(t, a) {
403
- M(this, "celulas", /* @__PURE__ */ new Map());
404
- M(this, "celulaDe", /* @__PURE__ */ new Map());
405
- /** Chaves das células com 2 ou mais pontos (as únicas que viram cluster). */
406
- M(this, "multiplas", /* @__PURE__ */ new Set());
407
- this.zoom = t, this.projetar = a;
408
- }
409
- /** Pontos agrupáveis na grade. */
410
- get total() {
411
- return this.celulaDe.size;
412
- }
413
- /** Chave da célula do ponto, ou `undefined` se ele não está na grade. */
414
- chaveDoPonto(t) {
415
- return this.celulaDe.get(t);
416
- }
417
- celula(t) {
418
- return this.celulas.get(t);
419
- }
420
- /** Só as células que viram cluster (2+ pontos). */
421
- *celulasAgrupadas() {
422
- for (const t of this.multiplas) {
423
- const a = this.celulas.get(t);
424
- a && (yield [t, a]);
425
- }
426
- }
427
- /** Está numa célula com 2 ou mais pontos (ou seja, dentro de um cluster)? */
428
- emCluster(t) {
429
- var e;
430
- const a = this.celulaDe.get(t);
431
- return a !== void 0 && (((e = this.celulas.get(a)) == null ? void 0 : e.membros.size) ?? 0) >= 2;
432
- }
433
- /** Insere (ou move) o ponto; devolve a chave da célula nova. */
434
- inserir(t) {
435
- this.remover(t.id);
436
- const { x: a, y: e } = this.projetar(t.coordenada), i = `${this.zoom}:${Math.floor(a / q)}:${Math.floor(e / q)}`;
437
- let n = this.celulas.get(i);
438
- return n || (n = { membros: /* @__PURE__ */ new Map(), somaLat: 0, somaLon: 0 }, this.celulas.set(i, n)), n.membros.set(t.id, t), n.somaLat += t.coordenada[0], n.somaLon += t.coordenada[1], n.membros.size >= 2 && this.multiplas.add(i), this.celulaDe.set(t.id, i), i;
439
- }
440
- /** Tira o ponto da grade; devolve a chave da célula de onde saiu. */
441
- remover(t) {
442
- const a = this.celulaDe.get(t);
443
- if (a === void 0) return;
444
- this.celulaDe.delete(t);
445
- const e = this.celulas.get(a), i = e == null ? void 0 : e.membros.get(t);
446
- return e && i && (e.membros.delete(t), e.somaLat -= i.coordenada[0], e.somaLon -= i.coordenada[1], e.membros.size < 2 && this.multiplas.delete(a), e.membros.size === 0 && this.celulas.delete(a)), a;
447
- }
448
- }
449
- const ra = 3, It = 0.75, lt = 85.0511287798, ca = 256;
450
- function Y(o, t, a) {
451
- const e = ca * 2 ** a, i = Math.max(-lt, Math.min(lt, o)), n = Math.sin(i * Math.PI / 180);
452
- return {
453
- x: (t + 180) / 360 * e,
454
- y: (0.5 - Math.log((1 + n) / (1 - n)) / (4 * Math.PI)) * e
455
- };
456
- }
457
- const da = (o) => Number.isFinite(o.minLat) && Number.isFinite(o.maxLat) && Number.isFinite(o.minLon) && Number.isFinite(o.maxLon) && o.minLat <= o.maxLat && o.minLon <= o.maxLon;
458
- function bt(o, t) {
459
- if (!Number.isFinite(t) || t < 0 || !da(o)) return NaN;
460
- const a = Y(o.minLat, o.minLon, t), e = Y(o.maxLat, o.maxLon, t);
461
- return Math.hypot(e.x - a.x, e.y - a.y);
462
- }
463
- function la(o, t, a = ra) {
464
- if (!o) return !1;
465
- const e = bt(o, t);
466
- return Number.isFinite(e) && e < a;
467
- }
468
- function ua(o) {
469
- return Number.isFinite(o) && o < 1.5 ? 1 : 2;
470
- }
471
- function ha(o) {
472
- const t = /* @__PURE__ */ new Map();
473
- for (const a of o) {
474
- const e = t.get(a.cor);
475
- e ? e.push(a) : t.set(a.cor, [a]);
476
- }
477
- return t;
478
- }
479
- const fa = "#38bdf8";
480
- function Va(o, t, a, e, i, n, s) {
481
- let r = 0;
482
- const c = ha(t);
483
- for (const [l, d] of c) {
484
- let h = !1;
485
- for (const u of d) {
486
- const g = Y(u.lat, u.lon, a), L = g.x - e, f = g.y - i;
487
- L >= -2 && f >= -2 && L <= n + 2 && f <= s + 2 && (h || (o.fillStyle = l || fa, o.globalAlpha = It, h = !0), o.fillRect(Math.round(L - u.lado / 2), Math.round(f - u.lado / 2), u.lado, u.lado), r++);
488
- }
489
- }
490
- return r;
491
- }
492
- const ma = [
493
- "continua",
494
- "tracejada",
495
- "tracejada-curta",
496
- "tracejada-longa",
497
- "pontilhada",
498
- "traco-ponto",
499
- "traco-ponto-ponto",
500
- "oculta",
501
- "centro",
502
- "fantasma",
503
- "divisa"
504
- ], pa = {
505
- tracejada: [12, 6],
506
- "tracejada-curta": [6, 4],
507
- "tracejada-longa": [24, 8],
508
- pontilhada: [0, 4],
509
- "traco-ponto": [12, 4, 0, 4],
510
- "traco-ponto-ponto": [12, 4, 0, 4, 0, 4],
511
- oculta: [6, 3],
512
- centro: [24, 4, 6, 4],
513
- fantasma: [24, 4, 6, 4, 6, 4],
514
- divisa: [12, 4, 12, 4, 0, 4]
515
- }, ut = { arredondada: "round", reta: "butt", quadrada: "square" }, ht = { arredondada: "round", chanfrada: "bevel", angular: "miter" }, ga = 0.05, va = 100, ft = {
516
- continuous: "continua",
517
- dashed: "tracejada",
518
- dashed2: "tracejada-curta",
519
- dashedx2: "tracejada-longa",
520
- dot: "pontilhada",
521
- dotted: "pontilhada",
522
- dashdot: "traco-ponto",
523
- divide: "traco-ponto-ponto",
524
- hidden: "oculta",
525
- center: "centro",
526
- phantom: "fantasma",
527
- border: "divisa"
528
- };
529
- function mt(o) {
530
- return typeof o == "string" && ma.includes(o);
531
- }
532
- function Ot(o) {
533
- if (mt(o)) return o;
534
- if (typeof o != "string") return;
535
- const t = o.trim().toLowerCase();
536
- return mt(t) ? t : Object.prototype.hasOwnProperty.call(ft, t) ? ft[t] : void 0;
537
- }
538
- function pt(o) {
539
- return typeof o == "string" && Object.prototype.hasOwnProperty.call(ut, o) ? ut[o] : void 0;
540
- }
541
- function gt(o) {
542
- return typeof o == "string" && Object.prototype.hasOwnProperty.call(ht, o) ? ht[o] : void 0;
543
- }
544
- function Ma(o) {
545
- return typeof o != "number" || !Number.isFinite(o) || o <= 0 ? 1 : Math.min(va, Math.max(ga, o));
546
- }
547
- function vt(o, t, a = 1, e = "round") {
548
- const i = Ot(o);
549
- if (!i || i === "continua") return;
550
- const n = Number.isFinite(t) && t > 0 ? t : 1, s = Ma(a) * Math.max(1, n / 2), r = e === "butt" ? n : 0, c = e === "butt" ? 0 : n;
551
- return pa[i].map((l, d) => {
552
- const h = d % 2 === 0 ? l === 0 ? r : l * s : l * s + c;
553
- return Math.round(h * 100) / 100;
554
- }).join(" ");
555
- }
556
- const U = "#38bdf8", La = "#38bdf8", xa = /^(#[0-9a-f]{3,8}|(rgb|hsl)a?\([0-9.,%\s\/-]+\)|[a-z]{3,20})$/i;
557
- function B(o, t) {
558
- return typeof o == "string" && xa.test(o.trim()) ? o.trim() : t;
559
- }
560
- const I = (o) => typeof o == "number" && Number.isFinite(o);
561
- function Mt(o, t, a = !1) {
562
- const e = o.estilo ?? {}, i = B(e.corTraco ?? t.corPrimaria, U), n = o.geometria.tipo, s = n === "Polygon" || n === "Circle", r = n === "Point", c = r && B(e.corContorno, "") || i, l = r && I(e.espessuraContorno) && e.espessuraContorno >= 0 ? e.espessuraContorno : void 0, d = l ?? (I(e.espessuraTraco) ? e.espessuraTraco : void 0) ?? (I(t.espessuraLinha) ? t.espessuraLinha : 2), h = I(e.opacidadePreenchimento) ? e.opacidadePreenchimento : s ? 0.2 : 0.85, u = a ? d + 2 : d, g = pt(e.terminacaoTraco) ?? pt(t.terminacaoLinha) ?? "round", L = I(e.opacidadeTraco) ? e.opacidadeTraco : I(t.opacidadeLinha) ? t.opacidadeLinha : 1;
563
- return {
564
- cor: a ? La : c,
565
- traco: !(l === 0 && !a),
566
- peso: u,
567
- dash: Pa(o, t, u, g),
568
- // selecionada fica opaca: a seleção precisa aparecer mesmo numa linha quase transparente
569
- opacidadeTraco: a ? 1 : Math.min(1, Math.max(0, L)),
570
- terminacao: g,
571
- juncao: gt(e.juncaoTraco) ?? gt(t.juncaoLinha) ?? "round",
572
- deslocamentoDash: I(e.deslocamentoTracejado) ? e.deslocamentoTracejado : 0,
573
- preencher: s || r,
574
- corPreenchimento: B(e.corPreenchimento, i),
575
- opacidadePreenchimento: a ? Math.min(1, h + 0.18) : h
576
- };
577
- }
578
- function Pa(o, t, a, e) {
579
- const i = o.estilo ?? {};
580
- if (i.dashArray) return i.dashArray;
581
- if (i.tipoLinha !== void 0 && i.tipoLinha !== null) {
582
- const n = vt(i.tipoLinha, a, i.escalaTipoLinha ?? t.escalaTipoLinha, e);
583
- if (n || Ot(i.tipoLinha) === "continua") return n;
584
- }
585
- return b(o) === "previa" ? "6 4" : t.dashArray ? t.dashArray : vt(t.tipoLinha, a, t.escalaTipoLinha, e);
586
- }
587
- function Aa(o, t) {
588
- var e;
589
- const a = ((e = o.estilo) == null ? void 0 : e.tamanhoIcone) ?? t.tamanhoMarcador ?? 8;
590
- return (I(a) && a > 0 ? a : 8) / 2;
591
- }
592
- class Da {
593
- constructor() {
594
- M(this, "porChave", /* @__PURE__ */ new Map());
595
- }
596
- interno(t) {
597
- const a = `${t.cor}|${t.traco ? 1 : 0}|${t.peso}|${t.dash ?? ""}|${t.opacidadeTraco ?? 1}|${t.terminacao ?? ""}|${t.juncao ?? ""}|${t.deslocamentoDash ?? 0}|${t.preencher ? 1 : 0}|${t.corPreenchimento}|${t.opacidadePreenchimento}`, e = this.porChave.get(a);
598
- return e || (this.porChave.set(a, t), t);
599
- }
600
- limpar() {
601
- this.porChave.clear();
602
- }
603
- }
604
- const ya = 0.3, Lt = (o) => !!o && typeof o.id == "string" && !!o.geometria && typeof o.geometria.tipo == "string";
605
- class Ca {
606
- constructor() {
607
- M(this, "loja", /* @__PURE__ */ new Map());
608
- M(this, "indice", new Xt());
609
- /** Muda a cada alteração dos dados (invalida cache de geometria por feição). */
610
- M(this, "revisao", 0);
611
- /** Muda quando o agrupamento e a contagem de pontos precisam ser refeitos do zero. */
612
- M(this, "revisaoBase", 0);
613
- M(this, "listaSincronizada", null);
614
- /** Entidades com geometria oficial, e quantas oficiais cada uma tem. */
615
- M(this, "oficiais", /* @__PURE__ */ new Set());
616
- M(this, "contOficiais", /* @__PURE__ */ new Map());
617
- /** Entidade -> quantas prévias (entidade com oficial E prévia forma um par: sempre em detalhe completo). */
618
- M(this, "contPrevias", /* @__PURE__ */ new Map());
619
- M(this, "nPrevias", 0);
620
- M(this, "selecionadas", /* @__PURE__ */ new Set());
621
- M(this, "regra", null);
622
- /** Revisão por feição (id → número crescente): chave do cache de geometria projetada. */
623
- M(this, "revisaoDe", /* @__PURE__ */ new Map());
624
- M(this, "contador", 0);
625
- }
626
- revisaoDaFeicao(t) {
627
- return this.revisaoDe.get(t) ?? 0;
628
- }
629
- /** Aparece segundo a regra (não oculta e visível por versão)? */
630
- desenhavel(t) {
631
- return t.oculta ? !1 : !this.regra || this.regra(t, this.oficiais);
632
- }
633
- /** Visível pela regra de versões (ignora `oculta`: o hit-test e a seleção seguem regras próprias). */
634
- visivelPorVersao(t) {
635
- return !this.regra || this.regra(t, this.oficiais);
636
- }
637
- /** Troca total: diferencia contra a loja, mantém o índice e a contabilidade de versões. */
638
- sincronizar(t) {
639
- const a = t.filter((s) => Lt(s) && !s.excluida), e = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set();
640
- for (const s of a)
641
- i.add(s.id), this.loja.get(s.id) !== s && e.add(s.id);
642
- const n = [...this.loja.keys()].filter((s) => !i.has(s));
643
- if (e.size > 0 || n.length > 0) {
644
- if (this.revisao++, this.revisaoBase++, this.loja.size === 0 || e.size + n.length > a.length * ya)
645
- this.indice.construir(a);
646
- else {
647
- for (const s of a) e.has(s.id) && this.indice.atualizar(s);
648
- for (const s of n) this.indice.remover(s);
649
- }
650
- this.loja.clear();
651
- for (const s of a) this.loja.set(s.id, s);
652
- for (const s of n) this.revisaoDe.delete(s);
653
- for (const s of e) this.revisaoDe.set(s, ++this.contador);
654
- this.recontarOficiais();
655
- }
656
- this.listaSincronizada = t;
657
- for (const s of [...this.selecionadas]) i.has(s) || this.selecionadas.delete(s);
658
- return { mudadas: [...e], removidas: n, oficiaisMudou: !1 };
659
- }
660
- recontarOficiais() {
661
- this.contOficiais = /* @__PURE__ */ new Map(), this.contPrevias = /* @__PURE__ */ new Map(), this.nPrevias = 0;
662
- for (const t of this.loja.values()) {
663
- if (b(t) !== "oficial") {
664
- this.nPrevias++;
665
- const e = O(t);
666
- this.contPrevias.set(e, (this.contPrevias.get(e) ?? 0) + 1);
667
- continue;
668
- }
669
- const a = O(t);
670
- this.contOficiais.set(a, (this.contOficiais.get(a) ?? 0) + 1);
671
- }
672
- this.oficiais = new Set(this.contOficiais.keys());
673
- }
674
- /** Aplica só a diferença. Devolve `null` se o delta não parte da lista sincronizada (então use `sincronizar`). */
675
- aplicarDelta(t, a) {
676
- if (!a || a.base !== this.listaSincronizada) return null;
677
- const e = /* @__PURE__ */ new Map(), i = (d, h) => {
678
- if (!d || d.excluida || b(d) !== "oficial") return;
679
- const u = O(d);
680
- e.has(u) || e.set(u, this.oficiais.has(u));
681
- const g = (this.contOficiais.get(u) ?? 0) + h;
682
- g <= 0 ? (this.contOficiais.delete(u), this.oficiais.delete(u)) : (this.contOficiais.set(u, g), this.oficiais.add(u));
683
- }, n = (d, h) => {
684
- const u = O(d), g = (this.contPrevias.get(u) ?? 0) + h;
685
- g <= 0 ? this.contPrevias.delete(u) : this.contPrevias.set(u, g);
686
- }, s = [], r = [], c = (d) => {
687
- const h = this.loja.get(d);
688
- h && (b(h) === "previa" && (this.nPrevias--, n(h, -1)), i(h, -1), this.loja.delete(d), this.indice.remover(d), this.selecionadas.delete(d), this.revisaoDe.delete(d), r.push(d));
689
- };
690
- for (const d of a.removidas ?? []) c(d);
691
- for (const d of a.mudadas ?? []) {
692
- if (!Lt(d)) continue;
693
- if (d.excluida) {
694
- c(d.id);
695
- continue;
696
- }
697
- const h = this.loja.get(d.id);
698
- b(d) === "previa" && (this.nPrevias++, n(d, 1)), h && (b(h) === "previa" && (this.nPrevias--, n(h, -1)), i(h, -1)), this.loja.set(d.id, d), this.indice.atualizar(d), i(d, 1), this.revisaoDe.set(d.id, ++this.contador), s.push(d.id);
699
- }
700
- let l = !1;
701
- if (this.nPrevias > 0)
702
- for (const [d, h] of e) h !== this.oficiais.has(d) && (l = !0);
703
- return this.listaSincronizada = t, this.revisao++, l && this.revisaoBase++, { mudadas: s, removidas: r, oficiaisMudou: l };
704
- }
705
- }
706
- const Sa = 256, N = 85.0511287798, Ia = 4007501668557849e-8;
707
- function jt(o, t, a, e, i) {
708
- const n = a > N ? N : a < -N ? -N : a, s = Math.sin(n * Math.PI / 180);
709
- o[t] = (e + 180) / 360 * i, o[t + 1] = (0.5 - Math.log((1 + s) / (1 - s)) / (4 * Math.PI)) * i;
710
- }
711
- const V = (o) => Sa * 2 ** o;
712
- function Xa(o, t, a) {
713
- const e = V(a);
714
- return [Math.atan(Math.sinh(Math.PI * (1 - 2 * t / e))) * 180 / Math.PI, o / e * 360 - 180];
715
- }
716
- function xt(o, t) {
717
- const a = V(t), e = new Float64Array(o.length * 2);
718
- for (let i = 0; i < o.length; i++) {
719
- const n = o[i];
720
- jt(e, i * 2, n[0], n[1], a);
721
- }
722
- return e;
723
- }
724
- function E(o, t, a) {
725
- const e = new Float64Array(2);
726
- return jt(e, 0, o, t, V(a)), e;
727
- }
728
- function ba(o, t) {
729
- const a = Math.max(-N, Math.min(N, o));
730
- return Ia * Math.cos(a * Math.PI / 180) / V(t);
731
- }
732
- function Oa(o, t, a) {
733
- const e = ba(o, a), i = t / e;
734
- return Number.isFinite(i) && i >= 0 ? i : 0;
735
- }
736
- function Ga(o) {
737
- let t = 1 / 0, a = 1 / 0, e = -1 / 0, i = -1 / 0;
738
- for (const n of o)
739
- for (let s = 0; s + 1 < n.length; s += 2) {
740
- const r = n[s], c = n[s + 1];
741
- Number.isFinite(r) && Number.isFinite(c) && (r < t && (t = r), r > e && (e = r), c < a && (a = c), c > i && (i = c));
742
- }
743
- return t <= e && a <= i ? { minX: t, minY: a, maxX: e, maxY: i } : null;
744
- }
745
- function ja(o, t, a, e, i, n) {
746
- const s = i - a, r = n - e, c = s * s + r * r;
747
- let l = c === 0 ? 0 : ((o - a) * s + (t - e) * r) / c;
748
- return l = l < 0 ? 0 : l > 1 ? 1 : l, Math.hypot(o - (a + l * s), t - (e + l * r));
749
- }
750
- function Pt(o, t, a) {
751
- const e = o.length >> 1;
752
- if (!(t > 0) || e < 3) return o;
753
- let i = o, n = e;
754
- a && (i = new Float64Array((e + 1) * 2), i.set(o), i[e * 2] = o[0], i[e * 2 + 1] = o[1], n = e + 1);
755
- const s = new Uint8Array(n);
756
- s[0] = 1, s[n - 1] = 1;
757
- const r = [0, n - 1];
758
- for (; r.length > 0; ) {
759
- const u = r.pop(), g = r.pop();
760
- let L = 0, f = -1;
761
- const m = i[g * 2], x = i[g * 2 + 1], w = i[u * 2], S = i[u * 2 + 1];
762
- for (let y = g + 1; y < u; y++) {
763
- const v = ja(i[y * 2], i[y * 2 + 1], m, x, w, S);
764
- v > L && (L = v, f = y);
765
- }
766
- f !== -1 && L > t && (s[f] = 1, r.push(g, f, f, u));
767
- }
768
- const c = a ? n - 1 : n;
769
- let l = 0;
770
- for (let u = 0; u < c; u++) s[u] && l++;
771
- if (a && l < 3 || l === c) return o;
772
- const d = new Float64Array(l * 2);
773
- let h = 0;
774
- for (let u = 0; u < c; u++)
775
- s[u] && (d[h++] = i[u * 2], d[h++] = i[u * 2 + 1]);
776
- return d;
777
- }
778
- const Na = 1.2, z = 1e-9, wa = 6, _ = {
779
- cor: U,
780
- traco: !1,
781
- peso: 0,
782
- dash: void 0,
783
- preencher: !1,
784
- corPreenchimento: U,
785
- opacidadePreenchimento: 0
786
- }, H = (o) => !!o && Number.isFinite(o.zoom) && o.zoom >= 0 && !!o.caixa && Number.isFinite(o.caixa.minLat) && Number.isFinite(o.caixa.maxLat) && Number.isFinite(o.caixa.minLon) && Number.isFinite(o.caixa.maxLon);
787
- class Za {
788
- constructor() {
789
- M(this, "camadas", /* @__PURE__ */ new Map());
790
- M(this, "regra", null);
791
- }
792
- // ---------------------------------------------------------------- camadas
793
- /** Cria a camada ou atualiza a definição (estilo, zIndex, opacidade, visibilidade). */
794
- definirCamada(t) {
795
- if (!t || typeof t.id != "string") return;
796
- let a = this.camadas.get(t.id);
797
- if (!a) {
798
- a = {
799
- def: t,
800
- dados: new Ca(),
801
- zoomCache: -1,
802
- geom: /* @__PURE__ */ new Map(),
803
- estilos: /* @__PURE__ */ new Map(),
804
- lod: /* @__PURE__ */ new Map(),
805
- avaliacoesLOD: 0,
806
- agrupador: null,
807
- agrupadorRev: -1,
808
- nPontos: 0,
809
- nPontosRev: -1,
810
- previas: /* @__PURE__ */ new Map(),
811
- destaques: /* @__PURE__ */ new Set(),
812
- revEstilo: 0,
813
- internador: new Da(),
814
- ultima: { total: 0, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: 0 }
815
- }, a.dados.regra = this.regra, this.camadas.set(t.id, a);
816
- return;
817
- }
818
- const e = JSON.stringify(a.def.estilo) !== JSON.stringify(t.estilo);
819
- a.def = t, e && (a.revEstilo++, a.estilos.clear(), a.internador.limpar());
820
- }
821
- removerCamada(t) {
822
- this.camadas.delete(t);
823
- }
824
- temCamada(t) {
825
- return this.camadas.has(t);
826
- }
827
- definirRegra(t) {
828
- this.regra = t;
829
- for (const a of this.camadas.values()) a.dados.regra = t;
830
- }
831
- /** A regra de versões mudou (prévias ligadas/desligadas): o conjunto desenhado e o agrupamento precisam ser refeitos. */
832
- reavaliarVersoes(t) {
833
- const a = this.camadas.get(t);
834
- a && (a.dados.revisao++, a.dados.revisaoBase++);
835
- }
836
- // ---------------------------------------------------------------- dados
837
- /** Troca total dos dados da camada (diferencia contra o que já existe). */
838
- definirFeicoes(t, a) {
839
- const e = this.camadas.get(t);
840
- if (!e) return;
841
- const i = Array.isArray(a) ? a : [], n = e.dados.sincronizar(i);
842
- this.aposMudanca(e, n.mudadas, n.removidas, !0);
843
- }
844
- /**
845
- * Mudança incremental: só vale se `delta.base` for a lista sincronizada por último; senão a camada é refeita
846
- * por inteiro a partir de `lista`.
847
- */
848
- aplicarDelta(t, a, e) {
849
- const i = this.camadas.get(t);
850
- if (!i) return;
851
- const n = Array.isArray(a) ? a : [], s = /* @__PURE__ */ new Map();
852
- if (e) {
853
- for (const l of e.removidas ?? []) s.set(l, this.pontoVisivel(i, i.dados.loja.get(l)));
854
- for (const l of e.mudadas ?? []) l && typeof l.id == "string" && s.set(l.id, this.pontoVisivel(i, i.dados.loja.get(l.id)));
855
- }
856
- const r = i.dados.aplicarDelta(n, e);
857
- if (!r) {
858
- this.definirFeicoes(t, n);
859
- return;
860
- }
861
- let c = i.nPontos;
862
- for (const [l, d] of s) {
863
- const h = this.pontoVisivel(i, i.dados.loja.get(l));
864
- c += (h ? 1 : 0) - (d ? 1 : 0);
865
- }
866
- i.nPontos = Math.max(0, c), this.aposMudanca(i, r.mudadas, r.removidas, r.oficiaisMudou), r.oficiaisMudou || this.manterAgrupador(i, r.mudadas, r.removidas);
867
- }
868
- pontoVisivel(t, a) {
869
- var e;
870
- return !!a && ((e = a.geometria) == null ? void 0 : e.tipo) === "Point" && t.dados.desenhavel(a);
871
- }
872
- aposMudanca(t, a, e, i) {
873
- for (const n of a)
874
- t.lod.delete(n), t.geom.delete(n), t.estilos.delete(n), t.previas.delete(n);
875
- for (const n of e)
876
- t.lod.delete(n), t.geom.delete(n), t.estilos.delete(n), t.previas.delete(n), t.destaques.delete(n);
877
- i && (t.agrupador = null);
878
- }
879
- /** O agrupador do zoom atual acompanha os pontos que mudaram (células afetadas, sem reagrupar a camada). */
880
- manterAgrupador(t, a, e) {
881
- const i = t.agrupador;
882
- if (i) {
883
- for (const n of e) i.remover(n);
884
- for (const n of a) {
885
- const s = t.dados.loja.get(n);
886
- s && s.geometria.tipo === "Point" && t.dados.desenhavel(s) ? i.inserir({ id: n, coordenada: s.geometria.coordenada }) : i.remover(n);
887
- }
888
- }
889
- }
890
- // ---------------------------------------------------------------- seleção e edição
891
- /** Define a seleção da camada. Devolve quem entrou e quem saiu (só o que mudou). */
892
- selecionar(t, a) {
893
- const e = this.camadas.get(t);
894
- if (!e) return { entrou: [], saiu: [] };
895
- const i = /* @__PURE__ */ new Set();
896
- for (const r of a) e.dados.loja.has(r) && i.add(r);
897
- const n = [], s = [];
898
- for (const r of i) e.dados.selecionadas.has(r) || n.push(r);
899
- for (const r of e.dados.selecionadas) i.has(r) || s.push(r);
900
- e.dados.selecionadas.clear();
901
- for (const r of i) e.dados.selecionadas.add(r);
902
- return { entrou: n, saiu: s };
903
- }
904
- selecionadas(t) {
905
- var a;
906
- return ((a = this.camadas.get(t)) == null ? void 0 : a.dados.selecionadas) ?? /* @__PURE__ */ new Set();
907
- }
908
- /** Geometria provisória (arrasto de vértice): o canvas base deixa de desenhar a feição e a sobreposição a mostra. */
909
- previsualizar(t, a) {
910
- const e = this.camadas.get(t);
911
- !e || !a || typeof a.id != "string" || !e.dados.loja.has(a.id) || e.previas.set(a.id, a);
912
- }
913
- temPrevia(t, a) {
914
- var e;
915
- return ((e = this.camadas.get(t)) == null ? void 0 : e.previas.has(a)) ?? !1;
916
- }
917
- /** Realce temporário (hover): as feições entram na sobreposição com `destaque: true`. */
918
- destacar(t, a) {
919
- const e = this.camadas.get(t);
920
- e && (e.destaques = new Set(a));
921
- }
922
- // ---------------------------------------------------------------- consultas (geometria original)
923
- feicao(t, a) {
924
- var e;
925
- return (e = this.camadas.get(t)) == null ? void 0 : e.dados.loja.get(a);
926
- }
927
- caixaDe(t, a) {
928
- var e;
929
- return (e = this.camadas.get(t)) == null ? void 0 : e.dados.indice.caixaDe(a);
930
- }
931
- /** Feições cujo envelope toca `caixa`, sem as ocultas (snap, hit-test, seleção por caixa). Não passa pelo LOD. */
932
- consultarCaixa(t, a) {
933
- const e = this.camadas.get(t);
934
- if (!e) return [];
935
- const i = [];
936
- for (const n of e.dados.indice.consultar(a)) {
937
- const s = e.dados.loja.get(n);
938
- s && !s.oculta && i.push(s);
939
- }
940
- return i;
941
- }
942
- feicaoVisivel(t, a) {
943
- const e = this.camadas.get(t);
944
- return !e || e.dados.visivelPorVersao(a);
945
- }
946
- estatisticas(t) {
947
- const a = this.camadas.get(t);
948
- return a ? { ...a.ultima, total: a.dados.loja.size, avaliacoesLOD: a.avaliacoesLOD } : null;
949
- }
950
- /** Entidades da camada com prévia e com oficial (pares em detalhe completo): para testes e diagnóstico. */
951
- ehPar(t, a) {
952
- const e = this.camadas.get(t);
953
- return !!e && this.emPar(e, a);
954
- }
955
- // ---------------------------------------------------------------- lista de desenho
956
- /**
957
- * O que desenhar nesta vista, camada a camada, na ordem de empilhamento (a última fica por cima).
958
- * `parte`: `'canvas'` só o que se pinta no canvas (marcas, formas, pontos sem ícone), `'dom'` só marcadores DOM e
959
- * curvas (clusters, ícones, textos, rótulos), `'tudo'` (padrão) os dois. O pan incremental pede o canvas só das faixas
960
- * expostas e o DOM da vista inteira (poucos itens, sem projetar nem simplificar formas).
961
- */
962
- listaDesenho(t, a) {
963
- const e = this.origemDe(t), i = { vista: t, origem: e, camadas: [] };
964
- if (!H(t)) return i;
965
- const n = a != null && a.camadas ? new Set(a.camadas) : null, s = [...this.camadas.values()].filter((r) => r.def.visivel && (!n || n.has(r.def.id)));
966
- s.sort((r, c) => r.def.zIndex - c.def.zIndex);
967
- for (const r of s)
968
- try {
969
- i.camadas.push(this.listarCamada(r, t, (a == null ? void 0 : a.parte) ?? "tudo"));
970
- } catch {
971
- i.camadas.push(this.camadaVazia(r));
972
- }
973
- return i;
974
- }
975
- origemDe(t) {
976
- if (t != null && t.origemPx && Number.isFinite(t.origemPx.x) && Number.isFinite(t.origemPx.y)) return t.origemPx;
977
- if (!H(t)) return { x: 0, y: 0 };
978
- const a = E(t.caixa.maxLat, t.caixa.minLon, t.zoom);
979
- return { x: a[0], y: a[1] };
980
- }
981
- camadaVazia(t) {
982
- return {
983
- camadaId: t.def.id,
984
- zIndex: t.def.zIndex,
985
- opacidade: t.def.opacidade,
986
- itens: [],
987
- estatisticas: { total: t.dados.loja.size, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: t.avaliacoesLOD }
988
- };
989
- }
990
- prepararZoom(t, a) {
991
- a !== t.zoomCache && (t.geom.clear(), t.lod.clear(), t.zoomCache = a);
992
- }
993
- estiloDe(t, a) {
994
- const e = t.dados.revisaoDaFeicao(a.id), i = t.estilos.get(a.id);
995
- if (i && i.rev === e && i.revEstilo === t.revEstilo) return i.estilo;
996
- const n = t.internador.interno(Mt(a, t.def.estilo, !1));
997
- return t.estilos.set(a.id, { rev: e, revEstilo: t.revEstilo, estilo: n }), n;
998
- }
999
- emPar(t, a) {
1000
- if (t.dados.contPrevias.size === 0) return !1;
1001
- const e = O(a);
1002
- return t.dados.contPrevias.has(e) && t.dados.oficiais.has(e);
1003
- }
1004
- /**
1005
- * Vira marca? Sempre em detalhe completo: com rótulo e em par oficial × prévia; ponto e texto nunca. A seleção NÃO
1006
- * entra aqui: o canvas base não depende dela (a sobreposição desenha a selecionada em detalhe completo por cima).
1007
- */
1008
- comoMarca(t, a, e) {
1009
- var r;
1010
- const i = a.geometria.tipo;
1011
- if (i === "Point" || i === "Text" || (r = a.estilo) != null && r.mostrarRotulo || this.emPar(t, a)) return !1;
1012
- const n = t.lod.get(a.id);
1013
- if (n !== void 0) return n;
1014
- t.avaliacoesLOD++;
1015
- const s = la(t.dados.indice.caixaDe(a.id), e);
1016
- return t.lod.set(a.id, s), s;
1017
- }
1018
- /** Geometria projetada e simplificada em px, em cache por (feição, revisão, zoom). `null` se não há o que desenhar. */
1019
- geometriaProjetada(t, a, e) {
1020
- const i = t.dados.revisaoDaFeicao(a.id), n = t.geom.get(a.id);
1021
- if (n && n.rev === i) return n;
1022
- const s = this.construirGeometria(t, a, e, i);
1023
- return s && t.geom.set(a.id, s), s;
1024
- }
1025
- construirGeometria(t, a, e, i) {
1026
- const n = a.geometria, s = e < At ? Na : 0;
1027
- if (n.tipo === "Polygon") {
1028
- const r = [];
1029
- for (const c of n.aneis ?? []) {
1030
- if (!Array.isArray(c) || c.length < 3) continue;
1031
- let l = xt(c, e);
1032
- s > 0 && c.length >= J && (l = Pt(l, s, !0)), r.push(l);
1033
- }
1034
- return r.length > 0 ? { rev: i, partes: r, raioPx: 0, marca: !1 } : null;
1035
- }
1036
- if (n.tipo === "LineString") {
1037
- const r = [];
1038
- for (const c of F(n)) {
1039
- if (!Array.isArray(c) || c.length < 2) continue;
1040
- let l = xt(c, e);
1041
- s > 0 && c.length >= J && (l = Pt(l, s, !1)), r.push(l);
1042
- }
1043
- return r.length > 0 ? { rev: i, partes: r, raioPx: 0, marca: !1 } : null;
1044
- }
1045
- if (n.tipo === "Circle") {
1046
- const r = n.centro;
1047
- if (!Array.isArray(r)) return null;
1048
- const c = E(r[0], r[1], e);
1049
- return { rev: i, partes: [c], raioPx: Oa(r[0], n.raioMetros, e), marca: !1 };
1050
- }
1051
- return n.tipo === "Point" || n.tipo === "Text" ? { rev: i, partes: [E(n.coordenada[0], n.coordenada[1], e)], raioPx: n.tipo === "Point" ? Aa(a, t.def.estilo) : 0, marca: !1 } : null;
1052
- }
1053
- /** Marca de LOD: centro do envelope, lado de 1–2 px, cor do preenchimento/contorno. */
1054
- marcaDe(t, a, e) {
1055
- const i = t.dados.revisaoDaFeicao(a.id), n = t.geom.get(a.id);
1056
- if (n && n.rev === i) return n;
1057
- const s = t.dados.indice.caixaDe(a.id);
1058
- if (!s) return null;
1059
- const r = E((s.minLat + s.maxLat) / 2, (s.minLon + s.maxLon) / 2, e);
1060
- if (!(Number.isFinite(r[0]) && Number.isFinite(r[1]))) return null;
1061
- const c = { rev: i, partes: [r], raioPx: ua(bt(s, e)), marca: !0 };
1062
- return t.geom.set(a.id, c), c;
1063
- }
1064
- /**
1065
- * Item da marca, em cache junto com a geometria por (feição, zoom). Com 100 mil marcas na tela, montar o item e internar
1066
- * o estilo a cada vista custava a maior parte da lista; no pan agora só se confere se algo mudou, sem alocar.
1067
- */
1068
- itemMarca(t, a, e) {
1069
- const i = this.marcaDe(t, a, e);
1070
- if (!i) return null;
1071
- const n = i.item;
1072
- if (n && n.feicao === a && i.revEstilo === t.revEstilo && n.selecionada === t.dados.selecionadas.has(a.id) && n.destaque === !0 === t.destaques.has(a.id)) return n;
1073
- const s = this.itemBase(t, a, "marca", i.partes, i.raioPx, this.estiloMarca(t, a));
1074
- return i.item = s, i.revEstilo = t.revEstilo, s;
1075
- }
1076
- estiloMarca(t, a) {
1077
- const e = a.estilo ?? {}, i = B(e.corPreenchimento ?? e.corTraco ?? t.def.estilo.corPrimaria, U);
1078
- return t.internador.interno({ cor: i, traco: !1, peso: 0, dash: void 0, preencher: !0, corPreenchimento: i, opacidadePreenchimento: It });
1079
- }
1080
- agrupadorAtivo(t, a) {
1081
- const { dados: e } = t;
1082
- if (t.nPontosRev !== e.revisaoBase) {
1083
- let s = 0;
1084
- for (const r of e.loja.values()) r.geometria.tipo === "Point" && e.desenhavel(r) && s++;
1085
- t.nPontos = s, t.nPontosRev = e.revisaoBase;
1086
- }
1087
- if (!St(t.nPontos, a))
1088
- return t.agrupador = null, null;
1089
- const i = t.agrupador;
1090
- if (i && i.zoom === a && t.agrupadorRev === e.revisaoBase) return i;
1091
- const n = new sa(a, (s) => {
1092
- const r = E(s[0], s[1], a);
1093
- return { x: r[0], y: r[1] };
1094
- });
1095
- for (const s of e.loja.values())
1096
- s.geometria.tipo === "Point" && e.desenhavel(s) && n.inserir({ id: s.id, coordenada: s.geometria.coordenada });
1097
- return t.agrupador = n, t.agrupadorRev = e.revisaoBase, n;
1098
- }
1099
- itemBase(t, a, e, i, n, s) {
1100
- return {
1101
- camadaId: t.def.id,
1102
- id: a.id,
1103
- forma: e,
1104
- geometriaEmPx: i,
1105
- raioPx: n,
1106
- estilo: s,
1107
- selecionada: t.dados.selecionadas.has(a.id),
1108
- feicao: a,
1109
- ...t.destaques.has(a.id) ? { destaque: !0 } : {}
1110
- };
1111
- }
1112
- /**
1113
- * A caixa da vista com uma folga de poucos px: o traço de uma feição com o envelope logo fora da vista ainda entra nela
1114
- * (o índice é por envelope). Sem isto, o pan incremental e o quadro completo divergem na borda do canvas.
1115
- */
1116
- caixaComFolga(t) {
1117
- const a = t.caixa, i = 360 / (256 * 2 ** t.zoom) * wa, n = i * Math.cos((a.minLat + a.maxLat) / 2 * Math.PI / 180);
1118
- return { minLat: a.minLat - n, maxLat: a.maxLat + n, minLon: a.minLon - i, maxLon: a.maxLon + i };
1119
- }
1120
- listarCamada(t, a, e) {
1121
- var y;
1122
- const { dados: i, def: n } = t, s = e !== "dom", r = e !== "canvas", c = a.zoom;
1123
- this.prepararZoom(t, c);
1124
- const l = i.indice.consultar(this.caixaComFolga(a)), d = this.agrupadorAtivo(t, c), h = [], u = [], g = [], L = [], f = [], m = { total: i.loja.size, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: 0 }, x = (v) => {
1125
- var A;
1126
- if (!r || !((A = v.estilo) != null && A.mostrarRotulo) || v.geometria.tipo === "Text") return;
1127
- const p = kt(v, v.estilo.campoRotulo), P = i.indice.caixaDe(v.id);
1128
- !p || !P || (f.push({
1129
- camadaId: n.id,
1130
- id: `rotulo:${v.id}`,
1131
- forma: "rotulo",
1132
- geometriaEmPx: [],
1133
- raioPx: 0,
1134
- estilo: _,
1135
- selecionada: !1,
1136
- feicao: v,
1137
- texto: p,
1138
- coordenada: [(P.minLat + P.maxLat) / 2, (P.minLon + P.maxLon) / 2]
1139
- }), m.marcadoresDom++);
1140
- }, w = (v) => {
1141
- var A;
1142
- const p = v.geometria;
1143
- if (p.tipo !== "Point") return;
1144
- if ((A = v.estilo) != null && A.icone) {
1145
- if (!r) return;
1146
- f.push({ ...this.itemBase(t, v, "icone", [], 0, _), coordenada: p.coordenada }), m.marcadoresDom++;
1147
- return;
1148
- }
1149
- if (!s) return;
1150
- const P = this.geometriaProjetada(t, v, c);
1151
- P && (L.push(this.itemBase(t, v, "ponto", P.partes, P.raioPx, this.estiloDe(t, v))), m.desenhadas++);
1152
- };
1153
- for (const v of l) {
1154
- const p = i.loja.get(v);
1155
- if (!p || !i.desenhavel(p) || t.previas.has(v)) continue;
1156
- const P = p.geometria;
1157
- if (P.tipo === "Point") {
1158
- if (d && d.emCluster(v) && (!((y = p.estilo) != null && y.icone) || !r || !this.soltoDoCluster(t, d, v)))
1159
- continue;
1160
- w(p), x(p);
1161
- continue;
1162
- }
1163
- if (P.tipo === "Text") {
1164
- if (!r) continue;
1165
- f.push({ ...this.itemBase(t, p, "texto", [], 0, _), coordenada: P.coordenada }), m.marcadoresDom++;
1166
- continue;
1167
- }
1168
- if (dt(P)) {
1169
- if (!r) continue;
1170
- f.push(this.itemBase(t, p, "curva", [], 0, this.estiloDe(t, p))), m.marcadoresDom++, x(p);
1171
- continue;
1172
- }
1173
- if (!s) {
1174
- x(p);
1175
- continue;
1176
- }
1177
- const A = t.geom.get(v), C = A == null ? void 0 : A.item;
1178
- if (C && C.feicao === p && A.revEstilo === t.revEstilo && !this.emPar(t, p) && C.selecionada === i.selecionadas.has(v) && C.destaque === !0 === t.destaques.has(v)) {
1179
- h.push(C), m.marcasLOD++;
1180
- continue;
1181
- }
1182
- if (this.comoMarca(t, p, c)) {
1183
- const K = this.itemMarca(t, p, c);
1184
- K && (h.push(K), m.marcasLOD++);
1185
- continue;
1186
- }
1187
- const j = this.geometriaProjetada(t, p, c);
1188
- if (!j) continue;
1189
- const X = this.estiloDe(t, p);
1190
- P.tipo === "LineString" ? g.push(this.itemBase(t, p, "linha", j.partes, 0, X)) : P.tipo === "Circle" ? u.push(this.itemBase(t, p, "circulo", j.partes, j.raioPx, X)) : u.push(this.itemBase(t, p, "poligono", j.partes, 0, X)), m.desenhadas++, x(p);
1191
- }
1192
- d && r && this.listarClusters(t, a, d, f, m, r), m.avaliacoesLOD = t.avaliacoesLOD, e === "tudo" && (t.ultima = m);
1193
- const S = h;
1194
- for (const v of [u, g, L, f]) for (const p of v) S.push(p);
1195
- return { camadaId: n.id, zIndex: n.zIndex, opacidade: n.opacidade, itens: S, estatisticas: m };
1196
- }
1197
- /**
1198
- * Clusters da vista (marcadores DOM). Selecionado nunca entra em cluster; o cluster só aparece com o centro dentro da
1199
- * vista e com 2 ou mais restantes. Os pontos individuais que a seleção solta (o selecionado e o único restante de uma
1200
- * célula) são da sobreposição: o canvas base não depende da seleção.
1201
- */
1202
- listarClusters(t, a, e, i, n, s) {
1203
- const { dados: r, def: c } = t;
1204
- for (const [l, d] of e.celulasAgrupadas()) {
1205
- const h = d.membros.size;
1206
- let u = 0, g = d.somaLat, L = d.somaLon;
1207
- for (const x of d.membros.values())
1208
- r.selecionadas.has(x.id) && (u++, g -= x.coordenada[0], L -= x.coordenada[1]);
1209
- const f = h - u, m = [d.somaLat / h, d.somaLon / h];
1210
- m[0] >= a.caixa.minLat - z && m[0] <= a.caixa.maxLat + z && m[1] >= a.caixa.minLon - z && m[1] <= a.caixa.maxLon + z && (f < 2 || !s || (i.push({
1211
- camadaId: c.id,
1212
- id: l,
1213
- forma: "cluster",
1214
- geometriaEmPx: [],
1215
- raioPx: 0,
1216
- estilo: _,
1217
- selecionada: !1,
1218
- coordenada: [g / f, L / f],
1219
- total: h,
1220
- restantes: f
1221
- }), n.clusters++, n.marcadoresDom++));
1222
- }
1223
- }
1224
- /** O ponto está dentro de um cluster neste zoom (não é desenhado nem clicável individualmente)? */
1225
- pontoAgrupado(t, a) {
1226
- const e = this.camadas.get(t);
1227
- return !!(e != null && e.agrupador) && e.agrupador.emCluster(a) && !e.dados.selecionadas.has(a);
1228
- }
1229
- /** O ponto de uma célula de cluster aparece solto: está selecionado ou é o único restante não selecionado? */
1230
- soltoDoCluster(t, a, e) {
1231
- if (t.dados.selecionadas.has(e)) return !0;
1232
- const i = a.chaveDoPonto(e), n = i === void 0 ? void 0 : a.celula(i);
1233
- if (!n) return !1;
1234
- let s = 0;
1235
- for (const r of n.membros.keys()) t.dados.selecionadas.has(r) || s++;
1236
- return s === 1;
1237
- }
1238
- /** Membros (id e coordenada) da célula de cluster: o clique no cluster enquadra o grupo. */
1239
- membrosDoCluster(t, a) {
1240
- var n;
1241
- const e = this.camadas.get(t), i = (n = e == null ? void 0 : e.agrupador) == null ? void 0 : n.celula(a);
1242
- return i ? [...i.membros.values()].map((s) => ({ id: s.id, coordenada: s.coordenada })) : [];
1243
- }
1244
- // ---------------------------------------------------------------- sobreposição (seleção, destaque, edição)
1245
- /**
1246
- * Itens da sobreposição: feições selecionadas, em edição ou destacadas, sempre em detalhe completo e com o estilo
1247
- * de seleção. Custo O(selecionadas): selecionar não repinta o canvas base.
1248
- */
1249
- listaSobreposicao(t, a) {
1250
- var r;
1251
- const e = this.camadas.get(t);
1252
- if (!e || !H(a)) return null;
1253
- this.prepararZoom(e, a.zoom);
1254
- const i = [], n = /* @__PURE__ */ new Set([...e.dados.selecionadas, ...e.previas.keys(), ...e.destaques]), s = e.agrupador;
1255
- if (s && e.dados.selecionadas.size > 0) {
1256
- const c = /* @__PURE__ */ new Set();
1257
- for (const l of e.dados.selecionadas) {
1258
- const d = s.chaveDoPonto(l);
1259
- d !== void 0 && c.add(d);
1260
- }
1261
- for (const l of c) {
1262
- const d = s.celula(l);
1263
- if (!d || d.membros.size < 2) continue;
1264
- const h = [...d.membros.keys()].filter((u) => !e.dados.selecionadas.has(u));
1265
- h.length === 1 && n.add(h[0]);
1266
- }
1267
- }
1268
- for (const c of n) {
1269
- const l = e.dados.loja.get(c);
1270
- if (!l || !e.dados.desenhavel(l)) continue;
1271
- const d = e.previas.get(c), h = d ?? l, u = h.geometria;
1272
- if (u.tipo === "Text" || dt(u) || u.tipo === "Point" && ((r = h.estilo) != null && r.icone)) continue;
1273
- const g = d ? null : e.dados.indice.caixaDe(c);
1274
- if (g && !$(g, a.caixa)) continue;
1275
- const L = e.dados.selecionadas.has(c) || !!d;
1276
- if (!L && !e.destaques.has(c) && !(u.tipo === "Point" && (s != null && s.emCluster(c)))) continue;
1277
- const f = d ? this.construirGeometria(e, h, a.zoom, -1) : this.geometriaProjetada(e, h, a.zoom);
1278
- if (!f) continue;
1279
- const m = e.internador.interno(Mt(h, e.def.estilo, L)), x = u.tipo === "LineString" ? "linha" : u.tipo === "Circle" ? "circulo" : u.tipo === "Point" ? "ponto" : "poligono";
1280
- i.push({
1281
- camadaId: t,
1282
- id: c,
1283
- forma: x,
1284
- geometriaEmPx: f.partes,
1285
- raioPx: f.raioPx,
1286
- estilo: m,
1287
- selecionada: L,
1288
- feicao: h,
1289
- ...e.destaques.has(c) ? { destaque: !0 } : {}
1290
- });
1291
- }
1292
- return {
1293
- camadaId: t,
1294
- zIndex: e.def.zIndex,
1295
- opacidade: e.def.opacidade,
1296
- itens: i,
1297
- estatisticas: { total: e.dados.loja.size, desenhadas: i.length, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: e.avaliacoesLOD }
1298
- };
1299
- }
1300
- /** A seleção da camada toca pontos sob agrupamento ativo? (então o conjunto de clusters muda e o base precisa refazer) */
1301
- selecaoAfetaAgrupamento(t, a) {
1302
- var i;
1303
- const e = this.camadas.get(t);
1304
- if (!e || !e.agrupador) return !1;
1305
- for (const n of a) if (((i = e.dados.loja.get(n)) == null ? void 0 : i.geometria.tipo) === "Point") return !0;
1306
- return !1;
1307
- }
1308
- }
1309
- export {
1310
- ma as $,
1311
- sa as A,
1312
- Aa as B,
1313
- U as C,
1314
- kt as D,
1315
- Za as E,
1316
- Xa as F,
1317
- ka as G,
1318
- $t as H,
1319
- Xt as I,
1320
- Bt as J,
1321
- zt as K,
1322
- _t as L,
1323
- J as M,
1324
- qt as N,
1325
- at as O,
1326
- ta as P,
1327
- gt as Q,
1328
- za as R,
1329
- pt as S,
1330
- Ot as T,
1331
- q as U,
1332
- Ca as V,
1333
- Da as W,
1334
- ra as X,
1335
- ia as Y,
1336
- At as Z,
1337
- It as _,
1338
- Et as a,
1339
- ea as a0,
1340
- ha as a1,
1341
- Ua as a2,
1342
- Ft as a3,
1343
- it as a4,
1344
- Ga as a5,
1345
- na as a6,
1346
- vt as a7,
1347
- mt as a8,
1348
- V as a9,
1349
- rt as aa,
1350
- Ma as ab,
1351
- ba as ac,
1352
- E as ad,
1353
- jt as ae,
1354
- Y as af,
1355
- xt as ag,
1356
- Oa as ah,
1357
- Jt as ai,
1358
- Dt as aj,
1359
- Pt as ak,
1360
- Zt as al,
1361
- F as b,
1362
- Ba as c,
1363
- Fa as d,
1364
- Ta as e,
1365
- tt as f,
1366
- yt as g,
1367
- aa as h,
1368
- _a as i,
1369
- $a as j,
1370
- Va as k,
1371
- B as l,
1372
- qa as m,
1373
- dt as n,
1374
- La as o,
1375
- oa as p,
1376
- O as q,
1377
- Ra as r,
1378
- b as s,
1379
- la as t,
1380
- ua as u,
1381
- Yt as v,
1382
- bt as w,
1383
- St as x,
1384
- $ as y,
1385
- Mt as z
1386
- };