@asteby/metacore-runtime-react 53.4.0 → 53.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +73 -0
  3. package/dist/display-value.d.ts +11 -0
  4. package/dist/display-value.d.ts.map +1 -1
  5. package/dist/display-value.js +26 -1
  6. package/dist/dynamic-columns.d.ts.map +1 -1
  7. package/dist/dynamic-columns.js +17 -6
  8. package/dist/index.d.ts +2 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +4 -0
  11. package/dist/setup/addon-config-surface.d.ts +110 -0
  12. package/dist/setup/addon-config-surface.d.ts.map +1 -0
  13. package/dist/setup/addon-config-surface.js +553 -0
  14. package/dist/setup/connector-form-model.d.ts +40 -0
  15. package/dist/setup/connector-form-model.d.ts.map +1 -0
  16. package/dist/setup/connector-form-model.js +76 -0
  17. package/dist/setup/flow-model.d.ts +49 -0
  18. package/dist/setup/flow-model.d.ts.map +1 -0
  19. package/dist/setup/flow-model.js +124 -0
  20. package/dist/setup/health-card.d.ts +25 -0
  21. package/dist/setup/health-card.d.ts.map +1 -0
  22. package/dist/setup/health-card.js +21 -0
  23. package/dist/setup/index.d.ts +11 -0
  24. package/dist/setup/index.d.ts.map +1 -0
  25. package/dist/setup/index.js +13 -0
  26. package/dist/setup/messages.d.ts +15 -0
  27. package/dist/setup/messages.d.ts.map +1 -0
  28. package/dist/setup/messages.js +249 -0
  29. package/dist/setup/records-table.d.ts +24 -0
  30. package/dist/setup/records-table.d.ts.map +1 -0
  31. package/dist/setup/records-table.js +80 -0
  32. package/dist/setup/setup-flow.d.ts +30 -0
  33. package/dist/setup/setup-flow.d.ts.map +1 -0
  34. package/dist/setup/setup-flow.js +277 -0
  35. package/dist/setup/setup-form-step.d.ts +20 -0
  36. package/dist/setup/setup-form-step.d.ts.map +1 -0
  37. package/dist/setup/setup-form-step.js +173 -0
  38. package/dist/setup/step-status-badge.d.ts +12 -0
  39. package/dist/setup/step-status-badge.d.ts.map +1 -0
  40. package/dist/setup/step-status-badge.js +21 -0
  41. package/dist/setup/tone.d.ts +8 -0
  42. package/dist/setup/tone.d.ts.map +1 -0
  43. package/dist/setup/tone.js +33 -0
  44. package/dist/setup/types.d.ts +130 -0
  45. package/dist/setup/types.d.ts.map +1 -0
  46. package/dist/setup/types.js +1 -0
  47. package/package.json +5 -1
  48. package/src/__tests__/addon-config-surface.test.tsx +248 -0
  49. package/src/__tests__/image-stack.test.tsx +58 -1
  50. package/src/__tests__/setup-components.test.tsx +147 -0
  51. package/src/__tests__/setup-flow-model.test.ts +117 -0
  52. package/src/__tests__/setup-flow.test.tsx +424 -0
  53. package/src/display-value.tsx +30 -1
  54. package/src/dynamic-columns.tsx +21 -5
  55. package/src/index.ts +25 -0
  56. package/src/setup/addon-config-surface.tsx +1262 -0
  57. package/src/setup/connector-form-model.ts +115 -0
  58. package/src/setup/flow-model.ts +156 -0
  59. package/src/setup/health-card.tsx +131 -0
  60. package/src/setup/index.ts +23 -0
  61. package/src/setup/messages.ts +263 -0
  62. package/src/setup/records-table.tsx +186 -0
  63. package/src/setup/setup-flow.tsx +562 -0
  64. package/src/setup/setup-form-step.tsx +342 -0
  65. package/src/setup/step-status-badge.tsx +47 -0
  66. package/src/setup/tone.ts +44 -0
  67. package/src/setup/types.ts +147 -0
@@ -0,0 +1,553 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // AddonConfigSurface — the unified "Configurar addon" dialog, moved from the
3
+ // ops host (installed-addons) into the SDK so every host renders the same
4
+ // surface. It combines:
5
+ // • Credenciales — the addon's connector credential form (secrets are
6
+ // write-only: never read back, empty = keep the stored one). Required
7
+ // fields up top, optional under "Avanzado"; or grouped by `form_layout`
8
+ // (sections / steps). Saved via POST /integrations/:provider.
9
+ // • Ajustes — the addon's settings_defs (GET/PUT /addons/:key/settings),
10
+ // with per-branch overrides, `visible_when` and `write_only`.
11
+ // • Probar conexión (connector.test_export) and Sincronizar ahora.
12
+ // Fixed header + footer; only the body scrolls (a connector can declare many
13
+ // fields). Everything host-specific is injected: the API client (ApiProvider
14
+ // or `client`), the admin gate (`canManageIssuer`), the active branch, the
15
+ // addon i18n bundle loader and the notifier.
16
+ import { createContext, useContext, useEffect, useId, useRef, useState } from 'react';
17
+ import { useMutation } from '@tanstack/react-query';
18
+ import { useTranslation } from 'react-i18next';
19
+ import { toast } from 'sonner';
20
+ import { Cable, Check, CheckCircle2, Loader2, Plug, RefreshCw, Settings, XCircle } from 'lucide-react';
21
+ import { Badge, Button, Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, Input, Label, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, } from '@asteby/metacore-ui/primitives';
22
+ import { cn } from '@asteby/metacore-ui/lib';
23
+ import { useApi } from '../api-context';
24
+ import { evaluateVisibleWhen, getVisibleWhen } from '../dynamic-form-schema';
25
+ import { useSetupT } from './messages';
26
+ import { isSecretCredential, missingRequired, parseSaveError, shapeMismatch, textOrFallback, } from './connector-form-model';
27
+ // Empty write_only value (typed then erased) must not overwrite the stored secret.
28
+ const isBlank = (v) => v == null || (typeof v === 'string' && v.trim() === '');
29
+ const NO_OPTION_KINDS = {};
30
+ // ─── Connector credential field (reusable render) ───────────────────────────
31
+ // One connector credential field: label (i18n) + control (select|password|text)
32
+ // + optional help. Shared by the unified config dialog for both the essential
33
+ // and the advanced groups so the select/secret/label/help logic lives in a
34
+ // single place (DRY).
35
+ // Humanize an i18n key's last segment as a graceful fallback so a missing addon
36
+ // translation never surfaces the raw dotted key (e.g.
37
+ // "fiscal_mexico.connector.section.connection" → "Connection").
38
+ const humanizeKey = (k) => (k?.split('.').pop() ?? '')
39
+ .replace(/[_-]+/g, ' ')
40
+ .replace(/\b\w/g, (m) => m.toUpperCase());
41
+ const ConnectorFormStateContext = createContext({
42
+ fields: [],
43
+ errors: {},
44
+ idPrefix: 'addon-config',
45
+ expectedOptionKinds: {},
46
+ });
47
+ function ConnectorCredentialFieldControl({ field, value, connected, provider, onChange, }) {
48
+ const { t } = useTranslation();
49
+ const st = useSetupT();
50
+ const form = useContext(ConnectorFormStateContext);
51
+ // label/description are i18n keys (addon locales are loaded into i18next);
52
+ // never surface a raw dotted key: fall back to the humanized field key.
53
+ const humanize = (k) => k.replace(/[_-]+/g, ' ').replace(/\b\w/g, (m) => m.toUpperCase());
54
+ const labelOf = (f) => f.label ? textOrFallback(t(f.label, { defaultValue: humanize(f.key) }), f.label, humanize(f.key)) : humanize(f.key);
55
+ const label = labelOf(field);
56
+ const help = field.description
57
+ ? textOrFallback(t(field.description, { defaultValue: '' }), field.description, '')
58
+ : '';
59
+ const isSecret = isSecretCredential(field);
60
+ const isDynamic = field.type === 'dynamic_select' || !!field.options_source;
61
+ const error = form.errors[field.key];
62
+ const mismatch = shapeMismatch(field, value, form.fields);
63
+ const target = mismatch?.suggestedKey
64
+ ? form.fields.find((f) => f.key === mismatch.suggestedKey)
65
+ : undefined;
66
+ const warning = mismatch
67
+ ? st(mismatch.shape === 'public_key'
68
+ ? 'installed_addons.shape_public_key'
69
+ : 'installed_addons.shape_secret_key', { target: target ? labelOf(target) : '' })
70
+ : '';
71
+ return (_jsxs("div", { className: 'flex flex-col gap-1', "data-field": field.key, children: [_jsxs(Label, { htmlFor: `${form.idPrefix}-cred-${field.key}`, children: [label, field.required ? _jsx("span", { className: 'text-destructive', children: " *" }) : null] }), isDynamic ? (_jsx(DynamicConnectorSelect, { field: field, value: value, provider: provider, connected: connected, onChange: onChange })) : field.type === 'select' && field.options?.length ? (_jsxs(Select, { value: value, onValueChange: onChange, children: [_jsx(SelectTrigger, { id: `${form.idPrefix}-cred-${field.key}`, "aria-invalid": !!error || undefined, children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: field.options.map((o) => (_jsx(SelectItem, { value: o.value, children: t(o.label, { defaultValue: o.value }) }, o.value))) })] })) : (_jsx(Input, { id: `${form.idPrefix}-cred-${field.key}`, type: isSecret ? 'password' : 'text',
72
+ // A secret must never be offered to (or filled by) the browser's
73
+ // password manager: "new-password" is the value browsers respect.
74
+ autoComplete: isSecret ? 'new-password' : 'off', "data-1p-ignore": isSecret ? true : undefined, "data-lpignore": isSecret ? 'true' : undefined, spellCheck: false, autoCapitalize: 'off', "aria-invalid": !!error || undefined, "aria-describedby": error ? `${form.idPrefix}-cred-${field.key}-error` : undefined, className: cn(error && 'border-destructive focus-visible:ring-destructive/40'), placeholder: connected && isSecret ? '••••••••' : '', value: value, onChange: (e) => onChange(e.target.value) })), error ? (_jsx("p", { id: `${form.idPrefix}-cred-${field.key}-error`, role: 'alert', className: 'text-xs text-destructive', children: error })) : null, warning ? (_jsx("p", { className: 'text-xs text-amber-600 dark:text-amber-400', role: 'status', children: warning })) : null, help ? _jsx("p", { className: 'text-xs text-muted-foreground', children: help }) : null] }));
75
+ }
76
+ // useApi() hands every component its own wrapper object, so the cache cannot be
77
+ // keyed by client: it is module-level, keyed by provider + export, and dropped
78
+ // whenever a config surface closes (a new org / credentials never reads stale).
79
+ const lookupCache = new Map();
80
+ /** Drops the shared option-lookup cache (called when the surface closes). */
81
+ export function clearConnectorLookupCache() {
82
+ lookupCache.clear();
83
+ }
84
+ function fetchLookupOptions(api, provider, field, force = false) {
85
+ const key = `${provider}:${field.options_source || field.key}`;
86
+ if (!force && lookupCache.has(key))
87
+ return lookupCache.get(key);
88
+ const p = api
89
+ .post(`/integrations/${provider}/lookup`, { credential: field.key })
90
+ .then((res) => (res.data?.data?.options ?? []))
91
+ .catch((err) => {
92
+ lookupCache.delete(key); // don't cache failures
93
+ throw err;
94
+ });
95
+ lookupCache.set(key, p);
96
+ return p;
97
+ }
98
+ // A dynamic_select connector credential: the option list is fetched from the
99
+ // host, which runs the addon's `options_source` WASM export org-scoped (it reads
100
+ // the org's SAVED credentials via connector_get, e.g. lists factura.com series).
101
+ // So options only resolve once the connector is configured+saved — until then we
102
+ // show a hint and a manual free-text fallback so the field is never a dead end.
103
+ function DynamicConnectorSelect({ field, value, provider, connected, onChange, }) {
104
+ const st = useSetupT();
105
+ const form = useContext(ConnectorFormStateContext);
106
+ const hostApi = useApi();
107
+ const api = form.client ?? hostApi;
108
+ const [options, setOptions] = useState([]);
109
+ const [state, setState] = useState('idle');
110
+ const [error, setError] = useState('');
111
+ const load = async (force = false) => {
112
+ setState('loading');
113
+ setError('');
114
+ try {
115
+ const opts = await fetchLookupOptions(api, provider, field, force);
116
+ setOptions(opts);
117
+ setState('done');
118
+ }
119
+ catch (err) {
120
+ setError(err.response?.data?.message ||
121
+ st('installed_addons.dynamic_select_error', {
122
+ defaultValue: 'No se pudieron listar las opciones. Guarda la conexión y vuelve a intentar.',
123
+ }));
124
+ setState('error');
125
+ }
126
+ };
127
+ // Auto-load once when the connector is already configured (editing an existing
128
+ // connection). Fresh configs load on demand via the refresh button.
129
+ useEffect(() => {
130
+ if (connected && state === 'idle')
131
+ void load();
132
+ // eslint-disable-next-line react-hooks/exhaustive-deps
133
+ }, [connected]);
134
+ // Scope the options to the kind (`tipo`) the host expects for this field,
135
+ // when the source reports one. The mapping is injected by the host
136
+ // (`expectedOptionKinds`); empty by default, so the SDK stays domain-agnostic.
137
+ const expected = form.expectedOptionKinds[field.key];
138
+ const filtered = expected && options.some((o) => o.tipo === expected)
139
+ ? options.filter((o) => o.tipo === expected)
140
+ : options;
141
+ return (_jsxs("div", { className: 'flex flex-col gap-1', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [filtered.length > 0 ? (_jsxs(Select, { value: value, onValueChange: onChange, children: [_jsx(SelectTrigger, { id: `${form.idPrefix}-cred-${field.key}`, className: 'flex-1', children: _jsx(SelectValue, { placeholder: st('installed_addons.dynamic_select_choose', {
142
+ defaultValue: 'Elige una opción',
143
+ }) }) }), _jsx(SelectContent, { children: filtered.map((o) => (_jsx(SelectItem, { value: o.value, children: o.label }, o.value))) })] })) : (_jsx(Input, { id: `${form.idPrefix}-cred-${field.key}`, value: value, placeholder: st('installed_addons.dynamic_select_placeholder', {
144
+ defaultValue: 'Guarda la conexión y actualiza para elegir',
145
+ }), onChange: (e) => onChange(e.target.value) })), _jsx(Button, { type: 'button', variant: 'outline', size: 'sm', onClick: () => void load(true), disabled: state === 'loading', title: st('installed_addons.dynamic_select_refresh', {
146
+ defaultValue: 'Actualizar opciones',
147
+ }), children: state === 'loading' ? (_jsx(Loader2, { className: 'h-4 w-4 animate-spin' })) : (_jsx(RefreshCw, { className: 'h-4 w-4' })) })] }), state === 'error' && _jsx("p", { className: 'text-xs text-destructive', children: error })] }));
148
+ }
149
+ // ─── Unified addon configuration dialog ─────────────────────────────────────
150
+ // One "Configuración del addon" surface per addon combining two sections:
151
+ // • Credenciales — the addon's `token` connector credential form. Essential
152
+ // (required) fields render up top; optional/advanced fields (base_url,
153
+ // stamp_path, …) collapse under an "Avanzado" <details>. Saved via
154
+ // POST /integrations/:provider (only non-empty values, so re-saving without
155
+ // retyping a stored secret doesn't wipe it).
156
+ // • Ajustes — the addon's settings_defs (GET/PUT /addons/:key/settings).
157
+ // Fixed header + footer, scrollable body — a connector can declare many fields
158
+ // (env, keys, RFC, régimen, CP, base_url, stamp/cancel path) that would
159
+ // otherwise overflow the viewport.
160
+ export function AddonConfigSurface({ addon, connector, open, onOpenChange, onSaved, canManageIssuer = true, activeBranch = null, ensureAddonBundle, notify = toast, client, expectedOptionKinds = NO_OPTION_KINDS, displayName, }) {
161
+ const idPrefix = useId();
162
+ const { t, i18n } = useTranslation();
163
+ const st = useSetupT();
164
+ const hostApi = useApi();
165
+ const api = client ?? hostApi;
166
+ const activeBranchId = activeBranch?.id ?? '';
167
+ useEffect(() => {
168
+ if (!open)
169
+ clearConnectorLookupCache();
170
+ }, [open]);
171
+ const credFields = connector?.credentials ?? [];
172
+ const requiredFields = credFields.filter((f) => f.required);
173
+ const advancedFields = credFields.filter((f) => !f.required);
174
+ // A connector with a form_layout groups its credentials into titled sections
175
+ // (a light wizard). Fall back to the required/advanced split when absent.
176
+ const layoutSections = connector?.form_layout?.sections ?? [];
177
+ const useLayout = layoutSections.length > 0 && credFields.some((f) => !!f.section);
178
+ // A form_layout with mode "steps" drives a real wizard (one section at a time
179
+ // with Atrás/Siguiente), instead of stacked cards.
180
+ const stepMode = useLayout && connector?.form_layout?.mode === 'steps';
181
+ const [credValues, setCredValues] = useState({});
182
+ const [settingsValues, setSettingsValues] = useState({});
183
+ const [definitions, setDefinitions] = useState([]);
184
+ const [loading, setLoading] = useState(false);
185
+ const [currentStep, setCurrentStep] = useState(0);
186
+ // Last failed save: the complete message (shown in full, not as a toast that
187
+ // cuts it) and the fields to highlight.
188
+ const [formError, setFormError] = useState(null);
189
+ const [fieldErrors, setFieldErrors] = useState({});
190
+ const errorRef = useRef(null);
191
+ const setCred = (key, val) => {
192
+ setCredValues((v) => ({ ...v, [key]: val }));
193
+ if (fieldErrors[key]) {
194
+ setFieldErrors((e) => {
195
+ const { [key]: _drop, ...rest } = e;
196
+ return rest;
197
+ });
198
+ }
199
+ };
200
+ // Per-branch settings (POS-1): a setting the manifest declares `scope: branch`
201
+ // can be overridden for the ACTIVE branch. `target` picks which level the form
202
+ // reads/writes; in "branch" mode only the branch-scoped settings show, only the
203
+ // ones the operator touched are saved (an untouched key keeps inheriting the org
204
+ // value) and «Heredar de la organización» clears an override.
205
+ const [target, setTarget] = useState('org');
206
+ const [overrides, setOverrides] = useState({});
207
+ const [touched, setTouched] = useState(new Set());
208
+ const [cleared, setCleared] = useState(new Set());
209
+ const hasBranchDefs = definitions.some((d) => d.scope === 'branch');
210
+ const canTargetBranch = !!activeBranch && hasBranchDefs;
211
+ const branchMode = target === 'branch' && canTargetBranch;
212
+ // `visible_when` (kernel Setting.visible_when) is evaluated against the live values.
213
+ const shownDefs = (branchMode ? definitions.filter((d) => d.scope === 'branch') : definitions).filter((d) => evaluateVisibleWhen(getVisibleWhen(d), settingsValues));
214
+ const setSetting = (key, value) => {
215
+ setSettingsValues((prev) => ({ ...prev, [key]: value }));
216
+ setTouched((prev) => new Set(prev).add(key));
217
+ setCleared((prev) => {
218
+ if (!prev.has(key))
219
+ return prev;
220
+ const next = new Set(prev);
221
+ next.delete(key);
222
+ return next;
223
+ });
224
+ };
225
+ // Seed connector defaults (e.g. environment = sandbox, first select option,
226
+ // or a value the backend prefilled from the org) so selects open on their
227
+ // default, then overlay the STORED non-secret values (GET …/values). Without
228
+ // the overlay a configured connector reopened empty, and re-saving sent the
229
+ // select defaults over what was stored (PIT-035: régimen reset to 601).
230
+ // Secrets are never returned; their inputs stay blank = "keep as is".
231
+ useEffect(() => {
232
+ if (!open)
233
+ return;
234
+ const seed = {};
235
+ for (const f of credFields) {
236
+ if (f.default != null && f.default !== '')
237
+ seed[f.key] = String(f.default);
238
+ else if (f.type === 'select' && f.options?.length)
239
+ seed[f.key] = f.options[0].value;
240
+ }
241
+ setCredValues(seed);
242
+ setCurrentStep(0);
243
+ setFormError(null);
244
+ setFieldErrors({});
245
+ if (!canManageIssuer || !connector?.provider || credFields.length === 0)
246
+ return;
247
+ let cancelled = false;
248
+ api
249
+ .get(`/integrations/${connector.provider}/values`)
250
+ .then((res) => {
251
+ const stored = (res.data?.data?.values ?? {});
252
+ if (cancelled)
253
+ return;
254
+ // Only fields the user has not touched yet.
255
+ setCredValues((prev) => {
256
+ const next = { ...prev };
257
+ for (const [k, v] of Object.entries(stored)) {
258
+ // Write-only: a secret is never prefilled, even if a host echoes it.
259
+ const def = credFields.find((f) => f.key === k);
260
+ if (def && isSecretCredential(def))
261
+ continue;
262
+ if (v !== '' && prev[k] === seed[k])
263
+ next[k] = v;
264
+ }
265
+ return next;
266
+ });
267
+ })
268
+ .catch(() => {
269
+ /* older backend or no stored config: keep the defaults */
270
+ });
271
+ return () => {
272
+ cancelled = true;
273
+ };
274
+ // eslint-disable-next-line react-hooks/exhaustive-deps
275
+ }, [open, connector?.provider, canManageIssuer]);
276
+ // Load stored settings values + definitions. The backend returns the
277
+ // manifest's setting definitions alongside the stored values; fall back to
278
+ // the manifest we already have so custom (declarative) addons whose lifecycle
279
+ // isn't registered still render.
280
+ useEffect(() => {
281
+ if (!open)
282
+ return;
283
+ setLoading(true);
284
+ setTouched(new Set());
285
+ setCleared(new Set());
286
+ const branchQuery = target === 'branch' && activeBranch ? `?branch_id=${encodeURIComponent(activeBranchId)}` : '';
287
+ api
288
+ .get(`/addons/${addon.addon_key}/settings${branchQuery}`)
289
+ .then((res) => {
290
+ setSettingsValues(res.data?.data || {});
291
+ setOverrides(res.data?.overrides || {});
292
+ const defs = res.data?.definitions?.length > 0
293
+ ? res.data.definitions
294
+ : (addon.manifest.settings_defs ?? []);
295
+ setDefinitions(defs);
296
+ })
297
+ .catch(() => {
298
+ setSettingsValues({});
299
+ setDefinitions(addon.manifest.settings_defs ?? []);
300
+ })
301
+ .finally(() => setLoading(false));
302
+ }, [open, addon.addon_key, target, activeBranchId]);
303
+ // The addon's texts can arrive after this dialog (installed a moment ago, or
304
+ // the org bundle still in flight): when its labels do not resolve yet, pull
305
+ // the addon's own bundle so the form never paints raw keys.
306
+ useEffect(() => {
307
+ if (!open || !connector || !ensureAddonBundle)
308
+ return;
309
+ const keys = [
310
+ ...credFields.flatMap((f) => [f.label, f.description]),
311
+ ...layoutSections.flatMap((sec) => [sec.title, sec.description]),
312
+ ].filter((k) => !!k);
313
+ if (keys.length === 0 || keys.every((k) => i18n.exists(k)))
314
+ return;
315
+ void ensureAddonBundle?.(connector.addon_key, i18n);
316
+ // eslint-disable-next-line react-hooks/exhaustive-deps
317
+ }, [open, connector?.addon_key, credFields.length]);
318
+ const credLabel = (f) => {
319
+ const fallback = humanizeKey(f.key);
320
+ return f.label ? textOrFallback(t(f.label, { defaultValue: fallback }), f.label, fallback) : fallback;
321
+ };
322
+ const saveMutation = useMutation({
323
+ mutationFn: async () => {
324
+ if (connector && canManageIssuer) {
325
+ // Only send non-empty values so re-saving without retyping a stored
326
+ // secret leaves it untouched (server merges).
327
+ const payload = {};
328
+ for (const [k, v] of Object.entries(credValues)) {
329
+ if (v != null && v !== '')
330
+ payload[k] = v;
331
+ }
332
+ await api.post(`/integrations/${connector.provider}`, payload);
333
+ }
334
+ if (branchMode) {
335
+ // Only what the operator touched: an untouched key keeps inheriting.
336
+ const payload = {};
337
+ for (const k of touched) {
338
+ const d = definitions.find((x) => x.key === k);
339
+ if (d?.write_only && isBlank(settingsValues[k]))
340
+ continue;
341
+ payload[k] = settingsValues[k];
342
+ }
343
+ for (const k of cleared)
344
+ payload[k] = null;
345
+ if (Object.keys(payload).length > 0) {
346
+ await api.put(`/addons/${addon.addon_key}/settings?branch_id=${encodeURIComponent(activeBranchId)}`, payload);
347
+ }
348
+ }
349
+ else if (definitions.length > 0) {
350
+ // write_only settings are never read back: send them only when typed.
351
+ const payload = { ...settingsValues };
352
+ for (const d of definitions) {
353
+ if (d.write_only && (!touched.has(d.key) || isBlank(payload[d.key])))
354
+ delete payload[d.key];
355
+ }
356
+ await api.put(`/addons/${addon.addon_key}/settings`, payload);
357
+ }
358
+ },
359
+ onSuccess: () => {
360
+ setFormError(null);
361
+ setFieldErrors({});
362
+ notify.success(st('installed_addons.config_saved'));
363
+ onOpenChange(false);
364
+ onSaved?.();
365
+ },
366
+ onError: (err) => {
367
+ const { message, fieldKeys } = parseSaveError(err, st('installed_addons.settings_error'));
368
+ const known = new Set(credFields.map((f) => f.key));
369
+ const errs = {};
370
+ for (const k of fieldKeys) {
371
+ const f = credFields.find((c) => c.key === k);
372
+ if (known.has(k) && f) {
373
+ errs[k] = st('installed_addons.field_required', {
374
+ defaultValue: 'Falta completar este campo.',
375
+ });
376
+ }
377
+ }
378
+ setFieldErrors(errs);
379
+ setFormError(message);
380
+ focusFirstInvalid(Object.keys(errs));
381
+ },
382
+ });
383
+ // Brings the first failed field into view and focuses it; in a stepper it
384
+ // also jumps to the step that holds it.
385
+ const focusFirstInvalid = (keys) => {
386
+ const first = keys[0];
387
+ if (!first) {
388
+ window.setTimeout(() => errorRef.current?.scrollIntoView({ block: 'nearest' }), 0);
389
+ return;
390
+ }
391
+ const sectionKey = credFields.find((f) => f.key === first)?.section;
392
+ if (sectionKey) {
393
+ const idx = layoutSections.findIndex((sec) => sec.key === sectionKey);
394
+ if (idx >= 0)
395
+ setCurrentStep(idx);
396
+ }
397
+ window.setTimeout(() => {
398
+ const el = document.getElementById(`${idPrefix}-cred-${first}`);
399
+ el?.closest('details')?.setAttribute('open', '');
400
+ el?.scrollIntoView({ block: 'center' });
401
+ el?.focus();
402
+ }, 50);
403
+ };
404
+ // Check what is certain before the round trip, so the operator sees WHICH
405
+ // field is missing instead of a generic failure.
406
+ const handleSave = () => {
407
+ setFormError(null);
408
+ if (connector && canManageIssuer) {
409
+ const miss = missingRequired(credFields, credValues, !!connector.connected);
410
+ if (miss.length > 0) {
411
+ const errs = {};
412
+ for (const k of miss) {
413
+ errs[k] = st('installed_addons.field_required', { defaultValue: 'Falta completar este campo.' });
414
+ }
415
+ setFieldErrors(errs);
416
+ setFormError(st('installed_addons.missing_fields', {
417
+ fields: miss.map((k) => credLabel(credFields.find((f) => f.key === k))).join(', '),
418
+ defaultValue: 'Faltan campos obligatorios: {{fields}}.',
419
+ }));
420
+ focusFirstInvalid(miss);
421
+ return;
422
+ }
423
+ }
424
+ setFieldErrors({});
425
+ saveMutation.mutate();
426
+ };
427
+ // "Probar conexión": runs the connector's test_export health-check against the
428
+ // SAVED credentials (connector_get reads what's stored), so it validates a
429
+ // real round-trip to the provider without saving a stamp/order.
430
+ const testMutation = useMutation({
431
+ mutationFn: async () => {
432
+ const res = await api.post(`/integrations/${connector?.provider}/test`, {});
433
+ return res.data?.data;
434
+ },
435
+ onSuccess: (data) => {
436
+ if (data?.ok) {
437
+ notify.success(data.message ||
438
+ st('installed_addons.test_ok', { defaultValue: 'Conexión válida' }));
439
+ }
440
+ else {
441
+ notify.error(data?.message ||
442
+ st('installed_addons.test_failed', { defaultValue: 'No se pudo conectar' }));
443
+ }
444
+ },
445
+ onError: (err) => notify.error(err.response?.data?.message || st('installed_addons.settings_error')),
446
+ });
447
+ // "Sincronizar ahora": ops-native connectors with a sync worker (hub →
448
+ // partner read-models) run one sync now and report the run summary.
449
+ const syncMutation = useMutation({
450
+ mutationFn: async () => {
451
+ const res = await api.post(connector?.sync_endpoint ?? '', {});
452
+ return res.data?.data;
453
+ },
454
+ onSuccess: (data) => {
455
+ if (data?.status === 'skipped') {
456
+ notify.info(data.message || st('installed_addons.sync_skipped'));
457
+ return;
458
+ }
459
+ const summary = st('installed_addons.sync_done', {
460
+ licenses: data?.licenses?.fetched ?? 0,
461
+ instances: data?.instances?.fetched ?? 0,
462
+ accounts: data?.accounts?.fetched ?? 0,
463
+ });
464
+ if (data?.status === 'partial') {
465
+ notify.warning(`${summary} · ${(data.errors ?? []).join('; ')}`);
466
+ }
467
+ else {
468
+ notify.success(summary);
469
+ }
470
+ },
471
+ onError: (err) => {
472
+ const msg = err?.response?.data?.message;
473
+ notify.error(msg || st('installed_addons.sync_failed'));
474
+ },
475
+ });
476
+ const hasCredentials = credFields.length > 0;
477
+ const hasSettings = definitions.length > 0;
478
+ const canTest = !!connector?.test_export && canManageIssuer;
479
+ const issuerAdminNote = (_jsx("p", { className: 'text-sm text-muted-foreground', children: st('installed_addons.issuer_admin_only', {
480
+ defaultValue: 'Solo un administrador de la organización puede ver y guardar los datos del emisor y el certificado. Pide a un administrador que los configure.',
481
+ }) }));
482
+ const canSync = !!connector?.sync_endpoint && !!connector?.connected;
483
+ const renderCred = (f) => (_jsx(ConnectorCredentialFieldControl, { field: f, connected: !!connector?.connected, provider: connector?.provider ?? '', value: credValues[f.key] ?? '', onChange: (val) => setCred(f.key, val) }, f.key));
484
+ // One setting control, shared by the flat layout and the wizard's last step.
485
+ const renderSetting = (def) => {
486
+ const id = `${idPrefix}-setting-${def.key}`;
487
+ const value = settingsValues[def.key] ?? def.default_value;
488
+ const isCleared = cleared.has(def.key);
489
+ const overridden = branchMode && def.key in overrides && !isCleared;
490
+ return (_jsxs("div", { className: 'flex flex-col gap-2', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [_jsx(Label, { htmlFor: id, children: def.label || def.key }), def.scope === 'branch' && !branchMode && (_jsx(Badge, { variant: 'outline', className: 'text-[10px]', children: st('installed_addons.per_branch') })), branchMode && (_jsx("span", { className: 'text-muted-foreground text-xs', children: isCleared
491
+ ? st('installed_addons.inherit_pending')
492
+ : overridden || touched.has(def.key)
493
+ ? st('installed_addons.branch_own')
494
+ : st('installed_addons.branch_inherited') })), branchMode && (overridden || touched.has(def.key)) && !isCleared && (_jsx(Button, { type: 'button', variant: 'link', size: 'sm', className: 'h-auto p-0 text-xs', onClick: () => setCleared((prev) => new Set(prev).add(def.key)), children: st('installed_addons.inherit') }))] }), def.type === 'boolean' ? (_jsx(Switch, { id: id, checked: !!value, onCheckedChange: (checked) => setSetting(def.key, checked) })) : def.type === 'select' && (def.options?.length ?? 0) > 0 ? (_jsxs(Select, { value: String(value ?? ''), onValueChange: (v) => setSetting(def.key, v), children: [_jsx(SelectTrigger, { id: id, children: _jsx(SelectValue, {}) }), _jsx(SelectContent, { children: def.options.map((o) => (_jsx(SelectItem, { value: String(o.value), children: o.label }, String(o.value)))) })] })) : def.write_only ? (_jsxs(_Fragment, { children: [_jsx(Input, { id: id, type: 'password', autoComplete: 'new-password', "data-1p-ignore": true, "data-lpignore": 'true', spellCheck: false, placeholder: def.stored ? '••••••••' : '', value: touched.has(def.key) ? String(settingsValues[def.key] ?? '') : '', onChange: (e) => setSetting(def.key, e.target.value) }), def.stored ? (_jsx("p", { className: 'text-xs text-muted-foreground', children: st('installed_addons.secret_stored') })) : null] })) : (_jsx(Input, { id: id, type: def.type === 'number' ? 'number' : 'text', value: String(value ?? ''), onChange: (e) => setSetting(def.key, def.type === 'number'
495
+ ? e.target.value === ''
496
+ ? undefined
497
+ : Number(e.target.value)
498
+ : e.target.value) }))] }, def.key));
499
+ };
500
+ // Which level the settings form edits (only offered when the addon has
501
+ // branch-scoped settings and a specific branch is active).
502
+ const targetPicker = canTargetBranch ? (_jsxs("div", { className: 'flex flex-wrap items-center gap-2 rounded-md border p-2 text-sm', children: [_jsx("span", { className: 'text-muted-foreground', children: st('installed_addons.applies_to') }), _jsx(Button, { type: 'button', size: 'sm', variant: branchMode ? 'outline' : 'default', onClick: () => setTarget('org'), children: st('installed_addons.whole_org') }), _jsx(Button, { type: 'button', size: 'sm', variant: branchMode ? 'default' : 'outline', onClick: () => setTarget('branch'), children: st('installed_addons.only_branch', { name: activeBranch?.name, defaultValue: 'Solo {{name}}' }) })] })) : null;
503
+ // Settings (Ajustes) body, reused by the flat layout and the wizard's last step.
504
+ const settingsBody = (_jsxs("div", { className: 'flex flex-col gap-3', children: [targetPicker, shownDefs.map(renderSetting)] }));
505
+ // Wizard steps: credential sections that actually have fields, + a final
506
+ // "Ajustes" step when the addon also ships settings.
507
+ const credSteps = stepMode
508
+ ? layoutSections.filter((sec) => credFields.some((f) => f.section === sec.key))
509
+ : [];
510
+ const wizardSteps = [
511
+ ...credSteps.map((sec) => ({
512
+ key: sec.key,
513
+ title: sec.title,
514
+ description: sec.description,
515
+ kind: 'creds',
516
+ })),
517
+ ...(stepMode && hasSettings
518
+ ? [{ key: '__settings', title: 'installed_addons.section_settings', description: undefined, kind: 'settings' }]
519
+ : []),
520
+ ];
521
+ const totalSteps = wizardSteps.length;
522
+ const useStepper = stepMode && totalSteps > 1;
523
+ const stepIdx = Math.min(currentStep, Math.max(0, totalSteps - 1));
524
+ const activeStep = wizardSteps[stepIdx];
525
+ const isLastStep = stepIdx >= totalSteps - 1;
526
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { className: 'flex max-h-[85vh] flex-col', children: _jsxs(ConnectorFormStateContext.Provider, { value: { fields: credFields, errors: fieldErrors, idPrefix, client: api, expectedOptionKinds }, children: [_jsxs(DialogHeader, { className: 'shrink-0', children: [_jsx(DialogTitle, { children: st('installed_addons.configure_title', { name: displayName ?? addon.manifest.display_name ?? addon.manifest.name }) }), _jsx(DialogDescription, { children: st('installed_addons.configure_description') })] }), _jsx("div", { className: '-mr-2 flex flex-col gap-6 overflow-y-auto py-2 pr-2', children: loading ? (_jsx("div", { className: 'flex justify-center py-8', children: _jsx(Loader2, { className: 'h-5 w-5 animate-spin text-muted-foreground' }) })) : useStepper ? (_jsxs("div", { className: 'flex flex-col gap-5', children: [_jsxs("div", { className: 'flex flex-col gap-2.5', children: [_jsx("ol", { className: 'flex items-center', children: wizardSteps.map((s, i) => {
527
+ const done = i < stepIdx;
528
+ const active = i === stepIdx;
529
+ return (_jsxs("li", { className: cn('flex items-center', i < wizardSteps.length - 1 && 'flex-1'), children: [_jsx("button", { type: 'button', onClick: () => setCurrentStep(i), title: t(s.title ?? '', { defaultValue: humanizeKey(s.title) }), "aria-current": active ? 'step' : undefined, className: cn('flex h-7 w-7 shrink-0 items-center justify-center rounded-full border text-[11px] font-semibold transition-all', active
530
+ ? 'border-primary bg-primary text-primary-foreground ring-4 ring-primary/15'
531
+ : done
532
+ ? 'border-primary bg-primary/10 text-primary'
533
+ : 'border-border text-muted-foreground'), children: done ? _jsx(Check, { className: 'h-3.5 w-3.5' }) : i + 1 }), i < wizardSteps.length - 1 && (_jsx("span", { className: cn('mx-1.5 h-0.5 flex-1 rounded-full transition-colors', done ? 'bg-primary' : 'bg-border') }))] }, s.key));
534
+ }) }), _jsxs("div", { className: 'flex items-baseline justify-between gap-2', children: [_jsx("h4", { className: 'truncate text-sm font-semibold', children: t(activeStep?.title ?? '', {
535
+ defaultValue: humanizeKey(activeStep?.title),
536
+ }) }), _jsxs("span", { className: 'shrink-0 text-[11px] font-medium tabular-nums text-muted-foreground', children: [stepIdx + 1, " / ", totalSteps] })] })] }), _jsxs("div", { className: 'flex flex-col gap-3', children: [activeStep?.description && (_jsx("p", { className: 'text-xs text-muted-foreground', children: t(activeStep.description, { defaultValue: '' }) })), activeStep?.kind === 'settings'
537
+ ? settingsBody
538
+ : !canManageIssuer
539
+ ? issuerAdminNote
540
+ : credFields
541
+ .filter((f) => f.section === activeStep?.key)
542
+ .map(renderCred)] })] })) : (_jsxs(_Fragment, { children: [hasCredentials && (_jsxs("section", { className: 'flex flex-col gap-3', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [_jsx(Cable, { className: 'h-4 w-4 text-muted-foreground' }), _jsx("h3", { className: 'text-sm font-semibold', children: st('installed_addons.section_credentials') })] }), !canManageIssuer ? (issuerAdminNote) : useLayout ? (
543
+ // form_layout: one titled group per section, in declared order.
544
+ layoutSections.map((sec) => {
545
+ const fields = credFields.filter((f) => f.section === sec.key);
546
+ if (fields.length === 0)
547
+ return null;
548
+ return (_jsxs("div", { className: 'flex flex-col gap-3 rounded-md border border-border/60 px-3 py-3', children: [sec.title && (_jsxs("div", { children: [_jsx("h4", { className: 'text-sm font-medium', children: t(sec.title, { defaultValue: sec.title }) }), sec.description && (_jsx("p", { className: 'text-xs text-muted-foreground', children: t(sec.description, { defaultValue: '' }) }))] })), fields.map((f) => (_jsx(ConnectorCredentialFieldControl, { field: f, connected: !!connector?.connected, provider: connector?.provider ?? '', value: credValues[f.key] ?? '', onChange: (val) => setCred(f.key, val) }, f.key)))] }, sec.key));
549
+ })) : (_jsxs(_Fragment, { children: [requiredFields.map((f) => (_jsx(ConnectorCredentialFieldControl, { field: f, connected: !!connector?.connected, provider: connector?.provider ?? '', value: credValues[f.key] ?? '', onChange: (val) => setCred(f.key, val) }, f.key))), advancedFields.length > 0 && (_jsxs("details", { className: 'rounded-md border border-border/60 px-3 py-2', open: advancedFields.some((f) => !!fieldErrors[f.key]) || undefined, children: [_jsx("summary", { className: 'cursor-pointer select-none text-sm font-medium text-muted-foreground', children: st('installed_addons.advanced') }), _jsx("div", { className: 'flex flex-col gap-3 pt-3', children: advancedFields.map((f) => (_jsx(ConnectorCredentialFieldControl, { field: f, connected: !!connector?.connected, provider: connector?.provider ?? '', value: credValues[f.key] ?? '', onChange: (val) => setCred(f.key, val) }, f.key))) })] }))] }))] })), hasSettings && (_jsxs("section", { className: 'flex flex-col gap-3', children: [_jsxs("div", { className: 'flex items-center gap-2', children: [_jsx(Settings, { className: 'h-4 w-4 text-muted-foreground' }), _jsx("h3", { className: 'text-sm font-semibold', children: st('installed_addons.section_settings') })] }), targetPicker, shownDefs.map(renderSetting)] })), !hasCredentials && !hasSettings && (_jsx("p", { className: 'text-sm text-muted-foreground', children: st('installed_addons.no_settings') }))] })) }), formError ? (_jsx("div", { ref: errorRef, role: 'alert', className: 'max-h-40 shrink-0 overflow-y-auto whitespace-pre-wrap break-words rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive', children: formError })) : null, _jsxs(DialogFooter, { className: 'shrink-0 sm:justify-between', children: [canTest ? (_jsxs(Button, { variant: 'outline', onClick: () => testMutation.mutate(), disabled: testMutation.isPending, className: 'gap-2', children: [testMutation.isPending ? (_jsx(Loader2, { className: 'h-4 w-4 animate-spin' })) : testMutation.data?.ok ? (_jsx(CheckCircle2, { className: 'h-4 w-4 text-emerald-500' })) : testMutation.isError ||
550
+ (testMutation.data && !testMutation.data.ok) ? (_jsx(XCircle, { className: 'h-4 w-4 text-destructive' })) : (_jsx(Plug, { className: 'h-4 w-4' })), st('installed_addons.test_connection', {
551
+ defaultValue: 'Probar conexión',
552
+ })] })) : (_jsx("span", {})), canSync ? (_jsxs(Button, { variant: 'outline', onClick: () => syncMutation.mutate(), disabled: syncMutation.isPending, className: 'gap-2', children: [syncMutation.isPending ? (_jsx(Loader2, { className: 'h-4 w-4 animate-spin' })) : (_jsx(RefreshCw, { className: 'h-4 w-4' })), st('installed_addons.sync_now', { defaultValue: 'Sincronizar ahora' })] })) : null, _jsxs("div", { className: 'flex gap-2', children: [useStepper && stepIdx > 0 && (_jsx(Button, { variant: 'outline', onClick: () => setCurrentStep((s) => Math.max(0, s - 1)), children: st('common.back', { defaultValue: 'Atrás' }) })), _jsx(Button, { variant: 'outline', onClick: () => onOpenChange(false), children: st('common.cancel') }), useStepper && !isLastStep ? (_jsx(Button, { onClick: () => setCurrentStep((s) => s + 1), children: st('common.next', { defaultValue: 'Siguiente' }) })) : (_jsxs(Button, { onClick: handleSave, disabled: saveMutation.isPending || loading || (!hasCredentials && !hasSettings), children: [saveMutation.isPending && (_jsx(Loader2, { className: 'mr-2 h-4 w-4 animate-spin' })), st('common.save')] }))] })] })] }) }) }));
553
+ }
@@ -0,0 +1,40 @@
1
+ /** The minimum a credential definition needs for these helpers. */
2
+ export interface CredentialLike {
3
+ key: string;
4
+ label?: string;
5
+ required?: boolean;
6
+ secret?: boolean;
7
+ type?: string;
8
+ default?: string;
9
+ }
10
+ export type CredentialShape = 'public_key' | 'secret_key';
11
+ /** What a pasted value looks like, or null when it is not recognisable. */
12
+ export declare function credentialShape(raw: string): CredentialShape | null;
13
+ export declare const isSecretCredential: (f: CredentialLike) => boolean;
14
+ export interface ShapeMismatch {
15
+ /** What the value looks like. */
16
+ shape: CredentialShape;
17
+ /** The sibling field the value probably belongs to, when the form has one. */
18
+ suggestedKey?: string;
19
+ }
20
+ /**
21
+ * A value pasted in the wrong box: a public key in the secret token field, or
22
+ * a secret in the public-key field. Only a warning (never blocks), and only
23
+ * raised when the form really has a field for what the value looks like.
24
+ */
25
+ export declare function shapeMismatch(field: CredentialLike, value: string, fields: CredentialLike[]): ShapeMismatch | null;
26
+ /** Required fields still empty. A stored secret (connected) counts as filled. */
27
+ export declare function missingRequired(fields: CredentialLike[], values: Record<string, string>, connected: boolean): string[];
28
+ export interface SaveError {
29
+ /** The complete server message, never shortened. */
30
+ message: string;
31
+ /** Fields the server (or the client check) says need attention. */
32
+ fieldKeys: string[];
33
+ }
34
+ /** Reads the kernel/ops error envelope: {message, errors: {field: [{code}]}}. */
35
+ export declare function parseSaveError(err: unknown, fallback: string): SaveError;
36
+ /** Never show a raw dotted key: fall back to `fallback` when the text is the key. */
37
+ export declare function textOrFallback(text: string | undefined, key: string, fallback: string): string;
38
+ /** Cheap content hash so a re-published bundle with the same key count re-merges. */
39
+ export declare function bundleSignature(labels: Record<string, unknown>): string;
40
+ //# sourceMappingURL=connector-form-model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-form-model.d.ts","sourceRoot":"","sources":["../../src/setup/connector-form-model.ts"],"names":[],"mappings":"AAMA,mEAAmE;AACnE,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,MAAM,eAAe,GAAG,YAAY,GAAG,YAAY,CAAA;AASzD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAMnE;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,cAAc,YAAsC,CAAA;AAI1F,MAAM,WAAW,aAAa;IAC5B,iCAAiC;IACjC,KAAK,EAAE,eAAe,CAAA;IACtB,8EAA8E;IAC9E,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,cAAc,EACrB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,cAAc,EAAE,GACvB,aAAa,GAAG,IAAI,CAatB;AAED,iFAAiF;AACjF,wBAAgB,eAAe,CAC7B,MAAM,EAAE,cAAc,EAAE,EACxB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9B,SAAS,EAAE,OAAO,GACjB,MAAM,EAAE,CAOV;AAED,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAA;IACf,mEAAmE;IACnE,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CASxE;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAG9F;AAED,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAKvE"}