@fileverse-dev/dsheet 3.0.0 → 3.0.1-formula-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/{constants-yStXQJiK.js → constants-Cdz6oSCq.js} +5 -7
  2. package/dist/constants.js +1 -1
  3. package/dist/editor/components/editor-workbook-sync.d.ts +1 -1
  4. package/dist/editor/components/sidebar/use-right-panels.d.ts +1 -1
  5. package/dist/editor/components/sidebars/named-ranges.d.ts +2 -0
  6. package/dist/editor/constants/shared-constants.d.ts +0 -2
  7. package/dist/editor/hooks/use-celldata-compaction.d.ts +23 -0
  8. package/dist/editor/hooks/use-xlsx-import-impl.d.ts +2 -1
  9. package/dist/editor/hooks/use-xlsx-import.d.ts +2 -1
  10. package/dist/editor/utils/compact-committed-celldata.d.ts +28 -0
  11. package/dist/editor/utils/config-ydoc-update.d.ts +20 -0
  12. package/dist/editor/utils/defined-names-ydoc.d.ts +31 -0
  13. package/dist/editor/utils/update-ydoc.d.ts +2 -2
  14. package/dist/editor/utils/xlsx-defined-names.d.ts +41 -0
  15. package/dist/executeStringFunction-DMPoSj5F.js +32826 -0
  16. package/dist/formula.js +1 -1
  17. package/dist/{index-CBzFxleP.js → index-DAVuAF9T.js} +23852 -26202
  18. package/dist/index.es.js +39 -39
  19. package/dist/jszip.min-CEyB-71x.js +2319 -0
  20. package/dist/sheet-engine/core/api/cell.d.ts +0 -20
  21. package/dist/sheet-engine/core/api/common.d.ts +2 -1
  22. package/dist/sheet-engine/core/api/index.d.ts +1 -0
  23. package/dist/sheet-engine/core/api/sheet-flowdata-lifecycle.d.ts +17 -0
  24. package/dist/sheet-engine/core/api/sheet.d.ts +5 -0
  25. package/dist/sheet-engine/core/context.d.ts +3 -1
  26. package/dist/sheet-engine/core/index.d.ts +2 -2
  27. package/dist/sheet-engine/core/modules/formula-snapshot-eval.d.ts +11 -0
  28. package/dist/sheet-engine/core/modules/formula-worker-bridge.d.ts +1 -0
  29. package/dist/sheet-engine/core/modules/formula.d.ts +27 -0
  30. package/dist/sheet-engine/core/modules/index.d.ts +3 -2
  31. package/dist/sheet-engine/core/modules/namedRanges.d.ts +53 -0
  32. package/dist/sheet-engine/core/modules/sheet-metadata-hooks.d.ts +4 -0
  33. package/dist/sheet-engine/core/modules/sheet.d.ts +17 -1
  34. package/dist/sheet-engine/core/paste/paste-border-utils.d.ts +23 -0
  35. package/dist/sheet-engine/core/settings.d.ts +3 -1
  36. package/dist/sheet-engine/core/types.d.ts +20 -0
  37. package/dist/sheet-engine/core/utils/border-config-utils.d.ts +16 -0
  38. package/dist/sheet-engine/core/utils/cell-persist-utils.d.ts +10 -0
  39. package/dist/sheet-engine/core/utils/range-format.d.ts +71 -0
  40. package/dist/sheet-engine/core/utils/ydoc-celldata-changes.d.ts +40 -0
  41. package/dist/sheet-engine/react/components/NamedRanges/index.d.ts +4 -0
  42. package/dist/sheet-engine/react/components/Workbook/api.d.ts +8 -1
  43. package/dist/sheet-engine/react/components/Workbook/index.d.ts +5 -1
  44. package/dist/style.css +1 -1
  45. package/dist/use-xlsx-import-impl-DzthrhwA.js +1595 -0
  46. package/dist/xlsx-defined-names-D2KoICbm.js +117 -0
  47. package/dist/xlsx-export-impl-b2z4De4f.js +818 -0
  48. package/package.json +2 -2
  49. package/dist/executeStringFunction-C5hEkx9z.js +0 -27694
  50. package/dist/use-xlsx-import-impl-C_npga_I.js +0 -1537
  51. package/dist/xlsx-export-impl-C2cU3lhm.js +0 -3126
@@ -0,0 +1,1595 @@
1
+ import { g as at } from "./executeStringFunction-DMPoSj5F.js";
2
+ import * as it from "yjs";
3
+ import { m as ct, y as ot, r as lt } from "./index-DAVuAF9T.js";
4
+ import { n as st } from "./xlsx-hyperlink-inline-DzewAypN.js";
5
+ import { toast as Je } from "@fileverse/ui";
6
+ var tt = { exports: {} };
7
+ (function(A) {
8
+ var h = {}, d = function(w) {
9
+ w.version = "0.11.2";
10
+ function C(r) {
11
+ for (var e = "", t = r.length - 1; t >= 0; ) e += r.charAt(t--);
12
+ return e;
13
+ }
14
+ function O(r, e) {
15
+ for (var t = ""; t.length < e; ) t += r;
16
+ return t;
17
+ }
18
+ function S(r, e) {
19
+ var t = "" + r;
20
+ return t.length >= e ? t : O("0", e - t.length) + t;
21
+ }
22
+ function R(r, e) {
23
+ var t = "" + r;
24
+ return t.length >= e ? t : O(" ", e - t.length) + t;
25
+ }
26
+ function W(r, e) {
27
+ var t = "" + r;
28
+ return t.length >= e ? t : t + O(" ", e - t.length);
29
+ }
30
+ function K(r, e) {
31
+ var t = "" + Math.round(r);
32
+ return t.length >= e ? t : O("0", e - t.length) + t;
33
+ }
34
+ function ge(r, e) {
35
+ var t = "" + r;
36
+ return t.length >= e ? t : O("0", e - t.length) + t;
37
+ }
38
+ var F = Math.pow(2, 32);
39
+ function J(r, e) {
40
+ if (r > F || r < -F) return K(r, e);
41
+ var t = Math.round(r);
42
+ return ge(t, e);
43
+ }
44
+ function ce(r, e) {
45
+ return e = e || 0, r.length >= 7 + e && (r.charCodeAt(e) | 32) === 103 && (r.charCodeAt(e + 1) | 32) === 101 && (r.charCodeAt(e + 2) | 32) === 110 && (r.charCodeAt(e + 3) | 32) === 101 && (r.charCodeAt(e + 4) | 32) === 114 && (r.charCodeAt(e + 5) | 32) === 97 && (r.charCodeAt(e + 6) | 32) === 108;
46
+ }
47
+ var Ae = [
48
+ ["Sun", "Sunday"],
49
+ ["Mon", "Monday"],
50
+ ["Tue", "Tuesday"],
51
+ ["Wed", "Wednesday"],
52
+ ["Thu", "Thursday"],
53
+ ["Fri", "Friday"],
54
+ ["Sat", "Saturday"]
55
+ ], be = [
56
+ ["J", "Jan", "January"],
57
+ ["F", "Feb", "February"],
58
+ ["M", "Mar", "March"],
59
+ ["A", "Apr", "April"],
60
+ ["M", "May", "May"],
61
+ ["J", "Jun", "June"],
62
+ ["J", "Jul", "July"],
63
+ ["A", "Aug", "August"],
64
+ ["S", "Sep", "September"],
65
+ ["O", "Oct", "October"],
66
+ ["N", "Nov", "November"],
67
+ ["D", "Dec", "December"]
68
+ ];
69
+ function Me(r) {
70
+ r[0] = "General", r[1] = "0", r[2] = "0.00", r[3] = "#,##0", r[4] = "#,##0.00", r[9] = "0%", r[10] = "0.00%", r[11] = "0.00E+00", r[12] = "# ?/?", r[13] = "# ??/??", r[14] = "m/d/yy", r[15] = "d-mmm-yy", r[16] = "d-mmm", r[17] = "mmm-yy", r[18] = "h:mm AM/PM", r[19] = "h:mm:ss AM/PM", r[20] = "h:mm", r[21] = "h:mm:ss", r[22] = "m/d/yy h:mm", r[37] = "#,##0 ;(#,##0)", r[38] = "#,##0 ;[Red](#,##0)", r[39] = "#,##0.00;(#,##0.00)", r[40] = "#,##0.00;[Red](#,##0.00)", r[45] = "mm:ss", r[46] = "[h]:mm:ss", r[47] = "mmss.0", r[48] = "##0.0E+0", r[49] = "@", r[56] = '"上午/下午 "hh"時"mm"分"ss"秒 "';
71
+ }
72
+ var ae = {};
73
+ Me(ae);
74
+ var Q = [], M = 0;
75
+ for (M = 5; M <= 8; ++M) Q[M] = 32 + M;
76
+ for (M = 23; M <= 26; ++M) Q[M] = 0;
77
+ for (M = 27; M <= 31; ++M) Q[M] = 14;
78
+ for (M = 50; M <= 58; ++M) Q[M] = 14;
79
+ for (M = 59; M <= 62; ++M) Q[M] = M - 58;
80
+ for (M = 67; M <= 68; ++M) Q[M] = M - 58;
81
+ for (M = 72; M <= 75; ++M) Q[M] = M - 58;
82
+ for (M = 67; M <= 68; ++M) Q[M] = M - 57;
83
+ for (M = 76; M <= 78; ++M) Q[M] = M - 56;
84
+ for (M = 79; M <= 81; ++M) Q[M] = M - 34;
85
+ var I = [];
86
+ I[5] = I[63] = '"$"#,##0_);\\("$"#,##0\\)', I[6] = I[64] = '"$"#,##0_);[Red]\\("$"#,##0\\)', I[7] = I[65] = '"$"#,##0.00_);\\("$"#,##0.00\\)', I[8] = I[66] = '"$"#,##0.00_);[Red]\\("$"#,##0.00\\)', I[41] = '_(* #,##0_);_(* \\(#,##0\\);_(* "-"_);_(@_)', I[42] = '_("$"* #,##0_);_("$"* \\(#,##0\\);_("$"* "-"_);_(@_)', I[43] = '_(* #,##0.00_);_(* \\(#,##0.00\\);_(* "-"??_);_(@_)', I[44] = '_("$"* #,##0.00_);_("$"* \\(#,##0.00\\);_("$"* "-"??_);_(@_)';
87
+ function le(r, e, t) {
88
+ for (var b = r < 0 ? -1 : 1, a = r * b, k = 0, i = 1, f = 0, E = 1, g = 0, u = 0, x = Math.floor(a); g < e && (x = Math.floor(a), f = x * i + k, u = x * g + E, !(a - x < 5e-8)); )
89
+ a = 1 / (a - x), k = i, i = f, E = g, g = u;
90
+ if (u > e && (g > e ? (u = E, f = k) : (u = g, f = i)), !t) return [0, b * f, u];
91
+ var P = Math.floor(b * f / u);
92
+ return [P, b * f - P * u, u];
93
+ }
94
+ function se(r, e, t) {
95
+ if (r > 2958465 || r < 0) return null;
96
+ var b = r | 0, a = Math.floor(86400 * (r - b)), k = 0, i = [], f = { D: b, T: a, u: 86400 * (r - b) - a, y: 0, m: 0, d: 0, H: 0, M: 0, S: 0, q: 0 };
97
+ if (Math.abs(f.u) < 1e-6 && (f.u = 0), e && e.date1904 && (b += 1462), f.u > 0.9999 && (f.u = 0, ++a == 86400 && (f.T = a = 0, ++b, ++f.D)), b === 60)
98
+ i = t ? [1317, 10, 29] : [1900, 2, 29], k = 3;
99
+ else if (b === 0)
100
+ i = t ? [1317, 8, 29] : [1900, 1, 0], k = 6;
101
+ else {
102
+ b > 60 && --b;
103
+ var E = new Date(1900, 0, 1);
104
+ E.setDate(E.getDate() + b - 1), i = [E.getFullYear(), E.getMonth() + 1, E.getDate()], k = E.getDay(), b < 60 && (k = (k + 6) % 7), t && (k = we(E, i));
105
+ }
106
+ return f.y = i[0], f.m = i[1], f.d = i[2], f.S = a % 60, a = Math.floor(a / 60), f.M = a % 60, a = Math.floor(a / 60), f.H = a, f.q = k, f;
107
+ }
108
+ w.parse_date_code = se;
109
+ var me = new Date(1899, 11, 31, 0, 0, 0), Re = me.getTime(), Le = new Date(1900, 2, 1, 0, 0, 0);
110
+ function Ne(r, e) {
111
+ var t = r.getTime();
112
+ return e ? t -= 1262304e5 : r >= Le && (t += 864e5), (t - (Re + (r.getTimezoneOffset() - me.getTimezoneOffset()) * 6e4)) / 864e5;
113
+ }
114
+ function He(r) {
115
+ return r.toString(10);
116
+ }
117
+ w._general_int = He;
118
+ var Se = /* @__PURE__ */ function() {
119
+ var e = /(?:\.0*|(\.\d*[1-9])0+)$/;
120
+ function t(g) {
121
+ return g.indexOf(".") == -1 ? g : g.replace(e, "$1");
122
+ }
123
+ var b = /(?:\.0*|(\.\d*[1-9])0+)[Ee]/, a = /(E[+-])(\d)$/;
124
+ function k(g) {
125
+ return g.indexOf("E") == -1 ? g : g.replace(b, "$1E").replace(a, "$10$2");
126
+ }
127
+ function i(g) {
128
+ var u = g < 0 ? 12 : 11, x = t(g.toFixed(12));
129
+ return x.length <= u || (x = g.toPrecision(10), x.length <= u) ? x : g.toExponential(5);
130
+ }
131
+ function f(g) {
132
+ var u = t(g.toFixed(11));
133
+ return u.length > (g < 0 ? 12 : 11) || u === "0" || u === "-0" ? g.toPrecision(6) : u;
134
+ }
135
+ function E(g) {
136
+ var u = Math.floor(Math.log(Math.abs(g)) * Math.LOG10E), x;
137
+ return u >= -4 && u <= -1 ? x = g.toPrecision(10 + u) : Math.abs(u) <= 9 ? x = i(g) : u === 10 ? x = g.toFixed(10).substr(0, 12) : x = f(g), t(k(x.toUpperCase()));
138
+ }
139
+ return E;
140
+ }();
141
+ w._general_num = Se;
142
+ function pe(r, e) {
143
+ switch (typeof r) {
144
+ case "string":
145
+ return r;
146
+ case "boolean":
147
+ return r ? "TRUE" : "FALSE";
148
+ case "number":
149
+ return (r | 0) === r ? r.toString(10) : Se(r);
150
+ case "undefined":
151
+ return "";
152
+ case "object":
153
+ if (r == null) return "";
154
+ if (r instanceof Date) return _e(14, Ne(r, e && e.date1904), e);
155
+ }
156
+ throw new Error("unsupported value in General format: " + r);
157
+ }
158
+ w._general = pe;
159
+ function we(r, e) {
160
+ e[0] -= 581;
161
+ var t = r.getDay();
162
+ return r < 60 && (t = (t + 6) % 7), t;
163
+ }
164
+ function Te(r, e, t, b) {
165
+ var a = "", k = 0, i = 0, f = t.y, E, g = 0;
166
+ switch (r) {
167
+ case 98:
168
+ f = t.y + 543;
169
+ case 121:
170
+ switch (e.length) {
171
+ case 1:
172
+ case 2:
173
+ E = f % 100, g = 2;
174
+ break;
175
+ default:
176
+ E = f % 1e4, g = 4;
177
+ break;
178
+ }
179
+ break;
180
+ case 109:
181
+ switch (e.length) {
182
+ case 1:
183
+ case 2:
184
+ E = t.m, g = e.length;
185
+ break;
186
+ case 3:
187
+ return be[t.m - 1][1];
188
+ case 5:
189
+ return be[t.m - 1][0];
190
+ default:
191
+ return be[t.m - 1][2];
192
+ }
193
+ break;
194
+ case 100:
195
+ switch (e.length) {
196
+ case 1:
197
+ case 2:
198
+ E = t.d, g = e.length;
199
+ break;
200
+ case 3:
201
+ return Ae[t.q][0];
202
+ default:
203
+ return Ae[t.q][1];
204
+ }
205
+ break;
206
+ case 104:
207
+ switch (e.length) {
208
+ case 1:
209
+ case 2:
210
+ E = 1 + (t.H + 11) % 12, g = e.length;
211
+ break;
212
+ default:
213
+ throw "bad hour format: " + e;
214
+ }
215
+ break;
216
+ case 72:
217
+ switch (e.length) {
218
+ case 1:
219
+ case 2:
220
+ E = t.H, g = e.length;
221
+ break;
222
+ default:
223
+ throw "bad hour format: " + e;
224
+ }
225
+ break;
226
+ case 77:
227
+ switch (e.length) {
228
+ case 1:
229
+ case 2:
230
+ E = t.M, g = e.length;
231
+ break;
232
+ default:
233
+ throw "bad minute format: " + e;
234
+ }
235
+ break;
236
+ case 115:
237
+ if (e != "s" && e != "ss" && e != ".0" && e != ".00" && e != ".000") throw "bad second format: " + e;
238
+ return t.u === 0 && (e == "s" || e == "ss") ? S(t.S, e.length) : (b >= 2 ? i = b === 3 ? 1e3 : 100 : i = b === 1 ? 10 : 1, k = Math.round(i * (t.S + t.u)), k >= 60 * i && (k = 0), e === "s" ? k === 0 ? "0" : "" + k / i : (a = S(k, 2 + b), e === "ss" ? a.substr(0, 2) : "." + a.substr(2, e.length - 1)));
239
+ case 90:
240
+ switch (e) {
241
+ case "[h]":
242
+ case "[hh]":
243
+ E = t.D * 24 + t.H;
244
+ break;
245
+ case "[m]":
246
+ case "[mm]":
247
+ E = (t.D * 24 + t.H) * 60 + t.M;
248
+ break;
249
+ case "[s]":
250
+ case "[ss]":
251
+ E = ((t.D * 24 + t.H) * 60 + t.M) * 60 + Math.round(t.S + t.u);
252
+ break;
253
+ default:
254
+ throw "bad abstime format: " + e;
255
+ }
256
+ g = e.length === 3 ? 1 : 2;
257
+ break;
258
+ case 101:
259
+ E = f, g = 1;
260
+ break;
261
+ }
262
+ var u = g > 0 ? S(E, g) : "";
263
+ return u;
264
+ }
265
+ function ie(r) {
266
+ var e = 3;
267
+ if (r.length <= e) return r;
268
+ for (var t = r.length % e, b = r.substr(0, t); t != r.length; t += e) b += (b.length > 0 ? "," : "") + r.substr(t, e);
269
+ return b;
270
+ }
271
+ var re = /* @__PURE__ */ function() {
272
+ var e = /%/g;
273
+ function t(s, n, c) {
274
+ var _ = n.replace(e, ""), o = n.length - _.length;
275
+ return re(s, _, c * Math.pow(10, 2 * o)) + O("%", o);
276
+ }
277
+ function b(s, n, c) {
278
+ for (var _ = n.length - 1; n.charCodeAt(_ - 1) === 44; ) --_;
279
+ return re(s, n.substr(0, _), c / Math.pow(10, 3 * (n.length - _)));
280
+ }
281
+ function a(s, n) {
282
+ var c, _ = s.indexOf("E") - s.indexOf(".") - 1;
283
+ if (s.match(/^#+0.0E\+0$/)) {
284
+ if (n == 0) return "0.0E+0";
285
+ if (n < 0) return "-" + a(s, -n);
286
+ var o = s.indexOf(".");
287
+ o === -1 && (o = s.indexOf("E"));
288
+ var l = Math.floor(Math.log(n) * Math.LOG10E) % o;
289
+ if (l < 0 && (l += o), c = (n / Math.pow(10, l)).toPrecision(_ + 1 + (o + l) % o), c.indexOf("e") === -1) {
290
+ var v = Math.floor(Math.log(n) * Math.LOG10E);
291
+ for (c.indexOf(".") === -1 ? c = c.charAt(0) + "." + c.substr(1) + "E+" + (v - c.length + l) : c += "E+" + (v - l); c.substr(0, 2) === "0."; )
292
+ c = c.charAt(0) + c.substr(2, o) + "." + c.substr(2 + o), c = c.replace(/^0+([1-9])/, "$1").replace(/^0+\./, "0.");
293
+ c = c.replace(/\+-/, "-");
294
+ }
295
+ c = c.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function(D, U, Y, N) {
296
+ return U + Y + N.substr(0, (o + l) % o) + "." + N.substr(l) + "E";
297
+ });
298
+ } else c = n.toExponential(_);
299
+ return s.match(/E\+00$/) && c.match(/e[+-]\d$/) && (c = c.substr(0, c.length - 1) + "0" + c.charAt(c.length - 1)), s.match(/E\-/) && c.match(/e\+/) && (c = c.replace(/e\+/, "e")), c.replace("e", "E");
300
+ }
301
+ var k = /# (\?+)( ?)\/( ?)(\d+)/;
302
+ function i(s, n, c) {
303
+ var _ = parseInt(s[4], 10), o = Math.round(n * _), l = Math.floor(o / _), v = o - l * _, D = _;
304
+ return c + (l === 0 ? "" : "" + l) + " " + (v === 0 ? O(" ", s[1].length + 1 + s[4].length) : R(v, s[1].length) + s[2] + "/" + s[3] + S(D, s[4].length));
305
+ }
306
+ function f(s, n, c) {
307
+ return c + (n === 0 ? "" : "" + n) + O(" ", s[1].length + 2 + s[4].length);
308
+ }
309
+ var E = /^#*0*\.([0#]+)/, g = /\).*[0#]/, u = /\(###\) ###\\?-####/;
310
+ function x(s) {
311
+ for (var n = "", c, _ = 0; _ != s.length; ++_) switch (c = s.charCodeAt(_)) {
312
+ case 35:
313
+ break;
314
+ case 63:
315
+ n += " ";
316
+ break;
317
+ case 48:
318
+ n += "0";
319
+ break;
320
+ default:
321
+ n += String.fromCharCode(c);
322
+ }
323
+ return n;
324
+ }
325
+ function P(s, n) {
326
+ var c = Math.pow(10, n);
327
+ return "" + Math.round(s * c) / c;
328
+ }
329
+ function z(s, n) {
330
+ var c = s - Math.floor(s), _ = Math.pow(10, n);
331
+ return n < ("" + Math.round(c * _)).length ? 0 : Math.round(c * _);
332
+ }
333
+ function ne(s, n) {
334
+ return n < ("" + Math.round((s - Math.floor(s)) * Math.pow(10, n))).length ? 1 : 0;
335
+ }
336
+ function L(s) {
337
+ return s < 2147483647 && s > -2147483648 ? "" + (s >= 0 ? s | 0 : s - 1 | 0) : "" + Math.floor(s);
338
+ }
339
+ function $(s, n, c) {
340
+ if (s.charCodeAt(0) === 40 && !n.match(g)) {
341
+ var _ = n.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
342
+ return c >= 0 ? $("n", _, c) : "(" + $("n", _, -c) + ")";
343
+ }
344
+ if (n.charCodeAt(n.length - 1) === 44) return b(s, n, c);
345
+ if (n.indexOf("%") !== -1) return t(s, n, c);
346
+ if (n.indexOf("E") !== -1) return a(n, c);
347
+ if (n.charCodeAt(0) === 36) return "$" + $(s, n.substr(n.charAt(1) == " " ? 2 : 1), c);
348
+ var o, l, v, D, U = Math.abs(c), Y = c < 0 ? "-" : "";
349
+ if (n.match(/^00+$/)) return Y + J(U, n.length);
350
+ if (n.match(/^[#?]+$/))
351
+ return o = J(c, 0), o === "0" && (o = ""), o.length > n.length ? o : x(n.substr(0, n.length - o.length)) + o;
352
+ if (l = n.match(k)) return i(l, U, Y);
353
+ if (n.match(/^#+0+$/)) return Y + J(U, n.length - n.indexOf("0"));
354
+ if (l = n.match(E))
355
+ return o = P(c, l[1].length).replace(/^([^\.]+)$/, "$1." + x(l[1])).replace(/\.$/, "." + x(l[1])).replace(/\.(\d*)$/, function(q, fe) {
356
+ return "." + fe + O("0", x(l[1]).length - fe.length);
357
+ }), n.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
358
+ if (n = n.replace(/^#+([0.])/, "$1"), l = n.match(/^(0*)\.(#*)$/))
359
+ return Y + P(U, l[2].length).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, l[1].length ? "0." : ".");
360
+ if (l = n.match(/^#{1,3},##0(\.?)$/)) return Y + ie(J(U, 0));
361
+ if (l = n.match(/^#,##0\.([#0]*0)$/))
362
+ return c < 0 ? "-" + $(s, n, -c) : ie("" + (Math.floor(c) + ne(c, l[1].length))) + "." + S(z(c, l[1].length), l[1].length);
363
+ if (l = n.match(/^#,#*,#0/)) return $(s, n.replace(/^#,#*,/, ""), c);
364
+ if (l = n.match(/^([0#]+)(\\?-([0#]+))+$/))
365
+ return o = C($(s, n.replace(/[\\-]/g, ""), c)), v = 0, C(C(n.replace(/\\/g, "")).replace(/[0#]/g, function(q) {
366
+ return v < o.length ? o.charAt(v++) : q === "0" ? "0" : "";
367
+ }));
368
+ if (n.match(u))
369
+ return o = $(s, "##########", c), "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
370
+ var N = "";
371
+ if (l = n.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))
372
+ return v = Math.min(l[4].length, 7), D = le(U, Math.pow(10, v) - 1, !1), o = "" + Y, N = re("n", l[1], D[1]), N.charAt(N.length - 1) == " " && (N = N.substr(0, N.length - 1) + "0"), o += N + l[2] + "/" + l[3], N = W(D[2], v), N.length < l[4].length && (N = x(l[4].substr(l[4].length - N.length)) + N), o += N, o;
373
+ if (l = n.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))
374
+ return v = Math.min(Math.max(l[1].length, l[4].length), 7), D = le(U, Math.pow(10, v) - 1, !0), Y + (D[0] || (D[1] ? "" : "0")) + " " + (D[1] ? R(D[1], v) + l[2] + "/" + l[3] + W(D[2], v) : O(" ", 2 * v + 1 + l[2].length + l[3].length));
375
+ if (l = n.match(/^[#0?]+$/))
376
+ return o = J(c, 0), n.length <= o.length ? o : x(n.substr(0, n.length - o.length)) + o;
377
+ if (l = n.match(/^([#0?]+)\.([#0]+)$/)) {
378
+ o = "" + c.toFixed(Math.min(l[2].length, 10)).replace(/([^0])0+$/, "$1"), v = o.indexOf(".");
379
+ var ue = n.indexOf(".") - v, xe = n.length - o.length - ue;
380
+ return x(n.substr(0, ue) + o + n.substr(n.length - xe));
381
+ }
382
+ if (l = n.match(/^00,000\.([#0]*0)$/))
383
+ return v = z(c, l[1].length), c < 0 ? "-" + $(s, n, -c) : ie(L(c)).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function(q) {
384
+ return "00," + (q.length < 3 ? S(0, 3 - q.length) : "") + q;
385
+ }) + "." + S(v, l[1].length);
386
+ switch (n) {
387
+ case "###,##0.00":
388
+ return $(s, "#,##0.00", c);
389
+ case "###,###":
390
+ case "##,###":
391
+ case "#,###":
392
+ var he = ie(J(U, 0));
393
+ return he !== "0" ? Y + he : "";
394
+ case "###,###.00":
395
+ return $(s, "###,##0.00", c).replace(/^0\./, ".");
396
+ case "#,###.00":
397
+ return $(s, "#,##0.00", c).replace(/^0\./, ".");
398
+ }
399
+ throw new Error("unsupported format |" + n + "|");
400
+ }
401
+ function H(s, n, c) {
402
+ for (var _ = n.length - 1; n.charCodeAt(_ - 1) === 44; ) --_;
403
+ return re(s, n.substr(0, _), c / Math.pow(10, 3 * (n.length - _)));
404
+ }
405
+ function X(s, n, c) {
406
+ var _ = n.replace(e, ""), o = n.length - _.length;
407
+ return re(s, _, c * Math.pow(10, 2 * o)) + O("%", o);
408
+ }
409
+ function j(s, n) {
410
+ var c, _ = s.indexOf("E") - s.indexOf(".") - 1;
411
+ if (s.match(/^#+0.0E\+0$/)) {
412
+ if (n == 0) return "0.0E+0";
413
+ if (n < 0) return "-" + j(s, -n);
414
+ var o = s.indexOf(".");
415
+ o === -1 && (o = s.indexOf("E"));
416
+ var l = Math.floor(Math.log(n) * Math.LOG10E) % o;
417
+ if (l < 0 && (l += o), c = (n / Math.pow(10, l)).toPrecision(_ + 1 + (o + l) % o), !c.match(/[Ee]/)) {
418
+ var v = Math.floor(Math.log(n) * Math.LOG10E);
419
+ c.indexOf(".") === -1 ? c = c.charAt(0) + "." + c.substr(1) + "E+" + (v - c.length + l) : c += "E+" + (v - l), c = c.replace(/\+-/, "-");
420
+ }
421
+ c = c.replace(/^([+-]?)(\d*)\.(\d*)[Ee]/, function(D, U, Y, N) {
422
+ return U + Y + N.substr(0, (o + l) % o) + "." + N.substr(l) + "E";
423
+ });
424
+ } else c = n.toExponential(_);
425
+ return s.match(/E\+00$/) && c.match(/e[+-]\d$/) && (c = c.substr(0, c.length - 1) + "0" + c.charAt(c.length - 1)), s.match(/E\-/) && c.match(/e\+/) && (c = c.replace(/e\+/, "e")), c.replace("e", "E");
426
+ }
427
+ function m(s, n, c) {
428
+ if (s.charCodeAt(0) === 40 && !n.match(g)) {
429
+ var _ = n.replace(/\( */, "").replace(/ \)/, "").replace(/\)/, "");
430
+ return c >= 0 ? m("n", _, c) : "(" + m("n", _, -c) + ")";
431
+ }
432
+ if (n.charCodeAt(n.length - 1) === 44) return H(s, n, c);
433
+ if (n.indexOf("%") !== -1) return X(s, n, c);
434
+ if (n.indexOf("E") !== -1) return j(n, c);
435
+ if (n.charCodeAt(0) === 36) return "$" + m(s, n.substr(n.charAt(1) == " " ? 2 : 1), c);
436
+ var o, l, v, D, U = Math.abs(c), Y = c < 0 ? "-" : "";
437
+ if (n.match(/^00+$/)) return Y + S(U, n.length);
438
+ if (n.match(/^[#?]+$/))
439
+ return o = "" + c, c === 0 && (o = ""), o.length > n.length ? o : x(n.substr(0, n.length - o.length)) + o;
440
+ if (l = n.match(k)) return f(l, U, Y);
441
+ if (n.match(/^#+0+$/)) return Y + S(U, n.length - n.indexOf("0"));
442
+ if (l = n.match(E))
443
+ return o = ("" + c).replace(/^([^\.]+)$/, "$1." + x(l[1])).replace(/\.$/, "." + x(l[1])), o = o.replace(/\.(\d*)$/, function(q, fe) {
444
+ return "." + fe + O("0", x(l[1]).length - fe.length);
445
+ }), n.indexOf("0.") !== -1 ? o : o.replace(/^0\./, ".");
446
+ if (n = n.replace(/^#+([0.])/, "$1"), l = n.match(/^(0*)\.(#*)$/))
447
+ return Y + ("" + U).replace(/\.(\d*[1-9])0*$/, ".$1").replace(/^(-?\d*)$/, "$1.").replace(/^0\./, l[1].length ? "0." : ".");
448
+ if (l = n.match(/^#{1,3},##0(\.?)$/)) return Y + ie("" + U);
449
+ if (l = n.match(/^#,##0\.([#0]*0)$/))
450
+ return c < 0 ? "-" + m(s, n, -c) : ie("" + c) + "." + O("0", l[1].length);
451
+ if (l = n.match(/^#,#*,#0/)) return m(s, n.replace(/^#,#*,/, ""), c);
452
+ if (l = n.match(/^([0#]+)(\\?-([0#]+))+$/))
453
+ return o = C(m(s, n.replace(/[\\-]/g, ""), c)), v = 0, C(C(n.replace(/\\/g, "")).replace(/[0#]/g, function(q) {
454
+ return v < o.length ? o.charAt(v++) : q === "0" ? "0" : "";
455
+ }));
456
+ if (n.match(u))
457
+ return o = m(s, "##########", c), "(" + o.substr(0, 3) + ") " + o.substr(3, 3) + "-" + o.substr(6);
458
+ var N = "";
459
+ if (l = n.match(/^([#0?]+)( ?)\/( ?)([#0?]+)/))
460
+ return v = Math.min(l[4].length, 7), D = le(U, Math.pow(10, v) - 1, !1), o = "" + Y, N = re("n", l[1], D[1]), N.charAt(N.length - 1) == " " && (N = N.substr(0, N.length - 1) + "0"), o += N + l[2] + "/" + l[3], N = W(D[2], v), N.length < l[4].length && (N = x(l[4].substr(l[4].length - N.length)) + N), o += N, o;
461
+ if (l = n.match(/^# ([#0?]+)( ?)\/( ?)([#0?]+)/))
462
+ return v = Math.min(Math.max(l[1].length, l[4].length), 7), D = le(U, Math.pow(10, v) - 1, !0), Y + (D[0] || (D[1] ? "" : "0")) + " " + (D[1] ? R(D[1], v) + l[2] + "/" + l[3] + W(D[2], v) : O(" ", 2 * v + 1 + l[2].length + l[3].length));
463
+ if (l = n.match(/^[#0?]+$/))
464
+ return o = "" + c, n.length <= o.length ? o : x(n.substr(0, n.length - o.length)) + o;
465
+ if (l = n.match(/^([#0]+)\.([#0]+)$/)) {
466
+ o = "" + c.toFixed(Math.min(l[2].length, 10)).replace(/([^0])0+$/, "$1"), v = o.indexOf(".");
467
+ var ue = n.indexOf(".") - v, xe = n.length - o.length - ue;
468
+ return x(n.substr(0, ue) + o + n.substr(n.length - xe));
469
+ }
470
+ if (l = n.match(/^00,000\.([#0]*0)$/))
471
+ return c < 0 ? "-" + m(s, n, -c) : ie("" + c).replace(/^\d,\d{3}$/, "0$&").replace(/^\d*$/, function(q) {
472
+ return "00," + (q.length < 3 ? S(0, 3 - q.length) : "") + q;
473
+ }) + "." + S(0, l[1].length);
474
+ switch (n) {
475
+ case "###,###":
476
+ case "##,###":
477
+ case "#,###":
478
+ var he = ie("" + U);
479
+ return he !== "0" ? Y + he : "";
480
+ default:
481
+ if (n.match(/\.[0#?]*$/)) return m(s, n.slice(0, n.lastIndexOf(".")), c) + x(n.slice(n.lastIndexOf(".")));
482
+ }
483
+ throw new Error("unsupported format |" + n + "|");
484
+ }
485
+ return function(n, c, _) {
486
+ return (_ | 0) === _ ? m(n, c, _) : $(n, c, _);
487
+ };
488
+ }();
489
+ function ve(r) {
490
+ for (var e = [], t = !1, b = 0, a = 0; b < r.length; ++b) switch (
491
+ /*cc=*/
492
+ r.charCodeAt(b)
493
+ ) {
494
+ case 34:
495
+ t = !t;
496
+ break;
497
+ case 95:
498
+ case 42:
499
+ case 92:
500
+ ++b;
501
+ break;
502
+ case 59:
503
+ e[e.length] = r.substr(a, b - a), a = b + 1;
504
+ }
505
+ if (e[e.length] = r.substr(a), t === !0) throw new Error("Format |" + r + "| unterminated string ");
506
+ return e;
507
+ }
508
+ w._split = ve;
509
+ var de = /\[[HhMmSs\u0E0A\u0E19\u0E17]*\]/;
510
+ function Ce(r) {
511
+ for (var e = 0, t = "", b = ""; e < r.length; )
512
+ switch (t = r.charAt(e)) {
513
+ case "G":
514
+ ce(r, e) && (e += 6), e++;
515
+ break;
516
+ case '"':
517
+ for (
518
+ ;
519
+ /*cc=*/
520
+ r.charCodeAt(++e) !== 34 && e < r.length;
521
+ )
522
+ ;
523
+ ++e;
524
+ break;
525
+ case "\\":
526
+ e += 2;
527
+ break;
528
+ case "_":
529
+ e += 2;
530
+ break;
531
+ case "@":
532
+ ++e;
533
+ break;
534
+ case "B":
535
+ case "b":
536
+ if (r.charAt(e + 1) === "1" || r.charAt(e + 1) === "2") return !0;
537
+ case "M":
538
+ case "D":
539
+ case "Y":
540
+ case "H":
541
+ case "S":
542
+ case "E":
543
+ case "m":
544
+ case "d":
545
+ case "y":
546
+ case "h":
547
+ case "s":
548
+ case "e":
549
+ case "g":
550
+ return !0;
551
+ case "A":
552
+ case "a":
553
+ case "上":
554
+ if (r.substr(e, 3).toUpperCase() === "A/P" || r.substr(e, 5).toUpperCase() === "AM/PM" || r.substr(e, 5).toUpperCase() === "上午/下午") return !0;
555
+ ++e;
556
+ break;
557
+ case "[":
558
+ for (b = t; r.charAt(e++) !== "]" && e < r.length; ) b += r.charAt(e);
559
+ if (b.match(de)) return !0;
560
+ break;
561
+ case ".":
562
+ case "0":
563
+ case "#":
564
+ for (; e < r.length && ("0#?.,E+-%".indexOf(t = r.charAt(++e)) > -1 || t == "\\" && r.charAt(e + 1) == "-" && "0#".indexOf(r.charAt(e + 2)) > -1); )
565
+ ;
566
+ break;
567
+ case "?":
568
+ for (; r.charAt(++e) === t; )
569
+ ;
570
+ break;
571
+ case "*":
572
+ ++e, (r.charAt(e) == " " || r.charAt(e) == "*") && ++e;
573
+ break;
574
+ case "(":
575
+ case ")":
576
+ ++e;
577
+ break;
578
+ case "1":
579
+ case "2":
580
+ case "3":
581
+ case "4":
582
+ case "5":
583
+ case "6":
584
+ case "7":
585
+ case "8":
586
+ case "9":
587
+ for (; e < r.length && "0123456789".indexOf(r.charAt(++e)) > -1; )
588
+ ;
589
+ break;
590
+ case " ":
591
+ ++e;
592
+ break;
593
+ default:
594
+ ++e;
595
+ break;
596
+ }
597
+ return !1;
598
+ }
599
+ w.is_date = Ce;
600
+ function Ee(r, e, t, b) {
601
+ for (var a = [], k = "", i = 0, f = "", E = "t", g, u, x, P = "H"; i < r.length; )
602
+ switch (f = r.charAt(i)) {
603
+ case "G":
604
+ if (!ce(r, i)) throw new Error("unrecognized character " + f + " in " + r);
605
+ a[a.length] = { t: "G", v: "General" }, i += 7;
606
+ break;
607
+ case '"':
608
+ for (k = ""; (x = r.charCodeAt(++i)) !== 34 && i < r.length; ) k += String.fromCharCode(x);
609
+ a[a.length] = { t: "t", v: k }, ++i;
610
+ break;
611
+ case "\\":
612
+ var z = r.charAt(++i), ne = z === "(" || z === ")" ? z : "t";
613
+ a[a.length] = { t: ne, v: z }, ++i;
614
+ break;
615
+ case "_":
616
+ a[a.length] = { t: "t", v: " " }, i += 2;
617
+ break;
618
+ case "@":
619
+ a[a.length] = { t: "T", v: e }, ++i;
620
+ break;
621
+ case "B":
622
+ case "b":
623
+ if (r.charAt(i + 1) === "1" || r.charAt(i + 1) === "2") {
624
+ if (g == null && (g = se(e, t, r.charAt(i + 1) === "2"), g == null))
625
+ return "";
626
+ a[a.length] = { t: "X", v: r.substr(i, 2) }, E = f, i += 2;
627
+ break;
628
+ }
629
+ case "M":
630
+ case "D":
631
+ case "Y":
632
+ case "H":
633
+ case "S":
634
+ case "E":
635
+ f = f.toLowerCase();
636
+ case "m":
637
+ case "d":
638
+ case "y":
639
+ case "h":
640
+ case "s":
641
+ case "e":
642
+ case "g":
643
+ if (e < 0 || g == null && (g = se(e, t), g == null))
644
+ return "";
645
+ for (k = f; ++i < r.length && r.charAt(i).toLowerCase() === f; ) k += f;
646
+ f === "m" && E.toLowerCase() === "h" && (f = "M"), f === "h" && (f = P), a[a.length] = { t: f, v: k }, E = f;
647
+ break;
648
+ case "A":
649
+ case "a":
650
+ case "上":
651
+ var L = { t: f, v: f };
652
+ if (g == null && (g = se(e, t)), r.substr(i, 3).toUpperCase() === "A/P" ? (g != null && (L.v = g.H >= 12 ? "P" : "A"), L.t = "T", P = "h", i += 3) : r.substr(i, 5).toUpperCase() === "AM/PM" ? (g != null && (L.v = g.H >= 12 ? "PM" : "AM"), L.t = "T", i += 5, P = "h") : r.substr(i, 5).toUpperCase() === "上午/下午" ? (g != null && (L.v = g.H >= 12 ? "下午" : "上午"), L.t = "T", i += 5, P = "h") : (L.t = "t", ++i), g == null && L.t === "T") return "";
653
+ a[a.length] = L, E = f;
654
+ break;
655
+ case "[":
656
+ for (k = f; r.charAt(i++) !== "]" && i < r.length; ) k += r.charAt(i);
657
+ if (k.slice(-1) !== "]") throw 'unterminated "[" block: |' + k + "|";
658
+ if (k.match(de)) {
659
+ if (g == null && (g = se(e, t), g == null))
660
+ return "";
661
+ a[a.length] = { t: "Z", v: k.toLowerCase() }, E = k.charAt(1);
662
+ } else k.indexOf("$") > -1 && (k = (k.match(/\$([^-\[\]]*)/) || [])[1] || "$", Ce(r) || (a[a.length] = { t: "t", v: k }));
663
+ break;
664
+ case ".":
665
+ if (g != null) {
666
+ for (k = f; ++i < r.length && (f = r.charAt(i)) === "0"; ) k += f;
667
+ a[a.length] = { t: "s", v: k };
668
+ break;
669
+ }
670
+ case "0":
671
+ case "#":
672
+ for (k = f; ++i < r.length && "0#?.,E+-%".indexOf(f = r.charAt(i)) > -1; ) k += f;
673
+ a[a.length] = { t: "n", v: k };
674
+ break;
675
+ case "?":
676
+ for (k = f; r.charAt(++i) === f; ) k += f;
677
+ a[a.length] = { t: f, v: k }, E = f;
678
+ break;
679
+ case "*":
680
+ ++i, (r.charAt(i) == " " || r.charAt(i) == "*") && ++i;
681
+ break;
682
+ case "(":
683
+ case ")":
684
+ a[a.length] = { t: b === 1 ? "t" : f, v: f }, ++i;
685
+ break;
686
+ case "1":
687
+ case "2":
688
+ case "3":
689
+ case "4":
690
+ case "5":
691
+ case "6":
692
+ case "7":
693
+ case "8":
694
+ case "9":
695
+ for (k = f; i < r.length && "0123456789".indexOf(r.charAt(++i)) > -1; ) k += r.charAt(i);
696
+ a[a.length] = { t: "D", v: k };
697
+ break;
698
+ case " ":
699
+ a[a.length] = { t: f, v: f }, ++i;
700
+ break;
701
+ case "$":
702
+ a[a.length] = { t: "t", v: "$" }, ++i;
703
+ break;
704
+ default:
705
+ if (",$-+/():!^&'~{}<>=€acfijklopqrtuvwxzP".indexOf(f) === -1) throw new Error("unrecognized character " + f + " in " + r);
706
+ a[a.length] = { t: "t", v: f }, ++i;
707
+ break;
708
+ }
709
+ var $ = 0, H = 0, X;
710
+ for (i = a.length - 1, E = "t"; i >= 0; --i)
711
+ switch (a[i].t) {
712
+ case "h":
713
+ case "H":
714
+ a[i].t = P, E = "h", $ < 1 && ($ = 1);
715
+ break;
716
+ case "s":
717
+ (X = a[i].v.match(/\.0+$/)) && (H = Math.max(H, X[0].length - 1)), $ < 3 && ($ = 3);
718
+ case "d":
719
+ case "y":
720
+ case "M":
721
+ case "e":
722
+ E = a[i].t;
723
+ break;
724
+ case "m":
725
+ E === "s" && (a[i].t = "M", $ < 2 && ($ = 2));
726
+ break;
727
+ case "X":
728
+ break;
729
+ case "Z":
730
+ $ < 1 && a[i].v.match(/[Hh]/) && ($ = 1), $ < 2 && a[i].v.match(/[Mm]/) && ($ = 2), $ < 3 && a[i].v.match(/[Ss]/) && ($ = 3);
731
+ }
732
+ switch ($) {
733
+ case 0:
734
+ break;
735
+ case 1:
736
+ g.u >= 0.5 && (g.u = 0, ++g.S), g.S >= 60 && (g.S = 0, ++g.M), g.M >= 60 && (g.M = 0, ++g.H);
737
+ break;
738
+ case 2:
739
+ g.u >= 0.5 && (g.u = 0, ++g.S), g.S >= 60 && (g.S = 0, ++g.M);
740
+ break;
741
+ }
742
+ var j = "", m;
743
+ for (i = 0; i < a.length; ++i)
744
+ switch (a[i].t) {
745
+ case "t":
746
+ case "T":
747
+ case " ":
748
+ case "D":
749
+ break;
750
+ case "X":
751
+ a[i].v = "", a[i].t = ";";
752
+ break;
753
+ case "d":
754
+ case "m":
755
+ case "y":
756
+ case "h":
757
+ case "H":
758
+ case "M":
759
+ case "s":
760
+ case "e":
761
+ case "b":
762
+ case "Z":
763
+ a[i].v = Te(a[i].t.charCodeAt(0), a[i].v, g, H), a[i].t = "t";
764
+ break;
765
+ case "n":
766
+ case "?":
767
+ for (m = i + 1; a[m] != null && ((f = a[m].t) === "?" || f === "D" || (f === " " || f === "t") && a[m + 1] != null && (a[m + 1].t === "?" || a[m + 1].t === "t" && a[m + 1].v === "/") || a[i].t === "(" && (f === " " || f === "n" || f === ")") || f === "t" && (a[m].v === "/" || a[m].v === " " && a[m + 1] != null && a[m + 1].t == "?")); )
768
+ a[i].v += a[m].v, a[m] = { v: "", t: ";" }, ++m;
769
+ j += a[i].v, i = m - 1;
770
+ break;
771
+ case "G":
772
+ a[i].t = "t", a[i].v = pe(e, t);
773
+ break;
774
+ }
775
+ var s = "", n, c;
776
+ if (j.length > 0) {
777
+ j.charCodeAt(0) == 40 ? (n = e < 0 && j.charCodeAt(0) === 45 ? -e : e, c = re("n", j, n)) : (n = e < 0 && b > 1 ? -e : e, c = re("n", j, n), n < 0 && a[0] && a[0].t == "t" && (c = c.substr(1), a[0].v = "-" + a[0].v)), m = c.length - 1;
778
+ var _ = a.length;
779
+ for (i = 0; i < a.length; ++i) if (a[i] != null && a[i].t != "t" && a[i].v.indexOf(".") > -1) {
780
+ _ = i;
781
+ break;
782
+ }
783
+ var o = a.length;
784
+ if (_ === a.length && c.indexOf("E") === -1) {
785
+ for (i = a.length - 1; i >= 0; --i)
786
+ a[i] == null || "n?".indexOf(a[i].t) === -1 || (m >= a[i].v.length - 1 ? (m -= a[i].v.length, a[i].v = c.substr(m + 1, a[i].v.length)) : m < 0 ? a[i].v = "" : (a[i].v = c.substr(0, m + 1), m = -1), a[i].t = "t", o = i);
787
+ m >= 0 && o < a.length && (a[o].v = c.substr(0, m + 1) + a[o].v);
788
+ } else if (_ !== a.length && c.indexOf("E") === -1) {
789
+ for (m = c.indexOf(".") - 1, i = _; i >= 0; --i)
790
+ if (!(a[i] == null || "n?".indexOf(a[i].t) === -1)) {
791
+ for (u = a[i].v.indexOf(".") > -1 && i === _ ? a[i].v.indexOf(".") - 1 : a[i].v.length - 1, s = a[i].v.substr(u + 1); u >= 0; --u)
792
+ m >= 0 && (a[i].v.charAt(u) === "0" || a[i].v.charAt(u) === "#") && (s = c.charAt(m--) + s);
793
+ a[i].v = s, a[i].t = "t", o = i;
794
+ }
795
+ for (m >= 0 && o < a.length && (a[o].v = c.substr(0, m + 1) + a[o].v), m = c.indexOf(".") + 1, i = _; i < a.length; ++i)
796
+ if (!(a[i] == null || "n?(".indexOf(a[i].t) === -1 && i !== _)) {
797
+ for (u = a[i].v.indexOf(".") > -1 && i === _ ? a[i].v.indexOf(".") + 1 : 0, s = a[i].v.substr(0, u); u < a[i].v.length; ++u)
798
+ m < c.length && (s += c.charAt(m++));
799
+ a[i].v = s, a[i].t = "t", o = i;
800
+ }
801
+ }
802
+ }
803
+ for (i = 0; i < a.length; ++i) a[i] != null && "n?".indexOf(a[i].t) > -1 && (n = b > 1 && e < 0 && i > 0 && a[i - 1].v === "-" ? -e : e, a[i].v = re(a[i].t, a[i].v, n), a[i].t = "t");
804
+ var l = "";
805
+ for (i = 0; i !== a.length; ++i) a[i] != null && (l += a[i].v);
806
+ return l;
807
+ }
808
+ w._eval = Ee;
809
+ var Fe = /\[[=<>]/, ye = /\[(=|>[=]?|<[>=]?)(-?\d+(?:\.\d*)?)\]/;
810
+ function Ve(r, e) {
811
+ if (e == null) return !1;
812
+ var t = parseFloat(e[2]);
813
+ switch (e[1]) {
814
+ case "=":
815
+ if (r == t) return !0;
816
+ break;
817
+ case ">":
818
+ if (r > t) return !0;
819
+ break;
820
+ case "<":
821
+ if (r < t) return !0;
822
+ break;
823
+ case "<>":
824
+ if (r != t) return !0;
825
+ break;
826
+ case ">=":
827
+ if (r >= t) return !0;
828
+ break;
829
+ case "<=":
830
+ if (r <= t) return !0;
831
+ break;
832
+ }
833
+ return !1;
834
+ }
835
+ function ke(r, e) {
836
+ var t = ve(r), b = t.length, a = t[b - 1].indexOf("@");
837
+ if (b < 4 && a > -1 && --b, t.length > 4) throw new Error("cannot find right format for |" + t.join("|") + "|");
838
+ if (typeof e != "number") return [4, t.length === 4 || a > -1 ? t[t.length - 1] : "@"];
839
+ switch (t.length) {
840
+ case 1:
841
+ t = a > -1 ? ["General", "General", "General", t[0]] : [t[0], t[0], t[0], "@"];
842
+ break;
843
+ case 2:
844
+ t = a > -1 ? [t[0], t[0], t[0], t[1]] : [t[0], t[1], t[0], "@"];
845
+ break;
846
+ case 3:
847
+ t = a > -1 ? [t[0], t[1], t[0], t[2]] : [t[0], t[1], t[2], "@"];
848
+ break;
849
+ }
850
+ var k = e > 0 ? t[0] : e < 0 ? t[1] : t[2];
851
+ if (t[0].indexOf("[") === -1 && t[1].indexOf("[") === -1) return [b, k];
852
+ if (t[0].match(Fe) != null || t[1].match(Fe) != null) {
853
+ var i = t[0].match(ye), f = t[1].match(ye);
854
+ return Ve(e, i) ? [b, t[0]] : Ve(e, f) ? [b, t[1]] : [b, t[i != null && f != null ? 2 : 1]];
855
+ }
856
+ return [b, k];
857
+ }
858
+ function _e(r, e, t) {
859
+ t == null && (t = {});
860
+ var b = "";
861
+ switch (typeof r) {
862
+ case "string":
863
+ r == "m/d/yy" && t.dateNF ? b = t.dateNF : b = r;
864
+ break;
865
+ case "number":
866
+ r == 14 && t.dateNF ? b = t.dateNF : b = (t.table != null ? t.table : ae)[r], b == null && (b = t.table && t.table[Q[r]] || ae[Q[r]]), b == null && (b = I[r] || "General");
867
+ break;
868
+ }
869
+ if (ce(b, 0)) return pe(e, t);
870
+ e instanceof Date && (e = Ne(e, t.date1904));
871
+ var a = ke(b, e);
872
+ if (ce(a[1])) return pe(e, t);
873
+ if (e === !0) e = "TRUE";
874
+ else if (e === !1) e = "FALSE";
875
+ else if (e === "" || e == null) return "";
876
+ return Ee(a[1], e, t, a[0]);
877
+ }
878
+ function $e(r, e) {
879
+ if (typeof e != "number") {
880
+ e = +e || -1;
881
+ for (var t = 0; t < 392; ++t) {
882
+ if (ae[t] == null) {
883
+ e < 0 && (e = t);
884
+ continue;
885
+ }
886
+ if (ae[t] == r) {
887
+ e = t;
888
+ break;
889
+ }
890
+ }
891
+ e < 0 && (e = 391);
892
+ }
893
+ return ae[e] = r, e;
894
+ }
895
+ w.load = $e, w._table = ae, w.get_table = function() {
896
+ return ae;
897
+ }, w.load_table = function(e) {
898
+ for (var t = 0; t != 392; ++t)
899
+ e[t] !== void 0 && $e(e[t], t);
900
+ }, w.init_table = Me, w.format = _e;
901
+ };
902
+ d(h), typeof DO_NOT_EXPORT_SSF > "u" && (A.exports = h);
903
+ })(tt);
904
+ var ut = tt.exports;
905
+ const De = /* @__PURE__ */ at(ut), Be = [
906
+ "228, 232, 237",
907
+ // Light Gray
908
+ "219, 233, 236",
909
+ // White
910
+ "244, 217, 227",
911
+ // Pink
912
+ "247, 229, 207",
913
+ // Peach
914
+ "217, 234, 244",
915
+ // Blue
916
+ "222, 239, 222",
917
+ // Green
918
+ "239, 239, 239",
919
+ // Light Green
920
+ "244, 230, 230",
921
+ // Rose
922
+ "247, 239, 217",
923
+ // Yellow
924
+ "230, 230, 244",
925
+ // Purple
926
+ "217, 244, 244",
927
+ // Cyan
928
+ "244, 239, 234"
929
+ // Cream
930
+ ], Qe = Be[0], ht = [
931
+ ["true", "false"],
932
+ ["yes", "no"],
933
+ ["1", "0"]
934
+ ];
935
+ function ft(A, h) {
936
+ const d = A.toLowerCase(), y = h.toLowerCase();
937
+ return ht.some(([w, C]) => d === w && y === C);
938
+ }
939
+ const gt = 200;
940
+ function dt() {
941
+ return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `sheet-${Date.now()}-${Math.random().toString(36).slice(2)}`;
942
+ }
943
+ function bt(A) {
944
+ if (!Array.isArray(A) || A.length === 0) return null;
945
+ const h = A.map((y) => String((y == null ? void 0 : y.v) ?? "")).join("");
946
+ return h.trim() ? h : null;
947
+ }
948
+ function mt(A) {
949
+ return A ? "TRUE" : "FALSE";
950
+ }
951
+ function pt(A) {
952
+ let h = !1, d = 0;
953
+ const y = () => {
954
+ if (h) return !0;
955
+ const C = A.current;
956
+ if (!(C != null && C.getWorkbookContext) || !C.recalculateAllFormulas) return !1;
957
+ const O = C.getWorkbookContext(), S = O == null ? void 0 : O.luckysheetfile;
958
+ return !(S != null && S.length) || !S.some(
959
+ (W) => Array.isArray(W.data) && W.data.length > 0
960
+ ) ? !1 : (C.recalculateAllFormulas(), h = !0, !0);
961
+ }, w = () => {
962
+ var C, O;
963
+ y() || (d += 1, d < gt ? requestAnimationFrame(w) : ((O = (C = A.current) == null ? void 0 : C.recalculateAllFormulas) == null || O.call(C), h = !0));
964
+ };
965
+ requestAnimationFrame(() => requestAnimationFrame(w));
966
+ for (const C of [120, 400, 1200])
967
+ window.setTimeout(() => {
968
+ h || y();
969
+ }, C);
970
+ }
971
+ function wt(A) {
972
+ return A <= 0 ? Qe : A > Be.length ? Array(A).fill(Qe).join(", ") : Be.slice(0, A).join(", ");
973
+ }
974
+ function We(A) {
975
+ const h = A.match(/^([A-Z]+)(\d+)$/i);
976
+ if (!h) return null;
977
+ const d = h[1].toUpperCase(), y = h[2];
978
+ let w = 0;
979
+ for (let S = 0; S < d.length; S++)
980
+ w = w * 26 + (d.charCodeAt(S) - 64);
981
+ const C = parseInt(y, 10) - 1, O = w - 1;
982
+ return { row: C, col: O };
983
+ }
984
+ function yt(A, h) {
985
+ const d = We(A);
986
+ if (!d) return null;
987
+ const { row: y, col: w } = d, C = `${y}_${w}`, O = Array.isArray(h.formulae) && h.formulae.length > 0 ? String(h.formulae[0]).replace(/^["']|["']$/g, "").replace(/["']/g, "") : "", S = O.split(",").map((ce) => ce.trim()).filter(Boolean);
988
+ let R = h.type === "list" ? "dropdown" : h.type || "dropdown", W = O, K = "";
989
+ h.type === "list" && S.length === 2 && ft(S[0], S[1]) && (R = "checkbox", W = S[0], K = S[1]);
990
+ const ge = R === "checkbox" ? 1 : W ? W.split(",").length : 0, F = wt(ge || 1), J = {
991
+ type: R,
992
+ type2: "",
993
+ rangeTxt: A,
994
+ value1: W,
995
+ value2: K,
996
+ validity: "",
997
+ remote: !1,
998
+ prohibitInput: h.type === "list",
999
+ hintShow: !!h.showInputMessage,
1000
+ hintValue: h.prompt ?? "",
1001
+ color: F,
1002
+ checked: !1
1003
+ };
1004
+ return { rowColKey: C, entry: J };
1005
+ }
1006
+ function kt(A) {
1007
+ const h = A.split(":"), d = We(h[0].trim());
1008
+ if (!d) return null;
1009
+ const y = h.length > 1 ? We(h[1].trim()) : d;
1010
+ return y ? {
1011
+ row: [Math.min(d.row, y.row), Math.max(d.row, y.row)],
1012
+ column: [Math.min(d.col, y.col), Math.max(d.col, y.col)]
1013
+ } : null;
1014
+ }
1015
+ function _t(A) {
1016
+ return String(A || "").split(/[,\s]+/).map((h) => h.trim()).filter(Boolean).map((h) => kt(h)).filter(
1017
+ (h) => !!h
1018
+ );
1019
+ }
1020
+ function Ke(A) {
1021
+ const h = _t(A);
1022
+ return h.length ? h.map((d) => {
1023
+ const [y, w] = d.row, [C, O] = d.column;
1024
+ return {
1025
+ left: 0,
1026
+ width: 104,
1027
+ top: 0,
1028
+ height: 23,
1029
+ left_move: 0,
1030
+ width_move: 104,
1031
+ top_move: 0,
1032
+ height_move: 11999,
1033
+ row: [y, w],
1034
+ column: [C, O],
1035
+ row_focus: y,
1036
+ column_focus: C,
1037
+ column_select: !0
1038
+ };
1039
+ }) : null;
1040
+ }
1041
+ function et(A) {
1042
+ var O, S;
1043
+ const h = {
1044
+ textColor: "#000000",
1045
+ cellColor: "#ffffff",
1046
+ bold: !1,
1047
+ italic: !1,
1048
+ underline: !1,
1049
+ strikethrough: !1
1050
+ };
1051
+ if (!A) return h;
1052
+ const d = A.font, y = A.fill;
1053
+ let w = h.textColor, C = h.cellColor;
1054
+ if ((O = d == null ? void 0 : d.color) != null && O.argb) {
1055
+ const R = d.color.argb;
1056
+ w = "#" + (R.length >= 6 ? R.slice(-6) : R);
1057
+ }
1058
+ if ((y == null ? void 0 : y.type) === "pattern" && y.pattern === "solid" && ((S = y.fgColor) != null && S.argb)) {
1059
+ const R = y.fgColor.argb;
1060
+ C = "#" + (R.length >= 6 ? R.slice(-6) : R);
1061
+ }
1062
+ return {
1063
+ textColor: w,
1064
+ cellColor: C,
1065
+ bold: !!(d != null && d.bold),
1066
+ italic: !!(d != null && d.italic),
1067
+ underline: !!(d != null && d.underline),
1068
+ strikethrough: !1
1069
+ };
1070
+ }
1071
+ function rt(A) {
1072
+ if (!A || typeof A != "string") return "";
1073
+ const h = A.trim().replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/&amp;/g, "&").replace(/^=/, ""), d = h.match(/(?:^|[^A-Z])SEARCH\s*\([\s(]*"((?:[^"]|"")*)"/i);
1074
+ if (d) return (d[1] ?? "").replace(/""/g, '"');
1075
+ const y = h.match(/(?:^|[^A-Z])SEARCH\s*\([\s(]*'([^']*)'/i);
1076
+ return y ? y[1] ?? "" : "";
1077
+ }
1078
+ function Pe(A) {
1079
+ if (!A || typeof A != "string") return "";
1080
+ const h = A.trim().replace(/&quot;/g, '"').replace(/&apos;/g, "'").replace(/^=/, ""), d = h.match(/"((?:[^"]|"")*)"/);
1081
+ if (d) return (d[1] ?? "").replace(/""/g, '"');
1082
+ const y = h.match(/'([^']*)'/);
1083
+ return y ? y[1] ?? "" : "";
1084
+ }
1085
+ function xt(A) {
1086
+ if (!A || typeof A != "string") return null;
1087
+ const h = A.trim().toUpperCase(), d = rt(A) || Pe(A);
1088
+ return d ? h.includes("SEARCH(") ? h.includes("ISERROR(SEARCH(") || h.includes("NOTNUMBER(SEARCH(") ? { conditionName: "textDoesNotContain", conditionValue: [d] } : { conditionName: "textContains", conditionValue: [d] } : h.includes("LEFT(") ? { conditionName: "textStartsWith", conditionValue: [d] } : h.includes("RIGHT(") ? { conditionName: "textEndsWith", conditionValue: [d] } : h.includes("EXACT(") || h.includes('="') ? { conditionName: "textExactly", conditionValue: [d] } : null : null;
1089
+ }
1090
+ function At(A, h, d) {
1091
+ const y = (A || "").toLowerCase();
1092
+ if (y === "cellis") {
1093
+ const w = (h || "").toLowerCase();
1094
+ return w === "greaterthan" ? { conditionName: "greaterThan", conditionValue: [] } : w === "greaterthanorequal" ? { conditionName: "greaterThanOrEqual", conditionValue: [] } : w === "lessthan" ? { conditionName: "lessThan", conditionValue: [] } : w === "lessthanorequal" ? { conditionName: "lessThanOrEqual", conditionValue: [] } : w === "equal" ? { conditionName: "equal", conditionValue: [] } : w === "notequal" ? { conditionName: "notEqual", conditionValue: [] } : w === "between" ? { conditionName: "between", conditionValue: [] } : w === "notbetween" ? { conditionName: "notBetween", conditionValue: [] } : null;
1095
+ }
1096
+ if (y === "containstext" || y === "notcontainstext" || y === "beginswith" || y === "endswith" || y === "containsblanks" || y === "notcontainsblanks") {
1097
+ const w = (h ?? "").toLowerCase();
1098
+ if (y === "containsblanks" || w === "containsblanks")
1099
+ return { conditionName: "empty", conditionValue: [""] };
1100
+ if (y === "notcontainsblanks" || w === "notcontainsblanks")
1101
+ return { conditionName: "notEmpty", conditionValue: [""] };
1102
+ if (y === "notcontainstext" || w === "notcontainstext" || w === "notcontains")
1103
+ return { conditionName: "textDoesNotContain", conditionValue: [] };
1104
+ if (y === "beginswith" || w === "beginswith")
1105
+ return { conditionName: "textStartsWith", conditionValue: [] };
1106
+ if (y === "endswith" || w === "endswith")
1107
+ return { conditionName: "textEndsWith", conditionValue: [] };
1108
+ if (w === "equal")
1109
+ return { conditionName: "textExactly", conditionValue: [] };
1110
+ const C = (d == null ? void 0 : d.text) ?? "";
1111
+ return {
1112
+ conditionName: "textContains",
1113
+ conditionValue: C ? [C] : []
1114
+ };
1115
+ }
1116
+ if (y === "duplicatevalues")
1117
+ return { conditionName: "duplicateValue", conditionValue: ["0"] };
1118
+ if (y === "uniquevalues")
1119
+ return { conditionName: "duplicateValue", conditionValue: ["1"] };
1120
+ if (y === "top10") {
1121
+ const w = (d == null ? void 0 : d.rank) ?? 10;
1122
+ return d != null && d.percent && (d != null && d.bottom) ? {
1123
+ conditionName: "last10_percent",
1124
+ conditionValue: [String(w)]
1125
+ } : d != null && d.percent ? { conditionName: "top10_percent", conditionValue: [String(w)] } : d != null && d.bottom ? { conditionName: "last10", conditionValue: [String(w)] } : { conditionName: "top10", conditionValue: [String(w)] };
1126
+ }
1127
+ if (y === "aboveaverage")
1128
+ return (d == null ? void 0 : d.aboveAverage) === !1 ? { conditionName: "belowAverage", conditionValue: [] } : { conditionName: "aboveAverage", conditionValue: [] };
1129
+ if (y === "timeperiod") {
1130
+ const w = ((d == null ? void 0 : d.timePeriod) ?? "").toLowerCase();
1131
+ return w === "today" || w === "tomorrow" || w === "yesterday" ? {
1132
+ conditionName: "dateIs",
1133
+ conditionValue: [`preset:${w}`, "", "DD/MM/YYYY"]
1134
+ } : w === "last7days" ? {
1135
+ conditionName: "dateIs",
1136
+ conditionValue: ["preset:pastWeek", "", "DD/MM/YYYY"]
1137
+ } : w === "lastmonth" ? {
1138
+ conditionName: "dateIs",
1139
+ conditionValue: ["preset:pastMonth", "", "DD/MM/YYYY"]
1140
+ } : w === "lastyear" ? {
1141
+ conditionName: "dateIs",
1142
+ conditionValue: ["preset:pastYear", "", "DD/MM/YYYY"]
1143
+ } : null;
1144
+ }
1145
+ return null;
1146
+ }
1147
+ function Mt(A, h) {
1148
+ if (!h.type) return null;
1149
+ let d = (h.text ?? "").trim();
1150
+ const y = Array.isArray(h.formulae) && h.formulae[0] ? String(h.formulae[0]) : void 0, w = (h.type.toLowerCase() === "expression" || h.type.toLowerCase() === "customformula") && xt(y);
1151
+ if (w) {
1152
+ const W = Ke(A);
1153
+ if (!W) return null;
1154
+ const K = et(h.style);
1155
+ return {
1156
+ type: "default",
1157
+ cellrange: W,
1158
+ format: {
1159
+ textColor: K.textColor,
1160
+ cellColor: K.cellColor,
1161
+ bold: K.bold,
1162
+ italic: K.italic,
1163
+ underline: K.underline,
1164
+ strikethrough: K.strikethrough
1165
+ },
1166
+ conditionName: w.conditionName,
1167
+ conditionRange: [],
1168
+ conditionValue: w.conditionValue
1169
+ };
1170
+ }
1171
+ (h.type === "containsText" || h.type === "notContainsText" || h.type === "beginsWith" || h.type === "endsWith") && !d && (d = rt(y), d || (d = Pe(y)));
1172
+ const C = At(h.type, h.operator, {
1173
+ percent: h.percent,
1174
+ bottom: h.bottom,
1175
+ rank: h.rank,
1176
+ aboveAverage: h.aboveAverage,
1177
+ text: d || h.text,
1178
+ timePeriod: h.timePeriod
1179
+ });
1180
+ if (!C) return null;
1181
+ let O;
1182
+ h.type === "cellIs" && Array.isArray(h.formulae) && h.formulae.length > 0 ? O = h.formulae.map((W) => String(W ?? "")) : C.conditionName === "empty" || C.conditionName === "notEmpty" ? O = [""] : h.type === "containsText" || h.type === "notContainsText" || h.type === "beginsWith" || h.type === "endsWith" ? O = d ? [d] : Pe(y) ? [Pe(y)] : [] : O = C.conditionValue.map(
1183
+ (W) => W == null ? "" : String(W)
1184
+ );
1185
+ const S = Ke(A);
1186
+ if (!S) return null;
1187
+ const R = et(h.style);
1188
+ return {
1189
+ type: "default",
1190
+ cellrange: S,
1191
+ format: {
1192
+ textColor: R.textColor,
1193
+ cellColor: R.cellColor,
1194
+ bold: R.bold,
1195
+ italic: R.italic,
1196
+ underline: R.underline,
1197
+ strikethrough: R.strikethrough
1198
+ },
1199
+ conditionName: C.conditionName,
1200
+ conditionRange: [],
1201
+ conditionValue: O
1202
+ };
1203
+ }
1204
+ async function Ot({
1205
+ sheetEditorRef: A,
1206
+ ydocRef: h,
1207
+ setForceSheetRender: d,
1208
+ dsheetId: y,
1209
+ currentDataRef: w,
1210
+ updateDocumentTitle: C,
1211
+ filterToastShown: O,
1212
+ setFilterToastShown: S,
1213
+ handleContentPortal: R
1214
+ }, W, K, ge, F) {
1215
+ var ae, Q;
1216
+ const J = W == null ? void 0 : W.target;
1217
+ if (!((ae = J == null ? void 0 : J.files) != null && ae.length) && !K)
1218
+ return Promise.resolve();
1219
+ const ce = ((Q = J == null ? void 0 : J.files) == null ? void 0 : Q[0]) || K, Ae = {}, be = {};
1220
+ let Me = !1;
1221
+ return new Promise((M, I) => {
1222
+ const le = new FileReader();
1223
+ le.onerror = () => I(new Error("Failed to read file")), le.onload = async (se) => {
1224
+ var Te, ie, re, ve;
1225
+ if (!se.target) {
1226
+ console.error("FileReader event target is null"), I(new Error("FileReader event target is null"));
1227
+ return;
1228
+ }
1229
+ const me = se.target.result;
1230
+ if (!(me instanceof ArrayBuffer)) {
1231
+ I(new Error("Expected ArrayBuffer from FileReader"));
1232
+ return;
1233
+ }
1234
+ const [{ Workbook: Re }, Le, Ne] = await Promise.all([
1235
+ import("exceljs"),
1236
+ // @ts-expect-error — luckyexcel ships without TypeScript types
1237
+ import("luckyexcel"),
1238
+ import("./xlsx-image-utils-Cvg0qxRA.js")
1239
+ ]), He = Le.default.transformExcelToLucky, { extractImagesFromWorksheet: Se, convertRawImagesToFortuneSheet: pe } = Ne, we = new Re();
1240
+ try {
1241
+ await we.xlsx.load(me);
1242
+ const {
1243
+ parseDefinedNamesFromXlsxBuffer: de,
1244
+ excelEntriesToDefinedNames: Ce
1245
+ } = await import("./xlsx-defined-names-D2KoICbm.js"), {
1246
+ syncDefinedNamesToYdoc: Ee,
1247
+ readDefinedNamesFromYdoc: Fe
1248
+ } = await import("./index-DAVuAF9T.js").then((e) => e.F), ye = await de(me), Ve = (ve = (re = (ie = (Te = we.model) == null ? void 0 : Te.styles) == null ? void 0 : ie.fonts) == null ? void 0 : re[0]) == null ? void 0 : ve.size, ke = {}, _e = {}, $e = {}, r = {};
1249
+ we.eachSheet((e, t) => {
1250
+ var P, z, ne;
1251
+ const b = t - 1, a = {}, k = e.views;
1252
+ if (k && k.length > 0) {
1253
+ const L = k[0];
1254
+ if (L.state === "frozen") {
1255
+ const $ = L.xSplit || 0, H = L.ySplit || 0;
1256
+ let X = null;
1257
+ $ > 0 && H > 0 ? X = "rangeBoth" : H > 0 ? X = "rangeRow" : $ > 0 && (X = "rangeColumn"), X && (_e[b] = {
1258
+ type: X,
1259
+ range: {
1260
+ row_focus: H - 1,
1261
+ column_focus: $ - 1
1262
+ }
1263
+ });
1264
+ }
1265
+ }
1266
+ const i = {};
1267
+ e.eachRow({ includeEmpty: !1 }, (L, $) => {
1268
+ L.eachCell({ includeEmpty: !1 }, (H, X) => {
1269
+ var c, _, o;
1270
+ const j = `${$ - 1}_${X - 1}`;
1271
+ H.hyperlink && (a[j] = [
1272
+ {
1273
+ linkType: "webpage",
1274
+ linkAddress: H.hyperlink
1275
+ }
1276
+ ]);
1277
+ const m = (c = H.style) == null ? void 0 : c.font, s = (_ = H.style) == null ? void 0 : _.fill, n = {};
1278
+ if (m) {
1279
+ m.bold && (n.bl = 1), m.italic && (n.it = 1), m.underline && (n.un = 1);
1280
+ const l = m.size ?? Ve;
1281
+ if (l && (n.fs = l), m.name && (n.ff = m.name), (o = m.color) != null && o.argb) {
1282
+ const v = m.color.argb, D = "#" + v.substring(v.length - 6);
1283
+ n.fc = D;
1284
+ }
1285
+ }
1286
+ if ((s == null ? void 0 : s.type) === "pattern" && s.pattern === "solid" && s.fgColor && s.fgColor.argb) {
1287
+ const l = s.fgColor.argb, v = "#" + l.substring(l.length - 6);
1288
+ n.bg = v;
1289
+ }
1290
+ Object.keys(n).length > 0 && (i[j] = n);
1291
+ });
1292
+ }), Object.keys(a).length > 0 && (ke[b] = a), Object.keys(i).length > 0 && ($e[b] = i);
1293
+ const f = Se(e, we);
1294
+ f.length > 0 && (r[b] = f);
1295
+ const E = e.tables;
1296
+ E && Object.keys(E).length > 0 && ((P = F == null ? void 0 : F.onWarning) == null || P.call(
1297
+ F,
1298
+ "Tables are not fully supported. Table styles will not be applied."
1299
+ ), F != null && F.suppressUiWarnings || Je({
1300
+ title: "Tables are not fully supported",
1301
+ description: "Table styles will not be applied",
1302
+ variant: "warning",
1303
+ showCloseButton: !0,
1304
+ duration: 40 * 1e3
1305
+ }));
1306
+ const g = (z = e.dataValidations) == null ? void 0 : z.model;
1307
+ if (g && typeof g == "object") {
1308
+ const L = {};
1309
+ for (const [$, H] of Object.entries(g)) {
1310
+ const j = yt($, H);
1311
+ j && (L[j.rowColKey] = j.entry);
1312
+ }
1313
+ Object.keys(L).length > 0 && (Ae[b] = L);
1314
+ }
1315
+ const u = e.conditionalFormattings;
1316
+ if (Array.isArray(u) && u.length > 0) {
1317
+ const L = [];
1318
+ for (const $ of u) {
1319
+ const H = $.ref, X = $.rules || [];
1320
+ for (const j of X) {
1321
+ const m = j;
1322
+ console.log("[XLSX CF RAW]", {
1323
+ ref: H,
1324
+ type: m.type,
1325
+ operator: m.operator,
1326
+ formulae: m.formulae,
1327
+ text: m.text,
1328
+ timePeriod: m.timePeriod,
1329
+ percent: m.percent,
1330
+ bottom: m.bottom,
1331
+ rank: m.rank,
1332
+ aboveAverage: m.aboveAverage
1333
+ });
1334
+ const s = m.type ? Mt(H, m) : null;
1335
+ s ? console.log("[XLSX CF MAPPED] accepted", s) : console.log("[XLSX CF MAPPED] skipped", {
1336
+ ref: H,
1337
+ type: m.type,
1338
+ operator: m.operator,
1339
+ formulae: m.formulae,
1340
+ text: m.text
1341
+ }), s && L.push(s);
1342
+ }
1343
+ }
1344
+ L.length > 0 && (be[b] = L);
1345
+ }
1346
+ e.autoFilter && (Me || (Me = !0, (ne = F == null ? void 0 : F.onWarning) == null || ne.call(
1347
+ F,
1348
+ "Filters are not supported in imported files."
1349
+ )), O || (S(!0), F != null && F.suppressUiWarnings || Je({
1350
+ title: "Filters are not supported in imported files",
1351
+ variant: "warning",
1352
+ showCloseButton: !0,
1353
+ duration: 30 * 1e3
1354
+ })));
1355
+ }), He(
1356
+ ce,
1357
+ function(e) {
1358
+ var g;
1359
+ let t = e.sheets;
1360
+ if (t.forEach((u, x) => {
1361
+ const P = Ae[x];
1362
+ P && Object.keys(P).length > 0 && (u.dataVerification = P);
1363
+ const z = be[x];
1364
+ u.luckysheet_conditionformat_save = Array.isArray(z) && z.length > 0 ? z : [];
1365
+ }), !h.current) {
1366
+ console.error("ydocRef.current is null");
1367
+ return;
1368
+ }
1369
+ const b = h.current.getArray(y), a = Array.from(b), k = /* @__PURE__ */ new Map();
1370
+ t = t.map((u, x) => {
1371
+ var s, n, c, _, o, l, v, D, U, Y, N, ue, xe, he, q, fe, je, Ue, Ye, Ge, Ie, ze, Xe, qe, Ze;
1372
+ const P = (s = u == null ? void 0 : u.celldata) == null ? void 0 : s[u.celldata.length - 1], z = (P == null ? void 0 : P.r) ?? 0, ne = (P == null ? void 0 : P.c) ?? 0;
1373
+ if (u.row = Math.max(z, 500), u.column = Math.max(ne, 36), u.id || (u.id = ((n = F == null ? void 0 : F.generateSheetId) == null ? void 0 : n.call(F)) ?? ((c = A.current) == null ? void 0 : c.getSettings().generateSheetId()) ?? dt()), _e[x] && (u.frozen = _e[x]), ke[x] && (u.hyperlink = {
1374
+ ...u.hyperlink || {},
1375
+ ...ke[x]
1376
+ }), (_ = u.config) != null && _.columnlen) {
1377
+ const p = {};
1378
+ Object.entries(u.config.columnlen).forEach(
1379
+ ([V, T]) => {
1380
+ const G = (Number(T) - 5) / 8 + 0.83;
1381
+ p[V] = Math.round(G * 7 + 5);
1382
+ }
1383
+ ), u.config.columnlen = p;
1384
+ }
1385
+ const L = Math.round(
1386
+ Number(u.defaultColWidth) || 73
1387
+ );
1388
+ if ((o = u.config) != null && o.columnlen) {
1389
+ const p = {};
1390
+ Object.entries(u.config.columnlen).forEach(([V, T]) => {
1391
+ Math.abs(Math.round(Number(T)) - L) > 1 && (p[V] = Number(T));
1392
+ }), u.config.columnlen = p;
1393
+ }
1394
+ if ((l = u.config) != null && l.rowlen) {
1395
+ const p = Math.round(
1396
+ Number(u.defaultRowHeight) || 21
1397
+ ), V = {};
1398
+ Object.entries(u.config.rowlen).forEach(([T, G]) => {
1399
+ Math.abs(Math.round(Number(G)) - p) > 1 && (V[T] = Number(G));
1400
+ }), u.config.rowlen = V;
1401
+ }
1402
+ if ((v = u.config) != null && v.customHeight) {
1403
+ const p = new Set(
1404
+ Object.keys(u.config.rowlen || {})
1405
+ ), V = {};
1406
+ Object.entries(u.config.customHeight).forEach(
1407
+ ([T, G]) => {
1408
+ p.has(T) && Number(G) === 1 && (V[T] = 1);
1409
+ }
1410
+ ), u.config.customHeight = V;
1411
+ }
1412
+ if (r[x]) {
1413
+ const p = Number(u.defaultColWidth) || Number(
1414
+ (Y = (U = (D = A.current) == null ? void 0 : D.getSettings) == null ? void 0 : U.call(D)) == null ? void 0 : Y.defaultColWidth
1415
+ ) || 99, V = Number(u.defaultRowHeight) || Number(
1416
+ (xe = (ue = (N = A.current) == null ? void 0 : N.getSettings) == null ? void 0 : ue.call(N)) == null ? void 0 : xe.defaultRowHeight
1417
+ ) || 21;
1418
+ u.images = pe(
1419
+ r[x],
1420
+ u,
1421
+ p,
1422
+ V
1423
+ );
1424
+ }
1425
+ const $ = ke[x], H = $e[x], X = [], j = (p, V) => {
1426
+ const T = `${p}_${V}`;
1427
+ j._seen == null && (j._seen = /* @__PURE__ */ new Set());
1428
+ const G = j._seen;
1429
+ G.has(T) || (G.add(T), X.push({ r: p, c: V, id: u.id }));
1430
+ }, m = (he = u.config) != null && he.merge ? /* @__PURE__ */ new Map() : null;
1431
+ if (u.celldata)
1432
+ for (const p of u.celldata) {
1433
+ const V = `${p.r}_${p.c}`;
1434
+ if (m == null || m.set(
1435
+ V,
1436
+ p
1437
+ ), p.v) {
1438
+ if (p.v.f) {
1439
+ const B = String(p.v.f);
1440
+ B.startsWith("=") || (p.v.f = `=${B}`);
1441
+ }
1442
+ if (p.v.f && ((q = p.v.ct) == null ? void 0 : q.t) !== "d" && (p.v.ct = { ...p.v.ct ?? {}, t: "str" }, j(p.r, p.c)), H != null && H[V]) {
1443
+ const B = H[V];
1444
+ if (!!($ != null && $[V])) {
1445
+ const { fc: te, un: Oe, ...nt } = B;
1446
+ Object.assign(p.v, nt);
1447
+ } else
1448
+ Object.assign(p.v, B);
1449
+ }
1450
+ if ($ != null && $[V] && !p.v.f) {
1451
+ const B = $[V][0];
1452
+ B && st(
1453
+ p.v,
1454
+ B
1455
+ );
1456
+ }
1457
+ const T = (fe = p.v.ct) == null ? void 0 : fe.fa, G = typeof T == "string" ? T.trim().toLowerCase() : "", ee = G === "general" || ((je = p.v.ct) == null ? void 0 : je.t) === "g", oe = G === "@" || ((Ue = p.v.ct) == null ? void 0 : Ue.t) === "s";
1458
+ if (T && !k.has(T) && k.set(T, De.is_date(T)), !p.v.f && T && k.get(T)) {
1459
+ const B = typeof p.v.v == "string" ? parseFloat(p.v.v) : p.v.v;
1460
+ if (typeof B == "number" && !isNaN(B))
1461
+ try {
1462
+ p.v.v = B, p.v.m = De.format(T, B), p.v.ct = { ...p.v.ct, t: "d" };
1463
+ } catch {
1464
+ }
1465
+ } else if (!p.v.f && typeof p.v.v == "string" && !oe && !ee) {
1466
+ const B = p.v.v.trim();
1467
+ if (/^[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?$/.test(
1468
+ B
1469
+ )) {
1470
+ const te = Number(B);
1471
+ if (!isFinite(te))
1472
+ continue;
1473
+ if (p.v.v = te, p.v.ht == null && (p.v.ht = 2), !T)
1474
+ p.v.m = String(te);
1475
+ else
1476
+ try {
1477
+ p.v.m = De.format(T, te);
1478
+ } catch {
1479
+ }
1480
+ }
1481
+ } else !p.v.f && typeof p.v.v == "number" && isFinite(p.v.v) && ((Ye = p.v.ct) == null ? void 0 : Ye.t) !== "s" && ((Ge = p.v.ct) == null ? void 0 : Ge.t) !== "d" && p.v.ht == null && (p.v.ht = 2);
1482
+ if (!p.v.f && (p.v.m === void 0 || p.v.m === null) && ((Ie = p.v.ct) == null ? void 0 : Ie.t) !== "d") {
1483
+ const B = bt((ze = p.v.ct) == null ? void 0 : ze.s), Z = p.v.v;
1484
+ if (!(Z == null || String(Z).trim() === ""))
1485
+ if (B != null)
1486
+ p.v.m = B;
1487
+ else if (typeof Z == "boolean")
1488
+ p.v.m = mt(Z);
1489
+ else if (typeof Z == "number" && isFinite(Z)) {
1490
+ const Oe = (Xe = p.v.ct) == null ? void 0 : Xe.fa;
1491
+ if (typeof Oe == "string" && Oe && k.get(Oe) === !1)
1492
+ try {
1493
+ p.v.m = De.format(Oe, Z);
1494
+ } catch {
1495
+ p.v.m = String(Z);
1496
+ }
1497
+ else
1498
+ p.v.m = String(Z);
1499
+ } else typeof Z == "object" || (p.v.m = String(Z));
1500
+ }
1501
+ }
1502
+ }
1503
+ if (Array.isArray(u.data)) {
1504
+ const p = u.data;
1505
+ for (let V = 0; V < p.length; V++) {
1506
+ const T = p[V];
1507
+ if (Array.isArray(T))
1508
+ for (let G = 0; G < T.length; G++) {
1509
+ const ee = T[G];
1510
+ if (!ee || typeof ee != "object" || !ee.f) continue;
1511
+ const oe = String(ee.f);
1512
+ oe.startsWith("=") || (ee.f = `=${oe}`), ((qe = ee.ct) == null ? void 0 : qe.t) !== "d" && (ee.ct = { ...ee.ct ?? {}, t: "str" }, j(V, G));
1513
+ }
1514
+ }
1515
+ }
1516
+ if (u.calcChain = X, m && ((Ze = u.config) != null && Ze.merge) && u.celldata)
1517
+ for (const p of Object.values(u.config.merge)) {
1518
+ const { r: V, c: T, rs: G, cs: ee } = p;
1519
+ for (let oe = 0; oe < G; oe++)
1520
+ for (let B = 0; B < ee; B++) {
1521
+ const Z = `${V + oe}_${T + B}`;
1522
+ if (oe !== 0 || B !== 0) continue;
1523
+ let te = m.get(Z);
1524
+ te ? (te.v || (te.v = {}), te.v.mc = { r: V, c: T, rs: G, cs: ee }) : (te = {
1525
+ r: V + oe,
1526
+ c: T + B,
1527
+ v: { mc: { r: V, c: T, rs: G, cs: ee } }
1528
+ }, u.celldata.push(te), m.set(Z, te));
1529
+ }
1530
+ }
1531
+ return u;
1532
+ }), console.log("[xlsx-import] parsed sheets data", {
1533
+ fileName: ce.name,
1534
+ sheetCount: t.length,
1535
+ sheets: t
1536
+ });
1537
+ let i;
1538
+ ge === "merge-current-dsheet" ? i = [...a, ...t] : i = [...t], i = i.map((u, x) => (u.order = x, u));
1539
+ const f = h.current;
1540
+ if (f.transact(() => {
1541
+ ge !== "merge-current-dsheet" && b.delete(0, b.length), i.forEach((u) => {
1542
+ if (u instanceof it.Map) return;
1543
+ const x = ct(u);
1544
+ b.push([x()]);
1545
+ });
1546
+ }), ge !== "merge-current-dsheet") {
1547
+ const u = Ce(
1548
+ ye,
1549
+ i
1550
+ );
1551
+ Ee({
1552
+ ydoc: f,
1553
+ dsheetId: y,
1554
+ definedNames: u
1555
+ });
1556
+ } else if (ye.length > 0) {
1557
+ const u = Fe(f, y), x = Ce(
1558
+ ye,
1559
+ t
1560
+ ), P = new Set(
1561
+ u.map((ne) => ne.name.toLowerCase())
1562
+ ), z = [
1563
+ ...u,
1564
+ ...x.filter(
1565
+ (ne) => !P.has(ne.name.toLowerCase())
1566
+ )
1567
+ ];
1568
+ Ee({
1569
+ ydoc: f,
1570
+ dsheetId: y,
1571
+ definedNames: z
1572
+ });
1573
+ }
1574
+ if (h != null && h.current) {
1575
+ const u = h.current.getArray(y), x = ot(u);
1576
+ w.current = x, d((P) => P + 1);
1577
+ }
1578
+ setTimeout(() => {
1579
+ R == null || R();
1580
+ }, 200), F != null && F.headless || pt(A);
1581
+ const E = lt((g = e == null ? void 0 : e.info) == null ? void 0 : g.name);
1582
+ C == null || C(E), M();
1583
+ }
1584
+ );
1585
+ } catch (de) {
1586
+ console.error("Error loading the workbook", de), !(F != null && F.suppressUiWarnings) && typeof alert < "u" && alert(
1587
+ "Error loading the workbook. Please ensure it is a valid .xlsx file."
1588
+ ), I(de);
1589
+ }
1590
+ }, le.readAsArrayBuffer(ce);
1591
+ });
1592
+ }
1593
+ export {
1594
+ Ot as runXlsxFileUpload
1595
+ };