@oondemand/oon-core-front 0.3.64 → 0.3.66

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
@@ -4577,7 +4577,7 @@ function Sidebar({ app, menu, registry }) {
4577
4577
  // package.json
4578
4578
  var package_default = {
4579
4579
  name: "@oondemand/oon-core-front",
4580
- version: "0.3.64",
4580
+ version: "0.3.66",
4581
4581
  repository: {
4582
4582
  type: "git",
4583
4583
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -5942,7 +5942,7 @@ function startFromManifest(manifest, runtime) {
5942
5942
  }
5943
5943
 
5944
5944
  // src/modules/integrations.tsx
5945
- import { Stack as Stack12 } from "@chakra-ui/react";
5945
+ import { Stack as Stack14 } from "@chakra-ui/react";
5946
5946
 
5947
5947
  // src/components/CoreIntegration.tsx
5948
5948
  import { useEffect as useEffect9, useState as useState14 } from "react";
@@ -6595,24 +6595,499 @@ function CoreIntegrationMappings() {
6595
6595
  ] });
6596
6596
  }
6597
6597
 
6598
- // src/components/CoreOmieIntegration.tsx
6599
- import { useEffect as useEffect10, useState as useState15 } from "react";
6598
+ // src/components/CoreIntegrationTickets.tsx
6599
+ import { useEffect as useEffect10, useMemo as useMemo9, useState as useState15 } from "react";
6600
6600
  import { Badge as Badge7, Box as Box24, Button as Button17, Flex as Flex17, Heading as Heading14, Input as Input9, Stack as Stack11, Text as Text25 } from "@chakra-ui/react";
6601
6601
  import { useMutation as useMutation5, useQuery as useQuery11 } from "@tanstack/react-query";
6602
6602
  import { jsx as jsx40, jsxs as jsxs25 } from "react/jsx-runtime";
6603
+ var TICKET_STATUSES = [
6604
+ "Pendente",
6605
+ "Processando",
6606
+ "Erro tempor\xE1rio",
6607
+ "Conclu\xEDdo",
6608
+ "Erro definitivo",
6609
+ "Arquivado"
6610
+ ];
6603
6611
  function dateTime3(value2) {
6604
6612
  if (!value2) return "\u2014";
6605
6613
  const date = new Date(value2);
6606
6614
  return Number.isNaN(date.getTime()) ? value2 : date.toLocaleString("pt-BR");
6607
6615
  }
6616
+ function shortId(value2) {
6617
+ if (!value2) return "\u2014";
6618
+ return value2.length > 12 ? `${value2.slice(0, 8)}\u2026${value2.slice(-4)}` : value2;
6619
+ }
6608
6620
  function statusPalette2(status) {
6621
+ const normalized2 = String(status || "").toLowerCase();
6622
+ if (normalized2.includes("definitivo")) return "red";
6623
+ if (normalized2.includes("tempor\xE1rio")) return "orange";
6624
+ if (normalized2.includes("processando")) return "blue";
6625
+ if (normalized2.includes("pendente")) return "yellow";
6626
+ if (normalized2.includes("conclu\xEDdo")) return "green";
6627
+ return "gray";
6628
+ }
6629
+ function integrationErrorMessage2(error) {
6630
+ const candidate = error;
6631
+ const message = candidate?.response?.data?.error?.message || candidate?.response?.data?.message || candidate?.message;
6632
+ return typeof message === "string" && message.trim() ? message : "N\xE3o foi poss\xEDvel concluir a opera\xE7\xE3o.";
6633
+ }
6634
+ function diagnosticMessage2(value2) {
6635
+ if (!value2) return "";
6636
+ if (typeof value2 === "string") return value2;
6637
+ if (typeof value2 === "object") {
6638
+ const candidate = value2;
6639
+ const message = candidate.message || candidate.error?.message;
6640
+ if (typeof message === "string") return message;
6641
+ }
6642
+ return JSON.stringify(value2);
6643
+ }
6644
+ function NativeSelect5({
6645
+ value: value2,
6646
+ onChange,
6647
+ children,
6648
+ ariaLabel
6649
+ }) {
6650
+ return /* @__PURE__ */ jsx40(
6651
+ "select",
6652
+ {
6653
+ "aria-label": ariaLabel,
6654
+ style: {
6655
+ minWidth: "190px",
6656
+ height: "34px",
6657
+ border: "1px solid #e2e8f0",
6658
+ borderRadius: "6px",
6659
+ padding: "0 8px",
6660
+ background: "white"
6661
+ },
6662
+ value: value2,
6663
+ onChange: (event) => onChange(event.currentTarget.value),
6664
+ children
6665
+ }
6666
+ );
6667
+ }
6668
+ function JsonDetails({ label, value: value2 }) {
6669
+ if (value2 === void 0 || value2 === null) return null;
6670
+ if (typeof value2 === "object" && !Array.isArray(value2) && !Object.keys(value2).length) return null;
6671
+ return /* @__PURE__ */ jsxs25("details", { children: [
6672
+ /* @__PURE__ */ jsx40("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: label }),
6673
+ /* @__PURE__ */ jsx40(
6674
+ Box24,
6675
+ {
6676
+ as: "pre",
6677
+ mt: 2,
6678
+ p: 3,
6679
+ borderRadius: "md",
6680
+ bg: "gray.50",
6681
+ overflowX: "auto",
6682
+ whiteSpace: "pre-wrap",
6683
+ fontSize: "xs",
6684
+ children: JSON.stringify(value2, null, 2)
6685
+ }
6686
+ )
6687
+ ] });
6688
+ }
6689
+ function TicketDetails({ ticket }) {
6690
+ const error = diagnosticMessage2(ticket.lastError);
6691
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 3, pt: 3, mt: 3, borderTopWidth: "1px", children: [
6692
+ /* @__PURE__ */ jsxs25(Box24, { display: "grid", gridTemplateColumns: { base: "1fr", md: "repeat(3, minmax(0, 1fr))" }, gap: 3, children: [
6693
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6694
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "ID completo" }),
6695
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", wordBreak: "break-all", children: ticket._id })
6696
+ ] }),
6697
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6698
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Chave de idempot\xEAncia" }),
6699
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", wordBreak: "break-all", children: ticket.idempotencyKey || "\u2014" })
6700
+ ] }),
6701
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6702
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Status anterior" }),
6703
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: ticket.previousStatus || "\u2014" })
6704
+ ] }),
6705
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6706
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Criado" }),
6707
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: dateTime3(ticket.createdAt) })
6708
+ ] }),
6709
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6710
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Atualizado" }),
6711
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: dateTime3(ticket.updatedAt) })
6712
+ ] }),
6713
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6714
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Conclu\xEDdo" }),
6715
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: dateTime3(ticket.completedAt) })
6716
+ ] }),
6717
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6718
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Worker" }),
6719
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: ticket.lockedBy || "\u2014" })
6720
+ ] }),
6721
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6722
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Lease expira" }),
6723
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: dateTime3(ticket.leaseExpiresAt) })
6724
+ ] }),
6725
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6726
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Heartbeat" }),
6727
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: dateTime3(ticket.heartbeatAt) })
6728
+ ] })
6729
+ ] }),
6730
+ error ? /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderColor: "red.100", borderRadius: "md", bg: "red.50", p: 3, children: [
6731
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.600", children: "\xDAltimo erro" }),
6732
+ /* @__PURE__ */ jsx40(Text25, { color: "red.700", children: error })
6733
+ ] }) : null,
6734
+ ticket.archiveReason ? /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
6735
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: "Motivo do arquivamento" }),
6736
+ /* @__PURE__ */ jsx40(Text25, { children: ticket.archiveReason })
6737
+ ] }) : null,
6738
+ /* @__PURE__ */ jsx40(JsonDetails, { label: "Payload sanitizado", value: ticket.payload }),
6739
+ /* @__PURE__ */ jsx40(JsonDetails, { label: "Resposta sanitizada", value: ticket.responseSummary }),
6740
+ /* @__PURE__ */ jsx40(JsonDetails, { label: "Erro sanitizado", value: ticket.lastError })
6741
+ ] });
6742
+ }
6743
+ function canReprocess(status) {
6744
+ return ["Erro tempor\xE1rio", "Erro definitivo", "Arquivado"].includes(status);
6745
+ }
6746
+ function canArchive(status) {
6747
+ return ["Erro tempor\xE1rio", "Erro definitivo"].includes(status);
6748
+ }
6749
+ function TicketActions({
6750
+ ticket,
6751
+ mutation,
6752
+ onToggle,
6753
+ expanded
6754
+ }) {
6755
+ const pending = mutation.isPending && mutation.variables?.id === ticket._id;
6756
+ return /* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", justify: "flex-end", children: [
6757
+ /* @__PURE__ */ jsx40(Button17, { size: "xs", variant: "outline", onClick: onToggle, "aria-expanded": expanded, children: expanded ? "Ocultar" : "Detalhes" }),
6758
+ canReprocess(ticket.status) ? /* @__PURE__ */ jsx40(
6759
+ Button17,
6760
+ {
6761
+ size: "xs",
6762
+ variant: "outline",
6763
+ loading: pending && mutation.variables?.action === "reprocess",
6764
+ onClick: () => mutation.mutate({ id: ticket._id, action: "reprocess" }),
6765
+ children: "Reprocessar"
6766
+ }
6767
+ ) : null,
6768
+ canArchive(ticket.status) ? /* @__PURE__ */ jsx40(
6769
+ Button17,
6770
+ {
6771
+ size: "xs",
6772
+ variant: "outline",
6773
+ colorPalette: "red",
6774
+ loading: pending && mutation.variables?.action === "archive",
6775
+ onClick: () => mutation.mutate({ id: ticket._id, action: "archive" }),
6776
+ children: "Arquivar"
6777
+ }
6778
+ ) : null
6779
+ ] });
6780
+ }
6781
+ function TicketCard({
6782
+ ticket,
6783
+ expanded,
6784
+ onToggle,
6785
+ mutation
6786
+ }) {
6787
+ const error = diagnosticMessage2(ticket.lastError);
6788
+ return /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: [
6789
+ /* @__PURE__ */ jsxs25(Flex17, { align: "start", justify: "space-between", gap: 2, children: [
6790
+ /* @__PURE__ */ jsxs25(Box24, { minW: 0, children: [
6791
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", title: ticket._id, children: [
6792
+ "#",
6793
+ shortId(ticket._id)
6794
+ ] }),
6795
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", wordBreak: "break-word", children: ticket.handler })
6796
+ ] }),
6797
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticket.status), children: ticket.status })
6798
+ ] }),
6799
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.600", mt: 2, children: [
6800
+ ticket.resource || "sem recurso",
6801
+ " \xB7 ",
6802
+ ticket.operation || "execute"
6803
+ ] }),
6804
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", mt: 1, wordBreak: "break-word", children: [
6805
+ ticket.aggregateType || "sem agregado",
6806
+ ticket.aggregateId ? ` \xB7 ${ticket.aggregateId}` : ""
6807
+ ] }),
6808
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, mt: 2, wrap: "wrap", children: [
6809
+ /* @__PURE__ */ jsxs25(Badge7, { variant: "outline", children: [
6810
+ "Tentativas: ",
6811
+ ticket.attempts ?? 0
6812
+ ] }),
6813
+ /* @__PURE__ */ jsxs25(Badge7, { variant: "outline", children: [
6814
+ "Criado: ",
6815
+ dateTime3(ticket.createdAt)
6816
+ ] })
6817
+ ] }),
6818
+ error ? /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "red.600", mt: 2, children: error }) : null,
6819
+ /* @__PURE__ */ jsx40(Box24, { mt: 3, children: /* @__PURE__ */ jsx40(TicketActions, { ticket, mutation, onToggle, expanded }) }),
6820
+ expanded ? /* @__PURE__ */ jsx40(TicketDetails, { ticket }) : null
6821
+ ] });
6822
+ }
6823
+ function CoreIntegrationTickets({ provider = "omie" }) {
6824
+ const { http } = useOonApi();
6825
+ const [view, setView] = useState15("list");
6826
+ const [status, setStatus] = useState15("");
6827
+ const [searchInput, setSearchInput] = useState15("");
6828
+ const [search, setSearch] = useState15("");
6829
+ const [page, setPage] = useState15(1);
6830
+ const [expandedId, setExpandedId] = useState15(null);
6831
+ const limit = view === "board" ? 200 : 25;
6832
+ useEffect10(() => {
6833
+ const timeout = window.setTimeout(() => {
6834
+ setSearch(searchInput.trim());
6835
+ setPage(1);
6836
+ }, 350);
6837
+ return () => window.clearTimeout(timeout);
6838
+ }, [searchInput]);
6839
+ const queue = useQuery11({
6840
+ queryKey: ["core-integration-tickets", provider, view, status, search, page],
6841
+ queryFn: async () => (await http.get("/integrations/queue", {
6842
+ params: {
6843
+ provider,
6844
+ status: status || void 0,
6845
+ search: search || void 0,
6846
+ page,
6847
+ limit
6848
+ }
6849
+ })).data
6850
+ });
6851
+ const action = useMutation5({
6852
+ mutationFn: async ({ id, action: ticketAction }) => {
6853
+ const body = ticketAction === "archive" ? { reason: "Arquivado manualmente pela vis\xE3o de tickets." } : {};
6854
+ return http.post(
6855
+ `/integrations/queue/${id}/${ticketAction}`,
6856
+ body,
6857
+ { headers: { "x-oon-origin": "integration" } }
6858
+ );
6859
+ },
6860
+ onSuccess: async () => {
6861
+ setExpandedId(null);
6862
+ await queue.refetch();
6863
+ }
6864
+ });
6865
+ useEffect10(() => {
6866
+ const totalPages2 = queue.data?.pagination?.totalPages ?? 1;
6867
+ if (page > totalPages2) setPage(Math.max(1, totalPages2));
6868
+ }, [page, queue.data?.pagination?.totalPages]);
6869
+ const tickets = queue.data?.results ?? [];
6870
+ const grouped = useMemo9(() => Object.fromEntries(
6871
+ TICKET_STATUSES.map((ticketStatus) => [ticketStatus, tickets.filter((ticket) => ticket.status === ticketStatus)])
6872
+ ), [tickets]);
6873
+ if (queue.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
6874
+ if (queue.error && !queue.data) return /* @__PURE__ */ jsx40(ErrorState, { error: queue.error });
6875
+ const pagination = queue.data?.pagination;
6876
+ const totalPages = Math.max(1, pagination?.totalPages ?? 1);
6877
+ const totalItems = pagination?.totalItems ?? 0;
6878
+ const statuses = queue.data?.summary?.statuses ?? {};
6879
+ const operationError = action.error || queue.error;
6880
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
6881
+ /* @__PURE__ */ jsxs25(Flex17, { align: "start", justify: "space-between", gap: 3, wrap: "wrap", children: [
6882
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6883
+ /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Tickets de integra\xE7\xE3o" }),
6884
+ /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Acompanhe cada opera\xE7\xE3o da fila, seus par\xE2metros sanitizados, tentativas, erros e resultado." })
6885
+ ] }),
6886
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
6887
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: view === "list" ? "solid" : "outline", onClick: () => {
6888
+ setView("list");
6889
+ setPage(1);
6890
+ }, children: "Lista" }),
6891
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: view === "board" ? "solid" : "outline", onClick: () => {
6892
+ setView("board");
6893
+ setPage(1);
6894
+ }, children: "Quadro" }),
6895
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", loading: queue.isFetching, onClick: () => queue.refetch(), children: "Atualizar" })
6896
+ ] })
6897
+ ] }),
6898
+ /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
6899
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 3, align: "center", wrap: "wrap", children: [
6900
+ /* @__PURE__ */ jsx40(
6901
+ Input9,
6902
+ {
6903
+ size: "sm",
6904
+ value: searchInput,
6905
+ onChange: (event) => setSearchInput(event.currentTarget.value),
6906
+ placeholder: "Pesquisar ID, handler, recurso, agregado ou idempot\xEAncia",
6907
+ flex: "1",
6908
+ minW: "280px"
6909
+ }
6910
+ ),
6911
+ /* @__PURE__ */ jsxs25(
6912
+ NativeSelect5,
6913
+ {
6914
+ ariaLabel: "Filtrar tickets por status",
6915
+ value: status,
6916
+ onChange: (value2) => {
6917
+ setStatus(value2);
6918
+ setPage(1);
6919
+ },
6920
+ children: [
6921
+ /* @__PURE__ */ jsx40("option", { value: "", children: "Todos os status" }),
6922
+ TICKET_STATUSES.map((ticketStatus) => /* @__PURE__ */ jsx40("option", { value: ticketStatus, children: ticketStatus }, ticketStatus))
6923
+ ]
6924
+ }
6925
+ ),
6926
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
6927
+ totalItems,
6928
+ " ticket(s)"
6929
+ ] })
6930
+ ] }),
6931
+ /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", mt: 3, children: TICKET_STATUSES.map((ticketStatus) => /* @__PURE__ */ jsxs25(
6932
+ Button17,
6933
+ {
6934
+ size: "xs",
6935
+ variant: status === ticketStatus ? "solid" : "outline",
6936
+ colorPalette: statusPalette2(ticketStatus),
6937
+ onClick: () => {
6938
+ setStatus((current) => current === ticketStatus ? "" : ticketStatus);
6939
+ setPage(1);
6940
+ },
6941
+ children: [
6942
+ ticketStatus,
6943
+ ": ",
6944
+ statuses[ticketStatus] ?? 0
6945
+ ]
6946
+ },
6947
+ ticketStatus
6948
+ )) })
6949
+ ] }),
6950
+ view === "list" ? /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", overflowX: "auto", children: /* @__PURE__ */ jsxs25(Box24, { minW: "1080px", children: [
6951
+ /* @__PURE__ */ jsx40(
6952
+ Box24,
6953
+ {
6954
+ display: "grid",
6955
+ gridTemplateColumns: "1.25fr 1.5fr 1.15fr .75fr 1.15fr .9fr 1.3fr",
6956
+ gap: 3,
6957
+ px: 3,
6958
+ py: 2,
6959
+ bg: "gray.50",
6960
+ borderBottomWidth: "1px",
6961
+ children: ["Ticket", "Opera\xE7\xE3o", "Agregado", "Tentativas", "Datas", "Status", "A\xE7\xF5es"].map((label) => /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", fontWeight: "semibold", color: "gray.600", children: label }, label))
6962
+ }
6963
+ ),
6964
+ tickets.length ? tickets.map((ticket) => {
6965
+ const expanded = expandedId === ticket._id;
6966
+ const error = diagnosticMessage2(ticket.lastError);
6967
+ return /* @__PURE__ */ jsxs25(Box24, { px: 3, py: 3, borderBottomWidth: "1px", _last: { borderBottomWidth: 0 }, children: [
6968
+ /* @__PURE__ */ jsxs25(
6969
+ Box24,
6970
+ {
6971
+ display: "grid",
6972
+ gridTemplateColumns: "1.25fr 1.5fr 1.15fr .75fr 1.15fr .9fr 1.3fr",
6973
+ gap: 3,
6974
+ alignItems: "start",
6975
+ children: [
6976
+ /* @__PURE__ */ jsxs25(Box24, { minW: 0, children: [
6977
+ /* @__PURE__ */ jsxs25(Text25, { fontWeight: "semibold", title: ticket._id, children: [
6978
+ "#",
6979
+ shortId(ticket._id)
6980
+ ] }),
6981
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: ticket.provider })
6982
+ ] }),
6983
+ /* @__PURE__ */ jsxs25(Box24, { minW: 0, children: [
6984
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", fontWeight: "medium", wordBreak: "break-word", children: ticket.handler }),
6985
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", children: [
6986
+ ticket.resource || "\u2014",
6987
+ " \xB7 ",
6988
+ ticket.operation || "execute"
6989
+ ] }),
6990
+ error ? /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "red.600", mt: 1, children: error }) : null
6991
+ ] }),
6992
+ /* @__PURE__ */ jsxs25(Box24, { minW: 0, children: [
6993
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: ticket.aggregateType || "\u2014" }),
6994
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", wordBreak: "break-all", children: ticket.aggregateId || "\u2014" })
6995
+ ] }),
6996
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6997
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", children: ticket.attempts ?? 0 }),
6998
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", children: [
6999
+ "Pr\xF3xima: ",
7000
+ dateTime3(ticket.nextAttemptAt)
7001
+ ] })
7002
+ ] }),
7003
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7004
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", children: [
7005
+ "Criado: ",
7006
+ dateTime3(ticket.createdAt)
7007
+ ] }),
7008
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", children: [
7009
+ "Atualizado: ",
7010
+ dateTime3(ticket.updatedAt)
7011
+ ] }),
7012
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", children: [
7013
+ "Conclu\xEDdo: ",
7014
+ dateTime3(ticket.completedAt)
7015
+ ] })
7016
+ ] }),
7017
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticket.status), width: "fit-content", children: ticket.status }),
7018
+ /* @__PURE__ */ jsx40(
7019
+ TicketActions,
7020
+ {
7021
+ ticket,
7022
+ mutation: action,
7023
+ expanded,
7024
+ onToggle: () => setExpandedId((current) => current === ticket._id ? null : ticket._id)
7025
+ }
7026
+ )
7027
+ ]
7028
+ }
7029
+ ),
7030
+ expanded ? /* @__PURE__ */ jsx40(TicketDetails, { ticket }) : null
7031
+ ] }, ticket._id);
7032
+ }) : /* @__PURE__ */ jsx40(Text25, { p: 5, color: "gray.400", children: "Nenhum ticket encontrado com os filtros informados." })
7033
+ ] }) }) : /* @__PURE__ */ jsx40(Box24, { overflowX: "auto", pb: 2, children: /* @__PURE__ */ jsx40(Flex17, { align: "start", gap: 3, minW: `${TICKET_STATUSES.length * 290}px`, children: TICKET_STATUSES.map((ticketStatus) => /* @__PURE__ */ jsxs25(Box24, { width: "280px", flex: "0 0 280px", bg: "gray.50", borderRadius: "md", p: 2, children: [
7034
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", mb: 2, children: [
7035
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticketStatus), children: ticketStatus }),
7036
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", children: statuses[ticketStatus] ?? 0 })
7037
+ ] }),
7038
+ /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: grouped[ticketStatus].length ? grouped[ticketStatus].map((ticket) => /* @__PURE__ */ jsx40(
7039
+ TicketCard,
7040
+ {
7041
+ ticket,
7042
+ mutation: action,
7043
+ expanded: expandedId === ticket._id,
7044
+ onToggle: () => setExpandedId((current) => current === ticket._id ? null : ticket._id)
7045
+ },
7046
+ ticket._id
7047
+ )) : /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.400", p: 2, children: "Nenhum ticket nesta p\xE1gina." }) })
7048
+ ] }, ticketStatus)) }) }),
7049
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7050
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7051
+ "P\xE1gina ",
7052
+ pagination?.currentPage ?? page,
7053
+ " de ",
7054
+ totalPages,
7055
+ " \xB7 ",
7056
+ pagination?.itemsPerPage ?? limit,
7057
+ " por p\xE1gina",
7058
+ view === "board" && totalItems > limit ? " \xB7 o quadro \xE9 paginado" : ""
7059
+ ] }),
7060
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
7061
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", disabled: page <= 1, onClick: () => setPage((current) => Math.max(1, current - 1)), children: "Anterior" }),
7062
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", disabled: page >= totalPages, onClick: () => setPage((current) => Math.min(totalPages, current + 1)), children: "Pr\xF3xima" })
7063
+ ] })
7064
+ ] }),
7065
+ operationError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(operationError) }) : null
7066
+ ] });
7067
+ }
7068
+
7069
+ // src/components/CoreOmieIntegrationWorkspace.tsx
7070
+ import { useState as useState17 } from "react";
7071
+ import { Button as Button19, Flex as Flex19, Stack as Stack13 } from "@chakra-ui/react";
7072
+
7073
+ // src/components/CoreOmieIntegration.tsx
7074
+ import { useEffect as useEffect11, useState as useState16 } from "react";
7075
+ import { Badge as Badge8, Box as Box25, Button as Button18, Flex as Flex18, Heading as Heading15, Input as Input10, Stack as Stack12, Text as Text26 } from "@chakra-ui/react";
7076
+ import { useMutation as useMutation6, useQuery as useQuery12 } from "@tanstack/react-query";
7077
+ import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
7078
+ function dateTime4(value2) {
7079
+ if (!value2) return "\u2014";
7080
+ const date = new Date(value2);
7081
+ return Number.isNaN(date.getTime()) ? value2 : date.toLocaleString("pt-BR");
7082
+ }
7083
+ function statusPalette3(status) {
6609
7084
  const normalized2 = String(status || "").toLowerCase();
6610
7085
  if (normalized2.includes("erro") || normalized2.includes("error") || normalized2.includes("inativo")) return "red";
6611
7086
  if (normalized2.includes("process") || normalized2.includes("pendente") || normalized2.includes("not-tested")) return "yellow";
6612
7087
  if (normalized2.includes("conclu\xEDdo") || normalized2.includes("ativo") || normalized2 === "ok") return "green";
6613
7088
  return "gray";
6614
7089
  }
6615
- function integrationErrorMessage2(error) {
7090
+ function integrationErrorMessage3(error) {
6616
7091
  const candidate = error;
6617
7092
  const message = candidate?.response?.data?.error?.message || candidate?.response?.data?.message || candidate?.message;
6618
7093
  return typeof message === "string" && message.trim() ? message : "N\xE3o foi poss\xEDvel concluir a opera\xE7\xE3o.";
@@ -6640,12 +7115,12 @@ async function copyText(value2) {
6640
7115
  document.execCommand("copy");
6641
7116
  textarea.remove();
6642
7117
  }
6643
- function NativeSelect5({
7118
+ function NativeSelect6({
6644
7119
  value: value2,
6645
7120
  onChange,
6646
7121
  children
6647
7122
  }) {
6648
- return /* @__PURE__ */ jsx40(
7123
+ return /* @__PURE__ */ jsx41(
6649
7124
  "select",
6650
7125
  {
6651
7126
  style: {
@@ -6664,11 +7139,11 @@ function NativeSelect5({
6664
7139
  }
6665
7140
  function OmieConfigurationTab() {
6666
7141
  const { http } = useOonApi();
6667
- const configuration = useQuery11({
7142
+ const configuration = useQuery12({
6668
7143
  queryKey: ["core-omie", "configuration"],
6669
7144
  queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
6670
7145
  });
6671
- const [draft, setDraft] = useState15({
7146
+ const [draft, setDraft] = useState16({
6672
7147
  instanceId: "default",
6673
7148
  label: "Omie",
6674
7149
  active: true,
@@ -6678,7 +7153,7 @@ function OmieConfigurationTab() {
6678
7153
  appSecret: ""
6679
7154
  });
6680
7155
  const selected = (configuration.data ?? []).find((item) => item.instanceId === draft.instanceId) ?? configuration.data?.[0];
6681
- useEffect10(() => {
7156
+ useEffect11(() => {
6682
7157
  if (!selected) return;
6683
7158
  setDraft((current) => ({
6684
7159
  ...current,
@@ -6691,7 +7166,7 @@ function OmieConfigurationTab() {
6691
7166
  appSecret: ""
6692
7167
  }));
6693
7168
  }, [selected?.instanceId, selected?.updatedAt]);
6694
- const save = useMutation5({
7169
+ const save = useMutation6({
6695
7170
  mutationFn: () => http.put(
6696
7171
  `/integrations/providers/omie/configuration/${draft.instanceId}`,
6697
7172
  {
@@ -6709,7 +7184,7 @@ function OmieConfigurationTab() {
6709
7184
  await configuration.refetch();
6710
7185
  }
6711
7186
  });
6712
- const testConnection = useMutation5({
7187
+ const testConnection = useMutation6({
6713
7188
  mutationFn: () => http.post(
6714
7189
  `/integrations/providers/omie/configuration/${draft.instanceId}/test`,
6715
7190
  {},
@@ -6717,30 +7192,30 @@ function OmieConfigurationTab() {
6717
7192
  ),
6718
7193
  onSuccess: () => configuration.refetch()
6719
7194
  });
6720
- if (configuration.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
6721
- if (configuration.error) return /* @__PURE__ */ jsx40(ErrorState, { error: configuration.error });
7195
+ if (configuration.isLoading) return /* @__PURE__ */ jsx41(LoadingScreen, {});
7196
+ if (configuration.error) return /* @__PURE__ */ jsx41(ErrorState, { error: configuration.error });
6722
7197
  const error = save.error || testConnection.error;
6723
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
6724
- /* @__PURE__ */ jsxs25(Box24, { children: [
6725
- /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Configura\xE7\xF5es" }),
6726
- /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. O token do webhook \xE9 gerado e administrado automaticamente." })
7198
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 4, children: [
7199
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7200
+ /* @__PURE__ */ jsx41(Heading15, { size: "md", children: "Configura\xE7\xF5es" }),
7201
+ /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. O token do webhook \xE9 gerado e administrado automaticamente." })
6727
7202
  ] }),
6728
- /* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
6729
- /* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
6730
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
6731
- /* @__PURE__ */ jsx40(
6732
- NativeSelect5,
7203
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 3, wrap: "wrap", children: [
7204
+ /* @__PURE__ */ jsxs26(Box25, { minW: "180px", flex: "1", children: [
7205
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
7206
+ /* @__PURE__ */ jsx41(
7207
+ NativeSelect6,
6733
7208
  {
6734
7209
  value: draft.instanceId,
6735
7210
  onChange: (instanceId) => setDraft((current) => ({ ...current, instanceId })),
6736
- children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx40("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId))
7211
+ children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx41("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId))
6737
7212
  }
6738
7213
  )
6739
7214
  ] }),
6740
- /* @__PURE__ */ jsxs25(Box24, { minW: "240px", flex: "2", children: [
6741
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Nome" }),
6742
- /* @__PURE__ */ jsx40(
6743
- Input9,
7215
+ /* @__PURE__ */ jsxs26(Box25, { minW: "240px", flex: "2", children: [
7216
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "Nome" }),
7217
+ /* @__PURE__ */ jsx41(
7218
+ Input10,
6744
7219
  {
6745
7220
  size: "sm",
6746
7221
  value: draft.label,
@@ -6748,25 +7223,25 @@ function OmieConfigurationTab() {
6748
7223
  }
6749
7224
  )
6750
7225
  ] }),
6751
- /* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
6752
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Ambiente" }),
6753
- /* @__PURE__ */ jsxs25(
6754
- NativeSelect5,
7226
+ /* @__PURE__ */ jsxs26(Box25, { minW: "180px", flex: "1", children: [
7227
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "Ambiente" }),
7228
+ /* @__PURE__ */ jsxs26(
7229
+ NativeSelect6,
6755
7230
  {
6756
7231
  value: draft.environment,
6757
7232
  onChange: (environment) => setDraft((current) => ({ ...current, environment })),
6758
7233
  children: [
6759
- /* @__PURE__ */ jsx40("option", { value: "production", children: "Produ\xE7\xE3o" }),
6760
- /* @__PURE__ */ jsx40("option", { value: "homologation", children: "Homologa\xE7\xE3o" })
7234
+ /* @__PURE__ */ jsx41("option", { value: "production", children: "Produ\xE7\xE3o" }),
7235
+ /* @__PURE__ */ jsx41("option", { value: "homologation", children: "Homologa\xE7\xE3o" })
6761
7236
  ]
6762
7237
  }
6763
7238
  )
6764
7239
  ] })
6765
7240
  ] }),
6766
- /* @__PURE__ */ jsxs25(Box24, { children: [
6767
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL base" }),
6768
- /* @__PURE__ */ jsx40(
6769
- Input9,
7241
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7242
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL base" }),
7243
+ /* @__PURE__ */ jsx41(
7244
+ Input10,
6770
7245
  {
6771
7246
  size: "sm",
6772
7247
  value: draft.baseUrl,
@@ -6774,14 +7249,14 @@ function OmieConfigurationTab() {
6774
7249
  }
6775
7250
  )
6776
7251
  ] }),
6777
- /* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
6778
- /* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
6779
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: [
7252
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 3, wrap: "wrap", children: [
7253
+ /* @__PURE__ */ jsxs26(Box25, { minW: "260px", flex: "1", children: [
7254
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: [
6780
7255
  "App Key ",
6781
7256
  selected?.appKeyMasked ? `(${selected.appKeyMasked})` : ""
6782
7257
  ] }),
6783
- /* @__PURE__ */ jsx40(
6784
- Input9,
7258
+ /* @__PURE__ */ jsx41(
7259
+ Input10,
6785
7260
  {
6786
7261
  size: "sm",
6787
7262
  type: "password",
@@ -6791,10 +7266,10 @@ function OmieConfigurationTab() {
6791
7266
  }
6792
7267
  )
6793
7268
  ] }),
6794
- /* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
6795
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "App Secret" }),
6796
- /* @__PURE__ */ jsx40(
6797
- Input9,
7269
+ /* @__PURE__ */ jsxs26(Box25, { minW: "260px", flex: "1", children: [
7270
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "App Secret" }),
7271
+ /* @__PURE__ */ jsx41(
7272
+ Input10,
6798
7273
  {
6799
7274
  size: "sm",
6800
7275
  type: "password",
@@ -6805,10 +7280,10 @@ function OmieConfigurationTab() {
6805
7280
  )
6806
7281
  ] })
6807
7282
  ] }),
6808
- /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6809
- /* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
6810
- /* @__PURE__ */ jsxs25("label", { children: [
6811
- /* @__PURE__ */ jsx40(
7283
+ /* @__PURE__ */ jsxs26(Flex18, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7284
+ /* @__PURE__ */ jsxs26(Flex18, { align: "center", gap: 2, wrap: "wrap", children: [
7285
+ /* @__PURE__ */ jsxs26("label", { children: [
7286
+ /* @__PURE__ */ jsx41(
6812
7287
  "input",
6813
7288
  {
6814
7289
  type: "checkbox",
@@ -6819,22 +7294,22 @@ function OmieConfigurationTab() {
6819
7294
  " ",
6820
7295
  "Integra\xE7\xE3o ativa"
6821
7296
  ] }),
6822
- /* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(selected?.connectionStatus), children: [
7297
+ /* @__PURE__ */ jsxs26(Badge8, { colorPalette: statusPalette3(selected?.connectionStatus), children: [
6823
7298
  "Conex\xE3o: ",
6824
7299
  selected?.connectionStatus ?? "n\xE3o testada"
6825
7300
  ] }),
6826
- /* @__PURE__ */ jsxs25(Badge7, { colorPalette: selected?.webhookConfigured ? "green" : "yellow", children: [
7301
+ /* @__PURE__ */ jsxs26(Badge8, { colorPalette: selected?.webhookConfigured ? "green" : "yellow", children: [
6827
7302
  "Webhook: ",
6828
7303
  selected?.webhookConfigured ? "configurado" : "ser\xE1 gerado"
6829
7304
  ] }),
6830
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", children: [
7305
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "xs", color: "gray.500", children: [
6831
7306
  "\xDAltimo teste: ",
6832
- dateTime3(selected?.lastConnectionTestAt)
7307
+ dateTime4(selected?.lastConnectionTestAt)
6833
7308
  ] })
6834
7309
  ] }),
6835
- /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
6836
- /* @__PURE__ */ jsx40(
6837
- Button17,
7310
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 2, children: [
7311
+ /* @__PURE__ */ jsx41(
7312
+ Button18,
6838
7313
  {
6839
7314
  size: "sm",
6840
7315
  variant: "outline",
@@ -6843,34 +7318,34 @@ function OmieConfigurationTab() {
6843
7318
  children: "Testar conex\xE3o"
6844
7319
  }
6845
7320
  ),
6846
- /* @__PURE__ */ jsx40(Button17, { size: "sm", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xF5es" })
7321
+ /* @__PURE__ */ jsx41(Button18, { size: "sm", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xF5es" })
6847
7322
  ] })
6848
7323
  ] }),
6849
- selected?.lastConnectionError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: selected.lastConnectionError }) : null,
6850
- error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
7324
+ selected?.lastConnectionError ? /* @__PURE__ */ jsx41(Text26, { color: "red.600", children: selected.lastConnectionError }) : null,
7325
+ error ? /* @__PURE__ */ jsx41(Text26, { color: "red.600", children: integrationErrorMessage3(error) }) : null
6851
7326
  ] });
6852
7327
  }
6853
7328
  function OmieSynchronizationTab() {
6854
7329
  const { http } = useOonApi();
6855
- const health = useQuery11({
7330
+ const health = useQuery12({
6856
7331
  queryKey: ["core-omie", "health"],
6857
7332
  queryFn: async () => {
6858
7333
  const providers = (await http.get("/integrations/health")).data?.results ?? [];
6859
7334
  return providers.find((provider2) => provider2.key === "omie") ?? null;
6860
7335
  }
6861
7336
  });
6862
- const mappings = useQuery11({
7337
+ const mappings = useQuery12({
6863
7338
  queryKey: ["core-omie", "mappings"],
6864
7339
  queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
6865
7340
  });
6866
- const queue = useQuery11({
7341
+ const queue = useQuery12({
6867
7342
  queryKey: ["core-omie", "queue"],
6868
7343
  queryFn: async () => (await http.get("/integrations/queue", {
6869
7344
  params: { provider: "omie", limit: 20 }
6870
7345
  })).data?.results ?? []
6871
7346
  });
6872
7347
  const refresh = () => Promise.all([health.refetch(), mappings.refetch(), queue.refetch()]);
6873
- const syncAll = useMutation5({
7348
+ const syncAll = useMutation6({
6874
7349
  mutationFn: () => http.post(
6875
7350
  "/integrations/providers/omie/sync-all",
6876
7351
  {},
@@ -6878,7 +7353,7 @@ function OmieSynchronizationTab() {
6878
7353
  ),
6879
7354
  onSuccess: refresh
6880
7355
  });
6881
- const syncResource = useMutation5({
7356
+ const syncResource = useMutation6({
6882
7357
  mutationFn: (resource) => http.post(
6883
7358
  `/integrations/providers/omie/resources/${resource}/sync`,
6884
7359
  {},
@@ -6886,7 +7361,7 @@ function OmieSynchronizationTab() {
6886
7361
  ),
6887
7362
  onSuccess: refresh
6888
7363
  });
6889
- const process = useMutation5({
7364
+ const process = useMutation6({
6890
7365
  mutationFn: () => http.post(
6891
7366
  "/integrations/actions/process-active",
6892
7367
  { provider: "omie" },
@@ -6894,43 +7369,43 @@ function OmieSynchronizationTab() {
6894
7369
  ),
6895
7370
  onSuccess: refresh
6896
7371
  });
6897
- if (health.isLoading || mappings.isLoading || queue.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
7372
+ if (health.isLoading || mappings.isLoading || queue.isLoading) return /* @__PURE__ */ jsx41(LoadingScreen, {});
6898
7373
  const error = health.error || mappings.error || queue.error || syncAll.error || syncResource.error || process.error;
6899
- if ((health.error || mappings.error || queue.error) && !health.data) return /* @__PURE__ */ jsx40(ErrorState, { error });
7374
+ if ((health.error || mappings.error || queue.error) && !health.data) return /* @__PURE__ */ jsx41(ErrorState, { error });
6900
7375
  const provider = health.data;
6901
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
6902
- /* @__PURE__ */ jsxs25(Flex17, { align: "start", justify: "space-between", gap: 3, wrap: "wrap", children: [
6903
- /* @__PURE__ */ jsxs25(Box24, { children: [
6904
- /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Sincroniza\xE7\xE3o" }),
6905
- /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execute listas declaradas e acompanhe o processamento da fila Omie." })
7376
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 5, children: [
7377
+ /* @__PURE__ */ jsxs26(Flex18, { align: "start", justify: "space-between", gap: 3, wrap: "wrap", children: [
7378
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7379
+ /* @__PURE__ */ jsx41(Heading15, { size: "md", children: "Sincroniza\xE7\xE3o" }),
7380
+ /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Execute listas declaradas e acompanhe o processamento da fila Omie." })
6906
7381
  ] }),
6907
- /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
6908
- /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" }),
6909
- /* @__PURE__ */ jsx40(Button17, { size: "sm", loading: syncAll.isPending, onClick: () => syncAll.mutate(), children: "Sincronizar tudo" })
7382
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 2, children: [
7383
+ /* @__PURE__ */ jsx41(Button18, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" }),
7384
+ /* @__PURE__ */ jsx41(Button18, { size: "sm", loading: syncAll.isPending, onClick: () => syncAll.mutate(), children: "Sincronizar tudo" })
6910
7385
  ] })
6911
7386
  ] }),
6912
- provider ? /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: [
6913
- /* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", mb: 3, children: [
6914
- /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(provider.status), children: provider.status || "\u2014" }),
6915
- /* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.queue) ? "yellow" : "green", children: [
7387
+ provider ? /* @__PURE__ */ jsxs26(Box25, { borderWidth: "1px", borderRadius: "md", p: 4, children: [
7388
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 2, wrap: "wrap", mb: 3, children: [
7389
+ /* @__PURE__ */ jsx41(Badge8, { colorPalette: statusPalette3(provider.status), children: provider.status || "\u2014" }),
7390
+ /* @__PURE__ */ jsxs26(Badge8, { colorPalette: countActive2(provider.queue) ? "yellow" : "green", children: [
6916
7391
  "Fila ativa: ",
6917
7392
  countActive2(provider.queue)
6918
7393
  ] }),
6919
- /* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.inbox) ? "yellow" : "green", children: [
7394
+ /* @__PURE__ */ jsxs26(Badge8, { colorPalette: countActive2(provider.inbox) ? "yellow" : "green", children: [
6920
7395
  "Eventos ativos: ",
6921
7396
  countActive2(provider.inbox)
6922
7397
  ] }),
6923
- /* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(provider.lastExecution?.status), children: [
7398
+ /* @__PURE__ */ jsxs26(Badge8, { colorPalette: statusPalette3(provider.lastExecution?.status), children: [
6924
7399
  "\xDAltima execu\xE7\xE3o: ",
6925
7400
  provider.lastExecution?.status || "sem hist\xF3rico"
6926
7401
  ] })
6927
7402
  ] }),
6928
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", mb: 3, children: [
7403
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", mb: 3, children: [
6929
7404
  "Pend\xEAncia mais antiga: ",
6930
- dateTime3(provider.oldestPendingAt)
7405
+ dateTime4(provider.oldestPendingAt)
6931
7406
  ] }),
6932
- /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx40(
6933
- Button17,
7407
+ /* @__PURE__ */ jsx41(Flex18, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx41(
7408
+ Button18,
6934
7409
  {
6935
7410
  size: "sm",
6936
7411
  variant: "outline",
@@ -6940,15 +7415,15 @@ function OmieSynchronizationTab() {
6940
7415
  },
6941
7416
  resource.key
6942
7417
  )) })
6943
- ] }) : /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Provider Omie n\xE3o registrado." }),
6944
- /* @__PURE__ */ jsxs25(Box24, { children: [
6945
- /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Listas declaradas" }),
6946
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (mappings.data?.lists ?? []).map((list) => {
7418
+ ] }) : /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Provider Omie n\xE3o registrado." }),
7419
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7420
+ /* @__PURE__ */ jsx41(Heading15, { size: "sm", mb: 3, children: "Listas declaradas" }),
7421
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: (mappings.data?.lists ?? []).map((list) => {
6947
7422
  const latest = list.executions?.[0];
6948
- return /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6949
- /* @__PURE__ */ jsxs25(Box24, { children: [
6950
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: list.label || list.key }),
6951
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7423
+ return /* @__PURE__ */ jsx41(Box25, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs26(Flex18, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7424
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7425
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "semibold", children: list.label || list.key }),
7426
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", children: [
6952
7427
  list.mode || "modo padr\xE3o",
6953
7428
  " \xB7 ",
6954
7429
  list.direction || "dire\xE7\xE3o padr\xE3o",
@@ -6956,59 +7431,59 @@ function OmieSynchronizationTab() {
6956
7431
  list.targetModel || "destino declarado"
6957
7432
  ] })
6958
7433
  ] }),
6959
- /* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", children: [
6960
- /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(latest?.status), children: latest?.status || "n\xE3o executada" }),
6961
- /* @__PURE__ */ jsx40(Badge7, { variant: "outline", children: dateTime3(latest?.lastCompletedAt) })
7434
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 2, wrap: "wrap", children: [
7435
+ /* @__PURE__ */ jsx41(Badge8, { colorPalette: statusPalette3(latest?.status), children: latest?.status || "n\xE3o executada" }),
7436
+ /* @__PURE__ */ jsx41(Badge8, { variant: "outline", children: dateTime4(latest?.lastCompletedAt) })
6962
7437
  ] })
6963
7438
  ] }) }, list.key);
6964
7439
  }) })
6965
7440
  ] }),
6966
- /* @__PURE__ */ jsxs25(Box24, { children: [
6967
- /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Fila recente" }),
6968
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (queue.data ?? []).length ? queue.data?.map((ticket) => /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6969
- /* @__PURE__ */ jsxs25(Box24, { children: [
6970
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: ticket.handler }),
6971
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7441
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7442
+ /* @__PURE__ */ jsx41(Heading15, { size: "sm", mb: 3, children: "Fila recente" }),
7443
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: (queue.data ?? []).length ? queue.data?.map((ticket) => /* @__PURE__ */ jsx41(Box25, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs26(Flex18, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7444
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7445
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "medium", children: ticket.handler }),
7446
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", children: [
6972
7447
  ticket.resource || "sem recurso",
6973
7448
  " \xB7 tentativas ",
6974
7449
  ticket.attempts ?? 0,
6975
7450
  " \xB7 pr\xF3xima ",
6976
- dateTime3(ticket.nextAttemptAt)
7451
+ dateTime4(ticket.nextAttemptAt)
6977
7452
  ] }),
6978
- ticket.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
7453
+ ticket.lastError?.message ? /* @__PURE__ */ jsx41(Text26, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
6979
7454
  ] }),
6980
- /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticket.status), children: ticket.status })
6981
- ] }) }, ticket._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma pend\xEAncia Omie." }) })
7455
+ /* @__PURE__ */ jsx41(Badge8, { colorPalette: statusPalette3(ticket.status), children: ticket.status })
7456
+ ] }) }, ticket._id)) : /* @__PURE__ */ jsx41(Text26, { color: "gray.400", children: "Nenhuma pend\xEAncia Omie." }) })
6982
7457
  ] }),
6983
- error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
7458
+ error ? /* @__PURE__ */ jsx41(Text26, { color: "red.600", children: integrationErrorMessage3(error) }) : null
6984
7459
  ] });
6985
7460
  }
6986
7461
  function OmieWebhooksTab() {
6987
7462
  const { http } = useOonApi();
6988
- const [instanceId, setInstanceId] = useState15("default");
6989
- const [copied, setCopied] = useState15(false);
6990
- const configuration = useQuery11({
7463
+ const [instanceId, setInstanceId] = useState16("default");
7464
+ const [copied, setCopied] = useState16(false);
7465
+ const configuration = useQuery12({
6991
7466
  queryKey: ["core-omie", "configuration"],
6992
7467
  queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
6993
7468
  });
6994
- const access = useQuery11({
7469
+ const access = useQuery12({
6995
7470
  queryKey: ["core-omie", "webhook-access", instanceId],
6996
7471
  enabled: Boolean(instanceId),
6997
7472
  queryFn: async () => (await http.get(
6998
7473
  `/integrations/providers/omie/configuration/${instanceId}/webhook`
6999
7474
  )).data
7000
7475
  });
7001
- const mappings = useQuery11({
7476
+ const mappings = useQuery12({
7002
7477
  queryKey: ["core-omie", "mappings"],
7003
7478
  queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
7004
7479
  });
7005
- const events = useQuery11({
7480
+ const events = useQuery12({
7006
7481
  queryKey: ["core-omie", "events"],
7007
7482
  queryFn: async () => (await http.get("/integrations/events", {
7008
7483
  params: { provider: "omie", limit: 20 }
7009
7484
  })).data?.results ?? []
7010
7485
  });
7011
- const rotate = useMutation5({
7486
+ const rotate = useMutation6({
7012
7487
  mutationFn: () => http.post(
7013
7488
  `/integrations/providers/omie/configuration/${instanceId}/webhook/rotate`,
7014
7489
  {},
@@ -7019,30 +7494,30 @@ function OmieWebhooksTab() {
7019
7494
  await Promise.all([access.refetch(), configuration.refetch()]);
7020
7495
  }
7021
7496
  });
7022
- useEffect10(() => {
7497
+ useEffect11(() => {
7023
7498
  const first = configuration.data?.[0]?.instanceId;
7024
7499
  if (first && !configuration.data?.some((item) => item.instanceId === instanceId)) setInstanceId(first);
7025
7500
  }, [configuration.data, instanceId]);
7026
- if (configuration.isLoading || mappings.isLoading || events.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
7501
+ if (configuration.isLoading || mappings.isLoading || events.isLoading) return /* @__PURE__ */ jsx41(LoadingScreen, {});
7027
7502
  const blockingError = configuration.error || mappings.error || events.error;
7028
- if (blockingError) return /* @__PURE__ */ jsx40(ErrorState, { error: blockingError });
7503
+ if (blockingError) return /* @__PURE__ */ jsx41(ErrorState, { error: blockingError });
7029
7504
  const url = absoluteWebhookUrl(access.data?.webhookPath);
7030
7505
  const operationError = access.error || rotate.error;
7031
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
7032
- /* @__PURE__ */ jsxs25(Box24, { children: [
7033
- /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Webhooks e gatilhos" }),
7034
- /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Copie a URL completa para o cadastro de webhook no Omie. O token \xE9 gerado automaticamente e pode ser rotacionado." })
7506
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 5, children: [
7507
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7508
+ /* @__PURE__ */ jsx41(Heading15, { size: "md", children: "Webhooks e gatilhos" }),
7509
+ /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Copie a URL completa para o cadastro de webhook no Omie. O token \xE9 gerado automaticamente e pode ser rotacionado." })
7035
7510
  ] }),
7036
- /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: /* @__PURE__ */ jsxs25(Stack11, { gap: 3, children: [
7037
- /* @__PURE__ */ jsxs25(Box24, { maxW: "360px", children: [
7038
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
7039
- /* @__PURE__ */ jsx40(NativeSelect5, { value: instanceId, onChange: setInstanceId, children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx40("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId)) })
7511
+ /* @__PURE__ */ jsx41(Box25, { borderWidth: "1px", borderRadius: "md", p: 4, children: /* @__PURE__ */ jsxs26(Stack12, { gap: 3, children: [
7512
+ /* @__PURE__ */ jsxs26(Box25, { maxW: "360px", children: [
7513
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
7514
+ /* @__PURE__ */ jsx41(NativeSelect6, { value: instanceId, onChange: setInstanceId, children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx41("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId)) })
7040
7515
  ] }),
7041
- /* @__PURE__ */ jsxs25(Box24, { children: [
7042
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL do webhook" }),
7043
- /* @__PURE__ */ jsxs25(Flex17, { gap: 2, align: "center", wrap: "wrap", children: [
7044
- /* @__PURE__ */ jsx40(
7045
- Input9,
7516
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7517
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL do webhook" }),
7518
+ /* @__PURE__ */ jsxs26(Flex18, { gap: 2, align: "center", wrap: "wrap", children: [
7519
+ /* @__PURE__ */ jsx41(
7520
+ Input10,
7046
7521
  {
7047
7522
  size: "sm",
7048
7523
  value: url,
@@ -7052,8 +7527,8 @@ function OmieWebhooksTab() {
7052
7527
  placeholder: access.isLoading ? "Gerando URL segura\u2026" : "URL indispon\xEDvel"
7053
7528
  }
7054
7529
  ),
7055
- /* @__PURE__ */ jsx40(
7056
- Button17,
7530
+ /* @__PURE__ */ jsx41(
7531
+ Button18,
7057
7532
  {
7058
7533
  size: "sm",
7059
7534
  variant: "outline",
@@ -7065,8 +7540,8 @@ function OmieWebhooksTab() {
7065
7540
  children: copied ? "Link copiado" : "Copiar link"
7066
7541
  }
7067
7542
  ),
7068
- /* @__PURE__ */ jsx40(
7069
- Button17,
7543
+ /* @__PURE__ */ jsx41(
7544
+ Button18,
7070
7545
  {
7071
7546
  size: "sm",
7072
7547
  colorPalette: "red",
@@ -7081,86 +7556,86 @@ function OmieWebhooksTab() {
7081
7556
  }
7082
7557
  )
7083
7558
  ] }),
7084
- /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mt: 2, children: "A rota\xE7\xE3o invalida imediatamente a URL anterior. Atualize o cadastro no Omie ap\xF3s gerar um novo token." })
7559
+ /* @__PURE__ */ jsx41(Text26, { fontSize: "xs", color: "gray.500", mt: 2, children: "A rota\xE7\xE3o invalida imediatamente a URL anterior. Atualize o cadastro no Omie ap\xF3s gerar um novo token." })
7085
7560
  ] })
7086
7561
  ] }) }),
7087
- /* @__PURE__ */ jsxs25(Box24, { children: [
7088
- /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Gatilhos declarados" }),
7089
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (mappings.data?.webhooks ?? []).length ? mappings.data?.webhooks?.map((webhook) => /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
7090
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: webhook.eventType }),
7091
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7562
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7563
+ /* @__PURE__ */ jsx41(Heading15, { size: "sm", mb: 3, children: "Gatilhos declarados" }),
7564
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: (mappings.data?.webhooks ?? []).length ? mappings.data?.webhooks?.map((webhook) => /* @__PURE__ */ jsxs26(Box25, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
7565
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "semibold", children: webhook.eventType }),
7566
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", children: [
7092
7567
  webhook.resource || "recurso gen\xE9rico",
7093
7568
  " \u2192 ",
7094
7569
  (webhook.actions ?? []).map((action) => action.handler).filter(Boolean).join(", ") || "sem a\xE7\xE3o declarada"
7095
7570
  ] })
7096
- ] }, `${webhook.eventType}:${webhook.resource || ""}`)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum gatilho declarado pela Central." }) })
7571
+ ] }, `${webhook.eventType}:${webhook.resource || ""}`)) : /* @__PURE__ */ jsx41(Text26, { color: "gray.400", children: "Nenhum gatilho declarado pela Central." }) })
7097
7572
  ] }),
7098
- /* @__PURE__ */ jsxs25(Box24, { children: [
7099
- /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Eventos recebidos" }),
7100
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (events.data ?? []).length ? events.data?.map((event) => /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7101
- /* @__PURE__ */ jsxs25(Box24, { children: [
7102
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: event.eventType || "Evento Omie" }),
7103
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7573
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7574
+ /* @__PURE__ */ jsx41(Heading15, { size: "sm", mb: 3, children: "Eventos recebidos" }),
7575
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: (events.data ?? []).length ? events.data?.map((event) => /* @__PURE__ */ jsx41(Box25, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs26(Flex18, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7576
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7577
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "medium", children: event.eventType || "Evento Omie" }),
7578
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", children: [
7104
7579
  event.resource || "sem recurso",
7105
7580
  " \xB7 recebido em ",
7106
- dateTime3(event.receivedAt),
7581
+ dateTime4(event.receivedAt),
7107
7582
  " \xB7 tentativas ",
7108
7583
  event.attempts ?? 0
7109
7584
  ] }),
7110
- event.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: event.lastError.message }) : null
7585
+ event.lastError?.message ? /* @__PURE__ */ jsx41(Text26, { fontSize: "sm", color: "red.600", children: event.lastError.message }) : null
7111
7586
  ] }),
7112
- /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(event.status), children: event.status })
7113
- ] }) }, event._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum webhook recebido." }) })
7587
+ /* @__PURE__ */ jsx41(Badge8, { colorPalette: statusPalette3(event.status), children: event.status })
7588
+ ] }) }, event._id)) : /* @__PURE__ */ jsx41(Text26, { color: "gray.400", children: "Nenhum webhook recebido." }) })
7114
7589
  ] }),
7115
- operationError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(operationError) }) : null
7590
+ operationError ? /* @__PURE__ */ jsx41(Text26, { color: "red.600", children: integrationErrorMessage3(operationError) }) : null
7116
7591
  ] });
7117
7592
  }
7118
- function diagnosticMessage2(value2) {
7593
+ function diagnosticMessage3(value2) {
7119
7594
  return value2.error?.message || value2.message || "Erro sem mensagem registrada.";
7120
7595
  }
7121
7596
  function OmieHistoryTab() {
7122
7597
  const { http } = useOonApi();
7123
- const [expandedId, setExpandedId] = useState15(null);
7124
- const history = useQuery11({
7598
+ const [expandedId, setExpandedId] = useState16(null);
7599
+ const history = useQuery12({
7125
7600
  queryKey: ["core-omie", "history"],
7126
7601
  queryFn: async () => (await http.get("/integrations/history", {
7127
7602
  params: { provider: "omie", limit: 30 }
7128
7603
  })).data?.results ?? []
7129
7604
  });
7130
- if (history.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
7131
- if (history.error) return /* @__PURE__ */ jsx40(ErrorState, { error: history.error });
7132
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
7133
- /* @__PURE__ */ jsxs25(Box24, { children: [
7134
- /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Hist\xF3rico" }),
7135
- /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execu\xE7\xF5es, erros por registro e diagn\xF3stico t\xE9cnico sanitizado." })
7605
+ if (history.isLoading) return /* @__PURE__ */ jsx41(LoadingScreen, {});
7606
+ if (history.error) return /* @__PURE__ */ jsx41(ErrorState, { error: history.error });
7607
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 4, children: [
7608
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7609
+ /* @__PURE__ */ jsx41(Heading15, { size: "md", children: "Hist\xF3rico" }),
7610
+ /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Execu\xE7\xF5es, erros por registro e diagn\xF3stico t\xE9cnico sanitizado." })
7136
7611
  ] }),
7137
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (history.data ?? []).length ? history.data?.map((execution) => {
7612
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: (history.data ?? []).length ? history.data?.map((execution) => {
7138
7613
  const expanded = expandedId === execution._id;
7139
7614
  const diagnostics = [...execution.errors ?? []];
7140
- if (execution.error?.message && !diagnostics.some((item) => diagnosticMessage2(item) === execution.error?.message)) {
7615
+ if (execution.error?.message && !diagnostics.some((item) => diagnosticMessage3(item) === execution.error?.message)) {
7141
7616
  diagnostics.push({ error: execution.error });
7142
7617
  }
7143
- return /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
7144
- /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7145
- /* @__PURE__ */ jsxs25(Box24, { children: [
7146
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: execution.title }),
7147
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7618
+ return /* @__PURE__ */ jsxs26(Box25, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
7619
+ /* @__PURE__ */ jsxs26(Flex18, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7620
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7621
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "semibold", children: execution.title }),
7622
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "sm", color: "gray.500", children: [
7148
7623
  execution.resource || "sem recurso",
7149
7624
  " \xB7 ",
7150
- dateTime3(execution.startedAt),
7625
+ dateTime4(execution.startedAt),
7151
7626
  " \xB7 ",
7152
7627
  execution.durationMs ?? 0,
7153
7628
  " ms"
7154
7629
  ] })
7155
7630
  ] }),
7156
- /* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
7157
- (execution.errorCount ?? diagnostics.length) > 0 ? /* @__PURE__ */ jsxs25(Badge7, { colorPalette: "red", children: [
7631
+ /* @__PURE__ */ jsxs26(Flex18, { align: "center", gap: 2, wrap: "wrap", children: [
7632
+ (execution.errorCount ?? diagnostics.length) > 0 ? /* @__PURE__ */ jsxs26(Badge8, { colorPalette: "red", children: [
7158
7633
  execution.errorCount ?? diagnostics.length,
7159
7634
  " erro(s)"
7160
7635
  ] }) : null,
7161
- /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(execution.status), children: execution.status }),
7162
- /* @__PURE__ */ jsx40(
7163
- Button17,
7636
+ /* @__PURE__ */ jsx41(Badge8, { colorPalette: statusPalette3(execution.status), children: execution.status }),
7637
+ /* @__PURE__ */ jsx41(
7638
+ Button18,
7164
7639
  {
7165
7640
  size: "sm",
7166
7641
  variant: "outline",
@@ -7171,22 +7646,22 @@ function OmieHistoryTab() {
7171
7646
  )
7172
7647
  ] })
7173
7648
  ] }),
7174
- expanded ? /* @__PURE__ */ jsxs25(Stack11, { gap: 3, mt: 3, pt: 3, borderTopWidth: "1px", children: [
7175
- execution.summary && Object.keys(execution.summary).length ? /* @__PURE__ */ jsxs25(Box24, { children: [
7176
- /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: "Resumo" }),
7177
- /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: Object.entries(execution.summary).map(([key, value2]) => /* @__PURE__ */ jsxs25(Badge7, { variant: "outline", children: [
7649
+ expanded ? /* @__PURE__ */ jsxs26(Stack12, { gap: 3, mt: 3, pt: 3, borderTopWidth: "1px", children: [
7650
+ execution.summary && Object.keys(execution.summary).length ? /* @__PURE__ */ jsxs26(Box25, { children: [
7651
+ /* @__PURE__ */ jsx41(Text26, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: "Resumo" }),
7652
+ /* @__PURE__ */ jsx41(Flex18, { gap: 2, wrap: "wrap", children: Object.entries(execution.summary).map(([key, value2]) => /* @__PURE__ */ jsxs26(Badge8, { variant: "outline", children: [
7178
7653
  key,
7179
7654
  ": ",
7180
7655
  String(value2 ?? "\u2014")
7181
7656
  ] }, key)) })
7182
7657
  ] }) : null,
7183
- diagnostics.length ? /* @__PURE__ */ jsxs25(Box24, { children: [
7184
- /* @__PURE__ */ jsxs25(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: [
7658
+ diagnostics.length ? /* @__PURE__ */ jsxs26(Box25, { children: [
7659
+ /* @__PURE__ */ jsxs26(Text26, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: [
7185
7660
  "Erros por registro",
7186
7661
  execution.errorsLimited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
7187
7662
  ] }),
7188
- /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs25(
7189
- Box24,
7663
+ /* @__PURE__ */ jsx41(Stack12, { gap: 2, children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs26(
7664
+ Box25,
7190
7665
  {
7191
7666
  borderWidth: "1px",
7192
7667
  borderColor: "red.100",
@@ -7194,30 +7669,30 @@ function OmieHistoryTab() {
7194
7669
  bg: "red.50",
7195
7670
  p: 3,
7196
7671
  children: [
7197
- /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.600", children: [
7672
+ /* @__PURE__ */ jsxs26(Text26, { fontSize: "xs", color: "gray.600", children: [
7198
7673
  "Registro ",
7199
7674
  diagnostic.index !== void 0 ? diagnostic.index + 1 : index + 1,
7200
7675
  diagnostic.externalKey !== void 0 ? ` \xB7 chave ${String(diagnostic.externalKey)}` : "",
7201
7676
  diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode ? ` \xB7 c\xF3digo ${String(diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode)}` : ""
7202
7677
  ] }),
7203
- /* @__PURE__ */ jsx40(Text25, { color: "red.700", children: diagnosticMessage2(diagnostic) })
7678
+ /* @__PURE__ */ jsx41(Text26, { color: "red.700", children: diagnosticMessage3(diagnostic) })
7204
7679
  ]
7205
7680
  },
7206
- `${diagnostic.index ?? index}:${diagnosticMessage2(diagnostic)}`
7681
+ `${diagnostic.index ?? index}:${diagnosticMessage3(diagnostic)}`
7207
7682
  )) })
7208
7683
  ] }) : null,
7209
7684
  [
7210
7685
  ["Itens processados", execution.items, execution.itemCount, execution.itemsLimited],
7211
7686
  ["Chamadas sanitizadas", execution.requests, execution.requestCount, execution.requestsLimited],
7212
7687
  ["Metadados", execution.metadata, void 0, false]
7213
- ].map(([label, value2, count, limited]) => value2 ? /* @__PURE__ */ jsxs25("details", { children: [
7214
- /* @__PURE__ */ jsxs25("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: [
7688
+ ].map(([label, value2, count, limited]) => value2 ? /* @__PURE__ */ jsxs26("details", { children: [
7689
+ /* @__PURE__ */ jsxs26("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: [
7215
7690
  String(label),
7216
7691
  typeof count === "number" ? ` (${count})` : "",
7217
7692
  limited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
7218
7693
  ] }),
7219
- /* @__PURE__ */ jsx40(
7220
- Box24,
7694
+ /* @__PURE__ */ jsx41(
7695
+ Box25,
7221
7696
  {
7222
7697
  as: "pre",
7223
7698
  mt: 2,
@@ -7233,7 +7708,7 @@ function OmieHistoryTab() {
7233
7708
  ] }, String(label)) : null)
7234
7709
  ] }) : null
7235
7710
  ] }, execution._id);
7236
- }) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o Omie registrada." }) })
7711
+ }) : /* @__PURE__ */ jsx41(Text26, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o Omie registrada." }) })
7237
7712
  ] });
7238
7713
  }
7239
7714
  var TABS = [
@@ -7243,14 +7718,14 @@ var TABS = [
7243
7718
  { id: "history", label: "Hist\xF3rico" }
7244
7719
  ];
7245
7720
  function CoreOmieIntegration() {
7246
- const [tab, setTab] = useState15("configuration");
7247
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
7248
- /* @__PURE__ */ jsxs25(Box24, { children: [
7249
- /* @__PURE__ */ jsx40(Heading14, { size: "lg", children: "Integra\xE7\xE3o Omie" }),
7250
- /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Configure credenciais, sincroniza\xE7\xF5es, webhooks, gatilhos e diagn\xF3sticos da inst\xE2ncia Omie." })
7721
+ const [tab, setTab] = useState16("configuration");
7722
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 5, children: [
7723
+ /* @__PURE__ */ jsxs26(Box25, { children: [
7724
+ /* @__PURE__ */ jsx41(Heading15, { size: "lg", children: "Integra\xE7\xE3o Omie" }),
7725
+ /* @__PURE__ */ jsx41(Text26, { color: "gray.500", children: "Configure credenciais, sincroniza\xE7\xF5es, webhooks, gatilhos e diagn\xF3sticos da inst\xE2ncia Omie." })
7251
7726
  ] }),
7252
- /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: TABS.map((item) => /* @__PURE__ */ jsx40(
7253
- Button17,
7727
+ /* @__PURE__ */ jsx41(Flex18, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: TABS.map((item) => /* @__PURE__ */ jsx41(
7728
+ Button18,
7254
7729
  {
7255
7730
  size: "sm",
7256
7731
  variant: tab === item.id ? "solid" : "ghost",
@@ -7259,19 +7734,49 @@ function CoreOmieIntegration() {
7259
7734
  },
7260
7735
  item.id
7261
7736
  )) }),
7262
- tab === "configuration" ? /* @__PURE__ */ jsx40(OmieConfigurationTab, {}) : null,
7263
- tab === "synchronization" ? /* @__PURE__ */ jsx40(OmieSynchronizationTab, {}) : null,
7264
- tab === "webhooks" ? /* @__PURE__ */ jsx40(OmieWebhooksTab, {}) : null,
7265
- tab === "history" ? /* @__PURE__ */ jsx40(OmieHistoryTab, {}) : null
7737
+ tab === "configuration" ? /* @__PURE__ */ jsx41(OmieConfigurationTab, {}) : null,
7738
+ tab === "synchronization" ? /* @__PURE__ */ jsx41(OmieSynchronizationTab, {}) : null,
7739
+ tab === "webhooks" ? /* @__PURE__ */ jsx41(OmieWebhooksTab, {}) : null,
7740
+ tab === "history" ? /* @__PURE__ */ jsx41(OmieHistoryTab, {}) : null
7741
+ ] });
7742
+ }
7743
+
7744
+ // src/components/CoreOmieIntegrationWorkspace.tsx
7745
+ import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
7746
+ function CoreOmieIntegrationWorkspace() {
7747
+ const [view, setView] = useState17("integration");
7748
+ return /* @__PURE__ */ jsxs27(Stack13, { gap: 4, children: [
7749
+ /* @__PURE__ */ jsxs27(Flex19, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: [
7750
+ /* @__PURE__ */ jsx42(
7751
+ Button19,
7752
+ {
7753
+ size: "sm",
7754
+ variant: view === "integration" ? "solid" : "ghost",
7755
+ onClick: () => setView("integration"),
7756
+ children: "Integra\xE7\xE3o Omie"
7757
+ }
7758
+ ),
7759
+ /* @__PURE__ */ jsx42(
7760
+ Button19,
7761
+ {
7762
+ size: "sm",
7763
+ variant: view === "tickets" ? "solid" : "ghost",
7764
+ onClick: () => setView("tickets"),
7765
+ children: "Tickets"
7766
+ }
7767
+ )
7768
+ ] }),
7769
+ view === "integration" ? /* @__PURE__ */ jsx42(CoreOmieIntegration, {}) : null,
7770
+ view === "tickets" ? /* @__PURE__ */ jsx42(CoreIntegrationTickets, { provider: "omie" }) : null
7266
7771
  ] });
7267
7772
  }
7268
7773
 
7269
7774
  // src/modules/integrations.tsx
7270
- import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
7775
+ import { jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
7271
7776
  function CoreIntegrationPage() {
7272
- return /* @__PURE__ */ jsxs26(Stack12, { gap: 8, children: [
7273
- /* @__PURE__ */ jsx41(CoreIntegration, {}),
7274
- /* @__PURE__ */ jsx41(CoreIntegrationMappings, {})
7777
+ return /* @__PURE__ */ jsxs28(Stack14, { gap: 8, children: [
7778
+ /* @__PURE__ */ jsx43(CoreIntegration, {}),
7779
+ /* @__PURE__ */ jsx43(CoreIntegrationMappings, {})
7275
7780
  ] });
7276
7781
  }
7277
7782
  function createIntegrationModule() {
@@ -7281,12 +7786,17 @@ function createIntegrationModule() {
7281
7786
  routes: [
7282
7787
  {
7283
7788
  path: "/integracoes",
7284
- element: /* @__PURE__ */ jsx41(CoreIntegrationPage, {}),
7789
+ element: /* @__PURE__ */ jsx43(CoreIntegrationPage, {}),
7285
7790
  capabilities: ["core.integrations"]
7286
7791
  },
7287
7792
  {
7288
7793
  path: "/configuracoes/integracao-omie",
7289
- element: /* @__PURE__ */ jsx41(CoreOmieIntegration, {}),
7794
+ element: /* @__PURE__ */ jsx43(CoreOmieIntegrationWorkspace, {}),
7795
+ capabilities: ["core.integrations", "core.integrations.omie"]
7796
+ },
7797
+ {
7798
+ path: "/configuracoes/integracao-omie/tickets",
7799
+ element: /* @__PURE__ */ jsx43(CoreIntegrationTickets, { provider: "omie" }),
7290
7800
  capabilities: ["core.integrations", "core.integrations.omie"]
7291
7801
  }
7292
7802
  ],
@@ -7340,36 +7850,36 @@ function defineOonModule(mod) {
7340
7850
  }
7341
7851
 
7342
7852
  // src/components/CoreCurrency.tsx
7343
- import { Button as Button18, Flex as Flex18, Heading as Heading15, Stack as Stack13, Text as Text26 } from "@chakra-ui/react";
7344
- import { useMutation as useMutation6, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
7345
- import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
7853
+ import { Button as Button20, Flex as Flex20, Heading as Heading16, Stack as Stack15, Text as Text27 } from "@chakra-ui/react";
7854
+ import { useMutation as useMutation7, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
7855
+ import { jsx as jsx44, jsxs as jsxs29 } from "react/jsx-runtime";
7346
7856
  function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/moedas", columns }) {
7347
7857
  const { http } = useOonApi();
7348
7858
  const queryClient = useQueryClient5();
7349
- const updateRates = useMutation6({
7859
+ const updateRates = useMutation7({
7350
7860
  mutationFn: () => http.post(`${endpoint}/actions/update-rates`, {}, { headers: { "x-oon-origin": "integration" } }),
7351
7861
  onSuccess: () => queryClient.invalidateQueries({ queryKey: ["oon", "list", endpoint] })
7352
7862
  });
7353
- return /* @__PURE__ */ jsxs27(Stack13, { gap: 6, children: [
7354
- /* @__PURE__ */ jsxs27(Flex18, { align: "center", justify: "space-between", children: [
7355
- /* @__PURE__ */ jsx42(Heading15, { size: "lg", children: label }),
7356
- /* @__PURE__ */ jsx42(Button18, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
7863
+ return /* @__PURE__ */ jsxs29(Stack15, { gap: 6, children: [
7864
+ /* @__PURE__ */ jsxs29(Flex20, { align: "center", justify: "space-between", children: [
7865
+ /* @__PURE__ */ jsx44(Heading16, { size: "lg", children: label }),
7866
+ /* @__PURE__ */ jsx44(Button20, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
7357
7867
  ] }),
7358
- updateRates.isError ? /* @__PURE__ */ jsx42(Text26, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
7359
- /* @__PURE__ */ jsx42(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
7868
+ updateRates.isError ? /* @__PURE__ */ jsx44(Text27, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
7869
+ /* @__PURE__ */ jsx44(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
7360
7870
  ] });
7361
7871
  }
7362
7872
 
7363
7873
  // src/components/CoreAssistant.tsx
7364
- import { useState as useState16 } from "react";
7365
- import { Box as Box25, Button as Button19, Flex as Flex19, Heading as Heading16, Input as Input10, Stack as Stack14, Text as Text27 } from "@chakra-ui/react";
7366
- import { useMutation as useMutation7 } from "@tanstack/react-query";
7367
- import { jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
7874
+ import { useState as useState18 } from "react";
7875
+ import { Box as Box26, Button as Button21, Flex as Flex21, Heading as Heading17, Input as Input11, Stack as Stack16, Text as Text28 } from "@chakra-ui/react";
7876
+ import { useMutation as useMutation8 } from "@tanstack/react-query";
7877
+ import { jsx as jsx45, jsxs as jsxs30 } from "react/jsx-runtime";
7368
7878
  function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint = "/assistant-runs" }) {
7369
7879
  const { http } = useOonApi();
7370
- const [messages, setMessages] = useState16([]);
7371
- const [input, setInput] = useState16("");
7372
- const ask = useMutation7({
7880
+ const [messages, setMessages] = useState18([]);
7881
+ const [input, setInput] = useState18("");
7882
+ const ask = useMutation8({
7373
7883
  mutationFn: async (message) => {
7374
7884
  const { data } = await http.post(
7375
7885
  endpoint,
@@ -7393,11 +7903,11 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
7393
7903
  setInput("");
7394
7904
  ask.mutate(text);
7395
7905
  };
7396
- return /* @__PURE__ */ jsxs28(Stack14, { gap: 4, maxW: "560px", children: [
7397
- /* @__PURE__ */ jsx43(Heading16, { size: "md", children: label }),
7398
- /* @__PURE__ */ jsx43(Box25, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs28(Stack14, { gap: 3, children: [
7399
- messages.length === 0 ? /* @__PURE__ */ jsx43(Text27, { color: "gray.400", fontSize: "sm", children: "Fa\xE7a uma pergunta ao assistente." }) : messages.map((m, idx) => /* @__PURE__ */ jsx43(Flex19, { justify: m.role === "user" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx43(
7400
- Box25,
7906
+ return /* @__PURE__ */ jsxs30(Stack16, { gap: 4, maxW: "560px", children: [
7907
+ /* @__PURE__ */ jsx45(Heading17, { size: "md", children: label }),
7908
+ /* @__PURE__ */ jsx45(Box26, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs30(Stack16, { gap: 3, children: [
7909
+ messages.length === 0 ? /* @__PURE__ */ jsx45(Text28, { color: "gray.400", fontSize: "sm", children: "Fa\xE7a uma pergunta ao assistente." }) : messages.map((m, idx) => /* @__PURE__ */ jsx45(Flex21, { justify: m.role === "user" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx45(
7910
+ Box26,
7401
7911
  {
7402
7912
  bg: m.role === "user" ? "brand.500" : "gray.100",
7403
7913
  color: m.role === "user" ? "white" : "gray.800",
@@ -7409,12 +7919,12 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
7409
7919
  children: m.content
7410
7920
  }
7411
7921
  ) }, idx)),
7412
- ask.isPending ? /* @__PURE__ */ jsx43(Text27, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
7413
- ask.isError ? /* @__PURE__ */ jsx43(Text27, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
7922
+ ask.isPending ? /* @__PURE__ */ jsx45(Text28, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
7923
+ ask.isError ? /* @__PURE__ */ jsx45(Text28, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
7414
7924
  ] }) }),
7415
- /* @__PURE__ */ jsxs28(Flex19, { gap: 2, children: [
7416
- /* @__PURE__ */ jsx43(
7417
- Input10,
7925
+ /* @__PURE__ */ jsxs30(Flex21, { gap: 2, children: [
7926
+ /* @__PURE__ */ jsx45(
7927
+ Input11,
7418
7928
  {
7419
7929
  size: "sm",
7420
7930
  value: input,
@@ -7425,7 +7935,7 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
7425
7935
  }
7426
7936
  }
7427
7937
  ),
7428
- /* @__PURE__ */ jsx43(Button19, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
7938
+ /* @__PURE__ */ jsx45(Button21, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
7429
7939
  ] })
7430
7940
  ] });
7431
7941
  }