@fileverse-dev/dsheet 4.1.27-stabilise-package-2 → 4.1.28

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 (134) hide show
  1. package/README.md +0 -10
  2. package/dist/editor/components/skeleton-loader.d.ts +1 -2
  3. package/dist/editor/contexts/editor-context.d.ts +0 -10
  4. package/dist/editor/hooks/use-celldata-compaction.d.ts +2 -44
  5. package/dist/editor/hooks/use-editor-data.d.ts +0 -1
  6. package/dist/editor/hooks/use-editor-sync.d.ts +1 -5
  7. package/dist/editor/types.d.ts +1 -47
  8. package/dist/editor/utils/after-update-cell.d.ts +0 -6
  9. package/dist/editor/utils/apply-comment-markers.d.ts +1 -3
  10. package/dist/editor/utils/editor-handle.d.ts +1 -1
  11. package/dist/editor/utils/remote-apply-guard.d.ts +0 -45
  12. package/dist/editor/utils/sheet-ydoc-sync-utils.d.ts +4 -13
  13. package/dist/editor/utils/update-ydoc.d.ts +1 -9
  14. package/dist/editor/utils/xlsx-export-impl.d.ts +0 -1
  15. package/dist/editor/utils/xlsx-export.d.ts +0 -1
  16. package/dist/{executeStringFunction-D1SB3Bwm.js → executeStringFunction-KWYZ3QNg.js} +13304 -14042
  17. package/dist/formula.js +1 -1
  18. package/dist/{index-DuRBkNo8.js → index-DiA_gqm4.js} +22384 -23650
  19. package/dist/index.d.ts +2 -3
  20. package/dist/index.es.js +55 -58
  21. package/dist/persistence-utils-BXFajzvq.js +98 -0
  22. package/dist/persistence-utils.d.ts +0 -2
  23. package/dist/persistence.d.ts +0 -13
  24. package/dist/persistence.js +74 -122
  25. package/dist/sheet-engine/core/api/cell.d.ts +1 -25
  26. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +0 -1
  27. package/dist/sheet-engine/core/index.d.ts +1 -1
  28. package/dist/sheet-engine/core/modules/border.d.ts +0 -9
  29. package/dist/sheet-engine/core/modules/dataVerification.d.ts +0 -15
  30. package/dist/sheet-engine/core/modules/formula-async-eval.d.ts +0 -5
  31. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +0 -2
  32. package/dist/sheet-engine/core/modules/formula-transitive-deps.d.ts +1 -26
  33. package/dist/sheet-engine/core/modules/formula.d.ts +1 -87
  34. package/dist/sheet-engine/core/modules/index.d.ts +2 -3
  35. package/dist/sheet-engine/core/modules/rowcol.d.ts +0 -8
  36. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.d.ts +0 -14
  37. package/dist/sheet-engine/core/settings.d.ts +1 -11
  38. package/dist/sheet-engine/core/utils/filter-selection.d.ts +3 -0
  39. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +2 -29
  40. package/dist/sheet-engine/react/components/ContextMenu/FilterMenu.d.ts +2 -2
  41. package/dist/sheet-engine/react/components/ContextMenu/SheetTab.d.ts +2 -2
  42. package/dist/sheet-engine/react/components/ContextMenu/index.d.ts +2 -2
  43. package/dist/sheet-engine/react/components/SVGDefines.d.ts +2 -2
  44. package/dist/sheet-engine/react/components/SheetTab/index.d.ts +2 -2
  45. package/dist/sheet-engine/react/components/Toolbar/index.d.ts +2 -2
  46. package/dist/sheet-engine/react/components/Workbook/api.d.ts +0 -4
  47. package/dist/sheet-engine/react/components/Workbook/index.d.ts +0 -2
  48. package/dist/sheet-engine/react/context/index.d.ts +0 -15
  49. package/dist/style.css +1 -1
  50. package/dist/sync-local/SyncManager.d.ts +2 -2
  51. package/dist/sync-local/socketClient.d.ts +0 -2
  52. package/dist/sync-local/types/index.d.ts +1 -5
  53. package/dist/{use-xlsx-import-impl-DflJ_tOs.js → use-xlsx-import-impl-DVsVdpLm.js} +119 -120
  54. package/dist/{xlsx-defined-names-Bz4lZarM.js → xlsx-defined-names-BqMo-DgB.js} +2 -2
  55. package/dist/xlsx-export-impl-D2KWcmcg.js +880 -0
  56. package/dist/{xlsx-hyperlink-inline-DPSsT1W8.js → xlsx-hyperlink-inline-D15rKG4m.js} +2 -2
  57. package/package.json +1 -1
  58. package/dist/editor/utils/active-sheet-keeper.test.d.ts +0 -1
  59. package/dist/editor/utils/after-update-cell.test.d.ts +0 -1
  60. package/dist/editor/utils/apply-comment-markers.test.d.ts +0 -1
  61. package/dist/editor/utils/calc-chain-ydoc-update.test.d.ts +0 -1
  62. package/dist/editor/utils/content-change.d.ts +0 -48
  63. package/dist/editor/utils/content-change.test.d.ts +0 -1
  64. package/dist/editor/utils/content-fingerprint.d.ts +0 -37
  65. package/dist/editor/utils/content-fingerprint.test.d.ts +0 -1
  66. package/dist/editor/utils/format-gate.d.ts +0 -27
  67. package/dist/editor/utils/format-gate.test.d.ts +0 -1
  68. package/dist/editor/utils/legacy-on-change.d.ts +0 -20
  69. package/dist/editor/utils/legacy-on-change.test.d.ts +0 -1
  70. package/dist/editor/utils/patch-plain-celldata.d.ts +0 -19
  71. package/dist/editor/utils/patch-plain-celldata.test.d.ts +0 -1
  72. package/dist/editor/utils/rebuild-indexeddb-store.d.ts +0 -19
  73. package/dist/editor/utils/rebuild-indexeddb-store.failure.test.d.ts +0 -1
  74. package/dist/editor/utils/rebuild-indexeddb-store.test.d.ts +0 -1
  75. package/dist/editor/utils/remote-apply-guard.test.d.ts +0 -1
  76. package/dist/editor/utils/sheet-ydoc-sync-utils.test.d.ts +0 -1
  77. package/dist/editor/utils/structural-edit-formula-sync.test.d.ts +0 -1
  78. package/dist/editor/utils/structural-edit-other-tabs.test.d.ts +0 -1
  79. package/dist/editor/utils/wait-for-sync.d.ts +0 -43
  80. package/dist/editor/utils/wait-for-sync.test.d.ts +0 -1
  81. package/dist/persistence-utils-CSKBobX8.js +0 -151
  82. package/dist/persistence.append.test.d.ts +0 -1
  83. package/dist/persistence.fingerprint.test.d.ts +0 -1
  84. package/dist/sheet-engine/core/api/remote-apply.test.d.ts +0 -1
  85. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.test.d.ts +0 -1
  86. package/dist/sheet-engine/core/modules/b6-ydoc-writes.test.d.ts +0 -1
  87. package/dist/sheet-engine/core/modules/cell-shift-dep-graph.test.d.ts +0 -1
  88. package/dist/sheet-engine/core/modules/cell-shift.d.ts +0 -11
  89. package/dist/sheet-engine/core/modules/cell.commit-ydoc.test.d.ts +0 -1
  90. package/dist/sheet-engine/core/modules/engine-hot-spots.test.d.ts +0 -1
  91. package/dist/sheet-engine/core/modules/formula-dep-text.d.ts +0 -23
  92. package/dist/sheet-engine/core/modules/formula-dep-text.test.d.ts +0 -1
  93. package/dist/sheet-engine/core/modules/formula-edge-update.d.ts +0 -13
  94. package/dist/sheet-engine/core/modules/formula-narrowing.test.d.ts +0 -1
  95. package/dist/sheet-engine/core/modules/formula-tab-load.test.d.ts +0 -1
  96. package/dist/sheet-engine/core/modules/formula-warmup.d.ts +0 -33
  97. package/dist/sheet-engine/core/modules/formula-warmup.test.d.ts +0 -1
  98. package/dist/sheet-engine/core/modules/formula-wide-grid-growth.test.d.ts +0 -1
  99. package/dist/sheet-engine/core/modules/formula.dep-graph.test.d.ts +0 -1
  100. package/dist/sheet-engine/core/modules/formula.str-change.test.d.ts +0 -1
  101. package/dist/sheet-engine/core/modules/formula.wide-seed.test.d.ts +0 -1
  102. package/dist/sheet-engine/core/modules/history-calc-chain.d.ts +0 -39
  103. package/dist/sheet-engine/core/modules/history-calc-chain.test.d.ts +0 -1
  104. package/dist/sheet-engine/core/modules/history-celldata.d.ts +0 -25
  105. package/dist/sheet-engine/core/modules/history-grid-size.d.ts +0 -16
  106. package/dist/sheet-engine/core/modules/history-grid-size.test.d.ts +0 -1
  107. package/dist/sheet-engine/core/modules/rowcol-dep-graph.test.d.ts +0 -1
  108. package/dist/sheet-engine/core/modules/rowcol-refused-edit.test.d.ts +0 -1
  109. package/dist/sheet-engine/core/modules/rowcol-unloaded-history.test.d.ts +0 -1
  110. package/dist/sheet-engine/core/modules/structural-edit-prep.d.ts +0 -36
  111. package/dist/sheet-engine/core/modules/structural-edit-prep.test.d.ts +0 -1
  112. package/dist/sheet-engine/core/paste/paste-dep-graph.test.d.ts +0 -1
  113. package/dist/sheet-engine/core/paste-helpers/calculate-range-cell-size.test.d.ts +0 -1
  114. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.d.ts +0 -20
  115. package/dist/sheet-engine/react/components/NotationBoxes/shown-comments.test.d.ts +0 -1
  116. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.d.ts +0 -7
  117. package/dist/sheet-engine/react/components/SheetOverlay/editing-as-formula.test.d.ts +0 -1
  118. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.d.ts +0 -44
  119. package/dist/sheet-engine/react/components/SheetOverlay/hover-tracker.test.d.ts +0 -1
  120. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.d.ts +0 -9
  121. package/dist/sheet-engine/react/components/Toolbar/FunctionList/group-functions.test.d.ts +0 -1
  122. package/dist/sheet-engine/react/components/Workbook/denomination-scan.d.ts +0 -16
  123. package/dist/sheet-engine/react/components/Workbook/denomination-scan.test.d.ts +0 -1
  124. package/dist/sheet-engine/react/components/Workbook/stable-handle.d.ts +0 -8
  125. package/dist/sheet-engine/react/components/Workbook/stable-handle.test.d.ts +0 -1
  126. package/dist/sheet-engine/react/context/use-workbook-store.d.ts +0 -30
  127. package/dist/sheet-engine/react/context/workbook-store.d.ts +0 -30
  128. package/dist/sheet-engine/react/context/workbook-store.test.d.ts +0 -1
  129. package/dist/sync-local/SyncManager.remote-apply.test.d.ts +0 -1
  130. package/dist/sync-local/SyncManager.test.d.ts +0 -1
  131. package/dist/sync-local/socketClient.test.d.ts +0 -1
  132. package/dist/xlsx-export-impl-CxEnpZJO.js +0 -903
  133. /package/dist/editor/{hooks/use-celldata-compaction.test.d.ts → utils/filter-select-ydoc-update.test.d.ts} +0 -0
  134. /package/dist/{editor/hooks/use-editor-sync.test.d.ts → sheet-engine/core/modules/filter.test.d.ts} +0 -0
@@ -1,903 +0,0 @@
1
- import { utils as S, write as tt } from "xlsx-js-style";
2
- import { Workbook as it } from "exceljs";
3
- import { toast as rt } from "@fileverse/ui";
4
- import { J as ct, c as X, g as lt, a as ft } from "./xlsx-hyperlink-inline-DPSsT1W8.js";
5
- import { b as ut } from "./executeStringFunction-D1SB3Bwm.js";
6
- import { e as pt, r as dt } from "./index-DuRBkNo8.js";
7
- const mt = {
8
- 1: "thin",
9
- 2: "hair",
10
- 3: "dotted",
11
- 4: "dashed",
12
- 5: "dashDot",
13
- 6: "dashDotDot",
14
- 7: "double",
15
- 8: "medium",
16
- 9: "mediumDashed",
17
- 10: "mediumDashDot",
18
- 11: "mediumDashDotDot",
19
- 12: "slantDashDot",
20
- 13: "thick"
21
- }, ht = (t) => {
22
- if (typeof t != "string") return "000000";
23
- const r = t.replace("#", "").toUpperCase();
24
- return r.length === 3 ? r.replace(/(.)/g, "$1$1") : r.length === 6 ? r : "000000";
25
- }, V = (t, r) => {
26
- const e = Number(t);
27
- if (e)
28
- return {
29
- style: mt[e] ?? "thin",
30
- color: { rgb: ht(r) }
31
- };
32
- }, W = (t, r, e, o, n) => {
33
- if (!n || !o.l && !o.r && !o.t && !o.b) return;
34
- const a = S.encode_cell({ r, c: e }), c = {
35
- ...t[a] || { t: "z" }
36
- }, l = { ...c.s || {} }, d = { ...l.border || {} };
37
- o.l && (d.left = n), o.r && (d.right = n), o.t && (d.top = n), o.b && (d.bottom = n), l.border = d, c.s = l, t[a] = c;
38
- }, gt = (t, r) => {
39
- r.forEach((e) => {
40
- if (e.rangeType === "cell") {
41
- if (!e.value) return;
42
- const { row_index: o, col_index: n } = e.value;
43
- if (o == null || n == null) return;
44
- const a = e.value, c = S.encode_cell({ r: o, c: n }), l = {
45
- ...t[c] || { t: "z" }
46
- }, d = { ...l.s || {} }, s = { ...d.border || {} };
47
- a.l && (s.left = V(a.l.style, a.l.color)), a.r && (s.right = V(a.r.style, a.r.color)), a.t && (s.top = V(a.t.style, a.t.color)), a.b && (s.bottom = V(a.b.style, a.b.color)), d.border = s, l.s = d, t[c] = l;
48
- } else if (e.rangeType === "range") {
49
- const { borderType: o, style: n, color: a, range: c } = e;
50
- if (o === "border-none" || !Array.isArray(c) || !n)
51
- return;
52
- const l = V(n, a);
53
- if (!l) return;
54
- c.forEach((d) => {
55
- const [s, C] = d.row, [F, E] = d.column;
56
- for (let b = s; b <= C; b++)
57
- for (let T = F; T <= E; T++)
58
- switch (o) {
59
- case "border-all":
60
- W(
61
- t,
62
- b,
63
- T,
64
- { l: !0, r: !0, t: !0, b: !0 },
65
- l
66
- );
67
- break;
68
- case "border-outside":
69
- W(
70
- t,
71
- b,
72
- T,
73
- { l: T === F, r: T === E, t: b === s, b: b === C },
74
- l
75
- );
76
- break;
77
- case "border-inside":
78
- W(
79
- t,
80
- b,
81
- T,
82
- { r: T < E, b: b < C },
83
- l
84
- );
85
- break;
86
- case "border-horizontal":
87
- W(t, b, T, { b: b < C }, l);
88
- break;
89
- case "border-vertical":
90
- W(t, b, T, { r: T < E }, l);
91
- break;
92
- case "border-left":
93
- T === F && W(t, b, T, { l: !0 }, l);
94
- break;
95
- case "border-right":
96
- T === E && W(t, b, T, { r: !0 }, l);
97
- break;
98
- case "border-top":
99
- b === s && W(t, b, T, { t: !0 }, l);
100
- break;
101
- case "border-bottom":
102
- b === C && W(t, b, T, { b: !0 }, l);
103
- break;
104
- }
105
- });
106
- }
107
- });
108
- };
109
- function J(t) {
110
- if (!t || typeof t != "string") return null;
111
- const r = t.trim();
112
- if (r.startsWith("#")) {
113
- const o = r.replace("#", "").toUpperCase();
114
- return o.length === 3 ? "FF" + o.split("").map((n) => n + n).join("") : o.length === 6 ? "FF" + o : null;
115
- }
116
- const e = r.match(/rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)/i);
117
- if (e) {
118
- const o = (n) => Math.min(255, Math.max(0, Math.round(n))).toString(16).padStart(2, "0").toUpperCase();
119
- return "FF" + o(parseFloat(e[1])) + o(parseFloat(e[2])) + o(parseFloat(e[3]));
120
- }
121
- return null;
122
- }
123
- function xt(t) {
124
- const r = {}, e = {};
125
- if (t.textColor && t.textColor.toLowerCase() !== "#000000") {
126
- const n = J(t.textColor);
127
- n && (e.color = { argb: n });
128
- }
129
- t.bold && (e.bold = !0), t.italic && (e.italic = !0), t.underline && (e.underline = !0), t.strikethrough && (e.strike = !0), Object.keys(e).length > 0 && (r.font = e);
130
- const o = t.cellColor;
131
- if (o && o.toLowerCase() !== "#ffffff") {
132
- const n = J(o);
133
- n && (r.fill = { type: "pattern", pattern: "solid", fgColor: { argb: n } });
134
- }
135
- return r;
136
- }
137
- function bt(t) {
138
- return !Array.isArray(t) || t.length === 0 ? "" : t.map((e) => {
139
- const [o, n] = e.row, [a, c] = e.column, l = S.encode_cell({ r: o, c: a }), d = S.encode_cell({ r: n, c });
140
- return l === d ? l : `${l}:${d}`;
141
- }).filter(Boolean).join(" ");
142
- }
143
- function yt(t, r, e) {
144
- const { conditionName: o, conditionValue: n = [], format: a = {} } = t, c = xt(a), l = (s) => s.replace(/"/g, '""'), d = r.split(/[\s:]/)[0];
145
- switch (o) {
146
- case "greaterThan":
147
- case "greaterThanOrEqual":
148
- case "lessThan":
149
- case "lessThanOrEqual":
150
- case "equal":
151
- return n[0] ? {
152
- type: "cellIs",
153
- operator: o,
154
- formulae: [n[0]],
155
- priority: e,
156
- style: c
157
- } : null;
158
- case "notEqual":
159
- return n[0] ? {
160
- type: "cellIs",
161
- operator: "notEqual",
162
- formulae: [n[0]],
163
- priority: e,
164
- style: c
165
- } : null;
166
- case "between":
167
- return n.length < 2 ? null : {
168
- type: "cellIs",
169
- operator: "between",
170
- formulae: [n[0], n[1]],
171
- priority: e,
172
- style: c
173
- };
174
- case "notBetween":
175
- return n.length < 2 ? null : {
176
- type: "cellIs",
177
- operator: "notBetween",
178
- formulae: [n[0], n[1]],
179
- priority: e,
180
- style: c
181
- };
182
- case "textContains": {
183
- if (!n[0]) return null;
184
- const s = n[0];
185
- return {
186
- type: "containsText",
187
- operator: "containsText",
188
- text: s,
189
- formulae: [
190
- `NOT(ISERROR(SEARCH("${l(s)}",${d})))`
191
- ],
192
- priority: e,
193
- style: c
194
- };
195
- }
196
- case "containsText": {
197
- if (!n[0]) return null;
198
- const s = n[0];
199
- return {
200
- type: "containsText",
201
- operator: "containsText",
202
- text: s,
203
- formulae: [
204
- `NOT(ISERROR(SEARCH("${l(s)}",${d})))`
205
- ],
206
- priority: e,
207
- style: c
208
- };
209
- }
210
- case "textDoesNotContain": {
211
- if (!n[0]) return null;
212
- const s = n[0];
213
- return {
214
- type: "notContainsText",
215
- operator: "notContainsText",
216
- text: s,
217
- formulae: [`ISERROR(SEARCH("${l(s)}",${d}))`],
218
- priority: e,
219
- style: c
220
- };
221
- }
222
- case "notContainsText":
223
- case "notContains": {
224
- if (!n[0]) return null;
225
- const s = n[0];
226
- return {
227
- type: "notContainsText",
228
- operator: "notContainsText",
229
- text: s,
230
- formulae: [`ISERROR(SEARCH("${l(s)}",${d}))`],
231
- priority: e,
232
- style: c
233
- };
234
- }
235
- case "textStartsWith": {
236
- if (!n[0]) return null;
237
- const s = n[0];
238
- return {
239
- type: "beginsWith",
240
- operator: "beginsWith",
241
- text: s,
242
- formulae: [
243
- `LEFT(${d},${s.length})="${l(s)}"`
244
- ],
245
- priority: e,
246
- style: c
247
- };
248
- }
249
- case "beginsWith": {
250
- if (!n[0]) return null;
251
- const s = n[0];
252
- return {
253
- type: "beginsWith",
254
- operator: "beginsWith",
255
- text: s,
256
- formulae: [
257
- `LEFT(${d},${s.length})="${l(s)}"`
258
- ],
259
- priority: e,
260
- style: c
261
- };
262
- }
263
- case "textEndsWith": {
264
- if (!n[0]) return null;
265
- const s = n[0];
266
- return {
267
- type: "endsWith",
268
- operator: "endsWith",
269
- text: s,
270
- formulae: [
271
- `RIGHT(${d},${s.length})="${l(s)}"`
272
- ],
273
- priority: e,
274
- style: c
275
- };
276
- }
277
- case "endsWith": {
278
- if (!n[0]) return null;
279
- const s = n[0];
280
- return {
281
- type: "endsWith",
282
- operator: "endsWith",
283
- text: s,
284
- formulae: [
285
- `RIGHT(${d},${s.length})="${l(s)}"`
286
- ],
287
- priority: e,
288
- style: c
289
- };
290
- }
291
- case "textExactly": {
292
- if (!n[0]) return null;
293
- const s = n[0];
294
- return {
295
- // Keep this in the text-rule family so Google/OOXML readers preserve it
296
- // similarly to other text CF rules.
297
- type: "containsText",
298
- operator: "equal",
299
- text: s,
300
- formulae: [`EXACT(${d},"${l(s)}")`],
301
- priority: e,
302
- style: c
303
- };
304
- }
305
- case "empty":
306
- return {
307
- type: "containsText",
308
- operator: "containsBlanks",
309
- formulae: [`LEN(TRIM(${d}))=0`],
310
- priority: e,
311
- style: c
312
- };
313
- case "containsBlanks":
314
- return {
315
- type: "containsText",
316
- operator: "containsBlanks",
317
- formulae: [`LEN(TRIM(${d}))=0`],
318
- priority: e,
319
- style: c
320
- };
321
- case "notEmpty":
322
- return {
323
- type: "containsText",
324
- operator: "notContainsBlanks",
325
- formulae: [`LEN(TRIM(${d}))>0`],
326
- priority: e,
327
- style: c
328
- };
329
- case "notContainsBlanks":
330
- return {
331
- type: "containsText",
332
- operator: "notContainsBlanks",
333
- formulae: [`LEN(TRIM(${d}))>0`],
334
- priority: e,
335
- style: c
336
- };
337
- case "top10":
338
- return {
339
- type: "top10",
340
- rank: parseInt(n[0] || "10", 10) || 10,
341
- percent: !1,
342
- bottom: !1,
343
- priority: e,
344
- style: c
345
- };
346
- case "top10Percent":
347
- case "top10_percent":
348
- return {
349
- type: "top10",
350
- rank: parseInt(n[0] || "10", 10) || 10,
351
- percent: !0,
352
- bottom: !1,
353
- priority: e,
354
- style: c
355
- };
356
- case "last10":
357
- return {
358
- type: "top10",
359
- rank: parseInt(n[0] || "10", 10) || 10,
360
- percent: !1,
361
- bottom: !0,
362
- priority: e,
363
- style: c
364
- };
365
- case "last10Percent":
366
- case "last10_percent":
367
- return {
368
- type: "top10",
369
- rank: parseInt(n[0] || "10", 10) || 10,
370
- percent: !0,
371
- bottom: !0,
372
- priority: e,
373
- style: c
374
- };
375
- case "aboveAverage":
376
- return { type: "aboveAverage", aboveAverage: !0, priority: e, style: c };
377
- case "belowAverage":
378
- return { type: "aboveAverage", aboveAverage: !1, priority: e, style: c };
379
- case "date":
380
- case "dateIs":
381
- case "dateBefore":
382
- case "dateAfter": {
383
- const s = String(n[0] ?? ""), C = s.startsWith("preset:") ? s.slice(7) : s.toLowerCase();
384
- return C === "today" || C === "tomorrow" || C === "yesterday" ? { type: "timePeriod", timePeriod: C, priority: e, style: c } : C === "pastWeek" ? { type: "timePeriod", timePeriod: "last7Days", priority: e, style: c } : C === "pastMonth" ? { type: "timePeriod", timePeriod: "lastMonth", priority: e, style: c } : C === "pastYear" ? { type: "timePeriod", timePeriod: "lastYear", priority: e, style: c } : null;
385
- }
386
- default:
387
- return null;
388
- }
389
- }
390
- function Tt(t, r, e) {
391
- var c;
392
- const o = r.luckysheet_conditionformat_save, n = [];
393
- if (!Array.isArray(o) || o.length === 0)
394
- return { nextPriority: e, pendingDuplicateValues: n };
395
- let a = e;
396
- for (const l of o) {
397
- if (l.type !== "default") continue;
398
- const d = bt(l.cellrange);
399
- if (!d) continue;
400
- if (l.conditionName === "duplicateValue") {
401
- const C = String(((c = l.conditionValue) == null ? void 0 : c[0]) ?? "0") === "1" ? "uniqueValues" : "duplicateValues";
402
- n.push({
403
- ref: d,
404
- format: l.format || {},
405
- priority: a,
406
- type: C
407
- }), a++;
408
- continue;
409
- }
410
- const s = yt(l, d, a);
411
- s && (t.addConditionalFormatting({ ref: d, rules: [s] }), a++);
412
- }
413
- return { nextPriority: a, pendingDuplicateValues: n };
414
- }
415
- function Ct(t) {
416
- let r = "";
417
- const e = [];
418
- if (t.bold && e.push("<b/>"), t.italic && e.push("<i/>"), t.underline && e.push("<u/>"), t.strikethrough && e.push("<strike/>"), t.textColor && t.textColor.toLowerCase() !== "#000000") {
419
- const n = J(t.textColor);
420
- n && e.push(`<color rgb="${n}"/>`);
421
- }
422
- e.length > 0 && (r += `<font>${e.join("")}</font>`);
423
- const o = t.cellColor;
424
- if (o && o.toLowerCase() !== "#ffffff") {
425
- const n = J(o);
426
- n && (r += `<fill><patternFill patternType="solid"><fgColor rgb="${n}"/></patternFill></fill>`);
427
- }
428
- return `<dxf>${r}</dxf>`;
429
- }
430
- function Et(t, r) {
431
- const e = t.match(/<dxfs count="(\d+)"/);
432
- if (e) {
433
- const o = parseInt(e[1], 10);
434
- return {
435
- xml: t.replace(/<dxfs count="\d+"/, `<dxfs count="${o + 1}"`).replace("</dxfs>", r + "</dxfs>"),
436
- dxfId: o
437
- };
438
- }
439
- return t.includes("<dxfs/>") ? {
440
- xml: t.replace("<dxfs/>", `<dxfs count="1">${r}</dxfs>`),
441
- dxfId: 0
442
- } : {
443
- xml: t.replace(
444
- "</styleSheet>",
445
- `<dxfs count="1">${r}</dxfs></styleSheet>`
446
- ),
447
- dxfId: 0
448
- };
449
- }
450
- function wt(t) {
451
- return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
452
- }
453
- function $t(t, r, e) {
454
- const o = new RegExp(
455
- `(<conditionalFormatting[^>]*\\bsqref="${wt(r)}"[^>]*>)`
456
- );
457
- if (o.test(t))
458
- return t.replace(o, `$1${e}`);
459
- const n = `<conditionalFormatting sqref="${r}">${e}</conditionalFormatting>`;
460
- for (const a of [
461
- "<pageMargins",
462
- "<pageSetup",
463
- "<headerFooter",
464
- "<drawing",
465
- "</worksheet>"
466
- ])
467
- if (t.includes(a))
468
- return t.replace(a, n + a);
469
- return t + n;
470
- }
471
- function At(t) {
472
- return t.replace(
473
- /<cfRule([^>]*)type="containsText"([^>]*?)>([\s\S]*?)<\/cfRule>/g,
474
- (r, e, o, n) => {
475
- if (/\btext=/.test(e) || /\btext=/.test(o)) return r;
476
- const a = n.match(/<formula[^>]*>([\s\S]*?)<\/formula>/);
477
- if (!a) return r;
478
- const l = a[1].replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").match(/SEARCH\s*\(\s*"([^"]*)"/i);
479
- if (!l) return r;
480
- const d = l[1].replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
481
- return `<cfRule${e}type="containsText"${o} text="${d}">${n}</cfRule>`;
482
- }
483
- );
484
- }
485
- async function Ft(t, r) {
486
- var c;
487
- const e = await ct.loadAsync(t), o = e.file("xl/styles.xml");
488
- let n = o ? await o.async("text") : "", a = !1;
489
- for (const [l, d] of Object.entries(e.files)) {
490
- if (d.dir) continue;
491
- const s = l.match(/^xl\/worksheets\/sheet(\d+)\.xml$/);
492
- if (!s) continue;
493
- const C = parseInt(s[1], 10) - 1;
494
- let F = await d.async("text"), E = !1;
495
- const b = At(F);
496
- b !== F && (F = b, E = !0);
497
- const T = ((c = r[C]) == null ? void 0 : c.duplicateValues) ?? [];
498
- for (const j of T) {
499
- const Y = Ct(j.format), { xml: G, dxfId: H } = Et(n, Y);
500
- n = G, a = !0;
501
- const U = `<cfRule type="${j.type}" dxfId="${H}" priority="${j.priority}"/>`;
502
- F = $t(F, j.ref, U), E = !0;
503
- }
504
- E && e.file(l, F);
505
- }
506
- return a && o && e.file("xl/styles.xml", n), e.generateAsync({ type: "arraybuffer", compression: "DEFLATE" });
507
- }
508
- const Rt = (t) => {
509
- if (!t || typeof t != "string") return null;
510
- const r = t.trim().toLowerCase();
511
- if (r.startsWith("#")) {
512
- const n = r.replace("#", "").toUpperCase();
513
- return n.length === 3 ? n.split("").map((a) => a + a).join("").toUpperCase() : n.length === 6 ? n : null;
514
- }
515
- const e = /rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+[\d.]+)?\s*\)/i, o = r.match(e);
516
- if (o) {
517
- const n = Math.min(255, Math.max(0, parseFloat(o[1]))), a = Math.min(255, Math.max(0, parseFloat(o[2]))), c = Math.min(255, Math.max(0, parseFloat(o[3])));
518
- return ((1 << 24) + (n << 16) + (a << 8) + c).toString(16).slice(1).toUpperCase();
519
- }
520
- return null;
521
- };
522
- function St(t) {
523
- const r = {};
524
- if (t.bl === 1 && (r.bold = !0), t.it === 1 && (r.italic = !0), t.un === 1 && (r.underline = !0), t.cl === 1 && (r.strike = !0), t.fs && (r.size = Number(t.fs)), typeof t.ff == "string" && t.ff && (r.name = t.ff), t.fc) {
525
- const e = Rt(t.fc);
526
- e && (r.color = { argb: `FF${e}` });
527
- }
528
- return Object.keys(r).length > 0 ? r : void 0;
529
- }
530
- function et(t) {
531
- if (!Array.isArray(t) || t.length === 0) return null;
532
- const r = [];
533
- for (const e of t) {
534
- const o = String(e.v ?? "");
535
- if (o === "" && !e.bl && !e.it && !e.un && !e.cl) continue;
536
- const n = St(e), a = { text: o };
537
- n && (a.font = n), r.push(a);
538
- }
539
- return r.length === 0 || !r.some((e) => e.text !== "") ? null : { richText: r };
540
- }
541
- function kt(t, r) {
542
- r.forEach((e, o) => {
543
- const n = t.getCell(o);
544
- n.value = e;
545
- });
546
- }
547
- const Nt = /* @__PURE__ */ new Set(["b", "n", "e", "s", "d", "z", "str"]);
548
- function ot(t, r) {
549
- return t === "d" ? "n" : t === "inlineStr" || t === "g" ? "s" : typeof t == "string" && Nt.has(t) ? t : typeof r == "number" && Number.isFinite(r) ? "n" : typeof r == "boolean" ? "b" : r instanceof Date ? "d" : "s";
550
- }
551
- function vt(t) {
552
- const r = ot(t.t, t.v);
553
- let e = t.v;
554
- r === "s" && e != null && typeof e != "string" && (e = String(e));
555
- const o = { t: r, v: e };
556
- typeof t.f == "string" && t.f && (o.f = t.f), t.w != null && (o.w = t.w), typeof t.z == "string" && t.z && t.z !== "General" && (o.z = t.z), Object.keys(t).forEach((n) => {
557
- delete t[n];
558
- }), Object.assign(t, o);
559
- }
560
- function Mt(t) {
561
- delete t.sheetFormat, Object.keys(t).forEach((r) => {
562
- if (r.startsWith("!")) return;
563
- const e = t[r];
564
- e && typeof e == "object" && vt(e);
565
- });
566
- }
567
- function Wt(t) {
568
- const r = t == null ? void 0 : t.filter, e = t == null ? void 0 : t.filter_select, o = !!(r && Object.keys(r).length > 0), n = !!e && (Array.isArray(e.row) || Array.isArray(e.column));
569
- return o || n;
570
- }
571
- const q = (t) => {
572
- if (!t || typeof t != "string") return null;
573
- const r = t.trim().toLowerCase();
574
- if (r.startsWith("#")) {
575
- const n = r.replace("#", "").toUpperCase();
576
- return n.length === 3 ? n.split("").map((a) => a + a).join("").toUpperCase() : n.length === 6 ? n : null;
577
- }
578
- const e = /rgba?\s*\(\s*([\d.]+)[,\s]+([\d.]+)[,\s]+([\d.]+)(?:[,\s/]+[\d.]+)?\s*\)/i, o = r.match(e);
579
- if (o) {
580
- const n = Math.min(255, Math.max(0, parseFloat(o[1]))), a = Math.min(255, Math.max(0, parseFloat(o[2]))), c = Math.min(255, Math.max(0, parseFloat(o[3])));
581
- return ((1 << 24) + (n << 16) + (a << 8) + c).toString(16).slice(1).toUpperCase();
582
- }
583
- return null;
584
- }, Lt = async (t, r, e, o) => at(
585
- t,
586
- r,
587
- e,
588
- o,
589
- "xlsx"
590
- ), Pt = async (t, r, e, o) => at(
591
- t,
592
- r,
593
- e,
594
- o,
595
- "ods"
596
- ), nt = (t) => t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t), st = async (t, r, e, o, n) => {
597
- var H, U, Z, K, Q;
598
- const a = (H = t.getWorkbookContext) == null ? void 0 : H.call(t), c = a == null ? void 0 : a.luckysheetfile;
599
- n.warnOnFilters && Array.isArray(c) && c.some(Wt) && rt({
600
- title: "Filters are not supported in Export",
601
- variant: "warning",
602
- showCloseButton: !0,
603
- duration: 30 * 1e3
604
- }), r.getArray(e);
605
- const l = t.getAllSheets();
606
- l.forEach((m) => pt(m));
607
- const d = S.book_new(), s = l.map(
608
- () => /* @__PURE__ */ new Map()
609
- ), C = /* @__PURE__ */ new Set();
610
- if (l.forEach((m, I) => {
611
- var z, M, P, D, L;
612
- const R = ut(m), g = S.aoa_to_sheet(R);
613
- Object.keys(g).forEach((f) => {
614
- if (f.startsWith("!")) return;
615
- const h = g[f];
616
- h && (h.t === "s" || h.t === void 0) && h.v !== "" && !isNaN(Number(h.v)) && (g[f] = { ...h, v: Number(h.v), t: "n" });
617
- }), g["!merges"] = [], (z = m.config) != null && z.merge && Object.values(m.config.merge).forEach((f) => {
618
- g["!merges"].push({
619
- s: { r: f.r, c: f.c },
620
- e: { r: f.r + f.rs - 1, c: f.c + f.cs - 1 }
621
- });
622
- });
623
- {
624
- const h = Math.round(3437.714285714286) / 256, u = m.column || 36;
625
- g["!cols"] = [];
626
- for (let i = 0; i < u; i++) {
627
- const x = (P = (M = m.config) == null ? void 0 : M.columnlen) == null ? void 0 : P[i];
628
- if (x !== void 0) {
629
- const p = Math.max(
630
- 0,
631
- Math.round((Number(x) - 5) / 7 * 256) / 256
632
- );
633
- g["!cols"][i] = { wch: p };
634
- } else
635
- g["!cols"][i] = { wch: h };
636
- }
637
- }
638
- {
639
- const f = Math.round(60.48) / 4;
640
- g.sheetFormat = {
641
- ...g.sheetFormat || {},
642
- defaultRowHeight: String(f)
643
- }, (D = m.config) != null && D.rowlen && (g["!rows"] = [], Object.entries(m.config.rowlen).forEach(([h, u]) => {
644
- const i = Math.round(Number(u) * 0.72 * 4) / 4;
645
- g["!rows"][Number(h)] = { hpt: i };
646
- }));
647
- }
648
- const O = /* @__PURE__ */ new Set();
649
- (m.celldata ?? []).forEach((f) => {
650
- var A, k, $, _, B;
651
- const h = f.r, u = f.c, i = f.v || {}, x = S.encode_cell({ r: h, c: u });
652
- let p = g[x] || {};
653
- if (p = { ...p }, i.f && (p.f = i.f.replace(/^=/, "")), !i.f && ((A = i.ct) == null ? void 0 : A.t) === "inlineStr" && Array.isArray(i.ct.s) ? (p.v = X(i.ct.s), p.t = "s") : p.v = i.v ?? ((_ = ($ = (k = i == null ? void 0 : i.ct) == null ? void 0 : k.s) == null ? void 0 : $[0]) == null ? void 0 : _.v), i.m && (p.w = i.m), !i.f && ((B = i.ct) == null ? void 0 : B.t) === "inlineStr" && Array.isArray(i.ct.s)) {
654
- const v = et(i.ct.s);
655
- v && s[I].set(x, v);
656
- }
657
- if (i.ct && (i.ct.fa && (p.z = i.ct.fa), i.ct.t && i.ct.t !== "inlineStr" && (p.t = ot(i.ct.t, p.v))), typeof p.v == "number" && !p.t && (p.t = "n"), p.s = p.s || {}, i.bg) {
658
- const v = q(i.bg);
659
- v && (p.s.fill = {
660
- patternType: "solid",
661
- fgColor: { rgb: v }
662
- });
663
- }
664
- p.s.font = {
665
- ...p.s.font || {},
666
- bold: i.bl === 1 || void 0,
667
- italic: i.it === 1 || void 0,
668
- strike: i.cl === 1 || void 0,
669
- underline: i.un === 1 || void 0,
670
- sz: i.fs ?? 10,
671
- name: i.ff ?? void 0,
672
- color: (() => {
673
- const v = q(i.fc);
674
- return v ? { rgb: v } : void 0;
675
- })()
676
- };
677
- const w = { 0: "center", 1: "left", 2: "right" }, y = { 0: "center", 1: "top", 2: "bottom" };
678
- p.s.alignment = {
679
- ...p.s.alignment || {},
680
- wrapText: i.tb === "1" || i.tb === "2" ? !0 : void 0,
681
- textRotation: i.tr !== void 0 ? i.tr : void 0
682
- }, p.s.alignment.horizontal = w[i.ht] || void 0, p.s.alignment.vertical = y[i.vt] || void 0, i.tb !== void 0 && (p.s.alignment = p.s.alignment || {}, i.tb === "1" ? p.s.alignment.wrapText = !0 : i.tb === "2" && (p.s.alignment.shrinkToFit = !0)), O.add(x), g[x] = p;
683
- }), R.forEach((f, h) => {
684
- Array.isArray(f) && f.forEach((u, i) => {
685
- if (!u || typeof u != "object") return;
686
- const x = S.encode_cell({ r: h, c: i });
687
- if (O.has(x)) return;
688
- const p = !!u.f, w = u.bg || u.bl || u.it || u.cl || u.un || u.fs || u.ff || u.fc || u.ht !== void 0 || u.vt !== void 0 || u.tb !== void 0 || u.tr !== void 0;
689
- if (!p && !w) return;
690
- const y = { ...g[x] || {} };
691
- if (y.s = y.s || {}, p && (y.f = u.f.replace(/^=/, "")), u.bg) {
692
- const $ = q(u.bg);
693
- $ && (y.s.fill = { patternType: "solid", fgColor: { rgb: $ } });
694
- }
695
- y.s.font = {
696
- ...y.s.font || {},
697
- bold: u.bl === 1 || void 0,
698
- italic: u.it === 1 || void 0,
699
- strike: u.cl === 1 || void 0,
700
- underline: u.un === 1 || void 0,
701
- sz: u.fs ?? 10,
702
- name: u.ff ?? void 0,
703
- color: (() => {
704
- const $ = q(u.fc);
705
- return $ ? { rgb: $ } : void 0;
706
- })()
707
- };
708
- const A = { 0: "center", 1: "left", 2: "right" }, k = { 0: "center", 1: "top", 2: "bottom" };
709
- y.s.alignment = {
710
- ...y.s.alignment || {},
711
- horizontal: A[u.ht] || void 0,
712
- vertical: k[u.vt] || void 0,
713
- textRotation: u.tr !== void 0 ? u.tr : void 0
714
- }, u.tb === "1" ? y.s.alignment.wrapText = !0 : u.tb === "2" && (y.s.alignment.shrinkToFit = !0), g[x] = y;
715
- });
716
- }), R.forEach((f, h) => {
717
- Array.isArray(f) && f.forEach((u, i) => {
718
- var y;
719
- if (!u || ((y = u.ct) == null ? void 0 : y.t) !== "inlineStr" || !Array.isArray(u.ct.s)) return;
720
- const x = S.encode_cell({ r: h, c: i }), p = X(u.ct.s);
721
- g[x] = {
722
- ...g[x] || {},
723
- v: p,
724
- t: "s"
725
- };
726
- const w = et(u.ct.s);
727
- w && s[I].set(x, w);
728
- });
729
- }), (L = m.config) != null && L.borderInfo && gt(g, m.config.borderInfo), Object.keys(g).forEach((f) => {
730
- if (f.startsWith("!")) return;
731
- const h = g[f];
732
- h && h.s && h.t == null && h.v == null && h.f == null && (h.t = "s", h.v = "");
733
- });
734
- const N = m.name.length > 30 ? m.name.slice(0, 30) : m.name;
735
- if (C.has(N)) {
736
- const f = N !== m.name ? `"${m.name}" is too long and collides with another sheet after being shortened to "${N}"` : `Two sheets share the name "${m.name}"`;
737
- throw new Error(
738
- `${f}. Sheet names must be unique. Rename one and try again.`
739
- );
740
- }
741
- C.add(N), o === "ods" && Mt(g), S.book_append_sheet(d, g, N);
742
- }), o === "ods") {
743
- const m = tt(d, {
744
- bookType: "ods",
745
- type: "array",
746
- compression: !0
747
- });
748
- return {
749
- data: nt(m),
750
- mimeType: "application/vnd.oasis.opendocument.spreadsheet",
751
- extension: "ods"
752
- };
753
- }
754
- const F = tt(d, {
755
- bookType: "xlsx",
756
- type: "array",
757
- compression: !0
758
- }), E = new it();
759
- await E.xlsx.load(F);
760
- const b = E.model;
761
- (Z = (U = b == null ? void 0 : b.styles) == null ? void 0 : U.fonts) != null && Z[0] && (b.styles.fonts[0] = { ...b.styles.fonts[0], size: 10 });
762
- const T = l.map(() => ({
763
- duplicateValues: []
764
- }));
765
- l.forEach((m, I) => {
766
- const R = E.worksheets[I];
767
- if (!R) return;
768
- kt(R, s[I]);
769
- const g = m.data;
770
- Object.entries(m.hyperlink || {}).forEach(([D, L]) => {
771
- var A, k, $, _;
772
- const f = lt(L);
773
- if (!(f != null && f.linkAddress)) return;
774
- const [h, u] = D.split("_").map(Number);
775
- if (Number.isNaN(h) || Number.isNaN(u)) return;
776
- const i = S.encode_cell({ r: h, c: u }), x = R.getCell(i), p = (A = g == null ? void 0 : g[h]) == null ? void 0 : A[u];
777
- let w = "";
778
- p && typeof p == "object" && ((k = p.ct) == null ? void 0 : k.t) === "inlineStr" && Array.isArray(p.ct.s) && (w = X(p.ct.s));
779
- const y = w || (typeof x.text == "string" && x.text.length > 0 ? x.text : (($ = x.value) == null ? void 0 : $.text) || (Array.isArray((_ = x.value) == null ? void 0 : _.richText) ? x.value.richText.map((B) => B.text || "").join("") : "") || "");
780
- x.value = {
781
- text: y || f.linkAddress,
782
- hyperlink: f.linkAddress
783
- };
784
- });
785
- const { nextPriority: O, pendingDuplicateValues: N } = Tt(R, m, 1);
786
- T[I] = { duplicateValues: N };
787
- let z = O;
788
- if (!m.dataVerification) return;
789
- const M = R;
790
- M.dataValidations || (M.dataValidations = { model: {} }), M.dataValidations.model || (M.dataValidations.model = {});
791
- const P = M.dataValidations.model;
792
- Object.entries(m.dataVerification).forEach(([D, L]) => {
793
- const f = L;
794
- if (f.type !== "dropdown" && f.type !== "checkbox") return;
795
- const [h, u] = D.split("_").map(Number), i = S.encode_cell({ r: h, c: u });
796
- if (f.type === "checkbox") {
797
- const p = (f.value1 || "TRUE").trim(), w = (f.value2 || "FALSE").trim(), y = [p, w].filter(Boolean);
798
- P[i] = {
799
- type: "list",
800
- allowBlank: !0,
801
- formulae: [`"${y.join(",")}"`],
802
- showInputMessage: !!f.hintShow,
803
- prompt: f.hintValue || "",
804
- showErrorMessage: !!f.prohibitInput
805
- };
806
- return;
807
- }
808
- const x = (f.value1 || "").split(",").map((p) => p.trim()).filter(Boolean);
809
- if (x.length !== 0 && (P[i] = {
810
- type: "list",
811
- allowBlank: !0,
812
- formulae: [`"${x.join(",")}"`],
813
- showInputMessage: !!f.hintShow,
814
- prompt: f.hintValue || "",
815
- showErrorMessage: !!f.prohibitInput
816
- }, f.color)) {
817
- const p = f.color.split(",").map((A) => parseInt(A.trim(), 10)), w = (A) => Math.max(0, Math.min(255, A)).toString(16).padStart(2, "0").toUpperCase(), y = x.map((A, k) => {
818
- const $ = p[k * 3], _ = p[k * 3 + 1], B = p[k * 3 + 2];
819
- if (isNaN($) || isNaN(_) || isNaN(B)) return null;
820
- const v = `FF${w($)}${w(_)}${w(B)}`;
821
- return {
822
- type: "cellIs",
823
- operator: "equal",
824
- formulae: [`"${A}"`],
825
- priority: z++,
826
- style: {
827
- fill: {
828
- type: "pattern",
829
- pattern: "solid",
830
- fgColor: { argb: v }
831
- }
832
- }
833
- };
834
- }).filter(Boolean);
835
- y.length > 0 && M.addConditionalFormatting({
836
- ref: i,
837
- rules: y
838
- });
839
- }
840
- });
841
- }), l.forEach((m, I) => {
842
- var N;
843
- if (!((N = m.images) != null && N.length)) return;
844
- const R = E.worksheets[I];
845
- if (!R) return;
846
- const g = Number(m.defaultColWidth) || 99, O = Number(m.defaultRowHeight) || 21;
847
- ft(
848
- R,
849
- E,
850
- m.images,
851
- m,
852
- g,
853
- O
854
- );
855
- });
856
- const { applyDefinedNamesToExcelWorkbook: j } = await import("./xlsx-defined-names-Bz4lZarM.js");
857
- j(
858
- E,
859
- ((Q = (K = t.getWorkbookContext) == null ? void 0 : K.call(t)) == null ? void 0 : Q.definedNames) ?? dt(r, e),
860
- l
861
- );
862
- const Y = await E.xlsx.writeBuffer(), G = await Ft(Y, T);
863
- return {
864
- data: nt(G),
865
- mimeType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
866
- extension: "xlsx"
867
- };
868
- }, at = async (t, r, e, o, n) => {
869
- if (!(!t.current || !r.current))
870
- try {
871
- const a = await st(
872
- t.current,
873
- r.current,
874
- e,
875
- n,
876
- { warnOnFilters: !0 }
877
- ), c = await (o == null ? void 0 : o(e)) || "Untitled", l = new Blob([a.data], { type: a.mimeType }), d = URL.createObjectURL(l), s = document.createElement("a");
878
- s.href = d, s.download = `${c}.${a.extension}`, s.click(), URL.revokeObjectURL(d);
879
- } catch (a) {
880
- console.error("Export failed:", a), rt({
881
- title: "Export failed",
882
- description: a instanceof Error && a.message ? a.message : `Something went wrong while exporting to .${n}. Please try again.`,
883
- variant: "error",
884
- showCloseButton: !0,
885
- duration: 10 * 1e3
886
- });
887
- }
888
- }, Vt = async (t, r, e) => {
889
- if (!t.current || !r.current)
890
- throw new Error("No workbook to export");
891
- return (await st(
892
- t.current,
893
- r.current,
894
- e,
895
- "xlsx",
896
- { warnOnFilters: !1 }
897
- )).data;
898
- };
899
- export {
900
- Vt as exportToXLSXBytes,
901
- Pt as handleExportToODS,
902
- Lt as handleExportToXLSX
903
- };