@embedpdf/plugin-annotation 1.3.11 → 1.3.13
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 +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/index.d.ts +1 -0
- package/dist/preact/index.cjs +1 -1
- package/dist/preact/index.cjs.map +1 -1
- package/dist/preact/index.js +21 -5
- 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 +21 -5
- package/dist/react/index.js.map +1 -1
- package/dist/shared-preact/components/annotation-container.d.ts +2 -1
- package/dist/shared-preact/components/annotation-layer.d.ts +1 -1
- package/dist/shared-preact/components/annotations.d.ts +1 -1
- package/dist/shared-preact/components/types.d.ts +51 -0
- package/dist/shared-preact/hooks/use-annotation.d.ts +5 -1
- package/dist/shared-preact/types.d.ts +1 -50
- package/dist/shared-react/components/annotation-container.d.ts +2 -1
- package/dist/shared-react/components/annotation-layer.d.ts +1 -1
- package/dist/shared-react/components/annotations.d.ts +1 -1
- package/dist/shared-react/components/types.d.ts +51 -0
- package/dist/shared-react/hooks/use-annotation.d.ts +5 -1
- package/dist/shared-react/types.d.ts +1 -50
- package/dist/vue/components/annotation-container.vue.d.ts +48 -0
- package/dist/vue/components/annotation-layer.vue.d.ts +27 -0
- package/dist/vue/components/annotation-paint-layer.vue.d.ts +6 -0
- package/dist/vue/components/annotations/circle.vue.d.ts +19 -0
- package/dist/vue/components/annotations/free-text.vue.d.ts +12 -0
- package/dist/vue/components/annotations/index.d.ts +8 -0
- package/dist/vue/components/annotations/ink.vue.d.ts +16 -0
- package/dist/vue/components/annotations/line.vue.d.ts +22 -0
- package/dist/vue/components/annotations/polygon.vue.d.ts +24 -0
- package/dist/vue/components/annotations/polyline.vue.d.ts +19 -0
- package/dist/vue/components/annotations/square.vue.d.ts +19 -0
- package/dist/vue/components/annotations/stamp.vue.d.ts +11 -0
- package/dist/vue/components/annotations.vue.d.ts +77 -0
- package/dist/vue/components/index.d.ts +9 -0
- package/dist/vue/components/preview-renderer.vue.d.ts +7 -0
- package/dist/vue/components/render-annotation.vue.d.ts +12 -0
- package/dist/vue/components/text-markup/highlight.vue.d.ts +14 -0
- package/dist/vue/components/text-markup/index.d.ts +4 -0
- package/dist/vue/components/text-markup/squiggly.vue.d.ts +14 -0
- package/dist/vue/components/text-markup/strikeout.vue.d.ts +14 -0
- package/dist/vue/components/text-markup/underline.vue.d.ts +14 -0
- package/dist/vue/components/text-markup.vue.d.ts +6 -0
- package/dist/vue/hooks/use-annotation.d.ts +2682 -0
- package/dist/vue/index.cjs +1 -1
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.ts +1 -0
- package/dist/vue/index.js +1921 -1
- package/dist/vue/index.js.map +1 -1
- package/package.json +10 -10
package/dist/lib/index.d.ts
CHANGED
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/preact"),t=require("@embedpdf/plugin-annotation"),n=require("preact/jsx-runtime"),o=require("@embedpdf/models"),i=require("@embedpdf/plugin-interaction-manager/preact"),s=require("@embedpdf/plugin-selection/preact"),r=require("preact"),l=require("preact/hooks"),a=require("@embedpdf/utils/preact"),c=()=>e.usePlugin(t.AnnotationPlugin.id),d=()=>e.useCapability(t.AnnotationPlugin.id),u={};function h({scale:e,pageIndex:t,rotation:o,pageWidth:i,pageHeight:s,trackedAnnotation:r,children:c,isSelected:u,isDraggable:h,isResizable:g,lockAspectRatio:p=!1,style:x={},vertexConfig:b,selectionMenu:y,outlineOffset:v=1,onDoubleClick:f,onSelect:m,zIndex:j=1,resizeUI:k,vertexUI:S,selectionOutlineColor:M="#007ACC",customAnnotationRenderer:A,...w}){const[z,P]=l.useState(r.object),{provides:R}=d(),C=l.useRef(null),D=z?{...r.object,...z}:r.object,I=(null==k?void 0:k.color)??"#007ACC",E=(null==S?void 0:S.color)??"#007ACC",B=(null==k?void 0:k.size)??12,T=(null==S?void 0:S.size)??12,{dragProps:$,vertices:L,resize:F}=a.useInteractionHandles({controller:{element:D.rect,vertices:null==b?void 0:b.extractVertices(D),constraints:{minWidth:10,minHeight:10,boundingBox:{width:i/e,height:s/e}},maintainAspectRatio:p,pageRotation:o,scale:e,enabled:u,onUpdate:e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type))return;"start"===e.state&&(C.current=D);const o=e.transformData.type,i=C.current??D,s=e.transformData.changes.vertices?null==b?void 0:b.transformAnnotation(i,e.transformData.changes.vertices):{rect:e.transformData.changes.rect},l=null==R?void 0:R.transformAnnotation(i,{type:o,changes:s,metadata:e.transformData.metadata});l&&P((e=>({...e,...l}))),"end"===e.state&&l&&(C.current=null,null==R||R.updateAnnotation(t,r.object.id,l))}},resizeUI:{handleSize:B,spacing:v,offsetMode:"outside",includeSides:!p,zIndex:j+1},vertexUI:{vertexSize:T,zIndex:j+2},includeVertices:!!b}),W=a.useDoublePressProps(f);return l.useEffect((()=>{P(r.object)}),[r.object]),n.jsxs("div",{"data-no-interaction":!0,children:[n.jsxs("div",{...h&&u?$:{},...W,style:{position:"absolute",left:D.rect.origin.x*e,top:D.rect.origin.y*e,width:D.rect.size.width*e,height:D.rect.size.height*e,outline:u?`1px solid ${M}`:"none",outlineOffset:u?`${v}px`:"0px",pointerEvents:u?"auto":"none",touchAction:"none",cursor:u&&h?"move":"default",zIndex:j,...x},...w,children:[(()=>{const n=null==A?void 0:A({annotation:D,isSelected:u,scale:e,rotation:o,pageWidth:i,pageHeight:s,pageIndex:t,onSelect:m});return null!=n?n:"function"==typeof c?c(D):c})(),u&&g&&F.map((({key:e,...t})=>(null==k?void 0:k.component)?k.component({key:e,...t,backgroundColor:I}):n.jsx("div",{...t,style:{...t.style,backgroundColor:I}},e))),u&&L.map((({key:e,...t})=>(null==S?void 0:S.component)?S.component({key:e,...t,backgroundColor:E}):n.jsx("div",{...t,style:{...t.style,backgroundColor:E}},e)))]}),n.jsx(a.CounterRotate,{rect:{origin:{x:D.rect.origin.x*e,y:D.rect.origin.y*e},size:{width:D.rect.size.width*e,height:D.rect.size.height*e}},rotation:o,children:({rect:e,menuWrapperProps:t})=>y&&y({annotation:r,selected:u,rect:e,menuWrapperProps:t})})]})}function g({color:e="#FFFF00",opacity:t=.5,segmentRects:o,rect:i,scale:s,onClick:r,style:l}){return n.jsx(n.Fragment,{children:o.map(((o,a)=>n.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?o.origin.x-i.origin.x:o.origin.x)*s,top:(i?o.origin.y-i.origin.y:o.origin.y)*s,width:o.size.width*s,height:o.size.height*s,background:e,opacity:t,pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:void 0,...l}},a)))})}function p({color:e="#FFFF00",opacity:t=.5,segmentRects:o,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return n.jsx(n.Fragment,{children:o.map(((o,c)=>n.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?o.origin.x-i.origin.x:o.origin.x)*s,top:(i?o.origin.y-i.origin.y:o.origin.y)*s,width:o.size.width*s,height:o.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:a,background:e,opacity:t,pointerEvents:"none"}})},c)))})}function x({color:e="#FFFF00",opacity:t=.5,segmentRects:o,rect:i,scale:s,onClick:r,style:l}){const a=2*s;return n.jsx(n.Fragment,{children:o.map(((o,c)=>n.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?o.origin.x-i.origin.x:o.origin.x)*s,top:(i?o.origin.y-i.origin.y:o.origin.y)*s,width:o.size.width*s,height:o.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:a,background:e,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},c)))})}function b({color:e="#FFFF00",opacity:t=.5,segmentRects:o,rect:i,scale:s,onClick:r,style:l}){const a=2*s,c=6*s,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}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return n.jsx(n.Fragment,{children:o.map(((e,o)=>n.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(i?e.origin.x-i.origin.x:e.origin.x)*s,top:(i?e.origin.y-i.origin.y:e.origin.y)*s,width:e.size.width*s,height:e.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:n.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:2*a,backgroundImage:d,backgroundRepeat:"repeat-x",backgroundSize:`${c}px ${2*a}px`,opacity:t,pointerEvents:"none"}})},o)))})}function y({isSelected:e,color:t="#000000",opacity:o=1,strokeWidth:i,inkList:s,rect:r,scale:a,onClick:c}){const d=l.useMemo((()=>s.map((({points:e})=>{let t="";return e.forEach((({x:e,y:n},o)=>{const i=e-r.origin.x,s=n-r.origin.y;t+=(0===o?"M":"L")+i+" "+s+" "})),t.trim()}))),[s,r]),u=r.size.width*a,h=r.size.height*a;return n.jsx("svg",{style:{position:"absolute",width:u,height:h,pointerEvents:"none",zIndex:2,overflow:"visible"},width:u,height:h,viewBox:`0 0 ${r.size.width} ${r.size.height}`,children:d.map(((s,r)=>n.jsx("path",{d:s,fill:"none",opacity:o,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:t,strokeWidth:i,strokeLinecap:"round",strokeLinejoin:"round"}},r)))})}function v({isSelected:e,color:t="#000000",strokeColor:i,opacity:s=1,strokeWidth:r,strokeStyle:a=o.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:h}){const{width:g,height:p,x:x,y:b}=l.useMemo((()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-r,0),height:Math.max(t-r,0),x:r/2,y:r/2}}),[d,r]),y=(g+r)*u,v=(p+r)*u;return n.jsx("svg",{style:{position:"absolute",width:y,height:v,pointerEvents:"none",zIndex:2},width:y,height:v,viewBox:`0 0 ${g+r} ${p+r}`,children:n.jsx("rect",{x:x,y:b,width:g,height:p,fill:t,opacity:s,onPointerDown:h,onTouchStart:h,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"transparent"===t?"visibleStroke":"visible",stroke:i??t,strokeWidth:r,...a===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}})})}function f({color:e="#000000",strokeColor:t,opacity:i=1,strokeWidth:s,strokeStyle:r=o.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:h}){const{width:g,height:p,cx:x,cy:b,rx:y,ry:v}=l.useMemo((()=>{const e=c.size.width,t=c.size.height,n=Math.max(e-s,0),o=Math.max(t-s,0);return{width:e,height:t,cx:s/2+n/2,cy:s/2+o/2,rx:n/2,ry:o/2}}),[c,s]),f=g*d,m=p*d;return n.jsx("svg",{style:{position:"absolute",width:f,height:m,pointerEvents:"none",zIndex:2},width:f,height:m,viewBox:`0 0 ${g} ${p}`,children:n.jsx("ellipse",{cx:x,cy:b,rx:y,ry:v,fill:e,opacity:i,onPointerDown:u,onTouchStart:u,style:{cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===e?"visibleStroke":"visible",stroke:t??e,strokeWidth:s,...r===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==a?void 0:a.join(",")}}})})}function m({color:e="transparent",opacity:i=1,strokeWidth:s,strokeColor:r="#000000",strokeStyle:a=o.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,linePoints:u,lineEndings:h,scale:g,onClick:p,isSelected:x}){const{x1:b,y1:y,x2:v,y2:f}=l.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=l.useMemo((()=>{const e=Math.atan2(f-y,v-b);return{start:t.patching.createEnding(null==h?void 0:h.start,s,e+Math.PI,b,y),end:t.patching.createEnding(null==h?void 0:h.end,s,e,v,f)}}),[h,s,b,y,v,f]),j=d.size.width*g,k=d.size.height*g;return n.jsxs("svg",{style:{position:"absolute",width:j,height:k,pointerEvents:"none",zIndex:2,overflow:"visible"},width:j,height:k,viewBox:`0 0 ${d.size.width} ${d.size.height}`,children:[n.jsx("line",{x1:b,y1:y,x2:v,y2:f,opacity:i,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:r,strokeWidth:s,strokeLinecap:"butt",...a===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&n.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:r,style:{cursor:x?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&n.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:r,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:s,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function j({rect:e,vertices:o,color:i="transparent",strokeColor:s="#000000",opacity:r=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:h}){const g=l.useMemo((()=>o.map((({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})))),[o,e]),p=l.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]),x=l.useMemo((()=>{if(g.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(g[0],g[1]),o=e(g[g.length-2],g[g.length-1]);return{start:t.patching.createEnding(null==h?void 0:h.start,a,n+Math.PI,g[0].x,g[0].y),end:t.patching.createEnding(null==h?void 0:h.end,a,o,g[g.length-1].x,g[g.length-1].y)}}),[g,h,a]),b=e.size.width*c,y=e.size.height*c;return n.jsxs("svg",{style:{position:"absolute",width:b,height:y,pointerEvents:"none",zIndex:2,overflow:"visible"},width:b,height:y,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:r,style:{fill:"none",stroke:s??i,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&n.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:s,fill:x.start.filled?i:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&n.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:s,fill:x.end.filled?i:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function k({rect:e,vertices:t,color:i="transparent",strokeColor:s="#000000",opacity:r=1,strokeWidth:a,strokeStyle:c=o.PdfAnnotationBorderStyle.SOLID,strokeDashArray:d,scale:u,isSelected:h,onClick:g,currentVertex:p,handleSize:x=14}){const b=p?[...t,p]:t,y=l.useMemo((()=>b.map((({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})))),[b,e]),v=l.useMemo((()=>{if(!y.length)return"";const[e,...t]=y,n=!!p;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y}`)).join(" ")+(n?"":" Z")).trim()}),[y,p]),f=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return n.jsxs("svg",{style:{position:"absolute",width:m,height:j,pointerEvents:"none",zIndex:2,overflow:"visible"},width:m,height:j,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[n.jsx("path",{d:v,onPointerDown:g,onTouchStart:g,opacity:r,style:{fill:p?"none":i,stroke:s??i,strokeWidth:a,cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===i?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===o.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),f&&t.length>1&&n.jsx("path",{d:`M ${y[y.length-1].x} ${y[y.length-1].y} L ${y[0].x} ${y[0].y}`,fill:"none",style:{stroke:s,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),f&&t.length>=2&&n.jsx("rect",{x:y[0].x-x/u/2,y:y[0].y-x/u/2,width:x/u,height:x/u,fill:s,opacity:.4,stroke:s,strokeWidth:a/2})]})}function S({isSelected:e,isEditing:t,annotation:i,pageIndex:s,scale:r,onClick:a}){const c=l.useRef(null),{provides:h}=d(),[g,p]=l.useState(!1);l.useEffect((()=>{if(t&&c.current){const e=c.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}}),[t]),l.useLayoutEffect((()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}}),[]);const x=i.object.fontSize*r,b=g&&t&&x>0&&x<16,y=b?16:x,v=b?x/16:1,f=b?100/v:100;return n.jsx("div",{style:{position:"absolute",width:i.object.rect.size.width*r,height:i.object.rect.size.height*r,cursor:e&&!t?"move":"default",pointerEvents:e&&!t?"none":"auto",zIndex:2},onPointerDown:a,onTouchStart:a,children:n.jsx("span",{ref:c,onBlur:()=>{h&&c.current&&h.updateAnnotation(s,i.object.id,{contents:c.current.innerText})},tabIndex:0,style:{color:i.object.fontColor,fontSize:y,fontFamily:o.standardFontCss(i.object.fontFamily),textAlign:o.textAlignmentToCss(i.object.textAlign),flexDirection:"column",justifyContent:i.object.verticalAlign===o.PdfVerticalAlignment.Top?"flex-start":i.object.verticalAlign===o.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:i.object.backgroundColor,opacity:i.object.opacity,width:b?`${f}%`:"100%",height:b?`${f}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:b?`scale(${v})`:void 0,transformOrigin:"top left"},contentEditable:t,...u,children:i.object.contents})})}function M({pageIndex:e,annotation:t,scaleFactor:i=1,style:s,...a}){const{provides:c}=d(),[u,h]=l.useState(null),g=l.useRef(null),{width:p,height:x}=t.rect.size;l.useEffect((()=>{if(c){const n=c.renderAnnotation({pageIndex:e,annotation:t,options:{scaleFactor:i,dpr:window.devicePixelRatio}});return n.wait((e=>{const t=URL.createObjectURL(e);h(t),g.current=t}),o.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:o.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[e,i,c,t.id,p,x]);return n.jsx(r.Fragment,{children:u&&n.jsx("img",{src:u,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...s||{}}})})}function A({isSelected:e,annotation:t,pageIndex:o,scale:i,onClick:s}){return n.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,onTouchStart:s,children:n.jsx(M,{pageIndex:o,annotation:{...t.object,id:t.object.id},scaleFactor:i})})}function w(e){const{pageIndex:a,scale:c,selectionMenu:u}=e,{provides:M}=d(),{provides:w}=s.useSelectionCapability(),[z,P]=l.useState([]),{register:R}=i.usePointerHandlers({pageIndex:a}),[C,D]=l.useState(null),[I,E]=l.useState(null);l.useEffect((()=>{M&&M.onStateChange((e=>{P(t.getAnnotationsByPageIndex(e,a)),D(t.getSelectedAnnotationByPageIndex(e,a))}))}),[M]);const B=l.useMemo((()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&M&&(M.deselectAnnotation(),E(null))}})),[M]),T=l.useCallback(((e,t)=>{e.stopPropagation(),M&&w&&(M.selectAnnotation(a,t.object.id),w.clear(),t.object.id!==I&&E(null))}),[M,w,I,a]);return l.useEffect((()=>R(B)),[R,B]),n.jsx(n.Fragment,{children:z.map((i=>{const s=(null==C?void 0:C.object.id)===i.object.id,l=I===i.object.id,d=null==M?void 0:M.findToolForAnnotation(i.object);return t.isInk(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!0,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(y,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isSquare(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!0,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(v,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isCircle(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!0,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(f,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isUnderline(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!1,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),zIndex:0,style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(p,{...e,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isStrikeout(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!1,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),zIndex:0,style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(x,{...e,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isSquiggly(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!1,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),zIndex:0,style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(b,{...e,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isHighlight(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!1,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),zIndex:0,style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Multiply)},...e,children:e=>n.jsx(g,{...e,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isLine(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(r.Fragment,{children:n.jsx(m,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})})},i.object.id):t.isPolyline(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(r.Fragment,{children:n.jsx(j,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})})},i.object.id):t.isPolygon(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!1,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(r.Fragment,{children:n.jsx(k,{...e,isSelected:s,scale:c,onClick:e=>T(e,i)})})},i.object.id):t.isFreeText(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:((null==d?void 0:d.interaction.isDraggable)??!0)&&!l,isResizable:(null==d?void 0:d.interaction.isResizable)??!0,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),E(i.object.id)},...e,children:e=>n.jsx(S,{isSelected:s,isEditing:l,annotation:{...i,object:e},pageIndex:a,scale:c,onClick:e=>T(e,i)})},i.object.id):t.isStamp(i)?n.jsx(h,{trackedAnnotation:i,isSelected:s,isDraggable:(null==d?void 0:d.interaction.isDraggable)??!0,isResizable:(null==d?void 0:d.interaction.isResizable)??!0,lockAspectRatio:(null==d?void 0:d.interaction.lockAspectRatio)??!1,selectionMenu:u,onSelect:e=>T(e,i),style:{mixBlendMode:o.blendModeToCss(i.object.blendMode??o.PdfBlendMode.Normal)},...e,children:e=>n.jsx(A,{isSelected:s,annotation:i,pageIndex:a,scale:c,onClick:e=>T(e,i)})},i.object.id):null}))})}function z({pageIndex:e,scale:t}){var i,r,a,c,u,h,y,v,f,m,j,k;const{provides:S}=s.useSelectionCapability(),{provides:M}=d(),[A,w]=l.useState([]),[z,P]=l.useState(null),[R,C]=l.useState(null);if(l.useEffect((()=>{if(!S)return;return S.onSelectionChange((()=>{w(S.getHighlightRectsForPage(e)),P(S.getBoundingRectForPage(e))}))}),[S,e]),l.useEffect((()=>{if(!M)return;return M.onActiveToolChange(C)}),[M]),!z)return null;if(!R||!R.defaults)return null;switch(R.defaults.type){case o.PdfAnnotationSubtype.UNDERLINE:return n.jsx("div",{style:{mixBlendMode:o.blendModeToCss((null==(i=R.defaults)?void 0:i.blendMode)??o.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(p,{color:null==(r=R.defaults)?void 0:r.color,opacity:null==(a=R.defaults)?void 0:a.opacity,segmentRects:A,scale:t})});case o.PdfAnnotationSubtype.HIGHLIGHT:return n.jsx("div",{style:{mixBlendMode:o.blendModeToCss((null==(c=R.defaults)?void 0:c.blendMode)??o.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(g,{color:null==(u=R.defaults)?void 0:u.color,opacity:null==(h=R.defaults)?void 0:h.opacity,segmentRects:A,scale:t})});case o.PdfAnnotationSubtype.STRIKEOUT:return n.jsx("div",{style:{mixBlendMode:o.blendModeToCss((null==(y=R.defaults)?void 0:y.blendMode)??o.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(x,{color:null==(v=R.defaults)?void 0:v.color,opacity:null==(f=R.defaults)?void 0:f.opacity,segmentRects:A,scale:t})});case o.PdfAnnotationSubtype.SQUIGGLY:return n.jsx("div",{style:{mixBlendMode:o.blendModeToCss((null==(m=R.defaults)?void 0:m.blendMode)??o.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:n.jsx(b,{color:null==(j=R.defaults)?void 0:j.color,opacity:null==(k=R.defaults)?void 0:k.opacity,segmentRects:A,scale:t})});default:return null}}function P({preview:e,scale:t}){const{bounds:i}=e,s={position:"absolute",left:i.origin.x*t,top:i.origin.y*t,width:i.size.width*t,height:i.size.height*t,pointerEvents:"none",zIndex:10};return e.type===o.PdfAnnotationSubtype.CIRCLE?n.jsx("div",{style:s,children:n.jsx(f,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.SQUARE?n.jsx("div",{style:s,children:n.jsx(v,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.POLYGON?n.jsx("div",{style:s,children:n.jsx(k,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.POLYLINE?n.jsx("div",{style:s,children:n.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.LINE?n.jsx("div",{style:s,children:n.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.INK?n.jsx("div",{style:s,children:n.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===o.PdfAnnotationSubtype.FREETEXT?n.jsx("div",{style:s,children:n.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function R({pageIndex:e,scale:t}){const{plugin:o}=c(),[i,s]=l.useState(new Map),r=l.useRef(null),a=l.useRef(null),d=l.useMemo((()=>({requestFile:({accept:e,onFile:t})=>{if(!r.current)return;const n=r.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=a.current;if(!i||!i.getContext)return;const s=i.getContext("2d");if(!s)return;const r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let{naturalWidth:l,naturalHeight:a}=r;const c=t?t/l:1,d=n?n/a:1,u=Math.min(c,d,1),h=l*u,g=a*u;i.width=h,i.height=g,s.drawImage(r,0,0,h,g);const p=s.getImageData(0,0,h,g);"string"!=typeof e&&URL.revokeObjectURL(r.src),o({imageData:p,width:h,height:g})},r.src="string"==typeof e?e:URL.createObjectURL(e)}})),[]);return l.useEffect((()=>{if(o)return o.registerPageHandlers(e,t,{services:d,onPreview:(e,t)=>{s((n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o}))}})}),[e,t,o,d]),n.jsxs(n.Fragment,{children:[n.jsx("input",{ref:r,type:"file",style:{display:"none"}}),n.jsx("canvas",{ref:a,style:{display:"none"}}),Array.from(i.entries()).map((([e,o])=>n.jsx(P,{preview:o,scale:t},e)))]})}exports.AnnotationLayer=function({style:e,pageIndex:t,scale:o,selectionMenu:i,resizeUI:s,vertexUI:r,pageWidth:l,pageHeight:a,rotation:c,selectionOutlineColor:d,customAnnotationRenderer:u,...h}){return n.jsxs("div",{style:{...e},...h,children:[n.jsx(w,{selectionMenu:i,pageIndex:t,scale:o,rotation:c,pageWidth:l,pageHeight:a,resizeUI:s,vertexUI:r,selectionOutlineColor:d,customAnnotationRenderer:u}),n.jsx(z,{pageIndex:t,scale:o}),n.jsx(R,{pageIndex:t,scale:o})]})},exports.useAnnotationCapability=d,exports.useAnnotationPlugin=c,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/preact"),t=require("@embedpdf/plugin-annotation"),n=require("preact"),o=require("preact/hooks"),i=require("preact/jsx-runtime"),s=require("@embedpdf/models"),r=require("@embedpdf/plugin-interaction-manager/preact"),l=require("@embedpdf/plugin-selection/preact"),a=require("@embedpdf/utils/preact"),c={},d=()=>e.usePlugin(t.AnnotationPlugin.id),u=()=>e.useCapability(t.AnnotationPlugin.id);function h({scale:e,pageIndex:t,rotation:n,pageWidth:s,pageHeight:r,trackedAnnotation:l,children:c,isSelected:d,isDraggable:h,isResizable:g,lockAspectRatio:p=!1,style:x={},vertexConfig:b,selectionMenu:y,outlineOffset:v=1,onDoubleClick:f,onSelect:m,zIndex:j=1,resizeUI:k,vertexUI:S,selectionOutlineColor:M="#007ACC",customAnnotationRenderer:A,...w}){const[z,P]=o.useState(l.object),{provides:C}=u(),R=o.useRef(null),D=z?{...l.object,...z}:l.object,I=(null==k?void 0:k.color)??"#007ACC",E=(null==S?void 0:S.color)??"#007ACC",B=(null==k?void 0:k.size)??12,T=(null==S?void 0:S.size)??12,{dragProps:$,vertices:L,resize:F}=a.useInteractionHandles({controller:{element:D.rect,vertices:null==b?void 0:b.extractVertices(D),constraints:{minWidth:10,minHeight:10,boundingBox:{width:s/e,height:r/e}},maintainAspectRatio:p,pageRotation:n,scale:e,enabled:d,onUpdate:e=>{var n;if(!(null==(n=e.transformData)?void 0:n.type))return;"start"===e.state&&(R.current=D);const o=e.transformData.type,i=R.current??D,s=e.transformData.changes.vertices?null==b?void 0:b.transformAnnotation(i,e.transformData.changes.vertices):{rect:e.transformData.changes.rect},r=null==C?void 0:C.transformAnnotation(i,{type:o,changes:s,metadata:e.transformData.metadata});r&&P((e=>({...e,...r}))),"end"===e.state&&r&&(R.current=null,null==C||C.updateAnnotation(t,l.object.id,r))}},resizeUI:{handleSize:B,spacing:v,offsetMode:"outside",includeSides:!p,zIndex:j+1},vertexUI:{vertexSize:T,zIndex:j+2},includeVertices:!!b}),W=a.useDoublePressProps(f);return o.useEffect((()=>{P(l.object)}),[l.object]),i.jsxs("div",{"data-no-interaction":!0,children:[i.jsxs("div",{...h&&d?$:{},...W,style:{position:"absolute",left:D.rect.origin.x*e,top:D.rect.origin.y*e,width:D.rect.size.width*e,height:D.rect.size.height*e,outline:d?`1px solid ${M}`:"none",outlineOffset:d?`${v}px`:"0px",pointerEvents:d?"auto":"none",touchAction:"none",cursor:d&&h?"move":"default",zIndex:j,...x},...w,children:[(()=>{const o="function"==typeof c?c(D):c,i=null==A?void 0:A({annotation:D,children:o,isSelected:d,scale:e,rotation:n,pageWidth:s,pageHeight:r,pageIndex:t,onSelect:m});return null!=i?i:o})(),d&&g&&F.map((({key:e,...t})=>(null==k?void 0:k.component)?k.component({key:e,...t,backgroundColor:I}):i.jsx("div",{...t,style:{...t.style,backgroundColor:I}},e))),d&&L.map((({key:e,...t})=>(null==S?void 0:S.component)?S.component({key:e,...t,backgroundColor:E}):i.jsx("div",{...t,style:{...t.style,backgroundColor:E}},e)))]}),i.jsx(a.CounterRotate,{rect:{origin:{x:D.rect.origin.x*e,y:D.rect.origin.y*e},size:{width:D.rect.size.width*e,height:D.rect.size.height*e}},rotation:n,children:({rect:e,menuWrapperProps:t})=>y&&y({annotation:l,selected:d,rect:e,menuWrapperProps:t})})]})}function g({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){return i.jsx(i.Fragment,{children:n.map(((n,a)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:e,opacity:t,pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:void 0,...l}},a)))})}function p({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s;return i.jsx(i.Fragment,{children:n.map(((n,c)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.jsx("div",{style:{position:"absolute",left:0,bottom:0,width:"100%",height:a,background:e,opacity:t,pointerEvents:"none"}})},c)))})}function x({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s;return i.jsx(i.Fragment,{children:n.map(((n,c)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?n.origin.x-o.origin.x:n.origin.x)*s,top:(o?n.origin.y-o.origin.y:n.origin.y)*s,width:n.size.width*s,height:n.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.jsx("div",{style:{position:"absolute",left:0,top:"50%",width:"100%",height:a,background:e,opacity:t,transform:"translateY(-50%)",pointerEvents:"none"}})},c)))})}function b({color:e="#FFFF00",opacity:t=.5,segmentRects:n,rect:o,scale:s,onClick:r,style:l}){const a=2*s,c=6*s,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}" stroke-width="${a}" stroke-linecap="round"/>\n </svg>`)}")`;return i.jsx(i.Fragment,{children:n.map(((e,n)=>i.jsx("div",{onPointerDown:r,onTouchStart:r,style:{position:"absolute",left:(o?e.origin.x-o.origin.x:e.origin.x)*s,top:(o?e.origin.y-o.origin.y:e.origin.y)*s,width:e.size.width*s,height:e.size.height*s,background:"transparent",pointerEvents:r?"auto":"none",cursor:r?"pointer":"default",zIndex:r?1:0,...l},children:i.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 y({isSelected:e,color:t="#000000",opacity:n=1,strokeWidth:s,inkList:r,rect:l,scale:a,onClick:c}){const d=o.useMemo((()=>r.map((({points:e})=>{let t="";return e.forEach((({x:e,y:n},o)=>{const i=e-l.origin.x,s=n-l.origin.y;t+=(0===o?"M":"L")+i+" "+s+" "})),t.trim()}))),[r,l]),u=l.size.width*a,h=l.size.height*a;return i.jsx("svg",{style:{position:"absolute",width:u,height:h,pointerEvents:"none",zIndex:2,overflow:"visible"},width:u,height:h,viewBox:`0 0 ${l.size.width} ${l.size.height}`,children:d.map(((o,r)=>i.jsx("path",{d:o,fill:"none",opacity:n,onPointerDown:c,onTouchStart:c,style:{cursor:e?"move":"pointer",pointerEvents:e?"none":"visibleStroke",stroke:t,strokeWidth:s,strokeLinecap:"round",strokeLinejoin:"round"}},r)))})}function v({isSelected:e,color:t="#000000",strokeColor:n,opacity:r=1,strokeWidth:l,strokeStyle:a=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:c,rect:d,scale:u,onClick:h}){const{width:g,height:p,x:x,y:b}=o.useMemo((()=>{const e=d.size.width,t=d.size.height;return{width:Math.max(e-l,0),height:Math.max(t-l,0),x:l/2,y:l/2}}),[d,l]),y=(g+l)*u,v=(p+l)*u;return i.jsx("svg",{style:{position:"absolute",width:y,height:v,pointerEvents:"none",zIndex:2},width:y,height:v,viewBox:`0 0 ${g+l} ${p+l}`,children:i.jsx("rect",{x:x,y:b,width:g,height:p,fill:t,opacity:r,onPointerDown:h,onTouchStart:h,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 f({color:e="#000000",strokeColor:t,opacity:n=1,strokeWidth:r,strokeStyle:l=s.PdfAnnotationBorderStyle.SOLID,strokeDashArray:a,rect:c,scale:d,onClick:u,isSelected:h}){const{width:g,height:p,cx:x,cy:b,rx:y,ry:v}=o.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]),f=g*d,m=p*d;return i.jsx("svg",{style:{position:"absolute",width:f,height:m,pointerEvents:"none",zIndex:2},width:f,height:m,viewBox:`0 0 ${g} ${p}`,children:i.jsx("ellipse",{cx:x,cy:b,rx:y,ry:v,fill:e,opacity:n,onPointerDown:u,onTouchStart:u,style:{cursor:h?"move":"pointer",pointerEvents:h?"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:h,scale:g,onClick:p,isSelected:x}){const{x1:b,y1:y,x2:v,y2:f}=o.useMemo((()=>({x1:u.start.x-d.origin.x,y1:u.start.y-d.origin.y,x2:u.end.x-d.origin.x,y2:u.end.y-d.origin.y})),[u,d]),m=o.useMemo((()=>{const e=Math.atan2(f-y,v-b);return{start:t.patching.createEnding(null==h?void 0:h.start,r,e+Math.PI,b,y),end:t.patching.createEnding(null==h?void 0:h.end,r,e,v,f)}}),[h,r,b,y,v,f]),j=d.size.width*g,k=d.size.height*g;return i.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:[i.jsx("line",{x1:b,y1:y,x2:v,y2:f,opacity:n,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",pointerEvents:x?"none":"visibleStroke",stroke:l,strokeWidth:r,strokeLinecap:"butt",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}}}),m.start&&i.jsx("path",{d:m.start.d,transform:m.start.transform,onPointerDown:p,onTouchStart:p,stroke:l,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.start.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.start.filled?e:"none"}),m.end&&i.jsx("path",{d:m.end.d,transform:m.end.transform,stroke:l,onPointerDown:p,onTouchStart:p,style:{cursor:x?"move":"pointer",strokeWidth:r,strokeLinecap:"butt",pointerEvents:x?"none":m.end.filled?"visible":"visibleStroke",...a===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==c?void 0:c.join(",")}},fill:m.end.filled?e:"none"})]})}function j({rect:e,vertices:n,color:s="transparent",strokeColor:r="#000000",opacity:l=1,strokeWidth:a,scale:c,isSelected:d,onClick:u,lineEndings:h}){const g=o.useMemo((()=>n.map((({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})))),[n,e]),p=o.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]),x=o.useMemo((()=>{if(g.length<2)return{start:null,end:null};const e=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),n=e(g[0],g[1]),o=e(g[g.length-2],g[g.length-1]);return{start:t.patching.createEnding(null==h?void 0:h.start,a,n+Math.PI,g[0].x,g[0].y),end:t.patching.createEnding(null==h?void 0:h.end,a,o,g[g.length-1].x,g[g.length-1].y)}}),[g,h,a]),b=e.size.width*c,y=e.size.height*c;return i.jsxs("svg",{style:{position:"absolute",width:b,height:y,pointerEvents:"none",zIndex:2,overflow:"visible"},width:b,height:y,viewBox:`0 0 ${e.size.width} ${e.size.height}`,children:[i.jsx("path",{d:p,onPointerDown:u,onTouchStart:u,opacity:l,style:{fill:"none",stroke:r??s,strokeWidth:a,cursor:d?"move":"pointer",pointerEvents:d?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"}}),x.start&&i.jsx("path",{d:x.start.d,transform:x.start.transform,stroke:r,fill:x.start.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.start.filled?"visible":"visibleStroke",strokeLinecap:"butt"}}),x.end&&i.jsx("path",{d:x.end.d,transform:x.end.transform,stroke:r,fill:x.end.filled?s:"none",onPointerDown:u,onTouchStart:u,style:{cursor:d?"move":"pointer",strokeWidth:a,pointerEvents:d?"none":x.end.filled?"visible":"visibleStroke",strokeLinecap:"butt"}})]})}function k({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:h,onClick:g,currentVertex:p,handleSize:x=14}){const b=p?[...t,p]:t,y=o.useMemo((()=>b.map((({x:t,y:n})=>({x:t-e.origin.x,y:n-e.origin.y})))),[b,e]),v=o.useMemo((()=>{if(!y.length)return"";const[e,...t]=y,n=!!p;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y}`)).join(" ")+(n?"":" Z")).trim()}),[y,p]),f=p&&t.length>0,m=e.size.width*u,j=e.size.height*u;return i.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:[i.jsx("path",{d:v,onPointerDown:g,onTouchStart:g,opacity:l,style:{fill:p?"none":n,stroke:r??n,strokeWidth:a,cursor:h?"move":"pointer",pointerEvents:h?"none":"transparent"===n?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...c===s.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==d?void 0:d.join(",")}}}),f&&t.length>1&&i.jsx("path",{d:`M ${y[y.length-1].x} ${y[y.length-1].y} L ${y[0].x} ${y[0].y}`,fill:"none",style:{stroke:r,strokeWidth:a,strokeDasharray:"4,4",opacity:.7}}),f&&t.length>=2&&i.jsx("rect",{x:y[0].x-x/u/2,y:y[0].y-x/u/2,width:x/u,height:x/u,fill:r,opacity:.4,stroke:r,strokeWidth:a/2})]})}function S({isSelected:e,isEditing:t,annotation:n,pageIndex:r,scale:l,onClick:a}){const d=o.useRef(null),{provides:h}=u(),[g,p]=o.useState(!1);o.useEffect((()=>{if(t&&d.current){const e=d.current;e.focus();const t=window.getSelection();if(t){const n=document.createRange();n.selectNodeContents(e),n.collapse(!1),t.removeAllRanges(),t.addRange(n)}}}),[t]),o.useLayoutEffect((()=>{try{const e=navigator,t=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1;p(t)}catch{p(!1)}}),[]);const x=n.object.fontSize*l,b=g&&t&&x>0&&x<16,y=b?16:x,v=b?x/16:1,f=b?100/v:100;return i.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:i.jsx("span",{ref:d,onBlur:()=>{h&&d.current&&h.updateAnnotation(r,n.object.id,{contents:d.current.innerText})},tabIndex:0,style:{color:n.object.fontColor,fontSize:y,fontFamily:s.standardFontCss(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.backgroundColor,opacity:n.object.opacity,width:b?`${f}%`:"100%",height:b?`${f}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:t?"text":"pointer",outline:"none",transform:b?`scale(${v})`:void 0,transformOrigin:"top left"},contentEditable:t,...c,children:n.object.contents})})}function M({pageIndex:e,annotation:t,scaleFactor:r=1,style:l,...a}){const{provides:c}=u(),[d,h]=o.useState(null),g=o.useRef(null),{width:p,height:x}=t.rect.size;o.useEffect((()=>{if(c){const n=c.renderAnnotation({pageIndex:e,annotation:t,options:{scaleFactor:r,dpr:window.devicePixelRatio}});return n.wait((e=>{const t=URL.createObjectURL(e);h(t),g.current=t}),s.ignore),()=>{g.current?(URL.revokeObjectURL(g.current),g.current=null):n.abort({code:s.PdfErrorCode.Cancelled,message:"canceled render task"})}}}),[e,r,c,t.id,p,x]);return i.jsx(n.Fragment,{children:d&&i.jsx("img",{src:d,onLoad:()=>{g.current&&(URL.revokeObjectURL(g.current),g.current=null)},...a,style:{width:"100%",height:"100%",display:"block",...l||{}}})})}function A({isSelected:e,annotation:t,pageIndex:n,scale:o,onClick:s}){return i.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:e?"none":"auto",cursor:"pointer"},onPointerDown:s,onTouchStart:s,children:i.jsx(M,{pageIndex:n,annotation:{...t.object,id:t.object.id},scaleFactor:o})})}function w(e){const{pageIndex:a,scale:c,selectionMenu:d}=e,{provides:M}=u(),{provides:w}=l.useSelectionCapability(),[z,P]=o.useState([]),{register:C}=r.usePointerHandlers({pageIndex:a}),[R,D]=o.useState(null),[I,E]=o.useState(null);o.useEffect((()=>{M&&M.onStateChange((e=>{P(t.getAnnotationsByPageIndex(e,a)),D(t.getSelectedAnnotationByPageIndex(e,a))}))}),[M]);const B=o.useMemo((()=>({onPointerDown:(e,t)=>{t.target===t.currentTarget&&M&&(M.deselectAnnotation(),E(null))}})),[M]),T=o.useCallback(((e,t)=>{e.stopPropagation(),M&&w&&(M.selectAnnotation(a,t.object.id),w.clear(),t.object.id!==I&&E(null))}),[M,w,I,a]);return o.useEffect((()=>C(B)),[C,B]),i.jsx(i.Fragment,{children:z.map((o=>{const r=(null==R?void 0:R.object.id)===o.object.id,l=I===o.object.id,u=null==M?void 0:M.findToolForAnnotation(o.object);return t.isInk(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(y,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isSquare(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(v,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isCircle(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(f,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isUnderline(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(p,{...e,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isStrikeout(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(x,{...e,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isSquiggly(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(b,{...e,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isHighlight(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!1,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),zIndex:0,style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Multiply)},...e,children:e=>i.jsx(g,{...e,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isLine(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),vertexConfig:{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(m,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})})},o.object.id):t.isPolyline(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(j,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})})},o.object.id):t.isPolygon(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!1,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),vertexConfig:{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})},style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(n.Fragment,{children:i.jsx(k,{...e,isSelected:r,scale:c,onClick:e=>T(e,o)})})},o.object.id):t.isFreeText(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:((null==u?void 0:u.interaction.isDraggable)??!0)&&!l,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},onDoubleClick:e=>{e.stopPropagation(),E(o.object.id)},...e,children:e=>i.jsx(S,{isSelected:r,isEditing:l,annotation:{...o,object:e},pageIndex:a,scale:c,onClick:e=>T(e,o)})},o.object.id):t.isStamp(o)?i.jsx(h,{trackedAnnotation:o,isSelected:r,isDraggable:(null==u?void 0:u.interaction.isDraggable)??!0,isResizable:(null==u?void 0:u.interaction.isResizable)??!0,lockAspectRatio:(null==u?void 0:u.interaction.lockAspectRatio)??!1,selectionMenu:d,onSelect:e=>T(e,o),style:{mixBlendMode:s.blendModeToCss(o.object.blendMode??s.PdfBlendMode.Normal)},...e,children:e=>i.jsx(A,{isSelected:r,annotation:o,pageIndex:a,scale:c,onClick:e=>T(e,o)})},o.object.id):null}))})}function z({pageIndex:e,scale:t}){var n,r,a,c,d,h,y,v,f,m,j,k;const{provides:S}=l.useSelectionCapability(),{provides:M}=u(),[A,w]=o.useState([]),[z,P]=o.useState(null),[C,R]=o.useState(null);if(o.useEffect((()=>{if(!S)return;return S.onSelectionChange((()=>{w(S.getHighlightRectsForPage(e)),P(S.getBoundingRectForPage(e))}))}),[S,e]),o.useEffect((()=>{if(!M)return;return M.onActiveToolChange(R)}),[M]),!z)return null;if(!C||!C.defaults)return null;switch(C.defaults.type){case s.PdfAnnotationSubtype.UNDERLINE:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(n=C.defaults)?void 0:n.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(p,{color:null==(r=C.defaults)?void 0:r.color,opacity:null==(a=C.defaults)?void 0:a.opacity,segmentRects:A,scale:t})});case s.PdfAnnotationSubtype.HIGHLIGHT:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(c=C.defaults)?void 0:c.blendMode)??s.PdfBlendMode.Multiply),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(g,{color:null==(d=C.defaults)?void 0:d.color,opacity:null==(h=C.defaults)?void 0:h.opacity,segmentRects:A,scale:t})});case s.PdfAnnotationSubtype.STRIKEOUT:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(y=C.defaults)?void 0:y.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(x,{color:null==(v=C.defaults)?void 0:v.color,opacity:null==(f=C.defaults)?void 0:f.opacity,segmentRects:A,scale:t})});case s.PdfAnnotationSubtype.SQUIGGLY:return i.jsx("div",{style:{mixBlendMode:s.blendModeToCss((null==(m=C.defaults)?void 0:m.blendMode)??s.PdfBlendMode.Normal),pointerEvents:"none",position:"absolute",inset:0},children:i.jsx(b,{color:null==(j=C.defaults)?void 0:j.color,opacity:null==(k=C.defaults)?void 0:k.opacity,segmentRects:A,scale:t})});default:return null}}function P({preview:e,scale:t}){const{bounds:n}=e,o={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?i.jsx("div",{style:o,children:i.jsx(f,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.SQUARE?i.jsx("div",{style:o,children:i.jsx(v,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYGON?i.jsx("div",{style:o,children:i.jsx(k,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.POLYLINE?i.jsx("div",{style:o,children:i.jsx(j,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.LINE?i.jsx("div",{style:o,children:i.jsx(m,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.INK?i.jsx("div",{style:o,children:i.jsx(y,{isSelected:!1,scale:t,...e.data})}):e.type===s.PdfAnnotationSubtype.FREETEXT?i.jsx("div",{style:o,children:i.jsx("div",{style:{width:"100%",height:"100%",border:`1px dashed ${e.data.fontColor||"#000000"}`,backgroundColor:"transparent"}})}):null}function C({pageIndex:e,scale:t}){const{plugin:n}=d(),[s,r]=o.useState(new Map),l=o.useRef(null),a=o.useRef(null),c=o.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=a.current;if(!i||!i.getContext)return;const s=i.getContext("2d");if(!s)return;const r=new Image;r.crossOrigin="Anonymous",r.onload=()=>{let{naturalWidth:l,naturalHeight:a}=r;const c=t?t/l:1,d=n?n/a:1,u=Math.min(c,d,1),h=l*u,g=a*u;i.width=h,i.height=g,s.drawImage(r,0,0,h,g);const p=s.getImageData(0,0,h,g);"string"!=typeof e&&URL.revokeObjectURL(r.src),o({imageData:p,width:h,height:g})},r.src="string"==typeof e?e:URL.createObjectURL(e)}})),[]);return o.useEffect((()=>{if(n)return n.registerPageHandlers(e,t,{services:c,onPreview:(e,t)=>{r((n=>{const o=new Map(n);return t?o.set(e,t):o.delete(e),o}))}})}),[e,t,n,c]),i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:l,type:"file",style:{display:"none"}}),i.jsx("canvas",{ref:a,style:{display:"none"}}),Array.from(s.entries()).map((([e,n])=>i.jsx(P,{preview:n,scale:t},e)))]})}exports.AnnotationLayer=function({style:e,pageIndex:t,scale:n,selectionMenu:o,resizeUI:s,vertexUI:r,pageWidth:l,pageHeight:a,rotation:c,selectionOutlineColor:d,customAnnotationRenderer:u,...h}){return i.jsxs("div",{style:{...e},...h,children:[i.jsx(w,{selectionMenu:o,pageIndex:t,scale:n,rotation:c,pageWidth:l,pageHeight:a,resizeUI:s,vertexUI:r,selectionOutlineColor:d,customAnnotationRenderer:u}),i.jsx(z,{pageIndex:t,scale:n}),i.jsx(C,{pageIndex:t,scale:n})]})},exports.useAnnotation=()=>{const{provides:e}=u(),[n,i]=o.useState(t.initialState({enabled:!0}));return o.useEffect((()=>null==e?void 0:e.onStateChange((e=>{i(e)}))),[e]),{state:n,provides:e}},exports.useAnnotationCapability=u,exports.useAnnotationPlugin=d,Object.keys(t).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|