report-studio 1.2.1 → 1.2.3
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 +28 -2
- package/dist/{designer-Be8PdEYf.js → designer-DQlfKnTr.js} +928 -928
- package/dist/designer.js +1 -1
- package/dist/index.js +2 -2
- package/dist/react-designer.js +1 -1
- package/dist/react.js +2 -1
- package/dist/viewer-BSPNCNRU.js +2912 -0
- package/package.json +1 -1
- package/src/engine/csv.js +12 -197
- package/src/engine/index.js +1 -0
- package/src/engine/rows.js +456 -0
- package/src/engine/xlsx-drawing.js +313 -0
- package/src/engine/xlsx-style.js +457 -0
- package/src/engine/xlsx.js +1200 -0
- package/src/engine/zip.js +138 -0
- package/src/index.js +5 -1
- package/src/preview/chrome.js +8 -0
- package/src/preview/viewer.js +42 -1
- package/src/react/index.js +3 -3
- package/types/index.d.ts +53 -0
- package/dist/viewer-5nSb_EH2.js +0 -1727
|
@@ -0,0 +1,2912 @@
|
|
|
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
|
+
function n(e) {
|
|
11
|
+
return typeof e?.groupBy == "string" && e.groupBy !== "";
|
|
12
|
+
}
|
|
13
|
+
function r(t) {
|
|
14
|
+
let r = e(t), i = r.find(n);
|
|
15
|
+
return i ? {
|
|
16
|
+
table: i,
|
|
17
|
+
by: i.groupBy
|
|
18
|
+
} : t?.groupBy != null && r.length > 0 ? {
|
|
19
|
+
table: r[0],
|
|
20
|
+
by: t.groupBy
|
|
21
|
+
} : null;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region src/engine/text-metrics.js
|
|
25
|
+
var i = 1.3, a = /* @__PURE__ */ new Map(), o = 1e4, s, c = !1;
|
|
26
|
+
function l() {
|
|
27
|
+
if (c) return s;
|
|
28
|
+
c = !0;
|
|
29
|
+
try {
|
|
30
|
+
s = typeof OffscreenCanvas < "u" ? new OffscreenCanvas(1, 1).getContext("2d") : typeof document < "u" ? document.createElement("canvas").getContext("2d") : null;
|
|
31
|
+
} catch {
|
|
32
|
+
s = null;
|
|
33
|
+
}
|
|
34
|
+
return s;
|
|
35
|
+
}
|
|
36
|
+
function u(e = {}) {
|
|
37
|
+
return `${e.fontStyle || "normal"} ${e.fontWeight || "normal"} ${e.fontSize ?? 12}px ${e.fontFamily || "Helvetica, Arial, sans-serif"}`;
|
|
38
|
+
}
|
|
39
|
+
function d(e, t) {
|
|
40
|
+
let n = String(e ?? "");
|
|
41
|
+
if (n === "") return 0;
|
|
42
|
+
let r = u(t), i = `${r}\u0000${n}`, s = a.get(i);
|
|
43
|
+
if (s !== void 0) return s;
|
|
44
|
+
let c = l(), d;
|
|
45
|
+
return c ? (c.font = r, d = c.measureText(n).width) : d = f(n, t), a.size >= o && a.clear(), a.set(i, d), d;
|
|
46
|
+
}
|
|
47
|
+
function f(e, t = {}) {
|
|
48
|
+
let n = t.fontSize ?? 12, r = String(t.fontWeight) === "bold" || Number(t.fontWeight) >= 600, i = /mono|courier|consolas/i.test(t.fontFamily || ""), a = 0;
|
|
49
|
+
for (let t of e) {
|
|
50
|
+
if (i) {
|
|
51
|
+
a += .6;
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
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;
|
|
55
|
+
}
|
|
56
|
+
return a * n * (r ? 1.06 : 1);
|
|
57
|
+
}
|
|
58
|
+
function p(e, t, n) {
|
|
59
|
+
let r = String(e ?? "").split("\n");
|
|
60
|
+
if (!(t > 0)) return r;
|
|
61
|
+
let i = [];
|
|
62
|
+
for (let e of r) {
|
|
63
|
+
let r = e.split(/(\s+)/).filter((e) => e !== "");
|
|
64
|
+
if (r.length === 0) {
|
|
65
|
+
i.push("");
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
let a = "";
|
|
69
|
+
for (let e of r) {
|
|
70
|
+
let r = a + e;
|
|
71
|
+
for (a !== "" && d(r, n) > t ? (i.push(a.trimEnd()), a = e.trimStart()) : a = r; d(a, n) > t && a.trim().length > 1;) {
|
|
72
|
+
let e = a.length;
|
|
73
|
+
for (; e > 1 && d(a.slice(0, e), n) > t;) e--;
|
|
74
|
+
if (e >= a.length) break;
|
|
75
|
+
i.push(a.slice(0, e)), a = a.slice(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
i.push(a.trimEnd());
|
|
79
|
+
}
|
|
80
|
+
return i;
|
|
81
|
+
}
|
|
82
|
+
function m(e, t, n) {
|
|
83
|
+
let r = Math.ceil((n?.fontSize ?? 12) * i);
|
|
84
|
+
return p(e, t, n).length * r;
|
|
85
|
+
}
|
|
86
|
+
function h(e) {
|
|
87
|
+
return {
|
|
88
|
+
fontSize: e.style?.fontSize ?? 12,
|
|
89
|
+
fontFamily: e.style?.fontFamily,
|
|
90
|
+
fontWeight: "normal",
|
|
91
|
+
fontStyle: "normal"
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
function g(e) {
|
|
95
|
+
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;
|
|
96
|
+
return t.map((e) => e * i);
|
|
97
|
+
}
|
|
98
|
+
function _(e) {
|
|
99
|
+
if (e.style?.borderStyle === "none") return 0;
|
|
100
|
+
let t = Number(e.style?.borderWidth);
|
|
101
|
+
return Number.isFinite(t) && t > 0 ? t : 1;
|
|
102
|
+
}
|
|
103
|
+
function v(e) {
|
|
104
|
+
let t = g(e), n = _(e), r = t.length - 1;
|
|
105
|
+
return t.map((e, t) => e - 16 - n * (t === r ? 2 : 1));
|
|
106
|
+
}
|
|
107
|
+
function y(e, t) {
|
|
108
|
+
let n = e.rowHeight ?? 0, r = t ?? [];
|
|
109
|
+
if (e.wrap === !1) return r.map(() => n);
|
|
110
|
+
let i = h(e), a = e.columns ?? [], o = v(e);
|
|
111
|
+
return r.map((e) => {
|
|
112
|
+
let t = n;
|
|
113
|
+
for (let [n, r] of a.entries()) {
|
|
114
|
+
let a = o[n];
|
|
115
|
+
if (!(a > 0)) continue;
|
|
116
|
+
let s = e?.[r.field];
|
|
117
|
+
s == null || s === "" || (t = Math.max(t, m(String(s), a, i)));
|
|
118
|
+
}
|
|
119
|
+
return t;
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
function b(e) {
|
|
123
|
+
if (!e.showHeader) return 0;
|
|
124
|
+
let t = e.headerHeight ?? e.rowHeight ?? 0;
|
|
125
|
+
if (e.wrap === !1) return t;
|
|
126
|
+
let n = (e.columns ?? []).map((e, t) => ({
|
|
127
|
+
...e,
|
|
128
|
+
field: `label${t}`
|
|
129
|
+
})), r = Object.fromEntries((e.columns ?? []).map((e, t) => [`label${t}`, e.label])), [i] = y({
|
|
130
|
+
...e,
|
|
131
|
+
rowHeight: t,
|
|
132
|
+
columns: n
|
|
133
|
+
}, [r]);
|
|
134
|
+
return i ?? t;
|
|
135
|
+
}
|
|
136
|
+
function x(e) {
|
|
137
|
+
if (e.type !== "table") return e.h ?? 0;
|
|
138
|
+
let t = e.rowHeight ?? 0;
|
|
139
|
+
return (e.showHeader ? e.headerHeight ?? t : 0) + 3 * t;
|
|
140
|
+
}
|
|
141
|
+
function S(e) {
|
|
142
|
+
let t = structuredClone(e);
|
|
143
|
+
for (let e of t.bands) e.items && C(e, t);
|
|
144
|
+
return t;
|
|
145
|
+
}
|
|
146
|
+
function C(e, t) {
|
|
147
|
+
let n = 0;
|
|
148
|
+
for (let r of e.items) r.measuredHeight = T(r, t), n = Math.max(n, (r.y ?? 0) + r.measuredHeight);
|
|
149
|
+
return e.contentHeight = n, e.measuredHeight = w(e) ? n : Math.max(e.height ?? 0, n), e;
|
|
150
|
+
}
|
|
151
|
+
function w(e) {
|
|
152
|
+
return e.items.some((e) => e.type === "table");
|
|
153
|
+
}
|
|
154
|
+
function T(e, t) {
|
|
155
|
+
switch (e.type) {
|
|
156
|
+
case "text": return E(e);
|
|
157
|
+
case "table": return O(e, t);
|
|
158
|
+
case "line": return D(e);
|
|
159
|
+
case "box":
|
|
160
|
+
case "image": return e.h ?? 0;
|
|
161
|
+
default: return console.warn(`Unknown item type "${e.type}" on item "${e.id}"; treating as zero height.`), 0;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
function E(e) {
|
|
165
|
+
let t = e.h ?? 0, n = m(e.text ?? e.value ?? "", e.w ?? 0, e.style);
|
|
166
|
+
return Math.max(t, n);
|
|
167
|
+
}
|
|
168
|
+
function D(e) {
|
|
169
|
+
let t = e.h ?? 0;
|
|
170
|
+
return e.orientation === "vertical" ? t : Math.max(t, e.style?.thickness ?? 0);
|
|
171
|
+
}
|
|
172
|
+
function O(e, t) {
|
|
173
|
+
let n = b(e);
|
|
174
|
+
if (e.headerMeasured = n, !Array.isArray(e.groups)) return e.rowHeights = y(e, e.row), n + k(e.rowHeights);
|
|
175
|
+
let r = e.groups ?? [], i = A(t, "groupHeader"), a = A(t, "groupFooter"), o = 0;
|
|
176
|
+
for (let t of r) t.rowHeights = y(e, t.rows), o += n + i + k(t.rowHeights) + a;
|
|
177
|
+
return o;
|
|
178
|
+
}
|
|
179
|
+
function k(e) {
|
|
180
|
+
return (e ?? []).reduce((e, t) => e + t, 0);
|
|
181
|
+
}
|
|
182
|
+
function A(e, t) {
|
|
183
|
+
let n = e.bands.find((e) => e.type === t);
|
|
184
|
+
if (!n?.items) return 0;
|
|
185
|
+
let r = 0;
|
|
186
|
+
for (let e of n.items) {
|
|
187
|
+
let t = e.type === "text" ? E(e) : 0;
|
|
188
|
+
r = Math.max(r, (e.y ?? 0) + t);
|
|
189
|
+
}
|
|
190
|
+
return Math.max(n.height ?? 0, r);
|
|
191
|
+
}
|
|
192
|
+
//#endregion
|
|
193
|
+
//#region src/engine/validate.js
|
|
194
|
+
var ee = [
|
|
195
|
+
"reportHeader",
|
|
196
|
+
"pageHeader",
|
|
197
|
+
"groupHeader",
|
|
198
|
+
"detail",
|
|
199
|
+
"groupFooter",
|
|
200
|
+
"reportFooter",
|
|
201
|
+
"pageFooter"
|
|
202
|
+
], te = [
|
|
203
|
+
"text",
|
|
204
|
+
"table",
|
|
205
|
+
"line",
|
|
206
|
+
"box",
|
|
207
|
+
"image"
|
|
208
|
+
], j = ["horizontal", "vertical"], M = [
|
|
209
|
+
"solid",
|
|
210
|
+
"dashed",
|
|
211
|
+
"dotted",
|
|
212
|
+
"double"
|
|
213
|
+
], N = [...M, "none"], P = [
|
|
214
|
+
"contain",
|
|
215
|
+
"cover",
|
|
216
|
+
"fill"
|
|
217
|
+
], F = class extends Error {
|
|
218
|
+
constructor(e, t = []) {
|
|
219
|
+
super(t.length ? `${e}\n - ${t.join("\n - ")}` : e), this.name = "ReportError", this.issues = t;
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
function I(e) {
|
|
223
|
+
let t = [];
|
|
224
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return ["layout must be an object"];
|
|
225
|
+
if (re(e.page, t), !Array.isArray(e.bands)) return t.push("layout.bands must be an array"), t;
|
|
226
|
+
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");
|
|
227
|
+
let n = /* @__PURE__ */ new Set();
|
|
228
|
+
return e.bands.forEach((e, r) => {
|
|
229
|
+
let i = `bands[${r}]`;
|
|
230
|
+
if (typeof e != "object" || !e) {
|
|
231
|
+
t.push(`${i} must be an object`);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
if (ee.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: ${ee.join(", ")}`), !Array.isArray(e.items)) {
|
|
235
|
+
t.push(`${i}.items must be an array`);
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
e.items.forEach((e, n) => ie(e, `${i}.items[${n}]`, t));
|
|
239
|
+
}), 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"), ne(e, e.bands, t), t;
|
|
240
|
+
}
|
|
241
|
+
function ne(t, r, i) {
|
|
242
|
+
let a = e(t);
|
|
243
|
+
for (let e of a) e.groupBy != null && typeof e.groupBy != "string" && i.push(`table "${e.id}".groupBy must be a field name or null`), e.dataset != null && typeof e.dataset != "string" && i.push(`table "${e.id}".dataset must be a dataset name or null`);
|
|
244
|
+
let o = a.filter(n);
|
|
245
|
+
o.length > 1 && i.push(`${o.length} tables are grouped (${o.map((e) => `"${e.id}"`).join(", ")}); a report groups one, because groupHeader and groupFooter are shared`), o.length > 0 && t.groupBy == null && !r.some((e) => e?.type === "groupHeader" || e?.type === "groupFooter") && i.push(`table "${o[0].id}" is grouped by "${o[0].groupBy}" but there is no groupHeader or groupFooter band to show it`);
|
|
246
|
+
for (let e of r) {
|
|
247
|
+
if (!Array.isArray(e?.items)) continue;
|
|
248
|
+
let t = e.items.filter((e) => e?.type === "table").map((e) => ({
|
|
249
|
+
item: e,
|
|
250
|
+
top: Number(e.y) || 0,
|
|
251
|
+
bottom: (Number(e.y) || 0) + x(e)
|
|
252
|
+
})).sort((e, t) => e.top - t.top);
|
|
253
|
+
for (let n = 1; n < t.length; n++) {
|
|
254
|
+
let r = t[n - 1], a = t[n];
|
|
255
|
+
a.top < r.bottom && i.push(`tables "${r.item.id}" and "${a.item.id}" overlap in the ${e.type} band; move "${a.item.id}" to y ${Math.ceil(r.bottom)} or lower - tables are stacked, one under another, not placed side by side`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
function re(e, t) {
|
|
260
|
+
if (typeof e != "object" || !e) {
|
|
261
|
+
t.push("layout.page must be an object with width, height and margin");
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
for (let n of ["width", "height"]) typeof e[n] == "number" && e[n] > 0 || t.push(`layout.page.${n} must be a positive number`);
|
|
265
|
+
if (e.margin == null || typeof e.margin != "object") {
|
|
266
|
+
t.push("layout.page.margin must be an object with top, right, bottom and left");
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
for (let n of [
|
|
270
|
+
"top",
|
|
271
|
+
"right",
|
|
272
|
+
"bottom",
|
|
273
|
+
"left"
|
|
274
|
+
]) typeof e.margin[n] == "number" && e.margin[n] >= 0 || t.push(`layout.page.margin.${n} must be a number of pixels`);
|
|
275
|
+
let n = e.height - (e.margin.top + e.margin.bottom);
|
|
276
|
+
n <= 0 && t.push(`layout.page margins leave no printable height (${n}px)`);
|
|
277
|
+
}
|
|
278
|
+
function ie(e, t, n) {
|
|
279
|
+
if (typeof e != "object" || !e) {
|
|
280
|
+
n.push(`${t} must be an object`);
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
if (!te.includes(e.type)) {
|
|
284
|
+
n.push(`${t}.type "${e.type}" is not one of: ${te.join(", ")}`);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if ((typeof e.id != "string" || e.id === "") && n.push(`${t}.id must be a non-empty string`), e.type === "text") {
|
|
288
|
+
typeof e.value != "string" && n.push(`${t}.value must be a string`);
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
if (e.type === "line") {
|
|
292
|
+
oe(e, t, n);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
if (e.type === "box") {
|
|
296
|
+
L(e, t, n);
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
if (e.type === "image") {
|
|
300
|
+
ae(e, t, n);
|
|
301
|
+
return;
|
|
302
|
+
}
|
|
303
|
+
if (typeof e.rowHeight == "number" && e.rowHeight > 0 || n.push(`${t}.rowHeight must be a positive number`), e.style?.borderStyle != null && !N.includes(e.style.borderStyle) && n.push(`${t}.style.borderStyle "${e.style.borderStyle}" is not one of: ` + N.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) {
|
|
304
|
+
n.push(`${t}.columns must be a non-empty array`);
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
e.columns.forEach((e, r) => {
|
|
308
|
+
(e == null || typeof e.field != "string" || e.field === "") && n.push(`${t}.columns[${r}].field must be a non-empty string`);
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
function L(e, t, n) {
|
|
312
|
+
let r = e.style;
|
|
313
|
+
if (r != null) {
|
|
314
|
+
if (typeof r != "object" || Array.isArray(r)) {
|
|
315
|
+
n.push(`${t}.style must be an object`);
|
|
316
|
+
return;
|
|
317
|
+
}
|
|
318
|
+
r.borderStyle != null && !N.includes(r.borderStyle) && n.push(`${t}.style.borderStyle "${r.borderStyle}" is not one of: ` + N.join(", "));
|
|
319
|
+
for (let e of ["borderWidth", "radius"]) {
|
|
320
|
+
let i = r[e], a = e === "radius" ? 0 : 1;
|
|
321
|
+
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"));
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
function ae(e, t, n) {
|
|
326
|
+
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 && !P.includes(e.fit) && n.push(`${t}.fit "${e.fit}" is not one of: ${P.join(", ")}`), e.alt != null && typeof e.alt != "string" && n.push(`${t}.alt must be a string`);
|
|
327
|
+
}
|
|
328
|
+
function oe(e, t, n) {
|
|
329
|
+
e.orientation != null && !j.includes(e.orientation) && n.push(`${t}.orientation "${e.orientation}" is not one of: ` + j.join(", "));
|
|
330
|
+
let r = e.style;
|
|
331
|
+
if (r != null) {
|
|
332
|
+
if (typeof r != "object" || Array.isArray(r)) {
|
|
333
|
+
n.push(`${t}.style must be an object`);
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
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 && !M.includes(r.lineStyle) && n.push(`${t}.style.lineStyle "${r.lineStyle}" is not one of: ` + M.join(", "));
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
function se(e, t) {
|
|
340
|
+
let n = I(e);
|
|
341
|
+
if (n.length) throw new F(`${t}: the layout file is not usable`, n);
|
|
342
|
+
}
|
|
343
|
+
function ce(e, t) {
|
|
344
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw new F(`${t}: data must be an object keyed by dataset name`);
|
|
345
|
+
}
|
|
346
|
+
//#endregion
|
|
347
|
+
//#region src/engine/resolve.js
|
|
348
|
+
var le = /\{([^{}]+)\}/g, ue = /^\w+\(.*\)$/, de = ["page", "totalPages"], fe = ["groupHeader", "groupFooter"], pe = le;
|
|
349
|
+
function me(e) {
|
|
350
|
+
return ue.test(e) || de.includes(e) || e === "today";
|
|
351
|
+
}
|
|
352
|
+
function he(e) {
|
|
353
|
+
return fe.includes(e);
|
|
354
|
+
}
|
|
355
|
+
function ge(e, t) {
|
|
356
|
+
se(e, "resolve"), ce(t, "resolve");
|
|
357
|
+
let n = structuredClone(e);
|
|
358
|
+
for (let e of n.bands) {
|
|
359
|
+
let n = fe.includes(e.type);
|
|
360
|
+
for (let r of e.items) r.type == "text" && (r.text = ve(r, t, n)), r.type == "image" && (r.resolvedSrc = _e(r, t));
|
|
361
|
+
}
|
|
362
|
+
return n;
|
|
363
|
+
}
|
|
364
|
+
function _e(e, t) {
|
|
365
|
+
let n = typeof e.field == "string" ? e.field.trim() : "";
|
|
366
|
+
if (n) {
|
|
367
|
+
let r = be(n, t);
|
|
368
|
+
if (typeof r == "string" && r !== "") return r;
|
|
369
|
+
e.src || console.warn(`Unresolved image field "${n}" on item "${e.id}".`);
|
|
370
|
+
}
|
|
371
|
+
return typeof e.src == "string" ? e.src : "";
|
|
372
|
+
}
|
|
373
|
+
function ve(e, t, n) {
|
|
374
|
+
return e.value.replace(le, (r, i) => ye(r, i.trim(), t, e, n));
|
|
375
|
+
}
|
|
376
|
+
function ye(e, t, n, r, i) {
|
|
377
|
+
if (ue.test(t) || de.includes(t)) return e;
|
|
378
|
+
if (t == "today") return (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
379
|
+
let a = be(t, n);
|
|
380
|
+
return a == null ? i ? e : (console.warn(`Unresolved placeholder "{${t}}" on item "${r.id}".`), "") : String(a);
|
|
381
|
+
}
|
|
382
|
+
function be(e, t) {
|
|
383
|
+
return e.replace(/\[(\d+)\]/g, ".$1").split(".").filter((e) => e !== "").reduce((e, t) => e?.[t], t);
|
|
384
|
+
}
|
|
385
|
+
//#endregion
|
|
386
|
+
//#region src/engine/group.js
|
|
387
|
+
var xe = /\{([^{}]+)\}/g;
|
|
388
|
+
function Se(n, i) {
|
|
389
|
+
let a = structuredClone(n), o = a.bands, s = e(a);
|
|
390
|
+
if (a.groupBy != null && s.length === 0) throw new F(`group: layout.groupBy is "${a.groupBy}" but no band contains a table to group`);
|
|
391
|
+
let c = r(a), l = we(i), u = s.map((e) => {
|
|
392
|
+
let n = Te(e, a, i);
|
|
393
|
+
return l.set(t(e, a), n), {
|
|
394
|
+
table: e,
|
|
395
|
+
rows: n
|
|
396
|
+
};
|
|
397
|
+
});
|
|
398
|
+
for (let { table: e, rows: n } of u) e === c?.table ? Ce(e, n, c.by, o, t(e, a)) : e.row = n;
|
|
399
|
+
return De(o, {
|
|
400
|
+
rows: u[0]?.rows ?? [],
|
|
401
|
+
named: l
|
|
402
|
+
}), a;
|
|
403
|
+
}
|
|
404
|
+
function Ce(e, t, n, r, i) {
|
|
405
|
+
let a = Pe(t, n), o = je(r, a, i);
|
|
406
|
+
e.groups = Object.entries(a).map(([e, t]) => ({
|
|
407
|
+
key: e,
|
|
408
|
+
rows: t,
|
|
409
|
+
aggregates: o[e]
|
|
410
|
+
}));
|
|
411
|
+
}
|
|
412
|
+
function we(e) {
|
|
413
|
+
let t = /* @__PURE__ */ new Map();
|
|
414
|
+
for (let [n, r] of Object.entries(e ?? {})) Array.isArray(r) && t.set(n, r);
|
|
415
|
+
return t;
|
|
416
|
+
}
|
|
417
|
+
function Te(e, n, r) {
|
|
418
|
+
let i = t(e, n), a = i == null ? void 0 : r[i];
|
|
419
|
+
if (a === void 0) throw new F(`group: table "${e.id}" is bound to dataset "${i}", which is not present in the data`);
|
|
420
|
+
if (!Array.isArray(a)) throw new F(`group: dataset "${i}" must be an array of rows, got ${typeof a}`);
|
|
421
|
+
return a;
|
|
422
|
+
}
|
|
423
|
+
var Ee = ["groupHeader", "groupFooter"];
|
|
424
|
+
function De(e, t) {
|
|
425
|
+
for (let n of e) if (!Ee.includes(n.type)) for (let e of n.items) e.type == "text" && (e.text = Oe(e.text ?? e.value, t));
|
|
426
|
+
}
|
|
427
|
+
function Oe(e, t) {
|
|
428
|
+
return e.replace(xe, (e, n) => {
|
|
429
|
+
let r = Ae(n.trim());
|
|
430
|
+
if (!r) return e;
|
|
431
|
+
let { rows: i, field: a } = ke(r.field, t), o = Fe({
|
|
432
|
+
key: r.key,
|
|
433
|
+
field: a
|
|
434
|
+
}, i);
|
|
435
|
+
return o == null ? "" : String(o);
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
function ke(e, t) {
|
|
439
|
+
if (t.named.has(e)) return {
|
|
440
|
+
rows: t.named.get(e),
|
|
441
|
+
field: ""
|
|
442
|
+
};
|
|
443
|
+
let n = e.indexOf(".");
|
|
444
|
+
if (n > 0) {
|
|
445
|
+
let r = e.slice(0, n);
|
|
446
|
+
if (t.named.has(r)) return {
|
|
447
|
+
rows: t.named.get(r),
|
|
448
|
+
field: e.slice(n + 1)
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
return {
|
|
452
|
+
rows: t.rows,
|
|
453
|
+
field: e
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function Ae(e) {
|
|
457
|
+
let t = e.match(/^(\w+)\((.*?)\)$/);
|
|
458
|
+
return t ? {
|
|
459
|
+
key: t[1],
|
|
460
|
+
field: t[2].trim()
|
|
461
|
+
} : null;
|
|
462
|
+
}
|
|
463
|
+
function je(e, t, n) {
|
|
464
|
+
let r = {};
|
|
465
|
+
for (let e of Object.keys(t)) r[e] = {};
|
|
466
|
+
for (let i of e) if (Ee.includes(i.type)) {
|
|
467
|
+
for (let e of i.items) if (e.type == "text") for (let i of Ne(e.value)) {
|
|
468
|
+
let e = Me(i.field, n);
|
|
469
|
+
for (let [n, a] of Object.entries(t)) r[n][i.field] || (r[n][i.field] = {
|
|
470
|
+
count: null,
|
|
471
|
+
sum: null,
|
|
472
|
+
avg: null,
|
|
473
|
+
min: null,
|
|
474
|
+
max: null
|
|
475
|
+
}), r[n][i.field][i.key] = Fe({
|
|
476
|
+
key: i.key,
|
|
477
|
+
field: e
|
|
478
|
+
}, a);
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return r;
|
|
482
|
+
}
|
|
483
|
+
function Me(e, t) {
|
|
484
|
+
return t == null ? e : e === t ? "" : e.startsWith(`${t}.`) ? e.slice(t.length + 1) : e;
|
|
485
|
+
}
|
|
486
|
+
function Ne(e) {
|
|
487
|
+
let t = [];
|
|
488
|
+
for (let [, n] of e.matchAll(xe)) {
|
|
489
|
+
let e = Ae(n.trim());
|
|
490
|
+
e && t.push(e);
|
|
491
|
+
}
|
|
492
|
+
return t;
|
|
493
|
+
}
|
|
494
|
+
function Pe(e, t) {
|
|
495
|
+
let n = {};
|
|
496
|
+
for (let r of e) {
|
|
497
|
+
let e = r[t];
|
|
498
|
+
n[e] || (n[e] = []), n[e].push(r);
|
|
499
|
+
}
|
|
500
|
+
return n;
|
|
501
|
+
}
|
|
502
|
+
function Fe(e, t) {
|
|
503
|
+
if (e.key === "count") return t.length;
|
|
504
|
+
let n = t.map((t) => t?.[e.field]).filter((e) => e != null && e !== "").map(Number).filter((e) => Number.isFinite(e));
|
|
505
|
+
switch (e.key) {
|
|
506
|
+
case "sum": return n.length ? Ie(n.reduce((e, t) => e + t, 0)) : null;
|
|
507
|
+
case "avg": return n.length ? Ie(n.reduce((e, t) => e + t, 0) / n.length) : null;
|
|
508
|
+
case "max": return n.length ? Math.max(...n) : null;
|
|
509
|
+
case "min": return n.length ? Math.min(...n) : null;
|
|
510
|
+
default: return console.warn(`Unknown aggregate "${e.key}()"; it has no value.`), null;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
function Ie(e) {
|
|
514
|
+
return Number(e.toPrecision(12));
|
|
515
|
+
}
|
|
516
|
+
//#endregion
|
|
517
|
+
//#region src/engine/regions.js
|
|
518
|
+
var Le = {
|
|
519
|
+
pageHeader: "10%",
|
|
520
|
+
reportHeader: "10%",
|
|
521
|
+
reportFooter: "10%",
|
|
522
|
+
pageFooter: "10%"
|
|
523
|
+
}, Re = ["pageHeader", "reportHeader"], ze = ["reportFooter", "pageFooter"];
|
|
524
|
+
function Be(e, t, n) {
|
|
525
|
+
let r = Ve(e, t);
|
|
526
|
+
return r === null ? Ve(n, t) ?? 0 : r;
|
|
527
|
+
}
|
|
528
|
+
function Ve(e, t) {
|
|
529
|
+
if (typeof e == "number" && Number.isFinite(e) && e >= 0) return e;
|
|
530
|
+
if (typeof e == "string") {
|
|
531
|
+
let n = e.trim().match(/^(-?[\d.]+)\s*%$/);
|
|
532
|
+
if (n) {
|
|
533
|
+
let e = Number(n[1]);
|
|
534
|
+
return Number.isFinite(e) && e >= 0 ? e / 100 * t : null;
|
|
535
|
+
}
|
|
536
|
+
let r = Number(e.trim().replace(/px$/i, ""));
|
|
537
|
+
if (Number.isFinite(r) && r >= 0) return r;
|
|
538
|
+
}
|
|
539
|
+
return null;
|
|
540
|
+
}
|
|
541
|
+
function He(e, t) {
|
|
542
|
+
if (!e) return 0;
|
|
543
|
+
let n = Be(e.height, t, Le[e.type]), r = e.measuredHeight ?? 0;
|
|
544
|
+
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;
|
|
545
|
+
}
|
|
546
|
+
function Ue({ bands: e, contentHeight: t, isFirstPage: n, isLastPage: r }) {
|
|
547
|
+
let i = {}, a = (e) => e === "reportHeader" ? n : e !== "reportFooter" || r, o = 0;
|
|
548
|
+
for (let n of Re) {
|
|
549
|
+
let r = e[n];
|
|
550
|
+
if (!r || !a(n)) continue;
|
|
551
|
+
let s = He(r, t);
|
|
552
|
+
i[n] = {
|
|
553
|
+
top: o,
|
|
554
|
+
height: s
|
|
555
|
+
}, o += s;
|
|
556
|
+
}
|
|
557
|
+
let s = o, c = t;
|
|
558
|
+
for (let n of [...ze].reverse()) {
|
|
559
|
+
let r = e[n];
|
|
560
|
+
if (!r || !a(n)) continue;
|
|
561
|
+
let o = He(r, t);
|
|
562
|
+
c -= o, i[n] = {
|
|
563
|
+
top: c,
|
|
564
|
+
height: o
|
|
565
|
+
};
|
|
566
|
+
}
|
|
567
|
+
return i.detail = {
|
|
568
|
+
top: s,
|
|
569
|
+
height: Math.max(c - s, 0)
|
|
570
|
+
}, i;
|
|
571
|
+
}
|
|
572
|
+
//#endregion
|
|
573
|
+
//#region src/engine/paginate.js
|
|
574
|
+
var We = /\{([^{}]+)\}/g, Ge = ["page", "totalPages"];
|
|
575
|
+
function Ke(e) {
|
|
576
|
+
let t = structuredClone(e), n = {
|
|
577
|
+
page: t.page,
|
|
578
|
+
bands: t.bands,
|
|
579
|
+
assignedBands: {
|
|
580
|
+
reportHeader: t.bands.find((e) => e.type === "reportHeader"),
|
|
581
|
+
reportFooter: t.bands.find((e) => e.type === "reportFooter"),
|
|
582
|
+
pageHeader: t.bands.find((e) => e.type === "pageHeader"),
|
|
583
|
+
pageFooter: t.bands.find((e) => e.type === "pageFooter"),
|
|
584
|
+
detail: t.bands.find((e) => e.type === "detail"),
|
|
585
|
+
groupHeader: t.bands.find((e) => e.type === "groupHeader") || null,
|
|
586
|
+
groupFooter: t.bands.find((e) => e.type === "groupFooter") || null
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
return n.availableHeight = tt(t.page), n.regionsFor = (e, t) => Ue({
|
|
590
|
+
bands: n.assignedBands,
|
|
591
|
+
contentHeight: n.availableHeight,
|
|
592
|
+
isFirstPage: e === 1,
|
|
593
|
+
isLastPage: t
|
|
594
|
+
}), t.pages = nt(Xe(t.bands.filter((e) => ![
|
|
595
|
+
"reportHeader",
|
|
596
|
+
"reportFooter",
|
|
597
|
+
"pageHeader",
|
|
598
|
+
"pageFooter",
|
|
599
|
+
"groupHeader",
|
|
600
|
+
"groupFooter"
|
|
601
|
+
].includes(e.type)), n)), t;
|
|
602
|
+
}
|
|
603
|
+
function qe(e, t, n, r = Infinity) {
|
|
604
|
+
let i = 0, a = 0;
|
|
605
|
+
for (; t + a < e.length && a < r;) {
|
|
606
|
+
let r = i + e[t + a];
|
|
607
|
+
if (r > n) break;
|
|
608
|
+
i = r, a++;
|
|
609
|
+
}
|
|
610
|
+
return a;
|
|
611
|
+
}
|
|
612
|
+
function Je(e, t, n) {
|
|
613
|
+
return k(e.slice(t, t + n));
|
|
614
|
+
}
|
|
615
|
+
function Ye(e, t, n) {
|
|
616
|
+
return Array.isArray(n) && n.length === (t ?? []).length ? n : (t ?? []).map(() => e.rowHeight ?? 0);
|
|
617
|
+
}
|
|
618
|
+
function Xe(e, t) {
|
|
619
|
+
let n = [], r = et(1, t);
|
|
620
|
+
n.push(r);
|
|
621
|
+
let { assignedBands: i, availableHeight: a } = t, { reportFooter: o, reportHeader: s, groupHeader: c, groupFooter: l, pageHeader: u, pageFooter: d } = i, f = t.regionsFor(2, !1).detail.height;
|
|
622
|
+
s && r.regions.detail.height <= 0 && console.warn("The header zones leave no room for detail on page 1. Reduce the reportHeader or pageHeader height.");
|
|
623
|
+
let p = 0, m = 0, h = [], g = () => r.regions.detail.height, _ = (e, i, a) => (e.items.length > 0 && r.bands.push(e), r = et(n.length + 1, t), n.push(r), p = 0, m = a, h = [], {
|
|
624
|
+
...i,
|
|
625
|
+
items: []
|
|
626
|
+
}), v = (e, t) => {
|
|
627
|
+
e.items.push(t), p = Math.max(p, (t.y ?? 0) + (t.measuredHeight ?? 0)), e.measuredHeight = p, r.usedHeight = a - g() + p;
|
|
628
|
+
}, y = (e) => {
|
|
629
|
+
let t = -Infinity, n = -Infinity;
|
|
630
|
+
for (let r of h) r.designBottom > e || (t = Math.max(t, r.designBottom), n = Math.max(n, r.actualBottom));
|
|
631
|
+
return t === -Infinity ? 0 : n - t;
|
|
632
|
+
}, S = (e) => {
|
|
633
|
+
let t = e - m;
|
|
634
|
+
return t + y(t);
|
|
635
|
+
};
|
|
636
|
+
for (let t of e) {
|
|
637
|
+
let e = {
|
|
638
|
+
...t,
|
|
639
|
+
items: []
|
|
640
|
+
};
|
|
641
|
+
m = 0, h = [];
|
|
642
|
+
let n = [...t.items].sort((e, t) => (e.y ?? 0) - (t.y ?? 0));
|
|
643
|
+
for (let r of n) {
|
|
644
|
+
let n = r.y ?? 0, i = S(n) + r.measuredHeight;
|
|
645
|
+
if (i > g() && r.type != "table") r.measuredHeight > f ? console.warn(`Item "${r.id}" is ${Math.ceil(r.measuredHeight)}px tall, past the ${f}px detail zone of an empty page; it will overflow.`) : e = _(e, t, n), v(e, {
|
|
646
|
+
...structuredClone(r),
|
|
647
|
+
y: S(n)
|
|
648
|
+
});
|
|
649
|
+
else if (i > g() && r.type == "table") {
|
|
650
|
+
let i = S(n);
|
|
651
|
+
if (r.groups) {
|
|
652
|
+
let a = c?.measuredHeight ?? 0, o = l?.measuredHeight ?? 0, s = r.headerMeasured ?? b(r), u = Math.max(r.rowHeight ?? 0, ...(r.groups ?? []).flatMap((e) => Ye(r, e.rows, e.rowHeights))), d = s + a + u + o;
|
|
653
|
+
d <= f || console.warn(`Table "${r.id}": table header + group header + one row + group footer (${d}px) exceeds the ${f}px printable page. Falling back to one row per page; rows will overflow their page.`);
|
|
654
|
+
let p = (e, t, n, r) => {
|
|
655
|
+
let i = n - a - s;
|
|
656
|
+
return r <= qe(e, t, i - o, r) ? r : Math.min(qe(e, t, i, r), r - 1);
|
|
657
|
+
}, m = [], h = 0;
|
|
658
|
+
for (let u of r.groups) {
|
|
659
|
+
let d = 0, y = u.rows.length, b = Ye(r, u.rows, u.rowHeights);
|
|
660
|
+
for (; d < y;) {
|
|
661
|
+
let x = g() - i - h, S = m.length === 0 && e.items.length === 0 && i === 0 && g() >= f, C = p(b, d, x, y - d);
|
|
662
|
+
if (C < 1 && S && (C = 1), C < 1) {
|
|
663
|
+
if (m.length > 0) {
|
|
664
|
+
let t = structuredClone(r);
|
|
665
|
+
t.groups = m, t.y = i, t.measuredHeight = h, v(e, t);
|
|
666
|
+
}
|
|
667
|
+
e = _(e, t, n), m = [], h = 0, i = 0;
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
let w = u.rows.slice(d, d + C), T = b.slice(d, d + C);
|
|
671
|
+
d += w.length;
|
|
672
|
+
let E = d < y, D = k(T) + (a + s) + (E ? 0 : o);
|
|
673
|
+
h += D;
|
|
674
|
+
let O = {
|
|
675
|
+
key: u.key,
|
|
676
|
+
rows: w,
|
|
677
|
+
rowHeights: T,
|
|
678
|
+
aggregates: u.aggregates,
|
|
679
|
+
showHeader: !0,
|
|
680
|
+
showFooter: !E,
|
|
681
|
+
headerBand: R(c, u, w[0]),
|
|
682
|
+
footerBand: E ? null : R(l, u, w[0])
|
|
683
|
+
};
|
|
684
|
+
m.push(O);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
if (m.length > 0) {
|
|
688
|
+
let t = structuredClone(r);
|
|
689
|
+
t.groups = m, t.y = i, t.measuredHeight = h, v(e, t), m = [];
|
|
690
|
+
}
|
|
691
|
+
} else {
|
|
692
|
+
let a = r.row.length, o = 0, s = r.headerMeasured ?? b(r), c = Ye(r, r.row, r.rowHeights), l = Math.max(r.rowHeight ?? 0, ...c);
|
|
693
|
+
for (f - s >= l || console.warn(`Table "${r.id}": its tallest row is ${Math.ceil(l)}px, which with the ${s}px header exceeds the ${f}px printable page. Falling back to one row per page; rows will overflow their page.`); o < a;) {
|
|
694
|
+
let l = g() - i, u = qe(c, o, l - s, a - o), d = e.items.length === 0 && i === 0 && g() >= f;
|
|
695
|
+
if (u < 1 && d && (u = 1), u < 1) {
|
|
696
|
+
e = _(e, t, n), i = 0;
|
|
697
|
+
continue;
|
|
698
|
+
}
|
|
699
|
+
u = Math.min(u, a - o);
|
|
700
|
+
let p = structuredClone(r), m = r.row.slice(o, o + u), h = Je(c, o, u) + s;
|
|
701
|
+
p.row = m, p.rowHeights = c.slice(o, o + u), p.y = i, p.measuredHeight = h, v(e, p), o += m.length, o < a && (e = _(e, t, n), i = 0);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
} else {
|
|
705
|
+
let t = r.type === "table" && r.groups ? {
|
|
706
|
+
...r,
|
|
707
|
+
groups: Qe(r, c, l)
|
|
708
|
+
} : r;
|
|
709
|
+
v(e, {
|
|
710
|
+
...structuredClone(t),
|
|
711
|
+
y: S(n)
|
|
712
|
+
});
|
|
713
|
+
}
|
|
714
|
+
let a = [...e.items].reverse().find((e) => e.id === r.id);
|
|
715
|
+
a && h.push({
|
|
716
|
+
designBottom: n - m + x(r),
|
|
717
|
+
actualBottom: (a.y ?? 0) + (a.measuredHeight ?? 0)
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
e.items.length > 0 && (r.bands.push(e), e = {
|
|
721
|
+
...t,
|
|
722
|
+
items: []
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
if (o) {
|
|
726
|
+
let e = He(o, a);
|
|
727
|
+
r.usedHeight + e > a && (r = et(n.length + 1, t), n.push(r)), r.bands.push(structuredClone(o)), r.usedHeight += e;
|
|
728
|
+
}
|
|
729
|
+
let C = n[n.length - 1];
|
|
730
|
+
return C.regions = t.regionsFor(C.pageNO, !!o), Ze(n), n;
|
|
731
|
+
}
|
|
732
|
+
function Ze(e) {
|
|
733
|
+
for (let t of e) for (let e of t.bands) {
|
|
734
|
+
let n = t.regions[e.type] ?? t.regions.detail;
|
|
735
|
+
e.top = n.top, e.zoneHeight = n.height;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function Qe(e, t, n) {
|
|
739
|
+
return e.groups.map((e) => ({
|
|
740
|
+
key: e.key,
|
|
741
|
+
rows: e.rows,
|
|
742
|
+
rowHeights: e.rowHeights,
|
|
743
|
+
aggregates: e.aggregates,
|
|
744
|
+
showHeader: !0,
|
|
745
|
+
showFooter: !0,
|
|
746
|
+
headerBand: R(t, e, e.rows[0]),
|
|
747
|
+
footerBand: R(n, e, e.rows[0])
|
|
748
|
+
}));
|
|
749
|
+
}
|
|
750
|
+
function R(e, t, n) {
|
|
751
|
+
if (!e) return null;
|
|
752
|
+
let r = structuredClone(e);
|
|
753
|
+
for (let e of r.items) e.type === "text" && (e.text = (e.text ?? e.value).replace(We, (e, r) => $e(e, r.trim(), t, n)));
|
|
754
|
+
return r;
|
|
755
|
+
}
|
|
756
|
+
function $e(e, t, n, r) {
|
|
757
|
+
if (Ge.includes(t)) return e;
|
|
758
|
+
let i = t.match(/^(\w+)\((.*?)\)$/);
|
|
759
|
+
if (i) {
|
|
760
|
+
let [, e, t] = i, r = n.aggregates?.[t]?.[e.trim()];
|
|
761
|
+
return r == null ? "" : String(r);
|
|
762
|
+
}
|
|
763
|
+
let a = r?.[t];
|
|
764
|
+
return a == null ? "" : String(a);
|
|
765
|
+
}
|
|
766
|
+
function et(e, t) {
|
|
767
|
+
let { pageHeader: n, pageFooter: r, reportHeader: i } = t.assignedBands, a = t.regionsFor(e, !1), o = [];
|
|
768
|
+
return n && o.push(structuredClone(n)), r && o.push(structuredClone(r)), i && e === 1 && o.push(structuredClone(i)), {
|
|
769
|
+
pageNO: e,
|
|
770
|
+
bands: o,
|
|
771
|
+
regions: a,
|
|
772
|
+
usedHeight: t.availableHeight - a.detail.height
|
|
773
|
+
};
|
|
774
|
+
}
|
|
775
|
+
function tt(e) {
|
|
776
|
+
return e.height - (e.margin.top + e.margin.bottom);
|
|
777
|
+
}
|
|
778
|
+
function nt(e) {
|
|
779
|
+
for (let t of e) for (let n of t.bands) rt(n, t.pageNO, e.length);
|
|
780
|
+
return e;
|
|
781
|
+
}
|
|
782
|
+
function rt(e, t, n) {
|
|
783
|
+
for (let r of e?.items ?? []) {
|
|
784
|
+
if (r.type === "text") {
|
|
785
|
+
let e = r.text ?? r.value ?? "";
|
|
786
|
+
if (!e.includes("{")) continue;
|
|
787
|
+
r.text = e.replace(We, (e, r) => {
|
|
788
|
+
switch (r.trim()) {
|
|
789
|
+
case "page": return t;
|
|
790
|
+
case "totalPages": return n;
|
|
791
|
+
default: return e;
|
|
792
|
+
}
|
|
793
|
+
});
|
|
794
|
+
continue;
|
|
795
|
+
}
|
|
796
|
+
if (r.type === "table" && r.groups) for (let e of r.groups) rt(e.headerBand, t, n), rt(e.footerBand, t, n);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region src/engine/search.js
|
|
801
|
+
function it(e, t, { caseSensitive: n = !1 } = {}) {
|
|
802
|
+
let r = String(t ?? "");
|
|
803
|
+
if (r === "") return [];
|
|
804
|
+
let i = [];
|
|
805
|
+
for (let t of e ?? []) for (let e of t.bands ?? []) ot(e, t.pageNO, e.type, r, n, i);
|
|
806
|
+
return i;
|
|
807
|
+
}
|
|
808
|
+
function at(e, t, n) {
|
|
809
|
+
return [...new Set(it(e, t, n).map((e) => e.pageNO))];
|
|
810
|
+
}
|
|
811
|
+
function ot(e, t, n, r, i, a) {
|
|
812
|
+
for (let o of e?.items ?? []) {
|
|
813
|
+
if (o.type === "text") {
|
|
814
|
+
lt(a, o.text, {
|
|
815
|
+
pageNO: t,
|
|
816
|
+
bandType: n,
|
|
817
|
+
itemId: o.id,
|
|
818
|
+
field: null
|
|
819
|
+
}, r, i);
|
|
820
|
+
continue;
|
|
821
|
+
}
|
|
822
|
+
o.type === "table" && st(o, t, n, r, i, a);
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
function st(e, t, n, r, i, a) {
|
|
826
|
+
let o = e.columns ?? [];
|
|
827
|
+
if (e.showHeader) for (let s of o) lt(a, s.label, {
|
|
828
|
+
pageNO: t,
|
|
829
|
+
bandType: n,
|
|
830
|
+
itemId: e.id,
|
|
831
|
+
field: s.field
|
|
832
|
+
}, r, i);
|
|
833
|
+
if (e.row) {
|
|
834
|
+
ct(e.row, o, e.id, t, n, r, i, a);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
for (let s of e.groups ?? []) ot(s.headerBand, t, "groupHeader", r, i, a), ct(s.rows, o, e.id, t, n, r, i, a), s.showFooter && ot(s.footerBand, t, "groupFooter", r, i, a);
|
|
838
|
+
}
|
|
839
|
+
function ct(e, t, n, r, i, a, o, s) {
|
|
840
|
+
for (let c of e ?? []) for (let e of t) lt(s, c?.[e.field], {
|
|
841
|
+
pageNO: r,
|
|
842
|
+
bandType: i,
|
|
843
|
+
itemId: n,
|
|
844
|
+
field: e.field
|
|
845
|
+
}, a, o);
|
|
846
|
+
}
|
|
847
|
+
function lt(e, t, n, r, i) {
|
|
848
|
+
if (t == null) return;
|
|
849
|
+
let a = String(t), o = i ? a : a.toLowerCase(), s = i ? r : r.toLowerCase(), c = 0;
|
|
850
|
+
for (; c <= o.length - s.length;) {
|
|
851
|
+
let t = o.indexOf(s, c);
|
|
852
|
+
if (t === -1) break;
|
|
853
|
+
e.push({
|
|
854
|
+
...n,
|
|
855
|
+
text: a,
|
|
856
|
+
start: t,
|
|
857
|
+
end: t + s.length
|
|
858
|
+
}), c = t + s.length;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
//#endregion
|
|
862
|
+
//#region src/engine/rows.js
|
|
863
|
+
var ut = [
|
|
864
|
+
"image",
|
|
865
|
+
"line",
|
|
866
|
+
"box"
|
|
867
|
+
];
|
|
868
|
+
function dt(e) {
|
|
869
|
+
return ft(e).rows.filter((e) => !e.spacer);
|
|
870
|
+
}
|
|
871
|
+
function ft(e) {
|
|
872
|
+
let t = [], n = [];
|
|
873
|
+
return (e ?? []).forEach((e, r) => {
|
|
874
|
+
for (let i of vt(e?.bands)) yt(i, t, {
|
|
875
|
+
page: r,
|
|
876
|
+
origin: Number(i?.top) || 0,
|
|
877
|
+
graphics: n
|
|
878
|
+
});
|
|
879
|
+
}), {
|
|
880
|
+
rows: t,
|
|
881
|
+
graphics: n
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
function pt(e, t = null) {
|
|
885
|
+
let n = null, r = t, i = null, a = [];
|
|
886
|
+
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)) {
|
|
887
|
+
if (n === null && (r = t.id, n = t.columns ?? [], i = t), t.row) {
|
|
888
|
+
t.row.forEach((e, n) => {
|
|
889
|
+
a.push({
|
|
890
|
+
group: null,
|
|
891
|
+
row: e,
|
|
892
|
+
height: z(t, t.rowHeights, n)
|
|
893
|
+
});
|
|
894
|
+
});
|
|
895
|
+
continue;
|
|
896
|
+
}
|
|
897
|
+
for (let e of t.groups ?? []) e.rows.forEach((n, r) => {
|
|
898
|
+
a.push({
|
|
899
|
+
group: e.key,
|
|
900
|
+
row: n,
|
|
901
|
+
height: z(t, e.rowHeights, r)
|
|
902
|
+
});
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
return n === null ? null : {
|
|
906
|
+
id: r,
|
|
907
|
+
columns: n,
|
|
908
|
+
table: ht(i),
|
|
909
|
+
headerHeight: gt(i),
|
|
910
|
+
rows: a
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
function mt(e) {
|
|
914
|
+
let t = /* @__PURE__ */ new Map();
|
|
915
|
+
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, {
|
|
916
|
+
id: n.id,
|
|
917
|
+
columns: (n.columns ?? []).map(B)
|
|
918
|
+
});
|
|
919
|
+
return [...t.values()];
|
|
920
|
+
}
|
|
921
|
+
function ht(e) {
|
|
922
|
+
return {
|
|
923
|
+
style: e.style ?? {},
|
|
924
|
+
wrap: e.wrap !== !1
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
function gt(e) {
|
|
928
|
+
return e.headerMeasured ?? e.headerHeight ?? e.rowHeight ?? null;
|
|
929
|
+
}
|
|
930
|
+
function z(e, t, n) {
|
|
931
|
+
return t?.[n] ?? e.rowHeight ?? null;
|
|
932
|
+
}
|
|
933
|
+
function _t(e) {
|
|
934
|
+
return Number(e?.measuredHeight ?? e?.height) || 0;
|
|
935
|
+
}
|
|
936
|
+
function B(e) {
|
|
937
|
+
return e.label ?? e.field;
|
|
938
|
+
}
|
|
939
|
+
function vt(e) {
|
|
940
|
+
return [...e ?? []].sort((e, t) => (e?.top ?? 0) - (t?.top ?? 0));
|
|
941
|
+
}
|
|
942
|
+
function yt(e, t, n) {
|
|
943
|
+
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) => ut.includes(e?.type)).map((e) => ({
|
|
944
|
+
kind: e.type,
|
|
945
|
+
page: r,
|
|
946
|
+
x: Number(e.x) || 0,
|
|
947
|
+
y: i + (Number(e.y) || 0),
|
|
948
|
+
w: Number(e.w) || 0,
|
|
949
|
+
h: Number(e.h) || 0,
|
|
950
|
+
item: e
|
|
951
|
+
})), c = null, l = () => {
|
|
952
|
+
c && t.push({
|
|
953
|
+
cells: c.cells,
|
|
954
|
+
header: !1,
|
|
955
|
+
design: c.design,
|
|
956
|
+
page: r,
|
|
957
|
+
top: c.top,
|
|
958
|
+
height: c.bottom - c.top
|
|
959
|
+
}), c = null;
|
|
960
|
+
}, u = (e) => ({
|
|
961
|
+
kind: "text",
|
|
962
|
+
style: e.style ?? {},
|
|
963
|
+
template: e.value,
|
|
964
|
+
x: Number(e.x) || 0,
|
|
965
|
+
y: i + (Number(e.y) || 0),
|
|
966
|
+
w: Number(e.w) || 0,
|
|
967
|
+
h: Number(e.measuredHeight ?? e.h) || 0
|
|
968
|
+
});
|
|
969
|
+
for (let e of o) {
|
|
970
|
+
if (e?.type === "table") {
|
|
971
|
+
l(), wt(e, t, {
|
|
972
|
+
...n,
|
|
973
|
+
origin: i + (Number(e.y) || 0)
|
|
974
|
+
});
|
|
975
|
+
continue;
|
|
976
|
+
}
|
|
977
|
+
if (e?.type !== "text") continue;
|
|
978
|
+
let r = u(e);
|
|
979
|
+
if (c && Ct(c.anchor, e)) {
|
|
980
|
+
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);
|
|
981
|
+
continue;
|
|
982
|
+
}
|
|
983
|
+
l(), c = {
|
|
984
|
+
anchor: e,
|
|
985
|
+
cells: [e.text],
|
|
986
|
+
design: [r],
|
|
987
|
+
top: r.y,
|
|
988
|
+
bottom: r.y + r.h
|
|
989
|
+
};
|
|
990
|
+
}
|
|
991
|
+
l(), xt(t, a, s, r), n.graphics.push(...s);
|
|
992
|
+
}
|
|
993
|
+
var bt = 4;
|
|
994
|
+
function xt(e, t, n, r) {
|
|
995
|
+
let i = e.slice(t).map((e) => [e.top, e.top + (e.height ?? 0)]), a = [];
|
|
996
|
+
for (let e of n) {
|
|
997
|
+
let t = [e.y, e.y + Math.max(e.h, 1)], n = St(t, i), r = n.length === 1 && n[0][0] === t[0] && n[0][1] === t[1];
|
|
998
|
+
for (let e of n) (r || e[1] - e[0] >= bt) && a.push(e);
|
|
999
|
+
}
|
|
1000
|
+
let o = [];
|
|
1001
|
+
for (let [e, t] of a.sort((e, t) => e[0] - t[0])) {
|
|
1002
|
+
let n = o[o.length - 1];
|
|
1003
|
+
if (n && e <= n.top + n.height) {
|
|
1004
|
+
n.height = Math.max(n.height, t - n.top);
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
o.push({
|
|
1008
|
+
cells: [],
|
|
1009
|
+
header: !1,
|
|
1010
|
+
design: [],
|
|
1011
|
+
page: r,
|
|
1012
|
+
top: e,
|
|
1013
|
+
height: t - e,
|
|
1014
|
+
spacer: !0
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
for (let n of o) {
|
|
1018
|
+
let r = t;
|
|
1019
|
+
for (; r < e.length && e[r].top < n.top + n.height;) r++;
|
|
1020
|
+
e.splice(r, 0, n);
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
function St([e, t], n) {
|
|
1024
|
+
let r = [[e, t]];
|
|
1025
|
+
for (let [e, t] of n) t > e && (r = r.flatMap(([n, r]) => {
|
|
1026
|
+
if (t <= n || e >= r) return [[n, r]];
|
|
1027
|
+
let i = e > n ? [[n, e]] : [], a = t < r ? [[t, r]] : [];
|
|
1028
|
+
return [...i, ...a];
|
|
1029
|
+
}));
|
|
1030
|
+
return r;
|
|
1031
|
+
}
|
|
1032
|
+
function Ct(e, t) {
|
|
1033
|
+
let n = (e) => {
|
|
1034
|
+
let t = e.y ?? 0;
|
|
1035
|
+
return [t, t + (e.measuredHeight ?? e.h ?? 0)];
|
|
1036
|
+
}, [r, i] = n(e), [a, o] = n(t);
|
|
1037
|
+
return Math.min(i, o) - Math.max(r, a) >= Math.min(i - r, o - a) / 2;
|
|
1038
|
+
}
|
|
1039
|
+
function wt(e, t, n) {
|
|
1040
|
+
let r = ht(e), { page: i } = n, a = n.origin, o = () => {
|
|
1041
|
+
let n = gt(e);
|
|
1042
|
+
t.push({
|
|
1043
|
+
cells: e.columns.map(B),
|
|
1044
|
+
header: !0,
|
|
1045
|
+
design: e.columns.map((e) => ({
|
|
1046
|
+
kind: "head",
|
|
1047
|
+
column: e,
|
|
1048
|
+
table: r
|
|
1049
|
+
})),
|
|
1050
|
+
page: i,
|
|
1051
|
+
top: a,
|
|
1052
|
+
height: n
|
|
1053
|
+
}), a += Number(n) || 0;
|
|
1054
|
+
}, s = (n, o) => {
|
|
1055
|
+
t.push({
|
|
1056
|
+
cells: e.columns.map((e) => n?.[e.field]),
|
|
1057
|
+
header: !1,
|
|
1058
|
+
design: e.columns.map((e) => ({
|
|
1059
|
+
kind: "cell",
|
|
1060
|
+
column: e,
|
|
1061
|
+
table: r
|
|
1062
|
+
})),
|
|
1063
|
+
page: i,
|
|
1064
|
+
top: a,
|
|
1065
|
+
height: o
|
|
1066
|
+
}), a += Number(o) || 0;
|
|
1067
|
+
}, c = (e) => {
|
|
1068
|
+
yt(e, t, {
|
|
1069
|
+
...n,
|
|
1070
|
+
origin: a
|
|
1071
|
+
}), a += _t(e);
|
|
1072
|
+
};
|
|
1073
|
+
if (!e.groups) {
|
|
1074
|
+
e.showHeader && o(), (e.row ?? []).forEach((t, n) => s(t, z(e, e.rowHeights, n)));
|
|
1075
|
+
return;
|
|
1076
|
+
}
|
|
1077
|
+
for (let t of e.groups) t.showHeader && e.showHeader && o(), t.headerBand && c(t.headerBand), t.rows.forEach((n, r) => s(n, z(e, t.rowHeights, r))), t.showFooter && t.footerBand && c(t.footerBand);
|
|
1078
|
+
}
|
|
1079
|
+
//#endregion
|
|
1080
|
+
//#region src/engine/csv.js
|
|
1081
|
+
var Tt = /^[=+\-@\t\r]/;
|
|
1082
|
+
function Et(e, t = {}) {
|
|
1083
|
+
let { delimiter: n = ",", newline: r = "\r\n", header: i = !0, groupColumn: a = !0, groupLabel: o = "Group", neutraliseFormulas: s = !0, table: c = null } = t, l = pt(e, c);
|
|
1084
|
+
if (!l) return "";
|
|
1085
|
+
let u = a && l.rows.some((e) => e.group !== null), d = l.columns.map(B), f = [];
|
|
1086
|
+
i && f.push(Ot(u ? [o, ...d] : d, n, s));
|
|
1087
|
+
for (let { group: e, row: t } of l.rows) {
|
|
1088
|
+
let r = l.columns.map((e) => t?.[e.field]);
|
|
1089
|
+
f.push(Ot(u ? [e, ...r] : r, n, s));
|
|
1090
|
+
}
|
|
1091
|
+
return f.join(r);
|
|
1092
|
+
}
|
|
1093
|
+
function Dt(e, t = {}) {
|
|
1094
|
+
let { delimiter: n = ",", newline: r = "\r\n", neutraliseFormulas: i = !0 } = t, a = dt(e);
|
|
1095
|
+
return a.length === 0 ? "" : a.map(({ cells: e }) => Ot(e, n, i)).join(r);
|
|
1096
|
+
}
|
|
1097
|
+
function V(e, t = "csv") {
|
|
1098
|
+
return `${String(e?.name ?? "report").replace(/[\\/:*?"<>|]+/g, "-").replace(/\s+/g, " ").trim() || "report"}.${t}`;
|
|
1099
|
+
}
|
|
1100
|
+
function Ot(e, t, n) {
|
|
1101
|
+
return e.map((e) => kt(e, t, n)).join(t);
|
|
1102
|
+
}
|
|
1103
|
+
function kt(e, t, n) {
|
|
1104
|
+
if (e == null) return "";
|
|
1105
|
+
let r = String(e);
|
|
1106
|
+
return n && Tt.test(r) && (r = `\t${r}`), r.includes(t) || r.includes("\"") || r.includes("\n") || r.includes("\r") ? `"${r.replace(/"/g, "\"\"")}"` : r;
|
|
1107
|
+
}
|
|
1108
|
+
//#endregion
|
|
1109
|
+
//#region src/engine/xlsx-style.js
|
|
1110
|
+
var H = Object.freeze({
|
|
1111
|
+
fontFamily: "Helvetica, Arial, sans-serif",
|
|
1112
|
+
fontSize: 12,
|
|
1113
|
+
headerWeight: 600,
|
|
1114
|
+
headerBackground: "#f1f3f5",
|
|
1115
|
+
ruleColor: "#cdd4db",
|
|
1116
|
+
ruleWidth: 1,
|
|
1117
|
+
ruleStyle: "solid",
|
|
1118
|
+
cellPadding: 8
|
|
1119
|
+
}), At = [
|
|
1120
|
+
"aptos",
|
|
1121
|
+
"arial",
|
|
1122
|
+
"calibri",
|
|
1123
|
+
"cambria",
|
|
1124
|
+
"candara",
|
|
1125
|
+
"consolas",
|
|
1126
|
+
"constantia",
|
|
1127
|
+
"corbel",
|
|
1128
|
+
"courier new",
|
|
1129
|
+
"georgia",
|
|
1130
|
+
"segoe ui",
|
|
1131
|
+
"tahoma",
|
|
1132
|
+
"times new roman",
|
|
1133
|
+
"trebuchet ms",
|
|
1134
|
+
"verdana"
|
|
1135
|
+
], jt = {
|
|
1136
|
+
"sans-serif": "Arial",
|
|
1137
|
+
serif: "Times New Roman",
|
|
1138
|
+
monospace: "Courier New",
|
|
1139
|
+
"system-ui": "Calibri",
|
|
1140
|
+
"-apple-system": "Calibri",
|
|
1141
|
+
"ui-sans-serif": "Arial",
|
|
1142
|
+
"ui-serif": "Times New Roman",
|
|
1143
|
+
"ui-monospace": "Courier New",
|
|
1144
|
+
cursive: "Comic Sans MS",
|
|
1145
|
+
fantasy: "Impact"
|
|
1146
|
+
}, Mt = 31, Nt = {
|
|
1147
|
+
black: "000000",
|
|
1148
|
+
white: "FFFFFF",
|
|
1149
|
+
red: "FF0000",
|
|
1150
|
+
green: "008000",
|
|
1151
|
+
blue: "0000FF",
|
|
1152
|
+
gray: "808080",
|
|
1153
|
+
grey: "808080",
|
|
1154
|
+
silver: "C0C0C0",
|
|
1155
|
+
maroon: "800000",
|
|
1156
|
+
navy: "000080",
|
|
1157
|
+
teal: "008080",
|
|
1158
|
+
olive: "808000",
|
|
1159
|
+
purple: "800080",
|
|
1160
|
+
orange: "FFA500",
|
|
1161
|
+
yellow: "FFFF00",
|
|
1162
|
+
lime: "00FF00",
|
|
1163
|
+
aqua: "00FFFF",
|
|
1164
|
+
cyan: "00FFFF",
|
|
1165
|
+
fuchsia: "FF00FF",
|
|
1166
|
+
magenta: "FF00FF",
|
|
1167
|
+
darkgray: "A9A9A9",
|
|
1168
|
+
darkgrey: "A9A9A9",
|
|
1169
|
+
lightgray: "D3D3D3",
|
|
1170
|
+
lightgrey: "D3D3D3"
|
|
1171
|
+
}, Pt = [
|
|
1172
|
+
"solid",
|
|
1173
|
+
"dashed",
|
|
1174
|
+
"dotted",
|
|
1175
|
+
"double"
|
|
1176
|
+
], Ft = [
|
|
1177
|
+
"left",
|
|
1178
|
+
"center",
|
|
1179
|
+
"right"
|
|
1180
|
+
], It = 15;
|
|
1181
|
+
function Lt(e) {
|
|
1182
|
+
let t = Math.round((Number(e) || 0) / 9);
|
|
1183
|
+
return Math.max(0, Math.min(It, t));
|
|
1184
|
+
}
|
|
1185
|
+
function U(e) {
|
|
1186
|
+
if (typeof e != "string") return null;
|
|
1187
|
+
let t = e.trim().toLowerCase();
|
|
1188
|
+
if (t === "" || t === "transparent" || t === "none" || t === "inherit") return null;
|
|
1189
|
+
if (Nt[t]) return `FF${Nt[t]}`;
|
|
1190
|
+
let n = t.match(/^#([0-9a-f]{3,8})$/);
|
|
1191
|
+
if (n) {
|
|
1192
|
+
let e = n[1];
|
|
1193
|
+
if ((e.length === 3 || e.length === 4) && (e = [...e].map((e) => e + e).join("")), e.length === 8) {
|
|
1194
|
+
if (e.slice(6) === "00") return null;
|
|
1195
|
+
e = e.slice(0, 6);
|
|
1196
|
+
}
|
|
1197
|
+
return e.length === 6 ? `FF${e.toUpperCase()}` : null;
|
|
1198
|
+
}
|
|
1199
|
+
let r = t.match(/^rgba?\(\s*([^)]*)\)$/);
|
|
1200
|
+
if (r) {
|
|
1201
|
+
let e = r[1].split(/[\s,/]+/).filter(Boolean);
|
|
1202
|
+
if (e.length < 3) return null;
|
|
1203
|
+
let t = e[3];
|
|
1204
|
+
if (t !== void 0 && parseFloat(t) === 0) return null;
|
|
1205
|
+
let n = e.slice(0, 3).map((e) => {
|
|
1206
|
+
let t = e.endsWith("%") ? parseFloat(e) * 255 / 100 : parseFloat(e);
|
|
1207
|
+
return Number.isFinite(t) ? Math.max(0, Math.min(255, Math.round(t))) : null;
|
|
1208
|
+
});
|
|
1209
|
+
return n.includes(null) ? null : "FF" + n.map((e) => e.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
1210
|
+
}
|
|
1211
|
+
return null;
|
|
1212
|
+
}
|
|
1213
|
+
function Rt(e) {
|
|
1214
|
+
let t = String(e ?? "").split(",").map((e) => e.trim().replace(/^['"]|['"]$/g, "").trim()).filter(Boolean);
|
|
1215
|
+
return t.length === 0 ? "Arial" : (t.find((e) => At.includes(e.toLowerCase())) ?? jt[t[0].toLowerCase()] ?? t[0]).slice(0, Mt);
|
|
1216
|
+
}
|
|
1217
|
+
function zt(e) {
|
|
1218
|
+
return Math.round(e * .75 * 2) / 2;
|
|
1219
|
+
}
|
|
1220
|
+
function Bt(e) {
|
|
1221
|
+
return Math.max(1, Math.round((e - 5) / 7 * 100) / 100);
|
|
1222
|
+
}
|
|
1223
|
+
function Vt(e) {
|
|
1224
|
+
if (e === "bold" || e === "bolder") return !0;
|
|
1225
|
+
let t = Number(e);
|
|
1226
|
+
return Number.isFinite(t) && t >= 600;
|
|
1227
|
+
}
|
|
1228
|
+
function Ht({ style: e = "solid", width: t = 1, color: n = null } = {}) {
|
|
1229
|
+
if (e === "none" || e === "hidden") return null;
|
|
1230
|
+
let r = Pt.includes(e) ? e : "solid", i = Number(t);
|
|
1231
|
+
return !Number.isFinite(i) || i <= 0 ? null : {
|
|
1232
|
+
style: {
|
|
1233
|
+
solid: i <= 1 ? "thin" : i <= 2 ? "medium" : "thick",
|
|
1234
|
+
dashed: i <= 1 ? "dashed" : "mediumDashed",
|
|
1235
|
+
dotted: "dotted",
|
|
1236
|
+
double: "double"
|
|
1237
|
+
}[r],
|
|
1238
|
+
color: U(n)
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
function Ut(e) {
|
|
1242
|
+
return e ? e.kind === "text" ? Wt(e.style ?? {}) : e.kind === "head" || e.kind === "cell" ? Gt(e.kind === "head", e.column ?? {}, e.table ?? {}) : null : null;
|
|
1243
|
+
}
|
|
1244
|
+
function Wt(e) {
|
|
1245
|
+
return {
|
|
1246
|
+
font: {
|
|
1247
|
+
name: Rt(e.fontFamily ?? H.fontFamily),
|
|
1248
|
+
size: zt(Kt(e.fontSize) ?? H.fontSize),
|
|
1249
|
+
bold: Vt(e.fontWeight),
|
|
1250
|
+
italic: e.fontStyle === "italic" || e.fontStyle === "oblique",
|
|
1251
|
+
color: U(e.color)
|
|
1252
|
+
},
|
|
1253
|
+
fill: null,
|
|
1254
|
+
border: null,
|
|
1255
|
+
alignment: {
|
|
1256
|
+
horizontal: Ft.includes(e.align) ? e.align : "left",
|
|
1257
|
+
vertical: "top",
|
|
1258
|
+
wrapText: !1
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
function Gt(e, t, n) {
|
|
1263
|
+
let r = n.style ?? {}, i = e ? U(r.headerColor) ?? U(r.color) : U(r.color);
|
|
1264
|
+
return {
|
|
1265
|
+
font: {
|
|
1266
|
+
name: Rt(r.fontFamily ?? H.fontFamily),
|
|
1267
|
+
size: zt(Kt(r.fontSize) ?? H.fontSize),
|
|
1268
|
+
bold: Vt(e ? r.fontWeight ?? H.headerWeight : r.fontWeight),
|
|
1269
|
+
italic: r.fontStyle === "italic" || r.fontStyle === "oblique",
|
|
1270
|
+
color: i
|
|
1271
|
+
},
|
|
1272
|
+
fill: e ? r.headerBackground === null ? null : U(r.headerBackground ?? H.headerBackground) : U(r.background),
|
|
1273
|
+
border: Ht({
|
|
1274
|
+
style: r.borderStyle ?? H.ruleStyle,
|
|
1275
|
+
width: r.borderWidth ?? H.ruleWidth,
|
|
1276
|
+
color: r.borderColor ?? H.ruleColor
|
|
1277
|
+
}),
|
|
1278
|
+
alignment: {
|
|
1279
|
+
horizontal: Ft.includes(t.align) ? t.align : "left",
|
|
1280
|
+
vertical: "center",
|
|
1281
|
+
wrapText: n.wrap !== !1,
|
|
1282
|
+
indent: t.align === "center" ? 0 : Lt(H.cellPadding)
|
|
1283
|
+
}
|
|
1284
|
+
};
|
|
1285
|
+
}
|
|
1286
|
+
function Kt(e) {
|
|
1287
|
+
let t = Number(e);
|
|
1288
|
+
return Number.isFinite(t) && t > 0 ? t : null;
|
|
1289
|
+
}
|
|
1290
|
+
function qt() {
|
|
1291
|
+
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 = new Map([
|
|
1292
|
+
...e.map((e, t) => [e, t]),
|
|
1293
|
+
...t.map((e, t) => [e, t]),
|
|
1294
|
+
...n.map((e, t) => [e, t]),
|
|
1295
|
+
...r.map((e, t) => [e, t])
|
|
1296
|
+
]), a = (e, t) => i.has(t) ? i.get(t) : (e.push(t), i.set(t, e.length - 1), e.length - 1);
|
|
1297
|
+
function o(e) {
|
|
1298
|
+
return e ? "<font>" + (e.bold ? "<b/>" : "") + (e.italic ? "<i/>" : "") + `<sz val="${e.size ?? 11}"/>` + (e.color ? `<color rgb="${e.color}"/>` : "") + `<name val="${Jt(e.name ?? "Calibri")}"/></font>` : null;
|
|
1299
|
+
}
|
|
1300
|
+
function s(e) {
|
|
1301
|
+
return e ? `<fill><patternFill patternType="solid"><fgColor rgb="${e}"/><bgColor indexed="64"/></patternFill></fill>` : null;
|
|
1302
|
+
}
|
|
1303
|
+
function c(e) {
|
|
1304
|
+
if (!e) return null;
|
|
1305
|
+
let t = (t) => `<${t} style="${e.style}">` + (e.color ? `<color rgb="${e.color}"/>` : "<color auto=\"1\"/>") + `</${t}>`;
|
|
1306
|
+
return `<border>${t("left")}${t("right")}${t("top")}${t("bottom")}<diagonal/></border>`;
|
|
1307
|
+
}
|
|
1308
|
+
function l(e) {
|
|
1309
|
+
if (!e) return "";
|
|
1310
|
+
let t = [];
|
|
1311
|
+
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 && [
|
|
1312
|
+
"left",
|
|
1313
|
+
"right",
|
|
1314
|
+
"distributed"
|
|
1315
|
+
].includes(e.horizontal) && t.push(`indent="${Math.round(Number(e.indent))}"`), t.length ? `<alignment ${t.join(" ")}/>` : "";
|
|
1316
|
+
}
|
|
1317
|
+
function u(i, u = 0) {
|
|
1318
|
+
if (!i && u === 0) return 0;
|
|
1319
|
+
let d = o(i?.font ? {
|
|
1320
|
+
name: "Calibri",
|
|
1321
|
+
size: 11,
|
|
1322
|
+
...i.font
|
|
1323
|
+
} : null), f = s(i?.fill), p = c(i?.border), m = l(i?.alignment), h = d ? a(e, d) : 0, g = f ? a(t, f) : 0, _ = p ? a(n, p) : 0, v = `<xf numFmtId="${u}" fontId="${h}" fillId="${g}" borderId="${_}" xfId="0"${[
|
|
1324
|
+
u ? " applyNumberFormat=\"1\"" : "",
|
|
1325
|
+
h ? " applyFont=\"1\"" : "",
|
|
1326
|
+
g ? " applyFill=\"1\"" : "",
|
|
1327
|
+
_ ? " applyBorder=\"1\"" : "",
|
|
1328
|
+
m ? " applyAlignment=\"1\"" : ""
|
|
1329
|
+
].join("")}` + (m ? `>${m}</xf>` : "/>");
|
|
1330
|
+
return a(r, v);
|
|
1331
|
+
}
|
|
1332
|
+
function d() {
|
|
1333
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1334
|
+
<styleSheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main"><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>`;
|
|
1335
|
+
}
|
|
1336
|
+
return {
|
|
1337
|
+
xf: u,
|
|
1338
|
+
xml: d,
|
|
1339
|
+
get size() {
|
|
1340
|
+
return r.length;
|
|
1341
|
+
}
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
function Jt(e) {
|
|
1345
|
+
return String(e).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1346
|
+
}
|
|
1347
|
+
//#endregion
|
|
1348
|
+
//#region src/engine/xlsx-drawing.js
|
|
1349
|
+
var Yt = "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing", Xt = "http://schemas.openxmlformats.org/drawingml/2006/main", Zt = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Qt = 9525, $t = "application/vnd.openxmlformats-officedocument.drawing+xml", en = `${Zt}/drawing`, tn = `${Zt}/image`, nn = Object.freeze({
|
|
1350
|
+
png: "image/png",
|
|
1351
|
+
jpeg: "image/jpeg",
|
|
1352
|
+
gif: "image/gif",
|
|
1353
|
+
bmp: "image/bmp"
|
|
1354
|
+
}), rn = /^data:image\/[a-z0-9.+-]+;base64,([a-z0-9+/=\s]*)$/i;
|
|
1355
|
+
function W(e) {
|
|
1356
|
+
return Math.max(0, Math.round((Number(e) || 0) * Qt));
|
|
1357
|
+
}
|
|
1358
|
+
function an(e) {
|
|
1359
|
+
if (typeof e != "string") return null;
|
|
1360
|
+
let t = e.trim().match(rn);
|
|
1361
|
+
if (!t) return null;
|
|
1362
|
+
try {
|
|
1363
|
+
let e = atob(t[1].replace(/\s+/g, "")), n = new Uint8Array(e.length);
|
|
1364
|
+
for (let t = 0; t < e.length; t++) n[t] = e.charCodeAt(t);
|
|
1365
|
+
return n;
|
|
1366
|
+
} catch {
|
|
1367
|
+
return null;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
function on(e) {
|
|
1371
|
+
if (!(e instanceof Uint8Array) || e.length < 10) return null;
|
|
1372
|
+
let t = new DataView(e.buffer, e.byteOffset, e.byteLength), n = (t, ...n) => n.every((n, r) => e[t + r] === n);
|
|
1373
|
+
return n(0, 137, 80, 78, 71, 13, 10, 26, 10) && e.length >= 24 ? {
|
|
1374
|
+
ext: "png",
|
|
1375
|
+
width: t.getUint32(16),
|
|
1376
|
+
height: t.getUint32(20)
|
|
1377
|
+
} : n(0, 71, 73, 70, 56) ? {
|
|
1378
|
+
ext: "gif",
|
|
1379
|
+
width: t.getUint16(6, !0),
|
|
1380
|
+
height: t.getUint16(8, !0)
|
|
1381
|
+
} : n(0, 66, 77) && e.length >= 26 ? {
|
|
1382
|
+
ext: "bmp",
|
|
1383
|
+
width: Math.abs(t.getInt32(18, !0)),
|
|
1384
|
+
height: Math.abs(t.getInt32(22, !0))
|
|
1385
|
+
} : n(0, 255, 216) ? {
|
|
1386
|
+
ext: "jpeg",
|
|
1387
|
+
...sn(e, t)
|
|
1388
|
+
} : null;
|
|
1389
|
+
}
|
|
1390
|
+
function sn(e, t) {
|
|
1391
|
+
let n = 2;
|
|
1392
|
+
for (; n + 9 < e.length;) {
|
|
1393
|
+
if (e[n] !== 255) {
|
|
1394
|
+
n++;
|
|
1395
|
+
continue;
|
|
1396
|
+
}
|
|
1397
|
+
let r = e[n + 1];
|
|
1398
|
+
if (r === 216 || r === 1 || r >= 208 && r <= 215) {
|
|
1399
|
+
n += 2;
|
|
1400
|
+
continue;
|
|
1401
|
+
}
|
|
1402
|
+
let i = t.getUint16(n + 2);
|
|
1403
|
+
if (r >= 192 && r <= 207 && ![
|
|
1404
|
+
196,
|
|
1405
|
+
200,
|
|
1406
|
+
204
|
|
1407
|
+
].includes(r)) return {
|
|
1408
|
+
height: t.getUint16(n + 5),
|
|
1409
|
+
width: t.getUint16(n + 7)
|
|
1410
|
+
};
|
|
1411
|
+
n += 2 + i;
|
|
1412
|
+
}
|
|
1413
|
+
return {
|
|
1414
|
+
width: null,
|
|
1415
|
+
height: null
|
|
1416
|
+
};
|
|
1417
|
+
}
|
|
1418
|
+
function cn(e, t, n) {
|
|
1419
|
+
let { width: r, height: i } = n ?? {}, a = {
|
|
1420
|
+
x: 0,
|
|
1421
|
+
y: 0,
|
|
1422
|
+
w: t.w,
|
|
1423
|
+
h: t.h,
|
|
1424
|
+
crop: null
|
|
1425
|
+
};
|
|
1426
|
+
if (!(r > 0 && i > 0) || e === "fill" || t.w <= 0 || t.h <= 0) return a;
|
|
1427
|
+
if (e === "cover") {
|
|
1428
|
+
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);
|
|
1429
|
+
return {
|
|
1430
|
+
...a,
|
|
1431
|
+
crop: o || s ? {
|
|
1432
|
+
l: o,
|
|
1433
|
+
r: o,
|
|
1434
|
+
t: s,
|
|
1435
|
+
b: s
|
|
1436
|
+
} : null
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
let o = Math.min(t.w / r, t.h / i), s = r * o, c = i * o;
|
|
1440
|
+
return {
|
|
1441
|
+
x: (t.w - s) / 2,
|
|
1442
|
+
y: (t.h - c) / 2,
|
|
1443
|
+
w: s,
|
|
1444
|
+
h: c,
|
|
1445
|
+
crop: null
|
|
1446
|
+
};
|
|
1447
|
+
}
|
|
1448
|
+
function ln(e) {
|
|
1449
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1450
|
+
<xdr:wsDr xmlns:xdr="${Yt}" xmlns:a="${Xt}" xmlns:r="${Zt}">${e.map((e, t) => {
|
|
1451
|
+
let n = t + 2;
|
|
1452
|
+
return `<xdr:oneCellAnchor><xdr:from><xdr:col>${e.col}</xdr:col><xdr:colOff>${W(e.colOff)}</xdr:colOff><xdr:row>${e.row}</xdr:row><xdr:rowOff>${W(e.rowOff)}</xdr:rowOff></xdr:from><xdr:ext cx="${W(e.cx)}" cy="${W(e.cy)}"/>` + e.shape(n, W(e.cx), W(e.cy)) + "<xdr:clientData/></xdr:oneCellAnchor>";
|
|
1453
|
+
}).join("")}</xdr:wsDr>`;
|
|
1454
|
+
}
|
|
1455
|
+
function un(e) {
|
|
1456
|
+
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="${tn}" Target="../media/${e.file}"/>`).join("") + "</Relationships>";
|
|
1457
|
+
}
|
|
1458
|
+
function dn({ rId: e, alt: t = "", crop: n = null }) {
|
|
1459
|
+
return (r, i, a) => `<xdr:pic><xdr:nvPicPr><xdr:cNvPr id="${r}" name="Picture ${r - 1}" descr="${vn(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>${_n(i, a)}<a:prstGeom prst="rect"><a:avLst/></a:prstGeom></xdr:spPr></xdr:pic>`;
|
|
1460
|
+
}
|
|
1461
|
+
function fn({ fill: e = null, outline: t = null, radius: n = 0, w: r, h: i }) {
|
|
1462
|
+
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>";
|
|
1463
|
+
return (n, r, i) => `<xdr:sp macro="" textlink=""><xdr:nvSpPr><xdr:cNvPr id="${n}" name="Box ${n - 1}"/><xdr:cNvSpPr/></xdr:nvSpPr><xdr:spPr>${_n(r, i)}${s}` + (e ? gn(e) : "<a:noFill/>") + hn(t) + "</xdr:spPr></xdr:sp>";
|
|
1464
|
+
}
|
|
1465
|
+
function pn(e) {
|
|
1466
|
+
return (t, n, r) => `<xdr:cxnSp macro=""><xdr:nvCxnSpPr><xdr:cNvPr id="${t}" name="Line ${t - 1}"/><xdr:cNvCxnSpPr/></xdr:nvCxnSpPr><xdr:spPr>${_n(n, r)}<a:prstGeom prst="line"><a:avLst/></a:prstGeom>${hn(e)}</xdr:spPr></xdr:cxnSp>`;
|
|
1467
|
+
}
|
|
1468
|
+
function mn({ style: e = "solid", width: t = 1, color: n = null } = {}) {
|
|
1469
|
+
if (e === "none" || e === "hidden") return null;
|
|
1470
|
+
let r = Number(t);
|
|
1471
|
+
return !Number.isFinite(r) || r <= 0 ? null : {
|
|
1472
|
+
width: r,
|
|
1473
|
+
color: n ?? "FF000000",
|
|
1474
|
+
dash: {
|
|
1475
|
+
dashed: "dash",
|
|
1476
|
+
dotted: "sysDot"
|
|
1477
|
+
}[e] ?? null,
|
|
1478
|
+
double: e === "double"
|
|
1479
|
+
};
|
|
1480
|
+
}
|
|
1481
|
+
function hn(e) {
|
|
1482
|
+
return e ? `<a:ln w="${W(e.width)}"${e.double ? " cmpd=\"dbl\"" : ""}>` + gn(e.color) + (e.dash ? `<a:prstDash val="${e.dash}"/>` : "") + "</a:ln>" : "<a:ln><a:noFill/></a:ln>";
|
|
1483
|
+
}
|
|
1484
|
+
function gn(e) {
|
|
1485
|
+
return `<a:solidFill><a:srgbClr val="${e.slice(-6)}"/></a:solidFill>`;
|
|
1486
|
+
}
|
|
1487
|
+
function _n(e, t) {
|
|
1488
|
+
return `<a:xfrm><a:off x="0" y="0"/><a:ext cx="${e}" cy="${t}"/></a:xfrm>`;
|
|
1489
|
+
}
|
|
1490
|
+
function vn(e) {
|
|
1491
|
+
return String(e ?? "").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g, "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
1492
|
+
}
|
|
1493
|
+
//#endregion
|
|
1494
|
+
//#region src/render/items.js
|
|
1495
|
+
var G = (e) => `position:absolute;top:${K(e?.y)}px;left:${K(e?.x)}px;`;
|
|
1496
|
+
function K(e, t = 0) {
|
|
1497
|
+
let n = Number(e);
|
|
1498
|
+
return Number.isFinite(n) ? n : t;
|
|
1499
|
+
}
|
|
1500
|
+
function q(e, t = "") {
|
|
1501
|
+
if (e == null) return t;
|
|
1502
|
+
let n = String(e).replace(/[<>"'`&;{}\\]/g, "").replace(/url\s*\(/gi, "").replace(/\s+/g, " ").trim();
|
|
1503
|
+
return n === "" ? t : n;
|
|
1504
|
+
}
|
|
1505
|
+
function J(e) {
|
|
1506
|
+
return e == null ? "" : String(e).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1507
|
+
}
|
|
1508
|
+
function yn(e) {
|
|
1509
|
+
return (e || []).map((e) => {
|
|
1510
|
+
switch (e.type) {
|
|
1511
|
+
case "text": return bn(e);
|
|
1512
|
+
case "table": return Nn(e);
|
|
1513
|
+
case "line": return On(e);
|
|
1514
|
+
case "box": return xn(e);
|
|
1515
|
+
case "image": return En(e);
|
|
1516
|
+
default: return console.warn(`Unknown item type "${e?.type}"; it is not drawn.`), "";
|
|
1517
|
+
}
|
|
1518
|
+
}).join("");
|
|
1519
|
+
}
|
|
1520
|
+
function bn(e) {
|
|
1521
|
+
let t = e.style ?? {};
|
|
1522
|
+
return `
|
|
1523
|
+
<p id="${J(e.id)}" style="
|
|
1524
|
+
width:${K(e.w)}px;
|
|
1525
|
+
height:${K(e.h)}px;
|
|
1526
|
+
${G(e)}
|
|
1527
|
+
font-size:${K(t.fontSize, 12)}px;
|
|
1528
|
+
font-family:${q(t.fontFamily, "inherit")};
|
|
1529
|
+
font-weight:${q(t.fontWeight, "normal")};
|
|
1530
|
+
font-style:${q(t.fontStyle, "normal")};
|
|
1531
|
+
text-align:${q(t.align, "left")};
|
|
1532
|
+
color:${q(t.color, "inherit")};
|
|
1533
|
+
" data-item-id="${J(e.id)}" data-item-type="text">${J(e.text)}</p>
|
|
1534
|
+
`;
|
|
1535
|
+
}
|
|
1536
|
+
function xn(e) {
|
|
1537
|
+
let t = e.style ?? {}, n = `${Math.max(0, Number(t.borderWidth ?? 1)) || 1}px ${An.includes(t.borderStyle) ? t.borderStyle : "solid"} ${q(t.borderColor, "#000000")}`, r = Math.max(0, Number(t.radius ?? 0)) || 0, i = q(t.background);
|
|
1538
|
+
return `
|
|
1539
|
+
<div id="${J(e.id)}" class="box" style="
|
|
1540
|
+
width:${K(e.w)}px;
|
|
1541
|
+
height:${K(e.h)}px;
|
|
1542
|
+
${G(e)}
|
|
1543
|
+
border:${n};
|
|
1544
|
+
${r ? `border-radius:${r}px;` : ""}
|
|
1545
|
+
${i ? `background:${i};` : ""}
|
|
1546
|
+
" data-item-id="${J(e.id)}" data-item-type="box"></div>
|
|
1547
|
+
`;
|
|
1548
|
+
}
|
|
1549
|
+
var Sn = [
|
|
1550
|
+
"contain",
|
|
1551
|
+
"cover",
|
|
1552
|
+
"fill"
|
|
1553
|
+
], Cn = /^data:image\/(png|jpe?g|gif|webp|avif|bmp);base64,[a-z0-9+/=\s]*$/i, wn = [
|
|
1554
|
+
"http:",
|
|
1555
|
+
"https:",
|
|
1556
|
+
"blob:"
|
|
1557
|
+
];
|
|
1558
|
+
function Tn(e) {
|
|
1559
|
+
if (typeof e != "string") return "";
|
|
1560
|
+
let t = e.trim();
|
|
1561
|
+
if (t === "") return "";
|
|
1562
|
+
let n = t.replace(/[\u0000-\u0020\u007f]+/g, "");
|
|
1563
|
+
if (/^data:/i.test(n)) return Cn.test(n) ? n : "";
|
|
1564
|
+
let r = n.match(/^([a-z][a-z0-9+.-]*:)/i)?.[1]?.toLowerCase();
|
|
1565
|
+
return r == null || wn.includes(r) ? t : "";
|
|
1566
|
+
}
|
|
1567
|
+
function En(e) {
|
|
1568
|
+
let t = Object.prototype.hasOwnProperty.call(e, "resolvedSrc"), n = Tn(t ? e.resolvedSrc : e.src), r = Sn.includes(e.fit) ? e.fit : "contain", i = "";
|
|
1569
|
+
if (n) i = `<img src="${J(n)}" alt="${J(e.alt ?? "")}" style="object-fit:${r}" draggable="false">`;
|
|
1570
|
+
else if (!t) {
|
|
1571
|
+
let t = typeof e.field == "string" ? e.field.trim() : "";
|
|
1572
|
+
i = `<span class="image-empty">${t ? J(`{${t}}`) : "Image"}</span>`;
|
|
1573
|
+
}
|
|
1574
|
+
return `
|
|
1575
|
+
<div id="${J(e.id)}" class="image" style="
|
|
1576
|
+
width:${K(e.w)}px;
|
|
1577
|
+
height:${K(e.h)}px;
|
|
1578
|
+
${G(e)}
|
|
1579
|
+
" data-item-id="${J(e.id)}" data-item-type="image">${i}</div>
|
|
1580
|
+
`;
|
|
1581
|
+
}
|
|
1582
|
+
function Dn(e) {
|
|
1583
|
+
return `${Math.max(0, Number(e?.thickness ?? 1)) || 1}px ${kn.includes(e?.lineStyle) ? e.lineStyle : "solid"} ${q(e?.color, "#000000")}`;
|
|
1584
|
+
}
|
|
1585
|
+
function On(e) {
|
|
1586
|
+
let t = e.orientation === "vertical", n = Dn(e.style);
|
|
1587
|
+
return `
|
|
1588
|
+
<div id="${J(e.id)}" class="line${t ? " is-vertical" : ""}" style="
|
|
1589
|
+
width:${K(e.w)}px;
|
|
1590
|
+
height:${K(e.h)}px;
|
|
1591
|
+
${G(e)}
|
|
1592
|
+
" data-item-id="${J(e.id)}" data-item-type="line"><span class="line-mark"
|
|
1593
|
+
style="${t ? `border-left:${n}` : `border-top:${n}`}"></span></div>
|
|
1594
|
+
`;
|
|
1595
|
+
}
|
|
1596
|
+
var kn = [
|
|
1597
|
+
"solid",
|
|
1598
|
+
"dashed",
|
|
1599
|
+
"dotted",
|
|
1600
|
+
"double"
|
|
1601
|
+
], An = [...kn, "none"];
|
|
1602
|
+
function jn(e) {
|
|
1603
|
+
let t = e.rowHeight ?? 0, n = e.showHeader ? e.headerHeight ?? t : t, r = Math.min(t || Infinity, n || Infinity);
|
|
1604
|
+
return Number.isFinite(r) ? Math.max(1, Math.floor(r / 2)) : 1;
|
|
1605
|
+
}
|
|
1606
|
+
function Mn(e) {
|
|
1607
|
+
let t = e.style ?? {}, n = [];
|
|
1608
|
+
An.includes(t.borderStyle) && n.push(`--rs-rule-style:${t.borderStyle}`), t.borderColor && n.push(`--rs-rule-color:${q(t.borderColor)}`), t.headerBackground && n.push(`--rs-head-bg:${q(t.headerBackground)}`), t.headerColor && n.push(`--rs-head-color:${q(t.headerColor)}`), t.fontFamily && n.push(`--rs-cell-family:${q(t.fontFamily)}`);
|
|
1609
|
+
let r = Number(t.fontSize);
|
|
1610
|
+
Number.isFinite(r) && r > 0 && n.push(`--rs-cell-size:${r}px`), t.color && n.push(`--rs-cell-color:${q(t.color)}`), e.wrap === !1 && n.push("--rs-cell-wrap:nowrap");
|
|
1611
|
+
let i = Number(t.borderWidth);
|
|
1612
|
+
return Number.isFinite(i) && i > 0 && n.push(`--rs-rule-width:${Math.min(i, jn(e))}px`), n.length ? `${n.join(";")};` : "";
|
|
1613
|
+
}
|
|
1614
|
+
function Nn(e) {
|
|
1615
|
+
return `
|
|
1616
|
+
<table id="${J(e.id)}" style="width:${K(e.w)}px;height:${K(e.measuredHeight)}px;${G(e)}${Mn(e)}" data-item-id="${J(e.id)}" data-item-type="table">
|
|
1617
|
+
${e.groups ? zn(e) : Rn(e)}
|
|
1618
|
+
</table>
|
|
1619
|
+
`;
|
|
1620
|
+
}
|
|
1621
|
+
function Pn(e, t, n) {
|
|
1622
|
+
return `<div class="cell" style="height:${K(e)}px;text-align:${q(t, "left")}">${J(n)}</div>`;
|
|
1623
|
+
}
|
|
1624
|
+
function Fn(e) {
|
|
1625
|
+
let t = e.headerMeasured ?? e.headerHeight ?? e.rowHeight;
|
|
1626
|
+
return `<thead>
|
|
1627
|
+
<tr style="height:${K(t)}px">
|
|
1628
|
+
${e.columns.map((e) => `<th style="width:${K(e.width)}px;">${Pn(t, e.align, e.label)}</th>`).join("")}
|
|
1629
|
+
</tr>
|
|
1630
|
+
</thead>`;
|
|
1631
|
+
}
|
|
1632
|
+
function In(e, t, n) {
|
|
1633
|
+
return (t || []).map((t, r) => {
|
|
1634
|
+
let i = n?.[r] ?? e.rowHeight;
|
|
1635
|
+
return `<tr style="height:${K(i)}px">
|
|
1636
|
+
${e.columns.map((e) => `<td style="width:${K(e.width)}px;">${Pn(i, e.align, t[e.field])}</td>`).join("")}
|
|
1637
|
+
</tr>`;
|
|
1638
|
+
}).join("");
|
|
1639
|
+
}
|
|
1640
|
+
function Ln(e, t, n) {
|
|
1641
|
+
return e ? `<tr class="${n}">
|
|
1642
|
+
<td colspan="${t}" class="group-band-cell">
|
|
1643
|
+
<div class="band" style="position:relative;height:${K(e.measuredHeight > 0 ? e.measuredHeight : e.height ?? 0)}px">${yn(e.items)}</div>
|
|
1644
|
+
</td>
|
|
1645
|
+
</tr>` : "";
|
|
1646
|
+
}
|
|
1647
|
+
function Rn(e) {
|
|
1648
|
+
return `
|
|
1649
|
+
${e.showHeader ? Fn(e) : ""}
|
|
1650
|
+
<tbody>
|
|
1651
|
+
${In(e, e.row, e.rowHeights)}
|
|
1652
|
+
</tbody>
|
|
1653
|
+
`;
|
|
1654
|
+
}
|
|
1655
|
+
function zn(e) {
|
|
1656
|
+
let t = e.columns.length;
|
|
1657
|
+
return e.groups.map((n) => `
|
|
1658
|
+
${n.showHeader && e.showHeader ? Fn(e) : ""}
|
|
1659
|
+
<tbody>
|
|
1660
|
+
${Ln(n.headerBand, t, "group-header")}
|
|
1661
|
+
${In(e, n.rows, n.rowHeights)}
|
|
1662
|
+
${n.showFooter ? Ln(n.footerBand, t, "group-footer") : ""}
|
|
1663
|
+
</tbody>
|
|
1664
|
+
`).join("");
|
|
1665
|
+
}
|
|
1666
|
+
//#endregion
|
|
1667
|
+
//#region src/engine/zip.js
|
|
1668
|
+
var Bn = 0, Vn = 33, Hn = 2048, Un = 20, Y = null;
|
|
1669
|
+
function Wn() {
|
|
1670
|
+
if (Y) return Y;
|
|
1671
|
+
Y = /* @__PURE__ */ new Uint32Array(256);
|
|
1672
|
+
for (let e = 0; e < 256; e++) {
|
|
1673
|
+
let t = e;
|
|
1674
|
+
for (let e = 0; e < 8; e++) t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
|
|
1675
|
+
Y[e] = t >>> 0;
|
|
1676
|
+
}
|
|
1677
|
+
return Y;
|
|
1678
|
+
}
|
|
1679
|
+
function Gn(e) {
|
|
1680
|
+
let t = Wn(), n = 4294967295;
|
|
1681
|
+
for (let r = 0; r < e.length; r++) n = t[(n ^ e[r]) & 255] ^ n >>> 8;
|
|
1682
|
+
return (n ^ 4294967295) >>> 0;
|
|
1683
|
+
}
|
|
1684
|
+
function Kn(e) {
|
|
1685
|
+
let t = new TextEncoder(), n = e.map(({ name: e, data: n }) => {
|
|
1686
|
+
let r = typeof n == "string" ? t.encode(n) : n;
|
|
1687
|
+
return {
|
|
1688
|
+
name: t.encode(e),
|
|
1689
|
+
bytes: r,
|
|
1690
|
+
crc: Gn(r),
|
|
1691
|
+
offset: 0
|
|
1692
|
+
};
|
|
1693
|
+
}), 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) => {
|
|
1694
|
+
o.setUint16(s, e, !0), s += 2;
|
|
1695
|
+
}, l = (e) => {
|
|
1696
|
+
o.setUint32(s, e, !0), s += 4;
|
|
1697
|
+
}, u = (e) => {
|
|
1698
|
+
a.set(e, s), s += e.length;
|
|
1699
|
+
};
|
|
1700
|
+
for (let e of n) e.offset = s, l(67324752), c(Un), c(Hn), c(0), c(Bn), c(Vn), l(e.crc), l(e.bytes.length), l(e.bytes.length), c(e.name.length), c(0), u(e.name), u(e.bytes);
|
|
1701
|
+
let d = s;
|
|
1702
|
+
for (let e of n) l(33639248), c(Un), c(Un), c(Hn), c(0), c(Bn), c(Vn), 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);
|
|
1703
|
+
let f = s - d;
|
|
1704
|
+
return l(101010256), c(0), c(0), c(n.length), c(n.length), l(f), l(d), c(0), a;
|
|
1705
|
+
}
|
|
1706
|
+
//#endregion
|
|
1707
|
+
//#region src/engine/xlsx.js
|
|
1708
|
+
var X = Object.freeze({
|
|
1709
|
+
rows: 1048576,
|
|
1710
|
+
columns: 16384,
|
|
1711
|
+
cellText: 32767,
|
|
1712
|
+
sheetName: 31
|
|
1713
|
+
}), qn = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", Jn = "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Z = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", Yn = "http://schemas.openxmlformats.org/package/2006/relationships", Xn = "http://schemas.openxmlformats.org/package/2006/content-types", Zn = `${Z}/officeDocument`, Qn = `${Z}/worksheet`, $n = `${Z}/styles`, er = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml", tr = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml", nr = "application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml", rr = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", ir = Object.freeze({ font: Object.freeze({ bold: !0 }) }), ar = 14, or = 22, sr = /[\x00-\x08\x0B\x0C\x0E-\x1F]/g, cr = /_(x[0-9A-Fa-f]{4}_)/g, lr = /[\[\]:*?\/\\\x00-\x1F]/g, ur = 8, dr = 60, fr = 50, pr = 2.5, mr = 2, hr = 24, gr = 20, _r = /^-?(0|[1-9]\d*)(\.\d+)?$/, vr = /\{[^{}]+\}/;
|
|
1714
|
+
function Q(e, t = {}) {
|
|
1715
|
+
let { report: n = !0, tables: r = !0, styled: i = !0, reportSheetName: a = "Report", groupColumn: o = !0, groupLabel: s = "Group", images: c = null } = t, l = [];
|
|
1716
|
+
if (n && dt(e).length > 0 && l.push(xr(e, a, i, c)), r) for (let { id: t } of mt(e)) l.push(Sr(pt(e, t), i, o, s));
|
|
1717
|
+
if (l.length === 0) return /* @__PURE__ */ new Uint8Array();
|
|
1718
|
+
let u = Hr(l.map((e) => e.name));
|
|
1719
|
+
l.forEach((e, t) => {
|
|
1720
|
+
e.name = u[t], e.width = e.rows.reduce((e, t) => Math.max(e, t.cells.length), 0);
|
|
1721
|
+
});
|
|
1722
|
+
let d = qt(), f = l.map((e) => Fr(e, d)), p = [], m = [];
|
|
1723
|
+
return l.forEach((e, t) => {
|
|
1724
|
+
e.drawing && (p.push({
|
|
1725
|
+
sheet: t + 1,
|
|
1726
|
+
n: p.length + 1,
|
|
1727
|
+
...e.drawing
|
|
1728
|
+
}), m.push(...e.drawing.media));
|
|
1729
|
+
}), Kn([
|
|
1730
|
+
{
|
|
1731
|
+
name: "[Content_Types].xml",
|
|
1732
|
+
data: Wr(l.length, p, m)
|
|
1733
|
+
},
|
|
1734
|
+
{
|
|
1735
|
+
name: "_rels/.rels",
|
|
1736
|
+
data: Gr()
|
|
1737
|
+
},
|
|
1738
|
+
{
|
|
1739
|
+
name: "xl/workbook.xml",
|
|
1740
|
+
data: qr(l)
|
|
1741
|
+
},
|
|
1742
|
+
{
|
|
1743
|
+
name: "xl/_rels/workbook.xml.rels",
|
|
1744
|
+
data: Jr(l.length)
|
|
1745
|
+
},
|
|
1746
|
+
{
|
|
1747
|
+
name: "xl/styles.xml",
|
|
1748
|
+
data: d.xml()
|
|
1749
|
+
},
|
|
1750
|
+
...f.map((e, t) => ({
|
|
1751
|
+
name: `xl/worksheets/sheet${t + 1}.xml`,
|
|
1752
|
+
data: e
|
|
1753
|
+
})),
|
|
1754
|
+
...p.flatMap((e) => [
|
|
1755
|
+
{
|
|
1756
|
+
name: `xl/worksheets/_rels/sheet${e.sheet}.xml.rels`,
|
|
1757
|
+
data: Kr(e.n)
|
|
1758
|
+
},
|
|
1759
|
+
{
|
|
1760
|
+
name: `xl/drawings/drawing${e.n}.xml`,
|
|
1761
|
+
data: ln(e.anchors)
|
|
1762
|
+
},
|
|
1763
|
+
...e.media.length ? [{
|
|
1764
|
+
name: `xl/drawings/_rels/drawing${e.n}.xml.rels`,
|
|
1765
|
+
data: un(e.media)
|
|
1766
|
+
}] : []
|
|
1767
|
+
]),
|
|
1768
|
+
...m.map((e) => ({
|
|
1769
|
+
name: `xl/media/${e.file}`,
|
|
1770
|
+
data: e.bytes
|
|
1771
|
+
}))
|
|
1772
|
+
]);
|
|
1773
|
+
}
|
|
1774
|
+
async function yr(e, t = {}) {
|
|
1775
|
+
let n = t.fetch ?? globalThis.fetch, r = new Map(t.images instanceof Map ? t.images : Object.entries(t.images ?? {}));
|
|
1776
|
+
return typeof n == "function" && await Promise.all(br(e).filter((e) => !r.has(e)).map(async (e) => {
|
|
1777
|
+
try {
|
|
1778
|
+
let t = await n(e);
|
|
1779
|
+
t?.ok && r.set(e, new Uint8Array(await t.arrayBuffer()));
|
|
1780
|
+
} catch {}
|
|
1781
|
+
})), Q(e, {
|
|
1782
|
+
...t,
|
|
1783
|
+
images: r
|
|
1784
|
+
});
|
|
1785
|
+
}
|
|
1786
|
+
function br(e) {
|
|
1787
|
+
let t = /* @__PURE__ */ new Set();
|
|
1788
|
+
for (let n of ft(e).graphics) {
|
|
1789
|
+
if (n.kind !== "image") continue;
|
|
1790
|
+
let e = Tn(n.item.resolvedSrc);
|
|
1791
|
+
e && !/^data:/i.test(e) && t.add(e);
|
|
1792
|
+
}
|
|
1793
|
+
return [...t];
|
|
1794
|
+
}
|
|
1795
|
+
function xr(e, t, n, r) {
|
|
1796
|
+
let { rows: i, graphics: a } = ft(e);
|
|
1797
|
+
if (!n) {
|
|
1798
|
+
let e = i.filter((e) => !e.spacer).map(({ cells: e, header: t }) => ({
|
|
1799
|
+
cells: e.map((e) => ({
|
|
1800
|
+
value: e,
|
|
1801
|
+
format: t ? ir : null
|
|
1802
|
+
})),
|
|
1803
|
+
height: null
|
|
1804
|
+
}));
|
|
1805
|
+
return {
|
|
1806
|
+
name: t,
|
|
1807
|
+
rows: e,
|
|
1808
|
+
frozen: !1,
|
|
1809
|
+
gridLines: !0,
|
|
1810
|
+
widths: Pr(e)
|
|
1811
|
+
};
|
|
1812
|
+
}
|
|
1813
|
+
let o = Cr(i), s = Nr(), c = i.flatMap((e) => e.spacer ? [{
|
|
1814
|
+
cells: [],
|
|
1815
|
+
page: e.page,
|
|
1816
|
+
top: e.top,
|
|
1817
|
+
own: e.height
|
|
1818
|
+
}] : e.design?.length > 0 && e.design.every((e) => e?.kind === "text") ? wr(e, o, s) : [{
|
|
1819
|
+
cells: e.cells.map((t, n) => ({
|
|
1820
|
+
value: t,
|
|
1821
|
+
format: s(e.design?.[n])
|
|
1822
|
+
})),
|
|
1823
|
+
page: e.page,
|
|
1824
|
+
top: e.top,
|
|
1825
|
+
own: e.height
|
|
1826
|
+
}]);
|
|
1827
|
+
Er(c);
|
|
1828
|
+
let l = Or(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) => Bt(o.px[t] ?? 64));
|
|
1829
|
+
return {
|
|
1830
|
+
name: t,
|
|
1831
|
+
rows: c.map((e) => ({
|
|
1832
|
+
cells: e.cells,
|
|
1833
|
+
height: e.height
|
|
1834
|
+
})),
|
|
1835
|
+
frozen: !1,
|
|
1836
|
+
gridLines: !1,
|
|
1837
|
+
widths: d,
|
|
1838
|
+
drawing: l.anchors.length ? l : null
|
|
1839
|
+
};
|
|
1840
|
+
}
|
|
1841
|
+
function Sr(e, t, n, r) {
|
|
1842
|
+
let i = n && e.rows.some((e) => e.group !== null), a = i ? [{
|
|
1843
|
+
field: null,
|
|
1844
|
+
align: "left"
|
|
1845
|
+
}, ...e.columns] : e.columns, o = i ? [r, ...e.columns.map(B)] : e.columns.map(B), s = a.map((n) => {
|
|
1846
|
+
if (!t) return ir;
|
|
1847
|
+
let r = Ut({
|
|
1848
|
+
kind: "head",
|
|
1849
|
+
column: n,
|
|
1850
|
+
table: e.table
|
|
1851
|
+
});
|
|
1852
|
+
return r.alignment.horizontal === "right" ? {
|
|
1853
|
+
...r,
|
|
1854
|
+
alignment: {
|
|
1855
|
+
...r.alignment,
|
|
1856
|
+
indent: Math.max(r.alignment.indent ?? 0, mr)
|
|
1857
|
+
}
|
|
1858
|
+
} : r;
|
|
1859
|
+
}), c = a.map((n) => t ? Ut({
|
|
1860
|
+
kind: "cell",
|
|
1861
|
+
column: n,
|
|
1862
|
+
table: e.table
|
|
1863
|
+
}) : null), l = [{
|
|
1864
|
+
cells: o.map((e, t) => ({
|
|
1865
|
+
value: e,
|
|
1866
|
+
format: s[t]
|
|
1867
|
+
})),
|
|
1868
|
+
height: t ? e.headerHeight : null
|
|
1869
|
+
}];
|
|
1870
|
+
for (let { group: n, row: r, height: a } of e.rows) {
|
|
1871
|
+
let o = e.columns.map((e) => r?.[e.field]), s = i ? [n, ...o] : o;
|
|
1872
|
+
l.push({
|
|
1873
|
+
cells: s.map((e, t) => ({
|
|
1874
|
+
value: e,
|
|
1875
|
+
format: c[t]
|
|
1876
|
+
})),
|
|
1877
|
+
height: t ? a : null
|
|
1878
|
+
});
|
|
1879
|
+
}
|
|
1880
|
+
let u = Pr(l), d = t ? a.map((e, t) => (Number(e.width) > 0 ? Bt(Number(e.width)) : u[t]) + pr) : u.map((e) => e + pr);
|
|
1881
|
+
return {
|
|
1882
|
+
name: e.id,
|
|
1883
|
+
rows: l,
|
|
1884
|
+
frozen: !0,
|
|
1885
|
+
gridLines: !0,
|
|
1886
|
+
widths: d
|
|
1887
|
+
};
|
|
1888
|
+
}
|
|
1889
|
+
function Cr(e) {
|
|
1890
|
+
let t = [];
|
|
1891
|
+
for (let n of e) n.design?.forEach((e, n) => {
|
|
1892
|
+
if (!e || e.kind === "text") return;
|
|
1893
|
+
let r = Number(e.column?.width);
|
|
1894
|
+
t[n] = Math.max(t[n] ?? 0, r > 0 ? r : 64);
|
|
1895
|
+
});
|
|
1896
|
+
for (let e = 0; e < t.length; e++) t[e] ??= 64;
|
|
1897
|
+
function n(e) {
|
|
1898
|
+
let n = 0;
|
|
1899
|
+
for (let r = 0;; r++) {
|
|
1900
|
+
if (r === t.length) {
|
|
1901
|
+
if (t.length >= fr) return t.length - 1;
|
|
1902
|
+
t.push(64);
|
|
1903
|
+
}
|
|
1904
|
+
if (n += t[r], e < n) return r;
|
|
1905
|
+
}
|
|
1906
|
+
}
|
|
1907
|
+
let r = (e) => t.slice(0, e).reduce((e, t) => e + t, 0);
|
|
1908
|
+
return {
|
|
1909
|
+
px: t,
|
|
1910
|
+
at: n,
|
|
1911
|
+
left: r,
|
|
1912
|
+
right: (e) => r(e) + t[e]
|
|
1913
|
+
};
|
|
1914
|
+
}
|
|
1915
|
+
function wr(e, t, n) {
|
|
1916
|
+
let r = [], i = (e) => {
|
|
1917
|
+
let t = r.find((t) => e.every((e) => t.cells[e] === void 0));
|
|
1918
|
+
return t || (t = {
|
|
1919
|
+
cells: [],
|
|
1920
|
+
top: Infinity,
|
|
1921
|
+
bottom: -Infinity
|
|
1922
|
+
}, r.push(t)), t;
|
|
1923
|
+
};
|
|
1924
|
+
return e.cells.forEach((r, a) => {
|
|
1925
|
+
let o = e.design[a], s = n(o)?.alignment?.horizontal ?? "left", c = Tr(r, o.template), l = Math.max(0, Number(o.x) || 0), u = Math.max(1, Number(o.w) || 1), d = t.at(l), f = Math.max(d, t.at(l + u - 1)), p;
|
|
1926
|
+
if (s === "center" && f > d) {
|
|
1927
|
+
let e = Array.from({ length: f - d + 1 }, (e, t) => d + t), t = n.text(o, { centred: !0 });
|
|
1928
|
+
p = i(e), p.cells[d] = {
|
|
1929
|
+
value: c,
|
|
1930
|
+
format: t
|
|
1931
|
+
};
|
|
1932
|
+
for (let e = d + 1; e <= f; e++) p.cells[e] = {
|
|
1933
|
+
value: null,
|
|
1934
|
+
format: t
|
|
1935
|
+
};
|
|
1936
|
+
} else {
|
|
1937
|
+
let e = s === "right" ? f : d, r = s === "right" ? t.right(e) - (l + u) : l - t.left(e);
|
|
1938
|
+
p = i([e]), p.cells[e] = {
|
|
1939
|
+
value: c,
|
|
1940
|
+
format: n.text(o, { indent: Lt(r) })
|
|
1941
|
+
};
|
|
1942
|
+
}
|
|
1943
|
+
p.top = Math.min(p.top, o.y), p.bottom = Math.max(p.bottom, o.y + (Number(o.h) || 0));
|
|
1944
|
+
}), r.map((t) => ({
|
|
1945
|
+
cells: t.cells,
|
|
1946
|
+
page: e.page,
|
|
1947
|
+
top: t.top,
|
|
1948
|
+
own: t.bottom - t.top
|
|
1949
|
+
}));
|
|
1950
|
+
}
|
|
1951
|
+
function Tr(e, t) {
|
|
1952
|
+
if (typeof e != "string" || typeof t != "string" || !vr.test(t)) return e;
|
|
1953
|
+
let n = e.trim();
|
|
1954
|
+
if (!_r.test(n)) return e;
|
|
1955
|
+
let r = n.replace(/^-/, "").split(".")[0], i = n.replace(/[-.]/g, "");
|
|
1956
|
+
return r.length > 11 || i.length > 15 ? e : Number(n);
|
|
1957
|
+
}
|
|
1958
|
+
function Er(e) {
|
|
1959
|
+
let t = 0;
|
|
1960
|
+
e.forEach((n, r) => {
|
|
1961
|
+
let i = n.own > 0 ? n.own : gr, a = e[r + 1], o = i;
|
|
1962
|
+
if (a && a.page === n.page) {
|
|
1963
|
+
let e = a.top - n.top;
|
|
1964
|
+
e > i && (o = Math.min(e, i + hr));
|
|
1965
|
+
}
|
|
1966
|
+
n.height = zt(o) / .75, n.sheetTop = t, t += n.height;
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
function Dr(e, t) {
|
|
1970
|
+
let n = /* @__PURE__ */ new Map();
|
|
1971
|
+
e.forEach((e, t) => {
|
|
1972
|
+
n.has(e.page) || n.set(e.page, []), n.get(e.page).push(t);
|
|
1973
|
+
});
|
|
1974
|
+
function r(t, r) {
|
|
1975
|
+
let i = n.get(t) ?? [e.length - 1], a = i[0];
|
|
1976
|
+
for (let t of i) e[t].top <= r && e[t].top >= e[a].top && (a = t);
|
|
1977
|
+
let o = e[a], s = Math.max(0, Math.min(r - o.top, o.height));
|
|
1978
|
+
return {
|
|
1979
|
+
row: a,
|
|
1980
|
+
offset: s,
|
|
1981
|
+
sheet: o.sheetTop + s
|
|
1982
|
+
};
|
|
1983
|
+
}
|
|
1984
|
+
function i(e) {
|
|
1985
|
+
let n = t.at(Math.max(0, e)), r = Math.max(0, Math.min(e - t.left(n), t.px[n]));
|
|
1986
|
+
return {
|
|
1987
|
+
col: n,
|
|
1988
|
+
offset: r,
|
|
1989
|
+
sheet: t.left(n) + r
|
|
1990
|
+
};
|
|
1991
|
+
}
|
|
1992
|
+
return {
|
|
1993
|
+
x: i,
|
|
1994
|
+
y: r
|
|
1995
|
+
};
|
|
1996
|
+
}
|
|
1997
|
+
function Or(e, t, n, r) {
|
|
1998
|
+
let i = Dr(t, n), a = [], o = kr(r), s = (e, t, n, r, a) => {
|
|
1999
|
+
let o = i.x(t), s = i.y(e, n), c = i.x(t + r), l = i.y(e, n + a);
|
|
2000
|
+
return {
|
|
2001
|
+
anchor: {
|
|
2002
|
+
col: o.col,
|
|
2003
|
+
colOff: o.offset,
|
|
2004
|
+
row: s.row,
|
|
2005
|
+
rowOff: s.offset
|
|
2006
|
+
},
|
|
2007
|
+
sheet: {
|
|
2008
|
+
x1: o.sheet,
|
|
2009
|
+
x2: c.sheet,
|
|
2010
|
+
y1: s.sheet,
|
|
2011
|
+
y2: l.sheet
|
|
2012
|
+
}
|
|
2013
|
+
};
|
|
2014
|
+
};
|
|
2015
|
+
for (let r of e) {
|
|
2016
|
+
if (r.kind === "image") {
|
|
2017
|
+
let e = o.get(Tn(r.item.resolvedSrc));
|
|
2018
|
+
if (!e) continue;
|
|
2019
|
+
let t = cn(r.item.fit, {
|
|
2020
|
+
w: r.w,
|
|
2021
|
+
h: r.h
|
|
2022
|
+
}, e.natural), { anchor: n } = s(r.page, r.x + t.x, r.y + t.y, t.w, t.h);
|
|
2023
|
+
a.push({
|
|
2024
|
+
...n,
|
|
2025
|
+
cx: t.w,
|
|
2026
|
+
cy: t.h,
|
|
2027
|
+
shape: dn({
|
|
2028
|
+
rId: e.rId,
|
|
2029
|
+
alt: r.item.alt,
|
|
2030
|
+
crop: t.crop
|
|
2031
|
+
})
|
|
2032
|
+
});
|
|
2033
|
+
continue;
|
|
2034
|
+
}
|
|
2035
|
+
if (r.kind === "line") {
|
|
2036
|
+
let e = r.item.style ?? {}, t = Math.max(0, Number(e.thickness ?? 1)) || 1, n = mn({
|
|
2037
|
+
style: [
|
|
2038
|
+
"solid",
|
|
2039
|
+
"dashed",
|
|
2040
|
+
"dotted",
|
|
2041
|
+
"double"
|
|
2042
|
+
].includes(e.lineStyle) ? e.lineStyle : "solid",
|
|
2043
|
+
width: t,
|
|
2044
|
+
color: U(e.color) ?? "FF000000"
|
|
2045
|
+
}), 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);
|
|
2046
|
+
a.push({
|
|
2047
|
+
...o.anchor,
|
|
2048
|
+
cx: i ? 0 : o.sheet.x2 - o.sheet.x1,
|
|
2049
|
+
cy: i ? o.sheet.y2 - o.sheet.y1 : 0,
|
|
2050
|
+
shape: pn(n)
|
|
2051
|
+
});
|
|
2052
|
+
continue;
|
|
2053
|
+
}
|
|
2054
|
+
if (r.kind === "box") {
|
|
2055
|
+
let e = r.item.style ?? {}, i = U(e.background), o = Math.max(0, Number(e.borderWidth ?? 1)) || 1, c = e.borderStyle === "none" ? null : mn({
|
|
2056
|
+
style: [
|
|
2057
|
+
"solid",
|
|
2058
|
+
"dashed",
|
|
2059
|
+
"dotted",
|
|
2060
|
+
"double"
|
|
2061
|
+
].includes(e.borderStyle) ? e.borderStyle : "solid",
|
|
2062
|
+
width: o,
|
|
2063
|
+
color: U(e.borderColor) ?? "FF000000"
|
|
2064
|
+
}), l = s(r.page, r.x, r.y, r.w, r.h), u = i && jr(t, n, l.sheet);
|
|
2065
|
+
if (u && Mr(t, n, l.sheet, i), !c && (u || !i)) continue;
|
|
2066
|
+
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);
|
|
2067
|
+
a.push({
|
|
2068
|
+
...f.anchor,
|
|
2069
|
+
cx: p,
|
|
2070
|
+
cy: m,
|
|
2071
|
+
shape: fn({
|
|
2072
|
+
fill: u ? null : i,
|
|
2073
|
+
outline: c,
|
|
2074
|
+
radius: Math.max(0, (Number(e.radius) || 0) - d),
|
|
2075
|
+
w: p,
|
|
2076
|
+
h: m
|
|
2077
|
+
})
|
|
2078
|
+
});
|
|
2079
|
+
}
|
|
2080
|
+
}
|
|
2081
|
+
return {
|
|
2082
|
+
anchors: a,
|
|
2083
|
+
media: o.list
|
|
2084
|
+
};
|
|
2085
|
+
}
|
|
2086
|
+
function kr(e) {
|
|
2087
|
+
let t = e instanceof Map ? e : new Map(Object.entries(e ?? {})), n = /* @__PURE__ */ new Map(), r = [];
|
|
2088
|
+
function i(e) {
|
|
2089
|
+
if (!e) return null;
|
|
2090
|
+
if (n.has(e)) return n.get(e);
|
|
2091
|
+
let i = an(e);
|
|
2092
|
+
if (!i) {
|
|
2093
|
+
let n = t.get(e);
|
|
2094
|
+
i = n instanceof ArrayBuffer ? new Uint8Array(n) : n instanceof Uint8Array ? n : null;
|
|
2095
|
+
}
|
|
2096
|
+
let a = i ? on(i) : null;
|
|
2097
|
+
if (!a || !nn[a.ext]) return n.set(e, null), null;
|
|
2098
|
+
let o = r.length + 1, s = {
|
|
2099
|
+
rId: `rId${o}`,
|
|
2100
|
+
file: `image${o}.${a.ext}`,
|
|
2101
|
+
ext: a.ext,
|
|
2102
|
+
bytes: i,
|
|
2103
|
+
natural: {
|
|
2104
|
+
width: a.width,
|
|
2105
|
+
height: a.height
|
|
2106
|
+
}
|
|
2107
|
+
};
|
|
2108
|
+
return r.push(s), n.set(e, s), s;
|
|
2109
|
+
}
|
|
2110
|
+
return {
|
|
2111
|
+
get: i,
|
|
2112
|
+
list: r
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
function Ar(e, t, n) {
|
|
2116
|
+
let r = (e, t, n, r) => Math.min(t, r) - Math.max(e, n) >= (r - n) / 2, i = [];
|
|
2117
|
+
e.forEach((e, t) => {
|
|
2118
|
+
e.height > 0 && r(n.y1, n.y2, e.sheetTop, e.sheetTop + e.height) && i.push(t);
|
|
2119
|
+
});
|
|
2120
|
+
let a = [];
|
|
2121
|
+
for (let e = 0; e < t.px.length; e++) r(n.x1, n.x2, t.left(e), t.right(e)) && a.push(e);
|
|
2122
|
+
if (i.length && a.length) return {
|
|
2123
|
+
rowIndexes: i,
|
|
2124
|
+
colIndexes: a
|
|
2125
|
+
};
|
|
2126
|
+
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);
|
|
2127
|
+
return s < 0 ? {
|
|
2128
|
+
rowIndexes: [],
|
|
2129
|
+
colIndexes: []
|
|
2130
|
+
} : {
|
|
2131
|
+
rowIndexes: [s],
|
|
2132
|
+
colIndexes: [c]
|
|
2133
|
+
};
|
|
2134
|
+
}
|
|
2135
|
+
function jr(e, t, n) {
|
|
2136
|
+
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));
|
|
2137
|
+
}
|
|
2138
|
+
function Mr(e, t, n, r) {
|
|
2139
|
+
let { rowIndexes: i, colIndexes: a } = Ar(e, t, n), o = /* @__PURE__ */ new Map(), s = (e) => e?.fill ? e : (o.has(e) || o.set(e, {
|
|
2140
|
+
...e ?? {},
|
|
2141
|
+
fill: r
|
|
2142
|
+
}), o.get(e));
|
|
2143
|
+
for (let t of i) for (let n of a) {
|
|
2144
|
+
let r = e[t].cells[n];
|
|
2145
|
+
e[t].cells[n] = r ? {
|
|
2146
|
+
...r,
|
|
2147
|
+
format: s(r.format)
|
|
2148
|
+
} : {
|
|
2149
|
+
value: null,
|
|
2150
|
+
format: s(null)
|
|
2151
|
+
};
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
function Nr() {
|
|
2155
|
+
let e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap();
|
|
2156
|
+
function n(t) {
|
|
2157
|
+
if (!t) return null;
|
|
2158
|
+
if (t.kind === "text") return n.text(t);
|
|
2159
|
+
let r = t.column ?? t;
|
|
2160
|
+
e.has(r) || e.set(r, {});
|
|
2161
|
+
let i = e.get(r);
|
|
2162
|
+
return i[t.kind] ??= Ut(t), i[t.kind];
|
|
2163
|
+
}
|
|
2164
|
+
return n.text = (e, { centred: n = !1, indent: r = 0 } = {}) => {
|
|
2165
|
+
let i = e.style ?? e;
|
|
2166
|
+
t.has(i) || t.set(i, /* @__PURE__ */ new Map());
|
|
2167
|
+
let a = t.get(i), o = `${n}|${r}`;
|
|
2168
|
+
if (!a.has(o)) {
|
|
2169
|
+
let t = Ut(e);
|
|
2170
|
+
a.set(o, {
|
|
2171
|
+
...t,
|
|
2172
|
+
alignment: {
|
|
2173
|
+
...t.alignment,
|
|
2174
|
+
...n ? { horizontal: "centerContinuous" } : {},
|
|
2175
|
+
indent: n ? 0 : r
|
|
2176
|
+
}
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
return a.get(o);
|
|
2180
|
+
}, n;
|
|
2181
|
+
}
|
|
2182
|
+
function Pr(e) {
|
|
2183
|
+
let t = [];
|
|
2184
|
+
for (let { cells: n } of e) n.forEach((e, n) => {
|
|
2185
|
+
t[n] ??= ur;
|
|
2186
|
+
let r = e?.value;
|
|
2187
|
+
if (r == null) return;
|
|
2188
|
+
let i = r instanceof Date ? 18 : String(r).split("\n").reduce((e, t) => Math.max(e, t.length), 0);
|
|
2189
|
+
t[n] = Math.max(t[n], Math.min(dr, i + 2));
|
|
2190
|
+
});
|
|
2191
|
+
for (let e = 0; e < t.length; e++) t[e] ??= ur;
|
|
2192
|
+
return t;
|
|
2193
|
+
}
|
|
2194
|
+
function Fr({ name: e, rows: t, frozen: n, gridLines: r, widths: i, width: a, drawing: o }, s) {
|
|
2195
|
+
if (t.length > X.rows) throw RangeError(`Sheet "${e}" has ${t.length} rows; Excel allows ${X.rows}.`);
|
|
2196
|
+
if (a > X.columns) throw RangeError(`Sheet "${e}" has ${a} columns; Excel allows ${X.columns}.`);
|
|
2197
|
+
let c = Ir(a, t.length), l = Lr(s), u = [rr, `<worksheet xmlns="${Jn}" xmlns:r="${Z}">`];
|
|
2198
|
+
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) {
|
|
2199
|
+
u.push("<cols>");
|
|
2200
|
+
for (let e = 0; e < a; e++) {
|
|
2201
|
+
let t = i?.[e] ?? ur;
|
|
2202
|
+
u.push(`<col min="${e + 1}" max="${e + 1}" width="${t}" customWidth="1"/>`);
|
|
2203
|
+
}
|
|
2204
|
+
u.push("</cols>");
|
|
2205
|
+
}
|
|
2206
|
+
return u.push("<sheetData>"), t.forEach((e, t) => {
|
|
2207
|
+
let n = "";
|
|
2208
|
+
e.cells.forEach((e, r) => {
|
|
2209
|
+
e && (n += Rr(`${Vr(r)}${t + 1}`, e.value, e.format, l));
|
|
2210
|
+
});
|
|
2211
|
+
let r = Number(e.height) > 0 ? ` ht="${zt(Number(e.height))}" customHeight="1"` : "";
|
|
2212
|
+
u.push(`<row r="${t + 1}"${r}>${n}</row>`);
|
|
2213
|
+
}), 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("");
|
|
2214
|
+
}
|
|
2215
|
+
function Ir(e, t) {
|
|
2216
|
+
if (e === 0 || t === 0) return "A1";
|
|
2217
|
+
let n = `${Vr(e - 1)}${t}`;
|
|
2218
|
+
return n === "A1" ? "A1" : `A1:${n}`;
|
|
2219
|
+
}
|
|
2220
|
+
function Lr(e) {
|
|
2221
|
+
let t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
|
|
2222
|
+
return (r, i) => {
|
|
2223
|
+
if (!r) return n.has(i) || n.set(i, e.xf(null, i)), n.get(i);
|
|
2224
|
+
t.has(r) || t.set(r, /* @__PURE__ */ new Map());
|
|
2225
|
+
let a = t.get(r);
|
|
2226
|
+
return a.has(i) || a.set(i, e.xf(r, i)), a.get(i);
|
|
2227
|
+
};
|
|
2228
|
+
}
|
|
2229
|
+
function Rr(e, t, n, r) {
|
|
2230
|
+
let i = t == null || t === "", a = t instanceof Date && !Number.isNaN(t.getTime()), o = 0, s = null;
|
|
2231
|
+
a && (s = Br(t), o = Number.isInteger(s) ? ar : or);
|
|
2232
|
+
let c = r(n, o), l = c ? ` s="${c}"` : "";
|
|
2233
|
+
return i ? c ? `<c r="${e}"${l}/>` : "" : a ? `<c r="${e}"${l}><v>${s}</v></c>` : typeof t == "number" ? Number.isFinite(t) ? `<c r="${e}"${l}><v>${t}</v></c>` : zr(e, String(t), l) : typeof t == "boolean" ? `<c r="${e}"${l} t="b"><v>${+!!t}</v></c>` : zr(e, String(t), l);
|
|
2234
|
+
}
|
|
2235
|
+
function zr(e, t, n) {
|
|
2236
|
+
let r = t.replace(sr, "");
|
|
2237
|
+
return r.length > X.cellText && (r = r.slice(0, X.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\"" : ""}>${Yr(r.replace(cr, "_x005F_$1"))}</t></is></c>`;
|
|
2238
|
+
}
|
|
2239
|
+
function Br(e) {
|
|
2240
|
+
return Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()) / 864e5 + 25569;
|
|
2241
|
+
}
|
|
2242
|
+
function Vr(e) {
|
|
2243
|
+
let t = "", n = e + 1;
|
|
2244
|
+
for (; n > 0;) {
|
|
2245
|
+
let e = (n - 1) % 26;
|
|
2246
|
+
t = String.fromCharCode(65 + e) + t, n = Math.floor((n - 1) / 26);
|
|
2247
|
+
}
|
|
2248
|
+
return t;
|
|
2249
|
+
}
|
|
2250
|
+
function Hr(e) {
|
|
2251
|
+
let t = /* @__PURE__ */ new Set(["history"]);
|
|
2252
|
+
return e.map((e) => {
|
|
2253
|
+
let n = String(e ?? "").replace(lr, "-").trim().replace(/^'+|'+$/g, "").trim() || "Sheet";
|
|
2254
|
+
n = Ur(n, X.sheetName);
|
|
2255
|
+
let r = n;
|
|
2256
|
+
for (let e = 2; t.has(r.toLowerCase()); e++) {
|
|
2257
|
+
let t = ` (${e})`;
|
|
2258
|
+
r = Ur(n, X.sheetName - t.length) + t;
|
|
2259
|
+
}
|
|
2260
|
+
return t.add(r.toLowerCase()), r;
|
|
2261
|
+
});
|
|
2262
|
+
}
|
|
2263
|
+
function Ur(e, t) {
|
|
2264
|
+
if (e.length <= t) return e;
|
|
2265
|
+
let n = e.slice(0, t);
|
|
2266
|
+
return /[\uD800-\uDBFF]$/.test(n) ? n.slice(0, -1) : n;
|
|
2267
|
+
}
|
|
2268
|
+
function Wr(e, t = [], n = []) {
|
|
2269
|
+
let r = Array.from({ length: e }, (e, t) => `<Override PartName="/xl/worksheets/sheet${t + 1}.xml" ContentType="${er}"/>`).join(""), i = t.map((e) => `<Override PartName="/xl/drawings/drawing${e.n}.xml" ContentType="${$t}"/>`).join(""), a = [...new Set(n.map((e) => e.ext))].map((e) => `<Default Extension="${e}" ContentType="${nn[e]}"/>`).join("");
|
|
2270
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2271
|
+
<Types xmlns="${Xn}"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/>` + a + `<Override PartName="/xl/workbook.xml" ContentType="${tr}"/><Override PartName="/xl/styles.xml" ContentType="${nr}"/>` + r + i + "</Types>";
|
|
2272
|
+
}
|
|
2273
|
+
function Gr() {
|
|
2274
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2275
|
+
<Relationships xmlns="${Yn}"><Relationship Id="rId1" Type="${Zn}" Target="xl/workbook.xml"/></Relationships>`;
|
|
2276
|
+
}
|
|
2277
|
+
function Kr(e) {
|
|
2278
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2279
|
+
<Relationships xmlns="${Yn}"><Relationship Id="rId1" Type="${en}" Target="../drawings/drawing${e}.xml"/></Relationships>`;
|
|
2280
|
+
}
|
|
2281
|
+
function qr(e) {
|
|
2282
|
+
let t = e.map((e, t) => `<sheet name="${Xr(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">${Yr(`${`'${e.name.replace(/'/g, "''")}'`}!$A$1:$${Vr(e.width - 1)}$${e.rows.length}`)}</definedName>`).join("");
|
|
2283
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2284
|
+
<workbook xmlns="${Jn}" xmlns:r="${Z}"><bookViews><workbookView/></bookViews><sheets>${t}</sheets>` + (n ? `<definedNames>${n}</definedNames>` : "") + "</workbook>";
|
|
2285
|
+
}
|
|
2286
|
+
function Jr(e) {
|
|
2287
|
+
let t = Array.from({ length: e }, (e, t) => `<Relationship Id="rId${t + 1}" Type="${Qn}" Target="worksheets/sheet${t + 1}.xml"/>`).join("");
|
|
2288
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
2289
|
+
<Relationships xmlns="${Yn}">` + t + `<Relationship Id="rId${e + 1}" Type="${$n}" Target="styles.xml"/></Relationships>`;
|
|
2290
|
+
}
|
|
2291
|
+
function Yr(e) {
|
|
2292
|
+
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
2293
|
+
}
|
|
2294
|
+
function Xr(e) {
|
|
2295
|
+
return Yr(e.replace(sr, "")).replace(/"/g, """);
|
|
2296
|
+
}
|
|
2297
|
+
//#endregion
|
|
2298
|
+
//#region src/engine/index.js
|
|
2299
|
+
function Zr(e, t) {
|
|
2300
|
+
return Ke(S(Se(ge(e, t), t)));
|
|
2301
|
+
}
|
|
2302
|
+
//#endregion
|
|
2303
|
+
//#region src/render/render.js
|
|
2304
|
+
var Qr = (e) => `padding-top:${K(e?.top)}px;padding-left:${K(e?.left)}px;padding-bottom:${K(e?.bottom)}px;padding-right:${K(e?.right)}px;`, $r = [
|
|
2305
|
+
"pageHeader",
|
|
2306
|
+
"reportHeader",
|
|
2307
|
+
"detail",
|
|
2308
|
+
"reportFooter",
|
|
2309
|
+
"pageFooter"
|
|
2310
|
+
];
|
|
2311
|
+
function ei(e) {
|
|
2312
|
+
let t = e.page;
|
|
2313
|
+
return `
|
|
2314
|
+
<main id="main-page">
|
|
2315
|
+
${e.pages.map((e) => `
|
|
2316
|
+
<section id="page-${J(e.pageNO)}" class="page" style="height:${K(t.height)}px; width:${K(t.width)}px; ${Qr(t.margin)};position:relative">
|
|
2317
|
+
${ti(e, t)}
|
|
2318
|
+
</section>
|
|
2319
|
+
`).join("")}
|
|
2320
|
+
</main>
|
|
2321
|
+
`;
|
|
2322
|
+
}
|
|
2323
|
+
function ti(e, t) {
|
|
2324
|
+
let n = (e) => {
|
|
2325
|
+
let t = $r.indexOf(e);
|
|
2326
|
+
return t === -1 ? $r.length : t;
|
|
2327
|
+
}, r = [...e.bands].sort(({ type: e }, { type: t }) => n(e) - n(t)), i = [];
|
|
2328
|
+
for (let n of r) i.push(ni(n, e.pageNO, t));
|
|
2329
|
+
return i.join("");
|
|
2330
|
+
}
|
|
2331
|
+
function ni(e, t, n) {
|
|
2332
|
+
let r = Number.isFinite(e.top), i = n?.margin ?? {
|
|
2333
|
+
top: 0,
|
|
2334
|
+
left: 0,
|
|
2335
|
+
right: 0
|
|
2336
|
+
}, a = r ? `position:absolute;top:${K(e.top) + K(i.top)}px;left:${K(i.left)}px;right:${K(i.right)}px;` : "position:relative;", o = Math.max(e.zoneHeight ?? 0, e.measuredHeight ?? 0);
|
|
2337
|
+
return `
|
|
2338
|
+
<div class="band" id="${J(e.type)}-${J(t)}" style="${a}${o > 0 ? `height:${K(o)}px` : ""}" data-band-type="${J(e.type)}">
|
|
2339
|
+
${yn(e.items)}
|
|
2340
|
+
</div>
|
|
2341
|
+
`;
|
|
2342
|
+
}
|
|
2343
|
+
//#endregion
|
|
2344
|
+
//#region src/shared/window.js
|
|
2345
|
+
var ri = 1280, ii = 900;
|
|
2346
|
+
function ai(e, t) {
|
|
2347
|
+
for (let n of e.querySelectorAll("link[rel=\"stylesheet\"], style")) {
|
|
2348
|
+
if (n.tagName === "LINK") {
|
|
2349
|
+
let e = t.createElement("link");
|
|
2350
|
+
e.rel = "stylesheet", e.href = n.href, t.head.appendChild(e);
|
|
2351
|
+
continue;
|
|
2352
|
+
}
|
|
2353
|
+
let e = t.createElement("style");
|
|
2354
|
+
e.textContent = n.textContent, t.head.appendChild(e);
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
function oi({ title: e = "Report Studio", width: t = ri, height: n = ii, features: r, opener: i = globalThis } = {}) {
|
|
2358
|
+
let a = r ?? `width=${t},height=${n},resizable=yes,scrollbars=yes`, o = i.open?.("", "_blank", a);
|
|
2359
|
+
if (!o || !o.document) return null;
|
|
2360
|
+
let s = o.document;
|
|
2361
|
+
s.open(), s.write("<!doctype html><html><head><meta charset=\"utf-8\"></head><body></body></html>"), s.close(), s.title = e, ai(i.document, s);
|
|
2362
|
+
let c = s.createElement("div");
|
|
2363
|
+
return c.id = "report-studio", c.style.height = "100vh", s.body.style.margin = "0", s.body.appendChild(c), {
|
|
2364
|
+
window: o,
|
|
2365
|
+
document: s,
|
|
2366
|
+
mount: c,
|
|
2367
|
+
close: () => o.close()
|
|
2368
|
+
};
|
|
2369
|
+
}
|
|
2370
|
+
function si(e, t, n = () => {}) {
|
|
2371
|
+
let r = () => {
|
|
2372
|
+
n(), t.close();
|
|
2373
|
+
};
|
|
2374
|
+
return e.addEventListener("pagehide", r), () => e.removeEventListener("pagehide", r);
|
|
2375
|
+
}
|
|
2376
|
+
//#endregion
|
|
2377
|
+
//#region src/shared/dropdown.js
|
|
2378
|
+
function ci(e) {
|
|
2379
|
+
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);
|
|
2380
|
+
function l() {
|
|
2381
|
+
i.forEach((e, t) => {
|
|
2382
|
+
let n = e.dataset.value === s;
|
|
2383
|
+
e.setAttribute("aria-selected", String(n)), e.classList.toggle("is-active", t === c);
|
|
2384
|
+
});
|
|
2385
|
+
let e = i.find((e) => e.dataset.value === s);
|
|
2386
|
+
e && (n.textContent = e.textContent.trim());
|
|
2387
|
+
}
|
|
2388
|
+
function u(e, { notify: t = !1 } = {}) {
|
|
2389
|
+
let n = i.find((t) => t.dataset.value === String(e));
|
|
2390
|
+
if (!n) return;
|
|
2391
|
+
let r = n.dataset.value !== s;
|
|
2392
|
+
if (s = n.dataset.value, c = i.indexOf(n), l(), t && r) for (let e of a) e();
|
|
2393
|
+
}
|
|
2394
|
+
let d = () => !r.hidden;
|
|
2395
|
+
function f() {
|
|
2396
|
+
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));
|
|
2397
|
+
}
|
|
2398
|
+
function p({ focusTrigger: e = !0 } = {}) {
|
|
2399
|
+
d() && (r.hidden = !0, t.setAttribute("aria-expanded", "false"), o().removeEventListener("pointerdown", m), e && t.focus());
|
|
2400
|
+
}
|
|
2401
|
+
function m(t) {
|
|
2402
|
+
e.contains(t.target) || p({ focusTrigger: !1 });
|
|
2403
|
+
}
|
|
2404
|
+
function h(e) {
|
|
2405
|
+
c = (e + i.length) % i.length, l(), i[c]?.focus();
|
|
2406
|
+
}
|
|
2407
|
+
function g(e) {
|
|
2408
|
+
[
|
|
2409
|
+
"ArrowDown",
|
|
2410
|
+
"ArrowUp",
|
|
2411
|
+
"Enter",
|
|
2412
|
+
" "
|
|
2413
|
+
].includes(e.key) && (e.preventDefault(), e.stopPropagation(), f());
|
|
2414
|
+
}
|
|
2415
|
+
function _(e) {
|
|
2416
|
+
let t = {
|
|
2417
|
+
ArrowDown: () => h(c + 1),
|
|
2418
|
+
ArrowUp: () => h(c - 1),
|
|
2419
|
+
Home: () => h(0),
|
|
2420
|
+
End: () => h(i.length - 1),
|
|
2421
|
+
Escape: () => p(),
|
|
2422
|
+
Enter: () => {
|
|
2423
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
2424
|
+
},
|
|
2425
|
+
" ": () => {
|
|
2426
|
+
u(i[c].dataset.value, { notify: !0 }), p();
|
|
2427
|
+
},
|
|
2428
|
+
Tab: () => p({ focusTrigger: !1 })
|
|
2429
|
+
}[e.key];
|
|
2430
|
+
t && (e.key !== "Tab" && (e.preventDefault(), e.stopPropagation()), t());
|
|
2431
|
+
}
|
|
2432
|
+
t.addEventListener("click", () => d() ? p() : f()), t.addEventListener("keydown", g), r.addEventListener("keydown", _);
|
|
2433
|
+
for (let e of i) e.addEventListener("click", () => {
|
|
2434
|
+
u(e.dataset.value, { notify: !0 }), p();
|
|
2435
|
+
});
|
|
2436
|
+
return l(), {
|
|
2437
|
+
get value() {
|
|
2438
|
+
return s;
|
|
2439
|
+
},
|
|
2440
|
+
set value(e) {
|
|
2441
|
+
u(e);
|
|
2442
|
+
},
|
|
2443
|
+
addEventListener(e, t) {
|
|
2444
|
+
e === "change" && a.add(t);
|
|
2445
|
+
},
|
|
2446
|
+
open: f,
|
|
2447
|
+
close: p,
|
|
2448
|
+
get isOpen() {
|
|
2449
|
+
return d();
|
|
2450
|
+
},
|
|
2451
|
+
destroy() {
|
|
2452
|
+
o().removeEventListener("pointerdown", m), a.clear();
|
|
2453
|
+
}
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
//#endregion
|
|
2457
|
+
//#region src/preview/chrome.js
|
|
2458
|
+
function li({ title: e = "Report Studio" } = {}) {
|
|
2459
|
+
return `
|
|
2460
|
+
<!--
|
|
2461
|
+
A header, not role="toolbar": that role promises arrow-key roving focus
|
|
2462
|
+
between the controls, and here the arrow keys page the report instead.
|
|
2463
|
+
|
|
2464
|
+
Two boxes: the header is what measures its width, and the row inside
|
|
2465
|
+
it is what rearranges. A container query restyles what is inside the
|
|
2466
|
+
container, never the container, so the grid cannot be the header.
|
|
2467
|
+
-->
|
|
2468
|
+
<header class="toolbar" aria-label="Report tools">
|
|
2469
|
+
<div class="toolbar-row" data-role="bar">
|
|
2470
|
+
<div class="toolbar-brand">${e}</div>
|
|
2471
|
+
|
|
2472
|
+
<div class="toolbar-centre">
|
|
2473
|
+
<div class="toolbar-group toolbar-search">
|
|
2474
|
+
<!--
|
|
2475
|
+
Buttons cannot live inside an <input>, so the wrapper draws
|
|
2476
|
+
the field and the input inside it draws no chrome of its own.
|
|
2477
|
+
-->
|
|
2478
|
+
<div class="search-field">
|
|
2479
|
+
<input type="search" data-role="query" placeholder="Search the report (ctrl+K)"
|
|
2480
|
+
title="Search the report (ctrl+K)"
|
|
2481
|
+
aria-label="Search the report" spellcheck="false">
|
|
2482
|
+
<span class="hits" data-role="hits" data-state="idle" aria-live="polite"></span>
|
|
2483
|
+
<button type="button" data-role="hit-prev" title="Previous match (shift+enter)"
|
|
2484
|
+
aria-label="Previous match">↑</button>
|
|
2485
|
+
<button type="button" data-role="hit-next" title="Next match (enter)"
|
|
2486
|
+
aria-label="Next match">↓</button>
|
|
2487
|
+
</div>
|
|
2488
|
+
</div>
|
|
2489
|
+
|
|
2490
|
+
<div class="toolbar-group toolbar-zoom">
|
|
2491
|
+
<button type="button" data-role="zoom-out" title="Zoom out (ctrl+-)"
|
|
2492
|
+
aria-label="Zoom out">−</button>
|
|
2493
|
+
|
|
2494
|
+
<!--
|
|
2495
|
+
A listbox rather than a <select>: option items are drawn by
|
|
2496
|
+
the operating system, so they cannot take the palette.
|
|
2497
|
+
-->
|
|
2498
|
+
<div class="dropdown" data-role="zoom-dropdown">
|
|
2499
|
+
<button type="button" class="dropdown-trigger" data-role="zoom"
|
|
2500
|
+
aria-haspopup="listbox" aria-expanded="false" aria-label="Zoom level">
|
|
2501
|
+
<span class="dropdown-value">100%</span>
|
|
2502
|
+
<span class="dropdown-caret" aria-hidden="true"></span>
|
|
2503
|
+
</button>
|
|
2504
|
+
|
|
2505
|
+
<ul class="dropdown-menu" data-role="zoom-menu" role="listbox"
|
|
2506
|
+
aria-label="Zoom level" hidden>
|
|
2507
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="fit">Fit width</li>
|
|
2508
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.5">50%</li>
|
|
2509
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="0.75">75%</li>
|
|
2510
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1"
|
|
2511
|
+
data-selected="true">100%</li>
|
|
2512
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.25">125%</li>
|
|
2513
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="1.5">150%</li>
|
|
2514
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="2">200%</li>
|
|
2515
|
+
<li class="dropdown-item" role="option" tabindex="-1" data-value="3">300%</li>
|
|
2516
|
+
</ul>
|
|
2517
|
+
</div>
|
|
2518
|
+
|
|
2519
|
+
<button type="button" data-role="zoom-in" title="Zoom in (ctrl++)"
|
|
2520
|
+
aria-label="Zoom in">+</button>
|
|
2521
|
+
</div>
|
|
2522
|
+
</div>
|
|
2523
|
+
|
|
2524
|
+
<div class="toolbar-group toolbar-save">
|
|
2525
|
+
<button type="button" data-role="print" title="Print or save as PDF (ctrl+P)">
|
|
2526
|
+
Print</button>
|
|
2527
|
+
<button type="button" data-role="export" title="Export the report (ctrl+X)">
|
|
2528
|
+
Export…</button>
|
|
2529
|
+
</div>
|
|
2530
|
+
</div>
|
|
2531
|
+
</header>
|
|
2532
|
+
|
|
2533
|
+
<div class="viewport" data-role="viewport"></div>
|
|
2534
|
+
|
|
2535
|
+
<!-- paging floats over the report rather than taking a strip of it -->
|
|
2536
|
+
<div class="pager" data-role="pager" role="toolbar" aria-label="Page navigation">
|
|
2537
|
+
<button type="button" data-role="prev" title="Previous page (left arrow)"
|
|
2538
|
+
aria-label="Previous page">‹</button>
|
|
2539
|
+
|
|
2540
|
+
<label class="page-of">
|
|
2541
|
+
<input type="number" data-role="current" min="1" value="1" aria-label="Current page">
|
|
2542
|
+
<span>of</span>
|
|
2543
|
+
<span data-role="total">1</span>
|
|
2544
|
+
</label>
|
|
2545
|
+
|
|
2546
|
+
<button type="button" data-role="next" title="Next page (right arrow)"
|
|
2547
|
+
aria-label="Next page">›</button>
|
|
2548
|
+
</div>
|
|
2549
|
+
|
|
2550
|
+
|
|
2551
|
+
|
|
2552
|
+
<!--
|
|
2553
|
+
Hand-written rather than a <dialog>: the element is still unimplemented
|
|
2554
|
+
in the environment the specs run in, and a stubbed showModal would test
|
|
2555
|
+
the stub instead of the behaviour.
|
|
2556
|
+
-->
|
|
2557
|
+
<div class="modal" data-role="export-modal" hidden>
|
|
2558
|
+
<div class="modal-backdrop" data-role="export-backdrop"></div>
|
|
2559
|
+
|
|
2560
|
+
<div class="modal-card" role="dialog" aria-modal="true" aria-labelledby="export-title">
|
|
2561
|
+
<h2 id="export-title">Export report</h2>
|
|
2562
|
+
|
|
2563
|
+
<div class="modal-formats" role="radiogroup" aria-labelledby="export-title">
|
|
2564
|
+
<label class="format">
|
|
2565
|
+
<input type="radio" name="export-format" value="pdf" checked>
|
|
2566
|
+
<span class="format-body">
|
|
2567
|
+
<span class="format-name">PDF</span>
|
|
2568
|
+
<span class="format-note">Opens the print dialog - choose "Save as PDF"</span>
|
|
2569
|
+
</span>
|
|
2570
|
+
</label>
|
|
2571
|
+
|
|
2572
|
+
<label class="format">
|
|
2573
|
+
<input type="radio" name="export-format" value="csv">
|
|
2574
|
+
<span class="format-body">
|
|
2575
|
+
<span class="format-name">CSV</span>
|
|
2576
|
+
<span class="format-note">Every text line and table row, in report order</span>
|
|
2577
|
+
</span>
|
|
2578
|
+
</label>
|
|
2579
|
+
|
|
2580
|
+
<label class="format">
|
|
2581
|
+
<input type="radio" name="export-format" value="xlsx">
|
|
2582
|
+
<span class="format-body">
|
|
2583
|
+
<span class="format-name">Excel</span>
|
|
2584
|
+
<span class="format-note">The report as it reads, plus a sheet per table</span>
|
|
2585
|
+
</span>
|
|
2586
|
+
</label>
|
|
2587
|
+
</div>
|
|
2588
|
+
|
|
2589
|
+
<p class="modal-summary" data-role="export-summary" aria-live="polite"></p>
|
|
2590
|
+
|
|
2591
|
+
<div class="modal-actions">
|
|
2592
|
+
<button type="button" data-role="export-cancel">Cancel</button>
|
|
2593
|
+
<button type="button" class="is-primary" data-role="export-confirm">Export</button>
|
|
2594
|
+
</div>
|
|
2595
|
+
</div>
|
|
2596
|
+
</div>
|
|
2597
|
+
`;
|
|
2598
|
+
}
|
|
2599
|
+
//#endregion
|
|
2600
|
+
//#region src/preview/viewer.js
|
|
2601
|
+
var $ = [
|
|
2602
|
+
.5,
|
|
2603
|
+
.75,
|
|
2604
|
+
1,
|
|
2605
|
+
1.25,
|
|
2606
|
+
1.5,
|
|
2607
|
+
2,
|
|
2608
|
+
3
|
|
2609
|
+
], ui = $[0], di = $[$.length - 1];
|
|
2610
|
+
function fi({ paginated: e, title: t, width: n, height: r, features: i, ...a } = {}) {
|
|
2611
|
+
let o = oi({
|
|
2612
|
+
title: t ?? "Report",
|
|
2613
|
+
width: n,
|
|
2614
|
+
height: r,
|
|
2615
|
+
features: i
|
|
2616
|
+
});
|
|
2617
|
+
if (!o) return null;
|
|
2618
|
+
let s = pi({
|
|
2619
|
+
...a,
|
|
2620
|
+
mount: o.mount,
|
|
2621
|
+
paginated: e,
|
|
2622
|
+
title: t
|
|
2623
|
+
}), c = si(globalThis, o.window, s.destroy);
|
|
2624
|
+
return {
|
|
2625
|
+
...s,
|
|
2626
|
+
window: o.window,
|
|
2627
|
+
destroy() {
|
|
2628
|
+
c(), s.destroy(), o.close();
|
|
2629
|
+
}
|
|
2630
|
+
};
|
|
2631
|
+
}
|
|
2632
|
+
function pi({ mount: e, paginated: t, title: n } = {}) {
|
|
2633
|
+
let r = typeof e == "string" ? document.querySelector(e) : e;
|
|
2634
|
+
if (!r) throw Error(`createViewer: no element for mount ${JSON.stringify(e)}. Add <div id="report"></div> to the page first.`);
|
|
2635
|
+
let i = r.ownerDocument, a = i.defaultView ?? globalThis;
|
|
2636
|
+
if (!t?.pages) throw Error("createViewer: paginated must be a buildPages(layout, data) result.");
|
|
2637
|
+
r.classList.add("report-viewer"), r.innerHTML = li({ title: n });
|
|
2638
|
+
let o = r.querySelector("[data-role=\"viewport\"]");
|
|
2639
|
+
o.innerHTML = ei(t);
|
|
2640
|
+
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 = {
|
|
2641
|
+
prev: f("prev"),
|
|
2642
|
+
next: f("next"),
|
|
2643
|
+
current: f("current"),
|
|
2644
|
+
total: f("total"),
|
|
2645
|
+
zoom: ci(f("zoom-dropdown")),
|
|
2646
|
+
zoomIn: f("zoom-in"),
|
|
2647
|
+
zoomOut: f("zoom-out"),
|
|
2648
|
+
print: f("print"),
|
|
2649
|
+
exportOpen: f("export"),
|
|
2650
|
+
query: f("query"),
|
|
2651
|
+
hits: f("hits"),
|
|
2652
|
+
hitPrev: f("hit-prev"),
|
|
2653
|
+
hitNext: f("hit-next")
|
|
2654
|
+
}, m = d ? {
|
|
2655
|
+
root: d,
|
|
2656
|
+
card: d.querySelector(".modal-card"),
|
|
2657
|
+
backdrop: d.querySelector("[data-role=\"export-backdrop\"]"),
|
|
2658
|
+
summary: d.querySelector("[data-role=\"export-summary\"]"),
|
|
2659
|
+
cancel: d.querySelector("[data-role=\"export-cancel\"]"),
|
|
2660
|
+
confirm: d.querySelector("[data-role=\"export-confirm\"]"),
|
|
2661
|
+
formats: [...d.querySelectorAll("input[name=\"export-format\"]")]
|
|
2662
|
+
} : null, h = 0, g = [], _ = -1, v = 1, y = !1, b = null, x = a.onafterprint !== void 0;
|
|
2663
|
+
p.total.textContent = String(c), p.current.max = String(c);
|
|
2664
|
+
function S(e) {
|
|
2665
|
+
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, se(), u.scrollTo?.({ top: 0 });
|
|
2666
|
+
}
|
|
2667
|
+
function C() {
|
|
2668
|
+
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) {
|
|
2669
|
+
let e = $.find((e) => Math.abs(e - v) < 1e-9);
|
|
2670
|
+
p.zoom.value = e === void 0 ? "fit" : String(e);
|
|
2671
|
+
}
|
|
2672
|
+
p.zoomOut.disabled = !y && v <= ui, p.zoomIn.disabled = !y && v >= di;
|
|
2673
|
+
}
|
|
2674
|
+
function w(e) {
|
|
2675
|
+
y = !1, v = Math.min(Math.max(e, ui), di), C();
|
|
2676
|
+
}
|
|
2677
|
+
function T() {
|
|
2678
|
+
y = !0, p.zoom.value = "fit";
|
|
2679
|
+
let e = u.clientWidth - 48;
|
|
2680
|
+
e > 0 && (v = Math.min(Math.max(e / t.page.width, ui), di)), C();
|
|
2681
|
+
}
|
|
2682
|
+
function E(e) {
|
|
2683
|
+
let t = v;
|
|
2684
|
+
w((e > 0 ? $.find((e) => e > t + 1e-9) : [...$].reverse().find((e) => e < t - 1e-9)) ?? t);
|
|
2685
|
+
}
|
|
2686
|
+
let D = {
|
|
2687
|
+
pdf: {
|
|
2688
|
+
available: () => !0,
|
|
2689
|
+
summary: () => `${c} page${c === 1 ? "" : "s"}, ${t.page.width}×${t.page.height}px each.`,
|
|
2690
|
+
run: () => O()
|
|
2691
|
+
},
|
|
2692
|
+
csv: {
|
|
2693
|
+
available: () => Dt(t.pages) !== "",
|
|
2694
|
+
summary: () => D.csv.available() ? `Downloads ${V(t, "csv")}.` : "This report has nothing to write out.",
|
|
2695
|
+
run: () => te()
|
|
2696
|
+
},
|
|
2697
|
+
xlsx: {
|
|
2698
|
+
available: () => D.csv.available() || mt(t.pages).length > 0,
|
|
2699
|
+
summary: () => D.xlsx.available() ? `Downloads ${V(t, "xlsx")}.` : "This report has nothing to write out.",
|
|
2700
|
+
run: () => j()
|
|
2701
|
+
}
|
|
2702
|
+
};
|
|
2703
|
+
function O() {
|
|
2704
|
+
let e = [...o.querySelectorAll("img")].filter((e) => !e.complete);
|
|
2705
|
+
if (e.length > 0) {
|
|
2706
|
+
Promise.all(e.map((e) => e.decode().catch(() => {}))).then(k);
|
|
2707
|
+
return;
|
|
2708
|
+
}
|
|
2709
|
+
k();
|
|
2710
|
+
}
|
|
2711
|
+
function k() {
|
|
2712
|
+
oe(), a.print(), x || A();
|
|
2713
|
+
}
|
|
2714
|
+
function A() {
|
|
2715
|
+
p.query.value.trim() !== "" && se();
|
|
2716
|
+
}
|
|
2717
|
+
function ee() {
|
|
2718
|
+
let { width: e, height: n } = t.page, r = i.getElementById("report-page-size");
|
|
2719
|
+
r || (r = i.createElement("style"), r.id = "report-page-size", i.head.appendChild(r)), r.textContent = `@page { size: ${e}px ${n}px; margin: 0; }`;
|
|
2720
|
+
}
|
|
2721
|
+
function te() {
|
|
2722
|
+
let e = Dt(t.pages);
|
|
2723
|
+
return e === "" ? !1 : (M(new Blob(["", e], { type: "text/csv;charset=utf-8" }), V(t, "csv")), !0);
|
|
2724
|
+
}
|
|
2725
|
+
function j() {
|
|
2726
|
+
if (!D.xlsx.available()) return !1;
|
|
2727
|
+
let e = (e) => {
|
|
2728
|
+
e.length > 0 && M(new Blob([e], { type: qn }), V(t, "xlsx"));
|
|
2729
|
+
};
|
|
2730
|
+
if (br(t.pages).length > 0) return yr(t.pages).then(e, () => e(Q(t.pages))), !0;
|
|
2731
|
+
let n = Q(t.pages);
|
|
2732
|
+
return n.length === 0 ? !1 : (e(n), !0);
|
|
2733
|
+
}
|
|
2734
|
+
function M(e, t) {
|
|
2735
|
+
let n = URL.createObjectURL(e), r = i.createElement("a");
|
|
2736
|
+
r.href = n, r.download = t, i.body.appendChild(r), r.click(), r.remove(), setTimeout(() => URL.revokeObjectURL(n), 0);
|
|
2737
|
+
}
|
|
2738
|
+
function N() {
|
|
2739
|
+
return m?.formats.find((e) => e.checked)?.value ?? "pdf";
|
|
2740
|
+
}
|
|
2741
|
+
function P() {
|
|
2742
|
+
if (!m) return;
|
|
2743
|
+
for (let e of m.formats) {
|
|
2744
|
+
let t = D[e.value];
|
|
2745
|
+
e.disabled = !t || !t.available(), e.closest(".format")?.classList.toggle("is-unavailable", e.disabled);
|
|
2746
|
+
}
|
|
2747
|
+
if (m.formats.find((e) => e.checked)?.disabled) {
|
|
2748
|
+
let e = m.formats.find((e) => !e.disabled);
|
|
2749
|
+
e && (e.checked = !0);
|
|
2750
|
+
}
|
|
2751
|
+
let e = D[N()];
|
|
2752
|
+
m.summary.textContent = e ? e.summary() : "", m.confirm.disabled = !e || !e.available();
|
|
2753
|
+
}
|
|
2754
|
+
function F() {
|
|
2755
|
+
m && (b = i.activeElement, m.root.hidden = !1, P(), (m.formats.find((e) => e.checked && !e.disabled) ?? m.formats.find((e) => !e.disabled) ?? m.cancel).focus());
|
|
2756
|
+
}
|
|
2757
|
+
function I() {
|
|
2758
|
+
!m || m.root.hidden || (m.root.hidden = !0, b?.focus?.(), b = null);
|
|
2759
|
+
}
|
|
2760
|
+
function ne() {
|
|
2761
|
+
let e = D[N()];
|
|
2762
|
+
e?.available() && (I(), e.run());
|
|
2763
|
+
}
|
|
2764
|
+
function re(e) {
|
|
2765
|
+
let t = [...m.card.querySelectorAll("button, input")].filter((e) => !e.disabled);
|
|
2766
|
+
if (!t.length) return;
|
|
2767
|
+
let n = t[0], r = t[t.length - 1];
|
|
2768
|
+
e.shiftKey && i.activeElement === n ? (e.preventDefault(), r.focus()) : !e.shiftKey && i.activeElement === r && (e.preventDefault(), n.focus());
|
|
2769
|
+
}
|
|
2770
|
+
function ie() {
|
|
2771
|
+
let e = p.query.value.trim();
|
|
2772
|
+
if (oe(), e === "") {
|
|
2773
|
+
g = [], _ = -1, p.hits.textContent = "", p.hits.dataset.state = "idle", ae();
|
|
2774
|
+
return;
|
|
2775
|
+
}
|
|
2776
|
+
if (g = it(t.pages, e), _ = g.length ? 0 : -1, p.hits.dataset.state = g.length ? "found" : "empty", ae(), !g.length) {
|
|
2777
|
+
p.hits.textContent = "no matches";
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
let n = at(t.pages, e).length;
|
|
2781
|
+
p.hits.textContent = `${g.length} on ${n} page${n === 1 ? "" : "s"}`, L(0);
|
|
2782
|
+
}
|
|
2783
|
+
function L(e) {
|
|
2784
|
+
if (!g.length) return;
|
|
2785
|
+
_ = (e + g.length) % g.length;
|
|
2786
|
+
let t = g[_].pageNO - 1;
|
|
2787
|
+
t === h ? se() : S(t), p.hits.textContent = `${_ + 1} of ${g.length}`, le();
|
|
2788
|
+
}
|
|
2789
|
+
function ae() {
|
|
2790
|
+
p.hitPrev.disabled = g.length === 0, p.hitNext.disabled = g.length === 0;
|
|
2791
|
+
}
|
|
2792
|
+
function oe() {
|
|
2793
|
+
for (let e of u.querySelectorAll("mark.hit")) {
|
|
2794
|
+
let t = e.parentNode;
|
|
2795
|
+
t.replaceChild(i.createTextNode(e.textContent), e), t.normalize();
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
function se() {
|
|
2799
|
+
oe();
|
|
2800
|
+
let e = p.query.value.trim();
|
|
2801
|
+
if (e === "") return;
|
|
2802
|
+
let t = s[h];
|
|
2803
|
+
if (!t) return;
|
|
2804
|
+
let n = e.toLowerCase(), r = i.createTreeWalker(t, NodeFilter.SHOW_TEXT), a = [];
|
|
2805
|
+
for (; r.nextNode();) {
|
|
2806
|
+
let e = r.currentNode;
|
|
2807
|
+
e.nodeValue.toLowerCase().includes(n) && a.push(e);
|
|
2808
|
+
}
|
|
2809
|
+
for (let e of a) ce(e, n);
|
|
2810
|
+
}
|
|
2811
|
+
function ce(e, t) {
|
|
2812
|
+
let n = e.nodeValue, r = i.createDocumentFragment(), a = 0;
|
|
2813
|
+
for (;;) {
|
|
2814
|
+
let e = n.toLowerCase().indexOf(t, a);
|
|
2815
|
+
if (e === -1) break;
|
|
2816
|
+
e > a && r.appendChild(i.createTextNode(n.slice(a, e)));
|
|
2817
|
+
let o = i.createElement("mark");
|
|
2818
|
+
o.className = "hit", o.textContent = n.slice(e, e + t.length), r.appendChild(o), a = e + t.length;
|
|
2819
|
+
}
|
|
2820
|
+
a < n.length && r.appendChild(i.createTextNode(n.slice(a))), e.parentNode.replaceChild(r, e);
|
|
2821
|
+
}
|
|
2822
|
+
function le() {
|
|
2823
|
+
let e = [...u.querySelectorAll("mark.hit")];
|
|
2824
|
+
if (!e.length) return;
|
|
2825
|
+
let t = g.filter((e) => e.pageNO === h + 1).indexOf(g[_]), n = e[Math.max(t, 0)] ?? e[0];
|
|
2826
|
+
e.forEach((e) => e.classList.remove("is-focused")), n.classList.add("is-focused"), n.scrollIntoView?.({
|
|
2827
|
+
block: "center",
|
|
2828
|
+
behavior: "smooth"
|
|
2829
|
+
});
|
|
2830
|
+
}
|
|
2831
|
+
if (p.prev.addEventListener("click", () => S(h - 1)), p.next.addEventListener("click", () => S(h + 1)), p.current.addEventListener("change", () => {
|
|
2832
|
+
let e = Number(p.current.value);
|
|
2833
|
+
Number.isFinite(e) ? S(e - 1) : p.current.value = String(h + 1);
|
|
2834
|
+
}), p.print?.addEventListener("click", O), p.exportOpen.addEventListener("click", F), m) {
|
|
2835
|
+
m.cancel.addEventListener("click", I), m.backdrop.addEventListener("click", I), m.confirm.addEventListener("click", ne);
|
|
2836
|
+
for (let e of m.formats) e.addEventListener("change", P);
|
|
2837
|
+
m.root.addEventListener("keydown", (e) => {
|
|
2838
|
+
e.key === "Tab" && re(e), e.key === "Enter" && (e.preventDefault(), ne());
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
p.zoomIn.addEventListener("click", () => E(1)), p.zoomOut.addEventListener("click", () => E(-1)), p.zoom.addEventListener("change", () => {
|
|
2842
|
+
p.zoom.value === "fit" ? T() : w(Number(p.zoom.value));
|
|
2843
|
+
});
|
|
2844
|
+
let ue = () => {
|
|
2845
|
+
y && T();
|
|
2846
|
+
};
|
|
2847
|
+
a.addEventListener("resize", ue), p.hitPrev.addEventListener("click", () => L(_ - 1)), p.hitNext.addEventListener("click", () => L(_ + 1));
|
|
2848
|
+
let de;
|
|
2849
|
+
p.query.addEventListener("input", () => {
|
|
2850
|
+
clearTimeout(de), de = setTimeout(ie, 150);
|
|
2851
|
+
}), p.query.addEventListener("keydown", (e) => {
|
|
2852
|
+
e.key === "Enter" && (e.preventDefault(), g.length ? L(_ + (e.shiftKey ? -1 : 1)) : ie());
|
|
2853
|
+
});
|
|
2854
|
+
let fe = (e) => {
|
|
2855
|
+
if (m && !m.root.hidden) {
|
|
2856
|
+
e.key === "Escape" && (e.preventDefault(), I());
|
|
2857
|
+
return;
|
|
2858
|
+
}
|
|
2859
|
+
if ((e.ctrlKey || e.metaKey) && ["k", "f"].includes(e.key.toLowerCase())) {
|
|
2860
|
+
e.preventDefault(), p.query.focus(), p.query.select();
|
|
2861
|
+
return;
|
|
2862
|
+
}
|
|
2863
|
+
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "p") {
|
|
2864
|
+
e.preventDefault(), O();
|
|
2865
|
+
return;
|
|
2866
|
+
}
|
|
2867
|
+
if (!(e.target === p.query || e.target === p.current)) {
|
|
2868
|
+
if ((e.ctrlKey || e.metaKey) && ["x", "s"].includes(e.key.toLowerCase())) {
|
|
2869
|
+
e.preventDefault(), F();
|
|
2870
|
+
return;
|
|
2871
|
+
}
|
|
2872
|
+
(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)));
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
i.addEventListener("keydown", fe), x && a.addEventListener("afterprint", A);
|
|
2876
|
+
function pe() {
|
|
2877
|
+
p.zoom.destroy(), i.removeEventListener("keydown", fe), a.removeEventListener("resize", ue), a.removeEventListener("afterprint", A), r.innerHTML = "", r.classList.remove("report-viewer");
|
|
2878
|
+
}
|
|
2879
|
+
return ee(), C(), S(0), ae(), {
|
|
2880
|
+
show: S,
|
|
2881
|
+
next: () => S(h + 1),
|
|
2882
|
+
prev: () => S(h - 1),
|
|
2883
|
+
find: (e) => {
|
|
2884
|
+
p.query.value = e, ie();
|
|
2885
|
+
},
|
|
2886
|
+
print: O,
|
|
2887
|
+
downloadCSV: te,
|
|
2888
|
+
downloadXLSX: j,
|
|
2889
|
+
openExport: F,
|
|
2890
|
+
closeExport: I,
|
|
2891
|
+
confirmExport: ne,
|
|
2892
|
+
destroy: pe,
|
|
2893
|
+
get exportOpen() {
|
|
2894
|
+
return m ? !m.root.hidden : !1;
|
|
2895
|
+
},
|
|
2896
|
+
setZoom: w,
|
|
2897
|
+
zoomIn: () => E(1),
|
|
2898
|
+
zoomOut: () => E(-1),
|
|
2899
|
+
fitWidth: T,
|
|
2900
|
+
get zoom() {
|
|
2901
|
+
return v;
|
|
2902
|
+
},
|
|
2903
|
+
get page() {
|
|
2904
|
+
return h + 1;
|
|
2905
|
+
},
|
|
2906
|
+
get pageCount() {
|
|
2907
|
+
return c;
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
}
|
|
2911
|
+
//#endregion
|
|
2912
|
+
export { he as A, t as B, at as C, Se as D, Ue as E, S as F, i as I, d as L, F as M, I as N, pe as O, x as P, m as R, it as S, He as T, r as V, yn as _, fi as a, Dt as b, oi as c, qn as d, br as f, Tn as g, J as h, pi as i, ge as j, me as k, ei as l, yr as m, ui as n, ci as o, Q as p, $ as r, si as s, di as t, Zr as u, V as v, Ke as w, mt as x, Et as y, p as z };
|