@poe-platform/safe-bash 0.1.766 → 0.1.768

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.
@@ -28,8 +28,8 @@ import {
28
28
  thresholdImage,
29
29
  tintImage,
30
30
  trimImage
31
- } from "../safe-bash/command-chunks/chunk-IOH3F3ZO.js";
32
- import "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
31
+ } from "../safe-bash/command-chunks/chunk-A5S6M37L.js";
32
+ import "../safe-bash/command-chunks/chunk-2JQONXIY.js";
33
33
  import {
34
34
  init_buffer
35
35
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -2,11 +2,11 @@ import {
2
2
  createPandocCommand,
3
3
  createPandocCommands,
4
4
  pandocCommands
5
- } from "../safe-bash/command-chunks/chunk-DKWMTHU3.js";
5
+ } from "../safe-bash/command-chunks/chunk-G55GHZV2.js";
6
6
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
7
7
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
8
- import "../safe-bash/command-chunks/chunk-IOH3F3ZO.js";
9
- import "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
8
+ import "../safe-bash/command-chunks/chunk-A5S6M37L.js";
9
+ import "../safe-bash/command-chunks/chunk-2JQONXIY.js";
10
10
  import "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
11
11
  import "../safe-bash/command-chunks/chunk-YGYOVXTO.js";
12
12
  import "../safe-bash/command-chunks/chunk-I5GLTNVH.js";
@@ -21,11 +21,11 @@ import {
21
21
  readDocument,
22
22
  resolveConversionArgs,
23
23
  writeDocument
24
- } from "../safe-bash/command-chunks/chunk-DKWMTHU3.js";
24
+ } from "../safe-bash/command-chunks/chunk-G55GHZV2.js";
25
25
  import "../safe-bash/command-chunks/chunk-MKQVQMXO.js";
26
26
  import "../safe-bash/command-chunks/chunk-RDV7UCYZ.js";
27
- import "../safe-bash/command-chunks/chunk-IOH3F3ZO.js";
28
- import "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
27
+ import "../safe-bash/command-chunks/chunk-A5S6M37L.js";
28
+ import "../safe-bash/command-chunks/chunk-2JQONXIY.js";
29
29
  import {
30
30
  createLuaFilterCapability
31
31
  } from "../safe-bash/command-chunks/chunk-Y2KHC6TZ.js";
@@ -36243,8 +36243,9 @@ function evaluateContentStreamToDisplayList(params) {
36243
36243
  const st = curState();
36244
36244
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
36245
36245
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
36246
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36247
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
36246
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36247
+ const isolated = isolation?.kind === "boolean" && isolation.value;
36248
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
36248
36249
  const formStreamBytes = params.cosDoc.decodeStream(form);
36249
36250
  const formNodes = parseContentStream(formStreamBytes);
36250
36251
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -36262,8 +36263,8 @@ function evaluateContentStreamToDisplayList(params) {
36262
36263
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
36263
36264
  nextCtm = multiplyMatrices(formMat, nextCtm);
36264
36265
  }
36265
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
36266
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
36266
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
36267
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
36267
36268
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
36268
36269
  if (bboxArr && bboxArr.items.length >= 4) {
36269
36270
  const bn = (idx, fb = 0) => {
@@ -36297,7 +36298,7 @@ function evaluateContentStreamToDisplayList(params) {
36297
36298
  const parentOperations = capturedOperations;
36298
36299
  const children = [];
36299
36300
  const nextState = { ...st, ctm: nextCtm };
36300
- if (isolate) {
36301
+ if (compositeGroup) {
36301
36302
  capturedOperations = children;
36302
36303
  nextState.fillAlpha = nextState.strokeAlpha = 1;
36303
36304
  nextState.blendMode = "Normal";
@@ -36315,7 +36316,7 @@ function evaluateContentStreamToDisplayList(params) {
36315
36316
  stateStack.pop();
36316
36317
  capturedOperations = parentOperations;
36317
36318
  }
36318
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36319
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36319
36320
  };
36320
36321
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
36321
36322
  for (const node of nodes) {
@@ -40447,6 +40448,9 @@ function renderSoftMask(mask, displayList, scale) {
40447
40448
  }
40448
40449
  return bitmap;
40449
40450
  }
40451
+ function hasBlendModes(operations) {
40452
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40453
+ }
40450
40454
  function renderDisplayListToBitmap(displayList, options = {}) {
40451
40455
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40452
40456
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40455,11 +40459,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40455
40459
  const width = Math.max(1, Math.round(displayList.width * scale));
40456
40460
  const height = Math.max(1, Math.round(displayList.height * scale));
40457
40461
  const rgba = new Uint8Array(width * height * 4);
40462
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40463
+ const transparent = options.transparent || deferBackground;
40458
40464
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40459
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40460
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40461
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40462
- const bgA = options.transparent ? 0 : 255;
40465
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40466
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40467
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40468
+ const bgA = transparent ? 0 : 255;
40463
40469
  for (let i = 0; i < width * height; i++) {
40464
40470
  rgba[i * 4] = bgR;
40465
40471
  rgba[i * 4 + 1] = bgG;
@@ -40636,6 +40642,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40636
40642
  }
40637
40643
  }
40638
40644
  }
40645
+ if (deferBackground) {
40646
+ for (let i = 0; i < rgba.length; i += 4) {
40647
+ const alpha = rgba[i + 3] / 255;
40648
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
40649
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
40650
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
40651
+ rgba[i + 3] = 255;
40652
+ }
40653
+ }
40639
40654
  let result = { width, height, data: rgba };
40640
40655
  if (Math.abs(scaleX - scaleY) > 1e-6) {
40641
40656
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -36437,8 +36437,9 @@ function evaluateContentStreamToDisplayList(params) {
36437
36437
  const st = curState();
36438
36438
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
36439
36439
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
36440
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36441
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
36440
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36441
+ const isolated = isolation?.kind === "boolean" && isolation.value;
36442
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
36442
36443
  const formStreamBytes = params.cosDoc.decodeStream(form);
36443
36444
  const formNodes = parseContentStream(formStreamBytes);
36444
36445
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -36456,8 +36457,8 @@ function evaluateContentStreamToDisplayList(params) {
36456
36457
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
36457
36458
  nextCtm = multiplyMatrices(formMat, nextCtm);
36458
36459
  }
36459
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
36460
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
36460
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
36461
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
36461
36462
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
36462
36463
  if (bboxArr && bboxArr.items.length >= 4) {
36463
36464
  const bn = (idx, fb = 0) => {
@@ -36491,7 +36492,7 @@ function evaluateContentStreamToDisplayList(params) {
36491
36492
  const parentOperations = capturedOperations;
36492
36493
  const children = [];
36493
36494
  const nextState = { ...st, ctm: nextCtm };
36494
- if (isolate) {
36495
+ if (compositeGroup) {
36495
36496
  capturedOperations = children;
36496
36497
  nextState.fillAlpha = nextState.strokeAlpha = 1;
36497
36498
  nextState.blendMode = "Normal";
@@ -36509,7 +36510,7 @@ function evaluateContentStreamToDisplayList(params) {
36509
36510
  stateStack.pop();
36510
36511
  capturedOperations = parentOperations;
36511
36512
  }
36512
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36513
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36513
36514
  };
36514
36515
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
36515
36516
  for (const node of nodes) {
@@ -40883,6 +40884,9 @@ function renderSoftMask(mask, displayList, scale) {
40883
40884
  }
40884
40885
  return bitmap;
40885
40886
  }
40887
+ function hasBlendModes(operations) {
40888
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40889
+ }
40886
40890
  function renderDisplayListToBitmap(displayList, options = {}) {
40887
40891
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40888
40892
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40891,11 +40895,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40891
40895
  const width = Math.max(1, Math.round(displayList.width * scale));
40892
40896
  const height = Math.max(1, Math.round(displayList.height * scale));
40893
40897
  const rgba = new Uint8Array(width * height * 4);
40898
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40899
+ const transparent = options.transparent || deferBackground;
40894
40900
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40895
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40896
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40897
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40898
- const bgA = options.transparent ? 0 : 255;
40901
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40902
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40903
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40904
+ const bgA = transparent ? 0 : 255;
40899
40905
  for (let i = 0; i < width * height; i++) {
40900
40906
  rgba[i * 4] = bgR;
40901
40907
  rgba[i * 4 + 1] = bgG;
@@ -41072,6 +41078,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
41072
41078
  }
41073
41079
  }
41074
41080
  }
41081
+ if (deferBackground) {
41082
+ for (let i = 0; i < rgba.length; i += 4) {
41083
+ const alpha = rgba[i + 3] / 255;
41084
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
41085
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
41086
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
41087
+ rgba[i + 3] = 255;
41088
+ }
41089
+ }
41075
41090
  let result = { width, height, data: rgba };
41076
41091
  if (Math.abs(scaleX - scaleY) > 1e-6) {
41077
41092
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -41180,6 +41195,7 @@ function renderDisplayListToSvg(displayList, options = {}) {
41180
41195
  if (!options.transparent) {
41181
41196
  parts.push(` <rect x="${vbX}" y="${vbY}" width="${vbW}" height="${vbH}" fill="#ffffff"/>`);
41182
41197
  }
41198
+ parts.push('<g style="isolation:isolate">');
41183
41199
  if (displayList.rotation) {
41184
41200
  const [a, b, c, d, e, f] = viewport.transform;
41185
41201
  parts.push(`<g transform="matrix(${a} ${b} ${-c} ${-d} ${e + c * displayList.height} ${f + d * displayList.height})">`);
@@ -41267,6 +41283,7 @@ function renderDisplayListToSvg(displayList, options = {}) {
41267
41283
  };
41268
41284
  appendOperations(paintOperations(displayList));
41269
41285
  if (displayList.rotation) parts.push("</g>");
41286
+ parts.push("</g>");
41270
41287
  parts.push("</svg>\n");
41271
41288
  return parts.join("\n");
41272
41289
  }
@@ -35898,8 +35898,9 @@ function evaluateContentStreamToDisplayList(params) {
35898
35898
  const st = curState();
35899
35899
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
35900
35900
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
35901
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
35902
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
35901
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
35902
+ const isolated = isolation?.kind === "boolean" && isolation.value;
35903
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
35903
35904
  const formStreamBytes = params.cosDoc.decodeStream(form);
35904
35905
  const formNodes = parseContentStream(formStreamBytes);
35905
35906
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -35917,8 +35918,8 @@ function evaluateContentStreamToDisplayList(params) {
35917
35918
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
35918
35919
  nextCtm = multiplyMatrices(formMat, nextCtm);
35919
35920
  }
35920
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
35921
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
35921
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
35922
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
35922
35923
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
35923
35924
  if (bboxArr && bboxArr.items.length >= 4) {
35924
35925
  const bn = (idx, fb = 0) => {
@@ -35952,7 +35953,7 @@ function evaluateContentStreamToDisplayList(params) {
35952
35953
  const parentOperations = capturedOperations;
35953
35954
  const children = [];
35954
35955
  const nextState = { ...st, ctm: nextCtm };
35955
- if (isolate) {
35956
+ if (compositeGroup) {
35956
35957
  capturedOperations = children;
35957
35958
  nextState.fillAlpha = nextState.strokeAlpha = 1;
35958
35959
  nextState.blendMode = "Normal";
@@ -35970,7 +35971,7 @@ function evaluateContentStreamToDisplayList(params) {
35970
35971
  stateStack.pop();
35971
35972
  capturedOperations = parentOperations;
35972
35973
  }
35973
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
35974
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
35974
35975
  };
35975
35976
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
35976
35977
  for (const node of nodes) {
@@ -40512,6 +40513,9 @@ function renderSoftMask(mask, displayList, scale) {
40512
40513
  }
40513
40514
  return bitmap;
40514
40515
  }
40516
+ function hasBlendModes(operations) {
40517
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40518
+ }
40515
40519
  function renderDisplayListToBitmap(displayList, options = {}) {
40516
40520
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40517
40521
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40520,11 +40524,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40520
40524
  const width = Math.max(1, Math.round(displayList.width * scale));
40521
40525
  const height = Math.max(1, Math.round(displayList.height * scale));
40522
40526
  const rgba = new Uint8Array(width * height * 4);
40527
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40528
+ const transparent = options.transparent || deferBackground;
40523
40529
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40524
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40525
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40526
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40527
- const bgA = options.transparent ? 0 : 255;
40530
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40531
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40532
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40533
+ const bgA = transparent ? 0 : 255;
40528
40534
  for (let i = 0; i < width * height; i++) {
40529
40535
  rgba[i * 4] = bgR;
40530
40536
  rgba[i * 4 + 1] = bgG;
@@ -40701,6 +40707,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40701
40707
  }
40702
40708
  }
40703
40709
  }
40710
+ if (deferBackground) {
40711
+ for (let i = 0; i < rgba.length; i += 4) {
40712
+ const alpha = rgba[i + 3] / 255;
40713
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
40714
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
40715
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
40716
+ rgba[i + 3] = 255;
40717
+ }
40718
+ }
40704
40719
  let result = { width, height, data: rgba };
40705
40720
  if (Math.abs(scaleX - scaleY) > 1e-6) {
40706
40721
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -36092,8 +36092,9 @@ function evaluateContentStreamToDisplayList(params) {
36092
36092
  const st = curState();
36093
36093
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
36094
36094
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
36095
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36096
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
36095
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36096
+ const isolated = isolation?.kind === "boolean" && isolation.value;
36097
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
36097
36098
  const formStreamBytes = params.cosDoc.decodeStream(form);
36098
36099
  const formNodes = parseContentStream(formStreamBytes);
36099
36100
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -36111,8 +36112,8 @@ function evaluateContentStreamToDisplayList(params) {
36111
36112
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
36112
36113
  nextCtm = multiplyMatrices(formMat, nextCtm);
36113
36114
  }
36114
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
36115
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
36115
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
36116
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
36116
36117
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
36117
36118
  if (bboxArr && bboxArr.items.length >= 4) {
36118
36119
  const bn = (idx, fb = 0) => {
@@ -36146,7 +36147,7 @@ function evaluateContentStreamToDisplayList(params) {
36146
36147
  const parentOperations = capturedOperations;
36147
36148
  const children = [];
36148
36149
  const nextState = { ...st, ctm: nextCtm };
36149
- if (isolate) {
36150
+ if (compositeGroup) {
36150
36151
  capturedOperations = children;
36151
36152
  nextState.fillAlpha = nextState.strokeAlpha = 1;
36152
36153
  nextState.blendMode = "Normal";
@@ -36164,7 +36165,7 @@ function evaluateContentStreamToDisplayList(params) {
36164
36165
  stateStack.pop();
36165
36166
  capturedOperations = parentOperations;
36166
36167
  }
36167
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36168
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36168
36169
  };
36169
36170
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
36170
36171
  for (const node of nodes) {
@@ -40538,6 +40539,9 @@ function renderSoftMask(mask, displayList, scale) {
40538
40539
  }
40539
40540
  return bitmap;
40540
40541
  }
40542
+ function hasBlendModes(operations) {
40543
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40544
+ }
40541
40545
  function renderDisplayListToBitmap(displayList, options = {}) {
40542
40546
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40543
40547
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40546,11 +40550,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40546
40550
  const width = Math.max(1, Math.round(displayList.width * scale));
40547
40551
  const height = Math.max(1, Math.round(displayList.height * scale));
40548
40552
  const rgba = new Uint8Array(width * height * 4);
40553
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40554
+ const transparent = options.transparent || deferBackground;
40549
40555
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40550
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40551
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40552
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40553
- const bgA = options.transparent ? 0 : 255;
40556
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40557
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40558
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40559
+ const bgA = transparent ? 0 : 255;
40554
40560
  for (let i = 0; i < width * height; i++) {
40555
40561
  rgba[i * 4] = bgR;
40556
40562
  rgba[i * 4 + 1] = bgG;
@@ -40727,6 +40733,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40727
40733
  }
40728
40734
  }
40729
40735
  }
40736
+ if (deferBackground) {
40737
+ for (let i = 0; i < rgba.length; i += 4) {
40738
+ const alpha = rgba[i + 3] / 255;
40739
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
40740
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
40741
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
40742
+ rgba[i + 3] = 255;
40743
+ }
40744
+ }
40730
40745
  let result = { width, height, data: rgba };
40731
40746
  if (Math.abs(scaleX - scaleY) > 1e-6) {
40732
40747
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -40835,6 +40850,7 @@ function renderDisplayListToSvg(displayList, options = {}) {
40835
40850
  if (!options.transparent) {
40836
40851
  parts.push(` <rect x="${vbX}" y="${vbY}" width="${vbW}" height="${vbH}" fill="#ffffff"/>`);
40837
40852
  }
40853
+ parts.push('<g style="isolation:isolate">');
40838
40854
  if (displayList.rotation) {
40839
40855
  const [a, b, c, d, e, f] = viewport.transform;
40840
40856
  parts.push(`<g transform="matrix(${a} ${b} ${-c} ${-d} ${e + c * displayList.height} ${f + d * displayList.height})">`);
@@ -40922,6 +40938,7 @@ function renderDisplayListToSvg(displayList, options = {}) {
40922
40938
  };
40923
40939
  appendOperations(paintOperations(displayList));
40924
40940
  if (displayList.rotation) parts.push("</g>");
40941
+ parts.push("</g>");
40925
40942
  parts.push("</svg>\n");
40926
40943
  return parts.join("\n");
40927
40944
  }
@@ -36243,8 +36243,9 @@ function evaluateContentStreamToDisplayList(params) {
36243
36243
  const st = curState();
36244
36244
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
36245
36245
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
36246
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36247
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
36246
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
36247
+ const isolated = isolation?.kind === "boolean" && isolation.value;
36248
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
36248
36249
  const formStreamBytes = params.cosDoc.decodeStream(form);
36249
36250
  const formNodes = parseContentStream(formStreamBytes);
36250
36251
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -36262,8 +36263,8 @@ function evaluateContentStreamToDisplayList(params) {
36262
36263
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
36263
36264
  nextCtm = multiplyMatrices(formMat, nextCtm);
36264
36265
  }
36265
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
36266
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
36266
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
36267
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
36267
36268
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
36268
36269
  if (bboxArr && bboxArr.items.length >= 4) {
36269
36270
  const bn = (idx, fb = 0) => {
@@ -36297,7 +36298,7 @@ function evaluateContentStreamToDisplayList(params) {
36297
36298
  const parentOperations = capturedOperations;
36298
36299
  const children = [];
36299
36300
  const nextState = { ...st, ctm: nextCtm };
36300
- if (isolate) {
36301
+ if (compositeGroup) {
36301
36302
  capturedOperations = children;
36302
36303
  nextState.fillAlpha = nextState.strokeAlpha = 1;
36303
36304
  nextState.blendMode = "Normal";
@@ -36315,7 +36316,7 @@ function evaluateContentStreamToDisplayList(params) {
36315
36316
  stateStack.pop();
36316
36317
  capturedOperations = parentOperations;
36317
36318
  }
36318
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36319
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
36319
36320
  };
36320
36321
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
36321
36322
  for (const node of nodes) {
@@ -40520,6 +40521,9 @@ function renderSoftMask(mask, displayList, scale) {
40520
40521
  }
40521
40522
  return bitmap;
40522
40523
  }
40524
+ function hasBlendModes(operations) {
40525
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40526
+ }
40523
40527
  function renderDisplayListToBitmap(displayList, options = {}) {
40524
40528
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40525
40529
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40528,11 +40532,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40528
40532
  const width = Math.max(1, Math.round(displayList.width * scale));
40529
40533
  const height = Math.max(1, Math.round(displayList.height * scale));
40530
40534
  const rgba = new Uint8Array(width * height * 4);
40535
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40536
+ const transparent = options.transparent || deferBackground;
40531
40537
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40532
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40533
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40534
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40535
- const bgA = options.transparent ? 0 : 255;
40538
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40539
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40540
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40541
+ const bgA = transparent ? 0 : 255;
40536
40542
  for (let i = 0; i < width * height; i++) {
40537
40543
  rgba[i * 4] = bgR;
40538
40544
  rgba[i * 4 + 1] = bgG;
@@ -40709,6 +40715,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40709
40715
  }
40710
40716
  }
40711
40717
  }
40718
+ if (deferBackground) {
40719
+ for (let i = 0; i < rgba.length; i += 4) {
40720
+ const alpha = rgba[i + 3] / 255;
40721
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
40722
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
40723
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
40724
+ rgba[i + 3] = 255;
40725
+ }
40726
+ }
40712
40727
  let result = { width, height, data: rgba };
40713
40728
  if (Math.abs(scaleX - scaleY) > 1e-6) {
40714
40729
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -35898,8 +35898,9 @@ function evaluateContentStreamToDisplayList(params) {
35898
35898
  const st = curState();
35899
35899
  const group = params.cosDoc.resolveDict(dictGet(form.dict, "Group"));
35900
35900
  const groupType = group ? params.cosDoc.resolve(dictGet(group, "S")) : void 0;
35901
- const isolated = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
35902
- const isolate = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && isolated?.kind === "boolean" && isolated.value;
35901
+ const isolation = group ? params.cosDoc.resolve(dictGet(group, "I")) : void 0;
35902
+ const isolated = isolation?.kind === "boolean" && isolation.value;
35903
+ const compositeGroup = !maskGroup && groupType?.kind === "name" && groupType.decoded === "Transparency" && (isolated || st.fillAlpha !== 1 || !!st.softMask || st.blendMode !== "Normal" && st.blendMode !== "Compatible");
35903
35904
  const formStreamBytes = params.cosDoc.decodeStream(form);
35904
35905
  const formNodes = parseContentStream(formStreamBytes);
35905
35906
  const formResDict = params.cosDoc.resolveDict(dictGet(form.dict, "Resources")) ?? activeResources;
@@ -35917,8 +35918,8 @@ function evaluateContentStreamToDisplayList(params) {
35917
35918
  const formMat = [mn(0, 1), mn(1, 0), mn(2, 0), mn(3, 1), mn(4, 0), mn(5, 0)];
35918
35919
  nextCtm = multiplyMatrices(formMat, nextCtm);
35919
35920
  }
35920
- let nextClip = !isolate && st.clipRect ? [...st.clipRect] : void 0;
35921
- let nextClipPaths = isolate ? void 0 : st.clipPaths;
35921
+ let nextClip = !compositeGroup && st.clipRect ? [...st.clipRect] : void 0;
35922
+ let nextClipPaths = compositeGroup ? void 0 : st.clipPaths;
35922
35923
  const bboxArr = params.cosDoc.resolveArray(dictGet(form.dict, "BBox"));
35923
35924
  if (bboxArr && bboxArr.items.length >= 4) {
35924
35925
  const bn = (idx, fb = 0) => {
@@ -35952,7 +35953,7 @@ function evaluateContentStreamToDisplayList(params) {
35952
35953
  const parentOperations = capturedOperations;
35953
35954
  const children = [];
35954
35955
  const nextState = { ...st, ctm: nextCtm };
35955
- if (isolate) {
35956
+ if (compositeGroup) {
35956
35957
  capturedOperations = children;
35957
35958
  nextState.fillAlpha = nextState.strokeAlpha = 1;
35958
35959
  nextState.blendMode = "Normal";
@@ -35970,7 +35971,7 @@ function evaluateContentStreamToDisplayList(params) {
35970
35971
  stateStack.pop();
35971
35972
  capturedOperations = parentOperations;
35972
35973
  }
35973
- if (isolate) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
35974
+ if (compositeGroup) emit({ kind: "group", value: { operations: children, alpha: st.fillAlpha, blendMode: st.blendMode, clipRect: st.clipRect } });
35974
35975
  };
35975
35976
  const walkNodes = (nodes, mcid, actualText, activeResources = params.resourcesDict, activeFonts = fonts, depth = 0) => {
35976
35977
  for (const node of nodes) {
@@ -40058,6 +40059,9 @@ function renderSoftMask(mask, displayList, scale) {
40058
40059
  }
40059
40060
  return bitmap;
40060
40061
  }
40062
+ function hasBlendModes(operations) {
40063
+ return operations.some((operation) => !!operation.value.blendMode && operation.value.blendMode !== "Normal" && operation.value.blendMode !== "Compatible" || operation.kind === "group" && hasBlendModes(operation.value.operations));
40064
+ }
40061
40065
  function renderDisplayListToBitmap(displayList, options = {}) {
40062
40066
  const baseScale = options.scale ?? (options.dpi ? options.dpi / 72 : 1.5);
40063
40067
  const scaleX = options.dpiX !== void 0 ? options.dpiX / 72 : baseScale;
@@ -40066,11 +40070,13 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40066
40070
  const width = Math.max(1, Math.round(displayList.width * scale));
40067
40071
  const height = Math.max(1, Math.round(displayList.height * scale));
40068
40072
  const rgba = new Uint8Array(width * height * 4);
40073
+ const deferBackground = !options.transparent && hasBlendModes(paintOperations(displayList));
40074
+ const transparent = options.transparent || deferBackground;
40069
40075
  const bg = options.background ?? { r: 1, g: 1, b: 1 };
40070
- const bgR = options.transparent ? 0 : Math.round(bg.r * 255);
40071
- const bgG = options.transparent ? 0 : Math.round(bg.g * 255);
40072
- const bgB = options.transparent ? 0 : Math.round(bg.b * 255);
40073
- const bgA = options.transparent ? 0 : 255;
40076
+ const bgR = transparent ? 0 : Math.round(bg.r * 255);
40077
+ const bgG = transparent ? 0 : Math.round(bg.g * 255);
40078
+ const bgB = transparent ? 0 : Math.round(bg.b * 255);
40079
+ const bgA = transparent ? 0 : 255;
40074
40080
  for (let i = 0; i < width * height; i++) {
40075
40081
  rgba[i * 4] = bgR;
40076
40082
  rgba[i * 4 + 1] = bgG;
@@ -40247,6 +40253,15 @@ function renderDisplayListToBitmap(displayList, options = {}) {
40247
40253
  }
40248
40254
  }
40249
40255
  }
40256
+ if (deferBackground) {
40257
+ for (let i = 0; i < rgba.length; i += 4) {
40258
+ const alpha = rgba[i + 3] / 255;
40259
+ rgba[i] = Math.round(rgba[i] * alpha + bg.r * 255 * (1 - alpha));
40260
+ rgba[i + 1] = Math.round(rgba[i + 1] * alpha + bg.g * 255 * (1 - alpha));
40261
+ rgba[i + 2] = Math.round(rgba[i + 2] * alpha + bg.b * 255 * (1 - alpha));
40262
+ rgba[i + 3] = 255;
40263
+ }
40264
+ }
40250
40265
  let result = { width, height, data: rgba };
40251
40266
  if (Math.abs(scaleX - scaleY) > 1e-6) {
40252
40267
  const targetW = Math.max(1, Math.round(displayList.width * scaleX));
@@ -11,8 +11,8 @@ import {
11
11
  readImageMetadata,
12
12
  resizeImage,
13
13
  rotateImage
14
- } from "../safe-bash/command-chunks/chunk-IOH3F3ZO.js";
15
- import "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
14
+ } from "../safe-bash/command-chunks/chunk-A5S6M37L.js";
15
+ import "../safe-bash/command-chunks/chunk-2JQONXIY.js";
16
16
  import {
17
17
  init_buffer
18
18
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";
@@ -31,7 +31,7 @@ import {
31
31
  PdfDocument,
32
32
  decodeFlate,
33
33
  rgb
34
- } from "../safe-bash/command-chunks/chunk-XFUFHHLU.js";
34
+ } from "../safe-bash/command-chunks/chunk-2JQONXIY.js";
35
35
  import {
36
36
  init_buffer
37
37
  } from "../safe-bash/command-chunks/chunk-HX3SHTCE.js";