@arcships/pptx-core 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -4434,8 +4434,8 @@ z.set("bentUpArrow", (t, n, e) => {
4434
4434
  ].join(" ");
4435
4435
  });
4436
4436
  z.set("curvedRightArrow", (t, n, e) => {
4437
- const o = (e == null ? void 0 : e.get("adj1")) ?? 25e3, s = (e == null ? void 0 : e.get("adj2")) ?? 5e4, i = (e == null ? void 0 : e.get("adj3")) ?? 25e3, r = 5e4, c = 1e5, l = n / 2, a = t, d = n, h = 0, u = 270, x = 180, p = 90, $ = Math.max(Math.min(t, n), 1), g = r * n / $, f = Math.max(0, Math.min(s, g)), y = Math.max(0, Math.min(o, f)), m = $ * y / c, b = $ * f / c, M = (m + b) / 4, L = l - M, v = L * 2, k = v * v, A = m * m, S = Math.max(k - A, 0), F = Math.sqrt(S) * t / Math.max(v, 1e-6), C = c * F / $, E = Math.max(0, Math.min(i, C)), P = $ * E / c, B = L + m, R = t * t, I = P * P, Z = Math.max(R - I, 0), q = Math.sqrt(Z) * L / Math.max(t, 1e-6), Q = L + q, G = B + q, D = (b - m) / 2, O = Q - D, ot = G + D, J = b / 2, W = d - J, it = a - P, lt = Math.atan(q / Math.max(P, 1e-6)), Pt = Math.PI - lt, Rt = -lt, Wt = m / 2, ft = Math.atan2(Wt, Math.max(F, 1e-6)) - Math.PI / 2, Zt = Pt * 180 / Math.PI, Dt = Rt * 180 / Math.PI, Ot = lt * 180 / Math.PI, Ut = ft * 180 / Math.PI, Y = (Bt, Ft, Xt, H, N, et) => {
4438
- const nt = N * Math.PI / 180, at = et * Math.PI / 180, bt = Bt + Xt * Math.cos(nt), Mt = Ft + H * Math.sin(nt), tt = Bt + Xt * Math.cos(at), ht = Ft + H * Math.sin(at), ut = et - N, zt = Math.abs(ut) > 180 ? 1 : 0, te = ut >= 0 ? 1 : 0;
4437
+ const o = (e == null ? void 0 : e.get("adj1")) ?? 25e3, s = (e == null ? void 0 : e.get("adj2")) ?? 5e4, i = (e == null ? void 0 : e.get("adj3")) ?? 25e3, r = 5e4, c = 1e5, l = n / 2, a = t, d = n, h = 0, u = 270, x = 180, p = 90, $ = Math.max(Math.min(t, n), 1), g = r * n / $, f = Math.max(0, Math.min(s, g)), y = Math.max(0, Math.min(o, f)), m = $ * y / c, b = $ * f / c, M = (m + b) / 4, L = l - M, v = L * 2, k = v * v, A = m * m, S = Math.max(k - A, 0), F = Math.sqrt(S) * t / Math.max(v, 1e-6), C = c * F / $, E = Math.max(0, Math.min(i, C)), P = $ * E / c, B = L + m, R = t * t, I = P * P, Z = Math.max(R - I, 0), q = Math.sqrt(Z) * L / Math.max(t, 1e-6), Q = L + q, G = B + q, D = (b - m) / 2, O = Q - D, ot = G + D, J = b / 2, W = d - J, it = a - P, lt = Math.atan(q / Math.max(P, 1e-6)), Pt = Math.PI - lt, Rt = -lt, Wt = m / 2, ft = Math.atan2(Wt, Math.max(F, 1e-6)) - Math.PI / 2, Zt = Pt * 180 / Math.PI, Dt = Rt * 180 / Math.PI, Ot = lt * 180 / Math.PI, Ut = ft * 180 / Math.PI, Y = (Bt, Ft, Xt, H, N, et2) => {
4438
+ const nt = N * Math.PI / 180, at = et2 * Math.PI / 180, bt = Bt + Xt * Math.cos(nt), Mt = Ft + H * Math.sin(nt), tt = Bt + Xt * Math.cos(at), ht = Ft + H * Math.sin(at), ut = et2 - N, zt = Math.abs(ut) > 180 ? 1 : 0, te = ut >= 0 ? 1 : 0;
4439
4439
  return `M${bt},${Mt} A${Xt},${H} 0 ${zt},${te} ${tt},${ht}`;
4440
4440
  };
4441
4441
  return [
@@ -4527,7 +4527,7 @@ z.set("curvedDownArrow", (t, n, e) => {
4527
4527
  ].join(" ");
4528
4528
  });
4529
4529
  function Tc(t, n, e, o = false, s = "circularArrow") {
4530
- const i = t / 2, r = n / 2, c = t / 2, l = n / 2, a = Math.min(t, n), d = 108e5, h = (Ht) => Ht / 6e4 * Math.PI / 180, u = (Ht, oe) => Ht * Math.sin(h(oe)), x = (Ht, oe) => Ht * Math.cos(h(oe)), p = (Ht, oe, Ve) => Ht * Math.cos(Math.atan2(Ve, oe)), $ = (Ht, oe, Ve) => Ht * Math.sin(Math.atan2(Ve, oe)), g = (Ht, oe) => Math.atan2(oe, Ht) * 180 / Math.PI * 6e4, f = (Ht, oe, Ve) => Math.sqrt(Ht * Ht + oe * oe + Ve * Ve), y = s === "leftCircularArrow", m = (e == null ? void 0 : e.get("adj1")) ?? 12500, b = (e == null ? void 0 : e.get("adj2")) ?? (y ? -1142319 : 1142319), M = (e == null ? void 0 : e.get("adj3")) ?? (y ? 1142319 : 20457681), L = (e == null ? void 0 : e.get("adj4")) ?? 108e5, v = (e == null ? void 0 : e.get("adj5")) ?? 12500, k = Math.max(0, Math.min(v, 25e3)), A = k * 2, S = Math.max(0, Math.min(m, A)), w = Math.max(1, Math.min(M, 21599999)), F = Math.max(0, Math.min(L, 21599999)), C = a * S / 1e5, E = a * k / 1e5, P = C / 2, B = c + P - E, R = l + P - E, I = B - C, Z = R - C, U = I + P, q = Z + P, Q = u(U, w), G = x(q, w), T = p(U, G, Q), D = $(q, G, Q), O = i + T, ot = r + D, J = Math.min(I, Z), W = T * T, it = D * D, lt = J * J, Pt = W - lt, Rt = it - lt, Wt = it !== 0 ? Pt * Rt / W : 0, ft = 1 - (it !== 0 ? Wt / it : 0), Zt = Math.sqrt(Math.max(0, ft)), Dt = T !== 0 ? Pt / T : 0, Ot = D !== 0 ? Dt / D : 0, Ut = Ot !== 0 ? (1 + Zt) / Ot : 0, Y = g(1, Ut), Bt = Y + 216e5, Xt = (Y >= 0 ? Y : Bt) - w, H = Xt + 216e5, N = Xt >= 0 ? Xt : H, et = N - d, nt = N - 216e5, at = et >= 0 ? nt : N, bt = Math.abs(at);
4530
+ const i = t / 2, r = n / 2, c = t / 2, l = n / 2, a = Math.min(t, n), d = 108e5, h = (Ht) => Ht / 6e4 * Math.PI / 180, u = (Ht, oe) => Ht * Math.sin(h(oe)), x = (Ht, oe) => Ht * Math.cos(h(oe)), p = (Ht, oe, Ve) => Ht * Math.cos(Math.atan2(Ve, oe)), $ = (Ht, oe, Ve) => Ht * Math.sin(Math.atan2(Ve, oe)), g = (Ht, oe) => Math.atan2(oe, Ht) * 180 / Math.PI * 6e4, f = (Ht, oe, Ve) => Math.sqrt(Ht * Ht + oe * oe + Ve * Ve), y = s === "leftCircularArrow", m = (e == null ? void 0 : e.get("adj1")) ?? 12500, b = (e == null ? void 0 : e.get("adj2")) ?? (y ? -1142319 : 1142319), M = (e == null ? void 0 : e.get("adj3")) ?? (y ? 1142319 : 20457681), L = (e == null ? void 0 : e.get("adj4")) ?? 108e5, v = (e == null ? void 0 : e.get("adj5")) ?? 12500, k = Math.max(0, Math.min(v, 25e3)), A = k * 2, S = Math.max(0, Math.min(m, A)), w = Math.max(1, Math.min(M, 21599999)), F = Math.max(0, Math.min(L, 21599999)), C = a * S / 1e5, E = a * k / 1e5, P = C / 2, B = c + P - E, R = l + P - E, I = B - C, Z = R - C, U = I + P, q = Z + P, Q = u(U, w), G = x(q, w), T = p(U, G, Q), D = $(q, G, Q), O = i + T, ot = r + D, J = Math.min(I, Z), W = T * T, it = D * D, lt = J * J, Pt = W - lt, Rt = it - lt, Wt = it !== 0 ? Pt * Rt / W : 0, ft = 1 - (it !== 0 ? Wt / it : 0), Zt = Math.sqrt(Math.max(0, ft)), Dt = T !== 0 ? Pt / T : 0, Ot = D !== 0 ? Dt / D : 0, Ut = Ot !== 0 ? (1 + Zt) / Ot : 0, Y = g(1, Ut), Bt = Y + 216e5, Xt = (Y >= 0 ? Y : Bt) - w, H = Xt + 216e5, N = Xt >= 0 ? Xt : H, et2 = N - d, nt = N - 216e5, at = et2 >= 0 ? nt : N, bt = Math.abs(at);
4531
4531
  let Mt;
4532
4532
  if (y) {
4533
4533
  const Ht = -bt, oe = -Math.abs(b);
@@ -5650,13 +5650,13 @@ z.set("funnel", (t, n) => {
5650
5650
  `L${ot},${J}`,
5651
5651
  `A${f},${y} 0 ${Bt},${Ft} ${ft},${Zt}`,
5652
5652
  "Z"
5653
- ].join(" "), H = o - l, N = o + l, et = [
5653
+ ].join(" "), H = o - l, N = o + l, et2 = [
5654
5654
  `M${H},${s}`,
5655
5655
  `A${l},${a} 0 1,0 ${N},${s}`,
5656
5656
  `A${l},${a} 0 1,0 ${H},${s}`,
5657
5657
  "Z"
5658
5658
  ].join(" ");
5659
- return `${Xt} ${et}`;
5659
+ return `${Xt} ${et2}`;
5660
5660
  });
5661
5661
  var jh = /* @__PURE__ */ new Map();
5662
5662
  jh.set("can", (t, n) => {
@@ -7222,12 +7222,12 @@ function ju(t, n) {
7222
7222
  }
7223
7223
  let U = null, q = null, Q = null, G = null;
7224
7224
  if (m) {
7225
- const H = "http://www.w3.org/2000/svg", N = document.createElementNS(H, "svg"), et = l ? d : u, nt = l ? a : x;
7226
- N.setAttribute("viewBox", `0 0 ${et} ${nt}`), N.setAttribute("width", String(et)), N.setAttribute("height", String(nt)), N.style.position = "absolute", N.style.left = "0", N.style.top = "0", N.style.overflow = "visible";
7225
+ const H = "http://www.w3.org/2000/svg", N = document.createElementNS(H, "svg"), et2 = l ? d : u, nt = l ? a : x;
7226
+ N.setAttribute("viewBox", `0 0 ${et2} ${nt}`), N.setAttribute("width", String(et2)), N.setAttribute("height", String(nt)), N.style.position = "absolute", N.style.left = "0", N.style.top = "0", N.style.overflow = "visible";
7227
7227
  const at = M.child("blipFill"), bt = at.exists() ? ku(at, n) : null;
7228
7228
  if (bt) {
7229
7229
  const Mt = document.createElementNS(H, "defs");
7230
- pr(H, N, Mt, at, m, { w: et, h: nt }, bt);
7230
+ pr(H, N, Mt, at, m, { w: et2, h: nt }, bt);
7231
7231
  const tt = b && ((it = b[0]) == null ? void 0 : it.stroke) === false;
7232
7232
  if (!Z && !tt && !E && A > 0 && k !== "none" && k !== "transparent") {
7233
7233
  const ht = document.createElementNS(H, "path");
@@ -7238,7 +7238,7 @@ function ju(t, n) {
7238
7238
  e.appendChild(N);
7239
7239
  } else {
7240
7240
  const Mt = document.createElementNS(H, "defs"), tt = document.createElementNS(H, "path");
7241
- tt.setAttribute("d", m), U = H, q = Mt, Q = tt, G = { w: et, h: nt };
7241
+ tt.setAttribute("d", m), U = H, q = Mt, Q = tt, G = { w: et2, h: nt };
7242
7242
  const ht = (lt = t.presetGeometry) == null ? void 0 : lt.toLowerCase();
7243
7243
  if (ht === "curveduparrow" || ht === "curveddownarrow" ? (tt.setAttribute("fill-rule", "evenodd"), tt.setAttribute("stroke-linejoin", "round")) : ht === "funnel" && tt.setAttribute("fill-rule", "evenodd"), L) {
7244
7244
  const rt = M.child("pattFill"), $t = rt.exists() ? Iu(H, Mt, rt, n) : null;
@@ -7293,11 +7293,11 @@ function ju(t, n) {
7293
7293
  v.colorInterpolation ?? "linearRGB"
7294
7294
  ), j.setAttribute("gradientUnits", "userSpaceOnUse");
7295
7295
  const At = v.cx ?? 0.5, It = v.cy ?? 0.5;
7296
- j.setAttribute("cx", String(At * et)), j.setAttribute("cy", String(It * nt));
7296
+ j.setAttribute("cx", String(At * et2)), j.setAttribute("cy", String(It * nt));
7297
7297
  const ct = Math.max(At, 1 - At), xt = Math.max(It, 1 - It);
7298
- j.setAttribute("r", String(Math.hypot(ct * et, xt * nt)));
7298
+ j.setAttribute("r", String(Math.hypot(ct * et2, xt * nt)));
7299
7299
  for (const St of Dn(v, {
7300
- width: et,
7300
+ width: et2,
7301
7301
  height: nt
7302
7302
  })) {
7303
7303
  const dt = document.createElementNS(H, "stop");
@@ -7311,7 +7311,7 @@ function ju(t, n) {
7311
7311
  v.colorInterpolation ?? "linearRGB"
7312
7312
  ), j.setAttribute("gradientUnits", "userSpaceOnUse");
7313
7313
  const At = so(v.angle);
7314
- j.setAttribute("x1", String(parseFloat(At.x1) / 100 * et)), j.setAttribute("y1", String(parseFloat(At.y1) / 100 * nt)), j.setAttribute("x2", String(parseFloat(At.x2) / 100 * et)), j.setAttribute("y2", String(parseFloat(At.y2) / 100 * nt));
7314
+ j.setAttribute("x1", String(parseFloat(At.x1) / 100 * et2)), j.setAttribute("y1", String(parseFloat(At.y1) / 100 * nt)), j.setAttribute("x2", String(parseFloat(At.x2) / 100 * et2)), j.setAttribute("y2", String(parseFloat(At.y2) / 100 * nt));
7315
7315
  for (const It of v.stops) {
7316
7316
  const ct = document.createElementNS(H, "stop");
7317
7317
  ct.setAttribute("offset", `${It.position}%`), ct.setAttribute("stop-color", It.color), j.appendChild(ct);
@@ -7373,19 +7373,19 @@ function ju(t, n) {
7373
7373
  if ($t.setAttribute("id", rt), $t.setAttribute(
7374
7374
  "color-interpolation",
7375
7375
  E.colorInterpolation ?? "linearRGB"
7376
- ), $t.setAttribute("gradientUnits", "userSpaceOnUse"), l || et <= 1 || nt <= 1) {
7377
- const j = E.angle * Math.PI / 180, At = Math.cos(j), It = Math.sin(j), ct = et / 2, xt = nt / 2, St = Math.max(et, nt) / 2;
7376
+ ), $t.setAttribute("gradientUnits", "userSpaceOnUse"), l || et2 <= 1 || nt <= 1) {
7377
+ const j = E.angle * Math.PI / 180, At = Math.cos(j), It = Math.sin(j), ct = et2 / 2, xt = nt / 2, St = Math.max(et2, nt) / 2;
7378
7378
  $t.setAttribute("x1", String(ct - St * At)), $t.setAttribute("y1", String(xt - St * It)), $t.setAttribute("x2", String(ct + St * At)), $t.setAttribute("y2", String(xt + St * It));
7379
7379
  } else {
7380
7380
  const j = so(E.angle);
7381
- $t.setAttribute("x1", String(parseFloat(j.x1) / 100 * et)), $t.setAttribute("y1", String(parseFloat(j.y1) / 100 * nt)), $t.setAttribute("x2", String(parseFloat(j.x2) / 100 * et)), $t.setAttribute("y2", String(parseFloat(j.y2) / 100 * nt));
7381
+ $t.setAttribute("x1", String(parseFloat(j.x1) / 100 * et2)), $t.setAttribute("y1", String(parseFloat(j.y1) / 100 * nt)), $t.setAttribute("x2", String(parseFloat(j.x2) / 100 * et2)), $t.setAttribute("y2", String(parseFloat(j.y2) / 100 * nt));
7382
7382
  }
7383
7383
  for (const j of E.stops) {
7384
7384
  const At = document.createElementNS(H, "stop");
7385
7385
  At.setAttribute("offset", `${j.position}%`), At.setAttribute("stop-color", j.color), $t.appendChild(At);
7386
7386
  }
7387
7387
  Mt.appendChild($t);
7388
- const vt = l || et <= 1 || nt <= 1 ? Math.max(E.width, 1) : E.width;
7388
+ const vt = l || et2 <= 1 || nt <= 1 ? Math.max(E.width, 1) : E.width;
7389
7389
  tt.setAttribute("stroke", `url(#${rt})`), tt.setAttribute("stroke-width", String(vt)), ee && tt.setAttribute("stroke-linecap", ee), C && tt.setAttribute("stroke-linejoin", C);
7390
7390
  } else if (!Z && !ce && yt > 0 && k !== "transparent") {
7391
7391
  tt.setAttribute("stroke", k), tt.setAttribute("stroke-width", String(yt)), ee && tt.setAttribute("stroke-linecap", ee), C && tt.setAttribute("stroke-linejoin", C);
@@ -7429,7 +7429,7 @@ function ju(t, n) {
7429
7429
  Mt,
7430
7430
  at,
7431
7431
  m,
7432
- { w: et, h: nt },
7432
+ { w: et2, h: nt },
7433
7433
  $t,
7434
7434
  tt
7435
7435
  );
@@ -7447,7 +7447,7 @@ function ju(t, n) {
7447
7447
  v.colorInterpolation ?? "sRGB"
7448
7448
  );
7449
7449
  const dt = so(v.angle);
7450
- St.setAttribute("x1", String(parseFloat(dt.x1) / 100 * et)), St.setAttribute("y1", String(parseFloat(dt.y1) / 100 * nt)), St.setAttribute("x2", String(parseFloat(dt.x2) / 100 * et)), St.setAttribute("y2", String(parseFloat(dt.y2) / 100 * nt));
7450
+ St.setAttribute("x1", String(parseFloat(dt.x1) / 100 * et2)), St.setAttribute("y1", String(parseFloat(dt.y1) / 100 * nt)), St.setAttribute("x2", String(parseFloat(dt.x2) / 100 * et2)), St.setAttribute("y2", String(parseFloat(dt.y2) / 100 * nt));
7451
7451
  for (const Vt of v.stops) {
7452
7452
  const Ct = document.createElementNS(H, "stop");
7453
7453
  Ct.setAttribute("offset", `${Vt.position}%`);
@@ -7484,7 +7484,7 @@ function ju(t, n) {
7484
7484
  const Vt = `grad-fill-face-${++Le}`, Ct = document.createElementNS(H, "linearGradient");
7485
7485
  Ct.setAttribute("id", Vt), Ct.setAttribute("gradientUnits", "userSpaceOnUse"), Ct.setAttribute("color-interpolation", "sRGB");
7486
7486
  const Lt = so(v.angle);
7487
- Ct.setAttribute("x1", String(parseFloat(Lt.x1) / 100 * et)), Ct.setAttribute("y1", String(parseFloat(Lt.y1) / 100 * nt)), Ct.setAttribute("x2", String(parseFloat(Lt.x2) / 100 * et)), Ct.setAttribute("y2", String(parseFloat(Lt.y2) / 100 * nt));
7487
+ Ct.setAttribute("x1", String(parseFloat(Lt.x1) / 100 * et2)), Ct.setAttribute("y1", String(parseFloat(Lt.y1) / 100 * nt)), Ct.setAttribute("x2", String(parseFloat(Lt.x2) / 100 * et2)), Ct.setAttribute("y2", String(parseFloat(Lt.y2) / 100 * nt));
7488
7488
  for (const kt of v.stops) {
7489
7489
  const gt = document.createElementNS(H, "stop");
7490
7490
  gt.setAttribute("offset", `${kt.position}%`), gt.setAttribute("stop-color", fc(kt.color, 65e3)), Ct.appendChild(gt);
@@ -7505,18 +7505,18 @@ function ju(t, n) {
7505
7505
  const Ct = `shape-detail-band-mask-${++Le}`, Lt = document.createElementNS(H, "mask");
7506
7506
  Lt.setAttribute("id", Ct), Lt.setAttribute("maskUnits", "userSpaceOnUse"), Lt.setAttribute("maskContentUnits", "userSpaceOnUse");
7507
7507
  const kt = document.createElementNS(H, "rect");
7508
- kt.setAttribute("x", "0"), kt.setAttribute("y", "0"), kt.setAttribute("width", String(et)), kt.setAttribute("height", String(nt)), kt.setAttribute("fill", "black"), Lt.appendChild(kt);
7508
+ kt.setAttribute("x", "0"), kt.setAttribute("y", "0"), kt.setAttribute("width", String(et2)), kt.setAttribute("height", String(nt)), kt.setAttribute("fill", "black"), Lt.appendChild(kt);
7509
7509
  const gt = document.createElementNS(H, "path");
7510
7510
  gt.setAttribute("d", m), gt.setAttribute("fill", "white"), gt.setAttribute("stroke", "none"), Lt.appendChild(gt);
7511
7511
  const Qt = ct.maskToMainOutlineBandScale, Yt = document.createElementNS(H, "path");
7512
7512
  Yt.setAttribute("d", m), Yt.setAttribute("fill", "black"), Yt.setAttribute("stroke", "none");
7513
- const mt = et * (1 - Qt) / 2, _t = nt * (1 - Qt) / 2;
7513
+ const mt = et2 * (1 - Qt) / 2, _t = nt * (1 - Qt) / 2;
7514
7514
  Yt.setAttribute("transform", `translate(${mt} ${_t}) scale(${Qt})`), Lt.appendChild(Yt), Mt.appendChild(Lt), xt.setAttribute("mask", `url(#${Ct})`);
7515
7515
  } else if (ct.maskToMainOutline) {
7516
7516
  const Ct = `shape-detail-mask-${++Le}`, Lt = document.createElementNS(H, "mask");
7517
7517
  Lt.setAttribute("id", Ct), Lt.setAttribute("maskUnits", "userSpaceOnUse"), Lt.setAttribute("maskContentUnits", "userSpaceOnUse");
7518
7518
  const kt = document.createElementNS(H, "rect");
7519
- kt.setAttribute("x", "0"), kt.setAttribute("y", "0"), kt.setAttribute("width", String(et)), kt.setAttribute("height", String(nt)), kt.setAttribute("fill", "black"), Lt.appendChild(kt);
7519
+ kt.setAttribute("x", "0"), kt.setAttribute("y", "0"), kt.setAttribute("width", String(et2)), kt.setAttribute("height", String(nt)), kt.setAttribute("fill", "black"), Lt.appendChild(kt);
7520
7520
  const gt = document.createElementNS(H, "path");
7521
7521
  gt.setAttribute("d", m), gt.setAttribute("fill", "none"), gt.setAttribute("stroke", "white");
7522
7522
  const Qt = Math.max(
@@ -7559,7 +7559,7 @@ function ju(t, n) {
7559
7559
  else {
7560
7560
  const N = document.createElement("div");
7561
7561
  N.style.position = "absolute", t.textBoxBounds ? (N.style.left = `${t.textBoxBounds.x}px`, N.style.top = `${t.textBoxBounds.y}px`, N.style.width = `${t.textBoxBounds.w}px`, N.style.height = `${t.textBoxBounds.h}px`) : (N.style.left = "0", N.style.top = "0", N.style.width = "100%", N.style.height = "100%"), N.style.display = "flex", N.style.flexDirection = "column", N.style.boxSizing = "border-box";
7562
- const et = fo(t.textBody, "spAutoFit"), nt = et == null ? void 0 : et.exists(), at = fo(t.textBody, "normAutofit"), bt = at == null ? void 0 : at.exists(), Mt = fo(t.textBody, "noAutofit"), tt = Mt == null ? void 0 : Mt.exists(), ht = t.textBody.bodyProperties, ut = t.textBody.layoutBodyProperties, zt = (ht ? ht.attr("wrap") : void 0) ?? (ut ? ut.attr("wrap") : void 0), te = (ht ? ht.attr("horzOverflow") : void 0) ?? (ut ? ut.attr("horzOverflow") : void 0), Me = (ht ? ht.attr("vertOverflow") : void 0) ?? (ut ? ut.attr("vertOverflow") : void 0), yt = nt && !bt && te === "overflow", ee = nt && !bt && Me === "overflow", ce = !nt && !bt && !tt && is(t.textBody) && !pu(t.textBody) && (zt === "none" || zt === void 0 && hu(t.textBody)), rt = tt && xu(t.placeholder) && is(t.textBody);
7562
+ const et2 = fo(t.textBody, "spAutoFit"), nt = et2 == null ? void 0 : et2.exists(), at = fo(t.textBody, "normAutofit"), bt = at == null ? void 0 : at.exists(), Mt = fo(t.textBody, "noAutofit"), tt = Mt == null ? void 0 : Mt.exists(), ht = t.textBody.bodyProperties, ut = t.textBody.layoutBodyProperties, zt = (ht ? ht.attr("wrap") : void 0) ?? (ut ? ut.attr("wrap") : void 0), te = (ht ? ht.attr("horzOverflow") : void 0) ?? (ut ? ut.attr("horzOverflow") : void 0), Me = (ht ? ht.attr("vertOverflow") : void 0) ?? (ut ? ut.attr("vertOverflow") : void 0), yt = nt && !bt && te === "overflow", ee = nt && !bt && Me === "overflow", ce = !nt && !bt && !tt && is(t.textBody) && !pu(t.textBody) && (zt === "none" || zt === void 0 && hu(t.textBody)), rt = tt && xu(t.placeholder) && is(t.textBody);
7563
7563
  N.style.overflowX = "visible", N.style.overflowY = "visible";
7564
7564
  let $t = false;
7565
7565
  if (bt && at) {
@@ -7649,9 +7649,9 @@ function ju(t, n) {
7649
7649
  if (!T.exists()) {
7650
7650
  const N = t.source.child("style").child("effectRef").numAttr("idx") ?? 0;
7651
7651
  if (N > 0 && (((Y = n.theme.effectStyles) == null ? void 0 : Y.length) ?? 0) >= N) {
7652
- const et = n.theme.effectStyles[N - 1];
7653
- if (et.exists()) {
7654
- const nt = et.child("effectLst");
7652
+ const et2 = n.theme.effectStyles[N - 1];
7653
+ if (et2.exists()) {
7654
+ const nt = et2.child("effectLst");
7655
7655
  nt.exists() && (T = nt);
7656
7656
  }
7657
7657
  }
@@ -7710,9 +7710,9 @@ function ju(t, n) {
7710
7710
  }
7711
7711
  const N = T.child("glow");
7712
7712
  N.exists() && gu(e, N, n);
7713
- const et = T.child("softEdge");
7714
- if (et.exists() && !l && U && q && Q && G) {
7715
- const bt = X(et.numAttr("rad") ?? 0);
7713
+ const et2 = T.child("softEdge");
7714
+ if (et2.exists() && !l && U && q && Q && G) {
7715
+ const bt = X(et2.numAttr("rad") ?? 0);
7716
7716
  bt > 0 && Ru(U, q, Q, G, bt);
7717
7717
  }
7718
7718
  const nt = T.child("innerShdw");
@@ -7736,11 +7736,11 @@ function ju(t, n) {
7736
7736
  }
7737
7737
  }
7738
7738
  if (t.hlinkClick && n.onNavigate) {
7739
- const { action: H, rId: N } = t.hlinkClick, et = N ? n.slide.rels.get(N) : void 0, nt = Es(n, H, et);
7739
+ const { action: H, rId: N } = t.hlinkClick, et2 = N ? n.slide.rels.get(N) : void 0, nt = Es(n, H, et2);
7740
7740
  nt !== void 0 ? (e.style.cursor = "pointer", e.title = t.hlinkClick.tooltip || Ps(nt), e.addEventListener("click", (at) => {
7741
7741
  at.stopPropagation(), n.onNavigate({ slideIndex: nt });
7742
- })) : N && et && Ie(et.targetMode) && Ro(et.target) && (e.style.cursor = "pointer", e.title = t.hlinkClick.tooltip || et.target, e.addEventListener("click", (at) => {
7743
- at.stopPropagation(), n.onNavigate({ url: et.target });
7742
+ })) : N && et2 && Ie(et2.targetMode) && Ro(et2.target) && (e.style.cursor = "pointer", e.title = t.hlinkClick.tooltip || et2.target, e.addEventListener("click", (at) => {
7743
+ at.stopPropagation(), n.onNavigate({ url: et2.target });
7744
7744
  }));
7745
7745
  }
7746
7746
  return e;
@@ -11231,25 +11231,25 @@ function Ur(t, n, e, o, s, i) {
11231
11231
  ...T.lineNoFill ? { opacity: 0 } : {}
11232
11232
  }, Pt = T.formatCode, Rt = Ye(f[D] ?? t, o) ?? g, Wt = (N) => {
11233
11233
  if (!N || !yn(N)) return;
11234
- const et = N, nt = {
11234
+ const et2 = N, nt = {
11235
11235
  show: true,
11236
11236
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11237
- position: U$(et.position),
11238
- fontSize: et.fontSize ?? 9,
11239
- ...et.color ? { color: et.color } : {},
11240
- ...et.bold === true ? { fontWeight: "bold" } : {},
11241
- ...Xs(et),
11237
+ position: U$(et2.position),
11238
+ fontSize: et2.fontSize ?? 9,
11239
+ ...et2.color ? { color: et2.color } : {},
11240
+ ...et2.bold === true ? { fontWeight: "bold" } : {},
11241
+ ...Xs(et2),
11242
11242
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
11243
11243
  formatter: (at) => {
11244
11244
  const bt = at == null ? void 0 : at.value, Mt = bt && typeof bt == "object" && "value" in bt ? bt.value : bt, tt = [];
11245
- return et.showSerName && (at != null && at.seriesName) && tt.push(at.seriesName), et.showCatName && (at != null && at.name) && tt.push(at.name), et.showVal && typeof Mt == "number" && tt.push(me(Mt, x ? "0%" : Pt)), et.showPercent && typeof (at == null ? void 0 : at.percent) == "number" && tt.push(`${at.percent}%`), tt.join(" ");
11245
+ return et2.showSerName && (at != null && at.seriesName) && tt.push(at.seriesName), et2.showCatName && (at != null && at.name) && tt.push(at.name), et2.showVal && typeof Mt == "number" && tt.push(me(Mt, x ? "0%" : Pt)), et2.showPercent && typeof (at == null ? void 0 : at.percent) == "number" && tt.push(`${at.percent}%`), tt.join(" ");
11246
11246
  }
11247
11247
  };
11248
- return et.fontSize !== void 0 ? Hs(nt) : nt;
11249
- }, Nt = Wt(Rt), ft = Ys(f[D], t), Zt = Ws(ft, o), Dt = /* @__PURE__ */ new Map(), Ut = ((p == null ? void 0 : p[D]) ?? T.values).map((N, et) => {
11250
- const nt = Ll(T, et, N, $), at = Zt.get(et);
11248
+ return et2.fontSize !== void 0 ? Hs(nt) : nt;
11249
+ }, Nt = Wt(Rt), ft = Ys(f[D], t), Zt = Ws(ft, o), Dt = /* @__PURE__ */ new Map(), Ut = ((p == null ? void 0 : p[D]) ?? T.values).map((N, et2) => {
11250
+ const nt = Ll(T, et2, N, $), at = Zt.get(et2);
11251
11251
  if (!at) return nt;
11252
- at.manualLayout && Dt.set(et, at.manualLayout);
11252
+ at.manualLayout && Dt.set(et2, at.manualLayout);
11253
11253
  const bt = at.deleted ? { show: false } : Wt(xo(Rt, at));
11254
11254
  return bt ? { value: nt, label: bt } : nt;
11255
11255
  }), Y = !!(Nt != null && Nt.show && J === "none"), Bt = Y ? "circle" : J && J !== "none" ? J : void 0, Ft = Y ? 0 : T.markerSize ?? (T.markerSymbol === void 0 && m === true ? $l : void 0), Xt = Y ? true : s && J === void 0 ? false : W, H = Xt === true && Bt !== void 0 && Bt !== "none" && Ft !== 0;
@@ -13222,6 +13222,75 @@ var OfficeLoadError = class extends Error {
13222
13222
  }
13223
13223
  };
13224
13224
 
13225
+ // ../office-runtime/src/source-format.ts
13226
+ var wordMainPart = "document";
13227
+ var OOXML_FORMATS = Object.freeze([
13228
+ { family: "xlsx", format: "xlsx", contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml" },
13229
+ { family: "xlsx", format: "xlsb", contentType: "application/vnd.ms-excel.sheet.binary.macroenabled.main" },
13230
+ { family: "xlsx", format: "xlsm", contentType: "application/vnd.ms-excel.sheet.macroenabled.main+xml" },
13231
+ { family: "xlsx", format: "xltx", contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml" },
13232
+ { family: "xlsx", format: "xltm", contentType: "application/vnd.ms-excel.template.macroenabled.main+xml" },
13233
+ { family: "docx", format: "docx", contentType: `application/vnd.openxmlformats-officedocument.wordprocessingml.${wordMainPart}.main+xml` },
13234
+ { family: "docx", format: "docm", contentType: `application/vnd.ms-word.${wordMainPart}.macroenabled.main+xml` },
13235
+ { family: "docx", format: "dotx", contentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml" },
13236
+ { family: "docx", format: "dotm", contentType: "application/vnd.ms-word.template.macroenabledtemplate.main+xml" },
13237
+ { family: "pptx", format: "pptx", contentType: "application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml" },
13238
+ { family: "pptx", format: "pptm", contentType: "application/vnd.ms-powerpoint.presentation.macroenabled.main+xml" },
13239
+ { family: "pptx", format: "ppsx", contentType: "application/vnd.openxmlformats-officedocument.presentationml.slideshow.main+xml" },
13240
+ { family: "pptx", format: "ppsm", contentType: "application/vnd.ms-powerpoint.slideshow.macroenabled.main+xml" },
13241
+ { family: "pptx", format: "potx", contentType: "application/vnd.openxmlformats-officedocument.presentationml.template.main+xml" },
13242
+ { family: "pptx", format: "potm", contentType: "application/vnd.ms-powerpoint.template.macroenabled.main+xml" }
13243
+ ]);
13244
+ var FORMAT_BY_EXTENSION = new Map([
13245
+ ...OOXML_FORMATS.map((definition) => [definition.format, {
13246
+ family: definition.family,
13247
+ format: definition.format
13248
+ }]),
13249
+ ["xls", { family: "xlsx", format: "xls" }],
13250
+ ["csv", { family: "xlsx", format: "csv" }],
13251
+ ["pdf", { family: "pdf", format: "pdf" }]
13252
+ ]);
13253
+ var FORMAT_BY_MIME = new Map([
13254
+ ...OOXML_FORMATS.map((definition) => [definition.contentType, {
13255
+ family: definition.family,
13256
+ format: definition.format
13257
+ }]),
13258
+ ["application/vnd.ms-excel", { family: "xlsx", format: "xls" }],
13259
+ ["application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", { family: "xlsx", format: "xlsx" }],
13260
+ ["application/vnd.ms-excel.sheet.binary.macroenabled.12", { family: "xlsx", format: "xlsb" }],
13261
+ ["application/vnd.ms-excel.sheet.macroenabled.12", { family: "xlsx", format: "xlsm" }],
13262
+ ["application/vnd.openxmlformats-officedocument.spreadsheetml.template", { family: "xlsx", format: "xltx" }],
13263
+ ["application/vnd.ms-excel.template.macroenabled.12", { family: "xlsx", format: "xltm" }],
13264
+ ["text/csv", { family: "xlsx", format: "csv" }],
13265
+ ["application/csv", { family: "xlsx", format: "csv" }],
13266
+ ["text/comma-separated-values", { family: "xlsx", format: "csv" }],
13267
+ [`application/vnd.openxmlformats-officedocument.wordprocessingml.${wordMainPart}`, { family: "docx", format: "docx" }],
13268
+ [`application/vnd.ms-word.${wordMainPart}.macroenabled.12`, { family: "docx", format: "docm" }],
13269
+ ["application/vnd.openxmlformats-officedocument.wordprocessingml.template", { family: "docx", format: "dotx" }],
13270
+ ["application/vnd.ms-word.template.macroenabled.12", { family: "docx", format: "dotm" }],
13271
+ ["application/vnd.openxmlformats-officedocument.presentationml.presentation", { family: "pptx", format: "pptx" }],
13272
+ ["application/vnd.ms-powerpoint.presentation.macroenabled.12", { family: "pptx", format: "pptm" }],
13273
+ ["application/vnd.openxmlformats-officedocument.presentationml.slideshow", { family: "pptx", format: "ppsx" }],
13274
+ ["application/vnd.ms-powerpoint.slideshow.macroenabled.12", { family: "pptx", format: "ppsm" }],
13275
+ ["application/vnd.openxmlformats-officedocument.presentationml.template", { family: "pptx", format: "potx" }],
13276
+ ["application/vnd.ms-powerpoint.template.macroenabled.12", { family: "pptx", format: "potm" }],
13277
+ ["application/pdf", { family: "pdf", format: "pdf" }]
13278
+ ]);
13279
+ function detectOoxmlSourceFormat(contentTypes) {
13280
+ const normalized = contentTypes.toLowerCase();
13281
+ const definition = OOXML_FORMATS.find(({ contentType }) => normalized.includes(contentType));
13282
+ if (!definition) return void 0;
13283
+ return Object.freeze({
13284
+ family: definition.family,
13285
+ format: definition.format,
13286
+ confidence: "high",
13287
+ evidence: Object.freeze([`[Content_Types].xml:${definition.contentType}`])
13288
+ });
13289
+ }
13290
+ function isMacroEnabledOfficeFormat(format) {
13291
+ return format === "xlsb" || format === "xlsm" || format === "xltm" || format === "docm" || format === "dotm" || format === "pptm" || format === "ppsm" || format === "potm";
13292
+ }
13293
+
13225
13294
  // ../office-runtime/src/limits.ts
13226
13295
  function snapshotOfficeLimits(limits) {
13227
13296
  return Object.freeze({ ...limits ?? {} });
@@ -13250,6 +13319,1065 @@ function assertOfficeInputBytes(actual, limits) {
13250
13319
  });
13251
13320
  }
13252
13321
 
13322
+ // ../../node_modules/.pnpm/fflate@0.8.3/node_modules/fflate/esm/index.mjs
13323
+ import { createRequire } from "module";
13324
+ var require2 = createRequire("/");
13325
+ var _a2;
13326
+ var Worker2;
13327
+ var isMarkedAsUntransferable;
13328
+ try {
13329
+ _a2 = require2("worker_threads"), Worker2 = _a2.Worker, isMarkedAsUntransferable = _a2.isMarkedAsUntransferable;
13330
+ } catch (e) {
13331
+ }
13332
+ var u8 = Uint8Array;
13333
+ var u16 = Uint16Array;
13334
+ var i32 = Int32Array;
13335
+ var fleb = new u8([
13336
+ 0,
13337
+ 0,
13338
+ 0,
13339
+ 0,
13340
+ 0,
13341
+ 0,
13342
+ 0,
13343
+ 0,
13344
+ 1,
13345
+ 1,
13346
+ 1,
13347
+ 1,
13348
+ 2,
13349
+ 2,
13350
+ 2,
13351
+ 2,
13352
+ 3,
13353
+ 3,
13354
+ 3,
13355
+ 3,
13356
+ 4,
13357
+ 4,
13358
+ 4,
13359
+ 4,
13360
+ 5,
13361
+ 5,
13362
+ 5,
13363
+ 5,
13364
+ 0,
13365
+ /* unused */
13366
+ 0,
13367
+ 0,
13368
+ /* impossible */
13369
+ 0
13370
+ ]);
13371
+ var fdeb = new u8([
13372
+ 0,
13373
+ 0,
13374
+ 0,
13375
+ 0,
13376
+ 1,
13377
+ 1,
13378
+ 2,
13379
+ 2,
13380
+ 3,
13381
+ 3,
13382
+ 4,
13383
+ 4,
13384
+ 5,
13385
+ 5,
13386
+ 6,
13387
+ 6,
13388
+ 7,
13389
+ 7,
13390
+ 8,
13391
+ 8,
13392
+ 9,
13393
+ 9,
13394
+ 10,
13395
+ 10,
13396
+ 11,
13397
+ 11,
13398
+ 12,
13399
+ 12,
13400
+ 13,
13401
+ 13,
13402
+ /* unused */
13403
+ 0,
13404
+ 0
13405
+ ]);
13406
+ var clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);
13407
+ var freb = function(eb, start) {
13408
+ var b = new u16(31);
13409
+ for (var i = 0; i < 31; ++i) {
13410
+ b[i] = start += 1 << eb[i - 1];
13411
+ }
13412
+ var r = new i32(b[30]);
13413
+ for (var i = 1; i < 30; ++i) {
13414
+ for (var j = b[i]; j < b[i + 1]; ++j) {
13415
+ r[j] = j - b[i] << 5 | i;
13416
+ }
13417
+ }
13418
+ return { b, r };
13419
+ };
13420
+ var _a2 = freb(fleb, 2);
13421
+ var fl2 = _a2.b;
13422
+ var revfl = _a2.r;
13423
+ fl2[28] = 258, revfl[258] = 28;
13424
+ var _b = freb(fdeb, 0);
13425
+ var fd2 = _b.b;
13426
+ var revfd = _b.r;
13427
+ var rev = new u16(32768);
13428
+ for (i = 0; i < 32768; ++i) {
13429
+ x = (i & 43690) >> 1 | (i & 21845) << 1;
13430
+ x = (x & 52428) >> 2 | (x & 13107) << 2;
13431
+ x = (x & 61680) >> 4 | (x & 3855) << 4;
13432
+ rev[i] = ((x & 65280) >> 8 | (x & 255) << 8) >> 1;
13433
+ }
13434
+ var x;
13435
+ var i;
13436
+ var hMap = (function(cd2, mb, r) {
13437
+ var s = cd2.length;
13438
+ var i = 0;
13439
+ var l = new u16(mb);
13440
+ for (; i < s; ++i) {
13441
+ if (cd2[i])
13442
+ ++l[cd2[i] - 1];
13443
+ }
13444
+ var le = new u16(mb);
13445
+ for (i = 1; i < mb; ++i) {
13446
+ le[i] = le[i - 1] + l[i - 1] << 1;
13447
+ }
13448
+ var co2;
13449
+ if (r) {
13450
+ co2 = new u16(1 << mb);
13451
+ var rvb = 15 - mb;
13452
+ for (i = 0; i < s; ++i) {
13453
+ if (cd2[i]) {
13454
+ var sv = i << 4 | cd2[i];
13455
+ var r_1 = mb - cd2[i];
13456
+ var v = le[cd2[i] - 1]++ << r_1;
13457
+ for (var m = v | (1 << r_1) - 1; v <= m; ++v) {
13458
+ co2[rev[v] >> rvb] = sv;
13459
+ }
13460
+ }
13461
+ }
13462
+ } else {
13463
+ co2 = new u16(s);
13464
+ for (i = 0; i < s; ++i) {
13465
+ if (cd2[i]) {
13466
+ co2[i] = rev[le[cd2[i] - 1]++] >> 15 - cd2[i];
13467
+ }
13468
+ }
13469
+ }
13470
+ return co2;
13471
+ });
13472
+ var flt = new u8(288);
13473
+ for (i = 0; i < 144; ++i)
13474
+ flt[i] = 8;
13475
+ var i;
13476
+ for (i = 144; i < 256; ++i)
13477
+ flt[i] = 9;
13478
+ var i;
13479
+ for (i = 256; i < 280; ++i)
13480
+ flt[i] = 7;
13481
+ var i;
13482
+ for (i = 280; i < 288; ++i)
13483
+ flt[i] = 8;
13484
+ var i;
13485
+ var fdt = new u8(32);
13486
+ for (i = 0; i < 32; ++i)
13487
+ fdt[i] = 5;
13488
+ var i;
13489
+ var flrm = /* @__PURE__ */ hMap(flt, 9, 1);
13490
+ var fdrm = /* @__PURE__ */ hMap(fdt, 5, 1);
13491
+ var max = function(a) {
13492
+ var m = a[0];
13493
+ for (var i = 1; i < a.length; ++i) {
13494
+ if (a[i] > m)
13495
+ m = a[i];
13496
+ }
13497
+ return m;
13498
+ };
13499
+ var bits = function(d, p, m) {
13500
+ var o = p / 8 | 0;
13501
+ return (d[o] | d[o + 1] << 8) >> (p & 7) & m;
13502
+ };
13503
+ var bits16 = function(d, p) {
13504
+ var o = p / 8 | 0;
13505
+ return (d[o] | d[o + 1] << 8 | d[o + 2] << 16) >> (p & 7);
13506
+ };
13507
+ var shft = function(p) {
13508
+ return (p + 7) / 8 | 0;
13509
+ };
13510
+ var slc = function(v, s, e) {
13511
+ if (s == null || s < 0)
13512
+ s = 0;
13513
+ if (e == null || e > v.length)
13514
+ e = v.length;
13515
+ return new u8(v.subarray(s, e));
13516
+ };
13517
+ var ec2 = [
13518
+ "unexpected EOF",
13519
+ "invalid block type",
13520
+ "invalid length/literal",
13521
+ "invalid distance",
13522
+ "stream finished",
13523
+ "no stream handler",
13524
+ ,
13525
+ // determined by compression function
13526
+ "no callback",
13527
+ "invalid UTF-8 data",
13528
+ "extra field too long",
13529
+ "date not in range 1980-2099",
13530
+ "filename too long",
13531
+ "stream finishing",
13532
+ "invalid zip data"
13533
+ // determined by unknown compression method
13534
+ ];
13535
+ var err = function(ind, msg, nt) {
13536
+ var e = new Error(msg || ec2[ind]);
13537
+ e.code = ind;
13538
+ if (Error.captureStackTrace)
13539
+ Error.captureStackTrace(e, err);
13540
+ if (!nt)
13541
+ throw e;
13542
+ return e;
13543
+ };
13544
+ var inflt = function(dat, st2, buf, dict) {
13545
+ var sl2 = dat.length, dl2 = dict ? dict.length : 0;
13546
+ if (!sl2 || st2.f && !st2.l)
13547
+ return buf || new u8(0);
13548
+ var noBuf = !buf;
13549
+ var resize = noBuf || st2.i != 2;
13550
+ var noSt = st2.i;
13551
+ if (noBuf)
13552
+ buf = new u8(sl2 * 3);
13553
+ var cbuf = function(l2) {
13554
+ var bl2 = buf.length;
13555
+ if (l2 > bl2) {
13556
+ var nbuf = new u8(Math.max(bl2 * 2, l2));
13557
+ nbuf.set(buf);
13558
+ buf = nbuf;
13559
+ }
13560
+ };
13561
+ var final = st2.f || 0, pos = st2.p || 0, bt = st2.b || 0, lm = st2.l, dm = st2.d, lbt = st2.m, dbt = st2.n;
13562
+ var tbts = sl2 * 8;
13563
+ do {
13564
+ if (!lm) {
13565
+ final = bits(dat, pos, 1);
13566
+ var type = bits(dat, pos + 1, 3);
13567
+ pos += 3;
13568
+ if (!type) {
13569
+ var s = shft(pos) + 4, l = dat[s - 4] | dat[s - 3] << 8, t = s + l;
13570
+ if (t > sl2) {
13571
+ if (noSt)
13572
+ err(0);
13573
+ break;
13574
+ }
13575
+ if (resize)
13576
+ cbuf(bt + l);
13577
+ buf.set(dat.subarray(s, t), bt);
13578
+ st2.b = bt += l, st2.p = pos = t * 8, st2.f = final;
13579
+ continue;
13580
+ } else if (type == 1)
13581
+ lm = flrm, dm = fdrm, lbt = 9, dbt = 5;
13582
+ else if (type == 2) {
13583
+ var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;
13584
+ var tl2 = hLit + bits(dat, pos + 5, 31) + 1;
13585
+ pos += 14;
13586
+ var ldt = new u8(tl2);
13587
+ var clt = new u8(19);
13588
+ for (var i = 0; i < hcLen; ++i) {
13589
+ clt[clim[i]] = bits(dat, pos + i * 3, 7);
13590
+ }
13591
+ pos += hcLen * 3;
13592
+ var clb = max(clt), clbmsk = (1 << clb) - 1;
13593
+ var clm = hMap(clt, clb, 1);
13594
+ for (var i = 0; i < tl2; ) {
13595
+ var r = clm[bits(dat, pos, clbmsk)];
13596
+ pos += r & 15;
13597
+ var s = r >> 4;
13598
+ if (s < 16) {
13599
+ ldt[i++] = s;
13600
+ } else {
13601
+ var c = 0, n = 0;
13602
+ if (s == 16)
13603
+ n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];
13604
+ else if (s == 17)
13605
+ n = 3 + bits(dat, pos, 7), pos += 3;
13606
+ else if (s == 18)
13607
+ n = 11 + bits(dat, pos, 127), pos += 7;
13608
+ while (n--)
13609
+ ldt[i++] = c;
13610
+ }
13611
+ }
13612
+ var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);
13613
+ lbt = max(lt);
13614
+ dbt = max(dt);
13615
+ lm = hMap(lt, lbt, 1);
13616
+ dm = hMap(dt, dbt, 1);
13617
+ } else
13618
+ err(1);
13619
+ if (pos > tbts) {
13620
+ if (noSt)
13621
+ err(0);
13622
+ break;
13623
+ }
13624
+ }
13625
+ if (resize)
13626
+ cbuf(bt + 131072);
13627
+ var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;
13628
+ var lpos = pos;
13629
+ for (; ; lpos = pos) {
13630
+ var c = lm[bits16(dat, pos) & lms], sym = c >> 4;
13631
+ pos += c & 15;
13632
+ if (pos > tbts) {
13633
+ if (noSt)
13634
+ err(0);
13635
+ break;
13636
+ }
13637
+ if (!c)
13638
+ err(2);
13639
+ if (sym < 256)
13640
+ buf[bt++] = sym;
13641
+ else if (sym == 256) {
13642
+ lpos = pos, lm = null;
13643
+ break;
13644
+ } else {
13645
+ var add = sym - 254;
13646
+ if (sym > 264) {
13647
+ var i = sym - 257, b = fleb[i];
13648
+ add = bits(dat, pos, (1 << b) - 1) + fl2[i];
13649
+ pos += b;
13650
+ }
13651
+ var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;
13652
+ if (!d)
13653
+ err(3);
13654
+ pos += d & 15;
13655
+ var dt = fd2[dsym];
13656
+ if (dsym > 3) {
13657
+ var b = fdeb[dsym];
13658
+ dt += bits16(dat, pos) & (1 << b) - 1, pos += b;
13659
+ }
13660
+ if (pos > tbts) {
13661
+ if (noSt)
13662
+ err(0);
13663
+ break;
13664
+ }
13665
+ if (resize)
13666
+ cbuf(bt + 131072);
13667
+ var end = bt + add;
13668
+ if (bt < dt) {
13669
+ var shift = dl2 - dt, dend = Math.min(dt, end);
13670
+ if (shift + bt < 0)
13671
+ err(3);
13672
+ for (; bt < dend; ++bt)
13673
+ buf[bt] = dict[shift + bt];
13674
+ }
13675
+ for (; bt < end; ++bt)
13676
+ buf[bt] = buf[bt - dt];
13677
+ }
13678
+ }
13679
+ st2.l = lm, st2.p = lpos, st2.b = bt, st2.f = final;
13680
+ if (lm)
13681
+ final = 1, st2.m = lbt, st2.d = dm, st2.n = dbt;
13682
+ } while (!final);
13683
+ return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);
13684
+ };
13685
+ var et = /* @__PURE__ */ new u8(0);
13686
+ var b2 = function(d, b) {
13687
+ return d[b] | d[b + 1] << 8;
13688
+ };
13689
+ var b4 = function(d, b) {
13690
+ return (d[b] | d[b + 1] << 8 | d[b + 2] << 16 | d[b + 3] << 24) >>> 0;
13691
+ };
13692
+ var b8 = function(d, b) {
13693
+ return b4(d, b) + b4(d, b + 4) * 4294967296;
13694
+ };
13695
+ var Inflate = /* @__PURE__ */ (function() {
13696
+ function Inflate2(opts, cb) {
13697
+ if (typeof opts == "function")
13698
+ cb = opts, opts = {};
13699
+ this.ondata = cb;
13700
+ var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);
13701
+ this.s = { i: 0, b: dict ? dict.length : 0 };
13702
+ this.o = new u8(32768);
13703
+ this.p = new u8(0);
13704
+ if (dict)
13705
+ this.o.set(dict);
13706
+ }
13707
+ Inflate2.prototype.e = function(c) {
13708
+ if (!this.ondata)
13709
+ err(5);
13710
+ if (this.d)
13711
+ err(4);
13712
+ if (!this.p.length)
13713
+ this.p = c;
13714
+ else if (c.length) {
13715
+ var n = new u8(this.p.length + c.length);
13716
+ n.set(this.p), n.set(c, this.p.length), this.p = n;
13717
+ }
13718
+ };
13719
+ Inflate2.prototype.c = function(final) {
13720
+ this.s.i = +(this.d = final || false);
13721
+ var bts = this.s.b;
13722
+ var dt = inflt(this.p, this.s, this.o);
13723
+ this.ondata(slc(dt, bts, this.s.b), this.d);
13724
+ this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;
13725
+ this.p = slc(this.p, this.s.p / 8 | 0), this.s.p &= 7;
13726
+ };
13727
+ Inflate2.prototype.push = function(chunk, final) {
13728
+ this.e(chunk), this.c(final);
13729
+ };
13730
+ return Inflate2;
13731
+ })();
13732
+ var td2 = typeof TextDecoder != "undefined" && /* @__PURE__ */ new TextDecoder();
13733
+ var tds = 0;
13734
+ try {
13735
+ td2.decode(et, { stream: true });
13736
+ tds = 1;
13737
+ } catch (e) {
13738
+ }
13739
+ var dutf8 = function(d) {
13740
+ for (var r = "", i = 0; ; ) {
13741
+ var c = d[i++];
13742
+ var eb = (c > 127) + (c > 223) + (c > 239);
13743
+ if (i + eb > d.length)
13744
+ return { s: r, r: slc(d, i - 1) };
13745
+ if (!eb)
13746
+ r += String.fromCharCode(c);
13747
+ else if (eb == 3) {
13748
+ c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | d[i++] & 63) - 65536, r += String.fromCharCode(55296 | c >> 10, 56320 | c & 1023);
13749
+ } else if (eb & 1)
13750
+ r += String.fromCharCode((c & 31) << 6 | d[i++] & 63);
13751
+ else
13752
+ r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | d[i++] & 63);
13753
+ }
13754
+ };
13755
+ function strFromU8(dat, latin1) {
13756
+ if (latin1) {
13757
+ var r = "";
13758
+ for (var i = 0; i < dat.length; i += 16384)
13759
+ r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));
13760
+ return r;
13761
+ } else if (td2) {
13762
+ return td2.decode(dat);
13763
+ } else {
13764
+ var _a3 = dutf8(dat), s = _a3.s, r = _a3.r;
13765
+ if (r.length)
13766
+ err(8);
13767
+ return s;
13768
+ }
13769
+ }
13770
+ var z64hs = function(d, b, l, z2, sc2, su2, off) {
13771
+ var nsc = sc2 == 4294967295, nsu = su2 == 4294967295, noff = off == 4294967295, e = b + l;
13772
+ var nf2 = nsc + nsu + noff;
13773
+ if (z2 && nf2) {
13774
+ for (; b + 4 < e; b += 4 + b2(d, b + 2)) {
13775
+ if (b2(d, b) == 1) {
13776
+ return [
13777
+ nsc ? b8(d, b + 4 + 8 * nsu) : sc2,
13778
+ nsu ? b8(d, b + 4) : su2,
13779
+ noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,
13780
+ 1
13781
+ ];
13782
+ }
13783
+ }
13784
+ if (z2 < 2)
13785
+ err(13);
13786
+ }
13787
+ return [sc2, su2, off, 0];
13788
+ };
13789
+ var UnzipPassThrough = /* @__PURE__ */ (function() {
13790
+ function UnzipPassThrough2() {
13791
+ }
13792
+ UnzipPassThrough2.prototype.push = function(chunk, final) {
13793
+ this.ondata(null, chunk, final);
13794
+ };
13795
+ UnzipPassThrough2.compression = 0;
13796
+ return UnzipPassThrough2;
13797
+ })();
13798
+ var UnzipInflate = /* @__PURE__ */ (function() {
13799
+ function UnzipInflate2() {
13800
+ var _this = this;
13801
+ this.i = new Inflate(function(dat, final) {
13802
+ _this.ondata(null, dat, final);
13803
+ });
13804
+ }
13805
+ UnzipInflate2.prototype.push = function(chunk, final) {
13806
+ try {
13807
+ this.i.push(chunk, final);
13808
+ } catch (e) {
13809
+ this.ondata(e, null, final);
13810
+ }
13811
+ };
13812
+ UnzipInflate2.compression = 8;
13813
+ return UnzipInflate2;
13814
+ })();
13815
+ var Unzip = /* @__PURE__ */ (function() {
13816
+ function Unzip2(cb) {
13817
+ this.onfile = cb;
13818
+ this.k = [];
13819
+ this.o = {
13820
+ 0: UnzipPassThrough
13821
+ };
13822
+ this.p = et;
13823
+ }
13824
+ Unzip2.prototype.push = function(chunk, final) {
13825
+ var _this = this;
13826
+ if (!this.onfile)
13827
+ err(5);
13828
+ if (!this.p)
13829
+ err(4);
13830
+ if (this.c > 0) {
13831
+ var len = Math.min(this.c, chunk.length);
13832
+ var toAdd = chunk.subarray(0, len);
13833
+ this.c -= len;
13834
+ if (this.d)
13835
+ this.d.push(toAdd, !this.c);
13836
+ else
13837
+ this.k[0].push(toAdd);
13838
+ chunk = chunk.subarray(len);
13839
+ if (chunk.length)
13840
+ return this.push(chunk, final);
13841
+ } else {
13842
+ var f = 0, i = 0, is2 = void 0, buf = void 0;
13843
+ if (!this.p.length)
13844
+ buf = chunk;
13845
+ else if (!chunk.length)
13846
+ buf = this.p;
13847
+ else {
13848
+ buf = new u8(this.p.length + chunk.length);
13849
+ buf.set(this.p), buf.set(chunk, this.p.length);
13850
+ }
13851
+ var l = buf.length, oc2 = this.c, add = oc2 && this.d;
13852
+ var _loop_2 = function() {
13853
+ var sig = b4(buf, i);
13854
+ if (sig == 67324752) {
13855
+ f = 1, is2 = i;
13856
+ this_1.d = null;
13857
+ this_1.c = 0;
13858
+ var bf2 = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf2 & 2048, dd2 = bf2 & 8, fnl = b2(buf, i + 26), es2 = b2(buf, i + 28);
13859
+ if (l > i + 30 + fnl + es2) {
13860
+ var chks_3 = [];
13861
+ this_1.k.unshift(chks_3);
13862
+ f = 2;
13863
+ var lsc = b4(buf, i + 18), lsu = b4(buf, i + 22);
13864
+ var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);
13865
+ var _a3 = z64hs(buf, i, es2, 2, lsc, lsu, 0), sc_1 = _a3[0], su_1 = _a3[1], z64 = _a3[3];
13866
+ if (dd2)
13867
+ sc_1 = -1 - z64;
13868
+ i += es2;
13869
+ this_1.c = sc_1;
13870
+ var d_1;
13871
+ var file_1 = {
13872
+ name: fn_1,
13873
+ compression: cmp_1,
13874
+ start: function() {
13875
+ if (!file_1.ondata)
13876
+ err(5);
13877
+ if (!sc_1)
13878
+ file_1.ondata(null, et, true);
13879
+ else {
13880
+ var ctr = _this.o[cmp_1];
13881
+ if (!ctr)
13882
+ file_1.ondata(err(14, "unknown compression type " + cmp_1, 1), null, false);
13883
+ d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);
13884
+ d_1.ondata = function(err2, dat3, final2) {
13885
+ file_1.ondata(err2, dat3, final2);
13886
+ };
13887
+ for (var _i2 = 0, chks_4 = chks_3; _i2 < chks_4.length; _i2++) {
13888
+ var dat2 = chks_4[_i2];
13889
+ d_1.push(dat2, false);
13890
+ }
13891
+ if (_this.k[0] == chks_3 && _this.c)
13892
+ _this.d = d_1;
13893
+ else
13894
+ d_1.push(et, true);
13895
+ }
13896
+ },
13897
+ terminate: function() {
13898
+ if (d_1 && d_1.terminate)
13899
+ d_1.terminate();
13900
+ }
13901
+ };
13902
+ if (sc_1 >= 0)
13903
+ file_1.size = sc_1, file_1.originalSize = su_1;
13904
+ this_1.onfile(file_1);
13905
+ }
13906
+ return "break";
13907
+ } else if (oc2) {
13908
+ if (sig == 134695760) {
13909
+ is2 = i += 12 + (oc2 == -2 && 8), f = 3, this_1.c = 0;
13910
+ return "break";
13911
+ } else if (sig == 33639248) {
13912
+ is2 = i -= 4, f = 3, this_1.c = 0;
13913
+ return "break";
13914
+ }
13915
+ }
13916
+ };
13917
+ var this_1 = this;
13918
+ for (; i < l - 4; ++i) {
13919
+ var state_1 = _loop_2();
13920
+ if (state_1 === "break")
13921
+ break;
13922
+ }
13923
+ this.p = et;
13924
+ if (oc2 < 0) {
13925
+ var dat = f ? buf.subarray(0, is2 - 12 - (oc2 == -2 && 8) - (b4(buf, is2 - 16) == 134695760 && 4)) : buf.subarray(0, i);
13926
+ if (add)
13927
+ add.push(dat, !!f);
13928
+ else
13929
+ this.k[+(f == 2)].push(dat);
13930
+ }
13931
+ if (f & 2)
13932
+ return this.push(buf.subarray(i), final);
13933
+ this.p = buf.subarray(i);
13934
+ }
13935
+ if (final) {
13936
+ if (this.c)
13937
+ err(13);
13938
+ this.p = null;
13939
+ }
13940
+ };
13941
+ Unzip2.prototype.register = function(decoder) {
13942
+ this.o[decoder.compression] = decoder;
13943
+ };
13944
+ return Unzip2;
13945
+ })();
13946
+
13947
+ // ../office-runtime/src/archive-budget.ts
13948
+ var END_OF_CENTRAL_DIRECTORY = 101010256;
13949
+ var CENTRAL_DIRECTORY_ENTRY = 33639248;
13950
+ var MAX_ZIP_COMMENT_BYTES = 65535;
13951
+ function throwIfAborted(signal) {
13952
+ if (!signal?.aborted) return;
13953
+ throw new OfficeLoadError({
13954
+ code: "ABORTED",
13955
+ message: "\u6587\u6863\u89E3\u6790\u5DF2\u53D6\u6D88\u3002",
13956
+ phase: "archive"
13957
+ });
13958
+ }
13959
+ function assertLimit(actual, allowed, limit, phase) {
13960
+ if (allowed === void 0 || actual <= allowed) return;
13961
+ throw new OfficeLoadError({
13962
+ code: "LIMIT_EXCEEDED",
13963
+ message: `${String(limit)} \u7684\u5B9E\u9645\u503C ${actual} \u8D85\u8FC7\u5141\u8BB8\u503C ${allowed}\u3002`,
13964
+ phase,
13965
+ limit,
13966
+ actual,
13967
+ allowed
13968
+ });
13969
+ }
13970
+ function invalidArchive(message, cause) {
13971
+ return new OfficeLoadError({
13972
+ code: "INVALID_SOURCE",
13973
+ message,
13974
+ phase: "archive",
13975
+ cause
13976
+ });
13977
+ }
13978
+ function invalidXml(message, cause) {
13979
+ return new OfficeLoadError({
13980
+ code: "INVALID_SOURCE",
13981
+ message,
13982
+ phase: "xml",
13983
+ cause
13984
+ });
13985
+ }
13986
+ function findEndOfCentralDirectory(bytes) {
13987
+ const minimum = Math.max(0, bytes.byteLength - 22 - MAX_ZIP_COMMENT_BYTES);
13988
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
13989
+ for (let offset = bytes.byteLength - 22; offset >= minimum; offset -= 1) {
13990
+ if (view.getUint32(offset, true) === END_OF_CENTRAL_DIRECTORY) return offset;
13991
+ }
13992
+ throw invalidArchive("\u6587\u4EF6\u4E0D\u662F\u5B8C\u6574\u7684 OOXML \u538B\u7F29\u5305\uFF1A\u627E\u4E0D\u5230\u76EE\u5F55\u7ED3\u675F\u8BB0\u5F55\u3002");
13993
+ }
13994
+ function decodeEntryName(bytes) {
13995
+ try {
13996
+ return new TextDecoder("utf-8", { fatal: true }).decode(bytes).normalize("NFC");
13997
+ } catch (error) {
13998
+ throw invalidArchive("\u538B\u7F29\u5305\u4E2D\u7684\u6587\u4EF6\u540D\u4E0D\u662F\u6709\u6548\u7684 UTF-8\u3002", error);
13999
+ }
14000
+ }
14001
+ function validateEntryName(name, limits) {
14002
+ assertLimit(new TextEncoder().encode(name).byteLength, limits.maxArchivePathLength, "maxArchivePathLength", "archive");
14003
+ if (!name || name.includes("\0") || name.includes("\\") || name.startsWith("/") || /^[A-Za-z]:/.test(name)) {
14004
+ throw invalidArchive(`\u538B\u7F29\u5305\u5305\u542B\u4E0D\u5B89\u5168\u7684\u6587\u4EF6\u8DEF\u5F84\uFF1A${name || "<empty>"}\u3002`);
14005
+ }
14006
+ const segments = name.split("/");
14007
+ if (segments.some((segment, index) => segment === ".." || segment === "." || segment === "" && index < segments.length - 1)) {
14008
+ throw invalidArchive(`\u538B\u7F29\u5305\u5305\u542B\u4E0D\u5B89\u5168\u7684\u6587\u4EF6\u8DEF\u5F84\uFF1A${name}\u3002`);
14009
+ }
14010
+ return name;
14011
+ }
14012
+ function compressionRatio(uncompressedBytes, compressedBytes) {
14013
+ if (uncompressedBytes === 0) return 0;
14014
+ return uncompressedBytes / Math.max(1, compressedBytes);
14015
+ }
14016
+ function inspectOfficeArchive(input, limits, signal) {
14017
+ const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
14018
+ throwIfAborted(signal);
14019
+ if (bytes.byteLength < 22) throw invalidArchive("\u6587\u4EF6\u4E0D\u662F\u5B8C\u6574\u7684 OOXML \u538B\u7F29\u5305\u3002");
14020
+ const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
14021
+ const eocd = findEndOfCentralDirectory(bytes);
14022
+ const disk = view.getUint16(eocd + 4, true);
14023
+ const directoryDisk = view.getUint16(eocd + 6, true);
14024
+ const entriesOnDisk = view.getUint16(eocd + 8, true);
14025
+ const entryCount = view.getUint16(eocd + 10, true);
14026
+ const directoryBytes = view.getUint32(eocd + 12, true);
14027
+ const directoryOffset = view.getUint32(eocd + 16, true);
14028
+ const commentBytes = view.getUint16(eocd + 20, true);
14029
+ if (disk !== 0 || directoryDisk !== 0 || entriesOnDisk !== entryCount) {
14030
+ throw invalidArchive("\u4E0D\u652F\u6301\u5206\u5377\u538B\u7F29\u5305\u3002");
14031
+ }
14032
+ if (entryCount === 65535 || directoryBytes === 4294967295 || directoryOffset === 4294967295) {
14033
+ throw invalidArchive("\u4E0D\u652F\u6301 ZIP64 \u538B\u7F29\u5305\u3002");
14034
+ }
14035
+ if (eocd + 22 + commentBytes !== bytes.byteLength || directoryOffset + directoryBytes !== eocd) {
14036
+ throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u5DF2\u635F\u574F\u6216\u88AB\u622A\u65AD\u3002");
14037
+ }
14038
+ assertLimit(entryCount, limits.maxArchiveEntries, "maxArchiveEntries", "archive");
14039
+ const seenNames = /* @__PURE__ */ new Set();
14040
+ const entries = [];
14041
+ let offset = directoryOffset;
14042
+ let totalCompressed = 0;
14043
+ let totalUncompressed = 0;
14044
+ let largestRatio = 0;
14045
+ for (let index = 0; index < entryCount; index += 1) {
14046
+ throwIfAborted(signal);
14047
+ if (offset + 46 > eocd || view.getUint32(offset, true) !== CENTRAL_DIRECTORY_ENTRY) {
14048
+ throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u9879\u5DF2\u635F\u574F\u6216\u6570\u91CF\u4E0D\u4E00\u81F4\u3002");
14049
+ }
14050
+ const flags = view.getUint16(offset + 8, true);
14051
+ const compression = view.getUint16(offset + 10, true);
14052
+ const compressedBytes = view.getUint32(offset + 20, true);
14053
+ const uncompressedBytes = view.getUint32(offset + 24, true);
14054
+ const nameBytes = view.getUint16(offset + 28, true);
14055
+ const extraBytes = view.getUint16(offset + 30, true);
14056
+ const entryCommentBytes = view.getUint16(offset + 32, true);
14057
+ const nextOffset = offset + 46 + nameBytes + extraBytes + entryCommentBytes;
14058
+ if (nextOffset > eocd) throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u9879\u5DF2\u88AB\u622A\u65AD\u3002");
14059
+ if ((flags & 1) !== 0) throw invalidArchive("\u4E0D\u652F\u6301\u52A0\u5BC6\u7684 OOXML \u538B\u7F29\u5305\u3002");
14060
+ if (compression !== 0 && compression !== 8) throw invalidArchive(`\u4E0D\u652F\u6301\u538B\u7F29\u7B97\u6CD5 ${compression}\u3002`);
14061
+ if (compressedBytes === 4294967295 || uncompressedBytes === 4294967295) {
14062
+ throw invalidArchive("\u4E0D\u652F\u6301 ZIP64 \u76EE\u5F55\u9879\u3002");
14063
+ }
14064
+ const name = validateEntryName(
14065
+ decodeEntryName(bytes.subarray(offset + 46, offset + 46 + nameBytes)),
14066
+ limits
14067
+ );
14068
+ if (seenNames.has(name)) throw invalidArchive(`\u538B\u7F29\u5305\u5305\u542B\u91CD\u590D\u6587\u4EF6\u8DEF\u5F84\uFF1A${name}\u3002`);
14069
+ seenNames.add(name);
14070
+ assertLimit(uncompressedBytes, limits.maxSingleEntryBytes, "maxSingleEntryBytes", "archive");
14071
+ const ratio = compressionRatio(uncompressedBytes, compressedBytes);
14072
+ assertLimit(ratio, limits.maxCompressionRatio, "maxCompressionRatio", "archive");
14073
+ totalCompressed += compressedBytes;
14074
+ totalUncompressed += uncompressedBytes;
14075
+ assertLimit(totalUncompressed, limits.maxUncompressedBytes, "maxUncompressedBytes", "archive");
14076
+ largestRatio = Math.max(largestRatio, ratio);
14077
+ entries.push({ name, compressedBytes, uncompressedBytes, compression });
14078
+ offset = nextOffset;
14079
+ }
14080
+ if (offset !== directoryOffset + directoryBytes) {
14081
+ throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u957F\u5EA6\u4E0E\u5B9E\u9645\u5185\u5BB9\u4E0D\u4E00\u81F4\u3002");
14082
+ }
14083
+ return Object.freeze({
14084
+ entryCount,
14085
+ compressedBytes: totalCompressed,
14086
+ uncompressedBytes: totalUncompressed,
14087
+ maxCompressionRatio: largestRatio,
14088
+ entries: Object.freeze(entries)
14089
+ });
14090
+ }
14091
+ function decodeXml(bytes) {
14092
+ let encoding = "utf-8";
14093
+ if (bytes[0] === 255 && bytes[1] === 254) encoding = "utf-16le";
14094
+ if (bytes[0] === 254 && bytes[1] === 255) encoding = "utf-16be";
14095
+ try {
14096
+ const text = new TextDecoder(encoding, { fatal: true }).decode(bytes);
14097
+ const declared = /^\uFEFF?<\?xml[^>]*\bencoding=["']([^"']+)["']/i.exec(text)?.[1]?.toLowerCase();
14098
+ if (declared && !["utf-8", "utf8", "utf-16", "utf-16le", "utf-16be"].includes(declared)) {
14099
+ throw invalidXml(`\u4E0D\u652F\u6301 XML \u7F16\u7801 ${declared}\u3002`);
14100
+ }
14101
+ return text;
14102
+ } catch (error) {
14103
+ if (error instanceof OfficeLoadError) throw error;
14104
+ throw invalidXml("XML \u5185\u5BB9\u4F7F\u7528\u4E86\u65E0\u6548\u7684\u5B57\u7B26\u7F16\u7801\u3002", error);
14105
+ }
14106
+ }
14107
+ function findTagEnd(xml, start) {
14108
+ let quote = "";
14109
+ for (let index = start + 1; index < xml.length; index += 1) {
14110
+ const char = xml[index] ?? "";
14111
+ if (quote) {
14112
+ if (char === quote) quote = "";
14113
+ } else if (char === '"' || char === "'") {
14114
+ quote = char;
14115
+ } else if (char === ">") {
14116
+ return index;
14117
+ }
14118
+ }
14119
+ return -1;
14120
+ }
14121
+ function columnNumber(label) {
14122
+ let value = 0;
14123
+ for (const char of label.toUpperCase()) value = value * 26 + char.charCodeAt(0) - 64;
14124
+ return value;
14125
+ }
14126
+ function xmlLocalName(qualifiedName) {
14127
+ const separator = qualifiedName.lastIndexOf(":");
14128
+ return separator >= 0 ? qualifiedName.slice(separator + 1) : qualifiedName;
14129
+ }
14130
+ function numericXmlAttribute(tag, localName) {
14131
+ const escapedName = localName.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
14132
+ const match = new RegExp(
14133
+ `(?:^|\\s)(?:[^\\s=/>]+:)?${escapedName}\\s*=\\s*(["'])(\\d+)\\1`
14134
+ ).exec(tag);
14135
+ if (!match?.[2]) return void 0;
14136
+ const value = Number(match[2]);
14137
+ return Number.isSafeInteger(value) ? value : void 0;
14138
+ }
14139
+ function cellReferenceXmlAttribute(tag) {
14140
+ const match = /(?:^|\s)(?:[^\s=/>]+:)?r\s*=\s*(["'])([A-Za-z]+)(\d+)\1/.exec(tag);
14141
+ if (!match?.[2] || !match[3]) return void 0;
14142
+ const row = Number(match[3]);
14143
+ if (!Number.isSafeInteger(row)) return void 0;
14144
+ return { row, column: columnNumber(match[2]) };
14145
+ }
14146
+ function validateOfficeXmlEntry(name, bytes, limits) {
14147
+ assertLimit(bytes.byteLength, limits.maxSingleXmlBytes, "maxSingleXmlBytes", "xml");
14148
+ if (/^xl\/worksheets\/[^/]+\.xml$/i.test(name)) {
14149
+ assertLimit(bytes.byteLength, limits.maxWorksheetXmlBytes, "maxWorksheetXmlBytes", "xml");
14150
+ }
14151
+ if (/^xl\/sharedStrings\.xml$/i.test(name)) {
14152
+ assertLimit(bytes.byteLength, limits.maxSharedStringsBytes, "maxSharedStringsBytes", "xml");
14153
+ }
14154
+ const xml = decodeXml(bytes);
14155
+ if (/<!DOCTYPE\b/i.test(xml) || /<!ENTITY\b/i.test(xml)) {
14156
+ throw invalidXml(`XML \u6587\u4EF6 ${name} \u5305\u542B\u88AB\u7981\u6B62\u7684\u6587\u6863\u7C7B\u578B\u6216\u5B9E\u4F53\u58F0\u660E\u3002`);
14157
+ }
14158
+ const stack = [];
14159
+ let roots = 0;
14160
+ let cursor = 0;
14161
+ let relationships = 0;
14162
+ let worksheets = 0;
14163
+ let sharedStrings = 0;
14164
+ let formulas = 0;
14165
+ let rows = 0;
14166
+ let maxRow = 0;
14167
+ let maxColumn = 0;
14168
+ const workbookEntry = /^xl\/workbook\.xml$/i.test(name);
14169
+ const sharedStringsEntry = /^xl\/sharedStrings\.xml$/i.test(name);
14170
+ const formulaEntry = /^xl\/(?:worksheets|chartsheets)\/[^/]+\.xml$/i.test(name);
14171
+ const worksheetEntry = /^xl\/worksheets\/[^/]+\.xml$/i.test(name);
14172
+ while (cursor < xml.length) {
14173
+ const start = xml.indexOf("<", cursor);
14174
+ if (start < 0) {
14175
+ assertLimit(
14176
+ new TextEncoder().encode(xml.slice(cursor)).byteLength,
14177
+ limits.maxTextNodeBytes,
14178
+ "maxTextNodeBytes",
14179
+ "xml"
14180
+ );
14181
+ break;
14182
+ }
14183
+ assertLimit(
14184
+ new TextEncoder().encode(xml.slice(cursor, start)).byteLength,
14185
+ limits.maxTextNodeBytes,
14186
+ "maxTextNodeBytes",
14187
+ "xml"
14188
+ );
14189
+ if (xml.startsWith("<!--", start)) {
14190
+ const end2 = xml.indexOf("-->", start + 4);
14191
+ if (end2 < 0) throw invalidXml(`XML \u6587\u4EF6 ${name} \u7684\u6CE8\u91CA\u672A\u7ED3\u675F\u3002`);
14192
+ cursor = end2 + 3;
14193
+ continue;
14194
+ }
14195
+ if (xml.startsWith("<![CDATA[", start)) {
14196
+ const end2 = xml.indexOf("]]>", start + 9);
14197
+ if (end2 < 0) throw invalidXml(`XML \u6587\u4EF6 ${name} \u7684 CDATA \u672A\u7ED3\u675F\u3002`);
14198
+ assertLimit(
14199
+ new TextEncoder().encode(xml.slice(start + 9, end2)).byteLength,
14200
+ limits.maxTextNodeBytes,
14201
+ "maxTextNodeBytes",
14202
+ "xml"
14203
+ );
14204
+ cursor = end2 + 3;
14205
+ continue;
14206
+ }
14207
+ const end = findTagEnd(xml, start);
14208
+ if (end < 0) throw invalidXml(`XML \u6587\u4EF6 ${name} \u7684\u6807\u7B7E\u672A\u7ED3\u675F\u3002`);
14209
+ const tag = xml.slice(start, end + 1);
14210
+ assertLimit(
14211
+ new TextEncoder().encode(tag).byteLength,
14212
+ limits.maxXmlAttributeBytes,
14213
+ "maxXmlAttributeBytes",
14214
+ "xml"
14215
+ );
14216
+ cursor = end + 1;
14217
+ if (tag.startsWith("<?") || tag.startsWith("<!")) continue;
14218
+ const closing = /^<\s*\/\s*([^\s>]+)/.exec(tag)?.[1];
14219
+ if (closing) {
14220
+ if (stack.pop() !== closing) throw invalidXml(`XML \u6587\u4EF6 ${name} \u7684\u6807\u7B7E\u5D4C\u5957\u4E0D\u6B63\u786E\u3002`);
14221
+ continue;
14222
+ }
14223
+ const opening = /^<\s*([^\s/>]+)/.exec(tag)?.[1];
14224
+ if (!opening) throw invalidXml(`XML \u6587\u4EF6 ${name} \u5305\u542B\u65E0\u6548\u6807\u7B7E\u3002`);
14225
+ const localName = xmlLocalName(opening);
14226
+ if (localName === "Relationship") relationships += 1;
14227
+ if (workbookEntry && localName === "sheet") worksheets += 1;
14228
+ if (sharedStringsEntry && localName === "si") sharedStrings += 1;
14229
+ if (formulaEntry && localName === "f") formulas += 1;
14230
+ if (worksheetEntry && localName === "row") {
14231
+ rows += 1;
14232
+ maxRow = Math.max(maxRow, numericXmlAttribute(tag, "r") ?? rows);
14233
+ }
14234
+ if (worksheetEntry && localName === "c") {
14235
+ const reference = cellReferenceXmlAttribute(tag);
14236
+ if (reference) {
14237
+ maxColumn = Math.max(maxColumn, reference.column);
14238
+ maxRow = Math.max(maxRow, reference.row);
14239
+ }
14240
+ }
14241
+ if (stack.length === 0) roots += 1;
14242
+ if (!/\/\s*>$/.test(tag)) {
14243
+ stack.push(opening);
14244
+ assertLimit(stack.length, limits.maxXmlDepth, "maxXmlDepth", "xml");
14245
+ }
14246
+ }
14247
+ if (stack.length > 0 || roots !== 1) throw invalidXml(`XML \u6587\u4EF6 ${name} \u4E0D\u662F\u5B8C\u6574\u7684\u5355\u6839\u6587\u6863\u3002`);
14248
+ if (worksheetEntry) {
14249
+ assertLimit(Math.max(rows, maxRow), limits.maxWorksheetRows, "maxWorksheetRows", "xml");
14250
+ assertLimit(maxColumn, limits.maxWorksheetColumns, "maxWorksheetColumns", "xml");
14251
+ }
14252
+ return { relationships, rows, maxRow, maxColumn, worksheets, sharedStrings, formulas };
14253
+ }
14254
+ function concatChunks(chunks, length) {
14255
+ if (chunks.length === 1 && chunks[0]?.byteLength === length) return chunks[0];
14256
+ const result = new Uint8Array(length);
14257
+ let offset = 0;
14258
+ for (const chunk of chunks) {
14259
+ result.set(chunk, offset);
14260
+ offset += chunk.byteLength;
14261
+ }
14262
+ return result;
14263
+ }
14264
+ function isXmlEntry(name) {
14265
+ return /(?:\.xml|\.rels)$/i.test(name) || name === "[Content_Types].xml";
14266
+ }
14267
+ function validateOfficeArchive(input, limits, options) {
14268
+ const bytes = input instanceof Uint8Array ? input : new Uint8Array(input);
14269
+ assertLimit(bytes.byteLength, limits.maxInputBytes, "maxInputBytes", "input");
14270
+ const central = inspectOfficeArchive(bytes, limits, options.signal);
14271
+ let entryCount = 0;
14272
+ let totalUncompressed = 0;
14273
+ let totalXmlBytes = 0;
14274
+ let relationships = 0;
14275
+ let worksheets = 0;
14276
+ let sharedStrings = 0;
14277
+ let formulas = 0;
14278
+ let completedEntries = 0;
14279
+ let contentTypes = "";
14280
+ let failure;
14281
+ const seenNames = /* @__PURE__ */ new Set();
14282
+ const unzip = new Unzip((file) => {
14283
+ if (failure) return;
14284
+ try {
14285
+ throwIfAborted(options.signal);
14286
+ const name = validateEntryName(file.name.normalize("NFC"), limits);
14287
+ if (seenNames.has(name)) throw invalidArchive(`\u538B\u7F29\u5305\u5305\u542B\u91CD\u590D\u6587\u4EF6\u8DEF\u5F84\uFF1A${name}\u3002`);
14288
+ seenNames.add(name);
14289
+ entryCount += 1;
14290
+ assertLimit(entryCount, limits.maxArchiveEntries, "maxArchiveEntries", "archive");
14291
+ if (file.originalSize !== void 0) {
14292
+ assertLimit(file.originalSize, limits.maxSingleEntryBytes, "maxSingleEntryBytes", "archive");
14293
+ }
14294
+ if (file.size !== void 0 && file.originalSize !== void 0) {
14295
+ assertLimit(compressionRatio(file.originalSize, file.size), limits.maxCompressionRatio, "maxCompressionRatio", "archive");
14296
+ }
14297
+ const xmlEntry = isXmlEntry(name);
14298
+ const xmlChunks = [];
14299
+ let entryBytes = 0;
14300
+ file.ondata = (error, chunk, final) => {
14301
+ if (failure) return;
14302
+ try {
14303
+ if (error) throw error;
14304
+ throwIfAborted(options.signal);
14305
+ entryBytes += chunk.byteLength;
14306
+ totalUncompressed += chunk.byteLength;
14307
+ assertLimit(entryBytes, limits.maxSingleEntryBytes, "maxSingleEntryBytes", "archive");
14308
+ assertLimit(totalUncompressed, limits.maxUncompressedBytes, "maxUncompressedBytes", "archive");
14309
+ if (xmlEntry) {
14310
+ totalXmlBytes += chunk.byteLength;
14311
+ assertLimit(totalXmlBytes, limits.maxXmlBytes, "maxXmlBytes", "xml");
14312
+ xmlChunks.push(chunk);
14313
+ }
14314
+ if (final) {
14315
+ if (file.originalSize !== void 0 && entryBytes !== file.originalSize) {
14316
+ throw invalidArchive(`\u538B\u7F29\u5305\u6587\u4EF6 ${name} \u7684\u5B9E\u9645\u5927\u5C0F\u4E0E\u76EE\u5F55\u8BB0\u5F55\u4E0D\u4E00\u81F4\u3002`);
14317
+ }
14318
+ if (xmlEntry) {
14319
+ const xmlBytes = concatChunks(xmlChunks, entryBytes);
14320
+ const summary = validateOfficeXmlEntry(name, xmlBytes, limits);
14321
+ relationships += summary.relationships;
14322
+ assertLimit(relationships, limits.maxRelationships, "maxRelationships", "xml");
14323
+ worksheets += summary.worksheets;
14324
+ sharedStrings += summary.sharedStrings;
14325
+ formulas += summary.formulas;
14326
+ assertLimit(worksheets, limits.maxWorksheets, "maxWorksheets", "xml");
14327
+ assertLimit(sharedStrings, limits.maxSharedStrings, "maxSharedStrings", "xml");
14328
+ assertLimit(formulas, limits.maxFormulaCount, "maxFormulaCount", "xml");
14329
+ if (name === "[Content_Types].xml") contentTypes = decodeXml(xmlBytes);
14330
+ }
14331
+ completedEntries += 1;
14332
+ }
14333
+ } catch (error2) {
14334
+ failure = error2;
14335
+ try {
14336
+ file.terminate();
14337
+ } catch {
14338
+ }
14339
+ }
14340
+ };
14341
+ file.start();
14342
+ } catch (error) {
14343
+ failure = error;
14344
+ try {
14345
+ file.terminate();
14346
+ } catch {
14347
+ }
14348
+ }
14349
+ });
14350
+ unzip.register(UnzipInflate);
14351
+ try {
14352
+ unzip.push(bytes, true);
14353
+ } catch (error) {
14354
+ if (!failure) failure = invalidArchive("\u538B\u7F29\u5305\u89E3\u538B\u5931\u8D25\u3002", error);
14355
+ }
14356
+ if (failure) throw failure;
14357
+ if (entryCount !== central.entryCount || completedEntries !== central.entryCount) {
14358
+ throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u4E0E\u5B9E\u9645\u6587\u4EF6\u6570\u91CF\u4E0D\u4E00\u81F4\u3002");
14359
+ }
14360
+ for (const entry of central.entries) {
14361
+ if (!seenNames.has(entry.name)) {
14362
+ throw invalidArchive("\u538B\u7F29\u5305\u76EE\u5F55\u4E0E\u5B9E\u9645\u6587\u4EF6\u8DEF\u5F84\u4E0D\u4E00\u81F4\u3002");
14363
+ }
14364
+ }
14365
+ const detected = contentTypes ? detectOoxmlSourceFormat(contentTypes) : void 0;
14366
+ if (!detected || detected.family !== options.format) {
14367
+ throw invalidArchive(`\u6587\u4EF6\u4E0D\u662F\u6709\u6548\u7684 ${options.format.toUpperCase()} \u6587\u6863\u3002`);
14368
+ }
14369
+ return Object.freeze({
14370
+ ...central,
14371
+ sourceFormat: detected.format,
14372
+ uncompressedBytes: totalUncompressed,
14373
+ xmlBytes: totalXmlBytes,
14374
+ relationships,
14375
+ worksheets,
14376
+ sharedStrings,
14377
+ formulas
14378
+ });
14379
+ }
14380
+
13253
14381
  // ../office-runtime/src/url-policy.ts
13254
14382
  function fail(message, url, cause) {
13255
14383
  throw new OfficeLoadError({
@@ -13314,122 +14442,6 @@ function snapshotOfficeUrlPolicy(policy) {
13314
14442
  });
13315
14443
  }
13316
14444
 
13317
- // ../office-runtime/src/load-context.ts
13318
- function createOfficeLoadContext(options) {
13319
- const source = Object.freeze({ ...options.source });
13320
- return Object.freeze({
13321
- runtimeId: options.runtimeId,
13322
- taskId: options.taskId,
13323
- source,
13324
- sourceKind: source.kind,
13325
- resources: Object.freeze({ ...options.resources ?? {} }),
13326
- limits: snapshotOfficeLimits(options.limits),
13327
- urlPolicy: snapshotOfficeUrlPolicy(options.urlPolicy),
13328
- signal: options.signal
13329
- });
13330
- }
13331
-
13332
- // ../office-runtime/src/load-task.ts
13333
- function createOfficeTaskSequence(runtimeId) {
13334
- if (!runtimeId.trim()) {
13335
- throw new OfficeLoadError({ code: "INVALID_ARGUMENT", message: "runtimeId \u4E0D\u80FD\u4E3A\u7A7A\u3002" });
13336
- }
13337
- let sequence = 0;
13338
- let disposed = false;
13339
- return Object.freeze({
13340
- runtimeId,
13341
- next() {
13342
- if (disposed) {
13343
- throw new OfficeLoadError({ code: "RUNTIME_DISPOSED", message: "\u8FD0\u884C\u5B9E\u4F8B\u5DF2\u7ECF\u9500\u6BC1\u3002", runtimeId });
13344
- }
13345
- sequence += 1;
13346
- return `${runtimeId}:${sequence}`;
13347
- },
13348
- dispose() {
13349
- disposed = true;
13350
- }
13351
- });
13352
- }
13353
- function createLatestTaskCoordinator(sequence) {
13354
- let current;
13355
- let disposed = false;
13356
- const cancel = () => {
13357
- const active = current;
13358
- current = void 0;
13359
- active?.controller.abort();
13360
- active?.cleanup();
13361
- };
13362
- return {
13363
- start(source, options = {}) {
13364
- if (disposed) {
13365
- throw new OfficeLoadError({
13366
- code: "RUNTIME_DISPOSED",
13367
- message: "\u52A0\u8F7D\u5668\u5DF2\u7ECF\u9500\u6BC1\u3002",
13368
- runtimeId: sequence.runtimeId
13369
- });
13370
- }
13371
- cancel();
13372
- const taskId = sequence.next();
13373
- const controller = new AbortController();
13374
- const abortFromExternal = () => controller.abort(options.signal?.reason);
13375
- let externalListenerAttached = false;
13376
- if (options.signal?.aborted) controller.abort(options.signal.reason);
13377
- else if (options.signal) {
13378
- options.signal.addEventListener("abort", abortFromExternal, { once: true });
13379
- externalListenerAttached = true;
13380
- }
13381
- let cleaned = false;
13382
- const active = {
13383
- controller,
13384
- cleanup: () => {
13385
- if (cleaned) return;
13386
- cleaned = true;
13387
- if (externalListenerAttached) {
13388
- externalListenerAttached = false;
13389
- options.signal?.removeEventListener("abort", abortFromExternal);
13390
- }
13391
- }
13392
- };
13393
- current = active;
13394
- const context = createOfficeLoadContext({
13395
- runtimeId: sequence.runtimeId,
13396
- taskId,
13397
- source,
13398
- resources: options.resources,
13399
- limits: options.limits,
13400
- urlPolicy: options.urlPolicy,
13401
- signal: controller.signal
13402
- });
13403
- const isCurrent = () => current === active && !disposed && !controller.signal.aborted;
13404
- return Object.freeze({
13405
- context,
13406
- signal: controller.signal,
13407
- isCurrent,
13408
- assertCurrent() {
13409
- if (isCurrent()) return;
13410
- throw new OfficeLoadError({
13411
- code: "STALE_RESULT",
13412
- message: "\u52A0\u8F7D\u7ED3\u679C\u5DF2\u7ECF\u8FC7\u671F\u3002",
13413
- runtimeId: sequence.runtimeId,
13414
- taskId,
13415
- sourceKind: source.kind
13416
- });
13417
- },
13418
- finish() {
13419
- active.cleanup();
13420
- if (current === active) current = void 0;
13421
- }
13422
- });
13423
- },
13424
- cancel,
13425
- dispose() {
13426
- if (disposed) return;
13427
- disposed = true;
13428
- cancel();
13429
- }
13430
- };
13431
- }
13432
-
13433
14445
  // ../office-runtime/src/source.ts
13434
14446
  function safeFileNameFromUrl(url) {
13435
14447
  const segment = url.pathname.split("/").filter(Boolean).pop();
@@ -13552,6 +14564,122 @@ async function loadOfficeSource(source, options = {}) {
13552
14564
  };
13553
14565
  }
13554
14566
 
14567
+ // ../office-runtime/src/load-context.ts
14568
+ function createOfficeLoadContext(options) {
14569
+ const source = Object.freeze({ ...options.source });
14570
+ return Object.freeze({
14571
+ runtimeId: options.runtimeId,
14572
+ taskId: options.taskId,
14573
+ source,
14574
+ sourceKind: source.kind,
14575
+ resources: Object.freeze({ ...options.resources ?? {} }),
14576
+ limits: snapshotOfficeLimits(options.limits),
14577
+ urlPolicy: snapshotOfficeUrlPolicy(options.urlPolicy),
14578
+ signal: options.signal
14579
+ });
14580
+ }
14581
+
14582
+ // ../office-runtime/src/load-task.ts
14583
+ function createOfficeTaskSequence(runtimeId) {
14584
+ if (!runtimeId.trim()) {
14585
+ throw new OfficeLoadError({ code: "INVALID_ARGUMENT", message: "runtimeId \u4E0D\u80FD\u4E3A\u7A7A\u3002" });
14586
+ }
14587
+ let sequence = 0;
14588
+ let disposed = false;
14589
+ return Object.freeze({
14590
+ runtimeId,
14591
+ next() {
14592
+ if (disposed) {
14593
+ throw new OfficeLoadError({ code: "RUNTIME_DISPOSED", message: "\u8FD0\u884C\u5B9E\u4F8B\u5DF2\u7ECF\u9500\u6BC1\u3002", runtimeId });
14594
+ }
14595
+ sequence += 1;
14596
+ return `${runtimeId}:${sequence}`;
14597
+ },
14598
+ dispose() {
14599
+ disposed = true;
14600
+ }
14601
+ });
14602
+ }
14603
+ function createLatestTaskCoordinator(sequence) {
14604
+ let current;
14605
+ let disposed = false;
14606
+ const cancel = () => {
14607
+ const active = current;
14608
+ current = void 0;
14609
+ active?.controller.abort();
14610
+ active?.cleanup();
14611
+ };
14612
+ return {
14613
+ start(source, options = {}) {
14614
+ if (disposed) {
14615
+ throw new OfficeLoadError({
14616
+ code: "RUNTIME_DISPOSED",
14617
+ message: "\u52A0\u8F7D\u5668\u5DF2\u7ECF\u9500\u6BC1\u3002",
14618
+ runtimeId: sequence.runtimeId
14619
+ });
14620
+ }
14621
+ cancel();
14622
+ const taskId = sequence.next();
14623
+ const controller = new AbortController();
14624
+ const abortFromExternal = () => controller.abort(options.signal?.reason);
14625
+ let externalListenerAttached = false;
14626
+ if (options.signal?.aborted) controller.abort(options.signal.reason);
14627
+ else if (options.signal) {
14628
+ options.signal.addEventListener("abort", abortFromExternal, { once: true });
14629
+ externalListenerAttached = true;
14630
+ }
14631
+ let cleaned = false;
14632
+ const active = {
14633
+ controller,
14634
+ cleanup: () => {
14635
+ if (cleaned) return;
14636
+ cleaned = true;
14637
+ if (externalListenerAttached) {
14638
+ externalListenerAttached = false;
14639
+ options.signal?.removeEventListener("abort", abortFromExternal);
14640
+ }
14641
+ }
14642
+ };
14643
+ current = active;
14644
+ const context = createOfficeLoadContext({
14645
+ runtimeId: sequence.runtimeId,
14646
+ taskId,
14647
+ source,
14648
+ resources: options.resources,
14649
+ limits: options.limits,
14650
+ urlPolicy: options.urlPolicy,
14651
+ signal: controller.signal
14652
+ });
14653
+ const isCurrent = () => current === active && !disposed && !controller.signal.aborted;
14654
+ return Object.freeze({
14655
+ context,
14656
+ signal: controller.signal,
14657
+ isCurrent,
14658
+ assertCurrent() {
14659
+ if (isCurrent()) return;
14660
+ throw new OfficeLoadError({
14661
+ code: "STALE_RESULT",
14662
+ message: "\u52A0\u8F7D\u7ED3\u679C\u5DF2\u7ECF\u8FC7\u671F\u3002",
14663
+ runtimeId: sequence.runtimeId,
14664
+ taskId,
14665
+ sourceKind: source.kind
14666
+ });
14667
+ },
14668
+ finish() {
14669
+ active.cleanup();
14670
+ if (current === active) current = void 0;
14671
+ }
14672
+ });
14673
+ },
14674
+ cancel,
14675
+ dispose() {
14676
+ if (disposed) return;
14677
+ disposed = true;
14678
+ cancel();
14679
+ }
14680
+ };
14681
+ }
14682
+
13555
14683
  // src/browser/renderer-markers.ts
13556
14684
  function objectSource(partPath, slidePath) {
13557
14685
  if (/\/slideMasters\//u.test(partPath)) return "master";
@@ -15450,6 +16578,7 @@ function createPptxDocumentSession(container, options = {}) {
15450
16578
  const viewer = new js(container, {
15451
16579
  fitMode: options.fitMode ?? "contain",
15452
16580
  zoomPercent: options.zoomPercent ?? 100,
16581
+ scrollContainer: options.scrollContainer,
15453
16582
  zipLimits: toZipLimits(baseLimits),
15454
16583
  lazyMedia: options.lazyMedia ?? true,
15455
16584
  lazySlides: options.lazySlides ?? true,
@@ -15539,6 +16668,11 @@ function createPptxDocumentSession(container, options = {}) {
15539
16668
  limits: task.context.limits
15540
16669
  });
15541
16670
  task.assertCurrent();
16671
+ const archiveValidation = validateOfficeArchive(resolved.buffer, task.context.limits, {
16672
+ format: "pptx",
16673
+ signal: task.signal
16674
+ });
16675
+ task.assertCurrent();
15542
16676
  const lazyMedia = openOptions.lazyMedia ?? options.lazyMedia ?? true;
15543
16677
  const files = lazyMedia ? await rc(resolved.buffer, toZipLimits(limits)) : await ic(resolved.buffer, toZipLimits(limits));
15544
16678
  task.assertCurrent();
@@ -15582,10 +16716,16 @@ function createPptxDocumentSession(container, options = {}) {
15582
16716
  number: index + 1,
15583
16717
  hidden: playbackDocument.slides[index]?.hidden ?? slide.hidden === true
15584
16718
  }))),
15585
- warnings: Object.freeze([Object.freeze({
15586
- code: "NOTES_UNSUPPORTED",
15587
- message: "\u5F53\u524D\u9759\u6001\u5E95\u5EA7\u5C1A\u672A\u89E3\u6790\u6F14\u8BB2\u8005\u5907\u6CE8\u3002"
15588
- })])
16719
+ warnings: Object.freeze([
16720
+ Object.freeze({
16721
+ code: "NOTES_UNSUPPORTED",
16722
+ message: "\u5F53\u524D\u9759\u6001\u5E95\u5EA7\u5C1A\u672A\u89E3\u6790\u6F14\u8BB2\u8005\u5907\u6CE8\u3002"
16723
+ }),
16724
+ ...isMacroEnabledOfficeFormat(archiveValidation.sourceFormat) ? [Object.freeze({
16725
+ code: "UNSUPPORTED_CONTENT",
16726
+ message: "\u6587\u4EF6\u4E2D\u7684 VBA \u5B8F\u5DF2\u5FFD\u7565\u4E14\u4E0D\u4F1A\u6267\u884C\u3002"
16727
+ })] : []
16728
+ ])
15589
16729
  });
15590
16730
  return currentDocument;
15591
16731
  } catch (error) {