@embedpdf/engine-core 3.0.0-next.14 → 3.0.0-next.16

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 (135) hide show
  1. package/dist/AnnotationList-DcyhF2kU.d.cts +27691 -0
  2. package/dist/AnnotationList-DcyhF2kU.d.ts +27691 -0
  3. package/dist/Change-Ct-dB8D5.cjs +1133 -0
  4. package/dist/Change-Ct-dB8D5.cjs.map +1 -0
  5. package/dist/Change-tMR34hTU.js +978 -0
  6. package/dist/Change-tMR34hTU.js.map +1 -0
  7. package/dist/DocumentRenderService-9IjSQEIU.cjs +121 -0
  8. package/dist/DocumentRenderService-9IjSQEIU.cjs.map +1 -0
  9. package/dist/DocumentRenderService-DFrZ9wfW.js +86 -0
  10. package/dist/DocumentRenderService-DFrZ9wfW.js.map +1 -0
  11. package/dist/{DocumentSecurityService-Ca6EK3-3.d.ts → DocumentSecurityService-D2zA4NKi.d.cts} +100 -112
  12. package/dist/{DocumentSecurityService-CIx1MT0T.d.cts → DocumentSecurityService-YJV9df8P.d.ts} +100 -112
  13. package/dist/LocalDocumentHandle-D02FMm-Z.cjs +53 -0
  14. package/dist/LocalDocumentHandle-D02FMm-Z.cjs.map +1 -0
  15. package/dist/LocalDocumentHandle-DAPdaOt_.js +30 -0
  16. package/dist/LocalDocumentHandle-DAPdaOt_.js.map +1 -0
  17. package/dist/LocalEngine-DBt2-GWF.d.ts +1649 -0
  18. package/dist/LocalEngine-IA9zh3Jh.d.cts +1649 -0
  19. package/dist/PageInsertBlankInput-CXHAM7l6.cjs +17 -0
  20. package/dist/PageInsertBlankInput-CXHAM7l6.cjs.map +1 -0
  21. package/dist/PageInsertBlankInput-DhVYVJ_S.js +12 -0
  22. package/dist/PageInsertBlankInput-DhVYVJ_S.js.map +1 -0
  23. package/dist/authority-BFp6XM04.cjs +2997 -0
  24. package/dist/authority-BFp6XM04.cjs.map +1 -0
  25. package/dist/authority-PuxpGFhJ.js +2506 -0
  26. package/dist/authority-PuxpGFhJ.js.map +1 -0
  27. package/dist/builders-DV62HA3I.js +165 -0
  28. package/dist/builders-DV62HA3I.js.map +1 -0
  29. package/dist/builders-DgTAj_tP.cjs +188 -0
  30. package/dist/builders-DgTAj_tP.cjs.map +1 -0
  31. package/dist/calibrate-DJbi1wuK.cjs +3012 -0
  32. package/dist/calibrate-DJbi1wuK.cjs.map +1 -0
  33. package/dist/calibrate-nQFgCuki.js +2461 -0
  34. package/dist/calibrate-nQFgCuki.js.map +1 -0
  35. package/dist/charmap-Cprti1ta.js +239 -0
  36. package/dist/charmap-Cprti1ta.js.map +1 -0
  37. package/dist/charmap-aYlefQP9.cjs +304 -0
  38. package/dist/charmap-aYlefQP9.cjs.map +1 -0
  39. package/dist/conformance.cjs +18146 -5258
  40. package/dist/conformance.cjs.map +1 -1
  41. package/dist/conformance.d.cts +1024 -170
  42. package/dist/conformance.d.ts +1024 -170
  43. package/dist/conformance.js +18148 -5309
  44. package/dist/conformance.js.map +1 -1
  45. package/dist/format-Bp3QFSH1.cjs +574 -0
  46. package/dist/format-Bp3QFSH1.cjs.map +1 -0
  47. package/dist/format-Dgg428Kb.js +461 -0
  48. package/dist/format-Dgg428Kb.js.map +1 -0
  49. package/dist/index.cjs +342 -116
  50. package/dist/index.d.cts +2 -2
  51. package/dist/index.d.ts +2 -2
  52. package/dist/index.js +14 -5
  53. package/dist/pageRefs-B3ur7Ckm.cjs +51 -0
  54. package/dist/pageRefs-B3ur7Ckm.cjs.map +1 -0
  55. package/dist/pageRefs-DkbuxSCV.js +40 -0
  56. package/dist/pageRefs-DkbuxSCV.js.map +1 -0
  57. package/dist/public.cjs +59 -0
  58. package/dist/public.d.cts +5 -0
  59. package/dist/public.d.ts +5 -0
  60. package/dist/public.js +9 -0
  61. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs +3646 -0
  62. package/dist/resolveAnnotationDraft-7Ke4nV7F.cjs.map +1 -0
  63. package/dist/resolveAnnotationDraft-CUpf0SMh.js +3167 -0
  64. package/dist/resolveAnnotationDraft-CUpf0SMh.js.map +1 -0
  65. package/dist/{resolver-inAVzsWt.js → resolver-BBggAxQc.js} +298 -145
  66. package/dist/resolver-BBggAxQc.js.map +1 -0
  67. package/dist/{resolver-CYVNV4hn.cjs → resolver-BWSWSF6R.cjs} +351 -144
  68. package/dist/resolver-BWSWSF6R.cjs.map +1 -0
  69. package/dist/runtime-BaDKjxiu.d.ts +1959 -0
  70. package/dist/runtime-CWEuiwbk.d.cts +1959 -0
  71. package/dist/runtime.cjs +986 -297
  72. package/dist/runtime.cjs.map +1 -1
  73. package/dist/runtime.d.cts +5 -1372
  74. package/dist/runtime.d.ts +5 -1372
  75. package/dist/runtime.js +634 -179
  76. package/dist/runtime.js.map +1 -1
  77. package/dist/schema-6S2VmlAj.js +2087 -0
  78. package/dist/schema-6S2VmlAj.js.map +1 -0
  79. package/dist/schema-miH6tWQC.cjs +3046 -0
  80. package/dist/schema-miH6tWQC.cjs.map +1 -0
  81. package/dist/schemas-BE2QGOit.js +1851 -0
  82. package/dist/schemas-BE2QGOit.js.map +1 -0
  83. package/dist/schemas-DljJR9ut.cjs +2798 -0
  84. package/dist/schemas-DljJR9ut.cjs.map +1 -0
  85. package/dist/subtype-CG4WpIRj.js +129 -0
  86. package/dist/subtype-CG4WpIRj.js.map +1 -0
  87. package/dist/subtype-aDt5TFmK.cjs +158 -0
  88. package/dist/subtype-aDt5TFmK.cjs.map +1 -0
  89. package/dist/validation.cjs +578 -0
  90. package/dist/validation.cjs.map +1 -0
  91. package/dist/validation.d.cts +174 -0
  92. package/dist/validation.d.ts +174 -0
  93. package/dist/validation.js +571 -0
  94. package/dist/validation.js.map +1 -0
  95. package/dist/value-BFS1R8ek.cjs +435 -0
  96. package/dist/value-BFS1R8ek.cjs.map +1 -0
  97. package/dist/value-Dhc8eYcx.js +340 -0
  98. package/dist/value-Dhc8eYcx.js.map +1 -0
  99. package/dist/viewport-CHG9qQUb.cjs +671 -0
  100. package/dist/viewport-CHG9qQUb.cjs.map +1 -0
  101. package/dist/viewport-DQR5LyX3.js +540 -0
  102. package/dist/viewport-DQR5LyX3.js.map +1 -0
  103. package/dist/wire.cjs +1242 -420
  104. package/dist/wire.cjs.map +1 -1
  105. package/dist/wire.d.cts +14840 -830
  106. package/dist/wire.d.ts +14840 -830
  107. package/dist/wire.js +985 -261
  108. package/dist/wire.js.map +1 -1
  109. package/package.json +10 -1
  110. package/dist/AbortError-DwuHPK_I.js +0 -27
  111. package/dist/AbortError-DwuHPK_I.js.map +0 -1
  112. package/dist/AbortError-P0RU0Mgg.cjs +0 -38
  113. package/dist/AbortError-P0RU0Mgg.cjs.map +0 -1
  114. package/dist/AnnotationListSnapshot-D9R5n2Kf.d.cts +0 -7101
  115. package/dist/AnnotationListSnapshot-D9R5n2Kf.d.ts +0 -7101
  116. package/dist/Engine-EWWHhEIi.d.ts +0 -1277
  117. package/dist/Engine-FNaAEjfb.d.cts +0 -1277
  118. package/dist/derive-BbsDk_Kz.cjs +0 -880
  119. package/dist/derive-BbsDk_Kz.cjs.map +0 -1
  120. package/dist/derive-DAFJolWu.js +0 -647
  121. package/dist/derive-DAFJolWu.js.map +0 -1
  122. package/dist/format-Bbphf4zR.js +0 -435
  123. package/dist/format-Bbphf4zR.js.map +0 -1
  124. package/dist/format-D_epWlob.cjs +0 -518
  125. package/dist/format-D_epWlob.cjs.map +0 -1
  126. package/dist/resolver-CYVNV4hn.cjs.map +0 -1
  127. package/dist/resolver-inAVzsWt.js.map +0 -1
  128. package/dist/schemas-CFQGvWiu.js +0 -3243
  129. package/dist/schemas-CFQGvWiu.js.map +0 -1
  130. package/dist/schemas-D0g6tKa9.cjs +0 -4694
  131. package/dist/schemas-D0g6tKa9.cjs.map +0 -1
  132. package/dist/viewport-BWeNHZmb.cjs +0 -3503
  133. package/dist/viewport-BWeNHZmb.cjs.map +0 -1
  134. package/dist/viewport-CvMcadfQ.js +0 -3072
  135. package/dist/viewport-CvMcadfQ.js.map +0 -1
@@ -0,0 +1,1133 @@
1
+ const require_calibrate = require("./calibrate-DJbi1wuK.cjs");
2
+ const require_format = require("./format-Bp3QFSH1.cjs");
3
+ //#region src/dto/DocumentOutline.ts
4
+ /**
5
+ * How much of an outline a read takes: the items, and how deep they nest.
6
+ * Past either, the read stops and says `incomplete`.
7
+ */
8
+ const OUTLINE_READ_LIMITS = {
9
+ items: 5e4,
10
+ depth: 128
11
+ };
12
+ //#endregion
13
+ //#region src/outline/predict.ts
14
+ /** A target as a read returns it: the target, and the `/A` action it is written as. */
15
+ function targetFieldsOf(target) {
16
+ return target ? {
17
+ target,
18
+ action: require_calibrate.actionTreeOf(target)
19
+ } : {
20
+ target: null,
21
+ action: null
22
+ };
23
+ }
24
+ /** A colour as a read returns it: `#rrggbb` in lowercase digits, or `null`. */
25
+ const colorAsRead = (color) => color ? color.toLowerCase() : null;
26
+ /** `outline.create`: the new item. It has no children yet, so it isn't open. */
27
+ function outlineItemOfDraft(ref, parent, draft) {
28
+ return {
29
+ ref,
30
+ parent,
31
+ title: draft.title,
32
+ ...targetFieldsOf(draft.target ?? null),
33
+ open: false,
34
+ color: colorAsRead(draft.color),
35
+ bold: draft.bold ?? false,
36
+ italic: draft.italic ?? false
37
+ };
38
+ }
39
+ /**
40
+ * `outline.update`: the item with the fields the patch names. `open` holds
41
+ * only on an item with children (`hasChildren`): a leaf has no open state.
42
+ * Returns `item` itself when the patch changes nothing.
43
+ */
44
+ function outlineItemAfter(item, patch, hasChildren) {
45
+ const next = {
46
+ ...item,
47
+ ...patch.title !== void 0 ? { title: patch.title } : {},
48
+ ...patch.target !== void 0 ? targetFieldsOf(patch.target) : {},
49
+ ...patch.color !== void 0 ? { color: colorAsRead(patch.color) } : {},
50
+ ...patch.bold !== void 0 ? { bold: patch.bold } : {},
51
+ ...patch.italic !== void 0 ? { italic: patch.italic } : {},
52
+ ...patch.open !== void 0 ? { open: patch.open && hasChildren } : {}
53
+ };
54
+ return patch.target === void 0 && next.title === item.title && next.color === item.color && next.bold === item.bold && next.italic === item.italic && next.open === item.open ? item : next;
55
+ }
56
+ /**
57
+ * An item whose children a write changed: one left without children is no
58
+ * longer open, and one that gains its first child stays closed, as a leaf
59
+ * is. Returns `item` itself when that changes nothing.
60
+ */
61
+ function outlineItemWithChildren(item, hasChildren) {
62
+ return item.open && !hasChildren ? {
63
+ ...item,
64
+ open: false
65
+ } : item;
66
+ }
67
+ //#endregion
68
+ //#region src/mutation/AttachmentMutationResults.ts
69
+ /**
70
+ * What a delete removed, as its `attachments.deleted` event names it for
71
+ * listeners that didn't make the call.
72
+ */
73
+ function deletedAttachmentOf(result) {
74
+ return result.meta.changed[0] ?? null;
75
+ }
76
+ //#endregion
77
+ //#region src/forms/write.ts
78
+ /** The shapes each family takes, for the message when a value doesn't fit. */
79
+ const TAKES = {
80
+ text: "{ value }",
81
+ checkbox: "{ checked } or { value }",
82
+ radio: "{ value }",
83
+ combobox: "{ value }",
84
+ listbox: "{ selectedValues }"
85
+ };
86
+ /**
87
+ * The write `value` makes for `field`, checked before anything is written:
88
+ * the shape must be one the family takes, a toggle's value must be the
89
+ * export value of one of its widgets (a radio group that must keep a choice
90
+ * can't be cleared), and a choice must be option values (free text for a
91
+ * dropdown that allows editing). `InvalidArg` otherwise.
92
+ */
93
+ function fieldValueWriteOf(field, value) {
94
+ switch (field.family) {
95
+ case "text":
96
+ if ("value" in value) return {
97
+ kind: "text",
98
+ value: value.value ?? ""
99
+ };
100
+ break;
101
+ case "checkbox":
102
+ if ("checked" in value) {
103
+ if (!value.checked) return {
104
+ kind: "toggle",
105
+ state: null
106
+ };
107
+ const first = field.widgets[0];
108
+ if (!first) throw invalidValue(`'${field.name}' has no widget to check`);
109
+ return {
110
+ kind: "toggle",
111
+ state: first.onState
112
+ };
113
+ }
114
+ if ("value" in value) return {
115
+ kind: "toggle",
116
+ state: toggleStateOf(field, value.value)
117
+ };
118
+ break;
119
+ case "radio":
120
+ if ("value" in value) {
121
+ const state = toggleStateOf(field, value.value);
122
+ if (state === null && field.noToggleToOff) throw invalidValue(`'${field.name}' must keep a choice: it can't be cleared`);
123
+ return {
124
+ kind: "toggle",
125
+ state
126
+ };
127
+ }
128
+ break;
129
+ case "combobox":
130
+ if ("value" in value) return choiceOf(field, value.value === null ? [] : [value.value]);
131
+ break;
132
+ case "listbox":
133
+ if ("selectedValues" in value) return choiceOf(field, value.selectedValues);
134
+ break;
135
+ default: throw invalidValue(`${field.family} fields hold no value you can set`);
136
+ }
137
+ throw invalidValue(`a ${field.family} field takes ${TAKES[field.family]}, not ${shapeOf(value)}`);
138
+ }
139
+ /**
140
+ * Check a choice field's default (`/DV`) before it is written: option values
141
+ * (one free text for a dropdown that allows editing), none twice, and one
142
+ * value unless the list box takes several. `InvalidArg` otherwise.
143
+ */
144
+ function assertChoiceDefault(target, values) {
145
+ const invalid = (message) => new require_format.EngineError(require_format.EngineErrorCode.InvalidArg, message, { details: { field: "defaultValue" } });
146
+ if (new Set(values).size !== values.length) throw invalid("the default values must not repeat");
147
+ if (values.length > 1 && !(target.family === "listbox" && target.multiSelect)) throw invalid(`a ${target.family === "listbox" ? "list without multiSelect" : "dropdown"} has one default`);
148
+ const freeText = target.family === "combobox" && target.edit === true;
149
+ const optionValues = new Set(target.options.map((option) => option.value));
150
+ const unknown = values.find((value) => !optionValues.has(value));
151
+ if (unknown !== void 0 && !freeText) throw invalid(`'${unknown}' is not an option value of the ${target.family === "listbox" ? "list" : "dropdown"}`);
152
+ }
153
+ /** Whether `write` would leave `field` as it is. */
154
+ function isNoOpWrite(field, write) {
155
+ switch (write.kind) {
156
+ case "text": return field.family === "text" && field.value === write.value;
157
+ case "toggle": return (field.family === "checkbox" || field.family === "radio") && field.widgets.every((widget) => widget.checked === (widget.onState === write.state));
158
+ case "choice":
159
+ if (field.family === "combobox") return write.values.length === 0 ? field.value === "" : field.value === write.values[0];
160
+ return field.family === "listbox" && field.selectedValues.length === write.values.length && field.selectedValues.every((value, index) => value === write.values[index]);
161
+ }
162
+ }
163
+ /**
164
+ * Whether a reset would leave `field` as it is: its value is its default, and
165
+ * a checkbox's or radio group's buttons show that default.
166
+ */
167
+ function isAtDefault(field) {
168
+ if (field.valueEntry.kind === "unsupported") return false;
169
+ if (!valueEntriesEqual(field.valueEntry, field.defaultValueEntry)) return false;
170
+ if (field.family !== "checkbox" && field.family !== "radio") return true;
171
+ const entry = field.defaultValueEntry;
172
+ const state = entry.kind === "scalar" ? entry.value : null;
173
+ return field.widgets.every((widget) => widget.checked === (widget.onState === state));
174
+ }
175
+ /** Whether two value entries hold the same value. */
176
+ function valueEntriesEqual(left, right) {
177
+ if (left.kind !== right.kind) return false;
178
+ if (left.kind === "scalar" && right.kind === "scalar") return left.value === right.value;
179
+ if (left.kind === "array" && right.kind === "array") return left.values.length === right.values.length && left.values.every((value, index) => value === right.values[index]);
180
+ return true;
181
+ }
182
+ /** A checkbox's or radio group's on-state for an export value; `'Off'` and `null` clear it. */
183
+ function toggleStateOf(field, exportValue) {
184
+ if (exportValue === null || exportValue === "Off") return null;
185
+ const widget = field.widgets.find((candidate) => candidate.exportValue === exportValue);
186
+ if (!widget) throw invalidValue(`no widget of '${field.name}' has the export value '${exportValue}'`);
187
+ return widget.onState;
188
+ }
189
+ function choiceOf(field, values) {
190
+ if (new Set(values).size !== values.length) throw invalidValue("the values must not repeat");
191
+ if (field.family === "listbox" && !field.multiSelect && values.length > 1) throw invalidValue(`'${field.name}' takes one value (it has no multiSelect)`);
192
+ const optionValues = new Set(field.options.map((option) => option.value));
193
+ const freeText = field.family === "combobox" && field.edit && values.length === 1;
194
+ const unknown = values.find((value) => !optionValues.has(value));
195
+ if (!freeText && unknown !== void 0) throw invalidValue(`'${unknown}' is not an option value of '${field.name}'`);
196
+ return {
197
+ kind: "choice",
198
+ values
199
+ };
200
+ }
201
+ function shapeOf(value) {
202
+ if ("checked" in value) return "{ checked }";
203
+ if ("selectedValues" in value) return "{ selectedValues }";
204
+ return "{ value }";
205
+ }
206
+ function invalidValue(message) {
207
+ return new require_format.EngineError(require_format.EngineErrorCode.InvalidArg, message, { details: { field: "value" } });
208
+ }
209
+ //#endregion
210
+ //#region src/forms/widgets.ts
211
+ /**
212
+ * A widget placement or patch as a `family` widget takes it. `/MK /CA` is a
213
+ * push button's caption and a checkbox's or radio button's symbol
214
+ * (`checkStyle`), so each goes on its own family's widgets only: on another
215
+ * widget, a `null` (as its row reads) is dropped, and a value is refused.
216
+ */
217
+ function fitWidgetToFamily(family, value) {
218
+ const toggle = family === "checkbox" || family === "radio";
219
+ return fitToFamily(family, fitToFamily(family, value, "caption", family === "pushbutton", "a push button's"), "checkStyle", toggle, "a checkbox's or radio button's");
220
+ }
221
+ function fitToFamily(family, value, key, takes, whose) {
222
+ if (takes || value[key] === void 0) return value;
223
+ if (value[key] !== null) {
224
+ const widget = family === "unknown" ? "this widget" : `a ${family} field's widget`;
225
+ throw new require_format.EngineError(require_format.EngineErrorCode.InvalidArg, `'${key}' applies to ${whose} widgets, not to ${widget}`, { details: { field: key } });
226
+ }
227
+ const { [key]: _none, ...rest } = value;
228
+ return rest;
229
+ }
230
+ /**
231
+ * `forms.updateWidget`: the row a widget patch leaves, as an annotation
232
+ * patch leaves it (a move keeps the look), checked against the widget's
233
+ * family first. A new box or turn moves where it stands (`standingRectOf`).
234
+ */
235
+ function widgetAfterPatch(row, patch) {
236
+ const fitted = fitWidgetToFamily(row.fieldFamily, patch);
237
+ const after = require_calibrate.applyAnnotationPatch(row, {
238
+ subtype: "widget",
239
+ ...fitted
240
+ });
241
+ if (![
242
+ "box",
243
+ "rect",
244
+ "rotation"
245
+ ].some((key) => key in fitted)) return after;
246
+ return {
247
+ ...after,
248
+ rect: standingRectOf(after.box, after.rotation)
249
+ };
250
+ }
251
+ /**
252
+ * Where a widget stands on the page: its box, with its sides swapped under a
253
+ * quarter turn (its contents turn, the frame keeps its place).
254
+ */
255
+ function standingRectOf(box, rotation) {
256
+ const turn = ((rotation ?? 0) % 360 + 360) % 360;
257
+ if (turn !== 90 && turn !== 270) return box;
258
+ const { x, y, width, height } = box;
259
+ return {
260
+ ...box,
261
+ x: x + (width - height) / 2,
262
+ y: y + (height - width) / 2,
263
+ width: height,
264
+ height: width
265
+ };
266
+ }
267
+ //#endregion
268
+ //#region src/forms/predict.ts
269
+ /**
270
+ * `forms.setValue`: a text field holds the text, cut to its maximum length
271
+ * (in characters); a checkbox checks every widget with the target's export
272
+ * value and on-state; a radio group checks the first button with the value,
273
+ * or every one with it when its radios move in unison; a choice field holds
274
+ * its option values in option order, or a dropdown's free text. Refuses what
275
+ * the engine refuses (`fieldValueWriteOf`).
276
+ */
277
+ function fieldAfterValue(current, value) {
278
+ const { field } = current;
279
+ const write = fieldValueWriteOf(field, value);
280
+ switch (write.kind) {
281
+ case "text": {
282
+ if (field.family !== "text") return current;
283
+ const text = firstCharacters(write.value, field.maxLength);
284
+ if (text === field.value) return current;
285
+ return redrawn({
286
+ ...field,
287
+ value: text,
288
+ valueEntry: {
289
+ kind: "scalar",
290
+ value: text
291
+ }
292
+ }, current);
293
+ }
294
+ case "toggle": {
295
+ if (field.family !== "checkbox" && field.family !== "radio") return current;
296
+ const target = field.widgets.findIndex((widget) => widget.onState === write.state);
297
+ return toggled(current, write.state === null ? -1 : target);
298
+ }
299
+ case "choice":
300
+ if (field.family !== "combobox" && field.family !== "listbox") return current;
301
+ return redrawn(choiceFieldWith(field, write.values), current);
302
+ }
303
+ }
304
+ /**
305
+ * `forms.reset`: back to the default value. A text field holds its default
306
+ * (or nothing); a choice field its default options; a checkbox or radio
307
+ * group checks the widget its default names, or none.
308
+ */
309
+ function fieldAfterReset(current) {
310
+ const { field } = current;
311
+ const defaults = field.defaultValueEntry;
312
+ switch (field.family) {
313
+ case "text": {
314
+ if (defaults.kind === "array" || defaults.kind === "unsupported") throw notReset(field);
315
+ const value = defaults.kind === "scalar" ? defaults.value : "";
316
+ const entry = defaults.kind === "scalar" ? defaults : { kind: "none" };
317
+ return redrawn({
318
+ ...field,
319
+ value,
320
+ valueEntry: entry
321
+ }, current);
322
+ }
323
+ case "checkbox":
324
+ case "radio": {
325
+ if (defaults.kind === "array" || defaults.kind === "unsupported") throw notReset(field);
326
+ const state = defaults.kind === "scalar" ? defaults.value : null;
327
+ if (state === null || state === "Off") return toggled(current, -1);
328
+ const target = widgetNamedBy(field.widgets, state);
329
+ if (target < 0) throw notReset(field);
330
+ return toggled(current, target);
331
+ }
332
+ case "combobox":
333
+ case "listbox": {
334
+ if (defaults.kind === "unsupported") throw notReset(field);
335
+ let values = defaults.kind === "scalar" ? [defaults.value] : defaults.kind === "array" ? [...defaults.values] : [];
336
+ if (values.length === 1 && values[0] === "" && !choiceMatches(field, values)) values = [];
337
+ if (!choiceMatches(field, values) && !freeTextAllowed(field, values)) throw notReset(field);
338
+ return redrawn(choiceFieldWith(field, values), current);
339
+ }
340
+ default: throw notReset(field);
341
+ }
342
+ }
343
+ /**
344
+ * `forms.setDisplay`, on each widget's flags, as Acrobat's `Field.display`
345
+ * sets them: visible and printed; hidden; visible but not printed; printed
346
+ * but not shown on screen.
347
+ */
348
+ function widgetsAfterDisplay(widgets, display) {
349
+ const flags = DISPLAY_FLAGS[display];
350
+ return widgets.map((row) => Object.keys(flags).every((key) => row[key] === flags[key]) ? row : {
351
+ ...row,
352
+ ...flags
353
+ });
354
+ }
355
+ const DISPLAY_FLAGS = {
356
+ visible: {
357
+ invisible: false,
358
+ hidden: false,
359
+ noView: false,
360
+ print: true
361
+ },
362
+ hidden: {
363
+ invisible: false,
364
+ hidden: true,
365
+ noView: false,
366
+ print: true
367
+ },
368
+ noPrint: {
369
+ invisible: false,
370
+ hidden: false,
371
+ noView: false,
372
+ print: false
373
+ },
374
+ noView: {
375
+ hidden: false,
376
+ noView: true,
377
+ print: true
378
+ }
379
+ };
380
+ /**
381
+ * The default (`/DV`) a draft gives its field: a text field's or dropdown's
382
+ * one value, a list box's option values in option order; none without one.
383
+ */
384
+ function defaultEntryOfDraft(draft) {
385
+ if ((draft.family === "combobox" || draft.family === "listbox") && draft.defaultValue !== void 0) {
386
+ const values = Array.isArray(draft.defaultValue) ? draft.defaultValue : [draft.defaultValue];
387
+ assertChoiceDefault({
388
+ ...draft,
389
+ options: draft.options ?? []
390
+ }, values);
391
+ }
392
+ switch (draft.family) {
393
+ case "text":
394
+ case "combobox": return draft.defaultValue !== void 0 ? scalar(draft.defaultValue) : none();
395
+ case "listbox": return choiceEntryOf(inOptionOrder((draft.options ?? []).map(optionOf), draft.defaultValue ?? []));
396
+ default: return none();
397
+ }
398
+ }
399
+ /**
400
+ * `forms.create`: the field and its widgets as a read of them returns them.
401
+ * Every flag the draft doesn't set is off, the value is empty (a default
402
+ * only sets the default), a checkbox's export value is `'Yes'` unless its
403
+ * widget names one, and a toggle's widgets start off.
404
+ */
405
+ function formFieldOfDraft(draft, context) {
406
+ const placements = draft.widgets ?? [];
407
+ const rows = placements.map((placement, at) => widgetRowOfPlacement(draft, placement, {
408
+ ref: context.widgets[at],
409
+ field: context.objectNumber,
410
+ nm: context.widgetNames?.[at]
411
+ }));
412
+ const widgets = rows.map((row) => require_format.formWidget(objectNumberOf(row.ref), row.page));
413
+ const options = (draft.family === "combobox" || draft.family === "listbox" ? draft.options ?? [] : []).map(optionOf);
414
+ const base = {
415
+ ref: {
416
+ kind: "objectNumber",
417
+ objectNumber: context.objectNumber
418
+ },
419
+ name: draft.name,
420
+ origin: "acroform",
421
+ readOnly: draft.readOnly ?? false,
422
+ required: draft.required ?? false,
423
+ noExport: draft.noExport ?? false,
424
+ alternateName: draft.alternateName ?? null,
425
+ mappingName: draft.mappingName ?? null,
426
+ valueEntry: { kind: "none" },
427
+ defaultValueEntry: { kind: "none" },
428
+ groupId: draft.groupId ?? context.groupId ?? null,
429
+ createdBy: context.createdBy ?? null,
430
+ createdAt: context.createdAt ?? null,
431
+ filledBy: null,
432
+ filledByName: null,
433
+ filledAt: null,
434
+ importedBy: null
435
+ };
436
+ let field;
437
+ switch (draft.family) {
438
+ case "text": {
439
+ const defaultValue = draft.defaultValue ?? "";
440
+ field = {
441
+ ...base,
442
+ family: "text",
443
+ defaultValueEntry: defaultEntryOfDraft(draft),
444
+ value: "",
445
+ defaultValue,
446
+ maxLength: draft.maxLength ?? null,
447
+ multiline: draft.multiline ?? false,
448
+ password: draft.password ?? false,
449
+ comb: draft.comb ?? false,
450
+ widgets
451
+ };
452
+ break;
453
+ }
454
+ case "checkbox": {
455
+ const toggles = placements.map((placement, at) => toggleWidgetOf(widgets[at], placement.exportValue ?? "Yes"));
456
+ field = {
457
+ ...base,
458
+ family: "checkbox",
459
+ checked: false,
460
+ exportValue: toggles[0]?.exportValue ?? "Yes",
461
+ widgets: toggles
462
+ };
463
+ break;
464
+ }
465
+ case "radio": {
466
+ const toggles = placements.map((placement, at) => toggleWidgetOf(widgets[at], placement.exportValue ?? ""));
467
+ field = {
468
+ ...base,
469
+ family: "radio",
470
+ value: "Off",
471
+ radiosInUnison: draft.radiosInUnison ?? false,
472
+ noToggleToOff: draft.noToggleToOff ?? false,
473
+ widgets: toggles
474
+ };
475
+ break;
476
+ }
477
+ case "combobox":
478
+ field = {
479
+ ...base,
480
+ family: "combobox",
481
+ defaultValueEntry: defaultEntryOfDraft(draft),
482
+ value: "",
483
+ defaultValue: draft.defaultValue ?? "",
484
+ edit: draft.edit ?? false,
485
+ options,
486
+ widgets
487
+ };
488
+ break;
489
+ case "listbox": {
490
+ const defaults = draft.defaultValue ?? [];
491
+ field = {
492
+ ...base,
493
+ family: "listbox",
494
+ defaultValueEntry: defaultEntryOfDraft(draft),
495
+ selectedValues: [],
496
+ defaultValue: inOptionOrder(options, defaults),
497
+ multiSelect: draft.multiSelect ?? false,
498
+ options,
499
+ topIndex: 0,
500
+ widgets
501
+ };
502
+ break;
503
+ }
504
+ default: field = {
505
+ ...base,
506
+ family: draft.family,
507
+ widgets
508
+ };
509
+ }
510
+ return {
511
+ field,
512
+ widgets: rows
513
+ };
514
+ }
515
+ /**
516
+ * `forms.update`: the settings the patch names. A new name replaces the
517
+ * field's own segment of its dotted name; new options keep what is still
518
+ * selected (an editable dropdown keeps its free text) and its default the
519
+ * same way; `null` clears a limit, a name or a default.
520
+ */
521
+ function formFieldAfter(current, patch) {
522
+ const given = patch;
523
+ let field = { ...current.field };
524
+ if (patch.name !== void 0) {
525
+ const parent = field.name.lastIndexOf(".");
526
+ field.name = parent < 0 ? patch.name : `${field.name.slice(0, parent + 1)}${patch.name}`;
527
+ }
528
+ for (const flag of FLAGS) if (typeof given[flag] === "boolean" && flag in field) field[flag] = given[flag];
529
+ if (patch.alternateName !== void 0) field.alternateName = patch.alternateName || null;
530
+ if (patch.mappingName !== void 0) field.mappingName = patch.mappingName || null;
531
+ if (patch.groupId !== void 0) field.groupId = patch.groupId;
532
+ if (field.family === "text") {
533
+ if ("maxLength" in patch && patch.maxLength !== void 0) field.maxLength = patch.maxLength;
534
+ if ("defaultValue" in patch && patch.defaultValue !== void 0) {
535
+ const value = patch.defaultValue;
536
+ field.defaultValue = value ?? "";
537
+ field.defaultValueEntry = value === null ? none() : scalar(value);
538
+ }
539
+ }
540
+ let redraw = false;
541
+ if (field.family === "combobox" || field.family === "listbox") {
542
+ if ("options" in patch && patch.options) {
543
+ field = withOptions(field, patch.options.map(optionOf));
544
+ redraw = true;
545
+ }
546
+ if ("defaultValue" in patch && patch.defaultValue !== void 0) {
547
+ const values = patch.defaultValue === null ? [] : Array.isArray(patch.defaultValue) ? patch.defaultValue : [patch.defaultValue];
548
+ assertChoiceDefault(field, values);
549
+ field = withDefault(field, values);
550
+ }
551
+ }
552
+ const after = {
553
+ ...current,
554
+ field
555
+ };
556
+ return redraw ? redrawn(after.field, after) : after;
557
+ }
558
+ const FLAGS = [
559
+ "readOnly",
560
+ "required",
561
+ "noExport",
562
+ "multiline",
563
+ "password",
564
+ "comb",
565
+ "radiosInUnison",
566
+ "noToggleToOff",
567
+ "edit",
568
+ "multiSelect"
569
+ ];
570
+ /** The first `limit` characters of `text` (characters, as the file counts them); all without a limit. */
571
+ function firstCharacters(text, limit) {
572
+ if (!limit) return text;
573
+ const characters = Array.from(text);
574
+ return characters.length > limit ? characters.slice(0, limit).join("") : text;
575
+ }
576
+ /** The field, with every widget's appearance drawn again (a text or choice write). */
577
+ function redrawn(field, current) {
578
+ return {
579
+ field,
580
+ widgets: current.widgets.map((row) => row.hasAppearance ? row : {
581
+ ...row,
582
+ hasAppearance: true
583
+ })
584
+ };
585
+ }
586
+ /**
587
+ * The widget a checkbox's or radio group's default names: the one whose
588
+ * on-state it is, or, when none is, the one at that position (a field with
589
+ * `/Opt` written by a tool that names its widgets by position). `-1`: none.
590
+ */
591
+ function widgetNamedBy(widgets, state) {
592
+ const named = widgets.findIndex((widget) => widget.onState === state);
593
+ if (named >= 0 || !/^\d+$/.test(state)) return named;
594
+ return Number(state) < widgets.length ? Number(state) : -1;
595
+ }
596
+ /**
597
+ * A checkbox or radio group with widget `target` checked (`-1`: none), and
598
+ * the widgets that go with it: every widget with its export value and
599
+ * on-state for a checkbox or radios in unison, otherwise that one. Its value
600
+ * names the checked widget's on-state (`/V` names the appearance state that
601
+ * is on), or `Off`.
602
+ */
603
+ function toggled(current, target) {
604
+ const field = current.field;
605
+ if (field.family !== "checkbox" && field.family !== "radio") return current;
606
+ const unison = field.family === "checkbox" || field.radiosInUnison;
607
+ const on = target >= 0 ? field.widgets[target] : null;
608
+ const toggles = field.widgets.map((widget, at) => {
609
+ const checked = on !== null && (unison ? widget.exportValue === on.exportValue && widget.onState === on.onState : at === target);
610
+ return widget.checked === checked ? widget : {
611
+ ...widget,
612
+ checked
613
+ };
614
+ });
615
+ const valueEntry = scalar(on ? on.onState : "Off");
616
+ const next = field.family === "checkbox" ? {
617
+ ...field,
618
+ widgets: toggles,
619
+ valueEntry,
620
+ checked: toggles.some((widget) => widget.checked)
621
+ } : {
622
+ ...field,
623
+ widgets: toggles,
624
+ valueEntry,
625
+ value: toggles.find((widget) => widget.checked)?.exportValue ?? "Off"
626
+ };
627
+ const states = new Map(toggles.map((widget) => [widget.objectNumber, widget.checked ? widget.onState : "Off"]));
628
+ return {
629
+ field: next,
630
+ widgets: current.widgets.map((row) => {
631
+ const state = states.get(objectNumberOf(row.ref));
632
+ return state === void 0 || row.appearanceState === state ? row : {
633
+ ...row,
634
+ appearanceState: state
635
+ };
636
+ })
637
+ };
638
+ }
639
+ /** The option indexes `values` name, each the first option with that value, in option order. */
640
+ function matchedIndexes(options, values) {
641
+ const indexes = /* @__PURE__ */ new Set();
642
+ for (const value of values) {
643
+ const at = options.findIndex((option) => option.value === value);
644
+ if (at >= 0) indexes.add(at);
645
+ }
646
+ return [...indexes].sort((left, right) => left - right);
647
+ }
648
+ const choiceMatches = (field, values) => values.every((value) => field.options.some((option) => option.value === value));
649
+ const freeTextAllowed = (field, values) => field.family === "combobox" && field.edit && values.length === 1;
650
+ /** A choice field holding `values`: its options' selection, its value and `/V`. */
651
+ function choiceFieldWith(field, values) {
652
+ const matched = choiceMatches(field, values) ? matchedIndexes(field.options, values) : [];
653
+ const freeText = values.length > 0 && matched.length === 0;
654
+ const options = field.options.map((option, at) => {
655
+ const selected = matched.includes(at);
656
+ return option.selected === selected ? option : {
657
+ ...option,
658
+ selected
659
+ };
660
+ });
661
+ const chosen = freeText ? [...values] : matched.map((at) => field.options[at].value);
662
+ const valueEntry = choiceEntryOf(chosen);
663
+ if (field.family === "combobox") return {
664
+ ...field,
665
+ options,
666
+ valueEntry,
667
+ value: chosen[0] ?? ""
668
+ };
669
+ return {
670
+ ...field,
671
+ options,
672
+ valueEntry,
673
+ selectedValues: chosen
674
+ };
675
+ }
676
+ /** How `/V` (or `/DV`) holds choice values: none, one string, or an array. */
677
+ function choiceEntryOf(values) {
678
+ if (values.length === 0) return none();
679
+ return values.length === 1 ? scalar(values[0]) : {
680
+ kind: "array",
681
+ values: [...values]
682
+ };
683
+ }
684
+ /** `values` that are option values, in option order. */
685
+ function inOptionOrder(options, values) {
686
+ return matchedIndexes(options, values).map((at) => options[at].value);
687
+ }
688
+ /** A choice field with new options: what is still an option stays selected, and stays its default. */
689
+ function withOptions(field, options) {
690
+ const exports = options.map((option) => option.value);
691
+ const keepsFreeText = field.family === "combobox" && field.edit;
692
+ const kept = keptValues(field.family === "combobox" ? field.value === "" ? [] : [field.value] : field.selectedValues, exports, keepsFreeText);
693
+ const reselected = choiceFieldWith(field.family === "listbox" ? {
694
+ ...field,
695
+ options,
696
+ topIndex: topRowOf(field.topIndex, options)
697
+ } : {
698
+ ...field,
699
+ options
700
+ }, kept);
701
+ const defaults = valuesOfEntry(field.defaultValueEntry);
702
+ if (field.defaultValueEntry.kind === "none") return reselected;
703
+ return withDefault(reselected, keptValues(defaults, exports, keepsFreeText), true);
704
+ }
705
+ /** A list box's top row: an option's position, the last one past the end. */
706
+ function topRowOf(topIndex, options) {
707
+ return Math.max(0, Math.min(topIndex, options.length - 1));
708
+ }
709
+ /** The values still among `exports`; free text survives when nothing else does. */
710
+ function keptValues(values, exports, keepFreeText) {
711
+ const kept = values.filter((value) => exports.includes(value));
712
+ return kept.length === 0 && keepFreeText && values.length > 0 ? [...values] : kept;
713
+ }
714
+ /**
715
+ * A choice field's default set to `values` (option order; a dropdown's free
716
+ * text as it is). `filtered`: what new options left of the old default,
717
+ * where none left is an empty default rather than no default.
718
+ */
719
+ function withDefault(field, values, filtered = false) {
720
+ if (values.length === 0) {
721
+ const entry = !filtered ? none() : field.family === "listbox" && field.multiSelect ? {
722
+ kind: "array",
723
+ values: []
724
+ } : scalar("");
725
+ return field.family === "combobox" ? {
726
+ ...field,
727
+ defaultValueEntry: entry,
728
+ defaultValue: ""
729
+ } : {
730
+ ...field,
731
+ defaultValueEntry: entry,
732
+ defaultValue: []
733
+ };
734
+ }
735
+ const matched = choiceMatches(field, values);
736
+ const ordered = matched ? inOptionOrder(field.options, values) : [...values];
737
+ const entry = matched ? choiceEntryOf(ordered) : scalar(values[0]);
738
+ return field.family === "combobox" ? {
739
+ ...field,
740
+ defaultValueEntry: entry,
741
+ defaultValue: ordered[0] ?? ""
742
+ } : {
743
+ ...field,
744
+ defaultValueEntry: entry,
745
+ defaultValue: ordered
746
+ };
747
+ }
748
+ function valuesOfEntry(entry) {
749
+ if (entry.kind === "scalar") return [entry.value];
750
+ if (entry.kind === "array") return [...entry.values];
751
+ return [];
752
+ }
753
+ /** A new widget's row: its placement and look, and what attaching it to the field gives it. */
754
+ function widgetRowOfPlacement(draft, placement, at) {
755
+ const { page: _page, exportValue: _exportValue, ...look } = placement;
756
+ const row = require_calibrate.annotationOfDraft({
757
+ subtype: "widget",
758
+ ...look
759
+ }, {
760
+ ref: at.ref,
761
+ ...at.nm !== void 0 ? { nm: at.nm } : {}
762
+ });
763
+ const toggle = draft.family === "checkbox" || draft.family === "radio";
764
+ return {
765
+ ...row,
766
+ rect: standingRectOf(row.box, row.rotation),
767
+ field: {
768
+ kind: "objectNumber",
769
+ objectNumber: at.field
770
+ },
771
+ fieldFamily: draft.family,
772
+ print: true,
773
+ hasAppearance: draft.family !== "signature",
774
+ appearanceState: toggle ? "Off" : null,
775
+ caption: draft.family === "pushbutton" ? placement.caption ?? null : null
776
+ };
777
+ }
778
+ function toggleWidgetOf(widget, exportValue) {
779
+ return {
780
+ ...widget,
781
+ onState: exportValue,
782
+ exportValue,
783
+ checked: false
784
+ };
785
+ }
786
+ const optionOf = (input) => ({
787
+ label: input.label,
788
+ value: input.value,
789
+ selected: false
790
+ });
791
+ const objectNumberOf = (ref) => ref.kind === "objectNumber" ? ref.objectNumber : 0;
792
+ const scalar = (value) => ({
793
+ kind: "scalar",
794
+ value
795
+ });
796
+ const none = () => ({ kind: "none" });
797
+ function notReset(field) {
798
+ return new require_format.EngineError(require_format.EngineErrorCode.Unknown, `'${field.name}' could not be reset`);
799
+ }
800
+ //#endregion
801
+ //#region src/forms/effects.ts
802
+ /**
803
+ * A script run's effects as the ops of one change, in their order: what a
804
+ * form commit sends with `doc.apply`, all or nothing.
805
+ */
806
+ function formEffectOps(effects) {
807
+ return effects.map((effect) => {
808
+ switch (effect.kind) {
809
+ case "setValue": return {
810
+ type: "forms.setValue",
811
+ field: effect.ref,
812
+ value: effect.value
813
+ };
814
+ case "setDisplay": return {
815
+ type: "forms.setDisplay",
816
+ field: effect.ref,
817
+ display: effect.display
818
+ };
819
+ case "setAppearanceText": return {
820
+ type: "forms.setAppearanceText",
821
+ field: effect.ref,
822
+ text: effect.text
823
+ };
824
+ case "reset": return {
825
+ type: "forms.reset",
826
+ fields: effect.refs
827
+ };
828
+ }
829
+ });
830
+ }
831
+ //#endregion
832
+ //#region src/mutation/Change.ts
833
+ /** Whether an item is an op an undo left alone entirely. */
834
+ function isSkippedItem(item) {
835
+ return item.type === "skipped";
836
+ }
837
+ /**
838
+ * Whether an item wrote to the document: not an op an undo left alone, nor
839
+ * an import that left every row of its bundle out.
840
+ */
841
+ function itemWrote(item) {
842
+ switch (item.type) {
843
+ case "skipped": return false;
844
+ case "annotations.import": return item.annotations.length > 0;
845
+ case "forms.import":
846
+ case "forms.importValues": return item.fields.length > 0;
847
+ default: return true;
848
+ }
849
+ }
850
+ /** Whether a change is an undo (`{ undoOf }`) rather than a list of ops. */
851
+ function isUndoChange(change) {
852
+ return "undoOf" in change;
853
+ }
854
+ /**
855
+ * The object numbers a change's creates name: each must be one its editing
856
+ * session holds. An undo names none; what it restores keeps its numbers.
857
+ */
858
+ function objectNumbersNamedBy(change) {
859
+ if (isUndoChange(change)) return [];
860
+ const named = [];
861
+ for (const op of change.ops) switch (op.type) {
862
+ case "annotations.create":
863
+ if (op.objectNumber !== void 0) named.push(op.objectNumber);
864
+ break;
865
+ case "forms.create":
866
+ if (op.objectNumber !== void 0) named.push(op.objectNumber);
867
+ named.push(...op.widgetObjectNumbers ?? []);
868
+ break;
869
+ case "forms.addWidget":
870
+ if (op.objectNumber !== void 0) named.push(op.objectNumber);
871
+ if (op.splitObjectNumber !== void 0) named.push(op.splitObjectNumber);
872
+ break;
873
+ case "outline.create":
874
+ if (op.objectNumber !== void 0) named.push(op.objectNumber);
875
+ break;
876
+ case "pages.insertBlank":
877
+ named.push(...op.objectNumbers ?? []);
878
+ break;
879
+ default: break;
880
+ }
881
+ return named;
882
+ }
883
+ /**
884
+ * The object numbers a change's ops refer to: every `{ kind: 'objectNumber' }`
885
+ * ref anywhere in them, the annotation or field an op writes and the parent
886
+ * a reply names among them. A change that refers to a number only a refused
887
+ * change creates can't apply. An undo refers to none: it names its change.
888
+ */
889
+ function objectNumbersReferencedBy(change) {
890
+ if (isUndoChange(change)) return [];
891
+ const referenced = /* @__PURE__ */ new Set();
892
+ const visit = (value) => {
893
+ if (Array.isArray(value)) {
894
+ value.forEach(visit);
895
+ return;
896
+ }
897
+ if (value === null || typeof value !== "object" || ArrayBuffer.isView(value)) return;
898
+ const record = value;
899
+ if (record.kind === "objectNumber" && typeof record.objectNumber === "number") referenced.add(record.objectNumber);
900
+ for (const field of Object.values(record)) visit(field);
901
+ };
902
+ change.ops.forEach(visit);
903
+ return [...referenced];
904
+ }
905
+ /**
906
+ * A change with bytes it owns, ready to send: each op's resources copied
907
+ * (`resolveAnnotationResources`), a file attachment's `file` completed from
908
+ * its `File` (`withFileFromResource`), a signature appearance copied.
909
+ * `buffers` lists every copy, for a worker's transfer list. The caller's
910
+ * bytes are only read.
911
+ */
912
+ async function resolveChangeResources(change) {
913
+ if (isUndoChange(change)) return {
914
+ change,
915
+ buffers: []
916
+ };
917
+ const buffers = [];
918
+ const ops = [];
919
+ for (const op of change.ops) switch (op.type) {
920
+ case "annotations.create": {
921
+ const { resources, ...rest } = op;
922
+ const wire = await require_calibrate.resolveAnnotationResources(resources);
923
+ buffers.push(...require_calibrate.annotationResourceBuffers(wire));
924
+ ops.push({
925
+ ...rest,
926
+ data: require_calibrate.withFileFromResource(op.data, resources),
927
+ ...require_calibrate.hasAnnotationResources(wire) ? { resources: wire } : {}
928
+ });
929
+ break;
930
+ }
931
+ case "annotations.update": {
932
+ const { resources, ...rest } = op;
933
+ const wire = await require_calibrate.resolveAnnotationResources(resources);
934
+ buffers.push(...require_calibrate.annotationResourceBuffers(wire));
935
+ ops.push({
936
+ ...rest,
937
+ ...require_calibrate.hasAnnotationResources(wire) ? { resources: wire } : {}
938
+ });
939
+ break;
940
+ }
941
+ case "forms.setSignatureAppearance": {
942
+ const pdf = op.appearance.pdf.slice();
943
+ buffers.push(pdf.buffer);
944
+ ops.push({
945
+ ...op,
946
+ appearance: { pdf }
947
+ });
948
+ break;
949
+ }
950
+ case "pages.insert": {
951
+ const source = op.source.slice();
952
+ buffers.push(source.buffer);
953
+ ops.push({
954
+ ...op,
955
+ source
956
+ });
957
+ break;
958
+ }
959
+ case "attachments.create": {
960
+ const wire = await require_calibrate.resolveAnnotationResources(op.resources);
961
+ buffers.push(...require_calibrate.annotationResourceBuffers(wire));
962
+ ops.push({
963
+ ...op,
964
+ resources: wire
965
+ });
966
+ break;
967
+ }
968
+ default: ops.push(op);
969
+ }
970
+ return {
971
+ change: { ops },
972
+ buffers
973
+ };
974
+ }
975
+ //#endregion
976
+ Object.defineProperty(exports, "OUTLINE_READ_LIMITS", {
977
+ enumerable: true,
978
+ get: function() {
979
+ return OUTLINE_READ_LIMITS;
980
+ }
981
+ });
982
+ Object.defineProperty(exports, "assertChoiceDefault", {
983
+ enumerable: true,
984
+ get: function() {
985
+ return assertChoiceDefault;
986
+ }
987
+ });
988
+ Object.defineProperty(exports, "defaultEntryOfDraft", {
989
+ enumerable: true,
990
+ get: function() {
991
+ return defaultEntryOfDraft;
992
+ }
993
+ });
994
+ Object.defineProperty(exports, "deletedAttachmentOf", {
995
+ enumerable: true,
996
+ get: function() {
997
+ return deletedAttachmentOf;
998
+ }
999
+ });
1000
+ Object.defineProperty(exports, "fieldAfterReset", {
1001
+ enumerable: true,
1002
+ get: function() {
1003
+ return fieldAfterReset;
1004
+ }
1005
+ });
1006
+ Object.defineProperty(exports, "fieldAfterValue", {
1007
+ enumerable: true,
1008
+ get: function() {
1009
+ return fieldAfterValue;
1010
+ }
1011
+ });
1012
+ Object.defineProperty(exports, "fieldValueWriteOf", {
1013
+ enumerable: true,
1014
+ get: function() {
1015
+ return fieldValueWriteOf;
1016
+ }
1017
+ });
1018
+ Object.defineProperty(exports, "fitWidgetToFamily", {
1019
+ enumerable: true,
1020
+ get: function() {
1021
+ return fitWidgetToFamily;
1022
+ }
1023
+ });
1024
+ Object.defineProperty(exports, "formEffectOps", {
1025
+ enumerable: true,
1026
+ get: function() {
1027
+ return formEffectOps;
1028
+ }
1029
+ });
1030
+ Object.defineProperty(exports, "formFieldAfter", {
1031
+ enumerable: true,
1032
+ get: function() {
1033
+ return formFieldAfter;
1034
+ }
1035
+ });
1036
+ Object.defineProperty(exports, "formFieldOfDraft", {
1037
+ enumerable: true,
1038
+ get: function() {
1039
+ return formFieldOfDraft;
1040
+ }
1041
+ });
1042
+ Object.defineProperty(exports, "isAtDefault", {
1043
+ enumerable: true,
1044
+ get: function() {
1045
+ return isAtDefault;
1046
+ }
1047
+ });
1048
+ Object.defineProperty(exports, "isNoOpWrite", {
1049
+ enumerable: true,
1050
+ get: function() {
1051
+ return isNoOpWrite;
1052
+ }
1053
+ });
1054
+ Object.defineProperty(exports, "isSkippedItem", {
1055
+ enumerable: true,
1056
+ get: function() {
1057
+ return isSkippedItem;
1058
+ }
1059
+ });
1060
+ Object.defineProperty(exports, "isUndoChange", {
1061
+ enumerable: true,
1062
+ get: function() {
1063
+ return isUndoChange;
1064
+ }
1065
+ });
1066
+ Object.defineProperty(exports, "itemWrote", {
1067
+ enumerable: true,
1068
+ get: function() {
1069
+ return itemWrote;
1070
+ }
1071
+ });
1072
+ Object.defineProperty(exports, "objectNumbersNamedBy", {
1073
+ enumerable: true,
1074
+ get: function() {
1075
+ return objectNumbersNamedBy;
1076
+ }
1077
+ });
1078
+ Object.defineProperty(exports, "objectNumbersReferencedBy", {
1079
+ enumerable: true,
1080
+ get: function() {
1081
+ return objectNumbersReferencedBy;
1082
+ }
1083
+ });
1084
+ Object.defineProperty(exports, "outlineItemAfter", {
1085
+ enumerable: true,
1086
+ get: function() {
1087
+ return outlineItemAfter;
1088
+ }
1089
+ });
1090
+ Object.defineProperty(exports, "outlineItemOfDraft", {
1091
+ enumerable: true,
1092
+ get: function() {
1093
+ return outlineItemOfDraft;
1094
+ }
1095
+ });
1096
+ Object.defineProperty(exports, "outlineItemWithChildren", {
1097
+ enumerable: true,
1098
+ get: function() {
1099
+ return outlineItemWithChildren;
1100
+ }
1101
+ });
1102
+ Object.defineProperty(exports, "resolveChangeResources", {
1103
+ enumerable: true,
1104
+ get: function() {
1105
+ return resolveChangeResources;
1106
+ }
1107
+ });
1108
+ Object.defineProperty(exports, "topRowOf", {
1109
+ enumerable: true,
1110
+ get: function() {
1111
+ return topRowOf;
1112
+ }
1113
+ });
1114
+ Object.defineProperty(exports, "valueEntriesEqual", {
1115
+ enumerable: true,
1116
+ get: function() {
1117
+ return valueEntriesEqual;
1118
+ }
1119
+ });
1120
+ Object.defineProperty(exports, "widgetAfterPatch", {
1121
+ enumerable: true,
1122
+ get: function() {
1123
+ return widgetAfterPatch;
1124
+ }
1125
+ });
1126
+ Object.defineProperty(exports, "widgetsAfterDisplay", {
1127
+ enumerable: true,
1128
+ get: function() {
1129
+ return widgetsAfterDisplay;
1130
+ }
1131
+ });
1132
+
1133
+ //# sourceMappingURL=Change-Ct-dB8D5.cjs.map