@silurus/ooxml 0.87.0 → 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/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-Cpk0YFvM.js → canvas-viewer-mechanics-DbLz0rYW.js} +2 -2
- package/dist/chart-ex.mjs +581 -616
- package/dist/{comment-ui-runtime-BfE7MJZn.js → comment-ui-runtime-CWGqn5Vr.js} +1 -1
- package/dist/{document-pull-client-yKxI8aDH.js → document-pull-client-B9PTM-pL.js} +3824 -3795
- package/dist/{docx-BkSRiy07.js → docx-BF9WXrYH.js} +428 -320
- package/dist/docx.mjs +4 -4
- package/dist/docx_parser_bg.wasm +0 -0
- package/dist/{dom-interaction-boundary-CBUQJsIM.js → dom-interaction-boundary-Cnm8DSBN.js} +2 -2
- package/dist/{hyperlink-ArrU3ArU.js → hyperlink-Cxzhet30.js} +93 -94
- package/dist/index.mjs +3 -3
- package/dist/{line-distribute-Dtudnqhs.js → line-distribute-D1WNHKz_.js} +2 -2
- package/dist/node.mjs +8 -8
- package/dist/plot-area-frame-DLTYKHNP.js +4354 -0
- package/dist/{pptx-62MmVbYB.js → pptx-DkyYBYoL.js} +13 -11
- package/dist/pptx.mjs +5 -5
- package/dist/pptx_parser_bg.wasm +0 -0
- package/dist/region-map.mjs +4 -4
- package/dist/{render-8Zo7dnds.js → render-D3iqVKCo.js} +1 -1
- package/dist/{render-worker-host-BfbnEChF.js → render-worker-host-B5wQfB7U.js} +1 -1
- package/dist/{render-worker-host-DNL9dWRh.js → render-worker-host-D4123J27.js} +1 -1
- package/dist/{render-worker-host-IkHrYOci.js → render-worker-host-Di3LxLc0.js} +1 -1
- package/dist/renderer-B4GZb5We.js +6492 -0
- package/dist/{resource-measurement-CJsgolre.js → resource-measurement-SHQCbkh2.js} +3 -3
- package/dist/{session-CrU8f8DI.js → session-BGq81gRQ.js} +2 -2
- package/dist/{slide-pull-client-B9KA8bU6.js → slide-pull-client-DiPnm240.js} +46 -46
- package/dist/{three-d-YYghQndN.js → three-d-DJBl8g8M.js} +251 -435
- package/dist/three-d.mjs +998 -906
- package/dist/tiff.mjs +1 -1
- package/dist/types/chart-ex.d.ts +142 -4
- package/dist/types/docx.d.ts +148 -10
- package/dist/types/index.d.ts +122 -16
- package/dist/types/node.d.ts +113 -7
- package/dist/types/pptx.d.ts +116 -10
- package/dist/types/region-map.d.ts +142 -4
- package/dist/types/three-d.d.ts +142 -4
- package/dist/types/xlsx.d.ts +148 -10
- package/dist/{worksheet-pull-client-eIcQ-xlD.js → worksheet-pull-client-BM8ywvbu.js} +2 -2
- package/dist/{xlsx-CRcSzZNq.js → xlsx-C9NVjgaV.js} +122 -120
- package/dist/xlsx.mjs +5 -5
- package/dist/xlsx_parser_bg.wasm +0 -0
- package/package.json +1 -1
- package/dist/assets/render-worker-CeK_iqK3.js +0 -10
- package/dist/assets/render-worker-DusrDhPk.js +0 -11
- package/dist/assets/render-worker-n2ZG0lrQ.js +0 -31
- package/dist/plot-area-frame-D5hEOgkJ.js +0 -2903
- package/dist/renderer-XFSCOT6m.js +0 -5857
- /package/dist/{pixel-budget-Dgjw269h.js → pixel-budget-9P63Bsk5.js} +0 -0
- /package/dist/{units-EJdC96r6.js → units-BzZ0gAxs.js} +0 -0
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import { t as e } from "./chunk-DmhlhrBa.js";
|
|
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-
|
|
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 { n as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { i as
|
|
10
|
-
import { n as
|
|
11
|
-
import { n as
|
|
12
|
-
import { t as
|
|
13
|
-
import { o as
|
|
14
|
-
import { i as
|
|
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";
|
|
15
15
|
//#region packages/core/src/fonts/open-type-metrics.ts
|
|
16
|
-
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 = [
|
|
17
17
|
[4352, 4607],
|
|
18
18
|
[11904, 12287],
|
|
19
19
|
[12352, 12543],
|
|
@@ -29,10 +29,10 @@ var N = (e) => (e.charCodeAt(0) << 24 >>> 0 | e.charCodeAt(1) << 16 | e.charCode
|
|
|
29
29
|
[63744, 64255],
|
|
30
30
|
[131072, 205743]
|
|
31
31
|
];
|
|
32
|
-
function
|
|
32
|
+
function N(e, t, n) {
|
|
33
33
|
return Number.isSafeInteger(t) && Number.isSafeInteger(n) && t >= 0 && n >= 0 && t <= e - n;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function xt(e, t, n) {
|
|
36
36
|
if (n < 16) return !1;
|
|
37
37
|
let r = e.getUint16(t + 2);
|
|
38
38
|
if (r < 16 || r > n) return !1;
|
|
@@ -48,7 +48,7 @@ function vt(e, t, n) {
|
|
|
48
48
|
}
|
|
49
49
|
for (let n = 0; n < a; n++) {
|
|
50
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);
|
|
51
|
-
for (let [n, o] of
|
|
51
|
+
for (let [n, o] of M) {
|
|
52
52
|
let s = Math.max(i, n), c = Math.min(a, o);
|
|
53
53
|
if (!(s > c)) {
|
|
54
54
|
if (f === 0) {
|
|
@@ -66,7 +66,7 @@ function vt(e, t, n) {
|
|
|
66
66
|
}
|
|
67
67
|
return !1;
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function St(e, t, n, r) {
|
|
70
70
|
if (n < 16) return !1;
|
|
71
71
|
let i = e.getUint32(t + 4), a = e.getUint32(t + 12);
|
|
72
72
|
if (i < 16 || i > n || a > (i - 16) / 12) return !1;
|
|
@@ -74,8 +74,8 @@ function yt(e, t, n, r) {
|
|
|
74
74
|
for (let n = 0; n < a; n++) {
|
|
75
75
|
let i = t + 16 + n * 12, a = e.getUint32(i), s = e.getUint32(i + 4), c = e.getUint32(i + 8);
|
|
76
76
|
if (a > s || s > 1114111 || a <= o) return !1;
|
|
77
|
-
if (o = s, a >
|
|
78
|
-
for (let [e, t] of
|
|
77
|
+
if (o = s, a > M[M.length - 1][1]) break;
|
|
78
|
+
for (let [e, t] of M) {
|
|
79
79
|
let n = Math.max(a, e), i = Math.min(s, t);
|
|
80
80
|
if (!(n > i)) {
|
|
81
81
|
if (r) {
|
|
@@ -86,7 +86,7 @@ function yt(e, t, n, r) {
|
|
|
86
86
|
}
|
|
87
87
|
return !1;
|
|
88
88
|
}
|
|
89
|
-
function
|
|
89
|
+
function Ct(e, t) {
|
|
90
90
|
if (!t || t.length < 4) return !1;
|
|
91
91
|
let n = e.getUint16(t.offset + 2);
|
|
92
92
|
if (4 + n * 8 > t.length) return !1;
|
|
@@ -96,61 +96,169 @@ function bt(e, t) {
|
|
|
96
96
|
let o = e.getUint32(n + 4);
|
|
97
97
|
if (o > t.length - 2) continue;
|
|
98
98
|
let s = t.offset + o, c = t.length - o, l = e.getUint16(s);
|
|
99
|
-
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;
|
|
100
100
|
}
|
|
101
101
|
return !1;
|
|
102
102
|
}
|
|
103
|
-
|
|
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) {
|
|
104
210
|
if (t !== void 0 && (!Number.isSafeInteger(t) || t < 0) || e.byteLength < 12) return null;
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
211
|
+
let r = new DataView(e.buffer, e.byteOffset, e.byteLength), i = 0;
|
|
212
|
+
if (r.getUint32(0) === ft) {
|
|
107
213
|
if (t === void 0 || e.byteLength < 12) return null;
|
|
108
|
-
let
|
|
109
|
-
if (t >=
|
|
110
|
-
|
|
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);
|
|
111
217
|
} else if (t !== void 0 && t !== 0) return null;
|
|
112
|
-
if (!
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
115
|
-
let
|
|
116
|
-
if (!
|
|
117
|
-
let
|
|
118
|
-
for (let t = 0; t <
|
|
119
|
-
let
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
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,
|
|
123
229
|
length: c
|
|
124
230
|
});
|
|
125
231
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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;
|
|
131
238
|
return Object.freeze({
|
|
132
|
-
unitsPerEm:
|
|
133
|
-
hheaAscent:
|
|
134
|
-
hheaDescent:
|
|
135
|
-
hheaLineGap:
|
|
136
|
-
hasEastAsianCmap:
|
|
137
|
-
...
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
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
|
|
144
252
|
} : {}
|
|
145
253
|
});
|
|
146
254
|
}
|
|
147
255
|
//#endregion
|
|
148
256
|
//#region packages/docx/src/worker.ts?worker&inline
|
|
149
|
-
var St = "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)})}};", Ct = typeof self < "u" && self.Blob && new Blob(["URL.revokeObjectURL(import.meta.url);", St], { type: "text/javascript;charset=utf-8" });
|
|
150
|
-
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) {
|
|
151
259
|
let t;
|
|
152
260
|
try {
|
|
153
|
-
if (t =
|
|
261
|
+
if (t = Pt && (self.URL || self.webkitURL).createObjectURL(Pt), !t) throw "";
|
|
154
262
|
let n = new Worker(t, {
|
|
155
263
|
type: "module",
|
|
156
264
|
name: e?.name
|
|
@@ -159,7 +267,7 @@ function wt(e) {
|
|
|
159
267
|
(self.URL || self.webkitURL).revokeObjectURL(t);
|
|
160
268
|
}), n;
|
|
161
269
|
} catch {
|
|
162
|
-
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(
|
|
270
|
+
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Nt), {
|
|
163
271
|
type: "module",
|
|
164
272
|
name: e?.name
|
|
165
273
|
});
|
|
@@ -167,17 +275,17 @@ function wt(e) {
|
|
|
167
275
|
}
|
|
168
276
|
//#endregion
|
|
169
277
|
//#region packages/docx/src/wasm/docx_parser_bg.wasm?url
|
|
170
|
-
var
|
|
278
|
+
var It = new URL("docx_parser_bg.wasm", import.meta.url).href;
|
|
171
279
|
//#endregion
|
|
172
280
|
//#region packages/docx/src/bookmark-nav.ts
|
|
173
|
-
function
|
|
281
|
+
function Lt(e) {
|
|
174
282
|
let t = /* @__PURE__ */ new Map();
|
|
175
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);
|
|
176
284
|
return t;
|
|
177
285
|
}
|
|
178
286
|
//#endregion
|
|
179
287
|
//#region packages/docx/src/embedded-fonts.ts
|
|
180
|
-
async function
|
|
288
|
+
async function Rt(e, t) {
|
|
181
289
|
let n = e.embeddedFonts;
|
|
182
290
|
if (!n || n.length === 0) return {
|
|
183
291
|
faces: [],
|
|
@@ -185,7 +293,7 @@ async function Dt(e, t) {
|
|
|
185
293
|
};
|
|
186
294
|
let r = [], i = /* @__PURE__ */ new Set();
|
|
187
295
|
for (let e of n) {
|
|
188
|
-
let t =
|
|
296
|
+
let t = zt(e.style) === "bold" ? 700 : 400, n = Bt(e.style), a = `${je(e.fontName)}:${t}:${n}`;
|
|
189
297
|
i.has(a) || (i.add(a), r.push(e));
|
|
190
298
|
}
|
|
191
299
|
let a = (await Promise.all(r.map(async (e) => {
|
|
@@ -195,23 +303,23 @@ async function Dt(e, t) {
|
|
|
195
303
|
bytes: n,
|
|
196
304
|
odttf: r,
|
|
197
305
|
fontKey: e.fontKey,
|
|
198
|
-
weight:
|
|
199
|
-
style:
|
|
306
|
+
weight: zt(e.style),
|
|
307
|
+
style: Bt(e.style)
|
|
200
308
|
};
|
|
201
|
-
if (!
|
|
309
|
+
if (!De(n)) return {
|
|
202
310
|
face: i,
|
|
203
311
|
metric: null
|
|
204
312
|
};
|
|
205
313
|
let a = i, o = null;
|
|
206
314
|
try {
|
|
207
|
-
let t = r ?
|
|
315
|
+
let t = r ? Se(n, e.fontKey ?? "") : n;
|
|
208
316
|
a = {
|
|
209
317
|
...i,
|
|
210
318
|
bytes: t,
|
|
211
319
|
odttf: !1,
|
|
212
320
|
fontKey: ""
|
|
213
321
|
};
|
|
214
|
-
let s =
|
|
322
|
+
let s = jt(t), c = s?.hasEastAsianCmap ? Ne(s) : 0;
|
|
215
323
|
c > 0 && (o = Object.freeze({
|
|
216
324
|
family: e.fontName,
|
|
217
325
|
requestedFamily: e.fontName,
|
|
@@ -234,13 +342,13 @@ async function Dt(e, t) {
|
|
|
234
342
|
faces: [],
|
|
235
343
|
metrics: {}
|
|
236
344
|
};
|
|
237
|
-
let o = await
|
|
345
|
+
let o = await ye(a.map((e) => e.face)), s = new Set(o.map((e) => {
|
|
238
346
|
let t = e.family.trim().replace(/^(['"])(.*)\1$/, "$2"), n = e.weight === "bold" ? 700 : Number(e.weight) || 400, r = e.style === "italic" ? "italic" : "normal";
|
|
239
|
-
return `${
|
|
347
|
+
return `${je(t)}:${n}:${r}`;
|
|
240
348
|
})), c = {};
|
|
241
349
|
for (let e of a) {
|
|
242
350
|
if (!e.metric) continue;
|
|
243
|
-
let t =
|
|
351
|
+
let t = je(e.face.family), n = e.face.weight === "bold" ? 700 : 400, r = e.face.style, i = `${t}:${n}:${r}`;
|
|
244
352
|
s.has(i) && (c[n === 400 && r === "normal" ? t : i] = e.metric);
|
|
245
353
|
}
|
|
246
354
|
return {
|
|
@@ -248,16 +356,16 @@ async function Dt(e, t) {
|
|
|
248
356
|
metrics: Object.freeze(c)
|
|
249
357
|
};
|
|
250
358
|
}
|
|
251
|
-
function
|
|
359
|
+
function zt(e) {
|
|
252
360
|
return e === "bold" || e === "boldItalic" ? "bold" : "normal";
|
|
253
361
|
}
|
|
254
|
-
function
|
|
362
|
+
function Bt(e) {
|
|
255
363
|
return e === "italic" || e === "boldItalic" ? "italic" : "normal";
|
|
256
364
|
}
|
|
257
365
|
//#endregion
|
|
258
366
|
//#region packages/docx/src/element-context.ts
|
|
259
|
-
var
|
|
260
|
-
function
|
|
367
|
+
var F = pe, Vt = 16384;
|
|
368
|
+
function Ht(e, t) {
|
|
261
369
|
let n = Math.min(e.length, t);
|
|
262
370
|
if (n > 0 && n < e.length) {
|
|
263
371
|
let t = e.charCodeAt(n - 1), r = e.charCodeAt(n);
|
|
@@ -265,7 +373,7 @@ function jt(e, t) {
|
|
|
265
373
|
}
|
|
266
374
|
return e.slice(0, n);
|
|
267
375
|
}
|
|
268
|
-
function
|
|
376
|
+
function Ut(e, t) {
|
|
269
377
|
let n = [], r = 0, i = !1;
|
|
270
378
|
for (let a of e) {
|
|
271
379
|
if (a.length === 0) continue;
|
|
@@ -276,7 +384,7 @@ function Mt(e, t) {
|
|
|
276
384
|
}
|
|
277
385
|
n.push("\n"), r++;
|
|
278
386
|
}
|
|
279
|
-
let e =
|
|
387
|
+
let e = Ht(a, Math.max(0, t - r));
|
|
280
388
|
if (n.push(e), r += e.length, e.length < a.length) {
|
|
281
389
|
i = !0;
|
|
282
390
|
break;
|
|
@@ -288,7 +396,7 @@ function Mt(e, t) {
|
|
|
288
396
|
truncated: i
|
|
289
397
|
};
|
|
290
398
|
}
|
|
291
|
-
function*
|
|
399
|
+
function* I(e) {
|
|
292
400
|
if (e.kind === "paragraph") {
|
|
293
401
|
for (let t of e.lines) {
|
|
294
402
|
let e = t.placements.flatMap((e) => e.kind === "text" ? [e.text] : []).join("");
|
|
@@ -297,42 +405,42 @@ function* L(e) {
|
|
|
297
405
|
return;
|
|
298
406
|
}
|
|
299
407
|
if (e.kind === "table") {
|
|
300
|
-
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);
|
|
301
409
|
return;
|
|
302
410
|
}
|
|
303
|
-
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);
|
|
304
412
|
}
|
|
305
|
-
function*
|
|
413
|
+
function* Wt(e) {
|
|
306
414
|
for (let t of e.drawing.commands) (t.kind === "text" || t.kind === "watermark-text") && (yield t.text);
|
|
307
|
-
for (let t of e.textBoxes) yield*
|
|
415
|
+
for (let t of e.textBoxes) yield* I(t);
|
|
308
416
|
}
|
|
309
|
-
function
|
|
310
|
-
let t = e ??
|
|
417
|
+
function Gt(e) {
|
|
418
|
+
let t = e ?? Vt;
|
|
311
419
|
if (!Number.isFinite(t) || t < 0) throw RangeError("maxTextCharacters must be a finite non-negative number.");
|
|
312
|
-
return Math.min(
|
|
420
|
+
return Math.min(F, Math.floor(t));
|
|
313
421
|
}
|
|
314
|
-
function
|
|
422
|
+
function Kt(e) {
|
|
315
423
|
return {
|
|
316
424
|
story: e.story,
|
|
317
425
|
storyInstance: e.storyInstance,
|
|
318
426
|
path: [...e.path]
|
|
319
427
|
};
|
|
320
428
|
}
|
|
321
|
-
function
|
|
429
|
+
function qt(e) {
|
|
322
430
|
return "drawing" in e ? e.drawing.inkBounds : e.placement.bounds;
|
|
323
431
|
}
|
|
324
|
-
function
|
|
325
|
-
let t =
|
|
326
|
-
|
|
327
|
-
|
|
432
|
+
function Jt(e) {
|
|
433
|
+
let t = qt(e), n = [
|
|
434
|
+
T(e.pointToPage, t),
|
|
435
|
+
T(e.pointToPage, {
|
|
328
436
|
xPt: t.xPt + t.widthPt,
|
|
329
437
|
yPt: t.yPt
|
|
330
438
|
}),
|
|
331
|
-
|
|
439
|
+
T(e.pointToPage, {
|
|
332
440
|
xPt: t.xPt,
|
|
333
441
|
yPt: t.yPt + t.heightPt
|
|
334
442
|
}),
|
|
335
|
-
|
|
443
|
+
T(e.pointToPage, {
|
|
336
444
|
xPt: t.xPt + t.widthPt,
|
|
337
445
|
yPt: t.yPt + t.heightPt
|
|
338
446
|
})
|
|
@@ -344,10 +452,10 @@ function Lt(e) {
|
|
|
344
452
|
heightPt: o - i
|
|
345
453
|
};
|
|
346
454
|
}
|
|
347
|
-
function
|
|
455
|
+
function L(e, t) {
|
|
348
456
|
return t.xPt >= e.xPt && t.xPt <= e.xPt + e.widthPt && t.yPt >= e.yPt && t.yPt <= e.yPt + e.heightPt;
|
|
349
457
|
}
|
|
350
|
-
function
|
|
458
|
+
function Yt(e, t) {
|
|
351
459
|
let n = !1;
|
|
352
460
|
for (let r = 0, i = t.length - 1; r < t.length; i = r++) {
|
|
353
461
|
let a = t[r], o = t[i];
|
|
@@ -355,35 +463,35 @@ function Rt(e, t) {
|
|
|
355
463
|
}
|
|
356
464
|
return n;
|
|
357
465
|
}
|
|
358
|
-
function
|
|
359
|
-
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;
|
|
360
468
|
}
|
|
361
|
-
function
|
|
469
|
+
function Zt(e, t, n) {
|
|
362
470
|
for (let n of e.clips) {
|
|
363
|
-
let e =
|
|
364
|
-
if (!e || !
|
|
471
|
+
let e = Me(n.pointToPage, t);
|
|
472
|
+
if (!e || !L(n.bounds, e)) return !1;
|
|
365
473
|
}
|
|
366
|
-
return "drawing" in e ?
|
|
474
|
+
return "drawing" in e ? Xt(e.drawing, n) : L(e.placement.bounds, n);
|
|
367
475
|
}
|
|
368
|
-
function
|
|
476
|
+
function R(e, t) {
|
|
369
477
|
return e.commands.find((e) => e.kind === "resource" && e.resourceKind === t);
|
|
370
478
|
}
|
|
371
|
-
function
|
|
372
|
-
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;
|
|
373
481
|
}
|
|
374
|
-
function
|
|
375
|
-
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;
|
|
376
484
|
if (!o) return null;
|
|
377
485
|
let s, c = !1, l, u;
|
|
378
486
|
if (o === "chart") {
|
|
379
|
-
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);
|
|
380
488
|
s = r.text, c = r.truncated, u = n.model.series.length;
|
|
381
489
|
} else if (o === "image") {
|
|
382
|
-
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);
|
|
383
491
|
if (!n) throw Error(`Unknown image paint resource: ${t}`);
|
|
384
492
|
l = n.mimeType;
|
|
385
493
|
} else {
|
|
386
|
-
let t =
|
|
494
|
+
let t = Ut(Wt(e), a);
|
|
387
495
|
s = t.text, c = t.truncated;
|
|
388
496
|
}
|
|
389
497
|
return {
|
|
@@ -393,8 +501,8 @@ function Ht(e, t, n, r, i, a) {
|
|
|
393
501
|
elementIndex: n,
|
|
394
502
|
elementType: o,
|
|
395
503
|
point: { ...r },
|
|
396
|
-
bounds:
|
|
397
|
-
source:
|
|
504
|
+
bounds: Jt(e),
|
|
505
|
+
source: Kt("drawing" in e ? e.drawing.source : e.source),
|
|
398
506
|
...s === void 0 ? {} : { text: s },
|
|
399
507
|
...l === void 0 ? {} : { mimeType: l },
|
|
400
508
|
...u === void 0 ? {} : { seriesCount: u },
|
|
@@ -404,26 +512,26 @@ function Ht(e, t, n, r, i, a) {
|
|
|
404
512
|
maxTextCharacters: a
|
|
405
513
|
};
|
|
406
514
|
}
|
|
407
|
-
function
|
|
515
|
+
function en(e, t, n, r, i = {}) {
|
|
408
516
|
if (!Number.isFinite(n.xPt) || !Number.isFinite(n.yPt)) throw RangeError("DOCX hit-test point must contain finite page coordinates.");
|
|
409
|
-
let a =
|
|
517
|
+
let a = Gt(i.maxTextCharacters), o = Ie(e, t);
|
|
410
518
|
for (let e = o.length - 1; e >= 0; e--) {
|
|
411
|
-
let i = o[e], s =
|
|
412
|
-
if (!s || !
|
|
413
|
-
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);
|
|
414
522
|
if (c) return c;
|
|
415
523
|
}
|
|
416
524
|
return null;
|
|
417
525
|
}
|
|
418
|
-
function
|
|
419
|
-
return
|
|
526
|
+
function tn(e, t, n, r) {
|
|
527
|
+
return en(Qe(e, {
|
|
420
528
|
currentDate: r.currentDate,
|
|
421
529
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
422
530
|
showTrackedChanges: r.showTrackedChanges
|
|
423
|
-
}, t).layout, t, n,
|
|
531
|
+
}, t).layout, t, n, Oe(e), r);
|
|
424
532
|
}
|
|
425
|
-
function
|
|
426
|
-
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;
|
|
427
535
|
return {
|
|
428
536
|
...structuredClone(e),
|
|
429
537
|
...r === void 0 ? {} : { text: r },
|
|
@@ -435,20 +543,20 @@ function Gt(e, t) {
|
|
|
435
543
|
}
|
|
436
544
|
//#endregion
|
|
437
545
|
//#region packages/docx/src/revisions.ts
|
|
438
|
-
function
|
|
439
|
-
let t =
|
|
546
|
+
function z(e) {
|
|
547
|
+
let t = lt(e.id);
|
|
440
548
|
return t === void 0 ? void 0 : `${e.kind}\u0000${t}`;
|
|
441
549
|
}
|
|
442
|
-
function
|
|
550
|
+
function B(e) {
|
|
443
551
|
return Object.freeze({
|
|
444
552
|
...e,
|
|
445
553
|
path: Object.freeze([...e.path])
|
|
446
554
|
});
|
|
447
555
|
}
|
|
448
|
-
function
|
|
556
|
+
function rn(e, t) {
|
|
449
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]);
|
|
450
558
|
}
|
|
451
|
-
function
|
|
559
|
+
function V(e, t) {
|
|
452
560
|
let n = 0, r = e.length;
|
|
453
561
|
for (; n < r;) {
|
|
454
562
|
let i = n + Math.floor((r - n) / 2);
|
|
@@ -456,22 +564,22 @@ function qt(e, t) {
|
|
|
456
564
|
}
|
|
457
565
|
return n;
|
|
458
566
|
}
|
|
459
|
-
function
|
|
567
|
+
function an(e, t) {
|
|
460
568
|
let n = Array(e.length), r;
|
|
461
569
|
for (let i = e.length - 1; i >= 0; --i) {
|
|
462
570
|
n[i] = r;
|
|
463
|
-
let a = e[i], o = t.get(
|
|
571
|
+
let a = e[i], o = t.get(k(a.source))?.[0];
|
|
464
572
|
o !== void 0 && (r = Object.freeze({
|
|
465
|
-
source:
|
|
573
|
+
source: B(a.source),
|
|
466
574
|
sourceRunIndex: o
|
|
467
575
|
}));
|
|
468
576
|
}
|
|
469
577
|
let i = Array(e.length), a;
|
|
470
578
|
for (let n = 0; n < e.length; n += 1) {
|
|
471
579
|
i[n] = a;
|
|
472
|
-
let r = e[n], o = t.get(
|
|
580
|
+
let r = e[n], o = t.get(k(r.source))?.at(-1);
|
|
473
581
|
o !== void 0 && (a = Object.freeze({
|
|
474
|
-
source:
|
|
582
|
+
source: B(r.source),
|
|
475
583
|
sourceRunIndex: o
|
|
476
584
|
}));
|
|
477
585
|
}
|
|
@@ -480,17 +588,17 @@ function Jt(e, t) {
|
|
|
480
588
|
preceding: i
|
|
481
589
|
};
|
|
482
590
|
}
|
|
483
|
-
function
|
|
484
|
-
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;
|
|
485
593
|
return u === void 0 ? a.following[e] ?? a.preceding[e] : Object.freeze({
|
|
486
|
-
source:
|
|
594
|
+
source: B(o.source),
|
|
487
595
|
sourceRunIndex: u
|
|
488
596
|
});
|
|
489
597
|
}
|
|
490
|
-
function
|
|
598
|
+
function sn(e, t, n = /* @__PURE__ */ new Map()) {
|
|
491
599
|
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set();
|
|
492
600
|
e.forEach((e, t) => {
|
|
493
|
-
let n =
|
|
601
|
+
let n = z(e);
|
|
494
602
|
n === void 0 || i.has(n) || (r.has(n) ? (r.delete(n), i.add(n)) : r.set(n, t));
|
|
495
603
|
});
|
|
496
604
|
let a = t.blocks.sources.flatMap((e) => {
|
|
@@ -500,11 +608,11 @@ function Xt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
500
608
|
source: e,
|
|
501
609
|
runs: n.runs
|
|
502
610
|
}] : [];
|
|
503
|
-
}), 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 = [];
|
|
504
612
|
for (let [e, t] of a.entries()) {
|
|
505
613
|
let n = 0;
|
|
506
614
|
for (; n < t.runs.length;) {
|
|
507
|
-
let i = t.runs[n], l = i.revision?.kind ?
|
|
615
|
+
let i = t.runs[n], l = i.revision?.kind ? z({
|
|
508
616
|
kind: i.revision.kind,
|
|
509
617
|
id: i.revision.id
|
|
510
618
|
}) : void 0, u = l === void 0 ? void 0 : r.get(l);
|
|
@@ -515,16 +623,16 @@ function Xt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
515
623
|
let d = n;
|
|
516
624
|
for (n += 1; n < t.runs.length;) {
|
|
517
625
|
let e = t.runs[n].revision;
|
|
518
|
-
if (!e?.kind ||
|
|
626
|
+
if (!e?.kind || z({
|
|
519
627
|
kind: e.kind,
|
|
520
628
|
id: e.id
|
|
521
629
|
}) !== l) break;
|
|
522
630
|
n += 1;
|
|
523
631
|
}
|
|
524
|
-
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);
|
|
525
633
|
c.push(Object.freeze({
|
|
526
634
|
revisionIndex: u,
|
|
527
|
-
source:
|
|
635
|
+
source: B(t.source),
|
|
528
636
|
startRunIndex: d,
|
|
529
637
|
endRunIndex: f,
|
|
530
638
|
...m === void 0 ? {} : { geometryFallback: m }
|
|
@@ -533,26 +641,26 @@ function Xt(e, t, n = /* @__PURE__ */ new Map()) {
|
|
|
533
641
|
}
|
|
534
642
|
return c;
|
|
535
643
|
}
|
|
536
|
-
function
|
|
644
|
+
function cn(e, t, n = /* @__PURE__ */ new Map(), r = {}) {
|
|
537
645
|
if ((e?.length ?? 0) === 0) return [];
|
|
538
|
-
let i =
|
|
646
|
+
let i = sn(e ?? [], t, n), a = r.completedSourceKeys;
|
|
539
647
|
return a === void 0 ? i : i.filter((e) => {
|
|
540
|
-
let t = n.get(
|
|
541
|
-
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));
|
|
542
650
|
});
|
|
543
651
|
}
|
|
544
|
-
function
|
|
545
|
-
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);
|
|
546
654
|
if (n.length > 0) return n;
|
|
547
655
|
let r = e.geometryFallback;
|
|
548
|
-
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));
|
|
549
657
|
}
|
|
550
658
|
//#endregion
|
|
551
659
|
//#region packages/docx/src/layout/progressive.ts
|
|
552
|
-
var
|
|
553
|
-
async function
|
|
660
|
+
var un = 12;
|
|
661
|
+
async function dn(e, t, n, r = {}) {
|
|
554
662
|
let { onPreview: i, scheduler: a } = r;
|
|
555
|
-
return
|
|
663
|
+
return Be(Pe(e, t, n, i && e.sequence.length > un ? { onPages: (e, t) => {
|
|
556
664
|
i(Object.freeze({
|
|
557
665
|
layout: e,
|
|
558
666
|
exact: !1,
|
|
@@ -573,7 +681,7 @@ function U(e, t) {
|
|
|
573
681
|
} catch {}
|
|
574
682
|
}
|
|
575
683
|
}
|
|
576
|
-
function
|
|
684
|
+
function fn(e, t, n, r) {
|
|
577
685
|
let i = H.get(e);
|
|
578
686
|
i || (i = /* @__PURE__ */ new Set(), H.set(e, i));
|
|
579
687
|
let a = Object.freeze({
|
|
@@ -594,30 +702,30 @@ function tn(e, t, n, r) {
|
|
|
594
702
|
}
|
|
595
703
|
//#endregion
|
|
596
704
|
//#region packages/docx/src/document-layout-view.ts
|
|
597
|
-
var W = /* @__PURE__ */ new WeakMap(),
|
|
705
|
+
var W = /* @__PURE__ */ new WeakMap(), pn = /* @__PURE__ */ new WeakMap(), mn = Symbol("docxLayoutViewRequester");
|
|
598
706
|
function G(e) {
|
|
599
|
-
let t =
|
|
707
|
+
let t = E(e), n = t.activeLayoutOptions;
|
|
600
708
|
return {
|
|
601
709
|
showTrackedChanges: n?.showTrackedChanges === !0,
|
|
602
710
|
currentDate: n?.currentDateMs ?? t.defaultCurrentDateMs
|
|
603
711
|
};
|
|
604
712
|
}
|
|
605
713
|
async function K(e, t, n) {
|
|
606
|
-
let r =
|
|
714
|
+
let r = E(e), i = Ae(t.currentDate, r.defaultCurrentDateMs, t.showTrackedChanges === !0), a = Object.freeze({
|
|
607
715
|
showTrackedChanges: i.showTrackedChanges === !0,
|
|
608
716
|
currentDate: i.currentDateMs
|
|
609
717
|
}), o = {
|
|
610
718
|
showTrackedChanges: a.showTrackedChanges,
|
|
611
719
|
currentDate: a.currentDate,
|
|
612
|
-
[
|
|
720
|
+
[mn]: n
|
|
613
721
|
};
|
|
614
722
|
await e.setLayoutView(o);
|
|
615
723
|
let s = G(e);
|
|
616
724
|
return s.currentDate === a.currentDate && s.showTrackedChanges === a.showTrackedChanges;
|
|
617
725
|
}
|
|
618
|
-
function
|
|
619
|
-
let n = Object.freeze({ ...G(e) }), r = (
|
|
620
|
-
|
|
726
|
+
function hn(e, t) {
|
|
727
|
+
let n = Object.freeze({ ...G(e) }), r = (pn.get(e) ?? 0) + 1;
|
|
728
|
+
pn.set(e, r);
|
|
621
729
|
let i = Object.freeze({
|
|
622
730
|
view: n,
|
|
623
731
|
generation: r,
|
|
@@ -631,7 +739,7 @@ function an(e, t) {
|
|
|
631
739
|
} catch {}
|
|
632
740
|
}
|
|
633
741
|
}
|
|
634
|
-
function
|
|
742
|
+
function gn(e, t, n) {
|
|
635
743
|
let r = W.get(e);
|
|
636
744
|
r || (r = /* @__PURE__ */ new Set(), W.set(e, r));
|
|
637
745
|
let i = Object.freeze({
|
|
@@ -644,10 +752,10 @@ function on(e, t, n) {
|
|
|
644
752
|
}
|
|
645
753
|
//#endregion
|
|
646
754
|
//#region packages/docx/src/document.ts
|
|
647
|
-
function
|
|
755
|
+
function _n(e, t) {
|
|
648
756
|
return e !== null && e.currentDateMs === t.currentDateMs && e.showTrackedChanges === !0 == (t.showTrackedChanges === !0);
|
|
649
757
|
}
|
|
650
|
-
function
|
|
758
|
+
function vn() {
|
|
651
759
|
let e, t;
|
|
652
760
|
return {
|
|
653
761
|
promise: new Promise((n, r) => {
|
|
@@ -657,12 +765,12 @@ function cn() {
|
|
|
657
765
|
reject: t
|
|
658
766
|
};
|
|
659
767
|
}
|
|
660
|
-
var
|
|
768
|
+
var yn = Object.freeze([]), bn = Object.freeze([]), xn = Object.freeze({
|
|
661
769
|
comments: Object.freeze([]),
|
|
662
770
|
revisions: Object.freeze([])
|
|
663
771
|
});
|
|
664
772
|
function q(e, t) {
|
|
665
|
-
return
|
|
773
|
+
return He({
|
|
666
774
|
comments: e,
|
|
667
775
|
revisions: t
|
|
668
776
|
}, "DOCX review metadata");
|
|
@@ -673,9 +781,9 @@ var J = class e {
|
|
|
673
781
|
_document = null;
|
|
674
782
|
_source = null;
|
|
675
783
|
_meta = null;
|
|
676
|
-
_review =
|
|
677
|
-
_layoutLifecycle = new
|
|
678
|
-
_layoutObservers = new
|
|
784
|
+
_review = xn;
|
|
785
|
+
_layoutLifecycle = new xe();
|
|
786
|
+
_layoutObservers = new we();
|
|
679
787
|
_layoutCompletion = null;
|
|
680
788
|
_layoutAbort = null;
|
|
681
789
|
_bookmarkPages = null;
|
|
@@ -694,7 +802,7 @@ var J = class e {
|
|
|
694
802
|
_tiff;
|
|
695
803
|
_worker;
|
|
696
804
|
_bridge;
|
|
697
|
-
_rawParts = new
|
|
805
|
+
_rawParts = new ct({
|
|
698
806
|
maxEntries: 64,
|
|
699
807
|
maxBytes: n
|
|
700
808
|
});
|
|
@@ -702,7 +810,7 @@ var J = class e {
|
|
|
702
810
|
_googleFontFaces = [];
|
|
703
811
|
_fetchImage = (e, t) => this.getImage(e, t);
|
|
704
812
|
constructor(e, t, n, r) {
|
|
705
|
-
this._worker = e, this._mode = t,
|
|
813
|
+
this._worker = e, this._mode = t, ke(this, n), this._bridge = new he(this._worker, {
|
|
706
814
|
correlate: (e) => "protocol" in e && e.protocol === "ooxml-pull-v1" ? e.requestId : "id" in e ? e.id : void 0,
|
|
707
815
|
onUnsolicited: (e) => this._onWorkerLayoutPush(e),
|
|
708
816
|
toError: (e) => {
|
|
@@ -714,14 +822,14 @@ var J = class e {
|
|
|
714
822
|
});
|
|
715
823
|
}
|
|
716
824
|
});
|
|
717
|
-
let i = new URL(r ??
|
|
825
|
+
let i = new URL(r ?? It, location.href).href;
|
|
718
826
|
this._bridge.post({
|
|
719
827
|
type: "init",
|
|
720
828
|
wasmUrl: i
|
|
721
829
|
});
|
|
722
830
|
}
|
|
723
831
|
static async load(t, n = {}) {
|
|
724
|
-
let i =
|
|
832
|
+
let i = tt(n.cjkFallback), a = f(n), o = Date.now(), s = n.mode ?? "main", c = new r({
|
|
725
833
|
enabled: !0,
|
|
726
834
|
format: "docx",
|
|
727
835
|
mode: s,
|
|
@@ -738,32 +846,32 @@ var J = class e {
|
|
|
738
846
|
r = await e.arrayBuffer();
|
|
739
847
|
} else r = t;
|
|
740
848
|
r = g(await h(r, n.password)), c.setSourceBytes(r.byteLength), c.checkpoint("container ready");
|
|
741
|
-
let l = s === "worker" ? (await import("./render-worker-host-
|
|
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;
|
|
742
850
|
try {
|
|
743
851
|
f = new e(l, s, o, n.wasmUrl), f._metrics = c, f._cjkFallback = i;
|
|
744
|
-
let t =
|
|
852
|
+
let t = E(f), p = Ae(n.currentDate, t.defaultCurrentDateMs, n.showTrackedChanges === !0);
|
|
745
853
|
t.activeLayoutOptions = p, await f._parse(r, a.policy, s === "worker" ? !!n.useGoogleFonts : !1, n.workerTimeoutMs, (e) => c.observeUsage(e), u, d ? {
|
|
746
854
|
onPartial: n.onLayoutPartial,
|
|
747
855
|
onComplete: n.onLayoutComplete,
|
|
748
856
|
onProgress: n.onLayoutProgress,
|
|
749
857
|
layoutOptions: p,
|
|
750
858
|
abort: new AbortController(),
|
|
751
|
-
firstPublication:
|
|
859
|
+
firstPublication: vn(),
|
|
752
860
|
published: !1,
|
|
753
861
|
settled: !1
|
|
754
|
-
} : 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(
|
|
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));
|
|
755
863
|
let h;
|
|
756
864
|
if (f._mode === "main" && f._document?.embeddedFonts?.length) {
|
|
757
|
-
let e = f, t = await
|
|
865
|
+
let e = f, t = await Rt(f._document, (t) => e.getFontBytes(t));
|
|
758
866
|
f._embeddedFontFaces = t.faces, h = t.metrics;
|
|
759
867
|
}
|
|
760
868
|
let g;
|
|
761
|
-
if (f._mode === "main" && n.math && f._document &&
|
|
762
|
-
let e = f, t =
|
|
763
|
-
t.services =
|
|
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, {
|
|
764
872
|
fontMetrics: h,
|
|
765
873
|
measureResolvedFontMetrics: !0,
|
|
766
|
-
resolvedFontMetricCandidates:
|
|
874
|
+
resolvedFontMetricCandidates: Je(f._document, f._source.fontFamilyCharsets),
|
|
767
875
|
useGoogleFonts: !!n.useGoogleFonts,
|
|
768
876
|
cjkFallback: i,
|
|
769
877
|
embeddedFaces: f._embeddedFontFaces,
|
|
@@ -771,14 +879,14 @@ var J = class e {
|
|
|
771
879
|
mathResources: g?.records,
|
|
772
880
|
mathDrawables: g?.drawables
|
|
773
881
|
});
|
|
774
|
-
let r = t.services, a =
|
|
882
|
+
let r = t.services, a = Fe(f._source, r, t.defaultCurrentDateMs), o = f._source.fatalParse === null, s = t.activeLayoutOptions;
|
|
775
883
|
if (!s) throw Error("Active layout view was not recorded at load");
|
|
776
884
|
let c = { onProgress: n.onLayoutProgress ? (t) => e._layoutObservers.notify("onLayoutProgress", n.onLayoutProgress, { committedUnits: t }) : void 0 };
|
|
777
885
|
if (o && n.progressiveLayout) {
|
|
778
886
|
let e = a.layoutVariants, t = f, i = new AbortController();
|
|
779
887
|
t._layoutAbort = i;
|
|
780
|
-
let o =
|
|
781
|
-
t._layoutCompletion =
|
|
888
|
+
let o = vn(), l = null, u = !0;
|
|
889
|
+
t._layoutCompletion = dn(f._source.bodyLayoutInput, r, s, {
|
|
782
890
|
scheduler: {
|
|
783
891
|
...c,
|
|
784
892
|
signal: i.signal
|
|
@@ -818,7 +926,7 @@ var J = class e {
|
|
|
818
926
|
o.reject(e);
|
|
819
927
|
return;
|
|
820
928
|
}
|
|
821
|
-
if (e instanceof
|
|
929
|
+
if (e instanceof Ve) {
|
|
822
930
|
t._layoutLifecycle.succeed();
|
|
823
931
|
return;
|
|
824
932
|
}
|
|
@@ -831,7 +939,7 @@ var J = class e {
|
|
|
831
939
|
}), t._layoutObservers.notify("onLayoutComplete", n.onLayoutComplete, r);
|
|
832
940
|
}), await o.promise;
|
|
833
941
|
} else if (o && (n.sliceLayout || n.onLayoutProgress)) {
|
|
834
|
-
let e = await
|
|
942
|
+
let e = await Ge(f._source.bodyLayoutInput, r, s, c);
|
|
835
943
|
a.layoutVariants.prime(s, e);
|
|
836
944
|
} else a.layoutVariants.layoutFor(s);
|
|
837
945
|
}
|
|
@@ -856,7 +964,7 @@ var J = class e {
|
|
|
856
964
|
resourcePolicy: t,
|
|
857
965
|
useGoogleFonts: n,
|
|
858
966
|
cjkFallback: this._cjkFallback,
|
|
859
|
-
defaultCurrentDateMs:
|
|
967
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
860
968
|
...this._parseViewFields(),
|
|
861
969
|
renderers: a
|
|
862
970
|
} : {
|
|
@@ -867,14 +975,14 @@ var J = class e {
|
|
|
867
975
|
}, [e], { timeoutMs: r });
|
|
868
976
|
if ("protocol" in s) throw Error("DOCX parse open returned a pull-protocol response");
|
|
869
977
|
if (this._mode === "worker") if ("usage" in s && s.usage && i?.(s.usage), s.type === "mainThreadVerticalFallback") {
|
|
870
|
-
let e = await
|
|
978
|
+
let e = await Ke(this._bridge.transport(Xe), s, {
|
|
871
979
|
timeoutMs: r,
|
|
872
980
|
onUsage: i
|
|
873
981
|
});
|
|
874
982
|
this._source = e.source, this._document = e.document, this._meta = null, this._mode = "main";
|
|
875
983
|
} else this._meta = s.meta;
|
|
876
984
|
else {
|
|
877
|
-
let e = s, t = await
|
|
985
|
+
let e = s, t = await Ke(this._bridge.transport(Xe), e, {
|
|
878
986
|
timeoutMs: r,
|
|
879
987
|
onUsage: i
|
|
880
988
|
});
|
|
@@ -956,7 +1064,7 @@ var J = class e {
|
|
|
956
1064
|
return i !== null && this._isLayoutViewActive(t) && this._invalidateLayoutDerivedCaches(), i;
|
|
957
1065
|
}
|
|
958
1066
|
_isLayoutViewActive(e) {
|
|
959
|
-
return
|
|
1067
|
+
return _n(E(this).activeLayoutOptions, e);
|
|
960
1068
|
}
|
|
961
1069
|
_rearmParseWatchdog() {
|
|
962
1070
|
this._parseWatchdogMs !== void 0 && (clearTimeout(this._parseWatchdog), this._parseWatchdog = setTimeout(() => this._onParseWentSilent(), this._parseWatchdogMs));
|
|
@@ -985,7 +1093,7 @@ var J = class e {
|
|
|
985
1093
|
}), this._layoutObservers.notify("onLayoutComplete", e.onComplete, n);
|
|
986
1094
|
}
|
|
987
1095
|
_parseViewFields() {
|
|
988
|
-
let e =
|
|
1096
|
+
let e = E(this), t = e.activeLayoutOptions;
|
|
989
1097
|
return t ? {
|
|
990
1098
|
...t.currentDateMs === e.defaultCurrentDateMs ? {} : { currentDateMs: t.currentDateMs },
|
|
991
1099
|
...t.showTrackedChanges === !0 ? { showTrackedChanges: !0 } : {}
|
|
@@ -999,7 +1107,7 @@ var J = class e {
|
|
|
999
1107
|
resourcePolicy: t,
|
|
1000
1108
|
useGoogleFonts: n,
|
|
1001
1109
|
cjkFallback: this._cjkFallback,
|
|
1002
|
-
defaultCurrentDateMs:
|
|
1110
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
1003
1111
|
...this._parseViewFields(),
|
|
1004
1112
|
renderers: a,
|
|
1005
1113
|
progressiveLayout: !0
|
|
@@ -1007,7 +1115,7 @@ var J = class e {
|
|
|
1007
1115
|
if (this._parseRequestId = null, "protocol" in e) throw Error("DOCX parse open returned a pull-protocol response");
|
|
1008
1116
|
if ("usage" in e && e.usage && i?.(e.usage), e.type === "mainThreadVerticalFallback") {
|
|
1009
1117
|
this._clearParseWatchdog(), o.settled = !0, this._progressive = null, this._layoutAbort = null;
|
|
1010
|
-
let t = await
|
|
1118
|
+
let t = await Ke(this._bridge.transport(Xe), e, {
|
|
1011
1119
|
timeoutMs: r,
|
|
1012
1120
|
onUsage: i
|
|
1013
1121
|
});
|
|
@@ -1026,7 +1134,7 @@ var J = class e {
|
|
|
1026
1134
|
}), this._rearmParseWatchdog(), await o.firstPublication.promise;
|
|
1027
1135
|
}
|
|
1028
1136
|
destroy() {
|
|
1029
|
-
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);
|
|
1030
1138
|
}
|
|
1031
1139
|
async getImage(e, t) {
|
|
1032
1140
|
return this._rawParts.get(e, t, () => this._bridge.request((t) => ({
|
|
@@ -1087,32 +1195,32 @@ var J = class e {
|
|
|
1087
1195
|
return this._reviewSnapshot().revisions;
|
|
1088
1196
|
}
|
|
1089
1197
|
commentAnchorRanges() {
|
|
1090
|
-
if (this._meta) return this._meta.commentAnchorRanges ??
|
|
1198
|
+
if (this._meta) return this._meta.commentAnchorRanges ?? yn;
|
|
1091
1199
|
if (!this._document || !this._source) return [];
|
|
1092
1200
|
let e = this._reviewSnapshot().comments;
|
|
1093
|
-
if (e.length === 0) return
|
|
1094
|
-
let t =
|
|
1201
|
+
if (e.length === 0) return yn;
|
|
1202
|
+
let t = E(this), n = t.services;
|
|
1095
1203
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1096
|
-
let r =
|
|
1204
|
+
let r = Ue(n);
|
|
1097
1205
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1098
1206
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1099
|
-
this._reviewProjectionIndex ??=
|
|
1207
|
+
this._reviewProjectionIndex ??= $e(a);
|
|
1100
1208
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1101
|
-
return this._commentAnchorRanges ??=
|
|
1209
|
+
return this._commentAnchorRanges ??= dt(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._commentAnchorRanges;
|
|
1102
1210
|
}
|
|
1103
1211
|
revisionAnchorRanges() {
|
|
1104
|
-
if (this._meta) return this._meta.revisionAnchorRanges ??
|
|
1212
|
+
if (this._meta) return this._meta.revisionAnchorRanges ?? bn;
|
|
1105
1213
|
if (!this._document || !this._source) return [];
|
|
1106
1214
|
let e = this._reviewSnapshot().revisions;
|
|
1107
|
-
if (e.length === 0) return
|
|
1108
|
-
let t =
|
|
1215
|
+
if (e.length === 0) return bn;
|
|
1216
|
+
let t = E(this), n = t.services;
|
|
1109
1217
|
if (!n) throw Error("Document layout services are not initialized");
|
|
1110
|
-
let r =
|
|
1218
|
+
let r = Ue(n);
|
|
1111
1219
|
if (!r) throw Error("Document layout variant store is not initialized");
|
|
1112
1220
|
let i = t.activeLayoutOptions, a = i ? r.layoutFor(i) : r.defaultLayout;
|
|
1113
|
-
this._reviewProjectionIndex ??=
|
|
1221
|
+
this._reviewProjectionIndex ??= $e(a);
|
|
1114
1222
|
let o = this._layoutLifecycle?.complete ?? !0 ? void 0 : { completedSourceKeys: this._reviewProjectionIndex.completedSourceKeys };
|
|
1115
|
-
return this._revisionAnchorRanges ??=
|
|
1223
|
+
return this._revisionAnchorRanges ??= cn(e, this._source, this._reviewProjectionIndex.renderedRunIndex, o), this._revisionAnchorRanges;
|
|
1116
1224
|
}
|
|
1117
1225
|
_reviewSnapshot() {
|
|
1118
1226
|
return this._review ||= q(this._meta?.comments ?? this._document?.comments ?? [], this._meta?.revisions ?? this._document?.revisions ?? []), this._review;
|
|
@@ -1125,16 +1233,16 @@ var J = class e {
|
|
|
1125
1233
|
}
|
|
1126
1234
|
_getLayout() {
|
|
1127
1235
|
if (!this._document) return null;
|
|
1128
|
-
let e =
|
|
1236
|
+
let e = E(this), t = e.services;
|
|
1129
1237
|
if (!t) throw Error("Document layout services are not initialized");
|
|
1130
|
-
let n =
|
|
1238
|
+
let n = Ue(t);
|
|
1131
1239
|
if (!n) throw Error("Document layout variant store is not initialized");
|
|
1132
1240
|
let r = e.activeLayoutOptions;
|
|
1133
1241
|
return r ? n.layoutFor(r) : n.defaultLayout;
|
|
1134
1242
|
}
|
|
1135
1243
|
async setLayoutView(e = {}) {
|
|
1136
|
-
let t = e[
|
|
1137
|
-
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)) {
|
|
1138
1246
|
if (this._mode === "worker" && this._meta) {
|
|
1139
1247
|
let e = await this._bridge.request((e) => ({
|
|
1140
1248
|
type: "selectLayoutView",
|
|
@@ -1147,17 +1255,17 @@ var J = class e {
|
|
|
1147
1255
|
n.activeLayoutOptions = r, this._meta = {
|
|
1148
1256
|
...this._meta,
|
|
1149
1257
|
...a.meta
|
|
1150
|
-
}, this._invalidateLayoutDerivedCaches(),
|
|
1258
|
+
}, this._invalidateLayoutDerivedCaches(), hn(this, t);
|
|
1151
1259
|
return;
|
|
1152
1260
|
}
|
|
1153
|
-
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(),
|
|
1261
|
+
n.activeLayoutOptions = r, this._invalidateLayoutDerivedCaches(), hn(this, t);
|
|
1154
1262
|
}
|
|
1155
1263
|
}
|
|
1156
1264
|
_getBookmarkPages() {
|
|
1157
1265
|
if (this._bookmarkPages) return this._bookmarkPages;
|
|
1158
1266
|
if (this._meta) return this._bookmarkPages = new Map(this._meta.bookmarkPages), this._bookmarkPages;
|
|
1159
1267
|
let e = this._getLayout();
|
|
1160
|
-
return e ? (this._bookmarkPages =
|
|
1268
|
+
return e ? (this._bookmarkPages = Lt(e), this._bookmarkPages) : null;
|
|
1161
1269
|
}
|
|
1162
1270
|
getBookmarkPage(e) {
|
|
1163
1271
|
return this._getBookmarkPages()?.get(e);
|
|
@@ -1189,7 +1297,7 @@ var J = class e {
|
|
|
1189
1297
|
};
|
|
1190
1298
|
}
|
|
1191
1299
|
_withActiveView(e) {
|
|
1192
|
-
let t =
|
|
1300
|
+
let t = E(this).activeLayoutOptions;
|
|
1193
1301
|
if (!t) return e;
|
|
1194
1302
|
let n = { ...e };
|
|
1195
1303
|
return e.currentDate === void 0 && (n.currentDate = t.currentDateMs), e.showTrackedChanges === void 0 && t.showTrackedChanges === !0 && (n.showTrackedChanges = !0), n;
|
|
@@ -1197,11 +1305,11 @@ var J = class e {
|
|
|
1197
1305
|
renderPage(e, t, n = {}) {
|
|
1198
1306
|
if (this._mode === "worker") throw Error("renderPage(canvas) is unavailable in mode: 'worker'; use renderPageToBitmap() and paint it via an ImageBitmapRenderingContext");
|
|
1199
1307
|
if (!this._source) throw Error("Document not loaded");
|
|
1200
|
-
return
|
|
1308
|
+
return Le(this._source, e, t, {
|
|
1201
1309
|
...this._withActiveView(n),
|
|
1202
1310
|
fetchImage: this._fetchImage,
|
|
1203
|
-
layoutServices:
|
|
1204
|
-
defaultCurrentDateMs:
|
|
1311
|
+
layoutServices: E(this).services ?? void 0,
|
|
1312
|
+
defaultCurrentDateMs: E(this).defaultCurrentDateMs,
|
|
1205
1313
|
threeD: this._threeD,
|
|
1206
1314
|
regionMap: this._regionMap,
|
|
1207
1315
|
chartEx: this._chartEx,
|
|
@@ -1241,9 +1349,9 @@ var J = class e {
|
|
|
1241
1349
|
pageIndex: e,
|
|
1242
1350
|
opts: n
|
|
1243
1351
|
}))).runs;
|
|
1244
|
-
let r =
|
|
1352
|
+
let r = E(this), i = r.services;
|
|
1245
1353
|
if (!i) throw Error("Document layout services are not initialized");
|
|
1246
|
-
return
|
|
1354
|
+
return et(i, e, {
|
|
1247
1355
|
currentDate: n.currentDate,
|
|
1248
1356
|
defaultCurrentDateMs: r.defaultCurrentDateMs,
|
|
1249
1357
|
width: n.width,
|
|
@@ -1252,7 +1360,7 @@ var J = class e {
|
|
|
1252
1360
|
}
|
|
1253
1361
|
async getCommentThreads(e, t = {}) {
|
|
1254
1362
|
let { includeResolved: n, ...r } = t, i = await this.collectPageRuns(e, r);
|
|
1255
|
-
return
|
|
1363
|
+
return ut(this.comments, this.commentAnchorRanges(), i, { includeResolved: n });
|
|
1256
1364
|
}
|
|
1257
1365
|
async getElementContextAt(e, t, n = {}) {
|
|
1258
1366
|
let r = this._withActiveView(n);
|
|
@@ -1263,9 +1371,9 @@ var J = class e {
|
|
|
1263
1371
|
point: t,
|
|
1264
1372
|
opts: r
|
|
1265
1373
|
}))).context;
|
|
1266
|
-
let i =
|
|
1374
|
+
let i = E(this), a = i.services;
|
|
1267
1375
|
if (!a) throw Error("Document layout services are not initialized");
|
|
1268
|
-
return
|
|
1376
|
+
return tn(a, e, t, {
|
|
1269
1377
|
...r,
|
|
1270
1378
|
defaultCurrentDateMs: i.defaultCurrentDateMs
|
|
1271
1379
|
});
|
|
@@ -1273,7 +1381,7 @@ var J = class e {
|
|
|
1273
1381
|
};
|
|
1274
1382
|
//#endregion
|
|
1275
1383
|
//#region packages/docx/src/tate-chu-yoko-overlay.ts
|
|
1276
|
-
function
|
|
1384
|
+
function Sn(e, t) {
|
|
1277
1385
|
if (!e.eastAsianVert) return 1;
|
|
1278
1386
|
let n = t(e.text);
|
|
1279
1387
|
return !(n > 0) || e.w >= n ? 1 : e.w / n;
|
|
@@ -1291,11 +1399,11 @@ function X(e, t, n, r, i, a, o) {
|
|
|
1291
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;
|
|
1292
1400
|
let l = c.transform ?? "";
|
|
1293
1401
|
if (a && c.eastAsianVert) {
|
|
1294
|
-
let e =
|
|
1402
|
+
let e = Sn(c, a(c.font));
|
|
1295
1403
|
e !== 1 && (l = `${l ? `${l} ` : ""}scaleX(${e})`);
|
|
1296
1404
|
}
|
|
1297
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`;
|
|
1298
|
-
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) => {
|
|
1299
1407
|
e.preventDefault(), i(d);
|
|
1300
1408
|
})), e.appendChild(t);
|
|
1301
1409
|
}
|
|
@@ -1308,16 +1416,16 @@ function Z(e, t, n, r, i, a, o = {}) {
|
|
|
1308
1416
|
for (let s of o.slices) {
|
|
1309
1417
|
let o = t[s.runIndex];
|
|
1310
1418
|
if (!o) continue;
|
|
1311
|
-
let c = a(o.font), l =
|
|
1312
|
-
if (
|
|
1313
|
-
let
|
|
1314
|
-
|
|
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);
|
|
1315
1423
|
}
|
|
1316
1424
|
}
|
|
1317
1425
|
}
|
|
1318
1426
|
//#endregion
|
|
1319
1427
|
//#region packages/docx/src/find.ts
|
|
1320
|
-
var
|
|
1428
|
+
var Cn = class {
|
|
1321
1429
|
_pageRuns = /* @__PURE__ */ new Map();
|
|
1322
1430
|
_matches = [];
|
|
1323
1431
|
_active = -1;
|
|
@@ -1380,8 +1488,8 @@ var pn = class {
|
|
|
1380
1488
|
if (n !== this._generation) return [];
|
|
1381
1489
|
let o = r === this._runsRevision ? i : new Map([...i, ...this._pageRuns]), s = [];
|
|
1382
1490
|
for (let n = 0; n < a; n++) {
|
|
1383
|
-
let r = o.get(n) ?? [], i =
|
|
1384
|
-
for (let a of
|
|
1491
|
+
let r = o.get(n) ?? [], i = oe(r);
|
|
1492
|
+
for (let a of ae(i, e, t)) {
|
|
1385
1493
|
let e = a.slices.map((e) => r[e.runIndex].text.slice(e.start, e.end)).join("");
|
|
1386
1494
|
s.push({
|
|
1387
1495
|
page: n,
|
|
@@ -1393,10 +1501,10 @@ var pn = class {
|
|
|
1393
1501
|
return this._runsRevision++, this._pageRuns = o, this._matches = s, this._active = -1, this.matches();
|
|
1394
1502
|
}
|
|
1395
1503
|
next() {
|
|
1396
|
-
return this._active =
|
|
1504
|
+
return this._active = re(this._active, this._matches.length), this._activePublic();
|
|
1397
1505
|
}
|
|
1398
1506
|
prev() {
|
|
1399
|
-
return this._active =
|
|
1507
|
+
return this._active = le(this._active, this._matches.length), this._activePublic();
|
|
1400
1508
|
}
|
|
1401
1509
|
_activePublic() {
|
|
1402
1510
|
let e = this._matchAt(this._active);
|
|
@@ -1409,7 +1517,7 @@ var pn = class {
|
|
|
1409
1517
|
};
|
|
1410
1518
|
//#endregion
|
|
1411
1519
|
//#region packages/docx/src/selection-context.ts
|
|
1412
|
-
function
|
|
1520
|
+
function wn(e, t, n, r, i = {}) {
|
|
1413
1521
|
let a = e.find((e) => e.id === n && e.parentId === void 0);
|
|
1414
1522
|
if (!a) return null;
|
|
1415
1523
|
let o = new Map(e.map((e) => [e.id, e])), s = e.filter((e) => {
|
|
@@ -1423,7 +1531,7 @@ function mn(e, t, n, r, i = {}) {
|
|
|
1423
1531
|
t = e;
|
|
1424
1532
|
}
|
|
1425
1533
|
return !1;
|
|
1426
|
-
}), c =
|
|
1534
|
+
}), c = Ce({
|
|
1427
1535
|
id: a.id,
|
|
1428
1536
|
author: a.author,
|
|
1429
1537
|
date: a.date,
|
|
@@ -1452,19 +1560,19 @@ function mn(e, t, n, r, i = {}) {
|
|
|
1452
1560
|
maxTextCharacters: c.maxTextCharacters
|
|
1453
1561
|
});
|
|
1454
1562
|
}
|
|
1455
|
-
function
|
|
1563
|
+
function Tn(e) {
|
|
1456
1564
|
if (e === void 0 || !/^\d+$/.test(e)) return null;
|
|
1457
1565
|
let t = Number(e);
|
|
1458
1566
|
return Number.isSafeInteger(t) ? t : null;
|
|
1459
1567
|
}
|
|
1460
|
-
function
|
|
1568
|
+
function En(e) {
|
|
1461
1569
|
for (let t = e; t; t = t.parentElement) {
|
|
1462
|
-
let e =
|
|
1570
|
+
let e = Tn(t.dataset.pageIndex);
|
|
1463
1571
|
if (e !== null) return e;
|
|
1464
1572
|
}
|
|
1465
1573
|
return null;
|
|
1466
1574
|
}
|
|
1467
|
-
var
|
|
1575
|
+
var Dn = new Set([
|
|
1468
1576
|
"body",
|
|
1469
1577
|
"header",
|
|
1470
1578
|
"footer",
|
|
@@ -1472,9 +1580,9 @@ var _n = new Set([
|
|
|
1472
1580
|
"endnote",
|
|
1473
1581
|
"textbox"
|
|
1474
1582
|
]);
|
|
1475
|
-
function
|
|
1583
|
+
function On(e) {
|
|
1476
1584
|
let t = e.dataset.sourceStory, n = e.dataset.sourceStoryInstance, r = e.dataset.sourcePath;
|
|
1477
|
-
if (!t || !
|
|
1585
|
+
if (!t || !Dn.has(t) || !n || !r) return null;
|
|
1478
1586
|
try {
|
|
1479
1587
|
let e = JSON.parse(r);
|
|
1480
1588
|
return !Array.isArray(e) || e.length === 0 || e.length > 32 || !e.every((e) => Number.isSafeInteger(e) && e >= 0) ? null : {
|
|
@@ -1487,13 +1595,13 @@ function vn(e) {
|
|
|
1487
1595
|
}
|
|
1488
1596
|
}
|
|
1489
1597
|
function Q(e, t, n = {}) {
|
|
1490
|
-
let r =
|
|
1491
|
-
let t =
|
|
1598
|
+
let r = de(e, t, (e) => {
|
|
1599
|
+
let t = En(e), n = Tn(e.dataset.runIndex);
|
|
1492
1600
|
return t === null || n === null ? null : {
|
|
1493
1601
|
pageIndex: t,
|
|
1494
1602
|
runIndex: n,
|
|
1495
1603
|
...e.dataset.paragraphId === void 0 ? {} : { paragraphId: e.dataset.paragraphId },
|
|
1496
|
-
...
|
|
1604
|
+
...On(e) === null ? {} : { source: On(e) }
|
|
1497
1605
|
};
|
|
1498
1606
|
}, {
|
|
1499
1607
|
maxChars: n.maxTextCharacters,
|
|
@@ -1522,7 +1630,7 @@ function $(e, t, n, r, i) {
|
|
|
1522
1630
|
}
|
|
1523
1631
|
//#endregion
|
|
1524
1632
|
//#region packages/docx/src/viewer.ts
|
|
1525
|
-
var
|
|
1633
|
+
var kn = Symbol("DocxViewer.borrowedDocument"), An = class e {
|
|
1526
1634
|
_documentOwner;
|
|
1527
1635
|
get _doc() {
|
|
1528
1636
|
return this._documentOwner.current;
|
|
@@ -1565,20 +1673,20 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1565
1673
|
...r,
|
|
1566
1674
|
currentDate: i.currentDate,
|
|
1567
1675
|
showTrackedChanges: i.showTrackedChanges,
|
|
1568
|
-
[
|
|
1676
|
+
[kn]: n
|
|
1569
1677
|
});
|
|
1570
1678
|
}
|
|
1571
1679
|
constructor(e, t = {}) {
|
|
1572
1680
|
this._canvas = e, this._opts = t;
|
|
1573
|
-
let n = t[
|
|
1574
|
-
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);
|
|
1575
1683
|
let r = e.ownerDocument?.defaultView ?? (typeof window < "u" ? window : null);
|
|
1576
1684
|
if (!r) throw Error("DocxViewer requires a canvas with an active Window");
|
|
1577
|
-
this._hostWindow = r, this._canvasMount = new
|
|
1685
|
+
this._hostWindow = r, this._canvasMount = new fe(e, {
|
|
1578
1686
|
wrapperCssText: "position:relative;display:inline-block;vertical-align:top;",
|
|
1579
1687
|
forceDisplayBlock: !0
|
|
1580
|
-
}), this._wrapper = this._canvasMount.wrapper, this._renderDispatcher = new
|
|
1581
|
-
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);
|
|
1582
1690
|
this._textLayer = i.textLayer, this._highlightLayer = i.highlightLayer, this._elementLayer = i.elementLayer, this._loadingLayer = this._wrapper.ownerDocument.createElement("div"), this._loadingLayer.style.cssText = [
|
|
1583
1691
|
"position:absolute",
|
|
1584
1692
|
"inset:0",
|
|
@@ -1592,7 +1700,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1592
1700
|
let a = this._wrapper.ownerDocument.createElement("progress");
|
|
1593
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) => {
|
|
1594
1702
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
1595
|
-
}, 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);
|
|
1596
1704
|
}
|
|
1597
1705
|
async load(e) {
|
|
1598
1706
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
@@ -1673,7 +1781,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1673
1781
|
await this.goToPage(this._currentPage - 1);
|
|
1674
1782
|
}
|
|
1675
1783
|
_naturalWidthPx() {
|
|
1676
|
-
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;
|
|
1677
1785
|
}
|
|
1678
1786
|
_renderWidth() {
|
|
1679
1787
|
if (this._scale === null) return this._opts.width;
|
|
@@ -1692,14 +1800,14 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1692
1800
|
return this._opts.zoomMax ?? 4;
|
|
1693
1801
|
}
|
|
1694
1802
|
async setScale(e) {
|
|
1695
|
-
let t =
|
|
1803
|
+
let t = ie(e, this._zoomMin(), this._zoomMax()), n = t !== this.getScale();
|
|
1696
1804
|
this._scale = t, await this._render(), n && this._opts.onScaleChange?.(t);
|
|
1697
1805
|
}
|
|
1698
1806
|
async zoomIn() {
|
|
1699
|
-
await this.setScale(
|
|
1807
|
+
await this.setScale(me(this.getScale()));
|
|
1700
1808
|
}
|
|
1701
1809
|
async zoomOut() {
|
|
1702
|
-
await this.setScale(
|
|
1810
|
+
await this.setScale(_e(this.getScale()));
|
|
1703
1811
|
}
|
|
1704
1812
|
async fitWidth() {
|
|
1705
1813
|
await this._fit("width");
|
|
@@ -1711,9 +1819,9 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1711
1819
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
1712
1820
|
let t = this._doc.pageSize(this._currentPage), n = this._fitContainer();
|
|
1713
1821
|
if (!n) return;
|
|
1714
|
-
let r =
|
|
1715
|
-
contentWidth: t.widthPt *
|
|
1716
|
-
contentHeight: t.heightPt *
|
|
1822
|
+
let r = y({
|
|
1823
|
+
contentWidth: t.widthPt * D,
|
|
1824
|
+
contentHeight: t.heightPt * D,
|
|
1717
1825
|
containerWidth: n.clientWidth,
|
|
1718
1826
|
containerHeight: n.clientHeight
|
|
1719
1827
|
}, e);
|
|
@@ -1752,7 +1860,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1752
1860
|
}
|
|
1753
1861
|
getSelectionContext(e = {}) {
|
|
1754
1862
|
if (this._destroyed) throw Error("DocxViewer is destroyed");
|
|
1755
|
-
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);
|
|
1756
1864
|
}
|
|
1757
1865
|
_emitSelectionContextChange() {
|
|
1758
1866
|
let e = this.getSelectionContext();
|
|
@@ -1769,11 +1877,11 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1769
1877
|
_redrawElementOutline() {
|
|
1770
1878
|
let e = this._elementContext, t = this._doc;
|
|
1771
1879
|
if (!e || !t || e.pageIndex !== this._currentPage) {
|
|
1772
|
-
|
|
1880
|
+
x(this._elementLayer, null);
|
|
1773
1881
|
return;
|
|
1774
1882
|
}
|
|
1775
1883
|
let n = t.pageSize(e.pageIndex);
|
|
1776
|
-
|
|
1884
|
+
x(this._elementLayer, {
|
|
1777
1885
|
x: e.bounds.xPt / n.widthPt,
|
|
1778
1886
|
y: e.bounds.yPt / n.heightPt,
|
|
1779
1887
|
width: e.bounds.widthPt / n.widthPt,
|
|
@@ -1807,7 +1915,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1807
1915
|
}, {
|
|
1808
1916
|
currentDate: this._opts.currentDate,
|
|
1809
1917
|
showTrackedChanges: this._opts.showTrackedChanges,
|
|
1810
|
-
maxTextCharacters:
|
|
1918
|
+
maxTextCharacters: F
|
|
1811
1919
|
});
|
|
1812
1920
|
} catch (e) {
|
|
1813
1921
|
if (this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc) return null;
|
|
@@ -1816,7 +1924,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1816
1924
|
return this._destroyed || a !== this._elementHitGeneration || o !== this._currentPage || t !== this._doc ? null : (this._setElementContext(c), this._destroyed ? null : this.getSelectionContext());
|
|
1817
1925
|
}
|
|
1818
1926
|
destroy() {
|
|
1819
|
-
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());
|
|
1820
1928
|
}
|
|
1821
1929
|
async _render() {
|
|
1822
1930
|
let e = this._renderDispatcher.begin();
|
|
@@ -1852,7 +1960,7 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1852
1960
|
}
|
|
1853
1961
|
_bindLayoutDocument(e) {
|
|
1854
1962
|
this._unbindLayoutDocument(), this._layoutFailed = !1, this._layoutViewPublicationGeneration = 0;
|
|
1855
|
-
let t =
|
|
1963
|
+
let t = gn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = fn(e, () => ({
|
|
1856
1964
|
pageCount: e.pageCount,
|
|
1857
1965
|
exact: e.layoutComplete,
|
|
1858
1966
|
complete: e.layoutComplete
|
|
@@ -1968,11 +2076,11 @@ var yn = Symbol("DocxViewer.borrowedDocument"), bn = class e {
|
|
|
1968
2076
|
let r = e.getBookmarkPage(t);
|
|
1969
2077
|
r !== void 0 && await this.goToPage(r);
|
|
1970
2078
|
}
|
|
1971
|
-
},
|
|
1972
|
-
function
|
|
1973
|
-
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");
|
|
1974
2082
|
}
|
|
1975
|
-
var
|
|
2083
|
+
var Rn = class e {
|
|
1976
2084
|
_documentOwner;
|
|
1977
2085
|
get _doc() {
|
|
1978
2086
|
return this._documentOwner.current;
|
|
@@ -2035,7 +2143,7 @@ var On = class e {
|
|
|
2035
2143
|
_prevBase = 0;
|
|
2036
2144
|
_lastFitWidth = 0;
|
|
2037
2145
|
_pageShadow;
|
|
2038
|
-
_find = new
|
|
2146
|
+
_find = new Cn(() => this.pageCount, (e) => this._collectPageRuns(e));
|
|
2039
2147
|
_findActive = !1;
|
|
2040
2148
|
_findRequestGeneration = 0;
|
|
2041
2149
|
_showTrackedChanges;
|
|
@@ -2048,14 +2156,14 @@ var On = class e {
|
|
|
2048
2156
|
...r,
|
|
2049
2157
|
currentDate: i.currentDate,
|
|
2050
2158
|
showTrackedChanges: i.showTrackedChanges,
|
|
2051
|
-
[
|
|
2159
|
+
[Fn]: n
|
|
2052
2160
|
});
|
|
2053
2161
|
}
|
|
2054
2162
|
constructor(e, t = {}) {
|
|
2055
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.");
|
|
2056
|
-
this._container = e, this._opts = t, this._errorRouter = new
|
|
2057
|
-
let n = t[
|
|
2058
|
-
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) => {
|
|
2059
2167
|
if (!this._destroyed) {
|
|
2060
2168
|
this._commentUi = e;
|
|
2061
2169
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
@@ -2063,7 +2171,7 @@ var On = class e {
|
|
|
2063
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) => {
|
|
2064
2172
|
this._onElementClick(e).catch((e) => this._reportRenderError(e));
|
|
2065
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) => {
|
|
2066
|
-
if (!
|
|
2174
|
+
if (!Ee(e, this._wrapper, "ooxmlCommentId") && this._activeCommentId !== null) {
|
|
2067
2175
|
this._activeCommentId = null, this._activeCommentPage = null;
|
|
2068
2176
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2069
2177
|
this._emitSelectionContextChange();
|
|
@@ -2074,7 +2182,7 @@ var On = class e {
|
|
|
2074
2182
|
this._pendingZoomAnchor = Number.isFinite(n) && Number.isFinite(r) ? {
|
|
2075
2183
|
x: n,
|
|
2076
2184
|
y: r
|
|
2077
|
-
} : null, this.setScale(
|
|
2185
|
+
} : null, this.setScale(ge(this._scale, e.deltaY, e.deltaMode));
|
|
2078
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());
|
|
2079
2187
|
}
|
|
2080
2188
|
async load(e) {
|
|
@@ -2134,7 +2242,7 @@ var On = class e {
|
|
|
2134
2242
|
}
|
|
2135
2243
|
_bindLayoutDocument(e) {
|
|
2136
2244
|
this._unbindLayoutDocument(), this._layoutViewPublicationGeneration = 0, this._presentedPageCount = e.pageCount;
|
|
2137
|
-
let t =
|
|
2245
|
+
let t = gn(e, (t) => this._onLayoutViewPublication(e, t), (e) => this._reportRenderError(e)), n = !0, r = fn(e, () => ({
|
|
2138
2246
|
pageCount: e.pageCount,
|
|
2139
2247
|
exact: e.layoutComplete,
|
|
2140
2248
|
complete: e.layoutComplete
|
|
@@ -2180,10 +2288,10 @@ var On = class e {
|
|
|
2180
2288
|
for (let [e, n] of t) e >= this._presentedPageCount || this._slots.get(e) !== n || this._refreshSlotAtomically(e, n);
|
|
2181
2289
|
}
|
|
2182
2290
|
_pageWidthPx(e) {
|
|
2183
|
-
return this._doc.pageSize(e).widthPt *
|
|
2291
|
+
return this._doc.pageSize(e).widthPt * D * this._scale;
|
|
2184
2292
|
}
|
|
2185
2293
|
_pageHeightPx(e) {
|
|
2186
|
-
return this._doc.pageSize(e).heightPt *
|
|
2294
|
+
return this._doc.pageSize(e).heightPt * D * this._scale;
|
|
2187
2295
|
}
|
|
2188
2296
|
_fitWidthPx() {
|
|
2189
2297
|
if (this._opts.width && this._opts.width > 0) return this._opts.width;
|
|
@@ -2205,7 +2313,7 @@ var On = class e {
|
|
|
2205
2313
|
return e.comments.some((e) => this._commentAnchorIds.has(e.id) && e.parentId === void 0 && (n || e.resolved !== !0));
|
|
2206
2314
|
}
|
|
2207
2315
|
_commentMarginExtent() {
|
|
2208
|
-
return this._hasCommentMargin() ? (
|
|
2316
|
+
return this._hasCommentMargin() ? (Nn + 280) * this._commentZoom() : 0;
|
|
2209
2317
|
}
|
|
2210
2318
|
_commentZoom() {
|
|
2211
2319
|
return this._scaleEstablished ? this._scale : 1;
|
|
@@ -2223,8 +2331,8 @@ var On = class e {
|
|
|
2223
2331
|
_syncCommentMarginGeometry(e) {
|
|
2224
2332
|
if (!e) return;
|
|
2225
2333
|
e.style.display = this._hasCommentMargin() ? "" : "none";
|
|
2226
|
-
let t = this._commentZoom(), n = `calc(100% + ${
|
|
2227
|
-
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);
|
|
2228
2336
|
}
|
|
2229
2337
|
_widestPageWidthPt() {
|
|
2230
2338
|
if (!this._doc) return 0;
|
|
@@ -2240,7 +2348,7 @@ var On = class e {
|
|
|
2240
2348
|
let e = this._fitWidthPx();
|
|
2241
2349
|
if (e <= 0) return 0;
|
|
2242
2350
|
let t = this._widestPageWidthPt();
|
|
2243
|
-
return t <= 0 ? 0 : e / (t *
|
|
2351
|
+
return t <= 0 ? 0 : e / (t * D);
|
|
2244
2352
|
}
|
|
2245
2353
|
relayout() {
|
|
2246
2354
|
this._relayout();
|
|
@@ -2269,7 +2377,7 @@ var On = class e {
|
|
|
2269
2377
|
_recomputeHeights() {
|
|
2270
2378
|
let e = Math.min(this._presentedPageCount, this._doc.pageCount), t = Array(e);
|
|
2271
2379
|
for (let n = 0; n < e; n++) t[n] = this._pageHeightPx(n);
|
|
2272
|
-
this._heights = t, this._scrollGeometry =
|
|
2380
|
+
this._heights = t, this._scrollGeometry = Te(t, this._gap(), this._pad());
|
|
2273
2381
|
}
|
|
2274
2382
|
_gap() {
|
|
2275
2383
|
return this._opts.gap ?? 16;
|
|
@@ -2300,7 +2408,7 @@ var On = class e {
|
|
|
2300
2408
|
return a;
|
|
2301
2409
|
}
|
|
2302
2410
|
_range() {
|
|
2303
|
-
return
|
|
2411
|
+
return w(this._scrollGeometry, this._scrollHost.scrollTop, this._scrollHost.clientHeight, this._overscan());
|
|
2304
2412
|
}
|
|
2305
2413
|
_syncSpacer() {
|
|
2306
2414
|
let e = this._range();
|
|
@@ -2357,7 +2465,7 @@ var On = class e {
|
|
|
2357
2465
|
i.style.cssText = "position:absolute;top:0;left:0;width:100%;height:100%;overflow:hidden;pointer-events:none;", t.appendChild(i);
|
|
2358
2466
|
let a = null, o = null, s = null;
|
|
2359
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)));
|
|
2360
|
-
let c =
|
|
2468
|
+
let c = ce(t, this._opts.enableElementSelection === !0);
|
|
2361
2469
|
return this._scrollHost.appendChild(t), {
|
|
2362
2470
|
wrapper: t,
|
|
2363
2471
|
canvas: n,
|
|
@@ -2371,11 +2479,11 @@ var On = class e {
|
|
|
2371
2479
|
commentGeometry: null,
|
|
2372
2480
|
renderedPage: -1,
|
|
2373
2481
|
renderedScale: -1,
|
|
2374
|
-
dispatcher: new
|
|
2482
|
+
dispatcher: new S(n, this._mode === "worker")
|
|
2375
2483
|
};
|
|
2376
2484
|
}
|
|
2377
2485
|
_recycleSlot(e, t) {
|
|
2378
|
-
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);
|
|
2379
2487
|
}
|
|
2380
2488
|
_positionSlot(e, t, n) {
|
|
2381
2489
|
e.wrapper.style.top = `${n.offsets[t]}px`;
|
|
@@ -2505,12 +2613,12 @@ var On = class e {
|
|
|
2505
2613
|
f = Math.min(1, Math.max(0, f));
|
|
2506
2614
|
let p = this._padH().left, m = this._scrollHost.scrollLeft || 0;
|
|
2507
2615
|
this._renderEpoch++, this._scale = r, this._recomputeHeights();
|
|
2508
|
-
let h =
|
|
2616
|
+
let h = w(this._scrollGeometry, 0, this._scrollHost.clientHeight, this._overscan());
|
|
2509
2617
|
this._spacer.style.height = `${h.totalHeight}px`, this._syncSpacerWidth();
|
|
2510
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;
|
|
2511
2619
|
if (this._scrollHost.scrollTop = Math.min(g, Math.max(0, v)), i) {
|
|
2512
2620
|
let e = Math.max(0, (this._spacer.offsetWidth || 0) - this._scrollHost.clientWidth);
|
|
2513
|
-
this._scrollHost.scrollLeft =
|
|
2621
|
+
this._scrollHost.scrollLeft = te(m, i.x - p, a, r, { maxScroll: e });
|
|
2514
2622
|
}
|
|
2515
2623
|
this._previewVisible(), this._scheduleSettle(), this._opts.onScaleChange?.(r);
|
|
2516
2624
|
}
|
|
@@ -2518,10 +2626,10 @@ var On = class e {
|
|
|
2518
2626
|
return this._scaleEstablished ? this._scale : this._pendingScale ?? 1;
|
|
2519
2627
|
}
|
|
2520
2628
|
zoomIn() {
|
|
2521
|
-
this.setScale(
|
|
2629
|
+
this.setScale(me(this.getScale()));
|
|
2522
2630
|
}
|
|
2523
2631
|
zoomOut() {
|
|
2524
|
-
this.setScale(
|
|
2632
|
+
this.setScale(_e(this.getScale(), this._effectiveZoomMin()));
|
|
2525
2633
|
}
|
|
2526
2634
|
_effectiveZoomMin() {
|
|
2527
2635
|
let e = this._opts.zoomMin ?? .1;
|
|
@@ -2535,9 +2643,9 @@ var On = class e {
|
|
|
2535
2643
|
}
|
|
2536
2644
|
_fit(e) {
|
|
2537
2645
|
if (!this._doc || this._doc.pageCount === 0) return;
|
|
2538
|
-
let t = this._doc.pageSize(0), n =
|
|
2539
|
-
contentWidth: (e === "width" ? this._widestPageWidthPt() : t.widthPt) *
|
|
2540
|
-
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,
|
|
2541
2649
|
containerWidth: this._fitWidthPx(),
|
|
2542
2650
|
containerHeight: this._scrollHost.clientHeight
|
|
2543
2651
|
}, e);
|
|
@@ -2574,7 +2682,7 @@ var On = class e {
|
|
|
2574
2682
|
_scheduleSettle() {
|
|
2575
2683
|
this._settleTimer !== null && clearTimeout(this._settleTimer), this._settleTimer = setTimeout(() => {
|
|
2576
2684
|
this._settleTimer = null, this._settleRender();
|
|
2577
|
-
},
|
|
2685
|
+
}, jn);
|
|
2578
2686
|
}
|
|
2579
2687
|
_settleRender() {
|
|
2580
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);
|
|
@@ -2588,7 +2696,7 @@ var On = class e {
|
|
|
2588
2696
|
}
|
|
2589
2697
|
let o = document.createElement("canvas");
|
|
2590
2698
|
o.style.cssText = "display:block;background:#fff;", this._applyPageShadow(o);
|
|
2591
|
-
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;
|
|
2592
2700
|
$(this._doc, o, e, "main", {
|
|
2593
2701
|
width: r,
|
|
2594
2702
|
dpr: n,
|
|
@@ -2632,14 +2740,14 @@ var On = class e {
|
|
|
2632
2740
|
}
|
|
2633
2741
|
scrollToPage(e, t) {
|
|
2634
2742
|
if (!this._doc || this._doc.pageCount === 0 || !this._scaleEstablished) return;
|
|
2635
|
-
let n = Math.max(0, Math.min(e, this._doc.pageCount - 1)), r =
|
|
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;
|
|
2636
2744
|
typeof a.scrollTo == "function" ? a.scrollTo({
|
|
2637
2745
|
top: i,
|
|
2638
2746
|
behavior: t?.behavior ?? "auto"
|
|
2639
2747
|
}) : this._scrollHost.scrollTop = i, this._mountVisible();
|
|
2640
2748
|
}
|
|
2641
2749
|
_scrollToPageTarget(e, t, n) {
|
|
2642
|
-
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;
|
|
2643
2751
|
typeof f.scrollTo == "function" ? f.scrollTo({
|
|
2644
2752
|
top: u,
|
|
2645
2753
|
left: d,
|
|
@@ -2654,7 +2762,7 @@ var On = class e {
|
|
|
2654
2762
|
}
|
|
2655
2763
|
_indexCommentPages(e, t, n) {
|
|
2656
2764
|
if (!this._commentIndexedPages.has(e)) {
|
|
2657
|
-
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);
|
|
2658
2766
|
this._commentIndexedPages.add(e), this._advanceCommentScanFrontier();
|
|
2659
2767
|
}
|
|
2660
2768
|
}
|
|
@@ -2704,7 +2812,7 @@ var On = class e {
|
|
|
2704
2812
|
if (a.length === 0 || o !== void 0 && o >= n.pageCount || s === void 0) return !1;
|
|
2705
2813
|
let u = await this._commentRunsForPage(s, n);
|
|
2706
2814
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2707
|
-
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;
|
|
2708
2816
|
this._activeCommentId = e, this._activeCommentPage = s, this._elementContext = null, this._scrollToPageTarget(s, c, t);
|
|
2709
2817
|
for (let [e, t] of this._slots) this._redrawSlotComments(e, t);
|
|
2710
2818
|
return this._emitSelectionContextChange(), !0;
|
|
@@ -2881,7 +2989,7 @@ var On = class e {
|
|
|
2881
2989
|
}
|
|
2882
2990
|
getSelectionContext(e = {}) {
|
|
2883
2991
|
if (this._destroyed) throw Error("DocxScrollViewer is destroyed");
|
|
2884
|
-
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));
|
|
2885
2993
|
}
|
|
2886
2994
|
_emitSelectionContextChange() {
|
|
2887
2995
|
let e = this.getSelectionContext();
|
|
@@ -2901,11 +3009,11 @@ var On = class e {
|
|
|
2901
3009
|
_redrawElementOutlineForSlot(e, t) {
|
|
2902
3010
|
let n = this._elementContext, r = this._doc;
|
|
2903
3011
|
if (!n || !r || n.pageIndex !== e) {
|
|
2904
|
-
|
|
3012
|
+
x(t.elementLayer, null);
|
|
2905
3013
|
return;
|
|
2906
3014
|
}
|
|
2907
3015
|
let i = r.pageSize(e);
|
|
2908
|
-
|
|
3016
|
+
x(t.elementLayer, {
|
|
2909
3017
|
x: n.bounds.xPt / i.widthPt,
|
|
2910
3018
|
y: n.bounds.yPt / i.heightPt,
|
|
2911
3019
|
width: n.bounds.widthPt / i.widthPt,
|
|
@@ -2941,7 +3049,7 @@ var On = class e {
|
|
|
2941
3049
|
}, {
|
|
2942
3050
|
currentDate: this._currentDate,
|
|
2943
3051
|
...this._showTrackedChanges ? { showTrackedChanges: !0 } : {},
|
|
2944
|
-
maxTextCharacters:
|
|
3052
|
+
maxTextCharacters: F
|
|
2945
3053
|
});
|
|
2946
3054
|
} catch (e) {
|
|
2947
3055
|
if (this._destroyed || l !== this._elementHitGeneration || t !== this._doc) return null;
|
|
@@ -2959,7 +3067,7 @@ var On = class e {
|
|
|
2959
3067
|
};
|
|
2960
3068
|
//#endregion
|
|
2961
3069
|
//#region packages/docx/src/types.ts
|
|
2962
|
-
function
|
|
3070
|
+
function zn(e) {
|
|
2963
3071
|
let t = [];
|
|
2964
3072
|
for (let n of e.content) {
|
|
2965
3073
|
if (n.type !== "paragraph") continue;
|
|
@@ -2971,25 +3079,25 @@ function kn(e) {
|
|
|
2971
3079
|
}
|
|
2972
3080
|
//#endregion
|
|
2973
3081
|
//#region src/docx.ts
|
|
2974
|
-
var
|
|
3082
|
+
var Bn = /* @__PURE__ */ e({
|
|
2975
3083
|
DocxDocument: () => J,
|
|
2976
|
-
DocxScrollViewer: () =>
|
|
2977
|
-
DocxViewer: () =>
|
|
2978
|
-
OoxmlDecodedImageLimitError: () =>
|
|
3084
|
+
DocxScrollViewer: () => Rn,
|
|
3085
|
+
DocxViewer: () => An,
|
|
3086
|
+
OoxmlDecodedImageLimitError: () => rt,
|
|
2979
3087
|
OoxmlError: () => c,
|
|
2980
3088
|
OoxmlResourceLimitError: () => d,
|
|
2981
|
-
TiffDecodeError: () =>
|
|
2982
|
-
autoResize: () =>
|
|
3089
|
+
TiffDecodeError: () => it,
|
|
3090
|
+
autoResize: () => ee,
|
|
2983
3091
|
buildDocxHighlightLayer: () => Z,
|
|
2984
3092
|
buildDocxTextLayer: () => X,
|
|
2985
|
-
isOoxmlDecodedImageLimitError: () =>
|
|
2986
|
-
isTiffDecodeError: () =>
|
|
2987
|
-
noteText: () =>
|
|
3093
|
+
isOoxmlDecodedImageLimitError: () => nt,
|
|
3094
|
+
isTiffDecodeError: () => at,
|
|
3095
|
+
noteText: () => zn,
|
|
2988
3096
|
openExternalHyperlink: () => u,
|
|
2989
3097
|
readDocxTextSelectionContext: () => Q,
|
|
2990
|
-
resolveCommentAnchorRuns: () =>
|
|
2991
|
-
resolveDocxCommentThreads: () =>
|
|
2992
|
-
resolveRevisionAnchorRuns: () =>
|
|
3098
|
+
resolveCommentAnchorRuns: () => A,
|
|
3099
|
+
resolveDocxCommentThreads: () => ut,
|
|
3100
|
+
resolveRevisionAnchorRuns: () => ln
|
|
2993
3101
|
});
|
|
2994
3102
|
//#endregion
|
|
2995
|
-
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 };
|