visio-react-viewer 0.1.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49653,17 +49653,17 @@ function safePath(path, directory = false) {
49653
49653
  return path;
49654
49654
  }
49655
49655
  function inspectZip(bytes, limits, check) {
49656
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
49657
- const bounds = (start, length) => {
49656
+ const view2 = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
49657
+ const bounds2 = (start, length) => {
49658
49658
  if (start < 0 || length < 0 || start + length > bytes.length) fail("INVALID_ZIP", "Truncated ZIP record");
49659
49659
  };
49660
49660
  const u16 = (offset2) => {
49661
- bounds(offset2, 2);
49662
- return view.getUint16(offset2, true);
49661
+ bounds2(offset2, 2);
49662
+ return view2.getUint16(offset2, true);
49663
49663
  };
49664
49664
  const u32 = (offset2) => {
49665
- bounds(offset2, 4);
49666
- return view.getUint32(offset2, true);
49665
+ bounds2(offset2, 4);
49666
+ return view2.getUint32(offset2, true);
49667
49667
  };
49668
49668
  let end = -1;
49669
49669
  for (let i = bytes.length - 22; i >= Math.max(0, bytes.length - 65557); i--) if (u32(i) === 101010256 && i + 22 + u16(i + 20) === bytes.length) {
@@ -49692,7 +49692,7 @@ function inspectZip(bytes, limits, check) {
49692
49692
  };
49693
49693
  for (let i = 0; i < count; i++) {
49694
49694
  check();
49695
- bounds(offset, 46);
49695
+ bounds2(offset, 46);
49696
49696
  if (u32(offset) !== 33639248) fail("INVALID_ZIP", "Invalid central directory entry");
49697
49697
  const flags = u16(offset + 8), method = u16(offset + 10), crc = u32(offset + 16);
49698
49698
  const compressed = u32(offset + 20), size = u32(offset + 24);
@@ -49700,7 +49700,7 @@ function inspectZip(bytes, limits, check) {
49700
49700
  const local = u32(offset + 42);
49701
49701
  if (flags & -2063 || method !== 0 && method !== 8 || u16(offset + 34)) fail("UNSUPPORTED_ZIP", "Encrypted, multidisk, or unsupported ZIP entry");
49702
49702
  if (compressed === 4294967295 || size === 4294967295 || local === 4294967295) fail("UNSUPPORTED_ZIP", "ZIP64 entries are unsupported");
49703
- bounds(offset + 46, nameLength + extraLength + commentLength);
49703
+ bounds2(offset + 46, nameLength + extraLength + commentLength);
49704
49704
  const name = utf8.decode(bytes.subarray(offset + 46, offset + 46 + nameLength));
49705
49705
  const directory = name.endsWith("/");
49706
49706
  safePath(name, directory);
@@ -49713,10 +49713,10 @@ function inspectZip(bytes, limits, check) {
49713
49713
  if (total > limits.maxTotalBytes) fail("LIMIT_TOTAL", "Inflated ZIP total exceeds limit");
49714
49714
  if (size > Math.max(1, compressed) * limits.maxCompressionRatio) fail("LIMIT_RATIO", `ZIP compression ratio exceeds limit: ${name}`);
49715
49715
  if (method === 0 && compressed !== size || directory && (compressed || size)) fail("ZIP_MISMATCH", "Invalid stored entry size");
49716
- bounds(local, 30);
49716
+ bounds2(local, 30);
49717
49717
  if (u32(local) !== 67324752 || u16(local + 6) !== flags || u16(local + 8) !== method || u16(local + 26) !== nameLength) fail("ZIP_MISMATCH", "Local and central ZIP headers differ");
49718
49718
  const localExtra = u16(local + 28), dataStart = local + 30 + nameLength + localExtra;
49719
- bounds(local + 30, nameLength + localExtra);
49719
+ bounds2(local + 30, nameLength + localExtra);
49720
49720
  if (!bytes.subarray(local + 30, local + 30 + nameLength).every((byte, index) => byte === bytes[offset + 46 + index])) fail("ZIP_MISMATCH", "Local and central ZIP filenames differ");
49721
49721
  extras(local + 30 + nameLength, localExtra, name);
49722
49722
  for (const [relative, expected] of [
@@ -49728,7 +49728,7 @@ function inspectZip(bytes, limits, check) {
49728
49728
  if (actual !== expected && (!(flags & 8) || actual !== 0)) fail("ZIP_MISMATCH", "Local and central ZIP sizes or CRC differ");
49729
49729
  }
49730
49730
  let dataEnd = dataStart + compressed;
49731
- bounds(dataStart, compressed);
49731
+ bounds2(dataStart, compressed);
49732
49732
  if (flags & 8) {
49733
49733
  if (u32(dataEnd) === 134695760) dataEnd += 4;
49734
49734
  if (u32(dataEnd) !== crc || u32(dataEnd + 4) !== compressed || u32(dataEnd + 8) !== size) fail("ZIP_MISMATCH", "Invalid ZIP data descriptor");
@@ -50013,7 +50013,7 @@ var VisioPackage = class _VisioPackage {
50013
50013
  async loadBytes(path) {
50014
50014
  const entry = this.entries.get(path), file = this.zip.file(path);
50015
50015
  if (!entry || entry.directory || !file) return fail("MISSING_PART", `Missing package part: ${path}`);
50016
- return new Promise((resolve, reject) => {
50016
+ return new Promise((resolve, reject2) => {
50017
50017
  const stream = file.internalStream("uint8array");
50018
50018
  let chunks = [], size = 0, crc = 4294967295, settled = false;
50019
50019
  const abort = (error) => {
@@ -50022,7 +50022,7 @@ var VisioPackage = class _VisioPackage {
50022
50022
  stream.pause();
50023
50023
  chunks = [];
50024
50024
  clearTimeout(timer);
50025
- reject(error instanceof VisioPackageError ? error : new VisioPackageError("INVALID_ZIP", `Cannot inflate ${path}: ${String(error)}`));
50025
+ reject2(error instanceof VisioPackageError ? error : new VisioPackageError("INVALID_ZIP", `Cannot inflate ${path}: ${String(error)}`));
50026
50026
  };
50027
50027
  const timer = setTimeout(() => abort(new VisioPackageError("LIMIT_RUNTIME", "Visio package processing deadline exceeded")), Math.max(1, this.deadline - Date.now()));
50028
50028
  stream.on("data", (chunk) => {
@@ -50379,7 +50379,7 @@ function emfInputOptions(options) {
50379
50379
  try {
50380
50380
  const prototype = Object.getPrototypeOf(options);
50381
50381
  if (prototype !== null && prototype !== Object.prototype) return null;
50382
- const snapshot = {};
50382
+ const snapshot2 = {};
50383
50383
  for (const key2 of Object.keys(VISIO_EMF_ADMISSION_LIMITS)) {
50384
50384
  const descriptor = Object.getOwnPropertyDescriptor(options, key2);
50385
50385
  if (!descriptor) continue;
@@ -50387,16 +50387,16 @@ function emfInputOptions(options) {
50387
50387
  const value = descriptor.value;
50388
50388
  if (value === void 0) continue;
50389
50389
  if (typeof value !== "number") return null;
50390
- snapshot[key2] = value;
50390
+ snapshot2[key2] = value;
50391
50391
  }
50392
- return snapshot;
50392
+ return snapshot2;
50393
50393
  } catch {
50394
50394
  return null;
50395
50395
  }
50396
50396
  }
50397
50397
  var EmfAdmissionContext = class {
50398
- constructor(view, options) {
50399
- this.view = view;
50398
+ constructor(view2, options) {
50399
+ this.view = view2;
50400
50400
  this.limits = { ...VISIO_EMF_ADMISSION_LIMITS };
50401
50401
  if (!options || typeof options !== "object") {
50402
50402
  this.emit("invalid", "limits", "Expected an options object.");
@@ -50469,7 +50469,7 @@ var EmfAdmissionContext = class {
50469
50469
  i16(at) {
50470
50470
  return this.view.getInt16(this.offset + at, true);
50471
50471
  }
50472
- emit(kind, code, message, limit2) {
50472
+ emit(kind, code, message, limit3) {
50473
50473
  if (kind === "invalid") this.invalid = true;
50474
50474
  if (kind === "unsupported") this.unsupported = true;
50475
50475
  if (kind === "budget-exceeded") this.budgetExceeded = true;
@@ -50479,7 +50479,7 @@ var EmfAdmissionContext = class {
50479
50479
  offset: this.offset,
50480
50480
  recordType: this.type,
50481
50481
  message,
50482
- ...limit2 === void 0 ? {} : { limit: limit2 }
50482
+ ...limit3 === void 0 ? {} : { limit: limit3 }
50483
50483
  });
50484
50484
  else this.omittedDiagnostics++;
50485
50485
  }
@@ -50487,9 +50487,9 @@ var EmfAdmissionContext = class {
50487
50487
  this.metrics.allocationUnits += units2;
50488
50488
  return this.bound(this.metrics.allocationUnits, this.limits.maxAllocationUnits, "allocation-limit", "Aggregate abstract allocation/work budget exceeded.");
50489
50489
  }
50490
- bound(value, limit2, code, message) {
50491
- if (Number.isFinite(value) && Math.abs(value) <= limit2) return true;
50492
- this.emit("budget-exceeded", code, message, limit2);
50490
+ bound(value, limit3, code, message) {
50491
+ if (Number.isFinite(value) && Math.abs(value) <= limit3) return true;
50492
+ this.emit("budget-exceeded", code, message, limit3);
50493
50493
  return false;
50494
50494
  }
50495
50495
  coordinate(value) {
@@ -50799,38 +50799,38 @@ function inspectEmfObjectRecord(c) {
50799
50799
  return true;
50800
50800
  }
50801
50801
  function inspectVisioEmfAdmission(input, options = {}) {
50802
- const snapshot = emfInputOptions(options);
50803
- const view = snapshot === null ? null : emfInputView(input);
50804
- const c = new EmfAdmissionContext(view ?? /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(0)), snapshot ?? {});
50805
- if (snapshot === null) {
50802
+ const snapshot2 = emfInputOptions(options);
50803
+ const view2 = snapshot2 === null ? null : emfInputView(input);
50804
+ const c = new EmfAdmissionContext(view2 ?? /* @__PURE__ */ new DataView(/* @__PURE__ */ new ArrayBuffer(0)), snapshot2 ?? {});
50805
+ if (snapshot2 === null) {
50806
50806
  c.emit("invalid", "limits", "Options must contain only plain own numeric data properties.");
50807
50807
  return c.result();
50808
50808
  }
50809
50809
  if (c.invalid) return c.result();
50810
- if (view === null) {
50810
+ if (view2 === null) {
50811
50811
  c.emit("invalid", "input", "Expected a Uint8Array backed by an unshared, fixed, attached ArrayBuffer.");
50812
50812
  return c.result();
50813
50813
  }
50814
- if (!c.bound(view.byteLength, c.limits.maxInputBytes, "allocation-limit", "Encoded input exceeds byte budget.")) return c.result();
50815
- if (view.byteLength < 88 || view.byteLength % 4 !== 0) {
50814
+ if (!c.bound(view2.byteLength, c.limits.maxInputBytes, "allocation-limit", "Encoded input exceeds byte budget.")) return c.result();
50815
+ if (view2.byteLength < 88 || view2.byteLength % 4 !== 0) {
50816
50816
  c.emit("invalid", "header", "Input must contain an aligned complete EMF header.");
50817
50817
  return c.result();
50818
50818
  }
50819
50819
  const headerSize = c.u32(4);
50820
50820
  if (!inspectHeader(c, headerSize)) return c.result();
50821
50821
  let eof = false;
50822
- while (c.offset < view.byteLength && !c.budgetExceeded) {
50822
+ while (c.offset < view2.byteLength && !c.budgetExceeded) {
50823
50823
  if (++c.metrics.records > c.limits.maxRecords) {
50824
50824
  c.emit("budget-exceeded", "record-limit", "Aggregate record budget exceeded.", c.limits.maxRecords);
50825
50825
  break;
50826
50826
  }
50827
- if (view.byteLength - c.offset < 8) {
50827
+ if (view2.byteLength - c.offset < 8) {
50828
50828
  c.emit("invalid", "record-size", "Truncated record header.");
50829
50829
  break;
50830
50830
  }
50831
50831
  c.type = c.u32(0);
50832
50832
  const size = c.u32(4);
50833
- if (size < 8 || size % 4 || size > view.byteLength - c.offset) {
50833
+ if (size < 8 || size % 4 || size > view2.byteLength - c.offset) {
50834
50834
  c.emit("invalid", "record-size", "Record must progress, align, and fit entirely within input.");
50835
50835
  break;
50836
50836
  }
@@ -50849,7 +50849,7 @@ function inspectVisioEmfAdmission(input, options = {}) {
50849
50849
  } else if (c.type === 14) {
50850
50850
  inspectEof(c, size);
50851
50851
  eof = true;
50852
- if (c.offset + size !== view.byteLength) c.emit("invalid", "trailing-data", "Data follows EOF.");
50852
+ if (c.offset + size !== view2.byteLength) c.emit("invalid", "trailing-data", "Data follows EOF.");
50853
50853
  else c.scanComplete = true;
50854
50854
  break;
50855
50855
  } else if (c.type === 70) inspectEmfComment(c, size, headerSize);
@@ -50889,13 +50889,13 @@ function inspectHeader(c, size) {
50889
50889
  if ((size === 100 || size === 108) && (c.u32(88) || c.u32(92) || c.u32(96))) c.emit("unsupported", "header", "Pixel format and OpenGL header extensions are excluded.");
50890
50890
  c.rect(8, false);
50891
50891
  c.rect(24, false);
50892
- const bounds = [
50892
+ const bounds2 = [
50893
50893
  c.i32(8),
50894
50894
  c.i32(12),
50895
50895
  c.i32(16),
50896
50896
  c.i32(20)
50897
50897
  ];
50898
- const width = bounds[2] - bounds[0] + 1, height = bounds[3] - bounds[1] + 1;
50898
+ const width = bounds2[2] - bounds2[0] + 1, height = bounds2[3] - bounds2[1] + 1;
50899
50899
  if (width <= 0 || height <= 0) c.emit("invalid", "header", "Inclusive header bounds must be nonempty.");
50900
50900
  for (const offset of [
50901
50901
  72,
@@ -50912,7 +50912,7 @@ function inspectHeader(c, size) {
50912
50912
  c.bound(c.headerPaletteEntries, c.limits.maxPaletteEntries, "palette-limit", "Declared palette exceeds budget.");
50913
50913
  if (c.headerPaletteEntries) c.emit("unsupported", "palette", "Header/EOF palettes are outside this subset.");
50914
50914
  c.header = {
50915
- bounds,
50915
+ bounds: bounds2,
50916
50916
  pixelWidth: width,
50917
50917
  pixelHeight: height,
50918
50918
  declaredRecords: c.u32(52),
@@ -51431,7 +51431,7 @@ function sanitize(root, limits) {
51431
51431
  children: data2.children
51432
51432
  };
51433
51433
  }
51434
- function children2(value, optional = false) {
51434
+ function children3(value, optional = false) {
51435
51435
  if (value === void 0 && optional) return [];
51436
51436
  if (!Array.isArray(value) || Object.getPrototypeOf(value) !== Array.prototype) unsafe("Expected plain child array.");
51437
51437
  if (value.length > limits.maxNodes - nodes) limit("Child array node limit exceeded.");
@@ -51460,7 +51460,7 @@ function sanitize(root, limits) {
51460
51460
  return target;
51461
51461
  }
51462
51462
  function leaf(data2) {
51463
- if (children2(data2.children, true).length !== 0) unsafe("Path cannot contain child elements.");
51463
+ if (children3(data2.children, true).length !== 0) unsafe("Path cannot contain child elements.");
51464
51464
  return pathCommands(data2.attrs.d, limits, pathBudget);
51465
51465
  }
51466
51466
  function item(value, depth) {
@@ -51473,7 +51473,7 @@ function sanitize(root, limits) {
51473
51473
  paint: paint(data2.attrs)
51474
51474
  }) : Object.assign(target, {
51475
51475
  kind: "group",
51476
- items: Object.freeze(children2(data2.children).map((child2) => item(child2, depth + 1)))
51476
+ items: Object.freeze(children3(data2.children).map((child2) => item(child2, depth + 1)))
51477
51477
  });
51478
51478
  freezeLater.push(result);
51479
51479
  return result;
@@ -51488,7 +51488,7 @@ function sanitize(root, limits) {
51488
51488
  ids.set(id, clips.length);
51489
51489
  const target = base(data2.attrs);
51490
51490
  const paths = [];
51491
- for (const child2 of children2(data2.children)) {
51491
+ for (const child2 of children3(data2.children)) {
51492
51492
  const part = node(child2, depth + 1, true);
51493
51493
  if (part.tag !== "path") unsafe("Clip content must be a path.");
51494
51494
  const path = Object.assign(base(part.attrs), {
@@ -51510,13 +51510,13 @@ function sanitize(root, limits) {
51510
51510
  const viewBox = numberList(data.attrs.viewBox, 4, limits.maxDimension);
51511
51511
  if (viewBox[0] !== 0 || viewBox[1] !== 0 || viewBox[2] !== width || viewBox[3] !== height) unsafe("Viewport differs from dimensions.");
51512
51512
  const items = [];
51513
- for (const child2 of children2(data.children)) if (record(child2, [
51513
+ for (const child2 of children3(data.children)) if (record(child2, [
51514
51514
  "tag",
51515
51515
  "attrs",
51516
51516
  "children"
51517
51517
  ]).tag === "defs") {
51518
51518
  const defs = node(child2, 1);
51519
- for (const value of children2(defs.children)) definition(value, 2);
51519
+ for (const value of children3(defs.children)) definition(value, 2);
51520
51520
  } else items.push(item(child2, 1));
51521
51521
  for (const { target, id } of pending) {
51522
51522
  const index = ids.get(id);
@@ -51751,9 +51751,9 @@ function dimensions(width, height, limits) {
51751
51751
  }
51752
51752
  var ascii = (bytes, start, length) => String.fromCharCode(...bytes.subarray(start, start + length));
51753
51753
  function png(bytes, limits) {
51754
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51755
- if (bytes.length < 33 || view.getUint32(8) !== 13 || ascii(bytes, 12, 4) !== "IHDR") return invalid("PNG is missing a complete IHDR header.");
51756
- const width = view.getUint32(16), height = view.getUint32(20);
51754
+ const view2 = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51755
+ if (bytes.length < 33 || view2.getUint32(8) !== 13 || ascii(bytes, 12, 4) !== "IHDR") return invalid("PNG is missing a complete IHDR header.");
51756
+ const width = view2.getUint32(16), height = view2.getUint32(20);
51757
51757
  dimensions(width, height, limits);
51758
51758
  const depth = bytes[24];
51759
51759
  if (!{
@@ -51777,9 +51777,9 @@ function png(bytes, limits) {
51777
51777
  let data = false;
51778
51778
  for (let at = 8; at < bytes.length;) {
51779
51779
  if (at + 12 > bytes.length) invalid("Truncated PNG chunk.");
51780
- const length = view.getUint32(at), type = ascii(bytes, at + 4, 4), end = at + length + 12;
51780
+ const length = view2.getUint32(at), type = ascii(bytes, at + 4, 4), end = at + length + 12;
51781
51781
  if (end > bytes.length) invalid("Truncated PNG chunk payload.");
51782
- if ((crc32(bytes.subarray(at + 4, end - 4)) ^ 4294967295) >>> 0 !== view.getUint32(end - 4)) invalid("PNG chunk checksum mismatch.");
51782
+ if ((crc32(bytes.subarray(at + 4, end - 4)) ^ 4294967295) >>> 0 !== view2.getUint32(end - 4)) invalid("PNG chunk checksum mismatch.");
51783
51783
  if (type === "acTL") unsupported("Animated PNG is not supported.");
51784
51784
  if (type === "IHDR" && at !== 8) invalid("PNG contains multiple image headers.");
51785
51785
  if (type === "IDAT" && length) data = true;
@@ -51793,8 +51793,8 @@ function png(bytes, limits) {
51793
51793
  }
51794
51794
  function gif(bytes, limits) {
51795
51795
  if (bytes.length < 13) return invalid("GIF is missing a complete screen descriptor.");
51796
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51797
- const width = view.getUint16(6, true), height = view.getUint16(8, true);
51796
+ const view2 = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51797
+ const width = view2.getUint16(6, true), height = view2.getUint16(8, true);
51798
51798
  dimensions(width, height, limits);
51799
51799
  let at = 13 + (bytes[10] & 128 ? 3 * 2 ** ((bytes[10] & 7) + 1) : 0);
51800
51800
  let frames = 0, pixels = 0;
@@ -51820,8 +51820,8 @@ function gif(bytes, limits) {
51820
51820
  continue;
51821
51821
  }
51822
51822
  if (marker2 !== 44 || at + 9 > bytes.length) invalid("GIF has an invalid image descriptor.");
51823
- const left = view.getUint16(at, true), top = view.getUint16(at + 2, true);
51824
- const frameWidth = view.getUint16(at + 4, true), frameHeight = view.getUint16(at + 6, true);
51823
+ const left = view2.getUint16(at, true), top = view2.getUint16(at + 2, true);
51824
+ const frameWidth = view2.getUint16(at + 4, true), frameHeight = view2.getUint16(at + 6, true);
51825
51825
  dimensions(frameWidth, frameHeight, limits);
51826
51826
  if (left + frameWidth > width || top + frameHeight > height) invalid("GIF frame exceeds its screen.");
51827
51827
  pixels += width * height;
@@ -51836,7 +51836,7 @@ function gif(bytes, limits) {
51836
51836
  return invalid("GIF has no image terminator.");
51837
51837
  }
51838
51838
  function jpeg(bytes, limits) {
51839
- const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51839
+ const view2 = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
51840
51840
  let at = 2, width = 0, height = 0, scan = false;
51841
51841
  while (at < bytes.length) {
51842
51842
  if (bytes[at++] !== 255) invalid("JPEG has an invalid segment marker.");
@@ -51848,7 +51848,7 @@ function jpeg(bytes, limits) {
51848
51848
  }
51849
51849
  if (marker2 === void 0 || marker2 === 0 || marker2 === 216 || marker2 === 1 || marker2 >= 208 && marker2 <= 215) invalid("JPEG has an unexpected standalone marker.");
51850
51850
  if (at + 2 > bytes.length) invalid("JPEG has a truncated segment header.");
51851
- const length = view.getUint16(at), end = at + length;
51851
+ const length = view2.getUint16(at), end = at + length;
51852
51852
  if (length < 2 || end > bytes.length) invalid("JPEG has a truncated segment.");
51853
51853
  if (marker2 >= 192 && marker2 <= 207 && ![
51854
51854
  196,
@@ -51861,8 +51861,8 @@ function jpeg(bytes, limits) {
51861
51861
  194
51862
51862
  ].includes(marker2)) unsupported("This JPEG frame coding is unsupported.");
51863
51863
  if (width || length < 11 || bytes[at + 2] !== 8 || length !== 8 + 3 * bytes[at + 7]) invalid("JPEG has an invalid frame header.");
51864
- height = view.getUint16(at + 3);
51865
- width = view.getUint16(at + 5);
51864
+ height = view2.getUint16(at + 3);
51865
+ width = view2.getUint16(at + 5);
51866
51866
  dimensions(width, height, limits);
51867
51867
  }
51868
51868
  if (marker2 === 220) unsupported("JPEG deferred dimensions are unsupported.");
@@ -52141,17 +52141,17 @@ function themeLinearGradient(sheet, resources, width, height, report) {
52141
52141
  if (enabled && enabled.value !== "Themed" && number(cells3, "FillGradientEnabled", 0) !== 1) return void 0;
52142
52142
  const context = themePaintContext(cells3, "Fill", resources, report);
52143
52143
  if (!context || context.selected.localName !== "gradFill") return void 0;
52144
- const reject = () => {
52144
+ const reject2 = () => {
52145
52145
  report("unsupported-theme-gradient", "The theme gradient has unsupported settings or overrides; its base color is used.");
52146
52146
  };
52147
- if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return reject();
52147
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return reject2();
52148
52148
  if ([
52149
52149
  "FillGradientDir",
52150
52150
  "FillGradientAngle",
52151
52151
  "RotateGradientWithShape",
52152
52152
  "UseGroupGradient"
52153
- ].some((key2) => cells3.has(key2) && cells3.get(key2)?.value !== "Themed")) return reject();
52154
- if (sectionRows(sheet, "FillGradient").some((row) => [...row.cells.values()].some((cell) => cell.value !== "Themed"))) return reject();
52153
+ ].some((key2) => cells3.has(key2) && cells3.get(key2)?.value !== "Themed")) return reject2();
52154
+ if (sectionRows(sheet, "FillGradient").some((row) => [...row.cells.values()].some((cell) => cell.value !== "Themed"))) return reject2();
52155
52155
  const fill = context.selected;
52156
52156
  const lin = themeChild(fill, "lin");
52157
52157
  const rawAngle = lin?.getAttribute("ang") ?? "0";
@@ -52160,14 +52160,14 @@ function themeLinearGradient(sheet, resources, width, height, report) {
52160
52160
  "gsLst",
52161
52161
  "lin",
52162
52162
  "tileRect"
52163
- ].includes(node.localName)) || themeChildren(fill, "lin").length !== 1 || themeChildren(fill, "gsLst").length !== 1) return reject();
52163
+ ].includes(node.localName)) || themeChildren(fill, "lin").length !== 1 || themeChildren(fill, "gsLst").length !== 1) return reject2();
52164
52164
  const nodes = themeChildren(themeChild(fill, "gsLst"), "gs");
52165
- if (nodes.length < 2 || nodes.length > 32 || elements(themeChild(fill, "gsLst")).length !== nodes.length) return reject();
52165
+ if (nodes.length < 2 || nodes.length > 32 || elements(themeChild(fill, "gsLst")).length !== nodes.length) return reject2();
52166
52166
  const stops = [];
52167
52167
  for (const node of nodes) {
52168
52168
  const position = integer(node.getAttribute("pos"));
52169
52169
  const paint2 = drawingPaint(colorChoice(node), context.colors, context.base);
52170
- if (position === void 0 || position > 1e5 || !paint2 || position / 1e5 < (stops.at(-1)?.offset ?? 0)) return reject();
52170
+ if (position === void 0 || position > 1e5 || !paint2 || position / 1e5 < (stops.at(-1)?.offset ?? 0)) return reject2();
52171
52171
  stops.push({
52172
52172
  offset: position / 1e5,
52173
52173
  ...paint2
@@ -52184,21 +52184,21 @@ function savedFillGradient(sheet, width, height, resolveColor, report) {
52184
52184
  if (number(cells3, "FillGradientEnabled", NaN) !== 1) return void 0;
52185
52185
  const rows = sectionRows(sheet, "FillGradient").slice(0, 10);
52186
52186
  if (!rows.some((row) => [...row.cells.values()].some((cell) => cell.value !== "Themed"))) return void 0;
52187
- const reject = () => {
52187
+ const reject2 = () => {
52188
52188
  report("unsupported-saved-fill-gradient", "The saved fill gradient has incomplete or unsupported settings; its foreground color is used.");
52189
52189
  };
52190
52190
  const wrapped = (number(cells3, "FillGradientAngle", NaN) % (2 * Math.PI) + 2 * Math.PI) % (2 * Math.PI);
52191
52191
  const horizontal = Math.min(wrapped, 2 * Math.PI - wrapped) < 1e-12 ? 0 : Math.abs(wrapped - Math.PI) < 1e-12 ? Math.PI : void 0;
52192
- if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 || horizontal === void 0 || number(cells3, "FillGradientDir", NaN) !== 0 || number(cells3, "RotateGradientWithShape", NaN) !== 1 || number(cells3, "UseGroupGradient", NaN) !== 0) return reject();
52193
- if (rows.length < 2) return reject();
52192
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0 || horizontal === void 0 || number(cells3, "FillGradientDir", NaN) !== 0 || number(cells3, "RotateGradientWithShape", NaN) !== 1 || number(cells3, "UseGroupGradient", NaN) !== 0) return reject2();
52193
+ if (rows.length < 2) return reject2();
52194
52194
  const stops = [];
52195
52195
  for (const row of rows) {
52196
52196
  const offset = number(row.cells, "GradientStopPosition", NaN);
52197
52197
  const transparency = number(row.cells, "GradientStopColorTrans", NaN);
52198
52198
  const value = row.cells.get("GradientStopColor")?.value;
52199
- if (!Number.isFinite(offset) || offset < 0 || offset > 1 || offset < (stops.at(-1)?.offset ?? 0) || !Number.isFinite(transparency) || transparency < 0 || transparency > 1 || !value || value === "Themed") return reject();
52199
+ if (!Number.isFinite(offset) || offset < 0 || offset > 1 || offset < (stops.at(-1)?.offset ?? 0) || !Number.isFinite(transparency) || transparency < 0 || transparency > 1 || !value || value === "Themed") return reject2();
52200
52200
  const color2 = resolveColor(row.cells);
52201
- if (!color2) return reject();
52201
+ if (!color2) return reject2();
52202
52202
  stops.push({
52203
52203
  offset,
52204
52204
  color: color2,
@@ -53227,7 +53227,7 @@ var marker = {
53227
53227
  function diagnosticCollector(maxCount) {
53228
53228
  const diagnostics = [], keys = /* @__PURE__ */ new Set();
53229
53229
  let characters = 0, truncated = false;
53230
- const bounded4 = (value, max) => {
53230
+ const bounded5 = (value, max) => {
53231
53231
  if (value.length <= max) return value;
53232
53232
  truncated = true;
53233
53233
  return value.slice(0, max - 1) + "…";
@@ -53238,12 +53238,12 @@ function diagnosticCollector(maxCount) {
53238
53238
  return;
53239
53239
  }
53240
53240
  const item = {
53241
- code: bounded4(code, 64),
53241
+ code: bounded5(code, 64),
53242
53242
  severity: context.severity ?? "warning",
53243
- message: bounded4(message, 2048),
53244
- ...context.part === void 0 ? {} : { part: bounded4(context.part, 1024) },
53245
- ...context.pageId === void 0 ? {} : { pageId: bounded4(context.pageId, 256) },
53246
- ...context.shapeId === void 0 ? {} : { shapeId: bounded4(context.shapeId, 1024) }
53243
+ message: bounded5(message, 2048),
53244
+ ...context.part === void 0 ? {} : { part: bounded5(context.part, 1024) },
53245
+ ...context.pageId === void 0 ? {} : { pageId: bounded5(context.pageId, 256) },
53246
+ ...context.shapeId === void 0 ? {} : { shapeId: bounded5(context.shapeId, 1024) }
53247
53247
  };
53248
53248
  const key2 = JSON.stringify(item);
53249
53249
  if (keys.has(key2)) return;
@@ -53935,6 +53935,170 @@ async function parseVsdx(input, options = {}) {
53935
53935
  diagnostics: diagnosticState.finish()
53936
53936
  };
53937
53937
  }
53938
+ new Uint8Array([
53939
+ 208,
53940
+ 207,
53941
+ 17,
53942
+ 224,
53943
+ 161,
53944
+ 177,
53945
+ 26,
53946
+ 225
53947
+ ]);
53948
+ new Map([
53949
+ 8364,
53950
+ 129,
53951
+ 8218,
53952
+ 402,
53953
+ 8222,
53954
+ 8230,
53955
+ 8224,
53956
+ 8225,
53957
+ 710,
53958
+ 8240,
53959
+ 352,
53960
+ 8249,
53961
+ 338,
53962
+ 141,
53963
+ 381,
53964
+ 143,
53965
+ 144,
53966
+ 8216,
53967
+ 8217,
53968
+ 8220,
53969
+ 8221,
53970
+ 8226,
53971
+ 8211,
53972
+ 8212,
53973
+ 732,
53974
+ 8482,
53975
+ 353,
53976
+ 8250,
53977
+ 339,
53978
+ 157,
53979
+ 382,
53980
+ 376
53981
+ ].map((codePoint, i) => [codePoint, 128 + i]));
53982
+ Object.freeze({
53983
+ maxCharacters: 16777216,
53984
+ maxPieces: 65536,
53985
+ maxFieldRecords: 65536
53986
+ });
53987
+ Object.freeze({
53988
+ read: Object.freeze([
53989
+ "paragraph-text",
53990
+ "character-runs",
53991
+ "direct-character-formatting",
53992
+ "paragraph-style-index",
53993
+ "compound-streams"
53994
+ ]),
53995
+ write: Object.freeze(["paragraph-text", "existing-direct-bold-italic"]),
53996
+ limitations: Object.freeze([
53997
+ "Paragraph insertion, removal and embedded paragraph breaks are unsupported.",
53998
+ "Character formatting reports direct CHPX exceptions, without resolving styles or piece PRMs.",
53999
+ "Bold/italic setters force an absolute value in an existing exclusive understood CHPX run. Run handles expire after edits.",
54000
+ "Fields, tables, objects and inherited styles are preserved where supported; their models are not editable.",
54001
+ "Unsupported edits and processing limits throw without changing the document.",
54002
+ "Text uses the bounded DOC codec defaults: 16,777,216 main-story characters and 65,536 pieces or field records.",
54003
+ "Rich formatting is bounded to 65,536 physical/mapped runs and paragraph style records."
54004
+ ])
54005
+ });
54006
+ new Map(`0 COUNT -1|1 IF -1|2 ISNA 1|3 ISERROR 1|4 SUM -1|5 AVERAGE -1|6 MIN -1|7 MAX -1|8 ROW -1|9 COLUMN -1|10 NA 0|11 NPV -1|12 STDEV -1|13 DOLLAR -1|14 FIXED -1|15 SIN 1|16 COS 1|17 TAN 1|18 ATAN 1|19 PI 0|20 SQRT 1|21 EXP 1|22 LN 1|23 LOG10 1|24 ABS 1|25 INT 1|26 SIGN 1|27 ROUND 2|28 LOOKUP -1|29 INDEX -1|30 REPT 2|31 MID 3|32 LEN 1|33 VALUE 1|34 TRUE 0|35 FALSE 0|36 AND -1|37 OR -1|38 NOT 1|39 MOD 2|40 DCOUNT 3|41 DSUM 3|42 DAVERAGE 3|43 DMIN 3|44 DMAX 3|45 DSTDEV 3|46 VAR -1|47 DVAR 3|48 TEXT 2|49 LINEST -1|50 TREND -1|51 LOGEST -1|52 GROWTH -1|56 PV -1|57 FV -1|58 NPER -1|59 PMT -1|60 RATE -1|61 MIRR 3|62 IRR -1|63 RAND 0|64 MATCH -1|65 DATE 3|66 TIME 3|67 DAY 1|68 MONTH 1|69 YEAR 1|70 WEEKDAY -1|71 HOUR 1|72 MINUTE 1|73 SECOND 1|74 NOW 0|75 AREAS 1|76 ROWS 1|77 COLUMNS 1|78 OFFSET -1|82 SEARCH -1|83 TRANSPOSE 1|86 TYPE 1|97 ATAN2 2|98 ASIN 1|99 ACOS 1|100 CHOOSE -1|101 HLOOKUP -1|102 VLOOKUP -1|105 ISREF 1|109 LOG -1|111 CHAR 1|112 LOWER 1|113 UPPER 1|114 PROPER 1|115 LEFT -1|116 RIGHT -1|117 EXACT 2|118 TRIM 1|119 REPLACE 4|120 SUBSTITUTE -1|121 CODE 1|124 FIND -1|125 CELL -1|126 ISERR 1|127 ISTEXT 1|128 ISNUMBER 1|129 ISBLANK 1|130 T 1|131 N 1|140 DATEVALUE 1|141 TIMEVALUE 1|142 SLN 3|143 SYD 4|144 DDB -1|148 INDIRECT -1|150 CALL -1|162 CLEAN 1|163 MDETERM 1|164 MINVERSE 1|165 MMULT 2|167 IPMT -1|168 PPMT -1|169 COUNTA -1|183 PRODUCT -1|184 FACT 1|189 DPRODUCT 3|190 ISNONTEXT 1|193 STDEVP -1|194 VARP -1|195 DSTDEVP 3|196 DVARP 3|197 TRUNC -1|198 ISLOGICAL 1|199 DCOUNTA 3|204 USDOLLAR -1|205 FINDB -1|206 SEARCHB -1|207 REPLACEB 4|208 LEFTB -1|209 RIGHTB -1|210 MIDB 3|211 LENB 1|212 ROUNDUP 2|213 ROUNDDOWN 2|214 ASC 1|215 DBCS 1|216 RANK -1|219 ADDRESS -1|220 DAYS360 -1|221 TODAY 0|222 VDB -1|227 MEDIAN -1|228 SUMPRODUCT -1|229 SINH 1|230 COSH 1|231 TANH 1|232 ASINH 1|233 ACOSH 1|234 ATANH 1|235 DGET 3|244 INFO 1|247 DB -1|252 FREQUENCY 2|261 ERROR.TYPE 1|269 AVEDEV -1|270 BETADIST -1|271 GAMMALN 1|272 BETAINV -1|273 BINOMDIST 4|274 CHIDIST 2|275 CHIINV 2|276 COMBIN 2|277 CONFIDENCE 3|278 CRITBINOM 3|279 EVEN 1|280 EXPONDIST 3|281 FDIST 3|282 FINV 3|283 FISHER 1|284 FISHERINV 1|285 FLOOR 2|286 GAMMADIST 4|287 GAMMAINV 3|288 CEILING 2|289 HYPGEOMDIST 4|290 LOGNORMDIST 3|291 LOGINV 3|292 NEGBINOMDIST 3|293 NORMDIST 4|294 NORMSDIST 1|295 NORMINV 3|296 NORMSINV 1|297 STANDARDIZE 3|298 ODD 1|299 PERMUT 2|300 POISSON 3|301 TDIST 3|302 WEIBULL 4|303 SUMXMY2 2|304 SUMX2MY2 2|305 SUMX2PY2 2|306 CHITEST 2|307 CORREL 2|308 COVAR 2|309 FORECAST 3|310 FTEST 2|311 INTERCEPT 2|312 PEARSON 2|313 RSQ 2|314 STEYX 2|315 SLOPE 2|316 TTEST 4|317 PROB -1|318 DEVSQ -1|319 GEOMEAN -1|320 HARMEAN -1|321 SUMSQ -1|322 KURT -1|323 SKEW -1|324 ZTEST -1|325 LARGE 2|326 SMALL 2|327 QUARTILE 2|328 PERCENTILE 2|329 PERCENTRANK -1|330 MODE -1|331 TRIMMEAN 2|332 TINV 2|336 CONCATENATE -1|337 POWER 2|342 RADIANS 1|343 DEGREES 1|344 SUBTOTAL -1|345 SUMIF -1|346 COUNTIF 2|347 COUNTBLANK 1|350 ISPMT 4|351 DATEDIF 3|352 DATESTRING 1|353 NUMBERSTRING 2|354 ROMAN -1|358 GETPIVOTDATA -1|359 HYPERLINK -1|360 PHONETIC 1|361 AVERAGEA -1|362 MAXA -1|363 MINA -1|364 STDEVPA -1|365 VARPA -1|366 STDEVA -1|367 VARA -1|368 BAHTTEXT 1`.split("|").map((entry) => {
54007
+ const [id, name, argc] = entry.split(" ");
54008
+ return [Number(id), {
54009
+ name: name ?? "",
54010
+ argc: Number(argc)
54011
+ }];
54012
+ }));
54013
+ "000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 000000 FFFFFF FF0000 00FF00 0000FF FFFF00 FF00FF 00FFFF 800000 008000 000080 808000 800080 008080 C0C0C0 808080 9999FF 993366 FFFFCC CCFFFF 660066 FF8080 0066CC CCCCFF 000080 FF00FF FFFF00 00FFFF 800080 800000 008080 0000FF 00CCFF CCFFFF CCFFCC FFFF99 99CCFF FF99CC CC99FF FFCC99 3366FF 33CCCC 99CC00 FFCC00 FF9900 FF6600 666699 969696 003366 339966 003300 333300 993300 993366 333399 333333".split(" ");
54014
+ Object.freeze({
54015
+ "#NULL!": 0,
54016
+ "#DIV/0!": 7,
54017
+ "#VALUE!": 15,
54018
+ "#REF!": 23,
54019
+ "#NAME?": 29,
54020
+ "#NUM!": 36,
54021
+ "#N/A": 42,
54022
+ "#GETTING_DATA": 43
54023
+ });
54024
+ Object.freeze({
54025
+ read: Object.freeze([
54026
+ "BIFF8 worksheets",
54027
+ "cell values and cached formulas",
54028
+ "styles and merges",
54029
+ "opaque compound streams"
54030
+ ]),
54031
+ write: Object.freeze([
54032
+ "existing NUMBER/RK/MULRK numeric values",
54033
+ "existing LABELSST/NUMBER/RK/MULRK plain string values",
54034
+ "existing NUMBER/RK/MULRK/BOOLERR boolean and error values"
54035
+ ]),
54036
+ limitations: Object.freeze([
54037
+ "No cell creation, formula editing or recalculation",
54038
+ "Numeric writes require exact original encoding",
54039
+ "Resizing writes reject unsupported relocation records and container layouts",
54040
+ "Plain string replacement removes selected rich text runs",
54041
+ "String-to-boolean/error and boolean/error-to-number/string conversions unsupported"
54042
+ ])
54043
+ });
54044
+ Object.freeze({
54045
+ read: Object.freeze([
54046
+ "active-slide-ids",
54047
+ "active-outline-and-inline-text",
54048
+ "text-encoding",
54049
+ "active-shape-ids-and-flags",
54050
+ "primitive-shape-kind",
54051
+ "explicit-anchor-geometry",
54052
+ "validated-inline-shape-text",
54053
+ "opaque-streams"
54054
+ ]),
54055
+ write: Object.freeze(["existing-text-fixed-utf16-length", "unmirrored-top-level-small-anchor-bounds"]),
54056
+ limitations: Object.freeze([
54057
+ "unresolved-outline-shape-text",
54058
+ "rich-text-runs",
54059
+ "notes",
54060
+ "variable-length-text",
54061
+ "OOXML-mirrored-text-and-shapes",
54062
+ "group-transforms-and-geometry",
54063
+ "large-anchor-writes",
54064
+ "inherited-rotated-or-flipped-geometry",
54065
+ "animations",
54066
+ "masters",
54067
+ "embedded-objects"
54068
+ ])
54069
+ });
54070
+ Object.freeze({
54071
+ read: Object.freeze([
54072
+ "v11-pages",
54073
+ "explicit-shape-transform",
54074
+ "utf16-shape-text",
54075
+ "move-to-line-to"
54076
+ ]),
54077
+ write: Object.freeze(["equal-length-shape-text", "literal-shape-transform"]),
54078
+ limitations: Object.freeze([
54079
+ "Version 11 only; stored values without master/style/formula evaluation.",
54080
+ "No added/deleted shapes, text length changes or text field edits.",
54081
+ "Shared/overlapping VSD blocks cannot be edited; no native Visio fidelity claim."
54082
+ ])
54083
+ });
54084
+ Object.freeze({
54085
+ read: Object.freeze(["directory", "stream-by-path"]),
54086
+ write: Object.freeze(["existing-stream-bytes"]),
54087
+ limitations: Object.freeze([
54088
+ "Container editing does not update Office format records.",
54089
+ "New directory entries and external DIFAT expansion are unsupported.",
54090
+ "Variable-length v4 mini-stream edits are unsupported."
54091
+ ])
54092
+ });
54093
+ (() => {
54094
+ const table = /* @__PURE__ */ new Uint32Array(256);
54095
+ for (let n = 0; n < 256; n++) {
54096
+ let c = n;
54097
+ for (let k = 0; k < 8; k++) c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
54098
+ table[n] = c >>> 0;
54099
+ }
54100
+ return table;
54101
+ })();
53938
54102
  Object.freeze({
53939
54103
  maxShapes: 25e3,
53940
54104
  maxDepth: 64,
@@ -53994,7 +54158,7 @@ function writeEditedPackage(parts, maxBytes, deadline, check) {
53994
54158
  check();
53995
54159
  zip.file(path, bytes, { createFolders: false });
53996
54160
  }
53997
- return new Promise((resolve, reject) => {
54161
+ return new Promise((resolve, reject2) => {
53998
54162
  const stream = zip.generateInternalStream({
53999
54163
  type: "uint8array",
54000
54164
  compression: "STORE",
@@ -54009,7 +54173,7 @@ function writeEditedPackage(parts, maxBytes, deadline, check) {
54009
54173
  stream.pause();
54010
54174
  chunks = [];
54011
54175
  clearTimeout(timer);
54012
- reject(error);
54176
+ reject2(error);
54013
54177
  };
54014
54178
  const timer = setTimeout(() => {
54015
54179
  try {
@@ -54124,7 +54288,7 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
54124
54288
  if (/[\u0000-\u0008\u000b\u000c\u000d\u000e-\u001f\ufffe\uffff]|[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/u.test(value)) fail("INVALID_EDIT_TEXT", "Replacement text contains invalid XML characters.");
54125
54289
  return value;
54126
54290
  };
54127
- const numeric4 = (value, dimension = false) => {
54291
+ const numeric5 = (value, dimension = false) => {
54128
54292
  if (typeof value !== "number" || !Number.isFinite(value) || Math.abs(value) > 1e6 || dimension && value <= 0) fail("INVALID_EDIT", "Geometry requires finite drawing inches within limits and positive dimensions.");
54129
54293
  return value;
54130
54294
  };
@@ -54144,23 +54308,23 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
54144
54308
  case "create-rectangle": return {
54145
54309
  ...target,
54146
54310
  type: edit.type,
54147
- x: numeric4(edit.x),
54148
- y: numeric4(edit.y),
54149
- width: numeric4(edit.width, true),
54150
- height: numeric4(edit.height, true),
54311
+ x: numeric5(edit.x),
54312
+ y: numeric5(edit.y),
54313
+ width: numeric5(edit.width, true),
54314
+ height: numeric5(edit.height, true),
54151
54315
  ...edit.text === void 0 ? {} : { text: text(edit.text) }
54152
54316
  };
54153
54317
  case "move-shape": return {
54154
54318
  ...target,
54155
54319
  type: edit.type,
54156
- x: numeric4(edit.x),
54157
- y: numeric4(edit.y)
54320
+ x: numeric5(edit.x),
54321
+ y: numeric5(edit.y)
54158
54322
  };
54159
54323
  case "resize-shape": return {
54160
54324
  ...target,
54161
54325
  type: edit.type,
54162
- width: numeric4(edit.width, true),
54163
- height: numeric4(edit.height, true)
54326
+ width: numeric5(edit.width, true),
54327
+ height: numeric5(edit.height, true)
54164
54328
  };
54165
54329
  case "delete-shape": return {
54166
54330
  ...target,
@@ -54561,16 +54725,16 @@ var units = {
54561
54725
  };
54562
54726
  function visioFormulaCachedValue(value, unit) {
54563
54727
  if (!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i.test(value.trim())) return formulaFailure("value", "Non-numeric cell cache");
54564
- const numeric4 = Number(value);
54565
- if (!Number.isFinite(numeric4)) return formulaFailure("value", "Non-finite cell cache");
54728
+ const numeric5 = Number(value);
54729
+ if (!Number.isFinite(numeric5)) return formulaFailure("value", "Non-finite cell cache");
54566
54730
  if (!unit || unit === "NUM" || unit === "BOOL") return {
54567
- value: numeric4,
54731
+ value: numeric5,
54568
54732
  unit: "scalar"
54569
54733
  };
54570
54734
  const definition = Object.hasOwn(units, unit.toUpperCase()) ? units[unit.toUpperCase()] : void 0;
54571
54735
  if (!definition) return formulaFailure("unit", `Unsupported unit ${unit}`);
54572
54736
  return {
54573
- value: numeric4,
54737
+ value: numeric5,
54574
54738
  unit: definition[0]
54575
54739
  };
54576
54740
  }
@@ -54911,7 +55075,7 @@ function recalculateVisioCells(roots, changed, options = {}) {
54911
55075
  if (active.has(id)) fail("EDIT_FORMULA_CYCLE", "Affected ShapeSheet dependency cycle.");
54912
55076
  if (active.size >= maxDepth) fail("LIMIT_FORMULA_DEPTH", "ShapeSheet dependency depth limit exceeded.");
54913
55077
  const item = cells3.get(id);
54914
- if (!item || item.unsafe) fail("EDIT_UNSUPPORTED_DEPENDENCY", "Affected formula references missing, inherited or grouped cells.");
55078
+ if (!item || item.unsafe && (!item.node || !options.masterMovePins?.has(item.node))) fail("EDIT_UNSUPPORTED_DEPENDENCY", "Affected formula references missing, inherited or grouped cells.");
54915
55079
  if (item.node?.hasAttribute("E")) fail("EDIT_FORMULA_ERROR", "Affected ShapeSheet cell has an error cache.");
54916
55080
  active.add(id);
54917
55081
  let result;
@@ -55000,7 +55164,7 @@ var locks = [
55000
55164
  "LockDelete"
55001
55165
  ];
55002
55166
  var cells = (shape) => new Map(children(shape, "Cell").map((node) => [attribute2(node, "N") ?? "", node]));
55003
- function numeric3(node, fallback) {
55167
+ function numeric4(node, fallback) {
55004
55168
  if (!node && fallback !== void 0) return fallback;
55005
55169
  if (!node || node.hasAttribute("E")) fail("UNSUPPORTED_GEOMETRY_EDIT", "A usable local numeric transform cache is required.");
55006
55170
  const value = visioFormulaCachedValue(attribute2(node, "V") ?? "", attribute2(node, "U")).value;
@@ -55030,13 +55194,16 @@ function setCell(shape, name, value, formula) {
55030
55194
  if (formula) node.setAttribute("F", formula);
55031
55195
  else if (attribute2(node, "F") !== "No Formula") node.removeAttribute("F");
55032
55196
  }
55033
- function admitted(root, shapeId) {
55197
+ function admitted(root, shapeId, masterMovePins = /* @__PURE__ */ new Set(), masterDimensions = /* @__PURE__ */ new Map()) {
55034
55198
  const containers = children(root, "Shapes");
55035
55199
  if (containers.length !== 1) fail("UNSUPPORTED_GEOMETRY_EDIT", "One local Shapes container is required.");
55036
55200
  const candidates = children(containers[0], "Shape").filter((node) => attribute2(node, "ID") === shapeId);
55037
55201
  if (candidates.length !== 1) fail("EDIT_TARGET_NOT_FOUND", "A unique top-level local shape is required.");
55038
55202
  const shape = candidates[0];
55039
- if (shape.hasAttribute("Master") || shape.hasAttribute("MasterShape") || ["1", "true"].includes(attribute2(shape, "Del") ?? "") || children(shape, "Shapes").length || children(shape, "ForeignData").length || children(shape, "Rel").length || attribute2(shape, "Type") && attribute2(shape, "Type") !== "Shape") fail("UNSUPPORTED_GEOMETRY_EDIT", "Master, group, foreign, deleted and non-shape operations are unsupported.");
55203
+ if ((shape.hasAttribute("Master") || shape.hasAttribute("MasterShape")) && !["PinX", "PinY"].every((name) => {
55204
+ const cell = cells(shape).get(name);
55205
+ return cell && masterMovePins.has(cell);
55206
+ }) || ["1", "true"].includes(attribute2(shape, "Del") ?? "") || children(shape, "Shapes").length || children(shape, "ForeignData").length || children(shape, "Rel").length || attribute2(shape, "Type") && attribute2(shape, "Type") !== "Shape") fail("UNSUPPORTED_GEOMETRY_EDIT", "Master, group, foreign, deleted and non-shape operations are unsupported.");
55040
55207
  const local = cells(shape);
55041
55208
  for (const name of [
55042
55209
  "Width",
@@ -55049,34 +55216,46 @@ function admitted(root, shapeId) {
55049
55216
  const unit = attribute2(local.get(name), "U");
55050
55217
  if (unit && visioFormulaCachedValue("0", unit).unit !== "length") fail("EDIT_FORMULA_UNIT", "Transform cells must use length units.");
55051
55218
  }
55052
- if (numeric3(local.get("OneD"), 0) !== 0 || [
55219
+ if (numeric4(local.get("OneD"), 0) !== 0 || [
55053
55220
  "BeginX",
55054
55221
  "BeginY",
55055
55222
  "EndX",
55056
55223
  "EndY"
55057
55224
  ].some((name) => local.has(name))) fail("UNSUPPORTED_GEOMETRY_EDIT", "Only local 2D shapes are admitted; line routing and glue are unsupported.");
55058
- if (!(numeric3(local.get("Width")) > 0) || !(numeric3(local.get("Height")) > 0)) fail("UNSUPPORTED_GEOMETRY_EDIT", "Positive local Width and Height caches are required.");
55225
+ const proven = masterDimensions.get(shape);
55226
+ if (!(numeric4(local.get("Width"), proven?.width) > 0) || !(numeric4(local.get("Height"), proven?.height) > 0)) fail("UNSUPPORTED_GEOMETRY_EDIT", "Positive proven Width and Height caches are required.");
55059
55227
  return shape;
55060
55228
  }
55061
- function protectedShape(shape, document) {
55229
+ function protectedShape(shape, document, masterMovePins = /* @__PURE__ */ new Set()) {
55062
55230
  const local = cells(shape);
55231
+ const certifiedMove = shape.hasAttribute("Master") && ["PinX", "PinY"].every((name) => {
55232
+ const node = local.get(name);
55233
+ return node !== void 0 && masterMovePins.has(node);
55234
+ });
55063
55235
  const styles = /* @__PURE__ */ new Map();
55064
55236
  for (const container of children(document, "StyleSheets")) for (const node of children(container, "StyleSheet")) {
55065
55237
  const id = attribute2(node, "ID");
55066
55238
  if (!id || styles.has(id)) fail("EDIT_PROTECTED_CELL", "Ambiguous protection style IDs.");
55067
55239
  styles.set(id, node);
55068
55240
  }
55069
- const inactive = (cell) => {
55241
+ const validateProtection = (cell) => {
55070
55242
  try {
55071
- if (cell.hasAttribute("E") || visioFormulaCachedValue(attribute2(cell, "V") ?? "", attribute2(cell, "U")).unit !== "scalar" || numeric3(cell) !== 0) fail("EDIT_PROTECTED_CELL", "Inherited protection is active or invalid.");
55243
+ const cached2 = numeric4(cell);
55244
+ const operationIndependent = certifiedMove && [
55245
+ "LockWidth",
55246
+ "LockHeight",
55247
+ "LockAspect",
55248
+ "LockDelete"
55249
+ ].includes(attribute2(cell, "N") ?? "");
55250
+ if (cell.hasAttribute("E") || visioFormulaCachedValue(attribute2(cell, "V") ?? "", attribute2(cell, "U")).unit !== "scalar" || !(cached2 === 0 || operationIndependent && cached2 === 1)) fail("EDIT_PROTECTED_CELL", "Inherited protection is active or invalid.");
55072
55251
  const source = executableCellFormula(attribute2(cell, "F"));
55073
55252
  if (!source) return;
55074
55253
  const analysis = analyzeVisioFormula(source);
55075
55254
  if (analysis.dynamic || analysis.references.length || analysis.unsupportedFunctions.length) fail("EDIT_PROTECTED_CELL", "Inherited protection formula cannot be resolved safely.");
55076
55255
  const result = evaluateVisioFormula(source, () => fail("EDIT_PROTECTED_CELL", "Inherited protection has dependencies."));
55077
- if (result.unit !== "scalar" || result.value !== 0) fail("EDIT_PROTECTED_CELL", "Inherited protection formula is active or stale.");
55256
+ if (result.unit !== "scalar" || result.value !== cached2) fail("EDIT_PROTECTED_CELL", "Inherited protection formula cache is stale.");
55078
55257
  } catch (error) {
55079
- fail("EDIT_PROTECTED_CELL", `Inherited protection cannot be proven inactive: ${error instanceof Error ? error.message : "invalid cache"}`);
55258
+ fail("EDIT_PROTECTED_CELL", `Inherited protection cannot be proven safe for this operation: ${error instanceof Error ? error.message : "invalid cache"}`);
55080
55259
  }
55081
55260
  };
55082
55261
  const resolve = (id, category, lock, seen = /* @__PURE__ */ new Set()) => {
@@ -55086,14 +55265,15 @@ function protectedShape(shape, document) {
55086
55265
  if (!style) fail("EDIT_PROTECTED_CELL", "Protection style ancestry cannot be resolved.");
55087
55266
  const cell = cells(style).get(lock), parent = attribute2(style, category);
55088
55267
  if (cell && attribute2(cell, "F") !== "Inh") {
55089
- inactive(cell);
55268
+ validateProtection(cell);
55090
55269
  return cell;
55091
55270
  }
55092
55271
  if (cell) {
55093
- inactive(cell);
55272
+ validateProtection(cell);
55094
55273
  if (parent === void 0 || parent === id) fail("EDIT_PROTECTED_CELL", "Inherited protection has no provable parent.");
55095
55274
  const inherited = resolve(parent, category, lock, seen);
55096
- if (!inherited) fail("EDIT_PROTECTED_CELL", "Inherited protection has no explicit inactive ancestor.");
55275
+ if (!inherited) fail("EDIT_PROTECTED_CELL", "Inherited protection has no explicit provable ancestor.");
55276
+ if (numeric4(cell) !== numeric4(inherited)) fail("EDIT_PROTECTED_CELL", "Delegated protection cache disagrees with its ancestor.");
55097
55277
  return inherited;
55098
55278
  }
55099
55279
  return parent !== void 0 && parent !== id ? resolve(parent, category, lock, seen) : void 0;
@@ -55118,7 +55298,7 @@ function protectedShape(shape, document) {
55118
55298
  const analysis = analyzeVisioFormula(formula);
55119
55299
  if (analysis.dynamic || analysis.references.length || analysis.unsupportedFunctions.length) fail("EDIT_PROTECTED_CELL", "Protection formula cannot be resolved safely.");
55120
55300
  const result = evaluateVisioFormula(formula, () => fail("EDIT_PROTECTED_CELL", "Protection dependency is unsupported."));
55121
- if (result.unit !== "scalar" || result.value !== numeric3(cell)) fail("EDIT_PROTECTED_CELL", "Protection cache is stale.");
55301
+ if (result.unit !== "scalar" || result.value !== numeric4(cell)) fail("EDIT_PROTECTED_CELL", "Protection cache is stale.");
55122
55302
  }
55123
55303
  }
55124
55304
  }
@@ -55139,9 +55319,9 @@ function resizeGeometry(shape, roots, edit, check) {
55139
55319
  if (!["X", "Y"].includes(attribute2(node, "N") ?? "")) fail("UNSUPPORTED_GEOMETRY_EDIT", "Unknown geometry row cells are unsupported.");
55140
55320
  if ((type ?? "").startsWith("Rel")) continue;
55141
55321
  const formula = executableCellFormula(attribute2(node, "F"));
55142
- if (!formula && numeric3(node) === 0) continue;
55322
+ if (!formula && numeric4(node) === 0) continue;
55143
55323
  if (!formula) fail("UNSUPPORTED_GEOMETRY_EDIT", "Absolute geometry needs a provable dimension-dependent formula.");
55144
- if (!analyzeVisioFormula(formula).references.length && numeric3(node) === 0) continue;
55324
+ if (!analyzeVisioFormula(formula).references.length && numeric4(node) === 0) continue;
55145
55325
  const cell = `Geometry${Number(attribute2(section, "IX") ?? "0") + 1}.${attribute2(node, "N")}${attribute2(row, "IX")}`;
55146
55326
  if (!visioCellDependsOn(roots, {
55147
55327
  pageId: edit.pageId,
@@ -55156,6 +55336,117 @@ function resizeGeometry(shape, roots, edit, check) {
55156
55336
  }
55157
55337
  }
55158
55338
  }
55339
+ var protection = [
55340
+ "LockMoveX",
55341
+ "LockMoveY",
55342
+ "LockWidth",
55343
+ "LockHeight",
55344
+ "LockAspect",
55345
+ "LockDelete"
55346
+ ];
55347
+ var dimensions2 = [
55348
+ "PinX",
55349
+ "PinY",
55350
+ "Width",
55351
+ "Height",
55352
+ "LocPinX",
55353
+ "LocPinY"
55354
+ ];
55355
+ var emptyMasterMoveProof = () => ({
55356
+ pins: /* @__PURE__ */ new Set(),
55357
+ dimensions: /* @__PURE__ */ new Map()
55358
+ });
55359
+ function prepareMasterMovePins(roots, commands, bindings, check) {
55360
+ const result = /* @__PURE__ */ new Set();
55361
+ const provenDimensions = /* @__PURE__ */ new Map();
55362
+ let work = 1e5;
55363
+ const charge = (amount = 1) => {
55364
+ check();
55365
+ work -= amount;
55366
+ if (work < 0) fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Master move preparation budget exceeded.");
55367
+ };
55368
+ const analyze = (formula) => {
55369
+ charge(formula.length);
55370
+ return analyzeVisioFormula(formula);
55371
+ };
55372
+ for (const command2 of commands) {
55373
+ charge();
55374
+ const instance = children(children(roots.get(command2.pageId), "Shapes")[0], "Shape").find((shape) => attribute2(shape, "ID") === command2.shapeId);
55375
+ if (!instance?.hasAttribute("Master")) continue;
55376
+ if (command2.type !== "move-shape") fail("UNSUPPORTED_GEOMETRY_EDIT", "Master-linked resizing and deletion remain unsupported.");
55377
+ const binding = bindings.find((candidate) => candidate.instance === instance);
55378
+ if (!binding) fail("UNSUPPORTED_GEOMETRY_EDIT", "A unique effective master root is required.");
55379
+ for (const node of [instance, binding.template]) {
55380
+ charge();
55381
+ if (attribute2(node, "Type") !== "Shape" || children(node, "Shapes").length || children(node, "ForeignData").length || children(node, "Rel").length || ["1", "true"].includes(attribute2(node, "Del") ?? "")) fail("UNSUPPORTED_GEOMETRY_EDIT", "Master moves require top-level local 2D shape roots.");
55382
+ }
55383
+ for (const name of [
55384
+ "BeginX",
55385
+ "BeginY",
55386
+ "EndX",
55387
+ "EndY"
55388
+ ]) if (binding.cells.has(name.toLowerCase())) fail("UNSUPPORTED_GEOMETRY_EDIT", "Master lines and endpoint routing remain unsupported.");
55389
+ const oneD = binding.cells.get("oned")?.node;
55390
+ charge();
55391
+ if (oneD && (numeric4(oneD) !== 0 || visioFormulaCachedValue(attribute2(oneD, "V") ?? "", attribute2(oneD, "U")).unit !== "scalar" || executableCellFormula(attribute2(oneD, "F")))) fail("UNSUPPORTED_GEOMETRY_EDIT", "A static effective 2D master is required.");
55392
+ const local = cells(instance);
55393
+ for (const name of dimensions2) {
55394
+ const effective = binding.cells.get(name.toLowerCase())?.node;
55395
+ for (const node of /* @__PURE__ */ new Set([effective, ...local.has(name) ? [local.get(name)] : []])) {
55396
+ charge();
55397
+ numeric4(node);
55398
+ if (visioFormulaCachedValue("0", attribute2(node, "U") ?? "DL").unit !== "length") fail("EDIT_FORMULA_UNIT", "Master transform caches require length units.");
55399
+ }
55400
+ }
55401
+ const dimension = (name) => numeric4(local.get(name) ?? binding.cells.get(name.toLowerCase())?.node);
55402
+ const width = dimension("Width"), height = dimension("Height");
55403
+ if (width <= 0 || height <= 0) fail("UNSUPPORTED_GEOMETRY_EDIT", "Positive proven effective dimensions are required.");
55404
+ provenDimensions.set(instance, {
55405
+ width,
55406
+ height
55407
+ });
55408
+ for (const name of protection) {
55409
+ charge();
55410
+ const node = binding.cells.get(name.toLowerCase())?.node;
55411
+ const cached2 = node ? numeric4(node) : NaN;
55412
+ const moving = name === "LockMoveX" || name === "LockMoveY";
55413
+ if (!node || visioFormulaCachedValue(attribute2(node, "V") ?? "", attribute2(node, "U")).unit !== "scalar" || ![0, 1].includes(cached2) || moving && cached2 !== 0) fail("EDIT_PROTECTED_CELL", "Effective master protection must be proven boolean with inactive movement locks.");
55414
+ const formula = executableCellFormula(attribute2(node, "F"));
55415
+ if (formula) {
55416
+ const analysis = analyze(formula);
55417
+ if (analysis.dynamic || analysis.references.length || analysis.unsupportedFunctions.length) fail("EDIT_PROTECTED_CELL", "Effective master protection dependencies are unsupported.");
55418
+ const value = evaluateVisioFormula(formula, () => fail("EDIT_PROTECTED_CELL", "Unexpected protection dependency."), { onStep: () => charge() });
55419
+ if (value.unit !== "scalar" || value.value !== cached2) fail("EDIT_PROTECTED_CELL", "Effective master protection cache is stale.");
55420
+ }
55421
+ }
55422
+ for (const name of ["PinX", "PinY"]) {
55423
+ charge();
55424
+ const node = local.get(name);
55425
+ if (!node) fail("EDIT_PROTECTED_CELL", "The rotation pin must be an explicit local override.");
55426
+ if (binding.cells.get(name.toLowerCase())?.node !== node) fail("EDIT_PROTECTED_CELL", "The rotation pin must be an explicit local override.");
55427
+ charge(executableCellFormula(attribute2(node, "F"))?.length ?? 0);
55428
+ editableCell(node);
55429
+ const inherited = binding.inheritedCells.get(name.toLowerCase())?.node;
55430
+ numeric4(inherited);
55431
+ if (visioFormulaCachedValue("0", attribute2(inherited, "U") ?? "DL").unit !== "length") fail("EDIT_FORMULA_UNIT", "Inherited rotation pins require length units.");
55432
+ const formula = executableCellFormula(attribute2(inherited, "F"));
55433
+ if (formula) {
55434
+ const analysis = analyze(formula);
55435
+ if (analysis.guarded || analysis.dynamic || analysis.unsupportedFunctions.length) fail("EDIT_PROTECTED_CELL", "Protected or redirected master pins cannot be overridden.");
55436
+ }
55437
+ result.add(node);
55438
+ }
55439
+ }
55440
+ if (result.size) {
55441
+ const indexed = indexCells(roots, { check });
55442
+ const pins = new Set([...indexed.values()].filter((cell) => cell.node && result.has(cell.node)).map(key));
55443
+ for (const cell of indexed.values()) if (charge(), cell.dependencies.some((dependency) => pins.has(dependency))) fail("EDIT_UNSUPPORTED_DEPENDENCY", "A page cache depends on a master rotation pin.");
55444
+ }
55445
+ return {
55446
+ pins: result,
55447
+ dimensions: provenDimensions
55448
+ };
55449
+ }
55159
55450
  function createRectangle(root, edit) {
55160
55451
  const doc = root.ownerDocument;
55161
55452
  const node = (name) => doc.createElementNS(root.namespaceURI, name);
@@ -55209,7 +55500,8 @@ function createRectangle(root, edit) {
55209
55500
  container.appendChild(shape);
55210
55501
  return shape;
55211
55502
  }
55212
- function applyGeometryEdit(roots, document, edit, check) {
55503
+ function applyGeometryEdit(roots, document, edit, check, masterMoveProof = emptyMasterMoveProof()) {
55504
+ const masterMovePins = masterMoveProof.pins, masterDimensions = masterMoveProof.dimensions;
55213
55505
  check();
55214
55506
  const root = roots.get(edit.pageId);
55215
55507
  if (!root) fail("EDIT_TARGET_NOT_FOUND", "Page does not exist.");
@@ -55235,14 +55527,14 @@ function applyGeometryEdit(roots, document, edit, check) {
55235
55527
  "PinY"
55236
55528
  ]) add(name);
55237
55529
  } else {
55238
- const shape = admitted(root, edit.shapeId);
55239
- protectedShape(shape, document);
55530
+ const shape = admitted(root, edit.shapeId, edit.type === "move-shape" ? masterMovePins : /* @__PURE__ */ new Set(), edit.type === "move-shape" ? masterDimensions : /* @__PURE__ */ new Map());
55531
+ protectedShape(shape, document, edit.type === "move-shape" ? masterMovePins : /* @__PURE__ */ new Set());
55240
55532
  if (edit.type !== "delete-shape") {
55241
55533
  for (const connections2 of children(root, "Connects")) for (const connection of children(connections2, "Connect")) if (["FromSheet", "ToSheet"].some((name) => attribute2(connection, name) === edit.shapeId)) fail("UNSUPPORTED_GEOMETRY_EDIT", "Glued connections need routing and endpoint recalculation outside this subset.");
55242
55534
  }
55243
55535
  const local = cells(shape);
55244
55536
  const unlocked = (name) => {
55245
- if (numeric3(local.get(name), 0) !== 0) fail("EDIT_PROTECTED_CELL", `${name} prevents this operation.`);
55537
+ if (numeric4(local.get(name), 0) !== 0) fail("EDIT_PROTECTED_CELL", `${name} prevents this operation.`);
55246
55538
  };
55247
55539
  if (edit.type === "delete-shape") {
55248
55540
  unlocked("LockDelete");
@@ -55251,9 +55543,10 @@ function applyGeometryEdit(roots, document, edit, check) {
55251
55543
  return [edit.pageId];
55252
55544
  }
55253
55545
  if (edit.type === "move-shape") {
55546
+ const proven = masterDimensions.get(shape);
55254
55547
  expected = {
55255
- width: numeric3(local.get("Width")),
55256
- height: numeric3(local.get("Height")),
55548
+ width: numeric4(local.get("Width"), proven?.width),
55549
+ height: numeric4(local.get("Height"), proven?.height),
55257
55550
  x: edit.x,
55258
55551
  y: edit.y
55259
55552
  };
@@ -55266,23 +55559,23 @@ function applyGeometryEdit(roots, document, edit, check) {
55266
55559
  edit.y,
55267
55560
  "LockMoveY"
55268
55561
  ]]) {
55269
- if (numeric3(local.get(name), name === "PinX" ? numeric3(local.get("Width")) / 2 : numeric3(local.get("Height")) / 2) === value) continue;
55562
+ if (numeric4(local.get(name), name === "PinX" ? expected.width / 2 : expected.height / 2) === value) continue;
55270
55563
  unlocked(lock);
55271
55564
  editableCell(local.get(name));
55272
55565
  setCell(shape, name, value);
55273
55566
  add(name);
55274
55567
  }
55275
55568
  } else {
55276
- const width = numeric3(local.get("Width")), height = numeric3(local.get("Height"));
55569
+ const width = numeric4(local.get("Width")), height = numeric4(local.get("Height"));
55277
55570
  expected = {
55278
55571
  width: edit.width,
55279
55572
  height: edit.height,
55280
- x: numeric3(local.get("PinX"), width / 2),
55281
- y: numeric3(local.get("PinY"), height / 2)
55573
+ x: numeric4(local.get("PinX"), width / 2),
55574
+ y: numeric4(local.get("PinY"), height / 2)
55282
55575
  };
55283
55576
  if (width === edit.width && height === edit.height) return [];
55284
55577
  resizeGeometry(shape, roots, edit, check);
55285
- if (numeric3(local.get("LockAspect"), 0) !== 0 && Math.abs(edit.width / width - edit.height / height) > 1e-9) fail("EDIT_PROTECTED_CELL", "LockAspect prevents changing the aspect ratio.");
55578
+ if (numeric4(local.get("LockAspect"), 0) !== 0 && Math.abs(edit.width / width - edit.height / height) > 1e-9) fail("EDIT_PROTECTED_CELL", "LockAspect prevents changing the aspect ratio.");
55286
55579
  for (const [name, value] of [["PinX", width / 2], ["PinY", height / 2]]) if (!local.has(name)) setCell(shape, name, value);
55287
55580
  for (const [name, value, lock] of [[
55288
55581
  "Width",
@@ -55293,7 +55586,7 @@ function applyGeometryEdit(roots, document, edit, check) {
55293
55586
  edit.height,
55294
55587
  "LockHeight"
55295
55588
  ]]) {
55296
- if (numeric3(local.get(name)) === value) continue;
55589
+ if (numeric4(local.get(name)) === value) continue;
55297
55590
  unlocked(lock);
55298
55591
  editableCell(local.get(name));
55299
55592
  setCell(shape, name, value);
@@ -55311,9 +55604,13 @@ function applyGeometryEdit(roots, document, edit, check) {
55311
55604
  }
55312
55605
  }
55313
55606
  if (!changed.length) return [];
55314
- const affectedPages = recalculateVisioCells(roots, changed, { check });
55315
- const result = cells(admitted(root, edit.shapeId));
55316
- if (expected && (numeric3(result.get("Width")) !== expected.width || numeric3(result.get("Height")) !== expected.height || numeric3(result.get("PinX"), expected.width / 2) !== expected.x || numeric3(result.get("PinY"), expected.height / 2) !== expected.y)) fail("EDIT_UNSUPPORTED_DEPENDENCY", "Dependent formulas would violate the requested geometry or fixed rotation pin.");
55607
+ const affectedPages = recalculateVisioCells(roots, changed, {
55608
+ check,
55609
+ masterMovePins
55610
+ });
55611
+ const resultShape = admitted(root, edit.shapeId, edit.type === "move-shape" ? masterMovePins : /* @__PURE__ */ new Set(), edit.type === "move-shape" ? masterDimensions : /* @__PURE__ */ new Map());
55612
+ const result = cells(resultShape), provenResult = masterDimensions.get(resultShape);
55613
+ if (expected && (numeric4(result.get("Width"), provenResult?.width) !== expected.width || numeric4(result.get("Height"), provenResult?.height) !== expected.height || numeric4(result.get("PinX"), expected.width / 2) !== expected.x || numeric4(result.get("PinY"), expected.height / 2) !== expected.y)) fail("EDIT_UNSUPPORTED_DEPENDENCY", "Dependent formulas would violate the requested geometry or fixed rotation pin.");
55317
55614
  return [.../* @__PURE__ */ new Set([edit.pageId, ...affectedPages])];
55318
55615
  }
55319
55616
  function analyzeVisioMasterFormula(source, options) {
@@ -55373,6 +55670,19 @@ function analyzeVisioMasterFormula(source, options) {
55373
55670
  readsTheme
55374
55671
  };
55375
55672
  }
55673
+ function inheritedProtection(node, ancestor) {
55674
+ try {
55675
+ const boolean2 = (cell) => {
55676
+ if (!cell || cell.hasAttribute("E")) fail("EDIT_PROTECTED_CELL", "Inherited protection has an unresolved or error cache.");
55677
+ const value = visioFormulaCachedValue(attribute2(cell, "V") ?? "", attribute2(cell, "U"));
55678
+ if (value.unit !== "scalar" || ![0, 1].includes(value.value)) fail("EDIT_PROTECTED_CELL", "Inherited protection requires scalar boolean caches.");
55679
+ return value.value;
55680
+ };
55681
+ if (boolean2(node) !== boolean2(ancestor)) fail("EDIT_PROTECTED_CELL", "Delegated master style protection cache disagrees with its ancestor.");
55682
+ } catch (error) {
55683
+ fail("EDIT_PROTECTED_CELL", `Inherited master style protection cannot be proven: ${error instanceof Error ? error.message : "invalid cache"}`);
55684
+ }
55685
+ }
55376
55686
  function masterCells(sheet, charge = () => {}) {
55377
55687
  const result = /* @__PURE__ */ new Map();
55378
55688
  if (!sheet) return result;
@@ -55421,7 +55731,7 @@ function assertMasterMarkup(root, known, check) {
55421
55731
  if (node.namespaceURI === root.namespaceURI && node.hasAttribute("F") && !known.has(node)) fail("EDIT_UNSUPPORTED_PACKAGE_DEPENDENCY", "Master formula outside admitted sheet cells has unknown scope.");
55422
55732
  }
55423
55733
  }
55424
- function masterStyleCells(document, template, instance, check, charge = () => {}) {
55734
+ function masterStyleCells(document, template, instance, check, charge = () => {}, verifyMovementProtection = false) {
55425
55735
  const styles = /* @__PURE__ */ new Map();
55426
55736
  for (const container of children(document, "StyleSheets")) for (const style of children(container, "StyleSheet")) {
55427
55737
  charge();
@@ -55443,6 +55753,10 @@ function masterStyleCells(document, template, instance, check, charge = () => {}
55443
55753
  for (const [name, node] of own) {
55444
55754
  charge();
55445
55755
  if (attribute2(node, "F") !== "Inh") result2.set(name, node);
55756
+ else if (verifyMovementProtection && /^lock(move[xy]|width|height|aspect|delete)$/.test(name)) {
55757
+ charge();
55758
+ inheritedProtection(node, result2.get(name));
55759
+ }
55446
55760
  }
55447
55761
  return result2;
55448
55762
  };
@@ -55514,12 +55828,15 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55514
55828
  pageId,
55515
55829
  instance
55516
55830
  })));
55517
- if (!instances.length) return;
55831
+ if (!instances.length) return emptyMasterMoveProof();
55518
55832
  const documentPart = await related(pkg, "", "document");
55519
55833
  if (!documentPart) problem("Missing master document relationship.");
55520
55834
  const document = await visioXml(pkg, documentPart, "VisioDocument");
55521
55835
  const mastersPart = await related(pkg, documentPart, "masters", false);
55522
- if (!mastersPart) problem("Active master definitions are missing.");
55836
+ if (!mastersPart) {
55837
+ if (commands.some((command2) => instances.some((item) => item.pageId === command2.pageId && attribute2(item.instance, "ID") === command2.shapeId))) fail("UNSUPPORTED_GEOMETRY_EDIT", "Active master definitions are missing.");
55838
+ problem("Active master definitions are missing.");
55839
+ }
55523
55840
  const definitions = /* @__PURE__ */ new Map();
55524
55841
  for (const node of children(await visioXml(pkg, mastersPart, "Masters"), "Master")) {
55525
55842
  const id = attribute2(node, "ID");
@@ -55534,6 +55851,11 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55534
55851
  if (--buildWork < 0) problem("Master effective-cell construction budget exceeded.");
55535
55852
  };
55536
55853
  const pageBindings = /* @__PURE__ */ new Map();
55854
+ const movingTargets = /* @__PURE__ */ new Set();
55855
+ for (const command2 of commands) {
55856
+ charge();
55857
+ if (command2.type === "move-shape") movingTargets.add(JSON.stringify([command2.pageId, command2.shapeId]));
55858
+ }
55537
55859
  const pageShapes = /* @__PURE__ */ new Map();
55538
55860
  for (const [pageId, root] of roots) for (const shape of masterShapes(root)) {
55539
55861
  const id = attribute2(shape, "ID");
@@ -55580,17 +55902,20 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55580
55902
  const templateId = attribute2(template, "ID");
55581
55903
  if (!templateId || context.has(templateId)) problem("Master-local sheet IDs are ambiguous.");
55582
55904
  const local = byTemplate.get(templateId), cells3 = /* @__PURE__ */ new Map();
55583
- for (const [name, node] of masterStyleCells(document, template, local, check, charge)) cells3.set(name, {
55905
+ const movedInstance = local === instance && movingTargets.has(JSON.stringify([pageId, attribute2(local, "ID")]));
55906
+ for (const [name, node] of masterStyleCells(document, template, local, check, charge, movedInstance)) cells3.set(name, {
55584
55907
  node,
55585
55908
  kind: "style"
55586
55909
  });
55587
55910
  overlay(cells3, masterCells(template, charge), "template", charge);
55911
+ const inheritedCells = new Map(cells3);
55588
55912
  overlay(cells3, masterCells(local, charge), "instance", charge);
55589
55913
  const binding = {
55590
55914
  id: `${pageId}:${attribute2(instance, "ID")}:${templateId}`,
55591
55915
  pageId,
55592
55916
  template,
55593
55917
  cells: cells3,
55918
+ inheritedCells,
55594
55919
  context,
55595
55920
  ...local ? { instance: local } : {}
55596
55921
  };
@@ -55600,6 +55925,7 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55600
55925
  }
55601
55926
  for (const id of byTemplate.keys()) if (!context.has(id)) problem("MasterShape refers to a missing template.");
55602
55927
  }
55928
+ const movePins = prepareMasterMovePins(roots, commands, bindings, check);
55603
55929
  const changed = commands.flatMap((command2) => command2.type === "delete-shape" ? [] : (command2.type === "move-shape" ? ["PinX", "PinY"] : command2.type === "resize-shape" ? ["Width", "Height"] : [
55604
55930
  "Width",
55605
55931
  "Height",
@@ -55632,13 +55958,14 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55632
55958
  template: shape,
55633
55959
  instance: shape,
55634
55960
  cells: cells3,
55961
+ inheritedCells: /* @__PURE__ */ new Map(),
55635
55962
  context: /* @__PURE__ */ new Map()
55636
55963
  };
55637
55964
  pageInputs.set(id, result);
55638
55965
  return result;
55639
55966
  };
55640
55967
  let steps = 1e5;
55641
- const inspect2 = (binding, name) => {
55968
+ const inspect4 = (binding, name) => {
55642
55969
  check();
55643
55970
  if (--steps < 0) problem("Master dependency proof exceeded its cell budget.");
55644
55971
  name = name.toLowerCase();
@@ -55660,7 +55987,7 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55660
55987
  txtlocpinx: "txtwidth",
55661
55988
  txtlocpiny: "txtheight"
55662
55989
  }[name];
55663
- if (dimension) inspect2(binding, dimension);
55990
+ if (dimension) inspect4(binding, dimension);
55664
55991
  else if (!themeCell.test(name)) problem(`Missing effective master reference ${name}.`);
55665
55992
  } else {
55666
55993
  const formula = executableCellFormula(attribute2(source.node, "F"));
@@ -55676,11 +56003,11 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55676
56003
  if (analysis.dynamic) problem("Effective master formula has unknown dynamic dependencies.");
55677
56004
  for (const ref of analysis.references) {
55678
56005
  if (analysis.readsText && ref.shapeId === void 0 && ref.cell.toLowerCase() === "thetext") continue;
55679
- if (ref.shapeId === void 0) inspect2(binding, ref.cell);
56006
+ if (ref.shapeId === void 0) inspect4(binding, ref.cell);
55680
56007
  else if (source.kind === "template") {
55681
56008
  const target = binding.context.get(ref.shapeId);
55682
56009
  if (!target) problem("Missing master-local Sheet reference.");
55683
- inspect2(target, ref.cell);
56010
+ inspect4(target, ref.cell);
55684
56011
  } else {
55685
56012
  if (source.kind === "style") problem("Explicit sheet references in inherited master styles are ambiguous.");
55686
56013
  if (directAffected(binding.pageId, ref.shapeId, ref.cell) || query({
@@ -55688,18 +56015,23 @@ async function assertVisioMasterIndependence(pkg, roots, commands, check) {
55688
56015
  shapeId: ref.shapeId,
55689
56016
  cell: ref.cell
55690
56017
  }, changed)) problem("Effective master cache depends on an edited page shape.");
55691
- inspect2(pageInput(binding.pageId, ref.shapeId), ref.cell);
56018
+ inspect4(pageInput(binding.pageId, ref.shapeId), ref.cell);
55692
56019
  }
55693
56020
  }
55694
56021
  if (analysis.readsText) {
55695
- for (const cell of binding.cells.keys()) if (/^(character\.|paragraph\.|tabs\.|leftmargin$|rightmargin$|topmargin$|bottommargin$)/i.test(cell)) inspect2(binding, cell);
56022
+ for (const cell of binding.cells.keys()) if (/^(character\.|paragraph\.|tabs\.|leftmargin$|rightmargin$|topmargin$|bottommargin$)/i.test(cell)) inspect4(binding, cell);
55696
56023
  }
55697
56024
  }
55698
56025
  }
55699
56026
  active.delete(id);
55700
56027
  done.add(id);
55701
56028
  };
55702
- for (const binding of bindings) for (const name of binding.cells.keys()) inspect2(binding, name);
56029
+ for (const binding of bindings) for (const name of binding.cells.keys()) {
56030
+ const source = binding.cells.get(name);
56031
+ if (["pinx", "piny"].includes(name) && source?.kind === "instance" && movePins.pins.has(source.node)) continue;
56032
+ inspect4(binding, name);
56033
+ }
56034
+ return movePins;
55703
56035
  }
55704
56036
  var admitted2 = (node) => node.namespaceURI === VISIO_NS || node.namespaceURI === VISIO_LEGACY_NS;
55705
56037
  function cells2(sheet) {
@@ -55807,16 +56139,18 @@ async function assertGeometryPackageScope(pkg, pagePaths, commands, check, roots
55807
56139
  });
55808
56140
  }
55809
56141
  }
56142
+ let movePins = emptyMasterMoveProof();
55810
56143
  if (hasMasterInstances) {
55811
56144
  for (const command2 of commands) {
55812
56145
  const root = roots.get(command2.pageId);
55813
56146
  if (!root) continue;
55814
56147
  const target = Array.from(root.getElementsByTagNameNS(root.namespaceURI, "Shape")).find((shape) => attribute2(shape, "ID") === command2.shapeId);
55815
- if (target?.hasAttribute("Master") || target?.hasAttribute("MasterShape")) fail("UNSUPPORTED_GEOMETRY_EDIT", "Editing master-linked shapes is unsupported.");
56148
+ if (target?.hasAttribute("MasterShape") && !target.hasAttribute("Master")) fail("UNSUPPORTED_GEOMETRY_EDIT", "Editing master-linked shapes is unsupported.");
56149
+ if (target?.hasAttribute("Master") && (command2.type !== "move-shape" || !["PinX", "PinY"].every((name) => children(target, "Cell").some((node) => attribute2(node, "N") === name)))) fail("UNSUPPORTED_GEOMETRY_EDIT", "Master moves require explicit local rotation pins.");
55816
56150
  }
55817
- await assertVisioMasterIndependence(pkg, roots, commands, check);
56151
+ movePins = await assertVisioMasterIndependence(pkg, roots, commands, check);
55818
56152
  }
55819
- if (!documentRoot) return;
56153
+ if (!documentRoot) return movePins;
55820
56154
  const styles = /* @__PURE__ */ new Map();
55821
56155
  for (const container of children(documentRoot, "StyleSheets")) for (const style of children(container, "StyleSheet")) {
55822
56156
  const id = attribute2(style, "ID");
@@ -55882,6 +56216,7 @@ async function assertGeometryPackageScope(pkg, pagePaths, commands, check, roots
55882
56216
  }
55883
56217
  }
55884
56218
  }
56219
+ return movePins;
55885
56220
  }
55886
56221
  function positive(value) {
55887
56222
  if (!Number.isSafeInteger(value) || value <= 0) fail("INVALID_LIMITS", "Edit limits must be positive safe integers.");
@@ -55909,12 +56244,13 @@ async function editVsdx(input, edits, options = {}) {
55909
56244
  const roots = /* @__PURE__ */ new Map();
55910
56245
  const geometry = commands.some((command2) => command2.type !== "replace-plain-text");
55911
56246
  let document;
56247
+ let masterMovePins = emptyMasterMoveProof();
55912
56248
  if (geometry) {
55913
56249
  for (const [pageId, path2] of pages) {
55914
56250
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
55915
56251
  roots.set(pageId, sourceRoot.ownerDocument.cloneNode(true).documentElement);
55916
56252
  }
55917
- await assertGeometryPackageScope(pkg, new Set(pages.values()), commands.filter((command2) => command2.type !== "replace-plain-text"), check, roots);
56253
+ masterMovePins = await assertGeometryPackageScope(pkg, new Set(pages.values()), commands.filter((command2) => command2.type !== "replace-plain-text"), check, roots);
55918
56254
  document = await visioXml(pkg, await related(pkg, "", "document"), "VisioDocument");
55919
56255
  }
55920
56256
  let textChanged = false;
@@ -55932,7 +56268,7 @@ async function editVsdx(input, edits, options = {}) {
55932
56268
  dirty.set(path, root);
55933
56269
  textChanged = true;
55934
56270
  }
55935
- } else for (const pageId of applyGeometryEdit(roots, document, command2, check)) dirty.set(pages.get(pageId), roots.get(pageId));
56271
+ } else for (const pageId of applyGeometryEdit(roots, document, command2, check, masterMovePins)) dirty.set(pages.get(pageId), roots.get(pageId));
55936
56272
  }
55937
56273
  let totalBytes = [...parts.values()].reduce((sum, bytes2) => sum + bytes2.length, 0);
55938
56274
  let nodes = 0;