ooxml-core 1.10.0 → 1.11.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.
Files changed (162) hide show
  1. package/dist/PptxHandler-DNZHAHUY.cjs +12 -0
  2. package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
  3. package/dist/{PptxHandler-ADEFY476.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
  4. package/dist/automation/index.cjs +3293 -2867
  5. package/dist/automation/index.mjs +3293 -2867
  6. package/dist/{chunk-3N6XMMTT.cjs → chunk-2UVH6RHI.cjs} +1138 -996
  7. package/dist/{chunk-ZOUGMAZG.mjs → chunk-7DSZI7S6.mjs} +1 -1
  8. package/dist/{chunk-S6DOCMQC.cjs → chunk-7QZGRB3T.cjs} +0 -10
  9. package/dist/chunk-ANZ4Q6I3.cjs +21 -0
  10. package/dist/{chunk-5NVJN4E6.mjs → chunk-EC2W2MDY.mjs} +1 -1
  11. package/dist/chunk-EGTRL3QJ.mjs +19 -0
  12. package/dist/chunk-GXHKNSZX.mjs +9 -0
  13. package/dist/{chunk-CCHYFCPD.mjs → chunk-HCXUI5UC.mjs} +296 -103
  14. package/dist/chunk-HDQXPSHY.cjs +17 -0
  15. package/dist/chunk-KTYBFGEY.mjs +14 -0
  16. package/dist/chunk-QOO36KG4.cjs +42 -0
  17. package/dist/chunk-R2KZXD6U.mjs +39 -0
  18. package/dist/{chunk-A6P7G3UK.mjs → chunk-U2DF3EGK.mjs} +1 -1
  19. package/dist/{chunk-R6KSBNKX.mjs → chunk-UAY26XOI.mjs} +1 -9
  20. package/dist/{chunk-WUE5ZHU3.mjs → chunk-W5ARCUJB.mjs} +3 -3
  21. package/dist/chunk-XZPZHXV4.cjs +12 -0
  22. package/dist/{chunk-ZE53K7DH.mjs → chunk-YB5SRNFS.mjs} +244 -102
  23. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  24. package/dist/docx/layout/index.cjs +125 -56
  25. package/dist/docx/layout/index.mjs +125 -56
  26. package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
  27. package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
  28. package/dist/docx/layout/result.d.ts +7 -0
  29. package/dist/docx/layout/result.d.ts.map +1 -1
  30. package/dist/docx/layout/table-border-layout.d.ts +1 -1
  31. package/dist/docx/layout/table-border-layout.d.ts.map +1 -1
  32. package/dist/docx/layout/table-cell-layout.d.ts +1 -1
  33. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
  34. package/dist/docx/layout/table-frames.d.ts.map +1 -1
  35. package/dist/docx/layout/table-layout.d.ts +1 -1
  36. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  37. package/dist/pptx/automation/index.cjs +266 -114
  38. package/dist/pptx/automation/index.d.ts +5 -4
  39. package/dist/pptx/automation/index.d.ts.map +1 -1
  40. package/dist/pptx/automation/index.mjs +5 -5
  41. package/dist/pptx/chunks/{text-operations-BqHmLaLA.d.ts → elements-DD3UGOMd.d.ts} +17 -3262
  42. package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
  43. package/dist/pptx/chunks/{index-DUCGeZh7.d.ts → index-BZrFyNtU.d.ts} +53 -5
  44. package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
  45. package/dist/pptx/chunks/{index-Cuxtr76Y.d.ts → index-DdX02BSm.d.ts} +5 -3
  46. package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
  47. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
  48. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
  49. package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
  50. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
  51. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
  52. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
  53. package/dist/pptx/cli/index.cjs +266 -114
  54. package/dist/pptx/cli/index.d.ts +1 -1
  55. package/dist/pptx/cli/index.mjs +4 -4
  56. package/dist/pptx/converter/index.d.ts +1 -1
  57. package/dist/pptx/converter/index.mjs +2 -2
  58. package/dist/pptx/editor/render/find-replace.cjs +17 -16
  59. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  60. package/dist/pptx/editor/render/find-replace.mjs +2 -1
  61. package/dist/pptx/editor/render/font-family-update.cjs +14 -0
  62. package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
  63. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
  64. package/dist/pptx/editor/render/font-family-update.mjs +1 -0
  65. package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
  66. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
  67. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
  68. package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
  69. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  70. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  71. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  72. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  73. package/dist/pptx/editor/render/text-content-style.cjs +18 -0
  74. package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
  75. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
  76. package/dist/pptx/editor/render/text-content-style.mjs +5 -0
  77. package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
  78. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
  79. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
  80. package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
  81. package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
  82. package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
  83. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
  84. package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
  85. package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
  86. package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
  87. package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
  88. package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
  89. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
  90. package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
  91. package/dist/pptx/index.cjs +329 -114
  92. package/dist/pptx/index.d.ts +7 -5
  93. package/dist/pptx/index.mjs +5 -5
  94. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  95. package/dist/teams/index.cjs +112 -16
  96. package/dist/teams/index.mjs +112 -16
  97. package/dist/visio/edit-commands.d.ts +3 -3
  98. package/dist/visio/edit-commands.d.ts.map +1 -1
  99. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  100. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  101. package/dist/visio/edit-text-field-commands.d.ts +15 -0
  102. package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
  103. package/dist/visio/edit-text-field.d.ts +2 -2
  104. package/dist/visio/edit-text-field.d.ts.map +1 -1
  105. package/dist/visio/edit.d.ts +1 -1
  106. package/dist/visio/edit.d.ts.map +1 -1
  107. package/dist/visio/index.cjs +382 -210
  108. package/dist/visio/index.d.ts +1 -1
  109. package/dist/visio/index.d.ts.map +1 -1
  110. package/dist/visio/index.mjs +382 -210
  111. package/dist/visio/model.d.ts +6 -0
  112. package/dist/visio/model.d.ts.map +1 -1
  113. package/dist/visio/shapes.d.ts.map +1 -1
  114. package/dist/visio/style.d.ts +1 -1
  115. package/dist/visio/style.d.ts.map +1 -1
  116. package/dist/visio/text-field-display.d.ts +3 -0
  117. package/dist/visio/text-field-display.d.ts.map +1 -1
  118. package/dist/visio/text-field-editability.d.ts +6 -0
  119. package/dist/visio/text-field-editability.d.ts.map +1 -0
  120. package/dist/visio/text-field-independent.d.ts +4 -0
  121. package/dist/visio/text-field-independent.d.ts.map +1 -0
  122. package/dist/visio/text-field-source.d.ts +6 -0
  123. package/dist/visio/text-field-source.d.ts.map +1 -0
  124. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  125. package/dist/visio/ui/index.cjs +394 -211
  126. package/dist/visio/ui/index.mjs +394 -211
  127. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  128. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  129. package/dist/xlsx/index.cjs +773 -514
  130. package/dist/xlsx/index.mjs +772 -515
  131. package/dist/xlsx/load/index.cjs +541 -292
  132. package/dist/xlsx/load/index.mjs +541 -292
  133. package/dist/xlsx/model-pivots.d.ts +8 -0
  134. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  135. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  136. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  137. package/dist/xlsx/pivot/data.d.ts +2 -2
  138. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  139. package/dist/xlsx/pivot/index.d.ts +2 -0
  140. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  141. package/dist/xlsx/pivot/measures.d.ts +1 -1
  142. package/dist/xlsx/pivot/measures.d.ts.map +1 -1
  143. package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
  144. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
  145. package/dist/xlsx/pivot/page-filter.d.ts +11 -0
  146. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
  147. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  148. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  149. package/dist/xlsx/pivot/values-axis.d.ts +4 -1
  150. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -1
  151. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  152. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  153. package/dist/xlsx/ui/index.cjs +95 -12
  154. package/dist/xlsx/ui/index.mjs +95 -12
  155. package/package.json +2 -2
  156. package/dist/PptxHandler-5UURGJEV.mjs +0 -2
  157. package/dist/PptxHandler-U5XB2HUE.cjs +0 -11
  158. package/dist/pptx/chunks/index-Cuxtr76Y.d.ts.map +0 -1
  159. package/dist/pptx/chunks/index-DUCGeZh7.d.ts.map +0 -1
  160. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts +0 -2980
  161. package/dist/pptx/chunks/smart-art-D-sXa_Nb.d.ts.map +0 -1
  162. package/dist/pptx/chunks/text-operations-BqHmLaLA.d.ts.map +0 -1
@@ -3456,6 +3456,208 @@ function takeDeferredTextSizes(root2) {
3456
3456
  return shapes;
3457
3457
  }
3458
3458
 
3459
+ // visio/text-fields.ts
3460
+ var PROPERTY_FUNCTIONS = {
3461
+ TITLE: "title",
3462
+ SUBJECT: "subject",
3463
+ CREATOR: "creator",
3464
+ KEYWORDS: "keywords",
3465
+ DESCRIPTION: "description",
3466
+ CATEGORY: "category",
3467
+ COMPANY: "company",
3468
+ MANAGER: "manager"
3469
+ };
3470
+ var DATE_FUNCTIONS = {
3471
+ NOW: void 0,
3472
+ DOCCREATION: "created",
3473
+ DOCLASTSAVE: "modified",
3474
+ DOCLASTEDIT: "modified",
3475
+ DOCLASTPRINT: "lastPrinted"
3476
+ };
3477
+ var VISIO_FIELD_FUNCTIONS = [
3478
+ ...Object.keys(PROPERTY_FUNCTIONS),
3479
+ ...Object.keys(DATE_FUNCTIONS),
3480
+ "PAGENAME"
3481
+ ];
3482
+ function visioWallClock(date2) {
3483
+ return new Date(
3484
+ Date.UTC(
3485
+ date2.getFullYear(),
3486
+ date2.getMonth(),
3487
+ date2.getDate(),
3488
+ date2.getHours(),
3489
+ date2.getMinutes(),
3490
+ date2.getSeconds()
3491
+ )
3492
+ );
3493
+ }
3494
+ var EPOCH = Date.UTC(1899, 11, 30);
3495
+ var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
3496
+ function evaluateVisioTextField(formula, context) {
3497
+ let ast;
3498
+ try {
3499
+ ast = parseVisioFormula(formula, { maxLength: 4096 });
3500
+ } catch {
3501
+ return void 0;
3502
+ }
3503
+ if (ast.kind === "call") {
3504
+ const name3 = ast.name;
3505
+ if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
3506
+ const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
3507
+ return value === void 0 ? void 0 : { kind: "string", text: value };
3508
+ }
3509
+ if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
3510
+ if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
3511
+ const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
3512
+ const time = stamp ? Date.parse(stamp) : Number.NaN;
3513
+ return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
3514
+ }
3515
+ if (name3 === "PAGENAME" && ast.args.length <= 1)
3516
+ return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
3517
+ }
3518
+ try {
3519
+ const result = evaluateVisioFormula(
3520
+ ast,
3521
+ context.resolve ?? (() => {
3522
+ throw new Error("No cell context");
3523
+ }),
3524
+ {
3525
+ ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
3526
+ ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
3527
+ }
3528
+ );
3529
+ return { kind: "number", value: result.value, unit: result.unit };
3530
+ } catch {
3531
+ return void 0;
3532
+ }
3533
+ }
3534
+ var MONTHS = [
3535
+ "January",
3536
+ "February",
3537
+ "March",
3538
+ "April",
3539
+ "May",
3540
+ "June",
3541
+ "July",
3542
+ "August",
3543
+ "September",
3544
+ "October",
3545
+ "November",
3546
+ "December"
3547
+ ];
3548
+ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
3549
+ var pad = (value, length = 2) => String(value).padStart(length, "0");
3550
+ function dateToken(date2, token) {
3551
+ const hours = date2.getUTCHours();
3552
+ switch (token) {
3553
+ case "yyyy":
3554
+ return pad(date2.getUTCFullYear(), 4);
3555
+ case "yy":
3556
+ return pad(date2.getUTCFullYear() % 100);
3557
+ case "MMMM":
3558
+ return MONTHS[date2.getUTCMonth()];
3559
+ case "MMM":
3560
+ return MONTHS[date2.getUTCMonth()].slice(0, 3);
3561
+ case "MM":
3562
+ return pad(date2.getUTCMonth() + 1);
3563
+ case "M":
3564
+ return String(date2.getUTCMonth() + 1);
3565
+ case "dddd":
3566
+ return DAYS[date2.getUTCDay()];
3567
+ case "ddd":
3568
+ return DAYS[date2.getUTCDay()].slice(0, 3);
3569
+ case "dd":
3570
+ return pad(date2.getUTCDate());
3571
+ case "d":
3572
+ return String(date2.getUTCDate());
3573
+ case "HH":
3574
+ return pad(hours);
3575
+ case "H":
3576
+ return String(hours);
3577
+ case "hh":
3578
+ return pad(hours % 12 || 12);
3579
+ case "h":
3580
+ return String(hours % 12 || 12);
3581
+ case "mm":
3582
+ return pad(date2.getUTCMinutes());
3583
+ case "ss":
3584
+ return pad(date2.getUTCSeconds());
3585
+ case "tt":
3586
+ return hours < 12 ? "AM" : "PM";
3587
+ default:
3588
+ return void 0;
3589
+ }
3590
+ }
3591
+ function formatDate(date2, picture) {
3592
+ return picture.replace(
3593
+ /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
3594
+ (token) => {
3595
+ if (token.startsWith('"')) return token.slice(1, -1);
3596
+ return dateToken(date2, token) ?? token;
3597
+ }
3598
+ );
3599
+ }
3600
+ function formatNumber(value, picture) {
3601
+ const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
3602
+ if (!match) return void 0;
3603
+ const decimals = match[2]?.length ?? 0;
3604
+ const optional = match[2]?.startsWith("#") ?? false;
3605
+ const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
3606
+ const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
3607
+ const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
3608
+ let text5 = (Math.sign(value) * rounded).toFixed(decimals);
3609
+ if (optional && text5.includes(".")) text5 = text5.replace(/\.?0+$/, "");
3610
+ if (match[1]) {
3611
+ const [whole, fraction] = text5.split(".");
3612
+ text5 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
3613
+ }
3614
+ return text5 === "-0" ? "0" : text5;
3615
+ }
3616
+ var VISIO_FIELD_FORMATS = {
3617
+ shortDate: "{{M/d/yyyy}}",
3618
+ isoDate: "{{yyyy-MM-dd}}",
3619
+ longDate: "{{dddd, MMMM d, yyyy}}",
3620
+ time: "{{h:mm tt}}",
3621
+ dateTime: "{{M/d/yyyy h:mm tt}}",
3622
+ text: "@",
3623
+ integer: "0",
3624
+ decimal: "0.00",
3625
+ decimalUnits: "0.00 u",
3626
+ integerUnits: "0 u"
3627
+ };
3628
+ function formatVisioFieldValue(value, format4 = "") {
3629
+ const picture = format4.trim();
3630
+ if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
3631
+ if (value.kind === "date") {
3632
+ const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
3633
+ return date2 === void 0 ? void 0 : formatDate(value.date, date2);
3634
+ }
3635
+ const units2 = / u$/.test(picture);
3636
+ const body = picture.replace(/ u$/, "");
3637
+ let number5 = value.value, suffix = "";
3638
+ if (value.unit === "angle") {
3639
+ number5 = number5 * 180 / Math.PI;
3640
+ suffix = " deg.";
3641
+ } else if (value.unit === "length") suffix = " in.";
3642
+ else if (value.unit !== "scalar") return void 0;
3643
+ const text5 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
3644
+ if (text5 === void 0) return void 0;
3645
+ return units2 || body === "" ? `${text5}${suffix}` : text5;
3646
+ }
3647
+
3648
+ // visio/text-field-independent.ts
3649
+ function independentTextFieldFormula(cell, formula) {
3650
+ const row2 = cell.parentNode, section3 = row2?.parentNode;
3651
+ if (cell.localName !== "Cell" || row2?.localName !== "Row" || section3?.localName !== "Section" || attribute2(section3, "N") !== "Field" || row2.hasAttribute("Del") || section3.hasAttribute("Del") || row2.hasAttribute("N") || row2.hasAttribute("T") || !/^(0|[1-9]\d*)$/.test(attribute2(row2, "IX") ?? "0") || (attribute2(section3, "IX") ?? "0") !== "0" || cell.hasAttribute("E"))
3652
+ return false;
3653
+ if (attribute2(cell, "N") === "Format")
3654
+ return /^\s*FIELDPICTURE\(\s*(2|37|204)\s*\)\s*$/i.test(formula);
3655
+ if (attribute2(cell, "N") !== "Value") return false;
3656
+ if (/^\s*DATE\(\s*\d{1,4}\s*,\s*\d{1,2}\s*,\s*\d{1,2}\s*\)\s*$/i.test(formula)) return true;
3657
+ const direct = /^\s*([A-Z]+)\(\s*\)\s*$/i.exec(formula)?.[1]?.toUpperCase();
3658
+ return direct !== void 0 && VISIO_FIELD_FUNCTIONS.includes(direct);
3659
+ }
3660
+
3459
3661
  // visio/edit-connector-glue.ts
3460
3662
  var VISIO_WALK_GLUE = "_WALKGLUE(BegTrigger,EndTrigger,WalkPreference)";
3461
3663
  var walkGlue = /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i;
@@ -3565,7 +3767,7 @@ function indexCells(roots, options) {
3565
3767
  unit: cellUnit(cell, relative)
3566
3768
  };
3567
3769
  const source = attribute2(node2, "F");
3568
- if (executableCellFormula(source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
3770
+ if (executableCellFormula(source) && !independentTextFieldFormula(node2, source) && !inertDoubleClickFormula(cell, source) && !(glue2 && isNativeGlueCell(cell, source)) && // A trigger only counts events of the sheet it names; an unglued connector keeps one
3569
3771
  // (Visio's freshly dropped connector names its own sheet).
3570
3772
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
3571
3773
  try {
@@ -6782,6 +6984,77 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
6782
6984
  }
6783
6985
  }
6784
6986
 
6987
+ // visio/text-field-source.ts
6988
+ var proofs = /* @__PURE__ */ new WeakMap();
6989
+ function textFieldSourceKey(cells4) {
6990
+ if (proofs.has(cells4)) return proofs.get(cells4);
6991
+ if (cells4.size > 64) {
6992
+ proofs.set(cells4, void 0);
6993
+ return void 0;
6994
+ }
6995
+ const key2 = JSON.stringify(
6996
+ [...cells4].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name3, cell]) => [
6997
+ name3,
6998
+ cell.value ?? null,
6999
+ cell.formula ?? null,
7000
+ cell.unit ?? null,
7001
+ cell.error ?? null
7002
+ ])
7003
+ );
7004
+ const bounded6 = key2.length <= 2048 ? key2 : void 0;
7005
+ proofs.set(cells4, bounded6);
7006
+ return bounded6;
7007
+ }
7008
+
7009
+ // visio/text-field-editability.ts
7010
+ function assertEditableFieldRow(existing) {
7011
+ for (const name3 of ["Calendar", "ObjectKind"]) {
7012
+ const cell = children2(existing, "Cell").find((cell2) => attribute2(cell2, "N") === name3);
7013
+ if (cell && (attribute2(cell, "V") !== "0" || cell.hasAttribute("F") || cell.hasAttribute("E")))
7014
+ fail(
7015
+ "UNSUPPORTED_TEXT_FIELD",
7016
+ "Nonstandard field calendar or object profiles cannot be edited."
7017
+ );
7018
+ }
7019
+ for (const cell of children2(existing, "Cell")) {
7020
+ const name3 = attribute2(cell, "N") ?? "";
7021
+ if (/^(value|format|type|calendar|objectkind)$/i.test(name3) && !["Value", "Format", "Type", "Calendar", "ObjectKind"].includes(name3))
7022
+ fail("UNSUPPORTED_TEXT_FIELD", "Noncanonical field cell names cannot be edited.");
7023
+ if (["Value", "Format", "Type"].includes(attribute2(cell, "N") ?? "") && (cell.hasAttribute("E") || /^\s*(Inh|GUARD\s*\()/i.test(attribute2(cell, "F") ?? "")))
7024
+ fail("UNSUPPORTED_TEXT_FIELD", "Protected or inherited field cells cannot be edited.");
7025
+ }
7026
+ }
7027
+ function assertEditableFieldShape(shape) {
7028
+ if (shape.localName !== "Shape" || shape.parentNode?.parentNode?.localName !== "PageContents" || shape.hasAttribute("Master") || shape.hasAttribute("MasterShape") || attribute2(shape, "Type") === "Group" || ["Shapes", "ForeignData", "Rel"].some((name3) => children2(shape, name3).length))
7029
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field edits require a top-level plain local shape.");
7030
+ }
7031
+ function editableTextFieldIndices(text5, allowed) {
7032
+ const result = /* @__PURE__ */ new Set();
7033
+ if (!allowed || !text5) return result;
7034
+ const shape = text5.parentNode;
7035
+ try {
7036
+ assertEditableFieldShape(shape);
7037
+ assertFormattingText(shape);
7038
+ const rows = formattingRows(shape, "Field");
7039
+ const markers = children2(text5, "fld");
7040
+ const counts = /* @__PURE__ */ new Map();
7041
+ for (const marker2 of markers) {
7042
+ const index = attribute2(marker2, "IX");
7043
+ counts.set(index, (counts.get(index) ?? 0) + 1);
7044
+ }
7045
+ for (const [index, row2] of rows) {
7046
+ if (counts.get(index) !== 1 || textFieldSourceKey(readCells(row2)) === void 0) continue;
7047
+ try {
7048
+ assertEditableFieldRow(row2);
7049
+ result.add(index);
7050
+ } catch {
7051
+ }
7052
+ }
7053
+ } catch {
7054
+ }
7055
+ return result;
7056
+ }
7057
+
6785
7058
  // geometry/svg-path-curves.ts
6786
7059
  function sampleCubic(p0, p1, p2, p3, segments, out) {
6787
7060
  for (let i = 1; i <= segments; i++) {
@@ -8881,195 +9154,6 @@ function visioFieldCase(text5, upper) {
8881
9154
  }).join("");
8882
9155
  }
8883
9156
 
8884
- // visio/text-fields.ts
8885
- var PROPERTY_FUNCTIONS = {
8886
- TITLE: "title",
8887
- SUBJECT: "subject",
8888
- CREATOR: "creator",
8889
- KEYWORDS: "keywords",
8890
- DESCRIPTION: "description",
8891
- CATEGORY: "category",
8892
- COMPANY: "company",
8893
- MANAGER: "manager"
8894
- };
8895
- var DATE_FUNCTIONS = {
8896
- NOW: void 0,
8897
- DOCCREATION: "created",
8898
- DOCLASTSAVE: "modified",
8899
- DOCLASTEDIT: "modified",
8900
- DOCLASTPRINT: "lastPrinted"
8901
- };
8902
- var VISIO_FIELD_FUNCTIONS = [
8903
- ...Object.keys(PROPERTY_FUNCTIONS),
8904
- ...Object.keys(DATE_FUNCTIONS),
8905
- "PAGENAME"
8906
- ];
8907
- function visioWallClock(date2) {
8908
- return new Date(
8909
- Date.UTC(
8910
- date2.getFullYear(),
8911
- date2.getMonth(),
8912
- date2.getDate(),
8913
- date2.getHours(),
8914
- date2.getMinutes(),
8915
- date2.getSeconds()
8916
- )
8917
- );
8918
- }
8919
- var EPOCH = Date.UTC(1899, 11, 30);
8920
- var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
8921
- function evaluateVisioTextField(formula, context) {
8922
- let ast;
8923
- try {
8924
- ast = parseVisioFormula(formula, { maxLength: 4096 });
8925
- } catch {
8926
- return void 0;
8927
- }
8928
- if (ast.kind === "call") {
8929
- const name3 = ast.name;
8930
- if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
8931
- const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
8932
- return value === void 0 ? void 0 : { kind: "string", text: value };
8933
- }
8934
- if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
8935
- if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
8936
- const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
8937
- const time = stamp ? Date.parse(stamp) : Number.NaN;
8938
- return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
8939
- }
8940
- if (name3 === "PAGENAME" && ast.args.length <= 1)
8941
- return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
8942
- }
8943
- try {
8944
- const result = evaluateVisioFormula(
8945
- ast,
8946
- context.resolve ?? (() => {
8947
- throw new Error("No cell context");
8948
- }),
8949
- {
8950
- ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
8951
- ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
8952
- }
8953
- );
8954
- return { kind: "number", value: result.value, unit: result.unit };
8955
- } catch {
8956
- return void 0;
8957
- }
8958
- }
8959
- var MONTHS = [
8960
- "January",
8961
- "February",
8962
- "March",
8963
- "April",
8964
- "May",
8965
- "June",
8966
- "July",
8967
- "August",
8968
- "September",
8969
- "October",
8970
- "November",
8971
- "December"
8972
- ];
8973
- var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
8974
- var pad = (value, length = 2) => String(value).padStart(length, "0");
8975
- function dateToken(date2, token) {
8976
- const hours = date2.getUTCHours();
8977
- switch (token) {
8978
- case "yyyy":
8979
- return pad(date2.getUTCFullYear(), 4);
8980
- case "yy":
8981
- return pad(date2.getUTCFullYear() % 100);
8982
- case "MMMM":
8983
- return MONTHS[date2.getUTCMonth()];
8984
- case "MMM":
8985
- return MONTHS[date2.getUTCMonth()].slice(0, 3);
8986
- case "MM":
8987
- return pad(date2.getUTCMonth() + 1);
8988
- case "M":
8989
- return String(date2.getUTCMonth() + 1);
8990
- case "dddd":
8991
- return DAYS[date2.getUTCDay()];
8992
- case "ddd":
8993
- return DAYS[date2.getUTCDay()].slice(0, 3);
8994
- case "dd":
8995
- return pad(date2.getUTCDate());
8996
- case "d":
8997
- return String(date2.getUTCDate());
8998
- case "HH":
8999
- return pad(hours);
9000
- case "H":
9001
- return String(hours);
9002
- case "hh":
9003
- return pad(hours % 12 || 12);
9004
- case "h":
9005
- return String(hours % 12 || 12);
9006
- case "mm":
9007
- return pad(date2.getUTCMinutes());
9008
- case "ss":
9009
- return pad(date2.getUTCSeconds());
9010
- case "tt":
9011
- return hours < 12 ? "AM" : "PM";
9012
- default:
9013
- return void 0;
9014
- }
9015
- }
9016
- function formatDate(date2, picture) {
9017
- return picture.replace(
9018
- /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
9019
- (token) => {
9020
- if (token.startsWith('"')) return token.slice(1, -1);
9021
- return dateToken(date2, token) ?? token;
9022
- }
9023
- );
9024
- }
9025
- function formatNumber(value, picture) {
9026
- const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
9027
- if (!match) return void 0;
9028
- const decimals = match[2]?.length ?? 0;
9029
- const optional = match[2]?.startsWith("#") ?? false;
9030
- const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
9031
- const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
9032
- const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
9033
- let text5 = (Math.sign(value) * rounded).toFixed(decimals);
9034
- if (optional && text5.includes(".")) text5 = text5.replace(/\.?0+$/, "");
9035
- if (match[1]) {
9036
- const [whole, fraction] = text5.split(".");
9037
- text5 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
9038
- }
9039
- return text5 === "-0" ? "0" : text5;
9040
- }
9041
- var VISIO_FIELD_FORMATS = {
9042
- shortDate: "{{M/d/yyyy}}",
9043
- isoDate: "{{yyyy-MM-dd}}",
9044
- longDate: "{{dddd, MMMM d, yyyy}}",
9045
- time: "{{h:mm tt}}",
9046
- dateTime: "{{M/d/yyyy h:mm tt}}",
9047
- text: "@",
9048
- integer: "0",
9049
- decimal: "0.00",
9050
- decimalUnits: "0.00 u",
9051
- integerUnits: "0 u"
9052
- };
9053
- function formatVisioFieldValue(value, format4 = "") {
9054
- const picture = format4.trim();
9055
- if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
9056
- if (value.kind === "date") {
9057
- const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
9058
- return date2 === void 0 ? void 0 : formatDate(value.date, date2);
9059
- }
9060
- const units2 = / u$/.test(picture);
9061
- const body = picture.replace(/ u$/, "");
9062
- let number5 = value.value, suffix = "";
9063
- if (value.unit === "angle") {
9064
- number5 = number5 * 180 / Math.PI;
9065
- suffix = " deg.";
9066
- } else if (value.unit === "length") suffix = " in.";
9067
- else if (value.unit !== "scalar") return void 0;
9068
- const text5 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
9069
- if (text5 === void 0) return void 0;
9070
- return units2 || body === "" ? `${text5}${suffix}` : text5;
9071
- }
9072
-
9073
9157
  // visio/text-field-fraction.ts
9074
9158
  function fractionalFieldNumber(value, maxDenominator) {
9075
9159
  if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
@@ -9226,7 +9310,12 @@ function textFieldDisplay(element2, sheet, context) {
9226
9310
  const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
9227
9311
  const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
9228
9312
  const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
9229
- const result = { cached: cached5, ...formula ? { formula } : {} };
9313
+ const sourceKey = row2 ? textFieldSourceKey(row2.cells) : void 0;
9314
+ const result = {
9315
+ cached: cached5,
9316
+ ...formula ? { formula } : {},
9317
+ ...sourceKey !== void 0 ? { index, format: format4?.value ?? "", sourceKey } : {}
9318
+ };
9230
9319
  if (!row2 || !context) return { text: cached5, ...result };
9231
9320
  const picture = format4?.value ?? "";
9232
9321
  const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
@@ -10100,7 +10189,8 @@ function runStyle(cells4, resources, report, themeCells) {
10100
10189
  ...characterExtras(cells4, report)
10101
10190
  };
10102
10191
  }
10103
- function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph) {
10192
+ function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph, allowFieldEditing = false) {
10193
+ const editableFields = editableTextFieldIndices(node2, allowFieldEditing);
10104
10194
  const cells4 = sheet.cells;
10105
10195
  const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
10106
10196
  const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
@@ -10135,7 +10225,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
10135
10225
  start: textOffset,
10136
10226
  end: textOffset + field2.text.length,
10137
10227
  cached: field2.cached,
10138
- ...field2.formula ? { formula: field2.formula } : {}
10228
+ ...field2.index !== void 0 && editableFields.has(field2.index) ? { editable: true } : {},
10229
+ ...field2.formula ? { formula: field2.formula } : {},
10230
+ ...field2.index === void 0 ? {} : { index: field2.index, format: field2.format, sourceKey: field2.sourceKey }
10139
10231
  });
10140
10232
  append(field2.text);
10141
10233
  } else if (element2.localName !== "pp" && element2.localName !== "tp") {
@@ -11414,7 +11506,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
11414
11506
  context.resources,
11415
11507
  report,
11416
11508
  context.consumeText,
11417
- context.consumeParagraph
11509
+ context.consumeParagraph,
11510
+ depth === 0 && masterId === void 0 && !sheet.cells.get("LockTextEdit")?.error && !sheet.cells.get("LockTextEdit")?.formula && number(sheet.cells, "LockTextEdit", 0, report) === 0
11418
11511
  ),
11419
11512
  hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
11420
11513
  visibility: {
@@ -22057,6 +22150,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots, pageId2, shap
22057
22150
  continue;
22058
22151
  const source = executableCellFormula(attribute2(node2, "F"));
22059
22152
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
22153
+ if (independentTextFieldFormula(node2, source)) continue;
22060
22154
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
22061
22155
  if (isConnectedGlueCell(node2, source)) continue;
22062
22156
  const owner = node2.parentNode;
@@ -26967,9 +27061,23 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26967
27061
  effectiveFormattingRows(shape, document, "Paragraph")
26968
27062
  );
26969
27063
  const rows = formattingRows(shape, "Field");
26970
- const point2 = insertionPoint(text5, edit.offset);
26971
- if (edit.offset !== void 0 && point2.logical !== edit.expectedText)
27064
+ const updating = edit.type === "update-text-field";
27065
+ if (updating) assertEditableFieldShape(shape);
27066
+ const point2 = insertionPoint(text5, updating ? void 0 : edit.offset);
27067
+ if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
26972
27068
  fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
27069
+ const existing = updating ? rows.get(edit.fieldIndex) : void 0;
27070
+ const markers = updating ? children2(text5, "fld").filter((field3) => attribute2(field3, "IX") === edit.fieldIndex) : [];
27071
+ if (updating) {
27072
+ if (!existing || markers.length !== 1)
27073
+ fail(
27074
+ "UNSUPPORTED_TEXT_FIELD",
27075
+ "Existing fields require one live local row and unique text marker."
27076
+ );
27077
+ if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
27078
+ fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
27079
+ assertEditableFieldRow(existing);
27080
+ }
26973
27081
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
26974
27082
  let value;
26975
27083
  try {
@@ -26982,9 +27090,19 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26982
27090
  "UNSUPPORTED_TEXT_FIELD",
26983
27091
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
26984
27092
  );
26985
- const display = formatVisioFieldValue(value, edit.format ?? "");
27093
+ const format4 = edit.format ?? "";
27094
+ const display = formatVisioFieldValue(value, format4);
26986
27095
  if (display === void 0)
26987
27096
  fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
27097
+ const prepared = valueCell(value);
27098
+ if (existing && markers[0].textContent === display) {
27099
+ const same5 = (name3, v, u, f) => {
27100
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27101
+ return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
27102
+ };
27103
+ if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
27104
+ return false;
27105
+ }
26988
27106
  if (texts[0])
26989
27107
  await assertFormattingDependencies(
26990
27108
  pkg,
@@ -26992,32 +27110,49 @@ async function insertVisioTextField(pkg, pagePaths, roots, document, edit, check
26992
27110
  roots,
26993
27111
  edit.pageId,
26994
27112
  shape,
26995
- /* @__PURE__ */ new Map([["TheText", text5]]),
27113
+ new Map([
27114
+ ["TheText", text5],
27115
+ ...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
27116
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
27117
+ return [
27118
+ [`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
27119
+ [`Fields.${name3}`, cell2]
27120
+ ];
27121
+ }) : []
27122
+ ]),
26996
27123
  check
26997
27124
  );
26998
27125
  check();
26999
- const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
27126
+ const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
27000
27127
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
27001
27128
  if (!section3) {
27002
27129
  section3 = owner.createElementNS(ns, "Section");
27003
27130
  section3.setAttribute("N", "Field");
27004
27131
  shape.insertBefore(section3, texts[0] ?? null);
27005
27132
  }
27006
- const row2 = owner.createElementNS(ns, "Row");
27007
- row2.setAttribute("IX", index);
27133
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
27134
+ if (!existing) row2.setAttribute("IX", index);
27008
27135
  const cell = (name3, v, extra = {}) => {
27009
- const node2 = owner.createElementNS(ns, "Cell");
27136
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
27010
27137
  node2.setAttribute("N", name3);
27011
27138
  node2.setAttribute("V", v);
27139
+ if (updating) {
27140
+ node2.removeAttribute("U");
27141
+ node2.removeAttribute("F");
27142
+ }
27012
27143
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
27013
- row2.appendChild(node2);
27144
+ if (!node2.parentNode) row2.appendChild(node2);
27014
27145
  };
27015
- const stored = valueCell(value);
27146
+ const stored = prepared;
27016
27147
  cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
27017
- if (edit.format)
27018
- cell("Format", edit.format, { U: "STR", F: `"${edit.format.replaceAll('"', '""')}"` });
27148
+ if (format4 || updating)
27149
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
27019
27150
  cell("Type", String(stored.type));
27020
- section3.appendChild(row2);
27151
+ if (!row2.parentNode) section3.appendChild(row2);
27152
+ if (updating) {
27153
+ markers[0].textContent = display;
27154
+ return true;
27155
+ }
27021
27156
  const field2 = owner.createElementNS(ns, "fld");
27022
27157
  field2.setAttribute("IX", index);
27023
27158
  field2.appendChild(owner.createTextNode(display));
@@ -29415,6 +29550,35 @@ function snapshotGuideEdit(edit) {
29415
29550
  }
29416
29551
 
29417
29552
  // visio/edit-text-field-commands.ts
29553
+ function snapshotTextFieldUpdate(edit) {
29554
+ const insert = snapshotTextFieldInsert({
29555
+ pageId: edit.pageId,
29556
+ shapeId: edit.shapeId,
29557
+ formula: edit.formula,
29558
+ ...edit.format === void 0 ? {} : { format: edit.format }
29559
+ });
29560
+ if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
29561
+ (ref) => /^fields?\./i.test(ref.cell)
29562
+ ))
29563
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
29564
+ if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
29565
+ fail("INVALID_EDIT", "An existing field needs a canonical row index.");
29566
+ if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
29567
+ (value) => typeof value !== "string" || value.length > 1e6
29568
+ ) || !edit.expectedSourceKey)
29569
+ fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
29570
+ return {
29571
+ type: "update-text-field",
29572
+ pageId: insert.pageId,
29573
+ shapeId: insert.shapeId,
29574
+ fieldIndex: edit.fieldIndex,
29575
+ formula: insert.formula,
29576
+ format: insert.format,
29577
+ expectedText: edit.expectedText,
29578
+ expectedCached: edit.expectedCached,
29579
+ expectedSourceKey: edit.expectedSourceKey
29580
+ };
29581
+ }
29418
29582
  function snapshotTextFieldInsert(edit) {
29419
29583
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
29420
29584
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -30168,6 +30332,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
30168
30332
  return { ...target2, type: edit.type, text: text5(edit.text) };
30169
30333
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text5);
30170
30334
  if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
30335
+ if (edit.type === "update-text-field") {
30336
+ const update = snapshotTextFieldUpdate(edit);
30337
+ update.formula = text5(update.formula);
30338
+ update.expectedText = text5(update.expectedText);
30339
+ update.expectedCached = text5(update.expectedCached);
30340
+ update.expectedSourceKey = text5(update.expectedSourceKey);
30341
+ return update;
30342
+ }
30171
30343
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
30172
30344
  if (edit.type === "reorder-shape") {
30173
30345
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -35595,7 +35767,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35595
35767
  const dirty = /* @__PURE__ */ new Map();
35596
35768
  const roots = /* @__PURE__ */ new Map();
35597
35769
  const geometryCommands = commands.filter(
35598
- (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
35770
+ (command2) => command2.type !== "replace-plain-text" && command2.type !== "replace-text-ranges" && command2.type !== "insert-text-field" && command2.type !== "update-text-field" && command2.type !== "reorder-shape" && command2.type !== "duplicate-shapes" && command2.type !== "paste-shapes" && command2.type !== "change-shape" && command2.type !== "insert-picture" && command2.type !== "set-page-theme" && !isVisioMetadataEdit(command2) && command2.type !== "set-shape-data" && !isVisioGroupEdit(command2) && !isVisioDiagramPartEdit(command2) && !isVisioGuideEdit(command2) && !isVisioFormatEdit(command2)
35599
35771
  );
35600
35772
  let document;
35601
35773
  let masterMovePins = emptyMasterMoveProof();
@@ -35603,7 +35775,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35603
35775
  let instanceDeletes = /* @__PURE__ */ new Set();
35604
35776
  let groupMembers = /* @__PURE__ */ new Map();
35605
35777
  if (geometryCommands.length || commands.some(
35606
- (command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
35778
+ (command2) => command2.type === "replace-plain-text" || command2.type === "replace-text-ranges" || command2.type === "insert-text-field" || command2.type === "update-text-field" || isVisioFormatEdit(command2) || isVisioMetadataEdit(command2) || command2.type === "set-shape-data" || command2.type === "reorder-shape" || command2.type === "duplicate-shapes" || command2.type === "paste-shapes" || command2.type === "change-shape" || isVisioGroupEdit(command2) || isVisioDiagramPartEdit(command2) || isVisioGuideEdit(command2)
35607
35779
  )) {
35608
35780
  for (const [pageId2, path2] of pages) {
35609
35781
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -35714,7 +35886,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
35714
35886
  textChanged = true;
35715
35887
  await noteTextSize(command2, root2);
35716
35888
  }
35717
- } else if (command2.type === "insert-text-field") {
35889
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
35718
35890
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots, document, command2, check)) {
35719
35891
  dirty.set(path, root2);
35720
35892
  textChanged = true;