@fayz-ai/plugin-financial 0.29.1 → 0.29.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,11 +3,11 @@ export { FINANCIAL_INVOICE_ZONES } from './chunk-IQHWMVUM.js';
3
3
  import './chunk-7VKJLBYY.js';
4
4
  import { FINANCIAL_MODULE_DEFAULTS } from './chunk-POYZFEAN.js';
5
5
  import { FinancialContextProvider, useFinancialProvider, formatCurrency, useFinancialConfig, useFinancialStore } from './chunk-CNXAVGSW.js';
6
- import * as React5 from 'react';
7
- import React5__default, { useEffect } from 'react';
8
- import { CircleDollarSign, FileText, Search, X, ChevronsUpDown, ChevronsDownUp, Plus, ChevronRight, FolderOpen, Folder, Pencil, Ban, RotateCcw, Trash2, Wallet, ArrowUpRight, ArrowDownRight, AlertTriangle, EyeOff, Eye, CreditCard } from 'lucide-react';
6
+ import * as React3 from 'react';
7
+ import React3__default, { useEffect } from 'react';
8
+ import { CircleDollarSign, FileText, Wallet, ArrowUpRight, ArrowDownRight, AlertTriangle, EyeOff, Eye, CreditCard } from 'lucide-react';
9
9
  import { registerTranslations, tl, recordRailFields, RECORD_GROUP, activeFacet, lazyComponent, createConnectionStore, connectionSettings, connectionStatus, settingsStatus, connectionRuns, useTranslation, resolveDataProvider, emitDataChanged, registerMessageDefaults, countByTenant, onAppPathChange, resolveCurrency } from '@fayz-ai/core';
10
- import { Button, Badge, Input, ModalTask, Skeleton, SegmentedControl, PageHeaderActions, Checkbox, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SearchSelect, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalBody, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget, useDashboardNavigate, GoldCard } from '@fayz-ai/ui';
10
+ import { Button, Badge, Input, ModalTask, SegmentedControl, TreeManager, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, SearchSelect, toast, defineKpiWidget, defineChartWidget, defineCustomWidget, defineTableWidget, Modal, ModalContent, ModalHeader, ModalTitle, ModalDescription, ModalBody, KpiCard, ChartWidget, Card, CardHeader, CardTitle, CardContent, TableWidget, useDashboardNavigate, GoldCard } from '@fayz-ai/ui';
11
11
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
12
12
  import { createSafeFinancialProvider, createFinancialStore } from '@fayz-ai/financial/store';
13
13
  export { createSafeFinancialProvider } from '@fayz-ai/financial/store';
@@ -15,7 +15,7 @@ import { FINANCIAL_ZONES } from '@fayz-ai/financial/views/zones';
15
15
  import { draftAllProductsForPriceTable, addAllProductsToPriceTable, fayzConnectorOAuth, defineSettingsTab, RightRailPage, useConnectors, useConnectorsPanelAvailable, SettingsForm, ConnectorMark, StateChip, ConnectorDetail, usePermissionOptional, openConnectorsPanel, createCrudPage, PluginSettingsPanel, useTenantPluginSettings } from '@fayz-ai/admin';
16
16
  import { invoiceOpensForEditing } from '@fayz-ai/financial/domain/invoice';
17
17
  import { T } from '@fayz-ai/financial/data/tables';
18
- import { buildChartTree, rootIds, searchVisibleIds, isGroupNode, descendantIds, accountLabel, suggestNextCode, childIds } from '@fayz-ai/financial/domain/chart-of-accounts';
18
+ import { buildChartTree, isGroupNode, compareCodes, suggestNextCode, accountLabel, descendantIds, childIds } from '@fayz-ai/financial/domain/chart-of-accounts';
19
19
  import { useStore } from 'zustand';
20
20
  import { MIGRATIONS } from '#migrations/main';
21
21
  export { createMockFinancialProvider } from '@fayz-ai/financial/data/mock';
@@ -247,7 +247,7 @@ function RecentTransactions() {
247
247
  const t = useTranslation();
248
248
  const { currency } = useFinancialConfig();
249
249
  const provider = useFinancialProvider();
250
- const [invoices, setInvoices] = React5__default.useState([]);
250
+ const [invoices, setInvoices] = React3__default.useState([]);
251
251
  useEffect(() => {
252
252
  let alive = true;
253
253
  void provider.getInvoices({ ...RECENT_TRANSACTIONS_QUERY, dateRange: recentWindow() }).then((res) => {
@@ -290,7 +290,7 @@ function BalanceHero() {
290
290
  const summary = useFinancialStore((s) => s.summary);
291
291
  const navigate = useDashboardNavigate();
292
292
  useEnsureSummary();
293
- const [hidden, setHidden] = React5__default.useState(false);
293
+ const [hidden, setHidden] = React3__default.useState(false);
294
294
  const money = (v) => hidden ? "\u2022\u2022\u2022\u2022\u2022\u2022" : formatCurrency(v ?? 0, currency);
295
295
  const inflow = summary?.monthlyInflow ?? 0;
296
296
  const outflow = summary?.monthlyOutflow ?? 0;
@@ -369,7 +369,7 @@ function categorizeSpend(notes) {
369
369
  function SpendByCategoryChart() {
370
370
  const t = useTranslation();
371
371
  const provider = useFinancialProvider();
372
- const [rows, setRows] = React5__default.useState([]);
372
+ const [rows, setRows] = React3__default.useState([]);
373
373
  useEffect(() => {
374
374
  let alive = true;
375
375
  void (async () => {
@@ -412,7 +412,7 @@ function UpcomingBills() {
412
412
  const { currency } = useFinancialConfig();
413
413
  const provider = useFinancialProvider();
414
414
  const dueLabel = useDueLabel();
415
- const [bills, setBills] = React5__default.useState([]);
415
+ const [bills, setBills] = React3__default.useState([]);
416
416
  useEffect(() => {
417
417
  let alive = true;
418
418
  void (async () => {
@@ -884,6 +884,7 @@ var en = {
884
884
  "financial.invoice.filterLastMonth": "Last month",
885
885
  "financial.invoice.filterLast30": "Last 30 days",
886
886
  "financial.invoice.filterLast90": "Last 90 days",
887
+ "financial.invoice.filterIncludeOverdue": "Include earlier overdue",
887
888
  "financial.invoice.filterMaxRange": "90-day maximum range",
888
889
  "financial.invoice.filterThisYear": "This year",
889
890
  "financial.invoice.filterCustom": "Custom",
@@ -1906,6 +1907,7 @@ var ptBR = {
1906
1907
  "financial.invoice.filterLastMonth": "M\xEAs passado",
1907
1908
  "financial.invoice.filterLast30": "\xDAltimos 30 dias",
1908
1909
  "financial.invoice.filterLast90": "\xDAltimos 90 dias",
1910
+ "financial.invoice.filterIncludeOverdue": "Incluir vencidas anteriores",
1909
1911
  "financial.invoice.filterMaxRange": "Per\xEDodo m\xE1ximo de 90 dias",
1910
1912
  "financial.invoice.filterThisYear": "Este ano",
1911
1913
  "financial.invoice.filterCustom": "Personalizado",
@@ -2696,8 +2698,8 @@ function ReceivePaymentModal({
2696
2698
  onClose,
2697
2699
  onPaid
2698
2700
  }) {
2699
- const provider = React5__default.useMemo(() => createSafeFinancialProvider(), []);
2700
- const store6 = React5__default.useMemo(() => createFinancialStore(provider), [provider]);
2701
+ const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
2702
+ const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
2701
2703
  return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(
2702
2704
  PaymentModal,
2703
2705
  {
@@ -2731,27 +2733,27 @@ function ClientAccountPanel({
2731
2733
  currency = BRL
2732
2734
  }) {
2733
2735
  const provider = useFinancialProvider();
2734
- const [account, setAccount] = React5__default.useState(null);
2735
- const [busy, setBusy] = React5__default.useState(false);
2736
- const [viewInvoiceId, setViewInvoiceId] = React5__default.useState(null);
2737
- const [comprando, setComprando] = React5__default.useState(false);
2738
- const [buscaServico, setBuscaServico] = React5__default.useState("");
2739
- const [catalogo, setCatalogo] = React5__default.useState([]);
2740
- const [escolhidos, setEscolhidos] = React5__default.useState([]);
2741
- const [comprandoBusy, setComprandoBusy] = React5__default.useState(false);
2742
- const [erroCompra, setErroCompra] = React5__default.useState(null);
2743
- const load = React5__default.useCallback(async () => {
2736
+ const [account, setAccount] = React3__default.useState(null);
2737
+ const [busy, setBusy] = React3__default.useState(false);
2738
+ const [viewInvoiceId, setViewInvoiceId] = React3__default.useState(null);
2739
+ const [comprando, setComprando] = React3__default.useState(false);
2740
+ const [buscaServico, setBuscaServico] = React3__default.useState("");
2741
+ const [catalogo, setCatalogo] = React3__default.useState([]);
2742
+ const [escolhidos, setEscolhidos] = React3__default.useState([]);
2743
+ const [comprandoBusy, setComprandoBusy] = React3__default.useState(false);
2744
+ const [erroCompra, setErroCompra] = React3__default.useState(null);
2745
+ const load = React3__default.useCallback(async () => {
2744
2746
  if (!personId) return;
2745
2747
  setAccount(await provider.getClientAccount(personId));
2746
2748
  }, [personId, provider]);
2747
- React5__default.useEffect(() => {
2749
+ React3__default.useEffect(() => {
2748
2750
  void load();
2749
2751
  }, [load]);
2750
2752
  const viewInvoice = account?.invoices.find((i) => i.id === viewInvoiceId) ?? null;
2751
2753
  const viewEditable = invoiceOpensForEditing(viewInvoice?.status);
2752
2754
  const forThis = account?.invoices.filter((i) => orderId && i.orderId === orderId) ?? [];
2753
2755
  const hasForThis = forThis.length > 0;
2754
- React5__default.useEffect(() => {
2756
+ React3__default.useEffect(() => {
2755
2757
  if (!comprando) return;
2756
2758
  let vivo = true;
2757
2759
  const t = setTimeout(async () => {
@@ -3040,8 +3042,8 @@ function ClientAccountPanel({
3040
3042
  ] });
3041
3043
  }
3042
3044
  function ClientAccountInline(props) {
3043
- const provider = React5__default.useMemo(() => createSafeFinancialProvider(), []);
3044
- const store6 = React5__default.useMemo(() => createFinancialStore(provider), [provider]);
3045
+ const provider = React3__default.useMemo(() => createSafeFinancialProvider(), []);
3046
+ const store6 = React3__default.useMemo(() => createFinancialStore(provider), [provider]);
3045
3047
  return /* @__PURE__ */ jsx(FinancialContextProvider, { config: STANDALONE_CONFIG, provider, store: store6, children: /* @__PURE__ */ jsx(ClientAccountPanel, { ...props }) });
3046
3048
  }
3047
3049
  function ClientAccountModal({
@@ -3126,371 +3128,265 @@ function ChartOfAccountsTree({ entity, mockData, dataProvider, embedded }) {
3126
3128
  const canCreate = can("financial", "create");
3127
3129
  const canEdit = can("financial", "edit");
3128
3130
  const canDelete = can("financial", "delete");
3129
- const provider = React5__default.useMemo(
3131
+ const provider = React3__default.useMemo(
3130
3132
  () => dataProvider ?? resolveDataProvider(entity, mockData ?? []),
3131
3133
  [entity, mockData, dataProvider]
3132
3134
  );
3133
3135
  const table = entity.data?.table;
3134
- const [nodes, setNodes] = React5__default.useState(null);
3135
- const [loadError, setLoadError] = React5__default.useState(null);
3136
- const [expanded, setExpanded] = React5__default.useState(/* @__PURE__ */ new Set());
3137
- const [query, setQuery] = React5__default.useState("");
3138
- const [showInactive, setShowInactive] = React5__default.useState(true);
3139
- const [side, setSide] = React5__default.useState("in");
3140
- const [editing, setEditing] = React5__default.useState(null);
3141
- const [confirmDelete, setConfirmDelete] = React5__default.useState(null);
3142
- const [busy, setBusy] = React5__default.useState(false);
3143
- const initialized = React5__default.useRef(false);
3144
- const reload = React5__default.useCallback(async () => {
3136
+ const [nodes, setNodes] = React3__default.useState(null);
3137
+ const [loadError, setLoadError] = React3__default.useState(null);
3138
+ const [side, setSide] = React3__default.useState("in");
3139
+ const [editing, setEditing] = React3__default.useState(null);
3140
+ const [busy, setBusy] = React3__default.useState(false);
3141
+ const reload = React3__default.useCallback(async () => {
3145
3142
  try {
3146
- const rows = await loadAll(provider);
3147
- setNodes(rows);
3143
+ setNodes(await loadAll(provider));
3148
3144
  setLoadError(null);
3149
- if (!initialized.current) {
3150
- initialized.current = true;
3151
- const tree2 = buildChartTree(rows);
3152
- setExpanded(new Set(rootIds(tree2)));
3153
- }
3154
3145
  } catch (err) {
3155
3146
  setLoadError(errorMessage(err));
3156
3147
  setNodes((prev) => prev ?? []);
3157
3148
  }
3158
3149
  }, [provider]);
3159
- React5__default.useEffect(() => {
3150
+ React3__default.useEffect(() => {
3160
3151
  void reload();
3161
3152
  }, [reload]);
3162
- const shown = React5__default.useMemo(
3163
- () => onSide((nodes ?? []).filter((n) => showInactive || n.isActive), side),
3164
- [nodes, showInactive, side]
3165
- );
3166
- const tree = React5__default.useMemo(() => buildChartTree(shown), [shown]);
3167
- const fullTree = React5__default.useMemo(() => buildChartTree(nodes ?? []), [nodes]);
3168
- const search = React5__default.useMemo(() => searchVisibleIds(tree, query), [tree, query]);
3169
- const groupIds = React5__default.useMemo(
3170
- () => [...tree.byId.values()].filter((n) => isGroupNode(tree, n)).map((n) => n.id),
3171
- [tree]
3172
- );
3173
- function toggle(id) {
3174
- setExpanded((prev) => {
3175
- const next = new Set(prev);
3176
- if (next.has(id)) next.delete(id);
3177
- else next.add(id);
3178
- return next;
3179
- });
3153
+ const shown = React3__default.useMemo(() => nodes === null ? null : onSide(nodes, side), [nodes, side]);
3154
+ const fullTree = React3__default.useMemo(() => buildChartTree(nodes ?? []), [nodes]);
3155
+ async function run(action, success) {
3156
+ setBusy(true);
3157
+ try {
3158
+ await action();
3159
+ if (table) emitDataChanged({ table });
3160
+ toast.success(success);
3161
+ await reload();
3162
+ return true;
3163
+ } catch (err) {
3164
+ toast.error(t("financial.chartTree.error.save"), { description: errorMessage(err) });
3165
+ return false;
3166
+ } finally {
3167
+ setBusy(false);
3168
+ }
3180
3169
  }
3181
- function startCreate(parentId) {
3182
- const parent = parentId ? fullTree.byId.get(parentId) : void 0;
3183
- setConfirmDelete(null);
3184
- setEditing({
3185
- mode: "create",
3186
- parentId,
3187
- draft: {
3188
- code: suggestNextCode(fullTree, parentId),
3189
- name: "",
3190
- nodeType: "leaf",
3191
- accountType: parent?.accountType ?? SIDE_TYPE[side],
3192
- parentId
3170
+ const hasOther = (nodes ?? []).some((n) => sideOf(n.accountType) === "other");
3171
+ const plural = (one, many) => (n) => t(n === 1 ? one : many, { count: n });
3172
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
3173
+ /* @__PURE__ */ jsx(
3174
+ SegmentedControl,
3175
+ {
3176
+ value: side,
3177
+ onChange: (v) => {
3178
+ setSide(v);
3179
+ setEditing(null);
3180
+ },
3181
+ options: [
3182
+ { value: "in", label: tl("Income (in)", "Receitas (entradas)") },
3183
+ { value: "out", label: tl("Expenses (out)", "Despesas (sa\xEDdas)") },
3184
+ ...hasOther ? [{ value: "other", label: tl("Balance", "Patrimoniais") }] : []
3185
+ ]
3193
3186
  }
3194
- });
3195
- if (parentId) setExpanded((prev) => new Set(prev).add(parentId));
3196
- }
3197
- function startEdit(node) {
3198
- setConfirmDelete(null);
3199
- setEditing({
3200
- mode: "edit",
3201
- id: node.id,
3202
- draft: {
3187
+ ),
3188
+ /* @__PURE__ */ jsx(
3189
+ TreeManager,
3190
+ {
3191
+ nodes: shown,
3192
+ getId: (n) => n.id,
3193
+ getParentId: (n) => n.parentId,
3194
+ getName: (n) => n.name,
3195
+ getCode: (n) => n.code,
3196
+ isActive: (n) => n.isActive,
3197
+ compare: (a, b) => compareCodes(a.code, b.code),
3198
+ isGroup: (n, hasChildren) => n.nodeType === "group" || hasChildren,
3199
+ loadError: loadError ? `${t("financial.chartTree.error.load")} ${loadError}` : null,
3200
+ busy,
3201
+ embedded,
3202
+ canCreate,
3203
+ canEdit,
3204
+ canRemove: canDelete,
3205
+ canAddChild: (n) => n.isActive && isGroupNode(fullTree, n),
3206
+ canDeactivate: (_n, hasChildren) => !hasChildren,
3207
+ onSetActive: (node, isActive) => run(
3208
+ () => provider.update(node.id, { isActive }),
3209
+ t(isActive ? "financial.chartTree.reactivated" : "financial.chartTree.deactivated", { name: node.name })
3210
+ ),
3211
+ onDelete: (node) => run(() => provider.remove(node.id), t("financial.chartTree.deleted", { name: node.name })),
3212
+ editing,
3213
+ onEditingChange: setEditing,
3214
+ renderBadges: (n) => n.accountType && /* @__PURE__ */ jsx(Badge, { variant: NATURE_VARIANT[n.accountType] ?? "default", dot: false, children: t(`financial.chartTree.nature.${n.accountType}`) }),
3215
+ renderEditor: (ctx) => /* @__PURE__ */ jsx(
3216
+ AccountEditor,
3217
+ {
3218
+ ctx,
3219
+ nodes: nodes ?? [],
3220
+ fullTree,
3221
+ side,
3222
+ busy,
3223
+ onSave: (id, payload) => id ? run(() => provider.update(id, payload), t("financial.chartTree.updated", { name: payload.name })) : run(() => provider.create({ ...payload, isActive: true }), t("financial.chartTree.created", { name: payload.name }))
3224
+ }
3225
+ ),
3226
+ labels: {
3227
+ searchPlaceholder: t("financial.chartTree.searchPlaceholder"),
3228
+ clearSearch: t("financial.chartTree.clearSearch"),
3229
+ expandAll: t("financial.chartTree.expandAll"),
3230
+ collapseAll: t("financial.chartTree.collapseAll"),
3231
+ expand: t("financial.chartTree.expand"),
3232
+ collapse: t("financial.chartTree.collapse"),
3233
+ addRoot: t("financial.chartTree.addRoot"),
3234
+ addChild: t("financial.chartTree.addChild"),
3235
+ edit: t("financial.chartTree.edit"),
3236
+ deactivate: t("financial.chartTree.deactivate"),
3237
+ reactivate: t("financial.chartTree.reactivate"),
3238
+ delete: t("financial.chartTree.delete"),
3239
+ confirmDelete: t("financial.chartTree.confirmDelete"),
3240
+ cancel: t("financial.chartTree.cancel"),
3241
+ inactive: t("financial.chartTree.inactive"),
3242
+ empty: t("financial.chartTree.empty"),
3243
+ noMatches: t("financial.chartTree.noMatches"),
3244
+ tree: t("registry.chart-of-accounts"),
3245
+ count: plural("financial.chartTree.countOne", "financial.chartTree.count"),
3246
+ matches: plural("financial.chartTree.matchesOne", "financial.chartTree.matches"),
3247
+ showInactive: (n) => t("financial.chartTree.showInactive", { count: n })
3248
+ }
3249
+ }
3250
+ )
3251
+ ] });
3252
+ }
3253
+ function AccountEditor({ ctx, nodes, fullTree, side, busy, onSave }) {
3254
+ const t = useTranslation();
3255
+ const selfId = ctx.editing.mode === "edit" ? ctx.editing.id : void 0;
3256
+ const [draft, setDraft] = React3__default.useState(() => {
3257
+ const node = ctx.node;
3258
+ if (node) {
3259
+ return {
3203
3260
  code: node.code,
3204
3261
  name: node.name,
3205
3262
  nodeType: node.nodeType === "group" ? "group" : "leaf",
3206
3263
  accountType: node.accountType ?? "",
3207
3264
  parentId: node.parentId ?? null
3208
- }
3209
- });
3210
- }
3211
- function validate(draft, selfId) {
3265
+ };
3266
+ }
3267
+ const parent2 = ctx.parentId ? fullTree.byId.get(ctx.parentId) : void 0;
3268
+ return {
3269
+ code: suggestNextCode(fullTree, ctx.parentId),
3270
+ name: "",
3271
+ nodeType: "leaf",
3272
+ accountType: parent2?.accountType ?? SIDE_TYPE[side],
3273
+ parentId: ctx.parentId
3274
+ };
3275
+ });
3276
+ const update = (patch) => setDraft((prev) => ({ ...prev, ...patch }));
3277
+ const parent = draft.parentId ? fullTree.byId.get(draft.parentId) : void 0;
3278
+ function validate() {
3212
3279
  const code = draft.code.trim();
3213
3280
  if (!code) return t("financial.chartTree.error.codeRequired");
3214
3281
  if (!draft.name.trim()) return t("financial.chartTree.error.nameRequired");
3215
- const clash = (nodes ?? []).find((n) => n.code === code && n.id !== selfId);
3282
+ const clash = nodes.find((n) => n.code === code && n.id !== selfId);
3216
3283
  if (clash) return t("financial.chartTree.error.codeTaken", { code, name: clash.name });
3217
3284
  if (selfId && draft.nodeType === "leaf" && childIds(fullTree, selfId).length > 0) {
3218
3285
  return t("financial.chartTree.error.leafWithChildren");
3219
3286
  }
3220
3287
  return null;
3221
3288
  }
3222
- async function run(action, success) {
3223
- setBusy(true);
3224
- try {
3225
- await action();
3226
- if (table) emitDataChanged({ table });
3227
- toast.success(success);
3228
- await reload();
3229
- return true;
3230
- } catch (err) {
3231
- toast.error(t("financial.chartTree.error.save"), { description: errorMessage(err) });
3232
- return false;
3233
- } finally {
3234
- setBusy(false);
3235
- }
3236
- }
3237
3289
  async function submit() {
3238
- if (!editing) return;
3239
- const { draft } = editing;
3240
- const invalid = validate(draft, editing.mode === "edit" ? editing.id : void 0);
3290
+ const invalid = validate();
3241
3291
  if (invalid) {
3242
3292
  toast.error(invalid);
3243
3293
  return;
3244
3294
  }
3245
- const payload = {
3295
+ const ok = await onSave(selfId ?? null, {
3246
3296
  code: draft.code.trim(),
3247
3297
  name: draft.name.trim(),
3248
3298
  nodeType: draft.nodeType,
3249
3299
  accountType: draft.accountType || null,
3250
3300
  parentId: draft.parentId
3251
- };
3252
- const ok = editing.mode === "create" ? await run(() => provider.create({ ...payload, isActive: true }), t("financial.chartTree.created", { name: payload.name })) : await run(() => provider.update(editing.id, payload), t("financial.chartTree.updated", { name: payload.name }));
3253
- if (ok) setEditing(null);
3254
- }
3255
- async function setActive(node, isActive) {
3256
- await run(
3257
- () => provider.update(node.id, { isActive }),
3258
- t(isActive ? "financial.chartTree.reactivated" : "financial.chartTree.deactivated", { name: node.name })
3259
- );
3260
- }
3261
- async function remove(node) {
3262
- const ok = await run(() => provider.remove(node.id), t("financial.chartTree.deleted", { name: node.name }));
3263
- if (ok) setConfirmDelete(null);
3301
+ });
3302
+ if (ok) ctx.close();
3264
3303
  }
3265
- const parentOptions = React5__default.useCallback((q, selfId) => {
3304
+ const parentOptions = (q) => {
3266
3305
  const blocked = selfId ? descendantIds(fullTree, selfId).add(selfId) : /* @__PURE__ */ new Set();
3267
3306
  const needle = q.trim().toLowerCase();
3268
- return [...fullTree.byId.values()].filter((n) => !blocked.has(n.id) && isGroupNode(fullTree, n)).filter((n) => !needle || accountLabel(n).toLowerCase().includes(needle)).sort((a, b) => a.code.localeCompare(b.code, void 0, { numeric: true })).slice(0, 50).map((n) => ({ id: n.id, label: accountLabel(n) }));
3269
- }, [fullTree]);
3270
- if (nodes === null) {
3271
- return /* @__PURE__ */ jsx("div", { className: "space-y-2", "aria-busy": "true", children: Array.from({ length: 6 }).map((_, i) => /* @__PURE__ */ jsx(Skeleton, { className: "h-9 w-full" }, i)) });
3272
- }
3273
- const roots = rootIds(tree).filter((id) => !search || search.visible.has(id));
3274
- const inactiveCount = (nodes ?? []).filter((n) => !n.isActive).length;
3275
- function renderForm(draft, level, selfId) {
3276
- const update = (patch) => setEditing((prev) => prev ? { ...prev, draft: { ...prev.draft, ...patch } } : prev);
3277
- const parent = draft.parentId ? fullTree.byId.get(draft.parentId) : void 0;
3278
- return (
3279
- // Not a <form>: Enter would "click" the first button inside SearchSelect
3280
- // (its clear action) and wipe the parent instead of saving.
3281
- /* @__PURE__ */ jsxs(
3282
- "div",
3283
- {
3284
- role: "group",
3285
- className: "rounded-md border border-border bg-muted/40 p-3 space-y-3",
3286
- style: { marginLeft: Math.min(level, 8) * 16 },
3287
- onKeyDown: (e) => {
3288
- if (e.key === "Escape") setEditing(null);
3289
- if (e.key === "Enter" && e.target.dataset.submitOnEnter) {
3290
- e.preventDefault();
3291
- void submit();
3292
- }
3293
- },
3294
- children: [
3295
- /* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-[8rem_1fr]", children: [
3296
- /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3297
- t("financial.chartTree.field.code"),
3298
- /* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", value: draft.code, onChange: (e) => update({ code: e.target.value }), required: true })
3299
- ] }),
3300
- /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3301
- t("financial.chartTree.field.name"),
3302
- /* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", autoFocus: true, value: draft.name, onChange: (e) => update({ name: e.target.value }), required: true })
3303
- ] })
3307
+ return [...fullTree.byId.values()].filter((n) => !blocked.has(n.id) && isGroupNode(fullTree, n)).filter((n) => !needle || accountLabel(n).toLowerCase().includes(needle)).sort((a, b) => compareCodes(a.code, b.code)).slice(0, 50).map((n) => ({ id: n.id, label: accountLabel(n) }));
3308
+ };
3309
+ return (
3310
+ // Not a <form>: Enter would "click" the first button inside SearchSelect
3311
+ // (its clear action) and wipe the parent instead of saving.
3312
+ /* @__PURE__ */ jsxs(
3313
+ "div",
3314
+ {
3315
+ role: "group",
3316
+ className: "rounded-md border border-border bg-muted/40 p-3 space-y-3",
3317
+ style: { marginLeft: Math.min(ctx.level, 8) * 16 },
3318
+ onKeyDown: (e) => {
3319
+ if (e.key === "Escape") ctx.close();
3320
+ if (e.key === "Enter" && e.target.dataset.submitOnEnter) {
3321
+ e.preventDefault();
3322
+ void submit();
3323
+ }
3324
+ },
3325
+ children: [
3326
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-[8rem_1fr]", children: [
3327
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3328
+ t("financial.chartTree.field.code"),
3329
+ /* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", value: draft.code, onChange: (e) => update({ code: e.target.value }), required: true })
3304
3330
  ] }),
3305
- /* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [
3306
- /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3307
- t("financial.chartTree.field.structure"),
3308
- /* @__PURE__ */ jsxs(Select, { value: draft.nodeType, onValueChange: (v) => update({ nodeType: v }), children: [
3309
- /* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
3310
- /* @__PURE__ */ jsxs(SelectContent, { children: [
3311
- /* @__PURE__ */ jsx(SelectItem, { value: "leaf", children: t("financial.chartTree.leaf") }),
3312
- /* @__PURE__ */ jsx(SelectItem, { value: "group", children: t("financial.chartTree.group") })
3313
- ] })
3331
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3332
+ t("financial.chartTree.field.name"),
3333
+ /* @__PURE__ */ jsx(Input, { "data-submit-on-enter": "1", autoFocus: true, value: draft.name, onChange: (e) => update({ name: e.target.value }), required: true })
3334
+ ] })
3335
+ ] }),
3336
+ /* @__PURE__ */ jsxs("div", { className: "grid gap-3 sm:grid-cols-3", children: [
3337
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3338
+ t("financial.chartTree.field.structure"),
3339
+ /* @__PURE__ */ jsxs(Select, { value: draft.nodeType, onValueChange: (v) => update({ nodeType: v }), children: [
3340
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
3341
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
3342
+ /* @__PURE__ */ jsx(SelectItem, { value: "leaf", children: t("financial.chartTree.leaf") }),
3343
+ /* @__PURE__ */ jsx(SelectItem, { value: "group", children: t("financial.chartTree.group") })
3314
3344
  ] })
3315
- ] }),
3316
- /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3317
- t("financial.chartTree.field.nature"),
3318
- /* @__PURE__ */ jsxs(
3319
- Select,
3320
- {
3321
- value: draft.accountType || NO_NATURE,
3322
- onValueChange: (v) => update({ accountType: v === NO_NATURE ? "" : v }),
3323
- children: [
3324
- /* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
3325
- /* @__PURE__ */ jsxs(SelectContent, { children: [
3326
- /* @__PURE__ */ jsx(SelectItem, { value: NO_NATURE, children: t("financial.chartTree.nature.none") }),
3327
- NATURES.map((n) => /* @__PURE__ */ jsx(SelectItem, { value: n, children: t(`financial.chartTree.nature.${n}`) }, n))
3328
- ] })
3329
- ]
3330
- }
3331
- )
3332
- ] }),
3333
- /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3334
- t("financial.chartTree.field.parent"),
3335
- /* @__PURE__ */ jsx(
3336
- SearchSelect,
3337
- {
3338
- value: draft.parentId ?? void 0,
3339
- displayValue: parent ? accountLabel(parent) : void 0,
3340
- onChange: (id) => update({ parentId: id || null }),
3341
- onSearch: (q) => parentOptions(q, selfId),
3342
- minChars: 0,
3343
- placeholder: t("financial.chartTree.rootLevel"),
3344
- noResultsLabel: t("financial.chartTree.noGroups"),
3345
- searchingLabel: t("financial.chartTree.searching"),
3346
- clearLabel: t("financial.chartTree.rootLevel")
3347
- }
3348
- )
3349
3345
  ] })
3350
3346
  ] }),
3351
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
3352
- /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: () => setEditing(null), disabled: busy, children: t("financial.chartTree.cancel") }),
3353
- /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void submit(), children: busy ? t("financial.chartTree.saving") : t("financial.chartTree.save") })
3354
- ] })
3355
- ]
3356
- }
3357
- )
3358
- );
3359
- }
3360
- function renderNode(id, level) {
3361
- const node = tree.byId.get(id);
3362
- const kids = childIds(tree, id).filter((c) => !search || search.visible.has(c));
3363
- const group = isGroupNode(tree, node);
3364
- const open = search ? true : expanded.has(id);
3365
- const isEditingThis = editing?.mode === "edit" && editing.id === id;
3366
- const creatingHere = editing?.mode === "create" && editing.parentId === id;
3367
- const isMatch = search?.matches.has(id);
3368
- const hasAnyChildren = childIds(fullTree, id).length > 0;
3369
- const FolderIcon = open ? FolderOpen : Folder;
3370
- return /* @__PURE__ */ jsxs("li", { role: "treeitem", "aria-level": level + 1, "aria-expanded": group ? open : void 0, children: [
3371
- isEditingThis && editing ? renderForm(editing.draft, level, id) : /* @__PURE__ */ jsxs(
3372
- "div",
3373
- {
3374
- className: "group/row flex min-h-10 items-center gap-2 rounded-md px-2 py-1 hover:bg-muted/60 " + (node.isActive ? "" : "opacity-60"),
3375
- style: { paddingLeft: 8 + Math.min(level, 8) * 16 },
3376
- children: [
3377
- /* @__PURE__ */ jsx(
3378
- Button,
3379
- {
3380
- variant: "bare",
3381
- size: "bare",
3382
- type: "button",
3383
- className: "flex h-6 w-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-muted " + (kids.length ? "" : "invisible"),
3384
- onClick: () => toggle(id),
3385
- "aria-label": open ? t("financial.chartTree.collapse") : t("financial.chartTree.expand"),
3386
- disabled: !!search,
3387
- children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 transition-transform " + (open ? "rotate-90" : "") })
3388
- }
3389
- ),
3390
- group ? /* @__PURE__ */ jsx(FolderIcon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }) : /* @__PURE__ */ jsx(FileText, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3391
- /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-xs tabular-nums text-muted-foreground", children: node.code }),
3392
- /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-sm " + (group ? "font-semibold" : "") + (isMatch ? " text-primary" : ""), children: node.name }),
3393
- /* @__PURE__ */ jsxs("span", { className: "hidden shrink-0 items-center gap-1 sm:flex", children: [
3394
- node.accountType && /* @__PURE__ */ jsx(Badge, { variant: NATURE_VARIANT[node.accountType] ?? "default", dot: false, children: t(`financial.chartTree.nature.${node.accountType}`) }),
3395
- !node.isActive && /* @__PURE__ */ jsx(Badge, { variant: "outline", children: t("financial.chartTree.inactive") })
3347
+ /* @__PURE__ */ jsxs("label", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3348
+ t("financial.chartTree.field.nature"),
3349
+ /* @__PURE__ */ jsxs(
3350
+ Select,
3351
+ {
3352
+ value: draft.accountType || NO_NATURE,
3353
+ onValueChange: (v) => update({ accountType: v === NO_NATURE ? "" : v }),
3354
+ children: [
3355
+ /* @__PURE__ */ jsx(SelectTrigger, { className: "px-2 font-normal text-foreground", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
3356
+ /* @__PURE__ */ jsxs(SelectContent, { children: [
3357
+ /* @__PURE__ */ jsx(SelectItem, { value: NO_NATURE, children: t("financial.chartTree.nature.none") }),
3358
+ NATURES.map((n) => /* @__PURE__ */ jsx(SelectItem, { value: n, children: t(`financial.chartTree.nature.${n}`) }, n))
3359
+ ] })
3360
+ ]
3361
+ }
3362
+ )
3396
3363
  ] }),
3397
- confirmDelete === id ? /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [
3398
- /* @__PURE__ */ jsx("span", { className: "hidden text-xs text-muted-foreground md:inline", children: t("financial.chartTree.confirmDelete") }),
3399
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "destructive", disabled: busy, onClick: () => void remove(node), children: t("financial.chartTree.delete") }),
3400
- /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", disabled: busy, onClick: () => setConfirmDelete(null), children: t("financial.chartTree.cancel") })
3401
- ] }) : /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center justify-end gap-0.5 sm:w-32 sm:opacity-0 sm:group-hover/row:opacity-100 sm:focus-within:opacity-100", children: [
3402
- canCreate && group && node.isActive && /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", title: t("financial.chartTree.addChild"), "aria-label": t("financial.chartTree.addChild"), onClick: () => startCreate(id), disabled: busy, children: /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }) }),
3403
- canEdit && /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", title: t("financial.chartTree.edit"), "aria-label": t("financial.chartTree.edit"), onClick: () => startEdit(node), disabled: busy, children: /* @__PURE__ */ jsx(Pencil, { className: "h-4 w-4" }) }),
3404
- canEdit && !hasAnyChildren && (node.isActive ? /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", title: t("financial.chartTree.deactivate"), "aria-label": t("financial.chartTree.deactivate"), onClick: () => void setActive(node, false), disabled: busy, children: /* @__PURE__ */ jsx(Ban, { className: "h-4 w-4" }) }) : null),
3405
- canEdit && !node.isActive && /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", title: t("financial.chartTree.reactivate"), "aria-label": t("financial.chartTree.reactivate"), onClick: () => void setActive(node, true), disabled: busy, children: /* @__PURE__ */ jsx(RotateCcw, { className: "h-4 w-4" }) }),
3406
- canDelete && !hasAnyChildren && /* @__PURE__ */ jsx(Button, { size: "icon", variant: "ghost", title: t("financial.chartTree.delete"), "aria-label": t("financial.chartTree.delete"), onClick: () => {
3407
- setEditing(null);
3408
- setConfirmDelete(id);
3409
- }, disabled: busy, children: /* @__PURE__ */ jsx(Trash2, { className: "h-4 w-4" }) })
3364
+ /* @__PURE__ */ jsxs("div", { className: "space-y-1 text-xs font-medium text-muted-foreground", children: [
3365
+ t("financial.chartTree.field.parent"),
3366
+ /* @__PURE__ */ jsx(
3367
+ SearchSelect,
3368
+ {
3369
+ value: draft.parentId ?? void 0,
3370
+ displayValue: parent ? accountLabel(parent) : void 0,
3371
+ onChange: (id) => update({ parentId: id || null }),
3372
+ onSearch: parentOptions,
3373
+ minChars: 0,
3374
+ placeholder: t("financial.chartTree.rootLevel"),
3375
+ noResultsLabel: t("financial.chartTree.noGroups"),
3376
+ searchingLabel: t("financial.chartTree.searching"),
3377
+ clearLabel: t("financial.chartTree.rootLevel")
3378
+ }
3379
+ )
3410
3380
  ] })
3411
- ]
3412
- }
3413
- ),
3414
- open && (kids.length > 0 || creatingHere) && /* @__PURE__ */ jsxs("ul", { role: "group", className: "space-y-0.5", children: [
3415
- creatingHere && editing && /* @__PURE__ */ jsx("li", { children: renderForm(editing.draft, level + 1) }),
3416
- kids.map((c) => renderNode(c, level + 1))
3417
- ] })
3418
- ] }, id);
3419
- }
3420
- const hasOther = (nodes ?? []).some((n) => sideOf(n.accountType) === "other");
3421
- return /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
3422
- /* @__PURE__ */ jsx(
3423
- SegmentedControl,
3424
- {
3425
- value: side,
3426
- onChange: (v) => {
3427
- setSide(v);
3428
- setEditing(null);
3429
- },
3430
- options: [
3431
- { value: "in", label: tl("Income (in)", "Receitas (entradas)") },
3432
- { value: "out", label: tl("Expenses (out)", "Despesas (sa\xEDdas)") },
3433
- ...hasOther ? [{ value: "other", label: tl("Balance", "Patrimoniais") }] : []
3381
+ ] }),
3382
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap justify-end gap-2", children: [
3383
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", onClick: ctx.close, disabled: busy, children: t("financial.chartTree.cancel") }),
3384
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", disabled: busy, onClick: () => void submit(), children: busy ? t("financial.chartTree.saving") : t("financial.chartTree.save") })
3385
+ ] })
3434
3386
  ]
3435
3387
  }
3436
- ),
3437
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
3438
- /* @__PURE__ */ jsxs("div", { className: "relative min-w-[12rem] flex-1", children: [
3439
- /* @__PURE__ */ jsx(Search, { className: "pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" }),
3440
- /* @__PURE__ */ jsx(
3441
- Input,
3442
- {
3443
- value: query,
3444
- onChange: (e) => setQuery(e.target.value),
3445
- placeholder: t("financial.chartTree.searchPlaceholder"),
3446
- className: "pl-8 pr-8",
3447
- "aria-label": t("financial.chartTree.searchPlaceholder")
3448
- }
3449
- ),
3450
- query && /* @__PURE__ */ jsx(
3451
- Button,
3452
- {
3453
- variant: "bare",
3454
- size: "bare",
3455
- type: "button",
3456
- className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
3457
- onClick: () => setQuery(""),
3458
- "aria-label": t("financial.chartTree.clearSearch"),
3459
- children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
3460
- }
3461
- )
3462
- ] }),
3463
- /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => setExpanded(new Set(groupIds)), disabled: !!search, title: t("financial.chartTree.expandAll"), "aria-label": t("financial.chartTree.expandAll"), children: [
3464
- /* @__PURE__ */ jsx(ChevronsUpDown, { className: "h-4 w-4" }),
3465
- /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: t("financial.chartTree.expandAll") })
3466
- ] }),
3467
- /* @__PURE__ */ jsxs(Button, { variant: "outline", size: "sm", onClick: () => setExpanded(/* @__PURE__ */ new Set()), disabled: !!search, title: t("financial.chartTree.collapseAll"), "aria-label": t("financial.chartTree.collapseAll"), children: [
3468
- /* @__PURE__ */ jsx(ChevronsDownUp, { className: "h-4 w-4" }),
3469
- /* @__PURE__ */ jsx("span", { className: "hidden sm:inline", children: t("financial.chartTree.collapseAll") })
3470
- ] })
3471
- ] }),
3472
- canCreate && (embedded ? /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => startCreate(null), disabled: busy, children: [
3473
- /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
3474
- t("financial.chartTree.addRoot")
3475
- ] }) : /* @__PURE__ */ jsx(PageHeaderActions, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", onClick: () => startCreate(null), disabled: busy, children: [
3476
- /* @__PURE__ */ jsx(Plus, { className: "h-4 w-4" }),
3477
- t("financial.chartTree.addRoot")
3478
- ] }) })),
3479
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 text-xs text-muted-foreground", children: [
3480
- /* @__PURE__ */ jsx("span", { children: search ? t(search.matches.size === 1 ? "financial.chartTree.matchesOne" : "financial.chartTree.matches", { count: search.matches.size }) : t(tree.byId.size === 1 ? "financial.chartTree.countOne" : "financial.chartTree.count", { count: tree.byId.size }) }),
3481
- inactiveCount > 0 && /* @__PURE__ */ jsxs("label", { className: "inline-flex cursor-pointer items-center gap-1.5", children: [
3482
- /* @__PURE__ */ jsx(Checkbox, { checked: showInactive, onChange: setShowInactive }),
3483
- t("financial.chartTree.showInactive", { count: inactiveCount })
3484
- ] })
3485
- ] }),
3486
- loadError && /* @__PURE__ */ jsxs("p", { className: "rounded-md border border-destructive/40 bg-destructive/5 p-3 text-sm text-destructive", children: [
3487
- t("financial.chartTree.error.load"),
3488
- " ",
3489
- loadError
3490
- ] }),
3491
- editing?.mode === "create" && editing.parentId === null && renderForm(editing.draft, 0),
3492
- roots.length === 0 && !(editing?.mode === "create" && editing.parentId === null) ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-dashed border-border p-8 text-center text-sm text-muted-foreground", children: search ? t("financial.chartTree.noMatches") : t("financial.chartTree.empty") }) : /* @__PURE__ */ jsx("ul", { role: "tree", "aria-label": t("registry.chart-of-accounts"), className: "space-y-0.5", children: roots.map((id) => renderNode(id, 0)) })
3493
- ] });
3388
+ )
3389
+ );
3494
3390
  }
3495
3391
 
3496
3392
  // src/data/registries.ts
@@ -3582,7 +3478,7 @@ var chartOfAccountsSeed = [
3582
3478
  { id: "coa-4.2", code: "4.2", name: "Utilities", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true },
3583
3479
  { id: "coa-4.3", code: "4.3", name: "Payroll", nodeType: "leaf", accountType: "expense", parentId: "coa-4", isActive: true }
3584
3480
  ];
3585
- var ChartOfAccountsRegistryView = (props) => React5__default.createElement(ChartOfAccountsTree, { ...props, entity: chartOfAccountsEntity, mockData: chartOfAccountsSeed });
3481
+ var ChartOfAccountsRegistryView = (props) => React3__default.createElement(ChartOfAccountsTree, { ...props, entity: chartOfAccountsEntity, mockData: chartOfAccountsSeed });
3586
3482
  ChartOfAccountsRegistryView.displayName = "ChartOfAccountsRegistryView";
3587
3483
  var costCenterEntity = {
3588
3484
  name: "Cost Center",
@@ -3680,7 +3576,7 @@ var bankAccountEntity = {
3680
3576
  labelWhen: (v) => v.kind === "card_payable" ? "Banco emissor" : void 0,
3681
3577
  visibleWhen: (v) => hasIssuer(v.kind),
3682
3578
  group: "bank",
3683
- renderInput: ({ value, values, onChange, setValue }) => React5__default.createElement(BankPicker, {
3579
+ renderInput: ({ value, values, onChange, setValue }) => React3__default.createElement(BankPicker, {
3684
3580
  code: values.bankCode ?? "",
3685
3581
  name: value ?? "",
3686
3582
  onChange: (next) => {
@@ -4687,10 +4583,10 @@ function CashSessionControl({ config, provider, store: store6 }) {
4687
4583
  const fetchCashSessions = useStore(store6, (s) => s.fetchCashSessions);
4688
4584
  const open = useStore(store6, (s) => s.cashSessionModalOpen);
4689
4585
  const setOpen = useStore(store6, (s) => s.setCashSessionModalOpen);
4690
- React5__default.useEffect(() => {
4586
+ React3__default.useEffect(() => {
4691
4587
  void fetchCashSessions?.();
4692
4588
  }, [fetchCashSessions]);
4693
- React5__default.useEffect(() => {
4589
+ React3__default.useEffect(() => {
4694
4590
  if (!open) return;
4695
4591
  const close = () => setOpen(false);
4696
4592
  return onAppPathChange(close);
@@ -5260,8 +5156,8 @@ var UPCOMING = [
5260
5156
  function CardMachinesSettings() {
5261
5157
  const { connectors } = useConnectors({ hostPluginId: "financial", includeGrants: false });
5262
5158
  const panelAvailable = useConnectorsPanelAvailable();
5263
- const [selected, setSelected] = React5.useState(null);
5264
- const acquirers = React5.useMemo(
5159
+ const [selected, setSelected] = React3.useState(null);
5160
+ const acquirers = React3.useMemo(
5265
5161
  () => (connectors ?? []).filter((c) => ACQUIRERS.includes(c.slug)).sort((a, b) => ACQUIRERS.indexOf(a.slug) - ACQUIRERS.indexOf(b.slug)),
5266
5162
  [connectors]
5267
5163
  );
@@ -5382,7 +5278,7 @@ function createFinancialSettingsPlugin(options) {
5382
5278
  ...financialRegistries.filter((r) => RECEIVING_REGISTRIES.includes(r.id)),
5383
5279
  ...options?.extraRegistries ?? []
5384
5280
  ];
5385
- const SettingsTab = () => React5__default.createElement(PluginSettingsPanel, {
5281
+ const SettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
5386
5282
  title: "Pagamentos",
5387
5283
  registries,
5388
5284
  hostPluginId: "financial",
@@ -5438,11 +5334,11 @@ function createFinancialPlugin(options) {
5438
5334
  const settingsRegistries = registries.filter((r) => r.id !== "bank-accounts" && r.id !== "commission-rules");
5439
5335
  const AccountsRegistryPage = createCrudPage(financialAccountEntity, { feature: "financial" });
5440
5336
  AccountsRegistryPage.displayName = "FinancialAccountsRegistryPage";
5441
- const PersonStatementBound = (props) => React5__default.createElement(PersonStatementWidget, { person: props.item, provider, config });
5337
+ const PersonStatementBound = (props) => React3__default.createElement(PersonStatementWidget, { person: props.item, provider, config });
5442
5338
  PersonStatementBound.displayName = "FinancialPersonStatement";
5443
- const SupplierFinancialSettingsBound = (props) => React5__default.createElement(SupplierFinancialSettings, { person: props.item, provider });
5339
+ const SupplierFinancialSettingsBound = (props) => React3__default.createElement(SupplierFinancialSettings, { person: props.item, provider });
5444
5340
  SupplierFinancialSettingsBound.displayName = "FinancialSupplierSettings";
5445
- const PageComponent = () => React5__default.createElement(FinancialPage, { config, provider, store: store6, registries });
5341
+ const PageComponent = () => React3__default.createElement(FinancialPage, { config, provider, store: store6, registries });
5446
5342
  const AgentMount = lazyComponent(() => import('./payable-agent-TCKHUAQG.js').then((m) => m.createFinancialAgentMount({ config, provider })));
5447
5343
  return {
5448
5344
  id: "financial",
@@ -5500,7 +5396,7 @@ function createFinancialPlugin(options) {
5500
5396
  // tem — lá é um ícone no cabeçalho, de qualquer tela.
5501
5397
  headerControls: config.modules.cashRegisters ? [{
5502
5398
  id: "financial.cash-session",
5503
- component: (() => React5__default.createElement(CashSessionHeaderControl, { config, provider, store: store6 })),
5399
+ component: (() => React3__default.createElement(CashSessionHeaderControl, { config, provider, store: store6 })),
5504
5400
  order: 90,
5505
5401
  permission: { feature: "financial", action: "read" }
5506
5402
  }] : [],
@@ -5750,9 +5646,9 @@ function createFinancialPlugin(options) {
5750
5646
  { id: "card-brands", label: "Card brands", icon: "CreditCard" }
5751
5647
  ],
5752
5648
  component: (() => {
5753
- const FinancialSettingsTab = () => React5__default.createElement(PluginSettingsPanel, {
5649
+ const FinancialSettingsTab = () => React3__default.createElement(PluginSettingsPanel, {
5754
5650
  title: "Financial Settings",
5755
- generalSettings: React5__default.createElement(FinancialGeneralSettings, { config }),
5651
+ generalSettings: React3__default.createElement(FinancialGeneralSettings, { config }),
5756
5652
  registries: settingsRegistries,
5757
5653
  hostPluginId: "financial",
5758
5654
  routeBase: "/settings/financial"
@@ -5777,7 +5673,7 @@ function createFinancialPlugin(options) {
5777
5673
  icon: "HandCoins",
5778
5674
  group: "Financeiro",
5779
5675
  component: (() => {
5780
- const CommissionRulesTab = () => React5__default.createElement(CommissionRulesView, { provider });
5676
+ const CommissionRulesTab = () => React3__default.createElement(CommissionRulesView, { provider });
5781
5677
  CommissionRulesTab.displayName = "CommissionRulesTab";
5782
5678
  return CommissionRulesTab;
5783
5679
  })(),
@@ -5813,7 +5709,7 @@ function createFinancialPlugin(options) {
5813
5709
  locales: financialLocales
5814
5710
  };
5815
5711
  }
5816
- var FinancialPage = React5__default.lazy(() => import('./FinancialPage-BFC3K4WY.js').then((m) => ({ default: m.FinancialPage })));
5712
+ var FinancialPage = React3__default.lazy(() => import('./FinancialPage-LCKLEAM3.js').then((m) => ({ default: m.FinancialPage })));
5817
5713
  var FinancialGeneralSettings = lazyComponent(() => import('./FinancialGeneralSettings-WXJOCJPZ.js').then((m) => m.FinancialGeneralSettings));
5818
5714
  var CommissionRulesView = lazyComponent(() => import('./CommissionRulesView-2RW4ZCDT.js').then((m) => m.CommissionRulesView));
5819
5715
  var PersonStatementWidget = lazyComponent(() => import('./PersonStatementWidget-ULXXXYZ4.js').then((m) => m.PersonStatementWidget));