@embedpdf/plugin-annotation 2.8.0 → 2.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +814 -139
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/geometry/cloudy-border.d.ts +90 -0
  6. package/dist/lib/geometry/index.d.ts +1 -0
  7. package/dist/lib/handlers/types.d.ts +2 -1
  8. package/dist/lib/tools/default-tools.d.ts +38 -87
  9. package/dist/lib/tools/types.d.ts +32 -1
  10. package/dist/preact/index.cjs +1 -1
  11. package/dist/preact/index.cjs.map +1 -1
  12. package/dist/preact/index.js +352 -239
  13. package/dist/preact/index.js.map +1 -1
  14. package/dist/react/index.cjs +1 -1
  15. package/dist/react/index.cjs.map +1 -1
  16. package/dist/react/index.js +352 -239
  17. package/dist/react/index.js.map +1 -1
  18. package/dist/shared/components/annotation-container.d.ts +4 -2
  19. package/dist/shared/components/annotations/circle.d.ts +6 -2
  20. package/dist/shared/components/annotations/polygon.d.ts +3 -1
  21. package/dist/shared/components/annotations/square.d.ts +6 -2
  22. package/dist/shared/components/types.d.ts +6 -2
  23. package/dist/shared-preact/components/annotation-container.d.ts +4 -2
  24. package/dist/shared-preact/components/annotations/circle.d.ts +6 -2
  25. package/dist/shared-preact/components/annotations/polygon.d.ts +3 -1
  26. package/dist/shared-preact/components/annotations/square.d.ts +6 -2
  27. package/dist/shared-preact/components/types.d.ts +6 -2
  28. package/dist/shared-react/components/annotation-container.d.ts +4 -2
  29. package/dist/shared-react/components/annotations/circle.d.ts +6 -2
  30. package/dist/shared-react/components/annotations/polygon.d.ts +3 -1
  31. package/dist/shared-react/components/annotations/square.d.ts +6 -2
  32. package/dist/shared-react/components/types.d.ts +6 -2
  33. package/dist/svelte/components/annotations/Circle.svelte.d.ts +3 -1
  34. package/dist/svelte/components/annotations/Polygon.svelte.d.ts +1 -0
  35. package/dist/svelte/components/annotations/Square.svelte.d.ts +3 -1
  36. package/dist/svelte/components/types.d.ts +2 -1
  37. package/dist/svelte/context/types.d.ts +6 -2
  38. package/dist/svelte/index.cjs +1 -1
  39. package/dist/svelte/index.cjs.map +1 -1
  40. package/dist/svelte/index.js +505 -293
  41. package/dist/svelte/index.js.map +1 -1
  42. package/dist/vue/components/annotation-container.vue.d.ts +7 -6
  43. package/dist/vue/components/annotations/circle.vue.d.ts +5 -1
  44. package/dist/vue/components/annotations/polygon.vue.d.ts +2 -0
  45. package/dist/vue/components/annotations/square.vue.d.ts +5 -1
  46. package/dist/vue/components/annotations.vue.d.ts +8 -9
  47. package/dist/vue/context/types.d.ts +6 -2
  48. package/dist/vue/index.cjs +1 -1
  49. package/dist/vue/index.cjs.map +1 -1
  50. package/dist/vue/index.js +259 -121
  51. package/dist/vue/index.js.map +1 -1
  52. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/preact/adapter.ts","../../src/shared/context/renderer-registry.tsx","../../src/shared/hooks/use-annotation.ts","../../src/shared/components/appearance-image.tsx","../../src/shared/components/annotation-container.tsx","../../src/shared/annotation-bounds.ts","../../src/shared/components/group-selection-box.tsx","../../src/shared/components/types.ts","../../src/shared/components/annotations/ink.tsx","../../src/shared/components/annotations/square.tsx","../../src/shared/components/annotations/circle.tsx","../../src/shared/components/annotations/line.tsx","../../src/shared/components/annotations/polyline.tsx","../../src/shared/components/annotations/polygon.tsx","../../src/shared/components/annotations/text.tsx","../../src/shared/components/annotations/free-text.tsx","../../src/shared/components/render-annotation.tsx","../../src/shared/components/annotations/stamp.tsx","../../src/shared/components/annotations/link.tsx","../../src/shared/components/text-markup/highlight.tsx","../../src/shared/components/text-markup/underline.tsx","../../src/shared/components/text-markup/strikeout.tsx","../../src/shared/components/text-markup/squiggly.tsx","../../src/shared/components/annotations/caret.tsx","../../src/shared/components/built-in-renderers.tsx","../../src/shared/components/annotations.tsx","../../src/shared/components/text-markup.tsx","../../src/shared/components/preview-renderer.tsx","../../src/shared/components/annotation-paint-layer.tsx","../../src/shared/components/annotation-layer.tsx","../../src/shared/index.ts"],"sourcesContent":["import { JSX, Fragment, createContext } from 'preact';\nexport {\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n useLayoutEffect,\n useContext,\n} from 'preact/hooks';\nexport type { ComponentChildren as ReactNode, JSX } from 'preact';\n\nexport { Fragment, createContext };\nexport type CSSProperties = import('preact').JSX.CSSProperties;\nexport type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<\n T extends EventTarget ? T : never\n>;\nexport type MouseEvent<T = Element> = JSX.TargetedMouseEvent<T extends EventTarget ? T : never>;\nexport type PointerEvent<T = Element> = JSX.TargetedPointerEvent<T extends EventTarget ? T : never>;\nexport type ChangeEvent<T = Element> = JSX.TargetedInputEvent<T extends EventTarget ? T : never>;\nexport type TouchEvent<T = Element> = JSX.TargetedTouchEvent<T extends EventTarget ? T : never>;\nexport type KeyboardEvent<T = Element> = JSX.TargetedKeyboardEvent<\n T extends EventTarget ? T : never\n>;\nexport type FormEvent<T = Element> = JSX.TargetedEvent<T extends EventTarget ? T : never>;\n\nexport { createPortal } from 'preact/compat';\n\nexport const suppressContentEditableWarningProps = {};\n","import {\n createContext,\n useContext,\n useState,\n useCallback,\n useRef,\n useEffect,\n ReactNode,\n} from '@framework';\nimport { BoxedAnnotationRenderer } from '../components/types';\n\n// Separate contexts: register function is stable, renderers list changes\ntype RegisterFn = (entries: BoxedAnnotationRenderer[]) => () => void;\n\nconst RegisterContext = createContext<RegisterFn | null>(null);\nconst RenderersContext = createContext<BoxedAnnotationRenderer[]>([]);\n\nexport function AnnotationRendererProvider({ children }: { children: ReactNode }) {\n const [renderers, setRenderers] = useState<BoxedAnnotationRenderer[]>([]);\n\n // Stable reference - no dependencies\n const register = useCallback((entries: BoxedAnnotationRenderer[]) => {\n setRenderers((prev) => {\n const ids = new Set(entries.map((e) => e.id));\n return [...prev.filter((r) => !ids.has(r.id)), ...entries];\n });\n return () => setRenderers((prev) => prev.filter((r) => !entries.some((e) => e.id === r.id)));\n }, []);\n\n return (\n <RegisterContext.Provider value={register}>\n <RenderersContext.Provider value={renderers}>{children}</RenderersContext.Provider>\n </RegisterContext.Provider>\n );\n}\n\n/**\n * Hook to register annotation renderers. Handles all registration lifecycle internally.\n * Plugin authors just call this with their renderers array.\n */\nexport function useRegisterRenderers(renderers: BoxedAnnotationRenderer[]) {\n const register = useContext(RegisterContext);\n const renderersRef = useRef(renderers);\n\n useEffect(() => {\n if (!register) return;\n return register(renderersRef.current);\n }, [register]);\n}\n\n/**\n * Hook to get all registered renderers (for rendering components).\n */\nexport function useRegisteredRenderers(): BoxedAnnotationRenderer[] {\n return useContext(RenderersContext);\n}\n\n/**\n * Low-level hook if someone needs direct access to register function.\n * Most plugins should use useRegisterRenderers instead.\n */\nexport function useRendererRegistry() {\n return useContext(RegisterContext);\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n AnnotationPlugin,\n AnnotationDocumentState,\n initialDocumentState,\n} from '@embedpdf/plugin-annotation';\nimport { useState, useEffect } from '@framework';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n\n/**\n * Hook for annotation state for a specific document\n * @param documentId Document ID\n */\nexport const useAnnotation = (documentId: string) => {\n const { provides } = useAnnotationCapability();\n const [state, setState] = useState<AnnotationDocumentState>(\n provides?.forDocument(documentId)?.getState() ?? initialDocumentState(),\n );\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { AnnotationAppearanceImage } from '@embedpdf/models';\nimport { useEffect, useRef, useState, CSSProperties } from '@framework';\n\ninterface AppearanceImageProps {\n appearance: AnnotationAppearanceImage<Blob>;\n style?: CSSProperties;\n}\n\n/**\n * Renders a pre-rendered annotation appearance stream image as an img URL.\n * Purely visual -- pointer events are always disabled; hit-area SVG handles interaction.\n */\nexport function AppearanceImage({ appearance, style }: AppearanceImageProps) {\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n const url = URL.createObjectURL(appearance.data);\n setImageUrl(url);\n urlRef.current = url;\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n }, [appearance.data]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return imageUrl ? (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n display: 'block',\n pointerEvents: 'none',\n userSelect: 'none',\n ...style,\n }}\n />\n ) : null;\n}\n","import { PdfAnnotationObject, Rect, AnnotationAppearances } from '@embedpdf/models';\nimport {\n CounterRotate,\n useDoublePressProps,\n useInteractionHandles,\n} from '@embedpdf/utils/@framework';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport {\n useState,\n JSX,\n CSSProperties,\n useRef,\n useEffect,\n useMemo,\n useCallback,\n createPortal,\n} from '@framework';\nimport { useDocumentPermissions } from '@embedpdf/core/@framework';\nimport { inferRotationCenterFromRects } from '../../lib/geometry/rotation';\n\nimport { useAnnotationCapability, useAnnotationPlugin } from '../hooks';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n AnnotationInteractionEvent,\n VertexHandleUI,\n RotationHandleUI,\n GroupSelectionMenuRenderFn,\n BoxedAnnotationRenderer,\n SelectionOutline,\n} from './types';\nimport { AppearanceImage } from './appearance-image';\nimport { VertexConfig } from '../types';\n\ninterface AnnotationContainerProps<T extends PdfAnnotationObject> {\n scale: number;\n documentId: string;\n pageIndex: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n trackedAnnotation: TrackedAnnotation<T>;\n children: JSX.Element | ((annotation: T, options: { appearanceActive: boolean }) => JSX.Element);\n isSelected: boolean;\n /** Whether the annotation is in editing mode (e.g., FreeText text editing) */\n isEditing?: boolean;\n /** Whether multiple annotations are selected (container becomes passive) */\n isMultiSelected?: boolean;\n isDraggable: boolean;\n isResizable: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n style?: CSSProperties;\n vertexConfig?: VertexConfig<T>;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n /** @deprecated Use `selectionOutline.offset` instead */\n outlineOffset?: number;\n onDoubleClick?: (event: any) => void;\n onSelect: (event: AnnotationInteractionEvent) => void;\n /** Pre-rendered appearance stream images for AP mode rendering */\n appearance?: AnnotationAppearances<Blob> | null;\n zIndex?: number;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline.color` instead */\n selectionOutlineColor?: string;\n /** Customize the selection outline (color, style, width, offset) */\n selectionOutline?: SelectionOutline;\n customAnnotationRenderer?: CustomAnnotationRenderer<T>;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n groupSelectionOutline?: SelectionOutline;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n annotationRenderers?: BoxedAnnotationRenderer[];\n}\n\n/**\n * AnnotationContainer wraps individual annotations with interaction handles.\n * When isMultiSelected is true, the container becomes passive - drag/resize\n * is handled by the GroupSelectionBox instead.\n */\nexport function AnnotationContainer<T extends PdfAnnotationObject>({\n scale,\n documentId,\n pageIndex,\n rotation,\n pageWidth,\n pageHeight,\n trackedAnnotation,\n children,\n isSelected,\n isEditing = false,\n isMultiSelected = false,\n isDraggable,\n isResizable,\n isRotatable = true,\n lockAspectRatio = false,\n style = {},\n vertexConfig,\n selectionMenu,\n outlineOffset = 1,\n onDoubleClick,\n onSelect,\n appearance,\n zIndex = 1,\n resizeUI,\n vertexUI,\n rotationUI,\n selectionOutlineColor,\n selectionOutline,\n customAnnotationRenderer,\n // Destructure props that shouldn't be passed to DOM elements\n groupSelectionMenu: _groupSelectionMenu,\n groupSelectionOutline: _groupSelectionOutline,\n annotationRenderers: _annotationRenderers,\n ...props\n}: AnnotationContainerProps<T>): JSX.Element {\n const [preview, setPreview] = useState<T>(trackedAnnotation.object);\n const [liveRotation, setLiveRotation] = useState<number | null>(null);\n const [cursorScreen, setCursorScreen] = useState<{ x: number; y: number } | null>(null);\n const [isHandleHovered, setIsHandleHovered] = useState(false);\n const [gestureActive, setGestureActive] = useState(false);\n const { provides: annotationCapability } = useAnnotationCapability();\n const { plugin } = useAnnotationPlugin();\n const { canModifyAnnotations } = useDocumentPermissions(documentId);\n const gestureBaseRef = useRef<T | null>(null);\n\n // When multi-selected, disable individual drag/resize - GroupSelectionBox handles it\n const effectiveIsDraggable = canModifyAnnotations && isDraggable && !isMultiSelected;\n const effectiveIsResizable = canModifyAnnotations && isResizable && !isMultiSelected;\n const effectiveIsRotatable = canModifyAnnotations && isRotatable && !isMultiSelected;\n // Get scoped API for this document\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const currentObject = preview\n ? { ...trackedAnnotation.object, ...preview }\n : trackedAnnotation.object;\n\n // Annotation flags\n const annoFlags = trackedAnnotation.object.flags ?? [];\n const hasNoZoom = annoFlags.includes('noZoom');\n const hasNoRotate = annoFlags.includes('noRotate');\n\n // visualScale: noZoom annotations maintain constant screen-pixel size regardless of zoom.\n // Sizing uses visualScale; page-space position (left/top) still uses scale.\n const visualScale = hasNoZoom ? 1 : scale;\n\n // effectivePageRotation: noRotate annotations stay visually upright regardless of page rotation.\n // The interaction controller and selection menu use this value.\n const effectivePageRotation = (hasNoRotate ? 0 : rotation) as typeof rotation;\n\n // UI constants\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const VERTEX_COLOR = vertexUI?.color ?? '#007ACC';\n const ROTATION_COLOR = rotationUI?.color ?? 'white';\n const ROTATION_CONNECTOR_COLOR = rotationUI?.connectorColor ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const VERTEX_SIZE = vertexUI?.size ?? 12;\n const ROTATION_SIZE = rotationUI?.size ?? 32;\n const ROTATION_MARGIN = rotationUI?.margin; // undefined = use default (35)\n const ROTATION_ICON_COLOR = rotationUI?.iconColor ?? '#007ACC';\n const SHOW_CONNECTOR = rotationUI?.showConnector ?? false;\n const ROTATION_BORDER_COLOR = rotationUI?.border?.color ?? '#007ACC';\n const ROTATION_BORDER_WIDTH = rotationUI?.border?.width ?? 1;\n const ROTATION_BORDER_STYLE = rotationUI?.border?.style ?? 'solid';\n\n // Outline resolution (new object > deprecated props > defaults)\n const outlineColor = selectionOutline?.color ?? selectionOutlineColor ?? '#007ACC';\n const outlineStyle = selectionOutline?.style ?? 'solid';\n const outlineWidth = selectionOutline?.width ?? 1;\n const outlineOff = selectionOutline?.offset ?? outlineOffset ?? 1;\n\n // Get annotation's current rotation (for simple shapes that store rotation)\n // During drag, use liveRotation if available; otherwise use the annotation's rotation\n const annotationRotation = liveRotation ?? currentObject.rotation ?? 0;\n const rotationDisplay = liveRotation ?? currentObject.rotation ?? 0;\n const normalizedRotationDisplay = Number.isFinite(rotationDisplay)\n ? Math.round(rotationDisplay * 10) / 10\n : 0;\n const rotationActive = liveRotation !== null;\n\n // Store original rect at gesture start (only need rect for delta calculation)\n const gestureBaseRectRef = useRef<Rect | null>(null);\n\n // Handle single-annotation drag/resize (only when NOT multi-selected)\n // Uses the unified plugin API - all preview updates come from event subscriptions!\n const handleUpdate = useCallback(\n (\n event: Parameters<\n NonNullable<Parameters<typeof useInteractionHandles>[0]['controller']['onUpdate']>\n >[0],\n ) => {\n if (!event.transformData?.type || isMultiSelected || !plugin) return;\n\n const { type, changes, metadata } = event.transformData;\n const id = trackedAnnotation.object.id;\n const pageSize = { width: pageWidth, height: pageHeight };\n\n // Gesture start - initialize plugin drag/resize\n if (event.state === 'start') {\n gestureBaseRectRef.current =\n trackedAnnotation.object.unrotatedRect ?? trackedAnnotation.object.rect;\n gestureBaseRef.current = trackedAnnotation.object;\n if (type === 'resize' || type === 'vertex-edit') {\n setGestureActive(true);\n }\n if (type === 'move') {\n plugin.startDrag(documentId, { annotationIds: [id], pageSize });\n } else if (type === 'resize') {\n plugin.startResize(documentId, {\n annotationIds: [id],\n pageSize,\n resizeHandle: metadata?.handle ?? 'se',\n });\n }\n }\n\n // Gesture update - call plugin, preview comes from subscription\n if (changes.rect && gestureBaseRectRef.current) {\n if (type === 'move') {\n const delta = {\n x: changes.rect.origin.x - gestureBaseRectRef.current.origin.x,\n y: changes.rect.origin.y - gestureBaseRectRef.current.origin.y,\n };\n plugin.updateDrag(documentId, delta);\n } else if (type === 'resize') {\n plugin.updateResize(documentId, changes.rect);\n }\n }\n\n // Vertex edit - handle directly (no attached link handling needed)\n if (type === 'vertex-edit' && changes.vertices && vertexConfig) {\n const base = gestureBaseRef.current ?? trackedAnnotation.object;\n const vertexChanges = vertexConfig.transformAnnotation(base, changes.vertices);\n const patched = annotationCapability?.transformAnnotation<T>(base, {\n type,\n changes: vertexChanges as Partial<T>,\n metadata,\n });\n if (patched) {\n setPreview((prev) => ({ ...prev, ...patched }));\n if (event.state === 'end') {\n annotationProvides?.updateAnnotation(pageIndex, id, patched);\n }\n }\n }\n\n if (type === 'rotate') {\n const cursorAngle = metadata?.rotationAngle ?? annotationRotation;\n const cursorPos = metadata?.cursorPosition;\n if (cursorPos) setCursorScreen({ x: cursorPos.clientX, y: cursorPos.clientY });\n if (event.state === 'start') {\n setLiveRotation(cursorAngle);\n plugin.startRotation(documentId, {\n annotationIds: [id],\n cursorAngle,\n rotationCenter: metadata?.rotationCenter,\n });\n } else if (event.state === 'move') {\n setLiveRotation(cursorAngle);\n plugin.updateRotation(documentId, cursorAngle, metadata?.rotationDelta);\n } else if (event.state === 'end') {\n setLiveRotation(null);\n setCursorScreen(null);\n plugin.commitRotation(documentId);\n }\n return;\n }\n\n // Gesture end - commit\n if (event.state === 'end') {\n gestureBaseRectRef.current = null;\n gestureBaseRef.current = null;\n setGestureActive(false);\n if (type === 'move') plugin.commitDrag(documentId);\n else if (type === 'resize') plugin.commitResize(documentId);\n }\n },\n [\n plugin,\n documentId,\n trackedAnnotation.object,\n pageWidth,\n pageHeight,\n pageIndex,\n isMultiSelected,\n vertexConfig,\n annotationCapability,\n annotationProvides,\n annotationRotation,\n ],\n );\n\n // Geometry model:\n // - `rect` is the visible AABB container.\n // - `unrotatedRect` is the local editing frame for resize/vertex operations.\n const explicitUnrotatedRect = currentObject.unrotatedRect;\n const effectiveUnrotatedRect = explicitUnrotatedRect ?? currentObject.rect;\n const rotationPivot =\n explicitUnrotatedRect && annotationRotation !== 0\n ? inferRotationCenterFromRects(effectiveUnrotatedRect, currentObject.rect, annotationRotation)\n : undefined;\n const controllerElement = effectiveUnrotatedRect;\n\n const {\n dragProps,\n vertices,\n resize,\n rotation: rotationHandle,\n } = useInteractionHandles({\n controller: {\n element: controllerElement,\n vertices: vertexConfig?.extractVertices(currentObject),\n constraints: {\n minWidth: 10,\n minHeight: 10,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n annotationRotation: annotationRotation,\n rotationCenter: rotationPivot,\n rotationElement: currentObject.rect,\n scale: scale,\n // Disable interaction handles when multi-selected\n enabled: isSelected && !isMultiSelected,\n onUpdate: handleUpdate,\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOff,\n offsetMode: 'outside',\n includeSides: lockAspectRatio ? false : true,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: VERTEX_SIZE,\n zIndex: zIndex + 2,\n },\n rotationUI: {\n handleSize: ROTATION_SIZE,\n margin: ROTATION_MARGIN,\n zIndex: zIndex + 3,\n showConnector: SHOW_CONNECTOR,\n },\n includeVertices: vertexConfig ? true : false,\n includeRotation: effectiveIsRotatable,\n currentRotation: annotationRotation,\n });\n\n // Wrap onDoubleClick to respect permissions\n const guardedOnDoubleClick = useMemo(() => {\n if (!canModifyAnnotations || !onDoubleClick) return undefined;\n return onDoubleClick;\n }, [canModifyAnnotations, onDoubleClick]);\n\n const doubleProps = useDoublePressProps(guardedOnDoubleClick);\n\n // Sync preview with tracked annotation when it changes\n useEffect(() => {\n setPreview(trackedAnnotation.object);\n }, [trackedAnnotation.object]);\n\n // Subscribe to unified drag changes - plugin sends pre-computed patches!\n // ALL preview updates come through here (primary, attached links, multi-select)\n useEffect(() => {\n if (!plugin) return;\n const id = trackedAnnotation.object.id;\n\n const handleEvent = (event: {\n documentId: string;\n type: string;\n previewPatches?: Record<string, any>;\n }) => {\n if (event.documentId !== documentId) return;\n if (event.type === 'end' || event.type === 'cancel') {\n setLiveRotation(null);\n }\n const patch = event.previewPatches?.[id];\n if (event.type === 'update' && patch) setPreview((prev) => ({ ...prev, ...patch }) as T);\n else if (event.type === 'cancel') setPreview(trackedAnnotation.object);\n };\n\n const unsubs = [\n plugin.onDragChange(handleEvent),\n plugin.onResizeChange(handleEvent),\n plugin.onRotateChange(handleEvent),\n ];\n\n return () => unsubs.forEach((u) => u());\n }, [plugin, documentId, trackedAnnotation.object]);\n\n // Determine if we should show the outline\n // When multi-selected, don't show individual outlines - GroupSelectionBox shows the group outline\n const showOutline = isSelected && !isMultiSelected;\n\n // Three-layer model: outer div (AABB) + inner rotated div (unrotatedRect) + content\n // noZoom: use visualScale (=1) for sizing so the annotation keeps a constant screen-pixel size.\n // noRotate: counter-rotate the outer div so the annotation stays upright on rotated pages.\n const aabbWidth = currentObject.rect.size.width * visualScale;\n const aabbHeight = currentObject.rect.size.height * visualScale;\n const innerWidth = effectiveUnrotatedRect.size.width * visualScale;\n const innerHeight = effectiveUnrotatedRect.size.height * visualScale;\n const usesCustomPivot = Boolean(explicitUnrotatedRect) && annotationRotation !== 0;\n const innerLeft = usesCustomPivot\n ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * visualScale\n : (aabbWidth - innerWidth) / 2;\n const innerTop = usesCustomPivot\n ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * visualScale\n : (aabbHeight - innerHeight) / 2;\n const innerTransformOrigin =\n usesCustomPivot && rotationPivot\n ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * visualScale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * visualScale}px`\n : 'center center';\n const centerX = rotationPivot\n ? (rotationPivot.x - currentObject.rect.origin.x) * visualScale\n : aabbWidth / 2;\n const centerY = rotationPivot\n ? (rotationPivot.y - currentObject.rect.origin.y) * visualScale\n : aabbHeight / 2;\n const guideLength = Math.max(300, Math.max(aabbWidth, aabbHeight) + 80);\n\n // noRotate: compute counter-rotation to undo page rotation on this annotation's outer div.\n const counterRot = hasNoRotate\n ? getCounterRotation(\n { origin: { x: 0, y: 0 }, size: { width: aabbWidth, height: aabbHeight } },\n rotation,\n )\n : null;\n\n // For children, override rect to use unrotatedRect so content renders in unrotated space\n const childObject = useMemo(() => {\n if (explicitUnrotatedRect) {\n return { ...currentObject, rect: explicitUnrotatedRect };\n }\n return currentObject;\n }, [currentObject, explicitUnrotatedRect]);\n\n const apActive =\n !!appearance?.normal && !gestureActive && !isEditing && !trackedAnnotation.dictMode;\n\n return (\n <div data-no-interaction>\n {/* Outer div: AABB container - stable center, holds help lines + rotation handle */}\n <div\n style={{\n position: 'absolute',\n left: currentObject.rect.origin.x * scale,\n top: currentObject.rect.origin.y * scale,\n width: counterRot ? counterRot.width : aabbWidth,\n height: counterRot ? counterRot.height : aabbHeight,\n pointerEvents: 'none',\n zIndex,\n // noRotate: apply counter-rotation matrix so the annotation stays upright\n ...(counterRot && {\n transform: counterRot.matrix,\n transformOrigin: '0 0',\n }),\n ...style,\n }}\n {...props}\n >\n {/* Rotation guide lines - anchored at stable AABB center */}\n {rotationActive && (\n <>\n {/* Fixed snap lines (cross at 0/90/180/270) */}\n <div\n style={{\n position: 'absolute',\n left: centerX - guideLength / 2,\n top: centerY,\n width: guideLength,\n height: 1,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n <div\n style={{\n position: 'absolute',\n left: centerX,\n top: centerY - guideLength / 2,\n width: 1,\n height: guideLength,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n {/* Rotating indicator line showing current angle */}\n <div\n style={{\n position: 'absolute',\n left: centerX - guideLength / 2,\n top: centerY,\n width: guideLength,\n height: 1,\n transformOrigin: 'center center',\n transform: `rotate(${annotationRotation}deg)`,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.8,\n pointerEvents: 'none',\n }}\n />\n </>\n )}\n\n {/* Rotation handle - orbits in AABB space, kept in DOM during rotation */}\n {isSelected &&\n effectiveIsRotatable &&\n rotationHandle &&\n (rotationUI?.component ? (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {rotationUI.component({\n ...rotationHandle.handle,\n backgroundColor: ROTATION_COLOR,\n iconColor: ROTATION_ICON_COLOR,\n connectorStyle: {\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n },\n showConnector: SHOW_CONNECTOR,\n opacity: rotationActive ? 0 : 1,\n border: {\n color: ROTATION_BORDER_COLOR,\n width: ROTATION_BORDER_WIDTH,\n style: ROTATION_BORDER_STYLE,\n },\n })}\n </div>\n ) : (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {/* Connector line */}\n {SHOW_CONNECTOR && (\n <div\n style={{\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n }}\n />\n )}\n {/* Rotation handle */}\n <div\n {...rotationHandle.handle}\n style={{\n ...rotationHandle.handle.style,\n backgroundColor: ROTATION_COLOR,\n border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,\n boxSizing: 'border-box',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'auto',\n opacity: rotationActive ? 0 : 1,\n }}\n >\n {/* Default rotation icon - a curved arrow */}\n <svg\n width={Math.round(ROTATION_SIZE * 0.6)}\n height={Math.round(ROTATION_SIZE * 0.6)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={ROTATION_ICON_COLOR}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\" />\n <path d=\"M21 3v5h-5\" />\n </svg>\n </div>\n </div>\n ))}\n\n {/* Inner div: rotated content area - holds content, resize handles, vertex handles */}\n <div\n {...(effectiveIsDraggable && isSelected ? dragProps : {})}\n {...doubleProps}\n style={{\n position: 'absolute',\n left: innerLeft,\n top: innerTop,\n width: innerWidth,\n height: innerHeight,\n transform: annotationRotation !== 0 ? `rotate(${annotationRotation}deg)` : undefined,\n transformOrigin: innerTransformOrigin,\n outline: showOutline ? `${outlineWidth}px ${outlineStyle} ${outlineColor}` : 'none',\n outlineOffset: showOutline ? `${outlineOff}px` : '0px',\n pointerEvents: isSelected && !isMultiSelected ? 'auto' : 'none',\n touchAction: 'none',\n cursor: isSelected && effectiveIsDraggable ? 'move' : 'default',\n }}\n >\n {/* Dict content -- always in DOM so hit area handles clicks and vertex handles keep pointer capture */}\n {(() => {\n const childrenRender =\n typeof children === 'function'\n ? children(childObject, { appearanceActive: apActive })\n : children;\n const customRender = customAnnotationRenderer?.({\n annotation: childObject,\n children: childrenRender,\n isSelected,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n pageIndex,\n onSelect,\n });\n return customRender ?? childrenRender;\n })()}\n\n {/* AP canvas -- purely visual, never interactive */}\n {appearance?.normal && (\n <AppearanceImage\n appearance={appearance.normal}\n style={{ display: apActive ? 'block' : 'none' }}\n />\n )}\n\n {/* Resize handles - rotate with the shape */}\n {isSelected &&\n effectiveIsResizable &&\n !rotationActive &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n\n {/* Vertex handles - rotate with the shape */}\n {isSelected &&\n canModifyAnnotations &&\n !isMultiSelected &&\n !rotationActive &&\n vertices.map(({ key, ...vProps }) =>\n vertexUI?.component ? (\n vertexUI.component({\n key,\n ...vProps,\n backgroundColor: VERTEX_COLOR,\n })\n ) : (\n <div\n key={key}\n {...vProps}\n style={{ ...vProps.style, backgroundColor: VERTEX_COLOR }}\n />\n ),\n )}\n </div>\n </div>\n\n {/* Selection menu - hide when multi-selected or rotating */}\n {selectionMenu && !isMultiSelected && !rotationActive && (\n <CounterRotate\n rect={{\n origin: {\n x: currentObject.rect.origin.x * scale,\n y: currentObject.rect.origin.y * scale,\n },\n size: {\n width: currentObject.rect.size.width * visualScale,\n height: currentObject.rect.size.height * visualScale,\n },\n }}\n rotation={rotation}\n >\n {(counterRotateProps) => {\n // The handle's visual angle = annotationRotation + pageRotation (in degrees).\n // `rotation` is in quarter turns (0-3), so multiply by 90 to get degrees.\n // The menu (suggestTop: false) renders at the visual bottom (180deg).\n // Flip the menu to the top when the handle is in the bottom visual hemisphere\n // to prevent it from overlapping with the rotation handle.\n const effectiveAngle =\n (((annotationRotation + effectivePageRotation * 90) % 360) + 360) % 360;\n const handleNearMenuSide =\n effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;\n\n return selectionMenu({\n ...counterRotateProps,\n context: {\n type: 'annotation',\n annotation: trackedAnnotation,\n pageIndex,\n },\n selected: isSelected,\n placement: {\n suggestTop: handleNearMenuSide,\n },\n });\n }}\n </CounterRotate>\n )}\n\n {/* Cursor-following rotation tooltip - portaled to document.body to escape CSS transform chain */}\n {(rotationActive || isHandleHovered) &&\n cursorScreen &&\n createPortal(\n <div\n style={{\n position: 'fixed',\n left: cursorScreen.x + 16,\n top: cursorScreen.y - 16,\n background: 'rgba(0,0,0,0.8)',\n color: '#fff',\n padding: '4px 8px',\n borderRadius: 4,\n fontSize: 12,\n fontFamily: 'monospace',\n pointerEvents: 'none',\n zIndex: 10000,\n whiteSpace: 'nowrap',\n }}\n >\n {normalizedRotationDisplay.toFixed(0)}°\n </div>,\n document.body,\n )}\n </div>\n );\n}\n","import { Rotation } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\nexport interface ScreenBounds {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nfunction mapCounterRotatePoint(\n x: number,\n y: number,\n width: number,\n height: number,\n rotation: Rotation,\n): { x: number; y: number } {\n switch (rotation) {\n case 1:\n return { x: y, y: height - x };\n case 2:\n return { x: width - x, y: height - y };\n case 3:\n return { x: width - y, y: x };\n default:\n return { x, y };\n }\n}\n\n/**\n * Compute the screen-space bounding box of an annotation, correctly accounting\n * for `noZoom` (constant pixel size regardless of zoom) and `noRotate`\n * (visually upright regardless of page rotation) annotation flags.\n */\nexport function getAnnotationScreenBounds(\n annotation: TrackedAnnotation,\n scale: number,\n rotation: Rotation,\n): ScreenBounds {\n const flags = annotation.object.flags ?? [];\n const hasNoZoom = flags.includes('noZoom');\n const hasNoRotate = flags.includes('noRotate');\n\n const left = annotation.object.rect.origin.x * scale;\n const top = annotation.object.rect.origin.y * scale;\n const width = annotation.object.rect.size.width * (hasNoZoom ? 1 : scale);\n const height = annotation.object.rect.size.height * (hasNoZoom ? 1 : scale);\n\n if (!hasNoRotate || rotation === 0) {\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n };\n }\n\n const corners = [\n mapCounterRotatePoint(0, 0, width, height, rotation),\n mapCounterRotatePoint(width, 0, width, height, rotation),\n mapCounterRotatePoint(0, height, width, height, rotation),\n mapCounterRotatePoint(width, height, width, height, rotation),\n ];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const corner of corners) {\n if (corner.x < minX) minX = corner.x;\n if (corner.y < minY) minY = corner.y;\n if (corner.x > maxX) maxX = corner.x;\n if (corner.y > maxY) maxY = corner.y;\n }\n\n return {\n left: left + minX,\n top: top + minY,\n right: left + maxX,\n bottom: top + maxY,\n };\n}\n","import { Rect, boundingRectOrEmpty, Rotation } from '@embedpdf/models';\nimport { useInteractionHandles, CounterRotate } from '@embedpdf/utils/@framework';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { useState, useMemo, useCallback, useRef, useEffect, createPortal } from '@framework';\nimport { useDocumentPermissions } from '@embedpdf/core/@framework';\n\nimport { useAnnotationPlugin } from '../hooks';\nimport {\n ResizeHandleUI,\n RotationHandleUI,\n GroupSelectionMenuRenderFn,\n SelectionOutline,\n} from './types';\nimport { getAnnotationScreenBounds } from '../annotation-bounds';\n\ninterface GroupSelectionBoxProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n /** All selected annotations on this page */\n selectedAnnotations: TrackedAnnotation[];\n /** Whether the group is draggable (all annotations must be group-draggable) */\n isDraggable: boolean;\n /** Whether the group is resizable (all annotations must be group-resizable) */\n isResizable: boolean;\n /** Whether the group can be rotated */\n isRotatable?: boolean;\n /** Whether to lock aspect ratio during group resize */\n lockAspectRatio?: boolean;\n /** Resize handle UI customization */\n resizeUI?: ResizeHandleUI;\n /** Rotation handle UI customization */\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline.color` instead */\n selectionOutlineColor?: string;\n /** @deprecated Use `selectionOutline.offset` instead */\n outlineOffset?: number;\n /** Customize the selection outline (color, style, width, offset) */\n selectionOutline?: SelectionOutline;\n /** Z-index for the group box */\n zIndex?: number;\n /** Group selection menu render function */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n}\n\n/**\n * GroupSelectionBox renders a bounding box around all selected annotations\n * with drag and resize handles for group manipulation.\n */\nexport function GroupSelectionBox({\n documentId,\n pageIndex,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n selectedAnnotations,\n isDraggable,\n isResizable,\n isRotatable = true,\n lockAspectRatio = false,\n resizeUI,\n rotationUI,\n selectionOutlineColor,\n outlineOffset,\n selectionOutline,\n zIndex = 2,\n groupSelectionMenu,\n}: GroupSelectionBoxProps): JSX.Element | null {\n const { plugin } = useAnnotationPlugin();\n const { canModifyAnnotations } = useDocumentPermissions(documentId);\n const gestureBaseRef = useRef<Rect | null>(null);\n const isDraggingRef = useRef(false);\n const isResizingRef = useRef(false);\n const [liveRotation, setLiveRotation] = useState<number | null>(null);\n const [cursorScreen, setCursorScreen] = useState<{ x: number; y: number } | null>(null);\n const [isHandleHovered, setIsHandleHovered] = useState(false);\n\n // Check permissions before allowing drag/resize\n const effectiveIsDraggable = canModifyAnnotations && isDraggable;\n const effectiveIsResizable = canModifyAnnotations && isResizable;\n const effectiveIsRotatable = canModifyAnnotations && isRotatable;\n\n // Compute the group bounding box from all selected annotations\n const groupBox = useMemo(() => {\n const rects = selectedAnnotations.map((ta) => ta.object.rect);\n return boundingRectOrEmpty(rects);\n }, [selectedAnnotations]);\n\n // Preview state for the group box during drag/resize\n const [previewGroupBox, setPreviewGroupBox] = useState<Rect>(groupBox);\n\n // Sync preview with actual group box when not dragging/resizing\n useEffect(() => {\n if (!isDraggingRef.current && !isResizingRef.current) {\n setPreviewGroupBox(groupBox);\n }\n }, [groupBox]);\n\n useEffect(() => {\n if (!plugin) return;\n const unsubscribe = plugin.onRotateChange((event) => {\n if (event.documentId !== documentId) return;\n if (event.type === 'end' || event.type === 'cancel') {\n setLiveRotation(null);\n }\n });\n return unsubscribe;\n }, [plugin, documentId]);\n\n // Handle both drag and resize updates using unified plugin API\n // The plugin handles attached links automatically and commits all patches\n const handleUpdate = useCallback(\n (\n event: Parameters<\n NonNullable<Parameters<typeof useInteractionHandles>[0]['controller']['onUpdate']>\n >[0],\n ) => {\n if (!event.transformData?.type) return;\n if (!plugin) return;\n\n const transformType = event.transformData.type;\n const isMove = transformType === 'move';\n const isResize = transformType === 'resize';\n\n // Skip drag operations if group is not draggable\n if (isMove && !effectiveIsDraggable) return;\n\n if (event.state === 'start') {\n gestureBaseRef.current = groupBox;\n\n if (isMove) {\n isDraggingRef.current = true;\n // Use unified drag API - plugin handles attached links automatically\n plugin.startDrag(documentId, {\n annotationIds: selectedAnnotations.map((ta) => ta.object.id),\n pageSize: { width: pageWidth, height: pageHeight },\n });\n } else if (isResize) {\n isResizingRef.current = true;\n // Use unified resize API - plugin handles attached links automatically\n plugin.startResize(documentId, {\n annotationIds: selectedAnnotations.map((ta) => ta.object.id),\n pageSize: { width: pageWidth, height: pageHeight },\n resizeHandle: event.transformData.metadata?.handle ?? 'se',\n });\n }\n }\n\n if (transformType === 'rotate') {\n if (!isRotatable) return;\n const ids = selectedAnnotations.map((ta) => ta.object.id);\n const cursorAngle = event.transformData.metadata?.rotationAngle ?? 0;\n const cursorPos = event.transformData.metadata?.cursorPosition;\n if (cursorPos) setCursorScreen({ x: cursorPos.clientX, y: cursorPos.clientY });\n if (event.state === 'start') {\n setLiveRotation(cursorAngle);\n plugin.startRotation(documentId, {\n annotationIds: ids,\n cursorAngle,\n rotationCenter: event.transformData.metadata?.rotationCenter,\n });\n } else if (event.state === 'move') {\n setLiveRotation(cursorAngle);\n plugin.updateRotation(\n documentId,\n cursorAngle,\n event.transformData.metadata?.rotationDelta,\n );\n } else if (event.state === 'end') {\n setLiveRotation(null);\n setCursorScreen(null);\n plugin.commitRotation(documentId);\n }\n return;\n }\n\n const base = gestureBaseRef.current ?? groupBox;\n\n if (isMove && event.transformData.changes.rect) {\n // Calculate delta from original position\n const newRect = event.transformData.changes.rect;\n const rawDelta = {\n x: newRect.origin.x - base.origin.x,\n y: newRect.origin.y - base.origin.y,\n };\n\n // Plugin clamps delta and emits events (attached links receive updates too)\n const clampedDelta = plugin.updateDrag(documentId, rawDelta);\n\n // Update preview group box with clamped delta\n setPreviewGroupBox({\n ...base,\n origin: {\n x: base.origin.x + clampedDelta.x,\n y: base.origin.y + clampedDelta.y,\n },\n });\n } else if (isResize && event.transformData.changes.rect) {\n const newGroupBox = event.transformData.changes.rect;\n\n // Plugin computes rects for all participants and emits events\n plugin.updateResize(documentId, newGroupBox);\n\n // Update preview\n setPreviewGroupBox(newGroupBox);\n }\n\n if (event.state === 'end') {\n gestureBaseRef.current = null;\n\n if (isMove && isDraggingRef.current) {\n isDraggingRef.current = false;\n // Plugin commits all patches (selected + attached links) - no patch building needed!\n plugin.commitDrag(documentId);\n } else if (isResize && isResizingRef.current) {\n isResizingRef.current = false;\n // Plugin commits all patches (selected + attached links) - no patch building needed!\n plugin.commitResize(documentId);\n }\n }\n },\n [\n plugin,\n documentId,\n pageWidth,\n pageHeight,\n groupBox,\n effectiveIsDraggable,\n selectedAnnotations,\n isRotatable,\n ],\n );\n\n const groupRotationDisplay = liveRotation ?? 0;\n const rotationActive = liveRotation !== null;\n const normalizedRotationDisplay = Number.isFinite(groupRotationDisplay)\n ? Math.round(groupRotationDisplay * 10) / 10\n : 0;\n\n // UI constants\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const ROTATION_COLOR = rotationUI?.color ?? 'white';\n const ROTATION_CONNECTOR_COLOR = rotationUI?.connectorColor ?? '#007ACC';\n const ROTATION_SIZE = rotationUI?.size ?? 32;\n const ROTATION_MARGIN = rotationUI?.margin;\n const ROTATION_ICON_COLOR = rotationUI?.iconColor ?? '#007ACC';\n const SHOW_CONNECTOR = rotationUI?.showConnector ?? false;\n const ROTATION_BORDER_COLOR = rotationUI?.border?.color ?? '#007ACC';\n const ROTATION_BORDER_WIDTH = rotationUI?.border?.width ?? 1;\n const ROTATION_BORDER_STYLE = rotationUI?.border?.style ?? 'solid';\n\n // Outline resolution (new object > deprecated props > group defaults)\n const outlineColor = selectionOutline?.color ?? selectionOutlineColor ?? '#007ACC';\n const outlineStyleVal = selectionOutline?.style ?? 'dashed';\n const outlineWidth = selectionOutline?.width ?? 2;\n const outlineOff = selectionOutline?.offset ?? outlineOffset ?? 2;\n\n // Use interaction handles for both drag and resize\n const {\n dragProps,\n resize,\n rotation: rotationHandle,\n } = useInteractionHandles({\n controller: {\n element: previewGroupBox,\n constraints: {\n minWidth: 20,\n minHeight: 20,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n scale: scale,\n enabled: true,\n onUpdate: handleUpdate,\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOff,\n offsetMode: 'outside',\n includeSides: !lockAspectRatio,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: 0,\n zIndex: zIndex,\n },\n rotationUI: {\n handleSize: ROTATION_SIZE,\n margin: ROTATION_MARGIN,\n zIndex: zIndex + 2,\n showConnector: SHOW_CONNECTOR,\n },\n includeVertices: false,\n includeRotation: effectiveIsRotatable,\n currentRotation: liveRotation ?? 0,\n });\n\n // Don't render if less than 2 annotations selected\n if (selectedAnnotations.length < 2) {\n return null;\n }\n\n // Compute visual bounds in screen pixels, including mixed noZoom/noRotate selections.\n let visualLeft = Infinity;\n let visualTop = Infinity;\n let visualRight = -Infinity;\n let visualBottom = -Infinity;\n for (const ta of selectedAnnotations) {\n const bounds = getAnnotationScreenBounds(ta, scale, rotation as Rotation);\n visualLeft = Math.min(visualLeft, bounds.left);\n visualTop = Math.min(visualTop, bounds.top);\n visualRight = Math.max(visualRight, bounds.right);\n visualBottom = Math.max(visualBottom, bounds.bottom);\n }\n const initialLogicalLeft = groupBox.origin.x * scale;\n const initialLogicalTop = groupBox.origin.y * scale;\n const initialLogicalRight = (groupBox.origin.x + groupBox.size.width) * scale;\n const initialLogicalBottom = (groupBox.origin.y + groupBox.size.height) * scale;\n const leftCorrection = visualLeft - initialLogicalLeft;\n const topCorrection = visualTop - initialLogicalTop;\n const rightCorrection = visualRight - initialLogicalRight;\n const bottomCorrection = visualBottom - initialLogicalBottom;\n\n const groupBoxLeft = previewGroupBox.origin.x * scale + leftCorrection;\n const groupBoxTop = previewGroupBox.origin.y * scale + topCorrection;\n const groupBoxWidth = previewGroupBox.size.width * scale + (rightCorrection - leftCorrection);\n const groupBoxHeight = previewGroupBox.size.height * scale + (bottomCorrection - topCorrection);\n const groupCenterX = groupBoxWidth / 2;\n const groupCenterY = groupBoxHeight / 2;\n const groupGuideLength = Math.max(300, Math.max(groupBoxWidth, groupBoxHeight) + 80);\n\n return (\n <div data-group-selection-box data-no-interaction>\n {/* Outer div: AABB container - stable center for help lines and rotation handle */}\n <div\n style={{\n position: 'absolute',\n left: groupBoxLeft,\n top: groupBoxTop,\n width: groupBoxWidth,\n height: groupBoxHeight,\n pointerEvents: 'none',\n zIndex,\n }}\n >\n {/* Rotation guide lines - anchored at stable center */}\n {rotationActive && (\n <>\n {/* Fixed snap lines (cross at 0/90/180/270) */}\n <div\n style={{\n position: 'absolute',\n left: groupCenterX - groupGuideLength / 2,\n top: groupCenterY,\n width: groupGuideLength,\n height: 1,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n <div\n style={{\n position: 'absolute',\n left: groupCenterX,\n top: groupCenterY - groupGuideLength / 2,\n width: 1,\n height: groupGuideLength,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n {/* Rotating indicator line showing current angle */}\n <div\n style={{\n position: 'absolute',\n left: groupCenterX - groupGuideLength / 2,\n top: groupCenterY,\n width: groupGuideLength,\n height: 1,\n transformOrigin: 'center center',\n transform: `rotate(${groupRotationDisplay}deg)`,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.8,\n pointerEvents: 'none',\n }}\n />\n </>\n )}\n\n {/* Rotation handle - orbits in AABB space */}\n {effectiveIsRotatable &&\n rotationHandle &&\n (rotationUI?.component ? (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {rotationUI.component({\n ...rotationHandle.handle,\n backgroundColor: ROTATION_COLOR,\n iconColor: ROTATION_ICON_COLOR,\n connectorStyle: {\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n },\n showConnector: SHOW_CONNECTOR,\n opacity: rotationActive ? 0 : 1,\n border: {\n color: ROTATION_BORDER_COLOR,\n width: ROTATION_BORDER_WIDTH,\n style: ROTATION_BORDER_STYLE,\n },\n })}\n </div>\n ) : (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {/* Connector line */}\n {SHOW_CONNECTOR && (\n <div\n style={{\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n }}\n />\n )}\n {/* Rotation handle */}\n <div\n {...rotationHandle.handle}\n style={{\n ...rotationHandle.handle.style,\n backgroundColor: ROTATION_COLOR,\n border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,\n boxSizing: 'border-box',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'auto',\n opacity: rotationActive ? 0 : 1,\n }}\n >\n <svg\n width={Math.round(ROTATION_SIZE * 0.6)}\n height={Math.round(ROTATION_SIZE * 0.6)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={ROTATION_ICON_COLOR}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\" />\n <path d=\"M21 3v5h-5\" />\n </svg>\n </div>\n </div>\n ))}\n\n {/* Inner div: group content area with outline and resize handles */}\n <div\n {...(effectiveIsDraggable\n ? dragProps\n : {\n onPointerDown: (e: any) => e.stopPropagation(),\n })}\n style={{\n position: 'absolute',\n left: 0,\n top: 0,\n width: groupBoxWidth,\n height: groupBoxHeight,\n outline: rotationActive\n ? 'none'\n : `${outlineWidth}px ${outlineStyleVal} ${outlineColor}`,\n outlineOffset: outlineOff - 1,\n cursor: effectiveIsDraggable ? 'move' : 'default',\n touchAction: 'none',\n pointerEvents: 'auto',\n }}\n >\n {/* Resize handles */}\n {effectiveIsResizable &&\n !rotationActive &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n </div>\n </div>\n\n {/* Cursor-following rotation tooltip */}\n {(rotationActive || isHandleHovered) &&\n cursorScreen &&\n createPortal(\n <div\n style={{\n position: 'fixed',\n left: cursorScreen.x + 16,\n top: cursorScreen.y - 16,\n background: 'rgba(0,0,0,0.8)',\n color: '#fff',\n padding: '4px 8px',\n borderRadius: 4,\n fontSize: 12,\n fontFamily: 'monospace',\n pointerEvents: 'none',\n zIndex: 10000,\n whiteSpace: 'nowrap',\n }}\n >\n {normalizedRotationDisplay.toFixed(0)}°\n </div>,\n document.body,\n )}\n\n {/* Group selection menu */}\n {groupSelectionMenu && (\n <CounterRotate\n rect={{\n origin: {\n x: groupBoxLeft,\n y: groupBoxTop,\n },\n size: {\n width: groupBoxWidth,\n height: groupBoxHeight,\n },\n }}\n rotation={rotation}\n >\n {(counterRotateProps) => {\n // The handle's visual angle = groupRotationDisplay + pageRotation (in degrees).\n // `rotation` is in quarter turns (0-3), so multiply by 90 to get degrees.\n // The menu (suggestTop: false) renders at the visual bottom (180deg).\n // Flip the menu to the top when the handle is in the bottom visual hemisphere\n // to prevent it from overlapping with the rotation handle.\n const effectiveAngle = (((groupRotationDisplay + rotation * 90) % 360) + 360) % 360;\n const handleNearMenuSide =\n effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;\n\n return groupSelectionMenu({\n ...counterRotateProps,\n context: {\n type: 'group',\n annotations: selectedAnnotations,\n pageIndex,\n },\n selected: true,\n placement: {\n suggestTop: handleNearMenuSide,\n },\n });\n }}\n </CounterRotate>\n )}\n </div>\n );\n}\n","import { PdfAnnotationObject } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport {\n HandleElementProps,\n SelectionMenuPropsBase,\n SelectionMenuRenderFn,\n} from '@embedpdf/utils/@framework';\nimport { JSX, CSSProperties, MouseEvent } from '@framework';\nimport { VertexConfig } from '../types';\n\nexport type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';\n\nexport interface AnnotationSelectionContext {\n type: 'annotation';\n annotation: TrackedAnnotation;\n pageIndex: number;\n}\n\nexport type AnnotationSelectionMenuProps = SelectionMenuPropsBase<AnnotationSelectionContext>;\nexport type AnnotationSelectionMenuRenderFn = SelectionMenuRenderFn<AnnotationSelectionContext>;\n\nexport interface GroupSelectionContext {\n type: 'group';\n annotations: TrackedAnnotation[];\n pageIndex: number;\n}\n\nexport type GroupSelectionMenuProps = SelectionMenuPropsBase<GroupSelectionContext>;\nexport type GroupSelectionMenuRenderFn = SelectionMenuRenderFn<GroupSelectionContext>;\n\nexport type HandleProps = HandleElementProps & {\n backgroundColor?: string;\n};\n\n/** UI customization for resize handles */\nexport interface ResizeHandleUI {\n /** Handle size in CSS px (default: 12) */\n size?: number;\n /** Default background color for the handle (used by default renderer) */\n color?: string;\n /** Custom renderer for each handle (overrides default) */\n component?: (p: HandleProps) => JSX.Element;\n}\n\n/** UI customization for vertex handles */\nexport interface VertexHandleUI {\n /** Handle size in CSS px (default: 12) */\n size?: number;\n /** Default background color for the handle (used by default renderer) */\n color?: string;\n /** Custom renderer for each vertex (overrides default) */\n component?: (p: HandleProps) => JSX.Element;\n}\n\n/** Props for the rotation handle component */\nexport interface RotationHandleComponentProps extends HandleProps {\n /** Props for the connector line element */\n connectorStyle?: CSSProperties;\n /** Whether to show the connector line */\n showConnector?: boolean;\n /** Color for the icon inside the handle (default: '#007ACC') */\n iconColor?: string;\n /** Resolved border configuration */\n border?: RotationHandleBorder;\n}\n\nexport type BorderStyle = 'solid' | 'dashed' | 'dotted';\n\nexport interface SelectionOutline {\n /** Outline color (default: '#007ACC') */\n color?: string;\n /** Outline style (default: 'solid' for single, 'dashed' for group) */\n style?: BorderStyle;\n /** Outline width in px (default: 1 for single, 2 for group) */\n width?: number;\n /** Outline offset in px (default: 1 for single, 2 for group) */\n offset?: number;\n}\n\n/** Border configuration for the rotation handle */\nexport interface RotationHandleBorder {\n /** Border color (default: '#007ACC') */\n color?: string;\n /** Border style (default: 'solid') */\n style?: BorderStyle;\n /** Border width in px (default: 1) */\n width?: number;\n}\n\n/** UI customization for rotation handle */\nexport interface RotationHandleUI {\n /** Handle size in CSS px (default: 16) */\n size?: number;\n /** Gap in CSS px between the bounding box edge and the rotation handle center (default: 20) */\n margin?: number;\n /** Default background color for the handle (default: 'white') */\n color?: string;\n /** Color for the connector line (default: '#007ACC') */\n connectorColor?: string;\n /** Whether to show the connector line (default: true) */\n showConnector?: boolean;\n /** Color for the icon inside the handle (default: '#007ACC') */\n iconColor?: string;\n /** Border configuration for the handle */\n border?: RotationHandleBorder;\n /** Custom renderer for the rotation handle (overrides default) */\n component?: (p: RotationHandleComponentProps) => JSX.Element;\n}\n\n/**\n * Props for the custom annotation renderer\n */\nexport interface CustomAnnotationRendererProps<T extends PdfAnnotationObject> {\n annotation: T;\n children: JSX.Element;\n isSelected: boolean;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n pageIndex: number;\n onSelect: (event: any) => void;\n}\n\n/**\n * Custom renderer for an annotation\n */\nexport type CustomAnnotationRenderer<T extends PdfAnnotationObject> = (\n props: CustomAnnotationRendererProps<T>,\n) => JSX.Element | null;\n\n/**\n * Properly typed event for annotation interactions (click, select, etc.)\n */\nexport type AnnotationInteractionEvent = MouseEvent<Element>;\n\n/**\n * Props for an annotation renderer entry\n */\nexport interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnnotationObject> {\n annotation: TrackedAnnotation<T>;\n currentObject: T;\n isSelected: boolean;\n isEditing: boolean;\n scale: number;\n pageIndex: number;\n documentId: string;\n onClick: (e: AnnotationInteractionEvent) => void;\n /** When true, AP canvas provides the visual; component should only render hit area */\n appearanceActive: boolean;\n}\n\n/**\n * Helpers passed to selectOverride for custom selection behavior.\n */\nexport interface SelectOverrideHelpers {\n defaultSelect: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation) => void;\n selectAnnotation: (pageIndex: number, id: string) => void;\n clearSelection: () => void;\n allAnnotations: TrackedAnnotation[];\n pageIndex: number;\n}\n\n/**\n * Entry for a custom annotation renderer that handles specific annotation types.\n * This allows external plugins to provide their own rendering for annotation subtypes.\n * Used at definition time for type safety.\n */\nexport interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {\n /** Unique identifier for this renderer (usually matches tool id) */\n id: string;\n\n /** Returns true if this renderer should handle the annotation */\n matches: (annotation: PdfAnnotationObject) => annotation is T;\n\n /** The component to render the annotation */\n render: (props: AnnotationRendererProps<T>) => JSX.Element;\n\n /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */\n vertexConfig?: VertexConfig<T>;\n\n /** z-index for the annotation container (default: 1, text markup uses 0) */\n zIndex?: number;\n\n /** Style applied to the annotation container (overrides default blendMode style) */\n containerStyle?: (annotation: T) => CSSProperties;\n\n /** Type-specific interaction fallbacks used when the tool doesn't define a property */\n interactionDefaults?: {\n isDraggable?: boolean;\n isResizable?: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n };\n\n /** Whether this annotation type uses AP rendering before editing (default: true) */\n useAppearanceStream?: boolean;\n\n /** Override resolved isDraggable (e.g., FreeText disables drag while editing) */\n isDraggable?: (toolDraggable: boolean, context: { isEditing: boolean }) => boolean;\n\n /** Handle double-click on the annotation container */\n onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;\n\n /** Override default selection behavior (e.g., Link IRT parent resolution) */\n selectOverride?: (\n e: AnnotationInteractionEvent,\n annotation: TrackedAnnotation<T>,\n helpers: SelectOverrideHelpers,\n ) => void;\n\n /** Return true to hide the selection menu for this annotation */\n hideSelectionMenu?: (annotation: T) => boolean;\n}\n\n/**\n * Boxed renderer that encapsulates type safety internally.\n * The generic is erased -- this is what the registry actually stores.\n */\nexport interface BoxedAnnotationRenderer {\n id: string;\n matches: (annotation: PdfAnnotationObject) => boolean;\n render: (props: AnnotationRendererProps) => JSX.Element;\n vertexConfig?: VertexConfig<PdfAnnotationObject>;\n zIndex?: number;\n containerStyle?: (annotation: PdfAnnotationObject) => CSSProperties;\n interactionDefaults?: {\n isDraggable?: boolean;\n isResizable?: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n };\n useAppearanceStream?: boolean;\n isDraggable?: (toolDraggable: boolean, context: { isEditing: boolean }) => boolean;\n onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;\n selectOverride?: (\n e: AnnotationInteractionEvent,\n annotation: TrackedAnnotation,\n helpers: SelectOverrideHelpers,\n ) => void;\n hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;\n}\n\n/**\n * Creates a boxed renderer from a typed entry.\n * Type safety is enforced at definition time, then erased for storage.\n */\nexport function createRenderer<T extends PdfAnnotationObject>(\n entry: AnnotationRendererEntry<T>,\n): BoxedAnnotationRenderer {\n return {\n id: entry.id,\n matches: (annotation) => entry.matches(annotation),\n render: (props) => entry.render(props as AnnotationRendererProps<T>),\n vertexConfig: entry.vertexConfig as VertexConfig<PdfAnnotationObject> | undefined,\n zIndex: entry.zIndex,\n containerStyle: entry.containerStyle as\n | ((annotation: PdfAnnotationObject) => CSSProperties)\n | undefined,\n interactionDefaults: entry.interactionDefaults,\n useAppearanceStream: entry.useAppearanceStream,\n isDraggable: entry.isDraggable,\n onDoubleClick: entry.onDoubleClick,\n selectOverride: entry.selectOverride as BoxedAnnotationRenderer['selectOverride'],\n hideSelectionMenu: entry.hideSelectionMenu as\n | ((annotation: PdfAnnotationObject) => boolean)\n | undefined,\n };\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfInkListObject, Rect } from '@embedpdf/models';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface InkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke color */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Line width in PDF units */\n strokeWidth: number;\n /** Array of strokes — exactly as in your JSON */\n inkList: PdfInkListObject[];\n /** Bounding box of the whole annotation */\n rect: Rect;\n /** Page zoom factor */\n scale: number;\n /** Callback for when the annotation is clicked */\n onClick?: (e: MouseEvent<SVGPathElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Ink annotation (free-hand drawing) as SVG.\n */\nexport function Ink({\n isSelected,\n strokeColor,\n opacity = 1,\n strokeWidth,\n inkList,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n}: InkProps): JSX.Element {\n const resolvedColor = strokeColor ?? '#000000';\n\n const paths = useMemo(() => {\n return inkList.map(({ points }) => {\n let d = '';\n points.forEach(({ x, y }, i) => {\n const lx = x - rect.origin.x;\n const ly = y - rect.origin.y;\n d += (i === 0 ? 'M' : 'L') + lx + ' ' + ly + ' ';\n });\n return d.trim();\n });\n }, [inkList, rect]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n {paths.map((d, i) => (\n <path\n key={`hit-${i}`}\n d={d}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive &&\n paths.map((d, i) => (\n <path\n key={`vis-${i}`}\n d={d}\n fill=\"none\"\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: resolvedColor,\n strokeWidth: strokeWidth,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface SquareProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium's black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Square annotation (rectangle) as SVG.\n */\nexport function Square({\n isSelected,\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n}: SquareProps): JSX.Element {\n const { width, height, x, y } = useMemo(() => {\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: innerW,\n height: innerH,\n x: strokeWidth / 2,\n y: strokeWidth / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = (width + strokeWidth) * scale;\n const svgHeight = (height + strokeWidth) * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width + strokeWidth} ${height + strokeWidth}`}\n overflow=\"visible\"\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface CircleProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium's black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Circle annotation (ellipse) as SVG.\n */\nexport function Circle({\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n isSelected,\n appearanceActive = false,\n}: CircleProps): JSX.Element {\n const { width, height, cx, cy, rx, ry } = useMemo(() => {\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: outerW,\n height: outerH,\n cx: strokeWidth / 2 + innerW / 2,\n cy: strokeWidth / 2 + innerH / 2,\n rx: innerW / 2,\n ry: innerH / 2,\n };\n }, [rect, strokeWidth]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n overflow=\"visible\"\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface LineProps {\n /** interior colour */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke colour (falls back to PDFium default black) */\n strokeColor?: string;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Line start / end points (page units) */\n linePoints: LinePoints;\n /** Line endings (eg. OpenArrow / Butt) */\n lineEndings?: LineEndings;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Line annotation as SVG (with arrow/butt endings).\n */\nexport function Line({\n color = 'transparent',\n opacity = 1,\n strokeWidth,\n strokeColor = '#000000',\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n linePoints,\n lineEndings,\n scale,\n onClick,\n isSelected,\n appearanceActive = false,\n}: LineProps): JSX.Element {\n const { x1, y1, x2, y2 } = useMemo(() => {\n return {\n x1: linePoints.start.x - rect.origin.x,\n y1: linePoints.start.y - rect.origin.y,\n x2: linePoints.end.x - rect.origin.x,\n y2: linePoints.end.y - rect.origin.y,\n };\n }, [linePoints, rect]);\n\n const endings = useMemo(() => {\n const angle = Math.atan2(y2 - y1, x2 - x1);\n return {\n start: patching.createEnding(lineEndings?.start, strokeWidth, angle + Math.PI, x1, y1),\n end: patching.createEnding(lineEndings?.end, strokeWidth, angle, x2, y2),\n };\n }, [lineEndings, strokeWidth, x1, y1, x2, y2]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor,\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </>\n )}\n </svg>\n );\n}\n","import { MouseEvent, useMemo } from '@framework';\nimport { Rect, Position, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface PolylineProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Optional start & end endings */\n lineEndings?: LineEndings;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\nexport function Polyline({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n lineEndings,\n appearanceActive = false,\n}: PolylineProps): JSX.Element {\n const localPts = useMemo(\n () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [vertices, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n return (\n `M ${first.x} ${first.y} ` +\n rest\n .map((p) => `L ${p.x} ${p.y} `)\n .join('')\n .trim()\n );\n }, [localPts]);\n\n const endings = useMemo(() => {\n if (localPts.length < 2) return { start: null, end: null };\n const toAngle = (a: Position, b: Position) => Math.atan2(b.y - a.y, b.x - a.x);\n\n const startRad = toAngle(localPts[0], localPts[1]);\n const endRad = toAngle(localPts[localPts.length - 2], localPts[localPts.length - 1]);\n\n const start = patching.createEnding(\n lineEndings?.start,\n strokeWidth,\n startRad + Math.PI,\n localPts[0].x,\n localPts[0].y,\n );\n const end = patching.createEnding(\n lineEndings?.end,\n strokeWidth,\n endRad,\n localPts[localPts.length - 1].x,\n localPts[localPts.length - 1].y,\n );\n return { start, end };\n }, [localPts, lineEndings, strokeWidth]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <path\n d={pathData}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n <path\n d={pathData}\n opacity={opacity}\n style={{\n fill: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n pointerEvents: 'none',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </>\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect, Position, PdfAnnotationBorderStyle } from '@embedpdf/models';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface PolygonProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n strokeStyle?: PdfAnnotationBorderStyle;\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement>) => void;\n currentVertex?: Position;\n handleSize?: number;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\nexport function Polygon({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n currentVertex,\n handleSize = 14,\n appearanceActive = false,\n}: PolygonProps): JSX.Element {\n const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;\n\n const localPts = useMemo(\n () => allPoints.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [allPoints, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n const isPreview = !!currentVertex;\n return (\n `M ${first.x} ${first.y} ` +\n rest.map((p) => `L ${p.x} ${p.y}`).join(' ') +\n (isPreview ? '' : ' Z')\n ).trim();\n }, [localPts, currentVertex]);\n\n const isPreviewing = currentVertex && vertices.length > 0;\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <path\n d={pathData}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n <path\n d={pathData}\n opacity={opacity}\n style={{\n fill: currentVertex ? 'none' : color,\n stroke: strokeColor ?? color,\n strokeWidth,\n pointerEvents: 'none',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {isPreviewing && vertices.length > 1 && (\n <path\n d={`M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`}\n fill=\"none\"\n style={{\n stroke: strokeColor,\n strokeWidth,\n strokeDasharray: '4,4',\n opacity: 0.7,\n pointerEvents: 'none',\n }}\n />\n )}\n {isPreviewing && vertices.length >= 2 && (\n <rect\n x={localPts[0].x - handleSize / scale / 2}\n y={localPts[0].y - handleSize / scale / 2}\n width={handleSize / scale}\n height={handleSize / scale}\n fill={strokeColor}\n opacity={0.4}\n stroke={strokeColor}\n strokeWidth={strokeWidth / 2}\n style={{ pointerEvents: 'none' }}\n />\n )}\n </>\n )}\n </svg>\n );\n}\n","import { getContrastStrokeColor } from '@embedpdf/models';\nimport { MouseEvent } from '@framework';\n\ninterface TextProps {\n isSelected: boolean;\n color?: string;\n opacity?: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a fallback sticky-note icon for PDF Text annotations when no\n * appearance stream image is available.\n */\nexport function Text({\n isSelected,\n color = '#facc15',\n opacity = 1,\n onClick,\n appearanceActive = false,\n}: TextProps): JSX.Element {\n const lineColor = getContrastStrokeColor(color);\n\n return (\n <div\n style={{\n position: 'absolute',\n inset: 0,\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: isSelected ? 'move' : 'pointer',\n }}\n onPointerDown={onClick}\n >\n {!appearanceActive && (\n <svg\n style={{\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n }}\n viewBox=\"0 0 20 20\"\n width=\"100%\"\n height=\"100%\"\n >\n <path\n d=\"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z\"\n fill={color}\n opacity={opacity}\n stroke={lineColor}\n strokeWidth=\"1\"\n strokeLinejoin=\"miter\"\n />\n <line x1=\"2.5\" y1=\"4.25\" x2=\"17.5\" y2=\"4.25\" stroke={lineColor} strokeWidth=\"1\" />\n <line x1=\"2.5\" y1=\"8\" x2=\"17.5\" y2=\"8\" stroke={lineColor} strokeWidth=\"1\" />\n <line x1=\"2.5\" y1=\"11.75\" x2=\"17.5\" y2=\"11.75\" stroke={lineColor} strokeWidth=\"1\" />\n </svg>\n )}\n </div>\n );\n}\n","import {\n MouseEvent,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n suppressContentEditableWarningProps,\n} from '@framework';\nimport {\n PdfFreeTextAnnoObject,\n PdfVerticalAlignment,\n standardFontCssProperties,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { useAnnotationCapability } from '../..';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\ninterface FreeTextProps {\n documentId: string;\n isSelected: boolean;\n isEditing: boolean;\n annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;\n pageIndex: number;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;\n /** When true, AP canvas provides the visual; hide text content */\n appearanceActive?: boolean;\n}\n\nexport function FreeText({\n documentId,\n isSelected,\n isEditing,\n annotation,\n pageIndex,\n scale,\n onClick,\n appearanceActive = false,\n}: FreeTextProps) {\n const editorRef = useRef<HTMLSpanElement>(null);\n const editingRef = useRef(false);\n const { provides: annotationCapability } = useAnnotationCapability();\n const annotationProvides = annotationCapability?.forDocument(documentId) ?? null;\n const [isIOS, setIsIOS] = useState(false);\n\n useEffect(() => {\n if (isEditing && editorRef.current) {\n editingRef.current = true;\n const editor = editorRef.current;\n editor.focus();\n\n const selection = window.getSelection();\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(editor);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n }, [isEditing]);\n\n useLayoutEffect(() => {\n try {\n const nav = navigator as any;\n const ios =\n /iPad|iPhone|iPod/.test(navigator.userAgent) ||\n (navigator.platform === 'MacIntel' && nav?.maxTouchPoints > 1);\n setIsIOS(ios);\n } catch {\n setIsIOS(false);\n }\n }, []);\n\n const handleBlur = () => {\n if (!editingRef.current) return;\n editingRef.current = false;\n if (!annotationProvides) return;\n if (!editorRef.current) return;\n annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {\n contents: editorRef.current.innerText,\n });\n };\n\n // iOS zoom prevention: keep focused font-size >= 16px, visually scale down if needed.\n const computedFontPx = annotation.object.fontSize * scale;\n const MIN_IOS_FOCUS_FONT_PX = 16;\n const needsComp =\n isIOS && isEditing && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;\n const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;\n const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;\n const invScalePercent = needsComp ? 100 / scaleComp : 100;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: annotation.object.rect.size.width * scale,\n height: annotation.object.rect.size.height * scale,\n cursor: isSelected && !isEditing ? 'move' : 'default',\n pointerEvents: isSelected && !isEditing ? 'none' : 'auto',\n zIndex: 2,\n opacity: appearanceActive ? 0 : 1,\n }}\n onPointerDown={onClick}\n >\n <span\n ref={editorRef}\n onBlur={handleBlur}\n tabIndex={0}\n style={{\n color: annotation.object.fontColor,\n fontSize: adjustedFontPx,\n ...standardFontCssProperties(annotation.object.fontFamily),\n textAlign: textAlignmentToCss(annotation.object.textAlign),\n flexDirection: 'column',\n justifyContent:\n annotation.object.verticalAlign === PdfVerticalAlignment.Top\n ? 'flex-start'\n : annotation.object.verticalAlign === PdfVerticalAlignment.Middle\n ? 'center'\n : 'flex-end',\n display: 'flex',\n backgroundColor: annotation.object.color ?? annotation.object.backgroundColor,\n opacity: annotation.object.opacity,\n width: needsComp ? `${invScalePercent}%` : '100%',\n height: needsComp ? `${invScalePercent}%` : '100%',\n lineHeight: '1.18',\n overflow: 'hidden',\n cursor: isEditing ? 'text' : 'pointer',\n outline: 'none',\n transform: needsComp ? `scale(${scaleComp})` : undefined,\n transformOrigin: 'top left',\n }}\n contentEditable={isEditing}\n {...suppressContentEditableWarningProps}\n >\n {annotation.object.contents}\n </span>\n </div>\n );\n}\n","import { Fragment, HTMLAttributes, CSSProperties, useEffect, useRef, useState } from '@framework';\nimport { AppearanceMode, ignore, PdfAnnotationObject, PdfErrorCode } from '@embedpdf/models';\n\nimport { useAnnotationCapability } from '../hooks/use-annotation';\n\ntype RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n annotation: PdfAnnotationObject;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n unrotated?: boolean;\n};\n\nexport function RenderAnnotation({\n documentId,\n pageIndex,\n annotation,\n scaleFactor = 1,\n unrotated,\n style,\n ...props\n}: RenderAnnotationProps) {\n const { provides: annotationProvides } = useAnnotationCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n const { width, height } = annotation.rect.size;\n\n useEffect(() => {\n if (annotationProvides) {\n const task = annotationProvides.forDocument(documentId).renderAnnotation({\n pageIndex,\n annotation,\n options: {\n scaleFactor,\n dpr: window.devicePixelRatio,\n unrotated,\n },\n });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [\n pageIndex,\n scaleFactor,\n unrotated,\n annotationProvides,\n documentId,\n annotation.id,\n width,\n height,\n ]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n display: 'block',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n","import { MouseEvent } from '@framework';\nimport { PdfStampAnnoObject } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { RenderAnnotation } from '../render-annotation';\n\ninterface StampProps {\n isSelected: boolean;\n annotation: TrackedAnnotation<PdfStampAnnoObject>;\n documentId: string;\n pageIndex: number;\n scale: number;\n onClick: (e: MouseEvent<HTMLDivElement>) => void;\n}\n\nexport function Stamp({\n isSelected,\n annotation,\n documentId,\n pageIndex,\n scale,\n onClick,\n}: StampProps) {\n const unrotated = !!annotation.object.rotation && !!annotation.object.unrotatedRect;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: 'pointer',\n }}\n onPointerDown={onClick}\n >\n <RenderAnnotation\n documentId={documentId}\n pageIndex={pageIndex}\n annotation={{ ...annotation.object, id: annotation.object.id }}\n scaleFactor={scale}\n unrotated={unrotated}\n />\n </div>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface LinkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour – defaults to blue when omitted */\n strokeColor?: string;\n /** Stroke width in PDF units */\n strokeWidth?: number;\n /** Stroke type – defaults to underline when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – for dashed style */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Whether this link has an IRT (In Reply To) reference - disables direct interaction */\n hasIRT?: boolean;\n}\n\n/**\n * Renders a PDF Link annotation as SVG.\n * Supports underline (default), solid, and dashed border styles.\n */\nexport function Link({\n isSelected,\n strokeColor = '#0000FF',\n strokeWidth = 2,\n strokeStyle = PdfAnnotationBorderStyle.UNDERLINE,\n strokeDashArray,\n rect,\n scale,\n onClick,\n hasIRT = false,\n}: LinkProps): JSX.Element {\n const { width, height } = useMemo(() => {\n return {\n width: rect.size.width,\n height: rect.size.height,\n };\n }, [rect]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n // Calculate dash array for SVG\n const dashArray = useMemo(() => {\n if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {\n return strokeDashArray?.join(',') ?? `${strokeWidth * 3},${strokeWidth}`;\n }\n return undefined;\n }, [strokeStyle, strokeDashArray, strokeWidth]);\n\n // For underline style, render a line at the bottom\n // For solid/dashed, render a rectangle border\n const isUnderline = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n >\n {/* Invisible hit area for the entire link region */}\n {/* IRT links are not directly clickable - interaction goes through parent */}\n <rect\n x={0}\n y={0}\n width={width}\n height={height}\n fill=\"transparent\"\n onPointerDown={hasIRT ? undefined : onClick}\n style={{\n cursor: hasIRT ? 'default' : isSelected ? 'move' : 'pointer',\n pointerEvents: hasIRT ? 'none' : isSelected ? 'none' : 'visible',\n }}\n />\n\n {isUnderline ? (\n // Underline style: line at bottom of rect\n <line\n x1={1}\n y1={height - 1}\n x2={width - 1}\n y2={height - 1}\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n strokeDasharray={dashArray}\n style={{\n pointerEvents: 'none',\n }}\n />\n ) : (\n // Solid/Dashed style: rectangle border\n <rect\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n width={Math.max(width - strokeWidth, 0)}\n height={Math.max(height - strokeWidth, 0)}\n fill=\"transparent\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n strokeDasharray={dashArray}\n style={{\n pointerEvents: 'none',\n }}\n />\n )}\n </svg>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype HighlightProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Highlight({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: HighlightProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n\n return (\n <>\n {segmentRects.map((b, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,\n top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background: appearanceActive ? 'transparent' : resolvedColor,\n opacity: appearanceActive ? undefined : opacity,\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : undefined,\n ...style,\n }}\n />\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype UnderlineProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Underline({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: UnderlineProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const thickness = 2 * scale; // 2 CSS px at 100 % zoom\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: thickness,\n background: resolvedColor,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype StrikeoutProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Strikeout({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: StrikeoutProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const thickness = 2 * scale;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n top: '50%',\n width: '100%',\n height: thickness,\n background: resolvedColor,\n opacity: opacity,\n transform: 'translateY(-50%)',\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype SquigglyProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Squiggly({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: SquigglyProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const amplitude = 2 * scale; // wave height\n const period = 6 * scale; // wave length\n\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${period}\" height=\"${amplitude * 2}\" viewBox=\"0 0 ${period} ${amplitude * 2}\">\n <path d=\"M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}\"\n fill=\"none\" stroke=\"${resolvedColor}\" stroke-width=\"${amplitude}\" stroke-linecap=\"round\"/>\n </svg>`;\n\n // Completely escape the SVG markup\n const svgDataUri = `url(\"data:image/svg+xml;utf8,${encodeURIComponent(svg)}\")`;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: amplitude * 2,\n backgroundImage: svgDataUri,\n backgroundRepeat: 'repeat-x',\n backgroundSize: `${period}px ${amplitude * 2}px`,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ninterface CaretProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Caret annotation as an SVG ^ symbol using bezier curves\n * that mirror the C++ appearance stream.\n */\nexport function Caret({\n isSelected,\n strokeColor = '#000000',\n opacity = 1,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n}: CaretProps): JSX.Element {\n const { width, height, path } = useMemo(() => {\n const w = rect.size.width;\n const h = rect.size.height;\n\n const midX = w / 2;\n\n const d = [\n `M 0 ${h}`,\n `C ${w * 0.27} ${h} ${midX} ${h - h * 0.44} ${midX} 0`,\n `C ${midX} ${h - h * 0.44} ${w - w * 0.27} ${h} ${w} ${h}`,\n 'Z',\n ].join(' ');\n\n return { width: w, height: h, path: d };\n }, [rect]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n overflow=\"visible\"\n >\n {/* Hit area */}\n <path\n d={path}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={4}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visible',\n }}\n />\n {/* Visual */}\n {!appearanceActive && (\n <path\n d={path}\n fill={strokeColor}\n stroke={strokeColor}\n strokeWidth={0.5}\n opacity={opacity}\n fillRule=\"evenodd\"\n style={{ pointerEvents: 'none' }}\n />\n )}\n </svg>\n );\n}\n","import {\n PdfAnnotationSubtype,\n PdfAnnotationObject,\n PdfBlendMode,\n PdfInkAnnoObject,\n PdfSquareAnnoObject,\n PdfCircleAnnoObject,\n PdfLineAnnoObject,\n PdfPolylineAnnoObject,\n PdfPolygonAnnoObject,\n PdfTextAnnoObject,\n PdfFreeTextAnnoObject,\n PdfStampAnnoObject,\n PdfLinkAnnoObject,\n PdfHighlightAnnoObject,\n PdfUnderlineAnnoObject,\n PdfStrikeOutAnnoObject,\n PdfSquigglyAnnoObject,\n PdfCaretAnnoObject,\n blendModeToCss,\n} from '@embedpdf/models';\nimport { Fragment } from '@framework';\nimport { BoxedAnnotationRenderer, createRenderer } from './types';\nimport { Ink } from './annotations/ink';\nimport { Square } from './annotations/square';\nimport { Circle } from './annotations/circle';\nimport { Line } from './annotations/line';\nimport { Polyline } from './annotations/polyline';\nimport { Polygon } from './annotations/polygon';\nimport { Text } from './annotations/text';\nimport { FreeText } from './annotations/free-text';\nimport { Stamp } from './annotations/stamp';\nimport { Link } from './annotations/link';\nimport { Highlight } from './text-markup/highlight';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Caret } from './annotations/caret';\n\nexport const builtInRenderers: BoxedAnnotationRenderer[] = [\n // --- Drawing ---\n\n createRenderer<PdfInkAnnoObject>({\n id: 'ink',\n matches: (a): a is PdfInkAnnoObject => a.type === PdfAnnotationSubtype.INK,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Ink\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Shapes ---\n\n createRenderer<PdfSquareAnnoObject>({\n id: 'square',\n matches: (a): a is PdfSquareAnnoObject => a.type === PdfAnnotationSubtype.SQUARE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Square\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n createRenderer<PdfCircleAnnoObject>({\n id: 'circle',\n matches: (a): a is PdfCircleAnnoObject => a.type === PdfAnnotationSubtype.CIRCLE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Circle\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Lines & Vertex-based ---\n\n createRenderer<PdfLineAnnoObject>({\n id: 'line',\n matches: (a): a is PdfLineAnnoObject => a.type === PdfAnnotationSubtype.LINE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Line\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => [a.linePoints.start, a.linePoints.end],\n transformAnnotation: (a, v) => ({\n ...a,\n linePoints: { start: v[0], end: v[1] },\n }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n createRenderer<PdfPolylineAnnoObject>({\n id: 'polyline',\n matches: (a): a is PdfPolylineAnnoObject => a.type === PdfAnnotationSubtype.POLYLINE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Polyline\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => a.vertices,\n transformAnnotation: (a, vertices) => ({ ...a, vertices }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n createRenderer<PdfPolygonAnnoObject>({\n id: 'polygon',\n matches: (a): a is PdfPolygonAnnoObject => a.type === PdfAnnotationSubtype.POLYGON,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Polygon\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => a.vertices,\n transformAnnotation: (a, vertices) => ({ ...a, vertices }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n // --- Text Markup ---\n\n createRenderer<PdfHighlightAnnoObject>({\n id: 'highlight',\n matches: (a): a is PdfHighlightAnnoObject => a.type === PdfAnnotationSubtype.HIGHLIGHT,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Highlight\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n containerStyle: (a) => ({\n mixBlendMode: blendModeToCss(a.blendMode ?? PdfBlendMode.Multiply),\n }),\n }),\n\n createRenderer<PdfUnderlineAnnoObject>({\n id: 'underline',\n matches: (a): a is PdfUnderlineAnnoObject => a.type === PdfAnnotationSubtype.UNDERLINE,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Underline\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n createRenderer<PdfStrikeOutAnnoObject>({\n id: 'strikeout',\n matches: (a): a is PdfStrikeOutAnnoObject => a.type === PdfAnnotationSubtype.STRIKEOUT,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Strikeout\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n createRenderer<PdfSquigglyAnnoObject>({\n id: 'squiggly',\n matches: (a): a is PdfSquigglyAnnoObject => a.type === PdfAnnotationSubtype.SQUIGGLY,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Squiggly\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n // --- Text Comment ---\n\n createRenderer<PdfTextAnnoObject>({\n id: 'text',\n matches: (a): a is PdfTextAnnoObject => a.type === PdfAnnotationSubtype.TEXT && !a.inReplyToId,\n render: ({ currentObject, isSelected, onClick, appearanceActive }) => (\n <Text\n isSelected={isSelected}\n color={currentObject.strokeColor ?? currentObject.color}\n opacity={currentObject.opacity}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: false },\n }),\n\n // --- Caret ---\n\n createRenderer<PdfCaretAnnoObject>({\n id: 'caret',\n matches: (a): a is PdfCaretAnnoObject => a.type === PdfAnnotationSubtype.CARET,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Caret\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n // --- FreeText ---\n\n createRenderer<PdfFreeTextAnnoObject>({\n id: 'freeText',\n matches: (a): a is PdfFreeTextAnnoObject => a.type === PdfAnnotationSubtype.FREETEXT,\n render: ({\n annotation,\n currentObject,\n isSelected,\n isEditing,\n scale,\n pageIndex,\n documentId,\n onClick,\n appearanceActive,\n }) => (\n <FreeText\n documentId={documentId}\n isSelected={isSelected}\n isEditing={isEditing}\n annotation={{ ...annotation, object: currentObject }}\n pageIndex={pageIndex}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n isDraggable: (toolDraggable, { isEditing }) => toolDraggable && !isEditing,\n onDoubleClick: (id, setEditingId) => setEditingId(id),\n }),\n\n // --- Stamp ---\n\n createRenderer<PdfStampAnnoObject>({\n id: 'stamp',\n matches: (a): a is PdfStampAnnoObject => a.type === PdfAnnotationSubtype.STAMP,\n render: ({ annotation, isSelected, documentId, pageIndex, scale, onClick }) => (\n <Stamp\n isSelected={isSelected}\n annotation={annotation}\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n onClick={onClick}\n />\n ),\n useAppearanceStream: false,\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Link ---\n\n createRenderer<PdfLinkAnnoObject>({\n id: 'link',\n matches: (a): a is PdfLinkAnnoObject => a.type === PdfAnnotationSubtype.LINK,\n render: ({ currentObject, isSelected, scale, onClick }) => (\n <Link\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n hasIRT={!!currentObject.inReplyToId}\n />\n ),\n interactionDefaults: {\n isDraggable: false,\n isResizable: false,\n isRotatable: false,\n },\n useAppearanceStream: false,\n selectOverride: (e, annotation, helpers) => {\n e.stopPropagation();\n helpers.clearSelection();\n if (annotation.object.inReplyToId) {\n const parent = helpers.allAnnotations.find(\n (a) => a.object.id === annotation.object.inReplyToId,\n );\n if (parent) {\n helpers.selectAnnotation(parent.object.pageIndex, parent.object.id);\n return;\n }\n }\n helpers.selectAnnotation(helpers.pageIndex, annotation.object.id);\n },\n hideSelectionMenu: (a) => !!a.inReplyToId,\n }),\n];\n","import {\n blendModeToCss,\n PdfAnnotationObject,\n PdfBlendMode,\n AnnotationAppearanceMap,\n AnnotationAppearances,\n} from '@embedpdf/models';\nimport {\n getAnnotationsByPageIndex,\n getSelectedAnnotationIds,\n TrackedAnnotation,\n resolveInteractionProp,\n} from '@embedpdf/plugin-annotation';\nimport { PointerEventHandlers, EmbedPdfPointerEvent } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\nimport { useMemo, useState, useEffect, useCallback, MouseEvent, useRef } from '@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport { AnnotationContainer } from './annotation-container';\nimport { GroupSelectionBox } from './group-selection-box';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n GroupSelectionMenuRenderFn,\n VertexHandleUI,\n RotationHandleUI,\n SelectionOutline,\n BoxedAnnotationRenderer,\n AnnotationInteractionEvent,\n SelectOverrideHelpers,\n} from './types';\nimport { builtInRenderers } from './built-in-renderers';\n\ninterface AnnotationsProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n rotationUI?: RotationHandleUI;\n selectionOutlineColor?: string;\n selectionOutline?: SelectionOutline;\n groupSelectionOutline?: SelectionOutline;\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n annotationRenderers?: BoxedAnnotationRenderer[];\n}\n\nexport function Annotations(annotationsProps: AnnotationsProps) {\n const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;\n const { provides: annotationCapability } = useAnnotationCapability();\n const { provides: selectionProvides } = useSelectionCapability();\n const [annotations, setAnnotations] = useState<TrackedAnnotation[]>([]);\n const { register } = usePointerHandlers({ documentId, pageIndex });\n const [allSelectedIds, setAllSelectedIds] = useState<string[]>([]);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [appearanceMap, setAppearanceMap] = useState<AnnotationAppearanceMap<Blob>>({});\n const prevScaleRef = useRef<number>(scale);\n\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const isMultiSelected = allSelectedIds.length > 1;\n\n useEffect(() => {\n if (annotationProvides) {\n const currentState = annotationProvides.getState();\n setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));\n setAllSelectedIds(getSelectedAnnotationIds(currentState));\n\n return annotationProvides.onStateChange((state) => {\n setAnnotations(getAnnotationsByPageIndex(state, pageIndex));\n setAllSelectedIds(getSelectedAnnotationIds(state));\n });\n }\n }, [annotationProvides, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n if (prevScaleRef.current !== scale) {\n annotationProvides.invalidatePageAppearances(pageIndex);\n prevScaleRef.current = scale;\n }\n\n const task = annotationProvides.getPageAppearances(pageIndex, {\n scaleFactor: scale,\n dpr: typeof window !== 'undefined' ? window.devicePixelRatio : 1,\n });\n task.wait(\n (map) => setAppearanceMap(map),\n () => setAppearanceMap({}),\n );\n }, [annotationProvides, pageIndex, scale]);\n\n const handlers = useMemo(\n (): PointerEventHandlers<EmbedPdfPointerEvent<MouseEvent>> => ({\n onPointerDown: (_, pe) => {\n if (pe.target === pe.currentTarget && annotationProvides) {\n annotationProvides.deselectAnnotation();\n setEditingId(null);\n }\n },\n }),\n [annotationProvides],\n );\n\n const handleClick = useCallback(\n (e: MouseEvent, annotation: TrackedAnnotation) => {\n e.stopPropagation();\n if (annotationProvides && selectionProvides) {\n selectionProvides.clear();\n\n const isModifierPressed = 'metaKey' in e ? e.metaKey || e.ctrlKey : false;\n\n if (isModifierPressed) {\n annotationProvides.toggleSelection(pageIndex, annotation.object.id);\n } else {\n annotationProvides.selectAnnotation(pageIndex, annotation.object.id);\n }\n\n if (annotation.object.id !== editingId) {\n setEditingId(null);\n }\n }\n },\n [annotationProvides, selectionProvides, editingId, pageIndex],\n );\n\n useEffect(() => {\n return register(handlers, {\n documentId,\n });\n }, [register, handlers]);\n\n const selectedAnnotationsOnPage = useMemo(() => {\n return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));\n }, [annotations, allSelectedIds]);\n\n const areAllSelectedDraggable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupDraggable = resolveInteractionProp(\n tool?.interaction.isGroupDraggable,\n ta.object,\n true,\n );\n const singleDraggable = resolveInteractionProp(\n tool?.interaction.isDraggable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupDraggable !== undefined ? groupDraggable : singleDraggable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const areAllSelectedResizable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupResizable = resolveInteractionProp(\n tool?.interaction.isGroupResizable,\n ta.object,\n true,\n );\n const singleResizable = resolveInteractionProp(\n tool?.interaction.isResizable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupResizable !== undefined ? groupResizable : singleResizable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const areAllSelectedRotatable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupRotatable = resolveInteractionProp(\n tool?.interaction.isGroupRotatable,\n ta.object,\n true,\n );\n const singleRotatable = resolveInteractionProp(\n tool?.interaction.isRotatable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupRotatable !== undefined ? groupRotatable : singleRotatable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const shouldLockGroupAspectRatio = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.some((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupLock = resolveInteractionProp(\n tool?.interaction.lockGroupAspectRatio,\n ta.object,\n false,\n );\n const singleLock = resolveInteractionProp(\n tool?.interaction.lockAspectRatio,\n ta.object,\n false,\n );\n return tool?.interaction.lockGroupAspectRatio !== undefined ? groupLock : singleLock;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const allSelectedOnSamePage = useMemo(() => {\n if (!annotationProvides) return false;\n const allSelected = annotationProvides.getSelectedAnnotations();\n return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);\n }, [annotationProvides, pageIndex, allSelectedIds]);\n\n const getAppearanceForAnnotation = useCallback(\n (ta: TrackedAnnotation): AnnotationAppearances<Blob> | null => {\n if (ta.dictMode) return null;\n if (ta.object.rotation && ta.object.unrotatedRect) return null;\n const appearances = appearanceMap[ta.object.id];\n if (!appearances?.normal) return null;\n return appearances;\n },\n [appearanceMap],\n );\n\n // Merge renderers: external renderers override built-ins by ID\n const allRenderers = useMemo(() => {\n const external = annotationsProps.annotationRenderers ?? [];\n const externalIds = new Set(external.map((r) => r.id));\n return [...external, ...builtInRenderers.filter((r) => !externalIds.has(r.id))];\n }, [annotationsProps.annotationRenderers]);\n\n const resolveRenderer = useCallback(\n (annotation: TrackedAnnotation) =>\n allRenderers.find((r) => r.matches(annotation.object)) ?? null,\n [allRenderers],\n );\n\n // Stable helpers object for selectOverride\n const selectHelpers = useMemo(\n (): SelectOverrideHelpers => ({\n defaultSelect: handleClick,\n selectAnnotation: (pi: number, id: string) => annotationProvides?.selectAnnotation(pi, id),\n clearSelection: () => selectionProvides?.clear(),\n allAnnotations: annotations,\n pageIndex,\n }),\n [handleClick, annotationProvides, selectionProvides, annotations, pageIndex],\n );\n\n return (\n <>\n {annotations.map((annotation) => {\n const renderer = resolveRenderer(annotation);\n if (!renderer) return null;\n\n const tool = annotationProvides?.findToolForAnnotation(annotation.object);\n const isSelected = allSelectedIds.includes(annotation.object.id);\n const isEditing = editingId === annotation.object.id;\n const defaults = renderer.interactionDefaults;\n\n const resolvedDraggable = resolveInteractionProp(\n tool?.interaction.isDraggable,\n annotation.object,\n defaults?.isDraggable ?? true,\n );\n const finalDraggable = renderer.isDraggable\n ? renderer.isDraggable(resolvedDraggable, { isEditing })\n : resolvedDraggable;\n\n const useAP = tool?.behavior?.useAppearanceStream ?? renderer.useAppearanceStream ?? true;\n\n const onSelect = renderer.selectOverride\n ? (e: AnnotationInteractionEvent) =>\n renderer.selectOverride!(e, annotation, selectHelpers)\n : (e: AnnotationInteractionEvent) => handleClick(e, annotation);\n\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isEditing={isEditing}\n isMultiSelected={isMultiSelected}\n isDraggable={finalDraggable}\n isResizable={resolveInteractionProp(\n tool?.interaction.isResizable,\n annotation.object,\n defaults?.isResizable ?? false,\n )}\n lockAspectRatio={resolveInteractionProp(\n tool?.interaction.lockAspectRatio,\n annotation.object,\n defaults?.lockAspectRatio ?? false,\n )}\n isRotatable={resolveInteractionProp(\n tool?.interaction.isRotatable,\n annotation.object,\n defaults?.isRotatable ?? false,\n )}\n vertexConfig={renderer.vertexConfig}\n selectionMenu={\n renderer.hideSelectionMenu?.(annotation.object) ? undefined : selectionMenu\n }\n onSelect={onSelect}\n onDoubleClick={\n renderer.onDoubleClick\n ? (e: AnnotationInteractionEvent) => {\n e.stopPropagation();\n renderer.onDoubleClick!(annotation.object.id, setEditingId);\n }\n : undefined\n }\n zIndex={renderer.zIndex}\n style={\n renderer.containerStyle?.(annotation.object) ?? {\n mixBlendMode: blendModeToCss(annotation.object.blendMode ?? PdfBlendMode.Normal),\n }\n }\n appearance={useAP ? getAppearanceForAnnotation(annotation) : undefined}\n {...annotationsProps}\n >\n {(currentObject, { appearanceActive }) =>\n renderer.render({\n annotation,\n currentObject,\n isSelected,\n isEditing,\n scale,\n pageIndex,\n documentId,\n onClick: onSelect,\n appearanceActive,\n })\n }\n </AnnotationContainer>\n );\n })}\n\n {allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && (\n <GroupSelectionBox\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n rotation={annotationsProps.rotation}\n pageWidth={pageWidth}\n pageHeight={pageHeight}\n selectedAnnotations={selectedAnnotationsOnPage}\n isDraggable={areAllSelectedDraggable}\n isResizable={areAllSelectedResizable}\n isRotatable={areAllSelectedRotatable}\n lockAspectRatio={shouldLockGroupAspectRatio}\n resizeUI={annotationsProps.resizeUI}\n rotationUI={annotationsProps.rotationUI}\n selectionOutlineColor={annotationsProps.selectionOutlineColor}\n selectionOutline={\n annotationsProps.groupSelectionOutline ?? annotationsProps.selectionOutline\n }\n groupSelectionMenu={annotationsProps.groupSelectionMenu}\n />\n )}\n </>\n );\n}\n","import { blendModeToCss, PdfAnnotationSubtype, PdfBlendMode, Rect } from '@embedpdf/models';\nimport { AnnotationTool } from '@embedpdf/plugin-annotation';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\n\nimport { useEffect, useState } from '@framework';\nimport { useAnnotationCapability } from '../hooks';\nimport { Highlight } from './text-markup/highlight';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\n\ninterface TextMarkupProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function TextMarkup({ documentId, pageIndex, scale }: TextMarkupProps) {\n const { provides: selectionProvides } = useSelectionCapability();\n const { provides: annotationProvides } = useAnnotationCapability();\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const [activeTool, setActiveTool] = useState<AnnotationTool | null>(null);\n\n useEffect(() => {\n if (!selectionProvides) return;\n\n return selectionProvides.forDocument(documentId).onSelectionChange(() => {\n setRects(selectionProvides.forDocument(documentId).getHighlightRectsForPage(pageIndex));\n setBoundingRect(selectionProvides.forDocument(documentId).getBoundingRectForPage(pageIndex));\n });\n }, [selectionProvides, documentId, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n // Initialize with current active tool\n setActiveTool(annotationProvides.forDocument(documentId).getActiveTool());\n\n return annotationProvides\n .forDocument(documentId)\n .onActiveToolChange((event) => setActiveTool(event));\n }, [annotationProvides, documentId]);\n\n if (!boundingRect) return null;\n if (!activeTool || !activeTool.defaults) return null;\n\n switch (activeTool.defaults.type) {\n case PdfAnnotationSubtype.UNDERLINE:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Underline\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.HIGHLIGHT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Multiply),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Highlight\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.STRIKEOUT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Strikeout\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.SQUIGGLY:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Squiggly\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.CARET:\n return null;\n default:\n return null;\n }\n}\n","import { AnyPreviewState } from '@embedpdf/plugin-annotation';\nimport { Circle } from './annotations/circle';\nimport { Square } from './annotations/square';\nimport { Polygon } from './annotations/polygon';\nimport { PdfAnnotationSubtype } from '@embedpdf/models';\nimport { Polyline } from './annotations/polyline';\nimport { Line } from './annotations/line';\nimport { Ink } from './annotations/ink';\n\ninterface Props {\n preview: AnyPreviewState;\n scale: number;\n}\n\nexport function PreviewRenderer({ preview, scale }: Props) {\n const { bounds } = preview;\n\n const style = {\n position: 'absolute' as const,\n left: bounds.origin.x * scale,\n top: bounds.origin.y * scale,\n width: bounds.size.width * scale,\n height: bounds.size.height * scale,\n pointerEvents: 'none' as const,\n zIndex: 10,\n };\n\n // Use type guards for proper type narrowing\n if (preview.type === PdfAnnotationSubtype.CIRCLE) {\n return (\n <div style={style}>\n <Circle isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.SQUARE) {\n return (\n <div style={style}>\n <Square isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYGON) {\n return (\n <div style={style}>\n <Polygon isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYLINE) {\n return (\n <div style={style}>\n <Polyline isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.LINE) {\n return (\n <div style={style}>\n <Line isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.INK) {\n return (\n <div style={style}>\n <Ink isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.FREETEXT) {\n return (\n <div style={style}>\n {/* Render a simple dashed border preview */}\n <div\n style={{\n width: '100%',\n height: '100%',\n border: `1px dashed ${preview.data.fontColor || '#000000'}`,\n backgroundColor: 'transparent',\n }}\n />\n </div>\n );\n }\n\n return null;\n}\n","import { useEffect, useMemo, useRef, useState } from '@framework';\nimport { useAnnotationPlugin } from '../hooks';\nimport { AnyPreviewState, HandlerServices } from '@embedpdf/plugin-annotation';\nimport { PreviewRenderer } from './preview-renderer';\n\ninterface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function AnnotationPaintLayer({ documentId, pageIndex, scale }: Props) {\n const { plugin: annotationPlugin } = useAnnotationPlugin();\n const [previews, setPreviews] = useState<Map<string, AnyPreviewState>>(new Map());\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const services = useMemo<HandlerServices>(\n () => ({\n requestFile: ({ accept, onFile }) => {\n if (!fileInputRef.current) return;\n const input = fileInputRef.current;\n input.accept = accept;\n input.onchange = (e) => {\n const file = (e.target as HTMLInputElement).files?.[0];\n if (file) {\n onFile(file);\n input.value = '';\n }\n };\n input.click();\n },\n processImage: ({ source, maxWidth, maxHeight, onComplete }) => {\n const canvas = canvasRef.current;\n if (!canvas || !canvas.getContext) return;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n\n const img = new Image();\n img.crossOrigin = 'Anonymous';\n img.onload = () => {\n let { naturalWidth: width, naturalHeight: height } = img;\n\n // --- SCALING LOGIC ---\n // Calculate the scale factor to fit within maxWidth and maxHeight\n const scaleX = maxWidth ? maxWidth / width : 1;\n const scaleY = maxHeight ? maxHeight / height : 1;\n const scaleFactor = Math.min(scaleX, scaleY, 1); // Ensure we don't scale up\n\n const finalWidth = width * scaleFactor;\n const finalHeight = height * scaleFactor;\n\n canvas.width = finalWidth;\n canvas.height = finalHeight;\n ctx.drawImage(img, 0, 0, finalWidth, finalHeight);\n\n const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);\n if (typeof source !== 'string') URL.revokeObjectURL(img.src);\n\n onComplete({ imageData, width: finalWidth, height: finalHeight });\n };\n img.src = typeof source === 'string' ? source : URL.createObjectURL(source);\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!annotationPlugin) return;\n\n return annotationPlugin.registerPageHandlers(documentId, pageIndex, scale, {\n services,\n onPreview: (toolId, state) => {\n setPreviews((prev) => {\n const next = new Map(prev);\n if (state) {\n next.set(toolId, state);\n } else {\n next.delete(toolId);\n }\n return next;\n });\n },\n });\n }, [documentId, pageIndex, scale, annotationPlugin, services]);\n\n return (\n <>\n {/* Hidden DOM elements required by services */}\n <input ref={fileInputRef} type=\"file\" style={{ display: 'none' }} />\n <canvas ref={canvasRef} style={{ display: 'none' }} />\n\n {/* Render any active previews from any tool */}\n {Array.from(previews.entries()).map(([toolId, preview]) => (\n <PreviewRenderer key={toolId} preview={preview} scale={scale} />\n ))}\n </>\n );\n}\n","import { HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Annotations } from './annotations';\nimport { TextMarkup } from './text-markup';\nimport {\n ResizeHandleUI,\n VertexHandleUI,\n RotationHandleUI,\n SelectionOutline,\n CustomAnnotationRenderer,\n AnnotationSelectionMenuRenderFn,\n GroupSelectionMenuRenderFn,\n BoxedAnnotationRenderer,\n} from './types';\nimport { AnnotationPaintLayer } from './annotation-paint-layer';\nimport { PdfAnnotationObject, Rotation } from '@embedpdf/models';\nimport { useRegisteredRenderers } from '../context/renderer-registry';\n\ntype AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n /** The ID of the document that this layer displays annotations for */\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: number;\n /** Customize selection menu across all annotations on this layer */\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n /** Customize group selection menu across all annotations on this layer */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n style?: CSSProperties;\n /** Customize resize handles */\n resizeUI?: ResizeHandleUI;\n /** Customize vertex handles */\n vertexUI?: VertexHandleUI;\n /** Customize rotation handle */\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline` instead */\n selectionOutlineColor?: string;\n /** Customize the selection outline for individual annotations */\n selectionOutline?: SelectionOutline;\n /** Customize the selection outline for the group selection box (falls back to selectionOutline) */\n groupSelectionOutline?: SelectionOutline;\n /** Customize annotation renderer */\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n /** Custom renderers for specific annotation types (provided by external plugins) */\n annotationRenderers?: BoxedAnnotationRenderer[];\n};\n\nexport function AnnotationLayer({\n style,\n documentId,\n pageIndex,\n scale: overrideScale,\n rotation: overrideRotation,\n selectionMenu,\n groupSelectionMenu,\n resizeUI,\n vertexUI,\n rotationUI,\n selectionOutlineColor,\n selectionOutline,\n groupSelectionOutline,\n customAnnotationRenderer,\n annotationRenderers,\n ...props\n}: AnnotationLayerProps) {\n const documentState = useDocumentState(documentId);\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n\n // Auto-load renderers from context\n const contextRenderers = useRegisteredRenderers();\n\n // Merge: context + explicit props (props take precedence by id)\n const allRenderers = useMemo(() => {\n const merged = [...contextRenderers];\n for (const renderer of annotationRenderers ?? []) {\n const idx = merged.findIndex((r) => r.id === renderer.id);\n if (idx >= 0) merged[idx] = renderer;\n else merged.push(renderer);\n }\n return merged;\n }, [contextRenderers, annotationRenderers]);\n\n const actualScale = useMemo(() => {\n if (overrideScale !== undefined) return overrideScale;\n return documentState?.scale ?? 1;\n }, [overrideScale, documentState?.scale]);\n\n const actualRotation = useMemo(() => {\n if (overrideRotation !== undefined) return overrideRotation;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page?.rotation ?? 0;\n const docRotation = documentState?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n }, [overrideRotation, page?.rotation, documentState?.rotation]);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n <Annotations\n documentId={documentId}\n selectionMenu={selectionMenu}\n groupSelectionMenu={groupSelectionMenu}\n pageIndex={pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n pageWidth={width}\n pageHeight={height}\n resizeUI={resizeUI}\n vertexUI={vertexUI}\n rotationUI={rotationUI}\n selectionOutlineColor={selectionOutlineColor}\n selectionOutline={selectionOutline}\n groupSelectionOutline={groupSelectionOutline}\n customAnnotationRenderer={customAnnotationRenderer}\n annotationRenderers={allRenderers}\n />\n <TextMarkup documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n <AnnotationPaintLayer documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n </div>\n );\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { AnnotationPluginPackage as BaseAnnotationPackage } from '@embedpdf/plugin-annotation';\nimport { AnnotationRendererProvider } from './context/renderer-registry';\n\nexport * from './hooks';\nexport * from './components';\nexport * from './components/types';\nexport * from './context';\nexport * from '@embedpdf/plugin-annotation';\n\n// Automatically wrap with AnnotationRendererProvider\nexport const AnnotationPluginPackage = createPluginPackage(BaseAnnotationPackage)\n .addWrapper(AnnotationRendererProvider)\n .build();\n"],"names":["_a","_b","_c","MIN_HIT_AREA_SCREEN_PX","Fragment","BaseAnnotationPackage"],"mappings":";;;;;;;;;;;;;AA4BO,MAAM,sCAAsC,CAAA;ACdnD,MAAM,kBAAkB,cAAiC,IAAI;AAC7D,MAAM,mBAAmB,cAAyC,EAAE;AAE7D,SAAS,2BAA2B,EAAE,YAAqC;AAChF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAoC,CAAA,CAAE;AAGxE,QAAM,WAAW,YAAY,CAAC,YAAuC;AACnE,iBAAa,CAAC,SAAS;AACrB,YAAM,MAAM,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5C,aAAO,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO;AAAA,IAC3D,CAAC;AACD,WAAO,MAAM,aAAa,CAAC,SAAS,KAAK,OAAO,CAAC,MAAM,CAAC,QAAQ,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CAAC,CAAC;AAAA,EAC7F,GAAG,CAAA,CAAE;AAEL,SACE,oBAAC,gBAAgB,UAAhB,EAAyB,OAAO,UAC/B,UAAA,oBAAC,iBAAiB,UAAjB,EAA0B,OAAO,WAAY,UAAS,GACzD;AAEJ;AAMO,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,YACA;AAAA,YACA,OAAO;AAAA,YACP,UAAU;AAAA,YACV,WAAW;AAAA,YACX,YAAY;AAAA,YACZ;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,qBAAqB;AAAA,UAAA;AAAA,QAAA;AAAA,QAEvB,oBAAC,YAAA,EAAW,YAAwB,WAAsB,OAAO,aAAa;AAAA,QAC9E,oBAAC,sBAAA,EAAqB,YAAwB,WAAsB,OAAO,YAAA,CAAa;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAG9F;ACnHO,MAAM,0BAA0B,oBAAoBC,yBAAqB,EAC7E,WAAW,0BAA0B,EACrC,MAAA;"}
1
+ {"version":3,"file":"index.js","sources":["../../src/preact/adapter.ts","../../src/shared/context/renderer-registry.tsx","../../src/shared/hooks/use-annotation.ts","../../src/shared/components/appearance-image.tsx","../../src/shared/components/annotation-container.tsx","../../src/shared/annotation-bounds.ts","../../src/shared/components/group-selection-box.tsx","../../src/shared/components/types.ts","../../src/shared/components/annotations/ink.tsx","../../src/shared/components/annotations/square.tsx","../../src/shared/components/annotations/circle.tsx","../../src/shared/components/annotations/line.tsx","../../src/shared/components/annotations/polyline.tsx","../../src/shared/components/annotations/polygon.tsx","../../src/shared/components/annotations/text.tsx","../../src/shared/components/annotations/free-text.tsx","../../src/shared/components/render-annotation.tsx","../../src/shared/components/annotations/stamp.tsx","../../src/shared/components/annotations/link.tsx","../../src/shared/components/text-markup/highlight.tsx","../../src/shared/components/text-markup/underline.tsx","../../src/shared/components/text-markup/strikeout.tsx","../../src/shared/components/text-markup/squiggly.tsx","../../src/shared/components/annotations/caret.tsx","../../src/shared/components/built-in-renderers.tsx","../../src/shared/components/annotations.tsx","../../src/shared/components/text-markup.tsx","../../src/shared/components/preview-renderer.tsx","../../src/shared/components/annotation-paint-layer.tsx","../../src/shared/components/annotation-layer.tsx","../../src/shared/index.ts"],"sourcesContent":["import { JSX, Fragment, createContext } from 'preact';\nexport {\n useEffect,\n useRef,\n useState,\n useCallback,\n useMemo,\n useLayoutEffect,\n useContext,\n} from 'preact/hooks';\nexport type { ComponentChildren as ReactNode, JSX } from 'preact';\n\nexport { Fragment, createContext };\nexport type CSSProperties = import('preact').JSX.CSSProperties;\nexport type HTMLAttributes<T = any> = import('preact').JSX.HTMLAttributes<\n T extends EventTarget ? T : never\n>;\nexport type MouseEvent<T = Element> = JSX.TargetedMouseEvent<T extends EventTarget ? T : never>;\nexport type PointerEvent<T = Element> = JSX.TargetedPointerEvent<T extends EventTarget ? T : never>;\nexport type ChangeEvent<T = Element> = JSX.TargetedInputEvent<T extends EventTarget ? T : never>;\nexport type TouchEvent<T = Element> = JSX.TargetedTouchEvent<T extends EventTarget ? T : never>;\nexport type KeyboardEvent<T = Element> = JSX.TargetedKeyboardEvent<\n T extends EventTarget ? T : never\n>;\nexport type FormEvent<T = Element> = JSX.TargetedEvent<T extends EventTarget ? T : never>;\n\nexport { createPortal } from 'preact/compat';\n\nexport const suppressContentEditableWarningProps = {};\n","import {\n createContext,\n useContext,\n useState,\n useCallback,\n useRef,\n useEffect,\n ReactNode,\n} from '@framework';\nimport { BoxedAnnotationRenderer } from '../components/types';\n\n// Separate contexts: register function is stable, renderers list changes\ntype RegisterFn = (entries: BoxedAnnotationRenderer[]) => () => void;\n\nconst RegisterContext = createContext<RegisterFn | null>(null);\nconst RenderersContext = createContext<BoxedAnnotationRenderer[]>([]);\n\nexport function AnnotationRendererProvider({ children }: { children: ReactNode }) {\n const [renderers, setRenderers] = useState<BoxedAnnotationRenderer[]>([]);\n\n // Stable reference - no dependencies\n const register = useCallback((entries: BoxedAnnotationRenderer[]) => {\n setRenderers((prev) => {\n const ids = new Set(entries.map((e) => e.id));\n return [...prev.filter((r) => !ids.has(r.id)), ...entries];\n });\n return () => setRenderers((prev) => prev.filter((r) => !entries.some((e) => e.id === r.id)));\n }, []);\n\n return (\n <RegisterContext.Provider value={register}>\n <RenderersContext.Provider value={renderers}>{children}</RenderersContext.Provider>\n </RegisterContext.Provider>\n );\n}\n\n/**\n * Hook to register annotation renderers. Handles all registration lifecycle internally.\n * Plugin authors just call this with their renderers array.\n */\nexport function useRegisterRenderers(renderers: BoxedAnnotationRenderer[]) {\n const register = useContext(RegisterContext);\n const renderersRef = useRef(renderers);\n\n useEffect(() => {\n if (!register) return;\n return register(renderersRef.current);\n }, [register]);\n}\n\n/**\n * Hook to get all registered renderers (for rendering components).\n */\nexport function useRegisteredRenderers(): BoxedAnnotationRenderer[] {\n return useContext(RenderersContext);\n}\n\n/**\n * Low-level hook if someone needs direct access to register function.\n * Most plugins should use useRegisterRenderers instead.\n */\nexport function useRendererRegistry() {\n return useContext(RegisterContext);\n}\n","import { useCapability, usePlugin } from '@embedpdf/core/@framework';\nimport {\n AnnotationPlugin,\n AnnotationDocumentState,\n initialDocumentState,\n} from '@embedpdf/plugin-annotation';\nimport { useState, useEffect } from '@framework';\n\nexport const useAnnotationPlugin = () => usePlugin<AnnotationPlugin>(AnnotationPlugin.id);\nexport const useAnnotationCapability = () => useCapability<AnnotationPlugin>(AnnotationPlugin.id);\n\n/**\n * Hook for annotation state for a specific document\n * @param documentId Document ID\n */\nexport const useAnnotation = (documentId: string) => {\n const { provides } = useAnnotationCapability();\n const [state, setState] = useState<AnnotationDocumentState>(\n provides?.forDocument(documentId)?.getState() ?? initialDocumentState(),\n );\n\n useEffect(() => {\n if (!provides) return;\n\n const scope = provides.forDocument(documentId);\n\n // Get initial state\n setState(scope.getState());\n\n // Subscribe to state changes\n return scope.onStateChange((newState) => {\n setState(newState);\n });\n }, [provides, documentId]);\n\n return {\n state,\n provides: provides?.forDocument(documentId) ?? null,\n };\n};\n","import type { AnnotationAppearanceImage } from '@embedpdf/models';\nimport { useEffect, useRef, useState, CSSProperties } from '@framework';\n\ninterface AppearanceImageProps {\n appearance: AnnotationAppearanceImage<Blob>;\n style?: CSSProperties;\n}\n\n/**\n * Renders a pre-rendered annotation appearance stream image as an img URL.\n * Purely visual -- pointer events are always disabled; hit-area SVG handles interaction.\n */\nexport function AppearanceImage({ appearance, style }: AppearanceImageProps) {\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n useEffect(() => {\n const url = URL.createObjectURL(appearance.data);\n setImageUrl(url);\n urlRef.current = url;\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n }, [appearance.data]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return imageUrl ? (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n display: 'block',\n pointerEvents: 'none',\n userSelect: 'none',\n ...style,\n }}\n />\n ) : null;\n}\n","import { PdfAnnotationObject, Rect, AnnotationAppearances, CssBlendMode } from '@embedpdf/models';\nimport {\n CounterRotate,\n useDoublePressProps,\n useInteractionHandles,\n} from '@embedpdf/utils/@framework';\nimport { getCounterRotation } from '@embedpdf/utils';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport {\n useState,\n JSX,\n CSSProperties,\n useRef,\n useEffect,\n useMemo,\n useCallback,\n createPortal,\n} from '@framework';\nimport { useDocumentPermissions } from '@embedpdf/core/@framework';\nimport { inferRotationCenterFromRects } from '../../lib/geometry/rotation';\n\nimport { useAnnotationCapability, useAnnotationPlugin } from '../hooks';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n AnnotationInteractionEvent,\n VertexHandleUI,\n RotationHandleUI,\n GroupSelectionMenuRenderFn,\n BoxedAnnotationRenderer,\n SelectionOutline,\n} from './types';\nimport { AppearanceImage } from './appearance-image';\nimport { VertexConfig } from '../types';\n\ninterface AnnotationContainerProps<T extends PdfAnnotationObject> {\n scale: number;\n documentId: string;\n pageIndex: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n trackedAnnotation: TrackedAnnotation<T>;\n children: JSX.Element | ((annotation: T, options: { appearanceActive: boolean }) => JSX.Element);\n isSelected: boolean;\n /** Whether the annotation is in editing mode (e.g., FreeText text editing) */\n isEditing?: boolean;\n /** Whether multiple annotations are selected (container becomes passive) */\n isMultiSelected?: boolean;\n isDraggable: boolean;\n isResizable: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n style?: CSSProperties;\n vertexConfig?: VertexConfig<T>;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n /** @deprecated Use `selectionOutline.offset` instead */\n outlineOffset?: number;\n onDoubleClick?: (event: any) => void;\n onSelect: (event: AnnotationInteractionEvent) => void;\n /** Pre-rendered appearance stream images for AP mode rendering */\n appearance?: AnnotationAppearances<Blob> | null;\n /** Blend mode applied only to the visual content (children + AP image), not to interaction handles */\n blendMode?: CssBlendMode;\n zIndex?: number;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline.color` instead */\n selectionOutlineColor?: string;\n /** Customize the selection outline (color, style, width, offset) */\n selectionOutline?: SelectionOutline;\n customAnnotationRenderer?: CustomAnnotationRenderer<T>;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n groupSelectionOutline?: SelectionOutline;\n /** Passed from parent but not used - destructured to prevent DOM spread */\n annotationRenderers?: BoxedAnnotationRenderer[];\n}\n\n/**\n * AnnotationContainer wraps individual annotations with interaction handles.\n * When isMultiSelected is true, the container becomes passive - drag/resize\n * is handled by the GroupSelectionBox instead.\n */\nexport function AnnotationContainer<T extends PdfAnnotationObject>({\n scale,\n documentId,\n pageIndex,\n rotation,\n pageWidth,\n pageHeight,\n trackedAnnotation,\n children,\n isSelected,\n isEditing = false,\n isMultiSelected = false,\n isDraggable,\n isResizable,\n isRotatable = true,\n lockAspectRatio = false,\n style = {},\n blendMode,\n vertexConfig,\n selectionMenu,\n outlineOffset = 1,\n onDoubleClick,\n onSelect,\n appearance,\n zIndex = 1,\n resizeUI,\n vertexUI,\n rotationUI,\n selectionOutlineColor,\n selectionOutline,\n customAnnotationRenderer,\n // Destructure props that shouldn't be passed to DOM elements\n groupSelectionMenu: _groupSelectionMenu,\n groupSelectionOutline: _groupSelectionOutline,\n annotationRenderers: _annotationRenderers,\n ...props\n}: AnnotationContainerProps<T>): JSX.Element {\n const [preview, setPreview] = useState<T>(trackedAnnotation.object);\n const [liveRotation, setLiveRotation] = useState<number | null>(null);\n const [cursorScreen, setCursorScreen] = useState<{ x: number; y: number } | null>(null);\n const [isHandleHovered, setIsHandleHovered] = useState(false);\n const [gestureActive, setGestureActive] = useState(false);\n const { provides: annotationCapability } = useAnnotationCapability();\n const { plugin } = useAnnotationPlugin();\n const { canModifyAnnotations } = useDocumentPermissions(documentId);\n const gestureBaseRef = useRef<T | null>(null);\n\n // When multi-selected, disable individual drag/resize - GroupSelectionBox handles it\n const effectiveIsDraggable = canModifyAnnotations && isDraggable && !isMultiSelected;\n const effectiveIsResizable = canModifyAnnotations && isResizable && !isMultiSelected;\n const effectiveIsRotatable = canModifyAnnotations && isRotatable && !isMultiSelected;\n // Get scoped API for this document\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const currentObject = preview\n ? { ...trackedAnnotation.object, ...preview }\n : trackedAnnotation.object;\n\n // Annotation flags\n const annoFlags = trackedAnnotation.object.flags ?? [];\n const hasNoZoom = annoFlags.includes('noZoom');\n const hasNoRotate = annoFlags.includes('noRotate');\n\n // visualScale: noZoom annotations maintain constant screen-pixel size regardless of zoom.\n // Sizing uses visualScale; page-space position (left/top) still uses scale.\n const visualScale = hasNoZoom ? 1 : scale;\n\n // effectivePageRotation: noRotate annotations stay visually upright regardless of page rotation.\n // The interaction controller and selection menu use this value.\n const effectivePageRotation = (hasNoRotate ? 0 : rotation) as typeof rotation;\n\n // UI constants\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const VERTEX_COLOR = vertexUI?.color ?? '#007ACC';\n const ROTATION_COLOR = rotationUI?.color ?? 'white';\n const ROTATION_CONNECTOR_COLOR = rotationUI?.connectorColor ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const VERTEX_SIZE = vertexUI?.size ?? 12;\n const ROTATION_SIZE = rotationUI?.size ?? 32;\n const ROTATION_MARGIN = rotationUI?.margin; // undefined = use default (35)\n const ROTATION_ICON_COLOR = rotationUI?.iconColor ?? '#007ACC';\n const SHOW_CONNECTOR = rotationUI?.showConnector ?? false;\n const ROTATION_BORDER_COLOR = rotationUI?.border?.color ?? '#007ACC';\n const ROTATION_BORDER_WIDTH = rotationUI?.border?.width ?? 1;\n const ROTATION_BORDER_STYLE = rotationUI?.border?.style ?? 'solid';\n\n // Outline resolution (new object > deprecated props > defaults)\n const outlineColor = selectionOutline?.color ?? selectionOutlineColor ?? '#007ACC';\n const outlineStyle = selectionOutline?.style ?? 'solid';\n const outlineWidth = selectionOutline?.width ?? 1;\n const outlineOff = selectionOutline?.offset ?? outlineOffset ?? 1;\n\n // Get annotation's current rotation (for simple shapes that store rotation)\n // During drag, use liveRotation if available; otherwise use the annotation's rotation\n const annotationRotation = liveRotation ?? currentObject.rotation ?? 0;\n const rotationDisplay = liveRotation ?? currentObject.rotation ?? 0;\n const normalizedRotationDisplay = Number.isFinite(rotationDisplay)\n ? Math.round(rotationDisplay * 10) / 10\n : 0;\n const rotationActive = liveRotation !== null;\n\n // Store original rect at gesture start (only need rect for delta calculation)\n const gestureBaseRectRef = useRef<Rect | null>(null);\n\n // Handle single-annotation drag/resize (only when NOT multi-selected)\n // Uses the unified plugin API - all preview updates come from event subscriptions!\n const handleUpdate = useCallback(\n (\n event: Parameters<\n NonNullable<Parameters<typeof useInteractionHandles>[0]['controller']['onUpdate']>\n >[0],\n ) => {\n if (!event.transformData?.type || isMultiSelected || !plugin) return;\n\n const { type, changes, metadata } = event.transformData;\n const id = trackedAnnotation.object.id;\n const pageSize = { width: pageWidth, height: pageHeight };\n\n // Gesture start - initialize plugin drag/resize\n if (event.state === 'start') {\n gestureBaseRectRef.current =\n trackedAnnotation.object.unrotatedRect ?? trackedAnnotation.object.rect;\n gestureBaseRef.current = trackedAnnotation.object;\n if (type === 'resize' || type === 'vertex-edit') {\n setGestureActive(true);\n }\n if (type === 'move') {\n plugin.startDrag(documentId, { annotationIds: [id], pageSize });\n } else if (type === 'resize') {\n plugin.startResize(documentId, {\n annotationIds: [id],\n pageSize,\n resizeHandle: metadata?.handle ?? 'se',\n });\n }\n }\n\n // Gesture update - call plugin, preview comes from subscription\n if (changes.rect && gestureBaseRectRef.current) {\n if (type === 'move') {\n const delta = {\n x: changes.rect.origin.x - gestureBaseRectRef.current.origin.x,\n y: changes.rect.origin.y - gestureBaseRectRef.current.origin.y,\n };\n plugin.updateDrag(documentId, delta);\n } else if (type === 'resize') {\n plugin.updateResize(documentId, changes.rect);\n }\n }\n\n // Vertex edit - handle directly (no attached link handling needed)\n if (type === 'vertex-edit' && changes.vertices && vertexConfig) {\n const base = gestureBaseRef.current ?? trackedAnnotation.object;\n const vertexChanges = vertexConfig.transformAnnotation(base, changes.vertices);\n const patched = annotationCapability?.transformAnnotation<T>(base, {\n type,\n changes: vertexChanges as Partial<T>,\n metadata,\n });\n if (patched) {\n setPreview((prev) => ({ ...prev, ...patched }));\n if (event.state === 'end') {\n annotationProvides?.updateAnnotation(pageIndex, id, patched);\n }\n }\n }\n\n if (type === 'rotate') {\n const cursorAngle = metadata?.rotationAngle ?? annotationRotation;\n const cursorPos = metadata?.cursorPosition;\n if (cursorPos) setCursorScreen({ x: cursorPos.clientX, y: cursorPos.clientY });\n if (event.state === 'start') {\n setLiveRotation(cursorAngle);\n plugin.startRotation(documentId, {\n annotationIds: [id],\n cursorAngle,\n rotationCenter: metadata?.rotationCenter,\n });\n } else if (event.state === 'move') {\n setLiveRotation(cursorAngle);\n plugin.updateRotation(documentId, cursorAngle, metadata?.rotationDelta);\n } else if (event.state === 'end') {\n setLiveRotation(null);\n setCursorScreen(null);\n plugin.commitRotation(documentId);\n }\n return;\n }\n\n // Gesture end - commit\n if (event.state === 'end') {\n gestureBaseRectRef.current = null;\n gestureBaseRef.current = null;\n setGestureActive(false);\n if (type === 'move') plugin.commitDrag(documentId);\n else if (type === 'resize') plugin.commitResize(documentId);\n }\n },\n [\n plugin,\n documentId,\n trackedAnnotation.object,\n pageWidth,\n pageHeight,\n pageIndex,\n isMultiSelected,\n vertexConfig,\n annotationCapability,\n annotationProvides,\n annotationRotation,\n ],\n );\n\n // Geometry model:\n // - `rect` is the visible AABB container.\n // - `unrotatedRect` is the local editing frame for resize/vertex operations.\n const explicitUnrotatedRect = currentObject.unrotatedRect;\n const effectiveUnrotatedRect = explicitUnrotatedRect ?? currentObject.rect;\n const rotationPivot =\n explicitUnrotatedRect && annotationRotation !== 0\n ? inferRotationCenterFromRects(effectiveUnrotatedRect, currentObject.rect, annotationRotation)\n : undefined;\n const controllerElement = effectiveUnrotatedRect;\n\n const {\n dragProps,\n vertices,\n resize,\n rotation: rotationHandle,\n } = useInteractionHandles({\n controller: {\n element: controllerElement,\n vertices: vertexConfig?.extractVertices(currentObject),\n constraints: {\n minWidth: 10,\n minHeight: 10,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n annotationRotation: annotationRotation,\n rotationCenter: rotationPivot,\n rotationElement: currentObject.rect,\n scale: scale,\n // Disable interaction handles when multi-selected\n enabled: isSelected && !isMultiSelected,\n onUpdate: handleUpdate,\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOff,\n offsetMode: 'outside',\n includeSides: lockAspectRatio ? false : true,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: VERTEX_SIZE,\n zIndex: zIndex + 2,\n },\n rotationUI: {\n handleSize: ROTATION_SIZE,\n margin: ROTATION_MARGIN,\n zIndex: zIndex + 3,\n showConnector: SHOW_CONNECTOR,\n },\n includeVertices: vertexConfig ? true : false,\n includeRotation: effectiveIsRotatable,\n currentRotation: annotationRotation,\n });\n\n // Wrap onDoubleClick to respect permissions\n const guardedOnDoubleClick = useMemo(() => {\n if (!canModifyAnnotations || !onDoubleClick) return undefined;\n return onDoubleClick;\n }, [canModifyAnnotations, onDoubleClick]);\n\n const doubleProps = useDoublePressProps(guardedOnDoubleClick);\n\n // Sync preview with tracked annotation when it changes\n useEffect(() => {\n setPreview(trackedAnnotation.object);\n }, [trackedAnnotation.object]);\n\n // Subscribe to unified drag changes - plugin sends pre-computed patches!\n // ALL preview updates come through here (primary, attached links, multi-select)\n useEffect(() => {\n if (!plugin) return;\n const id = trackedAnnotation.object.id;\n\n const handleEvent = (event: {\n documentId: string;\n type: string;\n previewPatches?: Record<string, any>;\n }) => {\n if (event.documentId !== documentId) return;\n if (event.type === 'end' || event.type === 'cancel') {\n setLiveRotation(null);\n }\n const patch = event.previewPatches?.[id];\n if (event.type === 'update' && patch) setPreview((prev) => ({ ...prev, ...patch }) as T);\n else if (event.type === 'cancel') setPreview(trackedAnnotation.object);\n };\n\n const unsubs = [\n plugin.onDragChange(handleEvent),\n plugin.onResizeChange(handleEvent),\n plugin.onRotateChange(handleEvent),\n ];\n\n return () => unsubs.forEach((u) => u());\n }, [plugin, documentId, trackedAnnotation.object]);\n\n // Determine if we should show the outline\n // When multi-selected, don't show individual outlines - GroupSelectionBox shows the group outline\n const showOutline = isSelected && !isMultiSelected;\n\n // Three-layer model: outer div (AABB) + inner rotated div (unrotatedRect) + content\n // noZoom: use visualScale (=1) for sizing so the annotation keeps a constant screen-pixel size.\n // noRotate: counter-rotate the outer div so the annotation stays upright on rotated pages.\n const aabbWidth = currentObject.rect.size.width * visualScale;\n const aabbHeight = currentObject.rect.size.height * visualScale;\n const innerWidth = effectiveUnrotatedRect.size.width * visualScale;\n const innerHeight = effectiveUnrotatedRect.size.height * visualScale;\n const usesCustomPivot = Boolean(explicitUnrotatedRect) && annotationRotation !== 0;\n const innerLeft = usesCustomPivot\n ? (effectiveUnrotatedRect.origin.x - currentObject.rect.origin.x) * visualScale\n : (aabbWidth - innerWidth) / 2;\n const innerTop = usesCustomPivot\n ? (effectiveUnrotatedRect.origin.y - currentObject.rect.origin.y) * visualScale\n : (aabbHeight - innerHeight) / 2;\n const innerTransformOrigin =\n usesCustomPivot && rotationPivot\n ? `${(rotationPivot.x - effectiveUnrotatedRect.origin.x) * visualScale}px ${(rotationPivot.y - effectiveUnrotatedRect.origin.y) * visualScale}px`\n : 'center center';\n const centerX = rotationPivot\n ? (rotationPivot.x - currentObject.rect.origin.x) * visualScale\n : aabbWidth / 2;\n const centerY = rotationPivot\n ? (rotationPivot.y - currentObject.rect.origin.y) * visualScale\n : aabbHeight / 2;\n const guideLength = Math.max(300, Math.max(aabbWidth, aabbHeight) + 80);\n\n // noRotate: compute counter-rotation to undo page rotation on this annotation's outer div.\n const counterRot = hasNoRotate\n ? getCounterRotation(\n { origin: { x: 0, y: 0 }, size: { width: aabbWidth, height: aabbHeight } },\n rotation,\n )\n : null;\n\n // For children, override rect to use unrotatedRect so content renders in unrotated space\n const childObject = useMemo(() => {\n if (explicitUnrotatedRect) {\n return { ...currentObject, rect: explicitUnrotatedRect };\n }\n return currentObject;\n }, [currentObject, explicitUnrotatedRect]);\n\n const apActive =\n !!appearance?.normal && !gestureActive && !isEditing && !trackedAnnotation.dictMode;\n\n // Shared positioning for both layers\n const layerBaseStyle = {\n position: 'absolute' as const,\n left: currentObject.rect.origin.x * scale,\n top: currentObject.rect.origin.y * scale,\n width: counterRot ? counterRot.width : aabbWidth,\n height: counterRot ? counterRot.height : aabbHeight,\n pointerEvents: 'none' as const,\n zIndex,\n // noRotate: apply counter-rotation matrix so the annotation stays upright\n ...(counterRot && {\n transform: counterRot.matrix,\n transformOrigin: '0 0',\n }),\n };\n\n // Shared inner div positioning/rotation (used in both layers)\n const innerDivBaseStyle = {\n position: 'absolute' as const,\n left: innerLeft,\n top: innerTop,\n width: innerWidth,\n height: innerHeight,\n transform: annotationRotation !== 0 ? `rotate(${annotationRotation}deg)` : undefined,\n transformOrigin: innerTransformOrigin,\n };\n\n return (\n <div data-no-interaction>\n {/*\n * VISUAL LAYER — has blend mode applied at this level so it blends against the PDF\n * canvas (in the parent stacking context), not against a transparent inner background.\n * Contains only the annotation content and AP image — no interaction handles.\n */}\n <div\n style={{\n ...layerBaseStyle,\n ...(blendMode && { mixBlendMode: blendMode }),\n ...style,\n }}\n >\n {/* Inner div: rotated content — visual only, no drag/interaction */}\n <div style={{ ...innerDivBaseStyle, pointerEvents: 'none' }}>\n {/* Dict content -- always in DOM so hit area handles clicks */}\n {(() => {\n const childrenRender =\n typeof children === 'function'\n ? children(childObject, { appearanceActive: apActive })\n : children;\n const customRender = customAnnotationRenderer?.({\n annotation: childObject,\n children: childrenRender,\n isSelected,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n pageIndex,\n onSelect,\n });\n return customRender ?? childrenRender;\n })()}\n\n {/* AP canvas -- purely visual, never interactive */}\n {appearance?.normal && (\n <AppearanceImage\n appearance={appearance.normal}\n style={{ display: apActive ? 'block' : 'none' }}\n />\n )}\n </div>\n </div>\n\n {/*\n * INTERACTION LAYER — no blend mode so handles render at full fidelity.\n * Same position/size as visual layer; rendered after it in DOM so it sits on top.\n * Contains rotation guides, rotation handle, resize/vertex handles.\n */}\n <div style={layerBaseStyle} {...props}>\n {/* Rotation guide lines - anchored at stable AABB center */}\n {rotationActive && (\n <>\n {/* Fixed snap lines (cross at 0/90/180/270) */}\n <div\n style={{\n position: 'absolute',\n left: centerX - guideLength / 2,\n top: centerY,\n width: guideLength,\n height: 1,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n <div\n style={{\n position: 'absolute',\n left: centerX,\n top: centerY - guideLength / 2,\n width: 1,\n height: guideLength,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n {/* Rotating indicator line showing current angle */}\n <div\n style={{\n position: 'absolute',\n left: centerX - guideLength / 2,\n top: centerY,\n width: guideLength,\n height: 1,\n transformOrigin: 'center center',\n transform: `rotate(${annotationRotation}deg)`,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: 0.8,\n pointerEvents: 'none',\n }}\n />\n </>\n )}\n\n {/* Rotation handle - orbits in AABB space, kept in DOM during rotation */}\n {isSelected &&\n effectiveIsRotatable &&\n rotationHandle &&\n (rotationUI?.component ? (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {rotationUI.component({\n ...rotationHandle.handle,\n backgroundColor: ROTATION_COLOR,\n iconColor: ROTATION_ICON_COLOR,\n connectorStyle: {\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n },\n showConnector: SHOW_CONNECTOR,\n opacity: rotationActive ? 0 : 1,\n border: {\n color: ROTATION_BORDER_COLOR,\n width: ROTATION_BORDER_WIDTH,\n style: ROTATION_BORDER_STYLE,\n },\n })}\n </div>\n ) : (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {/* Connector line */}\n {SHOW_CONNECTOR && (\n <div\n style={{\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n }}\n />\n )}\n {/* Rotation handle */}\n <div\n {...rotationHandle.handle}\n style={{\n ...rotationHandle.handle.style,\n backgroundColor: ROTATION_COLOR,\n border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,\n boxSizing: 'border-box',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'auto',\n opacity: rotationActive ? 0 : 1,\n }}\n >\n {/* Default rotation icon - a curved arrow */}\n <svg\n width={Math.round(ROTATION_SIZE * 0.6)}\n height={Math.round(ROTATION_SIZE * 0.6)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={ROTATION_ICON_COLOR}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\" />\n <path d=\"M21 3v5h-5\" />\n </svg>\n </div>\n </div>\n ))}\n\n {/* Inner div: drag/resize/vertex interaction — no blend mode */}\n <div\n {...(effectiveIsDraggable && isSelected ? dragProps : {})}\n {...doubleProps}\n style={{\n ...innerDivBaseStyle,\n outline: showOutline ? `${outlineWidth}px ${outlineStyle} ${outlineColor}` : 'none',\n outlineOffset: showOutline ? `${outlineOff}px` : '0px',\n pointerEvents: isSelected && !isMultiSelected ? 'auto' : 'none',\n touchAction: 'none',\n cursor: isSelected && effectiveIsDraggable ? 'move' : 'default',\n }}\n >\n {/* Resize handles - rotate with the shape */}\n {isSelected &&\n effectiveIsResizable &&\n !rotationActive &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n\n {/* Vertex handles - rotate with the shape */}\n {isSelected &&\n canModifyAnnotations &&\n !isMultiSelected &&\n !rotationActive &&\n vertices.map(({ key, ...vProps }) =>\n vertexUI?.component ? (\n vertexUI.component({\n key,\n ...vProps,\n backgroundColor: VERTEX_COLOR,\n })\n ) : (\n <div\n key={key}\n {...vProps}\n style={{ ...vProps.style, backgroundColor: VERTEX_COLOR }}\n />\n ),\n )}\n </div>\n </div>\n\n {/* Selection menu - hide when multi-selected or rotating */}\n {selectionMenu && !isMultiSelected && !rotationActive && (\n <CounterRotate\n rect={{\n origin: {\n x: currentObject.rect.origin.x * scale,\n y: currentObject.rect.origin.y * scale,\n },\n size: {\n width: currentObject.rect.size.width * visualScale,\n height: currentObject.rect.size.height * visualScale,\n },\n }}\n rotation={rotation}\n >\n {(counterRotateProps) => {\n // The handle's visual angle = annotationRotation + pageRotation (in degrees).\n // `rotation` is in quarter turns (0-3), so multiply by 90 to get degrees.\n // The menu (suggestTop: false) renders at the visual bottom (180deg).\n // Flip the menu to the top when the handle is in the bottom visual hemisphere\n // to prevent it from overlapping with the rotation handle.\n const effectiveAngle =\n (((annotationRotation + effectivePageRotation * 90) % 360) + 360) % 360;\n const handleNearMenuSide =\n effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;\n\n return selectionMenu({\n ...counterRotateProps,\n context: {\n type: 'annotation',\n annotation: trackedAnnotation,\n pageIndex,\n },\n selected: isSelected,\n placement: {\n suggestTop: handleNearMenuSide,\n },\n });\n }}\n </CounterRotate>\n )}\n\n {/* Cursor-following rotation tooltip - portaled to document.body to escape CSS transform chain */}\n {(rotationActive || isHandleHovered) &&\n cursorScreen &&\n createPortal(\n <div\n style={{\n position: 'fixed',\n left: cursorScreen.x + 16,\n top: cursorScreen.y - 16,\n background: 'rgba(0,0,0,0.8)',\n color: '#fff',\n padding: '4px 8px',\n borderRadius: 4,\n fontSize: 12,\n fontFamily: 'monospace',\n pointerEvents: 'none',\n zIndex: 10000,\n whiteSpace: 'nowrap',\n }}\n >\n {normalizedRotationDisplay.toFixed(0)}°\n </div>,\n document.body,\n )}\n </div>\n );\n}\n","import { Rotation } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\nexport interface ScreenBounds {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nfunction mapCounterRotatePoint(\n x: number,\n y: number,\n width: number,\n height: number,\n rotation: Rotation,\n): { x: number; y: number } {\n switch (rotation) {\n case 1:\n return { x: y, y: height - x };\n case 2:\n return { x: width - x, y: height - y };\n case 3:\n return { x: width - y, y: x };\n default:\n return { x, y };\n }\n}\n\n/**\n * Compute the screen-space bounding box of an annotation, correctly accounting\n * for `noZoom` (constant pixel size regardless of zoom) and `noRotate`\n * (visually upright regardless of page rotation) annotation flags.\n */\nexport function getAnnotationScreenBounds(\n annotation: TrackedAnnotation,\n scale: number,\n rotation: Rotation,\n): ScreenBounds {\n const flags = annotation.object.flags ?? [];\n const hasNoZoom = flags.includes('noZoom');\n const hasNoRotate = flags.includes('noRotate');\n\n const left = annotation.object.rect.origin.x * scale;\n const top = annotation.object.rect.origin.y * scale;\n const width = annotation.object.rect.size.width * (hasNoZoom ? 1 : scale);\n const height = annotation.object.rect.size.height * (hasNoZoom ? 1 : scale);\n\n if (!hasNoRotate || rotation === 0) {\n return {\n left,\n top,\n right: left + width,\n bottom: top + height,\n };\n }\n\n const corners = [\n mapCounterRotatePoint(0, 0, width, height, rotation),\n mapCounterRotatePoint(width, 0, width, height, rotation),\n mapCounterRotatePoint(0, height, width, height, rotation),\n mapCounterRotatePoint(width, height, width, height, rotation),\n ];\n\n let minX = Infinity;\n let minY = Infinity;\n let maxX = -Infinity;\n let maxY = -Infinity;\n\n for (const corner of corners) {\n if (corner.x < minX) minX = corner.x;\n if (corner.y < minY) minY = corner.y;\n if (corner.x > maxX) maxX = corner.x;\n if (corner.y > maxY) maxY = corner.y;\n }\n\n return {\n left: left + minX,\n top: top + minY,\n right: left + maxX,\n bottom: top + maxY,\n };\n}\n","import { Rect, boundingRectOrEmpty, Rotation } from '@embedpdf/models';\nimport { useInteractionHandles, CounterRotate } from '@embedpdf/utils/@framework';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { useState, useMemo, useCallback, useRef, useEffect, createPortal } from '@framework';\nimport { useDocumentPermissions } from '@embedpdf/core/@framework';\n\nimport { useAnnotationPlugin } from '../hooks';\nimport {\n ResizeHandleUI,\n RotationHandleUI,\n GroupSelectionMenuRenderFn,\n SelectionOutline,\n} from './types';\nimport { getAnnotationScreenBounds } from '../annotation-bounds';\n\ninterface GroupSelectionBoxProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n /** All selected annotations on this page */\n selectedAnnotations: TrackedAnnotation[];\n /** Whether the group is draggable (all annotations must be group-draggable) */\n isDraggable: boolean;\n /** Whether the group is resizable (all annotations must be group-resizable) */\n isResizable: boolean;\n /** Whether the group can be rotated */\n isRotatable?: boolean;\n /** Whether to lock aspect ratio during group resize */\n lockAspectRatio?: boolean;\n /** Resize handle UI customization */\n resizeUI?: ResizeHandleUI;\n /** Rotation handle UI customization */\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline.color` instead */\n selectionOutlineColor?: string;\n /** @deprecated Use `selectionOutline.offset` instead */\n outlineOffset?: number;\n /** Customize the selection outline (color, style, width, offset) */\n selectionOutline?: SelectionOutline;\n /** Z-index for the group box */\n zIndex?: number;\n /** Group selection menu render function */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n}\n\n/**\n * GroupSelectionBox renders a bounding box around all selected annotations\n * with drag and resize handles for group manipulation.\n */\nexport function GroupSelectionBox({\n documentId,\n pageIndex,\n scale,\n rotation,\n pageWidth,\n pageHeight,\n selectedAnnotations,\n isDraggable,\n isResizable,\n isRotatable = true,\n lockAspectRatio = false,\n resizeUI,\n rotationUI,\n selectionOutlineColor,\n outlineOffset,\n selectionOutline,\n zIndex = 2,\n groupSelectionMenu,\n}: GroupSelectionBoxProps): JSX.Element | null {\n const { plugin } = useAnnotationPlugin();\n const { canModifyAnnotations } = useDocumentPermissions(documentId);\n const gestureBaseRef = useRef<Rect | null>(null);\n const isDraggingRef = useRef(false);\n const isResizingRef = useRef(false);\n const [liveRotation, setLiveRotation] = useState<number | null>(null);\n const [cursorScreen, setCursorScreen] = useState<{ x: number; y: number } | null>(null);\n const [isHandleHovered, setIsHandleHovered] = useState(false);\n\n // Check permissions before allowing drag/resize\n const effectiveIsDraggable = canModifyAnnotations && isDraggable;\n const effectiveIsResizable = canModifyAnnotations && isResizable;\n const effectiveIsRotatable = canModifyAnnotations && isRotatable;\n\n // Compute the group bounding box from all selected annotations\n const groupBox = useMemo(() => {\n const rects = selectedAnnotations.map((ta) => ta.object.rect);\n return boundingRectOrEmpty(rects);\n }, [selectedAnnotations]);\n\n // Preview state for the group box during drag/resize\n const [previewGroupBox, setPreviewGroupBox] = useState<Rect>(groupBox);\n\n // Sync preview with actual group box when not dragging/resizing\n useEffect(() => {\n if (!isDraggingRef.current && !isResizingRef.current) {\n setPreviewGroupBox(groupBox);\n }\n }, [groupBox]);\n\n useEffect(() => {\n if (!plugin) return;\n const unsubscribe = plugin.onRotateChange((event) => {\n if (event.documentId !== documentId) return;\n if (event.type === 'end' || event.type === 'cancel') {\n setLiveRotation(null);\n }\n });\n return unsubscribe;\n }, [plugin, documentId]);\n\n // Handle both drag and resize updates using unified plugin API\n // The plugin handles attached links automatically and commits all patches\n const handleUpdate = useCallback(\n (\n event: Parameters<\n NonNullable<Parameters<typeof useInteractionHandles>[0]['controller']['onUpdate']>\n >[0],\n ) => {\n if (!event.transformData?.type) return;\n if (!plugin) return;\n\n const transformType = event.transformData.type;\n const isMove = transformType === 'move';\n const isResize = transformType === 'resize';\n\n // Skip drag operations if group is not draggable\n if (isMove && !effectiveIsDraggable) return;\n\n if (event.state === 'start') {\n gestureBaseRef.current = groupBox;\n\n if (isMove) {\n isDraggingRef.current = true;\n // Use unified drag API - plugin handles attached links automatically\n plugin.startDrag(documentId, {\n annotationIds: selectedAnnotations.map((ta) => ta.object.id),\n pageSize: { width: pageWidth, height: pageHeight },\n });\n } else if (isResize) {\n isResizingRef.current = true;\n // Use unified resize API - plugin handles attached links automatically\n plugin.startResize(documentId, {\n annotationIds: selectedAnnotations.map((ta) => ta.object.id),\n pageSize: { width: pageWidth, height: pageHeight },\n resizeHandle: event.transformData.metadata?.handle ?? 'se',\n });\n }\n }\n\n if (transformType === 'rotate') {\n if (!isRotatable) return;\n const ids = selectedAnnotations.map((ta) => ta.object.id);\n const cursorAngle = event.transformData.metadata?.rotationAngle ?? 0;\n const cursorPos = event.transformData.metadata?.cursorPosition;\n if (cursorPos) setCursorScreen({ x: cursorPos.clientX, y: cursorPos.clientY });\n if (event.state === 'start') {\n setLiveRotation(cursorAngle);\n plugin.startRotation(documentId, {\n annotationIds: ids,\n cursorAngle,\n rotationCenter: event.transformData.metadata?.rotationCenter,\n });\n } else if (event.state === 'move') {\n setLiveRotation(cursorAngle);\n plugin.updateRotation(\n documentId,\n cursorAngle,\n event.transformData.metadata?.rotationDelta,\n );\n } else if (event.state === 'end') {\n setLiveRotation(null);\n setCursorScreen(null);\n plugin.commitRotation(documentId);\n }\n return;\n }\n\n const base = gestureBaseRef.current ?? groupBox;\n\n if (isMove && event.transformData.changes.rect) {\n // Calculate delta from original position\n const newRect = event.transformData.changes.rect;\n const rawDelta = {\n x: newRect.origin.x - base.origin.x,\n y: newRect.origin.y - base.origin.y,\n };\n\n // Plugin clamps delta and emits events (attached links receive updates too)\n const clampedDelta = plugin.updateDrag(documentId, rawDelta);\n\n // Update preview group box with clamped delta\n setPreviewGroupBox({\n ...base,\n origin: {\n x: base.origin.x + clampedDelta.x,\n y: base.origin.y + clampedDelta.y,\n },\n });\n } else if (isResize && event.transformData.changes.rect) {\n const newGroupBox = event.transformData.changes.rect;\n\n // Plugin computes rects for all participants and emits events\n plugin.updateResize(documentId, newGroupBox);\n\n // Update preview\n setPreviewGroupBox(newGroupBox);\n }\n\n if (event.state === 'end') {\n gestureBaseRef.current = null;\n\n if (isMove && isDraggingRef.current) {\n isDraggingRef.current = false;\n // Plugin commits all patches (selected + attached links) - no patch building needed!\n plugin.commitDrag(documentId);\n } else if (isResize && isResizingRef.current) {\n isResizingRef.current = false;\n // Plugin commits all patches (selected + attached links) - no patch building needed!\n plugin.commitResize(documentId);\n }\n }\n },\n [\n plugin,\n documentId,\n pageWidth,\n pageHeight,\n groupBox,\n effectiveIsDraggable,\n selectedAnnotations,\n isRotatable,\n ],\n );\n\n const groupRotationDisplay = liveRotation ?? 0;\n const rotationActive = liveRotation !== null;\n const normalizedRotationDisplay = Number.isFinite(groupRotationDisplay)\n ? Math.round(groupRotationDisplay * 10) / 10\n : 0;\n\n // UI constants\n const HANDLE_COLOR = resizeUI?.color ?? '#007ACC';\n const HANDLE_SIZE = resizeUI?.size ?? 12;\n const ROTATION_COLOR = rotationUI?.color ?? 'white';\n const ROTATION_CONNECTOR_COLOR = rotationUI?.connectorColor ?? '#007ACC';\n const ROTATION_SIZE = rotationUI?.size ?? 32;\n const ROTATION_MARGIN = rotationUI?.margin;\n const ROTATION_ICON_COLOR = rotationUI?.iconColor ?? '#007ACC';\n const SHOW_CONNECTOR = rotationUI?.showConnector ?? false;\n const ROTATION_BORDER_COLOR = rotationUI?.border?.color ?? '#007ACC';\n const ROTATION_BORDER_WIDTH = rotationUI?.border?.width ?? 1;\n const ROTATION_BORDER_STYLE = rotationUI?.border?.style ?? 'solid';\n\n // Outline resolution (new object > deprecated props > group defaults)\n const outlineColor = selectionOutline?.color ?? selectionOutlineColor ?? '#007ACC';\n const outlineStyleVal = selectionOutline?.style ?? 'dashed';\n const outlineWidth = selectionOutline?.width ?? 2;\n const outlineOff = selectionOutline?.offset ?? outlineOffset ?? 2;\n\n // Use interaction handles for both drag and resize\n const {\n dragProps,\n resize,\n rotation: rotationHandle,\n } = useInteractionHandles({\n controller: {\n element: previewGroupBox,\n constraints: {\n minWidth: 20,\n minHeight: 20,\n boundingBox: { width: pageWidth, height: pageHeight },\n },\n maintainAspectRatio: lockAspectRatio,\n pageRotation: rotation,\n scale: scale,\n enabled: true,\n onUpdate: handleUpdate,\n },\n resizeUI: {\n handleSize: HANDLE_SIZE,\n spacing: outlineOff,\n offsetMode: 'outside',\n includeSides: !lockAspectRatio,\n zIndex: zIndex + 1,\n },\n vertexUI: {\n vertexSize: 0,\n zIndex: zIndex,\n },\n rotationUI: {\n handleSize: ROTATION_SIZE,\n margin: ROTATION_MARGIN,\n zIndex: zIndex + 2,\n showConnector: SHOW_CONNECTOR,\n },\n includeVertices: false,\n includeRotation: effectiveIsRotatable,\n currentRotation: liveRotation ?? 0,\n });\n\n // Don't render if less than 2 annotations selected\n if (selectedAnnotations.length < 2) {\n return null;\n }\n\n // Compute visual bounds in screen pixels, including mixed noZoom/noRotate selections.\n let visualLeft = Infinity;\n let visualTop = Infinity;\n let visualRight = -Infinity;\n let visualBottom = -Infinity;\n for (const ta of selectedAnnotations) {\n const bounds = getAnnotationScreenBounds(ta, scale, rotation as Rotation);\n visualLeft = Math.min(visualLeft, bounds.left);\n visualTop = Math.min(visualTop, bounds.top);\n visualRight = Math.max(visualRight, bounds.right);\n visualBottom = Math.max(visualBottom, bounds.bottom);\n }\n const initialLogicalLeft = groupBox.origin.x * scale;\n const initialLogicalTop = groupBox.origin.y * scale;\n const initialLogicalRight = (groupBox.origin.x + groupBox.size.width) * scale;\n const initialLogicalBottom = (groupBox.origin.y + groupBox.size.height) * scale;\n const leftCorrection = visualLeft - initialLogicalLeft;\n const topCorrection = visualTop - initialLogicalTop;\n const rightCorrection = visualRight - initialLogicalRight;\n const bottomCorrection = visualBottom - initialLogicalBottom;\n\n const groupBoxLeft = previewGroupBox.origin.x * scale + leftCorrection;\n const groupBoxTop = previewGroupBox.origin.y * scale + topCorrection;\n const groupBoxWidth = previewGroupBox.size.width * scale + (rightCorrection - leftCorrection);\n const groupBoxHeight = previewGroupBox.size.height * scale + (bottomCorrection - topCorrection);\n const groupCenterX = groupBoxWidth / 2;\n const groupCenterY = groupBoxHeight / 2;\n const groupGuideLength = Math.max(300, Math.max(groupBoxWidth, groupBoxHeight) + 80);\n\n return (\n <div data-group-selection-box data-no-interaction>\n {/* Outer div: AABB container - stable center for help lines and rotation handle */}\n <div\n style={{\n position: 'absolute',\n left: groupBoxLeft,\n top: groupBoxTop,\n width: groupBoxWidth,\n height: groupBoxHeight,\n pointerEvents: 'none',\n zIndex,\n }}\n >\n {/* Rotation guide lines - anchored at stable center */}\n {rotationActive && (\n <>\n {/* Fixed snap lines (cross at 0/90/180/270) */}\n <div\n style={{\n position: 'absolute',\n left: groupCenterX - groupGuideLength / 2,\n top: groupCenterY,\n width: groupGuideLength,\n height: 1,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n <div\n style={{\n position: 'absolute',\n left: groupCenterX,\n top: groupCenterY - groupGuideLength / 2,\n width: 1,\n height: groupGuideLength,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.35,\n pointerEvents: 'none',\n }}\n />\n {/* Rotating indicator line showing current angle */}\n <div\n style={{\n position: 'absolute',\n left: groupCenterX - groupGuideLength / 2,\n top: groupCenterY,\n width: groupGuideLength,\n height: 1,\n transformOrigin: 'center center',\n transform: `rotate(${groupRotationDisplay}deg)`,\n backgroundColor: HANDLE_COLOR,\n opacity: 0.8,\n pointerEvents: 'none',\n }}\n />\n </>\n )}\n\n {/* Rotation handle - orbits in AABB space */}\n {effectiveIsRotatable &&\n rotationHandle &&\n (rotationUI?.component ? (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {rotationUI.component({\n ...rotationHandle.handle,\n backgroundColor: ROTATION_COLOR,\n iconColor: ROTATION_ICON_COLOR,\n connectorStyle: {\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n },\n showConnector: SHOW_CONNECTOR,\n opacity: rotationActive ? 0 : 1,\n border: {\n color: ROTATION_BORDER_COLOR,\n width: ROTATION_BORDER_WIDTH,\n style: ROTATION_BORDER_STYLE,\n },\n })}\n </div>\n ) : (\n <div\n onPointerEnter={() => setIsHandleHovered(true)}\n onPointerLeave={() => {\n setIsHandleHovered(false);\n setCursorScreen(null);\n }}\n onPointerMove={(e: any) => {\n if (!rotationActive) setCursorScreen({ x: e.clientX, y: e.clientY });\n }}\n style={{ display: 'contents' }}\n >\n {/* Connector line */}\n {SHOW_CONNECTOR && (\n <div\n style={{\n ...rotationHandle.connector.style,\n backgroundColor: ROTATION_CONNECTOR_COLOR,\n opacity: rotationActive ? 0 : 1,\n }}\n />\n )}\n {/* Rotation handle */}\n <div\n {...rotationHandle.handle}\n style={{\n ...rotationHandle.handle.style,\n backgroundColor: ROTATION_COLOR,\n border: `${ROTATION_BORDER_WIDTH}px ${ROTATION_BORDER_STYLE} ${ROTATION_BORDER_COLOR}`,\n boxSizing: 'border-box',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'auto',\n opacity: rotationActive ? 0 : 1,\n }}\n >\n <svg\n width={Math.round(ROTATION_SIZE * 0.6)}\n height={Math.round(ROTATION_SIZE * 0.6)}\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke={ROTATION_ICON_COLOR}\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n >\n <path d=\"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8\" />\n <path d=\"M21 3v5h-5\" />\n </svg>\n </div>\n </div>\n ))}\n\n {/* Inner div: group content area with outline and resize handles */}\n <div\n {...(effectiveIsDraggable\n ? dragProps\n : {\n onPointerDown: (e: any) => e.stopPropagation(),\n })}\n style={{\n position: 'absolute',\n left: 0,\n top: 0,\n width: groupBoxWidth,\n height: groupBoxHeight,\n outline: rotationActive\n ? 'none'\n : `${outlineWidth}px ${outlineStyleVal} ${outlineColor}`,\n outlineOffset: outlineOff - 1,\n cursor: effectiveIsDraggable ? 'move' : 'default',\n touchAction: 'none',\n pointerEvents: 'auto',\n }}\n >\n {/* Resize handles */}\n {effectiveIsResizable &&\n !rotationActive &&\n resize.map(({ key, ...hProps }) =>\n resizeUI?.component ? (\n resizeUI.component({\n key,\n ...hProps,\n backgroundColor: HANDLE_COLOR,\n })\n ) : (\n <div\n key={key}\n {...hProps}\n style={{ ...hProps.style, backgroundColor: HANDLE_COLOR }}\n />\n ),\n )}\n </div>\n </div>\n\n {/* Cursor-following rotation tooltip */}\n {(rotationActive || isHandleHovered) &&\n cursorScreen &&\n createPortal(\n <div\n style={{\n position: 'fixed',\n left: cursorScreen.x + 16,\n top: cursorScreen.y - 16,\n background: 'rgba(0,0,0,0.8)',\n color: '#fff',\n padding: '4px 8px',\n borderRadius: 4,\n fontSize: 12,\n fontFamily: 'monospace',\n pointerEvents: 'none',\n zIndex: 10000,\n whiteSpace: 'nowrap',\n }}\n >\n {normalizedRotationDisplay.toFixed(0)}°\n </div>,\n document.body,\n )}\n\n {/* Group selection menu */}\n {groupSelectionMenu && !rotationActive && (\n <CounterRotate\n rect={{\n origin: {\n x: groupBoxLeft,\n y: groupBoxTop,\n },\n size: {\n width: groupBoxWidth,\n height: groupBoxHeight,\n },\n }}\n rotation={rotation}\n >\n {(counterRotateProps) => {\n // The handle's visual angle = groupRotationDisplay + pageRotation (in degrees).\n // `rotation` is in quarter turns (0-3), so multiply by 90 to get degrees.\n // The menu (suggestTop: false) renders at the visual bottom (180deg).\n // Flip the menu to the top when the handle is in the bottom visual hemisphere\n // to prevent it from overlapping with the rotation handle.\n const effectiveAngle = (((groupRotationDisplay + rotation * 90) % 360) + 360) % 360;\n const handleNearMenuSide =\n effectiveIsRotatable && effectiveAngle > 90 && effectiveAngle < 270;\n\n return groupSelectionMenu({\n ...counterRotateProps,\n context: {\n type: 'group',\n annotations: selectedAnnotations,\n pageIndex,\n },\n selected: true,\n placement: {\n suggestTop: handleNearMenuSide,\n },\n });\n }}\n </CounterRotate>\n )}\n </div>\n );\n}\n","import { PdfAnnotationObject, PdfBlendMode } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport {\n HandleElementProps,\n SelectionMenuPropsBase,\n SelectionMenuRenderFn,\n} from '@embedpdf/utils/@framework';\nimport { JSX, CSSProperties, MouseEvent } from '@framework';\nimport { VertexConfig } from '../types';\n\nexport type ResizeDirection = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'none';\n\nexport interface AnnotationSelectionContext {\n type: 'annotation';\n annotation: TrackedAnnotation;\n pageIndex: number;\n}\n\nexport type AnnotationSelectionMenuProps = SelectionMenuPropsBase<AnnotationSelectionContext>;\nexport type AnnotationSelectionMenuRenderFn = SelectionMenuRenderFn<AnnotationSelectionContext>;\n\nexport interface GroupSelectionContext {\n type: 'group';\n annotations: TrackedAnnotation[];\n pageIndex: number;\n}\n\nexport type GroupSelectionMenuProps = SelectionMenuPropsBase<GroupSelectionContext>;\nexport type GroupSelectionMenuRenderFn = SelectionMenuRenderFn<GroupSelectionContext>;\n\nexport type HandleProps = HandleElementProps & {\n backgroundColor?: string;\n};\n\n/** UI customization for resize handles */\nexport interface ResizeHandleUI {\n /** Handle size in CSS px (default: 12) */\n size?: number;\n /** Default background color for the handle (used by default renderer) */\n color?: string;\n /** Custom renderer for each handle (overrides default) */\n component?: (p: HandleProps) => JSX.Element;\n}\n\n/** UI customization for vertex handles */\nexport interface VertexHandleUI {\n /** Handle size in CSS px (default: 12) */\n size?: number;\n /** Default background color for the handle (used by default renderer) */\n color?: string;\n /** Custom renderer for each vertex (overrides default) */\n component?: (p: HandleProps) => JSX.Element;\n}\n\n/** Props for the rotation handle component */\nexport interface RotationHandleComponentProps extends HandleProps {\n /** Props for the connector line element */\n connectorStyle?: CSSProperties;\n /** Whether to show the connector line */\n showConnector?: boolean;\n /** Color for the icon inside the handle (default: '#007ACC') */\n iconColor?: string;\n /** Resolved border configuration */\n border?: RotationHandleBorder;\n}\n\nexport type BorderStyle = 'solid' | 'dashed' | 'dotted';\n\nexport interface SelectionOutline {\n /** Outline color (default: '#007ACC') */\n color?: string;\n /** Outline style (default: 'solid' for single, 'dashed' for group) */\n style?: BorderStyle;\n /** Outline width in px (default: 1 for single, 2 for group) */\n width?: number;\n /** Outline offset in px (default: 1 for single, 2 for group) */\n offset?: number;\n}\n\n/** Border configuration for the rotation handle */\nexport interface RotationHandleBorder {\n /** Border color (default: '#007ACC') */\n color?: string;\n /** Border style (default: 'solid') */\n style?: BorderStyle;\n /** Border width in px (default: 1) */\n width?: number;\n}\n\n/** UI customization for rotation handle */\nexport interface RotationHandleUI {\n /** Handle size in CSS px (default: 16) */\n size?: number;\n /** Gap in CSS px between the bounding box edge and the rotation handle center (default: 20) */\n margin?: number;\n /** Default background color for the handle (default: 'white') */\n color?: string;\n /** Color for the connector line (default: '#007ACC') */\n connectorColor?: string;\n /** Whether to show the connector line (default: true) */\n showConnector?: boolean;\n /** Color for the icon inside the handle (default: '#007ACC') */\n iconColor?: string;\n /** Border configuration for the handle */\n border?: RotationHandleBorder;\n /** Custom renderer for the rotation handle (overrides default) */\n component?: (p: RotationHandleComponentProps) => JSX.Element;\n}\n\n/**\n * Props for the custom annotation renderer\n */\nexport interface CustomAnnotationRendererProps<T extends PdfAnnotationObject> {\n annotation: T;\n children: JSX.Element;\n isSelected: boolean;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n pageIndex: number;\n onSelect: (event: any) => void;\n}\n\n/**\n * Custom renderer for an annotation\n */\nexport type CustomAnnotationRenderer<T extends PdfAnnotationObject> = (\n props: CustomAnnotationRendererProps<T>,\n) => JSX.Element | null;\n\n/**\n * Properly typed event for annotation interactions (click, select, etc.)\n */\nexport type AnnotationInteractionEvent = MouseEvent<Element>;\n\n/**\n * Props for an annotation renderer entry\n */\nexport interface AnnotationRendererProps<T extends PdfAnnotationObject = PdfAnnotationObject> {\n annotation: TrackedAnnotation<T>;\n currentObject: T;\n isSelected: boolean;\n isEditing: boolean;\n scale: number;\n pageIndex: number;\n documentId: string;\n onClick: (e: AnnotationInteractionEvent) => void;\n /** When true, AP canvas provides the visual; component should only render hit area */\n appearanceActive: boolean;\n}\n\n/**\n * Helpers passed to selectOverride for custom selection behavior.\n */\nexport interface SelectOverrideHelpers {\n defaultSelect: (e: AnnotationInteractionEvent, annotation: TrackedAnnotation) => void;\n selectAnnotation: (pageIndex: number, id: string) => void;\n clearSelection: () => void;\n allAnnotations: TrackedAnnotation[];\n pageIndex: number;\n}\n\n/**\n * Entry for a custom annotation renderer that handles specific annotation types.\n * This allows external plugins to provide their own rendering for annotation subtypes.\n * Used at definition time for type safety.\n */\nexport interface AnnotationRendererEntry<T extends PdfAnnotationObject = PdfAnnotationObject> {\n /** Unique identifier for this renderer (usually matches tool id) */\n id: string;\n\n /** Returns true if this renderer should handle the annotation */\n matches: (annotation: PdfAnnotationObject) => annotation is T;\n\n /** The component to render the annotation */\n render: (props: AnnotationRendererProps<T>) => JSX.Element;\n\n /** Vertex configuration for annotations with draggable vertices (line, polyline, polygon) */\n vertexConfig?: VertexConfig<T>;\n\n /** z-index for the annotation container (default: 1, text markup uses 0) */\n zIndex?: number;\n\n /** Default blend mode for this annotation type (used when annotation.blendMode is not set) */\n defaultBlendMode?: PdfBlendMode;\n\n /** Style applied to the annotation container — overrides the default blend-mode style. */\n containerStyle?: (annotation: T) => CSSProperties;\n\n /** Type-specific interaction fallbacks used when the tool doesn't define a property */\n interactionDefaults?: {\n isDraggable?: boolean;\n isResizable?: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n };\n\n /** Whether this annotation type uses AP rendering before editing (default: true) */\n useAppearanceStream?: boolean;\n\n /** Override resolved isDraggable (e.g., FreeText disables drag while editing) */\n isDraggable?: (toolDraggable: boolean, context: { isEditing: boolean }) => boolean;\n\n /** Handle double-click on the annotation container */\n onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;\n\n /** Override default selection behavior (e.g., Link IRT parent resolution) */\n selectOverride?: (\n e: AnnotationInteractionEvent,\n annotation: TrackedAnnotation<T>,\n helpers: SelectOverrideHelpers,\n ) => void;\n\n /** Return true to hide the selection menu for this annotation */\n hideSelectionMenu?: (annotation: T) => boolean;\n}\n\n/**\n * Boxed renderer that encapsulates type safety internally.\n * The generic is erased -- this is what the registry actually stores.\n */\nexport interface BoxedAnnotationRenderer {\n id: string;\n matches: (annotation: PdfAnnotationObject) => boolean;\n render: (props: AnnotationRendererProps) => JSX.Element;\n vertexConfig?: VertexConfig<PdfAnnotationObject>;\n zIndex?: number;\n defaultBlendMode?: PdfBlendMode;\n /** Style applied to the annotation container — overrides the default blend-mode style. */\n containerStyle?: (annotation: PdfAnnotationObject) => CSSProperties;\n interactionDefaults?: {\n isDraggable?: boolean;\n isResizable?: boolean;\n isRotatable?: boolean;\n lockAspectRatio?: boolean;\n };\n useAppearanceStream?: boolean;\n isDraggable?: (toolDraggable: boolean, context: { isEditing: boolean }) => boolean;\n onDoubleClick?: (annotationId: string, setEditingId: (id: string) => void) => void;\n selectOverride?: (\n e: AnnotationInteractionEvent,\n annotation: TrackedAnnotation,\n helpers: SelectOverrideHelpers,\n ) => void;\n hideSelectionMenu?: (annotation: PdfAnnotationObject) => boolean;\n}\n\n/**\n * Creates a boxed renderer from a typed entry.\n * Type safety is enforced at definition time, then erased for storage.\n */\nexport function createRenderer<T extends PdfAnnotationObject>(\n entry: AnnotationRendererEntry<T>,\n): BoxedAnnotationRenderer {\n return {\n id: entry.id,\n matches: (annotation) => entry.matches(annotation),\n render: (props) => entry.render(props as AnnotationRendererProps<T>),\n vertexConfig: entry.vertexConfig as VertexConfig<PdfAnnotationObject> | undefined,\n zIndex: entry.zIndex,\n defaultBlendMode: entry.defaultBlendMode,\n containerStyle: entry.containerStyle as\n | ((annotation: PdfAnnotationObject) => CSSProperties)\n | undefined,\n interactionDefaults: entry.interactionDefaults,\n useAppearanceStream: entry.useAppearanceStream,\n isDraggable: entry.isDraggable,\n onDoubleClick: entry.onDoubleClick,\n selectOverride: entry.selectOverride as BoxedAnnotationRenderer['selectOverride'],\n hideSelectionMenu: entry.hideSelectionMenu as\n | ((annotation: PdfAnnotationObject) => boolean)\n | undefined,\n };\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfInkListObject, Rect } from '@embedpdf/models';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface InkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke color */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Line width in PDF units */\n strokeWidth: number;\n /** Array of strokes — exactly as in your JSON */\n inkList: PdfInkListObject[];\n /** Bounding box of the whole annotation */\n rect: Rect;\n /** Page zoom factor */\n scale: number;\n /** Callback for when the annotation is clicked */\n onClick?: (e: MouseEvent<SVGPathElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Ink annotation (free-hand drawing) as SVG.\n */\nexport function Ink({\n isSelected,\n strokeColor,\n opacity = 1,\n strokeWidth,\n inkList,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n}: InkProps): JSX.Element {\n const resolvedColor = strokeColor ?? '#000000';\n\n const paths = useMemo(() => {\n return inkList.map(({ points }) => {\n let d = '';\n points.forEach(({ x, y }, i) => {\n const lx = x - rect.origin.x;\n const ly = y - rect.origin.y;\n d += (i === 0 ? 'M' : 'L') + lx + ' ' + ly + ' ';\n });\n return d.trim();\n });\n }, [inkList, rect]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n {paths.map((d, i) => (\n <path\n key={`hit-${i}`}\n d={d}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive &&\n paths.map((d, i) => (\n <path\n key={`vis-${i}`}\n d={d}\n fill=\"none\"\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: resolvedColor,\n strokeWidth: strokeWidth,\n strokeLinecap: 'round',\n strokeLinejoin: 'round',\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, PdfRectDifferences, Rect } from '@embedpdf/models';\nimport { generateCloudyRectanglePath } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface SquareProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium's black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n /** Cloudy border intensity (0 = no cloud, typically 1 or 2) */\n cloudyBorderIntensity?: number;\n /** Rectangle differences – inset from Rect to drawn area */\n rectangleDifferences?: PdfRectDifferences;\n}\n\n/**\n * Renders a PDF Square annotation (rectangle) as SVG.\n */\nexport function Square({\n isSelected,\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n cloudyBorderIntensity,\n rectangleDifferences,\n}: SquareProps): JSX.Element {\n const isCloudy = (cloudyBorderIntensity ?? 0) > 0;\n\n const { width, height, x, y } = useMemo(() => {\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: innerW,\n height: innerH,\n x: strokeWidth / 2,\n y: strokeWidth / 2,\n };\n }, [rect, strokeWidth]);\n\n const cloudyPath = useMemo(() => {\n if (!isCloudy) return null;\n return generateCloudyRectanglePath(\n { x: 0, y: 0, width: rect.size.width, height: rect.size.height },\n rectangleDifferences,\n cloudyBorderIntensity!,\n strokeWidth,\n );\n }, [isCloudy, rect, rectangleDifferences, cloudyBorderIntensity, strokeWidth]);\n\n const svgWidth = rect.size.width * scale;\n const svgHeight = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n overflow=\"visible\"\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n {isCloudy && cloudyPath ? (\n <path\n d={cloudyPath.path}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n ) : (\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n )}\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive &&\n (isCloudy && cloudyPath ? (\n <path\n d={cloudyPath.path}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n strokeLinejoin: 'round',\n }}\n />\n ) : (\n <rect\n x={x}\n y={y}\n width={width}\n height={height}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, PdfRectDifferences, Rect } from '@embedpdf/models';\nimport { generateCloudyEllipsePath } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface CircleProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Fill colour – defaults to PDFium's black if omitted */\n color?: string;\n /** Stroke colour – defaults to same as fill when omitted */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke type – defaults to solid when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – defaults to undefined when omitted */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n /** Cloudy border intensity (0 = no cloud, typically 1 or 2) */\n cloudyBorderIntensity?: number;\n /** Rectangle differences – inset from Rect to drawn area */\n rectangleDifferences?: PdfRectDifferences;\n}\n\n/**\n * Renders a PDF Circle annotation (ellipse) as SVG.\n */\nexport function Circle({\n color = '#000000',\n strokeColor,\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n scale,\n onClick,\n isSelected,\n appearanceActive = false,\n cloudyBorderIntensity,\n rectangleDifferences,\n}: CircleProps): JSX.Element {\n const isCloudy = (cloudyBorderIntensity ?? 0) > 0;\n\n const { width, height, cx, cy, rx, ry } = useMemo(() => {\n const outerW = rect.size.width;\n const outerH = rect.size.height;\n const innerW = Math.max(outerW - strokeWidth, 0);\n const innerH = Math.max(outerH - strokeWidth, 0);\n\n return {\n width: outerW,\n height: outerH,\n cx: strokeWidth / 2 + innerW / 2,\n cy: strokeWidth / 2 + innerH / 2,\n rx: innerW / 2,\n ry: innerH / 2,\n };\n }, [rect, strokeWidth]);\n\n const cloudyPath = useMemo(() => {\n if (!isCloudy) return null;\n return generateCloudyEllipsePath(\n { x: 0, y: 0, width: rect.size.width, height: rect.size.height },\n rectangleDifferences,\n cloudyBorderIntensity!,\n strokeWidth,\n );\n }, [isCloudy, rect, rectangleDifferences, cloudyBorderIntensity, strokeWidth]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n overflow=\"visible\"\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n {isCloudy && cloudyPath ? (\n <path\n d={cloudyPath.path}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n ) : (\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n }}\n />\n )}\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive &&\n (isCloudy && cloudyPath ? (\n <path\n d={cloudyPath.path}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n strokeLinejoin: 'round',\n }}\n />\n ) : (\n <ellipse\n cx={cx}\n cy={cy}\n rx={rx}\n ry={ry}\n fill={color}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n ))}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect, LinePoints, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface LineProps {\n /** interior colour */\n color?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Stroke width in PDF units */\n strokeWidth: number;\n /** Stroke colour (falls back to PDFium default black) */\n strokeColor?: string;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n /** Bounding box of the annotation */\n rect: Rect;\n /** Line start / end points (page units) */\n linePoints: LinePoints;\n /** Line endings (eg. OpenArrow / Butt) */\n lineEndings?: LineEndings;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Line annotation as SVG (with arrow/butt endings).\n */\nexport function Line({\n color = 'transparent',\n opacity = 1,\n strokeWidth,\n strokeColor = '#000000',\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n rect,\n linePoints,\n lineEndings,\n scale,\n onClick,\n isSelected,\n appearanceActive = false,\n}: LineProps): JSX.Element {\n const { x1, y1, x2, y2 } = useMemo(() => {\n return {\n x1: linePoints.start.x - rect.origin.x,\n y1: linePoints.start.y - rect.origin.y,\n x2: linePoints.end.x - rect.origin.x,\n y2: linePoints.end.y - rect.origin.y,\n };\n }, [linePoints, rect]);\n\n const endings = useMemo(() => {\n const angle = Math.atan2(y2 - y1, x2 - x1);\n return {\n start: patching.createEnding(lineEndings?.start, strokeWidth, angle + Math.PI, x1, y1),\n end: patching.createEnding(lineEndings?.end, strokeWidth, angle, x2, y2),\n };\n }, [lineEndings, strokeWidth, x1, y1, x2, y2]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n <line\n x1={x1}\n y1={y1}\n x2={x2}\n y2={y2}\n opacity={opacity}\n style={{\n pointerEvents: 'none',\n stroke: strokeColor,\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </>\n )}\n </svg>\n );\n}\n","import { MouseEvent, useMemo } from '@framework';\nimport { Rect, Position, LineEndings, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { patching } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface PolylineProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n /** Stroke style */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array */\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Optional start & end endings */\n lineEndings?: LineEndings;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\nexport function Polyline({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n lineEndings,\n appearanceActive = false,\n}: PolylineProps): JSX.Element {\n const localPts = useMemo(\n () => vertices.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [vertices, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n return (\n `M ${first.x} ${first.y} ` +\n rest\n .map((p) => `L ${p.x} ${p.y} `)\n .join('')\n .trim()\n );\n }, [localPts]);\n\n const endings = useMemo(() => {\n if (localPts.length < 2) return { start: null, end: null };\n const toAngle = (a: Position, b: Position) => Math.atan2(b.y - a.y, b.x - a.x);\n\n const startRad = toAngle(localPts[0], localPts[1]);\n const endRad = toAngle(localPts[localPts.length - 2], localPts[localPts.length - 1]);\n\n const start = patching.createEnding(\n lineEndings?.start,\n strokeWidth,\n startRad + Math.PI,\n localPts[0].x,\n localPts[0].y,\n );\n const end = patching.createEnding(\n lineEndings?.end,\n strokeWidth,\n endRad,\n localPts[localPts.length - 1].x,\n localPts[localPts.length - 1].y,\n );\n return { start, end };\n }, [localPts, lineEndings, strokeWidth]);\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <path\n d={pathData}\n fill=\"none\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visibleStroke',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.start.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : endings.end.filled ? 'visible' : 'visibleStroke',\n strokeLinecap: 'butt',\n }}\n />\n )}\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n <path\n d={pathData}\n opacity={opacity}\n style={{\n fill: 'none',\n stroke: strokeColor ?? color,\n strokeWidth,\n pointerEvents: 'none',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {endings.start && (\n <path\n d={endings.start.d}\n transform={endings.start.transform}\n stroke={strokeColor}\n fill={endings.start.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n {endings.end && (\n <path\n d={endings.end.d}\n transform={endings.end.transform}\n stroke={strokeColor}\n fill={endings.end.filled ? color : 'none'}\n style={{\n pointerEvents: 'none',\n strokeWidth,\n strokeLinecap: 'butt',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n )}\n </>\n )}\n </svg>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect, Position, PdfAnnotationBorderStyle } from '@embedpdf/models';\nimport { generateCloudyPolygonPath } from '@embedpdf/plugin-annotation';\n\nconst MIN_HIT_AREA_SCREEN_PX = 20;\n\ninterface PolygonProps {\n rect: Rect;\n vertices: Position[];\n color?: string;\n strokeColor?: string;\n opacity?: number;\n strokeWidth: number;\n strokeStyle?: PdfAnnotationBorderStyle;\n strokeDashArray?: number[];\n scale: number;\n isSelected: boolean;\n onClick?: (e: MouseEvent<SVGElement>) => void;\n currentVertex?: Position;\n handleSize?: number;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n /** Cloudy border intensity (0 = no cloud, typically 1 or 2) */\n cloudyBorderIntensity?: number;\n}\n\nexport function Polygon({\n rect,\n vertices,\n color = 'transparent',\n strokeColor = '#000000',\n opacity = 1,\n strokeWidth,\n strokeStyle = PdfAnnotationBorderStyle.SOLID,\n strokeDashArray,\n scale,\n isSelected,\n onClick,\n currentVertex,\n handleSize = 14,\n appearanceActive = false,\n cloudyBorderIntensity,\n}: PolygonProps): JSX.Element {\n const isCloudy = (cloudyBorderIntensity ?? 0) > 0;\n const allPoints = currentVertex ? [...vertices, currentVertex] : vertices;\n\n const localPts = useMemo(\n () => allPoints.map(({ x, y }) => ({ x: x - rect.origin.x, y: y - rect.origin.y })),\n [allPoints, rect],\n );\n\n const pathData = useMemo(() => {\n if (!localPts.length) return '';\n const [first, ...rest] = localPts;\n const isPreview = !!currentVertex;\n return (\n `M ${first.x} ${first.y} ` +\n rest.map((p) => `L ${p.x} ${p.y}`).join(' ') +\n (isPreview ? '' : ' Z')\n ).trim();\n }, [localPts, currentVertex]);\n\n const cloudyPath = useMemo(() => {\n if (!isCloudy || allPoints.length < 3) return null;\n return generateCloudyPolygonPath(allPoints, rect.origin, cloudyBorderIntensity!, strokeWidth);\n }, [isCloudy, allPoints, rect.origin, cloudyBorderIntensity, strokeWidth]);\n\n const isPreviewing = currentVertex && vertices.length > 0;\n\n const width = rect.size.width * scale;\n const height = rect.size.height * scale;\n const hitStrokeWidth = Math.max(strokeWidth, MIN_HIT_AREA_SCREEN_PX / scale);\n\n return (\n <svg\n style={{\n position: 'absolute',\n width,\n height,\n pointerEvents: 'none',\n zIndex: 2,\n overflow: 'visible',\n }}\n width={width}\n height={height}\n viewBox={`0 0 ${rect.size.width} ${rect.size.height}`}\n >\n {/* Hit area -- always rendered, transparent, wider stroke for mobile */}\n <path\n d={isCloudy && cloudyPath ? cloudyPath.path : pathData}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={hitStrokeWidth}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected\n ? 'none'\n : color === 'transparent'\n ? 'visibleStroke'\n : 'visible',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n }}\n />\n\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <>\n {isCloudy && cloudyPath ? (\n <path\n d={cloudyPath.path}\n opacity={opacity}\n style={{\n fill: color,\n stroke: strokeColor ?? color,\n strokeWidth,\n pointerEvents: 'none',\n strokeLinejoin: 'round',\n }}\n />\n ) : (\n <>\n <path\n d={pathData}\n opacity={opacity}\n style={{\n fill: currentVertex ? 'none' : color,\n stroke: strokeColor ?? color,\n strokeWidth,\n pointerEvents: 'none',\n strokeLinecap: 'butt',\n strokeLinejoin: 'miter',\n ...(strokeStyle === PdfAnnotationBorderStyle.DASHED && {\n strokeDasharray: strokeDashArray?.join(','),\n }),\n }}\n />\n {isPreviewing && vertices.length > 1 && (\n <path\n d={`M ${localPts[localPts.length - 1].x} ${localPts[localPts.length - 1].y} L ${localPts[0].x} ${localPts[0].y}`}\n fill=\"none\"\n style={{\n stroke: strokeColor,\n strokeWidth,\n strokeDasharray: '4,4',\n opacity: 0.7,\n pointerEvents: 'none',\n }}\n />\n )}\n {isPreviewing && vertices.length >= 2 && (\n <rect\n x={localPts[0].x - handleSize / scale / 2}\n y={localPts[0].y - handleSize / scale / 2}\n width={handleSize / scale}\n height={handleSize / scale}\n fill={strokeColor}\n opacity={0.4}\n stroke={strokeColor}\n strokeWidth={strokeWidth / 2}\n style={{ pointerEvents: 'none' }}\n />\n )}\n </>\n )}\n </>\n )}\n </svg>\n );\n}\n","import { getContrastStrokeColor } from '@embedpdf/models';\nimport { MouseEvent } from '@framework';\n\ninterface TextProps {\n isSelected: boolean;\n color?: string;\n opacity?: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a fallback sticky-note icon for PDF Text annotations when no\n * appearance stream image is available.\n */\nexport function Text({\n isSelected,\n color = '#facc15',\n opacity = 1,\n onClick,\n appearanceActive = false,\n}: TextProps): JSX.Element {\n const lineColor = getContrastStrokeColor(color);\n\n return (\n <div\n style={{\n position: 'absolute',\n inset: 0,\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: isSelected ? 'move' : 'pointer',\n }}\n onPointerDown={onClick}\n >\n {!appearanceActive && (\n <svg\n style={{\n position: 'absolute',\n inset: 0,\n pointerEvents: 'none',\n }}\n viewBox=\"0 0 20 20\"\n width=\"100%\"\n height=\"100%\"\n >\n <path\n d=\"M 0.5 15.5 L 0.5 0.5 L 19.5 0.5 L 19.5 15.5 L 8.5 15.5 L 6.5 19.5 L 4.5 15.5 Z\"\n fill={color}\n opacity={opacity}\n stroke={lineColor}\n strokeWidth=\"1\"\n strokeLinejoin=\"miter\"\n />\n <line x1=\"2.5\" y1=\"4.25\" x2=\"17.5\" y2=\"4.25\" stroke={lineColor} strokeWidth=\"1\" />\n <line x1=\"2.5\" y1=\"8\" x2=\"17.5\" y2=\"8\" stroke={lineColor} strokeWidth=\"1\" />\n <line x1=\"2.5\" y1=\"11.75\" x2=\"17.5\" y2=\"11.75\" stroke={lineColor} strokeWidth=\"1\" />\n </svg>\n )}\n </div>\n );\n}\n","import {\n MouseEvent,\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n suppressContentEditableWarningProps,\n} from '@framework';\nimport {\n PdfFreeTextAnnoObject,\n PdfVerticalAlignment,\n standardFontCssProperties,\n textAlignmentToCss,\n} from '@embedpdf/models';\nimport { useAnnotationCapability } from '../..';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\n\ninterface FreeTextProps {\n documentId: string;\n isSelected: boolean;\n isEditing: boolean;\n annotation: TrackedAnnotation<PdfFreeTextAnnoObject>;\n pageIndex: number;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n onDoubleClick?: (event: MouseEvent<HTMLDivElement>) => void;\n /** When true, AP canvas provides the visual; hide text content */\n appearanceActive?: boolean;\n}\n\nexport function FreeText({\n documentId,\n isSelected,\n isEditing,\n annotation,\n pageIndex,\n scale,\n onClick,\n appearanceActive = false,\n}: FreeTextProps) {\n const editorRef = useRef<HTMLSpanElement>(null);\n const editingRef = useRef(false);\n const { provides: annotationCapability } = useAnnotationCapability();\n const annotationProvides = annotationCapability?.forDocument(documentId) ?? null;\n const [isIOS, setIsIOS] = useState(false);\n\n useEffect(() => {\n if (isEditing && editorRef.current) {\n editingRef.current = true;\n const editor = editorRef.current;\n editor.focus();\n\n const selection = window.getSelection();\n if (selection) {\n const range = document.createRange();\n range.selectNodeContents(editor);\n range.collapse(false);\n selection.removeAllRanges();\n selection.addRange(range);\n }\n }\n }, [isEditing]);\n\n useLayoutEffect(() => {\n try {\n const nav = navigator as any;\n const ios =\n /iPad|iPhone|iPod/.test(navigator.userAgent) ||\n (navigator.platform === 'MacIntel' && nav?.maxTouchPoints > 1);\n setIsIOS(ios);\n } catch {\n setIsIOS(false);\n }\n }, []);\n\n const handleBlur = () => {\n if (!editingRef.current) return;\n editingRef.current = false;\n if (!annotationProvides) return;\n if (!editorRef.current) return;\n annotationProvides.updateAnnotation(pageIndex, annotation.object.id, {\n contents: editorRef.current.innerText,\n });\n };\n\n // iOS zoom prevention: keep focused font-size >= 16px, visually scale down if needed.\n const computedFontPx = annotation.object.fontSize * scale;\n const MIN_IOS_FOCUS_FONT_PX = 16;\n const needsComp =\n isIOS && isEditing && computedFontPx > 0 && computedFontPx < MIN_IOS_FOCUS_FONT_PX;\n const adjustedFontPx = needsComp ? MIN_IOS_FOCUS_FONT_PX : computedFontPx;\n const scaleComp = needsComp ? computedFontPx / MIN_IOS_FOCUS_FONT_PX : 1;\n const invScalePercent = needsComp ? 100 / scaleComp : 100;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: annotation.object.rect.size.width * scale,\n height: annotation.object.rect.size.height * scale,\n cursor: isSelected && !isEditing ? 'move' : 'default',\n pointerEvents: isSelected && !isEditing ? 'none' : 'auto',\n zIndex: 2,\n opacity: appearanceActive ? 0 : 1,\n }}\n onPointerDown={onClick}\n >\n <span\n ref={editorRef}\n onBlur={handleBlur}\n tabIndex={0}\n style={{\n color: annotation.object.fontColor,\n fontSize: adjustedFontPx,\n ...standardFontCssProperties(annotation.object.fontFamily),\n textAlign: textAlignmentToCss(annotation.object.textAlign),\n flexDirection: 'column',\n justifyContent:\n annotation.object.verticalAlign === PdfVerticalAlignment.Top\n ? 'flex-start'\n : annotation.object.verticalAlign === PdfVerticalAlignment.Middle\n ? 'center'\n : 'flex-end',\n display: 'flex',\n backgroundColor: annotation.object.color ?? annotation.object.backgroundColor,\n opacity: annotation.object.opacity,\n width: needsComp ? `${invScalePercent}%` : '100%',\n height: needsComp ? `${invScalePercent}%` : '100%',\n lineHeight: '1.18',\n overflow: 'hidden',\n cursor: isEditing ? 'text' : 'pointer',\n outline: 'none',\n transform: needsComp ? `scale(${scaleComp})` : undefined,\n transformOrigin: 'top left',\n }}\n contentEditable={isEditing}\n {...suppressContentEditableWarningProps}\n >\n {annotation.object.contents}\n </span>\n </div>\n );\n}\n","import { Fragment, HTMLAttributes, CSSProperties, useEffect, useRef, useState } from '@framework';\nimport { AppearanceMode, ignore, PdfAnnotationObject, PdfErrorCode } from '@embedpdf/models';\n\nimport { useAnnotationCapability } from '../hooks/use-annotation';\n\ntype RenderAnnotationProps = Omit<HTMLAttributes<HTMLImageElement>, 'style'> & {\n documentId: string;\n pageIndex: number;\n annotation: PdfAnnotationObject;\n scaleFactor?: number;\n dpr?: number;\n style?: CSSProperties;\n unrotated?: boolean;\n};\n\nexport function RenderAnnotation({\n documentId,\n pageIndex,\n annotation,\n scaleFactor = 1,\n unrotated,\n style,\n ...props\n}: RenderAnnotationProps) {\n const { provides: annotationProvides } = useAnnotationCapability();\n const [imageUrl, setImageUrl] = useState<string | null>(null);\n const urlRef = useRef<string | null>(null);\n\n const { width, height } = annotation.rect.size;\n\n useEffect(() => {\n if (annotationProvides) {\n const task = annotationProvides.forDocument(documentId).renderAnnotation({\n pageIndex,\n annotation,\n options: {\n scaleFactor,\n dpr: window.devicePixelRatio,\n unrotated,\n },\n });\n task.wait((blob) => {\n const url = URL.createObjectURL(blob);\n setImageUrl(url);\n urlRef.current = url;\n }, ignore);\n\n return () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n } else {\n task.abort({\n code: PdfErrorCode.Cancelled,\n message: 'canceled render task',\n });\n }\n };\n }\n }, [\n pageIndex,\n scaleFactor,\n unrotated,\n annotationProvides,\n documentId,\n annotation.id,\n width,\n height,\n ]);\n\n const handleImageLoad = () => {\n if (urlRef.current) {\n URL.revokeObjectURL(urlRef.current);\n urlRef.current = null;\n }\n };\n\n return (\n <Fragment>\n {imageUrl && (\n <img\n src={imageUrl}\n onLoad={handleImageLoad}\n {...props}\n style={{\n width: '100%',\n height: '100%',\n display: 'block',\n ...(style || {}),\n }}\n />\n )}\n </Fragment>\n );\n}\n","import { MouseEvent } from '@framework';\nimport { PdfStampAnnoObject } from '@embedpdf/models';\nimport { TrackedAnnotation } from '@embedpdf/plugin-annotation';\nimport { RenderAnnotation } from '../render-annotation';\n\ninterface StampProps {\n isSelected: boolean;\n annotation: TrackedAnnotation<PdfStampAnnoObject>;\n documentId: string;\n pageIndex: number;\n scale: number;\n onClick: (e: MouseEvent<HTMLDivElement>) => void;\n}\n\nexport function Stamp({\n isSelected,\n annotation,\n documentId,\n pageIndex,\n scale,\n onClick,\n}: StampProps) {\n const unrotated = !!annotation.object.rotation && !!annotation.object.unrotatedRect;\n\n return (\n <div\n style={{\n position: 'absolute',\n width: '100%',\n height: '100%',\n zIndex: 2,\n pointerEvents: isSelected ? 'none' : 'auto',\n cursor: 'pointer',\n }}\n onPointerDown={onClick}\n >\n <RenderAnnotation\n documentId={documentId}\n pageIndex={pageIndex}\n annotation={{ ...annotation.object, id: annotation.object.id }}\n scaleFactor={scale}\n unrotated={unrotated}\n />\n </div>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { PdfAnnotationBorderStyle, Rect } from '@embedpdf/models';\n\n/* ---------------------------------------------------------------- *\\\n|* Types *|\n\\* ---------------------------------------------------------------- */\n\ninterface LinkProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour – defaults to blue when omitted */\n strokeColor?: string;\n /** Stroke width in PDF units */\n strokeWidth?: number;\n /** Stroke type – defaults to underline when omitted */\n strokeStyle?: PdfAnnotationBorderStyle;\n /** Stroke dash array – for dashed style */\n strokeDashArray?: number[];\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** Whether this link has an IRT (In Reply To) reference - disables direct interaction */\n hasIRT?: boolean;\n}\n\n/**\n * Renders a PDF Link annotation as SVG.\n * Supports underline (default), solid, and dashed border styles.\n */\nexport function Link({\n isSelected,\n strokeColor = '#0000FF',\n strokeWidth = 2,\n strokeStyle = PdfAnnotationBorderStyle.UNDERLINE,\n strokeDashArray,\n rect,\n scale,\n onClick,\n hasIRT = false,\n}: LinkProps): JSX.Element {\n const { width, height } = useMemo(() => {\n return {\n width: rect.size.width,\n height: rect.size.height,\n };\n }, [rect]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n // Calculate dash array for SVG\n const dashArray = useMemo(() => {\n if (strokeStyle === PdfAnnotationBorderStyle.DASHED) {\n return strokeDashArray?.join(',') ?? `${strokeWidth * 3},${strokeWidth}`;\n }\n return undefined;\n }, [strokeStyle, strokeDashArray, strokeWidth]);\n\n // For underline style, render a line at the bottom\n // For solid/dashed, render a rectangle border\n const isUnderline = strokeStyle === PdfAnnotationBorderStyle.UNDERLINE;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n >\n {/* Invisible hit area for the entire link region */}\n {/* IRT links are not directly clickable - interaction goes through parent */}\n <rect\n x={0}\n y={0}\n width={width}\n height={height}\n fill=\"transparent\"\n onPointerDown={hasIRT ? undefined : onClick}\n style={{\n cursor: hasIRT ? 'default' : isSelected ? 'move' : 'pointer',\n pointerEvents: hasIRT ? 'none' : isSelected ? 'none' : 'visible',\n }}\n />\n\n {isUnderline ? (\n // Underline style: line at bottom of rect\n <line\n x1={1}\n y1={height - 1}\n x2={width - 1}\n y2={height - 1}\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n strokeDasharray={dashArray}\n style={{\n pointerEvents: 'none',\n }}\n />\n ) : (\n // Solid/Dashed style: rectangle border\n <rect\n x={strokeWidth / 2}\n y={strokeWidth / 2}\n width={Math.max(width - strokeWidth, 0)}\n height={Math.max(height - strokeWidth, 0)}\n fill=\"transparent\"\n stroke={strokeColor}\n strokeWidth={strokeWidth}\n strokeDasharray={dashArray}\n style={{\n pointerEvents: 'none',\n }}\n />\n )}\n </svg>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype HighlightProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Highlight({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: HighlightProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n\n return (\n <>\n {segmentRects.map((b, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? b.origin.x - rect.origin.x : b.origin.x) * scale,\n top: (rect ? b.origin.y - rect.origin.y : b.origin.y) * scale,\n width: b.size.width * scale,\n height: b.size.height * scale,\n background: appearanceActive ? 'transparent' : resolvedColor,\n opacity: appearanceActive ? undefined : opacity,\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : undefined,\n ...style,\n }}\n />\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype UnderlineProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Underline({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: UnderlineProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const thickness = 2 * scale; // 2 CSS px at 100 % zoom\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: thickness,\n background: resolvedColor,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype StrikeoutProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Strikeout({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: StrikeoutProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const thickness = 2 * scale;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n top: '50%',\n width: '100%',\n height: thickness,\n background: resolvedColor,\n opacity: opacity,\n transform: 'translateY(-50%)',\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { CSSProperties, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ntype SquigglyProps = {\n /** Stroke/markup color */\n strokeColor?: string;\n opacity?: number;\n segmentRects: Rect[];\n rect?: Rect;\n scale: number;\n onClick?: (e: MouseEvent<HTMLDivElement>) => void;\n style?: CSSProperties;\n /** When true, AP image provides the visual; only render hit area */\n appearanceActive?: boolean;\n};\n\nexport function Squiggly({\n strokeColor,\n opacity = 0.5,\n segmentRects,\n rect,\n scale,\n onClick,\n style,\n appearanceActive = false,\n}: SquigglyProps) {\n const resolvedColor = strokeColor ?? '#FFFF00';\n const amplitude = 2 * scale; // wave height\n const period = 6 * scale; // wave length\n\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${period}\" height=\"${amplitude * 2}\" viewBox=\"0 0 ${period} ${amplitude * 2}\">\n <path d=\"M0 ${amplitude} Q ${period / 4} 0 ${period / 2} ${amplitude} T ${period} ${amplitude}\"\n fill=\"none\" stroke=\"${resolvedColor}\" stroke-width=\"${amplitude}\" stroke-linecap=\"round\"/>\n </svg>`;\n\n // Completely escape the SVG markup\n const svgDataUri = `url(\"data:image/svg+xml;utf8,${encodeURIComponent(svg)}\")`;\n\n return (\n <>\n {segmentRects.map((r, i) => (\n <div\n key={i}\n onPointerDown={onClick}\n style={{\n position: 'absolute',\n left: (rect ? r.origin.x - rect.origin.x : r.origin.x) * scale,\n top: (rect ? r.origin.y - rect.origin.y : r.origin.y) * scale,\n width: r.size.width * scale,\n height: r.size.height * scale,\n background: 'transparent',\n pointerEvents: onClick ? 'auto' : 'none',\n cursor: onClick ? 'pointer' : 'default',\n zIndex: onClick ? 1 : 0,\n ...style,\n }}\n >\n {/* Visual -- hidden when AP active, never interactive */}\n {!appearanceActive && (\n <div\n style={{\n position: 'absolute',\n left: 0,\n bottom: 0,\n width: '100%',\n height: amplitude * 2,\n backgroundImage: svgDataUri,\n backgroundRepeat: 'repeat-x',\n backgroundSize: `${period}px ${amplitude * 2}px`,\n opacity: opacity,\n pointerEvents: 'none',\n }}\n />\n )}\n </div>\n ))}\n </>\n );\n}\n","import { useMemo, MouseEvent } from '@framework';\nimport { Rect } from '@embedpdf/models';\n\ninterface CaretProps {\n /** Whether the annotation is selected */\n isSelected: boolean;\n /** Stroke colour */\n strokeColor?: string;\n /** 0 – 1 */\n opacity?: number;\n /** Bounding box of the annotation (PDF units) */\n rect: Rect;\n /** Current page zoom factor */\n scale: number;\n /** Click handler (used for selection) */\n onClick?: (e: MouseEvent<SVGElement>) => void;\n /** When true, AP canvas provides the visual; only render hit area */\n appearanceActive?: boolean;\n}\n\n/**\n * Renders a PDF Caret annotation as an SVG ^ symbol using bezier curves\n * that mirror the C++ appearance stream.\n */\nexport function Caret({\n isSelected,\n strokeColor = '#000000',\n opacity = 1,\n rect,\n scale,\n onClick,\n appearanceActive = false,\n}: CaretProps): JSX.Element {\n const { width, height, path } = useMemo(() => {\n const w = rect.size.width;\n const h = rect.size.height;\n\n const midX = w / 2;\n\n const d = [\n `M 0 ${h}`,\n `C ${w * 0.27} ${h} ${midX} ${h - h * 0.44} ${midX} 0`,\n `C ${midX} ${h - h * 0.44} ${w - w * 0.27} ${h} ${w} ${h}`,\n 'Z',\n ].join(' ');\n\n return { width: w, height: h, path: d };\n }, [rect]);\n\n const svgWidth = width * scale;\n const svgHeight = height * scale;\n\n return (\n <svg\n style={{\n position: 'absolute',\n width: svgWidth,\n height: svgHeight,\n pointerEvents: 'none',\n zIndex: 2,\n }}\n width={svgWidth}\n height={svgHeight}\n viewBox={`0 0 ${width} ${height}`}\n overflow=\"visible\"\n >\n {/* Hit area */}\n <path\n d={path}\n fill=\"transparent\"\n stroke=\"transparent\"\n strokeWidth={4}\n onPointerDown={onClick}\n style={{\n cursor: isSelected ? 'move' : 'pointer',\n pointerEvents: isSelected ? 'none' : 'visible',\n }}\n />\n {/* Visual */}\n {!appearanceActive && (\n <path\n d={path}\n fill={strokeColor}\n stroke={strokeColor}\n strokeWidth={0.5}\n opacity={opacity}\n fillRule=\"evenodd\"\n style={{ pointerEvents: 'none' }}\n />\n )}\n </svg>\n );\n}\n","import {\n PdfAnnotationSubtype,\n PdfAnnotationObject,\n PdfInkAnnoObject,\n PdfSquareAnnoObject,\n PdfCircleAnnoObject,\n PdfLineAnnoObject,\n PdfPolylineAnnoObject,\n PdfPolygonAnnoObject,\n PdfTextAnnoObject,\n PdfFreeTextAnnoObject,\n PdfStampAnnoObject,\n PdfLinkAnnoObject,\n PdfHighlightAnnoObject,\n PdfUnderlineAnnoObject,\n PdfStrikeOutAnnoObject,\n PdfSquigglyAnnoObject,\n PdfCaretAnnoObject,\n PdfBlendMode,\n} from '@embedpdf/models';\nimport { Fragment } from '@framework';\nimport { BoxedAnnotationRenderer, createRenderer } from './types';\nimport { Ink } from './annotations/ink';\nimport { Square } from './annotations/square';\nimport { Circle } from './annotations/circle';\nimport { Line } from './annotations/line';\nimport { Polyline } from './annotations/polyline';\nimport { Polygon } from './annotations/polygon';\nimport { Text } from './annotations/text';\nimport { FreeText } from './annotations/free-text';\nimport { Stamp } from './annotations/stamp';\nimport { Link } from './annotations/link';\nimport { Highlight } from './text-markup/highlight';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Caret } from './annotations/caret';\n\nexport const builtInRenderers: BoxedAnnotationRenderer[] = [\n // --- Drawing ---\n\n createRenderer<PdfInkAnnoObject>({\n id: 'ink',\n matches: (a): a is PdfInkAnnoObject => a.type === PdfAnnotationSubtype.INK,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Ink\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Shapes ---\n\n createRenderer<PdfSquareAnnoObject>({\n id: 'square',\n matches: (a): a is PdfSquareAnnoObject => a.type === PdfAnnotationSubtype.SQUARE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Square\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n createRenderer<PdfCircleAnnoObject>({\n id: 'circle',\n matches: (a): a is PdfCircleAnnoObject => a.type === PdfAnnotationSubtype.CIRCLE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Circle\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Lines & Vertex-based ---\n\n createRenderer<PdfLineAnnoObject>({\n id: 'line',\n matches: (a): a is PdfLineAnnoObject => a.type === PdfAnnotationSubtype.LINE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Line\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => [a.linePoints.start, a.linePoints.end],\n transformAnnotation: (a, v) => ({\n ...a,\n linePoints: { start: v[0], end: v[1] },\n }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n createRenderer<PdfPolylineAnnoObject>({\n id: 'polyline',\n matches: (a): a is PdfPolylineAnnoObject => a.type === PdfAnnotationSubtype.POLYLINE,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Polyline\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => a.vertices,\n transformAnnotation: (a, vertices) => ({ ...a, vertices }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n createRenderer<PdfPolygonAnnoObject>({\n id: 'polygon',\n matches: (a): a is PdfPolygonAnnoObject => a.type === PdfAnnotationSubtype.POLYGON,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Fragment>\n <Polygon\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n </Fragment>\n ),\n vertexConfig: {\n extractVertices: (a) => a.vertices,\n transformAnnotation: (a, vertices) => ({ ...a, vertices }),\n },\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: true },\n }),\n\n // --- Text Markup ---\n\n createRenderer<PdfHighlightAnnoObject>({\n id: 'highlight',\n matches: (a): a is PdfHighlightAnnoObject => a.type === PdfAnnotationSubtype.HIGHLIGHT,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Highlight\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n defaultBlendMode: PdfBlendMode.Multiply,\n }),\n\n createRenderer<PdfUnderlineAnnoObject>({\n id: 'underline',\n matches: (a): a is PdfUnderlineAnnoObject => a.type === PdfAnnotationSubtype.UNDERLINE,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Underline\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n createRenderer<PdfStrikeOutAnnoObject>({\n id: 'strikeout',\n matches: (a): a is PdfStrikeOutAnnoObject => a.type === PdfAnnotationSubtype.STRIKEOUT,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Strikeout\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n createRenderer<PdfSquigglyAnnoObject>({\n id: 'squiggly',\n matches: (a): a is PdfSquigglyAnnoObject => a.type === PdfAnnotationSubtype.SQUIGGLY,\n render: ({ currentObject, scale, onClick, appearanceActive }) => (\n <Squiggly\n {...currentObject}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n zIndex: 0,\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n // --- Text Comment ---\n\n createRenderer<PdfTextAnnoObject>({\n id: 'text',\n matches: (a): a is PdfTextAnnoObject => a.type === PdfAnnotationSubtype.TEXT && !a.inReplyToId,\n render: ({ currentObject, isSelected, onClick, appearanceActive }) => (\n <Text\n isSelected={isSelected}\n color={currentObject.strokeColor ?? currentObject.color}\n opacity={currentObject.opacity}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: false, isRotatable: false },\n }),\n\n // --- Caret ---\n\n createRenderer<PdfCaretAnnoObject>({\n id: 'caret',\n matches: (a): a is PdfCaretAnnoObject => a.type === PdfAnnotationSubtype.CARET,\n render: ({ currentObject, isSelected, scale, onClick, appearanceActive }) => (\n <Caret\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: false, isResizable: false, isRotatable: false },\n }),\n\n // --- FreeText ---\n\n createRenderer<PdfFreeTextAnnoObject>({\n id: 'freeText',\n matches: (a): a is PdfFreeTextAnnoObject => a.type === PdfAnnotationSubtype.FREETEXT,\n render: ({\n annotation,\n currentObject,\n isSelected,\n isEditing,\n scale,\n pageIndex,\n documentId,\n onClick,\n appearanceActive,\n }) => (\n <FreeText\n documentId={documentId}\n isSelected={isSelected}\n isEditing={isEditing}\n annotation={{ ...annotation, object: currentObject }}\n pageIndex={pageIndex}\n scale={scale}\n onClick={onClick}\n appearanceActive={appearanceActive}\n />\n ),\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n isDraggable: (toolDraggable, { isEditing }) => toolDraggable && !isEditing,\n onDoubleClick: (id, setEditingId) => setEditingId(id),\n }),\n\n // --- Stamp ---\n\n createRenderer<PdfStampAnnoObject>({\n id: 'stamp',\n matches: (a): a is PdfStampAnnoObject => a.type === PdfAnnotationSubtype.STAMP,\n render: ({ annotation, isSelected, documentId, pageIndex, scale, onClick }) => (\n <Stamp\n isSelected={isSelected}\n annotation={annotation}\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n onClick={onClick}\n />\n ),\n useAppearanceStream: false,\n interactionDefaults: { isDraggable: true, isResizable: true, isRotatable: true },\n }),\n\n // --- Link ---\n\n createRenderer<PdfLinkAnnoObject>({\n id: 'link',\n matches: (a): a is PdfLinkAnnoObject => a.type === PdfAnnotationSubtype.LINK,\n render: ({ currentObject, isSelected, scale, onClick }) => (\n <Link\n {...currentObject}\n isSelected={isSelected}\n scale={scale}\n onClick={onClick}\n hasIRT={!!currentObject.inReplyToId}\n />\n ),\n interactionDefaults: {\n isDraggable: false,\n isResizable: false,\n isRotatable: false,\n },\n useAppearanceStream: false,\n selectOverride: (e, annotation, helpers) => {\n e.stopPropagation();\n helpers.clearSelection();\n if (annotation.object.inReplyToId) {\n const parent = helpers.allAnnotations.find(\n (a) => a.object.id === annotation.object.inReplyToId,\n );\n if (parent) {\n helpers.selectAnnotation(parent.object.pageIndex, parent.object.id);\n return;\n }\n }\n helpers.selectAnnotation(helpers.pageIndex, annotation.object.id);\n },\n hideSelectionMenu: (a) => !!a.inReplyToId,\n }),\n];\n","import {\n blendModeToCss,\n PdfAnnotationObject,\n PdfBlendMode,\n AnnotationAppearanceMap,\n AnnotationAppearances,\n} from '@embedpdf/models';\nimport {\n getAnnotationsByPageIndex,\n getSelectedAnnotationIds,\n TrackedAnnotation,\n resolveInteractionProp,\n} from '@embedpdf/plugin-annotation';\nimport { PointerEventHandlers, EmbedPdfPointerEvent } from '@embedpdf/plugin-interaction-manager';\nimport { usePointerHandlers } from '@embedpdf/plugin-interaction-manager/@framework';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\nimport { useMemo, useState, useEffect, useCallback, MouseEvent, useRef } from '@framework';\n\nimport { useAnnotationCapability } from '../hooks';\nimport { AnnotationContainer } from './annotation-container';\nimport { GroupSelectionBox } from './group-selection-box';\nimport {\n CustomAnnotationRenderer,\n ResizeHandleUI,\n AnnotationSelectionMenuRenderFn,\n GroupSelectionMenuRenderFn,\n VertexHandleUI,\n RotationHandleUI,\n SelectionOutline,\n BoxedAnnotationRenderer,\n AnnotationInteractionEvent,\n SelectOverrideHelpers,\n} from './types';\nimport { builtInRenderers } from './built-in-renderers';\n\ninterface AnnotationsProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n rotation: number;\n pageWidth: number;\n pageHeight: number;\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n resizeUI?: ResizeHandleUI;\n vertexUI?: VertexHandleUI;\n rotationUI?: RotationHandleUI;\n selectionOutlineColor?: string;\n selectionOutline?: SelectionOutline;\n groupSelectionOutline?: SelectionOutline;\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n annotationRenderers?: BoxedAnnotationRenderer[];\n}\n\nexport function Annotations(annotationsProps: AnnotationsProps) {\n const { documentId, pageIndex, scale, pageWidth, pageHeight, selectionMenu } = annotationsProps;\n const { provides: annotationCapability } = useAnnotationCapability();\n const { provides: selectionProvides } = useSelectionCapability();\n const [annotations, setAnnotations] = useState<TrackedAnnotation[]>([]);\n const { register } = usePointerHandlers({ documentId, pageIndex });\n const [allSelectedIds, setAllSelectedIds] = useState<string[]>([]);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [appearanceMap, setAppearanceMap] = useState<AnnotationAppearanceMap<Blob>>({});\n const prevScaleRef = useRef<number>(scale);\n\n const annotationProvides = useMemo(\n () => (annotationCapability ? annotationCapability.forDocument(documentId) : null),\n [annotationCapability, documentId],\n );\n\n const isMultiSelected = allSelectedIds.length > 1;\n\n useEffect(() => {\n if (annotationProvides) {\n const currentState = annotationProvides.getState();\n setAnnotations(getAnnotationsByPageIndex(currentState, pageIndex));\n setAllSelectedIds(getSelectedAnnotationIds(currentState));\n\n return annotationProvides.onStateChange((state) => {\n setAnnotations(getAnnotationsByPageIndex(state, pageIndex));\n setAllSelectedIds(getSelectedAnnotationIds(state));\n });\n }\n }, [annotationProvides, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n if (prevScaleRef.current !== scale) {\n annotationProvides.invalidatePageAppearances(pageIndex);\n prevScaleRef.current = scale;\n }\n\n const task = annotationProvides.getPageAppearances(pageIndex, {\n scaleFactor: scale,\n dpr: typeof window !== 'undefined' ? window.devicePixelRatio : 1,\n });\n task.wait(\n (map) => setAppearanceMap(map),\n () => setAppearanceMap({}),\n );\n }, [annotationProvides, pageIndex, scale]);\n\n const handlers = useMemo(\n (): PointerEventHandlers<EmbedPdfPointerEvent<MouseEvent>> => ({\n onPointerDown: (_, pe) => {\n if (pe.target === pe.currentTarget && annotationProvides) {\n annotationProvides.deselectAnnotation();\n setEditingId(null);\n }\n },\n }),\n [annotationProvides],\n );\n\n const handleClick = useCallback(\n (e: MouseEvent, annotation: TrackedAnnotation) => {\n e.stopPropagation();\n if (annotationProvides && selectionProvides) {\n selectionProvides.clear();\n\n const isModifierPressed = 'metaKey' in e ? e.metaKey || e.ctrlKey : false;\n\n if (isModifierPressed) {\n annotationProvides.toggleSelection(pageIndex, annotation.object.id);\n } else {\n annotationProvides.selectAnnotation(pageIndex, annotation.object.id);\n }\n\n if (annotation.object.id !== editingId) {\n setEditingId(null);\n }\n }\n },\n [annotationProvides, selectionProvides, editingId, pageIndex],\n );\n\n useEffect(() => {\n return register(handlers, {\n documentId,\n });\n }, [register, handlers]);\n\n const selectedAnnotationsOnPage = useMemo(() => {\n return annotations.filter((anno) => allSelectedIds.includes(anno.object.id));\n }, [annotations, allSelectedIds]);\n\n const areAllSelectedDraggable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupDraggable = resolveInteractionProp(\n tool?.interaction.isGroupDraggable,\n ta.object,\n true,\n );\n const singleDraggable = resolveInteractionProp(\n tool?.interaction.isDraggable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupDraggable !== undefined ? groupDraggable : singleDraggable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const areAllSelectedResizable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupResizable = resolveInteractionProp(\n tool?.interaction.isGroupResizable,\n ta.object,\n true,\n );\n const singleResizable = resolveInteractionProp(\n tool?.interaction.isResizable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupResizable !== undefined ? groupResizable : singleResizable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const areAllSelectedRotatable = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.every((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupRotatable = resolveInteractionProp(\n tool?.interaction.isGroupRotatable,\n ta.object,\n true,\n );\n const singleRotatable = resolveInteractionProp(\n tool?.interaction.isRotatable,\n ta.object,\n true,\n );\n return tool?.interaction.isGroupRotatable !== undefined ? groupRotatable : singleRotatable;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const shouldLockGroupAspectRatio = useMemo(() => {\n if (selectedAnnotationsOnPage.length < 2) return false;\n\n return selectedAnnotationsOnPage.some((ta) => {\n const tool = annotationProvides?.findToolForAnnotation(ta.object);\n const groupLock = resolveInteractionProp(\n tool?.interaction.lockGroupAspectRatio,\n ta.object,\n false,\n );\n const singleLock = resolveInteractionProp(\n tool?.interaction.lockAspectRatio,\n ta.object,\n false,\n );\n return tool?.interaction.lockGroupAspectRatio !== undefined ? groupLock : singleLock;\n });\n }, [selectedAnnotationsOnPage, annotationProvides]);\n\n const allSelectedOnSamePage = useMemo(() => {\n if (!annotationProvides) return false;\n const allSelected = annotationProvides.getSelectedAnnotations();\n return allSelected.length > 1 && allSelected.every((ta) => ta.object.pageIndex === pageIndex);\n }, [annotationProvides, pageIndex, allSelectedIds]);\n\n const getAppearanceForAnnotation = useCallback(\n (ta: TrackedAnnotation): AnnotationAppearances<Blob> | null => {\n if (ta.dictMode) return null;\n if (ta.object.rotation && ta.object.unrotatedRect) return null;\n const appearances = appearanceMap[ta.object.id];\n if (!appearances?.normal) return null;\n return appearances;\n },\n [appearanceMap],\n );\n\n // Merge renderers: external renderers override built-ins by ID\n const allRenderers = useMemo(() => {\n const external = annotationsProps.annotationRenderers ?? [];\n const externalIds = new Set(external.map((r) => r.id));\n return [...external, ...builtInRenderers.filter((r) => !externalIds.has(r.id))];\n }, [annotationsProps.annotationRenderers]);\n\n const resolveRenderer = useCallback(\n (annotation: TrackedAnnotation) =>\n allRenderers.find((r) => r.matches(annotation.object)) ?? null,\n [allRenderers],\n );\n\n // Stable helpers object for selectOverride\n const selectHelpers = useMemo(\n (): SelectOverrideHelpers => ({\n defaultSelect: handleClick,\n selectAnnotation: (pi: number, id: string) => annotationProvides?.selectAnnotation(pi, id),\n clearSelection: () => selectionProvides?.clear(),\n allAnnotations: annotations,\n pageIndex,\n }),\n [handleClick, annotationProvides, selectionProvides, annotations, pageIndex],\n );\n\n return (\n <>\n {annotations.map((annotation) => {\n const renderer = resolveRenderer(annotation);\n if (!renderer) return null;\n\n const tool = annotationProvides?.findToolForAnnotation(annotation.object);\n const isSelected = allSelectedIds.includes(annotation.object.id);\n const isEditing = editingId === annotation.object.id;\n const defaults = renderer.interactionDefaults;\n\n const resolvedDraggable = resolveInteractionProp(\n tool?.interaction.isDraggable,\n annotation.object,\n defaults?.isDraggable ?? true,\n );\n const finalDraggable = renderer.isDraggable\n ? renderer.isDraggable(resolvedDraggable, { isEditing })\n : resolvedDraggable;\n\n const useAP = tool?.behavior?.useAppearanceStream ?? renderer.useAppearanceStream ?? true;\n\n const onSelect = renderer.selectOverride\n ? (e: AnnotationInteractionEvent) =>\n renderer.selectOverride!(e, annotation, selectHelpers)\n : (e: AnnotationInteractionEvent) => handleClick(e, annotation);\n\n return (\n <AnnotationContainer\n key={annotation.object.id}\n trackedAnnotation={annotation}\n isSelected={isSelected}\n isEditing={isEditing}\n isMultiSelected={isMultiSelected}\n isDraggable={finalDraggable}\n isResizable={resolveInteractionProp(\n tool?.interaction.isResizable,\n annotation.object,\n defaults?.isResizable ?? false,\n )}\n lockAspectRatio={resolveInteractionProp(\n tool?.interaction.lockAspectRatio,\n annotation.object,\n defaults?.lockAspectRatio ?? false,\n )}\n isRotatable={resolveInteractionProp(\n tool?.interaction.isRotatable,\n annotation.object,\n defaults?.isRotatable ?? false,\n )}\n vertexConfig={renderer.vertexConfig}\n selectionMenu={\n renderer.hideSelectionMenu?.(annotation.object) ? undefined : selectionMenu\n }\n onSelect={onSelect}\n onDoubleClick={\n renderer.onDoubleClick\n ? (e: AnnotationInteractionEvent) => {\n e.stopPropagation();\n renderer.onDoubleClick!(annotation.object.id, setEditingId);\n }\n : undefined\n }\n zIndex={renderer.zIndex}\n blendMode={blendModeToCss(\n annotation.object.blendMode ?? renderer.defaultBlendMode ?? PdfBlendMode.Normal,\n )}\n style={renderer.containerStyle?.(annotation.object)}\n appearance={useAP ? getAppearanceForAnnotation(annotation) : undefined}\n {...annotationsProps}\n >\n {(currentObject, { appearanceActive }) =>\n renderer.render({\n annotation,\n currentObject,\n isSelected,\n isEditing,\n scale,\n pageIndex,\n documentId,\n onClick: onSelect,\n appearanceActive,\n })\n }\n </AnnotationContainer>\n );\n })}\n\n {allSelectedOnSamePage && selectedAnnotationsOnPage.length >= 2 && (\n <GroupSelectionBox\n documentId={documentId}\n pageIndex={pageIndex}\n scale={scale}\n rotation={annotationsProps.rotation}\n pageWidth={pageWidth}\n pageHeight={pageHeight}\n selectedAnnotations={selectedAnnotationsOnPage}\n isDraggable={areAllSelectedDraggable}\n isResizable={areAllSelectedResizable}\n isRotatable={areAllSelectedRotatable}\n lockAspectRatio={shouldLockGroupAspectRatio}\n resizeUI={annotationsProps.resizeUI}\n rotationUI={annotationsProps.rotationUI}\n selectionOutlineColor={annotationsProps.selectionOutlineColor}\n selectionOutline={\n annotationsProps.groupSelectionOutline ?? annotationsProps.selectionOutline\n }\n groupSelectionMenu={annotationsProps.groupSelectionMenu}\n />\n )}\n </>\n );\n}\n","import { blendModeToCss, PdfAnnotationSubtype, PdfBlendMode, Rect } from '@embedpdf/models';\nimport { AnnotationTool } from '@embedpdf/plugin-annotation';\nimport { useSelectionCapability } from '@embedpdf/plugin-selection/@framework';\n\nimport { useEffect, useState } from '@framework';\nimport { useAnnotationCapability } from '../hooks';\nimport { Highlight } from './text-markup/highlight';\nimport { Squiggly } from './text-markup/squiggly';\nimport { Underline } from './text-markup/underline';\nimport { Strikeout } from './text-markup/strikeout';\n\ninterface TextMarkupProps {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function TextMarkup({ documentId, pageIndex, scale }: TextMarkupProps) {\n const { provides: selectionProvides } = useSelectionCapability();\n const { provides: annotationProvides } = useAnnotationCapability();\n const [rects, setRects] = useState<Array<Rect>>([]);\n const [boundingRect, setBoundingRect] = useState<Rect | null>(null);\n const [activeTool, setActiveTool] = useState<AnnotationTool | null>(null);\n\n useEffect(() => {\n if (!selectionProvides) return;\n\n return selectionProvides.forDocument(documentId).onSelectionChange(() => {\n setRects(selectionProvides.forDocument(documentId).getHighlightRectsForPage(pageIndex));\n setBoundingRect(selectionProvides.forDocument(documentId).getBoundingRectForPage(pageIndex));\n });\n }, [selectionProvides, documentId, pageIndex]);\n\n useEffect(() => {\n if (!annotationProvides) return;\n\n // Initialize with current active tool\n setActiveTool(annotationProvides.forDocument(documentId).getActiveTool());\n\n return annotationProvides\n .forDocument(documentId)\n .onActiveToolChange((event) => setActiveTool(event));\n }, [annotationProvides, documentId]);\n\n if (!boundingRect) return null;\n if (!activeTool || !activeTool.defaults) return null;\n\n switch (activeTool.defaults.type) {\n case PdfAnnotationSubtype.UNDERLINE:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Underline\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.HIGHLIGHT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Multiply),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Highlight\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.STRIKEOUT:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Strikeout\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.SQUIGGLY:\n return (\n <div\n style={{\n mixBlendMode: blendModeToCss(activeTool.defaults?.blendMode ?? PdfBlendMode.Normal),\n pointerEvents: 'none',\n position: 'absolute',\n inset: 0,\n }}\n >\n <Squiggly\n strokeColor={activeTool.defaults?.strokeColor}\n opacity={activeTool.defaults?.opacity}\n segmentRects={rects}\n scale={scale}\n />\n </div>\n );\n case PdfAnnotationSubtype.CARET:\n return null;\n default:\n return null;\n }\n}\n","import { AnyPreviewState } from '@embedpdf/plugin-annotation';\nimport { Circle } from './annotations/circle';\nimport { Square } from './annotations/square';\nimport { Polygon } from './annotations/polygon';\nimport { blendModeToCss, PdfAnnotationSubtype, PdfBlendMode } from '@embedpdf/models';\nimport { Polyline } from './annotations/polyline';\nimport { Line } from './annotations/line';\nimport { Ink } from './annotations/ink';\n\ninterface Props {\n preview: AnyPreviewState;\n scale: number;\n}\n\nexport function PreviewRenderer({ preview, scale }: Props) {\n const { bounds } = preview;\n\n const style = {\n position: 'absolute' as const,\n left: bounds.origin.x * scale,\n top: bounds.origin.y * scale,\n width: bounds.size.width * scale,\n height: bounds.size.height * scale,\n pointerEvents: 'none' as const,\n zIndex: 10,\n };\n\n // Use type guards for proper type narrowing\n if (preview.type === PdfAnnotationSubtype.CIRCLE) {\n return (\n <div style={style}>\n <Circle isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.SQUARE) {\n return (\n <div style={style}>\n <Square isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYGON) {\n return (\n <div style={style}>\n <Polygon isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.POLYLINE) {\n return (\n <div style={style}>\n <Polyline isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.LINE) {\n return (\n <div style={style}>\n <Line isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.INK) {\n return (\n <div\n style={{\n ...style,\n mixBlendMode: blendModeToCss(preview.data.blendMode ?? PdfBlendMode.Normal),\n }}\n >\n <Ink isSelected={false} scale={scale} {...preview.data} />\n </div>\n );\n }\n\n if (preview.type === PdfAnnotationSubtype.FREETEXT) {\n return (\n <div style={style}>\n {/* Render a simple dashed border preview */}\n <div\n style={{\n width: '100%',\n height: '100%',\n border: `1px dashed ${preview.data.fontColor || '#000000'}`,\n backgroundColor: 'transparent',\n }}\n />\n </div>\n );\n }\n\n return null;\n}\n","import { useEffect, useMemo, useRef, useState } from '@framework';\nimport { useAnnotationPlugin } from '../hooks';\nimport { AnyPreviewState, HandlerServices } from '@embedpdf/plugin-annotation';\nimport { PreviewRenderer } from './preview-renderer';\n\ninterface Props {\n documentId: string;\n pageIndex: number;\n scale: number;\n}\n\nexport function AnnotationPaintLayer({ documentId, pageIndex, scale }: Props) {\n const { plugin: annotationPlugin } = useAnnotationPlugin();\n const [previews, setPreviews] = useState<Map<string, AnyPreviewState>>(new Map());\n\n const fileInputRef = useRef<HTMLInputElement>(null);\n const canvasRef = useRef<HTMLCanvasElement>(null);\n\n const services = useMemo<HandlerServices>(\n () => ({\n requestFile: ({ accept, onFile }) => {\n if (!fileInputRef.current) return;\n const input = fileInputRef.current;\n input.accept = accept;\n input.onchange = (e) => {\n const file = (e.target as HTMLInputElement).files?.[0];\n if (file) {\n onFile(file);\n input.value = '';\n }\n };\n input.click();\n },\n processImage: ({ source, maxWidth, maxHeight, onComplete }) => {\n const canvas = canvasRef.current;\n if (!canvas || !canvas.getContext) return;\n const ctx = canvas.getContext('2d');\n if (!ctx) return;\n\n const img = new Image();\n img.crossOrigin = 'Anonymous';\n img.onload = () => {\n let { naturalWidth: width, naturalHeight: height } = img;\n\n // --- SCALING LOGIC ---\n // Calculate the scale factor to fit within maxWidth and maxHeight\n const scaleX = maxWidth ? maxWidth / width : 1;\n const scaleY = maxHeight ? maxHeight / height : 1;\n const scaleFactor = Math.min(scaleX, scaleY, 1); // Ensure we don't scale up\n\n const finalWidth = width * scaleFactor;\n const finalHeight = height * scaleFactor;\n\n canvas.width = finalWidth;\n canvas.height = finalHeight;\n ctx.drawImage(img, 0, 0, finalWidth, finalHeight);\n\n const imageData = ctx.getImageData(0, 0, finalWidth, finalHeight);\n if (typeof source !== 'string') URL.revokeObjectURL(img.src);\n\n onComplete({ imageData, width: finalWidth, height: finalHeight });\n };\n img.src = typeof source === 'string' ? source : URL.createObjectURL(source);\n },\n }),\n [],\n );\n\n useEffect(() => {\n if (!annotationPlugin) return;\n\n return annotationPlugin.registerPageHandlers(documentId, pageIndex, scale, {\n services,\n onPreview: (toolId, state) => {\n setPreviews((prev) => {\n const next = new Map(prev);\n if (state) {\n next.set(toolId, state);\n } else {\n next.delete(toolId);\n }\n return next;\n });\n },\n });\n }, [documentId, pageIndex, scale, annotationPlugin, services]);\n\n return (\n <>\n {/* Hidden DOM elements required by services */}\n <input ref={fileInputRef} type=\"file\" style={{ display: 'none' }} />\n <canvas ref={canvasRef} style={{ display: 'none' }} />\n\n {/* Render any active previews from any tool */}\n {Array.from(previews.entries()).map(([toolId, preview]) => (\n <PreviewRenderer key={toolId} preview={preview} scale={scale} />\n ))}\n </>\n );\n}\n","import { HTMLAttributes, CSSProperties, useMemo } from '@framework';\nimport { useDocumentState } from '@embedpdf/core/@framework';\nimport { Annotations } from './annotations';\nimport { TextMarkup } from './text-markup';\nimport {\n ResizeHandleUI,\n VertexHandleUI,\n RotationHandleUI,\n SelectionOutline,\n CustomAnnotationRenderer,\n AnnotationSelectionMenuRenderFn,\n GroupSelectionMenuRenderFn,\n BoxedAnnotationRenderer,\n} from './types';\nimport { AnnotationPaintLayer } from './annotation-paint-layer';\nimport { PdfAnnotationObject, Rotation } from '@embedpdf/models';\nimport { useRegisteredRenderers } from '../context/renderer-registry';\n\ntype AnnotationLayerProps = Omit<HTMLAttributes<HTMLDivElement>, 'style'> & {\n /** The ID of the document that this layer displays annotations for */\n documentId: string;\n pageIndex: number;\n scale?: number;\n rotation?: number;\n /** Customize selection menu across all annotations on this layer */\n selectionMenu?: AnnotationSelectionMenuRenderFn;\n /** Customize group selection menu across all annotations on this layer */\n groupSelectionMenu?: GroupSelectionMenuRenderFn;\n style?: CSSProperties;\n /** Customize resize handles */\n resizeUI?: ResizeHandleUI;\n /** Customize vertex handles */\n vertexUI?: VertexHandleUI;\n /** Customize rotation handle */\n rotationUI?: RotationHandleUI;\n /** @deprecated Use `selectionOutline` instead */\n selectionOutlineColor?: string;\n /** Customize the selection outline for individual annotations */\n selectionOutline?: SelectionOutline;\n /** Customize the selection outline for the group selection box (falls back to selectionOutline) */\n groupSelectionOutline?: SelectionOutline;\n /** Customize annotation renderer */\n customAnnotationRenderer?: CustomAnnotationRenderer<PdfAnnotationObject>;\n /** Custom renderers for specific annotation types (provided by external plugins) */\n annotationRenderers?: BoxedAnnotationRenderer[];\n};\n\nexport function AnnotationLayer({\n style,\n documentId,\n pageIndex,\n scale: overrideScale,\n rotation: overrideRotation,\n selectionMenu,\n groupSelectionMenu,\n resizeUI,\n vertexUI,\n rotationUI,\n selectionOutlineColor,\n selectionOutline,\n groupSelectionOutline,\n customAnnotationRenderer,\n annotationRenderers,\n ...props\n}: AnnotationLayerProps) {\n const documentState = useDocumentState(documentId);\n const page = documentState?.document?.pages?.[pageIndex];\n const width = page?.size?.width ?? 0;\n const height = page?.size?.height ?? 0;\n\n // Auto-load renderers from context\n const contextRenderers = useRegisteredRenderers();\n\n // Merge: context + explicit props (props take precedence by id)\n const allRenderers = useMemo(() => {\n const merged = [...contextRenderers];\n for (const renderer of annotationRenderers ?? []) {\n const idx = merged.findIndex((r) => r.id === renderer.id);\n if (idx >= 0) merged[idx] = renderer;\n else merged.push(renderer);\n }\n return merged;\n }, [contextRenderers, annotationRenderers]);\n\n const actualScale = useMemo(() => {\n if (overrideScale !== undefined) return overrideScale;\n return documentState?.scale ?? 1;\n }, [overrideScale, documentState?.scale]);\n\n const actualRotation = useMemo(() => {\n if (overrideRotation !== undefined) return overrideRotation;\n // Combine page intrinsic rotation with document rotation\n const pageRotation = page?.rotation ?? 0;\n const docRotation = documentState?.rotation ?? 0;\n return ((pageRotation + docRotation) % 4) as Rotation;\n }, [overrideRotation, page?.rotation, documentState?.rotation]);\n\n return (\n <div\n style={{\n ...style,\n }}\n {...props}\n >\n <Annotations\n documentId={documentId}\n selectionMenu={selectionMenu}\n groupSelectionMenu={groupSelectionMenu}\n pageIndex={pageIndex}\n scale={actualScale}\n rotation={actualRotation}\n pageWidth={width}\n pageHeight={height}\n resizeUI={resizeUI}\n vertexUI={vertexUI}\n rotationUI={rotationUI}\n selectionOutlineColor={selectionOutlineColor}\n selectionOutline={selectionOutline}\n groupSelectionOutline={groupSelectionOutline}\n customAnnotationRenderer={customAnnotationRenderer}\n annotationRenderers={allRenderers}\n />\n <TextMarkup documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n <AnnotationPaintLayer documentId={documentId} pageIndex={pageIndex} scale={actualScale} />\n </div>\n );\n}\n","import { createPluginPackage } from '@embedpdf/core';\nimport { AnnotationPluginPackage as BaseAnnotationPackage } from '@embedpdf/plugin-annotation';\nimport { AnnotationRendererProvider } from './context/renderer-registry';\n\nexport * from './hooks';\nexport * from './components';\nexport * from './components/types';\nexport * from './context';\nexport * from '@embedpdf/plugin-annotation';\n\n// Automatically wrap with AnnotationRendererProvider\nexport const AnnotationPluginPackage = createPluginPackage(BaseAnnotationPackage)\n .addWrapper(AnnotationRendererProvider)\n .build();\n"],"names":["_a","_b","_c","MIN_HIT_AREA_SCREEN_PX","Fragment","BaseAnnotationPackage"],"mappings":";;;;;;;;;;;;;AA4BO,MAAM,sCAAsC,CAAA;ACdnD,MAAM,kBAAkB,cAAiC,IAAI;AAC7D,MAAM,mBAAmB,cAAyC,EAAE;AAE7D,SAAS,2BAA2B,EAAE,YAAqC;AAChF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAoC,CAAA,CAAE;AAGxE,QAAM,WAAW,YAAY,CAAC,YAAuC;AACnE,iBAAa,CAAC,SAAS;AACrB,YAAM,MAAM,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;AAC5C,aAAO,CAAC,GAAG,KAAK,OAAO,CAAC,MAAM,CAAC,IAAI,IAAI,EAAE,EAAE,CAAC,GAAG,GAAG,OAAO;AAAA,IAC3D,CAAC;AACD,WAAO,MAAM,aAAa,CAAC,SAAS,KAAK,OAAO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