@thibezer/ui-components-kit 2.24.0 → 2.24.2

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 (150) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/dist/botao.cjs +12 -1
  3. package/dist/botao.js +162 -3
  4. package/dist/camadas.cjs +311 -1
  5. package/dist/camadas.js +3244 -148
  6. package/dist/campo-texto.cjs +16 -1
  7. package/dist/campo-texto.js +308 -7
  8. package/dist/canvas.cjs +22 -22
  9. package/dist/canvas.js +230 -233
  10. package/dist/card.cjs +20 -1
  11. package/dist/card.js +145 -2
  12. package/dist/components/ui-canvas-prancha/index.d.ts +1 -1
  13. package/dist/components/ui-canvas-prancha/prancha-teclado.d.ts +18 -0
  14. package/dist/components/ui-canvas-prancha/ui-canvas-prancha-base.d.ts +4 -0
  15. package/dist/components/ui-card/ui-card.d.ts +4 -0
  16. package/dist/components/ui-editor-prancha/editor-modos.d.ts +10 -0
  17. package/dist/components/ui-editor-prancha/editor-tipos.d.ts +4 -0
  18. package/dist/components/ui-editor-prancha/index.d.ts +1 -0
  19. package/dist/components/ui-editor-prancha/ui-editor-prancha.d.ts +39 -6
  20. package/dist/core.cjs +1 -1
  21. package/dist/core.js +44 -55
  22. package/dist/{cores-utils-BrdynxRd.js → cores-utils-DMyqWvZh.js} +2 -2
  23. package/dist/cores.cjs +32 -1
  24. package/dist/cores.js +300 -13
  25. package/dist/custom-elements.json +33962 -33439
  26. package/dist/data.cjs +28 -1
  27. package/dist/data.js +286 -99
  28. package/dist/{feature_caixa-2Sxv3tGa.js → feature_caixa-BVc5LenS.js} +42 -42
  29. package/dist/{feature_desenho-BVHivWIB.js → feature_desenho-CC8Mp5Gp.js} +2 -2
  30. package/dist/feedback.cjs +52 -1
  31. package/dist/feedback.js +655 -25
  32. package/dist/forms.cjs +66 -1
  33. package/dist/forms.js +1216 -39
  34. package/dist/{geometria-px-DUs5FgLE.js → geometria-px-DHMPUsxC.js} +47 -47
  35. package/dist/index.cjs +67 -1
  36. package/dist/index.js +1476 -274
  37. package/dist/kit-base-CGqj9aiD.cjs +2 -0
  38. package/dist/kit-base-_THn4w3u.js +1079 -0
  39. package/dist/mapa.cjs +5 -5
  40. package/dist/mapa.js +16 -17
  41. package/dist/modal.cjs +18 -1
  42. package/dist/modal.js +235 -29
  43. package/dist/motor.js +49 -49
  44. package/dist/prancha-nucleo.cjs +3 -1
  45. package/dist/prancha-nucleo.js +3120 -277
  46. package/dist/prancha.cjs +38 -1
  47. package/dist/prancha.js +3233 -228
  48. package/dist/register.cjs +1 -1
  49. package/dist/register.js +3 -20
  50. package/dist/seletor-mapa-base.cjs +13 -13
  51. package/dist/seletor-mapa-base.js +3 -5
  52. package/dist/tabela.cjs +142 -1
  53. package/dist/tabela.js +3773 -92
  54. package/dist/tipos-elementos.d.ts +5 -1
  55. package/dist/tipos-vue.d.ts +4 -1
  56. package/dist/tools.cjs +16 -1
  57. package/dist/tools.js +1564 -26
  58. package/dist/ui-seletor-cor-BGw8SBPm.cjs +83 -0
  59. package/dist/{ui-seletor-cor-Cd8jkzXG.js → ui-seletor-cor-B_twSm-V.js} +8 -9
  60. package/dist/utils-ClVgqVyJ.cjs +1 -0
  61. package/dist/utils-DrHoxxmf.js +83 -0
  62. package/package.json +43 -2
  63. package/dist/acessibilidade-CSzX-DkG.cjs +0 -1
  64. package/dist/acessibilidade-CUlSXc2X.js +0 -38
  65. package/dist/altura-controle-ukMRPckR.cjs +0 -1
  66. package/dist/altura-controle-vxQiXG4q.js +0 -62
  67. package/dist/alvo-digitavel-CzCvNVQ3.js +0 -23
  68. package/dist/alvo-digitavel-DbH0hYFf.cjs +0 -1
  69. package/dist/degrade-CIxvOTUv.cjs +0 -1
  70. package/dist/degrade-gDa5sW__.js +0 -119
  71. package/dist/feature_caixa-CnYPKVFS.cjs +0 -1
  72. package/dist/feature_caixa-DCs9ZeSk.js +0 -1038
  73. package/dist/feature_historico-BAIYk1Me.cjs +0 -3
  74. package/dist/feature_historico-C4h9y5fu.js +0 -3039
  75. package/dist/form-atalhos-7JTYvumA.cjs +0 -1
  76. package/dist/form-atalhos-DDTlpgaB.js +0 -203
  77. package/dist/form-erros-CwPz7Jr4.cjs +0 -1
  78. package/dist/form-erros-DT5HklfD.js +0 -184
  79. package/dist/form-submissao-C-SPRKgT.js +0 -61
  80. package/dist/form-submissao-DxKO5MHI.cjs +0 -1
  81. package/dist/form-validacao-BlQFxUVj.js +0 -104
  82. package/dist/form-validacao-DIeyQVH5.cjs +0 -1
  83. package/dist/geometria-px-DKrWq_XY.js +0 -639
  84. package/dist/leaflet-CEPcxGWV.cjs +0 -1
  85. package/dist/leaflet-DOq10gfg.js +0 -84
  86. package/dist/leaflet-loader-94z5VsdY.cjs +0 -2
  87. package/dist/leaflet-loader-Cjcdgj5R.js +0 -21
  88. package/dist/listener-bag-D5omxZ9h.cjs +0 -1
  89. package/dist/listener-bag-DQgv7OON.js +0 -34
  90. package/dist/motor-By2te6PZ.js +0 -1400
  91. package/dist/motor-CkMxd378.cjs +0 -1
  92. package/dist/opcoes-CupvWVIm.js +0 -24
  93. package/dist/opcoes-vdAUY5OI.cjs +0 -1
  94. package/dist/parts-CaoQiCfI.js +0 -7
  95. package/dist/parts-vQa2873h.cjs +0 -1
  96. package/dist/prancha-paleta-BZ-9QDgh.js +0 -5276
  97. package/dist/prancha-paleta-Bb24vP71.cjs +0 -17
  98. package/dist/ssr-safe-5cWfJP-s.js +0 -10
  99. package/dist/ssr-safe-CiHD1adl.cjs +0 -1
  100. package/dist/svg-seguro-ChVJ2L2z.js +0 -74
  101. package/dist/svg-seguro-J2RM1Ssf.cjs +0 -1
  102. package/dist/ui-badge-DE58YSBY.cjs +0 -28
  103. package/dist/ui-badge-KgmI3jOD.js +0 -201
  104. package/dist/ui-botao-Dz8YvmiA.cjs +0 -12
  105. package/dist/ui-botao-zLkcMMyP.js +0 -168
  106. package/dist/ui-bus-CUd99VJi.js +0 -177
  107. package/dist/ui-bus-XqBLlTYQ.cjs +0 -1
  108. package/dist/ui-camadas-DoHPnbQm.js +0 -3133
  109. package/dist/ui-camadas-Vx7wYD4D.cjs +0 -311
  110. package/dist/ui-campo-texto-Dliyt9qr.cjs +0 -16
  111. package/dist/ui-campo-texto-btevggO3.js +0 -379
  112. package/dist/ui-card-7IEYbCN0.js +0 -150
  113. package/dist/ui-card-Bx8EyzYY.cjs +0 -20
  114. package/dist/ui-card-DFnRp9bl.js +0 -146
  115. package/dist/ui-card-DrWVJQKw.cjs +0 -20
  116. package/dist/ui-controle-cores-B1w_Yl69.cjs +0 -32
  117. package/dist/ui-controle-cores-BRjMvmMn.js +0 -291
  118. package/dist/ui-controle-cores-BcH9k2Fa.js +0 -292
  119. package/dist/ui-controle-cores-CvSTP6gJ.cjs +0 -32
  120. package/dist/ui-editor-prancha-CIngI6yI.js +0 -2886
  121. package/dist/ui-editor-prancha-DorSe6sC.cjs +0 -31
  122. package/dist/ui-linha-2kY7TNUJ.cjs +0 -38
  123. package/dist/ui-linha-B4mBRm1x.cjs +0 -61
  124. package/dist/ui-linha-DTEIIww4.js +0 -1167
  125. package/dist/ui-linha-KFF86FW5.js +0 -752
  126. package/dist/ui-modal-BrXzVZ65.js +0 -216
  127. package/dist/ui-modal-lARKzEVZ.cjs +0 -18
  128. package/dist/ui-paleta-ferramentas-Bu6JaT0s.js +0 -1245
  129. package/dist/ui-paleta-ferramentas-D3Jhwt26.cjs +0 -21
  130. package/dist/ui-paleta-ferramentas-DebHYiwd.js +0 -1615
  131. package/dist/ui-paleta-ferramentas-Dgejtluh.js +0 -1423
  132. package/dist/ui-paleta-ferramentas-hzyo8wBt.cjs +0 -22
  133. package/dist/ui-paleta-ferramentas-jWuICjW8.cjs +0 -22
  134. package/dist/ui-seletor-cor-0RLjcME6.cjs +0 -83
  135. package/dist/ui-seletor-cor-CMuuW-Ym.cjs +0 -83
  136. package/dist/ui-seletor-cor-DFIQ1sin.js +0 -405
  137. package/dist/ui-skeleton-BLEV6h3k.js +0 -653
  138. package/dist/ui-skeleton-B_XTaGrX.cjs +0 -52
  139. package/dist/ui-switch-BXIDwC-Y.cjs +0 -66
  140. package/dist/ui-switch-Ctxk-jKS.js +0 -1212
  141. package/dist/ui-tabela-CXxqbwXv.cjs +0 -7
  142. package/dist/ui-tabela-Cd0vOwnT.js +0 -1459
  143. package/dist/ui-tabela-propriedades-C5cIF5ES.js +0 -3779
  144. package/dist/ui-tabela-propriedades-CJyo568n.js +0 -3517
  145. package/dist/ui-tabela-propriedades-D96Djx-q.cjs +0 -136
  146. package/dist/ui-tabela-propriedades-Wa34hfIr.cjs +0 -142
  147. package/dist/ui-tabela-propriedades-ahQhQauu.js +0 -2329
  148. package/dist/ui-tabela-propriedades-w9JWhjHy.cjs +0 -142
  149. package/dist/zero-js-triggers-CJT988bR.js +0 -83
  150. package/dist/zero-js-triggers-CgM9IIQB.cjs +0 -1
@@ -1,1038 +0,0 @@
1
- var xt = Object.defineProperty;
2
- var St = (n, t, o) => t in n ? xt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : n[t] = o;
3
- var S = (n, t, o) => St(n, typeof t != "symbol" ? t + "" : t, o);
4
- import { e as At, m as Y, a as Ct, c as It, d as Ot, b as mt, f as nt, g as Nt, p as B, h as K, i as dt, t as H, j as z, k as Q, l as Dt } from "./geometria-px-DKrWq_XY.js";
5
- const Et = 111320;
6
- function bt(n) {
7
- const { lat: t, lng: o } = Y(n[0]), e = n[0], s = n[1], r = t, a = Math.max(o, 1);
8
- return {
9
- paraXY: (i) => [(i[1] - s) * a, (i[0] - e) * r],
10
- deXY: (i) => [e + i[1] / r, s + i[0] / a]
11
- };
12
- }
13
- const A = Object.freeze({
14
- tipo: "geografico",
15
- unidade: "m",
16
- distancia: (n, t) => Ot(n, t),
17
- comprimento: (n, t = !1) => It(n, t),
18
- area: (n) => Ct(n),
19
- planoLocal: bt,
20
- deslocar(n, t, o) {
21
- const e = Y(n[0]), s = o / e.lat, r = t / Math.max(e.lng, 1);
22
- return [n[0] + s, n[1] + r];
23
- },
24
- pontoDaBorda(n, t) {
25
- return [n[0], n[1] + t / Math.max(Y(n[0]).lng, 1)];
26
- },
27
- pontoDeMedidaDoRaio: (n, t) => [n[0] + t / Et, n[1]],
28
- extremosDoCirculo: At,
29
- fatorEixo: (n) => Math.cos(n[0] * Math.PI / 180) || 1
30
- });
31
- function _t(n, t) {
32
- const o = (e) => {
33
- let s = !1;
34
- for (let r = 0, a = e.length - 1; r < e.length; a = r++) {
35
- const [i, c] = e[r], [l, u] = e[a];
36
- i > n[0] != l > n[0] && n[1] < (u - c) * (n[0] - i) / (l - i) + c && (s = !s);
37
- }
38
- return s;
39
- };
40
- return !t[0] || !o(t[0]) ? !1 : !t.slice(1).some(o);
41
- }
42
- function gt(n, t, o, e) {
43
- const s = t[0] - n[0], r = t[1] - n[1], a = e[0] - o[0], i = e[1] - o[1], c = s * i - r * a;
44
- if (Math.abs(c) < 1e-12) return null;
45
- const l = ((o[0] - n[0]) * i - (o[1] - n[1]) * a) / c, u = ((o[0] - n[0]) * r - (o[1] - n[1]) * s) / c;
46
- return l < 0 || l > 1 || u < 0 || u >= 1 ? null : { t: l, u };
47
- }
48
- function $(n) {
49
- let t = 0;
50
- for (let o = 0; o < n.length; o++) {
51
- const [e, s] = n[o], [r, a] = n[(o + 1) % n.length];
52
- t += e * a - r * s;
53
- }
54
- return Math.abs(t) / 2;
55
- }
56
- function un(n, t, o = A) {
57
- if (n.length < 3 || t.length < 2) return null;
58
- const e = o.planoLocal(n[0]), s = b(n, e), r = b(t, e), a = yt(s, r, 0);
59
- return a && a.length >= 2 ? a.map((i) => j(i, e)) : null;
60
- }
61
- function yt(n, t, o) {
62
- if (o > 8) return null;
63
- const e = n.length, s = [];
64
- for (let f = 0; f < t.length - 1; f++)
65
- for (let M = 0; M < e; M++) {
66
- const v = gt(t[f], t[f + 1], n[M], n[(M + 1) % e]);
67
- v && s.push({
68
- tLinha: f + v.t,
69
- tAnel: M + v.u,
70
- ponto: [t[f][0] + v.t * (t[f + 1][0] - t[f][0]), t[f][1] + v.t * (t[f + 1][1] - t[f][1])]
71
- });
72
- }
73
- if (s.sort((f, M) => f.tLinha - M.tLinha), s.length < 2) return null;
74
- const [r, a] = s, i = [];
75
- for (let f = Math.floor(r.tLinha) + 1; f <= Math.floor(a.tLinha); f++)
76
- f > r.tLinha && f < a.tLinha && i.push(t[f]);
77
- const c = [r.ponto, ...i, a.ponto];
78
- let l = r, u = a, h = c;
79
- r.tAnel > a.tAnel && (l = a, u = r, h = [...c].reverse());
80
- const p = Math.floor(l.tAnel), d = Math.floor(u.tAnel), P = h.slice(1, -1), g = [l.ponto];
81
- for (let f = p + 1; f <= d; f++) g.push(n[f % e]);
82
- g.push(u.ponto, ...[...P].reverse());
83
- const y = [u.ponto];
84
- for (let f = d + 1; f <= p + e; f++) y.push(n[f % e]);
85
- y.push(l.ponto, ...P);
86
- const F = $(n) * 1e-9, C = [g, y].filter((f) => f.length >= 3 && $(f) > F);
87
- if (C.length < 2) return null;
88
- const m = [a.ponto, ...t.slice(Math.floor(a.tLinha) + 1)];
89
- if (s.length > 2 && m.length >= 2) {
90
- const f = [];
91
- for (const M of C) {
92
- const v = yt(M, m, o + 1);
93
- v ? f.push(...v) : f.push(M);
94
- }
95
- return f;
96
- }
97
- return C;
98
- }
99
- function b(n, t) {
100
- return n.map((o) => t.paraXY(o));
101
- }
102
- function j(n, t) {
103
- return n.map((o) => t.deXY(o));
104
- }
105
- const E = (n, t) => Math.hypot(n[0] - t[0], n[1] - t[1]);
106
- function hn(n, t = 0, o = A) {
107
- if (n.length === 0 || n.some((a) => a.length < 2)) return null;
108
- const e = o.planoLocal(n[0][0]), s = n.slice(1).map((a) => b(a, e));
109
- let r = b(n[0], e);
110
- for (; s.length > 0; ) {
111
- let a = null;
112
- if (s.forEach((h, p) => {
113
- const d = r[0], P = r[r.length - 1], g = [
114
- { inverter: !1, noFim: !0, d: E(P, h[0]) },
115
- { inverter: !0, noFim: !0, d: E(P, h[h.length - 1]) },
116
- { inverter: !1, noFim: !1, d: E(d, h[h.length - 1]) },
117
- { inverter: !0, noFim: !1, d: E(d, h[0]) }
118
- ];
119
- for (const y of g) (!a || y.d < a.d) && (a = { idx: p, ...y });
120
- }), !a || a.d > t) return null;
121
- const { idx: i, inverter: c, noFim: l } = a;
122
- let u = s.splice(i, 1)[0];
123
- c && (u = [...u].reverse()), r = l ? [...r, ...E(r[r.length - 1], u[0]) > 0 ? u : u.slice(1)] : [...u, ...E(u[u.length - 1], r[0]) > 0 ? r : r.slice(1)];
124
- }
125
- return j(r, e);
126
- }
127
- function Tt(n, t, o, e) {
128
- const s = gt(n, t, o, e);
129
- return !!s && s.t > 1e-9 && s.t < 1 - 1e-9 && s.u > 1e-9;
130
- }
131
- function Rt(n, t) {
132
- for (let o = 0; o < n.length; o++)
133
- for (let e = 0; e < t.length; e++)
134
- if (Tt(n[o], n[(o + 1) % n.length], t[e], t[(e + 1) % t.length])) return !0;
135
- return !1;
136
- }
137
- function fn(n, t, o = 0, e = A) {
138
- if (n.length < 3 || t.length < 3) return null;
139
- const s = e.planoLocal(n[0]), r = b(n, s), a = b(t, s);
140
- if (Rt(r, a)) return null;
141
- let i = { i: 0, j: 0, d: 1 / 0 };
142
- for (let h = 0; h < r.length; h++)
143
- for (let p = 0; p < a.length; p++) {
144
- const d = E(r[h], a[p]);
145
- d < i.d && (i = { i: h, j: p, d });
146
- }
147
- if (i.d > o) return null;
148
- const { i: c, j: l } = i, u = [];
149
- for (let h = 0; h <= r.length; h++) u.push(r[(c + h) % r.length]);
150
- for (let h = 0; h <= a.length; h++) u.push(a[(l + h) % a.length]);
151
- return j(u, s);
152
- }
153
- const ot = 16;
154
- function et(n, t, o, e) {
155
- const s = [];
156
- for (let r = 0; r <= ot; r++) {
157
- const a = o + (e - o) * r / ot;
158
- s.push([n[0] + t * Math.cos(a), n[1] + t * Math.sin(a)]);
159
- }
160
- return s;
161
- }
162
- function G(n, t) {
163
- const o = E(n, t) || 1;
164
- return [-(t[1] - n[1]) / o, (t[0] - n[0]) / o];
165
- }
166
- function J(n, t, o) {
167
- const e = n.length, s = [], r = e;
168
- for (let a = 0; a < r; a++) {
169
- const i = o ? n[(a - 1 + e) % e] : n[Math.max(0, a - 1)], c = n[a], l = o ? n[(a + 1) % e] : n[Math.min(e - 1, a + 1)], u = a === 0 && !o ? G(c, l) : G(i, c), h = a === e - 1 && !o ? G(i, c) : G(c, l);
170
- let p = u[0] + h[0], d = u[1] + h[1];
171
- const P = Math.hypot(p, d);
172
- if (P < 1e-9) {
173
- s.push([c[0] + u[0] * t, c[1] + u[1] * t]);
174
- continue;
175
- }
176
- p /= P, d /= P;
177
- const g = p * u[0] + d * u[1], y = Math.min(1 / Math.max(g, 0.5), 2);
178
- s.push([c[0] + p * t * y, c[1] + d * t * y]);
179
- }
180
- return s;
181
- }
182
- function Ft(n) {
183
- let t = 0;
184
- for (let o = 0; o < n.length; o++) {
185
- const [e, s] = n[o], [r, a] = n[(o + 1) % n.length];
186
- t += (r - e) * (a + s);
187
- }
188
- return t > 0;
189
- }
190
- function pn(n, t, o = A) {
191
- if (!Number.isFinite(t) || t === 0) return null;
192
- if (n.tipo === "Point" || n.tipo === "Text" || n.tipo === "Circle") {
193
- const e = n.tipo === "Circle" ? n.centro : n.coordenada, s = n.tipo === "Circle" ? n.raioMetros + t : t;
194
- if (s <= 0) return null;
195
- const r = o.planoLocal(e), a = 64;
196
- return Array.from({ length: a }, (i, c) => [s * Math.cos(2 * Math.PI * c / a), s * Math.sin(2 * Math.PI * c / a)]).map((i) => r.deXY(i));
197
- }
198
- if (n.tipo === "LineString") {
199
- if (t < 0 || n.coordenadas.length < 2 || mt(n)) return null;
200
- const e = o.planoLocal(n.coordenadas[0]), s = b(n.coordenadas, e), r = J(s, t, !1), a = J([...s].reverse(), t, !1), i = s[s.length - 1], c = s[0], l = Math.atan2(i[1] - s[s.length - 2][1], i[0] - s[s.length - 2][0]), u = Math.atan2(c[1] - s[1][1], c[0] - s[1][0]), h = et(i, t, l + Math.PI / 2, l - Math.PI / 2), p = et(c, t, u + Math.PI / 2, u - Math.PI / 2);
201
- return j([...r, ...h, ...a, ...p], e);
202
- }
203
- if (n.tipo === "Polygon") {
204
- const e = n.aneis[0];
205
- if (!e || e.length < 3) return null;
206
- const s = o.planoLocal(e[0]);
207
- let r = b(e, s);
208
- Ft(r) && (r = [...r].reverse());
209
- const i = J(r, -t, !0);
210
- return i.length < 3 || t < 0 && $(i) >= $(r) ? null : j(i, s);
211
- }
212
- return null;
213
- }
214
- function mn(n, t, o, e = A) {
215
- const s = (r) => e.deslocar(r, t, o);
216
- switch (n.tipo) {
217
- case "Point":
218
- return { tipo: "Point", coordenada: s(n.coordenada) };
219
- case "Text":
220
- return { ...n, coordenada: s(n.coordenada) };
221
- case "Circle":
222
- return { ...n, centro: s(n.centro) };
223
- case "LineString": {
224
- const r = Nt(B(n).map((a) => a.map(s)));
225
- return n.curva ? { ...r, curva: nt(n.curva, s) } : r;
226
- }
227
- case "Polygon": {
228
- const r = { tipo: "Polygon", aneis: n.aneis.map((a) => a.map(s)) };
229
- return n.curva ? { ...r, curva: nt(n.curva, s) } : r;
230
- }
231
- }
232
- }
233
- const rt = { m: 1, km: 1e3, ft: 0.3048, mi: 1609.344 }, st = { m2: 1, ha: 1e4, km2: 1e6, ac: 4046.8564224, alqueire: 24200 };
234
- function dn(n, t, o) {
235
- return n * rt[t] / rt[o];
236
- }
237
- function gn(n, t, o) {
238
- return n * st[t] / st[o];
239
- }
240
- function yn(n, t, o = 2) {
241
- const e = t === "lat" ? n < 0 ? "S" : "N" : n < 0 ? "O" : "L", s = Math.abs(n);
242
- let r = Math.floor(s), a = Math.floor((s - r) * 60), i = Number(((s - r - a / 60) * 3600).toFixed(o));
243
- i >= 60 && (i = 0, a += 1), a >= 60 && (a = 0, r += 1);
244
- const c = i.toFixed(o).padStart(o ? o + 3 : 2, "0");
245
- return `${r}°${String(a).padStart(2, "0")}'${c}"${e}`;
246
- }
247
- function Pn(n) {
248
- var p;
249
- if (typeof n != "string") return null;
250
- const t = n.trim().toUpperCase().replace(",", "."), o = (p = /[NSLEOW]$/.exec(t)) == null ? void 0 : p[0], e = t.replace(/[NSLEOW]$/, "").trim(), s = e.match(/-?\d+(?:\.\d+)?/g);
251
- if (!s || s.length === 0 || s.length > 3 || !/^[-\d\s°'"′″.]+$/.test(e)) return null;
252
- const [r, a = "0", i = "0"] = s, c = Math.abs(Number(r)), l = Number(a), u = Number(i);
253
- if (l < 0 || l >= 60 || u < 0 || u >= 60) return null;
254
- let h = c + l / 60 + u / 3600;
255
- return (r.startsWith("-") || o === "S" || o === "O" || o === "W") && (h = -h), h;
256
- }
257
- function Mn(n, t, o = A) {
258
- return o.distancia(n, t);
259
- }
260
- function vn(n, t, o) {
261
- return {
262
- ...n,
263
- id: t,
264
- geometria: o ?? JSON.parse(JSON.stringify(n.geometria)),
265
- estilo: n.estilo ? { ...n.estilo } : void 0,
266
- propriedades: { ...n.propriedades }
267
- };
268
- }
269
- const kt = 5e3;
270
- function Z(n) {
271
- return n.tipo === "Polygon" ? 3 : n.tipo === "LineString" ? 2 : 1;
272
- }
273
- function Ln(n, t = !1) {
274
- if (n.bloqueada || t) return "bloqueada";
275
- const o = n.geometria;
276
- return o.tipo !== "Point" && o.tipo !== "LineString" && o.tipo !== "Polygon" && o.tipo !== "Circle" ? "tipo-nao-suportado" : o.tipo === "Polygon" && o.aneis.length !== 1 ? "poligono-com-furos" : mt(o) ? "multiparte" : I(o).length > kt ? "muitos-vertices" : null;
277
- }
278
- function I(n) {
279
- return n.tipo === "Point" ? [n.coordenada] : n.tipo === "LineString" ? n.coordenadas : n.tipo === "Polygon" ? n.aneis[0] ?? [] : [];
280
- }
281
- function W(n, t) {
282
- return n.tipo === "Point" ? { tipo: "Point", coordenada: t[0] } : n.tipo === "LineString" ? { tipo: "LineString", coordenadas: t } : n.tipo === "Polygon" ? { tipo: "Polygon", aneis: [t] } : n;
283
- }
284
- function xn(n, t, o) {
285
- const e = I(n).slice();
286
- return t < 0 || t >= e.length ? n : (e[t] = o, W(n, e));
287
- }
288
- function qt(n, t, o) {
289
- if (n.tipo !== "LineString" && n.tipo !== "Polygon") return n;
290
- const e = I(n).slice();
291
- return t < 0 || t >= e.length ? n : (e.splice(t + 1, 0, o), W(n, e));
292
- }
293
- function wt(n, t) {
294
- if (n.tipo !== "LineString" && n.tipo !== "Polygon") return null;
295
- const o = I(n);
296
- return t < 0 || t >= o.length || o.length <= Z(n) ? null : W(n, o.filter((e, s) => s !== t));
297
- }
298
- function Pt(n, t) {
299
- return [(n[0] + t[0]) / 2, (n[1] + t[1]) / 2];
300
- }
301
- function Xt(n) {
302
- const t = I(n).length, o = [];
303
- if (n.tipo !== "LineString" && n.tipo !== "Polygon") return o;
304
- for (let e = 0; e < t - 1; e++) o.push([e, e + 1]);
305
- return n.tipo === "Polygon" && t > 2 && o.push([t - 1, 0]), o;
306
- }
307
- function _(n) {
308
- return (n.tipo === "LineString" || n.tipo === "Polygon") && n.curva && n.curva.length >= Z(n) ? n.curva : null;
309
- }
310
- const jt = 0.5;
311
- function Gt(n, t, o = A) {
312
- return o.pontoDaBorda(n, t);
313
- }
314
- function Sn(n, t = A) {
315
- var o;
316
- return n.tipo === "Circle" ? [n.centro, Gt(n.centro, n.raioMetros, t)] : ((o = _(n)) == null ? void 0 : o.map((e) => e.ponto)) ?? I(n);
317
- }
318
- function q(n, t) {
319
- const o = n.tipo === "Polygon", e = z(t, o);
320
- return o ? { tipo: "Polygon", aneis: [e], curva: t } : { tipo: "LineString", coordenadas: e, curva: t };
321
- }
322
- function An(n, t, o = A) {
323
- if (n.tipo === "Circle")
324
- return t.length < 2 ? n : { ...n, centro: t[0], raioMetros: Math.max(jt, o.distancia(t[0], t[1])) };
325
- const e = _(n);
326
- if (!e || e.length !== t.length) return W(n, t);
327
- const s = e.map((r, a) => {
328
- const i = t[a][0] - r.ponto[0], c = t[a][1] - r.ponto[1], l = (h) => [h[0] + i, h[1] + c], u = { ponto: t[a] };
329
- return r.entrada && (u.entrada = l(r.entrada)), r.saida && (u.saida = l(r.saida)), r.modo && (u.modo = r.modo), u;
330
- });
331
- return q(n, s);
332
- }
333
- function k(n, t, o) {
334
- return [n[0] + (t[0] - n[0]) * o, n[1] + (t[1] - n[1]) * o];
335
- }
336
- function Vt(n, t, o) {
337
- const [e, s] = K(n, t);
338
- let r = 0.5, a = 1 / 0;
339
- for (let i = 1; i < 64; i++) {
340
- const c = i / 64, l = dt(n.ponto, e, s, t.ponto, c), u = (l[0] - o[0]) ** 2 + (l[1] - o[1]) ** 2;
341
- u < a && (a = u, r = c);
342
- }
343
- return r;
344
- }
345
- function Yt(n, t, o) {
346
- const e = _(n);
347
- if (!e) {
348
- const a = I(n);
349
- return Pt(a[t], a[o]);
350
- }
351
- const [s, r] = K(e[t], e[o]);
352
- return dt(e[t].ponto, s, r, e[o].ponto, 0.5);
353
- }
354
- function zt(n) {
355
- const t = _(n);
356
- if (!t) return Xt(n);
357
- const o = [];
358
- for (let e = 0; e < t.length - 1; e++) o.push([e, e + 1]);
359
- return n.tipo === "Polygon" && t.length > 2 && o.push([t.length - 1, 0]), o;
360
- }
361
- function Cn(n, t, o) {
362
- const e = _(n);
363
- if (!e) return qt(n, t, o);
364
- if (t < 0 || t >= e.length) return n;
365
- const s = (t + 1) % e.length, r = e[t], a = e[s], i = r.saida === void 0 && a.entrada === void 0;
366
- let c, l = r, u = a;
367
- if (i)
368
- c = { ponto: o };
369
- else {
370
- const p = Vt(r, a, o), [d, P] = K(r, a), g = k(r.ponto, d, p), y = k(d, P, p), R = k(P, a.ponto, p), F = k(g, y, p), C = k(y, R, p);
371
- c = { ponto: k(F, C, p), entrada: F, saida: C, modo: "suave" }, l = { ...r, saida: g }, u = { ...a, entrada: R }, H(r) === "simetrico" && r.entrada && (l.modo = "suave"), H(a) === "simetrico" && a.saida && (u.modo = "suave");
372
- }
373
- const h = e.slice();
374
- return h[t] = l, h[s] = u, h.splice(t + 1, 0, c), q(n, h);
375
- }
376
- function In(n, t) {
377
- const o = _(n);
378
- return o ? t < 0 || t >= o.length || o.length <= Z(n) ? null : q(n, o.filter((e, s) => s !== t)) : wt(n, t);
379
- }
380
- function tt(n) {
381
- return n.tipo !== "LineString" && n.tipo !== "Polygon" ? null : _(n) ?? I(n).map((t) => ({ ponto: [t[0], t[1]] }));
382
- }
383
- const On = 40;
384
- function Nn(n, t, o) {
385
- const e = tt(n);
386
- if (!e || t < 0 || t >= e.length) return null;
387
- const s = n.tipo === "Polygon", r = e.length, a = o === "saida" ? t < r - 1 ? e[t + 1] : s ? e[0] : null : t > 0 ? e[t - 1] : s ? e[r - 1] : null;
388
- if (!a) return null;
389
- const i = e[t].ponto;
390
- return [i[0] + (a.ponto[0] - i[0]) / 3, i[1] + (a.ponto[1] - i[1]) / 3];
391
- }
392
- function $t(n) {
393
- const t = Y(n[0]);
394
- return { ref: n, mLat: Math.max(t.lat, 1e-9), mLng: Math.max(t.lng, 1e-9) };
395
- }
396
- const at = (n, t) => [(t[1] - n.ref[1]) * n.mLng, (t[0] - n.ref[0]) * n.mLat], Bt = (n, t, o) => [n.ref[0] + o / n.mLat, n.ref[1] + t / n.mLng], Wt = (n) => Array.isArray(n) && n.length === 2 && Number.isFinite(n[0]) && Number.isFinite(n[1]);
397
- function Jt(n, t, o, e, s = !1) {
398
- const r = H(n), a = s ? "livre" : r === "canto" ? e : r, i = t === "saida" ? "entrada" : "saida", c = { ...n, [t]: o, modo: a };
399
- if (a === "simetrico")
400
- c[i] = Q(n.ponto, o);
401
- else if (a === "suave") {
402
- const l = $t(n.ponto), [u, h] = at(l, o), p = Math.hypot(u, h), d = n[i], [P, g] = d ? at(l, d) : [u, h], y = Math.hypot(P, g);
403
- p > 0 && y > 0 && (c[i] = Bt(l, -(u / p) * y, -(h / p) * y));
404
- }
405
- return c;
406
- }
407
- function Dn(n, t, o, e, s = !0) {
408
- const r = tt(n);
409
- if (!r || t < 0 || t >= r.length || !Wt(e)) return n;
410
- const a = r.slice();
411
- return a[t] = Jt(r[t], o, e, "simetrico", !s), q(n, a);
412
- }
413
- function En(n, t) {
414
- const o = tt(n);
415
- if (!o || t < 0 || t >= o.length) return n;
416
- const e = o[t], s = o.slice();
417
- if (e.entrada || e.saida)
418
- return s[t] = { ponto: e.ponto }, q(n, s);
419
- const r = n.tipo === "Polygon", a = o.length, i = t > 0 ? o[t - 1] : r ? o[a - 1] : null, c = t < a - 1 ? o[t + 1] : r ? o[0] : null;
420
- if (!i && !c) return n;
421
- const l = e.ponto;
422
- let u, h;
423
- if (i && c)
424
- u = (c.ponto[0] - i.ponto[0]) / 6, h = (c.ponto[1] - i.ponto[1]) / 6;
425
- else {
426
- const p = (c ?? i).ponto, d = c ? 1 : -1;
427
- u = (p[0] - l[0]) / 3 * d, h = (p[1] - l[1]) / 3 * d;
428
- }
429
- return s[t] = { ponto: l, saida: [l[0] + u, l[1] + h], entrada: [l[0] - u, l[1] - h] }, q(n, s);
430
- }
431
- const Ut = "rgba(255,255,255,0.9)";
432
- function Ht(n) {
433
- if (!n) return [];
434
- const t = n.split(/[\s,]+/).map(Number).filter((o) => Number.isFinite(o) && o >= 0);
435
- return t.length > 0 && t.some((o) => o > 0) ? t.length % 2 === 1 ? [...t, ...t] : t : [];
436
- }
437
- const D = (n) => Number.isFinite(n), Kt = /* @__PURE__ */ new Set(["marca", "poligono", "circulo", "linha", "ponto"]);
438
- function bn(n) {
439
- let t = 0;
440
- if (n)
441
- for (const o of n.itens) Kt.has(o.forma) && t++;
442
- return t;
443
- }
444
- class _n {
445
- constructor(t) {
446
- S(this, "destaques", /* @__PURE__ */ new Set());
447
- S(this, "destruido", !1);
448
- /** Estatística da última pintura (diagnóstico e testes). */
449
- S(this, "ultima", { itens: 0, marcas: 0, preenchimentos: 0, tracos: 0, chamadas: 0 });
450
- /** Perfil de qualidade `baixa`: ignora `dash` (linha contínua, mais barata no Canvas 2D). */
451
- S(this, "semTracejado", !1);
452
- this.alvos = t;
453
- }
454
- definirTracejado(t) {
455
- this.semTracejado = !t;
456
- }
457
- destacar(t) {
458
- this.destaques = new Set(t);
459
- }
460
- limpar() {
461
- const t = this.alvos.sobreposicao();
462
- t && this.limparSuperficie(t);
463
- }
464
- destruir() {
465
- this.destruido = !0, this.destaques.clear();
466
- }
467
- desenhar(t, o, e = {}) {
468
- const s = { itens: 0, marcas: 0, preenchimentos: 0, tracos: 0, chamadas: 0 };
469
- if (this.destruido || !t) return s;
470
- const r = e.alvo === "sobreposicao", a = o && D(o.dpr) && o.dpr > 0 ? o.dpr : 1;
471
- if (r) {
472
- const i = this.alvos.sobreposicao();
473
- i && e.limpar !== !1 && this.limparSuperficie(i, a);
474
- }
475
- for (const i of t.camadas) {
476
- const c = r ? this.alvos.sobreposicao() : this.alvos.camada(i.camadaId);
477
- if (!c) continue;
478
- !r && e.limpar !== !1 ? this.limparSuperficie(c, a) : c.ctx.setTransform(a, 0, 0, a, 0, 0);
479
- const l = e.recorte;
480
- l && (c.ctx.save(), c.ctx.beginPath(), c.ctx.rect(l.x, l.y, l.largura, l.altura), c.ctx.clip());
481
- try {
482
- this.pintarCamada(c, i, t.origem, r, s);
483
- } finally {
484
- l && c.ctx.restore();
485
- }
486
- }
487
- return this.ultima = s, s;
488
- }
489
- limparSuperficie(t, o) {
490
- const e = o ?? t.dpr;
491
- t.ctx.setTransform(1, 0, 0, 1, 0, 0), t.ctx.clearRect(0, 0, Math.ceil(t.largura * e), Math.ceil(t.altura * e)), t.ctx.setTransform(e, 0, 0, e, 0, 0);
492
- }
493
- pintarCamada(t, o, e, s, r) {
494
- const a = t.ctx, i = [], c = [], l = [], u = [];
495
- for (const h of o.itens)
496
- switch (h.forma) {
497
- case "marca":
498
- i.push(h);
499
- break;
500
- case "poligono":
501
- case "circulo":
502
- c.push(h);
503
- break;
504
- case "linha":
505
- l.push(h);
506
- break;
507
- case "ponto":
508
- u.push(h);
509
- break;
510
- }
511
- if (r.itens += i.length + c.length + l.length + u.length, a.lineJoin = "round", a.lineCap = "round", s)
512
- for (const h of [...c, ...l, ...u]) (h.destaque || this.destaques.has(h.id)) && this.halo(a, h, e, r);
513
- this.pintarMarcas(a, i, e, r), this.pintarGrupos(a, c, e, r, !0), this.pintarGrupos(a, l, e, r, !1), this.pintarGrupos(a, u, e, r, !0), a.globalAlpha = 1, a.setLineDash([]), a.lineDashOffset = 0;
514
- }
515
- agrupar(t) {
516
- const o = /* @__PURE__ */ new Map();
517
- for (const e of t) {
518
- const s = o.get(e.estilo);
519
- s ? s.push(e) : o.set(e.estilo, [e]);
520
- }
521
- return o;
522
- }
523
- /** Marcas de LOD: `fillRect` por marca, a cor definida uma vez por grupo. */
524
- pintarMarcas(t, o, e, s) {
525
- for (const [r, a] of this.agrupar(o)) {
526
- t.fillStyle = r.corPreenchimento, t.globalAlpha = r.opacidadePreenchimento, s.chamadas += 2;
527
- for (const i of a) {
528
- const c = i.geometriaEmPx[0];
529
- if (!c) continue;
530
- const l = c[0] - e.x, u = c[1] - e.y;
531
- if (!(D(l) && D(u))) continue;
532
- const h = i.raioPx >= 2 ? 2 : 1;
533
- t.fillRect(Math.round(l - h / 2), Math.round(u - h / 2), h, h), s.marcas++, s.chamadas++;
534
- }
535
- }
536
- }
537
- /** Caminho de um item: anéis/partes (polígono e linha), círculo ou ponto. */
538
- caminho(t, o, e) {
539
- if (o.forma === "circulo" || o.forma === "ponto") {
540
- const r = o.geometriaEmPx[0];
541
- if (!r) return;
542
- const a = r[0] - e.x, i = r[1] - e.y;
543
- D(a) && D(i) && D(o.raioPx) && (t.moveTo(a + o.raioPx, i), t.arc(a, i, o.raioPx, 0, Math.PI * 2));
544
- return;
545
- }
546
- const s = o.forma === "poligono";
547
- for (const r of o.geometriaEmPx) {
548
- const a = r.length >> 1;
549
- if (a < 2) continue;
550
- let i = !1;
551
- for (let c = 0; c < a; c++) {
552
- const l = r[c * 2] - e.x, u = r[c * 2 + 1] - e.y;
553
- D(l) && D(u) && (i ? t.lineTo(l, u) : (t.moveTo(l, u), i = !0));
554
- }
555
- i && s && t.closePath();
556
- }
557
- }
558
- /**
559
- * Polígonos, círculos, linhas e pontos: o estilo do grupo é definido uma vez; cada forma é um caminho próprio com
560
- * preenchimento (se o estilo preenche) e traço. `areas` = tipos que podem ser preenchidos.
561
- */
562
- pintarGrupos(t, o, e, s, r) {
563
- for (const [a, i] of this.agrupar(o)) {
564
- const c = r && a.preencher && a.opacidadePreenchimento > 0, l = a.traco && a.peso > 0;
565
- if (!(!c && !l)) {
566
- c && (t.fillStyle = a.corPreenchimento), l && (t.strokeStyle = a.cor, t.lineWidth = a.peso, t.setLineDash(this.semTracejado ? [] : Ht(a.dash)), t.lineDashOffset = this.semTracejado ? 0 : a.deslocamentoDash ?? 0, t.lineCap = a.terminacao ?? "round", t.lineJoin = a.juncao ?? "round"), s.chamadas += 3;
567
- for (const u of i)
568
- t.beginPath(), this.caminho(t, u, e), c && (t.globalAlpha = a.opacidadePreenchimento, t.fill(), s.preenchimentos++, s.chamadas++), l && (t.globalAlpha = a.opacidadeTraco ?? 1, t.stroke(), s.tracos++, s.chamadas++);
569
- }
570
- }
571
- }
572
- /** Halo de destaque (hover): traço claro, mais grosso, por baixo do desenho normal. */
573
- halo(t, o, e, s) {
574
- t.strokeStyle = Ut, t.lineWidth = Math.max(o.estilo.peso, 1) + 4, t.globalAlpha = 0.9, t.setLineDash([]), t.lineCap = "round", t.lineJoin = "round", t.beginPath(), this.caminho(t, o, e), t.stroke(), s.tracos++, s.chamadas += 4;
575
- }
576
- }
577
- const it = 36, ct = 0.45;
578
- function Qt(n, t) {
579
- const o = Math.abs(t[0] - n[0]), e = Math.abs(t[1] - n[1]);
580
- if (o === 0 && e === 0) return null;
581
- const s = [];
582
- for (let r = 0; r < it; r++) {
583
- const a = r * 2 * Math.PI / it;
584
- s.push([n[0] + o * Math.sin(a), n[1] + e * Math.cos(a)]);
585
- }
586
- return s;
587
- }
588
- function Mt(n, t, o) {
589
- const e = o.fatorEixo(n), s = t[0] - n[0], r = (t[1] - n[1]) * e, a = Math.hypot(s, r);
590
- return a === 0 ? null : { raio: a, inicio: Math.atan2(s, r), cosLat: e };
591
- }
592
- function Zt(n, t, o = 6, e = A) {
593
- const s = Mt(n, t, e);
594
- if (!s || o < 3) return null;
595
- const r = [];
596
- for (let a = 0; a < o; a++) {
597
- const i = s.inicio + a * 2 * Math.PI / o;
598
- r.push([n[0] + s.raio * Math.sin(i), n[1] + s.raio * Math.cos(i) / s.cosLat]);
599
- }
600
- return r;
601
- }
602
- function tn(n, t, o = 5, e = A, s = ct) {
603
- const r = Mt(n, t, e);
604
- if (!r || o < 3) return null;
605
- const a = Number.isFinite(s) && s > 0 && s <= 1 ? s : ct, i = o * 2, c = [];
606
- for (let l = 0; l < i; l++) {
607
- const u = l % 2 === 0 ? r.raio : r.raio * a, h = r.inicio + l * 2 * Math.PI / i;
608
- c.push([n[0] + u * Math.sin(h), n[1] + u * Math.cos(h) / r.cosLat]);
609
- }
610
- return c;
611
- }
612
- const nn = [
613
- "ponto",
614
- "linha",
615
- "poligono",
616
- "retangulo",
617
- "elipse",
618
- "poligono-regular",
619
- "estrela",
620
- "circulo",
621
- "texto",
622
- "caneta",
623
- "medir-distancia",
624
- "medir-area",
625
- "dividir",
626
- "selecao-laco",
627
- "conta-gotas"
628
- ], on = 2, lt = (n, t, o, e) => typeof n == "number" && Number.isFinite(n) ? Math.min(o, Math.max(t, Math.round(n))) : e;
629
- function Tn(n) {
630
- return typeof n == "string" && nn.includes(n);
631
- }
632
- function vt(n) {
633
- return n.entrada ?? (n.alca ? Q(n.ponto, n.alca) : void 0);
634
- }
635
- function V(n) {
636
- return n.map((t) => {
637
- const o = { ponto: t.ponto };
638
- return t.alca ? (o.saida = t.alca, o.entrada = vt(t)) : t.entrada && (o.entrada = t.entrada), o;
639
- });
640
- }
641
- function en(n) {
642
- return z(V(n), !1);
643
- }
644
- function U(n, t) {
645
- const o = Dt(n);
646
- if (t) {
647
- const s = o ? z(n, !0) : n.map((r) => r.ponto);
648
- return o ? { tipo: "Polygon", aneis: [s], curva: n } : { tipo: "Polygon", aneis: [s] };
649
- }
650
- const e = o ? z(n, !1) : n.map((s) => s.ponto);
651
- return o ? { tipo: "LineString", coordenadas: e, curva: n } : { tipo: "LineString", coordenadas: e };
652
- }
653
- const rn = (n, t) => n[0] === t[0] && n[1] === t[1];
654
- class Rn {
655
- constructor(t, o = !1, e = {}) {
656
- S(this, "pontos", []);
657
- S(this, "cursor", null);
658
- S(this, "ancoras", []);
659
- S(this, "espaco");
660
- S(this, "raioMinimo");
661
- S(this, "lados");
662
- S(this, "pontas");
663
- S(this, "proporcaoInterna");
664
- this.ferramenta = t, this.fechar = o, this.espaco = e.espaco ?? A;
665
- const s = e.raioMinimoCirculo;
666
- this.raioMinimo = typeof s == "number" && Number.isFinite(s) && s >= 0 ? s : on, this.lados = lt(e.ladosPoligono, 3, 360, 6), this.pontas = lt(e.pontasEstrela, 3, 360, 5), this.proporcaoInterna = e.proporcaoInternaEstrela;
667
- }
668
- /** Formas de dois cliques (centro + ponto da borda) cuja geometria vem de um gerador. */
669
- formaDeDoisCliques(t, o) {
670
- return this.ferramenta === "elipse" ? Qt(t, o) : this.ferramenta === "poligono-regular" ? Zt(t, o, this.lados, this.espaco) : tn(t, o, this.pontas, this.espaco, this.proporcaoInterna);
671
- }
672
- /** Quantos vértices/âncoras já foram colocados. */
673
- get nos() {
674
- return this.ferramenta === "caneta" ? this.ancoras.length : this.pontos.length;
675
- }
676
- /** A ferramenta aceita vários cliques e termina com Enter/duplo clique? */
677
- get ehSequencial() {
678
- return ["linha", "poligono", "caneta", "medir-distancia", "medir-area", "dividir", "selecao-laco"].includes(this.ferramenta);
679
- }
680
- get ehArea() {
681
- return this.ferramenta === "poligono" || this.ferramenta === "medir-area" || this.ferramenta === "selecao-laco" || this.ferramenta === "caneta" && this.fechar;
682
- }
683
- /** Um clique perto do primeiro vértice fecha a figura? (polígono, laço, medir área e caneta com 3+ vértices) */
684
- get fechaNoPrimeiro() {
685
- return this.nos >= 3 && (this.ehArea || this.ferramenta === "caneta");
686
- }
687
- /** Posição do primeiro vértice/âncora (alvo do fechamento), se houver. */
688
- get primeiro() {
689
- var t;
690
- return (this.ferramenta === "caneta" ? (t = this.ancoras[0]) == null ? void 0 : t.ponto : this.pontos[0]) ?? null;
691
- }
692
- get minimo() {
693
- return this.ehArea ? 3 : 2;
694
- }
695
- get podeConcluir() {
696
- return this.ehSequencial && this.nos >= this.minimo;
697
- }
698
- mover(t) {
699
- this.cursor = t;
700
- }
701
- clicar(t) {
702
- switch (this.ferramenta) {
703
- case "ponto":
704
- return { concluida: { tipo: "Point", coordenada: t } };
705
- case "texto":
706
- return { concluida: { tipo: "Text", coordenada: t, texto: "" } };
707
- case "retangulo":
708
- if (this.pontos.length === 0)
709
- return this.pontos.push(t), {};
710
- {
711
- const o = this.retangulo(this.pontos[0], t);
712
- return o ? { concluida: o } : {
713
- aviso: this.espaco.tipo === "plano" ? "Os dois cantos precisam diferir na horizontal e na vertical." : "Os dois cantos precisam diferir em latitude e em longitude."
714
- };
715
- }
716
- case "circulo":
717
- if (this.pontos.length === 0)
718
- return this.pontos.push(t), {};
719
- {
720
- const o = this.espaco.distancia(this.pontos[0], t);
721
- return o >= this.raioMinimo ? { concluida: { tipo: "Circle", centro: this.pontos[0], raioMetros: o } } : { aviso: `Raio mínimo de ${this.raioMinimo} ${this.espaco.unidade}: clique mais longe do centro.` };
722
- }
723
- case "elipse":
724
- case "poligono-regular":
725
- case "estrela": {
726
- if (this.pontos.length === 0)
727
- return this.pontos.push(t), {};
728
- const o = this.formaDeDoisCliques(this.pontos[0], t);
729
- return o ? { concluida: { tipo: "Polygon", aneis: [o] } } : { aviso: "Clique num ponto diferente do centro." };
730
- }
731
- case "caneta":
732
- return this.ancoras.push({ ponto: t }), {};
733
- case "conta-gotas":
734
- return {};
735
- default:
736
- return this.pontos.length > 0 && rn(this.pontos[this.pontos.length - 1], t) ? {} : (this.pontos.push(t), {});
737
- }
738
- }
739
- /** Caneta: arrastar logo após colocar a âncora define a alça de saída (a de entrada é o espelho). */
740
- definirAlca(t) {
741
- const o = this.ancoras[this.ancoras.length - 1];
742
- this.ferramenta === "caneta" && o && (o.alca = t);
743
- }
744
- /**
745
- * Caneta: puxa uma alça de qualquer âncora já colocada. Com `simetrica` a oposta vira o espelho; sem ela
746
- * as duas ficam independentes (a oposta mantém onde estava).
747
- */
748
- moverAlcaDaAncora(t, o, e, s = !0) {
749
- const r = this.ancoras[t];
750
- if (this.ferramenta !== "caneta" || !r) return;
751
- if (s) {
752
- r.alca = o === "saida" ? e : Q(r.ponto, e), delete r.entrada;
753
- return;
754
- }
755
- const a = vt(r);
756
- o === "saida" ? (r.alca = e, a && (r.entrada = a)) : (r.alca ?? (r.alca = r.ponto), r.entrada = e);
757
- }
758
- /** Desfaz o último vértice/âncora (Backspace). Devolve se algo foi desfeito. */
759
- desfazer() {
760
- const t = this.ferramenta === "caneta" ? this.ancoras : this.pontos;
761
- return t.length === 0 ? !1 : (t.pop(), !0);
762
- }
763
- /** Vértices da linha/anel em construção, incluindo a curva da caneta. */
764
- vertices() {
765
- return this.ferramenta === "caneta" ? en(this.ancoras) : this.pontos;
766
- }
767
- retangulo(t, o) {
768
- return t[0] === o[0] || t[1] === o[1] ? null : { tipo: "Polygon", aneis: [[[t[0], t[1]], [t[0], o[1]], [o[0], o[1]], [o[0], t[1]]]] };
769
- }
770
- /** Geometria provisória para desenhar enquanto o mouse se move (inclui o cursor). */
771
- previa() {
772
- const t = this.cursor;
773
- switch (this.ferramenta) {
774
- case "retangulo":
775
- return this.pontos.length === 1 && t ? this.retangulo(this.pontos[0], t) : null;
776
- case "circulo": {
777
- if (this.pontos.length !== 1 || !t) return null;
778
- const o = this.espaco.distancia(this.pontos[0], t);
779
- return o >= this.raioMinimo ? { tipo: "Circle", centro: this.pontos[0], raioMetros: o } : null;
780
- }
781
- case "caneta": {
782
- if (this.ancoras.length === 0) return null;
783
- const o = V(t ? [...this.ancoras, { ponto: t }] : this.ancoras);
784
- return o.length < 2 ? null : U(o, this.ehArea && o.length >= 3);
785
- }
786
- case "elipse":
787
- case "poligono-regular":
788
- case "estrela": {
789
- if (this.pontos.length !== 1 || !t) return null;
790
- const o = this.formaDeDoisCliques(this.pontos[0], t);
791
- return o ? { tipo: "Polygon", aneis: [o] } : null;
792
- }
793
- case "ponto":
794
- case "texto":
795
- case "conta-gotas":
796
- return null;
797
- default: {
798
- const o = t ? [...this.pontos, t] : [...this.pontos];
799
- return o.length < 2 ? null : this.ehArea && o.length >= 3 ? { tipo: "Polygon", aneis: [o] } : { tipo: "LineString", coordenadas: o };
800
- }
801
- }
802
- }
803
- /** Fecha uma ferramenta sequencial (Enter ou duplo clique). `null` se ainda não há vértices suficientes. */
804
- concluir() {
805
- if (!this.podeConcluir) return null;
806
- if (this.ferramenta === "caneta") return U(V(this.ancoras), this.ehArea);
807
- const t = this.vertices();
808
- return this.ehArea ? { tipo: "Polygon", aneis: [t] } : { tipo: "LineString", coordenadas: t };
809
- }
810
- /** Fecha em polígono (clique no primeiro vértice). Na caneta vale mesmo sem a opção `fechar`. */
811
- concluirFechando() {
812
- return this.fechaNoPrimeiro ? this.ferramenta === "caneta" ? U(V(this.ancoras), !0) : { tipo: "Polygon", aneis: [this.vertices()] } : null;
813
- }
814
- /** Medida em andamento: comprimento (linha) ou comprimento do contorno (área), na unidade do espaço (m no geográfico). */
815
- comprimentoMetros() {
816
- const t = this.cursor && this.nos > 0 ? [...this.vertices(), this.cursor] : this.vertices();
817
- return this.espaco.comprimento(t, !1);
818
- }
819
- }
820
- const sn = 10, w = (n, t) => Math.hypot(n.x - t.x, n.y - t.y);
821
- function ut(n, t, o) {
822
- const e = o.x - t.x, s = o.y - t.y, r = e * e + s * s, a = r === 0 ? 0 : Math.max(0, Math.min(1, ((n.x - t.x) * e + (n.y - t.y) * s) / r));
823
- return { t: a, d: Math.hypot(n.x - (t.x + a * e), n.y - (t.y + a * s)) };
824
- }
825
- function Fn(n, t, o, e = {}, s) {
826
- const r = e.toleranciaPx ?? sn, a = e.vertice !== !1, i = e.meio !== !1, c = e.aresta !== !1;
827
- let l = null, u = null, h = null;
828
- const p = (d, P) => !d || P.distanciaPx < d.distanciaPx ? P : d;
829
- for (const d of t) {
830
- if (d.excluida || d.oculta) continue;
831
- const P = !!s && s.feicaoId === d.id && (s.camadaId === void 0 || s.camadaId === d.camadaId), g = d.geometria, y = { feicaoId: d.id, camadaId: d.camadaId };
832
- if (g.tipo === "Point" || g.tipo === "Text" || g.tipo === "Circle") {
833
- if (!a || P) continue;
834
- const m = g.tipo === "Circle" ? g.centro : g.coordenada, f = w(n, o(m));
835
- f <= r && (l = p(l, { tipo: "vertice", coordenada: m, distanciaPx: f, ...y }));
836
- continue;
837
- }
838
- if (P && (g.tipo === "LineString" || g.tipo === "Polygon") && g.curva) continue;
839
- const R = g.tipo === "LineString" || g.tipo === "Polygon" ? _(g) : null;
840
- if (R) {
841
- if (a)
842
- for (const m of R) {
843
- const f = w(n, o(m.ponto));
844
- f <= r && (l = p(l, { tipo: "vertice", coordenada: m.ponto, distanciaPx: f, ...y }));
845
- }
846
- if (i)
847
- for (const [m, f] of zt(g)) {
848
- const M = Yt(g, m, f), v = w(n, o(M));
849
- v <= r && (u = p(u, { tipo: "meio", coordenada: M, distanciaPx: v, ...y }));
850
- }
851
- if (c) {
852
- const m = I(g), f = m.map(o), M = g.tipo === "Polygon" && m.length > 2 ? m.length : m.length - 1;
853
- for (let v = 0; v < M; v++) {
854
- const L = v, x = (v + 1) % m.length, { t: O, d: N } = ut(n, f[L], f[x]);
855
- if (N <= r) {
856
- const T = [m[L][0] + O * (m[x][0] - m[L][0]), m[L][1] + O * (m[x][1] - m[L][1])];
857
- h = p(h, { tipo: "aresta", coordenada: T, distanciaPx: N, ...y });
858
- }
859
- }
860
- }
861
- continue;
862
- }
863
- const F = g.tipo === "LineString" ? B(g).map((m) => ({ pts: m, fechado: !1 })) : [{ pts: I(g), fechado: g.tipo === "Polygon" }], C = P ? s.vertice : void 0;
864
- for (const { pts: m, fechado: f } of F) {
865
- const M = m.map(o);
866
- if (a)
867
- for (let L = 0; L < m.length; L++) {
868
- if (L === C) continue;
869
- const x = w(n, M[L]);
870
- x <= r && (l = p(l, { tipo: "vertice", coordenada: m[L], distanciaPx: x, ...y }));
871
- }
872
- if (!i && !c) continue;
873
- const v = f && m.length > 2 ? m.length : m.length - 1;
874
- for (let L = 0; L < v; L++) {
875
- const x = L, O = (L + 1) % m.length;
876
- if (!(C !== void 0 && (x === C || O === C)) && !(P && C === void 0)) {
877
- if (i) {
878
- const N = Pt(m[x], m[O]), T = w(n, o(N));
879
- T <= r && (u = p(u, { tipo: "meio", coordenada: N, distanciaPx: T, ...y }));
880
- }
881
- if (c) {
882
- const { t: N, d: T } = ut(n, M[x], M[O]);
883
- if (T <= r) {
884
- const Lt = [m[x][0] + N * (m[O][0] - m[x][0]), m[x][1] + N * (m[O][1] - m[x][1])];
885
- h = p(h, { tipo: "aresta", coordenada: Lt, distanciaPx: T, ...y });
886
- }
887
- }
888
- }
889
- }
890
- }
891
- }
892
- return l ?? u ?? h;
893
- }
894
- function X(n, t) {
895
- return n.x >= t.x1 && n.x <= t.x2 && n.y >= t.y1 && n.y <= t.y2;
896
- }
897
- function ht(n, t, o) {
898
- let e = 0, s = 1;
899
- const r = t.x - n.x, a = t.y - n.y, i = [-r, r, -a, a], c = [n.x - o.x1, o.x2 - n.x, n.y - o.y1, o.y2 - n.y];
900
- for (let l = 0; l < 4; l++)
901
- if (i[l] === 0) {
902
- if (c[l] < 0) return !1;
903
- } else {
904
- const u = c[l] / i[l];
905
- if (i[l] < 0) {
906
- if (u > s) return !1;
907
- u > e && (e = u);
908
- } else {
909
- if (u < e) return !1;
910
- u < s && (s = u);
911
- }
912
- }
913
- return !0;
914
- }
915
- function ft(n, t) {
916
- let o = !1;
917
- for (let e = 0, s = t.length - 1; e < t.length; s = e++) {
918
- const r = t[e], a = t[s];
919
- r.y > n.y != a.y > n.y && n.x < (a.x - r.x) * (n.y - r.y) / (a.y - r.y) + r.x && (o = !o);
920
- }
921
- return o;
922
- }
923
- function pt(n, t, o) {
924
- for (let e = 1; e < n.length; e++) if (ht(n[e - 1], n[e], t)) return !0;
925
- return o && n.length > 2 && ht(n[n.length - 1], n[0], t);
926
- }
927
- function an(n, t, o, e) {
928
- const s = o(n), r = o(e.pontoDeMedidaDoRaio(n, t));
929
- return Math.hypot(r.x - s.x, r.y - s.y);
930
- }
931
- function kn(n, t, o, e, s = A) {
932
- if (n.oculta) return !1;
933
- const r = n.geometria, a = e === "window";
934
- switch (r.tipo) {
935
- case "Point":
936
- case "Text":
937
- return X(o(r.coordenada), t);
938
- case "LineString": {
939
- const i = B(r).map((c) => c.map(o));
940
- return a ? i.every((c) => c.every((l) => X(l, t))) : i.some((c) => c.some((l) => X(l, t)) || pt(c, t, !1));
941
- }
942
- case "Polygon": {
943
- const i = r.aneis.map((u) => u.map(o)), c = i[0];
944
- if (!c) return !1;
945
- if (a) return c.every((u) => X(u, t));
946
- if (i.some((u) => u.some((h) => X(h, t)) || pt(u, t, !0))) return !0;
947
- const l = { x: t.x1, y: t.y1 };
948
- return ft(l, c) && !i.slice(1).some((u) => ft(l, u));
949
- }
950
- case "Circle": {
951
- const i = o(r.centro), c = an(r.centro, r.raioMetros, o, s);
952
- if (a)
953
- return i.x - c >= t.x1 && i.x + c <= t.x2 && i.y - c >= t.y1 && i.y + c <= t.y2;
954
- const l = Math.max(t.x1, Math.min(i.x, t.x2)), u = Math.max(t.y1, Math.min(i.y, t.y2));
955
- return Math.hypot(i.x - l, i.y - u) <= c;
956
- }
957
- }
958
- }
959
- function qn(n, t) {
960
- if (t.length < 3 || n.oculta) return !1;
961
- const o = (s) => _t(s, [t]), e = n.geometria;
962
- switch (e.tipo) {
963
- case "Point":
964
- case "Text":
965
- return o(e.coordenada);
966
- case "Circle":
967
- return o(e.centro);
968
- case "LineString":
969
- return B(e).some((s) => s.some(o));
970
- case "Polygon": {
971
- const s = e.aneis[0] ?? [];
972
- if (s.some(o)) return !0;
973
- if (s.length < 3) return !1;
974
- const r = s.reduce((a, i) => [a[0] + i[0], a[1] + i[1]], [0, 0]);
975
- return o([r[0] / s.length, r[1] / s.length]);
976
- }
977
- }
978
- }
979
- export {
980
- V as $,
981
- at as A,
982
- Bt as B,
983
- q as C,
984
- Jt as D,
985
- A as E,
986
- $t as F,
987
- Nn as G,
988
- _ as H,
989
- Yt as I,
990
- Ln as J,
991
- nn as K,
992
- kt as L,
993
- On as M,
994
- jt as N,
995
- en as O,
996
- _n as P,
997
- W as Q,
998
- on as R,
999
- Rn as S,
1000
- sn as T,
1001
- gn as U,
1002
- dn as V,
1003
- yn as W,
1004
- Mn as X,
1005
- Pn as Y,
1006
- qt as Z,
1007
- xn as _,
1008
- Zt as a,
1009
- Gt as a0,
1010
- Pt as a1,
1011
- wt as a2,
1012
- I as a3,
1013
- _t as b,
1014
- qn as c,
1015
- pn as d,
1016
- Fn as e,
1017
- kn as f,
1018
- tn as g,
1019
- Sn as h,
1020
- Cn as i,
1021
- En as j,
1022
- Dn as k,
1023
- An as l,
1024
- Z as m,
1025
- tt as n,
1026
- hn as o,
1027
- Ht as p,
1028
- fn as q,
1029
- In as r,
1030
- un as s,
1031
- zt as t,
1032
- Xt as u,
1033
- bn as v,
1034
- vn as w,
1035
- mn as x,
1036
- vt as y,
1037
- Tn as z
1038
- };