@embedpdf/plugin-annotation 1.3.13 → 1.3.15
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.
|
@@ -15,8 +15,8 @@ declare const _default: <T extends PdfAnnotationObject>(__VLS_props: NonNullable
|
|
|
15
15
|
lockAspectRatio?: boolean;
|
|
16
16
|
vertexConfig?: VertexConfig<T>;
|
|
17
17
|
outlineOffset?: number;
|
|
18
|
-
onDoubleClick?: (event:
|
|
19
|
-
onSelect: (event:
|
|
18
|
+
onDoubleClick?: (event: PointerEvent | MouseEvent) => void;
|
|
19
|
+
onSelect: (event: TouchEvent | MouseEvent) => void;
|
|
20
20
|
zIndex?: number;
|
|
21
21
|
selectionOutlineColor?: string;
|
|
22
22
|
} & {}> & import('vue').PublicProps;
|
package/dist/vue/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),o=require("@embedpdf/plugin-annotation"),n=require("@embedpdf/utils/vue"),l=require("@embedpdf/plugin-interaction-manager/vue"),r=require("@embedpdf/plugin-selection/vue"),i=require("@embedpdf/models"),a=()=>t.usePlugin(o.AnnotationPlugin.id),c=()=>t.useCapability(o.AnnotationPlugin.id),s={"data-no-interaction":""},d="#007ACC",u="#007ACC",p=e.defineComponent({__name:"annotation-container",props:{scale:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isDraggable:{type:Boolean},isResizable:{type:Boolean},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},outlineOffset:{default:1},onDoubleClick:{},onSelect:{},zIndex:{default:1},selectionOutlineColor:{default:"#007ACC"}},setup(t){const o=t,l=e.shallowRef(e.toRaw(o.trackedAnnotation.object)),{provides:r}=c(),i=e.ref(null),a=e.computed((()=>({...e.toRaw(o.trackedAnnotation.object),...e.toRaw(l.value)}))),p=e.computed((()=>e.toRaw(a.value).rect)),v=e.computed((()=>{var t;const n=e.toRaw(a.value);return(null==(t=o.vertexConfig)?void 0:t.extractVertices(n))??[]})),k=e.computed((()=>({minWidth:10,minHeight:10,boundingBox:{width:o.pageWidth/o.scale,height:o.pageHeight/o.scale}}))),{dragProps:g,vertices:h,resize:f}=n.useInteractionHandles({controller:{element:p,vertices:v,constraints:k,maintainAspectRatio:e.computed((()=>o.lockAspectRatio)),pageRotation:e.computed((()=>o.rotation)),scale:e.computed((()=>o.scale)),enabled:e.computed((()=>o.isSelected)),onUpdate:t=>{var n,c,s,d;if(!(null==(n=t.transformData)?void 0:n.type))return;"start"===t.state&&(i.value=a.value);const u=i.value??a.value,p=t.transformData.changes.vertices?null==(c=o.vertexConfig)?void 0:c.transformAnnotation(e.toRaw(u),t.transformData.changes.vertices):{rect:t.transformData.changes.rect},v=null==(s=r.value)?void 0:s.transformAnnotation(u,{type:t.transformData.type,changes:p,metadata:t.transformData.metadata});v&&(l.value={...e.toRaw(l.value),...v}),"end"===t.state&&v&&(i.value=null,null==(d=r.value)||d.updateAnnotation(o.pageIndex,o.trackedAnnotation.object.id,v))}},resizeUI:{handleSize:12,spacing:o.outlineOffset,offsetMode:"outside",includeSides:!o.lockAspectRatio,zIndex:o.zIndex+1},vertexUI:{vertexSize:12,zIndex:o.zIndex+2},includeVertices:!!o.vertexConfig}),m=n.useDoublePressProps(o.onDoubleClick);e.watch((()=>o.trackedAnnotation.object),(e=>{l.value=e}),{deep:!0});const y=e.computed((()=>({position:"absolute",left:a.value.rect.origin.x*o.scale+"px",top:a.value.rect.origin.y*o.scale+"px",width:a.value.rect.size.width*o.scale+"px",height:a.value.rect.size.height*o.scale+"px",outline:o.isSelected?`1px solid ${o.selectionOutlineColor}`:"none",outlineOffset:o.isSelected?`${o.outlineOffset}px`:"0px",pointerEvents:o.isSelected?"auto":"none",touchAction:"none",cursor:o.isSelected&&o.isDraggable?"move":"default",zIndex:o.zIndex}))),x=e.useSlots();return(t,o)=>(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",e.mergeProps({...e.unref(g),...e.unref(m)},{style:y.value}),[e.renderSlot(t.$slots,"default",{annotation:a.value}),t.isSelected&&t.isResizable?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(f),(({key:o,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o},[e.unref(x)["resize-handle"]?e.renderSlot(t.$slots,"resize-handle",e.mergeProps({key:0,ref_for:!0},{key:o,style:n,...l,backgroundColor:d}),(()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},l,{style:[n,{backgroundColor:d}]}),null,16)])):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},l,{style:[n,{backgroundColor:d}]}),null,16))],64)))),128)):e.createCommentVNode("",!0),t.isSelected&&e.unref(h).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(e.unref(h),(({key:o,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o},[e.unref(x)["vertex-handle"]?e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({key:0,ref_for:!0},{key:o,style:n,...l,backgroundColor:u}),(()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},l,{style:[n,{backgroundColor:u}]}),null,16)])):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},l,{style:[n,{backgroundColor:u}]}),null,16))],64)))),128)):e.createCommentVNode("",!0)],16),e.createVNode(e.unref(n.CounterRotate),{rect:{origin:{x:a.value.rect.origin.x*t.scale,y:a.value.rect.origin.y*t.scale},size:{width:a.value.rect.size.width*t.scale,height:a.value.rect.size.height*t.scale}},rotation:t.rotation},{default:e.withCtx((({rect:o,menuWrapperProps:n})=>[e.renderSlot(t.$slots,"selection-menu",{annotation:t.trackedAnnotation,selected:t.isSelected,rect:o,menuWrapperProps:n})])),_:3},8,["rect","rotation"])]))}}),v=["width","height","viewBox"],k=["cx","cy","rx","ry","fill","opacity"],g=e.defineComponent({__name:"circle",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:i.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>{const e=o.rect.size.width,t=o.rect.size.height,n=Math.max(e-o.strokeWidth,0),l=Math.max(t-o.strokeWidth,0);return{width:e,height:t,cx:o.strokeWidth/2+n/2,cy:o.strokeWidth/2+l/2,rx:n/2,ry:l/2}})),l=e.computed((()=>n.value.width*o.scale)),r=e.computed((()=>n.value.height*o.scale));return(t,o)=>{var a;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:l.value,height:r.value,pointerEvents:"none",zIndex:2}),width:l.value,height:r.value,viewBox:`0 0 ${n.value.width} ${n.value.height}`},[e.createElementVNode("ellipse",{cx:n.value.cx,cy:n.value.cy,rx:n.value.rx,ry:n.value.ry,fill:t.color,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===e.unref(i.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(a=t.strokeDashArray)?void 0:a.join(",")}})},null,44,k)],12,v)}}}),h=["contenteditable"],f=e.defineComponent({__name:"free-text",props:{isSelected:{type:Boolean},isEditing:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{type:Function}},setup(t){const o=t,n=e.ref(null),{provides:l}=c(),r=e.ref(!1);e.onMounted((()=>{try{const e=navigator;r.value=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1}catch{r.value=!1}})),e.watch((()=>o.isEditing),(e=>{if(e&&n.value){const e=n.value;e.focus();const t=window.getSelection();if(t){const o=document.createRange();o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o)}}}));const a=()=>{l.value&&n.value&&l.value.updateAnnotation(o.pageIndex,o.annotation.object.id,{contents:n.value.innerText})},s=e.computed((()=>{const{object:e}=o.annotation,t=e.fontSize*o.scale,n=r.value&&o.isEditing&&t>0&&t<16,l=n?16:t,a=n?t/16:1,c=n?100/a:100;return{color:e.fontColor,fontSize:`${l}px`,fontFamily:i.standardFontCss(e.fontFamily),textAlign:i.textAlignmentToCss(e.textAlign),flexDirection:"column",justifyContent:e.verticalAlign===i.PdfVerticalAlignment.Top?"flex-start":e.verticalAlign===i.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:e.backgroundColor,opacity:e.opacity,width:n?`${c}%`:"100%",height:n?`${c}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:o.isEditing?"text":"pointer",outline:"none",transform:n?`scale(${a})`:void 0,transformOrigin:"top left"}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:t.annotation.object.rect.size.width*t.scale+"px",height:t.annotation.object.rect.size.height*t.scale+"px",cursor:t.isSelected&&!t.isEditing?"move":"default",pointerEvents:t.isSelected&&!t.isEditing?"none":"auto",zIndex:2}),onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createElementVNode("span",{ref_key:"editorRef",ref:n,onBlur:a,tabindex:"0",style:e.normalizeStyle(s.value),contenteditable:t.isEditing},e.toDisplayString(t.annotation.object.contents),45,h)],36))}}),m=["width","height","viewBox"],y=["d","opacity"],x=e.defineComponent({__name:"ink",props:{isSelected:{type:Boolean},color:{default:"#000000"},opacity:{default:1},strokeWidth:{},inkList:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>o.inkList.map((({points:e})=>{let t="";return e.forEach((({x:e,y:n},l)=>{const r=e-o.rect.origin.x,i=n-o.rect.origin.y;t+=(0===l?"M":"L")+`${r} ${i} `})),t.trim()})))),l=e.computed((()=>o.rect.size.width*o.scale)),r=e.computed((()=>o.rect.size.height*o.scale));return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${l.value}px`,height:`${r.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:l.value,height:r.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,((n,l)=>(e.openBlock(),e.createElementBlock("path",{key:l,d:n,fill:"none",opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",stroke:t.color,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"})},null,44,y)))),128))],12,m))}}),C=["width","height","viewBox"],S=["x1","y1","x2","y2","opacity"],b=["d","transform","stroke","fill"],w=["d","transform","stroke","fill"],B=e.defineComponent({__name:"line",props:{color:{default:"transparent"},opacity:{default:1},strokeWidth:{},strokeColor:{default:"#000000"},strokeStyle:{default:i.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},linePoints:{},lineEndings:{},scale:{},onClick:{},isSelected:{type:Boolean}},setup(t){const n=t,l=e.computed((()=>({x1:n.linePoints.start.x-n.rect.origin.x,y1:n.linePoints.start.y-n.rect.origin.y,x2:n.linePoints.end.x-n.rect.origin.x,y2:n.linePoints.end.y-n.rect.origin.y}))),r=e.computed((()=>{var e,t;const{x1:r,y1:i,x2:a,y2:c}=l.value,s=Math.atan2(c-i,a-r);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,s+Math.PI,r,i),end:o.patching.createEnding(null==(t=n.lineEndings)?void 0:t.end,n.strokeWidth,s,a,c)}})),a=e=>{var t;return{cursor:n.isSelected?"move":"pointer",strokeWidth:n.strokeWidth,strokeLinecap:"butt",pointerEvents:n.isSelected?"none":e.filled?"visible":"visibleStroke",...n.strokeStyle===i.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==(t=n.strokeDashArray)?void 0:t.join(",")}}},c=e.computed((()=>n.rect.size.width*n.scale)),s=e.computed((()=>n.rect.size.height*n.scale));return(t,o)=>{var n;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${c.value}px`,height:`${s.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:c.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("line",{x1:l.value.x1,y1:l.value.y1,x2:l.value.x2,y2:l.value.y2,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===e.unref(i.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(n=t.strokeDashArray)?void 0:n.join(",")}})},null,44,S),r.value.start?(e.openBlock(),e.createElementBlock("path",{key:0,d:r.value.start.d,transform:r.value.start.transform,onPointerdown:o[2]||(o[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[3]||(o[3]=(...e)=>t.onClick&&t.onClick(...e)),stroke:t.strokeColor,style:e.normalizeStyle(a(r.value.start)),fill:r.value.start.filled?t.color:"none"},null,44,b)):e.createCommentVNode("",!0),r.value.end?(e.openBlock(),e.createElementBlock("path",{key:1,d:r.value.end.d,transform:r.value.end.transform,onPointerdown:o[4]||(o[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[5]||(o[5]=(...e)=>t.onClick&&t.onClick(...e)),stroke:t.strokeColor,style:e.normalizeStyle(a(r.value.end)),fill:r.value.end.filled?t.color:"none"},null,44,w)):e.createCommentVNode("",!0)],12,C)}}}),P=["width","height","viewBox"],z=["d","opacity"],A=["d"],E=["x","y","width","height","fill","stroke","stroke-width"],R=e.defineComponent({__name:"polygon",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:i.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},currentVertex:{},handleSize:{default:14}},setup(t){const o=t,n=e.computed((()=>o.currentVertex?[...o.vertices,o.currentVertex]:o.vertices)),l=e.computed((()=>n.value.map((({x:e,y:t})=>({x:e-o.rect.origin.x,y:t-o.rect.origin.y}))))),r=e.computed((()=>{if(!l.value.length)return"";const[e,...t]=l.value,n=!!o.currentVertex;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y}`)).join(" ")+(n?"":" Z")).trim()})),a=e.computed((()=>o.currentVertex&&o.vertices.length>0)),c=e.computed((()=>o.rect.size.width*o.scale)),s=e.computed((()=>o.rect.size.height*o.scale));return(t,o)=>{var n;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${c.value}px`,height:`${s.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:c.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("path",{d:r.value,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),opacity:t.opacity,style:e.normalizeStyle({fill:t.currentVertex?"none":t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===e.unref(i.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(n=t.strokeDashArray)?void 0:n.join(",")}})},null,44,z),a.value&&l.value.length>1?(e.openBlock(),e.createElementBlock("path",{key:0,d:`M ${l.value[l.value.length-1].x} ${l.value[l.value.length-1].y} L ${l.value[0].x} ${l.value[0].y}`,fill:"none",style:e.normalizeStyle({stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeDasharray:"4,4",opacity:.7})},null,12,A)):e.createCommentVNode("",!0),a.value&&l.value.length>=2?(e.openBlock(),e.createElementBlock("rect",{key:1,x:l.value[0].x-t.handleSize/t.scale/2,y:l.value[0].y-t.handleSize/t.scale/2,width:t.handleSize/t.scale,height:t.handleSize/t.scale,fill:t.strokeColor,opacity:.4,stroke:t.strokeColor,"stroke-width":t.strokeWidth/2},null,8,E)):e.createCommentVNode("",!0)],12,P)}}}),_=["width","height","viewBox"],I=["d","opacity"],$=["d","transform","stroke","fill"],j=["d","transform","stroke","fill"],D=e.defineComponent({__name:"polyline",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},scale:{},isSelected:{type:Boolean},onClick:{},lineEndings:{}},setup(t){const n=t,l=e.computed((()=>n.vertices.map((({x:e,y:t})=>({x:e-n.rect.origin.x,y:t-n.rect.origin.y}))))),r=e.computed((()=>{if(0===l.value.length)return"";const[e,...t]=l.value;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y} `)).join("")).trim()})),i=e.computed((()=>{var e,t;if(l.value.length<2)return{start:null,end:null};const r=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),i=r(l.value[0],l.value[1]),a=r(l.value[l.value.length-2],l.value[l.value.length-1]);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,i+Math.PI,l.value[0].x,l.value[0].y),end:o.patching.createEnding(null==(t=n.lineEndings)?void 0:t.end,n.strokeWidth,a,l.value[l.value.length-1].x,l.value[l.value.length-1].y)}})),a=e=>({cursor:n.isSelected?"move":"pointer",strokeWidth:n.strokeWidth,pointerEvents:n.isSelected?"none":e.filled?"visible":"visibleStroke",strokeLinecap:"butt"}),c=e.computed((()=>n.rect.size.width*n.scale)),s=e.computed((()=>n.rect.size.height*n.scale));return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${c.value}px`,height:`${s.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:c.value,height:s.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("path",{d:r.value,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),opacity:t.opacity,style:e.normalizeStyle({fill:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,I),i.value.start?(e.openBlock(),e.createElementBlock("path",{key:0,d:i.value.start.d,transform:i.value.start.transform,stroke:t.strokeColor,fill:i.value.start.filled?t.color:"none",onPointerdown:o[2]||(o[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[3]||(o[3]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.start))},null,44,$)):e.createCommentVNode("",!0),i.value.end?(e.openBlock(),e.createElementBlock("path",{key:1,d:i.value.end.d,transform:i.value.end.transform,stroke:t.strokeColor,fill:i.value.end.filled?t.color:"none",onPointerdown:o[4]||(o[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[5]||(o[5]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.end))},null,44,j)):e.createCommentVNode("",!0)],12,_))}}),L=["width","height","viewBox"],V=["x","y","width","height","fill","opacity"],N=e.defineComponent({__name:"square",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:i.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>{const e=o.rect.size.width,t=o.rect.size.height;return{width:Math.max(e-o.strokeWidth,0),height:Math.max(t-o.strokeWidth,0),x:o.strokeWidth/2,y:o.strokeWidth/2}})),l=e.computed((()=>(n.value.width+o.strokeWidth)*o.scale)),r=e.computed((()=>(n.value.height+o.strokeWidth)*o.scale));return(t,o)=>{var a;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:l.value,height:r.value,pointerEvents:"none",zIndex:2}),width:l.value,height:r.value,viewBox:`0 0 ${n.value.width+t.strokeWidth} ${n.value.height+t.strokeWidth}`},[e.createElementVNode("rect",{x:n.value.x,y:n.value.y,width:n.value.width,height:n.value.height,fill:t.color,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===e.unref(i.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(a=t.strokeDashArray)?void 0:a.join(",")}})},null,44,V)],12,L)}}}),F=["src"],W=e.defineComponent({__name:"render-annotation",props:{pageIndex:{},annotation:{},scaleFactor:{default:1},style:{}},setup(t){const o=t,{provides:l}=c(),r=e.ref(null),a=e.ref(null),s=e.ref(null),d=e.computed((()=>o.annotation.id)),u=e.computed((()=>o.annotation.rect.size.width)),p=e.computed((()=>o.annotation.rect.size.height));e.watch((()=>[o.pageIndex,o.scaleFactor,d.value,u.value,p.value,l.value]),((e,t,c)=>{if(l.value){a.value&&(URL.revokeObjectURL(a.value),a.value=null);const e=l.value.renderAnnotation({pageIndex:o.pageIndex,annotation:n.deepToRaw(o.annotation),options:{scaleFactor:o.scaleFactor,dpr:window.devicePixelRatio}});s.value=e,e.wait((e=>{const t=URL.createObjectURL(e);r.value=t,a.value=t}),i.ignore),c((()=>{a.value?(URL.revokeObjectURL(a.value),a.value=null):e.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task"})}))}}),{immediate:!0}),e.onUnmounted((()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null),s.value&&s.value.abort({code:i.PdfErrorCode.Cancelled,message:"canceled render task on unmount"})}));const v=()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null)};return(t,o)=>r.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:r.value,onLoad:v,style:e.normalizeStyle({width:"100%",height:"100%",display:"block",...t.style})},null,44,F)):e.createCommentVNode("",!0)}}),T=e.defineComponent({__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{type:Function}},setup:t=>(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.isSelected?"none":"auto",cursor:"pointer"}),onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createVNode(W,{pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale},null,8,["pageIndex","annotation","scaleFactor"])],36))}),M=e.defineComponent({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup:t=>(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((n,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?n.origin.x-t.rect.origin.x:n.origin.x)*t.scale+"px",top:(t.rect?n.origin.y-t.rect.origin.y:n.origin.y)*t.scale+"px",width:n.size.width*t.scale+"px",height:n.size.height*t.scale+"px",background:t.color,opacity:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0})},null,36)))),128))}),O=e.defineComponent({__name:"squiggly",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale)),l=e.computed((()=>6*o.scale)),r=e.computed((()=>{const e=n.value,t=l.value,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${2*e}" viewBox="0 0 ${t} ${2*e}">\n <path d="M0 ${e} Q ${t/4} 0 ${t/2} ${e} T ${t} ${e}"\n fill="none" stroke="${o.color}" stroke-width="${e}" stroke-linecap="round"/>\n </svg>`;return`url("data:image/svg+xml;utf8,${encodeURIComponent(r)}")`}));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((i,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale+"px",top:(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale+"px",width:i.size.width*t.scale+"px",height:i.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,bottom:0,width:"100%",height:2*n.value+"px",backgroundImage:r.value,backgroundRepeat:"repeat-x",backgroundSize:`${l.value}px ${2*n.value}px`,opacity:t.opacity,pointerEvents:"none"})},null,4)],36)))),128))}}),U=e.defineComponent({__name:"strikeout",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((l,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale+"px",top:(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale+"px",width:l.size.width*t.scale+"px",height:l.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,top:"50%",width:"100%",height:`${n.value}px`,background:t.color,opacity:t.opacity,transform:"translateY(-50%)",pointerEvents:"none"})},null,4)],36)))),128))}}),H=e.defineComponent({__name:"underline",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((l,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale+"px",top:(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale+"px",width:l.size.width*t.scale+"px",height:l.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,bottom:0,width:"100%",height:`${n.value}px`,background:t.color,opacity:t.opacity,pointerEvents:"none"})},null,4)],36)))),128))}}),q=e.defineComponent({__name:"annotations",props:{pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{}},setup(t){const n=t,{provides:i}=c(),{provides:a}=r.useSelectionCapability(),s=e.ref([]),{register:d}=l.usePointerHandlers({pageIndex:n.pageIndex}),u=e.ref(null),v=e.ref(null);e.watchEffect((e=>{if(i.value){e(i.value.onStateChange((e=>{s.value=o.getAnnotationsByPageIndex(e,n.pageIndex),u.value=o.getSelectedAnnotationByPageIndex(e,n.pageIndex)})))}}));const k=(e,t)=>{t.target===t.currentTarget&&i.value&&(i.value.deselectAnnotation(),v.value=null)},h=(e,t)=>{e.stopPropagation(),i.value&&a.value&&(i.value.selectAnnotation(n.pageIndex,t.object.id),a.value.clear(),t.object.id!==v.value&&(v.value=null))};e.watchEffect((e=>{if(i.value){const t=d({onPointerDown:k});t&&e(t)}}));const m=e=>{var t;return null==(t=i.value)?void 0:t.findToolForAnnotation(e.object)},y=e=>{var t;return(!o.isFreeText(e)||v.value!==e.object.id)&&((null==(t=m(e))?void 0:t.interaction.isDraggable)??!1)},C=e=>{var t;return(null==(t=m(e))?void 0:t.interaction.isResizable)??!1},S=e=>{var t;return(null==(t=m(e))?void 0:t.interaction.lockAspectRatio)??!1},b=e=>o.isLine(e)?{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})}:o.isPolyline(e)||o.isPolygon(e)?{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})}:void 0;return(t,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,(l=>{var r,i,a,c,d,k,m,w,P,z,A,E;return e.openBlock(),e.createElementBlock(e.Fragment,{key:l.object.id},[e.unref(o.isInk)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:0,trackedAnnotation:l,isSelected:(null==(r=u.value)?void 0:r.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(x,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isSquare)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:1,trackedAnnotation:l,isSelected:(null==(i=u.value)?void 0:i.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(N,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isCircle)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:2,trackedAnnotation:l,isSelected:(null==(a=u.value)?void 0:a.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(g,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isLine)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,trackedAnnotation:l,isSelected:(null==(c=u.value)?void 0:c.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(B,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isPolyline)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:4,trackedAnnotation:l,isSelected:(null==(d=u.value)?void 0:d.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(D,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isPolygon)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:5,trackedAnnotation:l,isSelected:(null==(k=u.value)?void 0:k.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(R,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,scale:t.scale,onClick:e=>h(e,l)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isFreeText)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:6,trackedAnnotation:l,isSelected:(null==(m=u.value)?void 0:m.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),onDoubleClick:e=>{return t=l.object.id,void(o.isFreeText(s.value.find((e=>e.object.id===t)))&&(v.value=t));var t},vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(f,{isSelected:(null==(n=u.value)?void 0:n.object.id)===l.object.id,isEditing:v.value===l.object.id,annotation:{...l,object:o},pageIndex:t.pageIndex,scale:t.scale,onClick:e=>h(e,l)},null,8,["isSelected","isEditing","annotation","pageIndex","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","onDoubleClick","vertexConfig"])):e.unref(o.isStamp)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:7,trackedAnnotation:l,isSelected:(null==(w=u.value)?void 0:w.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l)},{ref_for:!0},n),{default:e.withCtx((()=>{var o;return[e.createVNode(T,{isSelected:(null==(o=u.value)?void 0:o.object.id)===l.object.id,annotation:l,pageIndex:t.pageIndex,scale:t.scale,onClick:e=>h(e,l)},null,8,["isSelected","annotation","pageIndex","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isUnderline)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:8,trackedAnnotation:l,isSelected:(null==(P=u.value)?void 0:P.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l),zIndex:0},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(H,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>h(e,l)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isStrikeout)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:9,trackedAnnotation:l,isSelected:(null==(z=u.value)?void 0:z.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l),zIndex:0},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(U,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>h(e,l)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isSquiggly)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:10,trackedAnnotation:l,isSelected:(null==(A=u.value)?void 0:A.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l),zIndex:0},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(O,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>h(e,l)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.unref(o.isHighlight)(l)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:11,trackedAnnotation:l,isSelected:(null==(E=u.value)?void 0:E.object.id)===l.object.id,isDraggable:y(l),isResizable:C(l),lockAspectRatio:S(l),onSelect:e=>h(e,l),vertexConfig:b(l),zIndex:0},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(M,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>h(e,l)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig"])):e.createCommentVNode("",!0)],64)})),128))}}),G=e.defineComponent({__name:"text-markup",props:{pageIndex:{},scale:{}},setup(t){const o=t,{provides:n}=r.useSelectionCapability(),{provides:l}=c(),a=e.ref([]),s=e.ref(null),d=e.ref(null);e.watchEffect((e=>{const t=[];if(n.value){const e=n.value,l=e.onSelectionChange((()=>{a.value=e.getHighlightRectsForPage(o.pageIndex),s.value=e.getBoundingRectForPage(o.pageIndex)}));t.push(l)}if(l.value){const e=l.value.onActiveToolChange((e=>d.value=e));t.push(e)}e((()=>{t.forEach((e=>e()))}))}));const u=e.computed((()=>{if(!d.value)return i.blendModeToCss(i.PdfBlendMode.Normal);const e=d.value.defaults.type===i.PdfAnnotationSubtype.HIGHLIGHT?i.PdfBlendMode.Multiply:i.PdfBlendMode.Normal;return i.blendModeToCss(d.value.defaults.blendMode??e)}));return(t,o)=>s.value&&d.value?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({mixBlendMode:u.value,pointerEvents:"none",position:"absolute",inset:0})},[d.value.defaults.type===e.unref(i.PdfAnnotationSubtype).HIGHLIGHT?(e.openBlock(),e.createBlock(M,{key:0,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(i.PdfAnnotationSubtype).UNDERLINE?(e.openBlock(),e.createBlock(H,{key:1,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(i.PdfAnnotationSubtype).STRIKEOUT?(e.openBlock(),e.createBlock(U,{key:2,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(i.PdfAnnotationSubtype).SQUIGGLY?(e.openBlock(),e.createBlock(O,{key:3,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0)}}),Y=e.defineComponent({__name:"preview-renderer",props:{preview:{},scale:{}},setup(t){const o=t,n=e.computed((()=>({position:"absolute",left:o.preview.bounds.origin.x*o.scale+"px",top:o.preview.bounds.origin.y*o.scale+"px",width:o.preview.bounds.size.width*o.scale+"px",height:o.preview.bounds.size.height*o.scale+"px",pointerEvents:"none",zIndex:10})));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(n.value)},[t.preview.type===e.unref(i.PdfAnnotationSubtype).CIRCLE?(e.openBlock(),e.createBlock(e.unref(g),e.mergeProps({key:0,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).SQUARE?(e.openBlock(),e.createBlock(e.unref(N),e.mergeProps({key:1,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).POLYGON?(e.openBlock(),e.createBlock(e.unref(R),e.mergeProps({key:2,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).POLYLINE?(e.openBlock(),e.createBlock(e.unref(D),e.mergeProps({key:3,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).LINE?(e.openBlock(),e.createBlock(e.unref(B),e.mergeProps({key:4,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).INK?(e.openBlock(),e.createBlock(e.unref(x),e.mergeProps({key:5,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(i.PdfAnnotationSubtype).FREETEXT?(e.openBlock(),e.createElementBlock("div",{key:6,style:e.normalizeStyle({width:"100%",height:"100%",border:`1px dashed ${t.preview.data.fontColor||"#000000"}`,backgroundColor:"transparent"})},null,4)):e.createCommentVNode("",!0)],4))}}),Q=e.defineComponent({__name:"annotation-paint-layer",props:{pageIndex:{},scale:{}},setup(t){const o=t,{plugin:n}=a(),l=e.ref(new Map),r=e.ref(null),i=e.ref(null),c=e.computed((()=>({requestFile:({accept:e,onFile:t})=>{const o=r.value;o&&(o.accept=e,o.onchange=e=>{var n;const l=null==(n=e.target.files)?void 0:n[0];l&&(t(l),o.value="")},o.click())},processImage:({source:e,maxWidth:t,maxHeight:o,onComplete:n})=>{const l=i.value;if(!l||!l.getContext)return;const r=l.getContext("2d");if(!r)return;const a=new Image;a.crossOrigin="Anonymous",a.onload=()=>{let{naturalWidth:i,naturalHeight:c}=a;const s=t?t/i:1,d=o?o/c:1,u=Math.min(s,d,1),p=i*u,v=c*u;l.width=p,l.height=v,r.drawImage(a,0,0,p,v);const k=r.getImageData(0,0,p,v);"string"!=typeof e&&URL.revokeObjectURL(a.src),n({imageData:k,width:p,height:v})},a.src="string"==typeof e?e:URL.createObjectURL(e)}})));let s;return e.watchEffect((e=>{n.value&&(s=n.value.registerPageHandlers(o.pageIndex,o.scale,{services:c.value,onPreview:(e,t)=>{const o=new Map(l.value);t?o.set(e,t):o.delete(e),l.value=o}})),e((()=>{null==s||s()}))})),(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",style:{display:"none"}},null,512),e.createElementVNode("canvas",{ref_key:"canvasRef",ref:i,style:{display:"none"}},null,512),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.entries(),(([o,n])=>(e.openBlock(),e.createBlock(Y,{key:o,preview:n,scale:t.scale},null,8,["preview","scale"])))),128))],64))}}),K=e.defineComponent({__name:"annotation-layer",props:{pageIndex:{},scale:{},pageWidth:{},pageHeight:{},rotation:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{}},setup(t){const o=t;return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(q,e.normalizeProps(e.guardReactiveProps(o)),{"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.normalizeProps(e.guardReactiveProps(o)))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.normalizeProps(e.guardReactiveProps(o)))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.normalizeProps(e.guardReactiveProps(o)))])),_:3},16),e.createVNode(G,{pageIndex:t.pageIndex,scale:t.scale},null,8,["pageIndex","scale"]),e.createVNode(Q,{pageIndex:t.pageIndex,scale:t.scale},null,8,["pageIndex","scale"])]))}});exports.AnnotationContainer=p,exports.AnnotationLayer=K,exports.AnnotationPaintLayer=Q,exports.Annotations=q,exports.Circle=g,exports.FreeText=f,exports.Highlight=M,exports.Ink=x,exports.Line=B,exports.Polygon=R,exports.Polyline=D,exports.PreviewRenderer=Y,exports.RenderAnnotation=W,exports.Square=N,exports.Squiggly=O,exports.Stamp=T,exports.Strikeout=U,exports.TextMarkup=G,exports.Underline=H,exports.useAnnotation=()=>{const{provides:t}=c(),n=e.ref(o.initialState({enabled:!0}));return e.watchEffect((e=>{if(t.value){e(t.value.onStateChange((e=>{n.value=e})))}})),{state:e.readonly(n),provides:t}},exports.useAnnotationCapability=c,exports.useAnnotationPlugin=a,Object.keys(o).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})}));
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),t=require("@embedpdf/core/vue"),o=require("@embedpdf/plugin-annotation"),n=require("@embedpdf/utils/vue"),l=require("@embedpdf/models"),r=require("@embedpdf/plugin-interaction-manager/vue"),i=require("@embedpdf/plugin-selection/vue"),a=()=>t.usePlugin(o.AnnotationPlugin.id),s=()=>t.useCapability(o.AnnotationPlugin.id),c={"data-no-interaction":""},d="#007ACC",u="#007ACC",p=e.defineComponent({__name:"annotation-container",props:{scale:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isDraggable:{type:Boolean},isResizable:{type:Boolean},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},outlineOffset:{default:1},onDoubleClick:{},onSelect:{},zIndex:{default:1},selectionOutlineColor:{default:"#007ACC"}},setup(t){const o=t,l=e.shallowRef(e.toRaw(o.trackedAnnotation.object)),{provides:r}=s(),i=e.ref(null),a=e.computed((()=>({...e.toRaw(o.trackedAnnotation.object),...e.toRaw(l.value)}))),p=e.computed((()=>e.toRaw(a.value).rect)),v=e.computed((()=>{var t;const n=e.toRaw(a.value);return(null==(t=o.vertexConfig)?void 0:t.extractVertices(n))??[]})),k=e.computed((()=>({minWidth:10,minHeight:10,boundingBox:{width:o.pageWidth/o.scale,height:o.pageHeight/o.scale}}))),{dragProps:g,vertices:f,resize:h}=n.useInteractionHandles({controller:{element:p,vertices:v,constraints:k,maintainAspectRatio:e.computed((()=>o.lockAspectRatio)),pageRotation:e.computed((()=>o.rotation)),scale:e.computed((()=>o.scale)),enabled:e.computed((()=>o.isSelected)),onUpdate:t=>{var n,s,c,d;if(!(null==(n=t.transformData)?void 0:n.type))return;"start"===t.state&&(i.value=a.value);const u=i.value??a.value,p=t.transformData.changes.vertices?null==(s=o.vertexConfig)?void 0:s.transformAnnotation(e.toRaw(u),t.transformData.changes.vertices):{rect:t.transformData.changes.rect},v=null==(c=r.value)?void 0:c.transformAnnotation(u,{type:t.transformData.type,changes:p,metadata:t.transformData.metadata});v&&(l.value={...e.toRaw(l.value),...v}),"end"===t.state&&v&&(i.value=null,null==(d=r.value)||d.updateAnnotation(o.pageIndex,o.trackedAnnotation.object.id,v))}},resizeUI:{handleSize:12,spacing:o.outlineOffset,offsetMode:"outside",includeSides:!o.lockAspectRatio,zIndex:o.zIndex+1},vertexUI:{vertexSize:12,zIndex:o.zIndex+2},includeVertices:!!o.vertexConfig}),m=n.useDoublePressProps(o.onDoubleClick);e.watch((()=>o.trackedAnnotation.object),(e=>{l.value=e}),{deep:!0});const y=e.computed((()=>({position:"absolute",left:a.value.rect.origin.x*o.scale+"px",top:a.value.rect.origin.y*o.scale+"px",width:a.value.rect.size.width*o.scale+"px",height:a.value.rect.size.height*o.scale+"px",outline:o.isSelected?`1px solid ${o.selectionOutlineColor}`:"none",outlineOffset:o.isSelected?`${o.outlineOffset}px`:"0px",pointerEvents:o.isSelected?"auto":"none",touchAction:"none",cursor:o.isSelected&&o.isDraggable?"move":"default",zIndex:o.zIndex}))),x=e.useSlots();return(t,o)=>(e.openBlock(),e.createElementBlock("div",c,[e.createElementVNode("div",e.mergeProps({...e.unref(g),...e.unref(m)},{style:y.value}),[e.renderSlot(t.$slots,"default",{annotation:a.value}),t.isSelected&&t.isResizable?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(h),(({key:o,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o},[e.unref(x)["resize-handle"]?e.renderSlot(t.$slots,"resize-handle",e.mergeProps({key:0,ref_for:!0},{key:o,style:n,...l,backgroundColor:d}),(()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},l,{style:[n,{backgroundColor:d}]}),null,16)])):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},l,{style:[n,{backgroundColor:d}]}),null,16))],64)))),128)):e.createCommentVNode("",!0),t.isSelected&&e.unref(f).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(e.unref(f),(({key:o,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:o},[e.unref(x)["vertex-handle"]?e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({key:0,ref_for:!0},{key:o,style:n,...l,backgroundColor:u}),(()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},l,{style:[n,{backgroundColor:u}]}),null,16)])):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},l,{style:[n,{backgroundColor:u}]}),null,16))],64)))),128)):e.createCommentVNode("",!0)],16),e.createVNode(e.unref(n.CounterRotate),{rect:{origin:{x:a.value.rect.origin.x*t.scale,y:a.value.rect.origin.y*t.scale},size:{width:a.value.rect.size.width*t.scale,height:a.value.rect.size.height*t.scale}},rotation:t.rotation},{default:e.withCtx((({rect:o,menuWrapperProps:n})=>[e.renderSlot(t.$slots,"selection-menu",{annotation:t.trackedAnnotation,selected:t.isSelected,rect:o,menuWrapperProps:n})])),_:3},8,["rect","rotation"])]))}}),v=["width","height","viewBox"],k=["cx","cy","rx","ry","fill","opacity"],g=e.defineComponent({__name:"circle",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:l.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>{const e=o.rect.size.width,t=o.rect.size.height,n=Math.max(e-o.strokeWidth,0),l=Math.max(t-o.strokeWidth,0);return{width:e,height:t,cx:o.strokeWidth/2+n/2,cy:o.strokeWidth/2+l/2,rx:n/2,ry:l/2}})),r=e.computed((()=>n.value.width*o.scale)),i=e.computed((()=>n.value.height*o.scale));return(t,o)=>{var a;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:r.value,height:i.value,pointerEvents:"none",zIndex:2}),width:r.value,height:i.value,viewBox:`0 0 ${n.value.width} ${n.value.height}`},[e.createElementVNode("ellipse",{cx:n.value.cx,cy:n.value.cy,rx:n.value.rx,ry:n.value.ry,fill:t.color,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===e.unref(l.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(a=t.strokeDashArray)?void 0:a.join(",")}})},null,44,k)],12,v)}}}),f=["contenteditable"],h=e.defineComponent({__name:"free-text",props:{isSelected:{type:Boolean},isEditing:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{type:Function}},setup(t){const o=t,n=e.ref(null),{provides:r}=s(),i=e.ref(!1);e.onMounted((()=>{try{const e=navigator;i.value=/iPad|iPhone|iPod/.test(navigator.userAgent)||"MacIntel"===navigator.platform&&(null==e?void 0:e.maxTouchPoints)>1}catch{i.value=!1}})),e.watch((()=>o.isEditing),(e=>{if(e&&n.value){const e=n.value;e.focus();const t=window.getSelection();if(t){const o=document.createRange();o.selectNodeContents(e),o.collapse(!1),t.removeAllRanges(),t.addRange(o)}}}));const a=()=>{r.value&&n.value&&r.value.updateAnnotation(o.pageIndex,o.annotation.object.id,{contents:n.value.innerText})},c=e.computed((()=>{const{object:e}=o.annotation,t=e.fontSize*o.scale,n=i.value&&o.isEditing&&t>0&&t<16,r=n?16:t,a=n?t/16:1,s=n?100/a:100;return{color:e.fontColor,fontSize:`${r}px`,fontFamily:l.standardFontCss(e.fontFamily),textAlign:l.textAlignmentToCss(e.textAlign),flexDirection:"column",justifyContent:e.verticalAlign===l.PdfVerticalAlignment.Top?"flex-start":e.verticalAlign===l.PdfVerticalAlignment.Middle?"center":"flex-end",display:"flex",backgroundColor:e.backgroundColor,opacity:e.opacity,width:n?`${s}%`:"100%",height:n?`${s}%`:"100%",lineHeight:"1.18",overflow:"hidden",cursor:o.isEditing?"text":"pointer",outline:"none",transform:n?`scale(${a})`:void 0,transformOrigin:"top left"}}));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:t.annotation.object.rect.size.width*t.scale+"px",height:t.annotation.object.rect.size.height*t.scale+"px",cursor:t.isSelected&&!t.isEditing?"move":"default",pointerEvents:t.isSelected&&!t.isEditing?"none":"auto",zIndex:2}),onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createElementVNode("span",{ref_key:"editorRef",ref:n,onBlur:a,tabindex:"0",style:e.normalizeStyle(c.value),contenteditable:t.isEditing},e.toDisplayString(t.annotation.object.contents),45,f)],36))}}),m=["width","height","viewBox"],y=["d","opacity"],x=e.defineComponent({__name:"ink",props:{isSelected:{type:Boolean},color:{default:"#000000"},opacity:{default:1},strokeWidth:{},inkList:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>o.inkList.map((({points:e})=>{let t="";return e.forEach((({x:e,y:n},l)=>{const r=e-o.rect.origin.x,i=n-o.rect.origin.y;t+=(0===l?"M":"L")+`${r} ${i} `})),t.trim()})))),l=e.computed((()=>o.rect.size.width*o.scale)),r=e.computed((()=>o.rect.size.height*o.scale));return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${l.value}px`,height:`${r.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:l.value,height:r.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.value,((n,l)=>(e.openBlock(),e.createElementBlock("path",{key:l,d:n,fill:"none",opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",stroke:t.color,strokeWidth:t.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round"})},null,44,y)))),128))],12,m))}}),C=["width","height","viewBox"],b=["x1","y1","x2","y2","opacity"],S=["d","transform","stroke","fill"],w=["d","transform","stroke","fill"],B=e.defineComponent({__name:"line",props:{color:{default:"transparent"},opacity:{default:1},strokeWidth:{},strokeColor:{default:"#000000"},strokeStyle:{default:l.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},linePoints:{},lineEndings:{},scale:{},onClick:{},isSelected:{type:Boolean}},setup(t){const n=t,r=e.computed((()=>({x1:n.linePoints.start.x-n.rect.origin.x,y1:n.linePoints.start.y-n.rect.origin.y,x2:n.linePoints.end.x-n.rect.origin.x,y2:n.linePoints.end.y-n.rect.origin.y}))),i=e.computed((()=>{var e,t;const{x1:l,y1:i,x2:a,y2:s}=r.value,c=Math.atan2(s-i,a-l);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,c+Math.PI,l,i),end:o.patching.createEnding(null==(t=n.lineEndings)?void 0:t.end,n.strokeWidth,c,a,s)}})),a=e=>{var t;return{cursor:n.isSelected?"move":"pointer",strokeWidth:n.strokeWidth,strokeLinecap:"butt",pointerEvents:n.isSelected?"none":e.filled?"visible":"visibleStroke",...n.strokeStyle===l.PdfAnnotationBorderStyle.DASHED&&{strokeDasharray:null==(t=n.strokeDashArray)?void 0:t.join(",")}}},s=e.computed((()=>n.rect.size.width*n.scale)),c=e.computed((()=>n.rect.size.height*n.scale));return(t,o)=>{var n;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${s.value}px`,height:`${c.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:s.value,height:c.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("line",{x1:r.value.x1,y1:r.value.y1,x2:r.value.x2,y2:r.value.y2,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeLinecap:"butt",...t.strokeStyle===e.unref(l.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(n=t.strokeDashArray)?void 0:n.join(",")}})},null,44,b),i.value.start?(e.openBlock(),e.createElementBlock("path",{key:0,d:i.value.start.d,transform:i.value.start.transform,onPointerdown:o[2]||(o[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[3]||(o[3]=(...e)=>t.onClick&&t.onClick(...e)),stroke:t.strokeColor,style:e.normalizeStyle(a(i.value.start)),fill:i.value.start.filled?t.color:"none"},null,44,S)):e.createCommentVNode("",!0),i.value.end?(e.openBlock(),e.createElementBlock("path",{key:1,d:i.value.end.d,transform:i.value.end.transform,onPointerdown:o[4]||(o[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[5]||(o[5]=(...e)=>t.onClick&&t.onClick(...e)),stroke:t.strokeColor,style:e.normalizeStyle(a(i.value.end)),fill:i.value.end.filled?t.color:"none"},null,44,w)):e.createCommentVNode("",!0)],12,C)}}}),P=["width","height","viewBox"],z=["d","opacity"],A=["d"],E=["x","y","width","height","fill","stroke","stroke-width"],R=e.defineComponent({__name:"polygon",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},strokeStyle:{default:l.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},scale:{},isSelected:{type:Boolean},onClick:{},currentVertex:{},handleSize:{default:14}},setup(t){const o=t,n=e.computed((()=>o.currentVertex?[...o.vertices,o.currentVertex]:o.vertices)),r=e.computed((()=>n.value.map((({x:e,y:t})=>({x:e-o.rect.origin.x,y:t-o.rect.origin.y}))))),i=e.computed((()=>{if(!r.value.length)return"";const[e,...t]=r.value,n=!!o.currentVertex;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y}`)).join(" ")+(n?"":" Z")).trim()})),a=e.computed((()=>o.currentVertex&&o.vertices.length>0)),s=e.computed((()=>o.rect.size.width*o.scale)),c=e.computed((()=>o.rect.size.height*o.scale));return(t,o)=>{var n;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${s.value}px`,height:`${c.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:s.value,height:c.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("path",{d:i.value,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),opacity:t.opacity,style:e.normalizeStyle({fill:t.currentVertex?"none":t.color,stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",strokeLinecap:"butt",strokeLinejoin:"miter",...t.strokeStyle===e.unref(l.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(n=t.strokeDashArray)?void 0:n.join(",")}})},null,44,z),a.value&&r.value.length>1?(e.openBlock(),e.createElementBlock("path",{key:0,d:`M ${r.value[r.value.length-1].x} ${r.value[r.value.length-1].y} L ${r.value[0].x} ${r.value[0].y}`,fill:"none",style:e.normalizeStyle({stroke:t.strokeColor,strokeWidth:t.strokeWidth,strokeDasharray:"4,4",opacity:.7})},null,12,A)):e.createCommentVNode("",!0),a.value&&r.value.length>=2?(e.openBlock(),e.createElementBlock("rect",{key:1,x:r.value[0].x-t.handleSize/t.scale/2,y:r.value[0].y-t.handleSize/t.scale/2,width:t.handleSize/t.scale,height:t.handleSize/t.scale,fill:t.strokeColor,opacity:.4,stroke:t.strokeColor,"stroke-width":t.strokeWidth/2},null,8,E)):e.createCommentVNode("",!0)],12,P)}}}),_=["width","height","viewBox"],I=["d","opacity"],j=["d","transform","stroke","fill"],$=["d","transform","stroke","fill"],M=e.defineComponent({__name:"polyline",props:{rect:{},vertices:{},color:{default:"transparent"},strokeColor:{default:"#000000"},opacity:{default:1},strokeWidth:{},scale:{},isSelected:{type:Boolean},onClick:{},lineEndings:{}},setup(t){const n=t,l=e.computed((()=>n.vertices.map((({x:e,y:t})=>({x:e-n.rect.origin.x,y:t-n.rect.origin.y}))))),r=e.computed((()=>{if(0===l.value.length)return"";const[e,...t]=l.value;return(`M ${e.x} ${e.y} `+t.map((e=>`L ${e.x} ${e.y} `)).join("")).trim()})),i=e.computed((()=>{var e,t;if(l.value.length<2)return{start:null,end:null};const r=(e,t)=>Math.atan2(t.y-e.y,t.x-e.x),i=r(l.value[0],l.value[1]),a=r(l.value[l.value.length-2],l.value[l.value.length-1]);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,i+Math.PI,l.value[0].x,l.value[0].y),end:o.patching.createEnding(null==(t=n.lineEndings)?void 0:t.end,n.strokeWidth,a,l.value[l.value.length-1].x,l.value[l.value.length-1].y)}})),a=e=>({cursor:n.isSelected?"move":"pointer",strokeWidth:n.strokeWidth,pointerEvents:n.isSelected?"none":e.filled?"visible":"visibleStroke",strokeLinecap:"butt"}),s=e.computed((()=>n.rect.size.width*n.scale)),c=e.computed((()=>n.rect.size.height*n.scale));return(t,o)=>(e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:`${s.value}px`,height:`${c.value}px`,pointerEvents:"none",zIndex:2,overflow:"visible"}),width:s.value,height:c.value,viewBox:`0 0 ${t.rect.size.width} ${t.rect.size.height}`},[e.createElementVNode("path",{d:r.value,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),opacity:t.opacity,style:e.normalizeStyle({fill:"none",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"visibleStroke",strokeLinecap:"butt",strokeLinejoin:"miter"})},null,44,I),i.value.start?(e.openBlock(),e.createElementBlock("path",{key:0,d:i.value.start.d,transform:i.value.start.transform,stroke:t.strokeColor,fill:i.value.start.filled?t.color:"none",onPointerdown:o[2]||(o[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[3]||(o[3]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.start))},null,44,j)):e.createCommentVNode("",!0),i.value.end?(e.openBlock(),e.createElementBlock("path",{key:1,d:i.value.end.d,transform:i.value.end.transform,stroke:t.strokeColor,fill:i.value.end.filled?t.color:"none",onPointerdown:o[4]||(o[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[5]||(o[5]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.end))},null,44,$)):e.createCommentVNode("",!0)],12,_))}}),D=["width","height","viewBox"],N=["x","y","width","height","fill","opacity"],L=e.defineComponent({__name:"square",props:{isSelected:{type:Boolean},color:{default:"#000000"},strokeColor:{},opacity:{default:1},strokeWidth:{},strokeStyle:{default:l.PdfAnnotationBorderStyle.SOLID},strokeDashArray:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>{const e=o.rect.size.width,t=o.rect.size.height;return{width:Math.max(e-o.strokeWidth,0),height:Math.max(t-o.strokeWidth,0),x:o.strokeWidth/2,y:o.strokeWidth/2}})),r=e.computed((()=>(n.value.width+o.strokeWidth)*o.scale)),i=e.computed((()=>(n.value.height+o.strokeWidth)*o.scale));return(t,o)=>{var a;return e.openBlock(),e.createElementBlock("svg",{style:e.normalizeStyle({position:"absolute",width:r.value,height:i.value,pointerEvents:"none",zIndex:2}),width:r.value,height:i.value,viewBox:`0 0 ${n.value.width+t.strokeWidth} ${n.value.height+t.strokeWidth}`},[e.createElementVNode("rect",{x:n.value.x,y:n.value.y,width:n.value.width,height:n.value.height,fill:t.color,opacity:t.opacity,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({cursor:t.isSelected?"move":"pointer",pointerEvents:t.isSelected?"none":"transparent"===t.color?"visibleStroke":"visible",stroke:t.strokeColor??t.color,strokeWidth:t.strokeWidth,...t.strokeStyle===e.unref(l.PdfAnnotationBorderStyle).DASHED&&{strokeDasharray:null==(a=t.strokeDashArray)?void 0:a.join(",")}})},null,44,N)],12,D)}}}),V=["src"],T=e.defineComponent({__name:"render-annotation",props:{pageIndex:{},annotation:{},scaleFactor:{default:1},style:{}},setup(t){const o=t,{provides:r}=s(),i=e.ref(null),a=e.ref(null),c=e.ref(null),d=e.computed((()=>o.annotation.id)),u=e.computed((()=>o.annotation.rect.size.width)),p=e.computed((()=>o.annotation.rect.size.height));e.watch((()=>[o.pageIndex,o.scaleFactor,d.value,u.value,p.value,r.value]),((e,t,s)=>{if(r.value){a.value&&(URL.revokeObjectURL(a.value),a.value=null);const e=r.value.renderAnnotation({pageIndex:o.pageIndex,annotation:n.deepToRaw(o.annotation),options:{scaleFactor:o.scaleFactor,dpr:window.devicePixelRatio}});c.value=e,e.wait((e=>{const t=URL.createObjectURL(e);i.value=t,a.value=t}),l.ignore),s((()=>{a.value?(URL.revokeObjectURL(a.value),a.value=null):e.abort({code:l.PdfErrorCode.Cancelled,message:"canceled render task"})}))}}),{immediate:!0}),e.onUnmounted((()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null),c.value&&c.value.abort({code:l.PdfErrorCode.Cancelled,message:"canceled render task on unmount"})}));const v=()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null)};return(t,o)=>i.value?(e.openBlock(),e.createElementBlock("img",{key:0,src:i.value,onLoad:v,style:e.normalizeStyle({width:"100%",height:"100%",display:"block",...t.style})},null,44,V)):e.createCommentVNode("",!0)}}),F=e.defineComponent({__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},pageIndex:{},scale:{},onClick:{type:Function}},setup:t=>(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.isSelected?"none":"auto",cursor:"pointer"}),onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createVNode(T,{pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale},null,8,["pageIndex","annotation","scaleFactor"])],36))}),W=e.defineComponent({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup:t=>(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((n,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?n.origin.x-t.rect.origin.x:n.origin.x)*t.scale+"px",top:(t.rect?n.origin.y-t.rect.origin.y:n.origin.y)*t.scale+"px",width:n.size.width*t.scale+"px",height:n.size.height*t.scale+"px",background:t.color,opacity:t.opacity,pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:void 0})},null,36)))),128))}),O=e.defineComponent({__name:"squiggly",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale)),l=e.computed((()=>6*o.scale)),r=e.computed((()=>{const e=n.value,t=l.value,r=`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${2*e}" viewBox="0 0 ${t} ${2*e}">\n <path d="M0 ${e} Q ${t/4} 0 ${t/2} ${e} T ${t} ${e}"\n fill="none" stroke="${o.color}" stroke-width="${e}" stroke-linecap="round"/>\n </svg>`;return`url("data:image/svg+xml;utf8,${encodeURIComponent(r)}")`}));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((i,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?i.origin.x-t.rect.origin.x:i.origin.x)*t.scale+"px",top:(t.rect?i.origin.y-t.rect.origin.y:i.origin.y)*t.scale+"px",width:i.size.width*t.scale+"px",height:i.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,bottom:0,width:"100%",height:2*n.value+"px",backgroundImage:r.value,backgroundRepeat:"repeat-x",backgroundSize:`${l.value}px ${2*n.value}px`,opacity:t.opacity,pointerEvents:"none"})},null,4)],36)))),128))}}),U=e.defineComponent({__name:"strikeout",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((l,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale+"px",top:(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale+"px",width:l.size.width*t.scale+"px",height:l.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,top:"50%",width:"100%",height:`${n.value}px`,background:t.color,opacity:t.opacity,transform:"translateY(-50%)",pointerEvents:"none"})},null,4)],36)))),128))}}),H=e.defineComponent({__name:"underline",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup(t){const o=t,n=e.computed((()=>2*o.scale));return(t,o)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,((l,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:o[0]||(o[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:o[1]||(o[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?l.origin.x-t.rect.origin.x:l.origin.x)*t.scale+"px",top:(t.rect?l.origin.y-t.rect.origin.y:l.origin.y)*t.scale+"px",width:l.size.width*t.scale+"px",height:l.size.height*t.scale+"px",background:"transparent",pointerEvents:t.onClick?"auto":"none",cursor:t.onClick?"pointer":"default",zIndex:t.onClick?1:0})},[e.createElementVNode("div",{style:e.normalizeStyle({position:"absolute",left:0,bottom:0,width:"100%",height:`${n.value}px`,background:t.color,opacity:t.opacity,pointerEvents:"none"})},null,4)],36)))),128))}}),q=e.defineComponent({__name:"annotations",props:{pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{}},setup(t){const n=t,{provides:a}=s(),{provides:c}=i.useSelectionCapability(),d=e.ref([]),{register:u}=r.usePointerHandlers({pageIndex:n.pageIndex}),v=e.ref(null),k=e.ref(null);e.watchEffect((e=>{if(a.value){e(a.value.onStateChange((e=>{d.value=o.getAnnotationsByPageIndex(e,n.pageIndex),v.value=o.getSelectedAnnotationByPageIndex(e,n.pageIndex)})))}}));const f=(e,t)=>{t.target===t.currentTarget&&a.value&&(a.value.deselectAnnotation(),k.value=null)},m=(e,t)=>{e.stopPropagation(),a.value&&c.value&&(a.value.selectAnnotation(n.pageIndex,t.object.id),c.value.clear(),t.object.id!==k.value&&(k.value=null))};e.watchEffect((e=>{if(a.value){const t=u({onPointerDown:f});t&&e(t)}}));const y=e=>{var t;return null==(t=a.value)?void 0:t.findToolForAnnotation(e.object)},C=e=>{var t;return(!o.isFreeText(e)||k.value!==e.object.id)&&((null==(t=y(e))?void 0:t.interaction.isDraggable)??!1)},b=e=>{var t;return(null==(t=y(e))?void 0:t.interaction.isResizable)??!1},S=e=>{var t;return(null==(t=y(e))?void 0:t.interaction.lockAspectRatio)??!1},w=e=>o.isLine(e)?{extractVertices:e=>[e.linePoints.start,e.linePoints.end],transformAnnotation:(e,t)=>({...e,linePoints:{start:t[0],end:t[1]}})}:o.isPolyline(e)||o.isPolygon(e)?{extractVertices:e=>e.vertices,transformAnnotation:(e,t)=>({...e,vertices:t})}:void 0;return(t,r)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,(r=>{var i,a,s,c,u,f,y,P,z,A,E,_;return e.openBlock(),e.createElementBlock(e.Fragment,{key:r.object.id},[e.unref(o.isInk)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:0,trackedAnnotation:r,isSelected:(null==(i=v.value)?void 0:i.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(x,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquare)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:1,trackedAnnotation:r,isSelected:(null==(a=v.value)?void 0:a.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(L,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isCircle)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:2,trackedAnnotation:r,isSelected:(null==(s=v.value)?void 0:s.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(g,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isLine)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,trackedAnnotation:r,isSelected:(null==(c=v.value)?void 0:c.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(B,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolyline)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:4,trackedAnnotation:r,isSelected:(null==(u=v.value)?void 0:u.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(M,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolygon)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:5,trackedAnnotation:r,isSelected:(null==(f=v.value)?void 0:f.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(R,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,scale:t.scale,onClick:e=>m(e,r)}),null,16,["isSelected","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isFreeText)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:6,trackedAnnotation:r,isSelected:(null==(y=v.value)?void 0:y.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),onDoubleClick:e=>{return t=r.object.id,void(o.isFreeText(d.value.find((e=>e.object.id===t)))&&(k.value=t));var t},vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>{var n;return[e.createVNode(h,{isSelected:(null==(n=v.value)?void 0:n.object.id)===r.object.id,isEditing:k.value===r.object.id,annotation:{...r,object:o},pageIndex:t.pageIndex,scale:t.scale,onClick:e=>m(e,r)},null,8,["isSelected","isEditing","annotation","pageIndex","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","onDoubleClick","vertexConfig","style"])):e.unref(o.isStamp)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:7,trackedAnnotation:r,isSelected:(null==(P=v.value)?void 0:P.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((()=>{var o;return[e.createVNode(F,{isSelected:(null==(o=v.value)?void 0:o.object.id)===r.object.id,annotation:r,pageIndex:t.pageIndex,scale:t.scale,onClick:e=>m(e,r)},null,8,["isSelected","annotation","pageIndex","scale","onClick"])]})),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.mergeProps({ref_for:!0},o))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isUnderline)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:8,trackedAnnotation:r,isSelected:(null==(z=v.value)?void 0:z.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(H,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>m(e,r)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isStrikeout)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:9,trackedAnnotation:r,isSelected:(null==(A=v.value)?void 0:A.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(U,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>m(e,r)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquiggly)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:10,trackedAnnotation:r,isSelected:(null==(E=v.value)?void 0:E.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(O,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>m(e,r)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isHighlight)(r)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:11,trackedAnnotation:r,isSelected:(null==(_=v.value)?void 0:_.object.id)===r.object.id,isDraggable:C(r),isResizable:b(r),lockAspectRatio:S(r),onSelect:e=>m(e,r),vertexConfig:w(r),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(r.object.blendMode??e.unref(l.PdfBlendMode).Multiply)}},{ref_for:!0},n),{default:e.withCtx((({annotation:o})=>[e.createVNode(W,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>m(e,r)}),null,16,["scale","onClick"])])),"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.mergeProps({ref_for:!0},o))])),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.createCommentVNode("",!0)],64)})),128))}}),G=e.defineComponent({__name:"text-markup",props:{pageIndex:{},scale:{}},setup(t){const o=t,{provides:n}=i.useSelectionCapability(),{provides:r}=s(),a=e.ref([]),c=e.ref(null),d=e.ref(null);e.watchEffect((e=>{const t=[];if(n.value){const e=n.value,l=e.onSelectionChange((()=>{a.value=e.getHighlightRectsForPage(o.pageIndex),c.value=e.getBoundingRectForPage(o.pageIndex)}));t.push(l)}if(r.value){const e=r.value.onActiveToolChange((e=>d.value=e));t.push(e)}e((()=>{t.forEach((e=>e()))}))}));const u=e.computed((()=>{if(!d.value)return l.blendModeToCss(l.PdfBlendMode.Normal);const e=d.value.defaults.type===l.PdfAnnotationSubtype.HIGHLIGHT?l.PdfBlendMode.Multiply:l.PdfBlendMode.Normal;return l.blendModeToCss(d.value.defaults.blendMode??e)}));return(t,o)=>c.value&&d.value?(e.openBlock(),e.createElementBlock("div",{key:0,style:e.normalizeStyle({mixBlendMode:u.value,pointerEvents:"none",position:"absolute",inset:0})},[d.value.defaults.type===e.unref(l.PdfAnnotationSubtype).HIGHLIGHT?(e.openBlock(),e.createBlock(W,{key:0,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(l.PdfAnnotationSubtype).UNDERLINE?(e.openBlock(),e.createBlock(H,{key:1,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(l.PdfAnnotationSubtype).STRIKEOUT?(e.openBlock(),e.createBlock(U,{key:2,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):d.value.defaults.type===e.unref(l.PdfAnnotationSubtype).SQUIGGLY?(e.openBlock(),e.createBlock(O,{key:3,color:d.value.defaults.color,opacity:d.value.defaults.opacity,segmentRects:a.value,scale:t.scale},null,8,["color","opacity","segmentRects","scale"])):e.createCommentVNode("",!0)],4)):e.createCommentVNode("",!0)}}),Y=e.defineComponent({__name:"preview-renderer",props:{preview:{},scale:{}},setup(t){const o=t,n=e.computed((()=>({position:"absolute",left:o.preview.bounds.origin.x*o.scale+"px",top:o.preview.bounds.origin.y*o.scale+"px",width:o.preview.bounds.size.width*o.scale+"px",height:o.preview.bounds.size.height*o.scale+"px",pointerEvents:"none",zIndex:10})));return(t,o)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(n.value)},[t.preview.type===e.unref(l.PdfAnnotationSubtype).CIRCLE?(e.openBlock(),e.createBlock(e.unref(g),e.mergeProps({key:0,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).SQUARE?(e.openBlock(),e.createBlock(e.unref(L),e.mergeProps({key:1,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).POLYGON?(e.openBlock(),e.createBlock(e.unref(R),e.mergeProps({key:2,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).POLYLINE?(e.openBlock(),e.createBlock(e.unref(M),e.mergeProps({key:3,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).LINE?(e.openBlock(),e.createBlock(e.unref(B),e.mergeProps({key:4,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).INK?(e.openBlock(),e.createBlock(e.unref(x),e.mergeProps({key:5,isSelected:!1,scale:t.scale},t.preview.data),null,16,["scale"])):t.preview.type===e.unref(l.PdfAnnotationSubtype).FREETEXT?(e.openBlock(),e.createElementBlock("div",{key:6,style:e.normalizeStyle({width:"100%",height:"100%",border:`1px dashed ${t.preview.data.fontColor||"#000000"}`,backgroundColor:"transparent"})},null,4)):e.createCommentVNode("",!0)],4))}}),Q=e.defineComponent({__name:"annotation-paint-layer",props:{pageIndex:{},scale:{}},setup(t){const o=t,{plugin:n}=a(),l=e.ref(new Map),r=e.ref(null),i=e.ref(null),s=e.computed((()=>({requestFile:({accept:e,onFile:t})=>{const o=r.value;o&&(o.accept=e,o.onchange=e=>{var n;const l=null==(n=e.target.files)?void 0:n[0];l&&(t(l),o.value="")},o.click())},processImage:({source:e,maxWidth:t,maxHeight:o,onComplete:n})=>{const l=i.value;if(!l||!l.getContext)return;const r=l.getContext("2d");if(!r)return;const a=new Image;a.crossOrigin="Anonymous",a.onload=()=>{let{naturalWidth:i,naturalHeight:s}=a;const c=t?t/i:1,d=o?o/s:1,u=Math.min(c,d,1),p=i*u,v=s*u;l.width=p,l.height=v,r.drawImage(a,0,0,p,v);const k=r.getImageData(0,0,p,v);"string"!=typeof e&&URL.revokeObjectURL(a.src),n({imageData:k,width:p,height:v})},a.src="string"==typeof e?e:URL.createObjectURL(e)}})));let c;return e.watchEffect((e=>{n.value&&(c=n.value.registerPageHandlers(o.pageIndex,o.scale,{services:s.value,onPreview:(e,t)=>{const o=new Map(l.value);t?o.set(e,t):o.delete(e),l.value=o}})),e((()=>{null==c||c()}))})),(t,o)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createElementVNode("input",{ref_key:"fileInputRef",ref:r,type:"file",style:{display:"none"}},null,512),e.createElementVNode("canvas",{ref_key:"canvasRef",ref:i,style:{display:"none"}},null,512),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value.entries(),(([o,n])=>(e.openBlock(),e.createBlock(Y,{key:o,preview:n,scale:t.scale},null,8,["preview","scale"])))),128))],64))}}),K=e.defineComponent({__name:"annotation-layer",props:{pageIndex:{},scale:{},pageWidth:{},pageHeight:{},rotation:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{}},setup(t){const o=t;return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(q,e.normalizeProps(e.guardReactiveProps(o)),{"selection-menu":e.withCtx((o=>[e.renderSlot(t.$slots,"selection-menu",e.normalizeProps(e.guardReactiveProps(o)))])),"resize-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"resize-handle",e.normalizeProps(e.guardReactiveProps(o)))])),"vertex-handle":e.withCtx((o=>[e.renderSlot(t.$slots,"vertex-handle",e.normalizeProps(e.guardReactiveProps(o)))])),_:3},16),e.createVNode(G,{pageIndex:t.pageIndex,scale:t.scale},null,8,["pageIndex","scale"]),e.createVNode(Q,{pageIndex:t.pageIndex,scale:t.scale},null,8,["pageIndex","scale"])]))}});exports.AnnotationContainer=p,exports.AnnotationLayer=K,exports.AnnotationPaintLayer=Q,exports.Annotations=q,exports.Circle=g,exports.FreeText=h,exports.Highlight=W,exports.Ink=x,exports.Line=B,exports.Polygon=R,exports.Polyline=M,exports.PreviewRenderer=Y,exports.RenderAnnotation=T,exports.Square=L,exports.Squiggly=O,exports.Stamp=F,exports.Strikeout=U,exports.TextMarkup=G,exports.Underline=H,exports.useAnnotation=()=>{const{provides:t}=s(),n=e.ref(o.initialState({enabled:!0}));return e.watchEffect((e=>{if(t.value){e(t.value.onStateChange((e=>{n.value=e})))}})),{state:e.readonly(n),provides:t}},exports.useAnnotationCapability=s,exports.useAnnotationPlugin=a,Object.keys(o).forEach((e=>{"default"===e||Object.prototype.hasOwnProperty.call(exports,e)||Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})}));
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|