@embedpdf/react 3.0.0-next.14 → 3.0.0-next.15

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 (232) hide show
  1. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.cts +877 -0
  2. package/dist/AnnotationList-CkijRHet-HEFNUIZe.d.ts +877 -0
  3. package/dist/actions.cjs +25 -5
  4. package/dist/actions.cjs.map +1 -1
  5. package/dist/actions.d.cts +18 -5
  6. package/dist/actions.d.ts +18 -5
  7. package/dist/actions.js +22 -6
  8. package/dist/actions.js.map +1 -1
  9. package/dist/anchored-DeX95xSd.d.ts +85 -0
  10. package/dist/anchored-DzN3JywS.d.cts +85 -0
  11. package/dist/anchored.cjs +71 -28
  12. package/dist/anchored.cjs.map +1 -1
  13. package/dist/anchored.d.cts +2 -45
  14. package/dist/anchored.d.ts +2 -45
  15. package/dist/anchored.js +56 -19
  16. package/dist/anchored.js.map +1 -1
  17. package/dist/annotation-B48UT2ln.d.ts +302 -0
  18. package/dist/annotation-C1ttM8Wj.js +708 -0
  19. package/dist/annotation-C1ttM8Wj.js.map +1 -0
  20. package/dist/annotation-C9dVwo9b.d.cts +302 -0
  21. package/dist/annotation-Dex5EBda.cjs +830 -0
  22. package/dist/annotation-Dex5EBda.cjs.map +1 -0
  23. package/dist/annotation.cjs +20 -784
  24. package/dist/annotation.d.cts +2 -2
  25. package/dist/annotation.d.ts +2 -2
  26. package/dist/annotation.js +2 -769
  27. package/dist/commands.cjs +68 -28
  28. package/dist/commands.cjs.map +1 -1
  29. package/dist/commands.d.cts +37 -10
  30. package/dist/commands.d.ts +37 -10
  31. package/dist/commands.js +68 -31
  32. package/dist/commands.js.map +1 -1
  33. package/dist/form-55izw0jS.js +511 -0
  34. package/dist/form-55izw0jS.js.map +1 -0
  35. package/dist/form-BNqQfGGH.cjs +548 -0
  36. package/dist/form-BNqQfGGH.cjs.map +1 -0
  37. package/dist/form.cjs +5 -5
  38. package/dist/form.d.cts +41 -2
  39. package/dist/form.d.ts +41 -2
  40. package/dist/form.js +2 -3
  41. package/dist/history.cjs +38 -0
  42. package/dist/history.cjs.map +1 -0
  43. package/dist/history.d.cts +27 -0
  44. package/dist/history.d.ts +27 -0
  45. package/dist/history.js +27 -0
  46. package/dist/history.js.map +1 -0
  47. package/dist/i18n.cjs +26 -30
  48. package/dist/i18n.cjs.map +1 -1
  49. package/dist/i18n.d.cts +24 -21
  50. package/dist/i18n.d.ts +24 -21
  51. package/dist/i18n.js +24 -31
  52. package/dist/i18n.js.map +1 -1
  53. package/dist/index.cjs +200 -57
  54. package/dist/index.d.cts +31 -32
  55. package/dist/index.d.ts +31 -32
  56. package/dist/index.js +32 -30
  57. package/dist/inert-CmBEbKCn.cjs +19 -0
  58. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  59. package/dist/inert-D8fkennb.js +14 -0
  60. package/dist/inert-D8fkennb.js.map +1 -0
  61. package/dist/interaction.cjs +48 -102
  62. package/dist/interaction.cjs.map +1 -1
  63. package/dist/interaction.d.cts +23 -32
  64. package/dist/interaction.d.ts +23 -32
  65. package/dist/interaction.js +33 -102
  66. package/dist/interaction.js.map +1 -1
  67. package/dist/link.cjs +65 -104
  68. package/dist/link.cjs.map +1 -1
  69. package/dist/link.d.cts +21 -16
  70. package/dist/link.d.ts +22 -17
  71. package/dist/link.js +67 -107
  72. package/dist/link.js.map +1 -1
  73. package/dist/measurement.cjs +36 -11
  74. package/dist/measurement.cjs.map +1 -1
  75. package/dist/measurement.d.cts +33 -7
  76. package/dist/measurement.d.ts +33 -7
  77. package/dist/measurement.js +35 -14
  78. package/dist/measurement.js.map +1 -1
  79. package/dist/metadata.cjs +20 -7
  80. package/dist/metadata.cjs.map +1 -1
  81. package/dist/metadata.d.cts +22 -7
  82. package/dist/metadata.d.ts +22 -7
  83. package/dist/metadata.js +20 -10
  84. package/dist/metadata.js.map +1 -1
  85. package/dist/page-edit.cjs +7 -3
  86. package/dist/page-edit.cjs.map +1 -1
  87. package/dist/page-edit.d.cts +6 -2
  88. package/dist/page-edit.d.ts +6 -2
  89. package/dist/page-edit.js +7 -4
  90. package/dist/page-edit.js.map +1 -1
  91. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  92. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  93. package/dist/page-layers-BloZDoOV.cjs +37 -0
  94. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  95. package/dist/page-view.cjs +89 -82
  96. package/dist/page-view.cjs.map +1 -1
  97. package/dist/page-view.d.cts +14 -7
  98. package/dist/page-view.d.ts +18 -11
  99. package/dist/page-view.js +86 -81
  100. package/dist/page-view.js.map +1 -1
  101. package/dist/redaction.cjs +30 -15
  102. package/dist/redaction.cjs.map +1 -1
  103. package/dist/redaction.d.cts +27 -9
  104. package/dist/redaction.d.ts +27 -9
  105. package/dist/redaction.js +29 -18
  106. package/dist/redaction.js.map +1 -1
  107. package/dist/render.cjs +71 -46
  108. package/dist/render.cjs.map +1 -1
  109. package/dist/render.d.cts +17 -5
  110. package/dist/render.d.ts +17 -5
  111. package/dist/render.js +70 -49
  112. package/dist/render.js.map +1 -1
  113. package/dist/runtime-B6xcPsEb.js +398 -0
  114. package/dist/runtime-B6xcPsEb.js.map +1 -0
  115. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  116. package/dist/runtime-V3MVMb91.d.ts +237 -0
  117. package/dist/runtime-fzpGv78v.cjs +555 -0
  118. package/dist/runtime-fzpGv78v.cjs.map +1 -0
  119. package/dist/runtime.cjs +45 -324
  120. package/dist/runtime.d.cts +2 -2
  121. package/dist/runtime.d.ts +2 -2
  122. package/dist/runtime.js +2 -306
  123. package/dist/search.cjs +81 -50
  124. package/dist/search.cjs.map +1 -1
  125. package/dist/search.d.cts +37 -24
  126. package/dist/search.d.ts +37 -24
  127. package/dist/search.js +81 -53
  128. package/dist/search.js.map +1 -1
  129. package/dist/selection.cjs +105 -108
  130. package/dist/selection.cjs.map +1 -1
  131. package/dist/selection.d.cts +54 -26
  132. package/dist/selection.d.ts +56 -28
  133. package/dist/selection.js +103 -110
  134. package/dist/selection.js.map +1 -1
  135. package/dist/shell.cjs +36 -21
  136. package/dist/shell.cjs.map +1 -1
  137. package/dist/shell.d.cts +32 -17
  138. package/dist/shell.d.ts +32 -17
  139. package/dist/shell.js +36 -24
  140. package/dist/shell.js.map +1 -1
  141. package/dist/signature.cjs +29 -48
  142. package/dist/signature.cjs.map +1 -1
  143. package/dist/signature.d.cts +26 -26
  144. package/dist/signature.d.ts +26 -26
  145. package/dist/signature.js +30 -48
  146. package/dist/signature.js.map +1 -1
  147. package/dist/stage-BIG6aeVd.cjs +369 -0
  148. package/dist/stage-BIG6aeVd.cjs.map +1 -0
  149. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  150. package/dist/stage-DaboaheR.d.ts +117 -0
  151. package/dist/stage-DoVekb83.js +302 -0
  152. package/dist/stage-DoVekb83.js.map +1 -0
  153. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  154. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  155. package/dist/stage-scope-D7ZeNduT.js +23 -0
  156. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  157. package/dist/stage.cjs +12 -235
  158. package/dist/stage.d.cts +2 -116
  159. package/dist/stage.d.ts +2 -116
  160. package/dist/stage.js +3 -228
  161. package/dist/stamp.cjs +41 -35
  162. package/dist/stamp.cjs.map +1 -1
  163. package/dist/stamp.d.cts +25 -18
  164. package/dist/stamp.d.ts +25 -18
  165. package/dist/stamp.js +40 -37
  166. package/dist/stamp.js.map +1 -1
  167. package/dist/state-0K1I5cM4.d.cts +29 -0
  168. package/dist/state-0K1I5cM4.d.ts +29 -0
  169. package/dist/state-CbgxhwLA.js +62 -0
  170. package/dist/state-CbgxhwLA.js.map +1 -0
  171. package/dist/state-CsfZy_Eq.cjs +73 -0
  172. package/dist/state-CsfZy_Eq.cjs.map +1 -0
  173. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  174. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  175. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  176. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  177. package/dist/toolbar.cjs +297 -295
  178. package/dist/toolbar.cjs.map +1 -1
  179. package/dist/toolbar.d.cts +58 -68
  180. package/dist/toolbar.d.ts +67 -77
  181. package/dist/toolbar.js +271 -293
  182. package/dist/toolbar.js.map +1 -1
  183. package/dist/view-manager.cjs +34 -0
  184. package/dist/view-manager.cjs.map +1 -0
  185. package/dist/view-manager.d.cts +21 -0
  186. package/dist/view-manager.d.ts +21 -0
  187. package/dist/view-manager.js +23 -0
  188. package/dist/view-manager.js.map +1 -0
  189. package/package.json +37 -39
  190. package/dist/annotation-BCED_p9H.d.cts +0 -160
  191. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  192. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  193. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  194. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  195. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  196. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  197. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  198. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  199. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  200. package/dist/annotation-menu.cjs +0 -64
  201. package/dist/annotation-menu.cjs.map +0 -1
  202. package/dist/annotation-menu.d.cts +0 -33
  203. package/dist/annotation-menu.d.ts +0 -33
  204. package/dist/annotation-menu.js +0 -48
  205. package/dist/annotation-menu.js.map +0 -1
  206. package/dist/annotation.cjs.map +0 -1
  207. package/dist/annotation.js.map +0 -1
  208. package/dist/form-BVumS7up.cjs +0 -926
  209. package/dist/form-BVumS7up.cjs.map +0 -1
  210. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  211. package/dist/form-CK3mp99m.js +0 -895
  212. package/dist/form-CK3mp99m.js.map +0 -1
  213. package/dist/form-CYRYgthn.d.ts +0 -537
  214. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  215. package/dist/runtime-DE76hlnl.d.ts +0 -216
  216. package/dist/runtime-umHA_xHt.d.cts +0 -216
  217. package/dist/runtime.cjs.map +0 -1
  218. package/dist/runtime.js.map +0 -1
  219. package/dist/scrollbar.cjs +0 -241
  220. package/dist/scrollbar.cjs.map +0 -1
  221. package/dist/scrollbar.d.cts +0 -42
  222. package/dist/scrollbar.d.ts +0 -42
  223. package/dist/scrollbar.js +0 -213
  224. package/dist/scrollbar.js.map +0 -1
  225. package/dist/stage.cjs.map +0 -1
  226. package/dist/stage.js.map +0 -1
  227. package/dist/views.cjs +0 -35
  228. package/dist/views.cjs.map +0 -1
  229. package/dist/views.d.cts +0 -21
  230. package/dist/views.d.ts +0 -21
  231. package/dist/views.js +0 -27
  232. package/dist/views.js.map +0 -1
@@ -0,0 +1,830 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
2
+ const require_runtime = require("./runtime-fzpGv78v.cjs");
3
+ const require_state = require("./state-CsfZy_Eq.cjs");
4
+ const require_anchored = require("./anchored.cjs");
5
+ const require_page_layers = require("./page-layers-BloZDoOV.cjs");
6
+ const require_inert = require("./inert-CmBEbKCn.cjs");
7
+ const require_svg_shapes = require("./svg-shapes-zo0GNkc9.cjs");
8
+ let react_jsx_runtime = require("react/jsx-runtime");
9
+ let _embedpdf_web = require("@embedpdf/web");
10
+ let react = require("react");
11
+ react = require_rolldown_runtime.__toESM(react, 1);
12
+ let _embedpdf_plugin_interaction_contract = require("@embedpdf/plugin-interaction/contract");
13
+ let _embedpdf_plugin_render_contract_host = require("@embedpdf/plugin-render/contract/host");
14
+ let _embedpdf_plugin_annotation = require("@embedpdf/plugin-annotation");
15
+ let _embedpdf_core_annotation = require("@embedpdf/core-annotation");
16
+ let _embedpdf_plugin_annotation_contract_host = require("@embedpdf/plugin-annotation/contract/host");
17
+ let _embedpdf_plugin_annotation_contract = require("@embedpdf/plugin-annotation/contract");
18
+ //#region src/annotation-hooks.ts
19
+ /**
20
+ * The annotation hooks other feature entries use too (the form plugin reads
21
+ * the selection), kept apart so they don't import the whole annotation
22
+ * feature: the state and the settings, each from its declaration.
23
+ */
24
+ /**
25
+ * The annotation state: `status` (`'loading'` until every annotation is in,
26
+ * then `'ready'`), the `selected` annotations, the one `hovered` under the
27
+ * pointer and the text box being typed in (`editing`). Re-renders only when a
28
+ * field changes, or the value `select` picks. Empty without a document.
29
+ */
30
+ const useAnnotationState = require_state.stateHook(_embedpdf_plugin_annotation_contract.annotationState);
31
+ /**
32
+ * The annotation settings (`snap`, `chrome`, `afterCreate`, `tools`), or the
33
+ * value `select` picks. They belong to the plugin, so they read without a
34
+ * document; change them with `useAnnotation().updateSettings()`.
35
+ */
36
+ const useAnnotationSettings = require_state.settingsHook(_embedpdf_plugin_annotation_contract.AnnotationToken);
37
+ //#endregion
38
+ //#region src/annotation-menu.tsx
39
+ /**
40
+ * Annotation menus: thin anchor plumbing over the one `<Anchored>` primitive.
41
+ * They come from `/annotation`; this module stays apart so it doesn't pull
42
+ * in the layer.
43
+ *
44
+ * These work identically under `<Stage>` (mount in the overlay slot; the
45
+ * camera projects, no DOM reads) and `<PageView>` (measured and portalled):
46
+ * the surface provides the projector, the menu doesn't care.
47
+ *
48
+ * No action bags: actions come from `useAnnotation()` and the state hooks,
49
+ * which subscribe properly and compose across plugins. Render props carry
50
+ * only the anchor's data (the draft menu's progress); the selection menu
51
+ * takes plain children.
52
+ */
53
+ /**
54
+ * Your own menu next to the selection (one anchor, also for a selection over
55
+ * several pages), clear of the rotation handle. It hides while the selection
56
+ * is dragged, resized or turned. What's in it is yours: build it from
57
+ * `useAnnotation()` and `useAnnotationState()`.
58
+ */
59
+ function AnnotationMenu({ children, gap = 15, placement = "top" }) {
60
+ const { projector } = require_anchored.useProjectorBinding();
61
+ const anchor = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => {
62
+ const selectionAnchor = annotation.selection.getAnchor();
63
+ if (!selectionAnchor) return null;
64
+ const env = projector.viewEnv(selectionAnchor.page);
65
+ return env ? annotation.getSelectionAnchorIn(env) : selectionAnchor;
66
+ }, null, _embedpdf_web.sameSelectionAnchor);
67
+ if (!anchor) return null;
68
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_anchored.Anchored, {
69
+ anchor: {
70
+ page: anchor.page,
71
+ bounds: anchor.bounds,
72
+ ...anchor.rotationHandle ? { avoid: [anchor.rotationHandle] } : {}
73
+ },
74
+ placement,
75
+ gap,
76
+ children
77
+ });
78
+ }
79
+ /** Floats over a live multi-click creation draft (polygon, polyline, …). */
80
+ function AnnotationDraftMenu({ children, gap = 8, placement = "top" }) {
81
+ const anchor = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract.AnnotationToken, (annotation) => annotation.draft.get(), null, _embedpdf_web.sameCreationDraftAnchor);
82
+ if (!anchor) return null;
83
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_anchored.Anchored, {
84
+ anchor,
85
+ placement,
86
+ gap,
87
+ children: children(anchor)
88
+ });
89
+ }
90
+ /**
91
+ * Follows the pointer while a selection is being turned, upright however the
92
+ * page is shown: it floats over the page like the menus, not in it. Shows
93
+ * nothing when no rotation is in progress.
94
+ */
95
+ function AnnotationRotationBadge({ children, gap = 16, placement = "right" }) {
96
+ const rotation = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract.AnnotationToken, (annotation) => annotation.selection.getRotationAnchor(), null, _embedpdf_web.sameRotationAnchor);
97
+ const readout = useAnnotationSettings((settings) => settings.chrome.readout);
98
+ if (!rotation || !children && !readout.enabled) return null;
99
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_anchored.Anchored, {
100
+ anchor: {
101
+ page: rotation.page,
102
+ bounds: {
103
+ ...rotation.at,
104
+ width: 0,
105
+ height: 0
106
+ }
107
+ },
108
+ placement,
109
+ gap,
110
+ children: children ? children(rotation) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
111
+ style: {
112
+ pointerEvents: "none",
113
+ whiteSpace: "nowrap",
114
+ borderRadius: 4,
115
+ padding: "2px 6px",
116
+ fontFamily: (0, _embedpdf_web.paintDefault)("font-mono"),
117
+ fontSize: 12,
118
+ background: (0, _embedpdf_web.paint)("readout-background", readout.background),
119
+ color: (0, _embedpdf_web.paint)("readout-color", readout.color)
120
+ },
121
+ children: [rotation.angle, "°"]
122
+ })
123
+ });
124
+ }
125
+ //#endregion
126
+ //#region src/annotation.tsx
127
+ /** How much the layer scales the look around it: 1 outside a look, or in one drawn at its size on screen. */
128
+ const LookScaleContext = react.createContext(1);
129
+ /**
130
+ * The box an annotation draws into, placed, sized and turned like the
131
+ * annotation (`item.frame`) inside the page layer, which the page itself
132
+ * turns. The annotation's own drawing and any look of yours draw inside it.
133
+ */
134
+ function AnnotationFrame({ item, page, interactive = false, inert = false, children }) {
135
+ const box = (0, _embedpdf_web.frameInPixels)(item.frame, page.transform);
136
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
137
+ ...inert ? require_inert.INERT : {},
138
+ style: {
139
+ position: "absolute",
140
+ left: box.left,
141
+ top: box.top,
142
+ width: box.width,
143
+ height: box.height,
144
+ transform: box.transform,
145
+ transformOrigin: "center",
146
+ mixBlendMode: item.blend,
147
+ pointerEvents: interactive ? "auto" : "none"
148
+ },
149
+ children
150
+ });
151
+ }
152
+ /** SVG attribute names as React props: `stroke-width` is `strokeWidth`. */
153
+ /**
154
+ * The scene, filling the item's frame: drawn upright in it, the frame turns
155
+ * it. The core computed the box and the painted scene; `@embedpdf/web`
156
+ * describes each scene node as one SVG element, so there is no per-kind
157
+ * logic and no bounds math here.
158
+ */
159
+ function Shape({ item }) {
160
+ const viewBox = (0, _embedpdf_web.sceneViewBox)(item.box);
161
+ if (!viewBox) return null;
162
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
163
+ viewBox,
164
+ style: {
165
+ position: "absolute",
166
+ left: 0,
167
+ top: 0,
168
+ width: "100%",
169
+ height: "100%",
170
+ overflow: "visible",
171
+ pointerEvents: "none",
172
+ ...item.source === "ghost" ? { opacity: (0, _embedpdf_web.ghostOpacity)(item.ghostOpacity ?? .5) } : {}
173
+ },
174
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_svg_shapes.SvgShapes, { shapes: (0, _embedpdf_web.svgShapesOf)((0, _embedpdf_core_annotation.scene)(item), { miterLimit: _embedpdf_core_annotation.MITER_LIMIT }) })
175
+ });
176
+ }
177
+ /** The engine's raster inside the item's frame, where `item.raster` puts it, at any frame size. */
178
+ function BakedImage({ url, box }) {
179
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
180
+ src: url,
181
+ alt: "",
182
+ draggable: false,
183
+ style: {
184
+ position: "absolute",
185
+ left: box.left,
186
+ top: box.top,
187
+ width: box.width,
188
+ height: box.height,
189
+ maxWidth: "none",
190
+ maxHeight: "none",
191
+ pointerEvents: "none",
192
+ transform: box.transform,
193
+ transformOrigin: "center"
194
+ }
195
+ });
196
+ }
197
+ /**
198
+ * The armed stamp's ghost: a see-through render of the payload drawn in the
199
+ * exact box a click would place it (the plugin computes it with the same fit
200
+ * + clamp as placement). Every other tool's ghost rides `pageItems` like a
201
+ * drawing in progress. The preview bytes live in the capability closure; this
202
+ * layer owns only the object-URL lifetime, keyed on the armed stamp — a new
203
+ * arm swaps the image, a disarm (or tool change) drops it.
204
+ */
205
+ function ToolGhostImage({ page }) {
206
+ const anno = require_runtime.useCapability(_embedpdf_plugin_annotation_contract_host.AnnotationToken);
207
+ const ghost = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.getImageGhost(page.ref));
208
+ const armed = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.getArmedStamp());
209
+ const [url, setUrl] = (0, react.useState)(null);
210
+ const bucket = ghost ? (0, _embedpdf_plugin_annotation_contract_host.previewBucket)(ghost.box.width * page.transform.renderScale) : 0;
211
+ (0, react.useEffect)(() => {
212
+ if (!bucket) {
213
+ setUrl(null);
214
+ return;
215
+ }
216
+ return (0, _embedpdf_web.loadObjectUrl)(() => anno.renderArmedStampPreview(bucket), setUrl);
217
+ }, [
218
+ anno,
219
+ armed,
220
+ bucket
221
+ ]);
222
+ if (!ghost || !url) return null;
223
+ const frame = (0, _embedpdf_web.rectInPixels)(ghost.box, page.transform);
224
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("img", {
225
+ src: url,
226
+ alt: "",
227
+ draggable: false,
228
+ style: {
229
+ position: "absolute",
230
+ left: frame.left,
231
+ top: frame.top,
232
+ width: frame.width,
233
+ height: frame.height,
234
+ maxWidth: "none",
235
+ maxHeight: "none",
236
+ pointerEvents: "none",
237
+ opacity: (0, _embedpdf_web.ghostOpacity)(ghost.opacity),
238
+ ...ghost.rot ? {
239
+ transform: `rotate(${ghost.rot}deg)`,
240
+ transformOrigin: "center"
241
+ } : {}
242
+ }
243
+ });
244
+ }
245
+ /** The chrome settings, painted: follows the settings and the viewer's accent live. */
246
+ function useChromePaint() {
247
+ const chrome = useAnnotationSettings((settings) => settings.chrome);
248
+ const accent = require_runtime.useViewerSettings((settings) => settings.accent);
249
+ return {
250
+ chrome,
251
+ painted: react.useMemo(() => (0, _embedpdf_web.annotationChromePaint)(chrome, accent), [chrome, accent])
252
+ };
253
+ }
254
+ /** A handle as the layer draws it: a square or a circle, `size` px across. */
255
+ function DefaultHandle({ at, size, rotation, shape, style }) {
256
+ if (shape === "circle") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
257
+ cx: at.x,
258
+ cy: at.y,
259
+ r: size / 2,
260
+ strokeWidth: 1.5,
261
+ style
262
+ });
263
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
264
+ x: at.x - size / 2,
265
+ y: at.y - size / 2,
266
+ width: size,
267
+ height: size,
268
+ strokeWidth: 1.5,
269
+ style,
270
+ ...rotation ? { transform: `rotate(${rotation} ${at.x} ${at.y})` } : {}
271
+ });
272
+ }
273
+ function Chrome({ page, components }) {
274
+ const scale = page.transform.viewScale;
275
+ const rotation = page.transform.rotation;
276
+ const zoom = page.transform.zoom;
277
+ const nodes = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.listChromeNodes(page.ref, scale, rotation, zoom), require_runtime.shallowArray);
278
+ const { chrome, painted } = useChromePaint();
279
+ const Handle = components?.Handle;
280
+ const RotationHandle = components?.RotationHandle;
281
+ const custom = [];
282
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
283
+ style: {
284
+ position: "absolute",
285
+ inset: 0,
286
+ overflow: "visible",
287
+ pointerEvents: "none"
288
+ },
289
+ children: (0, _embedpdf_web.chromeInPixels)(nodes, page.transform).map((node, i) => {
290
+ switch (node.kind) {
291
+ case "handle":
292
+ if (Handle) {
293
+ custom.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(Handle, {
294
+ at: node.at,
295
+ size: chrome.handles.size,
296
+ rotation: node.rotation,
297
+ kind: node.role,
298
+ active: node.active
299
+ }, i));
300
+ return null;
301
+ }
302
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DefaultHandle, {
303
+ at: node.at,
304
+ size: chrome.handles.size,
305
+ rotation: node.rotation,
306
+ shape: chrome.handles.shape,
307
+ style: painted.handle
308
+ }, i);
309
+ case "guide": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
310
+ x1: node.from.x,
311
+ y1: node.from.y,
312
+ x2: node.to.x,
313
+ y2: node.to.y,
314
+ shapeRendering: "crispEdges",
315
+ style: painted.guide
316
+ }, i);
317
+ case "turned-outline": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("polygon", {
318
+ points: node.points,
319
+ fill: "none",
320
+ style: painted.outline
321
+ }, i);
322
+ case "rotation-guides": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("g", { children: node.lines.map((line, j) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
323
+ x1: line.from.x,
324
+ y1: line.from.y,
325
+ x2: line.to.x,
326
+ y2: line.to.y,
327
+ opacity: line.opacity,
328
+ style: painted.rotationGuide
329
+ }, j)) }, i);
330
+ case "rotation-handle":
331
+ if (RotationHandle) {
332
+ custom.push(/* @__PURE__ */ (0, react_jsx_runtime.jsx)(RotationHandle, {
333
+ at: node.at,
334
+ from: node.from,
335
+ size: chrome.rotationHandle.size,
336
+ rotation: 0,
337
+ active: false
338
+ }, i));
339
+ return null;
340
+ }
341
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("g", { children: [chrome.rotationHandle.stalk && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("line", {
342
+ x1: node.from.x,
343
+ y1: node.from.y,
344
+ x2: node.at.x,
345
+ y2: node.at.y,
346
+ strokeWidth: 1,
347
+ style: { stroke: painted.rotationHandle.stroke }
348
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("circle", {
349
+ cx: node.at.x,
350
+ cy: node.at.y,
351
+ r: chrome.rotationHandle.size / 2,
352
+ strokeWidth: 1.5,
353
+ style: painted.rotationHandle
354
+ })] }, i);
355
+ case "marquee": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
356
+ x: node.box.left,
357
+ y: node.box.top,
358
+ width: node.box.width,
359
+ height: node.box.height,
360
+ strokeWidth: 1,
361
+ strokeDasharray: "4 3",
362
+ style: painted.marquee
363
+ }, i);
364
+ case "outline": return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("rect", {
365
+ x: node.box.left,
366
+ y: node.box.top,
367
+ width: node.box.width,
368
+ height: node.box.height,
369
+ fill: "none",
370
+ style: painted.outline
371
+ }, i);
372
+ }
373
+ })
374
+ }), custom.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
375
+ style: {
376
+ position: "absolute",
377
+ inset: 0,
378
+ pointerEvents: "none"
379
+ },
380
+ children: custom
381
+ })] });
382
+ }
383
+ /**
384
+ * Make an element the editor of a text box: `@embedpdf/web`'s text box
385
+ * editor binds it (rich text, focus and `contentEditable` following
386
+ * `item.editing`, presses kept inside), and its follower attaches again for
387
+ * another element or document and hands it the item and the scale. Returns
388
+ * the ref callback for the element.
389
+ */
390
+ function useTextBoxEditor(item, scale) {
391
+ const anno = require_runtime.useCapability(_embedpdf_plugin_annotation_contract_host.AnnotationToken);
392
+ const [element, setElement] = (0, react.useState)(null);
393
+ const [follower] = (0, react.useState)(() => (0, _embedpdf_web.createTextBoxEditorFollower)());
394
+ (0, react.useEffect)(() => follower.follow(element, anno, item, scale), [
395
+ follower,
396
+ anno,
397
+ element,
398
+ item,
399
+ scale
400
+ ]);
401
+ (0, react.useEffect)(() => () => follower.detach(), [follower]);
402
+ return setElement;
403
+ }
404
+ /** A free text annotation: the same styled element for reading and typing. */
405
+ function FreeText({ item, page }) {
406
+ const plate = (0, _embedpdf_web.textPlateInPixels)(item, page.transform);
407
+ const ref = useTextBoxEditor(item, plate.scale);
408
+ const { painted } = useChromePaint();
409
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
410
+ ref,
411
+ suppressContentEditableWarning: true,
412
+ style: {
413
+ position: "absolute",
414
+ left: plate.left,
415
+ top: plate.top,
416
+ width: plate.width,
417
+ height: plate.height,
418
+ ...(0, _embedpdf_web.textBoxStyleOf)(item.css, plate.scale),
419
+ boxSizing: "border-box",
420
+ background: "transparent",
421
+ whiteSpace: "pre-wrap",
422
+ overflowWrap: "break-word",
423
+ overflowY: item.editing ? "auto" : "hidden",
424
+ overflowX: "hidden",
425
+ outline: item.editing ? `1px solid ${painted.textOutline}` : "none",
426
+ cursor: item.editing ? "text" : "default",
427
+ ...item.rot ? {
428
+ transform: `rotate(${item.rot}deg)`,
429
+ transformOrigin: "center"
430
+ } : {},
431
+ pointerEvents: item.editing ? "auto" : "none"
432
+ }
433
+ });
434
+ }
435
+ const NO_STYLE = {};
436
+ /**
437
+ * Make your own element the editor of a text box you draw yourself (a
438
+ * renderer for free text): it draws the runs, turns typing back into runs,
439
+ * keeps the caret when the style changes, and handles pasting, input methods
440
+ * and the format shortcuts. The formatting calls (`text.toggleFormat`,
441
+ * `selection.update`) work on it as they do on the built-in one.
442
+ */
443
+ function useRichTextEditor(annotation) {
444
+ const page = require_runtime.usePage();
445
+ const zoom = page.transform.zoom;
446
+ const rotation = page.transform.rotation;
447
+ const key = (0, _embedpdf_plugin_annotation.annotationKey)(annotation.ref);
448
+ const item = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (anno) => anno.listTextItems(page.ref, {
449
+ zoom,
450
+ rotation
451
+ }).find((text) => text.ref !== null && (0, _embedpdf_plugin_annotation.annotationKey)(text.ref) === key) ?? null, null);
452
+ const scale = (0, _embedpdf_web.textBoxEditorScaleOf)(item, page.transform, react.useContext(LookScaleContext));
453
+ return {
454
+ ref: useTextBoxEditor(item, scale),
455
+ style: react.useMemo(() => item ? {
456
+ ...(0, _embedpdf_web.textBoxStyleOf)(item.css, scale),
457
+ ...item.editing ? { pointerEvents: "auto" } : {}
458
+ } : NO_STYLE, [item, scale]),
459
+ editing: item?.editing ?? false
460
+ };
461
+ }
462
+ /**
463
+ * Register the behaviors this layer's `interactive` renderers need, through
464
+ * `@embedpdf/web`'s `registerRendererBehaviors`: counted per capability and
465
+ * entry, since the layer mounts once per page. Entry identity is the key,
466
+ * hence the "define entries outside render" rule on {@link AnnotationRenderer}.
467
+ * Once they are registered the layer draws again: its drawings ask them.
468
+ */
469
+ function useRendererBehaviors(anno, activeToolId, renderers) {
470
+ const toolRef = (0, react.useRef)(activeToolId);
471
+ toolRef.current = activeToolId;
472
+ const [, setRegistrations] = (0, react.useState)(0);
473
+ (0, react.useEffect)(() => {
474
+ if (!renderers) return;
475
+ const release = (0, _embedpdf_web.registerRendererBehaviors)(anno, renderers, () => toolRef.current());
476
+ setRegistrations((count) => count + 1);
477
+ return release;
478
+ }, [anno, renderers]);
479
+ }
480
+ /**
481
+ * Draws a page's annotations, the selection's outline and handles, the tool's
482
+ * preview and the text boxes being typed in. Put it above the rendered page:
483
+ * while it's there, the render layer leaves the annotations out of the
484
+ * page's picture.
485
+ */
486
+ function AnnotationLayer({ renderers, components } = {}) {
487
+ const page = require_runtime.usePage();
488
+ const anno = require_runtime.useCapability(_embedpdf_plugin_annotation_contract_host.AnnotationToken);
489
+ require_runtime.useOptionalSelector(_embedpdf_plugin_interaction_contract.InteractionToken, (interaction) => interaction.getActiveToolId(), "");
490
+ const interaction = require_runtime.useOptionalCapability(_embedpdf_plugin_interaction_contract.InteractionToken);
491
+ const viewZoom = page.transform.zoom;
492
+ const viewRotation = page.transform.rotation;
493
+ const items = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.listPageItems(page.ref, {
494
+ zoom: viewZoom,
495
+ rotation: viewRotation
496
+ }), require_runtime.shallowArray);
497
+ const texts = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.listTextItems(page.ref, {
498
+ zoom: viewZoom,
499
+ rotation: viewRotation
500
+ }), require_runtime.shallowArray);
501
+ const [urls, setUrls] = (0, react.useState)(null);
502
+ const [shown] = (0, react.useState)(_embedpdf_web.createShownUrls);
503
+ (0, react.useEffect)(() => () => shown.release(), [shown]);
504
+ useRendererBehaviors(anno, () => interaction?.getActiveToolId() ?? "", renderers);
505
+ require_page_layers.usePaintsPagePart(page.ref, "annotations");
506
+ const previousRenderers = (0, react.useRef)(renderers);
507
+ if (renderers && previousRenderers.current && renderers !== previousRenderers.current && require_runtime.shallowArray(renderers, previousRenderers.current)) require_runtime.devWarn("annotation-renderers-inline", "<AnnotationLayer renderers> was given a new array with the same entries — define it outside render (module scope or useMemo), because entry identity keys the behavior registration.");
508
+ previousRenderers.current = renderers;
509
+ const bakedKey = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.getAppearanceEpoch(page.ref));
510
+ const bakeScale = require_runtime.useOptionalSelector(_embedpdf_plugin_render_contract_host.RenderToken, (render) => render.getAppearanceScale(page.transform.renderScale), page.transform.renderScale);
511
+ (0, react.useEffect)(() => (0, _embedpdf_web.loadAppearanceUrls)(shown, (signal) => anno.renderAppearances(page.ref, bakeScale, signal), _embedpdf_plugin_annotation.annotationKey, setUrls), [
512
+ shown,
513
+ anno,
514
+ page.ref,
515
+ bakeScale,
516
+ bakedKey
517
+ ]);
518
+ /** The text box being typed in, by key. */
519
+ const editingKey = (0, _embedpdf_web.editingTextKeyOf)(texts, _embedpdf_plugin_annotation.annotationKey);
520
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
521
+ style: {
522
+ position: "absolute",
523
+ inset: 0,
524
+ pointerEvents: "none"
525
+ },
526
+ children: [
527
+ items.map((item) => {
528
+ const state = item.annotation?.appearanceState ?? null;
529
+ const shows = (0, _embedpdf_web.pictureOrPainting)({
530
+ pending: item.source !== "baked",
531
+ picture: urls && (0, _embedpdf_web.shownAppearance)(urls, item.id, state),
532
+ version: item.pictureVersion ?? 0,
533
+ loaded: urls !== null,
534
+ paint: () => (0, _embedpdf_core_annotation.hasLiveDrawing)(item) ? item : null
535
+ });
536
+ const native = shows?.kind === "painting" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Shape, { item }) : shows?.kind === "picture" && item.raster ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(BakedImage, {
537
+ url: shows.picture.url,
538
+ box: (0, _embedpdf_web.rasterInFrame)(item.raster, item.frame)
539
+ }) : null;
540
+ const framed = (content, options) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotationFrame, {
541
+ item,
542
+ page,
543
+ ...options,
544
+ children: content
545
+ }, item.id);
546
+ const annotation = item.annotation;
547
+ if (!annotation) return framed(native);
548
+ /** Your look in the frame: drawn at the annotation's 100% size and scaled with the page, unless it opts out. */
549
+ const look = (entry, interactive) => {
550
+ const pixels = (0, _embedpdf_web.frameInPixels)(item.frame, page.transform);
551
+ const scaled = entry.scale !== false;
552
+ const Look = entry.component;
553
+ const drawn = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Look, {
554
+ annotation,
555
+ frame: (0, _embedpdf_web.lookFrameOf)(pixels, scaled),
556
+ native,
557
+ appearance: urls && (0, _embedpdf_web.bakedAppearanceOf)(urls, item.id, state),
558
+ hovered: item.hovered ?? false,
559
+ selected: item.selected,
560
+ interactive
561
+ });
562
+ if (!scaled) return drawn;
563
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
564
+ style: {
565
+ position: "absolute",
566
+ left: 0,
567
+ top: 0,
568
+ width: pixels.design.width,
569
+ height: pixels.design.height,
570
+ transform: `scale(${pixels.scale})`,
571
+ transformOrigin: "0 0"
572
+ },
573
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LookScaleContext.Provider, {
574
+ value: pixels.scale,
575
+ children: drawn
576
+ })
577
+ });
578
+ };
579
+ const typing = editingKey !== null && (0, _embedpdf_plugin_annotation.annotationKey)(annotation.ref) === editingKey;
580
+ const drawing = (0, _embedpdf_web.annotationDrawingOf)(annotation, anno, renderers, typing);
581
+ switch (drawing.kind) {
582
+ case "owned": {
583
+ const Owner = drawing.entry.component;
584
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Owner, {
585
+ annotation,
586
+ item,
587
+ page,
588
+ native: framed(native),
589
+ hovered: item.hovered ?? false,
590
+ selected: item.selected,
591
+ interactive: true
592
+ }, item.id);
593
+ }
594
+ case "look": return framed(look(drawing.entry, drawing.interactive), {
595
+ interactive: drawing.interactive,
596
+ inert: drawing.inert
597
+ });
598
+ case "native": return framed(native, { inert: drawing.inert });
599
+ }
600
+ }),
601
+ (0, _embedpdf_web.layerTextBoxesOf)(texts, items, renderers, _embedpdf_plugin_annotation.annotationKey).map((text) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FreeText, {
602
+ item: text,
603
+ page
604
+ }, text.id)),
605
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolGhostImage, { page }),
606
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chrome, {
607
+ page,
608
+ components
609
+ })
610
+ ]
611
+ });
612
+ }
613
+ /**
614
+ * The default file-picker provider: the built-in file dialog (from
615
+ * `@embedpdf/web`), honouring the tool's `accept` filter. This is the adapter
616
+ * fulfilling the plugin's DOM-free port — the dialog lives in the framework
617
+ * layer, never in the plugin.
618
+ */
619
+ const filePickerProvider = _embedpdf_web.pickRequestedFile;
620
+ /**
621
+ * Install the file-picker provider for the active document — the one port
622
+ * behind every click-then-pick tool (a stamp `'prompt'` source, the file-
623
+ * attachment tool). Call once at a document-scoped spot (not inside
624
+ * `<AnnotationLayer>`, which is per page). Defaults to
625
+ * {@link filePickerProvider}, so a bare `useFilePickerProvider()` makes all of
626
+ * them work out of the box; pass a custom provider (asset library, cloud
627
+ * drive — switch on `req.subtype` / `req.toolId`) or `null` to make
628
+ * click-then-pick tools inert. Cleared on unmount.
629
+ */
630
+ function useFilePickerProvider(provider = filePickerProvider) {
631
+ const anno = require_runtime.useOptionalCapability(_embedpdf_plugin_annotation.AnnotationToken);
632
+ (0, react.useEffect)(() => {
633
+ if (!anno) return;
634
+ return (0, _embedpdf_web.installFilePickerProvider)(anno, provider, () => require_runtime.devWarn("file-picker-provider-twice", "useFilePickerProvider() is called from two mounted components for the same document — the later one wins. Call it once, at a document-scoped spot."));
635
+ }, [anno, provider]);
636
+ }
637
+ function useAnnotation() {
638
+ return require_runtime.useCapability(_embedpdf_plugin_annotation.AnnotationToken);
639
+ }
640
+ /** Listen to one annotation event while the component is mounted: `useAnnotationEvent((annotation) => annotation.onCreated, handler)`. */
641
+ function useAnnotationEvent(select, handler) {
642
+ require_runtime.useCapabilityEvent(_embedpdf_plugin_annotation.AnnotationToken, select, handler);
643
+ }
644
+ const NO_ANNOTATIONS = [];
645
+ /**
646
+ * The annotations matching `filter` (some pages, one kind), in drawing order,
647
+ * as the user sees them; the same array while they stay the same. Empty
648
+ * without a document.
649
+ */
650
+ function useAnnotationList(filter) {
651
+ const key = filter ? `${(filter.pages ?? []).map((page) => typeof page === "number" ? `#${page}` : page.objectNumber).join(",")}|${filter.pages ? "p" : ""}|${filter.subtype ?? ""}` : "";
652
+ const stable = react.useMemo(() => filter, [key]);
653
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.list(stable), NO_ANNOTATIONS, require_runtime.shallowArray);
654
+ }
655
+ const NO_DEFAULTS = {};
656
+ /**
657
+ * A tool's defaults: the fields its next annotation starts with, over the
658
+ * engine's. The component re-renders when they change, so a color picker
659
+ * always shows the current color. Empty without a document.
660
+ */
661
+ function useAnnotationDefaults(toolId) {
662
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.tools.getDefaults(toolId), NO_DEFAULTS);
663
+ }
664
+ const NO_PROPERTIES = {
665
+ properties: [],
666
+ values: {},
667
+ mixed: []
668
+ };
669
+ /**
670
+ * What a style panel shows: the selection's properties (`selection.getProperties()`),
671
+ * or, given a tool id, the tool's (`tools.getProperties(id)`). The component
672
+ * re-renders when they change. Empty without a document.
673
+ */
674
+ function useAnnotationProperties(toolId) {
675
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => toolId === void 0 ? annotation.selection.getProperties() : annotation.tools.getProperties(toolId), NO_PROPERTIES);
676
+ }
677
+ /**
678
+ * An anchor for `<Anchored>` that keeps a card or a badge attached to one
679
+ * annotation: its page and the box around what it shows, following a move
680
+ * as it happens. `null` for `null`, or an annotation that isn't here. The
681
+ * component re-renders when the annotation moves, not while people scroll or
682
+ * zoom: a note that keeps its size on screen hands `<Anchored>` its
683
+ * `boundsIn`.
684
+ */
685
+ function useAnnotationAnchor(ref) {
686
+ const key = ref ? (0, _embedpdf_plugin_annotation.annotationKey)(ref) : null;
687
+ const stable = react.useMemo(() => ref, [key]);
688
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => stable ? annotation.getAnnotationAnchor(stable) : null, null, _embedpdf_web.sameAnnotationAnchor);
689
+ }
690
+ /** The comments API: the `comments` part of `useAnnotation()`. Pair it with
691
+ * {@link useCommentThreads} for the threads to show. */
692
+ function useComments() {
693
+ return require_runtime.useCapability(_embedpdf_plugin_annotation.AnnotationToken).comments;
694
+ }
695
+ const EMPTY_PAGES = [];
696
+ const NO_THREADS = [];
697
+ /**
698
+ * Every comment thread in the document, display-ordered (page position →
699
+ * top of page → creation date) and enriched with `pageIndex`/`pageLabel`.
700
+ * Subscribed to both stores: annotation writes (own, remote, hydration)
701
+ * recompute the threads; page moves/deletes re-run the join. Reference-
702
+ * stable between changes — safe to memo child renders on the array.
703
+ */
704
+ function useCommentThreads() {
705
+ const docId = require_runtime.useDocumentId();
706
+ const threads = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.comments.listThreads(), NO_THREADS);
707
+ const pages = require_runtime.useKernelValue((kernel) => docId ? kernel.documents.listPages(docId) : EMPTY_PAGES);
708
+ return react.useMemo(() => (0, _embedpdf_web.enrichCommentThreads)(threads, pages), [threads, pages]);
709
+ }
710
+ /** The enriched thread containing any member ref (root, reply, grouped part,
711
+ * state annotation), or null. */
712
+ function useCommentThread(ref) {
713
+ const views = useCommentThreads();
714
+ const api = require_runtime.useOptionalCapability(_embedpdf_plugin_annotation.AnnotationToken);
715
+ if (ref == null || !api) return null;
716
+ const thread = api.comments.getThread(ref);
717
+ if (!thread) return null;
718
+ return views.find((view) => (0, _embedpdf_plugin_annotation.annotationKey)(view.root.ref) === (0, _embedpdf_plugin_annotation.annotationKey)(thread.root.ref)) ?? null;
719
+ }
720
+ //#endregion
721
+ Object.defineProperty(exports, "AnnotationDraftMenu", {
722
+ enumerable: true,
723
+ get: function() {
724
+ return AnnotationDraftMenu;
725
+ }
726
+ });
727
+ Object.defineProperty(exports, "AnnotationLayer", {
728
+ enumerable: true,
729
+ get: function() {
730
+ return AnnotationLayer;
731
+ }
732
+ });
733
+ Object.defineProperty(exports, "AnnotationMenu", {
734
+ enumerable: true,
735
+ get: function() {
736
+ return AnnotationMenu;
737
+ }
738
+ });
739
+ Object.defineProperty(exports, "AnnotationRotationBadge", {
740
+ enumerable: true,
741
+ get: function() {
742
+ return AnnotationRotationBadge;
743
+ }
744
+ });
745
+ Object.defineProperty(exports, "filePickerProvider", {
746
+ enumerable: true,
747
+ get: function() {
748
+ return filePickerProvider;
749
+ }
750
+ });
751
+ Object.defineProperty(exports, "useAnnotation", {
752
+ enumerable: true,
753
+ get: function() {
754
+ return useAnnotation;
755
+ }
756
+ });
757
+ Object.defineProperty(exports, "useAnnotationAnchor", {
758
+ enumerable: true,
759
+ get: function() {
760
+ return useAnnotationAnchor;
761
+ }
762
+ });
763
+ Object.defineProperty(exports, "useAnnotationDefaults", {
764
+ enumerable: true,
765
+ get: function() {
766
+ return useAnnotationDefaults;
767
+ }
768
+ });
769
+ Object.defineProperty(exports, "useAnnotationEvent", {
770
+ enumerable: true,
771
+ get: function() {
772
+ return useAnnotationEvent;
773
+ }
774
+ });
775
+ Object.defineProperty(exports, "useAnnotationList", {
776
+ enumerable: true,
777
+ get: function() {
778
+ return useAnnotationList;
779
+ }
780
+ });
781
+ Object.defineProperty(exports, "useAnnotationProperties", {
782
+ enumerable: true,
783
+ get: function() {
784
+ return useAnnotationProperties;
785
+ }
786
+ });
787
+ Object.defineProperty(exports, "useAnnotationSettings", {
788
+ enumerable: true,
789
+ get: function() {
790
+ return useAnnotationSettings;
791
+ }
792
+ });
793
+ Object.defineProperty(exports, "useAnnotationState", {
794
+ enumerable: true,
795
+ get: function() {
796
+ return useAnnotationState;
797
+ }
798
+ });
799
+ Object.defineProperty(exports, "useCommentThread", {
800
+ enumerable: true,
801
+ get: function() {
802
+ return useCommentThread;
803
+ }
804
+ });
805
+ Object.defineProperty(exports, "useCommentThreads", {
806
+ enumerable: true,
807
+ get: function() {
808
+ return useCommentThreads;
809
+ }
810
+ });
811
+ Object.defineProperty(exports, "useComments", {
812
+ enumerable: true,
813
+ get: function() {
814
+ return useComments;
815
+ }
816
+ });
817
+ Object.defineProperty(exports, "useFilePickerProvider", {
818
+ enumerable: true,
819
+ get: function() {
820
+ return useFilePickerProvider;
821
+ }
822
+ });
823
+ Object.defineProperty(exports, "useRichTextEditor", {
824
+ enumerable: true,
825
+ get: function() {
826
+ return useRichTextEditor;
827
+ }
828
+ });
829
+
830
+ //# sourceMappingURL=annotation-Dex5EBda.cjs.map