@superdoc-dev/cli 0.2.0-next.17 → 0.2.0-next.19

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.
Files changed (2) hide show
  1. package/dist/index.js +754 -359
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -20029,7 +20029,7 @@ var init_uuid_2IzDu5nl_es = __esm(() => {
20029
20029
  v4_default = v4;
20030
20030
  });
20031
20031
 
20032
- // ../../packages/superdoc/dist/chunks/constants-DBKi0Amm.es.js
20032
+ // ../../packages/superdoc/dist/chunks/constants-Dw0kAsLd.es.js
20033
20033
  function computeCrc32Hex(data) {
20034
20034
  let crc = 4294967295;
20035
20035
  for (let i2 = 0;i2 < data.length; i2++)
@@ -20382,8 +20382,35 @@ var import_lib, CRC32_TABLE, REMOTE_RESOURCE_PATTERN, DATA_URI_PATTERN, getArray
20382
20382
  dta[i2] ^= guidBytes[gi];
20383
20383
  }
20384
20384
  return dta.buffer;
20385
+ }, detectImageType = (data) => {
20386
+ let bytes;
20387
+ if (typeof data === "string")
20388
+ try {
20389
+ bytes = base64ToUint8Array(data);
20390
+ } catch {
20391
+ return null;
20392
+ }
20393
+ else if (data instanceof Uint8Array)
20394
+ bytes = data;
20395
+ else
20396
+ return null;
20397
+ if (bytes.length < 12)
20398
+ return null;
20399
+ if (bytes[0] === 137 && bytes[1] === 80 && bytes[2] === 78 && bytes[3] === 71 && bytes[4] === 13 && bytes[5] === 10 && bytes[6] === 26 && bytes[7] === 10)
20400
+ return "png";
20401
+ if (bytes[0] === 255 && bytes[1] === 216 && bytes[2] === 255)
20402
+ return "jpeg";
20403
+ if (bytes[0] === 71 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 56)
20404
+ return "gif";
20405
+ if (bytes[0] === 66 && bytes[1] === 77)
20406
+ return "bmp";
20407
+ if (bytes[0] === 73 && bytes[1] === 73 && bytes[2] === 42 && bytes[3] === 0 || bytes[0] === 77 && bytes[1] === 77 && bytes[2] === 0 && bytes[3] === 42)
20408
+ return "tiff";
20409
+ if (bytes.length >= 12 && bytes[0] === 82 && bytes[1] === 73 && bytes[2] === 70 && bytes[3] === 70 && bytes[8] === 87 && bytes[9] === 69 && bytes[10] === 66 && bytes[11] === 80)
20410
+ return "webp";
20411
+ return null;
20385
20412
  }, COMMENT_FILE_BASENAMES, COMMENT_RELATIONSHIP_TYPES;
20386
- var init_constants_DBKi0Amm_es = __esm(() => {
20413
+ var init_constants_Dw0kAsLd_es = __esm(() => {
20387
20414
  init_xml_js_DLE8mr0n_es();
20388
20415
  import_lib = require_lib();
20389
20416
  CRC32_TABLE = new Uint32Array(256);
@@ -26591,7 +26618,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
26591
26618
  emptyOptions2 = {};
26592
26619
  });
26593
26620
 
26594
- // ../../packages/superdoc/dist/chunks/SuperConverter-D7fmxDmw.es.js
26621
+ // ../../packages/superdoc/dist/chunks/SuperConverter-CRrxAa8F.es.js
26595
26622
  function getExtensionConfigField(extension$1, field, context = { name: "" }) {
26596
26623
  const fieldValue = extension$1.config[field];
26597
26624
  if (typeof fieldValue === "function")
@@ -31604,6 +31631,7 @@ function handleImageNode(node3, params, isAnchor) {
31604
31631
  const blip = blipFill?.elements.find((el) => el.name === "a:blip");
31605
31632
  if (!blip)
31606
31633
  return null;
31634
+ const hasGrayscale = blip.elements?.some((el) => el.name === "a:grayscl");
31607
31635
  const stretch = blipFill?.elements?.find((el) => el.name === "a:stretch");
31608
31636
  const fillRect = stretch?.elements?.find((el) => el.name === "a:fillRect");
31609
31637
  const srcRect = blipFill?.elements?.find((el) => el.name === "a:srcRect");
@@ -31704,7 +31732,8 @@ function handleImageNode(node3, params, isAnchor) {
31704
31732
  originalAttributes: node3.attributes,
31705
31733
  rId: relAttributes["Id"],
31706
31734
  ...order2.length ? { drawingChildOrder: order2 } : {},
31707
- ...originalChildren.length ? { originalDrawingChildren: originalChildren } : {}
31735
+ ...originalChildren.length ? { originalDrawingChildren: originalChildren } : {},
31736
+ ...hasGrayscale ? { grayscale: true } : {}
31708
31737
  }
31709
31738
  };
31710
31739
  }
@@ -44885,6 +44914,162 @@ var isRegExp = (value) => {
44885
44914
  }
44886
44915
  return ret;
44887
44916
  }
44917
+ }, BitmapCoreHeader$1 = class {
44918
+ constructor(reader, skipsize) {
44919
+ if (skipsize)
44920
+ reader.skip(4);
44921
+ this.width = reader.readUint16();
44922
+ this.height = reader.readUint16();
44923
+ this.planes = reader.readUint16();
44924
+ this.bitcount = reader.readUint16();
44925
+ }
44926
+ colors() {
44927
+ return this.bitcount <= 8 ? 1 << this.bitcount : 0;
44928
+ }
44929
+ }, BitmapInfoHeader$1 = class {
44930
+ constructor(reader, skipsize) {
44931
+ if (skipsize)
44932
+ reader.skip(4);
44933
+ this.width = reader.readInt32();
44934
+ this.height = reader.readInt32();
44935
+ this.planes = reader.readUint16();
44936
+ this.bitcount = reader.readUint16();
44937
+ this.compression = reader.readUint32();
44938
+ this.sizeimage = reader.readUint32();
44939
+ this.xpelspermeter = reader.readInt32();
44940
+ this.ypelspermeter = reader.readInt32();
44941
+ this.clrused = reader.readUint32();
44942
+ this.clrimportant = reader.readUint32();
44943
+ }
44944
+ colors() {
44945
+ if (this.clrused !== 0)
44946
+ return this.clrused < 256 ? this.clrused : 256;
44947
+ else
44948
+ return this.bitcount > 8 ? 0 : 1 << this.bitcount;
44949
+ }
44950
+ }, BitmapInfo$1 = class {
44951
+ constructor(reader, usergb) {
44952
+ this._usergb = usergb;
44953
+ const hdrsize = reader.readUint32();
44954
+ this._infosize = hdrsize;
44955
+ if (hdrsize === Helper$1.GDI.BITMAPCOREHEADER_SIZE) {
44956
+ this._header = new BitmapCoreHeader$1(reader, false);
44957
+ this._infosize += this._header.colors() * (usergb ? 3 : 2);
44958
+ } else {
44959
+ this._header = new BitmapInfoHeader$1(reader, false);
44960
+ const masks = this._header.compression === Helper$1.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
44961
+ if (hdrsize <= Helper$1.GDI.BITMAPINFOHEADER_SIZE + masks * 4)
44962
+ this._infosize = Helper$1.GDI.BITMAPINFOHEADER_SIZE + masks * 4;
44963
+ this._infosize += this._header.colors() * (usergb ? 4 : 2);
44964
+ }
44965
+ }
44966
+ getWidth() {
44967
+ return this._header.width;
44968
+ }
44969
+ getHeight() {
44970
+ return Math.abs(this._header.height);
44971
+ }
44972
+ infosize() {
44973
+ return this._infosize;
44974
+ }
44975
+ header() {
44976
+ return this._header;
44977
+ }
44978
+ }, DIBitmap$1 = class {
44979
+ constructor(reader, bitmapInfo) {
44980
+ this._reader = reader;
44981
+ this._offset = reader.pos;
44982
+ this._location = bitmapInfo;
44983
+ this._info = new BitmapInfo$1(reader, true);
44984
+ }
44985
+ getWidth() {
44986
+ return this._info.getWidth();
44987
+ }
44988
+ getHeight() {
44989
+ return this._info.getHeight();
44990
+ }
44991
+ totalSize() {
44992
+ return this._location.header.size + this._location.data.size;
44993
+ }
44994
+ makeBitmapFileHeader() {
44995
+ const buf = /* @__PURE__ */ new ArrayBuffer(14);
44996
+ const view = new Uint8Array(buf);
44997
+ view[0] = 66;
44998
+ view[1] = 77;
44999
+ Helper$1._writeUint32Val(view, 2, this.totalSize() + 14);
45000
+ Helper$1._writeUint32Val(view, 10, this._info.infosize() + 14);
45001
+ return Helper$1._blobToBinary(view);
45002
+ }
45003
+ convertToPNG(bitmapData, width, height, hasAlpha) {
45004
+ const canvas = document.createElement("canvas");
45005
+ canvas.width = width;
45006
+ canvas.height = Math.abs(height);
45007
+ const ctx = canvas.getContext("2d");
45008
+ if (!ctx)
45009
+ throw new Error("Unable to get canvas context for PNG conversion");
45010
+ const imageData = ctx.createImageData(width, Math.abs(height));
45011
+ const pixels = imageData.data;
45012
+ const rowSize = width * 32 + 31 >>> 5 << 2;
45013
+ const absHeight = Math.abs(height);
45014
+ const topDown = height < 0;
45015
+ let alphaUsed = false;
45016
+ if (hasAlpha)
45017
+ for (let y = 0;y < absHeight && !alphaUsed; y++) {
45018
+ const srcY = topDown ? y : absHeight - 1 - y;
45019
+ for (let x = 0;x < width && !alphaUsed; x++)
45020
+ if (bitmapData[srcY * rowSize + x * 4 + 3] > 0)
45021
+ alphaUsed = true;
45022
+ }
45023
+ for (let y = 0;y < absHeight; y++) {
45024
+ const srcY = topDown ? y : absHeight - 1 - y;
45025
+ for (let x = 0;x < width; x++) {
45026
+ const srcOffset = srcY * rowSize + x * 4;
45027
+ const dstOffset = (y * width + x) * 4;
45028
+ pixels[dstOffset] = bitmapData[srcOffset + 2];
45029
+ pixels[dstOffset + 1] = bitmapData[srcOffset + 1];
45030
+ pixels[dstOffset + 2] = bitmapData[srcOffset];
45031
+ pixels[dstOffset + 3] = alphaUsed ? bitmapData[srcOffset + 3] : 255;
45032
+ }
45033
+ }
45034
+ ctx.putImageData(imageData, 0, 0);
45035
+ return canvas.toDataURL("image/png");
45036
+ }
45037
+ base64ref() {
45038
+ const prevpos = this._reader.pos;
45039
+ this._reader.seek(this._offset);
45040
+ const header = this._info.header();
45041
+ if (header instanceof BitmapInfoHeader$1 && header.compression != null)
45042
+ switch (header.compression) {
45043
+ case Helper$1.GDI.BitmapCompression.BI_JPEG:
45044
+ this._reader.seek(this._location.data.off);
45045
+ const jpegData = "data:image/jpeg;base64," + btoa(this._reader.readBinary(this._location.data.size));
45046
+ this._reader.seek(prevpos);
45047
+ return jpegData;
45048
+ case Helper$1.GDI.BitmapCompression.BI_PNG:
45049
+ this._reader.seek(this._location.data.off);
45050
+ const pngData = "data:image/png;base64," + btoa(this._reader.readBinary(this._location.data.size));
45051
+ this._reader.seek(prevpos);
45052
+ return pngData;
45053
+ }
45054
+ if (header instanceof BitmapInfoHeader$1 && header.bitcount === 32) {
45055
+ this._reader.seek(this._location.data.off);
45056
+ const bitmapBytes = new Uint8Array(this._location.data.size);
45057
+ const bitmapData = this._reader.readBinary(this._location.data.size);
45058
+ for (let i2 = 0;i2 < this._location.data.size; i2++)
45059
+ bitmapBytes[i2] = bitmapData.charCodeAt(i2);
45060
+ const pngDataUrl = this.convertToPNG(bitmapBytes, header.width, header.height, true);
45061
+ this._reader.seek(prevpos);
45062
+ return pngDataUrl;
45063
+ }
45064
+ let data = this.makeBitmapFileHeader();
45065
+ this._reader.seek(this._location.header.off);
45066
+ data += this._reader.readBinary(this._location.header.size);
45067
+ this._reader.seek(this._location.data.off);
45068
+ data += this._reader.readBinary(this._location.data.size);
45069
+ const ref2 = "data:image/bmp;base64," + btoa(data);
45070
+ this._reader.seek(prevpos);
45071
+ return ref2;
45072
+ }
44888
45073
  }, PointS$1 = class PointS$12 {
44889
45074
  constructor(reader, x, y) {
44890
45075
  if (reader != null) {
@@ -45065,123 +45250,6 @@ var isRegExp = (value) => {
45065
45250
  }
45066
45251
  return this.scanlines.length > 0;
45067
45252
  }
45068
- }, BitmapCoreHeader$1 = class {
45069
- constructor(reader, skipsize) {
45070
- if (skipsize)
45071
- reader.skip(4);
45072
- this.width = reader.readUint16();
45073
- this.height = reader.readUint16();
45074
- this.planes = reader.readUint16();
45075
- this.bitcount = reader.readUint16();
45076
- }
45077
- colors() {
45078
- return this.bitcount <= 8 ? 1 << this.bitcount : 0;
45079
- }
45080
- }, BitmapInfoHeader$1 = class {
45081
- constructor(reader, skipsize) {
45082
- if (skipsize)
45083
- reader.skip(4);
45084
- this.width = reader.readInt32();
45085
- this.height = reader.readInt32();
45086
- this.planes = reader.readUint16();
45087
- this.bitcount = reader.readUint16();
45088
- this.compression = reader.readUint32();
45089
- this.sizeimage = reader.readUint32();
45090
- this.xpelspermeter = reader.readInt32();
45091
- this.ypelspermeter = reader.readInt32();
45092
- this.clrused = reader.readUint32();
45093
- this.clrimportant = reader.readUint32();
45094
- }
45095
- colors() {
45096
- if (this.clrused !== 0)
45097
- return this.clrused < 256 ? this.clrused : 256;
45098
- else
45099
- return this.bitcount > 8 ? 0 : 1 << this.bitcount;
45100
- }
45101
- }, BitmapInfo$1 = class {
45102
- constructor(reader, usergb) {
45103
- this._usergb = usergb;
45104
- const hdrsize = reader.readUint32();
45105
- this._infosize = hdrsize;
45106
- if (hdrsize === Helper$1.GDI.BITMAPCOREHEADER_SIZE) {
45107
- this._header = new BitmapCoreHeader$1(reader, false);
45108
- this._infosize += this._header.colors() * (usergb ? 3 : 2);
45109
- } else {
45110
- this._header = new BitmapInfoHeader$1(reader, false);
45111
- const masks = this._header.compression === Helper$1.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
45112
- if (hdrsize <= Helper$1.GDI.BITMAPINFOHEADER_SIZE + masks * 4)
45113
- this._infosize = Helper$1.GDI.BITMAPINFOHEADER_SIZE + masks * 4;
45114
- this._infosize += this._header.colors() * (usergb ? 4 : 2);
45115
- }
45116
- }
45117
- getWidth() {
45118
- return this._header.width;
45119
- }
45120
- getHeight() {
45121
- return Math.abs(this._header.height);
45122
- }
45123
- infosize() {
45124
- return this._infosize;
45125
- }
45126
- header() {
45127
- return this._header;
45128
- }
45129
- }, DIBitmap$1 = class {
45130
- constructor(reader, bitmapInfo) {
45131
- this._reader = reader;
45132
- this._offset = reader.pos;
45133
- this._location = bitmapInfo;
45134
- this._info = new BitmapInfo$1(reader, true);
45135
- }
45136
- getWidth() {
45137
- return this._info.getWidth();
45138
- }
45139
- getHeight() {
45140
- return this._info.getHeight();
45141
- }
45142
- totalSize() {
45143
- return this._location.header.size + this._location.data.size;
45144
- }
45145
- makeBitmapFileHeader() {
45146
- const buf = /* @__PURE__ */ new ArrayBuffer(14);
45147
- const view = new Uint8Array(buf);
45148
- view[0] = 66;
45149
- view[1] = 77;
45150
- Helper$1._writeUint32Val(view, 2, this.totalSize() + 14);
45151
- Helper$1._writeUint32Val(view, 10, this._info.infosize() + 14);
45152
- return Helper$1._blobToBinary(view);
45153
- }
45154
- base64ref() {
45155
- const prevpos = this._reader.pos;
45156
- this._reader.seek(this._offset);
45157
- let mime = "image/bmp";
45158
- const header = this._info.header();
45159
- let data;
45160
- if (header instanceof BitmapInfoHeader$1 && header.compression != null)
45161
- switch (header.compression) {
45162
- case Helper$1.GDI.BitmapCompression.BI_JPEG:
45163
- mime = "data:image/jpeg";
45164
- break;
45165
- case Helper$1.GDI.BitmapCompression.BI_PNG:
45166
- mime = "data:image/png";
45167
- break;
45168
- default:
45169
- data = this.makeBitmapFileHeader();
45170
- break;
45171
- }
45172
- else
45173
- data = this.makeBitmapFileHeader();
45174
- this._reader.seek(this._location.header.offset);
45175
- if (data != null)
45176
- data += this._reader.readBinary(this._location.header.size);
45177
- else
45178
- data = this._reader.readBinary(this._location.header.size);
45179
- this._reader.seek(this._location.data.offset);
45180
- data += this._reader.readBinary(this._location.data.size);
45181
- const ref2 = "data:" + mime + ";base64," + btoa(data);
45182
- this._reader.seek(prevpos);
45183
- return ref2;
45184
- }
45185
45253
  }, ColorRef$1 = class ColorRef$12 {
45186
45254
  constructor(reader, r, g, b) {
45187
45255
  if (reader != null) {
@@ -45255,6 +45323,9 @@ var isRegExp = (value) => {
45255
45323
  }
45256
45324
  }
45257
45325
  }
45326
+ getBounds() {
45327
+ return this.bounds;
45328
+ }
45258
45329
  toString() {
45259
45330
  return "{bounds: " + this.bounds.toString() + ", frame: " + this.frame.toString() + ", description: " + this.description + "}";
45260
45331
  }
@@ -45364,11 +45435,11 @@ var isRegExp = (value) => {
45364
45435
  const cbBits = reader.readUint32();
45365
45436
  const pen = new Pen$1(reader, {
45366
45437
  header: {
45367
- off: offBmi,
45438
+ off: curpos + offBmi,
45368
45439
  size: cbBmi
45369
45440
  },
45370
45441
  data: {
45371
- off: offBits,
45442
+ off: curpos + offBits,
45372
45443
  size: cbBits
45373
45444
  }
45374
45445
  });
@@ -45608,6 +45679,37 @@ var isRegExp = (value) => {
45608
45679
  });
45609
45680
  break;
45610
45681
  }
45682
+ case Helper$1.GDI.RecordType.EMR_STRETCHDIBITS: {
45683
+ new RectL(reader);
45684
+ const xDest = reader.readInt32();
45685
+ const yDest = reader.readInt32();
45686
+ const xSrc = reader.readInt32();
45687
+ const ySrc = reader.readInt32();
45688
+ const cxSrc = reader.readInt32();
45689
+ const cySrc = reader.readInt32();
45690
+ const offBmiSrc = reader.readUint32();
45691
+ const cbBmiSrc = reader.readUint32();
45692
+ const offBitsSrc = reader.readUint32();
45693
+ const cbBitsSrc = reader.readUint32();
45694
+ const iUsageSrc = reader.readUint32();
45695
+ const dwRop = reader.readUint32();
45696
+ const cxDest = reader.readInt32();
45697
+ const cyDest = reader.readInt32();
45698
+ const dib = new DIBitmap$1(reader, {
45699
+ header: {
45700
+ off: curpos + offBmiSrc,
45701
+ size: cbBmiSrc
45702
+ },
45703
+ data: {
45704
+ off: curpos + offBitsSrc,
45705
+ size: cbBitsSrc
45706
+ }
45707
+ });
45708
+ this._records.push((gdi) => {
45709
+ gdi.stretchDibBits(xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest, cyDest, dwRop, iUsageSrc, dib);
45710
+ });
45711
+ break;
45712
+ }
45611
45713
  case Helper$1.GDI.RecordType.EMR_POLYLINE:
45612
45714
  case Helper$1.GDI.RecordType.EMR_POLYLINETO:
45613
45715
  case Helper$1.GDI.RecordType.EMR_POLYPOLYLINE:
@@ -45650,7 +45752,6 @@ var isRegExp = (value) => {
45650
45752
  case Helper$1.GDI.RecordType.EMR_MASKBLT:
45651
45753
  case Helper$1.GDI.RecordType.EMR_PLGBLT:
45652
45754
  case Helper$1.GDI.RecordType.EMR_SETDIBITSTODEVICE:
45653
- case Helper$1.GDI.RecordType.EMR_STRETCHDIBITS:
45654
45755
  case Helper$1.GDI.RecordType.EMR_EXTCREATEFONTINDIRECTW:
45655
45756
  case Helper$1.GDI.RecordType.EMR_EXTTEXTOUTA:
45656
45757
  case Helper$1.GDI.RecordType.EMR_EXTTEXTOUTW:
@@ -45699,6 +45800,9 @@ var isRegExp = (value) => {
45699
45800
  if (!all2)
45700
45801
  throw new EMFJSError("Could not read all records");
45701
45802
  }
45803
+ getBounds() {
45804
+ return this._header.getBounds();
45805
+ }
45702
45806
  play(gdi) {
45703
45807
  const len2 = this._records.length;
45704
45808
  for (let i2 = 0;i2 < len2; i2++)
@@ -45798,6 +45902,9 @@ var isRegExp = (value) => {
45798
45902
  this.state.mapmode = mode;
45799
45903
  this.state._svggroup = null;
45800
45904
  }
45905
+ getMapMode() {
45906
+ return this.state.mapmode;
45907
+ }
45801
45908
  setWindowOrgEx(x, y) {
45802
45909
  Helper$1.log("[gdi] setWindowOrgEx: x=" + x + " y=" + y);
45803
45910
  this.state.wx = x;
@@ -45850,6 +45957,20 @@ var isRegExp = (value) => {
45850
45957
  setStretchBltMode(stretchMode) {
45851
45958
  Helper$1.log("[gdi] setStretchBltMode: stretchMode=" + stretchMode);
45852
45959
  }
45960
+ stretchDibBits(srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH, rasterOp, colorUsage, dib) {
45961
+ Helper$1.log("[gdi] stretchDibBits: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH + " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH + " rasterOp=0x" + rasterOp.toString(16));
45962
+ srcX = this._todevX(srcX);
45963
+ srcY = this._todevY(srcY);
45964
+ srcW = this._todevW(srcW);
45965
+ srcH = this._todevH(srcH);
45966
+ dstX = this._todevX(dstX);
45967
+ dstY = this._todevY(dstY);
45968
+ dstW = this._todevW(dstW);
45969
+ dstH = this._todevH(dstH);
45970
+ Helper$1.log("[gdi] stretchDibBits: TRANSLATED: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH + " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH + " rasterOp=0x" + rasterOp.toString(16));
45971
+ this._pushGroup();
45972
+ this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());
45973
+ }
45853
45974
  rectangle(rect, rw, rh) {
45854
45975
  Helper$1.log("[gdi] rectangle: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString() + " and brush " + this.state.selected.brush.toString());
45855
45976
  const bottom = this._todevY(rect.bottom);
@@ -46328,14 +46449,16 @@ var isRegExp = (value) => {
46328
46449
  }
46329
46450
  render(info) {
46330
46451
  const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
46331
- this._render(new SVG(svgElement), info.mapMode, info.wExt, info.hExt, info.xExt, info.yExt);
46452
+ const emfBounds = this._img.getBounds();
46453
+ const gdi = this._render(new SVG(svgElement), info.mapMode, emfBounds.width, emfBounds.height, emfBounds.width, emfBounds.height);
46332
46454
  svgElement.setAttribute("viewBox", [
46333
46455
  0,
46334
46456
  0,
46335
- info.xExt,
46336
- info.yExt
46457
+ emfBounds.width,
46458
+ emfBounds.height
46337
46459
  ].join(" "));
46338
- svgElement.setAttribute("preserveAspectRatio", "none");
46460
+ const preserveAspectRatio = gdi.getMapMode() === Helper$1.GDI.MapMode.MM_ANISOTROPIC ? "none" : "xMidYMid meet";
46461
+ svgElement.setAttribute("preserveAspectRatio", preserveAspectRatio);
46339
46462
  svgElement.setAttribute("width", info.width);
46340
46463
  svgElement.setAttribute("height", info.height);
46341
46464
  return svgElement;
@@ -46360,6 +46483,7 @@ var isRegExp = (value) => {
46360
46483
  Helper$1.log("[EMF] BEGIN RENDERING --->");
46361
46484
  this._img.render(gdi);
46362
46485
  Helper$1.log("[EMF] <--- DONE RENDERING");
46486
+ return gdi;
46363
46487
  }
46364
46488
  }, EMF = class {
46365
46489
  constructor(reader, hdrsize) {
@@ -46369,6 +46493,13 @@ var isRegExp = (value) => {
46369
46493
  render(gdi) {
46370
46494
  this._records.play(gdi);
46371
46495
  }
46496
+ getBounds() {
46497
+ const bounds = this._records.getBounds();
46498
+ return {
46499
+ width: bounds.right - bounds.left,
46500
+ height: bounds.bottom - bounds.top
46501
+ };
46502
+ }
46372
46503
  }, WMFJSError, isLoggingEnabled = true, Helper, Blob$1 = class Blob$12 {
46373
46504
  constructor(blob, offset) {
46374
46505
  if (blob instanceof Blob$12) {
@@ -50368,7 +50499,8 @@ var isRegExp = (value) => {
50368
50499
  elements: [
50369
50500
  {
50370
50501
  name: "a:blip",
50371
- attributes: { "r:embed": imageId }
50502
+ attributes: { "r:embed": imageId },
50503
+ ...attrs.grayscale ? { elements: [{ name: "a:grayscl" }] } : {}
50372
50504
  },
50373
50505
  ...rawSrcRect ? [rawSrcRect] : [],
50374
50506
  {
@@ -53599,12 +53731,12 @@ var isRegExp = (value) => {
53599
53731
  state.kern = kernNode.attributes["w:val"];
53600
53732
  }
53601
53733
  }, SuperConverter;
53602
- var init_SuperConverter_D7fmxDmw_es = __esm(() => {
53734
+ var init_SuperConverter_CRrxAa8F_es = __esm(() => {
53603
53735
  init_rolldown_runtime_B2q5OVn9_es();
53604
53736
  init_jszip_ChlR43oI_es();
53605
53737
  init_xml_js_DLE8mr0n_es();
53606
53738
  init_uuid_2IzDu5nl_es();
53607
- init_constants_DBKi0Amm_es();
53739
+ init_constants_Dw0kAsLd_es();
53608
53740
  init_unified_BRHLwnjP_es();
53609
53741
  init_lib_HnbxUP96_es();
53610
53742
  init_lib_DAB30bX1_es();
@@ -66617,7 +66749,7 @@ var init_SuperConverter_D7fmxDmw_es = __esm(() => {
66617
66749
  };
66618
66750
  });
66619
66751
 
66620
- // ../../packages/superdoc/dist/chunks/DocxZipper-CXjNiywL.es.js
66752
+ // ../../packages/superdoc/dist/chunks/DocxZipper-B9Uo1uiZ.es.js
66621
66753
  function getLens2(b64) {
66622
66754
  var len$1 = b64.length;
66623
66755
  if (len$1 % 4 > 0)
@@ -66756,8 +66888,8 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
66756
66888
  this.mediaFiles[name] = fileBase64;
66757
66889
  } else {
66758
66890
  const fileBase64 = await zipEntry.async("base64");
66759
- const extension2 = this.getFileExtension(name)?.toLowerCase();
66760
- if (new Set([
66891
+ let extension2 = this.getFileExtension(name)?.toLowerCase();
66892
+ const imageTypes = new Set([
66761
66893
  "png",
66762
66894
  "jpg",
66763
66895
  "jpeg",
@@ -66768,7 +66900,14 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
66768
66900
  "wmf",
66769
66901
  "svg",
66770
66902
  "webp"
66771
- ]).has(extension2)) {
66903
+ ]);
66904
+ let detectedType = null;
66905
+ if (!imageTypes.has(extension2) || extension2 === "tmp") {
66906
+ detectedType = detectImageType(fileBase64);
66907
+ if (detectedType)
66908
+ extension2 = detectedType;
66909
+ }
66910
+ if (imageTypes.has(extension2)) {
66772
66911
  this.mediaFiles[name] = `data:image/${extension2};base64,${fileBase64}`;
66773
66912
  const blob = await zipEntry.async("blob");
66774
66913
  const fileObj = new File([blob], name, { type: blob.type });
@@ -67001,11 +67140,11 @@ var DOCX = "application/vnd.openxmlformats-officedocument.wordprocessingml.docum
67001
67140
  return unzippedOriginalDocx;
67002
67141
  }
67003
67142
  }, DocxZipper_default;
67004
- var init_DocxZipper_CXjNiywL_es = __esm(() => {
67143
+ var init_DocxZipper_B9Uo1uiZ_es = __esm(() => {
67005
67144
  init_rolldown_runtime_B2q5OVn9_es();
67006
67145
  init_jszip_ChlR43oI_es();
67007
67146
  init_xml_js_DLE8mr0n_es();
67008
- init_constants_DBKi0Amm_es();
67147
+ init_constants_Dw0kAsLd_es();
67009
67148
  buffer2 = {};
67010
67149
  base64Js2 = {};
67011
67150
  base64Js2.byteLength = byteLength2;
@@ -92869,9 +93008,9 @@ var init_remark_gfm_CQ3Jg4PR_es = __esm(() => {
92869
93008
  init_remark_gfm_z_sDF4ss_es();
92870
93009
  });
92871
93010
 
92872
- // ../../packages/superdoc/dist/chunks/src-DBQvqcRZ.es.js
92873
- var exports_src_DBQvqcRZ_es = {};
92874
- __export(exports_src_DBQvqcRZ_es, {
93011
+ // ../../packages/superdoc/dist/chunks/src-R57grOTY.es.js
93012
+ var exports_src_R57grOTY_es = {};
93013
+ __export(exports_src_R57grOTY_es, {
92875
93014
  zt: () => defineMark,
92876
93015
  z: () => cM,
92877
93016
  yt: () => removeAwarenessStates,
@@ -120496,6 +120635,24 @@ function imageNodeToRun({ node: node3, positions, sdtMetadata }) {
120496
120635
  }
120497
120636
  if (sdtMetadata)
120498
120637
  run2.sdt = sdtMetadata;
120638
+ const transformData = isPlainObject$2(attrs.transformData) ? attrs.transformData : undefined;
120639
+ if (transformData) {
120640
+ const rotation = typeof transformData.rotation === "number" ? transformData.rotation : undefined;
120641
+ if (rotation !== undefined)
120642
+ run2.rotation = rotation;
120643
+ const flipH = typeof transformData.horizontalFlip === "boolean" ? transformData.horizontalFlip : undefined;
120644
+ if (flipH !== undefined)
120645
+ run2.flipH = flipH;
120646
+ const flipV = typeof transformData.verticalFlip === "boolean" ? transformData.verticalFlip : undefined;
120647
+ if (flipV !== undefined)
120648
+ run2.flipV = flipV;
120649
+ }
120650
+ if (typeof attrs.gain === "string" || typeof attrs.gain === "number")
120651
+ run2.gain = attrs.gain;
120652
+ if (typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number")
120653
+ run2.blacklevel = attrs.blacklevel;
120654
+ if (typeof attrs.grayscale === "boolean")
120655
+ run2.grayscale = attrs.grayscale;
120499
120656
  return run2;
120500
120657
  }
120501
120658
  function isInlineImage(node3) {
@@ -120726,6 +120883,10 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
120726
120883
  const objectFit = isAllowedObjectFit(explicitObjectFit) ? explicitObjectFit : shouldCover ? "cover" : display === "inline" ? "scale-down" : isAnchor ? "contain" : "contain";
120727
120884
  const zIndexFromRelativeHeight = normalizeZIndex(attrs.originalAttributes);
120728
120885
  const zIndex = resolveFloatingZIndex(anchor?.behindDoc === true, zIndexFromRelativeHeight);
120886
+ const transformData = isPlainObject$1(attrs.transformData) ? attrs.transformData : undefined;
120887
+ const rotation = typeof transformData?.rotation === "number" ? transformData.rotation : undefined;
120888
+ const flipH = typeof transformData?.horizontalFlip === "boolean" ? transformData.horizontalFlip : undefined;
120889
+ const flipV = typeof transformData?.verticalFlip === "boolean" ? transformData.verticalFlip : undefined;
120729
120890
  return {
120730
120891
  kind: "image",
120731
120892
  id: nextBlockId("image"),
@@ -120743,7 +120904,11 @@ function imageNodeToBlock(node3, nextBlockId, positions, _trackedMeta, _trackedC
120743
120904
  ...zIndex !== undefined && { zIndex },
120744
120905
  attrs: attrsWithPm,
120745
120906
  gain: typeof attrs.gain === "string" || typeof attrs.gain === "number" ? attrs.gain : undefined,
120746
- blacklevel: typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number" ? attrs.blacklevel : undefined
120907
+ blacklevel: typeof attrs.blacklevel === "string" || typeof attrs.blacklevel === "number" ? attrs.blacklevel : undefined,
120908
+ grayscale: typeof attrs.grayscale === "boolean" ? attrs.grayscale : undefined,
120909
+ ...rotation !== undefined && { rotation },
120910
+ ...flipH !== undefined && { flipH },
120911
+ ...flipV !== undefined && { flipV }
120747
120912
  };
120748
120913
  }
120749
120914
  function handleImageNode2(node3, context) {
@@ -160047,7 +160212,28 @@ var Node$13 = class Node$14 {
160047
160212
  if (!trackedChangeId)
160048
160213
  return changes;
160049
160214
  return changes.filter((change) => change.id === trackedChangeId);
160050
- }, TrackChanges, getChangesByIdToResolve = (state, id2) => {
160215
+ }, TrackChanges, dedupeTrackedChangeRanges = (changes = []) => {
160216
+ const byKey = /* @__PURE__ */ new Map;
160217
+ changes.forEach((change) => {
160218
+ if (!change || typeof change.from !== "number" || typeof change.to !== "number")
160219
+ return;
160220
+ const type = change.mark?.type?.name || "";
160221
+ const id2 = change.mark?.attrs?.id || "";
160222
+ const key$1 = `${change.from}:${change.to}:${type}:${id2}`;
160223
+ if (!byKey.has(key$1))
160224
+ byKey.set(key$1, change);
160225
+ });
160226
+ return Array.from(byKey.values()).sort((left$1, right$1) => {
160227
+ if (left$1.from !== right$1.from)
160228
+ return left$1.from - right$1.from;
160229
+ return left$1.to - right$1.to;
160230
+ });
160231
+ }, getTrackedChangesByTouchedIds = (state, trackedChanges = []) => {
160232
+ const touchedIds = new Set(trackedChanges.map(({ mark: mark2 }) => mark2?.attrs?.id).filter(Boolean));
160233
+ if (!touchedIds.size)
160234
+ return trackedChanges;
160235
+ return Array.from(touchedIds).flatMap((id2) => getChangesByIdToResolve(state, id2) || []);
160236
+ }, getChangesByIdToResolve = (state, id2) => {
160051
160237
  const trackedChanges = getTrackChanges(state);
160052
160238
  const changeIndex = trackedChanges.findIndex(({ mark: mark2 }) => mark2.attrs.id === id2);
160053
160239
  if (changeIndex === -1)
@@ -162206,13 +162392,13 @@ var Node$13 = class Node$14 {
162206
162392
  trackedChanges: context.trackedChanges ?? []
162207
162393
  });
162208
162394
  }, _hoisted_1$6, _hoisted_2$1, _hoisted_3, _hoisted_4, ContextMenu_default, _hoisted_1$5, BasicUpload_default, _hoisted_1$4, MIN_WIDTH = 200, PPI = 96, alignment = "flex-end", Ruler_default, GenericPopover_default, _hoisted_1$3, RESIZE_HANDLE_WIDTH_PX = 9, RESIZE_HANDLE_OFFSET_PX = 4, DRAG_OVERLAY_EXTENSION_PX = 1000, MIN_DRAG_OVERLAY_WIDTH_PX = 2000, THROTTLE_INTERVAL_MS = 16, MIN_RESIZE_DELTA_PX = 1, TableResizeOverlay_default, _hoisted_1$2, OVERLAY_EXPANSION_PX = 2000, RESIZE_HANDLE_SIZE_PX = 12, MOUSE_MOVE_THROTTLE_MS = 16, DIMENSION_CHANGE_THRESHOLD_PX = 1, Z_INDEX_OVERLAY = 10, Z_INDEX_HANDLE = 15, Z_INDEX_GUIDELINE = 20, ImageResizeOverlay_default, LINK_CLICK_DEBOUNCE_MS = 300, CURSOR_UPDATE_TIMEOUT_MS = 10, LinkClickHandler_default, _hoisted_1$1, _hoisted_2, DOCX2 = "application/vnd.openxmlformats-officedocument.wordprocessingml.document", TABLE_RESIZE_HOVER_THRESHOLD = 8, TABLE_RESIZE_THROTTLE_MS = 16, SuperEditor_default, _hoisted_1, SuperInput_default, SlashMenu, Extensions;
162209
- var init_src_DBQvqcRZ_es = __esm(() => {
162395
+ var init_src_R57grOTY_es = __esm(() => {
162210
162396
  init_rolldown_runtime_B2q5OVn9_es();
162211
- init_SuperConverter_D7fmxDmw_es();
162397
+ init_SuperConverter_CRrxAa8F_es();
162212
162398
  init_jszip_ChlR43oI_es();
162213
162399
  init_uuid_2IzDu5nl_es();
162214
- init_constants_DBKi0Amm_es();
162215
- init_DocxZipper_CXjNiywL_es();
162400
+ init_constants_Dw0kAsLd_es();
162401
+ init_DocxZipper_B9Uo1uiZ_es();
162216
162402
  init_vue_UXsVEdB5_es();
162217
162403
  init__plugin_vue_export_helper_CUZ1eWFO_es();
162218
162404
  init_eventemitter3_U_DLl_Mg_es();
@@ -164907,10 +165093,6 @@ ${err.toString()}`);
164907
165093
  };
164908
165094
  shouldUpdate = true;
164909
165095
  editor.emit("commentsUpdate", update);
164910
- const { tr: newTr } = editor.view.state;
164911
- const { dispatch } = editor.view;
164912
- newTr.setMeta(CommentsPluginKey, { type: "force" });
164913
- dispatch(newTr);
164914
165096
  }
164915
165097
  }
164916
165098
  return pluginState;
@@ -180330,7 +180512,29 @@ function print() { __p += __j.call(arguments, '') }
180330
180512
  img2.style.objectPosition = "left top";
180331
180513
  applyImageClipPath(img2, resolveBlockClipPath(block), { clipContainer: fragmentEl });
180332
180514
  img2.style.display = block.display === "inline" ? "inline-block" : "block";
180515
+ const transforms = [];
180516
+ if (block.rotation != null && block.rotation !== 0) {
180517
+ const angleRad = block.rotation * Math.PI / 180;
180518
+ const w = block.width ?? fragment.width;
180519
+ const h$2 = block.height ?? fragment.height;
180520
+ const cosA = Math.cos(angleRad);
180521
+ const sinA = Math.sin(angleRad);
180522
+ const newTopLeftX = w / 2 * (1 - cosA) + h$2 / 2 * sinA;
180523
+ const newTopLeftY = w / 2 * sinA + h$2 / 2 * (1 - cosA);
180524
+ transforms.push(`translate(${-newTopLeftX}px, ${-newTopLeftY}px)`);
180525
+ transforms.push(`rotate(${block.rotation}deg)`);
180526
+ }
180527
+ if (block.flipH)
180528
+ transforms.push("scaleX(-1)");
180529
+ if (block.flipV)
180530
+ transforms.push("scaleY(-1)");
180531
+ if (transforms.length > 0) {
180532
+ img2.style.transform = transforms.join(" ");
180533
+ img2.style.transformOrigin = "center";
180534
+ }
180333
180535
  const filters = [];
180536
+ if (block.grayscale)
180537
+ filters.push("grayscale(100%)");
180334
180538
  if (block.gain != null || block.blacklevel != null) {
180335
180539
  if (block.gain && typeof block.gain === "string" && block.gain.endsWith("f")) {
180336
180540
  const contrast = Math.max(0, parseInt(block.gain) / 65536) * (2 / 3);
@@ -180342,9 +180546,9 @@ function print() { __p += __j.call(arguments, '') }
180342
180546
  if (brightness > 0)
180343
180547
  filters.push(`brightness(${brightness})`);
180344
180548
  }
180345
- if (filters.length > 0)
180346
- img2.style.filter = filters.join(" ");
180347
180549
  }
180550
+ if (filters.length > 0)
180551
+ img2.style.filter = filters.join(" ");
180348
180552
  fragmentEl.appendChild(img2);
180349
180553
  return fragmentEl;
180350
180554
  } catch (error) {
@@ -181201,6 +181405,43 @@ function print() { __p += __j.call(arguments, '') }
181201
181405
  img2.style.position = "relative";
181202
181406
  img2.style.zIndex = "1";
181203
181407
  }
181408
+ const transforms = [];
181409
+ if (run2.rotation != null && run2.rotation !== 0) {
181410
+ const angleRad = run2.rotation * Math.PI / 180;
181411
+ const w = run2.width;
181412
+ const h$2 = run2.height;
181413
+ const cosA = Math.cos(angleRad);
181414
+ const sinA = Math.sin(angleRad);
181415
+ const newTopLeftX = w / 2 * (1 - cosA) + h$2 / 2 * sinA;
181416
+ const newTopLeftY = w / 2 * sinA + h$2 / 2 * (1 - cosA);
181417
+ transforms.push(`translate(${-newTopLeftX}px, ${-newTopLeftY}px)`);
181418
+ transforms.push(`rotate(${run2.rotation}deg)`);
181419
+ }
181420
+ if (run2.flipH)
181421
+ transforms.push("scaleX(-1)");
181422
+ if (run2.flipV)
181423
+ transforms.push("scaleY(-1)");
181424
+ if (transforms.length > 0) {
181425
+ img2.style.transform = transforms.join(" ");
181426
+ img2.style.transformOrigin = "center";
181427
+ }
181428
+ const filters = [];
181429
+ if (run2.grayscale)
181430
+ filters.push("grayscale(100%)");
181431
+ if (run2.gain != null || run2.blacklevel != null) {
181432
+ if (run2.gain && typeof run2.gain === "string" && run2.gain.endsWith("f")) {
181433
+ const contrast = Math.max(0, parseInt(run2.gain) / 65536) * (2 / 3);
181434
+ if (contrast > 0)
181435
+ filters.push(`contrast(${contrast})`);
181436
+ }
181437
+ if (run2.blacklevel && typeof run2.blacklevel === "string" && run2.blacklevel.endsWith("f")) {
181438
+ const brightness = Math.max(0, 1 + parseInt(run2.blacklevel) / 327 / 100) * 1.3;
181439
+ if (brightness > 0)
181440
+ filters.push(`brightness(${brightness})`);
181441
+ }
181442
+ }
181443
+ if (filters.length > 0)
181444
+ img2.style.filter = filters.join(" ");
181204
181445
  assertPmPositions(run2, "inline image run");
181205
181446
  if (useWrapper) {
181206
181447
  const wrapper = this.doc.createElement("span");
@@ -189650,6 +189891,18 @@ function print() { __p += __j.call(arguments, '') }
189650
189891
  return { style: `transform: ${style$1};` };
189651
189892
  }
189652
189893
  },
189894
+ grayscale: {
189895
+ default: false,
189896
+ rendered: false
189897
+ },
189898
+ gain: {
189899
+ default: null,
189900
+ rendered: false
189901
+ },
189902
+ blacklevel: {
189903
+ default: null,
189904
+ rendered: false
189905
+ },
189653
189906
  simplePos: { rendered: false },
189654
189907
  extension: { rendered: false },
189655
189908
  originalExtension: { rendered: false },
@@ -192020,50 +192273,78 @@ function print() { __p += __j.call(arguments, '') }
192020
192273
  return true;
192021
192274
  },
192022
192275
  rejectTrackedChangesBetween: (from$12, to) => ({ state, dispatch, editor }) => {
192276
+ const trackedChangesInSelection = collectTrackedChanges({
192277
+ state,
192278
+ from: from$12,
192279
+ to
192280
+ });
192281
+ const trackedChangesById = getTrackedChangesByTouchedIds(state, trackedChangesInSelection);
192282
+ const trackedChangesWithoutId = trackedChangesInSelection.filter(({ mark: mark2 }) => !mark2?.attrs?.id);
192283
+ const trackedChanges = dedupeTrackedChangeRanges([...trackedChangesById, ...trackedChangesWithoutId]);
192023
192284
  if (!isTrackedChangeActionAllowed({
192024
192285
  editor,
192025
192286
  action: "reject",
192026
- trackedChanges: collectTrackedChanges({
192027
- state,
192028
- from: from$12,
192029
- to
192030
- })
192287
+ trackedChanges
192031
192288
  }))
192032
192289
  return false;
192033
192290
  const { tr, doc: doc$2 } = state;
192291
+ const rejectedChangeIds = /* @__PURE__ */ new Set;
192034
192292
  tr.setMeta("inputType", "acceptReject");
192035
192293
  const map$22 = new Mapping;
192036
- doc$2.nodesBetween(from$12, to, (node3, pos) => {
192037
- if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackDelete")) {
192038
- const deletionMark = node3.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName);
192039
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), deletionMark));
192040
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackInsert")) {
192041
- const deletionStep = new ReplaceStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), Slice.empty);
192042
- tr.step(deletionStep);
192043
- map$22.appendMap(deletionStep.getMap());
192044
- } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackFormat")) {
192045
- const formatChangeMark = node3.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
192046
- formatChangeMark.attrs.before.forEach((oldMark) => {
192047
- tr.step(new AddMarkStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), state.schema.marks[oldMark.type].create(oldMark.attrs)));
192048
- });
192049
- formatChangeMark.attrs.after.forEach((newMark) => {
192050
- const mappedFrom = map$22.map(Math.max(pos, from$12));
192051
- const mappedTo = map$22.map(Math.min(pos + node3.nodeSize, to));
192052
- const liveMark = findMarkInRangeBySnapshot({
192053
- doc: tr.doc,
192054
- from: mappedFrom,
192055
- to: mappedTo,
192056
- snapshot: newMark
192294
+ trackedChanges.forEach(({ from: rangeFrom, to: rangeTo }) => {
192295
+ doc$2.nodesBetween(rangeFrom, rangeTo, (node3, pos) => {
192296
+ if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackDelete")) {
192297
+ const deletionMark = node3.marks.find((mark2) => mark2.type.name === TrackDeleteMarkName);
192298
+ if (deletionMark?.attrs?.id)
192299
+ rejectedChangeIds.add(deletionMark.attrs.id);
192300
+ tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), deletionMark));
192301
+ } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackInsert")) {
192302
+ const insertionMark = node3.marks.find((mark2) => mark2.type.name === TrackInsertMarkName);
192303
+ if (insertionMark?.attrs?.id)
192304
+ rejectedChangeIds.add(insertionMark.attrs.id);
192305
+ const deletionStep = new ReplaceStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), Slice.empty);
192306
+ tr.step(deletionStep);
192307
+ map$22.appendMap(deletionStep.getMap());
192308
+ } else if (node3.marks && node3.marks.find((mark2) => mark2.type.name === "trackFormat")) {
192309
+ const formatChangeMark = node3.marks.find((mark2) => mark2.type.name === TrackFormatMarkName);
192310
+ if (formatChangeMark?.attrs?.id)
192311
+ rejectedChangeIds.add(formatChangeMark.attrs.id);
192312
+ formatChangeMark.attrs.before.forEach((oldMark) => {
192313
+ tr.step(new AddMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), state.schema.marks[oldMark.type].create(oldMark.attrs)));
192057
192314
  });
192058
- if (!liveMark)
192059
- return;
192060
- tr.step(new RemoveMarkStep(mappedFrom, mappedTo, liveMark));
192061
- });
192062
- tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, from$12)), map$22.map(Math.min(pos + node3.nodeSize, to)), formatChangeMark));
192063
- }
192315
+ formatChangeMark.attrs.after.forEach((newMark) => {
192316
+ const mappedFrom = map$22.map(Math.max(pos, rangeFrom));
192317
+ const mappedTo = map$22.map(Math.min(pos + node3.nodeSize, rangeTo));
192318
+ const liveMark = findMarkInRangeBySnapshot({
192319
+ doc: tr.doc,
192320
+ from: mappedFrom,
192321
+ to: mappedTo,
192322
+ snapshot: newMark
192323
+ });
192324
+ if (!liveMark)
192325
+ return;
192326
+ tr.step(new RemoveMarkStep(mappedFrom, mappedTo, liveMark));
192327
+ });
192328
+ tr.step(new RemoveMarkStep(map$22.map(Math.max(pos, rangeFrom)), map$22.map(Math.min(pos + node3.nodeSize, rangeTo)), formatChangeMark));
192329
+ }
192330
+ });
192064
192331
  });
192065
- if (tr.steps.length)
192332
+ if (tr.steps.length) {
192066
192333
  dispatch(tr);
192334
+ if (editor?.emit && rejectedChangeIds.size) {
192335
+ const resolvedByEmail = editor.options?.user?.email;
192336
+ const resolvedByName = editor.options?.user?.name;
192337
+ rejectedChangeIds.forEach((changeId) => {
192338
+ editor.emit("commentsUpdate", {
192339
+ type: "trackedChange",
192340
+ event: "resolve",
192341
+ changeId,
192342
+ resolvedByEmail,
192343
+ resolvedByName
192344
+ });
192345
+ });
192346
+ }
192347
+ }
192067
192348
  return true;
192068
192349
  },
192069
192350
  acceptTrackedChange: ({ trackedChange }) => ({ commands: commands$1 }) => {
@@ -195626,8 +195907,8 @@ function print() { __p += __j.call(arguments, '') }
195626
195907
  return isObjectLike_default(value) && hasOwnProperty$8.call(value, "callee") && !propertyIsEnumerable$1.call(value, "callee");
195627
195908
  };
195628
195909
  stubFalse_default = stubFalse;
195629
- freeExports$2 = typeof exports_src_DBQvqcRZ_es == "object" && exports_src_DBQvqcRZ_es && !exports_src_DBQvqcRZ_es.nodeType && exports_src_DBQvqcRZ_es;
195630
- freeModule$2 = freeExports$2 && typeof module_src_DBQvqcRZ_es == "object" && module_src_DBQvqcRZ_es && !module_src_DBQvqcRZ_es.nodeType && module_src_DBQvqcRZ_es;
195910
+ freeExports$2 = typeof exports_src_R57grOTY_es == "object" && exports_src_R57grOTY_es && !exports_src_R57grOTY_es.nodeType && exports_src_R57grOTY_es;
195911
+ freeModule$2 = freeExports$2 && typeof module_src_R57grOTY_es == "object" && module_src_R57grOTY_es && !module_src_R57grOTY_es.nodeType && module_src_R57grOTY_es;
195631
195912
  Buffer$1 = freeModule$2 && freeModule$2.exports === freeExports$2 ? _root_default.Buffer : undefined;
195632
195913
  isBuffer_default = (Buffer$1 ? Buffer$1.isBuffer : undefined) || stubFalse_default;
195633
195914
  typedArrayTags = {};
@@ -195635,8 +195916,8 @@ function print() { __p += __j.call(arguments, '') }
195635
195916
  typedArrayTags[argsTag$1] = typedArrayTags[arrayTag$1] = typedArrayTags[arrayBufferTag$1] = typedArrayTags[boolTag$1] = typedArrayTags[dataViewTag$2] = typedArrayTags[dateTag$1] = typedArrayTags[errorTag$1] = typedArrayTags[funcTag] = typedArrayTags[mapTag$2] = typedArrayTags[numberTag$1] = typedArrayTags[objectTag$3] = typedArrayTags[regexpTag$1] = typedArrayTags[setTag$2] = typedArrayTags[stringTag$1] = typedArrayTags[weakMapTag$1] = false;
195636
195917
  _baseIsTypedArray_default = baseIsTypedArray;
195637
195918
  _baseUnary_default = baseUnary;
195638
- freeExports$1 = typeof exports_src_DBQvqcRZ_es == "object" && exports_src_DBQvqcRZ_es && !exports_src_DBQvqcRZ_es.nodeType && exports_src_DBQvqcRZ_es;
195639
- freeModule$1 = freeExports$1 && typeof module_src_DBQvqcRZ_es == "object" && module_src_DBQvqcRZ_es && !module_src_DBQvqcRZ_es.nodeType && module_src_DBQvqcRZ_es;
195919
+ freeExports$1 = typeof exports_src_R57grOTY_es == "object" && exports_src_R57grOTY_es && !exports_src_R57grOTY_es.nodeType && exports_src_R57grOTY_es;
195920
+ freeModule$1 = freeExports$1 && typeof module_src_R57grOTY_es == "object" && module_src_R57grOTY_es && !module_src_R57grOTY_es.nodeType && module_src_R57grOTY_es;
195640
195921
  freeProcess = freeModule$1 && freeModule$1.exports === freeExports$1 && _freeGlobal_default.process;
195641
195922
  _nodeUtil_default = function() {
195642
195923
  try {
@@ -195741,8 +196022,8 @@ function print() { __p += __j.call(arguments, '') }
195741
196022
  Stack.prototype.has = _stackHas_default;
195742
196023
  Stack.prototype.set = _stackSet_default;
195743
196024
  _Stack_default = Stack;
195744
- freeExports = typeof exports_src_DBQvqcRZ_es == "object" && exports_src_DBQvqcRZ_es && !exports_src_DBQvqcRZ_es.nodeType && exports_src_DBQvqcRZ_es;
195745
- freeModule = freeExports && typeof module_src_DBQvqcRZ_es == "object" && module_src_DBQvqcRZ_es && !module_src_DBQvqcRZ_es.nodeType && module_src_DBQvqcRZ_es;
196025
+ freeExports = typeof exports_src_R57grOTY_es == "object" && exports_src_R57grOTY_es && !exports_src_R57grOTY_es.nodeType && exports_src_R57grOTY_es;
196026
+ freeModule = freeExports && typeof module_src_R57grOTY_es == "object" && module_src_R57grOTY_es && !module_src_R57grOTY_es.nodeType && module_src_R57grOTY_es;
195746
196027
  Buffer4 = freeModule && freeModule.exports === freeExports ? _root_default.Buffer : undefined;
195747
196028
  allocUnsafe = Buffer4 ? Buffer4.allocUnsafe : undefined;
195748
196029
  _cloneBuffer_default = cloneBuffer;
@@ -203394,13 +203675,13 @@ var init_zipper_Cnk_HjM2_es = __esm(() => {
203394
203675
 
203395
203676
  // ../../packages/superdoc/dist/super-editor.es.js
203396
203677
  var init_super_editor_es = __esm(() => {
203397
- init_src_DBQvqcRZ_es();
203398
- init_SuperConverter_D7fmxDmw_es();
203678
+ init_src_R57grOTY_es();
203679
+ init_SuperConverter_CRrxAa8F_es();
203399
203680
  init_jszip_ChlR43oI_es();
203400
203681
  init_xml_js_DLE8mr0n_es();
203401
- init_constants_DBKi0Amm_es();
203682
+ init_constants_Dw0kAsLd_es();
203402
203683
  init_unified_BRHLwnjP_es();
203403
- init_DocxZipper_CXjNiywL_es();
203684
+ init_DocxZipper_B9Uo1uiZ_es();
203404
203685
  init_vue_UXsVEdB5_es();
203405
203686
  init_eventemitter3_U_DLl_Mg_es();
203406
203687
  init_zipper_Cnk_HjM2_es();
@@ -237240,6 +237521,206 @@ var init_Blob = __esm(() => {
237240
237521
  init_Helper();
237241
237522
  });
237242
237523
 
237524
+ // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/rtfjs/emfjs/Bitmap.ts
237525
+ class BitmapCoreHeader2 {
237526
+ width;
237527
+ height;
237528
+ planes;
237529
+ bitcount;
237530
+ constructor(reader, skipsize) {
237531
+ if (skipsize) {
237532
+ reader.skip(4);
237533
+ }
237534
+ this.width = reader.readUint16();
237535
+ this.height = reader.readUint16();
237536
+ this.planes = reader.readUint16();
237537
+ this.bitcount = reader.readUint16();
237538
+ }
237539
+ colors() {
237540
+ return this.bitcount <= 8 ? 1 << this.bitcount : 0;
237541
+ }
237542
+ }
237543
+
237544
+ class BitmapInfoHeader2 {
237545
+ width;
237546
+ height;
237547
+ planes;
237548
+ bitcount;
237549
+ compression;
237550
+ sizeimage;
237551
+ xpelspermeter;
237552
+ ypelspermeter;
237553
+ clrused;
237554
+ clrimportant;
237555
+ constructor(reader, skipsize) {
237556
+ if (skipsize) {
237557
+ reader.skip(4);
237558
+ }
237559
+ this.width = reader.readInt32();
237560
+ this.height = reader.readInt32();
237561
+ this.planes = reader.readUint16();
237562
+ this.bitcount = reader.readUint16();
237563
+ this.compression = reader.readUint32();
237564
+ this.sizeimage = reader.readUint32();
237565
+ this.xpelspermeter = reader.readInt32();
237566
+ this.ypelspermeter = reader.readInt32();
237567
+ this.clrused = reader.readUint32();
237568
+ this.clrimportant = reader.readUint32();
237569
+ }
237570
+ colors() {
237571
+ if (this.clrused !== 0) {
237572
+ return this.clrused < 256 ? this.clrused : 256;
237573
+ } else {
237574
+ return this.bitcount > 8 ? 0 : 1 << this.bitcount;
237575
+ }
237576
+ }
237577
+ }
237578
+
237579
+ class BitmapInfo2 {
237580
+ _usergb;
237581
+ _infosize;
237582
+ _header;
237583
+ constructor(reader, usergb) {
237584
+ this._usergb = usergb;
237585
+ const hdrsize = reader.readUint32();
237586
+ this._infosize = hdrsize;
237587
+ if (hdrsize === Helper2.GDI.BITMAPCOREHEADER_SIZE) {
237588
+ this._header = new BitmapCoreHeader2(reader, false);
237589
+ this._infosize += this._header.colors() * (usergb ? 3 : 2);
237590
+ } else {
237591
+ this._header = new BitmapInfoHeader2(reader, false);
237592
+ const masks = this._header.compression === Helper2.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
237593
+ if (hdrsize <= Helper2.GDI.BITMAPINFOHEADER_SIZE + masks * 4) {
237594
+ this._infosize = Helper2.GDI.BITMAPINFOHEADER_SIZE + masks * 4;
237595
+ }
237596
+ this._infosize += this._header.colors() * (usergb ? 4 : 2);
237597
+ }
237598
+ }
237599
+ getWidth() {
237600
+ return this._header.width;
237601
+ }
237602
+ getHeight() {
237603
+ return Math.abs(this._header.height);
237604
+ }
237605
+ infosize() {
237606
+ return this._infosize;
237607
+ }
237608
+ header() {
237609
+ return this._header;
237610
+ }
237611
+ }
237612
+
237613
+ class DIBitmap2 {
237614
+ _reader;
237615
+ _offset;
237616
+ _location;
237617
+ _info;
237618
+ constructor(reader, bitmapInfo) {
237619
+ this._reader = reader;
237620
+ this._offset = reader.pos;
237621
+ this._location = bitmapInfo;
237622
+ this._info = new BitmapInfo2(reader, true);
237623
+ }
237624
+ getWidth() {
237625
+ return this._info.getWidth();
237626
+ }
237627
+ getHeight() {
237628
+ return this._info.getHeight();
237629
+ }
237630
+ totalSize() {
237631
+ return this._location.header.size + this._location.data.size;
237632
+ }
237633
+ makeBitmapFileHeader() {
237634
+ const buf = new ArrayBuffer(14);
237635
+ const view = new Uint8Array(buf);
237636
+ view[0] = 66;
237637
+ view[1] = 77;
237638
+ Helper2._writeUint32Val(view, 2, this.totalSize() + 14);
237639
+ Helper2._writeUint32Val(view, 10, this._info.infosize() + 14);
237640
+ return Helper2._blobToBinary(view);
237641
+ }
237642
+ convertToPNG(bitmapData, width, height, hasAlpha) {
237643
+ const canvas2 = document.createElement("canvas");
237644
+ canvas2.width = width;
237645
+ canvas2.height = Math.abs(height);
237646
+ const ctx2 = canvas2.getContext("2d");
237647
+ if (!ctx2) {
237648
+ throw new Error("Unable to get canvas context for PNG conversion");
237649
+ }
237650
+ const imageData = ctx2.createImageData(width, Math.abs(height));
237651
+ const pixels = imageData.data;
237652
+ const rowSize = width * 32 + 31 >>> 5 << 2;
237653
+ const absHeight = Math.abs(height);
237654
+ const topDown = height < 0;
237655
+ let alphaUsed = false;
237656
+ if (hasAlpha) {
237657
+ for (let y2 = 0;y2 < absHeight && !alphaUsed; y2++) {
237658
+ const srcY = topDown ? y2 : absHeight - 1 - y2;
237659
+ for (let x = 0;x < width && !alphaUsed; x++) {
237660
+ const srcOffset = srcY * rowSize + x * 4;
237661
+ if (bitmapData[srcOffset + 3] > 0) {
237662
+ alphaUsed = true;
237663
+ }
237664
+ }
237665
+ }
237666
+ }
237667
+ for (let y2 = 0;y2 < absHeight; y2++) {
237668
+ const srcY = topDown ? y2 : absHeight - 1 - y2;
237669
+ for (let x = 0;x < width; x++) {
237670
+ const srcOffset = srcY * rowSize + x * 4;
237671
+ const dstOffset = (y2 * width + x) * 4;
237672
+ pixels[dstOffset] = bitmapData[srcOffset + 2];
237673
+ pixels[dstOffset + 1] = bitmapData[srcOffset + 1];
237674
+ pixels[dstOffset + 2] = bitmapData[srcOffset];
237675
+ pixels[dstOffset + 3] = alphaUsed ? bitmapData[srcOffset + 3] : 255;
237676
+ }
237677
+ }
237678
+ ctx2.putImageData(imageData, 0, 0);
237679
+ return canvas2.toDataURL("image/png");
237680
+ }
237681
+ base64ref() {
237682
+ const prevpos = this._reader.pos;
237683
+ this._reader.seek(this._offset);
237684
+ const header = this._info.header();
237685
+ if (header instanceof BitmapInfoHeader2 && header.compression != null) {
237686
+ switch (header.compression) {
237687
+ case Helper2.GDI.BitmapCompression.BI_JPEG:
237688
+ this._reader.seek(this._location.data.off);
237689
+ const jpegData = "data:image/jpeg;base64," + btoa(this._reader.readBinary(this._location.data.size));
237690
+ this._reader.seek(prevpos);
237691
+ return jpegData;
237692
+ case Helper2.GDI.BitmapCompression.BI_PNG:
237693
+ this._reader.seek(this._location.data.off);
237694
+ const pngData = "data:image/png;base64," + btoa(this._reader.readBinary(this._location.data.size));
237695
+ this._reader.seek(prevpos);
237696
+ return pngData;
237697
+ }
237698
+ }
237699
+ if (header instanceof BitmapInfoHeader2 && header.bitcount === 32) {
237700
+ this._reader.seek(this._location.data.off);
237701
+ const bitmapBytes = new Uint8Array(this._location.data.size);
237702
+ const bitmapData = this._reader.readBinary(this._location.data.size);
237703
+ for (let i4 = 0;i4 < this._location.data.size; i4++) {
237704
+ bitmapBytes[i4] = bitmapData.charCodeAt(i4);
237705
+ }
237706
+ const pngDataUrl = this.convertToPNG(bitmapBytes, header.width, header.height, true);
237707
+ this._reader.seek(prevpos);
237708
+ return pngDataUrl;
237709
+ }
237710
+ let data = this.makeBitmapFileHeader();
237711
+ this._reader.seek(this._location.header.off);
237712
+ data += this._reader.readBinary(this._location.header.size);
237713
+ this._reader.seek(this._location.data.off);
237714
+ data += this._reader.readBinary(this._location.data.size);
237715
+ const ref3 = "data:image/bmp;base64," + btoa(data);
237716
+ this._reader.seek(prevpos);
237717
+ return ref3;
237718
+ }
237719
+ }
237720
+ var init_Bitmap = __esm(() => {
237721
+ init_Helper();
237722
+ });
237723
+
237243
237724
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/rtfjs/emfjs/Primitives.ts
237244
237725
  class PointS3 {
237245
237726
  x;
@@ -237715,162 +238196,6 @@ var init_Region = __esm(() => {
237715
238196
  };
237716
238197
  });
237717
238198
 
237718
- // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/rtfjs/emfjs/Bitmap.ts
237719
- class BitmapCoreHeader2 {
237720
- width;
237721
- height;
237722
- planes;
237723
- bitcount;
237724
- constructor(reader, skipsize) {
237725
- if (skipsize) {
237726
- reader.skip(4);
237727
- }
237728
- this.width = reader.readUint16();
237729
- this.height = reader.readUint16();
237730
- this.planes = reader.readUint16();
237731
- this.bitcount = reader.readUint16();
237732
- }
237733
- colors() {
237734
- return this.bitcount <= 8 ? 1 << this.bitcount : 0;
237735
- }
237736
- }
237737
-
237738
- class BitmapInfoHeader2 {
237739
- width;
237740
- height;
237741
- planes;
237742
- bitcount;
237743
- compression;
237744
- sizeimage;
237745
- xpelspermeter;
237746
- ypelspermeter;
237747
- clrused;
237748
- clrimportant;
237749
- constructor(reader, skipsize) {
237750
- if (skipsize) {
237751
- reader.skip(4);
237752
- }
237753
- this.width = reader.readInt32();
237754
- this.height = reader.readInt32();
237755
- this.planes = reader.readUint16();
237756
- this.bitcount = reader.readUint16();
237757
- this.compression = reader.readUint32();
237758
- this.sizeimage = reader.readUint32();
237759
- this.xpelspermeter = reader.readInt32();
237760
- this.ypelspermeter = reader.readInt32();
237761
- this.clrused = reader.readUint32();
237762
- this.clrimportant = reader.readUint32();
237763
- }
237764
- colors() {
237765
- if (this.clrused !== 0) {
237766
- return this.clrused < 256 ? this.clrused : 256;
237767
- } else {
237768
- return this.bitcount > 8 ? 0 : 1 << this.bitcount;
237769
- }
237770
- }
237771
- }
237772
-
237773
- class BitmapInfo2 {
237774
- _usergb;
237775
- _infosize;
237776
- _header;
237777
- constructor(reader, usergb) {
237778
- this._usergb = usergb;
237779
- const hdrsize = reader.readUint32();
237780
- this._infosize = hdrsize;
237781
- if (hdrsize === Helper2.GDI.BITMAPCOREHEADER_SIZE) {
237782
- this._header = new BitmapCoreHeader2(reader, false);
237783
- this._infosize += this._header.colors() * (usergb ? 3 : 2);
237784
- } else {
237785
- this._header = new BitmapInfoHeader2(reader, false);
237786
- const masks = this._header.compression === Helper2.GDI.BitmapCompression.BI_BITFIELDS ? 3 : 0;
237787
- if (hdrsize <= Helper2.GDI.BITMAPINFOHEADER_SIZE + masks * 4) {
237788
- this._infosize = Helper2.GDI.BITMAPINFOHEADER_SIZE + masks * 4;
237789
- }
237790
- this._infosize += this._header.colors() * (usergb ? 4 : 2);
237791
- }
237792
- }
237793
- getWidth() {
237794
- return this._header.width;
237795
- }
237796
- getHeight() {
237797
- return Math.abs(this._header.height);
237798
- }
237799
- infosize() {
237800
- return this._infosize;
237801
- }
237802
- header() {
237803
- return this._header;
237804
- }
237805
- }
237806
-
237807
- class DIBitmap2 {
237808
- _reader;
237809
- _offset;
237810
- _location;
237811
- _info;
237812
- constructor(reader, bitmapInfo) {
237813
- this._reader = reader;
237814
- this._offset = reader.pos;
237815
- this._location = bitmapInfo;
237816
- this._info = new BitmapInfo2(reader, true);
237817
- }
237818
- getWidth() {
237819
- return this._info.getWidth();
237820
- }
237821
- getHeight() {
237822
- return this._info.getHeight();
237823
- }
237824
- totalSize() {
237825
- return this._location.header.size + this._location.data.size;
237826
- }
237827
- makeBitmapFileHeader() {
237828
- const buf = new ArrayBuffer(14);
237829
- const view = new Uint8Array(buf);
237830
- view[0] = 66;
237831
- view[1] = 77;
237832
- Helper2._writeUint32Val(view, 2, this.totalSize() + 14);
237833
- Helper2._writeUint32Val(view, 10, this._info.infosize() + 14);
237834
- return Helper2._blobToBinary(view);
237835
- }
237836
- base64ref() {
237837
- const prevpos = this._reader.pos;
237838
- this._reader.seek(this._offset);
237839
- let mime = "image/bmp";
237840
- const header = this._info.header();
237841
- let data;
237842
- if (header instanceof BitmapInfoHeader2 && header.compression != null) {
237843
- switch (header.compression) {
237844
- case Helper2.GDI.BitmapCompression.BI_JPEG:
237845
- mime = "data:image/jpeg";
237846
- break;
237847
- case Helper2.GDI.BitmapCompression.BI_PNG:
237848
- mime = "data:image/png";
237849
- break;
237850
- default:
237851
- data = this.makeBitmapFileHeader();
237852
- break;
237853
- }
237854
- } else {
237855
- data = this.makeBitmapFileHeader();
237856
- }
237857
- this._reader.seek(this._location.header.offset);
237858
- if (data != null) {
237859
- data += this._reader.readBinary(this._location.header.size);
237860
- } else {
237861
- data = this._reader.readBinary(this._location.header.size);
237862
- }
237863
- this._reader.seek(this._location.data.offset);
237864
- data += this._reader.readBinary(this._location.data.size);
237865
- const ref3 = "data:" + mime + ";base64," + btoa(data);
237866
- this._reader.seek(prevpos);
237867
- return ref3;
237868
- }
237869
- }
237870
- var init_Bitmap = __esm(() => {
237871
- init_Helper();
237872
- });
237873
-
237874
238199
  // ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/rtfjs/emfjs/Style.ts
237875
238200
  class ColorRef3 {
237876
238201
  r;
@@ -238154,6 +238479,9 @@ class EmfHeader2 {
238154
238479
  }
238155
238480
  }
238156
238481
  }
238482
+ getBounds() {
238483
+ return this.bounds;
238484
+ }
238157
238485
  toString() {
238158
238486
  return "{bounds: " + this.bounds.toString() + ", frame: " + this.frame.toString() + ", description: " + this.description + "}";
238159
238487
  }
@@ -238269,11 +238597,11 @@ class EMFRecords2 {
238269
238597
  const cbBits = reader.readUint32();
238270
238598
  const pen = new Pen3(reader, {
238271
238599
  header: {
238272
- off: offBmi,
238600
+ off: curpos + offBmi,
238273
238601
  size: cbBmi
238274
238602
  },
238275
238603
  data: {
238276
- off: offBits,
238604
+ off: curpos + offBits,
238277
238605
  size: cbBits
238278
238606
  }
238279
238607
  });
@@ -238519,6 +238847,37 @@ class EMFRecords2 {
238519
238847
  });
238520
238848
  break;
238521
238849
  }
238850
+ case Helper2.GDI.RecordType.EMR_STRETCHDIBITS: {
238851
+ const bounds = new RectL3(reader);
238852
+ const xDest = reader.readInt32();
238853
+ const yDest = reader.readInt32();
238854
+ const xSrc = reader.readInt32();
238855
+ const ySrc = reader.readInt32();
238856
+ const cxSrc = reader.readInt32();
238857
+ const cySrc = reader.readInt32();
238858
+ const offBmiSrc = reader.readUint32();
238859
+ const cbBmiSrc = reader.readUint32();
238860
+ const offBitsSrc = reader.readUint32();
238861
+ const cbBitsSrc = reader.readUint32();
238862
+ const iUsageSrc = reader.readUint32();
238863
+ const dwRop = reader.readUint32();
238864
+ const cxDest = reader.readInt32();
238865
+ const cyDest = reader.readInt32();
238866
+ const dib = new DIBitmap2(reader, {
238867
+ header: {
238868
+ off: curpos + offBmiSrc,
238869
+ size: cbBmiSrc
238870
+ },
238871
+ data: {
238872
+ off: curpos + offBitsSrc,
238873
+ size: cbBitsSrc
238874
+ }
238875
+ });
238876
+ this._records.push((gdi) => {
238877
+ gdi.stretchDibBits(xSrc, ySrc, cxSrc, cySrc, xDest, yDest, cxDest, cyDest, dwRop, iUsageSrc, dib);
238878
+ });
238879
+ break;
238880
+ }
238522
238881
  case Helper2.GDI.RecordType.EMR_POLYLINE:
238523
238882
  case Helper2.GDI.RecordType.EMR_POLYLINETO:
238524
238883
  case Helper2.GDI.RecordType.EMR_POLYPOLYLINE:
@@ -238561,7 +238920,6 @@ class EMFRecords2 {
238561
238920
  case Helper2.GDI.RecordType.EMR_MASKBLT:
238562
238921
  case Helper2.GDI.RecordType.EMR_PLGBLT:
238563
238922
  case Helper2.GDI.RecordType.EMR_SETDIBITSTODEVICE:
238564
- case Helper2.GDI.RecordType.EMR_STRETCHDIBITS:
238565
238923
  case Helper2.GDI.RecordType.EMR_EXTCREATEFONTINDIRECTW:
238566
238924
  case Helper2.GDI.RecordType.EMR_EXTTEXTOUTA:
238567
238925
  case Helper2.GDI.RecordType.EMR_EXTTEXTOUTW:
@@ -238613,6 +238971,9 @@ class EMFRecords2 {
238613
238971
  throw new EMFJSError2("Could not read all records");
238614
238972
  }
238615
238973
  }
238974
+ getBounds() {
238975
+ return this._header.getBounds();
238976
+ }
238616
238977
  play(gdi) {
238617
238978
  const len3 = this._records.length;
238618
238979
  for (let i4 = 0;i4 < len3; i4++) {
@@ -238621,6 +238982,7 @@ class EMFRecords2 {
238621
238982
  }
238622
238983
  }
238623
238984
  var init_EMFRecords = __esm(() => {
238985
+ init_Bitmap();
238624
238986
  init_Helper();
238625
238987
  init_Primitives();
238626
238988
  init_Region();
@@ -238802,6 +239164,9 @@ class GDIContext2 {
238802
239164
  this.state.mapmode = mode;
238803
239165
  this.state._svggroup = null;
238804
239166
  }
239167
+ getMapMode() {
239168
+ return this.state.mapmode;
239169
+ }
238805
239170
  setWindowOrgEx(x, y2) {
238806
239171
  Helper2.log("[gdi] setWindowOrgEx: x=" + x + " y=" + y2);
238807
239172
  this.state.wx = x;
@@ -238856,6 +239221,20 @@ class GDIContext2 {
238856
239221
  setStretchBltMode(stretchMode) {
238857
239222
  Helper2.log("[gdi] setStretchBltMode: stretchMode=" + stretchMode);
238858
239223
  }
239224
+ stretchDibBits(srcX, srcY, srcW, srcH, dstX, dstY, dstW, dstH, rasterOp, colorUsage, dib) {
239225
+ Helper2.log("[gdi] stretchDibBits: srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH + " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH + " rasterOp=0x" + rasterOp.toString(16));
239226
+ srcX = this._todevX(srcX);
239227
+ srcY = this._todevY(srcY);
239228
+ srcW = this._todevW(srcW);
239229
+ srcH = this._todevH(srcH);
239230
+ dstX = this._todevX(dstX);
239231
+ dstY = this._todevY(dstY);
239232
+ dstW = this._todevW(dstW);
239233
+ dstH = this._todevH(dstH);
239234
+ Helper2.log("[gdi] stretchDibBits: TRANSLATED:" + " srcX=" + srcX + " srcY=" + srcY + " srcW=" + srcW + " srcH=" + srcH + " dstX=" + dstX + " dstY=" + dstY + " dstW=" + dstW + " dstH=" + dstH + " rasterOp=0x" + rasterOp.toString(16));
239235
+ this._pushGroup();
239236
+ this._svg.image(this.state._svggroup, dstX, dstY, dstW, dstH, dib.base64ref());
239237
+ }
238859
239238
  rectangle(rect, rw, rh) {
238860
239239
  Helper2.log("[gdi] rectangle: rect=" + rect.toString() + " with pen " + this.state.selected.pen.toString() + " and brush " + this.state.selected.brush.toString());
238861
239240
  const bottom2 = this._todevY(rect.bottom);
@@ -239372,9 +239751,12 @@ class Renderer2 {
239372
239751
  }
239373
239752
  render(info) {
239374
239753
  const svgElement = document.createElementNS("http://www.w3.org/2000/svg", "svg");
239375
- this._render(new SVG2(svgElement), info.mapMode, info.wExt, info.hExt, info.xExt, info.yExt);
239376
- svgElement.setAttribute("viewBox", [0, 0, info.xExt, info.yExt].join(" "));
239377
- svgElement.setAttribute("preserveAspectRatio", "none");
239754
+ const emfBounds = this._img.getBounds();
239755
+ const gdi = this._render(new SVG2(svgElement), info.mapMode, emfBounds.width, emfBounds.height, emfBounds.width, emfBounds.height);
239756
+ svgElement.setAttribute("viewBox", [0, 0, emfBounds.width, emfBounds.height].join(" "));
239757
+ const finalMapMode = gdi.getMapMode();
239758
+ const preserveAspectRatio = finalMapMode === Helper2.GDI.MapMode.MM_ANISOTROPIC ? "none" : "xMidYMid meet";
239759
+ svgElement.setAttribute("preserveAspectRatio", preserveAspectRatio);
239378
239760
  svgElement.setAttribute("width", info.width);
239379
239761
  svgElement.setAttribute("height", info.height);
239380
239762
  return svgElement;
@@ -239403,6 +239785,7 @@ class Renderer2 {
239403
239785
  Helper2.log("[EMF] BEGIN RENDERING --->");
239404
239786
  this._img.render(gdi);
239405
239787
  Helper2.log("[EMF] <--- DONE RENDERING");
239788
+ return gdi;
239406
239789
  }
239407
239790
  }
239408
239791
 
@@ -239416,6 +239799,13 @@ class EMF2 {
239416
239799
  render(gdi) {
239417
239800
  this._records.play(gdi);
239418
239801
  }
239802
+ getBounds() {
239803
+ const bounds = this._records.getBounds();
239804
+ return {
239805
+ width: bounds.right - bounds.left,
239806
+ height: bounds.bottom - bounds.top
239807
+ };
239808
+ }
239419
239809
  }
239420
239810
  var init_Renderer = __esm(() => {
239421
239811
  init_util();
@@ -243480,6 +243870,7 @@ function handleImageNode3(node4, params3, isAnchor) {
243480
243870
  if (!blip) {
243481
243871
  return null;
243482
243872
  }
243873
+ const hasGrayscale = blip.elements?.some((el) => el.name === "a:grayscl");
243483
243874
  const stretch = blipFill?.elements?.find((el) => el.name === "a:stretch");
243484
243875
  const fillRect = stretch?.elements?.find((el) => el.name === "a:fillRect");
243485
243876
  const srcRect = blipFill?.elements?.find((el) => el.name === "a:srcRect");
@@ -243580,7 +243971,8 @@ function handleImageNode3(node4, params3, isAnchor) {
243580
243971
  originalAttributes: node4.attributes,
243581
243972
  rId: relAttributes["Id"],
243582
243973
  ...order4.length ? { drawingChildOrder: order4 } : {},
243583
- ...originalChildren.length ? { originalDrawingChildren: originalChildren } : {}
243974
+ ...originalChildren.length ? { originalDrawingChildren: originalChildren } : {},
243975
+ ...hasGrayscale ? { grayscale: true } : {}
243584
243976
  };
243585
243977
  return {
243586
243978
  type: "image",
@@ -244418,7 +244810,10 @@ var translateImageNode2 = (params3) => {
244418
244810
  name: "a:blip",
244419
244811
  attributes: {
244420
244812
  "r:embed": imageId
244421
- }
244813
+ },
244814
+ ...attrs.grayscale ? {
244815
+ elements: [{ name: "a:grayscl" }]
244816
+ } : {}
244422
244817
  },
244423
244818
  ...rawSrcRect ? [rawSrcRect] : [],
244424
244819
  {