@embedpdf/plugin-annotation 2.0.0-next.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -22,6 +22,7 @@ declare const __VLS_export: <T extends PdfAnnotationObject>(__VLS_props: NonNull
|
|
|
22
22
|
onSelect: (event: TouchEvent | MouseEvent) => void;
|
|
23
23
|
zIndex?: number;
|
|
24
24
|
selectionOutlineColor?: string;
|
|
25
|
+
style?: Record<string, string | number>;
|
|
25
26
|
}> & import('vue').PublicProps;
|
|
26
27
|
expose: (exposed: {}) => void;
|
|
27
28
|
attrs: any;
|
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/models"),r=require("@embedpdf/plugin-interaction-manager/vue"),i=require("@embedpdf/plugin-selection/vue"),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:{},documentId:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isDraggable:{type:Boolean},isResizable:{type:Boolean},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},selectionMenu:{},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(()=>r.value?r.value.forDocument(o.documentId):null),p=e.computed(()=>({...e.toRaw(o.trackedAnnotation.object),...e.toRaw(l.value)})),v=e.computed(()=>o.isSelected&&(o.selectionMenu||P["selection-menu"])),g=e.computed(()=>({origin:{x:p.value.rect.origin.x*o.scale,y:p.value.rect.origin.y*o.scale},size:{width:p.value.rect.size.width*o.scale,height:p.value.rect.size.height*o.scale}})),k=e.computed(()=>({type:"annotation",annotation:o.trackedAnnotation,pageIndex:o.pageIndex})),m=e.computed(()=>({suggestTop:!1,spaceAbove:0,spaceBelow:0})),f=(e,t)=>o.selectionMenu?o.selectionMenu({rect:e,menuWrapperProps:t,selected:o.isSelected,placement:m.value,context:k.value}):null,h=e.computed(()=>e.toRaw(p.value).rect),y=e.computed(()=>{var t;const n=e.toRaw(p.value);return(null==(t=o.vertexConfig)?void 0:t.extractVertices(n))??[]}),x=e.computed(()=>({minWidth:10,minHeight:10,boundingBox:{width:o.pageWidth,height:o.pageHeight}})),{dragProps:C,vertices:b,resize:S}=n.useInteractionHandles({controller:{element:h,vertices:y,constraints:x,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=p.value);const u=i.value??p.value,v=t.transformData.changes.vertices?null==(c=o.vertexConfig)?void 0:c.transformAnnotation(e.toRaw(u),t.transformData.changes.vertices):{rect:t.transformData.changes.rect},g=null==(s=r.value)?void 0:s.transformAnnotation(u,{type:t.transformData.type,changes:v,metadata:t.transformData.metadata});g&&(l.value={...e.toRaw(l.value),...g}),"end"===t.state&&g&&(i.value=null,null==(d=a.value)||d.updateAnnotation(o.pageIndex,o.trackedAnnotation.object.id,g))}},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}),w=n.useDoublePressProps(o.onDoubleClick);e.watch(()=>o.trackedAnnotation.object,e=>{l.value=e},{deep:!0});const B=e.computed(()=>({position:"absolute",left:p.value.rect.origin.x*o.scale+"px",top:p.value.rect.origin.y*o.scale+"px",width:p.value.rect.size.width*o.scale+"px",height:p.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})),P=e.useSlots();return(o,l)=>(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",e.mergeProps({...e.unref(C),...e.unref(w)},{style:B.value}),[e.renderSlot(o.$slots,"default",{annotation:p.value}),t.isSelected&&t.isResizable?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(S),({key:t,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t},[e.unref(P)["resize-handle"]?e.renderSlot(o.$slots,"resize-handle",e.mergeProps({key:0,ref_for:!0},{key:t,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(b).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(e.unref(b),({key:t,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t},[e.unref(P)["vertex-handle"]?e.renderSlot(o.$slots,"vertex-handle",e.mergeProps({key:0,ref_for:!0},{key:t,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),v.value?(e.openBlock(),e.createBlock(e.unref(n.CounterRotate),{key:0,rect:g.value,rotation:t.rotation},{default:e.withCtx(({rect:n,menuWrapperProps:l})=>[t.selectionMenu?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f(n,l)),{key:0})):e.renderSlot(o.$slots,"selection-menu",{key:1,context:k.value,selected:t.isSelected,rect:n,placement:m.value,menuWrapperProps:l})]),_:3},8,["rect","rotation"])):e.createCommentVNode("",!0)]))}}),v=["width","height","viewBox"],g=["cx","cy","rx","ry","fill","opacity"],k=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(o,a)=>{var c;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:a[0]||(a[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:a[1]||(a[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==(c=t.strokeDashArray)?void 0:c.join(",")}})},null,44,g)],12,v)}}}),m=["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:r}=c(),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})},s=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,c=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?`${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(o,l)=>(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:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[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,m)],36))}}),h=["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(o,i)=>(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,(o,n)=>(e.openBlock(),e.createElementBlock("path",{key:n,d:o,fill:"none",opacity:t.opacity,onPointerdown:i[0]||(i[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:i[1]||(i[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,h))}}),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:c}=r.value,s=Math.atan2(c-i,a-l);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,s+Math.PI,l,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===l.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(o,n)=>{var d;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:r.value.x1,y1:r.value.y1,x2:r.value.x2,y2:r.value.y2,opacity:t.opacity,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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==(d=t.strokeDashArray)?void 0:d.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:n[2]||(n[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[3]||(n[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:n[4]||(n[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[5]||(n[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"],I=["d"],A=["x","y","width","height","fill","stroke","stroke-width"],E=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),c=e.computed(()=>o.rect.size.width*o.scale),s=e.computed(()=>o.rect.size.height*o.scale);return(o,n)=>{var d;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:i.value,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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==(d=t.strokeDashArray)?void 0:d.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,I)):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,A)):e.createCommentVNode("",!0)],12,P)}}}),R=["width","height","viewBox"],_=["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"}),c=e.computed(()=>n.rect.size.width*n.scale),s=e.computed(()=>n.rect.size.height*n.scale);return(o,n)=>(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:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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.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:n[2]||(n[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[3]||(n[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:n[4]||(n[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[5]||(n[5]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.end))},null,44,$)):e.createCommentVNode("",!0)],12,R))}}),D=["width","height","viewBox"],N=["x","y","width","height","fill","opacity"],V=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(o,a)=>{var c;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:a[0]||(a[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:a[1]||(a[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==(c=t.strokeDashArray)?void 0:c.join(",")}})},null,44,N)],12,D)}}}),L=["src"],T=e.defineComponent({__name:"render-annotation",props:{documentId:{},pageIndex:{},annotation:{},scaleFactor:{default:1},style:{}},setup(t){const o=t,{provides:r}=c(),i=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,o.documentId,d.value,u.value,p.value,r.value],(e,t,c)=>{if(r.value){a.value&&(URL.revokeObjectURL(a.value),a.value=null);const e=r.value.forDocument(o.documentId).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);i.value=t,a.value=t},l.ignore),c(()=>{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),s.value&&s.value.abort({code:l.PdfErrorCode.Cancelled,message:"canceled render task on unmount"})});const v=()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null)};return(o,n)=>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,L)):e.createCommentVNode("",!0)}}),F=e.defineComponent({__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},documentId:{},pageIndex:{},scale:{},onClick:{type:Function}},setup:t=>(o,n)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.isSelected?"none":"auto",cursor:"pointer"}),onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createVNode(T,{documentId:t.documentId,pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale},null,8,["documentId","pageIndex","annotation","scaleFactor"])],36))}),W=e.defineComponent({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup:t=>(o,n)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}),U=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(o,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,onPointerdown:i[0]||(i[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:i[1]||(i[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}}),O=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(o,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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(o,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{},selectionMenu:{type:Function}},setup(t){const n=t,{provides:a}=c(),{provides:s}=i.useSelectionCapability(),d=e.ref([]),{register:u}=r.usePointerHandlers({documentId:()=>n.documentId,pageIndex:n.pageIndex}),v=e.ref(null),g=e.ref(null),m=e.computed(()=>a.value?a.value.forDocument(n.documentId):null);e.watchEffect(e=>{if(m.value){const t=m.value.getState();d.value=o.getAnnotationsByPageIndex(t,n.pageIndex),v.value=o.getSelectedAnnotationByPageIndex(t,n.pageIndex);e(m.value.onStateChange(e=>{d.value=o.getAnnotationsByPageIndex(e,n.pageIndex),v.value=o.getSelectedAnnotationByPageIndex(e,n.pageIndex)}))}});const h=(e,t)=>{t.target===t.currentTarget&&m.value&&(m.value.deselectAnnotation(),g.value=null)},y=(e,t)=>{e.stopPropagation(),m.value&&s.value&&(m.value.selectAnnotation(n.pageIndex,t.object.id),s.value.clear(),t.object.id!==g.value&&(g.value=null))};e.watchEffect(e=>{if(m.value){const t=u({onPointerDown:h});t&&e(t)}});const C=e=>{var t;return null==(t=m.value)?void 0:t.findToolForAnnotation(e.object)},b=e=>{var t;return(!o.isFreeText(e)||g.value!==e.object.id)&&((null==(t=C(e))?void 0:t.interaction.isDraggable)??!1)},S=e=>{var t;return(null==(t=C(e))?void 0:t.interaction.isResizable)??!1},w=e=>{var t;return(null==(t=C(e))?void 0:t.interaction.lockAspectRatio)??!1},P=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(r,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,i=>{var a,c,s,u,m,h,C,z,I,A,R,_;return e.openBlock(),e.createElementBlock(e.Fragment,{key:i.object.id},[e.unref(o.isInk)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:0,trackedAnnotation:i,isSelected:(null==(a=v.value)?void 0:a.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquare)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:1,trackedAnnotation:i,isSelected:(null==(c=v.value)?void 0:c.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(V,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isCircle)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:2,trackedAnnotation:i,isSelected:(null==(s=v.value)?void 0:s.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(k,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isLine)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:3,trackedAnnotation:i,isSelected:(null==(u=v.value)?void 0:u.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolyline)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:4,trackedAnnotation:i,isSelected:(null==(m=v.value)?void 0:m.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolygon)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:5,trackedAnnotation:i,isSelected:(null==(h=v.value)?void 0:h.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(E,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=v.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>y(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isFreeText)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:6,trackedAnnotation:i,isSelected:(null==(C=v.value)?void 0:C.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),onDoubleClick:e=>{return t=i.object.id,void(o.isFreeText(d.value.find(e=>e.object.id===t))&&(g.value=t));var t},vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(f,{isSelected:(null==(n=v.value)?void 0:n.object.id)===i.object.id,isEditing:g.value===i.object.id,annotation:{...i,object:o},pageIndex:t.pageIndex,scale:t.scale,onClick:e=>y(e,i)},null,8,["isSelected","isEditing","annotation","pageIndex","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","onDoubleClick","vertexConfig","style"])):e.unref(o.isStamp)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:7,trackedAnnotation:i,isSelected:(null==(z=v.value)?void 0:z.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(()=>{var o;return[e.createVNode(F,{documentId:t.documentId,isSelected:(null==(o=v.value)?void 0:o.object.id)===i.object.id,annotation:i,pageIndex:t.pageIndex,scale:t.scale,onClick:e=>y(e,i)},null,8,["documentId","isSelected","annotation","pageIndex","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isUnderline)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:8,trackedAnnotation:i,isSelected:(null==(I=v.value)?void 0:I.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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=>y(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isStrikeout)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:9,trackedAnnotation:i,isSelected:(null==(A=v.value)?void 0:A.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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=>y(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquiggly)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:10,trackedAnnotation:i,isSelected:(null==(R=v.value)?void 0:R.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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=>y(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isHighlight)(i)?(e.openBlock(),e.createBlock(p,e.mergeProps({key:11,trackedAnnotation:i,isSelected:(null==(_=v.value)?void 0:_.object.id)===i.object.id,isDraggable:b(i),isResizable:S(i),lockAspectRatio:w(i),onSelect:e=>y(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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=>y(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.createCommentVNode("",!0)],64)}),128))}}),G=e.defineComponent({__name:"text-markup",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const o=t,{provides:n}=i.useSelectionCapability(),{provides:r}=c(),a=e.ref([]),s=e.ref(null),d=e.ref(null);e.watchEffect(e=>{const t=[];if(n.value){const e=n.value.forDocument(o.documentId),l=e.onSelectionChange(()=>{a.value=e.getHighlightRectsForPage(o.pageIndex),s.value=e.getBoundingRectForPage(o.pageIndex)});t.push(l)}if(r.value){const e=r.value.forDocument(o.documentId);d.value=e.getActiveTool();const n=e.onActiveToolChange(e=>d.value=e);t.push(n)}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(o,n)=>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(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(O,{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(U,{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(o,r)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(n.value)},[t.preview.type===e.unref(l.PdfAnnotationSubtype).CIRCLE?(e.openBlock(),e.createBlock(e.unref(k),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(V),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(E),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:{documentId:{},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 g=r.getImageData(0,0,p,v);"string"!=typeof e&&URL.revokeObjectURL(a.src),n({imageData:g,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.documentId,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()})}),(o,n)=>(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:{documentId:{},pageIndex:{},scale:{},rotation:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{},selectionMenu:{type:Function}},setup(o){const n=o,r=t.useDocumentState(()=>n.documentId),i=e.computed(()=>{var e,t,o;return null==(o=null==(t=null==(e=r.value)?void 0:e.document)?void 0:t.pages)?void 0:o[n.pageIndex]}),a=e.computed(()=>{var e,t;return(null==(t=null==(e=i.value)?void 0:e.size)?void 0:t.width)??0}),c=e.computed(()=>{var e,t;return(null==(t=null==(e=i.value)?void 0:e.size)?void 0:t.height)??0}),s=e.computed(()=>{var e;return void 0!==n.scale?n.scale:(null==(e=r.value)?void 0:e.scale)??1}),d=e.computed(()=>{var e;return void 0!==n.rotation?n.rotation:(null==(e=r.value)?void 0:e.rotation)??l.Rotation.Degree0});return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(q,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value,rotation:d.value,pageWidth:a.value,pageHeight:c.value,resizeUI:o.resizeUI,vertexUI:o.vertexUI,selectionOutlineColor:o.selectionOutlineColor,selectionMenu:o.selectionMenu},{"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},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","resizeUI","vertexUI","selectionOutlineColor","selectionMenu"]),e.createVNode(G,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value},null,8,["documentId","pageIndex","scale"]),e.createVNode(Q,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value},null,8,["documentId","pageIndex","scale"])]))}});exports.AnnotationContainer=p,exports.AnnotationLayer=K,exports.AnnotationPaintLayer=Q,exports.Annotations=q,exports.Circle=k,exports.FreeText=f,exports.Highlight=W,exports.Ink=x,exports.Line=B,exports.Polygon=E,exports.Polyline=M,exports.PreviewRenderer=Y,exports.RenderAnnotation=T,exports.Square=V,exports.Squiggly=U,exports.Stamp=F,exports.Strikeout=O,exports.TextMarkup=G,exports.Underline=H,exports.useAnnotation=t=>{var n,l;const{provides:r}=c(),i=e.ref((null==(l=null==(n=null==r?void 0:r.value)?void 0:n.forDocument(e.toValue(t)))?void 0:l.getState())??o.initialDocumentState());return e.watch([r,()=>e.toValue(t)],([e,t],o,n)=>{if(e&&t){const o=e.forDocument(t);i.value=o.getState();n(o.onStateChange(e=>{i.value=e}))}},{immediate:!0}),{state:i,provides:e.computed(()=>{var o;return(null==(o=r.value)?void 0:o.forDocument(e.toValue(t)))??null})}},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),c=()=>t.useCapability(o.AnnotationPlugin.id),s={"data-no-interaction":"",style:{display:"contents"}},d=e.defineComponent({inheritAttrs:!1,__name:"annotation-container",props:{scale:{},documentId:{},pageIndex:{},rotation:{},pageWidth:{},pageHeight:{},trackedAnnotation:{},isSelected:{type:Boolean},isDraggable:{type:Boolean},isResizable:{type:Boolean},lockAspectRatio:{type:Boolean,default:!1},vertexConfig:{},selectionMenu:{},outlineOffset:{default:1},onDoubleClick:{},onSelect:{},zIndex:{default:1},selectionOutlineColor:{default:"#007ACC"},style:{}},setup(t){const o=t,l="#007ACC",r="#007ACC",i=e.shallowRef(e.toRaw(o.trackedAnnotation.object)),{provides:a}=c(),d=e.ref(null),u=e.computed(()=>a.value?a.value.forDocument(o.documentId):null),p=e.computed(()=>({...e.toRaw(o.trackedAnnotation.object),...e.toRaw(i.value)})),v=e.computed(()=>o.isSelected&&(o.selectionMenu||z["selection-menu"])),g=e.computed(()=>({origin:{x:p.value.rect.origin.x*o.scale,y:p.value.rect.origin.y*o.scale},size:{width:p.value.rect.size.width*o.scale,height:p.value.rect.size.height*o.scale}})),k=e.computed(()=>({type:"annotation",annotation:o.trackedAnnotation,pageIndex:o.pageIndex})),m=e.computed(()=>({suggestTop:!1,spaceAbove:0,spaceBelow:0})),f=(e,t)=>o.selectionMenu?o.selectionMenu({rect:e,menuWrapperProps:t,selected:o.isSelected,placement:m.value,context:k.value}):null,h=e.computed(()=>e.toRaw(p.value).rect),y=e.computed(()=>{var t;const n=e.toRaw(p.value);return(null==(t=o.vertexConfig)?void 0:t.extractVertices(n))??[]}),x=e.computed(()=>({minWidth:10,minHeight:10,boundingBox:{width:o.pageWidth,height:o.pageHeight}})),{dragProps:C,vertices:b,resize:S}=n.useInteractionHandles({controller:{element:h,vertices:y,constraints:x,maintainAspectRatio:e.computed(()=>o.lockAspectRatio),pageRotation:e.computed(()=>o.rotation),scale:e.computed(()=>o.scale),enabled:e.computed(()=>o.isSelected),onUpdate:t=>{var n,l,r,c;if(!(null==(n=t.transformData)?void 0:n.type))return;"start"===t.state&&(d.value=p.value);const s=d.value??p.value,v=t.transformData.changes.vertices?null==(l=o.vertexConfig)?void 0:l.transformAnnotation(e.toRaw(s),t.transformData.changes.vertices):{rect:t.transformData.changes.rect},g=null==(r=a.value)?void 0:r.transformAnnotation(s,{type:t.transformData.type,changes:v,metadata:t.transformData.metadata});g&&(i.value={...e.toRaw(i.value),...g}),"end"===t.state&&g&&(d.value=null,null==(c=u.value)||c.updateAnnotation(o.pageIndex,o.trackedAnnotation.object.id,g))}},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}),w=n.useDoublePressProps(o.onDoubleClick);e.watch(()=>o.trackedAnnotation.object,e=>{i.value=e},{deep:!0});const B=e.computed(()=>({position:"absolute",left:p.value.rect.origin.x*o.scale+"px",top:p.value.rect.origin.y*o.scale+"px",width:p.value.rect.size.width*o.scale+"px",height:p.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})),P=e.computed(()=>({...B.value,...o.style??{}})),z=e.useSlots();return(o,i)=>(e.openBlock(),e.createElementBlock("div",s,[e.createElementVNode("div",e.mergeProps({...e.unref(C),...e.unref(w)},{style:P.value}),[e.renderSlot(o.$slots,"default",{annotation:p.value}),t.isSelected&&t.isResizable?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(e.unref(S),({key:t,style:n,...r})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t},[e.unref(z)["resize-handle"]?e.renderSlot(o.$slots,"resize-handle",e.mergeProps({key:0,ref_for:!0},{key:t,style:n,...r,backgroundColor:l}),()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},r,{style:[n,{backgroundColor:l}]}),null,16)]):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},r,{style:[n,{backgroundColor:l}]}),null,16))],64))),128)):e.createCommentVNode("",!0),t.isSelected&&e.unref(b).length>0?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(e.unref(b),({key:t,style:n,...l})=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:t},[e.unref(z)["vertex-handle"]?e.renderSlot(o.$slots,"vertex-handle",e.mergeProps({key:0,ref_for:!0},{key:t,style:n,...l,backgroundColor:r}),()=>[e.createElementVNode("div",e.mergeProps({ref_for:!0},l,{style:[n,{backgroundColor:r}]}),null,16)]):(e.openBlock(),e.createElementBlock("div",e.mergeProps({key:1,ref_for:!0},l,{style:[n,{backgroundColor:r}]}),null,16))],64))),128)):e.createCommentVNode("",!0)],16),v.value?(e.openBlock(),e.createBlock(e.unref(n.CounterRotate),{key:0,rect:g.value,rotation:t.rotation},{default:e.withCtx(({rect:n,menuWrapperProps:l})=>[t.selectionMenu?(e.openBlock(),e.createBlock(e.resolveDynamicComponent(f(n,l)),{key:0})):e.renderSlot(o.$slots,"selection-menu",{key:1,context:k.value,selected:t.isSelected,rect:n,placement:m.value,menuWrapperProps:l})]),_:3},8,["rect","rotation"])):e.createCommentVNode("",!0)]))}}),u=["width","height","viewBox"],p=["cx","cy","rx","ry","fill","opacity"],v=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(o,a)=>{var c;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:a[0]||(a[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:a[1]||(a[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==(c=t.strokeDashArray)?void 0:c.join(",")}})},null,44,p)],12,u)}}}),g=["contenteditable"],k=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}=c(),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})},s=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,c=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?`${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(o,l)=>(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:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[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,g)],36))}}),m=["width","height","viewBox"],f=["d","opacity"],h=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(o,i)=>(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,(o,n)=>(e.openBlock(),e.createElementBlock("path",{key:n,d:o,fill:"none",opacity:t.opacity,onPointerdown:i[0]||(i[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:i[1]||(i[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,f))),128))],12,m))}}),y=["width","height","viewBox"],x=["x1","y1","x2","y2","opacity"],C=["d","transform","stroke","fill"],b=["d","transform","stroke","fill"],S=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:c}=r.value,s=Math.atan2(c-i,a-l);return{start:o.patching.createEnding(null==(e=n.lineEndings)?void 0:e.start,n.strokeWidth,s+Math.PI,l,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===l.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(o,n)=>{var d;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:r.value.x1,y1:r.value.y1,x2:r.value.x2,y2:r.value.y2,opacity:t.opacity,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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==(d=t.strokeDashArray)?void 0:d.join(",")}})},null,44,x),i.value.start?(e.openBlock(),e.createElementBlock("path",{key:0,d:i.value.start.d,transform:i.value.start.transform,onPointerdown:n[2]||(n[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[3]||(n[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,C)):e.createCommentVNode("",!0),i.value.end?(e.openBlock(),e.createElementBlock("path",{key:1,d:i.value.end.d,transform:i.value.end.transform,onPointerdown:n[4]||(n[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[5]||(n[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,b)):e.createCommentVNode("",!0)],12,y)}}}),w=["width","height","viewBox"],B=["d","opacity"],P=["d"],z=["x","y","width","height","fill","stroke","stroke-width"],I=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),c=e.computed(()=>o.rect.size.width*o.scale),s=e.computed(()=>o.rect.size.height*o.scale);return(o,n)=>{var d;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:i.value,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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==(d=t.strokeDashArray)?void 0:d.join(",")}})},null,44,B),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,P)):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,z)):e.createCommentVNode("",!0)],12,w)}}}),A=["width","height","viewBox"],E=["d","opacity"],R=["d","transform","stroke","fill"],_=["d","transform","stroke","fill"],j=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(o,n)=>(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:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[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,E),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:n[2]||(n[2]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[3]||(n[3]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.start))},null,44,R)):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:n[4]||(n[4]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[5]||(n[5]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle(a(i.value.end))},null,44,_)):e.createCommentVNode("",!0)],12,A))}}),$=["width","height","viewBox"],M=["x","y","width","height","fill","opacity"],D=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(o,a)=>{var c;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:a[0]||(a[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:a[1]||(a[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==(c=t.strokeDashArray)?void 0:c.join(",")}})},null,44,M)],12,$)}}}),N=["src"],V=e.defineComponent({__name:"render-annotation",props:{documentId:{},pageIndex:{},annotation:{},scaleFactor:{default:1},style:{}},setup(t){const o=t,{provides:r}=c(),i=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,o.documentId,d.value,u.value,p.value,r.value],(e,t,c)=>{if(r.value){a.value&&(URL.revokeObjectURL(a.value),a.value=null);const e=r.value.forDocument(o.documentId).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);i.value=t,a.value=t},l.ignore),c(()=>{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),s.value&&s.value.abort({code:l.PdfErrorCode.Cancelled,message:"canceled render task on unmount"})});const v=()=>{a.value&&(URL.revokeObjectURL(a.value),a.value=null)};return(o,n)=>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,N)):e.createCommentVNode("",!0)}}),L=e.defineComponent({__name:"stamp",props:{isSelected:{type:Boolean},annotation:{},documentId:{},pageIndex:{},scale:{},onClick:{type:Function}},setup:t=>(o,n)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle({position:"absolute",width:"100%",height:"100%",zIndex:2,pointerEvents:t.isSelected?"none":"auto",cursor:"pointer"}),onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[1]=(...e)=>t.onClick&&t.onClick(...e))},[e.createVNode(V,{documentId:t.documentId,pageIndex:t.pageIndex,annotation:{...t.annotation.object,id:t.annotation.object.id},scaleFactor:t.scale},null,8,["documentId","pageIndex","annotation","scaleFactor"])],36))}),T=e.defineComponent({__name:"highlight",props:{color:{default:"#FFFF00"},opacity:{default:.5},segmentRects:{},rect:{},scale:{},onClick:{}},setup:t=>(o,n)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,l)=>(e.openBlock(),e.createElementBlock("div",{key:l,onPointerdown:n[0]||(n[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:n[1]||(n[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}),F=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(o,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,a)=>(e.openBlock(),e.createElementBlock("div",{key:a,onPointerdown:i[0]||(i[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:i[1]||(i[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}}),W=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(o,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}}),U=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(o,l)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.segmentRects,(o,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,onPointerdown:l[0]||(l[0]=(...e)=>t.onClick&&t.onClick(...e)),onTouchstart:l[1]||(l[1]=(...e)=>t.onClick&&t.onClick(...e)),style:e.normalizeStyle({position:"absolute",left:(t.rect?o.origin.x-t.rect.origin.x:o.origin.x)*t.scale+"px",top:(t.rect?o.origin.y-t.rect.origin.y:o.origin.y)*t.scale+"px",width:o.size.width*t.scale+"px",height:o.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))}}),O=e.defineComponent({__name:"annotations",props:{documentId:{},pageIndex:{},scale:{},rotation:{},pageWidth:{},pageHeight:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{},selectionMenu:{type:Function}},setup(t){const n=t,{provides:a}=c(),{provides:s}=i.useSelectionCapability(),u=e.ref([]),{register:p}=r.usePointerHandlers({documentId:()=>n.documentId,pageIndex:n.pageIndex}),g=e.ref(null),m=e.ref(null),f=e.computed(()=>a.value?a.value.forDocument(n.documentId):null);e.watchEffect(e=>{if(f.value){const t=f.value.getState();u.value=o.getAnnotationsByPageIndex(t,n.pageIndex),g.value=o.getSelectedAnnotationByPageIndex(t,n.pageIndex);e(f.value.onStateChange(e=>{u.value=o.getAnnotationsByPageIndex(e,n.pageIndex),g.value=o.getSelectedAnnotationByPageIndex(e,n.pageIndex)}))}});const y=(e,t)=>{t.target===t.currentTarget&&f.value&&(f.value.deselectAnnotation(),m.value=null)},x=(e,t)=>{e.stopPropagation(),f.value&&s.value&&(f.value.selectAnnotation(n.pageIndex,t.object.id),s.value.clear(),t.object.id!==m.value&&(m.value=null))};e.watchEffect(e=>{if(f.value){const t=p({onPointerDown:y});t&&e(t)}});const C=e=>{var t;return null==(t=f.value)?void 0:t.findToolForAnnotation(e.object)},b=e=>{var t;return(!o.isFreeText(e)||m.value!==e.object.id)&&((null==(t=C(e))?void 0:t.interaction.isDraggable)??!1)},w=e=>{var t;return(null==(t=C(e))?void 0:t.interaction.isResizable)??!1},B=e=>{var t;return(null==(t=C(e))?void 0:t.interaction.lockAspectRatio)??!1},P=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(r,i)=>(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,i=>{var a,c,s,p,f,y,C,z,A,E,R,_;return e.openBlock(),e.createElementBlock(e.Fragment,{key:i.object.id},[e.unref(o.isInk)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:0,trackedAnnotation:i,isSelected:(null==(a=g.value)?void 0:a.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(h,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquare)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:1,trackedAnnotation:i,isSelected:(null==(c=g.value)?void 0:c.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(D,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isCircle)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:2,trackedAnnotation:i,isSelected:(null==(s=g.value)?void 0:s.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(v,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isLine)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:3,trackedAnnotation:i,isSelected:(null==(p=g.value)?void 0:p.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(S,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolyline)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:4,trackedAnnotation:i,isSelected:(null==(f=g.value)?void 0:f.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(j,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isPolygon)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:5,trackedAnnotation:i,isSelected:(null==(y=g.value)?void 0:y.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(I,e.mergeProps({ref_for:!0},o,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,scale:t.scale,onClick:e=>x(e,i)}),null,16,["isSelected","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isFreeText)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:6,trackedAnnotation:i,isSelected:(null==(C=g.value)?void 0:C.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),onDoubleClick:e=>{return t=i.object.id,void(o.isFreeText(u.value.find(e=>e.object.id===t))&&(m.value=t));var t},vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>{var n;return[e.createVNode(k,{isSelected:(null==(n=g.value)?void 0:n.object.id)===i.object.id,isEditing:m.value===i.object.id,annotation:{...i,object:o},pageIndex:t.pageIndex,scale:t.scale,onClick:e=>x(e,i)},null,8,["isSelected","isEditing","annotation","pageIndex","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","onDoubleClick","vertexConfig","style"])):e.unref(o.isStamp)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:7,trackedAnnotation:i,isSelected:(null==(z=g.value)?void 0:z.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(()=>{var o;return[e.createVNode(L,{documentId:t.documentId,isSelected:(null==(o=g.value)?void 0:o.object.id)===i.object.id,annotation:i,pageIndex:t.pageIndex,scale:t.scale,onClick:e=>x(e,i)},null,8,["documentId","isSelected","annotation","pageIndex","scale","onClick"])]}),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),"resize-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"resize-handle",e.mergeProps({ref_for:!0},t))]),"vertex-handle":e.withCtx(t=>[e.renderSlot(r.$slots,"vertex-handle",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isUnderline)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:8,trackedAnnotation:i,isSelected:(null==(A=g.value)?void 0:A.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.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=>x(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isStrikeout)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:9,trackedAnnotation:i,isSelected:(null==(E=g.value)?void 0:E.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>[e.createVNode(W,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>x(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isSquiggly)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:10,trackedAnnotation:i,isSelected:(null==(R=g.value)?void 0:R.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Normal)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>[e.createVNode(F,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>x(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.unref(o.isHighlight)(i)?(e.openBlock(),e.createBlock(d,e.mergeProps({key:11,trackedAnnotation:i,isSelected:(null==(_=g.value)?void 0:_.object.id)===i.object.id,isDraggable:b(i),isResizable:w(i),lockAspectRatio:B(i),onSelect:e=>x(e,i),vertexConfig:P(i),zIndex:0,style:{mixBlendMode:e.unref(l.blendModeToCss)(i.object.blendMode??e.unref(l.PdfBlendMode).Multiply)}},{ref_for:!0},n),{default:e.withCtx(({annotation:o})=>[e.createVNode(T,e.mergeProps({ref_for:!0},o,{scale:t.scale,onClick:e=>x(e,i)}),null,16,["scale","onClick"])]),"selection-menu":e.withCtx(t=>[e.renderSlot(r.$slots,"selection-menu",e.mergeProps({ref_for:!0},t))]),_:2},1040,["trackedAnnotation","isSelected","isDraggable","isResizable","lockAspectRatio","onSelect","vertexConfig","style"])):e.createCommentVNode("",!0)],64)}),128))}}),H=e.defineComponent({__name:"text-markup",props:{documentId:{},pageIndex:{},scale:{}},setup(t){const o=t,{provides:n}=i.useSelectionCapability(),{provides:r}=c(),a=e.ref([]),s=e.ref(null),d=e.ref(null);e.watchEffect(e=>{const t=[];if(n.value){const e=n.value.forDocument(o.documentId),l=e.onSelectionChange(()=>{a.value=e.getHighlightRectsForPage(o.pageIndex),s.value=e.getBoundingRectForPage(o.pageIndex)});t.push(l)}if(r.value){const e=r.value.forDocument(o.documentId);d.value=e.getActiveTool();const n=e.onActiveToolChange(e=>d.value=e);t.push(n)}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(o,n)=>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(l.PdfAnnotationSubtype).HIGHLIGHT?(e.openBlock(),e.createBlock(T,{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(U,{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(W,{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(F,{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)}}),q=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(o,r)=>(e.openBlock(),e.createElementBlock("div",{style:e.normalizeStyle(n.value)},[t.preview.type===e.unref(l.PdfAnnotationSubtype).CIRCLE?(e.openBlock(),e.createBlock(e.unref(v),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(D),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(I),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(j),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(S),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(h),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))}}),G=e.defineComponent({__name:"annotation-paint-layer",props:{documentId:{},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 g=r.getImageData(0,0,p,v);"string"!=typeof e&&URL.revokeObjectURL(a.src),n({imageData:g,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.documentId,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()})}),(o,n)=>(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(q,{key:o,preview:n,scale:t.scale},null,8,["preview","scale"]))),128))],64))}}),Y=e.defineComponent({__name:"annotation-layer",props:{documentId:{},pageIndex:{},scale:{},rotation:{},resizeUI:{},vertexUI:{},selectionOutlineColor:{},selectionMenu:{type:Function}},setup(o){const n=o,r=t.useDocumentState(()=>n.documentId),i=e.computed(()=>{var e,t,o;return null==(o=null==(t=null==(e=r.value)?void 0:e.document)?void 0:t.pages)?void 0:o[n.pageIndex]}),a=e.computed(()=>{var e,t;return(null==(t=null==(e=i.value)?void 0:e.size)?void 0:t.width)??0}),c=e.computed(()=>{var e,t;return(null==(t=null==(e=i.value)?void 0:e.size)?void 0:t.height)??0}),s=e.computed(()=>{var e;return void 0!==n.scale?n.scale:(null==(e=r.value)?void 0:e.scale)??1}),d=e.computed(()=>{var e;return void 0!==n.rotation?n.rotation:(null==(e=r.value)?void 0:e.rotation)??l.Rotation.Degree0});return(t,n)=>(e.openBlock(),e.createElementBlock("div",null,[e.createVNode(O,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value,rotation:d.value,pageWidth:a.value,pageHeight:c.value,resizeUI:o.resizeUI,vertexUI:o.vertexUI,selectionOutlineColor:o.selectionOutlineColor,selectionMenu:o.selectionMenu},{"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},8,["documentId","pageIndex","scale","rotation","pageWidth","pageHeight","resizeUI","vertexUI","selectionOutlineColor","selectionMenu"]),e.createVNode(H,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value},null,8,["documentId","pageIndex","scale"]),e.createVNode(G,{documentId:o.documentId,pageIndex:o.pageIndex,scale:s.value},null,8,["documentId","pageIndex","scale"])]))}});exports.AnnotationContainer=d,exports.AnnotationLayer=Y,exports.AnnotationPaintLayer=G,exports.Annotations=O,exports.Circle=v,exports.FreeText=k,exports.Highlight=T,exports.Ink=h,exports.Line=S,exports.Polygon=I,exports.Polyline=j,exports.PreviewRenderer=q,exports.RenderAnnotation=V,exports.Square=D,exports.Squiggly=F,exports.Stamp=L,exports.Strikeout=W,exports.TextMarkup=H,exports.Underline=U,exports.useAnnotation=t=>{var n,l;const{provides:r}=c(),i=e.ref((null==(l=null==(n=null==r?void 0:r.value)?void 0:n.forDocument(e.toValue(t)))?void 0:l.getState())??o.initialDocumentState());return e.watch([r,()=>e.toValue(t)],([e,t],o,n)=>{if(e&&t){const o=e.forDocument(t);i.value=o.getState();n(o.onStateChange(e=>{i.value=e}))}},{immediate:!0}),{state:i,provides:e.computed(()=>{var o;return(null==(o=r.value)?void 0:o.forDocument(e.toValue(t)))??null})}},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]})});
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|