@oondemand/oon-core-front 0.4.28 → 0.4.30

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
@@ -7,7 +7,7 @@ import { StrictMode } from "react";
7
7
  import { createRoot } from "react-dom/client";
8
8
 
9
9
  // src/app/OonApp.tsx
10
- import { useMemo as useMemo11 } from "react";
10
+ import { useMemo as useMemo12 } from "react";
11
11
  import { RouterProvider } from "react-router-dom";
12
12
 
13
13
  // src/api/createRestClient.ts
@@ -5089,147 +5089,998 @@ function CorePage2({ page, registry }) {
5089
5089
  }
5090
5090
 
5091
5091
  // src/components/CoreTransactionalEmail.tsx
5092
- import { useState as useState18 } from "react";
5093
- import { Badge as Badge5, Box as Box22, Button as Button16, Flex as Flex15, Heading as Heading13, Input as Input10, Stack as Stack9, Text as Text23, Textarea as Textarea3 } from "@chakra-ui/react";
5092
+ import { useEffect as useEffect11, useMemo as useMemo11, useState as useState18 } from "react";
5093
+ import { Badge as Badge5, Box as Box22, Button as Button16, Flex as Flex15, Heading as Heading13, IconButton as IconButton3, Input as Input10, Stack as Stack9, Text as Text23, Textarea as Textarea3 } from "@chakra-ui/react";
5094
5094
  import { useMutation as useMutation5, useQuery as useQuery11, useQueryClient as useQueryClient7 } from "@tanstack/react-query";
5095
- import { jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
5095
+ import { Fragment as Fragment5, jsx as jsx31, jsxs as jsxs23 } from "react/jsx-runtime";
5096
+ var EMPTY_SCHEMA = '{\n "type": "object",\n "additionalProperties": false,\n "properties": {}\n}';
5097
+ var EMPTY_DRAFT = {
5098
+ code: "",
5099
+ name: "",
5100
+ subject: "",
5101
+ htmlContent: "",
5102
+ textContent: "",
5103
+ variablesSchema: EMPTY_SCHEMA,
5104
+ locale: "pt-BR"
5105
+ };
5096
5106
  function errorMessage(error) {
5097
5107
  return error?.response?.data?.message || error?.message || "N\xE3o foi poss\xEDvel concluir a opera\xE7\xE3o.";
5098
5108
  }
5099
5109
  function color(status) {
5100
- if (["active", "provider_accepted"].includes(String(status))) return "green";
5101
- if (["degraded", "failed", "dead_letter"].includes(String(status))) return "red";
5110
+ if (["active", "provider_accepted", "valid"].includes(String(status))) return "green";
5111
+ if (["degraded", "invalid", "failed", "dead_letter"].includes(String(status))) return "red";
5102
5112
  return "yellow";
5103
5113
  }
5114
+ function prettyDate(value3) {
5115
+ return value3 ? new Intl.DateTimeFormat("pt-BR", { dateStyle: "short", timeStyle: "short" }).format(new Date(value3)) : "Ainda n\xE3o executado";
5116
+ }
5117
+ function sampleVariables(schema) {
5118
+ const properties = schema?.properties || {};
5119
+ const values = {};
5120
+ for (const [key, definition] of Object.entries(properties)) {
5121
+ if (definition.type === "number" || definition.type === "integer") values[key] = 0;
5122
+ else if (definition.type === "boolean") values[key] = false;
5123
+ else if (definition.type === "array") values[key] = [];
5124
+ else if (definition.type === "object") values[key] = {};
5125
+ else values[key] = "";
5126
+ }
5127
+ return JSON.stringify(values, null, 2);
5128
+ }
5129
+ function parseObject(source, message) {
5130
+ try {
5131
+ const value3 = JSON.parse(source);
5132
+ if (!value3 || typeof value3 !== "object" || Array.isArray(value3)) throw new Error(message);
5133
+ return value3;
5134
+ } catch {
5135
+ throw new Error(message);
5136
+ }
5137
+ }
5104
5138
  function CoreTransactionalEmail() {
5105
5139
  const { http } = useOonApi();
5106
5140
  const cache = useQueryClient7();
5107
5141
  const [tab, setTab] = useState18("config");
5108
- const [draft, setDraft] = useState18({ apiKey: "", senderEmail: "", senderName: "", replyTo: "", testRecipient: "" });
5109
5142
  const [error, setError] = useState18("");
5110
- const [templateDraft, setTemplateDraft] = useState18({ code: "", name: "", subject: "", htmlContent: "", textContent: "", variablesSchema: '{\n "type": "object",\n "additionalProperties": false\n}', locale: "pt-BR" });
5111
- const [templateTest, setTemplateTest] = useState18({ code: "", to: "", variables: "{}" });
5112
- const health = useQuery11({ queryKey: ["transactional-email", "health"], queryFn: async () => (await http.get("/core/transactional-email/health")).data });
5113
- const configuration = useQuery11({ queryKey: ["transactional-email", "configuration"], queryFn: async () => (await http.get("/core/transactional-email/configuration")).data.configuration });
5114
- const templates = useQuery11({ queryKey: ["transactional-email", "templates"], queryFn: async () => (await http.get("/core/transactional-email/templates")).data.results, enabled: tab === "templates" });
5115
- const dispatches = useQuery11({ queryKey: ["transactional-email", "dispatches"], queryFn: async () => (await http.get("/core/transactional-email/dispatches")).data.results, enabled: tab === "dispatches", refetchInterval: 1e4 });
5116
- const save = useMutation5({ mutationFn: async () => (await http.put("/core/transactional-email/configuration", { ...draft, enabled: true })).data, onSuccess: () => {
5117
- setDraft((value3) => ({ ...value3, apiKey: "" }));
5143
+ const [notice, setNotice] = useState18("");
5144
+ const [configurationDraft, setConfigurationDraft] = useState18({
5145
+ apiKey: "",
5146
+ senderEmail: "",
5147
+ senderName: "",
5148
+ replyTo: ""
5149
+ });
5150
+ const [configurationTestRecipient, setConfigurationTestRecipient] = useState18("");
5151
+ const [loadedConfigurationKey, setLoadedConfigurationKey] = useState18("");
5152
+ const [templateDraft, setTemplateDraft] = useState18(EMPTY_DRAFT);
5153
+ const [editingBase, setEditingBase] = useState18(null);
5154
+ const [previewTarget, setPreviewTarget] = useState18(null);
5155
+ const [previewVariables, setPreviewVariables] = useState18("{}");
5156
+ const [testTarget, setTestTarget] = useState18(null);
5157
+ const [templateTest, setTemplateTest] = useState18({ to: "", variables: "{}" });
5158
+ const [templateModalOpen, setTemplateModalOpen] = useState18(false);
5159
+ const [templateModalTab, setTemplateModalTab] = useState18("versions");
5160
+ const [managedTemplateCode, setManagedTemplateCode] = useState18("");
5161
+ const health = useQuery11({
5162
+ queryKey: ["transactional-email", "health"],
5163
+ queryFn: async () => (await http.get("/core/transactional-email/health")).data
5164
+ });
5165
+ const configuration = useQuery11({
5166
+ queryKey: ["transactional-email", "configuration"],
5167
+ queryFn: async () => (await http.get("/core/transactional-email/configuration")).data.configuration
5168
+ });
5169
+ const templates = useQuery11({
5170
+ queryKey: ["transactional-email", "templates"],
5171
+ queryFn: async () => (await http.get("/core/transactional-email/templates")).data.results,
5172
+ enabled: tab === "templates"
5173
+ });
5174
+ const dispatches = useQuery11({
5175
+ queryKey: ["transactional-email", "dispatches"],
5176
+ queryFn: async () => (await http.get("/core/transactional-email/dispatches")).data.results,
5177
+ enabled: tab === "dispatches",
5178
+ refetchInterval: 1e4
5179
+ });
5180
+ const config = configuration.data;
5181
+ const configurationKey = [
5182
+ config?.updatedAt,
5183
+ config?.senderEmail,
5184
+ config?.senderName,
5185
+ config?.replyTo,
5186
+ config?.fingerprint
5187
+ ].join("|");
5188
+ useEffect11(() => {
5189
+ if (!config || configurationKey === loadedConfigurationKey) return;
5190
+ setConfigurationDraft({
5191
+ apiKey: "",
5192
+ senderEmail: config.senderEmail || "",
5193
+ senderName: config.senderName || "",
5194
+ replyTo: config.replyTo || ""
5195
+ });
5196
+ setConfigurationTestRecipient((value3) => value3 || config.senderEmail || "");
5197
+ setLoadedConfigurationKey(configurationKey);
5198
+ }, [config, configurationKey, loadedConfigurationKey]);
5199
+ const groupedTemplates = useMemo11(() => {
5200
+ var _a;
5201
+ const groups = {};
5202
+ for (const item of templates.data || []) (groups[_a = item.code] || (groups[_a] = [])).push(item);
5203
+ return Object.entries(groups);
5204
+ }, [templates.data]);
5205
+ const managedVersions = useMemo11(
5206
+ () => (templates.data || []).filter((item) => item.code === managedTemplateCode),
5207
+ [managedTemplateCode, templates.data]
5208
+ );
5209
+ const managedTemplate = managedVersions.find((item) => item.status === "active") || managedVersions[0] || null;
5210
+ const draftContext = !managedTemplateCode || Boolean(editingBase);
5211
+ const saveConfiguration = useMutation5({
5212
+ mutationFn: async () => {
5213
+ const payload = {
5214
+ senderEmail: configurationDraft.senderEmail,
5215
+ senderName: configurationDraft.senderName,
5216
+ replyTo: configurationDraft.replyTo,
5217
+ enabled: true
5218
+ };
5219
+ if (configurationDraft.apiKey.trim()) payload.apiKey = configurationDraft.apiKey.trim();
5220
+ return (await http.put("/core/transactional-email/configuration", payload)).data;
5221
+ },
5222
+ onSuccess: () => {
5223
+ setConfigurationDraft((value3) => ({ ...value3, apiKey: "" }));
5224
+ setError("");
5225
+ setNotice("Dados do remetente salvos. A credencial armazenada foi preservada.");
5226
+ cache.invalidateQueries({ queryKey: ["transactional-email"] });
5227
+ },
5228
+ onError: (reason) => {
5229
+ setNotice("");
5230
+ setError(errorMessage(reason));
5231
+ }
5232
+ });
5233
+ const testConfiguration = useMutation5({
5234
+ mutationFn: async () => (await http.post("/core/transactional-email/configuration/test", {
5235
+ recipient: configurationTestRecipient
5236
+ })).data,
5237
+ onSuccess: () => {
5238
+ setError("");
5239
+ setNotice("Teste enviado. Consulte a caixa do destinat\xE1rio e a aba Envios.");
5240
+ cache.invalidateQueries({ queryKey: ["transactional-email"] });
5241
+ },
5242
+ onError: (reason) => {
5243
+ setNotice("");
5244
+ setError(errorMessage(reason));
5245
+ cache.invalidateQueries({ queryKey: ["transactional-email"] });
5246
+ }
5247
+ });
5248
+ const createVersion = useMutation5({
5249
+ mutationFn: async () => http.post(
5250
+ "/core/transactional-email/templates/" + templateDraft.code + "/versions",
5251
+ {
5252
+ ...templateDraft,
5253
+ variablesSchema: parseObject(templateDraft.variablesSchema, "JSON Schema inv\xE1lido."),
5254
+ attachmentsPolicy: { allowed: false }
5255
+ }
5256
+ ),
5257
+ onSuccess: () => {
5258
+ setError("");
5259
+ setNotice("Nova vers\xE3o salva como rascunho. Ela ainda n\xE3o est\xE1 ativa.");
5260
+ setEditingBase(null);
5261
+ setTemplateDraft(EMPTY_DRAFT);
5262
+ setTemplateModalOpen(false);
5263
+ cache.invalidateQueries({ queryKey: ["transactional-email", "templates"] });
5264
+ },
5265
+ onError: (reason) => {
5266
+ setNotice("");
5267
+ setError(errorMessage(reason));
5268
+ }
5269
+ });
5270
+ const activate = useMutation5({
5271
+ mutationFn: async (item) => http.post(
5272
+ "/core/transactional-email/templates/" + item.code + "/versions/" + item.version + "/activate"
5273
+ ),
5274
+ onSuccess: () => {
5275
+ setError("");
5276
+ setNotice("Vers\xE3o ativada manualmente.");
5277
+ cache.invalidateQueries({ queryKey: ["transactional-email", "templates"] });
5278
+ },
5279
+ onError: (reason) => {
5280
+ setNotice("");
5281
+ setError(errorMessage(reason));
5282
+ }
5283
+ });
5284
+ const preview = useMutation5({
5285
+ mutationFn: async (request) => (await http.post(
5286
+ "/core/transactional-email/templates/" + request.code + "/preview",
5287
+ {
5288
+ version: request.version,
5289
+ definition: request.definition,
5290
+ variables: request.variables
5291
+ }
5292
+ )).data,
5293
+ onSuccess: () => {
5294
+ setError("");
5295
+ setNotice("");
5296
+ },
5297
+ onError: (reason) => {
5298
+ setNotice("");
5299
+ setError(errorMessage(reason));
5300
+ }
5301
+ });
5302
+ const testTemplate = useMutation5({
5303
+ mutationFn: async () => {
5304
+ if (!testTarget) throw new Error("Selecione uma vers\xE3o para testar.");
5305
+ return http.post("/core/transactional-email/templates/" + testTarget.code + "/test", {
5306
+ version: testTarget.version,
5307
+ to: templateTest.to,
5308
+ variables: parseObject(templateTest.variables, "JSON de vari\xE1veis inv\xE1lido.")
5309
+ });
5310
+ },
5311
+ onSuccess: () => {
5312
+ setError("");
5313
+ setNotice("Teste da vers\xE3o " + testTarget?.version + " enfileirado sem alterar a vers\xE3o ativa.");
5314
+ cache.invalidateQueries({ queryKey: ["transactional-email", "dispatches"] });
5315
+ },
5316
+ onError: (reason) => {
5317
+ setNotice("");
5318
+ setError(errorMessage(reason));
5319
+ }
5320
+ });
5321
+ const retry = useMutation5({
5322
+ mutationFn: async (id) => http.post("/core/transactional-email/dispatches/" + id + "/retry"),
5323
+ onSuccess: () => cache.invalidateQueries({ queryKey: ["transactional-email", "dispatches"] }),
5324
+ onError: (reason) => setError(errorMessage(reason))
5325
+ });
5326
+ function useAsBase(item) {
5327
+ setEditingBase(item);
5328
+ setManagedTemplateCode(item.code);
5329
+ setTemplateDraft({
5330
+ code: item.code,
5331
+ name: item.name,
5332
+ subject: item.subject,
5333
+ htmlContent: item.htmlContent,
5334
+ textContent: item.textContent,
5335
+ variablesSchema: JSON.stringify(item.variablesSchema || {}, null, 2),
5336
+ locale: item.locale || "pt-BR"
5337
+ });
5338
+ setPreviewVariables(sampleVariables(item.variablesSchema));
5339
+ setPreviewTarget(null);
5340
+ preview.reset();
5341
+ setTemplateModalTab("content");
5342
+ setTemplateModalOpen(true);
5343
+ setNotice("Vers\xE3o " + item.version + " carregada como base. Ao salvar, uma nova vers\xE3o em rascunho ser\xE1 criada.");
5118
5344
  setError("");
5119
- cache.invalidateQueries({ queryKey: ["transactional-email"] });
5120
- }, onError: (reason) => setError(errorMessage(reason)) });
5121
- const retry = useMutation5({ mutationFn: async (id) => http.post(`/core/transactional-email/dispatches/${id}/retry`), onSuccess: () => cache.invalidateQueries({ queryKey: ["transactional-email", "dispatches"] }), onError: (reason) => setError(errorMessage(reason)) });
5122
- const createVersion = useMutation5({ mutationFn: async () => http.post(`/core/transactional-email/templates/${templateDraft.code}/versions`, { ...templateDraft, variablesSchema: JSON.parse(templateDraft.variablesSchema), attachmentsPolicy: { allowed: false } }), onSuccess: () => {
5345
+ }
5346
+ function openNewTemplate() {
5347
+ setManagedTemplateCode("");
5348
+ setEditingBase(null);
5349
+ setTemplateDraft(EMPTY_DRAFT);
5350
+ setPreviewTarget(null);
5351
+ setTestTarget(null);
5352
+ setPreviewVariables("{}");
5353
+ setTemplateTest({ to: config?.senderEmail || "", variables: "{}" });
5354
+ preview.reset();
5123
5355
  setError("");
5124
- cache.invalidateQueries({ queryKey: ["transactional-email", "templates"] });
5125
- }, onError: (reason) => setError(errorMessage(reason)) });
5126
- const activate = useMutation5({ mutationFn: async (item) => http.post(`/core/transactional-email/templates/${item.code}/versions/${item.version}/activate`), onSuccess: () => cache.invalidateQueries({ queryKey: ["transactional-email", "templates"] }), onError: (reason) => setError(errorMessage(reason)) });
5127
- const testTemplate = useMutation5({ mutationFn: async () => http.post(`/core/transactional-email/templates/${templateTest.code}/test`, { to: templateTest.to, variables: JSON.parse(templateTest.variables) }), onSuccess: () => {
5356
+ setNotice("");
5357
+ setTemplateModalTab("content");
5358
+ setTemplateModalOpen(true);
5359
+ }
5360
+ function manageTemplate(code) {
5361
+ const versions = (templates.data || []).filter((item) => item.code === code);
5362
+ const target = versions.find((item) => item.status === "active") || versions[0] || null;
5363
+ setManagedTemplateCode(code);
5364
+ setEditingBase(null);
5365
+ setTemplateDraft(EMPTY_DRAFT);
5366
+ setPreviewTarget(target);
5367
+ setTestTarget(target);
5368
+ setPreviewVariables(sampleVariables(target?.variablesSchema));
5369
+ setTemplateTest({
5370
+ to: config?.senderEmail || "",
5371
+ variables: sampleVariables(target?.variablesSchema)
5372
+ });
5373
+ preview.reset();
5128
5374
  setError("");
5129
- cache.invalidateQueries({ queryKey: ["transactional-email", "dispatches"] });
5130
- }, onError: (reason) => setError(errorMessage(reason)) });
5131
- const config = configuration.data;
5375
+ setNotice("");
5376
+ setTemplateModalTab("versions");
5377
+ setTemplateModalOpen(true);
5378
+ }
5379
+ function closeTemplateModal() {
5380
+ setTemplateModalOpen(false);
5381
+ setError("");
5382
+ preview.reset();
5383
+ }
5384
+ function selectPreview(item) {
5385
+ setManagedTemplateCode(item.code);
5386
+ setPreviewTarget(item);
5387
+ setPreviewVariables(sampleVariables(item.variablesSchema));
5388
+ preview.reset();
5389
+ setTemplateModalTab("preview");
5390
+ setTemplateModalOpen(true);
5391
+ setError("");
5392
+ setNotice("");
5393
+ }
5394
+ function renderSavedPreview() {
5395
+ if (!previewTarget) return;
5396
+ try {
5397
+ preview.mutate({
5398
+ code: previewTarget.code,
5399
+ version: previewTarget.version,
5400
+ variables: parseObject(previewVariables, "JSON de vari\xE1veis inv\xE1lido.")
5401
+ });
5402
+ } catch (reason) {
5403
+ setError(errorMessage(reason));
5404
+ }
5405
+ }
5406
+ function renderDraftPreview() {
5407
+ try {
5408
+ const variablesSchema = parseObject(templateDraft.variablesSchema, "JSON Schema inv\xE1lido.");
5409
+ preview.mutate({
5410
+ code: templateDraft.code,
5411
+ definition: {
5412
+ ...templateDraft,
5413
+ variablesSchema,
5414
+ attachmentsPolicy: { allowed: false }
5415
+ },
5416
+ variables: parseObject(previewVariables, "JSON de vari\xE1veis inv\xE1lido.")
5417
+ });
5418
+ setPreviewTarget(null);
5419
+ } catch (reason) {
5420
+ setError(errorMessage(reason));
5421
+ }
5422
+ }
5423
+ function selectTest(item) {
5424
+ setManagedTemplateCode(item.code);
5425
+ setTestTarget(item);
5426
+ setTemplateTest((value3) => ({
5427
+ to: value3.to || config?.senderEmail || "",
5428
+ variables: sampleVariables(item.variablesSchema)
5429
+ }));
5430
+ setTemplateModalTab("test");
5431
+ setTemplateModalOpen(true);
5432
+ setError("");
5433
+ setNotice("");
5434
+ }
5435
+ useEffect11(() => {
5436
+ if (!templateModalOpen) return void 0;
5437
+ const previousOverflow = document.body.style.overflow;
5438
+ const onKeyDown = (event) => {
5439
+ if (event.key === "Escape") closeTemplateModal();
5440
+ };
5441
+ document.body.style.overflow = "hidden";
5442
+ document.addEventListener("keydown", onKeyDown);
5443
+ return () => {
5444
+ document.body.style.overflow = previousOverflow;
5445
+ document.removeEventListener("keydown", onKeyDown);
5446
+ };
5447
+ }, [templateModalOpen]);
5448
+ function activateVersion(item) {
5449
+ const confirmed = window.confirm(
5450
+ "Ativar " + item.code + " v" + item.version + "? A vers\xE3o ativa atual ser\xE1 arquivada."
5451
+ );
5452
+ if (confirmed) activate.mutate(item);
5453
+ }
5132
5454
  return /* @__PURE__ */ jsxs23(Stack9, { gap: 5, children: [
5133
5455
  /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", align: "center", wrap: "wrap", gap: 3, children: [
5134
5456
  /* @__PURE__ */ jsxs23(Box22, { children: [
5135
5457
  /* @__PURE__ */ jsx31(Heading13, { size: "lg", children: "E-mail transacional" }),
5136
- /* @__PURE__ */ jsx31(Text23, { color: "gray.600", children: "Configura\xE7\xE3o, templates e fila de envio deste App." })
5458
+ /* @__PURE__ */ jsx31(Text23, { color: "gray.600", children: "Configure o remetente, revise vers\xF5es e valide cada envio antes da ativa\xE7\xE3o." })
5137
5459
  ] }),
5138
5460
  /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(health.data?.status), children: health.data?.status || "carregando" })
5139
5461
  ] }),
5140
- /* @__PURE__ */ jsx31(Flex15, { gap: 2, children: [["config", "Configura\xE7\xE3o"], ["templates", "Templates"], ["dispatches", "Envios"]].map(([id, label]) => /* @__PURE__ */ jsx31(Button16, { size: "sm", variant: tab === id ? "solid" : "outline", onClick: () => setTab(id), children: label }, id)) }),
5141
- error ? /* @__PURE__ */ jsx31(Box22, { borderWidth: "1px", borderColor: "red.200", bg: "red.50", p: 3, borderRadius: "md", children: /* @__PURE__ */ jsx31(Text23, { color: "red.700", children: error }) }) : null,
5142
- tab === "config" ? /* @__PURE__ */ jsx31(Box22, { borderWidth: "1px", borderRadius: "lg", p: 5, children: /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5143
- /* @__PURE__ */ jsxs23(Flex15, { gap: 2, wrap: "wrap", children: [
5144
- /* @__PURE__ */ jsx31(Badge5, { colorPalette: config?.credentialConfigured ? "green" : "yellow", children: config?.credentialConfigured ? `Chave ${config.apiKeyMasked}` : "Chave pendente" }),
5145
- /* @__PURE__ */ jsx31(Badge5, { children: config?.connectionStatus || "n\xE3o testada" })
5146
- ] }),
5147
- /* @__PURE__ */ jsx31(Input10, { type: "password", autoComplete: "new-password", placeholder: "Nova API key SendGrid (write-only)", value: draft.apiKey, onChange: (event) => setDraft({ ...draft, apiKey: event.target.value }) }),
5148
- /* @__PURE__ */ jsx31(Input10, { placeholder: config?.senderEmail || "Remetente", value: draft.senderEmail, onChange: (event) => setDraft({ ...draft, senderEmail: event.target.value }) }),
5149
- /* @__PURE__ */ jsx31(Input10, { placeholder: config?.senderName || "Nome do remetente", value: draft.senderName, onChange: (event) => setDraft({ ...draft, senderName: event.target.value }) }),
5150
- /* @__PURE__ */ jsx31(Input10, { placeholder: config?.replyTo || "Reply-to", value: draft.replyTo, onChange: (event) => setDraft({ ...draft, replyTo: event.target.value }) }),
5151
- /* @__PURE__ */ jsx31(Input10, { placeholder: "Destinat\xE1rio do envio de teste", value: draft.testRecipient, onChange: (event) => setDraft({ ...draft, testRecipient: event.target.value }) }),
5152
- /* @__PURE__ */ jsx31(Button16, { alignSelf: "start", loading: save.isPending, onClick: () => save.mutate(), children: "Validar e ativar" })
5153
- ] }) }) : null,
5154
- tab === "templates" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5155
- /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: 5, children: [
5156
- /* @__PURE__ */ jsx31(Heading13, { size: "sm", mb: 3, children: "Nova vers\xE3o em rascunho" }),
5157
- /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5158
- /* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
5159
- /* @__PURE__ */ jsx31(Input10, { flex: "1", minW: "180px", placeholder: "C\xF3digo declarado", value: templateDraft.code, onChange: (event) => setTemplateDraft({ ...templateDraft, code: event.target.value }) }),
5160
- /* @__PURE__ */ jsx31(Input10, { flex: "2", minW: "220px", placeholder: "Nome", value: templateDraft.name, onChange: (event) => setTemplateDraft({ ...templateDraft, name: event.target.value }) })
5462
+ /* @__PURE__ */ jsx31(Flex15, { gap: 2, wrap: "wrap", children: [
5463
+ ["config", "Configura\xE7\xE3o"],
5464
+ ["templates", "Templates"],
5465
+ ["dispatches", "Envios"]
5466
+ ].map(([id, label]) => /* @__PURE__ */ jsx31(Button16, { size: "sm", variant: tab === id ? "solid" : "outline", onClick: () => setTab(id), children: label }, id)) }),
5467
+ error ? /* @__PURE__ */ jsx31(Box22, { role: "alert", borderWidth: "1px", borderColor: "red.200", bg: "red.50", p: 3, borderRadius: "md", children: /* @__PURE__ */ jsx31(Text23, { color: "red.700", children: error }) }) : null,
5468
+ notice ? /* @__PURE__ */ jsx31(Box22, { role: "status", borderWidth: "1px", borderColor: "green.200", bg: "green.50", p: 3, borderRadius: "md", children: /* @__PURE__ */ jsx31(Text23, { color: "green.800", children: notice }) }) : null,
5469
+ tab === "config" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5470
+ /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: { base: 4, md: 5 }, children: [
5471
+ /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", align: "start", gap: 3, wrap: "wrap", mb: 5, children: [
5472
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5473
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Remetente e credencial" }),
5474
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "Altere os dados abaixo sem informar novamente a API key j\xE1 protegida." })
5161
5475
  ] }),
5162
- /* @__PURE__ */ jsx31(Input10, { placeholder: "Assunto Handlebars", value: templateDraft.subject, onChange: (event) => setTemplateDraft({ ...templateDraft, subject: event.target.value }) }),
5163
- /* @__PURE__ */ jsx31(Textarea3, { placeholder: "HTML", value: templateDraft.htmlContent, onChange: (event) => setTemplateDraft({ ...templateDraft, htmlContent: event.target.value }) }),
5164
- /* @__PURE__ */ jsx31(Textarea3, { placeholder: "Texto simples", value: templateDraft.textContent, onChange: (event) => setTemplateDraft({ ...templateDraft, textContent: event.target.value }) }),
5165
- /* @__PURE__ */ jsx31(Textarea3, { "aria-label": "JSON Schema das vari\xE1veis", value: templateDraft.variablesSchema, onChange: (event) => setTemplateDraft({ ...templateDraft, variablesSchema: event.target.value }) }),
5166
- /* @__PURE__ */ jsx31(Button16, { alignSelf: "start", loading: createVersion.isPending, onClick: () => {
5167
- try {
5168
- JSON.parse(templateDraft.variablesSchema);
5169
- createVersion.mutate();
5170
- } catch {
5171
- setError("JSON Schema inv\xE1lido.");
5476
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, wrap: "wrap", children: [
5477
+ /* @__PURE__ */ jsx31(Badge5, { colorPalette: config?.credentialConfigured ? "green" : "yellow", children: config?.credentialConfigured ? "Chave " + config.apiKeyMasked : "Chave pendente" }),
5478
+ /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(config?.connectionStatus), children: config?.connectionStatus || "n\xE3o testada" })
5479
+ ] })
5480
+ ] }),
5481
+ /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5482
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5483
+ /* @__PURE__ */ jsx31("label", { htmlFor: "transactional-sender-email", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "E-mail do remetente" }),
5484
+ /* @__PURE__ */ jsx31(
5485
+ Input10,
5486
+ {
5487
+ id: "transactional-sender-email",
5488
+ type: "email",
5489
+ mt: 1,
5490
+ value: configurationDraft.senderEmail,
5491
+ onChange: (event) => setConfigurationDraft({ ...configurationDraft, senderEmail: event.target.value })
5492
+ }
5493
+ )
5494
+ ] }),
5495
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5496
+ /* @__PURE__ */ jsx31("label", { htmlFor: "transactional-sender-name", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Nome do remetente" }),
5497
+ /* @__PURE__ */ jsx31(
5498
+ Input10,
5499
+ {
5500
+ id: "transactional-sender-name",
5501
+ mt: 1,
5502
+ value: configurationDraft.senderName,
5503
+ onChange: (event) => setConfigurationDraft({ ...configurationDraft, senderName: event.target.value })
5504
+ }
5505
+ )
5506
+ ] }),
5507
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5508
+ /* @__PURE__ */ jsx31("label", { htmlFor: "transactional-reply-to", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Responder para" }),
5509
+ /* @__PURE__ */ jsx31(
5510
+ Input10,
5511
+ {
5512
+ id: "transactional-reply-to",
5513
+ type: "email",
5514
+ mt: 1,
5515
+ placeholder: "Opcional",
5516
+ value: configurationDraft.replyTo,
5517
+ onChange: (event) => setConfigurationDraft({ ...configurationDraft, replyTo: event.target.value })
5518
+ }
5519
+ )
5520
+ ] }),
5521
+ /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "md", p: 4, bg: "gray.50", children: [
5522
+ /* @__PURE__ */ jsx31("label", { htmlFor: "transactional-api-key", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Trocar API key" }),
5523
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.600", mb: 2, children: "Deixe em branco para manter a chave atual. O valor nunca ser\xE1 exibido depois de salvo." }),
5524
+ /* @__PURE__ */ jsx31(
5525
+ Input10,
5526
+ {
5527
+ id: "transactional-api-key",
5528
+ type: "password",
5529
+ autoComplete: "new-password",
5530
+ placeholder: "Nova API key SendGrid",
5531
+ bg: "white",
5532
+ value: configurationDraft.apiKey,
5533
+ onChange: (event) => setConfigurationDraft({ ...configurationDraft, apiKey: event.target.value })
5534
+ }
5535
+ )
5536
+ ] }),
5537
+ /* @__PURE__ */ jsx31(
5538
+ Button16,
5539
+ {
5540
+ alignSelf: "start",
5541
+ loading: saveConfiguration.isPending,
5542
+ onClick: () => saveConfiguration.mutate(),
5543
+ children: "Salvar altera\xE7\xF5es"
5172
5544
  }
5173
- }, children: "Salvar rascunho" })
5545
+ )
5174
5546
  ] })
5175
5547
  ] }),
5176
- templates.data?.map((item) => /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: 4, children: [
5177
- /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", gap: 3, children: [
5178
- /* @__PURE__ */ jsxs23(Box22, { children: [
5179
- /* @__PURE__ */ jsx31(Text23, { fontWeight: "semibold", children: item.name }),
5180
- /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.600", children: [
5181
- item.code,
5182
- " \xB7 vers\xE3o ",
5183
- item.version,
5184
- " \xB7 origem ",
5185
- item.origin
5186
- ] })
5548
+ /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: { base: 4, md: 5 }, children: [
5549
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Teste de entrega" }),
5550
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", mb: 4, children: "Refa\xE7a o teste com a chave e o remetente atualmente salvos." }),
5551
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 3, align: "end", wrap: "wrap", children: [
5552
+ /* @__PURE__ */ jsxs23(Box22, { flex: "1", minW: "240px", children: [
5553
+ /* @__PURE__ */ jsx31("label", { htmlFor: "transactional-test-recipient", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Destinat\xE1rio do teste" }),
5554
+ /* @__PURE__ */ jsx31(
5555
+ Input10,
5556
+ {
5557
+ id: "transactional-test-recipient",
5558
+ type: "email",
5559
+ mt: 1,
5560
+ value: configurationTestRecipient,
5561
+ onChange: (event) => setConfigurationTestRecipient(event.target.value)
5562
+ }
5563
+ )
5187
5564
  ] }),
5188
- /* @__PURE__ */ jsxs23(Stack9, { align: "end", children: [
5189
- /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(item.status), children: item.status }),
5190
- item.status !== "active" ? /* @__PURE__ */ jsx31(Button16, { size: "xs", loading: activate.isPending, onClick: () => activate.mutate(item), children: item.status === "archived" ? "Reverter para esta vers\xE3o" : "Ativar" }) : null
5191
- ] })
5192
- ] }),
5193
- /* @__PURE__ */ jsx31(Text23, { mt: 2, fontSize: "sm", children: item.subject })
5194
- ] }, item._id)),
5195
- !templates.isLoading && !templates.data?.length ? /* @__PURE__ */ jsx31(Text23, { children: "Nenhum template declarado." }) : null,
5196
- /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: 5, children: [
5197
- /* @__PURE__ */ jsx31(Heading13, { size: "sm", mb: 3, children: "Envio de teste" }),
5198
- /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5199
- /* @__PURE__ */ jsx31(Input10, { placeholder: "C\xF3digo do template ativo", value: templateTest.code, onChange: (event) => setTemplateTest({ ...templateTest, code: event.target.value }) }),
5200
- /* @__PURE__ */ jsx31(Input10, { type: "email", placeholder: "Destinat\xE1rio", value: templateTest.to, onChange: (event) => setTemplateTest({ ...templateTest, to: event.target.value }) }),
5201
- /* @__PURE__ */ jsx31(Textarea3, { "aria-label": "Vari\xE1veis do teste", value: templateTest.variables, onChange: (event) => setTemplateTest({ ...templateTest, variables: event.target.value }) }),
5202
- /* @__PURE__ */ jsx31(Button16, { alignSelf: "start", loading: testTemplate.isPending, onClick: () => {
5203
- try {
5204
- JSON.parse(templateTest.variables);
5205
- testTemplate.mutate();
5206
- } catch {
5207
- setError("JSON de vari\xE1veis inv\xE1lido.");
5565
+ /* @__PURE__ */ jsx31(
5566
+ Button16,
5567
+ {
5568
+ variant: "outline",
5569
+ loading: testConfiguration.isPending,
5570
+ disabled: !config?.credentialConfigured,
5571
+ onClick: () => testConfiguration.mutate(),
5572
+ children: "Enviar novo teste"
5208
5573
  }
5209
- }, children: "Enfileirar teste" })
5574
+ )
5575
+ ] }),
5576
+ /* @__PURE__ */ jsxs23(Text23, { mt: 3, fontSize: "xs", color: "gray.600", children: [
5577
+ "\xDAltimo teste: ",
5578
+ prettyDate(config?.lastTestAt),
5579
+ config?.lastError ? " \xB7 " + config.lastError : ""
5210
5580
  ] })
5211
5581
  ] })
5212
5582
  ] }) : null,
5213
- tab === "dispatches" ? /* @__PURE__ */ jsx31(Stack9, { gap: 3, children: dispatches.data?.map((item) => /* @__PURE__ */ jsx31(Box22, { borderWidth: "1px", borderRadius: "lg", p: 4, children: /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", gap: 3, align: "start", children: [
5214
- /* @__PURE__ */ jsxs23(Box22, { children: [
5215
- /* @__PURE__ */ jsx31(Text23, { fontWeight: "semibold", children: item.templateCode }),
5216
- /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.600", children: [
5217
- item.correlationId,
5218
- " \xB7 ",
5219
- item.attempts,
5220
- " tentativa(s)"
5583
+ tab === "templates" ? /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "lg", p: { base: 4, md: 5 }, children: [
5584
+ /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", align: "start", gap: 3, wrap: "wrap", mb: 4, children: [
5585
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5586
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Templates e vers\xF5es" }),
5587
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "Consulte o hist\xF3rico e abra o gerenciamento completo sem sair da lista." })
5221
5588
  ] }),
5222
- item.lastError?.message ? /* @__PURE__ */ jsxs23(Text23, { color: "red.600", fontSize: "sm", children: [
5223
- item.lastError.code,
5224
- ": ",
5225
- item.lastError.message
5226
- ] }) : null
5589
+ /* @__PURE__ */ jsx31(Button16, { size: "sm", variant: "outline", onClick: openNewTemplate, children: "Novo template" })
5227
5590
  ] }),
5228
- /* @__PURE__ */ jsxs23(Stack9, { align: "end", children: [
5229
- /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(item.status), children: item.status }),
5230
- item.status === "dead_letter" ? /* @__PURE__ */ jsx31(Button16, { size: "xs", loading: retry.isPending, onClick: () => retry.mutate(item._id), children: "Reprocessar" }) : null
5591
+ /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5592
+ groupedTemplates.map(([code, versions]) => {
5593
+ const activeVersion = versions.find((item) => item.status === "active");
5594
+ return /* @__PURE__ */ jsxs23(Box22, { borderWidth: "1px", borderRadius: "md", overflow: "hidden", children: [
5595
+ /* @__PURE__ */ jsxs23(
5596
+ Flex15,
5597
+ {
5598
+ px: 4,
5599
+ py: 3,
5600
+ bg: "gray.50",
5601
+ justify: "space-between",
5602
+ align: "center",
5603
+ gap: 3,
5604
+ wrap: "wrap",
5605
+ children: [
5606
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5607
+ /* @__PURE__ */ jsx31(Text23, { fontWeight: "bold", children: versions[0]?.name || code }),
5608
+ /* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.600", children: [
5609
+ code,
5610
+ " \xB7 ",
5611
+ versions.length,
5612
+ " vers\xE3o(\xF5es)"
5613
+ ] })
5614
+ ] }),
5615
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, align: "center", wrap: "wrap", children: [
5616
+ activeVersion ? /* @__PURE__ */ jsxs23(Badge5, { colorPalette: "green", children: [
5617
+ "ativa v",
5618
+ activeVersion.version
5619
+ ] }) : /* @__PURE__ */ jsx31(Badge5, { colorPalette: "yellow", children: "sem vers\xE3o ativa" }),
5620
+ /* @__PURE__ */ jsx31(Button16, { size: "sm", onClick: () => manageTemplate(code), children: "Gerenciar" })
5621
+ ] })
5622
+ ]
5623
+ }
5624
+ ),
5625
+ /* @__PURE__ */ jsx31(Stack9, { gap: 0, children: versions.map((item) => /* @__PURE__ */ jsxs23(
5626
+ Flex15,
5627
+ {
5628
+ px: 4,
5629
+ py: 3,
5630
+ borderTopWidth: "1px",
5631
+ justify: "space-between",
5632
+ align: "center",
5633
+ gap: 3,
5634
+ wrap: "wrap",
5635
+ children: [
5636
+ /* @__PURE__ */ jsxs23(Box22, { minW: "220px", flex: "1", children: [
5637
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, align: "center", wrap: "wrap", children: [
5638
+ /* @__PURE__ */ jsxs23(Text23, { fontWeight: "semibold", children: [
5639
+ "Vers\xE3o ",
5640
+ item.version
5641
+ ] }),
5642
+ /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(item.status), children: item.status }),
5643
+ /* @__PURE__ */ jsx31(Badge5, { variant: "outline", children: item.origin })
5644
+ ] }),
5645
+ /* @__PURE__ */ jsx31(Text23, { mt: 1, fontSize: "sm", color: "gray.700", children: item.subject }),
5646
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.500", children: prettyDate(item.createdAt) })
5647
+ ] }),
5648
+ /* @__PURE__ */ jsx31(Button16, { size: "xs", variant: "outline", onClick: () => selectPreview(item), children: "Abrir vers\xE3o" })
5649
+ ]
5650
+ },
5651
+ item._id
5652
+ )) })
5653
+ ] }, code);
5654
+ }),
5655
+ !templates.isLoading && !templates.data?.length ? /* @__PURE__ */ jsx31(Text23, { children: "Nenhum template declarado." }) : null
5231
5656
  ] })
5232
- ] }) }, item._id)) }) : null
5657
+ ] }) : null,
5658
+ templateModalOpen ? /* @__PURE__ */ jsx31(
5659
+ Flex15,
5660
+ {
5661
+ position: "fixed",
5662
+ inset: 0,
5663
+ zIndex: 1200,
5664
+ align: "center",
5665
+ justify: "center",
5666
+ p: { base: 2, md: 4 },
5667
+ bg: "rgba(15,23,42,.55)",
5668
+ children: /* @__PURE__ */ jsxs23(
5669
+ Box22,
5670
+ {
5671
+ role: "dialog",
5672
+ "aria-modal": "true",
5673
+ "aria-labelledby": "transactional-template-modal-title",
5674
+ display: "flex",
5675
+ flexDirection: "column",
5676
+ w: "min(1180px, 96vw)",
5677
+ h: "min(900px, 92vh)",
5678
+ maxH: "92vh",
5679
+ overflow: "hidden",
5680
+ bg: "white",
5681
+ borderRadius: "14px",
5682
+ boxShadow: "0 24px 70px rgba(15,23,42,.28)",
5683
+ children: [
5684
+ /* @__PURE__ */ jsxs23(
5685
+ Flex15,
5686
+ {
5687
+ minH: "72px",
5688
+ px: { base: 4, md: 5 },
5689
+ py: 3,
5690
+ align: "center",
5691
+ justify: "space-between",
5692
+ gap: 4,
5693
+ borderBottomWidth: "1px",
5694
+ borderColor: "gray.200",
5695
+ children: [
5696
+ /* @__PURE__ */ jsxs23(Box22, { minW: 0, children: [
5697
+ /* @__PURE__ */ jsx31(Text23, { color: "#0474AF", fontSize: "10px", fontWeight: "700", textTransform: "uppercase", children: "Template transacional" }),
5698
+ /* @__PURE__ */ jsx31(Heading13, { id: "transactional-template-modal-title", size: "md", lineClamp: 1, children: !managedTemplateCode ? "Novo template" : editingBase ? "Nova vers\xE3o de " + editingBase.name : managedTemplate?.name || managedTemplateCode }),
5699
+ managedTemplateCode ? /* @__PURE__ */ jsxs23(Text23, { fontSize: "xs", color: "gray.600", children: [
5700
+ managedTemplateCode,
5701
+ editingBase ? " \xB7 base v" + editingBase.version : ""
5702
+ ] }) : null
5703
+ ] }),
5704
+ /* @__PURE__ */ jsx31(
5705
+ IconButton3,
5706
+ {
5707
+ "aria-label": "Fechar gerenciamento do template",
5708
+ title: "Fechar",
5709
+ size: "sm",
5710
+ minW: "32px",
5711
+ h: "32px",
5712
+ borderRadius: "full",
5713
+ variant: "ghost",
5714
+ fontSize: "21px",
5715
+ onClick: closeTemplateModal,
5716
+ children: "\xD7"
5717
+ }
5718
+ )
5719
+ ]
5720
+ }
5721
+ ),
5722
+ /* @__PURE__ */ jsx31(
5723
+ Flex15,
5724
+ {
5725
+ flex: "0 0 auto",
5726
+ gap: 2,
5727
+ px: { base: 3, md: 5 },
5728
+ pt: 3,
5729
+ borderBottomWidth: "1px",
5730
+ borderColor: "gray.200",
5731
+ overflowX: "auto",
5732
+ children: [
5733
+ ["versions", "Vers\xF5es"],
5734
+ ["content", "Conte\xFAdo"],
5735
+ ["variables", "Vari\xE1veis"],
5736
+ ["preview", "Pr\xE9via"],
5737
+ ["test", "Teste"]
5738
+ ].map(([id, label]) => /* @__PURE__ */ jsx31(
5739
+ Button16,
5740
+ {
5741
+ type: "button",
5742
+ size: "sm",
5743
+ flex: "0 0 auto",
5744
+ variant: templateModalTab === id ? "solid" : "ghost",
5745
+ disabled: id === "versions" && !managedTemplateCode,
5746
+ onClick: () => {
5747
+ setTemplateModalTab(id);
5748
+ setError("");
5749
+ },
5750
+ children: label
5751
+ },
5752
+ id
5753
+ ))
5754
+ }
5755
+ ),
5756
+ /* @__PURE__ */ jsxs23(Box22, { flex: "1", minH: 0, overflowY: "auto", p: { base: 4, md: 5 }, children: [
5757
+ error ? /* @__PURE__ */ jsx31(Box22, { role: "alert", mb: 4, borderWidth: "1px", borderColor: "red.200", bg: "red.50", p: 3, borderRadius: "md", children: /* @__PURE__ */ jsx31(Text23, { color: "red.700", children: error }) }) : null,
5758
+ notice ? /* @__PURE__ */ jsx31(Box22, { role: "status", mb: 4, borderWidth: "1px", borderColor: "green.200", bg: "green.50", p: 3, borderRadius: "md", children: /* @__PURE__ */ jsx31(Text23, { color: "green.800", children: notice }) }) : null,
5759
+ templateModalTab === "versions" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5760
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5761
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Hist\xF3rico de vers\xF5es" }),
5762
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "Escolha a vers\xE3o que deseja revisar, testar ou usar como base." })
5763
+ ] }),
5764
+ managedVersions.map((item) => /* @__PURE__ */ jsx31(Box22, { borderWidth: "1px", borderRadius: "md", p: 4, children: /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", align: "start", gap: 3, wrap: "wrap", children: [
5765
+ /* @__PURE__ */ jsxs23(Box22, { flex: "1", minW: "220px", children: [
5766
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, align: "center", wrap: "wrap", children: [
5767
+ /* @__PURE__ */ jsxs23(Text23, { fontWeight: "bold", children: [
5768
+ "Vers\xE3o ",
5769
+ item.version
5770
+ ] }),
5771
+ /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(item.status), children: item.status }),
5772
+ /* @__PURE__ */ jsx31(Badge5, { variant: "outline", children: item.origin })
5773
+ ] }),
5774
+ /* @__PURE__ */ jsx31(Text23, { mt: 2, fontSize: "sm", children: item.subject }),
5775
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.500", children: prettyDate(item.createdAt) })
5776
+ ] }),
5777
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, wrap: "wrap", children: [
5778
+ /* @__PURE__ */ jsx31(Button16, { size: "xs", variant: "outline", onClick: () => selectPreview(item), children: "Visualizar" }),
5779
+ /* @__PURE__ */ jsx31(Button16, { size: "xs", variant: "outline", onClick: () => useAsBase(item), children: "Editar como nova" }),
5780
+ /* @__PURE__ */ jsx31(Button16, { size: "xs", variant: "outline", onClick: () => selectTest(item), children: "Enviar teste" }),
5781
+ item.status !== "active" ? /* @__PURE__ */ jsx31(
5782
+ Button16,
5783
+ {
5784
+ size: "xs",
5785
+ loading: activate.isPending,
5786
+ onClick: () => activateVersion(item),
5787
+ children: "Ativar vers\xE3o"
5788
+ }
5789
+ ) : null
5790
+ ] })
5791
+ ] }) }, item._id))
5792
+ ] }) : null,
5793
+ templateModalTab === "content" ? draftContext ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5794
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5795
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: editingBase ? "Nova vers\xE3o a partir da v" + editingBase.version : "Conte\xFAdo do novo template" }),
5796
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "O salvamento cria um rascunho e nunca altera a vers\xE3o ativa." })
5797
+ ] }),
5798
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 3, wrap: "wrap", children: [
5799
+ /* @__PURE__ */ jsxs23(Box22, { flex: "1", minW: "180px", children: [
5800
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-code", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "C\xF3digo" }),
5801
+ /* @__PURE__ */ jsx31(
5802
+ Input10,
5803
+ {
5804
+ id: "template-code",
5805
+ mt: 1,
5806
+ disabled: Boolean(editingBase),
5807
+ value: templateDraft.code,
5808
+ onChange: (event) => setTemplateDraft({ ...templateDraft, code: event.target.value })
5809
+ }
5810
+ )
5811
+ ] }),
5812
+ /* @__PURE__ */ jsxs23(Box22, { flex: "2", minW: "220px", children: [
5813
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-name", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Nome" }),
5814
+ /* @__PURE__ */ jsx31(
5815
+ Input10,
5816
+ {
5817
+ id: "template-name",
5818
+ mt: 1,
5819
+ value: templateDraft.name,
5820
+ onChange: (event) => setTemplateDraft({ ...templateDraft, name: event.target.value })
5821
+ }
5822
+ )
5823
+ ] })
5824
+ ] }),
5825
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5826
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-subject", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Assunto Handlebars" }),
5827
+ /* @__PURE__ */ jsx31(
5828
+ Input10,
5829
+ {
5830
+ id: "template-subject",
5831
+ mt: 1,
5832
+ value: templateDraft.subject,
5833
+ onChange: (event) => setTemplateDraft({ ...templateDraft, subject: event.target.value })
5834
+ }
5835
+ )
5836
+ ] }),
5837
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5838
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-html", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "HTML" }),
5839
+ /* @__PURE__ */ jsx31(
5840
+ Textarea3,
5841
+ {
5842
+ id: "template-html",
5843
+ mt: 1,
5844
+ minH: "280px",
5845
+ fontFamily: "mono",
5846
+ value: templateDraft.htmlContent,
5847
+ onChange: (event) => setTemplateDraft({ ...templateDraft, htmlContent: event.target.value })
5848
+ }
5849
+ ),
5850
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.600", children: "Imagens data:image/*;base64 s\xE3o aceitas; URLs remotas continuam bloqueadas." })
5851
+ ] }),
5852
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5853
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-text", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Texto simples" }),
5854
+ /* @__PURE__ */ jsx31(
5855
+ Textarea3,
5856
+ {
5857
+ id: "template-text",
5858
+ mt: 1,
5859
+ minH: "140px",
5860
+ value: templateDraft.textContent,
5861
+ onChange: (event) => setTemplateDraft({ ...templateDraft, textContent: event.target.value })
5862
+ }
5863
+ )
5864
+ ] })
5865
+ ] }) : /* @__PURE__ */ jsxs23(Stack9, { gap: 4, align: "start", children: [
5866
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Escolha uma vers\xE3o como base" }),
5867
+ /* @__PURE__ */ jsx31(Text23, { color: "gray.600", children: "Para proteger o hist\xF3rico, uma vers\xE3o publicada n\xE3o \xE9 alterada diretamente." }),
5868
+ managedTemplate ? /* @__PURE__ */ jsx31(Button16, { onClick: () => useAsBase(managedTemplate), children: "Editar a vers\xE3o ativa como nova" }) : null
5869
+ ] }) : null,
5870
+ templateModalTab === "variables" ? draftContext ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5871
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5872
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Contrato de vari\xE1veis" }),
5873
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "Defina os campos aceitos pelo Handlebars. O teste e a pr\xE9via validar\xE3o este schema." })
5874
+ ] }),
5875
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5876
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-schema", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "JSON Schema" }),
5877
+ /* @__PURE__ */ jsx31(
5878
+ Textarea3,
5879
+ {
5880
+ id: "template-schema",
5881
+ mt: 1,
5882
+ minH: "420px",
5883
+ fontFamily: "mono",
5884
+ value: templateDraft.variablesSchema,
5885
+ onChange: (event) => setTemplateDraft({ ...templateDraft, variablesSchema: event.target.value })
5886
+ }
5887
+ )
5888
+ ] })
5889
+ ] }) : /* @__PURE__ */ jsxs23(Stack9, { gap: 4, align: "start", children: [
5890
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Schema da vers\xE3o selecionada" }),
5891
+ /* @__PURE__ */ jsx31(Text23, { color: "gray.600", children: "Use a vers\xE3o como base para editar o contrato de vari\xE1veis em um novo rascunho." }),
5892
+ managedTemplate ? /* @__PURE__ */ jsxs23(Fragment5, { children: [
5893
+ /* @__PURE__ */ jsx31(Box22, { as: "pre", w: "100%", minH: "280px", overflow: "auto", whiteSpace: "pre-wrap", borderWidth: "1px", borderRadius: "md", p: 4, fontSize: "sm", children: JSON.stringify(managedTemplate.variablesSchema || {}, null, 2) }),
5894
+ /* @__PURE__ */ jsx31(Button16, { variant: "outline", onClick: () => useAsBase(managedTemplate), children: "Editar como nova vers\xE3o" })
5895
+ ] }) : null
5896
+ ] }) : null,
5897
+ templateModalTab === "preview" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5898
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5899
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Pr\xE9-visualiza\xE7\xE3o" }),
5900
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: previewTarget ? previewTarget.code + " \xB7 vers\xE3o " + previewTarget.version : editingBase ? "Rascunho baseado na vers\xE3o " + editingBase.version : "Conte\xFAdo do novo template" })
5901
+ ] }),
5902
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5903
+ /* @__PURE__ */ jsx31("label", { htmlFor: "preview-variables", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Vari\xE1veis de exemplo" }),
5904
+ /* @__PURE__ */ jsx31(
5905
+ Textarea3,
5906
+ {
5907
+ id: "preview-variables",
5908
+ mt: 1,
5909
+ minH: "140px",
5910
+ fontFamily: "mono",
5911
+ value: previewVariables,
5912
+ onChange: (event) => setPreviewVariables(event.target.value)
5913
+ }
5914
+ )
5915
+ ] }),
5916
+ /* @__PURE__ */ jsx31(
5917
+ Button16,
5918
+ {
5919
+ alignSelf: "start",
5920
+ variant: "outline",
5921
+ loading: preview.isPending,
5922
+ disabled: !previewTarget && !templateDraft.code,
5923
+ onClick: previewTarget ? renderSavedPreview : renderDraftPreview,
5924
+ children: "Atualizar pr\xE9via"
5925
+ }
5926
+ ),
5927
+ preview.data ? /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
5928
+ /* @__PURE__ */ jsxs23(Box22, { bg: "gray.50", borderWidth: "1px", borderRadius: "md", p: 3, children: [
5929
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.600", children: "Assunto renderizado" }),
5930
+ /* @__PURE__ */ jsx31(Text23, { fontWeight: "semibold", children: preview.data.subject })
5931
+ ] }),
5932
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5933
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", fontWeight: "semibold", mb: 1, children: "HTML" }),
5934
+ /* @__PURE__ */ jsx31(
5935
+ "iframe",
5936
+ {
5937
+ title: "Pr\xE9-visualiza\xE7\xE3o segura do template",
5938
+ sandbox: "",
5939
+ srcDoc: preview.data.html,
5940
+ style: {
5941
+ width: "100%",
5942
+ minHeight: 420,
5943
+ border: "1px solid #E2E8F0",
5944
+ borderRadius: 8,
5945
+ background: "white"
5946
+ }
5947
+ }
5948
+ )
5949
+ ] }),
5950
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5951
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", fontWeight: "semibold", mb: 1, children: "Texto simples" }),
5952
+ /* @__PURE__ */ jsx31(Box22, { as: "pre", whiteSpace: "pre-wrap", borderWidth: "1px", borderRadius: "md", p: 3, fontSize: "sm", children: preview.data.text })
5953
+ ] })
5954
+ ] }) : /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "Informe vari\xE1veis v\xE1lidas e atualize a pr\xE9via." })
5955
+ ] }) : null,
5956
+ templateModalTab === "test" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 4, children: [
5957
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5958
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Envio de teste" }),
5959
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: testTarget ? testTarget.code + " \xB7 vers\xE3o " + testTarget.version + " \xB7 " + testTarget.status : "Selecione uma vers\xE3o salva antes de enviar o teste." })
5960
+ ] }),
5961
+ testTarget ? /* @__PURE__ */ jsxs23(Fragment5, { children: [
5962
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5963
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-test-recipient", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Destinat\xE1rio" }),
5964
+ /* @__PURE__ */ jsx31(
5965
+ Input10,
5966
+ {
5967
+ id: "template-test-recipient",
5968
+ type: "email",
5969
+ mt: 1,
5970
+ value: templateTest.to,
5971
+ onChange: (event) => setTemplateTest({ ...templateTest, to: event.target.value })
5972
+ }
5973
+ )
5974
+ ] }),
5975
+ /* @__PURE__ */ jsxs23(Box22, { children: [
5976
+ /* @__PURE__ */ jsx31("label", { htmlFor: "template-test-variables", style: { fontSize: "0.875rem", fontWeight: 600 }, children: "Vari\xE1veis" }),
5977
+ /* @__PURE__ */ jsx31(
5978
+ Textarea3,
5979
+ {
5980
+ id: "template-test-variables",
5981
+ mt: 1,
5982
+ minH: "260px",
5983
+ fontFamily: "mono",
5984
+ value: templateTest.variables,
5985
+ onChange: (event) => setTemplateTest({ ...templateTest, variables: event.target.value })
5986
+ }
5987
+ )
5988
+ ] }),
5989
+ /* @__PURE__ */ jsx31(
5990
+ Button16,
5991
+ {
5992
+ alignSelf: "start",
5993
+ loading: testTemplate.isPending,
5994
+ onClick: () => {
5995
+ try {
5996
+ parseObject(templateTest.variables, "JSON de vari\xE1veis inv\xE1lido.");
5997
+ testTemplate.mutate();
5998
+ } catch (reason) {
5999
+ setError(errorMessage(reason));
6000
+ }
6001
+ },
6002
+ children: "Enfileirar teste desta vers\xE3o"
6003
+ }
6004
+ )
6005
+ ] }) : null
6006
+ ] }) : null
6007
+ ] }),
6008
+ /* @__PURE__ */ jsxs23(
6009
+ Flex15,
6010
+ {
6011
+ flex: "0 0 auto",
6012
+ minH: "64px",
6013
+ px: { base: 4, md: 5 },
6014
+ py: 3,
6015
+ align: "center",
6016
+ justify: "space-between",
6017
+ gap: 3,
6018
+ borderTopWidth: "1px",
6019
+ borderColor: "gray.200",
6020
+ boxShadow: "0 -8px 24px rgba(15,23,42,.05)",
6021
+ children: [
6022
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "xs", color: "gray.600", children: "Nenhuma altera\xE7\xE3o \xE9 publicada automaticamente." }),
6023
+ /* @__PURE__ */ jsxs23(Flex15, { gap: 2, children: [
6024
+ /* @__PURE__ */ jsx31(Button16, { variant: "ghost", onClick: closeTemplateModal, children: "Fechar" }),
6025
+ draftContext && ["content", "variables"].includes(templateModalTab) ? /* @__PURE__ */ jsx31(
6026
+ Button16,
6027
+ {
6028
+ loading: createVersion.isPending,
6029
+ disabled: !templateDraft.code,
6030
+ onClick: () => {
6031
+ try {
6032
+ parseObject(templateDraft.variablesSchema, "JSON Schema inv\xE1lido.");
6033
+ createVersion.mutate();
6034
+ } catch (reason) {
6035
+ setError(errorMessage(reason));
6036
+ }
6037
+ },
6038
+ children: "Salvar nova vers\xE3o"
6039
+ }
6040
+ ) : null
6041
+ ] })
6042
+ ]
6043
+ }
6044
+ )
6045
+ ]
6046
+ }
6047
+ )
6048
+ }
6049
+ ) : null,
6050
+ tab === "dispatches" ? /* @__PURE__ */ jsxs23(Stack9, { gap: 3, children: [
6051
+ /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", align: "center", gap: 3, wrap: "wrap", children: [
6052
+ /* @__PURE__ */ jsxs23(Box22, { children: [
6053
+ /* @__PURE__ */ jsx31(Heading13, { size: "sm", children: "Envios recentes" }),
6054
+ /* @__PURE__ */ jsx31(Text23, { fontSize: "sm", color: "gray.600", children: "A lista \xE9 atualizada automaticamente a cada 10 segundos." })
6055
+ ] }),
6056
+ /* @__PURE__ */ jsx31(Button16, { size: "sm", variant: "outline", onClick: () => dispatches.refetch(), children: "Atualizar agora" })
6057
+ ] }),
6058
+ dispatches.data?.map((item) => /* @__PURE__ */ jsx31(Box22, { borderWidth: "1px", borderRadius: "lg", p: 4, children: /* @__PURE__ */ jsxs23(Flex15, { justify: "space-between", gap: 3, align: "start", wrap: "wrap", children: [
6059
+ /* @__PURE__ */ jsxs23(Box22, { children: [
6060
+ /* @__PURE__ */ jsxs23(Text23, { fontWeight: "semibold", children: [
6061
+ item.templateCode,
6062
+ item.templateVersion ? " \xB7 vers\xE3o " + item.templateVersion : ""
6063
+ ] }),
6064
+ /* @__PURE__ */ jsxs23(Text23, { fontSize: "sm", color: "gray.600", children: [
6065
+ item.correlationId,
6066
+ " \xB7 ",
6067
+ item.attempts,
6068
+ " tentativa(s) \xB7 ",
6069
+ prettyDate(item.createdAt)
6070
+ ] }),
6071
+ item.lastError?.message ? /* @__PURE__ */ jsxs23(Text23, { color: "red.600", fontSize: "sm", children: [
6072
+ item.lastError.code,
6073
+ ": ",
6074
+ item.lastError.message
6075
+ ] }) : null
6076
+ ] }),
6077
+ /* @__PURE__ */ jsxs23(Stack9, { align: "end", children: [
6078
+ /* @__PURE__ */ jsx31(Badge5, { colorPalette: color(item.status), children: item.status }),
6079
+ item.status === "dead_letter" ? /* @__PURE__ */ jsx31(Button16, { size: "xs", loading: retry.isPending, onClick: () => retry.mutate(item._id), children: "Reprocessar" }) : null
6080
+ ] })
6081
+ ] }) }, item._id)),
6082
+ !dispatches.isLoading && !dispatches.data?.length ? /* @__PURE__ */ jsx31(Text23, { children: "Nenhum envio recente." }) : null
6083
+ ] }) : null
5233
6084
  ] });
5234
6085
  }
5235
6086
 
@@ -5545,7 +6396,7 @@ function Sidebar({ app, menu, registry }) {
5545
6396
  // package.json
5546
6397
  var package_default = {
5547
6398
  name: "@oondemand/oon-core-front",
5548
- version: "0.4.28",
6399
+ version: "0.4.30",
5549
6400
  repository: {
5550
6401
  type: "git",
5551
6402
  url: "git+https://github.com/oondemand/oon-platform.git",
@@ -5970,7 +6821,7 @@ function AccessDeniedPage({ app }) {
5970
6821
 
5971
6822
  // src/security/AppAccessGuard.tsx
5972
6823
  import { Navigate, useLocation as useLocation3 } from "react-router-dom";
5973
- import { Fragment as Fragment5, jsx as jsx37 } from "react/jsx-runtime";
6824
+ import { Fragment as Fragment6, jsx as jsx37 } from "react/jsx-runtime";
5974
6825
  function loginRedirect(pathname, search) {
5975
6826
  const destination = `${pathname}${search}`;
5976
6827
  return `/login?redirect=${encodeURIComponent(destination)}`;
@@ -5996,7 +6847,7 @@ function AppAccessGuard({ children }) {
5996
6847
  }
5997
6848
  );
5998
6849
  }
5999
- return /* @__PURE__ */ jsx37(Fragment5, { children });
6850
+ return /* @__PURE__ */ jsx37(Fragment6, { children });
6000
6851
  }
6001
6852
 
6002
6853
  // src/security/LoginPage.tsx
@@ -6178,9 +7029,9 @@ function FirstAccessPage() {
6178
7029
  }
6179
7030
 
6180
7031
  // src/security/ActivationPage.tsx
6181
- import { useEffect as useEffect11, useState as useState22 } from "react";
7032
+ import { useEffect as useEffect12, useState as useState22 } from "react";
6182
7033
  import { Box as Box28, Button as Button21, Heading as Heading17, Input as Input13, Text as Text29, VStack as VStack7 } from "@chakra-ui/react";
6183
- import { Fragment as Fragment6, jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
7034
+ import { Fragment as Fragment7, jsx as jsx40, jsxs as jsxs29 } from "react/jsx-runtime";
6184
7035
  function encodeBasicCredentials2(email, password) {
6185
7036
  const bytes = new TextEncoder().encode(`${email}:${password}`);
6186
7037
  let binary = "";
@@ -6205,7 +7056,7 @@ function ActivationPage() {
6205
7056
  const [devResult, setDevResult] = useState22(null);
6206
7057
  const [error, setError] = useState22(null);
6207
7058
  const [submitting, setSubmitting] = useState22(false);
6208
- useEffect11(() => {
7059
+ useEffect12(() => {
6209
7060
  http.get("/ativacao/configuracao").then((response) => {
6210
7061
  setConfig(response.data);
6211
7062
  setGlobal(response.data.defaults || {});
@@ -6213,7 +7064,7 @@ function ActivationPage() {
6213
7064
  () => setError("N\xE3o foi poss\xEDvel carregar a configura\xE7\xE3o de ativa\xE7\xE3o.")
6214
7065
  );
6215
7066
  }, [http]);
6216
- useEffect11(() => {
7067
+ useEffect12(() => {
6217
7068
  if (activation.status === "active") {
6218
7069
  window.location.replace("/login");
6219
7070
  }
@@ -6335,7 +7186,7 @@ function ActivationPage() {
6335
7186
  ] }, field.name);
6336
7187
  }
6337
7188
  function renderDevLocalActivation() {
6338
- return /* @__PURE__ */ jsxs29(Fragment6, { children: [
7189
+ return /* @__PURE__ */ jsxs29(Fragment7, { children: [
6339
7190
  /* @__PURE__ */ jsx40(Text29, { color: "gray.700", children: "Entre com seu e-mail e senha para ativar esta Central em ambiente de desenvolvimento. Se o e-mail ainda n\xE3o existir na Central de Ativa\xE7\xF5es, o usu\xE1rio ser\xE1 criado automaticamente com perfil de desenvolvedor." }),
6340
7191
  /* @__PURE__ */ jsxs29(Box28, { w: "100%", children: [
6341
7192
  /* @__PURE__ */ jsx40(Text29, { fontWeight: "medium", children: "Nome do usu\xE1rio" }),
@@ -6439,7 +7290,7 @@ function ActivationPage() {
6439
7290
  config.technical.ambiente
6440
7291
  ] }),
6441
7292
  error ? /* @__PURE__ */ jsx40(Text29, { color: "red.600", children: error }) : null,
6442
- step !== 6 ? /* @__PURE__ */ jsxs29(Fragment6, { children: [
7293
+ step !== 6 ? /* @__PURE__ */ jsxs29(Fragment7, { children: [
6443
7294
  /* @__PURE__ */ jsxs29(Box28, { w: "100%", children: [
6444
7295
  /* @__PURE__ */ jsx40(Text29, { fontWeight: "medium", children: "E-mail do administrador *" }),
6445
7296
  /* @__PURE__ */ jsx40(
@@ -6477,7 +7328,7 @@ function ActivationPage() {
6477
7328
  children: "Criar ecossistema e ativar"
6478
7329
  }
6479
7330
  )
6480
- ] }) : /* @__PURE__ */ jsxs29(Fragment6, { children: [
7331
+ ] }) : /* @__PURE__ */ jsxs29(Fragment7, { children: [
6481
7332
  /* @__PURE__ */ jsx40(Heading17, { size: "md", children: "Ativa\xE7\xE3o conclu\xEDda" }),
6482
7333
  /* @__PURE__ */ jsx40(Text29, { children: "Usu\xE1rio, acesso do sistema e aplicativo root foram preparados. Redirecionando para o primeiro login..." })
6483
7334
  ] })
@@ -6509,7 +7360,7 @@ function ActivationPage() {
6509
7360
  ] }),
6510
7361
  error ? /* @__PURE__ */ jsx40(Text29, { color: "red.600", children: error }) : null,
6511
7362
  step === 1 && isDevelopmentMember && !showCodeFlow ? renderDevLocalActivation() : null,
6512
- step === 1 && (!isDevelopmentMember || showCodeFlow) && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7363
+ step === 1 && (!isDevelopmentMember || showCodeFlow) && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6513
7364
  /* @__PURE__ */ jsx40(Text29, { children: "Informe o c\xF3digo de ativa\xE7\xE3o para validar Tenant, App, Entitlement e Deployment. A licen\xE7a ser\xE1 validada somente para Apps comerciais." }),
6514
7365
  /* @__PURE__ */ jsx40(
6515
7366
  Input13,
@@ -6539,22 +7390,22 @@ function ActivationPage() {
6539
7390
  }
6540
7391
  ) : null
6541
7392
  ] }),
6542
- step === 2 && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7393
+ step === 2 && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6543
7394
  /* @__PURE__ */ jsx40(Heading17, { size: "md", children: "Confirma\xE7\xE3o" }),
6544
7395
  /* @__PURE__ */ jsx40("pre", { children: JSON.stringify(preview, null, 2) }),
6545
7396
  /* @__PURE__ */ jsx40(Button21, { onClick: () => setStep(3), children: "Continuar" })
6546
7397
  ] }),
6547
- step === 3 && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7398
+ step === 3 && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6548
7399
  config.globalFields.map(
6549
7400
  (field) => renderField(field, global, setGlobal)
6550
7401
  ),
6551
7402
  /* @__PURE__ */ jsx40(Button21, { onClick: () => setStep(4), children: "Continuar" })
6552
7403
  ] }),
6553
- step === 4 && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7404
+ step === 4 && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6554
7405
  config.appFields.length ? config.appFields.map((field) => renderField(field, app, setApp)) : /* @__PURE__ */ jsx40(Text29, { children: "Nenhum par\xE2metro adicional declarado." }),
6555
7406
  /* @__PURE__ */ jsx40(Button21, { onClick: () => setStep(5), children: "Revisar" })
6556
7407
  ] }),
6557
- step === 5 && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7408
+ step === 5 && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6558
7409
  /* @__PURE__ */ jsx40(Text29, { children: "Ao confirmar, o c\xF3digo ser\xE1 consumido e este runtime ser\xE1 vinculado ao Deployment do Ecossistema Oon." }),
6559
7410
  /* @__PURE__ */ jsx40(
6560
7411
  Button21,
@@ -6567,7 +7418,7 @@ function ActivationPage() {
6567
7418
  }
6568
7419
  )
6569
7420
  ] }),
6570
- step === 6 && /* @__PURE__ */ jsxs29(Fragment6, { children: [
7421
+ step === 6 && /* @__PURE__ */ jsxs29(Fragment7, { children: [
6571
7422
  /* @__PURE__ */ jsx40(Heading17, { size: "md", children: "Ativa\xE7\xE3o conclu\xEDda" }),
6572
7423
  devResult?.appCode ? /* @__PURE__ */ jsxs29(Text29, { children: [
6573
7424
  "C\xF3digo do app: ",
@@ -6591,7 +7442,7 @@ function InstanceBlockedPage({
6591
7442
  }
6592
7443
 
6593
7444
  // src/security/RouteGuard.tsx
6594
- import { Fragment as Fragment7, jsx as jsx41 } from "react/jsx-runtime";
7445
+ import { Fragment as Fragment8, jsx as jsx41 } from "react/jsx-runtime";
6595
7446
  function RouteGuard({
6596
7447
  permission,
6597
7448
  children
@@ -6602,7 +7453,7 @@ function RouteGuard({
6602
7453
  if (!hasPermission(permission)) {
6603
7454
  return /* @__PURE__ */ jsx41(LoadingScreen, { message: "Voc\xEA n\xE3o tem acesso a esta tela." });
6604
7455
  }
6605
- return /* @__PURE__ */ jsx41(Fragment7, { children });
7456
+ return /* @__PURE__ */ jsx41(Fragment8, { children });
6606
7457
  }
6607
7458
 
6608
7459
  // src/security/ActivationGuard.tsx
@@ -6687,7 +7538,7 @@ function localLoginUrl() {
6687
7538
  return `/login?redirect=${encodeURIComponent(current)}`;
6688
7539
  }
6689
7540
  function OonApp({ config }) {
6690
- const { http, storage, tenantStorage, router } = useMemo11(() => {
7541
+ const { http, storage, tenantStorage, router } = useMemo12(() => {
6691
7542
  const storage2 = createTokenStorage(config.app.id);
6692
7543
  const tenantStorage2 = createTenantStorage(config.app.id);
6693
7544
  const externalLoginUrl = config.auth?.loginUrl ?? config.api.meusAppsUrl;
@@ -6977,7 +7828,7 @@ function startFromManifest(manifest, runtime) {
6977
7828
  import { Stack as Stack16 } from "@chakra-ui/react";
6978
7829
 
6979
7830
  // src/components/CoreIntegration.tsx
6980
- import { useEffect as useEffect12, useState as useState23 } from "react";
7831
+ import { useEffect as useEffect13, useState as useState23 } from "react";
6981
7832
  import { Badge as Badge6, Box as Box29, Button as Button22, Flex as Flex21, Heading as Heading18, Input as Input14, Stack as Stack11, Text as Text30 } from "@chakra-ui/react";
6982
7833
  import { useMutation as useMutation6, useQuery as useQuery12 } from "@tanstack/react-query";
6983
7834
  import { jsx as jsx46, jsxs as jsxs30 } from "react/jsx-runtime";
@@ -7161,7 +8012,7 @@ function ProviderConfigurationPanel({ provider }) {
7161
8012
  queryFn: async () => (await http.get(`/integrations/providers/${provider.key}/mappings`)).data
7162
8013
  });
7163
8014
  const selected = (configuration.data ?? []).find((item) => item.instanceId === draft.instanceId);
7164
- useEffect12(() => {
8015
+ useEffect13(() => {
7165
8016
  if (!selected) return;
7166
8017
  setDraft((current) => ({
7167
8018
  ...current,
@@ -7628,7 +8479,7 @@ function CoreIntegrationMappings() {
7628
8479
  }
7629
8480
 
7630
8481
  // src/components/CoreIntegrationTickets.tsx
7631
- import { useEffect as useEffect13, useMemo as useMemo12, useState as useState24 } from "react";
8482
+ import { useEffect as useEffect14, useMemo as useMemo13, useState as useState24 } from "react";
7632
8483
  import { Badge as Badge8, Box as Box31, Button as Button23, Flex as Flex23, Heading as Heading20, Input as Input15, Stack as Stack13, Text as Text32 } from "@chakra-ui/react";
7633
8484
  import { useMutation as useMutation7, useQuery as useQuery14 } from "@tanstack/react-query";
7634
8485
  import { jsx as jsx48, jsxs as jsxs32 } from "react/jsx-runtime";
@@ -7861,7 +8712,7 @@ function CoreIntegrationTickets({ provider = "omie" }) {
7861
8712
  const [page, setPage] = useState24(1);
7862
8713
  const [expandedId, setExpandedId] = useState24(null);
7863
8714
  const limit = view === "board" ? 200 : 25;
7864
- useEffect13(() => {
8715
+ useEffect14(() => {
7865
8716
  const timeout = window.setTimeout(() => {
7866
8717
  setSearch(searchInput.trim());
7867
8718
  setPage(1);
@@ -7904,12 +8755,12 @@ function CoreIntegrationTickets({ provider = "omie" }) {
7904
8755
  await queue.refetch();
7905
8756
  }
7906
8757
  });
7907
- useEffect13(() => {
8758
+ useEffect14(() => {
7908
8759
  const totalPages2 = queue.data?.pagination?.totalPages ?? 1;
7909
8760
  if (page > totalPages2) setPage(Math.max(1, totalPages2));
7910
8761
  }, [page, queue.data?.pagination?.totalPages]);
7911
8762
  const tickets = queue.data?.results ?? [];
7912
- const grouped = useMemo12(() => Object.fromEntries(
8763
+ const grouped = useMemo13(() => Object.fromEntries(
7913
8764
  TICKET_STATUSES.map((ticketStatus) => [ticketStatus, tickets.filter((ticket) => ticket.status === ticketStatus)])
7914
8765
  ), [tickets]);
7915
8766
  if (queue.isLoading) return /* @__PURE__ */ jsx48(LoadingScreen, {});
@@ -8124,7 +8975,7 @@ import { useState as useState26 } from "react";
8124
8975
  import { Button as Button25, Flex as Flex25, Stack as Stack15 } from "@chakra-ui/react";
8125
8976
 
8126
8977
  // src/components/CoreOmieIntegration.tsx
8127
- import { useEffect as useEffect14, useState as useState25 } from "react";
8978
+ import { useEffect as useEffect15, useState as useState25 } from "react";
8128
8979
  import { Badge as Badge9, Box as Box32, Button as Button24, Flex as Flex24, Heading as Heading21, Input as Input16, Stack as Stack14, Text as Text33 } from "@chakra-ui/react";
8129
8980
  import { useMutation as useMutation8, useQuery as useQuery15 } from "@tanstack/react-query";
8130
8981
  import { jsx as jsx49, jsxs as jsxs33 } from "react/jsx-runtime";
@@ -8206,7 +9057,7 @@ function OmieConfigurationTab() {
8206
9057
  appSecret: ""
8207
9058
  });
8208
9059
  const selected = (configuration.data ?? []).find((item) => item.instanceId === draft.instanceId) ?? configuration.data?.[0];
8209
- useEffect14(() => {
9060
+ useEffect15(() => {
8210
9061
  if (!selected) return;
8211
9062
  setDraft((current) => ({
8212
9063
  ...current,
@@ -8547,7 +9398,7 @@ function OmieWebhooksTab() {
8547
9398
  await Promise.all([access.refetch(), configuration.refetch()]);
8548
9399
  }
8549
9400
  });
8550
- useEffect14(() => {
9401
+ useEffect15(() => {
8551
9402
  const first = configuration.data?.[0]?.instanceId;
8552
9403
  if (first && !configuration.data?.some((item) => item.instanceId === instanceId)) setInstanceId(first);
8553
9404
  }, [configuration.data, instanceId]);