@silurus/ooxml 0.86.1 → 0.88.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -2
- package/dist/assets/render-worker-1uPAxMZr.js +31 -0
- package/dist/assets/render-worker-BlvJybji.js +10 -0
- package/dist/assets/render-worker-CzmiJfFL.js +11 -0
- package/dist/{canvas-viewer-mechanics-DN5SqWGS.js → canvas-viewer-mechanics-DbLz0rYW.js} +75 -66
- package/dist/chart-ex.mjs +581 -616
- package/dist/cjk-fallback-bLI3z70h.js +46 -0
- package/dist/comment-ui-runtime-BsK8pmUT.js +2 -0
- package/dist/{comment-ui-runtime-lXwVOgjW.js → comment-ui-runtime-CWGqn5Vr.js} +5 -5
- package/dist/{comment-ui-runtime-DEtgcmj7.js → comment-ui-runtime-DcJOYlw-.js} +5 -5
- package/dist/{comments-CAn2A_Xh.js → comments-Diid5ujN.js} +1 -1
- package/dist/{document-pull-client-uopDjRde.js → document-pull-client-B9PTM-pL.js} +4693 -4621
- package/dist/{docx-wPzeF76A.js → docx-BF9WXrYH.js} +503 -388
- package/dist/docx.mjs +6 -6
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-CswB9Tzi.js → dom-interaction-boundary-Cnm8DSBN.js} +22 -19
- package/dist/{hyperlink-BR1NCO7S.js → hyperlink-Cxzhet30.js} +842 -829
- package/dist/index.mjs +3 -3
- package/dist/{line-distribute-IsUGfHXm.js → line-distribute-D1WNHKz_.js} +2 -2
- package/dist/math.mjs +2 -2
- package/dist/node.mjs +356 -352
- package/dist/plot-area-frame-DLTYKHNP.js +4354 -0
- package/dist/{pptx-BxJ_RBSY.js → pptx-DkyYBYoL.js} +444 -435
- package/dist/pptx.mjs +7 -7
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +5 -5
- package/dist/{render-DEiun_AH.js → render-D3iqVKCo.js} +31 -29
- package/dist/{render-worker-host-Ba6Fchqr.js → render-worker-host-B5wQfB7U.js} +1 -1
- package/dist/{render-worker-host-BEfLZvSL.js → render-worker-host-D4123J27.js} +1 -1
- package/dist/{render-worker-host-C3xwtHnv.js → render-worker-host-Di3LxLc0.js} +1 -1
- package/dist/renderer-B4GZb5We.js +6492 -0
- package/dist/{resource-measurement-CclArDRs.js → resource-measurement-SHQCbkh2.js} +3 -3
- package/dist/{session-BuJL_xcp.js → session-BGq81gRQ.js} +98 -98
- package/dist/{slide-pull-client-Ck8wfRT_.js → slide-pull-client-DiPnm240.js} +767 -738
- package/dist/{three-d-YYghQndN.js → three-d-DJBl8g8M.js} +251 -435
- package/dist/three-d.mjs +998 -906
- package/dist/tiff.mjs +2 -2
- package/dist/types/chart-ex.d.ts +142 -4
- package/dist/types/docx.d.ts +155 -13
- package/dist/types/index.d.ts +131 -19
- package/dist/types/math.d.ts +1 -1
- package/dist/types/node.d.ts +120 -8
- package/dist/types/pptx.d.ts +123 -13
- package/dist/types/region-map.d.ts +142 -4
- package/dist/types/three-d.d.ts +142 -4
- package/dist/types/tiff.d.ts +1 -1
- package/dist/types/xlsx.d.ts +155 -13
- package/dist/{worksheet-pull-client-CAvuf22q.js → worksheet-pull-client-BM8ywvbu.js} +51 -51
- package/dist/{xlsx-Bblm5r1h.js → xlsx-C9NVjgaV.js} +1592 -1564
- package/dist/xlsx.mjs +6 -6
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/assets/render-worker-D21h5TGR.js +0 -10
- package/dist/assets/render-worker-Dsfekaht.js +0 -11
- package/dist/assets/render-worker-DxU7IrKo.js +0 -31
- package/dist/comment-ui-runtime-TLHustXJ.js +0 -2
- package/dist/plot-area-frame-D5hEOgkJ.js +0 -2903
- package/dist/renderer-XFSCOT6m.js +0 -5857
- /package/dist/{bounded-raw-part-cache-BfbSxRIL.js → bounded-raw-part-cache-Cg1BsSZQ.js} +0 -0
- /package/dist/{comment-occurrence-CqejEuts.js → comment-occurrence-C8Y2uoVr.js} +0 -0
- /package/dist/{delimited-text-worker-host-DcHj_JZt.js → delimited-text-worker-host-BVY-Ecni.js} +0 -0
- /package/dist/{highlight-rect-FuUSmL3a.js → highlight-rect-C5hkRqUr.js} +0 -0
- /package/dist/{line-metrics-CBbw80Ko.js → line-metrics-B60C86uh.js} +0 -0
- /package/dist/{mathjax-DS69BmJd.js → mathjax-DoyWZbSp.js} +0 -0
- /package/dist/{pixel-budget-Dgjw269h.js → pixel-budget-9P63Bsk5.js} +0 -0
- /package/dist/{read-only-comment-decoration-BTnWEeo5.js → read-only-comment-decoration-Dz7eTQ4d.js} +0 -0
- /package/dist/{read-only-comment-margin-plStyGfE.js → read-only-comment-margin-DkgzASAl.js} +0 -0
- /package/dist/{renderer-module-contract-Cu-GKuPd.js → renderer-module-contract-D91rkYHH.js} +0 -0
- /package/dist/{source-key-Ktb1GRE5.js → source-key-DIJG8BA0.js} +0 -0
- /package/dist/{transfer-mIj7E7NB.js → transfer-p6iCC2R7.js} +0 -0
- /package/dist/{units-EJdC96r6.js → units-BzZ0gAxs.js} +0 -0
- /package/dist/{visible-index-DPoQYSDt.js → visible-index-BgiHEc1z.js} +0 -0
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
2
|
-
import { $ as t,
|
|
3
|
-
import { C as p, D as m, M as h, N as g, O as _, S as v, T as
|
|
4
|
-
import { c as
|
|
5
|
-
import { A as
|
|
6
|
-
import {
|
|
7
|
-
import { a as
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { n as
|
|
11
|
-
import { t as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
2
|
+
import { $ as t, $t as n, L as r, R as i, U as a, _t as o, ft as s, ln as c, lt as l, r as u, un as d, z as f } from "./hyperlink-Cxzhet30.js";
|
|
3
|
+
import { C as p, D as m, M as h, N as g, O as _, S as v, T as ee, _ as y, a as b, b as te, c as x, d as ne, f as re, g as ie, h as ae, i as S, l as C, m as oe, n as se, o as ce, p as le, r as ue, s as de, t as fe, u as pe, v as me, w as he, x as ge, y as _e } from "./canvas-viewer-mechanics-DbLz0rYW.js";
|
|
4
|
+
import { c as ve, d as ye, f as be, i as xe, l as Se, n as Ce, o as w, r as we, s as Te, t as Ee, u as De } from "./dom-interaction-boundary-Cnm8DSBN.js";
|
|
5
|
+
import { A as Oe, C as T, D as ke, E as Ae, M as je, O as E, S as Me, T as Ne, _ as Pe, a as Fe, b as Ie, c as Le, d as Re, f as ze, g as Be, h as Ve, j as He, k as Ue, l as We, m as Ge, n as Ke, o as qe, p as Je, s as Ye, t as Xe, v as Ze, w as Qe, x as $e, y as et } from "./document-pull-client-B9PTM-pL.js";
|
|
6
|
+
import { n as tt } from "./cjk-fallback-bLI3z70h.js";
|
|
7
|
+
import { a as D } from "./units-BzZ0gAxs.js";
|
|
8
|
+
import { l as nt, s as rt } from "./pixel-budget-9P63Bsk5.js";
|
|
9
|
+
import { i as it, s as at } from "./raster-target-ojDdQizC.js";
|
|
10
|
+
import { n as ot } from "./renderer-module-contract-D91rkYHH.js";
|
|
11
|
+
import { n as st, t as O } from "./highlight-rect-C5hkRqUr.js";
|
|
12
|
+
import { t as ct } from "./bounded-raw-part-cache-Cg1BsSZQ.js";
|
|
13
|
+
import { o as k } from "./source-key-DIJG8BA0.js";
|
|
14
|
+
import { i as lt, n as A, r as ut, t as dt } from "./comments-Diid5ujN.js";
|
|
14
15
|
//#region packages/core/src/fonts/open-type-metrics.ts
|
|
15
|
-
var
|
|
16
|
+
var j = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCodeAt(2) << 8 | e.charCodeAt(3)) >>> 0, ft = j("ttcf"), pt = j("OTTO"), mt = j("true"), ht = j("typ1"), gt = j("head"), _t = j("hhea"), vt = j("OS/2"), yt = j("cmap"), bt = j("fvar"), M = [
|
|
16
17
|
[4352, 4607],
|
|
17
18
|
[11904, 12287],
|
|
18
19
|
[12352, 12543],
|
|
@@ -28,10 +29,10 @@ var P = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCode
|
|
|
28
29
|
[63744, 64255],
|
|
29
30
|
[131072, 205743]
|
|
30
31
|
];
|
|
31
|
-
function
|
|
32
|
+
function N(e, t, n) {
|
|
32
33
|
return Number.isSafeInteger(t) && Number.isSafeInteger(n) && t >= 0 && n >= 0 && t <= e - n;
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
+
function xt(e, t, n) {
|
|
35
36
|
if (n < 16) return !1;
|
|
36
37
|
let r = e.getUint16(t + 2);
|
|
37
38
|
if (r < 16 || r > n) return !1;
|
|
@@ -47,7 +48,7 @@ function ht(e, t, n) {
|
|
|
47
48
|
}
|
|
48
49
|
for (let n = 0; n < a; n++) {
|
|
49
50
|
let i = e.getUint16(s + n * 2), a = e.getUint16(o + n * 2), u = e.getInt16(c + n * 2), d = l + n * 2, f = e.getUint16(d);
|
|
50
|
-
for (let [n, o] of
|
|
51
|
+
for (let [n, o] of M) {
|
|
51
52
|
let s = Math.max(i, n), c = Math.min(a, o);
|
|
52
53
|
if (!(s > c)) {
|
|
53
54
|
if (f === 0) {
|
|
@@ -65,7 +66,7 @@ function ht(e, t, n) {
|
|
|
65
66
|
}
|
|
66
67
|
return !1;
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
+
function St(e, t, n, r) {
|
|
69
70
|
if (n < 16) return !1;
|
|
70
71
|
let i = e.getUint32(t + 4), a = e.getUint32(t + 12);
|
|
71
72
|
if (i < 16 || i > n || a > (i - 16) / 12) return !1;
|
|
@@ -73,8 +74,8 @@ function gt(e, t, n, r) {
|
|
|
73
74
|
for (let n = 0; n < a; n++) {
|
|
74
75
|
let i = t + 16 + n * 12, a = e.getUint32(i), s = e.getUint32(i + 4), c = e.getUint32(i + 8);
|
|
75
76
|
if (a > s || s > 1114111 || a <= o) return !1;
|
|
76
|
-
if (o = s, a >
|
|
77
|
-
for (let [e, t] of
|
|
77
|
+
if (o = s, a > M[M.length - 1][1]) break;
|
|
78
|
+
for (let [e, t] of M) {
|
|
78
79
|
let n = Math.max(a, e), i = Math.min(s, t);
|
|
79
80
|
if (!(n > i)) {
|
|
80
81
|
if (r) {
|
|
@@ -85,7 +86,7 @@ function gt(e, t, n, r) {
|
|
|
85
86
|
}
|
|
86
87
|
return !1;
|
|
87
88
|
}
|
|
88
|
-
function
|
|
89
|
+
function Ct(e, t) {
|
|
89
90
|
if (!t || t.length < 4) return !1;
|
|
90
91
|
let n = e.getUint16(t.offset + 2);
|
|
91
92
|
if (4 + n * 8 > t.length) return !1;
|
|
@@ -95,61 +96,169 @@ function _t(e, t) {
|
|
|
95
96
|
let o = e.getUint32(n + 4);
|
|
96
97
|
if (o > t.length - 2) continue;
|
|
97
98
|
let s = t.offset + o, c = t.length - o, l = e.getUint16(s);
|
|
98
|
-
if (l === 4 &&
|
|
99
|
+
if (l === 4 && xt(e, s, c) || l === 12 && St(e, s, c, !1) || l === 13 && St(e, s, c, !0)) return !0;
|
|
99
100
|
}
|
|
100
101
|
return !1;
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
+
var P = 32768, wt = 4096, Tt = 8, Et = 262144;
|
|
104
|
+
function Dt(e, t, n, r) {
|
|
105
|
+
if (n < 16) return null;
|
|
106
|
+
let i = e.getUint16(t + 2);
|
|
107
|
+
if (i < 16 || i > n) return null;
|
|
108
|
+
let a = e.getUint16(t + 6);
|
|
109
|
+
if (a === 0 || a % 2 != 0) return null;
|
|
110
|
+
let o = a / 2, s = t + 14, c = s + o * 2 + 2, l = c + o * 2, u = l + o * 2;
|
|
111
|
+
if (u + o * 2 > t + i) return null;
|
|
112
|
+
let d = [], f = -1, p = -1, m = (e) => {
|
|
113
|
+
d.length > 0 && p + 1 === e ? (p = e, d[d.length - 1] = [f, p]) : (f = p = e, d.push([e, e]));
|
|
114
|
+
}, h = -1;
|
|
115
|
+
for (let n = 0; n < o; n++) {
|
|
116
|
+
let a = e.getUint16(c + n * 2), o = e.getUint16(s + n * 2);
|
|
117
|
+
if (a > o || a <= h) return null;
|
|
118
|
+
h = o;
|
|
119
|
+
let f = e.getInt16(l + n * 2), p = u + n * 2, g = e.getUint16(p);
|
|
120
|
+
for (let n = a; n <= o && n < 65535; n++) if (--r.remaining < 0 || ((g === 0 ? n + f & 65535 : (() => {
|
|
121
|
+
let r = p + g + (n - a) * 2;
|
|
122
|
+
if (r + 2 > t + i) return 0;
|
|
123
|
+
let o = e.getUint16(r);
|
|
124
|
+
return o === 0 ? 0 : o + f & 65535;
|
|
125
|
+
})()) !== 0 && m(n), d.length > P)) return null;
|
|
126
|
+
}
|
|
127
|
+
return d;
|
|
128
|
+
}
|
|
129
|
+
function Ot(e, t, n, r, i) {
|
|
130
|
+
if (n < 16) return null;
|
|
131
|
+
let a = e.getUint32(t + 4), o = e.getUint32(t + 12);
|
|
132
|
+
if (a < 16 || a > n || o > (a - 16) / 12 || o > P) return null;
|
|
133
|
+
let s = [], c = -1;
|
|
134
|
+
for (let n = 0; n < o; n++) {
|
|
135
|
+
if (--i.remaining < 0) return null;
|
|
136
|
+
let a = t + 16 + n * 12, o = e.getUint32(a), l = e.getUint32(a + 4), u = e.getUint32(a + 8);
|
|
137
|
+
if (o > l || l > 1114111 || o <= c) return null;
|
|
138
|
+
if (c = l, r) u !== 0 && s.push([o, l]);
|
|
139
|
+
else {
|
|
140
|
+
let e = u === 0 ? o + 1 : o;
|
|
141
|
+
e <= l && s.push([e, l]);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return s;
|
|
145
|
+
}
|
|
146
|
+
function kt(e, t) {
|
|
147
|
+
if (!t || t.length < 4) return [];
|
|
148
|
+
let n = e.getUint16(t.offset + 2);
|
|
149
|
+
if (n > wt || 4 + n * 8 > t.length) return [];
|
|
150
|
+
let r = /* @__PURE__ */ new Set(), i = [];
|
|
151
|
+
for (let a = 0; a < n; a++) {
|
|
152
|
+
let n = t.offset + 4 + a * 8, o = e.getUint16(n), s = e.getUint16(n + 2);
|
|
153
|
+
if (o !== 0 && !(o === 3 && (s === 1 || s === 10))) continue;
|
|
154
|
+
let c = e.getUint32(n + 4);
|
|
155
|
+
if (c > t.length - 2) return [];
|
|
156
|
+
let l = t.offset + c, u = t.length - c, d = e.getUint16(l);
|
|
157
|
+
if (!(o === 0 && s === 5 && d === 14)) {
|
|
158
|
+
if (d !== 4 && d !== 12 && d !== 13) return [];
|
|
159
|
+
if (!r.has(c)) {
|
|
160
|
+
if (r.add(c), r.size > Tt) return [];
|
|
161
|
+
i.push({
|
|
162
|
+
subtable: l,
|
|
163
|
+
availableLength: u,
|
|
164
|
+
format: d
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
let a = { remaining: Et }, o = null;
|
|
170
|
+
for (let t of i) {
|
|
171
|
+
let n = t.format === 4 ? Dt(e, t.subtable, t.availableLength, a) : Ot(e, t.subtable, t.availableLength, t.format === 13, a);
|
|
172
|
+
if (!n?.length) return [];
|
|
173
|
+
if (o === null) {
|
|
174
|
+
o = n;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
let r = [], i = 0, s = 0;
|
|
178
|
+
for (; i < o.length && s < n.length;) {
|
|
179
|
+
if (--a.remaining < 0) return [];
|
|
180
|
+
let e = o[i], t = n[s], c = Math.max(e[0], t[0]), l = Math.min(e[1], t[1]);
|
|
181
|
+
if (c <= l) {
|
|
182
|
+
let e = r.at(-1);
|
|
183
|
+
if (e && e[1] + 1 === c) r[r.length - 1] = [e[0], l];
|
|
184
|
+
else {
|
|
185
|
+
if (r.length >= P) return [];
|
|
186
|
+
r.push([c, l]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
e[1] <= t[1] && i++, t[1] <= e[1] && s++;
|
|
190
|
+
}
|
|
191
|
+
if (!r.length) return [];
|
|
192
|
+
o = r;
|
|
193
|
+
}
|
|
194
|
+
return Object.freeze((o ?? []).map((e) => Object.freeze(e)));
|
|
195
|
+
}
|
|
196
|
+
function At(e) {
|
|
197
|
+
let t = 0, n = 0;
|
|
198
|
+
for (; t < e.length && n < M.length;) {
|
|
199
|
+
let [r, i] = e[t], [a, o] = M[n];
|
|
200
|
+
if (i < a) t++;
|
|
201
|
+
else if (o < r) n++;
|
|
202
|
+
else return !0;
|
|
203
|
+
}
|
|
204
|
+
return !1;
|
|
205
|
+
}
|
|
206
|
+
function jt(e, t) {
|
|
207
|
+
return Mt(e, t, !1);
|
|
208
|
+
}
|
|
209
|
+
function Mt(e, t, n) {
|
|
103
210
|
if (t !== void 0 && (!Number.isSafeInteger(t) || t < 0) || e.byteLength < 12) return null;
|
|
104
|
-
let
|
|
105
|
-
if (
|
|
211
|
+
let r = new DataView(e.buffer, e.byteOffset, e.byteLength), i = 0;
|
|
212
|
+
if (r.getUint32(0) === ft) {
|
|
106
213
|
if (t === void 0 || e.byteLength < 12) return null;
|
|
107
|
-
let
|
|
108
|
-
if (t >=
|
|
109
|
-
|
|
214
|
+
let n = r.getUint32(8);
|
|
215
|
+
if (t >= n || !N(e.byteLength, 12, n * 4)) return null;
|
|
216
|
+
i = r.getUint32(12 + t * 4);
|
|
110
217
|
} else if (t !== void 0 && t !== 0) return null;
|
|
111
|
-
if (!
|
|
112
|
-
let
|
|
113
|
-
if (
|
|
114
|
-
let
|
|
115
|
-
if (!
|
|
116
|
-
let
|
|
117
|
-
for (let t = 0; t <
|
|
118
|
-
let
|
|
119
|
-
if (
|
|
120
|
-
|
|
121
|
-
offset:
|
|
218
|
+
if (!N(e.byteLength, i, 12)) return null;
|
|
219
|
+
let a = r.getUint32(i);
|
|
220
|
+
if (a !== 65536 && a !== pt && a !== mt && a !== ht) return null;
|
|
221
|
+
let o = r.getUint16(i + 4);
|
|
222
|
+
if (!N(e.byteLength, i + 12, o * 16)) return null;
|
|
223
|
+
let s = /* @__PURE__ */ new Map();
|
|
224
|
+
for (let t = 0; t < o; t++) {
|
|
225
|
+
let n = i + 12 + t * 16, a = r.getUint32(n), o = r.getUint32(n + 8), c = r.getUint32(n + 12);
|
|
226
|
+
if (s.has(a) || !N(e.byteLength, o, c)) return null;
|
|
227
|
+
s.set(a, {
|
|
228
|
+
offset: o,
|
|
122
229
|
length: c
|
|
123
230
|
});
|
|
124
231
|
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
232
|
+
if (n && s.has(bt)) return null;
|
|
233
|
+
let c = s.get(gt), l = s.get(_t);
|
|
234
|
+
if (!c || c.length < 20 || !l || l.length < 10) return null;
|
|
235
|
+
let u = r.getUint16(c.offset + 18);
|
|
236
|
+
if (u < 16 || u > 16384) return null;
|
|
237
|
+
let d = s.get(vt), f = d !== void 0 && d.length >= 78, p = n ? kt(r, s.get(yt)) : void 0;
|
|
130
238
|
return Object.freeze({
|
|
131
|
-
unitsPerEm:
|
|
132
|
-
hheaAscent:
|
|
133
|
-
hheaDescent:
|
|
134
|
-
hheaLineGap:
|
|
135
|
-
hasEastAsianCmap:
|
|
136
|
-
...
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
239
|
+
unitsPerEm: u,
|
|
240
|
+
hheaAscent: r.getInt16(l.offset + 4),
|
|
241
|
+
hheaDescent: r.getInt16(l.offset + 6),
|
|
242
|
+
hheaLineGap: r.getInt16(l.offset + 8),
|
|
243
|
+
hasEastAsianCmap: p ? At(p) : Ct(r, s.get(yt)),
|
|
244
|
+
...p === void 0 ? {} : { unicodeRanges: p },
|
|
245
|
+
...f ? {
|
|
246
|
+
typoAscent: r.getInt16(d.offset + 68),
|
|
247
|
+
typoDescent: r.getInt16(d.offset + 70),
|
|
248
|
+
typoLineGap: r.getInt16(d.offset + 72),
|
|
249
|
+
winAscent: r.getUint16(d.offset + 74),
|
|
250
|
+
winDescent: r.getUint16(d.offset + 76),
|
|
251
|
+
useTypoMetrics: (r.getUint16(d.offset + 62) & 128) != 0
|
|
143
252
|
} : {}
|
|
144
253
|
});
|
|
145
254
|
}
|
|
146
255
|
//#endregion
|
|
147
256
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
148
|
-
var yt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};const J=67108864;var De=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>{let e=this.executeArchive(e=>e.document_cursor_resource_usage?.());return e?I(e):void 0}}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Y(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new De(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Y(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", bt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", yt], { type: "text/javascript;charset=utf-8" });
|
|
149
|
-
function
|
|
257
|
+
var Nt = "var e=(e,t)=>()=>(e&&(t=e(e=0)),t),t=class{__destroy_into_raw(){let e=this.__wbg_ptr;return this.__wbg_ptr=0,r.unregister(this),e}free(){let e=this.__destroy_into_raw();v.__wbg_docxarchive_free(e,0)}acknowledge_document_chunk(e,t,n){let r=v.docxarchive_acknowledge_document_chunk(this.__wbg_ptr,e,t,n);if(r[1])throw p(r[0])}assert_healthy(){let e=v.docxarchive_assert_healthy(this.__wbg_ptr);if(e[1])throw p(e[0])}cancel_document_cursor(){v.docxarchive_cancel_document_cursor(this.__wbg_ptr)}close_document_session(){v.docxarchive_close_document_session(this.__wbg_ptr)}document_chunk_done(){let e=v.docxarchive_document_chunk_done(this.__wbg_ptr);if(e[2])throw p(e[1]);return e[0]!==0}document_cursor_resource_usage(){let e=v.docxarchive_document_cursor_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}extract_image(e){let t=f(e,v.__wbindgen_malloc,v.__wbindgen_realloc),n=_,r=v.docxarchive_extract_image(this.__wbg_ptr,t,n);if(r[3])throw p(r[2]);var a=i(r[0],r[1]).slice();return v.__wbindgen_free(r[0],r[1]*1,1),a}constructor(e,t,n,i){let a=d(e,v.__wbindgen_malloc),o=_,s=v.docxarchive_new(a,o,!u(t),u(t)?BigInt(0):t,!u(n),u(n)?BigInt(0):n,!u(i),u(i)?BigInt(0):i);if(s[2])throw p(s[1]);return this.__wbg_ptr=s[0]>>>0,r.register(this,this.__wbg_ptr,this),this}open_document_cursor(e,t){let n=v.docxarchive_open_document_cursor(this.__wbg_ptr,e,t);if(n[1])throw p(n[0])}parse(){let e=v.docxarchive_parse(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}pull_document_chunk(e,t,n,r){let a=v.docxarchive_pull_document_chunk(this.__wbg_ptr,e,t,n,r);if(a[3])throw p(a[2]);var o=i(a[0],a[1]).slice();return v.__wbindgen_free(a[0],a[1]*1,1),o}resource_usage(){let e=v.docxarchive_resource_usage(this.__wbg_ptr);if(e[3])throw p(e[2]);var t=i(e[0],e[1]).slice();return v.__wbindgen_free(e[0],e[1]*1,1),t}to_markdown(){let e,t;try{let i=v.docxarchive_to_markdown(this.__wbg_ptr);var n=i[0],r=i[1];if(i[3])throw n=0,r=0,p(i[2]);return e=n,t=r,s(n,r)}finally{v.__wbindgen_free(e,t,1)}}};Symbol.dispose&&(t.prototype[Symbol.dispose]=t.prototype.free);function n(){return{__proto__:null,\"./docx_parser_bg.js\":{__proto__:null,__wbg___wbindgen_throw_6b64449b9b9ed33c:function(e,t){throw Error(s(e,t))},__wbg_error_a6fa202b58aa1cd3:function(e,t){let n,r;try{n=e,r=t,console.error(s(e,t))}finally{v.__wbindgen_free(n,r,1)}},__wbg_new_227d7c05414eb861:function(){return Error()},__wbg_stack_3b0d974bbf31e44f:function(e,t){let n=t.stack,r=f(n,v.__wbindgen_malloc,v.__wbindgen_realloc),i=_;o().setInt32(e+4,i,!0),o().setInt32(e+0,r,!0)},__wbindgen_cast_0000000000000001:function(e,t){return s(e,t)},__wbindgen_init_externref_table:function(){let e=v.__wbindgen_externrefs,t=e.grow(4);e.set(0,void 0),e.set(t+0,void 0),e.set(t+1,null),e.set(t+2,!0),e.set(t+3,!1)}}}}const r=typeof FinalizationRegistry>`u`?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(e=>v.__wbg_docxarchive_free(e>>>0,1));function i(e,t){return e>>>=0,l().subarray(e/1,e/1+t)}let a=null;function o(){return(a===null||a.buffer.detached===!0||a.buffer.detached===void 0&&a.buffer!==v.memory.buffer)&&(a=new DataView(v.memory.buffer)),a}function s(e,t){return e>>>=0,ee(e,t)}let c=null;function l(){return(c===null||c.byteLength===0)&&(c=new Uint8Array(v.memory.buffer)),c}function u(e){return e==null}function d(e,t){let n=t(e.length*1,1)>>>0;return l().set(e,n/1),_=e.length,n}function f(e,t,n){if(n===void 0){let n=g.encode(e),r=t(n.length,1)>>>0;return l().subarray(r,r+n.length).set(n),_=n.length,r}let r=e.length,i=t(r,1)>>>0,a=l(),o=0;for(;o<r;o++){let t=e.charCodeAt(o);if(t>127)break;a[i+o]=t}if(o!==r){o!==0&&(e=e.slice(o)),i=n(i,r,r=o+e.length*3,1)>>>0;let t=l().subarray(i+o,i+r),a=g.encodeInto(e,t);o+=a.written,i=n(i,r,o,1)>>>0}return _=o,i}function p(e){let t=v.__wbindgen_externrefs.get(e);return v.__externref_table_dealloc(e),t}let m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0});m.decode();let h=0;function ee(e,t){return h+=t,h>=2146435072&&(m=new TextDecoder(`utf-8`,{ignoreBOM:!0,fatal:!0}),m.decode(),h=t),m.decode(l().subarray(e,e+t))}const g=new TextEncoder;`encodeInto`in g||(g.encodeInto=function(e,t){let n=g.encode(e);return t.set(n),{read:e.length,written:n.length}});let _=0,v;function te(e,t){return v=e.exports,a=null,c=null,v.__wbindgen_start(),v}async function ne(e,t){if(typeof Response==`function`&&e instanceof Response){if(typeof WebAssembly.instantiateStreaming==`function`)try{return await WebAssembly.instantiateStreaming(e,t)}catch(t){if(e.ok&&n(e.type)&&e.headers.get(`Content-Type`)!==`application/wasm`)console.warn(\"`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\\n\",t);else throw t}let r=await e.arrayBuffer();return await WebAssembly.instantiate(r,t)}else{let n=await WebAssembly.instantiate(e,t);return n instanceof WebAssembly.Instance?{instance:n,module:e}:n}function n(e){switch(e){case`basic`:case`cors`:case`default`:return!0}return!1}}async function y(e){if(v!==void 0)return v;e!==void 0&&(Object.getPrototypeOf(e)===Object.prototype?{module_or_path:e}=e:console.warn(`using deprecated parameters for the initialization function; pass a single object instead`));let t=n();(typeof e==`string`||typeof Request==`function`&&e instanceof Request||typeof URL==`function`&&e instanceof URL)&&(e=fetch(e));let{instance:r,module:i}=await ne(await e,t);return te(r,i)}async function b(e){return v=void 0,a=null,c=null,y(e)}var x=class e extends Error{code;constructor(t,n){super(n),this.name=`OoxmlError`,this.code=t,Object.setPrototypeOf(this,e.prototype)}},S=class e extends Error{code=`ooxml-resource-limit`;details;constructor(t,n){super(t),this.name=`OoxmlResourceLimitError`;let r=n.violation,i=Object.freeze({format:r.format,operation:r.operation,resource:r.resource,metric:r.metric,...r.part===void 0?{}:{part:r.part},limit:r.limit,observed:r.observed,configurable:r.configurable,usage:Object.freeze({archiveEntryCount:r.usage.archiveEntryCount,declaredInflatedBytes:r.usage.declaredInflatedBytes,...r.usage.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:r.usage.largestInflatedEntryBytes},distinctInflatedBytes:r.usage.distinctInflatedBytes,operationInflatedBytes:r.usage.operationInflatedBytes})});this.details=Object.freeze({stage:n.stage,violation:i}),Object.setPrototypeOf(this,e.prototype)}};function re(e){return e===`image-dimension`||e===`image-pixels`||e===`active-decoded-bytes`}function C(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function ie(e){if(!(!e||typeof e!=`object`))try{let t=e,n=t.code,r=t.metric,i=t.limit,a=t.observed;return n!==`ooxml-decoded-image-limit`||!re(r)||!C(i)||!C(a)||a<=i?void 0:{metric:r,limit:i,observed:a}}catch{return}}var w,T,E,D=e((()=>{w=1<<25,T=1<<27,w*4,T*4,E=class e extends RangeError{code=`ooxml-decoded-image-limit`;constructor(t,n,r){super(`OOXML decoded image limit exceeded: ${t} ${r} > ${n}`),this.metric=t,this.limit=n,this.observed=r,this.name=`OoxmlDecodedImageLimitError`,Object.setPrototypeOf(this,e.prototype)}}}));function O(e){if(!(typeof e!=`object`||!e))try{let t=e,n=t.code,r=t.message;return n===`ooxml-tiff-decode`&&typeof r==`string`?{message:r}:void 0}catch{return}}var ae=e((()=>{}));function oe(e){if(!e.startsWith(`data:`))return null;let t=e.indexOf(`,`);if(t===-1)return null;let n=atob(e.slice(t+1)),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}var se=class{state=`uninitialized`;generationValue=0;readiness;poisonListeners=new Set;constructor(e,t,n){this.initialize=e,this.reinitialize=t,this.normalizeFailure=n}get generation(){return this.generationValue}get poisoned(){return this.state===`poisoned`}onPoison(e){return this.poisonListeners.add(e),()=>this.poisonListeners.delete(e)}async ensureReady(){if(this.state!==`ready`){if(!this.readiness){let e=this.state===`uninitialized`?this.initialize:this.reinitialize;this.readiness=Promise.resolve().then(e).then(()=>{this.generationValue+=1,this.state=`ready`,this.readiness=void 0},e=>{throw this.readiness=void 0,e})}await this.readiness}}run(e){try{return e()}catch(e){let t=this.normalizeFailure(e);throw t?(this.poison(t),t):e}}tryRunReady(e){if(this.state!==`ready`)return{current:!1};let t=this.generationValue,n=this.run(e);return this.state!==`ready`||t!==this.generationValue?{current:!1}:{current:!0,generation:t,value:n}}poison(e){this.state=`poisoned`,this.readiness=void 0;for(let t of this.poisonListeners)t(e)}assertCurrent(e){if(this.state!==`ready`||e!==this.generationValue)throw Error(`WASM archive session belongs to a discarded runtime generation`)}},k=class e extends Error{code=`parser-crashed`;constructor(t){super(t),this.name=`WasmTrapError`,Object.setPrototypeOf(this,e.prototype)}};function ce(e){let t=globalThis.WebAssembly?.RuntimeError;return t&&e instanceof t||e instanceof RangeError?!0:e instanceof Error?e.name===`RuntimeError`||e.name===`CompileError`||e.name===`LinkError`||e.name===`InternalError`||e.name===`OOMError`:!1}function le(e){try{if((typeof e!=`object`||!e)&&typeof e!=`function`)return;let t=Reflect.get(e,`__destroy_into_raw`);typeof t==`function`&&Reflect.apply(t,e,[])}catch{}}function ue(e,t){return e({module_or_path:t})}var de=class{runtime;wasmInput=null;currentArchive=null;constructor(e,t={}){this.init=e,this.options=t,this.runtime=new se(()=>this.invokeConfigured(this.init),()=>this.invokeConfigured(this.options.reinit??this.init),fe),this.runtime.onPoison(()=>this.dropPoisonedArchive())}setWasmInput(e){this.wasmInput=e,this.runtime.ensureReady().catch(()=>void 0)}setWasmUrl(e){this.setWasmInput(e)}get archive(){return this.currentArchive}setArchive(e){this.freeArchive(),this.currentArchive=e}disposeArchive(){this.freeArchive()}get poisoned(){return this.runtime.poisoned}async ensureReady(){await this.runtime.ensureReady()}run(e){return this.runtime.run(e)}poison(){this.runtime.poison(new k(`WASM parser was recycled`))}invokeConfigured(e){return this.wasmInput===null?Promise.reject(Error(`WasmParserHost: setWasmInput was never called`)):ue(e,this.wasmInput)}freeArchive(){this.currentArchive!==null&&this.options.freeArchive&&this.options.freeArchive(this.currentArchive),this.currentArchive=null}dropPoisonedArchive(){let e=this.currentArchive;this.currentArchive=null,le(e)}};function fe(e){return ce(e)?new k(`WASM parser trapped and was recycled: ${e instanceof Error?e.message:String(e)}`):null}function A(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>0}function pe(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return A(t.requiredBytes)&&A(t.offeredBytes)&&t.requiredBytes>t.offeredBytes}var j=class e extends RangeError{code=`ooxml-insufficient-credit`;requiredBytes;offeredBytes;constructor(t){super(`Pull unit requires ${t.requiredBytes} bytes but credit is ${t.offeredBytes}`),this.name=`PullSessionInsufficientCreditError`,this.requiredBytes=t.requiredBytes,this.offeredBytes=t.offeredBytes,Object.setPrototypeOf(this,e.prototype)}};function M(e){if(e instanceof j)return e;let t=e instanceof Error?e.message:String(e);if(!t.startsWith(`OOXML_INSUFFICIENT_CREDIT:`))return;let n;try{n=JSON.parse(t.slice(26))}catch{return}if(!n||typeof n!=`object`||Array.isArray(n))return;let r=n;if(!(r.code!==`ooxml-insufficient-credit`||!pe(r)))return new j(r)}function me(e,t,n){let r=M(e);if(!(!r||r.offeredBytes!==t||r.requiredBytes>n))return r}D(),ae();const N=`OOXML_RESOURCE_LIMIT:`;function P(e){return typeof e==`number`&&Number.isSafeInteger(e)&&e>=0}function F(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return P(t.archiveEntryCount)&&P(t.declaredInflatedBytes)&&(t.largestInflatedEntryBytes===void 0||P(t.largestInflatedEntryBytes))&&P(t.distinctInflatedBytes)&&P(t.operationInflatedBytes)}function I(e){let t;try{t=JSON.parse(new TextDecoder().decode(e))}catch{throw TypeError(`OOXML resource usage checkpoint is not valid JSON`)}if(!F(t))throw TypeError(`OOXML resource usage checkpoint is invalid`);return t}function L(e){return e===`docx`||e===`xlsx`||e===`pptx`}function R(e){return e===`container`||e===`decompression`||e===`parsing`||e===`serialization`||e===`layout`||e===`rendering`||e===`worker`}function z(e,t){return typeof e==`string`&&e.length>0&&e.length<=t&&!/[\\u0000-\\u001f\\u007f]/u.test(e)}function B(e){return z(e,128)&&/^[a-z0-9][a-z0-9-]*$/u.test(e)}function he(e){return!z(e,4096)||e.startsWith(`/`)||e.startsWith(`\\\\`)||e.includes(`\\\\`)||e.includes(`?`)||e.includes(`#`)||e.includes(`://`)||/^[a-z]:/iu.test(e)?!1:e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`)}const V=new Map([[`archive-entry:declared-inflated-bytes`,{stage:`container`,part:`required`}],[`archive-entry:actual-inflated-bytes`,{stage:`decompression`,part:`required`}],[`archive:entry-count`,{stage:`container`,part:`forbidden`}],[`archive:central-directory-bytes`,{stage:`container`,part:`forbidden`,configurable:!1}],[`archive:distinct-inflated-bytes`,{stage:`decompression`,part:`required`}],[`xml-event:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-context:bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`xml-tree:depth`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-row:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}],[`worksheet-shell:projected-bytes`,{stage:`parsing`,part:`optional`,configurable:!1}]]),ge=new Set([...V.keys()].map(e=>e.slice(0,e.indexOf(`:`)))),_e=new Set([...V.keys()].map(e=>e.slice(e.indexOf(`:`)+1)));function ve(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return!L(t.format)||!z(t.operation,256)||!B(t.resource)||!B(t.metric)||!P(t.limit)||!P(t.observed)||typeof t.configurable!=`boolean`||!F(t.usage)?!1:!(`part`in t)||he(t.part)}function H(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(!R(t.stage)||!ve(t.violation))return!1;let n=t.violation,r=V.get(`${n.resource}:${n.metric}`);return r?t.stage!==r.stage||r.configurable===!1&&n.configurable!==!1?!1:r.part===`required`?n.part!==void 0:r.part===`forbidden`?n.part===void 0:!0:!(ge.has(n.resource)&&_e.has(n.metric))}function ye(e){return{archiveEntryCount:e.archiveEntryCount,declaredInflatedBytes:e.declaredInflatedBytes,...e.largestInflatedEntryBytes===void 0?{}:{largestInflatedEntryBytes:e.largestInflatedEntryBytes},distinctInflatedBytes:e.distinctInflatedBytes,operationInflatedBytes:e.operationInflatedBytes}}function be(e){if(!H(e))return;let t=e.violation,n={stage:e.stage,violation:{format:t.format,operation:t.operation,resource:t.resource,metric:t.metric,...t.part===void 0?{}:{part:t.part},limit:t.limit,observed:t.observed,configurable:t.configurable,usage:ye(t.usage)}};return H(n)?n:void 0}function U(e){let t=e.violation;return`OOXML resource limit exceeded${t.part?` for ${t.part}`:``}: ${t.metric} ${t.observed} > ${t.limit}`}function xe(e){let t=e instanceof Error?e.message:String(e);if(!t.startsWith(N))return;let n;try{n=JSON.parse(t.slice(21))}catch{return}if(!n||typeof n!=`object`)return;let r=n;if(!(r.code!==`ooxml-resource-limit`||!H(r.details)))return new S(U(r.details),r.details)}function Se(e){let t=ie(e);if(t){let e=new E(t.metric,t.limit,t.observed);return{message:e.message,errorName:e.name,code:e.code,decodedImage:t}}let n=O(e);if(n)return{message:n.message,errorName:`TiffDecodeError`,code:`ooxml-tiff-decode`};let r=M(e);if(r)return{message:r.message,errorName:r.name,code:r.code,insufficientCredit:{requiredBytes:r.requiredBytes,offeredBytes:r.offeredBytes}};let i=e instanceof x||e instanceof S?e:xe(e);if(i instanceof S){let e=be(i.details);return e?{message:typeof i.message==`string`?i.message:U(e),errorName:`OoxmlResourceLimitError`,code:`ooxml-resource-limit`,resourceLimit:e}:{message:`Invalid OOXML resource-limit error payload`,errorName:`Error`}}if(i instanceof x)return{message:typeof i.message==`string`?i.message:String(i.message),errorName:z(i.name,128)?i.name:`OoxmlError`,...B(i.code)?{code:i.code}:{}};let a=e instanceof Error?e.message:String(e);if(typeof a==`string`&&a.startsWith(N))return{message:`Invalid OOXML resource-limit payload`,errorName:`Error`};let o=e instanceof Error?e:Error(a),s=o;return{message:typeof o.message==`string`?o.message:String(o.message),errorName:z(o.name,128)?o.name:`Error`,...typeof s.code==`string`?{code:s.code}:{}}}function W(e){try{return Se(e)}catch{return{message:`Worker operation failed with an unreadable error`,errorName:`Error`}}}function Ce(e){return e.byteOffset===0&&e.byteLength===e.buffer.byteLength&&e.buffer instanceof ArrayBuffer?e.buffer:e.slice().buffer}Object.freeze({maxArchiveEntryBytes:134217728,maxTotalInflatedBytes:268435456,maxArchiveEntries:4096});function we(e){return[e.maxArchiveEntryBytes===null?0n:BigInt(e.maxArchiveEntryBytes),e.maxTotalInflatedBytes===null?0n:BigInt(e.maxTotalInflatedBytes),e.maxArchiveEntries===null?0n:BigInt(e.maxArchiveEntries)]}const G=`ooxml-pull-v1`;function K(e,t){if(!Number.isSafeInteger(e)||e<=0)throw RangeError(`${t} must be a positive safe integer`)}function Te(e){if(!(typeof e==`string`&&e.length>0||typeof e==`number`&&Number.isSafeInteger(e)&&e>0))throw RangeError(`session id must be a non-empty string or positive safe integer`)}var q=class{owner;queue=Promise.resolve();leases=new Map;retainedBytes=0;retainedCount=0;maxRetainedBytes;maxRetainedCount;cleanups=new Set;pendingFatalCleanups=[];poisonRunning=!1;fatal;constructor(e){this.maxRetainedBytes=e?.maxRetainedBytes??64*1024*1024,this.maxRetainedCount=e?.maxRetainedCount??256,K(this.maxRetainedBytes,`max retained lease bytes`),K(this.maxRetainedCount,`max retained lease count`)}enqueue(e){let t=this.queue.then(e,e);return this.queue=t.then(()=>void 0,()=>void 0),t}acquire(e){return this.owner===void 0?(this.owner=e,!0):this.owner===e}release(e){this.owner===e&&(this.owner=void 0)}retainLease(e,t,n){if(!Number.isSafeInteger(n)||n<0)throw RangeError(`retained lease bytes are invalid`);let r=this.leases.get(e)??new Map;if(r.has(t))throw Error(`driver returned a duplicate lease id`);if(this.retainedCount+1>this.maxRetainedCount)throw RangeError(`retained lease count exceeds limit`);if(this.retainedBytes+n>this.maxRetainedBytes)throw RangeError(`retained lease bytes exceed limit`);r.set(t,n),this.leases.set(e,r),this.retainedCount++,this.retainedBytes+=n}releaseLease(e,t){let n=this.leases.get(e),r=n?.get(t);r!==void 0&&(n?.delete(t),n?.size===0&&this.leases.delete(e),this.retainedCount--,this.retainedBytes-=r)}registerCleanup(e){return this.fatal?(this.poisonRunning?this.pendingFatalCleanups.push(e):this.enqueue(e).catch(()=>void 0),()=>void 0):(this.cleanups.add(e),()=>this.cleanups.delete(e))}get fatalError(){return this.fatal}get registeredHostCount(){return this.cleanups.size}async poison(e){if(this.fatal??=e,this.poisonRunning)return this.fatal;this.poisonRunning=!0,this.pendingFatalCleanups.push(...this.cleanups);try{let e;for(;(e=this.pendingFatalCleanups.shift())!==void 0;)await e().catch(()=>void 0)}finally{this.poisonRunning=!1}return this.fatal}},Ee=class{options;coordinator;coordinatorOwner=Symbol(`pull-session-host`);unregisterCleanup;sequence=0;unacked;leases=new Map;activeDriverLeases=new Set;nextWireLeaseId;cancelRequested=!1;cancelComplete=!1;closeRequested=!1;closeComplete=!1;driverCancelComplete=!1;driverCloseComplete=!1;completed=!1;constructor(e){Te(e.sessionId),K(e.operationId,`operation id`),K(e.generation,`generation`),K(e.maxByteCredit,`max byte credit`),e.wireLeaseIdStart!==void 0&&K(e.wireLeaseIdStart,`wire lease id start`),this.options=e,this.coordinator=e.coordinator,this.nextWireLeaseId=e.wireLeaseIdStart??1,this.unregisterCleanup=this.coordinator.registerCleanup(()=>this.forceFatalCleanup())}dispatch(e,t){return this.coordinator.enqueue(async()=>{let n=await this.execute(e);try{t(n.response,n.transfer)}catch(e){throw await this.rollbackFailedPost(n),e}})}async rollbackFailedPost(e){let t=e.response;if(t.kind===`chunk`){let n=t.leaseId===void 0?void 0:this.leases.get(t.leaseId);try{await this.options.driver.disposeInvalidChunk?.({payload:t.payload,byteLength:t.byteLength,done:t.done,leaseId:n?.driverLeaseId,retainedBytes:n?.retainedBytes,transfer:e.transfer})}catch{}}this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);for(let[e,t]of[...this.leases])try{await this.options.driver.releaseLease?.(t.driverLeaseId)}catch{}finally{this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e)}if(this.cancelRequested=!0,!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch{}this.unregisterCleanup()}async execute(e){try{if(this.isStaleLifecycle(e)){let t=e.kind===`cancel`?`cancel`:`close`;return this.sameOperationIdentity(e)?{response:this.accepted(e,t,!0)}:{response:this.errorResponse(e,{message:`stale lifecycle targets another session or operation`,errorName:`PullSessionProtocolError`,code:`ooxml-stale-lifecycle`})}}this.validateCommandIdentity(e);let t=this.coordinator.fatalError;if(t)return e.kind===`pull`?{response:this.errorResponse(e,t)}:(e.kind===`cancel`?await this.cancel():e.kind===`close`?await this.close():e.kind===`release`&&await this.release(e.leaseId),{response:this.accepted(e,e.kind)});switch(e.kind){case`pull`:return await this.pull(e);case`ack`:return await this.ack(e.sequence),{response:this.accepted(e,`ack`)};case`release`:return await this.release(e.leaseId),{response:this.accepted(e,`release`)};case`cancel`:return await this.cancel(),{response:this.accepted(e,`cancel`)};case`close`:return await this.close(),{response:this.accepted(e,`close`)}}}catch(t){let n=W(t);return n.code===`ooxml-resource-limit`&&(n=await this.coordinator.poison(n)),{response:this.errorResponse(e,n)}}}async pull(e){if(this.closeRequested||this.cancelRequested||this.completed)throw Error(`pull session is closed`);if(this.unacked)throw Error(`previous chunk is not acknowledged`);if(!Number.isSafeInteger(e.sequence)||e.sequence<0||e.sequence!==this.sequence)throw Error(`pull command sequence mismatch`);if(this.validateHostCredit(e.byteCredit),!this.coordinator.acquire(this.coordinatorOwner))throw Error(`another operation has an unacknowledged package chunk`);let t;try{t=await this.options.driver.pull(e.byteCredit)}catch(e){throw this.coordinator.release(this.coordinatorOwner),e}let n=!1,r=!1,i,a;try{let o=this.options.driver.measureChunk(t),s=this.arrayBufferTransferBytes(t.transfer);if(o<s)throw RangeError(`measured chunk bytes are below ArrayBuffer transfer bytes`);if(a=Math.max(o,s),t.leaseId!==void 0){if(K(t.leaseId,`lease id`),t.retainedBytes===void 0)throw Error(`retained lease bytes are required`);if(this.activeDriverLeases.has(t.leaseId))throw r=!0,Error(`driver returned an active duplicate lease id`);i=this.allocateWireLeaseId(),this.coordinator.retainLease(this.coordinatorOwner,i,t.retainedBytes),this.leases.set(i,{driverLeaseId:t.leaseId,retainedBytes:t.retainedBytes}),this.activeDriverLeases.add(t.leaseId),n=!0}else if(t.retainedBytes!==void 0)throw Error(`retained lease bytes require a lease id`);if(!Number.isSafeInteger(a)||a<0)throw RangeError(`host chunk byte length must be a non-negative safe integer`);if(a>e.byteCredit)throw RangeError(`host chunk exceeds byte credit`)}catch(e){let a;try{await this.options.driver.disposeInvalidChunk?.(t)}catch(e){a=e}if(n&&i!==void 0)try{await this.release(i)}catch(e){a??=e}else if(t.leaseId!==void 0&&!r)try{await this.options.driver.releaseLease?.(t.leaseId)}catch(e){a??=e}if(r)try{await this.cancel()}catch(e){a??=e}throw this.coordinator.release(this.coordinatorOwner),a||e}return this.unacked={sequence:this.sequence,done:t.done},{response:{kind:`chunk`,protocol:G,...this.identity(),requestId:e.requestId,sequence:this.sequence,byteLength:a,done:t.done,payload:t.payload,leaseId:i,usage:this.resourceUsage()},transfer:t.transfer}}async ack(e){if(!Number.isSafeInteger(e)||e<0)throw RangeError(`invalid ack sequence`);if(e<this.sequence)return;if(!this.unacked||e!==this.sequence)throw Error(`ack sequence mismatch`);let t=this.unacked.done;await this.options.driver.acknowledge?.(e),this.unacked=void 0,this.coordinator.release(this.coordinatorOwner),this.sequence++,t&&(this.completed=!0,this.maybeUnregisterCompleted())}async release(e){K(e,`wire lease id`);let t=this.leases.get(e);t&&(await this.options.driver.releaseLease?.(t.driverLeaseId),this.leases.delete(e),this.activeDriverLeases.delete(t.driverLeaseId),this.coordinator.releaseLease(this.coordinatorOwner,e),this.maybeUnregisterCompleted())}async cancel(){if(this.cancelComplete)return;this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.cancelComplete=!0,this.unregisterCleanup()}async close(){if(this.closeComplete)return;this.closeRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;try{await this.releaseAllLeases()}catch(t){e=t}if(!this.driverCloseComplete)try{await this.options.driver.close?.(),this.driverCloseComplete=!0}catch(t){e??=t}if(e)throw e;this.closeComplete=!0,this.unregisterCleanup()}async releaseAllLeases(){let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(e)throw e}validateCommandIdentity(e){if(e.protocol!==`ooxml-pull-v1`||e.sessionId!==this.options.sessionId||e.operationId!==this.options.operationId||e.generation!==this.options.generation||!Number.isSafeInteger(e.requestId)||e.requestId<=0)throw Error(`stale or mismatched pull session command`)}validateHostCredit(e){if(K(e,`byte credit`),e>this.options.maxByteCredit)throw RangeError(`byte credit exceeds host maximum`)}accepted(e,t,n=!1){return{kind:`accepted`,protocol:G,...n?{sessionId:e.sessionId,operationId:e.operationId,generation:e.generation}:this.identity(),requestId:e.requestId,command:t,usage:this.resourceUsage()}}identity(){return{sessionId:this.options.sessionId,operationId:this.options.operationId,generation:this.options.generation}}isStaleLifecycle(e){return(e.kind===`cancel`||e.kind===`close`)&&e.protocol===`ooxml-pull-v1`&&Number.isSafeInteger(e.requestId)&&e.requestId>0&&Number.isSafeInteger(e.generation)&&e.generation>0&&e.generation<this.options.generation}sameOperationIdentity(e){return e.sessionId===this.options.sessionId&&e.operationId===this.options.operationId}errorResponse(e,t){return{kind:`error`,protocol:G,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:t,usage:this.errorResourceUsage()}}async forceFatalCleanup(){this.cancelRequested=!0,this.unacked=void 0,this.coordinator.release(this.coordinatorOwner);let e;for(let t of[...this.leases.keys()])try{await this.release(t)}catch(t){e??=t}if(!this.driverCancelComplete)try{await this.options.driver.cancel?.(),this.driverCancelComplete=!0}catch(t){e??=t}if(e)throw e;this.unregisterCleanup()}allocateWireLeaseId(){if(!Number.isSafeInteger(this.nextWireLeaseId)||this.nextWireLeaseId<=0)throw RangeError(`wire lease id space exhausted`);return this.nextWireLeaseId++}arrayBufferTransferBytes(e){let t=0;for(let n of e??[])if(n instanceof ArrayBuffer&&(t+=n.byteLength,!Number.isSafeInteger(t)))throw RangeError(`ArrayBuffer transfer bytes overflow`);return t}maybeUnregisterCompleted(){this.completed&&this.leases.size===0&&this.unregisterCleanup()}resourceUsage(){return this.options.driver.resourceUsage?.()}errorResourceUsage(){try{return this.resourceUsage()}catch{return}}};function De(e){try{let t=e(e=>e.document_cursor_resource_usage?.());return t?I(t):void 0}catch(e){if(String(e).includes(`document cursor usage is unavailable`))return;throw e}}const J=67108864;var Y=class{coordinator=new q;host=null;identity=null;constructor(e,t=e=>e(this.requireArchive())){this.archive=e,this.executeArchive=t}open(e){if(this.host)throw Error(`a DOCX document pull session is already active`);this.executeArchive(t=>{t.open_document_cursor(e.operationId,e.generation)});let t=0;this.identity=e,this.host=new Ee({...e,maxByteCredit:J,coordinator:this.coordinator,driver:{pull:n=>{let r;try{r=this.executeArchive(r=>r.pull_document_chunk(t,e.operationId,e.generation,n))}catch(e){throw me(e,n,J)||e}let i=Ce(r);return{payload:i,byteLength:i.byteLength,done:this.executeArchive(e=>e.document_chunk_done()),transfer:[i]}},measureChunk:({payload:e})=>e.byteLength,acknowledge:n=>{if(n!==t)throw Error(`DOCX document acknowledgement sequence mismatch`);this.executeArchive(n=>n.acknowledge_document_chunk(t,e.operationId,e.generation)),t+=1},cancel:()=>this.executeArchive(e=>e.cancel_document_cursor()),close:()=>this.executeArchive(e=>e.close_document_session()),resourceUsage:()=>De(this.executeArchive)}})}dispatch(e,t){return!this.host||!this.identity?(t({protocol:G,kind:`error`,sessionId:e.sessionId,operationId:e.operationId,generation:e.generation,requestId:e.requestId,error:W(Error(`DOCX document pull session is not open`))}),Promise.resolve()):this.host.dispatch(e,t)}async reset(){if(this.host)try{this.archive()&&this.executeArchive(e=>e.close_document_session())}finally{this.host=null,this.identity=null,this.coordinator=new q}}requireArchive(){let e=this.archive();if(!e)throw Error(`No docx loaded`);return e}};function Oe(e){return!!e&&typeof e==`object`&&e.protocol===`ooxml-pull-v1`}const X=new de(y,{freeArchive:e=>e.free(),reinit:b}),Z=new Y(()=>X.archive,e=>X.run(()=>{let t=X.archive;if(!t)throw Error(`No docx loaded`);return e(t)}));let Q=0;const $=(e,t)=>self.postMessage(e,t);self.onmessage=async e=>{let n=e.data;if(Oe(n)){try{await Z.dispatch(n,$)}catch(e){$({protocol:G,kind:`error`,sessionId:n.sessionId,operationId:n.operationId,generation:n.generation,requestId:n.requestId,error:W(e)})}return}if(n.type===`init`){X.setWasmInput(oe(n.wasmUrl)??n.wasmUrl);return}let r=n.id;try{if(await X.ensureReady(),n.type!==`parse`&&X.archive){let e=X.archive;X.run(()=>e.assert_healthy())}if(n.type===`parse`){await Z.reset();let[e,i,a]=we(n.resourcePolicy),o=new Uint8Array(n.data);X.run(()=>{let n=new t(o,e,i,a);X.setArchive(n)}),Q+=1;let s={sessionId:Q,operationId:Q,generation:Q};Z.open(s),$({type:`documentSessionOpened`,id:r,...s});return}let e=X.archive;if(n.type===`extractImage`){if(!e)throw Error(`No docx loaded`);let t=X.run(()=>e.extract_image(n.path).buffer),i={type:`imageExtracted`,id:r,bytes:t};self.postMessage(i,[t]);return}if(n.type===`resourceUsage`){if(!e)throw Error(`No docx loaded`);$({type:`resourceUsage`,id:r,usage:I(X.run(()=>e.resource_usage()))});return}if(n.type===`toMarkdown`){if(!e)throw Error(`No docx loaded`);$({type:`markdownRendered`,id:r,markdown:X.run(()=>e.to_markdown())});return}}catch(e){$({type:`error`,id:r,...W(e)})}};", Pt = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", Nt], { type: "text/javascript;charset=utf-8" });
|
|
258
|
+
function Ft(e) {
|
|
150
259
|
let t;
|
|
151
260
|
try {
|
|
152
|
-
if (t =
|
|
261
|
+
if (t = Pt && (self.URL || self.webkitURL).createObjectURL(Pt), !t) throw "";
|
|
153
262
|
let n = new Worker(t, {
|
|
154
263
|
type: "module",
|
|
155
264
|
name: e?.name
|
|
@@ -158,7 +267,7 @@ function xt(e) {
|
|
|
158
267
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
159
268
|
}), n;
|
|
160
269
|
} catch {
|
|
161
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
270
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Nt), {
|
|
162
271
|
type: "module",
|
|
163
272
|
name: e?.name
|
|
164
273
|
});
|
|
@@ -166,17 +275,17 @@ function xt(e) {
|
|
|
166
275
|
}
|
|
167
276
|
//#endregion
|
|
168
277
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
169
|
-
var
|
|
278
|
+
var It = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
170
279
|
//#endregion
|
|
171
280
|
//#region packages/docx/src/bookmark-nav.ts
|
|
172
|
-
function
|
|
281
|
+
function Lt(e) {
|
|
173
282
|
let t = /* @__PURE__ */ new Map();
|
|
174
283
|
for (let n of e.pages) for (let e of n.bookmarkStarts) e.name !== "" && !t.has(e.name) && t.set(e.name, n.pageIndex);
|
|
175
284
|
return t;
|
|
176
285
|
}
|
|
177
286
|
//#endregion
|
|
178
287
|
//#region packages/docx/src/embedded-fonts.ts
|
|
179
|
-
async function
|
|
288
|
+
async function Rt(e, t) {
|
|
180
289
|
let n = e.embeddedFonts;
|
|
181
290
|
if (!n || n.length === 0) return {
|
|
182
291
|
faces: [],
|
|
@@ -184,7 +293,7 @@ async function wt(e, t) {
|
|
|
184
293
|
};
|
|
185
294
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
186
295
|
for (let e of n) {
|
|
187
|
-
let t =
|
|
296
|
+
let t = zt(e.style) === "bold" ? 700 : 400, n = Bt(e.style), a = `${je(e.fontName)}:${t}:${n}`;
|
|
188
297
|
i.has(a) || (i.add(a), r.push(e));
|
|
189
298
|
}
|
|
190
299
|
let a = (await Promise.all(r.map(async (e) => {
|
|
@@ -194,23 +303,23 @@ async function wt(e, t) {
|
|
|
194
303
|
bytes: n,
|
|
195
304
|
odttf: r,
|
|
196
305
|
fontKey: e.fontKey,
|
|
197
|
-
weight:
|
|
198
|
-
style:
|
|
306
|
+
weight: zt(e.style),
|
|
307
|
+
style: Bt(e.style)
|
|
199
308
|
};
|
|
200
|
-
if (!
|
|
309
|
+
if (!De(n)) return {
|
|
201
310
|
face: i,
|
|
202
311
|
metric: null
|
|
203
312
|
};
|
|
204
313
|
let a = i, o = null;
|
|
205
314
|
try {
|
|
206
|
-
let t = r ?
|
|
315
|
+
let t = r ? Se(n, e.fontKey ?? "") : n;
|
|
207
316
|
a = {
|
|
208
317
|
...i,
|
|
209
318
|
bytes: t,
|
|
210
319
|
odttf: !1,
|
|
211
320
|
fontKey: ""
|
|
212
321
|
};
|
|
213
|
-
let s =
|
|
322
|
+
let s = jt(t), c = s?.hasEastAsianCmap ? Ne(s) : 0;
|
|
214
323
|
c > 0 && (o = Object.freeze({
|
|
215
324
|
family: e.fontName,
|
|
216
325
|
requestedFamily: e.fontName,
|
|
@@ -233,13 +342,13 @@ async function wt(e, t) {
|
|
|
233
342
|
faces: [],
|
|
234
343
|
metrics: {}
|
|
235
344
|
};
|
|
236
|
-
let o = await
|
|
345
|
+
let o = await ye(a.map((e) => e.face)), s = new Set(o.map((e) => {
|
|
237
346
|
let t = e.family.trim().replace(/^(['"])(.*)\1$/, "$2"), n = e.weight === "bold" ? 700 : Number(e.weight) || 400, r = e.style === "italic" ? "italic" : "normal";
|
|
238
|
-
return `${
|
|
347
|
+
return `${je(t)}:${n}:${r}`;
|
|
239
348
|
})), c = {};
|
|
240
349
|
for (let e of a) {
|
|
241
350
|
if (!e.metric) continue;
|
|
242
|
-
let t =
|
|
351
|
+
let t = je(e.face.family), n = e.face.weight === "bold" ? 700 : 400, r = e.face.style, i = `${t}:${n}:${r}`;
|
|
243
352
|
s.has(i) && (c[n === 400 && r === "normal" ? t : i] = e.metric);
|
|
244
353
|
}
|
|
245
354
|
return {
|
|
@@ -247,16 +356,16 @@ async function wt(e, t) {
|
|
|
247
356
|
metrics: Object.freeze(c)
|
|
248
357
|
};
|
|
249
358
|
}
|
|
250
|
-
function
|
|
359
|
+
function zt(e) {
|
|
251
360
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
252
361
|
}
|
|
253
|
-
function
|
|
362
|
+
function Bt(e) {
|
|
254
363
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
255
364
|
}
|
|
256
365
|
//#endregion
|
|
257
366
|
//#region packages/docx/src/element-context.ts
|
|
258
|
-
var
|
|
259
|
-
function
|
|
367
|
+
var F = pe, Vt = 16384;
|
|
368
|
+
function Ht(e, t) {
|
|
260
369
|
let n = Math.min(e.length, t);
|
|
261
370
|
if (n > 0 && n < e.length) {
|
|
262
371
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -264,7 +373,7 @@ function Ot(e, t) {
|
|
|
264
373
|
}
|
|
265
374
|
return e.slice(0, n);
|
|
266
375
|
}
|
|
267
|
-
function
|
|
376
|
+
function Ut(e, t) {
|
|
268
377
|
let n = [], r = 0, i = !1;
|
|
269
378
|
for (let a of e) {
|
|
270
379
|
if (a.length === 0) continue;
|
|
@@ -275,7 +384,7 @@ function kt(e, t) {
|
|
|
275
384
|
}
|
|
276
385
|
n.push("\n"), r++;
|
|
277
386
|
}
|
|
278
|
-
let e =
|
|
387
|
+
let e = Ht(a, Math.max(0, t - r));
|
|
279
388
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
280
389
|
i = !0;
|
|
281
390
|
break;
|
|
@@ -287,7 +396,7 @@ function kt(e, t) {
|
|
|
287
396
|
truncated: i
|
|
288
397
|
};
|
|
289
398
|
}
|
|
290
|
-
function*
|
|
399
|
+
function* I(e) {
|
|
291
400
|
if (e.kind === "paragraph") {
|
|
292
401
|
for (let t of e.lines) {
|
|
293
402
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -296,42 +405,42 @@ function* R(e) {
|
|
|
296
405
|
return;
|
|
297
406
|
}
|
|
298
407
|
if (e.kind === "table") {
|
|
299
|
-
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield*
|
|
408
|
+
for (let t of e.rows) for (let e of t.cells) for (let t of e.blocks) yield* I(t.layout);
|
|
300
409
|
return;
|
|
301
410
|
}
|
|
302
|
-
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield*
|
|
411
|
+
if (e.kind === "note" || e.kind === "textbox") for (let t of e.story.blocks) yield* I(t);
|
|
303
412
|
}
|
|
304
|
-
function*
|
|
413
|
+
function* Wt(e) {
|
|
305
414
|
for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
|
|
306
|
-
for (let t of e.textBoxes) yield*
|
|
415
|
+
for (let t of e.textBoxes) yield* I(t);
|
|
307
416
|
}
|
|
308
|
-
function
|
|
309
|
-
let t = e ??
|
|
417
|
+
function Gt(e) {
|
|
418
|
+
let t = e ?? Vt;
|
|
310
419
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
311
|
-
return Math.min(
|
|
420
|
+
return Math.min(F, Math.floor(t));
|
|
312
421
|
}
|
|
313
|
-
function
|
|
422
|
+
function Kt(e) {
|
|
314
423
|
return {
|
|
315
424
|
story: e.story,
|
|
316
425
|
storyInstance: e.storyInstance,
|
|
317
426
|
path: [...e.path]
|
|
318
427
|
};
|
|
319
428
|
}
|
|
320
|
-
function
|
|
429
|
+
function qt(e) {
|
|
321
430
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
322
431
|
}
|
|
323
|
-
function
|
|
324
|
-
let t =
|
|
325
|
-
|
|
326
|
-
|
|
432
|
+
function Jt(e) {
|
|
433
|
+
let t = qt(e), n = [
|
|
434
|
+
T(e.pointToPage, t),
|
|
435
|
+
T(e.pointToPage, {
|
|
327
436
|
xPt: t.xPt + t.widthPt,
|
|
328
437
|
yPt: t.yPt
|
|
329
438
|
}),
|
|
330
|
-
|
|
439
|
+
T(e.pointToPage, {
|
|
331
440
|
xPt: t.xPt,
|
|
332
441
|
yPt: t.yPt + t.heightPt
|
|
333
442
|
}),
|
|
334
|
-
|
|
443
|
+
T(e.pointToPage, {
|
|
335
444
|
xPt: t.xPt + t.widthPt,
|
|
336
445
|
yPt: t.yPt + t.heightPt
|
|
337
446
|
})
|
|
@@ -343,10 +452,10 @@ function Pt(e) {
|
|
|
343
452
|
heightPt: o - i
|
|
344
453
|
};
|
|
345
454
|
}
|
|
346
|
-
function
|
|
455
|
+
function L(e, t) {
|
|
347
456
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
348
457
|
}
|
|
349
|
-
function
|
|
458
|
+
function Yt(e, t) {
|
|
350
459
|
let n = !1;
|
|
351
460
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
352
461
|
let a = t[r], o = t[i];
|
|
@@ -354,35 +463,35 @@ function Ft(e, t) {
|
|
|
354
463
|
}
|
|
355
464
|
return n;
|
|
356
465
|
}
|
|
357
|
-
function
|
|
358
|
-
return
|
|
466
|
+
function Xt(e, t) {
|
|
467
|
+
return L(e.inkBounds, t) ? e.clip ? e.clip.kind === "rect" ? L(e.clip.rect, t) : Yt(t, e.clip.points) : !0 : !1;
|
|
359
468
|
}
|
|
360
|
-
function
|
|
469
|
+
function Zt(e, t, n) {
|
|
361
470
|
for (let n of e.clips) {
|
|
362
|
-
let e =
|
|
363
|
-
if (!e || !
|
|
471
|
+
let e = Me(n.pointToPage, t);
|
|
472
|
+
if (!e || !L(n.bounds, e)) return !1;
|
|
364
473
|
}
|
|
365
|
-
return "drawing" in e ?
|
|
474
|
+
return "drawing" in e ? Xt(e.drawing, n) : L(e.placement.bounds, n);
|
|
366
475
|
}
|
|
367
|
-
function
|
|
476
|
+
function R(e, t) {
|
|
368
477
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
369
478
|
}
|
|
370
|
-
function
|
|
371
|
-
return
|
|
479
|
+
function Qt(e) {
|
|
480
|
+
return R(e, "chart") ? "chart" : e.commands.some((e) => e.kind === "drawingml-shape" || e.kind === "drawingml-image-fill" || e.kind === "fill-rect" || e.kind === "stroke-rect" || e.kind === "text" || e.kind === "watermark-text") ? "shape" : R(e, "image") ? "image" : null;
|
|
372
481
|
}
|
|
373
|
-
function
|
|
374
|
-
let o = "drawing" in e ?
|
|
482
|
+
function $t(e, t, n, r, i, a) {
|
|
483
|
+
let o = "drawing" in e ? Qt(e.drawing) : e.placement.resourceKind;
|
|
375
484
|
if (!o) return null;
|
|
376
485
|
let s, c = !1, l, u;
|
|
377
486
|
if (o === "chart") {
|
|
378
|
-
let t = "drawing" in e ?
|
|
487
|
+
let t = "drawing" in e ? R(e.drawing, "chart").resourceKey : e.placement.resourceKey, n = i.resolve(t, "chart"), r = ne(n.model, a);
|
|
379
488
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
380
489
|
} else if (o === "image") {
|
|
381
|
-
let t = "drawing" in e ?
|
|
490
|
+
let t = "drawing" in e ? R(e.drawing, "image").resourceKey : e.placement.resourceKey, n = i.descriptors.find((e) => e.resourceKey === t && e.kind === "image" && "mimeType" in e);
|
|
382
491
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
383
492
|
l = n.mimeType;
|
|
384
493
|
} else {
|
|
385
|
-
let t =
|
|
494
|
+
let t = Ut(Wt(e), a);
|
|
386
495
|
s = t.text, c = t.truncated;
|
|
387
496
|
}
|
|
388
497
|
return {
|
|
@@ -392,8 +501,8 @@ function zt(e, t, n, r, i, a) {
|
|
|
392
501
|
elementIndex: n,
|
|
393
502
|
elementType: o,
|
|
394
503
|
point: { ...r },
|
|
395
|
-
bounds:
|
|
396
|
-
source:
|
|
504
|
+
bounds: Jt(e),
|
|
505
|
+
source: Kt("drawing" in e ? e.drawing.source : e.source),
|
|
397
506
|
...s === void 0 ? {} : { text: s },
|
|
398
507
|
...l === void 0 ? {} : { mimeType: l },
|
|
399
508
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -403,26 +512,26 @@ function zt(e, t, n, r, i, a) {
|
|
|
403
512
|
maxTextCharacters: a
|
|
404
513
|
};
|
|
405
514
|
}
|
|
406
|
-
function
|
|
515
|
+
function en(e, t, n, r, i = {}) {
|
|
407
516
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
408
|
-
let a =
|
|
517
|
+
let a = Gt(i.maxTextCharacters), o = Ie(e, t);
|
|
409
518
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
410
|
-
let i = o[e], s =
|
|
411
|
-
if (!s || !
|
|
412
|
-
let c =
|
|
519
|
+
let i = o[e], s = Me(i.pointToPage, n);
|
|
520
|
+
if (!s || !Zt(i, n, s)) continue;
|
|
521
|
+
let c = $t(i, t, e, n, r, a);
|
|
413
522
|
if (c) return c;
|
|
414
523
|
}
|
|
415
524
|
return null;
|
|
416
525
|
}
|
|
417
|
-
function
|
|
418
|
-
return
|
|
526
|
+
function tn(e, t, n, r) {
|
|
527
|
+
return en(Qe(e, {
|
|
419
528
|
currentDate: r.currentDate,
|
|
420
529
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
421
530
|
showTrackedChanges: r.showTrackedChanges
|
|
422
|
-
}, t).layout, t, n,
|
|
531
|
+
}, t).layout, t, n, Oe(e), r);
|
|
423
532
|
}
|
|
424
|
-
function
|
|
425
|
-
let n =
|
|
533
|
+
function nn(e, t) {
|
|
534
|
+
let n = Gt(t), r = e.text === void 0 ? void 0 : Ht(e.text, n), i = e.truncated || e.text !== void 0 && r.length < e.text.length;
|
|
426
535
|
return {
|
|
427
536
|
...structuredClone(e),
|
|
428
537
|
...r === void 0 ? {} : { text: r },
|
|
@@ -434,20 +543,20 @@ function Ht(e, t) {
|
|
|
434
543
|
}
|
|
435
544
|
//#endregion
|
|
436
545
|
//#region packages/docx/src/revisions.ts
|
|
437
|
-
function
|
|
438
|
-
let t =
|
|
546
|
+
function z(e) {
|
|
547
|
+
let t = lt(e.id);
|
|
439
548
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
440
549
|
}
|
|
441
|
-
function
|
|
550
|
+
function B(e) {
|
|
442
551
|
return Object.freeze({
|
|
443
552
|
...e,
|
|
444
553
|
path: Object.freeze([...e.path])
|
|
445
554
|
});
|
|
446
555
|
}
|
|
447
|
-
function
|
|
556
|
+
function rn(e, t) {
|
|
448
557
|
return e !== void 0 && e.story === t.story && e.storyInstance === t.storyInstance && e.path.length === t.path.length && e.path.every((e, n) => e === t.path[n]);
|
|
449
558
|
}
|
|
450
|
-
function
|
|
559
|
+
function V(e, t) {
|
|
451
560
|
let n = 0, r = e.length;
|
|
452
561
|
for (; n < r;) {
|
|
453
562
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -455,22 +564,22 @@ function Gt(e, t) {
|
|
|
455
564
|
}
|
|
456
565
|
return n;
|
|
457
566
|
}
|
|
458
|
-
function
|
|
567
|
+
function an(e, t) {
|
|
459
568
|
let n = Array(e.length), r;
|
|
460
569
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
461
570
|
n[i] = r;
|
|
462
|
-
let a = e[i], o = t.get(
|
|
571
|
+
let a = e[i], o = t.get(k(a.source))?.[0];
|
|
463
572
|
o !== void 0 && (r = Object.freeze({
|
|
464
|
-
source:
|
|
573
|
+
source: B(a.source),
|
|
465
574
|
sourceRunIndex: o
|
|
466
575
|
}));
|
|
467
576
|
}
|
|
468
577
|
let i = Array(e.length), a;
|
|
469
578
|
for (let n = 0; n < e.length; n += 1) {
|
|
470
579
|
i[n] = a;
|
|
471
|
-
let r = e[n], o = t.get(
|
|
580
|
+
let r = e[n], o = t.get(k(r.source))?.at(-1);
|
|
472
581
|
o !== void 0 && (a = Object.freeze({
|
|
473
|
-
source:
|
|
582
|
+
source: B(r.source),
|
|
474
583
|
sourceRunIndex: o
|
|
475
584
|
}));
|
|
476
585
|
}
|
|
@@ -479,17 +588,17 @@ function Kt(e, t) {
|
|
|
479
588
|
preceding: i
|
|
480
589
|
};
|
|
481
590
|
}
|
|
482
|
-
function
|
|
483
|
-
let o = r[e], s = i.get(
|
|
591
|
+
function on(e, t, n, r, i, a) {
|
|
592
|
+
let o = r[e], s = i.get(k(o.source)) ?? [], c = s[V(s, n)], l = s[V(s, t) - 1], u = c ?? l;
|
|
484
593
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
485
|
-
source:
|
|
594
|
+
source: B(o.source),
|
|
486
595
|
sourceRunIndex: u
|
|
487
596
|
});
|
|
488
597
|
}
|
|
489
|
-
function
|
|
598
|
+
function sn(e, t, n = /* @__PURE__ */ new Map()) {
|
|
490
599
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
491
600
|
e.forEach((e, t) => {
|
|
492
|
-
let n =
|
|
601
|
+
let n = z(e);
|
|
493
602
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
494
603
|
});
|
|
495
604
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -499,11 +608,11 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
499
608
|
source: e,
|
|
500
609
|
runs: n.runs
|
|
501
610
|
}] : [];
|
|
502
|
-
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s =
|
|
611
|
+
}), o = new Map([...n].map(([e, t]) => [e, Object.freeze([...t].sort((e, t) => e - t))])), s = an(a, o), c = [];
|
|
503
612
|
for (let [e, t] of a.entries()) {
|
|
504
613
|
let n = 0;
|
|
505
614
|
for (; n < t.runs.length;) {
|
|
506
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
615
|
+
let i = t.runs[n], l = i.revision?.kind ? z({
|
|
507
616
|
kind: i.revision.kind,
|
|
508
617
|
id: i.revision.id
|
|
509
618
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -514,16 +623,16 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
514
623
|
let d = n;
|
|
515
624
|
for (n += 1; n < t.runs.length;) {
|
|
516
625
|
let e = t.runs[n].revision;
|
|
517
|
-
if (!e?.kind ||
|
|
626
|
+
if (!e?.kind || z({
|
|
518
627
|
kind: e.kind,
|
|
519
628
|
id: e.id
|
|
520
629
|
}) !== l) break;
|
|
521
630
|
n += 1;
|
|
522
631
|
}
|
|
523
|
-
let f = n, p = o.get(
|
|
632
|
+
let f = n, p = o.get(k(t.source)) ?? [], m = (p[V(p, d)] ?? f) < f ? void 0 : on(e, d, f, a, o, s);
|
|
524
633
|
c.push(Object.freeze({
|
|
525
634
|
revisionIndex: u,
|
|
526
|
-
source:
|
|
635
|
+
source: B(t.source),
|
|
527
636
|
startRunIndex: d,
|
|
528
637
|
endRunIndex: f,
|
|
529
638
|
...m === void 0 ? {} : { geometryFallback: m }
|
|
@@ -532,26 +641,26 @@ function Jt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
532
641
|
}
|
|
533
642
|
return c;
|
|
534
643
|
}
|
|
535
|
-
function
|
|
644
|
+
function cn(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
536
645
|
if ((e?.length ?? 0) === 0) return [];
|
|
537
|
-
let i =
|
|
646
|
+
let i = sn(e ?? [], t, n), a = r.completedSourceKeys;
|
|
538
647
|
return a === void 0 ? i : i.filter((e) => {
|
|
539
|
-
let t = n.get(
|
|
540
|
-
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(
|
|
648
|
+
let t = n.get(k(e.source));
|
|
649
|
+
return t !== void 0 && [...t].some((t) => t >= e.startRunIndex && t < e.endRunIndex) || a.has(k(e.source));
|
|
541
650
|
});
|
|
542
651
|
}
|
|
543
|
-
function
|
|
544
|
-
let n = t.filter((t) => t.sourceRunIndex !== void 0 &&
|
|
652
|
+
function ln(e, t) {
|
|
653
|
+
let n = t.filter((t) => t.sourceRunIndex !== void 0 && rn(t.source, e.source) && t.sourceRunIndex >= e.startRunIndex && t.sourceRunIndex < e.endRunIndex);
|
|
545
654
|
if (n.length > 0) return n;
|
|
546
655
|
let r = e.geometryFallback;
|
|
547
|
-
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex &&
|
|
656
|
+
return r === void 0 ? [] : t.filter((e) => e.sourceRunIndex === r.sourceRunIndex && rn(e.source, r.source));
|
|
548
657
|
}
|
|
549
658
|
//#endregion
|
|
550
659
|
//#region packages/docx/src/layout/progressive.ts
|
|
551
|
-
var
|
|
552
|
-
async function
|
|
660
|
+
var un = 12;
|
|
661
|
+
async function dn(e, t, n, r = {}) {
|
|
553
662
|
let { onPreview: i, scheduler: a } = r;
|
|
554
|
-
return
|
|
663
|
+
return Be(Pe(e, t, n, i && e.sequence.length > un ? { onPages: (e, t) => {
|
|
555
664
|
i(Object.freeze({
|
|
556
665
|
layout: e,
|
|
557
666
|
exact: !1,
|
|
@@ -572,7 +681,7 @@ function U(e, t) {
|
|
|
572
681
|
} catch {}
|
|
573
682
|
}
|
|
574
683
|
}
|
|
575
|
-
function
|
|
684
|
+
function fn(e, t, n, r) {
|
|
576
685
|
let i = H.get(e);
|
|
577
686
|
i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
|
|
578
687
|
let a = Object.freeze({
|
|
@@ -593,30 +702,30 @@ function $t(e, t, n, r) {
|
|
|
593
702
|
}
|
|
594
703
|
//#endregion
|
|
595
704
|
//#region packages/docx/src/document-layout-view.ts
|
|
596
|
-
var W = /* @__PURE__ */ new WeakMap(),
|
|
705
|
+
var W = /* @__PURE__ */ new WeakMap(), pn = /* @__PURE__ */ new WeakMap(), mn = Symbol("docxLayoutViewRequester");
|
|
597
706
|
function G(e) {
|
|
598
|
-
let t =
|
|
707
|
+
let t = E(e), n = t.activeLayoutOptions;
|
|
599
708
|
return {
|
|
600
709
|
showTrackedChanges: n?.showTrackedChanges === !0,
|
|
601
710
|
currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
|
|
602
711
|
};
|
|
603
712
|
}
|
|
604
713
|
async function K(e, t, n) {
|
|
605
|
-
let r =
|
|
714
|
+
let r = E(e), i = Ae(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
606
715
|
showTrackedChanges: i.showTrackedChanges === !0,
|
|
607
716
|
currentDate: i.currentDateMs
|
|
608
717
|
}), o = {
|
|
609
718
|
showTrackedChanges: a.showTrackedChanges,
|
|
610
719
|
currentDate: a.currentDate,
|
|
611
|
-
[
|
|
720
|
+
[mn]: n
|
|
612
721
|
};
|
|
613
722
|
await e.setLayoutView(o);
|
|
614
723
|
let s = G(e);
|
|
615
724
|
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
616
725
|
}
|
|
617
|
-
function
|
|
618
|
-
let n = Object.freeze({ ...G(e) }), r = (
|
|
619
|
-
|
|
726
|
+
function hn(e, t) {
|
|
727
|
+
let n = Object.freeze({ ...G(e) }), r = (pn.get(e) ?? 0) + 1;
|
|
728
|
+
pn.set(e, r);
|
|
620
729
|
let i = Object.freeze({
|
|
621
730
|
view: n,
|
|
622
731
|
generation: r,
|
|
@@ -630,7 +739,7 @@ function nn(e, t) {
|
|
|
630
739
|
} catch {}
|
|
631
740
|
}
|
|
632
741
|
}
|
|
633
|
-
function
|
|
742
|
+
function gn(e, t, n) {
|
|
634
743
|
let r = W.get(e);
|
|
635
744
|
r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
|
|
636
745
|
let i = Object.freeze({
|
|
@@ -643,10 +752,10 @@ function rn(e, t, n) {
|
|
|
643
752
|
}
|
|
644
753
|
//#endregion
|
|
645
754
|
//#region packages/docx/src/document.ts
|
|
646
|
-
function
|
|
755
|
+
function _n(e, t) {
|
|
647
756
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
648
757
|
}
|
|
649
|
-
function
|
|
758
|
+
function vn() {
|
|
650
759
|
let e, t;
|
|
651
760
|
return {
|
|
652
761
|
promise: new Promise((n, r) => {
|
|
@@ -656,24 +765,25 @@ function on() {
|
|
|
656
765
|
reject: t
|
|
657
766
|
};
|
|
658
767
|
}
|
|
659
|
-
var
|
|
768
|
+
var yn = Object.freeze([]), bn = Object.freeze([]), xn = Object.freeze({
|
|
660
769
|
comments: Object.freeze([]),
|
|
661
770
|
revisions: Object.freeze([])
|
|
662
771
|
});
|
|
663
772
|
function q(e, t) {
|
|
664
|
-
return
|
|
773
|
+
return He({
|
|
665
774
|
comments: e,
|
|
666
775
|
revisions: t
|
|
667
776
|
}, "DOCX review metadata");
|
|
668
777
|
}
|
|
669
778
|
var J = class e {
|
|
670
779
|
_metrics = null;
|
|
780
|
+
_cjkFallback = "jp";
|
|
671
781
|
_document = null;
|
|
672
782
|
_source = null;
|
|
673
783
|
_meta = null;
|
|
674
|
-
_review =
|
|
675
|
-
_layoutLifecycle = new
|
|
676
|
-
_layoutObservers = new
|
|
784
|
+
_review = xn;
|
|
785
|
+
_layoutLifecycle = new xe();
|
|
786
|
+
_layoutObservers = new we();
|
|
677
787
|
_layoutCompletion = null;
|
|
678
788
|
_layoutAbort = null;
|
|
679
789
|
_bookmarkPages = null;
|
|
@@ -692,19 +802,19 @@ var J = class e {
|
|
|
692
802
|
_tiff;
|
|
693
803
|
_worker;
|
|
694
804
|
_bridge;
|
|
695
|
-
_rawParts = new
|
|
805
|
+
_rawParts = new ct({
|
|
696
806
|
maxEntries: 64,
|
|
697
|
-
maxBytes:
|
|
807
|
+
maxBytes: n
|
|
698
808
|
});
|
|
699
809
|
_embeddedFontFaces = [];
|
|
700
810
|
_googleFontFaces = [];
|
|
701
811
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
702
812
|
constructor(e, t, n, r) {
|
|
703
|
-
this._worker = e, this._mode = t,
|
|
813
|
+
this._worker = e, this._mode = t, ke(this, n), this._bridge = new he(this._worker, {
|
|
704
814
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
705
815
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
706
816
|
toError: (e) => {
|
|
707
|
-
if (!("protocol" in e || e.type !== "error")) return Object.assign(
|
|
817
|
+
if (!("protocol" in e || e.type !== "error")) return Object.assign(a(e), {
|
|
708
818
|
...e.reason === void 0 ? {} : { reason: e.reason },
|
|
709
819
|
...e.outgoingColumnIndex === void 0 ? {} : { outgoingColumnIndex: e.outgoingColumnIndex },
|
|
710
820
|
...e.outgoingColumnCount === void 0 ? {} : { outgoingColumnCount: e.outgoingColumnCount },
|
|
@@ -712,133 +822,134 @@ var J = class e {
|
|
|
712
822
|
});
|
|
713
823
|
}
|
|
714
824
|
});
|
|
715
|
-
let
|
|
825
|
+
let i = new URL(r ?? It, location.href).href;
|
|
716
826
|
this._bridge.post({
|
|
717
827
|
type: "init",
|
|
718
|
-
wasmUrl:
|
|
828
|
+
wasmUrl: i
|
|
719
829
|
});
|
|
720
830
|
}
|
|
721
|
-
static async load(t,
|
|
722
|
-
let i =
|
|
831
|
+
static async load(t, n = {}) {
|
|
832
|
+
let i = tt(n.cjkFallback), a = f(n), o = Date.now(), s = n.mode ?? "main", c = new r({
|
|
723
833
|
enabled: !0,
|
|
724
834
|
format: "docx",
|
|
725
|
-
mode:
|
|
726
|
-
policy:
|
|
727
|
-
onMetrics:
|
|
728
|
-
emitToConsole:
|
|
835
|
+
mode: s,
|
|
836
|
+
policy: a.policy,
|
|
837
|
+
onMetrics: a.onResourceMetrics,
|
|
838
|
+
emitToConsole: a.debug
|
|
729
839
|
});
|
|
730
840
|
try {
|
|
731
|
-
if (
|
|
732
|
-
let
|
|
841
|
+
if (s === "worker" && (typeof Worker > "u" || typeof OffscreenCanvas > "u")) throw Error("mode: 'worker' requires Worker and OffscreenCanvas support");
|
|
842
|
+
let r;
|
|
733
843
|
if (typeof t == "string") {
|
|
734
844
|
let e = await fetch(t);
|
|
735
845
|
if (!e.ok) throw Error(`Failed to fetch: ${e.status} ${e.statusText}`);
|
|
736
|
-
|
|
737
|
-
} else
|
|
738
|
-
|
|
739
|
-
let
|
|
846
|
+
r = await e.arrayBuffer();
|
|
847
|
+
} else r = t;
|
|
848
|
+
r = g(await h(r, n.password)), c.setSourceBytes(r.byteLength), c.checkpoint("container ready");
|
|
849
|
+
let l = s === "worker" ? (await import("./render-worker-host-Di3LxLc0.js")).createRenderWorker() : new Ft(), u = s === "worker" ? ot(n) : void 0, d = s === "worker" && !!n.progressiveLayout, f;
|
|
740
850
|
try {
|
|
741
|
-
|
|
742
|
-
let t =
|
|
743
|
-
t.activeLayoutOptions =
|
|
744
|
-
onPartial:
|
|
745
|
-
onComplete:
|
|
746
|
-
onProgress:
|
|
747
|
-
layoutOptions:
|
|
851
|
+
f = new e(l, s, o, n.wasmUrl), f._metrics = c, f._cjkFallback = i;
|
|
852
|
+
let t = E(f), p = Ae(n.currentDate, t.defaultCurrentDateMs, n.showTrackedChanges === !0);
|
|
853
|
+
t.activeLayoutOptions = p, await f._parse(r, a.policy, s === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => c.observeUsage(e), u, d ? {
|
|
854
|
+
onPartial: n.onLayoutPartial,
|
|
855
|
+
onComplete: n.onLayoutComplete,
|
|
856
|
+
onProgress: n.onLayoutProgress,
|
|
857
|
+
layoutOptions: p,
|
|
748
858
|
abort: new AbortController(),
|
|
749
|
-
firstPublication:
|
|
859
|
+
firstPublication: vn(),
|
|
750
860
|
published: !1,
|
|
751
861
|
settled: !1
|
|
752
|
-
} : void 0),
|
|
753
|
-
let p;
|
|
754
|
-
if (d._mode === "main" && d._document?.embeddedFonts?.length) {
|
|
755
|
-
let e = d, t = await wt(d._document, (t) => e.getFontBytes(t));
|
|
756
|
-
d._embeddedFontFaces = t.faces, p = t.metrics;
|
|
757
|
-
}
|
|
862
|
+
} : void 0), s === "worker" && f._mode === "main" && (c.setMode("main"), console.warn("[ooxml] mode: 'worker' fell back to main-thread rendering because this document requires DOM OpenType vertical glyph selection.")), n.math && f._mode === "worker" && !u?.math && console.warn("[ooxml] a custom math renderer cannot cross the worker boundary; equations will be skipped in mode: 'worker'. Use the math renderer from @silurus/ooxml/math."), n.threeD && f._mode === "worker" && !u?.threeD && console.warn("[ooxml] a custom 3-D chart renderer cannot cross the worker boundary; charts use their 2-D family fallback in mode: 'worker'. Use the renderer from @silurus/ooxml/three-d."), f._threeD = f._mode === "worker" ? void 0 : n.threeD, n.regionMap && f._mode === "worker" && !u?.regionMap && console.warn("[ooxml] a custom Region Map renderer cannot cross the worker boundary; geospatial charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/region-map."), f._regionMap = f._mode === "worker" ? void 0 : n.regionMap, n.chartEx && f._mode === "worker" && !u?.chartEx && console.warn("[ooxml] a custom ChartEx renderer cannot cross the worker boundary; ChartEx charts use the unsupported-chart placeholder in mode: 'worker'. Use the renderer from @silurus/ooxml/chart-ex."), f._chartEx = f._mode === "worker" ? void 0 : n.chartEx, n.tiff && f._mode === "worker" && !u?.tiff && console.warn("[ooxml] a custom TIFF codec cannot cross the worker boundary; recognized TIFF images will use an unavailable-image placeholder in mode: 'worker'. Use the codec from @silurus/ooxml/tiff to display them."), f._tiff = f._mode === "worker" ? void 0 : n.tiff, f._mode === "main" && n.useGoogleFonts && f._document && (f._googleFontFaces = await m(ze(f._document, i), Re));
|
|
758
863
|
let h;
|
|
759
|
-
if (
|
|
760
|
-
let e =
|
|
761
|
-
|
|
762
|
-
|
|
864
|
+
if (f._mode === "main" && f._document?.embeddedFonts?.length) {
|
|
865
|
+
let e = f, t = await Rt(f._document, (t) => e.getFontBytes(t));
|
|
866
|
+
f._embeddedFontFaces = t.faces, h = t.metrics;
|
|
867
|
+
}
|
|
868
|
+
let g;
|
|
869
|
+
if (f._mode === "main" && n.math && f._document && qe(f._document) && (g = await Ye(f._document, n.math)), f._mode === "main" && f._document && f._source) {
|
|
870
|
+
let e = f, t = E(f);
|
|
871
|
+
t.services = We(f._source, {
|
|
872
|
+
fontMetrics: h,
|
|
763
873
|
measureResolvedFontMetrics: !0,
|
|
764
|
-
resolvedFontMetricCandidates:
|
|
765
|
-
useGoogleFonts: !!
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
874
|
+
resolvedFontMetricCandidates: Je(f._document, f._source.fontFamilyCharsets),
|
|
875
|
+
useGoogleFonts: !!n.useGoogleFonts,
|
|
876
|
+
cjkFallback: i,
|
|
877
|
+
embeddedFaces: f._embeddedFontFaces,
|
|
878
|
+
googleFaces: f._googleFontFaces,
|
|
879
|
+
mathResources: g?.records,
|
|
880
|
+
mathDrawables: g?.drawables
|
|
770
881
|
});
|
|
771
|
-
let
|
|
772
|
-
if (!
|
|
773
|
-
let
|
|
774
|
-
if (
|
|
775
|
-
let e =
|
|
776
|
-
t._layoutAbort =
|
|
777
|
-
let
|
|
778
|
-
t._layoutCompletion =
|
|
882
|
+
let r = t.services, a = Fe(f._source, r, t.defaultCurrentDateMs), o = f._source.fatalParse === null, s = t.activeLayoutOptions;
|
|
883
|
+
if (!s) throw Error("Active layout view was not recorded at load");
|
|
884
|
+
let c = { onProgress: n.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", n.onLayoutProgress, { committedUnits: t }) : void 0 };
|
|
885
|
+
if (o && n.progressiveLayout) {
|
|
886
|
+
let e = a.layoutVariants, t = f, i = new AbortController();
|
|
887
|
+
t._layoutAbort = i;
|
|
888
|
+
let o = vn(), l = null, u = !0;
|
|
889
|
+
t._layoutCompletion = dn(f._source.bodyLayoutInput, r, s, {
|
|
779
890
|
scheduler: {
|
|
780
|
-
...
|
|
781
|
-
signal:
|
|
891
|
+
...c,
|
|
892
|
+
signal: i.signal
|
|
782
893
|
},
|
|
783
|
-
onPreview: (
|
|
894
|
+
onPreview: (r) => {
|
|
784
895
|
if (!u) return;
|
|
785
|
-
let i = l === null, a = t._replaceMainLayoutPublication(e,
|
|
896
|
+
let i = l === null, a = t._replaceMainLayoutPublication(e, s, l, r.layout);
|
|
786
897
|
if (a === null) {
|
|
787
898
|
u = !1;
|
|
788
899
|
return;
|
|
789
900
|
}
|
|
790
901
|
if (l = a, i) t._layoutLifecycle.begin(), U(t, {
|
|
791
|
-
pageCount:
|
|
792
|
-
exact:
|
|
902
|
+
pageCount: r.layout.pages.length,
|
|
903
|
+
exact: r.exact,
|
|
793
904
|
complete: !1
|
|
794
|
-
}),
|
|
905
|
+
}), o.resolve();
|
|
795
906
|
else {
|
|
796
|
-
if (!t._isLayoutViewActive(
|
|
907
|
+
if (!t._isLayoutViewActive(s)) return;
|
|
797
908
|
U(t, {
|
|
798
|
-
pageCount:
|
|
799
|
-
exact:
|
|
909
|
+
pageCount: r.layout.pages.length,
|
|
910
|
+
exact: r.exact,
|
|
800
911
|
complete: !1
|
|
801
|
-
}), t._layoutObservers.notify("onLayoutPartial",
|
|
802
|
-
availableUnits:
|
|
803
|
-
exact:
|
|
912
|
+
}), t._layoutObservers.notify("onLayoutPartial", n.onLayoutPartial, {
|
|
913
|
+
availableUnits: r.layout.pages.length,
|
|
914
|
+
exact: r.exact
|
|
804
915
|
});
|
|
805
916
|
}
|
|
806
917
|
}
|
|
807
|
-
}).then((
|
|
808
|
-
u && t._replaceMainLayoutPublication(e,
|
|
918
|
+
}).then((r) => {
|
|
919
|
+
u && t._replaceMainLayoutPublication(e, s, l, r) === null && (u = !1), t._layoutLifecycle.succeed(), U(t, {
|
|
809
920
|
pageCount: t.pageCount,
|
|
810
921
|
exact: !0,
|
|
811
922
|
complete: !0
|
|
812
|
-
}),
|
|
923
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete), o.resolve();
|
|
813
924
|
}).catch((e) => {
|
|
814
925
|
if (l === null) {
|
|
815
|
-
|
|
926
|
+
o.reject(e);
|
|
816
927
|
return;
|
|
817
928
|
}
|
|
818
|
-
if (e instanceof
|
|
929
|
+
if (e instanceof Ve) {
|
|
819
930
|
t._layoutLifecycle.succeed();
|
|
820
931
|
return;
|
|
821
932
|
}
|
|
822
|
-
let
|
|
933
|
+
let r = t._layoutLifecycle.fail(e);
|
|
823
934
|
U(t, {
|
|
824
935
|
pageCount: t.pageCount,
|
|
825
936
|
exact: !1,
|
|
826
937
|
complete: !1,
|
|
827
|
-
error:
|
|
828
|
-
}), t._layoutObservers.notify("onLayoutComplete",
|
|
829
|
-
}), await
|
|
830
|
-
} else if (
|
|
831
|
-
let e = await
|
|
832
|
-
|
|
833
|
-
} else
|
|
938
|
+
error: r
|
|
939
|
+
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete, r);
|
|
940
|
+
}), await o.promise;
|
|
941
|
+
} else if (o && (n.sliceLayout || n.onLayoutProgress)) {
|
|
942
|
+
let e = await Ge(f._source.bodyLayoutInput, r, s, c);
|
|
943
|
+
a.layoutVariants.prime(s, e);
|
|
944
|
+
} else a.layoutVariants.layoutFor(s);
|
|
834
945
|
}
|
|
835
|
-
return await
|
|
946
|
+
return await f._resourceUsage(n.workerTimeoutMs ?? 1e3).then((e) => c.observeUsage(e), () => void 0), c.checkpoint("model and layout ready"), c.succeed({ pages: f.pageCount }), f;
|
|
836
947
|
} catch (e) {
|
|
837
|
-
let t =
|
|
838
|
-
throw p(
|
|
948
|
+
let t = f;
|
|
949
|
+
throw p(l, t ? () => t.destroy() : void 0), e;
|
|
839
950
|
}
|
|
840
951
|
} catch (e) {
|
|
841
|
-
throw
|
|
952
|
+
throw c.fail(e), e;
|
|
842
953
|
}
|
|
843
954
|
}
|
|
844
955
|
async _parse(e, t, n = !1, r, i, a, o) {
|
|
@@ -852,7 +963,8 @@ var J = class e {
|
|
|
852
963
|
data: e,
|
|
853
964
|
resourcePolicy: t,
|
|
854
965
|
useGoogleFonts: n,
|
|
855
|
-
|
|
966
|
+
cjkFallback: this._cjkFallback,
|
|
967
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
856
968
|
...this._parseViewFields(),
|
|
857
969
|
renderers: a
|
|
858
970
|
} : {
|
|
@@ -863,14 +975,14 @@ var J = class e {
|
|
|
863
975
|
}, [e], { timeoutMs: r });
|
|
864
976
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
865
977
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
866
|
-
let e = await
|
|
978
|
+
let e = await Ke(this._bridge.transport(Xe), s, {
|
|
867
979
|
timeoutMs: r,
|
|
868
980
|
onUsage: i
|
|
869
981
|
});
|
|
870
982
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
871
983
|
} else this._meta = s.meta;
|
|
872
984
|
else {
|
|
873
|
-
let e = s, t = await
|
|
985
|
+
let e = s, t = await Ke(this._bridge.transport(Xe), e, {
|
|
874
986
|
timeoutMs: r,
|
|
875
987
|
onUsage: i
|
|
876
988
|
});
|
|
@@ -941,7 +1053,7 @@ var J = class e {
|
|
|
941
1053
|
pageCount: this.pageCount,
|
|
942
1054
|
exact: !0,
|
|
943
1055
|
complete: !0
|
|
944
|
-
}), t.firstPublication.resolve(),
|
|
1056
|
+
}), t.firstPublication.resolve(), this._layoutObservers.notify("onLayoutComplete", t.onComplete));
|
|
945
1057
|
}
|
|
946
1058
|
}
|
|
947
1059
|
_invalidateLayoutDerivedCaches() {
|
|
@@ -952,7 +1064,7 @@ var J = class e {
|
|
|
952
1064
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
953
1065
|
}
|
|
954
1066
|
_isLayoutViewActive(e) {
|
|
955
|
-
return
|
|
1067
|
+
return _n(E(this).activeLayoutOptions, e);
|
|
956
1068
|
}
|
|
957
1069
|
_rearmParseWatchdog() {
|
|
958
1070
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -981,7 +1093,7 @@ var J = class e {
|
|
|
981
1093
|
}), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
|
|
982
1094
|
}
|
|
983
1095
|
_parseViewFields() {
|
|
984
|
-
let e =
|
|
1096
|
+
let e = E(this), t = e.activeLayoutOptions;
|
|
985
1097
|
return t ? {
|
|
986
1098
|
...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
|
|
987
1099
|
...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
|
|
@@ -994,7 +1106,8 @@ var J = class e {
|
|
|
994
1106
|
data: e,
|
|
995
1107
|
resourcePolicy: t,
|
|
996
1108
|
useGoogleFonts: n,
|
|
997
|
-
|
|
1109
|
+
cjkFallback: this._cjkFallback,
|
|
1110
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
998
1111
|
...this._parseViewFields(),
|
|
999
1112
|
renderers: a,
|
|
1000
1113
|
progressiveLayout: !0
|
|
@@ -1002,7 +1115,7 @@ var J = class e {
|
|
|
1002
1115
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
1003
1116
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
1004
1117
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
1005
|
-
let t = await
|
|
1118
|
+
let t = await Ke(this._bridge.transport(Xe), e, {
|
|
1006
1119
|
timeoutMs: r,
|
|
1007
1120
|
onUsage: i
|
|
1008
1121
|
});
|
|
@@ -1021,7 +1134,7 @@ var J = class e {
|
|
|
1021
1134
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
1022
1135
|
}
|
|
1023
1136
|
destroy() {
|
|
1024
|
-
this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review =
|
|
1137
|
+
this._layoutAbort?.abort(), this._layoutAbort = null, this._clearParseWatchdog(), this._parseRequestId = null, this._progressive = null, this._layoutViewGeneration++, this._bridge.terminate(), this._document = null, this._source = null, this._meta = null, this._review = xn, E(this).services = null, this._bookmarkPages = null, this._commentAnchorRanges = null, this._revisionAnchorRanges = null, this._reviewProjectionIndex = null, this._rawParts.clear(), this._embeddedFontFaces.length > 0 && (be(this._embeddedFontFaces), this._embeddedFontFaces = []), this._googleFontFaces.length > 0 && (_(this._googleFontFaces), this._googleFontFaces = []), s(this._fetchImage), l(this._fetchImage);
|
|
1025
1138
|
}
|
|
1026
1139
|
async getImage(e, t) {
|
|
1027
1140
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -1050,7 +1163,7 @@ var J = class e {
|
|
|
1050
1163
|
async getResourceMetrics() {
|
|
1051
1164
|
let e = this._metrics;
|
|
1052
1165
|
if (!e) throw Error("Document not loaded");
|
|
1053
|
-
return
|
|
1166
|
+
return i(e, (e) => this._resourceUsage(e));
|
|
1054
1167
|
}
|
|
1055
1168
|
async toMarkdown() {
|
|
1056
1169
|
return (await this._bridge.request((e) => ({
|
|
@@ -1082,32 +1195,32 @@ var J = class e {
|
|
|
1082
1195
|
return this._reviewSnapshot().revisions;
|
|
1083
1196
|
}
|
|
1084
1197
|
commentAnchorRanges() {
|
|
1085
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
1198
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? yn;
|
|
1086
1199
|
if (!this._document || !this._source) return [];
|
|
1087
1200
|
let e = this._reviewSnapshot().comments;
|
|
1088
|
-
if (e.length === 0) return
|
|
1089
|
-
let t =
|
|
1201
|
+
if (e.length === 0) return yn;
|
|
1202
|
+
let t = E(this), n = t.services;
|
|
1090
1203
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1091
|
-
let r =
|
|
1204
|
+
let r = Ue(n);
|
|
1092
1205
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1093
1206
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1094
|
-
this._reviewProjectionIndex ??=
|
|
1207
|
+
this._reviewProjectionIndex ??= $e(a);
|
|
1095
1208
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1096
|
-
return this._commentAnchorRanges ??=
|
|
1209
|
+
return this._commentAnchorRanges ??= dt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
1097
1210
|
}
|
|
1098
1211
|
revisionAnchorRanges() {
|
|
1099
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
1212
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? bn;
|
|
1100
1213
|
if (!this._document || !this._source) return [];
|
|
1101
1214
|
let e = this._reviewSnapshot().revisions;
|
|
1102
|
-
if (e.length === 0) return
|
|
1103
|
-
let t =
|
|
1215
|
+
if (e.length === 0) return bn;
|
|
1216
|
+
let t = E(this), n = t.services;
|
|
1104
1217
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1105
|
-
let r =
|
|
1218
|
+
let r = Ue(n);
|
|
1106
1219
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1107
1220
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1108
|
-
this._reviewProjectionIndex ??=
|
|
1221
|
+
this._reviewProjectionIndex ??= $e(a);
|
|
1109
1222
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1110
|
-
return this._revisionAnchorRanges ??=
|
|
1223
|
+
return this._revisionAnchorRanges ??= cn(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
1111
1224
|
}
|
|
1112
1225
|
_reviewSnapshot() {
|
|
1113
1226
|
return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
@@ -1120,16 +1233,16 @@ var J = class e {
|
|
|
1120
1233
|
}
|
|
1121
1234
|
_getLayout() {
|
|
1122
1235
|
if (!this._document) return null;
|
|
1123
|
-
let e =
|
|
1236
|
+
let e = E(this), t = e.services;
|
|
1124
1237
|
if (!t) throw Error("Document layout services are not initialized");
|
|
1125
|
-
let n =
|
|
1238
|
+
let n = Ue(t);
|
|
1126
1239
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
1127
1240
|
let r = e.activeLayoutOptions;
|
|
1128
1241
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
1129
1242
|
}
|
|
1130
1243
|
async setLayoutView(e = {}) {
|
|
1131
|
-
let t = e[
|
|
1132
|
-
if (!
|
|
1244
|
+
let t = e[mn], n = E(this), r = Ae(e.currentDate, n.defaultCurrentDateMs, e.showTrackedChanges === !0), i = ++this._layoutViewGeneration, a = n.activeLayoutOptions;
|
|
1245
|
+
if (!_n(a, r)) {
|
|
1133
1246
|
if (this._mode === "worker" && this._meta) {
|
|
1134
1247
|
let e = await this._bridge.request((e) => ({
|
|
1135
1248
|
type: "selectLayoutView",
|
|
@@ -1142,17 +1255,17 @@ var J = class e {
|
|
|
1142
1255
|
n.activeLayoutOptions = r, this._meta = {
|
|
1143
1256
|
...this._meta,
|
|
1144
1257
|
...a.meta
|
|
1145
|
-
}, this._invalidateLayoutDerivedCaches(),
|
|
1258
|
+
}, this._invalidateLayoutDerivedCaches(), hn(this, t);
|
|
1146
1259
|
return;
|
|
1147
1260
|
}
|
|
1148
|
-
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(),
|
|
1261
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), hn(this, t);
|
|
1149
1262
|
}
|
|
1150
1263
|
}
|
|
1151
1264
|
_getBookmarkPages() {
|
|
1152
1265
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
1153
1266
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
1154
1267
|
let e = this._getLayout();
|
|
1155
|
-
return e ? (this._bookmarkPages =
|
|
1268
|
+
return e ? (this._bookmarkPages = Lt(e), this._bookmarkPages) : null;
|
|
1156
1269
|
}
|
|
1157
1270
|
getBookmarkPage(e) {
|
|
1158
1271
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -1184,7 +1297,7 @@ var J = class e {
|
|
|
1184
1297
|
};
|
|
1185
1298
|
}
|
|
1186
1299
|
_withActiveView(e) {
|
|
1187
|
-
let t =
|
|
1300
|
+
let t = E(this).activeLayoutOptions;
|
|
1188
1301
|
if (!t) return e;
|
|
1189
1302
|
let n = { ...e };
|
|
1190
1303
|
return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
|
|
@@ -1192,11 +1305,11 @@ var J = class e {
|
|
|
1192
1305
|
renderPage(e, t, n = {}) {
|
|
1193
1306
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1194
1307
|
if (!this._source) throw Error("Document not loaded");
|
|
1195
|
-
return
|
|
1308
|
+
return Le(this._source, e, t, {
|
|
1196
1309
|
...this._withActiveView(n),
|
|
1197
1310
|
fetchImage: this._fetchImage,
|
|
1198
|
-
layoutServices:
|
|
1199
|
-
defaultCurrentDateMs:
|
|
1311
|
+
layoutServices: E(this).services ?? void 0,
|
|
1312
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
1200
1313
|
threeD: this._threeD,
|
|
1201
1314
|
regionMap: this._regionMap,
|
|
1202
1315
|
chartEx: this._chartEx,
|
|
@@ -1236,9 +1349,9 @@ var J = class e {
|
|
|
1236
1349
|
pageIndex: e,
|
|
1237
1350
|
opts: n
|
|
1238
1351
|
}))).runs;
|
|
1239
|
-
let r =
|
|
1352
|
+
let r = E(this), i = r.services;
|
|
1240
1353
|
if (!i) throw Error("Document layout services are not initialized");
|
|
1241
|
-
return
|
|
1354
|
+
return et(i, e, {
|
|
1242
1355
|
currentDate: n.currentDate,
|
|
1243
1356
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
1244
1357
|
width: n.width,
|
|
@@ -1247,7 +1360,7 @@ var J = class e {
|
|
|
1247
1360
|
}
|
|
1248
1361
|
async getCommentThreads(e, t = {}) {
|
|
1249
1362
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1250
|
-
return
|
|
1363
|
+
return ut(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1251
1364
|
}
|
|
1252
1365
|
async getElementContextAt(e, t, n = {}) {
|
|
1253
1366
|
let r = this._withActiveView(n);
|
|
@@ -1258,9 +1371,9 @@ var J = class e {
|
|
|
1258
1371
|
point: t,
|
|
1259
1372
|
opts: r
|
|
1260
1373
|
}))).context;
|
|
1261
|
-
let i =
|
|
1374
|
+
let i = E(this), a = i.services;
|
|
1262
1375
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1263
|
-
return
|
|
1376
|
+
return tn(a, e, t, {
|
|
1264
1377
|
...r,
|
|
1265
1378
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1266
1379
|
});
|
|
@@ -1268,7 +1381,7 @@ var J = class e {
|
|
|
1268
1381
|
};
|
|
1269
1382
|
//#endregion
|
|
1270
1383
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1271
|
-
function
|
|
1384
|
+
function Sn(e, t) {
|
|
1272
1385
|
if (!e.eastAsianVert) return 1;
|
|
1273
1386
|
let n = t(e.text);
|
|
1274
1387
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
@@ -1286,11 +1399,11 @@ function X(e, t, n, r, i, a, o) {
|
|
|
1286
1399
|
Y(t, "ooxmlSelectionRun", "docx"), Y(t, "runIndex", String(o)), c.paragraphId !== void 0 && Y(t, "paragraphId", c.paragraphId), c.source !== void 0 && (Y(t, "sourceStory", c.source.story), Y(t, "sourceStoryInstance", c.source.storyInstance), Y(t, "sourcePath", JSON.stringify(c.source.path))), t.textContent = c.text;
|
|
1287
1400
|
let l = c.transform ?? "";
|
|
1288
1401
|
if (a && c.eastAsianVert) {
|
|
1289
|
-
let e =
|
|
1402
|
+
let e = Sn(c, a(c.font));
|
|
1290
1403
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1291
1404
|
}
|
|
1292
1405
|
let u = l ? `transform:${l};transform-origin:top left;` : "", d = i ? c.hyperlink : void 0, f = d ? "pointer" : "text", p = c.letterSpacingPx === void 0 ? "0" : `${c.letterSpacingPx}px`;
|
|
1293
|
-
t.style.cssText = `position:absolute;left:${
|
|
1406
|
+
t.style.cssText = `position:absolute;left:${O(c.x, n)};top:${O(c.y, r)};font:${c.font};line-height:${c.h}px;letter-spacing:${p};` + u + `white-space:pre;color:transparent;cursor:${f};pointer-events:all;`, d && i && (t.title = d.kind === "external" ? d.url : d.ref, t.addEventListener("click", (e) => {
|
|
1294
1407
|
e.preventDefault(), i(d);
|
|
1295
1408
|
})), e.appendChild(t);
|
|
1296
1409
|
}
|
|
@@ -1303,16 +1416,16 @@ function Z(e, t, n, r, i, a, o = {}) {
|
|
|
1303
1416
|
for (let s of o.slices) {
|
|
1304
1417
|
let o = t[s.runIndex];
|
|
1305
1418
|
if (!o) continue;
|
|
1306
|
-
let c = a(o.font), l =
|
|
1307
|
-
if (
|
|
1308
|
-
let
|
|
1309
|
-
|
|
1419
|
+
let c = a(o.font), l = st(o.text, s.start, s.end, c), u = o.letterSpacingPx ?? 0, d = Math.max(0, Math.min(s.start, o.text.length)), f = Math.max(d, Math.min(s.end, o.text.length)), p = [...o.text.slice(0, d)].length, m = [...o.text.slice(d, f)].length, h = l.x + p * u, g = l.width + Math.max(0, m - 1) * u, _ = Sn(o, c), v = h * _, ee = g * _;
|
|
1420
|
+
if (ee <= 0) continue;
|
|
1421
|
+
let y = document.createElement("div"), b = o.transform ? `transform:${o.transform};transform-origin:top left;` : "";
|
|
1422
|
+
y.style.cssText = `position:absolute;left:${O(o.x + v, r)};top:${O(o.y, i)};width:${O(ee, r)};height:${O(o.h, i)};` + b + `background:${n};pointer-events:none;`, e.appendChild(y);
|
|
1310
1423
|
}
|
|
1311
1424
|
}
|
|
1312
1425
|
}
|
|
1313
1426
|
//#endregion
|
|
1314
1427
|
//#region packages/docx/src/find.ts
|
|
1315
|
-
var
|
|
1428
|
+
var Cn = class {
|
|
1316
1429
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1317
1430
|
_matches = [];
|
|
1318
1431
|
_active = -1;
|
|
@@ -1375,8 +1488,8 @@ var dn = class {
|
|
|
1375
1488
|
if (n !== this._generation) return [];
|
|
1376
1489
|
let o = r === this._runsRevision ? i : new Map([...i, ...this._pageRuns]), s = [];
|
|
1377
1490
|
for (let n = 0; n < a; n++) {
|
|
1378
|
-
let r = o.get(n) ?? [], i =
|
|
1379
|
-
for (let a of
|
|
1491
|
+
let r = o.get(n) ?? [], i = oe(r);
|
|
1492
|
+
for (let a of ae(i, e, t)) {
|
|
1380
1493
|
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
1381
1494
|
s.push({
|
|
1382
1495
|
page: n,
|
|
@@ -1388,10 +1501,10 @@ var dn = class {
|
|
|
1388
1501
|
return this._runsRevision++, this._pageRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
1389
1502
|
}
|
|
1390
1503
|
next() {
|
|
1391
|
-
return this._active =
|
|
1504
|
+
return this._active = re(this._active, this._matches.length), this._activePublic();
|
|
1392
1505
|
}
|
|
1393
1506
|
prev() {
|
|
1394
|
-
return this._active =
|
|
1507
|
+
return this._active = le(this._active, this._matches.length), this._activePublic();
|
|
1395
1508
|
}
|
|
1396
1509
|
_activePublic() {
|
|
1397
1510
|
let e = this._matchAt(this._active);
|
|
@@ -1404,7 +1517,7 @@ var dn = class {
|
|
|
1404
1517
|
};
|
|
1405
1518
|
//#endregion
|
|
1406
1519
|
//#region packages/docx/src/selection-context.ts
|
|
1407
|
-
function
|
|
1520
|
+
function wn(e, t, n, r, i = {}) {
|
|
1408
1521
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1409
1522
|
if (!a) return null;
|
|
1410
1523
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1418,7 +1531,7 @@ function fn(e, t, n, r, i = {}) {
|
|
|
1418
1531
|
t = e;
|
|
1419
1532
|
}
|
|
1420
1533
|
return !1;
|
|
1421
|
-
}), c =
|
|
1534
|
+
}), c = Ce({
|
|
1422
1535
|
id: a.id,
|
|
1423
1536
|
author: a.author,
|
|
1424
1537
|
date: a.date,
|
|
@@ -1447,19 +1560,19 @@ function fn(e, t, n, r, i = {}) {
|
|
|
1447
1560
|
maxTextCharacters: c.maxTextCharacters
|
|
1448
1561
|
});
|
|
1449
1562
|
}
|
|
1450
|
-
function
|
|
1563
|
+
function Tn(e) {
|
|
1451
1564
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1452
1565
|
let t = Number(e);
|
|
1453
1566
|
return Number.isSafeInteger(t) ? t : null;
|
|
1454
1567
|
}
|
|
1455
|
-
function
|
|
1568
|
+
function En(e) {
|
|
1456
1569
|
for (let t = e; t; t = t.parentElement) {
|
|
1457
|
-
let e =
|
|
1570
|
+
let e = Tn(t.dataset.pageIndex);
|
|
1458
1571
|
if (e !== null) return e;
|
|
1459
1572
|
}
|
|
1460
1573
|
return null;
|
|
1461
1574
|
}
|
|
1462
|
-
var
|
|
1575
|
+
var Dn = new Set([
|
|
1463
1576
|
"body",
|
|
1464
1577
|
"header",
|
|
1465
1578
|
"footer",
|
|
@@ -1467,9 +1580,9 @@ var hn = new Set([
|
|
|
1467
1580
|
"endnote",
|
|
1468
1581
|
"textbox"
|
|
1469
1582
|
]);
|
|
1470
|
-
function
|
|
1583
|
+
function On(e) {
|
|
1471
1584
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1472
|
-
if (!t || !
|
|
1585
|
+
if (!t || !Dn.has(t) || !n || !r) return null;
|
|
1473
1586
|
try {
|
|
1474
1587
|
let e = JSON.parse(r);
|
|
1475
1588
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1482,13 +1595,13 @@ function gn(e) {
|
|
|
1482
1595
|
}
|
|
1483
1596
|
}
|
|
1484
1597
|
function Q(e, t, n = {}) {
|
|
1485
|
-
let r =
|
|
1486
|
-
let t =
|
|
1598
|
+
let r = de(e, t, (e) => {
|
|
1599
|
+
let t = En(e), n = Tn(e.dataset.runIndex);
|
|
1487
1600
|
return t === null || n === null ? null : {
|
|
1488
1601
|
pageIndex: t,
|
|
1489
1602
|
runIndex: n,
|
|
1490
1603
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1491
|
-
...
|
|
1604
|
+
...On(e) === null ? {} : { source: On(e) }
|
|
1492
1605
|
};
|
|
1493
1606
|
}, {
|
|
1494
1607
|
maxChars: n.maxTextCharacters,
|
|
@@ -1517,7 +1630,7 @@ function $(e, t, n, r, i) {
|
|
|
1517
1630
|
}
|
|
1518
1631
|
//#endregion
|
|
1519
1632
|
//#region packages/docx/src/viewer.ts
|
|
1520
|
-
var
|
|
1633
|
+
var kn = Symbol("DocxViewer.borrowedDocument"), An = class e {
|
|
1521
1634
|
_documentOwner;
|
|
1522
1635
|
get _doc() {
|
|
1523
1636
|
return this._documentOwner.current;
|
|
@@ -1560,20 +1673,20 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1560
1673
|
...r,
|
|
1561
1674
|
currentDate: i.currentDate,
|
|
1562
1675
|
showTrackedChanges: i.showTrackedChanges,
|
|
1563
|
-
[
|
|
1676
|
+
[kn]: n
|
|
1564
1677
|
});
|
|
1565
1678
|
}
|
|
1566
1679
|
constructor(e, t = {}) {
|
|
1567
1680
|
this._canvas = e, this._opts = t;
|
|
1568
|
-
let n = t[
|
|
1569
|
-
this._borrowed = n !== void 0, this._mode =
|
|
1681
|
+
let n = t[kn];
|
|
1682
|
+
this._borrowed = n !== void 0, this._mode = C("DocxViewer", t.mode, n), this._documentOwner = new b("DocxViewer", n ?? null, !1);
|
|
1570
1683
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1571
1684
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
1572
|
-
this._hostWindow = r, this._canvasMount = new
|
|
1685
|
+
this._hostWindow = r, this._canvasMount = new fe(e, {
|
|
1573
1686
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1574
1687
|
forceDisplayBlock: !0
|
|
1575
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new
|
|
1576
|
-
let i = new
|
|
1688
|
+
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new S(e, this._mode === "worker"), this._errorRouter = new ue("DocxViewer", t.onError);
|
|
1689
|
+
let i = new se(this._wrapper, t.enableTextSelection === !0, t.enableElementSelection === !0);
|
|
1577
1690
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
|
|
1578
1691
|
"position:absolute",
|
|
1579
1692
|
"inset:0",
|
|
@@ -1587,7 +1700,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1587
1700
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1588
1701
|
a.setAttribute("aria-hidden", "true"), this._loadingLayer.appendChild(a), this._wrapper.insertBefore(this._loadingLayer, this._elementLayer), this._textLayer && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
1589
1702
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1590
|
-
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new
|
|
1703
|
+
}, this._wrapper.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._wrapper.addEventListener("contextmenu", this._contextMenuListener)), this._find = new Cn(() => this.pageCount, (e) => this._collectPageRuns(e)), n && this._bindLayoutDocument(n);
|
|
1591
1704
|
}
|
|
1592
1705
|
async load(e) {
|
|
1593
1706
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
@@ -1597,6 +1710,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1597
1710
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
1598
1711
|
password: this._opts.password,
|
|
1599
1712
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
1713
|
+
cjkFallback: this._opts.cjkFallback,
|
|
1600
1714
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
1601
1715
|
resourceLimits: this._opts.resourceLimits,
|
|
1602
1716
|
debug: this._opts.debug,
|
|
@@ -1667,7 +1781,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1667
1781
|
await this.goToPage(this._currentPage - 1);
|
|
1668
1782
|
}
|
|
1669
1783
|
_naturalWidthPx() {
|
|
1670
|
-
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt *
|
|
1784
|
+
return !this._doc || this._doc.pageCount === 0 ? 0 : this._doc.pageSize(this._currentPage).widthPt * D;
|
|
1671
1785
|
}
|
|
1672
1786
|
_renderWidth() {
|
|
1673
1787
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1686,14 +1800,14 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1686
1800
|
return this._opts.zoomMax ?? 4;
|
|
1687
1801
|
}
|
|
1688
1802
|
async setScale(e) {
|
|
1689
|
-
let t =
|
|
1803
|
+
let t = ie(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1690
1804
|
this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
|
|
1691
1805
|
}
|
|
1692
1806
|
async zoomIn() {
|
|
1693
|
-
await this.setScale(
|
|
1807
|
+
await this.setScale(me(this.getScale()));
|
|
1694
1808
|
}
|
|
1695
1809
|
async zoomOut() {
|
|
1696
|
-
await this.setScale(
|
|
1810
|
+
await this.setScale(_e(this.getScale()));
|
|
1697
1811
|
}
|
|
1698
1812
|
async fitWidth() {
|
|
1699
1813
|
await this._fit("width");
|
|
@@ -1705,9 +1819,9 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1705
1819
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
1706
1820
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1707
1821
|
if (!n) return;
|
|
1708
|
-
let r =
|
|
1709
|
-
contentWidth: t.widthPt *
|
|
1710
|
-
contentHeight: t.heightPt *
|
|
1822
|
+
let r = y({
|
|
1823
|
+
contentWidth: t.widthPt * D,
|
|
1824
|
+
contentHeight: t.heightPt * D,
|
|
1711
1825
|
containerWidth: n.clientWidth,
|
|
1712
1826
|
containerHeight: n.clientHeight
|
|
1713
1827
|
}, e);
|
|
@@ -1746,7 +1860,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1746
1860
|
}
|
|
1747
1861
|
getSelectionContext(e = {}) {
|
|
1748
1862
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1749
|
-
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ?
|
|
1863
|
+
return (this._textLayer ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? nn(this._elementContext, e.maxTextCharacters) : null);
|
|
1750
1864
|
}
|
|
1751
1865
|
_emitSelectionContextChange() {
|
|
1752
1866
|
let e = this.getSelectionContext();
|
|
@@ -1763,11 +1877,11 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1763
1877
|
_redrawElementOutline() {
|
|
1764
1878
|
let e = this._elementContext, t = this._doc;
|
|
1765
1879
|
if (!e || !t || e.pageIndex !== this._currentPage) {
|
|
1766
|
-
|
|
1880
|
+
x(this._elementLayer, null);
|
|
1767
1881
|
return;
|
|
1768
1882
|
}
|
|
1769
1883
|
let n = t.pageSize(e.pageIndex);
|
|
1770
|
-
|
|
1884
|
+
x(this._elementLayer, {
|
|
1771
1885
|
x: e.bounds.xPt / n.widthPt,
|
|
1772
1886
|
y: e.bounds.yPt / n.heightPt,
|
|
1773
1887
|
width: e.bounds.widthPt / n.widthPt,
|
|
@@ -1801,7 +1915,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1801
1915
|
}, {
|
|
1802
1916
|
currentDate: this._opts.currentDate,
|
|
1803
1917
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1804
|
-
maxTextCharacters:
|
|
1918
|
+
maxTextCharacters: F
|
|
1805
1919
|
});
|
|
1806
1920
|
} catch (e) {
|
|
1807
1921
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1810,7 +1924,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1810
1924
|
return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
|
|
1811
1925
|
}
|
|
1812
1926
|
destroy() {
|
|
1813
|
-
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(),
|
|
1927
|
+
this._destroyed || (this._destroyed = !0, this._findRequestGeneration++, this._layoutViewGeneration++, this._unbindLayoutDocument(), this._errorRouter.close(), this._renderDispatcher.destroy(), Ze(this._canvas), this._documentOwner.close(), this._find.invalidate(), this._selectionChangeListener &&= (this._wrapper.ownerDocument.removeEventListener("selectionchange", this._selectionChangeListener), null), this._elementHitGeneration++, this._elementClickListener &&= (this._wrapper.removeEventListener("click", this._elementClickListener), null), this._contextMenuListener &&= (this._wrapper.removeEventListener("contextmenu", this._contextMenuListener), null), this._elementContext = null, this._canvasMount.restore());
|
|
1814
1928
|
}
|
|
1815
1929
|
async _render() {
|
|
1816
1930
|
let e = this._renderDispatcher.begin();
|
|
@@ -1846,7 +1960,7 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1846
1960
|
}
|
|
1847
1961
|
_bindLayoutDocument(e) {
|
|
1848
1962
|
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1849
|
-
let t =
|
|
1963
|
+
let t = gn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = fn(e, () => ({
|
|
1850
1964
|
pageCount: e.pageCount,
|
|
1851
1965
|
exact: e.layoutComplete,
|
|
1852
1966
|
complete: e.layoutComplete
|
|
@@ -1962,11 +2076,11 @@ var _n = Symbol("DocxViewer.borrowedDocument"), vn = class e {
|
|
|
1962
2076
|
let r = e.getBookmarkPage(t);
|
|
1963
2077
|
r !== void 0 && await this.goToPage(r);
|
|
1964
2078
|
}
|
|
1965
|
-
},
|
|
1966
|
-
function
|
|
1967
|
-
return
|
|
2079
|
+
}, jn = 150, Mn = "0 1px 3px rgba(0,0,0,0.2)", Nn = 12, Pn = 13, Fn = Symbol("DocxScrollViewer.borrowedDocument"), In;
|
|
2080
|
+
function Ln() {
|
|
2081
|
+
return In ??= import("./comment-ui-runtime-DcJOYlw-.js");
|
|
1968
2082
|
}
|
|
1969
|
-
var
|
|
2083
|
+
var Rn = class e {
|
|
1970
2084
|
_documentOwner;
|
|
1971
2085
|
get _doc() {
|
|
1972
2086
|
return this._documentOwner.current;
|
|
@@ -2029,7 +2143,7 @@ var En = class e {
|
|
|
2029
2143
|
_prevBase = 0;
|
|
2030
2144
|
_lastFitWidth = 0;
|
|
2031
2145
|
_pageShadow;
|
|
2032
|
-
_find = new
|
|
2146
|
+
_find = new Cn(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
2033
2147
|
_findActive = !1;
|
|
2034
2148
|
_findRequestGeneration = 0;
|
|
2035
2149
|
_showTrackedChanges;
|
|
@@ -2042,14 +2156,14 @@ var En = class e {
|
|
|
2042
2156
|
...r,
|
|
2043
2157
|
currentDate: i.currentDate,
|
|
2044
2158
|
showTrackedChanges: i.showTrackedChanges,
|
|
2045
|
-
[
|
|
2159
|
+
[Fn]: n
|
|
2046
2160
|
});
|
|
2047
2161
|
}
|
|
2048
2162
|
constructor(e, t = {}) {
|
|
2049
2163
|
if (e.tagName === "CANVAS") throw Error("DocxScrollViewer takes a container element (e.g. a <div>), not a <canvas> — the viewer creates and manages its own canvases. Pass a block container; for the single-page canvas API use DocxViewer.");
|
|
2050
|
-
this._container = e, this._opts = t, this._errorRouter = new
|
|
2051
|
-
let n = t[
|
|
2052
|
-
this._borrowed = n !== void 0, n ? (this._documentOwner = new
|
|
2164
|
+
this._container = e, this._opts = t, this._errorRouter = new ue("DocxScrollViewer", t.onError), this._showTrackedChanges = t.showTrackedChanges === !0, this._currentDate = t.currentDate, this._pageShadow = t.pageShadow ?? Mn;
|
|
2165
|
+
let n = t[Fn];
|
|
2166
|
+
this._borrowed = n !== void 0, n ? (this._documentOwner = new b("DocxScrollViewer", n, !1), this._mode = C("DocxScrollViewer", t.mode, n)) : (this._documentOwner = new b("DocxScrollViewer"), this._mode = C("DocxScrollViewer", t.mode, void 0)), this._wrapper = document.createElement("div"), this._wrapper.style.cssText = "position:relative;width:100%;height:100%;overflow:hidden;", this._scrollHost = document.createElement("div"), this._scrollHost.style.cssText = "position:absolute;inset:0;overflow:auto;", this._scrollHost.style.scrollbarGutter = "stable", t.background && (this._scrollHost.style.background = t.background), this._spacer = document.createElement("div"), this._spacer.style.cssText = "position:absolute;top:0;left:0;width:1px;height:0;pointer-events:none;", this._scrollHost.appendChild(this._spacer), this._wrapper.appendChild(this._scrollHost), this._container.appendChild(this._wrapper), this._commentsEnabled() && Ln().then((e) => {
|
|
2053
2167
|
if (!this._destroyed) {
|
|
2054
2168
|
this._commentUi = e;
|
|
2055
2169
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -2057,7 +2171,7 @@ var En = class e {
|
|
|
2057
2171
|
}).catch((e) => this._reportRenderError(e)), t.enableTextSelection && (t.onSelectionContextChange || t.enableElementSelection) && (this._selectionChangeListener = () => this._emitSelectionContextChange(), this._wrapper.ownerDocument.addEventListener("selectionchange", this._selectionChangeListener)), t.enableElementSelection && (this._elementClickListener = (e) => {
|
|
2058
2172
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
2059
2173
|
}, this._scrollHost.addEventListener("click", this._elementClickListener)), t.onContextMenu && (this._contextMenuListener = (e) => this._onContextMenu(e), this._scrollHost.addEventListener("contextmenu", this._contextMenuListener)), this._scrollListener = () => this._onScroll(), this._scrollHost.addEventListener("scroll", this._scrollListener), t.comments && (this._commentOutsidePointerListener = (e) => {
|
|
2060
|
-
if (!
|
|
2174
|
+
if (!Ee(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
|
|
2061
2175
|
this._activeCommentId = null, this._activeCommentPage = null;
|
|
2062
2176
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2063
2177
|
this._emitSelectionContextChange();
|
|
@@ -2068,7 +2182,7 @@ var En = class e {
|
|
|
2068
2182
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
2069
2183
|
x: n,
|
|
2070
2184
|
y: r
|
|
2071
|
-
} : null, this.setScale(
|
|
2185
|
+
} : null, this.setScale(ge(this._scale, e.deltaY, e.deltaMode));
|
|
2072
2186
|
}, this._scrollHost.addEventListener("wheel", this._wheelListener, { passive: !1 })), typeof ResizeObserver < "u" && (this._resizeObserver = new ResizeObserver(() => this._onResize()), this._resizeObserver.observe(this._container)), this._borrowed && (this._bindLayoutDocument(n), this.relayout());
|
|
2073
2187
|
}
|
|
2074
2188
|
async load(e) {
|
|
@@ -2079,6 +2193,7 @@ var En = class e {
|
|
|
2079
2193
|
let n = await this._documentOwner.replace(() => J.load(e, {
|
|
2080
2194
|
password: this._opts.password,
|
|
2081
2195
|
useGoogleFonts: this._opts.useGoogleFonts,
|
|
2196
|
+
cjkFallback: this._opts.cjkFallback,
|
|
2082
2197
|
maxZipEntryBytes: this._opts.maxZipEntryBytes,
|
|
2083
2198
|
resourceLimits: this._opts.resourceLimits,
|
|
2084
2199
|
debug: this._opts.debug,
|
|
@@ -2127,7 +2242,7 @@ var En = class e {
|
|
|
2127
2242
|
}
|
|
2128
2243
|
_bindLayoutDocument(e) {
|
|
2129
2244
|
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount;
|
|
2130
|
-
let t =
|
|
2245
|
+
let t = gn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = fn(e, () => ({
|
|
2131
2246
|
pageCount: e.pageCount,
|
|
2132
2247
|
exact: e.layoutComplete,
|
|
2133
2248
|
complete: e.layoutComplete
|
|
@@ -2173,10 +2288,10 @@ var En = class e {
|
|
|
2173
2288
|
for (let [e, n] of t) e >= this._presentedPageCount || this._slots.get(e) !== n || this._refreshSlotAtomically(e, n);
|
|
2174
2289
|
}
|
|
2175
2290
|
_pageWidthPx(e) {
|
|
2176
|
-
return this._doc.pageSize(e).widthPt *
|
|
2291
|
+
return this._doc.pageSize(e).widthPt * D * this._scale;
|
|
2177
2292
|
}
|
|
2178
2293
|
_pageHeightPx(e) {
|
|
2179
|
-
return this._doc.pageSize(e).heightPt *
|
|
2294
|
+
return this._doc.pageSize(e).heightPt * D * this._scale;
|
|
2180
2295
|
}
|
|
2181
2296
|
_fitWidthPx() {
|
|
2182
2297
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -2198,7 +2313,7 @@ var En = class e {
|
|
|
2198
2313
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
2199
2314
|
}
|
|
2200
2315
|
_commentMarginExtent() {
|
|
2201
|
-
return this._hasCommentMargin() ? (
|
|
2316
|
+
return this._hasCommentMargin() ? (Nn + 280) * this._commentZoom() : 0;
|
|
2202
2317
|
}
|
|
2203
2318
|
_commentZoom() {
|
|
2204
2319
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -2216,8 +2331,8 @@ var En = class e {
|
|
|
2216
2331
|
_syncCommentMarginGeometry(e) {
|
|
2217
2332
|
if (!e) return;
|
|
2218
2333
|
e.style.display = this._hasCommentMargin() ? "" : "none";
|
|
2219
|
-
let t = this._commentZoom(), n = `calc(100% + ${
|
|
2220
|
-
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${
|
|
2334
|
+
let t = this._commentZoom(), n = `calc(100% + ${Nn * t}px)`;
|
|
2335
|
+
e.style.left = this._commentSide() === "right" ? n : "", e.style.right = this._commentSide() === "left" ? n : "", e.style.width = `${280 * t}px`, e.style.fontSize = `${Pn}px`, e.dataset.ooxmlCommentZoom = String(t);
|
|
2221
2336
|
}
|
|
2222
2337
|
_widestPageWidthPt() {
|
|
2223
2338
|
if (!this._doc) return 0;
|
|
@@ -2233,7 +2348,7 @@ var En = class e {
|
|
|
2233
2348
|
let e = this._fitWidthPx();
|
|
2234
2349
|
if (e <= 0) return 0;
|
|
2235
2350
|
let t = this._widestPageWidthPt();
|
|
2236
|
-
return t <= 0 ? 0 : e / (t *
|
|
2351
|
+
return t <= 0 ? 0 : e / (t * D);
|
|
2237
2352
|
}
|
|
2238
2353
|
relayout() {
|
|
2239
2354
|
this._relayout();
|
|
@@ -2262,7 +2377,7 @@ var En = class e {
|
|
|
2262
2377
|
_recomputeHeights() {
|
|
2263
2378
|
let e = Math.min(this._presentedPageCount, this._doc.pageCount), t = Array(e);
|
|
2264
2379
|
for (let n = 0; n < e; n++) t[n] = this._pageHeightPx(n);
|
|
2265
|
-
this._heights = t, this._scrollGeometry =
|
|
2380
|
+
this._heights = t, this._scrollGeometry = Te(t, this._gap(), this._pad());
|
|
2266
2381
|
}
|
|
2267
2382
|
_gap() {
|
|
2268
2383
|
return this._opts.gap ?? 16;
|
|
@@ -2293,7 +2408,7 @@ var En = class e {
|
|
|
2293
2408
|
return a;
|
|
2294
2409
|
}
|
|
2295
2410
|
_range() {
|
|
2296
|
-
return
|
|
2411
|
+
return w(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
|
|
2297
2412
|
}
|
|
2298
2413
|
_syncSpacer() {
|
|
2299
2414
|
let e = this._range();
|
|
@@ -2350,7 +2465,7 @@ var En = class e {
|
|
|
2350
2465
|
i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
|
|
2351
2466
|
let a = null, o = null, s = null;
|
|
2352
2467
|
this._commentsEnabled() && (a = document.createElement("div"), a.style.cssText = "position:absolute;inset:0;overflow:hidden;pointer-events:none;", t.appendChild(a), this._commentsOptions()?.cards !== !1 && (o = document.createElement("div"), o.style.cssText = "position:absolute;top:0;height:100%;box-sizing:border-box;overflow-x:hidden;overflow-y:auto;pointer-events:auto;", this._syncCommentMarginGeometry(o), this._commentsOptions()?.connectors !== void 0 && (s = document.createElement("div"), s.style.cssText = "position:absolute;top:0;left:0;overflow:visible;pointer-events:none;", t.appendChild(s)), t.appendChild(o)));
|
|
2353
|
-
let c =
|
|
2468
|
+
let c = ce(t, this._opts.enableElementSelection === !0);
|
|
2354
2469
|
return this._scrollHost.appendChild(t), {
|
|
2355
2470
|
wrapper: t,
|
|
2356
2471
|
canvas: n,
|
|
@@ -2364,11 +2479,11 @@ var En = class e {
|
|
|
2364
2479
|
commentGeometry: null,
|
|
2365
2480
|
renderedPage: -1,
|
|
2366
2481
|
renderedScale: -1,
|
|
2367
|
-
dispatcher: new
|
|
2482
|
+
dispatcher: new S(n, this._mode === "worker")
|
|
2368
2483
|
};
|
|
2369
2484
|
}
|
|
2370
2485
|
_recycleSlot(e, t) {
|
|
2371
|
-
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new
|
|
2486
|
+
this._slots.delete(e), t.dispatcher.destroy(), this._destroyed || (t.dispatcher = new S(t.canvas, this._mode === "worker")), t.textLayer && (t.textLayer.innerHTML = "", this._clearTextLayerPreview(t.textLayer)), t.highlightLayer.innerHTML = "", t.highlightLayer.style.transform = "", t.highlightLayer.style.transformOrigin = "", t.commentTintLayer && (t.commentTintLayer.replaceChildren(), t.commentTintLayer.style.transform = "", t.commentTintLayer.style.transformOrigin = "", t.commentTintLayer.style.visibility = ""), t.commentMargin && (this._commentUi?.disposeReadOnlyCommentMargin(t.commentMargin), this._commentUi || t.commentMargin.replaceChildren(), t.commentMargin.style.visibility = ""), t.commentDecorationLayer && (this._commentUi?.disposeReadOnlyCommentDecoration(t.commentDecorationLayer), this._commentUi || t.commentDecorationLayer.replaceChildren()), t.commentRuns = Object.freeze([]), t.commentGeometry = null, x(t.elementLayer, null), t.renderedPage = -1, t.renderedScale = -1, t.wrapper.remove(), this._free.push(t);
|
|
2372
2487
|
}
|
|
2373
2488
|
_positionSlot(e, t, n) {
|
|
2374
2489
|
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
@@ -2498,12 +2613,12 @@ var En = class e {
|
|
|
2498
2613
|
f = Math.min(1, Math.max(0, f));
|
|
2499
2614
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
2500
2615
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2501
|
-
let h =
|
|
2616
|
+
let h = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
|
|
2502
2617
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
2503
2618
|
let g = Math.max(0, h.totalHeight - this._scrollHost.clientHeight), _ = (h.offsets[u] ?? 0) + f * (this._heights[u] || 0), v = l < (s.offsets[0] ?? 0) ? c : _ - o;
|
|
2504
2619
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
2505
2620
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2506
|
-
this._scrollHost.scrollLeft =
|
|
2621
|
+
this._scrollHost.scrollLeft = te(m, i.x - p, a, r, { maxScroll: e });
|
|
2507
2622
|
}
|
|
2508
2623
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2509
2624
|
}
|
|
@@ -2511,10 +2626,10 @@ var En = class e {
|
|
|
2511
2626
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2512
2627
|
}
|
|
2513
2628
|
zoomIn() {
|
|
2514
|
-
this.setScale(
|
|
2629
|
+
this.setScale(me(this.getScale()));
|
|
2515
2630
|
}
|
|
2516
2631
|
zoomOut() {
|
|
2517
|
-
this.setScale(
|
|
2632
|
+
this.setScale(_e(this.getScale(), this._effectiveZoomMin()));
|
|
2518
2633
|
}
|
|
2519
2634
|
_effectiveZoomMin() {
|
|
2520
2635
|
let e = this._opts.zoomMin ?? .1;
|
|
@@ -2528,9 +2643,9 @@ var En = class e {
|
|
|
2528
2643
|
}
|
|
2529
2644
|
_fit(e) {
|
|
2530
2645
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2531
|
-
let t = this._doc.pageSize(0), n =
|
|
2532
|
-
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) *
|
|
2533
|
-
contentHeight: t.heightPt *
|
|
2646
|
+
let t = this._doc.pageSize(0), n = y({
|
|
2647
|
+
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) * D,
|
|
2648
|
+
contentHeight: t.heightPt * D,
|
|
2534
2649
|
containerWidth: this._fitWidthPx(),
|
|
2535
2650
|
containerHeight: this._scrollHost.clientHeight
|
|
2536
2651
|
}, e);
|
|
@@ -2567,7 +2682,7 @@ var En = class e {
|
|
|
2567
2682
|
_scheduleSettle() {
|
|
2568
2683
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2569
2684
|
this._settleTimer = null, this._settleRender();
|
|
2570
|
-
},
|
|
2685
|
+
}, jn);
|
|
2571
2686
|
}
|
|
2572
2687
|
_settleRender() {
|
|
2573
2688
|
if (!(this._destroyed || !this._doc || this._doc.pageCount === 0)) for (let [e, t] of [...this._slots]) t.renderedScale !== this._scale && this._refreshSlotAtomically(e, t);
|
|
@@ -2581,7 +2696,7 @@ var En = class e {
|
|
|
2581
2696
|
}
|
|
2582
2697
|
let o = document.createElement("canvas");
|
|
2583
2698
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2584
|
-
let s = new
|
|
2699
|
+
let s = new S(o, !1), c = s.begin(), l = [], u = !!this._opts.enableTextSelection && !!t.textLayer, d = u || this._findActive || !!t.commentTintLayer, f = d ? (e) => l.push(e) : void 0;
|
|
2585
2700
|
$(this._doc, o, e, "main", {
|
|
2586
2701
|
width: r,
|
|
2587
2702
|
dpr: n,
|
|
@@ -2625,14 +2740,14 @@ var En = class e {
|
|
|
2625
2740
|
}
|
|
2626
2741
|
scrollToPage(e, t) {
|
|
2627
2742
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2628
|
-
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r =
|
|
2629
|
-
typeof
|
|
2630
|
-
top:
|
|
2743
|
+
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = ve(r.offsets[n] ?? 0, Math.max(0, r.totalHeight - this._scrollHost.clientHeight)), a = this._scrollHost;
|
|
2744
|
+
typeof a.scrollTo == "function" ? a.scrollTo({
|
|
2745
|
+
top: i,
|
|
2631
2746
|
behavior: t?.behavior ?? "auto"
|
|
2632
|
-
}) : this._scrollHost.scrollTop =
|
|
2747
|
+
}) : this._scrollHost.scrollTop = i, this._mountVisible();
|
|
2633
2748
|
}
|
|
2634
2749
|
_scrollToPageTarget(e, t, n) {
|
|
2635
|
-
let r =
|
|
2750
|
+
let r = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan()), i = this._pageWidthPx(e), { left: a } = this._padH(), o = Math.max(a, (this._scrollHost.clientWidth - i) / 2) + this._reviewOriginPx, s = Math.max(0, r.totalHeight - this._scrollHost.clientHeight), c = this._spacer.offsetWidth || Number.parseFloat(this._spacer.style.width) || 0, l = Math.max(0, c - this._scrollHost.clientWidth), u = Math.min(s, Math.max(0, (r.offsets[e] ?? 0) + t.y + t.h / 2 - this._scrollHost.clientHeight / 2)), d = Math.min(l, Math.max(0, o + t.x + t.w / 2 - this._scrollHost.clientWidth / 2)), f = this._scrollHost;
|
|
2636
2751
|
typeof f.scrollTo == "function" ? f.scrollTo({
|
|
2637
2752
|
top: u,
|
|
2638
2753
|
left: d,
|
|
@@ -2647,7 +2762,7 @@ var En = class e {
|
|
|
2647
2762
|
}
|
|
2648
2763
|
_indexCommentPages(e, t, n) {
|
|
2649
2764
|
if (!this._commentIndexedPages.has(e)) {
|
|
2650
|
-
for (let r of n) this._commentPageById.has(r.commentId) ||
|
|
2765
|
+
for (let r of n) this._commentPageById.has(r.commentId) || A(r, t).length > 0 && this._commentPageById.set(r.commentId, e);
|
|
2651
2766
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2652
2767
|
}
|
|
2653
2768
|
}
|
|
@@ -2697,7 +2812,7 @@ var En = class e {
|
|
|
2697
2812
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2698
2813
|
let u = await this._commentRunsForPage(s, n);
|
|
2699
2814
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2700
|
-
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) =>
|
|
2815
|
+
if (this._doc !== n || r !== this._commentNavigationGeneration || !u || (c = a.flatMap((e) => A(e, u))[0], !c)) return !1;
|
|
2701
2816
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2702
2817
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2703
2818
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2874,7 +2989,7 @@ var En = class e {
|
|
|
2874
2989
|
}
|
|
2875
2990
|
getSelectionContext(e = {}) {
|
|
2876
2991
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2877
|
-
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ?
|
|
2992
|
+
return (this._doc && this._activeCommentId !== null && this._activeCommentPage !== null ? wn(this._doc.comments, this._doc.commentAnchorRanges(), this._activeCommentId, this._activeCommentPage, e) : null) || ((this._opts.enableTextSelection ? Q(this._wrapper, this._wrapper.ownerDocument?.getSelection?.() ?? null, e) : null) ?? (this._elementContext ? nn(this._elementContext, e.maxTextCharacters) : null));
|
|
2878
2993
|
}
|
|
2879
2994
|
_emitSelectionContextChange() {
|
|
2880
2995
|
let e = this.getSelectionContext();
|
|
@@ -2894,11 +3009,11 @@ var En = class e {
|
|
|
2894
3009
|
_redrawElementOutlineForSlot(e, t) {
|
|
2895
3010
|
let n = this._elementContext, r = this._doc;
|
|
2896
3011
|
if (!n || !r || n.pageIndex !== e) {
|
|
2897
|
-
|
|
3012
|
+
x(t.elementLayer, null);
|
|
2898
3013
|
return;
|
|
2899
3014
|
}
|
|
2900
3015
|
let i = r.pageSize(e);
|
|
2901
|
-
|
|
3016
|
+
x(t.elementLayer, {
|
|
2902
3017
|
x: n.bounds.xPt / i.widthPt,
|
|
2903
3018
|
y: n.bounds.yPt / i.heightPt,
|
|
2904
3019
|
width: n.bounds.widthPt / i.widthPt,
|
|
@@ -2934,7 +3049,7 @@ var En = class e {
|
|
|
2934
3049
|
}, {
|
|
2935
3050
|
currentDate: this._currentDate,
|
|
2936
3051
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2937
|
-
maxTextCharacters:
|
|
3052
|
+
maxTextCharacters: F
|
|
2938
3053
|
});
|
|
2939
3054
|
} catch (e) {
|
|
2940
3055
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2952,7 +3067,7 @@ var En = class e {
|
|
|
2952
3067
|
};
|
|
2953
3068
|
//#endregion
|
|
2954
3069
|
//#region packages/docx/src/types.ts
|
|
2955
|
-
function
|
|
3070
|
+
function zn(e) {
|
|
2956
3071
|
let t = [];
|
|
2957
3072
|
for (let n of e.content) {
|
|
2958
3073
|
if (n.type !== "paragraph") continue;
|
|
@@ -2964,25 +3079,25 @@ function Dn(e) {
|
|
|
2964
3079
|
}
|
|
2965
3080
|
//#endregion
|
|
2966
3081
|
//#region src/docx.ts
|
|
2967
|
-
var
|
|
3082
|
+
var Bn = /* @__PURE__ */ e({
|
|
2968
3083
|
DocxDocument: () => J,
|
|
2969
|
-
DocxScrollViewer: () =>
|
|
2970
|
-
DocxViewer: () =>
|
|
2971
|
-
OoxmlDecodedImageLimitError: () =>
|
|
2972
|
-
OoxmlError: () =>
|
|
2973
|
-
OoxmlResourceLimitError: () =>
|
|
2974
|
-
TiffDecodeError: () =>
|
|
2975
|
-
autoResize: () =>
|
|
3084
|
+
DocxScrollViewer: () => Rn,
|
|
3085
|
+
DocxViewer: () => An,
|
|
3086
|
+
OoxmlDecodedImageLimitError: () => rt,
|
|
3087
|
+
OoxmlError: () => c,
|
|
3088
|
+
OoxmlResourceLimitError: () => d,
|
|
3089
|
+
TiffDecodeError: () => it,
|
|
3090
|
+
autoResize: () => ee,
|
|
2976
3091
|
buildDocxHighlightLayer: () => Z,
|
|
2977
3092
|
buildDocxTextLayer: () => X,
|
|
2978
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
2979
|
-
isTiffDecodeError: () =>
|
|
2980
|
-
noteText: () =>
|
|
3093
|
+
isOoxmlDecodedImageLimitError: () => nt,
|
|
3094
|
+
isTiffDecodeError: () => at,
|
|
3095
|
+
noteText: () => zn,
|
|
2981
3096
|
openExternalHyperlink: () => u,
|
|
2982
3097
|
readDocxTextSelectionContext: () => Q,
|
|
2983
|
-
resolveCommentAnchorRuns: () =>
|
|
2984
|
-
resolveDocxCommentThreads: () =>
|
|
2985
|
-
resolveRevisionAnchorRuns: () =>
|
|
3098
|
+
resolveCommentAnchorRuns: () => A,
|
|
3099
|
+
resolveDocxCommentThreads: () => ut,
|
|
3100
|
+
resolveRevisionAnchorRuns: () => ln
|
|
2986
3101
|
});
|
|
2987
3102
|
//#endregion
|
|
2988
|
-
export { Q as a, J as c,
|
|
3103
|
+
export { Q as a, J as c, An as i, ln as l, zn as n, Z as o, Rn as r, X as s, Bn as t };
|