universalviewer
Version:
The Universal Viewer is a community-developed open source project on a mission to help you share your 📚📜📰📽️📻🗿 with the 🌎
74 lines • 359 kB
JavaScript
import{a as Yt}from"./chunk-3UUJB7QR.js";import{a as Vt}from"./chunk-CHPN5XCG.js";import{a as Wt}from"./chunk-33LGA2Y2.js";import{b as Lt,c as oi,d as he,e as si,f as Qt,g as ve,h as Ht}from"./chunk-CLWCACQD.js";import"./chunk-BYXBJQAS.js";import{b as Gt,c as We,d as Ce,e as Ft,g as nt,h as Ot,i as zt,j as Zt,k as jt}from"./chunk-K2YFIJ7N.js";import{a as Et,b as yt,c as it}from"./chunk-FEXGFX4C.js";import{a as E}from"./chunk-M4MN2QTO.js";import{a as Me,b as bt,c as ee,g as wt,h as Dt,i as Ke,j as xt,k as Pt,p as ie}from"./chunk-YB7AEQFU.js";import{a as kt,b as Ue,c as Nt,e as Ut,g as $e}from"./chunk-5XPHF4E5.js";import{c as Mt,d as fe}from"./chunk-L67DAW3A.js";var dt=Mt((_t,ct)=>{function L(t){return new L.Viewer(t)}(function(t){t.version={versionStr:"4.0.0",major:parseInt("4",10),minor:parseInt("0",10),revision:parseInt("0",10)};var i={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object"},e=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.isFunction=function(a){return t.type(a)==="function"},t.isArray=Array.isArray||function(a){return t.type(a)==="array"},t.isWindow=function(a){return a&&typeof a=="object"&&"setInterval"in a},t.type=function(a){return a==null?String(a):i[e.call(a)]||"object"},t.isPlainObject=function(a){if(!a||L.type(a)!=="object"||a.nodeType||t.isWindow(a)||a.constructor&&!o.call(a,"constructor")&&!o.call(a.constructor.prototype,"isPrototypeOf"))return!1;var n;for(var s in a)n=s;return n===void 0||o.call(a,n)},t.isEmptyObject=function(a){for(var n in a)return!1;return!0},t.freezeObject=function(a){return Object.freeze?t.freezeObject=Object.freeze:t.freezeObject=function(n){return n},t.freezeObject(a)},t.supportsCanvas=function(){var a=document.createElement("canvas");return!!(t.isFunction(a.getContext)&&a.getContext("2d"))}(),t.isCanvasTainted=function(a){var n=!1;try{a.getContext("2d").getImageData(0,0,1,1)}catch{n=!0}return n},t.supportsAddEventListener=function(){return!!(document.documentElement.addEventListener&&document.addEventListener)}(),t.supportsRemoveEventListener=function(){return!!(document.documentElement.removeEventListener&&document.removeEventListener)}(),t.supportsEventListenerOptions=function(){var a=0;if(t.supportsAddEventListener)try{var n={get capture(){return a++,!1},get once(){return a++,!1},get passive(){return a++,!1}};window.addEventListener("test",null,n),window.removeEventListener("test",null,n)}catch{a=0}return a>=3}(),t.getCurrentPixelDensityRatio=function(){if(t.supportsCanvas){var a=document.createElement("canvas").getContext("2d"),n=window.devicePixelRatio||1,s=a.webkitBackingStorePixelRatio||a.mozBackingStorePixelRatio||a.msBackingStorePixelRatio||a.oBackingStorePixelRatio||a.backingStorePixelRatio||1;return Math.max(n,1)/s}else return 1},t.pixelDensityRatio=t.getCurrentPixelDensityRatio()})(L);(function(t){t.extend=function(){var s,r,A,l,u,m,p=arguments[0]||{},w=arguments.length,b=!1,x=1;for(typeof p=="boolean"&&(b=p,p=arguments[1]||{},x=2),typeof p!="object"&&!L.isFunction(p)&&(p={}),w===x&&(p=this,--x);x<w;x++)if(s=arguments[x],s!==null||s!==void 0)for(r in s){var I=Object.getOwnPropertyDescriptor(s,r);if(I!==void 0){if(I.get||I.set){Object.defineProperty(p,r,I);continue}l=I.value}else{t.console.warn('Could not copy inherited property "'+r+'".');continue}p!==l&&(b&&l&&(L.isPlainObject(l)||(u=L.isArray(l)))?(A=p[r],u?(u=!1,m=A&&L.isArray(A)?A:[]):m=A&&L.isPlainObject(A)?A:{},p[r]=L.extend(b,m,l)):l!==void 0&&(p[r]=l))}return p};var i=function(){if(typeof navigator!="object")return!1;var s=navigator.userAgent;return typeof s!="string"?!1:s.indexOf("iPhone")!==-1||s.indexOf("iPad")!==-1||s.indexOf("iPod")!==-1};t.extend(t,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!1,panHorizontal:!0,panVertical:!0,constrainDuringPan:!1,wrapHorizontal:!1,wrapVertical:!1,visibilityRatio:.5,minPixelRatio:.5,defaultZoomLevel:0,minZoomLevel:null,maxZoomLevel:null,homeFillsViewer:!1,clickTimeThreshold:300,clickDistThreshold:5,dblClickTimeThreshold:300,dblClickDistThreshold:20,springStiffness:6.5,animationTime:1.2,gestureSettingsMouse:{dragToPan:!0,scrollToZoom:!0,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsTouch:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!0,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsPen:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!0,dblClickToZoom:!1,dblClickDragToZoom:!1,pinchToZoom:!1,zoomToRefPoint:!0,flickEnabled:!1,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},gestureSettingsUnknown:{dragToPan:!0,scrollToZoom:!1,clickToZoom:!1,dblClickToZoom:!0,dblClickDragToZoom:!1,pinchToZoom:!0,zoomToRefPoint:!0,flickEnabled:!0,flickMinSpeed:120,flickMomentum:.25,pinchRotate:!1},zoomPerClick:2,zoomPerScroll:1.2,zoomPerDblClickDrag:1.2,zoomPerSecond:1,blendTime:0,alwaysBlend:!1,autoHideControls:!0,immediateRender:!1,minZoomImageRatio:.9,maxZoomPixelRatio:1.1,smoothTileEdgesMinZoom:1.1,iOSDevice:i(),pixelsPerWheelLine:40,pixelsPerArrowPress:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaTime:50,rotationIncrement:90,showSequenceControl:!0,sequenceControlAnchor:null,preserveViewport:!1,preserveOverlays:!1,navPrevNextWrap:!1,showNavigationControl:!0,navigationControlAnchor:null,showZoomControl:!0,showHomeControl:!0,showFullPageControl:!0,showRotationControl:!1,showFlipControl:!1,controlsFadeDelay:2e3,controlsFadeLength:1500,mouseNavEnabled:!0,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoResize:!0,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,opacity:1,preload:!1,compositeOperation:null,imageSmoothingEnabled:!0,placeholderFillStyle:null,subPixelRoundingForTransparency:null,showReferenceStrip:!1,referenceStripScroll:"horizontal",referenceStripElement:null,referenceStripHeight:null,referenceStripWidth:null,referenceStripPosition:"BOTTOM_LEFT",referenceStripSizeRatio:.2,collectionRows:3,collectionColumns:0,collectionLayout:"horizontal",collectionMode:!1,collectionTileSize:800,collectionTileMargin:80,imageLoaderLimit:0,maxImageCacheCount:200,timeout:3e4,useCanvas:!0,prefixUrl:"/images/",navImages:{zoomIn:{REST:"zoomin_rest.png",GROUP:"zoomin_grouphover.png",HOVER:"zoomin_hover.png",DOWN:"zoomin_pressed.png"},zoomOut:{REST:"zoomout_rest.png",GROUP:"zoomout_grouphover.png",HOVER:"zoomout_hover.png",DOWN:"zoomout_pressed.png"},home:{REST:"home_rest.png",GROUP:"home_grouphover.png",HOVER:"home_hover.png",DOWN:"home_pressed.png"},fullpage:{REST:"fullpage_rest.png",GROUP:"fullpage_grouphover.png",HOVER:"fullpage_hover.png",DOWN:"fullpage_pressed.png"},rotateleft:{REST:"rotateleft_rest.png",GROUP:"rotateleft_grouphover.png",HOVER:"rotateleft_hover.png",DOWN:"rotateleft_pressed.png"},rotateright:{REST:"rotateright_rest.png",GROUP:"rotateright_grouphover.png",HOVER:"rotateright_hover.png",DOWN:"rotateright_pressed.png"},flip:{REST:"flip_rest.png",GROUP:"flip_grouphover.png",HOVER:"flip_hover.png",DOWN:"flip_pressed.png"},previous:{REST:"previous_rest.png",GROUP:"previous_grouphover.png",HOVER:"previous_hover.png",DOWN:"previous_pressed.png"},next:{REST:"next_rest.png",GROUP:"next_grouphover.png",HOVER:"next_hover.png",DOWN:"next_pressed.png"}},debugMode:!1,debugGridColor:["#437AB2","#1B9E77","#D95F02","#7570B3","#E7298A","#66A61E","#E6AB02","#A6761D","#666666"],silenceMultiImageWarnings:!1},SIGNAL:"----seadragon----",delegate:function(s,r){return function(){var A=arguments;return A===void 0&&(A=[]),r.apply(s,A)}},BROWSERS:{UNKNOWN:0,IE:1,FIREFOX:2,SAFARI:3,CHROME:4,OPERA:5,EDGE:6,CHROMEEDGE:7},SUBPIXEL_ROUNDING_OCCURRENCES:{NEVER:0,ONLY_AT_REST:1,ALWAYS:2},_viewers:new Map,getViewer:function(s){return t._viewers.get(this.getElement(s))},getElement:function(s){return typeof s=="string"&&(s=document.getElementById(s)),s},getElementPosition:function(s){var r=new t.Point,A,l;for(s=t.getElement(s),A=t.getElementStyle(s).position==="fixed",l=n(s,A);l;)r.x+=s.offsetLeft,r.y+=s.offsetTop,A&&(r=r.plus(t.getPageScroll())),s=l,A=t.getElementStyle(s).position==="fixed",l=n(s,A);return r},getElementOffset:function(s){s=t.getElement(s);var r=s&&s.ownerDocument,A,l,u={top:0,left:0};return r?(A=r.documentElement,typeof s.getBoundingClientRect<"u"&&(u=s.getBoundingClientRect()),l=r===r.window?r:r.nodeType===9?r.defaultView||r.parentWindow:!1,new t.Point(u.left+(l.pageXOffset||A.scrollLeft)-(A.clientLeft||0),u.top+(l.pageYOffset||A.scrollTop)-(A.clientTop||0))):new t.Point},getElementSize:function(s){return s=t.getElement(s),new t.Point(s.clientWidth,s.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(s){return s=t.getElement(s),s.currentStyle}:function(s){return s=t.getElement(s),window.getComputedStyle(s,"")},getCssPropertyWithVendorPrefix:function(s){var r={};return t.getCssPropertyWithVendorPrefix=function(A){if(r[A]!==void 0)return r[A];var l=document.createElement("div").style,u=null;if(l[A]!==void 0)u=A;else for(var m=["Webkit","Moz","MS","O","webkit","moz","ms","o"],p=t.capitalizeFirstLetter(A),w=0;w<m.length;w++){var b=m[w]+p;if(l[b]!==void 0){u=b;break}}return r[A]=u,u},t.getCssPropertyWithVendorPrefix(s)},capitalizeFirstLetter:function(s){return s.charAt(0).toUpperCase()+s.slice(1)},positiveModulo:function(s,r){var A=s%r;return A<0&&(A+=r),A},pointInElement:function(s,r){s=t.getElement(s);var A=t.getElementOffset(s),l=t.getElementSize(s);return r.x>=A.x&&r.x<A.x+l.x&&r.y<A.y+l.y&&r.y>=A.y},getMousePosition:function(s){if(typeof s.pageX=="number")t.getMousePosition=function(r){var A=new t.Point;return A.x=r.pageX,A.y=r.pageY,A};else if(typeof s.clientX=="number")t.getMousePosition=function(r){var A=new t.Point;return A.x=r.clientX+document.body.scrollLeft+document.documentElement.scrollLeft,A.y=r.clientY+document.body.scrollTop+document.documentElement.scrollTop,A};else throw new Error("Unknown event mouse position, no known technique.");return t.getMousePosition(s)},getPageScroll:function(){var s=document.documentElement||{},r=document.body||{};if(typeof window.pageXOffset=="number")t.getPageScroll=function(){return new t.Point(window.pageXOffset,window.pageYOffset)};else if(r.scrollLeft||r.scrollTop)t.getPageScroll=function(){return new t.Point(document.body.scrollLeft,document.body.scrollTop)};else if(s.scrollLeft||s.scrollTop)t.getPageScroll=function(){return new t.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)};else return new t.Point(0,0);return t.getPageScroll()},setPageScroll:function(s){if(typeof window.scrollTo<"u")t.setPageScroll=function(l){window.scrollTo(l.x,l.y)};else{var r=t.getPageScroll();if(r.x===s.x&&r.y===s.y)return;document.body.scrollLeft=s.x,document.body.scrollTop=s.y;var A=t.getPageScroll();if(A.x!==r.x&&A.y!==r.y){t.setPageScroll=function(l){document.body.scrollLeft=l.x,document.body.scrollTop=l.y};return}if(document.documentElement.scrollLeft=s.x,document.documentElement.scrollTop=s.y,A=t.getPageScroll(),A.x!==r.x&&A.y!==r.y){t.setPageScroll=function(l){document.documentElement.scrollLeft=l.x,document.documentElement.scrollTop=l.y};return}t.setPageScroll=function(l){}}t.setPageScroll(s)},getWindowSize:function(){var s=document.documentElement||{},r=document.body||{};if(typeof window.innerWidth=="number")t.getWindowSize=function(){return new t.Point(window.innerWidth,window.innerHeight)};else if(s.clientWidth||s.clientHeight)t.getWindowSize=function(){return new t.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else if(r.clientWidth||r.clientHeight)t.getWindowSize=function(){return new t.Point(document.body.clientWidth,document.body.clientHeight)};else throw new Error("Unknown window size, no known technique.");return t.getWindowSize()},makeCenteredNode:function(s){s=t.getElement(s);var r=[t.makeNeutralElement("div"),t.makeNeutralElement("div"),t.makeNeutralElement("div")];return t.extend(r[0].style,{display:"table",height:"100%",width:"100%"}),t.extend(r[1].style,{display:"table-row"}),t.extend(r[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"}),r[0].appendChild(r[1]),r[1].appendChild(r[2]),r[2].appendChild(s),r[0]},makeNeutralElement:function(s){var r=document.createElement(s),A=r.style;return A.background="transparent none",A.border="none",A.margin="0px",A.padding="0px",A.position="static",r},now:function(){return Date.now?t.now=Date.now:t.now=function(){return new Date().getTime()},t.now()},makeTransparentImage:function(s){var r=t.makeNeutralElement("img");return r.src=s,r},setElementOpacity:function(s,r,A){var l,u;s=t.getElement(s),A&&!t.Browser.alpha&&(r=Math.round(r)),t.Browser.opacity?s.style.opacity=r<1?r:"":r<1?(l=Math.round(100*r),u="alpha(opacity="+l+")",s.style.filter=u):s.style.filter=""},setElementTouchActionNone:function(s){s=t.getElement(s),typeof s.style.touchAction<"u"?s.style.touchAction="none":typeof s.style.msTouchAction<"u"&&(s.style.msTouchAction="none")},setElementPointerEvents:function(s,r){s=t.getElement(s),typeof s.style<"u"&&typeof s.style.pointerEvents<"u"&&(s.style.pointerEvents=r)},setElementPointerEventsNone:function(s){t.setElementPointerEvents(s,"none")},addClass:function(s,r){s=t.getElement(s),s.className?(" "+s.className+" ").indexOf(" "+r+" ")===-1&&(s.className+=" "+r):s.className=r},indexOf:function(s,r,A){return Array.prototype.indexOf?this.indexOf=function(l,u,m){return l.indexOf(u,m)}:this.indexOf=function(l,u,m){var p,w=m||0,b;if(!l)throw new TypeError;if(b=l.length,b===0||w>=b)return-1;for(w<0&&(w=b-Math.abs(w)),p=w;p<b;p++)if(l[p]===u)return p;return-1},this.indexOf(s,r,A)},removeClass:function(s,r){var A,l=[],u;for(s=t.getElement(s),A=s.className.split(/\s+/),u=0;u<A.length;u++)A[u]&&A[u]!==r&&l.push(A[u]);s.className=l.join(" ")},normalizeEventListenerOptions:function(s){var r;return typeof s<"u"?typeof s=="boolean"?r=t.supportsEventListenerOptions?{capture:s}:s:r=t.supportsEventListenerOptions?s:typeof s.capture<"u"?s.capture:!1:r=t.supportsEventListenerOptions?{capture:!1}:!1,r},addEvent:function(){if(t.supportsAddEventListener)return function(s,r,A,l){l=t.normalizeEventListenerOptions(l),s=t.getElement(s),s.addEventListener(r,A,l)};if(document.documentElement.attachEvent&&document.attachEvent)return function(s,r,A){s=t.getElement(s),s.attachEvent("on"+r,A)};throw new Error("No known event model.")}(),removeEvent:function(){if(t.supportsRemoveEventListener)return function(s,r,A,l){l=t.normalizeEventListenerOptions(l),s=t.getElement(s),s.removeEventListener(r,A,l)};if(document.documentElement.detachEvent&&document.detachEvent)return function(s,r,A){s=t.getElement(s),s.detachEvent("on"+r,A)};throw new Error("No known event model.")}(),cancelEvent:function(s){s.preventDefault()},eventIsCanceled:function(s){return s.defaultPrevented},stopEvent:function(s){s.stopPropagation()},createCallback:function(s,r){var A=[],l;for(l=2;l<arguments.length;l++)A.push(arguments[l]);return function(){var u=A.concat([]),m;for(m=0;m<arguments.length;m++)u.push(arguments[m]);return r.apply(s,u)}},getUrlParameter:function(s){var r=a[s];return r||null},getUrlProtocol:function(s){var r=s.match(/^([a-z]+:)\/\//i);return r===null?window.location.protocol:r[1].toLowerCase()},createAjaxRequest:function(s){var r;try{r=!!new ActiveXObject("Microsoft.XMLHTTP")}catch{r=!1}if(r)window.XMLHttpRequest?t.createAjaxRequest=function(A){return A?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest}:t.createAjaxRequest=function(){return new ActiveXObject("Microsoft.XMLHTTP")};else if(window.XMLHttpRequest)t.createAjaxRequest=function(){return new XMLHttpRequest};else throw new Error("Browser doesn't support XMLHttpRequest.");return t.createAjaxRequest(s)},makeAjaxRequest:function(s,r,A){var l,u,m,p;t.isPlainObject(s)&&(r=s.success,A=s.error,l=s.withCredentials,u=s.headers,m=s.responseType||null,p=s.postData||null,s=s.url);var w=t.getUrlProtocol(s),b=t.createAjaxRequest(w==="file:");if(!t.isFunction(r))throw new Error("makeAjaxRequest requires a success callback");b.onreadystatechange=function(){b.readyState===4&&(b.onreadystatechange=function(){},b.status>=200&&b.status<300||b.status===0&&w!=="http:"&&w!=="https:"?r(b):t.isFunction(A)?A(b):t.console.error("AJAX request returned %d: %s",b.status,s))};var x=p?"POST":"GET";try{if(b.open(x,s,!0),m&&(b.responseType=m),u)for(var I in u)Object.prototype.hasOwnProperty.call(u,I)&&u[I]&&b.setRequestHeader(I,u[I]);l&&(b.withCredentials=!0),b.send(p)}catch(T){t.console.error("%s while making AJAX request: %s",T.name,T.message),b.onreadystatechange=function(){},t.isFunction(A)&&A(b,T)}return b},jsonp:function(s){var r,A=s.url,l=document.head||document.getElementsByTagName("head")[0]||document.documentElement,u=s.callbackName||"openseadragon"+t.now(),m=window[u],p="$1"+u+"$2",w=s.param||"callback",b=s.callback;A=A.replace(/(=)\?(&|$)|\?\?/i,p),A+=(/\?/.test(A)?"&":"?")+w+"="+u,window[u]=function(x){if(m)window[u]=m;else try{delete window[u]}catch{}b&&t.isFunction(b)&&b(x)},r=document.createElement("script"),(s.async!==void 0||s.async!==!1)&&(r.async="async"),s.scriptCharset&&(r.charset=s.scriptCharset),r.src=A,r.onload=r.onreadystatechange=function(x,I){(I||!r.readyState||/loaded|complete/.test(r.readyState))&&(r.onload=r.onreadystatechange=null,l&&r.parentNode&&l.removeChild(r),r=void 0)},l.insertBefore(r,l.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(s){if(window.DOMParser)t.parseXml=function(r){var A=null,l;return l=new DOMParser,A=l.parseFromString(r,"text/xml"),A};else if(window.ActiveXObject)t.parseXml=function(r){var A=null;return A=new ActiveXObject("Microsoft.XMLDOM"),A.async=!1,A.loadXML(r),A};else throw new Error("Browser doesn't support XML DOM.");return t.parseXml(s)},parseJSON:function(s){return t.parseJSON=window.JSON.parse,t.parseJSON(s)},imageFormatSupported:function(s){return s=s||"",!!o[s.toLowerCase()]},setImageFormatsSupported:function(s){t.extend(o,s)}});var e=function(s){};t.console=window.console||{log:e,debug:e,info:e,warn:e,error:e,assert:e},t.Browser={vendor:t.BROWSERS.UNKNOWN,version:0,alpha:!0};var o={bmp:!1,jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1},a={};(function(){var s=navigator.appVersion,r=navigator.userAgent,A;switch(navigator.appName){case"Microsoft Internet Explorer":window.attachEvent&&window.ActiveXObject&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(r.substring(r.indexOf("MSIE")+5,r.indexOf(";",r.indexOf("MSIE")))));break;case"Netscape":window.addEventListener&&(r.indexOf("Edge")>=0?(t.Browser.vendor=t.BROWSERS.EDGE,t.Browser.version=parseFloat(r.substring(r.indexOf("Edge")+5))):r.indexOf("Edg")>=0?(t.Browser.vendor=t.BROWSERS.CHROMEEDGE,t.Browser.version=parseFloat(r.substring(r.indexOf("Edg")+4))):r.indexOf("Firefox")>=0?(t.Browser.vendor=t.BROWSERS.FIREFOX,t.Browser.version=parseFloat(r.substring(r.indexOf("Firefox")+8))):r.indexOf("Safari")>=0?(t.Browser.vendor=r.indexOf("Chrome")>=0?t.BROWSERS.CHROME:t.BROWSERS.SAFARI,t.Browser.version=parseFloat(r.substring(r.substring(0,r.indexOf("Safari")).lastIndexOf("/")+1,r.indexOf("Safari")))):(A=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})"),A.exec(r)!==null&&(t.Browser.vendor=t.BROWSERS.IE,t.Browser.version=parseFloat(RegExp.$1))));break;case"Opera":t.Browser.vendor=t.BROWSERS.OPERA,t.Browser.version=parseFloat(s);break}var l=window.location.search.substring(1),u=l.split("&"),m,p,w;for(w=0;w<u.length;w++)if(m=u[w],p=m.indexOf("="),p>0){var b=m.substring(0,p),x=m.substring(p+1);try{a[b]=decodeURIComponent(x)}catch{t.console.error("Ignoring malformed URL parameter: %s=%s",b,x)}}t.Browser.alpha=!(t.Browser.vendor===t.BROWSERS.CHROME&&t.Browser.version<2),t.Browser.opacity=!0,t.Browser.vendor===t.BROWSERS.IE&&t.Browser.version<11&&t.console.error("Internet Explorer versions < 11 are not supported by OpenSeadragon")})(),function(s){var r=s.requestAnimationFrame||s.mozRequestAnimationFrame||s.webkitRequestAnimationFrame||s.msRequestAnimationFrame,A=s.cancelAnimationFrame||s.mozCancelAnimationFrame||s.webkitCancelAnimationFrame||s.msCancelAnimationFrame;if(r&&A)t.requestAnimationFrame=function(){return r.apply(s,arguments)},t.cancelAnimationFrame=function(){return A.apply(s,arguments)};else{var l=[],u=[],m=0,p;t.requestAnimationFrame=function(w){return l.push([++m,w]),p||(p=setInterval(function(){if(l.length){var b=t.now(),x=u;for(u=l,l=x;u.length;)u.shift()[1](b)}else clearInterval(p),p=void 0},1e3/50)),m},t.cancelAnimationFrame=function(w){var b,x;for(b=0,x=l.length;b<x;b+=1)if(l[b][0]===w){l.splice(b,1);return}for(b=0,x=u.length;b<x;b+=1)if(u[b][0]===w){u.splice(b,1);return}}}}(window);function n(s,r){return r&&s!==document.body?document.body:s.offsetParent}})(L);(function(t,i){typeof define=="function"&&define.amd?define([],i):typeof ct=="object"&&ct.exports?ct.exports=i():t.OpenSeadragon=i()})(_t,function(){return L});(function(t){var i={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};document.exitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.fullscreenElement},i.requestFullScreen=function(e){return e.requestFullscreen()},i.exitFullScreen=function(){document.exitFullscreen()},i.fullScreenEventName="fullscreenchange",i.fullScreenErrorEventName="fullscreenerror"):document.msExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.msFullscreenElement},i.requestFullScreen=function(e){return e.msRequestFullscreen()},i.exitFullScreen=function(){document.msExitFullscreen()},i.fullScreenEventName="MSFullscreenChange",i.fullScreenErrorEventName="MSFullscreenError"):document.webkitExitFullscreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitFullscreenElement},i.requestFullScreen=function(e){return e.webkitRequestFullscreen()},i.exitFullScreen=function(){document.webkitExitFullscreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.webkitCancelFullScreen?(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement},i.requestFullScreen=function(e){return e.webkitRequestFullScreen()},i.exitFullScreen=function(){document.webkitCancelFullScreen()},i.fullScreenEventName="webkitfullscreenchange",i.fullScreenErrorEventName="webkitfullscreenerror"):document.mozCancelFullScreen&&(i.supportsFullScreen=!0,i.getFullScreenElement=function(){return document.mozFullScreenElement},i.requestFullScreen=function(e){return e.mozRequestFullScreen()},i.exitFullScreen=function(){document.mozCancelFullScreen()},i.fullScreenEventName="mozfullscreenchange",i.fullScreenErrorEventName="mozfullscreenerror"),i.isFullScreen=function(){return i.getFullScreenElement()!==null},i.cancelFullScreen=function(){t.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead."),i.exitFullScreen()},t.extend(t,i)})(L);(function(t){t.EventSource=function(){this.events={}},t.EventSource.prototype={addOnceHandler:function(i,e,o,a){var n=this;a=a||1;var s=0,r=function(A){s++,s===a&&n.removeHandler(i,r),e(A)};this.addHandler(i,r,o)},addHandler:function(i,e,o){var a=this.events[i];a||(this.events[i]=a=[]),e&&t.isFunction(e)&&(a[a.length]={handler:e,userData:o||null})},removeHandler:function(i,e){var o=this.events[i],a=[],n;if(o&&t.isArray(o)){for(n=0;n<o.length;n++)o[n].handler!==e&&a.push(o[n]);this.events[i]=a}},numberOfHandlers:function(i){var e=this.events[i];return e?e.length:0},removeAllHandlers:function(i){if(i)this.events[i]=[];else for(var e in this.events)this.events[e]=[]},getHandler:function(i){var e=this.events[i];return!e||!e.length?null:(e=e.length===1?[e[0]]:Array.apply(null,e),function(o,a){var n,s=e.length;for(n=0;n<s;n++)e[n]&&(a.eventSource=o,a.userData=e[n].userData,e[n].handler(a))})},raiseEvent:function(i,e){var o=this.getHandler(i);o&&(e||(e={}),o(this,e))}}})(L);(function(t){var i=[],e={};t.MouseTracker=function(d){i.push(this);var c=arguments;t.isPlainObject(d)||(d={element:c[0],clickTimeThreshold:c[1],clickDistThreshold:c[2]}),this.hash=Math.random(),this.element=t.getElement(d.element),this.clickTimeThreshold=d.clickTimeThreshold||t.DEFAULT_SETTINGS.clickTimeThreshold,this.clickDistThreshold=d.clickDistThreshold||t.DEFAULT_SETTINGS.clickDistThreshold,this.dblClickTimeThreshold=d.dblClickTimeThreshold||t.DEFAULT_SETTINGS.dblClickTimeThreshold,this.dblClickDistThreshold=d.dblClickDistThreshold||t.DEFAULT_SETTINGS.dblClickDistThreshold,this.userData=d.userData||null,this.stopDelay=d.stopDelay||50,this.preProcessEventHandler=d.preProcessEventHandler||null,this.contextMenuHandler=d.contextMenuHandler||null,this.enterHandler=d.enterHandler||null,this.leaveHandler=d.leaveHandler||null,this.exitHandler=d.exitHandler||null,this.overHandler=d.overHandler||null,this.outHandler=d.outHandler||null,this.pressHandler=d.pressHandler||null,this.nonPrimaryPressHandler=d.nonPrimaryPressHandler||null,this.releaseHandler=d.releaseHandler||null,this.nonPrimaryReleaseHandler=d.nonPrimaryReleaseHandler||null,this.moveHandler=d.moveHandler||null,this.scrollHandler=d.scrollHandler||null,this.clickHandler=d.clickHandler||null,this.dblClickHandler=d.dblClickHandler||null,this.dragHandler=d.dragHandler||null,this.dragEndHandler=d.dragEndHandler||null,this.pinchHandler=d.pinchHandler||null,this.stopHandler=d.stopHandler||null,this.keyDownHandler=d.keyDownHandler||null,this.keyUpHandler=d.keyUpHandler||null,this.keyHandler=d.keyHandler||null,this.focusHandler=d.focusHandler||null,this.blurHandler=d.blurHandler||null;var g=this;e[this.hash]={click:function(f){Z(g,f)},dblclick:function(f){Y(g,f)},keydown:function(f){W(g,f)},keyup:function(f){J(g,f)},keypress:function(f){V(g,f)},focus:function(f){_(g,f)},blur:function(f){ae(g,f)},contextmenu:function(f){oe(g,f)},wheel:function(f){re(g,f)},mousewheel:function(f){le(g,f)},DOMMouseScroll:function(f){le(g,f)},MozMousePixelScroll:function(f){le(g,f)},losecapture:function(f){Pe(g,f)},mouseenter:function(f){ke(g,f)},mouseleave:function(f){Ne(g,f)},mouseover:function(f){ce(g,f)},mouseout:function(f){Qe(g,f)},mousedown:function(f){ge(g,f)},mouseup:function(f){He(g,f)},mousemove:function(f){ze(g,f)},touchstart:function(f){pe(g,f)},touchend:function(f){Re(g,f)},touchmove:function(f){ye(g,f)},touchcancel:function(f){Be(g,f)},gesturestart:function(f){Ie(g,f)},gesturechange:function(f){j(g,f)},gotpointercapture:function(f){Le(g,f)},lostpointercapture:function(f){Xe(g,f)},pointerenter:function(f){ke(g,f)},pointerleave:function(f){Ne(g,f)},pointerover:function(f){ce(g,f)},pointerout:function(f){Qe(g,f)},pointerdown:function(f){ge(g,f)},pointerup:function(f){He(g,f)},pointermove:function(f){ze(g,f)},pointercancel:function(f){h(g,f)},pointerupcaptured:function(f){_e(g,f)},pointermovecaptured:function(f){qe(g,f)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1},this.hasGestureHandlers=!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler),this.hasScrollHandler=!!this.scrollHandler,t.MouseTracker.havePointerEvents&&t.setElementPointerEvents(this.element,"auto"),this.exitHandler&&t.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead."),d.startDisabled||this.setTracking(!0)},t.MouseTracker.prototype={destroy:function(){var d;for(r(this),this.element=null,d=0;d<i.length;d++)if(i[d]===this){i.splice(d,1);break}e[this.hash]=null,delete e[this.hash]},isTracking:function(){return e[this.hash].tracking},setTracking:function(d){return d?s(this):r(this),this},getActivePointersListByType:function(d){var c=e[this.hash],g,f=c.activePointersLists.length,R;for(g=0;g<f;g++)if(c.activePointersLists[g].type===d)return c.activePointersLists[g];return R=new t.MouseTracker.GesturePointList(d),c.activePointersLists.push(R),R},getActivePointerCount:function(){var d=e[this.hash],c,g=d.activePointersLists.length,f=0;for(c=0;c<g;c++)f+=d.activePointersLists[c].getLength();return f},preProcessEventHandler:function(){},contextMenuHandler:function(){},enterHandler:function(){},leaveHandler:function(){},exitHandler:function(){},overHandler:function(){},outHandler:function(){},pressHandler:function(){},nonPrimaryPressHandler:function(){},releaseHandler:function(){},nonPrimaryReleaseHandler:function(){},moveHandler:function(){},scrollHandler:function(){},clickHandler:function(){},dblClickHandler:function(){},dragHandler:function(){},dragEndHandler:function(){},pinchHandler:function(){},stopHandler:function(){},keyDownHandler:function(){},keyUpHandler:function(){},keyHandler:function(){},focusHandler:function(){},blurHandler:function(){}};var o=function(){try{return window.self!==window.top}catch{return!0}}();function a(d){try{return d.addEventListener&&d.removeEventListener}catch{return!1}}t.MouseTracker.gesturePointVelocityTracker=function(){var d=[],c=0,g=0,f=function(q,z){return q.hash.toString()+z.type+z.id.toString()},R=function(){var q,z=d.length,me,Ae,je=t.now(),Tt,St,Bt;for(Tt=je-g,g=je,q=0;q<z;q++)me=d[q],Ae=me.gPoint,Ae.direction=Math.atan2(Ae.currentPos.y-me.lastPos.y,Ae.currentPos.x-me.lastPos.x),St=me.lastPos.distanceTo(Ae.currentPos),me.lastPos=Ae.currentPos,Bt=1e3*St/(Tt+1),Ae.speed=.75*Bt+.25*Ae.speed},B=function(q,z){var me=f(q,z);d.push({guid:me,gPoint:z,lastPos:z.currentPos}),d.length===1&&(g=t.now(),c=window.setInterval(R,50))},Q=function(q,z){var me=f(q,z),Ae,je=d.length;for(Ae=0;Ae<je;Ae++)if(d[Ae].guid===me){d.splice(Ae,1),je--,je===0&&window.clearInterval(c);break}};return{addPoint:B,removePoint:Q}}(),t.MouseTracker.captureElement=document,t.MouseTracker.wheelEventName=t.Browser.vendor===t.BROWSERS.IE&&t.Browser.version>8||"onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll",t.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",t.MouseTracker.wheelEventName],t.MouseTracker.wheelEventName==="DOMMouseScroll"&&t.MouseTracker.subscribeEvents.push("MozMousePixelScroll"),window.PointerEvent?(t.MouseTracker.havePointerEvents=!0,t.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel"),t.MouseTracker.havePointerCapture=function(){var d=document.createElement("div");return t.isFunction(d.setPointerCapture)&&t.isFunction(d.releasePointerCapture)}(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")):(t.MouseTracker.havePointerEvents=!1,t.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove"),t.MouseTracker.mousePointerId="legacy-mouse",t.MouseTracker.havePointerCapture=function(){var d=document.createElement("div");return t.isFunction(d.setCapture)&&t.isFunction(d.releaseCapture)}(),t.MouseTracker.havePointerCapture&&t.MouseTracker.subscribeEvents.push("losecapture"),"ontouchstart"in window&&t.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel"),"ongesturestart"in window&&t.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")),t.MouseTracker.GesturePointList=function(d){this._gPoints=[],this.type=d,this.buttons=0,this.contacts=0,this.clicks=0,this.captureCount=0},t.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(d){return this._gPoints.push(d)},removeById:function(d){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].id===d){this._gPoints.splice(c,1);break}return this._gPoints.length},getByIndex:function(d){return d<this._gPoints.length?this._gPoints[d]:null},getById:function(d){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].id===d)return this._gPoints[c];return null},getPrimary:function(d){var c,g=this._gPoints.length;for(c=0;c<g;c++)if(this._gPoints[c].isPrimary)return this._gPoints[c];return null},addContact:function(){++this.contacts,this.contacts>1&&(this.type==="mouse"||this.type==="pen")&&(t.console.warn("GesturePointList.addContact() Implausible contacts value"),this.contacts=1)},removeContact:function(){--this.contacts,this.contacts<0&&(this.contacts=0)}};function n(d){var c=e[d.hash],g,f,R,B,Q,q=c.activePointersLists.length;for(g=0;g<q;g++)if(R=c.activePointersLists[g],R.getLength()>0){for(Q=[],B=R.asArray(),f=0;f<B.length;f++)Q.push(B[f]);for(f=0;f<Q.length;f++)y(d,R,Q[f])}for(g=0;g<q;g++)c.activePointersLists.pop();c.sentDragEvent=!1}function s(d){var c=e[d.hash],g,f;if(!c.tracking){for(f=0;f<t.MouseTracker.subscribeEvents.length;f++)g=t.MouseTracker.subscribeEvents[f],t.addEvent(d.element,g,c[g],g===t.MouseTracker.wheelEventName?{passive:!1,capture:!1}:!1);n(d),c.tracking=!0}}function r(d){var c=e[d.hash],g,f;if(c.tracking){for(f=0;f<t.MouseTracker.subscribeEvents.length;f++)g=t.MouseTracker.subscribeEvents[f],t.removeEvent(d.element,g,c[g],!1);n(d),c.tracking=!1}}function A(d,c){var g=e[d.hash];if(c==="pointerevent")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(c==="mouse")return{upName:"pointerup",upHandler:g.pointerupcaptured,moveName:"pointermove",moveHandler:g.pointermovecaptured};if(c==="touch")return{upName:"touchend",upHandler:g.touchendcaptured,moveName:"touchmove",moveHandler:g.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function l(d,c){var g;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents)try{d.element.setPointerCapture(c.id)}catch{t.console.warn("setPointerCapture() called on invalid pointer ID");return}else d.element.setCapture(!0);else g=A(d,t.MouseTracker.havePointerEvents?"pointerevent":c.type),o&&a(window.top)&&t.addEvent(window.top,g.upName,g.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,g.upName,g.upHandler,!0),t.addEvent(t.MouseTracker.captureElement,g.moveName,g.moveHandler,!0);U(d,c,!0)}function u(d,c){var g,f,R;if(t.MouseTracker.havePointerCapture)if(t.MouseTracker.havePointerEvents){if(f=d.getActivePointersListByType(c.type),R=f.getById(c.id),!R||!R.captured)return;try{d.element.releasePointerCapture(c.id)}catch{}}else d.element.releaseCapture();else g=A(d,t.MouseTracker.havePointerEvents?"pointerevent":c.type),o&&a(window.top)&&t.removeEvent(window.top,g.upName,g.upHandler,!0),t.removeEvent(t.MouseTracker.captureElement,g.moveName,g.moveHandler,!0),t.removeEvent(t.MouseTracker.captureElement,g.upName,g.upHandler,!0);U(d,c,!1)}function m(d){return t.MouseTracker.havePointerEvents?d.pointerId:t.MouseTracker.mousePointerId}function p(d){return t.MouseTracker.havePointerEvents?d.pointerType||(t.Browser.vendor===t.BROWSERS.IE?"mouse":""):"mouse"}function w(d){return t.MouseTracker.havePointerEvents?d.isPrimary:!0}function b(d){return t.getMousePosition(d)}function x(d,c){return I(b(d),c)}function I(d,c){var g=t.getElementOffset(c);return d.minus(g)}function T(d,c){return new t.Point((d.x+c.x)/2,(d.y+c.y)/2)}function Z(d,c){var g={originalEvent:c,eventType:"click",pointerType:"mouse",isEmulated:!1};C(d,g),g.preventDefault&&!g.defaultPrevented&&t.cancelEvent(c),g.stopPropagation&&t.stopEvent(c)}function Y(d,c){var g={originalEvent:c,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};C(d,g),g.preventDefault&&!g.defaultPrevented&&t.cancelEvent(c),g.stopPropagation&&t.stopEvent(c)}function W(d,c){var g=null,f={originalEvent:c,eventType:"keydown",pointerType:"",isEmulated:!1};C(d,f),d.keyDownHandler&&!f.preventGesture&&!f.defaultPrevented&&(g={eventSource:d,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:f.preventDefault||f.defaultPrevented,userData:d.userData},d.keyDownHandler(g)),(g&&g.preventDefault||f.preventDefault&&!f.defaultPrevented)&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function J(d,c){var g=null,f={originalEvent:c,eventType:"keyup",pointerType:"",isEmulated:!1};C(d,f),d.keyUpHandler&&!f.preventGesture&&!f.defaultPrevented&&(g={eventSource:d,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:f.preventDefault||f.defaultPrevented,userData:d.userData},d.keyUpHandler(g)),(g&&g.preventDefault||f.preventDefault&&!f.defaultPrevented)&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function V(d,c){var g=null,f={originalEvent:c,eventType:"keypress",pointerType:"",isEmulated:!1};C(d,f),d.keyHandler&&!f.preventGesture&&!f.defaultPrevented&&(g={eventSource:d,keyCode:c.keyCode?c.keyCode:c.charCode,ctrl:c.ctrlKey,shift:c.shiftKey,alt:c.altKey,meta:c.metaKey,originalEvent:c,preventDefault:f.preventDefault||f.defaultPrevented,userData:d.userData},d.keyHandler(g)),(g&&g.preventDefault||f.preventDefault&&!f.defaultPrevented)&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function _(d,c){var g={originalEvent:c,eventType:"focus",pointerType:"",isEmulated:!1};C(d,g),d.focusHandler&&!g.preventGesture&&d.focusHandler({eventSource:d,originalEvent:c,userData:d.userData})}function ae(d,c){var g={originalEvent:c,eventType:"blur",pointerType:"",isEmulated:!1};C(d,g),d.blurHandler&&!g.preventGesture&&d.blurHandler({eventSource:d,originalEvent:c,userData:d.userData})}function oe(d,c){var g=null,f={originalEvent:c,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};C(d,f),d.contextMenuHandler&&!f.preventGesture&&!f.defaultPrevented&&(g={eventSource:d,position:I(b(c),d.element),originalEvent:f.originalEvent,preventDefault:f.preventDefault||f.defaultPrevented,userData:d.userData},d.contextMenuHandler(g)),(g&&g.preventDefault||f.preventDefault&&!f.defaultPrevented)&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function re(d,c){Ee(d,c,c)}function le(d,c){var g={target:c.target||c.srcElement,type:"wheel",shiftKey:c.shiftKey||!1,clientX:c.clientX,clientY:c.clientY,pageX:c.pageX?c.pageX:c.clientX,pageY:c.pageY?c.pageY:c.clientY,deltaMode:c.type==="MozMousePixelScroll"?0:1,deltaX:0,deltaZ:0};t.MouseTracker.wheelEventName==="mousewheel"?g.deltaY=-c.wheelDelta/t.DEFAULT_SETTINGS.pixelsPerWheelLine:g.deltaY=c.detail,Ee(d,g,c)}function Ee(d,c,g){var f=0,R,B=null;f=c.deltaY<0?1:-1,R={originalEvent:c,eventType:"wheel",pointerType:"mouse",isEmulated:c!==g},C(d,R),d.scrollHandler&&!R.preventGesture&&!R.defaultPrevented&&(B={eventSource:d,pointerType:"mouse",position:x(c,d.element),scroll:f,shift:c.shiftKey,isTouchEvent:!1,originalEvent:g,preventDefault:R.preventDefault||R.defaultPrevented,userData:d.userData},d.scrollHandler(B)),R.stopPropagation&&t.stopEvent(g),(B&&B.preventDefault||R.preventDefault&&!R.defaultPrevented)&&t.cancelEvent(g)}function Pe(d,c){var g={id:t.MouseTracker.mousePointerId,type:"mouse"},f={originalEvent:c,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};C(d,f),c.target===d.element&&U(d,g,!1),f.stopPropagation&&t.stopEvent(c)}function pe(d,c){var g,f,R=c.changedTouches.length,B,Q=d.getActivePointersListByType("touch");g=t.now(),Q.getLength()>c.touches.length-R&&t.console.warn("Tracked touch contact count doesn't match event.touches.length");var q={originalEvent:c,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};for(C(d,q),f=0;f<R;f++)B={id:c.changedTouches[f].identifier,type:"touch",isPrimary:Q.getLength()===0,currentPos:b(c.changedTouches[f]),currentTime:g},N(d,q,B),S(d,q,B,0),U(d,B,!0);q.preventDefault&&!q.defaultPrevented&&t.cancelEvent(c),q.stopPropagation&&t.stopEvent(c)}function Re(d,c){var g,f,R=c.changedTouches.length,B;g=t.now();var Q={originalEvent:c,eventType:"pointerup",pointerType:"touch",isEmulated:!1};for(C(d,Q),f=0;f<R;f++)B={id:c.changedTouches[f].identifier,type:"touch",currentPos:b(c.changedTouches[f]),currentTime:g},F(d,Q,B,0),U(d,B,!1),X(d,Q,B);Q.preventDefault&&!Q.defaultPrevented&&t.cancelEvent(c),Q.stopPropagation&&t.stopEvent(c)}function ye(d,c){var g,f,R=c.changedTouches.length,B;g=t.now();var Q={originalEvent:c,eventType:"pointermove",pointerType:"touch",isEmulated:!1};for(C(d,Q),f=0;f<R;f++)B={id:c.changedTouches[f].identifier,type:"touch",currentPos:b(c.changedTouches[f]),currentTime:g},O(d,Q,B);Q.preventDefault&&!Q.defaultPrevented&&t.cancelEvent(c),Q.stopPropagation&&t.stopEvent(c)}function Be(d,c){var g=c.changedTouches.length,f,R,B={originalEvent:c,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};for(C(d,B),f=0;f<g;f++)R={id:c.changedTouches[f].identifier,type:"touch"},K(d,B,R);B.stopPropagation&&t.stopEvent(c)}function Ie(d,c){return t.eventIsCanceled(c)||c.preventDefault(),!1}function j(d,c){return t.eventIsCanceled(c)||c.preventDefault(),!1}function Le(d,c){var g={originalEvent:c,eventType:"gotpointercapture",pointerType:p(c),isEmulated:!1};C(d,g),c.target===d.element&&U(d,{id:c.pointerId,type:p(c)},!0),g.stopPropagation&&t.stopEvent(c)}function Xe(d,c){var g={originalEvent:c,eventType:"lostpointercapture",pointerType:p(c),isEmulated:!1};C(d,g),c.target===d.element&&U(d,{id:c.pointerId,type:p(c)},!1),g.stopPropagation&&t.stopEvent(c)}function ke(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f={originalEvent:c,eventType:"pointerenter",pointerType:g.type,isEmulated:!1};C(d,f),N(d,f,g)}function Ne(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f={originalEvent:c,eventType:"pointerleave",pointerType:g.type,isEmulated:!1};C(d,f),X(d,f,g)}function ce(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f={originalEvent:c,eventType:"pointerover",pointerType:g.type,isEmulated:!1};C(d,f),k(d,f,g),f.preventDefault&&!f.defaultPrevented&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function Qe(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f={originalEvent:c,eventType:"pointerout",pointerType:g.type,isEmulated:!1};C(d,f),D(d,f,g),f.preventDefault&&!f.defaultPrevented&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function ge(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f=t.MouseTracker.havePointerEvents&&g.type==="touch"&&t.Browser.vendor!==t.BROWSERS.IE,R={originalEvent:c,eventType:"pointerdown",pointerType:g.type,isEmulated:!1};C(d,R),S(d,R,g,c.button),R.preventDefault&&!R.defaultPrevented&&t.cancelEvent(c),R.stopPropagation&&t.stopEvent(c),R.shouldCapture&&(f?U(d,g,!0):l(d,g))}function He(d,c){Oe(d,c)}function _e(d,c){var g=d.getActivePointersListByType(p(c));g.getById(c.pointerId)&&Oe(d,c),t.stopEvent(c)}function Oe(d,c){var g;g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()};var f={originalEvent:c,eventType:"pointerup",pointerType:g.type,isEmulated:!1};C(d,f),F(d,f,g,c.button),f.preventDefault&&!f.defaultPrevented&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c),f.shouldReleaseCapture&&(c.target===d.element?u(d,g):U(d,g,!1))}function ze(d,c){Ze(d,c)}function qe(d,c){var g=d.getActivePointersListByType(p(c));g.getById(c.pointerId)&&Ze(d,c),t.stopEvent(c)}function Ze(d,c){var g={id:m(c),type:p(c),isPrimary:w(c),currentPos:b(c),currentTime:t.now()},f={originalEvent:c,eventType:"pointermove",pointerType:g.type,isEmulated:!1};C(d,f),O(d,f,g),f.preventDefault&&!f.defaultPrevented&&t.cancelEvent(c),f.stopPropagation&&t.stopEvent(c)}function h(d,c){var g={id:c.pointerId,type:p(c)},f={originalEvent:c,eventType:"pointercancel",pointerType:g.type,isEmulated:!1};C(d,f),K(d,f,g),f.stopPropagation&&t.stopEvent(c)}function v(d,c){return c.speed=0,c.direction=0,c.contactPos=c.currentPos,c.contactTime=c.currentTime,c.lastPos=c.currentPos,c.lastTime=c.currentTime,d.add(c)}function y(d,c,g){var f,R=c.getById(g.id);return R?(R.captured&&(t.console.warn("stopTrackingPointer() called on captured pointer"),u(d,R)),c.removeContact(),f=c.removeById(g.id)):f=c.getLength(),f}function M(d,c){switch(c.eventType){case"pointermove":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!d.hasGestureHandlers,c.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break;case"pointerdown":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!d.hasGestureHandlers,c.stopPropagation=!1;break;case"pointerup":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!d.hasGestureHandlers,c.stopPropagation=!1;break;case"wheel":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!1,c.preventGesture=!d.hasScrollHandler,c.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":c.isStoppable=!0,c.isCancelable=!1,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break;case"click":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!!d.clickHandler,c.preventGesture=!1,c.stopPropagation=!1;break;case"dblclick":c.isStoppable=!0,c.isCancelable=!0,c.preventDefault=!!d.dblClickHandler,c.preventGesture=!1,c.stopPropagation=!1;break;case"focus":case"blur":case"pointerenter":case"pointerleave":default:c.isStoppable=!1,c.isCancelable=!1,c.preventDefault=!1,c.preventGesture=!1,c.stopPropagation=!1;break}}function C(d,c){c.eventSource=d,c.eventPhase=c.originalEvent&&typeof c.originalEvent.eventPhase<"u"?c.originalEvent.eventPhase:0,c.defaultPrevented=t.eventIsCanceled(c.originalEvent),c.shouldCapture=!1,c.shouldReleaseCapture=!1,c.userData=d.userData,M(d,c),d.preProcessEventHandler&&d.preProcessEventHandler(c)}function U(d,c,g){var f=d.getActivePointersListByType(c.type),R=f.getById(c.id);R?g&&!R.captured?(R.captured=!0,f.captureCount++):!g&&R.captured&&(R.captured=!1,f.captureCount--,f.captureCount<0&&(f.captureCount=0,t.console.warn("updatePointerCaptured() - pointsList.captureCount went negative"))):t.console.warn("updatePointerCaptured() called on untracked pointer")}function N(d,c,g){var f=d.getActivePointersListByType(g.type),R;R=f.getById(g.id),R?(R.insideElement=!0,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=g.currentPos,R.currentTime=g.currentTime,g=R):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,v(f,g)),d.enterHandler&&d.enterHandler({eventSource:d,pointerType:g.type,position:I(g.currentPos,d.element),buttons:f.buttons,pointers:d.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:f.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData})}function X(d,c,g){var f=d.getActivePointersListByType(g.type),R,B;R=f.getById(g.id),R?(R.captured?(R.insideElement=!1,R.lastPos=R.currentPos,R.lastTime=R.currentTime,R.currentPos=g.currentPos,R.currentTime=g.currentTime):y(d,f,R),g=R):(g.captured=!1,g.insideElementPressed=!1),(d.leaveHandler||d.exitHandler)&&(B={eventSource:d,pointerType:g.type,position:g.currentPos&&I(g.currentPos,d.element),buttons:f.buttons,pointers:d.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:f.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData},d.leaveHandler&&d.leaveHandler(B),d.exitHandler&&d.exitHandler(B))}function k(d,c,g){var f,R;f=d.getActivePointersListByType(g.type),R=f.getById(g.id),R?g=R:(g.captured=!1,g.insideElementPressed=!1),d.overHandler&&d.overHandler({eventSource:d,pointerType:g.type,position:I(g.currentPos,d.element),buttons:f.buttons,pointers:d.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:f.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData})}function D(d,c,g){var f,R;f=d.getActivePointersListByType(g.type),R=f.getById(g.id),R?g=R:(g.captured=!1,g.insideElementPressed=!1),d.outHandler&&d.outHandler({eventSource:d,pointerType:g.type,position:g.currentPos&&I(g.currentPos,d.element),buttons:f.buttons,pointers:d.getActivePointerCount(),insideElementPressed:g.insideElementPressed,buttonDownAny:f.buttons!==0,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData})}function S(d,c,g,f){var R=e[d.hash],B=d.getActivePointersListByType(g.type),Q;if(typeof c.originalEvent.buttons<"u"?B.buttons=c.originalEvent.buttons:f===0?B.buttons|=1:f===1?B.buttons|=4:f===2?B.buttons|=2:f===3?B.buttons|=8:f===4?B.buttons|=16:f===5&&(B.buttons|=32),f!==0){c.shouldCapture=!1,c.shouldReleaseCapture=!1,d.nonPrimaryPressHandler&&!c.preventGesture&&!c.defaultPrevented&&(c.preventDefault=!0,d.nonPrimaryPressHandler({eventSource:d,pointerType:g.type,position:I(g.currentPos,d.element),button:f,buttons:B.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData}));return}Q=B.getById(g.id),Q?(Q.insideElementPressed=!0,Q.insideElement=!0,Q.originalTarget=c.originalEvent.target,Q.contactPos=g.currentPos,Q.contactTime=g.currentTime,Q.lastPos=Q.currentPos,Q.lastTime=Q.currentTime,Q.currentPos=g.currentPos,Q.currentTime=g.currentTime,g=Q):(g.captured=!1,g.insideElementPressed=!0,g.insideElement=!0,g.originalTarget=c.originalEvent.target,v(B,g)),B.addContact(),!c.preventGesture&&!c.defaultPrevented?(c.shouldCapture=!0,c.shouldReleaseCapture=!1,c.preventDefault=!0,(d.dragHandler||d.dragEndHandler||d.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.addPoint(d,g),B.contacts===1?d.pressHandler&&!c.preventGesture&&d.pressHandler({eventSource:d,pointerType:g.type,position:I(g.contactPos,d.element),buttons:B.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData}):B.contacts===2&&d.pinchHandler&&g.type==="touch"&&(R.pinchGPoints=B.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=T(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(c.shouldCapture=!1,c.shouldReleaseCapture=!1)}function F(d,c,g,f){var R=e[d.hash],B=d.getActivePointersListByType(g.type),Q,q,z,me=!1,Ae;if(typeof c.originalEvent.buttons<"u"?B.buttons=c.originalEvent.buttons:f===0?B.buttons^=-2:f===1?B.buttons^=-5:f===2?B.buttons^=-3:f===3?B.buttons^=-9:f===4?B.buttons^=-17:f===5&&(B.buttons^=-33),c.shouldCapture=!1,f!==0){c.shouldReleaseCapture=!1,d.nonPrimaryReleaseHandler&&!c.preventGesture&&!c.defaultPrevented&&(c.preventDefault=!0,d.nonPrimaryReleaseHandler({eventSource:d,pointerType:g.type,position:I(g.currentPos,d.element),button:f,buttons:B.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData}));return}z=B.getById(g.id),z?(B.removeContact(),z.captured&&(me=!0),z.lastPos=z.currentPos,z.lastTime=z.currentTime,z.currentPos=g.currentPos,z.currentTime=g.currentTime,z.insideElement||y(d,B,z),Q=z.currentPos,q=z.currentTime):(g.captured=!1,g.insideElementPressed=!1,g.insideElement=!0,v(B,g),z=g),!c.preventGesture&&!c.defaultPrevented&&(me?(c.shouldReleaseCapture=!0,c.preventDefault=!0,(d.dragHandler||d.dragEndHandler||d.pinchHandler)&&t.MouseTracker.gesturePointVelocityTracker.removePoint(d,z),B.contacts===0?(d.releaseHandler&&Q&&d.releaseHandler({eventSource:d,pointerType:z.type,position:I(Q,d.element),buttons:B.buttons,insideElementPressed:z.insideElementPressed,insideElementReleased:z.insideElement,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:d.userData}),d.dragEndHandler&&R.sentDragEvent&&d.dragEndHandler({eventSource:d,pointerType:z.type,position:I(z.currentPos,d.element),speed:z.speed,direction:z.direction,shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:d.userData}),R.sentDragEvent=!1,(d.clickHandler||d.dblClickHandler)&&z.insideElement&&(Ae=q-z.contactTime<=d.clickTimeThreshold&&z.contactPos.distanceTo(Q)<=d.clickDistThreshold,d.clickHandler&&d.clickHandler({eventSource:d,pointerType:z.type,position:I(z.currentPos,d.element),quick:Ae,shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,originalTarget:z.originalTarget,userData:d.userData}),d.dblClickHandler&&Ae&&(B.clicks++,B.clicks===1?(R.lastClickPos=Q,R.dblClickTimeOut=setTimeout(function(){B.clicks=0},d.dblClickTimeThreshold)):B.clicks===2&&(clearTimeout(R.dblClickTimeOut),B.clicks=0,R.lastClickPos.distanceTo(Q)<=d.dblClickDistThreshold&&d.dblClickHandler({eventSource:d,pointerType:z.type,position:I(z.currentPos,d.element),shift:c.originalEvent.shiftKey,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:d.userData}),R.lastClickPos=null)))):B.contacts===2&&d.pinchHandler&&z.type==="touch"&&(R.pinchGPoints=B.asArray(),R.lastPinchDist=R.currentPinchDist=R.pinchGPoints[0].currentPos.distanceTo(R.pinchGPoints[1].currentPos),R.lastPinchCenter=R.currentPinchCenter=T(R.pinchGPoints[0].currentPos,R.pinchGPoints[1].currentPos))):(c.shouldReleaseCapture=!1,d.releaseHandler&&Q&&(d.releaseHandler({eventSource:d,pointerType:z.type,position:I(Q,d.element),buttons:B.buttons,insideElementPressed:z.insideElementPressed,insideElementReleased:z.insideElement,isTouchEvent:z.type==="touch",originalEvent:c.originalEvent,userData:d.userData}),c.preventDefault=!0)))}function O(d,c,g){var f=e[d.hash],R=d.getActivePointersListByType(g.type),B,Q,q;if(typeof c.originalEvent.buttons<"u"&&(R.buttons=c.originalEvent.buttons),B=R.getById(g.id),B)B.lastPos=B.currentPos,B.lastTime=B.currentTime,B.currentPos=g.currentPos,B.currentTime=g.currentTime;else return;c.shouldCapture=!1,c.shouldReleaseCapture=!1,d.stopHandler&&g.type==="mouse"&&(clearTimeout(d.stopTimeOut),d.stopTimeOut=setTimeout(function(){Te(d,c.originalEvent,g.type)},d.stopDelay)),R.contacts===0?d.moveHandler&&d.moveHandler({eventSource:d,pointerType:g.type,position:I(g.currentPos,d.element),buttons:R.buttons,isTouchEvent:g.type==="touch",originalEvent:c.originalEvent,userData:d.userData}):R.contacts===1?(d.moveHandler&&(B=R.asArray()[0],d.moveHandler({eventSource:d,pointerType:B.type,position:I(B.currentPos,d.element),buttons:R.buttons,isTouchEvent:B.type==="touch",originalEvent:c.originalEvent,userData:d.userData})),d.dragHandler&&!c.preventGesture&&!c.defaultPrevented&&(B=R.asArray()[0],q=B.currentPos.minus(B.lastPos),d.dragHandler({eventSource:d,pointerType:B.type,position:I(B.currentPos,d.element),buttons:R.buttons,delta:q,speed:B.speed,direction:B.direction,shift:c.originalEvent.shiftKey,isTouchEvent:B.type==="touch",originalEvent:c.originalEvent,userData:d.userData}),c.preventDefault=!0,f.sentDragEvent=!0)):R.contacts===2&&(d.moveHandler&&(Q=R.asArray(),d.moveHandler({eventSource:d,pointerType:Q[0].type,position:I(T(Q[0].currentPos,Q[1].currentPos),d.element),buttons:R.buttons,isTouchEvent:Q[0].type==="touch",originalEvent:c.originalEvent,userData:d.userData})),d.pinchHandler&&g.type==="touch"&&!c.preventGesture&&!c.defaultPrevented&&(q=f.pinchGPoints[0].currentPos.distanceTo(f.pinchGPoints[1].currentPos),q!==f.currentPinchDist&&(f.lastPinchDist=f.currentPinchDist,f.currentPinchDist=q,f.lastPinchCenter=f.currentPinchCenter,f.currentPinchCenter=T(f.pinchGPoints[0].currentPos,f.pinchGPoints[1].currentPos),d.pinchHandler({eventSource:d,pointerType:"touch",gesturePoints:f.pinchGPoints,lastCenter:I(f.lastPinchCenter,d.element),center:I(f.currentPinchCenter,d.element),lastDistance:f.lastPinchDist,distance:f.currentPinchDist,shift:c.originalEvent.shiftKey,originalEvent:c.originalEvent,userData:d.userData}),c.preventDefault=!0)))}function K(d,c,g){var f=d.getActivePointersListByType(g.type),R;R=f.getById(g.id),R&&y(d,f,R)}function Te(d,c,g){d.stopHandler&&d.stopHandler({eventSource:d,pointerType:g,position:x(c,d.element),buttons:d.getActivePointersListByType(g).buttons,isTouchEvent:g==="touch",originalEvent:c,userData:d.userData})}})(L);(function(t){t.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5},t.Control=function(i,e,o){var a=i.parentNode;typeof e=="number"&&(t.console.error("Passing an anchor directly into the OpenSeadragon.Control constructor is deprecated; please use an options object instead. Support for this deprecated variant is scheduled for removal in December 2013"),e={anchor:e}),e.attachToViewer=typeof e.attachToViewer>"u"?!0:e.attachToViewer,this.autoFade=typeof e.autoFade>"u"?!0:e.autoFade,this.element=i,this.anchor=e.anchor,this.container=o,this.anchor===t.ControlAnchor.ABSOLUTE?(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.position="absolute",this.wrapper.style.top=typeof e.top=="number"?e.top+"px":e.top,this.wrapper.style.left=typeof e.left=="number"?e.left+"px":e.left,this.wrapper.style.height=typeof e.height=="number"?e.height+"px":e.height,this.wrapper.style.width=typeof e.width=="number"?e.width+"px":e.width,this.wrapper.style.margin="0px",this.wrapper.style.padding="0px",this.element.style.position="relative",this.element.style.top="0px",this.element.style.left="0px",this.element.style.height="100%",this.element.style.width="100%"):(this.wrapper=t.makeNeutralElement("div"),this.wrapper.style.display="inline-block",this.anchor===t.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")),this.wrapper.appendChild(this.element),e.attachToViewer?this.anchor===t.ControlAnchor.TOP_RIGHT||this.anchor===t.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):a.appendChild(this.wrapper)},t.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element),this.anchor!==t.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return this.wrapper.style.display!=="none"},setVisible:function(i){this.wrapper.style.display=i?this.anchor===t.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(i){this.element[t.SIGNAL]&&t.Browser.vendor===t.BROWSERS.IE?t.setElementOpacity(this.element,i,!0):t.setElementOpacity(this.wrapper,i,!0)}}})(L);(function(t){t.ControlDock=function(e){var o=["topleft","topright","bottomright","bottomleft"],a,n;for(t.extend(!0,this,{id:"controldock-"+t.now()+"-"+Math.floor(Math.random()*1e6),container:t.makeNeutralElement("div"),controls:[]},e),this.container.onsubmit=function(){return!1},this.element&&(this.element=t.getElement(this.element),this.element.appendChild(this.container),this.element.style.position="relative",this.container.style.width="100%",this.container.style.height="100%"),n=0;n<o.length;n++)a=o[n],this.controls[a]=t.makeNeutralElement("div"),this.controls[a].style.position="absolute",a.match("left")&&(this.controls[a].style.left="0px"),a.match("right")&&(this.controls[a].style.right="0px"),a.match("top")&&(this.controls[a].style.top="0px"),a.match("bottom")&&(this.controls[a].style.bottom="0px");this.container.appendChild(this.controls.topleft),this.container.appendChild(this.controls.topright),this.container.appendChild(this.controls.bottomright),this.container.appendChild(this.controls.bottomleft)},t.ControlDock.prototype={addControl:function(e,o){e=t.getElement(e);var a=null;if(!(i(this,e)>=0)){switch(o.anchor){case t.ControlAnchor.TOP_RIGHT:a=this.controls.topright,e.style.position="relative",e.style.paddingRight="0px",e.style.paddingTop="0px";break;case t.ControlAnchor.BOTTOM_RIGHT:a=this.controls.bottomright,e.style.position="relative",e.style.paddingRight="0px",e.style.paddingBottom="0px";break;case t.ControlAnchor.BOTTOM_LEFT:a=this.controls.bottomleft,e.style.position="relative",e.style.paddingLeft="0px",e.style.paddingBottom="0px";break;case t.ControlAnchor.TOP_LEFT:a=this.controls.topleft,e.style.position="relative",e.style.paddingLeft="0px",e.style.paddingTop="0px";break;case t.ControlAnchor.ABSOLUTE:a=this.container,e.style.margin="0px",e.style.padding="0px";break;default:case t.ControlAnchor.NONE:a=this.container,e.style.margin="0px",e.style.padding="0px";break}this.controls.push(new t.Control(e,o,a)),e.style.display="inline-block"}},removeControl:function(e){e=t.getElement(e);var o=i(this,e);return o>=0&&(this.controls[o].destroy(),this.controls.splice(o,1)),this},clearControls:function(){for(;this.controls.length>0;)this.controls.pop().destroy();return this},areControlsEnabled:function(){var e;for(e=this.controls.length-1;e>=0;e--)if(this.controls[e].isVisible())return!0;return!1},setControlsEnabled:function(e){var o;for(o=this.controls.length-1;o>=0;o--)this.controls[o].setVisible(e);return this}};function i(e,o){var a=e.controls,n;for(n=a.length-1;n>=0;n--)if(a[n].element===o)return n;return-1}})(L);(function(t){t.Placement=t.freezeObject({CENTER:0,TOP_LEFT:1,TOP:2,TOP_RIGHT:3,RIGHT:4,BOTTOM_RIGHT:5,BOTTOM:6,BOTTOM_LEFT:7,LEFT:8,properties:{0:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1},1:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},2:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!0,isVerticallyCentered:!1,isBottom:!1},3:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!0,isVerticallyCentered:!1,isBottom:!1},4:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!0,isBottom:!1},5:{isLeft:!1,isHorizontallyCentered:!1,isRight:!0,isTop:!1,isVerticallyCentered:!1,isBottom:!0},6:{isLeft:!1,isHorizontallyCentered:!0,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},7:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!1,isBottom:!0},8:{isLeft:!0,isHorizontallyCentered:!1,isRight:!1,isTop:!1,isVerticallyCentered:!0,isBottom:!1}}})})(L);(function(t){var i={},e=1;t.Viewer=function(h){var v=arguments,y=this,M;if(t.isPlainObject(h)||(h={id:v[0],xmlPath:v.length>1?v[1]:void 0,prefixUrl:v.length>2?v[2]:void 0,controls:v.length>3?v[3]:void 0,overlays:v.length>4?v[4]:void 0}),h.config&&(t.extend(!0,h,h.config),delete h.config),t.extend(!0,this,{id:h.id,hash:h.hash||e++,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousBody:[],customControls:[],source:null,drawer:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},t.DEFAULT_SETTINGS,h),typeof this.hash>"u")throw new Error("A hash must be defined, either by specifying options.id or options.hash.");for(typeof i[this.hash]<"u"&&t.console.warn("Hash "+this.hash+" has already been used."),i[this.hash]={fsBoundsDelta:new t.Point(1,1),prevContainerSize:null,animating:!1,forceRedraw:!1,needsResize:!1,forceResize:!1,mouseInside:!1,group:null,zooming:!1,zoomFactor:null,lastZoomTime:null,fullPage:!1,onfullscreenchange:null,lastClickTime:null,draggingToZoom:!1},this._sequenceIndex=0,this._firstOpen=!0,this._updateRequestId=null,this._loadQueue=[],this.currentOverlays=[],this._updatePixelDensityRatioBind=null,this._lastScrollTime=t.now(),t.EventSource.call(this),this.addHandler("open-failed",function(C){var U=t.getString("Errors.OpenFailed",C.eventSource,C.message);y._showMessage(U)}),t.ControlDock.call(this,h),this.xmlPath&&(this.tileSources=[this.xmlPath]),this.element=this.element||document.getElementById(this.id),this.canvas=t.makeNeutralElement("div"),this.canvas.className="openseadragon-canvas",function(C){C.width="100%",C.height="100%",C.overflow="hidden",C.position="absolute",C.top="0px",C.left="0px"}(this.canvas.style),t.setElementTouchActionNone(this.canvas),h.tabIndex!==""&&(this.canvas.tabIndex=h.tabIndex===void 0?0:h.tabIndex),this.container.className="openseadragon-container",function(C){C.width="100%",C.height="100%",C.position="relative",C.overflow="hidden",C.left="0px",C.top="0px",C.textAlign="left"}(this.container.style),t.setElementTouchActionNone(this.container),this.container.insertBefore(this.canvas,this.container.firstChild),this.element.appendChild(this.container),this.bodyWidth=document.body.style.width,this.bodyHeight=document.body.style.height,this.bodyOverflow=document.body.style.overflow,this.docOverflow=document.documentElement.style.overflow,this.innerTracker=new t.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:t.delegate(this,b),keyDownHandler:t.delegate(this,x),keyHandler:t.delegate(this,I),clickHandler:t.delegate(this,T),dblClickHandler:t.delegate(this,Z),dragHandler:t.delegate(this,Y),dragEndHandler:t.delegate(this,W),enterHandler:t.delegate(this,J),leaveHandler:t.delegate(this,V),pressHandler:t.delegate(this,_),releaseHandler:t.delegate(this,ae),nonPrimaryPressHandler:t.delegate(this,oe),nonPrimaryReleaseHandler:t.delegate(this,re),scrollHandler:t.delegate(this,Ee),pinchHandler:t.delegate(this,le)}),this.outerTracker=new t.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:t.delegate(this,Pe),leaveHandler:t.delegate(this,pe)}),this.toolbar&&(this.toolbar=new t.ControlDock({element:this.toolbar})),this.bindStandardControls(),i[this.hash].prevContainerSize=o(this.container),window.ResizeObserver?(this._autoResizePolling=!1,this._resizeObserver=new ResizeObserver(function(){i[y.hash].needsResize=!0}),this._resizeObserver.observe(this.container,{})):this._autoResizePolling=!0,this.world=new t.World({viewer:this}),this.world.addHandler("add-item",function(C){y.source=y.world.getItemAt(0).source,i[y.hash].forceRedraw=!0,y._updateRequestId||(y._updateRequestId=r(y,Re))}),this.world.addHandler("remove-item",function(C){y.world.getItemCount()?y.source=y.world.getItemAt(0).source:y.source=null,i[y.hash].forceRedraw=!0}),this.world.addHandler("metrics-change",function(C){y.viewport&&y.viewport._setContentBounds(y.world.getHomeBounds(),y.world.getContentFactor())}),this.world.addHandler("item-index-change",function(C){y.source=y.world.getItemAt(0).source}),this.viewport=new t.Viewport({containerSize:i[this.hash].prevContainerSize,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,maxZoomPixelRatio:this.maxZoomPixelRatio,visibilityRatio:this.visibilityRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,defaultZoomLevel:this.defaultZoomLevel,minZoomLevel:this.minZoomLevel,maxZoomLevel:this.maxZoomLevel,viewer:this,degrees:this.degrees,flipped:this.flipped,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins,silenceMultiImageWarnings:this.silenceMultiImageWarnings}),this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor()),this.imageLoader=new t.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:h.timeout}),this.tileCache=new t.TileCache({maxImageCacheCount:this.maxImageCacheCount}),this.drawer=new t.Drawer({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor}),this.overlaysContainer=t.makeNeutralElement("div"),this.canvas.appendChild(this.overlaysContainer),this.drawer.canRotate()||(this.rotateLeft&&(M=this.buttonGroup.buttons.indexOf(this.rotateLeft),this.buttonGroup.buttons.splice(M,1),this.buttonGroup.element.removeChild(this.rotateLeft.element)),this.rotateRight&&(M=this.buttonGroup.buttons.indexOf(this.rotateRight),this.buttonGroup.buttons.splice(M,1),this.buttonGroup.element.removeChild(this.rotateRight.element))),this._addUpdatePixelDensityRatioEvent(),this.showNavigator&&(this.navigator=new t.Navigator({element:this.navigatorElement,id:this.navigatorId,position:this.navigatorPosition,sizeRatio:this.navigatorSizeRatio,maintainSizeRatio:this.navigatorMaintainSizeRatio,top:this.navigatorTop,left:this.navigatorLeft,width:this.navigatorWidth,height:this.navigatorHeight,autoResize:this.navigatorAutoResize,autoFade:this.navigatorAutoFade,prefixUrl:this.prefixUrl,viewer:this,navigatorRotate:this.navigatorRotate,background:this.navigatorBackground,opacity:this.navigatorOpacity,borderColor:this.navigatorBorderColor,displayRegionColor:this.navigatorDisplayRegionColor,crossOriginPolicy:this.crossOriginPolicy,animationTime:this.animationTime})),this.sequenceMode&&this.bindSequenceControls(),this.tileSources&&this.open(this.tileSources),M=0;M<this.customControls.length;M++)this.addControl(this.customControls[M].id,{anchor:this.customControls[M].anchor});t.requestAnimationFrame(function(){l(y)}),this.imageSmoothingEnabled!==void 0&&!this.imageSmoothingEnabled&&this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled),t._viewers.set(this.element,this)},t.extend(t.Viewer.prototype,t.EventSource.prototype,t.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},openDzi:function(h){return t.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead."),this.open(h)},openTileSource:function(h){return t.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead."),this.open(h)},get buttons(){return t.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup"),this.buttonGroup},open:function(h,v){var y=this;if(this.close(),!h)return this;if(this.sequenceMode&&t.isArray(h))return this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),typeof v<"u"&&!isNaN(v)&&(this.initialPage=v),this.tileSources=h,this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage)),this.tileSources.length&&(this.open(this.tileSources[this._sequenceIndex]),this.showReferenceStrip&&this.addReferenceStrip()),this._updateSequenceButtons(this._sequenceIndex),this;if(t.isArray(h)||(h=[h]),!h.length)return this;this._opening=!0;for(var M=h.length,C=0,U=0,N,X=function(){if(C+U===M)if(C){(y._firstOpen||!y.preserveViewport)&&(y.viewport.goHome(!0),y.viewport.update()),y._firstOpen=!1;var S=h[0];if(S.tileSource&&(S=S.tileSource),y.overlays&&!y.preserveOverlays)for(var F=0;F<y.overlays.length;F++)y.currentOverlays[F]=n(y,y.overlays[F]);y._drawOverlays(),y._opening=!1,y.raiseEvent("open",{source:S})}else y._opening=!1,y.raiseEvent("open-failed",N)},k=function(S){(!t.isPlainObject(S)||!S.tileSource)&&(S={tileSource:S}),S.index!==void 0&&(t.console.error("[Viewer.open] setting indexes here is not supported; use addTiledImage instead"),delete S.index),S.collectionImmediately===void 0&&(S.collectionImmediately=!0);var F=S.success;S.success=function(K){if(C++,S.tileSource.overlays)for(var Te=0;Te<S.tileSource.overlays.length;Te++)y.addOverlay(S.tileSource.overlays[Te]);F&&F(K),X()};var O=S.error;S.error=function(K){U++,N||(N=K),O&&O(K),X()},y.addTiledImage(S)},D=0;D<h.length;D++)k(h[D]);return this},close:function(){return i[this.hash]?(this._opening=!1,this.navigator&&this.navigator.close(),this.preserveOverlays||(this.clearOverlays(),this.overlaysContainer.innerHTML=""),i[this.hash].animating=!1,this.world.removeAll(),this.imageLoader.clear(),this.raiseEvent("close"),this):this},destroy:function(){if(i[this.hash]){if(this.raiseEvent("before-destroy"),this._removeUpdatePixelDensityRatioEvent(),this.close(),this.clearOverlays(),this.overlaysContainer.innerHTML="",this._resizeObserver&&this._resizeObserver.disconnect(),this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null),this._updateRequestId!==null&&(t.cancelAnimationFrame(this._updateRequestId),this._updateRequestId=null),this.drawer&&this.drawer.destroy(),this.navigator&&(this.navigator.destroy(),i[this.navigator.hash]=null,delete i[this.navigator.hash],this.navigator=null),this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();if(this.paging&&this.paging.destroy(),this.element)for(;this.element.firstChild;)this.element.removeChild(this.element.firstChild);this.container.onsubmit=null,this.clearControls(),this.innerTracker&&this.innerTracker.destroy(),this.outerTracker&&this.outerTracker.destroy(),i[this.hash]=null,delete i[this.hash],this.canvas=null,this.container=null,t._viewers.delete(this.element),this.element=null,this.raiseEvent("destroy"),this.removeAllHandlers()}},isMouseNavEnabled:function(){return this.innerTracker.isTracking()},setMouseNavEnabled:function(h){return this.innerTracker.setTracking(h),this.outerTracker.setTracking(h),this.raiseEvent("mouse-enabled",{enabled:h}),this},areControlsEnabled:function(){var h=this.controls.length,v;for(v=0;v<this.controls.length;v++)h=h&&this.controls[v].isVisible();return h},setControlsEnabled:function(h){return h?m(this):l(this),this.raiseEvent("controls-enabled",{enabled:h}),this},setDebugMode:function(h){for(var v=0;v<this.world.getItemCount();v++)this.world.getItemAt(v).debugMode=h;this.debugMode=h,this.forceRedraw()},isFullPage:function(){return i[this.hash].fullPage},setFullPage:function(h){var v=document.body,y=v.style,M=document.documentElement.style,C=this,U,N;if(h===this.isFullPage())return this;var X={fullPage:h,preventDefaultAction:!1};if(this.raiseEvent("pre-full-page",X),X.preventDefaultAction)return this;if(h){for(this.elementSize=t.getElementSize(this.element),this.pageScroll=t.getPageScroll(),this.elementMargin=this.element.style.margin,this.element.style.margin="0",this.elementPadding=this.element.style.padding,this.element.style.padding="0",this.bodyMargin=y.margin,this.docMargin=M.margin,y.margin="0",M.margin="0",this.bodyPadding=y.padding,this.docPadding=M.padding,y.padding="0",M.padding="0",this.bodyWidth=y.width,this.docWidth=M.width,y.width="100%",M.width="100%",this.bodyHeight=y.height,this.docHeight=M.height,y.height="100%",M.height="100%",this.bodyDisplay=y.display,y.display="block",this.previousBody=[],i[this.hash].prevElementParent=this.element.parentNode,i[this.hash].prevNextSibling=this.element.nextSibling,i[this.hash].prevElementWidth=this.element.style.width,i[this.hash].prevElementHeight=this.element.style.height,U=v.childNodes.length,N=0;N<U;N++)this.previousBody.push(v.childNodes[0]),v.removeChild(v.childNodes[0]);this.toolbar&&this.toolbar.element&&(this.toolbar.parentNode=this.toolbar.element.parentNode,this.toolbar.nextSibling=this.toolbar.element.nextSibling,v.appendChild(this.toolbar.element),t.addClass(this.toolbar.element,"fullpage")),t.addClass(this.element,"fullpage"),v.appendChild(this.element),this.element.style.height="100vh",this.element.style.width="100vw",this.toolbar&&this.toolbar.element&&(this.element.style.height=t.getElementSize(this.element).y-t.getElementSize(this.toolbar.element).y+"px"),i[this.hash].fullPage=!0,t.delegate(this,Pe)({})}else{for(this.element.style.margin=this.elementMargin,this.element.style.padding=this.elementPadding,y.margin=this.bodyMargin,M.margin=this.docMargin,y.padding=this.bodyPadding,M.padding=this.docPadding,y.width=this.bodyWidth,M.width=this.docWidth,y.height=this.bodyHeight,M.height=this.docHeight,y.display=this.bodyDisplay,v.removeChild(this.element),U=this.previousBody.length,N=0;N<U;N++)v.appendChild(this.previousBody.shift());t.removeClass(this.element,"fullpage"),i[this.hash].prevElementParent.insertBefore(this.element,i[this.hash].prevNextSibling),this.toolbar&&this.toolbar.element&&(v.removeChild(this.toolbar.element),t.removeClass(this.toolbar.element,"fullpage"),this.toolbar.parentNode.insertBefore(this.toolbar.element,this.toolbar.nextSibling),delete this.toolbar.parentNode,delete this.toolbar.nextSibling),this.element.style.width=i[this.hash].prevElementWidth,this.element.style.height=i[this.hash].prevElementHeight;var k=0,D=function(){t.setPageScroll(C.pageScroll);var S=t.getPageScroll();k++,k<10&&(S.x!==C.pageScroll.x||S.y!==C.pageScroll.y)&&t.requestAnimationFrame(D)};t.requestAnimationFrame(D),i[this.hash].fullPage=!1,t.delegate(this,pe)({})}return this.navigator&&this.viewport&&this.navigator.update(this.viewport),this.raiseEvent("full-page",{fullPage:h}),this},setFullScreen:function(h){var v=this;if(!t.supportsFullScreen)return this.setFullPage(h);if(t.isFullScreen()===h)return this;var y={fullScreen:h,preventDefaultAction:!1};if(this.raiseEvent("pre-full-screen",y),y.preventDefaultAction)return this;if(h){if(this.setFullPage(!0),!this.isFullPage())return this;this.fullPageStyleWidth=this.element.style.width,this.fullPageStyleHeight=this.element.style.height,this.element.style.width="100%",this.element.style.height="100%";var M=function(){var C=t.isFullScreen();C||(t.removeEvent(document,t.fullScreenEventName,M),t.removeEvent(document,t.fullScreenErrorEventName,M),v.setFullPage(!1),v.isFullPage()&&(v.element.style.width=v.fullPageStyleWidth,v.element.style.height=v.fullPageStyleHeight)),v.navigator&&v.viewport&&setTimeout(function(){v.navigator.update(v.viewport)}),v.raiseEvent("full-screen",{fullScreen:C})};t.addEvent(document,t.fullScreenEventName,M),t.addEvent(document,t.fullScreenErrorEventName,M),t.requestFullScreen(document.body)}else t.exitFullScreen();return this},isVisible:function(){return this.container.style.visibility!=="hidden"},isFullScreen:function(){return t.isFullScreen()&&this.isFullPage()},setVisible:function(h){return this.container.style.visibility=h?"":"hidden",this.raiseEvent("visible",{visible:h}),this},addTiledImage:function(h){t.console.assert(h,"[Viewer.addTiledImage] options is required"),t.console.assert(h.tileSource,"[Viewer.addTiledImage] options.tileSource is required"),t.console.assert(!h.replace||h.index>-1&&h.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");var v=this;h.replace&&(h.replaceItem=v.world.getItemAt(h.index)),this._hideMessage(),h.placeholderFillStyle===void 0&&(h.placeholderFillStyle=this.placeholderFillStyle),h.opacity===void 0&&(h.opacity=this.opacity),h.preload===void 0&&(h.preload=this.preload),h.compositeOperation===void 0&&(h.compositeOperation=this.compositeOperation),h.crossOriginPolicy===void 0&&(h.crossOriginPolicy=h.tileSource.crossOriginPolicy!==void 0?h.tileSource.crossOriginPolicy:this.crossOriginPolicy),h.ajaxWithCredentials===void 0&&(h.ajaxWithCredentials=this.ajaxWithCredentials),h.loadTilesWithAjax===void 0&&(h.loadTilesWithAjax=this.loadTilesWithAjax),h.ajaxHeaders===void 0||h.ajaxHeaders===null?h.ajaxHeaders=this.ajaxHeaders:t.isPlainObject(h.ajaxHeaders)&&t.isPlainObject(this.ajaxHeaders)&&(h.ajaxHeaders=t.extend({},this.ajaxHeaders,h.ajaxHeaders));var y={options:h};function M(N){for(var X=0;X<v._loadQueue.length;X++)if(v._loadQueue[X]===y){v._loadQueue.splice(X,1);break}v._loadQueue.length===0&&C(y),v.raiseEvent("add-item-failed",N),h.error&&h.error(N)}function C(N){v.collectionMode&&(v.world.arrange({immediately:N.options.collectionImmediately,rows:v.collectionRows,columns:v.collectionColumns,layout:v.collectionLayout,tileSize:v.collectionTileSize,tileMargin:v.collectionTileMargin}),v.world.setAutoRefigureSizes(!0))}if(t.isArray(h.tileSource)){setTimeout(function(){M({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:h.tileSource,options:h})});return}this._loadQueue.push(y);function U(){for(var N,X,k;v._loadQueue.length&&(N=v._loadQueue[0],!!N.tileSource);){if(v._loadQueue.splice(0,1),N.options.replace){var D=v.world.getIndexOfItem(N.options.replaceItem);D!==-1&&(N.options.index=D),v.world.removeItem(N.options.replaceItem)}X=new t.TiledImage({viewer:v,source:N.tileSource,viewport:v.viewport,drawer:v.drawer,tileCache:v.tileCache,imageLoader:v.imageLoader,x:N.options.x,y:N.options.y,width:N.options.width,height:N.options.height,fitBounds:N.options.fitBounds,fitBoundsPlacement:N.options.fitBoundsPlacement,clip:N.options.clip,placeholderFillStyle:N.options.placeholderFillStyle,opacity:N.options.opacity,preload:N.options.preload,degrees:N.options.degrees,flipped:N.options.flipped,compositeOperation:N.options.compositeOperation,springStiffness:v.springStiffness,animationTime:v.animationTime,minZoomImageRatio:v.minZoomImageRatio,wrapHorizontal:v.wrapHorizontal,wrapVertical:v.wrapVertical,immediateRender:v.immediateRender,blendTime:v.blendTime,alwaysBlend:v.alwaysBlend,minPixelRatio:v.minPixelRatio,smoothTileEdgesMinZoom:v.smoothTileEdgesMinZoom,iOSDevice:v.iOSDevice,crossOriginPolicy:N.options.crossOriginPolicy,ajaxWithCredentials:N.options.ajaxWithCredentials,loadTilesWithAjax:N.options.loadTilesWithAjax,ajaxHeaders:N.options.ajaxHeaders,debugMode:v.debugMode,subPixelRoundingForTransparency:v.subPixelRoundingForTransparency}),v.collectionMode&&v.world.setAutoRefigureSizes(!1),v.navigator&&(k=t.extend({},N.options,{replace:!1,originalTiledImage:X,tileSource:N.tileSource}),v.navigator.addTiledImage(k)),v.world.addItem(X,{index:N.options.index}),v._loadQueue.length===0&&C(N),v.world.getItemCount()===1&&!v.preserveViewport&&v.viewport.goHome(!0),N.options.success&&N.options.success({item:X})}}a(this,h.tileSource,h,function(N){y.tileSource=N,U()},function(N){N.options=h,M(N),U()})},addSimpleImage:function(h){t.console.assert(h,"[Viewer.addSimpleImage] options is required"),t.console.assert(h.url,"[Viewer.addSimpleImage] options.url is required");var v=t.extend({},h,{tileSource:{type:"image",url:h.url}});delete v.url,this.addTiledImage(v)},addLayer:function(h){var v=this;t.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var y=t.extend({},h,{success:function(M){v.raiseEvent("add-layer",{options:h,drawer:M.item})},error:function(M){v.raiseEvent("add-layer-failed",M)}});return this.addTiledImage(y),this},getLayerAtLevel:function(h){return t.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead."),this.world.getItemAt(h)},getLevelOfLayer:function(h){return t.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead."),this.world.getIndexOfItem(h)},getLayersCount:function(){return t.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead."),this.world.getItemCount()},setLayerLevel:function(h,v){return t.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead."),this.world.setItemIndex(h,v)},removeLayer:function(h){return t.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead."),this.world.removeItem(h)},forceRedraw:function(){return i[this.hash].forceRedraw=!0,this},forceResize:function(){i[this.hash].needsResize=!0,i[this.hash].forceResize=!0},bindSequenceControls:function(){var h=t.delegate(this,p),v=t.delegate(this,w),y=t.delegate(this,this.goToNextPage),M=t.delegate(this,this.goToPreviousPage),C=this.navImages,U=!0;return this.showSequenceControl&&((this.previousButton||this.nextButton)&&(U=!1),this.previousButton=new t.Button({element:this.previousButton?t.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.PreviousPage"),srcRest:j(this.prefixUrl,C.previous.REST),srcGroup:j(this.prefixUrl,C.previous.GROUP),srcHover:j(this.prefixUrl,C.previous.HOVER),srcDown:j(this.prefixUrl,C.previous.DOWN),onRelease:M,onFocus:h,onBlur:v}),this.nextButton=new t.Button({element:this.nextButton?t.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.NextPage"),srcRest:j(this.prefixUrl,C.next.REST),srcGroup:j(this.prefixUrl,C.next.GROUP),srcHover:j(this.prefixUrl,C.next.HOVER),srcDown:j(this.prefixUrl,C.next.DOWN),onRelease:y,onFocus:h,onBlur:v}),this.navPrevNextWrap||this.previousButton.disable(),(!this.tileSources||!this.tileSources.length)&&this.nextButton.disable(),U&&(this.paging=new t.ButtonGroup({buttons:[this.previousButton,this.nextButton],clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.pagingControl=this.paging.element,this.toolbar?this.toolbar.addControl(this.pagingControl,{anchor:t.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||t.ControlAnchor.TOP_LEFT}))),this},bindStandardControls:function(){var h=t.delegate(this,Le),v=t.delegate(this,ke),y=t.delegate(this,Qe),M=t.delegate(this,Xe),C=t.delegate(this,ge),U=t.delegate(this,_e),N=t.delegate(this,Oe),X=t.delegate(this,ze),k=t.delegate(this,qe),D=t.delegate(this,Ze),S=t.delegate(this,p),F=t.delegate(this,w),O=this.navImages,K=[],Te=!0;return this.showNavigationControl&&((this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(Te=!1),this.showZoomControl&&(K.push(this.zoomInButton=new t.Button({element:this.zoomInButton?t.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomIn"),srcRest:j(this.prefixUrl,O.zoomIn.REST),srcGroup:j(this.prefixUrl,O.zoomIn.GROUP),srcHover:j(this.prefixUrl,O.zoomIn.HOVER),srcDown:j(this.prefixUrl,O.zoomIn.DOWN),onPress:h,onRelease:v,onClick:y,onEnter:h,onExit:v,onFocus:S,onBlur:F})),K.push(this.zoomOutButton=new t.Button({element:this.zoomOutButton?t.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.ZoomOut"),srcRest:j(this.prefixUrl,O.zoomOut.REST),srcGroup:j(this.prefixUrl,O.zoomOut.GROUP),srcHover:j(this.prefixUrl,O.zoomOut.HOVER),srcDown:j(this.prefixUrl,O.zoomOut.DOWN),onPress:M,onRelease:v,onClick:C,onEnter:M,onExit:v,onFocus:S,onBlur:F}))),this.showHomeControl&&K.push(this.homeButton=new t.Button({element:this.homeButton?t.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Home"),srcRest:j(this.prefixUrl,O.home.REST),srcGroup:j(this.prefixUrl,O.home.GROUP),srcHover:j(this.prefixUrl,O.home.HOVER),srcDown:j(this.prefixUrl,O.home.DOWN),onRelease:U,onFocus:S,onBlur:F})),this.showFullPageControl&&K.push(this.fullPageButton=new t.Button({element:this.fullPageButton?t.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.FullPage"),srcRest:j(this.prefixUrl,O.fullpage.REST),srcGroup:j(this.prefixUrl,O.fullpage.GROUP),srcHover:j(this.prefixUrl,O.fullpage.HOVER),srcDown:j(this.prefixUrl,O.fullpage.DOWN),onRelease:N,onFocus:S,onBlur:F})),this.showRotationControl&&(K.push(this.rotateLeftButton=new t.Button({element:this.rotateLeftButton?t.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateLeft"),srcRest:j(this.prefixUrl,O.rotateleft.REST),srcGroup:j(this.prefixUrl,O.rotateleft.GROUP),srcHover:j(this.prefixUrl,O.rotateleft.HOVER),srcDown:j(this.prefixUrl,O.rotateleft.DOWN),onRelease:X,onFocus:S,onBlur:F})),K.push(this.rotateRightButton=new t.Button({element:this.rotateRightButton?t.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.RotateRight"),srcRest:j(this.prefixUrl,O.rotateright.REST),srcGroup:j(this.prefixUrl,O.rotateright.GROUP),srcHover:j(this.prefixUrl,O.rotateright.HOVER),srcDown:j(this.prefixUrl,O.rotateright.DOWN),onRelease:k,onFocus:S,onBlur:F}))),this.showFlipControl&&K.push(this.flipButton=new t.Button({element:this.flipButton?t.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:t.getString("Tooltips.Flip"),srcRest:j(this.prefixUrl,O.flip.REST),srcGroup:j(this.prefixUrl,O.flip.GROUP),srcHover:j(this.prefixUrl,O.flip.HOVER),srcDown:j(this.prefixUrl,O.flip.DOWN),onRelease:D,onFocus:S,onBlur:F})),Te?(this.buttonGroup=new t.ButtonGroup({buttons:K,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold}),this.navControl=this.buttonGroup.element,this.addHandler("open",t.delegate(this,He)),this.toolbar?this.toolbar.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT}):this.addControl(this.navControl,{anchor:this.navigationControlAnchor||t.ControlAnchor.TOP_LEFT})):this.customButtons=K),this},currentPage:function(){return this._sequenceIndex},goToPage:function(h){return this.tileSources&&h>=0&&h<this.tileSources.length&&(this._sequenceIndex=h,this._updateSequenceButtons(h),this.open(this.tileSources[h]),this.referenceStrip&&this.referenceStrip.setFocus(h),this.raiseEvent("page",{page:h})),this},addOverlay:function(h,v,y,M){var C;if(t.isPlainObject(h)?C=h:C={element:h,location:v,placement:y,onDraw:M},h=t.getElement(C.element),s(this.currentOverlays,h)>=0)return this;var U=n(this,C);return this.currentOverlays.push(U),U.drawHTML(this.overlaysContainer,this.viewport),this.raiseEvent("add-overlay",{element:h,location:C.location,placement:C.placement}),this},updateOverlay:function(h,v,y){var M;return h=t.getElement(h),M=s(this.currentOverlays,h),M>=0&&(this.currentOverlays[M].update(v,y),i[this.hash].forceRedraw=!0,this.raiseEvent("update-overlay",{element:h,location:v,placement:y})),this},removeOverlay:function(h){var v;return h=t.getElement(h),v=s(this.currentOverlays,h),v>=0&&(this.currentOverlays[v].destroy(),this.currentOverlays.splice(v,1),i[this.hash].forceRedraw=!0,this.raiseEvent("remove-overlay",{element:h})),this},clearOverlays:function(){for(;this.currentOverlays.length>0;)this.currentOverlays.pop().destroy();return i[this.hash].forceRedraw=!0,this.raiseEvent("clear-overlay",{}),this},getOverlayById:function(h){var v;return h=t.getElement(h),v=s(this.currentOverlays,h),v>=0?this.currentOverlays[v]:null},_updateSequenceButtons:function(h){this.nextButton&&(!this.tileSources||this.tileSources.length-1===h?this.navPrevNextWrap||this.nextButton.disable():this.nextButton.enable()),this.previousButton&&(h>0?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(h){this._hideMessage();var v=t.makeNeutralElement("div");v.appendChild(document.createTextNode(h)),this.messageDiv=t.makeCenteredNode(v),t.addClass(this.messageDiv,"openseadragon-message"),this.container.appendChild(this.messageDiv)},_hideMessage:function(){var h=this.messageDiv;h&&(h.parentNode.removeChild(h),delete this.messageDiv)},gestureSettingsByDeviceType:function(h){switch(h){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var h,v=this.currentOverlays.length;for(h=0;h<v;h++)this.currentOverlays[h].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1,this.referenceStrip&&(this.referenceStrip.destroy(),this.referenceStrip=null)},addReferenceStrip:function(){if(this.showReferenceStrip=!0,this.sequenceMode){if(this.referenceStrip)return;this.tileSources.length&&this.tileSources.length>1&&(this.referenceStrip=new t.ReferenceStrip({id:this.referenceStripElement,position:this.referenceStripPosition,sizeRatio:this.referenceStripSizeRatio,scroll:this.referenceStripScroll,height:this.referenceStripHeight,width:this.referenceStripWidth,tileSources:this.tileSources,prefixUrl:this.prefixUrl,useCanvas:this.useCanvas,viewer:this}),this.referenceStrip.setFocus(this._sequenceIndex))}else t.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this),t.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){t.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var h=t.pixelDensityRatio,v=t.getCurrentPixelDensityRatio();h!==v&&(t.pixelDensityRatio=v,this.world.resetItems(),this.forceRedraw())},goToPreviousPage:function(){var h=this._sequenceIndex-1;this.navPrevNextWrap&&h<0&&(h+=this.tileSources.length),this.goToPage(h)},goToNextPage:function(){var h=this._sequenceIndex+1;this.navPrevNextWrap&&h>=this.tileSources.length&&(h=0),this.goToPage(h)},isAnimating:function(){return i[this.hash].animating}});function o(h){return h=t.getElement(h),new t.Point(h.clientWidth===0?1:h.clientWidth,h.clientHeight===0?1:h.clientHeight)}function a(h,v,y,M,C){var U=h;if(t.type(v)==="string"){if(v.match(/^\s*<.*>\s*$/))v=t.parseXml(v);else if(v.match(/^\s*[{[].*[}\]]\s*$/))try{var N=t.parseJSON(v);v=N}catch{}}function X(k,D){k.ready?M(k):(k.addHandler("ready",function(){M(k)}),k.addHandler("open-failed",function(S){C({message:S.message,source:D})}))}setTimeout(function(){if(t.type(v)==="string")v=new t.TileSource({url:v,crossOriginPolicy:y.crossOriginPolicy!==void 0?y.crossOriginPolicy:h.crossOriginPolicy,ajaxWithCredentials:h.ajaxWithCredentials,ajaxHeaders:y.ajaxHeaders?y.ajaxHeaders:h.ajaxHeaders,splitHashDataForPost:h.splitHashDataForPost,useCanvas:h.useCanvas,success:function(F){M(F.tileSource)}}),v.addHandler("open-failed",function(F){C(F)});else if(t.isPlainObject(v)||v.nodeType)if(v.crossOriginPolicy===void 0&&(y.crossOriginPolicy!==void 0||h.crossOriginPolicy!==void 0)&&(v.crossOriginPolicy=y.crossOriginPolicy!==void 0?y.crossOriginPolicy:h.crossOriginPolicy),v.ajaxWithCredentials===void 0&&(v.ajaxWithCredentials=h.ajaxWithCredentials),v.useCanvas===void 0&&(v.useCanvas=h.useCanvas),t.isFunction(v.getTileUrl)){var k=new t.TileSource(v);k.getTileUrl=v.getTileUrl,M(k)}else{var D=t.TileSource.determineType(U,v);if(!D){C({message:"Unable to load TileSource",source:v});return}var S=D.prototype.configure.apply(U,[v]);X(new D(S),v)}else X(v,v)})}function n(h,v){if(v instanceof t.Overlay)return v;var y=null;if(v.element)y=t.getElement(v.element);else{var M=v.id?v.id:"openseadragon-overlay-"+Math.floor(Math.random()*1e7);y=t.getElement(v.id),y||(y=document.createElement("a"),y.href="#/overlay/"+M),y.id=M,t.addClass(y,v.className?v.className:"openseadragon-overlay")}var C=v.location,U=v.width,N=v.height;if(!C){var X=v.x,k=v.y;if(v.px!==void 0){var D=h.viewport.imageToViewportRectangle(new t.Rect(v.px,v.py,U||0,N||0));X=D.x,k=D.y,U=U!==void 0?D.width:void 0,N=N!==void 0?D.height:void 0}C=new t.Point(X,k)}var S=v.placement;return S&&t.type(S)==="string"&&(S=t.Placement[v.placement.toUpperCase()]),new t.Overlay({element:y,location:C,placement:S,onDraw:v.onDraw,checkResize:v.checkResize,width:U,height:N,rotationMode:v.rotationMode})}function s(h,v){var y;for(y=h.length-1;y>=0;y--)if(h[y].element===v)return y;return-1}function r(h,v){return t.requestAnimationFrame(function(){v(h)})}function A(h){t.requestAnimationFrame(function(){u(h)})}function l(h){h.autoHideControls&&(h.controlsShouldFade=!0,h.controlsFadeBeginTime=t.now()+h.controlsFadeDelay,window.setTimeout(function(){A(h)},h.controlsFadeDelay))}function u(h){var v,y,M,C;if(h.controlsShouldFade){for(v=t.now(),y=v-h.controlsFadeBeginTime,M=1-y/h.controlsFadeLength,M=Math.min(1,M),M=Math.max(0,M),C=h.controls.length-1;C>=0;C--)h.controls[C].autoFade&&h.controls[C].setOpacity(M);M>0&&A(h)}}function m(h){var v;for(h.controlsShouldFade=!1,v=h.controls.length-1;v>=0;v--)h.controls[v].setOpacity(1)}function p(){m(this)}function w(){l(this)}function b(h){var v={tracker:h.eventSource,position:h.position,originalEvent:h.originalEvent,preventDefault:h.preventDefault};this.raiseEvent("canvas-contextmenu",v),h.preventDefault=v.preventDefault}function x(h){var v={originalEvent:h.originalEvent,preventDefaultAction:!1,preventVerticalPan:h.preventVerticalPan||!this.panVertical,preventHorizontalPan:h.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",v),!v.preventDefaultAction&&!h.ctrl&&!h.alt&&!h.meta)switch(h.keyCode){case 38:v.preventVerticalPan||(h.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-this.pixelsPerArrowPress))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 40:v.preventVerticalPan||(h.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,this.pixelsPerArrowPress))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 37:v.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 39:v.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(this.pixelsPerArrowPress,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;default:h.preventDefault=!1;break}else h.preventDefault=!1}function I(h){var v={originalEvent:h.originalEvent,preventDefaultAction:!1,preventVerticalPan:h.preventVerticalPan||!this.panVertical,preventHorizontalPan:h.preventHorizontalPan||!this.panHorizontal};if(this.raiseEvent("canvas-key",v),!v.preventDefaultAction&&!h.ctrl&&!h.alt&&!h.meta)switch(h.keyCode){case 43:case 61:this.viewport.zoomBy(1.1),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 45:this.viewport.zoomBy(.9),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 48:this.viewport.goHome(),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 119:case 87:v.preventVerticalPan||(h.shift?this.viewport.zoomBy(1.1):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,-40))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 115:case 83:v.preventVerticalPan||(h.shift?this.viewport.zoomBy(.9):this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(0,40))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 97:v.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(-40,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 100:v.preventHorizontalPan||(this.viewport.panBy(this.viewport.deltaPointsFromPixels(new t.Point(40,0))),this.viewport.applyConstraints()),h.preventDefault=!0;break;case 114:this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 82:this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement),this.viewport.applyConstraints(),h.preventDefault=!0;break;case 102:this.viewport.toggleFlip(),h.preventDefault=!0;break;case 106:this.goToPreviousPage();break;case 107:this.goToNextPage();break;default:h.preventDefault=!1;break}else h.preventDefault=!1}function T(h){var v,y=document.activeElement===this.canvas;y||this.canvas.focus(),this.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x);var M={tracker:h.eventSource,position:h.position,quick:h.quick,shift:h.shift,originalEvent:h.originalEvent,originalTarget:h.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",M),!M.preventDefaultAction&&this.viewport&&h.quick&&(v=this.gestureSettingsByDeviceType(h.pointerType),v.clickToZoom===!0&&(this.viewport.zoomBy(h.shift?1/this.zoomPerClick:this.zoomPerClick,v.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints()),v.dblClickDragToZoom&&(i[this.hash].draggingToZoom===!0?(i[this.hash].lastClickTime=null,i[this.hash].draggingToZoom=!1):i[this.hash].lastClickTime=t.now()))}function Z(h){var v,y={tracker:h.eventSource,position:h.position,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",y),!y.preventDefaultAction&&this.viewport&&(v=this.gestureSettingsByDeviceType(h.pointerType),v.dblClickToZoom&&(this.viewport.zoomBy(h.shift?1/this.zoomPerClick:this.zoomPerClick,v.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints()))}function Y(h){var v,y={tracker:h.eventSource,pointerType:h.pointerType,position:h.position,delta:h.delta,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag",y),v=this.gestureSettingsByDeviceType(h.pointerType),!y.preventDefaultAction&&this.viewport){if(v.dblClickDragToZoom&&i[this.hash].draggingToZoom){var M=Math.pow(this.zoomPerDblClickDrag,h.delta.y/50);this.viewport.zoomBy(M)}else if(v.dragToPan&&!i[this.hash].draggingToZoom){if(this.panHorizontal||(h.delta.x=0),this.panVertical||(h.delta.y=0),this.viewport.flipped&&(h.delta.x=-h.delta.x),this.constrainDuringPan){var C=this.viewport.deltaPointsFromPixels(h.delta.negate());this.viewport.centerSpringX.target.value+=C.x,this.viewport.centerSpringY.target.value+=C.y;var U=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=C.x,this.viewport.centerSpringY.target.value-=C.y,U.xConstrained&&(h.delta.x=0),U.yConstrained&&(h.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(h.delta.negate()),v.flickEnabled&&!this.constrainDuringPan)}}}function W(h){var v,y={tracker:h.eventSource,pointerType:h.pointerType,position:h.position,speed:h.speed,direction:h.direction,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1};if(this.raiseEvent("canvas-drag-end",y),v=this.gestureSettingsByDeviceType(h.pointerType),!y.preventDefaultAction&&this.viewport){if(!i[this.hash].draggingToZoom&&v.flickEnabled&&h.speed>=v.flickMinSpeed){var M=0;this.panHorizontal&&(M=v.flickMomentum*h.speed*Math.cos(h.direction));var C=0;this.panVertical&&(C=v.flickMomentum*h.speed*Math.sin(h.direction));var U=this.viewport.pixelFromPoint(this.viewport.getCenter(!0)),N=this.viewport.pointFromPixel(new t.Point(U.x-M,U.y-C));this.viewport.panTo(N,!1)}this.viewport.applyConstraints()}v.dblClickDragToZoom&&i[this.hash].draggingToZoom===!0&&(i[this.hash].draggingToZoom=!1)}function J(h){this.raiseEvent("canvas-enter",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function V(h){this.raiseEvent("canvas-exit",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function _(h){var v;if(this.raiseEvent("canvas-press",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,insideElementPressed:h.insideElementPressed,insideElementReleased:h.insideElementReleased,originalEvent:h.originalEvent}),v=this.gestureSettingsByDeviceType(h.pointerType),v.dblClickDragToZoom){var y=i[this.hash].lastClickTime,M=t.now();if(y===null)return;M-y<this.dblClickTimeThreshold&&(i[this.hash].draggingToZoom=!0),i[this.hash].lastClickTime=null}}function ae(h){this.raiseEvent("canvas-release",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,insideElementPressed:h.insideElementPressed,insideElementReleased:h.insideElementReleased,originalEvent:h.originalEvent})}function oe(h){this.raiseEvent("canvas-nonprimary-press",{tracker:h.eventSource,position:h.position,pointerType:h.pointerType,button:h.button,buttons:h.buttons,originalEvent:h.originalEvent})}function re(h){this.raiseEvent("canvas-nonprimary-release",{tracker:h.eventSource,position:h.position,pointerType:h.pointerType,button:h.button,buttons:h.buttons,originalEvent:h.originalEvent})}function le(h){var v,y,M,C,U={tracker:h.eventSource,pointerType:h.pointerType,gesturePoints:h.gesturePoints,lastCenter:h.lastCenter,center:h.center,lastDistance:h.lastDistance,distance:h.distance,shift:h.shift,originalEvent:h.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};if(this.raiseEvent("canvas-pinch",U),this.viewport&&(v=this.gestureSettingsByDeviceType(h.pointerType),v.pinchToZoom&&(!U.preventDefaultPanAction||!U.preventDefaultZoomAction)&&(y=this.viewport.pointFromPixel(h.center,!0),v.zoomToRefPoint&&!U.preventDefaultPanAction&&(M=this.viewport.pointFromPixel(h.lastCenter,!0),C=M.minus(y),this.panHorizontal||(C.x=0),this.panVertical||(C.y=0),this.viewport.panBy(C,!0)),U.preventDefaultZoomAction||this.viewport.zoomBy(h.distance/h.lastDistance,y,!0),this.viewport.applyConstraints()),v.pinchRotate&&!U.preventDefaultRotateAction)){var N=Math.atan2(h.gesturePoints[0].currentPos.y-h.gesturePoints[1].currentPos.y,h.gesturePoints[0].currentPos.x-h.gesturePoints[1].currentPos.x),X=Math.atan2(h.gesturePoints[0].lastPos.y-h.gesturePoints[1].lastPos.y,h.gesturePoints[0].lastPos.x-h.gesturePoints[1].lastPos.x);this.viewport.setRotation(this.viewport.getRotation()+(N-X)*(180/Math.PI))}}function Ee(h){var v,y,M,C,U;C=t.now(),U=C-this._lastScrollTime,U>this.minScrollDeltaTime?(this._lastScrollTime=C,v={tracker:h.eventSource,position:h.position,scroll:h.scroll,shift:h.shift,originalEvent:h.originalEvent,preventDefaultAction:!1,preventDefault:!0},this.raiseEvent("canvas-scroll",v),!v.preventDefaultAction&&this.viewport&&(this.viewport.flipped&&(h.position.x=this.viewport.getContainerSize().x-h.position.x),y=this.gestureSettingsByDeviceType(h.pointerType),y.scrollToZoom&&(M=Math.pow(this.zoomPerScroll,h.scroll),this.viewport.zoomBy(M,y.zoomToRefPoint?this.viewport.pointFromPixel(h.position,!0):null),this.viewport.applyConstraints())),h.preventDefault=v.preventDefault):h.preventDefault=!0}function Pe(h){i[this.hash].mouseInside=!0,m(this),this.raiseEvent("container-enter",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function pe(h){h.pointers<1&&(i[this.hash].mouseInside=!1,i[this.hash].animating||l(this)),this.raiseEvent("container-exit",{tracker:h.eventSource,pointerType:h.pointerType,position:h.position,buttons:h.buttons,pointers:h.pointers,insideElementPressed:h.insideElementPressed,buttonDownAny:h.buttonDownAny,originalEvent:h.originalEvent})}function Re(h){Be(h),h.isOpen()?h._updateRequestId=r(h,Re):h._updateRequestId=!1}function ye(h,v){var y=h.viewport,M=y.getZoom(),C=y.getCenter();y.resize(v,h.preserveImageSizeOnResize),y.panTo(C,!0);var U;if(h.preserveImageSizeOnResize)U=i[h.hash].prevContainerSize.x/v.x;else{var N=new t.Point(0,0),X=new t.Point(i[h.hash].prevContainerSize.x,i[h.hash].prevContainerSize.y).distanceTo(N),k=new t.Point(v.x,v.y).distanceTo(N);U=k/X*i[h.hash].prevContainerSize.x/v.x}y.zoomTo(M*U,null,!0),i[h.hash].prevContainerSize=v,i[h.hash].forceRedraw=!0,i[h.hash].needsResize=!1,i[h.hash].forceResize=!1}function Be(h){if(!(h._opening||!i[h.hash])){if(h.autoResize||i[h.hash].forceResize){var v;if(h._autoResizePolling){v=o(h.container);var y=i[h.hash].prevContainerSize;v.equals(y)||(i[h.hash].needsResize=!0)}i[h.hash].needsResize&&ye(h,v||o(h.container))}var M=h.viewport.update(),C=h.world.update()||M;M&&h.raiseEvent("viewport-change"),h.referenceStrip&&(C=h.referenceStrip.update(h.viewport)||C);var U=i[h.hash].animating;!U&&C&&(h.raiseEvent("animation-start"),m(h));var N=U&&!C;N&&(i[h.hash].animating=!1),(C||N||i[h.hash].forceRedraw||h.world.needsDraw())&&(Ie(h),h._drawOverlays(),h.navigator&&h.navigator.update(h.viewport),i[h.hash].forceRedraw=!1,C&&h.raiseEvent("animation")),N&&(h.raiseEvent("animation-finish"),i[h.hash].mouseInside||l(h)),i[h.hash].animating=C}}function Ie(h){h.imageLoader.clear(),h.drawer.clear(),h.world.draw(),h.raiseEvent("update-viewport",{})}function j(h,v){return h?h+v:v}function Le(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=this.zoomPerSecond,i[this.hash].zooming=!0,Ne(this)}function Xe(){i[this.hash].lastZoomTime=t.now(),i[this.hash].zoomFactor=1/this.zoomPerSecond,i[this.hash].zooming=!0,Ne(this)}function ke(){i[this.hash].zooming=!1}function Ne(h){t.requestAnimationFrame(t.delegate(h,ce))}function ce(){var h,v,y;i[this.hash].zooming&&this.viewport&&(h=t.now(),v=h-i[this.hash].lastZoomTime,y=Math.pow(i[this.hash].zoomFactor,v/1e3),this.viewport.zoomBy(y),this.viewport.applyConstraints(),i[this.hash].lastZoomTime=h,Ne(this))}function Qe(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(this.zoomPerClick/1),this.viewport.applyConstraints())}function ge(){this.viewport&&(i[this.hash].zooming=!1,this.viewport.zoomBy(1/this.zoomPerClick),this.viewport.applyConstraints())}function He(){this.buttonGroup&&(this.buttonGroup.emulateEnter(),this.buttonGroup.emulateLeave())}function _e(){this.viewport&&this.viewport.goHome()}function Oe(){this.isFullPage()&&!t.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage()),this.buttonGroup&&this.buttonGroup.emulateLeave(),this.fullPageButton.element.focus(),this.viewport&&this.viewport.applyConstraints()}function ze(){if(this.viewport){var h=this.viewport.getRotation();this.viewport.flipped?h+=this.rotationIncrement:h-=this.rotationIncrement,this.viewport.setRotation(h)}}function qe(){if(this.viewport){var h=this.viewport.getRotation();this.viewport.flipped?h-=this.rotationIncrement:h+=this.rotationIncrement,this.viewport.setRotation(h)}}function Ze(){this.viewport.toggleFlip()}})(L);(function(t){t.Navigator=function(r){var A=r.viewer,l=this,u,m;r.element||r.id?(r.element?(r.id&&t.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead."),r.element.id?r.id=r.element.id:r.id="navigator-"+t.now(),this.element=r.element):this.element=document.getElementById(r.id),r.controlOptions={anchor:t.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}):(r.id="navigator-"+t.now(),this.element=t.makeNeutralElement("div"),r.controlOptions={anchor:t.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:r.autoFade},r.position&&(r.position==="BOTTOM_RIGHT"?r.controlOptions.anchor=t.ControlAnchor.BOTTOM_RIGHT:r.position==="BOTTOM_LEFT"?r.controlOptions.anchor=t.ControlAnchor.BOTTOM_LEFT:r.position==="TOP_RIGHT"?r.controlOptions.anchor=t.ControlAnchor.TOP_RIGHT:r.position==="TOP_LEFT"?r.controlOptions.anchor=t.ControlAnchor.TOP_LEFT:r.position==="ABSOLUTE"&&(r.controlOptions.anchor=t.ControlAnchor.ABSOLUTE,r.controlOptions.top=r.top,r.controlOptions.left=r.left,r.controlOptions.height=r.height,r.controlOptions.width=r.width))),this.element.id=r.id,this.element.className+=" navigator",r=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.navigatorSizeRatio},r,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:r.animationTime,autoResize:!1,minZoomImageRatio:1,background:r.background,opacity:r.opacity,borderColor:r.borderColor,displayRegionColor:r.displayRegionColor}),r.minPixelRatio=this.minPixelRatio=A.minPixelRatio,t.setElementTouchActionNone(this.element),this.borderWidth=2,this.fudge=new t.Point(1,1),this.totalBorderWidths=new t.Point(this.borderWidth*2,this.borderWidth*2).minus(this.fudge),r.controlOptions.anchor!==t.ControlAnchor.NONE&&function(b,x){b.margin="0px",b.border=x+"px solid "+r.borderColor,b.padding="0px",b.background=r.background,b.opacity=r.opacity,b.overflow="hidden"}(this.element.style,this.borderWidth),this.displayRegion=t.makeNeutralElement("div"),this.displayRegion.id=this.element.id+"-displayregion",this.displayRegion.className="displayregion",function(b,x){b.position="relative",b.top="0px",b.left="0px",b.fontSize="0px",b.overflow="hidden",b.border=x+"px solid "+r.displayRegionColor,b.margin="0px",b.padding="0px",b.background="transparent",b.float="left",b.cssFloat="left",b.styleFloat="left",b.zIndex=999999999,b.cursor="default"}(this.displayRegion.style,this.borderWidth),t.setElementPointerEventsNone(this.displayRegion),t.setElementTouchActionNone(this.displayRegion),this.displayRegionContainer=t.makeNeutralElement("div"),this.displayRegionContainer.id=this.element.id+"-displayregioncontainer",this.displayRegionContainer.className="displayregioncontainer",this.displayRegionContainer.style.width="100%",this.displayRegionContainer.style.height="100%",t.setElementPointerEventsNone(this.displayRegionContainer),t.setElementTouchActionNone(this.displayRegionContainer),A.addControl(this.element,r.controlOptions),this._resizeWithViewer=r.controlOptions.anchor!==t.ControlAnchor.ABSOLUTE&&r.controlOptions.anchor!==t.ControlAnchor.NONE,r.width&&r.height?(this.setWidth(r.width),this.setHeight(r.height)):this._resizeWithViewer&&(u=t.getElementSize(A.element),this.element.style.height=Math.round(u.y*r.sizeRatio)+"px",this.element.style.width=Math.round(u.x*r.sizeRatio)+"px",this.oldViewerSize=u,m=t.getElementSize(this.element),this.elementArea=m.x*m.y),this.oldContainerSize=new t.Point(0,0),t.Viewer.apply(this,[r]),this.displayRegionContainer.appendChild(this.displayRegion),this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function p(b){n(l.displayRegionContainer,b),n(l.displayRegion,-b),l.viewport.setRotation(b)}if(r.navigatorRotate){var w=r.viewer.viewport?r.viewer.viewport.getRotation():r.viewer.degrees||0;p(w),r.viewer.addHandler("rotate",function(b){p(b.degrees)})}this.innerTracker.destroy(),this.innerTracker=new t.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:t.delegate(this,e),clickHandler:t.delegate(this,i),releaseHandler:t.delegate(this,o),scrollHandler:t.delegate(this,a),preProcessEventHandler:function(b){b.eventType==="wheel"&&(b.preventDefault=!0)}}),this.outerTracker.userData="Navigator.outerTracker",t.setElementPointerEventsNone(this.canvas),t.setElementPointerEventsNone(this.container),this.addHandler("reset-size",function(){l.viewport&&l.viewport.goHome(!0)}),A.world.addHandler("item-index-change",function(b){window.setTimeout(function(){var x=l.world.getItemAt(b.previousIndex);l.world.setItemIndex(x,b.newIndex)},1)}),A.world.addHandler("remove-item",function(b){var x=b.item,I=l._getMatchingItem(x);I&&l.world.removeItem(I)}),this.update(A.viewport)},t.extend(t.Navigator.prototype,t.EventSource.prototype,t.Viewer.prototype,{updateSize:function(){if(this.viewport){var r=new t.Point(this.container.clientWidth===0?1:this.container.clientWidth,this.container.clientHeight===0?1:this.container.clientHeight);r.equals(this.oldContainerSize)||(this.viewport.resize(r,!0),this.viewport.goHome(!0),this.oldContainerSize=r,this.drawer.clear(),this.world.draw())}},setWidth:function(r){this.width=r,this.element.style.width=typeof r=="number"?r+"px":r,this._resizeWithViewer=!1},setHeight:function(r){this.height=r,this.element.style.height=typeof r=="number"?r+"px":r,this._resizeWithViewer=!1},setFlip:function(r){return this.viewport.setFlip(r),this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)"),this},setDisplayTransform:function(r){s(this.displayRegion,r),s(this.canvas,r),s(this.element,r)},update:function(r){var A,l,u,m,p,w;if(A=t.getElementSize(this.viewer.element),this._resizeWithViewer&&A.x&&A.y&&!A.equals(this.oldViewerSize)&&(this.oldViewerSize=A,this.maintainSizeRatio||!this.elementArea?(l=A.x*this.sizeRatio,u=A.y*this.sizeRatio):(l=Math.sqrt(this.elementArea*(A.x/A.y)),u=this.elementArea/l),this.element.style.width=Math.round(l)+"px",this.element.style.height=Math.round(u)+"px",this.elementArea||(this.elementArea=l*u),this.updateSize()),r&&this.viewport){m=r.getBoundsNoRotate(!0),p=this.viewport.pixelFromPointNoRotate(m.getTopLeft(),!1),w=this.viewport.pixelFromPointNoRotate(m.getBottomRight(),!1).minus(this.totalBorderWidths);var b=this.displayRegion.style;b.display=this.world.getItemCount()?"block":"none",b.top=Math.round(p.y)+"px",b.left=Math.round(p.x)+"px";var x=Math.abs(p.x-w.x),I=Math.abs(p.y-w.y);b.width=Math.round(Math.max(x,0))+"px",b.height=Math.round(Math.max(I,0))+"px"}},addTiledImage:function(r){var A=this,l=r.originalTiledImage;delete r.original;var u=t.extend({},r,{success:function(m){var p=m.item;p._originalForNavigator=l,A._matchBounds(p,l,!0),A._matchOpacity(p,l),A._matchCompositeOperation(p,l);function w(){A._matchBounds(p,l)}function b(){A._matchOpacity(p,l)}function x(){A._matchCompositeOperation(p,l)}l.addHandler("bounds-change",w),l.addHandler("clip-change",w),l.addHandler("opacity-change",b),l.addHandler("composite-operation-change",x)}});return t.Viewer.prototype.addTiledImage.apply(this,[u])},destroy:function(){return t.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(r){for(var A=this.world.getItemCount(),l,u=0;u<A;u++)if(l=this.world.getItemAt(u),l._originalForNavigator===r)return l;return null},_matchBounds:function(r,A,l){var u=A.getBoundsNoRotate();r.setPosition(u.getTopLeft(),l),r.setWidth(u.width,l),r.setRotation(A.getRotation(),l),r.setClip(A.getClip()),r.setFlip(A.getFlip())},_matchOpacity:function(r,A){r.setOpacity(A.opacity)},_matchCompositeOperation:function(r,A){r.setCompositeOperation(A.compositeOperation)}});function i(r){var A={tracker:r.eventSource,position:r.position,quick:r.quick,shift:r.shift,originalEvent:r.originalEvent,preventDefaultAction:!1};if(this.viewer.raiseEvent("navigator-click",A),!A.preventDefaultAction&&r.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(r.position.x=this.viewport.getContainerSize().x-r.position.x);var l=this.viewport.pointFromPixel(r.position);this.panVertical?this.panHorizontal||(l.x=this.viewer.viewport.getCenter(!0).x):l.y=this.viewer.viewport.getCenter(!0).y,this.viewer.viewport.panTo(l),this.viewer.viewport.applyConstraints()}}function e(r){var A={tracker:r.eventSource,position:r.position,delta:r.delta,speed:r.speed,direction:r.direction,shift:r.shift,originalEvent:r.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",A),!A.preventDefaultAction&&this.viewer.viewport&&(this.panHorizontal||(r.delta.x=0),this.panVertical||(r.delta.y=0),this.viewer.viewport.flipped&&(r.delta.x=-r.delta.x),this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(r.delta)),this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints())}function o(r){r.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function a(r){var A={tracker:r.eventSource,position:r.position,scroll:r.scroll,shift:r.shift,originalEvent:r.originalEvent,preventDefault:r.preventDefault};this.viewer.raiseEvent("navigator-scroll",A),r.preventDefault=A.preventDefault}function n(r,A){s(r,"rotate("+A+"deg)")}function s(r,A){r.style.webkitTransform=A,r.style.mozTransform=A,r.style.msTransform=A,r.style.oTransform=A,r.style.transform=A}})(L);(function(t){var i={Errors:{Dzc:"Sorry, we don't support Deep Zoom Collections!",Dzi:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",Xml:"Hmm, this doesn't appear to be a valid Deep Zoom Image.",ImageFormat:"Sorry, we don't support {0}-based Deep Zoom Images.",Security:"It looks like a security restriction stopped us from loading this Deep Zoom Image.",Status:"This space unintentionally left blank ({0} {1}).",OpenFailed:"Unable to open {0}: {1}"},Tooltips:{FullPage:"Toggle full page",Home:"Go home",ZoomIn:"Zoom in",ZoomOut:"Zoom out",NextPage:"Next page",PreviousPage:"Previous page",RotateLeft:"Rotate left",RotateRight:"Rotate right",Flip:"Flip Horizontally"}};t.extend(t,{getString:function(e){var o=e.split("."),a=null,n=arguments,s=i,r;for(r=0;r<o.length-1;r++)s=s[o[r]]||{};return a=s[o[r]],typeof a!="string"&&(t.console.error("Untranslated source string:",e),a=""),a.replace(/\{\d+\}/g,function(A){var l=parseInt(A.match(/\d+/),10)+1;return l<n.length?n[l]:""})},setString:function(e,o){var a=e.split("."),n=i,s;for(s=0;s<a.length-1;s++)n[a[s]]||(n[a[s]]={}),n=n[a[s]];n[a[s]]=o}})})(L);(function(t){t.Point=function(i,e){this.x=typeof i=="number"?i:0,this.y=typeof e=="number"?e:0},t.Point.prototype={clone:function(){return new t.Point(this.x,this.y)},plus:function(i){return new t.Point(this.x+i.x,this.y+i.y)},minus:function(i){return new t.Point(this.x-i.x,this.y-i.y)},times:function(i){return new t.Point(this.x*i,this.y*i)},divide:function(i){return new t.Point(this.x/i,this.y/i)},negate:function(){return new t.Point(-this.x,-this.y)},distanceTo:function(i){return Math.sqrt(Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2))},squaredDistanceTo:function(i){return Math.pow(this.x-i.x,2)+Math.pow(this.y-i.y,2)},apply:function(i){return new t.Point(i(this.x),i(this.y))},equals:function(i){return i instanceof t.Point&&this.x===i.x&&this.y===i.y},rotate:function(i,e){e=e||new t.Point(0,0);var o,a;if(i%90===0){var n=t.positiveModulo(i,360);switch(n){case 0:o=1,a=0;break;case 90:o=0,a=1;break;case 180:o=-1,a=0;break;case 270:o=0,a=-1;break}}else{var s=i*Math.PI/180;o=Math.cos(s),a=Math.sin(s)}var r=o*(this.x-e.x)-a*(this.y-e.y)+e.x,A=a*(this.x-e.x)+o*(this.y-e.y)+e.y;return new t.Point(r,A)},toString:function(){return"("+Math.round(this.x*100)/100+","+Math.round(this.y*100)/100+")"}}})(L);(function(t){t.TileSource=function(e,o,a,n,s,r){var A=this,l=arguments,u,m;if(t.isPlainObject(e)?u=e:u={width:l[0],height:l[1],tileSize:l[2],tileOverlap:l[3],minLevel:l[4],maxLevel:l[5]},t.EventSource.call(this),t.extend(!0,this,u),!this.success){for(m=0;m<arguments.length;m++)if(t.isFunction(arguments[m])){this.success=arguments[m];break}}this.success&&this.addHandler("ready",function(p){A.success(p)}),t.type(arguments[0])==="string"&&(this.url=arguments[0]),this.url?(this.aspectRatio=1,this.dimensions=new t.Point(10,10),this._tileWidth=0,this._tileHeight=0,this.tileOverlap=0,this.minLevel=0,this.maxLevel=0,this.ready=!1,this.getImageInfo(this.url)):(this.ready=!0,this.aspectRatio=u.width&&u.height?u.width/u.height:1,this.dimensions=new t.Point(u.width,u.height),this.tileSize?(this._tileWidth=this._tileHeight=this.tileSize,delete this.tileSize):(this.tileWidth?(this._tileWidth=this.tileWidth,delete this.tileWidth):this._tileWidth=0,this.tileHeight?(this._tileHeight=this.tileHeight,delete this.tileHeight):this._tileHeight=0),this.tileOverlap=u.tileOverlap?u.tileOverlap:0,this.minLevel=u.minLevel?u.minLevel:0,this.maxLevel=u.maxLevel!==void 0&&u.maxLevel!==null?u.maxLevel:u.width&&u.height?Math.ceil(Math.log(Math.max(u.width,u.height))/Math.log(2)):0,this.success&&t.isFunction(this.success)&&this.success(this))},t.TileSource.prototype={getTileSize:function(e){return t.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead"),this._tileWidth},getTileWidth:function(e){return this._tileWidth?this._tileWidth:this.getTileSize(e)},getTileHeight:function(e){return this._tileHeight?this._tileHeight:this.getTileSize(e)},setMaxLevel:function(e){this.maxLevel=e,this._memoizeLevelScale()},getLevelScale:function(e){return this._memoizeLevelScale(),this.getLevelScale(e)},_memoizeLevelScale:function(){var e={},o;for(o=0;o<=this.maxLevel;o++)e[o]=1/Math.pow(2,this.maxLevel-o);this.getLevelScale=function(a){return e[a]}},getNumTiles:function(e){var o=this.getLevelScale(e),a=Math.ceil(o*this.dimensions.x/this.getTileWidth(e)),n=Math.ceil(o*this.dimensions.y/this.getTileHeight(e));return new t.Point(a,n)},getPixelRatio:function(e){var o=this.dimensions.times(this.getLevelScale(e)),a=1/o.x*t.pixelDensityRatio,n=1/o.y*t.pixelDensityRatio;return new t.Point(a,n)},getClosestLevel:function(){var e,o;for(e=this.minLevel+1;e<=this.maxLevel&&(o=this.getNumTiles(e),!(o.x>1||o.y>1));e++);return e-1},getTileAtPoint:function(e,o){var a=o.x>=0&&o.x<=1&&o.y>=0&&o.y<=1/this.aspectRatio;t.console.assert(a,"[TileSource.getTileAtPoint] must be called with a valid point.");var n=this.dimensions.x*this.getLevelScale(e),s=o.x*n,r=o.y*n,A=Math.floor(s/this.getTileWidth(e)),l=Math.floor(r/this.getTileHeight(e));o.x>=1&&(A=this.getNumTiles(e).x-1);var u=1e-15;return o.y>=1/this.aspectRatio-u&&(l=this.getNumTiles(e).y-1),new t.Point(A,l)},getTileBounds:function(e,o,a,n){var s=this.dimensions.times(this.getLevelScale(e)),r=this.getTileWidth(e),A=this.getTileHeight(e),l=o===0?0:r*o-this.tileOverlap,u=a===0?0:A*a-this.tileOverlap,m=r+(o===0?1:2)*this.tileOverlap,p=A+(a===0?1:2)*this.tileOverlap,w=1/s.x;return m=Math.min(m,s.x-l),p=Math.min(p,s.y-u),n?new t.Rect(0,0,m,p):new t.Rect(l*w,u*w,m*w,p*w)},getImageInfo:function(e){var o=this,a,n,s,r,A,l,u;e&&(A=e.split("/"),l=A[A.length-1],u=l.lastIndexOf("."),u>-1&&(A[A.length-1]=l.slice(0,u)));var m=null;if(this.splitHashDataForPost){var p=e.indexOf("#");p!==-1&&(m=e.substring(p+1),e=e.substr(0,p))}n=function(w){typeof w=="string"&&(w=t.parseXml(w));var b=t.TileSource.determineType(o,w,e);if(!b){o.raiseEvent("open-failed",{message:"Unable to load TileSource",source:e});return}r=b.prototype.configure.apply(o,[w,e,m]),r.ajaxWithCredentials===void 0&&(r.ajaxWithCredentials=o.ajaxWithCredentials),s=new b(r),o.ready=!0,o.raiseEvent("ready",{tileSource:s})},e.match(/\.js$/)?(a=e.split("/").pop().replace(".js",""),t.jsonp({url:e,async:!1,callbackName:a,callback:n})):t.makeAjaxRequest({url:e,postData:m,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(w){var b=i(w);n(b)},error:function(w,b){var x;try{x="HTTP "+w.status+" attempting to load TileSource: "+e}catch{var I;typeof b>"u"||!b.toString?I="Unknown error":I=b.toString(),x=I+" attempting to load TileSource: "+e}t.console.error(x),o.raiseEvent("open-failed",{message:x,source:e,postData:m})}})},supports:function(e,o){return!1},configure:function(e,o,a){throw new Error("Method not implemented.")},getTileUrl:function(e,o,a){throw new Error("Method not implemented.")},getTilePostData:function(e,o,a){return null},getTileAjaxHeaders:function(e,o,a){return{}},getTileHashKey:function(e,o,a,n,s,r){function A(l){return s?l+"+"+JSON.stringify(s):l}return A(typeof n!="string"?e+"/"+o+"_"+a:n)},tileExists:function(e,o,a){var n=this.getNumTiles(e);return e>=this.minLevel&&e<=this.maxLevel&&o>=0&&a>=0&&o<n.x&&a<n.y},hasTransparency:function(e,o,a,n){return!!e||o.match(".png")},downloadTileStart:function(e){var o=e.userData,a=new Image;o.image=a,o.request=null;var n=function(s){if(!a){e.finish(null,o.request,"Image load failed: undefined Image instance.");return}a.onload=a.onerror=a.onabort=null,e.finish(s?null:a,o.request,s)};a.onload=function(){n()},a.onabort=a.onerror=function(){n("Image load aborted.")},e.loadWithAjax?o.request=t.makeAjaxRequest({url:e.src,withCredentials:e.ajaxWithCredentials,headers:e.ajaxHeaders,responseType:"arraybuffer",postData:e.postData,success:function(s){var r;try{r=new window.Blob([s.response])}catch(u){var A=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if(u.name==="TypeError"&&A){var l=new A;l.append(s.response),r=l.getBlob()}}r.size===0?n("Empty image response."):a.src=(window.URL||window.webkitURL).createObjectURL(r)},error:function(s){n("Image load aborted - XHR error")}}):(e.crossOriginPolicy!==!1&&(a.crossOrigin=e.crossOriginPolicy),a.src=e.src)},downloadTileAbort:function(e){e.userData.request&&e.userData.request.abort();var o=e.userData.image;e.userData.image&&(o.onload=o.onerror=o.onabort=null)},createTileCache:function(e,o,a){e._data=o},destroyTileCache:function(e){e._data=null,e._renderedContext=null},getTileCacheData:function(e){return e._data},getTileCacheDataAsImage:function(e){return e._data},getTileCacheDataAsContext2D:function(e){if(!e._renderedContext){var o=document.createElement("canvas");o.width=e._data.width,o.height=e._data.height,e._renderedContext=o.getContext("2d"),e._renderedContext.drawImage(e._data,0,0),e._data=null}return e._renderedContext}},t.extend(!0,t.TileSource.prototype,t.EventSource.prototype);function i(e){var o=e.responseText,a=e.status,n,s;if(e){if(e.status!==200&&e.status!==0)throw a=e.status,n=a===404?"Not Found":e.statusText,new Error(t.getString("Errors.Status",a,n))}else throw new Error(t.getString("Errors.Security"));if(o.match(/\s*<.*/))try{s=e.responseXML&&e.responseXML.documentElement?e.responseXML:t.parseXml(o)}catch{s=e.responseText}else if(o.match(/\s*[{[].*/))try{s=t.parseJSON(o)}catch{s=o}else s=o;return s}t.TileSource.determineType=function(e,o,a){var n;for(n in L)if(n.match(/.+TileSource$/)&&t.isFunction(L[n])&&t.isFunction(L[n].prototype.supports)&&L[n].prototype.supports.call(e,o,a))return L[n];return t.console.error("No TileSource was able to open %s %s",a,o),null}})(L);(function(t){t.DziTileSource=function(o,a,n,s,r,A,l,u,m){var p,w,b,x;if(t.isPlainObject(o)?x=o:x={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4],fileFormat:arguments[5],displayRects:arguments[6],minLevel:arguments[7],maxLevel:arguments[8]},this._levelRects={},this.tilesUrl=x.tilesUrl,this.fileFormat=x.fileFormat,this.displayRects=x.displayRects,this.displayRects)for(p=this.displayRects.length-1;p>=0;p--)for(w=this.displayRects[p],b=w.minLevel;b<=w.maxLevel;b++)this._levelRects[b]||(this._levelRects[b]=[]),this._levelRects[b].push(w);t.TileSource.apply(this,[x])},t.extend(t.DziTileSource.prototype,t.TileSource.prototype,{supports:function(o,a){var n;return o.Image?n=o.Image.xmlns:o.documentElement&&(o.documentElement.localName==="Image"||o.documentElement.tagName==="Image")&&(n=o.documentElement.namespaceURI),n=(n||"").toLowerCase(),n.indexOf("schemas.microsoft.com/deepzoom/2008")!==-1||n.indexOf("schemas.microsoft.com/deepzoom/2009")!==-1},configure:function(o,a,n){var s;return t.isPlainObject(o)?s=e(this,o):s=i(this,o),a&&!s.tilesUrl&&(s.tilesUrl=a.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/"),a.search(/\.(dzi|xml|js)\?/)!==-1?s.queryParams=a.match(/\?.*/):s.queryParams=""),s},getTileUrl:function(o,a,n){return[this.tilesUrl,o,"/",a,"_",n,".",this.fileFormat,this.queryParams].join("")},tileExists:function(o,a,n){var s=this._levelRects[o],r,A,l,u,m,p,w;if(this.minLevel&&o<this.minLevel||this.maxLevel&&o>this.maxLevel)return!1;if(!s||!s.length)return!0;for(w=s.length-1;w>=0;w--)if(r=s[w],!(o<r.minLevel||o>r.maxLevel)&&(A=this.getLevelScale(o),l=r.x*A,u=r.y*A,m=l+r.width*A,p=u+r.height*A,l=Math.floor(l/this._tileWidth),u=Math.floor(u/this._tileWidth),m=Math.ceil(m/this._tileWidth),p=Math.ceil(p/this._tileWidth),l<=a&&a<m&&u<=n&&n<p))return!0;return!1}});function i(o,a){if(!a||!a.documentElement)throw new Error(t.getString("Errors.Xml"));var n=a.documentElement,s=n.localName||n.tagName,r=a.documentElement.namespaceURI,A=null,l=[],u,m,p,w,b;if(s==="Image")try{if(w=n.getElementsByTagName("Size")[0],w===void 0&&(w=n.getElementsByTagNameNS(r,"Size")[0]),A={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:n.getAttribute("Url"),Format:n.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(n.getAttribute("Overlap"),10),TileSize:parseInt(n.getAttribute("TileSize"),10),Size:{Height:parseInt(w.getAttribute("Height"),10),Width:parseInt(w.getAttribute("Width"),10)}}},!t.imageFormatSupported(A.Image.Format))throw new Error(t.getString("Errors.ImageFormat",A.Image.Format.toUpperCase()));for(u=n.getElementsByTagName("DisplayRect"),u===void 0&&(u=n.getElementsByTagNameNS(r,"DisplayRect")[0]),b=0;b<u.length;b++)m=u[b],p=m.getElementsByTagName("Rect")[0],p===void 0&&(p=m.getElementsByTagNameNS(r,"Rect")[0]),l.push({Rect:{X:parseInt(p.getAttribute("X"),10),Y:parseInt(p.getAttribute("Y"),10),Width:parseInt(p.getAttribute("Width"),10),Height:parseInt(p.getAttribute("Height"),10),MinLevel:parseInt(m.getAttribute("MinLevel"),10),MaxLevel:parseInt(m.getAttribute("MaxLevel"),10)}});return l.length&&(A.Image.DisplayRect=l),e(o,A)}catch(T){throw T instanceof Error?T:new Error(t.getString("Errors.Dzi"))}else{if(s==="Collection")throw new Error(t.getString("Errors.Dzc"));if(s==="Error"){var x=n.getElementsByTagName("Message")[0],I=x.firstChild.nodeValue;throw new Error(I)}}throw new Error(t.getString("Errors.Dzi"))}function e(o,a){var n=a.Image,s=n.Url,r=n.Format,A=n.Size,l=n.DisplayRect||[],u=parseInt(A.Width,10),m=parseInt(A.Height,10),p=parseInt(n.TileSize,10),w=parseInt(n.Overlap,10),b=[],x,I;for(I=0;I<l.length;I++)x=l[I].Rect,b.push(new t.DisplayRect(parseInt(x.X,10),parseInt(x.Y,10),parseInt(x.Width,10),parseInt(x.Height,10),parseInt(x.MinLevel,10),parseInt(x.MaxLevel,10)));return t.extend(!0,{width:u,height:m,tileSize:p,tileOverlap:w,minLevel:null,maxLevel:null,tilesUrl:s,fileFormat:r,displayRects:b},a)}})(L);(function(t){t.IIIFTileSource=function(n){if(t.extend(!0,this,n),this._id=this["@id"]||this.id||this.identifier||null,!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");if(n.tileSizePerScaleFactor={},this.tileFormat=this.tileFormat||"jpg",this.version=n.version,this.tile_width&&this.tile_height)n.tileWidth=this.tile_width,n.tileHeight=this.tile_height;else if(this.tile_width)n.tileSize=this.tile_width;else if(this.tile_height)n.tileSize=this.tile_height;else if(this.tiles)if(this.tiles.length===1)n.tileWidth=this.tiles[0].width,n.tileHeight=this.tiles[0].height||this.tiles[0].width,this.scale_factors=this.tiles[0].scaleFactors;else{this.scale_factors=[];for(var s=0;s<this.tiles.length;s++)for(var r=0;r<this.tiles[s].scaleFactors.length;r++){var A=this.tiles[s].scaleFactors[r];this.scale_factors.push(A),n.tileSizePerScaleFactor[A]={width:this.tiles[s].width,height:this.tiles[s].height||this.tiles[s].width}}}else if(i(n)){for(var l=Math.min(this.height,this.width),u=[256,512,1024],m=[],p=0;p<u.length;p++)u[p]<=l&&m.push(u[p]);m.length>0?n.tileSize=Math.max.apply(null,m):n.tileSize=l}else this.sizes&&this.sizes.length>0?(this.emulateLegacyImagePyramid=!0,n.levels=e(this),t.extend(!0,n,{width:n.levels[n.levels.length-1].width,height:n.levels[n.levels.length-1].height,tileSize:Math.max(n.height,n.width),tileOverlap:0,minLevel:0,maxLevel:n.levels.length-1}),this.levels=n.levels):t.console.error("Nothing in the info.json to construct image pyramids from");if(!n.maxLevel&&!this.emulateLegacyImagePyramid)if(!this.scale_factors)n.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));else{var w=Math.max.apply(null,this.scale_factors);n.maxLevel=Math.round(Math.log(w)*Math.LOG2E)}t.TileSource.apply(this,[n])},t.extend(t.IIIFTileSource.prototype,t.TileSource.prototype,{supports:function(n,s){return n.protocol&&n.protocol==="http://iiif.io/api/image"||n["@context"]&&(n["@context"]==="http://library.stanford.edu/iiif/image-api/1.1/context.json"||n["@context"]==="http://iiif.io/api/image/1/context.json")||n.profile&&n.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html")===0||n.identifier&&n.width&&n.height?!0:!!(n.documentElement&&n.documentElement.tagName==="info"&&n.documentElement.namespaceURI==="http://library.stanford.edu/iiif/image-api/ns/")},configure:function(n,s,r){if(t.isPlainObject(n)){if(!n["@context"])n["@context"]="http://iiif.io/api/image/1.0/context.json",n["@id"]=s.replace("/info.json",""),n.version=1;else{var l=n["@context"];if(Array.isArray(l)){for(var u=0;u<l.length;u++)if(typeof l[u]=="string"&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(l[u])||l[u]==="http://library.stanford.edu/iiif/image-api/1.1/context.json")){l=l[u];break}}switch(l){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":n.version=1;break;case"http://iiif.io/api/image/2/context.json":n.version=2;break;case"http://iiif.io/api/image/3/context.json":n.version=3;break;default:t.console.error("Data has a @context property which contains no known IIIF context URI.")}}if(n.preferredFormats){for(var m=0;m<n.preferredFormats.length;m++)if(L.imageFormatSupported(n.preferredFormats[m])){n.tileFormat=n.preferredFormats[m];break}}return n}else{var A=o(n);return A["@context"]="http://iiif.io/api/image/1.0/context.json",A["@id"]=s.replace("/info.xml",""),A.version=1,A}},getTileWidth:function(n){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileWidth.call(this,n);var s=Math.pow(2,this.maxLevel-n);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[s]?this.tileSizePerScaleFactor[s].width:this._tileWidth},getTileHeight:function(n){if(this.emulateLegacyImagePyramid)return t.TileSource.prototype.getTileHeight.call(this,n);var s=Math.pow(2,this.maxLevel-n);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[s]?this.tileSizePerScaleFactor[s].height:this._tileHeight},getLevelScale:function(n){if(this.emulateLegacyImagePyramid){var s=NaN;return this.levels.length>0&&n>=this.minLevel&&n<=this.maxLevel&&(s=this.levels[n].width/this.levels[this.maxLevel].width),s}return t.TileSource.prototype.getLevelScale.call(this,n)},getNumTiles:function(n){if(this.emulateLegacyImagePyramid){var s=this.getLevelScale(n);return s?new t.Point(1,1):new t.Point(0,0)}return t.TileSource.prototype.getNumTiles.call(this,n)},getTileAtPoint:function(n,s){return this.emulateLegacyImagePyramid?new t.Point(0,0):t.TileSource.prototype.getTileAtPoint.call(this,n,s)},getTileUrl:function(n,s,r){if(this.emulateLegacyImagePyramid){var A=null;return this.levels.length>0&&n>=this.minLevel&&n<=this.maxLevel&&(A=this.levels[n].url),A}var l="0",u=Math.pow(.5,this.maxLevel-n),m=Math.round(this.width*u),p=Math.round(this.height*u),w,b,x,I,T,Z,Y,W,J,V,_,ae,oe,re;return w=this.getTileWidth(n),b=this.getTileHeight(n),x=Math.round(w/u),I=Math.round(b/u),this.version===1?oe="native."+this.tileFormat:oe="default."+this.tileFormat,m<w&&p<b?(this.version===2&&m===this.width?V="full":this.version===3&&m===this.width&&p===this.height?V="max":this.version===3?V=m+","+p:V=m+",",T="full"):(Z=s*x,Y=r*I,W=Math.min(x,this.width-Z),J=Math.min(I,this.height-Y),s===0&&r===0&&W===this.width&&J===this.height?T="full":T=[Z,Y,W,J].join(","),_=Math.round(W*u),ae=Math.round(J*u),this.version===2&&_===this.width?V="full":this.version===3&&_===this.width&&ae===this.height?V="max":this.version===3?V=_+","+ae:V=_+","),re=[this._id,T,V,l,oe].join("/"),re},__testonly__:{canBeTiled:i,constructLevels:e}});function i(n){var s=["http://library.stanford.edu/iiif/image-api/compliance.html#level0","http://library.stanford.edu/iiif/image-api/1.1/compliance.html#level0","http://iiif.io/api/image/2/level0.json","level0","https://iiif.io/api/image/3/level0.json"],r=Array.isArray(n.profile)?n.profile[0]:n.profile,A=s.indexOf(r)!==-1,l=!1;return n.version===2&&n.profile.length>1&&n.profile[1].supports&&(l=n.profile[1].supports.indexOf("sizeByW")!==-1),n.version===3&&n.extraFeatures&&(l=n.extraFeatures.indexOf("sizeByWh")!==-1),!A||l}function e(n){for(var s=[],r=0;r<n.sizes.length;r++)s.push({url:n._id+"/full/"+n.sizes[r].width+","+(n.version===3?n.sizes[r].height:"")+"/0/default."+n.tileFormat,width:n.sizes[r].width,height:n.sizes[r].height});return s.sort(function(A,l){return A.width-l.width})}function o(n){if(!n||!n.documentElement)throw new Error(t.getString("Errors.Xml"));var s=n.documentElement,r=s.tagName,A=null;if(r==="info")try{return A={},a(s,A),A}catch(l){throw l instanceof Error?l:new Error(t.getString("Errors.IIIF"))}throw new Error(t.getString("Errors.IIIF"))}function a(n,s,r){var A,l;if(n.nodeType===3&&r)l=n.nodeValue.trim(),l.match(/^\d*$/)&&(l=Number(l)),s[r]?(t.isArray(s[r])||(s[r]=[s[r]]),s[r].push(l)):s[r]=l;else if(n.nodeType===1)for(A=0;A<n.childNodes.length;A++)a(n.childNodes[A],s,n.nodeName)}})(L);(function(t){t.OsmTileSource=function(i,e,o,a,n){var s;t.isPlainObject(i)?s=i:s={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]},(!s.width||!s.height)&&(s.width=65572864,s.height=65572864),s.tileSize||(s.tileSize=256,s.tileOverlap=0),s.tilesUrl||(s.tilesUrl="http://tile.openstreetmap.org/"),s.minLevel=8,t.TileSource.apply(this,[s])},t.extend(t.OsmTileSource.prototype,t.TileSource.prototype,{supports:function(i,e){return i.type&&i.type==="openstreetmaps"},configure:function(i,e,o){return i},getTileUrl:function(i,e,o){return this.tilesUrl+(i-8)+"/"+e+"/"+o+".png"}})})(L);(function(t){t.TmsTileSource=function(i,e,o,a,n){var s;t.isPlainObject(i)?s=i:s={width:arguments[0],height:arguments[1],tileSize:arguments[2],tileOverlap:arguments[3],tilesUrl:arguments[4]};var r=Math.ceil(s.width/256)*256,A=Math.ceil(s.height/256)*256,l;r>A?l=r/256:l=A/256,s.maxLevel=Math.ceil(Math.log(l)/Math.log(2))-1,s.tileSize=256,s.width=r,s.height=A,t.TileSource.apply(this,[s])},t.extend(t.TmsTileSource.prototype,t.TileSource.prototype,{supports:function(i,e){return i.type&&i.type==="tiledmapservice"},configure:function(i,e,o){return i},getTileUrl:function(i,e,o){var a=this.getNumTiles(i).y-1;return this.tilesUrl+i+"/"+e+"/"+(a-o)+".png"}})})(L);(function(t){t.ZoomifyTileSource=function(i){typeof i.tileSize>"u"&&(i.tileSize=256),typeof i.fileFormat>"u"&&(i.fileFormat="jpg",this.fileFormat=i.fileFormat);var e={x:i.width,y:i.height};for(i.imageSizes=[{x:i.width,y:i.height}],i.gridSize=[this._getGridSize(i.width,i.height,i.tileSize)];parseInt(e.x,10)>i.tileSize||parseInt(e.y,10)>i.tileSize;)e.x=Math.floor(e.x/2),e.y=Math.floor(e.y/2),i.imageSizes.push({x:e.x,y:e.y}),i.gridSize.push(this._getGridSize(e.x,e.y,i.tileSize));i.imageSizes.reverse(),i.gridSize.reverse(),i.minLevel=0,i.maxLevel=i.gridSize.length-1,L.TileSource.apply(this,[i])},t.extend(t.ZoomifyTileSource.prototype,t.TileSource.prototype,{_getGridSize:function(i,e,o){return{x:Math.ceil(i/o),y:Math.ceil(e/o)}},_calculateAbsoluteTileNumber:function(i,e,o){for(var a=0,n={},s=0;s<i;s++)n=this.gridSize[s],a+=n.x*n.y;return n=this.gridSize[i],a+=n.x*o+e,a},supports:function(i,e){return i.type&&i.type==="zoomifytileservice"},configure:function(i,e,o){return i},getTileUrl:function(i,e,o){var a=0,n=this._calculateAbsoluteTileNumber(i,e,o);return a=Math.floor(n/256),this.tilesUrl+"TileGroup"+a+"/"+i+"-"+e+"-"+o+"."+this.fileFormat}})})(L);(function(t){t.LegacyTileSource=function(a){var n,s,r;t.isArray(a)&&(n={type:"legacy-image-pyramid",levels:a}),n.levels=i(n.levels),n.levels.length>0?(s=n.levels[n.levels.length-1].width,r=n.levels[n.levels.length-1].height):(s=0,r=0,t.console.error("No supported image formats found")),t.extend(!0,n,{width:s,height:r,tileSize:Math.max(r,s),tileOverlap:0,minLevel:0,maxLevel:n.levels.length>0?n.levels.length-1:0}),t.TileSource.apply(this,[n]),this.levels=n.levels},t.extend(t.LegacyTileSource.prototype,t.TileSource.prototype,{supports:function(a,n){return a.type&&a.type==="legacy-image-pyramid"||a.documentElement&&a.documentElement.getAttribute("type")==="legacy-image-pyramid"},configure:function(a,n,s){var r;return t.isPlainObject(a)?r=o(this,a):r=e(this,a),r},getLevelScale:function(a){var n=NaN;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(n=this.levels[a].width/this.levels[this.maxLevel].width),n},getNumTiles:function(a){var n=this.getLevelScale(a);return n?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(a,n,s){var r=null;return this.levels.length>0&&a>=this.minLevel&&a<=this.maxLevel&&(r=this.levels[a].url),r}});function i(a){var n=[],s,r;for(r=0;r<a.length;r++)s=a[r],s.height&&s.width&&s.url?n.push({url:s.url,width:Number(s.width),height:Number(s.height)}):t.console.error("Unsupported image format: %s",s.url?s.url:"<no URL>");return n.sort(function(A,l){return A.height-l.height})}function e(a,n){if(!n||!n.documentElement)throw new Error(t.getString("Errors.Xml"));var s=n.documentElement,r=s.tagName,A=null,l=[],u,m;if(r==="image")try{for(A={type:s.getAttribute("type"),levels:[]},l=s.getElementsByTagName("level"),m=0;m<l.length;m++)u=l[m],A.levels.push({url:u.getAttribute("url"),width:parseInt(u.getAttribute("width"),10),height:parseInt(u.getAttribute("height"),10)});return o(a,A)}catch(p){throw p instanceof Error?p:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if(r==="collection")throw new Error("Legacy Image Pyramid Collections not yet supported.");if(r==="error")throw new Error("Error: "+n)}throw new Error("Unknown element "+r)}function o(a,n){return n.levels}})(L);(function(t){t.ImageTileSource=function(i){i=t.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1,useCanvas:!0},i),t.TileSource.apply(this,[i])},t.extend(t.ImageTileSource.prototype,t.TileSource.prototype,{supports:function(i,e){return i.type&&i.type==="image"},configure:function(i,e,o){return i},getImageInfo:function(i){var e=this._image=new Image,o=this;this.crossOriginPolicy&&(e.crossOrigin=this.crossOriginPolicy),this.ajaxWithCredentials&&(e.useCredentials=this.ajaxWithCredentials),t.addEvent(e,"load",function(){o.width=e.naturalWidth,o.height=e.naturalHeight,o.aspectRatio=o.width/o.height,o.dimensions=new t.Point(o.width,o.height),o._tileWidth=o.width,o._tileHeight=o.height,o.tileOverlap=0,o.minLevel=0,o.levels=o._buildLevels(),o.maxLevel=o.levels.length-1,o.ready=!0,o.raiseEvent("ready",{tileSource:o})}),t.addEvent(e,"error",function(){o.raiseEvent("open-failed",{message:"Error loading image at "+i,source:i})}),e.src=i},getLevelScale:function(i){var e=NaN;return i>=this.minLevel&&i<=this.maxLevel&&(e=this.levels[i].width/this.levels[this.maxLevel].width),e},getNumTiles:function(i){var e=this.getLevelScale(i);return e?new t.Point(1,1):new t.Point(0,0)},getTileUrl:function(i,e,o){var a=null;return i>=this.minLevel&&i<=this.maxLevel&&(a=this.levels[i].url),a},getContext2D:function(i,e,o){var a=null;return i>=this.minLevel&&i<=this.maxLevel&&(a=this.levels[i].context2D),a},destroy:function(){this._freeupCanvasMemory()},_buildLevels:function(){var i=[{url:this._image.src,width:this._image.naturalWidth,height:this._image.naturalHeight}];if(!this.buildPyramid||!t.supportsCanvas||!this.useCanvas)return delete this._image,i;var e=this._image.naturalWidth,o=this._image.naturalHeight,a=document.createElement("canvas"),n=a.getContext("2d");if(a.width=e,a.height=o,n.drawImage(this._image,0,0,e,o),i[0].context2D=n,delete this._image,t.isCanvasTainted(a))return i;for(;e>=2&&o>=2;){e=Math.floor(e/2),o=Math.floor(o/2);var s=document.createElement("canvas"),r=s.getContext("2d");s.width=e,s.height=o,r.drawImage(a,0,0,e,o),i.splice(0,0,{context2D:r,width:e,height:o}),a=s,n=r}return i},_freeupCanvasMemory:function(){for(var i=0;i<this.levels.length;i++)this.levels[i].context2D&&(this.levels[i].context2D.canvas.height=0,this.levels[i].context2D.canvas.width=0)}})})(L);(function(t){t.TileSourceCollection=function(i,e,o,a){t.console.error("TileSourceCollection is deprecated; use World instead")}})(L);(function(t){t.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3},t.Button=function(r){var A=this;t.EventSource.call(this),t.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},r),this.element=r.element||t.makeNeutralElement("div"),r.element||(this.imgRest=t.makeTransparentImage(this.srcRest),this.imgGroup=t.makeTransparentImage(this.srcGroup),this.imgHover=t.makeTransparentImage(this.srcHover),this.imgDown=t.makeTransparentImage(this.srcDown),this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip,t.setElementPointerEventsNone(this.imgRest),t.setElementPointerEventsNone(this.imgGroup),t.setElementPointerEventsNone(this.imgHover),t.setElementPointerEventsNone(this.imgDown),this.element.style.position="relative",t.setElementTouchActionNone(this.element),this.imgGroup.style.position=this.imgHover.style.position=this.imgDown.style.position="absolute",this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top="0px",this.imgGroup.style.left=this.imgHover.style.left=this.imgDown.style.left="0px",this.imgHover.style.visibility=this.imgDown.style.visibility="hidden",t.Browser.vendor===t.BROWSERS.FIREFOX&&t.Browser.version<3&&(this.imgGroup.style.top=this.imgHover.style.top=this.imgDown.style.top=""),this.element.appendChild(this.imgRest),this.element.appendChild(this.imgGroup),this.element.appendChild(this.imgHover),this.element.appendChild(this.imgDown)),this.addHandler("press",this.onPress),this.addHandler("release",this.onRelease),this.addHandler("click",this.onClick),this.addHandler("enter",this.onEnter),this.addHandler("exit",this.onExit),this.addHandler("focus",this.onFocus),this.addHandler("blur",this.onBlur),this.currentState=t.ButtonState.GROUP,this.fadeBeginTime=null,this.shouldFade=!1,this.element.style.display="inline-block",this.element.style.position="relative",this.element.title=this.tooltip,this.tracker=new t.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(l){l.insideElementPressed?(n(A,t.ButtonState.DOWN),A.raiseEvent("enter",{originalEvent:l.originalEvent})):l.buttonDownAny||n(A,t.ButtonState.HOVER)},focusHandler:function(l){A.tracker.enterHandler(l),A.raiseEvent("focus",{originalEvent:l.originalEvent})},leaveHandler:function(l){s(A,t.ButtonState.GROUP),l.insideElementPressed&&A.raiseEvent("exit",{originalEvent:l.originalEvent})},blurHandler:function(l){A.tracker.leaveHandler(l),A.raiseEvent("blur",{originalEvent:l.originalEvent})},pressHandler:function(l){n(A,t.ButtonState.DOWN),A.raiseEvent("press",{originalEvent:l.originalEvent})},releaseHandler:function(l){l.insideElementPressed&&l.insideElementReleased?(s(A,t.ButtonState.HOVER),A.raiseEvent("release",{originalEvent:l.originalEvent})):l.insideElementPressed?s(A,t.ButtonState.GROUP):n(A,t.ButtonState.HOVER)},clickHandler:function(l){l.quick&&A.raiseEvent("click",{originalEvent:l.originalEvent})},keyHandler:function(l){l.keyCode===13?(A.raiseEvent("click",{originalEvent:l.originalEvent}),A.raiseEvent("release",{originalEvent:l.originalEvent}),l.preventDefault=!0):l.preventDefault=!1}}),s(this,t.ButtonState.REST)},t.extend(t.Button.prototype,t.EventSource.prototype,{notifyGroupEnter:function(){n(this,t.ButtonState.GROUP)},notifyGroupExit:function(){s(this,t.ButtonState.REST)},disable:function(){this.notifyGroupExit(),this.element.disabled=!0,this.tracker.setTracking(!1),t.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1,this.tracker.setTracking(!0),t.setElementOpacity(this.element,1,!0),this.notifyGroupEnter()},destroy:function(){this.imgRest&&(this.element.removeChild(this.imgRest),this.imgRest=null),this.imgGroup&&(this.element.removeChild(this.imgGroup),this.imgGroup=null),this.imgHover&&(this.element.removeChild(this.imgHover),this.imgHover=null),this.imgDown&&(this.element.removeChild(this.imgDown),this.imgDown=null),this.removeAllHandlers(),this.tracker.destroy(),this.element=null}});function i(r){t.requestAnimationFrame(function(){e(r)})}function e(r){var A,l,u;r.shouldFade&&(A=t.now(),l=A-r.fadeBeginTime,u=1-l/r.fadeLength,u=Math.min(1,u),u=Math.max(0,u),r.imgGroup&&t.setElementOpacity(r.imgGroup,u,!0),u>0&&i(r))}function o(r){r.shouldFade=!0,r.fadeBeginTime=t.now()+r.fadeDelay,window.setTimeout(function(){i(r)},r.fadeDelay)}function a(r){r.shouldFade=!1,r.imgGroup&&t.setElementOpacity(r.imgGroup,1,!0)}function n(r,A){r.element.disabled||(A>=t.ButtonState.GROUP&&r.currentState===t.ButtonState.REST&&(a(r),r.currentState=t.ButtonState.GROUP),A>=t.ButtonState.HOVER&&r.currentState===t.ButtonState.GROUP&&(r.imgHover&&(r.imgHover.style.visibility=""),r.currentState=t.ButtonState.HOVER),A>=t.ButtonState.DOWN&&r.currentState===t.ButtonState.HOVER&&(r.imgDown&&(r.imgDown.style.visibility=""),r.currentState=t.ButtonState.DOWN))}function s(r,A){r.element.disabled||(A<=t.ButtonState.HOVER&&r.currentState===t.ButtonState.DOWN&&(r.imgDown&&(r.imgDown.style.visibility="hidden"),r.currentState=t.ButtonState.HOVER),A<=t.ButtonState.GROUP&&r.currentState===t.ButtonState.HOVER&&(r.imgHover&&(r.imgHover.style.visibility="hidden"),r.currentState=t.ButtonState.GROUP),A<=t.ButtonState.REST&&r.currentState===t.ButtonState.GROUP&&(o(r),r.currentState=t.ButtonState.REST))}})(L);(function(t){t.ButtonGroup=function(i){t.extend(!0,this,{buttons:[],clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:t.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},i);var e=this.buttons.concat([]),o=this,a;if(this.element=i.element||t.makeNeutralElement("div"),!i.group)for(this.element.style.display="inline-block",a=0;a<e.length;a++)this.element.appendChild(e[a].element);t.setElementTouchActionNone(this.element),this.tracker=new t.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(n){var s;for(s=0;s<o.buttons.length;s++)o.buttons[s].notifyGroupEnter()},leaveHandler:function(n){var s;if(!n.insideElementPressed)for(s=0;s<o.buttons.length;s++)o.buttons[s].notifyGroupExit()}})},t.ButtonGroup.prototype={emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){var i=this.buttons.pop();this.element.removeChild(i.element),i.destroy()}this.tracker.destroy(),this.element=null}}})(L);(function(t){t.Rect=function(i,e,o,a,n){this.x=typeof i=="number"?i:0,this.y=typeof e=="number"?e:0,this.width=typeof o=="number"?o:0,this.height=typeof a=="number"?a:0,this.degrees=typeof n=="number"?n:0,this.degrees=t.positiveModulo(this.degrees,360);var s,r;this.degrees>=270?(s=this.getTopRight(),this.x=s.x,this.y=s.y,r=this.height,this.height=this.width,this.width=r,this.degrees-=270):this.degrees>=180?(s=this.getBottomRight(),this.x=s.x,this.y=s.y,this.degrees-=180):this.degrees>=90&&(s=this.getBottomLeft(),this.x=s.x,this.y=s.y,r=this.height,this.height=this.width,this.width=r,this.degrees-=90)},t.Rect.fromSummits=function(i,e,o){var a=i.distanceTo(e),n=i.distanceTo(o),s=e.minus(i),r=Math.atan(s.y/s.x);return s.x<0?r+=Math.PI:s.y<0&&(r+=2*Math.PI),new t.Rect(i.x,i.y,a,n,r/Math.PI*180)},t.Rect.prototype={clone:function(){return new t.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new t.Point(this.x,this.y)},getBottomRight:function(){return new t.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new t.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new t.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new t.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new t.Point(this.width,this.height)},equals:function(i){return i instanceof t.Rect&&this.x===i.x&&this.y===i.y&&this.width===i.width&&this.height===i.height&&this.degrees===i.degrees},times:function(i){return new t.Rect(this.x*i,this.y*i,this.width*i,this.height*i,this.degrees)},translate:function(i){return new t.Rect(this.x+i.x,this.y+i.y,this.width,this.height,this.degrees)},union:function(i){var e=this.getBoundingBox(),o=i.getBoundingBox(),a=Math.min(e.x,o.x),n=Math.min(e.y,o.y),s=Math.max(e.x+e.width,o.x+o.width),r=Math.max(e.y+e.height,o.y+o.height);return new t.Rect(a,n,s-a,r-n)},intersection:function(i){var e=1e-10,o=[],a=this.getTopLeft();i.containsPoint(a,e)&&o.push(a);var n=this.getTopRight();i.containsPoint(n,e)&&o.push(n);var s=this.getBottomLeft();i.containsPoint(s,e)&&o.push(s);var r=this.getBottomRight();i.containsPoint(r,e)&&o.push(r);var A=i.getTopLeft();this.containsPoint(A,e)&&o.push(A);var l=i.getTopRight();this.containsPoint(l,e)&&o.push(l);var u=i.getBottomLeft();this.containsPoint(u,e)&&o.push(u);var m=i.getBottomRight();this.containsPoint(m,e)&&o.push(m);for(var p=this._getSegments(),w=i._getSegments(),b=0;b<p.length;b++)for(var x=p[b],I=0;I<w.length;I++){var T=w[I],Z=Y(x[0],x[1],T[0],T[1]);Z&&o.push(Z)}function Y(re,le,Ee,Pe){var pe=le.minus(re),Re=Pe.minus(Ee),ye=-Re.x*pe.y+pe.x*Re.y;if(ye===0)return null;var Be=(pe.x*(re.y-Ee.y)-pe.y*(re.x-Ee.x))/ye,Ie=(Re.x*(re.y-Ee.y)-Re.y*(re.x-Ee.x))/ye;return-e<=Be&&Be<=1-e&&-e<=Ie&&Ie<=1-e?new t.Point(re.x+Ie*pe.x,re.y+Ie*pe.y):null}if(o.length===0)return null;for(var W=o[0].x,J=o[0].x,V=o[0].y,_=o[0].y,ae=1;ae<o.length;ae++){var oe=o[ae];oe.x<W&&(W=oe.x),oe.x>J&&(J=oe.x),oe.y<V&&(V=oe.y),oe.y>_&&(_=oe.y)}return new t.Rect(W,V,J-W,_-V)},_getSegments:function(){var i=this.getTopLeft(),e=this.getTopRight(),o=this.getBottomLeft(),a=this.getBottomRight();return[[i,e],[e,a],[a,o],[o,i]]},rotate:function(i,e){if(i=t.positiveModulo(i,360),i===0)return this.clone();e=e||this.getCenter();var o=this.getTopLeft().rotate(i,e),a=this.getTopRight().rotate(i,e),n=a.minus(o);n=n.apply(function(r){var A=1e-15;return Math.abs(r)<A?0:r});var s=Math.atan(n.y/n.x);return n.x<0?s+=Math.PI:n.y<0&&(s+=2*Math.PI),new t.Rect(o.x,o.y,this.width,this.height,s/Math.PI*180)},getBoundingBox:function(){if(this.degrees===0)return this.clone();var i=this.getTopLeft(),e=this.getTopRight(),o=this.getBottomLeft(),a=this.getBottomRight(),n=Math.min(i.x,e.x,o.x,a.x),s=Math.max(i.x,e.x,o.x,a.x),r=Math.min(i.y,e.y,o.y,a.y),A=Math.max(i.y,e.y,o.y,a.y);return new t.Rect(n,r,s-n,A-r)},getIntegerBoundingBox:function(){var i=this.getBoundingBox(),e=Math.floor(i.x),o=Math.floor(i.y),a=Math.ceil(i.width+i.x-e),n=Math.ceil(i.height+i.y-o);return new t.Rect(e,o,a,n)},containsPoint:function(i,e){e=e||0;var o=this.getTopLeft(),a=this.getTopRight(),n=this.getBottomLeft(),s=a.minus(o),r=n.minus(o);return(i.x-o.x)*s.x+(i.y-o.y)*s.y>=-e&&(i.x-a.x)*s.x+(i.y-a.y)*s.y<=e&&(i.x-o.x)*r.x+(i.y-o.y)*r.y>=-e&&(i.x-n.x)*r.x+(i.y-n.y)*r.y<=e},toString:function(){return"["+Math.round(this.x*100)/100+", "+Math.round(this.y*100)/100+", "+Math.round(this.width*100)/100+"x"+Math.round(this.height*100)/100+", "+Math.round(this.degrees*100)/100+"deg]"}}})(L);(function(t){var i={};t.ReferenceStrip=function(u){var m=this,p=u.viewer,w=t.getElementSize(p.element),b,x,I;for(u.id||(u.id="referencestrip-"+t.now(),this.element=t.makeNeutralElement("div"),this.element.id=u.id,this.element.className="referencestrip"),u=t.extend(!0,{sizeRatio:t.DEFAULT_SETTINGS.referenceStripSizeRatio,position:t.DEFAULT_SETTINGS.referenceStripPosition,scroll:t.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:t.DEFAULT_SETTINGS.clickTimeThreshold},u,{element:this.element}),t.extend(this,u),i[this.id]={animating:!1},this.minPixelRatio=this.viewer.minPixelRatio,this.element.tabIndex=0,x=this.element.style,x.marginTop="0px",x.marginRight="0px",x.marginBottom="0px",x.marginLeft="0px",x.left="0px",x.bottom="0px",x.border="0px",x.background="#000",x.position="relative",t.setElementTouchActionNone(this.element),t.setElementOpacity(this.element,.8),this.viewer=p,this.tracker=new t.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:t.delegate(this,e),dragHandler:t.delegate(this,o),scrollHandler:t.delegate(this,a),enterHandler:t.delegate(this,s),leaveHandler:t.delegate(this,r),keyDownHandler:t.delegate(this,A),keyHandler:t.delegate(this,l),preProcessEventHandler:function(T){T.eventType==="wheel"&&(T.preventDefault=!0)}}),u.width&&u.height?(this.element.style.width=u.width+"px",this.element.style.height=u.height+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):u.scroll==="horizontal"?(this.element.style.width=w.x*u.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.height=w.y*u.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.BOTTOM_LEFT})):(this.element.style.height=w.y*u.sizeRatio*p.tileSources.length+12*p.tileSources.length+"px",this.element.style.width=w.x*u.sizeRatio+"px",p.addControl(this.element,{anchor:t.ControlAnchor.TOP_LEFT})),this.panelWidth=w.x*this.sizeRatio+8,this.panelHeight=w.y*this.sizeRatio+8,this.panels=[],this.miniViewers={},I=0;I<p.tileSources.length;I++)b=t.makeNeutralElement("div"),b.id=this.element.id+"-"+I,b.style.width=m.panelWidth+"px",b.style.height=m.panelHeight+"px",b.style.display="inline",b.style.float="left",b.style.cssFloat="left",b.style.styleFloat="left",b.style.padding="2px",t.setElementTouchActionNone(b),t.setElementPointerEventsNone(b),this.element.appendChild(b),b.activePanel=!1,this.panels.push(b);n(this,this.scroll==="vertical"?w.y:w.x,0),this.setFocus(0)},t.ReferenceStrip.prototype={setFocus:function(u){var m=this.element.querySelector("#"+this.element.id+"-"+u),p=t.getElementSize(this.viewer.canvas),w=Number(this.element.style.width.replace("px","")),b=Number(this.element.style.height.replace("px","")),x=-Number(this.element.style.marginLeft.replace("px","")),I=-Number(this.element.style.marginTop.replace("px","")),T;this.currentSelected!==m&&(this.currentSelected&&(this.currentSelected.style.background="#000"),this.currentSelected=m,this.currentSelected.style.background="#999",this.scroll==="horizontal"?(T=Number(u)*(this.panelWidth+3),T>x+p.x-this.panelWidth?(T=Math.min(T,w-p.x),this.element.style.marginLeft=-T+"px",n(this,p.x,-T)):T<x&&(T=Math.max(0,T-p.x/2),this.element.style.marginLeft=-T+"px",n(this,p.x,-T))):(T=Number(u)*(this.panelHeight+3),T>I+p.y-this.panelHeight?(T=Math.min(T,b-p.y),this.element.style.marginTop=-T+"px",n(this,p.y,-T)):T<I&&(T=Math.max(0,T-p.y/2),this.element.style.marginTop=-T+"px",n(this,p.y,-T))),this.currentPage=u,s.call(this,{eventSource:this.tracker}))},update:function(){return!!i[this.id].animating},destroy:function(){if(this.miniViewers)for(var u in this.miniViewers)this.miniViewers[u].destroy();this.tracker.destroy(),this.element&&this.viewer.removeControl(this.element)}};function e(u){if(u.quick){var m;this.scroll==="horizontal"?m=Math.floor(u.position.x/this.panelWidth):m=Math.floor(u.position.y/this.panelHeight),this.viewer.goToPage(m)}this.element.focus()}function o(u){if(this.dragging=!0,this.element){var m=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),w=Number(this.element.style.width.replace("px","")),b=Number(this.element.style.height.replace("px","")),x=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?-u.delta.x>0?m>-(w-x.x)&&(this.element.style.marginLeft=m+u.delta.x*2+"px",n(this,x.x,m+u.delta.x*2)):-u.delta.x<0&&m<0&&(this.element.style.marginLeft=m+u.delta.x*2+"px",n(this,x.x,m+u.delta.x*2)):-u.delta.y>0?p>-(b-x.y)&&(this.element.style.marginTop=p+u.delta.y*2+"px",n(this,x.y,p+u.delta.y*2)):-u.delta.y<0&&p<0&&(this.element.style.marginTop=p+u.delta.y*2+"px",n(this,x.y,p+u.delta.y*2))}}function a(u){if(this.element){var m=Number(this.element.style.marginLeft.replace("px","")),p=Number(this.element.style.marginTop.replace("px","")),w=Number(this.element.style.width.replace("px","")),b=Number(this.element.style.height.replace("px","")),x=t.getElementSize(this.viewer.canvas);this.scroll==="horizontal"?u.scroll>0?m>-(w-x.x)&&(this.element.style.marginLeft=m-u.scroll*60+"px",n(this,x.x,m-u.scroll*60)):u.scroll<0&&m<0&&(this.element.style.marginLeft=m-u.scroll*60+"px",n(this,x.x,m-u.scroll*60)):u.scroll<0?p>x.y-b&&(this.element.style.marginTop=p+u.scroll*60+"px",n(this,x.y,p+u.scroll*60)):u.scroll>0&&p<0&&(this.element.style.marginTop=p+u.scroll*60+"px",n(this,x.y,p+u.scroll*60)),u.preventDefault=!0}}function n(u,m,p){var w,b,x,I,T,Z;for(u.scroll==="horizontal"?w=u.panelWidth:w=u.panelHeight,b=Math.ceil(m/w)+5,x=Math.ceil((Math.abs(p)+m)/w)+1,b=x-b,b=b<0?0:b,T=b;T<x&&T<u.panels.length;T++)if(Z=u.panels[T],!Z.activePanel){var Y,W=u.viewer.tileSources[T];W.referenceStripThumbnailUrl?Y={type:"image",url:W.referenceStripThumbnailUrl}:Y=W,I=new t.Viewer({id:Z.id,tileSources:[Y],element:Z,navigatorSizeRatio:u.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:u.viewer.loadTilesWithAjax,ajaxHeaders:u.viewer.ajaxHeaders,useCanvas:u.useCanvas}),t.setElementPointerEventsNone(I.canvas),t.setElementPointerEventsNone(I.container),I.innerTracker.setTracking(!1),I.outerTracker.setTracking(!1),u.miniViewers[Z.id]=I,Z.activePanel=!0}}function s(u){var m=u.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="0px":m.style.marginLeft="0px"}function r(u){var m=u.eventSource.element;this.scroll==="horizontal"?m.style.marginBottom="-"+t.getElementSize(m).y/2+"px":m.style.marginLeft="-"+t.getElementSize(m).x/2+"px"}function A(u){if(!u.ctrl&&!u.alt&&!u.meta)switch(u.keyCode){case 38:a.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),u.preventDefault=!0;break;case 40:a.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),u.preventDefault=!0;break;case 37:a.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),u.preventDefault=!0;break;case 39:a.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),u.preventDefault=!0;break;default:u.preventDefault=!1;break}else u.preventDefault=!1}function l(u){if(!u.ctrl&&!u.alt&&!u.meta)switch(u.keyCode){case 61:a.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),u.preventDefault=!0;break;case 45:a.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),u.preventDefault=!0;break;case 48:case 119:case 87:a.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),u.preventDefault=!0;break;case 115:case 83:a.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),u.preventDefault=!0;break;case 97:a.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null}),u.preventDefault=!0;break;case 100:a.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null}),u.preventDefault=!0;break;default:u.preventDefault=!1;break}else u.preventDefault=!1}})(L);(function(t){t.DisplayRect=function(i,e,o,a,n,s){t.Rect.apply(this,[i,e,o,a]),this.minLevel=n,this.maxLevel=s},t.extend(t.DisplayRect.prototype,t.Rect.prototype)})(L);(function(t){t.Spring=function(e){var o=arguments;typeof e!="object"&&(e={initial:o.length&&typeof o[0]=="number"?o[0]:void 0,springStiffness:o.length>1?o[1].springStiffness:5,animationTime:o.length>1?o[1].animationTime:1.5}),t.console.assert(typeof e.springStiffness=="number"&&e.springStiffness!==0,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number"),t.console.assert(typeof e.animationTime=="number"&&e.animationTime>=0,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0"),e.exponential&&(this._exponential=!0,delete e.exponential),t.extend(!0,this,e),this.current={value:typeof this.initial=="number"?this.initial:this._exponential?0:1,time:t.now()},t.console.assert(!this._exponential||this.current.value!==0,"[OpenSeadragon.Spring] value must be non-zero for exponential springs"),this.start={value:this.current.value,time:this.current.time},this.target={value:this.current.value,time:this.current.time},this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},t.Spring.prototype={resetTo:function(e){t.console.assert(!this._exponential||e!==0,"[OpenSeadragon.Spring.resetTo] target must be non-zero for exponential springs"),this.start.value=this.target.value=this.current.value=e,this.start.time=this.target.time=this.current.time=t.now(),this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},springTo:function(e){t.console.assert(!this._exponential||e!==0,"[OpenSeadragon.Spring.springTo] target must be non-zero for exponential springs"),this.start.value=this.current.value,this.start.time=this.current.time,this.target.value=e,this.target.time=this.start.time+1e3*this.animationTime,this._exponential&&(this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},shiftBy:function(e){this.start.value+=e,this.target.value+=e,this._exponential&&(t.console.assert(this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.shiftBy] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value))},setExponential:function(e){this._exponential=e,this._exponential&&(t.console.assert(this.current.value!==0&&this.target.value!==0&&this.start.value!==0,"[OpenSeadragon.Spring.setExponential] spring value must be non-zero for exponential springs"),this.start._logValue=Math.log(this.start.value),this.target._logValue=Math.log(this.target.value),this.current._logValue=Math.log(this.current.value))},update:function(){this.current.time=t.now();var e,o;this._exponential?(e=this.start._logValue,o=this.target._logValue):(e=this.start.value,o=this.target.value);var a=this.current.time>=this.target.time?o:e+(o-e)*i(this.springStiffness,(this.current.time-this.start.time)/(this.target.time-this.start.time)),n=this.current.value;return this._exponential?this.current.value=Math.exp(a):this.current.value=a,n!==this.current.value},isAtTargetValue:function(){return this.current.value===this.target.value}};function i(e,o){return(1-Math.exp(e*-o))/(1-Math.exp(-e))}})(L);(function(t){t.ImageJob=function(e){t.extend(!0,this,{timeout:t.DEFAULT_SETTINGS.timeout,jobId:null},e),this.data=null,this.userData={},this.errorMsg=null},t.ImageJob.prototype={start:function(){var e=this,o=this.abort;this.jobId=window.setTimeout(function(){e.finish(null,null,"Image load exceeded timeout ("+e.timeout+" ms)")},this.timeout),this.abort=function(){e.source.downloadTileAbort(e),typeof o=="function"&&o()},this.source.downloadTileStart(this)},finish:function(e,o,a){this.data=e,this.request=o,this.errorMsg=a,this.jobId&&window.clearTimeout(this.jobId),this.callback(this)}},t.ImageLoader=function(e){t.extend(!0,this,{jobLimit:t.DEFAULT_SETTINGS.imageLoaderLimit,timeout:t.DEFAULT_SETTINGS.timeout,jobQueue:[],jobsInProgress:0},e)},t.ImageLoader.prototype={addJob:function(e){if(!e.source){t.console.error("ImageLoader.prototype.addJob() requires [options.source]. TileSource since new API defines how images are fetched. Creating a dummy TileSource.");var o=t.TileSource.prototype;e.source={downloadTileStart:o.downloadTileStart,downloadTileAbort:o.downloadTileAbort}}var a=this,n=function(A){i(a,A,e.callback)},s={src:e.src,tile:e.tile||{},source:e.source,loadWithAjax:e.loadWithAjax,ajaxHeaders:e.loadWithAjax?e.ajaxHeaders:null,crossOriginPolicy:e.crossOriginPolicy,ajaxWithCredentials:e.ajaxWithCredentials,postData:e.postData,callback:n,abort:e.abort,timeout:this.timeout},r=new t.ImageJob(s);!this.jobLimit||this.jobsInProgress<this.jobLimit?(r.start(),this.jobsInProgress++):this.jobQueue.push(r)},clear:function(){for(var e=0;e<this.jobQueue.length;e++){var o=this.jobQueue[e];typeof o.abort=="function"&&o.abort()}this.jobQueue=[]}};function i(e,o,a){var n;e.jobsInProgress--,(!e.jobLimit||e.jobsInProgress<e.jobLimit)&&e.jobQueue.length>0&&(n=e.jobQueue.shift(),n.start(),e.jobsInProgress++),a(o.data,o.errorMsg,o.request)}})(L);(function(t){t.Tile=function(i,e,o,a,n,s,r,A,l,u,m,p){this.level=i,this.x=e,this.y=o,this.bounds=a,this.sourceBounds=u,this.exists=n,this._url=s,this.postData=m,this.context2D=r,this.loadWithAjax=A,this.ajaxHeaders=l,p===void 0&&(t.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used."),p=t.TileSource.prototype.getTileHashKey(i,e,o,s,l,m)),this.cacheKey=p,this.loaded=!1,this.loading=!1,this.element=null,this.imgElement=null,this.style=null,this.position=null,this.size=null,this.flipped=!1,this.blendStart=null,this.opacity=null,this.squaredDistance=null,this.visibility=null,this.hasTransparency=!1,this.beingDrawn=!1,this.lastTouchTime=0,this.isRightMost=!1,this.isBottomMost=!1},t.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},_hasTransparencyChannel:function(){return console.warn("Tile.prototype._hasTransparencyChannel() has been deprecated and will be removed in the future. Use TileSource.prototype.hasTransparency() instead."),!!this.context2D||this.getUrl().match(".png")},drawHTML:function(i){if(!this.cacheImageRecord){t.console.warn("[Tile.drawHTML] attempting to draw tile %s when it's not cached",this.toString());return}if(!this.loaded){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());return}if(!this.element){var e=this.getImage();if(!e)return;this.element=t.makeNeutralElement("div"),this.imgElement=e.cloneNode(),this.imgElement.style.msInterpolationMode="nearest-neighbor",this.imgElement.style.width="100%",this.imgElement.style.height="100%",this.style=this.element.style,this.style.position="absolute"}this.element.parentNode!==i&&i.appendChild(this.element),this.imgElement.parentNode!==this.element&&this.element.appendChild(this.imgElement),this.style.top=this.position.y+"px",this.style.left=this.position.x+"px",this.style.height=this.size.y+"px",this.style.width=this.size.x+"px",this.flipped&&(this.style.transform="scaleX(-1)"),t.setElementOpacity(this.element,this.opacity)},get image(){return t.console.error("[Tile.image] property has been deprecated. Use [Tile.prototype.getImage] instead."),this.getImage()},get url(){return t.console.error("[Tile.url] property has been deprecated. Use [Tile.prototype.getUrl] instead."),this.getUrl()},getImage:function(){return this.cacheImageRecord.getImage()},getUrl:function(){return typeof this._url=="function"?this._url():this._url},getCanvasContext:function(){return this.context2D||this.cacheImageRecord.getRenderedContext()},drawCanvas:function(i,e,o,a,n,s){var r=this.position.times(t.pixelDensityRatio),A=this.size.times(t.pixelDensityRatio),l;if(!this.context2D&&!this.cacheImageRecord){t.console.warn("[Tile.drawCanvas] attempting to draw tile %s when it's not cached",this.toString());return}if(l=this.getCanvasContext(),!this.loaded||!l){t.console.warn("Attempting to draw tile %s when it's not yet loaded.",this.toString());return}i.save(),i.globalAlpha=this.opacity,typeof o=="number"&&o!==1&&(r=r.times(o),A=A.times(o)),a instanceof t.Point&&(r=r.plus(a)),i.globalAlpha===1&&this.hasTransparency&&(n&&(r.x=Math.round(r.x),r.y=Math.round(r.y),A.x=Math.round(A.x),A.y=Math.round(A.y)),i.clearRect(r.x,r.y,A.x,A.y)),e({context:i,tile:this,rendered:l});var u,m;this.sourceBounds?(u=Math.min(this.sourceBounds.width,l.canvas.width),m=Math.min(this.sourceBounds.height,l.canvas.height)):(u=l.canvas.width,m=l.canvas.height),i.translate(r.x+A.x/2,0),this.flipped&&i.scale(-1,1),i.drawImage(l.canvas,0,0,u,m,-A.x/2,r.y,A.x,A.y),i.restore()},getScaleForEdgeSmoothing:function(){var i;if(this.cacheImageRecord)i=this.cacheImageRecord.getRenderedContext();else if(this.context2D)i=this.context2D;else return t.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString()),1;return i.canvas.width/(this.size.x*t.pixelDensityRatio)},getTranslationForEdgeSmoothing:function(i,e,o){var a=Math.max(1,Math.ceil((o.x-e.x)/2)),n=Math.max(1,Math.ceil((o.y-e.y)/2));return new t.Point(a,n).minus(this.position.times(t.pixelDensityRatio).times(i||1).apply(function(s){return s%1}))},unload:function(){this.imgElement&&this.imgElement.parentNode&&this.imgElement.parentNode.removeChild(this.imgElement),this.element&&this.element.parentNode&&this.element.parentNode.removeChild(this.element),this.element=null,this.imgElement=null,this.loaded=!1,this.loading=!1}}})(L);(function(t){t.OverlayPlacement=t.Placement,t.OverlayRotationMode=t.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3}),t.Overlay=function(i,e,o){var a;t.isPlainObject(i)?a=i:a={element:i,location:e,placement:o},this.element=a.element,this.style=a.element.style,this._init(a)},t.Overlay.prototype={_init:function(i){this.location=i.location,this.placement=i.placement===void 0?t.Placement.TOP_LEFT:i.placement,this.onDraw=i.onDraw,this.checkResize=i.checkResize===void 0?!0:i.checkResize,this.width=i.width===void 0?null:i.width,this.height=i.height===void 0?null:i.height,this.rotationMode=i.rotationMode||t.OverlayRotationMode.EXACT,this.location instanceof t.Rect&&(this.width=this.location.width,this.height=this.location.height,this.location=this.location.getTopLeft(),this.placement=t.Placement.TOP_LEFT),this.scales=this.width!==null&&this.height!==null,this.bounds=new t.Rect(this.location.x,this.location.y,this.width,this.height),this.position=this.location},adjust:function(i,e){var o=t.Placement.properties[this.placement];o&&(o.isHorizontallyCentered?i.x-=e.x/2:o.isRight&&(i.x-=e.x),o.isVerticallyCentered?i.y-=e.y/2:o.isBottom&&(i.y-=e.y))},destroy:function(){var i=this.element,e=this.style;i.parentNode&&(i.parentNode.removeChild(i),i.prevElementParent&&(e.display="none",document.body.appendChild(i))),this.onDraw=null,e.top="",e.left="",e.position="",this.width!==null&&(e.width=""),this.height!==null&&(e.height="");var o=t.getCssPropertyWithVendorPrefix("transformOrigin"),a=t.getCssPropertyWithVendorPrefix("transform");o&&a&&(e[o]="",e[a]="")},drawHTML:function(i,e){var o=this.element;o.parentNode!==i&&(o.prevElementParent=o.parentNode,o.prevNextSibling=o.nextSibling,i.appendChild(o),this.style.position="absolute",this.size=t.getElementSize(o));var a=this._getOverlayPositionAndSize(e),n=a.position,s=this.size=a.size,r=a.rotate;if(this.onDraw)this.onDraw(n,s,this.element);else{var A=this.style;A.left=n.x+"px",A.top=n.y+"px",this.width!==null&&(A.width=s.x+"px"),this.height!==null&&(A.height=s.y+"px");var l=t.getCssPropertyWithVendorPrefix("transformOrigin"),u=t.getCssPropertyWithVendorPrefix("transform");l&&u&&(r?(A[l]=this._getTransformOrigin(),A[u]="rotate("+r+"deg)"):(A[l]="",A[u]="")),A.display="block"}},_getOverlayPositionAndSize:function(i){var e=i.pixelFromPoint(this.location,!0),o=this._getSizeInPixels(i);this.adjust(e,o);var a=0;if(i.getRotation(!0)&&this.rotationMode!==t.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX&&this.width!==null&&this.height!==null){var n=new t.Rect(e.x,e.y,o.x,o.y),s=this._getBoundingBox(n,i.getRotation(!0));e=s.getTopLeft(),o=s.getSize()}else a=i.getRotation(!0);return{position:e,size:o,rotate:a}},_getSizeInPixels:function(i){var e=this.size.x,o=this.size.y;if(this.width!==null||this.height!==null){var a=i.deltaPixelsFromPointsNoRotate(new t.Point(this.width||0,this.height||0),!0);this.width!==null&&(e=a.x),this.height!==null&&(o=a.y)}if(this.checkResize&&(this.width===null||this.height===null)){var n=this.size=t.getElementSize(this.element);this.width===null&&(e=n.x),this.height===null&&(o=n.y)}return new t.Point(e,o)},_getBoundingBox:function(i,e){var o=this._getPlacementPoint(i);return i.rotate(e,o).getBoundingBox()},_getPlacementPoint:function(i){var e=new t.Point(i.x,i.y),o=t.Placement.properties[this.placement];return o&&(o.isHorizontallyCentered?e.x+=i.width/2:o.isRight&&(e.x+=i.width),o.isVerticallyCentered?e.y+=i.height/2:o.isBottom&&(e.y+=i.height)),e},_getTransformOrigin:function(){var i="",e=t.Placement.properties[this.placement];return e&&(e.isLeft?i="left":e.isRight&&(i="right"),e.isTop?i+=" top":e.isBottom&&(i+=" bottom")),i},update:function(i,e){var o=t.isPlainObject(i)?i:{location:i,placement:e};this._init({location:o.location||this.location,placement:o.placement!==void 0?o.placement:this.placement,onDraw:o.onDraw||this.onDraw,checkResize:o.checkResize||this.checkResize,width:o.width!==void 0?o.width:this.width,height:o.height!==void 0?o.height:this.height,rotationMode:o.rotationMode||this.rotationMode})},getBounds:function(i){t.console.assert(i,"A viewport must now be passed to Overlay.getBounds.");var e=this.width,o=this.height;if(e===null||o===null){var a=i.deltaPointsFromPixelsNoRotate(this.size,!0);e===null&&(e=a.x),o===null&&(o=a.y)}var n=this.location.clone();return this.adjust(n,new t.Point(e,o)),this._adjustBoundsForRotation(i,new t.Rect(n.x,n.y,e,o))},_adjustBoundsForRotation:function(i,e){if(!i||i.getRotation(!0)===0||this.rotationMode===t.OverlayRotationMode.EXACT)return e;if(this.rotationMode===t.OverlayRotationMode.BOUNDING_BOX){if(this.width===null||this.height===null)return e;var o=this._getOverlayPositionAndSize(i);return i.viewerElementToViewportRectangle(new t.Rect(o.position.x,o.position.y,o.size.x,o.size.y))}return e.rotate(-i.getRotation(!0),this._getPlacementPoint(e))}}})(L);(function(t){t.Drawer=function(i){t.console.assert(i.viewer,"[Drawer] options.viewer is required");var e=arguments;if(t.isPlainObject(i)||(i={source:e[0],viewport:e[1],element:e[2]}),t.console.assert(i.viewport,"[Drawer] options.viewport is required"),t.console.assert(i.element,"[Drawer] options.element is required"),i.source&&t.console.error("[Drawer] options.source is no longer accepted; use TiledImage instead"),this.viewer=i.viewer,this.viewport=i.viewport,this.debugGridColor=typeof i.debugGridColor=="string"?[i.debugGridColor]:i.debugGridColor||t.DEFAULT_SETTINGS.debugGridColor,i.opacity&&t.console.error("[Drawer] options.opacity is no longer accepted; set the opacity on the TiledImage instead"),this.useCanvas=t.supportsCanvas&&(this.viewer?this.viewer.useCanvas:!0),this.container=t.getElement(i.element),this.canvas=t.makeNeutralElement(this.useCanvas?"canvas":"div"),this.context=this.useCanvas?this.canvas.getContext("2d"):null,this.sketchCanvas=null,this.sketchContext=null,this.element=this.container,this.container.dir="ltr",this.useCanvas){var o=this._calculateCanvasSize();this.canvas.width=o.x,this.canvas.height=o.y}this.canvas.style.width="100%",this.canvas.style.height="100%",this.canvas.style.position="absolute",t.setElementOpacity(this.canvas,this.opacity,!0),t.setElementPointerEventsNone(this.canvas),t.setElementTouchActionNone(this.canvas),this.container.style.textAlign="left",this.container.appendChild(this.canvas),this._imageSmoothingEnabled=!0},t.Drawer.prototype={addOverlay:function(i,e,o,a){return t.console.error("drawer.addOverlay is deprecated. Use viewer.addOverlay instead."),this.viewer.addOverlay(i,e,o,a),this},updateOverlay:function(i,e,o){return t.console.error("drawer.updateOverlay is deprecated. Use viewer.updateOverlay instead."),this.viewer.updateOverlay(i,e,o),this},removeOverlay:function(i){return t.console.error("drawer.removeOverlay is deprecated. Use viewer.removeOverlay instead."),this.viewer.removeOverlay(i),this},clearOverlays:function(){return t.console.error("drawer.clearOverlays is deprecated. Use viewer.clearOverlays instead."),this.viewer.clearOverlays(),this},viewportCoordToDrawerCoord:function(i){var e=this.viewport.pixelFromPointNoRotate(i,!0);return new t.Point(e.x*t.pixelDensityRatio,e.y*t.pixelDensityRatio)},clipWithPolygons:function(i,e){if(this.useCanvas){var o=this._getContext(e);o.beginPath(),i.forEach(function(a){a.forEach(function(n,s){o[s===0?"moveTo":"lineTo"](n.x,n.y)})}),o.clip()}},setOpacity:function(i){t.console.error("drawer.setOpacity is deprecated. Use tiledImage.setOpacity instead.");for(var e=this.viewer.world,o=0;o<e.getItemCount();o++)e.getItemAt(o).setOpacity(i);return this},getOpacity:function(){t.console.error("drawer.getOpacity is deprecated. Use tiledImage.getOpacity instead.");for(var i=this.viewer.world,e=0,o=0;o<i.getItemCount();o++){var a=i.getItemAt(o).getOpacity();a>e&&(e=a)}return e},needsUpdate:function(){return t.console.error("[Drawer.needsUpdate] this function is deprecated. Use World.needsDraw instead."),this.viewer.world.needsDraw()},numTilesLoaded:function(){return t.console.error("[Drawer.numTilesLoaded] this function is deprecated. Use TileCache.numTilesLoaded instead."),this.viewer.tileCache.numTilesLoaded()},reset:function(){return t.console.error("[Drawer.reset] this function is deprecated. Use World.resetItems instead."),this.viewer.world.resetItems(),this},update:function(){return t.console.error("[Drawer.update] this function is deprecated. Use Drawer.clear and World.draw instead."),this.clear(),this.viewer.world.draw(),this},canRotate:function(){return this.useCanvas},destroy:function(){this.canvas.width=1,this.canvas.height=1,this.sketchCanvas=null,this.sketchContext=null},clear:function(){if(this.canvas.innerHTML="",this.useCanvas){var i=this._calculateCanvasSize();if((this.canvas.width!==i.x||this.canvas.height!==i.y)&&(this.canvas.width=i.x,this.canvas.height=i.y,this._updateImageSmoothingEnabled(this.context),this.sketchCanvas!==null)){var e=this._calculateSketchCanvasSize();this.sketchCanvas.width=e.x,this.sketchCanvas.height=e.y,this._updateImageSmoothingEnabled(this.sketchContext)}this._clear()}},_clear:function(i,e){if(this.useCanvas){var o=this._getContext(i);if(e)o.clearRect(e.x,e.y,e.width,e.height);else{var a=o.canvas;o.clearRect(0,0,a.width,a.height)}}},viewportToDrawerRectangle:function(i){var e=this.viewport.pixelFromPointNoRotate(i.getTopLeft(),!0),o=this.viewport.deltaPixelsFromPointsNoRotate(i.getSize(),!0);return new t.Rect(e.x*t.pixelDensityRatio,e.y*t.pixelDensityRatio,o.x*t.pixelDensityRatio,o.y*t.pixelDensityRatio)},drawTile:function(i,e,o,a,n,s,r){if(t.console.assert(i,"[Drawer.drawTile] tile is required"),t.console.assert(e,"[Drawer.drawTile] drawingHandler is required"),this.useCanvas){var A=this._getContext(o);a=a||1,i.drawCanvas(A,e,a,n,s,r)}else i.drawHTML(this.canvas)},_getContext:function(i){var e=this.context;if(i){if(this.sketchCanvas===null){this.sketchCanvas=document.createElement("canvas");var o=this._calculateSketchCanvasSize();if(this.sketchCanvas.width=o.x,this.sketchCanvas.height=o.y,this.sketchContext=this.sketchCanvas.getContext("2d"),this.viewport.getRotation()===0){var a=this;this.viewer.addHandler("rotate",function n(){if(a.viewport.getRotation()!==0){a.viewer.removeHandler("rotate",n);var s=a._calculateSketchCanvasSize();a.sketchCanvas.width=s.x,a.sketchCanvas.height=s.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}e=this.sketchContext}return e},saveContext:function(i){this.useCanvas&&this._getContext(i).save()},restoreContext:function(i){this.useCanvas&&this._getContext(i).restore()},setClip:function(i,e){if(this.useCanvas){var o=this._getContext(e);o.beginPath(),o.rect(i.x,i.y,i.width,i.height),o.clip()}},drawRectangle:function(i,e,o){if(this.useCanvas){var a=this._getContext(o);a.save(),a.fillStyle=e,a.fillRect(i.x,i.y,i.width,i.height),a.restore()}},blendSketch:function(i,e,o,a){var n=i;if(t.isPlainObject(n)||(n={opacity:i,scale:e,translate:o,compositeOperation:a}),!(!this.useCanvas||!this.sketchCanvas)){i=n.opacity,a=n.compositeOperation;var s=n.bounds;if(this.context.save(),this.context.globalAlpha=i,a&&(this.context.globalCompositeOperation=a),s)s.x<0&&(s.width+=s.x,s.x=0),s.x+s.width>this.canvas.width&&(s.width=this.canvas.width-s.x),s.y<0&&(s.height+=s.y,s.y=0),s.y+s.height>this.canvas.height&&(s.height=this.canvas.height-s.y),this.context.drawImage(this.sketchCanvas,s.x,s.y,s.width,s.height,s.x,s.y,s.width,s.height);else{e=n.scale||1,o=n.translate;var r=o instanceof t.Point?o:new t.Point(0,0),A=0,l=0;if(o){var u=this.sketchCanvas.width-this.canvas.width,m=this.sketchCanvas.height-this.canvas.height;A=Math.round(u/2),l=Math.round(m/2)}this.context.drawImage(this.sketchCanvas,r.x-A*e,r.y-l*e,(this.canvas.width+2*A)*e,(this.canvas.height+2*l)*e,-A,-l,this.canvas.width+2*A,this.canvas.height+2*l)}this.context.restore()}},drawDebugInfo:function(i,e,o,a){if(this.useCanvas){var n=this.viewer.world.getIndexOfItem(a)%this.debugGridColor.length,s=this.context;s.save(),s.lineWidth=2*t.pixelDensityRatio,s.font="small-caps bold "+13*t.pixelDensityRatio+"px arial",s.strokeStyle=this.debugGridColor[n],s.fillStyle=this.debugGridColor[n],this.viewport.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:this.viewport.getRotation(!0)}),a.getRotation(!0)%360!==0&&this._offsetForRotation({degrees:a.getRotation(!0),point:a.viewport.pixelFromPointNoRotate(a._getRotationPoint(!0),!0)}),a.viewport.getRotation(!0)%360===0&&a.getRotation(!0)%360===0&&a._drawer.viewer.viewport.getFlip()&&a._drawer._flip(),s.strokeRect(i.position.x*t.pixelDensityRatio,i.position.y*t.pixelDensityRatio,i.size.x*t.pixelDensityRatio,i.size.y*t.pixelDensityRatio);var r=(i.position.x+i.size.x/2)*t.pixelDensityRatio,A=(i.position.y+i.size.y/2)*t.pixelDensityRatio;s.translate(r,A),s.rotate(Math.PI/180*-this.viewport.getRotation(!0)),s.translate(-r,-A),i.x===0&&i.y===0&&(s.fillText("Zoom: "+this.viewport.getZoom(),i.position.x*t.pixelDensityRatio,(i.position.y-30)*t.pixelDensityRatio),s.fillText("Pan: "+this.viewport.getBounds().toString(),i.position.x*t.pixelDensityRatio,(i.position.y-20)*t.pixelDensityRatio)),s.fillText("Level: "+i.level,(i.position.x+10)*t.pixelDensityRatio,(i.position.y+20)*t.pixelDensityRatio),s.fillText("Column: "+i.x,(i.position.x+10)*t.pixelDensityRatio,(i.position.y+30)*t.pixelDensityRatio),s.fillText("Row: "+i.y,(i.position.x+10)*t.pixelDensityRatio,(i.position.y+40)*t.pixelDensityRatio),s.fillText("Order: "+o+" of "+e,(i.position.x+10)*t.pixelDensityRatio,(i.position.y+50)*t.pixelDensityRatio),s.fillText("Size: "+i.size.toString(),(i.position.x+10)*t.pixelDensityRatio,(i.position.y+60)*t.pixelDensityRatio),s.fillText("Position: "+i.position.toString(),(i.position.x+10)*t.pixelDensityRatio,(i.position.y+70)*t.pixelDensityRatio),this.viewport.getRotation(!0)%360!==0&&this._restoreRotationChanges(),a.getRotation(!0)%360!==0&&this._restoreRotationChanges(),a.viewport.getRotation(!0)%360===0&&a.getRotation(!0)%360===0&&a._drawer.viewer.viewport.getFlip()&&a._drawer._flip(),s.restore()}},debugRect:function(i){if(this.useCanvas){var e=this.context;e.save(),e.lineWidth=2*t.pixelDensityRatio,e.strokeStyle=this.debugGridColor[0],e.fillStyle=this.debugGridColor[0],e.strokeRect(i.x*t.pixelDensityRatio,i.y*t.pixelDensityRatio,i.width*t.pixelDensityRatio,i.height*t.pixelDensityRatio),e.restore()}},setImageSmoothingEnabled:function(i){this.useCanvas&&(this._imageSmoothingEnabled=i,this._updateImageSmoothingEnabled(this.context),this.viewer.forceRedraw())},_updateImageSmoothingEnabled:function(i){i.msImageSmoothingEnabled=this._imageSmoothingEnabled,i.imageSmoothingEnabled=this._imageSmoothingEnabled},getCanvasSize:function(i){var e=this._getContext(i).canvas;return new t.Point(e.width,e.height)},getCanvasCenter:function(){return new t.Point(this.canvas.width/2,this.canvas.height/2)},_offsetForRotation:function(i){var e=i.point?i.point.times(t.pixelDensityRatio):this.getCanvasCenter(),o=this._getContext(i.useSketch);o.save(),o.translate(e.x,e.y),this.viewer.viewport.flipped?(o.rotate(Math.PI/180*-i.degrees),o.scale(-1,1)):o.rotate(Math.PI/180*i.degrees),o.translate(-e.x,-e.y)},_flip:function(i){i=i||{};var e=i.point?i.point.times(t.pixelDensityRatio):this.getCanvasCenter(),o=this._getContext(i.useSketch);o.translate(e.x,0),o.scale(-1,1),o.translate(-e.x,0)},_restoreRotationChanges:function(i){var e=this._getContext(i);e.restore()},_calculateCanvasSize:function(){var i=t.pixelDensityRatio,e=this.viewport.getContainerSize();return{x:Math.round(e.x*i),y:Math.round(e.y*i)}},_calculateSketchCanvasSize:function(){var i=this._calculateCanvasSize();if(this.viewport.getRotation()===0)return i;var e=Math.ceil(Math.sqrt(i.x*i.x+i.y*i.y));return{x:e,y:e}}}})(L);(function(t){t.Viewport=function(i){var e=arguments;e.length&&e[0]instanceof t.Point&&(i={containerSize:e[0],contentSize:e[1],config:e[2]}),i.config&&(t.extend(!0,i,i.config),delete i.config),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i.margins||{}),delete i.margins,i.initialDegrees=i.degrees,delete i.degrees,t.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:t.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:t.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:t.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:t.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:t.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:t.DEFAULT_SETTINGS.degrees,flipped:t.DEFAULT_SETTINGS.flipped,homeFillsViewer:t.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:t.DEFAULT_SETTINGS.silenceMultiImageWarnings},i),this._updateContainerInnerSize(),this.centerSpringX=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.centerSpringY=new t.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.zoomSpring=new t.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime}),this.degreesSpring=new t.Spring({initial:i.initialDegrees,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,this._setContentBounds(new t.Rect(0,0,1,1),1),this.goHome(!0),this.update()},t.Viewport.prototype={get degrees(){return t.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead."),this.getRotation()},set degrees(i){t.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead."),this.rotateTo(i)},resetContentSize:function(i){return t.console.assert(i,"[Viewport.resetContentSize] contentSize is required"),t.console.assert(i instanceof t.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point"),t.console.assert(i.x>0,"[Viewport.resetContentSize] contentSize.x must be greater than 0"),t.console.assert(i.y>0,"[Viewport.resetContentSize] contentSize.y must be greater than 0"),this._setContentBounds(new t.Rect(0,0,1,i.y/i.x),i.x),this},setHomeBounds:function(i,e){t.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually."),this._setContentBounds(i,e)},_setContentBounds:function(i,e){t.console.assert(i,"[Viewport._setContentBounds] bounds is required"),t.console.assert(i instanceof t.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect"),t.console.assert(i.width>0,"[Viewport._setContentBounds] bounds.width must be greater than 0"),t.console.assert(i.height>0,"[Viewport._setContentBounds] bounds.height must be greater than 0"),this._contentBoundsNoRotate=i.clone(),this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(e),this._contentBounds=i.rotate(this.getRotation()).getBoundingBox(),this._contentSize=this._contentBounds.getSize().times(e),this._contentAspectRatio=this._contentSize.x/this._contentSize.y,this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:e,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var i=this._contentAspectRatio/this.getAspectRatio(),e;return this.homeFillsViewer?e=i>=1?i:1:e=i>=1?1:i,e/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var i=this._contentBounds.getCenter(),e=1/this.getHomeZoom(),o=e/this.getAspectRatio();return new t.Rect(i.x-e/2,i.y-o/2,e,o)},goHome:function(i){return this.viewer&&this.viewer.raiseEvent("home",{immediately:i}),this.fitBounds(this.getHomeBounds(),i)},getMinZoom:function(){var i=this.getHomeZoom(),e=this.minZoomLevel?this.minZoomLevel:this.minZoomImageRatio*i;return e},getMaxZoom:function(){var i=this.maxZoomLevel;return i||(i=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x,i/=this._contentBounds.width),Math.max(i,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new t.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return t.extend({},this._margins)},setMargins:function(i){t.console.assert(t.type(i)==="object","[Viewport.setMargins] margins must be an object"),this._margins=t.extend({left:0,top:0,right:0,bottom:0},i),this._updateContainerInnerSize(),this.viewer&&this.viewer.forceRedraw()},getBounds:function(i){return this.getBoundsNoRotate(i).rotate(-this.getRotation(i))},getBoundsNoRotate:function(i){var e=this.getCenter(i),o=1/this.getZoom(i),a=o/this.getAspectRatio();return new t.Rect(e.x-o/2,e.y-a/2,o,a)},getBoundsWithMargins:function(i){return this.getBoundsNoRotateWithMargins(i).rotate(-this.getRotation(i),this.getCenter(i))},getBoundsNoRotateWithMargins:function(i){var e=this.getBoundsNoRotate(i),o=this._containerInnerSize.x*this.getZoom(i);return e.x-=this._margins.left/o,e.y-=this._margins.top/o,e.width+=(this._margins.left+this._margins.right)/o,e.height+=(this._margins.top+this._margins.bottom)/o,e},getCenter:function(i){var e=new t.Point(this.centerSpringX.current.value,this.centerSpringY.current.value),o=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value),a,n,s,r,A,l,u,m;return i?e:this.zoomPoint?(a=this.pixelFromPoint(this.zoomPoint,!0),n=this.getZoom(),s=1/n,r=s/this.getAspectRatio(),A=new t.Rect(e.x-s/2,e.y-r/2,s,r),l=this._pixelFromPoint(this.zoomPoint,A),u=l.minus(a).rotate(-this.getRotation(!0)),m=u.divide(this._containerInnerSize.x*n),o.plus(m)):o},getZoom:function(i){return i?this.zoomSpring.current.value:this.zoomSpring.target.value},_applyZoomConstraints:function(i){return Math.max(Math.min(i,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(i){var e=this.viewportToViewerElementRectangle(i).getBoundingBox(),o=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox(),a=!1,n=!1;if(!this.wrapHorizontal){var s=e.x+e.width,r=o.x+o.width,A,l,u;e.width>o.width?A=this.visibilityRatio*o.width:A=this.visibilityRatio*e.width,l=o.x-s+A,u=r-e.x-A,A>o.width?(e.x+=(l+u)/2,a=!0):u<0?(e.x+=u,a=!0):l>0&&(e.x+=l,a=!0)}if(!this.wrapVertical){var m=e.y+e.height,p=o.y+o.height,w,b,x;e.height>o.height?w=this.visibilityRatio*o.height:w=this.visibilityRatio*e.height,b=o.y-m+w,x=p-e.y-w,w>o.height?(e.y+=(b+x)/2,n=!0):x<0?(e.y+=x,n=!0):b>0&&(e.y+=b,n=!0)}var I=a||n,T=I?this.viewerElementToViewportRectangle(e):i.clone();return T.xConstrained=a,T.yConstrained=n,T.constraintApplied=I,T},_raiseConstraintsEvent:function(i){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:i})},applyConstraints:function(i){var e=this.getZoom(),o=this._applyZoomConstraints(e);e!==o&&this.zoomTo(o,this.zoomPoint,i);var a=this.getConstrainedBounds(!1);return a.constraintApplied&&(this.fitBounds(a,i),this._raiseConstraintsEvent(i)),this},ensureVisible:function(i){return this.applyConstraints(i)},_fitBounds:function(i,e){e=e||{};var o=e.immediately||!1,a=e.constraints||!1,n=this.getAspectRatio(),s=i.getCenter(),r=new t.Rect(i.x,i.y,i.width,i.height,i.degrees+this.getRotation()).getBoundingBox();r.getAspectRatio()>=n?r.height=r.width/n:r.width=r.height*n,r.x=s.x-r.width/2,r.y=s.y-r.height/2;var A=1/r.width;if(o)return this.panTo(s,!0),this.zoomTo(A,null,!0),a&&this.applyConstraints(!0),this;var l=this.getCenter(!0),u=this.getZoom(!0);this.panTo(l,!0),this.zoomTo(u,null,!0);var m=this.getBounds(),p=this.getZoom();if(p===0||Math.abs(A/p-1)<1e-8)return this.zoomTo(A,null,!0),this.panTo(s,o),a&&this.applyConstraints(!1),this;if(a){this.panTo(s,!1),this.zoomTo(A,null,!1);var w=this.getConstrainedBounds();this.panTo(l,!0),this.zoomTo(u,null,!0),this.fitBounds(w)}else{var b=r.rotate(-this.getRotation()),x=b.getTopLeft().times(A).minus(m.getTopLeft().times(p)).divide(A-p);this.zoomTo(A,x,o)}return this},fitBounds:function(i,e){return this._fitBounds(i,{immediately:e,constraints:!1})},fitBoundsWithConstraints:function(i,e){return this._fitBounds(i,{immediately:e,constraints:!0})},fitVertically:function(i){var e=new t.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(e,i)},fitHorizontally:function(i){var e=new t.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(e,i)},getConstrainedBounds:function(i){var e,o;return e=this.getBounds(i),o=this._applyBoundaryConstraints(e),o},panBy:function(i,e){var o=new t.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);return this.panTo(o.plus(i),e)},panTo:function(i,e){return e?(this.centerSpringX.resetTo(i.x),this.centerSpringY.resetTo(i.y)):(this.centerSpringX.springTo(i.x),this.centerSpringY.springTo(i.y)),this.viewer&&this.viewer.raiseEvent("pan",{center:i,immediately:e}),this},zoomBy:function(i,e,o){return this.zoomTo(this.zoomSpring.target.value*i,e,o)},zoomTo:function(i,e,o){var a=this;return this.zoomPoint=e instanceof t.Point&&!isNaN(e.x)&&!isNaN(e.y)?e:null,o?this._adjustCenterSpringsForZoomPoint(function(){a.zoomSpring.resetTo(i)}):this.zoomSpring.springTo(i),this.viewer&&this.viewer.raiseEvent("zoom",{zoom:i,refPoint:e,immediately:o}),this},setRotation:function(i,e){return this.rotateTo(i,null,e)},getRotation:function(i){return i?this.degreesSpring.current.value:this.degreesSpring.target.value},setRotationWithPivot:function(i,e,o){return this.rotateTo(i,e,o)},rotateTo:function(i,e,o){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===i&&this.degreesSpring.isAtTargetValue())return this;if(this.rotationPivot=e instanceof t.Point&&!isNaN(e.x)&&!isNaN(e.y)?e:null,o)if(this.rotationPivot){var a=i-this._oldDegrees;if(!a)return this.rotationPivot=null,this;this._rotateAboutPivot(i)}else this.degreesSpring.resetTo(i);else{var n=t.positiveModulo(this.degreesSpring.current.value,360),s=t.positiveModulo(i,360),r=s-n;r>180?s-=360:r<-180&&(s+=360);var A=n-s;this.degreesSpring.resetTo(i+A),this.degreesSpring.springTo(i)}return this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor()),this.viewer.forceRedraw(),this.viewer.raiseEvent("rotate",{degrees:i,immediately:!!o,pivot:this.rotationPivot||this.getCenter()}),this},rotateBy:function(i,e,o){return this.rotateTo(this.degreesSpring.target.value+i,e,o)},resize:function(i,e){var o=this.getBoundsNoRotate(),a=o,n;return this.containerSize.x=i.x,this.containerSize.y=i.y,this._updateContainerInnerSize(),e&&(n=i.x/this.containerSize.x,a.width=o.width*n,a.height=a.width/this.getAspectRatio()),this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:i,maintain:e}),this.fitBounds(a,!0)},_updateContainerInnerSize:function(){this._containerInnerSize=new t.Point(Math.max(1,this.containerSize.x-(this._margins.left+this._margins.right)),Math.max(1,this.containerSize.y-(this._margins.top+this._margins.bottom)))},update:function(){var i=this;this._adjustCenterSpringsForZoomPoint(function(){i.zoomSpring.update()}),this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null),this.centerSpringX.update(),this.centerSpringY.update(),this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var e=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees;return this._oldCenterX=this.centerSpringX.current.value,this._oldCenterY=this.centerSpringY.current.value,this._oldZoom=this.zoomSpring.current.value,this._oldDegrees=this.degreesSpring.current.value,e},_rotateAboutPivot:function(i){var e=i===!0,o=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(o.x),this.centerSpringY.shiftBy(o.y),e?this.degreesSpring.update():this.degreesSpring.resetTo(i);var a=this.degreesSpring.current.value-this._oldDegrees,n=o.rotate(a*-1).times(-1);this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y)},_adjustCenterSpringsForZoomPoint:function(i){if(this.zoomPoint){var e=this.pixelFromPoint(this.zoomPoint,!0);i();var o=this.pixelFromPoint(this.zoomPoint,!0),a=o.minus(e),n=this.deltaPointsFromPixels(a,!0);this.centerSpringX.shiftBy(n.x),this.centerSpringY.shiftBy(n.y),this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else i()},deltaPixelsFromPointsNoRotate:function(i,e){return i.times(this._containerInnerSize.x*this.getZoom(e))},deltaPixelsFromPoints:function(i,e){return this.deltaPixelsFromPointsNoRotate(i.rotate(this.getRotation(e)),e)},deltaPointsFromPixelsNoRotate:function(i,e){return i.divide(this._containerInnerSize.x*this.getZoom(e))},deltaPointsFromPixels:function(i,e){return this.deltaPointsFromPixelsNoRotate(i,e).rotate(-this.getRotation(e))},pixelFromPointNoRotate:function(i,e){return this._pixelFromPointNoRotate(i,this.getBoundsNoRotate(e))},pixelFromPoint:function(i,e){return this._pixelFromPoint(i,this.getBoundsNoRotate(e))},_pixelFromPointNoRotate:function(i,e){return i.minus(e.getTopLeft()).times(this._containerInnerSize.x/e.width).plus(new t.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(i,e){return this._pixelFromPointNoRotate(i.rotate(this.getRotation(!0),this.getCenter(!0)),e)},pointFromPixelNoRotate:function(i,e){var o=this.getBoundsNoRotate(e);return i.minus(new t.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/o.width).plus(o.getTopLeft())},pointFromPixel:function(i,e){return this.pointFromPixelNoRotate(i,e).rotate(-this.getRotation(e),this.getCenter(e))},_viewportToImageDelta:function(i,e){var o=this._contentBoundsNoRotate.width;return new t.Point(i*this._contentSizeNoRotate.x/o,e*this._contentSizeNoRotate.x/o)},viewportToImageCoordinates:function(i,e){if(i instanceof t.Point)return this.viewportToImageCoordinates(i.x,i.y);if(this.viewer){var o=this.viewer.world.getItemCount();if(o>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(o===1){var a=this.viewer.world.getItemAt(0);return a.viewportToImageCoordinates(i,e,!0)}}return this._viewportToImageDelta(i-this._contentBoundsNoRotate.x,e-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(i,e){var o=this._contentBoundsNoRotate.width;return new t.Point(i/this._contentSizeNoRotate.x*o,e/this._contentSizeNoRotate.x*o)},imageToViewportCoordinates:function(i,e){if(i instanceof t.Point)return this.imageToViewportCoordinates(i.x,i.y);if(this.viewer){var o=this.viewer.world.getItemCount();if(o>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(o===1){var a=this.viewer.world.getItemAt(0);return a.imageToViewportCoordinates(i,e,!0)}}var n=this._imageToViewportDelta(i,e);return n.x+=this._contentBoundsNoRotate.x,n.y+=this._contentBoundsNoRotate.y,n},imageToViewportRectangle:function(i,e,o,a){var n=i;if(n instanceof t.Rect||(n=new t.Rect(i,e,o,a)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(s===1){var r=this.viewer.world.getItemAt(0);return r.imageToViewportRectangle(i,e,o,a,!0)}}var A=this.imageToViewportCoordinates(n.x,n.y),l=this._imageToViewportDelta(n.width,n.height);return new t.Rect(A.x,A.y,l.x,l.y,n.degrees)},viewportToImageRectangle:function(i,e,o,a){var n=i;if(n instanceof t.Rect||(n=new t.Rect(i,e,o,a)),this.viewer){var s=this.viewer.world.getItemCount();if(s>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(s===1){var r=this.viewer.world.getItemAt(0);return r.viewportToImageRectangle(i,e,o,a,!0)}}var A=this.viewportToImageCoordinates(n.x,n.y),l=this._viewportToImageDelta(n.width,n.height);return new t.Rect(A.x,A.y,l.x,l.y,n.degrees)},viewerElementToImageCoordinates:function(i){var e=this.pointFromPixel(i,!0);return this.viewportToImageCoordinates(e)},imageToViewerElementCoordinates:function(i){var e=this.imageToViewportCoordinates(i);return this.pixelFromPoint(e,!0)},windowToImageCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");var e=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(e)},imageToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");var e=this.imageToViewerElementCoordinates(i);return e.plus(t.getElementPosition(this.viewer.element))},viewerElementToViewportCoordinates:function(i){return this.pointFromPixel(i,!0)},viewportToViewerElementCoordinates:function(i){return this.pixelFromPoint(i,!0)},viewerElementToViewportRectangle:function(i){return t.Rect.fromSummits(this.pointFromPixel(i.getTopLeft(),!0),this.pointFromPixel(i.getTopRight(),!0),this.pointFromPixel(i.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(i){return t.Rect.fromSummits(this.pixelFromPoint(i.getTopLeft(),!0),this.pixelFromPoint(i.getTopRight(),!0),this.pixelFromPoint(i.getBottomLeft(),!0))},windowToViewportCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");var e=i.minus(t.getElementPosition(this.viewer.element));return this.viewerElementToViewportCoordinates(e)},viewportToWindowCoordinates:function(i){t.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");var e=this.viewportToViewerElementCoordinates(i);return e.plus(t.getElementPosition(this.viewer.element))},viewportToImageZoom:function(i){if(this.viewer){var e=this.viewer.world.getItemCount();if(e>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(e===1){var o=this.viewer.world.getItemAt(0);return o.viewportToImageZoom(i)}}var a=this._contentSizeNoRotate.x,n=this._containerInnerSize.x,s=this._contentBoundsNoRotate.width,r=n/a*s;return i*r},imageToViewportZoom:function(i){if(this.viewer){var e=this.viewer.world.getItemCount();if(e>1)this.silenceMultiImageWarnings||t.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image.");else if(e===1){var o=this.viewer.world.getItemAt(0);return o.imageToViewportZoom(i)}}var a=this._contentSizeNoRotate.x,n=this._containerInnerSize.x,s=this._contentBoundsNoRotate.width,r=a/n/s;return i*r},toggleFlip:function(){return this.setFlip(!this.getFlip()),this},getFlip:function(){return this.flipped},setFlip:function(i){return this.flipped===i?this:(this.flipped=i,this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip()),this.viewer.forceRedraw(),this.viewer.raiseEvent("flip",{flipped:i}),this)}}})(L);(function(t){t.TiledImage=function(n){var s=this;t.console.assert(n.tileCache,"[TiledImage] options.tileCache is required"),t.console.assert(n.drawer,"[TiledImage] options.drawer is required"),t.console.assert(n.viewer,"[TiledImage] options.viewer is required"),t.console.assert(n.imageLoader,"[TiledImage] options.imageLoader is required"),t.console.assert(n.source,"[TiledImage] options.source is required"),t.console.assert(!n.clip||n.clip instanceof t.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present"),t.EventSource.call(this),this._tileCache=n.tileCache,delete n.tileCache,this._drawer=n.drawer,delete n.drawer,this._imageLoader=n.imageLoader,delete n.imageLoader,n.clip instanceof t.Rect&&(this._clip=n.clip.clone()),delete n.clip;var r=n.x||0;delete n.x;var A=n.y||0;delete n.y,this.normHeight=n.source.dimensions.y/n.source.dimensions.x,this.contentAspectX=n.source.dimensions.x/n.source.dimensions.y;var l=1;n.width?(l=n.width,delete n.width,n.height&&(t.console.error("specifying both width and height to a tiledImage is not supported"),delete n.height)):n.height&&(l=n.height/this.normHeight,delete n.height);var u=n.fitBounds;delete n.fitBounds;var m=n.fitBoundsPlacement||L.Placement.CENTER;delete n.fitBoundsPlacement;var p=n.degrees||0;delete n.degrees,t.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastDrawn:[],lastResetTime:0,_midDraw:!1,_needsDraw:!0,_hasOpaqueTile:!1,_tilesLoading:0,springStiffness:t.DEFAULT_SETTINGS.springStiffness,animationTime:t.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:t.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:t.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:t.DEFAULT_SETTINGS.wrapVertical,immediateRender:t.DEFAULT_SETTINGS.immediateRender,blendTime:t.DEFAULT_SETTINGS.blendTime,alwaysBlend:t.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:t.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:t.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:t.DEFAULT_SETTINGS.iOSDevice,debugMode:t.DEFAULT_SETTINGS.debugMode,crossOriginPolicy:t.DEFAULT_SETTINGS.crossOriginPolicy,ajaxWithCredentials:t.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:t.DEFAULT_SETTINGS.placeholderFillStyle,opacity:t.DEFAULT_SETTINGS.opacity,preload:t.DEFAULT_SETTINGS.preload,compositeOperation:t.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:t.DEFAULT_SETTINGS.subPixelRoundingForTransparency},n),this._preload=this.preload,delete this.preload,this._fullyLoaded=!1,this._xSpring=new t.Spring({initial:r,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._ySpring=new t.Spring({initial:A,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._scaleSpring=new t.Spring({initial:l,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._degreesSpring=new t.Spring({initial:p,springStiffness:this.springStiffness,animationTime:this.animationTime}),this._updateForScale(),u&&this.fitBounds(u,m,!0),this._drawingHandler=function(w){s.viewer.raiseEvent("tile-drawing",t.extend({tiledImage:s},w))}},t.extend(t.TiledImage.prototype,t.EventSource.prototype,{needsDraw:function(){return this._needsDraw},getFullyLoaded:function(){return this._fullyLoaded},_setFullyLoaded:function(n){n!==this._fullyLoaded&&(this._fullyLoaded=n,this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded}))},reset:function(){this._tileCache.clearTilesFor(this),this.lastResetTime=t.now(),this._needsDraw=!0},update:function(){var n=this._xSpring.update(),s=this._ySpring.update(),r=this._scaleSpring.update(),A=this._degreesSpring.update();return n||s||r||A?(this._updateForScale(),this._needsDraw=!0,!0):!1},draw:function(){this.opacity!==0||this._preload?(this._midDraw=!0,this._updateViewport(),this._midDraw=!1):this._needsDraw=!1},destroy:function(){this.reset(),this.source.destroy&&this.source.destroy()},getBounds:function(n){return this.getBoundsNoRotate(n).rotate(this.getRotation(n),this._getRotationPoint(n))},getBoundsNoRotate:function(n){return n?new t.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new t.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){return t.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead"),this.getBounds()},getClippedBounds:function(n){var s=this.getBoundsNoRotate(n);if(this._clip){var r=n?this._worldWidthCurrent:this._worldWidthTarget,A=r/this.source.dimensions.x,l=this._clip.times(A);s=new t.Rect(s.x+l.x,s.y+l.y,l.width,l.height)}return s.rotate(this.getRotation(n),this._getRotationPoint(n))},getTileBounds:function(n,s,r){var A=this.source.getNumTiles(n),l=(A.x+s%A.x)%A.x,u=(A.y+r%A.y)%A.y,m=this.source.getTileBounds(n,l,u);return this.getFlip()&&(m.x=1-m.x-m.width),m.x+=(s-l)/A.x,m.y+=this._worldHeightCurrent/this._worldWidthCurrent*((r-u)/A.y),m},getContentSize:function(){return new t.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var n=this.imageToWindowCoordinates(new t.Point(0,0)),s=this.imageToWindowCoordinates(this.getContentSize());return new t.Point(s.x-n.x,s.y-n.y)},_viewportToImageDelta:function(n,s,r){var A=r?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(n*(this.source.dimensions.x/A),s*(this.source.dimensions.y*this.contentAspectX/A))},viewportToImageCoordinates:function(n,s,r){var A;return n instanceof t.Point?(r=s,A=n):A=new t.Point(n,s),A=A.rotate(-this.getRotation(r),this._getRotationPoint(r)),r?this._viewportToImageDelta(A.x-this._xSpring.current.value,A.y-this._ySpring.current.value):this._viewportToImageDelta(A.x-this._xSpring.target.value,A.y-this._ySpring.target.value)},_imageToViewportDelta:function(n,s,r){var A=r?this._scaleSpring.current.value:this._scaleSpring.target.value;return new t.Point(n/this.source.dimensions.x*A,s/this.source.dimensions.y/this.contentAspectX*A)},imageToViewportCoordinates:function(n,s,r){n instanceof t.Point&&(r=s,s=n.y,n=n.x);var A=this._imageToViewportDelta(n,s);return r?(A.x+=this._xSpring.current.value,A.y+=this._ySpring.current.value):(A.x+=this._xSpring.target.value,A.y+=this._ySpring.target.value),A.rotate(this.getRotation(r),this._getRotationPoint(r))},imageToViewportRectangle:function(n,s,r,A,l){var u=n;u instanceof t.Rect?l=s:u=new t.Rect(n,s,r,A);var m=this.imageToViewportCoordinates(u.getTopLeft(),l),p=this._imageToViewportDelta(u.width,u.height,l);return new t.Rect(m.x,m.y,p.x,p.y,u.degrees+this.getRotation(l))},viewportToImageRectangle:function(n,s,r,A,l){var u=n;n instanceof t.Rect?l=s:u=new t.Rect(n,s,r,A);var m=this.viewportToImageCoordinates(u.getTopLeft(),l),p=this._viewportToImageDelta(u.width,u.height,l);return new t.Rect(m.x,m.y,p.x,p.y,u.degrees-this.getRotation(l))},viewerElementToImageCoordinates:function(n){var s=this.viewport.pointFromPixel(n,!0);return this.viewportToImageCoordinates(s)},imageToViewerElementCoordinates:function(n){var s=this.imageToViewportCoordinates(n);return this.viewport.pixelFromPoint(s,!0)},windowToImageCoordinates:function(n){var s=n.minus(L.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(s)},imageToWindowCoordinates:function(n){var s=this.imageToViewerElementCoordinates(n);return s.plus(L.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(n){var s=this._scaleSpring.current.value;return n=n.rotate(-this.getRotation(!0),this._getRotationPoint(!0)),new t.Rect((n.x-this._xSpring.current.value)/s,(n.y-this._ySpring.current.value)/s,n.width/s,n.height/s,n.degrees)},viewportToImageZoom:function(n){var s=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return s*n},imageToViewportZoom:function(n){var s=this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x;return n/s},setPosition:function(n,s){var r=this._xSpring.target.value===n.x&&this._ySpring.target.value===n.y;if(s){if(r&&this._xSpring.current.value===n.x&&this._ySpring.current.value===n.y)return;this._xSpring.resetTo(n.x),this._ySpring.resetTo(n.y),this._needsDraw=!0}else{if(r)return;this._xSpring.springTo(n.x),this._ySpring.springTo(n.y),this._needsDraw=!0}r||this._raiseBoundsChange()},setWidth:function(n,s){this._setScale(n,s)},setHeight:function(n,s){this._setScale(n/this.normHeight,s)},setCroppingPolygons:function(n){var s=function(A){return A instanceof t.Point||typeof A.x=="number"&&typeof A.y=="number"},r=function(A){return A.map(function(l){try{if(s(l))return{x:l.x,y:l.y};throw new Error}catch{throw new Error("A Provided cropping polygon point is not supported")}})};try{if(!t.isArray(n))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=n.map(function(A){return r(A)})}catch(A){t.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported"),t.console.error(A),this._croppingPolygons=null}},resetCroppingPolygons:function(){this._croppingPolygons=null},fitBounds:function(n,s,r){s=s||t.Placement.CENTER;var A=t.Placement.properties[s],l=this.contentAspectX,u=0,m=0,p=1,w=1;if(this._clip&&(l=this._clip.getAspectRatio(),p=this._clip.width/this.source.dimensions.x,w=this._clip.height/this.source.dimensions.y,n.getAspectRatio()>l?(u=this._clip.x/this._clip.height*n.height,m=this._clip.y/this._clip.height*n.height):(u=this._clip.x/this._clip.width*n.width,m=this._clip.y/this._clip.width*n.width)),n.getAspectRatio()>l){var b=n.height/w,x=0;A.isHorizontallyCentered?x=(n.width-n.height*l)/2:A.isRight&&(x=n.width-n.height*l),this.setPosition(new t.Point(n.x-u+x,n.y-m),r),this.setHeight(b,r)}else{var I=n.width/p,T=0;A.isVerticallyCentered?T=(n.height-n.width/l)/2:A.isBottom&&(T=n.height-n.width/l),this.setPosition(new t.Point(n.x-u,n.y-m+T),r),this.setWidth(I,r)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(n){t.console.assert(!n||n instanceof t.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null"),n instanceof t.Rect?this._clip=n.clone():this._clip=null,this._needsDraw=!0,this.raiseEvent("clip-change")},getFlip:function(){return!!this.flipped},setFlip:function(n){this.flipped=!!n,this._needsDraw=!0,this._raiseBoundsChange()},getOpacity:function(){return this.opacity},setOpacity:function(n){n!==this.opacity&&(this.opacity=n,this._needsDraw=!0,this.raiseEvent("opacity-change",{opacity:this.opacity}))},getPreload:function(){return this._preload},setPreload:function(n){this._preload=!!n,this._needsDraw=!0},getRotation:function(n){return n?this._degreesSpring.current.value:this._degreesSpring.target.value},setRotation:function(n,s){this._degreesSpring.target.value===n&&this._degreesSpring.isAtTargetValue()||(s?this._degreesSpring.resetTo(n):this._degreesSpring.springTo(n),this._needsDraw=!0,this._raiseBoundsChange())},_getRotationPoint:function(n){return this.getBoundsNoRotate(n).getCenter()},getCompositeOperation:function(){return this.compositeOperation},setCompositeOperation:function(n){n!==this.compositeOperation&&(this.compositeOperation=n,this._needsDraw=!0,this.raiseEvent("composite-operation-change",{compositeOperation:this.compositeOperation}))},_setScale:function(n,s){var r=this._scaleSpring.target.value===n;if(s){if(r&&this._scaleSpring.current.value===n)return;this._scaleSpring.resetTo(n),this._updateForScale(),this._needsDraw=!0}else{if(r)return;this._scaleSpring.springTo(n),this._updateForScale(),this._needsDraw=!0}r||this._raiseBoundsChange()},_updateForScale:function(){this._worldWidthTarget=this._scaleSpring.target.value,this._worldHeightTarget=this.normHeight*this._scaleSpring.target.value,this._worldWidthCurrent=this._scaleSpring.current.value,this._worldHeightCurrent=this.normHeight*this._scaleSpring.current.value},_raiseBoundsChange:function(){this.raiseEvent("bounds-change")},_isBottomItem:function(){return this.viewer.world.getItemAt(0)===this},_getLevelsInterval:function(){var n=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2))),s=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value,r=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(s/this.minPixelRatio)/Math.log(2))));return r=Math.max(r,this.source.minLevel||0),n=Math.min(n,r),{lowestLevel:n,highestLevel:r}},_updateViewport:function(){for(this._needsDraw=!1,this._tilesLoading=0,this.loadingCoverage={};this.lastDrawn.length>0;){var n=this.lastDrawn.pop();n.beingDrawn=!1}var s=this.viewport,r=this._viewportToTiledImageRectangle(s.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var A=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));if(r=r.intersection(A),r===null)return}for(var l=this._getLevelsInterval(),u=l.lowestLevel,m=l.highestLevel,p=null,w=!1,b=t.now(),x=m;x>=u;x--){var I=!1,T=s.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(x),!0).x*this._scaleSpring.current.value;if(x===u||!w&&T>=this.minPixelRatio)I=!0,w=!0;else if(!w)continue;var Z=s.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(x),!1).x*this._scaleSpring.current.value,Y=s.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value,W=this.immediateRender?1:Y,J=Math.min(1,(T-.5)/.5),V=W/Math.abs(W-Z);if(p=this._updateLevel(w,I,x,J,V,r,b,p),this._providesCoverage(this.coverage,x))break}this._drawTiles(this.lastDrawn),p&&!p.context2D?(this._loadTile(p,b),this._needsDraw=!0,this._setFullyLoaded(!1)):this._setFullyLoaded(this._tilesLoading===0)},_getCornerTiles:function(n,s,r){var A,l;this.wrapHorizontal?(A=t.positiveModulo(s.x,1),l=t.positiveModulo(r.x,1)):(A=Math.max(0,s.x),l=Math.min(1,r.x));var u,m,p=1/this.source.aspectRatio;this.wrapVertical?(u=t.positiveModulo(s.y,p),m=t.positiveModulo(r.y,p)):(u=Math.max(0,s.y),m=Math.min(p,r.y));var w=this.source.getTileAtPoint(n,new t.Point(A,u)),b=this.source.getTileAtPoint(n,new t.Point(l,m)),x=this.source.getNumTiles(n);return this.wrapHorizontal&&(w.x+=x.x*Math.floor(s.x),b.x+=x.x*Math.floor(r.x)),this.wrapVertical&&(w.y+=x.y*Math.floor(s.y/p),b.y+=x.y*Math.floor(r.y/p)),{topLeft:w,bottomRight:b}},_updateLevel:function(n,s,r,A,l,u,m,p){var w=u.getBoundingBox().getTopLeft(),b=u.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:n,level:r,opacity:A,visibility:l,drawArea:u,topleft:w,bottomright:b,currenttime:m,best:p}),this._resetCoverage(this.coverage,r),this._resetCoverage(this.loadingCoverage,r);var x=this._getCornerTiles(r,w,b),I=x.topLeft,T=x.bottomRight,Z=this.source.getNumTiles(r),Y=this.viewport.pixelFromPoint(this.viewport.getCenter());this.getFlip()&&(T.x+=1,this.wrapHorizontal||(T.x=Math.min(T.x,Z.x-1)));for(var W=I.x;W<=T.x;W++)for(var J=I.y;J<=T.y;J++){var V;if(this.getFlip()){var _=(Z.x+W%Z.x)%Z.x;V=W+Z.x-_-_-1}else V=W;u.intersection(this.getTileBounds(r,V,J))!==null&&(p=this._updateTile(s,n,V,J,r,A,l,Y,Z,m,p))}return p},_updateTile:function(n,s,r,A,l,u,m,p,w,b,x){var I=this._getTile(r,A,l,b,w,this._worldWidthCurrent,this._worldHeightCurrent),T=s;this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:I}),this._setCoverage(this.coverage,l,r,A,!1);var Z=I.loaded||I.loading||this._isCovered(this.loadingCoverage,l,r,A);if(this._setCoverage(this.loadingCoverage,l,r,A,Z),!I.exists||(n&&!T&&(this._isCovered(this.coverage,l,r,A)?this._setCoverage(this.coverage,l,r,A,!0):T=!0),!T))return x;if(this._positionTile(I,this.source.tileOverlap,this.viewport,p,m),!I.loaded)if(I.context2D)this._setTileLoaded(I);else{var Y=this._tileCache.getImageRecord(I.cacheKey);Y&&this._setTileLoaded(I,Y.getData())}if(I.loaded){var W=this._blendTile(I,r,A,l,u,b);W&&(this._needsDraw=!0)}else I.loading?this._tilesLoading++:Z||(x=this._compareTiles(x,I));return x},_getTile:function(n,s,r,A,l,u,m){var p,w,b,x,I,T,Z,Y,W,J,V=this.tilesMatrix,_=this.source;return V[r]||(V[r]={}),V[r][n]||(V[r][n]={}),(!V[r][n][s]||!V[r][n][s].flipped!=!this.flipped)&&(p=(l.x+n%l.x)%l.x,w=(l.y+s%l.y)%l.y,b=this.getTileBounds(r,n,s),x=_.getTileBounds(r,p,w,!0),I=_.tileExists(r,p,w),T=_.getTileUrl(r,p,w),Z=_.getTilePostData(r,p,w),this.loadTilesWithAjax?(Y=_.getTileAjaxHeaders(r,p,w),t.isPlainObject(this.ajaxHeaders)&&(Y=t.extend({},this.ajaxHeaders,Y))):Y=null,W=_.getContext2D?_.getContext2D(r,p,w):void 0,J=new t.Tile(r,n,s,b,I,T,W,this.loadTilesWithAjax,Y,x,Z,_.getTileHashKey(r,p,w,T,Y,Z)),this.getFlip()?p===0&&(J.isRightMost=!0):p===l.x-1&&(J.isRightMost=!0),w===l.y-1&&(J.isBottomMost=!0),J.flipped=this.flipped,V[r][n][s]=J),J=V[r][n][s],J.lastTouchTime=A,J},_loadTile:function(n,s){var r=this;n.loading=!0,this._imageLoader.addJob({src:n.getUrl(),tile:n,source:this.source,postData:n.postData,loadWithAjax:n.loadWithAjax,ajaxHeaders:n.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(A,l,u){r._onTileLoad(n,s,A,l,u)},abort:function(){n.loading=!1}})},_onTileLoad:function(n,s,r,A,l){if(!r){t.console.error("Tile %s failed to load: %s - error: %s",n,n.getUrl(),A),this.viewer.raiseEvent("tile-load-failed",{tile:n,tiledImage:this,time:s,message:A,tileRequest:l}),n.loading=!1,n.exists=!1;return}if(s<this.lastResetTime){t.console.warn("Ignoring tile %s loaded before reset: %s",n,n.getUrl()),n.loading=!1;return}var u=this,m=function(){var p=u.source,w=p.getClosestLevel();u._setTileLoaded(n,r,w,l)};this._midDraw?window.setTimeout(m,1):m()},_setTileLoaded:function(n,s,r,A){var l=0,u=this;function m(){return l++,p}function p(){l--,l===0&&(n.loading=!1,n.loaded=!0,n.hasTransparency=u.source.hasTransparency(n.context2D,n.getUrl(),n.ajaxHeaders,n.postData),n.context2D||u._tileCache.cacheTile({data:s,tile:n,cutoff:r,tiledImage:u}),u._needsDraw=!0)}this.viewer.raiseEvent("tile-loaded",{tile:n,tiledImage:this,tileRequest:A,get image(){return t.console.error("[tile-loaded] event 'image' has been deprecated. Use 'data' property instead."),s},data:s,getCompletionCallback:m}),m()()},_positionTile:function(n,s,r,A,l){var u=n.bounds.getTopLeft();u.x*=this._scaleSpring.current.value,u.y*=this._scaleSpring.current.value,u.x+=this._xSpring.current.value,u.y+=this._ySpring.current.value;var m=n.bounds.getSize();m.x*=this._scaleSpring.current.value,m.y*=this._scaleSpring.current.value;var p=r.pixelFromPointNoRotate(u,!0),w=r.pixelFromPointNoRotate(u,!1),b=r.deltaPixelsFromPointsNoRotate(m,!0),x=r.deltaPixelsFromPointsNoRotate(m,!1),I=w.plus(x.divide(2)),T=A.squaredDistanceTo(I);s||(b=b.plus(new t.Point(1,1))),n.isRightMost&&this.wrapHorizontal&&(b.x+=.75),n.isBottomMost&&this.wrapVertical&&(b.y+=.75),n.position=p,n.size=b,n.squaredDistance=T,n.visibility=l},_blendTile:function(n,s,r,A,l,u){var m=1e3*this.blendTime,p,w;if(n.blendStart||(n.blendStart=u),p=u-n.blendStart,w=m?Math.min(1,p/m):1,this.alwaysBlend&&(w*=l),n.opacity=w,this.lastDrawn.push(n),w===1)this._setCoverage(this.coverage,A,s,r,!0),this._hasOpaqueTile=!0;else if(p<m)return!0;return!1},_compareTiles:function(n,s){return!n||s.visibility>n.visibility||s.visibility===n.visibility&&s.squaredDistance<n.squaredDistance?s:n},_drawTiles:function(n){if(!(this.opacity===0||n.length===0&&!this.placeholderFillStyle)){var s=n[0],r;s&&(r=this.opacity<1||this.compositeOperation&&this.compositeOperation!=="source-over"||!this._isBottomItem()&&this.source.hasTransparency(s.context2D,s.getUrl(),s.ajaxHeaders,s.postData));var A,l,u=this.viewport.getZoom(!0),m=this.viewportToImageZoom(u);n.length>1&&m>this.smoothTileEdgesMinZoom&&!this.iOSDevice&&this.getRotation(!0)%360===0&&t.supportsCanvas&&this.viewer.useCanvas&&(r=!0,A=s.getScaleForEdgeSmoothing(),l=s.getTranslationForEdgeSmoothing(A,this._drawer.getCanvasSize(!1),this._drawer.getCanvasSize(!0)));var p;r&&(A||(p=this.viewport.viewportToViewerElementRectangle(this.getClippedBounds(!0)).getIntegerBoundingBox(),this._drawer.viewer.viewport.getFlip()&&(this.viewport.getRotation(!0)%360!==0||this.getRotation(!0)%360!==0)&&(p.x=this._drawer.viewer.container.clientWidth-(p.x+p.width)),p=p.times(t.pixelDensityRatio)),this._drawer._clear(!0,p)),A||(this.viewport.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:r}),this.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(this._getRotationPoint(!0),!0),useSketch:r}),this.viewport.getRotation(!0)%360===0&&this.getRotation(!0)%360===0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip());var w=!1;if(this._clip){this._drawer.saveContext(r);var b=this.imageToViewportRectangle(this._clip,!0);b=b.rotate(-this.getRotation(!0),this._getRotationPoint(!0));var x=this._drawer.viewportToDrawerRectangle(b);A&&(x=x.times(A)),l&&(x=x.translate(l)),this._drawer.setClip(x,r),w=!0}if(this._croppingPolygons){var I=this;this._drawer.saveContext(r);try{var T=this._croppingPolygons.map(function(ae){return ae.map(function(oe){var re=I.imageToViewportCoordinates(oe.x,oe.y,!0).rotate(-I.getRotation(!0),I._getRotationPoint(!0)),le=I._drawer.viewportCoordToDrawerCoord(re);return A&&(le=le.times(A)),le})});this._drawer.clipWithPolygons(T,r)}catch(ae){t.console.error(ae)}w=!0}if(this.placeholderFillStyle&&this._hasOpaqueTile===!1){var Z=this._drawer.viewportToDrawerRectangle(this.getBounds(!0));A&&(Z=Z.times(A)),l&&(Z=Z.translate(l));var Y=null;typeof this.placeholderFillStyle=="function"?Y=this.placeholderFillStyle(this,this._drawer.context):Y=this.placeholderFillStyle,this._drawer.drawRectangle(Z,Y,r)}var W=a(this.subPixelRoundingForTransparency),J=!1;if(W===t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS)J=!0;else if(W===t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST){var V=this.viewer&&this.viewer.isAnimating();J=!V}for(var _=n.length-1;_>=0;_--)s=n[_],this._drawer.drawTile(s,this._drawingHandler,r,A,l,J,this.source),s.beingDrawn=!0,this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:this,tile:s});w&&this._drawer.restoreContext(r),A||(this.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(r),this.viewport.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(r)),r&&(A&&(this.viewport.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:!1}),this.getRotation(!0)%360!==0&&this._drawer._offsetForRotation({degrees:this.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(this._getRotationPoint(!0),!0),useSketch:!1})),this._drawer.blendSketch({opacity:this.opacity,scale:A,translate:l,compositeOperation:this.compositeOperation,bounds:p}),A&&(this.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(!1),this.viewport.getRotation(!0)%360!==0&&this._drawer._restoreRotationChanges(!1))),A||this.viewport.getRotation(!0)%360===0&&this.getRotation(!0)%360===0&&this._drawer.viewer.viewport.getFlip()&&this._drawer._flip(),this._drawDebugInfo(n)}},_drawDebugInfo:function(n){if(this.debugMode)for(var s=n.length-1;s>=0;s--){var r=n[s];try{this._drawer.drawDebugInfo(r,n.length,s,this)}catch(A){t.console.error(A)}}},_providesCoverage:function(n,s,r,A){var l,u,m,p;if(!n[s])return!1;if(r===void 0||A===void 0){l=n[s];for(m in l)if(Object.prototype.hasOwnProperty.call(l,m)){u=l[m];for(p in u)if(Object.prototype.hasOwnProperty.call(u,p)&&!u[p])return!1}return!0}return n[s][r]===void 0||n[s][r][A]===void 0||n[s][r][A]===!0},_isCovered:function(n,s,r,A){return r===void 0||A===void 0?this._providesCoverage(n,s+1):this._providesCoverage(n,s+1,2*r,2*A)&&this._providesCoverage(n,s+1,2*r,2*A+1)&&this._providesCoverage(n,s+1,2*r+1,2*A)&&this._providesCoverage(n,s+1,2*r+1,2*A+1)},_setCoverage:function(n,s,r,A,l){if(!n[s]){t.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",s);return}n[s][r]||(n[s][r]={}),n[s][r][A]=l},_resetCoverage:function(n,s){n[s]={}}});var i=t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function e(n){return n!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&n!==t.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&n!==t.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function o(n){return e(n)?i:n}function a(n){if(typeof n=="number")return o(n);if(!n||!t.Browser)return i;var s=n[t.Browser.vendor];return e(s)&&(s=n["*"]),o(s)}})(L);(function(t){var i=function(o){t.console.assert(o,"[TileCache.cacheTile] options is required"),t.console.assert(o.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(o.tiledImage,"[TileCache.cacheTile] options.tiledImage is required"),this.tile=o.tile,this.tiledImage=o.tiledImage},e=function(o){t.console.assert(o,"[ImageRecord] options is required"),t.console.assert(o.data,"[ImageRecord] options.data is required"),this._tiles=[],o.create.apply(null,[this,o.data,o.ownerTile]),this._destroyImplementation=o.destroy.bind(null,this),this.getImage=o.getImage.bind(null,this),this.getData=o.getData.bind(null,this),this.getRenderedContext=o.getRenderedContext.bind(null,this)};e.prototype={destroy:function(){this._destroyImplementation(),this._tiles=null},addTile:function(o){t.console.assert(o,"[ImageRecord.addTile] tile is required"),this._tiles.push(o)},removeTile:function(o){for(var a=0;a<this._tiles.length;a++)if(this._tiles[a]===o){this._tiles.splice(a,1);return}t.console.warn("[ImageRecord.removeTile] trying to remove unknown tile",o)},getTileCount:function(){return this._tiles.length}},t.TileCache=function(o){o=o||{},this._maxImageCacheCount=o.maxImageCacheCount||t.DEFAULT_SETTINGS.maxImageCacheCount,this._tilesLoaded=[],this._imagesLoaded=[],this._imagesLoadedCount=0},t.TileCache.prototype={numTilesLoaded:function(){return this._tilesLoaded.length},cacheTile:function(o){t.console.assert(o,"[TileCache.cacheTile] options is required"),t.console.assert(o.tile,"[TileCache.cacheTile] options.tile is required"),t.console.assert(o.tile.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required"),t.console.assert(o.tiledImage,"[TileCache.cacheTile] options.tiledImage is required");var a=o.cutoff||0,n=this._tilesLoaded.length,s=this._imagesLoaded[o.tile.cacheKey];if(s||(o.data||(t.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future."),o.data=o.image),t.console.assert(o.data,"[TileCache.cacheTile] options.data is required to create an ImageRecord"),s=this._imagesLoaded[o.tile.cacheKey]=new e({data:o.data,ownerTile:o.tile,create:o.tiledImage.source.createTileCache,destroy:o.tiledImage.source.destroyTileCache,getImage:o.tiledImage.source.getTileCacheDataAsImage,getData:o.tiledImage.source.getTileCacheData,getRenderedContext:o.tiledImage.source.getTileCacheDataAsContext2D}),this._imagesLoadedCount++),s.addTile(o.tile),o.tile.cacheImageRecord=s,this._imagesLoadedCount>this._maxImageCacheCount){for(var r=null,A=-1,l=null,u,m,p,w,b,x,I=this._tilesLoaded.length-1;I>=0;I--)if(x=this._tilesLoaded[I],u=x.tile,!(u.level<=a||u.beingDrawn)){if(!r){r=u,A=I,l=x;continue}w=u.lastTouchTime,m=r.lastTouchTime,b=u.level,p=r.level,(w<m||w===m&&b>p)&&(r=u,A=I,l=x)}r&&A>=0&&(this._unloadTile(l),n=A)}this._tilesLoaded[n]=new i({tile:o.tile,tiledImage:o.tiledImage})},clearTilesFor:function(o){t.console.assert(o,"[TileCache.clearTilesFor] tiledImage is required");for(var a,n=0;n<this._tilesLoaded.length;++n)a=this._tilesLoaded[n],a.tiledImage===o&&(this._unloadTile(a),this._tilesLoaded.splice(n,1),n--)},getImageRecord:function(o){return t.console.assert(o,"[TileCache.getImageRecord] cacheKey is required"),this._imagesLoaded[o]},_unloadTile:function(o){t.console.assert(o,"[TileCache._unloadTile] tileRecord is required");var a=o.tile,n=o.tiledImage;a.unload(),a.cacheImageRecord=null;var s=this._imagesLoaded[a.cacheKey];s.removeTile(a),s.getTileCount()||(s.destroy(),delete this._imagesLoaded[a.cacheKey],this._imagesLoadedCount--),n.viewer.raiseEvent("tile-unloaded",{tile:a,tiledImage:n})}}})(L);(function(t){t.World=function(i){var e=this;t.console.assert(i.viewer,"[World] options.viewer is required"),t.EventSource.call(this),this.viewer=i.viewer,this._items=[],this._needsDraw=!1,this._autoRefigureSizes=!0,this._needsSizesFigured=!1,this._delegatedFigureSizes=function(o){e._autoRefigureSizes?e._figureSizes():e._needsSizesFigured=!0},this._figureSizes()},t.extend(t.World.prototype,t.EventSource.prototype,{addItem:function(i,e){if(t.console.assert(i,"[World.addItem] item is required"),t.console.assert(i instanceof t.TiledImage,"[World.addItem] only TiledImages supported at this time"),e=e||{},e.index!==void 0){var o=Math.max(0,Math.min(this._items.length,e.index));this._items.splice(o,0,i)}else this._items.push(i);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0,this._needsDraw=!0,i.addHandler("bounds-change",this._delegatedFigureSizes),i.addHandler("clip-change",this._delegatedFigureSizes),this.raiseEvent("add-item",{item:i})},getItemAt:function(i){return t.console.assert(i!==void 0,"[World.getItemAt] index is required"),this._items[i]},getIndexOfItem:function(i){return t.console.assert(i,"[World.getIndexOfItem] item is required"),t.indexOf(this._items,i)},getItemCount:function(){return this._items.length},setItemIndex:function(i,e){t.console.assert(i,"[World.setItemIndex] item is required"),t.console.assert(e!==void 0,"[World.setItemIndex] index is required");var o=this.getIndexOfItem(i);if(e>=this._items.length)throw new Error("Index bigger than number of layers.");e===o||o===-1||(this._items.splice(o,1),this._items.splice(e,0,i),this._needsDraw=!0,this.raiseEvent("item-index-change",{item:i,previousIndex:o,newIndex:e}))},removeItem:function(i){t.console.assert(i,"[World.removeItem] item is required");var e=t.indexOf(this._items,i);e!==-1&&(i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy(),this._items.splice(e,1),this._figureSizes(),this._needsDraw=!0,this._raiseRemoveItem(i))},removeAll:function(){this.viewer._cancelPendingImages();var i,e;for(e=0;e<this._items.length;e++)i=this._items[e],i.removeHandler("bounds-change",this._delegatedFigureSizes),i.removeHandler("clip-change",this._delegatedFigureSizes),i.destroy();var o=this._items;for(this._items=[],this._figureSizes(),this._needsDraw=!0,e=0;e<o.length;e++)i=o[e],this._raiseRemoveItem(i)},resetItems:function(){for(var i=0;i<this._items.length;i++)this._items[i].reset()},update:function(){for(var i=!1,e=0;e<this._items.length;e++)i=this._items[e].update()||i;return i},draw:function(){for(var i=0;i<this._items.length;i++)this._items[i].draw();this._needsDraw=!1},needsDraw:function(){for(var i=0;i<this._items.length;i++)if(this._items[i].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(i){this._autoRefigureSizes=i,i&this._needsSizesFigured&&(this._figureSizes(),this._needsSizesFigured=!1)},arrange:function(i){i=i||{};var e=i.immediately||!1,o=i.layout||t.DEFAULT_SETTINGS.collectionLayout,a=i.rows||t.DEFAULT_SETTINGS.collectionRows,n=i.columns||t.DEFAULT_SETTINGS.collectionColumns,s=i.tileSize||t.DEFAULT_SETTINGS.collectionTileSize,r=i.tileMargin||t.DEFAULT_SETTINGS.collectionTileMargin,A=s+r,l;!i.rows&&n?l=n:l=Math.ceil(this._items.length/a);var u=0,m=0,p,w,b,x,I;this.setAutoRefigureSizes(!1);for(var T=0;T<this._items.length;T++)T&&T%l===0&&(o==="horizontal"?(m+=A,u=0):(u+=A,m=0)),p=this._items[T],w=p.getBounds(),w.width>w.height?b=s:b=s*(w.width/w.height),x=b*(w.height/w.width),I=new t.Point(u+(s-b)/2,m+(s-x)/2),p.setPosition(I,e),p.setWidth(b,e),o==="horizontal"?u+=A:m+=A;this.setAutoRefigureSizes(!0)},_figureSizes:function(){var i=this._homeBounds?this._homeBounds.clone():null,e=this._contentSize?this._contentSize.clone():null,o=this._contentFactor||0;if(!this._items.length)this._homeBounds=new t.Rect(0,0,1,1),this._contentSize=new t.Point(1,1),this._contentFactor=1;else{var a=this._items[0],n=a.getBounds();this._contentFactor=a.getContentSize().x/n.width;for(var s=a.getClippedBounds().getBoundingBox(),r=s.x,A=s.y,l=s.x+s.width,u=s.y+s.height,m=1;m<this._items.length;m++)a=this._items[m],n=a.getBounds(),this._contentFactor=Math.max(this._contentFactor,a.getContentSize().x/n.width),s=a.getClippedBounds().getBoundingBox(),r=Math.min(r,s.x),A=Math.min(A,s.y),l=Math.max(l,s.x+s.width),u=Math.max(u,s.y+s.height);this._homeBounds=new t.Rect(r,A,l-r,u-A),this._contentSize=new t.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}(this._contentFactor!==o||!this._homeBounds.equals(i)||!this._contentSize.equals(e))&&this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(i){this.raiseEvent("remove-item",{item:i})}})})(L)});var qt=Mt((gt,Rt)=>{(function(t,i){typeof gt=="object"&&typeof Rt=="object"?Rt.exports=i(dt()):typeof define=="function"&&define.amd?define(["openseadragon"],i):typeof gt=="object"?gt["openseadragon-viewerinputhook"]=i(dt()):t["openseadragon-viewerinputhook"]=i(t.openseadragon)})(window,function(t){return function(i){function e(a){if(o[a])return o[a].exports;var n=o[a]={i:a,l:!1,exports:{}};return i[a].call(n.exports,n,n.exports,e),n.l=!0,n.exports}var o={};return e.m=i,e.c=o,e.d=function(a,n,s){e.o(a,n)||Object.defineProperty(a,n,{enumerable:!0,get:s})},e.r=function(a){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(a,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(a,"__esModule",{value:!0})},e.t=function(a,n){if(1&n&&(a=e(a)),8&n||4&n&&typeof a=="object"&&a&&a.__esModule)return a;var s=Object.create(null);if(e.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:a}),2&n&&typeof a!="string")for(var r in a)e.d(s,r,function(A){return a[A]}.bind(null,r));return s},e.n=function(a){var n=a&&a.__esModule?function(){return a.default}:function(){return a};return e.d(n,"a",n),n},e.o=function(a,n){return Object.prototype.hasOwnProperty.call(a,n)},e.p="",e(e.s=1)}([function(i){i.exports=t},function(i,e,o){"use strict";o.r(e);var a=o(0),n=o.n(a);e.default=function(s,r){if(!s.version||1>s.version.major)throw new Error("OpenSeadragonViewerInputHook requires OpenSeadragon version 1.0.0+");return s.Viewer.prototype.addViewerInputHook=function(A){return(A=A||{}).viewer=this,new r.ViewerInputHook(A)},r.ViewerInputHook=function(A){var l,u;for((A=A||{}).hooks=A.hooks||[],this.viewer=A.viewer||null,this.viewerTrackers={},this.hooks=[],this.viewer&&(this.viewerTrackers.viewer=this.viewer.innerTracker,this.viewerTrackers.viewer_outer=this.viewer.outerTracker),l=0;l<A.hooks.length;l++){if(typeof A.hooks[l].tracker=="string"){if(!this.viewer)throw new Error("A viewer must be specified.");if((u=this.viewerTrackers[A.hooks[l].tracker])===void 0)throw new Error("Unknown tracker specified: "+A.hooks[l].tracker)}else u=A.hooks[l].tracker;this.hooks.push({tracker:u,handlerName:A.hooks[l].handler,origHandler:u[A.hooks[l].handler],hookHandler:A.hooks[l].hookHandler}),function(m,p,w,b){var x=p[w];p[w]=function(I){return m._callHandlers(b,x,I)}}(this,u,A.hooks[l].handler,A.hooks[l].hookHandler)}},r.ViewerInputHook.version={versionStr:"2.2.1",major:2,minor:2,revision:1},r.ViewerInputHook.prototype._callHandlers=function(A,l,u){var m=A(u);return l&&!u.stopHandlers&&(m=l(u)),!u.stopBubbling&&m},r.ViewerInputHook.prototype.destroy=function(){for(;0<this.hooks.length;){var A=this.hooks.pop();A.tracker[A.handlerName]=A.origHandler}this.viewer&&(delete this.viewerTrackers.viewer,delete this.viewerTrackers.viewer_outer,this.viewer=null)},r.ViewerInputHook}(n.a||window.OpenSeadragon,window.OpenSeadragonImaging=window.OpenSeadragonImaging||{})}]).default})});var Se=class t{constructor(i,e,o,a){this.x=i,this.y=e,this.w=o,this.h=a}toString(){return`${this.x},${this.y},${this.w},${this.h}`}static fromString(i){i=i.replace("xywh=","");let e=i.split(",");return new t(Number(e[0]),Number(e[1]),Number(e[2]),Number(e[3]))}};var Ve=class{constructor(i,e){this.x=i,this.y=e}};var ot=class{constructor(){this.region=new xt(0,0);this.regionPos=new Ve(0,0);this.size=new xt(0,0)}};var G=fe(Lt()),et=fe(si());var Fe=fe(it());var ri=({canvases:t,confinedImageSize:i,content:e,downloadCurrentViewEnabled:o,downloadWholeImageHighResEnabled:a,downloadWholeImageLowResEnabled:n,getConfinedImageDimensions:s,getConfinedImageUri:r,getCroppedImageDimensions:A,locale:l,manifest:u,maxImageWidth:m,mediaDownloadEnabled:p,onClose:w,onDownloadCurrentView:b,onDownloadSelection:x,onShowTermsOfUse:I,open:T,paged:Z,parent:Y,resources:W,requiredStatement:J,rotation:V,selectionEnabled:_,sequence:ae,termsOfUseEnabled:oe,triggerButton:re})=>{let le=(0,G.useRef)(null),[Ee,Pe]=(0,G.useState)({top:"0px",left:"0px"}),[pe,Re]=(0,G.useState)("0px 0px"),[ye,Be]=(0,G.useState)("left"),Ie=V%180==0;(0,G.useEffect)(()=>{if(T){let k=Y.clientHeight-le.current.clientHeight-re.clientHeight,D=re.getBoundingClientRect().left-Y.getBoundingClientRect().left,S=Ke.normalise(D,0,Y.clientWidth);D=Y.clientWidth*S-le.current.clientWidth*S;let F=le.current.clientWidth*S;Pe({top:`${k}px`,left:`${D}px`}),Re(`${F}px 0px`);let O=j();O&&O.length>0&&O[0]?.focus()}},[T]);let j=()=>le.current?.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),Le=k=>{if(k.key==="Tab"){let D=j();if(!D)return;let S=D[0],F=D[D.length-1];k.shiftKey?document.activeElement===S&&(k.preventDefault(),F.focus()):document.activeElement===F&&(k.preventDefault(),S.focus())}};if((0,G.useEffect)(()=>(T&&document.addEventListener("keydown",Le),()=>{document.removeEventListener("keydown",Le)}),[T]),!T)return null;function Xe(k){if(k.externalResource.data){let D=k.externalResource.data.width,S=k.externalResource.data.height;if(D&&S)return new Fe.Size(D,S)}return null}function ke(k){let D=Xe(k),S=k.getMaxDimensions();if(!D)return null;if(!S||D.width<=S.width&&D.height<=S.height)return D;let F=S.width/D.width,O=S.height/D.height,K=Math.min(F,O);return new Fe.Size(Math.floor(D.width*K),Math.floor(D.height*K))}function Ne(k){return!k||!k.length?!1:Fe.Utils.isLevel0ImageProfile(k[0])}function ce(){return t[ye==="left"?0:1]}function Qe(){return W&&W.length?W.length>1?W[ye==="left"?0:1]:W[0]:null}function ge(k){let D=Qe();if(!D)return!1;let S=ce();if(!S.externalResource.hasServiceDescriptor()||Ne(S.externalResource.data.profile))return k==="wholeImageHighRes"&&!(Z||Z&&D);switch(k){case"currentView":return o?!Z:!1;case"canvasRenderings":case"imageRenderings":case"wholeImageHighRes":if(!a)return!1;let F=S.getMaxDimensions();return F?F.width<=m:!0;case"wholeImageLowRes":if(!n)return!1;let O=ke(S);return O?Math.max(O.width,O.height)>i:!1;case"selection":return _;case"rangeRenderings":return S.ranges&&S.ranges.length?S.ranges[0].getRenderings().length>0:!1;case"entireFileAsOriginal":return p;default:return!0}}function He(k){let D=k.getImages();return D[0]?D[0].getResource():null}function _e(k){let D=k.getContent();if(D.length==0)return null;let S=D[0].getBody();return S.length==0?null:S[0]}function Oe(k){let D=He(k);if(D){let F=D.getFormat();if(F)return F.toString()}let S=_e(k);if(S){let F=S.getFormat();if(F)return F.toString()}return null}function ze(k){let D=ke(k);if(D){let S=D.width,F=k.getCanonicalImageUri(S);if(k.externalResource&&k.externalResource.hasServiceDescriptor()){let O=F.split("/");O[O.length-2]=String(V),F=O.join("/")}return F}else if(k.externalResource&&!k.externalResource.hasServiceDescriptor())return k.externalResource.dataUri;return""}function qe(){let k="",D=ce(),S=Oe(D);S?S=wt.simplifyMimeType(S):S="?";let F=ke(D);return F?k=Ie?ie.format(e.wholeImageHighRes,F.width.toString(),F.height.toString(),S):ie.format(e.wholeImageHighRes,F.height.toString(),F.width.toString(),S):D.externalResource&&!D.externalResource.hasServiceDescriptor()&&(k=ie.format(e.wholeImageHighRes,"?","?",S)),k}function Ze(){let k=ce(),D=s(k),S="";return D&&(S=Ie?ie.format(e.wholeImageLowResAsJpg,D.width.toString(),D.height.toString()):ie.format(e.wholeImageLowResAsJpg,D.height.toString(),D.width.toString())),S}function h(){let k=e.currentViewAsJpg,D=A(ce());return D&&(k=Ie?ie.format(k,D.size.width.toString(),D.size.height.toString()):ie.format(k,D.size.height.toString(),D.size.width.toString())),k}function v({resource:k,defaultLabel:D}){let S=k.getRenderings();return G.default.createElement(G.default.Fragment,null,S.map((F,O)=>{let K=Fe.LanguageMap.getValue(F.getLabel(),l);K?K+=" ({0})":K=D;let Te=wt.simplifyMimeType(F.getFormat().toString());return K=ie.format(K,Te),G.default.createElement("li",{key:O},G.default.createElement("button",{onClick:()=>{window.open(F.id,"_blank")}},K))}))}function y(){let k=ce();return G.default.createElement(G.default.Fragment,null,k.ranges?.map((D,S)=>G.default.createElement(v,{resource:D,defaultLabel:e.entireFileAsOriginal,key:`range-rendering-${String(S)}`})))}function M(){let D=ce().getImages();return G.default.createElement(G.default.Fragment,null,D.map((S,F)=>G.default.createElement(v,{resource:S.getResource(),defaultLabel:e.entireFileAsOriginal,key:`image-rendering-${String(F)}`})))}function C(){let k=ce();return G.default.createElement(v,{resource:k,defaultLabel:e.entireFileAsOriginal})}function U(){return ae.getRenderings().length>0||u.getRenderings.length>0}function N(){return G.default.createElement(G.default.Fragment,null,G.default.createElement(v,{resource:ae,defaultLabel:e.entireFileAsOriginal}),G.default.createElement(v,{resource:u,defaultLabel:e.entireFileAsOriginal}))}function X(){return oe&&J?G.default.createElement("button",{onClick:()=>{I()}},e.termsOfUse):null}return G.default.createElement("div",{ref:le,className:(0,et.default)("overlay download"),style:Ee},G.default.createElement("div",{className:"top"}),G.default.createElement("div",{className:"middle"},G.default.createElement("div",{className:"content"},G.default.createElement("div",{role:"heading",className:"heading"},e.download),G.default.createElement("h2",null,e.individualPages),t.length===2&&G.default.createElement("div",{className:"pages"},G.default.createElement("div",{onClick:()=>{Be("left")},className:(0,et.default)("page left",{selected:ye==="left"})},G.default.createElement("span",{className:"label"},t[0].getLabel().getValue())),G.default.createElement("div",{onClick:()=>{Be("right")},className:(0,et.default)("page right",{selected:ye==="right"})},G.default.createElement("span",{className:"label"},t[1].getLabel().getValue()))),G.default.createElement("ol",{className:"options"},ge("currentView")&&G.default.createElement("li",{className:"option single"},G.default.createElement("button",{onClick:()=>{b(ce())}},h())),ge("wholeImageHighRes")&&G.default.createElement("li",{className:"option single"},G.default.createElement("button",{onClick:()=>{window.open(ze(ce()))}},qe())),ge("wholeImageLowRes")&&G.default.createElement("li",{className:"option single"},G.default.createElement("button",{onClick:()=>{let k=r(ce());k&&window.open(k)}},Ze())),ge("rangeRenderings")&&G.default.createElement(y,null),ge("imageRenderings")&&G.default.createElement(M,null),ge("canvasRenderings")&&G.default.createElement(C,null)),(U()||ge("selection"))&&G.default.createElement("h2",null,e.allPages),G.default.createElement("ol",{className:"options"},ge("manifestRenderings")&&G.default.createElement(N,null),ge("selection")&&G.default.createElement("li",{className:"option single"},G.default.createElement("button",{onClick:()=>{x()}},e.selection))),G.default.createElement("div",{className:"footer"},G.default.createElement(X,null))),G.default.createElement("div",{className:"buttons"},G.default.createElement("button",{type:"button",className:"btn btn-default close",tabIndex:0,onClick:()=>{w()}},e.close))),G.default.createElement("div",{className:(0,et.default)("bottom"),style:{backgroundPosition:pe}}))},Jt=ri;var H=class H{};H.namespace="openseadragonExtension.",H.CURRENT_VIEW_URI=H.namespace+"currentViewUri",H.DOUBLECLICK=H.namespace+"doubleClick",H.IMAGE_SEARCH=H.namespace+"imageSearch",H.MODE_CHANGE=H.namespace+"modeChange",H.NEXT_SEARCH_RESULT=H.namespace+"nextSearchResult",H.NEXT_IMAGES_SEARCH_RESULT_UNAVAILABLE=H.namespace+"nextImagesSearchResultUnavailable",H.PREV_IMAGES_SEARCH_RESULT_UNAVAILABLE=H.namespace+"prevImagesSearchResultUnavailable",H.PAGE_SEARCH=H.namespace+"pageSearch",H.PAGING_TOGGLED=H.namespace+"pagingToggled",H.PREV_SEARCH_RESULT=H.namespace+"prevSearchResult",H.PRINT=H.namespace+"print",H.ROTATE=H.namespace+"rotate",H.OPENSEADRAGON_ANIMATION_FINISH=H.namespace+"animationFinish",H.OPENSEADRAGON_ANIMATION_START=H.namespace+"animationStart",H.OPENSEADRAGON_ANIMATION=H.namespace+"animation",H.OPENSEADRAGON_OPEN=H.namespace+"open",H.OPENSEADRAGON_RESIZE=H.namespace+"resize",H.OPENSEADRAGON_ROTATION=H.namespace+"rotationChange",H.SEARCH_PREVIEW_FINISH=H.namespace+"searchPreviewFinish",H.SEARCH_PREVIEW_START=H.namespace+"searchPreviewStart",H.SEARCH=H.namespace+"search",H.XYWH_CHANGE=H.namespace+"xywhChange",H.ZOOM_IN=H.namespace+"zoomIn",H.ZOOM_OUT=H.namespace+"zoomOut";var P=H;var ai=Me(),st=class extends We{constructor(i){super(i)}create(){this.setConfig("externalContentDialogue"),super.create(),this.openCommand=E.SHOW_EXTERNALCONTENT_DIALOGUE,this.closeCommand=E.HIDE_EXTERNALCONTENT_DIALOGUE,this.extensionHost.subscribe(this.openCommand,i=>{this.open(),this.$iframe.prop("src",i.uri)}),this.extensionHost.subscribe(this.closeCommand,()=>{this.close()}),this.$iframe=ai("<iframe></iframe>"),this.$content.append(this.$iframe),this.$element.hide()}resize(){super.resize(),this.$iframe.width(this.$content.width()),this.$iframe.height(this.$content.height())}};var rt=Me(),at=class extends nt{constructor(i){super(i)}create(){this.setConfig("mobileFooterPanel"),super.create(),this.$rotateButton=rt(`
<button class="btn imageBtn rotate" title="${this.content.rotateRight}">
<i class="uv-icon-rotate" aria-hidden="true"></i>${this.content.rotateRight}
</button>
`),this.$mainOptions.prepend(this.$rotateButton),this.$zoomOutButton=rt(`
<button class="btn imageBtn zoomOut" title="${this.content.zoomOut}">
<i class="uv-icon-zoom-out" aria-hidden="true"></i>${this.content.zoomOut}
</button>
`),this.$mainOptions.prepend(this.$zoomOutButton),this.$zoomInButton=rt(`
<button class="btn imageBtn zoomIn" title="${this.content.zoomIn}">
<i class="uv-icon-zoom-in" aria-hidden="true"></i>${this.content.zoomIn}
</button>
`),this.$mainOptions.prepend(this.$zoomInButton),this.$helpButton=rt(`
<a class="btn imageBtn help" tabindex="0" title="${this.content.help}" role="button">
<i class="uv-icon-help" aria-hidden="true"></i>
</a>
`),this.$options.prepend(this.$helpButton),this.options.helpEnabled&&this.options.helpUrl?this.$helpButton.show():this.$helpButton.hide(),this.$helpButton.onPressed(()=>{window.open(this.options.helpUrl)}),this.$zoomInButton.onPressed(()=>{this.extensionHost.publish(P.ZOOM_IN)}),this.$zoomOutButton.onPressed(()=>{this.extensionHost.publish(P.ZOOM_OUT)}),this.$rotateButton.onPressed(()=>{this.extensionHost.publish(P.ROTATE)})}resize(){super.resize(),setTimeout(()=>{this.$options.css("left",Math.floor(this.$element.width()/2-this.$options.width()/2))},1)}};var De=Me(),Ye=class{constructor(i,e,o,a,n=300,s=2,r=!1,A=!1){this._$element=i,this._autoCompleteFunc=e,this._delay=n,this._minChars=s,this._onSelect=a,this._parseResultsFunc=o,this._positionAbove=r,this._allowWords=A,this._$searchResultsList=De('<ul class="autocomplete"></ul>'),this._positionAbove?this._$element.parent().prepend(this._$searchResultsList):this._$element.parent().append(this._$searchResultsList),this._$searchResultTemplate=De('<li class="result"><a href="#" tabindex="-1"></a></li>');let l=function(){let m=0;return function(p,w){clearTimeout(m),m=setTimeout(p,w)}}(),u=this;this._$element.on("keydown",function(m){let p=m.originalEvent,w=Dt.getCharCode(p),b=!1;(w===Ce.LeftArrow||w===Ce.RightArrow)&&(b=!0),b&&(p.cancelBubble=!0,p.stopPropagation&&p.stopPropagation())}),this._$element.on("keyup",function(m){if(!u._getSelectedListItem().length&&m.keyCode===Ce.Enter){u._onSelect(u._getTerms());return}if(m.keyCode!==Ce.Tab){if(Ut(u._$searchResultsList)&&u._results.length){if(m.keyCode===Ce.Enter)u._searchForItem(u._getSelectedListItem());else if(m.keyCode===Ce.DownArrow){u._setSelectedResultIndex(1);return}else if(m.keyCode===Ce.UpArrow){u._setSelectedResultIndex(-1);return}}m.keyCode!==Ce.Enter&&l(()=>{let p=u._getTerms();p&&p.length>u._minChars&&u._searchForWords(p)?u._search(p):(u._clearResults(),u._hideResults())},u._delay)}}),De(document).on("mouseup",m=>{this._$searchResultsList.parent().has(De(m.target)[0]).length===0&&(this._clearResults(),this._hideResults())}),De(document).on("focusin",m=>{this._$searchResultsList.has(De(m.target)[0]).length===0&&!this._$element.is(De(m.target)[0])&&(this._clearResults(),this._hideResults())}),this._hideResults()}_searchForWords(i){return!!(this._allowWords||!i.includes(" "))}_getTerms(){return this._$element.val().trim()}_setSelectedResultIndex(i){let e;i===1?e=this._selectedResultIndex+1:e=this._selectedResultIndex-1;let o=this._$searchResultsList.find("li");e<0?e=o.length-1:e>o.length-1&&(e=0),this._selectedResultIndex=e,o.removeClass("selected");let a=o.eq(this._selectedResultIndex);a.addClass("selected");let n=a.outerHeight(!0)*this._selectedResultIndex;this._$searchResultsList.scrollTop(n)}_search(i){this._results=[],this._clearResults(),this._showResults(),this._$searchResultsList.append('<li class="loading"></li>'),this._updateListPosition();let e=this;this._autoCompleteFunc(i,o=>{e._listResults(o)})}_clearResults(){this._$searchResultsList.empty()}_hideResults(){this._$searchResultsList.hide()}_showResults(){this._selectedResultIndex=-1,this._$searchResultsList.show()}_updateListPosition(){this._positionAbove?this._$searchResultsList.css({top:this._$searchResultsList.outerHeight(!0)*-1}):this._$searchResultsList.css({top:this._$element.outerHeight(!0)})}_listResults(i){if(this._results=this._parseResultsFunc(i),this._clearResults(),!this._results.length){this._hideResults();return}for(let a=0;a<this._results.length;a++){let n=this._results[a],s=this._$searchResultTemplate.clone();s.find("a").text(n),this._$searchResultsList.append(s)}this._updateListPosition();let e=this;this._$searchResultsList.find("li").each((a,n)=>{De(n).on("click",function(s){s.preventDefault(),e._searchForItem(De(this))})})}_searchForItem(i){let e=i.find("a").text();this._$element.val(e),this._hideResults(),this._onSelect(e),this._clearResults(),this._hideResults()}_getSelectedListItem(){return this._$searchResultsList.find("li.selected")}};var It=fe(it()),te=Me(),At=class extends nt{constructor(e){super(e);this.placemarkerTouched=!1}create(){this.setConfig("searchFooterPanel"),super.create(),this.extensionHost.subscribe(E.CANVAS_INDEX_CHANGE,()=>{this.canvasIndexChanged(),this.setCurrentSearchResultPlacemarker(),this.updatePrevButton(),this.updateNextButton()}),this.extensionHost.subscribe(E.CLEAR_ANNOTATIONS,()=>{this.clearSearchResults()}),this.extensionHost.subscribe(P.MODE_CHANGE,()=>{this.settingsChanged()}),this.extensionHost.subscribe(P.SEARCH,n=>{this.terms=n}),this.extensionHost.subscribe(E.ANNOTATIONS,n=>{n.annotations.length&&(this.displaySearchResults(n.annotations,n.terms),this.setCurrentSearchResultPlacemarker(),this.updatePrevButton(),this.updateNextButton())}),this.extensionHost.subscribe(E.ANNOTATIONS_EMPTY,()=>{this.hideSearchSpinner()}),this.extensionHost.subscribe(E.ANNOTATION_CHANGE,()=>{this.updatePrevButton(),this.updateNextButton()}),this.$printButton=te(`
<button class="print btn imageBtn" title="${this.content.print}" tabindex="0">
<i class="uv-icon uv-icon-print" aria-hidden="true"></i>${this.content.print}
</button>
`),this.$options.prepend(this.$printButton),this.$searchContainer=te('<div class="search"></div>'),this.$element.prepend(this.$searchContainer),this.$searchOptions=te('<div class="searchOptions"></div>'),this.$searchContainer.append(this.$searchOptions),this.$searchLabel=te('<label class="label" for="searchWithinInput">'+this.content.searchWithin+"</label>"),this.$searchOptions.append(this.$searchLabel),this.$searchTextContainer=te('<div class="searchTextContainer"></div>'),this.$searchOptions.append(this.$searchTextContainer),this.$searchText=te('<input class="searchText" id="searchWithinInput" autocomplete="off" type="text" maxlength="100" value="'+this.content.enterKeyword+'" aria-label="'+this.content.searchWithin+'"/>'),this.$searchTextContainer.append(this.$searchText),this.$searchButton=te('<button class="imageButton searchButton"></button>'),this.$searchButton.attr("aria-label",this.content.searchWithin),this.$searchButton.attr("title",this.content.searchWithin),this.$searchTextContainer.append(this.$searchButton),this.$searchPagerContainer=te('<div class="searchPager"></div>'),this.$element.prepend(this.$searchPagerContainer),this.$searchPagerControls=te('<div class="controls"></div>'),this.$searchPagerContainer.prepend(this.$searchPagerControls),this.$previousResultButton=te('<button class="previousResult">'+this.content.previousResult+"</button>"),this.$searchPagerControls.append(this.$previousResultButton),this.$searchResultsInfo=te(`<div class="searchResultsInfo"><span class="info"><span class="number">x</span> <span class="foundFor"></span> '<span class="terms">y</span>'</span></div>`),this.$searchPagerControls.append(this.$searchResultsInfo),this.$clearSearchResultsButton=te('<button class="clearSearch">'+this.content.clearSearch+"</button>"),this.$searchResultsInfo.append(this.$clearSearchResultsButton),this.$nextResultButton=te('<button class="nextResult">'+this.content.nextResult+"</button>"),this.$searchPagerControls.append(this.$nextResultButton),this.$searchResultsContainer=te('<div class="searchResults"></div>'),this.$element.prepend(this.$searchResultsContainer),this.$line=te('<div class="line"></div>'),this.$searchResultsContainer.append(this.$line),this.$pagePositionMarker=te('<div class="positionPlacemarker"></div>'),this.$searchResultsContainer.append(this.$pagePositionMarker),this.$pagePositionLabel=te('<label class="label"></label>'),this.$searchResultsContainer.append(this.$pagePositionLabel),this.$placemarkerDetails=te('<div class="placeMarkerDetails"></div>'),this.$searchResultsContainer.append(this.$placemarkerDetails),this.$placemarkerDetailsTop=te('<div role="heading" class="heading"></div>'),this.$placemarkerDetails.append(this.$placemarkerDetailsTop),this.$placemarkerDetailsBottom=te("<p></p>"),this.$placemarkerDetails.append(this.$placemarkerDetailsBottom),this.$searchPagerContainer.hide(),this.$placemarkerDetails.hide();var e=this;this.$searchButton.on("click",n=>{n.preventDefault(),this.search(this.$searchText.val())}),this.$searchText.on("focus",()=>{this.$searchText.val()===this.content.enterKeyword&&this.$searchText.val("")}),this.$placemarkerDetails.on("mouseover",()=>{e.extensionHost.publish(P.SEARCH_PREVIEW_START,this.currentPlacemarkerIndex)}),this.$placemarkerDetails.on("mouseleave",function(){te(this).hide(),e.extensionHost.publish(P.SEARCH_PREVIEW_FINISH);var n=e.getSearchResultPlacemarkers();n.removeClass("hover")}),this.onAccessibleClick(this.$placemarkerDetails,()=>{e.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.currentPlacemarkerIndex)}),this.$previousResultButton.on("click",n=>{n.preventDefault(),this.isPreviousButtonEnabled()&&e.extensionHost.publish(P.PREV_SEARCH_RESULT)}),this.$nextResultButton.on("click",n=>{n.preventDefault(),this.isNextButtonEnabled()&&e.extensionHost.publish(P.NEXT_SEARCH_RESULT)}),this.$clearSearchResultsButton.on("click",n=>{n.preventDefault(),e.extensionHost.publish(E.CLEAR_ANNOTATIONS)}),this.isSearchEnabled()||(this.$searchContainer.hide(),this.$searchPagerContainer.hide(),this.$searchResultsContainer.hide(),this.$element.addClass("min")),this.extension.helper.getTotalCanvases()===1&&this.$searchResultsContainer.hide();let o=this.extension.getAutoCompleteUri();o?new Ye(this.$searchText,(n,s)=>{fetch(ie.format(o,n)).then(r=>r.json()).then(r=>{s(r)})},n=>te.map(n.terms,s=>s.match),n=>{this.search(n)},300,2,!0,ee.getBool(this.options.autocompleteAllowWords,!1)):this.$searchText.on("keyup",n=>{n.keyCode===Ce.Enter&&e.search(e.$searchText.val())}),this.$printButton.onPressed(()=>{e.extensionHost.publish(P.PRINT)}),this.updatePrintButton();var a=ee.getBool(this.config.options.positionMarkerEnabled,!0);a||(this.$pagePositionMarker.hide(),this.$pagePositionLabel.hide())}isSearchEnabled(){return this.extension.isSearchEnabled()}isZoomToSearchResultEnabled(){return ee.getBool(this.extension.data.config.options.zoomToSearchResultEnabled,!0)}isPreviousButtonEnabled(){let e=this.extension.helper.canvasIndex,o=this.getFirstSearchResultCanvasIndex(),a=this.getCurrentSearchResultRectIndex();return this.isZoomToSearchResultEnabled()&&this.extension.currentAnnotationRect?e<o?!1:!(e===o&&a===0):e>o}isNextButtonEnabled(){let e=this.extension.helper.canvasIndex,o=this.getLastSearchResultCanvasIndex(),a=this.getCurrentSearchResultRectIndex();return this.isZoomToSearchResultEnabled()&&this.extension.currentAnnotationRect?e>o?!1:!(e===o&&a===this.getLastSearchResultRectIndex()):e<=o}getSearchResults(){return this.extension.annotations}getCurrentSearchResultRectIndex(){return this.extension.getCurrentAnnotationRectIndex()}getFirstSearchResultCanvasIndex(){let e=this.getSearchResults();return!e||!e.length?-1:e[0].canvasIndex}getLastSearchResultCanvasIndex(){let e=this.getSearchResults();return!e||!e.length?-1:e[e.length-1].canvasIndex}getLastSearchResultRectIndex(){return this.extension.getLastAnnotationRectIndex()}updateNextButton(){let e=this.getSearchResults();e&&e.length&&(this.isNextButtonEnabled()?this.$nextResultButton.removeClass("disabled"):this.$nextResultButton.addClass("disabled"))}updatePrevButton(){let e=this.getSearchResults();e&&e.length&&(this.isPreviousButtonEnabled()?this.$previousResultButton.removeClass("disabled"):this.$previousResultButton.addClass("disabled"))}updatePrintButton(){ee.getBool(this.options.printEnabled,!1)?this.$printButton.show():this.$printButton.hide()}search(e){if(this.terms=e,this.terms===""||this.terms===this.content.enterKeyword){this.extension.showMessage(this.extension.data.config.modules.genericDialogue.content.emptyValue,function(){this.$searchText.focus()});return}this.$searchText.blur(),this.showSearchSpinner(),this.extensionHost.publish(P.SEARCH,this.terms)}getSearchResultPlacemarkers(){return this.$searchResultsContainer.find(".searchResultPlacemarker")}setCurrentSearchResultPlacemarker(){this.getSearchResultPlacemarkers().parent().find(".current").removeClass("current"),te('.searchResultPlacemarker[data-index="'+this.extension.helper.canvasIndex+'"]').addClass("current")}positionSearchResultPlacemarkers(){let e=this.getSearchResults();if(!e||!e.length)return;let o=this.getSearchResultPlacemarkers(),a=o.length===0;o.remove();let n=this.getPageLineRatio(),s=this.$line.position().top,r=this.$line.position().left,A=this;for(let l=0;l<e.length;l++){let u=e[l],m=u.canvasIndex*n,p=te('<div class="searchResultPlacemarker" tabindex="0" data-index="'+u.canvasIndex+'"></div>');p[0].ontouchstart=function(x){A.onPlacemarkerTouchStart.call(this,A)},p.click(function(x){A.onPlacemarkerClick.call(this,A)}),p.mouseenter(function(x){A.onPlacemarkerMouseEnter.call(this,A)}),this.onAccessibleClick(p,x=>{A.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.currentPlacemarkerIndex),A.onPlacemarkerMouseLeave.call(this,x,A)},!1),p.mouseleave(function(x){A.onPlacemarkerMouseLeave.call(this,x,A)}),p.blur(function(x){A.onPlacemarkerMouseLeave.call(this,x,A)}),this.$searchResultsContainer.append(p);let w=s-p.height(),b=r+m-p.width()/2;p.css({top:w,left:b}),l===0&&a&&p.focus()}}onPlacemarkerTouchStart(e){e.placemarkerTouched=!0}onPlacemarkerClick(e){e.placemarkerTouched||(e.placemarkerTouched=!1)}onPlacemarkerMouseEnter(e){if(e.placemarkerTouched)return;let o=te(this);o.addClass("hover");let a=parseInt(o.attr("data-index"));e.extensionHost.publish(P.SEARCH_PREVIEW_START,a);let s=e.getSearchResultPlacemarkers().index(o[0]);e.currentPlacemarkerIndex=a,e.$placemarkerDetails.show();let r="{0} {1}";if(e.isPageModeEnabled()){let p=e.extension.helper.getCanvasByIndex(a),w=It.LanguageMap.getValue(p.getLabel());!w&&e.extension.helper.manifest&&(w=e.extension.helper.manifest.options.defaultLabel),w&&(r=ie.format(r,e.content.pageCaps,w))}else r=ie.format(r,e.content.imageCaps,String(a+1));e.$placemarkerDetailsTop.html(r);let A=e.getSearchResults();if(A){let p=A[s],w="";e.terms&&(w=ie.ellipsis(e.terms,e.options.elideDetailsTermsCount));let b=e.content.instanceFound,x=e.content.instancesFound,I="";p.rects.length===1?(I=ie.format(b,w),e.$placemarkerDetailsBottom.html(I)):(I=ie.format(x,String(p.rects.length),w),e.$placemarkerDetailsBottom.html(I))}let l=o.position(),u=l.top-e.$placemarkerDetails.height(),m=l.left;m<e.$placemarkerDetails.width()/2?m=0-o.width()/2:m>e.$line.width()-e.$placemarkerDetails.width()/2?m=e.$line.width()-e.$placemarkerDetails.width()+o.width()/2:m-=e.$placemarkerDetails.width()/2,e.$placemarkerDetails.css({top:u,left:m})}onPlacemarkerMouseLeave(e,o){o.extensionHost.publish(P.SEARCH_PREVIEW_FINISH);let a=te(this),n=e.toElement||e.relatedTarget,s=te(n).closest(o.$placemarkerDetails).length;n!=o.$placemarkerDetails.get(0)&&s===0&&(o.$placemarkerDetails.hide(),a.removeClass("hover"))}setPageMarkerPosition(){if(this.extension.helper.canvasIndex===null)return;let e=this.getPageLineRatio(),o=this.$line.position().top,a=this.$line.position().left,n=this.extension.helper.canvasIndex*e,s=o,r=a+n;this.$pagePositionMarker.css({top:s,left:r});let A=this.$line.width();r+this.$pagePositionLabel.outerWidth(!0)>A?(r-=this.$pagePositionLabel.outerWidth(!0),this.$pagePositionLabel.removeClass("right"),this.$pagePositionLabel.addClass("left")):(this.$pagePositionLabel.removeClass("left"),this.$pagePositionLabel.addClass("right")),this.$pagePositionLabel.css({top:s,left:r})}clearSearchResults(){if(!this.isSearchEnabled())return;this.getSearchResultPlacemarkers().remove(),this.$searchText.val(this.content.enterKeyword),this.$searchContainer.show(),this.$searchPagerContainer.hide(),this.$searchText.focus()}getPageLineRatio(){let e=this.$line.width();return this.extension.helper.getTotalCanvases()===1?0:e/(this.extension.helper.getTotalCanvases()-1)}canvasIndexChanged(){this.setPageMarkerPosition(),this.setPlacemarkerLabel()}settingsChanged(){this.setPlacemarkerLabel()}setPlacemarkerLabel(){let e=this.content.displaying,o=this.extension.helper.canvasIndex;if(this.isPageModeEnabled()){let a=this.extension.helper.getCanvasByIndex(o),n=It.LanguageMap.getValue(a.getLabel());n||(n=this.content.defaultLabel);let s=this.extension.helper.getLastCanvasLabel(!0);s&&this.$pagePositionLabel.html(ie.format(e,this.content.page,Ue(n),Ue(s)))}else this.$pagePositionLabel.html(ie.format(e,this.content.image,String(o+1),this.extension.helper.getTotalCanvases().toString()))}isPageModeEnabled(){return this.config.options.pageModeEnabled&&this.extension.getMode().toString()===ve.page.toString()&&!ee.getBool(this.config.options.forceImageMode,!1)}showSearchSpinner(){this.$searchText.addClass("searching")}hideSearchSpinner(){this.$searchText.removeClass("searching")}displaySearchResults(e,o){if(!this.isSearchEnabled())return;this.hideSearchSpinner(),this.positionSearchResultPlacemarkers(),this.$searchContainer.hide(),this.$searchPagerControls.css({left:0});let a=this.$searchResultsInfo.find(".info"),n=a.find(".number"),s=a.find(".foundFor"),r=a.find(".terms");o?(a.show(),n.text(this.extension.getTotalAnnotationRects()),e.length===1?s.html(this.content.resultFoundFor):s.html(this.content.resultsFoundFor),r.html(ie.ellipsis(o,this.options.elideResultsTermsCount)),r.prop("title",o)):a.hide(),this.$searchPagerContainer.show(),this.resize()}resize(){super.resize();let e=this.getSearchResults();e&&e.length&&this.positionSearchResultPlacemarkers(),this.setPageMarkerPosition(),this.$searchPagerContainer.width(this.$element.width());let o=this.$element.width()/2;this.$searchPagerControls.css({left:o-this.$searchPagerControls.width()/2}),this.$searchOptions.css({left:o-this.$searchOptions.outerWidth()/2})}};var Xt=Me(),lt=class extends We{constructor(i){super(i)}create(){this.setConfig("multiSelectDialogue"),super.create();let i=this;this.openCommand=E.SHOW_MULTISELECT_DIALOGUE,this.closeCommand=E.HIDE_MULTISELECT_DIALOGUE,this.extensionHost.subscribe(this.openCommand,()=>{this.open(),this.extension.helper.getMultiSelectState().setEnabled(!0),this.galleryComponent.set(this.data)}),this.extensionHost.subscribe(this.closeCommand,()=>{this.close(),this.extension.helper.getMultiSelectState().setEnabled(!1)}),this.$title=Xt('<div role="heading" class="heading"></div>'),this.$content.append(this.$title),this.$title.text(this.content.title),this.$gallery=Xt('<div class="iiif-gallery-component"></div>'),this.$content.append(this.$gallery),this.data={helper:this.extension.helper,chunkedResizingThreshold:this.config.options.galleryThumbChunkedResizingThreshold,content:this.config.content,debug:!1,imageFadeInDuration:300,initialZoom:4,minLabelWidth:20,pageModeEnabled:this.isPageModeEnabled(),searchResults:[],scrollStopDuration:100,sizingEnabled:!0,thumbHeight:this.config.options.galleryThumbHeight,thumbLoadPadding:this.config.options.galleryThumbLoadPadding,thumbWidth:this.config.options.galleryThumbWidth,viewingDirection:this.extension.helper.getViewingDirection()},this.galleryComponent=new Qt({target:this.$gallery[0]}),this.$gallery.find("a.select").addClass("btn btn-primary"),this.galleryComponent.on("multiSelectionMade",o=>{this.extensionHost.publish(E.MULTISELECTION_MADE,o),i.close()},!1),this.$element.hide()}isPageModeEnabled(){return ee.getBool(this.config.options.pageModeEnabled,!0)&&this.extension.getMode().toString()===ve.page.toString()}open(){super.open()}close(){super.close()}resize(){super.resize();let i=this.$gallery.find(".main"),e=this.$gallery.find(".header");i.height(this.$content.height()-this.$title.outerHeight()-this.$title.verticalMargins()-e.height())}};var ht=class{};var se=fe(Et());var Je=fe(it()),ne=Me(),ut=class extends Ot{constructor(e){super(e);this.firstButtonEnabled=!1;this.lastButtonEnabled=!1;this.nextButtonEnabled=!1;this.prevButtonEnabled=!1}create(){if(this.setConfig("pagingHeaderPanel"),super.create(),this.extensionHost.subscribe(E.CANVAS_INDEX_CHANGE,o=>{this.canvasIndexChanged(o)}),this.extensionHost.subscribe(E.SETTINGS_CHANGE,()=>{this.modeChanged(),this.updatePagingToggle()}),this.extensionHost.subscribe(E.CANVAS_INDEX_CHANGE_FAILED,()=>{this.setSearchFieldValue(this.extension.helper.canvasIndex)}),this.extensionHost.subscribe(E.LEFTPANEL_EXPAND_FULL_START,()=>{this.openGallery()}),this.extensionHost.subscribe(E.LEFTPANEL_COLLAPSE_FULL_START,()=>{this.closeGallery()}),this.$prevOptions=ne('<div class="prevOptions"></div>'),this.$centerOptions.append(this.$prevOptions),this.$firstButton=ne(`
<button class="btn imageBtn first" tabindex="0" title="${this.content.first}">
<i class="uv-icon-first" aria-hidden="true"></i>
<span class="sr-only">${this.content.first}</span>
</button>
`),this.$prevOptions.append(this.$firstButton),this.$prevButton=ne(`
<button class="btn imageBtn prev" tabindex="0" title="${this.content.previous}">
<i class="uv-icon-prev" aria-hidden="true"></i>
<span class="sr-only">${this.content.previous}</span>
</button>
`),this.$prevOptions.append(this.$prevButton),this.$modeOptions=ne('<div class="mode"></div>'),this.$centerOptions.append(this.$modeOptions),this.$imageModeLabel=ne('<label for="image">'+this.content.image+"</label>"),this.$modeOptions.append(this.$imageModeLabel),this.$imageModeOption=ne('<input type="radio" id="image" name="mode" tabindex="0"/>'),this.$modeOptions.append(this.$imageModeOption),this.$pageModeLabel=ne('<label for="page"></label>'),this.$modeOptions.append(this.$pageModeLabel),this.$pageModeOption=ne('<input type="radio" id="page" name="mode" tabindex="0"/>'),this.$modeOptions.append(this.$pageModeOption),this.$search=ne('<div class="search"></div>'),this.$centerOptions.append(this.$search),this.$searchText=ne('<input class="searchText" maxlength="50" type="text" tabindex="0" aria-label="'+this.content.pageSearchLabel+'"/>'),this.$search.append(this.$searchText),ee.getBool(this.options.autoCompleteBoxEnabled,!0))this.$searchText.hide(),this.$autoCompleteBox=ne('<input class="autocompleteText" type="text" maxlength="100" aria-label="'+this.content.pageSearchLabel+'"/>'),this.$search.append(this.$autoCompleteBox),new Ye(this.$autoCompleteBox,(o,a)=>{let n=[],s=this.extension.helper.getCanvases();if(this.isPageModeEnabled())for(let r=0;r<s.length;r++){let A=s[r],l=Je.LanguageMap.getValue(A.getLabel());l&&l.startsWith(o)&&n.push(l)}else for(let r=0;r<s.length;r++){let A=s[r];A.index.toString().startsWith(o)&&n.push(A.index.toString())}a(n)},o=>o,o=>{this.search(o)},300,0,ee.getBool(this.options.autocompleteAllowWords,!1));else if(ee.getBool(this.options.imageSelectionBoxEnabled,!0)){this.$selectionBoxOptions=ne('<div class="image-selectionbox-options"></div>'),this.$centerOptions.append(this.$selectionBoxOptions),this.$imageSelectionBox=ne('<select class="image-selectionbox" name="image-select" tabindex="0" ></select>'),this.$selectionBoxOptions.append(this.$imageSelectionBox);for(let o=0;o<this.extension.helper.getTotalCanvases();o++){let a=this.extension.helper.getCanvasByIndex(o),n=Ue(Je.LanguageMap.getValue(a.getLabel(),this.extension.helper.options.locale));this.$imageSelectionBox.append("<option value="+o+">"+n+"</option>")}this.$imageSelectionBox.change(()=>{let o=parseInt(this.$imageSelectionBox.val());this.extensionHost.publish(P.IMAGE_SEARCH,o)})}this.$total=ne('<span class="total"></span>'),this.$search.append(this.$total),this.$searchButton=ne(`<button class="go btn btn-primary" tabindex="0">${this.content.go}</button>`),this.$search.append(this.$searchButton),this.$nextOptions=ne('<div class="nextOptions"></div>'),this.$centerOptions.append(this.$nextOptions),this.$nextButton=ne(`
<button class="btn imageBtn next" tabindex="0" title="${this.content.next}">
<i class="uv-icon-next" aria-hidden="true"></i>
<span class="sr-only">${this.content.next}</span>
</button>
`),this.$nextOptions.append(this.$nextButton),this.$lastButton=ne(`
<button class="btn imageBtn last" tabindex="0" title="${this.content.last}">
<i class="uv-icon-last" aria-hidden="true"></i>
<span class="sr-only">${this.content.last}</span>
</button>
`),this.$nextOptions.append(this.$lastButton),this.isPageModeEnabled()?(this.$pageModeOption.attr("checked","checked"),this.$pageModeOption.removeAttr("disabled"),this.$pageModeLabel.removeClass("disabled")):(this.$imageModeOption.attr("checked","checked"),this.$pageModeOption.attr("disabled","disabled"),this.$pageModeLabel.addClass("disabled")),this.extension.helper.getManifestType()===Je.ManifestType.MANUSCRIPT?this.$pageModeLabel.text(this.content.folio):this.$pageModeLabel.text(this.content.page),this.$galleryButton=ne(`
<button class="btn imageBtn gallery" title="${this.content.gallery}">
<i class="uv-icon-gallery" aria-hidden="true"></i>
<span class="sr-only">${this.content.gallery}</span>
</button>
`),this.$rightOptions.prepend(this.$galleryButton),this.$pagingToggleButtons=ne('<div class="pagingToggleButtons"></div>'),this.$rightOptions.prepend(this.$pagingToggleButtons),this.$oneUpButton=ne(`
<button class="btn imageBtn one-up" title="${this.content.oneUp}">
<i class="uv-icon-one-up" aria-hidden="true"></i>
<span class="sr-only">${this.content.oneUp}</span>
</button>`),this.$pagingToggleButtons.append(this.$oneUpButton),this.$twoUpButton=ne(`
<button class="btn imageBtn two-up" title="${this.content.twoUp}">
<i class="uv-icon-two-up" aria-hidden="true"></i>
<span class="sr-only">${this.content.twoUp}</span>
</button>
`),this.$pagingToggleButtons.append(this.$twoUpButton),this.updatePagingToggle(),this.updateGalleryButton(),this.$oneUpButton.onPressed(()=>{this.updateSettings({pagingEnabled:!1}),this.extensionHost.publish(P.PAGING_TOGGLED,!1)}),this.$twoUpButton.onPressed(()=>{this.updateSettings({pagingEnabled:!0}),this.extensionHost.publish(P.PAGING_TOGGLED,!0)}),this.$galleryButton.onPressed(()=>{this.extensionHost.publish(E.TOGGLE_EXPAND_LEFT_PANEL)}),this.setNavigationTitles(),this.setTotal();let e=this.extension.helper.getViewingDirection()||se.ViewingDirection.LEFT_TO_RIGHT;this.extension.helper.getTotalCanvases()===1&&this.$centerOptions.hide(),this.$firstButton.onPressed(()=>{switch(e.toString()){case se.ViewingDirection.LEFT_TO_RIGHT:case se.ViewingDirection.TOP_TO_BOTTOM:case se.ViewingDirection.BOTTOM_TO_TOP:this.extensionHost.publish(E.FIRST);break;case se.ViewingDirection.RIGHT_TO_LEFT:this.extensionHost.publish(E.LAST);break}}),this.$prevButton.onPressed(()=>{switch(e.toString()){case se.ViewingDirection.LEFT_TO_RIGHT:case se.ViewingDirection.BOTTOM_TO_TOP:case se.ViewingDirection.TOP_TO_BOTTOM:this.extensionHost.publish(E.PREV);break;case se.ViewingDirection.RIGHT_TO_LEFT:this.extensionHost.publish(E.NEXT);break}}),this.$nextButton.onPressed(()=>{switch(e.toString()){case se.ViewingDirection.LEFT_TO_RIGHT:case se.ViewingDirection.BOTTOM_TO_TOP:case se.ViewingDirection.TOP_TO_BOTTOM:this.extensionHost.publish(E.NEXT);break;case se.ViewingDirection.RIGHT_TO_LEFT:this.extensionHost.publish(E.PREV);break}}),this.$lastButton.onPressed(()=>{switch(e.toString()){case se.ViewingDirection.LEFT_TO_RIGHT:case se.ViewingDirection.TOP_TO_BOTTOM:case se.ViewingDirection.BOTTOM_TO_TOP:this.extensionHost.publish(E.LAST);break;case se.ViewingDirection.RIGHT_TO_LEFT:this.extensionHost.publish(E.FIRST);break}}),this.config.options.pageModeEnabled?(this.$imageModeOption.on("click",()=>{this.extensionHost.publish(P.MODE_CHANGE,ve.image.toString())}),this.$pageModeOption.on("click",()=>{this.extensionHost.publish(P.MODE_CHANGE,ve.page.toString())})):(this.$imageModeOption.hide(),this.$pageModeLabel.hide(),this.$pageModeOption.hide()),this.$searchText.onEnter(()=>{this.$searchText.blur(),this.search(this.$searchText.val())}),this.$searchText.click(function(){ne(this).select()}),this.onAccessibleClick(this.$searchButton,()=>{this.options.autoCompleteBoxEnabled?this.search(this.$autoCompleteBox.val()):this.search(this.$searchText.val())}),this.options.modeOptionsEnabled===!1&&(this.$modeOptions.hide(),this.$centerOptions.addClass("modeOptionsDisabled")),this.options.imageSelectionBoxEnabled===!0&&this.options.autoCompleteBoxEnabled!==!0&&this.$search.hide(),ee.getBool(this.options.pagingToggleEnabled,!0)||this.$pagingToggleButtons.hide()}openGallery(){this.$oneUpButton.removeClass("on"),this.$twoUpButton.removeClass("on"),this.$galleryButton.addClass("on")}closeGallery(){this.updatePagingToggle(),this.$galleryButton.removeClass("on")}isPageModeEnabled(){return this.config.options.pageModeEnabled&&this.extension.getMode().toString()===ve.page.toString()}setNavigationTitles(){this.isPageModeEnabled()?this.extension.helper.isRightToLeft()?(this.$firstButton.prop("title",this.content.lastPage),this.$firstButton.find("span").text(this.content.lastPage),this.$prevButton.prop("title",this.content.nextPage),this.$prevButton.find("span").text(this.content.nextPage),this.$nextButton.prop("title",this.content.previousPage),this.$nextButton.find("span").text(this.content.previousPage),this.$lastButton.prop("title",this.content.firstPage),this.$lastButton.find("span").text(this.content.firstPage)):(this.$firstButton.prop("title",this.content.firstPage),this.$firstButton.find("span").text(this.content.firstPage),this.$prevButton.prop("title",this.content.previousPage),this.$prevButton.find("span").text(this.content.previousPage),this.$nextButton.prop("title",this.content.nextPage),this.$nextButton.find("span").text(this.content.nextPage),this.$lastButton.prop("title",this.content.lastPage),this.$lastButton.find("span").text(this.content.lastPage)):this.extension.helper.isRightToLeft()?(this.$firstButton.prop("title",this.content.lastImage),this.$firstButton.find("span").text(this.content.lastPage),this.$prevButton.prop("title",this.content.nextImage),this.$prevButton.find("span").text(this.content.nextImage),this.$nextButton.prop("title",this.content.previousImage),this.$nextButton.find("span").text(this.content.previousImage),this.$lastButton.prop("title",this.content.firstImage),this.$lastButton.find("span").text(this.content.firstImage)):(this.$firstButton.prop("title",this.content.firstImage),this.$firstButton.find("span").text(this.content.firstImage),this.$prevButton.prop("title",this.content.previousImage),this.$prevButton.find("span").text(this.content.previousImage),this.$nextButton.prop("title",this.content.nextImage),this.$nextButton.find("span").text(this.content.nextImage),this.$lastButton.prop("title",this.content.lastImage),this.$lastButton.find("span").text(this.content.lastImage))}updatePagingToggle(){if(!this.pagingToggleIsVisible()){this.$pagingToggleButtons.hide();return}this.extension.isPagingSettingEnabled()?(this.$oneUpButton.removeClass("on"),this.$twoUpButton.addClass("on")):(this.$twoUpButton.removeClass("on"),this.$oneUpButton.addClass("on"))}pagingToggleIsVisible(){return ee.getBool(this.options.pagingToggleEnabled,!0)&&this.extension.helper.isPagingAvailable()}updateGalleryButton(){this.galleryIsVisible()||this.$galleryButton.hide()}galleryIsVisible(){return ee.getBool(this.options.galleryButtonEnabled,!0)&&this.extension.isLeftPanelEnabled()}setTotal(){let e=this.content.of;this.isPageModeEnabled()?this.$total.html(ie.format(e,this.extension.helper.getLastCanvasLabel(!0))):this.$total.html(ie.format(e,this.extension.helper.getTotalCanvases().toString()))}setSearchFieldValue(e){let o=this.extension.helper.getCanvasByIndex(e),a=null;if(this.isPageModeEnabled()){let n=Je.LanguageMap.getValue(o.getLabel());n==="-"?a="":a=n}else e+=1,a=e.toString();this.options.autoCompleteBoxEnabled?this.$autoCompleteBox.val(a):this.$searchText.val(a)}search(e){if(!e){this.extension.showMessage(this.content.emptyValue),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE_FAILED);return}if(this.isPageModeEnabled())this.extensionHost.publish(P.PAGE_SEARCH,e);else{let o;if(this.options.autoCompleteBoxEnabled?o=parseInt(this.$autoCompleteBox.val(),10):o=parseInt(this.$searchText.val(),10),o-=1,isNaN(o)){this.extension.showMessage(this.extension.data.config.modules.genericDialogue.content.invalidNumber),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE_FAILED);return}if(!this.extension.helper.getCanvasByIndex(o)){this.extension.showMessage(this.extension.data.config.modules.genericDialogue.content.pageNotFound),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE_FAILED);return}this.extensionHost.publish(P.IMAGE_SEARCH,o)}}canvasIndexChanged(e){this.setSearchFieldValue(e),this.options.imageSelectionBoxEnabled===!0&&this.options.autoCompleteBoxEnabled!==!0&&this.$imageSelectionBox.val(e),(this.extension.helper.getViewingDirection()||se.ViewingDirection.LEFT_TO_RIGHT)===se.ViewingDirection.RIGHT_TO_LEFT?(this.extension.helper.isFirstCanvas()?(this.disableLastButton(),this.disableNextButton()):(this.enableLastButton(),this.enableNextButton()),this.extension.helper.isLastCanvas()?(this.disableFirstButton(),this.disablePrevButton()):(this.enableFirstButton(),this.enablePrevButton())):(this.extension.helper.isFirstCanvas()?(this.disableFirstButton(),this.disablePrevButton()):(this.enableFirstButton(),this.enablePrevButton()),this.extension.helper.isLastCanvas()?(this.disableLastButton(),this.disableNextButton()):(this.enableLastButton(),this.enableNextButton()))}disableFirstButton(){this.firstButtonEnabled=!1,this.$firstButton.disable(),this.$firstButton.attr("disabled","disabled")}enableFirstButton(){this.firstButtonEnabled=!0,this.$firstButton.enable(),this.$firstButton.removeAttr("disabled")}disableLastButton(){this.lastButtonEnabled=!1,this.$lastButton.disable(),this.$lastButton.attr("disabled","disabled")}enableLastButton(){this.lastButtonEnabled=!0,this.$lastButton.enable(),this.$lastButton.removeAttr("disabled")}disablePrevButton(){this.prevButtonEnabled=!1,this.$prevButton.disable(),this.$prevButton.attr("disabled","disabled")}enablePrevButton(){this.prevButtonEnabled=!0,this.$prevButton.enable(),this.$prevButton.removeAttr("disabled")}disableNextButton(){this.nextButtonEnabled=!1,this.$nextButton.disable(),this.$nextButton.attr("disabled","disabled")}enableNextButton(){this.nextButtonEnabled=!0,this.$nextButton.enable(),this.$nextButton.removeAttr("disabled")}modeChanged(){this.setSearchFieldValue(this.extension.helper.canvasIndex),this.setNavigationTitles(),this.setTotal()}resize(){super.resize(),this.extension.isMobileMetric()?(this.pagingToggleIsVisible()&&this.$pagingToggleButtons.hide(),this.galleryIsVisible()&&this.$galleryButton.hide()):(this.pagingToggleIsVisible()&&this.$pagingToggleButtons.show(),this.galleryIsVisible()&&this.$galleryButton.show())}};var Ge=fe(dt()),bn=fe(qt()),Kt=fe(Et());var be=Me(),pt=class extends Gt{constructor(e){super(e);this.controlsVisible=!1;this.isCreated=!1;this.isLoaded=!1;this.isFirstLoad=!0;this.navigatedFromSearch=!1;this.nextButtonEnabled=!1;this.prevButtonEnabled=!1}create(){this.setConfig("openSeadragonCenterPanel"),super.create(),this.viewerId="osd"+new Date().getTime(),this.$viewer=be('<div id="'+this.viewerId+'" class="viewer"></div>'),this.$content.prepend(this.$viewer),this.extensionHost.subscribe(E.ANNOTATIONS,e=>{this.overlayAnnotations()}),this.extensionHost.subscribe(E.SETTINGS_CHANGE,e=>{this.viewer.gestureSettingsMouse.clickToZoom=e.clickToZoomEnabled,this.viewer.controlsFadeLength=this.getControlsFadeLength()}),this.extensionHost.subscribe(E.OPEN_EXTERNAL_RESOURCE,e=>{this.whenResized(async()=>{this.isCreated||this.createUI(),this.isLoaded=!1,await this.openMedia(e),this.isLoaded=!0,this.extensionHost.publish($e.EXTERNAL_RESOURCE_OPENED),this.extensionHost.publish($e.LOAD)})}),this.extensionHost.subscribe(E.CLEAR_ANNOTATIONS,()=>{this.whenCreated(()=>{this.extension.currentAnnotationRect=null,this.clearAnnotations()})}),this.extensionHost.subscribe(P.NEXT_SEARCH_RESULT,()=>{this.whenCreated(()=>{this.nextAnnotation()})}),this.extensionHost.subscribe(P.PREV_SEARCH_RESULT,()=>{this.whenCreated(()=>{this.prevAnnotation()})}),this.extensionHost.subscribe(P.ZOOM_IN,()=>{this.whenCreated(()=>{this.zoomIn()})}),this.extensionHost.subscribe(P.ZOOM_OUT,()=>{this.whenCreated(()=>{this.zoomOut()})}),this.extensionHost.subscribe(P.ROTATE,()=>{this.whenCreated(()=>{this.rotateRight()})}),this.extensionHost.subscribe(E.METRIC_CHANGE,()=>{this.whenCreated(()=>{this.updateResponsiveView()})}),this.extensionHost.subscribe(E.SET_TARGET,e=>{this.whenLoaded(()=>{this.fitToBounds(e,!1)})}),this.extensionHost.subscribe(E.SET_ROTATION,e=>{this.whenLoaded(()=>{this.viewer.viewport.setRotation(e)})})}whenCreated(e){bt.waitFor(()=>this.isCreated,e)}whenLoaded(e){bt.waitFor(()=>this.isLoaded,e)}zoomIn(){this.viewer.viewport.zoomTo(this.viewer.viewport.getZoom(!0)*2)}zoomOut(){this.viewer.viewport.zoomTo(this.viewer.viewport.getZoom(!0)*.5)}rotateRight(){this.viewer.viewport.setRotation(this.viewer.viewport.getRotation()+90)}updateResponsiveView(){this.setNavigatorVisible(),this.viewer.autoHideControls=this.extension.isDesktopMetric();let e=n=>{this.viewer.autoHideControls=!0},o=()=>{this.viewer.autoHideControls=!1};[this.$zoomInButton,this.$zoomOutButton,this.$goHomeButton,this.$rotateButton,this.$adjustImageButton].forEach(n=>{n.on("focus",o),n.on("focusout",e)})}async createUI(){this.$spinner=be('<div class="spinner"></div>'),this.$content.append(this.$spinner),this.showAdjustImageButton=ee.getBool(this.config.options.showAdjustImageControl,!1);let e="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==";this.viewer=(0,Ge.default)({element:this.$viewer[0],showNavigationControl:!0,showNavigator:!0,showRotationControl:!0,showHomeControl:ee.getBool(this.config.options.showHomeControl,!1),showFullPageControl:!1,defaultZoomLevel:this.config.options.defaultZoomLevel||0,maxZoomPixelRatio:this.config.options.maxZoomPixelRatio||2,controlsFadeDelay:this.config.options.controlsFadeDelay||250,controlsFadeLength:this.getControlsFadeLength(),navigatorPosition:this.config.options.navigatorPosition||"BOTTOM_RIGHT",navigatorHeight:"100px",navigatorWidth:"100px",animationTime:this.config.options.animationTime||1.2,visibilityRatio:this.config.options.visibilityRatio||.5,constrainDuringPan:ee.getBool(this.config.options.constrainDuringPan,!1),immediateRender:ee.getBool(this.config.options.immediateRender,!1),blendTime:this.config.options.blendTime||0,autoHideControls:ee.getBool(this.config.options.autoHideControls,!0),prefixUrl:null,gestureSettingsMouse:{clickToZoom:ee.getBool(this.extension.data.config.options.clickToZoomEnabled,!0)},navImages:{zoomIn:{REST:e,GROUP:e,HOVER:e,DOWN:e},zoomOut:{REST:e,GROUP:e,HOVER:e,DOWN:e},home:{REST:e,GROUP:e,HOVER:e,DOWN:e},rotateright:{REST:e,GROUP:e,HOVER:e,DOWN:e},rotateleft:{REST:e,GROUP:e,HOVER:e,DOWN:e},next:{REST:e,GROUP:e,HOVER:e,DOWN:e},previous:{REST:e,GROUP:e,HOVER:e,DOWN:e}}});let o=this,a=Nt(u=>{let m=o.extension.helper.getCurrentCanvas();var p=o.viewer.viewport.pointFromPixel(u.position),w=o.viewer.viewport.viewportToImageCoordinates(p.x,p.y);this.extensionHost.publish(P.DOUBLECLICK,{target:`${m.id}#xywh=${Math.round(w.x)},${Math.round(w.y)},1,1`})},100);this.viewer.addViewerInputHook({hooks:[{tracker:"viewer",handler:"dblClickHandler",hookHandler:u=>{let m=this.extension.getSettings(),p=this.extension.helper.isPagingAvailable();(p&&!m.pagingEnabled||!p)&&this.config.options.doubleClickAnnotationEnabled&&a(u)}}]});let n=this.$viewer.find('div[title="Zoom in"]');this.$zoomInButton=be("<button />").append(n.contents()),this.$zoomInButton.insertAfter(n),n.remove(),this.$zoomInButton.attr("tabindex",0),this.$zoomInButton.attr("title",this.content.zoomIn),this.$zoomInButton.attr("aria-label",this.content.zoomIn),this.$zoomInButton.addClass("zoomIn viewportNavButton"),this.onAccessibleClick(this.$zoomInButton,()=>{this.zoomIn()});let s=this.$viewer.find('div[title="Zoom out"]');this.$zoomOutButton=be("<button />").append(s.contents()),this.$zoomOutButton.insertAfter(s),n.remove(),this.$zoomOutButton.attr("tabindex",0),this.$zoomOutButton.attr("title",this.content.zoomOut),this.$zoomOutButton.attr("aria-label",this.content.zoomOut),this.$zoomOutButton.addClass("zoomOut viewportNavButton"),this.onAccessibleClick(this.$zoomOutButton,()=>{this.zoomOut()});let r=this.$viewer.find('div[title="Go home"]');this.$goHomeButton=be("<button />").append(r.contents()),this.$goHomeButton.insertAfter(r),r.remove(),this.$goHomeButton.attr("tabindex",0),this.$goHomeButton.attr("title",this.content.goHome),this.$goHomeButton.attr("aria-label",this.content.goHome),this.$goHomeButton.addClass("goHome viewportNavButton"),this.onAccessibleClick(this.$goHomeButton,()=>{this.goHome()});let A=this.$viewer.find('div[title="Rotate right"]');this.$rotateButton=be("<button />").append(A.contents()),this.$rotateButton.insertAfter(A),A.remove(),this.$rotateButton.attr("tabindex",0),this.$rotateButton.attr("title",this.content.rotateRight),this.$rotateButton.attr("aria-label",this.content.rotateRight),this.$rotateButton.addClass("rotate viewportNavButton"),this.onAccessibleClick(this.$rotateButton,()=>{this.rotateRight()}),this.showAdjustImageButton&&(this.$adjustImageButton=this.$rotateButton.clone(),this.$adjustImageButton.attr("title",this.content.adjustImage),this.$adjustImageButton.attr("aria-label",this.content.adjustImage),this.$adjustImageButton.switchClass("rotate","adjustImage"),this.$adjustImageButton.attr("tabindex",0),this.$adjustImageButton.onPressed(()=>{this.extensionHost.publish(E.SHOW_ADJUSTIMAGE_DIALOGUE)}),this.$adjustImageButton.insertAfter(this.$rotateButton),this.onAccessibleClick(this.$adjustImageButton,()=>{this.extensionHost.publish(E.SHOW_ADJUSTIMAGE_DIALOGUE)})),this.$zoomInButton.add(this.$zoomOutButton).add(this.$goHomeButton).add(this.$rotateButton).add(this.$adjustImageButton).on("focus",()=>{this.controlsVisible||(this.controlsVisible=!0,this.viewer.setControlsEnabled(!0))}),this.$zoomInButton.add(this.$adjustImageButton).on("blur",()=>{this.controlsVisible&&(this.controlsVisible=!1,this.viewer.setControlsEnabled(!1))}),this.$viewportNavButtonsContainer=this.$viewer.find(".openseadragon-container > div:not(.openseadragon-canvas):first"),this.$viewportNavButtons=this.$viewportNavButtonsContainer.find(".viewportNavButton"),this.$canvas=be(this.viewer.canvas);let l=this.extension.getSettings();if(this.extension.data.config?.options.saveUserSettings&&l.rememberSettings){let u=l.contrastPercent,m=l.brightnessPercent,p=l.saturationPercent;this.$canvas[0].children[0].style.filter=`contrast(${u}%) brightness(${m}%) saturate(${p}%)`}this.$canvas.on("contextmenu",()=>!1),this.$navigator=this.$viewer.find(".navigator"),this.setNavigatorVisible(),this.$element.on("mousemove",()=>{this.controlsVisible||(this.controlsVisible=!0,this.viewer.setControlsEnabled(!0))}),this.$element.on("mouseleave",()=>{this.controlsVisible&&(this.controlsVisible=!1,this.viewer.setControlsEnabled(!1))}),this.$element.on("mousemove",()=>{if(!this.$prevButton.ismouseover()&&!this.$nextButton.ismouseover()&&!this.$viewer.find(".navigator").ismouseover()){if(!this.controlsVisible)return;this.controlsVisible=!1,this.viewer.setControlsEnabled(!1)}},this.config.options.controlsFadeAfterInactive),this.viewer.addHandler("tile-drawn",()=>{this.$spinner.hide()}),this.viewer.addHandler("resize",u=>{this.extensionHost.publish(P.OPENSEADRAGON_RESIZE,u),this.viewerResize(u)}),this.viewer.addHandler("animation-start",u=>{this.extensionHost.publish(P.OPENSEADRAGON_ANIMATION_START,u)}),this.viewer.addHandler("animation",u=>{this.extensionHost.publish(P.OPENSEADRAGON_ANIMATION,u)}),this.viewer.addHandler("animation-finish",u=>{this.currentBounds=this.getViewportBounds(),this.updateVisibleAnnotationRects(),this.extensionHost.publish(P.OPENSEADRAGON_ANIMATION_FINISH,u)}),this.viewer.addHandler("rotate",u=>{this.extensionHost.publish(P.OPENSEADRAGON_ROTATION,u.degrees)}),this.title=this.extension.helper.getLabel(),this.createNavigationButtons(),this.hidePrevButton(),this.hideNextButton(),this.isCreated=!0}createNavigationButtons(){let e=this.extension.helper.getViewingDirection()||he.LEFT_TO_RIGHT;switch(this.$prevButton=be(`<button class="btn btn-default paging prev" title="${this.content.previousImage}">
<i class="uv-icon-prev" aria-hidden="true"></i>
<span class="sr-only">${this.content.previousImage}</span>
</button>`),this.extension.helper.isRightToLeft()?this.$prevButton.prop("title",this.content.nextImage).attr("aria-label",this.content.nextImage):this.$prevButton.prop("title",this.content.previousImage).attr("aria-label",this.content.previousImage),this.$nextButton=be(`<button class="btn btn-default paging next" title="${this.content.nextImage}">
<i class="uv-icon-next" aria-hidden="true"></i>
<span class="sr-only">${this.content.nextImage}</span>
</button>`),this.extension.helper.isRightToLeft()?this.$nextButton.prop("title",this.content.previousImage).attr("aria-label",this.content.previousImage):this.$nextButton.prop("title",this.content.nextImage).attr("aria-label",this.content.nextImage),this.viewer.addControl(this.$prevButton[0],{anchor:Ge.default.ControlAnchor.TOP_LEFT}),this.viewer.addControl(this.$nextButton[0],{anchor:Ge.default.ControlAnchor.TOP_RIGHT}),e){case he.BOTTOM_TO_TOP:case he.TOP_TO_BOTTOM:this.$prevButton.addClass("vertical"),this.$nextButton.addClass("vertical");break}let o=this;this.onAccessibleClick(this.$prevButton,a=>{if(a.preventDefault(),Ge.default.cancelEvent(a),!!o.prevButtonEnabled)switch(e){case he.LEFT_TO_RIGHT:case he.BOTTOM_TO_TOP:case he.TOP_TO_BOTTOM:this.extensionHost.publish(E.PREV);break;case he.RIGHT_TO_LEFT:this.extensionHost.publish(E.NEXT);break}}),this.onAccessibleClick(this.$nextButton,a=>{if(a.preventDefault(),Ge.default.cancelEvent(a),!!o.nextButtonEnabled)switch(e){case he.LEFT_TO_RIGHT:case he.BOTTOM_TO_TOP:case he.TOP_TO_BOTTOM:this.extensionHost.publish(E.NEXT);break;case he.RIGHT_TO_LEFT:this.extensionHost.publish(E.PREV);break}}),this.$prevButton.add(this.$nextButton).on("focus",()=>{this.controlsVisible||(this.controlsVisible=!0,this.viewer.setControlsEnabled(!0))}),this.$prevButton.add(this.$nextButton).on("blur",()=>{this.controlsVisible&&(this.controlsVisible=!1,this.viewer.setControlsEnabled(!1))})}async getGirderTileSource(){return new Promise(e=>{let a=this.extension.helper.getCurrentCanvas().getContent();if(a.length){let s=a[0].getBody();if(s.length){let r=s[0].getServices();if(r.length){let A=r[0].id,l=A;l.endsWith("/")||(l+="/"),l+="tiles",A.endsWith("/")&&(A=A.substr(0,A.length-1)),fetch(l).then(u=>u.json()).then(u=>{let m={height:u.sizeY,width:u.sizeX,tileWidth:u.tileWidth,tileHeight:u.tileHeight,minLevel:0,maxLevel:u.levels-1,units:"mm",spacing:[u.mm_x,u.mm_y],getTileUrl:function(p,w,b,x){var I=l+"/zxy/"+p+"/"+w+"/"+b;return x&&(I+="?"+be.param(x)),I}};u.mm_x||(m.units="pixels",m.spacing=[1,1]),e(m)})}}}})}async openMedia(e){if(!this.viewer)return;this.$spinner.show(),this.items=[];let o=await this.extension.getExternalResources(e),a=this.extension.format===Kt.MediaType.GIRDER;try{this.viewer.close(),o=this.getPagePositions(o);for(let n=0;n<o.length;n++){let s=o[n],r;s.hasServiceDescriptor?r=s:a?r=await this.getGirderTileSource():r={type:"image",url:s.id,buildPyramid:!1},this.viewer.addTiledImage({tileSource:r,x:s.x,y:s.y,width:s.width,success:A=>{this.items.push(A),this.items.length===o.length&&this.openPagesHandler(),this.resize(),this.goHome()}})}}catch{}}getPagePositions(e){let o,a,n,s,r,A;if(e.length>1)if(e.length===2)this.extension.helper.isVerticallyAligned()?(n=e[0],n.y=0,s=e[1],s.y=n.height+this.config.options.pageGap):(o=e[0],o.x=0,a=e[1],a.x=o.width+this.config.options.pageGap);else if(this.extension.helper.isVerticallyAligned())if(this.extension.helper.isTopToBottom())for(let l=0;l<e.length-1;l++)r=e[l],A=e[l+1],A.y=(r.y||0)+r.height;else for(let l=e.length;l>0;l--)r=e[l],A=e[l-1],A.y=(r.y||0)-r.height;else if(this.extension.helper.isLeftToRight())for(let l=0;l<e.length-1;l++)r=e[l],A=e[l+1],A.x=(r.x||0)+r.width;else for(let l=e.length-1;l>0;l--)r=e[l],A=e[l-1],A.x=(r.x||0)-r.width;return e}openPagesHandler(){this.extensionHost.publish(P.OPENSEADRAGON_OPEN),this.extension.helper.isMultiCanvas()&&!this.extension.helper.isContinuous()&&(this.showPrevButton(),this.showNextButton(),be(".navigator").addClass("extraMargin"),(this.extension.helper.getViewingDirection()||he.LEFT_TO_RIGHT)===he.RIGHT_TO_LEFT?(this.extension.helper.isFirstCanvas()?this.disableNextButton():this.enableNextButton(),this.extension.helper.isLastCanvas()?this.disablePrevButton():this.enablePrevButton()):(this.extension.helper.isFirstCanvas()?this.disablePrevButton():this.enablePrevButton(),this.extension.helper.isLastCanvas()?this.disableNextButton():this.enableNextButton())),this.setNavigatorVisible(),this.overlayAnnotations(),this.updateBounds(),this.navigatedFromSearch&&(this.navigatedFromSearch=!1,this.zoomToInitialAnnotation()),this.isFirstLoad=!1}zoomToInitialAnnotation(){let e=this.getInitialAnnotationRect();this.extension.previousAnnotationRect=null,this.extension.currentAnnotationRect=null,e&&this.isZoomToSearchResultEnabled()&&this.zoomToAnnotation(e)}overlayAnnotations(){let e=this.getAnnotationsForCurrentImages();this.clearAnnotations();for(let o=0;o<e.length;o++){let a=e[o],n=this.getAnnotationOverlayRects(a);for(let s=0;s<n.length;s++){let r=n[s],A=document.createElement("DIV");if(A.id="annotation-"+r.canvasIndex+"-"+r.resultIndex,A.title=Ue(r.chars),r.width===1&&r.height===1){A.className="annotationPin",A.onclick=u=>{u.preventDefault(),this.extensionHost.publish(E.PINPOINT_ANNOTATION_CLICKED,s)};let l=document.createElement("SPAN");l.innerText=String(s+1),A.appendChild(l)}else A.className="annotationRect";this.viewer.addOverlay(A,r)}}e.length&&this.shouldZoomToInitialAnnotation()&&this.zoomToInitialAnnotation()}updateBounds(){let e=this.extension.getSettings();if(this.isFirstLoad){this.initialRotation=this.extension.data.rotation,this.initialRotation&&this.viewer.viewport.setRotation(parseInt(this.initialRotation));let o=this.extension.data.xywh;o&&(this.initialBounds=Se.fromString(o),this.currentBounds=this.initialBounds,this.fitToBounds(this.currentBounds))}else e.preserveViewport&&this.currentBounds?this.fitToBounds(this.currentBounds):this.goHome()}goHome(){this.viewer.viewport.goHome(!0)}disablePrevButton(){this.prevButtonEnabled=!1,this.$prevButton.addClass("disabled")}enablePrevButton(){this.prevButtonEnabled=!0,this.$prevButton.removeClass("disabled")}hidePrevButton(){this.disablePrevButton(),this.$prevButton.hide()}showPrevButton(){this.enablePrevButton(),this.$prevButton.show()}disableNextButton(){this.nextButtonEnabled=!1,this.$nextButton.addClass("disabled")}enableNextButton(){this.nextButtonEnabled=!0,this.$nextButton.removeClass("disabled")}hideNextButton(){this.disableNextButton(),this.$nextButton.hide()}showNextButton(){this.enableNextButton(),this.$nextButton.show()}fitToBounds(e,o=!0){let a=new Ge.default.Rect;a.x=Number(e.x),a.y=Number(e.y),a.width=Number(e.w),a.height=Number(e.h),setTimeout(()=>{this.viewer.viewport.fitBoundsWithConstraints(a,o)},100)}getCroppedImageBounds(){if(!this.viewer||!this.viewer.viewport)return null;let e=this.extension.helper.getCurrentCanvas(),o=this.extension.getCroppedImageDimensions(e,this.viewer);return o?new Se(o.regionPos.x,o.regionPos.y,o.region.width,o.region.height).toString():null}getViewportBounds(){if(!this.viewer||!this.viewer.viewport)return null;let e=this.viewer.viewport.getBounds(!0);return new Se(Math.floor(e.x),Math.floor(e.y),Math.floor(e.width),Math.floor(e.height))}viewerResize(e){if(!e.viewport)return;let o=e.viewport.getCenter(!0);o&&setTimeout(function(){e.viewport.panTo(o,!0)},1)}clearAnnotations(){this.viewer.clearOverlays()}getAnnotationsForCurrentImages(){let e=[],o=this.extension.annotations;if(!o||!o.length)return e;let a=this.extension.getPagedIndices();for(let n=0;n<a.length;n++){let s=a[n];for(let r=0;r<o.length;r++)if(o[r].canvasIndex===s){e.push(o[r]);break}}return e}getAnnotationRectsForCurrentImages(){let e=this.getAnnotationsForCurrentImages();return e.length?e.map(o=>o.rects).reduce((o,a)=>o.concat(a)):[]}updateVisibleAnnotationRects(){let e=this.getAnnotationRectsForCurrentImages();for(let o=0;o<e.length;o++){let a=e[o],n=this.viewer.viewport.getBounds();a.isVisible=Pt.hitRect(n.x,n.y,n.width,n.height,a.viewportX,a.viewportY)}}getAnnotationRectIndex(e){return this.getAnnotationRectsForCurrentImages().indexOf(e)}isZoomToSearchResultEnabled(){return ee.getBool(this.extension.data.config.options.zoomToSearchResultEnabled,!0)}shouldZoomToInitialAnnotation(){return ee.getBool(this.config.options.zoomToInitialAnnotation,!0)}prevAnnotation(){let e=this.getAnnotationRectsForCurrentImages(),o=this.extension.currentAnnotationRect,a=o?this.getAnnotationRectIndex(o):e.length,n=null;for(let s=a-1;s>=0;s--){n=e[s];break}n&&this.isZoomToSearchResultEnabled()?n.canvasIndex<this.extension.helper.canvasIndex?(this.extension.currentAnnotationRect=n,this.navigatedFromSearch=!0,this.extensionHost.publish(E.ANNOTATION_CANVAS_CHANGE,[n])):this.zoomToAnnotation(n):(this.navigatedFromSearch=!0,this.extensionHost.publish(P.PREV_IMAGES_SEARCH_RESULT_UNAVAILABLE))}nextAnnotation(){let e=this.getAnnotationRectsForCurrentImages(),o=this.extension.currentAnnotationRect,a=o?this.getAnnotationRectIndex(o):-1,n=null;for(let s=a+1;s<e.length;s++){n=e[s];break}n&&this.isZoomToSearchResultEnabled()?n.canvasIndex>this.extension.helper.canvasIndex?(this.extension.currentAnnotationRect=n,this.navigatedFromSearch=!0,this.extensionHost.publish(E.ANNOTATION_CANVAS_CHANGE,[n])):this.zoomToAnnotation(n):(this.navigatedFromSearch=!0,this.extensionHost.publish(P.NEXT_IMAGES_SEARCH_RESULT_UNAVAILABLE))}getAnnotationRectByIndex(e){let o=this.getAnnotationRectsForCurrentImages();return o.length?o[e]:null}getInitialAnnotationRect(){let e=this.getAnnotationRectsForCurrentImages();if(!e.length)return null;if(!this.extension.previousAnnotationRect&&this.extension.lastCanvasIndex>this.extension.helper.canvasIndex){let a=e.filter(n=>n.canvasIndex===this.extension.helper.canvasIndex);return a[a.length-1]}return e.filter(a=>a.canvasIndex===this.extension.helper.canvasIndex)[0]}zoomToAnnotation(e){if(this.extension.previousAnnotationRect=this.extension.currentAnnotationRect||e,this.extension.currentAnnotationRect=e,ee.getBool(this.extension.data.config.options.zoomToBoundsEnabled,!1))this.fitToBounds(new Se(e.viewportX,e.viewportY,e.width,e.height),!1);else if(this.currentBounds){let o=e.viewportX-(this.currentBounds.w*.5-e.width*.5),a=e.viewportY-(this.currentBounds.h*.5-e.height*.5),n=this.currentBounds.w,s=this.currentBounds.h,r=new Se(o,a,n,s);this.fitToBounds(r)}this.highlightAnnotationRect(e),this.extensionHost.publish(E.ANNOTATION_CHANGE)}highlightAnnotationRect(e){let o=be("#annotation-"+e.canvasIndex+"-"+e.index);o.addClass("current"),be(".annotationRect").not(o).removeClass("current")}getAnnotationOverlayRects(e){let o=[];if(!this.extension.resources)return o;let a=this.extension.resources.filter(r=>r.index===e.canvasIndex)[0],n=this.extension.resources.indexOf(a),s=0;n>0&&(s=this.extension.resources[n-1].width);for(let r=0;r<e.rects.length;r++){let A=e.rects[r],l=A.x+s+(n>0?this.config.options.pageGap:0),u=A.y,m=A.width,p=A.height,w=new Ge.default.Rect(l,u,m,p);A.viewportX=l,A.viewportY=u,w.canvasIndex=A.canvasIndex,w.resultIndex=A.index,w.chars=A.chars,o.push(w)}return o}resize(){if(super.resize(),this.$viewer.height(this.$content.height()-this.$viewer.verticalMargins()),this.$viewer.width(this.$content.width()-this.$viewer.horizontalMargins()),!this.isCreated)return;this.title&&this.$title.text(Ue(this.title)),this.$spinner.css("top",this.$content.height()/2-this.$spinner.height()/2),this.$spinner.css("left",this.$content.width()/2-this.$spinner.width()/2);let e=this.extension.helper.getViewingDirection()||he.LEFT_TO_RIGHT;if(this.extension.helper.isRightToLeft()?this.$title.addClass("rtl"):this.$title.removeClass("rtl"),this.extension.helper.isMultiCanvas()&&this.$prevButton&&this.$nextButton){let o=Math.floor(this.$content.width()/2);switch(e){case he.BOTTOM_TO_TOP:this.$prevButton.addClass("down"),this.$nextButton.addClass("up"),this.$prevButton.css("left",o-this.$prevButton.outerWidth()/2),this.$prevButton.css("top",this.$content.height()-this.$prevButton.height()),this.$nextButton.css("left",o*-1-this.$nextButton.outerWidth()/2);break;case he.TOP_TO_BOTTOM:this.$prevButton.css("left",o-this.$prevButton.outerWidth()/2),this.$nextButton.css("left",o*-1-this.$nextButton.outerWidth()/2),this.$nextButton.css("top",this.$content.height()-this.$nextButton.height());break;default:this.$prevButton.css("top",(this.$content.height()-this.$prevButton.height())/2),this.$nextButton.css("top",(this.$content.height()-this.$nextButton.height())/2);break}}setTimeout(()=>{if(this.extension.helper.isContinuous())if(this.extension.helper.isHorizontallyAligned()){let o=this.$viewer.width()-this.$viewer.rightMargin();this.$navigator.width(o)}else this.$navigator.height(this.$viewer.height())},100)}setFocus(){this.$canvas&&!this.$canvas.is(":focus")&&this.extension.data.config.options.allowStealFocus&&this.$canvas.focus()}setNavigatorVisible(){let e=ee.getBool(this.extension.getSettings().navigatorEnabled,!0)&&this.extension.isDesktopMetric();this.viewer&&this.viewer.navigator&&(this.viewer.navigator.setVisible(e),e?this.$navigator.show():this.$navigator.hide())}getControlsFadeLength(){return this.extension.getSettings().reducedAnimation?0:this.config.options.controlsFadeLength||250}};var tt={options:{allowStealFocus:!1,authAPIVersion:1,bookmarkThumbHeight:150,bookmarkThumbWidth:90,dropEnabled:!0,footerPanelEnabled:!0,headerPanelEnabled:!0,leftPanelEnabled:!0,limitLocales:!1,doubleClickAnnotationEnabled:!1,metrics:[{type:"sm",minWidth:0},{type:"md",minWidth:768},{type:"lg",minWidth:1024},{type:"xl",minWidth:1280}],multiSelectionMimeType:"application/zip",navigatorEnabled:!0,openTemplate:"http://universalviewer.io?manifest={0}",overrideFullScreen:!1,pagingEnabled:!0,pagingOptionEnabled:!0,pessimisticAccessControl:!1,preserveViewport:!1,rightPanelEnabled:!0,saveUserSettings:!1,clickToZoomEnabled:!0,truncateThumbnailLabels:!0,searchWithinEnabled:!0,seeAlsoEnabled:!1,termsOfUseEnabled:!0,theme:"uv-en-GB-theme",tokenStorage:"session",useArrowKeysToNavigate:!1,zoomToSearchResultEnabled:!0,zoomToBoundsEnabled:!0},modules:{leftPanel:{options:{expandFullEnabled:!1,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1},content:{collapse:"$collapse",collapseFull:"$collapseFull",expand:"$expandContents",expandFull:"$expandGallery"}},contentLeftPanel:{options:{autoExpandTreeEnabled:!1,autoExpandTreeIfFewerThan:20,branchNodesExpandOnClick:!0,branchNodesSelectable:!1,defaultToTreeEnabled:!1,defaultToTreeIfGreaterThan:0,defaultToTreeIfCollection:!0,elideCount:40,expandFullEnabled:!0,galleryThumbChunkedResizingThreshold:400,galleryThumbHeight:320,galleryThumbLoadPadding:3,galleryThumbWidth:200,oneColThumbHeight:320,oneColThumbWidth:200,pageModeEnabled:!0,panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!0,tabOrder:"",thumbsCacheInvalidation:{enabled:!0,paramType:"?"},thumbsEnabled:!0,thumbsExtraHeight:8,thumbsImageFadeInDuration:300,thumbsLoadRange:15,topCloseButtonEnabled:!1,treeEnabled:!0,twoColThumbHeight:150,twoColThumbWidth:90},content:{close:"$close",collapse:"$collapse",collapseFull:"$collapseFull",date:"$date",expand:"$expandContents",expandFull:"$expandGallery",index:"$index",manifestRanges:"$manifestRanges",searchResult:"$searchResult",searchResults:"$searchResults",sortBy:"$sortBy",thumbnails:"$thumbnails",title:"$contents",volume:"$volume"}},dialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close"}},downloadDialogue:{options:{confinedImageSize:1e3,currentViewDisabledPercentage:90,downloadCurrentViewEnabled:!0,downloadWholeImageHighResEnabled:!0,downloadWholeImageLowResEnabled:!0,maxImageWidth:5e3,optionsExplanatoryTextEnabled:!1,selectionEnabled:!1,topCloseButtonEnabled:!1},content:{allPages:"$allPages",close:"$close",currentViewAsJpg:"$currentViewAsJpg",currentViewAsJpgExplanation:"$openNewWindow",download:"$download",downloadSelection:"$downloadSelection",downloadSelectionExplanation:"$downloadSelectionExplanation",editSettings:"$editSettings",entireDocument:"$entireDocument",entireFileAsOriginal:"$entireFile",entireFileAsOriginalWithFormat:"$entireFileWithFormat",individualPages:"$individualPages",noneAvailable:"$noDownloadOptionsAvailable",pagingNote:"$pagingNote",preview:"$preview",selection:"$selection",termsOfUse:"$termsOfUse",title:"$download",wholeImageHighRes:"$wholeImageHighRes",wholeImageHighResExplanation:"$openNewWindow",wholeImageLowResAsJpg:"$wholeImageLowResAsJpg",wholeImageLowResAsJpgExplanation:"$openNewWindow",wholeImagesHighRes:"$wholeImagesHighRes",wholeImagesHighResExplanation:"$wholeImagesHighResExplanation"}},footerPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",moreInfo:"$moreInfo",open:"$open",share:"$share",openLeftPanel:"$openLeftPanel",closeLeftPanel:"$closeLeftPanel",openRightPanel:"$openRightPanel",closeRightPanel:"$closeRightPanel"}},genericDialogue:{options:{topCloseButtonEnabled:!1},content:{emptyValue:"$emptyValue",close:"$close",invalidNumber:"$invalidNumber",noMatches:"$noMatches",ok:"$ok",pageNotFound:"$pageNotFound",refresh:"$refresh"}},headerPanel:{options:{centerOptionsEnabled:!0,localeToggleEnabled:!1,settingsButtonEnabled:!0},content:{close:"$close",settings:"$settings",help:"$help"}},helpDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",text:"$placeholder_text",title:"$help"}},moreInfoRightPanel:{options:{canvasDisplayOrder:"",canvasExclude:"",copyToClipboardEnabled:!1,expandFullEnabled:!1,limitToRange:!1,manifestDisplayOrder:"",manifestExclude:"",panelAnimationDuration:250,panelCollapsedWidth:30,panelExpandedWidth:255,panelOpen:!1,rtlLanguageCodes:"ar, ara, dv, div, he, heb, ur, urd",showAllLanguages:!1,textLimit:4,textLimitType:"lines",topCloseButtonEnabled:!1},content:{attribution:"$attribution",canvasHeader:"$aboutTheImage",close:"$close",collapse:"$collapseInformation",collapseFull:"$collapseGallery",copiedToClipboard:"$copiedToClipboard",copyToClipboard:"$copyToClipboard",description:"$description",expand:"$expandInformation",expandFull:"$expandGallery",holdingText:"$moduleGoesHere",less:"$less",lessAriaLabelTemplate:"$lessAriaLabelTemplate",license:"$license",logo:"$logo",manifestHeader:"$aboutTheItem",more:"$more",moreAriaLabelTemplate:"$moreAriaLabelTemplate",noData:"$noDataToDisplay",page:"$page",rangeHeader:"$aboutThisSection",title:"$moreInformation"}},multiSelectDialogue:{options:{galleryThumbChunkedResizingEnabled:!0,galleryThumbChunkedResizingThreshold:400,galleryThumbHeight:320,galleryThumbLoadPadding:3,galleryThumbWidth:200,pageModeEnabled:!0,topCloseButtonEnabled:!1},content:{close:"$close",select:"$download",selectAll:"$selectAll",title:"$selectPagesForDownload"}},pagingHeaderPanel:{options:{autoCompleteBoxEnabled:!0,autocompleteAllowWords:!1,galleryButtonEnabled:!0,imageSelectionBoxEnabled:!1,pageModeEnabled:!1,pagingToggleEnabled:!0,centerOptionsEnabled:!0,localeToggleEnabled:!1,settingsButtonEnabled:!0,helpEnabled:!1,helpUrl:"https://universalviewer.io/",modeOptionsEnabled:!0},content:{close:"$close",emptyValue:"$emptyValue",first:"$first",firstImage:"$firstImage",firstPage:"$firstPage",folio:"$folio",gallery:"$gallery",go:"$go",help:"$help",image:"$image",last:"$last",lastImage:"$lastImage",lastPage:"$lastPage",next:"$next",nextImage:"$nextImage",nextPage:"$nextPage",of:"$of",oneUp:"$singlePageView",page:"$page",pageSearchLabel:"$searchByPageNumber",previous:"$previous",previousImage:"$previousImage",previousPage:"$previousPage",settings:"$settings",twoUp:"$twoPageView"}},centerPanel:{options:{titleEnabled:!0,subtitleEnabled:!0,mostSpecificRequiredStatement:!0,requiredStatementEnabled:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution"}},openSeadragonCenterPanel:{options:{animationTime:.15,autoHideControls:!0,blendTime:0,constrainDuringPan:!1,controlsFadeAfterInactive:1500,controlsFadeDelay:250,controlsFadeLength:250,defaultZoomLevel:0,doubleClickAnnotationEnabled:!1,immediateRender:!1,maxZoomPixelRatio:1.25,mostSpecificRequiredStatement:!0,navigatorPosition:"BOTTOM_RIGHT",pageGap:50,requiredStatementEnabled:!0,showHomeControl:!1,showAdjustImageControl:!0,subtitleEnabled:!0,titleEnabled:!0,trimAttributionCount:150,visibilityRatio:.5,zoomToInitialAnnotation:!0},content:{attribution:"$attribution",close:"$close",closeAttribution:"$closeAttribution",goHome:"$goHome",imageUnavailable:"$imageUnavailable",nextImage:"$nextImage",previousImage:"$previousImage",rotateRight:"$rotateRight",zoomIn:"$zoomIn",zoomOut:"$zoomOut",adjustImage:"$adjustImage"}},searchFooterPanel:{options:{autocompleteAllowWords:!1,elideDetailsTermsCount:20,elideResultsTermsCount:10,forceImageMode:!1,pageModeEnabled:!0,positionMarkerEnabled:!0,bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0},content:{clearSearch:"$clearSearch",defaultLabel:"-",displaying:"$displaying_A_of_B",enterKeyword:"$enterKeyword",image:"$imageLowercase",imageCaps:"$image",instanceFound:"$instanceFound",instancesFound:"$instancesFound",nextResult:"$nextResult",page:"$pageLowercase",pageCaps:"$page",previousResult:"$previousResult",print:"$print",resultFoundFor:"$resultFoundFor",resultsFoundFor:"$resultsFoundFor",searchWithin:"$searchWithinItem",bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",moreInfo:"$moreInfo",open:"$open",share:"$share",openLeftPanel:"$openLeftPanel",closeLeftPanel:"$closeLeftPanel",openRightPanel:"$openRightPanel",closeRightPanel:"$closeRightPanel"}},settingsDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",locale:"$locale",navigatorEnabled:"$navigatorEnabled",clickToZoomEnabled:"$clickToZoomEnabled",pagingEnabled:"$twoPageView",reducedMotion:"$reducedMotion",truncateThumbnailLabels:"$truncateThumbnailLabels",preserveViewport:"$preserveViewport",title:"$settings",website:"$uvWebsite"}},shareDialogue:{options:{embedEnabled:!0,embedPath:"/uv.html",embedTemplate:'<iframe src="{0}" width="{1}" height="{2}" allowfullscreen frameborder="0" title="{3}"></iframe>',instructionsEnabled:!1,shareEnabled:!0,shareFrameEnabled:!0,shareManifestsEnabled:!0,topCloseButtonEnabled:!1,copyToClipboardEnabled:!0},content:{close:"$close",copyBtn:"$copyBtn",copyToClipboard:"$copyToClipboard",customSize:"$custom",embed:"$embed",embedInstructions:"$embedInstructions",height:"$height",iiif:"$iiifManifest",share:"$share",shareInstructions:"$shareInstructions",shareLink:"$shareLink",shareUrl:"$shareUrl",size:"$size",width:"$width"}},authDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",confirm:"$confirm",close:"$close"}},adjustImageDialogue:{options:{topCloseButtonEnabled:!1},content:{title:"$adjustImage",brightness:"$brightness",contrast:"$contrast",saturation:"$saturation",close:"$close",reset:"$reset",remember:"$remember"}},clickThroughDialogue:{options:{topCloseButtonEnabled:!1},content:{close:"$close",viewTerms:"$viewTerms"}},loginDialogue:{options:{topCloseButtonEnabled:!1},content:{login:"$login",logout:"$logout",cancel:"$cancel",close:"$close"}},mobileFooterPanel:{options:{bookmarkEnabled:!1,downloadEnabled:!0,embedEnabled:!1,feedbackEnabled:!1,fullscreenEnabled:!0,minimiseButtons:!0,moreInfoEnabled:!0,openEnabled:!1,printEnabled:!1,shareEnabled:!0,helpEnabled:!1,helpUrl:"https://universalviewer.io/"},content:{rotateRight:"$rotateRight",moreInfo:"$moreInfo",zoomIn:"$zoomIn",zoomOut:"$zoomOut",bookmark:"$add_to_bookmarks",download:"$download",embed:"$embed",exitFullScreen:"$exitFullScreen",feedback:"$feedback",fullScreen:"$fullScreen",open:"$open",share:"$share",openLeftPanel:"$openLeftPanel",closeLeftPanel:"$closeLeftPanel",openRightPanel:"$openRightPanel",closeRightPanel:"$closeRightPanel",help:"$help"}},restrictedDialogue:{options:{topCloseButtonEnabled:!1},content:{cancel:"$cancel",close:"$close"}}},localisation:{label:"English (GB)",locales:[{name:"cy-GB",label:"Cymraeg"},{name:"en-GB",label:"English (GB)"},{name:"fr-FR",label:"Fran\xE7ais (FR)"},{name:"pl-PL",label:"Polski"},{name:"sv-SE",label:"Svenska"}]},content:{authCORSError:"$authCORSError",authorisationFailedMessage:"$authorisationFailedMessage",canvasIndexOutOfRange:"$canvasIndexOutOfRange",fallbackDegradedLabel:"$fallbackDegradedLabel",fallbackDegradedMessage:"$fallbackDegradedMessage",forbiddenResourceMessage:"$forbiddenResourceMessage",mediaViewer:"$mediaViewer",skipToDownload:"$skipToDownload",termsOfUse:"$termsOfUse"}};var de=Me(),mt=class extends Zt{constructor(i){super(i)}create(){this.setConfig("settingsDialogue"),super.create(),this.$navigatorEnabled=de('<div class="setting navigatorEnabled"></div>'),this.$scroll.append(this.$navigatorEnabled),this.$navigatorEnabledCheckbox=de('<input id="navigatorEnabled" type="checkbox" tabindex="0" />'),this.$navigatorEnabled.append(this.$navigatorEnabledCheckbox),this.$navigatorEnabledLabel=de('<label for="navigatorEnabled">'+this.content.navigatorEnabled+"</label>"),this.$navigatorEnabled.append(this.$navigatorEnabledLabel),this.$pagingEnabled=de('<div class="setting pagingEnabled"></div>'),this.$scroll.append(this.$pagingEnabled),this.$pagingEnabledCheckbox=de('<input id="pagingEnabled" type="checkbox" tabindex="0" />'),this.$pagingEnabled.append(this.$pagingEnabledCheckbox),this.$pagingEnabledLabel=de('<label for="pagingEnabled">'+this.content.pagingEnabled+"</label>"),this.$pagingEnabled.append(this.$pagingEnabledLabel),tt.options.truncateThumbnailLabels&&(this.$truncateThumbnailLabels=de('<div class="setting truncateThumbnailLabels"></div>'),this.$scroll.append(this.$truncateThumbnailLabels),this.$truncateThumbnailLabelsCheckbox=de('<input id="truncateThumbnailLabels" type="checkbox" tabindex="0" />'),this.$truncateThumbnailLabels.append(this.$truncateThumbnailLabelsCheckbox),this.$truncateThumbnailLabelsLabel=de('<label for="truncateThumbnailLabels">'+this.content.truncateThumbnailLabels+"</label>"),this.$truncateThumbnailLabels.append(this.$truncateThumbnailLabelsLabel),this.$truncateThumbnailLabelsCheckbox.prop("checked",tt.options.truncateThumbnailLabels),this.$truncateThumbnailLabelsCheckbox.change(()=>{let i={};i.truncateThumbnailLabels=this.$truncateThumbnailLabelsCheckbox.is(":checked"),this.updateSettings(i)})),this.$clickToZoomEnabled=de('<div class="setting clickToZoom"></div>'),this.$scroll.append(this.$clickToZoomEnabled),this.$clickToZoomEnabledCheckbox=de('<input id="clickToZoomEnabled" type="checkbox" />'),this.$clickToZoomEnabled.append(this.$clickToZoomEnabledCheckbox),this.$clickToZoomEnabledLabel=de('<label for="clickToZoomEnabled">'+this.content.clickToZoomEnabled+"</label>"),this.$clickToZoomEnabled.append(this.$clickToZoomEnabledLabel),this.$preserveViewport=de('<div class="setting preserveViewport"></div>'),this.$scroll.append(this.$preserveViewport),this.$preserveViewportCheckbox=de('<input id="preserveViewport" type="checkbox" tabindex="0" />'),this.$preserveViewport.append(this.$preserveViewportCheckbox),this.$preserveViewportLabel=de('<label for="preserveViewport">'+this.content.preserveViewport+"</label>"),this.$preserveViewport.append(this.$preserveViewportLabel),this.$navigatorEnabledCheckbox.change(()=>{let i={};this.$navigatorEnabledCheckbox.is(":checked")?i.navigatorEnabled=!0:i.navigatorEnabled=!1,this.updateSettings(i)}),this.$clickToZoomEnabledCheckbox.change(()=>{let i={};this.$clickToZoomEnabledCheckbox.is(":checked")?i.clickToZoomEnabled=!0:i.clickToZoomEnabled=!1,this.updateSettings(i)}),this.$pagingEnabledCheckbox.change(()=>{let i={};this.$pagingEnabledCheckbox.is(":checked")?i.pagingEnabled=!0:i.pagingEnabled=!1,this.updateSettings(i)}),this.$preserveViewportCheckbox.change(()=>{let i={};this.$preserveViewportCheckbox.is(":checked")?i.preserveViewport=!0:i.preserveViewport=!1,this.updateSettings(i)})}open(){super.open();let i=this.getSettings();i.navigatorEnabled?this.$navigatorEnabledCheckbox.prop("checked",!0):this.$navigatorEnabledCheckbox.removeAttr("checked"),i.clickToZoomEnabled?this.$clickToZoomEnabledCheckbox.prop("checked",!0):this.$clickToZoomEnabledCheckbox.removeAttr("checked"),this.extension.helper.isPagingAvailable()?i.pagingEnabled?this.$pagingEnabledCheckbox.prop("checked",!0):this.$pagingEnabledCheckbox.removeAttr("checked"):this.$pagingEnabled.hide(),i.preserveViewport?this.$preserveViewportCheckbox.prop("checked",!0):this.$preserveViewportCheckbox.removeAttr("checked"),this.$truncateThumbnailLabelsCheckbox&&(i.truncateThumbnailLabels?this.$truncateThumbnailLabelsCheckbox.prop("checked",!0):this.$truncateThumbnailLabelsCheckbox.prop("checked",!1))}};var ft=class extends jt{constructor(i){super(i),this.extensionHost.subscribe(P.OPENSEADRAGON_OPEN,()=>{this.update()}),this.extensionHost.subscribe(P.OPENSEADRAGON_ANIMATION_FINISH,()=>{this.update()})}create(){this.setConfig("shareDialogue"),super.create()}update(){super.update();let i=this.extension.getViewportBounds(),e=this.extension.getViewerRotation();this.embedCode=this.extension.getEmbedScript(this.options.embedTemplate,this.currentWidth,this.currentHeight,i,e),this.$embedCode.val(this.embedCode)}resize(){super.resize()}};var ue=fe(Et());var xe=fe(it());var ii=fe(oi()),ni=fe(Lt());var $t=t=>{let i,e=new Set,o=(l,u)=>{let m=typeof l=="function"?l(i):l;if(!Object.is(m,i)){let p=i;i=u??(typeof m!="object"||m===null)?m:Object.assign({},i,m),e.forEach(w=>w(i,p))}},a=()=>i,r={setState:o,getState:a,getInitialState:()=>A,subscribe:l=>(e.add(l),()=>e.delete(l))},A=i=t(o,a,r);return r},ei=t=>t?$t(t):$t;var ti=()=>ei(t=>({downloadDialogueOpen:!1,dialogueTriggerButton:null,openDownloadDialogue:i=>t({downloadDialogueOpen:!0,dialogueTriggerButton:i}),closeDialogue:()=>t({downloadDialogueOpen:!1,dialogueTriggerButton:null})}));var we=Me(),vt=class extends We{constructor(e,o){super(e);this.contrastPercent=100;this.brightnessPercent=100;this.saturationPercent=100;this.rememberSettings=!1;this.shell=o}create(){this.setConfig("adjustImageDialogue"),super.create(),this.extensionHost.subscribe(E.SHOW_ADJUSTIMAGE_DIALOGUE,()=>{this.open()}),this.$title=we('<div role="heading" class="heading"></div>'),this.$content.append(this.$title),this.$contrastLabel=we('<label for="contrastInput">'+this.content.contrast+"</label>"),this.$contrastInput=we('<input id="contrastInput" type="range" min="1" max="200" step="1"></input>'),this.$content.append(this.$contrastLabel),this.$content.append(this.$contrastInput),this.$brightnessLabel=we('<label for="brightnessInput">'+this.content.brightness+"</label>"),this.$brightnessInput=we('<input id="brightnessInput" type="range" min="1" max="200" step="1"></input>'),this.$content.append(this.$brightnessLabel),this.$content.append(this.$brightnessInput),this.$saturationLabel=we('<label for="saturationInput">'+this.content.saturation+"</label>"),this.$saturationInput=we('<input id="saturationInput" type="range" min="1" max="200" step="1"></input>'),this.$content.append(this.$saturationLabel),this.$content.append(this.$saturationInput),this.$title.text(this.content.title),this.extension.data.config?.options.saveUserSettings&&(this.$rememberContainer=we('<div class="rememberContainer"></div>'),this.$rememberCheckbox=we('<input type="checkbox" id="rememberSettings" />'),this.$rememberLabel=we('<label for="rememberSettings">'+this.content.remember+"</label>"),this.$rememberContainer.append(this.$rememberCheckbox),this.$rememberContainer.append(this.$rememberLabel),this.$content.append(this.$rememberContainer),this.$rememberCheckbox.on("input",e=>{this.rememberSettings=this.$rememberCheckbox.prop("checked")})),this.$contrastInput.on("input",e=>{this.contrastPercent=Number(we(e.target).val()),this.filter()}),this.$brightnessInput.on("input",e=>{this.brightnessPercent=Number(we(e.target).val()),this.filter()}),this.$saturationInput.on("input",e=>{this.saturationPercent=Number(we(e.target).val()),this.filter()}),this.$resetButton=this.$buttons.find(".close").clone(),this.$resetButton.prop("title",this.content.reset),this.$resetButton.text(this.content.reset),this.$resetButton.onPressed(()=>{this.contrastPercent=100,this.brightnessPercent=100,this.saturationPercent=100,this.$contrastInput.val(this.contrastPercent),this.$brightnessInput.val(this.brightnessPercent),this.$saturationInput.val(this.saturationPercent);let e=this.extension.centerPanel.$canvas[0].children[0];e.style.filter="none"}),this.$resetButton.insertBefore(this.$buttons.find(".close")),this.$element.hide()}filter(){let e=this.extension.centerPanel.$canvas[0].children[0];e.style.filter=`contrast(${this.contrastPercent}%) brightness(${this.brightnessPercent}%) saturate(${this.saturationPercent}%)`}open(){let e=this.extension.getSettings();e.rememberSettings&&(this.contrastPercent=Number(e.contrastPercent),this.brightnessPercent=Number(e.brightnessPercent),this.saturationPercent=Number(e.saturationPercent),this.$contrastInput.val(this.contrastPercent),this.$brightnessInput.val(this.brightnessPercent),this.$saturationInput.val(this.saturationPercent),this.extension.data.config?.options.saveUserSettings&&(this.$rememberCheckbox.prop("checked",e.rememberSettings),this.rememberSettings=e.rememberSettings)),super.open(),this.shell.$overlays.css("background","none")}close(){this.rememberSettings?(this.extension.updateSettings({rememberSettings:this.rememberSettings}),this.extension.updateSettings({contrastPercent:this.contrastPercent}),this.extension.updateSettings({brightnessPercent:this.brightnessPercent}),this.extension.updateSettings({saturationPercent:this.saturationPercent})):(this.extension.updateSettings({rememberSettings:!1}),this.extension.updateSettings({contrastPercent:100}),this.extension.updateSettings({brightnessPercent:100}),this.extension.updateSettings({saturationPercent:100})),this.shell.$overlays.css("background",""),super.close(),this.extension.centerPanel.$adjustImageButton.focus()}resize(){super.resize(),this.$element.css({top:16,left:16})}};var Ct=class extends Ft{constructor(){super(...arguments);this.currentRotation=0;this.isAnnotating=!1;this.defaultConfig=tt}create(){super.create(),this.store=ti(),this.store.subscribe(e=>{this.renderDownloadDialogue()}),this.extensionHost.subscribe(E.METRIC_CHANGE,()=>{if(!this.isDesktopMetric()){let e={};e.pagingEnabled=!1,this.updateSettings(e),this.extensionHost.publish(E.UPDATE_SETTINGS)}}),this.extensionHost.subscribe(E.CANVAS_INDEX_CHANGE,e=>{this.previousAnnotationRect=null,this.currentAnnotationRect=null,this.changeCanvas(e)}),this.extensionHost.subscribe(E.CLEAR_ANNOTATIONS,()=>{this.clearAnnotations(),this.extensionHost.publish(E.ANNOTATIONS_CLEARED),this.fire(E.CLEAR_ANNOTATIONS)}),this.extensionHost.subscribe(E.DOWN_ARROW,()=>{this.useArrowKeysToNavigate()||this.centerPanel.setFocus()}),this.extensionHost.subscribe(E.END,()=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.getLastPageIndex())}),this.extensionHost.subscribe(E.FIRST,()=>{this.fire(E.FIRST),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.getFirstPageIndex())}),this.extensionHost.subscribe(E.GALLERY_DECREASE_SIZE,()=>{this.fire(E.GALLERY_DECREASE_SIZE)}),this.extensionHost.subscribe(E.GALLERY_INCREASE_SIZE,()=>{this.fire(E.GALLERY_INCREASE_SIZE)}),this.extensionHost.subscribe(E.GALLERY_THUMB_SELECTED,()=>{this.fire(E.GALLERY_THUMB_SELECTED)}),this.extensionHost.subscribe(E.HOME,()=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.getFirstPageIndex())}),this.extensionHost.subscribe(P.IMAGE_SEARCH,e=>{this.fire(P.IMAGE_SEARCH,e),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,e)}),this.extensionHost.subscribe(E.LAST,()=>{this.fire(E.LAST),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.getLastPageIndex())}),this.extensionHost.subscribe(E.LEFT_ARROW,()=>{this.useArrowKeysToNavigate()?this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getPrevPageIndex()):this.centerPanel.setFocus()}),this.extensionHost.subscribe(E.LEFTPANEL_COLLAPSE_FULL_START,()=>{this.isDesktopMetric()&&this.shell.$rightPanel.show()}),this.extensionHost.subscribe(E.LEFTPANEL_COLLAPSE_FULL_FINISH,()=>{this.shell.$centerPanel.show(),this.resize()}),this.extensionHost.subscribe(E.MINUS,()=>{this.centerPanel.setFocus()}),this.extensionHost.subscribe(P.MODE_CHANGE,e=>{this.fire(P.MODE_CHANGE,e),this.mode=new ve(e);let o=this.getSettings();this.extensionHost.publish(E.SETTINGS_CHANGE,o)}),this.extensionHost.subscribe(E.MULTISELECTION_MADE,e=>{let o=new ht;o.manifestUri=this.helper.manifestUri,o.allCanvases=e.length===this.helper.getCanvases().length,o.canvases=e,o.format=this.data.config.options.multiSelectionMimeType,o.sequence=this.helper.getCurrentSequence().id,this.fire(E.MULTISELECTION_MADE,o)}),this.extensionHost.subscribe(E.NEXT,()=>{this.fire(E.NEXT),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getNextPageIndex())}),this.extensionHost.subscribe(P.NEXT_SEARCH_RESULT,()=>{this.fire(P.NEXT_SEARCH_RESULT)}),this.extensionHost.subscribe(P.NEXT_IMAGES_SEARCH_RESULT_UNAVAILABLE,()=>{this.fire(P.NEXT_IMAGES_SEARCH_RESULT_UNAVAILABLE),this.nextSearchResult()}),this.extensionHost.subscribe(P.PREV_IMAGES_SEARCH_RESULT_UNAVAILABLE,()=>{this.fire(P.PREV_IMAGES_SEARCH_RESULT_UNAVAILABLE),this.prevSearchResult()}),this.extensionHost.subscribe(E.OPEN_THUMBS_VIEW,()=>{this.fire(E.OPEN_THUMBS_VIEW)}),this.extensionHost.subscribe(E.OPEN_TREE_VIEW,()=>{this.fire(E.OPEN_TREE_VIEW)}),this.extensionHost.subscribe(E.PAGE_DOWN,()=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getNextPageIndex())}),this.extensionHost.subscribe(P.PAGE_SEARCH,e=>{this.fire(P.PAGE_SEARCH,e),this.viewLabel(e)}),this.extensionHost.subscribe(E.PAGE_UP,()=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getPrevPageIndex())}),this.extensionHost.subscribe(P.PAGING_TOGGLED,e=>{this.fire(P.PAGING_TOGGLED,e)}),this.extensionHost.subscribe(E.PLUS,()=>{this.centerPanel.setFocus()}),this.extensionHost.subscribe(E.PREV,()=>{this.fire(E.PREV),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getPrevPageIndex())}),this.extensionHost.subscribe(P.PREV_SEARCH_RESULT,()=>{this.fire(P.PREV_SEARCH_RESULT)}),this.extensionHost.subscribe(P.PRINT,()=>{this.print()}),this.extensionHost.subscribe($e.RELOAD,()=>{this.extensionHost.publish(E.CLEAR_ANNOTATIONS)}),this.extensionHost.subscribe(E.RIGHT_ARROW,()=>{this.useArrowKeysToNavigate()?this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.getNextPageIndex()):this.centerPanel.setFocus()}),this.extensionHost.subscribe(P.OPENSEADRAGON_ANIMATION,()=>{this.fire(P.OPENSEADRAGON_ANIMATION)}),this.extensionHost.subscribe(P.OPENSEADRAGON_ROTATION,e=>{this.fire(P.OPENSEADRAGON_ROTATION,e)}),this.extensionHost.subscribe(P.OPENSEADRAGON_ANIMATION_FINISH,e=>{let o=this.centerPanel.getViewportBounds(),a=this.helper.getCurrentCanvas();this.centerPanel&&o&&a&&(this.extensionHost.publish(P.XYWH_CHANGE,o.toString()),this.data.target=a.id+"#xywh="+o.toString(),this.fire(E.TARGET_CHANGE,this.data.target)),this.fire(P.CURRENT_VIEW_URI,{cropUri:this.getCroppedImageUri(a,this.getViewer()),fullUri:this.getConfinedImageUri(a,a.getWidth())})}),this.extensionHost.subscribe(P.OPENSEADRAGON_ANIMATION_START,()=>{this.fire(P.OPENSEADRAGON_ANIMATION_START)}),this.extensionHost.subscribe(P.OPENSEADRAGON_OPEN,()=>{this.useArrowKeysToNavigate()||this.centerPanel.setFocus(),this.fire(P.OPENSEADRAGON_OPEN)}),this.extensionHost.subscribe(P.OPENSEADRAGON_RESIZE,()=>{this.fire(P.OPENSEADRAGON_RESIZE)}),this.extensionHost.subscribe(P.OPENSEADRAGON_ROTATION,e=>{this.data.rotation=e,this.fire(P.OPENSEADRAGON_ROTATION,this.data.rotation),this.currentRotation=e}),this.extensionHost.subscribe(P.SEARCH,e=>{this.fire(P.SEARCH,e),this.search(e)}),this.extensionHost.subscribe(P.SEARCH_PREVIEW_FINISH,()=>{this.fire(P.SEARCH_PREVIEW_FINISH)}),this.extensionHost.subscribe(P.SEARCH_PREVIEW_START,()=>{this.fire(P.SEARCH_PREVIEW_START)}),this.extensionHost.subscribe(E.ANNOTATIONS,e=>{this.fire(E.ANNOTATIONS,e)}),this.extensionHost.subscribe(E.ANNOTATION_CANVAS_CHANGE,e=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,e[0].canvasIndex)}),this.extensionHost.subscribe(E.ANNOTATIONS_EMPTY,()=>{this.fire(E.ANNOTATIONS_EMPTY)}),this.extensionHost.subscribe(E.THUMB_SELECTED,e=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,e.index)}),this.extensionHost.subscribe(E.TREE_NODE_SELECTED,e=>{this.fire(E.TREE_NODE_SELECTED,e.data.path),this.treeNodeSelected(e)}),this.extensionHost.subscribe(E.UP_ARROW,()=>{this.useArrowKeysToNavigate()||this.centerPanel.setFocus()}),this.extensionHost.subscribe(E.UPDATE_SETTINGS,()=>{this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.canvasIndex)}),this.extensionHost.subscribe(E.SHOW_DOWNLOAD_DIALOGUE,e=>{let o=this.store.getState();o!==null&&o.openDownloadDialogue(e[0])}),this.extensionHost.subscribe(E.HIDE_DOWNLOAD_DIALOGUE,()=>{this.closeActiveDialogue()}),this.extensionHost.subscribe(E.CLOSE_ACTIVE_DIALOGUE,()=>{this.closeActiveDialogue()}),this.extensionHost.subscribe(E.ESCAPE,()=>{this.closeActiveDialogue()})}createModules(){super.createModules(),this.isHeaderPanelEnabled()?this.headerPanel=new ut(this.shell.$headerPanel):this.shell.$headerPanel.hide(),this.isLeftPanelEnabled()?this.leftPanel=new Ht(this.shell.$leftPanel):this.shell.$leftPanel.hide(),this.centerPanel=new pt(this.shell.$centerPanel),this.isRightPanelEnabled()?this.rightPanel=new zt(this.shell.$rightPanel):this.shell.$rightPanel.hide(),this.isFooterPanelEnabled()?(this.footerPanel=new At(this.shell.$footerPanel),this.mobileFooterPanel=new at(this.shell.$mobileFooterPanel)):this.shell.$footerPanel.hide(),this.$helpDialogue=$('<div class="overlay help" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$helpDialogue),this.helpDialogue=new Wt(this.$helpDialogue),this.$multiSelectDialogue=$('<div class="overlay multiSelect" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$multiSelectDialogue),this.multiSelectDialogue=new lt(this.$multiSelectDialogue),this.$shareDialogue=$('<div class="overlay share" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$shareDialogue),this.shareDialogue=new ft(this.$shareDialogue),this.$adjustImageDialogue=$('<div class="overlay adjustImage" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$adjustImageDialogue),this.adjustImageDialogue=new vt(this.$adjustImageDialogue,this.shell),this.$downloadDialogue=$("<div></div>"),this.shell.$overlays.append(this.$downloadDialogue),this.downloadDialogueRoot=(0,ii.createRoot)(this.$downloadDialogue[0]),this.$settingsDialogue=$('<div class="overlay settings" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$settingsDialogue),this.settingsDialogue=new mt(this.$settingsDialogue),this.$externalContentDialogue=$('<div class="overlay externalContent" aria-hidden="true"></div>'),this.shell.$overlays.append(this.$externalContentDialogue),this.externalContentDialogue=new st(this.$externalContentDialogue),this.isHeaderPanelEnabled()&&this.headerPanel.init(),this.isLeftPanelEnabled()&&this.leftPanel.init(),this.isRightPanelEnabled()&&this.rightPanel.init(),this.isFooterPanelEnabled()&&this.footerPanel.init()}render(){super.render(),this.checkForTarget(),this.checkForAnnotations(),this.checkForSearchParam(),this.checkForRotationParam()}renderDownloadDialogue(){let e=this.isPagingSettingEnabled(),{downloadDialogueOpen:o,dialogueTriggerButton:a}=this.store.getState();o?this.extensionHost.publish(E.SHOW_OVERLAY):this.extensionHost.publish(E.HIDE_OVERLAY);let n=this.getPagedIndices(),s=this.helper.getCanvases().filter((u,m)=>n.includes(m)),r=kt(this.data.config.modules.dialogue,this.data.config.modules.downloadDialogue),A=this.helper.manifest.getService(ue.ServiceProfile.DOWNLOAD_EXTENSIONS),l=r.options.selectionEnabled&&A?.__jsonld.selectionEnabled;this.downloadDialogueRoot.render((0,ni.createElement)(Jt,{canvases:s,confinedImageSize:r.options.confinedImageSize,content:r.content,downloadCurrentViewEnabled:r.options.downloadCurrentViewEnabled,downloadWholeImageHighResEnabled:r.options.downloadWholeImageHighResEnabled,downloadWholeImageLowResEnabled:r.options.downloadWholeImageLowResEnabled,locale:this.getLocale(),manifest:this.helper.manifest,maxImageWidth:r.options.maxImageWidth,mediaDownloadEnabled:this.helper.isUIEnabled("mediaDownload"),open:o,paged:e,parent:this.shell.$overlays[0],requiredStatement:this.helper.getRequiredStatement()?.value,resources:this.resources,rotation:this.getViewerRotation(),selectionEnabled:l,sequence:this.helper.getCurrentSequence(),termsOfUseEnabled:this.data.config.options.termsOfUseEnabled,triggerButton:a,getCroppedImageDimensions:u=>this.getCroppedImageDimensions(u,this.getViewer()),getConfinedImageDimensions:u=>this.getConfinedImageDimensions(u,r.options.confinedImageSize),getConfinedImageUri:u=>this.getConfinedImageUri(u,r.options.confinedImageSize),onClose:()=>{this.closeActiveDialogue()},onDownloadCurrentView:u=>{let m=this.getViewer();window.open(this.getCroppedImageUri(u,m))},onDownloadSelection:()=>{this.closeActiveDialogue(),this.extensionHost.publish(E.SHOW_MULTISELECT_DIALOGUE)},onShowTermsOfUse:()=>{this.closeActiveDialogue(),this.extensionHost.publish(E.SHOW_TERMS_OF_USE)}}))}closeActiveDialogue(){let e=this.store.getState();e!==null&&e.closeDialogue()}checkForTarget(){if(this.data.target){let e=this.data.target.split("#"),o=e[0],a=this.helper.getCanvasIndexById(o);a!==null&&this.helper.canvasIndex!==a&&this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,a);let n=e[1];this.extensionHost.publish(E.SET_TARGET,Se.fromString(n))}}checkForAnnotations(){if(this.data.annotations){let e=[],o=this.data.annotations;Array.isArray(o)?e=this.groupWebAnnotationsByTarget(this.data.annotations):o.resources.length&&(e=this.groupOpenAnnotationsByTarget(this.data.annotations),this.extensionHost.publish(E.CLEAR_ANNOTATIONS)),this.annotate(e)}}annotate(e,o){this.annotations=e,this.annotations=e.sort((n,s)=>n.canvasIndex-s.canvasIndex);let a=new Yt;a.terms=o,a.annotations=this.annotations,this.extensionHost.publish(E.ANNOTATIONS,a)}groupWebAnnotationsByTarget(e){let o=[];for(let a=0;a<e.length;a++){let n=e[a],s=n.target.match(/(.*)#/)[1],r=this.helper.getCanvasIndexById(s),A=new yt(s);A.canvasIndex=r;let l=o.filter(u=>u.canvasId===A.canvasId)[0];l?l.addRect(n):(A.addRect(n),o.push(A))}return o}groupOpenAnnotationsByTarget(e){let o=[];for(let a=0;a<e.resources.length;a++){let n=e.resources[a],s=n.on.match(/(.*)#/)[1],r=this.helper.getCanvasIndexById(s),A=new yt(s);A.canvasIndex=r;let l=o.filter(u=>u.canvasId===A.canvasId)[0];l?l.addRect(n):(A.addRect(n),o.push(A))}return o.sort((a,n)=>a.canvasIndex-n.canvasIndex),o}checkForSearchParam(){let e=this.data.highlight;e&&(e.replace(/\+/g," ").replace(/"/g,""),this.extensionHost.publish(P.SEARCH,e))}checkForRotationParam(){let e=this.data.rotation;e&&this.extensionHost.publish(E.SET_ROTATION,e)}changeCanvas(e){if(e===-1)return;let o=!1;if(e===this.helper.canvasIndex&&(o=!0),this.helper.isCanvasIndexOutOfRange(e)&&(this.showMessage(this.data.config.content.canvasIndexOutOfRange),e=0),this.isPagingSettingEnabled()&&!o&&this.getPagedIndices(e).includes(this.helper.canvasIndex)){this.viewCanvas(e);return}this.viewCanvas(e)}getViewer(){return this.centerPanel.viewer}getMode(){if(this.mode)return this.mode;switch(this.helper.getManifestType()){case xe.ManifestType.MONOGRAPH:return ve.page;case xe.ManifestType.MANUSCRIPT:return ve.page;default:return ve.image}}getViewportBounds(){if(!this.centerPanel)return null;let e=this.centerPanel.getViewportBounds();return e?e.toString():null}getViewerRotation(){return this.centerPanel?this.currentRotation:null}viewRange(e){let o=this.helper.getRangeByPath(e);if(!o)return;let a=o.getCanvasIds()[0],n=this.helper.getCanvasIndexById(a);this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,n),this.extensionHost.publish(E.RANGE_CHANGE,o)}viewLabel(e){if(!e){this.showMessage(this.data.config.modules.genericDialogue.content.emptyValue),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE_FAILED);return}let o=this.helper.getCanvasIndexByLabel(e);o!=-1?this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,o):(this.showMessage(this.data.config.modules.genericDialogue.content.pageNotFound),this.extensionHost.publish(E.CANVAS_INDEX_CHANGE_FAILED))}treeNodeSelected(e){let o=e.data;if(o.type)switch(o.type){case ue.IIIFResourceType.MANIFEST:this.viewManifest(o);break;case ue.IIIFResourceType.COLLECTION:this.viewCollection(o);break;default:this.viewRange(o.path);break}}clearAnnotations(){this.annotations=[],this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,this.helper.canvasIndex)}prevSearchResult(){let e;if(this.annotations)for(let o=this.annotations.length-1;o>=0;o--){let a=this.annotations[o];if(a.canvasIndex<=this.getPrevPageIndex()){e=a,this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,e.canvasIndex);break}}}nextSearchResult(){if(this.annotations)for(let e=0;e<this.annotations.length;e++){let o=this.annotations[e];if(o&&o.canvasIndex>=this.getNextPageIndex()){this.extensionHost.publish(E.CANVAS_INDEX_CHANGE,o.canvasIndex);break}}}bookmark(){super.bookmark();let e=this.helper.getCurrentCanvas(),o=new Vt;o.index=this.helper.canvasIndex,o.label=xe.LanguageMap.getValue(e.getLabel()),o.path=this.getCroppedImageUri(e,this.getViewer()),o.thumb=e.getCanonicalImageUri(this.data.config.options.bookmarkThumbWidth),o.title=this.helper.getLabel(),o.trackingLabel=window.trackingLabel,o.type=ue.ExternalResourceType.IMAGE,this.fire(E.BOOKMARK,o)}print(){window.print(),this.fire(P.PRINT)}getCroppedImageDimensions(e,o){if(!o||!o.viewport)return null;let a,n;if(e.getWidth()?a=e.getWidth():a=e.externalResource.width,e.getHeight()?n=e.getHeight():n=e.externalResource.height,!a||!n)return null;let s=o.viewport.getBounds(!0),r=new ot,A=Math.floor(s.width),l=Math.floor(s.height),u=Math.floor(s.x),m=Math.floor(s.y);u+A>a?A=a-u:u<0&&(A=A+u),u<0&&(u=0),m+l>n?l=n-m:m<0&&(l=l+m),m<0&&(m=0),A=Math.min(A,a),l=Math.min(l,n);let p=A,w=l,b=e.getMaxDimensions();if(b){if(A>b.width){let x=b.width;l=Math.round(x*(l/A)),A=x}if(l>b.height){let x=b.height;A=Math.round(A/l*x),l=x}}return r.region=new xe.Size(p,w),r.regionPos=new Ve(u,m),r.size=new xe.Size(A,l),r}getCroppedImageUri(e,o){if(!o||!o.viewport)return null;let a=this.getCroppedImageDimensions(e,o);if(!a)return null;let n=this.getImageBaseUri(e),s=this.getImageId(e);if(!s)return null;let r=a.regionPos.x+","+a.regionPos.y+","+a.region.width+","+a.region.height,A=a.size.width+","+a.size.height,l=this.getViewerRotation();return`${n}/${s}/${r}/${A}/${l}/default.jpg`}getConfinedImageDimensions(e,o){let a=e.getWidth(),n=e.getHeight();a||(a=e.externalResource.width),n||(n=e.externalResource.height);let s=new xe.Size(0,0);if(a>n){s.width=o;let r=Ke.normalise(o,0,a);s.height=Math.floor(n*r)}else{s.height=o;let r=Ke.normalise(o,0,n);s.width=Math.floor(a*r)}return s}getConfinedImageUri(e,o){let a=this.getImageBaseUri(e),n=this.getImageId(e);if(!n)return null;let s="full",r=this.getConfinedImageDimensions(e,o),A=r.width+","+r.height,l=this.getViewerRotation();return`${a}/${n}/${s}/${A}/${l}/default.jpg`}getImageId(e){if(e.externalResource){let o=e.externalResource.data["@id"]||e.externalResource.data.id;if(o)return o.substr(o.lastIndexOf("/")+1)}return null}getImageBaseUri(e){let o=this.getInfoUri(e);return o=o.substr(0,o.lastIndexOf("/")),o.substr(0,o.lastIndexOf("/"))}getInfoUri(e){let o=null,a=e.getImages();if(a&&a.length){let r=a[0].getResource().getServices();for(let A=0;A<r.length;A++){let l=r[A],u=l.id;u.endsWith("/")||(u+="/"),xe.Utils.isImageProfile(l.getProfile())&&(o=u+"info.json")}}else{a=e.getContent();let s=a[0].getBody();if(s.length){let r=s[0].getServices();for(let A=0;A<r.length;A++){let l=r[A],u=l.id;u.endsWith("/")||(u+="/"),(xe.Utils.isImageProfile(l.getProfile())||xe.Utils.isImageServiceType(l.getIIIFResourceType()))&&(o=u+"info.json")}}}return o||(o="lib/imageunavailable.json"),o}getEmbedScript(e,o,a,n,s){let r=this.data.config?.uri??"",A=this.getSerializedLocales()??"",l=new URLSearchParams({manifest:this.helper.manifestUri,c:this.helper.collectionIndex.toString(),m:this.helper.manifestIndex.toString(),cv:this.helper.canvasIndex.toString(),config:r,locales:A,xywh:n,r:s.toString()});return super.buildEmbedScript(e,o,a,l)}isSearchEnabled(){return!(!ee.getBool(this.data.config.options.searchWithinEnabled,!1)||!this.helper.getSearchService())}isPagingSettingEnabled(){return this.helper.isPagingAvailable()?this.getSettings().pagingEnabled:!1}getAutoCompleteService(){let e=this.helper.getSearchService();return e?e.getService(ue.ServiceProfile.SEARCH_0_AUTO_COMPLETE)||e.getService(ue.ServiceProfile.SEARCH_1_AUTO_COMPLETE):null}getAutoCompleteUri(){let e=this.getAutoCompleteService();return e?e.id+"?q={0}":null}getSearchServiceUri(){let e=this.helper.getSearchService();if(!e)return null;let o=e.id;return o=o+"?q={0}",o}search(e){if(this.isAnnotating)return;this.isAnnotating=!0,this.annotations=[];let o=this,a=this.getSearchServiceUri();a&&(a=ie.format(a,encodeURIComponent(e)),this.getSearchResults(a,e,this.annotations,n=>{o.isAnnotating=!1,n.length?o.annotate(n,e):o.showMessage(o.data.config.modules.genericDialogue.content.noMatches,()=>{this.extensionHost.publish(E.ANNOTATIONS_EMPTY)})}))}getSearchResults(e,o,a,n){fetch(e).then(s=>s.json()).then(s=>{s.resources&&s.resources.length&&(a=a.concat(this.groupOpenAnnotationsByTarget(s))),s.next?this.getSearchResults(s.next,o,a,n):n(a)})}getAnnotationRects(){return this.annotations.length?this.annotations.map(e=>e.rects).reduce((e,o)=>e.concat(o)):[]}getCurrentAnnotationRectIndex(){let e=this.getAnnotationRects();return this.currentAnnotationRect?e.indexOf(this.currentAnnotationRect):-1}getTotalAnnotationRects(){return this.getAnnotationRects().length}isFirstAnnotationRect(){return this.getCurrentAnnotationRectIndex()===0}getLastAnnotationRectIndex(){return this.getTotalAnnotationRects()-1}getPrevPageIndex(e=this.helper.canvasIndex){let o;if(this.isPagingSettingEnabled()){let a=this.getPagedIndices(e);this.helper.isRightToLeft()?o=a[a.length-1]-1:o=a[0]-1}else o=e-1;return o}getNextPageIndex(e=this.helper.canvasIndex){let o;if(this.isPagingSettingEnabled()){let a=this.getPagedIndices(e);this.helper.isRightToLeft()?o=a[0]+1:o=a[a.length-1]+1}else o=e+1;return o>this.helper.getTotalCanvases()-1?-1:o}getPagedIndices(e=this.helper.canvasIndex){let a=this.helper.manifest.getSequences()[0],n=a.getCanvases(),s=!!this.getSettings().pagingEnabled&&this.helper.isPaged(),r=this.helper.getViewingDirection(),A=[];if(a.getViewingHint()===ue.ViewingHint.CONTINUOUS)A=n.map((l,u)=>u);else if(!s)A.push(e);else{if(e===0||e===n.length&&n.length%2===0)A=[e];else if(e%2===0){let l=n[e],u=n[e-1];l?.getViewingHint()!==ue.ViewingHint.NON_PAGED&&u?.getViewingHint()!==ue.ViewingHint.NON_PAGED?u?A=[e-1,e]:A=[e]:A=[e]}else{let l=n[e],u=n[e+1];l?.getViewingHint()!==ue.ViewingHint.NON_PAGED&&u?.getViewingHint()!==ue.ViewingHint.NON_PAGED?u?A=[e,e+1]:A=[e]:A=[e]}r===ue.ViewingDirection.RIGHT_TO_LEFT&&(A=A.reverse())}return A}};export{Ct as default};
/*! Bundled license information:
openseadragon/build/openseadragon/openseadragon.js:
(*! openseadragon 4.0.0 *)
(*! Built on 2022-12-16 *)
(*! Git commit: v4.0.0-0-8e6196a *)
(*! http://openseadragon.github.io *)
(*! License: http://openseadragon.github.io/license/ *)
@openseadragon-imaging/openseadragon-viewerinputhook/dist/openseadragon-viewerinputhook.js:
(*! @openseadragon-imaging/openseadragon-viewerinputhook 2.2.1 ab9b394 (clean) @license MIT *)
*/