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
@@ -3820,6 +3820,208 @@ function takeDeferredTextSizes(root2) {
3820
3820
  return shapes;
3821
3821
  }
3822
3822
 
3823
+ // visio/text-fields.ts
3824
+ var PROPERTY_FUNCTIONS = {
3825
+ TITLE: "title",
3826
+ SUBJECT: "subject",
3827
+ CREATOR: "creator",
3828
+ KEYWORDS: "keywords",
3829
+ DESCRIPTION: "description",
3830
+ CATEGORY: "category",
3831
+ COMPANY: "company",
3832
+ MANAGER: "manager"
3833
+ };
3834
+ var DATE_FUNCTIONS = {
3835
+ NOW: void 0,
3836
+ DOCCREATION: "created",
3837
+ DOCLASTSAVE: "modified",
3838
+ DOCLASTEDIT: "modified",
3839
+ DOCLASTPRINT: "lastPrinted"
3840
+ };
3841
+ var VISIO_FIELD_FUNCTIONS = [
3842
+ ...Object.keys(PROPERTY_FUNCTIONS),
3843
+ ...Object.keys(DATE_FUNCTIONS),
3844
+ "PAGENAME"
3845
+ ];
3846
+ function visioWallClock(date2) {
3847
+ return new Date(
3848
+ Date.UTC(
3849
+ date2.getFullYear(),
3850
+ date2.getMonth(),
3851
+ date2.getDate(),
3852
+ date2.getHours(),
3853
+ date2.getMinutes(),
3854
+ date2.getSeconds()
3855
+ )
3856
+ );
3857
+ }
3858
+ var EPOCH = Date.UTC(1899, 11, 30);
3859
+ var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
3860
+ function evaluateVisioTextField(formula, context) {
3861
+ let ast;
3862
+ try {
3863
+ ast = parseVisioFormula(formula, { maxLength: 4096 });
3864
+ } catch {
3865
+ return void 0;
3866
+ }
3867
+ if (ast.kind === "call") {
3868
+ const name3 = ast.name;
3869
+ if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
3870
+ const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
3871
+ return value === void 0 ? void 0 : { kind: "string", text: value };
3872
+ }
3873
+ if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
3874
+ if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
3875
+ const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
3876
+ const time = stamp ? Date.parse(stamp) : Number.NaN;
3877
+ return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
3878
+ }
3879
+ if (name3 === "PAGENAME" && ast.args.length <= 1)
3880
+ return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
3881
+ }
3882
+ try {
3883
+ const result = evaluateVisioFormula(
3884
+ ast,
3885
+ context.resolve ?? (() => {
3886
+ throw new Error("No cell context");
3887
+ }),
3888
+ {
3889
+ ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
3890
+ ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
3891
+ }
3892
+ );
3893
+ return { kind: "number", value: result.value, unit: result.unit };
3894
+ } catch {
3895
+ return void 0;
3896
+ }
3897
+ }
3898
+ var MONTHS = [
3899
+ "January",
3900
+ "February",
3901
+ "March",
3902
+ "April",
3903
+ "May",
3904
+ "June",
3905
+ "July",
3906
+ "August",
3907
+ "September",
3908
+ "October",
3909
+ "November",
3910
+ "December"
3911
+ ];
3912
+ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
3913
+ var pad = (value, length = 2) => String(value).padStart(length, "0");
3914
+ function dateToken(date2, token) {
3915
+ const hours = date2.getUTCHours();
3916
+ switch (token) {
3917
+ case "yyyy":
3918
+ return pad(date2.getUTCFullYear(), 4);
3919
+ case "yy":
3920
+ return pad(date2.getUTCFullYear() % 100);
3921
+ case "MMMM":
3922
+ return MONTHS[date2.getUTCMonth()];
3923
+ case "MMM":
3924
+ return MONTHS[date2.getUTCMonth()].slice(0, 3);
3925
+ case "MM":
3926
+ return pad(date2.getUTCMonth() + 1);
3927
+ case "M":
3928
+ return String(date2.getUTCMonth() + 1);
3929
+ case "dddd":
3930
+ return DAYS[date2.getUTCDay()];
3931
+ case "ddd":
3932
+ return DAYS[date2.getUTCDay()].slice(0, 3);
3933
+ case "dd":
3934
+ return pad(date2.getUTCDate());
3935
+ case "d":
3936
+ return String(date2.getUTCDate());
3937
+ case "HH":
3938
+ return pad(hours);
3939
+ case "H":
3940
+ return String(hours);
3941
+ case "hh":
3942
+ return pad(hours % 12 || 12);
3943
+ case "h":
3944
+ return String(hours % 12 || 12);
3945
+ case "mm":
3946
+ return pad(date2.getUTCMinutes());
3947
+ case "ss":
3948
+ return pad(date2.getUTCSeconds());
3949
+ case "tt":
3950
+ return hours < 12 ? "AM" : "PM";
3951
+ default:
3952
+ return void 0;
3953
+ }
3954
+ }
3955
+ function formatDate(date2, picture) {
3956
+ return picture.replace(
3957
+ /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
3958
+ (token) => {
3959
+ if (token.startsWith('"')) return token.slice(1, -1);
3960
+ return dateToken(date2, token) ?? token;
3961
+ }
3962
+ );
3963
+ }
3964
+ function formatNumber(value, picture) {
3965
+ const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
3966
+ if (!match) return void 0;
3967
+ const decimals = match[2]?.length ?? 0;
3968
+ const optional = match[2]?.startsWith("#") ?? false;
3969
+ const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
3970
+ const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
3971
+ const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
3972
+ let text7 = (Math.sign(value) * rounded).toFixed(decimals);
3973
+ if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
3974
+ if (match[1]) {
3975
+ const [whole, fraction] = text7.split(".");
3976
+ text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
3977
+ }
3978
+ return text7 === "-0" ? "0" : text7;
3979
+ }
3980
+ var VISIO_FIELD_FORMATS = {
3981
+ shortDate: "{{M/d/yyyy}}",
3982
+ isoDate: "{{yyyy-MM-dd}}",
3983
+ longDate: "{{dddd, MMMM d, yyyy}}",
3984
+ time: "{{h:mm tt}}",
3985
+ dateTime: "{{M/d/yyyy h:mm tt}}",
3986
+ text: "@",
3987
+ integer: "0",
3988
+ decimal: "0.00",
3989
+ decimalUnits: "0.00 u",
3990
+ integerUnits: "0 u"
3991
+ };
3992
+ function formatVisioFieldValue(value, format4 = "") {
3993
+ const picture = format4.trim();
3994
+ if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
3995
+ if (value.kind === "date") {
3996
+ const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
3997
+ return date2 === void 0 ? void 0 : formatDate(value.date, date2);
3998
+ }
3999
+ const units2 = / u$/.test(picture);
4000
+ const body = picture.replace(/ u$/, "");
4001
+ let number5 = value.value, suffix = "";
4002
+ if (value.unit === "angle") {
4003
+ number5 = number5 * 180 / Math.PI;
4004
+ suffix = " deg.";
4005
+ } else if (value.unit === "length") suffix = " in.";
4006
+ else if (value.unit !== "scalar") return void 0;
4007
+ const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
4008
+ if (text7 === void 0) return void 0;
4009
+ return units2 || body === "" ? `${text7}${suffix}` : text7;
4010
+ }
4011
+
4012
+ // visio/text-field-independent.ts
4013
+ function independentTextFieldFormula(cell, formula) {
4014
+ const row2 = cell.parentNode, section3 = row2?.parentNode;
4015
+ 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"))
4016
+ return false;
4017
+ if (attribute2(cell, "N") === "Format")
4018
+ return /^\s*FIELDPICTURE\(\s*(2|37|204)\s*\)\s*$/i.test(formula);
4019
+ if (attribute2(cell, "N") !== "Value") return false;
4020
+ if (/^\s*DATE\(\s*\d{1,4}\s*,\s*\d{1,2}\s*,\s*\d{1,2}\s*\)\s*$/i.test(formula)) return true;
4021
+ const direct = /^\s*([A-Z]+)\(\s*\)\s*$/i.exec(formula)?.[1]?.toUpperCase();
4022
+ return direct !== void 0 && VISIO_FIELD_FUNCTIONS.includes(direct);
4023
+ }
4024
+
3823
4025
  // visio/edit-connector-glue.ts
3824
4026
  var VISIO_WALK_GLUE = "_WALKGLUE(BegTrigger,EndTrigger,WalkPreference)";
3825
4027
  var walkGlue = /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i;
@@ -3929,7 +4131,7 @@ function indexCells(roots2, options) {
3929
4131
  unit: cellUnit(cell, relative)
3930
4132
  };
3931
4133
  const source = attribute2(node2, "F");
3932
- 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
4134
+ 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
3933
4135
  // (Visio's freshly dropped connector names its own sheet).
3934
4136
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
3935
4137
  try {
@@ -9766,6 +9968,77 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
9766
9968
  }
9767
9969
  }
9768
9970
 
9971
+ // visio/text-field-source.ts
9972
+ var proofs = /* @__PURE__ */ new WeakMap();
9973
+ function textFieldSourceKey(cells4) {
9974
+ if (proofs.has(cells4)) return proofs.get(cells4);
9975
+ if (cells4.size > 64) {
9976
+ proofs.set(cells4, void 0);
9977
+ return void 0;
9978
+ }
9979
+ const key2 = JSON.stringify(
9980
+ [...cells4].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name3, cell]) => [
9981
+ name3,
9982
+ cell.value ?? null,
9983
+ cell.formula ?? null,
9984
+ cell.unit ?? null,
9985
+ cell.error ?? null
9986
+ ])
9987
+ );
9988
+ const bounded6 = key2.length <= 2048 ? key2 : void 0;
9989
+ proofs.set(cells4, bounded6);
9990
+ return bounded6;
9991
+ }
9992
+
9993
+ // visio/text-field-editability.ts
9994
+ function assertEditableFieldRow(existing) {
9995
+ for (const name3 of ["Calendar", "ObjectKind"]) {
9996
+ const cell = children2(existing, "Cell").find((cell2) => attribute2(cell2, "N") === name3);
9997
+ if (cell && (attribute2(cell, "V") !== "0" || cell.hasAttribute("F") || cell.hasAttribute("E")))
9998
+ fail(
9999
+ "UNSUPPORTED_TEXT_FIELD",
10000
+ "Nonstandard field calendar or object profiles cannot be edited."
10001
+ );
10002
+ }
10003
+ for (const cell of children2(existing, "Cell")) {
10004
+ const name3 = attribute2(cell, "N") ?? "";
10005
+ if (/^(value|format|type|calendar|objectkind)$/i.test(name3) && !["Value", "Format", "Type", "Calendar", "ObjectKind"].includes(name3))
10006
+ fail("UNSUPPORTED_TEXT_FIELD", "Noncanonical field cell names cannot be edited.");
10007
+ if (["Value", "Format", "Type"].includes(attribute2(cell, "N") ?? "") && (cell.hasAttribute("E") || /^\s*(Inh|GUARD\s*\()/i.test(attribute2(cell, "F") ?? "")))
10008
+ fail("UNSUPPORTED_TEXT_FIELD", "Protected or inherited field cells cannot be edited.");
10009
+ }
10010
+ }
10011
+ function assertEditableFieldShape(shape) {
10012
+ 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))
10013
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field edits require a top-level plain local shape.");
10014
+ }
10015
+ function editableTextFieldIndices(text7, allowed) {
10016
+ const result = /* @__PURE__ */ new Set();
10017
+ if (!allowed || !text7) return result;
10018
+ const shape = text7.parentNode;
10019
+ try {
10020
+ assertEditableFieldShape(shape);
10021
+ assertFormattingText(shape);
10022
+ const rows = formattingRows(shape, "Field");
10023
+ const markers = children2(text7, "fld");
10024
+ const counts = /* @__PURE__ */ new Map();
10025
+ for (const marker2 of markers) {
10026
+ const index = attribute2(marker2, "IX");
10027
+ counts.set(index, (counts.get(index) ?? 0) + 1);
10028
+ }
10029
+ for (const [index, row2] of rows) {
10030
+ if (counts.get(index) !== 1 || textFieldSourceKey(readCells(row2)) === void 0) continue;
10031
+ try {
10032
+ assertEditableFieldRow(row2);
10033
+ result.add(index);
10034
+ } catch {
10035
+ }
10036
+ }
10037
+ } catch {
10038
+ }
10039
+ return result;
10040
+ }
10041
+
9769
10042
  // geometry/svg-path-curves.ts
9770
10043
  function sampleCubic(p0, p1, p2, p3, segments, out) {
9771
10044
  for (let i = 1; i <= segments; i++) {
@@ -12181,195 +12454,6 @@ function visioFieldCase(text7, upper) {
12181
12454
  }).join("");
12182
12455
  }
12183
12456
 
12184
- // visio/text-fields.ts
12185
- var PROPERTY_FUNCTIONS = {
12186
- TITLE: "title",
12187
- SUBJECT: "subject",
12188
- CREATOR: "creator",
12189
- KEYWORDS: "keywords",
12190
- DESCRIPTION: "description",
12191
- CATEGORY: "category",
12192
- COMPANY: "company",
12193
- MANAGER: "manager"
12194
- };
12195
- var DATE_FUNCTIONS = {
12196
- NOW: void 0,
12197
- DOCCREATION: "created",
12198
- DOCLASTSAVE: "modified",
12199
- DOCLASTEDIT: "modified",
12200
- DOCLASTPRINT: "lastPrinted"
12201
- };
12202
- var VISIO_FIELD_FUNCTIONS = [
12203
- ...Object.keys(PROPERTY_FUNCTIONS),
12204
- ...Object.keys(DATE_FUNCTIONS),
12205
- "PAGENAME"
12206
- ];
12207
- function visioWallClock(date2) {
12208
- return new Date(
12209
- Date.UTC(
12210
- date2.getFullYear(),
12211
- date2.getMonth(),
12212
- date2.getDate(),
12213
- date2.getHours(),
12214
- date2.getMinutes(),
12215
- date2.getSeconds()
12216
- )
12217
- );
12218
- }
12219
- var EPOCH = Date.UTC(1899, 11, 30);
12220
- var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
12221
- function evaluateVisioTextField(formula, context) {
12222
- let ast;
12223
- try {
12224
- ast = parseVisioFormula(formula, { maxLength: 4096 });
12225
- } catch {
12226
- return void 0;
12227
- }
12228
- if (ast.kind === "call") {
12229
- const name3 = ast.name;
12230
- if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
12231
- const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
12232
- return value === void 0 ? void 0 : { kind: "string", text: value };
12233
- }
12234
- if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
12235
- if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
12236
- const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
12237
- const time = stamp ? Date.parse(stamp) : Number.NaN;
12238
- return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
12239
- }
12240
- if (name3 === "PAGENAME" && ast.args.length <= 1)
12241
- return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
12242
- }
12243
- try {
12244
- const result = evaluateVisioFormula(
12245
- ast,
12246
- context.resolve ?? (() => {
12247
- throw new Error("No cell context");
12248
- }),
12249
- {
12250
- ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
12251
- ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
12252
- }
12253
- );
12254
- return { kind: "number", value: result.value, unit: result.unit };
12255
- } catch {
12256
- return void 0;
12257
- }
12258
- }
12259
- var MONTHS = [
12260
- "January",
12261
- "February",
12262
- "March",
12263
- "April",
12264
- "May",
12265
- "June",
12266
- "July",
12267
- "August",
12268
- "September",
12269
- "October",
12270
- "November",
12271
- "December"
12272
- ];
12273
- var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
12274
- var pad = (value, length = 2) => String(value).padStart(length, "0");
12275
- function dateToken(date2, token) {
12276
- const hours = date2.getUTCHours();
12277
- switch (token) {
12278
- case "yyyy":
12279
- return pad(date2.getUTCFullYear(), 4);
12280
- case "yy":
12281
- return pad(date2.getUTCFullYear() % 100);
12282
- case "MMMM":
12283
- return MONTHS[date2.getUTCMonth()];
12284
- case "MMM":
12285
- return MONTHS[date2.getUTCMonth()].slice(0, 3);
12286
- case "MM":
12287
- return pad(date2.getUTCMonth() + 1);
12288
- case "M":
12289
- return String(date2.getUTCMonth() + 1);
12290
- case "dddd":
12291
- return DAYS[date2.getUTCDay()];
12292
- case "ddd":
12293
- return DAYS[date2.getUTCDay()].slice(0, 3);
12294
- case "dd":
12295
- return pad(date2.getUTCDate());
12296
- case "d":
12297
- return String(date2.getUTCDate());
12298
- case "HH":
12299
- return pad(hours);
12300
- case "H":
12301
- return String(hours);
12302
- case "hh":
12303
- return pad(hours % 12 || 12);
12304
- case "h":
12305
- return String(hours % 12 || 12);
12306
- case "mm":
12307
- return pad(date2.getUTCMinutes());
12308
- case "ss":
12309
- return pad(date2.getUTCSeconds());
12310
- case "tt":
12311
- return hours < 12 ? "AM" : "PM";
12312
- default:
12313
- return void 0;
12314
- }
12315
- }
12316
- function formatDate(date2, picture) {
12317
- return picture.replace(
12318
- /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
12319
- (token) => {
12320
- if (token.startsWith('"')) return token.slice(1, -1);
12321
- return dateToken(date2, token) ?? token;
12322
- }
12323
- );
12324
- }
12325
- function formatNumber(value, picture) {
12326
- const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
12327
- if (!match) return void 0;
12328
- const decimals = match[2]?.length ?? 0;
12329
- const optional = match[2]?.startsWith("#") ?? false;
12330
- const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
12331
- const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
12332
- const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
12333
- let text7 = (Math.sign(value) * rounded).toFixed(decimals);
12334
- if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
12335
- if (match[1]) {
12336
- const [whole, fraction] = text7.split(".");
12337
- text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
12338
- }
12339
- return text7 === "-0" ? "0" : text7;
12340
- }
12341
- var VISIO_FIELD_FORMATS = {
12342
- shortDate: "{{M/d/yyyy}}",
12343
- isoDate: "{{yyyy-MM-dd}}",
12344
- longDate: "{{dddd, MMMM d, yyyy}}",
12345
- time: "{{h:mm tt}}",
12346
- dateTime: "{{M/d/yyyy h:mm tt}}",
12347
- text: "@",
12348
- integer: "0",
12349
- decimal: "0.00",
12350
- decimalUnits: "0.00 u",
12351
- integerUnits: "0 u"
12352
- };
12353
- function formatVisioFieldValue(value, format4 = "") {
12354
- const picture = format4.trim();
12355
- if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
12356
- if (value.kind === "date") {
12357
- const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
12358
- return date2 === void 0 ? void 0 : formatDate(value.date, date2);
12359
- }
12360
- const units2 = / u$/.test(picture);
12361
- const body = picture.replace(/ u$/, "");
12362
- let number5 = value.value, suffix = "";
12363
- if (value.unit === "angle") {
12364
- number5 = number5 * 180 / Math.PI;
12365
- suffix = " deg.";
12366
- } else if (value.unit === "length") suffix = " in.";
12367
- else if (value.unit !== "scalar") return void 0;
12368
- const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
12369
- if (text7 === void 0) return void 0;
12370
- return units2 || body === "" ? `${text7}${suffix}` : text7;
12371
- }
12372
-
12373
12457
  // visio/text-field-fraction.ts
12374
12458
  function fractionalFieldNumber(value, maxDenominator) {
12375
12459
  if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
@@ -12526,7 +12610,12 @@ function textFieldDisplay(element2, sheet, context) {
12526
12610
  const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
12527
12611
  const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
12528
12612
  const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
12529
- const result = { cached: cached5, ...formula ? { formula } : {} };
12613
+ const sourceKey = row2 ? textFieldSourceKey(row2.cells) : void 0;
12614
+ const result = {
12615
+ cached: cached5,
12616
+ ...formula ? { formula } : {},
12617
+ ...sourceKey !== void 0 ? { index, format: format4?.value ?? "", sourceKey } : {}
12618
+ };
12530
12619
  if (!row2 || !context) return { text: cached5, ...result };
12531
12620
  const picture = format4?.value ?? "";
12532
12621
  const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
@@ -13311,7 +13400,8 @@ function runStyle(cells4, resources, report, themeCells) {
13311
13400
  ...characterExtras(cells4, report)
13312
13401
  };
13313
13402
  }
13314
- function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph) {
13403
+ function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph, allowFieldEditing = false) {
13404
+ const editableFields = editableTextFieldIndices(node2, allowFieldEditing);
13315
13405
  const cells4 = sheet.cells;
13316
13406
  const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
13317
13407
  const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
@@ -13346,7 +13436,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
13346
13436
  start: textOffset,
13347
13437
  end: textOffset + field3.text.length,
13348
13438
  cached: field3.cached,
13349
- ...field3.formula ? { formula: field3.formula } : {}
13439
+ ...field3.index !== void 0 && editableFields.has(field3.index) ? { editable: true } : {},
13440
+ ...field3.formula ? { formula: field3.formula } : {},
13441
+ ...field3.index === void 0 ? {} : { index: field3.index, format: field3.format, sourceKey: field3.sourceKey }
13350
13442
  });
13351
13443
  append(field3.text);
13352
13444
  } else if (element2.localName !== "pp" && element2.localName !== "tp") {
@@ -14387,7 +14479,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
14387
14479
  context.resources,
14388
14480
  report,
14389
14481
  context.consumeText,
14390
- context.consumeParagraph
14482
+ context.consumeParagraph,
14483
+ depth === 0 && masterId === void 0 && !sheet.cells.get("LockTextEdit")?.error && !sheet.cells.get("LockTextEdit")?.formula && number(sheet.cells, "LockTextEdit", 0, report) === 0
14391
14484
  ),
14392
14485
  hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
14393
14486
  visibility: {
@@ -16107,6 +16200,35 @@ function snapshotGuideEdit(edit) {
16107
16200
  }
16108
16201
 
16109
16202
  // visio/edit-text-field-commands.ts
16203
+ function snapshotTextFieldUpdate(edit) {
16204
+ const insert = snapshotTextFieldInsert({
16205
+ pageId: edit.pageId,
16206
+ shapeId: edit.shapeId,
16207
+ formula: edit.formula,
16208
+ ...edit.format === void 0 ? {} : { format: edit.format }
16209
+ });
16210
+ if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
16211
+ (ref) => /^fields?\./i.test(ref.cell)
16212
+ ))
16213
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
16214
+ if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
16215
+ fail("INVALID_EDIT", "An existing field needs a canonical row index.");
16216
+ if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
16217
+ (value) => typeof value !== "string" || value.length > 1e6
16218
+ ) || !edit.expectedSourceKey)
16219
+ fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
16220
+ return {
16221
+ type: "update-text-field",
16222
+ pageId: insert.pageId,
16223
+ shapeId: insert.shapeId,
16224
+ fieldIndex: edit.fieldIndex,
16225
+ formula: insert.formula,
16226
+ format: insert.format,
16227
+ expectedText: edit.expectedText,
16228
+ expectedCached: edit.expectedCached,
16229
+ expectedSourceKey: edit.expectedSourceKey
16230
+ };
16231
+ }
16110
16232
  function snapshotTextFieldInsert(edit) {
16111
16233
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
16112
16234
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -16841,6 +16963,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
16841
16963
  return { ...target2, type: edit.type, text: text7(edit.text) };
16842
16964
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text7);
16843
16965
  if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
16966
+ if (edit.type === "update-text-field") {
16967
+ const update = snapshotTextFieldUpdate(edit);
16968
+ update.formula = text7(update.formula);
16969
+ update.expectedText = text7(update.expectedText);
16970
+ update.expectedCached = text7(update.expectedCached);
16971
+ update.expectedSourceKey = text7(update.expectedSourceKey);
16972
+ return update;
16973
+ }
16844
16974
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
16845
16975
  if (edit.type === "reorder-shape") {
16846
16976
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -17048,6 +17178,8 @@ function snapshotEdits(edits) {
17048
17178
  return snapshotTextRanges(command2, text7);
17049
17179
  case "insert-text-field":
17050
17180
  return snapshotTextFieldInsert(command2);
17181
+ case "update-text-field":
17182
+ return snapshotTextFieldUpdate(command2);
17051
17183
  case "delete-shape":
17052
17184
  return { type: command2.type, ...target2 };
17053
17185
  case "rotate-shape":
@@ -17693,6 +17825,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
17693
17825
  continue;
17694
17826
  const source = executableCellFormula(attribute2(node2, "F"));
17695
17827
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
17828
+ if (independentTextFieldFormula(node2, source)) continue;
17696
17829
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
17697
17830
  if (isConnectedGlueCell(node2, source)) continue;
17698
17831
  const owner = node2.parentNode;
@@ -21502,9 +21635,23 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21502
21635
  effectiveFormattingRows(shape, document, "Paragraph")
21503
21636
  );
21504
21637
  const rows = formattingRows(shape, "Field");
21505
- const point2 = insertionPoint(text7, edit.offset);
21506
- if (edit.offset !== void 0 && point2.logical !== edit.expectedText)
21638
+ const updating = edit.type === "update-text-field";
21639
+ if (updating) assertEditableFieldShape(shape);
21640
+ const point2 = insertionPoint(text7, updating ? void 0 : edit.offset);
21641
+ if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
21507
21642
  fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
21643
+ const existing = updating ? rows.get(edit.fieldIndex) : void 0;
21644
+ const markers = updating ? children2(text7, "fld").filter((field4) => attribute2(field4, "IX") === edit.fieldIndex) : [];
21645
+ if (updating) {
21646
+ if (!existing || markers.length !== 1)
21647
+ fail(
21648
+ "UNSUPPORTED_TEXT_FIELD",
21649
+ "Existing fields require one live local row and unique text marker."
21650
+ );
21651
+ if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
21652
+ fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
21653
+ assertEditableFieldRow(existing);
21654
+ }
21508
21655
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
21509
21656
  let value;
21510
21657
  try {
@@ -21517,9 +21664,19 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21517
21664
  "UNSUPPORTED_TEXT_FIELD",
21518
21665
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
21519
21666
  );
21520
- const display = formatVisioFieldValue(value, edit.format ?? "");
21667
+ const format4 = edit.format ?? "";
21668
+ const display = formatVisioFieldValue(value, format4);
21521
21669
  if (display === void 0)
21522
21670
  fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
21671
+ const prepared = valueCell(value);
21672
+ if (existing && markers[0].textContent === display) {
21673
+ const same5 = (name3, v, u, f) => {
21674
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
21675
+ return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
21676
+ };
21677
+ if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
21678
+ return false;
21679
+ }
21523
21680
  if (texts[0])
21524
21681
  await assertFormattingDependencies(
21525
21682
  pkg,
@@ -21527,32 +21684,49 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21527
21684
  roots2,
21528
21685
  edit.pageId,
21529
21686
  shape,
21530
- /* @__PURE__ */ new Map([["TheText", text7]]),
21687
+ new Map([
21688
+ ["TheText", text7],
21689
+ ...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
21690
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
21691
+ return [
21692
+ [`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
21693
+ [`Fields.${name3}`, cell2]
21694
+ ];
21695
+ }) : []
21696
+ ]),
21531
21697
  check
21532
21698
  );
21533
21699
  check();
21534
- const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
21700
+ const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
21535
21701
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
21536
21702
  if (!section3) {
21537
21703
  section3 = owner.createElementNS(ns, "Section");
21538
21704
  section3.setAttribute("N", "Field");
21539
21705
  shape.insertBefore(section3, texts[0] ?? null);
21540
21706
  }
21541
- const row2 = owner.createElementNS(ns, "Row");
21542
- row2.setAttribute("IX", index);
21707
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
21708
+ if (!existing) row2.setAttribute("IX", index);
21543
21709
  const cell = (name3, v, extra = {}) => {
21544
- const node2 = owner.createElementNS(ns, "Cell");
21710
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
21545
21711
  node2.setAttribute("N", name3);
21546
21712
  node2.setAttribute("V", v);
21713
+ if (updating) {
21714
+ node2.removeAttribute("U");
21715
+ node2.removeAttribute("F");
21716
+ }
21547
21717
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
21548
- row2.appendChild(node2);
21718
+ if (!node2.parentNode) row2.appendChild(node2);
21549
21719
  };
21550
- const stored = valueCell(value);
21720
+ const stored = prepared;
21551
21721
  cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
21552
- if (edit.format)
21553
- cell("Format", edit.format, { U: "STR", F: `"${edit.format.replaceAll('"', '""')}"` });
21722
+ if (format4 || updating)
21723
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
21554
21724
  cell("Type", String(stored.type));
21555
- section3.appendChild(row2);
21725
+ if (!row2.parentNode) section3.appendChild(row2);
21726
+ if (updating) {
21727
+ markers[0].textContent = display;
21728
+ return true;
21729
+ }
21556
21730
  const field3 = owner.createElementNS(ns, "fld");
21557
21731
  field3.setAttribute("IX", index);
21558
21732
  field3.appendChild(owner.createTextNode(display));
@@ -26904,7 +27078,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26904
27078
  const dirty = /* @__PURE__ */ new Map();
26905
27079
  const roots2 = /* @__PURE__ */ new Map();
26906
27080
  const geometryCommands = commands.filter(
26907
- (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)
27081
+ (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)
26908
27082
  );
26909
27083
  let document;
26910
27084
  let masterMovePins = emptyMasterMoveProof();
@@ -26912,7 +27086,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26912
27086
  let instanceDeletes = /* @__PURE__ */ new Set();
26913
27087
  let groupMembers = /* @__PURE__ */ new Map();
26914
27088
  if (geometryCommands.length || commands.some(
26915
- (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)
27089
+ (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)
26916
27090
  )) {
26917
27091
  for (const [pageId2, path2] of pages) {
26918
27092
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -27023,7 +27197,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
27023
27197
  textChanged = true;
27024
27198
  await noteTextSize(command2, root2);
27025
27199
  }
27026
- } else if (command2.type === "insert-text-field") {
27200
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
27027
27201
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots2, document, command2, check)) {
27028
27202
  dirty.set(path, root2);
27029
27203
  textChanged = true;
@@ -28214,7 +28388,16 @@ function copySnapshotScene(model) {
28214
28388
  source.fields,
28215
28389
  "text fields",
28216
28390
  1e4,
28217
- (field3) => fields(field3, ["start", "end", "cached", "formula"])
28391
+ (field3) => fields(field3, [
28392
+ "start",
28393
+ "end",
28394
+ "cached",
28395
+ "formula",
28396
+ "index",
28397
+ "format",
28398
+ "sourceKey",
28399
+ "editable"
28400
+ ])
28218
28401
  )
28219
28402
  },
28220
28403
  runs: list2(source.runs, "text runs", 1e5, (run) => ({