@fileverse-dev/dsheet 4.1.1 → 4.1.2-overhaul-2

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.
@@ -1,9 +1,9 @@
1
1
  import { utils as F, write as it } from "xlsx-js-style";
2
2
  import { Workbook as ct } from "exceljs";
3
3
  import { toast as nt } from "@fileverse/ui";
4
- import { J as ft, c as X, g as ut, a as pt } from "./xlsx-hyperlink-inline-DNeesFv6.js";
5
- import { b as dt } from "./executeStringFunction-BJ00H04h.js";
6
- import { e as ht } from "./index-CsYiH7pp.js";
4
+ import { J as ft, c as X, g as ut, a as pt } from "./xlsx-hyperlink-inline-BFXiCaHX.js";
5
+ import { b as dt } from "./executeStringFunction-adhsb5GH.js";
6
+ import { e as ht } from "./index-BNeQonN_.js";
7
7
  const mt = {
8
8
  1: "thin",
9
9
  2: "hair",
@@ -33,73 +33,73 @@ const mt = {
33
33
  if (!n || !r.l && !r.r && !r.t && !r.b) return;
34
34
  const l = F.encode_cell({ r: o, c: t }), i = {
35
35
  ...e[l] || { t: "z" }
36
- }, f = { ...i.s || {} }, d = { ...f.border || {} };
37
- r.l && (d.left = n), r.r && (d.right = n), r.t && (d.top = n), r.b && (d.bottom = n), f.border = d, i.s = f, e[l] = i;
36
+ }, u = { ...i.s || {} }, d = { ...u.border || {} };
37
+ r.l && (d.left = n), r.r && (d.right = n), r.t && (d.top = n), r.b && (d.bottom = n), u.border = d, i.s = u, e[l] = i;
38
38
  }, xt = (e, o) => {
39
39
  o.forEach((t) => {
40
40
  if (t.rangeType === "cell") {
41
41
  if (!t.value) return;
42
42
  const { row_index: r, col_index: n } = t.value;
43
43
  if (r == null || n == null) return;
44
- const l = t.value, i = F.encode_cell({ r, c: n }), f = {
44
+ const l = t.value, i = F.encode_cell({ r, c: n }), u = {
45
45
  ...e[i] || { t: "z" }
46
- }, d = { ...f.s || {} }, a = { ...d.border || {} };
47
- l.l && (a.left = q(l.l.style, l.l.color)), l.r && (a.right = q(l.r.style, l.r.color)), l.t && (a.top = q(l.t.style, l.t.color)), l.b && (a.bottom = q(l.b.style, l.b.color)), d.border = a, f.s = d, e[i] = f;
46
+ }, d = { ...u.s || {} }, a = { ...d.border || {} };
47
+ l.l && (a.left = q(l.l.style, l.l.color)), l.r && (a.right = q(l.r.style, l.r.color)), l.t && (a.top = q(l.t.style, l.t.color)), l.b && (a.bottom = q(l.b.style, l.b.color)), d.border = a, u.s = d, e[i] = u;
48
48
  } else if (t.rangeType === "range") {
49
49
  const { borderType: r, style: n, color: l, range: i } = t;
50
50
  if (r === "border-none" || !Array.isArray(i) || !n)
51
51
  return;
52
- const f = q(n, l);
53
- if (!f) return;
52
+ const u = q(n, l);
53
+ if (!u) return;
54
54
  i.forEach((d) => {
55
55
  const [a, T] = d.row, [w, k] = d.column;
56
56
  for (let C = a; C <= T; C++)
57
- for (let m = w; m <= k; m++)
57
+ for (let x = w; x <= k; x++)
58
58
  switch (r) {
59
59
  case "border-all":
60
60
  I(
61
61
  e,
62
62
  C,
63
- m,
63
+ x,
64
64
  { l: !0, r: !0, t: !0, b: !0 },
65
- f
65
+ u
66
66
  );
67
67
  break;
68
68
  case "border-outside":
69
69
  I(
70
70
  e,
71
71
  C,
72
- m,
73
- { l: m === w, r: m === k, t: C === a, b: C === T },
74
- f
72
+ x,
73
+ { l: x === w, r: x === k, t: C === a, b: C === T },
74
+ u
75
75
  );
76
76
  break;
77
77
  case "border-inside":
78
78
  I(
79
79
  e,
80
80
  C,
81
- m,
82
- { r: m < k, b: C < T },
83
- f
81
+ x,
82
+ { r: x < k, b: C < T },
83
+ u
84
84
  );
85
85
  break;
86
86
  case "border-horizontal":
87
- I(e, C, m, { b: C < T }, f);
87
+ I(e, C, x, { b: C < T }, u);
88
88
  break;
89
89
  case "border-vertical":
90
- I(e, C, m, { r: m < k }, f);
90
+ I(e, C, x, { r: x < k }, u);
91
91
  break;
92
92
  case "border-left":
93
- m === w && I(e, C, m, { l: !0 }, f);
93
+ x === w && I(e, C, x, { l: !0 }, u);
94
94
  break;
95
95
  case "border-right":
96
- m === k && I(e, C, m, { r: !0 }, f);
96
+ x === k && I(e, C, x, { r: !0 }, u);
97
97
  break;
98
98
  case "border-top":
99
- C === a && I(e, C, m, { t: !0 }, f);
99
+ C === a && I(e, C, x, { t: !0 }, u);
100
100
  break;
101
101
  case "border-bottom":
102
- C === T && I(e, C, m, { b: !0 }, f);
102
+ C === T && I(e, C, x, { b: !0 }, u);
103
103
  break;
104
104
  }
105
105
  });
@@ -136,12 +136,12 @@ function bt(e) {
136
136
  }
137
137
  function yt(e) {
138
138
  return !Array.isArray(e) || e.length === 0 ? "" : e.map((t) => {
139
- const [r, n] = t.row, [l, i] = t.column, f = F.encode_cell({ r, c: l }), d = F.encode_cell({ r: n, c: i });
140
- return f === d ? f : `${f}:${d}`;
139
+ const [r, n] = t.row, [l, i] = t.column, u = F.encode_cell({ r, c: l }), d = F.encode_cell({ r: n, c: i });
140
+ return u === d ? u : `${u}:${d}`;
141
141
  }).filter(Boolean).join(" ");
142
142
  }
143
143
  function Ct(e, o, t) {
144
- const { conditionName: r, conditionValue: n = [], format: l = {} } = e, i = bt(l), f = (a) => a.replace(/"/g, '""'), d = o.split(/[\s:]/)[0];
144
+ const { conditionName: r, conditionValue: n = [], format: l = {} } = e, i = bt(l), u = (a) => a.replace(/"/g, '""'), d = o.split(/[\s:]/)[0];
145
145
  switch (r) {
146
146
  case "greaterThan":
147
147
  case "greaterThanOrEqual":
@@ -187,7 +187,7 @@ function Ct(e, o, t) {
187
187
  operator: "containsText",
188
188
  text: a,
189
189
  formulae: [
190
- `NOT(ISERROR(SEARCH("${f(a)}",${d})))`
190
+ `NOT(ISERROR(SEARCH("${u(a)}",${d})))`
191
191
  ],
192
192
  priority: t,
193
193
  style: i
@@ -201,7 +201,7 @@ function Ct(e, o, t) {
201
201
  operator: "containsText",
202
202
  text: a,
203
203
  formulae: [
204
- `NOT(ISERROR(SEARCH("${f(a)}",${d})))`
204
+ `NOT(ISERROR(SEARCH("${u(a)}",${d})))`
205
205
  ],
206
206
  priority: t,
207
207
  style: i
@@ -214,7 +214,7 @@ function Ct(e, o, t) {
214
214
  type: "notContainsText",
215
215
  operator: "notContainsText",
216
216
  text: a,
217
- formulae: [`ISERROR(SEARCH("${f(a)}",${d}))`],
217
+ formulae: [`ISERROR(SEARCH("${u(a)}",${d}))`],
218
218
  priority: t,
219
219
  style: i
220
220
  };
@@ -227,7 +227,7 @@ function Ct(e, o, t) {
227
227
  type: "notContainsText",
228
228
  operator: "notContainsText",
229
229
  text: a,
230
- formulae: [`ISERROR(SEARCH("${f(a)}",${d}))`],
230
+ formulae: [`ISERROR(SEARCH("${u(a)}",${d}))`],
231
231
  priority: t,
232
232
  style: i
233
233
  };
@@ -240,7 +240,7 @@ function Ct(e, o, t) {
240
240
  operator: "beginsWith",
241
241
  text: a,
242
242
  formulae: [
243
- `LEFT(${d},${a.length})="${f(a)}"`
243
+ `LEFT(${d},${a.length})="${u(a)}"`
244
244
  ],
245
245
  priority: t,
246
246
  style: i
@@ -254,7 +254,7 @@ function Ct(e, o, t) {
254
254
  operator: "beginsWith",
255
255
  text: a,
256
256
  formulae: [
257
- `LEFT(${d},${a.length})="${f(a)}"`
257
+ `LEFT(${d},${a.length})="${u(a)}"`
258
258
  ],
259
259
  priority: t,
260
260
  style: i
@@ -268,7 +268,7 @@ function Ct(e, o, t) {
268
268
  operator: "endsWith",
269
269
  text: a,
270
270
  formulae: [
271
- `RIGHT(${d},${a.length})="${f(a)}"`
271
+ `RIGHT(${d},${a.length})="${u(a)}"`
272
272
  ],
273
273
  priority: t,
274
274
  style: i
@@ -282,7 +282,7 @@ function Ct(e, o, t) {
282
282
  operator: "endsWith",
283
283
  text: a,
284
284
  formulae: [
285
- `RIGHT(${d},${a.length})="${f(a)}"`
285
+ `RIGHT(${d},${a.length})="${u(a)}"`
286
286
  ],
287
287
  priority: t,
288
288
  style: i
@@ -297,7 +297,7 @@ function Ct(e, o, t) {
297
297
  type: "containsText",
298
298
  operator: "equal",
299
299
  text: a,
300
- formulae: [`EXACT(${d},"${f(a)}")`],
300
+ formulae: [`EXACT(${d},"${u(a)}")`],
301
301
  priority: t,
302
302
  style: i
303
303
  };
@@ -393,21 +393,21 @@ function Tt(e, o, t) {
393
393
  if (!Array.isArray(r) || r.length === 0)
394
394
  return { nextPriority: t, pendingDuplicateValues: n };
395
395
  let l = t;
396
- for (const f of r) {
397
- if (f.type !== "default") continue;
398
- const d = yt(f.cellrange);
396
+ for (const u of r) {
397
+ if (u.type !== "default") continue;
398
+ const d = yt(u.cellrange);
399
399
  if (!d) continue;
400
- if (f.conditionName === "duplicateValue") {
401
- const T = String(((i = f.conditionValue) == null ? void 0 : i[0]) ?? "0") === "1" ? "uniqueValues" : "duplicateValues";
400
+ if (u.conditionName === "duplicateValue") {
401
+ const T = String(((i = u.conditionValue) == null ? void 0 : i[0]) ?? "0") === "1" ? "uniqueValues" : "duplicateValues";
402
402
  n.push({
403
403
  ref: d,
404
- format: f.format || {},
404
+ format: u.format || {},
405
405
  priority: l,
406
406
  type: T
407
407
  }), l++;
408
408
  continue;
409
409
  }
410
- const a = Ct(f, d, l);
410
+ const a = Ct(u, d, l);
411
411
  a && (e.addConditionalFormatting({ ref: d, rules: [a] }), l++);
412
412
  }
413
413
  return { nextPriority: l, pendingDuplicateValues: n };
@@ -475,9 +475,9 @@ function kt(e) {
475
475
  if (/\btext=/.test(t) || /\btext=/.test(r)) return o;
476
476
  const l = n.match(/<formula[^>]*>([\s\S]*?)<\/formula>/);
477
477
  if (!l) return o;
478
- const f = l[1].replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").match(/SEARCH\s*\(\s*"([^"]*)"/i);
479
- if (!f) return o;
480
- const d = f[1].replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
478
+ const u = l[1].replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").match(/SEARCH\s*\(\s*"([^"]*)"/i);
479
+ if (!u) return o;
480
+ const d = u[1].replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
481
481
  return `<cfRule${t}type="containsText"${r} text="${d}">${n}</cfRule>`;
482
482
  }
483
483
  );
@@ -486,22 +486,22 @@ async function Rt(e, o) {
486
486
  var i;
487
487
  const t = await ft.loadAsync(e), r = t.file("xl/styles.xml");
488
488
  let n = r ? await r.async("text") : "", l = !1;
489
- for (const [f, d] of Object.entries(t.files)) {
489
+ for (const [u, d] of Object.entries(t.files)) {
490
490
  if (d.dir) continue;
491
- const a = f.match(/^xl\/worksheets\/sheet(\d+)\.xml$/);
491
+ const a = u.match(/^xl\/worksheets\/sheet(\d+)\.xml$/);
492
492
  if (!a) continue;
493
493
  const T = parseInt(a[1], 10) - 1;
494
494
  let w = await d.async("text"), k = !1;
495
495
  const C = kt(w);
496
496
  C !== w && (w = C, k = !0);
497
- const m = ((i = o[T]) == null ? void 0 : i.duplicateValues) ?? [];
498
- for (const B of m) {
499
- const O = wt(B.format), { xml: z, dxfId: Z } = Et(n, O);
497
+ const x = ((i = o[T]) == null ? void 0 : i.duplicateValues) ?? [];
498
+ for (const B of x) {
499
+ const V = wt(B.format), { xml: z, dxfId: Z } = Et(n, V);
500
500
  n = z, l = !0;
501
501
  const K = `<cfRule type="${B.type}" dxfId="${Z}" priority="${B.priority}"/>`;
502
502
  w = At(w, B.ref, K), k = !0;
503
503
  }
504
- k && t.file(f, w);
504
+ k && t.file(u, w);
505
505
  }
506
506
  return l && r && t.file("xl/styles.xml", n), t.generateAsync({ type: "arraybuffer", compression: "DEFLATE" });
507
507
  }
@@ -561,8 +561,8 @@ const Y = (e) => {
561
561
  return ((1 << 24) + (n << 16) + (l << 8) + i).toString(16).slice(1).toUpperCase();
562
562
  }
563
563
  return null;
564
- }, jt = async (e, o, t, r) => {
565
- var n, l, i, f, d, a, T;
564
+ }, Pt = async (e, o, t, r) => {
565
+ var n, l, i, u, d, a, T;
566
566
  if (!(!e.current || !o.current))
567
567
  try {
568
568
  const w = (l = (n = e.current).getWorkbookContext) == null ? void 0 : l.call(n), k = w == null ? void 0 : w.luckysheetfile;
@@ -572,65 +572,65 @@ const Y = (e) => {
572
572
  showCloseButton: !0,
573
573
  duration: 30 * 1e3
574
574
  }), o.current.getArray(t);
575
- const m = e.current.getAllSheets();
576
- m.forEach((h) => ht(h));
577
- const B = F.book_new(), O = m.map(() => /* @__PURE__ */ new Map()), z = /* @__PURE__ */ new Set();
578
- m.forEach((h, W) => {
579
- var J, N, U, L, V;
580
- const R = dt(h), x = F.aoa_to_sheet(R);
581
- Object.keys(x).forEach((p) => {
582
- if (p.startsWith("!")) return;
583
- const b = x[p];
584
- b && (b.t === "s" || b.t === void 0) && b.v !== "" && !isNaN(Number(b.v)) && (x[p] = { ...b, v: Number(b.v), t: "n" });
585
- }), x["!merges"] = [], (J = h.config) != null && J.merge && Object.values(h.config.merge).forEach((p) => {
586
- x["!merges"].push({
587
- s: { r: p.r, c: p.c },
588
- e: { r: p.r + p.rs - 1, c: p.c + p.cs - 1 }
575
+ const x = e.current.getAllSheets();
576
+ x.forEach((m) => ht(m));
577
+ const B = F.book_new(), V = x.map(() => /* @__PURE__ */ new Map()), z = /* @__PURE__ */ new Set();
578
+ x.forEach((m, W) => {
579
+ var J, N, U, L, O;
580
+ const R = dt(m), g = F.aoa_to_sheet(R);
581
+ Object.keys(g).forEach((c) => {
582
+ if (c.startsWith("!")) return;
583
+ const h = g[c];
584
+ h && (h.t === "s" || h.t === void 0) && h.v !== "" && !isNaN(Number(h.v)) && (g[c] = { ...h, v: Number(h.v), t: "n" });
585
+ }), g["!merges"] = [], (J = m.config) != null && J.merge && Object.values(m.config.merge).forEach((c) => {
586
+ g["!merges"].push({
587
+ s: { r: c.r, c: c.c },
588
+ e: { r: c.r + c.rs - 1, c: c.c + c.cs - 1 }
589
589
  });
590
590
  });
591
591
  {
592
- const b = Math.round(3437.714285714286) / 256, c = h.column || 36;
593
- x["!cols"] = [];
594
- for (let s = 0; s < c; s++) {
595
- const g = (U = (N = h.config) == null ? void 0 : N.columnlen) == null ? void 0 : U[s];
596
- if (g !== void 0) {
597
- const u = Math.max(
592
+ const h = Math.round(3437.714285714286) / 256, f = m.column || 36;
593
+ g["!cols"] = [];
594
+ for (let s = 0; s < f; s++) {
595
+ const b = (U = (N = m.config) == null ? void 0 : N.columnlen) == null ? void 0 : U[s];
596
+ if (b !== void 0) {
597
+ const p = Math.max(
598
598
  0,
599
- Math.round((Number(g) - 5) / 7 * 256) / 256
599
+ Math.round((Number(b) - 5) / 7 * 256) / 256
600
600
  );
601
- x["!cols"][s] = { wch: u };
601
+ g["!cols"][s] = { wch: p };
602
602
  } else
603
- x["!cols"][s] = { wch: b };
603
+ g["!cols"][s] = { wch: h };
604
604
  }
605
605
  }
606
606
  {
607
- const p = Math.round(60.48) / 4;
608
- x.sheetFormat = {
609
- ...x.sheetFormat || {},
610
- defaultRowHeight: String(p)
611
- }, (L = h.config) != null && L.rowlen && (x["!rows"] = [], Object.entries(h.config.rowlen).forEach(([b, c]) => {
612
- const s = Math.round(Number(c) * 0.72 * 4) / 4;
613
- x["!rows"][Number(b)] = { hpt: s };
607
+ const c = Math.round(60.48) / 4;
608
+ g.sheetFormat = {
609
+ ...g.sheetFormat || {},
610
+ defaultRowHeight: String(c)
611
+ }, (L = m.config) != null && L.rowlen && (g["!rows"] = [], Object.entries(m.config.rowlen).forEach(([h, f]) => {
612
+ const s = Math.round(Number(f) * 0.72 * 4) / 4;
613
+ g["!rows"][Number(h)] = { hpt: s };
614
614
  }));
615
615
  }
616
616
  const D = /* @__PURE__ */ new Set();
617
- (h.celldata ?? []).forEach((p) => {
618
- var A, S, $, _, j;
619
- const b = p.r, c = p.c, s = p.v || {}, g = F.encode_cell({ r: b, c });
620
- let u = x[g] || {};
621
- if (u = { ...u }, s.f && (u.f = s.f.replace(/^=/, "")), !s.f && ((A = s.ct) == null ? void 0 : A.t) === "inlineStr" && Array.isArray(s.ct.s) ? (u.v = X(s.ct.s), u.t = "s") : u.v = s.v ?? ((_ = ($ = (S = s == null ? void 0 : s.ct) == null ? void 0 : S.s) == null ? void 0 : $[0]) == null ? void 0 : _.v), s.m && (u.w = s.m), !s.f && ((j = s.ct) == null ? void 0 : j.t) === "inlineStr" && Array.isArray(s.ct.s)) {
617
+ (m.celldata ?? []).forEach((c) => {
618
+ var A, S, $, _, P;
619
+ const h = c.r, f = c.c, s = c.v || {}, b = F.encode_cell({ r: h, c: f });
620
+ let p = g[b] || {};
621
+ if (p = { ...p }, s.f && (p.f = s.f.replace(/^=/, "")), !s.f && ((A = s.ct) == null ? void 0 : A.t) === "inlineStr" && Array.isArray(s.ct.s) ? (p.v = X(s.ct.s), p.t = "s") : p.v = s.v ?? ((_ = ($ = (S = s == null ? void 0 : s.ct) == null ? void 0 : S.s) == null ? void 0 : $[0]) == null ? void 0 : _.v), s.m && (p.w = s.m), !s.f && ((P = s.ct) == null ? void 0 : P.t) === "inlineStr" && Array.isArray(s.ct.s)) {
622
622
  const M = rt(s.ct.s);
623
- M && O[W].set(g, M);
623
+ M && V[W].set(b, M);
624
624
  }
625
- if (s.ct && (s.ct.fa && (u.z = s.ct.fa), s.ct.t && s.ct.t !== "inlineStr" && (u.t = s.ct.t === "d" ? "n" : s.ct.t)), typeof u.v == "number" && !u.t && (u.t = "n"), u.s = u.s || {}, s.bg) {
625
+ if (s.ct && (s.ct.fa && (p.z = s.ct.fa), s.ct.t && s.ct.t !== "inlineStr" && (p.t = s.ct.t === "d" ? "n" : s.ct.t)), typeof p.v == "number" && !p.t && (p.t = "n"), p.s = p.s || {}, s.bg) {
626
626
  const M = Y(s.bg);
627
- M && (u.s.fill = {
627
+ M && (p.s.fill = {
628
628
  patternType: "solid",
629
629
  fgColor: { rgb: M }
630
630
  });
631
631
  }
632
- u.s.font = {
633
- ...u.s.font || {},
632
+ p.s.font = {
633
+ ...p.s.font || {},
634
634
  bold: s.bl === 1 || void 0,
635
635
  italic: s.it === 1 || void 0,
636
636
  strike: s.cl === 1 || void 0,
@@ -643,134 +643,138 @@ const Y = (e) => {
643
643
  })()
644
644
  };
645
645
  const E = { 0: "center", 1: "left", 2: "right" }, y = { 0: "center", 1: "top", 2: "bottom" };
646
- u.s.alignment = {
647
- ...u.s.alignment || {},
646
+ p.s.alignment = {
647
+ ...p.s.alignment || {},
648
648
  wrapText: s.tb === "1" || s.tb === "2" ? !0 : void 0,
649
649
  textRotation: s.tr !== void 0 ? s.tr : void 0
650
- }, u.s.alignment.horizontal = E[s.ht] || void 0, u.s.alignment.vertical = y[s.vt] || void 0, s.tb !== void 0 && (u.s.alignment = u.s.alignment || {}, s.tb === "1" ? u.s.alignment.wrapText = !0 : s.tb === "2" && (u.s.alignment.shrinkToFit = !0)), D.add(g), x[g] = u;
651
- }), R.forEach((p, b) => {
652
- Array.isArray(p) && p.forEach((c, s) => {
653
- if (!c || typeof c != "object") return;
654
- const g = F.encode_cell({ r: b, c: s });
655
- if (D.has(g)) return;
656
- const u = !!c.f, E = c.bg || c.bl || c.it || c.cl || c.un || c.fs || c.ff || c.fc || c.ht !== void 0 || c.vt !== void 0 || c.tb !== void 0 || c.tr !== void 0;
657
- if (!u && !E) return;
658
- const y = { ...x[g] || {} };
659
- if (y.s = y.s || {}, u && (y.f = c.f.replace(/^=/, "")), c.bg) {
660
- const $ = Y(c.bg);
650
+ }, p.s.alignment.horizontal = E[s.ht] || void 0, p.s.alignment.vertical = y[s.vt] || void 0, s.tb !== void 0 && (p.s.alignment = p.s.alignment || {}, s.tb === "1" ? p.s.alignment.wrapText = !0 : s.tb === "2" && (p.s.alignment.shrinkToFit = !0)), D.add(b), g[b] = p;
651
+ }), R.forEach((c, h) => {
652
+ Array.isArray(c) && c.forEach((f, s) => {
653
+ if (!f || typeof f != "object") return;
654
+ const b = F.encode_cell({ r: h, c: s });
655
+ if (D.has(b)) return;
656
+ const p = !!f.f, E = f.bg || f.bl || f.it || f.cl || f.un || f.fs || f.ff || f.fc || f.ht !== void 0 || f.vt !== void 0 || f.tb !== void 0 || f.tr !== void 0;
657
+ if (!p && !E) return;
658
+ const y = { ...g[b] || {} };
659
+ if (y.s = y.s || {}, p && (y.f = f.f.replace(/^=/, "")), f.bg) {
660
+ const $ = Y(f.bg);
661
661
  $ && (y.s.fill = { patternType: "solid", fgColor: { rgb: $ } });
662
662
  }
663
663
  y.s.font = {
664
664
  ...y.s.font || {},
665
- bold: c.bl === 1 || void 0,
666
- italic: c.it === 1 || void 0,
667
- strike: c.cl === 1 || void 0,
668
- underline: c.un === 1 || void 0,
669
- sz: c.fs ?? 10,
670
- name: c.ff ?? void 0,
665
+ bold: f.bl === 1 || void 0,
666
+ italic: f.it === 1 || void 0,
667
+ strike: f.cl === 1 || void 0,
668
+ underline: f.un === 1 || void 0,
669
+ sz: f.fs ?? 10,
670
+ name: f.ff ?? void 0,
671
671
  color: (() => {
672
- const $ = Y(c.fc);
672
+ const $ = Y(f.fc);
673
673
  return $ ? { rgb: $ } : void 0;
674
674
  })()
675
675
  };
676
676
  const A = { 0: "center", 1: "left", 2: "right" }, S = { 0: "center", 1: "top", 2: "bottom" };
677
677
  y.s.alignment = {
678
678
  ...y.s.alignment || {},
679
- horizontal: A[c.ht] || void 0,
680
- vertical: S[c.vt] || void 0,
681
- textRotation: c.tr !== void 0 ? c.tr : void 0
682
- }, c.tb === "1" ? y.s.alignment.wrapText = !0 : c.tb === "2" && (y.s.alignment.shrinkToFit = !0), x[g] = y;
679
+ horizontal: A[f.ht] || void 0,
680
+ vertical: S[f.vt] || void 0,
681
+ textRotation: f.tr !== void 0 ? f.tr : void 0
682
+ }, f.tb === "1" ? y.s.alignment.wrapText = !0 : f.tb === "2" && (y.s.alignment.shrinkToFit = !0), g[b] = y;
683
683
  });
684
- }), R.forEach((p, b) => {
685
- Array.isArray(p) && p.forEach((c, s) => {
684
+ }), R.forEach((c, h) => {
685
+ Array.isArray(c) && c.forEach((f, s) => {
686
686
  var y;
687
- if (!c || ((y = c.ct) == null ? void 0 : y.t) !== "inlineStr" || !Array.isArray(c.ct.s)) return;
688
- const g = F.encode_cell({ r: b, c: s }), u = X(c.ct.s);
689
- x[g] = {
690
- ...x[g] || {},
691
- v: u,
687
+ if (!f || ((y = f.ct) == null ? void 0 : y.t) !== "inlineStr" || !Array.isArray(f.ct.s)) return;
688
+ const b = F.encode_cell({ r: h, c: s }), p = X(f.ct.s);
689
+ g[b] = {
690
+ ...g[b] || {},
691
+ v: p,
692
692
  t: "s"
693
693
  };
694
- const E = rt(c.ct.s);
695
- E && O[W].set(g, E);
694
+ const E = rt(f.ct.s);
695
+ E && V[W].set(b, E);
696
696
  });
697
- }), (V = h.config) != null && V.borderInfo && xt(x, h.config.borderInfo);
698
- const v = h.name.length > 30 ? h.name.slice(0, 30) : h.name;
697
+ }), (O = m.config) != null && O.borderInfo && xt(g, m.config.borderInfo), Object.keys(g).forEach((c) => {
698
+ if (c.startsWith("!")) return;
699
+ const h = g[c];
700
+ h && h.s && h.t == null && h.v == null && h.f == null && (h.t = "s", h.v = "");
701
+ });
702
+ const v = m.name.length > 30 ? m.name.slice(0, 30) : m.name;
699
703
  if (z.has(v)) {
700
- const p = v !== h.name ? `"${h.name}" is too long and collides with another sheet after being shortened to "${v}"` : `Two sheets share the name "${h.name}"`;
704
+ const c = v !== m.name ? `"${m.name}" is too long and collides with another sheet after being shortened to "${v}"` : `Two sheets share the name "${m.name}"`;
701
705
  throw new Error(
702
- `${p}. Sheet names must be unique. Rename one and try again.`
706
+ `${c}. Sheet names must be unique. Rename one and try again.`
703
707
  );
704
708
  }
705
- z.add(v), F.book_append_sheet(B, x, v);
709
+ z.add(v), F.book_append_sheet(B, g, v);
706
710
  });
707
711
  const Z = await (r == null ? void 0 : r(t)) || "Untitled", K = it(B, {
708
712
  bookType: "xlsx",
709
713
  type: "array",
710
714
  compression: !0
711
- }), P = new ct();
712
- await P.xlsx.load(K);
713
- const H = P.model;
714
- (f = (i = H == null ? void 0 : H.styles) == null ? void 0 : i.fonts) != null && f[0] && (H.styles.fonts[0] = { ...H.styles.fonts[0], size: 10 });
715
- const tt = m.map(() => ({
715
+ }), j = new ct();
716
+ await j.xlsx.load(K);
717
+ const H = j.model;
718
+ (u = (i = H == null ? void 0 : H.styles) == null ? void 0 : i.fonts) != null && u[0] && (H.styles.fonts[0] = { ...H.styles.fonts[0], size: 10 });
719
+ const tt = x.map(() => ({
716
720
  duplicateValues: []
717
721
  }));
718
- m.forEach((h, W) => {
719
- const R = P.worksheets[W];
722
+ x.forEach((m, W) => {
723
+ const R = j.worksheets[W];
720
724
  if (!R) return;
721
- vt(R, O[W]);
722
- const x = h.data;
723
- Object.entries(h.hyperlink || {}).forEach(([L, V]) => {
725
+ vt(R, V[W]);
726
+ const g = m.data;
727
+ Object.entries(m.hyperlink || {}).forEach(([L, O]) => {
724
728
  var A, S, $, _;
725
- const p = ut(V);
726
- if (!(p != null && p.linkAddress)) return;
727
- const [b, c] = L.split("_").map(Number);
728
- if (Number.isNaN(b) || Number.isNaN(c)) return;
729
- const s = F.encode_cell({ r: b, c }), g = R.getCell(s), u = (A = x == null ? void 0 : x[b]) == null ? void 0 : A[c];
729
+ const c = ut(O);
730
+ if (!(c != null && c.linkAddress)) return;
731
+ const [h, f] = L.split("_").map(Number);
732
+ if (Number.isNaN(h) || Number.isNaN(f)) return;
733
+ const s = F.encode_cell({ r: h, c: f }), b = R.getCell(s), p = (A = g == null ? void 0 : g[h]) == null ? void 0 : A[f];
730
734
  let E = "";
731
- u && typeof u == "object" && ((S = u.ct) == null ? void 0 : S.t) === "inlineStr" && Array.isArray(u.ct.s) && (E = X(u.ct.s));
732
- const y = E || (typeof g.text == "string" && g.text.length > 0 ? g.text : (($ = g.value) == null ? void 0 : $.text) || (Array.isArray((_ = g.value) == null ? void 0 : _.richText) ? g.value.richText.map((j) => j.text || "").join("") : "") || "");
733
- g.value = {
734
- text: y || p.linkAddress,
735
- hyperlink: p.linkAddress
735
+ p && typeof p == "object" && ((S = p.ct) == null ? void 0 : S.t) === "inlineStr" && Array.isArray(p.ct.s) && (E = X(p.ct.s));
736
+ const y = E || (typeof b.text == "string" && b.text.length > 0 ? b.text : (($ = b.value) == null ? void 0 : $.text) || (Array.isArray((_ = b.value) == null ? void 0 : _.richText) ? b.value.richText.map((P) => P.text || "").join("") : "") || "");
737
+ b.value = {
738
+ text: y || c.linkAddress,
739
+ hyperlink: c.linkAddress
736
740
  };
737
741
  });
738
- const { nextPriority: D, pendingDuplicateValues: v } = Tt(R, h, 1);
742
+ const { nextPriority: D, pendingDuplicateValues: v } = Tt(R, m, 1);
739
743
  tt[W] = { duplicateValues: v };
740
744
  let J = D;
741
- if (!h.dataVerification) return;
745
+ if (!m.dataVerification) return;
742
746
  const N = R;
743
747
  N.dataValidations || (N.dataValidations = { model: {} }), N.dataValidations.model || (N.dataValidations.model = {});
744
748
  const U = N.dataValidations.model;
745
- Object.entries(h.dataVerification).forEach(([L, V]) => {
746
- const p = V;
747
- if (p.type !== "dropdown" && p.type !== "checkbox") return;
748
- const [b, c] = L.split("_").map(Number), s = F.encode_cell({ r: b, c });
749
- if (p.type === "checkbox") {
750
- const u = (p.value1 || "TRUE").trim(), E = (p.value2 || "FALSE").trim(), y = [u, E].filter(Boolean);
749
+ Object.entries(m.dataVerification).forEach(([L, O]) => {
750
+ const c = O;
751
+ if (c.type !== "dropdown" && c.type !== "checkbox") return;
752
+ const [h, f] = L.split("_").map(Number), s = F.encode_cell({ r: h, c: f });
753
+ if (c.type === "checkbox") {
754
+ const p = (c.value1 || "TRUE").trim(), E = (c.value2 || "FALSE").trim(), y = [p, E].filter(Boolean);
751
755
  U[s] = {
752
756
  type: "list",
753
757
  allowBlank: !0,
754
758
  formulae: [`"${y.join(",")}"`],
755
- showInputMessage: !!p.hintShow,
756
- prompt: p.hintValue || "",
757
- showErrorMessage: !!p.prohibitInput
759
+ showInputMessage: !!c.hintShow,
760
+ prompt: c.hintValue || "",
761
+ showErrorMessage: !!c.prohibitInput
758
762
  };
759
763
  return;
760
764
  }
761
- const g = (p.value1 || "").split(",").map((u) => u.trim()).filter(Boolean);
762
- if (g.length !== 0 && (U[s] = {
765
+ const b = (c.value1 || "").split(",").map((p) => p.trim()).filter(Boolean);
766
+ if (b.length !== 0 && (U[s] = {
763
767
  type: "list",
764
768
  allowBlank: !0,
765
- formulae: [`"${g.join(",")}"`],
766
- showInputMessage: !!p.hintShow,
767
- prompt: p.hintValue || "",
768
- showErrorMessage: !!p.prohibitInput
769
- }, p.color)) {
770
- const u = p.color.split(",").map((A) => parseInt(A.trim(), 10)), E = (A) => Math.max(0, Math.min(255, A)).toString(16).padStart(2, "0").toUpperCase(), y = g.map((A, S) => {
771
- const $ = u[S * 3], _ = u[S * 3 + 1], j = u[S * 3 + 2];
772
- if (isNaN($) || isNaN(_) || isNaN(j)) return null;
773
- const M = `FF${E($)}${E(_)}${E(j)}`;
769
+ formulae: [`"${b.join(",")}"`],
770
+ showInputMessage: !!c.hintShow,
771
+ prompt: c.hintValue || "",
772
+ showErrorMessage: !!c.prohibitInput
773
+ }, c.color)) {
774
+ const p = c.color.split(",").map((A) => parseInt(A.trim(), 10)), E = (A) => Math.max(0, Math.min(255, A)).toString(16).padStart(2, "0").toUpperCase(), y = b.map((A, S) => {
775
+ const $ = p[S * 3], _ = p[S * 3 + 1], P = p[S * 3 + 2];
776
+ if (isNaN($) || isNaN(_) || isNaN(P)) return null;
777
+ const M = `FF${E($)}${E(_)}${E(P)}`;
774
778
  return {
775
779
  type: "cellIs",
776
780
  operator: "equal",
@@ -791,28 +795,28 @@ const Y = (e) => {
791
795
  });
792
796
  }
793
797
  });
794
- }), m.forEach((h, W) => {
798
+ }), x.forEach((m, W) => {
795
799
  var v;
796
- if (!((v = h.images) != null && v.length)) return;
797
- const R = P.worksheets[W];
800
+ if (!((v = m.images) != null && v.length)) return;
801
+ const R = j.worksheets[W];
798
802
  if (!R) return;
799
- const x = Number(h.defaultColWidth) || 99, D = Number(h.defaultRowHeight) || 21;
803
+ const g = Number(m.defaultColWidth) || 99, D = Number(m.defaultRowHeight) || 21;
800
804
  pt(
801
805
  R,
802
- P,
803
- h.images,
804
- h,
805
- x,
806
+ j,
807
+ m.images,
808
+ m,
809
+ g,
806
810
  D
807
811
  );
808
812
  });
809
- const { applyDefinedNamesToExcelWorkbook: ot } = await import("./xlsx-defined-names-Klp22jvp.js");
813
+ const { applyDefinedNamesToExcelWorkbook: ot } = await import("./xlsx-defined-names-C1Hn6bYn.js");
810
814
  ot(
811
- P,
815
+ j,
812
816
  (T = (a = (d = e.current).getWorkbookContext) == null ? void 0 : a.call(d)) == null ? void 0 : T.definedNames,
813
- m
817
+ x
814
818
  );
815
- const at = await P.xlsx.writeBuffer(), st = await Rt(at, tt), lt = new Blob([st], {
819
+ const at = await j.xlsx.writeBuffer(), st = await Rt(at, tt), lt = new Blob([st], {
816
820
  type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
817
821
  }), et = URL.createObjectURL(lt), Q = document.createElement("a");
818
822
  Q.href = et, Q.download = `${Z}.xlsx`, Q.click(), URL.revokeObjectURL(et);
@@ -827,5 +831,5 @@ const Y = (e) => {
827
831
  }
828
832
  };
829
833
  export {
830
- jt as handleExportToXLSX
834
+ Pt as handleExportToXLSX
831
835
  };