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
@@ -3814,6 +3814,208 @@ function takeDeferredTextSizes(root2) {
3814
3814
  return shapes;
3815
3815
  }
3816
3816
 
3817
+ // visio/text-fields.ts
3818
+ var PROPERTY_FUNCTIONS = {
3819
+ TITLE: "title",
3820
+ SUBJECT: "subject",
3821
+ CREATOR: "creator",
3822
+ KEYWORDS: "keywords",
3823
+ DESCRIPTION: "description",
3824
+ CATEGORY: "category",
3825
+ COMPANY: "company",
3826
+ MANAGER: "manager"
3827
+ };
3828
+ var DATE_FUNCTIONS = {
3829
+ NOW: void 0,
3830
+ DOCCREATION: "created",
3831
+ DOCLASTSAVE: "modified",
3832
+ DOCLASTEDIT: "modified",
3833
+ DOCLASTPRINT: "lastPrinted"
3834
+ };
3835
+ var VISIO_FIELD_FUNCTIONS = [
3836
+ ...Object.keys(PROPERTY_FUNCTIONS),
3837
+ ...Object.keys(DATE_FUNCTIONS),
3838
+ "PAGENAME"
3839
+ ];
3840
+ function visioWallClock(date2) {
3841
+ return new Date(
3842
+ Date.UTC(
3843
+ date2.getFullYear(),
3844
+ date2.getMonth(),
3845
+ date2.getDate(),
3846
+ date2.getHours(),
3847
+ date2.getMinutes(),
3848
+ date2.getSeconds()
3849
+ )
3850
+ );
3851
+ }
3852
+ var EPOCH = Date.UTC(1899, 11, 30);
3853
+ var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
3854
+ function evaluateVisioTextField(formula, context) {
3855
+ let ast;
3856
+ try {
3857
+ ast = parseVisioFormula(formula, { maxLength: 4096 });
3858
+ } catch {
3859
+ return void 0;
3860
+ }
3861
+ if (ast.kind === "call") {
3862
+ const name3 = ast.name;
3863
+ if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
3864
+ const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
3865
+ return value === void 0 ? void 0 : { kind: "string", text: value };
3866
+ }
3867
+ if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
3868
+ if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
3869
+ const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
3870
+ const time = stamp ? Date.parse(stamp) : Number.NaN;
3871
+ return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
3872
+ }
3873
+ if (name3 === "PAGENAME" && ast.args.length <= 1)
3874
+ return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
3875
+ }
3876
+ try {
3877
+ const result = evaluateVisioFormula(
3878
+ ast,
3879
+ context.resolve ?? (() => {
3880
+ throw new Error("No cell context");
3881
+ }),
3882
+ {
3883
+ ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
3884
+ ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
3885
+ }
3886
+ );
3887
+ return { kind: "number", value: result.value, unit: result.unit };
3888
+ } catch {
3889
+ return void 0;
3890
+ }
3891
+ }
3892
+ var MONTHS = [
3893
+ "January",
3894
+ "February",
3895
+ "March",
3896
+ "April",
3897
+ "May",
3898
+ "June",
3899
+ "July",
3900
+ "August",
3901
+ "September",
3902
+ "October",
3903
+ "November",
3904
+ "December"
3905
+ ];
3906
+ var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
3907
+ var pad = (value, length = 2) => String(value).padStart(length, "0");
3908
+ function dateToken(date2, token) {
3909
+ const hours = date2.getUTCHours();
3910
+ switch (token) {
3911
+ case "yyyy":
3912
+ return pad(date2.getUTCFullYear(), 4);
3913
+ case "yy":
3914
+ return pad(date2.getUTCFullYear() % 100);
3915
+ case "MMMM":
3916
+ return MONTHS[date2.getUTCMonth()];
3917
+ case "MMM":
3918
+ return MONTHS[date2.getUTCMonth()].slice(0, 3);
3919
+ case "MM":
3920
+ return pad(date2.getUTCMonth() + 1);
3921
+ case "M":
3922
+ return String(date2.getUTCMonth() + 1);
3923
+ case "dddd":
3924
+ return DAYS[date2.getUTCDay()];
3925
+ case "ddd":
3926
+ return DAYS[date2.getUTCDay()].slice(0, 3);
3927
+ case "dd":
3928
+ return pad(date2.getUTCDate());
3929
+ case "d":
3930
+ return String(date2.getUTCDate());
3931
+ case "HH":
3932
+ return pad(hours);
3933
+ case "H":
3934
+ return String(hours);
3935
+ case "hh":
3936
+ return pad(hours % 12 || 12);
3937
+ case "h":
3938
+ return String(hours % 12 || 12);
3939
+ case "mm":
3940
+ return pad(date2.getUTCMinutes());
3941
+ case "ss":
3942
+ return pad(date2.getUTCSeconds());
3943
+ case "tt":
3944
+ return hours < 12 ? "AM" : "PM";
3945
+ default:
3946
+ return void 0;
3947
+ }
3948
+ }
3949
+ function formatDate(date2, picture) {
3950
+ return picture.replace(
3951
+ /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
3952
+ (token) => {
3953
+ if (token.startsWith('"')) return token.slice(1, -1);
3954
+ return dateToken(date2, token) ?? token;
3955
+ }
3956
+ );
3957
+ }
3958
+ function formatNumber(value, picture) {
3959
+ const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
3960
+ if (!match) return void 0;
3961
+ const decimals = match[2]?.length ?? 0;
3962
+ const optional = match[2]?.startsWith("#") ?? false;
3963
+ const [coefficient, exponent = "0"] = Math.abs(value).toString().split("e");
3964
+ const shifted = Number(coefficient + "e" + (Number(exponent) + decimals));
3965
+ const rounded = Math.floor(shifted + 0.5) / 10 ** decimals;
3966
+ let text7 = (Math.sign(value) * rounded).toFixed(decimals);
3967
+ if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
3968
+ if (match[1]) {
3969
+ const [whole, fraction] = text7.split(".");
3970
+ text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
3971
+ }
3972
+ return text7 === "-0" ? "0" : text7;
3973
+ }
3974
+ var VISIO_FIELD_FORMATS = {
3975
+ shortDate: "{{M/d/yyyy}}",
3976
+ isoDate: "{{yyyy-MM-dd}}",
3977
+ longDate: "{{dddd, MMMM d, yyyy}}",
3978
+ time: "{{h:mm tt}}",
3979
+ dateTime: "{{M/d/yyyy h:mm tt}}",
3980
+ text: "@",
3981
+ integer: "0",
3982
+ decimal: "0.00",
3983
+ decimalUnits: "0.00 u",
3984
+ integerUnits: "0 u"
3985
+ };
3986
+ function formatVisioFieldValue(value, format4 = "") {
3987
+ const picture = format4.trim();
3988
+ if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
3989
+ if (value.kind === "date") {
3990
+ const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
3991
+ return date2 === void 0 ? void 0 : formatDate(value.date, date2);
3992
+ }
3993
+ const units2 = / u$/.test(picture);
3994
+ const body = picture.replace(/ u$/, "");
3995
+ let number5 = value.value, suffix = "";
3996
+ if (value.unit === "angle") {
3997
+ number5 = number5 * 180 / Math.PI;
3998
+ suffix = " deg.";
3999
+ } else if (value.unit === "length") suffix = " in.";
4000
+ else if (value.unit !== "scalar") return void 0;
4001
+ const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
4002
+ if (text7 === void 0) return void 0;
4003
+ return units2 || body === "" ? `${text7}${suffix}` : text7;
4004
+ }
4005
+
4006
+ // visio/text-field-independent.ts
4007
+ function independentTextFieldFormula(cell, formula) {
4008
+ const row2 = cell.parentNode, section3 = row2?.parentNode;
4009
+ 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"))
4010
+ return false;
4011
+ if (attribute2(cell, "N") === "Format")
4012
+ return /^\s*FIELDPICTURE\(\s*(2|37|204)\s*\)\s*$/i.test(formula);
4013
+ if (attribute2(cell, "N") !== "Value") return false;
4014
+ if (/^\s*DATE\(\s*\d{1,4}\s*,\s*\d{1,2}\s*,\s*\d{1,2}\s*\)\s*$/i.test(formula)) return true;
4015
+ const direct = /^\s*([A-Z]+)\(\s*\)\s*$/i.exec(formula)?.[1]?.toUpperCase();
4016
+ return direct !== void 0 && VISIO_FIELD_FUNCTIONS.includes(direct);
4017
+ }
4018
+
3817
4019
  // visio/edit-connector-glue.ts
3818
4020
  var VISIO_WALK_GLUE = "_WALKGLUE(BegTrigger,EndTrigger,WalkPreference)";
3819
4021
  var walkGlue = /^\s*_WALKGLUE\((?:BegTrigger,EndTrigger|EndTrigger,BegTrigger),WalkPreference\)\s*$/i;
@@ -3923,7 +4125,7 @@ function indexCells(roots2, options) {
3923
4125
  unit: cellUnit(cell, relative)
3924
4126
  };
3925
4127
  const source = attribute2(node2, "F");
3926
- 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
4128
+ 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
3927
4129
  // (Visio's freshly dropped connector names its own sheet).
3928
4130
  !(/^(BegTrigger|EndTrigger)$/.test(cell) && isNativeGlueCell(cell, source))) {
3929
4131
  try {
@@ -9760,6 +9962,77 @@ async function prepareImages(shapes, pkg, sourcePart, report, options, converter
9760
9962
  }
9761
9963
  }
9762
9964
 
9965
+ // visio/text-field-source.ts
9966
+ var proofs = /* @__PURE__ */ new WeakMap();
9967
+ function textFieldSourceKey(cells4) {
9968
+ if (proofs.has(cells4)) return proofs.get(cells4);
9969
+ if (cells4.size > 64) {
9970
+ proofs.set(cells4, void 0);
9971
+ return void 0;
9972
+ }
9973
+ const key2 = JSON.stringify(
9974
+ [...cells4].sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0).map(([name3, cell]) => [
9975
+ name3,
9976
+ cell.value ?? null,
9977
+ cell.formula ?? null,
9978
+ cell.unit ?? null,
9979
+ cell.error ?? null
9980
+ ])
9981
+ );
9982
+ const bounded6 = key2.length <= 2048 ? key2 : void 0;
9983
+ proofs.set(cells4, bounded6);
9984
+ return bounded6;
9985
+ }
9986
+
9987
+ // visio/text-field-editability.ts
9988
+ function assertEditableFieldRow(existing) {
9989
+ for (const name3 of ["Calendar", "ObjectKind"]) {
9990
+ const cell = children2(existing, "Cell").find((cell2) => attribute2(cell2, "N") === name3);
9991
+ if (cell && (attribute2(cell, "V") !== "0" || cell.hasAttribute("F") || cell.hasAttribute("E")))
9992
+ fail(
9993
+ "UNSUPPORTED_TEXT_FIELD",
9994
+ "Nonstandard field calendar or object profiles cannot be edited."
9995
+ );
9996
+ }
9997
+ for (const cell of children2(existing, "Cell")) {
9998
+ const name3 = attribute2(cell, "N") ?? "";
9999
+ if (/^(value|format|type|calendar|objectkind)$/i.test(name3) && !["Value", "Format", "Type", "Calendar", "ObjectKind"].includes(name3))
10000
+ fail("UNSUPPORTED_TEXT_FIELD", "Noncanonical field cell names cannot be edited.");
10001
+ if (["Value", "Format", "Type"].includes(attribute2(cell, "N") ?? "") && (cell.hasAttribute("E") || /^\s*(Inh|GUARD\s*\()/i.test(attribute2(cell, "F") ?? "")))
10002
+ fail("UNSUPPORTED_TEXT_FIELD", "Protected or inherited field cells cannot be edited.");
10003
+ }
10004
+ }
10005
+ function assertEditableFieldShape(shape) {
10006
+ 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))
10007
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field edits require a top-level plain local shape.");
10008
+ }
10009
+ function editableTextFieldIndices(text7, allowed) {
10010
+ const result = /* @__PURE__ */ new Set();
10011
+ if (!allowed || !text7) return result;
10012
+ const shape = text7.parentNode;
10013
+ try {
10014
+ assertEditableFieldShape(shape);
10015
+ assertFormattingText(shape);
10016
+ const rows = formattingRows(shape, "Field");
10017
+ const markers = children2(text7, "fld");
10018
+ const counts = /* @__PURE__ */ new Map();
10019
+ for (const marker2 of markers) {
10020
+ const index = attribute2(marker2, "IX");
10021
+ counts.set(index, (counts.get(index) ?? 0) + 1);
10022
+ }
10023
+ for (const [index, row2] of rows) {
10024
+ if (counts.get(index) !== 1 || textFieldSourceKey(readCells(row2)) === void 0) continue;
10025
+ try {
10026
+ assertEditableFieldRow(row2);
10027
+ result.add(index);
10028
+ } catch {
10029
+ }
10030
+ }
10031
+ } catch {
10032
+ }
10033
+ return result;
10034
+ }
10035
+
9763
10036
  // geometry/svg-path-curves.ts
9764
10037
  function sampleCubic(p0, p1, p2, p3, segments, out) {
9765
10038
  for (let i = 1; i <= segments; i++) {
@@ -12175,195 +12448,35 @@ function visioFieldCase(text7, upper) {
12175
12448
  }).join("");
12176
12449
  }
12177
12450
 
12178
- // visio/text-fields.ts
12179
- var PROPERTY_FUNCTIONS = {
12180
- TITLE: "title",
12181
- SUBJECT: "subject",
12182
- CREATOR: "creator",
12183
- KEYWORDS: "keywords",
12184
- DESCRIPTION: "description",
12185
- CATEGORY: "category",
12186
- COMPANY: "company",
12187
- MANAGER: "manager"
12188
- };
12189
- var DATE_FUNCTIONS = {
12190
- NOW: void 0,
12191
- DOCCREATION: "created",
12192
- DOCLASTSAVE: "modified",
12193
- DOCLASTEDIT: "modified",
12194
- DOCLASTPRINT: "lastPrinted"
12195
- };
12196
- var VISIO_FIELD_FUNCTIONS = [
12197
- ...Object.keys(PROPERTY_FUNCTIONS),
12198
- ...Object.keys(DATE_FUNCTIONS),
12199
- "PAGENAME"
12200
- ];
12201
- function visioWallClock(date2) {
12202
- return new Date(
12203
- Date.UTC(
12204
- date2.getFullYear(),
12205
- date2.getMonth(),
12206
- date2.getDate(),
12207
- date2.getHours(),
12208
- date2.getMinutes(),
12209
- date2.getSeconds()
12210
- )
12211
- );
12212
- }
12213
- var EPOCH = Date.UTC(1899, 11, 30);
12214
- var visioDateSerial = (date2) => Number(((date2.getTime() - EPOCH) / 864e5).toFixed(8));
12215
- var visioSerialDate = (serial) => Number.isFinite(serial) && Math.abs(serial) < 3e6 ? new Date(EPOCH + Math.round(serial * 864e5)) : void 0;
12216
- function evaluateVisioTextField(formula, context) {
12217
- let ast;
12218
- try {
12219
- ast = parseVisioFormula(formula, { maxLength: 4096 });
12220
- } catch {
12221
- return void 0;
12222
- }
12223
- if (ast.kind === "call") {
12224
- const name3 = ast.name;
12225
- if (Object.hasOwn(PROPERTY_FUNCTIONS, name3) && !ast.args.length) {
12226
- const value = context.properties?.[PROPERTY_FUNCTIONS[name3]];
12227
- return value === void 0 ? void 0 : { kind: "string", text: value };
12228
- }
12229
- if (Object.hasOwn(DATE_FUNCTIONS, name3) && !ast.args.length) {
12230
- if (name3 === "NOW") return context.now ? { kind: "date", date: context.now } : void 0;
12231
- const stamp = context.properties?.[DATE_FUNCTIONS[name3]];
12232
- const time = stamp ? Date.parse(stamp) : Number.NaN;
12233
- return Number.isFinite(time) ? { kind: "date", date: visioWallClock(new Date(time)) } : void 0;
12451
+ // visio/text-field-fraction.ts
12452
+ function fractionalFieldNumber(value, maxDenominator) {
12453
+ if (!Number.isFinite(value) || Math.abs(value) > 1e15) return void 0;
12454
+ const absolute = Math.abs(value);
12455
+ let whole = Math.floor(absolute);
12456
+ const remainder = absolute - whole;
12457
+ let numerator = 0, denominator = 1, error = remainder;
12458
+ for (let candidate = 1; candidate <= maxDenominator; candidate++) {
12459
+ const top = Math.round(remainder * candidate);
12460
+ const fraction = top / candidate;
12461
+ const distance4 = Math.abs(remainder - fraction);
12462
+ if (distance4 < error || distance4 === error && fraction > numerator / denominator) {
12463
+ numerator = top;
12464
+ denominator = candidate;
12465
+ error = distance4;
12234
12466
  }
12235
- if (name3 === "PAGENAME" && ast.args.length <= 1)
12236
- return context.pageName === void 0 ? void 0 : { kind: "string", text: context.pageName };
12237
12467
  }
12238
- try {
12239
- const result = evaluateVisioFormula(
12240
- ast,
12241
- context.resolve ?? (() => {
12242
- throw new Error("No cell context");
12243
- }),
12244
- {
12245
- ...context.pageNumber === void 0 ? {} : { pageNumber: context.pageNumber },
12246
- ...context.pageCount === void 0 ? {} : { pageCount: context.pageCount }
12247
- }
12248
- );
12249
- return { kind: "number", value: result.value, unit: result.unit };
12250
- } catch {
12251
- return void 0;
12468
+ if (numerator === denominator) {
12469
+ whole++;
12470
+ numerator = 0;
12252
12471
  }
12253
- }
12254
- var MONTHS = [
12255
- "January",
12256
- "February",
12257
- "March",
12258
- "April",
12259
- "May",
12260
- "June",
12261
- "July",
12262
- "August",
12263
- "September",
12264
- "October",
12265
- "November",
12266
- "December"
12267
- ];
12268
- var DAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
12269
- var pad = (value, length = 2) => String(value).padStart(length, "0");
12270
- function dateToken(date2, token) {
12271
- const hours = date2.getUTCHours();
12272
- switch (token) {
12273
- case "yyyy":
12274
- return pad(date2.getUTCFullYear(), 4);
12275
- case "yy":
12276
- return pad(date2.getUTCFullYear() % 100);
12277
- case "MMMM":
12278
- return MONTHS[date2.getUTCMonth()];
12279
- case "MMM":
12280
- return MONTHS[date2.getUTCMonth()].slice(0, 3);
12281
- case "MM":
12282
- return pad(date2.getUTCMonth() + 1);
12283
- case "M":
12284
- return String(date2.getUTCMonth() + 1);
12285
- case "dddd":
12286
- return DAYS[date2.getUTCDay()];
12287
- case "ddd":
12288
- return DAYS[date2.getUTCDay()].slice(0, 3);
12289
- case "dd":
12290
- return pad(date2.getUTCDate());
12291
- case "d":
12292
- return String(date2.getUTCDate());
12293
- case "HH":
12294
- return pad(hours);
12295
- case "H":
12296
- return String(hours);
12297
- case "hh":
12298
- return pad(hours % 12 || 12);
12299
- case "h":
12300
- return String(hours % 12 || 12);
12301
- case "mm":
12302
- return pad(date2.getUTCMinutes());
12303
- case "ss":
12304
- return pad(date2.getUTCSeconds());
12305
- case "tt":
12306
- return hours < 12 ? "AM" : "PM";
12307
- default:
12308
- return void 0;
12309
- }
12310
- }
12311
- function formatDate(date2, picture) {
12312
- return picture.replace(
12313
- /yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|HH|H|hh|h|mm|ss|tt|"[^"]*"/g,
12314
- (token) => {
12315
- if (token.startsWith('"')) return token.slice(1, -1);
12316
- return dateToken(date2, token) ?? token;
12317
- }
12318
- );
12319
- }
12320
- function formatNumber(value, picture) {
12321
- const match = /^(#,##)?0(?:\.(0+|#+))?$/.exec(picture);
12322
- if (!match) return void 0;
12323
- const decimals = match[2]?.length ?? 0;
12324
- const optional = match[2]?.startsWith("#") ?? false;
12325
- let text7 = value.toFixed(decimals);
12326
- if (optional && text7.includes(".")) text7 = text7.replace(/\.?0+$/, "");
12327
- if (match[1]) {
12328
- const [whole, fraction] = text7.split(".");
12329
- text7 = whole.replace(/\B(?=(\d{3})+(?!\d))/g, ",") + (fraction ? `.${fraction}` : "");
12330
- }
12331
- return text7 === "-0" ? "0" : text7;
12332
- }
12333
- var VISIO_FIELD_FORMATS = {
12334
- shortDate: "{{M/d/yyyy}}",
12335
- longDate: "{{dddd, MMMM d, yyyy}}",
12336
- time: "{{h:mm tt}}",
12337
- dateTime: "{{M/d/yyyy h:mm tt}}",
12338
- text: "@",
12339
- integer: "0",
12340
- decimal: "0.00",
12341
- decimalUnits: "0.00 u",
12342
- integerUnits: "0 u"
12343
- };
12344
- function formatVisioFieldValue(value, format4 = "") {
12345
- const picture = format4.trim();
12346
- if (value.kind === "string") return picture === "" || picture === "@" ? value.text : void 0;
12347
- if (value.kind === "date") {
12348
- const date2 = /^\{\{(.+)\}\}$/.exec(picture)?.[1] ?? (picture ? void 0 : "M/d/yyyy");
12349
- return date2 === void 0 ? void 0 : formatDate(value.date, date2);
12350
- }
12351
- const units2 = / u$/.test(picture);
12352
- const body = picture.replace(/ u$/, "");
12353
- let number5 = value.value, suffix = "";
12354
- if (value.unit === "angle") {
12355
- number5 = number5 * 180 / Math.PI;
12356
- suffix = " deg.";
12357
- } else if (value.unit === "length") suffix = " in.";
12358
- else if (value.unit !== "scalar") return void 0;
12359
- const text7 = body === "" || body === "@" ? String(Number(number5.toFixed(4))) : formatNumber(Number(number5.toFixed(10)), body);
12360
- if (text7 === void 0) return void 0;
12361
- return units2 || body === "" ? `${text7}${suffix}` : text7;
12472
+ const text7 = numerator ? `${whole ? whole + " " : ""}${numerator}/${denominator}` : String(whole);
12473
+ return value < 0 && text7 !== "0" ? "-" + text7 : text7;
12362
12474
  }
12363
12475
 
12364
12476
  // visio/text-field-numeric.ts
12365
12477
  function numericFieldPicture(value, code, displayUnit) {
12366
- if (value.kind !== "number" || code < 2 || code > 9 || !Number.isInteger(code)) return void 0;
12478
+ if (value.kind !== "number" || code < 0 || code > 18 || code > 9 && code < 15 || !Number.isInteger(code))
12479
+ return void 0;
12367
12480
  const unit3 = displayUnit?.toUpperCase() ?? "NUM";
12368
12481
  const units2 = {
12369
12482
  NUM: ["scalar", 1, ""],
@@ -12376,21 +12489,106 @@ function numericFieldPicture(value, code, displayUnit) {
12376
12489
  };
12377
12490
  const definition = Object.hasOwn(units2, unit3) ? units2[unit3] : void 0;
12378
12491
  if (!definition || definition[0] !== value.unit) return void 0;
12379
- const decimals = Math.floor((code - 2) / 2);
12380
- const picture = decimals ? `0.${"0".repeat(decimals)}` : "0";
12381
- const text7 = formatVisioFieldValue(
12382
- { kind: "number", value: value.value * definition[1], unit: "scalar" },
12383
- picture
12384
- );
12492
+ const general = code < 2;
12493
+ const decimals = general ? 4 : Math.floor((code - 2) / 2);
12494
+ const picture = general ? "0.####" : decimals ? `0.${"0".repeat(decimals)}` : "0";
12495
+ const displayed = value.value * definition[1];
12496
+ if (!Number.isFinite(displayed)) return void 0;
12497
+ if (code >= 15) {
12498
+ const fraction = fractionalFieldNumber(displayed, code < 17 ? 9 : 99);
12499
+ return fraction === void 0 ? void 0 : fraction + (code % 2 === 0 ? definition[2] : "");
12500
+ }
12501
+ if ((general || !decimals) && Math.abs(displayed) > 1e15) return void 0;
12502
+ const scientific = decimals > 0 && (Math.abs(displayed) >= 1e15 || displayed !== 0 && Math.abs(displayed) < 0.5 / 10 ** decimals);
12503
+ let text7;
12504
+ if (scientific) {
12505
+ const [coefficient, power] = displayed.toExponential().split("e");
12506
+ let exponent = Number(power);
12507
+ let precision = Math.abs(displayed) >= 1e15 ? decimals : decimals - 1;
12508
+ const mantissaPicture = precision ? `0.${"0".repeat(precision)}` : "0";
12509
+ let mantissa = formatVisioFieldValue(
12510
+ { kind: "number", value: Number(coefficient), unit: "scalar" },
12511
+ mantissaPicture
12512
+ );
12513
+ if (mantissa === void 0) return void 0;
12514
+ if (Math.abs(Number(mantissa)) >= 10) {
12515
+ exponent += 1;
12516
+ precision = decimals;
12517
+ mantissa = Math.sign(displayed).toFixed(precision);
12518
+ }
12519
+ if (general) mantissa = mantissa.replace(/\.?0+$/, "");
12520
+ else if (!mantissa.includes(".")) mantissa += ".";
12521
+ text7 = mantissa + (code % 2 ? "e" : "E") + exponent;
12522
+ } else {
12523
+ text7 = formatVisioFieldValue({ kind: "number", value: displayed, unit: "scalar" }, picture);
12524
+ }
12385
12525
  return text7 === void 0 ? void 0 : text7 + (code % 2 ? definition[2] : "");
12386
12526
  }
12387
12527
 
12528
+ // visio/date-cache.ts
12529
+ function visioIsoDateSerial(text7) {
12530
+ const match = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?)?$/.exec(
12531
+ text7.trim()
12532
+ );
12533
+ if (!match) return void 0;
12534
+ const year = Number(match[1]), month = Number(match[2]), day = Number(match[3]);
12535
+ const hour = Number(match[4] ?? 0), minute = Number(match[5] ?? 0), second = Number(match[6] ?? 0);
12536
+ const millisecond = Number((match[7] ?? "").padEnd(3, "0").slice(0, 3));
12537
+ if (year < 1 || hour > 23 || minute > 59 || second > 59) return void 0;
12538
+ const date2 = /* @__PURE__ */ new Date(0);
12539
+ date2.setUTCFullYear(year, month - 1, day);
12540
+ date2.setUTCHours(hour, minute, second, millisecond);
12541
+ if (date2.getUTCFullYear() !== year || date2.getUTCMonth() !== month - 1 || date2.getUTCDate() !== day)
12542
+ return void 0;
12543
+ return (date2.getTime() - Date.UTC(1899, 11, 30)) / 864e5;
12544
+ }
12545
+
12546
+ // visio/text-field-system-date.ts
12547
+ var LONG_DATE = "{{dddd, MMMM d, yyyy}}";
12548
+ function englishLongDateProfile(cached5) {
12549
+ const match = /^[A-Za-z]+, [A-Za-z]+ ([1-9]|[12]\d|3[01]), (\d{4})$/.exec(cached5);
12550
+ if (!match) return false;
12551
+ for (let month = 0; month < 12; month++) {
12552
+ const candidate = /* @__PURE__ */ new Date(0);
12553
+ candidate.setUTCFullYear(Number(match[2]), month, Number(match[1]));
12554
+ if (candidate.getUTCMonth() === month && candidate.getTime() >= Date.UTC(1899, 11, 30) && formatVisioFieldValue({ kind: "date", date: candidate }, LONG_DATE) === cached5)
12555
+ return true;
12556
+ }
12557
+ return false;
12558
+ }
12559
+ function systemDatePicture(date2, code, cached5) {
12560
+ if (!Number.isFinite(date2.getTime()) || date2.getTime() < Date.UTC(1899, 11, 30) || date2.getUTCFullYear() > 9999)
12561
+ return void 0;
12562
+ if (code === "204") return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
12563
+ if (code === "21" || code === "201")
12564
+ return englishLongDateProfile(cached5) ? formatVisioFieldValue({ kind: "date", date: date2 }, LONG_DATE) : void 0;
12565
+ if (code === "20" || code === "200") {
12566
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(cached5) || visioIsoDateSerial(cached5) === void 0)
12567
+ return void 0;
12568
+ return formatVisioFieldValue({ kind: "date", date: date2 }, "{{yyyy-MM-dd}}");
12569
+ }
12570
+ if (code !== "211" && code !== "212") return void 0;
12571
+ const match = /^(\d{4}-\d{2}-\d{2}) ([1-9]|1[0-2]):([0-5]\d)(?::([0-5]\d))? (AM|PM)$/.exec(
12572
+ cached5
12573
+ );
12574
+ if (!match || code === "212" !== (match[4] !== void 0)) return void 0;
12575
+ const hour = Number(match[2]) % 12 + (match[5] === "PM" ? 12 : 0);
12576
+ if (visioIsoDateSerial(
12577
+ `${match[1]}T${String(hour).padStart(2, "0")}:${match[3]}:${match[4] ?? "00"}`
12578
+ ) === void 0)
12579
+ return void 0;
12580
+ return formatVisioFieldValue(
12581
+ { kind: "date", date: date2 },
12582
+ code === "211" ? "{{yyyy-MM-dd h:mm tt}}" : "{{yyyy-MM-dd h:mm:ss tt}}"
12583
+ );
12584
+ }
12585
+
12388
12586
  // visio/text-field-display.ts
12389
12587
  function cachedValue(value, unit3) {
12390
12588
  if (value === void 0) return void 0;
12391
12589
  if (unit3 === "STR") return { kind: "string", text: value };
12392
12590
  if (unit3 === "DATE") {
12393
- const date2 = visioSerialDate(Number(value));
12591
+ const date2 = visioSerialDate(visioIsoDateSerial(value) ?? Number(value));
12394
12592
  return date2 ? { kind: "date", date: date2 } : void 0;
12395
12593
  }
12396
12594
  try {
@@ -12406,7 +12604,12 @@ function textFieldDisplay(element2, sheet, context) {
12406
12604
  const row2 = sectionRows(sheet, "Field").find((candidate) => candidate.index === index);
12407
12605
  const value = row2?.cells.get("Value"), format4 = row2?.cells.get("Format");
12408
12606
  const formula = value?.formula && value.formula !== "Inh" ? value.formula : void 0;
12409
- const result = { cached: cached5, ...formula ? { formula } : {} };
12607
+ const sourceKey = row2 ? textFieldSourceKey(row2.cells) : void 0;
12608
+ const result = {
12609
+ cached: cached5,
12610
+ ...formula ? { formula } : {},
12611
+ ...sourceKey !== void 0 ? { index, format: format4?.value ?? "", sourceKey } : {}
12612
+ };
12410
12613
  if (!row2 || !context) return { text: cached5, ...result };
12411
12614
  const picture = format4?.value ?? "";
12412
12615
  const evaluated = formula ? evaluateVisioTextField(formula, context) : void 0;
@@ -12420,6 +12623,8 @@ function textFieldDisplay(element2, sheet, context) {
12420
12623
  }
12421
12624
  if (source?.kind === "number" && code !== void 0)
12422
12625
  text8 = numericFieldPicture(source, Number(code), value?.unit) ?? cached5;
12626
+ if (source?.kind === "date" && code !== void 0)
12627
+ text8 = systemDatePicture(source.date, code, cached5) ?? cached5;
12423
12628
  return { text: text8, ...result };
12424
12629
  }
12425
12630
  const text7 = source ? formatVisioFieldValue(source, picture) : void 0;
@@ -13189,7 +13394,8 @@ function runStyle(cells4, resources, report, themeCells) {
13189
13394
  ...characterExtras(cells4, report)
13190
13395
  };
13191
13396
  }
13192
- function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph) {
13397
+ function shapeText(sheet, node2, width, height, resources, report, consume, consumeParagraph, allowFieldEditing = false) {
13398
+ const editableFields = editableTextFieldIndices(node2, allowFieldEditing);
13193
13399
  const cells4 = sheet.cells;
13194
13400
  const characters = new Map(sectionRows(sheet, "Character").map((row2) => [row2.index, row2.cells]));
13195
13401
  const defaultCells = characters.get("0") ?? /* @__PURE__ */ new Map();
@@ -13224,7 +13430,9 @@ function shapeText(sheet, node2, width, height, resources, report, consume, cons
13224
13430
  start: textOffset,
13225
13431
  end: textOffset + field3.text.length,
13226
13432
  cached: field3.cached,
13227
- ...field3.formula ? { formula: field3.formula } : {}
13433
+ ...field3.index !== void 0 && editableFields.has(field3.index) ? { editable: true } : {},
13434
+ ...field3.formula ? { formula: field3.formula } : {},
13435
+ ...field3.index === void 0 ? {} : { index: field3.index, format: field3.format, sourceKey: field3.sourceKey }
13228
13436
  });
13229
13437
  append(field3.text);
13230
13438
  } else if (element2.localName !== "pp" && element2.localName !== "tp") {
@@ -13623,15 +13831,6 @@ function booleanValue(text7) {
13623
13831
  const value = numeric3(text7);
13624
13832
  return value === void 0 ? void 0 : value !== 0;
13625
13833
  }
13626
- function isoSerialDays(text7) {
13627
- const match = /^(\d{4})-(\d{2})-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2}(?:\.\d+)?))?)?$/.exec(
13628
- text7.trim()
13629
- );
13630
- if (!match) return void 0;
13631
- const [year, month, day, hour, minute, second] = match.slice(1).map((part) => Number(part ?? 0));
13632
- const time = Date.UTC(year, month - 1, day, hour, minute, second);
13633
- return Number.isFinite(time) ? (time - Date.UTC(1899, 11, 30)) / 864e5 : void 0;
13634
- }
13635
13834
  function property(row2, budget, report) {
13636
13835
  const get = (key2) => cached2(row2.cells, key2, budget, report);
13637
13836
  const rawType = get("Type"), rawValue = get("Value");
@@ -13642,7 +13841,7 @@ function property(row2, budget, report) {
13642
13841
  if (rawValue !== void 0 && row2.cells.get("Value")?.error === void 0) {
13643
13842
  if (type === 0 || type === 1 || type === 4) value = budget.retain(rawValue);
13644
13843
  else if (type === 3) value = booleanValue(rawValue);
13645
- else if (type === 5) value = numeric3(rawValue) ?? isoSerialDays(rawValue);
13844
+ else if (type === 5) value = numeric3(rawValue) ?? visioIsoDateSerial(rawValue);
13646
13845
  else if (valueKind !== "unparsed") value = numeric3(rawValue);
13647
13846
  }
13648
13847
  if (value === void 0) {
@@ -14274,7 +14473,8 @@ function normalizeShapes(raw, context, depth = 0, masterStack = []) {
14274
14473
  context.resources,
14275
14474
  report,
14276
14475
  context.consumeText,
14277
- context.consumeParagraph
14476
+ context.consumeParagraph,
14477
+ depth === 0 && masterId === void 0 && !sheet.cells.get("LockTextEdit")?.error && !sheet.cells.get("LockTextEdit")?.formula && number(sheet.cells, "LockTextEdit", 0, report) === 0
14278
14478
  ),
14279
14479
  hidden: membership.hidden || type === "Guide" || number(sheet.cells, "NoShow", 0, report) !== 0,
14280
14480
  visibility: {
@@ -15994,6 +16194,35 @@ function snapshotGuideEdit(edit) {
15994
16194
  }
15995
16195
 
15996
16196
  // visio/edit-text-field-commands.ts
16197
+ function snapshotTextFieldUpdate(edit) {
16198
+ const insert = snapshotTextFieldInsert({
16199
+ pageId: edit.pageId,
16200
+ shapeId: edit.shapeId,
16201
+ formula: edit.formula,
16202
+ ...edit.format === void 0 ? {} : { format: edit.format }
16203
+ });
16204
+ if (analyzeVisioFormula(parseVisioFormula(insert.formula)).references.some(
16205
+ (ref) => /^fields?\./i.test(ref.cell)
16206
+ ))
16207
+ fail("UNSUPPORTED_TEXT_FIELD", "Existing field formulas cannot reference Field rows.");
16208
+ if (typeof edit.fieldIndex !== "string" || !/^(0|[1-9]\d{0,9})$/.test(edit.fieldIndex) || Number(edit.fieldIndex) > 4294967295)
16209
+ fail("INVALID_EDIT", "An existing field needs a canonical row index.");
16210
+ if ([edit.expectedText, edit.expectedCached, edit.expectedSourceKey].some(
16211
+ (value) => typeof value !== "string" || value.length > 1e6
16212
+ ) || !edit.expectedSourceKey)
16213
+ fail("INVALID_EDIT", "An existing field needs its source text and row identity.");
16214
+ return {
16215
+ type: "update-text-field",
16216
+ pageId: insert.pageId,
16217
+ shapeId: insert.shapeId,
16218
+ fieldIndex: edit.fieldIndex,
16219
+ formula: insert.formula,
16220
+ format: insert.format,
16221
+ expectedText: edit.expectedText,
16222
+ expectedCached: edit.expectedCached,
16223
+ expectedSourceKey: edit.expectedSourceKey
16224
+ };
16225
+ }
15997
16226
  function snapshotTextFieldInsert(edit) {
15998
16227
  const { pageId: pageId2, shapeId: shapeId2 } = edit;
15999
16228
  if ([pageId2, shapeId2].some((id3) => typeof id3 !== "string" || !id3 || id3.length > 256))
@@ -16728,6 +16957,14 @@ function snapshotVisioEdits(edits, maxEdits, maxText) {
16728
16957
  return { ...target2, type: edit.type, text: text7(edit.text) };
16729
16958
  if (edit.type === "replace-text-ranges") return snapshotTextRanges(edit, text7);
16730
16959
  if (edit.type === "insert-text-field") return snapshotTextFieldInsert(edit);
16960
+ if (edit.type === "update-text-field") {
16961
+ const update = snapshotTextFieldUpdate(edit);
16962
+ update.formula = text7(update.formula);
16963
+ update.expectedText = text7(update.expectedText);
16964
+ update.expectedCached = text7(update.expectedCached);
16965
+ update.expectedSourceKey = text7(update.expectedSourceKey);
16966
+ return update;
16967
+ }
16731
16968
  if (isVisioFormatEdit(edit)) return snapshotFormatting(edit);
16732
16969
  if (edit.type === "reorder-shape") {
16733
16970
  if (!["front", "back", "forward", "backward"].includes(edit.order))
@@ -16935,6 +17172,8 @@ function snapshotEdits(edits) {
16935
17172
  return snapshotTextRanges(command2, text7);
16936
17173
  case "insert-text-field":
16937
17174
  return snapshotTextFieldInsert(command2);
17175
+ case "update-text-field":
17176
+ return snapshotTextFieldUpdate(command2);
16938
17177
  case "delete-shape":
16939
17178
  return { type: command2.type, ...target2 };
16940
17179
  case "rotate-shape":
@@ -17580,6 +17819,7 @@ async function assertFormattingDependencies(pkg, pagePaths, roots2, pageId2, sha
17580
17819
  continue;
17581
17820
  const source = executableCellFormula(attribute2(node2, "F"));
17582
17821
  if (!source || inertDoubleClickFormula(attribute2(node2, "N") ?? "", source)) continue;
17822
+ if (independentTextFieldFormula(node2, source)) continue;
17583
17823
  if (attribute2(node2, "V") === "Themed" && isThemeLookupFormula(source)) continue;
17584
17824
  if (isConnectedGlueCell(node2, source)) continue;
17585
17825
  const owner = node2.parentNode;
@@ -21348,7 +21588,8 @@ function shapeResolver(shape) {
21348
21588
  }
21349
21589
  function valueCell(value) {
21350
21590
  if (value.kind === "string") return { v: value.text, u: "STR", type: 0 };
21351
- if (value.kind === "date") return { v: String(visioDateSerial(value.date)), u: "DATE", type: 5 };
21591
+ if (value.kind === "date")
21592
+ return { v: value.date.toISOString().replace(/Z$/, ""), u: "DATE", type: 5 };
21352
21593
  const unit3 = value.unit === "length" ? "IN" : value.unit === "angle" ? "DEG" : void 0;
21353
21594
  return { v: String(Number(value.value.toFixed(10))), ...unit3 ? { u: unit3 } : {}, type: 2 };
21354
21595
  }
@@ -21388,9 +21629,23 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21388
21629
  effectiveFormattingRows(shape, document, "Paragraph")
21389
21630
  );
21390
21631
  const rows = formattingRows(shape, "Field");
21391
- const point2 = insertionPoint(text7, edit.offset);
21392
- if (edit.offset !== void 0 && point2.logical !== edit.expectedText)
21632
+ const updating = edit.type === "update-text-field";
21633
+ if (updating) assertEditableFieldShape(shape);
21634
+ const point2 = insertionPoint(text7, updating ? void 0 : edit.offset);
21635
+ if ((updating || edit.offset !== void 0) && point2.logical !== edit.expectedText)
21393
21636
  fail("EDIT_STALE_TEXT", "The shape text changed since the field position was chosen.");
21637
+ const existing = updating ? rows.get(edit.fieldIndex) : void 0;
21638
+ const markers = updating ? children2(text7, "fld").filter((field4) => attribute2(field4, "IX") === edit.fieldIndex) : [];
21639
+ if (updating) {
21640
+ if (!existing || markers.length !== 1)
21641
+ fail(
21642
+ "UNSUPPORTED_TEXT_FIELD",
21643
+ "Existing fields require one live local row and unique text marker."
21644
+ );
21645
+ if (markers[0].textContent !== edit.expectedCached || textFieldSourceKey(readCells(existing)) !== edit.expectedSourceKey)
21646
+ fail("EDIT_STALE_TEXT", "The field source changed since it was selected.");
21647
+ assertEditableFieldRow(existing);
21648
+ }
21394
21649
  const context = { ...await pageContext(pkg, edit.pageId), resolve: shapeResolver(shape) };
21395
21650
  let value;
21396
21651
  try {
@@ -21403,9 +21658,19 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21403
21658
  "UNSUPPORTED_TEXT_FIELD",
21404
21659
  `This editor cannot evaluate the field formula. Supported: ${VISIO_FIELD_FUNCTIONS.join(", ")}, PAGENUMBER, PAGECOUNT and numeric formulas on this shape.`
21405
21660
  );
21406
- const display = formatVisioFieldValue(value, edit.format ?? "");
21661
+ const format4 = edit.format ?? "";
21662
+ const display = formatVisioFieldValue(value, format4);
21407
21663
  if (display === void 0)
21408
21664
  fail("UNSUPPORTED_TEXT_FIELD", "The field format does not suit the field value.");
21665
+ const prepared = valueCell(value);
21666
+ if (existing && markers[0].textContent === display) {
21667
+ const same5 = (name3, v, u, f) => {
21668
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
21669
+ return attribute2(cell2, "V") === v && attribute2(cell2, "U") === u && attribute2(cell2, "F") === f;
21670
+ };
21671
+ if (same5("Value", prepared.v, prepared.u, edit.formula) && same5("Format", format4, "STR", `"${format4.replaceAll('"', '""')}"`) && same5("Type", String(prepared.type), void 0, void 0))
21672
+ return false;
21673
+ }
21409
21674
  if (texts[0])
21410
21675
  await assertFormattingDependencies(
21411
21676
  pkg,
@@ -21413,31 +21678,49 @@ async function insertVisioTextField(pkg, pagePaths, roots2, document, edit, chec
21413
21678
  roots2,
21414
21679
  edit.pageId,
21415
21680
  shape,
21416
- /* @__PURE__ */ new Map([["TheText", text7]]),
21681
+ new Map([
21682
+ ["TheText", text7],
21683
+ ...existing ? ["Value", "Format", "Type"].flatMap((name3) => {
21684
+ const cell2 = children2(existing, "Cell").find((cell3) => attribute2(cell3, "N") === name3);
21685
+ return [
21686
+ [`Field.${updating ? edit.fieldIndex : ""}.${name3}`, cell2],
21687
+ [`Fields.${name3}`, cell2]
21688
+ ];
21689
+ }) : []
21690
+ ]),
21417
21691
  check
21418
21692
  );
21419
21693
  check();
21420
- const index = String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
21694
+ const index = updating ? edit.fieldIndex : String(rows.size ? Math.max(...[...rows.keys()].map(Number)) + 1 : 0);
21421
21695
  let section3 = children2(shape, "Section").find((node2) => attribute2(node2, "N") === "Field");
21422
21696
  if (!section3) {
21423
21697
  section3 = owner.createElementNS(ns, "Section");
21424
21698
  section3.setAttribute("N", "Field");
21425
21699
  shape.insertBefore(section3, texts[0] ?? null);
21426
21700
  }
21427
- const row2 = owner.createElementNS(ns, "Row");
21428
- row2.setAttribute("IX", index);
21701
+ const row2 = existing ?? owner.createElementNS(ns, "Row");
21702
+ if (!existing) row2.setAttribute("IX", index);
21429
21703
  const cell = (name3, v, extra = {}) => {
21430
- const node2 = owner.createElementNS(ns, "Cell");
21704
+ const node2 = children2(row2, "Cell").find((cell2) => attribute2(cell2, "N") === name3) ?? owner.createElementNS(ns, "Cell");
21431
21705
  node2.setAttribute("N", name3);
21432
21706
  node2.setAttribute("V", v);
21707
+ if (updating) {
21708
+ node2.removeAttribute("U");
21709
+ node2.removeAttribute("F");
21710
+ }
21433
21711
  for (const [key2, item] of Object.entries(extra)) node2.setAttribute(key2, item);
21434
- row2.appendChild(node2);
21712
+ if (!node2.parentNode) row2.appendChild(node2);
21435
21713
  };
21436
- const stored = valueCell(value);
21714
+ const stored = prepared;
21437
21715
  cell("Value", stored.v, { ...stored.u ? { U: stored.u } : {}, F: edit.formula });
21438
- if (edit.format) cell("Format", edit.format, { F: `"${edit.format.replaceAll('"', '""')}"` });
21716
+ if (format4 || updating)
21717
+ cell("Format", format4, { U: "STR", F: `"${format4.replaceAll('"', '""')}"` });
21439
21718
  cell("Type", String(stored.type));
21440
- section3.appendChild(row2);
21719
+ if (!row2.parentNode) section3.appendChild(row2);
21720
+ if (updating) {
21721
+ markers[0].textContent = display;
21722
+ return true;
21723
+ }
21441
21724
  const field3 = owner.createElementNS(ns, "fld");
21442
21725
  field3.setAttribute("IX", index);
21443
21726
  field3.appendChild(owner.createTextNode(display));
@@ -26789,7 +27072,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26789
27072
  const dirty = /* @__PURE__ */ new Map();
26790
27073
  const roots2 = /* @__PURE__ */ new Map();
26791
27074
  const geometryCommands = commands.filter(
26792
- (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)
27075
+ (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)
26793
27076
  );
26794
27077
  let document;
26795
27078
  let masterMovePins = emptyMasterMoveProof();
@@ -26797,7 +27080,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26797
27080
  let instanceDeletes = /* @__PURE__ */ new Set();
26798
27081
  let groupMembers = /* @__PURE__ */ new Map();
26799
27082
  if (geometryCommands.length || commands.some(
26800
- (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)
27083
+ (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)
26801
27084
  )) {
26802
27085
  for (const [pageId2, path2] of pages) {
26803
27086
  const sourceRoot = await visioXml(pkg, path2, "PageContents");
@@ -26908,7 +27191,7 @@ async function editVsdxTransaction(input, edits, options, clock = {
26908
27191
  textChanged = true;
26909
27192
  await noteTextSize(command2, root2);
26910
27193
  }
26911
- } else if (command2.type === "insert-text-field") {
27194
+ } else if (command2.type === "insert-text-field" || command2.type === "update-text-field") {
26912
27195
  if (await insertVisioTextField(pkg, new Set(pages.values()), roots2, document, command2, check)) {
26913
27196
  dirty.set(path, root2);
26914
27197
  textChanged = true;
@@ -28099,7 +28382,16 @@ function copySnapshotScene(model) {
28099
28382
  source.fields,
28100
28383
  "text fields",
28101
28384
  1e4,
28102
- (field3) => fields(field3, ["start", "end", "cached", "formula"])
28385
+ (field3) => fields(field3, [
28386
+ "start",
28387
+ "end",
28388
+ "cached",
28389
+ "formula",
28390
+ "index",
28391
+ "format",
28392
+ "sourceKey",
28393
+ "editable"
28394
+ ])
28103
28395
  )
28104
28396
  },
28105
28397
  runs: list2(source.runs, "text runs", 1e5, (run) => ({
@@ -32784,6 +33076,7 @@ function visioTextBlockEdit(page, shape, frame) {
32784
33076
  // visio/ui/text-field-catalog.ts
32785
33077
  var dateFormats = [
32786
33078
  { label: "Short date (10/9/2026)", format: VISIO_FIELD_FORMATS.shortDate },
33079
+ { label: "ISO date (2026-10-09)", format: VISIO_FIELD_FORMATS.isoDate },
32787
33080
  { label: "Long date (Friday, October 9, 2026)", format: VISIO_FIELD_FORMATS.longDate },
32788
33081
  { label: "Time (2:05 PM)", format: VISIO_FIELD_FORMATS.time },
32789
33082
  { label: "Date and time", format: VISIO_FIELD_FORMATS.dateTime }