@embedpdf/plugin-annotation 2.2.0 → 2.4.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 (119) hide show
  1. package/dist/index.cjs +1 -1
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.js +1232 -101
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/actions.d.ts +33 -3
  6. package/dist/lib/annotation-plugin.d.ts +178 -2
  7. package/dist/lib/handlers/types.d.ts +1 -1
  8. package/dist/lib/helpers.d.ts +8 -2
  9. package/dist/lib/selectors.d.ts +97 -8
  10. package/dist/lib/tools/default-tools.d.ts +39 -11
  11. package/dist/lib/tools/types.d.ts +22 -4
  12. package/dist/lib/types.d.ts +278 -1
  13. package/dist/preact/adapter.d.ts +3 -3
  14. package/dist/preact/index.cjs +1 -1
  15. package/dist/preact/index.cjs.map +1 -1
  16. package/dist/preact/index.js +1133 -403
  17. package/dist/preact/index.js.map +1 -1
  18. package/dist/react/adapter.d.ts +1 -1
  19. package/dist/react/index.cjs +1 -1
  20. package/dist/react/index.cjs.map +1 -1
  21. package/dist/react/index.js +1132 -402
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/shared/components/annotation-container.d.ts +13 -2
  24. package/dist/shared/components/annotation-layer.d.ts +6 -2
  25. package/dist/shared/components/annotations/ink.d.ts +3 -3
  26. package/dist/shared/components/annotations/link.d.ts +28 -0
  27. package/dist/shared/components/annotations.d.ts +4 -1
  28. package/dist/shared/components/group-selection-box.d.ts +32 -0
  29. package/dist/shared/components/index.d.ts +1 -0
  30. package/dist/shared/components/text-markup/highlight.d.ts +3 -2
  31. package/dist/shared/components/text-markup/squiggly.d.ts +3 -2
  32. package/dist/shared/components/text-markup/strikeout.d.ts +3 -2
  33. package/dist/shared/components/text-markup/underline.d.ts +3 -2
  34. package/dist/shared/components/types.d.ts +50 -1
  35. package/dist/shared/context/index.d.ts +1 -0
  36. package/dist/shared/context/renderer-registry.d.ts +21 -0
  37. package/dist/shared/index.d.ts +2 -0
  38. package/dist/shared-preact/components/annotation-container.d.ts +13 -2
  39. package/dist/shared-preact/components/annotation-layer.d.ts +6 -2
  40. package/dist/shared-preact/components/annotations/ink.d.ts +3 -3
  41. package/dist/shared-preact/components/annotations/link.d.ts +28 -0
  42. package/dist/shared-preact/components/annotations.d.ts +4 -1
  43. package/dist/shared-preact/components/group-selection-box.d.ts +32 -0
  44. package/dist/shared-preact/components/index.d.ts +1 -0
  45. package/dist/shared-preact/components/text-markup/highlight.d.ts +3 -2
  46. package/dist/shared-preact/components/text-markup/squiggly.d.ts +3 -2
  47. package/dist/shared-preact/components/text-markup/strikeout.d.ts +3 -2
  48. package/dist/shared-preact/components/text-markup/underline.d.ts +3 -2
  49. package/dist/shared-preact/components/types.d.ts +50 -1
  50. package/dist/shared-preact/context/index.d.ts +1 -0
  51. package/dist/shared-preact/context/renderer-registry.d.ts +21 -0
  52. package/dist/shared-preact/index.d.ts +2 -0
  53. package/dist/shared-react/components/annotation-container.d.ts +13 -2
  54. package/dist/shared-react/components/annotation-layer.d.ts +6 -2
  55. package/dist/shared-react/components/annotations/ink.d.ts +3 -3
  56. package/dist/shared-react/components/annotations/link.d.ts +28 -0
  57. package/dist/shared-react/components/annotations.d.ts +4 -1
  58. package/dist/shared-react/components/group-selection-box.d.ts +32 -0
  59. package/dist/shared-react/components/index.d.ts +1 -0
  60. package/dist/shared-react/components/text-markup/highlight.d.ts +3 -2
  61. package/dist/shared-react/components/text-markup/squiggly.d.ts +3 -2
  62. package/dist/shared-react/components/text-markup/strikeout.d.ts +3 -2
  63. package/dist/shared-react/components/text-markup/underline.d.ts +3 -2
  64. package/dist/shared-react/components/types.d.ts +50 -1
  65. package/dist/shared-react/context/index.d.ts +1 -0
  66. package/dist/shared-react/context/renderer-registry.d.ts +21 -0
  67. package/dist/shared-react/index.d.ts +2 -0
  68. package/dist/svelte/components/AnnotationLayer.svelte.d.ts +8 -1
  69. package/dist/svelte/components/Annotations.svelte.d.ts +8 -1
  70. package/dist/svelte/components/GroupSelectionBox.svelte.d.ts +32 -0
  71. package/dist/svelte/components/RendererRegistryProvider.svelte.d.ts +7 -0
  72. package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -1
  73. package/dist/svelte/components/annotations/Link.svelte.d.ts +24 -0
  74. package/dist/svelte/components/annotations/index.d.ts +1 -0
  75. package/dist/svelte/components/index.d.ts +2 -0
  76. package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +2 -1
  77. package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +2 -1
  78. package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +2 -1
  79. package/dist/svelte/components/text-markup/Underline.svelte.d.ts +2 -1
  80. package/dist/svelte/components/types.d.ts +2 -0
  81. package/dist/svelte/context/index.d.ts +2 -0
  82. package/dist/svelte/context/renderer-registry.svelte.d.ts +20 -0
  83. package/dist/svelte/context/types.d.ts +33 -0
  84. package/dist/svelte/index.cjs +1 -1
  85. package/dist/svelte/index.cjs.map +1 -1
  86. package/dist/svelte/index.d.ts +2 -0
  87. package/dist/svelte/index.js +1215 -394
  88. package/dist/svelte/index.js.map +1 -1
  89. package/dist/svelte/types.d.ts +7 -0
  90. package/dist/vue/components/annotation-container.vue.d.ts +3 -1
  91. package/dist/vue/components/annotation-layer.vue.d.ts +31 -5
  92. package/dist/vue/components/annotations/free-text.vue.d.ts +1 -1
  93. package/dist/vue/components/annotations/index.d.ts +1 -0
  94. package/dist/vue/components/annotations/ink.vue.d.ts +2 -2
  95. package/dist/vue/components/annotations/line.vue.d.ts +1 -1
  96. package/dist/vue/components/annotations/link.vue.d.ts +29 -0
  97. package/dist/vue/components/annotations/polygon.vue.d.ts +1 -1
  98. package/dist/vue/components/annotations/polyline.vue.d.ts +1 -1
  99. package/dist/vue/components/annotations/stamp.vue.d.ts +1 -1
  100. package/dist/vue/components/annotations.vue.d.ts +151 -53
  101. package/dist/vue/components/group-selection-box.vue.d.ts +73 -0
  102. package/dist/vue/components/index.d.ts +2 -0
  103. package/dist/vue/components/preview-renderer.vue.d.ts +1 -1
  104. package/dist/vue/components/renderer-registry-provider.vue.d.ts +13 -0
  105. package/dist/vue/components/text-markup/highlight.vue.d.ts +2 -2
  106. package/dist/vue/components/text-markup/squiggly.vue.d.ts +2 -2
  107. package/dist/vue/components/text-markup/strikeout.vue.d.ts +2 -2
  108. package/dist/vue/components/text-markup/underline.vue.d.ts +2 -2
  109. package/dist/vue/context/index.d.ts +2 -0
  110. package/dist/vue/context/renderer-registry.d.ts +26 -0
  111. package/dist/vue/context/types.d.ts +33 -0
  112. package/dist/vue/hooks/use-annotation.d.ts +7 -5
  113. package/dist/vue/index.cjs +1 -1
  114. package/dist/vue/index.cjs.map +1 -1
  115. package/dist/vue/index.d.ts +3 -1
  116. package/dist/vue/index.js +1124 -459
  117. package/dist/vue/index.js.map +1 -1
  118. package/dist/vue/types.d.ts +8 -1
  119. package/package.json +10 -10
@@ -1,4 +1,4 @@
1
- export { Fragment, useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect, JSX, ChangeEvent, } from 'react';
1
+ export { Fragment, useEffect, useRef, useState, useCallback, useMemo, useLayoutEffect, createContext, useContext, JSX, ChangeEvent, } from 'react';
2
2
  export type { ReactNode, HTMLAttributes, CSSProperties, MouseEvent, PointerEvent, TouchEvent, } from 'react';
3
3
  export declare const suppressContentEditableWarningProps: {
4
4
  suppressContentEditableWarning: boolean;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core/react"),t=require("@embedpdf/plugin-annotation"),n=require("react"),o=require("react/jsx-runtime"),i=require("@embedpdf/models"),s=require("@embedpdf/plugin-interaction-manager/react"),r=require("@embedpdf/plugin-selection/react"),l=require("@embedpdf/utils/react"),a={suppressContentEditableWarning:!0},d=()=>e.usePlugin(t.AnnotationPlugin.id),c=()=>e.useCapability(t.AnnotationPlugin.id);function u({scale:t,documentId:i,pageIndex:s,rotation:r,pageWidth:a,pageHeight:d,trackedAnnotation:u,children:g,isSelected:h,isDraggable:p,isResizable:x,lockAspectRatio:v=!1,style:b={},vertexConfig:y,selectionMenu:f,outlineOffset:m=1,onDoubleClick:j,onSelect:k,zIndex:S=1,resizeUI:M,vertexUI:A,selectionOutlineColor:w="#007ACC",customAnnotationRenderer:z,...D}){const[P,C]=n.useState(u.object),{provides:R}=c(),{canModifyAnnotations:I}=e.useDocumentPermissions(i),E=n.useRef(null),B=I&&p,T=I&&x,$=n.useMemo(()=>R?R.forDocument(i):null,[R,i]),L=P?{...u.object,...P}:u.object,F=(null==M?void 0:M.color)??"#007ACC",O=(null==A?void 0:A.color)??"#007ACC",U=(null==M?void 0:M.size)??12,W=(null==A?void 0:A.size)??12,{dragProps:H,vertices:N,resize:q}=l.useInteractionHandles({controller:{element:L.rect,vertices:null==y?void 0:y.extractVertices(L),constraints:{minWidth:10,minHeight:10,boundingBox:{width:a,height:d}},maintainAspectRatio:v,pageRotation:r,scale:t,enabled:h,onUpdate:e=>{var t;if(!(null==(t=e.transformData)?void 0:t.type))return;"start"===e.state&&(E.current=L);const n=e.transformData.type,o=E.current??L,i=e.transformData.changes.vertices?null==y?void 0:y.transformAnnotation(o,e.transformData.changes.vertices):{rect:e.transformData.changes.rect},r=null==R?void 0:R.transformAnnotation(o,{type:n,changes:i,metadata:e.transformData.metadata});r&&C(e=>({...e,...r})),"end"===e.state&&r&&(E.current=null,null==$||$.updateAnnotation(s,u.object.id,r))}},resizeUI:{handleSize:U,spacing:m,offsetMode:"outside",includeSides:!v,zIndex:S+1},vertexUI:{vertexSize:W,zIndex:S+2},includeVertices:!!y}),V=n.useMemo(()=>{if(I&&j)return j},[I,j]),G=l.useDoublePressProps(V);return n.useEffect(()=>{C(u.object)},[u.object]),o.jsxs("div",{"data-no-interaction":!0,children:[o.jsxs("div",{...B&&h?H:{},...G,style:{position:"absolute",left:L.rect.origin.x*t,top:L.rect.origin.y*t,width:L.rect.size.width*t,height:L.rect.size.height*t,outline:h?`1px solid ${w}`:"none",outlineOffset:h?`${m}px`:"0px",pointerEvents:h?"auto":"none",touchAction:"none",cursor:h&&B?"move":"default",zIndex:S,...b},...D,children:[(()=>{const e="function"==typeof g?g(L):g,n=null==z?void 0:z({annotation:L,children:e,isSelected:h,scale:t,rotation:r,pageWidth:a,pageHeight:d,pageIndex:s,onSelect:k});return null!=n?n:e})(),h&&T&&q.map(({key:e,...t})=>(null==M?void 0:M.component)?M.component({key:e,...t,backgroundColor:F}):o.jsx("div",{...t,style:{...t.style,backgroundColor:F}},e)),h&&I&&N.map(({key:e,...t})=>(null==A?void 0:A.component)?A.component({key:e,...t,backgroundColor:O}):o.jsx("div",{...t,style:{...t.style,backgroundColor:O}},e))]}),f&&o.jsx(l.CounterRotate,{rect:{origin:{x:L.rect.origin.x*t,y:L.rect.origin.y*t},size:{width:L.rect.size.width*t,height:L.rect.size.height*t}},rotation:r,children:e=>f({...e,context:{type:"annotation",annotation:u,pageIndex:s},selected:h,placement:{suggestTop:!1}})})]})}function g({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){return o.jsx(o.Fragment,{children:n.map((n,a)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:e,opacity:t,pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:void 0,...l}},a))})}function h({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return o.jsx(o.Fragment,{children:n.map((n,d)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:a,background:e,opacity:t,pointerEvents:"none"}})},d))})}function p({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return o.jsx(o.Fragment,{children:n.map((n,d)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?n.origin.x-i.origin.x:n.origin.x)*s,top:(i?n.origin.y-i.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:a,background:e,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},d))})}function x({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:i,scale:s,onClick:r,style:l}){const a=2*s,d=6*s,c=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${2*a}" viewBox="0 0 ${d} ${2*a}">\n <path d="M0 ${a} Q ${d/4} 0 ${d/2} ${a} T ${d} ${a}"\n fill="none" stroke="${e}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*s,top:(i?e.origin.y-i.origin.y:e.origin.y)*s,width:e.size.width*s,height:e.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:c,backgroundRepeat:"repeat-x",backgroundSize:`${d}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},n))})}function v({isSelected:e,color:t="#000000",opacity:i=1,strokeWidth:s,inkList:r,rect:l,scale:a,onClick:d}){const c=n.useMemo(()=>r.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-l.origin.x,s=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+s+" "}),t.trim()}),[r,l]),u=l.size.width*a,g=l.size.height*a;return o.jsx("svg",{style:{position:"absolute",width:u,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:u,height:g,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:c.map((n,r)=>o.jsx("path",{d:n,fill:"none",opacity:i,onPointerDown:d,onTouchStart:d,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"}},r))})}function b({isSelected:e,color:t="#000000",strokeColor:s,opacity:r=1,strokeWidth:l,strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:c,scale:u,onClick:g}){const{width:h,height:p,x:x,y:v}=n.useMemo(()=>{const e=c.size.width,t=c.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[c,l]),b=(h+l)*u,y=(p+l)*u;return o.jsx("svg",{style:{position:"absolute",width:b,height:y,pointerEvents:"none",zIndex:2},width:b,height:y,viewBox:`0 0 ${h+l} ${p+l}`,children:o.jsx("rect",{x:x,y:v,width:h,height:p,fill:t,opacity:r,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:s??t,strokeWidth:l,...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}})})}function y({color:e="#000000",strokeColor:t,opacity:s=1,strokeWidth:r,strokeStyle:l=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:d,scale:c,onClick:u,isSelected:g}){const{width:h,height:p,cx:x,cy:v,rx:b,ry:y}=n.useMemo(()=>{const e=d.size.width,t=d.size.height,n=Math.max(e-r,0),o=Math.max(t-r,0);return{width:e,height:t,cx:r/2+n/2,cy:r/2+o/2,rx:n/2,ry:o/2}},[d,r]),f=h*c,m=p*c;return o.jsx("svg",{style:{position:"absolute",width:f,height:m,pointerEvents:"none",zIndex:2},width:f,height:m,viewBox:`0 0 ${h} ${p}`,children:o.jsx("ellipse",{cx:x,cy:v,rx:b,ry:y,fill:e,opacity:s,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:r,...l===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function f({color:e="transparent",opacity:s=1,strokeWidth:r,strokeColor:l="#000000",strokeStyle:a=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,rect:c,linePoints:u,lineEndings:g,scale:h,onClick:p,isSelected:x}){const{x1:v,y1:b,x2:y,y2:f}=n.useMemo(()=>({x1:u.start.x-c.origin.x,y1:u.start.y-c.origin.y,x2:u.end.x-c.origin.x,y2:u.end.y-c.origin.y}),[u,c]),m=n.useMemo(()=>{const e=Math.atan2(f-b,y-v);return{start:t.patching.createEnding(null==g?void 0:g.start,r,e+Math.PI,v,b),end:t.patching.createEnding(null==g?void 0:g.end,r,e,y,f)}},[g,r,v,b,y,f]),j=c.size.width*h,k=c.size.height*h;return o.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${c.size.width} ${c.size.height}`,children:[o.jsx("line",{x1:v,y1:b,x2:y,y2:f,opacity:s,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),m.start&&o.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:l,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}},fill:m.start.filled?e:"none"}),m.end&&o.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}},fill:m.end.filled?e:"none"})]})}function m({rect:e,vertices:i,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,scale:d,isSelected:c,onClick:u,lineEndings:g}){const h=n.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),p=n.useMemo(()=>{if(!h.length)return"";const[e,...t]=h;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[h]),x=n.useMemo(()=>{if(h.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(h[0],h[1]),o=e(h[h.length-2],h[h.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,n+Math.PI,h[0].x,h[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,o,h[h.length-1].x,h[h.length-1].y)}},[h,g,a]),v=e.size.width*d,b=e.size.height*d;return o.jsxs("svg",{style:{position:"absolute",width:v,height:b,pointerEvents:"none",zIndex:2,overflow:"visible"},width:v,height:b,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:r??s,strokeWidth:a,cursor:c?"move":"pointer",pointerEvents:c?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&o.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:r,fill:x.start.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:c?"move":"pointer",strokeWidth:a,pointerEvents:c?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&o.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:r,fill:x.end.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:c?"move":"pointer",strokeWidth:a,pointerEvents:c?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function j({rect:e,vertices:t,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,strokeStyle:d=i.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,scale:u,isSelected:g,onClick:h,currentVertex:p,handleSize:x=14}){const v=p?[...t,p]:t,b=n.useMemo(()=>v.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[v,e]),y=n.useMemo(()=>{if(!b.length)return"";const[e,...t]=b,n=!!p;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[b,p]),f=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return o.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[o.jsx("path",{d:y,onPointerDown:h,onTouchStart:h,opacity:l,style:{fill:p?"none":s,stroke:r??s,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===s?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...d===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),f&&t.length>1&&o.jsx("path",{d:`M ${b[b.length-1].x} ${b[b.length-1].y} L ${b[0].x} ${b[0].y}`,fill:"none",style:{stroke:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),f&&t.length>=2&&o.jsx("rect",{x:b[0].x-x/u/2,y:b[0].y-x/u/2,width:x/u,height:x/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function k({isSelected:e,isEditing:t,annotation:s,pageIndex:r,scale:l,onClick:d}){const u=n.useRef(null),{provides:g}=c(),[h,p]=n.useState(!1);n.useEffect(()=>{if(t&&u.current){const e=u.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}},[t]),n.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const x=s.object.fontSize*l,v=h&&t&&x>0&&x<16,b=v?16:x,y=v?x/16:1,f=v?100/y:100;return o.jsx("div",{style:{position:"absolute",width:s.object.rect.size.width*l,height:s.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:d,onTouchStart:d,children:o.jsx("span",{ref:u,onBlur:()=>{g&&u.current&&g.updateAnnotation(r,s.object.id,{contents:u.current.innerText})},tabIndex:0,style:{color:s.object.fontColor,fontSize:b,fontFamily:i.standardFontCss(s.object.fontFamily),textAlign:i.textAlignmentToCss(s.object.textAlign),flexDirection:"column",justifyContent:s.object.verticalAlign===i.PdfVerticalAlignment.Top?"flex-start":s.object.verticalAlign===i.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:s.object.backgroundColor,opacity:s.object.opacity,width:v?`${f}%`:"100%",height:v?`${f}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:v?`scale(${y})`:void 0,transformOrigin:"top left"},contentEditable:t,...a,children:s.object.contents})})}function S({documentId:e,pageIndex:t,annotation:s,scaleFactor:r=1,style:l,...a}){const{provides:d}=c(),[u,g]=n.useState(null),h=n.useRef(null),{width:p,height:x}=s.rect.size;n.useEffect(()=>{if(d){const n=d.forDocument(e).renderAnnotation({pageIndex:t,annotation:s,options:{scaleFactor:r,dpr:window.devicePixelRatio}});return n.wait(e=>{const t=URL.createObjectURL(e);g(t),h.current=t},i.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):n.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,r,d,e,s.id,p,x]);return o.jsx(n.Fragment,{children:u&&o.jsx("img",{src:u,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function M({isSelected:e,annotation:t,documentId:n,pageIndex:i,scale:s,onClick:r}){return o.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:r,onTouchStart:r,children:o.jsx(S,{documentId:n,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:s})})}function A(e){const{documentId:l,pageIndex:a,scale:d,selectionMenu:S}=e,{provides:A}=c(),{provides:w}=r.useSelectionCapability(),[z,D]=n.useState([]),{register:P}=s.usePointerHandlers({documentId:l,pageIndex:a}),[C,R]=n.useState(null),[I,E]=n.useState(null),B=n.useMemo(()=>A?A.forDocument(l):null,[A,l]);n.useEffect(()=>{if(B){const e=B.getState();return D(t.getAnnotationsByPageIndex(e,a)),R(t.getSelectedAnnotationByPageIndex(e,a)),B.onStateChange(e=>{D(t.getAnnotationsByPageIndex(e,a)),R(t.getSelectedAnnotationByPageIndex(e,a))})}},[B,a]);const T=n.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&B&&(B.deselectAnnotation(),E(null))}}),[B]),$=n.useCallback((e,t)=>{e.stopPropagation(),B&&w&&(B.selectAnnotation(a,t.object.id),w.clear(),t.object.id!==I&&E(null))},[B,w,I,a]);return n.useEffect(()=>P(T,{documentId:l}),[P,T]),o.jsx(o.Fragment,{children:z.map(s=>{const r=(null==C?void 0:C.object.id)===s.object.id,c=I===s.object.id,A=null==B?void 0:B.findToolForAnnotation(s.object);return t.isInk(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(v,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isSquare(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(b,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isCircle(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(y,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isUnderline(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(h,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isStrikeout(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(p,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isSquiggly(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(x,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isHighlight(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!1,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),zIndex:0,style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Multiply)},...e,children:e=>o.jsx(g,{...e,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isLine(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(f,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isPolyline(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(m,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isPolygon(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!1,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(j,{...e,isSelected:r,scale:d,onClick:e=>$(e,s)})})},s.object.id):t.isFreeText(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:((null==A?void 0:A.interaction.isDraggable)??!0)&&!c,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),E(s.object.id)},...e,children:e=>o.jsx(k,{isSelected:r,isEditing:c,annotation:{...s,object:e},pageIndex:a,scale:d,onClick:e=>$(e,s)})},s.object.id):t.isStamp(s)?o.jsx(u,{trackedAnnotation:s,isSelected:r,isDraggable:(null==A?void 0:A.interaction.isDraggable)??!0,isResizable:(null==A?void 0:A.interaction.isResizable)??!0,lockAspectRatio:(null==A?void 0:A.interaction.lockAspectRatio)??!1,selectionMenu:S,onSelect:e=>$(e,s),style:{mixBlendMode:i.blendModeToCss(s.object.blendMode??i.PdfBlendMode.Normal)},...e,children:e=>o.jsx(M,{isSelected:r,annotation:s,documentId:l,pageIndex:a,scale:d,onClick:e=>$(e,s)})},s.object.id):null})})}function w({documentId:e,pageIndex:t,scale:s}){var l,a,d,u,v,b,y,f,m,j,k,S;const{provides:M}=r.useSelectionCapability(),{provides:A}=c(),[w,z]=n.useState([]),[D,P]=n.useState(null),[C,R]=n.useState(null);if(n.useEffect(()=>{if(M)return M.forDocument(e).onSelectionChange(()=>{z(M.forDocument(e).getHighlightRectsForPage(t)),P(M.forDocument(e).getBoundingRectForPage(t))})},[M,e,t]),n.useEffect(()=>{if(A)return R(A.forDocument(e).getActiveTool()),A.forDocument(e).onActiveToolChange(e=>R(e))},[A,e]),!D)return null;if(!C||!C.defaults)return null;switch(C.defaults.type){case i.PdfAnnotationSubtype.UNDERLINE:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(l=C.defaults)?void 0:l.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(h,{color:null==(a=C.defaults)?void 0:a.color,opacity:null==(d=C.defaults)?void 0:d.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.HIGHLIGHT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(u=C.defaults)?void 0:u.blendMode)??i.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(g,{color:null==(v=C.defaults)?void 0:v.color,opacity:null==(b=C.defaults)?void 0:b.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.STRIKEOUT:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(y=C.defaults)?void 0:y.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(p,{color:null==(f=C.defaults)?void 0:f.color,opacity:null==(m=C.defaults)?void 0:m.opacity,segmentRects:w,scale:s})});case i.PdfAnnotationSubtype.SQUIGGLY:return o.jsx("div",{style:{mixBlendMode:i.blendModeToCss((null==(j=C.defaults)?void 0:j.blendMode)??i.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(x,{color:null==(k=C.defaults)?void 0:k.color,opacity:null==(S=C.defaults)?void 0:S.opacity,segmentRects:w,scale:s})});default:return null}}function z({preview:e,scale:t}){const{bounds:n}=e,s={position:"absolute",left:n.origin.x*t,top:n.origin.y*t,width:n.size.width*t,height:n.size.height*t,pointerEvents:"none",zIndex:10};return e.type===i.PdfAnnotationSubtype.CIRCLE?o.jsx("div",{style:s,children:o.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.SQUARE?o.jsx("div",{style:s,children:o.jsx(b,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYGON?o.jsx("div",{style:s,children:o.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.POLYLINE?o.jsx("div",{style:s,children:o.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.LINE?o.jsx("div",{style:s,children:o.jsx(f,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.INK?o.jsx("div",{style:s,children:o.jsx(v,{isSelected:!1,scale:t,...e.data})}):e.type===i.PdfAnnotationSubtype.FREETEXT?o.jsx("div",{style:s,children:o.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function D({documentId:e,pageIndex:t,scale:i}){const{plugin:s}=d(),[r,l]=n.useState(new Map),a=n.useRef(null),c=n.useRef(null),u=n.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const n=a.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const s=i.getContext("2d");if(!s)return;const r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let{naturalWidth:l,naturalHeight:a}=r;const d=t?t/l:1,c=n?n/a:1,u=Math.min(d,c,1),g=l*u,h=a*u;i.width=g,i.height=h,s.drawImage(r,0,0,g,h);const p=s.getImageData(0,0,g,h);"string"!=typeof e&&URL.revokeObjectURL(r.src),o({imageData:p,width:g,height:h})},r.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return n.useEffect(()=>{if(s)return s.registerPageHandlers(e,t,i,{services:u,onPreview:(e,t)=>{l(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,s,u]),o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:a,type:"file",style:{display:"none"}}),o.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(r.entries()).map(([e,t])=>o.jsx(z,{preview:t,scale:i},e))]})}exports.AnnotationLayer=function({style:t,documentId:s,pageIndex:r,scale:l,rotation:a,selectionMenu:d,resizeUI:c,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h,...p}){var x,v,b,y;const f=e.useDocumentState(s),m=null==(v=null==(x=null==f?void 0:f.document)?void 0:x.pages)?void 0:v[r],j=(null==(b=null==m?void 0:m.size)?void 0:b.width)??0,k=(null==(y=null==m?void 0:m.size)?void 0:y.height)??0,S=n.useMemo(()=>void 0!==l?l:(null==f?void 0:f.scale)??1,[l,null==f?void 0:f.scale]),M=n.useMemo(()=>void 0!==a?a:(null==f?void 0:f.rotation)??i.Rotation.Degree0,[a,null==f?void 0:f.rotation]);return o.jsxs("div",{style:{...t},...p,children:[o.jsx(A,{documentId:s,selectionMenu:d,pageIndex:r,scale:S,rotation:M,pageWidth:j,pageHeight:k,resizeUI:c,vertexUI:u,selectionOutlineColor:g,customAnnotationRenderer:h}),o.jsx(w,{documentId:s,pageIndex:r,scale:S}),o.jsx(D,{documentId:s,pageIndex:r,scale:S})]})},exports.useAnnotation=e=>{var o;const{provides:i}=c(),[s,r]=n.useState((null==(o=null==i?void 0:i.forDocument(e))?void 0:o.getState())??t.initialDocumentState());return n.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return r(t.getState()),t.onStateChange(e=>{r(e)})},[i,e]),{state:s,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=c,exports.useAnnotationPlugin=d,Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-annotation"),n=require("react/jsx-runtime"),o=require("react"),i=require("@embedpdf/core/react"),r=require("@embedpdf/models"),s=require("@embedpdf/plugin-interaction-manager/react"),l=require("@embedpdf/plugin-selection/react"),a=require("@embedpdf/utils/react"),c={suppressContentEditableWarning:!0},d=o.createContext(null),u=o.createContext([]);function g({children:e}){const[t,i]=o.useState([]),r=o.useCallback(e=>(i(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>i(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(d.Provider,{value:r,children:n.jsx(u.Provider,{value:t,children:e})})}function p(){return o.useContext(u)}const h=()=>i.usePlugin(t.AnnotationPlugin.id),v=()=>i.useCapability(t.AnnotationPlugin.id);function b({scale:e,documentId:t,pageIndex:r,rotation:s,pageWidth:l,pageHeight:c,trackedAnnotation:d,children:u,isSelected:g,isMultiSelected:p=!1,isDraggable:b,isResizable:x,lockAspectRatio:f=!1,style:y={},vertexConfig:m,selectionMenu:j,outlineOffset:k=1,onDoubleClick:S,onSelect:I,zIndex:M=1,resizeUI:P,vertexUI:z,selectionOutlineColor:R="#007ACC",customAnnotationRenderer:A,groupSelectionMenu:C,annotationRenderers:w,...D}){const[E,B]=o.useState(d.object),{provides:T}=v(),{plugin:$}=h(),{canModifyAnnotations:L}=i.useDocumentPermissions(t),F=o.useRef(null),U=L&&b&&!p,W=L&&x&&!p,O=o.useMemo(()=>T?T.forDocument(t):null,[T,t]),H=E?{...d.object,...E}:d.object,N=(null==P?void 0:P.color)??"#007ACC",q=(null==z?void 0:z.color)??"#007ACC",G=(null==P?void 0:P.size)??12,V=(null==z?void 0:z.size)??12,K=o.useRef(null),Y=o.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||p||!$)return;const{type:o,changes:i,metadata:s}=e.transformData,a=d.object.id,u={width:l,height:c};if("start"===e.state&&(K.current=d.object.rect,F.current=d.object,"move"===o?$.startDrag(t,{annotationIds:[a],pageSize:u}):"resize"===o&&$.startResize(t,{annotationIds:[a],pageSize:u,resizeHandle:(null==s?void 0:s.handle)??"se"})),i.rect&&K.current)if("move"===o){const e={x:i.rect.origin.x-K.current.origin.x,y:i.rect.origin.y-K.current.origin.y};$.updateDrag(t,e)}else"resize"===o&&$.updateResize(t,i.rect);if("vertex-edit"===o&&i.vertices&&m){const t=F.current??d.object,n=m.transformAnnotation(t,i.vertices),l=null==T?void 0:T.transformAnnotation(t,{type:o,changes:n,metadata:s});l&&(B(e=>({...e,...l})),"end"===e.state&&(null==O||O.updateAnnotation(r,a,l)))}"end"===e.state&&(K.current=null,F.current=null,"move"===o?$.commitDrag(t):"resize"===o&&$.commitResize(t))},[$,t,d.object,l,c,r,p,m,T,O]),{dragProps:Q,vertices:X,resize:Z}=a.useInteractionHandles({controller:{element:H.rect,vertices:null==m?void 0:m.extractVertices(H),constraints:{minWidth:10,minHeight:10,boundingBox:{width:l,height:c}},maintainAspectRatio:f,pageRotation:s,scale:e,enabled:g&&!p,onUpdate:Y},resizeUI:{handleSize:G,spacing:k,offsetMode:"outside",includeSides:!f,zIndex:M+1},vertexUI:{vertexSize:V,zIndex:M+2},includeVertices:!!m}),J=o.useMemo(()=>{if(L&&S)return S},[L,S]),_=a.useDoublePressProps(J);o.useEffect(()=>{B(d.object)},[d.object]),o.useEffect(()=>{if(!$)return;const e=d.object.id,n=n=>{var o;if(n.documentId!==t)return;const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?B(e=>({...e,...i})):"cancel"===n.type&&B(d.object)},o=[$.onDragChange(n),$.onResizeChange(n)];return()=>o.forEach(e=>e())},[$,t,d.object]);const ee=g&&!p;return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsxs("div",{...U&&g?Q:{},..._,style:{position:"absolute",left:H.rect.origin.x*e,top:H.rect.origin.y*e,width:H.rect.size.width*e,height:H.rect.size.height*e,outline:ee?`1px solid ${R}`:"none",outlineOffset:ee?`${k}px`:"0px",pointerEvents:g&&!p?"auto":"none",touchAction:"none",cursor:g&&U?"move":"default",zIndex:M,...y},...D,children:[(()=>{const t="function"==typeof u?u(H):u,n=null==A?void 0:A({annotation:H,children:t,isSelected:g,scale:e,rotation:s,pageWidth:l,pageHeight:c,pageIndex:r,onSelect:I});return null!=n?n:t})(),g&&W&&Z.map(({key:e,...t})=>(null==P?void 0:P.component)?P.component({key:e,...t,backgroundColor:N}):n.jsx("div",{...t,style:{...t.style,backgroundColor:N}},e)),g&&L&&!p&&X.map(({key:e,...t})=>(null==z?void 0:z.component)?z.component({key:e,...t,backgroundColor:q}):n.jsx("div",{...t,style:{...t.style,backgroundColor:q}},e))]}),j&&!p&&n.jsx(a.CounterRotate,{rect:{origin:{x:H.rect.origin.x*e,y:H.rect.origin.y*e},size:{width:H.rect.size.width*e,height:H.rect.size.height*e}},rotation:s,children:e=>j({...e,context:{type:"annotation",annotation:d,pageIndex:r},selected:g,placement:{suggestTop:!1}})})]})}function x({documentId:e,pageIndex:t,scale:s,rotation:l,pageWidth:c,pageHeight:d,selectedAnnotations:u,isDraggable:g,isResizable:p,resizeUI:v,selectionOutlineColor:b="#007ACC",outlineOffset:x=2,zIndex:f=100,groupSelectionMenu:y}){const{plugin:m}=h(),{canModifyAnnotations:j}=i.useDocumentPermissions(e),k=o.useRef(null),S=o.useRef(!1),I=o.useRef(!1),M=j&&g,P=j&&p,z=o.useMemo(()=>{const e=u.map(e=>e.object.rect);return r.boundingRectOrEmpty(e)},[u]),[R,A]=o.useState(z);o.useEffect(()=>{S.current||I.current||A(z)},[z]);const C=o.useCallback(t=>{var n,o;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!m)return;const i=t.transformData.type,r="move"===i,s="resize"===i;if(r&&!M)return;"start"===t.state&&(k.current=z,r?(S.current=!0,m.startDrag(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:c,height:d}})):s&&(I.current=!0,m.startResize(e,{annotationIds:u.map(e=>e.object.id),pageSize:{width:c,height:d},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"})));const l=k.current??z;if(r&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-l.origin.x,y:n.origin.y-l.origin.y},i=m.updateDrag(e,o);A({...l,origin:{x:l.origin.x+i.x,y:l.origin.y+i.y}})}else if(s&&t.transformData.changes.rect){const n=t.transformData.changes.rect;m.updateResize(e,n),A(n)}"end"===t.state&&(k.current=null,r&&S.current?(S.current=!1,m.commitDrag(e)):s&&I.current&&(I.current=!1,m.commitResize(e)))},[m,e,c,d,z,M,u]),w=(null==v?void 0:v.color)??"#007ACC",D=(null==v?void 0:v.size)??12,{dragProps:E,resize:B}=a.useInteractionHandles({controller:{element:R,constraints:{minWidth:20,minHeight:20,boundingBox:{width:c,height:d}},maintainAspectRatio:!1,pageRotation:l,scale:s,enabled:!0,onUpdate:C},resizeUI:{handleSize:D,spacing:x,offsetMode:"outside",includeSides:!0,zIndex:f+1},vertexUI:{vertexSize:0,zIndex:f},includeVertices:!1});return u.length<2?null:n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsx("div",{...M?E:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:R.origin.x*s,top:R.origin.y*s,width:R.size.width*s,height:R.size.height*s,outline:`2px dashed ${b}`,outlineOffset:x-1,cursor:M?"move":"default",touchAction:"none",zIndex:f},children:P&&B.map(({key:e,...t})=>(null==v?void 0:v.component)?v.component({key:e,...t,backgroundColor:w}):n.jsx("div",{...t,style:{...t.style,backgroundColor:w}},e))}),y&&n.jsx(a.CounterRotate,{rect:{origin:{x:R.origin.x*s,y:R.origin.y*s},size:{width:R.size.width*s,height:R.size.height*s}},rotation:l,children:e=>y({...e,context:{type:"group",annotations:u,pageIndex:t},selected:!0,placement:{suggestTop:!1}})})]})}function f({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00";return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:a,opacity:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...l}},o))})}function y({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:c,background:a,opacity:t,pointerEvents:"none"}})},o))})}function m({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:l}){const a=e??"#FFFF00",c=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:c,background:a,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function j({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:l}){const a=2*r,c=6*r,d=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${c}" height="${2*a}" viewBox="0 0 ${c} ${2*a}">\n <path d="M0 ${a} Q ${c/4} 0 ${c/2} ${a} T ${c} ${a}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown:s,onTouchStart:s,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*r,top:(i?e.origin.y-i.origin.y:e.origin.y)*r,width:e.size.width*r,height:e.size.height*r,background:"transparent",pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:d,backgroundRepeat:"repeat-x",backgroundSize:`${c}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},o))})}function k({isSelected:e,strokeColor:t,opacity:i=1,strokeWidth:r,inkList:s,rect:l,scale:a,onClick:c}){const d=t??"#000000",u=o.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-l.origin.x,r=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+r+" "}),t.trim()}),[s,l]),g=l.size.width*a,p=l.size.height*a;return n.jsx("svg",{style:{position:"absolute",width:g,height:p,pointerEvents:"none",zIndex:2,overflow:"visible"},width:g,height:p,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:u.map((t,o)=>n.jsx("path",{d:t,fill:"none",opacity:i,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:d,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},o))})}function S({isSelected:e,color:t="#000000",strokeColor:i,opacity:s=1,strokeWidth:l,strokeStyle:a=r.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:g}){const{width:p,height:h,x:v,y:b}=o.useMemo(()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}},[d,l]),x=(p+l)*u,f=(h+l)*u;return n.jsx("svg",{style:{position:"absolute",width:x,height:f,pointerEvents:"none",zIndex:2},width:x,height:f,viewBox:`0 0 ${p+l} ${h+l}`,children:n.jsx("rect",{x:v,y:b,width:p,height:h,fill:t,opacity:s,onPointerDown:g,onTouchStart:g,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:i??t,strokeWidth:l,...a===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function I({color:e="#000000",strokeColor:t,opacity:i=1,strokeWidth:s,strokeStyle:l=r.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:g}){const{width:p,height:h,cx:v,cy:b,rx:x,ry:f}=o.useMemo(()=>{const e=c.size.width,t=c.size.height,n=Math.max(e-s,0),o=Math.max(t-s,0);return{width:e,height:t,cx:s/2+n/2,cy:s/2+o/2,rx:n/2,ry:o/2}},[c,s]),y=p*d,m=h*d;return n.jsx("svg",{style:{position:"absolute",width:y,height:m,pointerEvents:"none",zIndex:2},width:y,height:m,viewBox:`0 0 ${p} ${h}`,children:n.jsx("ellipse",{cx:v,cy:b,rx:x,ry:f,fill:e,opacity:i,onPointerDown:u,onTouchStart:u,style:{cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:s,...l===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function M({color:e="transparent",opacity:i=1,strokeWidth:s,strokeColor:l="#000000",strokeStyle:a=r.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:g,scale:p,onClick:h,isSelected:v}){const{x1:b,y1:x,x2:f,y2:y}=o.useMemo(()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y}),[u,d]),m=o.useMemo(()=>{const e=Math.atan2(y-x,f-b);return{start:t.patching.createEnding(null==g?void 0:g.start,s,e+Math.PI,b,x),end:t.patching.createEnding(null==g?void 0:g.end,s,e,f,y)}},[g,s,b,x,f,y]),j=d.size.width*p,k=d.size.height*p;return n.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:b,y1:x,x2:f,y2:y,opacity:i,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":"visibleStroke",stroke:l,strokeWidth:s,strokeLinecap:"butt",...a===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&n.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:h,onTouchStart:h,stroke:l,style:{cursor:v?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:v?"none":m.start.filled?"visible":"visibleStroke",...a===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&n.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:v?"none":m.end.filled?"visible":"visibleStroke",...a===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function P({rect:e,vertices:i,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:g}){const p=o.useMemo(()=>i.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[i,e]),h=o.useMemo(()=>{if(!p.length)return"";const[e,...t]=p;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[p]),v=o.useMemo(()=>{if(p.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(p[0],p[1]),o=e(p[p.length-2],p[p.length-1]);return{start:t.patching.createEnding(null==g?void 0:g.start,a,n+Math.PI,p[0].x,p[0].y),end:t.patching.createEnding(null==g?void 0:g.end,a,o,p[p.length-1].x,p[p.length-1].y)}},[p,g,a]),b=e.size.width*c,x=e.size.height*c;return n.jsxs("svg",{style:{position:"absolute",width:b,height:x,pointerEvents:"none",zIndex:2,overflow:"visible"},width:b,height:x,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:h,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.start&&n.jsx("path",{d:v.start.d,transform:v.start.transform,stroke:s,fill:v.start.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":v.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),v.end&&n.jsx("path",{d:v.end.d,transform:v.end.transform,stroke:s,fill:v.end.filled?r:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":v.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function z({rect:e,vertices:t,color:i="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:a,strokeStyle:c=r.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:g,onClick:p,currentVertex:h,handleSize:v=14}){const b=h?[...t,h]:t,x=o.useMemo(()=>b.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[b,e]),f=o.useMemo(()=>{if(!x.length)return"";const[e,...t]=x,n=!!h;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[x,h]),y=h&&t.length>0,m=e.size.width*u,j=e.size.height*u;return n.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:f,onPointerDown:p,onTouchStart:p,opacity:l,style:{fill:h?"none":i,stroke:s??i,strokeWidth:a,cursor:g?"move":"pointer",pointerEvents:g?"none":"transparent"===i?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===r.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),y&&t.length>1&&n.jsx("path",{d:`M ${x[x.length-1].x} ${x[x.length-1].y} L ${x[0].x} ${x[0].y}`,fill:"none",style:{stroke:s,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),y&&t.length>=2&&n.jsx("rect",{x:x[0].x-v/u/2,y:x[0].y-v/u/2,width:v/u,height:v/u,fill:s,opacity:.4,stroke:s,strokeWidth:a/2})]})}function R({isSelected:e,isEditing:t,annotation:i,pageIndex:s,scale:l,onClick:a}){const d=o.useRef(null),{provides:u}=v(),[g,p]=o.useState(!1);o.useEffect(()=>{if(t&&d.current){const e=d.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}},[t]),o.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}},[]);const h=i.object.fontSize*l,b=g&&t&&h>0&&h<16,x=b?16:h,f=b?h/16:1,y=b?100/f:100;return n.jsx("div",{style:{position:"absolute",width:i.object.rect.size.width*l,height:i.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:a,onTouchStart:a,children:n.jsx("span",{ref:d,onBlur:()=>{u&&d.current&&u.updateAnnotation(s,i.object.id,{contents:d.current.innerText})},tabIndex:0,style:{color:i.object.fontColor,fontSize:x,fontFamily:r.standardFontCss(i.object.fontFamily),textAlign:r.textAlignmentToCss(i.object.textAlign),flexDirection:"column",justifyContent:i.object.verticalAlign===r.PdfVerticalAlignment.Top?"flex-start":i.object.verticalAlign===r.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:i.object.color??i.object.backgroundColor,opacity:i.object.opacity,width:b?`${y}%`:"100%",height:b?`${y}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:b?`scale(${f})`:void 0,transformOrigin:"top left"},contentEditable:t,...c,children:i.object.contents})})}function A({documentId:e,pageIndex:t,annotation:i,scaleFactor:s=1,style:l,...a}){const{provides:c}=v(),[d,u]=o.useState(null),g=o.useRef(null),{width:p,height:h}=i.rect.size;o.useEffect(()=>{if(c){const n=c.forDocument(e).renderAnnotation({pageIndex:t,annotation:i,options:{scaleFactor:s,dpr:window.devicePixelRatio}});return n.wait(e=>{const t=URL.createObjectURL(e);u(t),g.current=t},r.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:r.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,s,c,e,i.id,p,h]);return n.jsx(o.Fragment,{children:d&&n.jsx("img",{src:d,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function C({isSelected:e,annotation:t,documentId:o,pageIndex:i,scale:r,onClick:s}){return n.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,onTouchStart:s,children:n.jsx(A,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r})})}function w({isSelected:e,strokeColor:t="#0000FF",strokeWidth:i=2,strokeStyle:s=r.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:l,rect:a,scale:c,onClick:d,hasIRT:u=!1}){const{width:g,height:p}=o.useMemo(()=>({width:a.size.width,height:a.size.height}),[a]),h=g*c,v=p*c,b=o.useMemo(()=>{if(s===r.PdfAnnotationBorderStyle.DASHED)return(null==l?void 0:l.join(","))??`${3*i},${i}`},[s,l,i]),x=s===r.PdfAnnotationBorderStyle.UNDERLINE;return n.jsxs("svg",{style:{position:"absolute",width:h,height:v,pointerEvents:"none",zIndex:2},width:h,height:v,viewBox:`0 0 ${g} ${p}`,children:[n.jsx("rect",{x:0,y:0,width:g,height:p,fill:"transparent",onPointerDown:u?void 0:d,onTouchStart:u?void 0:d,style:{cursor:u?"default":e?"move":"pointer",pointerEvents:u||e?"none":"visible"}}),x?n.jsx("line",{x1:1,y1:p-1,x2:g-1,y2:p-1,stroke:t,strokeWidth:i,strokeDasharray:b,style:{pointerEvents:"none"}}):n.jsx("rect",{x:i/2,y:i/2,width:Math.max(g-i,0),height:Math.max(p-i,0),fill:"transparent",stroke:t,strokeWidth:i,strokeDasharray:b,style:{pointerEvents:"none"}})]})}function D(e){const{documentId:i,pageIndex:a,scale:c,pageWidth:d,pageHeight:u,selectionMenu:g}=e,{provides:p}=v(),{provides:h}=l.useSelectionCapability(),[A,D]=o.useState([]),{register:E}=s.usePointerHandlers({documentId:i,pageIndex:a}),[B,T]=o.useState([]),[$,L]=o.useState(null),F=o.useMemo(()=>p?p.forDocument(i):null,[p,i]),U=B.length>1;o.useEffect(()=>{if(F){const e=F.getState();return D(t.getAnnotationsByPageIndex(e,a)),T(t.getSelectedAnnotationIds(e)),F.onStateChange(e=>{D(t.getAnnotationsByPageIndex(e,a)),T(t.getSelectedAnnotationIds(e))})}},[F,a]);const W=o.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&F&&(F.deselectAnnotation(),L(null))}}),[F]),O=o.useCallback((e,t)=>{if(e.stopPropagation(),F&&h){h.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?F.toggleSelection(a,t.object.id):F.selectAnnotation(a,t.object.id),t.object.id!==$&&L(null)}},[F,h,$,a]),H=o.useCallback((e,t)=>{if(e.stopPropagation(),F&&h){if(h.clear(),t.object.inReplyToId){const e=t.object.inReplyToId,n=A.find(t=>t.object.id===e);if(n)return void F.selectAnnotation(n.object.pageIndex,e)}F.selectAnnotation(a,t.object.id)}},[F,h,A,a]);o.useEffect(()=>E(W,{documentId:i}),[E,W]);const N=o.useMemo(()=>A.filter(e=>B.includes(e.object.id)),[A,B]),q=o.useMemo(()=>!(N.length<2)&&N.every(e=>{const n=null==F?void 0:F.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isDraggable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupDraggable)?o:i}),[N,F]),G=o.useMemo(()=>!(N.length<2)&&N.every(e=>{const n=null==F?void 0:F.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isResizable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupResizable)?o:i}),[N,F]),V=o.useMemo(()=>{if(!F)return!1;const e=F.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===a)},[F,a,B]);return n.jsxs(n.Fragment,{children:[A.map(s=>{const l=B.includes(s.object.id),d=$===s.object.id,u=null==F?void 0:F.findToolForAnnotation(s.object);for(const o of e.annotationRenderers??[]){const i=o.tryRender(s,{isSelected:l,scale:c,pageIndex:a,onClick:e=>O(e,s)});if(i)return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:()=>i},s.object.id)}if(t.isInk(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(k,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isSquare(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(S,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isCircle(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(I,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isUnderline(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),zIndex:0,style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(y,{...e,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isStrikeout(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),zIndex:0,style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(m,{...e,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isSquiggly(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),zIndex:0,style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(j,{...e,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isHighlight(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),zIndex:0,style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Multiply)},...e,children:e=>n.jsx(f,{...e,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isLine(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(o.Fragment,{children:n.jsx(M,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})})},s.object.id);if(t.isPolyline(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(o.Fragment,{children:n.jsx(P,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})})},s.object.id);if(t.isPolygon(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(o.Fragment,{children:n.jsx(z,{...e,isSelected:l,scale:c,onClick:e=>O(e,s)})})},s.object.id);if(t.isFreeText(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0)&&!d,isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),L(s.object.id)},...e,children:e=>n.jsx(R,{isSelected:l,isEditing:d,annotation:{...s,object:e},pageIndex:a,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isStamp(s))return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,s.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,s.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,s.object,!1),selectionMenu:g,onSelect:e=>O(e,s),style:{mixBlendMode:r.blendModeToCss(s.object.blendMode??r.PdfBlendMode.Normal)},...e,children:e=>n.jsx(C,{isSelected:l,annotation:s,documentId:i,pageIndex:a,scale:c,onClick:e=>O(e,s)})},s.object.id);if(t.isLink(s)){const t=!!s.object.inReplyToId;return n.jsx(b,{trackedAnnotation:s,isSelected:l,isMultiSelected:U,isDraggable:!1,isResizable:!1,lockAspectRatio:!1,selectionMenu:t?void 0:g,onSelect:e=>H(e,s),...e,children:e=>n.jsx(w,{...e,isSelected:l,scale:c,onClick:e=>H(e,s),hasIRT:t})},s.object.id)}return null}),V&&N.length>=2&&n.jsx(x,{documentId:i,pageIndex:a,scale:c,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:N,isDraggable:q,isResizable:G,resizeUI:e.resizeUI,selectionOutlineColor:e.selectionOutlineColor,groupSelectionMenu:e.groupSelectionMenu})]})}function E({documentId:e,pageIndex:t,scale:i}){var s,a,c,d,u,g,p,h,b,x,k,S;const{provides:I}=l.useSelectionCapability(),{provides:M}=v(),[P,z]=o.useState([]),[R,A]=o.useState(null),[C,w]=o.useState(null);if(o.useEffect(()=>{if(I)return I.forDocument(e).onSelectionChange(()=>{z(I.forDocument(e).getHighlightRectsForPage(t)),A(I.forDocument(e).getBoundingRectForPage(t))})},[I,e,t]),o.useEffect(()=>{if(M)return w(M.forDocument(e).getActiveTool()),M.forDocument(e).onActiveToolChange(e=>w(e))},[M,e]),!R)return null;if(!C||!C.defaults)return null;switch(C.defaults.type){case r.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:r.blendModeToCss((null==(s=C.defaults)?void 0:s.blendMode)??r.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(y,{strokeColor:null==(a=C.defaults)?void 0:a.strokeColor,opacity:null==(c=C.defaults)?void 0:c.opacity,segmentRects:P,scale:i})});case r.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:r.blendModeToCss((null==(d=C.defaults)?void 0:d.blendMode)??r.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(f,{strokeColor:null==(u=C.defaults)?void 0:u.strokeColor,opacity:null==(g=C.defaults)?void 0:g.opacity,segmentRects:P,scale:i})});case r.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:r.blendModeToCss((null==(p=C.defaults)?void 0:p.blendMode)??r.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(m,{strokeColor:null==(h=C.defaults)?void 0:h.strokeColor,opacity:null==(b=C.defaults)?void 0:b.opacity,segmentRects:P,scale:i})});case r.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:r.blendModeToCss((null==(x=C.defaults)?void 0:x.blendMode)??r.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(j,{strokeColor:null==(k=C.defaults)?void 0:k.strokeColor,opacity:null==(S=C.defaults)?void 0:S.opacity,segmentRects:P,scale:i})});default:return null}}function B({preview:e,scale:t}){const{bounds:o}=e,i={position:"absolute",left:o.origin.x*t,top:o.origin.y*t,width:o.size.width*t,height:o.size.height*t,pointerEvents:"none",zIndex:10};return e.type===r.PdfAnnotationSubtype.CIRCLE?n.jsx("div",{style:i,children:n.jsx(I,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.SQUARE?n.jsx("div",{style:i,children:n.jsx(S,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.POLYGON?n.jsx("div",{style:i,children:n.jsx(z,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.POLYLINE?n.jsx("div",{style:i,children:n.jsx(P,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.LINE?n.jsx("div",{style:i,children:n.jsx(M,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.INK?n.jsx("div",{style:i,children:n.jsx(k,{isSelected:!1,scale:t,...e.data})}):e.type===r.PdfAnnotationSubtype.FREETEXT?n.jsx("div",{style:i,children:n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function T({documentId:e,pageIndex:t,scale:i}){const{plugin:r}=h(),[s,l]=o.useState(new Map),a=o.useRef(null),c=o.useRef(null),d=o.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const n=a.current;n.accept=e,n.onchange=e=>{var o;const i=null==(o=e.target.files)?void 0:o[0];i&&(t(i),n.value="")},n.click()},processImage:({source:e,maxWidth:t,maxHeight:n,onComplete:o})=>{const i=c.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const s=new Image;s.crossOrigin="Anonymous",s.onload=()=>{let{naturalWidth:l,naturalHeight:a}=s;const c=t?t/l:1,d=n?n/a:1,u=Math.min(c,d,1),g=l*u,p=a*u;i.width=g,i.height=p,r.drawImage(s,0,0,g,p);const h=r.getImageData(0,0,g,p);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:h,width:g,height:p})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return o.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,i,{services:d,onPreview:(e,t)=>{l(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,i,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:a,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(B,{preview:t,scale:i},e))]})}const $=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(g).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:s,scale:l,rotation:a,selectionMenu:c,groupSelectionMenu:d,resizeUI:u,vertexUI:g,selectionOutlineColor:h,customAnnotationRenderer:v,annotationRenderers:b,...x}){var f,y,m,j;const k=i.useDocumentState(t),S=null==(y=null==(f=null==k?void 0:k.document)?void 0:f.pages)?void 0:y[s],I=(null==(m=null==S?void 0:S.size)?void 0:m.width)??0,M=(null==(j=null==S?void 0:S.size)?void 0:j.height)??0,P=p(),z=o.useMemo(()=>{const e=[...P];for(const t of b??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[P,b]),R=o.useMemo(()=>void 0!==l?l:(null==k?void 0:k.scale)??1,[l,null==k?void 0:k.scale]),A=o.useMemo(()=>void 0!==a?a:(null==k?void 0:k.rotation)??r.Rotation.Degree0,[a,null==k?void 0:k.rotation]);return n.jsxs("div",{style:{...e},...x,children:[n.jsx(D,{documentId:t,selectionMenu:c,groupSelectionMenu:d,pageIndex:s,scale:R,rotation:A,pageWidth:I,pageHeight:M,resizeUI:u,vertexUI:g,selectionOutlineColor:h,customAnnotationRenderer:v,annotationRenderers:z}),n.jsx(E,{documentId:t,pageIndex:s,scale:R}),n.jsx(T,{documentId:t,pageIndex:s,scale:R})]})},exports.AnnotationPluginPackage=$,exports.AnnotationRendererProvider=g,exports.GroupSelectionBox=x,exports.createRenderer=function(e){return{id:e.id,tryRender:(t,n)=>e.matches(t.object)?e.render({...n,annotation:t}):null}},exports.useAnnotation=e=>{var n;const{provides:i}=v(),[r,s]=o.useState((null==(n=null==i?void 0:i.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return o.useEffect(()=>{if(!i)return;const t=i.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[i,e]),{state:r,provides:(null==i?void 0:i.forDocument(e))??null}},exports.useAnnotationCapability=v,exports.useAnnotationPlugin=h,exports.useRegisterRenderers=function(e){const t=o.useContext(d),n=o.useRef(e);o.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=p,exports.useRendererRegistry=function(){return o.useContext(d)},Object.keys(t).forEach(e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
2
2
  //# sourceMappingURL=index.cjs.map