@oondemand/oon-core-front 0.3.61 → 0.3.62

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
@@ -4071,7 +4071,8 @@ function formatWidget(value2, kind, field) {
4071
4071
  }
4072
4072
 
4073
4073
  // src/components/ui-v2/CorePage.tsx
4074
- import { Box as Box16, Heading as Heading8, Stack as Stack7, Text as Text17 } from "@chakra-ui/react";
4074
+ import { Box as Box16, Button as Button11, Flex as Flex10, Heading as Heading8, Stack as Stack7, Text as Text17 } from "@chakra-ui/react";
4075
+ import { useNavigate } from "react-router-dom";
4075
4076
 
4076
4077
  // src/security/PermissionGate.tsx
4077
4078
  import { Fragment as Fragment2, jsx as jsx21 } from "react/jsx-runtime";
@@ -4180,6 +4181,7 @@ function requiredAccess(source) {
4180
4181
  return values.length ? values : void 0;
4181
4182
  }
4182
4183
  function CoreBlock({ block, registry }) {
4184
+ const navigate = useNavigate();
4183
4185
  if (block.hidden) return null;
4184
4186
  const content = (() => {
4185
4187
  switch (block.type) {
@@ -4193,6 +4195,40 @@ function CoreBlock({ block, registry }) {
4193
4195
  const Component = resolveComponent(registry, block.renderer, "cardRenderers");
4194
4196
  return Component ? /* @__PURE__ */ jsx24(Component, { block, model: block.model }) : /* @__PURE__ */ jsx24(CoreCards, { model: block.model, renderer: block.renderer });
4195
4197
  }
4198
+ case "navigation.cards":
4199
+ return /* @__PURE__ */ jsx24(Flex10, { gap: 4, wrap: "wrap", children: block.cards.map((card) => /* @__PURE__ */ jsx24(
4200
+ Box16,
4201
+ {
4202
+ minW: "260px",
4203
+ flex: `1 1 calc(${100 / (block.columns ?? 2)}% - 16px)`,
4204
+ borderWidth: "1px",
4205
+ borderRadius: "lg",
4206
+ bg: "white",
4207
+ p: 5,
4208
+ children: /* @__PURE__ */ jsxs17(Stack7, { gap: 3, height: "100%", children: [
4209
+ /* @__PURE__ */ jsxs17(Box16, { flex: "1", children: [
4210
+ /* @__PURE__ */ jsx24(Heading8, { size: "md", mb: 2, children: card.title }),
4211
+ card.description ? /* @__PURE__ */ jsx24(Text17, { color: "gray.600", children: card.description }) : null
4212
+ ] }),
4213
+ /* @__PURE__ */ jsx24(
4214
+ Button11,
4215
+ {
4216
+ alignSelf: "flex-start",
4217
+ variant: "outline",
4218
+ onClick: () => {
4219
+ if (card.external) {
4220
+ window.open(card.href, "_blank", "noopener,noreferrer");
4221
+ return;
4222
+ }
4223
+ navigate(card.href);
4224
+ },
4225
+ children: card.actionLabel || "Abrir"
4226
+ }
4227
+ )
4228
+ ] })
4229
+ },
4230
+ `${card.title}:${card.href}`
4231
+ )) });
4196
4232
  case "section":
4197
4233
  return /* @__PURE__ */ jsxs17(Box16, { children: [
4198
4234
  /* @__PURE__ */ jsx24(Heading8, { size: "md", mb: block.description ? 1 : 4, children: block.title }),
@@ -4335,6 +4371,7 @@ function pageToMenu(page) {
4335
4371
  };
4336
4372
  }
4337
4373
  function viewToMenu(view) {
4374
+ if ("hidden" in view && view.hidden) return null;
4338
4375
  return {
4339
4376
  label: viewLabel(view),
4340
4377
  href: viewPath(view),
@@ -4363,7 +4400,8 @@ function resolveRegistry(config) {
4363
4400
  for (const item of mod.menu ?? []) pushMenu(item);
4364
4401
  for (const view of mod.views ?? []) {
4365
4402
  pushRoute(viewToRoute(view, componentRegistry));
4366
- pushMenu(viewToMenu(view));
4403
+ const item = viewToMenu(view);
4404
+ if (item) pushMenu(item);
4367
4405
  }
4368
4406
  }
4369
4407
  const navMode = config.ui?.navigation?.mode ?? "auto";
@@ -4372,7 +4410,8 @@ function resolveRegistry(config) {
4372
4410
  if (includeAuto) {
4373
4411
  for (const view of config.ui?.views ?? []) {
4374
4412
  pushRoute(viewToRoute(view, componentRegistry));
4375
- pushMenu(viewToMenu(view));
4413
+ const item = viewToMenu(view);
4414
+ if (item) pushMenu(item);
4376
4415
  }
4377
4416
  for (const page of config.ui?.pages ?? []) {
4378
4417
  pushRoute(pageToRoute(page, componentRegistry));
@@ -4394,11 +4433,11 @@ import {
4394
4433
  } from "react-router-dom";
4395
4434
 
4396
4435
  // src/shell/DefaultShell.tsx
4397
- import { Box as Box18, Button as Button11, Flex as Flex11, Spacer as Spacer2, Text as Text19 } from "@chakra-ui/react";
4398
- import { Outlet, useNavigate } from "react-router-dom";
4436
+ import { Box as Box18, Button as Button12, Flex as Flex12, Spacer as Spacer2, Text as Text19 } from "@chakra-ui/react";
4437
+ import { Outlet, useNavigate as useNavigate2 } from "react-router-dom";
4399
4438
 
4400
4439
  // src/shell/Sidebar.tsx
4401
- import { Box as Box17, Flex as Flex10, Image, Stack as Stack8, Text as Text18 } from "@chakra-ui/react";
4440
+ import { Box as Box17, Flex as Flex11, Image, Stack as Stack8, Text as Text18 } from "@chakra-ui/react";
4402
4441
  import { NavLink } from "react-router-dom";
4403
4442
  import { jsx as jsx26, jsxs as jsxs18 } from "react/jsx-runtime";
4404
4443
  function groupBySection(items) {
@@ -4429,9 +4468,9 @@ function Sidebar({ app, menu, registry }) {
4429
4468
  alignSelf: "flex-start",
4430
4469
  overflowY: "auto",
4431
4470
  children: [
4432
- /* @__PURE__ */ jsxs18(Flex10, { align: "center", gap: 3, mb: 6, px: { base: 1, lg: 2 }, minH: "42px", children: [
4471
+ /* @__PURE__ */ jsxs18(Flex11, { align: "center", gap: 3, mb: 6, px: { base: 1, lg: 2 }, minH: "42px", children: [
4433
4472
  app.logo ? /* @__PURE__ */ jsx26(Image, { src: app.logo, alt: app.name, maxH: "36px", maxW: { base: "44px", lg: "150px" }, objectFit: "contain" }) : /* @__PURE__ */ jsx26(
4434
- Flex10,
4473
+ Flex11,
4435
4474
  {
4436
4475
  w: "38px",
4437
4476
  h: "38px",
@@ -4470,7 +4509,7 @@ function Sidebar({ app, menu, registry }) {
4470
4509
  const CustomMenuItem = resolveComponent(registry, item.renderer, "menuRenderers");
4471
4510
  if (CustomMenuItem) return /* @__PURE__ */ jsx26(CustomMenuItem, { item }, item.href);
4472
4511
  return /* @__PURE__ */ jsx26(NavLink, { to: item.href, end: item.href === "/", title: item.label, children: ({ isActive }) => /* @__PURE__ */ jsxs18(
4473
- Flex10,
4512
+ Flex11,
4474
4513
  {
4475
4514
  align: "center",
4476
4515
  justify: { base: "center", lg: "flex-start" },
@@ -4502,7 +4541,7 @@ function Sidebar({ app, menu, registry }) {
4502
4541
  // package.json
4503
4542
  var package_default = {
4504
4543
  name: "@oondemand/oon-core-front",
4505
- version: "0.3.61",
4544
+ version: "0.3.62",
4506
4545
  repository: {
4507
4546
  type: "git",
4508
4547
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -4665,7 +4704,7 @@ function resolveSettingsHref(menu) {
4665
4704
  }
4666
4705
  function CoreTopbar({ app, menu }) {
4667
4706
  const { user, logout, hasPermission } = useOonAuth();
4668
- const navigate = useNavigate();
4707
+ const navigate = useNavigate2();
4669
4708
  const metadataQuery = useCoreMetadata();
4670
4709
  const runtime = resolveRuntimeVersionInfo(app, metadataQuery.data);
4671
4710
  const centralVersion = runtime.centralVersion ?? "n\xE3o informada";
@@ -4690,7 +4729,7 @@ function CoreTopbar({ app, menu }) {
4690
4729
  menu.filter((item) => !item.hidden && hasPermission(item.permissions))
4691
4730
  );
4692
4731
  return /* @__PURE__ */ jsxs19(
4693
- Flex11,
4732
+ Flex12,
4694
4733
  {
4695
4734
  as: "header",
4696
4735
  align: "center",
@@ -4729,13 +4768,13 @@ function CoreTopbar({ app, menu }) {
4729
4768
  publicationParts.length ? /* @__PURE__ */ jsx27(Text19, { fontSize: "10px", color: "gray.500", lineHeight: "1.35", children: publicationParts.join(" \xB7 ") }) : null
4730
4769
  ] }),
4731
4770
  /* @__PURE__ */ jsx27(Spacer2, {}),
4732
- user ? /* @__PURE__ */ jsxs19(Flex11, { align: "center", gap: 3, children: [
4771
+ user ? /* @__PURE__ */ jsxs19(Flex12, { align: "center", gap: 3, children: [
4733
4772
  /* @__PURE__ */ jsxs19(Box18, { textAlign: "right", display: { base: "none", md: "block" }, children: [
4734
4773
  /* @__PURE__ */ jsx27(Text19, { fontSize: "sm", fontWeight: "600", color: "#24323A", children: user.nome }),
4735
4774
  user.email ? /* @__PURE__ */ jsx27(Text19, { fontSize: "xs", color: "gray.500", children: user.email }) : null
4736
4775
  ] }),
4737
4776
  settingsHref ? /* @__PURE__ */ jsx27(
4738
- Button11,
4777
+ Button12,
4739
4778
  {
4740
4779
  size: "sm",
4741
4780
  variant: "outline",
@@ -4750,7 +4789,7 @@ function CoreTopbar({ app, menu }) {
4750
4789
  }
4751
4790
  ) : null,
4752
4791
  /* @__PURE__ */ jsx27(
4753
- Button11,
4792
+ Button12,
4754
4793
  {
4755
4794
  size: "sm",
4756
4795
  variant: "outline",
@@ -4792,7 +4831,7 @@ function DefaultShell({
4792
4831
  }) {
4793
4832
  const portal = layout?.shell === "portal" || layout?.shell === "content-only";
4794
4833
  const mainPadding = portal ? { base: 4, lg: 10 } : { base: 4, lg: 6 };
4795
- return /* @__PURE__ */ jsxs19(Flex11, { align: "stretch", minH: "100vh", bg: portal ? "white" : "#F8F9FA", children: [
4834
+ return /* @__PURE__ */ jsxs19(Flex12, { align: "stretch", minH: "100vh", bg: portal ? "white" : "#F8F9FA", children: [
4796
4835
  /* @__PURE__ */ jsx27(
4797
4836
  Slot,
4798
4837
  {
@@ -4803,7 +4842,7 @@ function DefaultShell({
4803
4842
  menu
4804
4843
  }
4805
4844
  ),
4806
- /* @__PURE__ */ jsxs19(Flex11, { direction: "column", flex: "1", minW: 0, children: [
4845
+ /* @__PURE__ */ jsxs19(Flex12, { direction: "column", flex: "1", minW: 0, children: [
4807
4846
  /* @__PURE__ */ jsx27(
4808
4847
  Slot,
4809
4848
  {
@@ -4845,17 +4884,17 @@ function AuthenticatedLayout({ app, menu, layout, registry }) {
4845
4884
  }
4846
4885
 
4847
4886
  // src/security/AccessDeniedPage.tsx
4848
- import { Box as Box19, Button as Button12, Flex as Flex12, Heading as Heading9, Text as Text20, VStack } from "@chakra-ui/react";
4849
- import { useNavigate as useNavigate2 } from "react-router-dom";
4887
+ import { Box as Box19, Button as Button13, Flex as Flex13, Heading as Heading9, Text as Text20, VStack } from "@chakra-ui/react";
4888
+ import { useNavigate as useNavigate3 } from "react-router-dom";
4850
4889
  import { jsx as jsx29, jsxs as jsxs20 } from "react/jsx-runtime";
4851
4890
  function AccessDeniedPage({ app }) {
4852
4891
  const { logout } = useOonAuth();
4853
- const navigate = useNavigate2();
4892
+ const navigate = useNavigate3();
4854
4893
  function useAnotherAccount() {
4855
4894
  logout();
4856
4895
  navigate("/login", { replace: true });
4857
4896
  }
4858
- return /* @__PURE__ */ jsx29(Flex12, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx29(
4897
+ return /* @__PURE__ */ jsx29(Flex13, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx29(
4859
4898
  Box19,
4860
4899
  {
4861
4900
  width: "100%",
@@ -4904,7 +4943,7 @@ function AccessDeniedPage({ app }) {
4904
4943
  ] })
4905
4944
  ] }),
4906
4945
  /* @__PURE__ */ jsx29(
4907
- Button12,
4946
+ Button13,
4908
4947
  {
4909
4948
  alignSelf: "flex-start",
4910
4949
  bg: "#07262E",
@@ -4961,8 +5000,8 @@ function AppAccessGuard({ children }) {
4961
5000
  import { useState as useState12 } from "react";
4962
5001
  import {
4963
5002
  Box as Box20,
4964
- Button as Button13,
4965
- Flex as Flex13,
5003
+ Button as Button14,
5004
+ Flex as Flex14,
4966
5005
  Heading as Heading10,
4967
5006
  Input as Input6,
4968
5007
  Text as Text21,
@@ -5008,7 +5047,7 @@ function LoginPage({ app }) {
5008
5047
  setSubmitting(false);
5009
5048
  }
5010
5049
  }
5011
- return /* @__PURE__ */ jsx31(Flex13, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx31(
5050
+ return /* @__PURE__ */ jsx31(Flex14, { minH: "100vh", align: "center", justify: "center", bg: "#F5F8FA", px: 4, children: /* @__PURE__ */ jsx31(
5012
5051
  Box20,
5013
5052
  {
5014
5053
  width: "100%",
@@ -5079,7 +5118,7 @@ function LoginPage({ app }) {
5079
5118
  }
5080
5119
  ) : null,
5081
5120
  /* @__PURE__ */ jsx31(
5082
- Button13,
5121
+ Button14,
5083
5122
  {
5084
5123
  type: "submit",
5085
5124
  bg: "#07262E",
@@ -5096,7 +5135,7 @@ function LoginPage({ app }) {
5096
5135
 
5097
5136
  // src/security/ActivationPage.tsx
5098
5137
  import { useEffect as useEffect8, useState as useState13 } from "react";
5099
- import { Box as Box21, Button as Button14, Heading as Heading11, Input as Input7, Text as Text22, VStack as VStack3 } from "@chakra-ui/react";
5138
+ import { Box as Box21, Button as Button15, Heading as Heading11, Input as Input7, Text as Text22, VStack as VStack3 } from "@chakra-ui/react";
5100
5139
  import { Fragment as Fragment5, jsx as jsx32, jsxs as jsxs22 } from "react/jsx-runtime";
5101
5140
  function encodeBasicCredentials2(email, password) {
5102
5141
  const bytes = new TextEncoder().encode(`${email}:${password}`);
@@ -5294,7 +5333,7 @@ function ActivationPage() {
5294
5333
  )
5295
5334
  ] }),
5296
5335
  /* @__PURE__ */ jsx32(
5297
- Button14,
5336
+ Button15,
5298
5337
  {
5299
5338
  colorPalette: "blue",
5300
5339
  onClick: activateDevLocal,
@@ -5304,7 +5343,7 @@ function ActivationPage() {
5304
5343
  }
5305
5344
  ),
5306
5345
  /* @__PURE__ */ jsx32(
5307
- Button14,
5346
+ Button15,
5308
5347
  {
5309
5348
  variant: "outline",
5310
5349
  onClick: () => setShowCodeFlow(true),
@@ -5385,7 +5424,7 @@ function ActivationPage() {
5385
5424
  )
5386
5425
  ] }),
5387
5426
  /* @__PURE__ */ jsx32(
5388
- Button14,
5427
+ Button15,
5389
5428
  {
5390
5429
  colorPalette: "blue",
5391
5430
  onClick: activateRoot,
@@ -5438,7 +5477,7 @@ function ActivationPage() {
5438
5477
  }
5439
5478
  ),
5440
5479
  /* @__PURE__ */ jsx32(
5441
- Button14,
5480
+ Button15,
5442
5481
  {
5443
5482
  onClick: validateCode,
5444
5483
  loading: submitting,
@@ -5447,7 +5486,7 @@ function ActivationPage() {
5447
5486
  }
5448
5487
  ),
5449
5488
  isDevelopmentMember ? /* @__PURE__ */ jsx32(
5450
- Button14,
5489
+ Button15,
5451
5490
  {
5452
5491
  variant: "outline",
5453
5492
  onClick: () => setShowCodeFlow(false),
@@ -5459,22 +5498,22 @@ function ActivationPage() {
5459
5498
  step === 2 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
5460
5499
  /* @__PURE__ */ jsx32(Heading11, { size: "md", children: "Confirma\xE7\xE3o" }),
5461
5500
  /* @__PURE__ */ jsx32("pre", { children: JSON.stringify(preview, null, 2) }),
5462
- /* @__PURE__ */ jsx32(Button14, { onClick: () => setStep(3), children: "Continuar" })
5501
+ /* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(3), children: "Continuar" })
5463
5502
  ] }),
5464
5503
  step === 3 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
5465
5504
  config.globalFields.map(
5466
5505
  (field) => renderField(field, global, setGlobal)
5467
5506
  ),
5468
- /* @__PURE__ */ jsx32(Button14, { onClick: () => setStep(4), children: "Continuar" })
5507
+ /* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(4), children: "Continuar" })
5469
5508
  ] }),
5470
5509
  step === 4 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
5471
5510
  config.appFields.length ? config.appFields.map((field) => renderField(field, app, setApp)) : /* @__PURE__ */ jsx32(Text22, { children: "Nenhum par\xE2metro adicional declarado." }),
5472
- /* @__PURE__ */ jsx32(Button14, { onClick: () => setStep(5), children: "Revisar" })
5511
+ /* @__PURE__ */ jsx32(Button15, { onClick: () => setStep(5), children: "Revisar" })
5473
5512
  ] }),
5474
5513
  step === 5 && /* @__PURE__ */ jsxs22(Fragment5, { children: [
5475
5514
  /* @__PURE__ */ jsx32(Text22, { children: "Ao confirmar, o c\xF3digo ser\xE1 consumido e a inst\xE2ncia ser\xE1 registrada no Ecossistema Oon." }),
5476
5515
  /* @__PURE__ */ jsx32(
5477
- Button14,
5516
+ Button15,
5478
5517
  {
5479
5518
  colorPalette: "blue",
5480
5519
  onClick: completeMemberActivation,
@@ -5765,6 +5804,7 @@ function manifestToConfig(manifest, runtime) {
5765
5804
  path: c.path,
5766
5805
  label: c.label,
5767
5806
  section: c.section,
5807
+ hidden: c.hidden,
5768
5808
  form: c.form,
5769
5809
  list: c.list,
5770
5810
  relations: c.relations,
@@ -5853,11 +5893,11 @@ function startFromManifest(manifest, runtime) {
5853
5893
  }
5854
5894
 
5855
5895
  // src/modules/integrations.tsx
5856
- import { Stack as Stack11 } from "@chakra-ui/react";
5896
+ import { Stack as Stack12 } from "@chakra-ui/react";
5857
5897
 
5858
5898
  // src/components/CoreIntegration.tsx
5859
5899
  import { useEffect as useEffect9, useState as useState14 } from "react";
5860
- import { Badge as Badge5, Box as Box22, Button as Button15, Flex as Flex14, Heading as Heading12, Input as Input8, Stack as Stack9, Text as Text23 } from "@chakra-ui/react";
5900
+ import { Badge as Badge5, Box as Box22, Button as Button16, Flex as Flex15, Heading as Heading12, Input as Input8, Stack as Stack9, Text as Text23 } from "@chakra-ui/react";
5861
5901
  import { useMutation as useMutation4, useQuery as useQuery8 } from "@tanstack/react-query";
5862
5902
  import { jsx as jsx38, jsxs as jsxs23 } from "react/jsx-runtime";
5863
5903
  function dateTime(value2) {
@@ -5958,7 +5998,7 @@ function ExecutionDetails({ execution }) {
5958
5998
  return /* @__PURE__ */ jsx38(Box22, { mt: 3, pt: 3, borderTopWidth: "1px", borderColor: "gray.100", children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5959
5999
  summaryEntries.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
5960
6000
  /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", mb: 2, children: "Resumo da execu\xE7\xE3o" }),
5961
- /* @__PURE__ */ jsx38(Flex14, { gap: 2, wrap: "wrap", children: summaryEntries.map(([key, value2]) => /* @__PURE__ */ jsxs23(
6001
+ /* @__PURE__ */ jsx38(Flex15, { gap: 2, wrap: "wrap", children: summaryEntries.map(([key, value2]) => /* @__PURE__ */ jsxs23(
5962
6002
  Badge5,
5963
6003
  {
5964
6004
  variant: "outline",
@@ -5973,7 +6013,7 @@ function ExecutionDetails({ execution }) {
5973
6013
  )) })
5974
6014
  ] }) : null,
5975
6015
  diagnostics.length ? /* @__PURE__ */ jsxs23(Box22, { children: [
5976
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 2, mb: 2, wrap: "wrap", children: [
6016
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 2, mb: 2, wrap: "wrap", children: [
5977
6017
  /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", fontWeight: "semibold", children: "Erros por registro" }),
5978
6018
  /* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.500", children: [
5979
6019
  execution.errorCount ?? diagnostics.length,
@@ -6088,12 +6128,12 @@ function ProviderConfigurationPanel({ provider }) {
6088
6128
  webhooks: mappings.data?.webhooks?.length ?? 0
6089
6129
  };
6090
6130
  return /* @__PURE__ */ jsx38(Box22, { borderTopWidth: "1px", borderColor: "gray.100", pt: 4, children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
6091
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6131
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6092
6132
  /* @__PURE__ */ jsxs23(Box22, { children: [
6093
6133
  /* @__PURE__ */ jsx38(Text23, { fontWeight: "semibold", children: "Configura\xE7\xE3o" }),
6094
6134
  /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. Segredos gravados nunca s\xE3o devolvidos ao navegador." })
6095
6135
  ] }),
6096
- /* @__PURE__ */ jsxs23(Flex14, { gap: 2, wrap: "wrap", children: [
6136
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, wrap: "wrap", children: [
6097
6137
  /* @__PURE__ */ jsxs23(Badge5, { variant: "outline", children: [
6098
6138
  mappingCounts.chamadas,
6099
6139
  " chamadas"
@@ -6108,7 +6148,7 @@ function ProviderConfigurationPanel({ provider }) {
6108
6148
  ] })
6109
6149
  ] })
6110
6150
  ] }),
6111
- /* @__PURE__ */ jsxs23(Flex14, { gap: 3, wrap: "wrap", children: [
6151
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
6112
6152
  /* @__PURE__ */ jsxs23(Box22, { minW: "180px", flex: "1", children: [
6113
6153
  /* @__PURE__ */ jsx38(Text23, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
6114
6154
  /* @__PURE__ */ jsx38(
@@ -6170,7 +6210,7 @@ function ProviderConfigurationPanel({ provider }) {
6170
6210
  }
6171
6211
  )
6172
6212
  ] }),
6173
- /* @__PURE__ */ jsxs23(Flex14, { gap: 3, wrap: "wrap", children: [
6213
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
6174
6214
  /* @__PURE__ */ jsxs23(Box22, { minW: "220px", flex: "1", children: [
6175
6215
  /* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.500", mb: 1, children: [
6176
6216
  "App Key ",
@@ -6214,8 +6254,8 @@ function ProviderConfigurationPanel({ provider }) {
6214
6254
  )
6215
6255
  ] })
6216
6256
  ] }),
6217
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6218
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", gap: 2, wrap: "wrap", children: [
6257
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6258
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
6219
6259
  /* @__PURE__ */ jsxs23("label", { children: [
6220
6260
  /* @__PURE__ */ jsx38(
6221
6261
  "input",
@@ -6237,9 +6277,9 @@ function ProviderConfigurationPanel({ provider }) {
6237
6277
  dateTime(selected?.lastConnectionTestAt)
6238
6278
  ] })
6239
6279
  ] }),
6240
- /* @__PURE__ */ jsxs23(Flex14, { gap: 2, children: [
6241
- /* @__PURE__ */ jsx38(Button15, { size: "xs", variant: "outline", loading: testConnection.isPending, onClick: () => testConnection.mutate(), children: "Testar conex\xE3o" }),
6242
- /* @__PURE__ */ jsx38(Button15, { size: "xs", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xE3o" })
6280
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, children: [
6281
+ /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: testConnection.isPending, onClick: () => testConnection.mutate(), children: "Testar conex\xE3o" }),
6282
+ /* @__PURE__ */ jsx38(Button16, { size: "xs", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xE3o" })
6243
6283
  ] })
6244
6284
  ] }),
6245
6285
  selected?.lastConnectionError ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: selected.lastConnectionError }) : null,
@@ -6308,25 +6348,25 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6308
6348
  const error = providers.error || queue.error || history.error;
6309
6349
  if (error) return /* @__PURE__ */ jsx38(ErrorState, { error });
6310
6350
  return /* @__PURE__ */ jsxs23(Stack9, { gap: 6, children: [
6311
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 4, wrap: "wrap", children: [
6351
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 4, wrap: "wrap", children: [
6312
6352
  /* @__PURE__ */ jsxs23(Box22, { children: [
6313
6353
  /* @__PURE__ */ jsx38(Heading12, { size: "lg", children: label }),
6314
6354
  /* @__PURE__ */ jsx38(Text23, { color: "gray.500", children: "Configura\xE7\xE3o, sa\xFAde, filas, eventos e diagn\xF3stico sanitizado por provedor." })
6315
6355
  ] }),
6316
- /* @__PURE__ */ jsx38(Button15, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" })
6356
+ /* @__PURE__ */ jsx38(Button16, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" })
6317
6357
  ] }),
6318
6358
  /* @__PURE__ */ jsx38(Stack9, { gap: 3, children: (providers.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum provedor registrado." }) : providers.data?.map((provider) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, children: /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
6319
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6359
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6320
6360
  /* @__PURE__ */ jsxs23(Box22, { children: [
6321
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", gap: 2, children: [
6361
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, children: [
6322
6362
  /* @__PURE__ */ jsx38(Text23, { fontWeight: "semibold", children: provider.label }),
6323
6363
  /* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(provider.status), children: provider.status ?? "\u2014" })
6324
6364
  ] }),
6325
6365
  provider.description ? /* @__PURE__ */ jsx38(Text23, { color: "gray.500", fontSize: "sm", children: provider.description }) : null
6326
6366
  ] }),
6327
- /* @__PURE__ */ jsx38(Button15, { size: "xs", variant: "outline", loading: syncAll.isPending, onClick: () => syncAll.mutate(provider.key), children: "Sincronizar tudo" })
6367
+ /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: syncAll.isPending, onClick: () => syncAll.mutate(provider.key), children: "Sincronizar tudo" })
6328
6368
  ] }),
6329
- /* @__PURE__ */ jsxs23(Flex14, { gap: 3, wrap: "wrap", children: [
6369
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
6330
6370
  /* @__PURE__ */ jsxs23(Badge5, { colorPalette: countActive(provider.queue) ? "yellow" : "green", children: [
6331
6371
  "Fila ativa: ",
6332
6372
  countActive(provider.queue)
@@ -6344,8 +6384,8 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6344
6384
  "Pend\xEAncia mais antiga: ",
6345
6385
  dateTime(provider.oldestPendingAt)
6346
6386
  ] }),
6347
- /* @__PURE__ */ jsx38(Flex14, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx38(
6348
- Button15,
6387
+ /* @__PURE__ */ jsx38(Flex15, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx38(
6388
+ Button16,
6349
6389
  {
6350
6390
  size: "xs",
6351
6391
  variant: "outline",
@@ -6359,9 +6399,9 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6359
6399
  ] }) }, provider.key)) }),
6360
6400
  /* @__PURE__ */ jsxs23(Box22, { children: [
6361
6401
  /* @__PURE__ */ jsx38(Heading12, { size: "md", mb: 3, children: "Fila recente" }),
6362
- /* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (queue.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum ticket de integra\xE7\xE3o." }) : queue.data?.map((ticket) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6402
+ /* @__PURE__ */ jsx38(Stack9, { gap: 2, children: (queue.data ?? []).length === 0 ? /* @__PURE__ */ jsx38(Text23, { color: "gray.400", children: "Nenhum ticket de integra\xE7\xE3o." }) : queue.data?.map((ticket) => /* @__PURE__ */ jsx38(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6363
6403
  /* @__PURE__ */ jsxs23(Box22, { children: [
6364
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", gap: 2, wrap: "wrap", children: [
6404
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
6365
6405
  /* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: ticket.handler }),
6366
6406
  /* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(ticket.status), children: ticket.status }),
6367
6407
  /* @__PURE__ */ jsx38(Badge5, { variant: "outline", children: ticket.provider })
@@ -6375,9 +6415,9 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6375
6415
  ] }),
6376
6416
  ticket.lastError?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
6377
6417
  ] }),
6378
- /* @__PURE__ */ jsxs23(Flex14, { gap: 2, children: [
6379
- ["Erro tempor\xE1rio", "Erro definitivo", "Arquivado"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button15, { size: "xs", variant: "outline", loading: reprocess.isPending, onClick: () => reprocess.mutate(ticket._id), children: "Reprocessar" }) : null,
6380
- ["Erro tempor\xE1rio", "Erro definitivo"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button15, { size: "xs", variant: "outline", loading: archive.isPending, onClick: () => archive.mutate(ticket._id), children: "Arquivar" }) : null
6418
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, children: [
6419
+ ["Erro tempor\xE1rio", "Erro definitivo", "Arquivado"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: reprocess.isPending, onClick: () => reprocess.mutate(ticket._id), children: "Reprocessar" }) : null,
6420
+ ["Erro tempor\xE1rio", "Erro definitivo"].includes(ticket.status) ? /* @__PURE__ */ jsx38(Button16, { size: "xs", variant: "outline", loading: archive.isPending, onClick: () => archive.mutate(ticket._id), children: "Arquivar" }) : null
6381
6421
  ] })
6382
6422
  ] }) }, ticket._id)) })
6383
6423
  ] }),
@@ -6387,7 +6427,7 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6387
6427
  const expanded = expandedExecutionId === execution._id;
6388
6428
  const diagnosticCount = execution.errorCount ?? execution.errors?.length ?? (execution.error?.message ? 1 : 0);
6389
6429
  return /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "md", p: 3, bg: "white", children: [
6390
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6430
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6391
6431
  /* @__PURE__ */ jsxs23(Box22, { children: [
6392
6432
  /* @__PURE__ */ jsx38(Text23, { fontWeight: "medium", children: execution.title }),
6393
6433
  /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.500", children: [
@@ -6402,14 +6442,14 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6402
6442
  ] }),
6403
6443
  execution.error?.message ? /* @__PURE__ */ jsx38(Text23, { fontSize: "sm", color: "red.600", children: execution.error.message }) : null
6404
6444
  ] }),
6405
- /* @__PURE__ */ jsxs23(Flex14, { align: "center", gap: 2, wrap: "wrap", children: [
6445
+ /* @__PURE__ */ jsxs23(Flex15, { align: "center", gap: 2, wrap: "wrap", children: [
6406
6446
  diagnosticCount > 0 ? /* @__PURE__ */ jsxs23(Badge5, { colorPalette: "red", children: [
6407
6447
  diagnosticCount,
6408
6448
  " erro(s)"
6409
6449
  ] }) : null,
6410
6450
  /* @__PURE__ */ jsx38(Badge5, { colorPalette: statusPalette(execution.status), children: execution.status }),
6411
6451
  /* @__PURE__ */ jsx38(
6412
- Button15,
6452
+ Button16,
6413
6453
  {
6414
6454
  size: "xs",
6415
6455
  variant: "outline",
@@ -6428,7 +6468,7 @@ function CoreIntegration({ label = "Integra\xE7\xF5es" }) {
6428
6468
  }
6429
6469
 
6430
6470
  // src/components/CoreIntegrationMappings.tsx
6431
- import { Badge as Badge6, Box as Box23, Flex as Flex15, Heading as Heading13, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
6471
+ import { Badge as Badge6, Box as Box23, Flex as Flex16, Heading as Heading13, Stack as Stack10, Text as Text24 } from "@chakra-ui/react";
6432
6472
  import { useQuery as useQuery9 } from "@tanstack/react-query";
6433
6473
  import { jsx as jsx39, jsxs as jsxs24 } from "react/jsx-runtime";
6434
6474
  function dateTime2(value2) {
@@ -6465,7 +6505,7 @@ function CoreIntegrationMappings() {
6465
6505
  /* @__PURE__ */ jsx39(Heading13, { size: "sm", children: provider.label }),
6466
6506
  /* @__PURE__ */ jsxs24(Box23, { children: [
6467
6507
  /* @__PURE__ */ jsx39(Text24, { fontWeight: "semibold", mb: 2, children: "Chamadas Omie" }),
6468
- /* @__PURE__ */ jsx39(Flex15, { gap: 2, wrap: "wrap", children: (mappings.calls ?? []).length ? mappings.calls?.map((call) => /* @__PURE__ */ jsxs24(Badge6, { variant: "outline", children: [
6508
+ /* @__PURE__ */ jsx39(Flex16, { gap: 2, wrap: "wrap", children: (mappings.calls ?? []).length ? mappings.calls?.map((call) => /* @__PURE__ */ jsxs24(Badge6, { variant: "outline", children: [
6469
6509
  call.label || call.key,
6470
6510
  " \xB7 ",
6471
6511
  call.call || "opera\xE7\xE3o",
@@ -6476,7 +6516,7 @@ function CoreIntegrationMappings() {
6476
6516
  /* @__PURE__ */ jsx39(Text24, { fontWeight: "semibold", mb: 2, children: "Listas Omie" }),
6477
6517
  /* @__PURE__ */ jsx39(Stack10, { gap: 2, children: (mappings.lists ?? []).length ? mappings.lists?.map((list) => {
6478
6518
  const latest = list.executions?.[0];
6479
- return /* @__PURE__ */ jsx39(Box23, { borderWidth: "1px", borderColor: "gray.100", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs24(Flex15, { align: "center", justify: "space-between", gap: 2, wrap: "wrap", children: [
6519
+ return /* @__PURE__ */ jsx39(Box23, { borderWidth: "1px", borderColor: "gray.100", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs24(Flex16, { align: "center", justify: "space-between", gap: 2, wrap: "wrap", children: [
6480
6520
  /* @__PURE__ */ jsxs24(Box23, { children: [
6481
6521
  /* @__PURE__ */ jsx39(Text24, { fontSize: "sm", fontWeight: "medium", children: list.label || list.key }),
6482
6522
  /* @__PURE__ */ jsxs24(Text24, { fontSize: "xs", color: "gray.500", children: [
@@ -6487,7 +6527,7 @@ function CoreIntegrationMappings() {
6487
6527
  list.targetModel || "destino declarado"
6488
6528
  ] })
6489
6529
  ] }),
6490
- /* @__PURE__ */ jsxs24(Flex15, { gap: 2, wrap: "wrap", children: [
6530
+ /* @__PURE__ */ jsxs24(Flex16, { gap: 2, wrap: "wrap", children: [
6491
6531
  /* @__PURE__ */ jsx39(Badge6, { variant: "outline", children: latest?.status || "n\xE3o executada" }),
6492
6532
  /* @__PURE__ */ jsx39(Badge6, { variant: "outline", children: dateTime2(latest?.lastCompletedAt) })
6493
6533
  ] })
@@ -6506,12 +6546,683 @@ function CoreIntegrationMappings() {
6506
6546
  ] });
6507
6547
  }
6508
6548
 
6509
- // src/modules/integrations.tsx
6549
+ // src/components/CoreOmieIntegration.tsx
6550
+ import { useEffect as useEffect10, useState as useState15 } from "react";
6551
+ 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";
6552
+ import { useMutation as useMutation5, useQuery as useQuery10 } from "@tanstack/react-query";
6510
6553
  import { jsx as jsx40, jsxs as jsxs25 } from "react/jsx-runtime";
6554
+ function dateTime3(value2) {
6555
+ if (!value2) return "\u2014";
6556
+ const date = new Date(value2);
6557
+ return Number.isNaN(date.getTime()) ? value2 : date.toLocaleString("pt-BR");
6558
+ }
6559
+ function statusPalette2(status) {
6560
+ const normalized2 = String(status || "").toLowerCase();
6561
+ if (normalized2.includes("erro") || normalized2.includes("error") || normalized2.includes("inativo")) return "red";
6562
+ if (normalized2.includes("process") || normalized2.includes("pendente") || normalized2.includes("not-tested")) return "yellow";
6563
+ if (normalized2.includes("conclu\xEDdo") || normalized2.includes("ativo") || normalized2 === "ok") return "green";
6564
+ return "gray";
6565
+ }
6566
+ function integrationErrorMessage2(error) {
6567
+ const candidate = error;
6568
+ const message = candidate?.response?.data?.error?.message || candidate?.response?.data?.message || candidate?.message;
6569
+ return typeof message === "string" && message.trim() ? message : "N\xE3o foi poss\xEDvel concluir a opera\xE7\xE3o.";
6570
+ }
6571
+ function countActive2(values) {
6572
+ return Object.entries(values ?? {}).filter(([status]) => !["Conclu\xEDdo", "Arquivado"].includes(status)).reduce((sum, [, count]) => sum + Number(count || 0), 0);
6573
+ }
6574
+ function absoluteWebhookUrl(path) {
6575
+ if (!path) return "";
6576
+ if (typeof window === "undefined") return path;
6577
+ return new URL(path, window.location.origin).toString();
6578
+ }
6579
+ async function copyText(value2) {
6580
+ if (typeof navigator !== "undefined" && navigator.clipboard?.writeText) {
6581
+ await navigator.clipboard.writeText(value2);
6582
+ return;
6583
+ }
6584
+ if (typeof document === "undefined") return;
6585
+ const textarea = document.createElement("textarea");
6586
+ textarea.value = value2;
6587
+ textarea.style.position = "fixed";
6588
+ textarea.style.opacity = "0";
6589
+ document.body.appendChild(textarea);
6590
+ textarea.select();
6591
+ document.execCommand("copy");
6592
+ textarea.remove();
6593
+ }
6594
+ function NativeSelect5({
6595
+ value: value2,
6596
+ onChange,
6597
+ children
6598
+ }) {
6599
+ return /* @__PURE__ */ jsx40(
6600
+ "select",
6601
+ {
6602
+ style: {
6603
+ width: "100%",
6604
+ height: "34px",
6605
+ border: "1px solid #e2e8f0",
6606
+ borderRadius: "6px",
6607
+ padding: "0 8px",
6608
+ background: "white"
6609
+ },
6610
+ value: value2,
6611
+ onChange: (event) => onChange(event.currentTarget.value),
6612
+ children
6613
+ }
6614
+ );
6615
+ }
6616
+ function OmieConfigurationTab() {
6617
+ const { http } = useOonApi();
6618
+ const configuration = useQuery10({
6619
+ queryKey: ["core-omie", "configuration"],
6620
+ queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
6621
+ });
6622
+ const [draft, setDraft] = useState15({
6623
+ instanceId: "default",
6624
+ label: "Omie",
6625
+ active: true,
6626
+ environment: "production",
6627
+ baseUrl: "https://app.omie.com.br/api/v1",
6628
+ appKey: "",
6629
+ appSecret: ""
6630
+ });
6631
+ const selected = (configuration.data ?? []).find((item) => item.instanceId === draft.instanceId) ?? configuration.data?.[0];
6632
+ useEffect10(() => {
6633
+ if (!selected) return;
6634
+ setDraft((current) => ({
6635
+ ...current,
6636
+ instanceId: selected.instanceId || "default",
6637
+ label: selected.label || "Omie",
6638
+ active: selected.active !== false,
6639
+ environment: selected.environment || "production",
6640
+ baseUrl: selected.baseUrl || "https://app.omie.com.br/api/v1",
6641
+ appKey: "",
6642
+ appSecret: ""
6643
+ }));
6644
+ }, [selected?.instanceId, selected?.updatedAt]);
6645
+ const save = useMutation5({
6646
+ mutationFn: () => http.put(
6647
+ `/integrations/providers/omie/configuration/${draft.instanceId}`,
6648
+ {
6649
+ label: draft.label,
6650
+ active: draft.active,
6651
+ environment: draft.environment,
6652
+ baseUrl: draft.baseUrl,
6653
+ ...draft.appKey ? { appKey: draft.appKey } : {},
6654
+ ...draft.appSecret ? { appSecret: draft.appSecret } : {}
6655
+ },
6656
+ { headers: { "x-oon-origin": "integration" } }
6657
+ ),
6658
+ onSuccess: async () => {
6659
+ setDraft((current) => ({ ...current, appKey: "", appSecret: "" }));
6660
+ await configuration.refetch();
6661
+ }
6662
+ });
6663
+ const testConnection = useMutation5({
6664
+ mutationFn: () => http.post(
6665
+ `/integrations/providers/omie/configuration/${draft.instanceId}/test`,
6666
+ {},
6667
+ { headers: { "x-oon-origin": "integration" } }
6668
+ ),
6669
+ onSuccess: () => configuration.refetch()
6670
+ });
6671
+ if (configuration.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
6672
+ if (configuration.error) return /* @__PURE__ */ jsx40(ErrorState, { error: configuration.error });
6673
+ const error = save.error || testConnection.error;
6674
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
6675
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6676
+ /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Configura\xE7\xF5es" }),
6677
+ /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Credenciais protegidas por inst\xE2ncia. O token do webhook \xE9 gerado e administrado automaticamente." })
6678
+ ] }),
6679
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
6680
+ /* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
6681
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
6682
+ /* @__PURE__ */ jsx40(
6683
+ NativeSelect5,
6684
+ {
6685
+ value: draft.instanceId,
6686
+ onChange: (instanceId) => setDraft((current) => ({ ...current, instanceId })),
6687
+ children: (configuration.data ?? []).map((instance) => /* @__PURE__ */ jsx40("option", { value: instance.instanceId, children: instance.label || instance.instanceId }, instance.instanceId))
6688
+ }
6689
+ )
6690
+ ] }),
6691
+ /* @__PURE__ */ jsxs25(Box24, { minW: "240px", flex: "2", children: [
6692
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Nome" }),
6693
+ /* @__PURE__ */ jsx40(
6694
+ Input9,
6695
+ {
6696
+ size: "sm",
6697
+ value: draft.label,
6698
+ onChange: (event) => setDraft((current) => ({ ...current, label: event.target.value }))
6699
+ }
6700
+ )
6701
+ ] }),
6702
+ /* @__PURE__ */ jsxs25(Box24, { minW: "180px", flex: "1", children: [
6703
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Ambiente" }),
6704
+ /* @__PURE__ */ jsxs25(
6705
+ NativeSelect5,
6706
+ {
6707
+ value: draft.environment,
6708
+ onChange: (environment) => setDraft((current) => ({ ...current, environment })),
6709
+ children: [
6710
+ /* @__PURE__ */ jsx40("option", { value: "production", children: "Produ\xE7\xE3o" }),
6711
+ /* @__PURE__ */ jsx40("option", { value: "homologation", children: "Homologa\xE7\xE3o" })
6712
+ ]
6713
+ }
6714
+ )
6715
+ ] })
6716
+ ] }),
6717
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6718
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL base" }),
6719
+ /* @__PURE__ */ jsx40(
6720
+ Input9,
6721
+ {
6722
+ size: "sm",
6723
+ value: draft.baseUrl,
6724
+ onChange: (event) => setDraft((current) => ({ ...current, baseUrl: event.target.value }))
6725
+ }
6726
+ )
6727
+ ] }),
6728
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 3, wrap: "wrap", children: [
6729
+ /* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
6730
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: [
6731
+ "App Key ",
6732
+ selected?.appKeyMasked ? `(${selected.appKeyMasked})` : ""
6733
+ ] }),
6734
+ /* @__PURE__ */ jsx40(
6735
+ Input9,
6736
+ {
6737
+ size: "sm",
6738
+ type: "password",
6739
+ value: draft.appKey,
6740
+ onChange: (event) => setDraft((current) => ({ ...current, appKey: event.target.value })),
6741
+ placeholder: selected?.credentialsConfigured ? "Manter valor atual" : "Informe a App Key"
6742
+ }
6743
+ )
6744
+ ] }),
6745
+ /* @__PURE__ */ jsxs25(Box24, { minW: "260px", flex: "1", children: [
6746
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "App Secret" }),
6747
+ /* @__PURE__ */ jsx40(
6748
+ Input9,
6749
+ {
6750
+ size: "sm",
6751
+ type: "password",
6752
+ value: draft.appSecret,
6753
+ onChange: (event) => setDraft((current) => ({ ...current, appSecret: event.target.value })),
6754
+ placeholder: selected?.credentialsConfigured ? "Manter valor atual" : "Informe o App Secret"
6755
+ }
6756
+ )
6757
+ ] })
6758
+ ] }),
6759
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6760
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
6761
+ /* @__PURE__ */ jsxs25("label", { children: [
6762
+ /* @__PURE__ */ jsx40(
6763
+ "input",
6764
+ {
6765
+ type: "checkbox",
6766
+ checked: draft.active,
6767
+ onChange: (event) => setDraft((current) => ({ ...current, active: event.target.checked }))
6768
+ }
6769
+ ),
6770
+ " ",
6771
+ "Integra\xE7\xE3o ativa"
6772
+ ] }),
6773
+ /* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(selected?.connectionStatus), children: [
6774
+ "Conex\xE3o: ",
6775
+ selected?.connectionStatus ?? "n\xE3o testada"
6776
+ ] }),
6777
+ /* @__PURE__ */ jsxs25(Badge7, { colorPalette: selected?.webhookConfigured ? "green" : "yellow", children: [
6778
+ "Webhook: ",
6779
+ selected?.webhookConfigured ? "configurado" : "ser\xE1 gerado"
6780
+ ] }),
6781
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.500", children: [
6782
+ "\xDAltimo teste: ",
6783
+ dateTime3(selected?.lastConnectionTestAt)
6784
+ ] })
6785
+ ] }),
6786
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
6787
+ /* @__PURE__ */ jsx40(
6788
+ Button17,
6789
+ {
6790
+ size: "sm",
6791
+ variant: "outline",
6792
+ loading: testConnection.isPending,
6793
+ onClick: () => testConnection.mutate(),
6794
+ children: "Testar conex\xE3o"
6795
+ }
6796
+ ),
6797
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", loading: save.isPending, onClick: () => save.mutate(), children: "Salvar configura\xE7\xF5es" })
6798
+ ] })
6799
+ ] }),
6800
+ selected?.lastConnectionError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: selected.lastConnectionError }) : null,
6801
+ error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
6802
+ ] });
6803
+ }
6804
+ function OmieSynchronizationTab() {
6805
+ const { http } = useOonApi();
6806
+ const health = useQuery10({
6807
+ queryKey: ["core-omie", "health"],
6808
+ queryFn: async () => {
6809
+ const providers = (await http.get("/integrations/health")).data?.results ?? [];
6810
+ return providers.find((provider2) => provider2.key === "omie") ?? null;
6811
+ }
6812
+ });
6813
+ const mappings = useQuery10({
6814
+ queryKey: ["core-omie", "mappings"],
6815
+ queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
6816
+ });
6817
+ const queue = useQuery10({
6818
+ queryKey: ["core-omie", "queue"],
6819
+ queryFn: async () => (await http.get("/integrations/queue", {
6820
+ params: { provider: "omie", limit: 20 }
6821
+ })).data?.results ?? []
6822
+ });
6823
+ const refresh = () => Promise.all([health.refetch(), mappings.refetch(), queue.refetch()]);
6824
+ const syncAll = useMutation5({
6825
+ mutationFn: () => http.post(
6826
+ "/integrations/providers/omie/sync-all",
6827
+ {},
6828
+ { headers: { "x-oon-origin": "integration" } }
6829
+ ),
6830
+ onSuccess: refresh
6831
+ });
6832
+ const syncResource = useMutation5({
6833
+ mutationFn: (resource) => http.post(
6834
+ `/integrations/providers/omie/resources/${resource}/sync`,
6835
+ {},
6836
+ { headers: { "x-oon-origin": "integration" } }
6837
+ ),
6838
+ onSuccess: refresh
6839
+ });
6840
+ const process = useMutation5({
6841
+ mutationFn: () => http.post(
6842
+ "/integrations/actions/process-active",
6843
+ { provider: "omie" },
6844
+ { headers: { "x-oon-origin": "integration" } }
6845
+ ),
6846
+ onSuccess: refresh
6847
+ });
6848
+ if (health.isLoading || mappings.isLoading || queue.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
6849
+ const error = health.error || mappings.error || queue.error || syncAll.error || syncResource.error || process.error;
6850
+ if ((health.error || mappings.error || queue.error) && !health.data) return /* @__PURE__ */ jsx40(ErrorState, { error });
6851
+ const provider = health.data;
6852
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
6853
+ /* @__PURE__ */ jsxs25(Flex17, { align: "start", justify: "space-between", gap: 3, wrap: "wrap", children: [
6854
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6855
+ /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Sincroniza\xE7\xE3o" }),
6856
+ /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execute listas declaradas e acompanhe o processamento da fila Omie." })
6857
+ ] }),
6858
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, children: [
6859
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", variant: "outline", loading: process.isPending, onClick: () => process.mutate(), children: "Processar pend\xEAncias" }),
6860
+ /* @__PURE__ */ jsx40(Button17, { size: "sm", loading: syncAll.isPending, onClick: () => syncAll.mutate(), children: "Sincronizar tudo" })
6861
+ ] })
6862
+ ] }),
6863
+ provider ? /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: [
6864
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", mb: 3, children: [
6865
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(provider.status), children: provider.status || "\u2014" }),
6866
+ /* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.queue) ? "yellow" : "green", children: [
6867
+ "Fila ativa: ",
6868
+ countActive2(provider.queue)
6869
+ ] }),
6870
+ /* @__PURE__ */ jsxs25(Badge7, { colorPalette: countActive2(provider.inbox) ? "yellow" : "green", children: [
6871
+ "Eventos ativos: ",
6872
+ countActive2(provider.inbox)
6873
+ ] }),
6874
+ /* @__PURE__ */ jsxs25(Badge7, { colorPalette: statusPalette2(provider.lastExecution?.status), children: [
6875
+ "\xDAltima execu\xE7\xE3o: ",
6876
+ provider.lastExecution?.status || "sem hist\xF3rico"
6877
+ ] })
6878
+ ] }),
6879
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", mb: 3, children: [
6880
+ "Pend\xEAncia mais antiga: ",
6881
+ dateTime3(provider.oldestPendingAt)
6882
+ ] }),
6883
+ /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: (provider.resources ?? []).map((resource) => /* @__PURE__ */ jsx40(
6884
+ Button17,
6885
+ {
6886
+ size: "sm",
6887
+ variant: "outline",
6888
+ loading: syncResource.isPending,
6889
+ onClick: () => syncResource.mutate(resource.key),
6890
+ children: resource.label
6891
+ },
6892
+ resource.key
6893
+ )) })
6894
+ ] }) : /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Provider Omie n\xE3o registrado." }),
6895
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6896
+ /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Listas declaradas" }),
6897
+ /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (mappings.data?.lists ?? []).map((list) => {
6898
+ const latest = list.executions?.[0];
6899
+ return /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
6900
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6901
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: list.label || list.key }),
6902
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
6903
+ list.mode || "modo padr\xE3o",
6904
+ " \xB7 ",
6905
+ list.direction || "dire\xE7\xE3o padr\xE3o",
6906
+ " \xB7 ",
6907
+ list.targetModel || "destino declarado"
6908
+ ] })
6909
+ ] }),
6910
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, wrap: "wrap", children: [
6911
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(latest?.status), children: latest?.status || "n\xE3o executada" }),
6912
+ /* @__PURE__ */ jsx40(Badge7, { variant: "outline", children: dateTime3(latest?.lastCompletedAt) })
6913
+ ] })
6914
+ ] }) }, list.key);
6915
+ }) })
6916
+ ] }),
6917
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6918
+ /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Fila recente" }),
6919
+ /* @__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: [
6920
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6921
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: ticket.handler }),
6922
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
6923
+ ticket.resource || "sem recurso",
6924
+ " \xB7 tentativas ",
6925
+ ticket.attempts ?? 0,
6926
+ " \xB7 pr\xF3xima ",
6927
+ dateTime3(ticket.nextAttemptAt)
6928
+ ] }),
6929
+ ticket.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: ticket.lastError.message }) : null
6930
+ ] }),
6931
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(ticket.status), children: ticket.status })
6932
+ ] }) }, ticket._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma pend\xEAncia Omie." }) })
6933
+ ] }),
6934
+ error ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(error) }) : null
6935
+ ] });
6936
+ }
6937
+ function OmieWebhooksTab() {
6938
+ const { http } = useOonApi();
6939
+ const [instanceId, setInstanceId] = useState15("default");
6940
+ const [copied, setCopied] = useState15(false);
6941
+ const configuration = useQuery10({
6942
+ queryKey: ["core-omie", "configuration"],
6943
+ queryFn: async () => (await http.get("/integrations/providers/omie/configuration")).data?.instances ?? []
6944
+ });
6945
+ const access = useQuery10({
6946
+ queryKey: ["core-omie", "webhook-access", instanceId],
6947
+ enabled: Boolean(instanceId),
6948
+ queryFn: async () => (await http.get(
6949
+ `/integrations/providers/omie/configuration/${instanceId}/webhook`
6950
+ )).data
6951
+ });
6952
+ const mappings = useQuery10({
6953
+ queryKey: ["core-omie", "mappings"],
6954
+ queryFn: async () => (await http.get("/integrations/providers/omie/mappings")).data
6955
+ });
6956
+ const events = useQuery10({
6957
+ queryKey: ["core-omie", "events"],
6958
+ queryFn: async () => (await http.get("/integrations/events", {
6959
+ params: { provider: "omie", limit: 20 }
6960
+ })).data?.results ?? []
6961
+ });
6962
+ const rotate = useMutation5({
6963
+ mutationFn: () => http.post(
6964
+ `/integrations/providers/omie/configuration/${instanceId}/webhook/rotate`,
6965
+ {},
6966
+ { headers: { "x-oon-origin": "integration" } }
6967
+ ),
6968
+ onSuccess: async () => {
6969
+ setCopied(false);
6970
+ await Promise.all([access.refetch(), configuration.refetch()]);
6971
+ }
6972
+ });
6973
+ useEffect10(() => {
6974
+ const first = configuration.data?.[0]?.instanceId;
6975
+ if (first && !configuration.data?.some((item) => item.instanceId === instanceId)) setInstanceId(first);
6976
+ }, [configuration.data, instanceId]);
6977
+ if (configuration.isLoading || mappings.isLoading || events.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
6978
+ const blockingError = configuration.error || mappings.error || events.error;
6979
+ if (blockingError) return /* @__PURE__ */ jsx40(ErrorState, { error: blockingError });
6980
+ const url = absoluteWebhookUrl(access.data?.webhookPath);
6981
+ const operationError = access.error || rotate.error;
6982
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
6983
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6984
+ /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Webhooks e gatilhos" }),
6985
+ /* @__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." })
6986
+ ] }),
6987
+ /* @__PURE__ */ jsx40(Box24, { borderWidth: "1px", borderRadius: "md", p: 4, children: /* @__PURE__ */ jsxs25(Stack11, { gap: 3, children: [
6988
+ /* @__PURE__ */ jsxs25(Box24, { maxW: "360px", children: [
6989
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "Inst\xE2ncia" }),
6990
+ /* @__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)) })
6991
+ ] }),
6992
+ /* @__PURE__ */ jsxs25(Box24, { children: [
6993
+ /* @__PURE__ */ jsx40(Text25, { fontSize: "xs", color: "gray.500", mb: 1, children: "URL do webhook" }),
6994
+ /* @__PURE__ */ jsxs25(Flex17, { gap: 2, align: "center", wrap: "wrap", children: [
6995
+ /* @__PURE__ */ jsx40(
6996
+ Input9,
6997
+ {
6998
+ size: "sm",
6999
+ value: url,
7000
+ readOnly: true,
7001
+ minW: "320px",
7002
+ flex: "1",
7003
+ placeholder: access.isLoading ? "Gerando URL segura\u2026" : "URL indispon\xEDvel"
7004
+ }
7005
+ ),
7006
+ /* @__PURE__ */ jsx40(
7007
+ Button17,
7008
+ {
7009
+ size: "sm",
7010
+ variant: "outline",
7011
+ disabled: !url,
7012
+ onClick: async () => {
7013
+ await copyText(url);
7014
+ setCopied(true);
7015
+ },
7016
+ children: copied ? "Link copiado" : "Copiar link"
7017
+ }
7018
+ ),
7019
+ /* @__PURE__ */ jsx40(
7020
+ Button17,
7021
+ {
7022
+ size: "sm",
7023
+ colorPalette: "red",
7024
+ variant: "outline",
7025
+ loading: rotate.isPending,
7026
+ onClick: () => {
7027
+ if (typeof window === "undefined" || window.confirm(
7028
+ "Gerar um novo token? A URL anterior deixar\xE1 de receber eventos."
7029
+ )) rotate.mutate();
7030
+ },
7031
+ children: "Gerar novo token"
7032
+ }
7033
+ )
7034
+ ] }),
7035
+ /* @__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." })
7036
+ ] })
7037
+ ] }) }),
7038
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7039
+ /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Gatilhos declarados" }),
7040
+ /* @__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: [
7041
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: webhook.eventType }),
7042
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7043
+ webhook.resource || "recurso gen\xE9rico",
7044
+ " \u2192 ",
7045
+ (webhook.actions ?? []).map((action) => action.handler).filter(Boolean).join(", ") || "sem a\xE7\xE3o declarada"
7046
+ ] })
7047
+ ] }, `${webhook.eventType}:${webhook.resource || ""}`)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum gatilho declarado pela Central." }) })
7048
+ ] }),
7049
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7050
+ /* @__PURE__ */ jsx40(Heading14, { size: "sm", mb: 3, children: "Eventos recebidos" }),
7051
+ /* @__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: [
7052
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7053
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "medium", children: event.eventType || "Evento Omie" }),
7054
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7055
+ event.resource || "sem recurso",
7056
+ " \xB7 recebido em ",
7057
+ dateTime3(event.receivedAt),
7058
+ " \xB7 tentativas ",
7059
+ event.attempts ?? 0
7060
+ ] }),
7061
+ event.lastError?.message ? /* @__PURE__ */ jsx40(Text25, { fontSize: "sm", color: "red.600", children: event.lastError.message }) : null
7062
+ ] }),
7063
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(event.status), children: event.status })
7064
+ ] }) }, event._id)) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhum webhook recebido." }) })
7065
+ ] }),
7066
+ operationError ? /* @__PURE__ */ jsx40(Text25, { color: "red.600", children: integrationErrorMessage2(operationError) }) : null
7067
+ ] });
7068
+ }
7069
+ function diagnosticMessage2(value2) {
7070
+ return value2.error?.message || value2.message || "Erro sem mensagem registrada.";
7071
+ }
7072
+ function OmieHistoryTab() {
7073
+ const { http } = useOonApi();
7074
+ const [expandedId, setExpandedId] = useState15(null);
7075
+ const history = useQuery10({
7076
+ queryKey: ["core-omie", "history"],
7077
+ queryFn: async () => (await http.get("/integrations/history", {
7078
+ params: { provider: "omie", limit: 30 }
7079
+ })).data?.results ?? []
7080
+ });
7081
+ if (history.isLoading) return /* @__PURE__ */ jsx40(LoadingScreen, {});
7082
+ if (history.error) return /* @__PURE__ */ jsx40(ErrorState, { error: history.error });
7083
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 4, children: [
7084
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7085
+ /* @__PURE__ */ jsx40(Heading14, { size: "md", children: "Hist\xF3rico" }),
7086
+ /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Execu\xE7\xF5es, erros por registro e diagn\xF3stico t\xE9cnico sanitizado." })
7087
+ ] }),
7088
+ /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: (history.data ?? []).length ? history.data?.map((execution) => {
7089
+ const expanded = expandedId === execution._id;
7090
+ const diagnostics = [...execution.errors ?? []];
7091
+ if (execution.error?.message && !diagnostics.some((item) => diagnosticMessage2(item) === execution.error?.message)) {
7092
+ diagnostics.push({ error: execution.error });
7093
+ }
7094
+ return /* @__PURE__ */ jsxs25(Box24, { borderWidth: "1px", borderRadius: "md", p: 3, children: [
7095
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", justify: "space-between", gap: 3, wrap: "wrap", children: [
7096
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7097
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", children: execution.title }),
7098
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "sm", color: "gray.500", children: [
7099
+ execution.resource || "sem recurso",
7100
+ " \xB7 ",
7101
+ dateTime3(execution.startedAt),
7102
+ " \xB7 ",
7103
+ execution.durationMs ?? 0,
7104
+ " ms"
7105
+ ] })
7106
+ ] }),
7107
+ /* @__PURE__ */ jsxs25(Flex17, { align: "center", gap: 2, wrap: "wrap", children: [
7108
+ (execution.errorCount ?? diagnostics.length) > 0 ? /* @__PURE__ */ jsxs25(Badge7, { colorPalette: "red", children: [
7109
+ execution.errorCount ?? diagnostics.length,
7110
+ " erro(s)"
7111
+ ] }) : null,
7112
+ /* @__PURE__ */ jsx40(Badge7, { colorPalette: statusPalette2(execution.status), children: execution.status }),
7113
+ /* @__PURE__ */ jsx40(
7114
+ Button17,
7115
+ {
7116
+ size: "sm",
7117
+ variant: "outline",
7118
+ "aria-expanded": expanded,
7119
+ onClick: () => setExpandedId((current) => current === execution._id ? null : execution._id),
7120
+ children: expanded ? "Ocultar detalhes" : "Ver detalhes"
7121
+ }
7122
+ )
7123
+ ] })
7124
+ ] }),
7125
+ expanded ? /* @__PURE__ */ jsxs25(Stack11, { gap: 3, mt: 3, pt: 3, borderTopWidth: "1px", children: [
7126
+ execution.summary && Object.keys(execution.summary).length ? /* @__PURE__ */ jsxs25(Box24, { children: [
7127
+ /* @__PURE__ */ jsx40(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: "Resumo" }),
7128
+ /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", children: Object.entries(execution.summary).map(([key, value2]) => /* @__PURE__ */ jsxs25(Badge7, { variant: "outline", children: [
7129
+ key,
7130
+ ": ",
7131
+ String(value2 ?? "\u2014")
7132
+ ] }, key)) })
7133
+ ] }) : null,
7134
+ diagnostics.length ? /* @__PURE__ */ jsxs25(Box24, { children: [
7135
+ /* @__PURE__ */ jsxs25(Text25, { fontWeight: "semibold", fontSize: "sm", mb: 2, children: [
7136
+ "Erros por registro",
7137
+ execution.errorsLimited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
7138
+ ] }),
7139
+ /* @__PURE__ */ jsx40(Stack11, { gap: 2, children: diagnostics.map((diagnostic, index) => /* @__PURE__ */ jsxs25(
7140
+ Box24,
7141
+ {
7142
+ borderWidth: "1px",
7143
+ borderColor: "red.100",
7144
+ borderRadius: "md",
7145
+ bg: "red.50",
7146
+ p: 3,
7147
+ children: [
7148
+ /* @__PURE__ */ jsxs25(Text25, { fontSize: "xs", color: "gray.600", children: [
7149
+ "Registro ",
7150
+ diagnostic.index !== void 0 ? diagnostic.index + 1 : index + 1,
7151
+ diagnostic.externalKey !== void 0 ? ` \xB7 chave ${String(diagnostic.externalKey)}` : "",
7152
+ diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode ? ` \xB7 c\xF3digo ${String(diagnostic.error?.code || diagnostic.code || diagnostic.error?.statusCode || diagnostic.statusCode)}` : ""
7153
+ ] }),
7154
+ /* @__PURE__ */ jsx40(Text25, { color: "red.700", children: diagnosticMessage2(diagnostic) })
7155
+ ]
7156
+ },
7157
+ `${diagnostic.index ?? index}:${diagnosticMessage2(diagnostic)}`
7158
+ )) })
7159
+ ] }) : null,
7160
+ [
7161
+ ["Itens processados", execution.items, execution.itemCount, execution.itemsLimited],
7162
+ ["Chamadas sanitizadas", execution.requests, execution.requestCount, execution.requestsLimited],
7163
+ ["Metadados", execution.metadata, void 0, false]
7164
+ ].map(([label, value2, count, limited]) => value2 ? /* @__PURE__ */ jsxs25("details", { children: [
7165
+ /* @__PURE__ */ jsxs25("summary", { style: { cursor: "pointer", fontWeight: 600 }, children: [
7166
+ String(label),
7167
+ typeof count === "number" ? ` (${count})` : "",
7168
+ limited ? " \xB7 visualiza\xE7\xE3o limitada" : ""
7169
+ ] }),
7170
+ /* @__PURE__ */ jsx40(
7171
+ Box24,
7172
+ {
7173
+ as: "pre",
7174
+ mt: 2,
7175
+ p: 3,
7176
+ borderRadius: "md",
7177
+ bg: "gray.50",
7178
+ overflowX: "auto",
7179
+ whiteSpace: "pre-wrap",
7180
+ fontSize: "xs",
7181
+ children: JSON.stringify(value2, null, 2)
7182
+ }
7183
+ )
7184
+ ] }, String(label)) : null)
7185
+ ] }) : null
7186
+ ] }, execution._id);
7187
+ }) : /* @__PURE__ */ jsx40(Text25, { color: "gray.400", children: "Nenhuma execu\xE7\xE3o Omie registrada." }) })
7188
+ ] });
7189
+ }
7190
+ var TABS = [
7191
+ { id: "configuration", label: "Configura\xE7\xF5es" },
7192
+ { id: "synchronization", label: "Sincroniza\xE7\xE3o" },
7193
+ { id: "webhooks", label: "Webhooks/Gatilhos" },
7194
+ { id: "history", label: "Hist\xF3rico" }
7195
+ ];
7196
+ function CoreOmieIntegration() {
7197
+ const [tab, setTab] = useState15("configuration");
7198
+ return /* @__PURE__ */ jsxs25(Stack11, { gap: 5, children: [
7199
+ /* @__PURE__ */ jsxs25(Box24, { children: [
7200
+ /* @__PURE__ */ jsx40(Heading14, { size: "lg", children: "Integra\xE7\xE3o Omie" }),
7201
+ /* @__PURE__ */ jsx40(Text25, { color: "gray.500", children: "Configure credenciais, sincroniza\xE7\xF5es, webhooks, gatilhos e diagn\xF3sticos da inst\xE2ncia Omie." })
7202
+ ] }),
7203
+ /* @__PURE__ */ jsx40(Flex17, { gap: 2, wrap: "wrap", borderBottomWidth: "1px", pb: 2, children: TABS.map((item) => /* @__PURE__ */ jsx40(
7204
+ Button17,
7205
+ {
7206
+ size: "sm",
7207
+ variant: tab === item.id ? "solid" : "ghost",
7208
+ onClick: () => setTab(item.id),
7209
+ children: item.label
7210
+ },
7211
+ item.id
7212
+ )) }),
7213
+ tab === "configuration" ? /* @__PURE__ */ jsx40(OmieConfigurationTab, {}) : null,
7214
+ tab === "synchronization" ? /* @__PURE__ */ jsx40(OmieSynchronizationTab, {}) : null,
7215
+ tab === "webhooks" ? /* @__PURE__ */ jsx40(OmieWebhooksTab, {}) : null,
7216
+ tab === "history" ? /* @__PURE__ */ jsx40(OmieHistoryTab, {}) : null
7217
+ ] });
7218
+ }
7219
+
7220
+ // src/modules/integrations.tsx
7221
+ import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
6511
7222
  function CoreIntegrationPage() {
6512
- return /* @__PURE__ */ jsxs25(Stack11, { gap: 8, children: [
6513
- /* @__PURE__ */ jsx40(CoreIntegration, {}),
6514
- /* @__PURE__ */ jsx40(CoreIntegrationMappings, {})
7223
+ return /* @__PURE__ */ jsxs26(Stack12, { gap: 8, children: [
7224
+ /* @__PURE__ */ jsx41(CoreIntegration, {}),
7225
+ /* @__PURE__ */ jsx41(CoreIntegrationMappings, {})
6515
7226
  ] });
6516
7227
  }
6517
7228
  function createIntegrationModule() {
@@ -6521,19 +7232,16 @@ function createIntegrationModule() {
6521
7232
  routes: [
6522
7233
  {
6523
7234
  path: "/integracoes",
6524
- element: /* @__PURE__ */ jsx40(CoreIntegrationPage, {}),
7235
+ element: /* @__PURE__ */ jsx41(CoreIntegrationPage, {}),
6525
7236
  capabilities: ["core.integrations"]
6526
- }
6527
- ],
6528
- menu: [
7237
+ },
6529
7238
  {
6530
- label: "Integra\xE7\xF5es",
6531
- href: "/integracoes",
6532
- section: "Integra\xE7\xF5es",
6533
- order: 800,
6534
- capabilities: ["core.integrations"]
7239
+ path: "/configuracoes/integracao-omie",
7240
+ element: /* @__PURE__ */ jsx41(CoreOmieIntegration, {}),
7241
+ capabilities: ["core.integrations", "core.integrations.omie"]
6535
7242
  }
6536
- ]
7243
+ ],
7244
+ menu: []
6537
7245
  };
6538
7246
  }
6539
7247
 
@@ -6583,36 +7291,36 @@ function defineOonModule(mod) {
6583
7291
  }
6584
7292
 
6585
7293
  // src/components/CoreCurrency.tsx
6586
- import { Button as Button16, Flex as Flex16, Heading as Heading14, Stack as Stack12, Text as Text25 } from "@chakra-ui/react";
6587
- import { useMutation as useMutation5, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
6588
- import { jsx as jsx41, jsxs as jsxs26 } from "react/jsx-runtime";
7294
+ import { Button as Button18, Flex as Flex18, Heading as Heading15, Stack as Stack13, Text as Text26 } from "@chakra-ui/react";
7295
+ import { useMutation as useMutation6, useQueryClient as useQueryClient5 } from "@tanstack/react-query";
7296
+ import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
6589
7297
  function CoreCurrency({ model = "Moeda", label = "Multi-moedas", endpoint = "/moedas", columns }) {
6590
7298
  const { http } = useOonApi();
6591
7299
  const queryClient = useQueryClient5();
6592
- const updateRates = useMutation5({
7300
+ const updateRates = useMutation6({
6593
7301
  mutationFn: () => http.post(`${endpoint}/actions/update-rates`, {}, { headers: { "x-oon-origin": "integration" } }),
6594
7302
  onSuccess: () => queryClient.invalidateQueries({ queryKey: ["oon", "list", endpoint] })
6595
7303
  });
6596
- return /* @__PURE__ */ jsxs26(Stack12, { gap: 6, children: [
6597
- /* @__PURE__ */ jsxs26(Flex16, { align: "center", justify: "space-between", children: [
6598
- /* @__PURE__ */ jsx41(Heading14, { size: "lg", children: label }),
6599
- /* @__PURE__ */ jsx41(Button16, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
7304
+ return /* @__PURE__ */ jsxs27(Stack13, { gap: 6, children: [
7305
+ /* @__PURE__ */ jsxs27(Flex18, { align: "center", justify: "space-between", children: [
7306
+ /* @__PURE__ */ jsx42(Heading15, { size: "lg", children: label }),
7307
+ /* @__PURE__ */ jsx42(Button18, { size: "sm", colorPalette: "blue", loading: updateRates.isPending, onClick: () => updateRates.mutate(), children: "Atualizar cota\xE7\xF5es" })
6600
7308
  ] }),
6601
- updateRates.isError ? /* @__PURE__ */ jsx41(Text25, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
6602
- /* @__PURE__ */ jsx41(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
7309
+ updateRates.isError ? /* @__PURE__ */ jsx42(Text26, { fontSize: "sm", color: "red.600", children: updateRates.error?.message }) : null,
7310
+ /* @__PURE__ */ jsx42(CoreCollection, { model, label: "", mode: columns ? "full" : "dynamic", endpoint, columns })
6603
7311
  ] });
6604
7312
  }
6605
7313
 
6606
7314
  // src/components/CoreAssistant.tsx
6607
- import { useState as useState15 } from "react";
6608
- import { Box as Box24, Button as Button17, Flex as Flex17, Heading as Heading15, Input as Input9, Stack as Stack13, Text as Text26 } from "@chakra-ui/react";
6609
- import { useMutation as useMutation6 } from "@tanstack/react-query";
6610
- import { jsx as jsx42, jsxs as jsxs27 } from "react/jsx-runtime";
7315
+ import { useState as useState16 } from "react";
7316
+ 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";
7317
+ import { useMutation as useMutation7 } from "@tanstack/react-query";
7318
+ import { jsx as jsx43, jsxs as jsxs28 } from "react/jsx-runtime";
6611
7319
  function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint = "/assistant-runs" }) {
6612
7320
  const { http } = useOonApi();
6613
- const [messages, setMessages] = useState15([]);
6614
- const [input, setInput] = useState15("");
6615
- const ask = useMutation6({
7321
+ const [messages, setMessages] = useState16([]);
7322
+ const [input, setInput] = useState16("");
7323
+ const ask = useMutation7({
6616
7324
  mutationFn: async (message) => {
6617
7325
  const { data } = await http.post(
6618
7326
  endpoint,
@@ -6636,11 +7344,11 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
6636
7344
  setInput("");
6637
7345
  ask.mutate(text);
6638
7346
  };
6639
- return /* @__PURE__ */ jsxs27(Stack13, { gap: 4, maxW: "560px", children: [
6640
- /* @__PURE__ */ jsx42(Heading15, { size: "md", children: label }),
6641
- /* @__PURE__ */ jsx42(Box24, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs27(Stack13, { gap: 3, children: [
6642
- messages.length === 0 ? /* @__PURE__ */ jsx42(Text26, { color: "gray.400", fontSize: "sm", children: "Fa\xE7a uma pergunta ao assistente." }) : messages.map((m, idx) => /* @__PURE__ */ jsx42(Flex17, { justify: m.role === "user" ? "flex-end" : "flex-start", children: /* @__PURE__ */ jsx42(
6643
- Box24,
7347
+ return /* @__PURE__ */ jsxs28(Stack14, { gap: 4, maxW: "560px", children: [
7348
+ /* @__PURE__ */ jsx43(Heading16, { size: "md", children: label }),
7349
+ /* @__PURE__ */ jsx43(Box25, { borderWidth: "1px", borderColor: "gray.200", borderRadius: "md", bg: "white", p: 4, minH: "240px", children: /* @__PURE__ */ jsxs28(Stack14, { gap: 3, children: [
7350
+ 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(
7351
+ Box25,
6644
7352
  {
6645
7353
  bg: m.role === "user" ? "brand.500" : "gray.100",
6646
7354
  color: m.role === "user" ? "white" : "gray.800",
@@ -6652,12 +7360,12 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
6652
7360
  children: m.content
6653
7361
  }
6654
7362
  ) }, idx)),
6655
- ask.isPending ? /* @__PURE__ */ jsx42(Text26, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
6656
- ask.isError ? /* @__PURE__ */ jsx42(Text26, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
7363
+ ask.isPending ? /* @__PURE__ */ jsx43(Text27, { color: "gray.400", fontSize: "sm", children: "Pensando\u2026" }) : null,
7364
+ ask.isError ? /* @__PURE__ */ jsx43(Text27, { color: "red.600", fontSize: "sm", children: ask.error?.message }) : null
6657
7365
  ] }) }),
6658
- /* @__PURE__ */ jsxs27(Flex17, { gap: 2, children: [
6659
- /* @__PURE__ */ jsx42(
6660
- Input9,
7366
+ /* @__PURE__ */ jsxs28(Flex19, { gap: 2, children: [
7367
+ /* @__PURE__ */ jsx43(
7368
+ Input10,
6661
7369
  {
6662
7370
  size: "sm",
6663
7371
  value: input,
@@ -6668,7 +7376,7 @@ function CoreAssistant({ assistantCode, label = "Assistente", entity, endpoint =
6668
7376
  }
6669
7377
  }
6670
7378
  ),
6671
- /* @__PURE__ */ jsx42(Button17, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
7379
+ /* @__PURE__ */ jsx43(Button19, { size: "sm", colorPalette: "blue", onClick: send, loading: ask.isPending, children: "Enviar" })
6672
7380
  ] })
6673
7381
  ] });
6674
7382
  }