@embedpdf/plugin-annotation 2.6.2 → 2.8.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +538 -90
- package/dist/index.js.map +1 -1
- package/dist/lib/actions.d.ts +12 -1
- package/dist/lib/annotation-plugin.d.ts +19 -0
- package/dist/lib/handlers/index.d.ts +4 -0
- package/dist/lib/handlers/insert-text.handler.d.ts +8 -0
- package/dist/lib/handlers/replace-text.handler.d.ts +9 -0
- package/dist/lib/handlers/selection-utils.d.ts +7 -0
- package/dist/lib/handlers/text-markup.handler.d.ts +7 -0
- package/dist/lib/handlers/text.handler.d.ts +3 -0
- package/dist/lib/handlers/types.d.ts +12 -0
- package/dist/lib/helpers.d.ts +2 -1
- package/dist/lib/selectors.d.ts +6 -1
- package/dist/lib/tools/default-tools.d.ts +153 -6
- package/dist/lib/tools/tools-utils.d.ts +2 -0
- package/dist/lib/tools/types.d.ts +4 -0
- package/dist/lib/types.d.ts +19 -2
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +1258 -1074
- package/dist/preact/index.js.map +1 -1
- package/dist/react/index.cjs +1 -1
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +1258 -1074
- package/dist/react/index.js.map +1 -1
- package/dist/shared/annotation-bounds.d.ts +14 -0
- package/dist/shared/components/annotation-container.d.ts +11 -5
- package/dist/shared/components/annotations/caret.d.ts +24 -0
- package/dist/shared/components/annotations/circle.d.ts +6 -4
- package/dist/shared/components/annotations/free-text.d.ts +6 -3
- package/dist/shared/components/annotations/ink.d.ts +5 -3
- package/dist/shared/components/annotations/line.d.ts +5 -3
- package/dist/shared/components/annotations/link.d.ts +2 -2
- package/dist/shared/components/annotations/polygon.d.ts +5 -4
- package/dist/shared/components/annotations/polyline.d.ts +10 -4
- package/dist/shared/components/annotations/square.d.ts +6 -4
- package/dist/shared/components/annotations/stamp.d.ts +2 -2
- package/dist/shared/components/annotations/text.d.ts +14 -0
- package/dist/shared/components/annotations.d.ts +0 -1
- package/dist/shared/components/appearance-image.d.ts +12 -0
- package/dist/shared/components/built-in-renderers.d.ts +2 -0
- package/dist/shared/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared/components/text-markup/underline.d.ts +5 -3
- package/dist/shared/components/types.d.ts +67 -11
- package/dist/shared-preact/annotation-bounds.d.ts +14 -0
- package/dist/shared-preact/components/annotation-container.d.ts +11 -5
- package/dist/shared-preact/components/annotations/caret.d.ts +24 -0
- package/dist/shared-preact/components/annotations/circle.d.ts +6 -4
- package/dist/shared-preact/components/annotations/free-text.d.ts +6 -3
- package/dist/shared-preact/components/annotations/ink.d.ts +5 -3
- package/dist/shared-preact/components/annotations/line.d.ts +5 -3
- package/dist/shared-preact/components/annotations/link.d.ts +2 -2
- package/dist/shared-preact/components/annotations/polygon.d.ts +5 -4
- package/dist/shared-preact/components/annotations/polyline.d.ts +10 -4
- package/dist/shared-preact/components/annotations/square.d.ts +6 -4
- package/dist/shared-preact/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-preact/components/annotations/text.d.ts +14 -0
- package/dist/shared-preact/components/annotations.d.ts +0 -1
- package/dist/shared-preact/components/appearance-image.d.ts +12 -0
- package/dist/shared-preact/components/built-in-renderers.d.ts +2 -0
- package/dist/shared-preact/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared-preact/components/text-markup/underline.d.ts +5 -3
- package/dist/shared-preact/components/types.d.ts +67 -11
- package/dist/shared-react/annotation-bounds.d.ts +14 -0
- package/dist/shared-react/components/annotation-container.d.ts +11 -5
- package/dist/shared-react/components/annotations/caret.d.ts +24 -0
- package/dist/shared-react/components/annotations/circle.d.ts +6 -4
- package/dist/shared-react/components/annotations/free-text.d.ts +6 -3
- package/dist/shared-react/components/annotations/ink.d.ts +5 -3
- package/dist/shared-react/components/annotations/line.d.ts +5 -3
- package/dist/shared-react/components/annotations/link.d.ts +2 -2
- package/dist/shared-react/components/annotations/polygon.d.ts +5 -4
- package/dist/shared-react/components/annotations/polyline.d.ts +10 -4
- package/dist/shared-react/components/annotations/square.d.ts +6 -4
- package/dist/shared-react/components/annotations/stamp.d.ts +2 -2
- package/dist/shared-react/components/annotations/text.d.ts +14 -0
- package/dist/shared-react/components/annotations.d.ts +0 -1
- package/dist/shared-react/components/appearance-image.d.ts +12 -0
- package/dist/shared-react/components/built-in-renderers.d.ts +2 -0
- package/dist/shared-react/components/text-markup/highlight.d.ts +5 -3
- package/dist/shared-react/components/text-markup/squiggly.d.ts +5 -3
- package/dist/shared-react/components/text-markup/strikeout.d.ts +5 -3
- package/dist/shared-react/components/text-markup/underline.d.ts +5 -3
- package/dist/shared-react/components/types.d.ts +67 -11
- package/dist/shared-vue/annotation-bounds.d.ts +14 -0
- package/dist/svelte/components/Annotations.svelte.d.ts +0 -7
- package/dist/svelte/components/AppearanceImage.svelte.d.ts +8 -0
- package/dist/svelte/components/annotations/Caret.svelte.d.ts +13 -0
- package/dist/svelte/components/annotations/Circle.svelte.d.ts +2 -11
- package/dist/svelte/components/annotations/FreeText.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Ink.svelte.d.ts +2 -2
- package/dist/svelte/components/annotations/Line.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Link.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Polygon.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Polyline.svelte.d.ts +5 -3
- package/dist/svelte/components/annotations/Square.svelte.d.ts +2 -1
- package/dist/svelte/components/annotations/Stamp.svelte.d.ts +1 -1
- package/dist/svelte/components/annotations/Text.svelte.d.ts +10 -0
- package/dist/svelte/components/annotations/index.d.ts +1 -0
- package/dist/svelte/components/built-in-renderers.d.ts +2 -0
- package/dist/svelte/components/renderers/CaretRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/CircleRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/FreeTextRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/HighlightRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/InkRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/LineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/LinkRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/PolygonRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/PolylineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/SquareRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/SquigglyRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/StampRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/StrikeoutRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/TextRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/renderers/UnderlineRenderer.svelte.d.ts +5 -0
- package/dist/svelte/components/text-markup/Highlight.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Squiggly.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Strikeout.svelte.d.ts +3 -1
- package/dist/svelte/components/text-markup/Underline.svelte.d.ts +3 -1
- package/dist/svelte/components/types.d.ts +8 -2
- package/dist/svelte/context/renderer-registry.svelte.d.ts +2 -2
- package/dist/svelte/context/types.d.ts +63 -2
- package/dist/svelte/index.cjs +1 -1
- package/dist/svelte/index.cjs.map +1 -1
- package/dist/svelte/index.js +2738 -2890
- package/dist/svelte/index.js.map +1 -1
- package/dist/vue/components/annotation-container.vue.d.ts +7 -2
- package/dist/vue/components/annotation-layer.vue.d.ts +2 -21
- package/dist/vue/components/annotations/caret.vue.d.ts +24 -0
- package/dist/vue/components/annotations/circle.vue.d.ts +19 -6
- package/dist/vue/components/annotations/free-text.vue.d.ts +18 -6
- package/dist/vue/components/annotations/index.d.ts +1 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +17 -7
- package/dist/vue/components/annotations/line.vue.d.ts +21 -6
- package/dist/vue/components/annotations/link.vue.d.ts +24 -6
- package/dist/vue/components/annotations/polygon.vue.d.ts +22 -6
- package/dist/vue/components/annotations/polyline.vue.d.ts +25 -7
- package/dist/vue/components/annotations/square.vue.d.ts +19 -6
- package/dist/vue/components/annotations/stamp.vue.d.ts +12 -6
- package/dist/vue/components/annotations/text.vue.d.ts +14 -0
- package/dist/vue/components/annotations.vue.d.ts +9 -576
- package/dist/vue/components/appearance-image.vue.d.ts +9 -0
- package/dist/vue/components/built-in-renderers.d.ts +2 -0
- package/dist/vue/components/group-selection-box.vue.d.ts +2 -2
- package/dist/vue/components/renderers/caret-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/circle-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/free-text-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/highlight-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/ink-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/line-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/link-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/polygon-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/polyline-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/square-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/squiggly-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/stamp-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/strikeout-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/text-renderer.vue.d.ts +6 -0
- package/dist/vue/components/renderers/underline-renderer.vue.d.ts +6 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +18 -6
- package/dist/vue/components/text-markup/underline.vue.d.ts +18 -6
- package/dist/vue/context/renderer-registry.d.ts +2 -2
- package/dist/vue/context/types.d.ts +63 -2
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.js +1995 -1336
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/preact/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@embedpdf/core"),t=require("@embedpdf/plugin-annotation"),o=require("preact/jsx-runtime"),n=require("preact"),i=require("preact/hooks"),r=require("preact/compat"),l=require("@embedpdf/core/preact"),s=require("@embedpdf/models"),a=require("@embedpdf/plugin-interaction-manager/preact"),c=require("@embedpdf/plugin-selection/preact"),d=require("@embedpdf/utils/preact"),u={},p=n.createContext(null),g=n.createContext([]);function h({children:e}){const[t,n]=i.useState([]),r=i.useCallback(e=>(n(t=>{const o=new Set(e.map(e=>e.id));return[...t.filter(e=>!o.has(e.id)),...e]}),()=>n(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return o.jsx(p.Provider,{value:r,children:o.jsx(g.Provider,{value:t,children:e})})}function v(){return i.useContext(g)}const b=()=>l.usePlugin(t.AnnotationPlugin.id),x=()=>l.useCapability(t.AnnotationPlugin.id);function f({scale:e,documentId:t,pageIndex:n,rotation:a,pageWidth:c,pageHeight:u,trackedAnnotation:p,children:g,isSelected:h,isMultiSelected:v=!1,isDraggable:f,isResizable:y,isRotatable:m=!0,lockAspectRatio:j=!1,style:k={},vertexConfig:S,selectionMenu:I,outlineOffset:R=1,onDoubleClick:P,onSelect:M,zIndex:C=1,resizeUI:z,vertexUI:w,rotationUI:A,selectionOutlineColor:D,selectionOutline:E,customAnnotationRenderer:B,groupSelectionMenu:$,groupSelectionOutline:T,annotationRenderers:L,...F}){var O,U,W;const[H,N]=i.useState(p.object),[q,G]=i.useState(null),[Y,V]=i.useState(null),[X,K]=i.useState(!1),{provides:Q}=x(),{plugin:Z}=b(),{canModifyAnnotations:J}=l.useDocumentPermissions(t),_=i.useRef(null),ee=J&&f&&!v,te=J&&y&&!v,oe=J&&m&&!v,ne=i.useMemo(()=>Q?Q.forDocument(t):null,[Q,t]),ie=H?{...p.object,...H}:p.object,re=(null==z?void 0:z.color)??"#007ACC",le=(null==w?void 0:w.color)??"#007ACC",se=(null==A?void 0:A.color)??"white",ae=(null==A?void 0:A.connectorColor)??"#007ACC",ce=(null==z?void 0:z.size)??12,de=(null==w?void 0:w.size)??12,ue=(null==A?void 0:A.size)??32,pe=null==A?void 0:A.margin,ge=(null==A?void 0:A.iconColor)??"#007ACC",he=(null==A?void 0:A.showConnector)??!1,ve=(null==(O=null==A?void 0:A.border)?void 0:O.color)??"#007ACC",be=(null==(U=null==A?void 0:A.border)?void 0:U.width)??1,xe=(null==(W=null==A?void 0:A.border)?void 0:W.style)??"solid",fe=(null==E?void 0:E.color)??D??"#007ACC",ye=(null==E?void 0:E.style)??"solid",me=(null==E?void 0:E.width)??1,je=(null==E?void 0:E.offset)??R??1,ke=q??ie.rotation??0,Se=q??ie.rotation??0,Ie=Number.isFinite(Se)?Math.round(10*Se)/10:0,Re=null!==q,Pe=i.useRef(null),Me=i.useCallback(e=>{var o;if(!(null==(o=e.transformData)?void 0:o.type)||v||!Z)return;const{type:i,changes:r,metadata:l}=e.transformData,s=p.object.id,a={width:c,height:u};if("start"===e.state&&(Pe.current=p.object.unrotatedRect??p.object.rect,_.current=p.object,"move"===i?Z.startDrag(t,{annotationIds:[s],pageSize:a}):"resize"===i&&Z.startResize(t,{annotationIds:[s],pageSize:a,resizeHandle:(null==l?void 0:l.handle)??"se"})),r.rect&&Pe.current)if("move"===i){const e={x:r.rect.origin.x-Pe.current.origin.x,y:r.rect.origin.y-Pe.current.origin.y};Z.updateDrag(t,e)}else"resize"===i&&Z.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&S){const t=_.current??p.object,o=S.transformAnnotation(t,r.vertices),a=null==Q?void 0:Q.transformAnnotation(t,{type:i,changes:o,metadata:l});a&&(N(e=>({...e,...a})),"end"===e.state&&(null==ne||ne.updateAnnotation(n,s,a)))}if("rotate"===i){const o=(null==l?void 0:l.rotationAngle)??ke,n=null==l?void 0:l.cursorPosition;return n&&V({x:n.clientX,y:n.clientY}),void("start"===e.state?(G(o),Z.startRotation(t,{annotationIds:[s],cursorAngle:o,rotationCenter:null==l?void 0:l.rotationCenter})):"move"===e.state?(G(o),Z.updateRotation(t,o,null==l?void 0:l.rotationDelta)):"end"===e.state&&(G(null),V(null),Z.commitRotation(t)))}"end"===e.state&&(Pe.current=null,_.current=null,"move"===i?Z.commitDrag(t):"resize"===i&&Z.commitResize(t))},[Z,t,p.object,c,u,n,v,S,Q,ne,ke]),Ce=ie.unrotatedRect,ze=Ce??ie.rect,we=Ce&&0!==ke?s.inferRotationCenterFromRects(ze,ie.rect,ke):void 0,Ae=ze,{dragProps:De,vertices:Ee,resize:Be,rotation:$e}=d.useInteractionHandles({controller:{element:Ae,vertices:null==S?void 0:S.extractVertices(ie),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:u}},maintainAspectRatio:j,pageRotation:a,annotationRotation:ke,rotationCenter:we,rotationElement:ie.rect,scale:e,enabled:h&&!v,onUpdate:Me},resizeUI:{handleSize:ce,spacing:je,offsetMode:"outside",includeSides:!j,zIndex:C+1},vertexUI:{vertexSize:de,zIndex:C+2},rotationUI:{handleSize:ue,margin:pe,zIndex:C+3,showConnector:he},includeVertices:!!S,includeRotation:oe,currentRotation:ke}),Te=i.useMemo(()=>{if(J&&P)return P},[J,P]),Le=d.useDoublePressProps(Te);i.useEffect(()=>{N(p.object)},[p.object]),i.useEffect(()=>{if(!Z)return;const e=p.object.id,o=o=>{var n;if(o.documentId!==t)return;"end"!==o.type&&"cancel"!==o.type||G(null);const i=null==(n=o.previewPatches)?void 0:n[e];"update"===o.type&&i?N(e=>({...e,...i})):"cancel"===o.type&&N(p.object)},n=[Z.onDragChange(o),Z.onResizeChange(o),Z.onRotateChange(o)];return()=>n.forEach(e=>e())},[Z,t,p.object]);const Fe=h&&!v,Oe=ie.rect.size.width*e,Ue=ie.rect.size.height*e,We=ze.size.width*e,He=ze.size.height*e,Ne=Boolean(Ce)&&0!==ke,qe=Ne?(ze.origin.x-ie.rect.origin.x)*e:(Oe-We)/2,Ge=Ne?(ze.origin.y-ie.rect.origin.y)*e:(Ue-He)/2,Ye=Ne&&we?`${(we.x-ze.origin.x)*e}px ${(we.y-ze.origin.y)*e}px`:"center center",Ve=we?(we.x-ie.rect.origin.x)*e:Oe/2,Xe=we?(we.y-ie.rect.origin.y)*e:Ue/2,Ke=Math.max(300,Math.max(Oe,Ue)+80),Qe=i.useMemo(()=>Ce?{...ie,rect:Ce}:ie,[ie,Ce]);return o.jsxs("div",{"data-no-interaction":!0,children:[o.jsxs("div",{style:{position:"absolute",left:ie.rect.origin.x*e,top:ie.rect.origin.y*e,width:Oe,height:Ue,pointerEvents:"none",zIndex:C,...k},...F,children:[Re&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{position:"absolute",left:Ve-Ke/2,top:Xe,width:Ke,height:1,backgroundColor:ae,opacity:.35,pointerEvents:"none"}}),o.jsx("div",{style:{position:"absolute",left:Ve,top:Xe-Ke/2,width:1,height:Ke,backgroundColor:ae,opacity:.35,pointerEvents:"none"}}),o.jsx("div",{style:{position:"absolute",left:Ve-Ke/2,top:Xe,width:Ke,height:1,transformOrigin:"center center",transform:`rotate(${ke}deg)`,backgroundColor:ae,opacity:.8,pointerEvents:"none"}})]}),h&&oe&&$e&&((null==A?void 0:A.component)?o.jsx("div",{onPointerEnter:()=>K(!0),onPointerLeave:()=>{K(!1),V(null)},onPointerMove:e=>{Re||V({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:A.component({...$e.handle,backgroundColor:se,iconColor:ge,connectorStyle:{...$e.connector.style,backgroundColor:ae,opacity:Re?0:1},showConnector:he,opacity:Re?0:1,border:{color:ve,width:be,style:xe}})}):o.jsxs("div",{onPointerEnter:()=>K(!0),onPointerLeave:()=>{K(!1),V(null)},onPointerMove:e=>{Re||V({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[he&&o.jsx("div",{style:{...$e.connector.style,backgroundColor:ae,opacity:Re?0:1}}),o.jsx("div",{...$e.handle,style:{...$e.handle.style,backgroundColor:se,border:`${be}px ${xe} ${ve}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Re?0:1},children:o.jsxs("svg",{width:Math.round(.6*ue),height:Math.round(.6*ue),viewBox:"0 0 24 24",fill:"none",stroke:ge,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),o.jsx("path",{d:"M21 3v5h-5"})]})})]})),o.jsxs("div",{...ee&&h?De:{},...Le,style:{position:"absolute",left:qe,top:Ge,width:We,height:He,transform:0!==ke?`rotate(${ke}deg)`:void 0,transformOrigin:Ye,outline:Fe?`${me}px ${ye} ${fe}`:"none",outlineOffset:Fe?`${je}px`:"0px",pointerEvents:h&&!v?"auto":"none",touchAction:"none",cursor:h&&ee?"move":"default"},children:[(()=>{const t="function"==typeof g?g(Qe):g,o=null==B?void 0:B({annotation:Qe,children:t,isSelected:h,scale:e,rotation:a,pageWidth:c,pageHeight:u,pageIndex:n,onSelect:M});return null!=o?o:t})(),h&&te&&!Re&&Be.map(({key:e,...t})=>(null==z?void 0:z.component)?z.component({key:e,...t,backgroundColor:re}):o.jsx("div",{...t,style:{...t.style,backgroundColor:re}},e)),h&&J&&!v&&!Re&&Ee.map(({key:e,...t})=>(null==w?void 0:w.component)?w.component({key:e,...t,backgroundColor:le}):o.jsx("div",{...t,style:{...t.style,backgroundColor:le}},e))]})]}),I&&!v&&!Re&&o.jsx(d.CounterRotate,{rect:{origin:{x:ie.rect.origin.x*e,y:ie.rect.origin.y*e},size:{width:ie.rect.size.width*e,height:ie.rect.size.height*e}},rotation:a,children:e=>{const t=((ke+90*a)%360+360)%360;return I({...e,context:{type:"annotation",annotation:p,pageIndex:n},selected:h,placement:{suggestTop:oe&&t>90&&t<270}})}}),(Re||X)&&Y&&r.createPortal(o.jsxs("div",{style:{position:"fixed",left:Y.x+16,top:Y.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[Ie.toFixed(0),"°"]}),document.body)]})}function y({documentId:e,pageIndex:t,scale:n,rotation:a,pageWidth:c,pageHeight:u,selectedAnnotations:p,isDraggable:g,isResizable:h,isRotatable:v=!0,lockAspectRatio:x=!1,resizeUI:f,rotationUI:y,selectionOutlineColor:m,outlineOffset:j,selectionOutline:k,zIndex:S=2,groupSelectionMenu:I}){var R,P,M;const{plugin:C}=b(),{canModifyAnnotations:z}=l.useDocumentPermissions(e),w=i.useRef(null),A=i.useRef(!1),D=i.useRef(!1),[E,B]=i.useState(null),[$,T]=i.useState(null),[L,F]=i.useState(!1),O=z&&g,U=z&&h,W=z&&v,H=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return s.boundingRectOrEmpty(e)},[p]),[N,q]=i.useState(H);i.useEffect(()=>{A.current||D.current||q(H)},[H]),i.useEffect(()=>{if(!C)return;return C.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||B(null))})},[C,e]);const G=i.useCallback(t=>{var o,n,i,r,l,s;if(!(null==(o=t.transformData)?void 0:o.type))return;if(!C)return;const a=t.transformData.type,d="move"===a,g="resize"===a;if(d&&!O)return;if("start"===t.state&&(w.current=H,d?(A.current=!0,C.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u}})):g&&(D.current=!0,C.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u},resizeHandle:(null==(n=t.transformData.metadata)?void 0:n.handle)??"se"}))),"rotate"===a){if(!v)return;const o=p.map(e=>e.object.id),n=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,a=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return a&&T({x:a.clientX,y:a.clientY}),void("start"===t.state?(B(n),C.startRotation(e,{annotationIds:o,cursorAngle:n,rotationCenter:null==(l=t.transformData.metadata)?void 0:l.rotationCenter})):"move"===t.state?(B(n),C.updateRotation(e,n,null==(s=t.transformData.metadata)?void 0:s.rotationDelta)):"end"===t.state&&(B(null),T(null),C.commitRotation(e)))}const h=w.current??H;if(d&&t.transformData.changes.rect){const o=t.transformData.changes.rect,n={x:o.origin.x-h.origin.x,y:o.origin.y-h.origin.y},i=C.updateDrag(e,n);q({...h,origin:{x:h.origin.x+i.x,y:h.origin.y+i.y}})}else if(g&&t.transformData.changes.rect){const o=t.transformData.changes.rect;C.updateResize(e,o),q(o)}"end"===t.state&&(w.current=null,d&&A.current?(A.current=!1,C.commitDrag(e)):g&&D.current&&(D.current=!1,C.commitResize(e)))},[C,e,c,u,H,O,p,v]),Y=E??0,V=null!==E,X=Number.isFinite(Y)?Math.round(10*Y)/10:0,K=(null==f?void 0:f.color)??"#007ACC",Q=(null==f?void 0:f.size)??12,Z=(null==y?void 0:y.color)??"white",J=(null==y?void 0:y.connectorColor)??"#007ACC",_=(null==y?void 0:y.size)??32,ee=null==y?void 0:y.margin,te=(null==y?void 0:y.iconColor)??"#007ACC",oe=(null==y?void 0:y.showConnector)??!1,ne=(null==(R=null==y?void 0:y.border)?void 0:R.color)??"#007ACC",ie=(null==(P=null==y?void 0:y.border)?void 0:P.width)??1,re=(null==(M=null==y?void 0:y.border)?void 0:M.style)??"solid",le=(null==k?void 0:k.color)??m??"#007ACC",se=(null==k?void 0:k.style)??"dashed",ae=(null==k?void 0:k.width)??2,ce=(null==k?void 0:k.offset)??j??2,{dragProps:de,resize:ue,rotation:pe}=d.useInteractionHandles({controller:{element:N,constraints:{minWidth:20,minHeight:20,boundingBox:{width:c,height:u}},maintainAspectRatio:x,pageRotation:a,scale:n,enabled:!0,onUpdate:G},resizeUI:{handleSize:Q,spacing:ce,offsetMode:"outside",includeSides:!x,zIndex:S+1},vertexUI:{vertexSize:0,zIndex:S},rotationUI:{handleSize:_,margin:ee,zIndex:S+2,showConnector:oe},includeVertices:!1,includeRotation:W,currentRotation:E??0});if(p.length<2)return null;const ge=N.size.width*n,he=N.size.height*n,ve=ge/2,be=he/2,xe=Math.max(300,Math.max(ge,he)+80);return o.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[o.jsxs("div",{style:{position:"absolute",left:N.origin.x*n,top:N.origin.y*n,width:ge,height:he,pointerEvents:"none",zIndex:S},children:[V&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{position:"absolute",left:ve-xe/2,top:be,width:xe,height:1,backgroundColor:K,opacity:.35,pointerEvents:"none"}}),o.jsx("div",{style:{position:"absolute",left:ve,top:be-xe/2,width:1,height:xe,backgroundColor:K,opacity:.35,pointerEvents:"none"}}),o.jsx("div",{style:{position:"absolute",left:ve-xe/2,top:be,width:xe,height:1,transformOrigin:"center center",transform:`rotate(${Y}deg)`,backgroundColor:K,opacity:.8,pointerEvents:"none"}})]}),W&&pe&&((null==y?void 0:y.component)?o.jsx("div",{onPointerEnter:()=>F(!0),onPointerLeave:()=>{F(!1),T(null)},onPointerMove:e=>{V||T({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:y.component({...pe.handle,backgroundColor:Z,iconColor:te,connectorStyle:{...pe.connector.style,backgroundColor:J,opacity:V?0:1},showConnector:oe,opacity:V?0:1,border:{color:ne,width:ie,style:re}})}):o.jsxs("div",{onPointerEnter:()=>F(!0),onPointerLeave:()=>{F(!1),T(null)},onPointerMove:e=>{V||T({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&o.jsx("div",{style:{...pe.connector.style,backgroundColor:J,opacity:V?0:1}}),o.jsx("div",{...pe.handle,style:{...pe.handle.style,backgroundColor:Z,border:`${ie}px ${re} ${ne}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:V?0:1},children:o.jsxs("svg",{width:Math.round(.6*_),height:Math.round(.6*_),viewBox:"0 0 24 24",fill:"none",stroke:te,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),o.jsx("path",{d:"M21 3v5h-5"})]})})]})),o.jsx("div",{...O?de:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:ge,height:he,outline:V?"none":`${ae}px ${se} ${le}`,outlineOffset:ce-1,cursor:O?"move":"default",touchAction:"none",pointerEvents:"auto"},children:U&&!V&&ue.map(({key:e,...t})=>(null==f?void 0:f.component)?f.component({key:e,...t,backgroundColor:K}):o.jsx("div",{...t,style:{...t.style,backgroundColor:K}},e))})]}),(V||L)&&$&&r.createPortal(o.jsxs("div",{style:{position:"fixed",left:$.x+16,top:$.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[X.toFixed(0),"°"]}),document.body),I&&o.jsx(d.CounterRotate,{rect:{origin:{x:N.origin.x*n,y:N.origin.y*n},size:{width:N.size.width*n,height:N.size.height*n}},rotation:a,children:e=>{const o=((Y+90*a)%360+360)%360;return I({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:W&&o>90&&o<270}})}})]})}function m({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:l,style:s}){const a=e??"#FFFF00";return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:l,onTouchStart:l,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:l?"auto":"none",cursor:l?"pointer":"default",zIndex:l?1:void 0,...s}},n))})}function j({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:l,style:s}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:l,onTouchStart:l,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:l?"auto":"none",cursor:l?"pointer":"default",zIndex:l?1:0,...s},children:o.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:c,background:a,opacity:t,pointerEvents:"none"}})},n))})}function k({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:l,style:s}){const a=e??"#FFFF00",c=2*r;return o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:l,onTouchStart:l,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:l?"auto":"none",cursor:l?"pointer":"default",zIndex:l?1:0,...s},children:o.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:c,background:a,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},n))})}function S({strokeColor:e,opacity:t=.5,segmentRects:n,rect:i,scale:r,onClick:l,style:s}){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 o.jsx(o.Fragment,{children:n.map((e,n)=>o.jsx("div",{onPointerDown:l,onTouchStart:l,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:l?"auto":"none",cursor:l?"pointer":"default",zIndex:l?1:0,...s},children:o.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"}})},n))})}function I({isSelected:e,strokeColor:t,opacity:n=1,strokeWidth:r,inkList:l,rect:s,scale:a,onClick:c}){const d=t??"#000000",u=i.useMemo(()=>l.map(({points:e})=>{let t="";return e.forEach(({x:e,y:o},n)=>{const i=e-s.origin.x,r=o-s.origin.y;t+=(0===n?"M":"L")+i+" "+r+" "}),t.trim()}),[l,s]),p=s.size.width*a,g=s.size.height*a;return o.jsx("svg",{style:{position:"absolute",width:p,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:p,height:g,viewBox:`0 0 ${s.size.width} ${s.size.height}`,children:u.map((t,i)=>o.jsx("path",{d:t,fill:"none",opacity:n,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:d,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},i))})}function R({isSelected:e,color:t="#000000",strokeColor:n,opacity:r=1,strokeWidth:l,strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p}){const{width:g,height:h,x:v,y:b}=i.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=(g+l)*u,f=(h+l)*u;return o.jsx("svg",{style:{position:"absolute",width:x,height:f,pointerEvents:"none",zIndex:2},width:x,height:f,viewBox:`0 0 ${g+l} ${h+l}`,children:o.jsx("rect",{x:v,y:b,width:g,height:h,fill:t,opacity:r,onPointerDown:p,onTouchStart:p,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:n??t,strokeWidth:l,...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function P({color:e="#000000",strokeColor:t,opacity:n=1,strokeWidth:r,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:p}){const{width:g,height:h,cx:v,cy:b,rx:x,ry:f}=i.useMemo(()=>{const e=c.size.width,t=c.size.height,o=Math.max(e-r,0),n=Math.max(t-r,0);return{width:e,height:t,cx:r/2+o/2,cy:r/2+n/2,rx:o/2,ry:n/2}},[c,r]),y=g*d,m=h*d;return o.jsx("svg",{style:{position:"absolute",width:y,height:m,pointerEvents:"none",zIndex:2},width:y,height:m,viewBox:`0 0 ${g} ${h}`,children:o.jsx("ellipse",{cx:v,cy:b,rx:x,ry:f,fill:e,opacity:n,onPointerDown:u,onTouchStart:u,style:{cursor:p?"move":"pointer",pointerEvents:p?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:r,...l===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function M({color:e="transparent",opacity:n=1,strokeWidth:r,strokeColor:l="#000000",strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:p,scale:g,onClick:h,isSelected:v}){const{x1:b,y1:x,x2:f,y2:y}=i.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=i.useMemo(()=>{const e=Math.atan2(y-x,f-b);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,b,x),end:t.patching.createEnding(null==p?void 0:p.end,r,e,f,y)}},[p,r,b,x,f,y]),j=d.size.width*g,k=d.size.height*g;return o.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:[o.jsx("line",{x1:b,y1:x,x2:f,y2:y,opacity:n,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&o.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:h,onTouchStart:h,stroke:l,style:{cursor:v?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:v?"none":m.start.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&o.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:h,onTouchStart:h,style:{cursor:v?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:v?"none":m.end.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function C({rect:e,vertices:n,color:r="transparent",strokeColor:l="#000000",opacity:s=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:p}){const g=i.useMemo(()=>n.map(({x:t,y:o})=>({x:t-e.origin.x,y:o-e.origin.y})),[n,e]),h=i.useMemo(()=>{if(!g.length)return"";const[e,...t]=g;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[g]),v=i.useMemo(()=>{if(g.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),o=e(g[0],g[1]),n=e(g[g.length-2],g[g.length-1]);return{start:t.patching.createEnding(null==p?void 0:p.start,a,o+Math.PI,g[0].x,g[0].y),end:t.patching.createEnding(null==p?void 0:p.end,a,n,g[g.length-1].x,g[g.length-1].y)}},[g,p,a]),b=e.size.width*c,x=e.size.height*c;return o.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:[o.jsx("path",{d:h,onPointerDown:u,onTouchStart:u,opacity:s,style:{fill:"none",stroke:l??r,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),v.start&&o.jsx("path",{d:v.start.d,transform:v.start.transform,stroke:l,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&&o.jsx("path",{d:v.end.d,transform:v.end.transform,stroke:l,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:n="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,strokeStyle:c=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:p,onClick:g,currentVertex:h,handleSize:v=14}){const b=h?[...t,h]:t,x=i.useMemo(()=>b.map(({x:t,y:o})=>({x:t-e.origin.x,y:o-e.origin.y})),[b,e]),f=i.useMemo(()=>{if(!x.length)return"";const[e,...t]=x,o=!!h;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(o?"":" Z")).trim()},[x,h]),y=h&&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:f,onPointerDown:g,onTouchStart:g,opacity:l,style:{fill:h?"none":n,stroke:r??n,strokeWidth:a,cursor:p?"move":"pointer",pointerEvents:p?"none":"transparent"===n?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),y&&t.length>1&&o.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:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),y&&t.length>=2&&o.jsx("rect",{x:x[0].x-v/u/2,y:x[0].y-v/u/2,width:v/u,height:v/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function w({isSelected:e,isEditing:t,annotation:n,pageIndex:r,scale:l,onClick:a}){const c=i.useRef(null),{provides:d}=x(),[p,g]=i.useState(!1);i.useEffect(()=>{if(t&&c.current){const e=c.current;e.focus();const t=window.getSelection();if(t){const o=document.createRange();o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o)}}},[t]),i.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;g(t)}catch{g(!1)}},[]);const h=n.object.fontSize*l,v=p&&t&&h>0&&h<16,b=v?16:h,f=v?h/16:1,y=v?100/f:100;return o.jsx("div",{style:{position:"absolute",width:n.object.rect.size.width*l,height:n.object.rect.size.height*l,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:a,onTouchStart:a,children:o.jsx("span",{ref:c,onBlur:()=>{d&&c.current&&d.updateAnnotation(r,n.object.id,{contents:c.current.innerText})},tabIndex:0,style:{color:n.object.fontColor,fontSize:b,...s.standardFontCssProperties(n.object.fontFamily),textAlign:s.textAlignmentToCss(n.object.textAlign),flexDirection:"column",justifyContent:n.object.verticalAlign===s.PdfVerticalAlignment.Top?"flex-start":n.object.verticalAlign===s.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:n.object.color??n.object.backgroundColor,opacity:n.object.opacity,width:v?`${y}%`:"100%",height:v?`${y}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:v?`scale(${f})`:void 0,transformOrigin:"top left"},contentEditable:t,...u,children:n.object.contents})})}function A({documentId:e,pageIndex:t,annotation:r,scaleFactor:l=1,unrotated:a,style:c,...d}){const{provides:u}=x(),[p,g]=i.useState(null),h=i.useRef(null),{width:v,height:b}=r.rect.size;i.useEffect(()=>{if(u){const o=u.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:l,dpr:window.devicePixelRatio,unrotated:a}});return o.wait(e=>{const t=URL.createObjectURL(e);g(t),h.current=t},s.ignore),()=>{h.current?(URL.revokeObjectURL(h.current),h.current=null):o.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,l,a,u,e,r.id,v,b]);return o.jsx(n.Fragment,{children:p&&o.jsx("img",{src:p,onLoad:()=>{h.current&&(URL.revokeObjectURL(h.current),h.current=null)},...d,style:{width:"100%",height:"100%",display:"block",...c||{}}})})}function D({isSelected:e,annotation:t,documentId:n,pageIndex:i,scale:r,onClick:l}){const s=!!t.object.rotation&&!!t.object.unrotatedRect;return o.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:l,onTouchStart:l,children:o.jsx(A,{documentId:n,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:s})})}function E({isSelected:e,strokeColor:t="#0000FF",strokeWidth:n=2,strokeStyle:r=s.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:l,rect:a,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:g}=i.useMemo(()=>({width:a.size.width,height:a.size.height}),[a]),h=p*c,v=g*c,b=i.useMemo(()=>{if(r===s.PdfAnnotationBorderStyle.DASHED)return(null==l?void 0:l.join(","))??`${3*n},${n}`},[r,l,n]),x=r===s.PdfAnnotationBorderStyle.UNDERLINE;return o.jsxs("svg",{style:{position:"absolute",width:h,height:v,pointerEvents:"none",zIndex:2},width:h,height:v,viewBox:`0 0 ${p} ${g}`,children:[o.jsx("rect",{x:0,y:0,width:p,height:g,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?o.jsx("line",{x1:1,y1:g-1,x2:p-1,y2:g-1,stroke:t,strokeWidth:n,strokeDasharray:b,style:{pointerEvents:"none"}}):o.jsx("rect",{x:n/2,y:n/2,width:Math.max(p-n,0),height:Math.max(g-n,0),fill:"transparent",stroke:t,strokeWidth:n,strokeDasharray:b,style:{pointerEvents:"none"}})]})}function B(e){const{documentId:r,pageIndex:l,scale:d,pageWidth:u,pageHeight:p,selectionMenu:g}=e,{provides:h}=x(),{provides:v}=c.useSelectionCapability(),[b,A]=i.useState([]),{register:B}=a.usePointerHandlers({documentId:r,pageIndex:l}),[$,T]=i.useState([]),[L,F]=i.useState(null),O=i.useMemo(()=>h?h.forDocument(r):null,[h,r]),U=$.length>1;i.useEffect(()=>{if(O){const e=O.getState();return A(t.getAnnotationsByPageIndex(e,l)),T(t.getSelectedAnnotationIds(e)),O.onStateChange(e=>{A(t.getAnnotationsByPageIndex(e,l)),T(t.getSelectedAnnotationIds(e))})}},[O,l]);const W=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&O&&(O.deselectAnnotation(),F(null))}}),[O]),H=i.useCallback((e,t)=>{if(e.stopPropagation(),O&&v){v.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?O.toggleSelection(l,t.object.id):O.selectAnnotation(l,t.object.id),t.object.id!==L&&F(null)}},[O,v,L,l]),N=i.useCallback((e,t)=>{if(e.stopPropagation(),O&&v){if(v.clear(),t.object.inReplyToId){const e=t.object.inReplyToId,o=b.find(t=>t.object.id===e);if(o)return void O.selectAnnotation(o.object.pageIndex,e)}O.selectAnnotation(l,t.object.id)}},[O,v,b,l]);i.useEffect(()=>B(W,{documentId:r}),[B,W]);const q=i.useMemo(()=>b.filter(e=>$.includes(e.object.id)),[b,$]),G=i.useMemo(()=>!(q.length<2)&&q.every(e=>{const o=null==O?void 0:O.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.isGroupDraggable,e.object,!0),i=t.resolveInteractionProp(null==o?void 0:o.interaction.isDraggable,e.object,!0);return void 0!==(null==o?void 0:o.interaction.isGroupDraggable)?n:i}),[q,O]),Y=i.useMemo(()=>!(q.length<2)&&q.every(e=>{const o=null==O?void 0:O.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.isGroupResizable,e.object,!0),i=t.resolveInteractionProp(null==o?void 0:o.interaction.isResizable,e.object,!0);return void 0!==(null==o?void 0:o.interaction.isGroupResizable)?n:i}),[q,O]),V=i.useMemo(()=>!(q.length<2)&&q.every(e=>{const o=null==O?void 0:O.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==o?void 0:o.interaction.isRotatable,e.object,!0);return void 0!==(null==o?void 0:o.interaction.isGroupRotatable)?n:i}),[q,O]),X=i.useMemo(()=>!(q.length<2)&&q.some(e=>{const o=null==O?void 0:O.findToolForAnnotation(e.object),n=t.resolveInteractionProp(null==o?void 0:o.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==o?void 0:o.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==o?void 0:o.interaction.lockGroupAspectRatio)?n:i}),[q,O]),K=i.useMemo(()=>{if(!O)return!1;const e=O.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===l)},[O,l,$]);return o.jsxs(o.Fragment,{children:[b.map(i=>{const a=$.includes(i.object.id),c=L===i.object.id,u=null==O?void 0:O.findToolForAnnotation(i.object);for(const n of e.annotationRenderers??[]){const r=n.tryRender(i,{isSelected:a,scale:d,pageIndex:l,onClick:e=>H(e,i)});if(r)return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!1),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:()=>r},i.object.id)}if(t.isInk(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(I,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isSquare(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(R,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isCircle(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(P,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isUnderline(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!1),selectionMenu:g,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(j,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isStrikeout(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!1),selectionMenu:g,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(k,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isSquiggly(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!1),selectionMenu:g,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(S,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isHighlight(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!1),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!1),selectionMenu:g,onSelect:e=>H(e,i),zIndex:0,style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Multiply)},...e,children:e=>o.jsx(m,{...e,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isLine(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(M,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isPolyline(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(C,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isPolygon(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!1),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(n.Fragment,{children:o.jsx(z,{...e,isSelected:a,scale:d,onClick:e=>H(e,i)})})},i.object.id);if(t.isFreeText(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0)&&!c,isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),F(i.object.id)},...e,children:e=>o.jsx(w,{isSelected:a,isEditing:c,annotation:{...i,object:e},pageIndex:l,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isStamp(i))return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:t.resolveInteractionProp(null==u?void 0:u.interaction.isDraggable,i.object,!0),isResizable:t.resolveInteractionProp(null==u?void 0:u.interaction.isResizable,i.object,!0),lockAspectRatio:t.resolveInteractionProp(null==u?void 0:u.interaction.lockAspectRatio,i.object,!1),isRotatable:t.resolveInteractionProp(null==u?void 0:u.interaction.isRotatable,i.object,!0),selectionMenu:g,onSelect:e=>H(e,i),style:{mixBlendMode:s.blendModeToCss(i.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>o.jsx(D,{isSelected:a,annotation:i,documentId:r,pageIndex:l,scale:d,onClick:e=>H(e,i)})},i.object.id);if(t.isLink(i)){const t=!!i.object.inReplyToId;return o.jsx(f,{trackedAnnotation:i,isSelected:a,isMultiSelected:U,isDraggable:!1,isResizable:!1,lockAspectRatio:!1,isRotatable:!1,selectionMenu:t?void 0:g,onSelect:e=>N(e,i),...e,children:e=>o.jsx(E,{...e,isSelected:a,scale:d,onClick:e=>N(e,i),hasIRT:t})},i.object.id)}return null}),K&&q.length>=2&&o.jsx(y,{documentId:r,pageIndex:l,scale:d,rotation:e.rotation,pageWidth:u,pageHeight:p,selectedAnnotations:q,isDraggable:G,isResizable:Y,isRotatable:V,lockAspectRatio:X,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function $({documentId:e,pageIndex:t,scale:n}){var r,l,a,d,u,p,g,h,v,b,f,y;const{provides:I}=c.useSelectionCapability(),{provides:R}=x(),[P,M]=i.useState([]),[C,z]=i.useState(null),[w,A]=i.useState(null);if(i.useEffect(()=>{if(I)return I.forDocument(e).onSelectionChange(()=>{M(I.forDocument(e).getHighlightRectsForPage(t)),z(I.forDocument(e).getBoundingRectForPage(t))})},[I,e,t]),i.useEffect(()=>{if(R)return A(R.forDocument(e).getActiveTool()),R.forDocument(e).onActiveToolChange(e=>A(e))},[R,e]),!C)return null;if(!w||!w.defaults)return null;switch(w.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(r=w.defaults)?void 0:r.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(j,{strokeColor:null==(l=w.defaults)?void 0:l.strokeColor,opacity:null==(a=w.defaults)?void 0:a.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.HIGHLIGHT:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(d=w.defaults)?void 0:d.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(m,{strokeColor:null==(u=w.defaults)?void 0:u.strokeColor,opacity:null==(p=w.defaults)?void 0:p.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.STRIKEOUT:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(g=w.defaults)?void 0:g.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(k,{strokeColor:null==(h=w.defaults)?void 0:h.strokeColor,opacity:null==(v=w.defaults)?void 0:v.opacity,segmentRects:P,scale:n})});case s.PdfAnnotationSubtype.SQUIGGLY:return o.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(b=w.defaults)?void 0:b.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:o.jsx(S,{strokeColor:null==(f=w.defaults)?void 0:f.strokeColor,opacity:null==(y=w.defaults)?void 0:y.opacity,segmentRects:P,scale:n})});default:return null}}function T({preview:e,scale:t}){const{bounds:n}=e,i={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===s.PdfAnnotationSubtype.CIRCLE?o.jsx("div",{style:i,children:o.jsx(P,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.SQUARE?o.jsx("div",{style:i,children:o.jsx(R,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYGON?o.jsx("div",{style:i,children:o.jsx(z,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYLINE?o.jsx("div",{style:i,children:o.jsx(C,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.LINE?o.jsx("div",{style:i,children:o.jsx(M,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.INK?o.jsx("div",{style:i,children:o.jsx(I,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.FREETEXT?o.jsx("div",{style:i,children:o.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function L({documentId:e,pageIndex:t,scale:n}){const{plugin:r}=b(),[l,s]=i.useState(new Map),a=i.useRef(null),c=i.useRef(null),d=i.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!a.current)return;const o=a.current;o.accept=e,o.onchange=e=>{var n;const i=null==(n=e.target.files)?void 0:n[0];i&&(t(i),o.value="")},o.click()},processImage:({source:e,maxWidth:t,maxHeight:o,onComplete:n})=>{const i=c.current;if(!i||!i.getContext)return;const r=i.getContext("2d");if(!r)return;const l=new Image;l.crossOrigin="Anonymous",l.onload=()=>{let{naturalWidth:s,naturalHeight:a}=l;const c=t?t/s:1,d=o?o/a:1,u=Math.min(c,d,1),p=s*u,g=a*u;i.width=p,i.height=g,r.drawImage(l,0,0,p,g);const h=r.getImageData(0,0,p,g);"string"!=typeof e&&URL.revokeObjectURL(l.src),n({imageData:h,width:p,height:g})},l.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,n,{services:d,onPreview:(e,t)=>{s(o=>{const n=new Map(o);return t?n.set(e,t):n.delete(e),n})}})},[e,t,n,r,d]),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(l.entries()).map(([e,t])=>o.jsx(T,{preview:t,scale:n},e))]})}const F=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(h).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:n,scale:r,rotation:s,selectionMenu:a,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:g,selectionOutline:h,groupSelectionOutline:b,customAnnotationRenderer:x,annotationRenderers:f,...y}){var m,j,k,S;const I=l.useDocumentState(t),R=null==(j=null==(m=null==I?void 0:I.document)?void 0:m.pages)?void 0:j[n],P=(null==(k=null==R?void 0:R.size)?void 0:k.width)??0,M=(null==(S=null==R?void 0:R.size)?void 0:S.height)??0,C=v(),z=i.useMemo(()=>{const e=[...C];for(const t of f??[]){const o=e.findIndex(e=>e.id===t.id);o>=0?e[o]=t:e.push(t)}return e},[C,f]),w=i.useMemo(()=>void 0!==r?r:(null==I?void 0:I.scale)??1,[r,null==I?void 0:I.scale]),A=i.useMemo(()=>{if(void 0!==s)return s;return(((null==R?void 0:R.rotation)??0)+((null==I?void 0:I.rotation)??0))%4},[s,null==R?void 0:R.rotation,null==I?void 0:I.rotation]);return o.jsxs("div",{style:{...e},...y,children:[o.jsx(B,{documentId:t,selectionMenu:a,groupSelectionMenu:c,pageIndex:n,scale:w,rotation:A,pageWidth:P,pageHeight:M,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:g,selectionOutline:h,groupSelectionOutline:b,customAnnotationRenderer:x,annotationRenderers:z}),o.jsx($,{documentId:t,pageIndex:n,scale:w}),o.jsx(L,{documentId:t,pageIndex:n,scale:w})]})},exports.AnnotationPluginPackage=F,exports.AnnotationRendererProvider=h,exports.GroupSelectionBox=y,exports.createRenderer=function(e){return{id:e.id,tryRender:(t,o)=>e.matches(t.object)?e.render({...o,annotation:t}):null}},exports.useAnnotation=e=>{var o;const{provides:n}=x(),[r,l]=i.useState((null==(o=null==n?void 0:n.forDocument(e))?void 0:o.getState())??t.initialDocumentState());return i.useEffect(()=>{if(!n)return;const t=n.forDocument(e);return l(t.getState()),t.onStateChange(e=>{l(e)})},[n,e]),{state:r,provides:(null==n?void 0:n.forDocument(e))??null}},exports.useAnnotationCapability=x,exports.useAnnotationPlugin=b,exports.useRegisterRenderers=function(e){const t=i.useContext(p),o=i.useRef(e);i.useEffect(()=>{if(t)return t(o.current)},[t])},exports.useRegisteredRenderers=v,exports.useRendererRegistry=function(){return i.useContext(p)},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("preact/jsx-runtime"),o=require("preact"),i=require("preact/hooks"),r=require("preact/compat"),s=require("@embedpdf/core/preact"),a=require("@embedpdf/models"),l=require("@embedpdf/plugin-interaction-manager/preact"),c=require("@embedpdf/plugin-selection/preact"),d=require("@embedpdf/utils/preact"),u=require("@embedpdf/utils"),p={},h=o.createContext(null),g=o.createContext([]);function v({children:e}){const[t,o]=i.useState([]),r=i.useCallback(e=>(o(t=>{const n=new Set(e.map(e=>e.id));return[...t.filter(e=>!n.has(e.id)),...e]}),()=>o(t=>t.filter(t=>!e.some(e=>e.id===t.id)))),[]);return n.jsx(h.Provider,{value:r,children:n.jsx(g.Provider,{value:t,children:e})})}function x(){return i.useContext(g)}const y=()=>s.usePlugin(t.AnnotationPlugin.id),f=()=>s.useCapability(t.AnnotationPlugin.id);function b({appearance:e,style:t}){const[o,r]=i.useState(null),s=i.useRef(null);i.useEffect(()=>{const t=URL.createObjectURL(e.data);return r(t),s.current=t,()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)}},[e.data]);return o?n.jsx("img",{src:o,onLoad:()=>{s.current&&(URL.revokeObjectURL(s.current),s.current=null)},style:{position:"absolute",width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none",...t}}):null}function m({scale:e,documentId:t,pageIndex:o,rotation:l,pageWidth:c,pageHeight:p,trackedAnnotation:h,children:g,isSelected:v,isEditing:x=!1,isMultiSelected:m=!1,isDraggable:k,isResizable:j,isRotatable:S=!0,lockAspectRatio:C=!1,style:A={},vertexConfig:w,selectionMenu:R,outlineOffset:I=1,onDoubleClick:D,onSelect:z,appearance:P,zIndex:E=1,resizeUI:M,vertexUI:L,rotationUI:$,selectionOutlineColor:O,selectionOutline:F,customAnnotationRenderer:U,groupSelectionMenu:W,groupSelectionOutline:B,annotationRenderers:T,...H}){var N,G,q;const[Y,V]=i.useState(h.object),[X,K]=i.useState(null),[Q,Z]=i.useState(null),[J,_]=i.useState(!1),[ee,te]=i.useState(!1),{provides:ne}=f(),{plugin:oe}=y(),{canModifyAnnotations:ie}=s.useDocumentPermissions(t),re=i.useRef(null),se=ie&&k&&!m,ae=ie&&j&&!m,le=ie&&S&&!m,ce=i.useMemo(()=>ne?ne.forDocument(t):null,[ne,t]),de=Y?{...h.object,...Y}:h.object,ue=h.object.flags??[],pe=ue.includes("noZoom"),he=ue.includes("noRotate"),ge=pe?1:e,ve=he?0:l,xe=(null==M?void 0:M.color)??"#007ACC",ye=(null==L?void 0:L.color)??"#007ACC",fe=(null==$?void 0:$.color)??"white",be=(null==$?void 0:$.connectorColor)??"#007ACC",me=(null==M?void 0:M.size)??12,ke=(null==L?void 0:L.size)??12,je=(null==$?void 0:$.size)??32,Se=null==$?void 0:$.margin,Ce=(null==$?void 0:$.iconColor)??"#007ACC",Ae=(null==$?void 0:$.showConnector)??!1,we=(null==(N=null==$?void 0:$.border)?void 0:N.color)??"#007ACC",Re=(null==(G=null==$?void 0:$.border)?void 0:G.width)??1,Ie=(null==(q=null==$?void 0:$.border)?void 0:q.style)??"solid",De=(null==F?void 0:F.color)??O??"#007ACC",ze=(null==F?void 0:F.style)??"solid",Pe=(null==F?void 0:F.width)??1,Ee=(null==F?void 0:F.offset)??I??1,Me=X??de.rotation??0,Le=X??de.rotation??0,$e=Number.isFinite(Le)?Math.round(10*Le)/10:0,Oe=null!==X,Fe=i.useRef(null),Ue=i.useCallback(e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type)||m||!oe)return;const{type:i,changes:r,metadata:s}=e.transformData,a=h.object.id,l={width:c,height:p};if("start"===e.state&&(Fe.current=h.object.unrotatedRect??h.object.rect,re.current=h.object,"resize"!==i&&"vertex-edit"!==i||te(!0),"move"===i?oe.startDrag(t,{annotationIds:[a],pageSize:l}):"resize"===i&&oe.startResize(t,{annotationIds:[a],pageSize:l,resizeHandle:(null==s?void 0:s.handle)??"se"})),r.rect&&Fe.current)if("move"===i){const e={x:r.rect.origin.x-Fe.current.origin.x,y:r.rect.origin.y-Fe.current.origin.y};oe.updateDrag(t,e)}else"resize"===i&&oe.updateResize(t,r.rect);if("vertex-edit"===i&&r.vertices&&w){const t=re.current??h.object,n=w.transformAnnotation(t,r.vertices),l=null==ne?void 0:ne.transformAnnotation(t,{type:i,changes:n,metadata:s});l&&(V(e=>({...e,...l})),"end"===e.state&&(null==ce||ce.updateAnnotation(o,a,l)))}if("rotate"===i){const n=(null==s?void 0:s.rotationAngle)??Me,o=null==s?void 0:s.cursorPosition;return o&&Z({x:o.clientX,y:o.clientY}),void("start"===e.state?(K(n),oe.startRotation(t,{annotationIds:[a],cursorAngle:n,rotationCenter:null==s?void 0:s.rotationCenter})):"move"===e.state?(K(n),oe.updateRotation(t,n,null==s?void 0:s.rotationDelta)):"end"===e.state&&(K(null),Z(null),oe.commitRotation(t)))}"end"===e.state&&(Fe.current=null,re.current=null,te(!1),"move"===i?oe.commitDrag(t):"resize"===i&&oe.commitResize(t))},[oe,t,h.object,c,p,o,m,w,ne,ce,Me]),We=de.unrotatedRect,Be=We??de.rect,Te=We&&0!==Me?a.inferRotationCenterFromRects(Be,de.rect,Me):void 0,He=Be,{dragProps:Ne,vertices:Ge,resize:qe,rotation:Ye}=d.useInteractionHandles({controller:{element:He,vertices:null==w?void 0:w.extractVertices(de),constraints:{minWidth:10,minHeight:10,boundingBox:{width:c,height:p}},maintainAspectRatio:C,pageRotation:l,annotationRotation:Me,rotationCenter:Te,rotationElement:de.rect,scale:e,enabled:v&&!m,onUpdate:Ue},resizeUI:{handleSize:me,spacing:Ee,offsetMode:"outside",includeSides:!C,zIndex:E+1},vertexUI:{vertexSize:ke,zIndex:E+2},rotationUI:{handleSize:je,margin:Se,zIndex:E+3,showConnector:Ae},includeVertices:!!w,includeRotation:le,currentRotation:Me}),Ve=i.useMemo(()=>{if(ie&&D)return D},[ie,D]),Xe=d.useDoublePressProps(Ve);i.useEffect(()=>{V(h.object)},[h.object]),i.useEffect(()=>{if(!oe)return;const e=h.object.id,n=n=>{var o;if(n.documentId!==t)return;"end"!==n.type&&"cancel"!==n.type||K(null);const i=null==(o=n.previewPatches)?void 0:o[e];"update"===n.type&&i?V(e=>({...e,...i})):"cancel"===n.type&&V(h.object)},o=[oe.onDragChange(n),oe.onResizeChange(n),oe.onRotateChange(n)];return()=>o.forEach(e=>e())},[oe,t,h.object]);const Ke=v&&!m,Qe=de.rect.size.width*ge,Ze=de.rect.size.height*ge,Je=Be.size.width*ge,_e=Be.size.height*ge,et=Boolean(We)&&0!==Me,tt=et?(Be.origin.x-de.rect.origin.x)*ge:(Qe-Je)/2,nt=et?(Be.origin.y-de.rect.origin.y)*ge:(Ze-_e)/2,ot=et&&Te?`${(Te.x-Be.origin.x)*ge}px ${(Te.y-Be.origin.y)*ge}px`:"center center",it=Te?(Te.x-de.rect.origin.x)*ge:Qe/2,rt=Te?(Te.y-de.rect.origin.y)*ge:Ze/2,st=Math.max(300,Math.max(Qe,Ze)+80),at=he?u.getCounterRotation({origin:{x:0,y:0},size:{width:Qe,height:Ze}},l):null,lt=i.useMemo(()=>We?{...de,rect:We}:de,[de,We]),ct=!(!(null==P?void 0:P.normal)||ee||x||h.dictMode);return n.jsxs("div",{"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:de.rect.origin.x*e,top:de.rect.origin.y*e,width:at?at.width:Qe,height:at?at.height:Ze,pointerEvents:"none",zIndex:E,...at&&{transform:at.matrix,transformOrigin:"0 0"},...A},...H,children:[Oe&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:it-st/2,top:rt,width:st,height:1,backgroundColor:be,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:it,top:rt-st/2,width:1,height:st,backgroundColor:be,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:it-st/2,top:rt,width:st,height:1,transformOrigin:"center center",transform:`rotate(${Me}deg)`,backgroundColor:be,opacity:.8,pointerEvents:"none"}})]}),v&&le&&Ye&&((null==$?void 0:$.component)?n.jsx("div",{onPointerEnter:()=>_(!0),onPointerLeave:()=>{_(!1),Z(null)},onPointerMove:e=>{Oe||Z({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:$.component({...Ye.handle,backgroundColor:fe,iconColor:Ce,connectorStyle:{...Ye.connector.style,backgroundColor:be,opacity:Oe?0:1},showConnector:Ae,opacity:Oe?0:1,border:{color:we,width:Re,style:Ie}})}):n.jsxs("div",{onPointerEnter:()=>_(!0),onPointerLeave:()=>{_(!1),Z(null)},onPointerMove:e=>{Oe||Z({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[Ae&&n.jsx("div",{style:{...Ye.connector.style,backgroundColor:be,opacity:Oe?0:1}}),n.jsx("div",{...Ye.handle,style:{...Ye.handle.style,backgroundColor:fe,border:`${Re}px ${Ie} ${we}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:Oe?0:1},children:n.jsxs("svg",{width:Math.round(.6*je),height:Math.round(.6*je),viewBox:"0 0 24 24",fill:"none",stroke:Ce,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsxs("div",{...se&&v?Ne:{},...Xe,style:{position:"absolute",left:tt,top:nt,width:Je,height:_e,transform:0!==Me?`rotate(${Me}deg)`:void 0,transformOrigin:ot,outline:Ke?`${Pe}px ${ze} ${De}`:"none",outlineOffset:Ke?`${Ee}px`:"0px",pointerEvents:v&&!m?"auto":"none",touchAction:"none",cursor:v&&se?"move":"default"},children:[(()=>{const t="function"==typeof g?g(lt,{appearanceActive:ct}):g;return(null==U?void 0:U({annotation:lt,children:t,isSelected:v,scale:e,rotation:l,pageWidth:c,pageHeight:p,pageIndex:o,onSelect:z}))??t})(),(null==P?void 0:P.normal)&&n.jsx(b,{appearance:P.normal,style:{display:ct?"block":"none"}}),v&&ae&&!Oe&&qe.map(({key:e,...t})=>(null==M?void 0:M.component)?M.component({key:e,...t,backgroundColor:xe}):n.jsx("div",{...t,style:{...t.style,backgroundColor:xe}},e)),v&&ie&&!m&&!Oe&&Ge.map(({key:e,...t})=>(null==L?void 0:L.component)?L.component({key:e,...t,backgroundColor:ye}):n.jsx("div",{...t,style:{...t.style,backgroundColor:ye}},e))]})]}),R&&!m&&!Oe&&n.jsx(d.CounterRotate,{rect:{origin:{x:de.rect.origin.x*e,y:de.rect.origin.y*e},size:{width:de.rect.size.width*ge,height:de.rect.size.height*ge}},rotation:l,children:e=>{const t=((Me+90*ve)%360+360)%360;return R({...e,context:{type:"annotation",annotation:h,pageIndex:o},selected:v,placement:{suggestTop:le&&t>90&&t<270}})}}),(Oe||J)&&Q&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:Q.x+16,top:Q.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[$e.toFixed(0),"°"]}),document.body)]})}function k(e,t,n,o,i){switch(i){case 1:return{x:t,y:o-e};case 2:return{x:n-e,y:o-t};case 3:return{x:n-t,y:e};default:return{x:e,y:t}}}function j(e,t,n){const o=e.object.flags??[],i=o.includes("noZoom"),r=o.includes("noRotate"),s=e.object.rect.origin.x*t,a=e.object.rect.origin.y*t,l=e.object.rect.size.width*(i?1:t),c=e.object.rect.size.height*(i?1:t);if(!r||0===n)return{left:s,top:a,right:s+l,bottom:a+c};const d=[k(0,0,l,c,n),k(l,0,l,c,n),k(0,c,l,c,n),k(l,c,l,c,n)];let u=1/0,p=1/0,h=-1/0,g=-1/0;for(const v of d)v.x<u&&(u=v.x),v.y<p&&(p=v.y),v.x>h&&(h=v.x),v.y>g&&(g=v.y);return{left:s+u,top:a+p,right:s+h,bottom:a+g}}function S({documentId:e,pageIndex:t,scale:o,rotation:l,pageWidth:c,pageHeight:u,selectedAnnotations:p,isDraggable:h,isResizable:g,isRotatable:v=!0,lockAspectRatio:x=!1,resizeUI:f,rotationUI:b,selectionOutlineColor:m,outlineOffset:k,selectionOutline:S,zIndex:C=2,groupSelectionMenu:A}){var w,R,I;const{plugin:D}=y(),{canModifyAnnotations:z}=s.useDocumentPermissions(e),P=i.useRef(null),E=i.useRef(!1),M=i.useRef(!1),[L,$]=i.useState(null),[O,F]=i.useState(null),[U,W]=i.useState(!1),B=z&&h,T=z&&g,H=z&&v,N=i.useMemo(()=>{const e=p.map(e=>e.object.rect);return a.boundingRectOrEmpty(e)},[p]),[G,q]=i.useState(N);i.useEffect(()=>{E.current||M.current||q(N)},[N]),i.useEffect(()=>{if(!D)return;return D.onRotateChange(t=>{t.documentId===e&&("end"!==t.type&&"cancel"!==t.type||$(null))})},[D,e]);const Y=i.useCallback(t=>{var n,o,i,r,s,a;if(!(null==(n=t.transformData)?void 0:n.type))return;if(!D)return;const l=t.transformData.type,d="move"===l,h="resize"===l;if(d&&!B)return;if("start"===t.state&&(P.current=N,d?(E.current=!0,D.startDrag(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u}})):h&&(M.current=!0,D.startResize(e,{annotationIds:p.map(e=>e.object.id),pageSize:{width:c,height:u},resizeHandle:(null==(o=t.transformData.metadata)?void 0:o.handle)??"se"}))),"rotate"===l){if(!v)return;const n=p.map(e=>e.object.id),o=(null==(i=t.transformData.metadata)?void 0:i.rotationAngle)??0,l=null==(r=t.transformData.metadata)?void 0:r.cursorPosition;return l&&F({x:l.clientX,y:l.clientY}),void("start"===t.state?($(o),D.startRotation(e,{annotationIds:n,cursorAngle:o,rotationCenter:null==(s=t.transformData.metadata)?void 0:s.rotationCenter})):"move"===t.state?($(o),D.updateRotation(e,o,null==(a=t.transformData.metadata)?void 0:a.rotationDelta)):"end"===t.state&&($(null),F(null),D.commitRotation(e)))}const g=P.current??N;if(d&&t.transformData.changes.rect){const n=t.transformData.changes.rect,o={x:n.origin.x-g.origin.x,y:n.origin.y-g.origin.y},i=D.updateDrag(e,o);q({...g,origin:{x:g.origin.x+i.x,y:g.origin.y+i.y}})}else if(h&&t.transformData.changes.rect){const n=t.transformData.changes.rect;D.updateResize(e,n),q(n)}"end"===t.state&&(P.current=null,d&&E.current?(E.current=!1,D.commitDrag(e)):h&&M.current&&(M.current=!1,D.commitResize(e)))},[D,e,c,u,N,B,p,v]),V=L??0,X=null!==L,K=Number.isFinite(V)?Math.round(10*V)/10:0,Q=(null==f?void 0:f.color)??"#007ACC",Z=(null==f?void 0:f.size)??12,J=(null==b?void 0:b.color)??"white",_=(null==b?void 0:b.connectorColor)??"#007ACC",ee=(null==b?void 0:b.size)??32,te=null==b?void 0:b.margin,ne=(null==b?void 0:b.iconColor)??"#007ACC",oe=(null==b?void 0:b.showConnector)??!1,ie=(null==(w=null==b?void 0:b.border)?void 0:w.color)??"#007ACC",re=(null==(R=null==b?void 0:b.border)?void 0:R.width)??1,se=(null==(I=null==b?void 0:b.border)?void 0:I.style)??"solid",ae=(null==S?void 0:S.color)??m??"#007ACC",le=(null==S?void 0:S.style)??"dashed",ce=(null==S?void 0:S.width)??2,de=(null==S?void 0:S.offset)??k??2,{dragProps:ue,resize:pe,rotation:he}=d.useInteractionHandles({controller:{element:G,constraints:{minWidth:20,minHeight:20,boundingBox:{width:c,height:u}},maintainAspectRatio:x,pageRotation:l,scale:o,enabled:!0,onUpdate:Y},resizeUI:{handleSize:Z,spacing:de,offsetMode:"outside",includeSides:!x,zIndex:C+1},vertexUI:{vertexSize:0,zIndex:C},rotationUI:{handleSize:ee,margin:te,zIndex:C+2,showConnector:oe},includeVertices:!1,includeRotation:H,currentRotation:L??0});if(p.length<2)return null;let ge=1/0,ve=1/0,xe=-1/0,ye=-1/0;for(const n of p){const e=j(n,o,l);ge=Math.min(ge,e.left),ve=Math.min(ve,e.top),xe=Math.max(xe,e.right),ye=Math.max(ye,e.bottom)}const fe=ge-N.origin.x*o,be=ve-N.origin.y*o,me=xe-(N.origin.x+N.size.width)*o,ke=ye-(N.origin.y+N.size.height)*o,je=G.origin.x*o+fe,Se=G.origin.y*o+be,Ce=G.size.width*o+(me-fe),Ae=G.size.height*o+(ke-be),we=Ce/2,Re=Ae/2,Ie=Math.max(300,Math.max(Ce,Ae)+80);return n.jsxs("div",{"data-group-selection-box":!0,"data-no-interaction":!0,children:[n.jsxs("div",{style:{position:"absolute",left:je,top:Se,width:Ce,height:Ae,pointerEvents:"none",zIndex:C},children:[X&&n.jsxs(n.Fragment,{children:[n.jsx("div",{style:{position:"absolute",left:we-Ie/2,top:Re,width:Ie,height:1,backgroundColor:Q,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we,top:Re-Ie/2,width:1,height:Ie,backgroundColor:Q,opacity:.35,pointerEvents:"none"}}),n.jsx("div",{style:{position:"absolute",left:we-Ie/2,top:Re,width:Ie,height:1,transformOrigin:"center center",transform:`rotate(${V}deg)`,backgroundColor:Q,opacity:.8,pointerEvents:"none"}})]}),H&&he&&((null==b?void 0:b.component)?n.jsx("div",{onPointerEnter:()=>W(!0),onPointerLeave:()=>{W(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:b.component({...he.handle,backgroundColor:J,iconColor:ne,connectorStyle:{...he.connector.style,backgroundColor:_,opacity:X?0:1},showConnector:oe,opacity:X?0:1,border:{color:ie,width:re,style:se}})}):n.jsxs("div",{onPointerEnter:()=>W(!0),onPointerLeave:()=>{W(!1),F(null)},onPointerMove:e=>{X||F({x:e.clientX,y:e.clientY})},style:{display:"contents"},children:[oe&&n.jsx("div",{style:{...he.connector.style,backgroundColor:_,opacity:X?0:1}}),n.jsx("div",{...he.handle,style:{...he.handle.style,backgroundColor:J,border:`${re}px ${se} ${ie}`,boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",opacity:X?0:1},children:n.jsxs("svg",{width:Math.round(.6*ee),height:Math.round(.6*ee),viewBox:"0 0 24 24",fill:"none",stroke:ne,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[n.jsx("path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8"}),n.jsx("path",{d:"M21 3v5h-5"})]})})]})),n.jsx("div",{...B?ue:{onPointerDown:e=>e.stopPropagation()},style:{position:"absolute",left:0,top:0,width:Ce,height:Ae,outline:X?"none":`${ce}px ${le} ${ae}`,outlineOffset:de-1,cursor:B?"move":"default",touchAction:"none",pointerEvents:"auto"},children:T&&!X&&pe.map(({key:e,...t})=>(null==f?void 0:f.component)?f.component({key:e,...t,backgroundColor:Q}):n.jsx("div",{...t,style:{...t.style,backgroundColor:Q}},e))})]}),(X||U)&&O&&r.createPortal(n.jsxs("div",{style:{position:"fixed",left:O.x+16,top:O.y-16,background:"rgba(0,0,0,0.8)",color:"#fff",padding:"4px 8px",borderRadius:4,fontSize:12,fontFamily:"monospace",pointerEvents:"none",zIndex:1e4,whiteSpace:"nowrap"},children:[K.toFixed(0),"°"]}),document.body),A&&n.jsx(d.CounterRotate,{rect:{origin:{x:je,y:Se},size:{width:Ce,height:Ae}},rotation:l,children:e=>{const n=((V+90*l)%360+360)%360;return A({...e,context:{type:"group",annotations:p,pageIndex:t},selected:!0,placement:{suggestTop:H&&n>90&&n<270}})}})]})}function C(e){return{id:e.id,matches:t=>e.matches(t),render:t=>e.render(t),vertexConfig:e.vertexConfig,zIndex:e.zIndex,containerStyle:e.containerStyle,interactionDefaults:e.interactionDefaults,useAppearanceStream:e.useAppearanceStream,isDraggable:e.isDraggable,onDoubleClick:e.onDoubleClick,selectOverride:e.selectOverride,hideSelectionMenu:e.hideSelectionMenu}}function A({isSelected:e,strokeColor:t,opacity:o=1,strokeWidth:r,inkList:s,rect:a,scale:l,onClick:c,appearanceActive:d=!1}){const u=t??"#000000",p=i.useMemo(()=>s.map(({points:e})=>{let t="";return e.forEach(({x:e,y:n},o)=>{const i=e-a.origin.x,r=n-a.origin.y;t+=(0===o?"M":"L")+i+" "+r+" "}),t.trim()}),[s,a]),h=a.size.width*l,g=a.size.height*l,v=Math.max(r,20/l);return n.jsxs("svg",{style:{position:"absolute",width:h,height:g,pointerEvents:"none",zIndex:2,overflow:"visible"},width:h,height:g,viewBox:`0 0 ${a.size.width} ${a.size.height}`,children:[p.map((t,o)=>n.jsx("path",{d:t,fill:"none",stroke:"transparent",strokeWidth:v,onPointerDown:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",strokeLinecap:"round",strokeLinejoin:"round"}},`hit-${o}`)),!d&&p.map((e,t)=>n.jsx("path",{d:e,fill:"none",opacity:o,style:{pointerEvents:"none",stroke:u,strokeWidth:r,strokeLinecap:"round",strokeLinejoin:"round"}},`vis-${t}`))]})}function w({isSelected:e,color:t="#000000",strokeColor:o,opacity:r=1,strokeWidth:s,strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:p,appearanceActive:h=!1}){const{width:g,height:v,x:x,y:y}=i.useMemo(()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-s,0),height:Math.max(t-s,0),x:s/2,y:s/2}},[d,s]),f=(g+s)*u,b=(v+s)*u,m=Math.max(s,20/u);return n.jsxs("svg",{style:{position:"absolute",width:f,height:b,pointerEvents:"none",zIndex:2},width:f,height:b,viewBox:`0 0 ${g+s} ${v+s}`,overflow:"visible",children:[n.jsx("rect",{x:x,y:y,width:g,height:v,fill:"transparent",stroke:"transparent",strokeWidth:m,onPointerDown:p,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible"}}),!h&&n.jsx("rect",{x:x,y:y,width:g,height:v,fill:t,opacity:r,style:{pointerEvents:"none",stroke:o??t,strokeWidth:s,...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})}function R({color:e="#000000",strokeColor:t,opacity:o=1,strokeWidth:r,strokeStyle:s=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:l,rect:c,scale:d,onClick:u,isSelected:p,appearanceActive:h=!1}){const{width:g,height:v,cx:x,cy:y,rx:f,ry:b}=i.useMemo(()=>{const e=c.size.width,t=c.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}},[c,r]),m=g*d,k=v*d,j=Math.max(r,20/d);return n.jsxs("svg",{style:{position:"absolute",width:m,height:k,pointerEvents:"none",zIndex:2},width:m,height:k,viewBox:`0 0 ${g} ${v}`,overflow:"visible",children:[n.jsx("ellipse",{cx:x,cy:y,rx:f,ry:b,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:u,style:{cursor:p?"move":"pointer",pointerEvents:p?"none":"transparent"===e?"visibleStroke":"visible"}}),!h&&n.jsx("ellipse",{cx:x,cy:y,rx:f,ry:b,fill:e,opacity:o,style:{pointerEvents:"none",stroke:t??e,strokeWidth:r,...s===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==l?void 0:l.join(",")}}})]})}function I({color:e="transparent",opacity:o=1,strokeWidth:r,strokeColor:s="#000000",strokeStyle:l=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:p,scale:h,onClick:g,isSelected:v,appearanceActive:x=!1}){const{x1:y,y1:f,x2:b,y2:m}=i.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]),k=i.useMemo(()=>{const e=Math.atan2(m-f,b-y);return{start:t.patching.createEnding(null==p?void 0:p.start,r,e+Math.PI,y,f),end:t.patching.createEnding(null==p?void 0:p.end,r,e,b,m)}},[p,r,y,f,b,m]),j=d.size.width*h,S=d.size.height*h,C=Math.max(r,20/h);return n.jsxs("svg",{style:{position:"absolute",width:j,height:S,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:S,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:y,y1:f,x2:b,y2:m,stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":"visibleStroke",strokeLinecap:"butt"}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":k.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:C,onPointerDown:g,style:{cursor:v?"move":"pointer",pointerEvents:v?"none":k.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),!x&&n.jsxs(n.Fragment,{children:[n.jsx("line",{x1:y,y1:f,x2:b,y2:m,opacity:o,style:{pointerEvents:"none",stroke:s,strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.start&&n.jsx("path",{d:k.start.d,transform:k.start.transform,stroke:s,fill:k.start.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),k.end&&n.jsx("path",{d:k.end.d,transform:k.end.transform,stroke:s,fill:k.end.filled?e:"none",style:{pointerEvents:"none",strokeWidth:r,strokeLinecap:"butt",...l===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})]})]})}function D({rect:e,vertices:o,color:r="transparent",strokeColor:s="#000000",opacity:l=1,strokeWidth:c,strokeStyle:d=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:u,scale:p,isSelected:h,onClick:g,lineEndings:v,appearanceActive:x=!1}){const y=i.useMemo(()=>o.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[o,e]),f=i.useMemo(()=>{if(!y.length)return"";const[e,...t]=y;return`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y} `).join("").trim()},[y]),b=i.useMemo(()=>{if(y.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(y[0],y[1]),o=e(y[y.length-2],y[y.length-1]);return{start:t.patching.createEnding(null==v?void 0:v.start,c,n+Math.PI,y[0].x,y[0].y),end:t.patching.createEnding(null==v?void 0:v.end,c,o,y[y.length-1].x,y[y.length-1].y)}},[y,v,c]),m=e.size.width*p,k=e.size.height*p,j=Math.max(c,20/p);return n.jsxs("svg",{style:{position:"absolute",width:m,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:k,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:f,fill:"none",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":b.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,fill:"transparent",stroke:"transparent",strokeWidth:j,onPointerDown:g,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":b.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),!x&&n.jsxs(n.Fragment,{children:[n.jsx("path",{d:f,opacity:l,style:{fill:"none",stroke:s??r,strokeWidth:c,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.start&&n.jsx("path",{d:b.start.d,transform:b.start.transform,stroke:s,fill:b.start.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}}),b.end&&n.jsx("path",{d:b.end.d,transform:b.end.transform,stroke:s,fill:b.end.filled?r:"none",style:{pointerEvents:"none",strokeWidth:c,strokeLinecap:"butt",...d===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==u?void 0:u.join(",")}}})]})]})}function z({rect:e,vertices:t,color:o="transparent",strokeColor:r="#000000",opacity:s=1,strokeWidth:l,strokeStyle:c=a.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:p,onClick:h,currentVertex:g,handleSize:v=14,appearanceActive:x=!1}){const y=g?[...t,g]:t,f=i.useMemo(()=>y.map(({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})),[y,e]),b=i.useMemo(()=>{if(!f.length)return"";const[e,...t]=f,n=!!g;return(`M ${e.x} ${e.y} `+t.map(e=>`L ${e.x} ${e.y}`).join(" ")+(n?"":" Z")).trim()},[f,g]),m=g&&t.length>0,k=e.size.width*u,j=e.size.height*u,S=Math.max(l,20/u);return n.jsxs("svg",{style:{position:"absolute",width:k,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:k,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:b,fill:"transparent",stroke:"transparent",strokeWidth:S,onPointerDown:h,style:{cursor:p?"move":"pointer",pointerEvents:p?"none":"transparent"===o?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter"}}),!x&&n.jsxs(n.Fragment,{children:[n.jsx("path",{d:b,opacity:s,style:{fill:g?"none":o,stroke:r??o,strokeWidth:l,pointerEvents:"none",strokeLinecap:"butt",strokeLinejoin:"miter",...c===a.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),m&&t.length>1&&n.jsx("path",{d:`M ${f[f.length-1].x} ${f[f.length-1].y} L ${f[0].x} ${f[0].y}`,fill:"none",style:{stroke:r,strokeWidth:l,strokeDasharray:"4,4",opacity:.7,pointerEvents:"none"}}),m&&t.length>=2&&n.jsx("rect",{x:f[0].x-v/u/2,y:f[0].y-v/u/2,width:v/u,height:v/u,fill:r,opacity:.4,stroke:r,strokeWidth:l/2,style:{pointerEvents:"none"}})]})]})}function P({isSelected:e,color:t="#facc15",opacity:o=1,onClick:i,appearanceActive:r=!1}){const s=a.getContrastStrokeColor(t);return n.jsx("div",{style:{position:"absolute",inset:0,zIndex:2,pointerEvents:e?"none":"auto",cursor:e?"move":"pointer"},onPointerDown:i,children:!r&&n.jsxs("svg",{style:{position:"absolute",inset:0,pointerEvents:"none"},viewBox:"0 0 20 20",width:"100%",height:"100%",children:[n.jsx("path",{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",fill:t,opacity:o,stroke:s,strokeWidth:"1",strokeLinejoin:"miter"}),n.jsx("line",{x1:"2.5",y1:"4.25",x2:"17.5",y2:"4.25",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"8",x2:"17.5",y2:"8",stroke:s,strokeWidth:"1"}),n.jsx("line",{x1:"2.5",y1:"11.75",x2:"17.5",y2:"11.75",stroke:s,strokeWidth:"1"})]})})}function E({documentId:e,isSelected:t,isEditing:o,annotation:r,pageIndex:s,scale:l,onClick:c,appearanceActive:d=!1}){const u=i.useRef(null),h=i.useRef(!1),{provides:g}=f(),v=(null==g?void 0:g.forDocument(e))??null,[x,y]=i.useState(!1);i.useEffect(()=>{if(o&&u.current){h.current=!0;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)}}},[o]),i.useLayoutEffect(()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;y(t)}catch{y(!1)}},[]);const b=r.object.fontSize*l,m=x&&o&&b>0&&b<16,k=m?16:b,j=m?b/16:1,S=m?100/j:100;return n.jsx("div",{style:{position:"absolute",width:r.object.rect.size.width*l,height:r.object.rect.size.height*l,cursor:t&&!o?"move":"default",pointerEvents:t&&!o?"none":"auto",zIndex:2,opacity:d?0:1},onPointerDown:c,children:n.jsx("span",{ref:u,onBlur:()=>{h.current&&(h.current=!1,v&&u.current&&v.updateAnnotation(s,r.object.id,{contents:u.current.innerText}))},tabIndex:0,style:{color:r.object.fontColor,fontSize:k,...a.standardFontCssProperties(r.object.fontFamily),textAlign:a.textAlignmentToCss(r.object.textAlign),flexDirection:"column",justifyContent:r.object.verticalAlign===a.PdfVerticalAlignment.Top?"flex-start":r.object.verticalAlign===a.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:r.object.color??r.object.backgroundColor,opacity:r.object.opacity,width:m?`${S}%`:"100%",height:m?`${S}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:o?"text":"pointer",outline:"none",transform:m?`scale(${j})`:void 0,transformOrigin:"top left"},contentEditable:o,...p,children:r.object.contents})})}function M({documentId:e,pageIndex:t,annotation:r,scaleFactor:s=1,unrotated:l,style:c,...d}){const{provides:u}=f(),[p,h]=i.useState(null),g=i.useRef(null),{width:v,height:x}=r.rect.size;i.useEffect(()=>{if(u){const n=u.forDocument(e).renderAnnotation({pageIndex:t,annotation:r,options:{scaleFactor:s,dpr:window.devicePixelRatio,unrotated:l}});return n.wait(e=>{const t=URL.createObjectURL(e);h(t),g.current=t},a.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:a.PdfErrorCode.Cancelled,message:"canceled render task"})}}},[t,s,l,u,e,r.id,v,x]);return n.jsx(o.Fragment,{children:p&&n.jsx("img",{src:p,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...d,style:{width:"100%",height:"100%",display:"block",...c||{}}})})}function L({isSelected:e,annotation:t,documentId:o,pageIndex:i,scale:r,onClick:s}){const a=!!t.object.rotation&&!!t.object.unrotatedRect;return n.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,children:n.jsx(M,{documentId:o,pageIndex:i,annotation:{...t.object,id:t.object.id},scaleFactor:r,unrotated:a})})}function $({isSelected:e,strokeColor:t="#0000FF",strokeWidth:o=2,strokeStyle:r=a.PdfAnnotationBorderStyle.UNDERLINE,strokeDashArray:s,rect:l,scale:c,onClick:d,hasIRT:u=!1}){const{width:p,height:h}=i.useMemo(()=>({width:l.size.width,height:l.size.height}),[l]),g=p*c,v=h*c,x=i.useMemo(()=>{if(r===a.PdfAnnotationBorderStyle.DASHED)return(null==s?void 0:s.join(","))??`${3*o},${o}`},[r,s,o]),y=r===a.PdfAnnotationBorderStyle.UNDERLINE;return n.jsxs("svg",{style:{position:"absolute",width:g,height:v,pointerEvents:"none",zIndex:2},width:g,height:v,viewBox:`0 0 ${p} ${h}`,children:[n.jsx("rect",{x:0,y:0,width:p,height:h,fill:"transparent",onPointerDown:u?void 0:d,style:{cursor:u?"default":e?"move":"pointer",pointerEvents:u||e?"none":"visible"}}),y?n.jsx("line",{x1:1,y1:h-1,x2:p-1,y2:h-1,stroke:t,strokeWidth:o,strokeDasharray:x,style:{pointerEvents:"none"}}):n.jsx("rect",{x:o/2,y:o/2,width:Math.max(p-o,0),height:Math.max(h-o,0),fill:"transparent",stroke:t,strokeWidth:o,strokeDasharray:x,style:{pointerEvents:"none"}})]})}function O({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00";return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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:l?"transparent":c,opacity:l?void 0:t,pointerEvents:s?"auto":"none",cursor:s?"pointer":"default",zIndex:s?1:void 0,...a}},o))})}function F({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:d,background:c,opacity:t,pointerEvents:"none"}})},o))})}function U({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=e??"#FFFF00",d=2*r;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:d,background:c,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},o))})}function W({strokeColor:e,opacity:t=.5,segmentRects:o,rect:i,scale:r,onClick:s,style:a,appearanceActive:l=!1}){const c=2*r,d=6*r,u=`url("data:image/svg+xml;utf8,${encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${2*c}" viewBox="0 0 ${d} ${2*c}">\n <path d="M0 ${c} Q ${d/4} 0 ${d/2} ${c} T ${d} ${c}"\n fill="none" stroke="${e??"#FFFF00"}" stroke-width="${c}" stroke-linecap="round"/>\n </svg>`)}")`;return n.jsx(n.Fragment,{children:o.map((e,o)=>n.jsx("div",{onPointerDown: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,...a},children:!l&&n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*c,backgroundImage:u,backgroundRepeat:"repeat-x",backgroundSize:`${d}px ${2*c}px`,opacity:t,pointerEvents:"none"}})},o))})}function B({isSelected:e,strokeColor:t="#000000",opacity:o=1,rect:r,scale:s,onClick:a,appearanceActive:l=!1}){const{width:c,height:d,path:u}=i.useMemo(()=>{const e=r.size.width,t=r.size.height,n=e/2;return{width:e,height:t,path:[`M 0 ${t}`,`C ${.27*e} ${t} ${n} ${t-.44*t} ${n} 0`,`C ${n} ${t-.44*t} ${e-.27*e} ${t} ${e} ${t}`,"Z"].join(" ")}},[r]),p=c*s,h=d*s;return n.jsxs("svg",{style:{position:"absolute",width:p,height:h,pointerEvents:"none",zIndex:2},width:p,height:h,viewBox:`0 0 ${c} ${d}`,overflow:"visible",children:[n.jsx("path",{d:u,fill:"transparent",stroke:"transparent",strokeWidth:4,onPointerDown:a,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visible"}}),!l&&n.jsx("path",{d:u,fill:t,stroke:t,strokeWidth:.5,opacity:o,fillRule:"evenodd",style:{pointerEvents:"none"}})]})}const T=[C({id:"ink",matches:e=>e.type===a.PdfAnnotationSubtype.INK,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(A,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"square",matches:e=>e.type===a.PdfAnnotationSubtype.SQUARE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(w,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"circle",matches:e=>e.type===a.PdfAnnotationSubtype.CIRCLE,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(R,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"line",matches:e=>e.type===a.PdfAnnotationSubtype.LINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(I,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"polyline",matches:e=>e.type===a.PdfAnnotationSubtype.POLYLINE,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(D,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"polygon",matches:e=>e.type===a.PdfAnnotationSubtype.POLYGON,render:({currentObject:e,isSelected:t,scale:i,onClick:r,appearanceActive:s})=>n.jsx(o.Fragment,{children:n.jsx(z,{...e,isSelected:t,scale:i,onClick:r,appearanceActive:s})}),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!0}}),C({id:"highlight",matches:e=>e.type===a.PdfAnnotationSubtype.HIGHLIGHT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(O,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},containerStyle:e=>({mixBlendMode:a.blendModeToCss(e.blendMode??a.PdfBlendMode.Multiply)})}),C({id:"underline",matches:e=>e.type===a.PdfAnnotationSubtype.UNDERLINE,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(F,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"strikeout",matches:e=>e.type===a.PdfAnnotationSubtype.STRIKEOUT,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(U,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"squiggly",matches:e=>e.type===a.PdfAnnotationSubtype.SQUIGGLY,render:({currentObject:e,scale:t,onClick:o,appearanceActive:i})=>n.jsx(W,{...e,scale:t,onClick:o,appearanceActive:i}),zIndex:0,interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"text",matches:e=>e.type===a.PdfAnnotationSubtype.TEXT&&!e.inReplyToId,render:({currentObject:e,isSelected:t,onClick:o,appearanceActive:i})=>n.jsx(P,{isSelected:t,color:e.strokeColor??e.color,opacity:e.opacity,onClick:o,appearanceActive:i}),interactionDefaults:{isDraggable:!0,isResizable:!1,isRotatable:!1}}),C({id:"caret",matches:e=>e.type===a.PdfAnnotationSubtype.CARET,render:({currentObject:e,isSelected:t,scale:o,onClick:i,appearanceActive:r})=>n.jsx(B,{...e,isSelected:t,scale:o,onClick:i,appearanceActive:r}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1}}),C({id:"freeText",matches:e=>e.type===a.PdfAnnotationSubtype.FREETEXT,render:({annotation:e,currentObject:t,isSelected:o,isEditing:i,scale:r,pageIndex:s,documentId:a,onClick:l,appearanceActive:c})=>n.jsx(E,{documentId:a,isSelected:o,isEditing:i,annotation:{...e,object:t},pageIndex:s,scale:r,onClick:l,appearanceActive:c}),interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0},isDraggable:(e,{isEditing:t})=>e&&!t,onDoubleClick:(e,t)=>t(e)}),C({id:"stamp",matches:e=>e.type===a.PdfAnnotationSubtype.STAMP,render:({annotation:e,isSelected:t,documentId:o,pageIndex:i,scale:r,onClick:s})=>n.jsx(L,{isSelected:t,annotation:e,documentId:o,pageIndex:i,scale:r,onClick:s}),useAppearanceStream:!1,interactionDefaults:{isDraggable:!0,isResizable:!0,isRotatable:!0}}),C({id:"link",matches:e=>e.type===a.PdfAnnotationSubtype.LINK,render:({currentObject:e,isSelected:t,scale:o,onClick:i})=>n.jsx($,{...e,isSelected:t,scale:o,onClick:i,hasIRT:!!e.inReplyToId}),interactionDefaults:{isDraggable:!1,isResizable:!1,isRotatable:!1},useAppearanceStream:!1,selectOverride:(e,t,n)=>{if(e.stopPropagation(),n.clearSelection(),t.object.inReplyToId){const e=n.allAnnotations.find(e=>e.object.id===t.object.inReplyToId);if(e)return void n.selectAnnotation(e.object.pageIndex,e.object.id)}n.selectAnnotation(n.pageIndex,t.object.id)},hideSelectionMenu:e=>!!e.inReplyToId})];function H(e){const{documentId:o,pageIndex:r,scale:s,pageWidth:d,pageHeight:u,selectionMenu:p}=e,{provides:h}=f(),{provides:g}=c.useSelectionCapability(),[v,x]=i.useState([]),{register:y}=l.usePointerHandlers({documentId:o,pageIndex:r}),[b,k]=i.useState([]),[j,C]=i.useState(null),[A,w]=i.useState({}),R=i.useRef(s),I=i.useMemo(()=>h?h.forDocument(o):null,[h,o]),D=b.length>1;i.useEffect(()=>{if(I){const e=I.getState();return x(t.getAnnotationsByPageIndex(e,r)),k(t.getSelectedAnnotationIds(e)),I.onStateChange(e=>{x(t.getAnnotationsByPageIndex(e,r)),k(t.getSelectedAnnotationIds(e))})}},[I,r]),i.useEffect(()=>{if(!I)return;R.current!==s&&(I.invalidatePageAppearances(r),R.current=s);I.getPageAppearances(r,{scaleFactor:s,dpr:"undefined"!=typeof window?window.devicePixelRatio:1}).wait(e=>w(e),()=>w({}))},[I,r,s]);const z=i.useMemo(()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&I&&(I.deselectAnnotation(),C(null))}}),[I]),P=i.useCallback((e,t)=>{if(e.stopPropagation(),I&&g){g.clear();"metaKey"in e&&(e.metaKey||e.ctrlKey)?I.toggleSelection(r,t.object.id):I.selectAnnotation(r,t.object.id),t.object.id!==j&&C(null)}},[I,g,j,r]);i.useEffect(()=>y(z,{documentId:o}),[y,z]);const E=i.useMemo(()=>v.filter(e=>b.includes(e.object.id)),[v,b]),M=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==I?void 0:I.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}),[E,I]),L=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==I?void 0:I.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}),[E,I]),$=i.useMemo(()=>!(E.length<2)&&E.every(e=>{const n=null==I?void 0:I.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.isGroupRotatable,e.object,!0),i=t.resolveInteractionProp(null==n?void 0:n.interaction.isRotatable,e.object,!0);return void 0!==(null==n?void 0:n.interaction.isGroupRotatable)?o:i}),[E,I]),O=i.useMemo(()=>!(E.length<2)&&E.some(e=>{const n=null==I?void 0:I.findToolForAnnotation(e.object),o=t.resolveInteractionProp(null==n?void 0:n.interaction.lockGroupAspectRatio,e.object,!1),i=t.resolveInteractionProp(null==n?void 0:n.interaction.lockAspectRatio,e.object,!1);return void 0!==(null==n?void 0:n.interaction.lockGroupAspectRatio)?o:i}),[E,I]),F=i.useMemo(()=>{if(!I)return!1;const e=I.getSelectedAnnotations();return e.length>1&&e.every(e=>e.object.pageIndex===r)},[I,r,b]),U=i.useCallback(e=>{if(e.dictMode)return null;if(e.object.rotation&&e.object.unrotatedRect)return null;const t=A[e.object.id];return(null==t?void 0:t.normal)?t:null},[A]),W=i.useMemo(()=>{const t=e.annotationRenderers??[],n=new Set(t.map(e=>e.id));return[...t,...T.filter(e=>!n.has(e.id))]},[e.annotationRenderers]),B=i.useCallback(e=>W.find(t=>t.matches(e.object))??null,[W]),H=i.useMemo(()=>({defaultSelect:P,selectAnnotation:(e,t)=>null==I?void 0:I.selectAnnotation(e,t),clearSelection:()=>null==g?void 0:g.clear(),allAnnotations:v,pageIndex:r}),[P,I,g,v,r]);return n.jsxs(n.Fragment,{children:[v.map(i=>{var l,c,d;const u=B(i);if(!u)return null;const h=null==I?void 0:I.findToolForAnnotation(i.object),g=b.includes(i.object.id),v=j===i.object.id,x=u.interactionDefaults,y=t.resolveInteractionProp(null==h?void 0:h.interaction.isDraggable,i.object,(null==x?void 0:x.isDraggable)??!0),f=u.isDraggable?u.isDraggable(y,{isEditing:v}):y,k=(null==(l=null==h?void 0:h.behavior)?void 0:l.useAppearanceStream)??u.useAppearanceStream??!0,S=u.selectOverride?e=>u.selectOverride(e,i,H):e=>P(e,i);return n.jsx(m,{trackedAnnotation:i,isSelected:g,isEditing:v,isMultiSelected:D,isDraggable:f,isResizable:t.resolveInteractionProp(null==h?void 0:h.interaction.isResizable,i.object,(null==x?void 0:x.isResizable)??!1),lockAspectRatio:t.resolveInteractionProp(null==h?void 0:h.interaction.lockAspectRatio,i.object,(null==x?void 0:x.lockAspectRatio)??!1),isRotatable:t.resolveInteractionProp(null==h?void 0:h.interaction.isRotatable,i.object,(null==x?void 0:x.isRotatable)??!1),vertexConfig:u.vertexConfig,selectionMenu:(null==(c=u.hideSelectionMenu)?void 0:c.call(u,i.object))?void 0:p,onSelect:S,onDoubleClick:u.onDoubleClick?e=>{e.stopPropagation(),u.onDoubleClick(i.object.id,C)}:void 0,zIndex:u.zIndex,style:(null==(d=u.containerStyle)?void 0:d.call(u,i.object))??{mixBlendMode:a.blendModeToCss(i.object.blendMode??a.PdfBlendMode.Normal)},appearance:k?U(i):void 0,...e,children:(e,{appearanceActive:t})=>u.render({annotation:i,currentObject:e,isSelected:g,isEditing:v,scale:s,pageIndex:r,documentId:o,onClick:S,appearanceActive:t})},i.object.id)}),F&&E.length>=2&&n.jsx(S,{documentId:o,pageIndex:r,scale:s,rotation:e.rotation,pageWidth:d,pageHeight:u,selectedAnnotations:E,isDraggable:M,isResizable:L,isRotatable:$,lockAspectRatio:O,resizeUI:e.resizeUI,rotationUI:e.rotationUI,selectionOutlineColor:e.selectionOutlineColor,selectionOutline:e.groupSelectionOutline??e.selectionOutline,groupSelectionMenu:e.groupSelectionMenu})]})}function N({documentId:e,pageIndex:t,scale:o}){var r,s,l,d,u,p,h,g,v,x,y,b;const{provides:m}=c.useSelectionCapability(),{provides:k}=f(),[j,S]=i.useState([]),[C,A]=i.useState(null),[w,R]=i.useState(null);if(i.useEffect(()=>{if(m)return m.forDocument(e).onSelectionChange(()=>{S(m.forDocument(e).getHighlightRectsForPage(t)),A(m.forDocument(e).getBoundingRectForPage(t))})},[m,e,t]),i.useEffect(()=>{if(k)return R(k.forDocument(e).getActiveTool()),k.forDocument(e).onActiveToolChange(e=>R(e))},[k,e]),!C)return null;if(!w||!w.defaults)return null;switch(w.defaults.type){case a.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(r=w.defaults)?void 0:r.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(F,{strokeColor:null==(s=w.defaults)?void 0:s.strokeColor,opacity:null==(l=w.defaults)?void 0:l.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(d=w.defaults)?void 0:d.blendMode)??a.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(O,{strokeColor:null==(u=w.defaults)?void 0:u.strokeColor,opacity:null==(p=w.defaults)?void 0:p.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(h=w.defaults)?void 0:h.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(U,{strokeColor:null==(g=w.defaults)?void 0:g.strokeColor,opacity:null==(v=w.defaults)?void 0:v.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:a.blendModeToCss((null==(x=w.defaults)?void 0:x.blendMode)??a.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(W,{strokeColor:null==(y=w.defaults)?void 0:y.strokeColor,opacity:null==(b=w.defaults)?void 0:b.opacity,segmentRects:j,scale:o})});case a.PdfAnnotationSubtype.CARET:default:return null}}function G({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===a.PdfAnnotationSubtype.CIRCLE?n.jsx("div",{style:i,children:n.jsx(R,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.SQUARE?n.jsx("div",{style:i,children:n.jsx(w,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.POLYGON?n.jsx("div",{style:i,children:n.jsx(z,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.POLYLINE?n.jsx("div",{style:i,children:n.jsx(D,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.LINE?n.jsx("div",{style:i,children:n.jsx(I,{isSelected:!1,scale:t,...e.data})}):e.type===a.PdfAnnotationSubtype.INK?n.jsx("div",{style:i,children:n.jsx(A,{isSelected:!1,scale:t,...e.data})}):e.type===a.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 q({documentId:e,pageIndex:t,scale:o}){const{plugin:r}=y(),[s,a]=i.useState(new Map),l=i.useRef(null),c=i.useRef(null),d=i.useMemo(()=>({requestFile:({accept:e,onFile:t})=>{if(!l.current)return;const n=l.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:a,naturalHeight:l}=s;const c=t?t/a:1,d=n?n/l:1,u=Math.min(c,d,1),p=a*u,h=l*u;i.width=p,i.height=h,r.drawImage(s,0,0,p,h);const g=r.getImageData(0,0,p,h);"string"!=typeof e&&URL.revokeObjectURL(s.src),o({imageData:g,width:p,height:h})},s.src="string"==typeof e?e:URL.createObjectURL(e)}}),[]);return i.useEffect(()=>{if(r)return r.registerPageHandlers(e,t,o,{services:d,onPreview:(e,t)=>{a(n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o})}})},[e,t,o,r,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:l,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:c,style:{display:"none"}}),Array.from(s.entries()).map(([e,t])=>n.jsx(G,{preview:t,scale:o},e))]})}const Y=e.createPluginPackage(t.AnnotationPluginPackage).addWrapper(v).build();exports.AnnotationLayer=function({style:e,documentId:t,pageIndex:o,scale:r,rotation:a,selectionMenu:l,groupSelectionMenu:c,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:y,annotationRenderers:f,...b}){var m,k,j,S;const C=s.useDocumentState(t),A=null==(k=null==(m=null==C?void 0:C.document)?void 0:m.pages)?void 0:k[o],w=(null==(j=null==A?void 0:A.size)?void 0:j.width)??0,R=(null==(S=null==A?void 0:A.size)?void 0:S.height)??0,I=x(),D=i.useMemo(()=>{const e=[...I];for(const t of f??[]){const n=e.findIndex(e=>e.id===t.id);n>=0?e[n]=t:e.push(t)}return e},[I,f]),z=i.useMemo(()=>void 0!==r?r:(null==C?void 0:C.scale)??1,[r,null==C?void 0:C.scale]),P=i.useMemo(()=>{if(void 0!==a)return a;return(((null==A?void 0:A.rotation)??0)+((null==C?void 0:C.rotation)??0))%4},[a,null==A?void 0:A.rotation,null==C?void 0:C.rotation]);return n.jsxs("div",{style:{...e},...b,children:[n.jsx(H,{documentId:t,selectionMenu:l,groupSelectionMenu:c,pageIndex:o,scale:z,rotation:P,pageWidth:w,pageHeight:R,resizeUI:d,vertexUI:u,rotationUI:p,selectionOutlineColor:h,selectionOutline:g,groupSelectionOutline:v,customAnnotationRenderer:y,annotationRenderers:D}),n.jsx(N,{documentId:t,pageIndex:o,scale:z}),n.jsx(q,{documentId:t,pageIndex:o,scale:z})]})},exports.AnnotationPluginPackage=Y,exports.AnnotationRendererProvider=v,exports.GroupSelectionBox=S,exports.createRenderer=C,exports.useAnnotation=e=>{var n;const{provides:o}=f(),[r,s]=i.useState((null==(n=null==o?void 0:o.forDocument(e))?void 0:n.getState())??t.initialDocumentState());return i.useEffect(()=>{if(!o)return;const t=o.forDocument(e);return s(t.getState()),t.onStateChange(e=>{s(e)})},[o,e]),{state:r,provides:(null==o?void 0:o.forDocument(e))??null}},exports.useAnnotationCapability=f,exports.useAnnotationPlugin=y,exports.useRegisterRenderers=function(e){const t=i.useContext(h),n=i.useRef(e);i.useEffect(()=>{if(t)return t(n.current)},[t])},exports.useRegisteredRenderers=x,exports.useRendererRegistry=function(){return i.useContext(h)},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
|