@embedpdf/plugin-annotation 1.5.0 → 2.0.0-next.1

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 (106) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1760 -1444
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +58 -19
  6. package/dist/lib/annotation-plugin.d.ts +14 -5
  7. package/dist/lib/index.d.ts +1 -1
  8. package/dist/lib/reducer.d.ts +2 -1
  9. package/dist/lib/selectors.d.ts +10 -8
  10. package/dist/lib/types.d.ts +53 -10
  11. package/dist/preact/index.cjs +1 -1
  12. package/dist/preact/index.cjs.map +1 -1
  13. package/dist/preact/index.js +96 -48
  14. package/dist/preact/index.js.map +1 -1
  15. package/dist/react/index.cjs +1 -1
  16. package/dist/react/index.cjs.map +1 -1
  17. package/dist/react/index.js +96 -48
  18. package/dist/react/index.js.map +1 -1
  19. package/dist/shared/components/annotation-container.d.ts +4 -3
  20. package/dist/shared/components/annotation-layer.d.ts +7 -7
  21. package/dist/shared/components/annotation-paint-layer.d.ts +2 -1
  22. package/dist/shared/components/annotations/stamp.d.ts +2 -1
  23. package/dist/shared/components/annotations.d.ts +3 -2
  24. package/dist/shared/components/render-annotation.d.ts +2 -1
  25. package/dist/shared/components/text-markup.d.ts +2 -1
  26. package/dist/shared/components/types.d.ts +7 -7
  27. package/dist/shared/hooks/use-annotation.d.ts +8 -4
  28. package/dist/shared/index.d.ts +1 -0
  29. package/dist/shared-preact/components/annotation-container.d.ts +4 -3
  30. package/dist/shared-preact/components/annotation-layer.d.ts +7 -7
  31. package/dist/shared-preact/components/annotation-paint-layer.d.ts +2 -1
  32. package/dist/shared-preact/components/annotations/stamp.d.ts +2 -1
  33. package/dist/shared-preact/components/annotations.d.ts +3 -2
  34. package/dist/shared-preact/components/render-annotation.d.ts +2 -1
  35. package/dist/shared-preact/components/text-markup.d.ts +2 -1
  36. package/dist/shared-preact/components/types.d.ts +7 -7
  37. package/dist/shared-preact/hooks/use-annotation.d.ts +8 -4
  38. package/dist/shared-preact/index.d.ts +1 -0
  39. package/dist/shared-react/components/annotation-container.d.ts +4 -3
  40. package/dist/shared-react/components/annotation-layer.d.ts +7 -7
  41. package/dist/shared-react/components/annotation-paint-layer.d.ts +2 -1
  42. package/dist/shared-react/components/annotations/stamp.d.ts +2 -1
  43. package/dist/shared-react/components/annotations.d.ts +3 -2
  44. package/dist/shared-react/components/render-annotation.d.ts +2 -1
  45. package/dist/shared-react/components/text-markup.d.ts +2 -1
  46. package/dist/shared-react/components/types.d.ts +7 -7
  47. package/dist/shared-react/hooks/use-annotation.d.ts +8 -4
  48. package/dist/shared-react/index.d.ts +1 -0
  49. package/dist/svelte/components/AnnotationContainer.svelte.d.ts +26 -0
  50. package/dist/svelte/components/AnnotationLayer.svelte.d.ts +27 -0
  51. package/dist/svelte/components/AnnotationPaintLayer.svelte.d.ts +8 -0
  52. package/dist/svelte/components/Annotations.svelte.d.ts +22 -0
  53. package/dist/svelte/components/PreviewRenderer.svelte.d.ts +8 -0
  54. package/dist/svelte/components/RenderAnnotation.svelte.d.ts +13 -0
  55. package/dist/svelte/components/TextMarkup.svelte.d.ts +8 -0
  56. package/dist/svelte/components/annotations/Circle.svelte.d.ts +26 -0
  57. package/dist/svelte/components/annotations/FreeText.svelte.d.ts +15 -0
  58. package/dist/svelte/components/annotations/Ink.svelte.d.ts +14 -0
  59. package/dist/svelte/components/annotations/Line.svelte.d.ts +18 -0
  60. package/dist/svelte/components/annotations/Polygon.svelte.d.ts +19 -0
  61. package/dist/svelte/components/annotations/Polyline.svelte.d.ts +17 -0
  62. package/dist/svelte/components/annotations/Square.svelte.d.ts +16 -0
  63. package/dist/svelte/components/annotations/Stamp.svelte.d.ts +13 -0
  64. package/dist/svelte/components/annotations/index.d.ts +8 -0
  65. package/dist/svelte/components/index.d.ts +9 -0
  66. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +13 -0
  67. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +13 -0
  68. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +13 -0
  69. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +13 -0
  70. package/dist/svelte/components/text-markup/index.d.ts +4 -0
  71. package/dist/svelte/components/types.d.ts +32 -0
  72. package/dist/svelte/hooks/index.d.ts +1 -0
  73. package/dist/svelte/hooks/use-annotation.svelte.d.ts +21 -0
  74. package/dist/svelte/index.cjs +2 -0
  75. package/dist/svelte/index.cjs.map +1 -0
  76. package/dist/svelte/index.d.ts +4 -0
  77. package/dist/svelte/index.js +3083 -0
  78. package/dist/svelte/index.js.map +1 -0
  79. package/dist/svelte/types.d.ts +54 -0
  80. package/dist/vue/components/annotation-container.vue.d.ts +10 -5
  81. package/dist/vue/components/annotation-layer.vue.d.ts +13 -7
  82. package/dist/vue/components/annotation-paint-layer.vue.d.ts +3 -1
  83. package/dist/vue/components/annotations/circle.vue.d.ts +2 -1
  84. package/dist/vue/components/annotations/free-text.vue.d.ts +2 -1
  85. package/dist/vue/components/annotations/ink.vue.d.ts +2 -1
  86. package/dist/vue/components/annotations/line.vue.d.ts +2 -1
  87. package/dist/vue/components/annotations/polygon.vue.d.ts +2 -1
  88. package/dist/vue/components/annotations/polyline.vue.d.ts +2 -1
  89. package/dist/vue/components/annotations/square.vue.d.ts +2 -1
  90. package/dist/vue/components/annotations/stamp.vue.d.ts +3 -1
  91. package/dist/vue/components/annotations.vue.d.ts +7 -3
  92. package/dist/vue/components/preview-renderer.vue.d.ts +2 -1
  93. package/dist/vue/components/render-annotation.vue.d.ts +3 -1
  94. package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -1
  95. package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -1
  96. package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -1
  97. package/dist/vue/components/text-markup/underline.vue.d.ts +2 -1
  98. package/dist/vue/components/text-markup.vue.d.ts +3 -1
  99. package/dist/vue/hooks/use-annotation.d.ts +21 -2682
  100. package/dist/vue/index.cjs +1 -1
  101. package/dist/vue/index.cjs.map +1 -1
  102. package/dist/vue/index.d.ts +1 -0
  103. package/dist/vue/index.js +354 -250
  104. package/dist/vue/index.js.map +1 -1
  105. package/dist/vue/types.d.ts +23 -0
  106. package/package.json +19 -11
@@ -0,0 +1,3083 @@
1
+ import * as $ from "svelte/internal/client";
2
+ import { AnnotationPlugin, initialDocumentState, patching, getAnnotationsByPageIndex, getSelectedAnnotationByPageIndex, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp } from "@embedpdf/plugin-annotation";
3
+ export * from "@embedpdf/plugin-annotation";
4
+ import { useCapability, usePlugin, useDocumentState } from "@embedpdf/core/svelte";
5
+ import "svelte/internal/disclose-version";
6
+ import { useInteractionHandles, deepToRaw, doublePress, CounterRotate } from "@embedpdf/utils/svelte";
7
+ import { PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCss, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype, Rotation } from "@embedpdf/models";
8
+ import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/svelte";
9
+ import { useSelectionCapability } from "@embedpdf/plugin-selection/svelte";
10
+ const useAnnotationCapability = () => useCapability(AnnotationPlugin.id);
11
+ const useAnnotationPlugin = () => usePlugin(AnnotationPlugin.id);
12
+ const useAnnotation = (getDocumentId) => {
13
+ const capability = useAnnotationCapability();
14
+ let state = $.state($.proxy(initialDocumentState()));
15
+ const documentId = $.derived(getDocumentId);
16
+ const scopedProvides = $.derived(() => capability.provides && $.get(documentId) ? capability.provides.forDocument($.get(documentId)) : null);
17
+ $.user_effect(() => {
18
+ const provides = capability.provides;
19
+ const docId = $.get(documentId);
20
+ if (!provides || !docId) {
21
+ $.set(state, initialDocumentState(), true);
22
+ return;
23
+ }
24
+ const scope = provides.forDocument(docId);
25
+ $.set(state, scope.getState(), true);
26
+ return scope.onStateChange((newState) => {
27
+ $.set(state, newState, true);
28
+ });
29
+ });
30
+ return {
31
+ get provides() {
32
+ return $.get(scopedProvides);
33
+ },
34
+ get state() {
35
+ return $.get(state);
36
+ }
37
+ };
38
+ };
39
+ var root_6$1 = $.from_html(`<div></div>`);
40
+ var root_10 = $.from_html(`<div></div>`);
41
+ var root$a = $.from_html(`<div data-no-interaction=""><div><!> <!> <!></div> <!></div>`);
42
+ function AnnotationContainer($$anchor, $$props) {
43
+ $.push($$props, true);
44
+ let lockAspectRatio = $.prop($$props, "lockAspectRatio", 3, false), propsClass = $.prop($$props, "class", 3, ""), outlineOffset = $.prop($$props, "outlineOffset", 3, 1), zIndex = $.prop($$props, "zIndex", 3, 20), selectionOutlineColor = $.prop($$props, "selectionOutlineColor", 3, "#007ACC"), restProps = $.rest_props($$props, [
45
+ "$$slots",
46
+ "$$events",
47
+ "$$legacy",
48
+ "documentId",
49
+ "scale",
50
+ "pageIndex",
51
+ "rotation",
52
+ "pageWidth",
53
+ "pageHeight",
54
+ "trackedAnnotation",
55
+ "children",
56
+ "isSelected",
57
+ "isDraggable",
58
+ "isResizable",
59
+ "lockAspectRatio",
60
+ "style",
61
+ "class",
62
+ "vertexConfig",
63
+ "selectionMenu",
64
+ "selectionMenuSnippet",
65
+ "outlineOffset",
66
+ "onDoubleClick",
67
+ "onSelect",
68
+ "zIndex",
69
+ "resizeUI",
70
+ "vertexUI",
71
+ "selectionOutlineColor",
72
+ "customAnnotationRenderer"
73
+ ]);
74
+ let preview = $.state($.proxy($$props.trackedAnnotation.object));
75
+ let annotationCapability = useAnnotationCapability();
76
+ let gestureBaseRef = $.state(null);
77
+ const annotationProvides = $.derived(() => annotationCapability.provides ? annotationCapability.provides.forDocument($$props.documentId) : null);
78
+ let currentObject = $.derived(() => $.get(preview) ? { ...$$props.trackedAnnotation.object, ...$.get(preview) } : $$props.trackedAnnotation.object);
79
+ const HANDLE_COLOR = $.derived(() => {
80
+ var _a;
81
+ return ((_a = $$props.resizeUI) == null ? void 0 : _a.color) ?? "#007ACC";
82
+ });
83
+ const VERTEX_COLOR = $.derived(() => {
84
+ var _a;
85
+ return ((_a = $$props.vertexUI) == null ? void 0 : _a.color) ?? "#007ACC";
86
+ });
87
+ const HANDLE_SIZE = $.derived(() => {
88
+ var _a;
89
+ return ((_a = $$props.resizeUI) == null ? void 0 : _a.size) ?? 12;
90
+ });
91
+ const VERTEX_SIZE = $.derived(() => {
92
+ var _a;
93
+ return ((_a = $$props.vertexUI) == null ? void 0 : _a.size) ?? 12;
94
+ });
95
+ $.user_effect(() => {
96
+ if ($$props.trackedAnnotation.object) {
97
+ $.set(preview, $$props.trackedAnnotation.object, true);
98
+ }
99
+ });
100
+ const interactionHandles = useInteractionHandles(() => {
101
+ var _a;
102
+ return {
103
+ controller: {
104
+ element: $.get(currentObject).rect,
105
+ vertices: (_a = $$props.vertexConfig) == null ? void 0 : _a.extractVertices($.get(currentObject)),
106
+ constraints: {
107
+ minWidth: 10,
108
+ minHeight: 10,
109
+ boundingBox: { width: $$props.pageWidth, height: $$props.pageHeight }
110
+ },
111
+ maintainAspectRatio: lockAspectRatio(),
112
+ pageRotation: $$props.rotation,
113
+ scale: $$props.scale,
114
+ enabled: $$props.isSelected,
115
+ onUpdate: (event) => {
116
+ var _a2, _b, _c, _d;
117
+ if (!((_a2 = event.transformData) == null ? void 0 : _a2.type)) return;
118
+ if (event.state === "start") {
119
+ $.set(gestureBaseRef, $.get(currentObject), true);
120
+ }
121
+ const transformType = event.transformData.type;
122
+ const base = $.get(gestureBaseRef) ?? $.get(currentObject);
123
+ const changes = event.transformData.changes.vertices ? (_b = $$props.vertexConfig) == null ? void 0 : _b.transformAnnotation(base, event.transformData.changes.vertices) : { rect: event.transformData.changes.rect };
124
+ const patched = (_c = annotationCapability.provides) == null ? void 0 : _c.transformAnnotation(base, {
125
+ type: transformType,
126
+ changes,
127
+ metadata: event.transformData.metadata
128
+ });
129
+ if (patched) {
130
+ $.set(preview, { ...$.get(preview), ...patched }, true);
131
+ }
132
+ if (event.state === "end" && patched) {
133
+ $.set(gestureBaseRef, null);
134
+ const sanitized = deepToRaw(patched);
135
+ (_d = $.get(annotationProvides)) == null ? void 0 : _d.updateAnnotation($$props.pageIndex, $$props.trackedAnnotation.object.id, sanitized);
136
+ }
137
+ }
138
+ },
139
+ resizeUI: {
140
+ handleSize: $.get(HANDLE_SIZE),
141
+ spacing: outlineOffset(),
142
+ offsetMode: "outside",
143
+ includeSides: lockAspectRatio() ? false : true,
144
+ zIndex: zIndex() + 1
145
+ },
146
+ vertexUI: { vertexSize: $.get(VERTEX_SIZE), zIndex: zIndex() + 2 },
147
+ includeVertices: $$props.vertexConfig ? true : false
148
+ };
149
+ });
150
+ const resizeHandles = $.derived(() => interactionHandles.resize);
151
+ const vertexHandles = $.derived(() => interactionHandles.vertices);
152
+ const shouldShowMenu = $.derived(() => $$props.isSelected && (!!$$props.selectionMenu || !!$$props.selectionMenuSnippet));
153
+ function buildContext() {
154
+ return {
155
+ type: "annotation",
156
+ annotation: $$props.trackedAnnotation,
157
+ pageIndex: $$props.pageIndex
158
+ };
159
+ }
160
+ const menuPlacement = { suggestTop: false, spaceAbove: 0, spaceBelow: 0 };
161
+ function buildMenuProps(rect, menuWrapperProps) {
162
+ return {
163
+ context: buildContext(),
164
+ selected: $$props.isSelected,
165
+ rect,
166
+ placement: menuPlacement,
167
+ menuWrapperProps
168
+ };
169
+ }
170
+ var div = root$a();
171
+ var div_1 = $.child(div);
172
+ $.attribute_effect(div_1, () => ({
173
+ ...$$props.isDraggable && $$props.isSelected ? interactionHandles.dragProps : {},
174
+ style: $$props.style || "",
175
+ class: propsClass(),
176
+ ...restProps,
177
+ [$.STYLE]: {
178
+ position: "absolute",
179
+ left: `${$.get(currentObject).rect.origin.x * $$props.scale}px`,
180
+ top: `${$.get(currentObject).rect.origin.y * $$props.scale}px`,
181
+ width: `${$.get(currentObject).rect.size.width * $$props.scale}px`,
182
+ height: `${$.get(currentObject).rect.size.height * $$props.scale}px`,
183
+ outline: $$props.isSelected ? `1px solid ${selectionOutlineColor()}` : "none",
184
+ "outline-offset": $$props.isSelected ? `${outlineOffset()}px` : "0px",
185
+ "pointer-events": $$props.isSelected ? "auto" : "none",
186
+ "touch-action": "none",
187
+ cursor: $$props.isSelected && $$props.isDraggable ? "move" : "default",
188
+ "z-index": zIndex()
189
+ }
190
+ }));
191
+ var node = $.child(div_1);
192
+ {
193
+ var consequent = ($$anchor2) => {
194
+ var fragment = $.comment();
195
+ var node_1 = $.first_child(fragment);
196
+ $.snippet(node_1, () => $$props.customAnnotationRenderer ?? $.noop, () => ({
197
+ annotation: $.get(currentObject),
198
+ children: $$props.children,
199
+ isSelected: $$props.isSelected,
200
+ scale: $$props.scale,
201
+ rotation: $$props.rotation,
202
+ pageWidth: $$props.pageWidth,
203
+ pageHeight: $$props.pageHeight,
204
+ pageIndex: $$props.pageIndex,
205
+ onSelect: $$props.onSelect
206
+ }));
207
+ $.append($$anchor2, fragment);
208
+ };
209
+ var alternate = ($$anchor2) => {
210
+ var fragment_1 = $.comment();
211
+ var node_2 = $.first_child(fragment_1);
212
+ $.snippet(node_2, () => $$props.children, () => $.get(currentObject));
213
+ $.append($$anchor2, fragment_1);
214
+ };
215
+ $.if(node, ($$render) => {
216
+ if ($$props.customAnnotationRenderer) $$render(consequent);
217
+ else $$render(alternate, false);
218
+ });
219
+ }
220
+ var node_3 = $.sibling(node, 2);
221
+ {
222
+ var consequent_2 = ($$anchor2) => {
223
+ var fragment_2 = $.comment();
224
+ var node_4 = $.first_child(fragment_2);
225
+ $.each(node_4, 17, () => $.get(resizeHandles), ({ key, style: handleStyle, ...hProps }) => key, ($$anchor3, $$item) => {
226
+ let handleStyle = () => $.get($$item).style;
227
+ let hProps = () => $.exclude_from_object($.get($$item), ["key", "style"]);
228
+ var fragment_3 = $.comment();
229
+ var node_5 = $.first_child(fragment_3);
230
+ {
231
+ var consequent_1 = ($$anchor4) => {
232
+ const Component = $.derived(() => $$props.resizeUI.component);
233
+ var fragment_4 = $.comment();
234
+ var node_6 = $.first_child(fragment_4);
235
+ $.component(node_6, () => $.get(Component), ($$anchor5, Component_1) => {
236
+ Component_1($$anchor5, $.spread_props(hProps, {
237
+ get backgroundColor() {
238
+ return $.get(HANDLE_COLOR);
239
+ }
240
+ }));
241
+ });
242
+ $.append($$anchor4, fragment_4);
243
+ };
244
+ var alternate_1 = ($$anchor4) => {
245
+ var div_2 = root_6$1();
246
+ $.attribute_effect(div_2, () => ({
247
+ ...hProps(),
248
+ style: `${handleStyle() ?? ""}; background-color: ${$.get(HANDLE_COLOR) ?? ""};`
249
+ }));
250
+ $.append($$anchor4, div_2);
251
+ };
252
+ $.if(node_5, ($$render) => {
253
+ var _a;
254
+ if ((_a = $$props.resizeUI) == null ? void 0 : _a.component) $$render(consequent_1);
255
+ else $$render(alternate_1, false);
256
+ });
257
+ }
258
+ $.append($$anchor3, fragment_3);
259
+ });
260
+ $.append($$anchor2, fragment_2);
261
+ };
262
+ $.if(node_3, ($$render) => {
263
+ if ($$props.isSelected && $$props.isResizable) $$render(consequent_2);
264
+ });
265
+ }
266
+ var node_7 = $.sibling(node_3, 2);
267
+ {
268
+ var consequent_4 = ($$anchor2) => {
269
+ var fragment_5 = $.comment();
270
+ var node_8 = $.first_child(fragment_5);
271
+ $.each(node_8, 17, () => $.get(vertexHandles), ({ key, style: vertexStyle, ...vProps }) => key, ($$anchor3, $$item) => {
272
+ let vertexStyle = () => $.get($$item).style;
273
+ let vProps = () => $.exclude_from_object($.get($$item), ["key", "style"]);
274
+ var fragment_6 = $.comment();
275
+ var node_9 = $.first_child(fragment_6);
276
+ {
277
+ var consequent_3 = ($$anchor4) => {
278
+ const Component = $.derived(() => $$props.vertexUI.component);
279
+ var fragment_7 = $.comment();
280
+ var node_10 = $.first_child(fragment_7);
281
+ $.component(node_10, () => $.get(Component), ($$anchor5, Component_2) => {
282
+ Component_2($$anchor5, $.spread_props(vProps, {
283
+ get backgroundColor() {
284
+ return $.get(VERTEX_COLOR);
285
+ }
286
+ }));
287
+ });
288
+ $.append($$anchor4, fragment_7);
289
+ };
290
+ var alternate_2 = ($$anchor4) => {
291
+ var div_3 = root_10();
292
+ $.attribute_effect(div_3, () => ({
293
+ ...vProps(),
294
+ style: `${vertexStyle() ?? ""}; background-color: ${$.get(VERTEX_COLOR) ?? ""};`
295
+ }));
296
+ $.append($$anchor4, div_3);
297
+ };
298
+ $.if(node_9, ($$render) => {
299
+ var _a;
300
+ if ((_a = $$props.vertexUI) == null ? void 0 : _a.component) $$render(consequent_3);
301
+ else $$render(alternate_2, false);
302
+ });
303
+ }
304
+ $.append($$anchor3, fragment_6);
305
+ });
306
+ $.append($$anchor2, fragment_5);
307
+ };
308
+ $.if(node_7, ($$render) => {
309
+ if ($$props.isSelected) $$render(consequent_4);
310
+ });
311
+ }
312
+ $.reset(div_1);
313
+ $.action(div_1, ($$node, $$action_arg) => {
314
+ var _a;
315
+ return (_a = doublePress) == null ? void 0 : _a($$node, $$action_arg);
316
+ }, () => ({ onDouble: $$props.onDoubleClick }));
317
+ var node_11 = $.sibling(div_1, 2);
318
+ {
319
+ var consequent_8 = ($$anchor2) => {
320
+ {
321
+ const children = ($$anchor3, $$arg0) => {
322
+ let rect = () => $$arg0 == null ? void 0 : $$arg0().rect;
323
+ let menuWrapperProps = () => $$arg0 == null ? void 0 : $$arg0().menuWrapperProps;
324
+ const menuProps = $.derived(() => buildMenuProps(rect(), menuWrapperProps()));
325
+ var fragment_9 = $.comment();
326
+ var node_12 = $.first_child(fragment_9);
327
+ {
328
+ var consequent_6 = ($$anchor4) => {
329
+ const result = $.derived(() => $$props.selectionMenu($.get(menuProps)));
330
+ var fragment_10 = $.comment();
331
+ var node_13 = $.first_child(fragment_10);
332
+ {
333
+ var consequent_5 = ($$anchor5) => {
334
+ var fragment_11 = $.comment();
335
+ var node_14 = $.first_child(fragment_11);
336
+ $.component(node_14, () => $.get(result).component, ($$anchor6, result_component) => {
337
+ result_component($$anchor6, $.spread_props(() => $.get(result).props));
338
+ });
339
+ $.append($$anchor5, fragment_11);
340
+ };
341
+ $.if(node_13, ($$render) => {
342
+ if ($.get(result)) $$render(consequent_5);
343
+ });
344
+ }
345
+ $.append($$anchor4, fragment_10);
346
+ };
347
+ var alternate_3 = ($$anchor4) => {
348
+ var fragment_12 = $.comment();
349
+ var node_15 = $.first_child(fragment_12);
350
+ {
351
+ var consequent_7 = ($$anchor5) => {
352
+ var fragment_13 = $.comment();
353
+ var node_16 = $.first_child(fragment_13);
354
+ $.snippet(node_16, () => $$props.selectionMenuSnippet, () => $.get(menuProps));
355
+ $.append($$anchor5, fragment_13);
356
+ };
357
+ $.if(
358
+ node_15,
359
+ ($$render) => {
360
+ if ($$props.selectionMenuSnippet) $$render(consequent_7);
361
+ },
362
+ true
363
+ );
364
+ }
365
+ $.append($$anchor4, fragment_12);
366
+ };
367
+ $.if(node_12, ($$render) => {
368
+ if ($$props.selectionMenu) $$render(consequent_6);
369
+ else $$render(alternate_3, false);
370
+ });
371
+ }
372
+ $.append($$anchor3, fragment_9);
373
+ };
374
+ let $0 = $.derived(() => ({
375
+ origin: {
376
+ x: $.get(currentObject).rect.origin.x * $$props.scale,
377
+ y: $.get(currentObject).rect.origin.y * $$props.scale
378
+ },
379
+ size: {
380
+ width: $.get(currentObject).rect.size.width * $$props.scale,
381
+ height: $.get(currentObject).rect.size.height * $$props.scale
382
+ }
383
+ }));
384
+ CounterRotate($$anchor2, {
385
+ get rect() {
386
+ return $.get($0);
387
+ },
388
+ get rotation() {
389
+ return $$props.rotation;
390
+ },
391
+ children,
392
+ $$slots: { default: true }
393
+ });
394
+ }
395
+ };
396
+ $.if(node_11, ($$render) => {
397
+ if ($.get(shouldShowMenu)) $$render(consequent_8);
398
+ });
399
+ }
400
+ $.reset(div);
401
+ $.append($$anchor, div);
402
+ $.pop();
403
+ }
404
+ var root_1$9 = $.from_html(`<div></div>`);
405
+ function Highlight($$anchor, $$props) {
406
+ $.push($$props, true);
407
+ let color = $.prop($$props, "color", 3, "#FFFF00"), opacity = $.prop($$props, "opacity", 3, 0.5);
408
+ var fragment = $.comment();
409
+ var node = $.first_child(fragment);
410
+ $.each(node, 17, () => $$props.segmentRects, $.index, ($$anchor2, b) => {
411
+ var div = root_1$9();
412
+ $.attribute_effect(
413
+ div,
414
+ ($0) => ({
415
+ role: "button",
416
+ tabindex: $$props.onClick ? 0 : -1,
417
+ onpointerdown: $$props.onClick,
418
+ ontouchstart: $$props.onClick,
419
+ ...$0,
420
+ [$.STYLE]: {
421
+ position: "absolute",
422
+ left: `${($$props.rect ? $.get(b).origin.x - $$props.rect.origin.x : $.get(b).origin.x) * $$props.scale}px`,
423
+ top: `${($$props.rect ? $.get(b).origin.y - $$props.rect.origin.y : $.get(b).origin.y) * $$props.scale}px`,
424
+ width: `${$.get(b).size.width * $$props.scale}px`,
425
+ height: `${$.get(b).size.height * $$props.scale}px`,
426
+ background: color(),
427
+ opacity: opacity(),
428
+ "pointer-events": $$props.onClick ? "auto" : "none",
429
+ cursor: $$props.onClick ? "pointer" : "default",
430
+ "z-index": $$props.onClick ? 1 : void 0
431
+ }
432
+ }),
433
+ [
434
+ () => $$props.style ? Object.fromEntries(Object.entries($$props.style).map(([k, v]) => [`style:${k}`, v])) : {}
435
+ ]
436
+ );
437
+ $.append($$anchor2, div);
438
+ });
439
+ $.append($$anchor, fragment);
440
+ $.pop();
441
+ }
442
+ var root_1$8 = $.from_html(`<div><div></div></div>`);
443
+ function Underline($$anchor, $$props) {
444
+ $.push($$props, true);
445
+ let color = $.prop($$props, "color", 3, "#FFFF00"), opacity = $.prop($$props, "opacity", 3, 0.5);
446
+ const thickness = $.derived(() => 2 * $$props.scale);
447
+ var fragment = $.comment();
448
+ var node = $.first_child(fragment);
449
+ $.each(node, 17, () => $$props.segmentRects, $.index, ($$anchor2, r) => {
450
+ var div = root_1$8();
451
+ $.attribute_effect(
452
+ div,
453
+ ($0) => ({
454
+ role: "button",
455
+ tabindex: $$props.onClick ? 0 : -1,
456
+ onpointerdown: $$props.onClick,
457
+ ontouchstart: $$props.onClick,
458
+ ...$0,
459
+ [$.STYLE]: {
460
+ position: "absolute",
461
+ left: `${($$props.rect ? $.get(r).origin.x - $$props.rect.origin.x : $.get(r).origin.x) * $$props.scale}px`,
462
+ top: `${($$props.rect ? $.get(r).origin.y - $$props.rect.origin.y : $.get(r).origin.y) * $$props.scale}px`,
463
+ width: `${$.get(r).size.width * $$props.scale}px`,
464
+ height: `${$.get(r).size.height * $$props.scale}px`,
465
+ background: "transparent",
466
+ "pointer-events": $$props.onClick ? "auto" : "none",
467
+ cursor: $$props.onClick ? "pointer" : "default",
468
+ "z-index": $$props.onClick ? 1 : 0
469
+ }
470
+ }),
471
+ [
472
+ () => $$props.style ? Object.fromEntries(Object.entries($$props.style).map(([k, v]) => [`style:${k}`, v])) : {}
473
+ ]
474
+ );
475
+ var div_1 = $.child(div);
476
+ let styles;
477
+ $.reset(div);
478
+ $.template_effect(() => styles = $.set_style(div_1, "", styles, {
479
+ position: "absolute",
480
+ left: "0",
481
+ bottom: "0",
482
+ width: "100%",
483
+ height: `${$.get(thickness) ?? ""}px`,
484
+ background: color(),
485
+ opacity: opacity(),
486
+ "pointer-events": "none"
487
+ }));
488
+ $.append($$anchor2, div);
489
+ });
490
+ $.append($$anchor, fragment);
491
+ $.pop();
492
+ }
493
+ var root_1$7 = $.from_html(`<div><div></div></div>`);
494
+ function Strikeout($$anchor, $$props) {
495
+ $.push($$props, true);
496
+ let color = $.prop($$props, "color", 3, "#FFFF00"), opacity = $.prop($$props, "opacity", 3, 0.5);
497
+ const thickness = $.derived(() => 2 * $$props.scale);
498
+ var fragment = $.comment();
499
+ var node = $.first_child(fragment);
500
+ $.each(node, 17, () => $$props.segmentRects, $.index, ($$anchor2, r) => {
501
+ var div = root_1$7();
502
+ $.attribute_effect(
503
+ div,
504
+ ($0) => ({
505
+ role: "button",
506
+ tabindex: $$props.onClick ? 0 : -1,
507
+ onpointerdown: $$props.onClick,
508
+ ontouchstart: $$props.onClick,
509
+ ...$0,
510
+ [$.STYLE]: {
511
+ position: "absolute",
512
+ left: `${($$props.rect ? $.get(r).origin.x - $$props.rect.origin.x : $.get(r).origin.x) * $$props.scale}px`,
513
+ top: `${($$props.rect ? $.get(r).origin.y - $$props.rect.origin.y : $.get(r).origin.y) * $$props.scale}px`,
514
+ width: `${$.get(r).size.width * $$props.scale}px`,
515
+ height: `${$.get(r).size.height * $$props.scale}px`,
516
+ background: "transparent",
517
+ "pointer-events": $$props.onClick ? "auto" : "none",
518
+ cursor: $$props.onClick ? "pointer" : "default",
519
+ "z-index": $$props.onClick ? 1 : 0
520
+ }
521
+ }),
522
+ [
523
+ () => $$props.style ? Object.fromEntries(Object.entries($$props.style).map(([k, v]) => [`style:${k}`, v])) : {}
524
+ ]
525
+ );
526
+ var div_1 = $.child(div);
527
+ let styles;
528
+ $.reset(div);
529
+ $.template_effect(() => styles = $.set_style(div_1, "", styles, {
530
+ position: "absolute",
531
+ left: "0",
532
+ top: "50%",
533
+ width: "100%",
534
+ height: `${$.get(thickness) ?? ""}px`,
535
+ background: color(),
536
+ opacity: opacity(),
537
+ transform: "translateY(-50%)",
538
+ "pointer-events": "none"
539
+ }));
540
+ $.append($$anchor2, div);
541
+ });
542
+ $.append($$anchor, fragment);
543
+ $.pop();
544
+ }
545
+ var root_1$6 = $.from_html(`<div><div></div></div>`);
546
+ function Squiggly($$anchor, $$props) {
547
+ $.push($$props, true);
548
+ let color = $.prop($$props, "color", 3, "#FFFF00"), opacity = $.prop($$props, "opacity", 3, 0.5);
549
+ const amplitude = $.derived(() => 2 * $$props.scale);
550
+ const period = $.derived(() => 6 * $$props.scale);
551
+ const svg = $.derived(() => `<svg xmlns="http://www.w3.org/2000/svg" width="${$.get(period)}" height="${$.get(amplitude) * 2}" viewBox="0 0 ${$.get(period)} ${$.get(amplitude) * 2}">
552
+ <path d="M0 ${$.get(amplitude)} Q ${$.get(period) / 4} 0 ${$.get(period) / 2} ${$.get(amplitude)} T ${$.get(period)} ${$.get(amplitude)}"
553
+ fill="none" stroke="${color()}" stroke-width="${$.get(amplitude)}" stroke-linecap="round"/>
554
+ </svg>`);
555
+ const svgDataUri = $.derived(() => `url("data:image/svg+xml;utf8,${encodeURIComponent($.get(svg))}")`);
556
+ var fragment = $.comment();
557
+ var node = $.first_child(fragment);
558
+ $.each(node, 17, () => $$props.segmentRects, $.index, ($$anchor2, r) => {
559
+ var div = root_1$6();
560
+ $.attribute_effect(
561
+ div,
562
+ ($0) => ({
563
+ role: "button",
564
+ tabindex: $$props.onClick ? 0 : -1,
565
+ onpointerdown: $$props.onClick,
566
+ ontouchstart: $$props.onClick,
567
+ ...$0,
568
+ [$.STYLE]: {
569
+ position: "absolute",
570
+ left: `${($$props.rect ? $.get(r).origin.x - $$props.rect.origin.x : $.get(r).origin.x) * $$props.scale}px`,
571
+ top: `${($$props.rect ? $.get(r).origin.y - $$props.rect.origin.y : $.get(r).origin.y) * $$props.scale}px`,
572
+ width: `${$.get(r).size.width * $$props.scale}px`,
573
+ height: `${$.get(r).size.height * $$props.scale}px`,
574
+ background: "transparent",
575
+ "pointer-events": $$props.onClick ? "auto" : "none",
576
+ cursor: $$props.onClick ? "pointer" : "default",
577
+ "z-index": $$props.onClick ? 1 : 0
578
+ }
579
+ }),
580
+ [
581
+ () => $$props.style ? Object.fromEntries(Object.entries($$props.style).map(([k, v]) => [`style:${k}`, v])) : {}
582
+ ]
583
+ );
584
+ var div_1 = $.child(div);
585
+ let styles;
586
+ $.reset(div);
587
+ $.template_effect(() => styles = $.set_style(div_1, "", styles, {
588
+ position: "absolute",
589
+ left: "0",
590
+ bottom: "0",
591
+ width: "100%",
592
+ height: `${$.get(amplitude) * 2}px`,
593
+ "background-image": $.get(svgDataUri),
594
+ "background-repeat": "repeat-x",
595
+ "background-size": `${$.get(period) ?? ""}px ${$.get(amplitude) * 2}px`,
596
+ opacity: opacity(),
597
+ "pointer-events": "none"
598
+ }));
599
+ $.append($$anchor2, div);
600
+ });
601
+ $.append($$anchor, fragment);
602
+ $.pop();
603
+ }
604
+ var root_1$5 = $.from_svg(`<path fill="none"></path>`);
605
+ var root$9 = $.from_svg(`<svg></svg>`);
606
+ function Ink($$anchor, $$props) {
607
+ $.push($$props, true);
608
+ let color = $.prop($$props, "color", 3, "#000000"), opacity = $.prop($$props, "opacity", 3, 1);
609
+ const paths = $.derived(() => $$props.inkList.map(({ points }) => {
610
+ let d = "";
611
+ for (let i = 0; i < points.length; i++) {
612
+ const { x, y } = points[i];
613
+ const lx = x - $$props.rect.origin.x;
614
+ const ly = y - $$props.rect.origin.y;
615
+ d += (i === 0 ? "M" : "L") + lx + " " + ly + " ";
616
+ }
617
+ return d.trim();
618
+ }));
619
+ const width = $.derived(() => $$props.rect.size.width * $$props.scale);
620
+ const height = $.derived(() => $$props.rect.size.height * $$props.scale);
621
+ var svg = root$9();
622
+ let styles;
623
+ $.each(svg, 21, () => $.get(paths), $.index, ($$anchor2, d) => {
624
+ var path = root_1$5();
625
+ path.__pointerdown = function(...$$args) {
626
+ var _a;
627
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
628
+ };
629
+ path.__touchstart = function(...$$args) {
630
+ var _a;
631
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
632
+ };
633
+ let styles_1;
634
+ $.template_effect(() => {
635
+ $.set_attribute(path, "d", $.get(d));
636
+ $.set_attribute(path, "opacity", opacity());
637
+ styles_1 = $.set_style(path, "", styles_1, {
638
+ cursor: $$props.isSelected ? "move" : "pointer",
639
+ "pointer-events": $$props.isSelected ? "none" : "visibleStroke",
640
+ stroke: color(),
641
+ "stroke-width": $$props.strokeWidth,
642
+ "stroke-linecap": "round",
643
+ "stroke-linejoin": "round"
644
+ });
645
+ });
646
+ $.append($$anchor2, path);
647
+ });
648
+ $.reset(svg);
649
+ $.template_effect(() => {
650
+ styles = $.set_style(svg, "position: absolute; z-index: 2; overflow: visible; pointer-events: none;", styles, { width: `${$.get(width)}px`, height: `${$.get(height)}px` });
651
+ $.set_attribute(svg, "width", $.get(width));
652
+ $.set_attribute(svg, "height", $.get(height));
653
+ $.set_attribute(svg, "viewBox", `0 0 ${$$props.rect.size.width} ${$$props.rect.size.height}`);
654
+ });
655
+ $.append($$anchor, svg);
656
+ $.pop();
657
+ }
658
+ $.delegate(["pointerdown", "touchstart"]);
659
+ var root$8 = $.from_svg(`<svg><rect></rect></svg>`);
660
+ function Square($$anchor, $$props) {
661
+ $.push($$props, true);
662
+ let color = $.prop($$props, "color", 3, "#000000"), opacity = $.prop($$props, "opacity", 3, 1), strokeStyle = $.prop($$props, "strokeStyle", 19, () => PdfAnnotationBorderStyle.SOLID);
663
+ const $$d = $.derived(() => {
664
+ const outerW = $$props.rect.size.width;
665
+ const outerH = $$props.rect.size.height;
666
+ const innerW = Math.max(outerW - $$props.strokeWidth, 0);
667
+ const innerH = Math.max(outerH - $$props.strokeWidth, 0);
668
+ return {
669
+ width: innerW,
670
+ height: innerH,
671
+ x: $$props.strokeWidth / 2,
672
+ y: $$props.strokeWidth / 2
673
+ };
674
+ }), width = $.derived(() => $.get($$d).width), height = $.derived(() => $.get($$d).height), x = $.derived(() => $.get($$d).x), y = $.derived(() => $.get($$d).y);
675
+ const svgWidth = $.derived(() => ($.get(width) + $$props.strokeWidth) * $$props.scale);
676
+ const svgHeight = $.derived(() => ($.get(height) + $$props.strokeWidth) * $$props.scale);
677
+ const dash = $.derived(() => {
678
+ var _a;
679
+ return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
680
+ });
681
+ var svg = root$8();
682
+ let styles;
683
+ var rect_1 = $.child(svg);
684
+ rect_1.__pointerdown = function(...$$args) {
685
+ var _a;
686
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
687
+ };
688
+ rect_1.__touchstart = function(...$$args) {
689
+ var _a;
690
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
691
+ };
692
+ let styles_1;
693
+ $.reset(svg);
694
+ $.template_effect(() => {
695
+ styles = $.set_style(svg, "position: absolute; pointer-events: none; z-index: 2;", styles, {
696
+ width: `${$.get(svgWidth)}px`,
697
+ height: `${$.get(svgHeight)}px`
698
+ });
699
+ $.set_attribute(svg, "width", $.get(svgWidth));
700
+ $.set_attribute(svg, "height", $.get(svgHeight));
701
+ $.set_attribute(svg, "viewBox", `0 0 ${$.get(width) + $$props.strokeWidth} ${$.get(height) + $$props.strokeWidth}`);
702
+ $.set_attribute(rect_1, "x", $.get(x));
703
+ $.set_attribute(rect_1, "y", $.get(y));
704
+ $.set_attribute(rect_1, "width", $.get(width));
705
+ $.set_attribute(rect_1, "height", $.get(height));
706
+ $.set_attribute(rect_1, "fill", color());
707
+ $.set_attribute(rect_1, "opacity", opacity());
708
+ styles_1 = $.set_style(rect_1, "", styles_1, {
709
+ cursor: $$props.isSelected ? "move" : "pointer",
710
+ "pointer-events": $$props.isSelected ? "none" : color() === "transparent" ? "visibleStroke" : "visible",
711
+ stroke: $$props.strokeColor ?? color(),
712
+ "stroke-width": $$props.strokeWidth,
713
+ "stroke-dasharray": $.get(dash)
714
+ });
715
+ });
716
+ $.append($$anchor, svg);
717
+ $.pop();
718
+ }
719
+ $.delegate(["pointerdown", "touchstart"]);
720
+ var root$7 = $.from_svg(`<svg><ellipse></ellipse></svg>`);
721
+ function Circle($$anchor, $$props) {
722
+ $.push($$props, true);
723
+ let color = $.prop($$props, "color", 3, "#000000"), opacity = $.prop($$props, "opacity", 3, 1), strokeStyle = $.prop($$props, "strokeStyle", 19, () => PdfAnnotationBorderStyle.SOLID);
724
+ const $$d = $.derived(() => {
725
+ const outerW = $$props.rect.size.width;
726
+ const outerH = $$props.rect.size.height;
727
+ const innerW = Math.max(outerW - $$props.strokeWidth, 0);
728
+ const innerH = Math.max(outerH - $$props.strokeWidth, 0);
729
+ return {
730
+ width: outerW,
731
+ height: outerH,
732
+ // Centre of the fill sits strokeWidth/2 in from the edges
733
+ cx: $$props.strokeWidth / 2 + innerW / 2,
734
+ cy: $$props.strokeWidth / 2 + innerH / 2,
735
+ rx: innerW / 2,
736
+ ry: innerH / 2
737
+ };
738
+ }), width = $.derived(() => $.get($$d).width), height = $.derived(() => $.get($$d).height), cx = $.derived(() => $.get($$d).cx), cy = $.derived(() => $.get($$d).cy), rx = $.derived(() => $.get($$d).rx), ry = $.derived(() => $.get($$d).ry);
739
+ let svgWidth = $.derived(() => $.get(width) * $$props.scale);
740
+ let svgHeight = $.derived(() => $.get(height) * $$props.scale);
741
+ let peValue = $.derived(() => $$props.isSelected ? "none" : color() === "transparent" ? "visibleStroke" : "visible");
742
+ var svg = root$7();
743
+ let styles;
744
+ var ellipse = $.child(svg);
745
+ ellipse.__pointerdown = (e) => {
746
+ var _a;
747
+ return (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
748
+ };
749
+ ellipse.__touchstart = (e) => {
750
+ var _a;
751
+ return (_a = $$props.onClick) == null ? void 0 : _a.call($$props, e);
752
+ };
753
+ let styles_1;
754
+ $.reset(svg);
755
+ $.template_effect(
756
+ ($0) => {
757
+ $.set_attribute(svg, "svgWidth", $.get(svgWidth));
758
+ $.set_attribute(svg, "svgHeight", $.get(svgHeight));
759
+ $.set_attribute(svg, "viewBox", `0 0 ${$.get(width)} ${$.get(height)}`);
760
+ styles = $.set_style(svg, "", styles, {
761
+ position: "absolute",
762
+ width: `${$.get(svgWidth)}px`,
763
+ height: `${$.get(svgHeight)}px`,
764
+ "pointer-events": "none",
765
+ "z-index": "2"
766
+ });
767
+ $.set_attribute(ellipse, "cx", $.get(cx));
768
+ $.set_attribute(ellipse, "cy", $.get(cy));
769
+ $.set_attribute(ellipse, "rx", $.get(rx));
770
+ $.set_attribute(ellipse, "ry", $.get(ry));
771
+ $.set_attribute(ellipse, "fill", color());
772
+ $.set_attribute(ellipse, "opacity", opacity());
773
+ $.set_attribute(ellipse, "pointer-events", $.get(peValue));
774
+ $.set_attribute(ellipse, "stroke", $$props.strokeColor ?? color());
775
+ $.set_attribute(ellipse, "stroke-width", $$props.strokeWidth);
776
+ $.set_attribute(ellipse, "stroke-dasharray", $0);
777
+ styles_1 = $.set_style(ellipse, "", styles_1, { cursor: $$props.isSelected ? "move" : "pointer" });
778
+ },
779
+ [
780
+ () => {
781
+ var _a;
782
+ return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
783
+ }
784
+ ]
785
+ );
786
+ $.append($$anchor, svg);
787
+ $.pop();
788
+ }
789
+ $.delegate(["pointerdown", "touchstart"]);
790
+ var root_1$4 = $.from_svg(`<path></path>`);
791
+ var root_2$3 = $.from_svg(`<path></path>`);
792
+ var root$6 = $.from_svg(`<svg><line></line><!><!></svg>`);
793
+ function Line($$anchor, $$props) {
794
+ $.push($$props, true);
795
+ let color = $.prop($$props, "color", 3, "transparent"), opacity = $.prop($$props, "opacity", 3, 1), strokeColor = $.prop($$props, "strokeColor", 3, "#000000"), strokeStyle = $.prop($$props, "strokeStyle", 19, () => PdfAnnotationBorderStyle.SOLID);
796
+ const x1 = $.derived(() => $$props.linePoints.start.x - $$props.rect.origin.x);
797
+ const y1 = $.derived(() => $$props.linePoints.start.y - $$props.rect.origin.y);
798
+ const x2 = $.derived(() => $$props.linePoints.end.x - $$props.rect.origin.x);
799
+ const y2 = $.derived(() => $$props.linePoints.end.y - $$props.rect.origin.y);
800
+ const endings = $.derived(() => {
801
+ var _a, _b;
802
+ const angle = Math.atan2($.get(y2) - $.get(y1), $.get(x2) - $.get(x1));
803
+ return {
804
+ start: patching.createEnding((_a = $$props.lineEndings) == null ? void 0 : _a.start, $$props.strokeWidth, angle + Math.PI, $.get(x1), $.get(y1)),
805
+ end: patching.createEnding((_b = $$props.lineEndings) == null ? void 0 : _b.end, $$props.strokeWidth, angle, $.get(x2), $.get(y2))
806
+ };
807
+ });
808
+ const width = $.derived(() => $$props.rect.size.width * $$props.scale);
809
+ const height = $.derived(() => $$props.rect.size.height * $$props.scale);
810
+ const dash = $.derived(() => {
811
+ var _a;
812
+ return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
813
+ });
814
+ var svg = root$6();
815
+ let styles;
816
+ var line = $.child(svg);
817
+ line.__pointerdown = function(...$$args) {
818
+ var _a;
819
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
820
+ };
821
+ line.__touchstart = function(...$$args) {
822
+ var _a;
823
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
824
+ };
825
+ let styles_1;
826
+ var node = $.sibling(line);
827
+ {
828
+ var consequent = ($$anchor2) => {
829
+ var path = root_1$4();
830
+ path.__pointerdown = function(...$$args) {
831
+ var _a;
832
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
833
+ };
834
+ path.__touchstart = function(...$$args) {
835
+ var _a;
836
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
837
+ };
838
+ let styles_2;
839
+ $.template_effect(() => {
840
+ $.set_attribute(path, "d", $.get(endings).start.d);
841
+ $.set_attribute(path, "transform", $.get(endings).start.transform);
842
+ $.set_attribute(path, "stroke", strokeColor());
843
+ $.set_attribute(path, "fill", $.get(endings).start.filled ? color() : "none");
844
+ styles_2 = $.set_style(path, "", styles_2, {
845
+ cursor: $$props.isSelected ? "move" : "pointer",
846
+ "stroke-width": $$props.strokeWidth,
847
+ "stroke-linecap": "butt",
848
+ "pointer-events": $$props.isSelected ? "none" : $.get(endings).start.filled ? "visible" : "visibleStroke",
849
+ "stroke-dasharray": $.get(dash)
850
+ });
851
+ });
852
+ $.append($$anchor2, path);
853
+ };
854
+ $.if(node, ($$render) => {
855
+ if ($.get(endings).start) $$render(consequent);
856
+ });
857
+ }
858
+ var node_1 = $.sibling(node);
859
+ {
860
+ var consequent_1 = ($$anchor2) => {
861
+ var path_1 = root_2$3();
862
+ path_1.__pointerdown = function(...$$args) {
863
+ var _a;
864
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
865
+ };
866
+ path_1.__touchstart = function(...$$args) {
867
+ var _a;
868
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
869
+ };
870
+ let styles_3;
871
+ $.template_effect(() => {
872
+ $.set_attribute(path_1, "d", $.get(endings).end.d);
873
+ $.set_attribute(path_1, "transform", $.get(endings).end.transform);
874
+ $.set_attribute(path_1, "stroke", strokeColor());
875
+ $.set_attribute(path_1, "fill", $.get(endings).end.filled ? color() : "none");
876
+ styles_3 = $.set_style(path_1, "", styles_3, {
877
+ cursor: $$props.isSelected ? "move" : "pointer",
878
+ "stroke-width": $$props.strokeWidth,
879
+ "stroke-linecap": "butt",
880
+ "pointer-events": $$props.isSelected ? "none" : $.get(endings).end.filled ? "visible" : "visibleStroke",
881
+ "stroke-dasharray": $.get(dash)
882
+ });
883
+ });
884
+ $.append($$anchor2, path_1);
885
+ };
886
+ $.if(node_1, ($$render) => {
887
+ if ($.get(endings).end) $$render(consequent_1);
888
+ });
889
+ }
890
+ $.reset(svg);
891
+ $.template_effect(() => {
892
+ styles = $.set_style(svg, "position: absolute; z-index: 2; overflow: visible; pointer-events: none;", styles, { width: `${$.get(width)}px`, height: `${$.get(height)}px` });
893
+ $.set_attribute(svg, "width", $.get(width));
894
+ $.set_attribute(svg, "height", $.get(height));
895
+ $.set_attribute(svg, "viewBox", `0 0 ${$$props.rect.size.width} ${$$props.rect.size.height}`);
896
+ $.set_attribute(line, "x1", $.get(x1));
897
+ $.set_attribute(line, "y1", $.get(y1));
898
+ $.set_attribute(line, "x2", $.get(x2));
899
+ $.set_attribute(line, "y2", $.get(y2));
900
+ $.set_attribute(line, "opacity", opacity());
901
+ styles_1 = $.set_style(line, "", styles_1, {
902
+ cursor: $$props.isSelected ? "move" : "pointer",
903
+ "pointer-events": $$props.isSelected ? "none" : "visibleStroke",
904
+ stroke: strokeColor(),
905
+ "stroke-width": $$props.strokeWidth,
906
+ "stroke-linecap": "butt",
907
+ "stroke-dasharray": $.get(dash)
908
+ });
909
+ });
910
+ $.append($$anchor, svg);
911
+ $.pop();
912
+ }
913
+ $.delegate(["pointerdown", "touchstart"]);
914
+ var root_1$3 = $.from_svg(`<path></path>`);
915
+ var root_2$2 = $.from_svg(`<path></path>`);
916
+ var root$5 = $.from_svg(`<svg><path></path><!><!></svg>`);
917
+ function Polyline($$anchor, $$props) {
918
+ $.push($$props, true);
919
+ let color = $.prop($$props, "color", 3, "transparent"), strokeColor = $.prop($$props, "strokeColor", 3, "#000000"), opacity = $.prop($$props, "opacity", 3, 1);
920
+ const localPts = $.derived(() => $$props.vertices.map(({ x, y }) => ({ x: x - $$props.rect.origin.x, y: y - $$props.rect.origin.y })));
921
+ const pathData = $.derived(() => {
922
+ if (!$.get(localPts).length) return "";
923
+ const [first, ...rest] = $.get(localPts);
924
+ return `M ${first.x} ${first.y} ` + rest.map((p) => `L ${p.x} ${p.y} `).join("").trim();
925
+ });
926
+ const endings = $.derived(() => {
927
+ var _a, _b;
928
+ if ($.get(localPts).length < 2) return { start: null, end: null };
929
+ const toAngle = (a, b) => Math.atan2(b.y - a.y, b.x - a.x);
930
+ const startRad = toAngle($.get(
931
+ localPts
932
+ // FROM first TO second
933
+ )[0], $.get(localPts)[1]);
934
+ const endRad = toAngle($.get(
935
+ localPts
936
+ // FROM second-to-last TO last
937
+ )[$.get(localPts).length - 2], $.get(localPts)[$.get(localPts).length - 1]);
938
+ const start = patching.createEnding(
939
+ (_a = $$props.lineEndings) == null ? void 0 : _a.start,
940
+ $$props.strokeWidth,
941
+ startRad + Math.PI,
942
+ // tip outward from start
943
+ $.get(localPts)[0].x,
944
+ $.get(localPts)[0].y
945
+ );
946
+ const end = patching.createEnding(
947
+ (_b = $$props.lineEndings) == null ? void 0 : _b.end,
948
+ $$props.strokeWidth,
949
+ endRad,
950
+ // tip in line direction
951
+ $.get(localPts)[$.get(localPts).length - 1].x,
952
+ $.get(localPts)[$.get(localPts).length - 1].y
953
+ );
954
+ return { start, end };
955
+ });
956
+ const width = $.derived(() => $$props.rect.size.width * $$props.scale);
957
+ const height = $.derived(() => $$props.rect.size.height * $$props.scale);
958
+ var svg = root$5();
959
+ let styles;
960
+ var path = $.child(svg);
961
+ path.__pointerdown = function(...$$args) {
962
+ var _a;
963
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
964
+ };
965
+ path.__touchstart = function(...$$args) {
966
+ var _a;
967
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
968
+ };
969
+ let styles_1;
970
+ var node = $.sibling(path);
971
+ {
972
+ var consequent = ($$anchor2) => {
973
+ var path_1 = root_1$3();
974
+ path_1.__pointerdown = function(...$$args) {
975
+ var _a;
976
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
977
+ };
978
+ path_1.__touchstart = function(...$$args) {
979
+ var _a;
980
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
981
+ };
982
+ let styles_2;
983
+ $.template_effect(() => {
984
+ $.set_attribute(path_1, "d", $.get(endings).start.d);
985
+ $.set_attribute(path_1, "transform", $.get(endings).start.transform);
986
+ $.set_attribute(path_1, "stroke", strokeColor());
987
+ $.set_attribute(path_1, "fill", $.get(endings).start.filled ? color() : "none");
988
+ styles_2 = $.set_style(path_1, "", styles_2, {
989
+ cursor: $$props.isSelected ? "move" : "pointer",
990
+ "stroke-width": $$props.strokeWidth,
991
+ "pointer-events": $$props.isSelected ? "none" : $.get(endings).start.filled ? "visible" : "visibleStroke",
992
+ "stroke-linecap": "butt"
993
+ });
994
+ });
995
+ $.append($$anchor2, path_1);
996
+ };
997
+ $.if(node, ($$render) => {
998
+ if ($.get(endings).start) $$render(consequent);
999
+ });
1000
+ }
1001
+ var node_1 = $.sibling(node);
1002
+ {
1003
+ var consequent_1 = ($$anchor2) => {
1004
+ var path_2 = root_2$2();
1005
+ path_2.__pointerdown = function(...$$args) {
1006
+ var _a;
1007
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1008
+ };
1009
+ path_2.__touchstart = function(...$$args) {
1010
+ var _a;
1011
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1012
+ };
1013
+ let styles_3;
1014
+ $.template_effect(() => {
1015
+ $.set_attribute(path_2, "d", $.get(endings).end.d);
1016
+ $.set_attribute(path_2, "transform", $.get(endings).end.transform);
1017
+ $.set_attribute(path_2, "stroke", strokeColor());
1018
+ $.set_attribute(path_2, "fill", $.get(endings).end.filled ? color() : "none");
1019
+ styles_3 = $.set_style(path_2, "", styles_3, {
1020
+ cursor: $$props.isSelected ? "move" : "pointer",
1021
+ "stroke-width": $$props.strokeWidth,
1022
+ "pointer-events": $$props.isSelected ? "none" : $.get(endings).end.filled ? "visible" : "visibleStroke",
1023
+ "stroke-linecap": "butt"
1024
+ });
1025
+ });
1026
+ $.append($$anchor2, path_2);
1027
+ };
1028
+ $.if(node_1, ($$render) => {
1029
+ if ($.get(endings).end) $$render(consequent_1);
1030
+ });
1031
+ }
1032
+ $.reset(svg);
1033
+ $.template_effect(() => {
1034
+ styles = $.set_style(svg, "position: absolute; width: var(--w); height: var(--h); pointer-events: none; z-index: 2; overflow: visible;", styles, { "--w": `${$.get(width)}px`, "--h": `${$.get(height)}px` });
1035
+ $.set_attribute(svg, "width", $.get(width));
1036
+ $.set_attribute(svg, "height", $.get(height));
1037
+ $.set_attribute(svg, "viewBox", `0 0 ${$$props.rect.size.width} ${$$props.rect.size.height}`);
1038
+ $.set_attribute(path, "d", $.get(pathData));
1039
+ $.set_attribute(path, "opacity", opacity());
1040
+ styles_1 = $.set_style(path, "", styles_1, {
1041
+ fill: "none",
1042
+ stroke: strokeColor() ?? color(),
1043
+ "stroke-width": $$props.strokeWidth,
1044
+ cursor: $$props.isSelected ? "move" : "pointer",
1045
+ "pointer-events": $$props.isSelected ? "none" : "visibleStroke",
1046
+ "stroke-linecap": "butt",
1047
+ "stroke-linejoin": "miter"
1048
+ });
1049
+ });
1050
+ $.append($$anchor, svg);
1051
+ $.pop();
1052
+ }
1053
+ $.delegate(["pointerdown", "touchstart"]);
1054
+ var root_1$2 = $.from_svg(`<path fill="none"></path>`);
1055
+ var root_2$1 = $.from_svg(`<rect></rect>`);
1056
+ var root$4 = $.from_svg(`<svg><path></path><!><!></svg>`);
1057
+ function Polygon($$anchor, $$props) {
1058
+ $.push($$props, true);
1059
+ let color = $.prop($$props, "color", 3, "transparent"), strokeColor = $.prop($$props, "strokeColor", 3, "#000000"), opacity = $.prop($$props, "opacity", 3, 1), strokeStyle = $.prop($$props, "strokeStyle", 19, () => PdfAnnotationBorderStyle.SOLID), handleSize = $.prop($$props, "handleSize", 3, 14);
1060
+ const allPoints = $.derived(() => $$props.currentVertex ? [...$$props.vertices, $$props.currentVertex] : $$props.vertices);
1061
+ const localPts = $.derived(() => $.get(allPoints).map(({ x, y }) => ({ x: x - $$props.rect.origin.x, y: y - $$props.rect.origin.y })));
1062
+ const pathData = $.derived(() => {
1063
+ if (!$.get(localPts).length) return "";
1064
+ const [first, ...rest] = $.get(localPts);
1065
+ const isPreview = !!$$props.currentVertex;
1066
+ return (`M ${first.x} ${first.y} ` + rest.map((p) => `L ${p.x} ${p.y}`).join(" ") + (isPreview ? "" : " Z")).trim();
1067
+ });
1068
+ const isPreviewing = $.derived(() => !!$$props.currentVertex && $$props.vertices.length > 0);
1069
+ const width = $.derived(() => $$props.rect.size.width * $$props.scale);
1070
+ const height = $.derived(() => $$props.rect.size.height * $$props.scale);
1071
+ const dash = $.derived(() => {
1072
+ var _a;
1073
+ return strokeStyle() === PdfAnnotationBorderStyle.DASHED ? (_a = $$props.strokeDashArray) == null ? void 0 : _a.join(",") : void 0;
1074
+ });
1075
+ var svg = root$4();
1076
+ let styles;
1077
+ var path = $.child(svg);
1078
+ path.__pointerdown = function(...$$args) {
1079
+ var _a;
1080
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1081
+ };
1082
+ path.__touchstart = function(...$$args) {
1083
+ var _a;
1084
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1085
+ };
1086
+ let styles_1;
1087
+ var node = $.sibling(path);
1088
+ {
1089
+ var consequent = ($$anchor2) => {
1090
+ var path_1 = root_1$2();
1091
+ let styles_2;
1092
+ $.template_effect(() => {
1093
+ $.set_attribute(path_1, "d", `M ${$.get(localPts)[$.get(localPts).length - 1].x} ${$.get(localPts)[$.get(localPts).length - 1].y} L ${$.get(localPts)[0].x} ${$.get(localPts)[0].y}`);
1094
+ styles_2 = $.set_style(path_1, "", styles_2, {
1095
+ stroke: strokeColor(),
1096
+ "stroke-width": $$props.strokeWidth,
1097
+ "stroke-dasharray": "4,4",
1098
+ opacity: 0.7
1099
+ });
1100
+ });
1101
+ $.append($$anchor2, path_1);
1102
+ };
1103
+ $.if(node, ($$render) => {
1104
+ if ($.get(isPreviewing) && $$props.vertices.length > 1) $$render(consequent);
1105
+ });
1106
+ }
1107
+ var node_1 = $.sibling(node);
1108
+ {
1109
+ var consequent_1 = ($$anchor2) => {
1110
+ var rect_1 = root_2$1();
1111
+ $.set_attribute(rect_1, "opacity", 0.4);
1112
+ $.template_effect(() => {
1113
+ $.set_attribute(rect_1, "x", $.get(localPts)[0].x - handleSize() / $$props.scale / 2);
1114
+ $.set_attribute(rect_1, "y", $.get(localPts)[0].y - handleSize() / $$props.scale / 2);
1115
+ $.set_attribute(rect_1, "width", handleSize() / $$props.scale);
1116
+ $.set_attribute(rect_1, "height", handleSize() / $$props.scale);
1117
+ $.set_attribute(rect_1, "fill", strokeColor());
1118
+ $.set_attribute(rect_1, "stroke", strokeColor());
1119
+ $.set_attribute(rect_1, "stroke-width", $$props.strokeWidth / 2);
1120
+ });
1121
+ $.append($$anchor2, rect_1);
1122
+ };
1123
+ $.if(node_1, ($$render) => {
1124
+ if ($.get(isPreviewing) && $$props.vertices.length >= 2) $$render(consequent_1);
1125
+ });
1126
+ }
1127
+ $.reset(svg);
1128
+ $.template_effect(() => {
1129
+ styles = $.set_style(svg, "position: absolute; z-index: 2; overflow: visible; pointer-events: none;", styles, { width: `${$.get(width)}px`, height: `${$.get(height)}px` });
1130
+ $.set_attribute(svg, "width", $.get(width));
1131
+ $.set_attribute(svg, "height", $.get(height));
1132
+ $.set_attribute(svg, "viewBox", `0 0 ${$$props.rect.size.width} ${$$props.rect.size.height}`);
1133
+ $.set_attribute(path, "d", $.get(pathData));
1134
+ $.set_attribute(path, "opacity", opacity());
1135
+ styles_1 = $.set_style(path, "", styles_1, {
1136
+ fill: $$props.currentVertex ? "none" : color(),
1137
+ stroke: strokeColor() ?? color(),
1138
+ "stroke-width": $$props.strokeWidth,
1139
+ cursor: $$props.isSelected ? "move" : "pointer",
1140
+ "pointer-events": $$props.isSelected ? "none" : color() === "transparent" ? "visibleStroke" : "visible",
1141
+ "stroke-linecap": "butt",
1142
+ "stroke-linejoin": "miter",
1143
+ "stroke-dasharray": $.get(dash)
1144
+ });
1145
+ });
1146
+ $.append($$anchor, svg);
1147
+ $.pop();
1148
+ }
1149
+ $.delegate(["pointerdown", "touchstart"]);
1150
+ var root$3 = $.from_html(`<div><span tabindex="0"> </span></div>`);
1151
+ function FreeText($$anchor, $$props) {
1152
+ $.push($$props, true);
1153
+ const annotationCapability = useAnnotationCapability();
1154
+ const annotationProvides = $.derived(() => annotationCapability.provides ? annotationCapability.provides.forDocument($$props.documentId) : null);
1155
+ let editorRef = null;
1156
+ let isIOS = $.state(false);
1157
+ $.user_effect(() => {
1158
+ var _a;
1159
+ if (!$$props.isEditing || !editorRef) return;
1160
+ editorRef.focus();
1161
+ const selection = (_a = window.getSelection) == null ? void 0 : _a.call(window);
1162
+ if (!selection) return;
1163
+ const range = document.createRange();
1164
+ range.selectNodeContents(editorRef);
1165
+ range.collapse(false);
1166
+ selection.removeAllRanges();
1167
+ selection.addRange(range);
1168
+ });
1169
+ $.user_pre_effect(() => {
1170
+ try {
1171
+ const nav = navigator;
1172
+ const ios = /iPad|iPhone|iPod/.test(navigator.userAgent) || navigator.platform === "MacIntel" && (nav == null ? void 0 : nav.maxTouchPoints) > 1;
1173
+ $.set(isIOS, ios, true);
1174
+ } catch {
1175
+ $.set(isIOS, false);
1176
+ }
1177
+ });
1178
+ function handleBlur() {
1179
+ if (!$.get(annotationProvides) || !editorRef) return;
1180
+ $.get(annotationProvides).updateAnnotation($$props.pageIndex, $$props.annotation.object.id, { contents: editorRef.innerText });
1181
+ }
1182
+ const computedFontPx = $.derived(() => $$props.annotation.object.fontSize * $$props.scale);
1183
+ const MIN_IOS_FOCUS_FONT_PX = 16;
1184
+ const needsComp = $.derived(() => $.get(isIOS) && $$props.isEditing && $.get(computedFontPx) > 0 && $.get(computedFontPx) < MIN_IOS_FOCUS_FONT_PX);
1185
+ const adjustedFontPx = $.derived(() => $.get(needsComp) ? MIN_IOS_FOCUS_FONT_PX : $.get(computedFontPx));
1186
+ const scaleComp = $.derived(() => $.get(needsComp) ? $.get(computedFontPx) / MIN_IOS_FOCUS_FONT_PX : 1);
1187
+ const invScalePercent = $.derived(() => $.get(needsComp) ? 100 / $.get(scaleComp) : 100);
1188
+ const outerW = $.derived(() => $$props.annotation.object.rect.size.width * $$props.scale);
1189
+ const outerH = $.derived(() => $$props.annotation.object.rect.size.height * $$props.scale);
1190
+ const justify = $.derived(() => $$props.annotation.object.verticalAlign === PdfVerticalAlignment.Top ? "flex-start" : $$props.annotation.object.verticalAlign === PdfVerticalAlignment.Middle ? "center" : "flex-end");
1191
+ var div = root$3();
1192
+ div.__pointerdown = function(...$$args) {
1193
+ var _a;
1194
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1195
+ };
1196
+ div.__touchstart = function(...$$args) {
1197
+ var _a;
1198
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1199
+ };
1200
+ let styles;
1201
+ var span = $.child(div);
1202
+ let styles_1;
1203
+ var text = $.child(span, true);
1204
+ $.reset(span);
1205
+ $.bind_this(span, ($$value) => editorRef = $$value, () => editorRef);
1206
+ $.reset(div);
1207
+ $.template_effect(
1208
+ ($0) => {
1209
+ styles = $.set_style(div, "", styles, {
1210
+ position: "absolute",
1211
+ width: `${$.get(outerW)}px`,
1212
+ height: `${$.get(outerH)}px`,
1213
+ "z-index": 2,
1214
+ cursor: $$props.isSelected && !$$props.isEditing ? "move" : "default",
1215
+ "pointer-events": $$props.isSelected && !$$props.isEditing ? "none" : "auto"
1216
+ });
1217
+ $.set_attribute(span, "contenteditable", $$props.isEditing);
1218
+ styles_1 = $.set_style(span, "", styles_1, $0);
1219
+ $.set_text(text, $$props.annotation.object.contents);
1220
+ },
1221
+ [
1222
+ () => ({
1223
+ display: "flex",
1224
+ "flex-direction": "column",
1225
+ "justify-content": $.get(justify),
1226
+ color: $$props.annotation.object.fontColor,
1227
+ "font-size": `${$.get(adjustedFontPx)}px`,
1228
+ "font-family": standardFontCss($$props.annotation.object.fontFamily),
1229
+ "text-align": textAlignmentToCss($$props.annotation.object.textAlign),
1230
+ "background-color": $$props.annotation.object.backgroundColor,
1231
+ opacity: $$props.annotation.object.opacity,
1232
+ width: $.get(needsComp) ? `${$.get(invScalePercent)}%` : "100%",
1233
+ height: $.get(needsComp) ? `${$.get(invScalePercent)}%` : "100%",
1234
+ "line-height": "1.18",
1235
+ overflow: "hidden",
1236
+ cursor: $$props.isEditing ? "text" : "pointer",
1237
+ outline: "none",
1238
+ transform: $.get(needsComp) ? `scale(${$.get(scaleComp)})` : void 0,
1239
+ "transform-origin": "top left"
1240
+ })
1241
+ ]
1242
+ );
1243
+ $.event("blur", span, handleBlur);
1244
+ $.append($$anchor, div);
1245
+ $.pop();
1246
+ }
1247
+ $.delegate(["pointerdown", "touchstart"]);
1248
+ var root_1$1 = $.from_html(`<img/>`);
1249
+ function RenderAnnotation($$anchor, $$props) {
1250
+ $.push($$props, true);
1251
+ let scaleFactor = $.prop($$props, "scaleFactor", 3, 1), restProps = $.rest_props($$props, [
1252
+ "$$slots",
1253
+ "$$events",
1254
+ "$$legacy",
1255
+ "documentId",
1256
+ "pageIndex",
1257
+ "annotation",
1258
+ "scaleFactor",
1259
+ "style"
1260
+ ]);
1261
+ const annotationCapability = useAnnotationCapability();
1262
+ let imageUrl = $.state(null);
1263
+ let urlRef = null;
1264
+ const $$d = $.derived(() => $$props.annotation.rect.size);
1265
+ $.derived(() => $.get($$d).width);
1266
+ $.derived(() => $.get($$d).height);
1267
+ const annotationProvides = $.derived(() => annotationCapability.provides ? annotationCapability.provides.forDocument($$props.documentId) : null);
1268
+ $.user_effect(() => {
1269
+ if ($.get(annotationProvides)) {
1270
+ const task = $.get(annotationProvides).renderAnnotation({
1271
+ pageIndex: $$props.pageIndex,
1272
+ annotation: deepToRaw($$props.annotation),
1273
+ options: { scaleFactor: scaleFactor(), dpr: window.devicePixelRatio }
1274
+ });
1275
+ task.wait(
1276
+ (blob) => {
1277
+ const url = URL.createObjectURL(blob);
1278
+ $.set(imageUrl, url, true);
1279
+ urlRef = url;
1280
+ },
1281
+ ignore
1282
+ );
1283
+ return () => {
1284
+ if (urlRef) {
1285
+ URL.revokeObjectURL(urlRef);
1286
+ urlRef = null;
1287
+ } else {
1288
+ task.abort({
1289
+ code: PdfErrorCode.Cancelled,
1290
+ message: "canceled render task"
1291
+ });
1292
+ }
1293
+ };
1294
+ }
1295
+ });
1296
+ function handleImageLoad() {
1297
+ if (urlRef) {
1298
+ URL.revokeObjectURL(urlRef);
1299
+ urlRef = null;
1300
+ }
1301
+ }
1302
+ var fragment = $.comment();
1303
+ var node = $.first_child(fragment);
1304
+ {
1305
+ var consequent = ($$anchor2) => {
1306
+ var img = root_1$1();
1307
+ $.attribute_effect(img, () => ({
1308
+ alt: "",
1309
+ src: $.get(imageUrl),
1310
+ onload: handleImageLoad,
1311
+ ...restProps,
1312
+ style: $$props.style,
1313
+ [$.STYLE]: { width: "100%", height: "100%", display: "block" }
1314
+ }));
1315
+ $.replay_events(img);
1316
+ $.append($$anchor2, img);
1317
+ };
1318
+ $.if(node, ($$render) => {
1319
+ if ($.get(imageUrl)) $$render(consequent);
1320
+ });
1321
+ }
1322
+ $.append($$anchor, fragment);
1323
+ $.pop();
1324
+ }
1325
+ var root$2 = $.from_html(`<div><!></div>`);
1326
+ function Stamp($$anchor, $$props) {
1327
+ $.push($$props, true);
1328
+ let annotationProp = $.derived(() => ({
1329
+ ...$$props.annotation.object,
1330
+ id: $$props.annotation.object.id
1331
+ }));
1332
+ var div = root$2();
1333
+ let styles;
1334
+ div.__pointerdown = function(...$$args) {
1335
+ var _a;
1336
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1337
+ };
1338
+ div.__touchstart = function(...$$args) {
1339
+ var _a;
1340
+ (_a = $$props.onClick) == null ? void 0 : _a.apply(this, $$args);
1341
+ };
1342
+ var node = $.child(div);
1343
+ RenderAnnotation(node, {
1344
+ get documentId() {
1345
+ return $$props.documentId;
1346
+ },
1347
+ get pageIndex() {
1348
+ return $$props.pageIndex;
1349
+ },
1350
+ get annotation() {
1351
+ return $.get(annotationProp);
1352
+ },
1353
+ get scaleFactor() {
1354
+ return $$props.scale;
1355
+ }
1356
+ });
1357
+ $.reset(div);
1358
+ $.template_effect(() => styles = $.set_style(div, "position: absolute; width: 100%; height: 100%; z-index: 2;", styles, {
1359
+ "pointer-events": $$props.isSelected ? "none" : "auto",
1360
+ cursor: "pointer"
1361
+ }));
1362
+ $.append($$anchor, div);
1363
+ $.pop();
1364
+ }
1365
+ $.delegate(["pointerdown", "touchstart"]);
1366
+ function Annotations($$anchor, $$props) {
1367
+ $.push($$props, true);
1368
+ let annotationsProps = $.rest_props($$props, ["$$slots", "$$events", "$$legacy"]);
1369
+ const annotationCapability = useAnnotationCapability();
1370
+ const selectionCapability = useSelectionCapability();
1371
+ const pointerHandlers = usePointerHandlers({ documentId: $$props.documentId, pageIndex: $$props.pageIndex });
1372
+ let annotations = $.state($.proxy([]));
1373
+ let selectionState = $.state(null);
1374
+ let editingId = $.state(null);
1375
+ const annotationProvides = $.derived(() => annotationCapability.provides ? annotationCapability.provides.forDocument($$props.documentId) : null);
1376
+ $.user_effect(() => {
1377
+ if (!$.get(annotationProvides)) return;
1378
+ const currentState = $.get(annotationProvides).getState();
1379
+ $.set(annotations, getAnnotationsByPageIndex(currentState, $$props.pageIndex), true);
1380
+ $.set(selectionState, getSelectedAnnotationByPageIndex(currentState, $$props.pageIndex), true);
1381
+ const off = $.get(annotationProvides).onStateChange((state) => {
1382
+ $.set(annotations, getAnnotationsByPageIndex(state, $$props.pageIndex), true);
1383
+ $.set(selectionState, getSelectedAnnotationByPageIndex(state, $$props.pageIndex), true);
1384
+ });
1385
+ return () => off == null ? void 0 : off();
1386
+ });
1387
+ const handlers = {
1388
+ onPointerDown: (_, pe) => {
1389
+ if (pe.target === pe.currentTarget && $.get(annotationProvides)) {
1390
+ $.get(annotationProvides).deselectAnnotation();
1391
+ $.set(editingId, null);
1392
+ }
1393
+ }
1394
+ };
1395
+ $.user_effect(() => {
1396
+ return pointerHandlers.register(handlers, { documentId: $$props.documentId });
1397
+ });
1398
+ function handleClick(e, annotation) {
1399
+ e.stopPropagation();
1400
+ if ($.get(annotationProvides) && selectionCapability.provides) {
1401
+ $.get(annotationProvides).selectAnnotation($$props.pageIndex, annotation.object.id);
1402
+ selectionCapability.provides.clear();
1403
+ if (annotation.object.id !== $.get(editingId)) {
1404
+ $.set(editingId, null);
1405
+ }
1406
+ }
1407
+ }
1408
+ var fragment = $.comment();
1409
+ var node = $.first_child(fragment);
1410
+ $.each(node, 17, () => $.get(annotations), (annotation) => annotation.object.id, ($$anchor2, annotation) => {
1411
+ const isSelected = $.derived(() => {
1412
+ var _a;
1413
+ return ((_a = $.get(selectionState)) == null ? void 0 : _a.object.id) === $.get(annotation).object.id;
1414
+ });
1415
+ const isEditing = $.derived(() => $.get(editingId) === $.get(annotation).object.id);
1416
+ const tool = $.derived(() => {
1417
+ var _a;
1418
+ return (_a = $.get(annotationProvides)) == null ? void 0 : _a.findToolForAnnotation($.get(annotation).object);
1419
+ });
1420
+ const mixBlendMode = $.derived(() => blendModeToCss($.get(annotation).object.blendMode ?? PdfBlendMode.Normal));
1421
+ var fragment_1 = $.comment();
1422
+ var node_1 = $.first_child(fragment_1);
1423
+ {
1424
+ var consequent = ($$anchor3) => {
1425
+ {
1426
+ const children = ($$anchor4, obj = $.noop) => {
1427
+ Ink($$anchor4, $.spread_props(obj, {
1428
+ get isSelected() {
1429
+ return $.get(isSelected);
1430
+ },
1431
+ get scale() {
1432
+ return $$props.scale;
1433
+ },
1434
+ onClick: (e) => handleClick(e, $.get(annotation))
1435
+ }));
1436
+ };
1437
+ let $0 = $.derived(() => {
1438
+ var _a;
1439
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1440
+ });
1441
+ let $1 = $.derived(() => {
1442
+ var _a;
1443
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? true;
1444
+ });
1445
+ let $2 = $.derived(() => {
1446
+ var _a;
1447
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1448
+ });
1449
+ AnnotationContainer($$anchor3, $.spread_props(
1450
+ {
1451
+ get trackedAnnotation() {
1452
+ return $.get(annotation);
1453
+ },
1454
+ get isSelected() {
1455
+ return $.get(isSelected);
1456
+ },
1457
+ get isDraggable() {
1458
+ return $.get($0);
1459
+ },
1460
+ get isResizable() {
1461
+ return $.get($1);
1462
+ },
1463
+ get lockAspectRatio() {
1464
+ return $.get($2);
1465
+ },
1466
+ get selectionMenu() {
1467
+ return $$props.selectionMenu;
1468
+ },
1469
+ get selectionMenuSnippet() {
1470
+ return $$props.selectionMenuSnippet;
1471
+ },
1472
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1473
+ get style() {
1474
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1475
+ }
1476
+ },
1477
+ () => annotationsProps,
1478
+ { children, $$slots: { default: true } }
1479
+ ));
1480
+ }
1481
+ };
1482
+ var alternate_10 = ($$anchor3) => {
1483
+ var fragment_4 = $.comment();
1484
+ var node_2 = $.first_child(fragment_4);
1485
+ {
1486
+ var consequent_1 = ($$anchor4) => {
1487
+ {
1488
+ const children = ($$anchor5, obj = $.noop) => {
1489
+ Square($$anchor5, $.spread_props(obj, {
1490
+ get isSelected() {
1491
+ return $.get(isSelected);
1492
+ },
1493
+ get scale() {
1494
+ return $$props.scale;
1495
+ },
1496
+ onClick: (e) => handleClick(e, $.get(annotation))
1497
+ }));
1498
+ };
1499
+ let $0 = $.derived(() => {
1500
+ var _a;
1501
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1502
+ });
1503
+ let $1 = $.derived(() => {
1504
+ var _a;
1505
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? true;
1506
+ });
1507
+ let $2 = $.derived(() => {
1508
+ var _a;
1509
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1510
+ });
1511
+ AnnotationContainer($$anchor4, $.spread_props(
1512
+ {
1513
+ get trackedAnnotation() {
1514
+ return $.get(annotation);
1515
+ },
1516
+ get isSelected() {
1517
+ return $.get(isSelected);
1518
+ },
1519
+ get isDraggable() {
1520
+ return $.get($0);
1521
+ },
1522
+ get isResizable() {
1523
+ return $.get($1);
1524
+ },
1525
+ get lockAspectRatio() {
1526
+ return $.get($2);
1527
+ },
1528
+ get selectionMenu() {
1529
+ return $$props.selectionMenu;
1530
+ },
1531
+ get selectionMenuSnippet() {
1532
+ return $$props.selectionMenuSnippet;
1533
+ },
1534
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1535
+ get style() {
1536
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1537
+ }
1538
+ },
1539
+ () => annotationsProps,
1540
+ { children, $$slots: { default: true } }
1541
+ ));
1542
+ }
1543
+ };
1544
+ var alternate_9 = ($$anchor4) => {
1545
+ var fragment_7 = $.comment();
1546
+ var node_3 = $.first_child(fragment_7);
1547
+ {
1548
+ var consequent_2 = ($$anchor5) => {
1549
+ {
1550
+ const children = ($$anchor6, obj = $.noop) => {
1551
+ Circle($$anchor6, $.spread_props(obj, {
1552
+ get isSelected() {
1553
+ return $.get(isSelected);
1554
+ },
1555
+ get scale() {
1556
+ return $$props.scale;
1557
+ },
1558
+ onClick: (e) => handleClick(e, $.get(annotation))
1559
+ }));
1560
+ };
1561
+ let $0 = $.derived(() => {
1562
+ var _a;
1563
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1564
+ });
1565
+ let $1 = $.derived(() => {
1566
+ var _a;
1567
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? true;
1568
+ });
1569
+ let $2 = $.derived(() => {
1570
+ var _a;
1571
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1572
+ });
1573
+ AnnotationContainer($$anchor5, $.spread_props(
1574
+ {
1575
+ get trackedAnnotation() {
1576
+ return $.get(annotation);
1577
+ },
1578
+ get isSelected() {
1579
+ return $.get(isSelected);
1580
+ },
1581
+ get isDraggable() {
1582
+ return $.get($0);
1583
+ },
1584
+ get isResizable() {
1585
+ return $.get($1);
1586
+ },
1587
+ get lockAspectRatio() {
1588
+ return $.get($2);
1589
+ },
1590
+ get selectionMenu() {
1591
+ return $$props.selectionMenu;
1592
+ },
1593
+ get selectionMenuSnippet() {
1594
+ return $$props.selectionMenuSnippet;
1595
+ },
1596
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1597
+ get style() {
1598
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1599
+ }
1600
+ },
1601
+ () => annotationsProps,
1602
+ { children, $$slots: { default: true } }
1603
+ ));
1604
+ }
1605
+ };
1606
+ var alternate_8 = ($$anchor5) => {
1607
+ var fragment_10 = $.comment();
1608
+ var node_4 = $.first_child(fragment_10);
1609
+ {
1610
+ var consequent_3 = ($$anchor6) => {
1611
+ {
1612
+ const children = ($$anchor7, obj = $.noop) => {
1613
+ Underline($$anchor7, $.spread_props(obj, {
1614
+ get scale() {
1615
+ return $$props.scale;
1616
+ },
1617
+ onClick: (e) => handleClick(e, $.get(annotation))
1618
+ }));
1619
+ };
1620
+ let $0 = $.derived(() => {
1621
+ var _a;
1622
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? false;
1623
+ });
1624
+ let $1 = $.derived(() => {
1625
+ var _a;
1626
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1627
+ });
1628
+ let $2 = $.derived(() => {
1629
+ var _a;
1630
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1631
+ });
1632
+ AnnotationContainer($$anchor6, $.spread_props(
1633
+ {
1634
+ get trackedAnnotation() {
1635
+ return $.get(annotation);
1636
+ },
1637
+ get isSelected() {
1638
+ return $.get(isSelected);
1639
+ },
1640
+ get isDraggable() {
1641
+ return $.get($0);
1642
+ },
1643
+ get isResizable() {
1644
+ return $.get($1);
1645
+ },
1646
+ get lockAspectRatio() {
1647
+ return $.get($2);
1648
+ },
1649
+ get selectionMenu() {
1650
+ return $$props.selectionMenu;
1651
+ },
1652
+ get selectionMenuSnippet() {
1653
+ return $$props.selectionMenuSnippet;
1654
+ },
1655
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1656
+ zIndex: 0,
1657
+ get style() {
1658
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1659
+ }
1660
+ },
1661
+ () => annotationsProps,
1662
+ { children, $$slots: { default: true } }
1663
+ ));
1664
+ }
1665
+ };
1666
+ var alternate_7 = ($$anchor6) => {
1667
+ var fragment_13 = $.comment();
1668
+ var node_5 = $.first_child(fragment_13);
1669
+ {
1670
+ var consequent_4 = ($$anchor7) => {
1671
+ {
1672
+ const children = ($$anchor8, obj = $.noop) => {
1673
+ Strikeout($$anchor8, $.spread_props(obj, {
1674
+ get scale() {
1675
+ return $$props.scale;
1676
+ },
1677
+ onClick: (e) => handleClick(e, $.get(annotation))
1678
+ }));
1679
+ };
1680
+ let $0 = $.derived(() => {
1681
+ var _a;
1682
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? false;
1683
+ });
1684
+ let $1 = $.derived(() => {
1685
+ var _a;
1686
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1687
+ });
1688
+ let $2 = $.derived(() => {
1689
+ var _a;
1690
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1691
+ });
1692
+ AnnotationContainer($$anchor7, $.spread_props(
1693
+ {
1694
+ get trackedAnnotation() {
1695
+ return $.get(annotation);
1696
+ },
1697
+ get isSelected() {
1698
+ return $.get(isSelected);
1699
+ },
1700
+ get isDraggable() {
1701
+ return $.get($0);
1702
+ },
1703
+ get isResizable() {
1704
+ return $.get($1);
1705
+ },
1706
+ get lockAspectRatio() {
1707
+ return $.get($2);
1708
+ },
1709
+ get selectionMenu() {
1710
+ return $$props.selectionMenu;
1711
+ },
1712
+ get selectionMenuSnippet() {
1713
+ return $$props.selectionMenuSnippet;
1714
+ },
1715
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1716
+ zIndex: 0,
1717
+ get style() {
1718
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1719
+ }
1720
+ },
1721
+ () => annotationsProps,
1722
+ { children, $$slots: { default: true } }
1723
+ ));
1724
+ }
1725
+ };
1726
+ var alternate_6 = ($$anchor7) => {
1727
+ var fragment_16 = $.comment();
1728
+ var node_6 = $.first_child(fragment_16);
1729
+ {
1730
+ var consequent_5 = ($$anchor8) => {
1731
+ {
1732
+ const children = ($$anchor9, obj = $.noop) => {
1733
+ Squiggly($$anchor9, $.spread_props(obj, {
1734
+ get scale() {
1735
+ return $$props.scale;
1736
+ },
1737
+ onClick: (e) => handleClick(e, $.get(annotation))
1738
+ }));
1739
+ };
1740
+ let $0 = $.derived(() => {
1741
+ var _a;
1742
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? false;
1743
+ });
1744
+ let $1 = $.derived(() => {
1745
+ var _a;
1746
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1747
+ });
1748
+ let $2 = $.derived(() => {
1749
+ var _a;
1750
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1751
+ });
1752
+ AnnotationContainer($$anchor8, $.spread_props(
1753
+ {
1754
+ get trackedAnnotation() {
1755
+ return $.get(annotation);
1756
+ },
1757
+ get isSelected() {
1758
+ return $.get(isSelected);
1759
+ },
1760
+ get isDraggable() {
1761
+ return $.get($0);
1762
+ },
1763
+ get isResizable() {
1764
+ return $.get($1);
1765
+ },
1766
+ get lockAspectRatio() {
1767
+ return $.get($2);
1768
+ },
1769
+ get selectionMenu() {
1770
+ return $$props.selectionMenu;
1771
+ },
1772
+ get selectionMenuSnippet() {
1773
+ return $$props.selectionMenuSnippet;
1774
+ },
1775
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1776
+ zIndex: 0,
1777
+ get style() {
1778
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1779
+ }
1780
+ },
1781
+ () => annotationsProps,
1782
+ { children, $$slots: { default: true } }
1783
+ ));
1784
+ }
1785
+ };
1786
+ var alternate_5 = ($$anchor8) => {
1787
+ var fragment_19 = $.comment();
1788
+ var node_7 = $.first_child(fragment_19);
1789
+ {
1790
+ var consequent_6 = ($$anchor9) => {
1791
+ {
1792
+ const children = ($$anchor10, obj = $.noop) => {
1793
+ Highlight($$anchor10, $.spread_props(obj, {
1794
+ get scale() {
1795
+ return $$props.scale;
1796
+ },
1797
+ onClick: (e) => handleClick(e, $.get(annotation))
1798
+ }));
1799
+ };
1800
+ let $0 = $.derived(() => {
1801
+ var _a;
1802
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? false;
1803
+ });
1804
+ let $1 = $.derived(() => {
1805
+ var _a;
1806
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1807
+ });
1808
+ let $2 = $.derived(() => {
1809
+ var _a;
1810
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1811
+ });
1812
+ let $3 = $.derived(() => blendModeToCss($.get(annotation).object.blendMode ?? PdfBlendMode.Multiply));
1813
+ AnnotationContainer($$anchor9, $.spread_props(
1814
+ {
1815
+ get trackedAnnotation() {
1816
+ return $.get(annotation);
1817
+ },
1818
+ get isSelected() {
1819
+ return $.get(isSelected);
1820
+ },
1821
+ get isDraggable() {
1822
+ return $.get($0);
1823
+ },
1824
+ get isResizable() {
1825
+ return $.get($1);
1826
+ },
1827
+ get lockAspectRatio() {
1828
+ return $.get($2);
1829
+ },
1830
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1831
+ zIndex: 0,
1832
+ get selectionMenu() {
1833
+ return $$props.selectionMenu;
1834
+ },
1835
+ get selectionMenuSnippet() {
1836
+ return $$props.selectionMenuSnippet;
1837
+ },
1838
+ get style() {
1839
+ return `mix-blend-mode: ${$.get($3) ?? ""}`;
1840
+ }
1841
+ },
1842
+ () => annotationsProps,
1843
+ { children, $$slots: { default: true } }
1844
+ ));
1845
+ }
1846
+ };
1847
+ var alternate_4 = ($$anchor9) => {
1848
+ var fragment_22 = $.comment();
1849
+ var node_8 = $.first_child(fragment_22);
1850
+ {
1851
+ var consequent_7 = ($$anchor10) => {
1852
+ {
1853
+ const children = ($$anchor11, obj = $.noop) => {
1854
+ Line($$anchor11, $.spread_props(obj, {
1855
+ get isSelected() {
1856
+ return $.get(isSelected);
1857
+ },
1858
+ get scale() {
1859
+ return $$props.scale;
1860
+ },
1861
+ onClick: (e) => handleClick(e, $.get(annotation))
1862
+ }));
1863
+ };
1864
+ let $0 = $.derived(() => {
1865
+ var _a;
1866
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1867
+ });
1868
+ let $1 = $.derived(() => {
1869
+ var _a;
1870
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1871
+ });
1872
+ let $2 = $.derived(() => {
1873
+ var _a;
1874
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1875
+ });
1876
+ AnnotationContainer($$anchor10, $.spread_props(
1877
+ {
1878
+ get trackedAnnotation() {
1879
+ return $.get(annotation);
1880
+ },
1881
+ get isSelected() {
1882
+ return $.get(isSelected);
1883
+ },
1884
+ get isDraggable() {
1885
+ return $.get($0);
1886
+ },
1887
+ get isResizable() {
1888
+ return $.get($1);
1889
+ },
1890
+ get lockAspectRatio() {
1891
+ return $.get($2);
1892
+ },
1893
+ get selectionMenu() {
1894
+ return $$props.selectionMenu;
1895
+ },
1896
+ get selectionMenuSnippet() {
1897
+ return $$props.selectionMenuSnippet;
1898
+ },
1899
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1900
+ vertexConfig: {
1901
+ extractVertices: (a) => [a.linePoints.start, a.linePoints.end],
1902
+ transformAnnotation: (a, vertices) => ({ ...a, linePoints: { start: vertices[0], end: vertices[1] } })
1903
+ },
1904
+ get style() {
1905
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1906
+ }
1907
+ },
1908
+ () => annotationsProps,
1909
+ { children, $$slots: { default: true } }
1910
+ ));
1911
+ }
1912
+ };
1913
+ var alternate_3 = ($$anchor10) => {
1914
+ var fragment_25 = $.comment();
1915
+ var node_9 = $.first_child(fragment_25);
1916
+ {
1917
+ var consequent_8 = ($$anchor11) => {
1918
+ {
1919
+ const children = ($$anchor12, obj = $.noop) => {
1920
+ Polyline($$anchor12, $.spread_props(obj, {
1921
+ get isSelected() {
1922
+ return $.get(isSelected);
1923
+ },
1924
+ get scale() {
1925
+ return $$props.scale;
1926
+ },
1927
+ onClick: (e) => handleClick(e, $.get(annotation))
1928
+ }));
1929
+ };
1930
+ let $0 = $.derived(() => {
1931
+ var _a;
1932
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1933
+ });
1934
+ let $1 = $.derived(() => {
1935
+ var _a;
1936
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
1937
+ });
1938
+ let $2 = $.derived(() => {
1939
+ var _a;
1940
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
1941
+ });
1942
+ AnnotationContainer($$anchor11, $.spread_props(
1943
+ {
1944
+ get trackedAnnotation() {
1945
+ return $.get(annotation);
1946
+ },
1947
+ get selectionMenu() {
1948
+ return $$props.selectionMenu;
1949
+ },
1950
+ get selectionMenuSnippet() {
1951
+ return $$props.selectionMenuSnippet;
1952
+ },
1953
+ get isDraggable() {
1954
+ return $.get($0);
1955
+ },
1956
+ get isResizable() {
1957
+ return $.get($1);
1958
+ },
1959
+ get lockAspectRatio() {
1960
+ return $.get($2);
1961
+ },
1962
+ get isSelected() {
1963
+ return $.get(isSelected);
1964
+ },
1965
+ onSelect: (e) => handleClick(e, $.get(annotation)),
1966
+ vertexConfig: {
1967
+ extractVertices: (a) => a.vertices,
1968
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
1969
+ },
1970
+ get style() {
1971
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
1972
+ }
1973
+ },
1974
+ () => annotationsProps,
1975
+ { children, $$slots: { default: true } }
1976
+ ));
1977
+ }
1978
+ };
1979
+ var alternate_2 = ($$anchor11) => {
1980
+ var fragment_28 = $.comment();
1981
+ var node_10 = $.first_child(fragment_28);
1982
+ {
1983
+ var consequent_9 = ($$anchor12) => {
1984
+ {
1985
+ const children = ($$anchor13, obj = $.noop) => {
1986
+ Polygon($$anchor13, $.spread_props(obj, {
1987
+ get isSelected() {
1988
+ return $.get(isSelected);
1989
+ },
1990
+ get scale() {
1991
+ return $$props.scale;
1992
+ },
1993
+ onClick: (e) => handleClick(e, $.get(annotation))
1994
+ }));
1995
+ };
1996
+ let $0 = $.derived(() => {
1997
+ var _a;
1998
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
1999
+ });
2000
+ let $1 = $.derived(() => {
2001
+ var _a;
2002
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? false;
2003
+ });
2004
+ let $2 = $.derived(() => {
2005
+ var _a;
2006
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
2007
+ });
2008
+ AnnotationContainer($$anchor12, $.spread_props(
2009
+ {
2010
+ get trackedAnnotation() {
2011
+ return $.get(annotation);
2012
+ },
2013
+ get isSelected() {
2014
+ return $.get(isSelected);
2015
+ },
2016
+ get isDraggable() {
2017
+ return $.get($0);
2018
+ },
2019
+ get isResizable() {
2020
+ return $.get($1);
2021
+ },
2022
+ get lockAspectRatio() {
2023
+ return $.get($2);
2024
+ },
2025
+ get selectionMenu() {
2026
+ return $$props.selectionMenu;
2027
+ },
2028
+ get selectionMenuSnippet() {
2029
+ return $$props.selectionMenuSnippet;
2030
+ },
2031
+ onSelect: (e) => handleClick(e, $.get(annotation)),
2032
+ vertexConfig: {
2033
+ extractVertices: (a) => a.vertices,
2034
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
2035
+ },
2036
+ get style() {
2037
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
2038
+ }
2039
+ },
2040
+ () => annotationsProps,
2041
+ { children, $$slots: { default: true } }
2042
+ ));
2043
+ }
2044
+ };
2045
+ var alternate_1 = ($$anchor12) => {
2046
+ var fragment_31 = $.comment();
2047
+ var node_11 = $.first_child(fragment_31);
2048
+ {
2049
+ var consequent_10 = ($$anchor13) => {
2050
+ {
2051
+ const children = ($$anchor14, object = $.noop) => {
2052
+ {
2053
+ let $02 = $.derived(() => ({ ...$.get(annotation), object: object() }));
2054
+ FreeText($$anchor14, {
2055
+ get documentId() {
2056
+ return $$props.documentId;
2057
+ },
2058
+ get isSelected() {
2059
+ return $.get(isSelected);
2060
+ },
2061
+ get isEditing() {
2062
+ return $.get(isEditing);
2063
+ },
2064
+ get annotation() {
2065
+ return $.get($02);
2066
+ },
2067
+ get pageIndex() {
2068
+ return $$props.pageIndex;
2069
+ },
2070
+ get scale() {
2071
+ return $$props.scale;
2072
+ },
2073
+ onClick: (e) => handleClick(e, $.get(annotation))
2074
+ });
2075
+ }
2076
+ };
2077
+ let $0 = $.derived(() => {
2078
+ var _a;
2079
+ return (((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true) && !$.get(isEditing);
2080
+ });
2081
+ let $1 = $.derived(() => {
2082
+ var _a;
2083
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? true;
2084
+ });
2085
+ let $2 = $.derived(() => {
2086
+ var _a;
2087
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
2088
+ });
2089
+ let $3 = $.derived(() => blendModeToCss($.get(annotation).object.blendMode ?? PdfBlendMode.Normal));
2090
+ AnnotationContainer($$anchor13, $.spread_props(
2091
+ {
2092
+ get trackedAnnotation() {
2093
+ return $.get(annotation);
2094
+ },
2095
+ get isSelected() {
2096
+ return $.get(isSelected);
2097
+ },
2098
+ get isDraggable() {
2099
+ return $.get($0);
2100
+ },
2101
+ get isResizable() {
2102
+ return $.get($1);
2103
+ },
2104
+ get lockAspectRatio() {
2105
+ return $.get($2);
2106
+ },
2107
+ get selectionMenu() {
2108
+ return $$props.selectionMenu;
2109
+ },
2110
+ get selectionMenuSnippet() {
2111
+ return $$props.selectionMenuSnippet;
2112
+ },
2113
+ onSelect: (e) => handleClick(e, $.get(annotation)),
2114
+ get style() {
2115
+ return `mix-blend-mode: ${$.get($3) ?? ""}`;
2116
+ },
2117
+ onDoubleClick: (e) => {
2118
+ e.stopPropagation();
2119
+ $.set(editingId, $.get(annotation).object.id, true);
2120
+ }
2121
+ },
2122
+ () => annotationsProps,
2123
+ { children, $$slots: { default: true } }
2124
+ ));
2125
+ }
2126
+ };
2127
+ var alternate = ($$anchor13) => {
2128
+ var fragment_34 = $.comment();
2129
+ var node_12 = $.first_child(fragment_34);
2130
+ {
2131
+ var consequent_11 = ($$anchor14) => {
2132
+ {
2133
+ const children = ($$anchor15, _object = $.noop) => {
2134
+ Stamp($$anchor15, {
2135
+ get documentId() {
2136
+ return $$props.documentId;
2137
+ },
2138
+ get isSelected() {
2139
+ return $.get(isSelected);
2140
+ },
2141
+ get annotation() {
2142
+ return $.get(annotation);
2143
+ },
2144
+ get pageIndex() {
2145
+ return $$props.pageIndex;
2146
+ },
2147
+ get scale() {
2148
+ return $$props.scale;
2149
+ },
2150
+ onClick: (e) => handleClick(e, $.get(annotation))
2151
+ });
2152
+ };
2153
+ let $0 = $.derived(() => {
2154
+ var _a;
2155
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isDraggable) ?? true;
2156
+ });
2157
+ let $1 = $.derived(() => {
2158
+ var _a;
2159
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.isResizable) ?? true;
2160
+ });
2161
+ let $2 = $.derived(() => {
2162
+ var _a;
2163
+ return ((_a = $.get(tool)) == null ? void 0 : _a.interaction.lockAspectRatio) ?? false;
2164
+ });
2165
+ AnnotationContainer($$anchor14, $.spread_props(
2166
+ {
2167
+ get trackedAnnotation() {
2168
+ return $.get(annotation);
2169
+ },
2170
+ get isSelected() {
2171
+ return $.get(isSelected);
2172
+ },
2173
+ get isDraggable() {
2174
+ return $.get($0);
2175
+ },
2176
+ get isResizable() {
2177
+ return $.get($1);
2178
+ },
2179
+ get lockAspectRatio() {
2180
+ return $.get($2);
2181
+ },
2182
+ get selectionMenu() {
2183
+ return $$props.selectionMenu;
2184
+ },
2185
+ get selectionMenuSnippet() {
2186
+ return $$props.selectionMenuSnippet;
2187
+ },
2188
+ onSelect: (e) => handleClick(e, $.get(annotation)),
2189
+ get style() {
2190
+ return `mix-blend-mode: ${$.get(mixBlendMode) ?? ""}`;
2191
+ }
2192
+ },
2193
+ () => annotationsProps,
2194
+ { children, $$slots: { default: true } }
2195
+ ));
2196
+ }
2197
+ };
2198
+ $.if(
2199
+ node_12,
2200
+ ($$render) => {
2201
+ if (isStamp($.get(annotation))) $$render(consequent_11);
2202
+ },
2203
+ true
2204
+ );
2205
+ }
2206
+ $.append($$anchor13, fragment_34);
2207
+ };
2208
+ $.if(
2209
+ node_11,
2210
+ ($$render) => {
2211
+ if (isFreeText($.get(annotation))) $$render(consequent_10);
2212
+ else $$render(alternate, false);
2213
+ },
2214
+ true
2215
+ );
2216
+ }
2217
+ $.append($$anchor12, fragment_31);
2218
+ };
2219
+ $.if(
2220
+ node_10,
2221
+ ($$render) => {
2222
+ if (isPolygon($.get(annotation))) $$render(consequent_9);
2223
+ else $$render(alternate_1, false);
2224
+ },
2225
+ true
2226
+ );
2227
+ }
2228
+ $.append($$anchor11, fragment_28);
2229
+ };
2230
+ $.if(
2231
+ node_9,
2232
+ ($$render) => {
2233
+ if (isPolyline($.get(annotation))) $$render(consequent_8);
2234
+ else $$render(alternate_2, false);
2235
+ },
2236
+ true
2237
+ );
2238
+ }
2239
+ $.append($$anchor10, fragment_25);
2240
+ };
2241
+ $.if(
2242
+ node_8,
2243
+ ($$render) => {
2244
+ if (isLine($.get(annotation))) $$render(consequent_7);
2245
+ else $$render(alternate_3, false);
2246
+ },
2247
+ true
2248
+ );
2249
+ }
2250
+ $.append($$anchor9, fragment_22);
2251
+ };
2252
+ $.if(
2253
+ node_7,
2254
+ ($$render) => {
2255
+ if (isHighlight($.get(annotation))) $$render(consequent_6);
2256
+ else $$render(alternate_4, false);
2257
+ },
2258
+ true
2259
+ );
2260
+ }
2261
+ $.append($$anchor8, fragment_19);
2262
+ };
2263
+ $.if(
2264
+ node_6,
2265
+ ($$render) => {
2266
+ if (isSquiggly($.get(annotation))) $$render(consequent_5);
2267
+ else $$render(alternate_5, false);
2268
+ },
2269
+ true
2270
+ );
2271
+ }
2272
+ $.append($$anchor7, fragment_16);
2273
+ };
2274
+ $.if(
2275
+ node_5,
2276
+ ($$render) => {
2277
+ if (isStrikeout($.get(annotation))) $$render(consequent_4);
2278
+ else $$render(alternate_6, false);
2279
+ },
2280
+ true
2281
+ );
2282
+ }
2283
+ $.append($$anchor6, fragment_13);
2284
+ };
2285
+ $.if(
2286
+ node_4,
2287
+ ($$render) => {
2288
+ if (isUnderline($.get(annotation))) $$render(consequent_3);
2289
+ else $$render(alternate_7, false);
2290
+ },
2291
+ true
2292
+ );
2293
+ }
2294
+ $.append($$anchor5, fragment_10);
2295
+ };
2296
+ $.if(
2297
+ node_3,
2298
+ ($$render) => {
2299
+ if (isCircle($.get(annotation))) $$render(consequent_2);
2300
+ else $$render(alternate_8, false);
2301
+ },
2302
+ true
2303
+ );
2304
+ }
2305
+ $.append($$anchor4, fragment_7);
2306
+ };
2307
+ $.if(
2308
+ node_2,
2309
+ ($$render) => {
2310
+ if (isSquare($.get(annotation))) $$render(consequent_1);
2311
+ else $$render(alternate_9, false);
2312
+ },
2313
+ true
2314
+ );
2315
+ }
2316
+ $.append($$anchor3, fragment_4);
2317
+ };
2318
+ $.if(node_1, ($$render) => {
2319
+ if (isInk($.get(annotation))) $$render(consequent);
2320
+ else $$render(alternate_10, false);
2321
+ });
2322
+ }
2323
+ $.append($$anchor2, fragment_1);
2324
+ });
2325
+ $.append($$anchor, fragment);
2326
+ $.pop();
2327
+ }
2328
+ var root_2 = $.from_html(`<div><!></div>`);
2329
+ var root_4 = $.from_html(`<div><!></div>`);
2330
+ var root_6 = $.from_html(`<div><!></div>`);
2331
+ var root_8 = $.from_html(`<div><!></div>`);
2332
+ function TextMarkup($$anchor, $$props) {
2333
+ $.push($$props, true);
2334
+ const selectionCapability = useSelectionCapability();
2335
+ const annotationCapability = useAnnotationCapability();
2336
+ let rects = $.state($.proxy([]));
2337
+ let boundingRect = $.state(null);
2338
+ let activeTool = $.state(null);
2339
+ const selectionProvides = $.derived(() => selectionCapability.provides ? selectionCapability.provides.forDocument($$props.documentId) : null);
2340
+ const annotationProvides = $.derived(() => annotationCapability.provides ? annotationCapability.provides.forDocument($$props.documentId) : null);
2341
+ $.user_effect(() => {
2342
+ if (!$.get(selectionProvides)) return;
2343
+ const off = $.get(selectionProvides).onSelectionChange(() => {
2344
+ $.set(rects, $.get(selectionProvides).getHighlightRectsForPage($$props.pageIndex), true);
2345
+ $.set(boundingRect, $.get(selectionProvides).getBoundingRectForPage($$props.pageIndex), true);
2346
+ });
2347
+ return off;
2348
+ });
2349
+ $.user_effect(() => {
2350
+ if (!$.get(annotationProvides)) return;
2351
+ $.set(activeTool, $.get(annotationProvides).getActiveTool(), true);
2352
+ const off = $.get(annotationProvides).onActiveToolChange((tool) => {
2353
+ $.set(activeTool, tool, true);
2354
+ });
2355
+ return off;
2356
+ });
2357
+ const mixBlendMode = $.derived(() => {
2358
+ var _a, _b, _c, _d;
2359
+ return ((_b = (_a = $.get(activeTool)) == null ? void 0 : _a.defaults) == null ? void 0 : _b.blendMode) ? blendModeToCss($.get(activeTool).defaults.blendMode) : ((_d = (_c = $.get(activeTool)) == null ? void 0 : _c.defaults) == null ? void 0 : _d.type) === PdfAnnotationSubtype.HIGHLIGHT ? blendModeToCss(PdfBlendMode.Multiply) : blendModeToCss(PdfBlendMode.Normal);
2360
+ });
2361
+ var fragment = $.comment();
2362
+ var node = $.first_child(fragment);
2363
+ {
2364
+ var consequent_4 = ($$anchor2) => {
2365
+ var fragment_1 = $.comment();
2366
+ var node_1 = $.first_child(fragment_1);
2367
+ {
2368
+ var consequent = ($$anchor3) => {
2369
+ var div = root_2();
2370
+ let styles;
2371
+ var node_2 = $.child(div);
2372
+ {
2373
+ let $0 = $.derived(() => {
2374
+ var _a;
2375
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.color;
2376
+ });
2377
+ let $1 = $.derived(() => {
2378
+ var _a;
2379
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.opacity;
2380
+ });
2381
+ Underline(node_2, {
2382
+ get color() {
2383
+ return $.get($0);
2384
+ },
2385
+ get opacity() {
2386
+ return $.get($1);
2387
+ },
2388
+ get segmentRects() {
2389
+ return $.get(rects);
2390
+ },
2391
+ get scale() {
2392
+ return $$props.scale;
2393
+ }
2394
+ });
2395
+ }
2396
+ $.reset(div);
2397
+ $.template_effect(() => styles = $.set_style(div, "", styles, {
2398
+ "mix-blend-mode": $.get(mixBlendMode),
2399
+ "pointer-events": "none",
2400
+ position: "absolute",
2401
+ inset: "0"
2402
+ }));
2403
+ $.append($$anchor3, div);
2404
+ };
2405
+ var alternate_2 = ($$anchor3) => {
2406
+ var fragment_2 = $.comment();
2407
+ var node_3 = $.first_child(fragment_2);
2408
+ {
2409
+ var consequent_1 = ($$anchor4) => {
2410
+ var div_1 = root_4();
2411
+ let styles_1;
2412
+ var node_4 = $.child(div_1);
2413
+ {
2414
+ let $0 = $.derived(() => {
2415
+ var _a;
2416
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.color;
2417
+ });
2418
+ let $1 = $.derived(() => {
2419
+ var _a;
2420
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.opacity;
2421
+ });
2422
+ Highlight(node_4, {
2423
+ get color() {
2424
+ return $.get($0);
2425
+ },
2426
+ get opacity() {
2427
+ return $.get($1);
2428
+ },
2429
+ get segmentRects() {
2430
+ return $.get(rects);
2431
+ },
2432
+ get scale() {
2433
+ return $$props.scale;
2434
+ }
2435
+ });
2436
+ }
2437
+ $.reset(div_1);
2438
+ $.template_effect(() => styles_1 = $.set_style(div_1, "", styles_1, {
2439
+ "mix-blend-mode": $.get(mixBlendMode),
2440
+ "pointer-events": "none",
2441
+ position: "absolute",
2442
+ inset: "0"
2443
+ }));
2444
+ $.append($$anchor4, div_1);
2445
+ };
2446
+ var alternate_1 = ($$anchor4) => {
2447
+ var fragment_3 = $.comment();
2448
+ var node_5 = $.first_child(fragment_3);
2449
+ {
2450
+ var consequent_2 = ($$anchor5) => {
2451
+ var div_2 = root_6();
2452
+ let styles_2;
2453
+ var node_6 = $.child(div_2);
2454
+ {
2455
+ let $0 = $.derived(() => {
2456
+ var _a;
2457
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.color;
2458
+ });
2459
+ let $1 = $.derived(() => {
2460
+ var _a;
2461
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.opacity;
2462
+ });
2463
+ Strikeout(node_6, {
2464
+ get color() {
2465
+ return $.get($0);
2466
+ },
2467
+ get opacity() {
2468
+ return $.get($1);
2469
+ },
2470
+ get segmentRects() {
2471
+ return $.get(rects);
2472
+ },
2473
+ get scale() {
2474
+ return $$props.scale;
2475
+ }
2476
+ });
2477
+ }
2478
+ $.reset(div_2);
2479
+ $.template_effect(() => styles_2 = $.set_style(div_2, "", styles_2, {
2480
+ "mix-blend-mode": $.get(mixBlendMode),
2481
+ "pointer-events": "none",
2482
+ position: "absolute",
2483
+ inset: "0"
2484
+ }));
2485
+ $.append($$anchor5, div_2);
2486
+ };
2487
+ var alternate = ($$anchor5) => {
2488
+ var fragment_4 = $.comment();
2489
+ var node_7 = $.first_child(fragment_4);
2490
+ {
2491
+ var consequent_3 = ($$anchor6) => {
2492
+ var div_3 = root_8();
2493
+ let styles_3;
2494
+ var node_8 = $.child(div_3);
2495
+ {
2496
+ let $0 = $.derived(() => {
2497
+ var _a;
2498
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.color;
2499
+ });
2500
+ let $1 = $.derived(() => {
2501
+ var _a;
2502
+ return (_a = $.get(activeTool).defaults) == null ? void 0 : _a.opacity;
2503
+ });
2504
+ Squiggly(node_8, {
2505
+ get color() {
2506
+ return $.get($0);
2507
+ },
2508
+ get opacity() {
2509
+ return $.get($1);
2510
+ },
2511
+ get segmentRects() {
2512
+ return $.get(rects);
2513
+ },
2514
+ get scale() {
2515
+ return $$props.scale;
2516
+ }
2517
+ });
2518
+ }
2519
+ $.reset(div_3);
2520
+ $.template_effect(() => styles_3 = $.set_style(div_3, "", styles_3, {
2521
+ "mix-blend-mode": $.get(mixBlendMode),
2522
+ "pointer-events": "none",
2523
+ position: "absolute",
2524
+ inset: "0"
2525
+ }));
2526
+ $.append($$anchor6, div_3);
2527
+ };
2528
+ $.if(
2529
+ node_7,
2530
+ ($$render) => {
2531
+ if ($.get(activeTool).defaults.type === PdfAnnotationSubtype.SQUIGGLY) $$render(consequent_3);
2532
+ },
2533
+ true
2534
+ );
2535
+ }
2536
+ $.append($$anchor5, fragment_4);
2537
+ };
2538
+ $.if(
2539
+ node_5,
2540
+ ($$render) => {
2541
+ if ($.get(activeTool).defaults.type === PdfAnnotationSubtype.STRIKEOUT) $$render(consequent_2);
2542
+ else $$render(alternate, false);
2543
+ },
2544
+ true
2545
+ );
2546
+ }
2547
+ $.append($$anchor4, fragment_3);
2548
+ };
2549
+ $.if(
2550
+ node_3,
2551
+ ($$render) => {
2552
+ if ($.get(activeTool).defaults.type === PdfAnnotationSubtype.HIGHLIGHT) $$render(consequent_1);
2553
+ else $$render(alternate_1, false);
2554
+ },
2555
+ true
2556
+ );
2557
+ }
2558
+ $.append($$anchor3, fragment_2);
2559
+ };
2560
+ $.if(node_1, ($$render) => {
2561
+ if ($.get(activeTool).defaults.type === PdfAnnotationSubtype.UNDERLINE) $$render(consequent);
2562
+ else $$render(alternate_2, false);
2563
+ });
2564
+ }
2565
+ $.append($$anchor2, fragment_1);
2566
+ };
2567
+ $.if(node, ($$render) => {
2568
+ if ($.get(boundingRect) && $.get(activeTool) && $.get(activeTool).defaults) $$render(consequent_4);
2569
+ });
2570
+ }
2571
+ $.append($$anchor, fragment);
2572
+ $.pop();
2573
+ }
2574
+ var root_1 = $.from_html(`<div><!></div>`);
2575
+ var root_3 = $.from_html(`<div><!></div>`);
2576
+ var root_5 = $.from_html(`<div><!></div>`);
2577
+ var root_7 = $.from_html(`<div><!></div>`);
2578
+ var root_9 = $.from_html(`<div><!></div>`);
2579
+ var root_11 = $.from_html(`<div><!></div>`);
2580
+ var root_13 = $.from_html(`<div><div></div></div>`);
2581
+ function PreviewRenderer($$anchor, $$props) {
2582
+ $.push($$props, true);
2583
+ const bounds = $.derived(() => $$props.preview.bounds);
2584
+ const style = $.derived(() => ({
2585
+ left: $.get(bounds).origin.x * $$props.scale,
2586
+ top: $.get(bounds).origin.y * $$props.scale,
2587
+ width: $.get(bounds).size.width * $$props.scale,
2588
+ height: $.get(bounds).size.height * $$props.scale
2589
+ }));
2590
+ var fragment = $.comment();
2591
+ var node = $.first_child(fragment);
2592
+ {
2593
+ var consequent = ($$anchor2) => {
2594
+ var div = root_1();
2595
+ let styles;
2596
+ var node_1 = $.child(div);
2597
+ Circle(node_1, $.spread_props(
2598
+ {
2599
+ isSelected: false,
2600
+ get scale() {
2601
+ return $$props.scale;
2602
+ }
2603
+ },
2604
+ () => $$props.preview.data
2605
+ ));
2606
+ $.reset(div);
2607
+ $.template_effect(() => styles = $.set_style(div, "", styles, {
2608
+ position: "absolute",
2609
+ left: `${$.get(style).left ?? ""}px`,
2610
+ top: `${$.get(style).top ?? ""}px`,
2611
+ width: `${$.get(style).width ?? ""}px`,
2612
+ height: `${$.get(style).height ?? ""}px`,
2613
+ "pointer-events": "none",
2614
+ "z-index": "10"
2615
+ }));
2616
+ $.append($$anchor2, div);
2617
+ };
2618
+ var alternate_5 = ($$anchor2) => {
2619
+ var fragment_1 = $.comment();
2620
+ var node_2 = $.first_child(fragment_1);
2621
+ {
2622
+ var consequent_1 = ($$anchor3) => {
2623
+ var div_1 = root_3();
2624
+ let styles_1;
2625
+ var node_3 = $.child(div_1);
2626
+ Square(node_3, $.spread_props(
2627
+ {
2628
+ isSelected: false,
2629
+ get scale() {
2630
+ return $$props.scale;
2631
+ }
2632
+ },
2633
+ () => $$props.preview.data
2634
+ ));
2635
+ $.reset(div_1);
2636
+ $.template_effect(() => styles_1 = $.set_style(div_1, "", styles_1, {
2637
+ position: "absolute",
2638
+ left: `${$.get(style).left ?? ""}px`,
2639
+ top: `${$.get(style).top ?? ""}px`,
2640
+ width: `${$.get(style).width ?? ""}px`,
2641
+ height: `${$.get(style).height ?? ""}px`,
2642
+ "pointer-events": "none",
2643
+ "z-index": "10"
2644
+ }));
2645
+ $.append($$anchor3, div_1);
2646
+ };
2647
+ var alternate_4 = ($$anchor3) => {
2648
+ var fragment_2 = $.comment();
2649
+ var node_4 = $.first_child(fragment_2);
2650
+ {
2651
+ var consequent_2 = ($$anchor4) => {
2652
+ var div_2 = root_5();
2653
+ let styles_2;
2654
+ var node_5 = $.child(div_2);
2655
+ Polygon(node_5, $.spread_props(
2656
+ {
2657
+ isSelected: false,
2658
+ get scale() {
2659
+ return $$props.scale;
2660
+ }
2661
+ },
2662
+ () => $$props.preview.data
2663
+ ));
2664
+ $.reset(div_2);
2665
+ $.template_effect(() => styles_2 = $.set_style(div_2, "", styles_2, {
2666
+ position: "absolute",
2667
+ left: `${$.get(style).left ?? ""}px`,
2668
+ top: `${$.get(style).top ?? ""}px`,
2669
+ width: `${$.get(style).width ?? ""}px`,
2670
+ height: `${$.get(style).height ?? ""}px`,
2671
+ "pointer-events": "none",
2672
+ "z-index": "10"
2673
+ }));
2674
+ $.append($$anchor4, div_2);
2675
+ };
2676
+ var alternate_3 = ($$anchor4) => {
2677
+ var fragment_3 = $.comment();
2678
+ var node_6 = $.first_child(fragment_3);
2679
+ {
2680
+ var consequent_3 = ($$anchor5) => {
2681
+ var div_3 = root_7();
2682
+ let styles_3;
2683
+ var node_7 = $.child(div_3);
2684
+ Polyline(node_7, $.spread_props(
2685
+ {
2686
+ isSelected: false,
2687
+ get scale() {
2688
+ return $$props.scale;
2689
+ }
2690
+ },
2691
+ () => $$props.preview.data
2692
+ ));
2693
+ $.reset(div_3);
2694
+ $.template_effect(() => styles_3 = $.set_style(div_3, "", styles_3, {
2695
+ position: "absolute",
2696
+ left: `${$.get(style).left ?? ""}px`,
2697
+ top: `${$.get(style).top ?? ""}px`,
2698
+ width: `${$.get(style).width ?? ""}px`,
2699
+ height: `${$.get(style).height ?? ""}px`,
2700
+ "pointer-events": "none",
2701
+ "z-index": "10"
2702
+ }));
2703
+ $.append($$anchor5, div_3);
2704
+ };
2705
+ var alternate_2 = ($$anchor5) => {
2706
+ var fragment_4 = $.comment();
2707
+ var node_8 = $.first_child(fragment_4);
2708
+ {
2709
+ var consequent_4 = ($$anchor6) => {
2710
+ var div_4 = root_9();
2711
+ let styles_4;
2712
+ var node_9 = $.child(div_4);
2713
+ Line(node_9, $.spread_props(
2714
+ {
2715
+ isSelected: false,
2716
+ get scale() {
2717
+ return $$props.scale;
2718
+ }
2719
+ },
2720
+ () => $$props.preview.data
2721
+ ));
2722
+ $.reset(div_4);
2723
+ $.template_effect(() => styles_4 = $.set_style(div_4, "", styles_4, {
2724
+ position: "absolute",
2725
+ left: `${$.get(style).left ?? ""}px`,
2726
+ top: `${$.get(style).top ?? ""}px`,
2727
+ width: `${$.get(style).width ?? ""}px`,
2728
+ height: `${$.get(style).height ?? ""}px`,
2729
+ "pointer-events": "none",
2730
+ "z-index": "10"
2731
+ }));
2732
+ $.append($$anchor6, div_4);
2733
+ };
2734
+ var alternate_1 = ($$anchor6) => {
2735
+ var fragment_5 = $.comment();
2736
+ var node_10 = $.first_child(fragment_5);
2737
+ {
2738
+ var consequent_5 = ($$anchor7) => {
2739
+ var div_5 = root_11();
2740
+ let styles_5;
2741
+ var node_11 = $.child(div_5);
2742
+ Ink(node_11, $.spread_props(
2743
+ {
2744
+ isSelected: false,
2745
+ get scale() {
2746
+ return $$props.scale;
2747
+ }
2748
+ },
2749
+ () => $$props.preview.data
2750
+ ));
2751
+ $.reset(div_5);
2752
+ $.template_effect(() => styles_5 = $.set_style(div_5, "", styles_5, {
2753
+ position: "absolute",
2754
+ left: `${$.get(style).left ?? ""}px`,
2755
+ top: `${$.get(style).top ?? ""}px`,
2756
+ width: `${$.get(style).width ?? ""}px`,
2757
+ height: `${$.get(style).height ?? ""}px`,
2758
+ "pointer-events": "none",
2759
+ "z-index": "10"
2760
+ }));
2761
+ $.append($$anchor7, div_5);
2762
+ };
2763
+ var alternate = ($$anchor7) => {
2764
+ var fragment_6 = $.comment();
2765
+ var node_12 = $.first_child(fragment_6);
2766
+ {
2767
+ var consequent_6 = ($$anchor8) => {
2768
+ var div_6 = root_13();
2769
+ let styles_6;
2770
+ var div_7 = $.child(div_6);
2771
+ let styles_7;
2772
+ $.reset(div_6);
2773
+ $.template_effect(() => {
2774
+ styles_6 = $.set_style(div_6, "", styles_6, {
2775
+ position: "absolute",
2776
+ left: `${$.get(style).left ?? ""}px`,
2777
+ top: `${$.get(style).top ?? ""}px`,
2778
+ width: `${$.get(style).width ?? ""}px`,
2779
+ height: `${$.get(style).height ?? ""}px`,
2780
+ "pointer-events": "none",
2781
+ "z-index": "10"
2782
+ });
2783
+ styles_7 = $.set_style(div_7, "", styles_7, {
2784
+ width: "100%",
2785
+ height: "100%",
2786
+ border: `1px dashed ${($$props.preview.data.fontColor || "#000000") ?? ""}`,
2787
+ "background-color": "transparent"
2788
+ });
2789
+ });
2790
+ $.append($$anchor8, div_6);
2791
+ };
2792
+ $.if(
2793
+ node_12,
2794
+ ($$render) => {
2795
+ if ($$props.preview.type === PdfAnnotationSubtype.FREETEXT) $$render(consequent_6);
2796
+ },
2797
+ true
2798
+ );
2799
+ }
2800
+ $.append($$anchor7, fragment_6);
2801
+ };
2802
+ $.if(
2803
+ node_10,
2804
+ ($$render) => {
2805
+ if ($$props.preview.type === PdfAnnotationSubtype.INK) $$render(consequent_5);
2806
+ else $$render(alternate, false);
2807
+ },
2808
+ true
2809
+ );
2810
+ }
2811
+ $.append($$anchor6, fragment_5);
2812
+ };
2813
+ $.if(
2814
+ node_8,
2815
+ ($$render) => {
2816
+ if ($$props.preview.type === PdfAnnotationSubtype.LINE) $$render(consequent_4);
2817
+ else $$render(alternate_1, false);
2818
+ },
2819
+ true
2820
+ );
2821
+ }
2822
+ $.append($$anchor5, fragment_4);
2823
+ };
2824
+ $.if(
2825
+ node_6,
2826
+ ($$render) => {
2827
+ if ($$props.preview.type === PdfAnnotationSubtype.POLYLINE) $$render(consequent_3);
2828
+ else $$render(alternate_2, false);
2829
+ },
2830
+ true
2831
+ );
2832
+ }
2833
+ $.append($$anchor4, fragment_3);
2834
+ };
2835
+ $.if(
2836
+ node_4,
2837
+ ($$render) => {
2838
+ if ($$props.preview.type === PdfAnnotationSubtype.POLYGON) $$render(consequent_2);
2839
+ else $$render(alternate_3, false);
2840
+ },
2841
+ true
2842
+ );
2843
+ }
2844
+ $.append($$anchor3, fragment_2);
2845
+ };
2846
+ $.if(
2847
+ node_2,
2848
+ ($$render) => {
2849
+ if ($$props.preview.type === PdfAnnotationSubtype.SQUARE) $$render(consequent_1);
2850
+ else $$render(alternate_4, false);
2851
+ },
2852
+ true
2853
+ );
2854
+ }
2855
+ $.append($$anchor2, fragment_1);
2856
+ };
2857
+ $.if(node, ($$render) => {
2858
+ if ($$props.preview.type === PdfAnnotationSubtype.CIRCLE) $$render(consequent);
2859
+ else $$render(alternate_5, false);
2860
+ });
2861
+ }
2862
+ $.append($$anchor, fragment);
2863
+ $.pop();
2864
+ }
2865
+ var root$1 = $.from_html(`<input type="file"/> <canvas></canvas> <!>`, 1);
2866
+ function AnnotationPaintLayer($$anchor, $$props) {
2867
+ $.push($$props, true);
2868
+ const annotationPlugin = useAnnotationPlugin();
2869
+ let previews = $.state($.proxy(/* @__PURE__ */ new Map()));
2870
+ let fileInputRef = $.state(null);
2871
+ let canvasRef = $.state(null);
2872
+ const services = {
2873
+ requestFile: ({ accept, onFile }) => {
2874
+ if (!$.get(fileInputRef)) return;
2875
+ const input = $.get(fileInputRef);
2876
+ input.accept = accept;
2877
+ input.onchange = (e) => {
2878
+ var _a;
2879
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
2880
+ if (file) {
2881
+ onFile(file);
2882
+ input.value = "";
2883
+ }
2884
+ };
2885
+ input.click();
2886
+ },
2887
+ processImage: ({ source, maxWidth, maxHeight, onComplete }) => {
2888
+ const canvas = $.get(canvasRef);
2889
+ if (!canvas || !canvas.getContext) return;
2890
+ const ctx = canvas.getContext("2d");
2891
+ if (!ctx) return;
2892
+ const img = new Image();
2893
+ img.crossOrigin = "Anonymous";
2894
+ img.onload = () => {
2895
+ let { naturalWidth: width, naturalHeight: height } = img;
2896
+ const scaleX = maxWidth ? maxWidth / width : 1;
2897
+ const scaleY = maxHeight ? maxHeight / height : 1;
2898
+ const scaleFactor = Math.min(scaleX, scaleY, 1);
2899
+ const finalWidth = width * scaleFactor;
2900
+ const finalHeight = height * scaleFactor;
2901
+ canvas.width = finalWidth;
2902
+ canvas.height = finalHeight;
2903
+ ctx.drawImage(img, 0, 0, finalWidth, finalHeight);
2904
+ const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);
2905
+ if (typeof source !== "string") URL.revokeObjectURL(img.src);
2906
+ onComplete({ imageData, width: finalWidth, height: finalHeight });
2907
+ };
2908
+ img.src = typeof source === "string" ? source : URL.createObjectURL(source);
2909
+ }
2910
+ };
2911
+ $.user_effect(() => {
2912
+ if (!annotationPlugin.plugin) return;
2913
+ return annotationPlugin.plugin.registerPageHandlers($$props.documentId, $$props.pageIndex, $$props.scale, {
2914
+ services,
2915
+ onPreview: (toolId, state) => {
2916
+ $.set(previews, new Map($.get(previews)), true);
2917
+ if (state) {
2918
+ $.get(previews).set(toolId, state);
2919
+ } else {
2920
+ $.get(previews).delete(toolId);
2921
+ }
2922
+ }
2923
+ });
2924
+ });
2925
+ var fragment = root$1();
2926
+ var input_1 = $.first_child(fragment);
2927
+ $.set_style(input_1, "", {}, { display: "none" });
2928
+ $.bind_this(input_1, ($$value) => $.set(fileInputRef, $$value), () => $.get(fileInputRef));
2929
+ var canvas_1 = $.sibling(input_1, 2);
2930
+ $.set_style(canvas_1, "", {}, { display: "none" });
2931
+ $.bind_this(canvas_1, ($$value) => $.set(canvasRef, $$value), () => $.get(canvasRef));
2932
+ var node = $.sibling(canvas_1, 2);
2933
+ $.each(node, 17, () => Array.from($.get(previews).entries()), ([toolId, preview]) => toolId, ($$anchor2, $$item) => {
2934
+ var $$array = $.derived(() => $.to_array($.get($$item), 2));
2935
+ let preview = () => $.get($$array)[1];
2936
+ PreviewRenderer($$anchor2, {
2937
+ get preview() {
2938
+ return preview();
2939
+ },
2940
+ get scale() {
2941
+ return $$props.scale;
2942
+ }
2943
+ });
2944
+ });
2945
+ $.append($$anchor, fragment);
2946
+ $.pop();
2947
+ }
2948
+ var root = $.from_html(`<div><!> <!> <!></div>`);
2949
+ function AnnotationLayer($$anchor, $$props) {
2950
+ $.push($$props, true);
2951
+ let restProps = $.rest_props($$props, [
2952
+ "$$slots",
2953
+ "$$events",
2954
+ "$$legacy",
2955
+ "style",
2956
+ "documentId",
2957
+ "pageIndex",
2958
+ "scale",
2959
+ "rotation",
2960
+ "selectionMenu",
2961
+ "selectionMenuSnippet",
2962
+ "resizeUI",
2963
+ "vertexUI",
2964
+ "selectionOutlineColor",
2965
+ "customAnnotationRenderer"
2966
+ ]);
2967
+ const documentState = useDocumentState(() => $$props.documentId);
2968
+ const page = $.derived(() => {
2969
+ var _a, _b, _c;
2970
+ return (_c = (_b = (_a = documentState == null ? void 0 : documentState.current) == null ? void 0 : _a.document) == null ? void 0 : _b.pages) == null ? void 0 : _c[$$props.pageIndex];
2971
+ });
2972
+ const pageWidth = $.derived(() => {
2973
+ var _a, _b;
2974
+ return ((_b = (_a = $.get(page)) == null ? void 0 : _a.size) == null ? void 0 : _b.width) ?? 0;
2975
+ });
2976
+ const pageHeight = $.derived(() => {
2977
+ var _a, _b;
2978
+ return ((_b = (_a = $.get(page)) == null ? void 0 : _a.size) == null ? void 0 : _b.height) ?? 0;
2979
+ });
2980
+ const actualScale = $.derived(() => {
2981
+ var _a;
2982
+ return $$props.scale !== void 0 ? $$props.scale : ((_a = documentState == null ? void 0 : documentState.current) == null ? void 0 : _a.scale) ?? 1;
2983
+ });
2984
+ const actualRotation = $.derived(() => {
2985
+ var _a;
2986
+ return $$props.rotation !== void 0 ? $$props.rotation : ((_a = documentState == null ? void 0 : documentState.current) == null ? void 0 : _a.rotation) ?? Rotation.Degree0;
2987
+ });
2988
+ var div = root();
2989
+ $.attribute_effect(div, ($0) => ({ id: "annotation-layer", ...$0, ...restProps }), [
2990
+ () => $$props.style ? Object.fromEntries(Object.entries($$props.style).map(([k, v]) => [`style:${k}`, v])) : {}
2991
+ ]);
2992
+ var node = $.child(div);
2993
+ Annotations(node, {
2994
+ get documentId() {
2995
+ return $$props.documentId;
2996
+ },
2997
+ get selectionMenu() {
2998
+ return $$props.selectionMenu;
2999
+ },
3000
+ get selectionMenuSnippet() {
3001
+ return $$props.selectionMenuSnippet;
3002
+ },
3003
+ get pageIndex() {
3004
+ return $$props.pageIndex;
3005
+ },
3006
+ get scale() {
3007
+ return $.get(actualScale);
3008
+ },
3009
+ get rotation() {
3010
+ return $.get(actualRotation);
3011
+ },
3012
+ get pageWidth() {
3013
+ return $.get(pageWidth);
3014
+ },
3015
+ get pageHeight() {
3016
+ return $.get(pageHeight);
3017
+ },
3018
+ get resizeUI() {
3019
+ return $$props.resizeUI;
3020
+ },
3021
+ get vertexUI() {
3022
+ return $$props.vertexUI;
3023
+ },
3024
+ get selectionOutlineColor() {
3025
+ return $$props.selectionOutlineColor;
3026
+ },
3027
+ get customAnnotationRenderer() {
3028
+ return $$props.customAnnotationRenderer;
3029
+ }
3030
+ });
3031
+ var node_1 = $.sibling(node, 2);
3032
+ TextMarkup(node_1, {
3033
+ get documentId() {
3034
+ return $$props.documentId;
3035
+ },
3036
+ get pageIndex() {
3037
+ return $$props.pageIndex;
3038
+ },
3039
+ get scale() {
3040
+ return $.get(actualScale);
3041
+ }
3042
+ });
3043
+ var node_2 = $.sibling(node_1, 2);
3044
+ AnnotationPaintLayer(node_2, {
3045
+ get documentId() {
3046
+ return $$props.documentId;
3047
+ },
3048
+ get pageIndex() {
3049
+ return $$props.pageIndex;
3050
+ },
3051
+ get scale() {
3052
+ return $.get(actualScale);
3053
+ }
3054
+ });
3055
+ $.reset(div);
3056
+ $.append($$anchor, div);
3057
+ $.pop();
3058
+ }
3059
+ export {
3060
+ AnnotationContainer,
3061
+ AnnotationLayer,
3062
+ AnnotationPaintLayer,
3063
+ Annotations,
3064
+ Circle,
3065
+ FreeText,
3066
+ Highlight,
3067
+ Ink,
3068
+ Line,
3069
+ Polygon,
3070
+ Polyline,
3071
+ PreviewRenderer,
3072
+ RenderAnnotation,
3073
+ Square,
3074
+ Squiggly,
3075
+ Stamp,
3076
+ Strikeout,
3077
+ TextMarkup,
3078
+ Underline,
3079
+ useAnnotation,
3080
+ useAnnotationCapability,
3081
+ useAnnotationPlugin
3082
+ };
3083
+ //# sourceMappingURL=index.js.map