@thibezer/ui-components-kit 2.12.4 → 2.13.0

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 (32) hide show
  1. package/CHANGELOG.md +668 -639
  2. package/dist/camadas.cjs +106 -106
  3. package/dist/camadas.js +1341 -1023
  4. package/dist/canvas.cjs +31 -31
  5. package/dist/canvas.js +1946 -1806
  6. package/dist/components/ui-camadas/camadas-arraste-controles.d.ts +2 -1
  7. package/dist/components/ui-camadas/camadas-atualizacao-incremental.d.ts +24 -0
  8. package/dist/components/ui-camadas/camadas-colecao.d.ts +3 -1
  9. package/dist/components/ui-camadas/camadas-drag-drop.d.ts +10 -0
  10. package/dist/components/ui-camadas/camadas-eventos-arvore.d.ts +5 -0
  11. package/dist/components/ui-camadas/camadas-eventos-camadas.d.ts +2 -0
  12. package/dist/components/ui-camadas/camadas-linha-feicao.d.ts +29 -0
  13. package/dist/components/ui-camadas/camadas-render.d.ts +8 -1
  14. package/dist/components/ui-camadas/camadas-renomear.d.ts +2 -1
  15. package/dist/components/ui-camadas/camadas-sincronizacao-dom.d.ts +5 -0
  16. package/dist/components/ui-camadas/tipos.d.ts +37 -0
  17. package/dist/components/ui-camadas/ui-camadas.d.ts +11 -2
  18. package/dist/components/ui-canvas-cad/ui-canvas-cad.d.ts +13 -0
  19. package/dist/custom-elements.json +16951 -16143
  20. package/dist/gerencigeo-canvas/motor/motor-formas.d.ts +10 -0
  21. package/dist/gerencigeo-canvas/qualidade.d.ts +52 -0
  22. package/dist/gerencigeo-canvas/renderers/canvas_formas_leaflet.d.ts +11 -0
  23. package/dist/gerencigeo-canvas/renderers/renderizador_formas.d.ts +3 -0
  24. package/dist/gerencigeo-canvas/renderers/tile_renderer.d.ts +1 -1
  25. package/dist/gerencigeo-canvas/types.d.ts +2 -0
  26. package/dist/motor-By2te6PZ.js +1400 -0
  27. package/dist/motor-CkMxd378.cjs +1 -0
  28. package/dist/motor.cjs +1 -1
  29. package/dist/motor.js +1 -1
  30. package/dist/tipos-elementos.d.ts +1 -0
  31. package/dist/tipos-vue.d.ts +1 -0
  32. package/package.json +1 -1
@@ -0,0 +1,1400 @@
1
+ var wt = Object.defineProperty;
2
+ var Et = (o, t, a) => t in o ? wt(o, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : o[t] = a;
3
+ var M = (o, t, a) => Et(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 Tt(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 Y(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 } = Y(o);
20
+ return { lat: D(1) * t, lng: D(1) * a * Math.cos(D(o)) };
21
+ }
22
+ function Ft(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, x = 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, x = 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)), N = h;
32
+ if (h = i + (1 - C) * e * A * (x + C * u * (m + C * g * (-1 + 2 * m * m))), Math.abs(h - N) < 1e-12) break;
33
+ }
34
+ const L = f * (T * T - a * a) / (a * a), w = 1 + L / 16384 * (4096 + L * (-768 + L * (320 - 175 * L))), S = L / 1024 * (256 + L * (-128 + L * (74 - 47 * L))), 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 * (x - 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 } = Y((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 Ft(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 } = Y(e / t), s = Math.abs(a * i * n / 2);
59
+ return Number.isFinite(s) ? s : 0;
60
+ }
61
+ function Rt(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 zt = new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 4, maximumFractionDigits: 4 }), et = new Intl.NumberFormat("pt-BR", { minimumFractionDigits: 2, maximumFractionDigits: 2 });
66
+ function _t(o) {
67
+ return `${zt.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 Bt(o) {
73
+ return o.tipo === "Polygon" ? Rt(o.aneis) : o.tipo === "Circle" ? Math.PI * o.raioMetros ** 2 : null;
74
+ }
75
+ function kt(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 qt(o, t) {
79
+ var i;
80
+ const a = t ?? "name";
81
+ if (a === "area") {
82
+ const n = Bt(o.geometria);
83
+ return n === null ? "" : _t(n);
84
+ }
85
+ if (a === "extensao") {
86
+ const n = kt(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 Ut(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, Vt = 256;
116
+ function it(o) {
117
+ const [[t, a], [e, i]] = Ut(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 Xt(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 Gt {
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(Vt, this.itens.size * 0.1) && this.remontar();
204
+ }
205
+ remontar() {
206
+ this.raiz = Xt([...this.itens.values()]), this.delta.clear(), this.obsoletos.clear();
207
+ }
208
+ }
209
+ const At = 17, J = 9, Zt = 1.2;
210
+ function Ht(o) {
211
+ return !Number.isFinite(o) || o >= At ? 0 : 360 / (256 * 2 ** o) * Zt;
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 Jt(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 = Jt(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 Qt(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 = Ht(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 Tt(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) => Qt(c, a, r)) };
256
+ }
257
+ return o;
258
+ }
259
+ const Kt = /* @__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" && Kt.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 Wt = 24, ta = 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 aa(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 oa(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 = Wt) {
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(oa(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 ea(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 = ea(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 = ta) {
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 aa(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, ia = 17, na = 8;
380
+ function St(o, t) {
381
+ return t < ia && o > na;
382
+ }
383
+ function sa(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: sa(r), membros: r });
399
+ return { clusters: i, isolados: n };
400
+ }
401
+ class ra {
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 It = 3, bt = 0.75, lt = 85.0511287798, ca = 256;
450
+ function Q(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 Ot(o, t) {
459
+ if (!Number.isFinite(t) || t < 0 || !da(o)) return NaN;
460
+ const a = Q(o.minLat, o.minLon, t), e = Q(o.maxLat, o.maxLon, t);
461
+ return Math.hypot(e.x - a.x, e.y - a.y);
462
+ }
463
+ function la(o, t, a = It) {
464
+ if (!o) return !1;
465
+ const e = Ot(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 = Q(u.lat, u.lon, a), x = g.x - e, f = g.y - i;
487
+ x >= -2 && f >= -2 && x <= n + 2 && f <= s + 2 && (h || (o.fillStyle = l || fa, o.globalAlpha = bt, h = !0), o.fillRect(Math.round(x - 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 Nt(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 = Nt(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", xa = "#38bdf8", La = /^(#[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" && La.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", x = I(e.opacidadeTraco) ? e.opacidadeTraco : I(t.opacidadeLinha) ? t.opacidadeLinha : 1;
563
+ return {
564
+ cor: a ? xa : 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, x)),
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 || Nt(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, xt = (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 Gt());
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) => xt(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 (!xt(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, j = 85.0511287798, Ia = 4007501668557849e-8;
707
+ function jt(o, t, a, e, i) {
708
+ const n = a > j ? j : a < -j ? -j : 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 Lt(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(-j, Math.min(j, 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 Na(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 x = 0, f = -1;
761
+ const m = i[g * 2], L = 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 = Na(i[y * 2], i[y * 2 + 1], m, L, w, S);
764
+ v > x && (x = v, f = y);
765
+ }
766
+ f !== -1 && x > 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 ja = 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
+ M(this, "limiteMarcaPx", It);
792
+ M(this, "toleranciaPx", ja);
793
+ }
794
+ /**
795
+ * Ajusta o LOD (diagonal em px abaixo da qual a feição vira marca) e a tolerância da simplificação em px (perfis de
796
+ * `qualidade.ts`). Valor inválido (NaN, <= 0) mantém o atual. Ao mudar de verdade, os caches por zoom são descartados.
797
+ */
798
+ definirQualidade(t) {
799
+ const a = Number.isFinite(t == null ? void 0 : t.limiteMarcaPx) && t.limiteMarcaPx > 0 ? t.limiteMarcaPx : this.limiteMarcaPx, e = Number.isFinite(t == null ? void 0 : t.toleranciaPx) && t.toleranciaPx > 0 ? t.toleranciaPx : this.toleranciaPx;
800
+ if (!(a === this.limiteMarcaPx && e === this.toleranciaPx)) {
801
+ this.limiteMarcaPx = a, this.toleranciaPx = e;
802
+ for (const i of this.camadas.values())
803
+ i.geom.clear(), i.lod.clear(), i.zoomCache = -1, i.dados.revisao++;
804
+ }
805
+ }
806
+ // ---------------------------------------------------------------- camadas
807
+ /** Cria a camada ou atualiza a definição (estilo, zIndex, opacidade, visibilidade). */
808
+ definirCamada(t) {
809
+ if (!t || typeof t.id != "string") return;
810
+ let a = this.camadas.get(t.id);
811
+ if (!a) {
812
+ a = {
813
+ def: t,
814
+ dados: new Ca(),
815
+ zoomCache: -1,
816
+ geom: /* @__PURE__ */ new Map(),
817
+ estilos: /* @__PURE__ */ new Map(),
818
+ lod: /* @__PURE__ */ new Map(),
819
+ avaliacoesLOD: 0,
820
+ agrupador: null,
821
+ agrupadorRev: -1,
822
+ nPontos: 0,
823
+ nPontosRev: -1,
824
+ previas: /* @__PURE__ */ new Map(),
825
+ destaques: /* @__PURE__ */ new Set(),
826
+ revEstilo: 0,
827
+ internador: new Da(),
828
+ ultima: { total: 0, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: 0 }
829
+ }, a.dados.regra = this.regra, this.camadas.set(t.id, a);
830
+ return;
831
+ }
832
+ const e = JSON.stringify(a.def.estilo) !== JSON.stringify(t.estilo);
833
+ a.def = t, e && (a.revEstilo++, a.estilos.clear(), a.internador.limpar());
834
+ }
835
+ removerCamada(t) {
836
+ this.camadas.delete(t);
837
+ }
838
+ temCamada(t) {
839
+ return this.camadas.has(t);
840
+ }
841
+ definirRegra(t) {
842
+ this.regra = t;
843
+ for (const a of this.camadas.values()) a.dados.regra = t;
844
+ }
845
+ /** A regra de versões mudou (prévias ligadas/desligadas): o conjunto desenhado e o agrupamento precisam ser refeitos. */
846
+ reavaliarVersoes(t) {
847
+ const a = this.camadas.get(t);
848
+ a && (a.dados.revisao++, a.dados.revisaoBase++);
849
+ }
850
+ // ---------------------------------------------------------------- dados
851
+ /** Troca total dos dados da camada (diferencia contra o que já existe). */
852
+ definirFeicoes(t, a) {
853
+ const e = this.camadas.get(t);
854
+ if (!e) return;
855
+ const i = Array.isArray(a) ? a : [], n = e.dados.sincronizar(i);
856
+ this.aposMudanca(e, n.mudadas, n.removidas, !0);
857
+ }
858
+ /**
859
+ * Mudança incremental: só vale se `delta.base` for a lista sincronizada por último; senão a camada é refeita
860
+ * por inteiro a partir de `lista`.
861
+ */
862
+ aplicarDelta(t, a, e) {
863
+ const i = this.camadas.get(t);
864
+ if (!i) return;
865
+ const n = Array.isArray(a) ? a : [], s = /* @__PURE__ */ new Map();
866
+ if (e) {
867
+ for (const l of e.removidas ?? []) s.set(l, this.pontoVisivel(i, i.dados.loja.get(l)));
868
+ for (const l of e.mudadas ?? []) l && typeof l.id == "string" && s.set(l.id, this.pontoVisivel(i, i.dados.loja.get(l.id)));
869
+ }
870
+ const r = i.dados.aplicarDelta(n, e);
871
+ if (!r) {
872
+ this.definirFeicoes(t, n);
873
+ return;
874
+ }
875
+ let c = i.nPontos;
876
+ for (const [l, d] of s) {
877
+ const h = this.pontoVisivel(i, i.dados.loja.get(l));
878
+ c += (h ? 1 : 0) - (d ? 1 : 0);
879
+ }
880
+ i.nPontos = Math.max(0, c), this.aposMudanca(i, r.mudadas, r.removidas, r.oficiaisMudou), r.oficiaisMudou || this.manterAgrupador(i, r.mudadas, r.removidas);
881
+ }
882
+ pontoVisivel(t, a) {
883
+ var e;
884
+ return !!a && ((e = a.geometria) == null ? void 0 : e.tipo) === "Point" && t.dados.desenhavel(a);
885
+ }
886
+ aposMudanca(t, a, e, i) {
887
+ for (const n of a)
888
+ t.lod.delete(n), t.geom.delete(n), t.estilos.delete(n), t.previas.delete(n);
889
+ for (const n of e)
890
+ t.lod.delete(n), t.geom.delete(n), t.estilos.delete(n), t.previas.delete(n), t.destaques.delete(n);
891
+ i && (t.agrupador = null);
892
+ }
893
+ /** O agrupador do zoom atual acompanha os pontos que mudaram (células afetadas, sem reagrupar a camada). */
894
+ manterAgrupador(t, a, e) {
895
+ const i = t.agrupador;
896
+ if (i) {
897
+ for (const n of e) i.remover(n);
898
+ for (const n of a) {
899
+ const s = t.dados.loja.get(n);
900
+ s && s.geometria.tipo === "Point" && t.dados.desenhavel(s) ? i.inserir({ id: n, coordenada: s.geometria.coordenada }) : i.remover(n);
901
+ }
902
+ }
903
+ }
904
+ // ---------------------------------------------------------------- seleção e edição
905
+ /** Define a seleção da camada. Devolve quem entrou e quem saiu (só o que mudou). */
906
+ selecionar(t, a) {
907
+ const e = this.camadas.get(t);
908
+ if (!e) return { entrou: [], saiu: [] };
909
+ const i = /* @__PURE__ */ new Set();
910
+ for (const r of a) e.dados.loja.has(r) && i.add(r);
911
+ const n = [], s = [];
912
+ for (const r of i) e.dados.selecionadas.has(r) || n.push(r);
913
+ for (const r of e.dados.selecionadas) i.has(r) || s.push(r);
914
+ e.dados.selecionadas.clear();
915
+ for (const r of i) e.dados.selecionadas.add(r);
916
+ return { entrou: n, saiu: s };
917
+ }
918
+ selecionadas(t) {
919
+ var a;
920
+ return ((a = this.camadas.get(t)) == null ? void 0 : a.dados.selecionadas) ?? /* @__PURE__ */ new Set();
921
+ }
922
+ /** Geometria provisória (arrasto de vértice): o canvas base deixa de desenhar a feição e a sobreposição a mostra. */
923
+ previsualizar(t, a) {
924
+ const e = this.camadas.get(t);
925
+ !e || !a || typeof a.id != "string" || !e.dados.loja.has(a.id) || e.previas.set(a.id, a);
926
+ }
927
+ temPrevia(t, a) {
928
+ var e;
929
+ return ((e = this.camadas.get(t)) == null ? void 0 : e.previas.has(a)) ?? !1;
930
+ }
931
+ /** Realce temporário (hover): as feições entram na sobreposição com `destaque: true`. */
932
+ destacar(t, a) {
933
+ const e = this.camadas.get(t);
934
+ e && (e.destaques = new Set(a));
935
+ }
936
+ // ---------------------------------------------------------------- consultas (geometria original)
937
+ feicao(t, a) {
938
+ var e;
939
+ return (e = this.camadas.get(t)) == null ? void 0 : e.dados.loja.get(a);
940
+ }
941
+ caixaDe(t, a) {
942
+ var e;
943
+ return (e = this.camadas.get(t)) == null ? void 0 : e.dados.indice.caixaDe(a);
944
+ }
945
+ /** Feições cujo envelope toca `caixa`, sem as ocultas (snap, hit-test, seleção por caixa). Não passa pelo LOD. */
946
+ consultarCaixa(t, a) {
947
+ const e = this.camadas.get(t);
948
+ if (!e) return [];
949
+ const i = [];
950
+ for (const n of e.dados.indice.consultar(a)) {
951
+ const s = e.dados.loja.get(n);
952
+ s && !s.oculta && i.push(s);
953
+ }
954
+ return i;
955
+ }
956
+ feicaoVisivel(t, a) {
957
+ const e = this.camadas.get(t);
958
+ return !e || e.dados.visivelPorVersao(a);
959
+ }
960
+ estatisticas(t) {
961
+ const a = this.camadas.get(t);
962
+ return a ? { ...a.ultima, total: a.dados.loja.size, avaliacoesLOD: a.avaliacoesLOD } : null;
963
+ }
964
+ /** Entidades da camada com prévia e com oficial (pares em detalhe completo): para testes e diagnóstico. */
965
+ ehPar(t, a) {
966
+ const e = this.camadas.get(t);
967
+ return !!e && this.emPar(e, a);
968
+ }
969
+ // ---------------------------------------------------------------- lista de desenho
970
+ /**
971
+ * O que desenhar nesta vista, camada a camada, na ordem de empilhamento (a última fica por cima).
972
+ * `parte`: `'canvas'` só o que se pinta no canvas (marcas, formas, pontos sem ícone), `'dom'` só marcadores DOM e
973
+ * curvas (clusters, ícones, textos, rótulos), `'tudo'` (padrão) os dois. O pan incremental pede o canvas só das faixas
974
+ * expostas e o DOM da vista inteira (poucos itens, sem projetar nem simplificar formas).
975
+ */
976
+ listaDesenho(t, a) {
977
+ const e = this.origemDe(t), i = { vista: t, origem: e, camadas: [] };
978
+ if (!H(t)) return i;
979
+ 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)));
980
+ s.sort((r, c) => r.def.zIndex - c.def.zIndex);
981
+ for (const r of s)
982
+ try {
983
+ i.camadas.push(this.listarCamada(r, t, (a == null ? void 0 : a.parte) ?? "tudo"));
984
+ } catch {
985
+ i.camadas.push(this.camadaVazia(r));
986
+ }
987
+ return i;
988
+ }
989
+ origemDe(t) {
990
+ if (t != null && t.origemPx && Number.isFinite(t.origemPx.x) && Number.isFinite(t.origemPx.y)) return t.origemPx;
991
+ if (!H(t)) return { x: 0, y: 0 };
992
+ const a = E(t.caixa.maxLat, t.caixa.minLon, t.zoom);
993
+ return { x: a[0], y: a[1] };
994
+ }
995
+ camadaVazia(t) {
996
+ return {
997
+ camadaId: t.def.id,
998
+ zIndex: t.def.zIndex,
999
+ opacidade: t.def.opacidade,
1000
+ itens: [],
1001
+ estatisticas: { total: t.dados.loja.size, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: t.avaliacoesLOD }
1002
+ };
1003
+ }
1004
+ prepararZoom(t, a) {
1005
+ a !== t.zoomCache && (t.geom.clear(), t.lod.clear(), t.zoomCache = a);
1006
+ }
1007
+ estiloDe(t, a) {
1008
+ const e = t.dados.revisaoDaFeicao(a.id), i = t.estilos.get(a.id);
1009
+ if (i && i.rev === e && i.revEstilo === t.revEstilo) return i.estilo;
1010
+ const n = t.internador.interno(Mt(a, t.def.estilo, !1));
1011
+ return t.estilos.set(a.id, { rev: e, revEstilo: t.revEstilo, estilo: n }), n;
1012
+ }
1013
+ emPar(t, a) {
1014
+ if (t.dados.contPrevias.size === 0) return !1;
1015
+ const e = O(a);
1016
+ return t.dados.contPrevias.has(e) && t.dados.oficiais.has(e);
1017
+ }
1018
+ /**
1019
+ * Vira marca? Sempre em detalhe completo: com rótulo e em par oficial × prévia; ponto e texto nunca. A seleção NÃO
1020
+ * entra aqui: o canvas base não depende dela (a sobreposição desenha a selecionada em detalhe completo por cima).
1021
+ */
1022
+ comoMarca(t, a, e) {
1023
+ var r;
1024
+ const i = a.geometria.tipo;
1025
+ if (i === "Point" || i === "Text" || (r = a.estilo) != null && r.mostrarRotulo || this.emPar(t, a)) return !1;
1026
+ const n = t.lod.get(a.id);
1027
+ if (n !== void 0) return n;
1028
+ t.avaliacoesLOD++;
1029
+ const s = la(t.dados.indice.caixaDe(a.id), e, this.limiteMarcaPx);
1030
+ return t.lod.set(a.id, s), s;
1031
+ }
1032
+ /** Geometria projetada e simplificada em px, em cache por (feição, revisão, zoom). `null` se não há o que desenhar. */
1033
+ geometriaProjetada(t, a, e) {
1034
+ const i = t.dados.revisaoDaFeicao(a.id), n = t.geom.get(a.id);
1035
+ if (n && n.rev === i) return n;
1036
+ const s = this.construirGeometria(t, a, e, i);
1037
+ return s && t.geom.set(a.id, s), s;
1038
+ }
1039
+ construirGeometria(t, a, e, i) {
1040
+ const n = a.geometria, s = e < At ? this.toleranciaPx : 0;
1041
+ if (n.tipo === "Polygon") {
1042
+ const r = [];
1043
+ for (const c of n.aneis ?? []) {
1044
+ if (!Array.isArray(c) || c.length < 3) continue;
1045
+ let l = Lt(c, e);
1046
+ s > 0 && c.length >= J && (l = Pt(l, s, !0)), r.push(l);
1047
+ }
1048
+ return r.length > 0 ? { rev: i, partes: r, raioPx: 0, marca: !1 } : null;
1049
+ }
1050
+ if (n.tipo === "LineString") {
1051
+ const r = [];
1052
+ for (const c of F(n)) {
1053
+ if (!Array.isArray(c) || c.length < 2) continue;
1054
+ let l = Lt(c, e);
1055
+ s > 0 && c.length >= J && (l = Pt(l, s, !1)), r.push(l);
1056
+ }
1057
+ return r.length > 0 ? { rev: i, partes: r, raioPx: 0, marca: !1 } : null;
1058
+ }
1059
+ if (n.tipo === "Circle") {
1060
+ const r = n.centro;
1061
+ if (!Array.isArray(r)) return null;
1062
+ const c = E(r[0], r[1], e);
1063
+ return { rev: i, partes: [c], raioPx: Oa(r[0], n.raioMetros, e), marca: !1 };
1064
+ }
1065
+ 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;
1066
+ }
1067
+ /** Marca de LOD: centro do envelope, lado de 1–2 px, cor do preenchimento/contorno. */
1068
+ marcaDe(t, a, e) {
1069
+ const i = t.dados.revisaoDaFeicao(a.id), n = t.geom.get(a.id);
1070
+ if (n && n.rev === i) return n;
1071
+ const s = t.dados.indice.caixaDe(a.id);
1072
+ if (!s) return null;
1073
+ const r = E((s.minLat + s.maxLat) / 2, (s.minLon + s.maxLon) / 2, e);
1074
+ if (!(Number.isFinite(r[0]) && Number.isFinite(r[1]))) return null;
1075
+ const c = { rev: i, partes: [r], raioPx: ua(Ot(s, e)), marca: !0 };
1076
+ return t.geom.set(a.id, c), c;
1077
+ }
1078
+ /**
1079
+ * Item da marca, em cache junto com a geometria por (feição, zoom). Com 100 mil marcas na tela, montar o item e internar
1080
+ * o estilo a cada vista custava a maior parte da lista; no pan agora só se confere se algo mudou, sem alocar.
1081
+ */
1082
+ itemMarca(t, a, e) {
1083
+ const i = this.marcaDe(t, a, e);
1084
+ if (!i) return null;
1085
+ const n = i.item;
1086
+ 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;
1087
+ const s = this.itemBase(t, a, "marca", i.partes, i.raioPx, this.estiloMarca(t, a));
1088
+ return i.item = s, i.revEstilo = t.revEstilo, s;
1089
+ }
1090
+ estiloMarca(t, a) {
1091
+ const e = a.estilo ?? {}, i = B(e.corPreenchimento ?? e.corTraco ?? t.def.estilo.corPrimaria, U);
1092
+ return t.internador.interno({ cor: i, traco: !1, peso: 0, dash: void 0, preencher: !0, corPreenchimento: i, opacidadePreenchimento: bt });
1093
+ }
1094
+ agrupadorAtivo(t, a) {
1095
+ const { dados: e } = t;
1096
+ if (t.nPontosRev !== e.revisaoBase) {
1097
+ let s = 0;
1098
+ for (const r of e.loja.values()) r.geometria.tipo === "Point" && e.desenhavel(r) && s++;
1099
+ t.nPontos = s, t.nPontosRev = e.revisaoBase;
1100
+ }
1101
+ if (!St(t.nPontos, a))
1102
+ return t.agrupador = null, null;
1103
+ const i = t.agrupador;
1104
+ if (i && i.zoom === a && t.agrupadorRev === e.revisaoBase) return i;
1105
+ const n = new ra(a, (s) => {
1106
+ const r = E(s[0], s[1], a);
1107
+ return { x: r[0], y: r[1] };
1108
+ });
1109
+ for (const s of e.loja.values())
1110
+ s.geometria.tipo === "Point" && e.desenhavel(s) && n.inserir({ id: s.id, coordenada: s.geometria.coordenada });
1111
+ return t.agrupador = n, t.agrupadorRev = e.revisaoBase, n;
1112
+ }
1113
+ itemBase(t, a, e, i, n, s) {
1114
+ return {
1115
+ camadaId: t.def.id,
1116
+ id: a.id,
1117
+ forma: e,
1118
+ geometriaEmPx: i,
1119
+ raioPx: n,
1120
+ estilo: s,
1121
+ selecionada: t.dados.selecionadas.has(a.id),
1122
+ feicao: a,
1123
+ ...t.destaques.has(a.id) ? { destaque: !0 } : {}
1124
+ };
1125
+ }
1126
+ /**
1127
+ * 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
1128
+ * (o índice é por envelope). Sem isto, o pan incremental e o quadro completo divergem na borda do canvas.
1129
+ */
1130
+ caixaComFolga(t) {
1131
+ const a = t.caixa, i = 360 / (256 * 2 ** t.zoom) * wa, n = i * Math.cos((a.minLat + a.maxLat) / 2 * Math.PI / 180);
1132
+ return { minLat: a.minLat - n, maxLat: a.maxLat + n, minLon: a.minLon - i, maxLon: a.maxLon + i };
1133
+ }
1134
+ listarCamada(t, a, e) {
1135
+ var y;
1136
+ const { dados: i, def: n } = t, s = e !== "dom", r = e !== "canvas", c = a.zoom;
1137
+ this.prepararZoom(t, c);
1138
+ const l = i.indice.consultar(this.caixaComFolga(a)), d = this.agrupadorAtivo(t, c), h = [], u = [], g = [], x = [], f = [], m = { total: i.loja.size, desenhadas: 0, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: 0 }, L = (v) => {
1139
+ var A;
1140
+ if (!r || !((A = v.estilo) != null && A.mostrarRotulo) || v.geometria.tipo === "Text") return;
1141
+ const p = qt(v, v.estilo.campoRotulo), P = i.indice.caixaDe(v.id);
1142
+ !p || !P || (f.push({
1143
+ camadaId: n.id,
1144
+ id: `rotulo:${v.id}`,
1145
+ forma: "rotulo",
1146
+ geometriaEmPx: [],
1147
+ raioPx: 0,
1148
+ estilo: _,
1149
+ selecionada: !1,
1150
+ feicao: v,
1151
+ texto: p,
1152
+ coordenada: [(P.minLat + P.maxLat) / 2, (P.minLon + P.maxLon) / 2]
1153
+ }), m.marcadoresDom++);
1154
+ }, w = (v) => {
1155
+ var A;
1156
+ const p = v.geometria;
1157
+ if (p.tipo !== "Point") return;
1158
+ if ((A = v.estilo) != null && A.icone) {
1159
+ if (!r) return;
1160
+ f.push({ ...this.itemBase(t, v, "icone", [], 0, _), coordenada: p.coordenada }), m.marcadoresDom++;
1161
+ return;
1162
+ }
1163
+ if (!s) return;
1164
+ const P = this.geometriaProjetada(t, v, c);
1165
+ P && (x.push(this.itemBase(t, v, "ponto", P.partes, P.raioPx, this.estiloDe(t, v))), m.desenhadas++);
1166
+ };
1167
+ for (const v of l) {
1168
+ const p = i.loja.get(v);
1169
+ if (!p || !i.desenhavel(p) || t.previas.has(v)) continue;
1170
+ const P = p.geometria;
1171
+ if (P.tipo === "Point") {
1172
+ if (d && d.emCluster(v) && (!((y = p.estilo) != null && y.icone) || !r || !this.soltoDoCluster(t, d, v)))
1173
+ continue;
1174
+ w(p), L(p);
1175
+ continue;
1176
+ }
1177
+ if (P.tipo === "Text") {
1178
+ if (!r) continue;
1179
+ f.push({ ...this.itemBase(t, p, "texto", [], 0, _), coordenada: P.coordenada }), m.marcadoresDom++;
1180
+ continue;
1181
+ }
1182
+ if (dt(P)) {
1183
+ if (!r) continue;
1184
+ f.push(this.itemBase(t, p, "curva", [], 0, this.estiloDe(t, p))), m.marcadoresDom++, L(p);
1185
+ continue;
1186
+ }
1187
+ if (!s) {
1188
+ L(p);
1189
+ continue;
1190
+ }
1191
+ const A = t.geom.get(v), C = A == null ? void 0 : A.item;
1192
+ 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)) {
1193
+ h.push(C), m.marcasLOD++;
1194
+ continue;
1195
+ }
1196
+ if (this.comoMarca(t, p, c)) {
1197
+ const K = this.itemMarca(t, p, c);
1198
+ K && (h.push(K), m.marcasLOD++);
1199
+ continue;
1200
+ }
1201
+ const N = this.geometriaProjetada(t, p, c);
1202
+ if (!N) continue;
1203
+ const X = this.estiloDe(t, p);
1204
+ P.tipo === "LineString" ? g.push(this.itemBase(t, p, "linha", N.partes, 0, X)) : P.tipo === "Circle" ? u.push(this.itemBase(t, p, "circulo", N.partes, N.raioPx, X)) : u.push(this.itemBase(t, p, "poligono", N.partes, 0, X)), m.desenhadas++, L(p);
1205
+ }
1206
+ d && r && this.listarClusters(t, a, d, f, m, r), m.avaliacoesLOD = t.avaliacoesLOD, e === "tudo" && (t.ultima = m);
1207
+ const S = h;
1208
+ for (const v of [u, g, x, f]) for (const p of v) S.push(p);
1209
+ return { camadaId: n.id, zIndex: n.zIndex, opacidade: n.opacidade, itens: S, estatisticas: m };
1210
+ }
1211
+ /**
1212
+ * Clusters da vista (marcadores DOM). Selecionado nunca entra em cluster; o cluster só aparece com o centro dentro da
1213
+ * vista e com 2 ou mais restantes. Os pontos individuais que a seleção solta (o selecionado e o único restante de uma
1214
+ * célula) são da sobreposição: o canvas base não depende da seleção.
1215
+ */
1216
+ listarClusters(t, a, e, i, n, s) {
1217
+ const { dados: r, def: c } = t;
1218
+ for (const [l, d] of e.celulasAgrupadas()) {
1219
+ const h = d.membros.size;
1220
+ let u = 0, g = d.somaLat, x = d.somaLon;
1221
+ for (const L of d.membros.values())
1222
+ r.selecionadas.has(L.id) && (u++, g -= L.coordenada[0], x -= L.coordenada[1]);
1223
+ const f = h - u, m = [d.somaLat / h, d.somaLon / h];
1224
+ 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({
1225
+ camadaId: c.id,
1226
+ id: l,
1227
+ forma: "cluster",
1228
+ geometriaEmPx: [],
1229
+ raioPx: 0,
1230
+ estilo: _,
1231
+ selecionada: !1,
1232
+ coordenada: [g / f, x / f],
1233
+ total: h,
1234
+ restantes: f
1235
+ }), n.clusters++, n.marcadoresDom++));
1236
+ }
1237
+ }
1238
+ /** O ponto está dentro de um cluster neste zoom (não é desenhado nem clicável individualmente)? */
1239
+ pontoAgrupado(t, a) {
1240
+ const e = this.camadas.get(t);
1241
+ return !!(e != null && e.agrupador) && e.agrupador.emCluster(a) && !e.dados.selecionadas.has(a);
1242
+ }
1243
+ /** O ponto de uma célula de cluster aparece solto: está selecionado ou é o único restante não selecionado? */
1244
+ soltoDoCluster(t, a, e) {
1245
+ if (t.dados.selecionadas.has(e)) return !0;
1246
+ const i = a.chaveDoPonto(e), n = i === void 0 ? void 0 : a.celula(i);
1247
+ if (!n) return !1;
1248
+ let s = 0;
1249
+ for (const r of n.membros.keys()) t.dados.selecionadas.has(r) || s++;
1250
+ return s === 1;
1251
+ }
1252
+ /** Membros (id e coordenada) da célula de cluster: o clique no cluster enquadra o grupo. */
1253
+ membrosDoCluster(t, a) {
1254
+ var n;
1255
+ const e = this.camadas.get(t), i = (n = e == null ? void 0 : e.agrupador) == null ? void 0 : n.celula(a);
1256
+ return i ? [...i.membros.values()].map((s) => ({ id: s.id, coordenada: s.coordenada })) : [];
1257
+ }
1258
+ // ---------------------------------------------------------------- sobreposição (seleção, destaque, edição)
1259
+ /**
1260
+ * Itens da sobreposição: feições selecionadas, em edição ou destacadas, sempre em detalhe completo e com o estilo
1261
+ * de seleção. Custo O(selecionadas): selecionar não repinta o canvas base.
1262
+ */
1263
+ listaSobreposicao(t, a) {
1264
+ var r;
1265
+ const e = this.camadas.get(t);
1266
+ if (!e || !H(a)) return null;
1267
+ this.prepararZoom(e, a.zoom);
1268
+ const i = [], n = /* @__PURE__ */ new Set([...e.dados.selecionadas, ...e.previas.keys(), ...e.destaques]), s = e.agrupador;
1269
+ if (s && e.dados.selecionadas.size > 0) {
1270
+ const c = /* @__PURE__ */ new Set();
1271
+ for (const l of e.dados.selecionadas) {
1272
+ const d = s.chaveDoPonto(l);
1273
+ d !== void 0 && c.add(d);
1274
+ }
1275
+ for (const l of c) {
1276
+ const d = s.celula(l);
1277
+ if (!d || d.membros.size < 2) continue;
1278
+ const h = [...d.membros.keys()].filter((u) => !e.dados.selecionadas.has(u));
1279
+ h.length === 1 && n.add(h[0]);
1280
+ }
1281
+ }
1282
+ for (const c of n) {
1283
+ const l = e.dados.loja.get(c);
1284
+ if (!l || !e.dados.desenhavel(l)) continue;
1285
+ const d = e.previas.get(c), h = d ?? l, u = h.geometria;
1286
+ if (u.tipo === "Text" || dt(u) || u.tipo === "Point" && ((r = h.estilo) != null && r.icone)) continue;
1287
+ const g = d ? null : e.dados.indice.caixaDe(c);
1288
+ if (g && !$(g, a.caixa)) continue;
1289
+ const x = e.dados.selecionadas.has(c) || !!d;
1290
+ if (!x && !e.destaques.has(c) && !(u.tipo === "Point" && (s != null && s.emCluster(c)))) continue;
1291
+ const f = d ? this.construirGeometria(e, h, a.zoom, -1) : this.geometriaProjetada(e, h, a.zoom);
1292
+ if (!f) continue;
1293
+ const m = e.internador.interno(Mt(h, e.def.estilo, x)), L = u.tipo === "LineString" ? "linha" : u.tipo === "Circle" ? "circulo" : u.tipo === "Point" ? "ponto" : "poligono";
1294
+ i.push({
1295
+ camadaId: t,
1296
+ id: c,
1297
+ forma: L,
1298
+ geometriaEmPx: f.partes,
1299
+ raioPx: f.raioPx,
1300
+ estilo: m,
1301
+ selecionada: x,
1302
+ feicao: h,
1303
+ ...e.destaques.has(c) ? { destaque: !0 } : {}
1304
+ });
1305
+ }
1306
+ return {
1307
+ camadaId: t,
1308
+ zIndex: e.def.zIndex,
1309
+ opacidade: e.def.opacidade,
1310
+ itens: i,
1311
+ estatisticas: { total: e.dados.loja.size, desenhadas: i.length, marcasLOD: 0, clusters: 0, marcadoresDom: 0, avaliacoesLOD: e.avaliacoesLOD }
1312
+ };
1313
+ }
1314
+ /** A seleção da camada toca pontos sob agrupamento ativo? (então o conjunto de clusters muda e o base precisa refazer) */
1315
+ selecaoAfetaAgrupamento(t, a) {
1316
+ var i;
1317
+ const e = this.camadas.get(t);
1318
+ if (!e || !e.agrupador) return !1;
1319
+ for (const n of a) if (((i = e.dados.loja.get(n)) == null ? void 0 : i.geometria.tipo) === "Point") return !0;
1320
+ return !1;
1321
+ }
1322
+ }
1323
+ export {
1324
+ ma as $,
1325
+ ra as A,
1326
+ Aa as B,
1327
+ U as C,
1328
+ qt as D,
1329
+ Za as E,
1330
+ Xa as F,
1331
+ ka as G,
1332
+ Bt as H,
1333
+ Gt as I,
1334
+ kt as J,
1335
+ _t as K,
1336
+ $t as L,
1337
+ J as M,
1338
+ Ut as N,
1339
+ at as O,
1340
+ aa as P,
1341
+ gt as Q,
1342
+ za as R,
1343
+ pt as S,
1344
+ Nt as T,
1345
+ q as U,
1346
+ Ca as V,
1347
+ Da as W,
1348
+ It as X,
1349
+ na as Y,
1350
+ At as Z,
1351
+ bt as _,
1352
+ Tt as a,
1353
+ ia as a0,
1354
+ ha as a1,
1355
+ Ua as a2,
1356
+ Rt as a3,
1357
+ it as a4,
1358
+ Ga as a5,
1359
+ sa as a6,
1360
+ vt as a7,
1361
+ mt as a8,
1362
+ V as a9,
1363
+ rt as aa,
1364
+ Ma as ab,
1365
+ ba as ac,
1366
+ E as ad,
1367
+ jt as ae,
1368
+ Q as af,
1369
+ Lt as ag,
1370
+ Oa as ah,
1371
+ Qt as ai,
1372
+ Dt as aj,
1373
+ Pt as ak,
1374
+ Ht as al,
1375
+ F as b,
1376
+ Ba as c,
1377
+ Fa as d,
1378
+ Ta as e,
1379
+ tt as f,
1380
+ yt as g,
1381
+ oa as h,
1382
+ _a as i,
1383
+ $a as j,
1384
+ Va as k,
1385
+ B as l,
1386
+ qa as m,
1387
+ dt as n,
1388
+ xa as o,
1389
+ ea as p,
1390
+ O as q,
1391
+ Ra as r,
1392
+ b as s,
1393
+ la as t,
1394
+ ua as u,
1395
+ Yt as v,
1396
+ Ot as w,
1397
+ St as x,
1398
+ $ as y,
1399
+ Mt as z
1400
+ };