report-studio 1.2.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +254 -3
- package/dist/designer-Dj330bWd.js +4690 -0
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +1 -1
- package/dist/viewer-BewnkhfP.js +4028 -0
- package/package.json +2 -2
- package/src/designer/blank.js +0 -1
- package/src/designer/canvas.js +172 -54
- package/src/designer/designer.js +313 -12
- package/src/designer/dialog.js +609 -5
- package/src/designer/fields.js +128 -11
- package/src/designer/geometry.js +77 -4
- package/src/designer/grouping.js +556 -0
- package/src/designer/icons.js +9 -0
- package/src/designer/menu.js +50 -6
- package/src/designer/panel.js +478 -38
- package/src/designer/rulers.js +14 -6
- package/src/designer/sample-data.js +112 -31
- package/src/designer/select.js +3 -2
- package/src/designer/structure.js +126 -12
- package/src/designer/styles.css +661 -27
- package/src/designer/tokens.js +38 -11
- package/src/engine/calculate.js +487 -0
- package/src/engine/csv.js +17 -9
- package/src/engine/format.js +483 -0
- package/src/engine/group.js +350 -70
- package/src/engine/highlight.js +224 -0
- package/src/engine/index.js +8 -1
- package/src/engine/measure.js +53 -26
- package/src/engine/paginate.js +189 -92
- package/src/engine/resolve.js +117 -10
- package/src/engine/rows.js +71 -8
- package/src/engine/search.js +12 -4
- package/src/engine/tables.js +309 -11
- package/src/engine/validate.js +265 -8
- package/src/engine/xlsx-style.js +50 -4
- package/src/engine/xlsx.js +91 -21
- package/src/index.js +18 -0
- package/src/render/items.js +61 -10
- package/src/render/report.css +0 -5
- package/types/index.d.ts +96 -8
- package/types/layout.d.ts +156 -2
- package/dist/designer-DQlfKnTr.js +0 -3416
- package/dist/viewer-BSPNCNRU.js +0 -2912
|
@@ -0,0 +1,4028 @@
|
|
|
1
|
+
//#region src/engine/tables.js
|
|
2
|
+
function e(e) {
|
|
3
|
+
let t = [];
|
|
4
|
+
for (let n of Array.isArray(e?.bands) ? e.bands : []) for (let e of Array.isArray(n?.items) ? n.items : []) e?.type === "table" && t.push(e);
|
|
5
|
+
return t;
|
|
6
|
+
}
|
|
7
|
+
function t(e, t) {
|
|
8
|
+
return (typeof e?.dataset == "string" && e.dataset !== "" ? e.dataset : null) ?? t?.dataset ?? null;
|
|
9
|
+
}
|
|
10
|
+
var n = ["groupHeader", "groupFooter"], r = 8, i = ["asc", "desc"];
|
|
11
|
+
function a(e) {
|
|
12
|
+
return typeof e?.groupBy == "string" && e.groupBy !== "";
|
|
13
|
+
}
|
|
14
|
+
function o(e) {
|
|
15
|
+
return Array.isArray(e?.grouping) ? e.grouping : [];
|
|
16
|
+
}
|
|
17
|
+
function s(e) {
|
|
18
|
+
return o(e).length > 0 || a(e);
|
|
19
|
+
}
|
|
20
|
+
function c(e, t = 0) {
|
|
21
|
+
let n = o(e)[t];
|
|
22
|
+
return {
|
|
23
|
+
header: n?.header ?? null,
|
|
24
|
+
footer: n?.footer ?? null
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function l(e, t, n, r) {
|
|
28
|
+
let i = o(e), a = t?.opens ?? 0, s = t?.closes ?? 0, c = [];
|
|
29
|
+
for (let e = n ? 0 : a; e < i.length; e++) {
|
|
30
|
+
let t = i[e]?.header;
|
|
31
|
+
t && c.push({
|
|
32
|
+
level: e,
|
|
33
|
+
band: t
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
let l = [];
|
|
37
|
+
if (r) for (let e = i.length - 1; e >= s; e--) {
|
|
38
|
+
let t = i[e]?.footer;
|
|
39
|
+
t && l.push({
|
|
40
|
+
level: e,
|
|
41
|
+
band: t
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
columnHeader: n || a === 0,
|
|
46
|
+
headers: c,
|
|
47
|
+
footers: l
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function u(e, t, n) {
|
|
51
|
+
if (n === 0) return !1;
|
|
52
|
+
let r = o(e);
|
|
53
|
+
for (let e = t?.opens ?? 0; e < r.length; e++) if (r[e]?.newPage === !0) return !0;
|
|
54
|
+
return !1;
|
|
55
|
+
}
|
|
56
|
+
function d(e) {
|
|
57
|
+
let t = Array.isArray(e?.headerBands) ? e.headerBands : [e?.headerBand], n = Array.isArray(e?.footerBands) ? e.footerBands : [e?.showFooter ? e?.footerBand : null];
|
|
58
|
+
return {
|
|
59
|
+
headers: t.filter(Boolean),
|
|
60
|
+
footers: n.filter(Boolean)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function f(t) {
|
|
64
|
+
let n = e(t), r = n.find(a);
|
|
65
|
+
return r ? {
|
|
66
|
+
table: r,
|
|
67
|
+
by: r.groupBy
|
|
68
|
+
} : t?.groupBy != null && n.length > 0 ? {
|
|
69
|
+
table: n[0],
|
|
70
|
+
by: t.groupBy
|
|
71
|
+
} : null;
|
|
72
|
+
}
|
|
73
|
+
function p(e, t) {
|
|
74
|
+
return (Array.isArray(e?.bands) ? e.bands : []).find((e) => e?.type === t) ?? null;
|
|
75
|
+
}
|
|
76
|
+
function m(t) {
|
|
77
|
+
let n = f(t), r = [];
|
|
78
|
+
for (let i of e(t)) {
|
|
79
|
+
let e = o(i).filter((e) => typeof e == "object" && !!e).map((e) => ({
|
|
80
|
+
...e,
|
|
81
|
+
header: e.header ?? null,
|
|
82
|
+
footer: e.footer ?? null
|
|
83
|
+
}));
|
|
84
|
+
if (e.length > 0) r.push({
|
|
85
|
+
table: i,
|
|
86
|
+
...e[0],
|
|
87
|
+
levels: e
|
|
88
|
+
});
|
|
89
|
+
else if (n?.table === i) {
|
|
90
|
+
let e = {
|
|
91
|
+
by: n.by,
|
|
92
|
+
header: p(t, "groupHeader"),
|
|
93
|
+
footer: p(t, "groupFooter")
|
|
94
|
+
};
|
|
95
|
+
r.push({
|
|
96
|
+
table: i,
|
|
97
|
+
...e,
|
|
98
|
+
levels: [e]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return r;
|
|
103
|
+
}
|
|
104
|
+
function h(e) {
|
|
105
|
+
return m(e)[0] ?? null;
|
|
106
|
+
}
|
|
107
|
+
function g(t) {
|
|
108
|
+
let r = structuredClone(t);
|
|
109
|
+
if (typeof r != "object" || !r) return r;
|
|
110
|
+
for (let e of m(r)) o(e.table).length === 0 && (e.table.grouping = [{
|
|
111
|
+
by: e.by,
|
|
112
|
+
header: e.header,
|
|
113
|
+
footer: e.footer
|
|
114
|
+
}]);
|
|
115
|
+
for (let t of e(r)) {
|
|
116
|
+
delete t.groupBy;
|
|
117
|
+
for (let e of o(t)) typeof e != "object" || !e || (e.header = _(e.header, "groupHeader"), e.footer = _(e.footer, "groupFooter"));
|
|
118
|
+
}
|
|
119
|
+
return delete r.groupBy, Array.isArray(r.bands) && (r.bands = r.bands.filter((e) => !n.includes(e?.type))), r;
|
|
120
|
+
}
|
|
121
|
+
function _(e, t) {
|
|
122
|
+
return typeof e != "object" || !e ? null : (e.type = t, e);
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/engine/format.js
|
|
126
|
+
var v = Object.freeze({
|
|
127
|
+
type: "text",
|
|
128
|
+
decimals: 2,
|
|
129
|
+
grouping: "international",
|
|
130
|
+
negative: "minus",
|
|
131
|
+
zero: "zero",
|
|
132
|
+
symbol: "",
|
|
133
|
+
symbolPosition: "before",
|
|
134
|
+
pattern: "yyyy-MM-dd"
|
|
135
|
+
}), y = Object.freeze({
|
|
136
|
+
grouping: "indian",
|
|
137
|
+
symbol: "₹",
|
|
138
|
+
symbolPosition: "before",
|
|
139
|
+
pattern: "dd/MM/yyyy"
|
|
140
|
+
}), b = [
|
|
141
|
+
"text",
|
|
142
|
+
"number",
|
|
143
|
+
"currency",
|
|
144
|
+
"percent",
|
|
145
|
+
"date",
|
|
146
|
+
"datetime"
|
|
147
|
+
], x = [
|
|
148
|
+
"international",
|
|
149
|
+
"indian",
|
|
150
|
+
"none"
|
|
151
|
+
], S = [
|
|
152
|
+
"minus",
|
|
153
|
+
"brackets",
|
|
154
|
+
"trailing"
|
|
155
|
+
], C = [
|
|
156
|
+
"zero",
|
|
157
|
+
"dash",
|
|
158
|
+
"blank"
|
|
159
|
+
], w = ["before", "after"], T = [
|
|
160
|
+
{
|
|
161
|
+
value: "",
|
|
162
|
+
label: "None"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
value: "₹",
|
|
166
|
+
label: "₹ Indian rupee"
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
value: "Rs.",
|
|
170
|
+
label: "Rs. Rupee"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
value: "$",
|
|
174
|
+
label: "$ Dollar"
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
value: "€",
|
|
178
|
+
label: "€ Euro"
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
value: "£",
|
|
182
|
+
label: "£ Pound"
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
value: "¥",
|
|
186
|
+
label: "¥ Yen / Yuan"
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
value: "AED",
|
|
190
|
+
label: "AED UAE dirham"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
value: "SAR",
|
|
194
|
+
label: "SAR Saudi riyal"
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
value: "S$",
|
|
198
|
+
label: "S$ Singapore dollar"
|
|
199
|
+
}
|
|
200
|
+
], E = [
|
|
201
|
+
"dd/MM/yyyy",
|
|
202
|
+
"dd-MMM-yyyy",
|
|
203
|
+
"d MMMM yyyy",
|
|
204
|
+
"MM/dd/yyyy",
|
|
205
|
+
"yyyy-MM-dd"
|
|
206
|
+
], D = [
|
|
207
|
+
"dd/MM/yyyy HH:mm",
|
|
208
|
+
"dd/MM/yyyy hh:mm a",
|
|
209
|
+
"dd-MMM-yyyy HH:mm",
|
|
210
|
+
"yyyy-MM-dd HH:mm"
|
|
211
|
+
], O = [
|
|
212
|
+
"number",
|
|
213
|
+
"currency",
|
|
214
|
+
"percent"
|
|
215
|
+
], ee = ["date", "datetime"], te = [
|
|
216
|
+
"January",
|
|
217
|
+
"February",
|
|
218
|
+
"March",
|
|
219
|
+
"April",
|
|
220
|
+
"May",
|
|
221
|
+
"June",
|
|
222
|
+
"July",
|
|
223
|
+
"August",
|
|
224
|
+
"September",
|
|
225
|
+
"October",
|
|
226
|
+
"November",
|
|
227
|
+
"December"
|
|
228
|
+
], ne = /yyyy|yy|MMMM|MMM|MM|M|dd|d|HH|H|hh|h|mm|ss|a/g, re = /^-?\d+(\.\d+)?$/, ie = /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.\d+)?)?)?(Z|[+-]\d{2}:?\d{2})?$/;
|
|
229
|
+
function k(e, t) {
|
|
230
|
+
if (typeof e != "object" || !e || !b.includes(e.type) || e.type === "text") return null;
|
|
231
|
+
let n = t && typeof t == "object" ? t : {}, r = {
|
|
232
|
+
...v,
|
|
233
|
+
...le(n),
|
|
234
|
+
...e
|
|
235
|
+
};
|
|
236
|
+
return r.decimals = ce(r.decimals), x.includes(r.grouping) || (r.grouping = v.grouping), S.includes(r.negative) || (r.negative = v.negative), C.includes(r.zero) || (r.zero = v.zero), w.includes(r.symbolPosition) || (r.symbolPosition = v.symbolPosition), typeof r.symbol != "string" && (r.symbol = ""), (typeof r.pattern != "string" || r.pattern === "") && (r.pattern = r.type === "datetime" ? "yyyy-MM-dd HH:mm" : v.pattern), r;
|
|
237
|
+
}
|
|
238
|
+
function A(e) {
|
|
239
|
+
return e?.type === "percent" ? e : {
|
|
240
|
+
type: "percent",
|
|
241
|
+
decimals: 2
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function j(e, t, n) {
|
|
245
|
+
if (e == null) return "";
|
|
246
|
+
let r = k(t, n);
|
|
247
|
+
if (!r) return String(e);
|
|
248
|
+
if (O.includes(r.type)) {
|
|
249
|
+
let t = M(e);
|
|
250
|
+
return t === null ? String(e) : oe(t, r);
|
|
251
|
+
}
|
|
252
|
+
let i = N(e);
|
|
253
|
+
return i === null ? String(e) : ue(i, r.pattern);
|
|
254
|
+
}
|
|
255
|
+
function M(e) {
|
|
256
|
+
if (typeof e == "number") return Number.isFinite(e) ? e : null;
|
|
257
|
+
if (typeof e != "string") return null;
|
|
258
|
+
let t = e.trim();
|
|
259
|
+
return re.test(t) ? Number(t) : null;
|
|
260
|
+
}
|
|
261
|
+
function N(e) {
|
|
262
|
+
if (e instanceof Date) return Number.isNaN(e.getTime()) ? null : {
|
|
263
|
+
year: e.getFullYear(),
|
|
264
|
+
month: e.getMonth() + 1,
|
|
265
|
+
day: e.getDate(),
|
|
266
|
+
hour: e.getHours(),
|
|
267
|
+
minute: e.getMinutes(),
|
|
268
|
+
second: e.getSeconds()
|
|
269
|
+
};
|
|
270
|
+
if (typeof e != "string") return null;
|
|
271
|
+
let t = e.trim().match(ie);
|
|
272
|
+
if (!t) return null;
|
|
273
|
+
let [, n, r, i, a = "0", o = "0", s = "0"] = t, c = {
|
|
274
|
+
year: Number(n),
|
|
275
|
+
month: Number(r),
|
|
276
|
+
day: Number(i),
|
|
277
|
+
hour: Number(a),
|
|
278
|
+
minute: Number(o),
|
|
279
|
+
second: Number(s)
|
|
280
|
+
}, l = new Date(Date.UTC(c.year, c.month - 1, c.day));
|
|
281
|
+
return l.getUTCMonth() !== c.month - 1 || l.getUTCDate() !== c.day || c.hour > 23 || c.minute > 59 || c.second > 59 ? null : c;
|
|
282
|
+
}
|
|
283
|
+
function ae(e, t) {
|
|
284
|
+
let n = k(e, t);
|
|
285
|
+
return n ? ee.includes(n.type) ? `${n.type === "date" ? "Date" : "Date & time"} · ${n.pattern}` : `${{
|
|
286
|
+
number: "Number",
|
|
287
|
+
currency: "Currency",
|
|
288
|
+
percent: "Percent"
|
|
289
|
+
}[n.type]} · ${j(n.type === "percent" ? 1234.5678 : 1234567.891, n)}` : "As it comes";
|
|
290
|
+
}
|
|
291
|
+
function oe(e, t) {
|
|
292
|
+
let n = t.type === "percent" ? e * 100 : e, r = F(Math.abs(n), t.decimals), i = /^[0.]*$/.test(r);
|
|
293
|
+
if (i && t.zero === "blank") return "";
|
|
294
|
+
if (i && t.zero === "dash") return "-";
|
|
295
|
+
let [a, o] = r.split("."), s = se(a, t.grouping) + (o ? `.${o}` : "");
|
|
296
|
+
if (t.type === "percent" && (s += "%"), t.type === "currency" && t.symbol && (s = t.symbolPosition === "after" ? `${s} ${t.symbol}` : `${t.symbol}${s}`), n >= 0 || i) return s;
|
|
297
|
+
switch (t.negative) {
|
|
298
|
+
case "brackets": return `(${s})`;
|
|
299
|
+
case "trailing": return `${s}-`;
|
|
300
|
+
default: return `-${s}`;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
var P = /* @__PURE__ */ new Map();
|
|
304
|
+
function F(e, t) {
|
|
305
|
+
return P.has(t) || P.set(t, new Intl.NumberFormat("en-US", {
|
|
306
|
+
minimumFractionDigits: t,
|
|
307
|
+
maximumFractionDigits: t,
|
|
308
|
+
useGrouping: !1
|
|
309
|
+
})), P.get(t).format(e);
|
|
310
|
+
}
|
|
311
|
+
function se(e, t) {
|
|
312
|
+
if (t === "none" || e.length <= 3) return e;
|
|
313
|
+
if (t === "indian") {
|
|
314
|
+
let t = e.slice(0, -3), n = e.slice(-3);
|
|
315
|
+
return `${t.replace(/\B(?=(\d{2})+$)/g, ",")},${n}`;
|
|
316
|
+
}
|
|
317
|
+
return e.replace(/\B(?=(\d{3})+$)/g, ",");
|
|
318
|
+
}
|
|
319
|
+
function ce(e) {
|
|
320
|
+
let t = Math.round(Number(e));
|
|
321
|
+
return Number.isFinite(t) ? Math.min(6, Math.max(0, t)) : v.decimals;
|
|
322
|
+
}
|
|
323
|
+
function le(e) {
|
|
324
|
+
let { type: t, ...n } = e;
|
|
325
|
+
return n;
|
|
326
|
+
}
|
|
327
|
+
function ue(e, t) {
|
|
328
|
+
let n = (e) => String(e).padStart(2, "0"), r = e.hour % 12 == 0 ? 12 : e.hour % 12;
|
|
329
|
+
return t.replace(ne, (t) => {
|
|
330
|
+
switch (t) {
|
|
331
|
+
case "yyyy": return String(e.year).padStart(4, "0");
|
|
332
|
+
case "yy": return n(e.year % 100);
|
|
333
|
+
case "MMMM": return te[e.month - 1];
|
|
334
|
+
case "MMM": return te[e.month - 1].slice(0, 3);
|
|
335
|
+
case "MM": return n(e.month);
|
|
336
|
+
case "M": return String(e.month);
|
|
337
|
+
case "dd": return n(e.day);
|
|
338
|
+
case "d": return String(e.day);
|
|
339
|
+
case "HH": return n(e.hour);
|
|
340
|
+
case "H": return String(e.hour);
|
|
341
|
+
case "hh": return n(r);
|
|
342
|
+
case "h": return String(r);
|
|
343
|
+
case "mm": return n(e.minute);
|
|
344
|
+
case "ss": return n(e.second);
|
|
345
|
+
case "a": return e.hour < 12 ? "AM" : "PM";
|
|
346
|
+
default: return t;
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
function de(e, t) {
|
|
351
|
+
let n = k(e, t);
|
|
352
|
+
if (!n) return null;
|
|
353
|
+
if (ee.includes(n.type)) return fe(n.pattern);
|
|
354
|
+
let r = n.decimals > 0 ? `.${"0".repeat(n.decimals)}` : "", i = n.type === "percent" ? "%" : "", a = n.type === "currency" && n.symbol ? I(n.symbol) : "", o = (e) => {
|
|
355
|
+
let t = `${e}${r}${i}`;
|
|
356
|
+
return a ? n.symbolPosition === "after" ? `${t}${I(" ")}${a}` : `${a}${t}` : t;
|
|
357
|
+
};
|
|
358
|
+
if (n.grouping === "indian") return [
|
|
359
|
+
`[>=10000000]${o("##\\,##\\,##\\,##0")}`,
|
|
360
|
+
`[>=100000]${o("##\\,##\\,##0")}`,
|
|
361
|
+
o("#,##0")
|
|
362
|
+
].join(";");
|
|
363
|
+
let s = o(n.grouping === "none" ? "0" : "#,##0");
|
|
364
|
+
return `${s};${{
|
|
365
|
+
minus: `-${s}`,
|
|
366
|
+
brackets: `(${s})`,
|
|
367
|
+
trailing: `${s}-`
|
|
368
|
+
}[n.negative]};${{
|
|
369
|
+
zero: s,
|
|
370
|
+
dash: I("-"),
|
|
371
|
+
blank: ""
|
|
372
|
+
}[n.zero]}`;
|
|
373
|
+
}
|
|
374
|
+
function fe(e) {
|
|
375
|
+
let t = "", n = 0;
|
|
376
|
+
for (let r of e.matchAll(ne)) t += pe(e.slice(n, r.index)), t += {
|
|
377
|
+
yyyy: "yyyy",
|
|
378
|
+
yy: "yy",
|
|
379
|
+
MMMM: "mmmm",
|
|
380
|
+
MMM: "mmm",
|
|
381
|
+
MM: "mm",
|
|
382
|
+
M: "m",
|
|
383
|
+
dd: "dd",
|
|
384
|
+
d: "d",
|
|
385
|
+
HH: "hh",
|
|
386
|
+
H: "h",
|
|
387
|
+
hh: "hh",
|
|
388
|
+
h: "h",
|
|
389
|
+
mm: "mm",
|
|
390
|
+
ss: "ss",
|
|
391
|
+
a: "AM/PM"
|
|
392
|
+
}[r[0]], n = r.index + r[0].length;
|
|
393
|
+
return t + pe(e.slice(n));
|
|
394
|
+
}
|
|
395
|
+
function pe(e) {
|
|
396
|
+
return [...e].map((e) => e === " " ? " " : `\\${e}`).join("");
|
|
397
|
+
}
|
|
398
|
+
function I(e) {
|
|
399
|
+
return `"${String(e).replace(/"/g, "")}"`;
|
|
400
|
+
}
|
|
401
|
+
function me(e, t, n) {
|
|
402
|
+
let r = k(t, n);
|
|
403
|
+
if (!r) return null;
|
|
404
|
+
if (O.includes(r.type)) return M(e);
|
|
405
|
+
let i = N(e);
|
|
406
|
+
if (!i) return null;
|
|
407
|
+
let a = Date.UTC(i.year, i.month - 1, i.day) / 864e5 + 25569, o = (i.hour * 3600 + i.minute * 60 + i.second) / 86400;
|
|
408
|
+
return r.type === "date" ? a : a + o;
|
|
409
|
+
}
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region src/engine/highlight.js
|
|
412
|
+
var he = [
|
|
413
|
+
"=",
|
|
414
|
+
"!=",
|
|
415
|
+
"<",
|
|
416
|
+
"<=",
|
|
417
|
+
">",
|
|
418
|
+
">=",
|
|
419
|
+
"between",
|
|
420
|
+
"contains",
|
|
421
|
+
"startsWith",
|
|
422
|
+
"empty",
|
|
423
|
+
"notEmpty"
|
|
424
|
+
], ge = ["empty", "notEmpty"], _e = [
|
|
425
|
+
"color",
|
|
426
|
+
"background",
|
|
427
|
+
"fontWeight",
|
|
428
|
+
"fontStyle"
|
|
429
|
+
];
|
|
430
|
+
function L(e, t, n = null) {
|
|
431
|
+
if (!Array.isArray(e)) return null;
|
|
432
|
+
for (let r of e) {
|
|
433
|
+
let e = r?.when;
|
|
434
|
+
if (!(!e || !he.includes(e.op)) && be(typeof e.field == "string" && e.field !== "" ? Te(n, e.field) : t, e)) return Ee(r.style);
|
|
435
|
+
}
|
|
436
|
+
return null;
|
|
437
|
+
}
|
|
438
|
+
function ve(e, t, n) {
|
|
439
|
+
let r = L(e?.rowHighlight, null, n), i = L(t?.highlight, n?.[t?.field], n);
|
|
440
|
+
return !r && !i ? null : {
|
|
441
|
+
...r ?? {},
|
|
442
|
+
...i ?? {}
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function ye(e) {
|
|
446
|
+
let t = Array.isArray(e) ? e.length : 0;
|
|
447
|
+
return t === 0 ? "None" : t === 1 ? "1 rule" : `${t} rules`;
|
|
448
|
+
}
|
|
449
|
+
function be(e, t) {
|
|
450
|
+
let { op: n } = t;
|
|
451
|
+
if (n === "empty") return we(e);
|
|
452
|
+
if (n === "notEmpty") return !we(e);
|
|
453
|
+
if (we(e)) return n === "!=" && !we(t.value);
|
|
454
|
+
if (n === "contains") return R(e).includes(R(t.value));
|
|
455
|
+
if (n === "startsWith") return R(e).startsWith(R(t.value));
|
|
456
|
+
if (n === "between") {
|
|
457
|
+
let n = xe(e, t.value), r = xe(e, t.to);
|
|
458
|
+
return n !== null && r !== null && n >= 0 && r <= 0;
|
|
459
|
+
}
|
|
460
|
+
let r = xe(e, t.value);
|
|
461
|
+
if (r === null) return n === "!=";
|
|
462
|
+
switch (n) {
|
|
463
|
+
case "=": return r === 0;
|
|
464
|
+
case "!=": return r !== 0;
|
|
465
|
+
case "<": return r < 0;
|
|
466
|
+
case "<=": return r <= 0;
|
|
467
|
+
case ">": return r > 0;
|
|
468
|
+
case ">=": return r >= 0;
|
|
469
|
+
default: return !1;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
function xe(e, t) {
|
|
473
|
+
if (t == null || t === "") return null;
|
|
474
|
+
let n = M(e), r = M(t);
|
|
475
|
+
if (n !== null && r !== null) return Math.sign(n - r);
|
|
476
|
+
let i = N(e), a = N(t);
|
|
477
|
+
return i && a ? Math.sign(Ce(i) - Ce(a)) : Se(e) === Se(t) ? Math.sign(R(e).localeCompare(R(t))) : null;
|
|
478
|
+
}
|
|
479
|
+
function Se(e) {
|
|
480
|
+
return M(e) === null ? N(e) ? "date" : "text" : "number";
|
|
481
|
+
}
|
|
482
|
+
function Ce(e) {
|
|
483
|
+
return ((((e.year * 100 + e.month) * 100 + e.day) * 100 + e.hour) * 100 + e.minute) * 100 + e.second;
|
|
484
|
+
}
|
|
485
|
+
function we(e) {
|
|
486
|
+
return e == null || String(e).trim() === "";
|
|
487
|
+
}
|
|
488
|
+
function R(e) {
|
|
489
|
+
return String(e ?? "").trim().toLowerCase();
|
|
490
|
+
}
|
|
491
|
+
function Te(e, t) {
|
|
492
|
+
return t.split(".").reduce((e, t) => e?.[t], e ?? void 0);
|
|
493
|
+
}
|
|
494
|
+
function Ee(e) {
|
|
495
|
+
let t = {};
|
|
496
|
+
for (let n of _e) {
|
|
497
|
+
let r = e?.[n];
|
|
498
|
+
typeof r == "string" && r !== "" && (t[n] = r);
|
|
499
|
+
}
|
|
500
|
+
return t;
|
|
501
|
+
}
|
|
502
|
+
//#endregion
|
|
503
|
+
//#region src/engine/calculate.js
|
|
504
|
+
var De = [
|
|
505
|
+
"sum",
|
|
506
|
+
"avg",
|
|
507
|
+
"count",
|
|
508
|
+
"min",
|
|
509
|
+
"max"
|
|
510
|
+
], Oe = [
|
|
511
|
+
"round",
|
|
512
|
+
"abs",
|
|
513
|
+
"min",
|
|
514
|
+
"max",
|
|
515
|
+
"percentage"
|
|
516
|
+
];
|
|
517
|
+
function ke(e) {
|
|
518
|
+
if (typeof e != "string" || e.trim() === "") return { error: "is empty" };
|
|
519
|
+
try {
|
|
520
|
+
let t = Pe(Ne(e)), n = t.expression();
|
|
521
|
+
return t.end(), { ast: n };
|
|
522
|
+
} catch (e) {
|
|
523
|
+
return { error: e.message };
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
function Ae(e) {
|
|
527
|
+
let t = /* @__PURE__ */ new Set();
|
|
528
|
+
for (let [, n] of String(e ?? "").matchAll(/\{([^{}]+)\}/g)) t.add(n.trim());
|
|
529
|
+
return [...t];
|
|
530
|
+
}
|
|
531
|
+
function je(e) {
|
|
532
|
+
return typeof e?.expression == "string" && e.expression.trim() !== "";
|
|
533
|
+
}
|
|
534
|
+
function Me(e, t) {
|
|
535
|
+
let n = (Array.isArray(e?.columns) ? e.columns : []).filter(je);
|
|
536
|
+
if (n.length === 0 || !Array.isArray(t)) return t;
|
|
537
|
+
let r = t.map((e) => ({ ...e }));
|
|
538
|
+
for (let t of n) {
|
|
539
|
+
let n = ke(t.expression);
|
|
540
|
+
if (n.error) {
|
|
541
|
+
for (let e of r) e[t.field] = null;
|
|
542
|
+
continue;
|
|
543
|
+
}
|
|
544
|
+
let i = Fe(e, r), a = r.map((e) => z(n.ast, e, i));
|
|
545
|
+
r.forEach((e, n) => {
|
|
546
|
+
e[t.field] = a[n];
|
|
547
|
+
}), r = [...r];
|
|
548
|
+
}
|
|
549
|
+
return r;
|
|
550
|
+
}
|
|
551
|
+
function Ne(e) {
|
|
552
|
+
let t = [], n = 0;
|
|
553
|
+
for (; n < e.length;) {
|
|
554
|
+
let r = e[n];
|
|
555
|
+
if (/\s/.test(r)) {
|
|
556
|
+
n++;
|
|
557
|
+
continue;
|
|
558
|
+
}
|
|
559
|
+
if (r === "{") {
|
|
560
|
+
let r = e.indexOf("}", n);
|
|
561
|
+
if (r === -1) throw Error(`has a { at ${n + 1} that is never closed`);
|
|
562
|
+
let i = e.slice(n + 1, r).trim();
|
|
563
|
+
if (!i) throw Error(`has an empty {} at ${n + 1}`);
|
|
564
|
+
t.push({
|
|
565
|
+
type: "field",
|
|
566
|
+
value: i,
|
|
567
|
+
at: n
|
|
568
|
+
}), n = r + 1;
|
|
569
|
+
continue;
|
|
570
|
+
}
|
|
571
|
+
let i = /^\d+(\.\d+)?|^\.\d+/.exec(e.slice(n));
|
|
572
|
+
if (i) {
|
|
573
|
+
t.push({
|
|
574
|
+
type: "number",
|
|
575
|
+
value: Number(i[0]),
|
|
576
|
+
at: n
|
|
577
|
+
}), n += i[0].length;
|
|
578
|
+
continue;
|
|
579
|
+
}
|
|
580
|
+
let a = /^[A-Za-z_]\w*/.exec(e.slice(n));
|
|
581
|
+
if (a) {
|
|
582
|
+
t.push({
|
|
583
|
+
type: "name",
|
|
584
|
+
value: a[0],
|
|
585
|
+
at: n
|
|
586
|
+
}), n += a[0].length;
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
if ("+-*/%(),".includes(r)) {
|
|
590
|
+
t.push({
|
|
591
|
+
type: r,
|
|
592
|
+
value: r,
|
|
593
|
+
at: n
|
|
594
|
+
}), n++;
|
|
595
|
+
continue;
|
|
596
|
+
}
|
|
597
|
+
throw Error(`cannot read "${r}" at ${n + 1}`);
|
|
598
|
+
}
|
|
599
|
+
return t;
|
|
600
|
+
}
|
|
601
|
+
function Pe(e) {
|
|
602
|
+
let t = 0, n = () => e[t], r = (r) => n()?.type === r ? e[t++] : null, i = (e, t) => {
|
|
603
|
+
let n = r(e);
|
|
604
|
+
if (!n) throw Error(`expects ${t}${a()}`);
|
|
605
|
+
return n;
|
|
606
|
+
}, a = () => n() ? ` at ${n().at + 1}` : " at the end";
|
|
607
|
+
function o() {
|
|
608
|
+
let e = s();
|
|
609
|
+
for (let r = n()?.type; r === "+" || r === "-"; r = n()?.type) t++, e = {
|
|
610
|
+
kind: "binary",
|
|
611
|
+
op: r,
|
|
612
|
+
left: e,
|
|
613
|
+
right: s()
|
|
614
|
+
};
|
|
615
|
+
return e;
|
|
616
|
+
}
|
|
617
|
+
function s() {
|
|
618
|
+
let e = c();
|
|
619
|
+
for (let r = n()?.type; r === "*" || r === "/" || r === "%"; r = n()?.type) t++, e = {
|
|
620
|
+
kind: "binary",
|
|
621
|
+
op: r,
|
|
622
|
+
left: e,
|
|
623
|
+
right: c()
|
|
624
|
+
};
|
|
625
|
+
return e;
|
|
626
|
+
}
|
|
627
|
+
function c() {
|
|
628
|
+
return r("-") ? {
|
|
629
|
+
kind: "negate",
|
|
630
|
+
value: c()
|
|
631
|
+
} : r("+") ? c() : l();
|
|
632
|
+
}
|
|
633
|
+
function l() {
|
|
634
|
+
let e = n();
|
|
635
|
+
if (!e) throw Error("ends where a value is expected");
|
|
636
|
+
if (r("number")) return {
|
|
637
|
+
kind: "number",
|
|
638
|
+
value: e.value
|
|
639
|
+
};
|
|
640
|
+
if (r("field")) return {
|
|
641
|
+
kind: "field",
|
|
642
|
+
name: e.value
|
|
643
|
+
};
|
|
644
|
+
if (r("(")) {
|
|
645
|
+
let e = o();
|
|
646
|
+
return i(")", "a )"), e;
|
|
647
|
+
}
|
|
648
|
+
if (r("name")) {
|
|
649
|
+
let a = e.value;
|
|
650
|
+
if (a === "group") throw Error(`uses "group" at ${e.at + 1}, which only means anything in percentage(x, group)`);
|
|
651
|
+
if (!Oe.includes(a) && !De.includes(a)) throw Error(`has no function called "${a}" - it knows ${[.../* @__PURE__ */ new Set([...Oe, ...De])].join(", ")}`);
|
|
652
|
+
i("(", `a ( after ${a}`);
|
|
653
|
+
let s = [];
|
|
654
|
+
if (!r(")")) {
|
|
655
|
+
do
|
|
656
|
+
a === "percentage" && s.length === 1 && n()?.type === "name" && n().value === "group" ? (t++, s.push({ kind: "group" })) : s.push(o());
|
|
657
|
+
while (r(","));
|
|
658
|
+
i(")", `a ) to close ${a}(`);
|
|
659
|
+
}
|
|
660
|
+
return u(a, s, e);
|
|
661
|
+
}
|
|
662
|
+
throw Error(`does not expect "${e.value}"${a()}`);
|
|
663
|
+
}
|
|
664
|
+
function u(e, t, n) {
|
|
665
|
+
let r = t.length, i = ` at ${n.at + 1}`;
|
|
666
|
+
if (e === "count") {
|
|
667
|
+
if (r !== 0) throw Error(`gives count() nothing - it counts rows${i}`);
|
|
668
|
+
return {
|
|
669
|
+
kind: "aggregate",
|
|
670
|
+
fn: "count",
|
|
671
|
+
value: null
|
|
672
|
+
};
|
|
673
|
+
}
|
|
674
|
+
if ((e === "min" || e === "max") && r > 1) return {
|
|
675
|
+
kind: "call",
|
|
676
|
+
fn: e,
|
|
677
|
+
args: t
|
|
678
|
+
};
|
|
679
|
+
if (De.includes(e)) {
|
|
680
|
+
if (r !== 1) throw Error(`gives ${e}() one value${i}`);
|
|
681
|
+
return {
|
|
682
|
+
kind: "aggregate",
|
|
683
|
+
fn: e,
|
|
684
|
+
value: t[0]
|
|
685
|
+
};
|
|
686
|
+
}
|
|
687
|
+
if (e === "round" && (r < 1 || r > 2)) throw Error(`gives round() a value and, if you like, places${i}`);
|
|
688
|
+
if (e === "abs" && r !== 1) throw Error(`gives abs() one value${i}`);
|
|
689
|
+
if (e === "percentage" && (r < 1 || r > 2)) throw Error(`gives percentage() a value and, if you like, what it is a share of${i}`);
|
|
690
|
+
return {
|
|
691
|
+
kind: "call",
|
|
692
|
+
fn: e,
|
|
693
|
+
args: t
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
return {
|
|
697
|
+
expression: o,
|
|
698
|
+
end() {
|
|
699
|
+
if (n()) throw Error(`has "${n().value}" left over at ${n().at + 1}`);
|
|
700
|
+
}
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
function Fe(e, t) {
|
|
704
|
+
let n = o(e).map((e) => e?.by).filter(Boolean), r = (e) => n.map((t) => String(e?.[t])).join("\0"), i = /* @__PURE__ */ new Map();
|
|
705
|
+
if (n.length) for (let e of t) {
|
|
706
|
+
let t = r(e);
|
|
707
|
+
i.has(t) || i.set(t, []), i.get(t).push(e);
|
|
708
|
+
}
|
|
709
|
+
return {
|
|
710
|
+
rows: t,
|
|
711
|
+
groupOf: (e) => n.length ? i.get(r(e)) ?? [e] : t,
|
|
712
|
+
groupKey: r,
|
|
713
|
+
cache: /* @__PURE__ */ new Map()
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
function z(e, t, n) {
|
|
717
|
+
switch (e.kind) {
|
|
718
|
+
case "number": return e.value;
|
|
719
|
+
case "field": return M(Be(t, e.name));
|
|
720
|
+
case "negate": {
|
|
721
|
+
let r = z(e.value, t, n);
|
|
722
|
+
return r === null ? null : -r;
|
|
723
|
+
}
|
|
724
|
+
case "binary": {
|
|
725
|
+
let r = z(e.left, t, n), i = z(e.right, t, n);
|
|
726
|
+
if (r === null || i === null) return null;
|
|
727
|
+
switch (e.op) {
|
|
728
|
+
case "+": return B(r + i);
|
|
729
|
+
case "-": return B(r - i);
|
|
730
|
+
case "*": return B(r * i);
|
|
731
|
+
case "/": return i === 0 ? null : B(r / i);
|
|
732
|
+
case "%": return i === 0 ? null : B(r % i);
|
|
733
|
+
}
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
736
|
+
case "aggregate": return Ie(e, n.rows, n, "all");
|
|
737
|
+
case "call": return ze(e, t, n);
|
|
738
|
+
default: return null;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function Ie(e, t, n, r) {
|
|
742
|
+
n.cache.has(e) || n.cache.set(e, /* @__PURE__ */ new Map());
|
|
743
|
+
let i = n.cache.get(e);
|
|
744
|
+
if (i.has(r)) return i.get(r);
|
|
745
|
+
let a;
|
|
746
|
+
if (e.fn === "count") a = t.length;
|
|
747
|
+
else {
|
|
748
|
+
let r = t.map((t) => z(e.value, t, n)).filter((e) => e !== null);
|
|
749
|
+
a = r.length ? e.fn === "sum" ? B(r.reduce((e, t) => e + t, 0)) : e.fn === "avg" ? B(r.reduce((e, t) => e + t, 0) / r.length) : e.fn === "min" ? Math.min(...r) : e.fn === "max" ? Math.max(...r) : null : null;
|
|
750
|
+
}
|
|
751
|
+
return i.set(r, a), a;
|
|
752
|
+
}
|
|
753
|
+
var Le = /* @__PURE__ */ new WeakMap();
|
|
754
|
+
function Re(e) {
|
|
755
|
+
return Le.has(e) || Le.set(e, {
|
|
756
|
+
kind: "aggregate",
|
|
757
|
+
fn: "sum",
|
|
758
|
+
value: e.args[0]
|
|
759
|
+
}), Le.get(e);
|
|
760
|
+
}
|
|
761
|
+
function ze(e, t, n) {
|
|
762
|
+
let r = (r) => z(e.args[r], t, n);
|
|
763
|
+
switch (e.fn) {
|
|
764
|
+
case "abs": {
|
|
765
|
+
let e = r(0);
|
|
766
|
+
return e === null ? null : Math.abs(e);
|
|
767
|
+
}
|
|
768
|
+
case "round": {
|
|
769
|
+
let t = r(0), n = e.args.length > 1 ? r(1) : 0;
|
|
770
|
+
if (t === null || n === null) return null;
|
|
771
|
+
let i = 10 ** Math.max(0, Math.min(10, Math.round(n)));
|
|
772
|
+
return Math.round((t + 2 ** -52 * Math.sign(t)) * i) / i;
|
|
773
|
+
}
|
|
774
|
+
case "min":
|
|
775
|
+
case "max": {
|
|
776
|
+
let t = e.args.map((e, t) => r(t));
|
|
777
|
+
return t.some((e) => e === null) ? null : e.fn === "min" ? Math.min(...t) : Math.max(...t);
|
|
778
|
+
}
|
|
779
|
+
case "percentage": {
|
|
780
|
+
let i = r(0);
|
|
781
|
+
if (i === null) return null;
|
|
782
|
+
let a = e.args[1], o;
|
|
783
|
+
return o = a ? a.kind === "group" ? Ie(Re(e), n.groupOf(t), n, `group:${n.groupKey(t)}`) : r(1) : Ie(Re(e), n.rows, n, "all"), o === null || o === 0 ? null : B(i / o);
|
|
784
|
+
}
|
|
785
|
+
default: return null;
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
function Be(e, t) {
|
|
789
|
+
return t.split(".").reduce((e, t) => e?.[t], e);
|
|
790
|
+
}
|
|
791
|
+
function B(e) {
|
|
792
|
+
return Number.isFinite(e) ? Number(e.toPrecision(12)) : null;
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/engine/text-metrics.js
|
|
796
|
+
var Ve = 1.3, He = /* @__PURE__ */ new Map(), Ue = 1e4, We, Ge = !1;
|
|
797
|
+
function Ke() {
|
|
798
|
+
if (Ge) return We;
|
|
799
|
+
Ge = !0;
|
|
800
|
+
try {
|
|
801
|
+
We = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
|
|
802
|
+
} catch {
|
|
803
|
+
We = null;
|
|
804
|
+
}
|
|
805
|
+
return We;
|
|
806
|
+
}
|
|
807
|
+
function qe(e = {}) {
|
|
808
|
+
return `${e.fontStyle || "normal"} ${e.fontWeight || "normal"} ${e.fontSize ?? 12}px ${e.fontFamily || "Helvetica, Arial, sans-serif"}`;
|
|
809
|
+
}
|
|
810
|
+
function Je(e, t) {
|
|
811
|
+
let n = String(e ?? "");
|
|
812
|
+
if (n === "") return 0;
|
|
813
|
+
let r = qe(t), i = `${r}\u0000${n}`, a = He.get(i);
|
|
814
|
+
if (a !== void 0) return a;
|
|
815
|
+
let o = Ke(), s;
|
|
816
|
+
return o ? (o.font = r, s = o.measureText(n).width) : s = Ye(n, t), He.size >= Ue && He.clear(), He.set(i, s), s;
|
|
817
|
+
}
|
|
818
|
+
function Ye(e, t = {}) {
|
|
819
|
+
let n = t.fontSize ?? 12, r = String(t.fontWeight) === "bold" || Number(t.fontWeight) >= 600, i = /mono|courier|consolas/i.test(t.fontFamily || ""), a = 0;
|
|
820
|
+
for (let t of e) {
|
|
821
|
+
if (i) {
|
|
822
|
+
a += .6;
|
|
823
|
+
continue;
|
|
824
|
+
}
|
|
825
|
+
t === " " ? a += .26 : /[iljI.,:;'`|!\[\]()]/.test(t) ? a += .28 : /[ftr]/.test(t) ? a += .34 : /[A-Z]/.test(t) ? a += .68 : /[mwMW@]/.test(t) ? a += .88 : /[0-9]/.test(t) ? a += .56 : a += .52;
|
|
826
|
+
}
|
|
827
|
+
return a * n * (r ? 1.06 : 1);
|
|
828
|
+
}
|
|
829
|
+
function Xe(e, t, n) {
|
|
830
|
+
let r = String(e ?? "").split("\n");
|
|
831
|
+
if (!(t > 0)) return r;
|
|
832
|
+
let i = [];
|
|
833
|
+
for (let e of r) {
|
|
834
|
+
let r = e.split(/(\s+)/).filter((e) => e !== "");
|
|
835
|
+
if (r.length === 0) {
|
|
836
|
+
i.push("");
|
|
837
|
+
continue;
|
|
838
|
+
}
|
|
839
|
+
let a = "";
|
|
840
|
+
for (let e of r) {
|
|
841
|
+
let r = a + e;
|
|
842
|
+
for (a !== "" && Je(r, n) > t ? (i.push(a.trimEnd()), a = e.trimStart()) : a = r; Je(a, n) > t && a.trim().length > 1;) {
|
|
843
|
+
let e = a.length;
|
|
844
|
+
for (; e > 1 && Je(a.slice(0, e), n) > t;) e--;
|
|
845
|
+
if (e >= a.length) break;
|
|
846
|
+
i.push(a.slice(0, e)), a = a.slice(e);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
i.push(a.trimEnd());
|
|
850
|
+
}
|
|
851
|
+
return i;
|
|
852
|
+
}
|
|
853
|
+
function Ze(e, t, n) {
|
|
854
|
+
let r = Math.ceil((n?.fontSize ?? 12) * Ve);
|
|
855
|
+
return Xe(e, t, n).length * r;
|
|
856
|
+
}
|
|
857
|
+
function Qe(e) {
|
|
858
|
+
return {
|
|
859
|
+
fontSize: e.style?.fontSize ?? 12,
|
|
860
|
+
fontFamily: e.style?.fontFamily,
|
|
861
|
+
fontWeight: "normal",
|
|
862
|
+
fontStyle: "normal"
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
function $e(e) {
|
|
866
|
+
let t = (e.columns ?? []).map((e) => e.width ?? 0), n = t.reduce((e, t) => e + t, 0), r = e.w ?? n, i = n > 0 && r > n ? r / n : 1;
|
|
867
|
+
return t.map((e) => e * i);
|
|
868
|
+
}
|
|
869
|
+
function et(e) {
|
|
870
|
+
if (e.style?.borderStyle === "none") return 0;
|
|
871
|
+
let t = Number(e.style?.borderWidth);
|
|
872
|
+
return Number.isFinite(t) && t > 0 ? t : 1;
|
|
873
|
+
}
|
|
874
|
+
function tt(e) {
|
|
875
|
+
let t = $e(e), n = et(e), r = t.length - 1;
|
|
876
|
+
return t.map((e, t) => e - 16 - n * (t === r ? 2 : 1));
|
|
877
|
+
}
|
|
878
|
+
function nt(e, t) {
|
|
879
|
+
let n = e.rowHeight ?? 0, r = t ?? [];
|
|
880
|
+
if (e.wrap === !1) return r.map(() => n);
|
|
881
|
+
let i = Qe(e), a = e.columns ?? [], o = tt(e);
|
|
882
|
+
return r.map((t) => {
|
|
883
|
+
let r = n;
|
|
884
|
+
for (let [n, s] of a.entries()) {
|
|
885
|
+
let a = o[n];
|
|
886
|
+
if (!(a > 0)) continue;
|
|
887
|
+
let c = j(t?.[s.field], s.format);
|
|
888
|
+
if (c === "") continue;
|
|
889
|
+
let l = ve(e, s, t), u = l?.fontWeight || l?.fontStyle ? {
|
|
890
|
+
...i,
|
|
891
|
+
fontWeight: l.fontWeight ?? i.fontWeight,
|
|
892
|
+
fontStyle: l.fontStyle ?? i.fontStyle
|
|
893
|
+
} : i;
|
|
894
|
+
r = Math.max(r, Ze(String(c), a, u));
|
|
895
|
+
}
|
|
896
|
+
return r;
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
function rt(e) {
|
|
900
|
+
if (!e.showHeader) return 0;
|
|
901
|
+
let t = e.headerHeight ?? e.rowHeight ?? 0;
|
|
902
|
+
if (e.wrap === !1) return t;
|
|
903
|
+
let n = (e.columns ?? []).map((e, t) => ({
|
|
904
|
+
...e,
|
|
905
|
+
field: `label${t}`
|
|
906
|
+
})), r = Object.fromEntries((e.columns ?? []).map((e, t) => [`label${t}`, e.label])), [i] = nt({
|
|
907
|
+
...e,
|
|
908
|
+
rowHeight: t,
|
|
909
|
+
columns: n
|
|
910
|
+
}, [r]);
|
|
911
|
+
return i ?? t;
|
|
912
|
+
}
|
|
913
|
+
function it(e) {
|
|
914
|
+
if (e.type !== "table") return e.h ?? 0;
|
|
915
|
+
let t = e.rowHeight ?? 0;
|
|
916
|
+
return (e.showHeader ? e.headerHeight ?? t : 0) + 3 * t;
|
|
917
|
+
}
|
|
918
|
+
function at(e) {
|
|
919
|
+
let t = structuredClone(e);
|
|
920
|
+
for (let e of t.bands) e.items && ot(e, t);
|
|
921
|
+
return t;
|
|
922
|
+
}
|
|
923
|
+
function ot(e, t) {
|
|
924
|
+
let n = 0;
|
|
925
|
+
for (let r of e.items) r.measuredHeight = ct(r, t), n = Math.max(n, (r.y ?? 0) + r.measuredHeight);
|
|
926
|
+
return e.contentHeight = n, e.measuredHeight = st(e) ? n : Math.max(e.height ?? 0, n), e;
|
|
927
|
+
}
|
|
928
|
+
function st(e) {
|
|
929
|
+
return e.items.some((e) => e.type === "table");
|
|
930
|
+
}
|
|
931
|
+
function ct(e, t) {
|
|
932
|
+
switch (e.type) {
|
|
933
|
+
case "text": return lt(e);
|
|
934
|
+
case "table": return dt(e, t);
|
|
935
|
+
case "line": return ut(e);
|
|
936
|
+
case "box":
|
|
937
|
+
case "image": return e.h ?? 0;
|
|
938
|
+
default: return console.warn(`Unknown item type "${e.type}" on item "${e.id}"; treating as zero height.`), 0;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
function lt(e) {
|
|
942
|
+
let t = e.h ?? 0, n = Ze(e.text ?? e.value ?? "", e.w ?? 0, e.highlighted ? {
|
|
943
|
+
...e.style ?? {},
|
|
944
|
+
...e.highlighted
|
|
945
|
+
} : e.style);
|
|
946
|
+
return Math.max(t, n);
|
|
947
|
+
}
|
|
948
|
+
function ut(e) {
|
|
949
|
+
let t = e.h ?? 0;
|
|
950
|
+
return e.orientation === "vertical" ? t : Math.max(t, e.style?.thickness ?? 0);
|
|
951
|
+
}
|
|
952
|
+
function dt(e, t) {
|
|
953
|
+
let n = rt(e);
|
|
954
|
+
if (e.headerMeasured = n, !Array.isArray(e.groups)) return e.rowHeights = nt(e, e.row), n + V(e.rowHeights);
|
|
955
|
+
for (let n of o(e)) pt(n?.header, t), pt(n?.footer, t);
|
|
956
|
+
let r = 0;
|
|
957
|
+
return e.groups.forEach((t, i) => {
|
|
958
|
+
t.rowHeights = nt(e, t.rows);
|
|
959
|
+
let a = l(e, t, i === 0, !0);
|
|
960
|
+
r += (a.columnHeader ? n : 0) + ft(a.headers) + V(t.rowHeights) + ft(a.footers);
|
|
961
|
+
}), r;
|
|
962
|
+
}
|
|
963
|
+
function V(e) {
|
|
964
|
+
return (e ?? []).reduce((e, t) => e + t, 0);
|
|
965
|
+
}
|
|
966
|
+
function ft(e) {
|
|
967
|
+
return V(e.map(({ band: e }) => e?.measuredHeight ?? 0));
|
|
968
|
+
}
|
|
969
|
+
function pt(e, t) {
|
|
970
|
+
return Array.isArray(e?.items) ? ot(e, t).measuredHeight : 0;
|
|
971
|
+
}
|
|
972
|
+
//#endregion
|
|
973
|
+
//#region src/engine/validate.js
|
|
974
|
+
var mt = [
|
|
975
|
+
"reportHeader",
|
|
976
|
+
"pageHeader",
|
|
977
|
+
"groupHeader",
|
|
978
|
+
"detail",
|
|
979
|
+
"groupFooter",
|
|
980
|
+
"reportFooter",
|
|
981
|
+
"pageFooter"
|
|
982
|
+
], ht = [
|
|
983
|
+
"text",
|
|
984
|
+
"table",
|
|
985
|
+
"line",
|
|
986
|
+
"box",
|
|
987
|
+
"image"
|
|
988
|
+
], gt = ["horizontal", "vertical"], _t = [
|
|
989
|
+
"solid",
|
|
990
|
+
"dashed",
|
|
991
|
+
"dotted",
|
|
992
|
+
"double"
|
|
993
|
+
], vt = [..._t, "none"], yt = [
|
|
994
|
+
"contain",
|
|
995
|
+
"cover",
|
|
996
|
+
"fill"
|
|
997
|
+
], H = class extends Error {
|
|
998
|
+
constructor(e, t = []) {
|
|
999
|
+
super(t.length ? `${e}\n - ${t.join("\n - ")}` : e), this.name = "ReportError", this.issues = t;
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
function bt(e) {
|
|
1003
|
+
let t = [];
|
|
1004
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return ["layout must be an object"];
|
|
1005
|
+
if (wt(e.page, t), !Array.isArray(e.bands)) return t.push("layout.bands must be an array"), t;
|
|
1006
|
+
e.bands.length === 0 && t.push("layout.bands is empty - there is nothing to render"), e.groupBy != null && typeof e.groupBy != "string" && t.push("layout.groupBy must be a field name or null"), Dt(e.format, "layout.format", t, !1);
|
|
1007
|
+
let n = /* @__PURE__ */ new Set();
|
|
1008
|
+
return e.bands.forEach((e, r) => {
|
|
1009
|
+
let i = `bands[${r}]`;
|
|
1010
|
+
if (typeof e != "object" || !e) {
|
|
1011
|
+
t.push(`${i} must be an object`);
|
|
1012
|
+
return;
|
|
1013
|
+
}
|
|
1014
|
+
if (mt.includes(e.type) ? n.has(e.type) ? t.push(`${i}.type "${e.type}" appears more than once; the engine places one band of each type`) : n.add(e.type) : t.push(`${i}.type "${e.type}" is not one of: ${mt.join(", ")}`), !Array.isArray(e.items)) {
|
|
1015
|
+
t.push(`${i}.items must be an array`);
|
|
1016
|
+
return;
|
|
1017
|
+
}
|
|
1018
|
+
e.items.forEach((e, n) => Tt(e, `${i}.items[${n}]`, t));
|
|
1019
|
+
}), e.groupBy != null && !n.has("groupHeader") && !n.has("groupFooter") && t.push("layout.groupBy is set but there is no groupHeader or groupFooter band to show it"), xt(e, e.bands, t), t;
|
|
1020
|
+
}
|
|
1021
|
+
function xt(t, n, r) {
|
|
1022
|
+
let i = e(t);
|
|
1023
|
+
for (let e of i) e.groupBy != null && typeof e.groupBy != "string" && r.push(`table "${e.id}".groupBy must be a field name or null`), e.dataset != null && typeof e.dataset != "string" && r.push(`table "${e.id}".dataset must be a dataset name or null`), St(e, r);
|
|
1024
|
+
let s = i.filter(a);
|
|
1025
|
+
s.length > 1 && r.push(`${s.length} tables are grouped by groupBy (${s.map((e) => `"${e.id}"`).join(", ")}); only one can use the report's groupHeader and groupFooter - give the others a grouping of their own`), s.length > 0 && t.groupBy == null && !n.some((e) => e?.type === "groupHeader" || e?.type === "groupFooter") && r.push(`table "${s[0].id}" is grouped by "${s[0].groupBy}" but there is no groupHeader or groupFooter band to show it`);
|
|
1026
|
+
let c = i[0];
|
|
1027
|
+
t.groupBy != null && s.length === 0 && c && o(c).length > 0 && r.push(`layout.groupBy groups the first table, "${c.id}", which already has a grouping of its own; remove one of the two`);
|
|
1028
|
+
for (let e of n) {
|
|
1029
|
+
if (!Array.isArray(e?.items)) continue;
|
|
1030
|
+
let t = e.items.filter((e) => e?.type === "table").map((e) => ({
|
|
1031
|
+
item: e,
|
|
1032
|
+
top: Number(e.y) || 0,
|
|
1033
|
+
bottom: (Number(e.y) || 0) + it(e)
|
|
1034
|
+
})).sort((e, t) => e.top - t.top);
|
|
1035
|
+
for (let n = 1; n < t.length; n++) {
|
|
1036
|
+
let i = t[n - 1], a = t[n];
|
|
1037
|
+
a.top < i.bottom && r.push(`tables "${i.item.id}" and "${a.item.id}" overlap in the ${e.type} band; move "${a.item.id}" to y ${Math.ceil(i.bottom)} or lower - tables are stacked, one under another, not placed side by side`);
|
|
1038
|
+
}
|
|
1039
|
+
}
|
|
1040
|
+
}
|
|
1041
|
+
function St(e, t) {
|
|
1042
|
+
if (e.grouping == null) return;
|
|
1043
|
+
let n = `table "${e.id}".grouping`;
|
|
1044
|
+
if (!Array.isArray(e.grouping)) {
|
|
1045
|
+
t.push(`${n} must be a list of group levels, or null`);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
e.grouping.length > 0 && a(e) && t.push(`table "${e.id}" is grouped both by groupBy and by grouping; remove groupBy`), e.grouping.length > 8 && t.push(`${n} has ${e.grouping.length} levels; a table may be grouped at 8 at most`);
|
|
1049
|
+
let r = /* @__PURE__ */ new Map();
|
|
1050
|
+
e.grouping.forEach((e, a) => {
|
|
1051
|
+
let o = `${n}[${a}]`;
|
|
1052
|
+
if (typeof e != "object" || !e || Array.isArray(e)) {
|
|
1053
|
+
t.push(`${o} must be an object with by, header and footer`);
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
typeof e.by != "string" || e.by === "" ? t.push(`${o}.by must be the name of the field to group by`) : r.has(e.by) ? t.push(`${o} groups by "${e.by}" again, as ${n}[${r.get(e.by)}] already does; group each level by a different field`) : r.set(e.by, a), e.sort != null && !i.includes(e.sort) && t.push(`${o}.sort must be ${i.map((e) => `"${e}"`).join(" or ")}, or null to keep the groups in the order they are first seen`), e.newPage != null && typeof e.newPage != "boolean" && t.push(`${o}.newPage must be true or false`), Ct(e.header, `${o}.header`, t), Ct(e.footer, `${o}.footer`, t), e.header == null && e.footer == null && t.push(`${o} has neither a header nor a footer to show its groups`);
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
function Ct(e, t, n) {
|
|
1060
|
+
if (e != null) {
|
|
1061
|
+
if (typeof e != "object" || Array.isArray(e)) {
|
|
1062
|
+
n.push(`${t} must be a band with items, or null`);
|
|
1063
|
+
return;
|
|
1064
|
+
}
|
|
1065
|
+
if (e.height != null && !(typeof e.height == "number" && e.height >= 0) && n.push(`${t}.height must be a number of pixels`), e.background != null && (typeof e.background != "string" || e.background === "") && n.push(`${t}.background must be a colour, or null`), !Array.isArray(e.items)) {
|
|
1066
|
+
n.push(`${t}.items must be an array`);
|
|
1067
|
+
return;
|
|
1068
|
+
}
|
|
1069
|
+
e.items.forEach((e, r) => {
|
|
1070
|
+
if (e?.type === "table") {
|
|
1071
|
+
n.push(`${t}.items[${r}] is a table; a group band cannot hold one`);
|
|
1072
|
+
return;
|
|
1073
|
+
}
|
|
1074
|
+
Tt(e, `${t}.items[${r}]`, n);
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function wt(e, t) {
|
|
1079
|
+
if (typeof e != "object" || !e) {
|
|
1080
|
+
t.push("layout.page must be an object with width, height and margin");
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
for (let n of ["width", "height"]) typeof e[n] == "number" && e[n] > 0 || t.push(`layout.page.${n} must be a positive number`);
|
|
1084
|
+
if (e.margin == null || typeof e.margin != "object") {
|
|
1085
|
+
t.push("layout.page.margin must be an object with top, right, bottom and left");
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
for (let n of [
|
|
1089
|
+
"top",
|
|
1090
|
+
"right",
|
|
1091
|
+
"bottom",
|
|
1092
|
+
"left"
|
|
1093
|
+
]) typeof e.margin[n] == "number" && e.margin[n] >= 0 || t.push(`layout.page.margin.${n} must be a number of pixels`);
|
|
1094
|
+
let n = e.height - (e.margin.top + e.margin.bottom);
|
|
1095
|
+
n <= 0 && t.push(`layout.page margins leave no printable height (${n}px)`);
|
|
1096
|
+
}
|
|
1097
|
+
function Tt(e, t, n) {
|
|
1098
|
+
if (typeof e != "object" || !e) {
|
|
1099
|
+
n.push(`${t} must be an object`);
|
|
1100
|
+
return;
|
|
1101
|
+
}
|
|
1102
|
+
if (!ht.includes(e.type)) {
|
|
1103
|
+
n.push(`${t}.type "${e.type}" is not one of: ${ht.join(", ")}`);
|
|
1104
|
+
return;
|
|
1105
|
+
}
|
|
1106
|
+
if ((typeof e.id != "string" || e.id === "") && n.push(`${t}.id must be a non-empty string`), e.type === "text") {
|
|
1107
|
+
typeof e.value != "string" && n.push(`${t}.value must be a string`), Dt(e.format, `${t}.format`, n, !0), Et(e.highlight, `${t}.highlight`, n, !1);
|
|
1108
|
+
return;
|
|
1109
|
+
}
|
|
1110
|
+
if (e.type === "line") {
|
|
1111
|
+
At(e, t, n);
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
if (e.type === "box") {
|
|
1115
|
+
Ot(e, t, n);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (e.type === "image") {
|
|
1119
|
+
kt(e, t, n);
|
|
1120
|
+
return;
|
|
1121
|
+
}
|
|
1122
|
+
if (typeof e.rowHeight == "number" && e.rowHeight > 0 || n.push(`${t}.rowHeight must be a positive number`), e.style?.borderStyle != null && !vt.includes(e.style.borderStyle) && n.push(`${t}.style.borderStyle "${e.style.borderStyle}" is not one of: ` + vt.join(", ")), e.style?.borderWidth != null && !(typeof e.style.borderWidth == "number" && e.style.borderWidth > 0) && n.push(`${t}.style.borderWidth must be a positive number of pixels`), !Array.isArray(e.columns) || e.columns.length === 0) {
|
|
1123
|
+
n.push(`${t}.columns must be a non-empty array`);
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
e.columns.forEach((e, r) => {
|
|
1127
|
+
if ((e == null || typeof e.field != "string" || e.field === "") && n.push(`${t}.columns[${r}].field must be a non-empty string`), Dt(e?.format, `${t}.columns[${r}].format`, n, !0), e?.expression != null && e.expression !== "") {
|
|
1128
|
+
let i = typeof e.expression == "string" ? ke(e.expression) : { error: "must be text" };
|
|
1129
|
+
i.error && n.push(`${t}.columns[${r}].expression ${i.error}`);
|
|
1130
|
+
}
|
|
1131
|
+
Et(e?.highlight, `${t}.columns[${r}].highlight`, n, !1);
|
|
1132
|
+
}), Et(e.rowHighlight, `${t}.rowHighlight`, n, !0);
|
|
1133
|
+
}
|
|
1134
|
+
function Et(e, t, n, r) {
|
|
1135
|
+
if (e != null) {
|
|
1136
|
+
if (!Array.isArray(e)) {
|
|
1137
|
+
n.push(`${t} must be a list of rules, or null`);
|
|
1138
|
+
return;
|
|
1139
|
+
}
|
|
1140
|
+
e.forEach((e, i) => {
|
|
1141
|
+
let a = `${t}[${i}]`, o = e?.when;
|
|
1142
|
+
if (typeof o != "object" || !o) {
|
|
1143
|
+
n.push(`${a}.when must say what to test`);
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1146
|
+
he.includes(o.op) || n.push(`${a}.when.op "${o.op}" is not one of: ${he.join(", ")}`), o.field != null && (typeof o.field != "string" || o.field === "") ? n.push(`${a}.when.field must be the name of a field`) : r && o.field == null && n.push(`${a}.when.field must name the field of the row to test`), o.op === "between" && (o.value == null || o.to == null) && n.push(`${a}.when needs both value and to for between`);
|
|
1147
|
+
let s = e.style;
|
|
1148
|
+
if (typeof s != "object" || !s || Array.isArray(s)) {
|
|
1149
|
+
n.push(`${a}.style must be an object`);
|
|
1150
|
+
return;
|
|
1151
|
+
}
|
|
1152
|
+
for (let e of Object.keys(s)) _e.includes(e) || n.push(`${a}.style.${e} is not one of: ${_e.join(", ")}`);
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
}
|
|
1156
|
+
function Dt(e, t, n, r) {
|
|
1157
|
+
if (e == null) return;
|
|
1158
|
+
if (typeof e != "object" || Array.isArray(e)) {
|
|
1159
|
+
n.push(`${t} must be an object, or null`);
|
|
1160
|
+
return;
|
|
1161
|
+
}
|
|
1162
|
+
let i = (r, i) => {
|
|
1163
|
+
e[r] != null && !i.includes(e[r]) && n.push(`${t}.${r} "${e[r]}" is not one of: ${i.join(", ")}`);
|
|
1164
|
+
};
|
|
1165
|
+
r ? i("type", b) : e.type != null && n.push(`${t}.type is an item's or a column's to say, not the report's`), i("grouping", x), i("negative", S), i("zero", C), i("symbolPosition", w), e.decimals != null && !(Number.isInteger(e.decimals) && e.decimals >= 0 && e.decimals <= 6) && n.push(`${t}.decimals must be a whole number from 0 to 6`);
|
|
1166
|
+
for (let r of ["symbol", "pattern"]) e[r] != null && typeof e[r] != "string" && n.push(`${t}.${r} must be text`);
|
|
1167
|
+
}
|
|
1168
|
+
function Ot(e, t, n) {
|
|
1169
|
+
let r = e.style;
|
|
1170
|
+
if (r != null) {
|
|
1171
|
+
if (typeof r != "object" || Array.isArray(r)) {
|
|
1172
|
+
n.push(`${t}.style must be an object`);
|
|
1173
|
+
return;
|
|
1174
|
+
}
|
|
1175
|
+
r.borderStyle != null && !vt.includes(r.borderStyle) && n.push(`${t}.style.borderStyle "${r.borderStyle}" is not one of: ` + vt.join(", "));
|
|
1176
|
+
for (let e of ["borderWidth", "radius"]) {
|
|
1177
|
+
let i = r[e], a = e === "radius" ? 0 : 1;
|
|
1178
|
+
i != null && !(typeof i == "number" && i >= a) && n.push(`${t}.style.${e} must be a number of pixels` + (a ? " greater than zero" : " of zero or more"));
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1181
|
+
}
|
|
1182
|
+
function kt(e, t, n) {
|
|
1183
|
+
e.src != null && typeof e.src != "string" && n.push(`${t}.src must be a string - a URL or a data: URI`), e.field != null && typeof e.field != "string" && n.push(`${t}.field must be a data path such as "company.logo"`), e.fit != null && !yt.includes(e.fit) && n.push(`${t}.fit "${e.fit}" is not one of: ${yt.join(", ")}`), e.alt != null && typeof e.alt != "string" && n.push(`${t}.alt must be a string`);
|
|
1184
|
+
}
|
|
1185
|
+
function At(e, t, n) {
|
|
1186
|
+
e.orientation != null && !gt.includes(e.orientation) && n.push(`${t}.orientation "${e.orientation}" is not one of: ` + gt.join(", "));
|
|
1187
|
+
let r = e.style;
|
|
1188
|
+
if (r != null) {
|
|
1189
|
+
if (typeof r != "object" || Array.isArray(r)) {
|
|
1190
|
+
n.push(`${t}.style must be an object`);
|
|
1191
|
+
return;
|
|
1192
|
+
}
|
|
1193
|
+
r.thickness != null && !(typeof r.thickness == "number" && r.thickness > 0) && n.push(`${t}.style.thickness must be a positive number of pixels`), r.lineStyle != null && !_t.includes(r.lineStyle) && n.push(`${t}.style.lineStyle "${r.lineStyle}" is not one of: ` + _t.join(", "));
|
|
1194
|
+
}
|
|
1195
|
+
}
|
|
1196
|
+
function jt(e, t) {
|
|
1197
|
+
let n = bt(e);
|
|
1198
|
+
if (n.length) throw new H(`${t}: the layout file is not usable`, n);
|
|
1199
|
+
}
|
|
1200
|
+
function Mt(e, t) {
|
|
1201
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw new H(`${t}: data must be an object keyed by dataset name`);
|
|
1202
|
+
}
|
|
1203
|
+
//#endregion
|
|
1204
|
+
//#region src/engine/resolve.js
|
|
1205
|
+
var Nt = /\{([^{}]+)\}/g, Pt = /^\w+\(.*\)$/, Ft = ["page", "totalPages"], It = ["groupHeader", "groupFooter"], Lt = Nt;
|
|
1206
|
+
function Rt(e) {
|
|
1207
|
+
return Pt.test(e) || Ft.includes(e) || e === "today";
|
|
1208
|
+
}
|
|
1209
|
+
function zt(e) {
|
|
1210
|
+
return It.includes(e);
|
|
1211
|
+
}
|
|
1212
|
+
function Bt(e) {
|
|
1213
|
+
let t = typeof e == "string" ? e.trim().match(/^{([^{}]+)}$/) : null;
|
|
1214
|
+
return t ? t[1].trim() : null;
|
|
1215
|
+
}
|
|
1216
|
+
function Vt(t) {
|
|
1217
|
+
let n = t.format, r = (e) => {
|
|
1218
|
+
let t = k(e?.format, n);
|
|
1219
|
+
t && (e.format = t);
|
|
1220
|
+
}, i = (e) => (Array.isArray(e?.items) ? e.items : []).filter((e) => e?.type === "text");
|
|
1221
|
+
for (let e of t.bands) i(e).forEach(r);
|
|
1222
|
+
for (let n of e(t)) {
|
|
1223
|
+
for (let e of Array.isArray(n.columns) ? n.columns : []) e && !e.format && /^\s*percentage\s*\(/.test(e.expression ?? "") && (e.format = { type: "percent" }), r(e);
|
|
1224
|
+
for (let e of o(n)) i(e?.header).forEach(r), i(e?.footer).forEach(r);
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
function Ht(e, t) {
|
|
1228
|
+
jt(e, "resolve"), Mt(t, "resolve");
|
|
1229
|
+
let n = structuredClone(e);
|
|
1230
|
+
Vt(n);
|
|
1231
|
+
for (let e of n.bands) {
|
|
1232
|
+
Ut(e, t, It.includes(e.type), n.format);
|
|
1233
|
+
for (let r of e.items) if (r.type === "table") for (let e of o(r)) for (let r of [e?.header, e?.footer]) Array.isArray(r?.items) && Ut(r, t, !0, n.format);
|
|
1234
|
+
}
|
|
1235
|
+
return n;
|
|
1236
|
+
}
|
|
1237
|
+
function Ut(e, t, n, r) {
|
|
1238
|
+
for (let i of e.items) i.type == "text" && (i.text = Gt(i, t, n, r)), i.type == "image" && (i.resolvedSrc = Wt(i, t));
|
|
1239
|
+
}
|
|
1240
|
+
function Wt(e, t) {
|
|
1241
|
+
let n = typeof e.field == "string" ? e.field.trim() : "";
|
|
1242
|
+
if (n) {
|
|
1243
|
+
let r = Jt(n, t);
|
|
1244
|
+
if (typeof r == "string" && r !== "") return r;
|
|
1245
|
+
e.src || console.warn(`Unresolved image field "${n}" on item "${e.id}".`);
|
|
1246
|
+
}
|
|
1247
|
+
return typeof e.src == "string" ? e.src : "";
|
|
1248
|
+
}
|
|
1249
|
+
function Gt(e, t, n, r) {
|
|
1250
|
+
let i = Bt(e.value);
|
|
1251
|
+
return e.value.replace(Nt, (a, o) => {
|
|
1252
|
+
let s = Kt(a, o.trim(), t, e, n, r);
|
|
1253
|
+
return i === o.trim() && s !== a && (e.raw = i === "today" ? /* @__PURE__ */ new Date() : Jt(i, t) ?? null), s;
|
|
1254
|
+
});
|
|
1255
|
+
}
|
|
1256
|
+
function Kt(e, t, n, r, i, a) {
|
|
1257
|
+
if (Pt.test(t) || Ft.includes(t)) return e;
|
|
1258
|
+
if (t == "today") return j(/* @__PURE__ */ new Date(), qt(r.format, a));
|
|
1259
|
+
let o = Jt(t, n);
|
|
1260
|
+
return o == null ? i ? e : (console.warn(`Unresolved placeholder "{${t}}" on item "${r.id}".`), "") : j(o, r.format);
|
|
1261
|
+
}
|
|
1262
|
+
function qt(e, t) {
|
|
1263
|
+
return e?.type === "date" || e?.type === "datetime" ? e : {
|
|
1264
|
+
type: "date",
|
|
1265
|
+
pattern: e?.pattern ?? t?.pattern ?? "yyyy-MM-dd"
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
function Jt(e, t) {
|
|
1269
|
+
return e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((e) => e !== "").reduce((e, t) => e?.[t], t);
|
|
1270
|
+
}
|
|
1271
|
+
//#endregion
|
|
1272
|
+
//#region src/engine/group.js
|
|
1273
|
+
var Yt = /\{([^{}]+)\}/g;
|
|
1274
|
+
function Xt(n, r) {
|
|
1275
|
+
if (n.groupBy != null && e(n).length === 0) throw new H(`group: layout.groupBy is "${n.groupBy}" but no band contains a table to group`);
|
|
1276
|
+
let i = g(n), a = i.bands, o = e(i), s = new Map(m(i).map((e) => [e.table, e])), c = $t(r), l = o.map((e) => {
|
|
1277
|
+
let n = Me(e, en(e, i, r));
|
|
1278
|
+
return c.set(t(e, i), n), {
|
|
1279
|
+
table: e,
|
|
1280
|
+
rows: n
|
|
1281
|
+
};
|
|
1282
|
+
});
|
|
1283
|
+
for (let { table: e, rows: n } of l) {
|
|
1284
|
+
let r = s.get(e);
|
|
1285
|
+
r ? Zt(e, n, r, t(e, i)) : e.row = n;
|
|
1286
|
+
}
|
|
1287
|
+
return nn(a, {
|
|
1288
|
+
rows: l[0]?.rows ?? [],
|
|
1289
|
+
table: l[0]?.table ?? null,
|
|
1290
|
+
named: c,
|
|
1291
|
+
data: r
|
|
1292
|
+
}), i;
|
|
1293
|
+
}
|
|
1294
|
+
function Zt(e, t, n, r) {
|
|
1295
|
+
let i = n.levels, a = [], o = t, s = (t, n, c) => {
|
|
1296
|
+
let l = i[n], u = [l.header, l.footer].filter(Boolean);
|
|
1297
|
+
for (let [d, f] of vn(gn(t, l.by), l.sort)) {
|
|
1298
|
+
let p = {
|
|
1299
|
+
by: l.by,
|
|
1300
|
+
key: d,
|
|
1301
|
+
aggregates: pn(u, f, r, {
|
|
1302
|
+
all: o,
|
|
1303
|
+
parent: t,
|
|
1304
|
+
table: e
|
|
1305
|
+
})
|
|
1306
|
+
}, m = [...c, p];
|
|
1307
|
+
if (n < i.length - 1) {
|
|
1308
|
+
s(f, n + 1, m);
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1311
|
+
a.push({
|
|
1312
|
+
key: d,
|
|
1313
|
+
path: m.map((e) => e.key),
|
|
1314
|
+
rows: f,
|
|
1315
|
+
aggregates: p.aggregates,
|
|
1316
|
+
levels: m
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
};
|
|
1320
|
+
s(t, 0, []), a.forEach((e, t) => {
|
|
1321
|
+
e.opens = Qt(a[t - 1], e), e.closes = Qt(a[t + 1], e);
|
|
1322
|
+
}), e.groups = a;
|
|
1323
|
+
}
|
|
1324
|
+
function Qt(e, t) {
|
|
1325
|
+
if (!e) return 0;
|
|
1326
|
+
let n = t.levels.findIndex((t, n) => e.levels[n] !== t);
|
|
1327
|
+
return n === -1 ? t.levels.length - 1 : n;
|
|
1328
|
+
}
|
|
1329
|
+
function $t(e) {
|
|
1330
|
+
let t = /* @__PURE__ */ new Map();
|
|
1331
|
+
for (let [n, r] of Object.entries(e ?? {})) Array.isArray(r) && t.set(n, r);
|
|
1332
|
+
return t;
|
|
1333
|
+
}
|
|
1334
|
+
function en(e, n, r) {
|
|
1335
|
+
let i = t(e, n), a = i == null ? void 0 : r[i];
|
|
1336
|
+
if (a === void 0) throw new H(`group: table "${e.id}" is bound to dataset "${i}", which is not present in the data`);
|
|
1337
|
+
if (!Array.isArray(a)) throw new H(`group: dataset "${i}" must be an array of rows, got ${typeof a}`);
|
|
1338
|
+
return a;
|
|
1339
|
+
}
|
|
1340
|
+
var tn = ["groupHeader", "groupFooter"];
|
|
1341
|
+
function nn(e, t) {
|
|
1342
|
+
for (let n of e) if (!tn.includes(n.type)) for (let e of n.items) {
|
|
1343
|
+
if (e.type != "text") continue;
|
|
1344
|
+
e.text = rn(e.text ?? e.value, t, e);
|
|
1345
|
+
let n = L(e.highlight, dn(e), t.data);
|
|
1346
|
+
n && (e.highlighted = n);
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
function rn(e, t, n) {
|
|
1350
|
+
let r = Bt(n.value);
|
|
1351
|
+
return e.replace(Yt, (e, i) => {
|
|
1352
|
+
let a = fn(i.trim());
|
|
1353
|
+
if (!a) return e;
|
|
1354
|
+
let o = a.key === on, s;
|
|
1355
|
+
if (o) s = sn(a.field, (e, n, r) => {
|
|
1356
|
+
let i = an(r, t);
|
|
1357
|
+
return yn({
|
|
1358
|
+
key: n,
|
|
1359
|
+
field: i.field
|
|
1360
|
+
}, i.rows);
|
|
1361
|
+
}, () => un(t.table, t.rows));
|
|
1362
|
+
else {
|
|
1363
|
+
let { rows: e, field: n } = an(a.field, t);
|
|
1364
|
+
s = yn({
|
|
1365
|
+
key: a.key,
|
|
1366
|
+
field: n
|
|
1367
|
+
}, e);
|
|
1368
|
+
}
|
|
1369
|
+
return r === i.trim() && (n.raw = s, o && (n.rawFormat = A(n.format))), s == null ? "" : o ? j(s, A(n.format)) : j(s, a.key === "count" ? null : n.format);
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1372
|
+
function an(e, t) {
|
|
1373
|
+
if (t.named.has(e)) return {
|
|
1374
|
+
rows: t.named.get(e),
|
|
1375
|
+
field: ""
|
|
1376
|
+
};
|
|
1377
|
+
let n = e.indexOf(".");
|
|
1378
|
+
if (n > 0) {
|
|
1379
|
+
let r = e.slice(0, n);
|
|
1380
|
+
if (t.named.has(r)) return {
|
|
1381
|
+
rows: t.named.get(r),
|
|
1382
|
+
field: e.slice(n + 1)
|
|
1383
|
+
};
|
|
1384
|
+
}
|
|
1385
|
+
return {
|
|
1386
|
+
rows: t.rows,
|
|
1387
|
+
field: e
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
var on = "percentage";
|
|
1391
|
+
function sn(e, t, n) {
|
|
1392
|
+
let [r, i] = ln(e), a = cn(r);
|
|
1393
|
+
if (!a || a.kind === "parent") return null;
|
|
1394
|
+
let o = a.kind === "aggregate" ? {
|
|
1395
|
+
fn: a.fn,
|
|
1396
|
+
field: a.field
|
|
1397
|
+
} : {
|
|
1398
|
+
fn: "sum",
|
|
1399
|
+
field: n()
|
|
1400
|
+
}, s = a.kind === "number" ? a.value : t("part", a.fn, a.field), c = i === void 0 ? { kind: "all" } : cn(i);
|
|
1401
|
+
if (!c) return null;
|
|
1402
|
+
let l = null;
|
|
1403
|
+
return c.kind === "number" ? l = c.value : c.kind === "aggregate" ? l = t("all", c.fn, c.field) : (o.fn === "count" || o.field) && (l = t(c.kind === "parent" ? "parent" : "all", o.fn, o.field)), s == null || l == null || l === 0 ? null : bn(s / l);
|
|
1404
|
+
}
|
|
1405
|
+
function cn(e) {
|
|
1406
|
+
let t = (e ?? "").trim();
|
|
1407
|
+
if (t === "") return null;
|
|
1408
|
+
if (t === "parent") return { kind: "parent" };
|
|
1409
|
+
let n = M(t);
|
|
1410
|
+
if (n !== null) return {
|
|
1411
|
+
kind: "number",
|
|
1412
|
+
value: n
|
|
1413
|
+
};
|
|
1414
|
+
let r = fn(t);
|
|
1415
|
+
return !r || r.key === "percentage" ? null : {
|
|
1416
|
+
kind: "aggregate",
|
|
1417
|
+
fn: r.key,
|
|
1418
|
+
field: r.field
|
|
1419
|
+
};
|
|
1420
|
+
}
|
|
1421
|
+
function ln(e) {
|
|
1422
|
+
let t = 0;
|
|
1423
|
+
for (let n = 0; n < e.length; n++) if (e[n] === "(") t++;
|
|
1424
|
+
else if (e[n] === ")") t--;
|
|
1425
|
+
else if (e[n] === "," && t === 0) return [e.slice(0, n), e.slice(n + 1)];
|
|
1426
|
+
return [e, void 0];
|
|
1427
|
+
}
|
|
1428
|
+
function un(e, t) {
|
|
1429
|
+
let n = Array.isArray(e?.columns) ? e.columns : [], r = (e) => n.find((t) => t?.format?.type === e)?.field, i = [...n].reverse().find((e) => (t ?? []).some((t) => M(t?.[e?.field]) !== null));
|
|
1430
|
+
return r("currency") ?? r("number") ?? i?.field ?? null;
|
|
1431
|
+
}
|
|
1432
|
+
function dn(e) {
|
|
1433
|
+
return e.rawFormat?.type === "percent" && typeof e.raw == "number" ? bn(e.raw * 100) : e.raw;
|
|
1434
|
+
}
|
|
1435
|
+
function fn(e) {
|
|
1436
|
+
let t = e.match(/^(\w+)\((.*?)\)$/);
|
|
1437
|
+
return t ? {
|
|
1438
|
+
key: t[1],
|
|
1439
|
+
field: t[2].trim()
|
|
1440
|
+
} : null;
|
|
1441
|
+
}
|
|
1442
|
+
function pn(e, t, n, r = {}) {
|
|
1443
|
+
let i = {}, a = {
|
|
1444
|
+
part: t,
|
|
1445
|
+
all: r.all ?? t,
|
|
1446
|
+
parent: r.parent ?? r.all ?? t
|
|
1447
|
+
}, o = (e, t, r) => yn({
|
|
1448
|
+
key: t,
|
|
1449
|
+
field: mn(r, n)
|
|
1450
|
+
}, a[e]);
|
|
1451
|
+
for (let s of e) for (let e of s.items ?? []) if (e.type == "text") for (let s of hn(e.value)) {
|
|
1452
|
+
let e = mn(s.field, n);
|
|
1453
|
+
i[s.field] ??= {
|
|
1454
|
+
count: null,
|
|
1455
|
+
sum: null,
|
|
1456
|
+
avg: null,
|
|
1457
|
+
min: null,
|
|
1458
|
+
max: null
|
|
1459
|
+
}, i[s.field][s.key] = s.key === "percentage" ? sn(s.field, o, () => un(r.table, a.all)) : yn({
|
|
1460
|
+
key: s.key,
|
|
1461
|
+
field: e
|
|
1462
|
+
}, t);
|
|
1463
|
+
}
|
|
1464
|
+
return i;
|
|
1465
|
+
}
|
|
1466
|
+
function mn(e, t) {
|
|
1467
|
+
return t == null ? e : e === t ? "" : e.startsWith(`${t}.`) ? e.slice(t.length + 1) : e;
|
|
1468
|
+
}
|
|
1469
|
+
function hn(e) {
|
|
1470
|
+
let t = [];
|
|
1471
|
+
for (let [, n] of e.matchAll(Yt)) {
|
|
1472
|
+
let e = fn(n.trim());
|
|
1473
|
+
e && t.push(e);
|
|
1474
|
+
}
|
|
1475
|
+
return t;
|
|
1476
|
+
}
|
|
1477
|
+
function gn(e, t) {
|
|
1478
|
+
let n = /* @__PURE__ */ new Map();
|
|
1479
|
+
for (let r of e) {
|
|
1480
|
+
let e = String(r?.[t]);
|
|
1481
|
+
n.has(e) || n.set(e, []), n.get(e).push(r);
|
|
1482
|
+
}
|
|
1483
|
+
return n;
|
|
1484
|
+
}
|
|
1485
|
+
var _n = new Intl.Collator(void 0, {
|
|
1486
|
+
numeric: !0,
|
|
1487
|
+
sensitivity: "base"
|
|
1488
|
+
});
|
|
1489
|
+
function vn(e, t) {
|
|
1490
|
+
if (t !== "asc" && t !== "desc") return e;
|
|
1491
|
+
let n = t === "desc" ? -1 : 1, r = (e) => e.trim() !== "" && Number.isFinite(Number(e));
|
|
1492
|
+
return [...e].sort(([e], [t]) => n * (r(e) && r(t) ? Number(e) - Number(t) : _n.compare(e, t)));
|
|
1493
|
+
}
|
|
1494
|
+
function yn(e, t) {
|
|
1495
|
+
if (e.key === "count") return t.length;
|
|
1496
|
+
let n = t.map((t) => t?.[e.field]).filter((e) => e != null && e !== "").map(Number).filter((e) => Number.isFinite(e));
|
|
1497
|
+
switch (e.key) {
|
|
1498
|
+
case "sum": return n.length ? bn(n.reduce((e, t) => e + t, 0)) : null;
|
|
1499
|
+
case "avg": return n.length ? bn(n.reduce((e, t) => e + t, 0) / n.length) : null;
|
|
1500
|
+
case "max": return n.length ? Math.max(...n) : null;
|
|
1501
|
+
case "min": return n.length ? Math.min(...n) : null;
|
|
1502
|
+
default: return console.warn(`Unknown aggregate "${e.key}()"; it has no value.`), null;
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
function bn(e) {
|
|
1506
|
+
return Number(e.toPrecision(12));
|
|
1507
|
+
}
|
|
1508
|
+
//#endregion
|
|
1509
|
+
//#region src/engine/regions.js
|
|
1510
|
+
var xn = {
|
|
1511
|
+
pageHeader: "10%",
|
|
1512
|
+
reportHeader: "10%",
|
|
1513
|
+
reportFooter: "10%",
|
|
1514
|
+
pageFooter: "10%"
|
|
1515
|
+
}, Sn = ["pageHeader", "reportHeader"], Cn = ["reportFooter", "pageFooter"];
|
|
1516
|
+
function wn(e, t, n) {
|
|
1517
|
+
let r = Tn(e, t);
|
|
1518
|
+
return r === null ? Tn(n, t) ?? 0 : r;
|
|
1519
|
+
}
|
|
1520
|
+
function Tn(e, t) {
|
|
1521
|
+
if (typeof e == "number" && Number.isFinite(e) && e >= 0) return e;
|
|
1522
|
+
if (typeof e == "string") {
|
|
1523
|
+
let n = e.trim().match(/^(-?[\d.]+)\s*%$/);
|
|
1524
|
+
if (n) {
|
|
1525
|
+
let e = Number(n[1]);
|
|
1526
|
+
return Number.isFinite(e) && e >= 0 ? e / 100 * t : null;
|
|
1527
|
+
}
|
|
1528
|
+
let r = Number(e.trim().replace(/px$/i, ""));
|
|
1529
|
+
if (Number.isFinite(r) && r >= 0) return r;
|
|
1530
|
+
}
|
|
1531
|
+
return null;
|
|
1532
|
+
}
|
|
1533
|
+
function En(e, t) {
|
|
1534
|
+
if (!e) return 0;
|
|
1535
|
+
let n = wn(e.height, t, xn[e.type]), r = e.measuredHeight ?? 0;
|
|
1536
|
+
return r > n ? (console.warn(`Band "${e.type}" needs ${Math.ceil(r)}px but its zone is ${Math.round(n)}px; the zone has been grown to fit.`), r) : n;
|
|
1537
|
+
}
|
|
1538
|
+
function Dn({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
|
|
1539
|
+
let i = {}, a = (e) => e === "reportHeader" ? n : e !== "reportFooter" || r, o = 0;
|
|
1540
|
+
for (let n of Sn) {
|
|
1541
|
+
let r = e[n];
|
|
1542
|
+
if (!r || !a(n)) continue;
|
|
1543
|
+
let s = En(r, t);
|
|
1544
|
+
i[n] = {
|
|
1545
|
+
top: o,
|
|
1546
|
+
height: s
|
|
1547
|
+
}, o += s;
|
|
1548
|
+
}
|
|
1549
|
+
let s = o, c = t;
|
|
1550
|
+
for (let n of [...Cn].reverse()) {
|
|
1551
|
+
let r = e[n];
|
|
1552
|
+
if (!r || !a(n)) continue;
|
|
1553
|
+
let o = En(r, t);
|
|
1554
|
+
c -= o, i[n] = {
|
|
1555
|
+
top: c,
|
|
1556
|
+
height: o
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
return i.detail = {
|
|
1560
|
+
top: s,
|
|
1561
|
+
height: Math.max(c - s, 0)
|
|
1562
|
+
}, i;
|
|
1563
|
+
}
|
|
1564
|
+
//#endregion
|
|
1565
|
+
//#region src/engine/paginate.js
|
|
1566
|
+
var On = /\{([^{}]+)\}/g, kn = ["page", "totalPages"];
|
|
1567
|
+
function An(e) {
|
|
1568
|
+
let t = structuredClone(e), n = {
|
|
1569
|
+
page: t.page,
|
|
1570
|
+
bands: t.bands,
|
|
1571
|
+
assignedBands: {
|
|
1572
|
+
reportHeader: t.bands.find((e) => e.type === "reportHeader"),
|
|
1573
|
+
reportFooter: t.bands.find((e) => e.type === "reportFooter"),
|
|
1574
|
+
pageHeader: t.bands.find((e) => e.type === "pageHeader"),
|
|
1575
|
+
pageFooter: t.bands.find((e) => e.type === "pageFooter"),
|
|
1576
|
+
detail: t.bands.find((e) => e.type === "detail")
|
|
1577
|
+
}
|
|
1578
|
+
};
|
|
1579
|
+
return n.availableHeight = Hn(t.page), n.regionsFor = (e, t) => Dn({
|
|
1580
|
+
bands: n.assignedBands,
|
|
1581
|
+
contentHeight: n.availableHeight,
|
|
1582
|
+
isFirstPage: e === 1,
|
|
1583
|
+
isLastPage: t
|
|
1584
|
+
}), t.pages = Un(Pn(t.bands.filter((e) => ![
|
|
1585
|
+
"reportHeader",
|
|
1586
|
+
"reportFooter",
|
|
1587
|
+
"pageHeader",
|
|
1588
|
+
"pageFooter",
|
|
1589
|
+
"groupHeader",
|
|
1590
|
+
"groupFooter"
|
|
1591
|
+
].includes(e.type)), n)), t;
|
|
1592
|
+
}
|
|
1593
|
+
function jn(e, t, n, r = Infinity) {
|
|
1594
|
+
let i = 0, a = 0;
|
|
1595
|
+
for (; t + a < e.length && a < r;) {
|
|
1596
|
+
let r = i + e[t + a];
|
|
1597
|
+
if (r > n) break;
|
|
1598
|
+
i = r, a++;
|
|
1599
|
+
}
|
|
1600
|
+
return a;
|
|
1601
|
+
}
|
|
1602
|
+
function Mn(e, t, n) {
|
|
1603
|
+
return V(e.slice(t, t + n));
|
|
1604
|
+
}
|
|
1605
|
+
function Nn(e, t, n) {
|
|
1606
|
+
return Array.isArray(n) && n.length === (t ?? []).length ? n : (t ?? []).map(() => e.rowHeight ?? 0);
|
|
1607
|
+
}
|
|
1608
|
+
function Pn(e, t) {
|
|
1609
|
+
let n = [], r = Vn(1, t);
|
|
1610
|
+
n.push(r);
|
|
1611
|
+
let { assignedBands: i, availableHeight: a } = t, { reportFooter: s, reportHeader: c, pageHeader: d, pageFooter: f } = i, p = t.regionsFor(2, !1).detail.height;
|
|
1612
|
+
c && r.regions.detail.height <= 0 && console.warn("The header zones leave no room for detail on page 1. Reduce the reportHeader or pageHeader height.");
|
|
1613
|
+
let m = 0, h = 0, g = [], _ = () => r.regions.detail.height, v = (e, i, a) => (e.items.length > 0 && r.bands.push(e), r = Vn(n.length + 1, t), n.push(r), m = 0, h = a, g = [], {
|
|
1614
|
+
...i,
|
|
1615
|
+
items: []
|
|
1616
|
+
}), y = (e, t) => {
|
|
1617
|
+
e.items.push(t), m = Math.max(m, (t.y ?? 0) + (t.measuredHeight ?? 0)), e.measuredHeight = m, r.usedHeight = a - _() + m;
|
|
1618
|
+
}, b = (e) => {
|
|
1619
|
+
let t = -Infinity, n = -Infinity;
|
|
1620
|
+
for (let r of g) r.designBottom > e || (t = Math.max(t, r.designBottom), n = Math.max(n, r.actualBottom));
|
|
1621
|
+
return t === -Infinity ? 0 : n - t;
|
|
1622
|
+
}, x = (e) => {
|
|
1623
|
+
let t = e - h;
|
|
1624
|
+
return t + b(t);
|
|
1625
|
+
};
|
|
1626
|
+
for (let t of e) {
|
|
1627
|
+
let e = {
|
|
1628
|
+
...t,
|
|
1629
|
+
items: []
|
|
1630
|
+
};
|
|
1631
|
+
h = 0, g = [];
|
|
1632
|
+
let n = [...t.items].sort((e, t) => (e.y ?? 0) - (t.y ?? 0));
|
|
1633
|
+
for (let r of n) {
|
|
1634
|
+
let n = r.y ?? 0, i = x(n) + r.measuredHeight;
|
|
1635
|
+
if (i > _() && r.type != "table") r.measuredHeight > p ? console.warn(`Item "${r.id}" is ${Math.ceil(r.measuredHeight)}px tall, past the ${p}px detail zone of an empty page; it will overflow.`) : e = v(e, t, n), y(e, {
|
|
1636
|
+
...structuredClone(r),
|
|
1637
|
+
y: x(n)
|
|
1638
|
+
});
|
|
1639
|
+
else if (r.type == "table" && (i > _() || In(r))) {
|
|
1640
|
+
let i = x(n);
|
|
1641
|
+
if (r.groups) {
|
|
1642
|
+
let a = r.headerMeasured ?? rt(r), s = o(r), c = (e, t, n) => {
|
|
1643
|
+
let i = l(r, e, t, n);
|
|
1644
|
+
return {
|
|
1645
|
+
frame: i,
|
|
1646
|
+
above: (i.columnHeader ? a : 0) + ft(i.headers),
|
|
1647
|
+
below: ft(i.footers)
|
|
1648
|
+
};
|
|
1649
|
+
}, d = a + Math.max(r.rowHeight ?? 0, ...(r.groups ?? []).flatMap((e) => Nn(r, e.rows, e.rowHeights))) + V(s.map((e) => e?.header?.measuredHeight ?? 0)) + V(s.map((e) => e?.footer?.measuredHeight ?? 0));
|
|
1650
|
+
d <= p || console.warn(`Table "${r.id}": table header + group headers + one row + group footers (${d}px) exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`);
|
|
1651
|
+
let f = (e, t, n, r, i, a) => {
|
|
1652
|
+
let o = n - i;
|
|
1653
|
+
return r <= jn(e, t, o - a, r) ? r : Math.min(jn(e, t, o, r), r - 1);
|
|
1654
|
+
}, m = [], h = 0;
|
|
1655
|
+
for (let [a, o] of r.groups.entries()) {
|
|
1656
|
+
if (u(r, o, a) && m.length > 0) {
|
|
1657
|
+
let a = structuredClone(r);
|
|
1658
|
+
a.groups = m, a.y = i, a.measuredHeight = h, y(e, a), e = v(e, t, n), m = [], h = 0, i = 0;
|
|
1659
|
+
}
|
|
1660
|
+
let s = 0, l = o.rows.length, d = Nn(r, o.rows, o.rowHeights);
|
|
1661
|
+
for (; s < l;) {
|
|
1662
|
+
let a = _() - i - h, u = m.length === 0, g = u && e.items.length === 0 && i === 0 && _() >= p, { above: b } = c(o, u, !1), { below: x } = c(o, u, !0), S = f(d, s, a, l - s, b, x);
|
|
1663
|
+
if (S < 1 && g && (S = 1), S < 1) {
|
|
1664
|
+
if (m.length > 0) {
|
|
1665
|
+
let t = structuredClone(r);
|
|
1666
|
+
t.groups = m, t.y = i, t.measuredHeight = h, y(e, t);
|
|
1667
|
+
}
|
|
1668
|
+
e = v(e, t, n), m = [], h = 0, i = 0;
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
let C = o.rows.slice(s, s + S), w = d.slice(s, s + S);
|
|
1672
|
+
s += C.length;
|
|
1673
|
+
let T = s < l, { frame: E, above: D, below: O } = c(o, u, !T);
|
|
1674
|
+
h += V(w) + D + O, m.push(Rn(o, E, C, w, !T));
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
if (m.length > 0) {
|
|
1678
|
+
let t = structuredClone(r);
|
|
1679
|
+
t.groups = m, t.y = i, t.measuredHeight = h, y(e, t), m = [];
|
|
1680
|
+
}
|
|
1681
|
+
} else {
|
|
1682
|
+
let a = r.row.length, o = 0, s = r.headerMeasured ?? rt(r), c = Nn(r, r.row, r.rowHeights), l = Math.max(r.rowHeight ?? 0, ...c);
|
|
1683
|
+
for (p - s >= l || console.warn(`Table "${r.id}": its tallest row is ${Math.ceil(l)}px, which with the ${s}px header exceeds the ${p}px printable page. Falling back to one row per page; rows will overflow their page.`); o < a;) {
|
|
1684
|
+
let l = _() - i, u = jn(c, o, l - s, a - o), d = e.items.length === 0 && i === 0 && _() >= p;
|
|
1685
|
+
if (u < 1 && d && (u = 1), u < 1) {
|
|
1686
|
+
e = v(e, t, n), i = 0;
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
u = Math.min(u, a - o);
|
|
1690
|
+
let f = structuredClone(r), m = r.row.slice(o, o + u), h = Mn(c, o, u) + s;
|
|
1691
|
+
f.row = m, f.rowHeights = c.slice(o, o + u), f.y = i, f.measuredHeight = h, y(e, f), o += m.length, o < a && (e = v(e, t, n), i = 0);
|
|
1692
|
+
}
|
|
1693
|
+
}
|
|
1694
|
+
} else {
|
|
1695
|
+
let t = r.type === "table" && r.groups ? {
|
|
1696
|
+
...r,
|
|
1697
|
+
groups: Ln(r)
|
|
1698
|
+
} : r;
|
|
1699
|
+
y(e, {
|
|
1700
|
+
...structuredClone(t),
|
|
1701
|
+
y: x(n)
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
let a = [...e.items].reverse().find((e) => e.id === r.id);
|
|
1705
|
+
a && g.push({
|
|
1706
|
+
designBottom: n - h + it(r),
|
|
1707
|
+
actualBottom: (a.y ?? 0) + (a.measuredHeight ?? 0)
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
e.items.length > 0 && (r.bands.push(e), e = {
|
|
1711
|
+
...t,
|
|
1712
|
+
items: []
|
|
1713
|
+
});
|
|
1714
|
+
}
|
|
1715
|
+
if (s) {
|
|
1716
|
+
let e = En(s, a);
|
|
1717
|
+
r.usedHeight + e > a && (r = Vn(n.length + 1, t), n.push(r)), r.bands.push(structuredClone(s)), r.usedHeight += e;
|
|
1718
|
+
}
|
|
1719
|
+
let S = n[n.length - 1];
|
|
1720
|
+
return S.regions = t.regionsFor(S.pageNO, !!s), Fn(n), n;
|
|
1721
|
+
}
|
|
1722
|
+
function Fn(e) {
|
|
1723
|
+
for (let t of e) for (let e of t.bands) {
|
|
1724
|
+
let n = t.regions[e.type] ?? t.regions.detail;
|
|
1725
|
+
e.top = n.top, e.zoneHeight = n.height;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
function In(e) {
|
|
1729
|
+
return Array.isArray(e.groups) && e.groups.some((t, n) => u(e, t, n));
|
|
1730
|
+
}
|
|
1731
|
+
function Ln(e) {
|
|
1732
|
+
return e.groups.map((t, n) => Rn(t, l(e, t, n === 0, !0), t.rows, t.rowHeights, !0));
|
|
1733
|
+
}
|
|
1734
|
+
function Rn(e, t, n, r, i) {
|
|
1735
|
+
let a = (e.levels?.length ?? 1) - 1, o = ({ level: t, band: r }) => zn(r, e.levels?.[t] ?? e, n[0], t), s = t.headers.map(o), c = t.footers.map(o);
|
|
1736
|
+
return {
|
|
1737
|
+
key: e.key,
|
|
1738
|
+
path: e.path ?? [e.key],
|
|
1739
|
+
rows: n,
|
|
1740
|
+
rowHeights: r,
|
|
1741
|
+
aggregates: e.aggregates,
|
|
1742
|
+
showHeader: t.columnHeader,
|
|
1743
|
+
showFooter: i,
|
|
1744
|
+
headerBands: s,
|
|
1745
|
+
footerBands: c,
|
|
1746
|
+
headerBand: s.find((e) => e.level === a) ?? null,
|
|
1747
|
+
footerBand: c.find((e) => e.level === a) ?? null
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1750
|
+
function zn(e, t, n, r = 0) {
|
|
1751
|
+
if (!e) return null;
|
|
1752
|
+
let i = structuredClone(e);
|
|
1753
|
+
i.level = r;
|
|
1754
|
+
for (let e of i.items) {
|
|
1755
|
+
if (e.type !== "text") continue;
|
|
1756
|
+
let r = Bt(e.value);
|
|
1757
|
+
e.text = (e.text ?? e.value).replace(On, (i, a) => {
|
|
1758
|
+
let o = Bn(i, a.trim(), t, n);
|
|
1759
|
+
return r === a.trim() && o.value !== void 0 && (e.raw = o.value, o.share && (e.rawFormat = A(e.format))), o.value === void 0 ? o.text : o.value == null ? "" : o.share ? j(o.value, A(e.format)) : j(o.value, o.count ? null : e.format);
|
|
1760
|
+
});
|
|
1761
|
+
let i = L(e.highlight, dn(e), n);
|
|
1762
|
+
i && (e.highlighted = i);
|
|
1763
|
+
}
|
|
1764
|
+
return i;
|
|
1765
|
+
}
|
|
1766
|
+
function Bn(e, t, n, r) {
|
|
1767
|
+
if (kn.includes(t)) return { text: e };
|
|
1768
|
+
let i = t.match(/^(\w+)\((.*?)\)$/);
|
|
1769
|
+
if (i) {
|
|
1770
|
+
let [, e, t] = i;
|
|
1771
|
+
return {
|
|
1772
|
+
value: n.aggregates?.[t]?.[e.trim()] ?? null,
|
|
1773
|
+
count: e.trim() === "count",
|
|
1774
|
+
share: e.trim() === on
|
|
1775
|
+
};
|
|
1776
|
+
}
|
|
1777
|
+
return { value: r?.[t] ?? null };
|
|
1778
|
+
}
|
|
1779
|
+
function Vn(e, t) {
|
|
1780
|
+
let { pageHeader: n, pageFooter: r, reportHeader: i } = t.assignedBands, a = t.regionsFor(e, !1), o = [];
|
|
1781
|
+
return n && o.push(structuredClone(n)), r && o.push(structuredClone(r)), i && e === 1 && o.push(structuredClone(i)), {
|
|
1782
|
+
pageNO: e,
|
|
1783
|
+
bands: o,
|
|
1784
|
+
regions: a,
|
|
1785
|
+
usedHeight: t.availableHeight - a.detail.height
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
function Hn(e) {
|
|
1789
|
+
return e.height - (e.margin.top + e.margin.bottom);
|
|
1790
|
+
}
|
|
1791
|
+
function Un(e) {
|
|
1792
|
+
for (let t of e) for (let n of t.bands) Wn(n, t.pageNO, e.length);
|
|
1793
|
+
return e;
|
|
1794
|
+
}
|
|
1795
|
+
function Wn(e, t, n) {
|
|
1796
|
+
for (let r of e?.items ?? []) {
|
|
1797
|
+
if (r.type === "text") {
|
|
1798
|
+
let e = r.text ?? r.value ?? "";
|
|
1799
|
+
if (!e.includes("{")) continue;
|
|
1800
|
+
r.text = e.replace(On, (e, r) => {
|
|
1801
|
+
switch (r.trim()) {
|
|
1802
|
+
case "page": return t;
|
|
1803
|
+
case "totalPages": return n;
|
|
1804
|
+
default: return e;
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
continue;
|
|
1808
|
+
}
|
|
1809
|
+
if (r.type === "table" && r.groups) for (let e of r.groups) {
|
|
1810
|
+
let { headers: r, footers: i } = d(e);
|
|
1811
|
+
for (let e of [...r, ...i]) Wn(e, t, n);
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
//#endregion
|
|
1816
|
+
//#region src/engine/search.js
|
|
1817
|
+
function Gn(e, t, { caseSensitive: n = !1 } = {}) {
|
|
1818
|
+
let r = String(t ?? "");
|
|
1819
|
+
if (r === "") return [];
|
|
1820
|
+
let i = [];
|
|
1821
|
+
for (let t of e ?? []) for (let e of t.bands ?? []) qn(e, t.pageNO, e.type, r, n, i);
|
|
1822
|
+
return i;
|
|
1823
|
+
}
|
|
1824
|
+
function Kn(e, t, n) {
|
|
1825
|
+
return [...new Set(Gn(e, t, n).map((e) => e.pageNO))];
|
|
1826
|
+
}
|
|
1827
|
+
function qn(e, t, n, r, i, a) {
|
|
1828
|
+
for (let o of e?.items ?? []) {
|
|
1829
|
+
if (o.type === "text") {
|
|
1830
|
+
Xn(a, o.text, {
|
|
1831
|
+
pageNO: t,
|
|
1832
|
+
bandType: n,
|
|
1833
|
+
itemId: o.id,
|
|
1834
|
+
field: null
|
|
1835
|
+
}, r, i);
|
|
1836
|
+
continue;
|
|
1837
|
+
}
|
|
1838
|
+
o.type === "table" && Jn(o, t, n, r, i, a);
|
|
1839
|
+
}
|
|
1840
|
+
}
|
|
1841
|
+
function Jn(e, t, n, r, i, a) {
|
|
1842
|
+
let o = e.columns ?? [];
|
|
1843
|
+
if (e.showHeader) for (let s of o) Xn(a, s.label, {
|
|
1844
|
+
pageNO: t,
|
|
1845
|
+
bandType: n,
|
|
1846
|
+
itemId: e.id,
|
|
1847
|
+
field: s.field
|
|
1848
|
+
}, r, i);
|
|
1849
|
+
if (e.row) {
|
|
1850
|
+
Yn(e.row, o, e.id, t, n, r, i, a);
|
|
1851
|
+
return;
|
|
1852
|
+
}
|
|
1853
|
+
for (let s of e.groups ?? []) {
|
|
1854
|
+
let { headers: c, footers: l } = d(s);
|
|
1855
|
+
for (let e of c) qn(e, t, "groupHeader", r, i, a);
|
|
1856
|
+
Yn(s.rows, o, e.id, t, n, r, i, a);
|
|
1857
|
+
for (let e of l) qn(e, t, "groupFooter", r, i, a);
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
function Yn(e, t, n, r, i, a, o, s) {
|
|
1861
|
+
for (let c of e ?? []) for (let e of t) Xn(s, j(c?.[e.field], e.format), {
|
|
1862
|
+
pageNO: r,
|
|
1863
|
+
bandType: i,
|
|
1864
|
+
itemId: n,
|
|
1865
|
+
field: e.field
|
|
1866
|
+
}, a, o);
|
|
1867
|
+
}
|
|
1868
|
+
function Xn(e, t, n, r, i) {
|
|
1869
|
+
if (t == null) return;
|
|
1870
|
+
let a = String(t), o = i ? a : a.toLowerCase(), s = i ? r : r.toLowerCase(), c = 0;
|
|
1871
|
+
for (; c <= o.length - s.length;) {
|
|
1872
|
+
let t = o.indexOf(s, c);
|
|
1873
|
+
if (t === -1) break;
|
|
1874
|
+
e.push({
|
|
1875
|
+
...n,
|
|
1876
|
+
text: a,
|
|
1877
|
+
start: t,
|
|
1878
|
+
end: t + s.length
|
|
1879
|
+
}), c = t + s.length;
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
//#endregion
|
|
1883
|
+
//#region src/engine/rows.js
|
|
1884
|
+
var Zn = [
|
|
1885
|
+
"image",
|
|
1886
|
+
"line",
|
|
1887
|
+
"box"
|
|
1888
|
+
];
|
|
1889
|
+
function Qn(e) {
|
|
1890
|
+
return $n(e).rows.filter((e) => !e.spacer);
|
|
1891
|
+
}
|
|
1892
|
+
function $n(e) {
|
|
1893
|
+
let t = [], n = [];
|
|
1894
|
+
return (e ?? []).forEach((e, r) => {
|
|
1895
|
+
for (let i of cr(e?.bands)) lr(i, t, {
|
|
1896
|
+
page: r,
|
|
1897
|
+
origin: Number(i?.top) || 0,
|
|
1898
|
+
graphics: n
|
|
1899
|
+
});
|
|
1900
|
+
}), {
|
|
1901
|
+
rows: t,
|
|
1902
|
+
graphics: n
|
|
1903
|
+
};
|
|
1904
|
+
}
|
|
1905
|
+
function er(e, t = null) {
|
|
1906
|
+
let n = null, r = t, i = null, a = [];
|
|
1907
|
+
for (let t of e ?? []) for (let e of t.bands ?? []) for (let t of e.items ?? []) if (t.type === "table" && !(r !== null && t.id !== r)) {
|
|
1908
|
+
if (n === null && (r = t.id, n = t.columns ?? [], i = t), t.row) {
|
|
1909
|
+
t.row.forEach((e, n) => {
|
|
1910
|
+
a.push({
|
|
1911
|
+
group: null,
|
|
1912
|
+
row: e,
|
|
1913
|
+
height: ar(t, t.rowHeights, n)
|
|
1914
|
+
});
|
|
1915
|
+
});
|
|
1916
|
+
continue;
|
|
1917
|
+
}
|
|
1918
|
+
for (let e of t.groups ?? []) {
|
|
1919
|
+
let n = Array.isArray(e.path) ? e.path : [e.key];
|
|
1920
|
+
e.rows.forEach((r, i) => {
|
|
1921
|
+
a.push({
|
|
1922
|
+
group: e.key,
|
|
1923
|
+
groups: n,
|
|
1924
|
+
row: r,
|
|
1925
|
+
height: ar(t, e.rowHeights, i)
|
|
1926
|
+
});
|
|
1927
|
+
});
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1930
|
+
return n === null ? null : {
|
|
1931
|
+
id: r,
|
|
1932
|
+
columns: n,
|
|
1933
|
+
table: rr(i),
|
|
1934
|
+
headerHeight: ir(i),
|
|
1935
|
+
rows: a,
|
|
1936
|
+
groupBy: o(i).map((e) => e?.by ?? null)
|
|
1937
|
+
};
|
|
1938
|
+
}
|
|
1939
|
+
function tr(e, t = "Group") {
|
|
1940
|
+
let n = (e) => e.groups ?? (e.group == null ? [] : [e.group]), r = Math.max(0, ...e.rows.map((e) => n(e).length)), i = (t) => {
|
|
1941
|
+
let n = e.groupBy?.[t], r = e.columns.find((e) => n != null && e.field === n);
|
|
1942
|
+
return r ? sr(r) : n ?? `Group ${t + 1}`;
|
|
1943
|
+
};
|
|
1944
|
+
return {
|
|
1945
|
+
labels: Array.from({ length: r }, (e, n) => Array.isArray(t) ? t[n] ?? i(n) : r === 1 ? t : i(n)),
|
|
1946
|
+
cells: (e) => {
|
|
1947
|
+
let t = n(e);
|
|
1948
|
+
return Array.from({ length: r }, (e, n) => t[n] ?? null);
|
|
1949
|
+
}
|
|
1950
|
+
};
|
|
1951
|
+
}
|
|
1952
|
+
function nr(e) {
|
|
1953
|
+
let t = /* @__PURE__ */ new Map();
|
|
1954
|
+
for (let n of e ?? []) for (let e of n.bands ?? []) for (let n of e.items ?? []) n.type !== "table" || t.has(n.id) || t.set(n.id, {
|
|
1955
|
+
id: n.id,
|
|
1956
|
+
columns: (n.columns ?? []).map(sr)
|
|
1957
|
+
});
|
|
1958
|
+
return [...t.values()];
|
|
1959
|
+
}
|
|
1960
|
+
function rr(e) {
|
|
1961
|
+
return {
|
|
1962
|
+
style: e.style ?? {},
|
|
1963
|
+
wrap: e.wrap !== !1,
|
|
1964
|
+
rowHighlight: e.rowHighlight ?? null
|
|
1965
|
+
};
|
|
1966
|
+
}
|
|
1967
|
+
function ir(e) {
|
|
1968
|
+
return e.headerMeasured ?? e.headerHeight ?? e.rowHeight ?? null;
|
|
1969
|
+
}
|
|
1970
|
+
function ar(e, t, n) {
|
|
1971
|
+
return t?.[n] ?? e.rowHeight ?? null;
|
|
1972
|
+
}
|
|
1973
|
+
function or(e) {
|
|
1974
|
+
return Number(e?.measuredHeight ?? e?.height) || 0;
|
|
1975
|
+
}
|
|
1976
|
+
function sr(e) {
|
|
1977
|
+
return e.label ?? e.field;
|
|
1978
|
+
}
|
|
1979
|
+
function cr(e) {
|
|
1980
|
+
return [...e ?? []].sort((e, t) => (e?.top ?? 0) - (t?.top ?? 0));
|
|
1981
|
+
}
|
|
1982
|
+
function lr(e, t, n) {
|
|
1983
|
+
let { page: r, origin: i } = n, a = t.length, o = [...e?.items ?? []].sort((e, t) => (e?.y ?? 0) - (t?.y ?? 0) || (e?.x ?? 0) - (t?.x ?? 0)), s = o.filter((e) => Zn.includes(e?.type)).map((e) => ({
|
|
1984
|
+
kind: e.type,
|
|
1985
|
+
page: r,
|
|
1986
|
+
x: Number(e.x) || 0,
|
|
1987
|
+
y: i + (Number(e.y) || 0),
|
|
1988
|
+
w: Number(e.w) || 0,
|
|
1989
|
+
h: Number(e.h) || 0,
|
|
1990
|
+
item: e
|
|
1991
|
+
})), c = null, l = () => {
|
|
1992
|
+
c && t.push({
|
|
1993
|
+
cells: c.cells,
|
|
1994
|
+
header: !1,
|
|
1995
|
+
design: c.design,
|
|
1996
|
+
page: r,
|
|
1997
|
+
top: c.top,
|
|
1998
|
+
height: c.bottom - c.top
|
|
1999
|
+
}), c = null;
|
|
2000
|
+
}, u = (e) => ({
|
|
2001
|
+
kind: "text",
|
|
2002
|
+
style: e.style ?? {},
|
|
2003
|
+
template: e.value,
|
|
2004
|
+
format: e.rawFormat ?? e.format,
|
|
2005
|
+
raw: e.raw,
|
|
2006
|
+
highlight: e.highlighted ?? null,
|
|
2007
|
+
x: Number(e.x) || 0,
|
|
2008
|
+
y: i + (Number(e.y) || 0),
|
|
2009
|
+
w: Number(e.w) || 0,
|
|
2010
|
+
h: Number(e.measuredHeight ?? e.h) || 0
|
|
2011
|
+
});
|
|
2012
|
+
for (let e of o) {
|
|
2013
|
+
if (e?.type === "table") {
|
|
2014
|
+
l(), mr(e, t, {
|
|
2015
|
+
...n,
|
|
2016
|
+
origin: i + (Number(e.y) || 0)
|
|
2017
|
+
});
|
|
2018
|
+
continue;
|
|
2019
|
+
}
|
|
2020
|
+
if (e?.type !== "text") continue;
|
|
2021
|
+
let r = u(e);
|
|
2022
|
+
if (c && pr(c.anchor, e)) {
|
|
2023
|
+
c.cells.push(e.text), c.design.push(r), c.top = Math.min(c.top, r.y), c.bottom = Math.max(c.bottom, r.y + r.h);
|
|
2024
|
+
continue;
|
|
2025
|
+
}
|
|
2026
|
+
l(), c = {
|
|
2027
|
+
anchor: e,
|
|
2028
|
+
cells: [e.text],
|
|
2029
|
+
design: [r],
|
|
2030
|
+
top: r.y,
|
|
2031
|
+
bottom: r.y + r.h
|
|
2032
|
+
};
|
|
2033
|
+
}
|
|
2034
|
+
l(), dr(t, a, s, r), n.graphics.push(...s);
|
|
2035
|
+
}
|
|
2036
|
+
var ur = 4;
|
|
2037
|
+
function dr(e, t, n, r) {
|
|
2038
|
+
let i = e.slice(t).map((e) => [e.top, e.top + (e.height ?? 0)]), a = [];
|
|
2039
|
+
for (let e of n) {
|
|
2040
|
+
let t = [e.y, e.y + Math.max(e.h, 1)], n = fr(t, i), r = n.length === 1 && n[0][0] === t[0] && n[0][1] === t[1];
|
|
2041
|
+
for (let e of n) (r || e[1] - e[0] >= ur) && a.push(e);
|
|
2042
|
+
}
|
|
2043
|
+
let o = [];
|
|
2044
|
+
for (let [e, t] of a.sort((e, t) => e[0] - t[0])) {
|
|
2045
|
+
let n = o[o.length - 1];
|
|
2046
|
+
if (n && e <= n.top + n.height) {
|
|
2047
|
+
n.height = Math.max(n.height, t - n.top);
|
|
2048
|
+
continue;
|
|
2049
|
+
}
|
|
2050
|
+
o.push({
|
|
2051
|
+
cells: [],
|
|
2052
|
+
header: !1,
|
|
2053
|
+
design: [],
|
|
2054
|
+
page: r,
|
|
2055
|
+
top: e,
|
|
2056
|
+
height: t - e,
|
|
2057
|
+
spacer: !0
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
for (let n of o) {
|
|
2061
|
+
let r = t;
|
|
2062
|
+
for (; r < e.length && e[r].top < n.top + n.height;) r++;
|
|
2063
|
+
e.splice(r, 0, n);
|
|
2064
|
+
}
|
|
2065
|
+
}
|
|
2066
|
+
function fr([e, t], n) {
|
|
2067
|
+
let r = [[e, t]];
|
|
2068
|
+
for (let [e, t] of n) t > e && (r = r.flatMap(([n, r]) => {
|
|
2069
|
+
if (t <= n || e >= r) return [[n, r]];
|
|
2070
|
+
let i = e > n ? [[n, e]] : [], a = t < r ? [[t, r]] : [];
|
|
2071
|
+
return [...i, ...a];
|
|
2072
|
+
}));
|
|
2073
|
+
return r;
|
|
2074
|
+
}
|
|
2075
|
+
function pr(e, t) {
|
|
2076
|
+
let n = (e) => {
|
|
2077
|
+
let t = e.y ?? 0;
|
|
2078
|
+
return [t, t + (e.measuredHeight ?? e.h ?? 0)];
|
|
2079
|
+
}, [r, i] = n(e), [a, o] = n(t);
|
|
2080
|
+
return Math.min(i, o) - Math.max(r, a) >= Math.min(i - r, o - a) / 2;
|
|
2081
|
+
}
|
|
2082
|
+
function mr(e, t, n) {
|
|
2083
|
+
let r = rr(e), { page: i } = n, a = n.origin, o = () => {
|
|
2084
|
+
let n = ir(e);
|
|
2085
|
+
t.push({
|
|
2086
|
+
cells: e.columns.map(sr),
|
|
2087
|
+
header: !0,
|
|
2088
|
+
design: e.columns.map((e) => ({
|
|
2089
|
+
kind: "head",
|
|
2090
|
+
column: e,
|
|
2091
|
+
table: r
|
|
2092
|
+
})),
|
|
2093
|
+
page: i,
|
|
2094
|
+
top: a,
|
|
2095
|
+
height: n
|
|
2096
|
+
}), a += Number(n) || 0;
|
|
2097
|
+
}, s = (n, o) => {
|
|
2098
|
+
t.push({
|
|
2099
|
+
cells: e.columns.map((e) => n?.[e.field]),
|
|
2100
|
+
header: !1,
|
|
2101
|
+
design: e.columns.map((t) => ({
|
|
2102
|
+
kind: "cell",
|
|
2103
|
+
column: t,
|
|
2104
|
+
table: r,
|
|
2105
|
+
highlight: ve(e, t, n)
|
|
2106
|
+
})),
|
|
2107
|
+
page: i,
|
|
2108
|
+
top: a,
|
|
2109
|
+
height: o
|
|
2110
|
+
}), a += Number(o) || 0;
|
|
2111
|
+
}, c = (e) => {
|
|
2112
|
+
lr(e, t, {
|
|
2113
|
+
...n,
|
|
2114
|
+
origin: a
|
|
2115
|
+
}), a += or(e);
|
|
2116
|
+
};
|
|
2117
|
+
if (!e.groups) {
|
|
2118
|
+
e.showHeader && o(), (e.row ?? []).forEach((t, n) => s(t, ar(e, e.rowHeights, n)));
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
for (let t of e.groups) {
|
|
2122
|
+
let { headers: n, footers: r } = d(t);
|
|
2123
|
+
t.showHeader && e.showHeader && o(), n.forEach((e) => c(e)), t.rows.forEach((n, r) => s(n, ar(e, t.rowHeights, r))), r.forEach((e) => c(e));
|
|
2124
|
+
}
|
|
2125
|
+
}
|
|
2126
|
+
//#endregion
|
|
2127
|
+
//#region src/engine/csv.js
|
|
2128
|
+
var hr = /^[=+\-@\t\r]/;
|
|
2129
|
+
function gr(e, t = {}) {
|
|
2130
|
+
let { delimiter: n = ",", newline: r = "\r\n", header: i = !0, groupColumn: a = !0, groupLabel: o = "Group", neutraliseFormulas: s = !0, formatted: c = !1, table: l = null } = t, u = er(e, l);
|
|
2131
|
+
if (!u) return "";
|
|
2132
|
+
let d = a ? tr(u, o) : {
|
|
2133
|
+
labels: [],
|
|
2134
|
+
cells: () => []
|
|
2135
|
+
}, f = u.columns.map(sr), p = [];
|
|
2136
|
+
i && p.push(vr([...d.labels, ...f], n, s));
|
|
2137
|
+
for (let e of u.rows) {
|
|
2138
|
+
let t = u.columns.map((t) => c ? j(e.row?.[t.field], t.format) : e.row?.[t.field]);
|
|
2139
|
+
p.push(vr([...d.cells(e), ...t], n, s));
|
|
2140
|
+
}
|
|
2141
|
+
return p.join(r);
|
|
2142
|
+
}
|
|
2143
|
+
function _r(e, t = {}) {
|
|
2144
|
+
let { delimiter: n = ",", newline: r = "\r\n", neutraliseFormulas: i = !0 } = t, a = Qn(e);
|
|
2145
|
+
return a.length === 0 ? "" : a.map(({ cells: e }) => vr(e, n, i)).join(r);
|
|
2146
|
+
}
|
|
2147
|
+
function U(e, t = "csv") {
|
|
2148
|
+
return `${String(e?.name ?? "report").replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim() || "report"}.${t}`;
|
|
2149
|
+
}
|
|
2150
|
+
function vr(e, t, n) {
|
|
2151
|
+
return e.map((e) => yr(e, t, n)).join(t);
|
|
2152
|
+
}
|
|
2153
|
+
function yr(e, t, n) {
|
|
2154
|
+
if (e == null) return "";
|
|
2155
|
+
let r = String(e);
|
|
2156
|
+
return n && hr.test(r) && (r = `\t${r}`), r.includes(t) || r.includes("\"") || r.includes("\n") || r.includes("\r") ? `"${r.replace(/"/g, "\"\"")}"` : r;
|
|
2157
|
+
}
|
|
2158
|
+
//#endregion
|
|
2159
|
+
//#region src/engine/xlsx-style.js
|
|
2160
|
+
var W = Object.freeze({
|
|
2161
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
2162
|
+
fontSize: 12,
|
|
2163
|
+
headerWeight: 600,
|
|
2164
|
+
headerBackground: "#f1f3f5",
|
|
2165
|
+
ruleColor: "#cdd4db",
|
|
2166
|
+
ruleWidth: 1,
|
|
2167
|
+
ruleStyle: "solid",
|
|
2168
|
+
cellPadding: 8
|
|
2169
|
+
}), br = [
|
|
2170
|
+
"aptos",
|
|
2171
|
+
"arial",
|
|
2172
|
+
"calibri",
|
|
2173
|
+
"cambria",
|
|
2174
|
+
"candara",
|
|
2175
|
+
"consolas",
|
|
2176
|
+
"constantia",
|
|
2177
|
+
"corbel",
|
|
2178
|
+
"courier new",
|
|
2179
|
+
"georgia",
|
|
2180
|
+
"segoe ui",
|
|
2181
|
+
"tahoma",
|
|
2182
|
+
"times new roman",
|
|
2183
|
+
"trebuchet ms",
|
|
2184
|
+
"verdana"
|
|
2185
|
+
], xr = {
|
|
2186
|
+
"sans-serif": "Arial",
|
|
2187
|
+
serif: "Times New Roman",
|
|
2188
|
+
monospace: "Courier New",
|
|
2189
|
+
"system-ui": "Calibri",
|
|
2190
|
+
"-apple-system": "Calibri",
|
|
2191
|
+
"ui-sans-serif": "Arial",
|
|
2192
|
+
"ui-serif": "Times New Roman",
|
|
2193
|
+
"ui-monospace": "Courier New",
|
|
2194
|
+
cursive: "Comic Sans MS",
|
|
2195
|
+
fantasy: "Impact"
|
|
2196
|
+
}, Sr = 31, Cr = {
|
|
2197
|
+
black: "000000",
|
|
2198
|
+
white: "FFFFFF",
|
|
2199
|
+
red: "FF0000",
|
|
2200
|
+
green: "008000",
|
|
2201
|
+
blue: "0000FF",
|
|
2202
|
+
gray: "808080",
|
|
2203
|
+
grey: "808080",
|
|
2204
|
+
silver: "C0C0C0",
|
|
2205
|
+
maroon: "800000",
|
|
2206
|
+
navy: "000080",
|
|
2207
|
+
teal: "008080",
|
|
2208
|
+
olive: "808000",
|
|
2209
|
+
purple: "800080",
|
|
2210
|
+
orange: "FFA500",
|
|
2211
|
+
yellow: "FFFF00",
|
|
2212
|
+
lime: "00FF00",
|
|
2213
|
+
aqua: "00FFFF",
|
|
2214
|
+
cyan: "00FFFF",
|
|
2215
|
+
fuchsia: "FF00FF",
|
|
2216
|
+
magenta: "FF00FF",
|
|
2217
|
+
darkgray: "A9A9A9",
|
|
2218
|
+
darkgrey: "A9A9A9",
|
|
2219
|
+
lightgray: "D3D3D3",
|
|
2220
|
+
lightgrey: "D3D3D3"
|
|
2221
|
+
}, wr = [
|
|
2222
|
+
"solid",
|
|
2223
|
+
"dashed",
|
|
2224
|
+
"dotted",
|
|
2225
|
+
"double"
|
|
2226
|
+
], Tr = [
|
|
2227
|
+
"left",
|
|
2228
|
+
"center",
|
|
2229
|
+
"right"
|
|
2230
|
+
], Er = 15;
|
|
2231
|
+
function Dr(e) {
|
|
2232
|
+
let t = Math.round((Number(e) || 0) / 9);
|
|
2233
|
+
return Math.max(0, Math.min(Er, t));
|
|
2234
|
+
}
|
|
2235
|
+
function G(e) {
|
|
2236
|
+
if (typeof e != "string") return null;
|
|
2237
|
+
let t = e.trim().toLowerCase();
|
|
2238
|
+
if (t === "" || t === "transparent" || t === "none" || t === "inherit") return null;
|
|
2239
|
+
if (Cr[t]) return `FF${Cr[t]}`;
|
|
2240
|
+
let n = t.match(/^#([0-9a-f]{3,8})$/);
|
|
2241
|
+
if (n) {
|
|
2242
|
+
let e = n[1];
|
|
2243
|
+
if ((e.length === 3 || e.length === 4) && (e = [...e].map((e) => e + e).join("")), e.length === 8) {
|
|
2244
|
+
if (e.slice(6) === "00") return null;
|
|
2245
|
+
e = e.slice(0, 6);
|
|
2246
|
+
}
|
|
2247
|
+
return e.length === 6 ? `FF${e.toUpperCase()}` : null;
|
|
2248
|
+
}
|
|
2249
|
+
let r = t.match(/^rgba?\(\s*([^)]*)\)$/);
|
|
2250
|
+
if (r) {
|
|
2251
|
+
let e = r[1].split(/[\s,/]+/).filter(Boolean);
|
|
2252
|
+
if (e.length < 3) return null;
|
|
2253
|
+
let t = e[3];
|
|
2254
|
+
if (t !== void 0 && parseFloat(t) === 0) return null;
|
|
2255
|
+
let n = e.slice(0, 3).map((e) => {
|
|
2256
|
+
let t = e.endsWith("%") ? parseFloat(e) * 255 / 100 : parseFloat(e);
|
|
2257
|
+
return Number.isFinite(t) ? Math.max(0, Math.min(255, Math.round(t))) : null;
|
|
2258
|
+
});
|
|
2259
|
+
return n.includes(null) ? null : "FF" + n.map((e) => e.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
2260
|
+
}
|
|
2261
|
+
return null;
|
|
2262
|
+
}
|
|
2263
|
+
function Or(e) {
|
|
2264
|
+
let t = String(e ?? "").split(",").map((e) => e.trim().replace(/^['"]|['"]$/g, "").trim()).filter(Boolean);
|
|
2265
|
+
return t.length === 0 ? "Arial" : (t.find((e) => br.includes(e.toLowerCase())) ?? xr[t[0].toLowerCase()] ?? t[0]).slice(0, Sr);
|
|
2266
|
+
}
|
|
2267
|
+
function kr(e) {
|
|
2268
|
+
return Math.round(e * .75 * 2) / 2;
|
|
2269
|
+
}
|
|
2270
|
+
function Ar(e) {
|
|
2271
|
+
return Math.max(1, Math.round((e - 5) / 7 * 100) / 100);
|
|
2272
|
+
}
|
|
2273
|
+
function jr(e) {
|
|
2274
|
+
if (e === "bold" || e === "bolder") return !0;
|
|
2275
|
+
let t = Number(e);
|
|
2276
|
+
return Number.isFinite(t) && t >= 600;
|
|
2277
|
+
}
|
|
2278
|
+
function Mr({ style: e = "solid", width: t = 1, color: n = null } = {}) {
|
|
2279
|
+
if (e === "none" || e === "hidden") return null;
|
|
2280
|
+
let r = wr.includes(e) ? e : "solid", i = Number(t);
|
|
2281
|
+
return !Number.isFinite(i) || i <= 0 ? null : {
|
|
2282
|
+
style: {
|
|
2283
|
+
solid: i <= 1 ? "thin" : i <= 2 ? "medium" : "thick",
|
|
2284
|
+
dashed: i <= 1 ? "dashed" : "mediumDashed",
|
|
2285
|
+
dotted: "dotted",
|
|
2286
|
+
double: "double"
|
|
2287
|
+
}[r],
|
|
2288
|
+
color: G(n)
|
|
2289
|
+
};
|
|
2290
|
+
}
|
|
2291
|
+
function K(e) {
|
|
2292
|
+
return e ? e.kind === "text" ? Nr(Pr(e.style ?? {}), e.highlight) : e.kind === "head" || e.kind === "cell" ? Nr(Fr(e.kind === "head", e.column ?? {}, e.table ?? {}), e.highlight) : null : null;
|
|
2293
|
+
}
|
|
2294
|
+
function Nr(e, t) {
|
|
2295
|
+
if (!t) return e;
|
|
2296
|
+
let n = { ...e.font };
|
|
2297
|
+
return t.color && (n.color = G(t.color) ?? n.color), t.fontWeight && (n.bold = jr(t.fontWeight)), t.fontStyle && (n.italic = t.fontStyle === "italic" || t.fontStyle === "oblique"), {
|
|
2298
|
+
...e,
|
|
2299
|
+
font: n,
|
|
2300
|
+
fill: t.background ? G(t.background) ?? e.fill : e.fill
|
|
2301
|
+
};
|
|
2302
|
+
}
|
|
2303
|
+
function Pr(e) {
|
|
2304
|
+
return {
|
|
2305
|
+
font: {
|
|
2306
|
+
name: Or(e.fontFamily ?? W.fontFamily),
|
|
2307
|
+
size: kr(Ir(e.fontSize) ?? W.fontSize),
|
|
2308
|
+
bold: jr(e.fontWeight),
|
|
2309
|
+
italic: e.fontStyle === "italic" || e.fontStyle === "oblique",
|
|
2310
|
+
color: G(e.color)
|
|
2311
|
+
},
|
|
2312
|
+
fill: null,
|
|
2313
|
+
border: null,
|
|
2314
|
+
alignment: {
|
|
2315
|
+
horizontal: Tr.includes(e.align) ? e.align : "left",
|
|
2316
|
+
vertical: "top",
|
|
2317
|
+
wrapText: !1
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
}
|
|
2321
|
+
function Fr(e, t, n) {
|
|
2322
|
+
let r = n.style ?? {}, i = e ? G(r.headerColor) ?? G(r.color) : G(r.color);
|
|
2323
|
+
return {
|
|
2324
|
+
font: {
|
|
2325
|
+
name: Or(r.fontFamily ?? W.fontFamily),
|
|
2326
|
+
size: kr(Ir(r.fontSize) ?? W.fontSize),
|
|
2327
|
+
bold: jr(e ? r.fontWeight ?? W.headerWeight : r.fontWeight),
|
|
2328
|
+
italic: r.fontStyle === "italic" || r.fontStyle === "oblique",
|
|
2329
|
+
color: i
|
|
2330
|
+
},
|
|
2331
|
+
fill: e ? r.headerBackground === null ? null : G(r.headerBackground ?? W.headerBackground) : G(r.background),
|
|
2332
|
+
border: Mr({
|
|
2333
|
+
style: r.borderStyle ?? W.ruleStyle,
|
|
2334
|
+
width: r.borderWidth ?? W.ruleWidth,
|
|
2335
|
+
color: r.borderColor ?? W.ruleColor
|
|
2336
|
+
}),
|
|
2337
|
+
alignment: {
|
|
2338
|
+
horizontal: Tr.includes(t.align) ? t.align : "left",
|
|
2339
|
+
vertical: "center",
|
|
2340
|
+
wrapText: n.wrap !== !1,
|
|
2341
|
+
indent: t.align === "center" ? 0 : Dr(W.cellPadding)
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
}
|
|
2345
|
+
function Ir(e) {
|
|
2346
|
+
let t = Number(e);
|
|
2347
|
+
return Number.isFinite(t) && t > 0 ? t : null;
|
|
2348
|
+
}
|
|
2349
|
+
function Lr() {
|
|
2350
|
+
let e = ["<font><sz val=\"11\"/><name val=\"Calibri\"/><family val=\"2\"/></font>"], t = ["<fill><patternFill patternType=\"none\"/></fill>", "<fill><patternFill patternType=\"gray125\"/></fill>"], n = ["<border><left/><right/><top/><bottom/><diagonal/></border>"], r = ["<xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\"/>"], i = /* @__PURE__ */ new Map();
|
|
2351
|
+
function a(e) {
|
|
2352
|
+
return i.has(e) || i.set(e, 164 + i.size), i.get(e);
|
|
2353
|
+
}
|
|
2354
|
+
let o = new Map([
|
|
2355
|
+
...e.map((e, t) => [e, t]),
|
|
2356
|
+
...t.map((e, t) => [e, t]),
|
|
2357
|
+
...n.map((e, t) => [e, t]),
|
|
2358
|
+
...r.map((e, t) => [e, t])
|
|
2359
|
+
]), s = (e, t) => o.has(t) ? o.get(t) : (e.push(t), o.set(t, e.length - 1), e.length - 1);
|
|
2360
|
+
function c(e) {
|
|
2361
|
+
return e ? "<font>" + (e.bold ? "<b/>" : "") + (e.italic ? "<i/>" : "") + `<sz val="${e.size ?? 11}"/>` + (e.color ? `<color rgb="${e.color}"/>` : "") + `<name val="${Rr(e.name ?? "Calibri")}"/></font>` : null;
|
|
2362
|
+
}
|
|
2363
|
+
function l(e) {
|
|
2364
|
+
return e ? `<fill><patternFill patternType="solid"><fgColor rgb="${e}"/><bgColor indexed="64"/></patternFill></fill>` : null;
|
|
2365
|
+
}
|
|
2366
|
+
function u(e) {
|
|
2367
|
+
if (!e) return null;
|
|
2368
|
+
let t = (t) => `<${t} style="${e.style}">` + (e.color ? `<color rgb="${e.color}"/>` : "<color auto=\"1\"/>") + `</${t}>`;
|
|
2369
|
+
return `<border>${t("left")}${t("right")}${t("top")}${t("bottom")}<diagonal/></border>`;
|
|
2370
|
+
}
|
|
2371
|
+
function d(e) {
|
|
2372
|
+
if (!e) return "";
|
|
2373
|
+
let t = [];
|
|
2374
|
+
return e.horizontal && e.horizontal !== "general" && t.push(`horizontal="${e.horizontal}"`), e.vertical && e.vertical !== "bottom" && t.push(`vertical="${e.vertical}"`), e.wrapText && t.push("wrapText=\"1\""), Number(e.indent) > 0 && [
|
|
2375
|
+
"left",
|
|
2376
|
+
"right",
|
|
2377
|
+
"distributed"
|
|
2378
|
+
].includes(e.horizontal) && t.push(`indent="${Math.round(Number(e.indent))}"`), t.length ? `<alignment ${t.join(" ")}/>` : "";
|
|
2379
|
+
}
|
|
2380
|
+
function f(i, a = 0) {
|
|
2381
|
+
if (!i && a === 0) return 0;
|
|
2382
|
+
let o = c(i?.font ? {
|
|
2383
|
+
name: "Calibri",
|
|
2384
|
+
size: 11,
|
|
2385
|
+
...i.font
|
|
2386
|
+
} : null), f = l(i?.fill), p = u(i?.border), m = d(i?.alignment), h = o ? s(e, o) : 0, g = f ? s(t, f) : 0, _ = p ? s(n, p) : 0, v = `<xf numFmtId="${a}" fontId="${h}" fillId="${g}" borderId="${_}" xfId="0"${[
|
|
2387
|
+
a ? " applyNumberFormat=\"1\"" : "",
|
|
2388
|
+
h ? " applyFont=\"1\"" : "",
|
|
2389
|
+
g ? " applyFill=\"1\"" : "",
|
|
2390
|
+
_ ? " applyBorder=\"1\"" : "",
|
|
2391
|
+
m ? " applyAlignment=\"1\"" : ""
|
|
2392
|
+
].join("")}` + (m ? `>${m}</xf>` : "/>");
|
|
2393
|
+
return s(r, v);
|
|
2394
|
+
}
|
|
2395
|
+
function p() {
|
|
2396
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" + (i.size ? `<numFmts count="${i.size}">${[...i].map(([e, t]) => `<numFmt numFmtId="${t}" formatCode="${Rr(e)}"/>`).join("")}</numFmts>` : "") + `<fonts count="${e.length}">${e.join("")}</fonts><fills count="${t.length}">${t.join("")}</fills><borders count="${n.length}">${n.join("")}</borders><cellStyleXfs count="1"><xf numFmtId="0" fontId="0" fillId="0" borderId="0"/></cellStyleXfs><cellXfs count="${r.length}">${r.join("")}</cellXfs><cellStyles count="1"><cellStyle name="Normal" xfId="0" builtinId="0"/></cellStyles></styleSheet>`;
|
|
2397
|
+
}
|
|
2398
|
+
return {
|
|
2399
|
+
xf: f,
|
|
2400
|
+
numFmt: a,
|
|
2401
|
+
xml: p,
|
|
2402
|
+
get size() {
|
|
2403
|
+
return r.length;
|
|
2404
|
+
}
|
|
2405
|
+
};
|
|
2406
|
+
}
|
|
2407
|
+
function Rr(e) {
|
|
2408
|
+
return String(e).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2409
|
+
}
|
|
2410
|
+
//#endregion
|
|
2411
|
+
//#region src/engine/xlsx-drawing.js
|
|
2412
|
+
var zr = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing", Br = "http://schemas.openxmlformats.org/drawingml/2006/main", Vr = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Hr = 9525, Ur = "application/vnd.openxmlformats-officedocument.drawing+xml", Wr = `${Vr}/drawing`, Gr = `${Vr}/image`, Kr = Object.freeze({
|
|
2413
|
+
png: "image/png",
|
|
2414
|
+
jpeg: "image/jpeg",
|
|
2415
|
+
gif: "image/gif",
|
|
2416
|
+
bmp: "image/bmp"
|
|
2417
|
+
}), qr = /^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]*)$/i;
|
|
2418
|
+
function q(e) {
|
|
2419
|
+
return Math.max(0, Math.round((Number(e) || 0) * Hr));
|
|
2420
|
+
}
|
|
2421
|
+
function Jr(e) {
|
|
2422
|
+
if (typeof e != "string") return null;
|
|
2423
|
+
let t = e.trim().match(qr);
|
|
2424
|
+
if (!t) return null;
|
|
2425
|
+
try {
|
|
2426
|
+
let e = atob(t[1].replace(/\s+/g, "")), n = new Uint8Array(e.length);
|
|
2427
|
+
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
2428
|
+
return n;
|
|
2429
|
+
} catch {
|
|
2430
|
+
return null;
|
|
2431
|
+
}
|
|
2432
|
+
}
|
|
2433
|
+
function Yr(e) {
|
|
2434
|
+
if (!(e instanceof Uint8Array) || e.length < 10) return null;
|
|
2435
|
+
let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (t, ...n) => n.every((n, r) => e[t + r] === n);
|
|
2436
|
+
return n(0, 137, 80, 78, 71, 13, 10, 26, 10) && e.length >= 24 ? {
|
|
2437
|
+
ext: "png",
|
|
2438
|
+
width: t.getUint32(16),
|
|
2439
|
+
height: t.getUint32(20)
|
|
2440
|
+
} : n(0, 71, 73, 70, 56) ? {
|
|
2441
|
+
ext: "gif",
|
|
2442
|
+
width: t.getUint16(6, !0),
|
|
2443
|
+
height: t.getUint16(8, !0)
|
|
2444
|
+
} : n(0, 66, 77) && e.length >= 26 ? {
|
|
2445
|
+
ext: "bmp",
|
|
2446
|
+
width: Math.abs(t.getInt32(18, !0)),
|
|
2447
|
+
height: Math.abs(t.getInt32(22, !0))
|
|
2448
|
+
} : n(0, 255, 216) ? {
|
|
2449
|
+
ext: "jpeg",
|
|
2450
|
+
...Xr(e, t)
|
|
2451
|
+
} : null;
|
|
2452
|
+
}
|
|
2453
|
+
function Xr(e, t) {
|
|
2454
|
+
let n = 2;
|
|
2455
|
+
for (; n + 9 < e.length;) {
|
|
2456
|
+
if (e[n] !== 255) {
|
|
2457
|
+
n++;
|
|
2458
|
+
continue;
|
|
2459
|
+
}
|
|
2460
|
+
let r = e[n + 1];
|
|
2461
|
+
if (r === 216 || r === 1 || r >= 208 && r <= 215) {
|
|
2462
|
+
n += 2;
|
|
2463
|
+
continue;
|
|
2464
|
+
}
|
|
2465
|
+
let i = t.getUint16(n + 2);
|
|
2466
|
+
if (r >= 192 && r <= 207 && ![
|
|
2467
|
+
196,
|
|
2468
|
+
200,
|
|
2469
|
+
204
|
|
2470
|
+
].includes(r)) return {
|
|
2471
|
+
height: t.getUint16(n + 5),
|
|
2472
|
+
width: t.getUint16(n + 7)
|
|
2473
|
+
};
|
|
2474
|
+
n += 2 + i;
|
|
2475
|
+
}
|
|
2476
|
+
return {
|
|
2477
|
+
width: null,
|
|
2478
|
+
height: null
|
|
2479
|
+
};
|
|
2480
|
+
}
|
|
2481
|
+
function Zr(e, t, n) {
|
|
2482
|
+
let { width: r, height: i } = n ?? {}, a = {
|
|
2483
|
+
x: 0,
|
|
2484
|
+
y: 0,
|
|
2485
|
+
w: t.w,
|
|
2486
|
+
h: t.h,
|
|
2487
|
+
crop: null
|
|
2488
|
+
};
|
|
2489
|
+
if (!(r > 0 && i > 0) || e === "fill" || t.w <= 0 || t.h <= 0) return a;
|
|
2490
|
+
if (e === "cover") {
|
|
2491
|
+
let e = Math.max(t.w / r, t.h / i), n = (e, t) => Math.round((1 - e / t) / 2 * 1e5), o = n(t.w, r * e), s = n(t.h, i * e);
|
|
2492
|
+
return {
|
|
2493
|
+
...a,
|
|
2494
|
+
crop: o || s ? {
|
|
2495
|
+
l: o,
|
|
2496
|
+
r: o,
|
|
2497
|
+
t: s,
|
|
2498
|
+
b: s
|
|
2499
|
+
} : null
|
|
2500
|
+
};
|
|
2501
|
+
}
|
|
2502
|
+
let o = Math.min(t.w / r, t.h / i), s = r * o, c = i * o;
|
|
2503
|
+
return {
|
|
2504
|
+
x: (t.w - s) / 2,
|
|
2505
|
+
y: (t.h - c) / 2,
|
|
2506
|
+
w: s,
|
|
2507
|
+
h: c,
|
|
2508
|
+
crop: null
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2511
|
+
function Qr(e) {
|
|
2512
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2513
|
+
<xdr:wsDr xmlns:xdr="${zr}" xmlns:a="${Br}" xmlns:r="${Vr}">${e.map((e, t) => {
|
|
2514
|
+
let n = t + 2;
|
|
2515
|
+
return `<xdr:oneCellAnchor><xdr:from><xdr:col>${e.col}</xdr:col><xdr:colOff>${q(e.colOff)}</xdr:colOff><xdr:row>${e.row}</xdr:row><xdr:rowOff>${q(e.rowOff)}</xdr:rowOff></xdr:from><xdr:ext cx="${q(e.cx)}" cy="${q(e.cy)}"/>` + e.shape(n, q(e.cx), q(e.cy)) + "<xdr:clientData/></xdr:oneCellAnchor>";
|
|
2516
|
+
}).join("")}</xdr:wsDr>`;
|
|
2517
|
+
}
|
|
2518
|
+
function $r(e) {
|
|
2519
|
+
return "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Relationships xmlns=\"http://schemas.openxmlformats.org/package/2006/relationships\">" + e.map((e) => `<Relationship Id="${e.rId}" Type="${Gr}" Target="../media/${e.file}"/>`).join("") + "</Relationships>";
|
|
2520
|
+
}
|
|
2521
|
+
function ei({ rId: e, alt: t = "", crop: n = null }) {
|
|
2522
|
+
return (r, i, a) => `<xdr:pic><xdr:nvPicPr><xdr:cNvPr id="${r}" name="Picture ${r - 1}" descr="${si(t)}"/><xdr:cNvPicPr><a:picLocks noChangeAspect="1"/></xdr:cNvPicPr></xdr:nvPicPr><xdr:blipFill><a:blip r:embed="${e}"/>` + (n ? `<a:srcRect l="${n.l}" t="${n.t}" r="${n.r}" b="${n.b}"/>` : "") + `<a:stretch><a:fillRect/></a:stretch></xdr:blipFill><xdr:spPr>${oi(i, a)}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>`;
|
|
2523
|
+
}
|
|
2524
|
+
function ti({ fill: e = null, outline: t = null, radius: n = 0, w: r, h: i }) {
|
|
2525
|
+
let a = Math.min(r, i), o = n > 0 && a > 0 ? Math.min(5e4, Math.round(n / a * 1e5)) : 0, s = o > 0 ? `<a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val ${o}"/></a:avLst></a:prstGeom>` : "<a:prstGeom prst=\"rect\"><a:avLst/></a:prstGeom>";
|
|
2526
|
+
return (n, r, i) => `<xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="${n}" name="Box ${n - 1}"/><xdr:cNvSpPr/></xdr:nvSpPr><xdr:spPr>${oi(r, i)}${s}` + (e ? ai(e) : "<a:noFill/>") + ii(t) + "</xdr:spPr></xdr:sp>";
|
|
2527
|
+
}
|
|
2528
|
+
function ni(e) {
|
|
2529
|
+
return (t, n, r) => `<xdr:cxnSp macro=""><xdr:nvCxnSpPr><xdr:cNvPr id="${t}" name="Line ${t - 1}"/><xdr:cNvCxnSpPr/></xdr:nvCxnSpPr><xdr:spPr>${oi(n, r)}<a:prstGeom prst="line"><a:avLst/></a:prstGeom>${ii(e)}</xdr:spPr></xdr:cxnSp>`;
|
|
2530
|
+
}
|
|
2531
|
+
function ri({ style: e = "solid", width: t = 1, color: n = null } = {}) {
|
|
2532
|
+
if (e === "none" || e === "hidden") return null;
|
|
2533
|
+
let r = Number(t);
|
|
2534
|
+
return !Number.isFinite(r) || r <= 0 ? null : {
|
|
2535
|
+
width: r,
|
|
2536
|
+
color: n ?? "FF000000",
|
|
2537
|
+
dash: {
|
|
2538
|
+
dashed: "dash",
|
|
2539
|
+
dotted: "sysDot"
|
|
2540
|
+
}[e] ?? null,
|
|
2541
|
+
double: e === "double"
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
function ii(e) {
|
|
2545
|
+
return e ? `<a:ln w="${q(e.width)}"${e.double ? " cmpd=\"dbl\"" : ""}>` + ai(e.color) + (e.dash ? `<a:prstDash val="${e.dash}"/>` : "") + "</a:ln>" : "<a:ln><a:noFill/></a:ln>";
|
|
2546
|
+
}
|
|
2547
|
+
function ai(e) {
|
|
2548
|
+
return `<a:solidFill><a:srgbClr val="${e.slice(-6)}"/></a:solidFill>`;
|
|
2549
|
+
}
|
|
2550
|
+
function oi(e, t) {
|
|
2551
|
+
return `<a:xfrm><a:off x="0" y="0"/><a:ext cx="${e}" cy="${t}"/></a:xfrm>`;
|
|
2552
|
+
}
|
|
2553
|
+
function si(e) {
|
|
2554
|
+
return String(e ?? "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
2555
|
+
}
|
|
2556
|
+
//#endregion
|
|
2557
|
+
//#region src/render/items.js
|
|
2558
|
+
var J = (e) => `position:absolute;top:${Y(e?.y)}px;left:${Y(e?.x)}px;`;
|
|
2559
|
+
function Y(e, t = 0) {
|
|
2560
|
+
let n = Number(e);
|
|
2561
|
+
return Number.isFinite(n) ? n : t;
|
|
2562
|
+
}
|
|
2563
|
+
function X(e, t = "") {
|
|
2564
|
+
if (e == null) return t;
|
|
2565
|
+
let n = String(e).replace(/[<>"'`&;{}\\]/g, "").replace(/url\s*\(/gi, "").replace(/\s+/g, " ").trim();
|
|
2566
|
+
return n === "" ? t : n;
|
|
2567
|
+
}
|
|
2568
|
+
function Z(e) {
|
|
2569
|
+
return e == null ? "" : String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2570
|
+
}
|
|
2571
|
+
function ci(e) {
|
|
2572
|
+
return (e || []).map((e) => {
|
|
2573
|
+
switch (e.type) {
|
|
2574
|
+
case "text": return li(e);
|
|
2575
|
+
case "table": return Si(e);
|
|
2576
|
+
case "line": return _i(e);
|
|
2577
|
+
case "box": return ui(e);
|
|
2578
|
+
case "image": return hi(e);
|
|
2579
|
+
default: return console.warn(`Unknown item type "${e?.type}"; it is not drawn.`), "";
|
|
2580
|
+
}
|
|
2581
|
+
}).join("");
|
|
2582
|
+
}
|
|
2583
|
+
function li(e) {
|
|
2584
|
+
let t = e.highlighted ?? null, n = {
|
|
2585
|
+
...e.style ?? {},
|
|
2586
|
+
...t ?? {}
|
|
2587
|
+
};
|
|
2588
|
+
return `
|
|
2589
|
+
<p id="${Z(e.id)}" style="
|
|
2590
|
+
${t?.background ? `background:${X(t.background)};` : ""}
|
|
2591
|
+
width:${Y(e.w)}px;
|
|
2592
|
+
height:${Y(e.h)}px;
|
|
2593
|
+
${J(e)}
|
|
2594
|
+
font-size:${Y(n.fontSize, 12)}px;
|
|
2595
|
+
font-family:${X(n.fontFamily, "inherit")};
|
|
2596
|
+
font-weight:${X(n.fontWeight, "normal")};
|
|
2597
|
+
font-style:${X(n.fontStyle, "normal")};
|
|
2598
|
+
text-align:${X(n.align, "left")};
|
|
2599
|
+
color:${X(n.color, "inherit")};
|
|
2600
|
+
" data-item-id="${Z(e.id)}" data-item-type="text">${Z(e.text)}</p>
|
|
2601
|
+
`;
|
|
2602
|
+
}
|
|
2603
|
+
function ui(e) {
|
|
2604
|
+
let t = e.style ?? {}, n = `${Math.max(0, Number(t.borderWidth ?? 1)) || 1}px ${yi.includes(t.borderStyle) ? t.borderStyle : "solid"} ${X(t.borderColor, "#000000")}`, r = Math.max(0, Number(t.radius ?? 0)) || 0, i = X(t.background);
|
|
2605
|
+
return `
|
|
2606
|
+
<div id="${Z(e.id)}" class="box" style="
|
|
2607
|
+
width:${Y(e.w)}px;
|
|
2608
|
+
height:${Y(e.h)}px;
|
|
2609
|
+
${J(e)}
|
|
2610
|
+
border:${n};
|
|
2611
|
+
${r ? `border-radius:${r}px;` : ""}
|
|
2612
|
+
${i ? `background:${i};` : ""}
|
|
2613
|
+
" data-item-id="${Z(e.id)}" data-item-type="box"></div>
|
|
2614
|
+
`;
|
|
2615
|
+
}
|
|
2616
|
+
var di = [
|
|
2617
|
+
"contain",
|
|
2618
|
+
"cover",
|
|
2619
|
+
"fill"
|
|
2620
|
+
], fi = /^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]*$/i, pi = [
|
|
2621
|
+
"http:",
|
|
2622
|
+
"https:",
|
|
2623
|
+
"blob:"
|
|
2624
|
+
];
|
|
2625
|
+
function mi(e) {
|
|
2626
|
+
if (typeof e != "string") return "";
|
|
2627
|
+
let t = e.trim();
|
|
2628
|
+
if (t === "") return "";
|
|
2629
|
+
let n = t.replace(/[\u0000-\u0020\u007f]+/g, "");
|
|
2630
|
+
if (/^data:/i.test(n)) return fi.test(n) ? n : "";
|
|
2631
|
+
let r = n.match(/^([a-z][a-z0-9+.-]*:)/i)?.[1]?.toLowerCase();
|
|
2632
|
+
return r == null || pi.includes(r) ? t : "";
|
|
2633
|
+
}
|
|
2634
|
+
function hi(e) {
|
|
2635
|
+
let t = Object.prototype.hasOwnProperty.call(e, "resolvedSrc"), n = mi(t ? e.resolvedSrc : e.src), r = di.includes(e.fit) ? e.fit : "contain", i = "";
|
|
2636
|
+
if (n) i = `<img src="${Z(n)}" alt="${Z(e.alt ?? "")}" style="object-fit:${r}" draggable="false">`;
|
|
2637
|
+
else if (!t) {
|
|
2638
|
+
let t = typeof e.field == "string" ? e.field.trim() : "";
|
|
2639
|
+
i = `<span class="image-empty">${t ? Z(`{${t}}`) : "Image"}</span>`;
|
|
2640
|
+
}
|
|
2641
|
+
return `
|
|
2642
|
+
<div id="${Z(e.id)}" class="image" style="
|
|
2643
|
+
width:${Y(e.w)}px;
|
|
2644
|
+
height:${Y(e.h)}px;
|
|
2645
|
+
${J(e)}
|
|
2646
|
+
" data-item-id="${Z(e.id)}" data-item-type="image">${i}</div>
|
|
2647
|
+
`;
|
|
2648
|
+
}
|
|
2649
|
+
function gi(e) {
|
|
2650
|
+
return `${Math.max(0, Number(e?.thickness ?? 1)) || 1}px ${vi.includes(e?.lineStyle) ? e.lineStyle : "solid"} ${X(e?.color, "#000000")}`;
|
|
2651
|
+
}
|
|
2652
|
+
function _i(e) {
|
|
2653
|
+
let t = e.orientation === "vertical", n = gi(e.style);
|
|
2654
|
+
return `
|
|
2655
|
+
<div id="${Z(e.id)}" class="line${t ? " is-vertical" : ""}" style="
|
|
2656
|
+
width:${Y(e.w)}px;
|
|
2657
|
+
height:${Y(e.h)}px;
|
|
2658
|
+
${J(e)}
|
|
2659
|
+
" data-item-id="${Z(e.id)}" data-item-type="line"><span class="line-mark"
|
|
2660
|
+
style="${t ? `border-left:${n}` : `border-top:${n}`}"></span></div>
|
|
2661
|
+
`;
|
|
2662
|
+
}
|
|
2663
|
+
var vi = [
|
|
2664
|
+
"solid",
|
|
2665
|
+
"dashed",
|
|
2666
|
+
"dotted",
|
|
2667
|
+
"double"
|
|
2668
|
+
], yi = [...vi, "none"];
|
|
2669
|
+
function bi(e) {
|
|
2670
|
+
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
2671
|
+
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
2672
|
+
}
|
|
2673
|
+
function xi(e) {
|
|
2674
|
+
let t = e.style ?? {}, n = [];
|
|
2675
|
+
yi.includes(t.borderStyle) && n.push(`--rs-rule-style:${t.borderStyle}`), t.borderColor && n.push(`--rs-rule-color:${X(t.borderColor)}`), t.headerBackground && n.push(`--rs-head-bg:${X(t.headerBackground)}`), t.headerColor && n.push(`--rs-head-color:${X(t.headerColor)}`), t.fontFamily && n.push(`--rs-cell-family:${X(t.fontFamily)}`);
|
|
2676
|
+
let r = Number(t.fontSize);
|
|
2677
|
+
Number.isFinite(r) && r > 0 && n.push(`--rs-cell-size:${r}px`), t.color && n.push(`--rs-cell-color:${X(t.color)}`), e.wrap === !1 && n.push("--rs-cell-wrap:nowrap");
|
|
2678
|
+
let i = Number(t.borderWidth);
|
|
2679
|
+
return Number.isFinite(i) && i > 0 && n.push(`--rs-rule-width:${Math.min(i, bi(e))}px`), n.length ? `${n.join(";")};` : "";
|
|
2680
|
+
}
|
|
2681
|
+
function Si(e) {
|
|
2682
|
+
return `
|
|
2683
|
+
<table id="${Z(e.id)}" style="width:${Y(e.w)}px;height:${Y(e.measuredHeight)}px;${J(e)}${xi(e)}" data-item-id="${Z(e.id)}" data-item-type="table">
|
|
2684
|
+
${e.groups ? Oi(e) : Di(e)}
|
|
2685
|
+
</table>
|
|
2686
|
+
`;
|
|
2687
|
+
}
|
|
2688
|
+
function Ci(e, t, n, r = null) {
|
|
2689
|
+
let i = r ? [
|
|
2690
|
+
r.color ? `color:${X(r.color)};` : "",
|
|
2691
|
+
r.fontWeight ? `font-weight:${X(r.fontWeight)};` : "",
|
|
2692
|
+
r.fontStyle ? `font-style:${X(r.fontStyle)};` : ""
|
|
2693
|
+
].join("") : "";
|
|
2694
|
+
return `<div class="cell" style="height:${Y(e)}px;text-align:${X(t, "left")};${i}">${Z(n)}</div>`;
|
|
2695
|
+
}
|
|
2696
|
+
function wi(e) {
|
|
2697
|
+
let t = e.headerMeasured ?? e.headerHeight ?? e.rowHeight;
|
|
2698
|
+
return `<thead>
|
|
2699
|
+
<tr style="height:${Y(t)}px">
|
|
2700
|
+
${e.columns.map((e) => `<th style="width:${Y(e.width)}px;">${Ci(t, e.align, e.label)}</th>`).join("")}
|
|
2701
|
+
</tr>
|
|
2702
|
+
</thead>`;
|
|
2703
|
+
}
|
|
2704
|
+
function Ti(e, t, n) {
|
|
2705
|
+
return (t || []).map((t, r) => {
|
|
2706
|
+
let i = n?.[r] ?? e.rowHeight;
|
|
2707
|
+
return `<tr style="height:${Y(i)}px">
|
|
2708
|
+
${e.columns.map((n) => {
|
|
2709
|
+
let r = ve(e, n, t), a = r?.background ? `background:${X(r.background)};` : "";
|
|
2710
|
+
return `<td style="width:${Y(n.width)}px;${a}">${Ci(i, n.align, j(t[n.field], n.format), r)}</td>`;
|
|
2711
|
+
}).join("")}
|
|
2712
|
+
</tr>`;
|
|
2713
|
+
}).join("");
|
|
2714
|
+
}
|
|
2715
|
+
function Ei(e, t, n) {
|
|
2716
|
+
if (!e) return "";
|
|
2717
|
+
let r = e.measuredHeight > 0 ? e.measuredHeight : e.height ?? 0;
|
|
2718
|
+
return `<tr class="${n}"${Number.isInteger(e.level) ? ` data-group-level="${e.level}"` : ""}>
|
|
2719
|
+
<td colspan="${t}" class="group-band-cell"${e.background ? ` style="background:${X(e.background)}"` : ""}>
|
|
2720
|
+
<div class="band" style="position:relative;height:${Y(r)}px">${ci(e.items)}</div>
|
|
2721
|
+
</td>
|
|
2722
|
+
</tr>`;
|
|
2723
|
+
}
|
|
2724
|
+
function Di(e) {
|
|
2725
|
+
return `
|
|
2726
|
+
${e.showHeader ? wi(e) : ""}
|
|
2727
|
+
<tbody>
|
|
2728
|
+
${Ti(e, e.row, e.rowHeights)}
|
|
2729
|
+
</tbody>
|
|
2730
|
+
`;
|
|
2731
|
+
}
|
|
2732
|
+
function Oi(e) {
|
|
2733
|
+
let t = e.columns.length;
|
|
2734
|
+
return e.groups.map((n) => {
|
|
2735
|
+
let { headers: r, footers: i } = ki(n);
|
|
2736
|
+
return `
|
|
2737
|
+
${n.showHeader && e.showHeader ? wi(e) : ""}
|
|
2738
|
+
<tbody>
|
|
2739
|
+
${r.map((e) => Ei(e, t, "group-header")).join("")}
|
|
2740
|
+
${Ti(e, n.rows, n.rowHeights)}
|
|
2741
|
+
${i.map((e) => Ei(e, t, "group-footer")).join("")}
|
|
2742
|
+
</tbody>
|
|
2743
|
+
`;
|
|
2744
|
+
}).join("");
|
|
2745
|
+
}
|
|
2746
|
+
function ki(e) {
|
|
2747
|
+
let t = Array.isArray(e.headerBands) ? e.headerBands : [e.headerBand], n = Array.isArray(e.footerBands) ? e.footerBands : [e.showFooter ? e.footerBand : null];
|
|
2748
|
+
return {
|
|
2749
|
+
headers: t.filter(Boolean),
|
|
2750
|
+
footers: n.filter(Boolean)
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
//#endregion
|
|
2754
|
+
//#region src/engine/zip.js
|
|
2755
|
+
var Ai = 0, ji = 33, Mi = 2048, Ni = 20, Pi = null;
|
|
2756
|
+
function Fi() {
|
|
2757
|
+
if (Pi) return Pi;
|
|
2758
|
+
Pi = /* @__PURE__ */ new Uint32Array(256);
|
|
2759
|
+
for (let e = 0; e < 256; e++) {
|
|
2760
|
+
let t = e;
|
|
2761
|
+
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
2762
|
+
Pi[e] = t >>> 0;
|
|
2763
|
+
}
|
|
2764
|
+
return Pi;
|
|
2765
|
+
}
|
|
2766
|
+
function Ii(e) {
|
|
2767
|
+
let t = Fi(), n = 4294967295;
|
|
2768
|
+
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
2769
|
+
return (n ^ 4294967295) >>> 0;
|
|
2770
|
+
}
|
|
2771
|
+
function Li(e) {
|
|
2772
|
+
let t = new TextEncoder(), n = e.map(({ name: e, data: n }) => {
|
|
2773
|
+
let r = typeof n == "string" ? t.encode(n) : n;
|
|
2774
|
+
return {
|
|
2775
|
+
name: t.encode(e),
|
|
2776
|
+
bytes: r,
|
|
2777
|
+
crc: Ii(r),
|
|
2778
|
+
offset: 0
|
|
2779
|
+
};
|
|
2780
|
+
}), r = n.reduce((e, t) => e + 30 + t.name.length + t.bytes.length, 0), i = n.reduce((e, t) => e + 46 + t.name.length, 0), a = new Uint8Array(r + i + 22), o = new DataView(a.buffer), s = 0, c = (e) => {
|
|
2781
|
+
o.setUint16(s, e, !0), s += 2;
|
|
2782
|
+
}, l = (e) => {
|
|
2783
|
+
o.setUint32(s, e, !0), s += 4;
|
|
2784
|
+
}, u = (e) => {
|
|
2785
|
+
a.set(e, s), s += e.length;
|
|
2786
|
+
};
|
|
2787
|
+
for (let e of n) e.offset = s, l(67324752), c(Ni), c(Mi), c(0), c(Ai), c(ji), l(e.crc), l(e.bytes.length), l(e.bytes.length), c(e.name.length), c(0), u(e.name), u(e.bytes);
|
|
2788
|
+
let d = s;
|
|
2789
|
+
for (let e of n) l(33639248), c(Ni), c(Ni), c(Mi), c(0), c(Ai), c(ji), l(e.crc), l(e.bytes.length), l(e.bytes.length), c(e.name.length), c(0), c(0), c(0), c(0), l(0), l(e.offset), u(e.name);
|
|
2790
|
+
let f = s - d;
|
|
2791
|
+
return l(101010256), c(0), c(0), c(n.length), c(n.length), l(f), l(d), c(0), a;
|
|
2792
|
+
}
|
|
2793
|
+
//#endregion
|
|
2794
|
+
//#region src/engine/xlsx.js
|
|
2795
|
+
var Q = Object.freeze({
|
|
2796
|
+
rows: 1048576,
|
|
2797
|
+
columns: 16384,
|
|
2798
|
+
cellText: 32767,
|
|
2799
|
+
sheetName: 31
|
|
2800
|
+
}), Ri = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", zi = "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Bi = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Vi = "http://schemas.openxmlformats.org/package/2006/relationships", Hi = "http://schemas.openxmlformats.org/package/2006/content-types", Ui = `${Bi}/officeDocument`, Wi = `${Bi}/worksheet`, Gi = `${Bi}/styles`, Ki = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml", qi = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", Ji = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml", Yi = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", Xi = Object.freeze({ font: Object.freeze({ bold: !0 }) }), Zi = 14, Qi = 22, $i = /[\x00-\x08\x0B\x0C\x0E-\x1F]/g, ea = /_(x[0-9A-Fa-f]{4}_)/g, ta = /[\[\]:*?\/\\\x00-\x1F]/g, na = 8, ra = 60, ia = 50, aa = 2.5, oa = 2, sa = 24, ca = 20, la = /^-?(0|[1-9]\d*)(\.\d+)?$/, ua = /\{[^{}]+\}/;
|
|
2801
|
+
function da(e, t = {}) {
|
|
2802
|
+
let { report: n = !0, tables: r = !0, styled: i = !0, reportSheetName: a = "Report", groupColumn: o = !0, groupLabel: s = "Group", images: c = null } = t, l = [];
|
|
2803
|
+
if (n && Qn(e).length > 0 && l.push(ma(e, a, i, c)), r) for (let { id: t } of nr(e)) l.push(ha(er(e, t), i, o, s));
|
|
2804
|
+
if (l.length === 0) return /* @__PURE__ */ new Uint8Array();
|
|
2805
|
+
let u = Ia(l.map((e) => e.name));
|
|
2806
|
+
l.forEach((e, t) => {
|
|
2807
|
+
e.name = u[t], e.width = e.rows.reduce((e, t) => Math.max(e, t.cells.length), 0);
|
|
2808
|
+
});
|
|
2809
|
+
let d = Lr(), f = l.map((e) => ka(e, d)), p = [], m = [];
|
|
2810
|
+
return l.forEach((e, t) => {
|
|
2811
|
+
e.drawing && (p.push({
|
|
2812
|
+
sheet: t + 1,
|
|
2813
|
+
n: p.length + 1,
|
|
2814
|
+
...e.drawing
|
|
2815
|
+
}), m.push(...e.drawing.media));
|
|
2816
|
+
}), Li([
|
|
2817
|
+
{
|
|
2818
|
+
name: "[Content_Types].xml",
|
|
2819
|
+
data: Ra(l.length, p, m)
|
|
2820
|
+
},
|
|
2821
|
+
{
|
|
2822
|
+
name: "_rels/.rels",
|
|
2823
|
+
data: za()
|
|
2824
|
+
},
|
|
2825
|
+
{
|
|
2826
|
+
name: "xl/workbook.xml",
|
|
2827
|
+
data: Va(l)
|
|
2828
|
+
},
|
|
2829
|
+
{
|
|
2830
|
+
name: "xl/_rels/workbook.xml.rels",
|
|
2831
|
+
data: Ha(l.length)
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
name: "xl/styles.xml",
|
|
2835
|
+
data: d.xml()
|
|
2836
|
+
},
|
|
2837
|
+
...f.map((e, t) => ({
|
|
2838
|
+
name: `xl/worksheets/sheet${t + 1}.xml`,
|
|
2839
|
+
data: e
|
|
2840
|
+
})),
|
|
2841
|
+
...p.flatMap((e) => [
|
|
2842
|
+
{
|
|
2843
|
+
name: `xl/worksheets/_rels/sheet${e.sheet}.xml.rels`,
|
|
2844
|
+
data: Ba(e.n)
|
|
2845
|
+
},
|
|
2846
|
+
{
|
|
2847
|
+
name: `xl/drawings/drawing${e.n}.xml`,
|
|
2848
|
+
data: Qr(e.anchors)
|
|
2849
|
+
},
|
|
2850
|
+
...e.media.length ? [{
|
|
2851
|
+
name: `xl/drawings/_rels/drawing${e.n}.xml.rels`,
|
|
2852
|
+
data: $r(e.media)
|
|
2853
|
+
}] : []
|
|
2854
|
+
]),
|
|
2855
|
+
...m.map((e) => ({
|
|
2856
|
+
name: `xl/media/${e.file}`,
|
|
2857
|
+
data: e.bytes
|
|
2858
|
+
}))
|
|
2859
|
+
]);
|
|
2860
|
+
}
|
|
2861
|
+
async function fa(e, t = {}) {
|
|
2862
|
+
let n = t.fetch ?? globalThis.fetch, r = new Map(t.images instanceof Map ? t.images : Object.entries(t.images ?? {}));
|
|
2863
|
+
return typeof n == "function" && await Promise.all(pa(e).filter((e) => !r.has(e)).map(async (e) => {
|
|
2864
|
+
try {
|
|
2865
|
+
let t = await n(e);
|
|
2866
|
+
t?.ok && r.set(e, new Uint8Array(await t.arrayBuffer()));
|
|
2867
|
+
} catch {}
|
|
2868
|
+
})), da(e, {
|
|
2869
|
+
...t,
|
|
2870
|
+
images: r
|
|
2871
|
+
});
|
|
2872
|
+
}
|
|
2873
|
+
function pa(e) {
|
|
2874
|
+
let t = /* @__PURE__ */ new Set();
|
|
2875
|
+
for (let n of $n(e).graphics) {
|
|
2876
|
+
if (n.kind !== "image") continue;
|
|
2877
|
+
let e = mi(n.item.resolvedSrc);
|
|
2878
|
+
e && !/^data:/i.test(e) && t.add(e);
|
|
2879
|
+
}
|
|
2880
|
+
return [...t];
|
|
2881
|
+
}
|
|
2882
|
+
function ma(e, t, n, r) {
|
|
2883
|
+
let { rows: i, graphics: a } = $n(e);
|
|
2884
|
+
if (!n) {
|
|
2885
|
+
let e = i.filter((e) => !e.spacer).map(({ cells: e, header: t }) => ({
|
|
2886
|
+
cells: e.map((e) => ({
|
|
2887
|
+
value: e,
|
|
2888
|
+
format: t ? Xi : null
|
|
2889
|
+
})),
|
|
2890
|
+
height: null
|
|
2891
|
+
}));
|
|
2892
|
+
return {
|
|
2893
|
+
name: t,
|
|
2894
|
+
rows: e,
|
|
2895
|
+
frozen: !1,
|
|
2896
|
+
gridLines: !0,
|
|
2897
|
+
widths: Oa(e)
|
|
2898
|
+
};
|
|
2899
|
+
}
|
|
2900
|
+
let o = ga(i), s = Da(), c = i.flatMap((e) => e.spacer ? [{
|
|
2901
|
+
cells: [],
|
|
2902
|
+
page: e.page,
|
|
2903
|
+
top: e.top,
|
|
2904
|
+
own: e.height
|
|
2905
|
+
}] : e.design?.length > 0 && e.design.every((e) => e?.kind === "text") ? _a(e, o, s) : [{
|
|
2906
|
+
cells: e.cells.map((t, n) => ({
|
|
2907
|
+
...va(t, e.design?.[n]),
|
|
2908
|
+
format: s(e.design?.[n])
|
|
2909
|
+
})),
|
|
2910
|
+
page: e.page,
|
|
2911
|
+
top: e.top,
|
|
2912
|
+
own: e.height
|
|
2913
|
+
}]);
|
|
2914
|
+
ba(c);
|
|
2915
|
+
let l = Sa(a, c, o, r), u = c.reduce((e, t) => Math.max(e, t.cells.length), o.px.length), d = Array.from({ length: u }, (e, t) => Ar(o.px[t] ?? 64));
|
|
2916
|
+
return {
|
|
2917
|
+
name: t,
|
|
2918
|
+
rows: c.map((e) => ({
|
|
2919
|
+
cells: e.cells,
|
|
2920
|
+
height: e.height
|
|
2921
|
+
})),
|
|
2922
|
+
frozen: !1,
|
|
2923
|
+
gridLines: !1,
|
|
2924
|
+
widths: d,
|
|
2925
|
+
drawing: l.anchors.length ? l : null
|
|
2926
|
+
};
|
|
2927
|
+
}
|
|
2928
|
+
function ha(e, t, n, r) {
|
|
2929
|
+
let i = n ? tr(e, r) : {
|
|
2930
|
+
labels: [],
|
|
2931
|
+
cells: () => []
|
|
2932
|
+
}, a = [...i.labels.map(() => ({
|
|
2933
|
+
field: null,
|
|
2934
|
+
align: "left"
|
|
2935
|
+
})), ...e.columns], o = [...i.labels, ...e.columns.map(sr)], s = a.map((n) => {
|
|
2936
|
+
if (!t) return Xi;
|
|
2937
|
+
let r = K({
|
|
2938
|
+
kind: "head",
|
|
2939
|
+
column: n,
|
|
2940
|
+
table: e.table
|
|
2941
|
+
});
|
|
2942
|
+
return r.alignment.horizontal === "right" ? {
|
|
2943
|
+
...r,
|
|
2944
|
+
alignment: {
|
|
2945
|
+
...r.alignment,
|
|
2946
|
+
indent: Math.max(r.alignment.indent ?? 0, oa)
|
|
2947
|
+
}
|
|
2948
|
+
} : r;
|
|
2949
|
+
}), c = a.map((n) => t ? K({
|
|
2950
|
+
kind: "cell",
|
|
2951
|
+
column: n,
|
|
2952
|
+
table: e.table
|
|
2953
|
+
}) : null), l = /* @__PURE__ */ new Map(), u = (n, r) => {
|
|
2954
|
+
if (!t || !r) return c[n];
|
|
2955
|
+
let i = `${n}|${JSON.stringify(r)}`;
|
|
2956
|
+
return l.has(i) || l.set(i, K({
|
|
2957
|
+
kind: "cell",
|
|
2958
|
+
column: a[n],
|
|
2959
|
+
table: e.table,
|
|
2960
|
+
highlight: r
|
|
2961
|
+
})), l.get(i);
|
|
2962
|
+
}, d = a.length - e.columns.length, f = [{
|
|
2963
|
+
cells: o.map((e, t) => ({
|
|
2964
|
+
value: e,
|
|
2965
|
+
format: s[t]
|
|
2966
|
+
})),
|
|
2967
|
+
height: t ? e.headerHeight : null
|
|
2968
|
+
}];
|
|
2969
|
+
for (let n of e.rows) {
|
|
2970
|
+
let { row: r, height: o } = n, s = e.columns.map((e) => r?.[e.field]), l = [...i.cells(n), ...s];
|
|
2971
|
+
f.push({
|
|
2972
|
+
cells: l.map((t, n) => ({
|
|
2973
|
+
...va(t, {
|
|
2974
|
+
kind: "cell",
|
|
2975
|
+
column: a[n]
|
|
2976
|
+
}),
|
|
2977
|
+
format: n < d ? c[n] : u(n, ve(e.table, a[n], r))
|
|
2978
|
+
})),
|
|
2979
|
+
height: t ? o : null
|
|
2980
|
+
});
|
|
2981
|
+
}
|
|
2982
|
+
let p = Oa(f), m = t ? a.map((e, t) => (Number(e.width) > 0 ? Ar(Number(e.width)) : p[t]) + aa) : p.map((e) => e + aa);
|
|
2983
|
+
return {
|
|
2984
|
+
name: e.id,
|
|
2985
|
+
rows: f,
|
|
2986
|
+
frozen: !0,
|
|
2987
|
+
gridLines: !0,
|
|
2988
|
+
widths: m
|
|
2989
|
+
};
|
|
2990
|
+
}
|
|
2991
|
+
function ga(e) {
|
|
2992
|
+
let t = [];
|
|
2993
|
+
for (let n of e) n.design?.forEach((e, n) => {
|
|
2994
|
+
if (!e || e.kind === "text") return;
|
|
2995
|
+
let r = Number(e.column?.width);
|
|
2996
|
+
t[n] = Math.max(t[n] ?? 0, r > 0 ? r : 64);
|
|
2997
|
+
});
|
|
2998
|
+
for (let e = 0; e < t.length; e++) t[e] ??= 64;
|
|
2999
|
+
function n(e) {
|
|
3000
|
+
let n = 0;
|
|
3001
|
+
for (let r = 0;; r++) {
|
|
3002
|
+
if (r === t.length) {
|
|
3003
|
+
if (t.length >= ia) return t.length - 1;
|
|
3004
|
+
t.push(64);
|
|
3005
|
+
}
|
|
3006
|
+
if (n += t[r], e < n) return r;
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
3009
|
+
let r = (e) => t.slice(0, e).reduce((e, t) => e + t, 0);
|
|
3010
|
+
return {
|
|
3011
|
+
px: t,
|
|
3012
|
+
at: n,
|
|
3013
|
+
left: r,
|
|
3014
|
+
right: (e) => r(e) + t[e]
|
|
3015
|
+
};
|
|
3016
|
+
}
|
|
3017
|
+
function _a(e, t, n) {
|
|
3018
|
+
let r = [], i = (e) => {
|
|
3019
|
+
let t = r.find((t) => e.every((e) => t.cells[e] === void 0));
|
|
3020
|
+
return t || (t = {
|
|
3021
|
+
cells: [],
|
|
3022
|
+
top: Infinity,
|
|
3023
|
+
bottom: -Infinity
|
|
3024
|
+
}, r.push(t)), t;
|
|
3025
|
+
};
|
|
3026
|
+
return e.cells.forEach((r, a) => {
|
|
3027
|
+
let o = e.design[a], s = n(o)?.alignment?.horizontal ?? "left", c = va(r, o), l = c.numFmt ? c.value : ya(r, o.template), u = c.numFmt, d = Math.max(0, Number(o.x) || 0), f = Math.max(1, Number(o.w) || 1), p = t.at(d), m = Math.max(p, t.at(d + f - 1)), h;
|
|
3028
|
+
if (s === "center" && m > p) {
|
|
3029
|
+
let e = Array.from({ length: m - p + 1 }, (e, t) => p + t), t = n.text(o, { centred: !0 });
|
|
3030
|
+
h = i(e), h.cells[p] = {
|
|
3031
|
+
value: l,
|
|
3032
|
+
format: t,
|
|
3033
|
+
numFmt: u
|
|
3034
|
+
};
|
|
3035
|
+
for (let e = p + 1; e <= m; e++) h.cells[e] = {
|
|
3036
|
+
value: null,
|
|
3037
|
+
format: t
|
|
3038
|
+
};
|
|
3039
|
+
} else {
|
|
3040
|
+
let e = s === "right" ? m : p, r = s === "right" ? t.right(e) - (d + f) : d - t.left(e);
|
|
3041
|
+
h = i([e]), h.cells[e] = {
|
|
3042
|
+
value: l,
|
|
3043
|
+
format: n.text(o, { indent: Dr(r) }),
|
|
3044
|
+
numFmt: u
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
h.top = Math.min(h.top, o.y), h.bottom = Math.max(h.bottom, o.y + (Number(o.h) || 0));
|
|
3048
|
+
}), r.map((t) => ({
|
|
3049
|
+
cells: t.cells,
|
|
3050
|
+
page: e.page,
|
|
3051
|
+
top: t.top,
|
|
3052
|
+
own: t.bottom - t.top
|
|
3053
|
+
}));
|
|
3054
|
+
}
|
|
3055
|
+
function va(e, t) {
|
|
3056
|
+
let n = t?.kind === "cell" ? t.column?.format : t?.kind === "text" ? t.format : null, r = de(n);
|
|
3057
|
+
if (!r) return { value: e };
|
|
3058
|
+
let i = t.kind === "text" ? t.raw : e;
|
|
3059
|
+
if (i === void 0) return { value: e };
|
|
3060
|
+
let a = me(i, n);
|
|
3061
|
+
return a === null ? { value: e } : {
|
|
3062
|
+
value: a,
|
|
3063
|
+
numFmt: r
|
|
3064
|
+
};
|
|
3065
|
+
}
|
|
3066
|
+
function ya(e, t) {
|
|
3067
|
+
if (typeof e != "string" || typeof t != "string" || !ua.test(t)) return e;
|
|
3068
|
+
let n = e.trim();
|
|
3069
|
+
if (!la.test(n)) return e;
|
|
3070
|
+
let r = n.replace(/^-/, "").split(".")[0], i = n.replace(/[-.]/g, "");
|
|
3071
|
+
return r.length > 11 || i.length > 15 ? e : Number(n);
|
|
3072
|
+
}
|
|
3073
|
+
function ba(e) {
|
|
3074
|
+
let t = 0;
|
|
3075
|
+
e.forEach((n, r) => {
|
|
3076
|
+
let i = n.own > 0 ? n.own : ca, a = e[r + 1], o = i;
|
|
3077
|
+
if (a && a.page === n.page) {
|
|
3078
|
+
let e = a.top - n.top;
|
|
3079
|
+
e > i && (o = Math.min(e, i + sa));
|
|
3080
|
+
}
|
|
3081
|
+
n.height = kr(o) / .75, n.sheetTop = t, t += n.height;
|
|
3082
|
+
});
|
|
3083
|
+
}
|
|
3084
|
+
function xa(e, t) {
|
|
3085
|
+
let n = /* @__PURE__ */ new Map();
|
|
3086
|
+
e.forEach((e, t) => {
|
|
3087
|
+
n.has(e.page) || n.set(e.page, []), n.get(e.page).push(t);
|
|
3088
|
+
});
|
|
3089
|
+
function r(t, r) {
|
|
3090
|
+
let i = n.get(t) ?? [e.length - 1], a = i[0];
|
|
3091
|
+
for (let t of i) e[t].top <= r && e[t].top >= e[a].top && (a = t);
|
|
3092
|
+
let o = e[a], s = Math.max(0, Math.min(r - o.top, o.height));
|
|
3093
|
+
return {
|
|
3094
|
+
row: a,
|
|
3095
|
+
offset: s,
|
|
3096
|
+
sheet: o.sheetTop + s
|
|
3097
|
+
};
|
|
3098
|
+
}
|
|
3099
|
+
function i(e) {
|
|
3100
|
+
let n = t.at(Math.max(0, e)), r = Math.max(0, Math.min(e - t.left(n), t.px[n]));
|
|
3101
|
+
return {
|
|
3102
|
+
col: n,
|
|
3103
|
+
offset: r,
|
|
3104
|
+
sheet: t.left(n) + r
|
|
3105
|
+
};
|
|
3106
|
+
}
|
|
3107
|
+
return {
|
|
3108
|
+
x: i,
|
|
3109
|
+
y: r
|
|
3110
|
+
};
|
|
3111
|
+
}
|
|
3112
|
+
function Sa(e, t, n, r) {
|
|
3113
|
+
let i = xa(t, n), a = [], o = Ca(r), s = (e, t, n, r, a) => {
|
|
3114
|
+
let o = i.x(t), s = i.y(e, n), c = i.x(t + r), l = i.y(e, n + a);
|
|
3115
|
+
return {
|
|
3116
|
+
anchor: {
|
|
3117
|
+
col: o.col,
|
|
3118
|
+
colOff: o.offset,
|
|
3119
|
+
row: s.row,
|
|
3120
|
+
rowOff: s.offset
|
|
3121
|
+
},
|
|
3122
|
+
sheet: {
|
|
3123
|
+
x1: o.sheet,
|
|
3124
|
+
x2: c.sheet,
|
|
3125
|
+
y1: s.sheet,
|
|
3126
|
+
y2: l.sheet
|
|
3127
|
+
}
|
|
3128
|
+
};
|
|
3129
|
+
};
|
|
3130
|
+
for (let r of e) {
|
|
3131
|
+
if (r.kind === "image") {
|
|
3132
|
+
let e = o.get(mi(r.item.resolvedSrc));
|
|
3133
|
+
if (!e) continue;
|
|
3134
|
+
let t = Zr(r.item.fit, {
|
|
3135
|
+
w: r.w,
|
|
3136
|
+
h: r.h
|
|
3137
|
+
}, e.natural), { anchor: n } = s(r.page, r.x + t.x, r.y + t.y, t.w, t.h);
|
|
3138
|
+
a.push({
|
|
3139
|
+
...n,
|
|
3140
|
+
cx: t.w,
|
|
3141
|
+
cy: t.h,
|
|
3142
|
+
shape: ei({
|
|
3143
|
+
rId: e.rId,
|
|
3144
|
+
alt: r.item.alt,
|
|
3145
|
+
crop: t.crop
|
|
3146
|
+
})
|
|
3147
|
+
});
|
|
3148
|
+
continue;
|
|
3149
|
+
}
|
|
3150
|
+
if (r.kind === "line") {
|
|
3151
|
+
let e = r.item.style ?? {}, t = Math.max(0, Number(e.thickness ?? 1)) || 1, n = ri({
|
|
3152
|
+
style: [
|
|
3153
|
+
"solid",
|
|
3154
|
+
"dashed",
|
|
3155
|
+
"dotted",
|
|
3156
|
+
"double"
|
|
3157
|
+
].includes(e.lineStyle) ? e.lineStyle : "solid",
|
|
3158
|
+
width: t,
|
|
3159
|
+
color: G(e.color) ?? "FF000000"
|
|
3160
|
+
}), i = r.item.orientation === "vertical", o = i ? s(r.page, r.x + r.w / 2, r.y, 0, r.h) : s(r.page, r.x, r.y + r.h / 2, r.w, 0);
|
|
3161
|
+
a.push({
|
|
3162
|
+
...o.anchor,
|
|
3163
|
+
cx: i ? 0 : o.sheet.x2 - o.sheet.x1,
|
|
3164
|
+
cy: i ? o.sheet.y2 - o.sheet.y1 : 0,
|
|
3165
|
+
shape: ni(n)
|
|
3166
|
+
});
|
|
3167
|
+
continue;
|
|
3168
|
+
}
|
|
3169
|
+
if (r.kind === "box") {
|
|
3170
|
+
let e = r.item.style ?? {}, i = G(e.background), o = Math.max(0, Number(e.borderWidth ?? 1)) || 1, c = e.borderStyle === "none" ? null : ri({
|
|
3171
|
+
style: [
|
|
3172
|
+
"solid",
|
|
3173
|
+
"dashed",
|
|
3174
|
+
"dotted",
|
|
3175
|
+
"double"
|
|
3176
|
+
].includes(e.borderStyle) ? e.borderStyle : "solid",
|
|
3177
|
+
width: o,
|
|
3178
|
+
color: G(e.borderColor) ?? "FF000000"
|
|
3179
|
+
}), l = s(r.page, r.x, r.y, r.w, r.h), u = i && Ta(t, n, l.sheet);
|
|
3180
|
+
if (u && Ea(t, n, l.sheet, i), !c && (u || !i)) continue;
|
|
3181
|
+
let d = c ? c.width / 2 : 0, f = s(r.page, r.x + d, r.y + d, r.w - 2 * d, r.h - 2 * d), p = Math.max(0, f.sheet.x2 - f.sheet.x1), m = Math.max(0, f.sheet.y2 - f.sheet.y1);
|
|
3182
|
+
a.push({
|
|
3183
|
+
...f.anchor,
|
|
3184
|
+
cx: p,
|
|
3185
|
+
cy: m,
|
|
3186
|
+
shape: ti({
|
|
3187
|
+
fill: u ? null : i,
|
|
3188
|
+
outline: c,
|
|
3189
|
+
radius: Math.max(0, (Number(e.radius) || 0) - d),
|
|
3190
|
+
w: p,
|
|
3191
|
+
h: m
|
|
3192
|
+
})
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
}
|
|
3196
|
+
return {
|
|
3197
|
+
anchors: a,
|
|
3198
|
+
media: o.list
|
|
3199
|
+
};
|
|
3200
|
+
}
|
|
3201
|
+
function Ca(e) {
|
|
3202
|
+
let t = e instanceof Map ? e : new Map(Object.entries(e ?? {})), n = /* @__PURE__ */ new Map(), r = [];
|
|
3203
|
+
function i(e) {
|
|
3204
|
+
if (!e) return null;
|
|
3205
|
+
if (n.has(e)) return n.get(e);
|
|
3206
|
+
let i = Jr(e);
|
|
3207
|
+
if (!i) {
|
|
3208
|
+
let n = t.get(e);
|
|
3209
|
+
i = n instanceof ArrayBuffer ? new Uint8Array(n) : n instanceof Uint8Array ? n : null;
|
|
3210
|
+
}
|
|
3211
|
+
let a = i ? Yr(i) : null;
|
|
3212
|
+
if (!a || !Kr[a.ext]) return n.set(e, null), null;
|
|
3213
|
+
let o = r.length + 1, s = {
|
|
3214
|
+
rId: `rId${o}`,
|
|
3215
|
+
file: `image${o}.${a.ext}`,
|
|
3216
|
+
ext: a.ext,
|
|
3217
|
+
bytes: i,
|
|
3218
|
+
natural: {
|
|
3219
|
+
width: a.width,
|
|
3220
|
+
height: a.height
|
|
3221
|
+
}
|
|
3222
|
+
};
|
|
3223
|
+
return r.push(s), n.set(e, s), s;
|
|
3224
|
+
}
|
|
3225
|
+
return {
|
|
3226
|
+
get: i,
|
|
3227
|
+
list: r
|
|
3228
|
+
};
|
|
3229
|
+
}
|
|
3230
|
+
function wa(e, t, n) {
|
|
3231
|
+
let r = (e, t, n, r) => Math.min(t, r) - Math.max(e, n) >= (r - n) / 2, i = [];
|
|
3232
|
+
e.forEach((e, t) => {
|
|
3233
|
+
e.height > 0 && r(n.y1, n.y2, e.sheetTop, e.sheetTop + e.height) && i.push(t);
|
|
3234
|
+
});
|
|
3235
|
+
let a = [];
|
|
3236
|
+
for (let e = 0; e < t.px.length; e++) r(n.x1, n.x2, t.left(e), t.right(e)) && a.push(e);
|
|
3237
|
+
if (i.length && a.length) return {
|
|
3238
|
+
rowIndexes: i,
|
|
3239
|
+
colIndexes: a
|
|
3240
|
+
};
|
|
3241
|
+
let o = (n.y1 + n.y2) / 2, s = e.findIndex((e) => o >= e.sheetTop && o < e.sheetTop + e.height), c = t.at((n.x1 + n.x2) / 2);
|
|
3242
|
+
return s < 0 ? {
|
|
3243
|
+
rowIndexes: [],
|
|
3244
|
+
colIndexes: []
|
|
3245
|
+
} : {
|
|
3246
|
+
rowIndexes: [s],
|
|
3247
|
+
colIndexes: [c]
|
|
3248
|
+
};
|
|
3249
|
+
}
|
|
3250
|
+
function Ta(e, t, n) {
|
|
3251
|
+
return e.some((e, r) => e.sheetTop >= n.y2 || e.sheetTop + e.height <= n.y1 ? !1 : e.cells.some((e, r) => !e || e.value === null || e.value === void 0 || e.value === "" ? !1 : t.left(r) < n.x2 && t.right(r) > n.x1));
|
|
3252
|
+
}
|
|
3253
|
+
function Ea(e, t, n, r) {
|
|
3254
|
+
let { rowIndexes: i, colIndexes: a } = wa(e, t, n), o = /* @__PURE__ */ new Map(), s = (e) => e?.fill ? e : (o.has(e) || o.set(e, {
|
|
3255
|
+
...e ?? {},
|
|
3256
|
+
fill: r
|
|
3257
|
+
}), o.get(e));
|
|
3258
|
+
for (let t of i) for (let n of a) {
|
|
3259
|
+
let r = e[t].cells[n];
|
|
3260
|
+
e[t].cells[n] = r ? {
|
|
3261
|
+
...r,
|
|
3262
|
+
format: s(r.format)
|
|
3263
|
+
} : {
|
|
3264
|
+
value: null,
|
|
3265
|
+
format: s(null)
|
|
3266
|
+
};
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
function Da() {
|
|
3270
|
+
let e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
|
|
3271
|
+
function n(t) {
|
|
3272
|
+
if (!t) return null;
|
|
3273
|
+
if (t.kind === "text") return n.text(t);
|
|
3274
|
+
let r = t.column ?? t;
|
|
3275
|
+
e.has(r) || e.set(r, {});
|
|
3276
|
+
let i = e.get(r), a = t.highlight ? `${t.kind}|${JSON.stringify(t.highlight)}` : t.kind;
|
|
3277
|
+
return i[a] ??= K(t), i[a];
|
|
3278
|
+
}
|
|
3279
|
+
return n.text = (e, { centred: n = !1, indent: r = 0 } = {}) => {
|
|
3280
|
+
let i = e.style ?? e;
|
|
3281
|
+
t.has(i) || t.set(i, /* @__PURE__ */ new Map());
|
|
3282
|
+
let a = t.get(i), o = `${n}|${r}|${e.highlight ? JSON.stringify(e.highlight) : ""}`;
|
|
3283
|
+
if (!a.has(o)) {
|
|
3284
|
+
let t = K(e);
|
|
3285
|
+
a.set(o, {
|
|
3286
|
+
...t,
|
|
3287
|
+
alignment: {
|
|
3288
|
+
...t.alignment,
|
|
3289
|
+
...n ? { horizontal: "centerContinuous" } : {},
|
|
3290
|
+
indent: n ? 0 : r
|
|
3291
|
+
}
|
|
3292
|
+
});
|
|
3293
|
+
}
|
|
3294
|
+
return a.get(o);
|
|
3295
|
+
}, n;
|
|
3296
|
+
}
|
|
3297
|
+
function Oa(e) {
|
|
3298
|
+
let t = [];
|
|
3299
|
+
for (let { cells: n } of e) n.forEach((e, n) => {
|
|
3300
|
+
t[n] ??= na;
|
|
3301
|
+
let r = e?.value;
|
|
3302
|
+
if (r == null) return;
|
|
3303
|
+
let i = r instanceof Date ? 18 : String(r).split("\n").reduce((e, t) => Math.max(e, t.length), 0);
|
|
3304
|
+
t[n] = Math.max(t[n], Math.min(ra, i + 2));
|
|
3305
|
+
});
|
|
3306
|
+
for (let e = 0; e < t.length; e++) t[e] ??= na;
|
|
3307
|
+
return t;
|
|
3308
|
+
}
|
|
3309
|
+
function ka({ name: e, rows: t, frozen: n, gridLines: r, widths: i, width: a, drawing: o }, s) {
|
|
3310
|
+
if (t.length > Q.rows) throw RangeError(`Sheet "${e}" has ${t.length} rows; Excel allows ${Q.rows}.`);
|
|
3311
|
+
if (a > Q.columns) throw RangeError(`Sheet "${e}" has ${a} columns; Excel allows ${Q.columns}.`);
|
|
3312
|
+
let c = Aa(a, t.length), l = ja(s), u = [Yi, `<worksheet xmlns="${zi}" xmlns:r="${Bi}">`];
|
|
3313
|
+
if (u.push(`<dimension ref="${c}"/>`), u.push(`<sheetViews><sheetView${r ? "" : " showGridLines=\"0\""} workbookViewId="0">`), n && t.length > 1 && u.push("<pane ySplit=\"1\" topLeftCell=\"A2\" activePane=\"bottomLeft\" state=\"frozen\"/><selection pane=\"bottomLeft\" activeCell=\"A2\" sqref=\"A2\"/>"), u.push("</sheetView></sheetViews>"), a > 0) {
|
|
3314
|
+
u.push("<cols>");
|
|
3315
|
+
for (let e = 0; e < a; e++) {
|
|
3316
|
+
let t = i?.[e] ?? na;
|
|
3317
|
+
u.push(`<col min="${e + 1}" max="${e + 1}" width="${t}" customWidth="1"/>`);
|
|
3318
|
+
}
|
|
3319
|
+
u.push("</cols>");
|
|
3320
|
+
}
|
|
3321
|
+
return u.push("<sheetData>"), t.forEach((e, t) => {
|
|
3322
|
+
let n = "";
|
|
3323
|
+
e.cells.forEach((e, r) => {
|
|
3324
|
+
e && (n += Ma(`${Fa(r)}${t + 1}`, e.value, e.format, l, e.numFmt));
|
|
3325
|
+
});
|
|
3326
|
+
let r = Number(e.height) > 0 ? ` ht="${kr(Number(e.height))}" customHeight="1"` : "";
|
|
3327
|
+
u.push(`<row r="${t + 1}"${r}>${n}</row>`);
|
|
3328
|
+
}), u.push("</sheetData>"), n && a > 0 && u.push(`<autoFilter ref="${c}"/>`), a > 0 && u.push(`<ignoredErrors><ignoredError sqref="${c}" numberStoredAsText="1"/></ignoredErrors>`), o && u.push("<drawing r:id=\"rId1\"/>"), u.push("</worksheet>"), u.join("");
|
|
3329
|
+
}
|
|
3330
|
+
function Aa(e, t) {
|
|
3331
|
+
if (e === 0 || t === 0) return "A1";
|
|
3332
|
+
let n = `${Fa(e - 1)}${t}`;
|
|
3333
|
+
return n === "A1" ? "A1" : `A1:${n}`;
|
|
3334
|
+
}
|
|
3335
|
+
function ja(e) {
|
|
3336
|
+
let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
|
|
3337
|
+
return (r, i) => {
|
|
3338
|
+
let a = typeof i == "string" ? e.numFmt(i) : i;
|
|
3339
|
+
if (!r) return n.has(a) || n.set(a, e.xf(null, a)), n.get(a);
|
|
3340
|
+
t.has(r) || t.set(r, /* @__PURE__ */ new Map());
|
|
3341
|
+
let o = t.get(r);
|
|
3342
|
+
return o.has(a) || o.set(a, e.xf(r, a)), o.get(a);
|
|
3343
|
+
};
|
|
3344
|
+
}
|
|
3345
|
+
function Ma(e, t, n, r, i) {
|
|
3346
|
+
let a = t == null || t === "", o = t instanceof Date && !Number.isNaN(t.getTime()), s = 0, c = null;
|
|
3347
|
+
o && (c = Pa(t), s = Number.isInteger(c) ? Zi : Qi), i && typeof t == "number" && (s = i), i && o && (s = i);
|
|
3348
|
+
let l = r(n, s), u = l ? ` s="${l}"` : "";
|
|
3349
|
+
return a ? l ? `<c r="${e}"${u}/>` : "" : o ? `<c r="${e}"${u}><v>${c}</v></c>` : typeof t == "number" ? Number.isFinite(t) ? `<c r="${e}"${u}><v>${t}</v></c>` : Na(e, String(t), u) : typeof t == "boolean" ? `<c r="${e}"${u} t="b"><v>${+!!t}</v></c>` : Na(e, String(t), u);
|
|
3350
|
+
}
|
|
3351
|
+
function Na(e, t, n) {
|
|
3352
|
+
let r = t.replace($i, "");
|
|
3353
|
+
return r.length > Q.cellText && (r = r.slice(0, Q.cellText), /[\uD800-\uDBFF]$/.test(r) && (r = r.slice(0, -1))), `<c r="${e}"${n} t="inlineStr"><is><t${/^\s|\s$|\n/.test(r) ? " xml:space=\"preserve\"" : ""}>${Ua(r.replace(ea, "_x005F_$1"))}</t></is></c>`;
|
|
3354
|
+
}
|
|
3355
|
+
function Pa(e) {
|
|
3356
|
+
return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()) / 864e5 + 25569;
|
|
3357
|
+
}
|
|
3358
|
+
function Fa(e) {
|
|
3359
|
+
let t = "", n = e + 1;
|
|
3360
|
+
for (; n > 0;) {
|
|
3361
|
+
let e = (n - 1) % 26;
|
|
3362
|
+
t = String.fromCharCode(65 + e) + t, n = Math.floor((n - 1) / 26);
|
|
3363
|
+
}
|
|
3364
|
+
return t;
|
|
3365
|
+
}
|
|
3366
|
+
function Ia(e) {
|
|
3367
|
+
let t = /* @__PURE__ */ new Set(["history"]);
|
|
3368
|
+
return e.map((e) => {
|
|
3369
|
+
let n = String(e ?? "").replace(ta, "-").trim().replace(/^'+|'+$/g, "").trim() || "Sheet";
|
|
3370
|
+
n = La(n, Q.sheetName);
|
|
3371
|
+
let r = n;
|
|
3372
|
+
for (let e = 2; t.has(r.toLowerCase()); e++) {
|
|
3373
|
+
let t = ` (${e})`;
|
|
3374
|
+
r = La(n, Q.sheetName - t.length) + t;
|
|
3375
|
+
}
|
|
3376
|
+
return t.add(r.toLowerCase()), r;
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
function La(e, t) {
|
|
3380
|
+
if (e.length <= t) return e;
|
|
3381
|
+
let n = e.slice(0, t);
|
|
3382
|
+
return /[\uD800-\uDBFF]$/.test(n) ? n.slice(0, -1) : n;
|
|
3383
|
+
}
|
|
3384
|
+
function Ra(e, t = [], n = []) {
|
|
3385
|
+
let r = Array.from({ length: e }, (e, t) => `<Override PartName="/xl/worksheets/sheet${t + 1}.xml" ContentType="${Ki}"/>`).join(""), i = t.map((e) => `<Override PartName="/xl/drawings/drawing${e.n}.xml" ContentType="${Ur}"/>`).join(""), a = [...new Set(n.map((e) => e.ext))].map((e) => `<Default Extension="${e}" ContentType="${Kr[e]}"/>`).join("");
|
|
3386
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3387
|
+
<Types xmlns="${Hi}"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>` + a + `<Override PartName="/xl/workbook.xml" ContentType="${qi}"/><Override PartName="/xl/styles.xml" ContentType="${Ji}"/>` + r + i + "</Types>";
|
|
3388
|
+
}
|
|
3389
|
+
function za() {
|
|
3390
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3391
|
+
<Relationships xmlns="${Vi}"><Relationship Id="rId1" Type="${Ui}" Target="xl/workbook.xml"/></Relationships>`;
|
|
3392
|
+
}
|
|
3393
|
+
function Ba(e) {
|
|
3394
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3395
|
+
<Relationships xmlns="${Vi}"><Relationship Id="rId1" Type="${Wr}" Target="../drawings/drawing${e}.xml"/></Relationships>`;
|
|
3396
|
+
}
|
|
3397
|
+
function Va(e) {
|
|
3398
|
+
let t = e.map((e, t) => `<sheet name="${Wa(e.name)}" sheetId="${t + 1}" r:id="rId${t + 1}"/>`).join(""), n = e.map((e, t) => !e.frozen || e.width === 0 ? "" : `<definedName name="_xlnm._FilterDatabase" localSheetId="${t}" hidden="1">${Ua(`${`'${e.name.replace(/'/g, "''")}'`}!$A$1:$${Fa(e.width - 1)}$${e.rows.length}`)}</definedName>`).join("");
|
|
3399
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3400
|
+
<workbook xmlns="${zi}" xmlns:r="${Bi}"><bookViews><workbookView/></bookViews><sheets>${t}</sheets>` + (n ? `<definedNames>${n}</definedNames>` : "") + "</workbook>";
|
|
3401
|
+
}
|
|
3402
|
+
function Ha(e) {
|
|
3403
|
+
let t = Array.from({ length: e }, (e, t) => `<Relationship Id="rId${t + 1}" Type="${Wi}" Target="worksheets/sheet${t + 1}.xml"/>`).join("");
|
|
3404
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
3405
|
+
<Relationships xmlns="${Vi}">` + t + `<Relationship Id="rId${e + 1}" Type="${Gi}" Target="styles.xml"/></Relationships>`;
|
|
3406
|
+
}
|
|
3407
|
+
function Ua(e) {
|
|
3408
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
3409
|
+
}
|
|
3410
|
+
function Wa(e) {
|
|
3411
|
+
return Ua(e.replace($i, "")).replace(/"/g, """);
|
|
3412
|
+
}
|
|
3413
|
+
//#endregion
|
|
3414
|
+
//#region src/engine/index.js
|
|
3415
|
+
function Ga(e, t) {
|
|
3416
|
+
return An(at(Xt(Ht(e, t), t)));
|
|
3417
|
+
}
|
|
3418
|
+
//#endregion
|
|
3419
|
+
//#region src/render/render.js
|
|
3420
|
+
var Ka = (e) => `padding-top:${Y(e?.top)}px;padding-left:${Y(e?.left)}px;padding-bottom:${Y(e?.bottom)}px;padding-right:${Y(e?.right)}px;`, qa = [
|
|
3421
|
+
"pageHeader",
|
|
3422
|
+
"reportHeader",
|
|
3423
|
+
"detail",
|
|
3424
|
+
"reportFooter",
|
|
3425
|
+
"pageFooter"
|
|
3426
|
+
];
|
|
3427
|
+
function Ja(e) {
|
|
3428
|
+
let t = e.page;
|
|
3429
|
+
return `
|
|
3430
|
+
<main id="main-page">
|
|
3431
|
+
${e.pages.map((e) => `
|
|
3432
|
+
<section id="page-${Z(e.pageNO)}" class="page" style="height:${Y(t.height)}px; width:${Y(t.width)}px; ${Ka(t.margin)};position:relative">
|
|
3433
|
+
${Ya(e, t)}
|
|
3434
|
+
</section>
|
|
3435
|
+
`).join("")}
|
|
3436
|
+
</main>
|
|
3437
|
+
`;
|
|
3438
|
+
}
|
|
3439
|
+
function Ya(e, t) {
|
|
3440
|
+
let n = (e) => {
|
|
3441
|
+
let t = qa.indexOf(e);
|
|
3442
|
+
return t === -1 ? qa.length : t;
|
|
3443
|
+
}, r = [...e.bands].sort(({ type: e }, { type: t }) => n(e) - n(t)), i = [];
|
|
3444
|
+
for (let n of r) i.push(Xa(n, e.pageNO, t));
|
|
3445
|
+
return i.join("");
|
|
3446
|
+
}
|
|
3447
|
+
function Xa(e, t, n) {
|
|
3448
|
+
let r = Number.isFinite(e.top), i = n?.margin ?? {
|
|
3449
|
+
top: 0,
|
|
3450
|
+
left: 0,
|
|
3451
|
+
right: 0
|
|
3452
|
+
}, a = r ? `position:absolute;top:${Y(e.top) + Y(i.top)}px;left:${Y(i.left)}px;right:${Y(i.right)}px;` : "position:relative;", o = Math.max(e.zoneHeight ?? 0, e.measuredHeight ?? 0);
|
|
3453
|
+
return `
|
|
3454
|
+
<div class="band" id="${Z(e.type)}-${Z(t)}" style="${a}${o > 0 ? `height:${Y(o)}px` : ""}" data-band-type="${Z(e.type)}">
|
|
3455
|
+
${ci(e.items)}
|
|
3456
|
+
</div>
|
|
3457
|
+
`;
|
|
3458
|
+
}
|
|
3459
|
+
//#endregion
|
|
3460
|
+
//#region src/shared/window.js
|
|
3461
|
+
var Za = 1280, Qa = 900;
|
|
3462
|
+
function $a(e, t) {
|
|
3463
|
+
for (let n of e.querySelectorAll("link[rel=\"stylesheet\"], style")) {
|
|
3464
|
+
if (n.tagName === "LINK") {
|
|
3465
|
+
let e = t.createElement("link");
|
|
3466
|
+
e.rel = "stylesheet", e.href = n.href, t.head.appendChild(e);
|
|
3467
|
+
continue;
|
|
3468
|
+
}
|
|
3469
|
+
let e = t.createElement("style");
|
|
3470
|
+
e.textContent = n.textContent, t.head.appendChild(e);
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
function eo({ title: e = "Report Studio", width: t = Za, height: n = Qa, features: r, opener: i = globalThis } = {}) {
|
|
3474
|
+
let a = r ?? `width=${t},height=${n},resizable=yes,scrollbars=yes`, o = i.open?.("", "_blank", a);
|
|
3475
|
+
if (!o || !o.document) return null;
|
|
3476
|
+
let s = o.document;
|
|
3477
|
+
s.open(), s.write("<!doctype html><html><head><meta charset=\"utf-8\"></head><body></body></html>"), s.close(), s.title = e, $a(i.document, s);
|
|
3478
|
+
let c = s.createElement("div");
|
|
3479
|
+
return c.id = "report-studio", c.style.height = "100vh", s.body.style.margin = "0", s.body.appendChild(c), {
|
|
3480
|
+
window: o,
|
|
3481
|
+
document: s,
|
|
3482
|
+
mount: c,
|
|
3483
|
+
close: () => o.close()
|
|
3484
|
+
};
|
|
3485
|
+
}
|
|
3486
|
+
function to(e, t, n = () => {}) {
|
|
3487
|
+
let r = () => {
|
|
3488
|
+
n(), t.close();
|
|
3489
|
+
};
|
|
3490
|
+
return e.addEventListener("pagehide", r), () => e.removeEventListener("pagehide", r);
|
|
3491
|
+
}
|
|
3492
|
+
//#endregion
|
|
3493
|
+
//#region src/shared/dropdown.js
|
|
3494
|
+
function no(e) {
|
|
3495
|
+
let t = e.querySelector(".dropdown-trigger"), n = e.querySelector(".dropdown-value"), r = e.querySelector(".dropdown-menu"), i = [...r.querySelectorAll(".dropdown-item")], a = /* @__PURE__ */ new Set(), o = () => t.ownerDocument, s = i.find((e) => e.dataset.selected === "true")?.dataset.value ?? i[0]?.dataset.value ?? "", c = Math.max(i.findIndex((e) => e.dataset.value === s), 0);
|
|
3496
|
+
function l() {
|
|
3497
|
+
i.forEach((e, t) => {
|
|
3498
|
+
let n = e.dataset.value === s;
|
|
3499
|
+
e.setAttribute("aria-selected", String(n)), e.classList.toggle("is-active", t === c);
|
|
3500
|
+
});
|
|
3501
|
+
let e = i.find((e) => e.dataset.value === s);
|
|
3502
|
+
e && (n.textContent = e.textContent.trim());
|
|
3503
|
+
}
|
|
3504
|
+
function u(e, { notify: t = !1 } = {}) {
|
|
3505
|
+
let n = i.find((t) => t.dataset.value === String(e));
|
|
3506
|
+
if (!n) return;
|
|
3507
|
+
let r = n.dataset.value !== s;
|
|
3508
|
+
if (s = n.dataset.value, c = i.indexOf(n), l(), t && r) for (let e of a) e();
|
|
3509
|
+
}
|
|
3510
|
+
let d = () => !r.hidden;
|
|
3511
|
+
function f() {
|
|
3512
|
+
d() || (r.hidden = !1, t.setAttribute("aria-expanded", "true"), c = Math.max(i.findIndex((e) => e.dataset.value === s), 0), l(), i[c]?.focus(), setTimeout(() => o().addEventListener("pointerdown", m), 0));
|
|
3513
|
+
}
|
|
3514
|
+
function p({ focusTrigger: e = !0 } = {}) {
|
|
3515
|
+
d() && (r.hidden = !0, t.setAttribute("aria-expanded", "false"), o().removeEventListener("pointerdown", m), e && t.focus());
|
|
3516
|
+
}
|
|
3517
|
+
function m(t) {
|
|
3518
|
+
e.contains(t.target) || p({ focusTrigger: !1 });
|
|
3519
|
+
}
|
|
3520
|
+
function h(e) {
|
|
3521
|
+
c = (e + i.length) % i.length, l(), i[c]?.focus();
|
|
3522
|
+
}
|
|
3523
|
+
function g(e) {
|
|
3524
|
+
[
|
|
3525
|
+
"ArrowDown",
|
|
3526
|
+
"ArrowUp",
|
|
3527
|
+
"Enter",
|
|
3528
|
+
" "
|
|
3529
|
+
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), f());
|
|
3530
|
+
}
|
|
3531
|
+
function _(e) {
|
|
3532
|
+
let t = {
|
|
3533
|
+
ArrowDown: () => h(c + 1),
|
|
3534
|
+
ArrowUp: () => h(c - 1),
|
|
3535
|
+
Home: () => h(0),
|
|
3536
|
+
End: () => h(i.length - 1),
|
|
3537
|
+
Escape: () => p(),
|
|
3538
|
+
Enter: () => {
|
|
3539
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
3540
|
+
},
|
|
3541
|
+
" ": () => {
|
|
3542
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
3543
|
+
},
|
|
3544
|
+
Tab: () => p({ focusTrigger: !1 })
|
|
3545
|
+
}[e.key];
|
|
3546
|
+
t && (e.key !== "Tab" && (e.preventDefault(), e.stopPropagation()), t());
|
|
3547
|
+
}
|
|
3548
|
+
t.addEventListener("click", () => d() ? p() : f()), t.addEventListener("keydown", g), r.addEventListener("keydown", _);
|
|
3549
|
+
for (let e of i) e.addEventListener("click", () => {
|
|
3550
|
+
u(e.dataset.value, { notify: !0 }), p();
|
|
3551
|
+
});
|
|
3552
|
+
return l(), {
|
|
3553
|
+
get value() {
|
|
3554
|
+
return s;
|
|
3555
|
+
},
|
|
3556
|
+
set value(e) {
|
|
3557
|
+
u(e);
|
|
3558
|
+
},
|
|
3559
|
+
addEventListener(e, t) {
|
|
3560
|
+
e === "change" && a.add(t);
|
|
3561
|
+
},
|
|
3562
|
+
open: f,
|
|
3563
|
+
close: p,
|
|
3564
|
+
get isOpen() {
|
|
3565
|
+
return d();
|
|
3566
|
+
},
|
|
3567
|
+
destroy() {
|
|
3568
|
+
o().removeEventListener("pointerdown", m), a.clear();
|
|
3569
|
+
}
|
|
3570
|
+
};
|
|
3571
|
+
}
|
|
3572
|
+
//#endregion
|
|
3573
|
+
//#region src/preview/chrome.js
|
|
3574
|
+
function ro({ title: e = "Report Studio" } = {}) {
|
|
3575
|
+
return `
|
|
3576
|
+
<!--
|
|
3577
|
+
A header, not role="toolbar": that role promises arrow-key roving focus
|
|
3578
|
+
between the controls, and here the arrow keys page the report instead.
|
|
3579
|
+
|
|
3580
|
+
Two boxes: the header is what measures its width, and the row inside
|
|
3581
|
+
it is what rearranges. A container query restyles what is inside the
|
|
3582
|
+
container, never the container, so the grid cannot be the header.
|
|
3583
|
+
-->
|
|
3584
|
+
<header class="toolbar" aria-label="Report tools">
|
|
3585
|
+
<div class="toolbar-row" data-role="bar">
|
|
3586
|
+
<div class="toolbar-brand">${e}</div>
|
|
3587
|
+
|
|
3588
|
+
<div class="toolbar-centre">
|
|
3589
|
+
<div class="toolbar-group toolbar-search">
|
|
3590
|
+
<!--
|
|
3591
|
+
Buttons cannot live inside an <input>, so the wrapper draws
|
|
3592
|
+
the field and the input inside it draws no chrome of its own.
|
|
3593
|
+
-->
|
|
3594
|
+
<div class="search-field">
|
|
3595
|
+
<input type="search" data-role="query" placeholder="Search the report (ctrl+K)"
|
|
3596
|
+
title="Search the report (ctrl+K)"
|
|
3597
|
+
aria-label="Search the report" spellcheck="false">
|
|
3598
|
+
<span class="hits" data-role="hits" data-state="idle" aria-live="polite"></span>
|
|
3599
|
+
<button type="button" data-role="hit-prev" title="Previous match (shift+enter)"
|
|
3600
|
+
aria-label="Previous match">↑</button>
|
|
3601
|
+
<button type="button" data-role="hit-next" title="Next match (enter)"
|
|
3602
|
+
aria-label="Next match">↓</button>
|
|
3603
|
+
</div>
|
|
3604
|
+
</div>
|
|
3605
|
+
|
|
3606
|
+
<div class="toolbar-group toolbar-zoom">
|
|
3607
|
+
<button type="button" data-role="zoom-out" title="Zoom out (ctrl+-)"
|
|
3608
|
+
aria-label="Zoom out">−</button>
|
|
3609
|
+
|
|
3610
|
+
<!--
|
|
3611
|
+
A listbox rather than a <select>: option items are drawn by
|
|
3612
|
+
the operating system, so they cannot take the palette.
|
|
3613
|
+
-->
|
|
3614
|
+
<div class="dropdown" data-role="zoom-dropdown">
|
|
3615
|
+
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
3616
|
+
aria-haspopup="listbox" aria-expanded="false" aria-label="Zoom level">
|
|
3617
|
+
<span class="dropdown-value">100%</span>
|
|
3618
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
3619
|
+
</button>
|
|
3620
|
+
|
|
3621
|
+
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
3622
|
+
aria-label="Zoom level" hidden>
|
|
3623
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="fit">Fit width</li>
|
|
3624
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.5">50%</li>
|
|
3625
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.75">75%</li>
|
|
3626
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1"
|
|
3627
|
+
data-selected="true">100%</li>
|
|
3628
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.25">125%</li>
|
|
3629
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.5">150%</li>
|
|
3630
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="2">200%</li>
|
|
3631
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="3">300%</li>
|
|
3632
|
+
</ul>
|
|
3633
|
+
</div>
|
|
3634
|
+
|
|
3635
|
+
<button type="button" data-role="zoom-in" title="Zoom in (ctrl++)"
|
|
3636
|
+
aria-label="Zoom in">+</button>
|
|
3637
|
+
</div>
|
|
3638
|
+
</div>
|
|
3639
|
+
|
|
3640
|
+
<div class="toolbar-group toolbar-save">
|
|
3641
|
+
<button type="button" data-role="print" title="Print or save as PDF (ctrl+P)">
|
|
3642
|
+
Print</button>
|
|
3643
|
+
<button type="button" data-role="export" title="Export the report (ctrl+X)">
|
|
3644
|
+
Export…</button>
|
|
3645
|
+
</div>
|
|
3646
|
+
</div>
|
|
3647
|
+
</header>
|
|
3648
|
+
|
|
3649
|
+
<div class="viewport" data-role="viewport"></div>
|
|
3650
|
+
|
|
3651
|
+
<!-- paging floats over the report rather than taking a strip of it -->
|
|
3652
|
+
<div class="pager" data-role="pager" role="toolbar" aria-label="Page navigation">
|
|
3653
|
+
<button type="button" data-role="prev" title="Previous page (left arrow)"
|
|
3654
|
+
aria-label="Previous page">‹</button>
|
|
3655
|
+
|
|
3656
|
+
<label class="page-of">
|
|
3657
|
+
<input type="number" data-role="current" min="1" value="1" aria-label="Current page">
|
|
3658
|
+
<span>of</span>
|
|
3659
|
+
<span data-role="total">1</span>
|
|
3660
|
+
</label>
|
|
3661
|
+
|
|
3662
|
+
<button type="button" data-role="next" title="Next page (right arrow)"
|
|
3663
|
+
aria-label="Next page">›</button>
|
|
3664
|
+
</div>
|
|
3665
|
+
|
|
3666
|
+
|
|
3667
|
+
|
|
3668
|
+
<!--
|
|
3669
|
+
Hand-written rather than a <dialog>: the element is still unimplemented
|
|
3670
|
+
in the environment the specs run in, and a stubbed showModal would test
|
|
3671
|
+
the stub instead of the behaviour.
|
|
3672
|
+
-->
|
|
3673
|
+
<div class="modal" data-role="export-modal" hidden>
|
|
3674
|
+
<div class="modal-backdrop" data-role="export-backdrop"></div>
|
|
3675
|
+
|
|
3676
|
+
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="export-title">
|
|
3677
|
+
<h2 id="export-title">Export report</h2>
|
|
3678
|
+
|
|
3679
|
+
<div class="modal-formats" role="radiogroup" aria-labelledby="export-title">
|
|
3680
|
+
<label class="format">
|
|
3681
|
+
<input type="radio" name="export-format" value="pdf" checked>
|
|
3682
|
+
<span class="format-body">
|
|
3683
|
+
<span class="format-name">PDF</span>
|
|
3684
|
+
<span class="format-note">Opens the print dialog - choose "Save as PDF"</span>
|
|
3685
|
+
</span>
|
|
3686
|
+
</label>
|
|
3687
|
+
|
|
3688
|
+
<label class="format">
|
|
3689
|
+
<input type="radio" name="export-format" value="csv">
|
|
3690
|
+
<span class="format-body">
|
|
3691
|
+
<span class="format-name">CSV</span>
|
|
3692
|
+
<span class="format-note">Every text line and table row, in report order</span>
|
|
3693
|
+
</span>
|
|
3694
|
+
</label>
|
|
3695
|
+
|
|
3696
|
+
<label class="format">
|
|
3697
|
+
<input type="radio" name="export-format" value="xlsx">
|
|
3698
|
+
<span class="format-body">
|
|
3699
|
+
<span class="format-name">Excel</span>
|
|
3700
|
+
<span class="format-note">The report as it reads, plus a sheet per table</span>
|
|
3701
|
+
</span>
|
|
3702
|
+
</label>
|
|
3703
|
+
</div>
|
|
3704
|
+
|
|
3705
|
+
<p class="modal-summary" data-role="export-summary" aria-live="polite"></p>
|
|
3706
|
+
|
|
3707
|
+
<div class="modal-actions">
|
|
3708
|
+
<button type="button" data-role="export-cancel">Cancel</button>
|
|
3709
|
+
<button type="button" class="is-primary" data-role="export-confirm">Export</button>
|
|
3710
|
+
</div>
|
|
3711
|
+
</div>
|
|
3712
|
+
</div>
|
|
3713
|
+
`;
|
|
3714
|
+
}
|
|
3715
|
+
//#endregion
|
|
3716
|
+
//#region src/preview/viewer.js
|
|
3717
|
+
var $ = [
|
|
3718
|
+
.5,
|
|
3719
|
+
.75,
|
|
3720
|
+
1,
|
|
3721
|
+
1.25,
|
|
3722
|
+
1.5,
|
|
3723
|
+
2,
|
|
3724
|
+
3
|
|
3725
|
+
], io = $[0], ao = $[$.length - 1];
|
|
3726
|
+
function oo({ paginated: e, title: t, width: n, height: r, features: i, ...a } = {}) {
|
|
3727
|
+
let o = eo({
|
|
3728
|
+
title: t ?? "Report",
|
|
3729
|
+
width: n,
|
|
3730
|
+
height: r,
|
|
3731
|
+
features: i
|
|
3732
|
+
});
|
|
3733
|
+
if (!o) return null;
|
|
3734
|
+
let s = so({
|
|
3735
|
+
...a,
|
|
3736
|
+
mount: o.mount,
|
|
3737
|
+
paginated: e,
|
|
3738
|
+
title: t
|
|
3739
|
+
}), c = to(globalThis, o.window, s.destroy);
|
|
3740
|
+
return {
|
|
3741
|
+
...s,
|
|
3742
|
+
window: o.window,
|
|
3743
|
+
destroy() {
|
|
3744
|
+
c(), s.destroy(), o.close();
|
|
3745
|
+
}
|
|
3746
|
+
};
|
|
3747
|
+
}
|
|
3748
|
+
function so({ mount: e, paginated: t, title: n } = {}) {
|
|
3749
|
+
let r = typeof e == "string" ? document.querySelector(e) : e;
|
|
3750
|
+
if (!r) throw Error(`createViewer: no element for mount ${JSON.stringify(e)}. Add <div id="report"></div> to the page first.`);
|
|
3751
|
+
let i = r.ownerDocument, a = i.defaultView ?? globalThis;
|
|
3752
|
+
if (!t?.pages) throw Error("createViewer: paginated must be a buildPages(layout, data) result.");
|
|
3753
|
+
r.classList.add("report-viewer"), r.innerHTML = ro({ title: n });
|
|
3754
|
+
let o = r.querySelector("[data-role=\"viewport\"]");
|
|
3755
|
+
o.innerHTML = Ja(t);
|
|
3756
|
+
let s = [...o.querySelectorAll(".page")], c = s.length, l = o.querySelector("#main-page"), u = o, d = r.querySelector("[data-role=\"export-modal\"]"), f = (e) => r.querySelector(`[data-role="${e}"]`), p = {
|
|
3757
|
+
prev: f("prev"),
|
|
3758
|
+
next: f("next"),
|
|
3759
|
+
current: f("current"),
|
|
3760
|
+
total: f("total"),
|
|
3761
|
+
zoom: no(f("zoom-dropdown")),
|
|
3762
|
+
zoomIn: f("zoom-in"),
|
|
3763
|
+
zoomOut: f("zoom-out"),
|
|
3764
|
+
print: f("print"),
|
|
3765
|
+
exportOpen: f("export"),
|
|
3766
|
+
query: f("query"),
|
|
3767
|
+
hits: f("hits"),
|
|
3768
|
+
hitPrev: f("hit-prev"),
|
|
3769
|
+
hitNext: f("hit-next")
|
|
3770
|
+
}, m = d ? {
|
|
3771
|
+
root: d,
|
|
3772
|
+
card: d.querySelector(".modal-card"),
|
|
3773
|
+
backdrop: d.querySelector("[data-role=\"export-backdrop\"]"),
|
|
3774
|
+
summary: d.querySelector("[data-role=\"export-summary\"]"),
|
|
3775
|
+
cancel: d.querySelector("[data-role=\"export-cancel\"]"),
|
|
3776
|
+
confirm: d.querySelector("[data-role=\"export-confirm\"]"),
|
|
3777
|
+
formats: [...d.querySelectorAll("input[name=\"export-format\"]")]
|
|
3778
|
+
} : null, h = 0, g = [], _ = -1, v = 1, y = !1, b = null, x = a.onafterprint !== void 0;
|
|
3779
|
+
p.total.textContent = String(c), p.current.max = String(c);
|
|
3780
|
+
function S(e) {
|
|
3781
|
+
h = Math.min(Math.max(e, 0), c - 1), s.forEach((e, t) => e.classList.toggle("is-current", t === h)), p.current.value = String(h + 1), p.prev.disabled = h === 0, p.next.disabled = h === c - 1, le(), u.scrollTo?.({ top: 0 });
|
|
3782
|
+
}
|
|
3783
|
+
function C() {
|
|
3784
|
+
if (u.style.setProperty("--zoom", String(v)), l && (l.style.width = `${t.page.width * v}px`, l.style.height = `${t.page.height * v}px`), !y) {
|
|
3785
|
+
let e = $.find((e) => Math.abs(e - v) < 1e-9);
|
|
3786
|
+
p.zoom.value = e === void 0 ? "fit" : String(e);
|
|
3787
|
+
}
|
|
3788
|
+
p.zoomOut.disabled = !y && v <= io, p.zoomIn.disabled = !y && v >= ao;
|
|
3789
|
+
}
|
|
3790
|
+
function w(e) {
|
|
3791
|
+
y = !1, v = Math.min(Math.max(e, io), ao), C();
|
|
3792
|
+
}
|
|
3793
|
+
function T() {
|
|
3794
|
+
y = !0, p.zoom.value = "fit";
|
|
3795
|
+
let e = u.clientWidth - 48;
|
|
3796
|
+
e > 0 && (v = Math.min(Math.max(e / t.page.width, io), ao)), C();
|
|
3797
|
+
}
|
|
3798
|
+
function E(e) {
|
|
3799
|
+
let t = v;
|
|
3800
|
+
w((e > 0 ? $.find((e) => e > t + 1e-9) : [...$].reverse().find((e) => e < t - 1e-9)) ?? t);
|
|
3801
|
+
}
|
|
3802
|
+
let D = {
|
|
3803
|
+
pdf: {
|
|
3804
|
+
available: () => !0,
|
|
3805
|
+
summary: () => `${c} page${c === 1 ? "" : "s"}, ${t.page.width}×${t.page.height}px each.`,
|
|
3806
|
+
run: () => O()
|
|
3807
|
+
},
|
|
3808
|
+
csv: {
|
|
3809
|
+
available: () => _r(t.pages) !== "",
|
|
3810
|
+
summary: () => D.csv.available() ? `Downloads ${U(t, "csv")}.` : "This report has nothing to write out.",
|
|
3811
|
+
run: () => re()
|
|
3812
|
+
},
|
|
3813
|
+
xlsx: {
|
|
3814
|
+
available: () => D.csv.available() || nr(t.pages).length > 0,
|
|
3815
|
+
summary: () => D.xlsx.available() ? `Downloads ${U(t, "xlsx")}.` : "This report has nothing to write out.",
|
|
3816
|
+
run: () => ie()
|
|
3817
|
+
}
|
|
3818
|
+
};
|
|
3819
|
+
function O() {
|
|
3820
|
+
let e = [...o.querySelectorAll("img")].filter((e) => !e.complete);
|
|
3821
|
+
if (e.length > 0) {
|
|
3822
|
+
Promise.all(e.map((e) => e.decode().catch(() => {}))).then(ee);
|
|
3823
|
+
return;
|
|
3824
|
+
}
|
|
3825
|
+
ee();
|
|
3826
|
+
}
|
|
3827
|
+
function ee() {
|
|
3828
|
+
ce(), a.print(), x || te();
|
|
3829
|
+
}
|
|
3830
|
+
function te() {
|
|
3831
|
+
p.query.value.trim() !== "" && le();
|
|
3832
|
+
}
|
|
3833
|
+
function ne() {
|
|
3834
|
+
let { width: e, height: n } = t.page, r = i.getElementById("report-page-size");
|
|
3835
|
+
r || (r = i.createElement("style"), r.id = "report-page-size", i.head.appendChild(r)), r.textContent = `@page { size: ${e}px ${n}px; margin: 0; }`;
|
|
3836
|
+
}
|
|
3837
|
+
function re() {
|
|
3838
|
+
let e = _r(t.pages);
|
|
3839
|
+
return e === "" ? !1 : (k(new Blob(["", e], { type: "text/csv;charset=utf-8" }), U(t, "csv")), !0);
|
|
3840
|
+
}
|
|
3841
|
+
function ie() {
|
|
3842
|
+
if (!D.xlsx.available()) return !1;
|
|
3843
|
+
let e = (e) => {
|
|
3844
|
+
e.length > 0 && k(new Blob([e], { type: Ri }), U(t, "xlsx"));
|
|
3845
|
+
};
|
|
3846
|
+
if (pa(t.pages).length > 0) return fa(t.pages).then(e, () => e(da(t.pages))), !0;
|
|
3847
|
+
let n = da(t.pages);
|
|
3848
|
+
return n.length === 0 ? !1 : (e(n), !0);
|
|
3849
|
+
}
|
|
3850
|
+
function k(e, t) {
|
|
3851
|
+
let n = URL.createObjectURL(e), r = i.createElement("a");
|
|
3852
|
+
r.href = n, r.download = t, i.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
3853
|
+
}
|
|
3854
|
+
function A() {
|
|
3855
|
+
return m?.formats.find((e) => e.checked)?.value ?? "pdf";
|
|
3856
|
+
}
|
|
3857
|
+
function j() {
|
|
3858
|
+
if (!m) return;
|
|
3859
|
+
for (let e of m.formats) {
|
|
3860
|
+
let t = D[e.value];
|
|
3861
|
+
e.disabled = !t || !t.available(), e.closest(".format")?.classList.toggle("is-unavailable", e.disabled);
|
|
3862
|
+
}
|
|
3863
|
+
if (m.formats.find((e) => e.checked)?.disabled) {
|
|
3864
|
+
let e = m.formats.find((e) => !e.disabled);
|
|
3865
|
+
e && (e.checked = !0);
|
|
3866
|
+
}
|
|
3867
|
+
let e = D[A()];
|
|
3868
|
+
m.summary.textContent = e ? e.summary() : "", m.confirm.disabled = !e || !e.available();
|
|
3869
|
+
}
|
|
3870
|
+
function M() {
|
|
3871
|
+
m && (b = i.activeElement, m.root.hidden = !1, j(), (m.formats.find((e) => e.checked && !e.disabled) ?? m.formats.find((e) => !e.disabled) ?? m.cancel).focus());
|
|
3872
|
+
}
|
|
3873
|
+
function N() {
|
|
3874
|
+
!m || m.root.hidden || (m.root.hidden = !0, b?.focus?.(), b = null);
|
|
3875
|
+
}
|
|
3876
|
+
function ae() {
|
|
3877
|
+
let e = D[A()];
|
|
3878
|
+
e?.available() && (N(), e.run());
|
|
3879
|
+
}
|
|
3880
|
+
function oe(e) {
|
|
3881
|
+
let t = [...m.card.querySelectorAll("button, input")].filter((e) => !e.disabled);
|
|
3882
|
+
if (!t.length) return;
|
|
3883
|
+
let n = t[0], r = t[t.length - 1];
|
|
3884
|
+
e.shiftKey && i.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && i.activeElement === r && (e.preventDefault(), n.focus());
|
|
3885
|
+
}
|
|
3886
|
+
function P() {
|
|
3887
|
+
let e = p.query.value.trim();
|
|
3888
|
+
if (ce(), e === "") {
|
|
3889
|
+
g = [], _ = -1, p.hits.textContent = "", p.hits.dataset.state = "idle", se();
|
|
3890
|
+
return;
|
|
3891
|
+
}
|
|
3892
|
+
if (g = Gn(t.pages, e), _ = g.length ? 0 : -1, p.hits.dataset.state = g.length ? "found" : "empty", se(), !g.length) {
|
|
3893
|
+
p.hits.textContent = "no matches";
|
|
3894
|
+
return;
|
|
3895
|
+
}
|
|
3896
|
+
let n = Kn(t.pages, e).length;
|
|
3897
|
+
p.hits.textContent = `${g.length} on ${n} page${n === 1 ? "" : "s"}`, F(0);
|
|
3898
|
+
}
|
|
3899
|
+
function F(e) {
|
|
3900
|
+
if (!g.length) return;
|
|
3901
|
+
_ = (e + g.length) % g.length;
|
|
3902
|
+
let t = g[_].pageNO - 1;
|
|
3903
|
+
t === h ? le() : S(t), p.hits.textContent = `${_ + 1} of ${g.length}`, de();
|
|
3904
|
+
}
|
|
3905
|
+
function se() {
|
|
3906
|
+
p.hitPrev.disabled = g.length === 0, p.hitNext.disabled = g.length === 0;
|
|
3907
|
+
}
|
|
3908
|
+
function ce() {
|
|
3909
|
+
for (let e of u.querySelectorAll("mark.hit")) {
|
|
3910
|
+
let t = e.parentNode;
|
|
3911
|
+
t.replaceChild(i.createTextNode(e.textContent), e), t.normalize();
|
|
3912
|
+
}
|
|
3913
|
+
}
|
|
3914
|
+
function le() {
|
|
3915
|
+
ce();
|
|
3916
|
+
let e = p.query.value.trim();
|
|
3917
|
+
if (e === "") return;
|
|
3918
|
+
let t = s[h];
|
|
3919
|
+
if (!t) return;
|
|
3920
|
+
let n = e.toLowerCase(), r = i.createTreeWalker(t, NodeFilter.SHOW_TEXT), a = [];
|
|
3921
|
+
for (; r.nextNode();) {
|
|
3922
|
+
let e = r.currentNode;
|
|
3923
|
+
e.nodeValue.toLowerCase().includes(n) && a.push(e);
|
|
3924
|
+
}
|
|
3925
|
+
for (let e of a) ue(e, n);
|
|
3926
|
+
}
|
|
3927
|
+
function ue(e, t) {
|
|
3928
|
+
let n = e.nodeValue, r = i.createDocumentFragment(), a = 0;
|
|
3929
|
+
for (;;) {
|
|
3930
|
+
let e = n.toLowerCase().indexOf(t, a);
|
|
3931
|
+
if (e === -1) break;
|
|
3932
|
+
e > a && r.appendChild(i.createTextNode(n.slice(a, e)));
|
|
3933
|
+
let o = i.createElement("mark");
|
|
3934
|
+
o.className = "hit", o.textContent = n.slice(e, e + t.length), r.appendChild(o), a = e + t.length;
|
|
3935
|
+
}
|
|
3936
|
+
a < n.length && r.appendChild(i.createTextNode(n.slice(a))), e.parentNode.replaceChild(r, e);
|
|
3937
|
+
}
|
|
3938
|
+
function de() {
|
|
3939
|
+
let e = [...u.querySelectorAll("mark.hit")];
|
|
3940
|
+
if (!e.length) return;
|
|
3941
|
+
let t = g.filter((e) => e.pageNO === h + 1).indexOf(g[_]), n = e[Math.max(t, 0)] ?? e[0];
|
|
3942
|
+
e.forEach((e) => e.classList.remove("is-focused")), n.classList.add("is-focused"), n.scrollIntoView?.({
|
|
3943
|
+
block: "center",
|
|
3944
|
+
behavior: "smooth"
|
|
3945
|
+
});
|
|
3946
|
+
}
|
|
3947
|
+
if (p.prev.addEventListener("click", () => S(h - 1)), p.next.addEventListener("click", () => S(h + 1)), p.current.addEventListener("change", () => {
|
|
3948
|
+
let e = Number(p.current.value);
|
|
3949
|
+
Number.isFinite(e) ? S(e - 1) : p.current.value = String(h + 1);
|
|
3950
|
+
}), p.print?.addEventListener("click", O), p.exportOpen.addEventListener("click", M), m) {
|
|
3951
|
+
m.cancel.addEventListener("click", N), m.backdrop.addEventListener("click", N), m.confirm.addEventListener("click", ae);
|
|
3952
|
+
for (let e of m.formats) e.addEventListener("change", j);
|
|
3953
|
+
m.root.addEventListener("keydown", (e) => {
|
|
3954
|
+
e.key === "Tab" && oe(e), e.key === "Enter" && (e.preventDefault(), ae());
|
|
3955
|
+
});
|
|
3956
|
+
}
|
|
3957
|
+
p.zoomIn.addEventListener("click", () => E(1)), p.zoomOut.addEventListener("click", () => E(-1)), p.zoom.addEventListener("change", () => {
|
|
3958
|
+
p.zoom.value === "fit" ? T() : w(Number(p.zoom.value));
|
|
3959
|
+
});
|
|
3960
|
+
let fe = () => {
|
|
3961
|
+
y && T();
|
|
3962
|
+
};
|
|
3963
|
+
a.addEventListener("resize", fe), p.hitPrev.addEventListener("click", () => F(_ - 1)), p.hitNext.addEventListener("click", () => F(_ + 1));
|
|
3964
|
+
let pe;
|
|
3965
|
+
p.query.addEventListener("input", () => {
|
|
3966
|
+
clearTimeout(pe), pe = setTimeout(P, 150);
|
|
3967
|
+
}), p.query.addEventListener("keydown", (e) => {
|
|
3968
|
+
e.key === "Enter" && (e.preventDefault(), g.length ? F(_ + (e.shiftKey ? -1 : 1)) : P());
|
|
3969
|
+
});
|
|
3970
|
+
let I = (e) => {
|
|
3971
|
+
if (m && !m.root.hidden) {
|
|
3972
|
+
e.key === "Escape" && (e.preventDefault(), N());
|
|
3973
|
+
return;
|
|
3974
|
+
}
|
|
3975
|
+
if ((e.ctrlKey || e.metaKey) && ["k", "f"].includes(e.key.toLowerCase())) {
|
|
3976
|
+
e.preventDefault(), p.query.focus(), p.query.select();
|
|
3977
|
+
return;
|
|
3978
|
+
}
|
|
3979
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "p") {
|
|
3980
|
+
e.preventDefault(), O();
|
|
3981
|
+
return;
|
|
3982
|
+
}
|
|
3983
|
+
if (!(e.target === p.query || e.target === p.current)) {
|
|
3984
|
+
if ((e.ctrlKey || e.metaKey) && ["x", "s"].includes(e.key.toLowerCase())) {
|
|
3985
|
+
e.preventDefault(), M();
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3988
|
+
(e.key === "ArrowRight" || e.key === "PageDown") && S(h + 1), (e.key === "ArrowLeft" || e.key === "PageUp") && S(h - 1), e.key === "Home" && S(0), e.key === "End" && S(c - 1), (e.ctrlKey || e.metaKey) && ((e.key === "+" || e.key === "=") && (e.preventDefault(), E(1)), e.key === "-" && (e.preventDefault(), E(-1)), e.key === "0" && (e.preventDefault(), w(1)));
|
|
3989
|
+
}
|
|
3990
|
+
};
|
|
3991
|
+
i.addEventListener("keydown", I), x && a.addEventListener("afterprint", te);
|
|
3992
|
+
function me() {
|
|
3993
|
+
p.zoom.destroy(), i.removeEventListener("keydown", I), a.removeEventListener("resize", fe), a.removeEventListener("afterprint", te), r.innerHTML = "", r.classList.remove("report-viewer");
|
|
3994
|
+
}
|
|
3995
|
+
return ne(), C(), S(0), se(), {
|
|
3996
|
+
show: S,
|
|
3997
|
+
next: () => S(h + 1),
|
|
3998
|
+
prev: () => S(h - 1),
|
|
3999
|
+
find: (e) => {
|
|
4000
|
+
p.query.value = e, P();
|
|
4001
|
+
},
|
|
4002
|
+
print: O,
|
|
4003
|
+
downloadCSV: re,
|
|
4004
|
+
downloadXLSX: ie,
|
|
4005
|
+
openExport: M,
|
|
4006
|
+
closeExport: N,
|
|
4007
|
+
confirmExport: ae,
|
|
4008
|
+
destroy: me,
|
|
4009
|
+
get exportOpen() {
|
|
4010
|
+
return m ? !m.root.hidden : !1;
|
|
4011
|
+
},
|
|
4012
|
+
setZoom: w,
|
|
4013
|
+
zoomIn: () => E(1),
|
|
4014
|
+
zoomOut: () => E(-1),
|
|
4015
|
+
fitWidth: T,
|
|
4016
|
+
get zoom() {
|
|
4017
|
+
return v;
|
|
4018
|
+
},
|
|
4019
|
+
get page() {
|
|
4020
|
+
return h + 1;
|
|
4021
|
+
},
|
|
4022
|
+
get pageCount() {
|
|
4023
|
+
return c;
|
|
4024
|
+
}
|
|
4025
|
+
};
|
|
4026
|
+
}
|
|
4027
|
+
//#endregion
|
|
4028
|
+
export { de as $, zt as A, Ae as B, Kn as C, Xt as D, Dn as E, at as F, L as G, ge as H, Ve as I, E as J, T as K, Je as L, H as M, bt as N, Lt as O, it as P, k as Q, Ze as R, Gn as S, En as T, ve as U, je as V, ye as W, y as X, v as Y, ae as Z, ci as _, oo as a, t as at, _r as b, eo as c, h as ct, Ri as d, s as dt, j as et, pa as f, o as ft, mi as g, Z as h, so as i, r as it, Ht as j, Rt as k, Ja as l, m as lt, fa as m, e as mt, io as n, n as nt, no as o, d as ot, da as p, g as pt, D as q, $ as r, i as rt, to as s, c as st, ao as t, M as tt, Ga as u, a as ut, U as v, An as w, nr as x, gr as y, Xe as z };
|