@fayz-ai/plugin-financial 0.30.3 → 0.31.1

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 (34) hide show
  1. package/dist/CashRegistersView-MIULZ4ID.js +5 -0
  2. package/dist/{CashRegistersView-5U252GGF.js.map → CashRegistersView-MIULZ4ID.js.map} +1 -1
  3. package/dist/{CommissionRulesView-2RW4ZCDT.js → CommissionRulesView-B3EFOJHX.js} +19 -10
  4. package/dist/CommissionRulesView-B3EFOJHX.js.map +1 -0
  5. package/dist/{FinancialPage-R5WZWICY.js → FinancialPage-FUTZIECP.js} +28 -16
  6. package/dist/FinancialPage-FUTZIECP.js.map +1 -0
  7. package/dist/{chunk-W7T7RTC4.js → chunk-D4WRL7ST.js} +45 -213
  8. package/dist/chunk-D4WRL7ST.js.map +1 -0
  9. package/dist/chunk-MTYUOE76.js +101 -0
  10. package/dist/chunk-MTYUOE76.js.map +1 -0
  11. package/dist/{chunk-G3BID4RP.js → chunk-NS2XEAQQ.js} +27 -6
  12. package/dist/chunk-NS2XEAQQ.js.map +1 -0
  13. package/dist/components/InvoiceAttachmentsModal.d.ts +2 -3
  14. package/dist/components/InvoiceAttachmentsModal.d.ts.map +1 -1
  15. package/dist/data/registries.d.ts.map +1 -1
  16. package/dist/index.js +16 -78
  17. package/dist/index.js.map +1 -1
  18. package/dist/lib/onboarding.d.ts +10 -1
  19. package/dist/lib/onboarding.d.ts.map +1 -1
  20. package/dist/migrations/index.d.ts +2 -0
  21. package/dist/migrations/index.d.ts.map +1 -1
  22. package/dist/migrations/main.browser.js +3 -1
  23. package/dist/migrations/main.browser.js.map +1 -1
  24. package/dist/migrations/main.js +260 -2
  25. package/dist/migrations/main.js.map +1 -1
  26. package/dist/views/CashRegistersView.d.ts.map +1 -1
  27. package/dist/views/CommissionRulesView.d.ts.map +1 -1
  28. package/dist/views/GoalsView.d.ts.map +1 -1
  29. package/package.json +6 -6
  30. package/dist/CashRegistersView-5U252GGF.js +0 -4
  31. package/dist/CommissionRulesView-2RW4ZCDT.js.map +0 -1
  32. package/dist/FinancialPage-R5WZWICY.js.map +0 -1
  33. package/dist/chunk-G3BID4RP.js.map +0 -1
  34. package/dist/chunk-W7T7RTC4.js.map +0 -1
@@ -3,15 +3,15 @@ import { consumePayableDraft, PayableDraftSurface } from './chunk-7VKJLBYY.js';
3
3
  import { useFinancialConfig, useFinancialStore, formatCurrency, useFinancialProvider } from './chunk-CNXAVGSW.js';
4
4
  import { FINANCIAL_INVOICE_ZONES } from '@fayz-ai/financial/views/zones';
5
5
  export { FINANCIAL_INVOICE_ZONES } from '@fayz-ai/financial/views/zones';
6
- import * as React13 from 'react';
7
- import React13__default, { useState, useRef, useEffect, useMemo } from 'react';
6
+ import * as React12 from 'react';
7
+ import React12__default, { useState, useEffect, useRef, useMemo } from 'react';
8
8
  import { useTranslation, createPendingCommand, useUnitMode, useDataChanged, useActiveUnitId, appHref, resolveCurrency, getSupabaseClientOptional } from '@fayz-ai/core';
9
9
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
10
- import { Landmark, CreditCard, Banknote, TriangleAlert, Loader2, Check, X, Paperclip, Image, FileText, ChevronRight, UploadCloud, ArrowLeft, ChevronLeft, ExternalLink, Ban, CircleDashed, CircleAlert, CircleCheckBig, CircleEllipsis, Pencil, Package, PackagePlus, Receipt, Gift, Briefcase, CalendarDays, DollarSign, LayoutList, Layers, Ticket, FileCheck, ArrowRightLeft, QrCode, Undo2, Building2, MoreVertical, Calendar, User, Wallet, Unlink, Trash2, ChevronDown, Search, Settings } from 'lucide-react';
11
- import { INLINE_LINK_TONE, SearchSelect, Button, useInModalTaskHost, ModalTask, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, ModalFooter, toast, Skeleton, SubpageHeader, DatePicker, Checkbox, Textarea, ChoiceSelect, useSaveBar, tourAnchor, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Input, TreeSelect, SegmentedControl, CurrencyInput, Badge, Hint, Popover, PopoverTrigger, PopoverContent } from '@fayz-ai/ui';
10
+ import { Landmark, CreditCard, Banknote, TriangleAlert, Loader2, Check, X, Ban, CircleDashed, CircleAlert, CircleCheckBig, CircleEllipsis, Pencil, Package, PackagePlus, Receipt, Gift, Briefcase, CalendarDays, ExternalLink, DollarSign, LayoutList, Layers, Ticket, FileCheck, ArrowRightLeft, QrCode, Undo2, Paperclip, Building2, MoreVertical, FileText, ChevronRight, Calendar, User, Wallet, Unlink, Trash2, ChevronDown, Search, Settings } from 'lucide-react';
11
+ import { INLINE_LINK_TONE, SearchSelect, Button, useInModalTaskHost, ModalTask, toast, Skeleton, SubpageHeader, DatePicker, Checkbox, Textarea, ChoiceSelect, useSaveBar, tourAnchor, Select, SelectTrigger, SelectValue, SelectContent, SelectItem, Input, TreeSelect, SegmentedControl, CurrencyInput, Badge, Modal, ModalContent, ModalHeader, ModalTitle, ModalBody, Hint, ModalFooter, Popover, PopoverTrigger, PopoverContent } from '@fayz-ai/ui';
12
12
  import { createPortal } from 'react-dom';
13
13
  import { createIdempotencyKey } from '@fayz-ai/financial/data/idempotency';
14
- import { useCurrency, useUnitStore, OrderDetailSkeleton, WidgetSlot, PageActions, OrderDetailBlock, TagChip, OrderDetailView, PersonLink, CurrencyScope, useUnitFilter, usePermissionOptional, adminNavigateTo, createArchetypeLookup, listPickablePriceTables, withPriceTable, useLimitGuard, useLookupCreate, OrderFormSkeleton, OrderFormBlock, initialPriceTableId, TagsField, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, RecordMetaFooter, quotePriceTable, invalidateLimit, useHouseCurrency } from '@fayz-ai/admin';
14
+ import { AttachmentsModal, useCurrency, useUnitStore, OrderDetailSkeleton, WidgetSlot, PageActions, OrderDetailBlock, TagChip, OrderDetailView, PersonLink, CurrencyScope, useUnitFilter, usePermissionOptional, adminNavigateTo, createArchetypeLookup, listPickablePriceTables, withPriceTable, useLimitGuard, useLookupCreate, OrderFormSkeleton, OrderFormBlock, initialPriceTableId, TagsField, OrderFormView, OrderFormItemsCard, OrderFormItemRow, OrderFormAddItemStep, RecordMetaFooter, quotePriceTable, invalidateLimit, useHouseCurrency } from '@fayz-ai/admin';
15
15
  import { T } from '@fayz-ai/financial/data/tables';
16
16
  import { groupPaymentsByBill, reversiblePayments } from '@fayz-ai/financial/domain/movement';
17
17
  import { describePayment, paymentHolderId } from '@fayz-ai/financial/domain/payment-method';
@@ -71,14 +71,14 @@ function CardVisual({
71
71
  lastFour,
72
72
  color,
73
73
  brandId,
74
- size: size2 = "sm"
74
+ size = "sm"
75
75
  }) {
76
76
  const brand = useBrandName(brandId);
77
77
  const last = (lastFour ?? "").trim();
78
78
  if (!last && !color && !brand) return null;
79
79
  const bg = color && /^#[0-9a-fA-F]{6}$/.test(color) ? color : void 0;
80
- const lg = size2 === "lg";
81
- if (size2 === "xs") {
80
+ const lg = size === "lg";
81
+ if (size === "xs") {
82
82
  return /* @__PURE__ */ jsx(
83
83
  "span",
84
84
  {
@@ -183,22 +183,22 @@ function searchBrBanks(query) {
183
183
  (b) => qd && qd === q && (b.code.startsWith(qd) || b.code.replace(/^0+/, "").startsWith(qd)) || norm(b.name).includes(q) || b.aliases?.some((a) => norm(a).includes(q))
184
184
  );
185
185
  }
186
- function BankLogo({ bank, size: size2 = 20 }) {
186
+ function BankLogo({ bank, size = 20 }) {
187
187
  const [broken, setBroken] = useState(false);
188
188
  if (!bank?.logo || broken) {
189
- return /* @__PURE__ */ jsx(Landmark, { className: "text-muted-foreground", style: { width: size2 * 0.8, height: size2 * 0.8 }, "aria-hidden": true });
189
+ return /* @__PURE__ */ jsx(Landmark, { className: "text-muted-foreground", style: { width: size * 0.8, height: size * 0.8 }, "aria-hidden": true });
190
190
  }
191
191
  return /* @__PURE__ */ jsx(
192
192
  "img",
193
193
  {
194
194
  src: bank.logo,
195
195
  alt: "",
196
- width: size2,
197
- height: size2,
196
+ width: size,
197
+ height: size,
198
198
  loading: "lazy",
199
199
  onError: () => setBroken(true),
200
200
  className: "shrink-0 object-contain",
201
- style: { width: size2, height: size2 }
201
+ style: { width: size, height: size }
202
202
  }
203
203
  );
204
204
  }
@@ -277,8 +277,8 @@ function AccountIcon({ account }) {
277
277
  var FIELD_CLASS = "mt-1 flex w-full items-center gap-2 rounded-input border border-input bg-card px-3 py-2 text-left text-sm shadow-[inset_0_1px_0_rgb(0_0_0_/0.06)] focus:outline-none focus:ring-2 focus:ring-ring";
278
278
  var norm2 = (v) => v.normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase();
279
279
  function AccountPicker({ accounts, value, onChange, disabled, title, placeholder, ariaLabel, clearLabel, className, onManage, manageLabel, variant = "inline" }) {
280
- const [open, setOpen] = React13__default.useState(false);
281
- const [q, setQ] = React13__default.useState("");
280
+ const [open, setOpen] = React12__default.useState(false);
281
+ const [q, setQ] = React12__default.useState("");
282
282
  const selected = accounts.find((a) => a.id === value);
283
283
  const list = q ? accounts.filter((a) => norm2(a.name).includes(norm2(q))) : accounts;
284
284
  const pick = (id) => {
@@ -748,10 +748,10 @@ function PaymentModal({ movement, receiptUrl, onClose, onPaid }) {
748
748
  const payMovement = useFinancialStore((s) => s.payMovement);
749
749
  const remaining = movement.amount - movement.paidAmount;
750
750
  const [saving, setSaving] = useState(false);
751
- const command = React13__default.useRef(createPendingCommand(() => createIdempotencyKey("financial:payment"), (input) => input.movementId));
751
+ const command = React12__default.useRef(createPendingCommand(() => createIdempotencyKey("financial:payment"), (input) => input.movementId));
752
752
  const [pending, setPending] = useState(false);
753
753
  const [visible, setVisible] = useState(false);
754
- React13__default.useEffect(() => {
754
+ React12__default.useEffect(() => {
755
755
  requestAnimationFrame(() => setVisible(true));
756
756
  }, []);
757
757
  const source = movement.metadata ?? {};
@@ -965,7 +965,7 @@ function InstallmentStatusBadge({ status }) {
965
965
  ] });
966
966
  }
967
967
  function InlineAmount({ label, value, onCommit }) {
968
- const [draft, setDraft] = React13__default.useState(null);
968
+ const [draft, setDraft] = React12__default.useState(null);
969
969
  if (draft === null) {
970
970
  return /* @__PURE__ */ jsx(
971
971
  Button,
@@ -1120,7 +1120,7 @@ function PaymentReceiptModal({
1120
1120
  payment: m,
1121
1121
  reversal: ordenados.find((r) => r.metadata?.reversal_of === m.id)
1122
1122
  }));
1123
- const [verDesfeitos, setVerDesfeitos] = React13__default.useState(false);
1123
+ const [verDesfeitos, setVerDesfeitos] = React12__default.useState(false);
1124
1124
  const total = vivos.reduce((soma, m) => soma + (m.paidAmount || m.amount), 0);
1125
1125
  return /* @__PURE__ */ jsx(Modal, { open: true, onOpenChange: (o) => {
1126
1126
  if (!o) onClose();
@@ -1244,191 +1244,23 @@ function rebalanceInstallments(input) {
1244
1244
  });
1245
1245
  return next.map((c) => c / 100);
1246
1246
  }
1247
- var ACCEPT = "image/*,application/pdf";
1248
- var MAX_BYTES = 15 * 1024 * 1024;
1249
- function size(bytes) {
1250
- if (!bytes) return "";
1251
- return bytes < 1024 * 1024 ? `${Math.max(1, Math.round(bytes / 1024))} KB` : `${(bytes / 1024 / 1024).toFixed(1)} MB`;
1252
- }
1253
1247
  function InvoiceAttachmentsModal({ invoiceId, onClose, onChanged }) {
1254
1248
  const provider = useFinancialProvider();
1255
- const inputRef = useRef(null);
1256
- const [items, setItems] = useState(null);
1257
- const [uploading, setUploading] = useState(0);
1258
- const [over, setOver] = useState(false);
1259
- const [preview, setPreview] = useState(null);
1260
- const [added, setAdded] = useState(0);
1261
- async function load() {
1262
- try {
1263
- setItems(await (provider.getInvoiceAttachments?.(invoiceId) ?? Promise.resolve([])));
1264
- } catch (e) {
1265
- setItems([]);
1266
- toast.error(e?.message ?? String(e));
1267
- }
1268
- }
1269
- useEffect(() => {
1270
- void load();
1271
- }, [invoiceId]);
1272
- async function upload(files) {
1273
- const list = Array.from(files);
1274
- if (!list.length || !provider.addInvoiceAttachment) return;
1275
- const invalid = list.filter((f) => !(f.type.startsWith("image/") || f.type === "application/pdf") || f.size > MAX_BYTES);
1276
- if (invalid.length) toast.error("Envie imagem ou PDF de at\xE9 15 MB.");
1277
- const ok = list.filter((f) => !invalid.includes(f));
1278
- if (!ok.length) return;
1279
- setUploading((n) => n + ok.length);
1280
- for (const file of ok) {
1281
- try {
1282
- await provider.addInvoiceAttachment(invoiceId, file);
1283
- setAdded((n) => n + 1);
1284
- } catch (e) {
1285
- toast.error(`${file.name}: ${e?.message ?? String(e)}`);
1286
- } finally {
1287
- setUploading((n) => n - 1);
1288
- }
1289
- }
1290
- await load();
1291
- onChanged?.();
1292
- }
1293
- return /* @__PURE__ */ jsx(Modal, { open: true, onOpenChange: (o) => {
1294
- if (!o) onClose();
1295
- }, children: /* @__PURE__ */ jsx(ModalContent, { size: preview !== null ? "3xl" : "sm", children: preview !== null && items?.[preview] ? /* @__PURE__ */ jsx(
1296
- AttachmentPreview,
1249
+ return /* @__PURE__ */ jsx(
1250
+ AttachmentsModal,
1297
1251
  {
1298
- items,
1299
- index: preview,
1300
- onIndex: setPreview,
1301
- onBack: () => setPreview(null)
1252
+ labels: {
1253
+ title: "Anexos da conta",
1254
+ emptyTitle: "Nenhum anexo ainda",
1255
+ emptyHint: "Guarde aqui o boleto, a nota ou o comprovante de pagamento \u2014 fica tudo junto da conta.",
1256
+ pendingMessage: "O registro deste anexo atravessou, o arquivo ainda n\xE3o. Ele continua no V1 \u2014 procure pelo nome do arquivo."
1257
+ },
1258
+ load: () => provider.getInvoiceAttachments?.(invoiceId) ?? Promise.resolve([]),
1259
+ upload: provider.addInvoiceAttachment ? (file) => provider.addInvoiceAttachment(invoiceId, file) : void 0,
1260
+ onClose,
1261
+ onChanged
1302
1262
  }
1303
- ) : /* @__PURE__ */ jsxs(Fragment, { children: [
1304
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsxs(ModalTitle, { className: "flex items-center gap-2", children: [
1305
- /* @__PURE__ */ jsx(Paperclip, { className: "h-4 w-4 text-muted-foreground", "aria-hidden": true }),
1306
- "Anexos da conta"
1307
- ] }) }),
1308
- /* @__PURE__ */ jsxs(ModalBody, { className: "space-y-3", children: [
1309
- items === null ? /* @__PURE__ */ jsx("ul", { className: "divide-y rounded-card border", "aria-busy": "true", children: [0, 1].map((i) => /* @__PURE__ */ jsxs("li", { className: "flex items-center gap-3 px-3 py-2.5", children: [
1310
- /* @__PURE__ */ jsx("div", { className: "h-4 w-4 shrink-0 animate-pulse rounded bg-muted" }),
1311
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 space-y-1.5", children: [
1312
- /* @__PURE__ */ jsx("div", { className: "h-3 w-2/3 animate-pulse rounded bg-muted" }),
1313
- /* @__PURE__ */ jsx("div", { className: "h-2.5 w-1/3 animate-pulse rounded bg-muted" })
1314
- ] })
1315
- ] }, i)) }) : items.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "rounded-card bg-muted/40 px-4 py-5 text-center", children: [
1316
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: "Nenhum anexo ainda" }),
1317
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-muted-foreground", children: "Guarde aqui o boleto, a nota ou o comprovante de pagamento \u2014 fica tudo junto da conta." })
1318
- ] }) : /* @__PURE__ */ jsx("ul", { className: "divide-y rounded-card border", children: items.map((a, i) => {
1319
- const Icon = (a.mimeType ?? "").startsWith("image/") ? Image : FileText;
1320
- return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
1321
- Button,
1322
- {
1323
- variant: "bare",
1324
- size: "bare",
1325
- type: "button",
1326
- onClick: () => setPreview(i),
1327
- className: "font-normal whitespace-normal justify-start flex w-full items-center gap-3 px-3 py-2 text-left transition-colors hover:bg-muted/40",
1328
- children: [
1329
- /* @__PURE__ */ jsx(Icon, { className: "h-4 w-4 shrink-0 text-muted-foreground", "aria-hidden": true }),
1330
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
1331
- /* @__PURE__ */ jsx("p", { className: "truncate text-sm", children: a.fileName }),
1332
- /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: a.pending ? "Arquivo ainda n\xE3o dispon\xEDvel" : [size(a.fileSize), a.createdAt?.slice(0, 10).split("-").reverse().join("/")].filter(Boolean).join(" \xB7 ") })
1333
- ] }),
1334
- /* @__PURE__ */ jsx(ChevronRight, { className: "h-3.5 w-3.5 shrink-0 text-muted-foreground", "aria-hidden": true })
1335
- ]
1336
- }
1337
- ) }, a.id);
1338
- }) }),
1339
- provider.addInvoiceAttachment && /* @__PURE__ */ jsxs(
1340
- Button,
1341
- {
1342
- variant: "bare",
1343
- size: "bare",
1344
- type: "button",
1345
- onClick: () => inputRef.current?.click(),
1346
- onDragOver: (e) => {
1347
- e.preventDefault();
1348
- setOver(true);
1349
- },
1350
- onDragLeave: () => setOver(false),
1351
- onDrop: (e) => {
1352
- e.preventDefault();
1353
- setOver(false);
1354
- void upload(e.dataTransfer.files);
1355
- },
1356
- disabled: uploading > 0,
1357
- className: `font-normal whitespace-normal justify-start ${`flex w-full flex-col items-center gap-1 rounded-card border-2 border-dashed px-4 py-5 text-center transition-colors ${over ? "border-primary bg-primary/5" : "border-border hover:bg-muted/40"}`}`,
1358
- children: [
1359
- uploading > 0 ? /* @__PURE__ */ jsx(Loader2, { className: "h-5 w-5 animate-spin text-muted-foreground" }) : /* @__PURE__ */ jsx(UploadCloud, { className: "h-5 w-5 text-muted-foreground", "aria-hidden": true }),
1360
- /* @__PURE__ */ jsx("span", { className: "text-sm font-medium", children: uploading > 0 ? "Enviando\u2026" : "Solte arquivos aqui ou clique para escolher" }),
1361
- /* @__PURE__ */ jsx("span", { className: "text-[11px] text-muted-foreground", children: "Imagem ou PDF, at\xE9 15 MB" })
1362
- ]
1363
- }
1364
- ),
1365
- /* @__PURE__ */ jsx(
1366
- "input",
1367
- {
1368
- ref: inputRef,
1369
- type: "file",
1370
- accept: ACCEPT,
1371
- multiple: true,
1372
- className: "hidden",
1373
- onChange: (e) => {
1374
- const f = e.target.files;
1375
- if (f) void upload(f);
1376
- e.target.value = "";
1377
- }
1378
- }
1379
- )
1380
- ] }),
1381
- /* @__PURE__ */ jsx(ModalFooter, { children: /* @__PURE__ */ jsx(Button, { onClick: onClose, disabled: uploading > 0, variant: added > 0 ? "default" : "outline", children: uploading > 0 ? "Enviando\u2026" : added > 0 ? "Concluir" : "Fechar" }) })
1382
- ] }) }) });
1383
- }
1384
- function AttachmentPreview({ items, index, onIndex, onBack }) {
1385
- const doc = items[index];
1386
- const isImage = (doc.mimeType ?? "").startsWith("image/");
1387
- const isPdf = doc.mimeType === "application/pdf";
1388
- const go = (d) => onIndex((index + d + items.length) % items.length);
1389
- return /* @__PURE__ */ jsxs(Fragment, { children: [
1390
- /* @__PURE__ */ jsx(ModalHeader, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pr-8", children: [
1391
- /* @__PURE__ */ jsxs(
1392
- Button,
1393
- {
1394
- variant: "bare",
1395
- size: "bare",
1396
- type: "button",
1397
- onClick: onBack,
1398
- className: "font-normal inline-flex shrink-0 items-center gap-1 rounded-md px-1.5 py-1 text-sm text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
1399
- children: [
1400
- /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4", "aria-hidden": true }),
1401
- " Voltar"
1402
- ]
1403
- }
1404
- ),
1405
- /* @__PURE__ */ jsx(ModalTitle, { className: "min-w-0 flex-1 truncate text-sm font-medium", title: doc.fileName, children: doc.fileName }),
1406
- items.length > 1 && /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1 text-xs text-muted-foreground", children: [
1407
- /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => go(-1), "aria-label": "Anterior", className: "font-normal rounded-md p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-4 w-4" }) }),
1408
- index + 1,
1409
- " de ",
1410
- items.length,
1411
- /* @__PURE__ */ jsx(Button, { variant: "bare", size: "bare", type: "button", onClick: () => go(1), "aria-label": "Pr\xF3ximo", className: "font-normal rounded-md p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4" }) })
1412
- ] }),
1413
- doc.url && /* @__PURE__ */ jsx(
1414
- "a",
1415
- {
1416
- href: doc.url,
1417
- target: "_blank",
1418
- rel: "noreferrer",
1419
- "aria-label": "Abrir em nova aba",
1420
- className: "shrink-0 rounded-md p-1.5 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",
1421
- children: /* @__PURE__ */ jsx(ExternalLink, { className: "h-4 w-4" })
1422
- }
1423
- )
1424
- ] }) }),
1425
- /* @__PURE__ */ jsx(ModalBody, { children: /* @__PURE__ */ jsx("div", { className: "flex h-[65vh] items-center justify-center overflow-hidden rounded-card bg-muted/40", children: doc.pending || !doc.url ? /* @__PURE__ */ jsxs("p", { className: "max-w-sm p-8 text-center text-sm text-muted-foreground", children: [
1426
- "O registro deste anexo atravessou, o arquivo ainda n\xE3o. Ele continua no V1 \u2014 procure por",
1427
- " ",
1428
- /* @__PURE__ */ jsx("span", { className: "font-mono text-xs", children: doc.fileName }),
1429
- "."
1430
- ] }) : isImage ? /* @__PURE__ */ jsx("img", { src: doc.url, alt: doc.fileName, className: "max-h-full max-w-full object-contain" }) : isPdf ? /* @__PURE__ */ jsx("iframe", { src: doc.url, title: doc.fileName, className: "h-full w-full bg-white" }) : /* @__PURE__ */ jsx("p", { className: "p-8 text-center text-sm text-muted-foreground", children: "Este tipo de arquivo n\xE3o tem pr\xE9-visualiza\xE7\xE3o. Use o bot\xE3o de abrir." }) }) })
1431
- ] });
1263
+ );
1432
1264
  }
1433
1265
  var DESTINATIONS = [
1434
1266
  { value: "devolver", label: "Devolver ao fornecedor" },
@@ -2335,8 +2167,8 @@ function InvoiceDetailView({ invoiceId, direction, onBack, onEdit, backLabel, em
2335
2167
  useEffect(() => {
2336
2168
  void loadPaymentDetails();
2337
2169
  }, [invoiceId]);
2338
- const [chartNames, setChartNames] = React13__default.useState(/* @__PURE__ */ new Map());
2339
- React13__default.useEffect(() => {
2170
+ const [chartNames, setChartNames] = React12__default.useState(/* @__PURE__ */ new Map());
2171
+ React12__default.useEffect(() => {
2340
2172
  let cancelled2 = false;
2341
2173
  void provider.getChartOfAccounts().then((rows) => {
2342
2174
  if (!cancelled2) setChartNames(new Map(rows.map((r) => [r.id, r.name])));
@@ -2900,7 +2732,7 @@ function FinancialCounterpartySearchSelect({
2900
2732
  onEdit,
2901
2733
  disabled
2902
2734
  }) {
2903
- const search = React13.useCallback(async (query) => {
2735
+ const search = React12.useCallback(async (query) => {
2904
2736
  const results = await lookup.search(query);
2905
2737
  return results.map((result) => ({
2906
2738
  id: result.id,
@@ -2959,9 +2791,9 @@ function consumirItemParaAbrir(invoiceId) {
2959
2791
  }
2960
2792
  }
2961
2793
  function useStockedItemTypes(itemTypes, entityLookups) {
2962
- const [empty, setEmpty] = React13__default.useState(null);
2794
+ const [empty, setEmpty] = React12__default.useState(null);
2963
2795
  const backed = itemTypes.filter((type) => entityLookups[type.value]?.count).map((type) => type.value).sort().join(",");
2964
- React13__default.useEffect(() => {
2796
+ React12__default.useEffect(() => {
2965
2797
  const kinds = backed ? backed.split(",") : [];
2966
2798
  if (!kinds.length) {
2967
2799
  setEmpty(null);
@@ -2982,7 +2814,7 @@ function useStockedItemTypes(itemTypes, entityLookups) {
2982
2814
  cancelled = true;
2983
2815
  };
2984
2816
  }, [backed]);
2985
- return React13__default.useMemo(
2817
+ return React12__default.useMemo(
2986
2818
  () => empty?.size ? itemTypes.filter((type) => !empty.has(type.value)) : itemTypes,
2987
2819
  [itemTypes, empty]
2988
2820
  );
@@ -3154,14 +2986,14 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
3154
2986
  ...base.service ? { service: withPriceTable(base.service, pickedTable.id, { kinds: ["service"] }) } : {}
3155
2987
  };
3156
2988
  }, [config.entityLookups, giftCardLookup, pickedTable]);
3157
- const translatedItemTypes = React13__default.useMemo(
2989
+ const translatedItemTypes = React12__default.useMemo(
3158
2990
  () => itemTypesRaw.map((tp) => {
3159
2991
  const traduzido = t(`financial.itemType.${tp.value}`);
3160
2992
  return traduzido === `financial.itemType.${tp.value}` ? tp : { ...tp, label: traduzido };
3161
2993
  }),
3162
2994
  [itemTypesRaw, t]
3163
2995
  );
3164
- const offeredItemTypes = React13__default.useMemo(
2996
+ const offeredItemTypes = React12__default.useMemo(
3165
2997
  () => availableInvoiceItemTypes(
3166
2998
  giftCardsEnabled && !translatedItemTypes.some((type) => type.value === "gift_card") ? [...translatedItemTypes, { value: "gift_card", label: t("financial.itemType.gift_card"), icon: "Gift" }] : translatedItemTypes,
3167
2999
  Object.keys(entityLookups),
@@ -3185,7 +3017,7 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
3185
3017
  const isEdit = !!editId;
3186
3018
  const [attachmentsOpen, setAttachmentsOpen] = useState(false);
3187
3019
  const [attachmentCount, setAttachmentCount] = useState(0);
3188
- const loadAttachmentCount = React13__default.useCallback(() => {
3020
+ const loadAttachmentCount = React12__default.useCallback(() => {
3189
3021
  if (!editId || !provider.getInvoiceAttachments) return;
3190
3022
  provider.getInvoiceAttachments(editId).then((list) => setAttachmentCount(list.length)).catch(() => {
3191
3023
  });
@@ -3524,13 +3356,13 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
3524
3356
  if (isEdit || totalAmount <= 0 || installments.length > 0) return;
3525
3357
  generateInstallments(1);
3526
3358
  }, [isEdit, totalAmount, installments.length]);
3527
- const fromCard = React13__default.useMemo(
3359
+ const fromCard = React12__default.useMemo(
3528
3360
  () => fromCardId ? bankAccounts.find((a) => a.id === fromCardId) : void 0,
3529
3361
  [fromCardId, bankAccounts]
3530
3362
  );
3531
3363
  const cardLast4 = (fromCard?.accountNumber ?? "").replace(/\D/g, "").slice(-4);
3532
3364
  const nomeJaTemOsDigitos = !!cardLast4 && (fromCard?.name ?? "").replace(/\D/g, "").endsWith(cardLast4);
3533
- const cardMethodName = React13__default.useMemo(() => {
3365
+ const cardMethodName = React12__default.useMemo(() => {
3534
3366
  const id = installments[0]?.payMethodTypeId;
3535
3367
  const escolhida = id ? paymentMethodTypes.find((tp) => tp.id === id) : void 0;
3536
3368
  return (escolhida ?? paymentMethodTypes.find((tp) => tp.transactionType === "credit_card"))?.name;
@@ -4433,5 +4265,5 @@ function InvoiceFormView({ direction, editId, onSaved, focusReceipt = false, fro
4433
4265
  }
4434
4266
 
4435
4267
  export { ACCOUNTS_ROUTE, AccountIcon, BankLogo, BankPicker, CancelInvoicesDialog, FinancialCounterpartySearchSelect, InvoiceAttachmentsModal, InvoiceDetailView, InvoiceFormView, PaymentModal, UnitField, createFinancialCounterpartyLookup, findBrBank, marcarItemParaAbrir, renderAccountAvatar, renderCardChip, useStockedItemTypes, useWritableUnits };
4436
- //# sourceMappingURL=chunk-W7T7RTC4.js.map
4437
- //# sourceMappingURL=chunk-W7T7RTC4.js.map
4268
+ //# sourceMappingURL=chunk-D4WRL7ST.js.map
4269
+ //# sourceMappingURL=chunk-D4WRL7ST.js.map