UNPKG

@react-pdf-viewer/core

Version:

A React component to view a PDF document

1 lines 92.2 kB
"use strict";var e=require("react"),t=require("pdfjs-dist");function n(e){var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var r,o=n(e),a=n(t);exports.AnnotationType=void 0,(r=exports.AnnotationType||(exports.AnnotationType={}))[r.Text=1]="Text",r[r.Link=2]="Link",r[r.FreeText=3]="FreeText",r[r.Line=4]="Line",r[r.Square=5]="Square",r[r.Circle=6]="Circle",r[r.Polygon=7]="Polygon",r[r.Polyline=8]="Polyline",r[r.Highlight=9]="Highlight",r[r.Underline=10]="Underline",r[r.Squiggly=11]="Squiggly",r[r.StrikeOut=12]="StrikeOut",r[r.Stamp=13]="Stamp",r[r.Caret=14]="Caret",r[r.Ink=15]="Ink",r[r.Popup=16]="Popup",r[r.FileAttachment=17]="FileAttachment";var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},i(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s,l=function(){return l=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},l.apply(this,arguments)};exports.TextDirection=void 0,(s=exports.TextDirection||(exports.TextDirection={})).RightToLeft="RTL",s.LeftToRight="LTR";var u,p=o.createContext({currentTheme:"light",direction:exports.TextDirection.LeftToRight,setCurrentTheme:function(){}}),d=function(e){var t=[];return Object.keys(e).forEach((function(n){n&&e[n]&&t.push(n)})),t.join(" ")},f="undefined"!=typeof window?o.useLayoutEffect:o.useEffect,g=function(e){var t=o.useRef(null),n=e.once,r=e.threshold,a=e.onVisibilityChanged;return f((function(){var e=t.current;if(e){var o=new IntersectionObserver((function(t){t.forEach((function(t){var r=t.isIntersecting,i=t.intersectionRatio;a({isVisible:r,ratio:i}),r&&n&&(o.unobserve(e),o.disconnect())}))}),{threshold:r||0});return o.observe(e),function(){o.unobserve(e),o.disconnect()}}}),[]),t},v=function(e){var t=e.children,n=e.ignoreDirection,r=void 0!==n&&n,a=e.size,i=void 0===a?24:a,c=o.useContext(p).direction,s=!r&&c===exports.TextDirection.RightToLeft,l="".concat(i||24,"px");return o.createElement("svg",{"aria-hidden":"true",className:d({"rpv-core__icon":!0,"rpv-core__icon--rtl":s}),focusable:"false",height:l,viewBox:"0 0 24 24",width:l},t)},h=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M23.5,0.499l-16.5,23l-6.5-6.5"}))},m=function(e){var t=e.children,n=e.testId,r=e.onClick,a=o.useContext(p).direction===exports.TextDirection.RightToLeft,i=n?{"data-testid":n}:{};return o.createElement("button",l({className:d({"rpv-core__primary-button":!0,"rpv-core__primary-button--rtl":a}),type:"button",onClick:r},i),t)},x=function(e){var t=e.size,n=void 0===t?"4rem":t,r=e.testId,a=o.useState(!1),i=a[0],c=a[1],s=r?{"data-testid":r}:{},u=g({onVisibilityChanged:function(e){c(e.isVisible)}});return o.createElement("div",l({},s,{className:d({"rpv-core__spinner":!0,"rpv-core__spinner--animating":i}),ref:u,style:{height:n,width:n}}))},w=function(e){var t=e.ariaLabel,n=void 0===t?"":t,r=e.autoFocus,a=void 0!==r&&r,i=e.placeholder,c=void 0===i?"":i,s=e.testId,u=e.type,g=void 0===u?"text":u,v=e.value,h=void 0===v?"":v,m=e.onChange,x=e.onKeyDown,w=void 0===x?function(){}:x,E=o.useContext(p).direction,b=o.useRef(),y=E===exports.TextDirection.RightToLeft,S={ref:b,"data-testid":"","aria-label":n,className:d({"rpv-core__textbox":!0,"rpv-core__textbox--rtl":y}),placeholder:c,value:h,onChange:function(e){return m(e.target.value)},onKeyDown:w};return s&&(S["data-testid"]=s),f((function(){if(a){var e=b.current;if(e){var t=window.scrollX,n=window.scrollY;e.focus(),window.scrollTo(t,n)}}}),[]),"text"===g?o.createElement("input",l({type:"text"},S)):o.createElement("input",l({type:"password"},S))};!function(e){e[e.ExitFullScreen=0]="ExitFullScreen",e[e.FullScreenChange=1]="FullScreenChange",e[e.FullScreenElement=2]="FullScreenElement",e[e.FullScreenEnabled=3]="FullScreenEnabled",e[e.RequestFullScreen=4]="RequestFullScreen"}(u||(u={}));var E,b={ExitFullScreen:"exitFullscreen",FullScreenChange:"fullscreenchange",FullScreenElement:"fullscreenElement",FullScreenEnabled:"fullscreenEnabled",RequestFullScreen:"requestFullscreen"},y={ExitFullScreen:"webkitExitFullscreen",FullScreenChange:"webkitfullscreenchange",FullScreenElement:"webkitFullscreenElement",FullScreenEnabled:"webkitFullscreenEnabled",RequestFullScreen:"webkitRequestFullscreen"},S={ExitFullScreen:"msExitFullscreen",FullScreenChange:"msFullscreenChange",FullScreenElement:"msFullscreenElement",FullScreenEnabled:"msFullscreenEnabled",RequestFullScreen:"msRequestFullscreen"},_="undefined"!=typeof window,P=_&&(u.FullScreenEnabled in document&&b||y.FullScreenEnabled in document&&y||S.FullScreenEnabled in document&&S)||b,R=function(){return _&&P.FullScreenEnabled in document&&!0===document[P.FullScreenEnabled]},M=function(e){return _?e[P.ExitFullScreen]():Promise.resolve({})},k=function(){return _?document[P.FullScreenElement]:null},C=function(e,t){var n=o.useRef(),r=function(){n.current&&clearTimeout(n.current)};return o.useEffect((function(){return function(){return r()}}),[]),o.useCallback((function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];r(),n.current=setTimeout((function(){e.apply(void 0,o)}),t)}),[e,t])},T=function(){var e=o.useRef(!1);return o.useEffect((function(){return e.current=!0,function(){e.current=!1}}),[]),e},L=function(e){var t=o.useRef(e);return o.useEffect((function(){t.current=e}),[e]),t.current};!function(e){e.NotRenderedYet="NotRenderedYet",e.Rendering="Rendering",e.Rendered="Rendered"}(E||(E={}));var O,F=-9999,D=function(e){var t=e.doc,n=t.numPages,r=t.loadingTask.docId,a=o.useMemo((function(){return Array(n).fill(null).map((function(e,t){return{pageIndex:t,renderStatus:E.NotRenderedYet,visibility:F}}))}),[r]),i=o.useRef({currentRenderingPage:-1,startRange:0,endRange:n-1,visibilities:a}),c=function(e,t){i.current.visibilities[e].visibility=t};return{getHighestPriorityPage:function(){var e=i.current.visibilities.slice(i.current.startRange,i.current.endRange+1).filter((function(e){return e.visibility>F}));if(!e.length)return-1;for(var t=e[0].pageIndex,r=e[e.length-1].pageIndex,o=e.length,a=0;a<o;a++){if(e[a].renderStatus===E.Rendering)return-1;if(e[a].renderStatus===E.NotRenderedYet)return e[a].pageIndex}return r+1<n&&i.current.visibilities[r+1].renderStatus!==E.Rendered?r+1:t-1>=0&&i.current.visibilities[t-1].renderStatus!==E.Rendered?t-1:-1},isInRange:function(e){return e>=i.current.startRange&&e<=i.current.endRange},markNotRendered:function(){for(var e=0;e<n;e++)i.current.visibilities[e].renderStatus=E.NotRenderedYet},markRendered:function(e){i.current.visibilities[e].renderStatus=E.Rendered},markRendering:function(e){-1!==i.current.currentRenderingPage&&i.current.currentRenderingPage!==e&&i.current.visibilities[i.current.currentRenderingPage].renderStatus===E.Rendering&&(i.current.visibilities[i.current.currentRenderingPage].renderStatus=E.NotRenderedYet),i.current.visibilities[e].renderStatus=E.Rendering,i.current.currentRenderingPage=e},setOutOfRange:function(e){c(e,F)},setRange:function(e,t){i.current.startRange=e,i.current.endRange=t;for(var r=0;r<n;r++)(r<e||r>t)&&(i.current.visibilities[r].visibility=F,i.current.visibilities[r].renderStatus=E.NotRenderedYet)},setVisibility:c}},I={core:{askingPassword:{requirePasswordToOpen:"This document requires a password to open",submit:"Submit"},wrongPassword:{tryAgain:"The password is wrong. Please try again"},pageLabel:"Page {{pageIndex}}"}},A=o.createContext({l10n:I,setL10n:function(){}}),H=0,N=function(){return H++},V=function(e,t,n){var r=function(e){var r=t.current;if(r){var o=e.target;if(o instanceof Element&&o.shadowRoot){var a=e.composedPath();a.length>0&&!r.contains(a[0])&&n()}else r.contains(o)||n()}};o.useEffect((function(){if(e){var t={capture:!0};return document.addEventListener("click",r,t),function(){document.removeEventListener("click",r,t)}}}),[])},z=function(e){var t=function(t){"Escape"===t.key&&e()};o.useEffect((function(){return document.addEventListener("keyup",t),function(){document.removeEventListener("keyup",t)}}),[])},B=function(e){var t=e.ariaControlsSuffix,n=e.children,r=e.closeOnClickOutside,a=e.closeOnEscape,i=e.onToggle,c=o.useRef(),s=o.useContext(p).direction===exports.TextDirection.RightToLeft;return o.useEffect((function(){var e=window.getComputedStyle(document.body).overflow;return document.body.style.overflow="hidden",function(){document.body.style.overflow=e}}),[]),z((function(){c.current&&a&&i()})),V(r,c,i),f((function(){var e=c.current;if(e){var t=.75*document.body.clientHeight;e.getBoundingClientRect().height>=t&&(e.style.overflow="auto",e.style.maxHeight="".concat(t,"px"))}}),[]),o.createElement("div",{"aria-modal":"true",className:d({"rpv-core__modal-body":!0,"rpv-core__modal-body--rtl":s}),id:"rpv-core__modal-body-".concat(t),ref:c,role:"dialog",tabIndex:-1},n)},W=function(e){var t=e.children;return o.createElement("div",{className:"rpv-core__modal-overlay"},t)};exports.ToggleStatus=void 0,(O=exports.ToggleStatus||(exports.ToggleStatus={})).Close="Close",O.Open="Open",O.Toggle="Toggle";var j,q=function(e){var t=o.useState(e),n=t[0],r=t[1];return{opened:n,toggle:function(e){switch(e){case exports.ToggleStatus.Close:r(!1);break;case exports.ToggleStatus.Open:r(!0);break;case exports.ToggleStatus.Toggle:default:r((function(e){return!e}))}}}},U=function(e){var t=e.content,n=e.isOpened,r=void 0!==n&&n,a=e.target,i=q(r),c=i.opened,s=i.toggle;return o.createElement(o.Fragment,null,a&&a(s,c),c&&t(s))};exports.Position=void 0,(j=exports.Position||(exports.Position={})).TopLeft="TOP_LEFT",j.TopCenter="TOP_CENTER",j.TopRight="TOP_RIGHT",j.RightTop="RIGHT_TOP",j.RightCenter="RIGHT_CENTER",j.RightBottom="RIGHT_BOTTOM",j.BottomLeft="BOTTOM_LEFT",j.BottomCenter="BOTTOM_CENTER",j.BottomRight="BOTTOM_RIGHT",j.LeftTop="LEFT_TOP",j.LeftCenter="LEFT_CENTER",j.LeftBottom="LEFT_BOTTOM";var Z,J,G,Y,K,X,Q,$,ee=function(e,t,n,r,o){f((function(){var a=t.current,i=e.current,c=n.current;if(i&&a&&c){var s=c.getBoundingClientRect(),l=function(e,t,n,r){var o=t.getBoundingClientRect(),a=e.getBoundingClientRect(),i=a.height,c=a.width,s=0,l=0;switch(n){case exports.Position.TopLeft:s=o.top-i,l=o.left;break;case exports.Position.TopCenter:s=o.top-i,l=o.left+o.width/2-c/2;break;case exports.Position.TopRight:s=o.top-i,l=o.left+o.width-c;break;case exports.Position.RightTop:s=o.top,l=o.left+o.width;break;case exports.Position.RightCenter:s=o.top+o.height/2-i/2,l=o.left+o.width;break;case exports.Position.RightBottom:s=o.top+o.height-i,l=o.left+o.width;break;case exports.Position.BottomLeft:s=o.top+o.height,l=o.left;break;case exports.Position.BottomCenter:s=o.top+o.height,l=o.left+o.width/2-c/2;break;case exports.Position.BottomRight:s=o.top+o.height,l=o.left+o.width-c;break;case exports.Position.LeftTop:s=o.top,l=o.left-c;break;case exports.Position.LeftCenter:s=o.top+o.height/2-i/2,l=o.left-c;break;case exports.Position.LeftBottom:s=o.top+o.height-i,l=o.left-c}return{left:l+(r.left||0),top:s+(r.top||0)}}(i,a,r,o),u=l.top,p=l.left;i.style.top="".concat(u-s.top,"px"),i.style.left="".concat(p-s.left,"px")}}),[])},te=function(e){var t,n=e.customClassName,r=e.position;return o.createElement("div",{className:d((t={"rpv-core__arrow":!0,"rpv-core__arrow--tl":r===exports.Position.TopLeft,"rpv-core__arrow--tc":r===exports.Position.TopCenter,"rpv-core__arrow--tr":r===exports.Position.TopRight,"rpv-core__arrow--rt":r===exports.Position.RightTop,"rpv-core__arrow--rc":r===exports.Position.RightCenter,"rpv-core__arrow--rb":r===exports.Position.RightBottom,"rpv-core__arrow--bl":r===exports.Position.BottomLeft,"rpv-core__arrow--bc":r===exports.Position.BottomCenter,"rpv-core__arrow--br":r===exports.Position.BottomRight,"rpv-core__arrow--lt":r===exports.Position.LeftTop,"rpv-core__arrow--lc":r===exports.Position.LeftCenter,"rpv-core__arrow--lb":r===exports.Position.LeftBottom},t["".concat(n)]=""!==n,t))})},ne=function(e){var t=e.ariaControlsSuffix,n=e.children,r=e.closeOnClickOutside,a=e.offset,i=e.position,c=e.targetRef,s=e.onClose,l=o.useRef(),u=o.useRef(),g=o.useRef(),v=o.useContext(p).direction===exports.TextDirection.RightToLeft;V(r,l,s),ee(l,c,g,i,a),f((function(){var e=u.current;if(e){var t=.75*document.body.clientHeight;e.getBoundingClientRect().height>=t&&(e.style.overflow="auto",e.style.maxHeight="".concat(t,"px"))}}),[]);var h="rpv-core__popover-body-inner-".concat(t);return o.createElement(o.Fragment,null,o.createElement("div",{ref:g,style:{left:0,position:"absolute",top:0}}),o.createElement("div",{"aria-describedby":h,className:d({"rpv-core__popover-body":!0,"rpv-core__popover-body--rtl":v}),id:"rpv-core__popover-body-".concat(t),ref:l,role:"dialog",tabIndex:-1},o.createElement(te,{customClassName:"rpv-core__popover-body-arrow",position:i}),o.createElement("div",{id:h,ref:u},n)))},re=function(e){var t=e.closeOnEscape,n=e.onClose,r=o.useRef();return z((function(){r.current&&t&&n()})),o.createElement("div",{className:"rpv-core__popover-overlay",ref:r})},oe=function(e){var t=e.ariaControlsSuffix,n=e.children,r=e.contentRef,a=e.offset,i=e.position,c=e.targetRef,s=o.useRef(),l=o.useContext(p).direction===exports.TextDirection.RightToLeft;return ee(r,c,s,i,a),o.createElement(o.Fragment,null,o.createElement("div",{ref:s,style:{left:0,position:"absolute",top:0}}),o.createElement("div",{className:d({"rpv-core__tooltip-body":!0,"rpv-core__tooltip-body--rtl":l}),id:"rpv-core__tooltip-body-".concat(t),ref:r,role:"tooltip"},o.createElement(te,{customClassName:"rpv-core__tooltip-body-arrow",position:i}),o.createElement("div",{className:"rpv-core__tooltip-body-content"},n)))};exports.FullScreenMode=void 0,(Z=exports.FullScreenMode||(exports.FullScreenMode={})).Normal="Normal",Z.Entering="Entering",Z.Entered="Entered",Z.EnteredCompletely="EnteredCompletely",Z.Exitting="Exitting",Z.Exited="Exited",exports.LayerRenderStatus=void 0,(J=exports.LayerRenderStatus||(exports.LayerRenderStatus={}))[J.PreRender=0]="PreRender",J[J.DidRender=1]="DidRender",exports.PageMode=void 0,(G=exports.PageMode||(exports.PageMode={})).Attachments="UseAttachments",G.Bookmarks="UseOutlines",G.ContentGroup="UseOC",G.Default="UserNone",G.FullScreen="FullScreen",G.Thumbnails="UseThumbs",exports.PasswordStatus=void 0,(Y=exports.PasswordStatus||(exports.PasswordStatus={})).RequiredPassword="RequiredPassword",Y.WrongPassword="WrongPassword",exports.RotateDirection=void 0,(K=exports.RotateDirection||(exports.RotateDirection={})).Backward="Backward",K.Forward="Forward",exports.ScrollMode=void 0,(X=exports.ScrollMode||(exports.ScrollMode={})).Page="Page",X.Horizontal="Horizontal",X.Vertical="Vertical",X.Wrapped="Wrapped",exports.SpecialZoomLevel=void 0,(Q=exports.SpecialZoomLevel||(exports.SpecialZoomLevel={})).ActualSize="ActualSize",Q.PageFit="PageFit",Q.PageWidth="PageWidth",exports.ViewMode=void 0,($=exports.ViewMode||(exports.ViewMode={})).DualPage="DualPage",$.DualPageWithCover="DualPageWithCover",$.SinglePage="SinglePage";var ae,ie=function(e,t){return e.reduce((function(e,n,r){return r%t?e[e.length-1].push(n):e.push([n]),e}),[])},ce=function(e,t){switch(t[1].name){case"XYZ":return{bottomOffset:function(e,n){return null===t[3]?n:t[3]},leftOffset:function(e,n){return null===t[2]?0:t[2]},pageIndex:e,scaleTo:t[4]};case"Fit":case"FitB":return{bottomOffset:0,leftOffset:0,pageIndex:e,scaleTo:exports.SpecialZoomLevel.PageFit};case"FitH":case"FitBH":return{bottomOffset:t[2],leftOffset:0,pageIndex:e,scaleTo:exports.SpecialZoomLevel.PageWidth};default:return{bottomOffset:0,leftOffset:0,pageIndex:e,scaleTo:1}}},se=new Map,le=new Map,ue=function(e,t){return"".concat(e.loadingTask.docId,"___").concat(t.num,"R").concat(0===t.gen?"":t.gen)},pe=function(e,t,n){se.set(ue(e,t),n)},de=function(e,t){if(!e)return Promise.reject("The document is not loaded yet");var n="".concat(e.loadingTask.docId,"___").concat(t),r=le.get(n);return r?Promise.resolve(r):new Promise((function(r,o){e.getPage(t+1).then((function(o){le.set(n,o),o.ref&&pe(e,o.ref,t),r(o)}))}))},fe=function(e,t){return new Promise((function(n){new Promise((function(n){"string"==typeof t?e.getDestination(t).then((function(e){n(e)})):n(t)})).then((function(r){if("object"==typeof r[0]&&null!==r[0]){var o=r[0],a=function(e,t){var n=ue(e,t);return se.has(n)?se.get(n):null}(e,o);null===a?e.getPageIndex(o).then((function(r){pe(e,o,r),fe(e,t).then((function(e){return n(e)}))})):n(ce(a,r))}else{var i=ce(r[0],r);n(i)}}))}))};!function(e){e[e.Solid=1]="Solid",e[e.Dashed=2]="Dashed",e[e.Beveled=3]="Beveled",e[e.Inset=4]="Inset",e[e.Underline=5]="Underline"}(ae||(ae={}));var ge,ve=new RegExp("^D:(\\d{4})(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?(\\d{2})?([Z|+|-])?(\\d{2})?'?(\\d{2})?'?"),he=function(e,t,n,r){var o=parseInt(e,10);return o>=t&&o<=n?o:r},me=function(e){return e.contentsObj?e.contentsObj.str:e.contents||""},xe=function(e){return e.titleObj?e.titleObj.str:e.title||""},we=function(e){var t=e.annotation,n=o.useContext(p).direction,r=xe(t),a=me(t),i=n===exports.TextDirection.RightToLeft,c=o.useRef(),s="";if(t.modificationDate){var l=function(e){var t=ve.exec(e);if(!t)return null;var n=parseInt(t[1],10),r=he(t[2],1,12,1)-1,o=he(t[3],1,31,1),a=he(t[4],0,23,0),i=he(t[5],0,59,0),c=he(t[6],0,59,0),s=t[7]||"Z",l=he(t[8],0,23,0),u=he(t[9],0,59,0);switch(s){case"-":a+=l,i+=u;break;case"+":a-=l,i-=u}return new Date(Date.UTC(n,r,o,a,i,c))}(t.modificationDate);s=l?"".concat(l.toLocaleDateString(),", ").concat(l.toLocaleTimeString()):""}return o.useLayoutEffect((function(){if(c.current){var e=document.querySelector('[data-annotation-id="'.concat(t.id,'"]'));if(e){var n=e;return n.style.zIndex+=1,function(){n.style.zIndex="".concat(parseInt(n.style.zIndex,10)-1)}}}}),[]),o.createElement("div",{ref:c,className:d({"rpv-core__annotation-popup-wrapper":!0,"rpv-core__annotation-popup-wrapper--rtl":i}),style:{top:t.annotationType===exports.AnnotationType.Popup?"":"100%"}},r&&o.createElement(o.Fragment,null,o.createElement("div",{className:d({"rpv-core__annotation-popup-title":!0,"rpv-core__annotation-popup-title--ltr":!i,"rpv-core__annotation-popup-title--rtl":i})},r),o.createElement("div",{className:"rpv-core__annotation-popup-date"},s)),a&&o.createElement("div",{className:"rpv-core__annotation-popup-content"},a.split("\n").map((function(e,t){return o.createElement(o.Fragment,{key:t},e,o.createElement("br",null))}))))};!function(e){e.Click="Click",e.Hover="Hover"}(ge||(ge={}));var Ee,be=function(e){var t,n=e.annotation,r=e.children,a=e.ignoreBorder,i=e.hasPopup,c=e.isRenderable,s=e.page,l=e.viewport,u=n.rect,p=function(){var e=q(!1),t=e.opened,n=e.toggle,r=o.useState(ge.Hover),a=r[0],i=r[1];return{opened:t,closeOnHover:function(){a===ge.Hover&&n(exports.ToggleStatus.Close)},openOnHover:function(){a===ge.Hover&&n(exports.ToggleStatus.Open)},toggleOnClick:function(){switch(a){case ge.Click:t&&i(ge.Hover),n(exports.ToggleStatus.Toggle);break;case ge.Hover:i(ge.Click),n(exports.ToggleStatus.Open)}}}}(),d=p.closeOnHover,f=p.opened,g=p.openOnHover,v=p.toggleOnClick,h=(t=[u[0],s.view[3]+s.view[1]-u[1],u[2],s.view[3]+s.view[1]-u[3]],[Math.min(t[0],t[2]),Math.min(t[1],t[3]),Math.max(t[0],t[2]),Math.max(t[1],t[3])]),m=u[2]-u[0],x=u[3]-u[1],w={borderColor:"",borderRadius:"",borderStyle:"",borderWidth:""};if(!a&&n.borderStyle.width>0){switch(n.borderStyle.style){case ae.Dashed:w.borderStyle="dashed";break;case ae.Solid:w.borderStyle="solid";break;case ae.Underline:w=Object.assign({borderBottomStyle:"solid"},w);case ae.Beveled:case ae.Inset:}var E=n.borderStyle.width;w.borderWidth="".concat(E,"px"),n.borderStyle.style!==ae.Underline&&(m-=2*E,x-=2*E);var b=n.borderStyle,y=b.horizontalCornerRadius,S=b.verticalCornerRadius;(y>0||S>0)&&(w.borderRadius="".concat(y,"px / ").concat(S,"px")),n.color?w.borderColor="rgb(".concat(0|n.color[0],", ").concat(0|n.color[1],", ").concat(0|n.color[2],")"):w.borderWidth="0"}return o.createElement(o.Fragment,null,c&&r({popup:{opened:f,closeOnHover:d,openOnHover:g,toggleOnClick:v},slot:{attrs:{style:Object.assign({height:"".concat(x,"px"),left:"".concat(h[0],"px"),top:"".concat(h[1],"px"),transform:"matrix(".concat(l.transform.join(","),")"),transformOrigin:"-".concat(h[0],"px -").concat(h[1],"px"),width:"".concat(m,"px")},w)},children:o.createElement(o.Fragment,null,i&&f&&o.createElement(we,{annotation:n}))}}))},ye=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--caret","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},Se=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--circle","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},o.createElement("circle",{cy:d/2,fill:"none",rx:p/2-f/2,ry:d/2-f/2,stroke:"transparent",strokeWidth:f||1})),e.slot.children)}))},_e=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=xe(t),i=me(t),c=!(!1!==t.hasPopup||!a&&!i),s=function(){var e,n,r,o,a=t.file;a&&(e=a.filename,n=a.content,r="string"==typeof n?"":URL.createObjectURL(new Blob([n],{type:""})),(o=document.createElement("a")).style.display="none",o.href=r||e,o.setAttribute("download",function(e){var t=e.split("/").pop();return t?t.split("#")[0].split("?")[0]:e}(e)),document.body.appendChild(o),o.click(),document.body.removeChild(o),r&&URL.revokeObjectURL(r))};return o.createElement(be,{annotation:t,hasPopup:c,ignoreBorder:!0,isRenderable:!0,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--file-attachment","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onDoubleClick:s,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},Pe=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--free-text","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},Re=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=xe(t),i=me(t),c=!(!a&&!i),s=!t.parentType||-1!==["Circle","Ink","Line","Polygon","PolyLine","Square"].indexOf(t.parentType);return f((function(){if(t.parentId){var e=document.querySelector('[data-annotation-id="'.concat(t.parentId,'"]')),n=document.querySelector('[data-annotation-id="'.concat(t.id,'"]'));if(e&&n){var r=parseFloat(e.style.left),o=parseFloat(e.style.top)+parseFloat(e.style.height);n.style.left="".concat(r,"px"),n.style.top="".concat(o,"px"),n.style.transformOrigin="-".concat(r,"px -").concat(o,"px")}}}),[]),o.createElement(be,{annotation:t,hasPopup:s,ignoreBorder:!1,isRenderable:c,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--popup","data-annotation-id":t.id}),o.createElement(we,{annotation:t}))}))},Me=function(e){var t=e.annotation,n=e.childAnnotation,r=e.page,a=e.viewport,i=!1===t.hasPopup,c=xe(t),s=me(t),u=!!(t.hasPopup||c||s);if(t.quadPoints&&t.quadPoints.length>0){var p=t.quadPoints.map((function(e){return Object.assign({},t,{rect:[e[2].x,e[2].y,e[1].x,e[1].y],quadPoints:[]})}));return o.createElement(o.Fragment,null,p.map((function(e,t){return o.createElement(Me,{key:t,annotation:e,childAnnotation:n,page:r,viewport:a})})))}return o.createElement(be,{annotation:t,hasPopup:i,ignoreBorder:!0,isRenderable:u,page:r,viewport:a},(function(e){return o.createElement(o.Fragment,null,o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--highlight","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children),n&&n.annotationType===exports.AnnotationType.Popup&&e.popup.opened&&o.createElement(Re,{annotation:n,page:r,viewport:a}))}))},ke=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--ink","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),t.inkLists&&t.inkLists.length&&o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},t.inkLists.map((function(e,t){return o.createElement("polyline",{key:t,fill:"none",stroke:"transparent",strokeWidth:f||1,points:e.map((function(e){return"".concat(e.x-u[0],",").concat(u[3]-e.y)})).join(" ")})}))),e.slot.children)}))},Ce=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--line","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},o.createElement("line",{stroke:"transparent",strokeWidth:f||1,x1:u[2]-t.lineCoordinates[0],x2:u[2]-t.lineCoordinates[2],y1:u[3]-t.lineCoordinates[1],y2:u[3]-t.lineCoordinates[3]})),e.slot.children)}))},Te=/^([^\w]*)(javascript|data|vbscript)/im,Le=/&#(\w+)(^\w|;)?/g,Oe=/[\u0000-\u001F\u007F-\u009F\u2000-\u200D\uFEFF]/gim,Fe=/^([^:]+):/gm,De=function(e,t){void 0===t&&(t="about:blank");var n,r=(n=e||"",n.replace(Le,(function(e,t){return String.fromCharCode(t)}))).replace(Oe,"").trim();if(!r)return t;var o=r[0];if("."===o||"/"===o)return r;var a=r.match(Fe);if(!a)return r;var i=a[0];return Te.test(i)?t:r},Ie=function(e){var t,n=e.annotation,r=e.annotationContainerRef,a=e.doc,i=e.outlines,c=e.page,s=e.pageIndex,u=e.scale,p=e.viewport,d=e.onExecuteNamedAction,f=e.onJumpFromLinkAnnotation,g=e.onJumpToDest,v=o.useRef(),h=i&&i.length&&n.dest&&"string"==typeof n.dest?null===(t=i.find((function(e){return e.dest===n.dest})))||void 0===t?void 0:t.title:"",m=!!(n.url||n.dest||n.action||n.unsafeUrl),x={};if(n.url||n.unsafeUrl){var w=De(n.url||n.unsafeUrl,"");w?x={"data-target":"external",href:w,rel:"noopener noreferrer nofollow",target:n.newWindow?"_blank":"",title:w}:m=!1}else x={href:"","data-annotation-link":n.id,onClick:function(e){e.preventDefault(),n.action?d(n.action):fe(a,n.dest).then((function(e){var t=v.current,n=r.current;if(t&&n){var o=t.getBoundingClientRect();n.style.setProperty("height","100%"),n.style.setProperty("width","100%");var a=n.getBoundingClientRect();n.style.removeProperty("height"),n.style.removeProperty("width");var i=(o.left-a.left)/u,c=(a.bottom-o.bottom+o.height)/u;f({bottomOffset:c,label:h,leftOffset:i,pageIndex:s})}g(e)}))}};return h&&(x=Object.assign({},x,{title:h,"aria-label":h})),o.createElement(be,{annotation:n,hasPopup:!1,ignoreBorder:!1,isRenderable:m,page:c,viewport:p},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--link","data-annotation-id":n.id,"data-testid":"core__annotation--link-".concat(n.id)}),o.createElement("a",l({ref:v},x)))}))},Ae=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--polygon","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),t.vertices&&t.vertices.length&&o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},o.createElement("polygon",{fill:"none",stroke:"transparent",strokeWidth:f||1,points:t.vertices.map((function(e){return"".concat(e.x-u[0],",").concat(u[3]-e.y)})).join(" ")})),e.slot.children)}))},He=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--polyline","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),t.vertices&&t.vertices.length&&o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},o.createElement("polyline",{fill:"none",stroke:"transparent",strokeWidth:f||1,points:t.vertices.map((function(e){return"".concat(e.x-u[0],",").concat(u[3]-e.y)})).join(" ")})),e.slot.children)}))},Ne=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c),u=t.rect,p=u[2]-u[0],d=u[3]-u[1],f=t.borderStyle.width;return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--square","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),o.createElement("svg",{height:"".concat(d,"px"),preserveAspectRatio:"none",version:"1.1",viewBox:"0 0 ".concat(p," ").concat(d),width:"".concat(p,"px")},o.createElement("rect",{height:d-f,fill:"none",stroke:"transparent",strokeWidth:f||1,x:f/2,y:f/2,width:p-f})),e.slot.children)}))},Ve=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--squiggly","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},ze=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--stamp","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},Be=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--strike-out","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},We=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M.5,16.5a1,1,0,0,0,1,1h2v4l4-4h15a1,1,0,0,0,1-1V3.5a1,1,0,0,0-1-1H1.5a1,1,0,0,0-1,1Z"}),o.createElement("path",{d:"M7.25,9.75A.25.25,0,1,1,7,10a.25.25,0,0,1,.25-.25"}),o.createElement("path",{d:"M12,9.75a.25.25,0,1,1-.25.25A.25.25,0,0,1,12,9.75"}),o.createElement("path",{d:"M16.75,9.75a.25.25,0,1,1-.25.25.25.25,0,0,1,.25-.25"}))},je=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M0.500 12.001 A11.500 11.500 0 1 0 23.500 12.001 A11.500 11.500 0 1 0 0.500 12.001 Z"}),o.createElement("path",{d:"M6.000 12.001 A6.000 6.000 0 1 0 18.000 12.001 A6.000 6.000 0 1 0 6.000 12.001 Z"}),o.createElement("path",{d:"M21.423 5.406L17.415 9.414"}),o.createElement("path",{d:"M14.587 6.585L18.607 2.565"}),o.createElement("path",{d:"M5.405 21.424L9.413 17.416"}),o.createElement("path",{d:"M6.585 14.588L2.577 18.596"}),o.createElement("path",{d:"M18.602 21.419L14.595 17.412"}),o.createElement("path",{d:"M17.419 14.58L21.428 18.589"}),o.createElement("path",{d:"M2.582 5.399L6.588 9.406"}),o.createElement("path",{d:"M9.421 6.581L5.412 2.572"}))},qe=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M4.000 18.500 A1.500 1.500 0 1 0 7.000 18.500 A1.500 1.500 0 1 0 4.000 18.500 Z"}),o.createElement("path",{d:"M20.5.5l-9.782,9.783a7,7,0,1,0,3,3L17,10h1.5V8.5L19,8h1.5V6.5L21,6h1.5V4.5l1-1V.5Z"}))},Ue=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M2.000 2.500 L22.000 2.500 L22.000 23.500 L2.000 23.500 Z"}),o.createElement("path",{d:"M6 4.5L6 0.5"}),o.createElement("path",{d:"M18 4.5L18 0.5"}),o.createElement("path",{d:"M10 4.5L10 0.5"}),o.createElement("path",{d:"M14 4.5L14 0.5"}))},Ze=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M17.5 0.498L17.5 23.498"}),o.createElement("path",{d:"M10.5 0.498L10.5 23.498"}),o.createElement("path",{d:"M23.5.5H6.5a6,6,0,0,0,0,12h4"}))},Je=function(){return o.createElement(v,{size:16},o.createElement("path",{d:"M2.5 22.995L12 6.005 21.5 22.995 2.5 22.995z"}))},Ge=function(e){var t=e.annotation,n=e.childAnnotation,r=e.page,a=e.viewport,i=!1===t.hasPopup,c=xe(t),s=me(t),u=!!(t.hasPopup||c||s),p=t.name?t.name.toLowerCase():"";return o.createElement(be,{annotation:t,hasPopup:i,ignoreBorder:!1,isRenderable:u,page:r,viewport:a},(function(e){return o.createElement(o.Fragment,null,o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--text","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),p&&o.createElement("div",{className:"rpv-core__annotation-text-icon"},"check"===p&&o.createElement(h,null),"comment"===p&&o.createElement(We,null),"help"===p&&o.createElement(je,null),"insert"===p&&o.createElement(Je,null),"key"===p&&o.createElement(qe,null),"note"===p&&o.createElement(Ue,null),("newparagraph"===p||"paragraph"===p)&&o.createElement(Ze,null)),e.slot.children),n&&n.annotationType===exports.AnnotationType.Popup&&e.popup.opened&&o.createElement(Re,{annotation:n,page:r,viewport:a}))}))},Ye=function(e){var t=e.annotation,n=e.page,r=e.viewport,a=!1===t.hasPopup,i=xe(t),c=me(t),s=!!(t.hasPopup||i||c);return o.createElement(be,{annotation:t,hasPopup:a,ignoreBorder:!0,isRenderable:s,page:n,viewport:r},(function(e){return o.createElement("div",l({},e.slot.attrs,{className:"rpv-core__annotation rpv-core__annotation--underline","data-annotation-id":t.id,onClick:e.popup.toggleOnClick,onMouseEnter:e.popup.openOnHover,onMouseLeave:e.popup.closeOnHover}),e.slot.children)}))},Ke=function(e){var t=e.annotations,n=e.doc,r=e.outlines,a=e.page,i=e.pageIndex,c=e.plugins,s=e.rotation,l=e.scale,u=e.onExecuteNamedAction,p=e.onJumpFromLinkAnnotation,d=e.onJumpToDest,g=o.useRef(),v=a.getViewport({rotation:s,scale:l}).clone({dontFlip:!0}),h=t.filter((function(e){return!e.parentId}));return f((function(){var e=g.current;e&&c.forEach((function(t){t.onAnnotationLayerRender&&t.onAnnotationLayerRender({annotations:h,container:e,pageIndex:i,rotation:s,scale:l})}))}),[]),o.createElement("div",{ref:g,className:"rpv-core__annotation-layer","data-testid":"core__annotation-layer-".concat(i)},h.map((function(e){var c=t.find((function(t){return t.parentId===e.id}));switch(e.annotationType){case exports.AnnotationType.Caret:return o.createElement(ye,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Circle:return o.createElement(Se,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.FileAttachment:return o.createElement(_e,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.FreeText:return o.createElement(Pe,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Highlight:return o.createElement(Me,{key:e.id,annotation:e,childAnnotation:c,page:a,viewport:v});case exports.AnnotationType.Ink:return o.createElement(ke,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Line:return o.createElement(Ce,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Link:return o.createElement(Ie,{key:e.id,annotation:e,annotationContainerRef:g,doc:n,outlines:r,page:a,pageIndex:i,scale:l,viewport:v,onExecuteNamedAction:u,onJumpFromLinkAnnotation:p,onJumpToDest:d});case exports.AnnotationType.Polygon:return o.createElement(Ae,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Polyline:return o.createElement(He,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Popup:return o.createElement(Re,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Square:return o.createElement(Ne,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Squiggly:return o.createElement(Ve,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Stamp:return o.createElement(ze,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.StrikeOut:return o.createElement(Be,{key:e.id,annotation:e,page:a,viewport:v});case exports.AnnotationType.Text:return o.createElement(Ge,{key:e.id,annotation:e,childAnnotation:c,page:a,viewport:v});case exports.AnnotationType.Underline:return o.createElement(Ye,{key:e.id,annotation:e,page:a,viewport:v});default:return o.createElement(o.Fragment,{key:e.id})}})))},Xe=function(e){var t=e.page,n=e.renderAnnotations,r=T(),a=o.useState({loading:!0,annotations:[]}),i=a[0],c=a[1];return o.useEffect((function(){t.getAnnotations({intent:"display"}).then((function(e){r.current&&c({loading:!1,annotations:e})}))}),[]),i.loading?o.createElement(o.Fragment,null):n(i.annotations)},Qe=function(e){var t=e.doc,n=e.outlines,r=e.page,a=e.pageIndex,i=e.plugins,c=e.rotation,s=e.scale,l=e.onExecuteNamedAction,u=e.onJumpFromLinkAnnotation,p=e.onJumpToDest;return o.createElement(Xe,{page:r,renderAnnotations:function(e){return o.createElement(Ke,{annotations:e,doc:t,outlines:n,page:r,pageIndex:a,plugins:i,rotation:c,scale:s,onExecuteNamedAction:l,onJumpFromLinkAnnotation:u,onJumpToDest:p})}})},$e=function(e,t){var n=e%t;return 0===n?e:Math.floor(e-n)},et=function(e){var t=e.canvasLayerRef,n=e.height,r=e.page,a=e.pageIndex,i=e.plugins,c=e.rotation,s=e.scale,l=e.width,u=e.onRenderCanvasCompleted,p=o.useRef();return f((function(){var e=p.current;e&&e.cancel();var n=t.current;n.removeAttribute("data-testid"),i.forEach((function(e){e.onCanvasLayerRender&&e.onCanvasLayerRender({ele:n,pageIndex:a,rotation:c,scale:s,status:exports.LayerRenderStatus.PreRender})}));var o=r.getViewport({rotation:c,scale:s}),l=window.devicePixelRatio||1,d=Math.sqrt(16777216/(o.width*o.height)),f=l>d;f?n.style.transform="scale(1, 1)":n.style.removeProperty("transform");var g=Math.min(d,l),v=function(e,t){var n,r;if(Math.floor(e)===e)return[e,1];var o=1/e;if(o>t)return[1,t];if(Math.floor(o)===o)return[1,o];for(var a=e>1?o:e,i=0,c=1,s=1,l=1;;){var u=i+s,p=c+l;if(p>t)break;a<=u/p?(s=(n=[u,p])[0],l=n[1]):(i=(r=[u,p])[0],c=r[1])}return a<(i/c+s/l)/2?a===e?[i,c]:[c,i]:a===e?[s,l]:[l,s]}(g,8),h=v[0],m=v[1];n.width=$e(o.width*g,h),n.height=$e(o.height*g,h),n.style.width="".concat($e(o.width,m),"px"),n.style.height="".concat($e(o.height,m),"px"),n.hidden=!0;var x=n.getContext("2d",{alpha:!1}),w=f||1!==l?[g,0,0,g,0,0]:null;return p.current=r.render({canvasContext:x,transform:w,viewport:o}),p.current.promise.then((function(){n.hidden=!1,n.setAttribute("data-testid","core__canvas-layer-".concat(a)),i.forEach((function(e){e.onCanvasLayerRender&&e.onCanvasLayerRender({ele:n,pageIndex:a,rotation:c,scale:s,status:exports.LayerRenderStatus.DidRender})})),u()}),(function(){u()})),function(){n&&(n.width=0,n.height=0)}}),[]),o.createElement("div",{className:"rpv-core__canvas-layer",style:{height:"".concat(n,"px"),width:"".concat(l,"px")}},o.createElement("canvas",{ref:t}))},tt=function(e){var t=e.height,n=e.page,r=e.rotation,i=e.scale,c=e.width,s=o.useRef();return f((function(){var e=s.current,o=n.getViewport({rotation:r,scale:i});n.getOperatorList().then((function(r){!function(){var e=s.current;e&&(e.innerHTML="")}(),new a.SVGGraphics(n.commonObjs,n.objs).getSVG(r,o).then((function(n){n.style.height="".concat(t,"px"),n.style.width="".concat(c,"px"),e.appendChild(n)}))}))}),[]),o.createElement("div",{className:"rpv-core__svg-layer",ref:s})},nt=function(e){var t=e.containerRef,n=e.page,r=e.pageIndex,i=e.plugins,c=e.rotation,s=e.scale,l=e.onRenderTextCompleted,u=o.useRef(),p=function(){var e=t.current;e&&([].slice.call(e.querySelectorAll(".rpv-core__text-layer-text")).forEach((function(t){return e.removeChild(t)})),[].slice.call(e.querySelectorAll('br[role="presentation"]')).forEach((function(t){return e.removeChild(t)})))};return f((function(){var e=u.current;e&&e.cancel();var o=t.current;if(o){o.removeAttribute("data-testid");var d=n.getViewport({rotation:c,scale:s});return i.forEach((function(e){e.onTextLayerRender&&e.onTextLayerRender({ele:o,pageIndex:r,scale:s,status:exports.LayerRenderStatus.PreRender})})),n.getTextContent().then((function(e){p(),u.current=a.renderTextLayer({container:o,textContent:e,textContentSource:e,viewport:d}),u.current.promise.then((function(){o.setAttribute("data-testid","core__text-layer-".concat(r)),[].slice.call(o.children).forEach((function(e){e.classList.contains("rpv-core__text-layer-text--not")||e.classList.add("rpv-core__text-layer-text")})),i.forEach((function(e){e.onTextLayerRender&&e.onTextLayerRender({ele:o,pageIndex:r,scale:s,status:exports.LayerRenderStatus.DidRender})})),l()}),(function(){o.removeAttribute("data-testid"),l()}))})),function(){var e;p(),null===(e=u.current)||void 0===e||e.cancel()}}}),[]),o.createElement("div",{className:"rpv-core__text-layer",ref:t})},rt=function(e){var t=e.doc,n=e.measureRef,r=e.outlines,a=e.pageIndex,i=e.pageRotation,c=e.pageSize,s=e.plugins,l=e.renderPage,u=e.renderQueueKey,p=e.rotation,f=e.scale,g=e.shouldRender,v=e.viewMode,h=e.onExecuteNamedAction,m=e.onJumpFromLinkAnnotation,w=e.onJumpToDest,E=e.onRenderCompleted,b=e.onRotatePage,y=T(),S=o.useState(null),_=S[0],P=S[1],R=o.useState(!1),M=R[0],k=R[1],C=o.useState(!1),L=C[0],O=C[1],F=o.useRef(),D=o.useRef(),I=Math.abs(p+i)%180==0,A=c.pageWidth*f,H=c.pageHeight*f,N=I?A:H,V=I?H:A,z=(c.rotation+p+i)%360,B=o.useRef(0),W=l||function(e){return o.createElement(o.Fragment,null,e.canvasLayer.children,e.textLayer.children,e.annotationLayer.children)};return o.useEffect((function(){P(null),k(!1),O(!1)}),[i,p,f]),o.useEffect((function(){g&&y.current&&!_&&de(t,a).then((function(e){y.current&&(B.current=u,P(e))}))}),[g,_]),o.useEffect((function(){M&&L&&(u!==B.current?(P(null),k(!1),O(!1)):E(a))}),[M,L]),o.createElement("div",{className:d({"rpv-core__page-layer":!0,"rpv-core__page-layer--dual":v===exports.ViewMode.DualPage,"rpv-core__page-layer--dual-cover":v===exports.ViewMode.DualPageWithCover,"rpv-core__page-layer--single":v===exports.ViewMode.SinglePage}),"data-testid":"core__page-layer-".concat(a),ref:n,style:{height:"".concat(V,"px"),width:"".concat(N,"px")}},_?o.createElement(o.Fragment,null,W({annotationLayer:{attrs:{},children:o.createElement(Qe,{doc:t,outlines:r,page:_,pageIndex:a,plugins:s,rotation:z,scale:f,onExecuteNamedAction:h,onJumpFromLinkAnnotation:m,onJumpToDest:w})},canvasLayer:{attrs:{},children:o.createElement(et,{canvasLayerRef:F,height:V,page:_,pageIndex:a,plugins:s,rotation:z,scale:f,width:N,onRenderCanvasCompleted:function(){y.current&&k(!0)}})},canvasLayerRendered:M,doc:t,height:V,pageIndex:a,rotation:z,scale:f,svgLayer:{attrs:{},children:o.createElement(tt,{height:V,page:_,rotation:z,scale:f,width:N})},textLayer:{attrs:{},children:o.createElement(nt,{containerRef:D,page:_,pageIndex:a,plugins:s,rotation:z,scale:f,onRenderTextCompleted:function(){y.current&&O(!0)}})},textLayerRendered:L,width:N,markRendered:E,onRotatePage:function(e){return b(a,e)}}),s.map((function(e,n){return e.renderPageLayer?o.createElement(o.Fragment,{key:n},e.renderPageLayer({canvasLayerRef:F,canvasLayerRendered:M,doc:t,height:V,pageIndex:a,rotation:z,scale:f,textLayerRef:D,textLayerRendered:L,width:N})):o.createElement(o.Fragment,{key:n})}))):o.createElement(x,{testId:"core__page-layer-loading-".concat(a)}))},ot=function(e,t){var n=t.rect;return e.height!==n.height||e.width!==n.width?n:e};!function(e){e.Horizontal="Horizontal",e.Vertical="Vertical",e.Both="Both"}(Ee||(Ee={}));var at=function(e){return 1-Math.pow(1-e,4)},it=1e-4,ct={left:0,top:0},st={capture:!1,passive:!0},lt=function(e){var t=e.elementRef,n=e.enableSmoothScroll,r=e.isRtl,a=e.scrollDirection,i=e.onSmoothScroll,c=o.useState(ct),s=c[0],l=c[1],u=o.useState(t.current),p=u[0],d=u[1],g=r?-1:1,v=o.useRef(a);v.current=a;var h=o.useRef(ct),m=o.useRef(!0),x=o.useCallback((function(){m.current=!0,n&&l(h.current),i(!1)}),[]),w=o.useCallback((function(){if(p){switch(v.current){case Ee.Horizontal:h.current={left:g*p.scrollLeft,top:0};break;case Ee.Both:h.current={left:g*p.scrollLeft,top:p.scrollTop};break;case Ee.Vertical:default:h.current={left:0,top:p.scrollTop}}n&&!m.current||l(h.current)}}),[p]);f((function(){d(t.current)})),f((function(){if(p)return p.addEventListener("scroll",w,st),function(){p.removeEventListener("scroll",w,st)}}),[p]);var E=o.useCallback((function(e,n){var r=t.current;if(!r)return Promise.resolve();var o={left:0,top:0};switch(v.current){case Ee.Horizontal:o.left=g*e.left;break;case Ee.Both:o.left=g*e.left,o.top=e.top;break;case Ee.Vertical:default:o.top=e.top}return n?(m.current=!1,i(!0),new Promise((function(e,t){!function(e,t,n,r,o,a){void 0===o&&(o=function(e){return e}),void 0===a&&(a=function(){});var i=0,c=0,s=!1;switch(t){case Ee.Horizontal:c=e.scrollLeft,i=0;case Ee.Both:c=e.scrollLeft,i=e.scrollTop;break;case Ee.Vertical:default:c=0,i=e.scrollTop}var l=function(){s||(s=!0,e.scrollLeft=n.left,e.scrollTop=n.top,a())};if(Math.abs(i-n.top)<=it&&t===Ee.Vertical)l();else if(Math.abs(c-n.left)<=it&&t===Ee.Horizontal)l();else{var u,p=-1,d=c-n.left,f=i-n.top,g=function(a){-1===p&&(p=a);var v=a-p,h=Math.min(v/r,1),m=o(h),x={left:c-d*m,top:i-f*m};switch(t){case Ee.Horizontal:e.scrollLeft=x.left;break;case Ee.Both:e.scrollLeft=x.left,e.scrollTop=x.top;break;case Ee.Vertical:default:e.scrollTop=x.top}Math.abs(x.top-n.top)<=it&&Math.abs(x.left-n.left)<=it&&!s&&(window.cancelAnimationFrame(u),l()),v<r?u=window.requestAnimationFrame(g):window.cancelAnimationFrame(u)};u=window.requestAnimationFrame(g)}}(r,v.current,o,400,at,(function(){x(),e()}))}))):new Promise((function(e,t){switch(v.current){case Ee.Horizontal:r.scrollLeft=o.left;break;case Ee.Both:r.scrollLeft=o.left,r.scrollTop=o.top;break;case Ee.Vertical:default:r.scrollTop=o.top}e()}))}),[t]);return{scrollOffset:s,scrollTo:E}},ut=function(e,t,n){return Math.max(e,Math.min(n,t))},pt=function(e,t){if(t!==exports.ViewMode.DualPageWithCover)return 0;if(!function(e){var t=e.length;if(1===t)return!1;for(var n=1;n<t;n++)if(e[n].height!==e[0].height||e[n].width!==e[0].width)return!0;return!1}(e))return 2*e[0].width;var n=ie(e.slice(1),2).map((function(e){return 2===e.length?e[0].width+e[1].width:e[0].width})),r=[e[0].width].concat(n);return Math.max.apply(Math,r)},dt={left:0,top:0},ft={left:0,top:0},gt={left:0,top:0},vt={left:0,top:0},ht={height:0,width:0},mt={left:0,top:0},xt="data-virtual-index",wt=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1],Et=function(e){var t=e.enableSmoothScroll,n=e.isRtl,r=e.numberOfItems,a=e.parentRef,i=e.setRenderRange,c=e.sizes,s=e.scrollMode,u=e.viewMode,p=o.useState(!1),d=p[0],g=p[1],v=o.useCallback((function(e){return g(e)}),[]),h=o.useRef(s);h.current=s;var m=o.useRef(u);m.current=u;var x=s===exports.ScrollMode.Wrapped||u===exports.ViewMode.DualPageWithCover||u===exports.ViewMode.DualPage?Ee.Both:s===exports.ScrollMode.Horizontal?Ee.Horizontal:Ee.Vertical,w=lt({elementRef:a,enableSmoothScroll:t,isRtl:n,scrollDirection:x,onSmoothScroll:v}),E=w.scrollOffset,b=w.scrollTo,y=function(e){var t=e.elementRef,n=o.useState(t.current),r=n[0],a=n[1],i=o.useRef(!1),c=o.useReducer(ot,{height:0,width:0}),s=c[0],l=c[1];return f((function(){t.current!==r&&a(t.current)})),f((function(){if(r&&!i.current){i.current=!0;var e=r.getBoundingClientRect