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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.cts +878 -0
  2. package/dist/AnnotationList-DcyhF2kU-CiBFOq1z.d.ts +878 -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-3UvABfJm.d.cts +305 -0
  18. package/dist/annotation-BNHQpMKv.cjs +806 -0
  19. package/dist/annotation-BNHQpMKv.cjs.map +1 -0
  20. package/dist/annotation-CDI8CFb3.js +684 -0
  21. package/dist/annotation-CDI8CFb3.js.map +1 -0
  22. package/dist/annotation-DhEfs0pH.d.ts +305 -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/attachment.cjs +39 -0
  28. package/dist/attachment.cjs.map +1 -0
  29. package/dist/attachment.d.cts +29 -0
  30. package/dist/attachment.d.ts +29 -0
  31. package/dist/attachment.js +28 -0
  32. package/dist/attachment.js.map +1 -0
  33. package/dist/commands.cjs +68 -28
  34. package/dist/commands.cjs.map +1 -1
  35. package/dist/commands.d.cts +37 -10
  36. package/dist/commands.d.ts +37 -10
  37. package/dist/commands.js +68 -31
  38. package/dist/commands.js.map +1 -1
  39. package/dist/form-BSGvjA5D.js +511 -0
  40. package/dist/form-BSGvjA5D.js.map +1 -0
  41. package/dist/form-BgztZyOK.cjs +548 -0
  42. package/dist/form-BgztZyOK.cjs.map +1 -0
  43. package/dist/form.cjs +5 -5
  44. package/dist/form.d.cts +41 -2
  45. package/dist/form.d.ts +41 -2
  46. package/dist/form.js +2 -3
  47. package/dist/history.cjs +38 -0
  48. package/dist/history.cjs.map +1 -0
  49. package/dist/history.d.cts +27 -0
  50. package/dist/history.d.ts +27 -0
  51. package/dist/history.js +27 -0
  52. package/dist/history.js.map +1 -0
  53. package/dist/i18n.cjs +26 -30
  54. package/dist/i18n.cjs.map +1 -1
  55. package/dist/i18n.d.cts +24 -21
  56. package/dist/i18n.d.ts +24 -21
  57. package/dist/i18n.js +24 -31
  58. package/dist/i18n.js.map +1 -1
  59. package/dist/index.cjs +227 -57
  60. package/dist/index.d.cts +35 -32
  61. package/dist/index.d.ts +35 -32
  62. package/dist/index.js +36 -30
  63. package/dist/inert-CmBEbKCn.cjs +19 -0
  64. package/dist/inert-CmBEbKCn.cjs.map +1 -0
  65. package/dist/inert-D8fkennb.js +14 -0
  66. package/dist/inert-D8fkennb.js.map +1 -0
  67. package/dist/interaction.cjs +48 -102
  68. package/dist/interaction.cjs.map +1 -1
  69. package/dist/interaction.d.cts +23 -32
  70. package/dist/interaction.d.ts +23 -32
  71. package/dist/interaction.js +33 -102
  72. package/dist/interaction.js.map +1 -1
  73. package/dist/link.cjs +65 -104
  74. package/dist/link.cjs.map +1 -1
  75. package/dist/link.d.cts +21 -16
  76. package/dist/link.d.ts +22 -17
  77. package/dist/link.js +67 -107
  78. package/dist/link.js.map +1 -1
  79. package/dist/measurement.cjs +36 -11
  80. package/dist/measurement.cjs.map +1 -1
  81. package/dist/measurement.d.cts +33 -7
  82. package/dist/measurement.d.ts +33 -7
  83. package/dist/measurement.js +35 -14
  84. package/dist/measurement.js.map +1 -1
  85. package/dist/metadata.cjs +20 -7
  86. package/dist/metadata.cjs.map +1 -1
  87. package/dist/metadata.d.cts +22 -7
  88. package/dist/metadata.d.ts +22 -7
  89. package/dist/metadata.js +20 -10
  90. package/dist/metadata.js.map +1 -1
  91. package/dist/outline.cjs +39 -0
  92. package/dist/outline.cjs.map +1 -0
  93. package/dist/outline.d.cts +31 -0
  94. package/dist/outline.d.ts +31 -0
  95. package/dist/outline.js +28 -0
  96. package/dist/outline.js.map +1 -0
  97. package/dist/page-edit.cjs +15 -3
  98. package/dist/page-edit.cjs.map +1 -1
  99. package/dist/page-edit.d.cts +17 -2
  100. package/dist/page-edit.d.ts +17 -2
  101. package/dist/page-edit.js +15 -5
  102. package/dist/page-edit.js.map +1 -1
  103. package/dist/page-layers-Bkaaz8Zf.js +26 -0
  104. package/dist/page-layers-Bkaaz8Zf.js.map +1 -0
  105. package/dist/page-layers-BloZDoOV.cjs +37 -0
  106. package/dist/page-layers-BloZDoOV.cjs.map +1 -0
  107. package/dist/page-view.cjs +89 -82
  108. package/dist/page-view.cjs.map +1 -1
  109. package/dist/page-view.d.cts +14 -7
  110. package/dist/page-view.d.ts +18 -11
  111. package/dist/page-view.js +86 -81
  112. package/dist/page-view.js.map +1 -1
  113. package/dist/redaction.cjs +30 -15
  114. package/dist/redaction.cjs.map +1 -1
  115. package/dist/redaction.d.cts +27 -9
  116. package/dist/redaction.d.ts +27 -9
  117. package/dist/redaction.js +29 -18
  118. package/dist/redaction.js.map +1 -1
  119. package/dist/render.cjs +71 -46
  120. package/dist/render.cjs.map +1 -1
  121. package/dist/render.d.cts +17 -5
  122. package/dist/render.d.ts +17 -5
  123. package/dist/render.js +70 -49
  124. package/dist/render.js.map +1 -1
  125. package/dist/runtime-BfnpyfY0.cjs +556 -0
  126. package/dist/runtime-BfnpyfY0.cjs.map +1 -0
  127. package/dist/runtime-DBEBlpQV.d.cts +237 -0
  128. package/dist/runtime-V3MVMb91.d.ts +237 -0
  129. package/dist/runtime-tD5iJU83.js +399 -0
  130. package/dist/runtime-tD5iJU83.js.map +1 -0
  131. package/dist/runtime.cjs +45 -324
  132. package/dist/runtime.d.cts +2 -2
  133. package/dist/runtime.d.ts +2 -2
  134. package/dist/runtime.js +2 -306
  135. package/dist/search.cjs +81 -50
  136. package/dist/search.cjs.map +1 -1
  137. package/dist/search.d.cts +37 -24
  138. package/dist/search.d.ts +37 -24
  139. package/dist/search.js +81 -53
  140. package/dist/search.js.map +1 -1
  141. package/dist/selection.cjs +105 -108
  142. package/dist/selection.cjs.map +1 -1
  143. package/dist/selection.d.cts +54 -26
  144. package/dist/selection.d.ts +56 -28
  145. package/dist/selection.js +103 -110
  146. package/dist/selection.js.map +1 -1
  147. package/dist/shell.cjs +36 -21
  148. package/dist/shell.cjs.map +1 -1
  149. package/dist/shell.d.cts +32 -17
  150. package/dist/shell.d.ts +32 -17
  151. package/dist/shell.js +36 -24
  152. package/dist/shell.js.map +1 -1
  153. package/dist/signature.cjs +29 -48
  154. package/dist/signature.cjs.map +1 -1
  155. package/dist/signature.d.cts +26 -26
  156. package/dist/signature.d.ts +26 -26
  157. package/dist/signature.js +30 -48
  158. package/dist/signature.js.map +1 -1
  159. package/dist/stage-B7BG2e8Q.cjs +369 -0
  160. package/dist/stage-B7BG2e8Q.cjs.map +1 -0
  161. package/dist/stage-BqfBjDu6.js +302 -0
  162. package/dist/stage-BqfBjDu6.js.map +1 -0
  163. package/dist/stage-ByFPD-Fv.d.cts +117 -0
  164. package/dist/stage-DaboaheR.d.ts +117 -0
  165. package/dist/stage-scope-CQgCuf1w.cjs +46 -0
  166. package/dist/stage-scope-CQgCuf1w.cjs.map +1 -0
  167. package/dist/stage-scope-D7ZeNduT.js +23 -0
  168. package/dist/stage-scope-D7ZeNduT.js.map +1 -0
  169. package/dist/stage.cjs +12 -235
  170. package/dist/stage.d.cts +2 -116
  171. package/dist/stage.d.ts +2 -116
  172. package/dist/stage.js +3 -228
  173. package/dist/stamp.cjs +41 -35
  174. package/dist/stamp.cjs.map +1 -1
  175. package/dist/stamp.d.cts +25 -18
  176. package/dist/stamp.d.ts +25 -18
  177. package/dist/stamp.js +40 -37
  178. package/dist/stamp.js.map +1 -1
  179. package/dist/state-0K1I5cM4.d.cts +29 -0
  180. package/dist/state-0K1I5cM4.d.ts +29 -0
  181. package/dist/state-CzI2KlZb.js +62 -0
  182. package/dist/state-CzI2KlZb.js.map +1 -0
  183. package/dist/state-Dtf8HAue.cjs +73 -0
  184. package/dist/state-Dtf8HAue.cjs.map +1 -0
  185. package/dist/svg-shapes-Dm1yTR1b.js +40 -0
  186. package/dist/svg-shapes-Dm1yTR1b.js.map +1 -0
  187. package/dist/svg-shapes-zo0GNkc9.cjs +53 -0
  188. package/dist/svg-shapes-zo0GNkc9.cjs.map +1 -0
  189. package/dist/toolbar.cjs +297 -295
  190. package/dist/toolbar.cjs.map +1 -1
  191. package/dist/toolbar.d.cts +58 -68
  192. package/dist/toolbar.d.ts +67 -77
  193. package/dist/toolbar.js +271 -293
  194. package/dist/toolbar.js.map +1 -1
  195. package/dist/view-manager.cjs +34 -0
  196. package/dist/view-manager.cjs.map +1 -0
  197. package/dist/view-manager.d.cts +21 -0
  198. package/dist/view-manager.d.ts +21 -0
  199. package/dist/view-manager.js +23 -0
  200. package/dist/view-manager.js.map +1 -0
  201. package/package.json +47 -39
  202. package/dist/annotation-BCED_p9H.d.cts +0 -160
  203. package/dist/annotation-anchors-CetwM1g7.js +0 -15
  204. package/dist/annotation-anchors-CetwM1g7.js.map +0 -1
  205. package/dist/annotation-anchors-DuYRBJLl.cjs +0 -26
  206. package/dist/annotation-anchors-DuYRBJLl.cjs.map +0 -1
  207. package/dist/annotation-hooks-BB5ZhPpf.cjs +0 -16
  208. package/dist/annotation-hooks-BB5ZhPpf.cjs.map +0 -1
  209. package/dist/annotation-hooks-Df8EmzDO.js +0 -11
  210. package/dist/annotation-hooks-Df8EmzDO.js.map +0 -1
  211. package/dist/annotation-k38KDlIZ.d.ts +0 -160
  212. package/dist/annotation-menu.cjs +0 -64
  213. package/dist/annotation-menu.cjs.map +0 -1
  214. package/dist/annotation-menu.d.cts +0 -33
  215. package/dist/annotation-menu.d.ts +0 -33
  216. package/dist/annotation-menu.js +0 -48
  217. package/dist/annotation-menu.js.map +0 -1
  218. package/dist/annotation.cjs.map +0 -1
  219. package/dist/annotation.js.map +0 -1
  220. package/dist/form-BVumS7up.cjs +0 -926
  221. package/dist/form-BVumS7up.cjs.map +0 -1
  222. package/dist/form-Bdjk0Z3T.d.cts +0 -537
  223. package/dist/form-CK3mp99m.js +0 -895
  224. package/dist/form-CK3mp99m.js.map +0 -1
  225. package/dist/form-CYRYgthn.d.ts +0 -537
  226. package/dist/rolldown-runtime-BBjsoOtd.js +0 -27
  227. package/dist/runtime-DE76hlnl.d.ts +0 -216
  228. package/dist/runtime-umHA_xHt.d.cts +0 -216
  229. package/dist/runtime.cjs.map +0 -1
  230. package/dist/runtime.js.map +0 -1
  231. package/dist/scrollbar.cjs +0 -241
  232. package/dist/scrollbar.cjs.map +0 -1
  233. package/dist/scrollbar.d.cts +0 -42
  234. package/dist/scrollbar.d.ts +0 -42
  235. package/dist/scrollbar.js +0 -213
  236. package/dist/scrollbar.js.map +0 -1
  237. package/dist/stage.cjs.map +0 -1
  238. package/dist/stage.js.map +0 -1
  239. package/dist/views.cjs +0 -35
  240. package/dist/views.cjs.map +0 -1
  241. package/dist/views.d.cts +0 -21
  242. package/dist/views.d.ts +0 -21
  243. package/dist/views.js +0 -27
  244. package/dist/views.js.map +0 -1
@@ -0,0 +1,806 @@
1
+ const require_rolldown_runtime = require("./rolldown-runtime-DDXJien1.cjs");
2
+ const require_runtime = require("./runtime-BfnpyfY0.cjs");
3
+ const require_state = require("./state-Dtf8HAue.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 { painted } = useChromePaint();
407
+ const box = (0, _embedpdf_web.freeTextBoxOf)(item, page.transform, painted.textOutline);
408
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
409
+ ref: useTextBoxEditor(item, box.scale),
410
+ suppressContentEditableWarning: true,
411
+ style: box.style
412
+ });
413
+ }
414
+ const NO_STYLE = {};
415
+ /**
416
+ * Make your own element the editor of a text box you draw yourself (a
417
+ * renderer for free text): it draws the runs, turns typing back into runs,
418
+ * keeps the caret when the style changes, and handles pasting, input methods
419
+ * and the format shortcuts. The formatting calls (`text.toggleFormat`,
420
+ * `selection.update`) work on it as they do on the built-in one.
421
+ */
422
+ function useRichTextEditor(annotation) {
423
+ const page = require_runtime.usePage();
424
+ const zoom = page.transform.zoom;
425
+ const rotation = page.transform.rotation;
426
+ const item = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (anno) => anno.getTextItem(annotation.ref, {
427
+ zoom,
428
+ rotation
429
+ }), null);
430
+ const scale = (0, _embedpdf_web.textBoxEditorScaleOf)(item, page.transform, react.useContext(LookScaleContext));
431
+ const own = react.useMemo(() => item ? (0, _embedpdf_web.ownTextBoxOf)(item, scale) : null, [item, scale]);
432
+ return {
433
+ ref: useTextBoxEditor(item, own?.scale ?? scale),
434
+ style: own?.style ?? NO_STYLE,
435
+ editing: item?.editing ?? false
436
+ };
437
+ }
438
+ /**
439
+ * Register the behaviors this layer's `interactive` renderers need, through
440
+ * `@embedpdf/web`'s `registerRendererBehaviors`: counted per capability and
441
+ * entry, since the layer mounts once per page. Entry identity is the key,
442
+ * hence the "define entries outside render" rule on {@link AnnotationRenderer}.
443
+ * Once they are registered the layer draws again: its drawings ask them.
444
+ */
445
+ function useRendererBehaviors(anno, activeToolId, renderers) {
446
+ const toolRef = (0, react.useRef)(activeToolId);
447
+ toolRef.current = activeToolId;
448
+ const [, setRegistrations] = (0, react.useState)(0);
449
+ (0, react.useEffect)(() => {
450
+ if (!renderers) return;
451
+ const release = (0, _embedpdf_web.registerRendererBehaviors)(anno, renderers, () => toolRef.current());
452
+ setRegistrations((count) => count + 1);
453
+ return release;
454
+ }, [anno, renderers]);
455
+ }
456
+ /**
457
+ * Draws a page's annotations, the selection's outline and handles, the tool's
458
+ * preview and the text boxes being typed in. Put it above the rendered page:
459
+ * while it's there, the render layer leaves the annotations out of the
460
+ * page's picture.
461
+ */
462
+ function AnnotationLayer({ renderers, components } = {}) {
463
+ const page = require_runtime.usePage();
464
+ const anno = require_runtime.useCapability(_embedpdf_plugin_annotation_contract_host.AnnotationToken);
465
+ require_runtime.useOptionalSelector(_embedpdf_plugin_interaction_contract.InteractionToken, (interaction) => interaction.getActiveToolId(), "");
466
+ const interaction = require_runtime.useOptionalCapability(_embedpdf_plugin_interaction_contract.InteractionToken);
467
+ const viewZoom = page.transform.zoom;
468
+ const viewRotation = page.transform.rotation;
469
+ const items = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.listPageItems(page.ref, {
470
+ zoom: viewZoom,
471
+ rotation: viewRotation
472
+ }), require_runtime.shallowArray);
473
+ const texts = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.listTextItems(page.ref, {
474
+ zoom: viewZoom,
475
+ rotation: viewRotation
476
+ }), require_runtime.shallowArray);
477
+ const [urls, setUrls] = (0, react.useState)(null);
478
+ const [shown] = (0, react.useState)(_embedpdf_web.createShownUrls);
479
+ (0, react.useEffect)(() => () => shown.release(), [shown]);
480
+ useRendererBehaviors(anno, () => interaction?.getActiveToolId() ?? "", renderers);
481
+ require_page_layers.usePaintsPagePart(page.ref, "annotations");
482
+ const previousRenderers = (0, react.useRef)(renderers);
483
+ 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.");
484
+ previousRenderers.current = renderers;
485
+ const bakedKey = require_runtime.useSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => annotation.getAppearanceEpoch(page.ref));
486
+ const bakeScale = require_runtime.useOptionalSelector(_embedpdf_plugin_render_contract_host.RenderToken, (render) => render.getAppearanceScale(page.transform.renderScale), page.transform.renderScale);
487
+ (0, react.useEffect)(() => (0, _embedpdf_web.loadAppearanceUrls)(shown, (signal) => anno.renderAppearances(page.ref, bakeScale, signal), _embedpdf_plugin_annotation.annotationKey, setUrls), [
488
+ shown,
489
+ anno,
490
+ page.ref,
491
+ bakeScale,
492
+ bakedKey
493
+ ]);
494
+ /** The text box being typed in, by key. */
495
+ const editingKey = (0, _embedpdf_web.editingTextKeyOf)(texts, _embedpdf_plugin_annotation.annotationKey);
496
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
497
+ style: {
498
+ position: "absolute",
499
+ inset: 0,
500
+ pointerEvents: "none"
501
+ },
502
+ children: [
503
+ items.map((item) => {
504
+ const state = item.annotation?.appearanceState ?? null;
505
+ const shows = (0, _embedpdf_web.pictureOrPainting)({
506
+ pending: item.source !== "baked",
507
+ picture: urls && (0, _embedpdf_web.shownAppearance)(urls, item.id, state),
508
+ version: item.pictureVersion ?? 0,
509
+ loaded: urls !== null,
510
+ paint: () => (0, _embedpdf_core_annotation.hasLiveDrawing)(item) ? item : null
511
+ });
512
+ 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, {
513
+ url: shows.picture.url,
514
+ box: (0, _embedpdf_web.rasterInFrame)(item.raster, item.frame)
515
+ }) : null;
516
+ const framed = (content, options) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(AnnotationFrame, {
517
+ item,
518
+ page,
519
+ ...options,
520
+ children: content
521
+ }, item.id);
522
+ const annotation = item.annotation;
523
+ if (!annotation) return framed(native);
524
+ /** Your look in the frame: drawn at the annotation's 100% size and scaled with the page, unless it opts out. */
525
+ const look = (entry, interactive) => {
526
+ const pixels = (0, _embedpdf_web.frameInPixels)(item.frame, page.transform);
527
+ const scaled = entry.scale !== false;
528
+ const Look = entry.component;
529
+ const drawn = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Look, {
530
+ annotation,
531
+ frame: (0, _embedpdf_web.lookFrameOf)(pixels, scaled),
532
+ native,
533
+ appearance: urls && (0, _embedpdf_web.bakedAppearanceOf)(urls, item.id, state),
534
+ hovered: item.hovered ?? false,
535
+ selected: item.selected,
536
+ interactive
537
+ });
538
+ if (!scaled) return drawn;
539
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
540
+ style: {
541
+ position: "absolute",
542
+ left: 0,
543
+ top: 0,
544
+ width: pixels.design.width,
545
+ height: pixels.design.height,
546
+ transform: `scale(${pixels.scale})`,
547
+ transformOrigin: "0 0"
548
+ },
549
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LookScaleContext.Provider, {
550
+ value: pixels.scale,
551
+ children: drawn
552
+ })
553
+ });
554
+ };
555
+ const typing = editingKey !== null && (0, _embedpdf_plugin_annotation.annotationKey)(annotation.ref) === editingKey;
556
+ const drawing = (0, _embedpdf_web.annotationDrawingOf)(annotation, anno, renderers, typing);
557
+ switch (drawing.kind) {
558
+ case "owned": {
559
+ const Owner = drawing.entry.component;
560
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Owner, {
561
+ annotation,
562
+ item,
563
+ page,
564
+ native: framed(native),
565
+ hovered: item.hovered ?? false,
566
+ selected: item.selected,
567
+ interactive: true
568
+ }, item.id);
569
+ }
570
+ case "look": return framed(look(drawing.entry, drawing.interactive), {
571
+ interactive: drawing.interactive,
572
+ inert: drawing.inert
573
+ });
574
+ case "native": return framed(native, { inert: drawing.inert });
575
+ }
576
+ }),
577
+ (0, _embedpdf_web.layerTextBoxesOf)(texts, items, renderers, _embedpdf_plugin_annotation.annotationKey).map((text) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(FreeText, {
578
+ item: text,
579
+ page
580
+ }, text.id)),
581
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ToolGhostImage, { page }),
582
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Chrome, {
583
+ page,
584
+ components
585
+ })
586
+ ]
587
+ });
588
+ }
589
+ /**
590
+ * The default file-picker provider: the built-in file dialog (from
591
+ * `@embedpdf/web`), honouring the tool's `accept` filter. This is the adapter
592
+ * fulfilling the plugin's DOM-free port — the dialog lives in the framework
593
+ * layer, never in the plugin.
594
+ */
595
+ const filePickerProvider = _embedpdf_web.pickRequestedFile;
596
+ /**
597
+ * Install the file-picker provider for the active document — the one port
598
+ * behind every click-then-pick tool (a stamp `'prompt'` source, the file-
599
+ * attachment tool). Call once at a document-scoped spot (not inside
600
+ * `<AnnotationLayer>`, which is per page). Defaults to
601
+ * {@link filePickerProvider}, so a bare `useFilePickerProvider()` makes all of
602
+ * them work out of the box; pass a custom provider (asset library, cloud
603
+ * drive — switch on `req.subtype` / `req.toolId`) or `null` to make
604
+ * click-then-pick tools inert. Cleared on unmount.
605
+ */
606
+ function useFilePickerProvider(provider = filePickerProvider) {
607
+ const anno = require_runtime.useOptionalCapability(_embedpdf_plugin_annotation.AnnotationToken);
608
+ (0, react.useEffect)(() => {
609
+ if (!anno) return;
610
+ 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."));
611
+ }, [anno, provider]);
612
+ }
613
+ function useAnnotation() {
614
+ return require_runtime.useCapability(_embedpdf_plugin_annotation.AnnotationToken);
615
+ }
616
+ /** Listen to one annotation event while the component is mounted: `useAnnotationEvent((annotation) => annotation.onCreated, handler)`. */
617
+ function useAnnotationEvent(select, handler) {
618
+ require_runtime.useCapabilityEvent(_embedpdf_plugin_annotation.AnnotationToken, select, handler);
619
+ }
620
+ const NO_ANNOTATIONS = [];
621
+ /**
622
+ * The annotations matching `filter` (some pages, one kind), in drawing order,
623
+ * as the user sees them; the same array while they stay the same. Empty
624
+ * without a document.
625
+ */
626
+ function useAnnotationList(filter) {
627
+ const key = filter ? `${(filter.pages ?? []).map((page) => typeof page === "number" ? `#${page}` : page.objectNumber).join(",")}|${filter.pages ? "p" : ""}|${filter.subtype ?? ""}` : "";
628
+ const stable = react.useMemo(() => filter, [key]);
629
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.list(stable), NO_ANNOTATIONS, require_runtime.shallowArray);
630
+ }
631
+ const NO_DEFAULTS = {};
632
+ /**
633
+ * A tool's defaults: the fields its next annotation starts with, over the
634
+ * engine's. The component re-renders when they change, so a color picker
635
+ * always shows the current color. Empty without a document.
636
+ */
637
+ function useAnnotationDefaults(toolId) {
638
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.tools.getDefaults(toolId), NO_DEFAULTS);
639
+ }
640
+ const NO_PROPERTIES = {
641
+ properties: [],
642
+ values: {},
643
+ mixed: []
644
+ };
645
+ /**
646
+ * What a style panel shows: the selection's properties (`selection.getProperties()`),
647
+ * or, given a tool id, the tool's (`tools.getProperties(id)`). The component
648
+ * re-renders when they change. Empty without a document.
649
+ */
650
+ function useAnnotationProperties(toolId) {
651
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => toolId === void 0 ? annotation.selection.getProperties() : annotation.tools.getProperties(toolId), NO_PROPERTIES);
652
+ }
653
+ /**
654
+ * An anchor for `<Anchored>` that keeps a card or a badge attached to one
655
+ * annotation: its page and the box around what it shows, following a move
656
+ * as it happens. `null` for `null`, or an annotation that isn't here. The
657
+ * component re-renders when the annotation moves, not while people scroll or
658
+ * zoom: a note that keeps its size on screen hands `<Anchored>` its
659
+ * `boundsIn`.
660
+ */
661
+ function useAnnotationAnchor(ref) {
662
+ const key = ref ? (0, _embedpdf_plugin_annotation.annotationKey)(ref) : null;
663
+ const stable = react.useMemo(() => ref, [key]);
664
+ return require_runtime.useOptionalSelector(_embedpdf_plugin_annotation_contract_host.AnnotationToken, (annotation) => stable ? annotation.getAnnotationAnchor(stable) : null, null, _embedpdf_web.sameAnnotationAnchor);
665
+ }
666
+ /** The comments API: the `comments` part of `useAnnotation()`. Pair it with
667
+ * {@link useCommentThreads} for the threads to show. */
668
+ function useComments() {
669
+ return require_runtime.useCapability(_embedpdf_plugin_annotation.AnnotationToken).comments;
670
+ }
671
+ const EMPTY_PAGES = [];
672
+ const NO_THREADS = [];
673
+ /**
674
+ * Every comment thread in the document, display-ordered (page position →
675
+ * top of page → creation date) and enriched with `pageIndex`/`pageLabel`.
676
+ * Subscribed to both stores: annotation writes (own, remote, hydration)
677
+ * recompute the threads; page moves/deletes re-run the join. Reference-
678
+ * stable between changes — safe to memo child renders on the array.
679
+ */
680
+ function useCommentThreads() {
681
+ const docId = require_runtime.useDocumentId();
682
+ const threads = require_runtime.useOptionalSelector(_embedpdf_plugin_annotation.AnnotationToken, (annotation) => annotation.comments.listThreads(), NO_THREADS);
683
+ const pages = require_runtime.useKernelValue((kernel) => docId ? kernel.documents.listPages(docId) : EMPTY_PAGES);
684
+ return react.useMemo(() => (0, _embedpdf_web.enrichCommentThreads)(threads, pages), [threads, pages]);
685
+ }
686
+ /** The enriched thread containing any member ref (root, reply, grouped part,
687
+ * state annotation), or null. */
688
+ function useCommentThread(ref) {
689
+ const views = useCommentThreads();
690
+ const api = require_runtime.useOptionalCapability(_embedpdf_plugin_annotation.AnnotationToken);
691
+ if (ref == null || !api) return null;
692
+ const thread = api.comments.getThread(ref);
693
+ if (!thread) return null;
694
+ return views.find((view) => (0, _embedpdf_plugin_annotation.annotationKey)(view.root.ref) === (0, _embedpdf_plugin_annotation.annotationKey)(thread.root.ref)) ?? null;
695
+ }
696
+ //#endregion
697
+ Object.defineProperty(exports, "AnnotationDraftMenu", {
698
+ enumerable: true,
699
+ get: function() {
700
+ return AnnotationDraftMenu;
701
+ }
702
+ });
703
+ Object.defineProperty(exports, "AnnotationLayer", {
704
+ enumerable: true,
705
+ get: function() {
706
+ return AnnotationLayer;
707
+ }
708
+ });
709
+ Object.defineProperty(exports, "AnnotationMenu", {
710
+ enumerable: true,
711
+ get: function() {
712
+ return AnnotationMenu;
713
+ }
714
+ });
715
+ Object.defineProperty(exports, "AnnotationRotationBadge", {
716
+ enumerable: true,
717
+ get: function() {
718
+ return AnnotationRotationBadge;
719
+ }
720
+ });
721
+ Object.defineProperty(exports, "filePickerProvider", {
722
+ enumerable: true,
723
+ get: function() {
724
+ return filePickerProvider;
725
+ }
726
+ });
727
+ Object.defineProperty(exports, "useAnnotation", {
728
+ enumerable: true,
729
+ get: function() {
730
+ return useAnnotation;
731
+ }
732
+ });
733
+ Object.defineProperty(exports, "useAnnotationAnchor", {
734
+ enumerable: true,
735
+ get: function() {
736
+ return useAnnotationAnchor;
737
+ }
738
+ });
739
+ Object.defineProperty(exports, "useAnnotationDefaults", {
740
+ enumerable: true,
741
+ get: function() {
742
+ return useAnnotationDefaults;
743
+ }
744
+ });
745
+ Object.defineProperty(exports, "useAnnotationEvent", {
746
+ enumerable: true,
747
+ get: function() {
748
+ return useAnnotationEvent;
749
+ }
750
+ });
751
+ Object.defineProperty(exports, "useAnnotationList", {
752
+ enumerable: true,
753
+ get: function() {
754
+ return useAnnotationList;
755
+ }
756
+ });
757
+ Object.defineProperty(exports, "useAnnotationProperties", {
758
+ enumerable: true,
759
+ get: function() {
760
+ return useAnnotationProperties;
761
+ }
762
+ });
763
+ Object.defineProperty(exports, "useAnnotationSettings", {
764
+ enumerable: true,
765
+ get: function() {
766
+ return useAnnotationSettings;
767
+ }
768
+ });
769
+ Object.defineProperty(exports, "useAnnotationState", {
770
+ enumerable: true,
771
+ get: function() {
772
+ return useAnnotationState;
773
+ }
774
+ });
775
+ Object.defineProperty(exports, "useCommentThread", {
776
+ enumerable: true,
777
+ get: function() {
778
+ return useCommentThread;
779
+ }
780
+ });
781
+ Object.defineProperty(exports, "useCommentThreads", {
782
+ enumerable: true,
783
+ get: function() {
784
+ return useCommentThreads;
785
+ }
786
+ });
787
+ Object.defineProperty(exports, "useComments", {
788
+ enumerable: true,
789
+ get: function() {
790
+ return useComments;
791
+ }
792
+ });
793
+ Object.defineProperty(exports, "useFilePickerProvider", {
794
+ enumerable: true,
795
+ get: function() {
796
+ return useFilePickerProvider;
797
+ }
798
+ });
799
+ Object.defineProperty(exports, "useRichTextEditor", {
800
+ enumerable: true,
801
+ get: function() {
802
+ return useRichTextEditor;
803
+ }
804
+ });
805
+
806
+ //# sourceMappingURL=annotation-BNHQpMKv.cjs.map