@agile-team/mach-report 2.11.0 → 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,28 +1,28 @@
1
- import { D as Z, a as ve } from "./defaults-DXhiM1ZD.js";
2
- import { b as kn, c as In, d as $n, L as Nn, S as Ln } from "./defaults-DXhiM1ZD.js";
3
- import { e as Fn, f as On, p as zn, t as Hn, c as Wn } from "./list-cell-ClFra1zS.js";
1
+ import { D as Z, a as ye } from "./defaults-DXhiM1ZD.js";
2
+ import { b as In, c as $n, d as Nn, L as Ln, S as Dn } from "./defaults-DXhiM1ZD.js";
3
+ import { e as On, f as zn, p as Hn, t as Wn, c as _n } from "./list-cell-ClFra1zS.js";
4
4
  import { a as H, r as W, b as Q, c as j, d as Me, m as ie, e as xe, p as O, f as Ee, P as K } from "./style-CQ1PK8ZB.js";
5
- import { C as jn, M as Bn, g as Gn, h as Un } from "./style-CQ1PK8ZB.js";
5
+ import { C as Bn, M as Gn, g as Un, h as Vn } from "./style-CQ1PK8ZB.js";
6
6
  import { i as ee, a as Se } from "./render-plan-Ck6koX9L.js";
7
- import { R as qn } from "./render-plan-Ck6koX9L.js";
8
- import { a as Kn, v as Xn, b as Jn, c as Zn } from "./validate-7s0yn6ii.js";
7
+ import { R as Yn } from "./render-plan-Ck6koX9L.js";
8
+ import { a as Xn, v as Jn, b as Zn, c as Qn } from "./validate-7s0yn6ii.js";
9
9
  import { v as je } from "./dataset-H5pFuQGU.js";
10
- import { d as er } from "./dataset-H5pFuQGU.js";
11
- import { h as ae, w as Te } from "./textwrap-DE1kgcJB.js";
12
- import { c as nr, a as rr, b as ir, m as ar } from "./textwrap-DE1kgcJB.js";
10
+ import { d as tr } from "./dataset-H5pFuQGU.js";
11
+ import { h as oe, w as Te } from "./textwrap-DE1kgcJB.js";
12
+ import { c as rr, a as ir, b as or, m as ar } from "./textwrap-DE1kgcJB.js";
13
13
  import { R as Be, p as Ge } from "./template-review-BdcXSYbx.js";
14
- import { P as sr, a as lr, b as cr, c as dr, d as mr, e as hr, f as gr, g as ur, h as fr, i as pr, j as wr, k as br, l as yr, m as vr, n as Mr, o as xr, q as Er, r as Sr, s as Tr, t as Cr, u as Rr, v as Pr, w as Ar, x as kr, y as Ir, z as $r } from "./template-review-BdcXSYbx.js";
14
+ import { P as lr, a as cr, b as dr, c as mr, d as hr, e as ur, f as gr, g as fr, h as pr, i as wr, j as br, k as vr, l as yr, m as Mr, n as xr, o as Er, q as Sr, r as Tr, s as Cr, t as Rr, u as Pr, v as Ar, w as kr, x as Ir, y as $r, z as Nr } from "./template-review-BdcXSYbx.js";
15
15
  import { r as Ce } from "./grid-geometry-BNptEcMm.js";
16
- import { r as Re, a as oe } from "./assets-DegqDNqY.js";
17
- import { O as Lr } from "./assets-DegqDNqY.js";
16
+ import { r as Re, a as ae } from "./assets-DegqDNqY.js";
17
+ import { O as Dr } from "./assets-DegqDNqY.js";
18
18
  import { r as G, n as Pe, O as Ue } from "./capabilities-CK_7hizc.js";
19
- import { i as Fr } from "./capabilities-CK_7hizc.js";
19
+ import { i as Or } from "./capabilities-CK_7hizc.js";
20
20
  import { o as Ve } from "./progress-7OSZbFok.js";
21
21
  import { c as qe } from "./page-window-index-CIuT4BAv.js";
22
- import { p as D } from "./template-registry-WNXdkiET.js";
23
- import { R as zr, a as Hr, c as Wr, d as _r, s as jr, v as Br, b as Gr } from "./template-registry-WNXdkiET.js";
24
- import { R as Vr, a as qr, f as Yr, i as Kr, b as Xr, c as Jr, p as Zr, r as Qr, v as ei, d as ti } from "./param-validation-BlHHXs6u.js";
25
- import { T as ri, c as ii, v as ai } from "./tree-CqcQ99NM.js";
22
+ import { p as I } from "./template-registry-WNXdkiET.js";
23
+ import { R as Hr, a as Wr, c as _r, d as jr, s as Br, v as Gr, b as Ur } from "./template-registry-WNXdkiET.js";
24
+ import { R as qr, a as Yr, f as Kr, i as Xr, b as Jr, c as Zr, p as Qr, r as ei, v as ti, d as ni } from "./param-validation-BlHHXs6u.js";
25
+ import { T as ii, c as oi, v as ai } from "./tree-CqcQ99NM.js";
26
26
  const Ye = {
27
27
  root: "mr-root",
28
28
  page: "mr-page",
@@ -64,7 +64,7 @@ class Ke {
64
64
  n && (t.style.cssText = n);
65
65
  }
66
66
  }
67
- function v(e, t = "unset") {
67
+ function y(e, t = "unset") {
68
68
  return new Ke().add("all", t).add("display", e).add("box-sizing", "border-box");
69
69
  }
70
70
  function Ae(e, t, n) {
@@ -77,65 +77,65 @@ function Xe(e, t, n) {
77
77
  Ae(e, r, n), e.add("background-color", r.backgroundColor).add("opacity", r.opacity != null ? String(r.opacity) : void 0).add("transform", r.rotateDeg ? `rotate(${r.rotateDeg}deg)` : void 0);
78
78
  }
79
79
  function Je(e, t, n, r, i, o) {
80
- const l = e.cell, a = o.createElement("td");
81
- a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), l.colSpan && (a.colSpan = l.colSpan), l.rowSpan && (a.rowSpan = l.rowSpan);
82
- const s = xe(t.style, l.style), c = v("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", s.backgroundColor).add("vertical-align", s.verticalAlign ?? "middle");
83
- Ae(c, s, r), c.applyTo(a);
80
+ const s = e.cell, a = o.createElement("td");
81
+ a.className = E("cell", i), a.dataset.mrRowIndex = String(e.ri), a.dataset.mrColumnIndex = String(e.ci), a.setAttribute("role", t.table?.role === "header" ? "columnheader" : "cell"), s.colSpan && (a.colSpan = s.colSpan), s.rowSpan && (a.rowSpan = s.rowSpan);
82
+ const l = xe(t.style, s.style), c = y("block").add("position", "absolute").mm("left", e.xMm, r).mm("top", e.yMm, r).mm("width", e.widthMm, r).mm("height", e.heightMm, r).add("background-color", l.backgroundColor).add("vertical-align", l.verticalAlign ?? "middle");
83
+ Ae(c, l, r), c.applyTo(a);
84
84
  const d = o.createElement("div");
85
- d.className = "mr-cell-content", v("flex").add("position", "absolute").mm("left", n + (l.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", s.verticalAlign === "top" ? "flex-start" : s.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), l.text != null && d.append(l.text);
86
- for (const m of l.children ?? []) d.appendChild(ke(m, r, i, o));
85
+ d.className = "mr-cell-content", y("flex").add("position", "absolute").mm("left", n + (s.indentMm ?? 0), r).mm("right", n, r).mm("top", n, r).mm("bottom", n, r).add("flex-direction", "column").add("justify-content", l.verticalAlign === "top" ? "flex-start" : l.verticalAlign === "bottom" ? "flex-end" : "center").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(d), s.text != null && d.append(s.text);
86
+ for (const m of s.children ?? []) d.appendChild(ke(m, r, i, o));
87
87
  return a.appendChild(d), a;
88
88
  }
89
89
  function Ze(e, t, n, r) {
90
90
  return Re(e, t).map((i) => {
91
- const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, l = r.createElement("div");
92
- l.className = "mr-grid-edge", l.setAttribute("aria-hidden", "true");
91
+ const o = `${H(i.widthPt * n / 72, 2)}px solid ${i.color}`, s = r.createElement("div");
92
+ s.className = "mr-grid-edge", s.setAttribute("aria-hidden", "true");
93
93
  const a = i.kind === "h";
94
- return v("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(l), l;
94
+ return y("block").add("position", "absolute").add("pointer-events", "none").mm("left", a ? i.from : i.pos, n).mm("top", a ? i.pos : i.from, n).mm("width", a ? i.to - i.from : 0, n).mm("height", a ? 0 : i.to - i.from, n).add(a ? "border-top" : "border-left", o).applyTo(s), s;
95
95
  });
96
96
  }
97
97
  function Qe(e, t, n, r, i) {
98
98
  const o = i.createElement("table");
99
- o.className = E("grid", r), o.setAttribute("role", "table"), v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
100
- const l = Ce(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
101
- v("contents").applyTo(a), o.appendChild(a);
102
- const s = e.cells.map(() => {
99
+ o.className = E("grid", r), o.setAttribute("role", "table"), y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(o);
100
+ const s = Ce(e, t.widthMm, t.heightMm), a = i.createElement("tbody");
101
+ y("contents").applyTo(a), o.appendChild(a);
102
+ const l = e.cells.map(() => {
103
103
  const d = i.createElement("tr");
104
- return d.className = E("row", r), d.setAttribute("role", "row"), v("contents").applyTo(d), a.appendChild(d), d;
104
+ return d.className = E("row", r), d.setAttribute("role", "row"), y("contents").applyTo(d), a.appendChild(d), d;
105
105
  });
106
- for (const d of l.cells)
107
- s[d.ri].appendChild(Je(d, t, e.paddingMm ?? 0.5, n, r, i));
106
+ for (const d of s.cells)
107
+ l[d.ri].appendChild(Je(d, t, e.paddingMm ?? 0.5, n, r, i));
108
108
  const c = i.createElement("div");
109
- return v("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Ze(l, t, n, i)), c;
109
+ return y("block").add("position", "relative").add("width", "100%").add("height", "100%").applyTo(c), c.append(o, ...Ze(s, t, n, i)), c;
110
110
  }
111
111
  function et(e, t, n, r) {
112
112
  const i = r.createElement("div");
113
- i.className = E("paragraph", n), v("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
113
+ i.className = E("paragraph", n), y("block").add("text-align", e.align).add("line-height", e.lineHeight != null ? String(e.lineHeight) : void 0).mm("margin-top", e.spaceBeforeMm ?? 0, t).mm("margin-bottom", e.spaceAfterMm ?? 0, t).mm("text-indent", e.indentMm ?? 0, t).applyTo(i);
114
114
  for (const o of e.segments || []) {
115
- const l = r.createElement("span");
116
- l.className = E("segment", n), l.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
117
- const a = v("inline");
115
+ const s = r.createElement("span");
116
+ s.className = E("segment", n), s.textContent = o.kind === "field" ? o.field ?? "" : o.text ?? "";
117
+ const a = y("inline");
118
118
  if (o.style) {
119
- const s = o.style;
120
- a.add("color", s.color).add("font-family", s.fontFamily).add("font-weight", s.bold != null ? s.bold ? "700" : "400" : void 0).add("font-style", s.italic != null ? s.italic ? "italic" : "normal" : void 0).add("text-decoration", s.underline != null ? s.underline ? "underline" : "none" : void 0), (s.fontSize != null || s.fontSizePx != null) && a.add("font-size", `${H(W(s, t).fontSizePx, 2)}px`);
119
+ const l = o.style;
120
+ a.add("color", l.color).add("font-family", l.fontFamily).add("font-weight", l.bold != null ? l.bold ? "700" : "400" : void 0).add("font-style", l.italic != null ? l.italic ? "italic" : "normal" : void 0).add("text-decoration", l.underline != null ? l.underline ? "underline" : "none" : void 0), (l.fontSize != null || l.fontSizePx != null) && a.add("font-size", `${H(W(l, t).fontSizePx, 2)}px`);
121
121
  }
122
- a.applyTo(l), i.appendChild(l);
122
+ a.applyTo(s), i.appendChild(s);
123
123
  }
124
124
  return i;
125
125
  }
126
126
  function tt(e, t, n, r) {
127
127
  if (Se(e)) {
128
128
  const i = r.createElement("div");
129
- i.className = E("rich", n), v("block").applyTo(i);
129
+ i.className = E("rich", n), y("block").applyTo(i);
130
130
  for (const o of e.richParagraphs) i.appendChild(et(o, t, n, r));
131
131
  return i;
132
132
  }
133
133
  if (Array.isArray(e.lines) && e.lines.length > 0) {
134
134
  const i = r.createElement("div");
135
- i.className = E("lines", n), v("block").applyTo(i);
135
+ i.className = E("lines", n), y("block").applyTo(i);
136
136
  for (const o of e.lines) {
137
- const l = r.createElement("div");
138
- l.className = E("line", n), l.textContent = o, v("block").add("white-space", "pre").add("min-height", "1lh").applyTo(l), i.appendChild(l);
137
+ const s = r.createElement("div");
138
+ s.className = E("line", n), s.textContent = o, y("block").add("white-space", "pre").add("min-height", "1lh").applyTo(s), i.appendChild(s);
139
139
  }
140
140
  return i;
141
141
  }
@@ -145,74 +145,74 @@ function nt(e, t, n, r) {
145
145
  const i = r.createElement("div");
146
146
  i.className = E("text", n);
147
147
  const o = e.style || {};
148
- return v("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(tt(e, t, n, r)), i;
148
+ return y("flex").add("width", "100%").add("height", "100%").add("flex-direction", "column").add("justify-content", o.verticalAlign === "middle" ? "center" : o.verticalAlign === "bottom" ? "flex-end" : "flex-start").add("overflow-wrap", "anywhere").add("overflow", "hidden").applyTo(i), i.append(tt(e, t, n, r)), i;
149
149
  }
150
150
  function rt(e, t, n) {
151
151
  const r = n.createElement("img");
152
- return r.className = E("image", t), r.src = e.imageData, v("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
152
+ return r.className = E("image", t), r.src = e.imageData, y("block").add("width", "100%").add("height", "100%").add("object-fit", "contain").applyTo(r), r.alt = e.kind, r;
153
153
  }
154
- function ue(e, t, n, r) {
154
+ function ge(e, t, n, r) {
155
155
  const i = r.createElement("div");
156
156
  i.className = E("shape", n);
157
- const o = e.style || {}, l = j(o), a = Me(o), s = `${H(l.widthPt * t / 72, 2)}px solid ${l.color}`, c = v("block");
158
- return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", s), a.right && c.add("border-right", s), a.bottom && c.add("border-bottom", s), a.left && c.add("border-left", s)) : e.kind === "ellipse" ? (a.inner && c.add("border", s).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", s), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
157
+ const o = e.style || {}, s = j(o), a = Me(o), l = `${H(s.widthPt * t / 72, 2)}px solid ${s.color}`, c = y("block");
158
+ return e.grid ? c.add("position", "relative") : e.kind === "rect" ? (a.top && c.add("border-top", l), a.right && c.add("border-right", l), a.bottom && c.add("border-bottom", l), a.left && c.add("border-left", l)) : e.kind === "ellipse" ? (a.inner && c.add("border", l).add("border-radius", "50%"), o.backgroundColor && c.add("background-color", o.backgroundColor)) : e.kind === "line" && c.add("height", "0").add("border-top", l), c.add("box-sizing", "border-box").add("width", "100%").add("height", "100%"), c.applyTo(i), i;
159
159
  }
160
160
  function it(e, t, n) {
161
161
  const r = n.createElementNS("http://www.w3.org/2000/svg", "svg"), i = ie(e.widthMm, t), o = ie(e.heightMm, t);
162
162
  r.setAttribute("width", String(Math.max(1, i))), r.setAttribute("height", String(Math.max(1, o))), r.setAttribute("aria-hidden", "true"), r.style.overflow = "visible", r.style.display = "block";
163
- const l = n.createElementNS("http://www.w3.org/2000/svg", "line");
164
- l.setAttribute("x1", "0"), l.setAttribute("x2", String(i)), l.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), l.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
163
+ const s = n.createElementNS("http://www.w3.org/2000/svg", "line");
164
+ s.setAttribute("x1", "0"), s.setAttribute("x2", String(i)), s.setAttribute("y1", e.lineDirection === "up" ? String(o) : "0"), s.setAttribute("y2", e.lineDirection === "up" ? "0" : String(o));
165
165
  const a = j({ ...e.style, borderColor: e.style?.lineColor ?? e.style?.borderColor });
166
- return l.setAttribute("stroke", a.color), l.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(l), r;
166
+ return s.setAttribute("stroke", a.color), s.setAttribute("stroke-width", String(a.widthPt * t / 72)), r.appendChild(s), r;
167
167
  }
168
168
  function ke(e, t, n, r) {
169
169
  const i = r.createElement("div");
170
170
  i.className = `${E("comp", n)} mr-kind-${e.kind}`;
171
- const o = v("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
171
+ const o = y("block").add("position", "absolute").mm("left", e.leftMm, t).mm("top", e.topMm, t).mm("width", e.widthMm, t).mm("height", e.heightMm, t).add("box-sizing", "border-box");
172
172
  if (Xe(o, e, t), o.applyTo(i), ee(e))
173
173
  return i.appendChild(rt(e, n, r)), i;
174
174
  if (e.kind === "text")
175
175
  return i.appendChild(nt(e, t, n, r)), i;
176
176
  if (e.grid) {
177
- const a = ue(e, t, n, r);
177
+ const a = ge(e, t, n, r);
178
178
  return a.appendChild(Qe(e.grid, e, t, n, r)), i.appendChild(a), i;
179
179
  }
180
180
  if (e.kind === "line" && e.lineDirection)
181
181
  return i.appendChild(it(e, t, r)), i;
182
182
  if (e.kind === "line" || e.kind === "rect" || e.kind === "ellipse")
183
- return i.appendChild(ue(e, t, n, r)), i;
184
- const l = r.createElement("div");
185
- return l.className = E("unknown", n), v("block").applyTo(l), l.textContent = e.fallbackText ?? `[${e.kind}]`, l.dataset.mrUnsupported = e.kind, l.setAttribute("role", "note"), i.appendChild(l), i;
183
+ return i.appendChild(ge(e, t, n, r)), i;
184
+ const s = r.createElement("div");
185
+ return s.className = E("unknown", n), y("block").applyTo(s), s.textContent = e.fallbackText ?? `[${e.kind}]`, s.dataset.mrUnsupported = e.kind, s.setAttribute("role", "note"), i.appendChild(s), i;
186
186
  }
187
- function at(e, t, n, r) {
187
+ function ot(e, t, n, r) {
188
188
  const i = r.createElement("div");
189
- return i.className = E("page", n), v("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(W(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", ve).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, l) => {
189
+ return i.className = E("page", n), y("block", "initial").add("position", "relative").add("font-family", Z).add("font-size", `${H(W(void 0, t).fontSizePx, 2)}px`).add("line-height", String(Q(void 0))).add("white-space", "pre-wrap").add("direction", "ltr").mm("width", e.pageWidthMm, t).mm("height", e.pageHeightMm, t).add("background-color", "#fff").add("color", ye).add("overflow", "hidden").add("box-sizing", "border-box").applyTo(i), e.components.forEach((o, s) => {
190
190
  const a = ke(o, t, n, r);
191
- a.dataset.mrComponentIndex = String(l), i.appendChild(a);
191
+ a.dataset.mrComponentIndex = String(s), i.appendChild(a);
192
192
  }), i;
193
193
  }
194
- function dn(e, t, n = {}) {
194
+ function mn(e, t, n = {}) {
195
195
  const r = n.dpi ?? 96;
196
196
  G(e, "dom", n);
197
197
  const i = t.createElement("div");
198
- return i.className = E("root", n), v("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
199
- i.appendChild(at(o, r, n, t));
198
+ return i.className = E("root", n), y("block").applyTo(i), i.dataset.schemaVersion = e.schemaVersion, e.pages.forEach((o) => {
199
+ i.appendChild(ot(o, r, n, t));
200
200
  }), i;
201
201
  }
202
202
  function R(e) {
203
203
  if (e?.aborted) throw e.reason ?? new DOMException("The operation was aborted.", "AbortError");
204
204
  }
205
- const ot = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
205
+ const at = (e, t) => (R(t), /^data:image\/(?:png|jpe?g|webp|gif|svg\+xml)[;,]/i.test(e) ? new Promise((n, r) => {
206
206
  const i = new Image(), o = () => {
207
- i.onload = null, i.onerror = null, t?.removeEventListener("abort", l);
208
- }, l = () => {
207
+ i.onload = null, i.onerror = null, t?.removeEventListener("abort", s);
208
+ }, s = () => {
209
209
  o(), i.src = "", r(t?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
210
210
  };
211
211
  i.onload = () => {
212
212
  o(), n(i);
213
213
  }, i.onerror = () => {
214
214
  o(), r(new Error("Image could not be decoded for Canvas output."));
215
- }, t?.addEventListener("abort", l, { once: !0 }), i.src = e;
215
+ }, t?.addEventListener("abort", s, { once: !0 }), i.src = e;
216
216
  }) : Promise.reject(new TypeError("Canvas imageData must be an image data URL; provide imageLoader for other sources.")));
217
217
  function st(e, t, n) {
218
218
  return R(n), n ? new Promise((r, i) => {
@@ -227,9 +227,9 @@ async function lt(e, t, n) {
227
227
  return R(n), r;
228
228
  }
229
229
  function ct(e, t, n, r, i, o) {
230
- const l = t, a = l.naturalWidth ?? l.width ?? i, s = l.naturalHeight ?? l.height ?? o;
231
- if (a <= 0 || s <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
232
- const c = Math.min(i / a, o / s), d = a * c, m = s * c;
230
+ const s = t, a = s.naturalWidth ?? s.width ?? i, l = s.naturalHeight ?? s.height ?? o;
231
+ if (a <= 0 || l <= 0) throw new RangeError("Decoded Canvas image dimensions must be positive.");
232
+ const c = Math.min(i / a, o / l), d = a * c, m = l * c;
233
233
  e.drawImage(t, n + (i - d) / 2, r + (o - m) / 2, d, m);
234
234
  }
235
235
  function dt(e) {
@@ -246,90 +246,90 @@ function le(e, t = 96) {
246
246
  function Ie(e, t, n, r = 64e6) {
247
247
  if (!Number.isFinite(t) || t <= 0 || !Number.isFinite(n) || n <= 0) throw new RangeError("Canvas dpr and dpi must be positive finite numbers.");
248
248
  if (!Number.isFinite(r) || r <= 0) throw new RangeError("maxCanvasPixels must be positive and finite.");
249
- const i = le(e, n), o = Math.round(i.widthPx * t), l = Math.round(i.heightPx * t);
250
- if (!Number.isSafeInteger(o) || !Number.isSafeInteger(l) || o * l > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
251
- return { width: o, height: l };
249
+ const i = le(e, n), o = Math.round(i.widthPx * t), s = Math.round(i.heightPx * t);
250
+ if (!Number.isSafeInteger(o) || !Number.isSafeInteger(s) || o * s > r) throw new RangeError("Canvas page exceeds maxCanvasPixels; reduce resolution or split the report.");
251
+ return { width: o, height: s };
252
252
  }
253
253
  function $e(e, t, n, r) {
254
- const i = document.createElement("canvas"), { widthPx: o, heightPx: l } = le(e, n), a = Ie(e, t, n, r);
255
- i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${l}px`;
256
- const s = i.getContext("2d");
257
- if (!s)
254
+ const i = document.createElement("canvas"), { widthPx: o, heightPx: s } = le(e, n), a = Ie(e, t, n, r);
255
+ i.width = a.width, i.height = a.height, i.style.width = `${o}px`, i.style.height = `${s}px`;
256
+ const l = i.getContext("2d");
257
+ if (!l)
258
258
  throw new Error("当前环境不支持 Canvas 2D(测试需真浏览器,见 e2e/canvas.spec.ts)");
259
- return s.scale(t, t), s.fillStyle = "#ffffff", s.fillRect(0, 0, o, l), { canvas: i, ctx: s };
259
+ return l.scale(t, t), l.fillStyle = "#ffffff", l.fillRect(0, 0, o, s), { canvas: i, ctx: l };
260
260
  }
261
- function mn(e, t = 96) {
261
+ function hn(e, t = 96) {
262
262
  return W(e, t).fontSizePx;
263
263
  }
264
- function Ne(e, t, n, r, i, o, l, a = "top") {
265
- e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${l}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
266
- const s = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
267
- `), d = c.length * s;
264
+ function Ne(e, t, n, r, i, o, s, a = "top") {
265
+ e.font = `${t.italic ? "italic " : ""}${t.bold ? "bold " : ""}${t.fontSizePx}px ${s}`, "letterSpacing" in e && (e.letterSpacing = "0px"), e.fillStyle = t.color, e.textBaseline = "alphabetic";
266
+ const l = t.fontSizePx * t.lineHeight, c = t.text === "" ? [""] : t.text.split(`
267
+ `), d = c.length * l;
268
268
  let m = r;
269
- a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, g) => {
270
- mt(e, h, t, n, m + g * s + t.fontSizePx * 0.8, i);
269
+ a === "middle" ? m = r + (o - d) / 2 : a === "bottom" && (m = r + o - d), c.forEach((h, u) => {
270
+ mt(e, h, t, n, m + u * l + t.fontSizePx * 0.8, i);
271
271
  }), e.textAlign = "left";
272
272
  }
273
273
  function mt(e, t, n, r, i, o) {
274
- const l = Array.from(t), a = n.letterSpacingPx ?? 0;
274
+ const s = Array.from(t), a = n.letterSpacingPx ?? 0;
275
275
  if (!a) {
276
276
  e.textAlign = n.align === "center" ? "center" : n.align === "right" ? "right" : "left";
277
277
  const m = n.align === "center" ? r + o / 2 : n.align === "right" ? r + o : r;
278
278
  e.fillText(t, m, i);
279
279
  return;
280
280
  }
281
- const s = e.measureText(t).width + Math.max(0, l.length - 1) * a, c = n.align === "center" ? r + (o - s) / 2 : n.align === "right" ? r + o - s : r;
281
+ const l = e.measureText(t).width + Math.max(0, s.length - 1) * a, c = n.align === "center" ? r + (o - l) / 2 : n.align === "right" ? r + o - l : r;
282
282
  e.textAlign = "left";
283
283
  let d = "";
284
- l.forEach((m, h) => {
284
+ s.forEach((m, h) => {
285
285
  e.fillText(m, c + e.measureText(d).width + h * a, i), d += m;
286
286
  });
287
287
  }
288
- function ht(e, t, n, r, i, o, l) {
288
+ function ht(e, t, n, r, i, o, s) {
289
289
  for (const a of Re(t, n))
290
- e.strokeStyle = a.color, e.lineWidth = O(a.widthPt, l), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
290
+ e.strokeStyle = a.color, e.lineWidth = O(a.widthPt, s), e.beginPath(), a.kind === "v" ? (e.moveTo(r + a.pos * o, i + a.from * o), e.lineTo(r + a.pos * o, i + a.to * o)) : (e.moveTo(r + a.from * o, i + a.pos * o), e.lineTo(r + a.to * o, i + a.pos * o)), e.stroke();
291
291
  }
292
- function gt(e, t, n, r, i, o) {
292
+ function ut(e, t, n, r, i, o) {
293
293
  e.beginPath(), t.top && (e.moveTo(n, r), e.lineTo(n + i, r)), t.right && (e.moveTo(n + i, r), e.lineTo(n + i, r + o)), t.bottom && (e.moveTo(n + i, r + o), e.lineTo(n, r + o)), t.left && (e.moveTo(n, r + o), e.lineTo(n, r)), e.stroke();
294
294
  }
295
- function ut(e, t, n, r, i, o, l, a, s, c, d) {
296
- const m = Ce(t, o / a, l / a);
297
- for (const g of m.cells) {
298
- const f = g.cell.style?.backgroundColor ?? n.style?.backgroundColor;
299
- f && (e.fillStyle = f, e.fillRect(r + g.xMm * a, i + g.yMm * a, g.widthMm * a, g.heightMm * a));
295
+ function gt(e, t, n, r, i, o, s, a, l, c, d) {
296
+ const m = Ce(t, o / a, s / a);
297
+ for (const u of m.cells) {
298
+ const f = u.cell.style?.backgroundColor ?? n.style?.backgroundColor;
299
+ f && (e.fillStyle = f, e.fillRect(r + u.xMm * a, i + u.yMm * a, u.widthMm * a, u.heightMm * a));
300
300
  }
301
- ht(e, m, n, r, i, a, s);
301
+ ht(e, m, n, r, i, a, l);
302
302
  const h = t.paddingMm ?? 0.5;
303
- for (const g of m.cells) {
304
- const f = g.cell.text ?? "";
303
+ for (const u of m.cells) {
304
+ const f = u.cell.text ?? "";
305
305
  if (!f) continue;
306
- const b = xe(n.style, g.cell.style), I = W(b, s), C = g.cell.indentMm ?? 0, S = Math.max(0, g.widthMm - 2 * h - C), A = Te(f, S, { fontSizePt: I.fontSizePt, bold: b.bold, italic: b.italic, fontFamily: b.fontFamily ?? c, letterSpacingPt: b.letterSpacing }, d).join(`
306
+ const b = xe(n.style, u.cell.style), $ = W(b, l), C = u.cell.indentMm ?? 0, S = Math.max(0, u.widthMm - 2 * h - C), A = Te(f, S, { fontSizePt: $.fontSizePt, bold: b.bold, italic: b.italic, fontFamily: b.fontFamily ?? c, letterSpacingPt: b.letterSpacing }, d).join(`
307
307
  `);
308
308
  Ne(
309
309
  e,
310
310
  {
311
311
  text: A,
312
- fontSizePx: I.fontSizePx,
312
+ fontSizePx: $.fontSizePx,
313
313
  bold: b.bold ?? !1,
314
314
  italic: b.italic,
315
- color: Ee(b, ve),
315
+ color: Ee(b, ye),
316
316
  align: b.align ?? "left",
317
317
  lineHeight: Q(b),
318
- letterSpacingPx: O(b.letterSpacing ?? 0, s)
318
+ letterSpacingPx: O(b.letterSpacing ?? 0, l)
319
319
  },
320
- r + (g.xMm + h + C) * a,
321
- i + (g.yMm + h) * a,
320
+ r + (u.xMm + h + C) * a,
321
+ i + (u.yMm + h) * a,
322
322
  S * a,
323
- Math.max(0, g.heightMm - 2 * h) * a,
323
+ Math.max(0, u.heightMm - 2 * h) * a,
324
324
  b.fontFamily ?? c,
325
325
  b.verticalAlign ?? "middle"
326
326
  );
327
327
  }
328
328
  }
329
- function ft(e, t, n, r, i, o, l, a, s) {
330
- const c = t.style ?? {}, d = W(c, l), m = Se(t) ? t.richParagraphs.map((h) => h.segments.map((g) => g.text ?? g.field ?? "").join("")).join(`
329
+ function ft(e, t, n, r, i, o, s, a, l) {
330
+ const c = t.style ?? {}, d = W(c, s), m = Se(t) ? t.richParagraphs.map((h) => h.segments.map((u) => u.text ?? u.field ?? "").join("")).join(`
331
331
  `) : t.lines?.length ? t.lines.join(`
332
- `) : Te(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, s).join(`
332
+ `) : Te(t.text ?? "", t.widthMm, { fontSizePt: d.fontSizePt, bold: c.bold, italic: c.italic, fontFamily: c.fontFamily ?? a, letterSpacingPt: c.letterSpacing }, l).join(`
333
333
  `);
334
334
  Ne(e, {
335
335
  text: m,
@@ -339,201 +339,201 @@ function ft(e, t, n, r, i, o, l, a, s) {
339
339
  color: Ee(c),
340
340
  align: c.align ?? "left",
341
341
  lineHeight: Q(c),
342
- letterSpacingPx: O(c.letterSpacing ?? 0, l)
342
+ letterSpacingPx: O(c.letterSpacing ?? 0, s)
343
343
  }, n, r, i, o, c.fontFamily ?? a, c.verticalAlign);
344
344
  }
345
- function ce(e, t, n, r, i, o, l) {
346
- const a = t.leftMm * n, s = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
345
+ function ce(e, t, n, r, i, o, s) {
346
+ const a = t.leftMm * n, l = t.topMm * n, c = t.widthMm * n, d = t.heightMm * n, m = t.style ?? {};
347
347
  if (ee(t)) {
348
- const h = l?.get(t.imageData);
349
- h ? ct(e, h, a, s, c, d) : fe(e, t, a, s, c, d);
348
+ const h = s?.get(t.imageData);
349
+ h ? ct(e, h, a, l, c, d) : fe(e, t, a, l, c, d);
350
350
  return;
351
351
  }
352
352
  if (t.grid) {
353
- ut(e, t.grid, t, a, s, c, d, n, r, i, o);
353
+ gt(e, t.grid, t, a, l, c, d, n, r, i, o);
354
354
  return;
355
355
  }
356
356
  switch (t.kind) {
357
357
  case "text": {
358
- ft(e, t, a, s, c, d, r, i, o);
358
+ ft(e, t, a, l, c, d, r, i, o);
359
359
  break;
360
360
  }
361
361
  case "rect": {
362
- const h = j(m), g = Me(m);
363
- m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, s, c, d)), g.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), gt(e, g, a, s, c, d));
362
+ const h = j(m), u = Me(m);
363
+ m.backgroundColor && (e.fillStyle = m.backgroundColor, e.fillRect(a, l, c, d)), u.inner && (e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), ut(e, u, a, l, c, d));
364
364
  break;
365
365
  }
366
366
  case "line": {
367
367
  const h = j({ ...m, borderColor: m.lineColor ?? m.borderColor });
368
368
  e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), e.beginPath();
369
- const g = t.lineDirection === "up" ? s + d : t.lineDirection === "down" ? s : s + d / 2, f = t.lineDirection === "up" ? s : t.lineDirection === "down" ? s + d : s + d / 2;
370
- e.moveTo(a, g), e.lineTo(a + c, f), e.stroke();
369
+ const u = t.lineDirection === "up" ? l + d : t.lineDirection === "down" ? l : l + d / 2, f = t.lineDirection === "up" ? l : t.lineDirection === "down" ? l + d : l + d / 2;
370
+ e.moveTo(a, u), e.lineTo(a + c, f), e.stroke();
371
371
  break;
372
372
  }
373
373
  case "ellipse": {
374
374
  const h = j(m);
375
- e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, s + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
375
+ e.strokeStyle = h.color, e.lineWidth = O(h.widthPt, r), m.backgroundColor && (e.fillStyle = m.backgroundColor, e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.fill()), e.beginPath(), e.ellipse(a + c / 2, l + d / 2, c / 2, d / 2, 0, 0, Math.PI * 2), e.stroke();
376
376
  break;
377
377
  }
378
378
  default:
379
- fe(e, t, a, s, c, d);
379
+ fe(e, t, a, l, c, d);
380
380
  break;
381
381
  }
382
382
  }
383
383
  function fe(e, t, n, r, i, o) {
384
384
  e.save(), e.strokeStyle = "#94a3b8", e.strokeRect(n, r, i, o), e.fillStyle = "#64748b", e.font = "12px sans-serif", e.fillText(t.fallbackText ?? `[${t.kind}]`, n + 3, r + 14), e.restore();
385
385
  }
386
- async function hn(e, t = {}) {
386
+ async function un(e, t = {}) {
387
387
  if (typeof document > "u")
388
388
  throw new Error("renderPlanToImages 需要浏览器环境(SSR/Node 请在客户端钩子中调用)");
389
389
  const { format: n = "png", quality: r = 0.92, ...i } = t;
390
390
  if (n !== "png" && n !== "jpeg") throw new TypeError("Image format must be png or jpeg.");
391
391
  if (!Number.isFinite(r) || r < 0 || r > 1) throw new RangeError("Image quality must be between 0 and 1.");
392
392
  R(t.signal);
393
- const o = await oe(e, { ...t, format: "canvas" });
393
+ const o = await ae(e, { ...t, format: "canvas" });
394
394
  e = o.plan;
395
- const l = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", s = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
395
+ const s = [...o.diagnostics, ...G(e, "canvas", t)], a = n === "jpeg" ? "image/jpeg" : "image/png", l = [], c = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
396
396
  for (let d = Math.max(0, t.start ?? 0); d <= c; d++) {
397
397
  R(t.signal);
398
- const m = await Le(e.pages[d], d, i, l);
398
+ const m = await Le(e.pages[d], d, i, s);
399
399
  try {
400
- s.push(await pt(m, a, r, t.signal));
400
+ l.push(await pt(m, a, r, t.signal));
401
401
  } finally {
402
402
  m.width = 0, m.height = 0;
403
403
  }
404
- await Ve(t, s.length, c - Math.max(0, t.start ?? 0) + 1);
404
+ await Ve(t, l.length, c - Math.max(0, t.start ?? 0) + 1);
405
405
  }
406
- return R(t.signal), { blobs: s, diagnostics: l };
406
+ return R(t.signal), { blobs: l, diagnostics: s };
407
407
  }
408
408
  function pt(e, t, n, r) {
409
409
  return R(r), new Promise((i, o) => {
410
- const l = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
411
- r?.addEventListener("abort", l, { once: !0 });
410
+ const s = () => o(r?.reason ?? new DOMException("The operation was aborted.", "AbortError"));
411
+ r?.addEventListener("abort", s, { once: !0 });
412
412
  try {
413
413
  e.toBlob((a) => {
414
- r?.removeEventListener("abort", l), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
414
+ r?.removeEventListener("abort", s), a ? i(a) : o(new Error("Canvas encoding failed; no empty image was emitted."));
415
415
  }, t, n);
416
416
  } catch (a) {
417
- r?.removeEventListener("abort", l), o(a);
417
+ r?.removeEventListener("abort", s), o(a);
418
418
  }
419
419
  });
420
420
  }
421
421
  function gn(e, t = {}) {
422
422
  if (R(t.signal), typeof document > "u")
423
423
  throw new Error("renderPlanToCanvas 需要浏览器环境(SSR 请在客户端钩子中调用)");
424
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, l = t.measurer ?? ae, a = Math.max(0, t.start ?? 0), s = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = wt(e, a, s);
424
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = Math.max(0, t.start ?? 0), l = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1), c = [], d = G(e, "canvas", t), m = wt(e, a, l);
425
425
  for (const h of m)
426
426
  Pe(h, t), d.push(h);
427
427
  if (t.fidelity === "strict" && m.length) throw new Ue(d);
428
- for (let h = a; h <= s; h++) {
428
+ for (let h = a; h <= l; h++) {
429
429
  R(t.signal);
430
- const g = e.pages[h], { canvas: f, ctx: b } = $e(g, n, r, t.maxCanvasPixels);
431
- for (const I of g.components)
432
- ce(b, I, i, r, o, l);
430
+ const u = e.pages[h], { canvas: f, ctx: b } = $e(u, n, r, t.maxCanvasPixels);
431
+ for (const $ of u.components)
432
+ ce(b, $, i, r, o, s);
433
433
  c.push(f);
434
434
  }
435
435
  return { canvases: c, diagnostics: d };
436
436
  }
437
437
  function wt(e, t, n) {
438
- return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, l) => ee(o) ? [{
438
+ return n < t ? [] : e.pages.slice(t, n + 1).flatMap((r, i) => r.components.flatMap((o, s) => ee(o) ? [{
439
439
  code: "async-image-required",
440
440
  severity: "warning",
441
441
  format: "canvas",
442
442
  pageIndex: t + i,
443
- componentIndex: l,
443
+ componentIndex: s,
444
444
  kind: o.kind,
445
445
  nid: o.nid,
446
446
  message: "Use renderPlanToCanvasAsync or renderPlanToImages to decode and include images."
447
447
  }] : []));
448
448
  }
449
- async function un(e, t = {}) {
449
+ async function fn(e, t = {}) {
450
450
  if (typeof document > "u") throw new Error("renderPlanToCanvasAsync 需要浏览器环境(Node 请使用 PDF 或 XLSX 输出)");
451
451
  R(t.signal);
452
- const n = await oe(e, { ...t, format: "canvas" });
452
+ const n = await ae(e, { ...t, format: "canvas" });
453
453
  e = n.plan;
454
454
  const r = [...n.diagnostics, ...G(e, "canvas", t)], i = [], o = Math.min(e.pages.length - 1, t.end ?? e.pages.length - 1);
455
- for (let l = Math.max(0, t.start ?? 0); l <= o; l++)
456
- i.push(await Le(e.pages[l], l, t, r));
455
+ for (let s = Math.max(0, t.start ?? 0); s <= o; s++)
456
+ i.push(await Le(e.pages[s], s, t, r));
457
457
  return { canvases: i, diagnostics: r };
458
458
  }
459
459
  async function Le(e, t, n, r) {
460
- const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, l = n.fontFamily ?? Z, a = await De(e, t, n, r);
460
+ const i = n.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), o = n.dpi ?? 96, s = n.fontFamily ?? Z, a = await De(e, t, n, r);
461
461
  R(n.signal);
462
- const { canvas: s, ctx: c } = $e(e, i, o, n.maxCanvasPixels);
463
- for (const d of e.components) ce(c, d, o / 25.4, o, l, n.measurer ?? ae, a);
464
- return s;
462
+ const { canvas: l, ctx: c } = $e(e, i, o, n.maxCanvasPixels);
463
+ for (const d of e.components) ce(c, d, o / 25.4, o, s, n.measurer ?? oe, a);
464
+ return l;
465
465
  }
466
466
  async function De(e, t, n, r) {
467
- const i = n.imageLoader ?? ot;
468
- return lt(e, async (o, l) => {
467
+ const i = n.imageLoader ?? at;
468
+ return lt(e, async (o, s) => {
469
469
  try {
470
- return await i(o, l);
470
+ return await i(o, s);
471
471
  } catch (a) {
472
- if (l?.aborted) throw a;
473
- const s = e.components.findIndex((m) => m.imageData === o), c = e.components[s], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: s, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
472
+ if (s?.aborted) throw a;
473
+ const l = e.components.findIndex((m) => m.imageData === o), c = e.components[l], d = { code: "image-decode-failed", severity: "warning", format: "canvas", pageIndex: t, componentIndex: l, kind: c.kind, nid: c.nid, message: "Image decoding failed; raster output was cancelled instead of omitting the image." };
474
474
  throw r.push(d), Pe(d, n), a;
475
475
  }
476
476
  }, n.signal);
477
477
  }
478
- function fn(e, t = {}) {
479
- const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, l = t.measurer ?? ae, a = t.overscan ?? 1, s = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((u) => u.pageHeightMm * i), m = Math.max(1, ...e.pages.map((u) => u.pageWidthMm * i)), h = { start: 0, end: -1 };
480
- let g = null, f = null, b = null, I = null, C = [], S = 0, A = [], U = 0, _ = new AbortController();
478
+ function pn(e, t = {}) {
479
+ const n = t.dpr ?? (typeof devicePixelRatio == "number" ? devicePixelRatio : 1), r = t.dpi ?? 96, i = r / 96 * se, o = t.fontFamily ?? Z, s = t.measurer ?? oe, a = t.overscan ?? 1, l = t.gapPx ?? 18, c = t.pagesPerFrame ?? 1, d = e.pages.map((g) => g.pageHeightMm * i), m = Math.max(1, ...e.pages.map((g) => g.pageWidthMm * i)), h = { start: 0, end: -1 };
480
+ let u = null, f = null, b = null, $ = null, C = [], S = 0, A = [], U = 0, _ = new AbortController();
481
481
  const me = [];
482
482
  function ze() {
483
- const u = g;
484
- u.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), I = document.createElement("div"), f.appendChild(b), C = [];
483
+ const g = u;
484
+ g.innerHTML = "", f = document.createElement("div"), f.style.cssText = `width:${m}px;margin:0 auto;`, b = document.createElement("div"), $ = document.createElement("div"), f.appendChild(b), C = [];
485
485
  const M = Math.min(e.pages.length, 3 + a * 2);
486
- for (let L = 0; L < M; L++) {
487
- const y = document.createElement("div");
488
- y.style.cssText = `margin:0 auto ${s}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(y), C.push(y);
486
+ for (let D = 0; D < M; D++) {
487
+ const v = document.createElement("div");
488
+ v.style.cssText = `margin:0 auto ${l}px;box-shadow:0 2px 8px rgba(0,0,0,.35);background:#fff;`, f.appendChild(v), C.push(v);
489
489
  }
490
- f.appendChild(I), u.appendChild(f);
490
+ f.appendChild($), g.appendChild(f);
491
491
  }
492
- async function He(u, M) {
493
- const L = U, y = await oe(e, { ...t, signal: _.signal, format: "canvas", start: M, end: M });
494
- me.push(...y.diagnostics);
495
- const T = y.plan.pages[M], Y = await De(T, M, { ...t, signal: _.signal }, me);
496
- if (L !== U || !g) return;
492
+ async function He(g, M) {
493
+ const D = U, v = await ae(e, { ...t, signal: _.signal, format: "canvas", start: M, end: M });
494
+ me.push(...v.diagnostics);
495
+ const T = v.plan.pages[M], Y = await De(T, M, { ...t, signal: _.signal }, me);
496
+ if (D !== U || !u) return;
497
497
  const { widthPx: ne, heightPx: re } = le(T, r);
498
- let $ = u.firstElementChild;
499
- (!$ || $.tagName !== "CANVAS") && ($ = document.createElement("canvas"), u.innerHTML = "", u.appendChild($));
500
- const ge = Ie(T, n, r, t.maxCanvasPixels);
501
- $.width = ge.width, $.height = ge.height, $.style.width = `${ne}px`, $.style.height = `${re}px`;
502
- const F = $.getContext("2d");
498
+ let N = g.firstElementChild;
499
+ (!N || N.tagName !== "CANVAS") && (N = document.createElement("canvas"), g.innerHTML = "", g.appendChild(N));
500
+ const ue = Ie(T, n, r, t.maxCanvasPixels);
501
+ N.width = ue.width, N.height = ue.height, N.style.width = `${ne}px`, N.style.height = `${re}px`;
502
+ const F = N.getContext("2d");
503
503
  if (F) {
504
504
  F.setTransform(1, 0, 0, 1, 0, 0), F.scale(n, n), F.fillStyle = "#ffffff", F.fillRect(0, 0, ne, re);
505
505
  for (const _e of T.components)
506
- ce(F, _e, i, r, o, l, Y);
507
- $.dataset.canvasPage = String(M), u.style.height = `${re}px`, u.style.width = `${ne}px`;
506
+ ce(F, _e, i, r, o, s, Y);
507
+ N.dataset.canvasPage = String(M), g.style.height = `${re}px`, g.style.width = `${ne}px`;
508
508
  }
509
509
  }
510
- function We(u) {
511
- U++, h.start = u.start, h.end = u.end, b.style.height = `${u.start * s + d.slice(0, u.start).reduce((y, T) => y + T, 0)}px`;
512
- const M = e.pages.length - 1 - u.end;
513
- I.style.height = `${M * s + d.slice(u.end + 1).reduce((y, T) => y + T, 0)}px`;
514
- const L = u.end - u.start + 1;
515
- C.forEach((y, T) => {
516
- if (T < L) {
517
- y.style.display = "";
518
- const Y = u.start + T;
519
- y.style.height = `${d[Y] ?? 0}px`;
510
+ function We(g) {
511
+ U++, h.start = g.start, h.end = g.end, b.style.height = `${g.start * l + d.slice(0, g.start).reduce((v, T) => v + T, 0)}px`;
512
+ const M = e.pages.length - 1 - g.end;
513
+ $.style.height = `${M * l + d.slice(g.end + 1).reduce((v, T) => v + T, 0)}px`;
514
+ const D = g.end - g.start + 1;
515
+ C.forEach((v, T) => {
516
+ if (T < D) {
517
+ v.style.display = "";
518
+ const Y = g.start + T;
519
+ v.style.height = `${d[Y] ?? 0}px`;
520
520
  } else
521
- y.style.display = "none";
521
+ v.style.display = "none";
522
522
  }), A = [];
523
- for (let y = u.start; y <= u.end; y++) {
524
- const T = C[y - u.start];
523
+ for (let v = g.start; v <= g.end; v++) {
524
+ const T = C[v - g.start];
525
525
  if (!T) continue;
526
- T.firstElementChild?.dataset?.canvasPage !== String(y) && A.push(y);
526
+ T.firstElementChild?.dataset?.canvasPage !== String(v) && A.push(v);
527
527
  }
528
528
  te();
529
529
  }
530
530
  function te() {
531
531
  S || A.length === 0 || (S = requestAnimationFrame(() => {
532
532
  S = 0;
533
- let u = Math.max(1, c);
534
- for (; A.length > 0 && u-- > 0; ) {
535
- const M = A.shift(), L = C[M - h.start];
536
- L && He(L, M).catch(() => {
533
+ let g = Math.max(1, c);
534
+ for (; A.length > 0 && g-- > 0; ) {
535
+ const M = A.shift(), D = C[M - h.start];
536
+ D && He(D, M).catch(() => {
537
537
  });
538
538
  }
539
539
  A.length > 0 && te();
@@ -542,25 +542,25 @@ function fn(e, t = {}) {
542
542
  function V() {
543
543
  S || (S = requestAnimationFrame(() => {
544
544
  S = 0;
545
- const u = g, M = dt({
545
+ const g = u, M = dt({
546
546
  pageHeightsPx: d,
547
- viewportHeightPx: u.clientHeight,
548
- scrollTopPx: u.scrollTop,
547
+ viewportHeightPx: g.clientHeight,
548
+ scrollTopPx: g.scrollTop,
549
549
  overscan: a,
550
- gapPx: s
550
+ gapPx: l
551
551
  });
552
552
  M.start !== h.start || M.end !== h.end ? We(M) : te();
553
553
  }));
554
554
  }
555
555
  let q = null;
556
556
  return {
557
- attach(u) {
557
+ attach(g) {
558
558
  if (typeof document > "u")
559
559
  throw new Error("createCanvasPager 需要浏览器环境(SSR 请在客户端钩子中调用 attach)");
560
- R(t.signal), _ = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), G(e, "canvas", t), g = u, ze(), u.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(u)), V();
560
+ R(t.signal), _ = new AbortController(), t.signal?.addEventListener("abort", he, { once: !0 }), G(e, "canvas", t), u = g, ze(), g.addEventListener("scroll", V, { passive: !0 }), typeof ResizeObserver < "u" && (q = new ResizeObserver(() => V()), q.observe(g)), V();
561
561
  },
562
562
  destroy() {
563
- U++, _.abort(), t.signal?.removeEventListener("abort", he), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, g?.removeEventListener("scroll", V), A = [], f?.remove(), g = null;
563
+ U++, _.abort(), t.signal?.removeEventListener("abort", he), S && cancelAnimationFrame(S), S = 0, q?.disconnect(), q = null, u?.removeEventListener("scroll", V), A = [], f?.remove(), u = null;
564
564
  },
565
565
  window() {
566
566
  return { ...h };
@@ -608,18 +608,18 @@ class bt {
608
608
  */
609
609
  page(t = "a4", n = {}, r) {
610
610
  this.collect();
611
- const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: l, heightMm: a } = Fe(
611
+ const o = r != null && !("margins" in r) && !("landscape" in r) && ("marginTopMm" in r || "marginBottomMm" in r || "marginLeftMm" in r || "marginRightMm" in r) ? { margins: r } : typeof n == "number" ? r ?? {} : n, { widthMm: s, heightMm: a } = Fe(
612
612
  t,
613
613
  typeof n == "number" ? n : void 0,
614
614
  o.landscape
615
- ), s = o.margins ?? {};
616
- return this.pending = new yt(this, {
617
- widthMm: l,
615
+ ), l = o.margins ?? {};
616
+ return this.pending = new vt(this, {
617
+ widthMm: s,
618
618
  heightMm: a,
619
- marginTopMm: s.marginTopMm ?? 10,
620
- marginBottomMm: s.marginBottomMm ?? 10,
621
- marginLeftMm: s.marginLeftMm ?? 10,
622
- marginRightMm: s.marginRightMm ?? 10
619
+ marginTopMm: l.marginTopMm ?? 10,
620
+ marginBottomMm: l.marginBottomMm ?? 10,
621
+ marginLeftMm: l.marginLeftMm ?? 10,
622
+ marginRightMm: l.marginRightMm ?? 10
623
623
  }), this.pending;
624
624
  }
625
625
  collect() {
@@ -631,7 +631,7 @@ class bt {
631
631
  return this.templateParams ? { params: this.templateParams, pages: this.pages } : { pages: this.pages };
632
632
  }
633
633
  }
634
- class yt {
634
+ class vt {
635
635
  constructor(t, n) {
636
636
  this.parent = t, this.page = n, this.components = [];
637
637
  }
@@ -700,10 +700,10 @@ class yt {
700
700
  return this.done().build();
701
701
  }
702
702
  }
703
- function pn() {
703
+ function wn() {
704
704
  return new bt();
705
705
  }
706
- function wn(e, t = {}) {
706
+ function bn(e, t = {}) {
707
707
  return je([], e), e.fields.map((n) => ({
708
708
  field: n.field,
709
709
  header: `${n.label ?? n.field}${n.unit ? ` (${n.unit})` : ""}`,
@@ -719,7 +719,7 @@ function X(e, t, n) {
719
719
  if (e !== void 0 && !["left", "center", "right", "justify", ...n ? ["auto"] : []].includes(e))
720
720
  throw new Error(`${t} 必须是 left/center/right/justify${n ? "/auto" : ""}`);
721
721
  }
722
- function vt(e) {
722
+ function yt(e) {
723
723
  const t = e.layout ?? "page";
724
724
  if (t !== "page" && t !== "wide")
725
725
  throw new Error("layout 必须是 page 或 wide");
@@ -759,10 +759,10 @@ function Et(e, t) {
759
759
  throw new Error("title 必须是字符串");
760
760
  const r = e.titleHeightMm === void 0 ? 10 : e.titleHeightMm, i = e.titleGapMm === void 0 ? 4 : e.titleGapMm;
761
761
  P(r, "titleHeightMm"), P(i, "titleGapMm", !0);
762
- const o = e.title !== void 0 && e.title.length > 0, l = o ? r + i : 0;
763
- if (l >= t)
762
+ const o = e.title !== void 0 && e.title.length > 0, s = o ? r + i : 0;
763
+ if (s >= t)
764
764
  throw new Error("标题高度与间距占满页面,必须为表格保留可用高度");
765
- return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: l };
765
+ return { dataset: n, titleHeightMm: r, hasTitle: o, titleSpaceMm: s };
766
766
  }
767
767
  function St(e) {
768
768
  if (e.listOptions !== void 0 && (!e.listOptions || typeof e.listOptions != "object" || Array.isArray(e.listOptions)))
@@ -788,56 +788,56 @@ function Ct(e, t, n, r) {
788
788
  const { fixedWidthMm: i, maxFlex: o } = Tt(e.columns);
789
789
  if (t === "page" && i > r)
790
790
  throw new Error(`固定列宽 ${i}mm 超出页面可用宽度 ${r}mm`);
791
- const l = r - i;
792
- if (t === "page" && o > 0 && l <= 0)
791
+ const s = r - i;
792
+ if (t === "page" && o > 0 && s <= 0)
793
793
  throw new Error("固定列占满页面可用宽度,自动列需要正的剩余宽度");
794
794
  const a = o > 0 ? e.columns.reduce((c, d) => c + (d.widthMm === void 0 ? (d.flex ?? 1) / o : 0), 0) : 0;
795
795
  return { columns: e.columns.map(({ widthMm: c, flex: d, ...m }, h) => {
796
- const g = c ?? (t === "wide" ? n * (d ?? 1) : l * ((d ?? 1) / o) / a);
797
- return P(g, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: g };
796
+ const u = c ?? (t === "wide" ? n * (d ?? 1) : s * ((d ?? 1) / o) / a);
797
+ return P(u, `columns[${h}] 分配后的 widthMm`), { ...m, widthMm: u };
798
798
  }), fixedWidthMm: i, maxFlex: o };
799
799
  }
800
- function bn(e) {
800
+ function vn(e) {
801
801
  if (!e || typeof e != "object")
802
802
  throw new Error("标准明细模板需要 options 对象");
803
803
  if (!Array.isArray(e.columns) || e.columns.length === 0)
804
804
  throw new Error("columns 至少需要一列");
805
- const { layout: t, columnWidthMm: n } = vt(e), r = Mt(e);
805
+ const { layout: t, columnWidthMm: n } = yt(e), r = Mt(e);
806
806
  let i = r.widthMm;
807
- const o = r.heightMm, l = xt(e);
808
- let a = i - l.marginLeftMm - l.marginRightMm;
809
- const s = o - l.marginTopMm - l.marginBottomMm;
810
- if (t === "page" && a <= 0 || s <= 0)
807
+ const o = r.heightMm, s = xt(e);
808
+ let a = i - s.marginLeftMm - s.marginRightMm;
809
+ const l = o - s.marginTopMm - s.marginBottomMm;
810
+ if (t === "page" && a <= 0 || l <= 0)
811
811
  throw new Error("页边距占满纸张,必须保留正的可用宽度和高度");
812
- const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Et(e, s), g = St(e), { columns: f, fixedWidthMm: b, maxFlex: I } = Ct(e, t, n, a);
813
- t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a + l.marginLeftMm + l.marginRightMm, P(i, "宽表总宽度"));
814
- const C = { widthMm: i, heightMm: o, ...l, components: [], ...t === "wide" ? { layout: t } : {} };
812
+ const { dataset: c, titleHeightMm: d, hasTitle: m, titleSpaceMm: h } = Et(e, l), u = St(e), { columns: f, fixedWidthMm: b, maxFlex: $ } = Ct(e, t, n, a);
813
+ t === "wide" && (a = f.reduce((S, A) => S + A.widthMm, 0), P(a, "宽表总列宽"), i = a + s.marginLeftMm + s.marginRightMm, P(i, "宽表总宽度"));
814
+ const C = { widthMm: i, heightMm: o, ...s, components: [], ...t === "wide" ? { layout: t } : {} };
815
815
  return m && C.components.push({
816
816
  kind: "text",
817
817
  text: e.title,
818
- leftMm: l.marginLeftMm,
819
- topMm: l.marginTopMm,
818
+ leftMm: s.marginLeftMm,
819
+ topMm: s.marginTopMm,
820
820
  widthMm: a,
821
821
  heightMm: d,
822
822
  style: { fontSize: 16, bold: !0, align: "center", verticalAlign: "middle", ...e.titleStyle }
823
823
  }), C.components.push({
824
824
  align: "auto",
825
825
  headerAlign: "center",
826
- ...g,
826
+ ...u,
827
827
  kind: "list",
828
828
  ...t === "wide" ? { layout: t } : {},
829
829
  ...m ? { title: e.title } : {},
830
830
  dataset: c,
831
831
  columns: f,
832
- leftMm: l.marginLeftMm,
833
- topMm: l.marginTopMm + h,
834
- widthMm: t === "wide" || I > 0 ? a : b
832
+ leftMm: s.marginLeftMm,
833
+ topMm: s.marginTopMm + h,
834
+ widthMm: t === "wide" || $ > 0 ? a : b
835
835
  }), e.params === void 0 ? { pages: [C] } : { params: e.params, pages: [C] };
836
836
  }
837
837
  function yn(e) {
838
838
  return e;
839
839
  }
840
- class N extends Error {
840
+ class L extends Error {
841
841
  constructor(t, n) {
842
842
  super(n), this.code = t, this.name = "ReportTemplateStoreError";
843
843
  }
@@ -852,75 +852,75 @@ function x(e) {
852
852
  }
853
853
  function pe(e) {
854
854
  const t = e ? Number(e.revision) : 0;
855
- if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new N("history", "修订号无效或已达上限");
855
+ if (!Number.isSafeInteger(t) || t < 0 || t >= Number.MAX_SAFE_INTEGER) throw new L("history", "修订号无效或已达上限");
856
856
  return String(t + 1);
857
857
  }
858
- function vn(e, t = {}) {
859
- const n = async (l, a) => {
858
+ function Mn(e, t = {}) {
859
+ const n = async (s, a) => {
860
860
  x(a);
861
- const s = await e.read(l, a);
862
- return x(a), s ? k(s) : void 0;
863
- }, r = async (l, a) => {
864
- const s = await n(l, a.signal);
865
- if ((s?.revision ?? null) !== a.expectedRevision) throw new N("conflict", "模板已变化,请重新读取后提交");
866
- return s;
867
- }, i = async (l, a, s) => {
868
- if (x(a.signal), !await e.compareAndSwap(l.id, a.expectedRevision, k(l), { signal: a.signal, ...s ? { publication: k(s) } : {} })) throw new N("conflict", "模板已被其他请求更新");
869
- return k(l);
870
- }, o = async (l, a, s, c) => {
861
+ const l = await e.read(s, a);
862
+ return x(a), l ? k(l) : void 0;
863
+ }, r = async (s, a) => {
864
+ const l = await n(s, a.signal);
865
+ if ((l?.revision ?? null) !== a.expectedRevision) throw new L("conflict", "模板已变化,请重新读取后提交");
866
+ return l;
867
+ }, i = async (s, a, l) => {
868
+ if (x(a.signal), !await e.compareAndSwap(s.id, a.expectedRevision, k(s), { signal: a.signal, ...l ? { publication: k(l) } : {} })) throw new L("conflict", "模板已被其他请求更新");
869
+ return k(s);
870
+ }, o = async (s, a, l, c) => {
871
871
  if (t.beforePublish) {
872
- x(s.signal);
873
- const g = await t.beforePublish({ document: D(a), previous: l.published ? D(l.published) : void 0, signal: s.signal });
874
- if (!g || g.ok !== !0) throw new N("review", g?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
875
- x(s.signal);
872
+ x(l.signal);
873
+ const u = await t.beforePublish({ document: I(a), previous: s.published ? I(s.published) : void 0, signal: l.signal });
874
+ if (!u || u.ok !== !0) throw new L("review", u?.issues?.find((f) => f.severity === "error")?.message ?? "模板发布检查未通过");
875
+ x(l.signal);
876
876
  }
877
- const d = pe(l), m = D({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
878
- return c !== void 0 && (h.restoredFrom = c), i({ id: l.id, revision: d, publishedRevision: d, published: m }, s, h);
877
+ const d = pe(s), m = I({ ...a, revision: d }), h = { revision: d, document: m, publishedAt: (t.now?.() ?? /* @__PURE__ */ new Date()).toISOString() };
878
+ return c !== void 0 && (h.restoredFrom = c), i({ id: s.id, revision: d, publishedRevision: d, published: m }, l, h);
879
879
  };
880
880
  return {
881
- list: async (l) => {
882
- x(l);
883
- const a = await e.list(l);
884
- return x(l), k(a);
881
+ list: async (s) => {
882
+ x(s);
883
+ const a = await e.list(s);
884
+ return x(s), k(a);
885
885
  },
886
- get: async (l, a = {}) => {
887
- const s = await n(l, a.signal), c = a.draft ? s?.draft : s?.published;
888
- return c ? D(c) : void 0;
886
+ get: async (s, a = {}) => {
887
+ const l = await n(s, a.signal), c = a.draft ? l?.draft : l?.published;
888
+ return c ? I(c) : void 0;
889
889
  },
890
- history: async (l, a) => {
890
+ history: async (s, a) => {
891
891
  x(a);
892
- const s = await e.history(l, a);
893
- return x(a), k(s);
892
+ const l = await e.history(s, a);
893
+ return x(a), k(l);
894
894
  },
895
- saveDraft: async (l, a) => {
895
+ saveDraft: async (s, a) => {
896
896
  a = { ...a }, x(a.signal);
897
- const s = D(t.migrate ? await t.migrate(l) : l), c = await r(s.id, a), d = pe(c);
897
+ const l = I(t.migrate ? await t.migrate(s) : s), c = await r(l.id, a), d = pe(c);
898
898
  return i({
899
- id: s.id,
899
+ id: l.id,
900
900
  revision: d,
901
- draft: { ...s, revision: d },
901
+ draft: { ...l, revision: d },
902
902
  ...c?.publishedRevision ? { publishedRevision: c.publishedRevision, published: c.published } : {}
903
903
  }, a);
904
904
  },
905
- publish: async (l, a) => {
905
+ publish: async (s, a) => {
906
906
  a = { ...a };
907
- const s = await r(l, a);
908
- if (!s) throw new N("missing", "模板不存在");
909
- if (!s.draft) throw new N("draft", "没有可发布的草稿");
910
- return o(s, s.draft, a);
907
+ const l = await r(s, a);
908
+ if (!l) throw new L("missing", "模板不存在");
909
+ if (!l.draft) throw new L("draft", "没有可发布的草稿");
910
+ return o(l, l.draft, a);
911
911
  },
912
- rollback: async (l, a, s) => {
913
- s = { ...s };
914
- const c = await r(l, s);
915
- if (!c) throw new N("missing", "模板不存在");
916
- x(s.signal);
917
- const d = await e.getVersion(l, a, s.signal);
918
- if (!d) throw new N("history", "历史修订不存在");
919
- return o(c, d.document, s, a);
912
+ rollback: async (s, a, l) => {
913
+ l = { ...l };
914
+ const c = await r(s, l);
915
+ if (!c) throw new L("missing", "模板不存在");
916
+ x(l.signal);
917
+ const d = await e.getVersion(s, a, l.signal);
918
+ if (!d) throw new L("history", "历史修订不存在");
919
+ return o(c, d.document, l, a);
920
920
  }
921
921
  };
922
922
  }
923
- function Mn() {
923
+ function xn() {
924
924
  const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map();
925
925
  return {
926
926
  read: async (n, r) => {
@@ -937,46 +937,54 @@ function Mn() {
937
937
  },
938
938
  compareAndSwap: async (n, r, i, o) => {
939
939
  if (x(o.signal), (e.get(n)?.revision ?? null) !== r) return !1;
940
- if (i.id !== n) throw new N("history", "状态 ID 与存储 ID 不一致");
941
- const l = k(i), a = o.publication;
940
+ if (i.id !== n) throw new L("history", "状态 ID 与存储 ID 不一致");
941
+ const s = k(i), a = o.publication;
942
942
  if (a) {
943
- const s = t.get(n) ?? /* @__PURE__ */ new Map();
944
- if (s.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new N("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
945
- s.set(a.revision, k(a)), t.set(n, s);
943
+ const l = t.get(n) ?? /* @__PURE__ */ new Map();
944
+ if (l.has(a.revision) || a.revision !== i.revision || a.document.id !== n) throw new L("history", "发布修订不可覆盖,且必须与状态修订和模板 ID 一致");
945
+ l.set(a.revision, k(a)), t.set(n, l);
946
946
  }
947
- return e.set(n, l), !0;
947
+ return e.set(n, s), !0;
948
948
  }
949
949
  };
950
950
  }
951
- function xn(e, t) {
952
- const n = D(e);
951
+ function Rt(e, t) {
952
+ const n = e.publishedRevision ?? e.published?.revision;
953
+ for (const r of [e.draftRevision, n]) if (r !== void 0 && (typeof r != "string" || !r.trim())) throw new TypeError("模板生命周期修订应为非空字符串");
954
+ if (e.draftRevision !== void 0 && e.draftRevision !== t.revision) throw new TypeError("可编辑文档应与草稿修订一致");
955
+ if (e.published && (e.published.id !== t.id || e.published.revision !== n)) throw new TypeError("发布文档身份或修订不一致");
956
+ if (!e.published && n !== void 0 && n !== t.revision) throw new TypeError("发布修订需要对应的独立文档");
957
+ return { ...e.draftRevision === void 0 ? {} : { draftRevision: e.draftRevision }, ...n === void 0 ? {} : { publishedRevision: n } };
958
+ }
959
+ function En(e, t) {
960
+ const n = I(e);
953
961
  if (t.id === n.id) throw new Error("复制模板应使用新的 ID");
954
962
  const { revision: r, ...i } = n;
955
- return D({ ...i, id: t.id, name: t.name });
963
+ return I({ ...i, id: t.id, name: t.name });
956
964
  }
957
- function En(e) {
965
+ function Sn(e) {
958
966
  if (!Array.isArray(e) || e.length > 1e3) throw new RangeError("本地模板目录最多 1000 项");
959
- const t = /* @__PURE__ */ new Map(), n = [];
960
- for (const r of e) {
961
- const i = D(r.document);
962
- if (t.has(i.id)) throw new Error(`模板 ID 重复:${i.id}`);
963
- if (r.category !== void 0 && (typeof r.category != "string" || r.category.length > 128) || r.tags !== void 0 && (!Array.isArray(r.tags) || r.tags.length > 20 || r.tags.some((a) => typeof a != "string" || a.length > 128))) throw new TypeError("模板分类和标签无效");
964
- const { template: o, ...l } = i;
965
- t.set(i.id, i), n.push({ ...l, ...r.category ? { category: r.category } : {}, ...r.tags ? { tags: [...r.tags] } : {} });
967
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = [];
968
+ for (const i of e) {
969
+ const o = I(i.document);
970
+ if (t.has(o.id)) throw new Error(`模板 ID 重复:${o.id}`);
971
+ if (i.category !== void 0 && (typeof i.category != "string" || i.category.length > 128) || i.tags !== void 0 && (!Array.isArray(i.tags) || i.tags.length > 20 || i.tags.some((c) => typeof c != "string" || c.length > 128))) throw new TypeError("模板分类和标签无效");
972
+ const s = Rt(i, o), { template: a, ...l } = o;
973
+ t.set(o.id, o), i.published ? n.set(o.id, I(i.published)) : s.publishedRevision && n.set(o.id, I(o)), r.push({ ...l, ...s, ...i.category ? { category: i.category } : {}, ...i.tags ? { tags: [...i.tags] } : {} });
966
974
  }
967
- return n.sort((r, i) => r.id < i.id ? -1 : 1), {
968
- search: async (r) => {
969
- we(r.signal);
970
- const i = r.limit ?? 30;
971
- if (!Number.isSafeInteger(i) || i < 1 || i > 100) throw new RangeError("模板每页数量应为 1–100");
972
- const o = r.query?.trim().toLocaleLowerCase() ?? "", l = n.filter((s) => (!r.category || s.category === r.category) && (!r.cursor || s.id > r.cursor) && (!o || [s.id, s.name, s.description, ...s.tags ?? []].some((c) => c?.toLocaleLowerCase().includes(o)))), a = /* @__PURE__ */ new Map();
973
- for (const s of n) s.category && a.set(s.category, (a.get(s.category) ?? 0) + 1);
974
- return JSON.parse(JSON.stringify({ items: l.slice(0, i), ...l.length > i ? { next: l[i - 1].id } : {}, categories: Array.from(a, ([s, c]) => ({ id: s, label: s, count: c })) }));
975
- },
976
- get: async (r, i) => {
975
+ return r.sort((i, o) => i.id < o.id ? -1 : 1), {
976
+ search: async (i) => {
977
977
  we(i.signal);
978
- const o = t.get(r);
979
- return o ? D(o) : void 0;
978
+ const o = i.limit ?? 30;
979
+ if (!Number.isSafeInteger(o) || o < 1 || o > 100) throw new RangeError("模板每页数量应为 1–100");
980
+ const s = i.query?.trim().toLocaleLowerCase() ?? "", a = r.filter((c) => (!i.category || c.category === i.category) && (!i.cursor || c.id > i.cursor) && (!s || [c.id, c.name, c.description, ...c.tags ?? []].some((d) => d?.toLocaleLowerCase().includes(s)))), l = /* @__PURE__ */ new Map();
981
+ for (const c of r) c.category && l.set(c.category, (l.get(c.category) ?? 0) + 1);
982
+ return JSON.parse(JSON.stringify({ items: a.slice(0, o), ...a.length > o ? { next: a[o - 1].id } : {}, categories: Array.from(l, ([c, d]) => ({ id: c, label: c, count: d })) }));
983
+ },
984
+ get: async (i, o) => {
985
+ we(o.signal);
986
+ const s = o.mode === "published" ? n.get(i) : t.get(i);
987
+ return s ? I(s) : void 0;
980
988
  }
981
989
  };
982
990
  }
@@ -985,31 +993,31 @@ function we(e) {
985
993
  const t = new Error("模板目录操作已取消");
986
994
  throw t.name = "AbortError", t;
987
995
  }
988
- function Sn(e) {
996
+ function Tn(e) {
989
997
  return e.map((t) => t.map((n) => /[\t\r\n"]/.test(n) ? `"${n.replace(/"/g, '""')}"` : n).join(" ")).join(`\r
990
998
  `);
991
999
  }
992
- function Rt(e, t) {
1000
+ function Pt(e, t) {
993
1001
  const n = e[e.length - 1];
994
1002
  e.length > 1 && n?.length === 1 && n[0] === "" && /[\r\n]$/.test(t) && e.pop();
995
1003
  }
996
- function Tn(e, t = 1e4) {
1004
+ function Cn(e, t = 1e4) {
997
1005
  if (e.length > 4 * 1024 * 1024) throw new Error("Clipboard text limit exceeded");
998
1006
  const n = [[]];
999
- let r = "", i = !1, o = !1, l = 0;
1007
+ let r = "", i = !1, o = !1, s = 0;
1000
1008
  function a() {
1001
- if (++l > t) throw new Error("Clipboard cell limit exceeded");
1009
+ if (++s > t) throw new Error("Clipboard cell limit exceeded");
1002
1010
  n[n.length - 1].push(r), r = "", o = !1;
1003
1011
  }
1004
- for (let s = 0; s < e.length; s++) {
1005
- const c = e[s];
1012
+ for (let l = 0; l < e.length; l++) {
1013
+ const c = e[l];
1006
1014
  if (i) {
1007
1015
  if (c !== '"') {
1008
1016
  r += c;
1009
1017
  continue;
1010
1018
  }
1011
- if (e[s + 1] === '"') {
1012
- r += '"', s++;
1019
+ if (e[l + 1] === '"') {
1020
+ r += '"', l++;
1013
1021
  continue;
1014
1022
  }
1015
1023
  i = !1, o = !0;
@@ -1025,17 +1033,17 @@ function Tn(e, t = 1e4) {
1025
1033
  }
1026
1034
  if (c === "\r" || c === `
1027
1035
  `) {
1028
- a(), n.push([]), c === "\r" && e[s + 1] === `
1029
- ` && s++;
1036
+ a(), n.push([]), c === "\r" && e[l + 1] === `
1037
+ ` && l++;
1030
1038
  continue;
1031
1039
  }
1032
1040
  if (o) throw new Error("Invalid quoted clipboard value");
1033
1041
  r += c;
1034
1042
  }
1035
1043
  if (i) throw new Error("Unclosed clipboard quote");
1036
- return a(), Rt(n, e), n;
1044
+ return a(), Pt(n, e), n;
1037
1045
  }
1038
- class Pt extends Error {
1046
+ class At extends Error {
1039
1047
  constructor(t, n, r) {
1040
1048
  const i = typeof n.label == "string" ? n.label : "单元格", o = {
1041
1049
  definition: `${i}的编辑器配置无效`,
@@ -1052,46 +1060,46 @@ class Pt extends Error {
1052
1060
  }
1053
1061
  }
1054
1062
  function p(e, t, n) {
1055
- throw new Pt(t, e, n);
1063
+ throw new At(t, e, n);
1056
1064
  }
1057
1065
  function Oe(e) {
1058
1066
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}$/.test(e) || e.startsWith("0000-")) return !1;
1059
1067
  const t = /* @__PURE__ */ new Date(`${e}T00:00:00.000Z`);
1060
1068
  return Number.isFinite(t.getTime()) && t.toISOString().slice(0, 10) === e;
1061
1069
  }
1062
- function At(e) {
1070
+ function kt(e) {
1063
1071
  const [t = "", n = "0"] = String(e).toLowerCase().split("e");
1064
1072
  return Math.max(0, (t.split(".")[1]?.length ?? 0) - Number(n));
1065
1073
  }
1066
- function kt(e, t) {
1067
- e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && At(t) > e.precision && p(e, "precision", e.precision);
1068
- }
1069
1074
  function It(e, t) {
1075
+ e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max), e.precision !== void 0 && kt(t) > e.precision && p(e, "precision", e.precision);
1076
+ }
1077
+ function $t(e, t) {
1070
1078
  Oe(t) || p(e, "date"), e.min !== void 0 && t < e.min && p(e, "min", e.min), e.max !== void 0 && t > e.max && p(e, "max", e.max);
1071
1079
  }
1072
- function $t(e) {
1080
+ function Nt(e) {
1073
1081
  [e.min, e.max].some((t) => t !== void 0 && !Number.isFinite(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition"), e.precision !== void 0 && (!Number.isInteger(e.precision) || e.precision < 0 || e.precision > 15) && p(e, "definition");
1074
1082
  }
1075
- function Nt(e) {
1083
+ function Lt(e) {
1076
1084
  [e.min, e.max].some((t) => t !== void 0 && !Oe(t)) && p(e, "definition"), e.min !== void 0 && e.max !== void 0 && e.min > e.max && p(e, "definition");
1077
1085
  }
1078
- function Lt(e, t) {
1086
+ function Dt(e, t) {
1079
1087
  (!Array.isArray(t.options) || !t.options.length) && p(t, "definition");
1080
1088
  const n = e.valueType === "text" ? "string" : e.valueType, r = /* @__PURE__ */ new Set();
1081
1089
  for (const i of t.options)
1082
1090
  (!i || typeof i.value !== n || typeof i.value == "number" && !Number.isFinite(i.value)) && p(t, "definition"), i.label !== void 0 && typeof i.label != "string" && p(t, "definition"), r.has(i.value) && p(t, "definition"), r.add(i.value);
1083
1091
  }
1084
- function Dt(e) {
1092
+ function Ft(e) {
1085
1093
  e.required !== void 0 && typeof e.required != "boolean" && p(e, "definition"), [e.label, e.hint, e.unit].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition"), e.type === "boolean" && [e.trueLabel, e.falseLabel].some((t) => t !== void 0 && typeof t != "string") && p(e, "definition");
1086
1094
  }
1087
- function Ft(e, t) {
1088
- (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Dt(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && $t(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Nt(t), t.type === "enum" && Lt(e, t);
1095
+ function Ot(e, t) {
1096
+ (!t || typeof t != "object" || Array.isArray(t) || !["text", "number", "boolean", "enum", "date"].includes(t.type)) && p(t ?? { type: "text" }, "definition"), Ft(t), (t.type === "number" || t.type === "boolean") && e.valueType !== t.type && p(t, "type"), (t.type === "text" || t.type === "date") && e.valueType !== "text" && p(t, "type"), t.type === "number" && Nt(t), t.type === "text" && t.maxLength !== void 0 && (!Number.isInteger(t.maxLength) || t.maxLength < 0) && p(t, "definition"), t.type === "date" && Lt(t), t.type === "enum" && Dt(e, t);
1089
1097
  }
1090
- function Cn(e, t, n) {
1098
+ function Rn(e, t, n) {
1091
1099
  if (!e.editable) throw new Be("readonly");
1092
- n && Ft(e, n);
1100
+ n && Ot(e, n);
1093
1101
  const r = Ge(e, t);
1094
- return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && kt(n, r), n.type === "date" && It(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
1102
+ return n ? (n.required && typeof r == "string" && !r.trim() && p(n, "required"), r === null || r === "" ? (n.required && p(n, "required"), r) : (n.type === "number" && It(n, r), n.type === "date" && $t(n, r), n.type === "text" && n.maxLength !== void 0 && [...String(r)].length > n.maxLength && p(n, "length", n.maxLength), n.type === "enum" && !n.options.some((i) => Object.is(i.value, r)) && p(n, "choice"), r)) : r;
1095
1103
  }
1096
1104
  class w extends Error {
1097
1105
  constructor(t) {
@@ -1115,86 +1123,86 @@ function be(e, t, n) {
1115
1123
  if (![t.pageIndex, t.componentIndex, t.rowIndex, t.columnIndex].every((a) => Number.isSafeInteger(a) && a >= 0)) throw new w("selection");
1116
1124
  const r = e.pages[t.pageIndex]?.components[t.componentIndex];
1117
1125
  if (!r?.grid || t.rowIndex >= r.grid.cells.length) throw new w("selection");
1118
- const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, s) => Math.max(a, s.length), 1);
1126
+ const i = r.grid.colWidthsMm?.length ?? r.grid.cells.reduce((a, l) => Math.max(a, l.length), 1);
1119
1127
  if (t.columnIndex >= i) throw new w("selection");
1120
- const o = r.table, l = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
1121
- if (o && l && o.id === l.id) {
1122
- const a = l.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1128
+ const o = r.table, s = e.pages[n.pageIndex]?.components[n.componentIndex]?.table;
1129
+ if (o && s && o.id === s.id) {
1130
+ const a = s.columnKeys.indexOf(o.columnKeys[t.columnIndex] ?? "");
1123
1131
  if (a < 0) throw new w("selection");
1124
1132
  return { grid: o.id, row: de(r) + t.rowIndex, column: a };
1125
1133
  }
1126
1134
  return { grid: `${t.pageIndex}:${t.componentIndex}`, row: t.rowIndex, column: t.columnIndex };
1127
1135
  }
1128
- function Ot(e, t, n) {
1136
+ function zt(e, t, n) {
1129
1137
  const r = be(e, t.anchor, t.anchor), i = be(e, t.focus, t.anchor);
1130
1138
  if (r.grid !== i.grid) throw new w("selection");
1131
1139
  const o = (Math.abs(r.row - i.row) + 1) * (Math.abs(r.column - i.column) + 1);
1132
1140
  if (!Number.isSafeInteger(o) || o > n) throw new w("limit");
1133
1141
  return { grid: r.grid, rowStart: Math.min(r.row, i.row), rowEnd: Math.max(r.row, i.row), columnStart: Math.min(r.column, i.column), columnEnd: Math.max(r.column, i.column), origin: e.pages[t.anchor.pageIndex].components[t.anchor.componentIndex].table };
1134
1142
  }
1135
- function zt(e) {
1143
+ function Ht(e) {
1136
1144
  if (!e) return !1;
1137
1145
  const t = e.replace(/"[^"]*"|\\.|\[(?![hms]+\])[^\]]*\]/gi, "");
1138
1146
  return /[ymdhs]/i.test(t);
1139
1147
  }
1140
- function Ht(e) {
1141
- if (e.valueType === "text" || e.valueType === "boolean" || zt(e.numberFormat)) return null;
1148
+ function Wt(e) {
1149
+ if (e.valueType === "text" || e.valueType === "boolean" || Ht(e.numberFormat)) return null;
1142
1150
  const t = e.value;
1143
1151
  if (typeof t != "number" || !Number.isFinite(t)) return null;
1144
1152
  if (Number.isInteger(t) && !Number.isSafeInteger(t)) throw new w("precision");
1145
1153
  return t;
1146
1154
  }
1147
- function Wt(e, t, n) {
1155
+ function _t(e, t, n) {
1148
1156
  if (e.seen.has(n)) return;
1149
1157
  e.seen.add(n), e.selected++;
1150
- const r = t ? Ht(t) : null;
1158
+ const r = t ? Wt(t) : null;
1151
1159
  r === null ? e.excluded++ : e.values.push(r);
1152
1160
  }
1153
- function _t(e, t, n, r) {
1161
+ function jt(e, t, n, r) {
1154
1162
  return r.origin ? e.table?.id === r.origin.id : `${t}:${n}` === r.grid;
1155
1163
  }
1156
- function jt(e, t, n) {
1164
+ function Bt(e, t, n) {
1157
1165
  return n.origin ? n.origin.columnKeys.indexOf(e.table.columnKeys[t] ?? "") : t;
1158
1166
  }
1159
- function Bt(e, t, n, r) {
1160
- const i = r.origin ? de(e) + t : t, o = jt(e, n, r);
1167
+ function Gt(e, t, n, r) {
1168
+ const i = r.origin ? de(e) + t : t, o = Bt(e, n, r);
1161
1169
  return i < r.rowStart || i > r.rowEnd || o < r.columnStart || o > r.columnEnd ? null : `${r.grid}:${i}:${o}`;
1162
1170
  }
1163
- function Gt(e, t) {
1171
+ function Ut(e, t) {
1164
1172
  const n = t.origin ? de(e) : 0, r = Math.max(0, t.rowStart - n), i = Math.min(e.grid.cells.length, t.rowEnd - n + 1);
1165
1173
  return i > r ? i : 0;
1166
1174
  }
1167
- async function Ut(e, t, n, r, i) {
1175
+ async function Vt(e, t, n, r, i) {
1168
1176
  const o = e.grid;
1169
1177
  if (t > r.maxScanned) throw new w("limit");
1170
- const l = o.colWidthsMm?.length ?? o.cells.reduce((s, c) => Math.max(s, c.length), 1);
1171
- if (l > r.maxScanned) throw new w("limit");
1178
+ const s = o.colWidthsMm?.length ?? o.cells.reduce((l, c) => Math.max(l, c.length), 1);
1179
+ if (s > r.maxScanned) throw new w("limit");
1172
1180
  const a = /* @__PURE__ */ new Map();
1173
- for (let s = 0; s < t; s++) {
1174
- s > 0 && s % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
1181
+ for (let l = 0; l < t; l++) {
1182
+ l > 0 && l % 2048 === 0 && (await r.yieldToHost(), z(r.signal));
1175
1183
  let c = 0;
1176
- for (const d of o.cells[s]) {
1177
- for (await J(r); c < l && (a.get(c) ?? 0) > s; ) c++;
1178
- if (c >= l) break;
1179
- const m = Math.max(1, Math.min(d?.colSpan ?? 1, l - c)), h = Math.min(o.cells.length, s + Math.max(1, d?.rowSpan ?? 1));
1184
+ for (const d of o.cells[l]) {
1185
+ for (await J(r); c < s && (a.get(c) ?? 0) > l; ) c++;
1186
+ if (c >= s) break;
1187
+ const m = Math.max(1, Math.min(d?.colSpan ?? 1, s - c)), h = Math.min(o.cells.length, l + Math.max(1, d?.rowSpan ?? 1));
1180
1188
  m > 1 && await J(r, m - 1);
1181
1189
  for (let f = c; f < c + m; f++) a.set(f, h);
1182
- const g = Bt(e, s, c, n);
1183
- g && Wt(i, d, g), c += m;
1190
+ const u = Gt(e, l, c, n);
1191
+ u && _t(i, d, u), c += m;
1184
1192
  }
1185
1193
  }
1186
1194
  }
1187
- async function Vt(e, t, n) {
1195
+ async function qt(e, t, n) {
1188
1196
  const r = { values: [], seen: /* @__PURE__ */ new Set(), excluded: 0, selected: 0 };
1189
1197
  for (let i = 0; i < e.pages.length; i++) {
1190
1198
  await J(n);
1191
1199
  const o = e.pages[i];
1192
- for (let l = 0; l < o.components.length; l++) {
1200
+ for (let s = 0; s < o.components.length; s++) {
1193
1201
  await J(n);
1194
- const a = o.components[l];
1195
- if (!a.grid || !_t(a, i, l, t) || a.table && a.table.role !== "body") continue;
1196
- const s = Gt(a, t);
1197
- s && await Ut(a, s, t, n, r);
1202
+ const a = o.components[s];
1203
+ if (!a.grid || !jt(a, i, s, t) || a.table && a.table.role !== "body") continue;
1204
+ const l = Ut(a, t);
1205
+ l && await Vt(a, l, t, n, r);
1198
1206
  }
1199
1207
  }
1200
1208
  return r;
@@ -1203,7 +1211,7 @@ function B(e) {
1203
1211
  if (!Number.isFinite(e)) throw new w("overflow");
1204
1212
  return e;
1205
1213
  }
1206
- function qt(e) {
1214
+ function Yt(e) {
1207
1215
  let t = 0, n = 0;
1208
1216
  for (const r of e) {
1209
1217
  const i = r - n, o = B(t + i);
@@ -1211,209 +1219,209 @@ function qt(e) {
1211
1219
  }
1212
1220
  return t;
1213
1221
  }
1214
- async function ye(e, t) {
1222
+ async function ve(e, t) {
1215
1223
  let n = [...e], r = new Array(e.length);
1216
1224
  for (let o = 1; o < e.length; o *= 2) {
1217
- for (let l = 0; l < e.length; l += o * 2) {
1218
- const a = Math.min(l + o, e.length), s = Math.min(l + o * 2, e.length);
1219
- let c = l, d = a;
1220
- for (let m = l; m < s; m++)
1221
- r[m] = d >= s || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
1225
+ for (let s = 0; s < e.length; s += o * 2) {
1226
+ const a = Math.min(s + o, e.length), l = Math.min(s + o * 2, e.length);
1227
+ let c = s, d = a;
1228
+ for (let m = s; m < l; m++)
1229
+ r[m] = d >= l || c < a && n[c] <= n[d] ? n[c++] : n[d++], m % 2048 === 0 && (await t.yieldToHost(), z(t.signal));
1222
1230
  }
1223
1231
  [n, r] = [r, n];
1224
1232
  }
1225
1233
  const i = Math.floor(n.length / 2);
1226
1234
  return n.length % 2 ? n[i] : B(n[i - 1] / 2 + n[i] / 2);
1227
1235
  }
1228
- function Yt(e) {
1229
- const t = qt(e);
1236
+ function Kt(e) {
1237
+ const t = Yt(e);
1230
1238
  let n = 1 / 0, r = -1 / 0;
1231
1239
  for (const i of e)
1232
1240
  n = Math.min(n, i), r = Math.max(r, i);
1233
1241
  return { SUM: t, AVERAGE: t / e.length, AVG: t / e.length, MIN: n, MAX: r, COUNT: e.length };
1234
1242
  }
1235
- function Kt(e, t) {
1243
+ function Xt(e, t) {
1236
1244
  if (typeof e != "string" || e.length > 256) throw new w("expression");
1237
1245
  const n = e.toUpperCase().match(/(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?|[A-Z_]+|[()+\-*/]|\S/g) ?? [];
1238
1246
  if (!n.length || n.length > 64) throw new w("expression");
1239
1247
  let r = 0;
1240
1248
  function i(a) {
1241
1249
  if (a > 16) throw new w("expression");
1242
- const s = n[r++];
1243
- if (s === "+" || s === "-") return (s === "-" ? -1 : 1) * i(a + 1);
1244
- if (s === "(") {
1250
+ const l = n[r++];
1251
+ if (l === "+" || l === "-") return (l === "-" ? -1 : 1) * i(a + 1);
1252
+ if (l === "(") {
1245
1253
  const c = o(0, a + 1);
1246
1254
  if (n[r++] !== ")") throw new w("expression");
1247
1255
  return c;
1248
1256
  }
1249
- if (s && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(s) && Object.prototype.hasOwnProperty.call(t, s)) return B(t[s]);
1250
- if (s && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(s)) return B(Number(s));
1257
+ if (l && /^(?:SUM|AVERAGE|AVG|MIN|MAX|COUNT|MEDIAN)$/.test(l) && Object.prototype.hasOwnProperty.call(t, l)) return B(t[l]);
1258
+ if (l && /^(?:\d+(?:\.\d*)?|\.\d+)(?:E[+-]?\d+)?$/.test(l)) return B(Number(l));
1251
1259
  throw new w("expression");
1252
1260
  }
1253
- function o(a, s) {
1254
- let c = i(s);
1261
+ function o(a, l) {
1262
+ let c = i(l);
1255
1263
  for (; r < n.length; ) {
1256
1264
  const d = n[r], m = d === "+" || d === "-" ? 1 : d === "*" || d === "/" ? 2 : 0;
1257
1265
  if (!m || m < a) break;
1258
1266
  r++;
1259
- const h = o(m + 1, s + 1);
1267
+ const h = o(m + 1, l + 1);
1260
1268
  if (d === "/" && h === 0) throw new w("division");
1261
1269
  c = B(d === "+" ? c + h : d === "-" ? c - h : d === "*" ? c * h : c / h);
1262
1270
  }
1263
1271
  return c;
1264
1272
  }
1265
- const l = o(1, 0);
1273
+ const s = o(1, 0);
1266
1274
  if (r !== n.length) throw new w("expression");
1267
- return l;
1275
+ return s;
1268
1276
  }
1269
- function Xt(e) {
1277
+ function Jt(e) {
1270
1278
  const t = e.maxCells ?? 1e5, n = e.maxScannedCells ?? 2e5, r = e.precision ?? 2;
1271
1279
  if (![t, n].every((i) => Number.isSafeInteger(i) && i >= 1 && i <= 2e6)) throw new w("limit");
1272
1280
  if (!Number.isInteger(r) || r < 0 || r > 12) throw new w("precision");
1273
1281
  return { maxCells: t, maxScanned: n, precision: r };
1274
1282
  }
1275
- async function Rn(e, t, n = {}) {
1276
- const r = Xt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((s) => setTimeout(s, 0))) };
1283
+ async function Pn(e, t, n = {}) {
1284
+ const r = Jt(n), i = { scanned: 0, maxScanned: r.maxScanned, signal: n.signal, yieldToHost: n.yieldToHost ?? (() => new Promise((l) => setTimeout(l, 0))) };
1277
1285
  z(i.signal);
1278
- const o = await Vt(e, Ot(e, t, r.maxCells), i), l = n.operation ?? "sum";
1279
- if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(l)) throw new w("expression");
1286
+ const o = await qt(e, zt(e, t, r.maxCells), i), s = n.operation ?? "sum";
1287
+ if (!["sum", "average", "min", "max", "count", "median", "expression"].includes(s)) throw new w("expression");
1280
1288
  let a = null;
1281
- if (l === "count") a = o.values.length;
1289
+ if (s === "count") a = o.values.length;
1282
1290
  else if (o.values.length)
1283
- if (l === "median") a = await ye(o.values, i);
1291
+ if (s === "median") a = await ve(o.values, i);
1284
1292
  else {
1285
- const s = Yt(o.values);
1286
- l === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (s.MEDIAN = await ye(o.values, i)), a = Kt(n.expression ?? "", s)) : a = s[l.toUpperCase()];
1293
+ const l = Kt(o.values);
1294
+ s === "expression" ? (/\bMEDIAN\b/i.test(n.expression ?? "") && (l.MEDIAN = await ve(o.values, i)), a = Xt(n.expression ?? "", l)) : a = l[s.toUpperCase()];
1287
1295
  }
1288
1296
  if (z(i.signal), a !== null && Number.isInteger(a) && !Number.isSafeInteger(a)) throw new w("precision");
1289
1297
  return { value: a, formatted: a === null ? "—" : a.toFixed(r.precision), numericCells: o.values.length, excludedCells: o.excluded, selectedCells: o.selected, precision: r.precision };
1290
1298
  }
1291
1299
  export {
1292
- jn as CSS_DPI,
1293
- kn as DEFAULT_BORDER_PT,
1300
+ Bn as CSS_DPI,
1301
+ In as DEFAULT_BORDER_PT,
1294
1302
  Z as DEFAULT_FONT_FAMILY,
1295
- In as DEFAULT_FONT_PT,
1296
- $n as DEFAULT_STROKE_COLOR,
1297
- ve as DEFAULT_TEXT_COLOR,
1298
- Nn as LINE_HEIGHT,
1299
- Bn as MM_PER_INCH,
1300
- Lr as OutputAssetError,
1303
+ $n as DEFAULT_FONT_PT,
1304
+ Nn as DEFAULT_STROKE_COLOR,
1305
+ ye as DEFAULT_TEXT_COLOR,
1306
+ Ln as LINE_HEIGHT,
1307
+ Gn as MM_PER_INCH,
1308
+ Dr as OutputAssetError,
1301
1309
  Ue as OutputFidelityError,
1302
1310
  K as PAPER_SIZES,
1303
- yt as PageBuilder,
1304
- sr as PaginateCellLimitError,
1305
- lr as PaginatePageLimitError,
1306
- qn as RENDER_PLAN_SCHEMA_VERSION,
1307
- zr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1311
+ vt as PageBuilder,
1312
+ lr as PaginateCellLimitError,
1313
+ cr as PaginatePageLimitError,
1314
+ Yn as RENDER_PLAN_SCHEMA_VERSION,
1315
+ Hr as REPORT_TEMPLATE_DOCUMENT_VERSION,
1308
1316
  w as ReportCalculationError,
1309
1317
  Be as ReportCellEditError,
1310
- Pt as ReportCellFieldError,
1311
- Vr as ReportParamValidationError,
1312
- cr as ReportSourceError,
1313
- Hr as ReportTemplateError,
1314
- N as ReportTemplateStoreError,
1315
- Ln as SCHEMA_VERSION_MACH,
1318
+ At as ReportCellFieldError,
1319
+ qr as ReportParamValidationError,
1320
+ dr as ReportSourceError,
1321
+ Wr as ReportTemplateError,
1322
+ L as ReportTemplateStoreError,
1323
+ Dn as SCHEMA_VERSION_MACH,
1316
1324
  bt as TemplateBuilder,
1317
- ri as TreeRowLimitError,
1318
- dr as applyReportCellEdit,
1319
- mr as applyReportCellEditBatch,
1320
- hr as applyReportEditResult,
1321
- Kn as assertRenderPlan,
1322
- qr as assertReportParams,
1323
- Rn as calculateReportSelection,
1324
- nr as charWidthEm,
1325
+ ii as TreeRowLimitError,
1326
+ mr as applyReportCellEdit,
1327
+ hr as applyReportCellEditBatch,
1328
+ ur as applyReportEditResult,
1329
+ Xn as assertRenderPlan,
1330
+ Yr as assertReportParams,
1331
+ Pn as calculateReportSelection,
1332
+ rr as charWidthEm,
1325
1333
  E as classOf,
1326
- xn as cloneReportTemplate,
1327
- wn as columnsFromContract,
1334
+ En as cloneReportTemplate,
1335
+ bn as columnsFromContract,
1328
1336
  dt as computePageWindow,
1329
1337
  gr as countTemplatePages,
1330
- rr as createCanvasMeasurer,
1331
- fn as createCanvasPager,
1332
- ir as createHeuristicMeasurer,
1333
- En as createLocalTemplateCatalog,
1334
- Mn as createMemoryTemplateStore,
1338
+ ir as createCanvasMeasurer,
1339
+ pn as createCanvasPager,
1340
+ or as createHeuristicMeasurer,
1341
+ Sn as createLocalTemplateCatalog,
1342
+ xn as createMemoryTemplateStore,
1335
1343
  yn as createProviderReport,
1336
- ur as createReportCellEdit,
1337
- fr as createReportCellEditBatch,
1338
- pr as createReportCellResolver,
1339
- wr as createReportEditSession,
1340
- br as createReportSource,
1341
- bn as createTableTemplate,
1342
- pn as createTemplate,
1343
- vn as createTemplateManager,
1344
- Wr as createTemplateRegistry,
1345
- ii as createTreeTable,
1346
- er as datasetJsonSchema,
1344
+ fr as createReportCellEdit,
1345
+ pr as createReportCellEditBatch,
1346
+ wr as createReportCellResolver,
1347
+ br as createReportEditSession,
1348
+ vr as createReportSource,
1349
+ vn as createTableTemplate,
1350
+ wn as createTemplate,
1351
+ Mn as createTemplateManager,
1352
+ _r as createTemplateRegistry,
1353
+ oi as createTreeTable,
1354
+ tr as datasetJsonSchema,
1347
1355
  yr as defineReport,
1348
- _r as defineReportTemplate,
1349
- vr as diffReportTemplates,
1350
- Mr as estimateListLayoutCells,
1351
- Fn as evalStyleRule,
1352
- Kt as evaluateReportAggregateExpression,
1353
- xr as formatReportCellEdit,
1354
- Sn as formatReportClipboard,
1355
- Yr as formatReportDateRange,
1356
- On as formatValue,
1357
- Er as getReportCellContext,
1358
- Sr as getReportEditSession,
1359
- ae as heuristicMeasurer,
1360
- Fr as inspectOutputCapabilities,
1356
+ jr as defineReportTemplate,
1357
+ Mr as diffReportTemplates,
1358
+ xr as estimateListLayoutCells,
1359
+ On as evalStyleRule,
1360
+ Xt as evaluateReportAggregateExpression,
1361
+ Er as formatReportCellEdit,
1362
+ Tn as formatReportClipboard,
1363
+ Kr as formatReportDateRange,
1364
+ zn as formatValue,
1365
+ Sr as getReportCellContext,
1366
+ Tr as getReportEditSession,
1367
+ oe as heuristicMeasurer,
1368
+ Or as inspectOutputCapabilities,
1361
1369
  ee as isImageBackedComponent,
1362
- Kr as isReportDate,
1363
- Xr as isReportMonth,
1364
- Jr as isReportYear,
1370
+ Xr as isReportDate,
1371
+ Jr as isReportMonth,
1372
+ Zr as isReportYear,
1365
1373
  Se as isRichText,
1366
1374
  le as measurePageSizePx,
1367
1375
  ar as measureTextMm,
1368
1376
  xe as mergeComponentStyles,
1369
1377
  ie as mmToPx,
1370
- Gn as mmToPxFactor,
1371
- Tr as paginateTemplate,
1372
- Cr as paginateTemplatePages,
1373
- zn as parseDateLocal,
1374
- Cn as parseReportCellFieldInput,
1378
+ Un as mmToPxFactor,
1379
+ Cr as paginateTemplate,
1380
+ Rr as paginateTemplatePages,
1381
+ Hn as parseDateLocal,
1382
+ Rn as parseReportCellFieldInput,
1375
1383
  Ge as parseReportCellInput,
1376
- Tn as parseReportClipboard,
1377
- Zr as parseReportDateRange,
1378
- D as parseReportTemplate,
1379
- mn as planFontSizePx,
1380
- Rr as projectListColumns,
1384
+ Cn as parseReportClipboard,
1385
+ Qr as parseReportDateRange,
1386
+ I as parseReportTemplate,
1387
+ hn as planFontSizePx,
1388
+ Pr as projectListColumns,
1381
1389
  O as ptToPx,
1382
- Un as pxToMm,
1383
- Pr as registerReportEditSession,
1384
- Ar as relocateReportCellEdits,
1390
+ Vn as pxToMm,
1391
+ Ar as registerReportEditSession,
1392
+ kr as relocateReportCellEdits,
1385
1393
  ke as renderComponent,
1386
- at as renderPage,
1387
- dn as renderPlan,
1394
+ ot as renderPage,
1395
+ mn as renderPlan,
1388
1396
  gn as renderPlanToCanvas,
1389
- un as renderPlanToCanvasAsync,
1390
- hn as renderPlanToImages,
1391
- kr as reportCellEditKey,
1397
+ fn as renderPlanToCanvasAsync,
1398
+ un as renderPlanToImages,
1399
+ Ir as reportCellEditKey,
1392
1400
  G as reportOutputDiagnostics,
1393
- Qr as reportParamsJsonSchema,
1401
+ ei as reportParamsJsonSchema,
1394
1402
  Me as resolveBoxBorders,
1395
1403
  W as resolveFontSize,
1396
1404
  Ce as resolveGridLayout,
1397
1405
  Q as resolveLineHeight,
1398
1406
  Fe as resolvePaper,
1399
- oe as resolvePlanAssets,
1407
+ ae as resolvePlanAssets,
1400
1408
  j as resolveStroke,
1401
1409
  Ee as resolveTextColor,
1402
- Ir as reviewReportTemplate,
1410
+ $r as reviewReportTemplate,
1403
1411
  H as round,
1404
- jr as serializeReportTemplate,
1405
- $r as summarizeReportCellEdits,
1406
- Hn as toExcelNumberFormat,
1407
- Wn as toNumber,
1408
- Xn as validateComponent,
1412
+ Br as serializeReportTemplate,
1413
+ Nr as summarizeReportCellEdits,
1414
+ Wn as toExcelNumberFormat,
1415
+ _n as toNumber,
1416
+ Jn as validateComponent,
1409
1417
  je as validateDatasetRows,
1410
- Jn as validatePage,
1411
- Zn as validateRenderPlan,
1412
- Ft as validateReportCellFieldDefinition,
1413
- ei as validateReportParamDefinitions,
1414
- ti as validateReportParams,
1415
- Br as validateReportTemplate,
1416
- Gr as validateReportTemplateDocument,
1418
+ Zn as validatePage,
1419
+ Qn as validateRenderPlan,
1420
+ Ot as validateReportCellFieldDefinition,
1421
+ ti as validateReportParamDefinitions,
1422
+ ni as validateReportParams,
1423
+ Gr as validateReportTemplate,
1424
+ Ur as validateReportTemplateDocument,
1417
1425
  ai as validateTreeOptions,
1418
1426
  Te as wrapText
1419
1427
  };