@embedpdf/plugin-annotation 2.6.2 → 2.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +203 -8
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +12 -1
  6. package/dist/lib/annotation-plugin.d.ts +17 -0
  7. package/dist/lib/tools/default-tools.d.ts +2 -0
  8. package/dist/lib/tools/types.d.ts +2 -0
  9. package/dist/lib/types.d.ts +18 -2
  10. package/dist/preact/index.cjs +1 -1
  11. package/dist/preact/index.cjs.map +1 -1
  12. package/dist/preact/index.js +1008 -1058
  13. package/dist/preact/index.js.map +1 -1
  14. package/dist/react/index.cjs +1 -1
  15. package/dist/react/index.cjs.map +1 -1
  16. package/dist/react/index.js +1008 -1058
  17. package/dist/react/index.js.map +1 -1
  18. package/dist/shared/components/annotation-container.d.ts +11 -5
  19. package/dist/shared/components/annotations/circle.d.ts +4 -2
  20. package/dist/shared/components/annotations/free-text.d.ts +4 -1
  21. package/dist/shared/components/annotations/ink.d.ts +3 -1
  22. package/dist/shared/components/annotations/line.d.ts +3 -1
  23. package/dist/shared/components/annotations/polygon.d.ts +3 -2
  24. package/dist/shared/components/annotations/polyline.d.ts +3 -1
  25. package/dist/shared/components/annotations/square.d.ts +4 -2
  26. package/dist/shared/components/annotations.d.ts +0 -1
  27. package/dist/shared/components/appearance-image.d.ts +12 -0
  28. package/dist/shared/components/built-in-renderers.d.ts +2 -0
  29. package/dist/shared/components/text-markup/highlight.d.ts +3 -1
  30. package/dist/shared/components/text-markup/squiggly.d.ts +3 -1
  31. package/dist/shared/components/text-markup/strikeout.d.ts +3 -1
  32. package/dist/shared/components/text-markup/underline.d.ts +3 -1
  33. package/dist/shared/components/types.d.ts +66 -10
  34. package/dist/shared-preact/components/annotation-container.d.ts +11 -5
  35. package/dist/shared-preact/components/annotations/circle.d.ts +4 -2
  36. package/dist/shared-preact/components/annotations/free-text.d.ts +4 -1
  37. package/dist/shared-preact/components/annotations/ink.d.ts +3 -1
  38. package/dist/shared-preact/components/annotations/line.d.ts +3 -1
  39. package/dist/shared-preact/components/annotations/polygon.d.ts +3 -2
  40. package/dist/shared-preact/components/annotations/polyline.d.ts +3 -1
  41. package/dist/shared-preact/components/annotations/square.d.ts +4 -2
  42. package/dist/shared-preact/components/annotations.d.ts +0 -1
  43. package/dist/shared-preact/components/appearance-image.d.ts +12 -0
  44. package/dist/shared-preact/components/built-in-renderers.d.ts +2 -0
  45. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -1
  46. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -1
  47. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -1
  48. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -1
  49. package/dist/shared-preact/components/types.d.ts +66 -10
  50. package/dist/shared-react/components/annotation-container.d.ts +11 -5
  51. package/dist/shared-react/components/annotations/circle.d.ts +4 -2
  52. package/dist/shared-react/components/annotations/free-text.d.ts +4 -1
  53. package/dist/shared-react/components/annotations/ink.d.ts +3 -1
  54. package/dist/shared-react/components/annotations/line.d.ts +3 -1
  55. package/dist/shared-react/components/annotations/polygon.d.ts +3 -2
  56. package/dist/shared-react/components/annotations/polyline.d.ts +3 -1
  57. package/dist/shared-react/components/annotations/square.d.ts +4 -2
  58. package/dist/shared-react/components/annotations.d.ts +0 -1
  59. package/dist/shared-react/components/appearance-image.d.ts +12 -0
  60. package/dist/shared-react/components/built-in-renderers.d.ts +2 -0
  61. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -1
  62. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -1
  63. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -1
  64. package/dist/shared-react/components/text-markup/underline.d.ts +3 -1
  65. package/dist/shared-react/components/types.d.ts +66 -10
  66. package/dist/svelte/components/Annotations.svelte.d.ts +0 -7
  67. package/dist/svelte/components/AppearanceImage.svelte.d.ts +8 -0
  68. package/dist/svelte/components/annotations/Circle.svelte.d.ts +1 -10
  69. package/dist/svelte/components/annotations/FreeText.svelte.d.ts +1 -0
  70. package/dist/svelte/components/annotations/Ink.svelte.d.ts +1 -1
  71. package/dist/svelte/components/annotations/Line.svelte.d.ts +1 -0
  72. package/dist/svelte/components/annotations/Polygon.svelte.d.ts +1 -0
  73. package/dist/svelte/components/annotations/Polyline.svelte.d.ts +1 -1
  74. package/dist/svelte/components/annotations/Square.svelte.d.ts +1 -0
  75. package/dist/svelte/components/built-in-renderers.d.ts +2 -0
  76. package/dist/svelte/components/renderers/CircleRenderer.svelte.d.ts +5 -0
  77. package/dist/svelte/components/renderers/FreeTextRenderer.svelte.d.ts +5 -0
  78. package/dist/svelte/components/renderers/HighlightRenderer.svelte.d.ts +5 -0
  79. package/dist/svelte/components/renderers/InkRenderer.svelte.d.ts +5 -0
  80. package/dist/svelte/components/renderers/LineRenderer.svelte.d.ts +5 -0
  81. package/dist/svelte/components/renderers/LinkRenderer.svelte.d.ts +5 -0
  82. package/dist/svelte/components/renderers/PolygonRenderer.svelte.d.ts +5 -0
  83. package/dist/svelte/components/renderers/PolylineRenderer.svelte.d.ts +5 -0
  84. package/dist/svelte/components/renderers/SquareRenderer.svelte.d.ts +5 -0
  85. package/dist/svelte/components/renderers/SquigglyRenderer.svelte.d.ts +5 -0
  86. package/dist/svelte/components/renderers/StampRenderer.svelte.d.ts +5 -0
  87. package/dist/svelte/components/renderers/StrikeoutRenderer.svelte.d.ts +5 -0
  88. package/dist/svelte/components/renderers/UnderlineRenderer.svelte.d.ts +5 -0
  89. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -0
  90. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -0
  91. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -0
  92. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -0
  93. package/dist/svelte/components/types.d.ts +8 -2
  94. package/dist/svelte/context/renderer-registry.svelte.d.ts +2 -2
  95. package/dist/svelte/context/types.d.ts +63 -2
  96. package/dist/svelte/index.cjs +1 -1
  97. package/dist/svelte/index.cjs.map +1 -1
  98. package/dist/svelte/index.js +2509 -2864
  99. package/dist/svelte/index.js.map +1 -1
  100. package/dist/vue/components/annotation-container.vue.d.ts +8 -3
  101. package/dist/vue/components/annotation-layer.vue.d.ts +1 -20
  102. package/dist/vue/components/annotations/circle.vue.d.ts +18 -5
  103. package/dist/vue/components/annotations/free-text.vue.d.ts +17 -5
  104. package/dist/vue/components/annotations/ink.vue.d.ts +16 -6
  105. package/dist/vue/components/annotations/line.vue.d.ts +20 -5
  106. package/dist/vue/components/annotations/link.vue.d.ts +24 -6
  107. package/dist/vue/components/annotations/polygon.vue.d.ts +21 -5
  108. package/dist/vue/components/annotations/polyline.vue.d.ts +18 -5
  109. package/dist/vue/components/annotations/square.vue.d.ts +18 -5
  110. package/dist/vue/components/annotations/stamp.vue.d.ts +11 -5
  111. package/dist/vue/components/annotations.vue.d.ts +8 -575
  112. package/dist/vue/components/appearance-image.vue.d.ts +9 -0
  113. package/dist/vue/components/built-in-renderers.d.ts +2 -0
  114. package/dist/vue/components/group-selection-box.vue.d.ts +2 -2
  115. package/dist/vue/components/renderers/circle-renderer.vue.d.ts +6 -0
  116. package/dist/vue/components/renderers/free-text-renderer.vue.d.ts +6 -0
  117. package/dist/vue/components/renderers/highlight-renderer.vue.d.ts +6 -0
  118. package/dist/vue/components/renderers/ink-renderer.vue.d.ts +6 -0
  119. package/dist/vue/components/renderers/line-renderer.vue.d.ts +6 -0
  120. package/dist/vue/components/renderers/link-renderer.vue.d.ts +6 -0
  121. package/dist/vue/components/renderers/polygon-renderer.vue.d.ts +6 -0
  122. package/dist/vue/components/renderers/polyline-renderer.vue.d.ts +6 -0
  123. package/dist/vue/components/renderers/square-renderer.vue.d.ts +6 -0
  124. package/dist/vue/components/renderers/squiggly-renderer.vue.d.ts +6 -0
  125. package/dist/vue/components/renderers/stamp-renderer.vue.d.ts +6 -0
  126. package/dist/vue/components/renderers/strikeout-renderer.vue.d.ts +6 -0
  127. package/dist/vue/components/renderers/underline-renderer.vue.d.ts +6 -0
  128. package/dist/vue/components/text-markup/highlight.vue.d.ts +17 -5
  129. package/dist/vue/components/text-markup/squiggly.vue.d.ts +17 -5
  130. package/dist/vue/components/text-markup/strikeout.vue.d.ts +17 -5
  131. package/dist/vue/components/text-markup/underline.vue.d.ts +17 -5
  132. package/dist/vue/context/renderer-registry.d.ts +2 -2
  133. package/dist/vue/context/types.d.ts +63 -2
  134. package/dist/vue/index.cjs +1 -1
  135. package/dist/vue/index.cjs.map +1 -1
  136. package/dist/vue/index.js +1651 -1278
  137. package/dist/vue/index.js.map +1 -1
  138. package/package.json +10 -10
@@ -1,11 +1,11 @@
1
1
  import { createPluginPackage } from "@embedpdf/core";
2
- import { initialDocumentState, AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, isInk, isSquare, isCircle, isUnderline, isStrikeout, isSquiggly, isHighlight, isLine, isPolyline, isPolygon, isFreeText, isStamp, isLink, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
2
+ import { initialDocumentState, AnnotationPlugin, patching, getAnnotationsByPageIndex, getSelectedAnnotationIds, resolveInteractionProp, AnnotationPluginPackage as AnnotationPluginPackage$1 } from "@embedpdf/plugin-annotation";
3
3
  export * from "@embedpdf/plugin-annotation";
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { createContext, useState, useCallback, useContext, useRef, useEffect, useMemo, useLayoutEffect, Fragment as Fragment$1 } from "react";
6
6
  import { createPortal } from "react-dom";
7
7
  import { useCapability, usePlugin, useDocumentPermissions, useDocumentState } from "@embedpdf/core/react";
8
- import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, blendModeToCss, PdfBlendMode, PdfAnnotationSubtype } from "@embedpdf/models";
8
+ import { inferRotationCenterFromRects, boundingRectOrEmpty, PdfAnnotationBorderStyle, PdfVerticalAlignment, textAlignmentToCss, standardFontCssProperties, ignore, PdfErrorCode, PdfAnnotationSubtype, blendModeToCss, PdfBlendMode } from "@embedpdf/models";
9
9
  import { usePointerHandlers } from "@embedpdf/plugin-interaction-manager/react";
10
10
  import { useSelectionCapability } from "@embedpdf/plugin-selection/react";
11
11
  import { useInteractionHandles, useDoublePressProps, CounterRotate } from "@embedpdf/utils/react";
@@ -60,6 +60,43 @@ const useAnnotation = (documentId) => {
60
60
  provides: (provides == null ? void 0 : provides.forDocument(documentId)) ?? null
61
61
  };
62
62
  };
63
+ function AppearanceImage({ appearance, style }) {
64
+ const [imageUrl, setImageUrl] = useState(null);
65
+ const urlRef = useRef(null);
66
+ useEffect(() => {
67
+ const url = URL.createObjectURL(appearance.data);
68
+ setImageUrl(url);
69
+ urlRef.current = url;
70
+ return () => {
71
+ if (urlRef.current) {
72
+ URL.revokeObjectURL(urlRef.current);
73
+ urlRef.current = null;
74
+ }
75
+ };
76
+ }, [appearance.data]);
77
+ const handleImageLoad = () => {
78
+ if (urlRef.current) {
79
+ URL.revokeObjectURL(urlRef.current);
80
+ urlRef.current = null;
81
+ }
82
+ };
83
+ return imageUrl ? /* @__PURE__ */ jsx(
84
+ "img",
85
+ {
86
+ src: imageUrl,
87
+ onLoad: handleImageLoad,
88
+ style: {
89
+ position: "absolute",
90
+ width: "100%",
91
+ height: "100%",
92
+ display: "block",
93
+ pointerEvents: "none",
94
+ userSelect: "none",
95
+ ...style
96
+ }
97
+ }
98
+ ) : null;
99
+ }
63
100
  function AnnotationContainer({
64
101
  scale,
65
102
  documentId,
@@ -70,6 +107,7 @@ function AnnotationContainer({
70
107
  trackedAnnotation,
71
108
  children,
72
109
  isSelected,
110
+ isEditing = false,
73
111
  isMultiSelected = false,
74
112
  isDraggable,
75
113
  isResizable,
@@ -81,6 +119,7 @@ function AnnotationContainer({
81
119
  outlineOffset = 1,
82
120
  onDoubleClick,
83
121
  onSelect,
122
+ appearance,
84
123
  zIndex = 1,
85
124
  resizeUI,
86
125
  vertexUI,
@@ -99,6 +138,7 @@ function AnnotationContainer({
99
138
  const [liveRotation, setLiveRotation] = useState(null);
100
139
  const [cursorScreen, setCursorScreen] = useState(null);
101
140
  const [isHandleHovered, setIsHandleHovered] = useState(false);
141
+ const [gestureActive, setGestureActive] = useState(false);
102
142
  const { provides: annotationCapability } = useAnnotationCapability();
103
143
  const { plugin } = useAnnotationPlugin();
104
144
  const { canModifyAnnotations } = useDocumentPermissions(documentId);
@@ -143,6 +183,9 @@ function AnnotationContainer({
143
183
  if (event.state === "start") {
144
184
  gestureBaseRectRef.current = trackedAnnotation.object.unrotatedRect ?? trackedAnnotation.object.rect;
145
185
  gestureBaseRef.current = trackedAnnotation.object;
186
+ if (type === "resize" || type === "vertex-edit") {
187
+ setGestureActive(true);
188
+ }
146
189
  if (type === "move") {
147
190
  plugin.startDrag(documentId, { annotationIds: [id], pageSize });
148
191
  } else if (type === "resize") {
@@ -203,6 +246,7 @@ function AnnotationContainer({
203
246
  if (event.state === "end") {
204
247
  gestureBaseRectRef.current = null;
205
248
  gestureBaseRef.current = null;
249
+ setGestureActive(false);
206
250
  if (type === "move") plugin.commitDrag(documentId);
207
251
  else if (type === "resize") plugin.commitResize(documentId);
208
252
  }
@@ -316,6 +360,7 @@ function AnnotationContainer({
316
360
  }
317
361
  return currentObject;
318
362
  }, [currentObject, explicitUnrotatedRect]);
363
+ const apActive = !!(appearance == null ? void 0 : appearance.normal) && !gestureActive && !isEditing && !trackedAnnotation.dictMode;
319
364
  return /* @__PURE__ */ jsxs("div", { "data-no-interaction": true, children: [
320
365
  /* @__PURE__ */ jsxs(
321
366
  "div",
@@ -492,7 +537,7 @@ function AnnotationContainer({
492
537
  },
493
538
  children: [
494
539
  (() => {
495
- const childrenRender = typeof children === "function" ? children(childObject) : children;
540
+ const childrenRender = typeof children === "function" ? children(childObject, { appearanceActive: apActive }) : children;
496
541
  const customRender = customAnnotationRenderer == null ? void 0 : customAnnotationRenderer({
497
542
  annotation: childObject,
498
543
  children: childrenRender,
@@ -504,11 +549,15 @@ function AnnotationContainer({
504
549
  pageIndex,
505
550
  onSelect
506
551
  });
507
- if (customRender !== null && customRender !== void 0) {
508
- return customRender;
509
- }
510
- return childrenRender;
552
+ return customRender ?? childrenRender;
511
553
  })(),
554
+ (appearance == null ? void 0 : appearance.normal) && /* @__PURE__ */ jsx(
555
+ AppearanceImage,
556
+ {
557
+ appearance: appearance.normal,
558
+ style: { display: apActive ? "block" : "none" }
559
+ }
560
+ ),
512
561
  isSelected && effectiveIsResizable && !rotationActive && resize.map(
513
562
  ({ key, ...hProps }) => (resizeUI == null ? void 0 : resizeUI.component) ? resizeUI.component({
514
563
  key,
@@ -1065,188 +1114,23 @@ function GroupSelectionBox({
1065
1114
  )
1066
1115
  ] });
1067
1116
  }
1068
- function Highlight({
1069
- strokeColor,
1070
- opacity = 0.5,
1071
- segmentRects,
1072
- rect,
1073
- scale,
1074
- onClick,
1075
- style
1076
- }) {
1077
- const resolvedColor = strokeColor ?? "#FFFF00";
1078
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
1079
- "div",
1080
- {
1081
- onPointerDown: onClick,
1082
- onTouchStart: onClick,
1083
- style: {
1084
- position: "absolute",
1085
- left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
1086
- top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
1087
- width: b.size.width * scale,
1088
- height: b.size.height * scale,
1089
- background: resolvedColor,
1090
- opacity,
1091
- pointerEvents: onClick ? "auto" : "none",
1092
- cursor: onClick ? "pointer" : "default",
1093
- zIndex: onClick ? 1 : void 0,
1094
- ...style
1095
- }
1096
- },
1097
- i
1098
- )) });
1099
- }
1100
- function Underline({
1101
- strokeColor,
1102
- opacity = 0.5,
1103
- segmentRects,
1104
- rect,
1105
- scale,
1106
- onClick,
1107
- style
1108
- }) {
1109
- const resolvedColor = strokeColor ?? "#FFFF00";
1110
- const thickness = 2 * scale;
1111
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1112
- "div",
1113
- {
1114
- onPointerDown: onClick,
1115
- onTouchStart: onClick,
1116
- style: {
1117
- position: "absolute",
1118
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1119
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1120
- width: r.size.width * scale,
1121
- height: r.size.height * scale,
1122
- background: "transparent",
1123
- pointerEvents: onClick ? "auto" : "none",
1124
- cursor: onClick ? "pointer" : "default",
1125
- zIndex: onClick ? 1 : 0,
1126
- ...style
1127
- },
1128
- children: /* @__PURE__ */ jsx(
1129
- "div",
1130
- {
1131
- style: {
1132
- position: "absolute",
1133
- left: 0,
1134
- bottom: 0,
1135
- width: "100%",
1136
- height: thickness,
1137
- background: resolvedColor,
1138
- opacity,
1139
- pointerEvents: "none"
1140
- }
1141
- }
1142
- )
1143
- },
1144
- i
1145
- )) });
1146
- }
1147
- function Strikeout({
1148
- strokeColor,
1149
- opacity = 0.5,
1150
- segmentRects,
1151
- rect,
1152
- scale,
1153
- onClick,
1154
- style
1155
- }) {
1156
- const resolvedColor = strokeColor ?? "#FFFF00";
1157
- const thickness = 2 * scale;
1158
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1159
- "div",
1160
- {
1161
- onPointerDown: onClick,
1162
- onTouchStart: onClick,
1163
- style: {
1164
- position: "absolute",
1165
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1166
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1167
- width: r.size.width * scale,
1168
- height: r.size.height * scale,
1169
- background: "transparent",
1170
- pointerEvents: onClick ? "auto" : "none",
1171
- cursor: onClick ? "pointer" : "default",
1172
- zIndex: onClick ? 1 : 0,
1173
- ...style
1174
- },
1175
- children: /* @__PURE__ */ jsx(
1176
- "div",
1177
- {
1178
- style: {
1179
- position: "absolute",
1180
- left: 0,
1181
- top: "50%",
1182
- width: "100%",
1183
- height: thickness,
1184
- background: resolvedColor,
1185
- opacity,
1186
- transform: "translateY(-50%)",
1187
- pointerEvents: "none"
1188
- }
1189
- }
1190
- )
1191
- },
1192
- i
1193
- )) });
1194
- }
1195
- function Squiggly({
1196
- strokeColor,
1197
- opacity = 0.5,
1198
- segmentRects,
1199
- rect,
1200
- scale,
1201
- onClick,
1202
- style
1203
- }) {
1204
- const resolvedColor = strokeColor ?? "#FFFF00";
1205
- const amplitude = 2 * scale;
1206
- const period = 6 * scale;
1207
- const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
1208
- <path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
1209
- fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
1210
- </svg>`;
1211
- const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
1212
- return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
1213
- "div",
1214
- {
1215
- onPointerDown: onClick,
1216
- onTouchStart: onClick,
1217
- style: {
1218
- position: "absolute",
1219
- left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
1220
- top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
1221
- width: r.size.width * scale,
1222
- height: r.size.height * scale,
1223
- background: "transparent",
1224
- pointerEvents: onClick ? "auto" : "none",
1225
- cursor: onClick ? "pointer" : "default",
1226
- zIndex: onClick ? 1 : 0,
1227
- ...style
1228
- },
1229
- children: /* @__PURE__ */ jsx(
1230
- "div",
1231
- {
1232
- style: {
1233
- position: "absolute",
1234
- left: 0,
1235
- bottom: 0,
1236
- width: "100%",
1237
- height: amplitude * 2,
1238
- backgroundImage: svgDataUri,
1239
- backgroundRepeat: "repeat-x",
1240
- backgroundSize: `${period}px ${amplitude * 2}px`,
1241
- opacity,
1242
- pointerEvents: "none"
1243
- }
1244
- }
1245
- )
1246
- },
1247
- i
1248
- )) });
1117
+ function createRenderer(entry) {
1118
+ return {
1119
+ id: entry.id,
1120
+ matches: (annotation) => entry.matches(annotation),
1121
+ render: (props) => entry.render(props),
1122
+ vertexConfig: entry.vertexConfig,
1123
+ zIndex: entry.zIndex,
1124
+ containerStyle: entry.containerStyle,
1125
+ interactionDefaults: entry.interactionDefaults,
1126
+ useAppearanceStream: entry.useAppearanceStream,
1127
+ isDraggable: entry.isDraggable,
1128
+ onDoubleClick: entry.onDoubleClick,
1129
+ selectOverride: entry.selectOverride,
1130
+ hideSelectionMenu: entry.hideSelectionMenu
1131
+ };
1249
1132
  }
1133
+ const MIN_HIT_AREA_SCREEN_PX$5 = 20;
1250
1134
  function Ink({
1251
1135
  isSelected,
1252
1136
  strokeColor,
@@ -1255,7 +1139,8 @@ function Ink({
1255
1139
  inkList,
1256
1140
  rect,
1257
1141
  scale,
1258
- onClick
1142
+ onClick,
1143
+ appearanceActive = false
1259
1144
  }) {
1260
1145
  const resolvedColor = strokeColor ?? "#000000";
1261
1146
  const paths = useMemo(() => {
@@ -1271,7 +1156,8 @@ function Ink({
1271
1156
  }, [inkList, rect]);
1272
1157
  const width = rect.size.width * scale;
1273
1158
  const height = rect.size.height * scale;
1274
- return /* @__PURE__ */ jsx(
1159
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$5 / scale);
1160
+ return /* @__PURE__ */ jsxs(
1275
1161
  "svg",
1276
1162
  {
1277
1163
  style: {
@@ -1285,28 +1171,46 @@ function Ink({
1285
1171
  width,
1286
1172
  height,
1287
1173
  viewBox: `0 0 ${rect.size.width} ${rect.size.height}`,
1288
- children: paths.map((d, i) => /* @__PURE__ */ jsx(
1289
- "path",
1290
- {
1291
- d,
1292
- fill: "none",
1293
- opacity,
1294
- onPointerDown: onClick,
1295
- onTouchStart: onClick,
1296
- style: {
1297
- cursor: isSelected ? "move" : "pointer",
1298
- pointerEvents: isSelected ? "none" : "visibleStroke",
1299
- stroke: resolvedColor,
1300
- strokeWidth,
1301
- strokeLinecap: "round",
1302
- strokeLinejoin: "round"
1303
- }
1304
- },
1305
- i
1306
- ))
1174
+ children: [
1175
+ paths.map((d, i) => /* @__PURE__ */ jsx(
1176
+ "path",
1177
+ {
1178
+ d,
1179
+ fill: "none",
1180
+ stroke: "transparent",
1181
+ strokeWidth: hitStrokeWidth,
1182
+ onPointerDown: onClick,
1183
+ onTouchStart: onClick,
1184
+ style: {
1185
+ cursor: isSelected ? "move" : "pointer",
1186
+ pointerEvents: isSelected ? "none" : "visibleStroke",
1187
+ strokeLinecap: "round",
1188
+ strokeLinejoin: "round"
1189
+ }
1190
+ },
1191
+ `hit-${i}`
1192
+ )),
1193
+ !appearanceActive && paths.map((d, i) => /* @__PURE__ */ jsx(
1194
+ "path",
1195
+ {
1196
+ d,
1197
+ fill: "none",
1198
+ opacity,
1199
+ style: {
1200
+ pointerEvents: "none",
1201
+ stroke: resolvedColor,
1202
+ strokeWidth,
1203
+ strokeLinecap: "round",
1204
+ strokeLinejoin: "round"
1205
+ }
1206
+ },
1207
+ `vis-${i}`
1208
+ ))
1209
+ ]
1307
1210
  }
1308
1211
  );
1309
1212
  }
1213
+ const MIN_HIT_AREA_SCREEN_PX$4 = 20;
1310
1214
  function Square({
1311
1215
  isSelected,
1312
1216
  color = "#000000",
@@ -1317,7 +1221,8 @@ function Square({
1317
1221
  strokeDashArray,
1318
1222
  rect,
1319
1223
  scale,
1320
- onClick
1224
+ onClick,
1225
+ appearanceActive = false
1321
1226
  }) {
1322
1227
  const { width, height, x, y } = useMemo(() => {
1323
1228
  const outerW = rect.size.width;
@@ -1333,7 +1238,8 @@ function Square({
1333
1238
  }, [rect, strokeWidth]);
1334
1239
  const svgWidth = (width + strokeWidth) * scale;
1335
1240
  const svgHeight = (height + strokeWidth) * scale;
1336
- return /* @__PURE__ */ jsx(
1241
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$4 / scale);
1242
+ return /* @__PURE__ */ jsxs(
1337
1243
  "svg",
1338
1244
  {
1339
1245
  style: {
@@ -1346,31 +1252,50 @@ function Square({
1346
1252
  width: svgWidth,
1347
1253
  height: svgHeight,
1348
1254
  viewBox: `0 0 ${width + strokeWidth} ${height + strokeWidth}`,
1349
- children: /* @__PURE__ */ jsx(
1350
- "rect",
1351
- {
1352
- x,
1353
- y,
1354
- width,
1355
- height,
1356
- fill: color,
1357
- opacity,
1358
- onPointerDown: onClick,
1359
- onTouchStart: onClick,
1360
- style: {
1361
- cursor: isSelected ? "move" : "pointer",
1362
- pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1363
- stroke: strokeColor ?? color,
1364
- strokeWidth,
1365
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1366
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1255
+ overflow: "visible",
1256
+ children: [
1257
+ /* @__PURE__ */ jsx(
1258
+ "rect",
1259
+ {
1260
+ x,
1261
+ y,
1262
+ width,
1263
+ height,
1264
+ fill: "transparent",
1265
+ stroke: "transparent",
1266
+ strokeWidth: hitStrokeWidth,
1267
+ onPointerDown: onClick,
1268
+ onTouchStart: onClick,
1269
+ style: {
1270
+ cursor: isSelected ? "move" : "pointer",
1271
+ pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
1367
1272
  }
1368
1273
  }
1369
- }
1370
- )
1274
+ ),
1275
+ !appearanceActive && /* @__PURE__ */ jsx(
1276
+ "rect",
1277
+ {
1278
+ x,
1279
+ y,
1280
+ width,
1281
+ height,
1282
+ fill: color,
1283
+ opacity,
1284
+ style: {
1285
+ pointerEvents: "none",
1286
+ stroke: strokeColor ?? color,
1287
+ strokeWidth,
1288
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1289
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1290
+ }
1291
+ }
1292
+ }
1293
+ )
1294
+ ]
1371
1295
  }
1372
1296
  );
1373
1297
  }
1298
+ const MIN_HIT_AREA_SCREEN_PX$3 = 20;
1374
1299
  function Circle({
1375
1300
  color = "#000000",
1376
1301
  strokeColor,
@@ -1381,7 +1306,8 @@ function Circle({
1381
1306
  rect,
1382
1307
  scale,
1383
1308
  onClick,
1384
- isSelected
1309
+ isSelected,
1310
+ appearanceActive = false
1385
1311
  }) {
1386
1312
  const { width, height, cx, cy, rx, ry } = useMemo(() => {
1387
1313
  const outerW = rect.size.width;
@@ -1391,7 +1317,6 @@ function Circle({
1391
1317
  return {
1392
1318
  width: outerW,
1393
1319
  height: outerH,
1394
- // Centre of the fill sits strokeWidth/2 in from the edges
1395
1320
  cx: strokeWidth / 2 + innerW / 2,
1396
1321
  cy: strokeWidth / 2 + innerH / 2,
1397
1322
  rx: innerW / 2,
@@ -1400,7 +1325,8 @@ function Circle({
1400
1325
  }, [rect, strokeWidth]);
1401
1326
  const svgWidth = width * scale;
1402
1327
  const svgHeight = height * scale;
1403
- return /* @__PURE__ */ jsx(
1328
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$3 / scale);
1329
+ return /* @__PURE__ */ jsxs(
1404
1330
  "svg",
1405
1331
  {
1406
1332
  style: {
@@ -1413,31 +1339,50 @@ function Circle({
1413
1339
  width: svgWidth,
1414
1340
  height: svgHeight,
1415
1341
  viewBox: `0 0 ${width} ${height}`,
1416
- children: /* @__PURE__ */ jsx(
1417
- "ellipse",
1418
- {
1419
- cx,
1420
- cy,
1421
- rx,
1422
- ry,
1423
- fill: color,
1424
- opacity,
1425
- onPointerDown: onClick,
1426
- onTouchStart: onClick,
1427
- style: {
1428
- cursor: isSelected ? "move" : "pointer",
1429
- pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1430
- stroke: strokeColor ?? color,
1431
- strokeWidth,
1432
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1433
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1342
+ overflow: "visible",
1343
+ children: [
1344
+ /* @__PURE__ */ jsx(
1345
+ "ellipse",
1346
+ {
1347
+ cx,
1348
+ cy,
1349
+ rx,
1350
+ ry,
1351
+ fill: "transparent",
1352
+ stroke: "transparent",
1353
+ strokeWidth: hitStrokeWidth,
1354
+ onPointerDown: onClick,
1355
+ onTouchStart: onClick,
1356
+ style: {
1357
+ cursor: isSelected ? "move" : "pointer",
1358
+ pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible"
1434
1359
  }
1435
1360
  }
1436
- }
1437
- )
1361
+ ),
1362
+ !appearanceActive && /* @__PURE__ */ jsx(
1363
+ "ellipse",
1364
+ {
1365
+ cx,
1366
+ cy,
1367
+ rx,
1368
+ ry,
1369
+ fill: color,
1370
+ opacity,
1371
+ style: {
1372
+ pointerEvents: "none",
1373
+ stroke: strokeColor ?? color,
1374
+ strokeWidth,
1375
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1376
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1377
+ }
1378
+ }
1379
+ }
1380
+ )
1381
+ ]
1438
1382
  }
1439
1383
  );
1440
1384
  }
1385
+ const MIN_HIT_AREA_SCREEN_PX$2 = 20;
1441
1386
  function Line({
1442
1387
  color = "transparent",
1443
1388
  opacity = 1,
@@ -1450,7 +1395,8 @@ function Line({
1450
1395
  lineEndings,
1451
1396
  scale,
1452
1397
  onClick,
1453
- isSelected
1398
+ isSelected,
1399
+ appearanceActive = false
1454
1400
  }) {
1455
1401
  const { x1, y1, x2, y2 } = useMemo(() => {
1456
1402
  return {
@@ -1469,6 +1415,7 @@ function Line({
1469
1415
  }, [lineEndings, strokeWidth, x1, y1, x2, y2]);
1470
1416
  const width = rect.size.width * scale;
1471
1417
  const height = rect.size.height * scale;
1418
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$2 / scale);
1472
1419
  return /* @__PURE__ */ jsxs(
1473
1420
  "svg",
1474
1421
  {
@@ -1491,18 +1438,14 @@ function Line({
1491
1438
  y1,
1492
1439
  x2,
1493
1440
  y2,
1494
- opacity,
1441
+ stroke: "transparent",
1442
+ strokeWidth: hitStrokeWidth,
1495
1443
  onPointerDown: onClick,
1496
1444
  onTouchStart: onClick,
1497
1445
  style: {
1498
1446
  cursor: isSelected ? "move" : "pointer",
1499
1447
  pointerEvents: isSelected ? "none" : "visibleStroke",
1500
- stroke: strokeColor,
1501
- strokeWidth,
1502
- strokeLinecap: "butt",
1503
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1504
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1505
- }
1448
+ strokeLinecap: "butt"
1506
1449
  }
1507
1450
  }
1508
1451
  ),
@@ -1511,19 +1454,16 @@ function Line({
1511
1454
  {
1512
1455
  d: endings.start.d,
1513
1456
  transform: endings.start.transform,
1457
+ fill: "transparent",
1458
+ stroke: "transparent",
1459
+ strokeWidth: hitStrokeWidth,
1514
1460
  onPointerDown: onClick,
1515
1461
  onTouchStart: onClick,
1516
- stroke: strokeColor,
1517
1462
  style: {
1518
1463
  cursor: isSelected ? "move" : "pointer",
1519
- strokeWidth,
1520
- strokeLinecap: "butt",
1521
1464
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1522
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1523
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1524
- }
1525
- },
1526
- fill: endings.start.filled ? color : "none"
1465
+ strokeLinecap: "butt"
1466
+ }
1527
1467
  }
1528
1468
  ),
1529
1469
  endings.end && /* @__PURE__ */ jsx(
@@ -1531,25 +1471,78 @@ function Line({
1531
1471
  {
1532
1472
  d: endings.end.d,
1533
1473
  transform: endings.end.transform,
1534
- stroke: strokeColor,
1474
+ fill: "transparent",
1475
+ stroke: "transparent",
1476
+ strokeWidth: hitStrokeWidth,
1535
1477
  onPointerDown: onClick,
1536
1478
  onTouchStart: onClick,
1537
1479
  style: {
1538
1480
  cursor: isSelected ? "move" : "pointer",
1539
- strokeWidth,
1540
- strokeLinecap: "butt",
1541
1481
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1542
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1543
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1544
- }
1545
- },
1546
- fill: endings.end.filled ? color : "none"
1482
+ strokeLinecap: "butt"
1483
+ }
1547
1484
  }
1548
- )
1485
+ ),
1486
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1487
+ /* @__PURE__ */ jsx(
1488
+ "line",
1489
+ {
1490
+ x1,
1491
+ y1,
1492
+ x2,
1493
+ y2,
1494
+ opacity,
1495
+ style: {
1496
+ pointerEvents: "none",
1497
+ stroke: strokeColor,
1498
+ strokeWidth,
1499
+ strokeLinecap: "butt",
1500
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1501
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1502
+ }
1503
+ }
1504
+ }
1505
+ ),
1506
+ endings.start && /* @__PURE__ */ jsx(
1507
+ "path",
1508
+ {
1509
+ d: endings.start.d,
1510
+ transform: endings.start.transform,
1511
+ stroke: strokeColor,
1512
+ fill: endings.start.filled ? color : "none",
1513
+ style: {
1514
+ pointerEvents: "none",
1515
+ strokeWidth,
1516
+ strokeLinecap: "butt",
1517
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1518
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1519
+ }
1520
+ }
1521
+ }
1522
+ ),
1523
+ endings.end && /* @__PURE__ */ jsx(
1524
+ "path",
1525
+ {
1526
+ d: endings.end.d,
1527
+ transform: endings.end.transform,
1528
+ stroke: strokeColor,
1529
+ fill: endings.end.filled ? color : "none",
1530
+ style: {
1531
+ pointerEvents: "none",
1532
+ strokeWidth,
1533
+ strokeLinecap: "butt",
1534
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1535
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1536
+ }
1537
+ }
1538
+ }
1539
+ )
1540
+ ] })
1549
1541
  ]
1550
1542
  }
1551
1543
  );
1552
1544
  }
1545
+ const MIN_HIT_AREA_SCREEN_PX$1 = 20;
1553
1546
  function Polyline({
1554
1547
  rect,
1555
1548
  vertices,
@@ -1560,7 +1553,8 @@ function Polyline({
1560
1553
  scale,
1561
1554
  isSelected,
1562
1555
  onClick,
1563
- lineEndings
1556
+ lineEndings,
1557
+ appearanceActive = false
1564
1558
  }) {
1565
1559
  const localPts = useMemo(
1566
1560
  () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),
@@ -1580,7 +1574,6 @@ function Polyline({
1580
1574
  lineEndings == null ? void 0 : lineEndings.start,
1581
1575
  strokeWidth,
1582
1576
  startRad + Math.PI,
1583
- // tip points outward from line start
1584
1577
  localPts[0].x,
1585
1578
  localPts[0].y
1586
1579
  );
@@ -1588,7 +1581,6 @@ function Polyline({
1588
1581
  lineEndings == null ? void 0 : lineEndings.end,
1589
1582
  strokeWidth,
1590
1583
  endRad,
1591
- // tip points in line direction
1592
1584
  localPts[localPts.length - 1].x,
1593
1585
  localPts[localPts.length - 1].y
1594
1586
  );
@@ -1596,6 +1588,7 @@ function Polyline({
1596
1588
  }, [localPts, lineEndings, strokeWidth]);
1597
1589
  const width = rect.size.width * scale;
1598
1590
  const height = rect.size.height * scale;
1591
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX$1 / scale);
1599
1592
  return /* @__PURE__ */ jsxs(
1600
1593
  "svg",
1601
1594
  {
@@ -1615,13 +1608,12 @@ function Polyline({
1615
1608
  "path",
1616
1609
  {
1617
1610
  d: pathData,
1611
+ fill: "none",
1612
+ stroke: "transparent",
1613
+ strokeWidth: hitStrokeWidth,
1618
1614
  onPointerDown: onClick,
1619
1615
  onTouchStart: onClick,
1620
- opacity,
1621
1616
  style: {
1622
- fill: "none",
1623
- stroke: strokeColor ?? color,
1624
- strokeWidth,
1625
1617
  cursor: isSelected ? "move" : "pointer",
1626
1618
  pointerEvents: isSelected ? "none" : "visibleStroke",
1627
1619
  strokeLinecap: "butt",
@@ -1634,13 +1626,13 @@ function Polyline({
1634
1626
  {
1635
1627
  d: endings.start.d,
1636
1628
  transform: endings.start.transform,
1637
- stroke: strokeColor,
1638
- fill: endings.start.filled ? color : "none",
1629
+ fill: "transparent",
1630
+ stroke: "transparent",
1631
+ strokeWidth: hitStrokeWidth,
1639
1632
  onPointerDown: onClick,
1640
1633
  onTouchStart: onClick,
1641
1634
  style: {
1642
1635
  cursor: isSelected ? "move" : "pointer",
1643
- strokeWidth,
1644
1636
  pointerEvents: isSelected ? "none" : endings.start.filled ? "visible" : "visibleStroke",
1645
1637
  strokeLinecap: "butt"
1646
1638
  }
@@ -1651,22 +1643,68 @@ function Polyline({
1651
1643
  {
1652
1644
  d: endings.end.d,
1653
1645
  transform: endings.end.transform,
1654
- stroke: strokeColor,
1655
- fill: endings.end.filled ? color : "none",
1646
+ fill: "transparent",
1647
+ stroke: "transparent",
1648
+ strokeWidth: hitStrokeWidth,
1656
1649
  onPointerDown: onClick,
1657
1650
  onTouchStart: onClick,
1658
1651
  style: {
1659
1652
  cursor: isSelected ? "move" : "pointer",
1660
- strokeWidth,
1661
1653
  pointerEvents: isSelected ? "none" : endings.end.filled ? "visible" : "visibleStroke",
1662
1654
  strokeLinecap: "butt"
1663
1655
  }
1664
1656
  }
1665
- )
1657
+ ),
1658
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1659
+ /* @__PURE__ */ jsx(
1660
+ "path",
1661
+ {
1662
+ d: pathData,
1663
+ opacity,
1664
+ style: {
1665
+ fill: "none",
1666
+ stroke: strokeColor ?? color,
1667
+ strokeWidth,
1668
+ pointerEvents: "none",
1669
+ strokeLinecap: "butt",
1670
+ strokeLinejoin: "miter"
1671
+ }
1672
+ }
1673
+ ),
1674
+ endings.start && /* @__PURE__ */ jsx(
1675
+ "path",
1676
+ {
1677
+ d: endings.start.d,
1678
+ transform: endings.start.transform,
1679
+ stroke: strokeColor,
1680
+ fill: endings.start.filled ? color : "none",
1681
+ style: {
1682
+ pointerEvents: "none",
1683
+ strokeWidth,
1684
+ strokeLinecap: "butt"
1685
+ }
1686
+ }
1687
+ ),
1688
+ endings.end && /* @__PURE__ */ jsx(
1689
+ "path",
1690
+ {
1691
+ d: endings.end.d,
1692
+ transform: endings.end.transform,
1693
+ stroke: strokeColor,
1694
+ fill: endings.end.filled ? color : "none",
1695
+ style: {
1696
+ pointerEvents: "none",
1697
+ strokeWidth,
1698
+ strokeLinecap: "butt"
1699
+ }
1700
+ }
1701
+ )
1702
+ ] })
1666
1703
  ]
1667
1704
  }
1668
1705
  );
1669
1706
  }
1707
+ const MIN_HIT_AREA_SCREEN_PX = 20;
1670
1708
  function Polygon({
1671
1709
  rect,
1672
1710
  vertices,
@@ -1680,9 +1718,8 @@ function Polygon({
1680
1718
  isSelected,
1681
1719
  onClick,
1682
1720
  currentVertex,
1683
- // A preview-only prop
1684
- handleSize = 14
1685
- // in CSS pixels
1721
+ handleSize = 14,
1722
+ appearanceActive = false
1686
1723
  }) {
1687
1724
  const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;
1688
1725
  const localPts = useMemo(
@@ -1698,6 +1735,7 @@ function Polygon({
1698
1735
  const isPreviewing = currentVertex && vertices.length > 0;
1699
1736
  const width = rect.size.width * scale;
1700
1737
  const height = rect.size.height * scale;
1738
+ const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);
1701
1739
  return /* @__PURE__ */ jsxs(
1702
1740
  "svg",
1703
1741
  {
@@ -1717,62 +1755,89 @@ function Polygon({
1717
1755
  "path",
1718
1756
  {
1719
1757
  d: pathData,
1758
+ fill: "transparent",
1759
+ stroke: "transparent",
1760
+ strokeWidth: hitStrokeWidth,
1720
1761
  onPointerDown: onClick,
1721
1762
  onTouchStart: onClick,
1722
- opacity,
1723
1763
  style: {
1724
- fill: currentVertex ? "none" : color,
1725
- // No fill during preview
1726
- stroke: strokeColor ?? color,
1727
- strokeWidth,
1728
1764
  cursor: isSelected ? "move" : "pointer",
1729
1765
  pointerEvents: isSelected ? "none" : color === "transparent" ? "visibleStroke" : "visible",
1730
1766
  strokeLinecap: "butt",
1731
- strokeLinejoin: "miter",
1732
- ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1733
- strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1734
- }
1767
+ strokeLinejoin: "miter"
1735
1768
  }
1736
1769
  }
1737
1770
  ),
1738
- isPreviewing && vertices.length > 1 && /* @__PURE__ */ jsx(
1739
- "path",
1740
- {
1741
- d: `M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`,
1742
- fill: "none",
1743
- style: { stroke: strokeColor, strokeWidth, strokeDasharray: "4,4", opacity: 0.7 }
1744
- }
1745
- ),
1746
- isPreviewing && vertices.length >= 2 && /* @__PURE__ */ jsx(
1747
- "rect",
1748
- {
1749
- x: localPts[0].x - handleSize / scale / 2,
1750
- y: localPts[0].y - handleSize / scale / 2,
1751
- width: handleSize / scale,
1752
- height: handleSize / scale,
1753
- fill: strokeColor,
1754
- opacity: 0.4,
1755
- stroke: strokeColor,
1756
- strokeWidth: strokeWidth / 2
1757
- }
1758
- )
1771
+ !appearanceActive && /* @__PURE__ */ jsxs(Fragment, { children: [
1772
+ /* @__PURE__ */ jsx(
1773
+ "path",
1774
+ {
1775
+ d: pathData,
1776
+ opacity,
1777
+ style: {
1778
+ fill: currentVertex ? "none" : color,
1779
+ stroke: strokeColor ?? color,
1780
+ strokeWidth,
1781
+ pointerEvents: "none",
1782
+ strokeLinecap: "butt",
1783
+ strokeLinejoin: "miter",
1784
+ ...strokeStyle === PdfAnnotationBorderStyle.DASHED && {
1785
+ strokeDasharray: strokeDashArray == null ? void 0 : strokeDashArray.join(",")
1786
+ }
1787
+ }
1788
+ }
1789
+ ),
1790
+ isPreviewing && vertices.length > 1 && /* @__PURE__ */ jsx(
1791
+ "path",
1792
+ {
1793
+ d: `M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`,
1794
+ fill: "none",
1795
+ style: {
1796
+ stroke: strokeColor,
1797
+ strokeWidth,
1798
+ strokeDasharray: "4,4",
1799
+ opacity: 0.7,
1800
+ pointerEvents: "none"
1801
+ }
1802
+ }
1803
+ ),
1804
+ isPreviewing && vertices.length >= 2 && /* @__PURE__ */ jsx(
1805
+ "rect",
1806
+ {
1807
+ x: localPts[0].x - handleSize / scale / 2,
1808
+ y: localPts[0].y - handleSize / scale / 2,
1809
+ width: handleSize / scale,
1810
+ height: handleSize / scale,
1811
+ fill: strokeColor,
1812
+ opacity: 0.4,
1813
+ stroke: strokeColor,
1814
+ strokeWidth: strokeWidth / 2,
1815
+ style: { pointerEvents: "none" }
1816
+ }
1817
+ )
1818
+ ] })
1759
1819
  ]
1760
1820
  }
1761
1821
  );
1762
1822
  }
1763
1823
  function FreeText({
1824
+ documentId,
1764
1825
  isSelected,
1765
1826
  isEditing,
1766
1827
  annotation,
1767
1828
  pageIndex,
1768
1829
  scale,
1769
- onClick
1830
+ onClick,
1831
+ appearanceActive = false
1770
1832
  }) {
1771
1833
  const editorRef = useRef(null);
1772
- const { provides: annotationProvides } = useAnnotationCapability();
1834
+ const editingRef = useRef(false);
1835
+ const { provides: annotationCapability } = useAnnotationCapability();
1836
+ const annotationProvides = (annotationCapability == null ? void 0 : annotationCapability.forDocument(documentId)) ?? null;
1773
1837
  const [isIOS, setIsIOS] = useState(false);
1774
1838
  useEffect(() => {
1775
1839
  if (isEditing && editorRef.current) {
1840
+ editingRef.current = true;
1776
1841
  const editor = editorRef.current;
1777
1842
  editor.focus();
1778
1843
  const selection = window.getSelection();
@@ -1795,6 +1860,8 @@ function FreeText({
1795
1860
  }
1796
1861
  }, []);
1797
1862
  const handleBlur = () => {
1863
+ if (!editingRef.current) return;
1864
+ editingRef.current = false;
1798
1865
  if (!annotationProvides) return;
1799
1866
  if (!editorRef.current) return;
1800
1867
  annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {
@@ -1816,7 +1883,8 @@ function FreeText({
1816
1883
  height: annotation.object.rect.size.height * scale,
1817
1884
  cursor: isSelected && !isEditing ? "move" : "default",
1818
1885
  pointerEvents: isSelected && !isEditing ? "none" : "auto",
1819
- zIndex: 2
1886
+ zIndex: 2,
1887
+ opacity: appearanceActive ? 0 : 1
1820
1888
  },
1821
1889
  onPointerDown: onClick,
1822
1890
  onTouchStart: onClick,
@@ -1985,7 +2053,7 @@ function Link({
1985
2053
  }
1986
2054
  return void 0;
1987
2055
  }, [strokeStyle, strokeDashArray, strokeWidth]);
1988
- const isUnderline2 = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
2056
+ const isUnderline = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;
1989
2057
  return /* @__PURE__ */ jsxs(
1990
2058
  "svg",
1991
2059
  {
@@ -2016,7 +2084,7 @@ function Link({
2016
2084
  }
2017
2085
  }
2018
2086
  ),
2019
- isUnderline2 ? (
2087
+ isUnderline ? (
2020
2088
  // Underline style: line at bottom of rect
2021
2089
  /* @__PURE__ */ jsx(
2022
2090
  "line",
@@ -2056,83 +2124,528 @@ function Link({
2056
2124
  }
2057
2125
  );
2058
2126
  }
2059
- function Annotations(annotationsProps) {
2060
- const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
2061
- const { provides: annotationCapability } = useAnnotationCapability();
2062
- const { provides: selectionProvides } = useSelectionCapability();
2063
- const [annotations, setAnnotations] = useState([]);
2064
- const { register } = usePointerHandlers({ documentId, pageIndex });
2065
- const [allSelectedIds, setAllSelectedIds] = useState([]);
2066
- const [editingId, setEditingId] = useState(null);
2067
- const annotationProvides = useMemo(
2068
- () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
2069
- [annotationCapability, documentId]
2070
- );
2071
- const isMultiSelected = allSelectedIds.length > 1;
2072
- useEffect(() => {
2073
- if (annotationProvides) {
2074
- const currentState = annotationProvides.getState();
2075
- setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
2076
- setAllSelectedIds(getSelectedAnnotationIds(currentState));
2077
- return annotationProvides.onStateChange((state) => {
2078
- setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
2079
- setAllSelectedIds(getSelectedAnnotationIds(state));
2080
- });
2081
- }
2082
- }, [annotationProvides, pageIndex]);
2083
- const handlers = useMemo(
2084
- () => ({
2085
- onPointerDown: (_, pe) => {
2086
- if (pe.target === pe.currentTarget && annotationProvides) {
2087
- annotationProvides.deselectAnnotation();
2088
- setEditingId(null);
2089
- }
2090
- }
2091
- }),
2092
- [annotationProvides]
2093
- );
2094
- const handleClick = useCallback(
2095
- (e, annotation) => {
2096
- e.stopPropagation();
2097
- if (annotationProvides && selectionProvides) {
2098
- selectionProvides.clear();
2099
- const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
2100
- if (isModifierPressed) {
2101
- annotationProvides.toggleSelection(pageIndex, annotation.object.id);
2102
- } else {
2103
- annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2104
- }
2105
- if (annotation.object.id !== editingId) {
2106
- setEditingId(null);
2107
- }
2108
- }
2109
- },
2110
- [annotationProvides, selectionProvides, editingId, pageIndex]
2111
- );
2112
- const handleLinkClick = useCallback(
2113
- (e, annotation) => {
2114
- e.stopPropagation();
2115
- if (!annotationProvides || !selectionProvides) return;
2116
- selectionProvides.clear();
2117
- if (annotation.object.inReplyToId) {
2118
- const parentId = annotation.object.inReplyToId;
2119
- const parent = annotations.find((a) => a.object.id === parentId);
2120
- if (parent) {
2121
- annotationProvides.selectAnnotation(parent.object.pageIndex, parentId);
2122
- return;
2123
- }
2127
+ function Highlight({
2128
+ strokeColor,
2129
+ opacity = 0.5,
2130
+ segmentRects,
2131
+ rect,
2132
+ scale,
2133
+ onClick,
2134
+ style,
2135
+ appearanceActive = false
2136
+ }) {
2137
+ const resolvedColor = strokeColor ?? "#FFFF00";
2138
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((b, i) => /* @__PURE__ */ jsx(
2139
+ "div",
2140
+ {
2141
+ onPointerDown: onClick,
2142
+ onTouchStart: onClick,
2143
+ style: {
2144
+ position: "absolute",
2145
+ left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,
2146
+ top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,
2147
+ width: b.size.width * scale,
2148
+ height: b.size.height * scale,
2149
+ background: appearanceActive ? "transparent" : resolvedColor,
2150
+ opacity: appearanceActive ? void 0 : opacity,
2151
+ pointerEvents: onClick ? "auto" : "none",
2152
+ cursor: onClick ? "pointer" : "default",
2153
+ zIndex: onClick ? 1 : void 0,
2154
+ ...style
2124
2155
  }
2125
- annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2126
2156
  },
2127
- [annotationProvides, selectionProvides, annotations, pageIndex]
2128
- );
2129
- useEffect(() => {
2130
- return register(handlers, {
2131
- documentId
2132
- });
2133
- }, [register, handlers]);
2134
- const selectedAnnotationsOnPage = useMemo(() => {
2135
- return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
2157
+ i
2158
+ )) });
2159
+ }
2160
+ function Underline({
2161
+ strokeColor,
2162
+ opacity = 0.5,
2163
+ segmentRects,
2164
+ rect,
2165
+ scale,
2166
+ onClick,
2167
+ style,
2168
+ appearanceActive = false
2169
+ }) {
2170
+ const resolvedColor = strokeColor ?? "#FFFF00";
2171
+ const thickness = 2 * scale;
2172
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2173
+ "div",
2174
+ {
2175
+ onPointerDown: onClick,
2176
+ onTouchStart: onClick,
2177
+ style: {
2178
+ position: "absolute",
2179
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2180
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2181
+ width: r.size.width * scale,
2182
+ height: r.size.height * scale,
2183
+ background: "transparent",
2184
+ pointerEvents: onClick ? "auto" : "none",
2185
+ cursor: onClick ? "pointer" : "default",
2186
+ zIndex: onClick ? 1 : 0,
2187
+ ...style
2188
+ },
2189
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2190
+ "div",
2191
+ {
2192
+ style: {
2193
+ position: "absolute",
2194
+ left: 0,
2195
+ bottom: 0,
2196
+ width: "100%",
2197
+ height: thickness,
2198
+ background: resolvedColor,
2199
+ opacity,
2200
+ pointerEvents: "none"
2201
+ }
2202
+ }
2203
+ )
2204
+ },
2205
+ i
2206
+ )) });
2207
+ }
2208
+ function Strikeout({
2209
+ strokeColor,
2210
+ opacity = 0.5,
2211
+ segmentRects,
2212
+ rect,
2213
+ scale,
2214
+ onClick,
2215
+ style,
2216
+ appearanceActive = false
2217
+ }) {
2218
+ const resolvedColor = strokeColor ?? "#FFFF00";
2219
+ const thickness = 2 * scale;
2220
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2221
+ "div",
2222
+ {
2223
+ onPointerDown: onClick,
2224
+ onTouchStart: onClick,
2225
+ style: {
2226
+ position: "absolute",
2227
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2228
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2229
+ width: r.size.width * scale,
2230
+ height: r.size.height * scale,
2231
+ background: "transparent",
2232
+ pointerEvents: onClick ? "auto" : "none",
2233
+ cursor: onClick ? "pointer" : "default",
2234
+ zIndex: onClick ? 1 : 0,
2235
+ ...style
2236
+ },
2237
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2238
+ "div",
2239
+ {
2240
+ style: {
2241
+ position: "absolute",
2242
+ left: 0,
2243
+ top: "50%",
2244
+ width: "100%",
2245
+ height: thickness,
2246
+ background: resolvedColor,
2247
+ opacity,
2248
+ transform: "translateY(-50%)",
2249
+ pointerEvents: "none"
2250
+ }
2251
+ }
2252
+ )
2253
+ },
2254
+ i
2255
+ )) });
2256
+ }
2257
+ function Squiggly({
2258
+ strokeColor,
2259
+ opacity = 0.5,
2260
+ segmentRects,
2261
+ rect,
2262
+ scale,
2263
+ onClick,
2264
+ style,
2265
+ appearanceActive = false
2266
+ }) {
2267
+ const resolvedColor = strokeColor ?? "#FFFF00";
2268
+ const amplitude = 2 * scale;
2269
+ const period = 6 * scale;
2270
+ const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${period}" height="${amplitude * 2}" viewBox="0 0 ${period} ${amplitude * 2}">
2271
+ <path d="M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}"
2272
+ fill="none" stroke="${resolvedColor}" stroke-width="${amplitude}" stroke-linecap="round"/>
2273
+ </svg>`;
2274
+ const svgDataUri = `url("data:image/svg+xml;utf8,${encodeURIComponent(svg)}")`;
2275
+ return /* @__PURE__ */ jsx(Fragment, { children: segmentRects.map((r, i) => /* @__PURE__ */ jsx(
2276
+ "div",
2277
+ {
2278
+ onPointerDown: onClick,
2279
+ onTouchStart: onClick,
2280
+ style: {
2281
+ position: "absolute",
2282
+ left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,
2283
+ top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,
2284
+ width: r.size.width * scale,
2285
+ height: r.size.height * scale,
2286
+ background: "transparent",
2287
+ pointerEvents: onClick ? "auto" : "none",
2288
+ cursor: onClick ? "pointer" : "default",
2289
+ zIndex: onClick ? 1 : 0,
2290
+ ...style
2291
+ },
2292
+ children: !appearanceActive && /* @__PURE__ */ jsx(
2293
+ "div",
2294
+ {
2295
+ style: {
2296
+ position: "absolute",
2297
+ left: 0,
2298
+ bottom: 0,
2299
+ width: "100%",
2300
+ height: amplitude * 2,
2301
+ backgroundImage: svgDataUri,
2302
+ backgroundRepeat: "repeat-x",
2303
+ backgroundSize: `${period}px ${amplitude * 2}px`,
2304
+ opacity,
2305
+ pointerEvents: "none"
2306
+ }
2307
+ }
2308
+ )
2309
+ },
2310
+ i
2311
+ )) });
2312
+ }
2313
+ const builtInRenderers = [
2314
+ // --- Drawing ---
2315
+ createRenderer({
2316
+ id: "ink",
2317
+ matches: (a) => a.type === PdfAnnotationSubtype.INK,
2318
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2319
+ Ink,
2320
+ {
2321
+ ...currentObject,
2322
+ isSelected,
2323
+ scale,
2324
+ onClick,
2325
+ appearanceActive
2326
+ }
2327
+ ),
2328
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2329
+ }),
2330
+ // --- Shapes ---
2331
+ createRenderer({
2332
+ id: "square",
2333
+ matches: (a) => a.type === PdfAnnotationSubtype.SQUARE,
2334
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2335
+ Square,
2336
+ {
2337
+ ...currentObject,
2338
+ isSelected,
2339
+ scale,
2340
+ onClick,
2341
+ appearanceActive
2342
+ }
2343
+ ),
2344
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2345
+ }),
2346
+ createRenderer({
2347
+ id: "circle",
2348
+ matches: (a) => a.type === PdfAnnotationSubtype.CIRCLE,
2349
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2350
+ Circle,
2351
+ {
2352
+ ...currentObject,
2353
+ isSelected,
2354
+ scale,
2355
+ onClick,
2356
+ appearanceActive
2357
+ }
2358
+ ),
2359
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2360
+ }),
2361
+ // --- Lines & Vertex-based ---
2362
+ createRenderer({
2363
+ id: "line",
2364
+ matches: (a) => a.type === PdfAnnotationSubtype.LINE,
2365
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2366
+ Line,
2367
+ {
2368
+ ...currentObject,
2369
+ isSelected,
2370
+ scale,
2371
+ onClick,
2372
+ appearanceActive
2373
+ }
2374
+ ) }),
2375
+ vertexConfig: {
2376
+ extractVertices: (a) => [a.linePoints.start, a.linePoints.end],
2377
+ transformAnnotation: (a, v) => ({
2378
+ ...a,
2379
+ linePoints: { start: v[0], end: v[1] }
2380
+ })
2381
+ },
2382
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2383
+ }),
2384
+ createRenderer({
2385
+ id: "polyline",
2386
+ matches: (a) => a.type === PdfAnnotationSubtype.POLYLINE,
2387
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2388
+ Polyline,
2389
+ {
2390
+ ...currentObject,
2391
+ isSelected,
2392
+ scale,
2393
+ onClick,
2394
+ appearanceActive
2395
+ }
2396
+ ) }),
2397
+ vertexConfig: {
2398
+ extractVertices: (a) => a.vertices,
2399
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
2400
+ },
2401
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2402
+ }),
2403
+ createRenderer({
2404
+ id: "polygon",
2405
+ matches: (a) => a.type === PdfAnnotationSubtype.POLYGON,
2406
+ render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2407
+ Polygon,
2408
+ {
2409
+ ...currentObject,
2410
+ isSelected,
2411
+ scale,
2412
+ onClick,
2413
+ appearanceActive
2414
+ }
2415
+ ) }),
2416
+ vertexConfig: {
2417
+ extractVertices: (a) => a.vertices,
2418
+ transformAnnotation: (a, vertices) => ({ ...a, vertices })
2419
+ },
2420
+ interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true }
2421
+ }),
2422
+ // --- Text Markup ---
2423
+ createRenderer({
2424
+ id: "highlight",
2425
+ matches: (a) => a.type === PdfAnnotationSubtype.HIGHLIGHT,
2426
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2427
+ Highlight,
2428
+ {
2429
+ ...currentObject,
2430
+ scale,
2431
+ onClick,
2432
+ appearanceActive
2433
+ }
2434
+ ),
2435
+ zIndex: 0,
2436
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },
2437
+ containerStyle: (a) => ({
2438
+ mixBlendMode: blendModeToCss(a.blendMode ?? PdfBlendMode.Multiply)
2439
+ })
2440
+ }),
2441
+ createRenderer({
2442
+ id: "underline",
2443
+ matches: (a) => a.type === PdfAnnotationSubtype.UNDERLINE,
2444
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2445
+ Underline,
2446
+ {
2447
+ ...currentObject,
2448
+ scale,
2449
+ onClick,
2450
+ appearanceActive
2451
+ }
2452
+ ),
2453
+ zIndex: 0,
2454
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2455
+ }),
2456
+ createRenderer({
2457
+ id: "strikeout",
2458
+ matches: (a) => a.type === PdfAnnotationSubtype.STRIKEOUT,
2459
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2460
+ Strikeout,
2461
+ {
2462
+ ...currentObject,
2463
+ scale,
2464
+ onClick,
2465
+ appearanceActive
2466
+ }
2467
+ ),
2468
+ zIndex: 0,
2469
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2470
+ }),
2471
+ createRenderer({
2472
+ id: "squiggly",
2473
+ matches: (a) => a.type === PdfAnnotationSubtype.SQUIGGLY,
2474
+ render: ({ currentObject, scale, onClick, appearanceActive }) => /* @__PURE__ */ jsx(
2475
+ Squiggly,
2476
+ {
2477
+ ...currentObject,
2478
+ scale,
2479
+ onClick,
2480
+ appearanceActive
2481
+ }
2482
+ ),
2483
+ zIndex: 0,
2484
+ interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false }
2485
+ }),
2486
+ // --- FreeText ---
2487
+ createRenderer({
2488
+ id: "freeText",
2489
+ matches: (a) => a.type === PdfAnnotationSubtype.FREETEXT,
2490
+ render: ({
2491
+ annotation,
2492
+ currentObject,
2493
+ isSelected,
2494
+ isEditing,
2495
+ scale,
2496
+ pageIndex,
2497
+ documentId,
2498
+ onClick,
2499
+ appearanceActive
2500
+ }) => /* @__PURE__ */ jsx(
2501
+ FreeText,
2502
+ {
2503
+ documentId,
2504
+ isSelected,
2505
+ isEditing,
2506
+ annotation: { ...annotation, object: currentObject },
2507
+ pageIndex,
2508
+ scale,
2509
+ onClick,
2510
+ appearanceActive
2511
+ }
2512
+ ),
2513
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },
2514
+ isDraggable: (toolDraggable, { isEditing }) => toolDraggable && !isEditing,
2515
+ onDoubleClick: (id, setEditingId) => setEditingId(id)
2516
+ }),
2517
+ // --- Stamp ---
2518
+ createRenderer({
2519
+ id: "stamp",
2520
+ matches: (a) => a.type === PdfAnnotationSubtype.STAMP,
2521
+ render: ({ annotation, isSelected, documentId, pageIndex, scale, onClick }) => /* @__PURE__ */ jsx(
2522
+ Stamp,
2523
+ {
2524
+ isSelected,
2525
+ annotation,
2526
+ documentId,
2527
+ pageIndex,
2528
+ scale,
2529
+ onClick
2530
+ }
2531
+ ),
2532
+ useAppearanceStream: false,
2533
+ interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true }
2534
+ }),
2535
+ // --- Link ---
2536
+ createRenderer({
2537
+ id: "link",
2538
+ matches: (a) => a.type === PdfAnnotationSubtype.LINK,
2539
+ render: ({ currentObject, isSelected, scale, onClick }) => /* @__PURE__ */ jsx(
2540
+ Link,
2541
+ {
2542
+ ...currentObject,
2543
+ isSelected,
2544
+ scale,
2545
+ onClick,
2546
+ hasIRT: !!currentObject.inReplyToId
2547
+ }
2548
+ ),
2549
+ interactionDefaults: {
2550
+ isDraggable: false,
2551
+ isResizable: false,
2552
+ isRotatable: false
2553
+ },
2554
+ useAppearanceStream: false,
2555
+ selectOverride: (e, annotation, helpers) => {
2556
+ e.stopPropagation();
2557
+ helpers.clearSelection();
2558
+ if (annotation.object.inReplyToId) {
2559
+ const parent = helpers.allAnnotations.find(
2560
+ (a) => a.object.id === annotation.object.inReplyToId
2561
+ );
2562
+ if (parent) {
2563
+ helpers.selectAnnotation(parent.object.pageIndex, parent.object.id);
2564
+ return;
2565
+ }
2566
+ }
2567
+ helpers.selectAnnotation(helpers.pageIndex, annotation.object.id);
2568
+ },
2569
+ hideSelectionMenu: (a) => !!a.inReplyToId
2570
+ })
2571
+ ];
2572
+ function Annotations(annotationsProps) {
2573
+ const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;
2574
+ const { provides: annotationCapability } = useAnnotationCapability();
2575
+ const { provides: selectionProvides } = useSelectionCapability();
2576
+ const [annotations, setAnnotations] = useState([]);
2577
+ const { register } = usePointerHandlers({ documentId, pageIndex });
2578
+ const [allSelectedIds, setAllSelectedIds] = useState([]);
2579
+ const [editingId, setEditingId] = useState(null);
2580
+ const [appearanceMap, setAppearanceMap] = useState({});
2581
+ const prevScaleRef = useRef(scale);
2582
+ const annotationProvides = useMemo(
2583
+ () => annotationCapability ? annotationCapability.forDocument(documentId) : null,
2584
+ [annotationCapability, documentId]
2585
+ );
2586
+ const isMultiSelected = allSelectedIds.length > 1;
2587
+ useEffect(() => {
2588
+ if (annotationProvides) {
2589
+ const currentState = annotationProvides.getState();
2590
+ setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));
2591
+ setAllSelectedIds(getSelectedAnnotationIds(currentState));
2592
+ return annotationProvides.onStateChange((state) => {
2593
+ setAnnotations(getAnnotationsByPageIndex(state, pageIndex));
2594
+ setAllSelectedIds(getSelectedAnnotationIds(state));
2595
+ });
2596
+ }
2597
+ }, [annotationProvides, pageIndex]);
2598
+ useEffect(() => {
2599
+ if (!annotationProvides) return;
2600
+ if (prevScaleRef.current !== scale) {
2601
+ annotationProvides.invalidatePageAppearances(pageIndex);
2602
+ prevScaleRef.current = scale;
2603
+ }
2604
+ const task = annotationProvides.getPageAppearances(pageIndex, {
2605
+ scaleFactor: scale,
2606
+ dpr: typeof window !== "undefined" ? window.devicePixelRatio : 1
2607
+ });
2608
+ task.wait(
2609
+ (map) => setAppearanceMap(map),
2610
+ () => setAppearanceMap({})
2611
+ );
2612
+ }, [annotationProvides, pageIndex, scale]);
2613
+ const handlers = useMemo(
2614
+ () => ({
2615
+ onPointerDown: (_, pe) => {
2616
+ if (pe.target === pe.currentTarget && annotationProvides) {
2617
+ annotationProvides.deselectAnnotation();
2618
+ setEditingId(null);
2619
+ }
2620
+ }
2621
+ }),
2622
+ [annotationProvides]
2623
+ );
2624
+ const handleClick = useCallback(
2625
+ (e, annotation) => {
2626
+ e.stopPropagation();
2627
+ if (annotationProvides && selectionProvides) {
2628
+ selectionProvides.clear();
2629
+ const isModifierPressed = "metaKey" in e ? e.metaKey || e.ctrlKey : false;
2630
+ if (isModifierPressed) {
2631
+ annotationProvides.toggleSelection(pageIndex, annotation.object.id);
2632
+ } else {
2633
+ annotationProvides.selectAnnotation(pageIndex, annotation.object.id);
2634
+ }
2635
+ if (annotation.object.id !== editingId) {
2636
+ setEditingId(null);
2637
+ }
2638
+ }
2639
+ },
2640
+ [annotationProvides, selectionProvides, editingId, pageIndex]
2641
+ );
2642
+ useEffect(() => {
2643
+ return register(handlers, {
2644
+ documentId
2645
+ });
2646
+ }, [register, handlers]);
2647
+ const selectedAnnotationsOnPage = useMemo(() => {
2648
+ return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));
2136
2649
  }, [annotations, allSelectedIds]);
2137
2650
  const areAllSelectedDraggable = useMemo(() => {
2138
2651
  if (selectedAnnotationsOnPage.length < 2) return false;
@@ -2207,651 +2720,102 @@ function Annotations(annotationsProps) {
2207
2720
  const allSelected = annotationProvides.getSelectedAnnotations();
2208
2721
  return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);
2209
2722
  }, [annotationProvides, pageIndex, allSelectedIds]);
2723
+ const getAppearanceForAnnotation = useCallback(
2724
+ (ta) => {
2725
+ if (ta.dictMode) return null;
2726
+ if (ta.object.rotation && ta.object.unrotatedRect) return null;
2727
+ const appearances = appearanceMap[ta.object.id];
2728
+ if (!(appearances == null ? void 0 : appearances.normal)) return null;
2729
+ return appearances;
2730
+ },
2731
+ [appearanceMap]
2732
+ );
2733
+ const allRenderers = useMemo(() => {
2734
+ const external = annotationsProps.annotationRenderers ?? [];
2735
+ const externalIds = new Set(external.map((r) => r.id));
2736
+ return [...external, ...builtInRenderers.filter((r) => !externalIds.has(r.id))];
2737
+ }, [annotationsProps.annotationRenderers]);
2738
+ const resolveRenderer = useCallback(
2739
+ (annotation) => allRenderers.find((r) => r.matches(annotation.object)) ?? null,
2740
+ [allRenderers]
2741
+ );
2742
+ const selectHelpers = useMemo(
2743
+ () => ({
2744
+ defaultSelect: handleClick,
2745
+ selectAnnotation: (pi, id) => annotationProvides == null ? void 0 : annotationProvides.selectAnnotation(pi, id),
2746
+ clearSelection: () => selectionProvides == null ? void 0 : selectionProvides.clear(),
2747
+ allAnnotations: annotations,
2748
+ pageIndex
2749
+ }),
2750
+ [handleClick, annotationProvides, selectionProvides, annotations, pageIndex]
2751
+ );
2210
2752
  return /* @__PURE__ */ jsxs(Fragment, { children: [
2211
2753
  annotations.map((annotation) => {
2754
+ var _a, _b, _c;
2755
+ const renderer = resolveRenderer(annotation);
2756
+ if (!renderer) return null;
2757
+ const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
2212
2758
  const isSelected = allSelectedIds.includes(annotation.object.id);
2213
2759
  const isEditing = editingId === annotation.object.id;
2214
- const tool = annotationProvides == null ? void 0 : annotationProvides.findToolForAnnotation(annotation.object);
2215
- for (const renderer of annotationsProps.annotationRenderers ?? []) {
2216
- const element = renderer.tryRender(annotation, {
2760
+ const defaults = renderer.interactionDefaults;
2761
+ const resolvedDraggable = resolveInteractionProp(
2762
+ tool == null ? void 0 : tool.interaction.isDraggable,
2763
+ annotation.object,
2764
+ (defaults == null ? void 0 : defaults.isDraggable) ?? true
2765
+ );
2766
+ const finalDraggable = renderer.isDraggable ? renderer.isDraggable(resolvedDraggable, { isEditing }) : resolvedDraggable;
2767
+ const useAP = ((_a = tool == null ? void 0 : tool.behavior) == null ? void 0 : _a.useAppearanceStream) ?? renderer.useAppearanceStream ?? true;
2768
+ const onSelect = renderer.selectOverride ? (e) => renderer.selectOverride(e, annotation, selectHelpers) : (e) => handleClick(e, annotation);
2769
+ return /* @__PURE__ */ jsx(
2770
+ AnnotationContainer,
2771
+ {
2772
+ trackedAnnotation: annotation,
2217
2773
  isSelected,
2218
- scale,
2219
- pageIndex,
2220
- onClick: (e) => handleClick(e, annotation)
2221
- });
2222
- if (element) {
2223
- return /* @__PURE__ */ jsx(
2224
- AnnotationContainer,
2225
- {
2226
- trackedAnnotation: annotation,
2227
- isSelected,
2228
- isMultiSelected,
2229
- isDraggable: resolveInteractionProp(
2230
- tool == null ? void 0 : tool.interaction.isDraggable,
2231
- annotation.object,
2232
- false
2233
- ),
2234
- isResizable: resolveInteractionProp(
2235
- tool == null ? void 0 : tool.interaction.isResizable,
2236
- annotation.object,
2237
- false
2238
- ),
2239
- lockAspectRatio: resolveInteractionProp(
2240
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2241
- annotation.object,
2242
- false
2243
- ),
2244
- isRotatable: resolveInteractionProp(
2245
- tool == null ? void 0 : tool.interaction.isRotatable,
2246
- annotation.object,
2247
- false
2248
- ),
2249
- selectionMenu,
2250
- onSelect: (e) => handleClick(e, annotation),
2251
- style: {
2252
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2253
- },
2254
- ...annotationsProps,
2255
- children: () => element
2256
- },
2257
- annotation.object.id
2258
- );
2259
- }
2260
- }
2261
- if (isInk(annotation)) {
2262
- return /* @__PURE__ */ jsx(
2263
- AnnotationContainer,
2264
- {
2265
- trackedAnnotation: annotation,
2266
- isSelected,
2267
- isMultiSelected,
2268
- isDraggable: resolveInteractionProp(
2269
- tool == null ? void 0 : tool.interaction.isDraggable,
2270
- annotation.object,
2271
- true
2272
- ),
2273
- isResizable: resolveInteractionProp(
2274
- tool == null ? void 0 : tool.interaction.isResizable,
2275
- annotation.object,
2276
- true
2277
- ),
2278
- lockAspectRatio: resolveInteractionProp(
2279
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2280
- annotation.object,
2281
- false
2282
- ),
2283
- isRotatable: resolveInteractionProp(
2284
- tool == null ? void 0 : tool.interaction.isRotatable,
2285
- annotation.object,
2286
- true
2287
- ),
2288
- selectionMenu,
2289
- onSelect: (e) => handleClick(e, annotation),
2290
- style: {
2291
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2292
- },
2293
- ...annotationsProps,
2294
- children: (obj) => /* @__PURE__ */ jsx(
2295
- Ink,
2296
- {
2297
- ...obj,
2298
- isSelected,
2299
- scale,
2300
- onClick: (e) => handleClick(e, annotation)
2301
- }
2302
- )
2303
- },
2304
- annotation.object.id
2305
- );
2306
- }
2307
- if (isSquare(annotation)) {
2308
- return /* @__PURE__ */ jsx(
2309
- AnnotationContainer,
2310
- {
2311
- trackedAnnotation: annotation,
2312
- isSelected,
2313
- isMultiSelected,
2314
- isDraggable: resolveInteractionProp(
2315
- tool == null ? void 0 : tool.interaction.isDraggable,
2316
- annotation.object,
2317
- true
2318
- ),
2319
- isResizable: resolveInteractionProp(
2320
- tool == null ? void 0 : tool.interaction.isResizable,
2321
- annotation.object,
2322
- true
2323
- ),
2324
- lockAspectRatio: resolveInteractionProp(
2325
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2326
- annotation.object,
2327
- false
2328
- ),
2329
- isRotatable: resolveInteractionProp(
2330
- tool == null ? void 0 : tool.interaction.isRotatable,
2331
- annotation.object,
2332
- true
2333
- ),
2334
- selectionMenu,
2335
- onSelect: (e) => handleClick(e, annotation),
2336
- style: {
2337
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2338
- },
2339
- ...annotationsProps,
2340
- children: (obj) => /* @__PURE__ */ jsx(
2341
- Square,
2342
- {
2343
- ...obj,
2344
- isSelected,
2345
- scale,
2346
- onClick: (e) => handleClick(e, annotation)
2347
- }
2348
- )
2349
- },
2350
- annotation.object.id
2351
- );
2352
- }
2353
- if (isCircle(annotation)) {
2354
- return /* @__PURE__ */ jsx(
2355
- AnnotationContainer,
2356
- {
2357
- trackedAnnotation: annotation,
2358
- isSelected,
2359
- isMultiSelected,
2360
- isDraggable: resolveInteractionProp(
2361
- tool == null ? void 0 : tool.interaction.isDraggable,
2362
- annotation.object,
2363
- true
2364
- ),
2365
- isResizable: resolveInteractionProp(
2366
- tool == null ? void 0 : tool.interaction.isResizable,
2367
- annotation.object,
2368
- true
2369
- ),
2370
- lockAspectRatio: resolveInteractionProp(
2371
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2372
- annotation.object,
2373
- false
2374
- ),
2375
- isRotatable: resolveInteractionProp(
2376
- tool == null ? void 0 : tool.interaction.isRotatable,
2377
- annotation.object,
2378
- true
2379
- ),
2380
- selectionMenu,
2381
- onSelect: (e) => handleClick(e, annotation),
2382
- style: {
2383
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2384
- },
2385
- ...annotationsProps,
2386
- children: (obj) => /* @__PURE__ */ jsx(
2387
- Circle,
2388
- {
2389
- ...obj,
2390
- isSelected,
2391
- scale,
2392
- onClick: (e) => handleClick(e, annotation)
2393
- }
2394
- )
2395
- },
2396
- annotation.object.id
2397
- );
2398
- }
2399
- if (isUnderline(annotation)) {
2400
- return /* @__PURE__ */ jsx(
2401
- AnnotationContainer,
2402
- {
2403
- trackedAnnotation: annotation,
2404
- isSelected,
2405
- isMultiSelected,
2406
- isDraggable: resolveInteractionProp(
2407
- tool == null ? void 0 : tool.interaction.isDraggable,
2408
- annotation.object,
2409
- false
2410
- ),
2411
- isResizable: resolveInteractionProp(
2412
- tool == null ? void 0 : tool.interaction.isResizable,
2413
- annotation.object,
2414
- false
2415
- ),
2416
- lockAspectRatio: resolveInteractionProp(
2417
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2418
- annotation.object,
2419
- false
2420
- ),
2421
- isRotatable: resolveInteractionProp(
2422
- tool == null ? void 0 : tool.interaction.isRotatable,
2423
- annotation.object,
2424
- false
2425
- ),
2426
- selectionMenu,
2427
- onSelect: (e) => handleClick(e, annotation),
2428
- zIndex: 0,
2429
- style: {
2430
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2431
- },
2432
- ...annotationsProps,
2433
- children: (obj) => /* @__PURE__ */ jsx(Underline, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2774
+ isEditing,
2775
+ isMultiSelected,
2776
+ isDraggable: finalDraggable,
2777
+ isResizable: resolveInteractionProp(
2778
+ tool == null ? void 0 : tool.interaction.isResizable,
2779
+ annotation.object,
2780
+ (defaults == null ? void 0 : defaults.isResizable) ?? false
2781
+ ),
2782
+ lockAspectRatio: resolveInteractionProp(
2783
+ tool == null ? void 0 : tool.interaction.lockAspectRatio,
2784
+ annotation.object,
2785
+ (defaults == null ? void 0 : defaults.lockAspectRatio) ?? false
2786
+ ),
2787
+ isRotatable: resolveInteractionProp(
2788
+ tool == null ? void 0 : tool.interaction.isRotatable,
2789
+ annotation.object,
2790
+ (defaults == null ? void 0 : defaults.isRotatable) ?? false
2791
+ ),
2792
+ vertexConfig: renderer.vertexConfig,
2793
+ selectionMenu: ((_b = renderer.hideSelectionMenu) == null ? void 0 : _b.call(renderer, annotation.object)) ? void 0 : selectionMenu,
2794
+ onSelect,
2795
+ onDoubleClick: renderer.onDoubleClick ? (e) => {
2796
+ e.stopPropagation();
2797
+ renderer.onDoubleClick(annotation.object.id, setEditingId);
2798
+ } : void 0,
2799
+ zIndex: renderer.zIndex,
2800
+ style: ((_c = renderer.containerStyle) == null ? void 0 : _c.call(renderer, annotation.object)) ?? {
2801
+ mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2434
2802
  },
2435
- annotation.object.id
2436
- );
2437
- }
2438
- if (isStrikeout(annotation)) {
2439
- return /* @__PURE__ */ jsx(
2440
- AnnotationContainer,
2441
- {
2442
- trackedAnnotation: annotation,
2443
- isSelected,
2444
- isMultiSelected,
2445
- isDraggable: resolveInteractionProp(
2446
- tool == null ? void 0 : tool.interaction.isDraggable,
2447
- annotation.object,
2448
- false
2449
- ),
2450
- isResizable: resolveInteractionProp(
2451
- tool == null ? void 0 : tool.interaction.isResizable,
2452
- annotation.object,
2453
- false
2454
- ),
2455
- lockAspectRatio: resolveInteractionProp(
2456
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2457
- annotation.object,
2458
- false
2459
- ),
2460
- isRotatable: resolveInteractionProp(
2461
- tool == null ? void 0 : tool.interaction.isRotatable,
2462
- annotation.object,
2463
- false
2464
- ),
2465
- selectionMenu,
2466
- onSelect: (e) => handleClick(e, annotation),
2467
- zIndex: 0,
2468
- style: {
2469
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2470
- },
2471
- ...annotationsProps,
2472
- children: (obj) => /* @__PURE__ */ jsx(Strikeout, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2473
- },
2474
- annotation.object.id
2475
- );
2476
- }
2477
- if (isSquiggly(annotation)) {
2478
- return /* @__PURE__ */ jsx(
2479
- AnnotationContainer,
2480
- {
2481
- trackedAnnotation: annotation,
2803
+ appearance: useAP ? getAppearanceForAnnotation(annotation) : void 0,
2804
+ ...annotationsProps,
2805
+ children: (currentObject, { appearanceActive }) => renderer.render({
2806
+ annotation,
2807
+ currentObject,
2482
2808
  isSelected,
2483
- isMultiSelected,
2484
- isDraggable: resolveInteractionProp(
2485
- tool == null ? void 0 : tool.interaction.isDraggable,
2486
- annotation.object,
2487
- false
2488
- ),
2489
- isResizable: resolveInteractionProp(
2490
- tool == null ? void 0 : tool.interaction.isResizable,
2491
- annotation.object,
2492
- false
2493
- ),
2494
- lockAspectRatio: resolveInteractionProp(
2495
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2496
- annotation.object,
2497
- false
2498
- ),
2499
- isRotatable: resolveInteractionProp(
2500
- tool == null ? void 0 : tool.interaction.isRotatable,
2501
- annotation.object,
2502
- false
2503
- ),
2504
- selectionMenu,
2505
- onSelect: (e) => handleClick(e, annotation),
2506
- zIndex: 0,
2507
- style: {
2508
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2509
- },
2510
- ...annotationsProps,
2511
- children: (obj) => /* @__PURE__ */ jsx(Squiggly, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2512
- },
2513
- annotation.object.id
2514
- );
2515
- }
2516
- if (isHighlight(annotation)) {
2517
- return /* @__PURE__ */ jsx(
2518
- AnnotationContainer,
2519
- {
2520
- trackedAnnotation: annotation,
2521
- isSelected,
2522
- isMultiSelected,
2523
- isDraggable: resolveInteractionProp(
2524
- tool == null ? void 0 : tool.interaction.isDraggable,
2525
- annotation.object,
2526
- false
2527
- ),
2528
- isResizable: resolveInteractionProp(
2529
- tool == null ? void 0 : tool.interaction.isResizable,
2530
- annotation.object,
2531
- false
2532
- ),
2533
- lockAspectRatio: resolveInteractionProp(
2534
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2535
- annotation.object,
2536
- false
2537
- ),
2538
- isRotatable: resolveInteractionProp(
2539
- tool == null ? void 0 : tool.interaction.isRotatable,
2540
- annotation.object,
2541
- false
2542
- ),
2543
- selectionMenu,
2544
- onSelect: (e) => handleClick(e, annotation),
2545
- zIndex: 0,
2546
- style: {
2547
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Multiply)
2548
- },
2549
- ...annotationsProps,
2550
- children: (obj) => /* @__PURE__ */ jsx(Highlight, { ...obj, scale, onClick: (e) => handleClick(e, annotation) })
2551
- },
2552
- annotation.object.id
2553
- );
2554
- }
2555
- if (isLine(annotation)) {
2556
- return /* @__PURE__ */ jsx(
2557
- AnnotationContainer,
2558
- {
2559
- trackedAnnotation: annotation,
2560
- isSelected,
2561
- isMultiSelected,
2562
- isDraggable: resolveInteractionProp(
2563
- tool == null ? void 0 : tool.interaction.isDraggable,
2564
- annotation.object,
2565
- true
2566
- ),
2567
- isResizable: resolveInteractionProp(
2568
- tool == null ? void 0 : tool.interaction.isResizable,
2569
- annotation.object,
2570
- false
2571
- ),
2572
- lockAspectRatio: resolveInteractionProp(
2573
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2574
- annotation.object,
2575
- false
2576
- ),
2577
- isRotatable: resolveInteractionProp(
2578
- tool == null ? void 0 : tool.interaction.isRotatable,
2579
- annotation.object,
2580
- true
2581
- ),
2582
- selectionMenu,
2583
- onSelect: (e) => handleClick(e, annotation),
2584
- vertexConfig: {
2585
- extractVertices: (annotation2) => [
2586
- annotation2.linePoints.start,
2587
- annotation2.linePoints.end
2588
- ],
2589
- transformAnnotation: (annotation2, vertices) => {
2590
- return {
2591
- ...annotation2,
2592
- linePoints: {
2593
- start: vertices[0],
2594
- end: vertices[1]
2595
- }
2596
- };
2597
- }
2598
- },
2599
- style: {
2600
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2601
- },
2602
- ...annotationsProps,
2603
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2604
- Line,
2605
- {
2606
- ...obj,
2607
- isSelected,
2608
- scale,
2609
- onClick: (e) => handleClick(e, annotation)
2610
- }
2611
- ) })
2612
- },
2613
- annotation.object.id
2614
- );
2615
- }
2616
- if (isPolyline(annotation)) {
2617
- return /* @__PURE__ */ jsx(
2618
- AnnotationContainer,
2619
- {
2620
- trackedAnnotation: annotation,
2621
- isSelected,
2622
- isMultiSelected,
2623
- isDraggable: resolveInteractionProp(
2624
- tool == null ? void 0 : tool.interaction.isDraggable,
2625
- annotation.object,
2626
- true
2627
- ),
2628
- isResizable: resolveInteractionProp(
2629
- tool == null ? void 0 : tool.interaction.isResizable,
2630
- annotation.object,
2631
- false
2632
- ),
2633
- lockAspectRatio: resolveInteractionProp(
2634
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2635
- annotation.object,
2636
- false
2637
- ),
2638
- isRotatable: resolveInteractionProp(
2639
- tool == null ? void 0 : tool.interaction.isRotatable,
2640
- annotation.object,
2641
- true
2642
- ),
2643
- selectionMenu,
2644
- onSelect: (e) => handleClick(e, annotation),
2645
- vertexConfig: {
2646
- extractVertices: (annotation2) => annotation2.vertices,
2647
- transformAnnotation: (annotation2, vertices) => {
2648
- return {
2649
- ...annotation2,
2650
- vertices
2651
- };
2652
- }
2653
- },
2654
- style: {
2655
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2656
- },
2657
- ...annotationsProps,
2658
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2659
- Polyline,
2660
- {
2661
- ...obj,
2662
- isSelected,
2663
- scale,
2664
- onClick: (e) => handleClick(e, annotation)
2665
- }
2666
- ) })
2667
- },
2668
- annotation.object.id
2669
- );
2670
- }
2671
- if (isPolygon(annotation)) {
2672
- return /* @__PURE__ */ jsx(
2673
- AnnotationContainer,
2674
- {
2675
- trackedAnnotation: annotation,
2676
- isSelected,
2677
- isMultiSelected,
2678
- isDraggable: resolveInteractionProp(
2679
- tool == null ? void 0 : tool.interaction.isDraggable,
2680
- annotation.object,
2681
- true
2682
- ),
2683
- isResizable: resolveInteractionProp(
2684
- tool == null ? void 0 : tool.interaction.isResizable,
2685
- annotation.object,
2686
- false
2687
- ),
2688
- lockAspectRatio: resolveInteractionProp(
2689
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2690
- annotation.object,
2691
- false
2692
- ),
2693
- isRotatable: resolveInteractionProp(
2694
- tool == null ? void 0 : tool.interaction.isRotatable,
2695
- annotation.object,
2696
- true
2697
- ),
2698
- selectionMenu,
2699
- onSelect: (e) => handleClick(e, annotation),
2700
- vertexConfig: {
2701
- extractVertices: (annotation2) => annotation2.vertices,
2702
- transformAnnotation: (annotation2, vertices) => {
2703
- return {
2704
- ...annotation2,
2705
- vertices
2706
- };
2707
- }
2708
- },
2709
- style: {
2710
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2711
- },
2712
- ...annotationsProps,
2713
- children: (obj) => /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
2714
- Polygon,
2715
- {
2716
- ...obj,
2717
- isSelected,
2718
- scale,
2719
- onClick: (e) => handleClick(e, annotation)
2720
- }
2721
- ) })
2722
- },
2723
- annotation.object.id
2724
- );
2725
- }
2726
- if (isFreeText(annotation)) {
2727
- return /* @__PURE__ */ jsx(
2728
- AnnotationContainer,
2729
- {
2730
- trackedAnnotation: annotation,
2731
- isSelected,
2732
- isMultiSelected,
2733
- isDraggable: resolveInteractionProp(tool == null ? void 0 : tool.interaction.isDraggable, annotation.object, true) && !isEditing,
2734
- isResizable: resolveInteractionProp(
2735
- tool == null ? void 0 : tool.interaction.isResizable,
2736
- annotation.object,
2737
- true
2738
- ),
2739
- lockAspectRatio: resolveInteractionProp(
2740
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2741
- annotation.object,
2742
- false
2743
- ),
2744
- isRotatable: resolveInteractionProp(
2745
- tool == null ? void 0 : tool.interaction.isRotatable,
2746
- annotation.object,
2747
- true
2748
- ),
2749
- selectionMenu,
2750
- onSelect: (e) => handleClick(e, annotation),
2751
- style: {
2752
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2753
- },
2754
- onDoubleClick: (e) => {
2755
- e.stopPropagation();
2756
- setEditingId(annotation.object.id);
2757
- },
2758
- ...annotationsProps,
2759
- children: (object) => /* @__PURE__ */ jsx(
2760
- FreeText,
2761
- {
2762
- isSelected,
2763
- isEditing,
2764
- annotation: {
2765
- ...annotation,
2766
- object
2767
- },
2768
- pageIndex,
2769
- scale,
2770
- onClick: (e) => handleClick(e, annotation)
2771
- }
2772
- )
2773
- },
2774
- annotation.object.id
2775
- );
2776
- }
2777
- if (isStamp(annotation)) {
2778
- return /* @__PURE__ */ jsx(
2779
- AnnotationContainer,
2780
- {
2781
- trackedAnnotation: annotation,
2782
- isSelected,
2783
- isMultiSelected,
2784
- isDraggable: resolveInteractionProp(
2785
- tool == null ? void 0 : tool.interaction.isDraggable,
2786
- annotation.object,
2787
- true
2788
- ),
2789
- isResizable: resolveInteractionProp(
2790
- tool == null ? void 0 : tool.interaction.isResizable,
2791
- annotation.object,
2792
- true
2793
- ),
2794
- lockAspectRatio: resolveInteractionProp(
2795
- tool == null ? void 0 : tool.interaction.lockAspectRatio,
2796
- annotation.object,
2797
- false
2798
- ),
2799
- isRotatable: resolveInteractionProp(
2800
- tool == null ? void 0 : tool.interaction.isRotatable,
2801
- annotation.object,
2802
- true
2803
- ),
2804
- selectionMenu,
2805
- onSelect: (e) => handleClick(e, annotation),
2806
- style: {
2807
- mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal)
2808
- },
2809
- ...annotationsProps,
2810
- children: (_object) => /* @__PURE__ */ jsx(
2811
- Stamp,
2812
- {
2813
- isSelected,
2814
- annotation,
2815
- documentId,
2816
- pageIndex,
2817
- scale,
2818
- onClick: (e) => handleClick(e, annotation)
2819
- }
2820
- )
2821
- },
2822
- annotation.object.id
2823
- );
2824
- }
2825
- if (isLink(annotation)) {
2826
- const hasIRT = !!annotation.object.inReplyToId;
2827
- return /* @__PURE__ */ jsx(
2828
- AnnotationContainer,
2829
- {
2830
- trackedAnnotation: annotation,
2831
- isSelected,
2832
- isMultiSelected,
2833
- isDraggable: false,
2834
- isResizable: false,
2835
- lockAspectRatio: false,
2836
- isRotatable: false,
2837
- selectionMenu: hasIRT ? void 0 : selectionMenu,
2838
- onSelect: (e) => handleLinkClick(e, annotation),
2839
- ...annotationsProps,
2840
- children: (obj) => /* @__PURE__ */ jsx(
2841
- Link,
2842
- {
2843
- ...obj,
2844
- isSelected,
2845
- scale,
2846
- onClick: (e) => handleLinkClick(e, annotation),
2847
- hasIRT
2848
- }
2849
- )
2850
- },
2851
- annotation.object.id
2852
- );
2853
- }
2854
- return null;
2809
+ isEditing,
2810
+ scale,
2811
+ pageIndex,
2812
+ documentId,
2813
+ onClick: onSelect,
2814
+ appearanceActive
2815
+ })
2816
+ },
2817
+ annotation.object.id
2818
+ );
2855
2819
  }),
2856
2820
  allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && /* @__PURE__ */ jsx(
2857
2821
  GroupSelectionBox,
@@ -3178,20 +3142,6 @@ function AnnotationLayer({
3178
3142
  }
3179
3143
  );
3180
3144
  }
3181
- function createRenderer(entry) {
3182
- return {
3183
- id: entry.id,
3184
- tryRender: (annotation, props) => {
3185
- if (entry.matches(annotation.object)) {
3186
- return entry.render({
3187
- ...props,
3188
- annotation
3189
- });
3190
- }
3191
- return null;
3192
- }
3193
- };
3194
- }
3195
3145
  const AnnotationPluginPackage = createPluginPackage(AnnotationPluginPackage$1).addWrapper(AnnotationRendererProvider).build();
3196
3146
  export {
3197
3147
  AnnotationLayer,