ooxml-core 1.9.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 (202) hide show
  1. package/dist/PptxHandler-DNZHAHUY.cjs +12 -0
  2. package/dist/PptxHandler-E44KDHMQ.mjs +3 -0
  3. package/dist/{PptxHandler-EX4WBIQQ.mjs → PptxHandler-NROFYT2N.mjs} +2 -2
  4. package/dist/automation/index.cjs +3236 -2258
  5. package/dist/automation/index.mjs +3236 -2258
  6. package/dist/{chunk-SWF7KVL5.cjs → chunk-2UVH6RHI.cjs} +1608 -1163
  7. package/dist/{chunk-M76PHYRR.mjs → chunk-7DSZI7S6.mjs} +1 -1
  8. package/dist/{chunk-AT66SA5M.cjs → chunk-7QZGRB3T.cjs} +28 -10
  9. package/dist/chunk-ANZ4Q6I3.cjs +21 -0
  10. package/dist/{chunk-CPKNMQLX.cjs → chunk-AWIDASUW.cjs} +25 -2
  11. package/dist/{chunk-SVQZXP3F.mjs → chunk-CBNKBVX5.mjs} +25 -2
  12. package/dist/{chunk-FIELY5PI.mjs → chunk-EC2W2MDY.mjs} +30 -2
  13. package/dist/chunk-EGTRL3QJ.mjs +19 -0
  14. package/dist/chunk-GXHKNSZX.mjs +9 -0
  15. package/dist/{chunk-OXHMZS7B.mjs → chunk-HCXUI5UC.mjs} +943 -273
  16. package/dist/chunk-HDQXPSHY.cjs +17 -0
  17. package/dist/chunk-KTYBFGEY.mjs +14 -0
  18. package/dist/chunk-QOO36KG4.cjs +42 -0
  19. package/dist/chunk-R2KZXD6U.mjs +39 -0
  20. package/dist/{chunk-IGOA57LE.mjs → chunk-U2DF3EGK.mjs} +1 -1
  21. package/dist/{chunk-OB277ZGE.mjs → chunk-UAY26XOI.mjs} +27 -9
  22. package/dist/{chunk-WSO4T2LJ.mjs → chunk-W5ARCUJB.mjs} +26 -3
  23. package/dist/chunk-XZPZHXV4.cjs +12 -0
  24. package/dist/{chunk-LCS3J3QI.mjs → chunk-YB5SRNFS.mjs} +717 -272
  25. package/dist/docx/layout/adapt-table.d.ts +2 -2
  26. package/dist/docx/layout/adapt-table.d.ts.map +1 -1
  27. package/dist/docx/layout/flow-table.d.ts.map +1 -1
  28. package/dist/docx/layout/index.cjs +554 -83
  29. package/dist/docx/layout/index.mjs +554 -84
  30. package/dist/docx/layout/nested-fragment-edges.d.ts +9 -0
  31. package/dist/docx/layout/nested-fragment-edges.d.ts.map +1 -0
  32. package/dist/docx/layout/nested-frame-profile.d.ts +9 -0
  33. package/dist/docx/layout/nested-frame-profile.d.ts.map +1 -0
  34. package/dist/docx/layout/page-cursor.d.ts +2 -0
  35. package/dist/docx/layout/page-cursor.d.ts.map +1 -1
  36. package/dist/docx/layout/result.d.ts +20 -0
  37. package/dist/docx/layout/result.d.ts.map +1 -1
  38. package/dist/docx/layout/table-border-layout.d.ts +16 -0
  39. package/dist/docx/layout/table-border-layout.d.ts.map +1 -0
  40. package/dist/docx/layout/table-cell-layout.d.ts +3 -2
  41. package/dist/docx/layout/table-cell-layout.d.ts.map +1 -1
  42. package/dist/docx/layout/table-content.d.ts +4 -0
  43. package/dist/docx/layout/table-content.d.ts.map +1 -0
  44. package/dist/docx/layout/table-footnotes.d.ts +5 -0
  45. package/dist/docx/layout/table-footnotes.d.ts.map +1 -1
  46. package/dist/docx/layout/table-frames.d.ts +4 -0
  47. package/dist/docx/layout/table-frames.d.ts.map +1 -0
  48. package/dist/docx/layout/table-layout.d.ts +8 -3
  49. package/dist/docx/layout/table-layout.d.ts.map +1 -1
  50. package/dist/docx/layout/table-note-completion.d.ts +5 -0
  51. package/dist/docx/layout/table-note-completion.d.ts.map +1 -0
  52. package/dist/docx/layout/table-note-stories.d.ts +6 -0
  53. package/dist/docx/layout/table-note-stories.d.ts.map +1 -0
  54. package/dist/pptx/automation/index.cjs +801 -296
  55. package/dist/pptx/automation/index.d.ts +5 -4
  56. package/dist/pptx/automation/index.d.ts.map +1 -1
  57. package/dist/pptx/automation/index.mjs +5 -5
  58. package/dist/pptx/chunks/{text-operations-BLodkuXE.d.ts → elements-DD3UGOMd.d.ts} +27 -3248
  59. package/dist/pptx/chunks/elements-DD3UGOMd.d.ts.map +1 -0
  60. package/dist/pptx/chunks/{index-B4cnSPNz.d.ts → index-BZrFyNtU.d.ts} +113 -5
  61. package/dist/pptx/chunks/index-BZrFyNtU.d.ts.map +1 -0
  62. package/dist/pptx/chunks/{index-BZh-IMkN.d.ts → index-DdX02BSm.d.ts} +19 -3
  63. package/dist/pptx/chunks/index-DdX02BSm.d.ts.map +1 -0
  64. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts +1512 -0
  65. package/dist/pptx/chunks/smart-art-ENMMEbmW.d.ts.map +1 -0
  66. package/dist/pptx/chunks/text-D49FKllA.d.ts +1473 -0
  67. package/dist/pptx/chunks/text-D49FKllA.d.ts.map +1 -0
  68. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts +3261 -0
  69. package/dist/pptx/chunks/text-operations-CyMTMfID.d.ts.map +1 -0
  70. package/dist/pptx/cli/index.cjs +801 -296
  71. package/dist/pptx/cli/index.d.ts +1 -1
  72. package/dist/pptx/cli/index.mjs +4 -4
  73. package/dist/pptx/converter/index.cjs +1 -0
  74. package/dist/pptx/converter/index.d.ts +1 -1
  75. package/dist/pptx/converter/index.mjs +2 -2
  76. package/dist/pptx/editor/render/collaboration-live-patch-target.cjs +2 -2
  77. package/dist/pptx/editor/render/collaboration-live-patch-target.mjs +1 -1
  78. package/dist/pptx/editor/render/find-replace.cjs +19 -18
  79. package/dist/pptx/editor/render/find-replace.d.ts +2 -2
  80. package/dist/pptx/editor/render/find-replace.mjs +3 -2
  81. package/dist/pptx/editor/render/font-family-update.cjs +14 -0
  82. package/dist/pptx/editor/render/font-family-update.d.ts +17 -0
  83. package/dist/pptx/editor/render/font-family-update.d.ts.map +1 -0
  84. package/dist/pptx/editor/render/font-family-update.mjs +1 -0
  85. package/dist/pptx/editor/render/paragraph-geometry-overrides.cjs +14 -0
  86. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts +17 -0
  87. package/dist/pptx/editor/render/paragraph-geometry-overrides.d.ts.map +1 -0
  88. package/dist/pptx/editor/render/paragraph-geometry-overrides.mjs +12 -0
  89. package/dist/pptx/editor/render/remap-text.cjs +2 -2
  90. package/dist/pptx/editor/render/remap-text.d.ts.map +1 -1
  91. package/dist/pptx/editor/render/remap-text.mjs +1 -1
  92. package/dist/pptx/editor/render/slide-operations.cjs +9 -8
  93. package/dist/pptx/editor/render/slide-operations.mjs +3 -2
  94. package/dist/pptx/editor/render/table-data-grid-ops.cjs +1 -1
  95. package/dist/pptx/editor/render/table-data-grid-ops.mjs +1 -1
  96. package/dist/pptx/editor/render/text-content-style.cjs +18 -0
  97. package/dist/pptx/editor/render/text-content-style.d.ts +9 -0
  98. package/dist/pptx/editor/render/text-content-style.d.ts.map +1 -0
  99. package/dist/pptx/editor/render/text-content-style.mjs +5 -0
  100. package/dist/pptx/editor/render/text-runs-style-patch.cjs +17 -0
  101. package/dist/pptx/editor/render/text-runs-style-patch.d.ts +7 -0
  102. package/dist/pptx/editor/render/text-runs-style-patch.d.ts.map +1 -0
  103. package/dist/pptx/editor/render/text-runs-style-patch.mjs +15 -0
  104. package/dist/pptx/editor/render/text-style-scope.cjs +173 -0
  105. package/dist/pptx/editor/render/text-style-scope.d.ts +76 -0
  106. package/dist/pptx/editor/render/text-style-scope.d.ts.map +1 -0
  107. package/dist/pptx/editor/render/text-style-scope.mjs +164 -0
  108. package/dist/pptx/editor/render/theme-editor-model.cjs +1 -1
  109. package/dist/pptx/editor/render/theme-editor-model.mjs +1 -1
  110. package/dist/pptx/editor/render/update-text-segment-style.cjs +11 -0
  111. package/dist/pptx/editor/render/update-text-segment-style.d.ts +14 -0
  112. package/dist/pptx/editor/render/update-text-segment-style.d.ts.map +1 -0
  113. package/dist/pptx/editor/render/update-text-segment-style.mjs +2 -0
  114. package/dist/pptx/index.cjs +1091 -296
  115. package/dist/pptx/index.d.ts +7 -5
  116. package/dist/pptx/index.mjs +5 -5
  117. package/dist/pptx/smartart-layouts/index.d.ts +1 -1
  118. package/dist/teams/index.cjs +590 -122
  119. package/dist/teams/index.mjs +590 -122
  120. package/dist/visio/date-cache.d.ts +3 -0
  121. package/dist/visio/date-cache.d.ts.map +1 -0
  122. package/dist/visio/edit-commands.d.ts +3 -3
  123. package/dist/visio/edit-commands.d.ts.map +1 -1
  124. package/dist/visio/edit-formatting-scope.d.ts.map +1 -1
  125. package/dist/visio/edit-recalculate-index.d.ts.map +1 -1
  126. package/dist/visio/edit-text-field-commands.d.ts +15 -0
  127. package/dist/visio/edit-text-field-commands.d.ts.map +1 -1
  128. package/dist/visio/edit-text-field.d.ts +2 -2
  129. package/dist/visio/edit-text-field.d.ts.map +1 -1
  130. package/dist/visio/edit.d.ts +1 -1
  131. package/dist/visio/edit.d.ts.map +1 -1
  132. package/dist/visio/index.cjs +501 -220
  133. package/dist/visio/index.d.ts +1 -1
  134. package/dist/visio/index.d.ts.map +1 -1
  135. package/dist/visio/index.mjs +501 -220
  136. package/dist/visio/model.d.ts +6 -0
  137. package/dist/visio/model.d.ts.map +1 -1
  138. package/dist/visio/shape-metadata.d.ts.map +1 -1
  139. package/dist/visio/shapes.d.ts.map +1 -1
  140. package/dist/visio/style.d.ts +1 -1
  141. package/dist/visio/style.d.ts.map +1 -1
  142. package/dist/visio/text-field-display.d.ts +3 -0
  143. package/dist/visio/text-field-display.d.ts.map +1 -1
  144. package/dist/visio/text-field-editability.d.ts +6 -0
  145. package/dist/visio/text-field-editability.d.ts.map +1 -0
  146. package/dist/visio/text-field-fraction.d.ts +3 -0
  147. package/dist/visio/text-field-fraction.d.ts.map +1 -0
  148. package/dist/visio/text-field-independent.d.ts +4 -0
  149. package/dist/visio/text-field-independent.d.ts.map +1 -0
  150. package/dist/visio/text-field-numeric.d.ts +1 -1
  151. package/dist/visio/text-field-numeric.d.ts.map +1 -1
  152. package/dist/visio/text-field-source.d.ts +6 -0
  153. package/dist/visio/text-field-source.d.ts.map +1 -0
  154. package/dist/visio/text-field-system-date.d.ts +4 -0
  155. package/dist/visio/text-field-system-date.d.ts.map +1 -0
  156. package/dist/visio/text-fields.d.ts +1 -0
  157. package/dist/visio/text-fields.d.ts.map +1 -1
  158. package/dist/visio/ui/edit-commands.d.ts.map +1 -1
  159. package/dist/visio/ui/index.cjs +514 -221
  160. package/dist/visio/ui/index.mjs +514 -221
  161. package/dist/visio/ui/snapshot-scene.d.ts.map +1 -1
  162. package/dist/visio/ui/text-field-catalog.d.ts.map +1 -1
  163. package/dist/xlsx/edit/pivots.d.ts.map +1 -1
  164. package/dist/xlsx/index.cjs +1362 -659
  165. package/dist/xlsx/index.mjs +1361 -660
  166. package/dist/xlsx/load/index.cjs +1091 -430
  167. package/dist/xlsx/load/index.mjs +1091 -430
  168. package/dist/xlsx/model-pivots.d.ts +31 -2
  169. package/dist/xlsx/model-pivots.d.ts.map +1 -1
  170. package/dist/xlsx/pivot/admission.d.ts.map +1 -1
  171. package/dist/xlsx/pivot/aggregate.d.ts +3 -1
  172. package/dist/xlsx/pivot/aggregate.d.ts.map +1 -1
  173. package/dist/xlsx/pivot/data.d.ts +2 -2
  174. package/dist/xlsx/pivot/data.d.ts.map +1 -1
  175. package/dist/xlsx/pivot/hierarchy-first.d.ts +21 -0
  176. package/dist/xlsx/pivot/hierarchy-first.d.ts.map +1 -0
  177. package/dist/xlsx/pivot/hierarchy.d.ts +2 -4
  178. package/dist/xlsx/pivot/hierarchy.d.ts.map +1 -1
  179. package/dist/xlsx/pivot/index.d.ts +2 -0
  180. package/dist/xlsx/pivot/index.d.ts.map +1 -1
  181. package/dist/xlsx/pivot/measures.d.ts +13 -0
  182. package/dist/xlsx/pivot/measures.d.ts.map +1 -0
  183. package/dist/xlsx/pivot/page-filter-admission.d.ts +5 -0
  184. package/dist/xlsx/pivot/page-filter-admission.d.ts.map +1 -0
  185. package/dist/xlsx/pivot/page-filter.d.ts +11 -0
  186. package/dist/xlsx/pivot/page-filter.d.ts.map +1 -0
  187. package/dist/xlsx/pivot/read.d.ts.map +1 -1
  188. package/dist/xlsx/pivot/table-xml.d.ts.map +1 -1
  189. package/dist/xlsx/pivot/values-axis.d.ts +12 -0
  190. package/dist/xlsx/pivot/values-axis.d.ts.map +1 -0
  191. package/dist/xlsx/ui/commands/i18n/navigation.d.ts.map +1 -1
  192. package/dist/xlsx/ui/commands/i18n/pivots.d.ts.map +1 -1
  193. package/dist/xlsx/ui/index.cjs +640 -137
  194. package/dist/xlsx/ui/index.mjs +640 -137
  195. package/package.json +2 -2
  196. package/dist/PptxHandler-AT7FVG5Q.mjs +0 -2
  197. package/dist/PptxHandler-VFSCECPL.cjs +0 -11
  198. package/dist/pptx/chunks/index-B4cnSPNz.d.ts.map +0 -1
  199. package/dist/pptx/chunks/index-BZh-IMkN.d.ts.map +0 -1
  200. package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts +0 -2970
  201. package/dist/pptx/chunks/smart-art-Q2kZQtHh.d.ts.map +0 -1
  202. package/dist/pptx/chunks/text-operations-BLodkuXE.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,35 @@ 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 visioDateSerial = (date2) => Number(((date2.getTime() - EPOCH) / 864e5).toFixed(8));
12221
- var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
12222
- function evaluateVisioTextField(formula, context) {
12223
- let ast;
12224
- try {
12225
- ast = parseVisioFormula(formula, { maxLength: 4096 });
12226
- } catch {
12227
- return void 0;
12228
- }
12229
- if (ast.kind === "call") {
12230
- const name3 = ast.name;
12231
- if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
12232
- const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
12233
- return value === void 0 ? void 0 : { kind: "string", text: value };
12234
- }
12235
- if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
12236
- if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
12237
- const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
12238
- const time = stamp ? Date.parse(stamp) : Number.NaN;
12239
- return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
12457
+ // visio/text-field-fraction.ts
12458
+ function fractionalFieldNumber(value, maxDenominator) {
12459
+ if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
12460
+ const absolute = Math.abs(value);
12461
+ let whole = Math.floor(absolute);
12462
+ const remainder = absolute - whole;
12463
+ let numerator = 0, denominator = 1, error = remainder;
12464
+ for (let candidate = 1; candidate <= maxDenominator; candidate++) {
12465
+ const top = Math.round(remainder * candidate);
12466
+ const fraction = top / candidate;
12467
+ const distance4 = Math.abs(remainder - fraction);
12468
+ if (distance4 < error || distance4 === error && fraction > numerator / denominator) {
12469
+ numerator = top;
12470
+ denominator = candidate;
12471
+ error = distance4;
12240
12472
  }
12241
- if (name3 === "PAGENAME" && ast.args.length <= 1)
12242
- return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
12243
12473
  }
12244
- try {
12245
- const result = evaluateVisioFormula(
12246
- ast,
12247
- context.resolve ?? (() => {
12248
- throw new Error("No cell context");
12249
- }),
12250
- {
12251
- ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
12252
- ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
12253
- }
12254
- );
12255
- return { kind: "number", value: result.value, unit: result.unit };
12256
- } catch {
12257
- return void 0;
12474
+ if (numerator === denominator) {
12475
+ whole++;
12476
+ numerator = 0;
12258
12477
  }
12259
- }
12260
- var MONTHS = [
12261
- "January",
12262
- "February",
12263
- "March",
12264
- "April",
12265
- "May",
12266
- "June",
12267
- "July",
12268
- "August",
12269
- "September",
12270
- "October",
12271
- "November",
12272
- "December"
12273
- ];
12274
- var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
12275
- var pad = (value, length = 2) => String(value).padStart(length, "0");
12276
- function dateToken(date2, token) {
12277
- const hours = date2.getUTCHours();
12278
- switch (token) {
12279
- case "yyyy":
12280
- return pad(date2.getUTCFullYear(), 4);
12281
- case "yy":
12282
- return pad(date2.getUTCFullYear() % 100);
12283
- case "MMMM":
12284
- return MONTHS[date2.getUTCMonth()];
12285
- case "MMM":
12286
- return MONTHS[date2.getUTCMonth()].slice(0, 3);
12287
- case "MM":
12288
- return pad(date2.getUTCMonth() + 1);
12289
- case "M":
12290
- return String(date2.getUTCMonth() + 1);
12291
- case "dddd":
12292
- return DAYS[date2.getUTCDay()];
12293
- case "ddd":
12294
- return DAYS[date2.getUTCDay()].slice(0, 3);
12295
- case "dd":
12296
- return pad(date2.getUTCDate());
12297
- case "d":
12298
- return String(date2.getUTCDate());
12299
- case "HH":
12300
- return pad(hours);
12301
- case "H":
12302
- return String(hours);
12303
- case "hh":
12304
- return pad(hours % 12 || 12);
12305
- case "h":
12306
- return String(hours % 12 || 12);
12307
- case "mm":
12308
- return pad(date2.getUTCMinutes());
12309
- case "ss":
12310
- return pad(date2.getUTCSeconds());
12311
- case "tt":
12312
- return hours < 12 ? "AM" : "PM";
12313
- default:
12314
- return void 0;
12315
- }
12316
- }
12317
- function formatDate(date2, picture) {
12318
- return picture.replace(
12319
- /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
12320
- (token) => {
12321
- if (token.startsWith('"')) return token.slice(1, -1);
12322
- return dateToken(date2, token) ?? token;
12323
- }
12324
- );
12325
- }
12326
- function formatNumber(value, picture) {
12327
- const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
12328
- if (!match) return void 0;
12329
- const decimals = match[2]?.length ?? 0;
12330
- const optional = match[2]?.startsWith("#") ?? false;
12331
- let text7 = value.toFixed(decimals);
12332
- if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
12333
- if (match[1]) {
12334
- const [whole, fraction] = text7.split(".");
12335
- text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
12336
- }
12337
- return text7 === "-0" ? "0" : text7;
12338
- }
12339
- var VISIO_FIELD_FORMATS = {
12340
- shortDate: "{{M/d/yyyy}}",
12341
- longDate: "{{dddd, MMMM d, yyyy}}",
12342
- time: "{{h:mm tt}}",
12343
- dateTime: "{{M/d/yyyy h:mm tt}}",
12344
- text: "@",
12345
- integer: "0",
12346
- decimal: "0.00",
12347
- decimalUnits: "0.00 u",
12348
- integerUnits: "0 u"
12349
- };
12350
- function formatVisioFieldValue(value, format4 = "") {
12351
- const picture = format4.trim();
12352
- if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
12353
- if (value.kind === "date") {
12354
- const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
12355
- return date2 === void 0 ? void 0 : formatDate(value.date, date2);
12356
- }
12357
- const units2 = / u$/.test(picture);
12358
- const body = picture.replace(/ u$/, "");
12359
- let number5 = value.value, suffix = "";
12360
- if (value.unit === "angle") {
12361
- number5 = number5 * 180 / Math.PI;
12362
- suffix = " deg.";
12363
- } else if (value.unit === "length") suffix = " in.";
12364
- else if (value.unit !== "scalar") return void 0;
12365
- const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
12366
- if (text7 === void 0) return void 0;
12367
- return units2 || body === "" ? `${text7}${suffix}` : text7;
12478
+ const text7 = numerator ? `${whole ? whole + " " : ""}${numerator}/${denominator}` : String(whole);
12479
+ return value < 0 && text7 !== "0" ? "-" + text7 : text7;
12368
12480
  }
12369
12481
 
12370
12482
  // visio/text-field-numeric.ts
12371
12483
  function numericFieldPicture(value, code, displayUnit) {
12372
- if (value.kind !== "number" || code < 2 || code > 9 || !Number.isInteger(code)) return void 0;
12484
+ if (value.kind !== "number" || code < 0 || code > 18 || code > 9 && code < 15 || !Number.isInteger(code))
12485
+ return void 0;
12373
12486
  const unit3 = displayUnit?.toUpperCase() ?? "NUM";
12374
12487
  const units2 = {
12375
12488
  NUM: ["scalar", 1, ""],
@@ -12382,21 +12495,106 @@ function numericFieldPicture(value, code, displayUnit) {
12382
12495
  };
12383
12496
  const definition = Object.hasOwn(units2, unit3) ? units2[unit3] : void 0;
12384
12497
  if (!definition || definition[0] !== value.unit) return void 0;
12385
- const decimals = Math.floor((code - 2) / 2);
12386
- const picture = decimals ? `0.${"0".repeat(decimals)}` : "0";
12387
- const text7 = formatVisioFieldValue(
12388
- { kind: "number", value: value.value * definition[1], unit: "scalar" },
12389
- picture
12390
- );
12498
+ const general = code < 2;
12499
+ const decimals = general ? 4 : Math.floor((code - 2) / 2);
12500
+ const picture = general ? "0.####" : decimals ? `0.${"0".repeat(decimals)}` : "0";
12501
+ const displayed = value.value * definition[1];
12502
+ if (!Number.isFinite(displayed)) return void 0;
12503
+ if (code >= 15) {
12504
+ const fraction = fractionalFieldNumber(displayed, code < 17 ? 9 : 99);
12505
+ return fraction === void 0 ? void 0 : fraction + (code % 2 === 0 ? definition[2] : "");
12506
+ }
12507
+ if ((general || !decimals) && Math.abs(displayed) > 1e15) return void 0;
12508
+ const scientific = decimals > 0 && (Math.abs(displayed) >= 1e15 || displayed !== 0 && Math.abs(displayed) < 0.5 / 10 ** decimals);
12509
+ let text7;
12510
+ if (scientific) {
12511
+ const [coefficient, power] = displayed.toExponential().split("e");
12512
+ let exponent = Number(power);
12513
+ let precision = Math.abs(displayed) >= 1e15 ? decimals : decimals - 1;
12514
+ const mantissaPicture = precision ? `0.${"0".repeat(precision)}` : "0";
12515
+ let mantissa = formatVisioFieldValue(
12516
+ { kind: "number", value: Number(coefficient), unit: "scalar" },
12517
+ mantissaPicture
12518
+ );
12519
+ if (mantissa === void 0) return void 0;
12520
+ if (Math.abs(Number(mantissa)) >= 10) {
12521
+ exponent += 1;
12522
+ precision = decimals;
12523
+ mantissa = Math.sign(displayed).toFixed(precision);
12524
+ }
12525
+ if (general) mantissa = mantissa.replace(/\.?0+$/, "");
12526
+ else if (!mantissa.includes(".")) mantissa += ".";
12527
+ text7 = mantissa + (code % 2 ? "e" : "E") + exponent;
12528
+ } else {
12529
+ text7 = formatVisioFieldValue({ kind: "number", value: displayed, unit: "scalar" }, picture);
12530
+ }
12391
12531
  return text7 === void 0 ? void 0 : text7 + (code % 2 ? definition[2] : "");
12392
12532
  }
12393
12533
 
12534
+ // visio/date-cache.ts
12535
+ function visioIsoDateSerial(text7) {
12536
+ const match = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?$/.exec(
12537
+ text7.trim()
12538
+ );
12539
+ if (!match) return void 0;
12540
+ const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
12541
+ const hour = Number(match[4] ?? 0), minute = Number(match[5] ?? 0), second = Number(match[6] ?? 0);
12542
+ const millisecond = Number((match[7] ?? "").padEnd(3, "0").slice(0, 3));
12543
+ if (year < 1 || hour > 23 || minute > 59 || second > 59) return void 0;
12544
+ const date2 = /* @__PURE__ */ new Date(0);
12545
+ date2.setUTCFullYear(year, month - 1, day);
12546
+ date2.setUTCHours(hour, minute, second, millisecond);
12547
+ if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month - 1 || date2.getUTCDate() !== day)
12548
+ return void 0;
12549
+ return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
12550
+ }
12551
+
12552
+ // visio/text-field-system-date.ts
12553
+ var LONG_DATE = "{{dddd, MMMM d, yyyy}}";
12554
+ function englishLongDateProfile(cached5) {
12555
+ const match = /^[A-Za-z]+, [A-Za-z]+ ([1-9]|[12]\d|3[01]), (\d{4})$/.exec(cached5);
12556
+ if (!match) return false;
12557
+ for (let month = 0; month < 12; month++) {
12558
+ const candidate = /* @__PURE__ */ new Date(0);
12559
+ candidate.setUTCFullYear(Number(match[2]), month, Number(match[1]));
12560
+ if (candidate.getUTCMonth() === month && candidate.getTime() >= Date.UTC(1899, 11, 30) && formatVisioFieldValue({ kind: "date", date: candidate }, LONG_DATE) === cached5)
12561
+ return true;
12562
+ }
12563
+ return false;
12564
+ }
12565
+ function systemDatePicture(date2, code, cached5) {
12566
+ if (!Number.isFinite(date2.getTime()) || date2.getTime() < Date.UTC(1899, 11, 30) || date2.getUTCFullYear() > 9999)
12567
+ return void 0;
12568
+ if (code === "204") return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
12569
+ if (code === "21" || code === "201")
12570
+ return englishLongDateProfile(cached5) ? formatVisioFieldValue({ kind: "date", date: date2 }, LONG_DATE) : void 0;
12571
+ if (code === "20" || code === "200") {
12572
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(cached5) || visioIsoDateSerial(cached5) === void 0)
12573
+ return void 0;
12574
+ return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
12575
+ }
12576
+ if (code !== "211" && code !== "212") return void 0;
12577
+ const match = /^(\d{4}-\d{2}-\d{2}) ([1-9]|1[0-2]):([0-5]\d)(?::([0-5]\d))? (AM|PM)$/.exec(
12578
+ cached5
12579
+ );
12580
+ if (!match || code === "212" !== (match[4] !== void 0)) return void 0;
12581
+ const hour = Number(match[2]) % 12 + (match[5] === "PM" ? 12 : 0);
12582
+ if (visioIsoDateSerial(
12583
+ `${match[1]}T${String(hour).padStart(2, "0")}:${match[3]}:${match[4] ?? "00"}`
12584
+ ) === void 0)
12585
+ return void 0;
12586
+ return formatVisioFieldValue(
12587
+ { kind: "date", date: date2 },
12588
+ code === "211" ? "{{yyyy-MM-dd h:mm tt}}" : "{{yyyy-MM-dd h:mm:ss tt}}"
12589
+ );
12590
+ }
12591
+
12394
12592
  // visio/text-field-display.ts
12395
12593
  function cachedValue(value, unit3) {
12396
12594
  if (value === void 0) return void 0;
12397
12595
  if (unit3 === "STR") return { kind: "string", text: value };
12398
12596
  if (unit3 === "DATE") {
12399
- const date2 = visioSerialDate(Number(value));
12597
+ const date2 = visioSerialDate(visioIsoDateSerial(value) ?? Number(value));
12400
12598
  return date2 ? { kind: "date", date: date2 } : void 0;
12401
12599
  }
12402
12600
  try {
@@ -12412,7 +12610,12 @@ function textFieldDisplay(element2, sheet, context) {
12412
12610
  const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
12413
12611
  const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
12414
12612
  const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
12415
- 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
+ };
12416
12619
  if (!row2 || !context) return { text: cached5, ...result };
12417
12620
  const picture = format4?.value ?? "";
12418
12621
  const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
@@ -12426,6 +12629,8 @@ function textFieldDisplay(element2, sheet, context) {
12426
12629
  }
12427
12630
  if (source?.kind === "number" && code !== void 0)
12428
12631
  text8 = numericFieldPicture(source, Number(code), value?.unit) ?? cached5;
12632
+ if (source?.kind === "date" && code !== void 0)
12633
+ text8 = systemDatePicture(source.date, code, cached5) ?? cached5;
12429
12634
  return { text: text8, ...result };
12430
12635
  }
12431
12636
  const text7 = source ? formatVisioFieldValue(source, picture) : void 0;
@@ -13195,7 +13400,8 @@ function runStyle(cells4, resources, report, themeCells) {
13195
13400
  ...characterExtras(cells4, report)
13196
13401
  };
13197
13402
  }
13198
- 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);
13199
13405
  const cells4 = sheet.cells;
13200
13406
  const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
13201
13407
  const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
@@ -13230,7 +13436,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
13230
13436
  start: textOffset,
13231
13437
  end: textOffset + field3.text.length,
13232
13438
  cached: field3.cached,
13233
- ...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 }
13234
13442
  });
13235
13443
  append(field3.text);
13236
13444
  } else if (element2.localName !== "pp" && element2.localName !== "tp") {
@@ -13629,15 +13837,6 @@ function booleanValue(text7) {
13629
13837
  const value = numeric3(text7);
13630
13838
  return value === void 0 ? void 0 : value !== 0;
13631
13839
  }
13632
- function isoSerialDays(text7) {
13633
- const match = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?)?$/.exec(
13634
- text7.trim()
13635
- );
13636
- if (!match) return void 0;
13637
- const [year, month, day, hour, minute, second] = match.slice(1).map((part) => Number(part ?? 0));
13638
- const time = Date.UTC(year, month - 1, day, hour, minute, second);
13639
- return Number.isFinite(time) ? (time - Date.UTC(1899, 11, 30)) / 864e5 : void 0;
13640
- }
13641
13840
  function property(row2, budget, report) {
13642
13841
  const get = (key2) => cached2(row2.cells, key2, budget, report);
13643
13842
  const rawType = get("Type"), rawValue = get("Value");
@@ -13648,7 +13847,7 @@ function property(row2, budget, report) {
13648
13847
  if (rawValue !== void 0 && row2.cells.get("Value")?.error === void 0) {
13649
13848
  if (type === 0 || type === 1 || type === 4) value = budget.retain(rawValue);
13650
13849
  else if (type === 3) value = booleanValue(rawValue);
13651
- else if (type === 5) value = numeric3(rawValue) ?? isoSerialDays(rawValue);
13850
+ else if (type === 5) value = numeric3(rawValue) ?? visioIsoDateSerial(rawValue);
13652
13851
  else if (valueKind !== "unparsed") value = numeric3(rawValue);
13653
13852
  }
13654
13853
  if (value === void 0) {
@@ -14280,7 +14479,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
14280
14479
  context.resources,
14281
14480
  report,
14282
14481
  context.consumeText,
14283
- 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
14284
14484
  ),
14285
14485
  hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
14286
14486
  visibility: {
@@ -16000,6 +16200,35 @@ function snapshotGuideEdit(edit) {
16000
16200
  }
16001
16201
 
16002
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
+ }
16003
16232
  function snapshotTextFieldInsert(edit) {
16004
16233
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
16005
16234
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -16734,6 +16963,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
16734
16963
  return { ...target2, type: edit.type, text: text7(edit.text) };
16735
16964
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text7);
16736
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
+ }
16737
16974
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
16738
16975
  if (edit.type === "reorder-shape") {
16739
16976
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -16941,6 +17178,8 @@ function snapshotEdits(edits) {
16941
17178
  return snapshotTextRanges(command2, text7);
16942
17179
  case "insert-text-field":
16943
17180
  return snapshotTextFieldInsert(command2);
17181
+ case "update-text-field":
17182
+ return snapshotTextFieldUpdate(command2);
16944
17183
  case "delete-shape":
16945
17184
  return { type: command2.type, ...target2 };
16946
17185
  case "rotate-shape":
@@ -17586,6 +17825,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
17586
17825
  continue;
17587
17826
  const source = executableCellFormula(attribute2(node2, "F"));
17588
17827
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
17828
+ if (independentTextFieldFormula(node2, source)) continue;
17589
17829
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
17590
17830
  if (isConnectedGlueCell(node2, source)) continue;
17591
17831
  const owner = node2.parentNode;
@@ -21354,7 +21594,8 @@ function shapeResolver(shape) {
21354
21594
  }
21355
21595
  function valueCell(value) {
21356
21596
  if (value.kind === "string") return { v: value.text, u: "STR", type: 0 };
21357
- if (value.kind === "date") return { v: String(visioDateSerial(value.date)), u: "DATE", type: 5 };
21597
+ if (value.kind === "date")
21598
+ return { v: value.date.toISOString().replace(/Z$/, ""), u: "DATE", type: 5 };
21358
21599
  const unit3 = value.unit === "length" ? "IN" : value.unit === "angle" ? "DEG" : void 0;
21359
21600
  return { v: String(Number(value.value.toFixed(10))), ...unit3 ? { u: unit3 } : {}, type: 2 };
21360
21601
  }
@@ -21394,9 +21635,23 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21394
21635
  effectiveFormattingRows(shape, document, "Paragraph")
21395
21636
  );
21396
21637
  const rows = formattingRows(shape, "Field");
21397
- const point2 = insertionPoint(text7, edit.offset);
21398
- 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)
21399
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
+ }
21400
21655
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
21401
21656
  let value;
21402
21657
  try {
@@ -21409,9 +21664,19 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21409
21664
  "UNSUPPORTED_TEXT_FIELD",
21410
21665
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
21411
21666
  );
21412
- const display = formatVisioFieldValue(value, edit.format ?? "");
21667
+ const format4 = edit.format ?? "";
21668
+ const display = formatVisioFieldValue(value, format4);
21413
21669
  if (display === void 0)
21414
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
+ }
21415
21680
  if (texts[0])
21416
21681
  await assertFormattingDependencies(
21417
21682
  pkg,
@@ -21419,31 +21684,49 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21419
21684
  roots2,
21420
21685
  edit.pageId,
21421
21686
  shape,
21422
- /* @__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
+ ]),
21423
21697
  check
21424
21698
  );
21425
21699
  check();
21426
- 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);
21427
21701
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
21428
21702
  if (!section3) {
21429
21703
  section3 = owner.createElementNS(ns, "Section");
21430
21704
  section3.setAttribute("N", "Field");
21431
21705
  shape.insertBefore(section3, texts[0] ?? null);
21432
21706
  }
21433
- const row2 = owner.createElementNS(ns, "Row");
21434
- row2.setAttribute("IX", index);
21707
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
21708
+ if (!existing) row2.setAttribute("IX", index);
21435
21709
  const cell = (name3, v, extra = {}) => {
21436
- const node2 = owner.createElementNS(ns, "Cell");
21710
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
21437
21711
  node2.setAttribute("N", name3);
21438
21712
  node2.setAttribute("V", v);
21713
+ if (updating) {
21714
+ node2.removeAttribute("U");
21715
+ node2.removeAttribute("F");
21716
+ }
21439
21717
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
21440
- row2.appendChild(node2);
21718
+ if (!node2.parentNode) row2.appendChild(node2);
21441
21719
  };
21442
- const stored = valueCell(value);
21720
+ const stored = prepared;
21443
21721
  cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
21444
- if (edit.format) cell("Format", edit.format, { F: `"${edit.format.replaceAll('"', '""')}"` });
21722
+ if (format4 || updating)
21723
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
21445
21724
  cell("Type", String(stored.type));
21446
- section3.appendChild(row2);
21725
+ if (!row2.parentNode) section3.appendChild(row2);
21726
+ if (updating) {
21727
+ markers[0].textContent = display;
21728
+ return true;
21729
+ }
21447
21730
  const field3 = owner.createElementNS(ns, "fld");
21448
21731
  field3.setAttribute("IX", index);
21449
21732
  field3.appendChild(owner.createTextNode(display));
@@ -26795,7 +27078,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26795
27078
  const dirty = /* @__PURE__ */ new Map();
26796
27079
  const roots2 = /* @__PURE__ */ new Map();
26797
27080
  const geometryCommands = commands.filter(
26798
- (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)
26799
27082
  );
26800
27083
  let document;
26801
27084
  let masterMovePins = emptyMasterMoveProof();
@@ -26803,7 +27086,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26803
27086
  let instanceDeletes = /* @__PURE__ */ new Set();
26804
27087
  let groupMembers = /* @__PURE__ */ new Map();
26805
27088
  if (geometryCommands.length || commands.some(
26806
- (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)
26807
27090
  )) {
26808
27091
  for (const [pageId2, path2] of pages) {
26809
27092
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -26914,7 +27197,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26914
27197
  textChanged = true;
26915
27198
  await noteTextSize(command2, root2);
26916
27199
  }
26917
- } else if (command2.type === "insert-text-field") {
27200
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
26918
27201
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots2, document, command2, check)) {
26919
27202
  dirty.set(path, root2);
26920
27203
  textChanged = true;
@@ -28105,7 +28388,16 @@ function copySnapshotScene(model) {
28105
28388
  source.fields,
28106
28389
  "text fields",
28107
28390
  1e4,
28108
- (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
+ ])
28109
28401
  )
28110
28402
  },
28111
28403
  runs: list2(source.runs, "text runs", 1e5, (run) => ({
@@ -32790,6 +33082,7 @@ function visioTextBlockEdit(page, shape, frame) {
32790
33082
  // visio/ui/text-field-catalog.ts
32791
33083
  var dateFormats = [
32792
33084
  { label: "Short date (10/9/2026)", format: VISIO_FIELD_FORMATS.shortDate },
33085
+ { label: "ISO date (2026-10-09)", format: VISIO_FIELD_FORMATS.isoDate },
32793
33086
  { label: "Long date (Friday, October 9, 2026)", format: VISIO_FIELD_FORMATS.longDate },
32794
33087
  { label: "Time (2:05 PM)", format: VISIO_FIELD_FORMATS.time },
32795
33088
  { label: "Date and time", format: VISIO_FIELD_FORMATS.dateTime }