@seedprotocol/mapping 0.6.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.js CHANGED
@@ -1,9 +1,9 @@
1
- import { c as e, d as t, g as n, h as r, i, l as a, m as o, n as s, p as c, t as l } from "./autoMap-PTFd4l-9.js";
2
- import { useCallback as u, useEffect as d, useMemo as f, useRef as p, useState as m } from "react";
3
- import { Fragment as h, jsx as g, jsxs as _ } from "react/jsx-runtime";
1
+ import { S as e, _ as t, b as n, c as r, d as i, h as a, i as o, l as s, m as c, n as l, p as u, t as d, v as f, x as p, y as m } from "./autoMap-OMvtOG0S.js";
2
+ import { useCallback as h, useEffect as g, useMemo as _, useRef as v, useState as y } from "react";
3
+ import { Fragment as b, jsx as x, jsxs as S } from "react/jsx-runtime";
4
4
  //#region src/react/fieldMapperControls.tsx
5
- function v({ className: e, value: t, onChange: n, children: r, disabled: i, "aria-label": a }) {
6
- return /* @__PURE__ */ g("select", {
5
+ function C({ className: e, value: t, onChange: n, children: r, disabled: i, "aria-label": a }) {
6
+ return /* @__PURE__ */ x("select", {
7
7
  className: e,
8
8
  "aria-label": a,
9
9
  disabled: i,
@@ -12,8 +12,8 @@ function v({ className: e, value: t, onChange: n, children: r, disabled: i, "ari
12
12
  children: r
13
13
  });
14
14
  }
15
- function y({ className: e, type: t = "button", onClick: n, children: r, disabled: i, "aria-label": a, "aria-pressed": o }) {
16
- return /* @__PURE__ */ g("button", {
15
+ function w({ className: e, type: t = "button", onClick: n, children: r, disabled: i, "aria-label": a, "aria-pressed": o }) {
16
+ return /* @__PURE__ */ x("button", {
17
17
  type: t,
18
18
  className: e,
19
19
  onClick: n,
@@ -23,15 +23,15 @@ function y({ className: e, type: t = "button", onClick: n, children: r, disabled
23
23
  children: r
24
24
  });
25
25
  }
26
- function b({ className: e, children: t }) {
27
- return /* @__PURE__ */ g("span", {
26
+ function T({ className: e, children: t }) {
27
+ return /* @__PURE__ */ x("span", {
28
28
  className: e,
29
29
  children: t
30
30
  });
31
31
  }
32
32
  //#endregion
33
33
  //#region src/react/fieldMapperSlots.ts
34
- var x = {
34
+ var E = {
35
35
  root: "seed-field-mapper",
36
36
  toolbar: "fm-toolbar",
37
37
  filter: "fm-filter",
@@ -52,14 +52,14 @@ var x = {
52
52
  lookupEditor: "fm-lookups",
53
53
  jsonPreview: "fm-preview"
54
54
  };
55
- function S(e, t, n) {
55
+ function D(e, t, n) {
56
56
  return [
57
- x[e],
57
+ E[e],
58
58
  t?.[e],
59
59
  n
60
60
  ].filter(Boolean).join(" ");
61
61
  }
62
- function C(e, t, n) {
62
+ function O(e, t, n) {
63
63
  let r;
64
64
  r = e?.preview === void 0 ? t !== !1 && "both" : e.preview;
65
65
  let i;
@@ -71,81 +71,85 @@ function C(e, t, n) {
71
71
  lookups: i
72
72
  };
73
73
  }
74
- function w(e) {
74
+ function k(e) {
75
75
  return e === "row" || e === "both";
76
76
  }
77
- function T(e) {
77
+ function A(e) {
78
78
  return e === "json" || e === "both";
79
79
  }
80
80
  //#endregion
81
81
  //#region src/react/fieldMapperCore.ts
82
- function E(e, t = 40) {
82
+ function j(e, t = 40) {
83
83
  let n = e.replace(/\s+/g, " ").trim();
84
84
  return n.length <= t ? n : `${n.slice(0, t)}…`;
85
85
  }
86
- function D(e) {
87
- let t = e.subtitle ? `${e.label} · ${e.subtitle}` : e.label, n = E(e.value, 36);
86
+ function M(e) {
87
+ let t = e.subtitle ? `${e.label} · ${e.subtitle}` : e.label, n = j(e.value, 36);
88
88
  return n ? `${t} · "${n}"` : t;
89
89
  }
90
- function O(e) {
90
+ function N(e) {
91
91
  return e.filter((e) => e.kind !== "resolved");
92
92
  }
93
- function k(e) {
94
- return O(e).map((e) => ({
93
+ function P(e) {
94
+ return N(e).map((e) => ({
95
95
  value: e.id,
96
- label: D(e),
96
+ label: M(e),
97
97
  sample: e.value,
98
98
  kind: e.kind
99
99
  }));
100
100
  }
101
- function A(e) {
101
+ function F(e) {
102
102
  return e.map((e) => ({
103
103
  value: e.name,
104
104
  label: e.required ? `${e.name} *` : e.name,
105
105
  dataType: e.dataType
106
106
  }));
107
107
  }
108
- function j(e) {
108
+ function I(e) {
109
109
  if (e.kind === "full" || e.kind === "section") return !1;
110
110
  let t = typeof e.meta?.url == "string" && e.meta.url.trim() ? e.meta.url.trim() : e.value;
111
- return !t.trim().includes("<") && c(t);
111
+ return !t.trim().includes("<") && u(t);
112
112
  }
113
- function M(e, t) {
113
+ function L(e, t) {
114
114
  if (!e || !t) return null;
115
- if (o(t)) return "lookup";
116
- if (j(e)) {
115
+ if (c(t)) return "lookup";
116
+ if (I(e)) {
117
117
  if (t.dataType === "Image" || t.dataType === "File") return "file";
118
118
  if (t.dataType === "Html") return "extract";
119
119
  }
120
120
  return null;
121
121
  }
122
- function N(e, t, a) {
122
+ function R(e, t, r) {
123
123
  if (!e) return "";
124
- if (t === "extract") return `‹extract HTML from ${E(e.value, 48)}›`;
125
- if (t === "file") return `‹file stored from ${E(e.value, 48)}›`;
124
+ if (t === "extract") return `‹extract HTML from ${j(e.value, 48)}›`;
125
+ if (t === "file") return `‹file stored from ${j(e.value, 48)}›`;
126
126
  if (t === "lookup") {
127
- let t = a?.propertyName ?? a?.target?.name, i = r(e.value || e.label), o = t ? a?.lookups?.[t] : void 0;
128
- if (o && Object.prototype.hasOwnProperty.call(o, i)) {
129
- let e = o[i], t = a?.target ? n(e, a.target) : e;
130
- return E(Array.isArray(t) ? t.join(", ") : String(t), 80);
127
+ let t = e.value || e.label, i = r?.mapping ?? {
128
+ sourceId: e.id,
129
+ propertyName: r?.propertyName ?? r?.target?.name ?? "",
130
+ resolve: "lookup"
131
+ }, a = f(i, t, r?.lookups);
132
+ if (a !== void 0) {
133
+ let e = r?.target ? n(a, r.target) : a;
134
+ return j(Array.isArray(e) ? e.join(", ") : String(e), 80);
131
135
  }
132
- return `‹lookup uid for "${E(e.value, 48)}"›`;
136
+ return `‹lookup ref for "${j(e.value, 48)}"›`;
133
137
  }
134
- if (a?.target && o(a.target)) return "";
135
- if (a?.target) {
136
- let t = e.value || e.label, n = i(t, a.target.dataType);
137
- if (typeof n == "string") return E(n, 80);
138
+ if (r?.target && c(r.target)) return "";
139
+ if (r?.target) {
140
+ let t = e.value || e.label, n = o(t, r.target.dataType);
141
+ if (typeof n == "string") return j(n, 80);
138
142
  if (typeof n == "number" || typeof n == "boolean") return String(n);
139
143
  try {
140
- return E(JSON.stringify(n), 80);
144
+ return j(JSON.stringify(n), 80);
141
145
  } catch {
142
- return E(String(n), 80);
146
+ return j(String(n), 80);
143
147
  }
144
148
  }
145
- return E(e.value, 80);
149
+ return j(e.value, 80);
146
150
  }
147
- function P(e, t, n) {
148
- let r = s(e, t, n), i = t.filter((e) => e.resolve);
151
+ function z(e, t, n) {
152
+ let r = l(e, t, n), i = t.filter((e) => e.resolve && e.resolve !== "lookup");
149
153
  return i.length === 0 ? r : {
150
154
  ...r,
151
155
  _pendingResolve: i.map((e) => ({
@@ -155,13 +159,18 @@ function P(e, t, n) {
155
159
  }))
156
160
  };
157
161
  }
158
- function F(e) {
162
+ function B(e) {
159
163
  if (e.conflict) return "conflict";
160
164
  if (!e.mapping?.sourceId || !e.mapping.propertyName) return "empty";
161
165
  let t = e.mapping.resolve ?? null;
162
- return e.requiredResolve && t !== e.requiredResolve ? "needsResolve" : "mapped";
166
+ if (e.requiredResolve && t !== e.requiredResolve) return "needsResolve";
167
+ if (t === "lookup") {
168
+ let t = e.sampleValue ?? "";
169
+ if (!t || f(e.mapping, t, e.lookups) === void 0) return "needsLookup";
170
+ }
171
+ return "mapped";
163
172
  }
164
- function I(e, t) {
173
+ function V(e, t) {
165
174
  let n = new Set(t.filter((e) => e.sourceId && e.propertyName).map((e) => e.propertyName)), r = e.filter((e) => e.required && !n.has(e.name)).map((e) => e.name);
166
175
  return {
167
176
  mapped: n.size,
@@ -169,7 +178,7 @@ function I(e, t) {
169
178
  missingRequired: r
170
179
  };
171
180
  }
172
- function L(e) {
181
+ function H(e) {
173
182
  let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Set();
174
183
  for (let r of e) {
175
184
  let e = r.propertyName;
@@ -179,33 +188,49 @@ function L(e) {
179
188
  }
180
189
  return n;
181
190
  }
182
- function R(e, t) {
183
- return e.resolve ? e : t && o(t) ? {
184
- ...e,
191
+ function U(e, t) {
192
+ return e.resolve ? e.resolve === "lookup" ? e : p(e) : t && c(t) ? {
193
+ ...p(e),
185
194
  resolve: "lookup"
186
- } : e;
195
+ } : p(e);
196
+ }
197
+ function W(t, n, r, i, a) {
198
+ if (n === "property") {
199
+ let n = t.findIndex((e) => e.propertyName === r);
200
+ if (n < 0) return null;
201
+ let i = t[n];
202
+ if (i.resolve !== "lookup") return null;
203
+ let o = [...t];
204
+ return o[n] = e(i, a), o;
205
+ }
206
+ let o = i.indexOf(r);
207
+ if (o < 0) return null;
208
+ let s = t[o];
209
+ if (!s || s.resolve !== "lookup") return null;
210
+ let c = [...t];
211
+ return c[o] = e(s, a), c;
187
212
  }
188
- function z(e, t) {
213
+ function G(e, t) {
189
214
  let n = e.filter((e) => e.propertyName !== t.propertyName);
190
215
  return n.push(t), n;
191
216
  }
192
- function B(e, t) {
217
+ function K(e, t) {
193
218
  if (t.length === 0) return null;
194
219
  let n = !1, r = { ...e };
195
220
  for (let e of t) e in r && (delete r[e], n = !0);
196
221
  return n ? r : null;
197
222
  }
198
- function V(t, n, r, i, a) {
199
- let o = new Map(r.map((e) => [e.name, e])), s = e(i, a);
200
- s = R(s, o.get(a)), n.some((e) => e.id === s.sourceId) || !O(n).find((e) => e.id === s.sourceId) && n.some((e) => e.id === i);
201
- let c = t.find((e) => e.propertyName === a), l = z(t, s), u = [];
223
+ function q(e, t, n, i, a) {
224
+ let o = new Map(n.map((e) => [e.name, e])), s = r(i, a);
225
+ s = U(s, o.get(a)), t.some((e) => e.id === s.sourceId) || !N(t).find((e) => e.id === s.sourceId) && t.some((e) => e.id === i);
226
+ let c = e.find((e) => e.propertyName === a), l = G(e, s), u = [];
202
227
  return c?.resolve === "lookup" && s.resolve !== "lookup" && u.push(a), {
203
228
  mappings: l,
204
229
  clearedLookupProps: u
205
230
  };
206
231
  }
207
232
  function ee(e, t) {
208
- let n = a(t), r = [];
233
+ let n = s(t), r = [];
209
234
  return {
210
235
  mappings: e.filter((e) => {
211
236
  let i;
@@ -214,30 +239,34 @@ function ee(e, t) {
214
239
  clearedLookupProps: r
215
240
  };
216
241
  }
217
- function H(e) {
218
- let { targets: t, mappings: n, sources: r, lookups: i } = e, a = new Map(n.map((e) => [e.propertyName, e])), o = new Map(O(r).map((e) => [e.id, e]));
242
+ function J(e) {
243
+ let { targets: t, mappings: n, sources: r, lookups: i } = e, a = new Map(n.map((e) => [e.propertyName, e])), o = new Map(N(r).map((e) => [e.id, e]));
219
244
  for (let e of r) o.has(e.id) || o.set(e.id, e);
220
245
  return (e.visiblePropertyNames == null ? t : t.filter((t) => e.visiblePropertyNames.has(t.name))).map((e) => {
221
- let t = a.get(e.name), n = t ? o.get(t.sourceId) : void 0, r = M(n, e), s = F({
246
+ let t = a.get(e.name), n = t ? o.get(t.sourceId) : void 0, r = L(n, e), s = m(n), c = B({
222
247
  mapping: t,
223
- requiredResolve: r
248
+ requiredResolve: r,
249
+ sampleValue: s,
250
+ lookups: i
224
251
  });
225
252
  return {
226
253
  id: e.name,
227
254
  target: e,
228
255
  mapping: t,
229
256
  source: n,
230
- preview: N(n, t?.resolve, {
257
+ sampleValue: s,
258
+ preview: R(n, t?.resolve, {
231
259
  target: e,
232
260
  lookups: i,
233
- propertyName: e.name
261
+ propertyName: e.name,
262
+ mapping: t
234
263
  }),
235
264
  requiredResolve: r,
236
- state: s
265
+ state: c
237
266
  };
238
267
  });
239
268
  }
240
- function U(e) {
269
+ function te(e) {
241
270
  let { mappings: t, edgeIds: n, drafts: r, sources: i, targets: a, lookups: o } = e, s = new Map(i.map((e) => [e.id, e])), c = new Map(a.map((e) => [e.name, e])), l = [];
242
271
  for (let e = 0; e < t.length; e++) {
243
272
  let r = t[e], i = n[e] ?? `edge-${e}`;
@@ -264,42 +293,46 @@ function U(e) {
264
293
  source: e.sourceId ? s.get(e.sourceId) : void 0,
265
294
  target: e.propertyName ? c.get(e.propertyName) : void 0
266
295
  });
267
- let u = L(l);
296
+ let u = H(l);
268
297
  return {
269
298
  rows: l.map((e) => {
270
- let t = M(e.source, e.target), n = (e.mapping && e.mapping.sourceId && e.mapping.propertyName, e.mapping), r = F({
299
+ let t = L(e.source, e.target), n = (e.mapping && e.mapping.sourceId && e.mapping.propertyName, e.mapping), r = m(e.source), i = B({
271
300
  mapping: n && n.sourceId && n.propertyName ? n : void 0,
272
301
  requiredResolve: t,
273
- conflict: u.has(e.id)
274
- }), i = !n?.sourceId || !n?.propertyName ? u.has(e.id) ? "conflict" : "empty" : r, a = n && n.sourceId && n.propertyName ? n : void 0;
302
+ conflict: u.has(e.id),
303
+ sampleValue: r,
304
+ lookups: o
305
+ }), a = !n?.sourceId || !n?.propertyName ? u.has(e.id) ? "conflict" : "empty" : i, s = n && n.sourceId && n.propertyName ? n : void 0;
275
306
  return {
276
307
  id: e.id,
277
308
  target: e.target,
278
- mapping: a,
309
+ mapping: s,
279
310
  source: e.source,
280
- preview: N(e.source, a?.resolve, {
311
+ sampleValue: r,
312
+ preview: R(e.source, s?.resolve, {
281
313
  target: e.target,
282
314
  lookups: o,
283
- propertyName: a?.propertyName
315
+ propertyName: s?.propertyName,
316
+ mapping: s
284
317
  }),
285
318
  requiredResolve: t,
286
- state: i
319
+ state: a
287
320
  };
288
321
  }),
289
322
  conflicts: u
290
323
  };
291
324
  }
292
- function W(e) {
325
+ function Y(e) {
293
326
  return `${e}-${Math.random().toString(36).slice(2, 10)}`;
294
327
  }
295
- function G(e, t) {
328
+ function ne(e, t) {
296
329
  if (e.length === t) return e;
297
330
  if (e.length > t) return e.slice(0, t);
298
331
  let n = [...e];
299
- for (; n.length < t;) n.push(W("edge"));
332
+ for (; n.length < t;) n.push(Y("edge"));
300
333
  return n;
301
334
  }
302
- function K(e, t, n, r) {
335
+ function re(e, t, n, r) {
303
336
  if (n === "all") return null;
304
337
  let i = new Set(t.map((e) => e.propertyName)), a = new Set(r);
305
338
  for (let t of e) (i.has(t.name) || n === "requiredAndMapped" && t.required) && a.add(t.name);
@@ -307,100 +340,89 @@ function K(e, t, n, r) {
307
340
  }
308
341
  //#endregion
309
342
  //#region src/react/LookupEditor.tsx
310
- function q(e) {
311
- let t = e.split(",").map((e) => e.trim()).filter(Boolean);
312
- return t.length === 0 ? "" : t.length === 1 ? t[0] : t;
313
- }
314
- function te(e) {
315
- return e == null ? "" : Array.isArray(e) ? e.join(", ") : e;
316
- }
317
- function ne(e, t, n, r) {
318
- let i = { ...e[t] ?? {} }, a = q(r);
319
- a === "" || Array.isArray(a) && a.length === 0 ? delete i[n] : i[n] = a;
320
- let o = { ...e };
321
- return Object.keys(i).length === 0 ? delete o[t] : o[t] = i, o;
322
- }
323
- function J({ mapping: e, sources: t, targetsByName: n, lookups: i, onLookupsChange: a, compact: o }) {
324
- let s = t.find((t) => t.id === e.sourceId), c = r(s?.value || s?.label || ""), l = i[e.propertyName] ?? {}, u = new Set(Object.keys(l));
343
+ function ie(e, n, r) {
344
+ let i = t(n), a = r.trim(), o = e.filter((e) => t(e.value) !== i);
345
+ return a && o.push({
346
+ value: i,
347
+ ref: a
348
+ }), o;
349
+ }
350
+ function ae({ mapping: e, sources: n, targetsByName: r, onLookupChange: i, compact: o }) {
351
+ let s = n.find((t) => t.id === e.sourceId), c = t(s?.value || s?.label || ""), l = a(e), u = new Set(l.map((e) => t(e.value)).filter(Boolean));
325
352
  c && u.add(c);
326
- let d = [...u], f = n.get(e.propertyName);
327
- return /* @__PURE__ */ _("div", {
353
+ let d = [...u], f = r.get(e.propertyName), p = new Map(l.map((e) => [t(e.value), e.ref]));
354
+ return /* @__PURE__ */ S("div", {
328
355
  className: "fm-lookup-block",
329
356
  children: [
330
- !o && /* @__PURE__ */ _("h4", { children: [e.propertyName, f?.ref ? ` → ${f.ref}` : ""] }),
331
- /* @__PURE__ */ _("div", {
357
+ !o && /* @__PURE__ */ S("h4", { children: [e.propertyName, f?.ref ? ` → ${f.ref}` : ""] }),
358
+ /* @__PURE__ */ x("div", {
332
359
  className: "fm-lookup-hint",
333
- children: [
334
- "Map source strings to seed UIDs",
335
- f?.dataType === "List" ? " (comma-separate for multiple)" : "",
336
- ". Host owns Identity search/create."
337
- ]
360
+ children: "Map source strings to refs. Host owns Identity search/create."
338
361
  }),
339
- d.length === 0 ? /* @__PURE__ */ g("div", {
362
+ d.length === 0 ? /* @__PURE__ */ x("div", {
340
363
  className: "fm-lookup-hint",
341
364
  children: "No sample value yet — paste a source string key after connecting."
342
- }) : d.map((t) => /* @__PURE__ */ _("div", {
365
+ }) : d.map((t) => /* @__PURE__ */ S("div", {
343
366
  className: "fm-lookup-row",
344
- children: [/* @__PURE__ */ g("div", {
367
+ children: [/* @__PURE__ */ x("div", {
345
368
  className: "fm-lookup-key",
346
369
  title: t,
347
370
  children: t || "(empty)"
348
- }), /* @__PURE__ */ g("input", {
371
+ }), /* @__PURE__ */ x("input", {
349
372
  className: "fm-lookup-input",
350
373
  type: "text",
351
- placeholder: "seed uid",
352
- value: te(l[t]),
353
- onChange: (n) => a(ne(i, e.propertyName, t, n.target.value)),
374
+ placeholder: "ref",
375
+ value: p.get(t) ?? "",
376
+ onChange: (n) => i(e, ie(l, t, n.target.value)),
354
377
  onClick: (e) => e.stopPropagation()
355
378
  })]
356
379
  }, t))
357
380
  ]
358
381
  });
359
382
  }
360
- function Y({ mode: e, mappings: t, sources: n, targets: r, lookups: i, onLookupsChange: a, classNames: o, className: s }) {
361
- let c = f(() => t.filter((e) => e.resolve === "lookup"), [t]), l = f(() => {
383
+ function X({ mode: e, mappings: t, sources: n, targets: r, onLookupChange: i, classNames: a, className: o }) {
384
+ let s = _(() => t.filter((e) => e.resolve === "lookup"), [t]), c = _(() => {
362
385
  let e = /* @__PURE__ */ new Map();
363
386
  for (let t of r) e.set(t.name, t);
364
387
  return e;
365
388
  }, [r]);
366
- if (c.length === 0) return null;
367
- let u = [
368
- S("lookupEditor", o),
389
+ if (s.length === 0) return null;
390
+ let l = [
391
+ D("lookupEditor", a),
369
392
  e === "row" ? "fm-lookups--row" : null,
370
- s
393
+ o
371
394
  ].filter(Boolean).join(" ");
372
- return /* @__PURE__ */ _("div", {
373
- className: u,
374
- children: [e === "section" && /* @__PURE__ */ g("div", {
395
+ return /* @__PURE__ */ S("div", {
396
+ className: l,
397
+ children: [e === "section" && /* @__PURE__ */ x("div", {
375
398
  className: "fm-lookups-title",
376
399
  children: "Relation lookups"
377
- }), c.map((t) => /* @__PURE__ */ g(J, {
400
+ }), s.map((t) => /* @__PURE__ */ x(ae, {
378
401
  mapping: t,
379
402
  sources: n,
380
- targetsByName: l,
381
- lookups: i,
382
- onLookupsChange: a,
403
+ targetsByName: c,
404
+ onLookupChange: i,
383
405
  compact: e === "row"
384
406
  }, `${t.sourceId}-${t.propertyName}`))]
385
407
  });
386
408
  }
387
409
  //#endregion
388
410
  //#region src/react/fieldMapperTheme.ts
389
- var re = 8, X = "seed-field-mapper-theme";
390
- function Z(e) {
411
+ var oe = 8, Z = "seed-field-mapper-theme";
412
+ function Q(e) {
391
413
  return e % 8;
392
414
  }
393
- function ie(e, t) {
415
+ function se(e, t) {
394
416
  if (t && t.length > 0) return t[e % t.length];
395
- let n = Z(e) + 1;
417
+ let n = Q(e) + 1;
396
418
  return `var(--fm-map-${n}, var(--map-${n}, currentColor))`;
397
419
  }
398
- function ae(e = "default") {
420
+ function ce(e = "default") {
399
421
  return e === "unstyled" ? "none" : e;
400
422
  }
401
- var oe = "\n --sfm-color-ground: #0f172a;\n --sfm-color-ink: #e2e8f0;\n --sfm-color-well: #1e293b;\n --sfm-color-line: #334155;\n --sfm-color-muted: #94a3b8;\n --sfm-color-faint: #64748b;\n --sfm-color-selection: #3b82f6;\n --sfm-color-warning: #fbbf24;\n --sfm-color-danger: #f87171;\n --sfm-color-highlight: #f59e0b;\n --sfm-map-1: #3b82f6;\n --sfm-map-2: #8b5cf6;\n --sfm-map-3: #ec4899;\n --sfm-map-4: #f59e0b;\n --sfm-map-5: #10b981;\n --sfm-map-6: #06b6d4;\n --sfm-map-7: #f97316;\n --sfm-map-8: #14b8a6;\n --fm-ground: var(--sfm-color-ground);\n --fm-ink: var(--sfm-color-ink);\n --fm-well: var(--sfm-color-well);\n --fm-line: var(--sfm-color-line);\n --fm-muted: var(--sfm-color-muted);\n --fm-faint: var(--sfm-color-faint);\n --fm-selection: var(--sfm-color-selection);\n --fm-highlight: var(--sfm-color-highlight);\n --fm-danger: var(--sfm-color-danger);\n --fm-warning: var(--sfm-color-warning);\n --fm-map-1: var(--sfm-map-1);\n --fm-map-2: var(--sfm-map-2);\n --fm-map-3: var(--sfm-map-3);\n --fm-map-4: var(--sfm-map-4);\n --fm-map-5: var(--sfm-map-5);\n --fm-map-6: var(--sfm-map-6);\n --fm-map-7: var(--sfm-map-7);\n --fm-map-8: var(--sfm-map-8);\n", se = "\n.seed-field-mapper {\n\n --sfm-space-1: 4px;\n --sfm-space-2: 8px;\n --sfm-space-3: 12px;\n --sfm-space-4: 16px;\n --sfm-radius-sm: 4px;\n --sfm-radius-md: 8px;\n --sfm-radius-lg: 12px;\n --sfm-font-family: inherit;\n --sfm-font-mono: ui-monospace, monospace;\n --sfm-font-size-sm: 11px;\n --sfm-font-size-md: 13px;\n --sfm-control-height: 32px;\n --sfm-row-gap: var(--sfm-space-2);\n\n font-family: var(--sfm-font-family);\n border-radius: var(--sfm-radius-lg);\n padding: var(--sfm-space-4);\n}\n.seed-field-mapper * { box-sizing: border-box; }\n.seed-field-mapper .fm-toolbar {\n display: flex;\n gap: var(--sfm-space-2);\n align-items: center;\n margin-bottom: var(--sfm-space-3);\n flex-wrap: wrap;\n}\n.seed-field-mapper .fm-btn {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 6px var(--sfm-space-3);\n cursor: pointer;\n font-size: var(--sfm-font-size-md);\n min-height: var(--sfm-control-height);\n}\n.seed-field-mapper .fm-meta {\n font-size: 12px;\n margin-left: auto;\n}\n.seed-field-mapper .fm-banner {\n font-size: 12px;\n padding: var(--sfm-space-2) 10px;\n border-radius: var(--sfm-radius-md);\n margin-bottom: 10px;\n border: 1px solid;\n}\n.seed-field-mapper .fm-grid {\n position: relative;\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 48px;\n min-height: 240px;\n}\n.seed-field-mapper .fm-col-title {\n font-size: var(--sfm-font-size-sm);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-card {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n margin-bottom: var(--sfm-space-2);\n cursor: pointer;\n transition: border-color 0.15s, box-shadow 0.15s;\n}\n.seed-field-mapper .fm-label {\n font-weight: 600;\n font-size: var(--sfm-font-size-md);\n margin-bottom: var(--sfm-space-1);\n}\n.seed-field-mapper .fm-value {\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.seed-field-mapper .fm-kind {\n font-size: 10px;\n margin-left: 6px;\n}\n.seed-field-mapper .fm-prop-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-dtype {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: var(--sfm-radius-sm);\n border: 1px solid;\n}\n.seed-field-mapper .fm-remove {\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 14px;\n padding: 0 var(--sfm-space-1);\n}\n.seed-field-mapper .fm-svg {\n position: absolute;\n inset: 0;\n pointer-events: none;\n overflow: visible;\n}\n.seed-field-mapper .fm-preview {\n margin-top: var(--sfm-space-3);\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: var(--sfm-space-3);\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: pre-wrap;\n max-height: 200px;\n overflow: auto;\n}\n.seed-field-mapper details.fm-preview {\n font-family: var(--sfm-font-family);\n white-space: normal;\n max-height: none;\n overflow: visible;\n padding: var(--sfm-space-2) var(--sfm-space-3);\n}\n.seed-field-mapper details.fm-preview > summary {\n cursor: pointer;\n font-size: var(--sfm-font-size-sm);\n list-style: disclosure-closed;\n}\n.seed-field-mapper details.fm-preview[open] > summary {\n list-style: disclosure-open;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-preview-body {\n margin: 0;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: pre-wrap;\n max-height: 200px;\n overflow: auto;\n}\n.seed-field-mapper .fm-lookups {\n margin-top: var(--sfm-space-4);\n border-top: 1px solid;\n padding-top: var(--sfm-space-3);\n}\n.seed-field-mapper .fm-row .fm-lookups,\n.seed-field-mapper .fm-lookups--row {\n margin-top: var(--sfm-space-2);\n border-top: none;\n padding-top: 0;\n}\n.seed-field-mapper .fm-row .fm-lookup-block {\n margin-bottom: 0;\n padding: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookups-title {\n font-size: var(--sfm-font-size-sm);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-block {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-block h4 {\n margin: 0 0 var(--sfm-space-2);\n font-size: var(--sfm-font-size-md);\n font-weight: 600;\n}\n.seed-field-mapper .fm-lookup-hint {\n font-size: var(--sfm-font-size-sm);\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-row {\n display: grid;\n grid-template-columns: 1fr 1.4fr;\n gap: var(--sfm-space-2);\n align-items: center;\n margin-bottom: 6px;\n}\n.seed-field-mapper .fm-lookup-key {\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.seed-field-mapper .fm-lookup-input {\n width: 100%;\n border: 1px solid;\n border-radius: 6px;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n padding: 6px var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-input:focus {\n outline: none;\n}\n.seed-field-mapper .fm-row-list {\n display: flex;\n flex-direction: column;\n gap: var(--sfm-row-gap);\n}\n.seed-field-mapper .fm-row {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n}\n.seed-field-mapper .fm-row-main {\n display: grid;\n grid-template-columns: minmax(100px, 140px) 1fr auto auto auto;\n gap: var(--sfm-space-2);\n align-items: center;\n}\n.seed-field-mapper .fm-row-main-source {\n grid-template-columns: 1fr auto auto 1fr auto auto;\n}\n.seed-field-mapper .fm-row-accessory {\n display: flex;\n align-items: center;\n min-width: 0;\n}\n.seed-field-mapper .fm-row-accessory:empty {\n display: none;\n}\n.seed-field-mapper .fm-row-prop {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n.seed-field-mapper .fm-row-prop-name {\n font-weight: 600;\n font-size: var(--sfm-font-size-md);\n}\n.seed-field-mapper .fm-row-preview {\n margin-top: 6px;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n}\n.seed-field-mapper .fm-row-flag {\n font-size: var(--sfm-font-size-sm);\n margin-top: var(--sfm-space-1);\n}\n.seed-field-mapper .fm-select {\n width: 100%;\n border: 1px solid;\n border-radius: 6px;\n font-size: 12px;\n padding: 6px var(--sfm-space-2);\n min-width: 0;\n min-height: var(--sfm-control-height);\n}\n.seed-field-mapper .fm-select:focus {\n outline: none;\n}\n.seed-field-mapper .fm-filter {\n display: flex;\n gap: 6px;\n margin-bottom: 10px;\n flex-wrap: wrap;\n}\n.seed-field-mapper .fm-inspector {\n margin-top: var(--sfm-space-3);\n border-top: 1px solid;\n padding-top: 10px;\n}\n.seed-field-mapper .fm-inspector summary {\n cursor: pointer;\n font-size: 12px;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-inspector-row {\n display: grid;\n grid-template-columns: 1fr 1.5fr auto;\n gap: var(--sfm-space-2);\n align-items: center;\n padding: 6px 0;\n border-bottom: 1px solid;\n font-size: 12px;\n}\n.seed-field-mapper .fm-into {\n font-size: var(--sfm-font-size-sm);\n}\n", ce = `
423
+ var le = "\n --sfm-color-ground: #0f172a;\n --sfm-color-ink: #e2e8f0;\n --sfm-color-well: #1e293b;\n --sfm-color-line: #334155;\n --sfm-color-muted: #94a3b8;\n --sfm-color-faint: #64748b;\n --sfm-color-selection: #3b82f6;\n --sfm-color-warning: #fbbf24;\n --sfm-color-danger: #f87171;\n --sfm-color-highlight: #f59e0b;\n --sfm-map-1: #3b82f6;\n --sfm-map-2: #8b5cf6;\n --sfm-map-3: #ec4899;\n --sfm-map-4: #f59e0b;\n --sfm-map-5: #10b981;\n --sfm-map-6: #06b6d4;\n --sfm-map-7: #f97316;\n --sfm-map-8: #14b8a6;\n --fm-ground: var(--sfm-color-ground);\n --fm-ink: var(--sfm-color-ink);\n --fm-well: var(--sfm-color-well);\n --fm-line: var(--sfm-color-line);\n --fm-muted: var(--sfm-color-muted);\n --fm-faint: var(--sfm-color-faint);\n --fm-selection: var(--sfm-color-selection);\n --fm-highlight: var(--sfm-color-highlight);\n --fm-danger: var(--sfm-color-danger);\n --fm-warning: var(--sfm-color-warning);\n --fm-map-1: var(--sfm-map-1);\n --fm-map-2: var(--sfm-map-2);\n --fm-map-3: var(--sfm-map-3);\n --fm-map-4: var(--sfm-map-4);\n --fm-map-5: var(--sfm-map-5);\n --fm-map-6: var(--sfm-map-6);\n --fm-map-7: var(--sfm-map-7);\n --fm-map-8: var(--sfm-map-8);\n", ue = "\n.seed-field-mapper {\n\n --sfm-space-1: 4px;\n --sfm-space-2: 8px;\n --sfm-space-3: 12px;\n --sfm-space-4: 16px;\n --sfm-radius-sm: 4px;\n --sfm-radius-md: 8px;\n --sfm-radius-lg: 12px;\n --sfm-font-family: inherit;\n --sfm-font-mono: ui-monospace, monospace;\n --sfm-font-size-sm: 11px;\n --sfm-font-size-md: 13px;\n --sfm-control-height: 32px;\n --sfm-row-gap: var(--sfm-space-2);\n\n font-family: var(--sfm-font-family);\n border-radius: var(--sfm-radius-lg);\n padding: var(--sfm-space-4);\n}\n.seed-field-mapper * { box-sizing: border-box; }\n.seed-field-mapper .fm-toolbar {\n display: flex;\n gap: var(--sfm-space-2);\n align-items: center;\n margin-bottom: var(--sfm-space-3);\n flex-wrap: wrap;\n}\n.seed-field-mapper .fm-btn {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 6px var(--sfm-space-3);\n cursor: pointer;\n font-size: var(--sfm-font-size-md);\n min-height: var(--sfm-control-height);\n}\n.seed-field-mapper .fm-meta {\n font-size: 12px;\n margin-left: auto;\n}\n.seed-field-mapper .fm-banner {\n font-size: 12px;\n padding: var(--sfm-space-2) 10px;\n border-radius: var(--sfm-radius-md);\n margin-bottom: 10px;\n border: 1px solid;\n}\n.seed-field-mapper .fm-grid {\n position: relative;\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 48px;\n min-height: 240px;\n}\n.seed-field-mapper .fm-col-title {\n font-size: var(--sfm-font-size-sm);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-card {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n margin-bottom: var(--sfm-space-2);\n cursor: pointer;\n transition: border-color 0.15s, box-shadow 0.15s;\n}\n.seed-field-mapper .fm-label {\n font-weight: 600;\n font-size: var(--sfm-font-size-md);\n margin-bottom: var(--sfm-space-1);\n}\n.seed-field-mapper .fm-value {\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.seed-field-mapper .fm-kind {\n font-size: 10px;\n margin-left: 6px;\n}\n.seed-field-mapper .fm-prop-row {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-dtype {\n font-size: 10px;\n padding: 2px 6px;\n border-radius: var(--sfm-radius-sm);\n border: 1px solid;\n}\n.seed-field-mapper .fm-remove {\n background: transparent;\n border: none;\n cursor: pointer;\n font-size: 14px;\n padding: 0 var(--sfm-space-1);\n}\n.seed-field-mapper .fm-svg {\n position: absolute;\n inset: 0;\n pointer-events: none;\n overflow: visible;\n}\n.seed-field-mapper .fm-preview {\n margin-top: var(--sfm-space-3);\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: var(--sfm-space-3);\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: pre-wrap;\n max-height: 200px;\n overflow: auto;\n}\n.seed-field-mapper details.fm-preview {\n font-family: var(--sfm-font-family);\n white-space: normal;\n max-height: none;\n overflow: visible;\n padding: var(--sfm-space-2) var(--sfm-space-3);\n}\n.seed-field-mapper details.fm-preview > summary {\n cursor: pointer;\n font-size: var(--sfm-font-size-sm);\n list-style: disclosure-closed;\n}\n.seed-field-mapper details.fm-preview[open] > summary {\n list-style: disclosure-open;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-preview-body {\n margin: 0;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n white-space: pre-wrap;\n max-height: 200px;\n overflow: auto;\n}\n.seed-field-mapper .fm-lookups {\n margin-top: var(--sfm-space-4);\n border-top: 1px solid;\n padding-top: var(--sfm-space-3);\n}\n.seed-field-mapper .fm-row .fm-lookups,\n.seed-field-mapper .fm-lookups--row {\n margin-top: var(--sfm-space-2);\n border-top: none;\n padding-top: 0;\n}\n.seed-field-mapper .fm-row .fm-lookup-block {\n margin-bottom: 0;\n padding: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookups-title {\n font-size: var(--sfm-font-size-sm);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-block {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-block h4 {\n margin: 0 0 var(--sfm-space-2);\n font-size: var(--sfm-font-size-md);\n font-weight: 600;\n}\n.seed-field-mapper .fm-lookup-hint {\n font-size: var(--sfm-font-size-sm);\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-row {\n display: grid;\n grid-template-columns: 1fr 1.4fr;\n gap: var(--sfm-space-2);\n align-items: center;\n margin-bottom: 6px;\n}\n.seed-field-mapper .fm-lookup-key {\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.seed-field-mapper .fm-lookup-input {\n width: 100%;\n border: 1px solid;\n border-radius: 6px;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n padding: 6px var(--sfm-space-2);\n}\n.seed-field-mapper .fm-lookup-input:focus {\n outline: none;\n}\n.seed-field-mapper .fm-row-list {\n display: flex;\n flex-direction: column;\n gap: var(--sfm-row-gap);\n}\n.seed-field-mapper .fm-row {\n border: 1px solid;\n border-radius: var(--sfm-radius-md);\n padding: 10px var(--sfm-space-3);\n}\n.seed-field-mapper .fm-row-main {\n display: grid;\n grid-template-columns: minmax(100px, 140px) 1fr auto auto auto;\n gap: var(--sfm-space-2);\n align-items: center;\n}\n.seed-field-mapper .fm-row-main-source {\n grid-template-columns: 1fr auto auto 1fr auto auto;\n}\n.seed-field-mapper .fm-row-accessory {\n display: flex;\n align-items: center;\n min-width: 0;\n}\n.seed-field-mapper .fm-row-accessory:empty {\n display: none;\n}\n.seed-field-mapper .fm-row-prop {\n display: flex;\n flex-direction: column;\n gap: 2px;\n min-width: 0;\n}\n.seed-field-mapper .fm-row-prop-name {\n font-weight: 600;\n font-size: var(--sfm-font-size-md);\n}\n.seed-field-mapper .fm-row-preview {\n margin-top: 6px;\n font-family: var(--sfm-font-mono);\n font-size: var(--sfm-font-size-sm);\n}\n.seed-field-mapper .fm-row-flag {\n font-size: var(--sfm-font-size-sm);\n margin-top: var(--sfm-space-1);\n}\n.seed-field-mapper .fm-select {\n width: 100%;\n border: 1px solid;\n border-radius: 6px;\n font-size: 12px;\n padding: 6px var(--sfm-space-2);\n min-width: 0;\n min-height: var(--sfm-control-height);\n}\n.seed-field-mapper .fm-select:focus {\n outline: none;\n}\n.seed-field-mapper .fm-filter {\n display: flex;\n gap: 6px;\n margin-bottom: 10px;\n flex-wrap: wrap;\n}\n.seed-field-mapper .fm-inspector {\n margin-top: var(--sfm-space-3);\n border-top: 1px solid;\n padding-top: 10px;\n}\n.seed-field-mapper .fm-inspector summary {\n cursor: pointer;\n font-size: 12px;\n margin-bottom: var(--sfm-space-2);\n}\n.seed-field-mapper .fm-inspector-row {\n display: grid;\n grid-template-columns: 1fr 1.5fr auto;\n gap: var(--sfm-space-2);\n align-items: center;\n padding: 6px 0;\n border-bottom: 1px solid;\n font-size: 12px;\n}\n.seed-field-mapper .fm-into {\n font-size: var(--sfm-font-size-sm);\n}\n", de = `
402
424
  .seed-field-mapper {
403
- ${oe}
425
+ ${le}
404
426
  color: var(--sfm-color-ink);
405
427
  background: var(--sfm-color-ground);
406
428
  }
@@ -535,53 +557,53 @@ ${oe}
535
557
  color: var(--sfm-color-faint);
536
558
  }
537
559
  `;
538
- function le(e) {
560
+ function fe(e) {
539
561
  return `@layer seed-field-mapper {\n${e}\n}`;
540
562
  }
541
- function ue(e) {
542
- return e === "none" ? "" : le(e === "structural" ? se : `${se}\n${ce}`);
563
+ function pe(e) {
564
+ return e === "none" ? "" : fe(e === "structural" ? ue : `${ue}\n${de}`);
543
565
  }
544
- var de = ue("default"), Q = null;
545
- function fe(e) {
566
+ var me = pe("default"), he = null;
567
+ function ge(e) {
546
568
  if (typeof document > "u" || e === "none") return;
547
- let t = ue(e), n = document.getElementById(X);
569
+ let t = pe(e), n = document.getElementById(Z);
548
570
  if (n) {
549
- Q !== e && (n.textContent = t, Q = e);
571
+ he !== e && (n.textContent = t, he = e);
550
572
  return;
551
573
  }
552
574
  let r = document.createElement("style");
553
- r.id = X, r.textContent = t, document.head.appendChild(r), Q = e;
575
+ r.id = Z, r.textContent = t, document.head.appendChild(r), he = e;
554
576
  }
555
- function pe() {
556
- if (Q = null, typeof document > "u") return;
557
- let e = document.getElementById(X);
577
+ function _e() {
578
+ if (he = null, typeof document > "u") return;
579
+ let e = document.getElementById(Z);
558
580
  e && (typeof e.remove == "function" ? e.remove() : e.parentNode && e.parentNode.removeChild(e));
559
581
  }
560
582
  //#endregion
561
583
  //#region src/react/FieldMapperWires.tsx
562
- function $(e, n) {
584
+ function $(e, t) {
563
585
  if (!e.resolve) return e.sourceId;
564
- let r = t(e.sourceId, e.resolve);
565
- return n.some((e) => e.id === r) ? r : e.sourceId;
586
+ let n = i(e.sourceId, e.resolve);
587
+ return t.some((e) => e.id === n) ? n : e.sourceId;
566
588
  }
567
- function me(e, t) {
589
+ function ve(e, t) {
568
590
  let n = e.replace(/\s+/g, " ").trim();
569
591
  return n.length <= t ? n : `${n.slice(0, t)}…`;
570
592
  }
571
- function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, onLookupsChange: o, connectionColors: s, slots: c, classNames: l, ui: x = {
572
- Select: v,
573
- Button: y,
574
- Pill: b
593
+ function ye({ sources: e, targets: t, mappings: n, mapper: r, onLookupsChange: i, renderLookup: a, connectionColors: o, slots: c, classNames: l, ui: u = {
594
+ Select: C,
595
+ Button: w,
596
+ Pill: T
575
597
  } }) {
576
- let C = x.Button, [w, E] = m(null), [D, O] = m(null), [k, A] = m(null), [j, M] = m(!1), [N, F] = m({
598
+ let d = u.Button, [f, p] = y(null), [m, E] = y(null), [O, k] = y(null), [j, M] = y(!1), [N, P] = y({
577
599
  width: 0,
578
600
  height: 0
579
- }), [I, L] = m([]), R = p(null), z = p({}), B = p({}), V = f(() => {
601
+ }), [F, I] = y([]), L = v(null), R = v({}), B = v({}), V = _(() => {
580
602
  let e = /* @__PURE__ */ new Map();
581
603
  return n.forEach((t, n) => {
582
604
  e.set(t.propertyName, n);
583
605
  }), e;
584
- }, [n]), ee = f(() => {
606
+ }, [n]), H = _(() => {
585
607
  let t = /* @__PURE__ */ new Map();
586
608
  return n.forEach((n, r) => {
587
609
  let i = $(n, e);
@@ -590,38 +612,38 @@ function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, o
590
612
  n.push(r), t.set(e, n);
591
613
  }
592
614
  }), t;
593
- }, [n, e]), H = u(() => {
594
- if (!R.current) return [];
595
- let t = R.current.getBoundingClientRect();
615
+ }, [n, e]), U = h(() => {
616
+ if (!L.current) return [];
617
+ let t = L.current.getBoundingClientRect();
596
618
  return n.map((n, r) => {
597
- let i = $(n, e), a = z.current[i] ?? z.current[n.sourceId], o = B.current[n.propertyName];
598
- if (!a || !o) return null;
599
- let c = a.getBoundingClientRect(), l = o.getBoundingClientRect();
619
+ let i = $(n, e), a = R.current[i] ?? R.current[n.sourceId], s = B.current[n.propertyName];
620
+ if (!a || !s) return null;
621
+ let c = a.getBoundingClientRect(), l = s.getBoundingClientRect();
600
622
  return {
601
623
  x1: c.right - t.left,
602
624
  y1: c.top + c.height / 2 - t.top,
603
625
  x2: l.left - t.left,
604
626
  y2: l.top + l.height / 2 - t.top,
605
- stroke: ie(r, s),
627
+ stroke: se(r, o),
606
628
  mappingIndex: r,
607
629
  mapping: n
608
630
  };
609
631
  }).filter((e) => e !== null);
610
632
  }, [
611
633
  n,
612
- s,
634
+ o,
613
635
  e
614
636
  ]);
615
- d(() => {
637
+ g(() => {
616
638
  let e = () => {
617
- if (R.current) {
618
- let e = R.current.getBoundingClientRect();
619
- F({
639
+ if (L.current) {
640
+ let e = L.current.getBoundingClientRect();
641
+ P({
620
642
  width: e.width,
621
643
  height: e.height
622
644
  });
623
645
  }
624
- L(H());
646
+ I(U());
625
647
  };
626
648
  e(), window.addEventListener("resize", e);
627
649
  let t = setInterval(e, 200);
@@ -629,127 +651,127 @@ function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, o
629
651
  window.removeEventListener("resize", e), clearInterval(t);
630
652
  };
631
653
  }, [
632
- H,
654
+ U,
633
655
  n,
634
656
  e,
635
657
  t
636
658
  ]);
637
- let U = (e) => {
638
- E((t) => t === e ? null : e);
639
- }, W = (e) => {
640
- w && r.connect(w, e);
659
+ let W = (e) => {
660
+ p((t) => t === e ? null : e);
641
661
  }, G = (e) => {
642
- let t = a(e);
662
+ f && r.connect(f, e);
663
+ }, K = (e) => {
664
+ let t = s(e);
643
665
  return t ? n.some((e) => e.sourceId === t.originId && e.resolve === t.resolve) : n.some((t) => t.sourceId === e);
644
- }, K = (e) => n.find((t) => t.propertyName === e), q = (t) => {
645
- if (D) return t.propertyName === D;
646
- if (k) {
666
+ }, q = (e) => n.find((t) => t.propertyName === e), ee = (t) => {
667
+ if (m) return t.propertyName === m;
668
+ if (O) {
647
669
  let n = $(t, e);
648
- return t.sourceId === k || n === k;
670
+ return t.sourceId === O || n === O;
649
671
  }
650
672
  return !1;
651
- }, te = D != null || k != null, ne = f(() => P(e, n, t), [
673
+ }, J = m != null || O != null, te = _(() => z(e, n, t), [
652
674
  e,
653
675
  n,
654
676
  t
655
- ]), { coverage: J } = r, re = T(c.preview);
656
- return /* @__PURE__ */ _(h, { children: [
657
- /* @__PURE__ */ _("div", {
658
- className: S("toolbar", l),
659
- children: [c.autoMap && /* @__PURE__ */ g(C, {
660
- className: S("autoMapButton", l),
677
+ ]), { coverage: Y } = r, ne = A(c.preview);
678
+ return /* @__PURE__ */ S(b, { children: [
679
+ /* @__PURE__ */ S("div", {
680
+ className: D("toolbar", l),
681
+ children: [c.autoMap && /* @__PURE__ */ x(d, {
682
+ className: D("autoMapButton", l),
661
683
  onClick: () => r.autoMap(),
662
684
  children: "Auto-map"
663
- }), /* @__PURE__ */ _("span", {
664
- className: S("coverage", l),
685
+ }), /* @__PURE__ */ S("span", {
686
+ className: D("coverage", l),
665
687
  children: [
666
- J.mapped,
688
+ Y.mapped,
667
689
  " / ",
668
- J.total,
690
+ Y.total,
669
691
  " mapped",
670
- J.missingRequired.length > 0 ? ` · ${J.missingRequired.length} required missing` : "",
671
- w ? " · click properties (source stays selected)" : " · click a source"
692
+ Y.missingRequired.length > 0 ? ` · ${Y.missingRequired.length} required missing` : "",
693
+ f ? " · click properties (source stays selected)" : " · click a source"
672
694
  ]
673
695
  })]
674
696
  }),
675
- /* @__PURE__ */ _("div", {
697
+ /* @__PURE__ */ S("div", {
676
698
  className: "fm-grid",
677
- ref: R,
699
+ ref: L,
678
700
  children: [
679
- /* @__PURE__ */ g("svg", {
701
+ /* @__PURE__ */ x("svg", {
680
702
  className: "fm-svg",
681
703
  width: N.width,
682
704
  height: N.height,
683
- children: I.map((e) => {
684
- let t = q(e.mapping), n = (e.x1 + e.x2) / 2;
685
- return /* @__PURE__ */ g("path", {
705
+ children: F.map((e) => {
706
+ let t = ee(e.mapping), n = (e.x1 + e.x2) / 2;
707
+ return /* @__PURE__ */ x("path", {
686
708
  className: "fm-connector",
687
709
  "data-mapping-index": e.mappingIndex,
688
- "data-pair": Z(e.mappingIndex),
710
+ "data-pair": Q(e.mappingIndex),
689
711
  d: `M ${e.x1} ${e.y1} C ${n} ${e.y1}, ${n} ${e.y2}, ${e.x2} ${e.y2}`,
690
712
  stroke: e.stroke,
691
713
  strokeWidth: t ? 3 : 2,
692
714
  fill: "none",
693
- opacity: te && !t ? .25 : .85
715
+ opacity: J && !t ? .25 : .85
694
716
  }, `${e.mapping.sourceId}-${e.mapping.propertyName}-${e.mapping.resolve ?? "copy"}`);
695
717
  })
696
718
  }),
697
- /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("div", {
719
+ /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
698
720
  className: "fm-col-title",
699
721
  children: "Sources"
700
722
  }), e.map((t) => {
701
- let i = G(t.id), a = w === t.id, o = ee.get(t.id) ?? [], s = o[0], c = k === t.id || D != null && n.some((n) => {
723
+ let i = K(t.id), a = f === t.id, o = H.get(t.id) ?? [], s = o[0], c = O === t.id || m != null && n.some((n) => {
702
724
  let r = $(n, e);
703
- return (n.sourceId === t.id || r === t.id) && n.propertyName === D;
725
+ return (n.sourceId === t.id || r === t.id) && n.propertyName === m;
704
726
  });
705
- return /* @__PURE__ */ _("div", {
727
+ return /* @__PURE__ */ S("div", {
706
728
  ref: (e) => {
707
- z.current[t.id] = e;
729
+ R.current[t.id] = e;
708
730
  },
709
731
  className: `fm-card${a ? " active pending" : ""}${i ? " mapped" : ""}${c ? " highlight" : ""}`,
710
732
  "data-source-id": t.id,
711
733
  ...o.length > 0 ? {
712
734
  "data-mapping-index": o.join(" "),
713
- "data-pair": String(Z(s))
735
+ "data-pair": String(Q(s))
714
736
  } : {},
715
- onClick: () => U(t.id),
716
- onMouseEnter: () => A(t.id),
717
- onMouseLeave: () => A(null),
718
- children: [/* @__PURE__ */ _("div", {
737
+ onClick: () => W(t.id),
738
+ onMouseEnter: () => k(t.id),
739
+ onMouseLeave: () => k(null),
740
+ children: [/* @__PURE__ */ S("div", {
719
741
  className: "fm-prop-row",
720
- children: [/* @__PURE__ */ _("div", {
742
+ children: [/* @__PURE__ */ S("div", {
721
743
  className: "fm-label",
722
744
  children: [
723
745
  t.label,
724
- t.subtitle ? /* @__PURE__ */ g("span", {
746
+ t.subtitle ? /* @__PURE__ */ x("span", {
725
747
  className: "fm-kind",
726
748
  children: t.subtitle
727
749
  }) : null,
728
- /* @__PURE__ */ g("span", {
750
+ /* @__PURE__ */ x("span", {
729
751
  className: "fm-kind",
730
752
  children: t.kind
731
753
  })
732
754
  ]
733
- }), i && /* @__PURE__ */ g(C, {
734
- className: S("removeButton", l),
755
+ }), i && /* @__PURE__ */ x(d, {
756
+ className: D("removeButton", l),
735
757
  "aria-label": "Remove all mappings for source",
736
758
  onClick: (e) => {
737
759
  e.stopPropagation(), r.removeBySource(t.id);
738
760
  },
739
761
  children: "×"
740
762
  })]
741
- }), /* @__PURE__ */ g("div", {
763
+ }), /* @__PURE__ */ x("div", {
742
764
  className: "fm-value",
743
- children: me(t.value, 80)
765
+ children: ve(t.value, 80)
744
766
  })]
745
767
  }, t.id);
746
768
  })] }),
747
- /* @__PURE__ */ _("div", { children: [/* @__PURE__ */ g("div", {
769
+ /* @__PURE__ */ S("div", { children: [/* @__PURE__ */ x("div", {
748
770
  className: "fm-col-title",
749
771
  children: "Model properties"
750
772
  }), t.map((t) => {
751
- let n = K(t.name), i = V.get(t.name), a = D === t.name || k != null && n != null && (n.sourceId === k || $(n, e) === k);
752
- return /* @__PURE__ */ _("div", {
773
+ let n = q(t.name), i = V.get(t.name), a = m === t.name || O != null && n != null && (n.sourceId === O || $(n, e) === O);
774
+ return /* @__PURE__ */ S("div", {
753
775
  ref: (e) => {
754
776
  B.current[t.name] = e;
755
777
  },
@@ -757,27 +779,27 @@ function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, o
757
779
  "data-property-name": t.name,
758
780
  ...i == null ? {} : {
759
781
  "data-mapping-index": String(i),
760
- "data-pair": String(Z(i))
782
+ "data-pair": String(Q(i))
761
783
  },
762
- onClick: () => W(t.name),
763
- onMouseEnter: () => O(t.name),
764
- onMouseLeave: () => O(null),
765
- children: [/* @__PURE__ */ _("div", {
784
+ onClick: () => G(t.name),
785
+ onMouseEnter: () => E(t.name),
786
+ onMouseLeave: () => E(null),
787
+ children: [/* @__PURE__ */ S("div", {
766
788
  className: "fm-prop-row",
767
- children: [/* @__PURE__ */ g("div", {
789
+ children: [/* @__PURE__ */ x("div", {
768
790
  className: "fm-label",
769
791
  children: t.name
770
- }), /* @__PURE__ */ _("div", {
792
+ }), /* @__PURE__ */ S("div", {
771
793
  style: {
772
794
  display: "flex",
773
795
  alignItems: "center",
774
796
  gap: 4
775
797
  },
776
- children: [/* @__PURE__ */ _("span", {
798
+ children: [/* @__PURE__ */ S("span", {
777
799
  className: "fm-dtype",
778
800
  children: [t.dataType, t.ref ? ` → ${t.ref}` : ""]
779
- }), n && /* @__PURE__ */ g(C, {
780
- className: S("removeButton", l),
801
+ }), n && /* @__PURE__ */ x(d, {
802
+ className: D("removeButton", l),
781
803
  "aria-label": "Remove mapping for property",
782
804
  onClick: (e) => {
783
805
  e.stopPropagation(), r.removeRow(t.name);
@@ -785,7 +807,7 @@ function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, o
785
807
  children: "×"
786
808
  })]
787
809
  })]
788
- }), n && /* @__PURE__ */ _("div", {
810
+ }), n && /* @__PURE__ */ S("div", {
789
811
  className: "fm-value",
790
812
  children: [
791
813
  "← ",
@@ -797,29 +819,39 @@ function he({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, o
797
819
  })] })
798
820
  ]
799
821
  }),
800
- c.lookups === "section" && o && /* @__PURE__ */ g(Y, {
822
+ c.lookups === "section" && a && r.rows.filter((e) => e.mapping?.resolve === "lookup").map((e) => /* @__PURE__ */ x("div", {
823
+ className: D("lookupEditor", l),
824
+ children: a({
825
+ ...e,
826
+ sampleValue: e.sampleValue ?? "",
827
+ onLookupChange: (t) => r.setLookupEntries(e.id, t)
828
+ })
829
+ }, e.id)),
830
+ c.lookups === "section" && !a && i && /* @__PURE__ */ x(X, {
801
831
  mode: "section",
802
832
  mappings: n,
803
833
  sources: e,
804
834
  targets: t,
805
- lookups: i,
806
- onLookupsChange: o,
835
+ onLookupChange: (e, t) => {
836
+ let n = r.rows.find((t) => t.mapping?.sourceId === e.sourceId && t.mapping?.propertyName === e.propertyName);
837
+ n && r.setLookupEntries(n.id, t);
838
+ },
807
839
  classNames: l
808
840
  }),
809
- re && /* @__PURE__ */ _("details", {
810
- className: S("jsonPreview", l),
841
+ ne && /* @__PURE__ */ S("details", {
842
+ className: D("jsonPreview", l),
811
843
  open: j,
812
844
  onToggle: (e) => M(e.target.open),
813
- children: [/* @__PURE__ */ g("summary", { children: "Preview JSON" }), /* @__PURE__ */ g("pre", {
845
+ children: [/* @__PURE__ */ x("summary", { children: "Preview JSON" }), /* @__PURE__ */ x("pre", {
814
846
  className: "fm-preview-body",
815
- children: JSON.stringify(ne, null, 2)
847
+ children: JSON.stringify(te, null, 2)
816
848
  })]
817
849
  })
818
850
  ] });
819
851
  }
820
852
  //#endregion
821
853
  //#region src/react/PropertyRows.tsx
822
- var ge = [
854
+ var be = [
823
855
  {
824
856
  value: "",
825
857
  label: "copy"
@@ -837,65 +869,65 @@ var ge = [
837
869
  label: "lookup"
838
870
  }
839
871
  ];
840
- function _e({ sources: e, targets: t, mappings: n, mapper: r, defaultRows: i = "requiredAndMapped", lookups: a = {}, onLookupsChange: o, slots: s, classNames: c, ui: l = {
841
- Select: v,
842
- Button: y,
843
- Pill: b
844
- }, renderRowAccessory: u }) {
845
- let d = l.Select, p = l.Button, x = l.Pill, [C, D] = m(i), [k, A] = m(() => /* @__PURE__ */ new Set()), [j, M] = m(!1), [N, F] = m(!1), [I, L] = m(null), [R, z] = m(!1), B = f(() => K(t, n, C, k), [
872
+ function xe({ sources: e, targets: t, mappings: n, mapper: r, defaultRows: i = "requiredAndMapped", onLookupsChange: a, slots: o, classNames: s, ui: c = {
873
+ Select: C,
874
+ Button: w,
875
+ Pill: T
876
+ }, renderRowAccessory: l, renderLookup: u }) {
877
+ let d = c.Select, f = c.Button, p = c.Pill, [m, h] = y(i), [g, v] = y(() => /* @__PURE__ */ new Set()), [E, O] = y(!1), [M, P] = y(!1), [F, I] = y(null), [L, R] = y(!1), B = _(() => re(t, n, m, g), [
846
878
  t,
847
879
  n,
848
- C,
849
- k
850
- ]), V = f(() => B == null ? r.rows : r.rows.filter((e) => B.has(e.id)), [r.rows, B]), ee = f(() => {
880
+ m,
881
+ g
882
+ ]), V = _(() => B == null ? r.rows : r.rows.filter((e) => B.has(e.id)), [r.rows, B]), H = _(() => {
851
883
  let e = /* @__PURE__ */ new Map();
852
884
  for (let t of n) {
853
885
  let n = e.get(t.sourceId) ?? [];
854
886
  n.push(t.propertyName), e.set(t.sourceId, n);
855
887
  }
856
888
  return e;
857
- }, [n]), H = f(() => P(e, n, t), [
889
+ }, [n]), U = _(() => z(e, n, t), [
858
890
  e,
859
891
  n,
860
892
  t
861
- ]), { coverage: U, sourceOptions: W, addableProperties: G } = r, q = T(s.preview), te = w(s.preview), ne = s.lookups === "row" && !!o, J = s.lookups === "section" && !!o, re = (e) => {
862
- r.addRow(e), A((t) => new Set(t).add(e)), F(!1);
863
- }, X = (e) => {
864
- L(e), F(!0);
865
- }, Z = (e) => {
866
- re(e), I && (r.setSource(e, I), L(null));
893
+ ]), { coverage: W, sourceOptions: G, addableProperties: K } = r, q = A(o.preview), ee = k(o.preview), J = o.lookups === "row" && (!!u || !!a), te = o.lookups === "section" && !u && !!a, Y = (e) => {
894
+ r.addRow(e), v((t) => new Set(t).add(e)), P(!1);
895
+ }, ne = (e) => {
896
+ I(e), P(!0);
897
+ }, ie = (e) => {
898
+ Y(e), F && (r.setSource(e, F), I(null));
867
899
  };
868
- return /* @__PURE__ */ _(h, { children: [
869
- /* @__PURE__ */ _("div", {
870
- className: S("toolbar", c),
871
- children: [s.autoMap && /* @__PURE__ */ g(p, {
872
- className: S("autoMapButton", c),
900
+ return /* @__PURE__ */ S(b, { children: [
901
+ /* @__PURE__ */ S("div", {
902
+ className: D("toolbar", s),
903
+ children: [o.autoMap && /* @__PURE__ */ x(f, {
904
+ className: D("autoMapButton", s),
873
905
  onClick: () => r.autoMap(),
874
906
  children: "Auto-map"
875
- }), /* @__PURE__ */ _("span", {
876
- className: S("coverage", c),
907
+ }), /* @__PURE__ */ S("span", {
908
+ className: D("coverage", s),
877
909
  children: [
878
- U.mapped,
910
+ W.mapped,
879
911
  " of ",
880
- U.total,
912
+ W.total,
881
913
  " properties mapped",
882
- U.missingRequired.length > 0 ? ` · ${U.missingRequired.length} required missing` : ""
914
+ W.missingRequired.length > 0 ? ` · ${W.missingRequired.length} required missing` : ""
883
915
  ]
884
916
  })]
885
917
  }),
886
- s.filter && /* @__PURE__ */ _("div", {
887
- className: S("filter", c),
918
+ o.filter && /* @__PURE__ */ S("div", {
919
+ className: D("filter", s),
888
920
  role: "group",
889
921
  "aria-label": "Row filter",
890
- children: [/* @__PURE__ */ g(p, {
922
+ children: [/* @__PURE__ */ x(f, {
891
923
  className: "fm-btn",
892
- "aria-pressed": C === "requiredAndMapped",
893
- onClick: () => D("requiredAndMapped"),
924
+ "aria-pressed": m === "requiredAndMapped",
925
+ onClick: () => h("requiredAndMapped"),
894
926
  children: "Mapped + required"
895
- }), /* @__PURE__ */ _(p, {
927
+ }), /* @__PURE__ */ S(f, {
896
928
  className: "fm-btn",
897
- "aria-pressed": C === "all",
898
- onClick: () => D("all"),
929
+ "aria-pressed": m === "all",
930
+ onClick: () => h("all"),
899
931
  children: [
900
932
  "All ",
901
933
  t.length,
@@ -903,107 +935,117 @@ function _e({ sources: e, targets: t, mappings: n, mapper: r, defaultRows: i = "
903
935
  ]
904
936
  })]
905
937
  }),
906
- /* @__PURE__ */ g("div", {
907
- className: S("rowList", c),
938
+ /* @__PURE__ */ x("div", {
939
+ className: D("rowList", s),
908
940
  children: V.map((n) => {
909
941
  let i = n.mapping?.resolve ?? "";
910
- return /* @__PURE__ */ _("div", {
911
- className: S("row", c),
942
+ return /* @__PURE__ */ S("div", {
943
+ className: D("row", s),
912
944
  "data-state": n.state,
913
945
  "data-property-name": n.id,
914
946
  "data-required": n.target?.required ? "true" : void 0,
915
947
  "data-resolve": n.mapping?.resolve,
916
948
  "data-source-kind": n.source?.kind,
917
949
  children: [
918
- /* @__PURE__ */ _("div", {
950
+ /* @__PURE__ */ S("div", {
919
951
  className: "fm-row-main",
920
952
  children: [
921
- /* @__PURE__ */ _("div", {
953
+ /* @__PURE__ */ S("div", {
922
954
  className: "fm-row-prop",
923
- children: [/* @__PURE__ */ _("div", {
924
- className: S("propertyLabel", c),
955
+ children: [/* @__PURE__ */ S("div", {
956
+ className: D("propertyLabel", s),
925
957
  children: [n.target?.name, n.target?.required ? " *" : ""]
926
- }), /* @__PURE__ */ g(x, {
927
- className: S("dataType", c),
958
+ }), /* @__PURE__ */ x(p, {
959
+ className: D("dataType", s),
928
960
  children: n.target?.dataType
929
961
  })]
930
962
  }),
931
- /* @__PURE__ */ _(d, {
932
- className: S("sourceSelect", c),
963
+ /* @__PURE__ */ S(d, {
964
+ className: D("sourceSelect", s),
933
965
  "aria-label": `Source for ${n.id}`,
934
966
  value: n.mapping?.sourceId ?? "",
935
967
  onChange: (e) => {
936
968
  r.setSource(n.id, e || null);
937
969
  },
938
- children: [/* @__PURE__ */ g("option", {
970
+ children: [/* @__PURE__ */ x("option", {
939
971
  value: "",
940
972
  children: "Choose a source field…"
941
- }), W.map((e) => /* @__PURE__ */ g("option", {
973
+ }), G.map((e) => /* @__PURE__ */ x("option", {
942
974
  value: e.value,
943
975
  children: e.label
944
976
  }, e.value))]
945
977
  }),
946
- n.mapping?.sourceId ? /* @__PURE__ */ g(d, {
947
- className: S("transformSelect", c),
978
+ n.mapping?.sourceId ? /* @__PURE__ */ x(d, {
979
+ className: D("transformSelect", s),
948
980
  "aria-label": `Transform for ${n.id}`,
949
981
  value: i,
950
982
  onChange: (e) => {
951
983
  r.setTransform(n.id, e || null);
952
984
  },
953
- children: ge.map((e) => /* @__PURE__ */ g("option", {
985
+ children: be.map((e) => /* @__PURE__ */ x("option", {
954
986
  value: e.value,
955
987
  children: e.label
956
988
  }, e.label))
957
- }) : /* @__PURE__ */ g(x, {
958
- className: S("dataType", c),
989
+ }) : /* @__PURE__ */ x(p, {
990
+ className: D("dataType", s),
959
991
  children: n.target?.dataType
960
992
  }),
961
- /* @__PURE__ */ g("div", {
962
- className: S("rowAccessory", c),
963
- children: u?.(n) ?? null
993
+ /* @__PURE__ */ x("div", {
994
+ className: D("rowAccessory", s),
995
+ children: l?.(n) ?? null
964
996
  }),
965
- /* @__PURE__ */ g(p, {
966
- className: S("removeButton", c),
997
+ /* @__PURE__ */ x(f, {
998
+ className: D("removeButton", s),
967
999
  "aria-label": `Remove mapping for ${n.id}`,
968
1000
  onClick: () => r.removeRow(n.id),
969
1001
  children: "×"
970
1002
  })
971
1003
  ]
972
1004
  }),
973
- te && n.preview && /* @__PURE__ */ g("div", {
974
- className: S("preview", c),
1005
+ ee && n.preview && /* @__PURE__ */ x("div", {
1006
+ className: D("preview", s),
975
1007
  children: n.preview
976
1008
  }),
977
- n.state === "needsResolve" && n.requiredResolve && /* @__PURE__ */ _("div", {
978
- className: S("validation", c),
1009
+ n.state === "needsResolve" && n.requiredResolve && /* @__PURE__ */ S("div", {
1010
+ className: D("validation", s),
979
1011
  children: ["needs ", n.requiredResolve]
980
1012
  }),
981
- ne && n.mapping?.resolve === "lookup" && n.mapping && /* @__PURE__ */ g(Y, {
1013
+ n.state === "needsLookup" && /* @__PURE__ */ x("div", {
1014
+ className: D("validation", s),
1015
+ children: "needs lookup"
1016
+ }),
1017
+ J && n.mapping?.resolve === "lookup" && n.mapping && (u ? /* @__PURE__ */ x("div", {
1018
+ className: D("lookupEditor", s),
1019
+ children: u({
1020
+ ...n,
1021
+ sampleValue: n.sampleValue ?? "",
1022
+ onLookupChange: (e) => r.setLookupEntries(n.id, e)
1023
+ })
1024
+ }) : /* @__PURE__ */ x(X, {
982
1025
  mode: "row",
983
1026
  mappings: [n.mapping],
984
1027
  sources: e,
985
1028
  targets: t,
986
- lookups: a,
987
- onLookupsChange: o,
988
- classNames: c
989
- })
1029
+ onLookupChange: (e, t) => r.setLookupEntries(n.id, t),
1030
+ classNames: s
1031
+ }))
990
1032
  ]
991
1033
  }, n.id);
992
1034
  })
993
1035
  }),
994
- /* @__PURE__ */ g("div", {
1036
+ /* @__PURE__ */ x("div", {
995
1037
  style: { marginTop: 10 },
996
- children: N ? /* @__PURE__ */ _(d, {
997
- className: S("sourceSelect", c),
1038
+ children: M ? /* @__PURE__ */ S(d, {
1039
+ className: D("sourceSelect", s),
998
1040
  "aria-label": "Add property mapping",
999
1041
  value: "",
1000
1042
  onChange: (e) => {
1001
- e && Z(e);
1043
+ e && ie(e);
1002
1044
  },
1003
- children: [/* @__PURE__ */ g("option", {
1045
+ children: [/* @__PURE__ */ x("option", {
1004
1046
  value: "",
1005
1047
  children: "Choose a property…"
1006
- }), G.map((e) => /* @__PURE__ */ _("option", {
1048
+ }), K.map((e) => /* @__PURE__ */ S("option", {
1007
1049
  value: e.name,
1008
1050
  children: [
1009
1051
  e.name,
@@ -1013,73 +1055,75 @@ function _e({ sources: e, targets: t, mappings: n, mapper: r, defaultRows: i = "
1013
1055
  ")"
1014
1056
  ]
1015
1057
  }, e.name))]
1016
- }) : /* @__PURE__ */ g(p, {
1017
- className: S("addButton", c),
1018
- onClick: () => F(!0),
1019
- disabled: G.length === 0,
1058
+ }) : /* @__PURE__ */ x(f, {
1059
+ className: D("addButton", s),
1060
+ onClick: () => P(!0),
1061
+ disabled: K.length === 0,
1020
1062
  children: "+ Add mapping"
1021
1063
  })
1022
1064
  }),
1023
- s.inspector && /* @__PURE__ */ _("details", {
1024
- className: S("inspector", c),
1025
- open: j,
1026
- onToggle: (e) => M(e.target.open),
1027
- children: [/* @__PURE__ */ _("summary", { children: [
1065
+ o.inspector && /* @__PURE__ */ S("details", {
1066
+ className: D("inspector", s),
1067
+ open: E,
1068
+ onToggle: (e) => O(e.target.open),
1069
+ children: [/* @__PURE__ */ S("summary", { children: [
1028
1070
  "Source fields (",
1029
- O(e).length,
1071
+ N(e).length,
1030
1072
  ")"
1031
- ] }), O(e).map((e) => {
1032
- let t = ee.get(e.id) ?? [];
1033
- return /* @__PURE__ */ _("div", {
1073
+ ] }), N(e).map((e) => {
1074
+ let t = H.get(e.id) ?? [];
1075
+ return /* @__PURE__ */ S("div", {
1034
1076
  className: "fm-inspector-row",
1035
1077
  children: [
1036
- /* @__PURE__ */ _("div", { children: [
1037
- /* @__PURE__ */ g("strong", { children: e.label }),
1038
- e.subtitle ? /* @__PURE__ */ g("div", {
1078
+ /* @__PURE__ */ S("div", { children: [
1079
+ /* @__PURE__ */ x("strong", { children: e.label }),
1080
+ e.subtitle ? /* @__PURE__ */ x("div", {
1039
1081
  className: "fm-value",
1040
1082
  children: e.subtitle
1041
1083
  }) : null,
1042
- /* @__PURE__ */ g("div", {
1084
+ /* @__PURE__ */ x("div", {
1043
1085
  className: "fm-value",
1044
- children: E(e.value, 60)
1086
+ children: j(e.value, 60)
1045
1087
  })
1046
1088
  ] }),
1047
- /* @__PURE__ */ g("div", {
1089
+ /* @__PURE__ */ x("div", {
1048
1090
  className: "fm-value",
1049
1091
  children: t.length > 0 ? `→ ${t.join(", ")}` : "unused"
1050
1092
  }),
1051
- /* @__PURE__ */ g(p, {
1093
+ /* @__PURE__ */ x(f, {
1052
1094
  className: "fm-btn",
1053
- onClick: () => X(e.id),
1095
+ onClick: () => ne(e.id),
1054
1096
  children: "Map this"
1055
1097
  })
1056
1098
  ]
1057
1099
  }, e.id);
1058
1100
  })]
1059
1101
  }),
1060
- J && /* @__PURE__ */ g(Y, {
1102
+ te && /* @__PURE__ */ x(X, {
1061
1103
  mode: "section",
1062
1104
  mappings: n,
1063
1105
  sources: e,
1064
1106
  targets: t,
1065
- lookups: a,
1066
- onLookupsChange: o,
1067
- classNames: c
1107
+ onLookupChange: (e, t) => {
1108
+ let n = r.rows.find((t) => t.mapping?.sourceId === e.sourceId && t.mapping?.propertyName === e.propertyName);
1109
+ n && r.setLookupEntries(n.id, t);
1110
+ },
1111
+ classNames: s
1068
1112
  }),
1069
- q && /* @__PURE__ */ _("details", {
1070
- className: S("jsonPreview", c),
1071
- open: R,
1072
- onToggle: (e) => z(e.target.open),
1073
- children: [/* @__PURE__ */ g("summary", { children: "Preview JSON" }), /* @__PURE__ */ g("pre", {
1113
+ q && /* @__PURE__ */ S("details", {
1114
+ className: D("jsonPreview", s),
1115
+ open: L,
1116
+ onToggle: (e) => R(e.target.open),
1117
+ children: [/* @__PURE__ */ x("summary", { children: "Preview JSON" }), /* @__PURE__ */ x("pre", {
1074
1118
  className: "fm-preview-body",
1075
- children: JSON.stringify(H, null, 2)
1119
+ children: JSON.stringify(U, null, 2)
1076
1120
  })]
1077
1121
  })
1078
1122
  ] });
1079
1123
  }
1080
1124
  //#endregion
1081
1125
  //#region src/react/SourceRows.tsx
1082
- var ve = [
1126
+ var Se = [
1083
1127
  {
1084
1128
  value: "",
1085
1129
  label: "copy"
@@ -1097,190 +1141,202 @@ var ve = [
1097
1141
  label: "lookup"
1098
1142
  }
1099
1143
  ];
1100
- function ye({ sources: e, targets: t, mappings: n, mapper: r, lookups: i = {}, onLookupsChange: a, slots: o, classNames: s, ui: c = {
1101
- Select: v,
1102
- Button: y,
1103
- Pill: b
1104
- }, renderRowAccessory: l }) {
1105
- let u = c.Select, d = c.Button, [p, x] = m(!1), { rows: C, sourceOptions: E, propertyOptions: D, coverage: O, conflicts: k, setSource: A, setProperty: j, setTransform: M, addRow: N, removeRow: F, autoMap: I } = r, L = f(() => P(e, n, t), [
1144
+ function Ce({ sources: e, targets: t, mappings: n, mapper: r, onLookupsChange: i, slots: a, classNames: o, ui: s = {
1145
+ Select: C,
1146
+ Button: w,
1147
+ Pill: T
1148
+ }, renderRowAccessory: c, renderLookup: l }) {
1149
+ let u = s.Select, d = s.Button, [f, p] = y(!1), { rows: m, sourceOptions: h, propertyOptions: g, coverage: v, conflicts: E, setSource: O, setProperty: j, setTransform: M, addRow: N, removeRow: P, autoMap: F } = r, I = _(() => z(e, n, t), [
1106
1150
  e,
1107
1151
  n,
1108
1152
  t
1109
- ]), R = T(o.preview), z = w(o.preview), B = o.lookups === "row" && !!a, V = o.lookups === "section" && !!a;
1110
- return /* @__PURE__ */ _(h, { children: [
1111
- /* @__PURE__ */ _("div", {
1112
- className: S("toolbar", s),
1113
- children: [o.autoMap && /* @__PURE__ */ g(d, {
1114
- className: S("autoMapButton", s),
1115
- onClick: () => I(),
1153
+ ]), L = A(a.preview), R = k(a.preview), B = a.lookups === "row" && (!!l || !!i), V = a.lookups === "section" && !l && !!i;
1154
+ return /* @__PURE__ */ S(b, { children: [
1155
+ /* @__PURE__ */ S("div", {
1156
+ className: D("toolbar", o),
1157
+ children: [a.autoMap && /* @__PURE__ */ x(d, {
1158
+ className: D("autoMapButton", o),
1159
+ onClick: () => F(),
1116
1160
  children: "Auto-map"
1117
- }), /* @__PURE__ */ _("span", {
1118
- className: S("coverage", s),
1161
+ }), /* @__PURE__ */ S("span", {
1162
+ className: D("coverage", o),
1119
1163
  children: [
1120
- O.mapped,
1164
+ v.mapped,
1121
1165
  " of ",
1122
- O.total,
1166
+ v.total,
1123
1167
  " mapped",
1124
- O.missingRequired.length > 0 ? ` · ${O.missingRequired.length} required missing: ${O.missingRequired.join(", ")}` : ""
1168
+ v.missingRequired.length > 0 ? ` · ${v.missingRequired.length} required missing: ${v.missingRequired.join(", ")}` : ""
1125
1169
  ]
1126
1170
  })]
1127
1171
  }),
1128
- k.size > 0 && /* @__PURE__ */ _("div", {
1172
+ E.size > 0 && /* @__PURE__ */ S("div", {
1129
1173
  className: "fm-banner fm-banner-danger",
1130
1174
  role: "alert",
1131
1175
  children: [
1132
- k.size,
1176
+ E.size,
1133
1177
  " row",
1134
- k.size === 1 ? "" : "s",
1178
+ E.size === 1 ? "" : "s",
1135
1179
  " claim the same property — each property can only have one source."
1136
1180
  ]
1137
1181
  }),
1138
- O.missingRequired.length > 0 && /* @__PURE__ */ _("div", {
1182
+ v.missingRequired.length > 0 && /* @__PURE__ */ S("div", {
1139
1183
  className: "fm-banner fm-banner-warn",
1140
1184
  role: "status",
1141
- children: ["Required missing: ", O.missingRequired.join(", ")]
1185
+ children: ["Required missing: ", v.missingRequired.join(", ")]
1142
1186
  }),
1143
- /* @__PURE__ */ g("div", {
1144
- className: S("rowList", s),
1145
- children: C.map((n) => {
1146
- let r = n.mapping?.resolve ?? "", o = n.source?.id ?? n.mapping?.sourceId ?? "", c = n.target?.name ?? n.mapping?.propertyName ?? "";
1147
- return /* @__PURE__ */ _("div", {
1148
- className: S("row", s),
1187
+ /* @__PURE__ */ x("div", {
1188
+ className: D("rowList", o),
1189
+ children: m.map((n) => {
1190
+ let i = n.mapping?.resolve ?? "", a = n.source?.id ?? n.mapping?.sourceId ?? "", s = n.target?.name ?? n.mapping?.propertyName ?? "";
1191
+ return /* @__PURE__ */ S("div", {
1192
+ className: D("row", o),
1149
1193
  "data-state": n.state,
1150
- "data-property-name": c || void 0,
1194
+ "data-property-name": s || void 0,
1151
1195
  "data-required": n.target?.required ? "true" : void 0,
1152
1196
  "data-resolve": n.mapping?.resolve,
1153
1197
  "data-source-kind": n.source?.kind,
1154
1198
  children: [
1155
- /* @__PURE__ */ _("div", {
1199
+ /* @__PURE__ */ S("div", {
1156
1200
  className: "fm-row-main fm-row-main-source",
1157
1201
  children: [
1158
- /* @__PURE__ */ _(u, {
1159
- className: S("sourceSelect", s),
1202
+ /* @__PURE__ */ S(u, {
1203
+ className: D("sourceSelect", o),
1160
1204
  "aria-label": "Source field",
1161
- value: o,
1205
+ value: a,
1162
1206
  onChange: (e) => {
1163
- A(n.id, e || null);
1207
+ O(n.id, e || null);
1164
1208
  },
1165
- children: [/* @__PURE__ */ g("option", {
1209
+ children: [/* @__PURE__ */ x("option", {
1166
1210
  value: "",
1167
1211
  children: "Choose a source field…"
1168
- }), E.map((e) => /* @__PURE__ */ g("option", {
1212
+ }), h.map((e) => /* @__PURE__ */ x("option", {
1169
1213
  value: e.value,
1170
1214
  children: e.label
1171
1215
  }, e.value))]
1172
1216
  }),
1173
- o ? /* @__PURE__ */ g(u, {
1174
- className: S("transformSelect", s),
1217
+ a ? /* @__PURE__ */ x(u, {
1218
+ className: D("transformSelect", o),
1175
1219
  "aria-label": "Transform",
1176
- value: r,
1220
+ value: i,
1177
1221
  onChange: (e) => {
1178
1222
  M(n.id, e || null);
1179
1223
  },
1180
- children: ve.map((e) => /* @__PURE__ */ g("option", {
1224
+ children: Se.map((e) => /* @__PURE__ */ x("option", {
1181
1225
  value: e.value,
1182
1226
  children: e.label
1183
1227
  }, e.label))
1184
- }) : /* @__PURE__ */ g("span", { className: "fm-into" }),
1185
- /* @__PURE__ */ g("span", {
1228
+ }) : /* @__PURE__ */ x("span", { className: "fm-into" }),
1229
+ /* @__PURE__ */ x("span", {
1186
1230
  className: "fm-into",
1187
1231
  children: "into"
1188
1232
  }),
1189
- /* @__PURE__ */ _(u, {
1190
- className: S("sourceSelect", s),
1233
+ /* @__PURE__ */ S(u, {
1234
+ className: D("sourceSelect", o),
1191
1235
  "aria-label": "Target property",
1192
- value: c,
1236
+ value: s,
1193
1237
  onChange: (e) => {
1194
1238
  e && j(n.id, e);
1195
1239
  },
1196
- children: [/* @__PURE__ */ g("option", {
1240
+ children: [/* @__PURE__ */ x("option", {
1197
1241
  value: "",
1198
1242
  children: "Choose a property…"
1199
- }), D.map((e) => /* @__PURE__ */ g("option", {
1243
+ }), g.map((e) => /* @__PURE__ */ x("option", {
1200
1244
  value: e.value,
1201
1245
  children: e.label
1202
1246
  }, e.value))]
1203
1247
  }),
1204
- /* @__PURE__ */ g("div", {
1205
- className: S("rowAccessory", s),
1206
- children: l?.(n) ?? null
1248
+ /* @__PURE__ */ x("div", {
1249
+ className: D("rowAccessory", o),
1250
+ children: c?.(n) ?? null
1207
1251
  }),
1208
- /* @__PURE__ */ g(d, {
1209
- className: S("removeButton", s),
1252
+ /* @__PURE__ */ x(d, {
1253
+ className: D("removeButton", o),
1210
1254
  "aria-label": "Remove row",
1211
- onClick: () => F(n.id),
1255
+ onClick: () => P(n.id),
1212
1256
  children: "×"
1213
1257
  })
1214
1258
  ]
1215
1259
  }),
1216
- z && n.preview && /* @__PURE__ */ g("div", {
1217
- className: S("preview", s),
1260
+ R && n.preview && /* @__PURE__ */ x("div", {
1261
+ className: D("preview", o),
1218
1262
  children: n.preview
1219
1263
  }),
1220
- n.state === "needsResolve" && n.requiredResolve && /* @__PURE__ */ _("div", {
1221
- className: S("validation", s),
1264
+ n.state === "needsResolve" && n.requiredResolve && /* @__PURE__ */ S("div", {
1265
+ className: D("validation", o),
1222
1266
  children: ["needs ", n.requiredResolve]
1223
1267
  }),
1224
- n.state === "conflict" && /* @__PURE__ */ g("div", {
1225
- className: S("validation", s),
1268
+ n.state === "needsLookup" && /* @__PURE__ */ x("div", {
1269
+ className: D("validation", o),
1270
+ children: "needs lookup"
1271
+ }),
1272
+ n.state === "conflict" && /* @__PURE__ */ x("div", {
1273
+ className: D("validation", o),
1226
1274
  style: { color: "var(--fm-danger)" },
1227
1275
  children: "property already mapped by another row"
1228
1276
  }),
1229
- B && n.mapping?.resolve === "lookup" && n.mapping && /* @__PURE__ */ g(Y, {
1277
+ B && n.mapping?.resolve === "lookup" && n.mapping && (l ? /* @__PURE__ */ x("div", {
1278
+ className: D("lookupEditor", o),
1279
+ children: l({
1280
+ ...n,
1281
+ sampleValue: n.sampleValue ?? "",
1282
+ onLookupChange: (e) => r.setLookupEntries(n.id, e)
1283
+ })
1284
+ }) : /* @__PURE__ */ x(X, {
1230
1285
  mode: "row",
1231
1286
  mappings: [n.mapping],
1232
1287
  sources: e,
1233
1288
  targets: t,
1234
- lookups: i,
1235
- onLookupsChange: a,
1236
- classNames: s
1237
- })
1289
+ onLookupChange: (e, t) => r.setLookupEntries(n.id, t),
1290
+ classNames: o
1291
+ }))
1238
1292
  ]
1239
1293
  }, n.id);
1240
1294
  })
1241
1295
  }),
1242
- /* @__PURE__ */ g("div", {
1296
+ /* @__PURE__ */ x("div", {
1243
1297
  style: { marginTop: 10 },
1244
- children: /* @__PURE__ */ g(d, {
1245
- className: S("addButton", s),
1298
+ children: /* @__PURE__ */ x(d, {
1299
+ className: D("addButton", o),
1246
1300
  onClick: () => N(),
1247
1301
  children: "+ Add mapping"
1248
1302
  })
1249
1303
  }),
1250
- V && /* @__PURE__ */ g(Y, {
1304
+ V && /* @__PURE__ */ x(X, {
1251
1305
  mode: "section",
1252
1306
  mappings: n,
1253
1307
  sources: e,
1254
1308
  targets: t,
1255
- lookups: i,
1256
- onLookupsChange: a,
1257
- classNames: s
1309
+ onLookupChange: (e, t) => {
1310
+ let n = r.rows.find((t) => t.mapping?.sourceId === e.sourceId && t.mapping?.propertyName === e.propertyName);
1311
+ n && r.setLookupEntries(n.id, t);
1312
+ },
1313
+ classNames: o
1258
1314
  }),
1259
- R && /* @__PURE__ */ _("details", {
1260
- className: S("jsonPreview", s),
1261
- open: p,
1262
- onToggle: (e) => x(e.target.open),
1263
- children: [/* @__PURE__ */ g("summary", { children: "Preview JSON" }), /* @__PURE__ */ g("pre", {
1315
+ L && /* @__PURE__ */ S("details", {
1316
+ className: D("jsonPreview", o),
1317
+ open: f,
1318
+ onToggle: (e) => p(e.target.open),
1319
+ children: [/* @__PURE__ */ x("summary", { children: "Preview JSON" }), /* @__PURE__ */ x("pre", {
1264
1320
  className: "fm-preview-body",
1265
- children: JSON.stringify(L, null, 2)
1321
+ children: JSON.stringify(I, null, 2)
1266
1322
  })]
1267
1323
  })
1268
1324
  ] });
1269
1325
  }
1270
1326
  //#endregion
1271
1327
  //#region src/react/useFieldMapper.ts
1272
- function be({ sources: e, targets: t, mappings: n, onChange: r, lookups: i = {}, onLookupsChange: a, rowKey: o = "property", onAutoMap: s }) {
1273
- let [c, d] = m(() => /* @__PURE__ */ new Set()), [h, g] = m([]), _ = p([]);
1274
- _.current = G(_.current, n.length);
1275
- let v = _.current, y = u((e) => {
1328
+ function we({ sources: e, targets: t, mappings: n, onChange: r, lookups: i = {}, onLookupsChange: a, rowKey: o = "property", onAutoMap: s }) {
1329
+ let [c, l] = y(() => /* @__PURE__ */ new Set()), [u, f] = y([]), m = v([]);
1330
+ m.current = ne(m.current, n.length);
1331
+ let g = m.current, b = h((e) => {
1276
1332
  if (!a || e.length === 0) return;
1277
- let t = B(i, e);
1333
+ let t = K(i, e);
1278
1334
  t && a(t);
1279
- }, [i, a]), b = f(() => k(e), [e]), x = f(() => A(t), [t]), S = f(() => I(t, n), [t, n]), C = f(() => new Set(n.map((e) => e.propertyName)), [n]), w = f(() => t.filter((e) => !C.has(e.name) && !c.has(e.name)), [
1335
+ }, [i, a]), x = _(() => P(e), [e]), S = _(() => F(t), [t]), C = _(() => V(t, n), [t, n]), w = _(() => new Set(n.map((e) => e.propertyName)), [n]), T = _(() => t.filter((e) => !w.has(e.name) && !c.has(e.name)), [
1280
1336
  t,
1281
- C,
1337
+ w,
1282
1338
  c
1283
- ]), T = f(() => H({
1339
+ ]), E = _(() => J({
1284
1340
  targets: t,
1285
1341
  mappings: n,
1286
1342
  sources: e,
@@ -1290,328 +1346,345 @@ function be({ sources: e, targets: t, mappings: n, onChange: r, lookups: i = {},
1290
1346
  n,
1291
1347
  e,
1292
1348
  i
1293
- ]), E = f(() => U({
1349
+ ]), D = _(() => te({
1294
1350
  mappings: n,
1295
- edgeIds: v,
1296
- drafts: h,
1351
+ edgeIds: g,
1352
+ drafts: u,
1297
1353
  sources: e,
1298
1354
  targets: t,
1299
1355
  lookups: i
1300
1356
  }), [
1301
1357
  n,
1302
- v,
1303
- h,
1358
+ g,
1359
+ u,
1304
1360
  e,
1305
1361
  t,
1306
1362
  i
1307
- ]), D = o === "property" ? T : E.rows, j = o === "property" ? /* @__PURE__ */ new Set() : E.conflicts, N = u((i, a) => {
1308
- let o = V(n, e, t, i, a);
1309
- r(o.mappings), y(o.clearedLookupProps);
1363
+ ]), O = o === "property" ? E : D.rows, k = o === "property" ? /* @__PURE__ */ new Set() : D.conflicts, A = h((i, a) => {
1364
+ let o = q(n, e, t, i, a);
1365
+ r(o.mappings), b(o.clearedLookupProps);
1310
1366
  }, [
1311
1367
  n,
1312
1368
  e,
1313
1369
  t,
1314
1370
  r,
1315
- y
1316
- ]), P = u((e) => {
1371
+ b
1372
+ ]), j = h((e) => {
1317
1373
  let t = ee(n, e);
1318
- r(t.mappings), y(t.clearedLookupProps);
1374
+ r(t.mappings), b(t.clearedLookupProps);
1319
1375
  }, [
1320
1376
  n,
1321
1377
  r,
1322
- y
1323
- ]), F = u(() => {
1324
- r(s ? s() : l(e, t)), g([]), d(/* @__PURE__ */ new Set());
1378
+ b
1379
+ ]), M = h(() => {
1380
+ r(s ? s() : d(e, t)), f([]), l(/* @__PURE__ */ new Set());
1325
1381
  }, [
1326
1382
  s,
1327
1383
  e,
1328
1384
  t,
1329
1385
  r
1330
- ]);
1331
- return {
1332
- rows: D,
1333
- sourceOptions: b,
1334
- propertyOptions: x,
1335
- addableProperties: w,
1336
- coverage: S,
1337
- conflicts: j,
1338
- setSource: u((i, a) => {
1339
- if (o === "property") {
1340
- if (!a) {
1341
- let e = n.find((e) => e.propertyName === i);
1342
- r(n.filter((e) => e.propertyName !== i)), e?.resolve === "lookup" && y([i]);
1343
- return;
1344
- }
1345
- let o = V(n, e, t, a, i), s = t.find((e) => e.name === i), c = O(e).find((e) => e.id === a), l = o.mappings.find((e) => e.propertyName === i);
1346
- if (!l.resolve) {
1347
- let e = M(c, s);
1348
- if (e) {
1349
- l = {
1350
- ...l,
1351
- resolve: e
1352
- }, r(z(o.mappings, l)), y(o.clearedLookupProps);
1353
- return;
1354
- }
1355
- }
1356
- r(o.mappings), y(o.clearedLookupProps);
1386
+ ]), I = h((i, a) => {
1387
+ if (o === "property") {
1388
+ if (!a) {
1389
+ let e = n.find((e) => e.propertyName === i);
1390
+ r(n.filter((e) => e.propertyName !== i)), e?.resolve === "lookup" && b([i]);
1357
1391
  return;
1358
1392
  }
1359
- let s = v.indexOf(i);
1360
- if (s >= 0) {
1361
- if (!a) {
1362
- let e = n[s];
1363
- r(n.filter((e, t) => t !== s)), e?.resolve === "lookup" && y([e.propertyName]);
1393
+ let o = q(n, e, t, a, i), s = t.find((e) => e.name === i), c = N(e).find((e) => e.id === a), l = o.mappings.find((e) => e.propertyName === i);
1394
+ if (!l.resolve) {
1395
+ let e = L(c, s);
1396
+ if (e) {
1397
+ l = {
1398
+ ...l,
1399
+ resolve: e
1400
+ }, r(G(o.mappings, l)), b(o.clearedLookupProps);
1364
1401
  return;
1365
1402
  }
1366
- let i = n[s], o = t.find((e) => e.name === i.propertyName), c = {
1403
+ }
1404
+ r(o.mappings), b(o.clearedLookupProps);
1405
+ return;
1406
+ }
1407
+ let s = g.indexOf(i);
1408
+ if (s >= 0) {
1409
+ if (!a) {
1410
+ let e = n[s];
1411
+ r(n.filter((e, t) => t !== s)), e?.resolve === "lookup" && b([e.propertyName]);
1412
+ return;
1413
+ }
1414
+ let i = n[s], o = t.find((e) => e.name === i.propertyName), c = {
1415
+ sourceId: a,
1416
+ propertyName: i.propertyName
1417
+ };
1418
+ if (c = U(c, o), !c.resolve) {
1419
+ let t = L(N(e).find((e) => e.id === a), o);
1420
+ t && (c = {
1421
+ ...c,
1422
+ resolve: t
1423
+ });
1424
+ }
1425
+ let l = [...n];
1426
+ l[s] = c, r(l), i.resolve === "lookup" && c.resolve !== "lookup" && b([i.propertyName]);
1427
+ return;
1428
+ }
1429
+ f((o) => {
1430
+ let s = o.map((n) => {
1431
+ if (n.id !== i) return n;
1432
+ if (!a) return {
1433
+ id: n.id,
1434
+ propertyName: n.propertyName
1435
+ };
1436
+ let r = n.propertyName ? t.find((e) => e.name === n.propertyName) : void 0, o = L(N(e).find((e) => e.id === a), r), s = r && U({
1367
1437
  sourceId: a,
1368
- propertyName: i.propertyName
1438
+ propertyName: n.propertyName ?? ""
1439
+ }, r).resolve || o || void 0;
1440
+ return {
1441
+ id: n.id,
1442
+ sourceId: a,
1443
+ propertyName: n.propertyName,
1444
+ resolve: s
1369
1445
  };
1370
- if (c = R(c, o), !c.resolve) {
1371
- let t = M(O(e).find((e) => e.id === a), o);
1372
- t && (c = {
1373
- ...c,
1374
- resolve: t
1375
- });
1376
- }
1377
- let l = [...n];
1378
- l[s] = c, r(l), i.resolve === "lookup" && c.resolve !== "lookup" && y([i.propertyName]);
1379
- return;
1446
+ }), c = s.filter((e) => e.sourceId && e.propertyName), l = s.filter((e) => !(e.sourceId && e.propertyName));
1447
+ return c.length > 0 ? (r([...n, ...c.map((e) => ({
1448
+ sourceId: e.sourceId,
1449
+ propertyName: e.propertyName,
1450
+ ...e.resolve ? { resolve: e.resolve } : {}
1451
+ }))]), l) : s;
1452
+ });
1453
+ }, [
1454
+ o,
1455
+ n,
1456
+ e,
1457
+ t,
1458
+ r,
1459
+ b,
1460
+ g
1461
+ ]), R = h((i, a) => {
1462
+ if (o === "property") return;
1463
+ let s = g.indexOf(i);
1464
+ if (s >= 0) {
1465
+ let i = n[s], o = t.find((e) => e.name === a), c = N(e).find((e) => e.id === i.sourceId), l = {
1466
+ sourceId: i.sourceId,
1467
+ propertyName: a
1468
+ };
1469
+ if (l = U(l, o), !l.resolve) {
1470
+ let e = L(c, o);
1471
+ e && (l = {
1472
+ ...l,
1473
+ resolve: e
1474
+ });
1380
1475
  }
1381
- g((o) => {
1382
- let s = o.map((n) => {
1383
- if (n.id !== i) return n;
1384
- if (!a) return {
1385
- id: n.id,
1386
- propertyName: n.propertyName
1387
- };
1388
- let r = n.propertyName ? t.find((e) => e.name === n.propertyName) : void 0, o = M(O(e).find((e) => e.id === a), r), s = r && R({
1389
- sourceId: a,
1390
- propertyName: n.propertyName ?? ""
1391
- }, r).resolve || o || void 0;
1392
- return {
1393
- id: n.id,
1394
- sourceId: a,
1395
- propertyName: n.propertyName,
1396
- resolve: s
1397
- };
1398
- }), c = s.filter((e) => e.sourceId && e.propertyName), l = s.filter((e) => !(e.sourceId && e.propertyName));
1399
- return c.length > 0 ? (r([...n, ...c.map((e) => ({
1476
+ let u = [...n];
1477
+ u[s] = l, r(u), i.resolve === "lookup" && l.resolve !== "lookup" && b([i.propertyName]), i.propertyName !== a && i.resolve === "lookup" && l.resolve === "lookup" && b([i.propertyName]);
1478
+ return;
1479
+ }
1480
+ f((o) => {
1481
+ let s = o.map((n) => {
1482
+ if (n.id !== i) return n;
1483
+ let r = t.find((e) => e.name === a), o = n.sourceId ? N(e).find((e) => e.id === n.sourceId) : void 0, s = n.resolve;
1484
+ n.sourceId && r && (s = U({
1485
+ sourceId: n.sourceId,
1486
+ propertyName: a
1487
+ }, r).resolve ?? L(o, r) ?? void 0);
1488
+ let c = {
1489
+ id: n.id,
1490
+ sourceId: n.sourceId,
1491
+ propertyName: a,
1492
+ resolve: s
1493
+ };
1494
+ return c.sourceId && c.propertyName, c;
1495
+ }), c = s.filter((e) => e.sourceId && e.propertyName), l = s.filter((e) => !(e.sourceId && e.propertyName));
1496
+ if (c.length > 0) {
1497
+ let e = c.map((e) => ({
1400
1498
  sourceId: e.sourceId,
1401
1499
  propertyName: e.propertyName,
1402
1500
  ...e.resolve ? { resolve: e.resolve } : {}
1403
- }))]), l) : s;
1404
- });
1405
- }, [
1406
- o,
1407
- n,
1408
- e,
1409
- t,
1410
- r,
1411
- y,
1412
- v
1413
- ]),
1414
- setProperty: u((i, a) => {
1415
- if (o === "property") return;
1416
- let s = v.indexOf(i);
1417
- if (s >= 0) {
1418
- let i = n[s], o = t.find((e) => e.name === a), c = O(e).find((e) => e.id === i.sourceId), l = {
1419
- sourceId: i.sourceId,
1420
- propertyName: a
1421
- };
1422
- if (l = R(l, o), !l.resolve) {
1423
- let e = M(c, o);
1424
- e && (l = {
1425
- ...l,
1426
- resolve: e
1427
- });
1428
- }
1429
- let u = [...n];
1430
- u[s] = l, r(u), i.resolve === "lookup" && l.resolve !== "lookup" && y([i.propertyName]), i.propertyName !== a && i.resolve === "lookup" && l.resolve === "lookup" && y([i.propertyName]);
1431
- return;
1501
+ }));
1502
+ return r([...n, ...e]), l;
1432
1503
  }
1433
- g((o) => {
1434
- let s = o.map((n) => {
1435
- if (n.id !== i) return n;
1436
- let r = t.find((e) => e.name === a), o = n.sourceId ? O(e).find((e) => e.id === n.sourceId) : void 0, s = n.resolve;
1437
- n.sourceId && r && (s = R({
1438
- sourceId: n.sourceId,
1439
- propertyName: a
1440
- }, r).resolve ?? M(o, r) ?? void 0);
1441
- let c = {
1442
- id: n.id,
1443
- sourceId: n.sourceId,
1444
- propertyName: a,
1445
- resolve: s
1446
- };
1447
- return c.sourceId && c.propertyName, c;
1448
- }), c = s.filter((e) => e.sourceId && e.propertyName), l = s.filter((e) => !(e.sourceId && e.propertyName));
1449
- if (c.length > 0) {
1450
- let e = c.map((e) => ({
1451
- sourceId: e.sourceId,
1452
- propertyName: e.propertyName,
1453
- ...e.resolve ? { resolve: e.resolve } : {}
1454
- }));
1455
- return r([...n, ...e]), l;
1456
- }
1457
- return s;
1458
- });
1459
- }, [
1460
- o,
1461
- v,
1462
- n,
1463
- t,
1464
- e,
1465
- r,
1466
- y
1467
- ]),
1468
- setTransform: u((e, t) => {
1504
+ return s;
1505
+ });
1506
+ }, [
1507
+ o,
1508
+ g,
1509
+ n,
1510
+ t,
1511
+ e,
1512
+ r,
1513
+ b
1514
+ ]), z = h((e, t) => {
1515
+ let s = W(n, o, e, g, t);
1516
+ if (!s || (r(s), !a)) return;
1517
+ let c = o === "property" ? s.find((t) => t.propertyName === e) : s[g.indexOf(e)];
1518
+ if (!c) return;
1519
+ let l = Object.fromEntries((c.lookup?.entries ?? []).map((e) => [e.value, e.ref])), u = { ...i };
1520
+ Object.keys(l).length === 0 ? delete u[c.propertyName] : u[c.propertyName] = l, a(u);
1521
+ }, [
1522
+ n,
1523
+ o,
1524
+ g,
1525
+ r,
1526
+ a,
1527
+ i
1528
+ ]);
1529
+ return {
1530
+ rows: O,
1531
+ sourceOptions: x,
1532
+ propertyOptions: S,
1533
+ addableProperties: T,
1534
+ coverage: C,
1535
+ conflicts: k,
1536
+ setSource: I,
1537
+ setProperty: R,
1538
+ setTransform: h((e, t) => {
1539
+ let i = (e, t) => t ? t === "lookup" ? {
1540
+ ...e,
1541
+ resolve: t
1542
+ } : p({
1543
+ sourceId: e.sourceId,
1544
+ propertyName: e.propertyName,
1545
+ resolve: t
1546
+ }) : {
1547
+ sourceId: e.sourceId,
1548
+ propertyName: e.propertyName
1549
+ };
1469
1550
  if (o === "property") {
1470
- let i = n.find((t) => t.propertyName === e);
1471
- if (!i) return;
1472
- r(z(n, t ? {
1473
- ...i,
1474
- resolve: t
1475
- } : {
1476
- sourceId: i.sourceId,
1477
- propertyName: i.propertyName
1478
- })), i.resolve === "lookup" && t !== "lookup" && y([e]);
1551
+ let a = n.find((t) => t.propertyName === e);
1552
+ if (!a) return;
1553
+ r(G(n, i(a, t))), a.resolve === "lookup" && t !== "lookup" && b([e]);
1479
1554
  return;
1480
1555
  }
1481
- let i = v.indexOf(e);
1482
- if (i >= 0) {
1483
- let e = n[i], a = t ? {
1484
- ...e,
1485
- resolve: t
1486
- } : {
1487
- sourceId: e.sourceId,
1488
- propertyName: e.propertyName
1489
- }, o = [...n];
1490
- o[i] = a, r(o), e.resolve === "lookup" && t !== "lookup" && y([e.propertyName]);
1556
+ let a = g.indexOf(e);
1557
+ if (a >= 0) {
1558
+ let e = n[a], o = [...n];
1559
+ o[a] = i(e, t), r(o), e.resolve === "lookup" && t !== "lookup" && b([e.propertyName]);
1491
1560
  return;
1492
1561
  }
1493
- g((n) => n.map((n) => n.id === e ? {
1562
+ f((n) => n.map((n) => n.id === e ? {
1494
1563
  ...n,
1495
1564
  resolve: t ?? void 0
1496
1565
  } : n));
1497
1566
  }, [
1498
1567
  o,
1499
1568
  n,
1500
- v,
1569
+ g,
1501
1570
  r,
1502
- y
1571
+ b
1503
1572
  ]),
1504
- addRow: u((e) => {
1573
+ setLookupEntries: z,
1574
+ addRow: h((e) => {
1505
1575
  if (o === "property") {
1506
- e && d((t) => new Set(t).add(e));
1576
+ e && l((t) => new Set(t).add(e));
1507
1577
  return;
1508
1578
  }
1509
- g((t) => [...t, {
1510
- id: W("draft"),
1579
+ f((t) => [...t, {
1580
+ id: Y("draft"),
1511
1581
  ...e ? { propertyName: e } : {}
1512
1582
  }]);
1513
1583
  }, [o]),
1514
- removeRow: u((e) => {
1584
+ removeRow: h((e) => {
1515
1585
  if (o === "property") {
1516
1586
  let t = n.find((t) => t.propertyName === e);
1517
- r(n.filter((t) => t.propertyName !== e)), t?.resolve === "lookup" && y([e]), d((t) => {
1587
+ r(n.filter((t) => t.propertyName !== e)), t?.resolve === "lookup" && b([e]), l((t) => {
1518
1588
  if (!t.has(e)) return t;
1519
1589
  let n = new Set(t);
1520
1590
  return n.delete(e), n;
1521
1591
  });
1522
1592
  return;
1523
1593
  }
1524
- let t = v.indexOf(e);
1594
+ let t = g.indexOf(e);
1525
1595
  if (t >= 0) {
1526
1596
  let e = n[t];
1527
- r(n.filter((e, n) => n !== t)), e?.resolve === "lookup" && y([e.propertyName]);
1597
+ r(n.filter((e, n) => n !== t)), e?.resolve === "lookup" && b([e.propertyName]);
1528
1598
  return;
1529
1599
  }
1530
- g((t) => t.filter((t) => t.id !== e));
1600
+ f((t) => t.filter((t) => t.id !== e));
1531
1601
  }, [
1532
1602
  o,
1533
1603
  n,
1534
- v,
1604
+ g,
1535
1605
  r,
1536
- y
1606
+ b
1537
1607
  ]),
1538
- autoMap: F,
1539
- connect: N,
1540
- removeBySource: P
1608
+ autoMap: M,
1609
+ connect: A,
1610
+ removeBySource: j
1541
1611
  };
1542
1612
  }
1543
1613
  //#endregion
1544
1614
  //#region src/react/FieldMapper.tsx
1545
- function xe({ sources: e, targets: t, mappings: n, onChange: r, lookups: i = {}, onLookupsChange: a, onAutoMap: o, className: s, theme: c = "default", connectionColors: l, showPreview: u, layout: p = "rows", rowKey: m = "property", defaultRows: h = "requiredAndMapped", classNames: _, components: x, slots: w, renderRowAccessory: T }) {
1546
- let E = be({
1615
+ function Te({ sources: e, targets: t, mappings: n, onChange: r, lookups: i = {}, onLookupsChange: a, onAutoMap: o, className: s, theme: c = "default", connectionColors: l, showPreview: u, layout: d = "rows", rowKey: f = "property", defaultRows: p = "requiredAndMapped", classNames: m, components: h, slots: v, renderRowAccessory: y, renderLookup: b }) {
1616
+ let S = we({
1547
1617
  sources: e,
1548
1618
  targets: t,
1549
1619
  mappings: n,
1550
1620
  onChange: r,
1551
1621
  lookups: i,
1552
1622
  onLookupsChange: a,
1553
- rowKey: p === "rows" ? m : "property",
1623
+ rowKey: d === "rows" ? f : "property",
1554
1624
  onAutoMap: o
1555
- }), D = ae(c), O = f(() => C(w, u, { layout: p }), [
1556
- w,
1625
+ }), E = ce(c), k = _(() => O(v, u, { layout: d }), [
1626
+ v,
1557
1627
  u,
1558
- p
1559
- ]), k = f(() => ({
1560
- Select: x?.Select ?? v,
1561
- Button: x?.Button ?? y,
1562
- Pill: x?.Pill ?? b
1563
- }), [x]);
1564
- d(() => {
1565
- fe(D);
1566
- }, [D]);
1567
- let A = S("root", _, [
1568
- D === "none" || c === "unstyled" || c === "none" ? "seed-field-mapper--unstyled" : null,
1569
- p === "rows" ? "seed-field-mapper--rows" : "seed-field-mapper--wires",
1628
+ d
1629
+ ]), A = _(() => ({
1630
+ Select: h?.Select ?? C,
1631
+ Button: h?.Button ?? w,
1632
+ Pill: h?.Pill ?? T
1633
+ }), [h]);
1634
+ g(() => {
1635
+ ge(E);
1636
+ }, [E]);
1637
+ let j = D("root", m, [
1638
+ E === "none" || c === "unstyled" || c === "none" ? "seed-field-mapper--unstyled" : null,
1639
+ d === "rows" ? "seed-field-mapper--rows" : "seed-field-mapper--wires",
1570
1640
  s
1571
1641
  ].filter(Boolean).join(" ") || null);
1572
- return /* @__PURE__ */ g("div", {
1573
- className: A,
1574
- "data-theme": D,
1575
- "data-layout": p,
1576
- "data-row-key": p === "rows" ? m : void 0,
1577
- children: p === "wires" ? /* @__PURE__ */ g(he, {
1642
+ return /* @__PURE__ */ x("div", {
1643
+ className: j,
1644
+ "data-theme": E,
1645
+ "data-layout": d,
1646
+ "data-row-key": d === "rows" ? f : void 0,
1647
+ children: d === "wires" ? /* @__PURE__ */ x(ye, {
1578
1648
  sources: e,
1579
1649
  targets: t,
1580
1650
  mappings: n,
1581
- mapper: E,
1651
+ mapper: S,
1582
1652
  lookups: i,
1583
1653
  onLookupsChange: a,
1654
+ renderLookup: b,
1584
1655
  connectionColors: l,
1585
- slots: O,
1586
- classNames: _,
1587
- ui: k
1588
- }) : m === "source" ? /* @__PURE__ */ g(ye, {
1656
+ slots: k,
1657
+ classNames: m,
1658
+ ui: A
1659
+ }) : f === "source" ? /* @__PURE__ */ x(Ce, {
1589
1660
  sources: e,
1590
1661
  targets: t,
1591
1662
  mappings: n,
1592
- mapper: E,
1663
+ mapper: S,
1593
1664
  lookups: i,
1594
1665
  onLookupsChange: a,
1595
- slots: O,
1596
- classNames: _,
1597
- ui: k,
1598
- renderRowAccessory: T
1599
- }) : /* @__PURE__ */ g(_e, {
1666
+ slots: k,
1667
+ classNames: m,
1668
+ ui: A,
1669
+ renderRowAccessory: y,
1670
+ renderLookup: b
1671
+ }) : /* @__PURE__ */ x(xe, {
1600
1672
  sources: e,
1601
1673
  targets: t,
1602
1674
  mappings: n,
1603
- mapper: E,
1604
- defaultRows: h,
1675
+ mapper: S,
1676
+ defaultRows: p,
1605
1677
  lookups: i,
1606
1678
  onLookupsChange: a,
1607
- slots: O,
1608
- classNames: _,
1609
- ui: k,
1610
- renderRowAccessory: T
1679
+ slots: k,
1680
+ classNames: m,
1681
+ ui: A,
1682
+ renderRowAccessory: y,
1683
+ renderLookup: b
1611
1684
  })
1612
1685
  });
1613
1686
  }
1614
1687
  //#endregion
1615
- export { de as DEFAULT_THEME_CSS, re as FIELD_MAPPER_PAIR_SLOTS, xe as FieldMapper, ce as PAINT_THEME_CSS, x as SLOT_BASE_CLASS, se as STRUCTURAL_THEME_CSS, X as THEME_STYLE_ID, H as buildPropertyModeRows, k as buildSourceOptions, P as buildSyncPreviewBag, ue as buildThemeCss, I as computeCoverage, M as computeRequiredResolve, V as connectSourceToProperty, ie as connectionStrokeForIndex, fe as ensureThemeInjected, K as filterPropertyNames, L as findConflicts, N as previewForEdge, pe as resetThemeInjectionForTests, C as resolveSlots, ae as resolveTheme, T as showJsonPreview, w as showRowPreview, S as slotClass, be as useFieldMapper, le as wrapInThemeLayer };
1688
+ export { me as DEFAULT_THEME_CSS, oe as FIELD_MAPPER_PAIR_SLOTS, Te as FieldMapper, de as PAINT_THEME_CSS, E as SLOT_BASE_CLASS, ue as STRUCTURAL_THEME_CSS, Z as THEME_STYLE_ID, J as buildPropertyModeRows, P as buildSourceOptions, z as buildSyncPreviewBag, pe as buildThemeCss, V as computeCoverage, L as computeRequiredResolve, q as connectSourceToProperty, se as connectionStrokeForIndex, ge as ensureThemeInjected, re as filterPropertyNames, H as findConflicts, R as previewForEdge, _e as resetThemeInjectionForTests, O as resolveSlots, ce as resolveTheme, A as showJsonPreview, k as showRowPreview, D as slotClass, we as useFieldMapper, fe as wrapInThemeLayer };
1616
1689
 
1617
1690
  //# sourceMappingURL=react.js.map