@updog/data-editor 0.1.49 → 0.1.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/index.css +1 -1
  2. package/index.d.ts +6 -0
  3. package/index.js +871 -616
  4. package/package.json +1 -1
package/index.js CHANGED
@@ -413,6 +413,7 @@ var Ur = {
413
413
  steps: {
414
414
  selectFiles: "Select files",
415
415
  sheetSelection: "Select sheet",
416
+ headerSelection: "Header selection",
416
417
  matchColumns: "Match columns",
417
418
  matchValues: "Match values",
418
419
  primaryKey: "Primary key"
@@ -432,12 +433,15 @@ var Ur = {
432
433
  emptyData: "The source returned no data",
433
434
  fetchError: "Failed to load data"
434
435
  },
436
+ headerSelection: { noHeaderLabel: "My data has no header row" },
435
437
  matchColumns: {
436
438
  banner: "Some columns could not be automatically matched",
437
439
  importedColumns: "Imported columns",
438
440
  matchedCount: "{{matched}}/{{total}} matched",
439
441
  targetColumns: "Target columns",
440
442
  selectColumnPlaceholder: "Select column",
443
+ syntheticColumn: "C{{index}}",
444
+ syntheticColumnValue: "C{{index}}: {{value}}",
441
445
  bestMatch: "Best match",
442
446
  createColumn: "Create column",
443
447
  createColumnNameLabel: "Column name",
@@ -13112,17 +13116,17 @@ function ff(e, t, n) {
13112
13116
  }
13113
13117
  //#endregion
13114
13118
  //#region src/components/PreviewTable/index.tsx
13115
- var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t, lockedColumns: n, displayRows: r = pf, blur: a = !0, scrollbars: o = !0, className: s }) => {
13116
- let c = e.length, l = Array.from({ length: r }, (e, n) => t[n]), u = o === !0, d = o === !0 || o === "empty", f = y(null), p = y(null), h = y(null), g = y(null), _ = y(null), x = y(null), [T, D] = b(!1), [O, k] = b(!1);
13119
+ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t, lockedColumns: n, displayRows: r = pf, blur: i = !0, scrollbars: a = !0, selectedRow: o, onSelectRow: s, className: c }) => {
13120
+ let l = e.length, u = Array.from({ length: r }, (e, n) => t[n]), d = a === !0, p = a === !0 || a === "empty", h = y(null), g = y(null), _ = y(null), x = y(null), T = y(null), D = y(null), [O, k] = b(!1), [A, j] = b(!1);
13117
13121
  m(() => {
13118
- if (!u) return;
13119
- let e = f.current, t = h.current, n = g.current, r = _.current, i = x.current;
13122
+ if (!d) return;
13123
+ let e = h.current, t = _.current, n = x.current, r = T.current, i = D.current;
13120
13124
  if (!e) return;
13121
13125
  let a = () => {
13122
13126
  let a = e.scrollHeight - e.clientHeight, o = e.scrollWidth - e.clientWidth;
13123
- t && r && (r.style.height = a + t.clientHeight + "px"), n && i && (i.style.width = o + n.clientWidth + "px"), k(a > 0), D(o > 0);
13127
+ t && r && (r.style.height = a + t.clientHeight + "px"), n && i && (i.style.width = o + n.clientWidth + "px"), j(a > 0), k(o > 0);
13124
13128
  }, o = new ResizeObserver(a);
13125
- o.observe(e), p.current && o.observe(p.current), a();
13129
+ o.observe(e), g.current && o.observe(g.current), a();
13126
13130
  let s = (e) => {
13127
13131
  e.preventDefault(), t && (t.scrollTop += e.deltaY), n && (n.scrollLeft += e.deltaX);
13128
13132
  };
@@ -13135,24 +13139,28 @@ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t,
13135
13139
  return t?.addEventListener("scroll", c, { passive: !0 }), n?.addEventListener("scroll", l, { passive: !0 }), () => {
13136
13140
  o.disconnect(), e.removeEventListener("wheel", s), t?.removeEventListener("scroll", c), n?.removeEventListener("scroll", l);
13137
13141
  };
13138
- }, [u]);
13139
- let A = v(() => ({ gridTemplateColumns: `var(--marker-width) repeat(${Math.max(c, 1)}, auto)` }), [c]);
13142
+ }, [d]);
13143
+ let M = f((e) => {
13144
+ s?.(Number(e.currentTarget.dataset.rowIndex));
13145
+ }, [s]), N = f((e) => {
13146
+ e.key !== "Enter" && e.key !== " " || (e.preventDefault(), s?.(Number(e.currentTarget.dataset.rowIndex)));
13147
+ }, [s]), P = v(() => ({ gridTemplateColumns: `var(--marker-width) repeat(${Math.max(l, 1)}, auto)` }), [l]);
13140
13148
  return /* @__PURE__ */ w("div", {
13141
- className: E("updog__preview-table", o === !1 ? "updog__preview-table--scrollbars-none" : o === "empty" ? "updog__preview-table--scrollbars-empty" : "updog__preview-table--scrollbars-show", u && !T && "updog__preview-table--no-hscroll", u && !O && "updog__preview-table--no-vscroll", s),
13149
+ className: E("updog__preview-table", a === !1 ? "updog__preview-table--scrollbars-none" : a === "empty" ? "updog__preview-table--scrollbars-empty" : "updog__preview-table--scrollbars-show", d && !O && "updog__preview-table--no-hscroll", d && !A && "updog__preview-table--no-vscroll", c),
13142
13150
  children: [
13143
13151
  /* @__PURE__ */ C("div", {
13144
13152
  className: "updog__preview-table__canvas-wrap",
13145
13153
  children: /* @__PURE__ */ C("div", {
13146
13154
  className: "updog__preview-table__scroll",
13147
- ref: f,
13155
+ ref: h,
13148
13156
  children: /* @__PURE__ */ w("div", {
13149
13157
  className: "updog__preview-table__grid",
13150
- style: A,
13151
- ref: p,
13158
+ style: P,
13159
+ ref: g,
13152
13160
  children: [
13153
13161
  /* @__PURE__ */ C("div", { className: "updog__preview-table-marker" }),
13154
- c === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-th", "updog__preview-table-cell--last-col") }) : e.map((e, t) => /* @__PURE__ */ w("div", {
13155
- className: E("updog__preview-table-th", t === c - 1 && "updog__preview-table-cell--last-col"),
13162
+ l === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-th", "updog__preview-table-cell--last-col") }) : e.map((e, t) => /* @__PURE__ */ w("div", {
13163
+ className: E("updog__preview-table-th", t === l - 1 && "updog__preview-table-cell--last-col"),
13156
13164
  children: [/* @__PURE__ */ C("span", {
13157
13165
  className: "updog__preview-table-th__label",
13158
13166
  children: e
@@ -13161,33 +13169,45 @@ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t,
13161
13169
  className: "updog__preview-table-th__lock-icon"
13162
13170
  })]
13163
13171
  }, t)),
13164
- l.map((t, n) => /* @__PURE__ */ w(i, { children: [/* @__PURE__ */ C("div", {
13165
- className: E("updog__preview-table-marker", n === r - 1 && "updog__preview-table-cell--last-row"),
13166
- children: n + 1
13167
- }), c === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-td", "updog__preview-table-cell--last-col", n === r - 1 && "updog__preview-table-cell--last-row") }) : e.map((e, i) => /* @__PURE__ */ C("div", {
13168
- className: E("updog__preview-table-td", i === c - 1 && "updog__preview-table-cell--last-col", n === r - 1 && "updog__preview-table-cell--last-row"),
13169
- children: t?.[i] ?? ""
13170
- }, i))] }, n))
13172
+ u.map((t, n) => {
13173
+ let i = n === r - 1, a = !!s && t !== void 0, c = o === n;
13174
+ return /* @__PURE__ */ w("div", {
13175
+ className: E("updog__preview-table-row", a && "updog__preview-table-row--interactive", c && "updog__preview-table-row--selected"),
13176
+ "data-row-index": n,
13177
+ role: a ? "row" : void 0,
13178
+ tabIndex: a ? 0 : void 0,
13179
+ "aria-selected": a ? c : void 0,
13180
+ onClick: a ? M : void 0,
13181
+ onKeyDown: a ? N : void 0,
13182
+ children: [/* @__PURE__ */ C("div", {
13183
+ className: E("updog__preview-table-marker", i && "updog__preview-table-cell--last-row"),
13184
+ children: n + 1
13185
+ }), l === 0 ? /* @__PURE__ */ C("div", { className: E("updog__preview-table-td", "updog__preview-table-cell--last-col", i && "updog__preview-table-cell--last-row") }) : e.map((e, n) => /* @__PURE__ */ C("div", {
13186
+ className: E("updog__preview-table-td", n === l - 1 && "updog__preview-table-cell--last-col", i && "updog__preview-table-cell--last-row"),
13187
+ children: t?.[n] ?? ""
13188
+ }, n))]
13189
+ }, n);
13190
+ })
13171
13191
  ]
13172
13192
  })
13173
13193
  })
13174
13194
  }),
13175
- d && /* @__PURE__ */ w(S, { children: [
13195
+ p && /* @__PURE__ */ w(S, { children: [
13176
13196
  /* @__PURE__ */ C("div", {
13177
13197
  className: "updog__preview-table__vtrack",
13178
- ref: h,
13198
+ ref: _,
13179
13199
  tabIndex: -1,
13180
13200
  children: /* @__PURE__ */ C("div", {
13181
- ref: _,
13201
+ ref: T,
13182
13202
  style: mf
13183
13203
  })
13184
13204
  }),
13185
13205
  /* @__PURE__ */ C("div", {
13186
13206
  className: "updog__preview-table__htrack",
13187
- ref: g,
13207
+ ref: x,
13188
13208
  tabIndex: -1,
13189
13209
  children: /* @__PURE__ */ C("div", {
13190
- ref: x,
13210
+ ref: D,
13191
13211
  style: hf
13192
13212
  })
13193
13213
  }),
@@ -13195,8 +13215,8 @@ var pf = 15, mf = { width: 1 }, hf = { height: 1 }, gf = ({ headers: e, rows: t,
13195
13215
  /* @__PURE__ */ C("div", { className: "updog__preview-table__corner updog__preview-table__corner--bottom-left" }),
13196
13216
  /* @__PURE__ */ C("div", { className: "updog__preview-table__corner updog__preview-table__corner--bottom-right" })
13197
13217
  ] }),
13198
- a && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-vertical" }),
13199
- a && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-horizontal" })
13218
+ i && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-vertical" }),
13219
+ i && /* @__PURE__ */ C("div", { className: "updog__preview-table-blur-horizontal" })
13200
13220
  ]
13201
13221
  });
13202
13222
  }, _f = s(null);
@@ -20892,7 +20912,7 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
20892
20912
  return this.state.hasError ? /* @__PURE__ */ C(_v, { error: vv }) : this.props.children;
20893
20913
  }
20894
20914
  }, bv = ({ leftSlot: e }) => {
20895
- let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = hb(), y = i && t === "editor", b = f(() => {
20915
+ let { variant: t, setShowUploader: n } = X(), { t: r } = K(), { isFirstStep: i, isLastStep: a, nextStep: o, prevStep: s, onImport: c, parsedCsv: l, xlsxFile: u, isParsing: d, isImporting: p, steps: m, activeStepIndex: h, selectedSheet: g, handleSheetConfirmed: _, remoteSourceLoading: v } = Bb(), y = i && t === "editor", b = f(() => {
20896
20916
  n(!1);
20897
20917
  }, [n]), x = m[h]?.id === "sheet-selection", S = f(() => {
20898
20918
  a ? c() : x ? _() : o();
@@ -21661,15 +21681,17 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21661
21681
  }
21662
21682
  return i;
21663
21683
  }, Hv = () => {
21664
- let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { parsedCsv: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = hb(), [l, u] = b(null), d = y(null), p = i?.headers ?? [], m = y(null);
21665
- m.current === null && (m.current = Vv(p, e, n));
21666
- let h = f((e, t) => {
21684
+ let { columns: e, enableCreateColumn: t, synonyms: n } = X(), { t: r } = K(), { headers: i, columnMapping: a, updateColumnMapping: o, pendingColumns: s, setPendingColumns: c } = Bb(), [l, u] = b(null), d = y(null), p = v(() => Vv(i, e, n), [
21685
+ i,
21686
+ e,
21687
+ n
21688
+ ]), m = f((e, t) => {
21667
21689
  if (t === "action:create") {
21668
21690
  d.current = e, u({ title: e });
21669
21691
  return;
21670
21692
  }
21671
21693
  o(e, t);
21672
- }, [o]), g = f((e) => {
21694
+ }, [o]), h = f((e) => {
21673
21695
  if (d.current === null) return;
21674
21696
  let t = Math.random().toString(36).slice(2, 7), n = `${Go}${e.title}-${t}`;
21675
21697
  c((t) => [...t, {
@@ -21677,59 +21699,64 @@ var ov = ({ text: e, onSelect: t }) => /* @__PURE__ */ C(J, {
21677
21699
  id: n,
21678
21700
  size: 150
21679
21701
  }]), o(d.current, n), d.current = null, u(null);
21680
- }, [o, c]), _ = f(() => {
21702
+ }, [o, c]), g = f(() => {
21681
21703
  d.current = null, u(null);
21682
- }, []), x = v(() => [...e.map((e) => e.title), ...s.map((e) => e.title)], [e, s]), S = v(() => {
21704
+ }, []), _ = v(() => [...e.map((e) => e.title), ...s.map((e) => e.title)], [e, s]), x = v(() => {
21683
21705
  let n = {
21684
21706
  text: r("dataEditor.uploader.matchColumns.bestMatch"),
21685
21707
  color: "green"
21686
- }, i = {
21708
+ }, a = {
21687
21709
  text: r("dataEditor.uploader.matchColumns.newColumnTag"),
21688
21710
  color: "blue"
21689
- }, a = r("dataEditor.uploader.matchColumns.createColumn");
21690
- return Object.fromEntries(p.map((r) => {
21691
- let o = m.current?.[r], c = e.map((e) => ({
21711
+ }, o = r("dataEditor.uploader.matchColumns.createColumn");
21712
+ return Object.fromEntries(i.map((r) => {
21713
+ let i = p[r], c = e.map((e) => ({
21692
21714
  id: e.id,
21693
21715
  text: e.title,
21694
- ...e.id === o && { tag: n }
21716
+ ...e.id === i && { tag: n }
21695
21717
  }));
21696
21718
  for (let e of s) c.push({
21697
21719
  id: e.id,
21698
21720
  text: e.title,
21699
- tag: i
21721
+ tag: a
21700
21722
  });
21701
21723
  return t && c.push({
21702
21724
  id: `${r}_d`,
21703
21725
  type: "divider"
21704
21726
  }, {
21705
21727
  id: Lv,
21706
- text: a,
21728
+ text: o,
21707
21729
  icon: /* @__PURE__ */ C(Ce, { size: "1rem" })
21708
21730
  }), [r, c];
21709
21731
  }));
21710
21732
  }, [
21711
- p,
21733
+ i,
21712
21734
  e,
21713
21735
  s,
21714
21736
  r,
21715
- t
21716
- ]), w = v(() => p.filter((e) => a[e]).length, [p, a]);
21737
+ t,
21738
+ p
21739
+ ]), S = v(() => i.filter((e) => a[e]).length, [i, a]);
21717
21740
  return {
21718
- headers: p,
21719
- matchedCount: w,
21720
- allMatched: w === p.length,
21741
+ headers: i,
21742
+ matchedCount: S,
21743
+ allMatched: S === i.length,
21721
21744
  placeholder: r("dataEditor.uploader.matchColumns.selectColumnPlaceholder"),
21722
- existingNames: x,
21745
+ existingNames: _,
21723
21746
  createModalValues: l,
21724
21747
  getRowData: f((e) => ({
21725
21748
  mappedValue: a[e],
21726
- options: S[e],
21727
- autoMatchId: m.current?.[e]
21728
- }), [a, S]),
21729
- onSelectChange: h,
21749
+ options: x[e],
21750
+ autoMatchId: p[e]
21751
+ }), [
21752
+ a,
21753
+ x,
21754
+ p
21755
+ ]),
21756
+ onSelectChange: m,
21730
21757
  onClear: o,
21731
- submitCreate: g,
21732
- closeCreate: _
21758
+ submitCreate: h,
21759
+ closeCreate: g
21733
21760
  };
21734
21761
  }, Uv = s(null);
21735
21762
  function Wv({ children: e }) {
@@ -21873,12 +21900,205 @@ var Gv = () => {
21873
21900
  /* @__PURE__ */ C(Yv, {})
21874
21901
  ]
21875
21902
  }), Zv = () => {
21876
- let { parsedCsv: e } = hb();
21903
+ let { parsedCsv: e } = Bb();
21877
21904
  return e ? /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
21878
21905
  className: "updog__step-column-matching__content updog__scrollbar",
21879
21906
  children: /* @__PURE__ */ C(Wv, { children: /* @__PURE__ */ C(Xv, {}) })
21880
21907
  }), /* @__PURE__ */ C(bv, {})] }) }) : null;
21881
- }, Qv = ({ open: e, existingOptions: t, initialName: n, onClose: r, onSubmit: i }) => {
21908
+ }, Qv = new Set([
21909
+ "true",
21910
+ "false",
21911
+ "yes",
21912
+ "no"
21913
+ ]), $v = /^\d{1,4}[-/.]\d{1,2}[-/.]\d{1,4}$/, ey = /^[-+]?(\d{1,3}([ ,.]\d{3})+|\d+)([.,]\d+)?%?$/, ty = new Set([
21914
+ "number",
21915
+ "date",
21916
+ "bool"
21917
+ ]);
21918
+ function ny(e) {
21919
+ if (e == null) return "empty";
21920
+ let t = String(e).trim();
21921
+ return t.length === 0 ? "empty" : Qv.has(t.toLowerCase()) ? "bool" : $v.test(t) ? "date" : ey.test(t) ? "number" : "text";
21922
+ }
21923
+ function ry(e) {
21924
+ return e.filter((e) => e != null && String(e).trim().length > 0).length;
21925
+ }
21926
+ function iy(e) {
21927
+ let t = /* @__PURE__ */ new Map(), n = 0, r = 0;
21928
+ for (let i of e) {
21929
+ let e = ry(i);
21930
+ if (e === 0) continue;
21931
+ let a = (t.get(e) ?? 0) + 1;
21932
+ t.set(e, a), a > n && (n = a, r = e);
21933
+ }
21934
+ return r;
21935
+ }
21936
+ function ay(e) {
21937
+ let t = 0;
21938
+ for (let n of e) t = Math.max(t, n.length);
21939
+ return t;
21940
+ }
21941
+ function oy(e, t, n) {
21942
+ if (t <= 0) return 0;
21943
+ let r = -1, i = 0;
21944
+ for (let a = 0; a < e.length; a++) if (ry(e[a]) === t) {
21945
+ if (r < 0 && (r = a), i++, i >= n) return r;
21946
+ } else r = -1, i = 0;
21947
+ for (let n = 0; n < e.length; n++) if (ry(e[n]) === t) return n;
21948
+ return 0;
21949
+ }
21950
+ function sy(e, t, n, r) {
21951
+ let i = /* @__PURE__ */ new Map();
21952
+ for (let a = t; a < n; a++) {
21953
+ let t = ny(e[a]?.[r]);
21954
+ t !== "empty" && i.set(t, (i.get(t) ?? 0) + 1);
21955
+ }
21956
+ let a = "empty", o = 0;
21957
+ for (let [e, t] of i) t > o && (o = t, a = e);
21958
+ return a;
21959
+ }
21960
+ function cy(e, t, n, r) {
21961
+ let i = 0, a = 0;
21962
+ for (let o = 0; o < r; o++) {
21963
+ let r = sy(e, t + 1, n, o);
21964
+ r !== "empty" && (a++, ny(e[t]?.[o]) === "text" && ty.has(r) && i++);
21965
+ }
21966
+ return a === 0 ? 0 : i / a;
21967
+ }
21968
+ function ly(e, t, n, r) {
21969
+ let i = 0, a = 0;
21970
+ for (let o = 0; o < r; o++) {
21971
+ let r = sy(e, t, n, o);
21972
+ if (r !== "empty") for (let s = t; s < n; s++) {
21973
+ let t = ny(e[s]?.[o]);
21974
+ t !== "empty" && (a++, t === r && i++);
21975
+ }
21976
+ }
21977
+ return a === 0 ? 0 : i / a;
21978
+ }
21979
+ function uy(e) {
21980
+ let t = e.map(ny).filter((e) => e !== "empty");
21981
+ return t.length === 0 ? 0 : 1 - t.filter((e) => e !== "text").length / t.length;
21982
+ }
21983
+ function dy(e, t) {
21984
+ if (t <= 0) return 0;
21985
+ let n = ry(e);
21986
+ return Math.max(0, 1 - Math.abs(n - t) / t);
21987
+ }
21988
+ function fy(e) {
21989
+ let t = e.map((e) => String(e ?? "").trim().toLowerCase()).filter((e) => e.length > 0);
21990
+ return t.length === 0 ? 0 : new Set(t).size / t.length;
21991
+ }
21992
+ function py(e, t, n, r, i) {
21993
+ return .45 * cy(e, t, n, r) + .25 * ly(e, t + 1, n, r) + .15 * uy(e[t] ?? []) + .1 * dy(e[t] ?? [], i) + .05 * fy(e[t] ?? []);
21994
+ }
21995
+ function my(e, t = 100) {
21996
+ if (e.length === 0) return {
21997
+ headerRowIndex: 0,
21998
+ dataStartIndex: 0,
21999
+ confidence: 0,
22000
+ mode: "header",
22001
+ review: { kind: "none" }
22002
+ };
22003
+ let n = Math.min(t, e.length), r = e.slice(0, n), i = ay(r), a = iy(r), o = oy(r, a, 3), s = e[o] ?? [], c = cy(e, o, n, i), l = ly(e, o + 1, n, i), u = ry(s) > 0 && uy(s) === 0, d = Math.round(Math.max(0, py(e, o, n, i, a)) * 100) / 100;
22004
+ if (u && c <= .15 && l >= .7) return {
22005
+ headerRowIndex: -1,
22006
+ dataStartIndex: o,
22007
+ confidence: d,
22008
+ mode: "no-header",
22009
+ review: { kind: "no-header" }
22010
+ };
22011
+ let f = d >= .55 ? { kind: "none" } : {
22012
+ kind: "ambiguous-row",
22013
+ confidence: d
22014
+ };
22015
+ return {
22016
+ headerRowIndex: o,
22017
+ dataStartIndex: o + 1,
22018
+ confidence: d,
22019
+ mode: "header",
22020
+ review: f
22021
+ };
22022
+ }
22023
+ function hy(e) {
22024
+ let t = /* @__PURE__ */ new Set();
22025
+ return e.map((e) => {
22026
+ let n = e, r = 2;
22027
+ for (; t.has(n);) n = `${e} (${r})`, r++;
22028
+ return t.add(n), n;
22029
+ });
22030
+ }
22031
+ //#endregion
22032
+ //#region src/components/DataUploader/components/StepHeaderSelection/context/useViewModel.tsx
22033
+ function gy(e, t, n, r) {
22034
+ return v(() => ({
22035
+ sample: e,
22036
+ selectedRow: t,
22037
+ selectRow: n,
22038
+ noHeader: r
22039
+ }), [
22040
+ e,
22041
+ t,
22042
+ n,
22043
+ r
22044
+ ]);
22045
+ }
22046
+ //#endregion
22047
+ //#region src/components/DataUploader/components/StepHeaderSelection/context/index.tsx
22048
+ var _y = s(null);
22049
+ function vy({ sample: e, selectedRow: t, selectRow: n, noHeader: r, children: i }) {
22050
+ let a = gy(e, t, n, r);
22051
+ return /* @__PURE__ */ C(_y.Provider, {
22052
+ value: a,
22053
+ children: i
22054
+ });
22055
+ }
22056
+ var yy = () => {
22057
+ let e = p(_y);
22058
+ if (!e) throw Error("useHeaderSelection must be used within HeaderSelectionProvider");
22059
+ return e;
22060
+ }, by = () => {
22061
+ let { sample: e, selectedRow: t, selectRow: n, noHeader: r } = yy(), { headers: i } = Bb(), { headers: a, rows: o } = v(() => {
22062
+ let t = i.length;
22063
+ return {
22064
+ headers: i.map((e) => r ? e : ""),
22065
+ rows: e.map((e) => Array.from({ length: t }, (t, n) => String(e[n] ?? "")))
22066
+ };
22067
+ }, [
22068
+ e,
22069
+ i,
22070
+ r
22071
+ ]);
22072
+ return /* @__PURE__ */ C(gf, {
22073
+ className: "updog__step-header-selection__preview",
22074
+ headers: a,
22075
+ rows: o,
22076
+ displayRows: e.length,
22077
+ blur: !1,
22078
+ selectedRow: r ? void 0 : t,
22079
+ onSelectRow: r ? void 0 : n
22080
+ });
22081
+ }, xy = () => {
22082
+ let { t: e } = K(), { parsedCsv: t, headerRowIndex: n, setHeaderRowIndex: r } = Bb(), i = f((e) => {
22083
+ r(e ? -1 : Math.max(0, t?.detection.headerRowIndex ?? 0));
22084
+ }, [r, t]);
22085
+ if (!t) return null;
22086
+ let a = t.rawRows.slice(0, 50), o = n < 0;
22087
+ return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ C(Jl, { children: /* @__PURE__ */ w(vy, {
22088
+ sample: a,
22089
+ selectedRow: o ? void 0 : n,
22090
+ selectRow: r,
22091
+ noHeader: o,
22092
+ children: [/* @__PURE__ */ w("div", {
22093
+ className: "updog__step-header-selection__content updog__scrollbar",
22094
+ children: [/* @__PURE__ */ C(Ni, {
22095
+ checked: o,
22096
+ onChange: i,
22097
+ label: e("dataEditor.uploader.headerSelection.noHeaderLabel")
22098
+ }), /* @__PURE__ */ C(by, {})]
22099
+ }), /* @__PURE__ */ C(bv, {})]
22100
+ }) }) });
22101
+ }, Sy = ({ open: e, existingOptions: t, initialName: n, onClose: r, onSubmit: i }) => {
21882
22102
  let { t: a } = K();
21883
22103
  return /* @__PURE__ */ C(Vi, {
21884
22104
  open: e,
@@ -21891,13 +22111,13 @@ var Gv = () => {
21891
22111
  onSubmit: i
21892
22112
  })
21893
22113
  });
21894
- }, $v = [
22114
+ }, Cy = [
21895
22115
  ",",
21896
22116
  ";",
21897
22117
  "|",
21898
22118
  "\n",
21899
22119
  " "
21900
- ], ey = (e, t, n) => {
22120
+ ], wy = (e, t, n) => {
21901
22121
  let r = new Set(n.map((e) => e.trim().toLowerCase())), i = (e) => r.has(e.trim().toLowerCase());
21902
22122
  if (e.trim() === "") return [];
21903
22123
  if (i(e)) return [e.trim()];
@@ -21909,80 +22129,144 @@ var Gv = () => {
21909
22129
  a.push(e);
21910
22130
  continue;
21911
22131
  }
21912
- a.push(...ty(e, t, i));
22132
+ a.push(...Ty(e, t, i));
21913
22133
  }
21914
22134
  }
21915
22135
  return a;
21916
- }, ty = (e, t, n) => {
21917
- for (let r of $v) {
22136
+ }, Ty = (e, t, n) => {
22137
+ for (let r of Cy) {
21918
22138
  if (r === t || !e.includes(r)) continue;
21919
22139
  let i = e.split(r).map((e) => e.trim()).filter((e) => e !== "");
21920
22140
  if (i.length >= 2 && i.every(n)) return i;
21921
22141
  }
21922
22142
  return [e];
21923
- }, ny = (e, t, n, r) => {
21924
- let i = /* @__PURE__ */ new Set();
21925
- for (let a of e) {
21926
- let e = a[t];
21927
- if (!(e === void 0 || e === "")) if (r) for (let t of ey(e, r, n)) i.add(t);
21928
- else i.add(e);
21929
- }
21930
- return [...i];
21931
- }, ry = () => {
21932
- let { columns: e } = X(), { t } = K(), { parsedCsv: n, columnMapping: r, valueMapping: i, autoValueMapping: a, updateValueMapping: o, multiselectDelimiters: s, setMultiselectDelimiter: c, reapplyMultiselectDelimiter: l, pendingOptions: u, addPendingOption: d } = hb(), [p, h] = b({}), [g, _] = b({}), [x, S] = b(null), w = y(!1), T = v(() => {
22143
+ }, Ey = (e, t, n) => {
22144
+ let r = /* @__PURE__ */ new Set();
22145
+ for (let i of e) if (i !== "") if (n) for (let e of wy(i, n, t)) r.add(e);
22146
+ else r.add(i);
22147
+ return [...r];
22148
+ }, Dy = (e) => !e.some((e) => e != null && String(e).trim() !== ""), Oy = (e, t) => {
22149
+ let n = 0;
22150
+ for (let r = t; r < e.length; r++) n = Math.max(n, e[r].length);
22151
+ return n;
22152
+ }, ky = 50, Ay = (e, t, n) => {
22153
+ let r = Math.min(e.length, t + ky);
22154
+ for (let i = t; i < r; i++) {
22155
+ let t = e[i];
22156
+ if (!t || Dy(t)) continue;
22157
+ let r = !0;
22158
+ for (let e = 0; e < n; e++) {
22159
+ let n = t[e];
22160
+ if (n == null || String(n).trim() === "") {
22161
+ r = !1;
22162
+ break;
22163
+ }
22164
+ }
22165
+ if (r) return Array.from({ length: n }, (e, n) => String(t[n]).trim());
22166
+ }
22167
+ return Array.from({ length: n }, (n, i) => {
22168
+ for (let n = t; n < r; n++) {
22169
+ let t = e[n];
22170
+ if (!t || Dy(t)) continue;
22171
+ let r = t[i], a = r == null ? "" : String(r).trim();
22172
+ if (a !== "") return a;
22173
+ }
22174
+ return "";
22175
+ });
22176
+ }, jy = (e, t) => t === e.headerRowIndex ? e.dataStartIndex : t + 1, My = (e, t, n, r) => {
22177
+ if (t < 0) {
22178
+ let t = Oy(e, n), i = Ay(e, n, t);
22179
+ return Array.from({ length: t }, (e, t) => r(t, i[t]));
22180
+ }
22181
+ return hy((e[t] ?? []).map((e) => String(e ?? "").trim()));
22182
+ }, Ny = () => ({
22183
+ headerRowIndex: 0,
22184
+ dataStartIndex: 1,
22185
+ confidence: 1,
22186
+ mode: "header",
22187
+ review: { kind: "none" }
22188
+ }), Py = (e, t) => {
22189
+ let n = [e];
22190
+ for (let r of t) n.push(e.map((e) => r[e] ?? ""));
22191
+ return n;
22192
+ }, Fy = (e) => {
22193
+ let t = /* @__PURE__ */ new Map();
22194
+ for (let n = 0; n < e.length; n++) t.set(e[n], n);
22195
+ return t;
22196
+ }, Iy = (e, t, n) => {
22197
+ let r = [];
22198
+ for (let i = t; i < e.length; i++) {
22199
+ let t = e[i];
22200
+ if (Dy(t)) continue;
22201
+ let a = t[n], o = a == null ? "" : String(a);
22202
+ o !== "" && r.push(o);
22203
+ }
22204
+ return r;
22205
+ }, Ly = (e, t) => {
22206
+ let n = {};
22207
+ for (let r = 0; r < t.length; r++) n[t[r]] = String(e[r] ?? "");
22208
+ return n;
22209
+ }, Ry = (e, t, n, r) => {
22210
+ let i = [];
22211
+ for (let a = n; a < e.length && i.length < r; a++) Dy(e[a]) || i.push(Ly(e[a], t));
22212
+ return i;
22213
+ }, zy = () => {
22214
+ let { columns: e } = X(), { t } = K(), { parsedCsv: n, headers: r, dataStartIndex: i, columnMapping: a, valueMapping: o, autoValueMapping: s, updateValueMapping: c, multiselectDelimiters: l, setMultiselectDelimiter: u, reapplyMultiselectDelimiter: d, pendingOptions: p, addPendingOption: h } = Bb(), [g, _] = b({}), [x, S] = b({}), [w, T] = b(null), E = y(!1), D = v(() => {
21933
22215
  if (!n) return [];
21934
- let t = [];
21935
- for (let [a, o] of Object.entries(r)) {
21936
- if (!o) continue;
21937
- let r = e.find((e) => e.id === o);
21938
- if (!r?.editor) continue;
21939
- let c = r.editor.type;
21940
- if (c !== "select" && c !== "multiselect") continue;
21941
- let l = r.editor.options, u = i[o] ?? {}, d = c === "multiselect", f = d ? s[o] ?? null : null, p = ny(n.rows, a, l, f).map((e) => ({
22216
+ let t = [], s = Fy(r);
22217
+ for (let [r, c] of Object.entries(a)) {
22218
+ if (!c) continue;
22219
+ let a = e.find((e) => e.id === c);
22220
+ if (!a?.editor) continue;
22221
+ let u = a.editor.type;
22222
+ if (u !== "select" && u !== "multiselect") continue;
22223
+ let d = a.editor.options, f = o[c] ?? {}, p = u === "multiselect", m = p ? l[c] ?? null : null, h = s.get(r), g = Ey(h === void 0 ? [] : Iy(n.rawRows, i, h), d, m).map((e) => ({
21942
22224
  imported: e,
21943
- mapped: u[e]
22225
+ mapped: f[e]
21944
22226
  }));
21945
- p.sort((e, t) => e.imported.localeCompare(t.imported));
21946
- let m = p.filter((e) => e.mapped !== void 0).length;
22227
+ g.sort((e, t) => e.imported.localeCompare(t.imported));
22228
+ let _ = g.filter((e) => e.mapped !== void 0).length;
21947
22229
  t.push({
21948
- columnId: o,
21949
- columnTitle: r.title,
21950
- options: l,
21951
- enableCustomValue: r.editor.enableCustomValue !== !1,
21952
- isMultiselect: d,
21953
- delimiter: f,
21954
- values: p,
21955
- matchedCount: m,
21956
- allMatched: m === p.length
22230
+ columnId: c,
22231
+ columnTitle: a.title,
22232
+ options: d,
22233
+ enableCustomValue: a.editor.enableCustomValue !== !1,
22234
+ isMultiselect: p,
22235
+ delimiter: m,
22236
+ values: g,
22237
+ matchedCount: _,
22238
+ allMatched: _ === g.length
21957
22239
  });
21958
22240
  }
21959
22241
  return t;
21960
22242
  }, [
21961
22243
  n,
21962
22244
  r,
21963
- e,
21964
22245
  i,
21965
- s
22246
+ a,
22247
+ e,
22248
+ o,
22249
+ l
21966
22250
  ]);
21967
22251
  m(() => {
21968
- if (w.current || T.length === 0) return;
21969
- w.current = !0;
22252
+ if (E.current || D.length === 0) return;
22253
+ E.current = !0;
21970
22254
  let e = {};
21971
- for (let t of T) t.allMatched && (e[t.columnId] = !0);
21972
- _(e);
21973
- }, [T]);
21974
- let E = v(() => {
22255
+ for (let t of D) t.allMatched && (e[t.columnId] = !0);
22256
+ S(e);
22257
+ }, [D]);
22258
+ let O = v(() => {
21975
22259
  let e = {
21976
22260
  text: t("dataEditor.uploader.matchColumns.bestMatch"),
21977
22261
  color: "green"
21978
22262
  }, n = t("dataEditor.uploader.matchValues.createOption"), r = {};
21979
- for (let t of T) {
21980
- let i = u[t.columnId] ?? [], o = {};
22263
+ for (let t of D) {
22264
+ let i = p[t.columnId] ?? [], a = {};
21981
22265
  for (let r of t.values) {
21982
- let s = a[t.columnId]?.[r.imported], c = new Set(t.options), l = t.options.map((t) => ({
22266
+ let o = s[t.columnId]?.[r.imported], c = new Set(t.options), l = t.options.map((t) => ({
21983
22267
  id: t,
21984
22268
  text: t,
21985
- ...t === s && { tag: e }
22269
+ ...t === o && { tag: e }
21986
22270
  }));
21987
22271
  if (t.enableCustomValue) {
21988
22272
  for (let e of i) c.has(e) || (l.push({
@@ -21998,81 +22282,81 @@ var Gv = () => {
21998
22282
  icon: /* @__PURE__ */ C(Ce, { size: "1rem" })
21999
22283
  });
22000
22284
  }
22001
- o[r.imported] = l;
22285
+ a[r.imported] = l;
22002
22286
  }
22003
- r[t.columnId] = o;
22287
+ r[t.columnId] = a;
22004
22288
  }
22005
22289
  return r;
22006
22290
  }, [
22007
- T,
22008
- a,
22009
- u,
22291
+ D,
22292
+ s,
22293
+ p,
22010
22294
  t
22011
- ]), D = f((e) => p[e] ?? !0, [p]), O = f((e) => g[e] ?? !1, [g]), k = f((e) => {
22012
- let t = p[e.columnId] ?? !0;
22295
+ ]), k = f((e) => g[e] ?? !0, [g]), A = f((e) => x[e] ?? !1, [x]), j = f((e) => {
22296
+ let t = g[e.columnId] ?? !0;
22013
22297
  return e.values.filter((e) => t || e.mapped === void 0);
22014
- }, [p]), A = f((e, t) => E[e]?.[t] ?? [], [E]), j = f((e, t) => {
22015
- h((n) => ({
22298
+ }, [g]), M = f((e, t) => O[e]?.[t] ?? [], [O]), N = f((e, t) => {
22299
+ _((n) => ({
22016
22300
  ...n,
22017
22301
  [e]: t
22018
22302
  }));
22019
- }, []), M = f((e) => {
22020
- _((t) => ({
22303
+ }, []), P = f((e) => {
22304
+ S((t) => ({
22021
22305
  ...t,
22022
22306
  [e]: !t[e]
22023
22307
  }));
22024
- }, []), N = f((e, t, n) => {
22308
+ }, []), F = f((e, t, n) => {
22025
22309
  if (n === "action:create-option") {
22026
- S({
22310
+ T({
22027
22311
  columnId: e,
22028
22312
  imported: t
22029
22313
  });
22030
22314
  return;
22031
22315
  }
22032
- o(e, t, n);
22033
- }, [o]), P = f((e, t) => {
22034
- c(e, t === "" ? null : t);
22035
- }, [c]), F = f((e) => {
22036
- l(e);
22037
- }, [l]), I = f((e) => {
22038
- x && (d(x.columnId, e), o(x.columnId, x.imported, e), S(null));
22316
+ c(e, t, n);
22317
+ }, [c]), I = f((e, t) => {
22318
+ u(e, t === "" ? null : t);
22319
+ }, [u]), L = f((e) => {
22320
+ d(e);
22321
+ }, [d]), R = f((e) => {
22322
+ w && (h(w.columnId, e), c(w.columnId, w.imported, e), T(null));
22039
22323
  }, [
22040
- x,
22041
- d,
22042
- o
22043
- ]), L = f(() => S(null), []);
22324
+ w,
22325
+ h,
22326
+ c
22327
+ ]), z = f(() => T(null), []);
22044
22328
  return {
22045
- sections: T,
22046
- selectOptionsByValue: E,
22047
- createForOptions: v(() => T.find((e) => e.columnId === x?.columnId)?.options ?? [], [T, x]),
22048
- hasCreateTarget: x !== null,
22049
- createInitialName: x?.imported ?? "",
22050
- isShowMatched: D,
22051
- isCollapsed: O,
22052
- getVisibleValues: k,
22053
- getSelectOptions: A,
22054
- setShowMatched: j,
22055
- toggleCollapsed: M,
22056
- selectValue: N,
22057
- changeDelimiter: P,
22058
- reapplyDelimiter: F,
22059
- submitCreate: I,
22060
- closeCreate: L
22329
+ sections: D,
22330
+ selectOptionsByValue: O,
22331
+ createForOptions: v(() => D.find((e) => e.columnId === w?.columnId)?.options ?? [], [D, w]),
22332
+ hasCreateTarget: w !== null,
22333
+ createInitialName: w?.imported ?? "",
22334
+ isShowMatched: k,
22335
+ isCollapsed: A,
22336
+ getVisibleValues: j,
22337
+ getSelectOptions: M,
22338
+ setShowMatched: N,
22339
+ toggleCollapsed: P,
22340
+ selectValue: F,
22341
+ changeDelimiter: I,
22342
+ reapplyDelimiter: L,
22343
+ submitCreate: R,
22344
+ closeCreate: z
22061
22345
  };
22062
- }, iy = s(null);
22063
- function ay({ children: e }) {
22064
- let t = ry();
22065
- return /* @__PURE__ */ C(iy.Provider, {
22346
+ }, By = s(null);
22347
+ function Vy({ children: e }) {
22348
+ let t = zy();
22349
+ return /* @__PURE__ */ C(By.Provider, {
22066
22350
  value: t,
22067
22351
  children: e
22068
22352
  });
22069
22353
  }
22070
- var oy = () => {
22071
- let e = p(iy);
22354
+ var Hy = () => {
22355
+ let e = p(By);
22072
22356
  if (!e) throw Error("useValueMatching must be used within ValueMatchingProvider");
22073
22357
  return e;
22074
- }, sy = ({ section: e }) => {
22075
- let { t } = K(), { isShowMatched: n, isCollapsed: r, setShowMatched: i, toggleCollapsed: a } = oy(), o = r(e.columnId), s = t(o ? "dataEditor.common.expand" : "dataEditor.common.collapse"), c = f((t) => i(e.columnId, t), [i, e.columnId]), l = f(() => a(e.columnId), [a, e.columnId]);
22358
+ }, Uy = ({ section: e }) => {
22359
+ let { t } = K(), { isShowMatched: n, isCollapsed: r, setShowMatched: i, toggleCollapsed: a } = Hy(), o = r(e.columnId), s = t(o ? "dataEditor.common.expand" : "dataEditor.common.collapse"), c = f((t) => i(e.columnId, t), [i, e.columnId]), l = f(() => a(e.columnId), [a, e.columnId]);
22076
22360
  return /* @__PURE__ */ w("header", {
22077
22361
  className: "updog__value-matching__section-header",
22078
22362
  children: [/* @__PURE__ */ C("div", {
@@ -22116,14 +22400,14 @@ var oy = () => {
22116
22400
  })
22117
22401
  })]
22118
22402
  });
22119
- }, cy = {
22403
+ }, Wy = {
22120
22404
  ",": ",",
22121
22405
  ";": ";",
22122
22406
  "|": "|",
22123
22407
  "\n": "\\n",
22124
22408
  " ": "\\t"
22125
- }, ly = (e) => e === null ? "" : cy[e] ?? e, uy = ({ section: e }) => {
22126
- let { t } = K(), { changeDelimiter: n, reapplyDelimiter: r } = oy(), i = y(e.delimiter), a = ly(e.delimiter), [o, s] = b(a), { debouncedValue: c } = za(o, 300), l = y(a);
22409
+ }, Gy = (e) => e === null ? "" : Wy[e] ?? e, Ky = ({ section: e }) => {
22410
+ let { t } = K(), { changeDelimiter: n, reapplyDelimiter: r } = Hy(), i = y(e.delimiter), a = Gy(e.delimiter), [o, s] = b(a), { debouncedValue: c } = za(o, 300), l = y(a);
22127
22411
  m(() => {
22128
22412
  s(a), l.current = a;
22129
22413
  }, [a]), m(() => {
@@ -22166,8 +22450,8 @@ var oy = () => {
22166
22450
  })
22167
22451
  ]
22168
22452
  });
22169
- }, dy = ({ section: e, val: t }) => {
22170
- let { t: n } = K(), { getSelectOptions: r, selectValue: i } = oy(), a = t.mapped === void 0, o = f((n) => i(e.columnId, t.imported, n), [
22453
+ }, qy = ({ section: e, val: t }) => {
22454
+ let { t: n } = K(), { getSelectOptions: r, selectValue: i } = Hy(), a = t.mapped === void 0, o = f((n) => i(e.columnId, t.imported, n), [
22171
22455
  i,
22172
22456
  e.columnId,
22173
22457
  t.imported
@@ -22219,8 +22503,8 @@ var oy = () => {
22219
22503
  })
22220
22504
  ]
22221
22505
  });
22222
- }, fy = ({ section: e }) => {
22223
- let { t } = K(), { getVisibleValues: n } = oy(), r = n(e);
22506
+ }, Jy = ({ section: e }) => {
22507
+ let { t } = K(), { getVisibleValues: n } = Hy(), r = n(e);
22224
22508
  return /* @__PURE__ */ w("div", {
22225
22509
  className: "updog__value-matching__table",
22226
22510
  children: [r.length === 0 ? /* @__PURE__ */ C("div", {
@@ -22240,7 +22524,7 @@ var oy = () => {
22240
22524
  size: "sm",
22241
22525
  weight: "medium",
22242
22526
  children: t("dataEditor.uploader.matchValues.importedValues")
22243
- }), e.isMultiselect && /* @__PURE__ */ C(uy, { section: e })]
22527
+ }), e.isMultiselect && /* @__PURE__ */ C(Ky, { section: e })]
22244
22528
  }),
22245
22529
  /* @__PURE__ */ C("div", { className: "updog__value-matching__arrow-spacer" }),
22246
22530
  /* @__PURE__ */ C(q, {
@@ -22252,25 +22536,25 @@ var oy = () => {
22252
22536
  }),
22253
22537
  /* @__PURE__ */ C("div", { className: "updog__value-matching__action" })
22254
22538
  ]
22255
- }), r.map((t) => /* @__PURE__ */ C(dy, {
22539
+ }), r.map((t) => /* @__PURE__ */ C(qy, {
22256
22540
  section: e,
22257
22541
  val: t
22258
22542
  }, t.imported))]
22259
22543
  });
22260
- }, py = ({ section: e }) => {
22261
- let { isCollapsed: t } = oy(), n = !t(e.columnId);
22544
+ }, Yy = ({ section: e }) => {
22545
+ let { isCollapsed: t } = Hy(), n = !t(e.columnId);
22262
22546
  return /* @__PURE__ */ w("div", {
22263
22547
  className: "updog__value-matching__section",
22264
- children: [/* @__PURE__ */ C(sy, { section: e }), /* @__PURE__ */ C("div", {
22548
+ children: [/* @__PURE__ */ C(Uy, { section: e }), /* @__PURE__ */ C("div", {
22265
22549
  className: E("updog__value-matching__collapsible", n && "updog__value-matching__collapsible--expanded"),
22266
- children: /* @__PURE__ */ C(fy, { section: e })
22550
+ children: /* @__PURE__ */ C(Jy, { section: e })
22267
22551
  })]
22268
22552
  });
22269
- }, my = () => {
22270
- let { sections: e, hasCreateTarget: t, createForOptions: n, createInitialName: r, submitCreate: i, closeCreate: a } = oy();
22553
+ }, Xy = () => {
22554
+ let { sections: e, hasCreateTarget: t, createForOptions: n, createInitialName: r, submitCreate: i, closeCreate: a } = Hy();
22271
22555
  return /* @__PURE__ */ w("div", {
22272
22556
  className: "updog__value-matching",
22273
- children: [e.map((e) => /* @__PURE__ */ C(py, { section: e }, e.columnId)), t && /* @__PURE__ */ C(Qv, {
22557
+ children: [e.map((e) => /* @__PURE__ */ C(Yy, { section: e }, e.columnId)), t && /* @__PURE__ */ C(Sy, {
22274
22558
  open: !0,
22275
22559
  existingOptions: n,
22276
22560
  initialName: r,
@@ -22278,22 +22562,26 @@ var oy = () => {
22278
22562
  onSubmit: i
22279
22563
  })]
22280
22564
  });
22281
- }, hy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22565
+ }, Zy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22282
22566
  className: "updog__step-match-values__content updog__scrollbar",
22283
- children: /* @__PURE__ */ C(ay, { children: /* @__PURE__ */ C(my, {}) })
22284
- }), /* @__PURE__ */ C(bv, {})] }) }), gy = 20, _y = () => {
22285
- let { store: e } = X(), { t } = K(), { primaryKey: n, onPrimaryKeyChange: r, parsedCsv: i, columnMapping: a, primaryKeyColumns: o } = hb(), s = e.isClient(), c = f(() => r(null), [r]), l = v(() => {
22567
+ children: /* @__PURE__ */ C(Vy, { children: /* @__PURE__ */ C(Xy, {}) })
22568
+ }), /* @__PURE__ */ C(bv, {})] }) }), Qy = 20, $y = () => {
22569
+ let { store: e } = X(), { t } = K(), { primaryKey: n, onPrimaryKeyChange: r, parsedCsv: i, headers: a, dataStartIndex: o, columnMapping: s, primaryKeyColumns: c } = Bb(), l = e.isClient(), u = f(() => r(null), [r]), d = v(() => {
22286
22570
  let e = {};
22287
- for (let [t, n] of Object.entries(a)) n && (e[n] = t);
22571
+ for (let [t, n] of Object.entries(s)) n && (e[n] = t);
22288
22572
  return e;
22289
- }, [a]), u = i?.rows.slice(0, gy) ?? [];
22573
+ }, [s]), p = v(() => i ? Ry(i.rawRows, a, o, Qy) : [], [
22574
+ i,
22575
+ a,
22576
+ o
22577
+ ]);
22290
22578
  return /* @__PURE__ */ w("div", {
22291
22579
  className: "updog__primary-key-selection updog__scrollbar",
22292
- children: [s && /* @__PURE__ */ w(Ra, {
22580
+ children: [l && /* @__PURE__ */ w(Ra, {
22293
22581
  name: "primaryKey",
22294
22582
  value: "",
22295
22583
  checked: n === null,
22296
- onChange: c,
22584
+ onChange: u,
22297
22585
  radioPosition: "end",
22298
22586
  className: E("updog__primary-key-selection__card", n === null && "updog__primary-key-selection__card--selected"),
22299
22587
  children: [/* @__PURE__ */ C(q, {
@@ -22306,8 +22594,8 @@ var oy = () => {
22306
22594
  className: "updog__primary-key-selection__value-text updog__primary-key-selection__value-none",
22307
22595
  children: t("dataEditor.uploader.primaryKey.noneHint")
22308
22596
  })]
22309
- }), o.map((e) => {
22310
- let t = l[e.id], i = t ? u.map((e) => e[t] ?? "") : [];
22597
+ }), c.map((e) => {
22598
+ let t = d[e.id], i = t ? p.map((e) => e[t] ?? "") : [];
22311
22599
  return /* @__PURE__ */ w(Ra, {
22312
22600
  name: "primaryKey",
22313
22601
  value: e.id,
@@ -22334,8 +22622,8 @@ var oy = () => {
22334
22622
  }, e.id);
22335
22623
  })]
22336
22624
  });
22337
- }, vy = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(_y, {}), /* @__PURE__ */ C(bv, {})] }) }), yy = () => {
22338
- let { columns: e, importFormats: t, remoteSources: n, sampleData: r } = X(), i = t === !1 ? [] : t, { t: a } = K(), { parsedCsv: o, xlsxFile: s, handleFileRemoved: c, parseFile: l, isParsing: u, remoteSourceLoading: d, remoteSourceError: p, handleRemoteSourceSelect: m } = hb(), h = [
22625
+ }, eb = () => /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C($y, {}), /* @__PURE__ */ C(bv, {})] }) }), tb = () => {
22626
+ let { columns: e, importFormats: t, remoteSources: n, sampleData: r } = X(), i = t === !1 ? [] : t, { t: a } = K(), { parsedCsv: o, xlsxFile: s, handleFileRemoved: c, parseFile: l, isParsing: u, remoteSourceLoading: d, remoteSourceError: p, handleRemoteSourceSelect: m } = Bb(), h = [
22339
22627
  {
22340
22628
  id: "csv",
22341
22629
  format: "csv",
@@ -22393,20 +22681,20 @@ var oy = () => {
22393
22681
  }, [c]),
22394
22682
  handleRemoteSourceSelect: m
22395
22683
  };
22396
- }, by = s(null);
22397
- function xy({ children: e }) {
22398
- let t = yy();
22399
- return /* @__PURE__ */ C(by.Provider, {
22684
+ }, nb = s(null);
22685
+ function rb({ children: e }) {
22686
+ let t = tb();
22687
+ return /* @__PURE__ */ C(nb.Provider, {
22400
22688
  value: t,
22401
22689
  children: e
22402
22690
  });
22403
22691
  }
22404
- var Sy = () => {
22405
- let e = p(by);
22692
+ var ib = () => {
22693
+ let e = p(nb);
22406
22694
  if (!e) throw Error("useSelectFiles must be used within SelectFilesProvider");
22407
22695
  return e;
22408
- }, Cy = () => {
22409
- let { t: e } = K(), { exampleMenuOptions: t, onExampleDownload: n } = Sy();
22696
+ }, ab = () => {
22697
+ let { t: e } = K(), { exampleMenuOptions: t, onExampleDownload: n } = ib();
22410
22698
  return /* @__PURE__ */ C(Fa, {
22411
22699
  options: t,
22412
22700
  onSelect: n,
@@ -22418,7 +22706,7 @@ var Sy = () => {
22418
22706
  children: e("dataEditor.uploader.uploadFile.downloadExample")
22419
22707
  })
22420
22708
  });
22421
- }, wy = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */ C("span", {
22709
+ }, ob = ({ source: e }) => e.icon.trimStart().startsWith("<") ? /* @__PURE__ */ C("span", {
22422
22710
  className: "updog__remote-source-btn__icon",
22423
22711
  dangerouslySetInnerHTML: { __html: e.icon }
22424
22712
  }) : /* @__PURE__ */ C("span", {
@@ -22427,7 +22715,7 @@ var Sy = () => {
22427
22715
  src: e.icon,
22428
22716
  alt: e.label
22429
22717
  })
22430
- }), Ty = ({ source: e, loading: t, disabled: n, onSelect: r }) => /* @__PURE__ */ C(J, {
22718
+ }), sb = ({ source: e, loading: t, disabled: n, onSelect: r }) => /* @__PURE__ */ C(J, {
22431
22719
  variant: "filled",
22432
22720
  color: "neutral",
22433
22721
  size: "sm",
@@ -22437,11 +22725,11 @@ var Sy = () => {
22437
22725
  disabled: !t && n,
22438
22726
  loading: t,
22439
22727
  spinnerPosition: "start",
22440
- startIcon: /* @__PURE__ */ C(wy, { source: e }),
22728
+ startIcon: /* @__PURE__ */ C(ob, { source: e }),
22441
22729
  title: e.description,
22442
22730
  children: e.label
22443
- }), Ey = () => {
22444
- let { t: e } = K(), { importFormats: t, remoteSources: n, remoteSourceLoading: r, remoteSourceError: i, handleRemoteSourceSelect: a } = Sy(), o = n.length > 0;
22731
+ }), cb = () => {
22732
+ let { t: e } = K(), { importFormats: t, remoteSources: n, remoteSourceLoading: r, remoteSourceError: i, handleRemoteSourceSelect: a } = ib(), o = n.length > 0;
22445
22733
  return /* @__PURE__ */ w("div", {
22446
22734
  className: "updog__source-picker",
22447
22735
  children: [
@@ -22468,7 +22756,7 @@ var Sy = () => {
22468
22756
  }),
22469
22757
  o && /* @__PURE__ */ w(S, { children: [/* @__PURE__ */ C(Oa, {}), /* @__PURE__ */ C("div", {
22470
22758
  className: "updog__source-picker__sources-list",
22471
- children: n.map((e) => /* @__PURE__ */ C(Ty, {
22759
+ children: n.map((e) => /* @__PURE__ */ C(sb, {
22472
22760
  source: e,
22473
22761
  loading: r === e.id,
22474
22762
  disabled: !!r,
@@ -22482,7 +22770,7 @@ var Sy = () => {
22482
22770
  })
22483
22771
  ]
22484
22772
  });
22485
- }, Dy = () => {
22773
+ }, lb = () => {
22486
22774
  let { t: e } = K();
22487
22775
  return /* @__PURE__ */ w("div", {
22488
22776
  className: "updog__uploading-state",
@@ -22495,12 +22783,12 @@ var Sy = () => {
22495
22783
  children: e("dataEditor.uploader.uploadFile.uploading")
22496
22784
  })]
22497
22785
  });
22498
- }, Oy = () => {
22499
- let { t: e } = K(), { isBlocked: t, isParsing: n, hasFile: r, fileName: i, open: a, onRemoveClick: o } = Sy();
22786
+ }, ub = () => {
22787
+ let { t: e } = K(), { isBlocked: t, isParsing: n, hasFile: r, fileName: i, open: a, onRemoveClick: o } = ib();
22500
22788
  return /* @__PURE__ */ C("div", {
22501
22789
  className: E("updog__step-select-files__upload-area", t && "updog__step-select-files__upload-area--disabled"),
22502
22790
  onClick: t ? void 0 : a,
22503
- children: n ? /* @__PURE__ */ C(Dy, {}) : /* @__PURE__ */ w(S, { children: [
22791
+ children: n ? /* @__PURE__ */ C(lb, {}) : /* @__PURE__ */ w(S, { children: [
22504
22792
  /* @__PURE__ */ C("div", {
22505
22793
  className: "updog__step-select-files__icon-container",
22506
22794
  children: r ? /* @__PURE__ */ C(I, {
@@ -22511,7 +22799,7 @@ var Sy = () => {
22511
22799
  className: "updog__step-select-files__icon"
22512
22800
  })
22513
22801
  }),
22514
- !r && /* @__PURE__ */ C(Ey, {}),
22802
+ !r && /* @__PURE__ */ C(cb, {}),
22515
22803
  r && /* @__PURE__ */ w("div", {
22516
22804
  className: "updog__step-select-files__info",
22517
22805
  children: [/* @__PURE__ */ C(q, {
@@ -22528,19 +22816,19 @@ var Sy = () => {
22528
22816
  })
22529
22817
  ] })
22530
22818
  });
22531
- }, ky = () => {
22532
- let { getRootProps: e, getInputProps: t, isDragActive: n } = Sy();
22819
+ }, db = () => {
22820
+ let { getRootProps: e, getInputProps: t, isDragActive: n } = ib();
22533
22821
  return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w("div", {
22534
22822
  className: "updog__step-select-files__dropzone",
22535
22823
  ...e(),
22536
22824
  children: [
22537
22825
  /* @__PURE__ */ C("input", { ...t() }),
22538
- /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(Oy, {}), /* @__PURE__ */ C(bv, { leftSlot: /* @__PURE__ */ C(Cy, {}) })] }),
22826
+ /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C(ub, {}), /* @__PURE__ */ C(bv, { leftSlot: /* @__PURE__ */ C(ab, {}) })] }),
22539
22827
  n && /* @__PURE__ */ C(Yl, {})
22540
22828
  ]
22541
22829
  }) });
22542
- }, Ay = () => /* @__PURE__ */ C(xy, { children: /* @__PURE__ */ C(ky, {}) }), jy = ({ preview: e }) => {
22543
- let { selectedSheet: t, setSelectedSheet: n } = hb(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22830
+ }, fb = () => /* @__PURE__ */ C(rb, { children: /* @__PURE__ */ C(db, {}) }), pb = ({ preview: e }) => {
22831
+ let { selectedSheet: t, setSelectedSheet: n } = Bb(), { t: r } = K(), i = Math.max(0, e.totalRows), a = t === e.name, o = v(() => {
22544
22832
  let { headers: t, rows: n } = e;
22545
22833
  return n.map((e) => t.map((t) => e[t] ?? ""));
22546
22834
  }, [e]);
@@ -22577,16 +22865,16 @@ var Sy = () => {
22577
22865
  })]
22578
22866
  })
22579
22867
  });
22580
- }, My = () => {
22581
- let { sheetPreviews: e } = hb();
22868
+ }, mb = () => {
22869
+ let { sheetPreviews: e } = Bb();
22582
22870
  return /* @__PURE__ */ C(Xl, { children: /* @__PURE__ */ w(Jl, { children: [/* @__PURE__ */ C("div", {
22583
22871
  className: "updog__sheet-preview-wrapper updog__scrollbar",
22584
22872
  children: /* @__PURE__ */ C("div", {
22585
22873
  className: "updog__sheet-preview-grid",
22586
- children: e.map((e) => /* @__PURE__ */ C(jy, { preview: e }, e.name))
22874
+ children: e.map((e) => /* @__PURE__ */ C(pb, { preview: e }, e.name))
22587
22875
  })
22588
22876
  }), /* @__PURE__ */ C(bv, {})] }) });
22589
- }, Ny = (e, t, n) => {
22877
+ }, hb = (e, t, n) => {
22590
22878
  let r = new Map(t.map((e) => [e.id, e])), i = [];
22591
22879
  for (let [t, a] of Object.entries(e)) a && i.push({
22592
22880
  csvHeader: t,
@@ -22594,11 +22882,11 @@ var Sy = () => {
22594
22882
  column: n.has(a) ? void 0 : r.get(a)
22595
22883
  });
22596
22884
  return i;
22597
- }, Py = (e) => {
22885
+ }, gb = (e) => {
22598
22886
  let t = [];
22599
22887
  for (let { csvHeader: n, column: r } of e) r?.editor?.type === "number" && t.push(n);
22600
22888
  return t;
22601
- }, Fy = (e, t, n) => {
22889
+ }, _b = (e, t, n) => {
22602
22890
  let r = {};
22603
22891
  for (let { csvHeader: i, columnId: a, column: o } of t) {
22604
22892
  let t = e[i] ?? "";
@@ -22613,7 +22901,7 @@ var Sy = () => {
22613
22901
  continue;
22614
22902
  }
22615
22903
  if (s === "multiselect") {
22616
- let e = n.multiselectDelimiters[a], i = o.editor.options ?? [], s = e ? ey(t, e, i) : t === "" ? [] : [t], c = [], l = /* @__PURE__ */ new Set();
22904
+ let e = n.multiselectDelimiters[a], i = o.editor.options ?? [], s = e ? wy(t, e, i) : t === "" ? [] : [t], c = [], l = /* @__PURE__ */ new Set();
22617
22905
  for (let e of s) {
22618
22906
  let t = n.valueMapping[a]?.[e.trim()];
22619
22907
  t !== void 0 && !l.has(t) && (l.add(t), c.push(t));
@@ -22625,88 +22913,16 @@ var Sy = () => {
22625
22913
  r[a] = o.transformer ? o.transformer(c) : c;
22626
22914
  }
22627
22915
  return r;
22628
- }, Iy = /^-?\d+([.,]\d+)?%?$/, Ly = /^\d{1,4}[-/.]\d{1,2}[-/.]\d{1,4}$/, Ry = new Set([
22629
- "true",
22630
- "false",
22631
- "yes",
22632
- "no"
22633
- ]), zy = 50;
22634
- function By(e) {
22635
- return !!(Iy.test(e) || Ly.test(e) || Ry.has(e.toLowerCase()));
22636
- }
22637
- function Vy(e) {
22638
- return e.filter((e) => e != null && String(e).trim().length > 0).length;
22639
- }
22640
- function Hy(e) {
22641
- let t = /* @__PURE__ */ new Map(), n = 0, r = 0;
22642
- for (let i of e) {
22643
- let e = Vy(i);
22644
- if (e === 0) continue;
22645
- let a = (t.get(e) ?? 0) + 1;
22646
- t.set(e, a), a > n && (n = a, r = e);
22647
- }
22648
- return r;
22649
- }
22650
- function Uy(e, t) {
22651
- let n = e.map((e) => String(e ?? "").trim()), r = n.filter((e) => e.length > 0);
22652
- if (r.length === 0) return 0;
22653
- let i = r.filter((e) => By(e)).length === 0 ? 1 : 0, a = r.length / Math.max(n.length, 1), o = new Set(r.map((e) => e.toLowerCase())).size / r.length, s = r.filter((e) => e.length <= zy).length / r.length, c = t > 0 ? 1 - Math.abs(r.length - t) / t : 0;
22654
- return .3 * i + .25 * a + .2 * o + .15 * s + .1 * Math.max(0, c);
22655
- }
22656
- function Wy(e, t = 100) {
22657
- if (e.length === 0) return {
22658
- headerRowIndex: 0,
22659
- confidence: 0
22660
- };
22661
- if (e.length === 1) return {
22662
- headerRowIndex: 0,
22663
- confidence: 1
22664
- };
22665
- let n = Math.min(t, e.length), r = Hy(e.slice(0, n)), i = 0, a = -1;
22666
- for (let t = 0; t < n; t++) {
22667
- let n = Uy(e[t], r);
22668
- if (n > a && (a = n, i = t), t === 0 && n > .85 && Vy(e[0]) === r) break;
22669
- }
22670
- return {
22671
- headerRowIndex: i,
22672
- confidence: Math.round(a * 100) / 100
22673
- };
22674
- }
22675
- function Gy(e) {
22676
- let t = /* @__PURE__ */ new Set();
22677
- return e.map((e) => {
22678
- let n = e, r = 2;
22679
- for (; t.has(n);) n = `${e} (${r})`, r++;
22680
- return t.add(n), n;
22681
- });
22682
- }
22683
- function Ky(e) {
22684
- let { headerRowIndex: t } = Wy(e), n = Gy((e[t] ?? []).map((e) => String(e ?? "").trim())), r = [], i = [];
22685
- for (let a of e.slice(t + 1)) {
22686
- if (!a.some((e) => e != null && String(e).trim() !== "")) continue;
22687
- let e = {};
22688
- for (let t = 0; t < n.length; t++) e[n[t]] = String(a[t] ?? "");
22689
- r.push(e), i.push(a.length === n.length ? null : a.map((e) => String(e ?? "")));
22690
- }
22691
- return {
22692
- headerRowIndex: t,
22693
- headers: n,
22694
- rows: r,
22695
- rawCells: i
22696
- };
22697
- }
22698
- //#endregion
22699
- //#region src/components/DataUploader/utils/detectMultiValueDelimiter.ts
22700
- var qy = 200, Jy = (e, t, n) => {
22916
+ }, vb = 200, yb = (e, t, n) => {
22701
22917
  if (n) return n;
22702
22918
  let r = new Set(t.map((e) => e.trim().toLowerCase())), i = (e) => r.has(e.trim().toLowerCase()), a = /* @__PURE__ */ new Set(), o = [];
22703
22919
  for (let t of e) {
22704
22920
  let e = t.trim();
22705
- if (!(e === "" || a.has(e)) && (a.add(e), o.push(e), o.length >= qy)) break;
22921
+ if (!(e === "" || a.has(e)) && (a.add(e), o.push(e), o.length >= vb)) break;
22706
22922
  }
22707
22923
  if (o.length === 0) return null;
22708
22924
  let s = null, c = 0, l = 0;
22709
- for (let e of $v) {
22925
+ for (let e of Cy) {
22710
22926
  let n = 0, r = 0;
22711
22927
  for (let a of o) {
22712
22928
  if (i(a) || !a.includes(e)) continue;
@@ -22719,7 +22935,7 @@ var qy = 200, Jy = (e, t, n) => {
22719
22935
  (n > c || n === c && n > 0 && r > l) && (s = e, c = n, l = r);
22720
22936
  }
22721
22937
  return c > 0 ? s : null;
22722
- }, Yy = (e) => {
22938
+ }, bb = (e) => {
22723
22939
  let t = /* @__PURE__ */ new Map();
22724
22940
  for (let [n, r] of Object.entries(e)) {
22725
22941
  let e = wv(n), i = t.get(e) ?? /* @__PURE__ */ new Set();
@@ -22727,8 +22943,8 @@ var qy = 200, Jy = (e, t, n) => {
22727
22943
  t.set(e, i);
22728
22944
  }
22729
22945
  return t;
22730
- }, Xy = (e, t, n, r) => {
22731
- let i = Yy(r), a = (e, t) => i.get(wv(e))?.has(wv(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
22946
+ }, xb = (e, t, n, r) => {
22947
+ let i = bb(r), a = (e, t) => i.get(wv(e))?.has(wv(t)) ?? !1, o = new Map(n.map((e) => [e.id, e])), s = (e, t) => (n, r) => {
22732
22948
  if (wv(n) === wv(r) || a(r, n)) return;
22733
22949
  let i = `${n} ${r}`;
22734
22950
  t.has(i) || (t.add(i), e.push({
@@ -22748,16 +22964,16 @@ var qy = 200, Jy = (e, t, n) => {
22748
22964
  for (let e of Object.values(t)) for (let [t, n] of Object.entries(e)) n && u(t, n);
22749
22965
  return c;
22750
22966
  };
22751
- function Zy(e, t, n) {
22967
+ function Sb(e, t, n) {
22752
22968
  let r = e.length, i = t;
22753
- return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? Qy(i, i - r) : Qy(r - 1, i - 1)) > 1e3 ? [] : r < i ? $y(e, i) : eb(e, i, n);
22969
+ return i <= 0 ? [] : r === i ? [{ cells: [...e] }] : (r < i ? Cb(i, i - r) : Cb(r - 1, i - 1)) > 1e3 ? [] : r < i ? wb(e, i) : Tb(e, i, n);
22754
22970
  }
22755
- function Qy(e, t) {
22971
+ function Cb(e, t) {
22756
22972
  let n = Math.min(t, e - t), r = 1;
22757
22973
  for (let t = 1; t <= n; t++) if (r = r * (e - n + t) / t, r > 1e3) return r;
22758
22974
  return r;
22759
22975
  }
22760
- function $y(e, t) {
22976
+ function wb(e, t) {
22761
22977
  let n = e.length, r = [], i = [], a = (o) => {
22762
22978
  if (i.length === n) {
22763
22979
  let a = Array(t).fill("");
@@ -22769,7 +22985,7 @@ function $y(e, t) {
22769
22985
  };
22770
22986
  return a(0), r;
22771
22987
  }
22772
- function eb(e, t, n) {
22988
+ function Tb(e, t, n) {
22773
22989
  let r = e.length, i = [], a = [], o = (s) => {
22774
22990
  if (a.length === t - 1) {
22775
22991
  let o = [
@@ -22787,27 +23003,27 @@ function eb(e, t, n) {
22787
23003
  }
22788
23004
  //#endregion
22789
23005
  //#region src/components/DataUploader/utils/raggedRows/pruneByValidators.ts
22790
- var tb = {};
22791
- function nb(e, t) {
23006
+ var Eb = {};
23007
+ function Db(e, t) {
22792
23008
  for (let n of t.validators ?? []) if (n.type !== "expression") {
22793
23009
  if (n.type === "function") {
22794
- if (n.fn(e, tb) != null) return !1;
23010
+ if (n.fn(e, Eb) != null) return !1;
22795
23011
  continue;
22796
23012
  }
22797
- if (Al(n, e, tb) != null) return !1;
23013
+ if (Al(n, e, Eb) != null) return !1;
22798
23014
  }
22799
23015
  return !0;
22800
23016
  }
22801
- function rb(e, t) {
22802
- for (let n = 0; n < t.length; n++) if (!nb(e.cells[n] ?? "", t[n])) return !1;
23017
+ function Ob(e, t) {
23018
+ for (let n = 0; n < t.length; n++) if (!Db(e.cells[n] ?? "", t[n])) return !1;
22803
23019
  return !0;
22804
23020
  }
22805
- function ib(e, t) {
22806
- return e.filter((e) => rb(e, t));
23021
+ function kb(e, t) {
23022
+ return e.filter((e) => Ob(e, t));
22807
23023
  }
22808
23024
  //#endregion
22809
23025
  //#region src/components/DataUploader/utils/raggedRows/computeDisputeSpans.ts
22810
- function ab(e) {
23026
+ function Ab(e) {
22811
23027
  if (e.length <= 1) return [];
22812
23028
  let t = e[0].cells.length, n = [], r = -1;
22813
23029
  for (let i = 0; i < t; i++) {
@@ -22824,25 +23040,25 @@ function ab(e) {
22824
23040
  }
22825
23041
  //#endregion
22826
23042
  //#region src/components/DataUploader/utils/raggedRows/alignRow.ts
22827
- function ob(e, t, n) {
22828
- let r = Zy(e, t.length, n), i = ib(r, t);
23043
+ function jb(e, t, n) {
23044
+ let r = Sb(e, t.length, n), i = kb(r, t);
22829
23045
  return i.length === 1 ? {
22830
23046
  kind: "confident",
22831
23047
  alignment: i[0]
22832
23048
  } : i.length > 1 ? {
22833
23049
  kind: "ambiguous",
22834
23050
  candidates: i,
22835
- disputeSpans: ab(i)
23051
+ disputeSpans: Ab(i)
22836
23052
  } : {
22837
23053
  kind: "invalid",
22838
23054
  candidates: r,
22839
- disputeSpans: ab(r)
23055
+ disputeSpans: Ab(r)
22840
23056
  };
22841
23057
  }
22842
23058
  //#endregion
22843
23059
  //#region src/components/DataUploader/utils/raggedRows/resolveRaggedRow.ts
22844
- function sb(e, t, n) {
22845
- let r = ob(e, t, n);
23060
+ function Mb(e, t, n) {
23061
+ let r = jb(e, t, n);
22846
23062
  if (r.kind === "confident") return {
22847
23063
  cells: r.alignment.cells,
22848
23064
  conflictColumns: []
@@ -22861,111 +23077,131 @@ function sb(e, t, n) {
22861
23077
  }
22862
23078
  //#endregion
22863
23079
  //#region src/components/DataUploader/context/useViewModel.tsx
22864
- var cb = 5e3, lb = 15, ub = 20, db = new Set([
23080
+ var Nb = 5e3, Pb = 15, Fb = 20, Ib = new Set([
22865
23081
  "xlsx",
22866
23082
  "xls",
22867
23083
  "xlsb",
22868
23084
  "ods"
22869
23085
  ]);
22870
- function fb() {
23086
+ function Lb() {
22871
23087
  let { store: e, validator: t, columns: n, primaryKey: r, setShowUploader: i, pendingImportFile: a, setPendingImportFile: o, onColumnMatch: s, onValueMatch: c, synonyms: l, addDynamicColumns: u, scaleClient: d } = X(), { t: p } = K(), [h, g] = b(0), [_, x] = b(0), [S, w] = b(null), [T, E] = b({}), D = v(() => {
22872
23088
  let e = new Set(Object.values(T).filter(Boolean));
22873
23089
  return n.filter((t) => t.unique && e.has(t.id));
22874
- }, [T, n]), [O, k] = b(() => r), [A, j] = b(!1), [M, N] = b(!1), [P, F] = b(null), [I, L] = b([]), [R, z] = b(null), [B, V] = b([]), [ee, te] = b({}), [H, ne] = b([]), [re, ie] = b({}), ae = y(null), [oe, se] = b(0), ce = f((e) => {
23090
+ }, [T, n]), [O, k] = b(() => r), [A, j] = b(!1), [M, N] = b(!1), [P, F] = b(null), [I, L] = b([]), [R, z] = b(null), [B, V] = b([]), [ee, te] = b({}), [H, ne] = b([]), [re, ie] = b({}), ae = y(null), [oe, se] = b(-1), ce = f((e, t) => t ? p("dataEditor.uploader.matchColumns.syntheticColumnValue", {
23091
+ index: e + 1,
23092
+ value: t
23093
+ }) : p("dataEditor.uploader.matchColumns.syntheticColumn", { index: e + 1 }), [p]), le = v(() => S ? jy(S.detection, oe) : 0, [S, oe]), ue = v(() => S ? My(S.rawRows, oe, le, ce) : [], [
23094
+ S,
23095
+ oe,
23096
+ le,
23097
+ ce
23098
+ ]), de = f((e) => {
22875
23099
  M || k(e);
22876
- }, [M]), le = y(null);
22877
- le.current ||= new $l();
22878
- let ue = le.current;
22879
- m(() => () => ue.dispose(), [ue]);
22880
- let de = v(() => {
23100
+ }, [M]), fe = y(null);
23101
+ fe.current ||= new $l();
23102
+ let pe = fe.current;
23103
+ m(() => () => pe.dispose(), [pe]);
23104
+ let me = v(() => {
22881
23105
  let e = new Set(Object.values(T).filter(Boolean));
22882
23106
  return n.some((t) => t.editor?.type === "select" && e.has(t.id));
22883
- }, [T, n]), [fe] = b(() => e.getLocalRowCount() > 0), pe = v(() => {
23107
+ }, [T, n]), [he] = b(() => e.getLocalRowCount() > 0), ge = v(() => {
22884
23108
  let e = [{
22885
23109
  id: "select-files",
22886
23110
  title: p("dataEditor.uploader.steps.selectFiles"),
22887
- content: /* @__PURE__ */ C(Ay, {})
23111
+ content: /* @__PURE__ */ C(fb, {})
22888
23112
  }];
22889
23113
  return I.length > 1 && e.push({
22890
23114
  id: "sheet-selection",
22891
23115
  title: p("dataEditor.uploader.steps.sheetSelection"),
22892
- content: /* @__PURE__ */ C(My, {})
23116
+ content: /* @__PURE__ */ C(mb, {})
23117
+ }), S && S.detection.review.kind !== "none" && e.push({
23118
+ id: "header-selection",
23119
+ title: p("dataEditor.uploader.steps.headerSelection"),
23120
+ content: /* @__PURE__ */ C(xy, {})
22893
23121
  }), e.push({
22894
23122
  id: "column-matching",
22895
23123
  title: p("dataEditor.uploader.steps.matchColumns"),
22896
23124
  content: /* @__PURE__ */ C(Zv, {})
22897
- }), de && e.push({
23125
+ }), me && e.push({
22898
23126
  id: "match-values",
22899
23127
  title: p("dataEditor.uploader.steps.matchValues"),
22900
- content: /* @__PURE__ */ C(hy, {})
22901
- }), D.length > 0 && fe && e.push({
23128
+ content: /* @__PURE__ */ C(Zy, {})
23129
+ }), D.length > 0 && he && e.push({
22902
23130
  id: "primary-key",
22903
23131
  title: p("dataEditor.uploader.steps.primaryKey"),
22904
- content: /* @__PURE__ */ C(vy, {})
23132
+ content: /* @__PURE__ */ C(eb, {})
22905
23133
  }), e;
22906
23134
  }, [
22907
23135
  D.length,
22908
23136
  I.length,
22909
- de,
22910
- fe,
23137
+ me,
23138
+ he,
23139
+ S,
22911
23140
  p
22912
- ]), me = f((e) => {
22913
- e >= 0 && e < pe.length && g(e);
22914
- }, [pe.length]), he = f(() => {
23141
+ ]), _e = f((e) => {
23142
+ e >= 0 && e < ge.length && g(e);
23143
+ }, [ge.length]), ve = f(() => {
22915
23144
  g((e) => {
22916
- let t = Math.min(e + 1, pe.length - 1);
23145
+ let t = Math.min(e + 1, ge.length - 1);
22917
23146
  return x((e) => Math.max(e, t)), t;
22918
23147
  });
22919
- }, [pe.length]), ge = f(() => {
23148
+ }, [ge.length]), ye = f(() => {
22920
23149
  g((e) => Math.max(e - 1, 0));
22921
- }, []), _e = h === 0, ve = h === pe.length - 1, ye = f((e) => {
22922
- w(e), j(!1), Bv(e.headers, n, s, l).then(E);
23150
+ }, []), be = h === 0, xe = h === ge.length - 1, Se = f((e) => {
23151
+ w(e), j(!1);
23152
+ }, []), Ce = y(0);
23153
+ m(() => {
23154
+ if (!S || ue.length === 0) return;
23155
+ let e = ++Ce.current;
23156
+ Bv(ue, n, s, l).then((t) => {
23157
+ Ce.current === e && E(t);
23158
+ });
22923
23159
  }, [
23160
+ S,
23161
+ ue,
22924
23162
  n,
22925
23163
  s,
22926
23164
  l
22927
- ]), be = f(() => {
22928
- ue.cancel(), w(null), j(!1), E({}), ne([]), ie({}), ae.current = null, se(0), F(null), L([]), z(null), V([]);
22929
- }, [ue]), xe = f((e, t, n) => {
23165
+ ]);
23166
+ let we = f(() => {
23167
+ pe.cancel(), w(null), j(!1), E({}), ne([]), ie({}), ae.current = null, se(-1), F(null), L([]), z(null), V([]);
23168
+ }, [pe]), Te = f((e, t, n) => {
22930
23169
  F(e), L(t), z(t[0]), V(n), j(!1);
22931
- }, []), Se = f(() => {
22932
- !P || !R || (j(!0), ue.parse(P, {
23170
+ }, []), Ee = f(() => {
23171
+ !P || !R || (j(!0), pe.parse(P, {
22933
23172
  format: "xlsx",
22934
23173
  sheetName: R
22935
23174
  }).then((e) => {
22936
23175
  if (e.kind !== "rows") return;
22937
- let t = Ky(e.rows);
22938
- se(t.headerRowIndex), ye({
23176
+ let t = my(e.rows);
23177
+ se(t.headerRowIndex), Se({
22939
23178
  fileName: P.name,
22940
- headers: t.headers,
22941
- rows: t.rows,
22942
- isParsing: !1,
22943
- rawCells: t.rawCells,
23179
+ rawRows: e.rows,
23180
+ detection: t,
22944
23181
  delimiter: ","
22945
- }), he();
23182
+ }), ve();
22946
23183
  }).catch(() => {
22947
23184
  j(!1);
22948
23185
  }));
22949
23186
  }, [
22950
23187
  P,
22951
23188
  R,
22952
- ue,
22953
- ye,
22954
- he
22955
- ]), Ce = f(async (t) => {
23189
+ pe,
23190
+ Se,
23191
+ ve,
23192
+ ce
23193
+ ]), De = f(async (t) => {
22956
23194
  try {
22957
- let e = await ue.parse(t, { format: "csv" });
23195
+ let e = await pe.parse(t, { format: "csv" });
22958
23196
  if (e.kind !== "rows") {
22959
23197
  j(!1);
22960
23198
  return;
22961
23199
  }
22962
- let n = Ky(e.rows);
22963
- if (se(n.headerRowIndex), ye({
23200
+ let n = my(e.rows);
23201
+ if (se(n.headerRowIndex), Se({
22964
23202
  fileName: t.name,
22965
- headers: n.headers,
22966
- rows: n.rows,
22967
- isParsing: !1,
22968
- rawCells: n.rawCells,
23203
+ rawRows: e.rows,
23204
+ detection: n,
22969
23205
  delimiter: e.delimiter
22970
23206
  }), e.errors.length > 0) {
22971
23207
  let t = e.errors.slice(0, 3).map((e) => e.row == null ? "?" : String(e.row + 1)).join(", ");
@@ -22983,20 +23219,20 @@ function fb() {
22983
23219
  });
22984
23220
  }
22985
23221
  }, [
22986
- ue,
22987
- ye,
23222
+ pe,
23223
+ Se,
22988
23224
  j,
22989
23225
  e,
22990
- p
22991
- ]), we = f(async (t) => {
23226
+ p,
23227
+ ce
23228
+ ]), Oe = f(async (t) => {
22992
23229
  try {
22993
- let e = await ue.parse(t, { format: "json" });
23230
+ let e = await pe.parse(t, { format: "json" });
22994
23231
  if (e.kind !== "records") return;
22995
- ye({
23232
+ se(0), Se({
22996
23233
  fileName: t.name,
22997
- headers: e.headers,
22998
- rows: e.rows,
22999
- isParsing: !1
23234
+ rawRows: Py(e.headers, e.rows),
23235
+ detection: Ny()
23000
23236
  });
23001
23237
  } catch (t) {
23002
23238
  j(!1), e.errorHandler.handleError({
@@ -23007,19 +23243,18 @@ function fb() {
23007
23243
  });
23008
23244
  }
23009
23245
  }, [
23010
- ue,
23011
- ye,
23246
+ pe,
23247
+ Se,
23012
23248
  j,
23013
23249
  e
23014
- ]), Te = f(async (t) => {
23250
+ ]), ke = f(async (t) => {
23015
23251
  try {
23016
- let e = await ue.parse(t, { format: "xml" });
23252
+ let e = await pe.parse(t, { format: "xml" });
23017
23253
  if (e.kind !== "records") return;
23018
- ye({
23254
+ se(0), Se({
23019
23255
  fileName: t.name,
23020
- headers: e.headers,
23021
- rows: e.rows,
23022
- isParsing: !1
23256
+ rawRows: Py(e.headers, e.rows),
23257
+ detection: Ny()
23023
23258
  });
23024
23259
  } catch (t) {
23025
23260
  j(!1), e.errorHandler.handleError({
@@ -23030,33 +23265,31 @@ function fb() {
23030
23265
  });
23031
23266
  }
23032
23267
  }, [
23033
- ue,
23034
- ye,
23268
+ pe,
23269
+ Se,
23035
23270
  j,
23036
23271
  e
23037
- ]), Ee = f((t) => {
23038
- ue.parse(t, { format: "xlsx" }).then((e) => {
23272
+ ]), Ae = f((t) => {
23273
+ pe.parse(t, { format: "xlsx" }).then((e) => {
23039
23274
  if (e.kind === "sheets") {
23040
23275
  let n = e.sheets.map((e) => {
23041
- let { headers: t, rows: n } = Ky(e.rows);
23276
+ let t = my(e.rows), n = jy(t, t.headerRowIndex), r = My(e.rows, t.headerRowIndex, n, ce);
23042
23277
  return {
23043
23278
  name: e.name,
23044
- headers: t,
23045
- rows: n.slice(0, lb),
23279
+ headers: r,
23280
+ rows: Ry(e.rows, r, n, Pb),
23046
23281
  totalRows: e.totalRows - 1
23047
23282
  };
23048
23283
  });
23049
- xe(t, e.sheets.map((e) => e.name), n);
23284
+ Te(t, e.sheets.map((e) => e.name), n);
23050
23285
  return;
23051
23286
  }
23052
23287
  if (e.kind !== "rows") return;
23053
- let n = Ky(e.rows);
23054
- se(n.headerRowIndex), ye({
23288
+ let n = my(e.rows);
23289
+ se(n.headerRowIndex), Se({
23055
23290
  fileName: t.name,
23056
- headers: n.headers,
23057
- rows: n.rows,
23058
- isParsing: !1,
23059
- rawCells: n.rawCells,
23291
+ rawRows: e.rows,
23292
+ detection: n,
23060
23293
  delimiter: ","
23061
23294
  });
23062
23295
  }).catch((t) => {
@@ -23068,39 +23301,40 @@ function fb() {
23068
23301
  }), j(!1);
23069
23302
  });
23070
23303
  }, [
23071
- ue,
23072
- ye,
23073
- xe,
23304
+ pe,
23305
+ Se,
23306
+ Te,
23074
23307
  j,
23075
- e
23076
- ]), De = f((e) => {
23308
+ e,
23309
+ ce
23310
+ ]), je = f((e) => {
23077
23311
  j(!0), ae.current = e;
23078
23312
  let t = e.name.split(".").pop()?.toLowerCase();
23079
- t && db.has(t) ? Ee(e) : t === "json" ? we(e) : t === "xml" ? Te(e) : Ce(e);
23313
+ t && Ib.has(t) ? Ae(e) : t === "json" ? Oe(e) : t === "xml" ? ke(e) : De(e);
23080
23314
  }, [
23081
- Ce,
23082
- we,
23083
- Ee,
23084
- Te,
23315
+ De,
23316
+ Oe,
23317
+ Ae,
23318
+ ke,
23085
23319
  j
23086
23320
  ]);
23087
23321
  m(() => {
23088
- a && (De(a), o(null));
23322
+ a && (je(a), o(null));
23089
23323
  }, [
23090
23324
  a,
23091
23325
  o,
23092
- De
23326
+ je
23093
23327
  ]);
23094
- let [Oe, ke] = b(null), [Ae, je] = b(null), Me = f(() => {
23095
- je(null);
23096
- }, []), Ne = f(async (e) => {
23097
- ke(e.id), je(null);
23328
+ let [Me, Ne] = b(null), [Pe, Fe] = b(null), Ie = f(() => {
23329
+ Fe(null);
23330
+ }, []), Le = f(async (e) => {
23331
+ Ne(e.id), Fe(null);
23098
23332
  try {
23099
23333
  let t = await e.fetch();
23100
- if (t instanceof File) De(t);
23334
+ if (t instanceof File) je(t);
23101
23335
  else if (Array.isArray(t)) {
23102
23336
  if (t.length === 0) {
23103
- je(p("dataEditor.uploader.remoteSources.emptyData"));
23337
+ Fe(p("dataEditor.uploader.remoteSources.emptyData"));
23104
23338
  return;
23105
23339
  }
23106
23340
  let n = Object.keys(t[0]), r = t.map((e) => {
@@ -23111,23 +23345,22 @@ function fb() {
23111
23345
  }
23112
23346
  return t;
23113
23347
  });
23114
- ye({
23348
+ se(0), Se({
23115
23349
  fileName: e.label,
23116
- headers: n,
23117
- rows: r,
23118
- isParsing: !1
23350
+ rawRows: Py(n, r),
23351
+ detection: Ny()
23119
23352
  });
23120
23353
  }
23121
23354
  } catch (e) {
23122
- je(e instanceof Error ? e.message : String(e));
23355
+ Fe(e instanceof Error ? e.message : String(e));
23123
23356
  } finally {
23124
- ke(null);
23357
+ Ne(null);
23125
23358
  }
23126
23359
  }, [
23127
- De,
23128
- ye,
23360
+ je,
23361
+ Se,
23129
23362
  p
23130
- ]), Pe = f((e, t) => {
23363
+ ]), Re = f((e, t) => {
23131
23364
  E((n) => {
23132
23365
  let r = {
23133
23366
  ...n,
@@ -23136,52 +23369,50 @@ function fb() {
23136
23369
  if (t) for (let n in r) n !== e && r[n] === t && (r[n] = void 0);
23137
23370
  return r;
23138
23371
  });
23139
- }, []), [Fe, Ie] = b({}), [Le, Re] = b({}), ze = y(0);
23372
+ }, []), [ze, Be] = b({}), [Ve, He] = b({}), Ue = y(0);
23140
23373
  m(() => {
23141
23374
  if (!S) {
23142
- Ie({}), Re({});
23375
+ Be({}), He({});
23143
23376
  return;
23144
23377
  }
23145
23378
  if (M) return;
23146
- let e = {}, t = {};
23147
- for (let [r, i] of Object.entries(T)) {
23148
- if (!i) continue;
23149
- let a = n.find((e) => e.id === i);
23150
- if (!a?.editor) continue;
23151
- let o = a.editor.type;
23152
- if (o !== "select" && o !== "multiselect") continue;
23153
- let s = a.editor.options, c = [];
23154
- for (let e of S.rows) {
23155
- let t = e[r];
23156
- t === void 0 || t === "" || c.push(t);
23157
- }
23158
- if (o === "multiselect") {
23159
- let n = a.editor.delimiter, r = Jy(c, s, n);
23160
- t[i] = r;
23161
- let o = new Set(s.map((e) => e.trim().toLowerCase())), l = /* @__PURE__ */ new Set();
23162
- for (let e of c) {
23163
- let t = o.has(e.trim().toLowerCase()), n = r && !t ? e.split(r) : [e];
23379
+ let e = {}, t = {}, r = Fy(ue);
23380
+ for (let [i, a] of Object.entries(T)) {
23381
+ if (!a) continue;
23382
+ let o = n.find((e) => e.id === a);
23383
+ if (!o?.editor) continue;
23384
+ let s = o.editor.type;
23385
+ if (s !== "select" && s !== "multiselect") continue;
23386
+ let c = o.editor.options, l = r.get(i);
23387
+ if (l === void 0) continue;
23388
+ let u = Iy(S.rawRows, le, l);
23389
+ if (s === "multiselect") {
23390
+ let n = o.editor.delimiter, r = yb(u, c, n);
23391
+ t[a] = r;
23392
+ let i = new Set(c.map((e) => e.trim().toLowerCase())), s = /* @__PURE__ */ new Set();
23393
+ for (let e of u) {
23394
+ let t = i.has(e.trim().toLowerCase()), n = r && !t ? e.split(r) : [e];
23164
23395
  for (let e of n) {
23165
23396
  let t = e.trim();
23166
- t !== "" && l.add(t);
23397
+ t !== "" && s.add(t);
23167
23398
  }
23168
23399
  }
23169
- e[i] = {
23170
- importedValues: Array.from(l),
23171
- options: s
23400
+ e[a] = {
23401
+ importedValues: Array.from(s),
23402
+ options: c
23172
23403
  };
23173
- } else e[i] = {
23174
- importedValues: Array.from(new Set(c)),
23175
- options: s
23404
+ } else e[a] = {
23405
+ importedValues: Array.from(new Set(u)),
23406
+ options: c
23176
23407
  };
23177
23408
  }
23178
- if (Re(t), Object.keys(e).length === 0) {
23179
- Ie({});
23409
+ if (He(t), Object.keys(e).length === 0) {
23410
+ Be({});
23180
23411
  return;
23181
23412
  }
23182
- let r = ++ze.current;
23413
+ let i = ++Ue.current;
23183
23414
  Iv(e, c, l).then((e) => {
23184
- ze.current === r && Ie(e);
23415
+ Ue.current === i && Be(e);
23185
23416
  });
23186
23417
  }, [
23187
23418
  S,
@@ -23189,16 +23420,18 @@ function fb() {
23189
23420
  n,
23190
23421
  c,
23191
23422
  l,
23192
- M
23423
+ M,
23424
+ ue,
23425
+ le
23193
23426
  ]);
23194
- let Be = v(() => {
23427
+ let We = v(() => {
23195
23428
  let e = {};
23196
- for (let [t, n] of Object.entries(Fe)) e[t] = {
23429
+ for (let [t, n] of Object.entries(ze)) e[t] = {
23197
23430
  ...n,
23198
23431
  ...ee[t]
23199
23432
  };
23200
23433
  return e;
23201
- }, [Fe, ee]), Ve = f((e, t, n) => {
23434
+ }, [ze, ee]), Ge = f((e, t, n) => {
23202
23435
  te((r) => ({
23203
23436
  ...r,
23204
23437
  [e]: {
@@ -23206,30 +23439,29 @@ function fb() {
23206
23439
  [t]: n
23207
23440
  }
23208
23441
  }));
23209
- }, []), He = f((e, t) => {
23210
- Re((n) => ({
23442
+ }, []), Ke = f((e, t) => {
23443
+ He((n) => ({
23211
23444
  ...n,
23212
23445
  [e]: t
23213
23446
  }));
23214
- }, []), Ue = f((e) => {
23447
+ }, []), qe = f((e) => {
23215
23448
  if (!S) return;
23216
23449
  let t = Object.keys(T).find((t) => T[t] === e);
23217
23450
  if (!t) return;
23218
23451
  let r = n.find((t) => t.id === e);
23219
23452
  if (r?.editor?.type !== "multiselect") return;
23220
- let i = [];
23221
- for (let e of S.rows) {
23222
- let n = e[t];
23223
- n !== void 0 && n !== "" && i.push(n);
23224
- }
23225
- let a = r.editor.delimiter;
23226
- He(e, Jy(i, r.editor.options, a));
23453
+ let i = Fy(ue).get(t);
23454
+ if (i === void 0) return;
23455
+ let a = Iy(S.rawRows, le, i), o = r.editor.delimiter;
23456
+ Ke(e, yb(a, r.editor.options, o));
23227
23457
  }, [
23228
23458
  S,
23229
23459
  T,
23230
23460
  n,
23231
- He
23232
- ]), We = f((e, t) => {
23461
+ Ke,
23462
+ ue,
23463
+ le
23464
+ ]), Je = f((e, t) => {
23233
23465
  ie((n) => {
23234
23466
  let r = n[e] ?? [];
23235
23467
  return r.includes(t) ? n : {
@@ -23237,36 +23469,38 @@ function fb() {
23237
23469
  [e]: [...r, t]
23238
23470
  };
23239
23471
  });
23240
- }, []), Ge = f((e) => {
23472
+ }, []), Ye = f((e) => {
23241
23473
  let t = [];
23242
23474
  for (let [r, i] of Object.entries(T)) !i || e.has(i) || n.find((e) => e.id === i)?.editor?.type === "date" && t.push(r);
23243
23475
  return t;
23244
- }, [T, n]), Ke = f(() => {
23245
- let e = new Set(H.map((e) => e.id)), t = Ny(T, n, e), i = tc(S?.rows ?? [], Py(t)), a = Ge(e), o = oc(S?.rows ?? [], a);
23476
+ }, [T, n]), Xe = f(() => {
23477
+ let e = new Set(H.map((e) => e.id)), t = hb(T, n, e), i = S ? Ry(S.rawRows, ue, le, 1e3) : [], a = tc(i, gb(t)), o = oc(i, Ye(e));
23246
23478
  return {
23247
23479
  columnMapping: T,
23248
- valueMapping: Be,
23480
+ valueMapping: We,
23249
23481
  primaryKey: O ?? r,
23250
23482
  selectedSheet: R ?? void 0,
23251
23483
  headerRowIndex: oe,
23252
- numberFormat: i,
23484
+ numberFormat: a,
23253
23485
  dateFormat: o,
23254
23486
  newColumns: H
23255
23487
  };
23256
23488
  }, [
23257
23489
  S,
23258
23490
  T,
23259
- Be,
23491
+ We,
23260
23492
  O,
23261
23493
  R,
23262
23494
  r,
23263
23495
  oe,
23496
+ ue,
23497
+ le,
23264
23498
  H,
23265
23499
  n,
23266
- Ge
23267
- ]), qe = f(async () => {
23500
+ Ye
23501
+ ]), Ze = f(async () => {
23268
23502
  if (!ae.current || !d?.onFileImport) return;
23269
- let t = new AbortController(), n = Ke();
23503
+ let t = new AbortController(), n = Xe();
23270
23504
  await d.onFileImport({
23271
23505
  file: ae.current,
23272
23506
  mappings: n,
@@ -23275,49 +23509,59 @@ function fb() {
23275
23509
  }), e.reloadServerData();
23276
23510
  }, [
23277
23511
  d,
23278
- Ke,
23512
+ Xe,
23279
23513
  e
23280
- ]), Je = f(async () => {
23514
+ ]), Qe = f(async () => {
23281
23515
  if (!S || !d?.onRowsImport) return;
23282
23516
  let t = S;
23283
23517
  w(null);
23284
- let r = crypto.randomUUID(), i = Ke(), a = new AbortController(), o = d.importChunkSize ?? cb, s = Ny(T, n, new Set(H.map((e) => e.id))), c = {
23518
+ let r = crypto.randomUUID(), i = Xe(), a = new AbortController(), o = d.importChunkSize ?? Nb, s = hb(T, n, new Set(H.map((e) => e.id))), c = {
23285
23519
  numberFormat: i.numberFormat,
23286
23520
  dateFormat: i.dateFormat,
23287
23521
  monthTable: ic(p),
23288
- valueMapping: Be,
23289
- multiselectDelimiters: Le
23290
- }, l = t.rows, u = 0;
23291
- for (; u < l.length;) {
23292
- let e = Math.min(u + o, l.length), n = [];
23293
- for (let t = u; t < e; t++) n.push(Fy(l[t], s, c));
23294
- let f = e >= l.length, p = Math.floor(u / o);
23522
+ valueMapping: We,
23523
+ multiselectDelimiters: Ve
23524
+ }, l = ue, u = t.rawRows, f = [];
23525
+ for (let e = le; e < u.length; e++) {
23526
+ let t = u[e];
23527
+ t && !Dy(t) && f.push(e);
23528
+ }
23529
+ let m = 0;
23530
+ for (; m < f.length;) {
23531
+ let e = Math.min(m + o, f.length), n = [];
23532
+ for (let t = m; t < e; t++) {
23533
+ let e = Ly(u[f[t]] ?? [], l);
23534
+ n.push(_b(e, s, c));
23535
+ }
23536
+ let p = e >= f.length, h = Math.floor(m / o);
23295
23537
  await d.onRowsImport({
23296
23538
  importId: r,
23297
23539
  sourceName: t.fileName,
23298
- chunkIndex: p,
23299
- isLastChunk: f,
23540
+ chunkIndex: h,
23541
+ isLastChunk: p,
23300
23542
  rows: n,
23301
- newColumns: p === 0 && H.length > 0 ? H : void 0,
23543
+ newColumns: h === 0 && H.length > 0 ? H : void 0,
23302
23544
  primaryKey: i.primaryKey,
23303
23545
  signal: a.signal
23304
23546
  });
23305
- for (let t = u; t < e; t++) l[t] = null;
23306
- u = e;
23547
+ for (let t = m; t < e; t++) u[f[t]] = void 0;
23548
+ m = e;
23307
23549
  }
23308
23550
  e.reloadServerData();
23309
23551
  }, [
23310
23552
  S,
23311
23553
  d,
23312
- Ke,
23554
+ Xe,
23313
23555
  T,
23314
23556
  H,
23315
23557
  n,
23316
- Be,
23317
- Le,
23558
+ ue,
23559
+ le,
23560
+ We,
23561
+ Ve,
23318
23562
  e,
23319
23563
  p
23320
- ]), Ye = f(() => new Promise((r) => {
23564
+ ]), $e = f(() => new Promise((r) => {
23321
23565
  if (!S) {
23322
23566
  r();
23323
23567
  return;
@@ -23328,47 +23572,52 @@ function fb() {
23328
23572
  H.length > 0 && u(H);
23329
23573
  for (let [t, n] of Object.entries(re)) e.addColumnOptions(t, n);
23330
23574
  let o = e.registerSource({ name: i.fileName });
23331
- e.setSourceLoading(o, !0), e.recordLearnedSynonyms(Xy(T, Be, [...n, ...H], Sv(xv, l)));
23332
- let s = Ny(T, n, a), c = {
23333
- numberFormat: tc(i.rows, Py(s)),
23334
- dateFormat: oc(i.rows, Ge(a)),
23575
+ e.setSourceLoading(o, !0), e.recordLearnedSynonyms(xb(T, We, [...n, ...H], Sv(xv, l)));
23576
+ let s = ue, c = i.delimiter ?? ",", d = i.rawRows, f = [];
23577
+ for (let e = le; e < d.length; e++) {
23578
+ let t = d[e];
23579
+ t && !Dy(t) && f.push(e);
23580
+ }
23581
+ let m = Ry(i.rawRows, s, le, 1e3), h = hb(T, n, a), g = {
23582
+ numberFormat: tc(m, gb(h)),
23583
+ dateFormat: oc(m, Ye(a)),
23335
23584
  monthTable: ic(p),
23336
- valueMapping: Be,
23337
- multiselectDelimiters: Le
23338
- }, d = i.rows, f = i.rawCells ?? [], m = i.delimiter ?? ",", h = i.headers, g = h.map((e) => {
23585
+ valueMapping: We,
23586
+ multiselectDelimiters: Ve
23587
+ }, _ = s.map((e) => {
23339
23588
  let t = T[e];
23340
23589
  return (t ? n.find((e) => e.id === t) : void 0) ?? {
23341
23590
  id: e,
23342
23591
  title: e
23343
23592
  };
23344
- }), _ = 0, v = () => {
23345
- let n = Math.min(_ + cb, d.length), i = [], a = [];
23346
- for (let e = _; e < n; e++) {
23347
- let t = d[e], n = f[e];
23348
- if (n) {
23349
- let { cells: r, conflictColumns: i } = sb(n, g, m);
23593
+ }), v = 0, y = () => {
23594
+ let n = Math.min(v + Nb, f.length), i = [], a = [];
23595
+ for (let e = v; e < n; e++) {
23596
+ let t = d[f[e]] ?? [], n = Ly(t, s);
23597
+ if (t.length !== s.length) {
23598
+ let { cells: r, conflictColumns: i } = Mb(t.map((e) => String(e ?? "")), _, c);
23350
23599
  if (r.length) {
23351
23600
  let e = {};
23352
- for (let t = 0; t < h.length; t++) e[h[t]] = r[t] ?? "";
23353
- t = e;
23601
+ for (let t = 0; t < s.length; t++) e[s[t]] = r[t] ?? "";
23602
+ n = e;
23354
23603
  }
23355
23604
  if (i.length) {
23356
23605
  let t = [];
23357
23606
  for (let e of i) {
23358
- let n = T[h[e]];
23607
+ let n = T[s[e]];
23359
23608
  n && t.push(n);
23360
23609
  }
23361
23610
  t.length && a.push({
23362
- localIndex: e - _,
23611
+ localIndex: e - v,
23363
23612
  columnIds: t
23364
23613
  });
23365
23614
  }
23366
23615
  }
23367
- i.push(Fy(t, s, c));
23616
+ i.push(_b(n, h, g));
23368
23617
  }
23369
23618
  let { rows: l, rowIds: u } = e.upsertRows(o, i, { anchorKey: O ?? void 0 });
23370
- for (let e = _; e < n; e++) e < ub || (d[e] = null, e < f.length && (f[e] = null));
23371
- _ = n, setTimeout(() => {
23619
+ for (let e = v; e < n; e++) e < Fb || (d[f[e]] = void 0);
23620
+ v = n, setTimeout(() => {
23372
23621
  t.validateRows(l, u);
23373
23622
  for (let { localIndex: t, columnIds: n } of a) {
23374
23623
  let r = u[t];
@@ -23381,11 +23630,11 @@ function fb() {
23381
23630
  }
23382
23631
  }
23383
23632
  a.length > 0 && e.notify();
23384
- }, 0), _ < d.length ? setTimeout(v, 0) : e.finalizeSource(o).then(() => {
23633
+ }, 0), v < f.length ? setTimeout(y, 0) : e.finalizeSource(o).then(() => {
23385
23634
  t.validateUniqueness(), r();
23386
23635
  });
23387
23636
  };
23388
- v();
23637
+ y();
23389
23638
  }, 0);
23390
23639
  }), [
23391
23640
  S,
@@ -23397,43 +23646,45 @@ function fb() {
23397
23646
  t,
23398
23647
  n,
23399
23648
  u,
23400
- Be,
23401
- Le,
23649
+ We,
23650
+ Ve,
23402
23651
  l,
23403
- Ge,
23652
+ Ye,
23653
+ ue,
23654
+ le,
23404
23655
  p
23405
23656
  ]);
23406
23657
  return {
23407
- steps: pe,
23658
+ steps: ge,
23408
23659
  activeStepIndex: h,
23409
23660
  currentStepIndex: _,
23410
- isFirstStep: _e,
23411
- isLastStep: ve,
23412
- goToStep: me,
23413
- nextStep: he,
23414
- prevStep: ge,
23661
+ isFirstStep: be,
23662
+ isLastStep: xe,
23663
+ goToStep: _e,
23664
+ nextStep: ve,
23665
+ prevStep: ye,
23415
23666
  parsedCsv: S,
23416
23667
  columnMapping: T,
23417
- handleFileParsed: ye,
23418
- handleFileRemoved: be,
23419
- updateColumnMapping: Pe,
23420
- valueMapping: Be,
23421
- autoValueMapping: Fe,
23422
- updateValueMapping: Ve,
23423
- multiselectDelimiters: Le,
23424
- setMultiselectDelimiter: He,
23425
- reapplyMultiselectDelimiter: Ue,
23668
+ handleFileParsed: Se,
23669
+ handleFileRemoved: we,
23670
+ updateColumnMapping: Re,
23671
+ valueMapping: We,
23672
+ autoValueMapping: ze,
23673
+ updateValueMapping: Ge,
23674
+ multiselectDelimiters: Ve,
23675
+ setMultiselectDelimiter: Ke,
23676
+ reapplyMultiselectDelimiter: qe,
23426
23677
  pendingOptions: re,
23427
- addPendingOption: We,
23678
+ addPendingOption: Je,
23428
23679
  xlsxFile: P,
23429
23680
  sheetNames: I,
23430
23681
  selectedSheet: R,
23431
23682
  setSelectedSheet: z,
23432
- handleSheetConfirmed: Se,
23433
- handleXlsxMultiSheet: xe,
23683
+ handleSheetConfirmed: Ee,
23684
+ handleXlsxMultiSheet: Te,
23434
23685
  sheetPreviews: B,
23435
23686
  primaryKey: O,
23436
- onPrimaryKeyChange: ce,
23687
+ onPrimaryKeyChange: de,
23437
23688
  primaryKeyColumns: D,
23438
23689
  pendingColumns: H,
23439
23690
  setPendingColumns: ne,
@@ -23445,7 +23696,7 @@ function fb() {
23445
23696
  N(!0);
23446
23697
  try {
23447
23698
  await Yo(e, "importing", Infinity, async () => {
23448
- d?.onFileImport ? await qe() : d?.onRowsImport ? await Je() : await Ye();
23699
+ d?.onFileImport ? await Ze() : d?.onRowsImport ? await Qe() : await $e();
23449
23700
  });
23450
23701
  } finally {
23451
23702
  w(null), N(!1), i(!1);
@@ -23455,34 +23706,38 @@ function fb() {
23455
23706
  S,
23456
23707
  e,
23457
23708
  d,
23458
- qe,
23459
- Je,
23460
- Ye,
23709
+ Ze,
23710
+ Qe,
23711
+ $e,
23461
23712
  i
23462
23713
  ]),
23463
- parseFile: De,
23464
- remoteSourceLoading: Oe,
23465
- remoteSourceError: Ae,
23466
- clearRemoteSourceError: Me,
23467
- handleRemoteSourceSelect: Ne
23714
+ parseFile: je,
23715
+ remoteSourceLoading: Me,
23716
+ remoteSourceError: Pe,
23717
+ clearRemoteSourceError: Ie,
23718
+ handleRemoteSourceSelect: Le,
23719
+ headerRowIndex: oe,
23720
+ setHeaderRowIndex: se,
23721
+ headers: ue,
23722
+ dataStartIndex: le
23468
23723
  };
23469
23724
  }
23470
23725
  //#endregion
23471
23726
  //#region src/components/DataUploader/context/index.tsx
23472
- var pb = s(null);
23473
- function mb({ children: e }) {
23474
- let t = fb();
23475
- return /* @__PURE__ */ C(pb.Provider, {
23727
+ var Rb = s(null);
23728
+ function zb({ children: e }) {
23729
+ let t = Lb();
23730
+ return /* @__PURE__ */ C(Rb.Provider, {
23476
23731
  value: t,
23477
23732
  children: e
23478
23733
  });
23479
23734
  }
23480
- var hb = () => {
23481
- let e = p(pb);
23735
+ var Bb = () => {
23736
+ let e = p(Rb);
23482
23737
  if (!e) throw Error("useDataUploaderContext must be used within DataUploaderProvider");
23483
23738
  return e;
23484
- }, gb = () => {
23485
- let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = hb();
23739
+ }, Vb = () => {
23740
+ let { steps: e, activeStepIndex: t, currentStepIndex: n, goToStep: r } = Bb();
23486
23741
  return /* @__PURE__ */ C(co, {
23487
23742
  steps: e,
23488
23743
  activeStepIndex: t,
@@ -23490,79 +23745,79 @@ var hb = () => {
23490
23745
  onStepChange: r,
23491
23746
  isProgressive: !0
23492
23747
  });
23493
- }, _b = () => /* @__PURE__ */ C(mb, { children: /* @__PURE__ */ C(gb, {}) }), vb = {
23748
+ }, Hb = () => /* @__PURE__ */ C(zb, { children: /* @__PURE__ */ C(Vb, {}) }), Ub = {
23494
23749
  kty: "EC",
23495
23750
  crv: "P-256",
23496
23751
  x: "wZO1Jxr21FEBDsVMzbTbF8blU2CP17c_eQY7gorO13U",
23497
23752
  y: "Nwr-tXatJZ3DxZqpUG_gOWzmpU6szTqrEL7Gnh5UGwo"
23498
- }, yb = "updog_license_grant", bb = new Set([
23753
+ }, Wb = "updog_license_grant", Gb = new Set([
23499
23754
  "updog.tech",
23500
23755
  "landing.updog.tech",
23501
23756
  "demo.updog.tech"
23502
23757
  ]);
23503
- function xb() {
23504
- return bb.has(window.location.hostname);
23758
+ function Kb() {
23759
+ return Gb.has(window.location.hostname);
23505
23760
  }
23506
- function Sb() {
23761
+ function qb() {
23507
23762
  return !1;
23508
23763
  }
23509
- function Cb() {
23764
+ function Jb() {
23510
23765
  return "https://api.updog.tech";
23511
23766
  }
23512
- function wb(e) {
23767
+ function Yb(e) {
23513
23768
  let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = t + "=".repeat((4 - t.length % 4) % 4), r = atob(n), i = new Uint8Array(r.length);
23514
23769
  for (let e = 0; e < r.length; e++) i[e] = r.charCodeAt(e);
23515
23770
  return i;
23516
23771
  }
23517
- async function Tb(e) {
23772
+ async function Xb(e) {
23518
23773
  let t = new TextEncoder().encode(e), n = await crypto.subtle.digest("SHA-256", t);
23519
23774
  return Array.from(new Uint8Array(n)).map((e) => e.toString(16).padStart(2, "0")).join("");
23520
23775
  }
23521
- var Eb = null;
23522
- async function Db() {
23523
- return Eb || (Eb = await crypto.subtle.importKey("jwk", vb, {
23776
+ var Zb = null;
23777
+ async function Qb() {
23778
+ return Zb || (Zb = await crypto.subtle.importKey("jwk", Ub, {
23524
23779
  name: "ECDSA",
23525
23780
  namedCurve: "P-256"
23526
- }, !1, ["verify"]), Eb);
23781
+ }, !1, ["verify"]), Zb);
23527
23782
  }
23528
- function Ob() {
23783
+ function $b() {
23529
23784
  try {
23530
- return localStorage.getItem(yb);
23785
+ return localStorage.getItem(Wb);
23531
23786
  } catch {
23532
23787
  return null;
23533
23788
  }
23534
23789
  }
23535
- function kb(e) {
23790
+ function ex(e) {
23536
23791
  try {
23537
- localStorage.setItem(yb, e);
23792
+ localStorage.setItem(Wb, e);
23538
23793
  } catch {}
23539
23794
  }
23540
- function Ab() {
23795
+ function tx() {
23541
23796
  try {
23542
- localStorage.removeItem(yb);
23797
+ localStorage.removeItem(Wb);
23543
23798
  } catch {}
23544
23799
  }
23545
- async function jb(e, t, n) {
23800
+ async function nx(e, t, n) {
23546
23801
  let r = e.indexOf(".");
23547
23802
  if (r === -1) return !1;
23548
- let i = e.slice(0, r), a = e.slice(r + 1), o = wb(i), s = wb(a), c = await Db();
23803
+ let i = e.slice(0, r), a = e.slice(r + 1), o = Yb(i), s = Yb(a), c = await Qb();
23549
23804
  if (!await crypto.subtle.verify({
23550
23805
  name: "ECDSA",
23551
23806
  hash: "SHA-256"
23552
23807
  }, c, new Uint8Array(s), new Uint8Array(o))) return !1;
23553
23808
  let l = JSON.parse(new TextDecoder().decode(o));
23554
23809
  if (l.exp <= Math.floor(Date.now() / 1e3)) return !1;
23555
- let u = await Tb(t);
23810
+ let u = await Xb(t);
23556
23811
  return !(l.key !== u || l.domain !== n);
23557
23812
  }
23558
- async function Mb(e) {
23559
- let t = Ob();
23813
+ async function rx(e) {
23814
+ let t = $b();
23560
23815
  if (!t) return {
23561
23816
  valid: !1,
23562
23817
  errorCode: "license.invalid"
23563
23818
  };
23564
23819
  try {
23565
- if (await jb(t, e, window.location.hostname.toLowerCase().trim())) return {
23820
+ if (await nx(t, e, window.location.hostname.toLowerCase().trim())) return {
23566
23821
  valid: !0,
23567
23822
  errorCode: null
23568
23823
  };
@@ -23572,23 +23827,23 @@ async function Mb(e) {
23572
23827
  errorCode: "license.invalid"
23573
23828
  };
23574
23829
  }
23575
- async function Nb(e, t = !0) {
23576
- if (xb() || Sb()) return {
23830
+ async function ix(e, t = !0) {
23831
+ if (Kb() || qb()) return {
23577
23832
  valid: !0,
23578
23833
  errorCode: null
23579
23834
  };
23580
- let n = Cb();
23835
+ let n = Jb();
23581
23836
  try {
23582
23837
  let r = await fetch(`${n}/v1/validate`, { headers: { "X-API-Key": e } });
23583
23838
  if (r.ok) {
23584
23839
  let e = await r.json();
23585
- return t && e.grant && kb(e.grant), {
23840
+ return t && e.grant && ex(e.grant), {
23586
23841
  valid: !0,
23587
23842
  errorCode: null
23588
23843
  };
23589
23844
  }
23590
23845
  if (r.status >= 400 && r.status < 500) {
23591
- t && Ab();
23846
+ t && tx();
23592
23847
  try {
23593
23848
  return await r.json();
23594
23849
  } catch {
@@ -23600,7 +23855,7 @@ async function Nb(e, t = !0) {
23600
23855
  }
23601
23856
  throw Error(`Server error: ${r.status}`);
23602
23857
  } catch {
23603
- return t ? Mb(e) : {
23858
+ return t ? rx(e) : {
23604
23859
  valid: !1,
23605
23860
  errorCode: "license.invalid"
23606
23861
  };
@@ -23608,7 +23863,7 @@ async function Nb(e, t = !0) {
23608
23863
  }
23609
23864
  //#endregion
23610
23865
  //#region src/hooks/useLicenseValidation.ts
23611
- function Pb(e, t, n = !0) {
23866
+ function ax(e, t, n = !0) {
23612
23867
  let [r, i] = b({
23613
23868
  isValidating: t,
23614
23869
  isValid: !1,
@@ -23628,7 +23883,7 @@ function Pb(e, t, n = !0) {
23628
23883
  isValidating: !0,
23629
23884
  isValid: !1,
23630
23885
  errorCode: null
23631
- }), Nb(e, n).then((e) => {
23886
+ }), ix(e, n).then((e) => {
23632
23887
  r || i({
23633
23888
  isValidating: !1,
23634
23889
  isValid: e.valid,
@@ -23651,7 +23906,7 @@ function Pb(e, t, n = !0) {
23651
23906
  }
23652
23907
  //#endregion
23653
23908
  //#region src/server/auth/AuthState.ts
23654
- var Fb = class {
23909
+ var ox = class {
23655
23910
  token = null;
23656
23911
  get() {
23657
23912
  return this.token;
@@ -23662,13 +23917,13 @@ var Fb = class {
23662
23917
  clear() {
23663
23918
  this.token = null;
23664
23919
  }
23665
- }, Ib = class extends Error {
23920
+ }, sx = class extends Error {
23666
23921
  status;
23667
23922
  code;
23668
23923
  constructor(e) {
23669
23924
  super(e.message), this.name = "ScaleHttpError", this.status = e.status, this.code = e.code;
23670
23925
  }
23671
- }, Lb = class {
23926
+ }, cx = class {
23672
23927
  baseUrl;
23673
23928
  apiKey;
23674
23929
  auth;
@@ -23698,7 +23953,7 @@ var Fb = class {
23698
23953
  signal: r?.signal
23699
23954
  });
23700
23955
  } catch (e) {
23701
- this.notify(new Ib({
23956
+ this.notify(new sx({
23702
23957
  status: 0,
23703
23958
  code: "network",
23704
23959
  message: e instanceof Error ? e.message : String(e)
@@ -23709,7 +23964,7 @@ var Fb = class {
23709
23964
  try {
23710
23965
  e = await s.json();
23711
23966
  } catch {}
23712
- this.notify(new Ib({
23967
+ this.notify(new sx({
23713
23968
  status: s.status,
23714
23969
  code: e.error ?? `http_${s.status}`,
23715
23970
  message: e.message ?? s.statusText
@@ -23720,23 +23975,23 @@ var Fb = class {
23720
23975
  };
23721
23976
  //#endregion
23722
23977
  //#region src/server/endpoints/workspaces.ts
23723
- async function Rb(e, t) {
23978
+ async function lx(e, t) {
23724
23979
  return e.post("/workspaces", {
23725
23980
  primaryKey: t.primaryKey,
23726
23981
  columns: t.columns
23727
23982
  }, { signal: t.signal });
23728
23983
  }
23729
- async function zb(e) {
23984
+ async function ux(e) {
23730
23985
  try {
23731
23986
  await e.http.delete(`/workspaces/${e.workspaceId}`, { signal: e.signal });
23732
23987
  } catch (e) {
23733
- if (e instanceof Ib && e.status === 404) return;
23988
+ if (e instanceof sx && e.status === 404) return;
23734
23989
  throw e;
23735
23990
  }
23736
23991
  }
23737
23992
  //#endregion
23738
23993
  //#region src/server/endpoints/query.ts
23739
- async function Bb(e, t) {
23994
+ async function dx(e, t) {
23740
23995
  let n = await e.http.post(`/workspaces/${e.workspaceId}/query`, {
23741
23996
  page: {
23742
23997
  limit: t.limit,
@@ -23754,12 +24009,12 @@ async function Bb(e, t) {
23754
24009
  }
23755
24010
  //#endregion
23756
24011
  //#region src/server/ScaleClient.ts
23757
- var Vb = class {
24012
+ var fx = class {
23758
24013
  disposed = !1;
23759
24014
  constructor(e) {
23760
24015
  this.deps = e;
23761
24016
  }
23762
- onQuery = (e) => Bb(this.deps, e);
24017
+ onQuery = (e) => dx(this.deps, e);
23763
24018
  onEdit = async (e) => ({
23764
24019
  rejected: !0,
23765
24020
  reason: "Edits are not yet supported in server mode (v0)."
@@ -23776,7 +24031,7 @@ var Vb = class {
23776
24031
  pageSize = void 0;
23777
24032
  scrollSensitivity = void 0;
23778
24033
  dispose = async () => {
23779
- this.disposed || (this.disposed = !0, await zb({
24034
+ this.disposed || (this.disposed = !0, await ux({
23780
24035
  http: this.deps.http,
23781
24036
  workspaceId: this.deps.workspaceId
23782
24037
  }));
@@ -23784,25 +24039,25 @@ var Vb = class {
23784
24039
  };
23785
24040
  //#endregion
23786
24041
  //#region src/server/createScaleClient.ts
23787
- async function Hb(e) {
23788
- let t = new Fb(), n = new Lb({
24042
+ async function px(e) {
24043
+ let t = new ox(), n = new cx({
23789
24044
  baseUrl: e.url,
23790
24045
  apiKey: e.apiKey,
23791
24046
  auth: t,
23792
24047
  onDegraded: e.onDegraded
23793
- }), { workspaceId: r, accessToken: i } = await Rb(n, {
24048
+ }), { workspaceId: r, accessToken: i } = await lx(n, {
23794
24049
  primaryKey: e.primaryKey,
23795
24050
  columns: e.columns,
23796
24051
  signal: e.signal
23797
24052
  });
23798
- return t.set(i), new Vb({
24053
+ return t.set(i), new fx({
23799
24054
  workspaceId: r,
23800
24055
  http: n
23801
24056
  });
23802
24057
  }
23803
24058
  //#endregion
23804
24059
  //#region src/server/errors.ts
23805
- function Ub(e, t, n) {
24060
+ function mx(e, t, n) {
23806
24061
  return {
23807
24062
  code: e,
23808
24063
  message: t,
@@ -23812,7 +24067,7 @@ function Ub(e, t, n) {
23812
24067
  }
23813
24068
  //#endregion
23814
24069
  //#region src/hooks/useScaleClient.ts
23815
- function Wb(e) {
24070
+ function hx(e) {
23816
24071
  let [t, n] = b({ status: "idle" }), r = y(e.columns), i = y(e.primaryKey);
23817
24072
  return m(() => {
23818
24073
  if (!e.enabled) {
@@ -23821,7 +24076,7 @@ function Wb(e) {
23821
24076
  }
23822
24077
  n({ status: "bootstrapping" });
23823
24078
  let t = new AbortController(), a = null;
23824
- return Hb({
24079
+ return px({
23825
24080
  url: e.url,
23826
24081
  apiKey: e.apiKey,
23827
24082
  primaryKey: i.current,
@@ -23830,7 +24085,7 @@ function Wb(e) {
23830
24085
  onDegraded: (e) => {
23831
24086
  t.signal.aborted || n({
23832
24087
  status: "failed",
23833
- error: Kb(e)
24088
+ error: _x(e)
23834
24089
  });
23835
24090
  }
23836
24091
  }).then((e) => {
@@ -23845,7 +24100,7 @@ function Wb(e) {
23845
24100
  }).catch((e) => {
23846
24101
  t.signal.aborted || n({
23847
24102
  status: "failed",
23848
- error: Gb(e)
24103
+ error: gx(e)
23849
24104
  });
23850
24105
  }), () => {
23851
24106
  t.abort(), a?.dispose().catch(() => {});
@@ -23856,30 +24111,30 @@ function Wb(e) {
23856
24111
  e.apiKey
23857
24112
  ]), t;
23858
24113
  }
23859
- function Gb(e) {
23860
- return e instanceof Ib ? e.status === 401 ? Ub(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? Ub("scale.unreachable", e.message, e) : e.status >= 500 ? Ub("scale.server_error", e.message, e) : Ub("scale.bootstrap_failed", e.message, e) : Ub("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
24114
+ function gx(e) {
24115
+ return e instanceof sx ? e.status === 401 ? mx(e.code.startsWith("license.") ? e.code : "license.invalid", e.message, e) : e.status === 0 ? mx("scale.unreachable", e.message, e) : e.status >= 500 ? mx("scale.server_error", e.message, e) : mx("scale.bootstrap_failed", e.message, e) : mx("scale.bootstrap_failed", e instanceof Error ? e.message : String(e), e);
23861
24116
  }
23862
- function Kb(e) {
23863
- return e.status === 0 ? Ub("scale.unreachable", e.message, e) : e.status === 404 ? Ub("scale.workspace_lost", e.message, e) : Ub("scale.server_error", e.message, e);
24117
+ function _x(e) {
24118
+ return e.status === 0 ? mx("scale.unreachable", e.message, e) : e.status === 404 ? mx("scale.workspace_lost", e.message, e) : mx("scale.server_error", e.message, e);
23864
24119
  }
23865
24120
  //#endregion
23866
24121
  //#region src/index.tsx
23867
- function qb(e) {
24122
+ function vx(e) {
23868
24123
  return e === !1 ? { licenseGrant: !1 } : { licenseGrant: e?.licenseGrant ?? !0 };
23869
24124
  }
23870
- function Jb(e) {
24125
+ function yx(e) {
23871
24126
  let t = v(() => new Bo(e.onError), [e.onError]);
23872
24127
  return /* @__PURE__ */ C(yv, {
23873
24128
  errorHandler: t,
23874
24129
  children: /* @__PURE__ */ C(Wl, {
23875
24130
  ...e,
23876
24131
  errorHandler: t,
23877
- children: e.showUploader ? /* @__PURE__ */ C(_b, {}) : /* @__PURE__ */ C(hv, {})
24132
+ children: e.showUploader ? /* @__PURE__ */ C(Hb, {}) : /* @__PURE__ */ C(hv, {})
23878
24133
  })
23879
24134
  });
23880
24135
  }
23881
- function Yb(e) {
23882
- let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = qb(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = Pb(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = Wb({
24136
+ function bx(e) {
24137
+ let t = e.mode ?? "modal", { t: n, rtl: r } = K(), i = r ? "rtl" : "ltr", a = vx(e.localStorage), o = t === "modal" ? e.open : !0, { isValidating: s, isValid: c, errorCode: l } = ax(e.apiKey, t === "modal" ? o : !0, a.licenseGrant), u = e.__server != null, d = hx({
23883
24138
  enabled: !s && c && u,
23884
24139
  url: e.__server?.url ?? "",
23885
24140
  apiKey: e.apiKey,
@@ -23934,7 +24189,7 @@ function Yb(e) {
23934
24189
  code: e,
23935
24190
  message: "License validation failed",
23936
24191
  source: "license"
23937
- } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(_v, { error: d.error }) : /* @__PURE__ */ C(Jb, { ...k }) : j(l ?? "license.invalid");
24192
+ } }), M = () => s ? A(n("dataEditor.license.loading")) : c ? u && d.status === "bootstrapping" ? A(n("dataEditor.connecting.label")) : u && d.status === "failed" ? /* @__PURE__ */ C(_v, { error: d.error }) : /* @__PURE__ */ C(yx, { ...k }) : j(l ?? "license.invalid");
23938
24193
  return t === "inline" ? /* @__PURE__ */ C("div", {
23939
24194
  className: "updog__data-editor updog__data-editor-inline",
23940
24195
  dir: i,
@@ -23954,14 +24209,14 @@ function Yb(e) {
23954
24209
  submitText: n("dataEditor.confirmClose.action")
23955
24210
  })] });
23956
24211
  }
23957
- function Xb(e) {
24212
+ function xx(e) {
23958
24213
  let { translations: t, rtl: n = !1, locale: r = "en", className: i, ...a } = e;
23959
24214
  return /* @__PURE__ */ C(Zr, {
23960
24215
  translations: t,
23961
24216
  rtl: n,
23962
24217
  locale: r,
23963
- children: /* @__PURE__ */ C(Yb, { ...a })
24218
+ children: /* @__PURE__ */ C(bx, { ...a })
23964
24219
  });
23965
24220
  }
23966
24221
  //#endregion
23967
- export { Xb as DataEditor, ou as downloadExampleFile, su as exportDataEditor };
24222
+ export { xx as DataEditor, ou as downloadExampleFile, su as exportDataEditor };