@wgalleti/primevue-components 0.3.4

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 (85) hide show
  1. package/README.md +218 -0
  2. package/dist/components/crud/WCrudColumnRenderer.vue.d.ts +8 -0
  3. package/dist/components/crud/WCrudFormDialog.vue.d.ts +214 -0
  4. package/dist/components/crud/WCrudView.vue.d.ts +89 -0
  5. package/dist/components/form/WAutoCompleteFK.vue.d.ts +43 -0
  6. package/dist/components/form/WFormRenderer.vue.d.ts +41 -0
  7. package/dist/components/form/WMoneyInput.vue.d.ts +28 -0
  8. package/dist/components/form/WTransferList.vue.d.ts +25 -0
  9. package/dist/components/index.d.ts +18 -0
  10. package/dist/components/ui/WActionBar.vue.d.ts +27 -0
  11. package/dist/components/ui/WDetailHeader.vue.d.ts +29 -0
  12. package/dist/components/ui/WEmptyState.vue.d.ts +13 -0
  13. package/dist/components/ui/WFormSection.vue.d.ts +23 -0
  14. package/dist/components/ui/WInfoCard.vue.d.ts +11 -0
  15. package/dist/components/ui/WKpiCard.vue.d.ts +33 -0
  16. package/dist/components/ui/WKpiGrid.vue.d.ts +31 -0
  17. package/dist/components/ui/WPageHeader.vue.d.ts +27 -0
  18. package/dist/components/ui/WProgressFlow.vue.d.ts +33 -0
  19. package/dist/components/ui/WSectionHeader.vue.d.ts +25 -0
  20. package/dist/components/ui/WStatusTag.vue.d.ts +10 -0
  21. package/dist/composables/index.d.ts +6 -0
  22. package/dist/composables/useApi.d.ts +2 -0
  23. package/dist/composables/useApiError.d.ts +4 -0
  24. package/dist/composables/useAppConfirm.d.ts +4 -0
  25. package/dist/composables/useAppToast.d.ts +6 -0
  26. package/dist/composables/useCrudManager.d.ts +2 -0
  27. package/dist/composables/useFormatters.d.ts +19 -0
  28. package/dist/data-providers/axiosDataProvider.d.ts +3 -0
  29. package/dist/data-providers/index.d.ts +2 -0
  30. package/dist/data-providers/supabaseDataProvider.d.ts +54 -0
  31. package/dist/index.cjs +11 -0
  32. package/dist/index.cjs.map +1 -0
  33. package/dist/index.d.ts +11 -0
  34. package/dist/index.js +3287 -0
  35. package/dist/index.js.map +1 -0
  36. package/dist/plugin.d.ts +2 -0
  37. package/dist/primevue-components.css +1 -0
  38. package/dist/types/api.d.ts +60 -0
  39. package/dist/types/components/crud/WCrudColumnRenderer.vue.d.ts +8 -0
  40. package/dist/types/components/crud/WCrudFormDialog.vue.d.ts +49 -0
  41. package/dist/types/components/crud/WCrudView.vue.d.ts +103 -0
  42. package/dist/types/components/form/WAutoCompleteFK.vue.d.ts +43 -0
  43. package/dist/types/components/form/WFormRenderer.vue.d.ts +40 -0
  44. package/dist/types/components/form/WMoneyInput.vue.d.ts +28 -0
  45. package/dist/types/components/form/WTransferList.vue.d.ts +25 -0
  46. package/dist/types/components/index.d.ts +18 -0
  47. package/dist/types/components/ui/WActionBar.vue.d.ts +25 -0
  48. package/dist/types/components/ui/WDetailHeader.vue.d.ts +24 -0
  49. package/dist/types/components/ui/WEmptyState.vue.d.ts +13 -0
  50. package/dist/types/components/ui/WFormSection.vue.d.ts +19 -0
  51. package/dist/types/components/ui/WInfoCard.vue.d.ts +11 -0
  52. package/dist/types/components/ui/WKpiCard.vue.d.ts +32 -0
  53. package/dist/types/components/ui/WKpiGrid.vue.d.ts +26 -0
  54. package/dist/types/components/ui/WPageHeader.vue.d.ts +22 -0
  55. package/dist/types/components/ui/WProgressFlow.vue.d.ts +28 -0
  56. package/dist/types/components/ui/WSectionHeader.vue.d.ts +22 -0
  57. package/dist/types/components/ui/WStatusTag.vue.d.ts +10 -0
  58. package/dist/types/composables/index.d.ts +6 -0
  59. package/dist/types/composables/useApi.d.ts +2 -0
  60. package/dist/types/composables/useApiError.d.ts +4 -0
  61. package/dist/types/composables/useAppConfirm.d.ts +4 -0
  62. package/dist/types/composables/useAppToast.d.ts +6 -0
  63. package/dist/types/composables/useCrudManager.d.ts +2 -0
  64. package/dist/types/composables/useFormatters.d.ts +19 -0
  65. package/dist/types/crud.d.ts +184 -0
  66. package/dist/types/data-providers/axiosDataProvider.d.ts +3 -0
  67. package/dist/types/data-providers/index.d.ts +2 -0
  68. package/dist/types/data-providers/supabaseDataProvider.d.ts +54 -0
  69. package/dist/types/dataProvider.d.ts +28 -0
  70. package/dist/types/index.d.ts +12 -0
  71. package/dist/types/plugin.d.ts +2 -0
  72. package/dist/types/types/api.d.ts +60 -0
  73. package/dist/types/types/crud.d.ts +184 -0
  74. package/dist/types/types/dataProvider.d.ts +28 -0
  75. package/dist/types/types/index.d.ts +6 -0
  76. package/dist/types/types/plugin.d.ts +24 -0
  77. package/dist/types/utils/cep.d.ts +14 -0
  78. package/dist/types/utils/dates.d.ts +5 -0
  79. package/dist/types/utils/fieldMapper.d.ts +20 -0
  80. package/dist/types/utils/masks.d.ts +8 -0
  81. package/dist/utils/cep.d.ts +14 -0
  82. package/dist/utils/dates.d.ts +5 -0
  83. package/dist/utils/fieldMapper.d.ts +20 -0
  84. package/dist/utils/masks.d.ts +8 -0
  85. package/package.json +78 -0
package/dist/index.js ADDED
@@ -0,0 +1,3287 @@
1
+ import { inject as Ie, defineComponent as re, openBlock as s, createElementBlock as c, createBlock as I, unref as g, toDisplayString as R, ref as K, watch as ot, computed as q, reactive as ve, resolveDirective as yt, Fragment as le, createElementVNode as v, createVNode as W, withDirectives as Pe, withCtx as te, createCommentVNode as S, renderList as se, normalizeStyle as Be, createTextVNode as xe, normalizeClass as ue, renderSlot as O, isRef as Wt, withModifiers as Ot, createSlots as nt, normalizeProps as lt, guardReactiveProps as st, useSlots as Bt, onMounted as jt, createStaticVNode as Ut } from "vue";
2
+ import bt from "primevue/datatable";
3
+ import Le from "primevue/column";
4
+ import oe from "primevue/button";
5
+ import ce from "primevue/inputtext";
6
+ import Ue from "primevue/iconfield";
7
+ import _e from "primevue/inputicon";
8
+ import _t from "primevue/paginator";
9
+ import wt from "primevue/tag";
10
+ import Re from "dayjs";
11
+ import kt from "primevue/dialog";
12
+ import ut from "primevue/inputnumber";
13
+ import qt from "primevue/textarea";
14
+ import Ht from "primevue/select";
15
+ import $t from "primevue/autocomplete";
16
+ import dt from "primevue/datepicker";
17
+ import Kt from "primevue/toggleswitch";
18
+ import Gt from "primevue/colorpicker";
19
+ import Jt from "primevue/password";
20
+ import { useToast as Zt } from "primevue/usetoast";
21
+ import { useConfirm as Xt } from "primevue/useconfirm";
22
+ import Qt from "primevue/inputgroup";
23
+ import ct from "primevue/inputgroupaddon";
24
+ import Ke from "primevue/skeleton";
25
+ const ea = Symbol("w-axios"), Qe = Symbol("w-data-provider"), et = Symbol("w-config");
26
+ function ta(e) {
27
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
28
+ }
29
+ var Je = { exports: {} }, aa = Je.exports, ft;
30
+ function oa() {
31
+ return ft || (ft = 1, (function(e, t) {
32
+ (function(a, o) {
33
+ e.exports = o();
34
+ })(aa, (function() {
35
+ var a = { LTS: "h:mm:ss A", LT: "h:mm A", L: "MM/DD/YYYY", LL: "MMMM D, YYYY", LLL: "MMMM D, YYYY h:mm A", LLLL: "dddd, MMMM D, YYYY h:mm A" }, o = /(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g, l = /\d/, r = /\d\d/, i = /\d\d?/, y = /\d*[^-_:/,()\s\d]+/, u = {}, k = function(f) {
36
+ return (f = +f) + (f > 68 ? 1900 : 2e3);
37
+ }, M = function(f) {
38
+ return function(b) {
39
+ this[f] = +b;
40
+ };
41
+ }, P = [/[+-]\d\d:?(\d\d)?|Z/, function(f) {
42
+ (this.zone || (this.zone = {})).offset = (function(b) {
43
+ if (!b || b === "Z") return 0;
44
+ var $ = b.match(/([+-]|\d\d)/g), V = 60 * $[1] + (+$[2] || 0);
45
+ return V === 0 ? 0 : $[0] === "+" ? -V : V;
46
+ })(f);
47
+ }], B = function(f) {
48
+ var b = u[f];
49
+ return b && (b.indexOf ? b : b.s.concat(b.f));
50
+ }, Y = function(f, b) {
51
+ var $, V = u.meridiem;
52
+ if (V) {
53
+ for (var T = 1; T <= 24; T += 1) if (f.indexOf(V(T, 0, b)) > -1) {
54
+ $ = T > 12;
55
+ break;
56
+ }
57
+ } else $ = f === (b ? "pm" : "PM");
58
+ return $;
59
+ }, G = { A: [y, function(f) {
60
+ this.afternoon = Y(f, !1);
61
+ }], a: [y, function(f) {
62
+ this.afternoon = Y(f, !0);
63
+ }], Q: [l, function(f) {
64
+ this.month = 3 * (f - 1) + 1;
65
+ }], S: [l, function(f) {
66
+ this.milliseconds = 100 * +f;
67
+ }], SS: [r, function(f) {
68
+ this.milliseconds = 10 * +f;
69
+ }], SSS: [/\d{3}/, function(f) {
70
+ this.milliseconds = +f;
71
+ }], s: [i, M("seconds")], ss: [i, M("seconds")], m: [i, M("minutes")], mm: [i, M("minutes")], H: [i, M("hours")], h: [i, M("hours")], HH: [i, M("hours")], hh: [i, M("hours")], D: [i, M("day")], DD: [r, M("day")], Do: [y, function(f) {
72
+ var b = u.ordinal, $ = f.match(/\d+/);
73
+ if (this.day = $[0], b) for (var V = 1; V <= 31; V += 1) b(V).replace(/\[|\]/g, "") === f && (this.day = V);
74
+ }], w: [i, M("week")], ww: [r, M("week")], M: [i, M("month")], MM: [r, M("month")], MMM: [y, function(f) {
75
+ var b = B("months"), $ = (B("monthsShort") || b.map((function(V) {
76
+ return V.slice(0, 3);
77
+ }))).indexOf(f) + 1;
78
+ if ($ < 1) throw new Error();
79
+ this.month = $ % 12 || $;
80
+ }], MMMM: [y, function(f) {
81
+ var b = B("months").indexOf(f) + 1;
82
+ if (b < 1) throw new Error();
83
+ this.month = b % 12 || b;
84
+ }], Y: [/[+-]?\d+/, M("year")], YY: [r, function(f) {
85
+ this.year = k(f);
86
+ }], YYYY: [/\d{4}/, M("year")], Z: P, ZZ: P };
87
+ function Z(f) {
88
+ var b, $;
89
+ b = f, $ = u && u.formats;
90
+ for (var V = (f = b.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g, (function(A, L, X) {
91
+ var d = X && X.toUpperCase();
92
+ return L || $[X] || a[X] || $[d].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g, (function(E, F, n) {
93
+ return F || n.slice(1);
94
+ }));
95
+ }))).match(o), T = V.length, j = 0; j < T; j += 1) {
96
+ var w = V[j], h = G[w], U = h && h[0], m = h && h[1];
97
+ V[j] = m ? { regex: U, parser: m } : w.replace(/^\[|\]$/g, "");
98
+ }
99
+ return function(A) {
100
+ for (var L = {}, X = 0, d = 0; X < T; X += 1) {
101
+ var E = V[X];
102
+ if (typeof E == "string") d += E.length;
103
+ else {
104
+ var F = E.regex, n = E.parser, p = A.slice(d), J = F.exec(p)[0];
105
+ n.call(L, J), A = A.replace(J, "");
106
+ }
107
+ }
108
+ return (function(ne) {
109
+ var Q = ne.afternoon;
110
+ if (Q !== void 0) {
111
+ var _ = ne.hours;
112
+ Q ? _ < 12 && (ne.hours += 12) : _ === 12 && (ne.hours = 0), delete ne.afternoon;
113
+ }
114
+ })(L), L;
115
+ };
116
+ }
117
+ return function(f, b, $) {
118
+ $.p.customParseFormat = !0, f && f.parseTwoDigitYear && (k = f.parseTwoDigitYear);
119
+ var V = b.prototype, T = V.parse;
120
+ V.parse = function(j) {
121
+ var w = j.date, h = j.utc, U = j.args;
122
+ this.$u = h;
123
+ var m = U[1];
124
+ if (typeof m == "string") {
125
+ var A = U[2] === !0, L = U[3] === !0, X = A || L, d = U[2];
126
+ L && (d = U[2]), u = this.$locale(), !A && d && (u = $.Ls[d]), this.$d = (function(p, J, ne, Q) {
127
+ try {
128
+ if (["x", "X"].indexOf(J) > -1) return new Date((J === "X" ? 1e3 : 1) * p);
129
+ var _ = Z(J)(p), de = _.year, me = _.month, Ne = _.day, Ye = _.hours, ge = _.minutes, fe = _.seconds, he = _.milliseconds, pe = _.zone, ye = _.week, Ee = /* @__PURE__ */ new Date(), be = Ne || (de || me ? 1 : Ee.getDate()), Me = de || Ee.getFullYear(), $e = 0;
130
+ de && !me || ($e = me > 0 ? me - 1 : Ee.getMonth());
131
+ var De, Fe = Ye || 0, Ce = ge || 0, Ae = fe || 0, D = he || 0;
132
+ return pe ? new Date(Date.UTC(Me, $e, be, Fe, Ce, Ae, D + 60 * pe.offset * 1e3)) : ne ? new Date(Date.UTC(Me, $e, be, Fe, Ce, Ae, D)) : (De = new Date(Me, $e, be, Fe, Ce, Ae, D), ye && (De = Q(De).week(ye).toDate()), De);
133
+ } catch {
134
+ return /* @__PURE__ */ new Date("");
135
+ }
136
+ })(w, m, h, $), this.init(), d && d !== !0 && (this.$L = this.locale(d).$L), X && w != this.format(m) && (this.$d = /* @__PURE__ */ new Date("")), u = {};
137
+ } else if (m instanceof Array) for (var E = m.length, F = 1; F <= E; F += 1) {
138
+ U[1] = m[F - 1];
139
+ var n = $.apply(this, U);
140
+ if (n.isValid()) {
141
+ this.$d = n.$d, this.$L = n.$L, this.init();
142
+ break;
143
+ }
144
+ F === E && (this.$d = /* @__PURE__ */ new Date(""));
145
+ }
146
+ else T.call(this, j);
147
+ };
148
+ };
149
+ }));
150
+ })(Je)), Je.exports;
151
+ }
152
+ var na = oa();
153
+ const la = /* @__PURE__ */ ta(na);
154
+ Re.extend(la);
155
+ function Dt(e) {
156
+ if (!e) return null;
157
+ if (e instanceof Date) return e;
158
+ const t = Re(e, "YYYY-MM-DD", !0);
159
+ return t.isValid() ? t.toDate() : Re(e).toDate();
160
+ }
161
+ function Ct(e) {
162
+ return e ? typeof e == "string" ? e : Re(e).format("YYYY-MM-DD") : null;
163
+ }
164
+ function St(e) {
165
+ return e ? typeof e == "string" ? e : Re(e).toISOString() : null;
166
+ }
167
+ function sa(e, t = "DD/MM/YYYY") {
168
+ return e ? Re(e).format(t) : "—";
169
+ }
170
+ function ra(e) {
171
+ return e ? Re(e).format("DD/MM/YYYY HH:mm") : "—";
172
+ }
173
+ function Ve(e) {
174
+ return e.replace(/\D/g, "");
175
+ }
176
+ function Pt(e) {
177
+ if (!e) return "—";
178
+ const t = Ve(e);
179
+ return t.length !== 11 ? e : t.replace(/^(\d{3})(\d{3})(\d{3})(\d{2})$/, "$1.$2.$3-$4");
180
+ }
181
+ function xt(e) {
182
+ if (!e) return "—";
183
+ const t = Ve(e);
184
+ return t.length !== 14 ? e : t.replace(
185
+ /^(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/,
186
+ "$1.$2.$3/$4-$5"
187
+ );
188
+ }
189
+ function ia(e) {
190
+ if (!e) return "—";
191
+ const t = Ve(e);
192
+ return t.length === 11 ? Pt(e) : t.length === 14 ? xt(e) : e;
193
+ }
194
+ function ua(e) {
195
+ if (!e) return "—";
196
+ const t = Ve(e);
197
+ return t.length === 11 ? t.replace(/^(\d{2})(\d{5})(\d{4})$/, "($1) $2-$3") : t.length === 10 ? t.replace(/^(\d{2})(\d{4})(\d{4})$/, "($1) $2-$3") : e;
198
+ }
199
+ function Vt(e) {
200
+ if (!e) return null;
201
+ const t = Ve(e);
202
+ if (t.length !== 11) return "CPF deve ter 11 dígitos.";
203
+ if (/^(\d)\1{10}$/.test(t)) return "CPF inválido.";
204
+ let a = 0;
205
+ for (let i = 0; i < 9; i++) a += parseInt(t[i]) * (10 - i);
206
+ let o = a % 11;
207
+ const l = o < 2 ? 0 : 11 - o;
208
+ if (parseInt(t[9]) !== l) return "CPF inválido.";
209
+ a = 0;
210
+ for (let i = 0; i < 10; i++) a += parseInt(t[i]) * (11 - i);
211
+ o = a % 11;
212
+ const r = o < 2 ? 0 : 11 - o;
213
+ return parseInt(t[10]) !== r ? "CPF inválido." : null;
214
+ }
215
+ function Et(e) {
216
+ if (!e) return null;
217
+ const t = Ve(e);
218
+ if (t.length !== 14) return "CNPJ deve ter 14 dígitos.";
219
+ if (/^(\d)\1{13}$/.test(t)) return "CNPJ inválido.";
220
+ const a = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
221
+ let o = 0;
222
+ for (let u = 0; u < 12; u++) o += parseInt(t[u]) * a[u];
223
+ let l = o % 11;
224
+ const r = l < 2 ? 0 : 11 - l;
225
+ if (parseInt(t[12]) !== r) return "CNPJ inválido.";
226
+ const i = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
227
+ o = 0;
228
+ for (let u = 0; u < 13; u++) o += parseInt(t[u]) * i[u];
229
+ l = o % 11;
230
+ const y = l < 2 ? 0 : 11 - l;
231
+ return parseInt(t[13]) !== y ? "CNPJ inválido." : null;
232
+ }
233
+ function da(e) {
234
+ if (!e) return null;
235
+ const t = Ve(e);
236
+ return t.length === 11 ? Vt(e) : t.length === 14 ? Et(e) : "CPF deve ter 11 dígitos ou CNPJ deve ter 14 dígitos.";
237
+ }
238
+ const Ze = /* @__PURE__ */ new Map();
239
+ function mt(e, t) {
240
+ const a = `${e}-${t}`;
241
+ let o = Ze.get(a);
242
+ return o || (o = new Intl.NumberFormat(e, {
243
+ minimumFractionDigits: t,
244
+ maximumFractionDigits: t
245
+ }), Ze.set(a, o)), o;
246
+ }
247
+ function ca(e, t) {
248
+ const a = `${e}-${t}`;
249
+ let o = Ze.get(a);
250
+ return o || (o = new Intl.NumberFormat(e, {
251
+ style: "currency",
252
+ currency: t
253
+ }), Ze.set(a, o)), o;
254
+ }
255
+ function rt() {
256
+ const e = Ie(et, {
257
+ defaultPageSize: 20,
258
+ dateFormat: "DD/MM/YYYY",
259
+ dateTimeFormat: "DD/MM/YYYY HH:mm",
260
+ locale: "pt-BR",
261
+ currency: "BRL"
262
+ }), t = (e == null ? void 0 : e.locale) ?? "pt-BR", a = (e == null ? void 0 : e.currency) ?? "BRL";
263
+ function o(u) {
264
+ return u == null ? "—" : ca(t, a).format(u);
265
+ }
266
+ function l(u, k = 2) {
267
+ return u == null ? "—" : mt(t, k).format(u);
268
+ }
269
+ function r(u, k) {
270
+ return sa(u, k ?? (e == null ? void 0 : e.dateFormat) ?? "DD/MM/YYYY");
271
+ }
272
+ function i(u) {
273
+ return ra(u);
274
+ }
275
+ function y(u) {
276
+ return u == null ? "—" : `${mt(t, 2).format(u)}%`;
277
+ }
278
+ return {
279
+ formatCurrency: o,
280
+ formatNumber: l,
281
+ formatDate: r,
282
+ formatDateTime: i,
283
+ formatPercent: y,
284
+ formatCpf: Pt,
285
+ formatCnpj: xt,
286
+ formatCpfCnpj: ia,
287
+ formatTelefone: ua,
288
+ validateCpf: Vt,
289
+ validateCnpj: Et,
290
+ validateCpfCnpj: da,
291
+ parseDate: Dt,
292
+ toDateString: Ct,
293
+ toDateTimeString: St
294
+ };
295
+ }
296
+ const fa = {
297
+ key: 0,
298
+ class: "text-muted-color text-xs"
299
+ }, ma = ["src", "alt"], pa = {
300
+ key: 3,
301
+ class: "text-muted-color tabular-nums text-[0.8125rem]"
302
+ }, va = {
303
+ key: 4,
304
+ class: "text-muted-color tabular-nums text-[0.8125rem]"
305
+ }, ga = {
306
+ key: 5,
307
+ class: "font-semibold tabular-nums text-[0.8125rem]"
308
+ }, ha = {
309
+ key: 6,
310
+ class: "font-semibold tabular-nums text-[0.8125rem]"
311
+ }, ya = {
312
+ key: 7,
313
+ class: "text-[0.8125rem]"
314
+ }, Xe = /* @__PURE__ */ re({
315
+ __name: "WCrudColumnRenderer",
316
+ props: {
317
+ column: {},
318
+ value: {},
319
+ rowData: {}
320
+ },
321
+ setup(e) {
322
+ const { formatDate: t, formatDateTime: a, formatCurrency: o, formatNumber: l } = rt();
323
+ return (r, i) => e.value == null ? (s(), c("span", fa, "—")) : e.column.type === "image" ? (s(), c("img", {
324
+ key: 1,
325
+ src: String(e.value),
326
+ alt: e.column.header,
327
+ class: "size-9 rounded-lg object-cover ring-1 ring-surface-200 dark:ring-surface-700"
328
+ }, null, 8, ma)) : e.column.type === "boolean" ? (s(), I(g(wt), {
329
+ key: 2,
330
+ value: e.column.tagValue ? e.column.tagValue(e.value, e.rowData) : e.value ? "Ativo" : "Inativo",
331
+ severity: e.column.tagSeverity ? e.column.tagSeverity(e.value, e.rowData) : e.value ? "success" : "danger",
332
+ class: "text-xs"
333
+ }, null, 8, ["value", "severity"])) : e.column.type === "date" ? (s(), c("span", pa, R(g(t)(e.value)), 1)) : e.column.type === "datetime" ? (s(), c("span", va, R(g(a)(e.value)), 1)) : e.column.type === "currency" ? (s(), c("span", ga, R(g(o)(e.value)), 1)) : e.column.type === "number" ? (s(), c("span", ha, R(e.column.format ? e.column.format(e.value, e.rowData) : g(l)(e.value, e.column.decimals ?? 0)), 1)) : (s(), c("span", ya, R(e.column.format ? e.column.format(e.value, e.rowData) : e.value), 1));
334
+ }
335
+ });
336
+ var ba = Object.defineProperty, wa = (e, t, a) => t in e ? ba(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a, je = (e, t, a) => wa(e, typeof t != "symbol" ? t + "" : t, a);
337
+ const pt = {
338
+ "#": { pattern: /[0-9]/ },
339
+ "@": { pattern: /[a-zA-Z]/ },
340
+ "*": { pattern: /[a-zA-Z0-9]/ }
341
+ }, vt = (e, t, a) => e.replaceAll(t, "").replace(a, ".").replace("..", ".").replace(/[^.\d]/g, ""), gt = (e, t, a) => {
342
+ var o;
343
+ return new Intl.NumberFormat(((o = a.number) == null ? void 0 : o.locale) ?? "en", {
344
+ minimumFractionDigits: e,
345
+ maximumFractionDigits: t,
346
+ roundingMode: "trunc"
347
+ });
348
+ }, ka = (e, t = !0, a) => {
349
+ var o, l, r, i;
350
+ const y = ((o = a.number) == null ? void 0 : o.unsigned) !== !0 && e.startsWith("-") ? "-" : "", u = ((l = a.number) == null ? void 0 : l.fraction) ?? 0;
351
+ let k = gt(0, u, a);
352
+ const M = k.formatToParts(1000.12), P = ((r = M.find((f) => f.type === "group")) == null ? void 0 : r.value) ?? " ", B = ((i = M.find((f) => f.type === "decimal")) == null ? void 0 : i.value) ?? ".", Y = vt(e, P, B);
353
+ if (Number.isNaN(parseFloat(Y))) return y;
354
+ const G = Y.split(".");
355
+ if (G[1] != null && G[1].length >= 1) {
356
+ const f = G[1].length <= u ? G[1].length : u;
357
+ k = gt(f, u, a);
358
+ }
359
+ let Z = k.format(parseFloat(Y));
360
+ return t ? u > 0 && Y.endsWith(".") && !Y.slice(0, -1).includes(".") && (Z += B) : Z = vt(Z, P, B), y + Z;
361
+ }, Mt = (e) => JSON.parse(e.replaceAll("'", '"')), $a = (e, t = {}) => {
362
+ const a = { ...t };
363
+ e.dataset.maska != null && e.dataset.maska !== "" && (a.mask = Da(e.dataset.maska)), e.dataset.maskaEager != null && (a.eager = Ge(e.dataset.maskaEager)), e.dataset.maskaReversed != null && (a.reversed = Ge(e.dataset.maskaReversed)), e.dataset.maskaTokensReplace != null && (a.tokensReplace = Ge(e.dataset.maskaTokensReplace)), e.dataset.maskaTokens != null && (a.tokens = Ca(e.dataset.maskaTokens));
364
+ const o = {};
365
+ return e.dataset.maskaNumberLocale != null && (o.locale = e.dataset.maskaNumberLocale), e.dataset.maskaNumberFraction != null && (o.fraction = parseInt(e.dataset.maskaNumberFraction)), e.dataset.maskaNumberUnsigned != null && (o.unsigned = Ge(e.dataset.maskaNumberUnsigned)), (e.dataset.maskaNumber != null || Object.values(o).length > 0) && (a.number = o), a;
366
+ }, Ge = (e) => e !== "" ? !!JSON.parse(e) : !0, Da = (e) => e.startsWith("[") && e.endsWith("]") ? Mt(e) : e, Ca = (e) => {
367
+ if (e.startsWith("{") && e.endsWith("}"))
368
+ return Mt(e);
369
+ const t = {};
370
+ return e.split("|").forEach((a) => {
371
+ const o = a.split(":");
372
+ t[o[0]] = {
373
+ pattern: Ft() ? new RegExp(o[1], "u") : new RegExp(o[1]),
374
+ optional: o[2] === "optional",
375
+ multiple: o[2] === "multiple",
376
+ repeated: o[2] === "repeated"
377
+ };
378
+ }), t;
379
+ }, Ft = () => {
380
+ try {
381
+ return new RegExp("\\p{L}", "u"), !0;
382
+ } catch {
383
+ return !1;
384
+ }
385
+ };
386
+ class Sa {
387
+ constructor(t = {}) {
388
+ je(this, "opts", {}), je(this, "memo", /* @__PURE__ */ new Map());
389
+ const a = { ...t };
390
+ if (a.tokens != null) {
391
+ a.tokens = a.tokensReplace ? { ...a.tokens } : { ...pt, ...a.tokens };
392
+ for (const o of Object.values(a.tokens))
393
+ typeof o.pattern == "string" && (o.pattern = Ft() ? new RegExp(o.pattern, "u") : new RegExp(o.pattern));
394
+ } else
395
+ a.tokens = pt;
396
+ Array.isArray(a.mask) && (a.mask.length > 1 ? a.mask = [...a.mask].sort((o, l) => o.length - l.length) : a.mask = a.mask[0] ?? ""), a.mask === "" && (a.mask = null), this.opts = a;
397
+ }
398
+ masked(t) {
399
+ return this.process(String(t), this.findMask(String(t)));
400
+ }
401
+ unmasked(t) {
402
+ return this.process(String(t), this.findMask(String(t)), !1);
403
+ }
404
+ isEager() {
405
+ return this.opts.eager === !0;
406
+ }
407
+ isReversed() {
408
+ return this.opts.reversed === !0;
409
+ }
410
+ completed(t) {
411
+ const a = this.findMask(String(t));
412
+ if (this.opts.mask == null || a == null) return !1;
413
+ const o = this.process(String(t), a).length;
414
+ return typeof this.opts.mask == "string" ? o >= this.opts.mask.length : o >= a.length;
415
+ }
416
+ findMask(t) {
417
+ const a = this.opts.mask;
418
+ if (a == null)
419
+ return null;
420
+ if (typeof a == "string")
421
+ return a;
422
+ if (typeof a == "function")
423
+ return a(t);
424
+ const o = this.process(t, a.slice(-1).pop() ?? "", !1);
425
+ return a.find((l) => this.process(t, l, !1).length >= o.length) ?? "";
426
+ }
427
+ escapeMask(t) {
428
+ const a = [], o = [];
429
+ return t.split("").forEach((l, r) => {
430
+ l === "!" && t[r - 1] !== "!" ? o.push(r - o.length) : a.push(l);
431
+ }), { mask: a.join(""), escaped: o };
432
+ }
433
+ process(t, a, o = !0) {
434
+ if (this.opts.number != null) return ka(t, o, this.opts);
435
+ if (a == null) return t;
436
+ const l = `v=${t},mr=${a},m=${o ? 1 : 0}`;
437
+ if (this.memo.has(l)) return this.memo.get(l);
438
+ const { mask: r, escaped: i } = this.escapeMask(a), y = [], u = this.opts.tokens != null ? this.opts.tokens : {}, k = this.isReversed() ? -1 : 1, M = this.isReversed() ? "unshift" : "push", P = this.isReversed() ? 0 : r.length - 1, B = this.isReversed() ? () => f > -1 && b > -1 : () => f < r.length && b < t.length, Y = (V) => !this.isReversed() && V <= P || this.isReversed() && V >= P;
439
+ let G, Z = -1, f = this.isReversed() ? r.length - 1 : 0, b = this.isReversed() ? t.length - 1 : 0, $ = !1;
440
+ for (; B(); ) {
441
+ const V = r.charAt(f), T = u[V], j = (T == null ? void 0 : T.transform) != null ? T.transform(t.charAt(b)) : t.charAt(b);
442
+ if (!i.includes(f) && T != null ? (j.match(T.pattern) != null ? (y[M](j), T.repeated ? (Z === -1 ? Z = f : f === P && f !== Z && (f = Z - k), P === Z && (f -= k)) : T.multiple && ($ = !0, f -= k), f += k) : T.multiple ? $ && (f += k, b -= k, $ = !1) : j === G ? G = void 0 : T.optional && (f += k, b -= k), b += k) : (o && !this.isEager() && y[M](V), j === V && !this.isEager() ? b += k : G = V, this.isEager() || (f += k)), this.isEager())
443
+ for (; Y(f) && (u[r.charAt(f)] == null || i.includes(f)); ) {
444
+ if (o) {
445
+ if (y[M](r.charAt(f)), t.charAt(b) === r.charAt(f)) {
446
+ f += k, b += k;
447
+ continue;
448
+ }
449
+ } else r.charAt(f) === t.charAt(b) && (b += k);
450
+ f += k;
451
+ }
452
+ }
453
+ return this.memo.set(l, y.join("")), this.memo.get(l);
454
+ }
455
+ }
456
+ class Pa {
457
+ constructor(t, a = {}) {
458
+ je(this, "items", /* @__PURE__ */ new Map()), je(this, "eventAbortController"), je(this, "onInput", (o) => {
459
+ if (o instanceof CustomEvent && o.type === "input" && !o.isTrusted && !o.bubbles)
460
+ return;
461
+ const l = o.target, r = this.items.get(l);
462
+ if (r === void 0) return;
463
+ const i = "inputType" in o && o.inputType.startsWith("delete"), y = r.isEager(), u = i && y && r.unmasked(l.value) === "" ? "" : l.value;
464
+ this.fixCursor(l, i, () => this.setValue(l, u));
465
+ }), this.options = a, this.eventAbortController = new AbortController(), this.init(this.getInputs(t));
466
+ }
467
+ update(t = {}) {
468
+ this.options = { ...t }, this.init(Array.from(this.items.keys()));
469
+ }
470
+ updateValue(t) {
471
+ var a;
472
+ t.value !== "" && t.value !== ((a = this.processInput(t)) == null ? void 0 : a.masked) && this.setValue(t, t.value);
473
+ }
474
+ destroy() {
475
+ this.eventAbortController.abort(), this.items.clear();
476
+ }
477
+ init(t) {
478
+ const a = this.getOptions(this.options);
479
+ for (const o of t) {
480
+ if (!this.items.has(o)) {
481
+ const { signal: r } = this.eventAbortController;
482
+ o.addEventListener("input", this.onInput, { capture: !0, signal: r });
483
+ }
484
+ const l = new Sa($a(o, a));
485
+ this.items.set(o, l), queueMicrotask(() => this.updateValue(o)), o.selectionStart === null && l.isEager() && console.warn("Maska: input of `%s` type is not supported", o.type);
486
+ }
487
+ }
488
+ getInputs(t) {
489
+ return typeof t == "string" ? Array.from(document.querySelectorAll(t)) : "length" in t ? Array.from(t) : [t];
490
+ }
491
+ getOptions(t) {
492
+ const { onMaska: a, preProcess: o, postProcess: l, ...r } = t;
493
+ return r;
494
+ }
495
+ fixCursor(t, a, o) {
496
+ var l, r;
497
+ const i = t.selectionStart, y = t.value;
498
+ if (o(), i === null || i === y.length && !a) return;
499
+ const u = t.value, k = y.slice(0, i), M = u.slice(0, i), P = (l = this.processInput(t, k)) == null ? void 0 : l.unmasked, B = (r = this.processInput(t, M)) == null ? void 0 : r.unmasked;
500
+ if (P === void 0 || B === void 0) return;
501
+ let Y = i;
502
+ k !== M && (Y += a ? u.length - y.length : P.length - B.length), t.setSelectionRange(Y, Y);
503
+ }
504
+ setValue(t, a) {
505
+ const o = this.processInput(t, a);
506
+ o !== void 0 && (t.value = o.masked, this.options.onMaska != null && (Array.isArray(this.options.onMaska) ? this.options.onMaska.forEach((l) => l(o)) : this.options.onMaska(o)), t.dispatchEvent(new CustomEvent("maska", { detail: o })), t.dispatchEvent(new CustomEvent("input", { detail: o.masked })));
507
+ }
508
+ processInput(t, a) {
509
+ const o = this.items.get(t);
510
+ if (o === void 0) return;
511
+ let l = a ?? t.value;
512
+ this.options.preProcess != null && (l = this.options.preProcess(l));
513
+ let r = o.masked(l);
514
+ return this.options.postProcess != null && (r = this.options.postProcess(r)), {
515
+ masked: r,
516
+ unmasked: o.unmasked(l),
517
+ completed: o.completed(l)
518
+ };
519
+ }
520
+ }
521
+ const tt = /* @__PURE__ */ new WeakMap(), xa = (e, t) => {
522
+ if (e.arg == null || e.instance == null) return;
523
+ const a = "setup" in e.instance.$.type;
524
+ e.arg in e.instance ? e.instance[e.arg] = t : a && console.warn("Maska: please expose `%s` using defineExpose", e.arg);
525
+ }, at = (e, t) => {
526
+ var a;
527
+ const o = e instanceof HTMLInputElement ? e : e.querySelector("input");
528
+ if (o == null || (o == null ? void 0 : o.type) === "file") return;
529
+ let l = {};
530
+ if (t.value != null && (l = typeof t.value == "string" ? { mask: t.value } : { ...t.value }), t.arg != null) {
531
+ const r = (i) => {
532
+ const y = t.modifiers.unmasked ? i.unmasked : t.modifiers.completed ? i.completed : i.masked;
533
+ xa(t, y);
534
+ };
535
+ l.onMaska = l.onMaska == null ? r : Array.isArray(l.onMaska) ? [...l.onMaska, r] : [l.onMaska, r];
536
+ }
537
+ tt.has(o) ? (a = tt.get(o)) == null || a.update(l) : tt.set(o, new Pa(o, l));
538
+ }, Va = {
539
+ string: "text",
540
+ integer: "number",
541
+ decimal: "number",
542
+ float: "number",
543
+ boolean: "switch",
544
+ choice: "select",
545
+ fk: "fk",
546
+ date: "date",
547
+ datetime: "datetime",
548
+ email: "email",
549
+ url: "text",
550
+ slug: "text",
551
+ text: "textarea"
552
+ };
553
+ function Ea(e) {
554
+ var o;
555
+ const t = Va[e.type] ?? "text", a = {
556
+ field: e.name,
557
+ label: e.label,
558
+ type: t,
559
+ required: e.required ?? !1
560
+ };
561
+ return (e.type === "decimal" || e.type === "float") && (a.minFractionDigits = 2, a.maxFractionDigits = 2), e.type === "boolean" && (a.defaultValue = !1), e.type === "choice" && ((o = e.choices) != null && o.length) && (a.options = e.choices.map((l) => ({
562
+ label: l.label,
563
+ value: l.value
564
+ }))), e.type === "fk" && (a.endpoint = e.endpoint, e.option_label && (a.optionLabel = e.option_label), e.option_value && (a.optionValue = e.option_value)), a;
565
+ }
566
+ function Ma(e) {
567
+ return e.filter((t) => !t.read_only && t.name !== "id").map(Ea);
568
+ }
569
+ const Fa = {
570
+ boolean: "boolean",
571
+ date: "date",
572
+ datetime: "datetime",
573
+ decimal: "number",
574
+ float: "number",
575
+ integer: "number"
576
+ };
577
+ function Aa(e) {
578
+ return {
579
+ field: e.type === "fk" ? `${e.name}_nome` : e.name,
580
+ header: e.label,
581
+ type: Fa[e.type],
582
+ sortable: !0
583
+ };
584
+ }
585
+ function Ia(e, t = 6) {
586
+ return e.filter((a) => !a.read_only && a.name !== "id").slice(0, t).map(Aa);
587
+ }
588
+ function At() {
589
+ const e = Zt();
590
+ function t(r, i = "Sucesso") {
591
+ e.add({ severity: "success", summary: i, detail: r, life: 3e3 });
592
+ }
593
+ function a(r, i = "Erro") {
594
+ e.add({ severity: "error", summary: i, detail: r, life: 5e3 });
595
+ }
596
+ function o(r, i = "Atenção") {
597
+ e.add({ severity: "warn", summary: i, detail: r, life: 4e3 });
598
+ }
599
+ function l(r, i = "Info") {
600
+ e.add({ severity: "info", summary: i, detail: r, life: 3e3 });
601
+ }
602
+ return { success: t, error: a, warn: o, info: l };
603
+ }
604
+ function It() {
605
+ const e = Xt();
606
+ function t(o, l = "Deseja realmente excluir este registro?") {
607
+ e.require({
608
+ message: l,
609
+ header: "Confirmar Exclusão",
610
+ icon: "pi pi-trash",
611
+ rejectLabel: "Cancelar",
612
+ rejectProps: {
613
+ severity: "secondary",
614
+ text: !0
615
+ },
616
+ acceptLabel: "Excluir",
617
+ acceptProps: {
618
+ severity: "danger"
619
+ },
620
+ accept: o
621
+ });
622
+ }
623
+ function a(o, l, r = "Confirmação") {
624
+ e.require({
625
+ message: o,
626
+ header: r,
627
+ icon: "pi pi-question-circle",
628
+ rejectLabel: "Cancelar",
629
+ rejectProps: {
630
+ severity: "secondary",
631
+ text: !0
632
+ },
633
+ acceptLabel: "Confirmar",
634
+ accept: l
635
+ });
636
+ }
637
+ return { confirmDelete: t, confirmAction: a };
638
+ }
639
+ function Ra(e) {
640
+ return e.replace(/_/g, " ").replace(/^\w/, (t) => t.toUpperCase());
641
+ }
642
+ function Ta(e) {
643
+ if (typeof e == "string")
644
+ return e;
645
+ if (Array.isArray(e)) {
646
+ const t = e.filter((a) => typeof a == "string");
647
+ return t.length > 0 ? t.join(" ") : null;
648
+ }
649
+ if (typeof e == "object" && e !== null) {
650
+ const t = e;
651
+ if (Array.isArray(t.non_field_errors) && t.non_field_errors.length > 0)
652
+ return t.non_field_errors.filter((o) => typeof o == "string").join(" ");
653
+ const a = [];
654
+ for (const [o, l] of Object.entries(t)) {
655
+ if (o === "non_field_errors") continue;
656
+ const r = Ra(o);
657
+ if (Array.isArray(l)) {
658
+ const i = l.filter((y) => typeof y == "string");
659
+ i.length > 0 && a.push(`${r}: ${i.join(" ")}`);
660
+ } else typeof l == "string" && a.push(`${r}: ${l}`);
661
+ }
662
+ return a.length > 0 ? a.join(`
663
+ `) : null;
664
+ }
665
+ return null;
666
+ }
667
+ function qe(e, t = "Erro inesperado") {
668
+ var r;
669
+ if (!e || typeof e != "object") return t;
670
+ const a = e, o = (r = a.response) == null ? void 0 : r.data;
671
+ if (!o || typeof o != "object")
672
+ return a.message || t;
673
+ const l = o.detail ?? o;
674
+ return Ta(l) || t;
675
+ }
676
+ function Nl() {
677
+ return { extractApiError: qe };
678
+ }
679
+ const La = { class: "w-autocompletefk" }, Na = ["disabled"], Ya = { class: "w-autocompletefk-toolbar" }, za = { class: "w-autocompletefk-toolbar-actions" }, Wa = { class: "flex items-center justify-end gap-1" }, Oa = { class: "w-autocompletefk-footer" }, Rt = /* @__PURE__ */ re({
680
+ __name: "WAutoCompleteFK",
681
+ props: {
682
+ modelValue: {},
683
+ endpoint: {},
684
+ endpointParams: {},
685
+ optionLabel: { default: "nome" },
686
+ optionValue: { default: "id" },
687
+ placeholder: { default: "Buscar..." },
688
+ disabled: { type: Boolean, default: !1 },
689
+ showClear: { type: Boolean, default: !0 },
690
+ forceSelection: { type: Boolean, default: !0 },
691
+ columns: {},
692
+ minLength: { default: 0 },
693
+ dialogHeader: {},
694
+ canCreate: { type: Boolean, default: void 0 },
695
+ canEdit: { type: Boolean, default: void 0 },
696
+ canDelete: { type: Boolean, default: void 0 },
697
+ crudFields: {},
698
+ crudColumns: {},
699
+ dialogWidth: { default: "480px" }
700
+ },
701
+ emits: ["update:modelValue"],
702
+ setup(e, { emit: t }) {
703
+ const a = e, o = t, l = Ie(Qe);
704
+ if (!l)
705
+ throw new Error(
706
+ "[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin."
707
+ );
708
+ const r = l, i = At(), { confirmDelete: y } = It(), u = K(null), k = K([]), M = K(!1);
709
+ let P = null;
710
+ async function B(D) {
711
+ try {
712
+ const C = await r.get(a.endpoint, D);
713
+ u.value = C.data;
714
+ } catch {
715
+ u.value = null;
716
+ }
717
+ }
718
+ async function Y(D) {
719
+ M.value = !0;
720
+ try {
721
+ const C = {
722
+ page_size: 20,
723
+ ...a.endpointParams
724
+ };
725
+ D && (C.search = D);
726
+ const ee = await r.list(a.endpoint, C);
727
+ k.value = ee.data;
728
+ } catch {
729
+ k.value = [];
730
+ } finally {
731
+ M.value = !1;
732
+ }
733
+ }
734
+ function G(D) {
735
+ const C = D.query || "";
736
+ if (C.length < a.minLength) {
737
+ k.value = [];
738
+ return;
739
+ }
740
+ P && clearTimeout(P), P = setTimeout(() => Y(C), 300);
741
+ }
742
+ function Z(D) {
743
+ u.value = D.value, o("update:modelValue", D.value);
744
+ }
745
+ function f() {
746
+ u.value = null, o("update:modelValue", null);
747
+ }
748
+ ot(
749
+ () => a.modelValue,
750
+ async (D) => {
751
+ if (D != null) {
752
+ if (typeof D == "object" && D !== null && a.optionLabel in D) {
753
+ u.value = D;
754
+ return;
755
+ }
756
+ (!u.value || u.value[a.optionValue] !== D) && await B(D);
757
+ } else
758
+ u.value = null;
759
+ },
760
+ { immediate: !0 }
761
+ );
762
+ const b = K(!1), $ = K([]), V = K(!1), T = K(""), j = K(1), w = K(15), h = K(0), U = K(null), m = K(null), A = K(0);
763
+ let L = null;
764
+ const X = K([]), d = q(() => {
765
+ var D;
766
+ return (D = a.crudFields) != null && D.length ? !0 : X.value.length > 0;
767
+ }), E = q(() => a.canCreate ?? d.value), F = q(() => a.canEdit ?? d.value), n = q(() => a.canDelete ?? d.value), p = q(() => F.value || n.value), J = q(() => {
768
+ var D;
769
+ return (D = a.crudFields) != null && D.length ? a.crudFields : Ma(X.value);
770
+ }), ne = q(() => {
771
+ var D, C;
772
+ return (D = a.crudColumns) != null && D.length ? a.crudColumns : (C = a.columns) != null && C.length ? a.columns.map((ee) => ({
773
+ field: ee.field,
774
+ header: ee.header,
775
+ sortable: !0
776
+ })) : X.value.length ? Ia(X.value) : [
777
+ { field: a.optionLabel, header: a.optionLabel, sortable: !0 }
778
+ ];
779
+ });
780
+ async function Q() {
781
+ var D, C, ee;
782
+ V.value = !0;
783
+ try {
784
+ const z = {
785
+ page: j.value,
786
+ page_size: w.value,
787
+ ...a.endpointParams
788
+ };
789
+ T.value && (z.search = T.value), m.value && A.value !== 0 && (z.ordering = A.value === -1 ? `-${m.value}` : m.value);
790
+ const ie = await r.list(a.endpoint, z);
791
+ $.value = ie.data, h.value = ie.rows, (D = ie.extras) != null && D.fields && !((C = a.columns) != null && C.length) && !((ee = a.crudFields) != null && ee.length) && (X.value = ie.extras.fields);
792
+ } catch {
793
+ $.value = [], h.value = 0;
794
+ } finally {
795
+ V.value = !1;
796
+ }
797
+ }
798
+ function _() {
799
+ a.disabled || (T.value = "", j.value = 1, m.value = null, A.value = 0, U.value = null, b.value = !0, Q());
800
+ }
801
+ function de(D) {
802
+ j.value = D.page + 1, w.value = D.rows, Q();
803
+ }
804
+ function me(D) {
805
+ m.value = D.sortField ?? null, A.value = D.sortOrder ?? 0, j.value = 1, Q();
806
+ }
807
+ function Ne() {
808
+ U.value && (u.value = U.value, o("update:modelValue", U.value), b.value = !1);
809
+ }
810
+ function Ye(D) {
811
+ u.value = D.data, o("update:modelValue", D.data), b.value = !1;
812
+ }
813
+ ot(T, () => {
814
+ L && clearTimeout(L), L = setTimeout(() => {
815
+ j.value = 1, Q();
816
+ }, 300);
817
+ });
818
+ const ge = K(!1), fe = K(!1), he = K(null), pe = ve({}), ye = q(() => he.value !== null), Ee = q(
819
+ () => ye.value ? "Editar Registro" : "Novo Registro"
820
+ );
821
+ function be() {
822
+ const D = {};
823
+ for (const C of J.value)
824
+ D[C.field] = C.defaultValue !== void 0 ? typeof C.defaultValue == "function" ? C.defaultValue() : C.defaultValue : null;
825
+ return D;
826
+ }
827
+ function Me() {
828
+ const D = be();
829
+ for (const C of Object.keys(pe))
830
+ delete pe[C];
831
+ for (const [C, ee] of Object.entries(D))
832
+ pe[C] = ee;
833
+ }
834
+ function $e() {
835
+ he.value = null, Me(), ge.value = !0;
836
+ }
837
+ function De(D) {
838
+ he.value = D;
839
+ for (const C of J.value)
840
+ pe[C.field] = D[C.field] !== void 0 ? D[C.field] : null;
841
+ ge.value = !0;
842
+ }
843
+ function Fe(D, C) {
844
+ pe[D] = C;
845
+ }
846
+ async function Ce() {
847
+ fe.value = !0;
848
+ try {
849
+ const D = { ...pe };
850
+ for (const ee of J.value) {
851
+ const z = D[ee.field];
852
+ if (ee.type === "fk" && z !== null && typeof z == "object") {
853
+ const ie = ee.optionValue || "id";
854
+ D[ee.field] = z[ie] ?? z;
855
+ }
856
+ }
857
+ let C;
858
+ if (ye.value && he.value) {
859
+ const ee = he.value[a.optionValue];
860
+ C = await r.update(
861
+ a.endpoint,
862
+ ee,
863
+ D
864
+ );
865
+ const z = $.value.findIndex((ie) => ie[a.optionValue] === ee);
866
+ z !== -1 && ($.value[z] = C.data), i.success("Registro atualizado com sucesso");
867
+ } else
868
+ C = await r.create(a.endpoint, D), $.value.unshift(C.data), h.value++, i.success("Registro criado com sucesso");
869
+ ge.value = !1, he.value = null, U.value = C.data;
870
+ } catch (D) {
871
+ i.error(qe(D, "Erro ao salvar registro"));
872
+ } finally {
873
+ fe.value = !1;
874
+ }
875
+ }
876
+ function Ae(D) {
877
+ y(async () => {
878
+ try {
879
+ const C = D[a.optionValue];
880
+ await r.delete(a.endpoint, C);
881
+ const ee = $.value.findIndex((z) => z[a.optionValue] === C);
882
+ ee !== -1 && ($.value.splice(ee, 1), h.value--), u.value && u.value[a.optionValue] === C && (u.value = null, o("update:modelValue", null)), U.value && U.value[a.optionValue] === C && (U.value = null), i.success("Registro excluído com sucesso");
883
+ } catch (C) {
884
+ i.error(qe(C, "Erro ao excluir registro"));
885
+ }
886
+ });
887
+ }
888
+ return (D, C) => {
889
+ const ee = yt("tooltip");
890
+ return s(), c(le, null, [
891
+ v("div", La, [
892
+ W(g($t), {
893
+ "model-value": u.value,
894
+ suggestions: k.value,
895
+ "option-label": e.optionLabel,
896
+ placeholder: e.placeholder,
897
+ disabled: e.disabled,
898
+ "force-selection": e.forceSelection,
899
+ loading: M.value,
900
+ fluid: "",
901
+ onComplete: G,
902
+ onItemSelect: Z,
903
+ onClear: f
904
+ }, null, 8, ["model-value", "suggestions", "option-label", "placeholder", "disabled", "force-selection", "loading"]),
905
+ Pe((s(), c("button", {
906
+ type: "button",
907
+ disabled: e.disabled,
908
+ class: "w-autocompletefk-trigger",
909
+ onClick: _
910
+ }, [...C[6] || (C[6] = [
911
+ v("i", { class: "pi pi-search" }, null, -1)
912
+ ])], 8, Na)), [
913
+ [
914
+ ee,
915
+ "Pesquisar",
916
+ void 0,
917
+ { top: !0 }
918
+ ]
919
+ ])
920
+ ]),
921
+ W(g(kt), {
922
+ visible: b.value,
923
+ "onUpdate:visible": C[4] || (C[4] = (z) => b.value = z),
924
+ header: e.dialogHeader || "Pesquisar",
925
+ style: { width: "80vw" },
926
+ modal: "",
927
+ draggable: !1,
928
+ class: "w-autocompletefk-dialog"
929
+ }, {
930
+ footer: te(() => [
931
+ v("div", Oa, [
932
+ W(g(oe), {
933
+ label: "Cancelar",
934
+ severity: "secondary",
935
+ text: "",
936
+ onClick: C[3] || (C[3] = (z) => b.value = !1)
937
+ }),
938
+ W(g(oe), {
939
+ label: "Selecionar",
940
+ icon: "pi pi-check",
941
+ disabled: !U.value,
942
+ onClick: Ne
943
+ }, null, 8, ["disabled"])
944
+ ])
945
+ ]),
946
+ default: te(() => [
947
+ v("div", Ya, [
948
+ W(g(Ue), { class: "w-autocompletefk-toolbar-search" }, {
949
+ default: te(() => [
950
+ W(g(_e), { class: "pi pi-search" }),
951
+ W(g(ce), {
952
+ modelValue: T.value,
953
+ "onUpdate:modelValue": C[0] || (C[0] = (z) => T.value = z),
954
+ placeholder: "Pesquisar...",
955
+ class: "w-full"
956
+ }, null, 8, ["modelValue"])
957
+ ]),
958
+ _: 1
959
+ }),
960
+ v("div", za, [
961
+ E.value ? (s(), I(g(oe), {
962
+ key: 0,
963
+ label: "Novo",
964
+ icon: "pi pi-plus",
965
+ size: "small",
966
+ onClick: $e
967
+ })) : S("", !0)
968
+ ])
969
+ ]),
970
+ W(g(bt), {
971
+ selection: U.value,
972
+ "onUpdate:selection": C[1] || (C[1] = (z) => U.value = z),
973
+ value: $.value,
974
+ loading: V.value,
975
+ paginator: "",
976
+ lazy: "",
977
+ "striped-rows": "",
978
+ "removable-sort": "",
979
+ size: "small",
980
+ rows: w.value,
981
+ "total-records": h.value,
982
+ "sort-field": m.value ?? void 0,
983
+ "sort-order": A.value,
984
+ "selection-mode": "single",
985
+ "data-key": e.optionValue,
986
+ onPage: de,
987
+ onSort: C[2] || (C[2] = (z) => me({ sortField: z.sortField, sortOrder: z.sortOrder })),
988
+ onRowDblclick: Ye
989
+ }, {
990
+ empty: te(() => [...C[7] || (C[7] = [
991
+ v("div", { class: "w-autocompletefk-empty" }, "Nenhum registro encontrado", -1)
992
+ ])]),
993
+ default: te(() => [
994
+ W(g(Le), {
995
+ "selection-mode": "single",
996
+ "header-style": "width: 3rem"
997
+ }),
998
+ (s(!0), c(le, null, se(ne.value, (z) => (s(), I(g(Le), {
999
+ key: z.field,
1000
+ field: z.field,
1001
+ header: z.header,
1002
+ sortable: z.sortable ?? !0,
1003
+ style: Be(z.style)
1004
+ }, {
1005
+ body: te(({ data: ie }) => [
1006
+ z.type ? (s(), I(Xe, {
1007
+ key: 0,
1008
+ column: z,
1009
+ value: ie[z.field],
1010
+ "row-data": ie
1011
+ }, null, 8, ["column", "value", "row-data"])) : (s(), c(le, { key: 1 }, [
1012
+ xe(R(ie[z.field]), 1)
1013
+ ], 64))
1014
+ ]),
1015
+ _: 2
1016
+ }, 1032, ["field", "header", "sortable", "style"]))), 128)),
1017
+ p.value ? (s(), I(g(Le), {
1018
+ key: 0,
1019
+ header: "",
1020
+ style: { width: "6rem" }
1021
+ }, {
1022
+ body: te(({ data: z }) => [
1023
+ v("div", Wa, [
1024
+ F.value ? Pe((s(), I(g(oe), {
1025
+ key: 0,
1026
+ icon: "pi pi-pencil",
1027
+ text: "",
1028
+ rounded: "",
1029
+ size: "small",
1030
+ onClick: (ie) => De(z)
1031
+ }, null, 8, ["onClick"])), [
1032
+ [
1033
+ ee,
1034
+ "Editar",
1035
+ void 0,
1036
+ { top: !0 }
1037
+ ]
1038
+ ]) : S("", !0),
1039
+ n.value ? Pe((s(), I(g(oe), {
1040
+ key: 1,
1041
+ icon: "pi pi-trash",
1042
+ text: "",
1043
+ rounded: "",
1044
+ size: "small",
1045
+ severity: "danger",
1046
+ onClick: (ie) => Ae(z)
1047
+ }, null, 8, ["onClick"])), [
1048
+ [
1049
+ ee,
1050
+ "Excluir",
1051
+ void 0,
1052
+ { top: !0 }
1053
+ ]
1054
+ ]) : S("", !0)
1055
+ ])
1056
+ ]),
1057
+ _: 1
1058
+ })) : S("", !0)
1059
+ ]),
1060
+ _: 1
1061
+ }, 8, ["selection", "value", "loading", "rows", "total-records", "sort-field", "sort-order", "data-key"])
1062
+ ]),
1063
+ _: 1
1064
+ }, 8, ["visible", "header"]),
1065
+ d.value ? (s(), I(it, {
1066
+ key: 0,
1067
+ visible: ge.value,
1068
+ title: Ee.value,
1069
+ fields: J.value,
1070
+ "form-data": pe,
1071
+ "is-editing": ye.value,
1072
+ saving: fe.value,
1073
+ width: e.dialogWidth,
1074
+ "onUpdate:visible": C[5] || (C[5] = (z) => {
1075
+ ge.value = z, z || (he.value = null);
1076
+ }),
1077
+ "onUpdate:field": Fe,
1078
+ onSave: Ce
1079
+ }, null, 8, ["visible", "title", "fields", "form-data", "is-editing", "saving", "width"])) : S("", !0)
1080
+ ], 64);
1081
+ };
1082
+ }
1083
+ }), Tt = /* @__PURE__ */ re({
1084
+ __name: "WMoneyInput",
1085
+ props: {
1086
+ modelValue: {},
1087
+ decimals: { default: 2 },
1088
+ currency: { type: Boolean, default: !1 },
1089
+ prefix: {},
1090
+ suffix: {},
1091
+ locale: { default: "pt-BR" },
1092
+ disabled: { type: Boolean, default: !1 },
1093
+ placeholder: {},
1094
+ invalid: { type: Boolean }
1095
+ },
1096
+ emits: ["update:modelValue"],
1097
+ setup(e, { emit: t }) {
1098
+ const a = e, o = t, l = q(
1099
+ () => a.prefix ?? (a.currency ? "R$" : void 0)
1100
+ ), r = q(() => !!l.value || !!a.suffix), i = q(() => {
1101
+ const u = a.modelValue;
1102
+ return u == null || Number.isNaN(u) ? "" : new Intl.NumberFormat(a.locale, {
1103
+ minimumFractionDigits: a.decimals,
1104
+ maximumFractionDigits: a.decimals
1105
+ }).format(u);
1106
+ });
1107
+ function y(u) {
1108
+ const k = u.target.value.replace(/\D/g, "");
1109
+ if (!k) {
1110
+ o("update:modelValue", null);
1111
+ return;
1112
+ }
1113
+ const M = Number(k) / Math.pow(10, a.decimals);
1114
+ o("update:modelValue", M);
1115
+ }
1116
+ return (u, k) => r.value ? (s(), I(g(Qt), {
1117
+ key: 0,
1118
+ class: "w-money-input"
1119
+ }, {
1120
+ default: te(() => [
1121
+ l.value ? (s(), I(g(ct), { key: 0 }, {
1122
+ default: te(() => [
1123
+ xe(R(l.value), 1)
1124
+ ]),
1125
+ _: 1
1126
+ })) : S("", !0),
1127
+ W(g(ce), {
1128
+ "model-value": i.value,
1129
+ inputmode: "numeric",
1130
+ class: "w-money-input__field",
1131
+ placeholder: e.placeholder,
1132
+ disabled: e.disabled,
1133
+ invalid: e.invalid,
1134
+ onInput: y
1135
+ }, null, 8, ["model-value", "placeholder", "disabled", "invalid"]),
1136
+ e.suffix ? (s(), I(g(ct), { key: 1 }, {
1137
+ default: te(() => [
1138
+ xe(R(e.suffix), 1)
1139
+ ]),
1140
+ _: 1
1141
+ })) : S("", !0)
1142
+ ]),
1143
+ _: 1
1144
+ })) : (s(), I(g(ce), {
1145
+ key: 1,
1146
+ "model-value": i.value,
1147
+ inputmode: "numeric",
1148
+ fluid: "",
1149
+ class: "w-money-input__field",
1150
+ placeholder: e.placeholder,
1151
+ disabled: e.disabled,
1152
+ invalid: e.invalid,
1153
+ onInput: y
1154
+ }, null, 8, ["model-value", "placeholder", "disabled", "invalid"]));
1155
+ }
1156
+ }), Ba = { class: "w-transfer__pane" }, ja = { class: "w-transfer__head" }, Ua = { class: "w-transfer__count" }, _a = { class: "w-transfer__list" }, qa = ["onClick"], Ha = {
1157
+ key: 0,
1158
+ class: "w-transfer__empty"
1159
+ }, Ka = { class: "w-transfer__controls" }, Ga = { class: "w-transfer__pane" }, Ja = { class: "w-transfer__head" }, Za = { class: "w-transfer__count" }, Xa = { class: "w-transfer__list" }, Qa = ["onClick"], eo = {
1160
+ key: 0,
1161
+ class: "w-transfer__empty"
1162
+ }, Lt = /* @__PURE__ */ re({
1163
+ __name: "WTransferList",
1164
+ props: {
1165
+ source: {},
1166
+ selected: { default: () => [] },
1167
+ trackBy: { default: "id" },
1168
+ optionLabel: { default: "nome" },
1169
+ searchFields: {},
1170
+ disabled: { type: Boolean }
1171
+ },
1172
+ emits: ["update:selected"],
1173
+ setup(e, { emit: t }) {
1174
+ const a = e, o = t, l = K(""), r = K(""), i = q(() => new Set(a.selected)), y = q(() => a.searchFields ?? [a.optionLabel]);
1175
+ function u(b) {
1176
+ return b[a.trackBy];
1177
+ }
1178
+ function k(b) {
1179
+ return String(b[a.optionLabel] ?? "");
1180
+ }
1181
+ function M(b, $) {
1182
+ if (!$) return !0;
1183
+ const V = $.toLowerCase();
1184
+ return y.value.some(
1185
+ (T) => String(b[T] ?? "").toLowerCase().includes(V)
1186
+ );
1187
+ }
1188
+ const P = q(
1189
+ () => a.source.filter(
1190
+ (b) => !i.value.has(u(b)) && M(b, l.value)
1191
+ )
1192
+ ), B = q(
1193
+ () => a.source.filter(
1194
+ (b) => i.value.has(u(b)) && M(b, r.value)
1195
+ )
1196
+ );
1197
+ function Y(b) {
1198
+ a.disabled || o("update:selected", [...a.selected, u(b)]);
1199
+ }
1200
+ function G(b) {
1201
+ if (a.disabled) return;
1202
+ const $ = u(b);
1203
+ o("update:selected", a.selected.filter((V) => V !== $));
1204
+ }
1205
+ function Z() {
1206
+ a.disabled || o("update:selected", a.source.map(u));
1207
+ }
1208
+ function f() {
1209
+ a.disabled || o("update:selected", []);
1210
+ }
1211
+ return (b, $) => (s(), c("div", {
1212
+ class: ue(["w-transfer", { "w-transfer--disabled": e.disabled }])
1213
+ }, [
1214
+ v("div", Ba, [
1215
+ v("div", ja, [
1216
+ $[2] || ($[2] = v("span", { class: "w-transfer__title" }, "Disponíveis", -1)),
1217
+ v("span", Ua, R(P.value.length), 1)
1218
+ ]),
1219
+ W(g(Ue), { class: "w-transfer__search" }, {
1220
+ default: te(() => [
1221
+ W(g(_e), { class: "pi pi-search" }),
1222
+ W(g(ce), {
1223
+ modelValue: l.value,
1224
+ "onUpdate:modelValue": $[0] || ($[0] = (V) => l.value = V),
1225
+ placeholder: "Buscar...",
1226
+ fluid: ""
1227
+ }, null, 8, ["modelValue"])
1228
+ ]),
1229
+ _: 1
1230
+ }),
1231
+ v("ul", _a, [
1232
+ (s(!0), c(le, null, se(P.value, (V) => (s(), c("li", {
1233
+ key: `a-${u(V)}`,
1234
+ class: "w-transfer__item",
1235
+ onClick: (T) => Y(V)
1236
+ }, [
1237
+ v("span", null, R(k(V)), 1),
1238
+ $[3] || ($[3] = v("i", { class: "pi pi-angle-right" }, null, -1))
1239
+ ], 8, qa))), 128)),
1240
+ P.value.length ? S("", !0) : (s(), c("li", Ha, "Nenhum item"))
1241
+ ])
1242
+ ]),
1243
+ v("div", Ka, [
1244
+ W(g(oe), {
1245
+ type: "button",
1246
+ icon: "pi pi-angle-double-right",
1247
+ text: "",
1248
+ rounded: "",
1249
+ disabled: e.disabled || !P.value.length,
1250
+ onClick: Z
1251
+ }, null, 8, ["disabled"]),
1252
+ W(g(oe), {
1253
+ type: "button",
1254
+ icon: "pi pi-angle-double-left",
1255
+ text: "",
1256
+ rounded: "",
1257
+ disabled: e.disabled || !e.selected.length,
1258
+ onClick: f
1259
+ }, null, 8, ["disabled"])
1260
+ ]),
1261
+ v("div", Ga, [
1262
+ v("div", Ja, [
1263
+ $[4] || ($[4] = v("span", { class: "w-transfer__title" }, "Selecionados", -1)),
1264
+ v("span", Za, R(B.value.length), 1)
1265
+ ]),
1266
+ W(g(Ue), { class: "w-transfer__search" }, {
1267
+ default: te(() => [
1268
+ W(g(_e), { class: "pi pi-search" }),
1269
+ W(g(ce), {
1270
+ modelValue: r.value,
1271
+ "onUpdate:modelValue": $[1] || ($[1] = (V) => r.value = V),
1272
+ placeholder: "Buscar...",
1273
+ fluid: ""
1274
+ }, null, 8, ["modelValue"])
1275
+ ]),
1276
+ _: 1
1277
+ }),
1278
+ v("ul", Xa, [
1279
+ (s(!0), c(le, null, se(B.value, (V) => (s(), c("li", {
1280
+ key: `s-${u(V)}`,
1281
+ class: "w-transfer__item",
1282
+ onClick: (T) => G(V)
1283
+ }, [
1284
+ $[5] || ($[5] = v("i", { class: "pi pi-angle-left" }, null, -1)),
1285
+ v("span", null, R(k(V)), 1)
1286
+ ], 8, Qa))), 128)),
1287
+ B.value.length ? S("", !0) : (s(), c("li", eo, "Nenhum item"))
1288
+ ])
1289
+ ])
1290
+ ], 2));
1291
+ }
1292
+ });
1293
+ async function to(e) {
1294
+ const t = e.replace(/\D/g, "");
1295
+ if (t.length !== 8) return null;
1296
+ try {
1297
+ const a = await fetch(`https://viacep.com.br/ws/${t}/json/`);
1298
+ if (!a.ok) return null;
1299
+ const o = await a.json();
1300
+ return o.erro ? null : o;
1301
+ } catch {
1302
+ return null;
1303
+ }
1304
+ }
1305
+ const ao = { class: "w-crud-form" }, oo = {
1306
+ key: 0,
1307
+ class: "w-crud-form-group-header"
1308
+ }, no = { class: "w-crud-form-group-title" }, lo = {
1309
+ key: 0,
1310
+ class: "w-crud-form-group-desc"
1311
+ }, so = { class: "w-crud-form-fields" }, ro = {
1312
+ key: 0,
1313
+ class: "w-crud-form-switch"
1314
+ }, io = { class: "w-crud-form-switch-label" }, uo = {
1315
+ key: 1,
1316
+ class: "w-crud-form-col-full"
1317
+ }, co = { class: "w-crud-form-label" }, fo = {
1318
+ key: 0,
1319
+ class: "w-crud-form-required"
1320
+ }, mo = { class: "w-crud-form-color-row" }, po = {
1321
+ key: 2,
1322
+ class: "w-crud-form-col-full"
1323
+ }, vo = { class: "w-crud-form-label" }, go = ["accept", "disabled", "onChange"], ho = {
1324
+ key: 3,
1325
+ class: "w-crud-form-col-full"
1326
+ }, yo = { class: "w-crud-form-label" }, bo = {
1327
+ key: 0,
1328
+ class: "w-crud-form-required"
1329
+ }, wo = { class: "w-crud-form-label" }, ko = {
1330
+ key: 0,
1331
+ class: "w-crud-form-required"
1332
+ }, $o = {
1333
+ key: 1,
1334
+ class: "pi pi-spin pi-spinner w-crud-form-cep-spinner"
1335
+ }, Do = {
1336
+ key: 16,
1337
+ class: "w-crud-form-cep-error"
1338
+ }, Co = {
1339
+ key: 17,
1340
+ class: "w-crud-form-error"
1341
+ }, So = /* @__PURE__ */ re({
1342
+ __name: "WFormRenderer",
1343
+ props: {
1344
+ fields: {},
1345
+ formData: {},
1346
+ isEditing: { type: Boolean },
1347
+ disabled: { type: Boolean, default: !1 }
1348
+ },
1349
+ emits: ["update:field"],
1350
+ setup(e, { expose: t, emit: a }) {
1351
+ const o = e, l = a, r = ve({}), i = ve({}), y = ve({}), u = ve({});
1352
+ function k(d, E) {
1353
+ const F = E.target.value, n = F.replace(/\D/g, "");
1354
+ l("update:field", d.field, F), y[d.field] = null, u[d.field] && (clearTimeout(u[d.field]), u[d.field] = null), n.length === 8 && (u[d.field] = setTimeout(async () => {
1355
+ i[d.field] = !0, y[d.field] = null;
1356
+ try {
1357
+ const p = await to(n);
1358
+ if (!p)
1359
+ y[d.field] = "CEP não encontrado. Preencha os campos manualmente.";
1360
+ else {
1361
+ const J = d.cepFields || {}, ne = Object.keys(J);
1362
+ for (const Q of ne) {
1363
+ const _ = J[Q];
1364
+ if (!_) continue;
1365
+ const de = o.formData[_];
1366
+ (de == null || de === "") && l("update:field", _, p[Q] ?? "");
1367
+ }
1368
+ }
1369
+ } finally {
1370
+ i[d.field] = !1;
1371
+ }
1372
+ }, 400));
1373
+ }
1374
+ const M = q(
1375
+ () => o.fields.filter((d) => d.visible === void 0 || d.visible === !0 ? !0 : typeof d.visible == "function" ? d.visible(o.formData, o.isEditing) : d.visible)
1376
+ );
1377
+ function P(d) {
1378
+ return o.disabled || d.disabledOnEdit && o.isEditing ? !0 : typeof d.disabled == "function" ? d.disabled(o.formData, o.isEditing) : !!d.disabled;
1379
+ }
1380
+ function B(d) {
1381
+ return Wt(d) ? d.value : d;
1382
+ }
1383
+ const Y = q(() => {
1384
+ const d = o.isEditing ? "edit" : "create", E = o.fields.find(
1385
+ (n) => n.autofocus === !0 || n.autofocus === d
1386
+ );
1387
+ if (E) return E.field;
1388
+ const F = M.value.find((n) => !(n.type === "switch" || n.type === "fk" || n.type === "select" || n.type === "image" || n.disabled === !0 || n.disabledOnEdit && o.isEditing));
1389
+ return (F == null ? void 0 : F.field) ?? null;
1390
+ });
1391
+ function G(d) {
1392
+ return d.field === Y.value;
1393
+ }
1394
+ function Z(d) {
1395
+ if (d)
1396
+ return d.replace(/9/g, "#").replace(/a/g, "S").replace(/\*/g, "X");
1397
+ }
1398
+ function f(d) {
1399
+ if (!d) return "";
1400
+ const E = String(d).replace(/\D/g, "").slice(0, 14);
1401
+ return E.length <= 11 ? E.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2") : E.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1/$2").replace(/(\d{4})(\d{1,2})$/, "$1-$2");
1402
+ }
1403
+ function b(d, E) {
1404
+ const F = E.target.value.replace(/\D/g, "").slice(0, 14);
1405
+ l("update:field", d, F);
1406
+ }
1407
+ const $ = ve({});
1408
+ function V(d) {
1409
+ const E = o.formData[d.field];
1410
+ if (E == null) return null;
1411
+ const F = d.optionValue || "value";
1412
+ return (B(d.options) || []).find(
1413
+ (p) => p[F] === E
1414
+ ) ?? null;
1415
+ }
1416
+ function T(d) {
1417
+ return $[d.field] || [];
1418
+ }
1419
+ function j(d, E) {
1420
+ const F = (E.query || "").toLowerCase(), n = B(d.options) || [], p = d.optionLabel || "label";
1421
+ $[d.field] = n.filter(
1422
+ (J) => String(J[p] || "").toLowerCase().includes(F)
1423
+ );
1424
+ }
1425
+ function w(d, E) {
1426
+ const F = d.optionValue || "value";
1427
+ l("update:field", d.field, E.value[F]);
1428
+ }
1429
+ function h(d) {
1430
+ const E = o.formData[d.field];
1431
+ return E ? String(E).replace("#", "") : "FFFFFF";
1432
+ }
1433
+ function U(d, E) {
1434
+ l("update:field", d.field, `#${E}`);
1435
+ }
1436
+ function m(d) {
1437
+ if (typeof d.validate == "function") {
1438
+ const E = d.validate(o.formData[d.field]);
1439
+ r[d.field] = E || null;
1440
+ }
1441
+ }
1442
+ function A() {
1443
+ const d = [];
1444
+ for (const E of o.fields)
1445
+ if (typeof E.validate == "function") {
1446
+ const F = E.validate(o.formData[E.field]);
1447
+ r[E.field] = F || null, F && d.push(F);
1448
+ }
1449
+ return d;
1450
+ }
1451
+ function L() {
1452
+ Object.keys(r).forEach((d) => delete r[d]);
1453
+ }
1454
+ const X = q(() => {
1455
+ var n, p, J, ne;
1456
+ const d = /* @__PURE__ */ new Map(), E = [], F = /* @__PURE__ */ new Map();
1457
+ for (const Q of M.value) {
1458
+ const _ = ((n = Q.fieldGroup) == null ? void 0 : n.id) ?? "__default__";
1459
+ d.has(_) || (d.set(_, {
1460
+ id: _,
1461
+ title: (p = Q.fieldGroup) == null ? void 0 : p.title,
1462
+ description: (J = Q.fieldGroup) == null ? void 0 : J.description,
1463
+ fields: []
1464
+ }), E.push(_), ((ne = Q.fieldGroup) == null ? void 0 : ne.order) != null && F.set(_, Q.fieldGroup.order)), d.get(_).fields.push(Q);
1465
+ }
1466
+ return E.slice().sort((Q, _) => {
1467
+ const de = F.get(Q), me = F.get(_);
1468
+ return de != null && me != null ? de - me : de != null ? -1 : me != null ? 1 : E.indexOf(Q) - E.indexOf(_);
1469
+ }).map((Q) => d.get(Q));
1470
+ });
1471
+ return t({ validateAll: A, clearErrors: L }), (d, E) => (s(), c("div", ao, [
1472
+ (s(!0), c(le, null, se(X.value, (F) => (s(), c("div", {
1473
+ key: F.id,
1474
+ class: "w-crud-form-group"
1475
+ }, [
1476
+ F.title ? (s(), c("div", oo, [
1477
+ v("h3", no, R(F.title), 1),
1478
+ F.description ? (s(), c("p", lo, R(F.description), 1)) : S("", !0)
1479
+ ])) : S("", !0),
1480
+ v("div", so, [
1481
+ (s(!0), c(le, null, se(F.fields, (n) => O(d.$slots, `field-${n.field}`, {
1482
+ key: n.field,
1483
+ field: n,
1484
+ formData: e.formData,
1485
+ isEditing: e.isEditing,
1486
+ setFormField: (p, J) => l("update:field", p, J)
1487
+ }, () => [
1488
+ n.type === "switch" ? (s(), c("div", ro, [
1489
+ W(g(Kt), {
1490
+ "model-value": e.formData[n.field],
1491
+ disabled: P(n),
1492
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1493
+ }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"]),
1494
+ v("label", io, R(n.switchLabel || n.label), 1)
1495
+ ])) : n.type === "color" ? (s(), c("div", uo, [
1496
+ v("label", co, [
1497
+ xe(R(n.label) + " ", 1),
1498
+ n.required ? (s(), c("span", fo, "*")) : S("", !0)
1499
+ ]),
1500
+ v("div", mo, [
1501
+ W(g(Gt), {
1502
+ "model-value": h(n),
1503
+ disabled: P(n),
1504
+ "onUpdate:modelValue": (p) => U(n, p)
1505
+ }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"]),
1506
+ W(g(ce), {
1507
+ "model-value": e.formData[n.field],
1508
+ class: "w-28",
1509
+ maxlength: "7",
1510
+ placeholder: "#000000",
1511
+ disabled: P(n),
1512
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1513
+ }, null, 8, ["model-value", "disabled", "onUpdate:modelValue"])
1514
+ ])
1515
+ ])) : n.type === "image" ? (s(), c("div", po, [
1516
+ v("label", vo, R(n.label), 1),
1517
+ O(d.$slots, `image-${n.field}`, {
1518
+ field: n,
1519
+ formData: e.formData
1520
+ }, () => [
1521
+ v("input", {
1522
+ type: "file",
1523
+ accept: n.accept || "image/*",
1524
+ disabled: P(n),
1525
+ onChange: (p) => {
1526
+ var ne;
1527
+ const J = ((ne = p.target.files) == null ? void 0 : ne[0]) ?? null;
1528
+ l("update:field", n.field, J);
1529
+ }
1530
+ }, null, 40, go)
1531
+ ])
1532
+ ])) : n.type === "transfer" ? (s(), c("div", ho, [
1533
+ v("label", yo, [
1534
+ xe(R(n.label) + " ", 1),
1535
+ n.required ? (s(), c("span", bo, "*")) : S("", !0)
1536
+ ]),
1537
+ W(Lt, {
1538
+ source: B(n.options) || [],
1539
+ selected: e.formData[n.field] || [],
1540
+ "track-by": n.optionValue || "id",
1541
+ "option-label": n.optionLabel || "nome",
1542
+ "search-fields": n.searchFields,
1543
+ disabled: P(n),
1544
+ "onUpdate:selected": (p) => l("update:field", n.field, p)
1545
+ }, null, 8, ["source", "selected", "track-by", "option-label", "search-fields", "disabled", "onUpdate:selected"])
1546
+ ])) : (s(), c("div", {
1547
+ key: 4,
1548
+ class: ue(n.colSpan === 0.5 ? "w-crud-form-col-half" : "w-crud-form-col-full")
1549
+ }, [
1550
+ v("label", wo, [
1551
+ xe(R(n.label) + " ", 1),
1552
+ n.required ? (s(), c("span", ko, "*")) : S("", !0),
1553
+ i[n.field] ? (s(), c("i", $o)) : S("", !0)
1554
+ ]),
1555
+ (!n.type || n.type === "text") && n.mask ? Pe((s(), I(g(ce), {
1556
+ key: 0,
1557
+ "model-value": e.formData[n.field],
1558
+ fluid: "",
1559
+ autofocus: G(n) || void 0,
1560
+ placeholder: n.placeholder,
1561
+ disabled: P(n),
1562
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1563
+ }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])), [
1564
+ [g(at), { mask: Z(n.mask) }]
1565
+ ]) : !n.type || n.type === "text" ? (s(), I(g(ce), {
1566
+ key: 1,
1567
+ "model-value": e.formData[n.field],
1568
+ fluid: "",
1569
+ autofocus: G(n) || void 0,
1570
+ placeholder: n.placeholder,
1571
+ disabled: P(n),
1572
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1573
+ }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "email" ? (s(), I(g(ce), {
1574
+ key: 2,
1575
+ "model-value": e.formData[n.field],
1576
+ type: "email",
1577
+ fluid: "",
1578
+ autofocus: G(n) || void 0,
1579
+ placeholder: n.placeholder,
1580
+ disabled: P(n),
1581
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1582
+ }, null, 8, ["model-value", "autofocus", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "password" ? (s(), I(g(Jt), {
1583
+ key: 3,
1584
+ "model-value": e.formData[n.field],
1585
+ fluid: "",
1586
+ "toggle-mask": "",
1587
+ feedback: n.feedback !== !1,
1588
+ placeholder: n.placeholder,
1589
+ disabled: P(n),
1590
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1591
+ }, null, 8, ["model-value", "feedback", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "number" ? (s(), I(g(ut), {
1592
+ key: 4,
1593
+ "model-value": e.formData[n.field],
1594
+ fluid: "",
1595
+ locale: "pt-BR",
1596
+ min: n.min,
1597
+ max: n.max,
1598
+ "min-fraction-digits": n.minFractionDigits,
1599
+ "max-fraction-digits": n.maxFractionDigits,
1600
+ suffix: n.suffix,
1601
+ prefix: n.prefix,
1602
+ placeholder: n.placeholder,
1603
+ disabled: P(n),
1604
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1605
+ }, null, 8, ["model-value", "min", "max", "min-fraction-digits", "max-fraction-digits", "suffix", "prefix", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "currency" && n.fillFromRight ? (s(), I(Tt, {
1606
+ key: 5,
1607
+ "model-value": e.formData[n.field],
1608
+ decimals: n.decimals ?? 2,
1609
+ currency: "",
1610
+ prefix: n.prefix,
1611
+ suffix: n.suffix,
1612
+ placeholder: n.placeholder,
1613
+ disabled: P(n),
1614
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1615
+ }, null, 8, ["model-value", "decimals", "prefix", "suffix", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "currency" ? (s(), I(g(ut), {
1616
+ key: 6,
1617
+ "model-value": e.formData[n.field],
1618
+ fluid: "",
1619
+ mode: "currency",
1620
+ currency: "BRL",
1621
+ locale: "pt-BR",
1622
+ min: n.min,
1623
+ max: n.max,
1624
+ placeholder: n.placeholder,
1625
+ disabled: P(n),
1626
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1627
+ }, null, 8, ["model-value", "min", "max", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "select" ? (s(), I(g(Ht), {
1628
+ key: 7,
1629
+ "model-value": e.formData[n.field],
1630
+ fluid: "",
1631
+ options: B(n.options),
1632
+ "option-label": n.optionLabel || "label",
1633
+ "option-value": n.optionValue || "value",
1634
+ "show-clear": n.showClear !== !1,
1635
+ placeholder: n.placeholder,
1636
+ disabled: P(n),
1637
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1638
+ }, null, 8, ["model-value", "options", "option-label", "option-value", "show-clear", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "autocomplete" ? (s(), I(g($t), {
1639
+ key: 8,
1640
+ "model-value": V(n),
1641
+ fluid: "",
1642
+ suggestions: T(n),
1643
+ "option-label": n.optionLabel || "label",
1644
+ placeholder: n.placeholder,
1645
+ disabled: P(n),
1646
+ onComplete: (p) => j(n, p),
1647
+ onItemSelect: (p) => w(n, p),
1648
+ onClear: (p) => l("update:field", n.field, null)
1649
+ }, null, 8, ["model-value", "suggestions", "option-label", "placeholder", "disabled", "onComplete", "onItemSelect", "onClear"])) : n.type === "fk" ? (s(), I(Rt, {
1650
+ key: 9,
1651
+ "model-value": e.formData[n.field],
1652
+ endpoint: n.endpoint,
1653
+ "endpoint-params": n.endpointParams,
1654
+ "option-label": n.optionLabel || "nome",
1655
+ placeholder: n.placeholder,
1656
+ disabled: P(n),
1657
+ "show-clear": n.showClear !== !1,
1658
+ "dialog-header": n.label,
1659
+ "crud-fields": n.crudFields,
1660
+ "crud-columns": n.crudColumns,
1661
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1662
+ }, null, 8, ["model-value", "endpoint", "endpoint-params", "option-label", "placeholder", "disabled", "show-clear", "dialog-header", "crud-fields", "crud-columns", "onUpdate:modelValue"])) : n.type === "date" ? (s(), I(g(dt), {
1663
+ key: 10,
1664
+ "model-value": e.formData[n.field],
1665
+ fluid: "",
1666
+ "date-format": n.dateFormat || "dd/mm/yy",
1667
+ placeholder: n.placeholder,
1668
+ disabled: P(n),
1669
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1670
+ }, null, 8, ["model-value", "date-format", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "datetime" ? (s(), I(g(dt), {
1671
+ key: 11,
1672
+ "model-value": e.formData[n.field],
1673
+ fluid: "",
1674
+ "show-time": "",
1675
+ "hour-format": n.hourFormat || "24",
1676
+ "date-format": n.dateFormat || "dd/mm/yy",
1677
+ placeholder: n.placeholder,
1678
+ disabled: P(n),
1679
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1680
+ }, null, 8, ["model-value", "hour-format", "date-format", "placeholder", "disabled", "onUpdate:modelValue"])) : n.type === "cpf_cnpj" ? (s(), I(g(ce), {
1681
+ key: 12,
1682
+ "model-value": f(e.formData[n.field]),
1683
+ fluid: "",
1684
+ maxlength: "18",
1685
+ placeholder: n.placeholder || "000.000.000-00",
1686
+ disabled: P(n),
1687
+ invalid: !!r[n.field],
1688
+ onInput: (p) => b(n.field, p),
1689
+ onBlur: (p) => m(n)
1690
+ }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onInput", "onBlur"])) : n.type === "mask" ? Pe((s(), I(g(ce), {
1691
+ key: 13,
1692
+ "model-value": e.formData[n.field],
1693
+ fluid: "",
1694
+ placeholder: n.placeholder,
1695
+ disabled: P(n),
1696
+ invalid: !!r[n.field],
1697
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p),
1698
+ onBlur: (p) => m(n)
1699
+ }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onUpdate:modelValue", "onBlur"])), [
1700
+ [g(at), { mask: Z(n.mask) }]
1701
+ ]) : n.type === "cep" ? Pe((s(), I(g(ce), {
1702
+ key: 14,
1703
+ "model-value": e.formData[n.field],
1704
+ fluid: "",
1705
+ placeholder: n.placeholder || "00000-000",
1706
+ disabled: P(n),
1707
+ invalid: !!y[n.field],
1708
+ onInput: (p) => k(n, p)
1709
+ }, null, 8, ["model-value", "placeholder", "disabled", "invalid", "onInput"])), [
1710
+ [g(at), { mask: "#####-###" }]
1711
+ ]) : n.type === "textarea" ? (s(), I(g(qt), {
1712
+ key: 15,
1713
+ "model-value": e.formData[n.field],
1714
+ fluid: "",
1715
+ autofocus: G(n) || void 0,
1716
+ rows: n.rows || 3,
1717
+ placeholder: n.placeholder,
1718
+ disabled: P(n),
1719
+ "onUpdate:modelValue": (p) => l("update:field", n.field, p)
1720
+ }, null, 8, ["model-value", "autofocus", "rows", "placeholder", "disabled", "onUpdate:modelValue"])) : S("", !0),
1721
+ y[n.field] ? (s(), c("small", Do, R(y[n.field]), 1)) : r[n.field] ? (s(), c("small", Co, R(r[n.field]), 1)) : S("", !0)
1722
+ ], 2))
1723
+ ])), 128))
1724
+ ])
1725
+ ]))), 128))
1726
+ ]));
1727
+ }
1728
+ }), Po = { class: "w-crud-form-footer" }, it = /* @__PURE__ */ re({
1729
+ __name: "WCrudFormDialog",
1730
+ props: {
1731
+ visible: { type: Boolean },
1732
+ title: {},
1733
+ fields: {},
1734
+ formData: {},
1735
+ isEditing: { type: Boolean },
1736
+ saving: { type: Boolean },
1737
+ disabled: { type: Boolean, default: !1 },
1738
+ width: { default: "480px" }
1739
+ },
1740
+ emits: ["update:visible", "update:field", "save"],
1741
+ setup(e, { emit: t }) {
1742
+ const a = e, o = t, l = K(null);
1743
+ function r() {
1744
+ l.value ? l.value.validateAll().length === 0 && o("save") : o("save");
1745
+ }
1746
+ return ot(
1747
+ () => a.visible,
1748
+ (i) => {
1749
+ i && l.value && l.value.clearErrors();
1750
+ }
1751
+ ), (i, y) => (s(), I(g(kt), {
1752
+ visible: e.visible,
1753
+ header: e.title,
1754
+ style: Be({ width: e.width }),
1755
+ modal: "",
1756
+ draggable: !1,
1757
+ class: "w-crud-form-dialog",
1758
+ "onUpdate:visible": y[2] || (y[2] = (u) => o("update:visible", u))
1759
+ }, {
1760
+ default: te(() => [
1761
+ v("form", {
1762
+ class: "w-crud-form",
1763
+ onSubmit: Ot(r, ["prevent"])
1764
+ }, [
1765
+ W(So, {
1766
+ ref_key: "rendererRef",
1767
+ ref: l,
1768
+ fields: e.fields,
1769
+ "form-data": e.formData,
1770
+ "is-editing": e.isEditing,
1771
+ disabled: e.disabled,
1772
+ "onUpdate:field": y[0] || (y[0] = (u, k) => o("update:field", u, k))
1773
+ }, nt({ _: 2 }, [
1774
+ se(e.fields, (u) => ({
1775
+ name: `field-${u.field}`,
1776
+ fn: te((k) => [
1777
+ O(i.$slots, `field-${u.field}`, lt(st(k)))
1778
+ ])
1779
+ })),
1780
+ se(e.fields.filter((u) => u.type === "image"), (u) => ({
1781
+ name: `image-${u.field}`,
1782
+ fn: te((k) => [
1783
+ O(i.$slots, `image-${u.field}`, lt(st(k)))
1784
+ ])
1785
+ }))
1786
+ ]), 1032, ["fields", "form-data", "is-editing", "disabled"]),
1787
+ v("div", Po, [
1788
+ O(i.$slots, "footer", {
1789
+ saving: e.saving,
1790
+ disabled: e.disabled
1791
+ }, () => [
1792
+ W(g(oe), {
1793
+ type: "button",
1794
+ label: e.disabled ? "Fechar" : "Cancelar",
1795
+ severity: "secondary",
1796
+ text: "",
1797
+ disabled: e.saving,
1798
+ onClick: y[1] || (y[1] = (u) => o("update:visible", !1))
1799
+ }, null, 8, ["label", "disabled"]),
1800
+ e.disabled ? S("", !0) : (s(), I(g(oe), {
1801
+ key: 0,
1802
+ type: "submit",
1803
+ label: e.isEditing ? "Atualizar" : "Salvar",
1804
+ icon: "pi pi-check",
1805
+ loading: e.saving
1806
+ }, null, 8, ["label", "loading"]))
1807
+ ])
1808
+ ])
1809
+ ], 32)
1810
+ ]),
1811
+ _: 3
1812
+ }, 8, ["visible", "header", "style"]));
1813
+ }
1814
+ }), xo = { class: "w-crud" }, Vo = {
1815
+ key: 0,
1816
+ class: "w-crud-header"
1817
+ }, Eo = { class: "w-crud-header-content" }, Mo = { class: "w-crud-title" }, Fo = {
1818
+ key: 0,
1819
+ class: "w-crud-subtitle"
1820
+ }, Ao = { class: "w-crud-header-actions" }, Io = {
1821
+ key: 0,
1822
+ class: "w-crud-kpis"
1823
+ }, Ro = { class: "w-crud-kpi-content" }, To = { class: "w-crud-kpi-label" }, Lo = { class: "w-crud-kpi-value" }, No = {
1824
+ key: 1,
1825
+ class: "w-crud-table"
1826
+ }, Yo = { class: "w-crud-toolbar" }, zo = { class: "w-crud-toolbar-start" }, Wo = { class: "w-crud-toolbar-end" }, Oo = {
1827
+ key: 0,
1828
+ class: "w-crud-view-toggle"
1829
+ }, Bo = { class: "w-crud-actions" }, jo = {
1830
+ key: 2,
1831
+ class: "w-crud-cards-wrap"
1832
+ }, Uo = { class: "w-crud-toolbar w-crud-toolbar--standalone" }, _o = { class: "w-crud-toolbar-start" }, qo = { class: "w-crud-toolbar-end" }, Ho = {
1833
+ key: 0,
1834
+ class: "w-crud-view-toggle"
1835
+ }, Ko = {
1836
+ key: 0,
1837
+ class: "w-crud-cards-loading"
1838
+ }, Go = {
1839
+ key: 2,
1840
+ class: "w-crud-cards"
1841
+ }, Jo = ["onDblclick"], Zo = { class: "w-crud-card-body" }, Xo = {
1842
+ key: 0,
1843
+ class: "w-crud-card-label"
1844
+ }, Qo = { class: "w-crud-card-value" }, en = {
1845
+ key: 0,
1846
+ class: "w-crud-card-actions"
1847
+ }, tn = /* @__PURE__ */ re({
1848
+ __name: "WCrudView",
1849
+ props: {
1850
+ crud: {},
1851
+ title: {},
1852
+ subtitle: {},
1853
+ showSearch: { type: Boolean, default: !0 },
1854
+ showHeader: { type: Boolean, default: !0 },
1855
+ dialogWidth: { default: "480px" },
1856
+ autoInit: { type: Boolean, default: !0 },
1857
+ showKpi: { type: Boolean, default: !1 },
1858
+ kpiIcon: { default: "pi pi-list" },
1859
+ kpiLabel: { default: "Total de Registros" },
1860
+ extraKpis: { default: () => [] },
1861
+ expandable: { type: Boolean, default: !1 },
1862
+ viewToggle: { type: Boolean, default: !1 },
1863
+ defaultView: { default: "table" },
1864
+ cardFields: { default: 4 }
1865
+ },
1866
+ emits: ["row-expand", "row-collapse"],
1867
+ setup(e, { emit: t }) {
1868
+ const a = e, o = t, l = Bt(), { formatNumber: r } = rt(), i = K({}), y = K(a.defaultView);
1869
+ function u(w) {
1870
+ return y.value === w;
1871
+ }
1872
+ function k(w) {
1873
+ y.value = w;
1874
+ }
1875
+ const M = q(
1876
+ () => (a.crud.pagination.page - 1) * a.crud.pagination.pageSize
1877
+ ), P = q(
1878
+ () => a.crud.config.columns.filter((w) => w.visible !== !1).map((w) => w.type === "number" && !w.align ? { ...w, align: "right" } : w.type === "currency" && !w.align ? { ...w, align: "right" } : w)
1879
+ );
1880
+ function B(w) {
1881
+ if (w.align === "right") return "text-right";
1882
+ if (w.align === "center") return "text-center";
1883
+ }
1884
+ const Y = q(() => P.value.slice(0, a.cardFields)), G = q(() => {
1885
+ const w = [];
1886
+ return a.crud.config.canEdit !== !1 && w.push({ action: "edit", icon: "pi pi-pencil", tooltip: "Editar" }), a.crud.config.canDelete !== !1 && w.push({
1887
+ action: "delete",
1888
+ icon: "pi pi-trash",
1889
+ tooltip: "Excluir",
1890
+ severity: "danger"
1891
+ }), w;
1892
+ }), Z = q(
1893
+ () => a.crud.config.rowActions ?? G.value
1894
+ ), f = q(() => Z.value.length > 0 || !!l["row-actions"]);
1895
+ function b(w, h) {
1896
+ w.action === "edit" ? a.crud.openEditDialog(h) : w.action === "view" ? a.crud.openViewDialog(h) : w.action === "delete" ? a.crud.confirmDelete(h) : w.handler && w.handler(h);
1897
+ }
1898
+ function $(w, h) {
1899
+ return w.visible ? w.visible(h) : !0;
1900
+ }
1901
+ function V(w, h) {
1902
+ return w.disabled ? w.disabled(h) : !1;
1903
+ }
1904
+ const T = q(() => {
1905
+ const w = [];
1906
+ return a.showKpi && w.push({
1907
+ icon: a.kpiIcon,
1908
+ label: a.kpiLabel,
1909
+ value: r(a.crud.pagination.rows, 0)
1910
+ }), w.push(...a.extraKpis), w;
1911
+ });
1912
+ q(() => a.crud.config.labels ?? {});
1913
+ const j = q(() => a.crud.config.canCreate !== !1);
1914
+ return jt(() => {
1915
+ a.autoInit && a.crud.init();
1916
+ }), (w, h) => {
1917
+ const U = yt("tooltip");
1918
+ return s(), c("div", xo, [
1919
+ e.showHeader ? (s(), c("div", Vo, [
1920
+ v("div", Eo, [
1921
+ v("h1", Mo, R(e.title), 1),
1922
+ e.subtitle ? (s(), c("p", Fo, R(e.subtitle), 1)) : S("", !0)
1923
+ ]),
1924
+ v("div", Ao, [
1925
+ O(w.$slots, "header-actions"),
1926
+ j.value ? (s(), I(g(oe), {
1927
+ key: 0,
1928
+ label: "Novo",
1929
+ icon: "pi pi-plus",
1930
+ onClick: h[0] || (h[0] = (m) => e.crud.openCreateDialog())
1931
+ })) : S("", !0)
1932
+ ])
1933
+ ])) : S("", !0),
1934
+ O(w.$slots, "before-table", {}, () => [
1935
+ T.value.length ? (s(), c("div", Io, [
1936
+ (s(!0), c(le, null, se(T.value, (m, A) => (s(), c("div", {
1937
+ key: A,
1938
+ class: "w-crud-kpi"
1939
+ }, [
1940
+ v("div", {
1941
+ class: ue(["w-crud-kpi-icon", m.severity ? `w-crud-kpi-icon--${m.severity}` : ""])
1942
+ }, [
1943
+ v("i", {
1944
+ class: ue([m.icon]),
1945
+ style: Be(m.color ? `color: ${m.color}` : "")
1946
+ }, null, 6)
1947
+ ], 2),
1948
+ v("div", Ro, [
1949
+ v("div", To, R(m.label), 1),
1950
+ v("div", Lo, R(m.value), 1)
1951
+ ])
1952
+ ]))), 128))
1953
+ ])) : S("", !0)
1954
+ ]),
1955
+ y.value === "table" ? (s(), c("div", No, [
1956
+ W(g(bt), {
1957
+ value: e.crud.items.value,
1958
+ loading: e.crud.loading.value,
1959
+ "expanded-rows": i.value,
1960
+ "onUpdate:expandedRows": h[4] || (h[4] = (m) => i.value = m),
1961
+ paginator: "",
1962
+ rows: e.crud.pagination.pageSize,
1963
+ "total-records": e.crud.pagination.rows,
1964
+ "rows-per-page-options": [10, 20, 50],
1965
+ "paginator-template": "CurrentPageReport PrevPageLink NextPageLink",
1966
+ "current-page-report-template": "Página {currentPage} de {totalPages}",
1967
+ pt: { pcPaginator: { root: { class: "w-crud-paginator" } } },
1968
+ lazy: "",
1969
+ "striped-rows": "",
1970
+ "removable-sort": "",
1971
+ size: "small",
1972
+ "sort-field": e.crud.sort.field ?? void 0,
1973
+ "sort-order": e.crud.sort.order,
1974
+ "data-key": e.crud.config.pk || "id",
1975
+ onPage: e.crud.onPage,
1976
+ onSort: h[5] || (h[5] = (m) => e.crud.onSort({ sortField: m.sortField, sortOrder: m.sortOrder })),
1977
+ onRowExpand: h[6] || (h[6] = (m) => o("row-expand", m.data)),
1978
+ onRowCollapse: h[7] || (h[7] = (m) => o("row-collapse", m.data))
1979
+ }, nt({
1980
+ header: te(() => [
1981
+ v("div", Yo, [
1982
+ v("div", zo, [
1983
+ e.showSearch ? (s(), I(g(Ue), { key: 0 }, {
1984
+ default: te(() => [
1985
+ W(g(_e), { class: "pi pi-search" }),
1986
+ W(g(ce), {
1987
+ "model-value": e.crud.search.value,
1988
+ placeholder: "Buscar...",
1989
+ class: "w-72",
1990
+ onInput: e.crud.onSearch
1991
+ }, null, 8, ["model-value", "onInput"])
1992
+ ]),
1993
+ _: 1
1994
+ })) : S("", !0),
1995
+ O(w.$slots, "toolbar-start"),
1996
+ O(w.$slots, "toolbar-filters")
1997
+ ]),
1998
+ v("div", Wo, [
1999
+ O(w.$slots, "toolbar-actions"),
2000
+ e.viewToggle ? (s(), c("div", Oo, [
2001
+ W(g(oe), {
2002
+ icon: "pi pi-table",
2003
+ size: "small",
2004
+ text: !u("table"),
2005
+ outlined: u("table"),
2006
+ onClick: h[1] || (h[1] = (m) => k("table"))
2007
+ }, null, 8, ["text", "outlined"]),
2008
+ W(g(oe), {
2009
+ icon: "pi pi-th-large",
2010
+ size: "small",
2011
+ text: !u("cards"),
2012
+ outlined: u("cards"),
2013
+ onClick: h[2] || (h[2] = (m) => k("cards"))
2014
+ }, null, 8, ["text", "outlined"])
2015
+ ])) : S("", !0),
2016
+ !e.showHeader && j.value ? (s(), I(g(oe), {
2017
+ key: 1,
2018
+ label: "Novo",
2019
+ icon: "pi pi-plus",
2020
+ onClick: h[3] || (h[3] = (m) => e.crud.openCreateDialog())
2021
+ })) : S("", !0)
2022
+ ])
2023
+ ])
2024
+ ]),
2025
+ empty: te(() => [
2026
+ O(w.$slots, "empty", {}, () => [
2027
+ h[14] || (h[14] = v("div", { class: "w-crud-empty" }, [
2028
+ v("div", { class: "w-crud-empty-icon" }, [
2029
+ v("i", { class: "pi pi-inbox" })
2030
+ ]),
2031
+ v("p", { class: "w-crud-empty-title" }, "Nenhum registro encontrado"),
2032
+ v("p", { class: "w-crud-empty-text" }, "Tente ajustar sua busca ou crie um novo registro")
2033
+ ], -1))
2034
+ ])
2035
+ ]),
2036
+ default: te(() => [
2037
+ e.expandable ? (s(), I(g(Le), {
2038
+ key: 0,
2039
+ expander: "",
2040
+ style: { width: "3rem" }
2041
+ })) : S("", !0),
2042
+ (s(!0), c(le, null, se(P.value, (m) => (s(), I(g(Le), {
2043
+ key: m.field,
2044
+ field: m.field,
2045
+ header: m.header,
2046
+ sortable: m.sortable,
2047
+ style: Be(m.style),
2048
+ "header-class": B(m),
2049
+ "body-class": B(m)
2050
+ }, {
2051
+ body: te(({ data: A }) => [
2052
+ O(w.$slots, `column-${m.field}`, {
2053
+ data: A,
2054
+ value: A[m.field]
2055
+ }, () => [
2056
+ W(Xe, {
2057
+ column: m,
2058
+ value: A[m.field],
2059
+ "row-data": A
2060
+ }, null, 8, ["column", "value", "row-data"])
2061
+ ])
2062
+ ]),
2063
+ _: 2
2064
+ }, 1032, ["field", "header", "sortable", "style", "header-class", "body-class"]))), 128)),
2065
+ f.value ? (s(), I(g(Le), {
2066
+ key: 1,
2067
+ "header-class": "w-crud-actions-header",
2068
+ style: Be({ width: `${(Z.value.length + (g(l)["row-actions"] ? 1 : 0)) * 2.5 + 1}rem` })
2069
+ }, {
2070
+ body: te(({ data: m }) => [
2071
+ v("div", Bo, [
2072
+ (s(!0), c(le, null, se(Z.value, (A) => (s(), c(le, {
2073
+ key: A.action
2074
+ }, [
2075
+ $(A, m) ? Pe((s(), I(g(oe), {
2076
+ key: 0,
2077
+ icon: A.icon,
2078
+ text: "",
2079
+ rounded: "",
2080
+ size: "small",
2081
+ severity: A.severity,
2082
+ disabled: V(A, m),
2083
+ onClick: (L) => b(A, m)
2084
+ }, null, 8, ["icon", "severity", "disabled", "onClick"])), [
2085
+ [
2086
+ U,
2087
+ A.tooltip,
2088
+ void 0,
2089
+ { top: !0 }
2090
+ ]
2091
+ ]) : S("", !0)
2092
+ ], 64))), 128)),
2093
+ O(w.$slots, "row-actions", {
2094
+ data: m,
2095
+ crud: e.crud
2096
+ })
2097
+ ])
2098
+ ]),
2099
+ _: 3
2100
+ }, 8, ["style"])) : S("", !0)
2101
+ ]),
2102
+ _: 2
2103
+ }, [
2104
+ e.expandable ? {
2105
+ name: "expansion",
2106
+ fn: te((m) => [
2107
+ O(w.$slots, "expansion", {
2108
+ data: m.data
2109
+ })
2110
+ ]),
2111
+ key: "0"
2112
+ } : void 0
2113
+ ]), 1032, ["value", "loading", "expanded-rows", "rows", "total-records", "sort-field", "sort-order", "data-key", "onPage"])
2114
+ ])) : (s(), c("div", jo, [
2115
+ v("div", Uo, [
2116
+ v("div", _o, [
2117
+ e.showSearch ? (s(), I(g(Ue), { key: 0 }, {
2118
+ default: te(() => [
2119
+ W(g(_e), { class: "pi pi-search" }),
2120
+ W(g(ce), {
2121
+ "model-value": e.crud.search.value,
2122
+ placeholder: "Buscar...",
2123
+ class: "w-72",
2124
+ onInput: e.crud.onSearch
2125
+ }, null, 8, ["model-value", "onInput"])
2126
+ ]),
2127
+ _: 1
2128
+ })) : S("", !0),
2129
+ O(w.$slots, "toolbar-start"),
2130
+ O(w.$slots, "toolbar-filters")
2131
+ ]),
2132
+ v("div", qo, [
2133
+ O(w.$slots, "toolbar-actions"),
2134
+ e.viewToggle ? (s(), c("div", Ho, [
2135
+ W(g(oe), {
2136
+ icon: "pi pi-table",
2137
+ size: "small",
2138
+ text: !u("table"),
2139
+ outlined: u("table"),
2140
+ onClick: h[8] || (h[8] = (m) => k("table"))
2141
+ }, null, 8, ["text", "outlined"]),
2142
+ W(g(oe), {
2143
+ icon: "pi pi-th-large",
2144
+ size: "small",
2145
+ text: !u("cards"),
2146
+ outlined: u("cards"),
2147
+ onClick: h[9] || (h[9] = (m) => k("cards"))
2148
+ }, null, 8, ["text", "outlined"])
2149
+ ])) : S("", !0),
2150
+ !e.showHeader && j.value ? (s(), I(g(oe), {
2151
+ key: 1,
2152
+ label: "Novo",
2153
+ icon: "pi pi-plus",
2154
+ onClick: h[10] || (h[10] = (m) => e.crud.openCreateDialog())
2155
+ })) : S("", !0)
2156
+ ])
2157
+ ]),
2158
+ e.crud.loading.value ? (s(), c("div", Ko, [...h[15] || (h[15] = [
2159
+ v("i", { class: "pi pi-spin pi-spinner" }, null, -1)
2160
+ ])])) : e.crud.items.value.length ? (s(), c("div", Go, [
2161
+ (s(!0), c(le, null, se(e.crud.items.value, (m, A) => (s(), c("div", {
2162
+ key: m[e.crud.config.pk || "id"] ?? A,
2163
+ class: "w-crud-card",
2164
+ onDblclick: (L) => e.crud.config.canEdit !== !1 && e.crud.openEditDialog(m)
2165
+ }, [
2166
+ v("div", Zo, [
2167
+ (s(!0), c(le, null, se(Y.value, (L, X) => (s(), c("div", {
2168
+ key: L.field,
2169
+ class: ue(["w-crud-card-row", { "w-crud-card-row--title": X === 0 }])
2170
+ }, [
2171
+ X !== 0 ? (s(), c("span", Xo, R(L.header), 1)) : S("", !0),
2172
+ v("span", Qo, [
2173
+ O(w.$slots, `column-${L.field}`, {
2174
+ data: m,
2175
+ value: m[L.field]
2176
+ }, () => [
2177
+ W(Xe, {
2178
+ column: L,
2179
+ value: m[L.field],
2180
+ "row-data": m
2181
+ }, null, 8, ["column", "value", "row-data"])
2182
+ ])
2183
+ ])
2184
+ ], 2))), 128))
2185
+ ]),
2186
+ f.value ? (s(), c("div", en, [
2187
+ (s(!0), c(le, null, se(Z.value, (L) => (s(), c(le, {
2188
+ key: L.action
2189
+ }, [
2190
+ $(L, m) ? Pe((s(), I(g(oe), {
2191
+ key: 0,
2192
+ icon: L.icon,
2193
+ text: "",
2194
+ rounded: "",
2195
+ size: "small",
2196
+ severity: L.severity,
2197
+ disabled: V(L, m),
2198
+ onClick: (X) => b(L, m)
2199
+ }, null, 8, ["icon", "severity", "disabled", "onClick"])), [
2200
+ [
2201
+ U,
2202
+ L.tooltip,
2203
+ void 0,
2204
+ { top: !0 }
2205
+ ]
2206
+ ]) : S("", !0)
2207
+ ], 64))), 128)),
2208
+ O(w.$slots, "row-actions", {
2209
+ data: m,
2210
+ crud: e.crud
2211
+ })
2212
+ ])) : S("", !0)
2213
+ ], 40, Jo))), 128))
2214
+ ])) : O(w.$slots, "empty", { key: 1 }, () => [
2215
+ h[16] || (h[16] = Ut('<div class="w-crud-empty"><div class="w-crud-empty-icon"><i class="pi pi-inbox"></i></div><p class="w-crud-empty-title">Nenhum registro encontrado</p><p class="w-crud-empty-text">Tente ajustar sua busca ou crie um novo registro</p></div>', 1))
2216
+ ]),
2217
+ e.crud.items.value.length ? (s(), I(g(_t), {
2218
+ key: 3,
2219
+ rows: e.crud.pagination.pageSize,
2220
+ "total-records": e.crud.pagination.rows,
2221
+ first: M.value,
2222
+ "rows-per-page-options": [10, 20, 50],
2223
+ template: "CurrentPageReport PrevPageLink NextPageLink",
2224
+ "current-page-report-template": "Página {currentPage} de {totalPages}",
2225
+ class: "w-crud-paginator",
2226
+ onPage: e.crud.onPage
2227
+ }, null, 8, ["rows", "total-records", "first", "onPage"])) : S("", !0)
2228
+ ])),
2229
+ O(w.$slots, "form-dialog", {
2230
+ crud: e.crud,
2231
+ dialogWidth: e.dialogWidth
2232
+ }, () => {
2233
+ var m;
2234
+ return [
2235
+ W(it, {
2236
+ visible: e.crud.dialogVisible.value,
2237
+ title: e.crud.dialogTitle.value,
2238
+ fields: e.crud.config.form,
2239
+ "form-data": e.crud.formData,
2240
+ "is-editing": e.crud.isEditing.value,
2241
+ saving: e.crud.saving.value,
2242
+ disabled: ((m = e.crud.viewMode) == null ? void 0 : m.value) ?? !1,
2243
+ width: e.dialogWidth,
2244
+ "onUpdate:visible": h[11] || (h[11] = (A) => {
2245
+ e.crud.dialogVisible.value = A, A || (e.crud.editingItem.value = null);
2246
+ }),
2247
+ "onUpdate:field": h[12] || (h[12] = (A, L) => e.crud.setFormField(A, L)),
2248
+ onSave: h[13] || (h[13] = (A) => e.crud.save())
2249
+ }, nt({ _: 2 }, [
2250
+ se(e.crud.config.form, (A) => ({
2251
+ name: `field-${A.field}`,
2252
+ fn: te((L) => [
2253
+ O(w.$slots, `field-${A.field}`, lt(st(L)))
2254
+ ])
2255
+ }))
2256
+ ]), 1032, ["visible", "title", "fields", "form-data", "is-editing", "saving", "disabled", "width"])
2257
+ ];
2258
+ })
2259
+ ]);
2260
+ };
2261
+ }
2262
+ }), an = /* @__PURE__ */ re({
2263
+ __name: "WStatusTag",
2264
+ props: {
2265
+ value: {},
2266
+ map: {}
2267
+ },
2268
+ setup(e) {
2269
+ const t = e, a = {
2270
+ ativo: { label: "Ativo", severity: "success" },
2271
+ ativa: { label: "Ativa", severity: "success" },
2272
+ inativo: { label: "Inativo", severity: "danger" },
2273
+ inativa: { label: "Inativa", severity: "danger" },
2274
+ suspensa: { label: "Suspensa", severity: "warn" },
2275
+ suspenso: { label: "Suspenso", severity: "warn" },
2276
+ cancelada: { label: "Cancelada", severity: "danger" },
2277
+ cancelado: { label: "Cancelado", severity: "danger" },
2278
+ pendente: { label: "Pendente", severity: "warn" },
2279
+ confirmada: { label: "Confirmada", severity: "success" },
2280
+ confirmado: { label: "Confirmado", severity: "success" },
2281
+ vencida: { label: "Vencida", severity: "danger" },
2282
+ vencido: { label: "Vencido", severity: "danger" },
2283
+ concluido: { label: "Concluído", severity: "success" },
2284
+ concluida: { label: "Concluída", severity: "success" },
2285
+ em_progresso: { label: "Em Progresso", severity: "info" },
2286
+ em_andamento: { label: "Em Andamento", severity: "info" },
2287
+ expirado: { label: "Expirado", severity: "secondary" },
2288
+ expirada: { label: "Expirada", severity: "secondary" },
2289
+ aberto: { label: "Aberto", severity: "info" },
2290
+ aberta: { label: "Aberta", severity: "info" },
2291
+ fechado: { label: "Fechado", severity: "secondary" },
2292
+ fechada: { label: "Fechada", severity: "secondary" },
2293
+ pago: { label: "Pago", severity: "success" },
2294
+ paga: { label: "Paga", severity: "success" },
2295
+ inadimplente: { label: "Inadimplente", severity: "danger" }
2296
+ }, o = q(() => (t.map ?? a)[t.value] ?? { label: t.value, severity: "secondary" });
2297
+ return (l, r) => (s(), I(g(wt), {
2298
+ value: o.value.label,
2299
+ severity: o.value.severity
2300
+ }, null, 8, ["value", "severity"]));
2301
+ }
2302
+ }), on = { class: "w-page-header" }, nn = { class: "w-page-header-content" }, ln = { class: "w-page-header-title" }, sn = {
2303
+ key: 0,
2304
+ class: "w-page-header-subtitle"
2305
+ }, rn = { class: "w-page-header-actions" }, Yl = /* @__PURE__ */ re({
2306
+ __name: "WPageHeader",
2307
+ props: {
2308
+ title: {},
2309
+ subtitle: {},
2310
+ actionLabel: {},
2311
+ actionIcon: {}
2312
+ },
2313
+ emits: ["action"],
2314
+ setup(e, { emit: t }) {
2315
+ const a = t;
2316
+ return (o, l) => (s(), c("div", on, [
2317
+ v("div", nn, [
2318
+ v("h2", ln, R(e.title), 1),
2319
+ e.subtitle ? (s(), c("p", sn, R(e.subtitle), 1)) : S("", !0)
2320
+ ]),
2321
+ v("div", rn, [
2322
+ O(o.$slots, "actions"),
2323
+ e.actionLabel ? (s(), I(g(oe), {
2324
+ key: 0,
2325
+ label: e.actionLabel,
2326
+ icon: e.actionIcon,
2327
+ onClick: l[0] || (l[0] = (r) => a("action"))
2328
+ }, null, 8, ["label", "icon"])) : S("", !0)
2329
+ ])
2330
+ ]));
2331
+ }
2332
+ }), un = { class: "w-empty-state" }, dn = { class: "w-empty-state-icon" }, cn = { class: "w-empty-state-title" }, fn = {
2333
+ key: 0,
2334
+ class: "w-empty-state-description"
2335
+ }, zl = /* @__PURE__ */ re({
2336
+ __name: "WEmptyState",
2337
+ props: {
2338
+ icon: {},
2339
+ title: {},
2340
+ description: {},
2341
+ actionLabel: {},
2342
+ actionIcon: {}
2343
+ },
2344
+ emits: ["action"],
2345
+ setup(e, { emit: t }) {
2346
+ const a = t;
2347
+ return (o, l) => (s(), c("div", un, [
2348
+ v("div", dn, [
2349
+ v("i", {
2350
+ class: ue(e.icon)
2351
+ }, null, 2)
2352
+ ]),
2353
+ v("p", cn, R(e.title), 1),
2354
+ e.description ? (s(), c("p", fn, R(e.description), 1)) : S("", !0),
2355
+ e.actionLabel ? (s(), I(g(oe), {
2356
+ key: 1,
2357
+ label: e.actionLabel,
2358
+ icon: e.actionIcon,
2359
+ size: "small",
2360
+ class: "mt-3",
2361
+ onClick: l[0] || (l[0] = (r) => a("action"))
2362
+ }, null, 8, ["label", "icon"])) : S("", !0)
2363
+ ]));
2364
+ }
2365
+ });
2366
+ /*!
2367
+ * vue-router v4.6.4
2368
+ * (c) 2025 Eduardo San Martin Morote
2369
+ * @license MIT
2370
+ */
2371
+ Symbol(process.env.NODE_ENV !== "production" ? "navigation failure" : "");
2372
+ Symbol(process.env.NODE_ENV !== "production" ? "router view location matched" : "");
2373
+ Symbol(process.env.NODE_ENV !== "production" ? "router view depth" : "");
2374
+ const mn = Symbol(process.env.NODE_ENV !== "production" ? "router" : "");
2375
+ Symbol(process.env.NODE_ENV !== "production" ? "route location" : "");
2376
+ Symbol(process.env.NODE_ENV !== "production" ? "router view location" : "");
2377
+ /*!
2378
+ * vue-router v4.6.4
2379
+ * (c) 2025 Eduardo San Martin Morote
2380
+ * @license MIT
2381
+ */
2382
+ function pn() {
2383
+ return Ie(mn);
2384
+ }
2385
+ const vn = { class: "w-detail-header" }, gn = { class: "w-detail-header-left" }, hn = { class: "w-detail-header-content" }, yn = { class: "w-detail-header-title" }, bn = {
2386
+ key: 0,
2387
+ class: "w-detail-header-subtitle"
2388
+ }, wn = { class: "w-detail-header-actions" }, Wl = /* @__PURE__ */ re({
2389
+ __name: "WDetailHeader",
2390
+ props: {
2391
+ title: {},
2392
+ subtitle: {},
2393
+ icon: {},
2394
+ backRoute: {},
2395
+ backTo: {},
2396
+ status: {},
2397
+ statusMap: {}
2398
+ },
2399
+ setup(e) {
2400
+ const t = e, a = pn();
2401
+ function o() {
2402
+ t.backTo ? a.push(typeof t.backTo == "string" ? { name: t.backTo } : t.backTo) : t.backRoute ? a.push({ name: t.backRoute }) : a.back();
2403
+ }
2404
+ return (l, r) => (s(), c("div", vn, [
2405
+ v("div", gn, [
2406
+ W(g(oe), {
2407
+ icon: "pi pi-arrow-left",
2408
+ text: "",
2409
+ rounded: "",
2410
+ onClick: o
2411
+ }),
2412
+ e.icon ? (s(), c("i", {
2413
+ key: 0,
2414
+ class: ue([e.icon, "w-detail-header-icon"])
2415
+ }, null, 2)) : S("", !0),
2416
+ v("div", hn, [
2417
+ v("h2", yn, R(e.title), 1),
2418
+ e.subtitle ? (s(), c("p", bn, R(e.subtitle), 1)) : S("", !0)
2419
+ ]),
2420
+ e.status ? (s(), I(an, {
2421
+ key: 1,
2422
+ value: e.status,
2423
+ map: e.statusMap
2424
+ }, null, 8, ["value", "map"])) : S("", !0)
2425
+ ]),
2426
+ v("div", wn, [
2427
+ O(l.$slots, "actions")
2428
+ ])
2429
+ ]));
2430
+ }
2431
+ }), kn = { class: "w-info-card" }, $n = {
2432
+ key: 0,
2433
+ class: "w-info-card-title"
2434
+ }, Dn = { class: "w-info-card-grid" }, Cn = { class: "w-info-card-label" }, Sn = { class: "w-info-card-value" }, Ol = /* @__PURE__ */ re({
2435
+ __name: "WInfoCard",
2436
+ props: {
2437
+ title: {},
2438
+ fields: {}
2439
+ },
2440
+ setup(e) {
2441
+ const { formatCurrency: t, formatDate: a, formatNumber: o } = rt();
2442
+ function l(r) {
2443
+ const i = r.value;
2444
+ return i == null || i === "" ? "-" : r.format === "currency" ? t(Number(i)) : r.format === "date" ? a(String(i)) : r.format === "datetime" ? a(String(i), "DD/MM/YYYY HH:mm") : r.format === "number" ? o(Number(i)) : String(i);
2445
+ }
2446
+ return (r, i) => (s(), c("div", kn, [
2447
+ e.title ? (s(), c("h3", $n, R(e.title), 1)) : S("", !0),
2448
+ v("div", Dn, [
2449
+ (s(!0), c(le, null, se(e.fields, (y) => (s(), c("div", {
2450
+ key: y.label,
2451
+ class: "w-info-card-field"
2452
+ }, [
2453
+ v("span", Cn, R(y.label), 1),
2454
+ v("span", Sn, R(l(y)), 1)
2455
+ ]))), 128))
2456
+ ])
2457
+ ]));
2458
+ }
2459
+ }), Pn = {
2460
+ key: 0,
2461
+ class: "w-kpi-card__loading"
2462
+ }, xn = { class: "w-kpi-card__loading-content" }, Vn = { class: "w-kpi-card__header" }, En = {
2463
+ key: 0,
2464
+ class: "w-kpi-card__icon"
2465
+ }, Mn = {
2466
+ key: 1,
2467
+ class: "w-kpi-card__trend"
2468
+ }, Fn = { class: "w-kpi-card__content" }, An = { class: "w-kpi-card__label" }, In = { class: "w-kpi-card__value" }, Rn = {
2469
+ key: 0,
2470
+ class: "w-kpi-card__hint"
2471
+ }, Tn = {
2472
+ key: 0,
2473
+ class: "w-kpi-card__footer"
2474
+ }, Ln = /* @__PURE__ */ re({
2475
+ __name: "WKpiCard",
2476
+ props: {
2477
+ label: {},
2478
+ value: {},
2479
+ icon: {},
2480
+ hint: {},
2481
+ severity: {},
2482
+ trend: {},
2483
+ loading: { type: Boolean }
2484
+ },
2485
+ setup(e) {
2486
+ return (t, a) => (s(), c("article", {
2487
+ class: ue(["w-kpi-card", e.severity ? `w-kpi-card--${e.severity}` : ""])
2488
+ }, [
2489
+ e.loading ? (s(), c("div", Pn, [
2490
+ W(g(Ke), {
2491
+ shape: "circle",
2492
+ size: "2.75rem"
2493
+ }),
2494
+ v("div", xn, [
2495
+ W(g(Ke), {
2496
+ width: "6rem",
2497
+ height: "0.75rem"
2498
+ }),
2499
+ W(g(Ke), {
2500
+ width: "7.5rem",
2501
+ height: "1.5rem"
2502
+ }),
2503
+ W(g(Ke), {
2504
+ width: "5rem",
2505
+ height: "0.75rem"
2506
+ })
2507
+ ])
2508
+ ])) : (s(), c(le, { key: 1 }, [
2509
+ v("div", Vn, [
2510
+ e.icon || t.$slots.icon ? (s(), c("div", En, [
2511
+ O(t.$slots, "icon", {}, () => [
2512
+ e.icon ? (s(), c("i", {
2513
+ key: 0,
2514
+ class: ue(e.icon)
2515
+ }, null, 2)) : S("", !0)
2516
+ ])
2517
+ ])) : S("", !0),
2518
+ e.trend || t.$slots.trend ? (s(), c("div", Mn, [
2519
+ O(t.$slots, "trend", {}, () => [
2520
+ e.trend ? (s(), c("span", {
2521
+ key: 0,
2522
+ class: ue(["w-kpi-card__trend-badge", e.trend.direction ? `w-kpi-card__trend-badge--${e.trend.direction}` : ""])
2523
+ }, R(e.trend.value), 3)) : S("", !0)
2524
+ ])
2525
+ ])) : S("", !0)
2526
+ ]),
2527
+ v("div", Fn, [
2528
+ v("p", An, R(e.label), 1),
2529
+ v("div", In, [
2530
+ O(t.$slots, "value", {}, () => [
2531
+ xe(R(e.value), 1)
2532
+ ])
2533
+ ]),
2534
+ e.hint || t.$slots.hint ? (s(), c("p", Rn, [
2535
+ O(t.$slots, "hint", {}, () => [
2536
+ xe(R(e.hint), 1)
2537
+ ])
2538
+ ])) : S("", !0)
2539
+ ]),
2540
+ t.$slots.footer ? (s(), c("footer", Tn, [
2541
+ O(t.$slots, "footer")
2542
+ ])) : S("", !0)
2543
+ ], 64))
2544
+ ], 2));
2545
+ }
2546
+ }), Bl = /* @__PURE__ */ re({
2547
+ __name: "WKpiGrid",
2548
+ props: {
2549
+ items: { default: () => [] },
2550
+ columns: { default: 4 },
2551
+ dense: { type: Boolean, default: !1 }
2552
+ },
2553
+ setup(e) {
2554
+ const t = e, a = q(() => [
2555
+ `w-kpi-grid--cols-${t.columns}`,
2556
+ { "w-kpi-grid--dense": t.dense }
2557
+ ]);
2558
+ return (o, l) => (s(), c("div", {
2559
+ class: ue(["w-kpi-grid", a.value])
2560
+ }, [
2561
+ o.$slots.item ? (s(!0), c(le, { key: 0 }, se(e.items, (r, i) => O(o.$slots, "item", {
2562
+ key: i,
2563
+ item: r,
2564
+ index: i
2565
+ })), 128)) : (s(!0), c(le, { key: 1 }, se(e.items, (r, i) => (s(), I(Ln, {
2566
+ key: i,
2567
+ label: r.label,
2568
+ value: r.value,
2569
+ icon: r.icon,
2570
+ severity: r.severity || "primary",
2571
+ hint: r.hint,
2572
+ trend: r.trend,
2573
+ loading: r.loading
2574
+ }, null, 8, ["label", "value", "icon", "severity", "hint", "trend", "loading"]))), 128))
2575
+ ], 2));
2576
+ }
2577
+ }), Nn = { class: "w-section-header__main" }, Yn = {
2578
+ key: 0,
2579
+ class: "w-section-header__icon"
2580
+ }, zn = { class: "w-section-header__content" }, Wn = { class: "w-section-header__title-row" }, On = { class: "w-section-header__title" }, Bn = {
2581
+ key: 0,
2582
+ class: "w-section-header__subtitle"
2583
+ }, jn = {
2584
+ key: 0,
2585
+ class: "w-section-header__actions"
2586
+ }, jl = /* @__PURE__ */ re({
2587
+ __name: "WSectionHeader",
2588
+ props: {
2589
+ title: {},
2590
+ subtitle: {},
2591
+ icon: {},
2592
+ compact: { type: Boolean }
2593
+ },
2594
+ setup(e) {
2595
+ return (t, a) => (s(), c("div", {
2596
+ class: ue(["w-section-header", { "w-section-header--compact": e.compact }])
2597
+ }, [
2598
+ v("div", Nn, [
2599
+ e.icon || t.$slots.icon ? (s(), c("div", Yn, [
2600
+ O(t.$slots, "icon", {}, () => [
2601
+ e.icon ? (s(), c("i", {
2602
+ key: 0,
2603
+ class: ue(e.icon)
2604
+ }, null, 2)) : S("", !0)
2605
+ ])
2606
+ ])) : S("", !0),
2607
+ v("div", zn, [
2608
+ v("div", Wn, [
2609
+ v("h3", On, R(e.title), 1),
2610
+ O(t.$slots, "meta")
2611
+ ]),
2612
+ e.subtitle ? (s(), c("p", Bn, R(e.subtitle), 1)) : S("", !0)
2613
+ ])
2614
+ ]),
2615
+ t.$slots.actions ? (s(), c("div", jn, [
2616
+ O(t.$slots, "actions")
2617
+ ])) : S("", !0)
2618
+ ], 2));
2619
+ }
2620
+ }), Un = {
2621
+ key: 0,
2622
+ class: "w-form-section__header"
2623
+ }, _n = { class: "w-form-section__content" }, qn = { class: "w-form-section__title" }, Hn = {
2624
+ key: 0,
2625
+ class: "w-form-section__description"
2626
+ }, Kn = {
2627
+ key: 0,
2628
+ class: "w-form-section__actions"
2629
+ }, Gn = { class: "w-form-section__body" }, Ul = /* @__PURE__ */ re({
2630
+ __name: "WFormSection",
2631
+ props: {
2632
+ title: {},
2633
+ description: {},
2634
+ variant: {}
2635
+ },
2636
+ setup(e) {
2637
+ return (t, a) => (s(), c("section", {
2638
+ class: ue(["w-form-section", e.variant ? `w-form-section--${e.variant}` : ""])
2639
+ }, [
2640
+ e.title || e.description || t.$slots.actions ? (s(), c("div", Un, [
2641
+ v("div", _n, [
2642
+ v("h3", qn, R(e.title), 1),
2643
+ e.description ? (s(), c("p", Hn, R(e.description), 1)) : S("", !0)
2644
+ ]),
2645
+ t.$slots.actions ? (s(), c("div", Kn, [
2646
+ O(t.$slots, "actions")
2647
+ ])) : S("", !0)
2648
+ ])) : S("", !0),
2649
+ v("div", Gn, [
2650
+ O(t.$slots, "default")
2651
+ ])
2652
+ ], 2));
2653
+ }
2654
+ }), Jn = {
2655
+ key: 0,
2656
+ class: "w-action-bar__primary"
2657
+ }, Zn = {
2658
+ key: 1,
2659
+ class: "w-action-bar__filters"
2660
+ }, Xn = {
2661
+ key: 2,
2662
+ class: "w-action-bar__secondary"
2663
+ }, _l = /* @__PURE__ */ re({
2664
+ __name: "WActionBar",
2665
+ props: {
2666
+ align: { default: "between" },
2667
+ stackOnMobile: { type: Boolean, default: !0 }
2668
+ },
2669
+ setup(e) {
2670
+ return (t, a) => (s(), c("div", {
2671
+ class: ue(["w-action-bar", [
2672
+ `w-action-bar--${e.align}`,
2673
+ { "w-action-bar--stack": e.stackOnMobile }
2674
+ ]])
2675
+ }, [
2676
+ t.$slots.primary || t.$slots.default ? (s(), c("div", Jn, [
2677
+ O(t.$slots, "primary", {}, () => [
2678
+ O(t.$slots, "default")
2679
+ ])
2680
+ ])) : S("", !0),
2681
+ t.$slots.filters ? (s(), c("div", Zn, [
2682
+ O(t.$slots, "filters")
2683
+ ])) : S("", !0),
2684
+ t.$slots.secondary ? (s(), c("div", Xn, [
2685
+ O(t.$slots, "secondary")
2686
+ ])) : S("", !0)
2687
+ ], 2));
2688
+ }
2689
+ }), Qn = { class: "w-progress-flow__marker" }, el = { class: "w-progress-flow__content" }, tl = { class: "w-progress-flow__label" }, al = {
2690
+ key: 0,
2691
+ class: "w-progress-flow__description"
2692
+ }, ql = /* @__PURE__ */ re({
2693
+ __name: "WProgressFlow",
2694
+ props: {
2695
+ steps: {},
2696
+ currentStep: {},
2697
+ orientation: { default: "horizontal" }
2698
+ },
2699
+ setup(e) {
2700
+ const t = e, a = q(
2701
+ () => t.steps.findIndex((l) => l.key === t.currentStep)
2702
+ );
2703
+ function o(l) {
2704
+ return l < a.value ? "done" : l === a.value ? "current" : "pending";
2705
+ }
2706
+ return (l, r) => (s(), c("div", {
2707
+ class: ue(["w-progress-flow", `w-progress-flow--${e.orientation}`])
2708
+ }, [
2709
+ (s(!0), c(le, null, se(e.steps, (i, y) => (s(), c("div", {
2710
+ key: i.key,
2711
+ class: ue(["w-progress-flow__step", `w-progress-flow__step--${o(y)}`])
2712
+ }, [
2713
+ O(l.$slots, "step", {
2714
+ step: i,
2715
+ index: y,
2716
+ state: o(y)
2717
+ }, () => [
2718
+ v("div", Qn, [
2719
+ v("span", null, R(y + 1), 1)
2720
+ ]),
2721
+ v("div", el, [
2722
+ v("p", tl, R(i.label), 1),
2723
+ i.description ? (s(), c("p", al, R(i.description), 1)) : S("", !0)
2724
+ ])
2725
+ ])
2726
+ ], 2))), 128))
2727
+ ], 2));
2728
+ }
2729
+ });
2730
+ function ol(e, t, a) {
2731
+ const o = e;
2732
+ return Array.isArray(o.results) ? {
2733
+ data: o.results,
2734
+ page: o.page ?? t,
2735
+ page_size: o.page_size ?? a,
2736
+ rows: o.count ?? 0,
2737
+ extras: o.extras ?? {}
2738
+ } : Array.isArray(o.data) ? {
2739
+ data: o.data,
2740
+ page: o.page ?? t,
2741
+ page_size: o.page_size ?? a,
2742
+ rows: o.rows ?? 0,
2743
+ extras: o.extras ?? {}
2744
+ } : {
2745
+ data: Array.isArray(e) ? e : [],
2746
+ page: t,
2747
+ page_size: a,
2748
+ rows: Array.isArray(e) ? e.length : 0,
2749
+ extras: {}
2750
+ };
2751
+ }
2752
+ function nl(e) {
2753
+ return {
2754
+ async list(t, a = {}) {
2755
+ const o = await e.get(t, { params: a });
2756
+ return ol(
2757
+ o.data,
2758
+ Number(a.page ?? 1),
2759
+ Number(a.page_size ?? 20)
2760
+ );
2761
+ },
2762
+ async get(t, a, o) {
2763
+ return { data: (await e.get(`${t}${a}/`, o)).data };
2764
+ },
2765
+ async create(t, a, o) {
2766
+ return { data: (await e.post(t, a, o)).data };
2767
+ },
2768
+ async update(t, a, o, l) {
2769
+ return { data: (await e.patch(
2770
+ `${t}${a}/`,
2771
+ o,
2772
+ l
2773
+ )).data };
2774
+ },
2775
+ async delete(t, a) {
2776
+ await e.delete(`${t}${a}/`);
2777
+ }
2778
+ };
2779
+ }
2780
+ const Hl = {
2781
+ install(e, t) {
2782
+ if (!(t != null && t.axios) && !(t != null && t.dataProvider))
2783
+ throw new Error(
2784
+ '[wPrimeVueComponents] Informe "axios" ou "dataProvider" ao registrar o WPrimeVuePlugin.'
2785
+ );
2786
+ const a = t.dataProvider ?? nl(t.axios), o = {
2787
+ axios: t.axios,
2788
+ dataProvider: a,
2789
+ defaultPageSize: t.defaultPageSize ?? 20,
2790
+ dateFormat: t.dateFormat ?? "DD/MM/YYYY",
2791
+ dateTimeFormat: t.dateTimeFormat ?? "DD/MM/YYYY HH:mm",
2792
+ locale: t.locale ?? "pt-BR",
2793
+ currency: t.currency ?? "BRL"
2794
+ };
2795
+ t.axios && e.provide(ea, t.axios), e.provide(Qe, a), e.provide(et, o), t.registerComponents !== !1 && (e.component("WCrudView", tn), e.component("WCrudFormDialog", it), e.component("WCrudColumnRenderer", Xe), e.component("WAutoCompleteFK", Rt), e.component("WMoneyInput", Tt), e.component("WTransferList", Lt));
2796
+ }
2797
+ }, ll = {
2798
+ createTitle: "Novo Registro",
2799
+ editTitle: "Editar Registro",
2800
+ createButton: "Novo",
2801
+ saveButton: "Salvar",
2802
+ updateButton: "Atualizar",
2803
+ cancelButton: "Cancelar",
2804
+ deleteConfirmTitle: "Confirmar Exclusão",
2805
+ deleteConfirmMessage: "Deseja realmente excluir este registro?",
2806
+ searchPlaceholder: "Buscar...",
2807
+ emptyMessage: "Nenhum registro encontrado",
2808
+ successCreate: "Registro criado com sucesso",
2809
+ successUpdate: "Registro atualizado com sucesso",
2810
+ successDelete: "Registro excluído com sucesso"
2811
+ };
2812
+ function sl(e, t) {
2813
+ const a = {};
2814
+ for (const o of Object.keys(t))
2815
+ JSON.stringify(e[o]) !== JSON.stringify(t[o]) && (a[o] = t[o]);
2816
+ return a;
2817
+ }
2818
+ function Kl(e) {
2819
+ const {
2820
+ endpoint: t,
2821
+ columns: a,
2822
+ form: o,
2823
+ pk: l = "id",
2824
+ searchDebounce: r = 300,
2825
+ partialUpdate: i = !0,
2826
+ canCreate: y = !0,
2827
+ canEdit: u = !0,
2828
+ canDelete: k = !0,
2829
+ rowActions: M = void 0,
2830
+ filterParams: P = void 0,
2831
+ createDefaults: B = void 0,
2832
+ transformPayload: Y = void 0,
2833
+ onAfterSave: G = void 0,
2834
+ onAfterDelete: Z = void 0
2835
+ } = e, f = Ie(Qe);
2836
+ if (!f)
2837
+ throw new Error(
2838
+ "[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin antes de usar useCrudManager."
2839
+ );
2840
+ const b = f, $ = Ie(et), V = e.pageSize ?? ($ == null ? void 0 : $.defaultPageSize) ?? 20, T = { ...ll, ...e.labels }, j = At(), { confirmDelete: w } = It(), h = K([]), U = K({}), m = K(!1), A = K(!1), L = K(""), X = K(!1), d = K(!1), E = K(null), F = ve({});
2841
+ let n = null;
2842
+ const p = ve({
2843
+ page: 1,
2844
+ pageSize: V,
2845
+ rows: 0,
2846
+ totalPages: 0
2847
+ }), J = ve({
2848
+ field: null,
2849
+ order: 0
2850
+ });
2851
+ function ne() {
2852
+ const x = {};
2853
+ for (const N of o)
2854
+ x[N.field] = N.defaultValue !== void 0 ? typeof N.defaultValue == "function" ? N.defaultValue() : N.defaultValue : null;
2855
+ return x;
2856
+ }
2857
+ const Q = ne();
2858
+ for (const x of Object.keys(Q))
2859
+ F[x] = Q[x];
2860
+ const _ = q(
2861
+ () => E.value !== null && !d.value
2862
+ ), de = q(() => d.value), me = q(
2863
+ () => d.value ? T.viewTitle ?? "Visualizar Registro" : _.value ? T.editTitle : T.createTitle
2864
+ ), Ne = q(() => p.page <= 1), Ye = q(() => p.page >= p.totalPages);
2865
+ let ge = null;
2866
+ async function fe(x = {}) {
2867
+ m.value = !0;
2868
+ try {
2869
+ const N = {
2870
+ page: p.page,
2871
+ page_size: p.pageSize,
2872
+ ...x
2873
+ };
2874
+ L.value && (N.search = L.value), J.field && J.order !== 0 && (N.ordering = J.order === -1 ? `-${J.field}` : J.field), P && Object.assign(N, P());
2875
+ const H = await b.list(t, N);
2876
+ h.value = H.data, p.rows = H.rows, U.value = H.extras ?? {}, H.page && (p.page = H.page), H.page_size && (p.pageSize = H.page_size), p.totalPages = Math.ceil(p.rows / p.pageSize) || 0;
2877
+ } finally {
2878
+ m.value = !1;
2879
+ }
2880
+ }
2881
+ async function he() {
2882
+ await fe();
2883
+ }
2884
+ async function pe() {
2885
+ await fe();
2886
+ }
2887
+ function ye(x) {
2888
+ L.value = x, ge && clearTimeout(ge), ge = setTimeout(() => {
2889
+ p.page = 1, fe();
2890
+ }, r);
2891
+ }
2892
+ function Ee(x) {
2893
+ const N = x.target;
2894
+ ye(N.value);
2895
+ }
2896
+ function be(x) {
2897
+ p.page = x, fe();
2898
+ }
2899
+ function Me() {
2900
+ be(1);
2901
+ }
2902
+ function $e() {
2903
+ be(p.totalPages);
2904
+ }
2905
+ function De(x) {
2906
+ p.page = x.page + 1, p.pageSize = x.rows, fe();
2907
+ }
2908
+ function Fe(x) {
2909
+ J.field = x.sortField ?? null, J.order = x.sortOrder ?? 0, p.page = 1, fe();
2910
+ }
2911
+ function Ce() {
2912
+ const x = ne();
2913
+ for (const N of Object.keys(x))
2914
+ F[N] = x[N];
2915
+ }
2916
+ function Ae(x, N) {
2917
+ F[x] = N;
2918
+ }
2919
+ function D() {
2920
+ if (d.value = !1, E.value = null, n = null, Ce(), B) {
2921
+ const x = B();
2922
+ for (const [N, H] of Object.entries(x))
2923
+ F[N] = H;
2924
+ }
2925
+ X.value = !0;
2926
+ }
2927
+ function C(x) {
2928
+ const N = {};
2929
+ for (const H of o) {
2930
+ let ae = x[H.field] !== void 0 ? x[H.field] : null;
2931
+ ae && (H.type === "date" || H.type === "datetime") && typeof ae == "string" && (ae = Dt(ae)), F[H.field] = ae, N[H.field] = ae;
2932
+ }
2933
+ n = N;
2934
+ }
2935
+ function ee(x) {
2936
+ d.value = !1, E.value = x, C(x), X.value = !0;
2937
+ }
2938
+ function z(x) {
2939
+ d.value = !0, E.value = x, C(x), X.value = !0;
2940
+ }
2941
+ function ie(x) {
2942
+ const N = { ...x };
2943
+ for (const H of o) {
2944
+ const ae = N[H.field];
2945
+ if (H.type === "date" && ae instanceof Date ? N[H.field] = Ct(ae) : H.type === "datetime" && ae instanceof Date && (N[H.field] = St(ae)), H.type === "fk" && ae !== null && typeof ae == "object") {
2946
+ const He = H.optionValue || "id";
2947
+ N[H.field] = ae[He] ?? ae;
2948
+ }
2949
+ (H.type === "mask" || H.type === "cpf_cnpj") && typeof ae == "string" && (N[H.field] = Ve(ae));
2950
+ }
2951
+ return N;
2952
+ }
2953
+ async function Yt() {
2954
+ for (const x of o) {
2955
+ if (x.validate) {
2956
+ const N = x.validate(F[x.field]);
2957
+ if (N)
2958
+ return j.error(N), null;
2959
+ }
2960
+ if (x.required) {
2961
+ const N = F[x.field];
2962
+ if (N == null || N === "")
2963
+ return j.error(`${x.label} é obrigatório`), null;
2964
+ }
2965
+ }
2966
+ A.value = !0;
2967
+ try {
2968
+ let x = ie(F);
2969
+ if (!_.value && B && Object.assign(x, B()), _.value && i && n) {
2970
+ const we = ie(n);
2971
+ if (x = sl(we, x), Object.keys(x).length === 0 && !Y) {
2972
+ X.value = !1;
2973
+ const Se = E.value;
2974
+ return E.value = null, n = null, Se;
2975
+ }
2976
+ }
2977
+ Y && (x = Y(x, _.value));
2978
+ const N = o.some(
2979
+ (we) => we.type === "image" && x[we.field] instanceof File
2980
+ );
2981
+ let H = x, ae;
2982
+ if (N) {
2983
+ const we = new Set(
2984
+ o.filter((ke) => ke.type === "image").map((ke) => ke.field)
2985
+ ), Se = new FormData();
2986
+ for (const [ke, ze] of Object.entries(x))
2987
+ if (ze != null)
2988
+ if (ze instanceof File)
2989
+ Se.append(ke, ze);
2990
+ else {
2991
+ if (we.has(ke))
2992
+ continue;
2993
+ Se.append(ke, String(ze));
2994
+ }
2995
+ H = Se, ae = { "Content-Type": "multipart/form-data" };
2996
+ }
2997
+ const He = ae ? { headers: ae } : void 0;
2998
+ let Te;
2999
+ if (_.value && E.value) {
3000
+ const we = E.value[l];
3001
+ Te = await b.update(
3002
+ t,
3003
+ we,
3004
+ H,
3005
+ He
3006
+ );
3007
+ const Se = h.value.findIndex((ke) => ke[l] === we);
3008
+ Se !== -1 && (h.value[Se] = Te.data), j.success(T.successUpdate);
3009
+ } else
3010
+ Te = await b.create(t, H, He), h.value.unshift(Te.data), p.rows++, j.success(T.successCreate);
3011
+ return X.value = !1, E.value = null, n = null, G && G(Te.data, _.value), Te.data;
3012
+ } catch (x) {
3013
+ return j.error(qe(x, "Erro ao salvar registro")), null;
3014
+ } finally {
3015
+ A.value = !1;
3016
+ }
3017
+ }
3018
+ function zt(x) {
3019
+ w(async () => {
3020
+ try {
3021
+ const N = x[l];
3022
+ await b.delete(t, N);
3023
+ const H = h.value.findIndex((ae) => ae[l] === N);
3024
+ H !== -1 && (h.value.splice(H, 1), p.rows--), j.success(T.successDelete), Z && Z(x);
3025
+ } catch (N) {
3026
+ j.error(qe(N, "Erro ao excluir registro"));
3027
+ }
3028
+ }, T.deleteConfirmMessage);
3029
+ }
3030
+ return {
3031
+ items: h,
3032
+ extras: U,
3033
+ loading: m,
3034
+ saving: A,
3035
+ search: L,
3036
+ dialogVisible: X,
3037
+ editingItem: E,
3038
+ formData: F,
3039
+ pagination: p,
3040
+ sort: J,
3041
+ isEditing: _,
3042
+ isViewing: de,
3043
+ viewMode: d,
3044
+ dialogTitle: me,
3045
+ isFirstPage: Ne,
3046
+ isLastPage: Ye,
3047
+ init: he,
3048
+ fetchItems: fe,
3049
+ refresh: pe,
3050
+ setSearch: ye,
3051
+ onSearch: Ee,
3052
+ onPage: De,
3053
+ onSort: Fe,
3054
+ openCreateDialog: D,
3055
+ openEditDialog: ee,
3056
+ openViewDialog: z,
3057
+ save: Yt,
3058
+ confirmDelete: zt,
3059
+ setFormField: Ae,
3060
+ resetForm: Ce,
3061
+ goToPage: be,
3062
+ firstPage: Me,
3063
+ lastPage: $e,
3064
+ config: e
3065
+ };
3066
+ }
3067
+ function Gl(e) {
3068
+ const { endpoint: t, searchDebounce: a = 300, immediate: o = !1 } = e, l = Ie(Qe);
3069
+ if (!l)
3070
+ throw new Error(
3071
+ "[wPrimeVueComponents] dataProvider não encontrado. Registre o WPrimeVuePlugin antes de usar useApi."
3072
+ );
3073
+ const r = l, i = Ie(et), y = e.pageSize ?? (i == null ? void 0 : i.defaultPageSize) ?? 20, u = K([]), k = K(!1), M = K(""), P = K({}), B = ve({}), Y = ve({
3074
+ page: 1,
3075
+ pageSize: y,
3076
+ rows: 0,
3077
+ totalPages: 0
3078
+ }), G = ve({
3079
+ field: null,
3080
+ order: 0
3081
+ });
3082
+ let Z = null;
3083
+ async function f(h = {}) {
3084
+ k.value = !0;
3085
+ try {
3086
+ const U = {
3087
+ page: Y.page,
3088
+ page_size: Y.pageSize,
3089
+ ...h
3090
+ };
3091
+ M.value && (U.search = M.value), G.field && G.order !== 0 && (U.ordering = G.order === -1 ? `-${G.field}` : G.field);
3092
+ for (const [A, L] of Object.entries(B))
3093
+ L != null && L !== "" && (U[A] = L);
3094
+ const m = await r.list(t, U);
3095
+ u.value = m.data, Y.rows = m.rows, m.page && (Y.page = m.page), m.page_size && (Y.pageSize = m.page_size), Y.totalPages = Math.ceil(Y.rows / Y.pageSize) || 0, P.value = m.extras ?? {};
3096
+ } finally {
3097
+ k.value = !1;
3098
+ }
3099
+ }
3100
+ async function b() {
3101
+ await f();
3102
+ }
3103
+ function $(h) {
3104
+ M.value = h, Z && clearTimeout(Z), Z = setTimeout(() => {
3105
+ Y.page = 1, f();
3106
+ }, a);
3107
+ }
3108
+ function V(h, U) {
3109
+ B[h] = U, Y.page = 1, f();
3110
+ }
3111
+ function T() {
3112
+ for (const h of Object.keys(B))
3113
+ delete B[h];
3114
+ Y.page = 1, f();
3115
+ }
3116
+ function j(h) {
3117
+ Y.page = h.page + 1, Y.pageSize = h.rows, f();
3118
+ }
3119
+ function w(h) {
3120
+ G.field = h.sortField ?? null, G.order = h.sortOrder ?? 0, Y.page = 1, f();
3121
+ }
3122
+ return o && f(), {
3123
+ items: u,
3124
+ loading: k,
3125
+ search: M,
3126
+ pagination: Y,
3127
+ sort: G,
3128
+ extras: P,
3129
+ fetchItems: f,
3130
+ refresh: b,
3131
+ setSearch: $,
3132
+ setFilter: V,
3133
+ clearFilters: T,
3134
+ onPage: j,
3135
+ onSort: w
3136
+ };
3137
+ }
3138
+ function rl(e) {
3139
+ return e.split("?")[0].replace(/^\/+|\/+$/g, "").replace(/^api\/v\d+\//, "");
3140
+ }
3141
+ function il(e) {
3142
+ return typeof e == "string" ? { table: e } : e;
3143
+ }
3144
+ function Nt(e, t = 400) {
3145
+ return {
3146
+ response: {
3147
+ status: t,
3148
+ data: { detail: e }
3149
+ },
3150
+ message: e
3151
+ };
3152
+ }
3153
+ function ht(e) {
3154
+ if (e instanceof FormData)
3155
+ throw Nt(
3156
+ "SupabaseDataProvider nao envia FormData diretamente. Faça upload do arquivo no Storage e envie a URL/caminho no payload."
3157
+ );
3158
+ return e;
3159
+ }
3160
+ function We(e) {
3161
+ throw {
3162
+ response: {
3163
+ data: {
3164
+ detail: (e == null ? void 0 : e.message) ?? "Erro ao consultar Supabase",
3165
+ code: e == null ? void 0 : e.code,
3166
+ details: e == null ? void 0 : e.details,
3167
+ hint: e == null ? void 0 : e.hint
3168
+ }
3169
+ },
3170
+ message: (e == null ? void 0 : e.message) ?? "Erro ao consultar Supabase"
3171
+ };
3172
+ }
3173
+ function Oe(e, t) {
3174
+ var l, r;
3175
+ const a = rl(e), o = (l = t.resources) == null ? void 0 : l[a];
3176
+ if (o)
3177
+ return il(o);
3178
+ if ((r = t.allowedTables) != null && r.includes(a))
3179
+ return { table: a };
3180
+ throw Nt(
3181
+ `Recurso Supabase nao registrado para o endpoint "${e}".`,
3182
+ 404
3183
+ );
3184
+ }
3185
+ function ul(e, t, a) {
3186
+ const o = /* @__PURE__ */ new Set(["page", "page_size", "search", "ordering"]), l = { ...a.defaultFilters, ...t };
3187
+ for (const [r, i] of Object.entries(l))
3188
+ o.has(r) || i === null || i === void 0 || i === "" || (e = e.eq(r, i));
3189
+ return e;
3190
+ }
3191
+ function dl(e, t, a) {
3192
+ if (typeof t != "string" || !t.trim() || !(a != null && a.length))
3193
+ return e;
3194
+ const o = t.trim().replace(/,/g, "\\,"), l = a.map((r) => `${r}.ilike.%${o}%`).join(",");
3195
+ return e.or(l);
3196
+ }
3197
+ function cl(e, t) {
3198
+ const a = typeof e == "string" && e ? e : t;
3199
+ return a ? {
3200
+ field: a.startsWith("-") ? a.slice(1) : a,
3201
+ ascending: !a.startsWith("-")
3202
+ } : null;
3203
+ }
3204
+ function fl(e, t) {
3205
+ return e ? t.mapListItem ? e.map(
3206
+ (a) => {
3207
+ var o;
3208
+ return (o = t.mapListItem) == null ? void 0 : o.call(t, a);
3209
+ }
3210
+ ) : e : [];
3211
+ }
3212
+ function Jl(e) {
3213
+ const t = e.defaultSelect ?? "*";
3214
+ return {
3215
+ async list(a, o = {}) {
3216
+ var B;
3217
+ const l = Oe(a, e), r = Math.max(Number(o.page ?? 1), 1), i = Math.max(Number(o.page_size ?? 20), 1), y = (r - 1) * i, u = y + i - 1;
3218
+ let k = e.client.from(l.table).select(l.select ?? t, { count: "exact" });
3219
+ k = ul(k, o, l), k = dl(k, o.search, l.searchFields);
3220
+ const M = cl(o.ordering, l.defaultOrdering);
3221
+ M && (k = k.order(M.field, { ascending: M.ascending }));
3222
+ const P = await k.range(y, u);
3223
+ return P.error && We(P.error), {
3224
+ data: fl(P.data, l),
3225
+ page: r,
3226
+ page_size: i,
3227
+ rows: P.count ?? ((B = P.data) == null ? void 0 : B.length) ?? 0,
3228
+ extras: {}
3229
+ };
3230
+ },
3231
+ async get(a, o, l) {
3232
+ const r = Oe(a, e), i = r.pk ?? "id", y = await e.client.from(r.table).select(r.select ?? t).eq(i, o).single();
3233
+ return y.error && We(y.error), { data: y.data };
3234
+ },
3235
+ async create(a, o, l) {
3236
+ const r = Oe(a, e), i = ht(o), y = r.mapPayload ? r.mapPayload(i, "create") : i, u = await e.client.from(r.table).insert(y).select(r.select ?? t).single();
3237
+ return u.error && We(u.error), { data: u.data };
3238
+ },
3239
+ async update(a, o, l, r) {
3240
+ const i = Oe(a, e), y = i.pk ?? "id", u = ht(l), k = i.mapPayload ? i.mapPayload(u, "update") : u, M = await e.client.from(i.table).update(k).eq(y, o).select(i.select ?? t).single();
3241
+ return M.error && We(M.error), { data: M.data };
3242
+ },
3243
+ async delete(a, o) {
3244
+ const l = Oe(a, e), r = l.pk ?? "id", i = l.softDelete === !0 ? { is_active: !1 } : typeof l.softDelete == "object" ? l.softDelete : null, y = i ? await e.client.from(l.table).update(i).eq(r, o) : await e.client.from(l.table).delete().eq(r, o);
3245
+ y.error && We(y.error);
3246
+ }
3247
+ };
3248
+ }
3249
+ export {
3250
+ ll as DEFAULT_CRUD_LABELS,
3251
+ _l as WActionBar,
3252
+ Rt as WAutoCompleteFK,
3253
+ Xe as WCrudColumnRenderer,
3254
+ it as WCrudFormDialog,
3255
+ tn as WCrudView,
3256
+ Wl as WDetailHeader,
3257
+ zl as WEmptyState,
3258
+ So as WFormRenderer,
3259
+ Ul as WFormSection,
3260
+ Ol as WInfoCard,
3261
+ Ln as WKpiCard,
3262
+ Bl as WKpiGrid,
3263
+ Tt as WMoneyInput,
3264
+ Yl as WPageHeader,
3265
+ Hl as WPrimeVuePlugin,
3266
+ ql as WProgressFlow,
3267
+ jl as WSectionHeader,
3268
+ an as WStatusTag,
3269
+ Lt as WTransferList,
3270
+ ea as W_AXIOS_KEY,
3271
+ et as W_CONFIG_KEY,
3272
+ Qe as W_DATA_PROVIDER_KEY,
3273
+ nl as createAxiosDataProvider,
3274
+ Jl as createSupabaseDataProvider,
3275
+ qe as extractApiError,
3276
+ Aa as mapApiFieldToColumnDef,
3277
+ Ea as mapApiFieldToFieldDef,
3278
+ Ia as mapApiFieldsToColumnDefs,
3279
+ Ma as mapApiFieldsToFieldDefs,
3280
+ Gl as useApi,
3281
+ Nl as useApiError,
3282
+ It as useAppConfirm,
3283
+ At as useAppToast,
3284
+ Kl as useCrudManager,
3285
+ rt as useFormatters
3286
+ };
3287
+ //# sourceMappingURL=index.js.map