@thibezer/ui-components-kit 2.21.0 → 2.23.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 (151) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/README.md +1 -1
  3. package/dist/camadas.cjs +1 -311
  4. package/dist/camadas.js +148 -3248
  5. package/dist/canvas.cjs +82 -82
  6. package/dist/canvas.js +2964 -3442
  7. package/dist/components/ui-barra-ferramentas/paleta-ajuste.d.ts +43 -0
  8. package/dist/components/ui-barra-ferramentas/paleta-excesso.d.ts +8 -0
  9. package/dist/components/ui-barra-ferramentas/tipos.d.ts +15 -0
  10. package/dist/components/ui-barra-ferramentas/ui-paleta-ferramentas.d.ts +47 -6
  11. package/dist/components/ui-canvas-prancha/index.d.ts +13 -0
  12. package/dist/components/ui-canvas-prancha/prancha-acessibilidade.d.ts +5 -0
  13. package/dist/components/ui-canvas-prancha/prancha-atributos-sync.d.ts +14 -0
  14. package/dist/components/ui-canvas-prancha/prancha-bus.d.ts +5 -0
  15. package/dist/components/ui-canvas-prancha/prancha-comandos-organizacao.d.ts +45 -0
  16. package/dist/components/ui-canvas-prancha/prancha-comandos-pathfinder.d.ts +3 -0
  17. package/dist/components/ui-canvas-prancha/prancha-comandos-propriedades.d.ts +12 -0
  18. package/dist/components/ui-canvas-prancha/prancha-comandos.d.ts +27 -0
  19. package/dist/components/ui-canvas-prancha/prancha-controlador.d.ts +122 -0
  20. package/dist/components/ui-canvas-prancha/prancha-cores.d.ts +23 -0
  21. package/dist/components/ui-canvas-prancha/prancha-documento.d.ts +59 -0
  22. package/dist/components/ui-canvas-prancha/prancha-estado-ui.d.ts +45 -0
  23. package/dist/components/ui-canvas-prancha/prancha-ferramentas-edicao.d.ts +7 -0
  24. package/dist/components/ui-canvas-prancha/prancha-ferramentas.d.ts +38 -0
  25. package/dist/components/ui-canvas-prancha/prancha-gestos.d.ts +88 -0
  26. package/dist/components/ui-canvas-prancha/prancha-interacao.d.ts +31 -0
  27. package/dist/components/ui-canvas-prancha/prancha-medidor-texto.d.ts +6 -0
  28. package/dist/components/ui-canvas-prancha/prancha-paineis.d.ts +29 -0
  29. package/dist/components/ui-canvas-prancha/prancha-painel-camadas.d.ts +52 -0
  30. package/dist/components/ui-canvas-prancha/prancha-painel-propriedades.d.ts +50 -0
  31. package/dist/components/ui-canvas-prancha/prancha-paleta.d.ts +13 -0
  32. package/dist/components/ui-canvas-prancha/prancha-pintura.d.ts +55 -0
  33. package/dist/components/ui-canvas-prancha/prancha-reguas.d.ts +26 -0
  34. package/dist/components/ui-canvas-prancha/prancha-render.d.ts +35 -0
  35. package/dist/components/ui-canvas-prancha/prancha-teclado.d.ts +12 -0
  36. package/dist/components/ui-canvas-prancha/prancha-template.d.ts +1 -0
  37. package/dist/components/ui-canvas-prancha/prancha-vista.d.ts +31 -0
  38. package/dist/components/ui-canvas-prancha/tipos.d.ts +138 -0
  39. package/dist/components/ui-canvas-prancha/ui-canvas-prancha-base.d.ts +158 -0
  40. package/dist/components/ui-canvas-prancha/ui-canvas-prancha.d.ts +119 -0
  41. package/dist/components/ui-editor-prancha/editor-tipos.d.ts +12 -0
  42. package/dist/components/ui-editor-prancha/index.d.ts +2 -0
  43. package/dist/components/ui-editor-prancha/ui-editor-prancha.d.ts +60 -0
  44. package/dist/cores-utils-BmkzhA1v.cjs +1 -0
  45. package/dist/cores-utils-BrdynxRd.js +54 -0
  46. package/dist/cores.cjs +1 -1
  47. package/dist/cores.js +12 -11
  48. package/dist/custom-elements.json +21776 -11591
  49. package/dist/data.cjs +1 -1
  50. package/dist/data.js +99 -98
  51. package/dist/feature_caixa-2Sxv3tGa.js +824 -0
  52. package/dist/feature_caixa-4M4MkFH7.cjs +1 -0
  53. package/dist/feature_caixa-CnYPKVFS.cjs +1 -0
  54. package/dist/feature_caixa-DCs9ZeSk.js +1038 -0
  55. package/dist/feature_desenho-BH-E1Q9Q.cjs +1 -0
  56. package/dist/feature_desenho-BVHivWIB.js +222 -0
  57. package/dist/feature_historico-BAIYk1Me.cjs +3 -0
  58. package/dist/feature_historico-C4h9y5fu.js +3039 -0
  59. package/dist/geometria-px-Cyi_oPD6.cjs +1 -0
  60. package/dist/geometria-px-DKrWq_XY.js +639 -0
  61. package/dist/geometria-px-DUs5FgLE.js +639 -0
  62. package/dist/gerencigeo-canvas/booleanas/classificacao.d.ts +41 -0
  63. package/dist/gerencigeo-canvas/booleanas/index.d.ts +10 -0
  64. package/dist/gerencigeo-canvas/booleanas/montagem.d.ts +23 -0
  65. package/dist/gerencigeo-canvas/booleanas/segmentos.d.ts +38 -0
  66. package/dist/gerencigeo-canvas/booleanas/tipos.d.ts +44 -0
  67. package/dist/gerencigeo-canvas/espaco/espaco_geografico.d.ts +2 -0
  68. package/dist/gerencigeo-canvas/espaco/espaco_matriz.d.ts +58 -0
  69. package/dist/gerencigeo-canvas/espaco/espaco_plano.d.ts +13 -0
  70. package/dist/gerencigeo-canvas/espaco/espaco_tipos.d.ts +35 -0
  71. package/dist/gerencigeo-canvas/espaco/index.d.ts +4 -0
  72. package/dist/gerencigeo-canvas/feature_algoritmos.d.ts +12 -8
  73. package/dist/gerencigeo-canvas/feature_amostra.d.ts +2 -1
  74. package/dist/gerencigeo-canvas/feature_caixa.d.ts +3 -2
  75. package/dist/gerencigeo-canvas/feature_curvas.d.ts +9 -2
  76. package/dist/gerencigeo-canvas/feature_desenho.d.ts +23 -2
  77. package/dist/gerencigeo-canvas/feature_edicao_nos.d.ts +68 -0
  78. package/dist/gerencigeo-canvas/feature_edicao_ops.d.ts +28 -8
  79. package/dist/gerencigeo-canvas/feature_editor_painel_no.d.ts +40 -0
  80. package/dist/gerencigeo-canvas/feature_editor_vertices.d.ts +46 -0
  81. package/dist/gerencigeo-canvas/feature_formas.d.ts +7 -3
  82. package/dist/gerencigeo-canvas/feature_historico.d.ts +41 -0
  83. package/dist/gerencigeo-canvas/feature_indice.d.ts +10 -2
  84. package/dist/gerencigeo-canvas/feature_metricas.d.ts +15 -4
  85. package/dist/gerencigeo-canvas/feature_types.d.ts +14 -2
  86. package/dist/gerencigeo-canvas/motor/geometria-px.d.ts +2 -0
  87. package/dist/gerencigeo-canvas/prancha/ajuste_caixa.d.ts +32 -0
  88. package/dist/gerencigeo-canvas/prancha/aparencia_estilo.d.ts +86 -0
  89. package/dist/gerencigeo-canvas/prancha/aparencia_lote.d.ts +49 -0
  90. package/dist/gerencigeo-canvas/prancha/camadas.d.ts +14 -0
  91. package/dist/gerencigeo-canvas/prancha/cantos_vivos.d.ts +18 -0
  92. package/dist/gerencigeo-canvas/prancha/elemento_consulta.d.ts +63 -0
  93. package/dist/gerencigeo-canvas/prancha/elemento_criacao.d.ts +27 -0
  94. package/dist/gerencigeo-canvas/prancha/elemento_edicao.d.ts +24 -0
  95. package/dist/gerencigeo-canvas/prancha/elemento_geometria.d.ts +60 -0
  96. package/dist/gerencigeo-canvas/prancha/elemento_predefinicoes.d.ts +88 -0
  97. package/dist/gerencigeo-canvas/prancha/elemento_snap.d.ts +39 -0
  98. package/dist/gerencigeo-canvas/prancha/elemento_transformacao.d.ts +65 -0
  99. package/dist/gerencigeo-canvas/prancha/elemento_validacao.d.ts +27 -0
  100. package/dist/gerencigeo-canvas/prancha/envelope_visual.d.ts +12 -0
  101. package/dist/gerencigeo-canvas/prancha/exportar_svg.d.ts +18 -0
  102. package/dist/gerencigeo-canvas/prancha/guias_inteligentes.d.ts +21 -0
  103. package/dist/gerencigeo-canvas/prancha/index.d.ts +28 -0
  104. package/dist/gerencigeo-canvas/prancha/operacoes_caminho.d.ts +35 -0
  105. package/dist/gerencigeo-canvas/prancha/organizacao.d.ts +46 -0
  106. package/dist/gerencigeo-canvas/prancha/pathfinder.d.ts +17 -0
  107. package/dist/gerencigeo-canvas/prancha/pintura_canvas.d.ts +118 -0
  108. package/dist/gerencigeo-canvas/prancha/pintura_contexto.d.ts +54 -0
  109. package/dist/gerencigeo-canvas/prancha/pintura_formas.d.ts +32 -0
  110. package/dist/gerencigeo-canvas/prancha/pintura_gradiente_faixas.d.ts +21 -0
  111. package/dist/gerencigeo-canvas/prancha/pintura_plano.d.ts +126 -0
  112. package/dist/gerencigeo-canvas/prancha/propriedades.d.ts +15 -0
  113. package/dist/gerencigeo-canvas/prancha/tipos.d.ts +228 -0
  114. package/dist/index.cjs +1 -1
  115. package/dist/index.d.ts +8 -0
  116. package/dist/index.js +252 -248
  117. package/dist/motor.cjs +1 -1
  118. package/dist/motor.js +822 -57
  119. package/dist/prancha-nucleo.cjs +1 -0
  120. package/dist/prancha-nucleo.d.ts +3 -0
  121. package/dist/prancha-nucleo.js +302 -0
  122. package/dist/prancha-paleta-BZ-9QDgh.js +5276 -0
  123. package/dist/prancha-paleta-Bb24vP71.cjs +17 -0
  124. package/dist/prancha.cjs +1 -0
  125. package/dist/prancha.d.ts +13 -0
  126. package/dist/prancha.js +231 -0
  127. package/dist/register.cjs +1 -1
  128. package/dist/register.js +10 -6
  129. package/dist/tabela.cjs +1 -1
  130. package/dist/tabela.js +90 -89
  131. package/dist/tipos-elementos.d.ts +73 -1
  132. package/dist/tipos-react.d.ts +4 -0
  133. package/dist/tipos-vue.d.ts +73 -1
  134. package/dist/tools.cjs +1 -1
  135. package/dist/tools.js +1 -1
  136. package/dist/ui-camadas-DoHPnbQm.js +3133 -0
  137. package/dist/ui-camadas-Vx7wYD4D.cjs +311 -0
  138. package/dist/ui-controle-cores-BcH9k2Fa.js +292 -0
  139. package/dist/ui-controle-cores-CvSTP6gJ.cjs +32 -0
  140. package/dist/ui-editor-prancha-CIngI6yI.js +2886 -0
  141. package/dist/ui-editor-prancha-DorSe6sC.cjs +31 -0
  142. package/dist/ui-kit.css +1 -1
  143. package/dist/ui-paleta-ferramentas-DebHYiwd.js +1615 -0
  144. package/dist/ui-paleta-ferramentas-jWuICjW8.cjs +22 -0
  145. package/dist/ui-seletor-cor-0RLjcME6.cjs +83 -0
  146. package/dist/ui-seletor-cor-Cd8jkzXG.js +354 -0
  147. package/dist/ui-tabela-CXxqbwXv.cjs +7 -0
  148. package/dist/ui-tabela-Cd0vOwnT.js +1459 -0
  149. package/dist/ui-tabela-propriedades-D96Djx-q.cjs +136 -0
  150. package/dist/ui-tabela-propriedades-ahQhQauu.js +2329 -0
  151. package/package.json +11 -1
@@ -0,0 +1,1459 @@
1
+ var te = Object.defineProperty;
2
+ var ae = (t, a, e) => a in t ? te(t, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[a] = e;
3
+ var h = (t, a, e) => ae(t, typeof a != "symbol" ? a + "" : a, e);
4
+ import { L as $ } from "./listener-bag-DQgv7OON.js";
5
+ import { a as X } from "./parts-CaoQiCfI.js";
6
+ import { d as ie, S as re } from "./ssr-safe-5cWfJP-s.js";
7
+ import { A as oe, e as ne, a as B } from "./degrade-gDa5sW__.js";
8
+ class se {
9
+ constructor(a) {
10
+ h(this, "autoFetchController", null);
11
+ h(this, "emVoo", null);
12
+ this.ctx = a;
13
+ }
14
+ /**
15
+ * Busca os dados. Resolve `true` em sucesso e `false` em falha, cancelamento ou requisição
16
+ * substituída (nunca rejeita; o motivo da falha vai no evento `ui-fetch-erro`).
17
+ * Uma chamada com a mesma URL de uma requisição em andamento reaproveita essa requisição.
18
+ */
19
+ carregar(a) {
20
+ if (!a) return Promise.resolve(!1);
21
+ if (this.emVoo && this.emVoo.url === a && this.autoFetchController) return this.emVoo.promessa;
22
+ this.cancelarEmVoo();
23
+ const e = new AbortController();
24
+ this.autoFetchController = e;
25
+ const i = this.executar(a, e);
26
+ return this.emVoo = { url: a, promessa: i }, i;
27
+ }
28
+ emitir(a, e) {
29
+ this.ctx.host.dispatchEvent(new CustomEvent(a, { bubbles: !0, composed: !0, detail: e }));
30
+ }
31
+ erro(a, e, i, r) {
32
+ const o = e instanceof Error ? e.message : String(e);
33
+ console.error("[ui-tabela] Erro ao carregar dados remotos:", e);
34
+ const n = { url: a, erro: o, origem: i };
35
+ r !== void 0 && (n.status = r), this.emitir("ui-fetch-erro", n);
36
+ }
37
+ async executar(a, e) {
38
+ var s, l, c, d;
39
+ const i = () => this.autoFetchController === e, r = () => {
40
+ this.autoFetchController === e && (this.autoFetchController = null, this.emVoo = null);
41
+ };
42
+ this.ctx.onCarregandoAlterado(!0), this.emitir("ui-fetch-start", { url: a });
43
+ let o = "rede", n;
44
+ try {
45
+ const u = { ...((l = (s = this.ctx).getOpcoes) == null ? void 0 : l.call(s)) ?? {}, signal: e.signal }, m = await (((d = (c = this.ctx).getFetcher) == null ? void 0 : d.call(c)) ?? ((p, y) => fetch(p, y)))(a, u);
46
+ if (!m.ok)
47
+ throw o = "http", n = m.status, new Error(`HTTP ${m.status}: ${m.statusText}`);
48
+ o = "json";
49
+ const f = await m.json(), b = Array.isArray(f) ? f : (f == null ? void 0 : f.dados) || (f == null ? void 0 : f.items) || (f == null ? void 0 : f.data) || (f == null ? void 0 : f.rows) || [], _ = Array.isArray(b) ? b : [];
50
+ return i() ? (o = "render", this.ctx.onDadosRecebidos(_), r(), this.ctx.onCarregandoAlterado(!1), this.emitir("ui-fetch-sucesso", { url: a, total: _.length, dados: _ }), !0) : !1;
51
+ } catch (u) {
52
+ return (u == null ? void 0 : u.name) === "AbortError" ? (i() && (r(), this.ctx.onCarregandoAlterado(!1)), this.emitir("ui-fetch-cancelado", { url: a }), !1) : (i() && (r(), this.ctx.onCarregandoAlterado(!1), this.erro(a, u, o, n)), !1);
53
+ }
54
+ }
55
+ /** Cancela a requisição em andamento (se houver) e libera o indicador de carregamento. */
56
+ abortar() {
57
+ this.autoFetchController && (this.cancelarEmVoo(), this.ctx.onCarregandoAlterado(!1));
58
+ }
59
+ cancelarEmVoo() {
60
+ if (this.autoFetchController) {
61
+ const a = this.autoFetchController;
62
+ this.autoFetchController = null, this.emVoo = null, a.abort();
63
+ }
64
+ }
65
+ }
66
+ const le = ["id", "_id", "codigo", "key"];
67
+ function de(t, a) {
68
+ return t != null && (t === a || String(t) === String(a));
69
+ }
70
+ function P(t, a) {
71
+ let e = -1;
72
+ return typeof t == "number" && Number.isInteger(t) ? e = t : typeof t == "string" && /^\d+$/.test(t.trim()) && (e = parseInt(t.trim(), 10)), e >= 0 && e < a ? e : -1;
73
+ }
74
+ function ce(t, a, e = "id", i = !1) {
75
+ if (!t || t.length === 0) return -1;
76
+ if (typeof a == "function")
77
+ return t.findIndex(a);
78
+ if (i) return P(a, t.length);
79
+ const r = [e, ...le.filter((o) => o !== e)];
80
+ for (const o of r) {
81
+ const n = t.findIndex((s) => !!s && typeof s == "object" && de(s[o], a));
82
+ if (n !== -1) return n;
83
+ }
84
+ return P(a, t.length);
85
+ }
86
+ class ue {
87
+ constructor(a) {
88
+ h(this, "itemSelecionado", null);
89
+ h(this, "indiceSelecionado", null);
90
+ this.ctx = a;
91
+ }
92
+ /** Mesmo objeto ou mesmo valor na chave configurada. */
93
+ indiceDoItem(a, e) {
94
+ const i = this.ctx.getChaveId(), r = a.indexOf(e);
95
+ return r >= 0 ? r : e[i] == null ? -1 : a.findIndex((o) => (o == null ? void 0 : o[i]) != null && String(o[i]) === String(e[i]));
96
+ }
97
+ getItemSelecionado() {
98
+ return this.itemSelecionado;
99
+ }
100
+ setItemSelecionado(a) {
101
+ this.itemSelecionado = a;
102
+ const e = a ? this.indiceDoItem(this.ctx.getDadosExibicao(), a) : -1;
103
+ this.indiceSelecionado = e >= 0 ? e : null, this.atualizarLinhasSelecionadas();
104
+ }
105
+ getIndiceSelecionado() {
106
+ return this.indiceSelecionado;
107
+ }
108
+ setIndiceSelecionado(a) {
109
+ const e = this.ctx.getDadosExibicao(), i = a !== null && a >= 0 && a < e.length;
110
+ this.indiceSelecionado = i ? a : null, this.itemSelecionado = i ? e[a] : null, this.atualizarLinhasSelecionadas();
111
+ }
112
+ /**
113
+ * Reaplica a seleção após ordenar, filtrar ou trocar os dados.
114
+ * - Item ainda exibido: atualiza o índice (e a referência, se veio um objeto novo com a mesma chave).
115
+ * - Item só escondido pelo filtro: mantém a seleção (sem índice) para reaparecer ao limpar o filtro.
116
+ * - Item removido dos dados: limpa a seleção e emite `ui-selecao-removida`.
117
+ */
118
+ reconciliar() {
119
+ const a = this.itemSelecionado;
120
+ if (!a) {
121
+ this.indiceSelecionado = null;
122
+ return;
123
+ }
124
+ const e = this.ctx.getDadosExibicao(), i = this.indiceDoItem(e, a);
125
+ if (i >= 0) {
126
+ this.indiceSelecionado = i, this.substituirReferencia(a, e[i]);
127
+ return;
128
+ }
129
+ this.indiceSelecionado = null;
130
+ const r = this.ctx.getDadosOriginais(), o = this.indiceDoItem(r, a);
131
+ if (o >= 0) {
132
+ this.substituirReferencia(a, r[o]);
133
+ return;
134
+ }
135
+ this.itemSelecionado = null, this.ctx.host.dispatchEvent(
136
+ new CustomEvent("ui-selecao-removida", { bubbles: !0, composed: !0, detail: { item: a } })
137
+ );
138
+ }
139
+ /** Mesmo registro com outro objeto (dados recarregados): atualiza a referência e avisa. */
140
+ substituirReferencia(a, e) {
141
+ this.itemSelecionado = e, a !== e && this.ctx.host.dispatchEvent(
142
+ new CustomEvent("ui-selecao-atualizada", { bubbles: !0, composed: !0, detail: { item: e, anterior: a } })
143
+ );
144
+ }
145
+ limparSelecao() {
146
+ this.itemSelecionado = null, this.indiceSelecionado = null, this.atualizarLinhasSelecionadas();
147
+ }
148
+ isItemSelecionado(a, e) {
149
+ if (this.itemSelecionado) {
150
+ if (this.itemSelecionado === a) return !0;
151
+ const i = this.ctx.getChaveId();
152
+ if (a[i] != null && this.itemSelecionado[i] != null)
153
+ return String(a[i]) === String(this.itemSelecionado[i]);
154
+ if (a.id != null && this.itemSelecionado.id != null)
155
+ return String(a.id) === String(this.itemSelecionado.id);
156
+ }
157
+ return this.indiceSelecionado !== null && this.indiceSelecionado === e;
158
+ }
159
+ atualizarLinhasSelecionadas() {
160
+ const a = this.ctx.getTbody();
161
+ if (!a) return;
162
+ const e = this.ctx.getDadosExibicao();
163
+ a.querySelectorAll("tr:not(.ui-tabela__virtual-spacer)").forEach((r) => {
164
+ const o = r.getAttribute("data-index"), n = o !== null ? parseInt(o, 10) : -1, s = n >= 0 ? e[n] : null, l = s ? this.isItemSelecionado(s, n) : !1;
165
+ r.classList.toggle("ui-tabela__tr--selecionada", l), X(r, "linha-selecionada", l), l ? (r.setAttribute("data-selecionada", "true"), r.setAttribute("aria-current", "true"), r.setAttribute("aria-selected", "true")) : (r.removeAttribute("data-selecionada"), r.removeAttribute("aria-current"), r.setAttribute("aria-selected", "false"));
166
+ });
167
+ }
168
+ rolarPara(a, e) {
169
+ const i = this.ctx.getDadosExibicao(), r = ce(i, a, this.ctx.getChaveId(), (e == null ? void 0 : e.porIndice) === !0);
170
+ if (r === -1)
171
+ return !1;
172
+ if (e != null && e.selecionar) {
173
+ const o = i[r];
174
+ this.itemSelecionado = o, this.indiceSelecionado = r, this.atualizarLinhasSelecionadas(), this.ctx.onLinhaAtiva(r), this.ctx.host.dispatchEvent(
175
+ new CustomEvent("ui-linha-selecionada", {
176
+ bubbles: !0,
177
+ composed: !0,
178
+ detail: { item: o, indice: r }
179
+ })
180
+ );
181
+ }
182
+ return this.ctx.onRolarParaIndice(r, (e == null ? void 0 : e.comportamento) || "smooth");
183
+ }
184
+ }
185
+ function he(t, a, e) {
186
+ return t !== e ? {
187
+ idColuna: e,
188
+ direcao: "asc"
189
+ } : a === "asc" ? {
190
+ idColuna: e,
191
+ direcao: "desc"
192
+ } : a === "desc" ? {
193
+ idColuna: null,
194
+ direcao: "original"
195
+ } : {
196
+ idColuna: e,
197
+ direcao: "asc"
198
+ };
199
+ }
200
+ const me = new Intl.Collator("pt-BR", { numeric: !0, sensitivity: "base" });
201
+ function q(t) {
202
+ if (t instanceof Date) return t.getTime();
203
+ if (typeof t == "number") return t;
204
+ const a = String(t).trim(), e = /^(\d{1,2})\/(\d{1,2})\/(\d{4})(?:[ T](\d{1,2}):(\d{2}))?$/.exec(a);
205
+ return e ? new Date(+e[3], +e[2] - 1, +e[1], +(e[4] ?? 0), +(e[5] ?? 0)).getTime() : Date.parse(a);
206
+ }
207
+ function pe(t, a, e) {
208
+ if (e === "data" || !e && (t instanceof Date || a instanceof Date)) {
209
+ const i = q(t), r = q(a);
210
+ if (!Number.isNaN(i) && !Number.isNaN(r)) return i - r;
211
+ } else if (e === "numero" || !e && typeof t == "number" && typeof a == "number") {
212
+ const i = Number(t), r = Number(a);
213
+ if (!Number.isNaN(i) && !Number.isNaN(r)) return i - r;
214
+ } else if (e === "booleano" || !e && typeof t == "boolean" && typeof a == "boolean")
215
+ return +!!t - +!!a;
216
+ return me.compare(String(t), String(a));
217
+ }
218
+ function be(t, a, e, i) {
219
+ if (!a || e === "original")
220
+ return [...t];
221
+ const r = e === "desc" ? -1 : 1;
222
+ return [...t].sort((o, n) => {
223
+ const s = o[a], l = n[a], c = s == null, d = l == null;
224
+ return c || d ? c === d ? 0 : c ? 1 : -1 : i != null && i.comparador ? i.comparador(s, l, o, n) * r : s === l ? 0 : pe(s, l, i == null ? void 0 : i.tipo) * r;
225
+ });
226
+ }
227
+ function D(t) {
228
+ return t.normalize("NFD").replace(/[̀-ͯ]/g, "").toLowerCase();
229
+ }
230
+ class fe {
231
+ constructor() {
232
+ h(this, "dadosOriginais", []);
233
+ h(this, "dadosExibicao", []);
234
+ h(this, "indicePorItem", null);
235
+ h(this, "colunaOrdenada", null);
236
+ h(this, "direcaoOrdenacao", "original");
237
+ h(this, "ultimoFiltro", "");
238
+ /** Colunas declaradas: o filtro olha só elas (vazio = todos os campos do registro). */
239
+ h(this, "colunasFiltro", []);
240
+ h(this, "colunas", []);
241
+ /** Ordenação feita pelo servidor: a tabela guarda coluna/direção (indicador) mas não reordena os dados. */
242
+ h(this, "ordenacaoRemota", !1);
243
+ }
244
+ setColunas(a) {
245
+ this.colunas = a, this.colunaOrdenada && this.aplicarOrdenacao();
246
+ }
247
+ setOrdenacaoRemota(a) {
248
+ this.ordenacaoRemota !== a && (this.ordenacaoRemota = a, this.aplicarOrdenacao());
249
+ }
250
+ /** Restaura coluna/direção (ex.: `ui-sort` cancelado) e recalcula. */
251
+ restaurarOrdenacao(a, e) {
252
+ this.colunaOrdenada = a, this.direcaoOrdenacao = e, this.aplicarOrdenacao();
253
+ }
254
+ setColunasFiltro(a) {
255
+ this.colunasFiltro = a, this.ultimoFiltro && this.aplicarOrdenacao();
256
+ }
257
+ getDadosOriginais() {
258
+ return this.dadosOriginais;
259
+ }
260
+ setDadosOriginais(a) {
261
+ this.dadosOriginais = Array.isArray(a) ? a.filter((e) => e != null) : [], this.indicePorItem = null, this.aplicarOrdenacao();
262
+ }
263
+ /** Posição do item em `dados` (-1 se não pertence). Índice por objeto montado sob demanda, uma vez por troca de dados. */
264
+ indiceOriginal(a) {
265
+ this.indicePorItem || (this.indicePorItem = /* @__PURE__ */ new Map(), this.dadosOriginais.forEach((i, r) => {
266
+ this.indicePorItem.has(i) || this.indicePorItem.set(i, r);
267
+ }));
268
+ const e = this.indicePorItem.get(a);
269
+ return e !== void 0 && this.dadosOriginais[e] === a ? e : this.dadosOriginais.indexOf(a);
270
+ }
271
+ getDadosExibicao() {
272
+ return this.dadosExibicao;
273
+ }
274
+ getColunaOrdenada() {
275
+ return this.colunaOrdenada;
276
+ }
277
+ setColunaOrdenada(a) {
278
+ this.colunaOrdenada = a, a ? this.direcaoOrdenacao === "original" && (this.direcaoOrdenacao = "asc") : this.direcaoOrdenacao = "original", this.aplicarOrdenacao();
279
+ }
280
+ getDirecaoOrdenacao() {
281
+ return this.direcaoOrdenacao;
282
+ }
283
+ setDirecaoOrdenacao(a) {
284
+ this.direcaoOrdenacao = a || "original", this.direcaoOrdenacao === "original" && (this.colunaOrdenada = null), this.aplicarOrdenacao();
285
+ }
286
+ alternarOrdenacaoColuna(a) {
287
+ if (!a.ordenavel) return null;
288
+ const e = he(this.colunaOrdenada, this.direcaoOrdenacao, a.id);
289
+ return this.colunaOrdenada = e.idColuna, this.direcaoOrdenacao = e.direcao, this.aplicarOrdenacao(), e;
290
+ }
291
+ /** Recalcula a lista exibida: filtro vigente e, sobre o resultado, a ordenação da coluna (valem juntos). */
292
+ aplicarOrdenacao() {
293
+ const a = this.ultimoFiltro, e = a ? this.dadosOriginais.filter((r) => this.casaFiltro(r, a)) : this.dadosOriginais, i = this.colunaOrdenada ? this.colunas.find((r) => r.id === this.colunaOrdenada) : null;
294
+ this.dadosExibicao = this.ordenacaoRemota ? [...e] : be(e, this.colunaOrdenada, this.direcaoOrdenacao, i);
295
+ }
296
+ casaFiltro(a, e) {
297
+ return (this.colunasFiltro.length > 0 ? this.colunasFiltro : Object.keys(a)).some((r) => {
298
+ const o = a[r], n = this.colunas.find((l) => l.id === r);
299
+ if (n != null && n.textoFiltro)
300
+ try {
301
+ if (D(String(n.textoFiltro(o, a) ?? "")).includes(e)) return !0;
302
+ } catch {
303
+ }
304
+ if (o == null || typeof o == "object" && !(o instanceof Date)) return !1;
305
+ const s = o instanceof Date ? `${o.toISOString()} ${o.toLocaleDateString("pt-BR")}` : String(o);
306
+ return D(s).includes(e);
307
+ });
308
+ }
309
+ /** Há um filtro de texto aplicado (o vazio vira "sem resultados"). */
310
+ temFiltro() {
311
+ return this.ultimoFiltro !== "";
312
+ }
313
+ filtrar(a) {
314
+ this.ultimoFiltro = D((a || "").trim()), this.aplicarOrdenacao();
315
+ }
316
+ }
317
+ const ge = ':host{display:block;width:100%;box-sizing:border-box;font-family:inherit;color:var(--ui-cor-texto, #e1e1e6);position:relative}.ui-tabela-container{width:100%;max-width:100%;max-height:var(--ui-tabela-max-height, 500px);overflow-x:auto;overflow-y:auto;-webkit-overflow-scrolling:touch;overscroll-behavior:contain;border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));border-radius:var(--ui-raio-borda, 6px);background:var(--ui-degrade-interno, var(--ui-tabela-fundo, var(--ui-fundo-superficie, var(--ui-cor-superficie, #141417))));box-sizing:border-box;position:relative}.ui-tabela{width:100%;border-collapse:separate;border-spacing:0;text-align:left;font-size:14px;font-family:var(--ui-fonte-base, inherit);font-variant-numeric:tabular-nums}.ui-tabela thead{background:var(--ui-tabela-cabecalho-fundo, var(--ui-fundo-elevado, var(--ui-cor-fundo-elevado, #1a1a1e)))}.ui-tabela th{position:sticky;top:0;z-index:10;padding:10px 16px;background:var(--ui-tabela-cabecalho-fundo, var(--ui-fundo-elevado, var(--ui-cor-fundo-elevado, #1a1a1e)));color:var(--ui-cor-texto-secundario, #9696a6);font-size:13px;font-weight:600;letter-spacing:.02em;border-bottom:2px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));white-space:nowrap;-webkit-user-select:none;user-select:none;box-sizing:border-box}.ui-tabela th[aria-sort=ascending],.ui-tabela th[aria-sort=descending]{color:var(--ui-cor-texto, #e1e1e6)}.ui-tabela__resizer{position:absolute;top:0;right:0;width:8px;height:100%;cursor:col-resize;-webkit-user-select:none;user-select:none;touch-action:none;z-index:20;background:linear-gradient(var(--ui-cor-borda, rgba(255, 255, 255, .12)),var(--ui-cor-borda, rgba(255, 255, 255, .12))) center / 1px 60% no-repeat;transition:background-color .15s ease}.ui-tabela__resizer:hover,.ui-tabela__resizer:focus-visible,.ui-tabela__resizer--ativo{background:var(--ui-cor-primaria, #00E08A);outline:none}:host([densidade="compacta"]) th,:host([densidade="compacta"]) td,:host([density="compact"]) th,:host([density="compact"]) td{padding:4px 8px}:host([densidade="normal"]) th,:host([densidade="normal"]) td,:host([density="normal"]) th,:host([density="normal"]) td{padding:10px 16px}:host([densidade="relaxada"]) th,:host([densidade="relaxada"]) td,:host([density="relaxed"]) th,:host([density="relaxed"]) td{padding:16px 20px}:host([altura-linha]) td,:host([row-height]) td{height:var(--ui-tabela-altura-linha);box-sizing:border-box;padding-top:0;padding-bottom:0;overflow:hidden;white-space:nowrap}.ui-tabela__header-content{display:inline-flex;align-items:center;vertical-align:middle;width:100%;box-sizing:border-box}.ui-tabela__header-text{margin-right:var(--ui-tabela-th-gap, 6px);display:inline-block;min-width:0;overflow:hidden;text-overflow:ellipsis}.ui-tabela__sort-icon{width:var(--ui-tabela-th-icone, 16px);min-width:var(--ui-tabela-th-icone, 16px);flex:none;display:inline-flex;justify-content:center;align-items:center}.ui-tabela th.ui-tabela__th--ordenavel{cursor:pointer}@media (hover: hover){.ui-tabela th.ui-tabela__th--ordenavel:hover{background:color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 8%,var(--ui-cor-fundo-elevado, #1a1a1e));color:var(--ui-cor-texto, #e1e1e6)}}.ui-tabela__ordenar{all:unset;display:flex;width:100%;box-sizing:border-box;cursor:pointer;font:inherit;color:inherit;text-align:inherit}.ui-tabela__ordenar:focus-visible{outline:2px solid var(--ui-cor-primaria, #00E08A);outline-offset:2px;border-radius:var(--ui-raio-sm, 4px)}.ui-tabela tbody tr:focus{outline:none}.ui-tabela tbody tr:focus-visible{outline:2px solid var(--ui-tabela-cor-foco, var(--ui-cor-texto, #e1e1e6));outline-offset:-2px;background:var(--ui-tabela-hover, color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 8%, transparent))}.ui-tabela__sort-arrow{display:inline-block;width:14px;height:14px;vertical-align:middle;shape-rendering:geometricPrecision;fill:var(--ui-cor-primaria, #00E08A)}.ui-tabela__sort-arrow path{transition:opacity .15s ease;opacity:.35}.ui-tabela__sort-arrow--asc .seta-cima,.ui-tabela__sort-arrow--desc .seta-baixo{opacity:1}.ui-tabela__sort-arrow--inativo{fill:var(--ui-cor-texto-secundario, #9696a6)}.ui-tabela__sort-arrow--inativo path{opacity:.6}.ui-tabela td{padding:10px 16px;border-bottom:1px solid color-mix(in srgb,var(--ui-cor-borda, rgba(255, 255, 255, .12)) 60%,transparent);white-space:nowrap;vertical-align:middle;color:var(--ui-cor-texto, #e1e1e6);box-sizing:border-box}.ui-tabela__cell-content{display:inline-flex;align-items:center;vertical-align:middle}.ui-tabela__cell-truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%}.ui-tabela--alinhar-esquerda{text-align:left}.ui-tabela--alinhar-esquerda .ui-tabela__header-content,.ui-tabela--alinhar-esquerda .ui-tabela__cell-content{justify-content:flex-start}.ui-tabela--alinhar-centro{text-align:center}.ui-tabela--alinhar-centro .ui-tabela__header-content,.ui-tabela--alinhar-centro .ui-tabela__cell-content{justify-content:center}.ui-tabela--alinhar-direita{text-align:right}.ui-tabela--alinhar-direita .ui-tabela__header-content,.ui-tabela--alinhar-direita .ui-tabela__cell-content{justify-content:flex-end}.ui-tabela tbody tr[data-index]{cursor:pointer}.ui-tabela tbody tr.ui-tabela__tr--par{background:var(--ui-tabela-zebra, color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 4%, transparent))}@media (hover: hover){.ui-tabela tbody tr[data-index]:hover{background:var(--ui-tabela-hover, color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 8%, transparent))}}.ui-tabela tbody tr[data-index]:active{background:var(--ui-tabela-hover, color-mix(in srgb, var(--ui-cor-texto, #e1e1e6) 12%, transparent))}:host(:not([selecionar-texto])) .ui-tabela tbody td{-webkit-user-select:none;user-select:none}.ui-tabela tbody tr.ui-tabela__tr--selecionada,.ui-tabela tbody tr[data-selecionada=true]{background:var(--ui-tabela-selecionada, var(--ui-cor-linha-selecionada, color-mix(in srgb, var(--ui-cor-primaria, #00E08A) 14%, transparent)))}.ui-tabela tbody tr.ui-tabela__tr--selecionada td:first-child,.ui-tabela tbody tr[data-selecionada=true] td:first-child{box-shadow:inset 3px 0 0 var(--ui-cor-primaria, #00E08A)}@media (hover: hover){.ui-tabela tbody tr.ui-tabela__tr--selecionada:hover,.ui-tabela tbody tr[data-selecionada=true]:hover{background:var(--ui-tabela-selecionada-hover, var(--ui-cor-linha-selecionada-hover, color-mix(in srgb, var(--ui-cor-primaria, #00E08A) 22%, transparent)))}}.ui-tabela__virtual-spacer td{padding:0!important;border:none!important;height:inherit;background:transparent!important}.ui-tabela__empty{padding:40px 24px;text-align:center;color:var(--ui-cor-texto-secundario, #9696a6);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:8px;box-sizing:border-box}.ui-tabela__empty-icon{width:32px;height:32px;opacity:.5;fill:currentColor}.ui-tabela__empty-text{font-size:14px;font-weight:500;color:var(--ui-cor-texto-secundario, #9696a6)}.ui-tabela__erro{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin:12px;padding:10px 14px;border:1px solid var(--ui-cor-texto-erro, #ff5555);border-left-width:4px;border-radius:var(--ui-raio-borda, 6px);background:color-mix(in srgb,var(--ui-cor-texto-erro, #ff5555) 10%,transparent);color:var(--ui-cor-texto, #e1e1e6);font-size:14px;box-sizing:border-box}.ui-tabela__erro-texto{flex:1 1 200px;min-width:0}.ui-tabela__erro-detalhe{display:block;margin-top:2px;font-size:12px;color:var(--ui-cor-texto-secundario, #9696a6);overflow-wrap:anywhere}.ui-tabela__erro-acao,.ui-tabela__prompt-actions button{background:var(--ui-cor-botao-secundario-fundo, rgba(255, 255, 255, .12));color:var(--ui-cor-texto, #e1e1e6);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .12));padding:6px 12px;border-radius:var(--ui-raio-sm, 4px);font:inherit;cursor:pointer}.ui-tabela__erro-acao:hover,.ui-tabela__prompt-actions button:hover{background:var(--ui-cor-botao-secundario-hover, rgba(255, 255, 255, .2))}.ui-tabela__erro-acao:focus-visible,.ui-tabela__prompt-actions button:focus-visible,.ui-tabela__prompt-dialog input:focus-visible{outline:2px solid var(--ui-cor-primaria, #00E08A);outline-offset:2px}.ui-tabela__sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}.ui-tabela__loading{position:absolute;top:0;left:0;right:0;bottom:0;background:color-mix(in srgb,var(--ui-cor-superficie, #141417) 72%,transparent);-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;z-index:50;color:var(--ui-cor-texto, #e1e1e6);font-size:14px}.ui-tabela__spinner{width:32px;height:32px;border:3px solid color-mix(in srgb,var(--ui-cor-texto, #e1e1e6) 15%,transparent);border-top-color:var(--ui-cor-primaria, #00E08A);border-radius:50%;animation:ui-tabela-spin .8s linear infinite}@keyframes ui-tabela-spin{to{transform:rotate(360deg)}}.ui-tabela__prompt-dialog{margin:0;max-width:calc(100vw - 16px);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .2));border-radius:var(--ui-raio-borda, 6px);background:var(--ui-tabela-dialogo-fundo, var(--ui-fundo-elevado, var(--ui-cor-fundo-elevado, #1a1a1e)));color:var(--ui-cor-texto, #e1e1e6);padding:12px;box-shadow:var(--ui-sombra-lg, 0 8px 32px rgba(0, 0, 0, .8));font-family:inherit;font-size:14px}.ui-tabela__prompt-dialog::backdrop{background:#0000004d}.ui-tabela__prompt-title{display:block;margin-bottom:8px;font-weight:500}.ui-tabela__prompt-dialog input{width:100%;padding:6px 8px;border-radius:var(--ui-raio-sm, 4px);border:1px solid var(--ui-cor-borda, rgba(255, 255, 255, .2));background:var(--ui-cor-superficie, #141417);color:var(--ui-cor-texto, #e1e1e6);margin-bottom:8px;box-sizing:border-box;font:inherit}.ui-tabela__prompt-dialog input[aria-invalid=true]{border-color:var(--ui-cor-texto-erro, #ff5555)}.ui-tabela__prompt-erro{min-height:1.2em;margin-bottom:8px;font-size:12px;color:var(--ui-cor-texto-erro, #ff5555)}.ui-tabela__prompt-actions{display:flex;justify-content:flex-end;gap:8px}.ui-tabela__prompt-actions button:last-child{background:var(--ui-cor-primaria, #00E08A);border-color:transparent;color:var(--ui-cor-texto-sobre-primaria, #000000);font-weight:600}.ui-tabela__prompt-actions button:last-child:hover{background:color-mix(in srgb,var(--ui-cor-primaria, #00E08A) 85%,var(--ui-cor-texto, #e1e1e6))}@media (pointer: coarse){.ui-tabela__resizer{width:16px}:host(:not([altura-linha]):not([row-height])) .ui-tabela tbody tr[data-index]{height:44px}}@media (max-width: 640px){.ui-tabela th{padding:8px 10px;font-size:12px}.ui-tabela td{padding:8px 10px;font-size:13px}}@media (prefers-reduced-motion: reduce){.ui-tabela__resizer,.ui-tabela__sort-arrow path{transition:none}.ui-tabela__spinner{animation-duration:2.4s}}:host(.degrade),:host(.gradiente),:host([data-degrade]:not([data-degrade="false"])),.ui-tabela-container[data-degrade]:not([data-degrade=false]){--ui-tabela-fundo: var(--ui-gradiente-superficie);--ui-tabela-cabecalho-fundo: var(--ui-gradiente-elevado);--ui-tabela-dialogo-fundo: var(--ui-gradiente-elevado)}';
318
+ function G(t) {
319
+ return t == null || t === "" ? "" : typeof t == "number" ? `${t}px` : t;
320
+ }
321
+ function J(t) {
322
+ return t === "centro" || t === "center" ? "ui-tabela--alinhar-centro" : t === "direita" || t === "right" ? "ui-tabela--alinhar-direita" : "ui-tabela--alinhar-esquerda";
323
+ }
324
+ function Y(t) {
325
+ return t === "centro" || t === "center" ? "center" : t === "direita" || t === "right" ? "right" : "left";
326
+ }
327
+ function V(t) {
328
+ return t === "compacta" ? 30 : t === "relaxada" ? 56 : 42;
329
+ }
330
+ function ve(t, a, e, i) {
331
+ t.innerHTML = `<style>${ge}</style>`;
332
+ const r = document.createElement("div");
333
+ r.className = "ui-tabela-container", r.setAttribute("part", "base"), e && (r.style.maxHeight = e);
334
+ const o = document.createElement("div");
335
+ o.className = "ui-tabela__empty", o.setAttribute("part", "vazio"), o.style.display = "none", o.setAttribute("role", "status");
336
+ const n = document.createElement("div");
337
+ n.innerHTML = `
338
+ <svg class="ui-tabela__empty-icon" aria-hidden="true" focusable="false" viewBox="0 0 24 24">
339
+ <path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zm0 16H5V5h14v14zM7 10h2v7H7zm4-3h2v10h-2zm4 6h2v4h-2z"/>
340
+ </svg>`;
341
+ const s = document.createElement("span");
342
+ s.className = "ui-tabela__empty-text", s.textContent = a, o.appendChild(n), o.appendChild(s);
343
+ const l = document.createElement("table");
344
+ l.className = "ui-tabela", l.setAttribute("part", "tabela"), l.setAttribute("role", "grid");
345
+ const c = document.createElement("colgroup"), d = document.createElement("thead"), u = document.createElement("tbody");
346
+ l.appendChild(c), l.appendChild(d), l.appendChild(u);
347
+ const v = document.createElement("div");
348
+ v.className = "ui-tabela__erro", v.setAttribute("part", "erro"), v.setAttribute("role", "alert"), v.style.display = "none";
349
+ const m = document.createElement("div");
350
+ m.className = "ui-tabela__erro-texto";
351
+ const f = document.createElement("span");
352
+ f.className = "ui-tabela__erro-mensagem";
353
+ const b = document.createElement("span");
354
+ b.className = "ui-tabela__erro-detalhe", m.appendChild(f), m.appendChild(b);
355
+ const _ = document.createElement("button");
356
+ _.type = "button", _.className = "ui-tabela__erro-acao", _.setAttribute("part", "erro-acao"), _.textContent = "Tentar novamente", v.appendChild(m), v.appendChild(_);
357
+ const p = document.createElement("div");
358
+ p.className = "ui-tabela__sr", p.setAttribute("role", "status"), p.setAttribute("aria-live", "polite"), r.appendChild(v), r.appendChild(l), r.appendChild(o), r.appendChild(p);
359
+ const y = document.createElement("div");
360
+ return y.className = "ui-tabela__loading", y.setAttribute("part", "carregando"), y.setAttribute("role", "status"), y.setAttribute("aria-live", "polite"), y.style.display = i ? "flex" : "none", y.innerHTML = `
361
+ <div class="ui-tabela__spinner" aria-hidden="true"></div>
362
+ <span class="ui-tabela__loading-texto">Carregando dados...</span>
363
+ `, r.appendChild(y), t.appendChild(r), {
364
+ containerElement: r,
365
+ tableElement: l,
366
+ theadElement: d,
367
+ tbodyElement: u,
368
+ colgroupElement: c,
369
+ emptyElement: o,
370
+ loadingElement: y,
371
+ erroElement: v,
372
+ anuncioElement: p
373
+ };
374
+ }
375
+ function _e(t) {
376
+ var o, n;
377
+ if (!t.theadElement || !t.colgroupElement) return;
378
+ t.headerListeners.cleanup();
379
+ const e = t.theadElement.getRootNode().activeElement, i = e && t.theadElement.contains(e) ? ((o = e.closest("th")) == null ? void 0 : o.getAttribute("data-coluna")) ?? null : null;
380
+ t.theadElement.innerHTML = "", t.colgroupElement.innerHTML = "";
381
+ const r = document.createElement("tr");
382
+ if (r.setAttribute("aria-rowindex", "1"), t.colunas.forEach((s, l) => {
383
+ const c = document.createElement("col");
384
+ s.largura !== void 0 && (c.style.width = t.formatWidth(s.largura)), t.colgroupElement.appendChild(c);
385
+ const d = document.createElement("th"), u = t.getAlignmentClass(s.alinhamento);
386
+ if (d.className = u, d.setAttribute("part", "celula-cabecalho"), d.scope = "col", d.setAttribute("data-coluna", s.id), d.style.textAlign = t.getTextAlign(s.alinhamento), s.largura !== void 0 && (d.style.width = t.formatWidth(s.largura)), s.larguraMinima !== void 0 && (d.style.minWidth = t.formatWidth(s.larguraMinima)), s.larguraMaxima !== void 0) {
387
+ const g = t.formatWidth(s.larguraMaxima);
388
+ d.style.maxWidth = g, d.style.overflow = "hidden", d.style.textOverflow = "ellipsis", d.style.whiteSpace = "nowrap";
389
+ }
390
+ s.tooltip && (d.title = s.tooltip);
391
+ const v = !!s.ordenavel && t.colunaOrdenada === s.id && t.direcaoOrdenacao !== "original", m = v && t.direcaoOrdenacao === "desc";
392
+ if (s.ordenavel) {
393
+ d.classList.add("ui-tabela__th--ordenavel");
394
+ const g = () => t.onHeaderClick(s);
395
+ t.headerListeners.add(d, "click", g), d.setAttribute("aria-sort", v ? m ? "descending" : "ascending" : "none");
396
+ }
397
+ const f = (g) => t.onHeaderContextMenu(g, s, l, d);
398
+ t.headerListeners.add(d, "contextmenu", f);
399
+ const b = document.createElement("div");
400
+ b.className = "ui-tabela__header-content";
401
+ const _ = document.createElement("span");
402
+ if (_.className = "ui-tabela__header-text", _.textContent = s.rotulo, b.appendChild(_), s.ordenavel) {
403
+ const g = document.createElement("span");
404
+ g.className = "ui-tabela__sort-icon";
405
+ const E = v ? m ? "ui-tabela__sort-arrow--desc" : "ui-tabela__sort-arrow--asc" : "ui-tabela__sort-arrow--inativo";
406
+ g.setAttribute("aria-hidden", "true"), g.innerHTML = `<svg class="ui-tabela__sort-arrow ${E}" viewBox="0 0 24 24" focusable="false"><path class="seta-cima" d="M7 11l5-5 5 5H7z"/><path class="seta-baixo" d="M7 13l5 5 5-5H7z"/></svg>`, b.appendChild(g);
407
+ }
408
+ if (s.ordenavel) {
409
+ const g = document.createElement("button");
410
+ g.type = "button", g.className = "ui-tabela__ordenar", g.setAttribute("part", "ordenar"), g.appendChild(b), d.appendChild(g);
411
+ } else
412
+ d.appendChild(b);
413
+ const p = document.createElement("div");
414
+ p.className = "ui-tabela__resizer", p.setAttribute("part", "redimensionador"), p.title = "Arrastar para redimensionar largura (duplo-clique para auto-ajuste)", p.tabIndex = 0, p.setAttribute("role", "separator"), p.setAttribute("aria-orientation", "vertical"), p.setAttribute("aria-label", `Redimensionar coluna ${s.rotulo}`);
415
+ const y = (g) => t.onInitColumnResize(g, s, l, d, p);
416
+ t.headerListeners.add(p, "mousedown", y);
417
+ const C = (g) => {
418
+ const E = g;
419
+ E.pointerType === "mouse" || !E.pointerType || t.onInitColumnResize(E, s, l, d, p);
420
+ };
421
+ t.headerListeners.add(p, "pointerdown", C);
422
+ const A = (g) => {
423
+ var S, z;
424
+ const E = g, L = E.shiftKey ? 50 : 10;
425
+ if (E.key === "ArrowRight")
426
+ E.preventDefault(), (S = t.onResizeTeclado) == null || S.call(t, L, s, l, d, c);
427
+ else if (E.key === "ArrowLeft")
428
+ E.preventDefault(), (z = t.onResizeTeclado) == null || z.call(t, -L, s, l, d, c);
429
+ else if (E.key === "Enter" || E.key === "F2") {
430
+ E.preventDefault();
431
+ const x = d.getBoundingClientRect();
432
+ t.onHeaderContextMenu(new MouseEvent("contextmenu", { clientX: x.left, clientY: x.bottom }), s, l, d);
433
+ }
434
+ };
435
+ t.headerListeners.add(p, "keydown", A);
436
+ const w = (g) => {
437
+ g.stopPropagation(), t.onColumnAutoFit(s, d, c);
438
+ };
439
+ t.headerListeners.add(p, "dblclick", w), t.headerListeners.add(p, "click", (g) => g.stopPropagation()), d.appendChild(p), r.appendChild(d);
440
+ }), t.theadElement.appendChild(r), i !== null) {
441
+ const s = Array.from(r.children).find((l) => l.getAttribute("data-coluna") === i);
442
+ (n = s == null ? void 0 : s.querySelector(".ui-tabela__ordenar")) == null || n.focus();
443
+ }
444
+ }
445
+ const I = /* @__PURE__ */ new WeakMap(), N = /* @__PURE__ */ new WeakMap();
446
+ function R(t) {
447
+ return t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement || t instanceof HTMLSelectElement;
448
+ }
449
+ function K(t) {
450
+ return t instanceof HTMLInputElement && (t.type === "checkbox" || t.type === "radio") ? t.checked : t.value;
451
+ }
452
+ function Ee(t) {
453
+ t.querySelectorAll("input, textarea, select").forEach((a) => {
454
+ R(a) && N.set(a, K(a));
455
+ });
456
+ }
457
+ function xe(t) {
458
+ try {
459
+ const a = t;
460
+ return { inicio: a.selectionStart ?? null, fim: a.selectionEnd ?? null };
461
+ } catch {
462
+ return { inicio: null, fim: null };
463
+ }
464
+ }
465
+ function ye(t) {
466
+ const e = t.getRootNode().activeElement;
467
+ if (!e || e === t || !t.contains(e)) return null;
468
+ const i = e.closest("td"), r = i == null ? void 0 : i.closest("tr");
469
+ if (!i || !r || r.parentElement !== t || !r.hasAttribute("data-index")) return null;
470
+ const { inicio: o, fim: n } = xe(e), s = R(e) ? N.get(e) : void 0, l = R(e) ? K(e) : void 0, c = s !== void 0 && l !== s;
471
+ return {
472
+ digitado: c ? l : void 0,
473
+ valorInicial: c ? s : void 0,
474
+ item: I.get(r),
475
+ dataId: r.getAttribute("data-id"),
476
+ indiceLinha: Number(r.getAttribute("data-index")),
477
+ indiceColuna: Array.from(r.children).indexOf(i),
478
+ ordinal: Array.from(i.querySelectorAll("*")).indexOf(e),
479
+ selecaoInicio: o,
480
+ selecaoFim: n
481
+ };
482
+ }
483
+ function Ce(t, a) {
484
+ const e = Array.from(t.querySelectorAll("tr[data-index]"));
485
+ if (a.item) {
486
+ const i = e.find((r) => I.get(r) === a.item);
487
+ if (i) return i;
488
+ }
489
+ if (a.dataId !== null) {
490
+ const i = e.find((r) => r.getAttribute("data-id") === a.dataId);
491
+ if (i) return i;
492
+ }
493
+ return e.find((i) => Number(i.getAttribute("data-index")) === a.indiceLinha) ?? null;
494
+ }
495
+ function Ae(t, a) {
496
+ if (!a) return;
497
+ const e = Ce(t, a), i = e == null ? void 0 : e.children[a.indiceColuna], r = i == null ? void 0 : i.querySelectorAll("*")[a.ordinal];
498
+ if (!(!r || typeof r.focus != "function") && (r.focus({ preventScroll: !0 }), a.digitado !== void 0 && R(r) && N.get(r) === a.valorInicial && (typeof a.digitado == "boolean" ? r.checked = a.digitado : r.value = a.digitado), a.selecaoInicio !== null && a.selecaoFim !== null))
499
+ try {
500
+ r.setSelectionRange(a.selecaoInicio, a.selecaoFim);
501
+ } catch {
502
+ }
503
+ }
504
+ const we = [
505
+ "button",
506
+ "input",
507
+ "select",
508
+ "textarea",
509
+ "a",
510
+ "summary",
511
+ "label",
512
+ '[role="button"]',
513
+ '[role="checkbox"]',
514
+ '[role="switch"]',
515
+ '[role="radio"]',
516
+ '[role="textbox"]',
517
+ '[role="combobox"]',
518
+ '[role="slider"]',
519
+ '[role="spinbutton"]',
520
+ '[role="menuitem"]',
521
+ '[role="tab"]',
522
+ '[role="link"]',
523
+ '[contenteditable]:not([contenteditable="false"])',
524
+ "[data-prevent-select]"
525
+ ].join(", "), Q = /* @__PURE__ */ new WeakMap();
526
+ function Se(t, a) {
527
+ for (const e of t.composedPath()) {
528
+ if (e === a) return !1;
529
+ if (e instanceof Element && e.matches(we)) return !0;
530
+ }
531
+ return !1;
532
+ }
533
+ function T(t, a, e) {
534
+ const i = document.createElement("tr");
535
+ i.className = "ui-tabela__virtual-spacer", i.setAttribute("data-espacador", t), i.setAttribute("aria-hidden", "true"), i.style.height = `${a}px`;
536
+ const r = document.createElement("td");
537
+ return r.colSpan = e, i.appendChild(r), i;
538
+ }
539
+ function ze(t, a, e, i) {
540
+ const r = document.createElement("td"), o = t.getAlignmentClass(a.alinhamento);
541
+ if (r.className = o, r.setAttribute("part", "celula"), r.style.textAlign = t.getTextAlign(a.alinhamento), a.larguraMaxima !== void 0) {
542
+ const l = t.formatWidth(a.larguraMaxima);
543
+ r.style.maxWidth = l, r.style.overflow = "hidden", r.style.textOverflow = "ellipsis", r.style.whiteSpace = "nowrap";
544
+ }
545
+ const n = document.createElement("div");
546
+ n.className = "ui-tabela__cell-content", a.larguraMaxima !== void 0 && n.classList.add("ui-tabela__cell-truncate");
547
+ const s = e[a.id];
548
+ if (typeof a.render == "function")
549
+ try {
550
+ const l = t.indiceOriginal ? t.indiceOriginal(e) : i, c = a.render(s, e, i, l);
551
+ c instanceof Node ? n.appendChild(c) : n.textContent = String(c ?? "");
552
+ } catch (l) {
553
+ console.error(`[ui-tabela] Erro no render da coluna "${a.id}" (linha ${i}):`, l), n.textContent = "";
554
+ }
555
+ else if (s instanceof Node)
556
+ n.appendChild(s);
557
+ else {
558
+ const l = s != null ? String(s) : "";
559
+ n.textContent = l, a.larguraMaxima !== void 0 && !a.tooltip && (r.title = l);
560
+ }
561
+ return r.appendChild(n), Ee(r), r;
562
+ }
563
+ function Z(t, a, e, i) {
564
+ const r = document.createElement("tr");
565
+ I.set(r, a), Q.set(r, t.colunas), r.setAttribute("data-index", String(e)), r.setAttribute("part", "linha"), r.setAttribute("aria-rowindex", String(e + 2)), r.setAttribute("aria-selected", "false"), r.tabIndex = e === i ? 0 : -1, e % 2 === 1 && r.classList.add("ui-tabela__tr--par");
566
+ const o = t.chaveId;
567
+ return a[o] !== void 0 ? r.setAttribute("data-id", String(a[o])) : a.id !== void 0 ? r.setAttribute("data-id", String(a.id)) : a._id !== void 0 && r.setAttribute("data-id", String(a._id)), t.isItemSelecionado(a, e) && (r.classList.add("ui-tabela__tr--selecionada"), r.setAttribute("part", "linha linha-selecionada"), r.setAttribute("aria-current", "true"), r.setAttribute("aria-selected", "true"), r.setAttribute("data-selecionada", "true")), r.addEventListener("click", (n) => {
568
+ Se(n, r) || t.onLinhaClique(a, e);
569
+ }), t.colunas.forEach((n) => {
570
+ r.appendChild(ze(t, n, a, e));
571
+ }), r;
572
+ }
573
+ function Le(t, a, e, i, r) {
574
+ a.tabIndex = i === r ? 0 : -1;
575
+ const o = t.isItemSelecionado(e, i);
576
+ o !== a.classList.contains("ui-tabela__tr--selecionada") && (a.classList.toggle("ui-tabela__tr--selecionada", o), X(a, "linha-selecionada", o), a.setAttribute("aria-selected", String(o)), o ? (a.setAttribute("aria-current", "true"), a.setAttribute("data-selecionada", "true")) : (a.removeAttribute("aria-current"), a.removeAttribute("data-selecionada")));
577
+ }
578
+ function Oe(t, a, e, i, r) {
579
+ return e >= i && e < r && I.get(a) === t.dadosExibicao[e] && Q.get(a) === t.colunas;
580
+ }
581
+ function Re(t, a, e, i, r, o, n) {
582
+ const s = t.dadosExibicao.length, l = t.colunas.length || 1, c = /* @__PURE__ */ new Map();
583
+ let d = null, u = null;
584
+ for (const b of Array.from(a.children)) {
585
+ const _ = b.getAttribute("data-espacador");
586
+ if (_ === "topo") {
587
+ d = b;
588
+ continue;
589
+ }
590
+ if (_ === "base") {
591
+ u = b;
592
+ continue;
593
+ }
594
+ const p = Number(b.getAttribute("data-index"));
595
+ b.hasAttribute("data-index") && !c.has(p) && Oe(t, b, p, e, i) ? c.set(p, b) : b.remove();
596
+ }
597
+ const v = o && e > 0 ? e * r : 0;
598
+ v > 0 ? d ? (d.style.height = `${v}px`, d.firstElementChild.colSpan = l) : (d = T("topo", v, l), a.insertBefore(d, a.firstChild)) : d && (d.remove(), d = null);
599
+ let m = d ? d.nextSibling : a.firstChild;
600
+ for (let b = e; b < i; b++) {
601
+ const _ = t.dadosExibicao[b], p = c.get(b);
602
+ p ? (Le(t, p, _, b, n), p === m ? m = p.nextSibling : a.insertBefore(p, m)) : a.insertBefore(Z(t, _, b, n), m);
603
+ }
604
+ const f = o && i < s ? (s - i) * r : 0;
605
+ f > 0 ? u ? (u.style.height = `${f}px`, u.firstElementChild.colSpan = l, u.nextSibling && a.appendChild(u)) : a.appendChild(T("base", f, l)) : u && u.remove();
606
+ }
607
+ function Te(t, a, e, i, r, o, n) {
608
+ const s = t.dadosExibicao.length, l = t.colunas.length || 1;
609
+ a.innerHTML = "";
610
+ const c = document.createDocumentFragment();
611
+ o && e > 0 && c.appendChild(T("topo", e * r, l));
612
+ for (let d = e; d < i; d++)
613
+ c.appendChild(Z(t, t.dadosExibicao[d], d, n));
614
+ o && i < s && c.appendChild(T("base", (s - i) * r, l)), a.appendChild(c);
615
+ }
616
+ function Ie(t) {
617
+ if (!t.tbodyElement || !t.tableElement || !t.emptyElement || !t.containerElement) return;
618
+ if (t.tableElement.setAttribute("aria-colcount", String(t.colunas.length)), !t.dadosExibicao || t.dadosExibicao.length === 0) {
619
+ t.tbodyElement.innerHTML = "", t.tableElement.setAttribute("aria-rowcount", "1"), t.tableElement.style.display = t.colunas.length > 0 ? "table" : "none", t.emptyElement.style.display = "flex";
620
+ const m = t.emptyElement.querySelector(".ui-tabela__empty-text"), f = t.filtroAtivo ? t.textoSemResultados : t.textoVazio;
621
+ m && f !== void 0 && (m.textContent = f);
622
+ return;
623
+ }
624
+ t.emptyElement.style.display = "none", t.tableElement.style.display = "table", t.tableElement.setAttribute("aria-rowcount", String(t.dadosExibicao.length + 1));
625
+ const a = t.dadosExibicao.length, e = t.rowHeight, i = t.virtualizar && a > 30;
626
+ let r = 0, o = a;
627
+ if (i) {
628
+ const m = t.containerElement.scrollTop, f = t.containerElement.clientHeight || 400, b = 5;
629
+ r = Math.max(0, Math.floor(m / e) - b), o = Math.min(a, Math.ceil((m + f) / e) + b);
630
+ }
631
+ const n = t.tbodyElement, s = n.getRootNode(), l = s.activeElement, c = l && l.parentElement === n ? l.getAttribute("data-index") : null, d = ye(n), u = t.indiceAtivo ?? null, v = u !== null && u >= r && u < o ? u : r;
632
+ if (t.modo === "rolagem" ? Re(t, n, r, o, e, i, v) : Te(t, n, r, o, e, i, v), c !== null) {
633
+ const m = n.querySelector(`tr[data-index="${c}"]`);
634
+ m && s.activeElement !== m && m.focus({ preventScroll: !0 });
635
+ } else d && !(l && l.isConnected) && Ae(n, d);
636
+ }
637
+ function W(t) {
638
+ if (t === void 0) return null;
639
+ const a = typeof t == "number" ? t : parseInt(t, 10);
640
+ return isNaN(a) ? null : a;
641
+ }
642
+ function H(t, a) {
643
+ const e = W(t.larguraMinima);
644
+ let i = Math.max(e ?? 60, a);
645
+ const r = W(t.larguraMaxima);
646
+ return r !== null && (i = Math.min(r, i)), i;
647
+ }
648
+ function ke(t, a, e, i) {
649
+ const r = H(t, a.offsetWidth + i);
650
+ return t.largura = `${r}px`, a.style.width = `${r}px`, e && (e.style.width = `${r}px`), `${r}px`;
651
+ }
652
+ function Me(t) {
653
+ const {
654
+ evento: a,
655
+ coluna: e,
656
+ colIndex: i,
657
+ thElement: r,
658
+ resizer: o,
659
+ colgroupElement: n,
660
+ onResizeStart: s,
661
+ onResizeEnd: l,
662
+ onResizeCancel: c
663
+ } = t;
664
+ a.stopPropagation(), a.preventDefault(), s(), o.classList.add("ui-tabela__resizer--ativo");
665
+ const d = a.pageX, u = r.offsetWidth, v = n == null ? void 0 : n.children[i], m = a.type === "pointerdown", f = m ? a.pointerId : null, b = m ? "pointermove" : "mousemove", _ = m ? "pointerup" : "mouseup";
666
+ let p = !1;
667
+ const y = (w) => {
668
+ const g = w;
669
+ if (f !== null && g.pointerId !== f) return;
670
+ p = !0;
671
+ const E = H(e, u + (g.pageX - d));
672
+ e.largura = `${E}px`, r.style.width = `${E}px`, v && (v.style.width = `${E}px`);
673
+ }, C = () => {
674
+ A(), p ? l(String(e.largura)) : c == null || c();
675
+ }, A = () => {
676
+ o.classList.remove("ui-tabela__resizer--ativo"), window.removeEventListener(b, y), window.removeEventListener(_, C), m && window.removeEventListener("pointercancel", C);
677
+ };
678
+ return window.addEventListener(b, y), window.addEventListener(_, C), m && window.addEventListener("pointercancel", C), A;
679
+ }
680
+ const O = 20;
681
+ let De = 0;
682
+ function Ne(t) {
683
+ var z;
684
+ const {
685
+ evento: a,
686
+ coluna: e,
687
+ colIndex: i,
688
+ thElement: r,
689
+ colgroupElement: o,
690
+ shadow: n,
691
+ onResizeEnd: s
692
+ } = t, l = `ui-tabela-dlg-${++De}`, c = document.createElement("dialog");
693
+ c.className = "ui-tabela__prompt-dialog", c.setAttribute("part", "dialogo"), c.setAttribute("aria-labelledby", `${l}-titulo`);
694
+ const d = document.createElement("label");
695
+ d.className = "ui-tabela__prompt-title", d.id = `${l}-titulo`, d.htmlFor = `${l}-campo`, d.textContent = `Largura de "${e.rotulo}" (px; vazio = automática)`;
696
+ const u = document.createElement("input");
697
+ u.id = `${l}-campo`, u.type = "number", u.min = String(O), u.step = "1", u.setAttribute("inputmode", "numeric"), u.placeholder = "auto";
698
+ const v = e.largura ? parseInt(String(e.largura), 10) : NaN;
699
+ u.value = Number.isFinite(v) ? String(v) : "";
700
+ const m = document.createElement("div");
701
+ m.className = "ui-tabela__prompt-erro", m.id = `${l}-erro`, m.setAttribute("role", "alert");
702
+ const f = document.createElement("div");
703
+ f.className = "ui-tabela__prompt-actions";
704
+ const b = document.createElement("button");
705
+ b.type = "button", b.textContent = "Aplicar";
706
+ const _ = document.createElement("button");
707
+ _.type = "button", _.textContent = "Cancelar", f.appendChild(_), f.appendChild(b), c.appendChild(d), c.appendChild(u), c.appendChild(m), c.appendChild(f), n.appendChild(c), typeof c.showModal == "function" ? c.showModal() : c.setAttribute("open", ""), c.style.position = "fixed";
708
+ const p = c.getBoundingClientRect(), y = p.width || 240, C = p.height || 140, A = Math.max(8, Math.min(a.clientX || 0, window.innerWidth - y - 8)), w = Math.max(8, Math.min(a.clientY || 0, window.innerHeight - C - 8));
709
+ c.style.left = `${A}px`, c.style.top = `${w}px`;
710
+ let g = !1;
711
+ const E = () => {
712
+ var x;
713
+ g || (g = !0, c.open && typeof c.close == "function" && c.close(), c.remove(), (x = r.querySelector(".ui-tabela__ordenar, .ui-tabela__resizer")) == null || x.focus());
714
+ }, L = (x) => {
715
+ m.textContent = x, u.setAttribute("aria-invalid", "true"), u.setAttribute("aria-describedby", m.id), u.focus();
716
+ }, S = () => {
717
+ const x = e.largura, F = u.value.trim();
718
+ if (F === "")
719
+ e.largura = void 0, r.style.width = "", o != null && o.children[i] && (o.children[i].style.width = "");
720
+ else {
721
+ const k = Number(F);
722
+ if (!Number.isFinite(k) || k < O) {
723
+ L(`Informe um valor de pelo menos ${O} px, ou deixe vazio para automática.`);
724
+ return;
725
+ }
726
+ const M = Math.round(H({ ...e, larguraMinima: e.larguraMinima ?? O }, k));
727
+ e.largura = `${M}px`, r.style.width = `${M}px`, o != null && o.children[i] && (o.children[i].style.width = `${M}px`);
728
+ }
729
+ E(), e.largura !== x && s(e.largura ? String(e.largura) : "auto");
730
+ };
731
+ b.addEventListener("click", (x) => {
732
+ x.stopPropagation(), S();
733
+ }), _.addEventListener("click", (x) => {
734
+ x.stopPropagation(), E();
735
+ }), c.addEventListener("close", E), u.addEventListener("input", () => {
736
+ m.textContent = "", u.removeAttribute("aria-invalid"), u.removeAttribute("aria-describedby");
737
+ }), u.addEventListener("keydown", (x) => {
738
+ x.key === "Enter" ? (x.preventDefault(), S()) : x.key === "Escape" && (x.preventDefault(), E());
739
+ }), u.focus(), (z = u.select) == null || z.call(u);
740
+ }
741
+ function He(t, a, e, i, r, o) {
742
+ return Me({
743
+ evento: t,
744
+ coluna: a,
745
+ colIndex: e,
746
+ thElement: i,
747
+ resizer: r,
748
+ colgroupElement: o.colgroupElement,
749
+ onResizeStart: () => o.onSetIsResizing(!0),
750
+ onResizeCancel: () => {
751
+ setTimeout(() => o.onSetIsResizing(!1), 50);
752
+ },
753
+ onResizeEnd: (n) => {
754
+ setTimeout(() => o.onSetIsResizing(!1), 50), o.host.dispatchEvent(
755
+ new CustomEvent("ui-column-resize", {
756
+ detail: { idColuna: a.id, largura: n },
757
+ bubbles: !0,
758
+ composed: !0
759
+ })
760
+ );
761
+ }
762
+ });
763
+ }
764
+ function Fe(t, a, e, i, r) {
765
+ t.preventDefault(), t.stopPropagation(), Ne({
766
+ evento: t,
767
+ coluna: a,
768
+ colIndex: e,
769
+ thElement: i,
770
+ colgroupElement: r.colgroupElement,
771
+ shadow: r.shadow,
772
+ onResizeEnd: (o) => {
773
+ r.host.dispatchEvent(
774
+ new CustomEvent("ui-column-resize", {
775
+ detail: { idColuna: a.id, largura: o },
776
+ bubbles: !0,
777
+ composed: !0
778
+ })
779
+ );
780
+ }
781
+ });
782
+ }
783
+ function $e(t, a, e, i, r) {
784
+ const o = ke(a, e, i, t);
785
+ r.host.dispatchEvent(
786
+ new CustomEvent("ui-column-resize", {
787
+ detail: { idColuna: a.id, largura: o },
788
+ bubbles: !0,
789
+ composed: !0
790
+ })
791
+ );
792
+ }
793
+ function Be(t) {
794
+ _e({
795
+ theadElement: t.theadElement,
796
+ colgroupElement: t.colgroupElement,
797
+ colunas: t.colunas,
798
+ colunaOrdenada: t.dadosController.getColunaOrdenada(),
799
+ direcaoOrdenacao: t.dadosController.getDirecaoOrdenacao(),
800
+ headerListeners: t.headerListeners,
801
+ formatWidth: G,
802
+ getAlignmentClass: J,
803
+ getTextAlign: Y,
804
+ onHeaderClick: (a) => t.onHeaderClick(a),
805
+ onHeaderContextMenu: (a, e, i, r) => {
806
+ Fe(a, e, i, r, {
807
+ host: t.host,
808
+ colgroupElement: t.colgroupElement,
809
+ shadow: t.shadow,
810
+ onSetIsResizing: t.onSetIsResizing
811
+ });
812
+ },
813
+ onInitColumnResize: (a, e, i, r, o) => {
814
+ const n = He(a, e, i, r, o, {
815
+ host: t.host,
816
+ colgroupElement: t.colgroupElement,
817
+ shadow: t.shadow,
818
+ onSetIsResizing: t.onSetIsResizing
819
+ });
820
+ t.onActiveResizeCleanup(n);
821
+ },
822
+ onResizeTeclado: (a, e, i, r, o) => {
823
+ $e(a, e, r, o, {
824
+ host: t.host,
825
+ colgroupElement: t.colgroupElement,
826
+ shadow: t.shadow,
827
+ onSetIsResizing: t.onSetIsResizing
828
+ });
829
+ },
830
+ onColumnAutoFit: (a, e, i) => {
831
+ a.largura = void 0, e.style.width = "", i.style.width = "", t.host.dispatchEvent(
832
+ new CustomEvent("ui-column-resize", {
833
+ bubbles: !0,
834
+ composed: !0,
835
+ detail: { idColuna: a.id, largura: "auto" }
836
+ })
837
+ );
838
+ }
839
+ });
840
+ }
841
+ function Pe(t) {
842
+ Ie({
843
+ tbodyElement: t.tbodyElement,
844
+ tableElement: t.tableElement,
845
+ emptyElement: t.emptyElement,
846
+ containerElement: t.containerElement,
847
+ dadosExibicao: t.dadosController.getDadosExibicao(),
848
+ colunas: t.colunas,
849
+ chaveId: t.chaveId,
850
+ virtualizar: t.virtualizar,
851
+ rowHeight: t.rowHeight,
852
+ indiceAtivo: t.indiceAtivo,
853
+ filtroAtivo: t.dadosController.temFiltro(),
854
+ modo: t.modoCorpo,
855
+ indiceOriginal: (a) => t.dadosController.indiceOriginal(a),
856
+ textoVazio: t.textoVazio,
857
+ textoSemResultados: t.textoSemResultados,
858
+ isItemSelecionado: (a, e) => t.selecaoController.isItemSelecionado(a, e),
859
+ onLinhaClique: (a, e) => {
860
+ t.selecaoController.setItemSelecionado(a), t.host.dispatchEvent(
861
+ new CustomEvent("ui-linha-clique", {
862
+ bubbles: !0,
863
+ composed: !0,
864
+ detail: { item: a, indice: e }
865
+ })
866
+ );
867
+ },
868
+ formatWidth: G,
869
+ getAlignmentClass: J,
870
+ getTextAlign: Y
871
+ });
872
+ }
873
+ function qe(t, a) {
874
+ let e = !1;
875
+ const i = () => {
876
+ e || (window.requestAnimationFrame(() => {
877
+ try {
878
+ a();
879
+ } finally {
880
+ e = !1;
881
+ }
882
+ }), e = !0);
883
+ };
884
+ return t.addEventListener("scroll", i), i;
885
+ }
886
+ function Ve(t, a, e, i) {
887
+ return ve(t, a, e, i);
888
+ }
889
+ function ee(t) {
890
+ const a = t.host.getAttribute("texto-vazio") || t.host.getAttribute("empty-text");
891
+ a && t.onTextoVazioAlterado(a);
892
+ const e = t.host.getAttribute("virtualizar") || t.host.getAttribute("virtualize");
893
+ e !== null && t.onVirtualizarAlterado(e !== "false"), t.onSrcLido(t.host.getAttribute("src"));
894
+ const i = t.host.hasAttribute("carregando") || t.host.hasAttribute("loading");
895
+ t.onCarregandoAlterado(i), t.loadingElement && (t.loadingElement.style.display = i ? "flex" : "none");
896
+ }
897
+ function We(t, a, e) {
898
+ if (ee(e), t === "src") {
899
+ a && e.host.isConnected && e.onCarregarSrc(a);
900
+ return;
901
+ }
902
+ if (t === "max-height" && e.containerElement) {
903
+ e.containerElement.style.maxHeight = a || "";
904
+ return;
905
+ }
906
+ if ((t === "texto-vazio" || t === "empty-text") && e.emptyElement) {
907
+ const i = e.emptyElement.querySelector(".ui-tabela__empty-text");
908
+ i && a && (i.textContent = a), e.onRenderBody();
909
+ return;
910
+ }
911
+ if (t === "carregando" || t === "loading") {
912
+ e.loadingElement && (e.loadingElement.style.display = a !== null ? "flex" : "none");
913
+ return;
914
+ }
915
+ if (!(t === "aria-label" || t === "texto-erro" || t === "texto-carregando")) {
916
+ if (t === "texto-sem-resultados" || t === "densidade" || t === "density") {
917
+ e.onRenderBody();
918
+ return;
919
+ }
920
+ e.onRenderTotal();
921
+ }
922
+ }
923
+ function Ue(t, a, e, i) {
924
+ if (t === "Enter" || t === " ") return { tipo: "ativar" };
925
+ if (!Number.isInteger(a) || !Number.isInteger(e) || e < 0) return null;
926
+ const r = Math.max(1, Math.floor(Number.isFinite(i) ? i : 1)), o = (n) => Math.min(e, Math.max(0, n));
927
+ switch (t) {
928
+ case "ArrowDown":
929
+ return { tipo: "mover", indice: o(a + 1) };
930
+ case "ArrowUp":
931
+ return { tipo: "mover", indice: o(a - 1) };
932
+ case "Home":
933
+ return { tipo: "mover", indice: 0 };
934
+ case "End":
935
+ return { tipo: "mover", indice: e };
936
+ case "PageDown":
937
+ return { tipo: "mover", indice: o(a + r) };
938
+ case "PageUp":
939
+ return { tipo: "mover", indice: o(a - r) };
940
+ default:
941
+ return null;
942
+ }
943
+ }
944
+ const je = "Não foi possível carregar os dados.", Xe = "Nenhum resultado para o filtro";
945
+ function Ge(t, a, e, i) {
946
+ if (!t) return;
947
+ if (!a) {
948
+ t.style.display = "none";
949
+ return;
950
+ }
951
+ const r = t.querySelector(".ui-tabela__erro-mensagem"), o = t.querySelector(".ui-tabela__erro-detalhe");
952
+ r && (r.textContent = e || je), o && (o.textContent = a.erro || "");
953
+ const n = t.querySelector(".ui-tabela__erro-acao");
954
+ n && (n.style.display = i ? "" : "none"), t.style.display = "flex";
955
+ }
956
+ function Je(t, a, e, i) {
957
+ if (!t) return;
958
+ const r = e ? a === 0 ? i : `${a} ${a === 1 ? "registro encontrado" : "registros encontrados"}` : "";
959
+ t.textContent !== r && (t.textContent = r);
960
+ }
961
+ function Ye({ tabela: t, container: a }, e, i) {
962
+ t && (e ? t.setAttribute("aria-label", e) : t.removeAttribute("aria-label"), t.setAttribute("aria-busy", String(i)), a && (e ? (a.setAttribute("role", "region"), a.setAttribute("aria-label", e)) : (a.removeAttribute("role"), a.removeAttribute("aria-label"))));
963
+ }
964
+ const Ke = 800;
965
+ function U(t, a, e) {
966
+ const i = t.getBoundingClientRect(), r = a.getBoundingClientRect(), o = i.top + t.clientTop + e, n = i.top + t.clientTop + t.clientHeight;
967
+ return r.top < o ? r.top - o : r.bottom > n ? Math.min(r.bottom - n, r.top - o) : 0;
968
+ }
969
+ function j(t, a, e) {
970
+ e === "smooth" && typeof t.scrollTo == "function" ? t.scrollTo({ top: a, behavior: "smooth" }) : t.scrollTop = a;
971
+ }
972
+ class Qe {
973
+ constructor(a) {
974
+ h(this, "cancelarCorrecao", null);
975
+ this.p = a;
976
+ }
977
+ alturaCabecalho() {
978
+ var a;
979
+ return ((a = this.p.cabecalho()) == null ? void 0 : a.offsetHeight) ?? 0;
980
+ }
981
+ /** Linhas inteiras que cabem na área visível (mínimo 1). */
982
+ linhasPorPagina() {
983
+ var e;
984
+ const a = (((e = this.p.container()) == null ? void 0 : e.clientHeight) ?? 0) - this.alturaCabecalho();
985
+ return Math.max(1, Math.floor(a / this.p.alturaLinha()));
986
+ }
987
+ /** Foca a linha, renderizando a janela virtual se necessário, e a mantém visível abaixo do cabeçalho fixo. */
988
+ focar(a) {
989
+ const e = this.p.container(), i = this.p.tbody();
990
+ if (!e || !i) return;
991
+ this.p.aoLinhaAtiva(a);
992
+ const r = `tr[data-index="${a}"]`;
993
+ let o = i.querySelector(r);
994
+ if (o || (e.scrollTop = Math.max(0, a * this.p.alturaLinha() - e.clientHeight / 2), this.p.renderizarCorpo(), o = i.querySelector(r)), !o) return;
995
+ o.focus({ preventScroll: !0 });
996
+ const n = U(e, o, this.alturaCabecalho());
997
+ n && (e.scrollTop += n);
998
+ }
999
+ /**
1000
+ * Posiciona a linha exibida `indice` na área visível.
1001
+ * Fora da janela virtual, rola até a posição estimada, renderiza a janela e corrige pela posição
1002
+ * real da linha. No modo suave a correção ocorre ao fim da animação (`scrollend`, com timeout de
1003
+ * segurança para navegadores sem o evento ou quando não há rolagem a fazer).
1004
+ */
1005
+ posicionar(a, e) {
1006
+ const i = this.p.container(), r = this.p.tbody();
1007
+ if (!i || !r) return !1;
1008
+ this.cancelar();
1009
+ const o = () => r.querySelector(`tr[data-index="${a}"]`), n = (u) => {
1010
+ const v = o();
1011
+ if (!v) return;
1012
+ const m = U(i, v, this.alturaCabecalho());
1013
+ m && j(i, i.scrollTop + m, u);
1014
+ };
1015
+ if (o())
1016
+ return n(e), !0;
1017
+ const s = () => {
1018
+ i.scrollTop = Math.max(0, a * this.p.alturaLinha()), this.p.renderizarCorpo(), n("auto"), this.p.renderizarCorpo();
1019
+ };
1020
+ if (e === "auto")
1021
+ return s(), !0;
1022
+ j(i, Math.max(0, a * this.p.alturaLinha()), "smooth");
1023
+ let l = !0;
1024
+ const c = () => {
1025
+ l && (this.cancelar(), this.p.renderizarCorpo(), o() ? n("smooth") : s());
1026
+ }, d = window.setTimeout(c, Ke);
1027
+ return i.addEventListener("scrollend", c, { once: !0 }), this.cancelarCorrecao = () => {
1028
+ l = !1, window.clearTimeout(d), i.removeEventListener("scrollend", c), this.cancelarCorrecao = null;
1029
+ }, !0;
1030
+ }
1031
+ /** Cancela a correção pendente de uma rolagem suave (nova rolagem, desconexão). */
1032
+ cancelar() {
1033
+ var a;
1034
+ (a = this.cancelarCorrecao) == null || a.call(this);
1035
+ }
1036
+ }
1037
+ class Ze extends re {
1038
+ constructor() {
1039
+ super();
1040
+ h(this, "shadow");
1041
+ h(this, "_colunas", []);
1042
+ h(this, "_textoVazio", "Nenhum registro encontrado");
1043
+ h(this, "_virtualizar", !0);
1044
+ h(this, "_isResizing", !1);
1045
+ h(this, "_carregando", !1);
1046
+ h(this, "_src", null);
1047
+ h(this, "_fetchOpcoes", null);
1048
+ h(this, "_fetcher", null);
1049
+ h(this, "_containerElement", null);
1050
+ h(this, "_tableElement", null);
1051
+ h(this, "_theadElement", null);
1052
+ h(this, "_tbodyElement", null);
1053
+ h(this, "_colgroupElement", null);
1054
+ h(this, "_emptyElement", null);
1055
+ h(this, "_loadingElement", null);
1056
+ h(this, "_erroElement", null);
1057
+ h(this, "_anuncioElement", null);
1058
+ /** Último erro de carregamento remoto (null = sem erro). */
1059
+ h(this, "_erro", null);
1060
+ h(this, "_scrollHandler", null);
1061
+ h(this, "_activeResizeCleanup", null);
1062
+ h(this, "_headerListeners", new $());
1063
+ h(this, "_corpoListeners", new $());
1064
+ /** Linha com o foco móvel (navegação por teclado); null = primeira linha visível. */
1065
+ h(this, "_indiceAtivo", null);
1066
+ /** Altura real das linhas medida no DOM; null = usa a estimativa da densidade. */
1067
+ h(this, "_alturaLinhaMedida", null);
1068
+ h(this, "rolagem", new Qe({
1069
+ container: () => this._containerElement,
1070
+ tbody: () => this._tbodyElement,
1071
+ cabecalho: () => this._theadElement,
1072
+ alturaLinha: () => this.getRowHeight(),
1073
+ renderizarCorpo: () => this.renderBody("rolagem"),
1074
+ aoLinhaAtiva: (e) => {
1075
+ this._indiceAtivo = e;
1076
+ }
1077
+ }));
1078
+ h(this, "remotaController");
1079
+ h(this, "selecaoController");
1080
+ h(this, "dadosController", new fe());
1081
+ /** Mantém um único tabindex=0 (foco móvel): Tab entra na tabela pela última linha ativa. */
1082
+ h(this, "handleFocoLinha", (e) => {
1083
+ const i = e.target;
1084
+ i.parentElement !== this._tbodyElement || !i.hasAttribute("data-index") || this.definirLinhaAtiva(Number(i.getAttribute("data-index")));
1085
+ });
1086
+ /**
1087
+ * Teclado nas linhas: setas, Home/End e PageUp/PageDown movem o foco;
1088
+ * Enter/Espaço selecionam a linha (mesmo caminho do clique, emite `ui-linha-clique`).
1089
+ */
1090
+ h(this, "handleTecladoCorpo", (e) => {
1091
+ const i = e.target;
1092
+ if (i.parentElement !== this._tbodyElement || !i.hasAttribute("data-index")) return;
1093
+ const r = this.dadosController.getDadosExibicao().length - 1, o = Ue(e.key, Number(i.getAttribute("data-index")), r, this.rolagem.linhasPorPagina());
1094
+ o && (e.preventDefault(), o.tipo === "ativar" ? i.click() : this.rolagem.focar(o.indice));
1095
+ });
1096
+ this.shadow = this.attachShadow({ mode: "open" }), this.remotaController = new se({
1097
+ host: this,
1098
+ onCarregandoAlterado: (e) => {
1099
+ this.carregando = e;
1100
+ },
1101
+ onDadosRecebidos: (e) => {
1102
+ this.dados = e;
1103
+ },
1104
+ getOpcoes: () => this._fetchOpcoes,
1105
+ getFetcher: () => this._fetcher
1106
+ }), this.selecaoController = new ue({
1107
+ host: this,
1108
+ getTbody: () => this._tbodyElement,
1109
+ getDadosExibicao: () => this.dadosController.getDadosExibicao(),
1110
+ getDadosOriginais: () => this.dadosController.getDadosOriginais(),
1111
+ getChaveId: () => this.chaveId,
1112
+ onRolarParaIndice: (e, i) => this.rolagem.posicionar(e, i),
1113
+ onLinhaAtiva: (e) => this.definirLinhaAtiva(e)
1114
+ }), this.addEventListener("ui-fetch-erro", (e) => this.mostrarErro(e.detail)), this.addEventListener("ui-fetch-start", () => this.mostrarErro(null)), this.addEventListener("ui-fetch-sucesso", () => this.mostrarErro(null));
1115
+ }
1116
+ static get observedAttributes() {
1117
+ return ["texto-vazio", "empty-text", "max-height", "densidade", "density", "altura-linha", "row-height", "virtualizar", "virtualize", "src", "carregando", "loading", "chave-id", "id-key", "aria-label", "ordenacao-remota", "texto-erro", "texto-sem-resultados", "texto-carregando", ...oe];
1118
+ }
1119
+ connectedCallback() {
1120
+ this.syncAttributes(), this.alturaLinha && this.style.setProperty("--ui-tabela-altura-linha", `${this.alturaLinha}px`), !this.hasAttribute("densidade") && !this.hasAttribute("density") && this.setAttribute("densidade", "normal"), this.renderTotal(), this._src && this.remotaController.carregar(this._src);
1121
+ }
1122
+ disconnectedCallback() {
1123
+ this.cleanupEventListeners();
1124
+ }
1125
+ attributeChangedCallback(e, i, r) {
1126
+ if (ne(e)) {
1127
+ B(this, this._containerElement);
1128
+ return;
1129
+ }
1130
+ e === "ordenacao-remota" && (this.dadosController.setOrdenacaoRemota(r !== null), this.atualizarContextoSelecao()), (e === "densidade" || e === "density" || e === "altura-linha" || e === "row-height") && (this._alturaLinhaMedida = null), (e === "altura-linha" || e === "row-height") && this.aplicarAlturaLinha(), (e === "chave-id" || e === "id-key") && this.atualizarContextoSelecao(), We(e, r, this.obterContextoAtributos()), this.sincronizarAria();
1131
+ }
1132
+ /** Nome acessível vem do host (`aria-label`); `aria-busy` acompanha o carregamento remoto. */
1133
+ sincronizarAria() {
1134
+ this._tableElement && (Ye({ tabela: this._tableElement, container: this._containerElement }, this.getAttribute("aria-label"), this._carregando), this.atualizarTextosEstado());
1135
+ }
1136
+ /** Textos de estado configuráveis por atributo (carregando, sem resultados, erro). */
1137
+ atualizarTextosEstado() {
1138
+ var i;
1139
+ const e = (i = this._loadingElement) == null ? void 0 : i.querySelector(".ui-tabela__loading-texto");
1140
+ e && (e.textContent = this.getAttribute("texto-carregando") || "Carregando dados..."), this.renderizarErro();
1141
+ }
1142
+ /** Mostra (ou oculta, com null) o aviso de erro de carregamento com a ação "Tentar novamente". */
1143
+ mostrarErro(e) {
1144
+ this._erro = e, this.renderizarErro();
1145
+ }
1146
+ renderizarErro() {
1147
+ Ge(this._erroElement, this._erro, this.getAttribute("texto-erro"), !!this._src);
1148
+ }
1149
+ /** Anuncia ao leitor de tela o resultado do filtro (a região é limpa sem filtro ativo). */
1150
+ anunciarResultado() {
1151
+ Je(
1152
+ this._anuncioElement,
1153
+ this.dadosController.getDadosExibicao().length,
1154
+ this.dadosController.temFiltro(),
1155
+ this._textoSemResultados()
1156
+ );
1157
+ }
1158
+ _textoSemResultados() {
1159
+ return this.getAttribute("texto-sem-resultados") || Xe;
1160
+ }
1161
+ syncAttributes() {
1162
+ ee(this.obterContextoAtributos());
1163
+ }
1164
+ obterContextoAtributos() {
1165
+ return {
1166
+ host: this,
1167
+ containerElement: this._containerElement,
1168
+ emptyElement: this._emptyElement,
1169
+ loadingElement: this._loadingElement,
1170
+ onTextoVazioAlterado: (e) => {
1171
+ this._textoVazio = e;
1172
+ },
1173
+ onVirtualizarAlterado: (e) => {
1174
+ this._virtualizar = e;
1175
+ },
1176
+ onSrcLido: (e) => {
1177
+ this._src = e;
1178
+ },
1179
+ onCarregarSrc: (e) => {
1180
+ this.remotaController.carregar(e);
1181
+ },
1182
+ onCarregandoAlterado: (e) => {
1183
+ this._carregando = e;
1184
+ },
1185
+ onRenderBody: () => this.renderBody(),
1186
+ onRenderTotal: () => this.renderTotal()
1187
+ };
1188
+ }
1189
+ get src() {
1190
+ return this._src;
1191
+ }
1192
+ set src(e) {
1193
+ this._src = e, e ? this.setAttribute("src", e) : this.removeAttribute("src");
1194
+ }
1195
+ get carregando() {
1196
+ return this._carregando;
1197
+ }
1198
+ set carregando(e) {
1199
+ this._carregando = !!e, this._carregando ? this.setAttribute("carregando", "") : (this.removeAttribute("carregando"), this.removeAttribute("loading")), this._loadingElement && (this._loadingElement.style.display = this._carregando ? "flex" : "none"), this.sincronizarAria();
1200
+ }
1201
+ /** Opções do `fetch` do modo remoto (headers, credentials, method, body...); o `signal` é da tabela. */
1202
+ get fetchOpcoes() {
1203
+ return this._fetchOpcoes;
1204
+ }
1205
+ set fetchOpcoes(e) {
1206
+ this._fetchOpcoes = e ?? null;
1207
+ }
1208
+ /** Função de busca alternativa ao `fetch` (autenticação, renovação de token, mocks). */
1209
+ get fetcher() {
1210
+ return this._fetcher;
1211
+ }
1212
+ set fetcher(e) {
1213
+ this._fetcher = typeof e == "function" ? e : null;
1214
+ }
1215
+ /** Ordenação feita pelo servidor: o clique no cabeçalho atualiza o indicador e emite `ui-sort`, mas não reordena. */
1216
+ get ordenacaoRemota() {
1217
+ return this.hasAttribute("ordenacao-remota");
1218
+ }
1219
+ set ordenacaoRemota(e) {
1220
+ this.toggleAttribute("ordenacao-remota", !!e);
1221
+ }
1222
+ /** Busca a URL (guardada como `src`, para `recarregar()`). Resolve `true` em sucesso; falhas vão em `ui-fetch-erro`. */
1223
+ async carregarDoEndpoint(e) {
1224
+ return e && e !== this._src && (this.src = e), this.remotaController.carregar(e || this._src || "");
1225
+ }
1226
+ async recarregar() {
1227
+ return this._src ? this.remotaController.carregar(this._src) : (this.dadosController.aplicarOrdenacao(), this.atualizarContextoSelecao(), this.renderBody(), !0);
1228
+ }
1229
+ filtrar(e) {
1230
+ this.dadosController.filtrar(e), this.atualizarContextoSelecao(), this.renderBody();
1231
+ }
1232
+ cleanupEventListeners() {
1233
+ this._containerElement && this._scrollHandler && (this._containerElement.removeEventListener("scroll", this._scrollHandler), this._scrollHandler = null), this._activeResizeCleanup && (this._activeResizeCleanup(), this._activeResizeCleanup = null, this._isResizing = !1), this.rolagem.cancelar(), this.remotaController.abortar(), this._headerListeners.cleanup(), this._corpoListeners.cleanup();
1234
+ }
1235
+ get colunas() {
1236
+ return this._colunas;
1237
+ }
1238
+ set colunas(e) {
1239
+ this._colunas = Array.isArray(e) ? e.filter((i) => i != null).map((i) => ({ ...i })) : [], this.dadosController.setColunas(this._colunas), this.dadosController.setColunasFiltro(this._colunas.map((i) => i.id)), this._alturaLinhaMedida = null, this.renderTotal();
1240
+ }
1241
+ get dados() {
1242
+ return this.dadosController.getDadosOriginais();
1243
+ }
1244
+ set dados(e) {
1245
+ this.dadosController.setDadosOriginais(e), this.atualizarContextoSelecao(), this.renderBody();
1246
+ }
1247
+ get itens() {
1248
+ return this.dados;
1249
+ }
1250
+ set itens(e) {
1251
+ this.dados = e;
1252
+ }
1253
+ get chaveId() {
1254
+ return this.getAttribute("chave-id") || this.getAttribute("id-key") || "id";
1255
+ }
1256
+ set chaveId(e) {
1257
+ e ? this.setAttribute("chave-id", e) : (this.removeAttribute("chave-id"), this.removeAttribute("id-key")), this.atualizarContextoSelecao();
1258
+ }
1259
+ get itemSelecionado() {
1260
+ return this.selecaoController.getItemSelecionado();
1261
+ }
1262
+ set itemSelecionado(e) {
1263
+ this.selecaoController.setItemSelecionado(e);
1264
+ }
1265
+ get indiceSelecionado() {
1266
+ return this.selecaoController.getIndiceSelecionado();
1267
+ }
1268
+ set indiceSelecionado(e) {
1269
+ this.selecaoController.setIndiceSelecionado(e);
1270
+ }
1271
+ limparSelecao() {
1272
+ this.selecaoController.limparSelecao();
1273
+ }
1274
+ get densidade() {
1275
+ const e = this.getAttribute("densidade") || this.getAttribute("density");
1276
+ return e === "compacta" || e === "compact" ? "compacta" : e === "relaxada" || e === "relaxed" ? "relaxada" : "normal";
1277
+ }
1278
+ set densidade(e) {
1279
+ e ? this.setAttribute("densidade", e) : (this.removeAttribute("densidade"), this.removeAttribute("density")), this.renderBody();
1280
+ }
1281
+ get virtualizar() {
1282
+ return this._virtualizar;
1283
+ }
1284
+ set virtualizar(e) {
1285
+ this._virtualizar = !!e, e ? this.setAttribute("virtualizar", "true") : this.removeAttribute("virtualizar"), this.renderTotal();
1286
+ }
1287
+ get colunaOrdenada() {
1288
+ return this.dadosController.getColunaOrdenada();
1289
+ }
1290
+ set colunaOrdenada(e) {
1291
+ this.dadosController.setColunaOrdenada(e), this.atualizarContextoSelecao(), this.renderHeader(), this.renderBody();
1292
+ }
1293
+ get direcaoOrdenacao() {
1294
+ return this.dadosController.getDirecaoOrdenacao();
1295
+ }
1296
+ set direcaoOrdenacao(e) {
1297
+ this.dadosController.setDirecaoOrdenacao(e), this.atualizarContextoSelecao(), this.renderHeader(), this.renderBody();
1298
+ }
1299
+ get textoVazio() {
1300
+ return this._textoVazio;
1301
+ }
1302
+ set textoVazio(e) {
1303
+ this._textoVazio = e || "Nenhum registro encontrado", this.renderTotal();
1304
+ }
1305
+ handleHeaderClick(e) {
1306
+ if (!e.ordenavel || this._isResizing) return;
1307
+ const i = this.dadosController.getColunaOrdenada(), r = this.dadosController.getDirecaoOrdenacao(), o = this.dadosController.alternarOrdenacaoColuna(e);
1308
+ if (!o) return;
1309
+ this.atualizarContextoSelecao(), this.renderHeader(), this.renderBody();
1310
+ const n = new CustomEvent("ui-sort", { detail: o, bubbles: !0, composed: !0, cancelable: !0 });
1311
+ this.dispatchEvent(n), n.defaultPrevented && (this.dadosController.restaurarOrdenacao(i, r), this.atualizarContextoSelecao(), this.renderHeader(), this.renderBody());
1312
+ }
1313
+ /** Altura fixa das linhas em px (`altura-linha`), sobrepõe a densidade; null = vale a densidade. */
1314
+ get alturaLinha() {
1315
+ const e = this.getAttribute("altura-linha") ?? this.getAttribute("row-height"), i = e === null ? NaN : parseFloat(e);
1316
+ return Number.isFinite(i) && i > 0 ? i : null;
1317
+ }
1318
+ set alturaLinha(e) {
1319
+ e && e > 0 ? this.setAttribute("altura-linha", String(e)) : (this.removeAttribute("altura-linha"), this.removeAttribute("row-height"));
1320
+ }
1321
+ /** Publica a altura fixa como variável CSS (usada pelo estilo `:host([altura-linha])`). */
1322
+ aplicarAlturaLinha() {
1323
+ const e = this.alturaLinha;
1324
+ e ? this.style.setProperty("--ui-tabela-altura-linha", `${e}px`) : this.style.removeProperty("--ui-tabela-altura-linha"), this.renderBody();
1325
+ }
1326
+ /** Altura usada na virtualização: a fixa (`altura-linha`), a medida no DOM ou a estimativa da densidade. */
1327
+ getRowHeight() {
1328
+ return this.alturaLinha ?? this._alturaLinhaMedida ?? V(this.densidade);
1329
+ }
1330
+ /**
1331
+ * Mede a altura real das linhas uma vez por configuração (densidade/colunas): padding, fonte e
1332
+ * renderizadores customizados mudam a altura, e a estimativa fixa desalinharia a janela virtual.
1333
+ * Não remede a cada rolagem para os espaçadores não "pularem" com linhas de alturas diferentes.
1334
+ */
1335
+ medirAlturaLinha() {
1336
+ if (this._alturaLinhaMedida !== null || !this._tbodyElement) return;
1337
+ const e = this._tbodyElement.querySelectorAll("tr[data-index]");
1338
+ if (e.length === 0) return;
1339
+ let i = 0;
1340
+ e.forEach((o) => {
1341
+ i += o.getBoundingClientRect().height;
1342
+ });
1343
+ const r = i / e.length;
1344
+ r <= 0 || (this._alturaLinhaMedida = r, Math.abs(r - V(this.densidade)) > 0.5 && this.renderBody());
1345
+ }
1346
+ /** Ordenar, filtrar, trocar os dados ou a chave mantém a linha selecionada (se ainda existir). */
1347
+ atualizarContextoSelecao() {
1348
+ this.selecaoController.reconciliar(), this._indiceAtivo = this.selecaoController.getIndiceSelecionado();
1349
+ }
1350
+ renderTotal() {
1351
+ var e;
1352
+ if (this.shadow) {
1353
+ if (this._containerElement) {
1354
+ if (this._containerElement.style.maxHeight = this.getAttribute("max-height") || "", this._emptyElement) {
1355
+ const i = this._emptyElement.querySelector(".ui-tabela__empty-text");
1356
+ i && (i.textContent = this._textoVazio);
1357
+ }
1358
+ } else {
1359
+ this.cleanupEventListeners();
1360
+ const i = Ve(this.shadow, this._textoVazio, this.getAttribute("max-height"), this._carregando);
1361
+ this._containerElement = i.containerElement, this._tableElement = i.tableElement, this._colgroupElement = i.colgroupElement, this._theadElement = i.theadElement, this._tbodyElement = i.tbodyElement, this._emptyElement = i.emptyElement, this._loadingElement = i.loadingElement, this._erroElement = i.erroElement, this._anuncioElement = i.anuncioElement, (e = i.erroElement.querySelector(".ui-tabela__erro-acao")) == null || e.addEventListener("click", () => {
1362
+ this.recarregar();
1363
+ });
1364
+ }
1365
+ B(this, this._containerElement), this.renderHeader(), this.renderBody(), this._virtualizar && this._containerElement && !this._scrollHandler && (this._scrollHandler = qe(this._containerElement, () => this.renderBody("rolagem"))), this._tbodyElement && this._corpoListeners.size === 0 && (this._corpoListeners.add(this._tbodyElement, "keydown", this.handleTecladoCorpo), this._corpoListeners.add(this._tbodyElement, "focusin", this.handleFocoLinha)), this.sincronizarAria();
1366
+ }
1367
+ }
1368
+ definirLinhaAtiva(e) {
1369
+ this._indiceAtivo = e;
1370
+ const i = this._tbodyElement, r = i == null ? void 0 : i.querySelector(`tr[data-index="${e}"]`);
1371
+ !i || !r || (i.querySelectorAll('tr[tabindex="0"]').forEach((o) => {
1372
+ o !== r && (o.tabIndex = -1);
1373
+ }), r.tabIndex = 0);
1374
+ }
1375
+ obterContextoRenderizador(e = "completo") {
1376
+ return {
1377
+ modoCorpo: e,
1378
+ host: this,
1379
+ shadow: this.shadow,
1380
+ theadElement: this._theadElement,
1381
+ colgroupElement: this._colgroupElement,
1382
+ tbodyElement: this._tbodyElement,
1383
+ tableElement: this._tableElement,
1384
+ emptyElement: this._emptyElement,
1385
+ containerElement: this._containerElement,
1386
+ colunas: this._colunas,
1387
+ dadosController: this.dadosController,
1388
+ selecaoController: this.selecaoController,
1389
+ chaveId: this.chaveId,
1390
+ virtualizar: this._virtualizar,
1391
+ rowHeight: this.getRowHeight(),
1392
+ indiceAtivo: this._indiceAtivo,
1393
+ textoVazio: this._textoVazio,
1394
+ textoSemResultados: this._textoSemResultados(),
1395
+ headerListeners: this._headerListeners,
1396
+ onSetIsResizing: (i) => {
1397
+ this._isResizing = i;
1398
+ },
1399
+ onActiveResizeCleanup: (i) => {
1400
+ this._activeResizeCleanup = i;
1401
+ },
1402
+ onHeaderClick: (i) => this.handleHeaderClick(i)
1403
+ };
1404
+ }
1405
+ renderHeader() {
1406
+ Be(this.obterContextoRenderizador());
1407
+ }
1408
+ /**
1409
+ * Renderiza o corpo. `completo` (padrão) recria as linhas e roda o `render` das colunas de novo;
1410
+ * `rolagem` só ajusta a janela virtual e mantém as linhas que continuam visíveis (foco e texto digitado intactos).
1411
+ */
1412
+ renderBody(e = "completo") {
1413
+ Pe(this.obterContextoRenderizador(e)), this.anunciarResultado(), this.medirAlturaLinha();
1414
+ }
1415
+ /**
1416
+ * Rola até um item e opcionalmente o seleciona. Aceita ID (pela `chave-id`, depois `id`, `_id`,
1417
+ * `codigo`, `key`), predicado ou índice. Um número é procurado primeiro como ID; use
1418
+ * `{ porIndice: true }` ou `rolarParaIndice()` para tratá-lo só como índice da linha exibida.
1419
+ */
1420
+ rolarPara(e, i) {
1421
+ return this.selecaoController.rolarPara(e, i);
1422
+ }
1423
+ /** Rola até a linha exibida de índice `indice` (posição após ordenação/filtro, base 0). */
1424
+ rolarParaIndice(e, i) {
1425
+ return this.selecaoController.rolarPara(e, { ...i, porIndice: !0 });
1426
+ }
1427
+ }
1428
+ ie("ui-tabela", Ze);
1429
+ export {
1430
+ We as A,
1431
+ fe as T,
1432
+ Ze as U,
1433
+ se as a,
1434
+ ue as b,
1435
+ Fe as c,
1436
+ he as d,
1437
+ be as e,
1438
+ Pe as f,
1439
+ Be as g,
1440
+ He as h,
1441
+ $e as i,
1442
+ Ne as j,
1443
+ G as k,
1444
+ J as l,
1445
+ V as m,
1446
+ Y as n,
1447
+ qe as o,
1448
+ Me as p,
1449
+ P as q,
1450
+ H as r,
1451
+ ce as s,
1452
+ ve as t,
1453
+ D as u,
1454
+ Ve as v,
1455
+ ke as w,
1456
+ Ie as x,
1457
+ _e as y,
1458
+ ee as z
1459
+ };