openseadragon
Version:
Provides a smooth, zoomable user interface for HTML/Javascript.
110 lines • 345 kB
JavaScript
//! openseadragon 6.0.2
//! Built on 2026-03-13
//! Git commit: v6.0.2-0-7842cd92
//! http://openseadragon.github.io
//! License: http://openseadragon.github.io/license/
function OpenSeadragon(e){return new OpenSeadragon.Viewer(e)}!function(n){n.version={versionStr:"6.0.2",major:parseInt("6",10),minor:parseInt("0",10),revision:parseInt("2",10)};const t={"[object Boolean]":"boolean","[object Number]":"number","[object String]":"string","[object Function]":"function","[object AsyncFunction]":"function","[object Promise]":"promise","[object Array]":"array","[object Date]":"date","[object RegExp]":"regexp","[object Object]":"object","[object HTMLUnknownElement]":"dom-node","[object HTMLImageElement]":"image","[object HTMLCanvasElement]":"canvas","[object CanvasRenderingContext2D]":"context2d"};const i=Object.prototype.toString;const r=Object.prototype.hasOwnProperty;n.isFunction=function(e){return"function"===n.type(e)};n.isArray=Array.isArray||function(e){return"array"===n.type(e)};n.isWindow=function(e){return e&&"object"==typeof e&&"setInterval"in e};n.type=function(e){return null==e?String(e):t[i.call(e)]||"object"};n.isPlainObject=function(e){if(!e||"object"!==OpenSeadragon.type(e)||e.nodeType||n.isWindow(e))return!1;if(e.constructor&&!r.call(e,"constructor")&&!r.call(e.constructor.prototype,"isPrototypeOf"))return!1;let t;for(const i in e)t=i;return void 0===t||r.call(e,t)};n.isEmptyObject=function(e){for(const t in e)return!1;return!0};n.freezeObject=function(e){Object.freeze?n.freezeObject=Object.freeze:n.freezeObject=function(e){return e};return n.freezeObject(e)};n.supportsCanvas=function(){const e=document.createElement("canvas");return!(!n.isFunction(e.getContext)||!e.getContext("2d"))}();n.isCanvasTainted=function(e){let t=!1;try{e.getContext("2d").getImageData(0,0,1,1)}catch(e){t=!0}return t};n.supportsAddEventListener=!(!document.documentElement.addEventListener||!document.addEventListener);n.supportsRemoveEventListener=!(!document.documentElement.removeEventListener||!document.removeEventListener);n.supportsEventListenerOptions=function(){let t=0;if(n.supportsAddEventListener)try{var e={get capture(){t++;return!1},get once(){t++;return!1},get passive(){t++;return!1}};window.addEventListener("test",null,e);window.removeEventListener("test",null,e)}catch(e){t=0}return 3<=t}();n.supportsAsync=!0;n.getCurrentPixelDensityRatio=function(){if(n.supportsCanvas){var e=document.createElement("canvas").getContext("2d");var t=window.devicePixelRatio||1;e=e.webkitBackingStorePixelRatio||e.mozBackingStorePixelRatio||e.msBackingStorePixelRatio||e.oBackingStorePixelRatio||e.backingStorePixelRatio||1;return Math.max(t,1)/e}return 1};n.pixelDensityRatio=n.getCurrentPixelDensityRatio()}(OpenSeadragon);!function(u){u.extend=function(){var e;let t;let i;let n;let r;let o=arguments[0]||{};var s=arguments.length;let a=!1;let l=1;if("boolean"==typeof o){a=o;o=arguments[1]||{};l=2}"object"==typeof o||OpenSeadragon.isFunction(o)||(o={});if(s===l){o=this;--l}for(;l<s;l++)if(null!==(e=arguments[l])||void 0!==e)for(t in e){var h=Object.getOwnPropertyDescriptor(e,t);if(void 0!==h)if(h.get||h.set)Object.defineProperty(o,t,h);else{i=h.value;if(o!==i)if(a&&i&&(OpenSeadragon.isPlainObject(i)||(n=OpenSeadragon.isArray(i)))){h=o[t];if(n){n=!1;r=h&&OpenSeadragon.isArray(h)?h:[]}else r=h&&OpenSeadragon.isPlainObject(h)?h:{};o[t]=OpenSeadragon.extend(a,r,i)}else void 0!==i&&(o[t]=i)}else u.console.warn('Could not copy inherited property "'+t+'".')}return o};u.extend(u,{DEFAULT_SETTINGS:{xmlPath:null,tileSources:null,tileHost:null,initialPage:0,crossOriginPolicy:!1,ajaxWithCredentials:!1,loadTilesWithAjax:!1,ajaxHeaders:{},splitHashDataForPost:!1,callTileLoadedWithCachedData:!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,loadDestinationTilesOnAnimation:!0,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:function(){if("object"!=typeof navigator)return!1;const e=navigator.userAgent;return"string"==typeof e&&(-1!==e.indexOf("iPhone")||-1!==e.indexOf("iPad")||-1!==e.indexOf("iPod"))}(),pixelsPerWheelLine:40,pixelsPerArrowPress:40,autoResize:!0,preserveImageSizeOnResize:!1,minScrollDeltaTime:50,rotationIncrement:90,maxTilesPerFrame:1,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,keyboardNavEnabled:!0,showNavigator:!1,navigatorElement:null,navigatorId:null,navigatorPosition:null,navigatorSizeRatio:.2,navigatorMaintainSizeRatio:!1,navigatorTop:null,navigatorLeft:null,navigatorHeight:null,navigatorWidth:null,navigatorAutoFade:!0,navigatorRotate:!0,navigatorBackground:"#000",navigatorOpacity:.8,navigatorBorderColor:"#555",navigatorDisplayRegionColor:"#900",degrees:0,flipped:!1,overlayPreserveContentDirection:!0,opacity:1,compositeOperation:null,drawer:["auto","webgl","canvas","html"],drawerOptions:{},preload:!1,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,tileRetryMax:0,tileRetryDelay:2500,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},delegate:function(t,i){return function(){let e=arguments;void 0===e&&(e=[]);return i.apply(t,e)}},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(e){return u._viewers.get(this.getElement(e))},getElement:function(e){return e="string"==typeof e?document.getElementById(e):e},getElementPosition:function(e){let t=new u.Point;let i;let n;e=u.getElement(e);i="fixed"===u.getElementStyle(e).position;n=r(e,i);for(;n;){t.x+=e.offsetLeft;t.y+=e.offsetTop;i&&(t=t.plus(u.getPageScroll()));e=n;i="fixed"===u.getElementStyle(e).position;n=r(e,i)}return t},getElementOffset:function(e){var t=(e=u.getElement(e))&&e.ownerDocument;let i={top:0,left:0};if(!t)return new u.Point;var n=t.documentElement;void 0!==e.getBoundingClientRect&&(i=e.getBoundingClientRect());t=t===t.window?t:9===t.nodeType&&(t.defaultView||t.parentWindow);return new u.Point(i.left+(t.pageXOffset||n.scrollLeft)-(n.clientLeft||0),i.top+(t.pageYOffset||n.scrollTop)-(n.clientTop||0))},getElementSize:function(e){e=u.getElement(e);return new u.Point(e.clientWidth,e.clientHeight)},getElementStyle:document.documentElement.currentStyle?function(e){return(e=u.getElement(e)).currentStyle}:function(e){e=u.getElement(e);return window.getComputedStyle(e,"")},getCssPropertyWithVendorPrefix:function(e){const s={};u.getCssPropertyWithVendorPrefix=function(e){if(void 0!==s[e])return s[e];var t=document.createElement("div").style;let i=null;if(void 0!==t[e])i=e;else{var n=["Webkit","Moz","MS","O","webkit","moz","ms","o"];var r=u.capitalizeFirstLetter(e);for(let e=0;e<n.length;e++){var o=n[e]+r;if(void 0!==t[o]){i=o;break}}}s[e]=i;return i};return u.getCssPropertyWithVendorPrefix(e)},capitalizeFirstLetter:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},positiveModulo:function(e,t){let i=e%t;i<0&&(i+=t);return i},pointInElement:function(e,t){e=u.getElement(e);var i=u.getElementOffset(e);e=u.getElementSize(e);return t.x>=i.x&&t.x<i.x+e.x&&t.y<i.y+e.y&&t.y>=i.y},getMousePosition:function(e){if("number"==typeof e.pageX)u.getMousePosition=function(e){const t=new u.Point;t.x=e.pageX;t.y=e.pageY;return t};else{if("number"!=typeof e.clientX)throw new Error("Unknown event mouse position, no known technique.");u.getMousePosition=function(e){const t=new u.Point;t.x=e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;t.y=e.clientY+document.body.scrollTop+document.documentElement.scrollTop;return t}}return u.getMousePosition(e)},getPageScroll:function(){var e=document.documentElement||{};var t=document.body||{};if("number"==typeof window.pageXOffset)u.getPageScroll=function(){return new u.Point(window.pageXOffset,window.pageYOffset)};else if(t.scrollLeft||t.scrollTop)u.getPageScroll=function(){return new u.Point(document.body.scrollLeft,document.body.scrollTop)};else{if(!e.scrollLeft&&!e.scrollTop)return new u.Point(0,0);u.getPageScroll=function(){return new u.Point(document.documentElement.scrollLeft,document.documentElement.scrollTop)}}return u.getPageScroll()},setPageScroll:function(t){if(void 0!==window.scrollTo)u.setPageScroll=function(e){window.scrollTo(e.x,e.y)};else{var i=u.getPageScroll();if(i.x===t.x&&i.y===t.y)return;document.body.scrollLeft=t.x;document.body.scrollTop=t.y;let e=u.getPageScroll();if(e.x!==i.x&&e.y!==i.y){u.setPageScroll=function(e){document.body.scrollLeft=e.x;document.body.scrollTop=e.y};return}document.documentElement.scrollLeft=t.x;document.documentElement.scrollTop=t.y;e=u.getPageScroll();if(e.x!==i.x&&e.y!==i.y){u.setPageScroll=function(e){document.documentElement.scrollLeft=e.x;document.documentElement.scrollTop=e.y};return}u.setPageScroll=function(e){}}u.setPageScroll(t)},getWindowSize:function(){var e=document.documentElement||{};var t=document.body||{};if("number"==typeof window.innerWidth)u.getWindowSize=function(){return new u.Point(window.innerWidth,window.innerHeight)};else if(e.clientWidth||e.clientHeight)u.getWindowSize=function(){return new u.Point(document.documentElement.clientWidth,document.documentElement.clientHeight)};else{if(!t.clientWidth&&!t.clientHeight)throw new Error("Unknown window size, no known technique.");u.getWindowSize=function(){return new u.Point(document.body.clientWidth,document.body.clientHeight)}}return u.getWindowSize()},makeCenteredNode:function(e){e=u.getElement(e);const t=[u.makeNeutralElement("div"),u.makeNeutralElement("div"),u.makeNeutralElement("div")];u.extend(t[0].style,{display:"table",height:"100%",width:"100%"});u.extend(t[1].style,{display:"table-row"});u.extend(t[2].style,{display:"table-cell",verticalAlign:"middle",textAlign:"center"});t[0].appendChild(t[1]);t[1].appendChild(t[2]);t[2].appendChild(e);return t[0]},trace:function(e,t=!1){this.__traceLogs=[];setInterval(()=>{if(this.__traceLogs.length){console.log(this.__traceLogs.join("\n"));this.__traceLogs=[]}},2e3);this.trace=function(e,t=!1){if("string"!=typeof e){const i=(e=e instanceof OpenSeadragon.Tile?e.getCache(e.originalCacheKey):e)._tiles[0];this.__traceLogs.push(`Cache ${i.toString()} loaded ${i.loaded} loading ${i.loading} cacheCount ${Object.keys(i._caches).length} - CACHE `+e.__invStamp);t&&this.__traceLogs.push(...(new Error).stack.split("\n").slice(1))}else{this.__traceLogs.push(e);t&&this.__traceLogs.push(...(new Error).stack.split("\n").slice(1))}};this.trace(e,t)},makeNeutralElement:function(e){e=document.createElement(e);const t=e.style;t.background="transparent none";t.border="none";t.margin="0px";t.padding="0px";t.position="static";return e},now:function(){Date.now?u.now=Date.now:u.now=function(){return(new Date).getTime()};return u.now()},makeTransparentImage:function(e){const t=u.makeNeutralElement("img");t.src=e;return t},setElementOpacity:function(e,t,i){e=u.getElement(e);i&&!u.Browser.alpha&&(t=Math.round(t));if(u.Browser.opacity)e.style.opacity=t<1?t:"";else if(t<1){t=Math.round(100*t);e.style.filter="alpha(opacity="+t+")"}else e.style.filter=""},setElementTouchActionNone:function(e){void 0!==(e=u.getElement(e)).style.touchAction?e.style.touchAction="none":void 0!==e.style.msTouchAction&&(e.style.msTouchAction="none")},setElementPointerEvents:function(e,t){void 0!==(e=u.getElement(e)).style&&void 0!==e.style.pointerEvents&&(e.style.pointerEvents=t)},setElementPointerEventsNone:function(e){u.setElementPointerEvents(e,"none")},addClass:function(e,t){(e=u.getElement(e)).className?-1===(" "+e.className+" ").indexOf(" "+t+" ")&&(e.className+=" "+t):e.className=t},indexOf:function(e,t,i){Array.prototype.indexOf?this.indexOf=function(e,t,i){return e.indexOf(t,i)}:this.indexOf=function(t,i,e){let n=e||0;if(!t)throw new TypeError;var r=t.length;if(0===r||n>=r)return-1;n<0&&(n=r-Math.abs(n));for(let e=n;e<r;e++)if(t[e]===i)return e;return-1};return this.indexOf(e,t,i)},removeClass:function(e,t){const i=[];var n=(e=u.getElement(e)).className.split(/\s+/);for(let e=0;e<n.length;e++)n[e]&&n[e]!==t&&i.push(n[e]);e.className=i.join(" ")},normalizeEventListenerOptions:function(e){let t;t=void 0!==e?"boolean"==typeof e?u.supportsEventListenerOptions?{capture:e}:e:u.supportsEventListenerOptions?e:void 0!==e.capture&&e.capture:!!u.supportsEventListenerOptions&&{capture:!1};return t},addEvent:function(){if(u.supportsAddEventListener)return function(e,t,i,n){n=u.normalizeEventListenerOptions(n);(e=u.getElement(e)).addEventListener(t,i,n)};if(document.documentElement.attachEvent&&document.attachEvent)return function(e,t,i){(e=u.getElement(e)).attachEvent("on"+t,i)};throw new Error("No known event model.")}(),removeEvent:function(){if(u.supportsRemoveEventListener)return function(e,t,i,n){n=u.normalizeEventListenerOptions(n);(e=u.getElement(e)).removeEventListener(t,i,n)};if(document.documentElement.detachEvent&&document.detachEvent)return function(e,t,i){(e=u.getElement(e)).detachEvent("on"+t,i)};throw new Error("No known event model.")}(),cancelEvent:function(e){e.preventDefault()},eventIsCanceled:function(e){return e.defaultPrevented},stopEvent:function(e){e.stopPropagation()},getUrlParameter:function(e){e=l[e];return e||null},getUrlProtocol:function(e){const t=e.match(/^([a-z]+:)\/\//i);return null===t?window.location.protocol:t[1].toLowerCase()},createAjaxRequest:function(){if(window.XMLHttpRequest){u.createAjaxRequest=function(){return new XMLHttpRequest};return new XMLHttpRequest}throw new Error("Browser doesn't support XMLHttpRequest.")},makeAjaxRequest:function(e,t,i){let n;let r;let o;let s;if(u.isPlainObject(e)){t=e.success;i=e.error;n=e.withCredentials;r=e.headers;o=e.responseType||null;s=e.postData||null;e=e.url}else u.console.warn("OpenSeadragon.makeAjaxRequest() deprecated usage!");const a=u.getUrlProtocol(e);const l=u.createAjaxRequest();if(!u.isFunction(t))throw new Error("makeAjaxRequest requires a success callback");l.onreadystatechange=function(){if(4===l.readyState){l.onreadystatechange=function(){};200<=l.status&&l.status<300||0===l.status&&"http:"!==a&&"https:"!==a?t(l):u.isFunction(i)?i(l):u.console.error("AJAX request returned %d: %s",l.status,e)}};var h=s?"POST":"GET";try{l.open(h,e,!0);o&&(l.responseType=o);if(r)for(const c in r)Object.prototype.hasOwnProperty.call(r,c)&&r[c]&&l.setRequestHeader(c,r[c]);n&&(l.withCredentials=!0);l.send(s)}catch(e){u.console.error("%s while making AJAX request: %s",e.name,e.message);l.onreadystatechange=function(){};u.isFunction(i)&&i(l,e)}return l},jsonp:function(e){let i;let t=e.url;const n=document.head||document.getElementsByTagName("head")[0]||document.documentElement;const r=e.callbackName||"openseadragon"+u.now();const o=window[r];var s="$1"+r+"$2";var a=e.param||"callback";const l=e.callback;t=t.replace(/(=)\?(&|$)|\?\?/i,s);t+=(/\?/.test(t)?"&":"?")+a+"="+r;window[r]=function(e){if(o)window[r]=o;else try{delete window[r]}catch(e){}l&&u.isFunction(l)&&l(e)};i=document.createElement("script");void 0===e.async&&!1===e.async||(i.async="async");e.scriptCharset&&(i.charset=e.scriptCharset);i.src=t;i.onload=i.onreadystatechange=function(e,t){if(t||!i.readyState||/loaded|complete/.test(i.readyState)){i.onload=i.onreadystatechange=null;n&&i.parentNode&&n.removeChild(i);i=void 0}};n.insertBefore(i,n.firstChild)},createFromDZI:function(){throw"OpenSeadragon.createFromDZI is deprecated, use Viewer.open."},parseXml:function(e){if(!window.DOMParser)throw new Error("Browser doesn't support XML DOM.");u.parseXml=function(e){const t=new DOMParser;return t.parseFromString(e,"text/xml")};return u.parseXml(e)},parseJSON:function(e){u.parseJSON=window.JSON.parse;return u.parseJSON(e)},imageFormatSupported:function(e){e=e||"";return!!t[e.toLowerCase()]},setImageFormatsSupported:function(e){u.extend(t,e)}});function e(e){}u.console=window.console||{log:e,debug:e,info:e,warn:e,error:e,assert:e};const t={avif:!0,bmp:!(u.Browser={vendor:u.BROWSERS.UNKNOWN,version:0,alpha:!0}),jpeg:!0,jpg:!0,png:!0,tif:!1,wdp:!1,webp:!0};const l={};!function(){var e=navigator.appVersion;const t=navigator.userAgent;let i;switch(navigator.appName){case"Microsoft Internet Explorer":if(window.attachEvent&&window.ActiveXObject){u.Browser.vendor=u.BROWSERS.IE;u.Browser.version=parseFloat(t.substring(t.indexOf("MSIE")+5,t.indexOf(";",t.indexOf("MSIE"))))}break;case"Netscape":if(window.addEventListener)if(0<=t.indexOf("Edge")){u.Browser.vendor=u.BROWSERS.EDGE;u.Browser.version=parseFloat(t.substring(t.indexOf("Edge")+5))}else if(0<=t.indexOf("Edg")){u.Browser.vendor=u.BROWSERS.CHROMEEDGE;u.Browser.version=parseFloat(t.substring(t.indexOf("Edg")+4))}else if(0<=t.indexOf("Firefox")){u.Browser.vendor=u.BROWSERS.FIREFOX;u.Browser.version=parseFloat(t.substring(t.indexOf("Firefox")+8))}else if(0<=t.indexOf("Safari")){u.Browser.vendor=0<=t.indexOf("Chrome")?u.BROWSERS.CHROME:u.BROWSERS.SAFARI;u.Browser.version=parseFloat(t.substring(t.substring(0,t.indexOf("Safari")).lastIndexOf("/")+1,t.indexOf("Safari")))}else{i=new RegExp("Trident/.*rv:([0-9]{1,}[.0-9]{0,})");if(null!==i.exec(t)){u.Browser.vendor=u.BROWSERS.IE;u.Browser.version=parseFloat(RegExp.$1)}}break;case"Opera":u.Browser.vendor=u.BROWSERS.OPERA;u.Browser.version=parseFloat(e)}const n=window.location.search.substring(1);var r=n.split("&");for(let e=0;e<r.length;e++){const a=r[e];var o=a.indexOf("=");if(0<o){var s=a.substring(0,o);o=a.substring(o+1);try{l[s]=decodeURIComponent(o)}catch(e){u.console.error("Ignoring malformed URL parameter: %s=%s",s,o)}}}u.Browser.alpha=!(u.Browser.vendor===u.BROWSERS.CHROME&&u.Browser.version<2);u.Browser.opacity=!0;u.Browser.vendor===u.BROWSERS.IE&&u.console.error("Internet Explorer is not supported by OpenSeadragon")}();!function(e){const t=e.requestAnimationFrame||e.mozRequestAnimationFrame||e.webkitRequestAnimationFrame||e.msRequestAnimationFrame;const i=e.cancelAnimationFrame||e.mozCancelAnimationFrame||e.webkitCancelAnimationFrame||e.msCancelAnimationFrame;if(t&&i){u.requestAnimationFrame=function(){return t.apply(e,arguments)};u.cancelAnimationFrame=function(){return i.apply(e,arguments)}}else{let n=[];let r=[];let i;let t=0;u.requestAnimationFrame=function(e){n.push([++t,e]);i=i||setInterval(function(){if(n.length){var e=u.now();var t=r;r=n;n=t;for(;r.length;)r.shift()[1](e)}else{clearInterval(i);i=void 0}},20);return t};u.cancelAnimationFrame=function(e){let t,i;for(t=0,i=n.length;t<i;t+=1)if(n[t][0]===e){n.splice(t,1);return}for(t=0,i=r.length;t<i;t+=1)if(r[t][0]===e){r.splice(t,1);return}}}}(window);function r(e,t){return t&&e!==document.body?document.body:e.offsetParent}u.Promise=window.Promise&&u.supportsAsync?window.Promise:class{constructor(e){this._error=!1;this.__value=void 0;try{e(e=>{for(;e instanceof u.Promise;)e=e._value;this._value=e},e=>{for(;e instanceof u.Promise;)e=e._value;this._value=e;this._error=!0})}catch(e){this._value=e;this._error=!0}}then(e){if(!this._error)try{this._value=e(this._value)}catch(e){this._value=e;this._error=!0}return this}catch(e){if(this._error)try{this._value=e(this._value);this._error=!1}catch(e){this._value=e;this._error=!0}return this}get _value(){return this.__value}set _value(e){e&&e.constructor===this.constructor&&(e=e._value);this.__value=e}static resolve(t){return new this(e=>e(t))}static reject(i){return new this((e,t)=>t(i))}static all(t){return new this(e=>e(t.map(e=>e())))}static race(t){return t.length<1?this.resolve():new this(e=>e(t[0]()))}}}(OpenSeadragon);!function(e,t){if("function"==typeof define&&define.amd)define([],function(){return t});else if("object"==typeof module&&module.exports)module.exports=t;else{(e=e||"object"==typeof window&&window)||t.console.error("OpenSeadragon must run in browser environment!");e.OpenSeadragon=t}}(this,OpenSeadragon);!function(e){e.Mat3=class y{constructor(e){this.values=e=e||[0,0,0,0,0,0,0,0,0]}static makeIdentity(){return new y([1,0,0,0,1,0,0,0,1])}static makeTranslation(e,t){return new y([1,0,0,0,1,0,e,t,1])}static makeRotation(e){var t=Math.cos(e);e=Math.sin(e);return new y([t,-e,0,e,t,0,0,0,1])}static makeScaling(e,t){return new y([e,0,0,0,t,0,0,0,1])}multiply(e){var t=this.values;var i=e.values;var n=t[0],r=t[1],o=t[2];var s=t[3],a=t[4],l=t[5];var h=t[6],c=t[7],u=t[8];var d=i[0],p=i[1],g=i[2];var m=i[3],f=i[4],v=i[5];e=i[6],t=i[7],i=i[8];return new y([d*n+p*s+g*h,d*r+p*a+g*c,d*o+p*l+g*u,m*n+f*s+v*h,m*r+f*a+v*c,m*o+f*l+v*u,e*n+t*s+i*h,e*r+t*a+i*c,e*o+t*l+i*u])}setValues(e,t,i,n,r,o,s,a,l){this.values[0]=e;this.values[1]=t;this.values[2]=i;this.values[3]=n;this.values[4]=r;this.values[5]=o;this.values[6]=s;this.values[7]=a;this.values[8]=l}scaleAndTranslate(e,t,i,n){var r=this.values;var o=r[0];var s=r[1];var a=r[2];var l=r[3];var h=r[4];r=r[5];return new y([e*o,e*s,e*a,t*l,t*h,t*r,i*o+n*l,i*s+n*h,i*a+n*r])}scaleAndTranslateSelf(e,t,i,n){const r=this.values;var o=r[0],s=r[1],a=r[2];var l=r[3],h=r[4],c=r[5];r[0]=e*o;r[1]=e*s;r[2]=e*a;r[3]=t*l;r[4]=t*h;r[5]=t*c;r[6]=i*o+n*l+r[6];r[7]=i*s+n*h+r[7];r[8]=i*a+n*c+r[8]}scaleAndTranslateOtherSetSelf(e){var t=e.values;const i=this.values;var n=i[0];var r=i[4];var o=i[6];e=i[7];i[0]=n*t[0];i[1]=n*t[1];i[2]=n*t[2];i[3]=r*t[3];i[4]=r*t[4];i[5]=r*t[5];i[6]=o*t[0]+e*t[3]+t[6];i[7]=o*t[1]+e*t[4]+t[7];i[8]=o*t[2]+e*t[5]+t[8]}}}(OpenSeadragon);!function(t){const e={supportsFullScreen:!1,isFullScreen:function(){return!1},getFullScreenElement:function(){return null},requestFullScreen:function(){},exitFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",fullScreenErrorEventName:""};if(document.exitFullscreen){e.supportsFullScreen=!0;e.getFullScreenElement=function(){return document.fullscreenElement};e.requestFullScreen=function(e){return e.requestFullscreen().catch(function(e){t.console.error("Fullscreen request failed: ",e)})};e.exitFullScreen=function(){document.exitFullscreen().catch(function(e){t.console.error("Error while exiting fullscreen: ",e)})};e.fullScreenEventName="fullscreenchange";e.fullScreenErrorEventName="fullscreenerror"}else if(document.msExitFullscreen){e.supportsFullScreen=!0;e.getFullScreenElement=function(){return document.msFullscreenElement};e.requestFullScreen=function(e){return e.msRequestFullscreen()};e.exitFullScreen=function(){document.msExitFullscreen()};e.fullScreenEventName="MSFullscreenChange";e.fullScreenErrorEventName="MSFullscreenError"}else if(document.webkitExitFullscreen){e.supportsFullScreen=!0;e.getFullScreenElement=function(){return document.webkitFullscreenElement};e.requestFullScreen=function(e){return e.webkitRequestFullscreen()};e.exitFullScreen=function(){document.webkitExitFullscreen()};e.fullScreenEventName="webkitfullscreenchange";e.fullScreenErrorEventName="webkitfullscreenerror"}else if(document.webkitCancelFullScreen){e.supportsFullScreen=!0;e.getFullScreenElement=function(){return document.webkitCurrentFullScreenElement};e.requestFullScreen=function(e){return e.webkitRequestFullScreen()};e.exitFullScreen=function(){document.webkitCancelFullScreen()};e.fullScreenEventName="webkitfullscreenchange";e.fullScreenErrorEventName="webkitfullscreenerror"}else if(document.mozCancelFullScreen){e.supportsFullScreen=!0;e.getFullScreenElement=function(){return document.mozFullScreenElement};e.requestFullScreen=function(e){return e.mozRequestFullScreen()};e.exitFullScreen=function(){document.mozCancelFullScreen()};e.fullScreenEventName="mozfullscreenchange";e.fullScreenErrorEventName="mozfullscreenerror"}e.isFullScreen=function(){return null!==e.getFullScreenElement()};e.cancelFullScreen=function(){t.console.error("cancelFullScreen is deprecated. Use exitFullScreen instead.");e.exitFullScreen()};t.extend(t,e)}(OpenSeadragon);!function(c){c.EventSource=function(){this.events={};this._rejectedEventList={}};c.EventSource.prototype={addOnceHandler:function(t,i,e,n,r){const o=this;n=n||1;let s=0;function a(e){s++;s===n&&o.removeHandler(t,a);return i(e)}return this.addHandler(t,a,e,r)},addHandler:function(e,i,n,r){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,e)){c.console.error(`Error adding handler for ${e}. `+this._rejectedEventList[e]);return!1}let o=this.events[e];o||(this.events[e]=o=[]);if(i&&c.isFunction(i)){let e=o.length,t={handler:i,userData:n||null,priority:r||0};o[e]=t;for(;0<e&&o[e-1].priority<o[e].priority;){o[e]=o[e-1];o[e-1]=t;e--}}return!0},removeHandler:function(e,t){var i=this.events[e];const n=[];if(i&&c.isArray(i)){for(let e=0;e<i.length;e++)i[e].handler!==t&&n.push(i[e]);this.events[e]=n}},numberOfHandlers:function(e){e=this.events[e];return e?e.length:0},removeAllHandlers:function(e){if(e)this.events[e]=[];else for(var t in this.events)this.events[t]=[]},getHandler:function(e){let r=this.events[e];if(!r||!r.length)return null;r=1===r.length?[r[0]]:Array.apply(null,r);return function(t,i){var n=r.length;for(let e=0;e<n;e++)if(r[e]){i.eventSource=t;i.userData=r[e].userData;r[e].handler(i);if(i.stopPropagation&&("function"!=typeof i.stopPropagation||!0===i.stopPropagation()))break}}},getAwaitingHandler:function(e,l){let h=this.events[e];if(!h||!h.length)return null;h=1===h.length?[h[0]]:Array.apply(null,h);return function(s,a){return new c.Promise((n,r)=>{const o=h.length;!function e(t){if(t>=o||!h[t]){n(l);return null}a.eventSource=s;a.userData=h[t].userData;let i;try{i=h[t].handler(a)}catch(e){return r(e)}i=i&&"promise"===c.type(i)?i:c.Promise.resolve();return i.then(()=>!a.stopPropagation||"function"==typeof a.stopPropagation&&!1===a.stopPropagation()?e(t+1):e(o))}(0).catch(r)})}},raiseEvent:function(e,t){if(Object.prototype.hasOwnProperty.call(this._rejectedEventList,e)){c.console.error(`Error adding handler for ${e}. `+this._rejectedEventList[e]);return!1}const i=this.getHandler(e);i&&i(this,t||{});return!0},raiseEventAwaiting:function(e,t,i=null){const n=this.getAwaitingHandler(e,i);return n?n(this,t||{}):c.Promise.resolve(i)},rejectEventHandler(e,t=""){this._rejectedEventList[e]=t},allowEventHandler(e){delete this._rejectedEventList[e]}}}(OpenSeadragon);!function(c){const n=[];const u={};c.MouseTracker=function(e){n.push(this);var t=arguments;c.isPlainObject(e)||(e={element:t[0],clickTimeThreshold:t[1],clickDistThreshold:t[2]});this.hash=function(){let e=Date.now().toString(36)+Math.random().toString(36).substring(2);for(;e in u;)e=Date.now().toString(36)+Math.random().toString(36).substring(2);return e}();this.element=c.getElement(e.element);this.clickTimeThreshold=e.clickTimeThreshold||c.DEFAULT_SETTINGS.clickTimeThreshold;this.clickDistThreshold=e.clickDistThreshold||c.DEFAULT_SETTINGS.clickDistThreshold;this.dblClickTimeThreshold=e.dblClickTimeThreshold||c.DEFAULT_SETTINGS.dblClickTimeThreshold;this.dblClickDistThreshold=e.dblClickDistThreshold||c.DEFAULT_SETTINGS.dblClickDistThreshold;this.userData=e.userData||null;this.stopDelay=e.stopDelay||50;this.preProcessEventHandler=e.preProcessEventHandler||null;this.contextMenuHandler=e.contextMenuHandler||null;this.enterHandler=e.enterHandler||null;this.leaveHandler=e.leaveHandler||null;this.exitHandler=e.exitHandler||null;this.overHandler=e.overHandler||null;this.outHandler=e.outHandler||null;this.pressHandler=e.pressHandler||null;this.nonPrimaryPressHandler=e.nonPrimaryPressHandler||null;this.releaseHandler=e.releaseHandler||null;this.nonPrimaryReleaseHandler=e.nonPrimaryReleaseHandler||null;this.moveHandler=e.moveHandler||null;this.scrollHandler=e.scrollHandler||null;this.clickHandler=e.clickHandler||null;this.dblClickHandler=e.dblClickHandler||null;this.dragHandler=e.dragHandler||null;this.dragEndHandler=e.dragEndHandler||null;this.pinchHandler=e.pinchHandler||null;this.stopHandler=e.stopHandler||null;this.keyDownHandler=e.keyDownHandler||null;this.keyUpHandler=e.keyUpHandler||null;this.keyHandler=e.keyHandler||null;this.focusHandler=e.focusHandler||null;this.blurHandler=e.blurHandler||null;const i=this;u[this.hash]={click:function(e){!function(e,t){var i={originalEvent:t,eventType:"click",pointerType:"mouse",isEmulated:!1};A(e,i);i.preventDefault&&!i.defaultPrevented&&c.cancelEvent(t);i.stopPropagation&&c.stopEvent(t)}(i,e)},dblclick:function(e){!function(e,t){var i={originalEvent:t,eventType:"dblclick",pointerType:"mouse",isEmulated:!1};A(e,i);i.preventDefault&&!i.defaultPrevented&&c.cancelEvent(t);i.stopPropagation&&c.stopEvent(t)}(i,e)},keydown:function(e){!function(e,t){let i=null;var n={originalEvent:t,eventType:"keydown",pointerType:"",isEmulated:!1};A(e,n);if(e.keyDownHandler&&!n.preventGesture&&!n.defaultPrevented){i={eventSource:e,keyCode:t.keyCode||t.charCode,ctrl:t.ctrlKey,shift:t.shiftKey,alt:t.altKey,meta:t.metaKey,originalEvent:t,preventDefault:n.preventDefault||n.defaultPrevented,userData:e.userData};e.keyDownHandler(i)}(i&&i.preventDefault||n.preventDefault&&!n.defaultPrevented)&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}(i,e)},keyup:function(e){!function(e,t){let i=null;var n={originalEvent:t,eventType:"keyup",pointerType:"",isEmulated:!1};A(e,n);if(e.keyUpHandler&&!n.preventGesture&&!n.defaultPrevented){i={eventSource:e,keyCode:t.keyCode||t.charCode,ctrl:t.ctrlKey,shift:t.shiftKey,alt:t.altKey,meta:t.metaKey,originalEvent:t,preventDefault:n.preventDefault||n.defaultPrevented,userData:e.userData};e.keyUpHandler(i)}(i&&i.preventDefault||n.preventDefault&&!n.defaultPrevented)&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}(i,e)},keypress:function(e){!function(e,t){let i=null;var n={originalEvent:t,eventType:"keypress",pointerType:"",isEmulated:!1};A(e,n);if(e.keyHandler&&!n.preventGesture&&!n.defaultPrevented){i={eventSource:e,keyCode:t.keyCode||t.charCode,ctrl:t.ctrlKey,shift:t.shiftKey,alt:t.altKey,meta:t.metaKey,originalEvent:t,preventDefault:n.preventDefault||n.defaultPrevented,userData:e.userData};e.keyHandler(i)}(i&&i.preventDefault||n.preventDefault&&!n.defaultPrevented)&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}(i,e)},focus:function(e){!function(e,t){var i={originalEvent:t,eventType:"focus",pointerType:"",isEmulated:!1};A(e,i);e.focusHandler&&!i.preventGesture&&e.focusHandler({eventSource:e,originalEvent:t,userData:e.userData})}(i,e)},blur:function(e){!function(e,t){var i={originalEvent:t,eventType:"blur",pointerType:"",isEmulated:!1};A(e,i);e.blurHandler&&!i.preventGesture&&e.blurHandler({eventSource:e,originalEvent:t,userData:e.userData})}(i,e)},contextmenu:function(e){!function(e,t){let i=null;var n={originalEvent:t,eventType:"contextmenu",pointerType:"mouse",isEmulated:!1};A(e,n);if(e.contextMenuHandler&&!n.preventGesture&&!n.defaultPrevented){i={eventSource:e,position:f(g(t),e.element),originalEvent:n.originalEvent,preventDefault:n.preventDefault||n.defaultPrevented,userData:e.userData};e.contextMenuHandler(i)}(i&&i.preventDefault||n.preventDefault&&!n.defaultPrevented)&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}(i,e)},wheel:function(e){w(i,e,e)},mousewheel:function(e){y(i,e)},DOMMouseScroll:function(e){y(i,e)},MozMousePixelScroll:function(e){y(i,e)},losecapture:function(e){!function(e,t){var i={id:c.MouseTracker.mousePointerId,type:"mouse"};var n={originalEvent:t,eventType:"lostpointercapture",pointerType:"mouse",isEmulated:!1};A(e,n);t.target===e.element&&F(e,i,!1);n.stopPropagation&&c.stopEvent(t)}(i,e)},mouseenter:function(e){_(i,e)},mouseleave:function(e){T(i,e)},mouseover:function(e){x(i,e)},mouseout:function(e){S(i,e)},mousedown:function(e){E(i,e)},mouseup:function(e){C(i,e)},mousemove:function(e){P(i,e)},touchstart:function(e){!function(t,i){var n=i.changedTouches.length;const r=t.getActivePointersListByType("touch");var o=c.now();r.getLength()>i.touches.length-n&&c.console.warn("Tracked touch contact count doesn't match event.touches.length");var s={originalEvent:i,eventType:"pointerdown",pointerType:"touch",isEmulated:!1};A(t,s);for(let e=0;e<n;e++){var a={id:i.changedTouches[e].identifier,type:"touch",isPrimary:0===r.getLength(),currentPos:g(i.changedTouches[e]),currentTime:o};L(t,s,a);k(t,s,a,0);F(t,a,!0)}s.preventDefault&&!s.defaultPrevented&&c.cancelEvent(i);s.stopPropagation&&c.stopEvent(i)}(i,e)},touchend:function(e){!function(t,i){var n=i.changedTouches.length;var r=c.now();var o={originalEvent:i,eventType:"pointerup",pointerType:"touch",isEmulated:!1};A(t,o);for(let e=0;e<n;e++){var s={id:i.changedTouches[e].identifier,type:"touch",currentPos:g(i.changedTouches[e]),currentTime:r};B(t,o,s,0);F(t,s,!1);O(t,o,s)}o.preventDefault&&!o.defaultPrevented&&c.cancelEvent(i);o.stopPropagation&&c.stopEvent(i)}(i,e)},touchmove:function(e){!function(t,i){var n=i.changedTouches.length;var r=c.now();var o={originalEvent:i,eventType:"pointermove",pointerType:"touch",isEmulated:!1};A(t,o);for(let e=0;e<n;e++){var s={id:i.changedTouches[e].identifier,type:"touch",currentPos:g(i.changedTouches[e]),currentTime:r};M(t,o,s)}o.preventDefault&&!o.defaultPrevented&&c.cancelEvent(i);o.stopPropagation&&c.stopEvent(i)}(i,e)},touchcancel:function(e){!function(t,i){var n=i.changedTouches.length;var e={originalEvent:i,eventType:"pointercancel",pointerType:"touch",isEmulated:!1};A(t,e);for(let e=0;e<n;e++){var r={id:i.changedTouches[e].identifier,type:"touch"};z(t,0,r)}e.stopPropagation&&c.stopEvent(i)}(i,e)},gesturestart:function(e){!(e=(i,e),c.eventIsCanceled(e)||e.preventDefault())},gesturechange:function(e){!(e=(i,e),c.eventIsCanceled(e)||e.preventDefault())},gotpointercapture:function(e){!function(e,t){var i={originalEvent:t,eventType:"gotpointercapture",pointerType:d(t),isEmulated:!1};A(e,i);t.target===e.element&&F(e,{id:t.pointerId,type:d(t)},!0);i.stopPropagation&&c.stopEvent(t)}(i,e)},lostpointercapture:function(e){!function(e,t){var i={originalEvent:t,eventType:"lostpointercapture",pointerType:d(t),isEmulated:!1};A(e,i);t.target===e.element&&F(e,{id:t.pointerId,type:d(t)},!1);i.stopPropagation&&c.stopEvent(t)}(i,e)},pointerenter:function(e){_(i,e)},pointerleave:function(e){T(i,e)},pointerover:function(e){x(i,e)},pointerout:function(e){S(i,e)},pointerdown:function(e){E(i,e)},pointerup:function(e){C(i,e)},pointermove:function(e){P(i,e)},pointercancel:function(e){!function(e,t){var i={id:t.pointerId,type:d(t)};var n={originalEvent:t,eventType:"pointercancel",pointerType:i.type,isEmulated:!1};A(e,n);z(e,0,i);n.stopPropagation&&c.stopEvent(t)}(i,e)},pointerupcaptured:function(e){!function(e,t){const i=e.getActivePointersListByType(d(t));i.getById(t.pointerId)&&b(e,t);c.stopEvent(t)}(i,e)},pointermovecaptured:function(e){!function(e,t){const i=e.getActivePointersListByType(d(t));i.getById(t.pointerId)&&R(e,t);c.stopEvent(t)}(i,e)},tracking:!1,activePointersLists:[],lastClickPos:null,dblClickTimeOut:null,pinchGPoints:[],lastPinchDist:0,currentPinchDist:0,lastPinchCenter:null,currentPinchCenter:null,sentDragEvent:!1};c.MouseTracker.havePointerEvents&&c.setElementPointerEvents(this.element,"auto");this.exitHandler&&c.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead.");e.startDisabled||this.setTracking(!0)};c.MouseTracker.prototype={destroy:function(){t(this);this.element=null;for(let e=0;e<n.length;e++)if(n[e]===this){n.splice(e,1);break}u[this.hash]=null;delete u[this.hash]},isTracking:function(){return u[this.hash].tracking},setTracking:function(e){(e?function(t){const i=u[t.hash];if(!i.tracking){for(let e=0;e<c.MouseTracker.subscribeEvents.length;e++){var n=c.MouseTracker.subscribeEvents[e];c.addEvent(t.element,n,i[n],n===c.MouseTracker.wheelEventName&&{passive:!1,capture:!1})}r(t);i.tracking=!0}}:t)(this);return this},getActivePointersListByType:function(t){const i=u[this.hash];var n=i?i.activePointersLists.length:0;var e;for(let e=0;e<n;e++)if(i.activePointersLists[e].type===t)return i.activePointersLists[e];e=new c.MouseTracker.GesturePointList(t);i&&i.activePointersLists.push(e);return e},getActivePointerCount:function(){const t=u[this.hash];var i=t.activePointersLists.length;let n=0;for(let e=0;e<i;e++)n+=t.activePointersLists[e].getLength();return n},get hasGestureHandlers(){return!!(this.pressHandler||this.nonPrimaryPressHandler||this.releaseHandler||this.nonPrimaryReleaseHandler||this.clickHandler||this.dblClickHandler||this.dragHandler||this.dragEndHandler||this.pinchHandler)},get hasScrollHandler(){return!!this.scrollHandler},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(){}};const o=function(){try{return window.self!==window.top}catch(e){return!0}}();function s(e){try{return e.addEventListener&&e.removeEventListener}catch(e){return}}c.MouseTracker.gesturePointVelocityTracker=function(){const s=[];let r=0;let a=0;function o(e,t){return e.hash.toString()+t.type+t.id.toString()}function i(){var t=s.length;var e=c.now();var i;var n=e-a;a=e;for(let e=0;e<t;e++){const r=s[e];const o=r.gPoint;o.direction=Math.atan2(o.currentPos.y-r.lastPos.y,o.currentPos.x-r.lastPos.x);i=r.lastPos.distanceTo(o.currentPos);r.lastPos=o.currentPos;o.speed=.75*(1e3*i/(1+n))+.25*o.speed}}return{addPoint:function(e,t){e=o(e,t);s.push({guid:e,gPoint:t,lastPos:t.currentPos});if(1===s.length){a=c.now();r=window.setInterval(i,50)}},removePoint:function(e,t){var i=o(e,t);let n=s.length;for(let e=0;e<n;e++)if(s[e].guid===i){s.splice(e,1);n--;0===n&&window.clearInterval(r);break}}}}();c.MouseTracker.captureElement=document;c.MouseTracker.wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";c.MouseTracker.subscribeEvents=["click","dblclick","keydown","keyup","keypress","focus","blur","contextmenu",c.MouseTracker.wheelEventName];"DOMMouseScroll"===c.MouseTracker.wheelEventName&&c.MouseTracker.subscribeEvents.push("MozMousePixelScroll");if(window.PointerEvent){c.MouseTracker.havePointerEvents=!0;c.MouseTracker.subscribeEvents.push("pointerenter","pointerleave","pointerover","pointerout","pointerdown","pointerup","pointermove","pointercancel");c.MouseTracker.havePointerCapture=(e=document.createElement("div"),c.isFunction(e.setPointerCapture)&&c.isFunction(e.releasePointerCapture));c.MouseTracker.havePointerCapture&&c.MouseTracker.subscribeEvents.push("gotpointercapture","lostpointercapture")}else{c.MouseTracker.havePointerEvents=!1;c.MouseTracker.subscribeEvents.push("mouseenter","mouseleave","mouseover","mouseout","mousedown","mouseup","mousemove");c.MouseTracker.mousePointerId="legacy-mouse";c.MouseTracker.havePointerCapture=(e=document.createElement("div"),c.isFunction(e.setCapture)&&c.isFunction(e.releaseCapture));c.MouseTracker.havePointerCapture&&c.MouseTracker.subscribeEvents.push("losecapture");"ontouchstart"in window&&c.MouseTracker.subscribeEvents.push("touchstart","touchend","touchmove","touchcancel");"ongesturestart"in window&&c.MouseTracker.subscribeEvents.push("gesturestart","gesturechange")}var e;c.MouseTracker.GesturePointList=function(e){this._gPoints=[];this.type=e;this.buttons=0;this.contacts=0;this.clicks=0;this.captureCount=0};c.MouseTracker.GesturePointList.prototype={getLength:function(){return this._gPoints.length},asArray:function(){return this._gPoints},add:function(e){return this._gPoints.push(e)},removeById:function(t){var i=this._gPoints.length;for(let e=0;e<i;e++)if(this._gPoints[e].id===t){this._gPoints.splice(e,1);break}return this._gPoints.length},getByIndex:function(e){return e<this._gPoints.length?this._gPoints[e]:null},getById:function(t){var i=this._gPoints.length;for(let e=0;e<i;e++)if(this._gPoints[e].id===t)return this._gPoints[e];return null},getPrimary:function(e){var t=this._gPoints.length;for(let e=0;e<t;e++)if(this._gPoints[e].isPrimary)return this._gPoints[e];return null},addContact:function(){++this.contacts;if(1<this.contacts&&("mouse"===this.type||"pen"===this.type)){c.console.warn("GesturePointList.addContact() Implausible contacts value");this.contacts=1}},removeContact:function(){--this.contacts;this.contacts<0&&(this.contacts=0)}};function r(t){const i=u[t.hash];var n=i.activePointersLists.length;for(let e=0;e<n;e++){const o=i.activePointersLists[e];if(0<o.getLength()){const s=[];var r=o.asArray();for(let e=0;e<r.length;e++)s.push(r[e]);for(let e=0;e<s.length;e++)I(t,o,s[e])}}for(let e=0;e<n;e++)i.activePointersLists.pop();i.sentDragEvent=!1}function t(t){const i=u[t.hash];if(i.tracking){for(let e=0;e<c.MouseTracker.subscribeEvents.length;e++){var n=c.MouseTracker.subscribeEvents[e];c.removeEvent(t.element,n,i[n],!1)}r(t);i.tracking=!1}}function a(e,t){e=u[e.hash];if("pointerevent"===t)return{upName:"pointerup",upHandler:e.pointerupcaptured,moveName:"pointermove",moveHandler:e.pointermovecaptured};if("mouse"===t)return{upName:"pointerup",upHandler:e.pointerupcaptured,moveName:"pointermove",moveHandler:e.pointermovecaptured};if("touch"===t)return{upName:"touchend",upHandler:e.touchendcaptured,moveName:"touchmove",moveHandler:e.touchmovecaptured};throw new Error("MouseTracker.getCaptureEventParams: Unknown pointer type.")}function l(e,t){if(c.MouseTracker.havePointerCapture)if(c.MouseTracker.havePointerEvents){const n=e.getActivePointersListByType(t.type);var i=n.getById(t.id);if(!i||!i.captured)return;try{e.element.releasePointerCapture(t.id)}catch(e){}}else e.element.releaseCapture();else{i=a(e,c.MouseTracker.havePointerEvents?"pointerevent":t.type);o&&s(window.top)&&c.removeEvent(window.top,i.upName,i.upHandler,!0);c.removeEvent(c.MouseTracker.captureElement,i.moveName,i.moveHandler,!0);c.removeEvent(c.MouseTracker.captureElement,i.upName,i.upHandler,!0)}F(e,t,!1)}function h(e){return c.MouseTracker.havePointerEvents?e.pointerId:c.MouseTracker.mousePointerId}function d(e){return c.MouseTracker.havePointerEvents&&e.pointerType?e.pointerType:"mouse"}function p(e){return!c.MouseTracker.havePointerEvents||e.isPrimary}function g(e){return c.getMousePosition(e)}function m(e,t){return f(g(e),t)}function f(e,t){t=c.getElementOffset(t);return e.minus(t)}function v(e,t){return new c.Point((e.x+t.x)/2,(e.y+t.y)/2)}function y(e,t){const i={target:t.target||t.srcElement,type:"wheel",shiftKey:t.shiftKey||!1,clientX:t.clientX,clientY:t.clientY,pageX:t.pageX||t.clientX,pageY:t.pageY||t.clientY,deltaMode:"MozMousePixelScroll"===t.type?0:1,deltaX:0,deltaZ:0};"mousewheel"===c.MouseTracker.wheelEventName?i.deltaY=-t.wheelDelta/c.DEFAULT_SETTINGS.pixelsPerWheelLine:i.deltaY=t.detail;w(e,i,t)}function w(e,t,i){var n;var r;let o=null;n=t.deltaY?t.deltaY<0?1:-1:0;A(e,r={originalEvent:t,eventType:"wheel",pointerType:"mouse",isEmulated:t!==i});if(e.scrollHandler&&!r.preventGesture&&!r.defaultPrevented){o={eventSource:e,pointerType:"mouse",position:m(t,e.element),scroll:n,shift:t.shiftKey,isTouchEvent:!1,originalEvent:i,preventDefault:r.preventDefault||r.defaultPrevented,userData:e.userData};e.scrollHandler(o)}r.stopPropagation&&c.stopEvent(i);(o&&o.preventDefault||r.preventDefault&&!r.defaultPrevented)&&c.cancelEvent(i)}function _(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};t={originalEvent:t,eventType:"pointerenter",pointerType:i.type,isEmulated:!1};A(e,t);L(e,t,i)}function T(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};t={originalEvent:t,eventType:"pointerleave",pointerType:i.type,isEmulated:!1};A(e,t);O(e,t,i)}function x(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};var n={originalEvent:t,eventType:"pointerover",pointerType:i.type,isEmulated:!1};A(e,n);!function(e,t,i){const n=e.getActivePointersListByType(i.type);var r=n.getById(i.id);if(r)i=r;else{i.captured=!1;i.insideElementPressed=!1}e.overHandler&&e.overHandler({eventSource:e,pointerType:i.type,position:f(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}(e,n,i);n.preventDefault&&!n.defaultPrevented&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}function S(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};var n={originalEvent:t,eventType:"pointerout",pointerType:i.type,isEmulated:!1};A(e,n);!function(e,t,i){const n=e.getActivePointersListByType(i.type);var r=n.getById(i.id);if(r)i=r;else{i.captured=!1;i.insideElementPressed=!1}e.outHandler&&e.outHandler({eventSource:e,pointerType:i.type,position:i.currentPos&&f(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}(e,n,i);n.preventDefault&&!n.defaultPrevented&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}function E(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};var n=c.MouseTracker.havePointerEvents&&"touch"===i.type;var r={originalEvent:t,eventType:"pointerdown",pointerType:i.type,isEmulated:!1};A(e,r);k(e,r,i,t.button);r.preventDefault&&!r.defaultPrevented&&c.cancelEvent(t);r.stopPropagation&&c.stopEvent(t);r.shouldCapture&&(n?F(e,i,!0):function(e,t){if(c.MouseTracker.havePointerCapture)if(c.MouseTracker.havePointerEvents)try{e.element.setPointerCapture(t.id)}catch(e){c.console.warn("setPointerCapture() called on invalid pointer ID");return}else e.element.setCapture(!0);else{var i=a(e,c.MouseTracker.havePointerEvents?"pointerevent":t.type);o&&s(window.top)&&c.addEvent(window.top,i.upName,i.upHandler,!0);c.addEvent(c.MouseTracker.captureElement,i.upName,i.upHandler,!0);c.addEvent(c.MouseTracker.captureElement,i.moveName,i.moveHandler,!0)}F(e,t,!0)}(e,i))}function C(e,t){b(e,t)}function b(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};var n={originalEvent:t,eventType:"pointerup",pointerType:i.type,isEmulated:!1};A(e,n);B(e,n,i,t.button);n.preventDefault&&!n.defaultPrevented&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t);n.shouldReleaseCapture&&(t.target===e.element?l(e,i):F(e,i,!1))}function P(e,t){R(e,t)}function R(e,t){var i={id:h(t),type:d(t),isPrimary:p(t),currentPos:g(t),currentTime:c.now()};var n={originalEvent:t,eventType:"pointermove",pointerType:i.type,isEmulated:!1};A(e,n);M(e,n,i);n.preventDefault&&!n.defaultPrevented&&c.cancelEvent(t);n.stopPropagation&&c.stopEvent(t)}function D(e,t){t.speed=0;t.direction=0;t.contactPos=t.currentPos;t.contactTime=t.currentTime;t.lastPos=t.currentPos;t.lastTime=t.currentTime;return e.add(t)}function I(e,t,i){let n;var r=t.getById(i.id);if(r){if(r.captured){c.console.warn("stopTrackingPointer() called on captured pointer");l(e,r)}t.removeContact();n=t.removeById(i.id)}else n=t.getLength();return n}function A(e,t){t.eventSource=e;t.eventPhase=t.originalEvent&&void 0!==t.originalEvent.eventPhase?t.originalEvent.eventPhase:0;t.defaultPrevented=c.eventIsCanceled(t.originalEvent);t.shouldCapture=!1;t.shouldReleaseCapture=!1;t.userData=e.userData;!function(e,t){switch(t.eventType){case"pointermove":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!1;t.preventGesture=!e.hasGestureHandlers;t.stopPropagation=!1;break;case"pointerover":case"pointerout":case"contextmenu":case"keydown":case"keyup":case"keypress":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!1;t.preventGesture=!1;t.stopPropagation=!1;break;case"pointerdown":case"pointerup":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!1;t.preventGesture=!e.hasGestureHandlers;t.stopPropagation=!1;break;case"wheel":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!1;t.preventGesture=!e.hasScrollHandler;t.stopPropagation=!1;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":t.isStoppable=!0;t.isCancelable=!1;t.preventDefault=!1;t.preventGesture=!1;t.stopPropagation=!1;break;case"click":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!!e.clickHandler;t.preventGesture=!1;t.stopPropagation=!1;break;case"dblclick":t.isStoppable=!0;t.isCancelable=!0;t.preventDefault=!!e.dblClickHandler;t.preventGesture=!1;t.stopPropagation=!1;break;default:t.isStoppable=!1;t.isCancelable=!1;t.preventDefault=!1;t.preventGesture=!1;t.stopPropagation=!1}}(e,t);e.preProcessEventHandler&&e.preProcessEventHandler(t)}function F(e,t,i){const n=e.getActivePointersListByType(t.type);const r=n.getById(t.id);if(r){if(i&&!r.captured){r.captured=!0;n.captureCount++}else if(!i&&r.captured){r.captured=!1;n.captureCount--;if(n.captureCount<0){n.captureCount=0;c.console.warn("updatePointerCaptured() - pointsList.captureCount went negative")}}}else c.console.warn("updatePointerCaptured() called on untracked pointer")}function L(e,t,i){const n=e.getActivePointersListByType(i.type);const r=n.getById(i.id);if(r){r.insideElement=!0;r.lastPos=r.currentPos;r.lastTime=r.currentTime;r.currentPos=i.currentPos;r.currentTime=i.currentTime;i=r}else{i.captured=!1;i.insideElementPressed=!1;i.insideElement=!0;D(n,i)}e.enterHandler&&e.enterHandler({eventSource:e,pointerType:i.type,position:f(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}function O(e,t,i){const n=e.getActivePointersListByType(i.type);const r=n.getById(i.id);if(r){if(r.captured){r.insideElement=!1;r.lastPos=r.currentPos;r.lastTime=r.currentTime;r.currentPos=i.currentPos;r.currentTime=i.currentTime}else I(e,n,r);i=r}else{i.captured=!1;i.insideElementPressed=!1}if(e.leaveHandler||e.exitHandler){t={eventSource:e,pointerType:i.type,position:i.currentPos&&f(i.currentPos,e.element),buttons:n.buttons,pointers:e.getActivePointerCount(),insideElementPressed:i.insideElementPressed,buttonDownAny:0!==n.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData};e.leaveHandler&&e.leaveHandler(t);e.exitHandler&&e.exitHandler(t)}}function k(e,t,i,n){const r=u[e.hash];const o=e.getActivePointersListByType(i.type);void 0!==t.originalEvent.buttons?o.buttons=t.originalEvent.buttons:0===n?o.buttons|=1:1===n?o.buttons|=4:2===n?o.buttons|=2:3===n?o.buttons|=8:4===n?o.buttons|=16:5===n&&(o.buttons|=32);if(0===n){const s=o.getById(i.id);if(s){s.insideElementPressed=!0;s.insideElement=!0;s.originalTarget=t.originalEvent.target;s.contactPos=i.currentPos;s.contactTime=i.currentTime;s.lastPos=s.currentPos;s.lastTime=s.currentTime;s.currentPos=i.currentPos;s.currentTime=i.currentTime;i=s}else{i.captured=!1;i.insideElementPressed=!0;i.insideElement=!0;i.originalTarget=t.originalEvent.target;D(o,i)}o.addContact();if(t.preventGesture||t.defaultPrevented){t.shouldCapture=!1;t.shouldReleaseCapture=!1}else{t.shouldCapture=!0;t.shouldReleaseCapture=!1;t.preventDefault=!0;(e.dragHandler||e.dragEndHandler||e.pinchHandler)&&c.MouseTracker.gesturePointVelocityTracker.addPoint(e,i);if(1===o.contacts)e.pressHandler&&!t.preventGesture&&e.pressHandler({eventSource:e,pointerType:i.type,position:f(i.contactPos,e.element),buttons:o.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData});else if(2===o.contacts&&e.pinchHandler&&"touch"===i.type){r.pinchGPoints=o.asArray();r.lastPinchDist=r.currentPinchDist=r.pinchGPoints[0].currentPos.distanceTo(r.pinchGPoints[1].currentPos);r.lastPinchCenter=r.currentPinchCenter=v(r.pinchGPoints[0].currentPos,r.pinchGPoints[1].currentPos)}}}else{t.shouldCapture=!1;t.shouldReleaseCapture=!1;if(e.nonPrimaryPressHandler&&!t.preventGesture&&!t.defaultPrevented){t.preventDefault=!0;e.nonPrimaryPressHandler({eventSource:e,pointerType:i.type,position:f(i.currentPos,e.element),button:n,buttons:o.buttons,isTouchEvent:"touch"===i.type,originalEvent:t.originalEvent,userData:e.userData})}}}function B(t,i,n,e){const r=u[t.hash];const o=t.getActivePointersListByType(n.type);let s;let a;let l=!1;var h;void 0!==i.originalEvent.buttons?o.buttons=i.originalEvent.buttons:0===e?o.buttons^=-2:1===e?o.buttons^=-5:2===e?o.buttons^=-3:3===e?o.buttons^=-9:4===e?o.buttons^=-17:5===e&&(o.buttons^=-33);i.shouldCapture=!1;if(0===e){let e=o.getById(n.id);if(e){o.removeContact();e.captured&&(l=!0);e.lastPos=e.currentPos;e.lastTime=e.currentTime;e.currentPos=n.currentPos;e.currentTime=n.currentTime;e.insideElement||I(t,o,e);s=e.currentPos;a=e.currentTime}else{n.captured=!1;n.insideElementPressed=!1;n.insideElement=!0;D(o,n);e=n}if(!i.preventGesture&&!i.defaultPrevented)if(l){i.shouldReleaseCapture=!0;i.preventDefault=!0;(t.dragHandler||t.dragEndHandler||t.pinchHandler)&&c.MouseTracker.gesturePointVelocityTracker.removePoint(t,e);if(0===o.contacts){t.releaseHandler&&s&&t.releaseHandler({eventSource:t,pointerType:e.type,position:f(s,t.element),buttons:o.buttons,insideElementPressed:e.insideElementPressed,insideElementReleased:e.insideElement,isTouchEvent:"touch"===e.type,originalEvent:i.originalEvent,userData:t.userData});t.dragEndHandler&&r.sentDragEvent&&t.dragEndHandler({eventSource:t,pointerType:e.type,position:f(e.currentPos,t.element),speed:e.speed,direction:e.direction,shift:i.originalEvent.shiftKey,isTouchEvent:"touch"===e.type,originalEvent:i.originalEvent,userData:t.userData});r.sentDragEvent=!1;if((t.clickHandler||t.dblClickHandler)&&e.insideElement){h=a-e.contactTime<=t.clickTimeThreshold&&e.contactPos.distanceTo(s)<=t.clickDistThreshold;t.clickHandler&&t.clickHandler({eventSource:t,pointerType:e.type,position:f(e.currentPos,t.element),quick:h,shift:i.originalEvent.shiftKey,isTouchEvent:"touch"===e.type,originalEvent:i.originalEvent,originalTarget:e.originalTarget,userData:t.userData});if(t.dblClickHandler&&h){o.clicks++;if(1===o.clicks){r.lastClickPos=s;r.dblClickTimeOut=setTimeout(function(){o.clicks=0},t.dblClickTimeThreshold)}else if(2===o.clicks){clearTimeout(r.dblClickTimeOut);o.clicks=0;r.lastClickPos.distanceTo(s)<=t.dblClickDistThreshold&&t.dblClickHandler({eventSource:t,pointerType:e.type,position:f(e.currentPos,t.element),shift:i.originalEvent.shiftKey,isTouchEvent:"touch"===e.type,originalEvent:i.originalEvent,userData:t.userData});r.lastClickPos=null}}}}else if(2===o.contacts&&t.pinchHandler&&"touch"===e.type){r.pinchGPoints=o.asArray();r.lastPinchDist=r.currentPinchDist=r.pinchGPoints[0].currentPos.distanceTo(r.pinchGPoints[1].currentPos);r.lastPinchCenter=r.currentPinchCenter=v(r.pinchGPoints[0].currentPos,r.pinchGPoints[1].currentPos)}}else{i.shouldReleaseCapture=!1;if(t.releaseHandler&&s){t.releaseHandler({eventSource:t,pointerType:e.type,position:f(s,t.element),buttons:o.buttons,insideElementPressed:e.insideElementPressed,insideElementReleased:e.insideElement,isTouchEvent:"touch"===e.type,originalEvent:i.originalEvent,userData:t.userData});i.preventDefault=!0}}}else{i.shouldReleaseCapture=!1;if(t.nonPrimaryReleaseHandler&&!i.preventGesture&&!i.defaultPrevented){i.preventDefault=!0;t.nonPrimaryReleaseHandler({eventSource:t,pointerType:n.type,position:f(n.currentPos,t.element),button:e,buttons:o.buttons,isTouchEvent:"touch"===n.type,originalEvent:i.originalEvent,userData:t.userData})}}}function M(n,r,o){const e=u[n.hash];const t=n.getActivePointersListByType(o.type);let i;void 0!==r.originalEvent.buttons&&(t.buttons=r.originalEvent.buttons);let s=t.getById(o.id);if(s){s.lastPos=s.currentPos;s.lastTime=s.currentTime;s.currentPos=o.currentPos;s.currentTime=o.currentTime;r.shouldCapture=!1;r.shouldReleaseCapture=!1;if(n.stopHandler&&"mouse"===o.type){clearTimeout(n.stopTimeOut);n.stopTimeOut=setTimeout(function(){e=n,t=r.originalEvent,i=o.type,e.stopHandler&&e.stopHandler({eventSource:e,pointerType:i,position:m(t,e.element),buttons:e.getActivePointersListByType(i).buttons,isTouchEvent:"touch"===i,originalEvent:t,userData:e.userData});var e,t,i},n.stopDelay)}if(0===t.contacts)n.moveHandler&&n.moveHandler({eventSource:n,pointerType:o.type,position:f(o.currentPos,n.element),buttons:t.buttons,isTouchEvent:"touch"===o.type,originalEvent:r.originalEvent,userData:n.userData});else if(1===t.contacts){if(n.moveHandler){s=t.asArray()[0];n.moveHandler({eventSource:n,pointerType:s.type,position:f(s.currentPos,n.element),buttons:t.buttons,isTouchEvent:"touch"===s.type,originalEvent:r.originalEvent,userData:n.userData})}if(n.dragHandler&&!r.preventGesture&&!r.defaultPrevented){s=t.asArray()[0];i=s.currentPos.minus(s.lastPos);n.dragHandler({eventSource:n,pointerType:s.type,position:f(s.currentPos,n.element),buttons:t.buttons,delta:i,speed:s.speed,direction:s.direction,shift:r.originalEvent.shiftKey,isTouchEvent:"touch"===s.type,originalEvent:r.originalEvent,userData:n.userData});r.preventDefault=!0;e.sentDragEvent=!0}}else if(2===t.contacts){if(n.moveHandler){var a=t.asArray();n.moveHandler({eventSource:n,pointerType:a[0].type,position:f(v(a[0].currentPos,a[1].currentPos),n.element),buttons:t.buttons,isTouchEvent:"touch"===a[0].type,originalEvent:r.originalEvent,userData:n.userData})}if(n.pinchHandler&&"touch"===o.type&&!r.preventGesture&&!r.defaultPrevented){i=e.pinchGPoints[0].currentPos.distanceTo(e.pinchGPoints[1].currentPos);if(i!==e.currentPinchDist){e.lastPinchDist=e.currentPinchDist;e.currentPinchDist=i;e.lastPinchCenter=e.currentPinchCenter;e.currentPinchCenter=v(e.pinchGPoints[0].currentPos,e.pinchGPoints[1].currentPos);n.pinchHandler({eventSource:n,pointerType:"touch",gesturePoints:e.pinchGPoints,lastCenter:f(e.lastPinchCenter,n.element),center:f(e.currentPinchCenter,n.element),lastDistance:e.lastPinchDist,distance:e.currentPinchDist,shift:r.originalEvent.shiftKey,originalEvent:r.originalEvent,userData:n.userData});r.preventDefault=!0}}}}}function z(e,t,i){const n=e.getActivePointersListByType(i.type);i=n.getById(i.id);i&&I(e,n,i)}}(OpenSeadragon);!function(r){r.ControlAnchor={NONE:0,TOP_LEFT:1,TOP_RIGHT:2,BOTTOM_RIGHT:3,BOTTOM_LEFT:4,ABSOLUTE:5};r.Control=function(e,t,i){const n=e.parentNode;if("number"==typeof t){r.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");t={anchor:t}}t.attachToViewer=void 0===t.attachToViewer||t.attachToViewer;this.autoFade=void 0===t.autoFade||t.autoFade;this.element=e;this.anchor=t.anchor;this.container=i;if(this.anchor===r.ControlAnchor.ABSOLUTE){this.wrapper=r.makeNeutralElement("div");this.wrapper.style.position="absolute";this.wrapper.style.top="number"==typeof t.top?t.top+"px":t.top;this.wrapper.style.left="number"==typeof t.left?t.left+"px":t.left;this.wrapper.style.height="number"==typeof t.height?t.height+"px":t.height;this.wrapper.style.width="number"==typeof t.width?t.width+"px":t.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%"}else{this.wrapper=r.makeNeutralElement("div");this.wrapper.style.display="inline-block";this.anchor===r.ControlAnchor.NONE&&(this.wrapper.style.width=this.wrapper.style.height="100%")}this.wrapper.appendChild(this.element);t.attachToViewer?this.anchor===r.ControlAnchor.TOP_RIGHT||this.anchor===r.ControlAnchor.BOTTOM_RIGHT?this.container.insertBefore(this.wrapper,this.container.firstChild):this.container.appendChild(this.wrapper):n.appendChild(this.wrapper)};r.Control.prototype={destroy:function(){this.wrapper.removeChild(this.element);this.anchor!==r.ControlAnchor.NONE&&this.container.removeChild(this.wrapper)},isVisible:function(){return"none"!==this.wrapper.style.display},setVisible:function(e){this.wrapper.style.display=e?this.anchor===r.ControlAnchor.ABSOLUTE?"block":"inline-block":"none"},setOpacity:function(e){r.setElementOpacity(this.wrapper,e,!0)}}}(OpenSeadragon);!function(n){n.ControlDock=function(e){var i=["topleft","topright","bottomright","bottomleft"];n.extend(!0,this,{id:"controldock-"+n.now()+"-"+Math.floor(1e6*Math.random()),container:n.makeNeutralElement("div"),controls:[]},e);this.container.onsubmit=function(){return!1};if(this.element){this.element=n.getElement(this.element);this.element.appendChild(this.container);"static"===n.getElementStyle(this.element).position&&(this.element.style.position="relative");this.container.style.width="100%";this.container.style.height="100%"}for(let t=0;t<i.length;t++){let e=i[t];this.controls[e]=n.makeNeutralElement("div");this.controls[e].style.position="absolute";e.match("left")&&(this.controls[e].style.left="0px");e.match("right")&&(this.controls[e].style.right="0px");e.match("top")&&(this.controls[e].style.top="0px");e.match("bottom")&&(this.controls[e].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)};n.ControlDock.prototype={addControl:function(e,t){let i=null;if(!(0<=r(this,e=n.getElement(e)))){switch(t.anchor){case n.ControlAnchor.TOP_RIGHT:i=this.controls.topright;e.style.position="relative";e.style.paddingRight="0px";e.style.paddingTop="0px";break;case n.ControlAnchor.BOTTOM_RIGHT:i=this.controls.bottomright;e.style.position="relative";e.style.paddingRight="0px";e.style.paddingBottom="0px";break;case n.ControlAnchor.BOTTOM_LEFT:i=this.controls.bottomleft;e.style.position="relative";e.style.paddingLeft="0px";e.style.paddingBottom="0px";break;case n.ControlAnchor.TOP_LEFT:i=this.controls.topleft;e.style.position="relative";e.style.paddingLeft="0px";e.style.paddingTop="0px";break;case n.ControlAnchor.ABSOLUTE:i=this.container;e.style.margin="0px";e.style.padding="0px";break;default:case n.ControlAnchor.NONE:i=this.container;e.style.margin="0px";e.style.padding="0px"}this.controls.push(new n.Control(e,t,i));e.style.display="inline-block"}},removeControl:function(e){e=r(this,e=n.getElement(e));if(0<=e){this.controls[e].destroy();this.controls.splice(e,1)}return this},clearControls:function(){for(;0<this.controls.length;)this.controls.pop().destroy();return this},areControlsEnabled:function(){for(let e=this.controls.length-1;0<=e;e--)if(this.controls[e].isVisible())return!0;return!1},setControlsEnabled:function(t){for(let e=this.controls.length-1;0<=e;e--)this.controls[e].setVisible(t);return this}};function r(e,t){var i=e.controls;for(let e=i.length-1;0<=e;e--)if(i[e].element===t)return e;return-1}}(OpenSeadragon);!function(e){e.Placement=e.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}}})}(OpenSeadragon);!function(m){const u={};let a=1;m.Viewer=function(i){var e=arguments;const n=this;let t;if((i=!m.isPlainObject(i)?{id:e[0],xmlPath:1<e.length?e[1]:void 0,prefixUrl:2<e.length?e[2]:void 0,controls:3<e.length?e[3]:void 0,overlays:4<e.length?e[4]:void 0}:i).config){m.extend(!0,i,i.config);delete i.config}i.drawerOptions=Object.assign({},["useCanvas"].reduce((e,t)=>{e[t]=i[t];delete i[t];return e},{}),i.drawerOptions);m.extend(!0,this,{id:i.id,hash:i.hash||a++,viewer:null,initialPage:0,element:null,container:null,canvas:null,overlays:[],overlaysContainer:null,previousDisplayValuesOfBodyChildren:[],customControls:[],source:null,drawer:null,drawerCandidates:null,world:null,viewport:null,navigator:null,collectionViewport:null,collectionDrawer:null,navImages:null,buttonGroup:null,profiler:null},m.DEFAULT_SETTINGS,i);if(void 0===this.hash)throw new Error("A hash must be defined, either by specifying options.id or options.hash.");void 0!==u[this.hash]&&m.console.warn("Hash "+this.hash+" has already been used.");u[this.hash]={fsBoundsDelta:new m.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=m.now();this._fullyLoaded=!1;this._navActionFrames={};this._navActionVirtuallyHeld={};this._minNavActionFrames=10;this._activeActions={panUp:!1,panDown:!1,panLeft:!1,panRight:!1,zoomIn:!1,zoomOut:!1};m.EventSource.call(this);this.addHandler("open-failed",function(e){e=m.getString("Errors.OpenFailed",e.eventSource,e.message);n._showMessage(e)});m.ControlDock.call(this,i);this.xmlPath&&(this.tileSources=[this.xmlPath]);this.element=this.element||document.getElementById(this.id);this.canvas=m.makeNeutralElement("div");this.canvas.className="openseadragon-canvas";if(!document.querySelector("style[data-openseadragon-mobile-css]")){const o=document.createElement("style");o.setAttribute("data-openseadragon-mobile-css","true");o.textContent="@media (hover: none) { .openseadragon-canvas:focus { outline: none !important; }}";document.head.appendChild(o)}!function(e){e.width="100%";e.height="100%";e.overflow="hidden";e.position="absolute";e.top="0px";e.left="0px"}(this.canvas.style);m.setElementTouchActionNone(this.canvas);""!==i.tabIndex&&(this.canvas.tabIndex=void 0===i.tabIndex?0:i.tabIndex);this.container.className="openseadragon-container";!function(e){e.width="100%";e.height="100%";e.position="relative";e.overflow="hidden";e.left="0px";e.top="0px";e.textAlign="left"}(this.container.style);m.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 m.MouseTracker({userData:"Viewer.innerTracker",element:this.canvas,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,contextMenuHandler:m.delegate(this,p),keyDownHandler:m.delegate(this,y),keyUpHandler:m.delegate(this,g),keyHandler:m.delegate(this,w),clickHandler:m.delegate(this,_),dblClickHandler:m.delegate(this,T),dragHandler:m.delegate(this,x),dragEndHandler:m.delegate(this,S),enterHandler:m.delegate(this,E),leaveHandler:m.delegate(this,C),pressHandler:m.delegate(this,b),releaseHandler:m.delegate(this,P),nonPrimaryPressHandler:m.delegate(this,R),nonPrimaryReleaseHandler:m.delegate(this,D),scrollHandler:m.delegate(this,L),pinchHandler:m.delegate(this,I),focusHandler:m.delegate(this,A),blurHandler:m.delegate(this,F)});this.outerTracker=new m.MouseTracker({userData:"Viewer.outerTracker",element:this.container,startDisabled:!this.mouseNavEnabled,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,dblClickTimeThreshold:this.dblClickTimeThreshold,dblClickDistThreshold:this.dblClickDistThreshold,enterHandler:m.delegate(this,O),leaveHandler:m.delegate(this,k)});this.toolbar&&(this.toolbar=new m.ControlDock({element:this.toolbar}));this.bindStandardControls();u[this.hash].prevContainerSize=l(this.container);if(window.ResizeObserver){this._autoResizePolling=!1;this._resizeObserver=new ResizeObserver(function(){u[n.hash].needsResize=!0});this._resizeObserver.observe(this.container,{})}else this._autoResizePolling=!0;this.world=new m.World({viewer:this});this.world.addHandler("add-item",function(e){n.source=n.world.getItemAt(0).source;u[n.hash].forceRedraw=!0;n._updateRequestId||(n._updateRequestId=c(n,B));const t=e.item;function i(){var e=n._areAllFullyLoaded();if(e!==n._fullyLoaded){n._fullyLoaded=e;n.raiseEvent("fully-loaded-change",{fullyLoaded:e})}}t._fullyLoadedHandlerForViewer=i;t.addHandler("fully-loaded-change",i)});this.world.addHandler("remove-item",function(e){const t=e.item;if(t._fullyLoadedHandlerForViewer){t.removeHandler("fully-loaded-change",t._fullyLoadedHandlerForViewer);delete t._fullyLoadedHandlerForViewer}n.world.getItemCount()?n.source=n.world.getItemAt(0).source:n.source=null;u[n.hash].forceRedraw=!0});this.world.addHandler("metrics-change",function(e){n.viewport&&n.viewport._setContentBounds(n.world.getHomeBounds(),n.world.getContentFactor())});this.world.addHandler("item-index-change",function(e){n.source=n.world.getItemAt(0).source});this.viewport=new m.Viewport({containerSize:u[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,overlayPreserveContentDirection:this.overlayPreserveContentDirection,navigatorRotate:this.navigatorRotate,homeFillsViewer:this.homeFillsViewer,margins:this.viewportMargins,silenceMultiImageWarnings:this.silenceMultiImageWarnings});this.viewport._setContentBounds(this.world.getHomeBounds(),this.world.getContentFactor());this.imageLoader=new m.ImageLoader({jobLimit:this.imageLoaderLimit,timeout:i.timeout,tileRetryMax:this.tileRetryMax,tileRetryDelay:this.tileRetryDelay});this.tileCache=new m.TileCache({viewer:this,maxImageCacheCount:this.maxImageCacheCount});if(Object.prototype.hasOwnProperty.call(this.drawerOptions,"useCanvas")){m.console.error('useCanvas is deprecated, use the "drawer" option to indicate preferred drawer(s)');this.drawerOptions.useCanvas||(this.drawer=m.HTMLDrawer);delete this.drawerOptions.useCanvas}let r=Array.isArray(this.drawer)?this.drawer:[this.drawer];if(0===r.length){r=[m.DEFAULT_SETTINGS.drawer].flat();m.console.warn("No valid drawers were selected. Using the default value.")}r=r.flatMap(function(e){return"auto"===e?V():[e]});r=r.filter(function(e,t,i){return i.indexOf(e)===t});this.drawerCandidates=r.map(G).filter(Boolean);this.drawer=null;for(const s of r)if(this.requestDrawer(s,{mainDrawer:!0,redrawImmediately:!1}))break;if(!this.drawer){m.console.error("No drawer could be created!");throw"Error with creating the selected drawer(s)"}this.drawer.setImageSmoothingEnabled(this.imageSmoothingEnabled);this.overlaysContainer=m.makeNeutralElement("div");this.canvas.appendChild(this.overlaysContainer);if(!this.drawer.canRotate()){if(this.rotateLeft){t=this.buttonGroup.buttons.indexOf(this.rotateLeft);this.buttonGroup.buttons.splice(t,1);this.buttonGroup.element.removeChild(this.rotateLeft.element)}if(this.rotateRight){t=this.buttonGroup.buttons.indexOf(this.rotateRight);this.buttonGroup.buttons.splice(t,1);this.buttonGroup.element.removeChild(this.rotateRight.element)}}this._addUpdatePixelDensityRatioEvent();"navigatorAutoResize"in this&&m.console.warn("navigatorAutoResize is deprecated, this value will be ignored.");this.showNavigator&&(this.navigator=new m.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,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,drawer:this.drawer.getType(),drawerOptions:this.drawerOptions,loadTilesWithAjax:this.loadTilesWithAjax,ajaxHeaders:this.ajaxHeaders,ajaxWithCredentials:this.ajaxWithCredentials}));this.sequenceMode&&this.bindSequenceControls();this.tileSources&&this.open(this.tileSources);for(t=0;t<this.customControls.length;t++)this.addControl(this.customControls[t].id,{anchor:this.customControls[t].anchor});m.requestAnimationFrame(function(){d(n)});m._viewers.set(this.element,this)};m.extend(m.Viewer.prototype,m.EventSource.prototype,m.ControlDock.prototype,{isOpen:function(){return!!this.world.getItemCount()},_areAllFullyLoaded:function(){var e=this.world.getItemCount();for(let t=0;t<e;t++){let e=this.world.getItemAt(t);if(!e.getFullyLoaded())return!1}return!0},getFullyLoaded:function(){return this._fullyLoaded},whenFullyLoaded:function(e){this.getFullyLoaded()?setTimeout(e,1):this.addOnceHandler("fully-loaded-change",function(){e()})},openDzi:function(e){m.console.error("[Viewer.openDzi] this function is deprecated; use Viewer.open() instead.");return this.open(e)},openTileSource:function(e){m.console.error("[Viewer.openTileSource] this function is deprecated; use Viewer.open() instead.");return this.open(e)},get buttons(){m.console.warn("Viewer.buttons is deprecated; Please use Viewer.buttonGroup");return this.buttonGroup},open:function(t,e=void 0){const r=this;this.close();if(!t)return this;if(this.sequenceMode&&m.isArray(t)){if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}void 0===e||isNaN(e)||(this.initialPage=e);this.tileSources=t;this._sequenceIndex=Math.max(0,Math.min(this.tileSources.length-1,this.initialPage));if(this.tileSources.length){this.open(this.tileSources[this._sequenceIndex]);this.showReferenceStrip&&this.addReferenceStrip()}this._updateSequenceButtons(this._sequenceIndex);return this}if(!(t=!m.isArray(t)?[t]:t).length)return this;this._opening=!0;const i=t.length;let o=0;let s=0;let a;const l=function(){if(o+s===i)if(o){if(r._firstOpen||!r.preserveViewport){r.viewport.goHome(!0);r.viewport.update()}r._firstOpen=!1;let e=t[0];e.tileSource&&(e=e.tileSource);if(r.overlays&&!r.preserveOverlays)for(let e=0;e<r.overlays.length;e++)r.currentOverlays[e]=h(r,r.overlays[e]);r._drawOverlays();r._opening=!1;r.raiseEvent("open",{source:e})}else{r._opening=!1;r.raiseEvent("open-failed",a)}};for(let e=0;e<t.length;e++)!function(e,t){if(void 0!==(t=!m.isPlainObject(t)||!t.tileSource?{tileSource:t}:t).index){m.console.warn("[Viewer.open] Ignoring user-supplied index; preserving order by setting index to "+e+". If you need to set indexes, use addTiledImage instead.");delete t.index;t.index=e}void 0===t.collectionImmediately&&(t.collectionImmediately=!0);const i=t.success;t.success=function(e){o++;if(t.tileSource.overlays)for(let e=0;e<t.tileSource.overlays.length;e++)r.addOverlay(t.tileSource.overlays[e]);i&&i(e);l()};const n=t.error;t.error=function(e){s++;a=a||e;n&&n(e);l()};r.addTiledImage(t)}(e,t[e]);return this},requestInvalidate:function(t=!0){if(!u[this.hash]||!this._drawerList)return m.Promise.resolve();const i=m.now();return m.Promise.all(this._drawerList.map(e=>e.viewer.world.requestInvalidate(t,i)))},close:function(){if(!u[this.hash])return this;this._opening=!1;this.navigator&&this.navigator.close();if(!this.preserveOverlays){this.clearOverlays();this.overlaysContainer.innerHTML=""}u[this.hash].animating=!1;this.world.removeAll();this.tileCache.clear();this.imageLoader.clear();this.raiseEvent("close");return this},destroy:function(){if(u[this.hash]){this.raiseEvent("before-destroy");this._removeUpdatePixelDensityRatioEvent();this.close();this.clearOverlays();this.overlaysContainer.innerHTML="";this._resizeObserver&&this._resizeObserver.disconnect();if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}if(null!==this._updateRequestId){m.cancelAnimationFrame(this._updateRequestId);this._updateRequestId=null}this.drawer&&this.drawer.destroy();if(this.navigator){this.navigator.destroy();u[this.navigator.hash]=null;delete u[this.navigator.hash];this.navigator=null}if(this.buttonGroup)this.buttonGroup.destroy();else if(this.customButtons)for(;this.customButtons.length;)this.customButtons.pop().destroy();this.paging&&this.paging.destroy();this.container&&this.container.parentNode===this.element&&this.element.removeChild(this.container);this.container.onsubmit=null;this.clearControls();this.innerTracker&&this.innerTracker.destroy();this.outerTracker&&this.outerTracker.destroy();u[this.hash]=null;delete u[this.hash];this.canvas=null;this.container=null;m._viewers.delete(this.element);this.element=null;this.raiseEvent("destroy");this.removeAllHandlers()}},isDestroyed(){return!u[this.hash]},requestDrawer(t,e){var i=(e=m.extend(!0,{mainDrawer:!0,redrawImmediately:!0,drawerOptions:null},e)).mainDrawer;var n=e.redrawImmediately;e=e.drawerOptions;const r=this.drawer;let o=null;if(t&&t.prototype instanceof m.DrawerBase){o=t;t="custom"}else"string"==typeof t&&(o=m.determineDrawer(t));o||m.console.warn("Unsupported drawer %s! Drawer must be an existing string type, or a class that extends OpenSeadragon.DrawerBase.",t);let s=!1;if(o)try{s=o.isSupported()}catch(e){m.console.warn("Error in %s isSupported(); treating this drawer as unsupported:",t,e&&e.message?e.message:e)}if(s){r&&i&&r.destroy();t=new o({viewer:this,viewport:this.viewport,element:this.canvas,debugGridColor:this.debugGridColor,options:e||this.drawerOptions[t]});if(i){this.drawer=t;n&&this.forceRedraw()}return t}return!1},isMouseNavEnabled:function(){return this.innerTracker.tracking},setMouseNavEnabled:function(e){this.innerTracker.setTracking(e);this.outerTracker.setTracking(e);this.raiseEvent("mouse-enabled",{enabled:e});return this},isKeyboardNavEnabled:function(){return this.keyboardNavEnabled},setKeyboardNavEnabled:function(e){this.keyboardNavEnabled=e;this.raiseEvent("keyboard-enabled",{enabled:e});return this},areControlsEnabled:function(){let t=this.controls.length;for(let e=0;e<this.controls.length;e++)t=t&&this.controls[e].isVisible();return t},setControlsEnabled:function(e){(e?r:d)(this);this.raiseEvent("controls-enabled",{enabled:e});return this},setDebugMode:function(t){for(let e=0;e<this.world.getItemCount();e++)this.world.getItemAt(e).debugMode=t;this.debugMode=t;this.forceRedraw()},setAjaxHeaders:function(e,t){if(m.isPlainObject(e=null===e?{}:e)){void 0===t&&(t=!0);this.ajaxHeaders=e;if(t){for(let e=0;e<this.world.getItemCount();e++)this.world.getItemAt(e)._updateAjaxHeaders(!0);this.navigator&&this.navigator.setAjaxHeaders(this.ajaxHeaders,!0);if(this.referenceStrip&&this.referenceStrip.miniViewers)for(const i in this.referenceStrip.miniViewers)this.referenceStrip.miniViewers[i].setAjaxHeaders(this.ajaxHeaders,!0)}}else m.console.error("[Viewer.setAjaxHeaders] Ignoring invalid headers, must be a plain object")},addButton:function(e){this.buttonGroup.addButton(e)},isFullPage:function(){return u[this.hash]&&u[this.hash].fullPage},setFullPage:function(e){const i=document.body;const n=i.style;const r=document.documentElement.style;const o=this;let s;if(e===this.isFullPage())return this;var t={fullPage:e,preventDefaultAction:!1};this.raiseEvent("pre-full-page",t);if(t.preventDefaultAction)return this;if(e&&this.element){this.elementSize=m.getElementSize(this.element);this.pageScroll=m.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=n.margin;this.docMargin=r.margin;n.margin="0";r.margin="0";this.bodyPadding=n.padding;this.docPadding=r.padding;n.padding="0";r.padding="0";this.bodyWidth=n.width;this.docWidth=r.width;n.width="100%";r.width="100%";this.bodyHeight=n.height;this.docHeight=r.height;n.height="100%";r.height="100%";this.bodyDisplay=n.display;n.display="block";this.previousDisplayValuesOfBodyChildren=[];u[this.hash].prevElementParent=this.element.parentNode;u[this.hash].prevNextSibling=this.element.nextSibling;u[this.hash].prevElementWidth=this.element.style.width;u[this.hash].prevElementHeight=this.element.style.height;s=i.children.length;for(let e=0;e<s;e++){const a=i.children[e];if(a!==this.element){this.previousDisplayValuesOfBodyChildren.push({element:a,display:a.style.display});a.style.display="none"}}if(this.toolbar&&this.toolbar.element){this.toolbar.parentNode=this.toolbar.element.parentNode;this.toolbar.nextSibling=this.toolbar.element.nextSibling;i.appendChild(this.toolbar.element);m.addClass(this.toolbar.element,"fullpage")}m.addClass(this.element,"fullpage");i.appendChild(this.element);this.element.style.height="100vh";this.element.style.width="100vw";this.toolbar&&this.toolbar.element&&(this.element.style.height=m.getElementSize(this.element).y-m.getElementSize(this.toolbar.element).y+"px");u[this.hash].fullPage=!0;m.delegate(this,O)({})}else{this.element.style.margin=this.elementMargin;this.element.style.padding=this.elementPadding;n.margin=this.bodyMargin;r.margin=this.docMargin;n.padding=this.bodyPadding;r.padding=this.docPadding;n.width=this.bodyWidth;r.width=this.docWidth;n.height=this.bodyHeight;r.height=this.docHeight;n.display=this.bodyDisplay;i.removeChild(this.element);s=this.previousDisplayValuesOfBodyChildren.length;for(let e=0;e<s;e++){const{element:h,display:c}=this.previousDisplayValuesOfBodyChildren[e];h.style.display=c}m.removeClass(this.element,"fullpage");u[this.hash].prevElementParent.insertBefore(this.element,u[this.hash].prevNextSibling);if(this.toolbar&&this.toolbar.element){i.removeChild(this.toolbar.element);m.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=u[this.hash].prevElementWidth;this.element.style.height=u[this.hash].prevElementHeight;let t=0;const l=function(){m.setPageScroll(o.pageScroll);var e=m.getPageScroll();t++;t<10&&(e.x!==o.pageScroll.x||e.y!==o.pageScroll.y)&&m.requestAnimationFrame(l)};m.requestAnimationFrame(l);u[this.hash].fullPage=!1;m.delegate(this,k)({})}this.navigator&&this.viewport&&this.navigator.update(this.viewport);this.raiseEvent("full-page",{fullPage:e});return this},setFullScreen:function(e){const t=this;if(!m.supportsFullScreen)return this.setFullPage(e);if(m.isFullScreen()===e)return this;var i={fullScreen:e,preventDefaultAction:!1};this.raiseEvent("pre-full-screen",i);if(i.preventDefaultAction)return this;if(e){this.setFullPage(!0);if(!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%";const n=function(){if(u[t.hash]){var e=m.isFullScreen();if(!e){m.removeEvent(document,m.fullScreenEventName,n);m.removeEvent(document,m.fullScreenErrorEventName,n);t.setFullPage(!1);if(t.isFullPage()){t.element.style.width=t.fullPageStyleWidth;t.element.style.height=t.fullPageStyleHeight}}t.navigator&&t.viewport&&setTimeout(function(){t.navigator.update(t.viewport)});t.raiseEvent("full-screen",{fullScreen:e})}else{m.removeEvent(document,m.fullScreenEventName,n);m.removeEvent(document,m.fullScreenErrorEventName,n)}};m.addEvent(document,m.fullScreenEventName,n);m.addEvent(document,m.fullScreenErrorEventName,n);m.requestFullScreen(document.body)}else m.exitFullScreen();return this},isVisible:function(){return"hidden"!==this.container.style.visibility},isFullScreen:function(){return m.isFullScreen()&&this.isFullPage()},setVisible:function(e){this.container.style.visibility=e?"":"hidden";this.raiseEvent("visible",{visible:e});return this},addTiledImage:function(e){m.console.assert(e,"[Viewer.addTiledImage] options is required");m.console.assert(e.tileSource,"[Viewer.addTiledImage] options.tileSource is required");m.console.assert(!e.replace||-1<e.index&&e.index<this.world.getItemCount(),"[Viewer.addTiledImage] if options.replace is used, options.index must be a valid index in Viewer.world");this._hideMessage();const a=e.success;const t=e.error;e.replace&&(e.replaceItem=this.world.getItemAt(e.index));const l={options:e};this._loadQueue.push(l);const h=e=>{if(this.collectionMode){this.world.arrange({immediately:e.options.collectionImmediately,rows:this.collectionRows,columns:this.collectionColumns,layout:this.collectionLayout,tileSize:this.collectionTileSize,tileMargin:this.collectionTileMargin});this.world.setAutoRefigureSizes(!0)}};const i=e=>{for(let e=0;e<this._loadQueue.length;e++)if(this._loadQueue[e]===l){this._loadQueue.splice(e,1);break}0===this._loadQueue.length&&h(l);this.raiseEvent("add-item-failed",e);t&&t(e)};if(m.isArray(e.tileSource))setTimeout(function(){i({message:"[Viewer.addTiledImage] Sequences can not be added; add them one at a time instead.",source:e.tileSource,options:e})});else{delete l.tiledImage;e.success=e=>{l.tiledImage=e.item;l.originalSuccess=a;let t,i;for(;this._loadQueue.length;){t=this._loadQueue[0];var n=t.tiledImage;if(!n)break;this._loadQueue.splice(0,1);var r=n.source;if(t.options.replace){const s=t.options.replaceItem;var o=this.world.getIndexOfItem(s);-1!==o&&(t.options.index=o);!s._zombieCache&&s.source.equals(r)&&s.allowZombieCache(!0);this.world.removeItem(s)}this.collectionMode&&this.world.setAutoRefigureSizes(!1);if(this.navigator){i=m.extend({},t.options,{replace:!1,originalTiledImage:n,tileSource:r});this.navigator.addTiledImage(i)}this.world.addItem(n,{index:t.options.index});0===this._loadQueue.length&&h(t);1!==this.world.getItemCount()||this.preserveViewport||this.viewport.goHome(!0);t.originalSuccess&&t.originalSuccess({item:n});this.drawer&&this.drawer.tiledImageCreated(n)}};e.error=i;this.instantiateTiledImageClass(e)}},instantiateTiledImageClass:function(t){return this.instantiateTileSourceClass(t).then(e=>{e=new m.TiledImage({viewer:this,source:e.source,viewport:this.viewport,drawer:this.drawer,tileCache:this.tileCache,imageLoader:this.imageLoader,x:t.x,y:t.y,width:t.width,height:t.height,fitBounds:t.fitBounds,fitBoundsPlacement:t.fitBoundsPlacement,clip:t.clip,placeholderFillStyle:t.placeholderFillStyle,opacity:t.opacity,preload:t.preload,degrees:t.degrees,flipped:t.flipped,compositeOperation:t.compositeOperation,springStiffness:this.springStiffness,animationTime:this.animationTime,minZoomImageRatio:this.minZoomImageRatio,wrapHorizontal:this.wrapHorizontal,wrapVertical:this.wrapVertical,maxTilesPerFrame:this.maxTilesPerFrame,loadDestinationTilesOnAnimation:this.loadDestinationTilesOnAnimation,immediateRender:this.immediateRender,blendTime:this.blendTime,alwaysBlend:this.alwaysBlend,minPixelRatio:this.minPixelRatio,smoothTileEdgesMinZoom:this.smoothTileEdgesMinZoom,iOSDevice:this.iOSDevice,crossOriginPolicy:t.crossOriginPolicy,ajaxWithCredentials:t.ajaxWithCredentials,loadTilesWithAjax:t.loadTilesWithAjax,ajaxHeaders:t.ajaxHeaders,debugMode:this.debugMode,subPixelRoundingForTransparency:this.subPixelRoundingForTransparency,callTileLoadedWithCachedData:this.callTileLoadedWithCachedData,originalDataType:t.originalDataType});t.success({item:e});return e}).catch(e=>{if(t.error){t.error(e);return e}throw e})},instantiateTileSourceClass(s){return new m.Promise((i,n)=>{void 0===s.placeholderFillStyle&&(s.placeholderFillStyle=this.placeholderFillStyle);void 0===s.opacity&&(s.opacity=this.opacity);void 0===s.preload&&(s.preload=this.preload);void 0===s.compositeOperation&&(s.compositeOperation=this.compositeOperation);void 0===s.crossOriginPolicy&&(s.crossOriginPolicy=(void 0!==s.tileSource.crossOriginPolicy?s.tileSource:this).crossOriginPolicy);void 0===s.ajaxWithCredentials&&(s.ajaxWithCredentials=this.ajaxWithCredentials);void 0===s.loadTilesWithAjax&&(s.loadTilesWithAjax=this.loadTilesWithAjax);m.isPlainObject(s.ajaxHeaders)||(s.ajaxHeaders={});let r=s.tileSource;if("string"===m.type(r))if(r.match(/^\s*<.*>\s*$/))r=m.parseXml(r);else if(r.match(/^\s*[{[].*[}\]]\s*$/))try{r=m.parseJSON(r)}catch(e){}function o(e,t){if(e.ready)i({source:e});else{e.addHandler("ready",function(e){i({source:e.tileSource})});e.addHandler("open-failed",function(e){n({message:e.message,source:t})})}}setTimeout(()=>{if("string"===m.type(r)){r=new m.TileSource({url:r,crossOriginPolicy:(void 0!==s.crossOriginPolicy?s:this).crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,ajaxHeaders:m.extend({},this.ajaxHeaders,s.ajaxHeaders),splitHashDataForPost:this.splitHashDataForPost});o(r,r)}else if(m.isPlainObject(r)||r.nodeType){void 0!==r.crossOriginPolicy||void 0===s.crossOriginPolicy&&void 0===this.crossOriginPolicy||(r.crossOriginPolicy=(void 0!==s.crossOriginPolicy?s:this).crossOriginPolicy);void 0===r.ajaxWithCredentials&&(r.ajaxWithCredentials=this.ajaxWithCredentials);if(m.isFunction(r.getTileUrl)){const e=new m.TileSource(r);e.getTileUrl=r.getTileUrl;r.ready=!1;o(e,r)}else{const t=m.TileSource.determineType(this,r,null);if(t){const i=t.prototype.configure.apply(this,[r]);i.ready=!1;o(new t(i),r)}else n({message:"Unable to load TileSource",source:r,error:!0})}}else o(r,r)})})},addSimpleImage:function(e){m.console.assert(e,"[Viewer.addSimpleImage] options is required");m.console.assert(e.url,"[Viewer.addSimpleImage] options.url is required");const t=m.extend({},e,{tileSource:{type:"image",url:e.url}});delete t.url;this.addTiledImage(t)},addLayer:function(t){const i=this;m.console.error("[Viewer.addLayer] this function is deprecated; use Viewer.addTiledImage() instead.");var e=m.extend({},t,{success:function(e){i.raiseEvent("add-layer",{options:t,drawer:e.item})},error:function(e){i.raiseEvent("add-layer-failed",e)}});this.addTiledImage(e);return this},getLayerAtLevel:function(e){m.console.error("[Viewer.getLayerAtLevel] this function is deprecated; use World.getItemAt() instead.");return this.world.getItemAt(e)},getLevelOfLayer:function(e){m.console.error("[Viewer.getLevelOfLayer] this function is deprecated; use World.getIndexOfItem() instead.");return this.world.getIndexOfItem(e)},getLayersCount:function(){m.console.error("[Viewer.getLayersCount] this function is deprecated; use World.getItemCount() instead.");return this.world.getItemCount()},setLayerLevel:function(e,t){m.console.error("[Viewer.setLayerLevel] this function is deprecated; use World.setItemIndex() instead.");return this.world.setItemIndex(e,t)},removeLayer:function(e){m.console.error("[Viewer.removeLayer] this function is deprecated; use World.removeItem() instead.");return this.world.removeItem(e)},forceRedraw:function(){u[this.hash].forceRedraw=!0;return this},forceResize:function(){u[this.hash].needsResize=!0;u[this.hash].forceResize=!0},bindSequenceControls:function(){var e=m.delegate(this,f);var t=m.delegate(this,v);var i=m.delegate(this,this.goToNextPage);var n=m.delegate(this,this.goToPreviousPage);var r=this.navImages;let o=!0;if(this.showSequenceControl){(this.previousButton||this.nextButton)&&(o=!1);this.previousButton=new m.Button({element:this.previousButton?m.getElement(this.previousButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.PreviousPage"),srcRest:M(this.prefixUrl,r.previous.REST),srcGroup:M(this.prefixUrl,r.previous.GROUP),srcHover:M(this.prefixUrl,r.previous.HOVER),srcDown:M(this.prefixUrl,r.previous.DOWN),onRelease:n,onFocus:e,onBlur:t});this.nextButton=new m.Button({element:this.nextButton?m.getElement(this.nextButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.NextPage"),srcRest:M(this.prefixUrl,r.next.REST),srcGroup:M(this.prefixUrl,r.next.GROUP),srcHover:M(this.prefixUrl,r.next.HOVER),srcDown:M(this.prefixUrl,r.next.DOWN),onRelease:i,onFocus:e,onBlur:t});this.navPrevNextWrap||this.previousButton.disable();this.tileSources&&this.tileSources.length||this.nextButton.disable();if(o){this.paging=new m.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:m.ControlAnchor.BOTTOM_RIGHT}):this.addControl(this.pagingControl,{anchor:this.sequenceControlAnchor||m.ControlAnchor.TOP_LEFT})}}return this},bindStandardControls:function(){var e=m.delegate(this,this.startZoomInAction);var t=m.delegate(this,this.endZoomAction);var i=m.delegate(this,this.singleZoomInAction);var n=m.delegate(this,this.startZoomOutAction);var r=m.delegate(this,this.singleZoomOutAction);var o=m.delegate(this,H);var s=m.delegate(this,N);var a=m.delegate(this,U);var l=m.delegate(this,W);var h=m.delegate(this,j);var c=m.delegate(this,f);var u=m.delegate(this,v);var d=this.navImages;const p=[];let g=!0;if(this.showNavigationControl){(this.zoomInButton||this.zoomOutButton||this.homeButton||this.fullPageButton||this.rotateLeftButton||this.rotateRightButton||this.flipButton)&&(g=!1);if(this.showZoomControl){p.push(this.zoomInButton=new m.Button({element:this.zoomInButton?m.getElement(this.zoomInButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.ZoomIn"),srcRest:M(this.prefixUrl,d.zoomIn.REST),srcGroup:M(this.prefixUrl,d.zoomIn.GROUP),srcHover:M(this.prefixUrl,d.zoomIn.HOVER),srcDown:M(this.prefixUrl,d.zoomIn.DOWN),onPress:e,onRelease:t,onClick:i,onEnter:e,onExit:t,onFocus:c,onBlur:u}));p.push(this.zoomOutButton=new m.Button({element:this.zoomOutButton?m.getElement(this.zoomOutButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.ZoomOut"),srcRest:M(this.prefixUrl,d.zoomOut.REST),srcGroup:M(this.prefixUrl,d.zoomOut.GROUP),srcHover:M(this.prefixUrl,d.zoomOut.HOVER),srcDown:M(this.prefixUrl,d.zoomOut.DOWN),onPress:n,onRelease:t,onClick:r,onEnter:n,onExit:t,onFocus:c,onBlur:u}))}this.showHomeControl&&p.push(this.homeButton=new m.Button({element:this.homeButton?m.getElement(this.homeButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.Home"),srcRest:M(this.prefixUrl,d.home.REST),srcGroup:M(this.prefixUrl,d.home.GROUP),srcHover:M(this.prefixUrl,d.home.HOVER),srcDown:M(this.prefixUrl,d.home.DOWN),onRelease:o,onFocus:c,onBlur:u}));this.showFullPageControl&&p.push(this.fullPageButton=new m.Button({element:this.fullPageButton?m.getElement(this.fullPageButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.FullPage"),srcRest:M(this.prefixUrl,d.fullpage.REST),srcGroup:M(this.prefixUrl,d.fullpage.GROUP),srcHover:M(this.prefixUrl,d.fullpage.HOVER),srcDown:M(this.prefixUrl,d.fullpage.DOWN),onRelease:s,onFocus:c,onBlur:u}));if(this.showRotationControl){p.push(this.rotateLeftButton=new m.Button({element:this.rotateLeftButton?m.getElement(this.rotateLeftButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.RotateLeft"),srcRest:M(this.prefixUrl,d.rotateleft.REST),srcGroup:M(this.prefixUrl,d.rotateleft.GROUP),srcHover:M(this.prefixUrl,d.rotateleft.HOVER),srcDown:M(this.prefixUrl,d.rotateleft.DOWN),onRelease:a,onFocus:c,onBlur:u}));p.push(this.rotateRightButton=new m.Button({element:this.rotateRightButton?m.getElement(this.rotateRightButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.RotateRight"),srcRest:M(this.prefixUrl,d.rotateright.REST),srcGroup:M(this.prefixUrl,d.rotateright.GROUP),srcHover:M(this.prefixUrl,d.rotateright.HOVER),srcDown:M(this.prefixUrl,d.rotateright.DOWN),onRelease:l,onFocus:c,onBlur:u}))}this.showFlipControl&&p.push(this.flipButton=new m.Button({element:this.flipButton?m.getElement(this.flipButton):null,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,tooltip:m.getString("Tooltips.Flip"),srcRest:M(this.prefixUrl,d.flip.REST),srcGroup:M(this.prefixUrl,d.flip.GROUP),srcHover:M(this.prefixUrl,d.flip.HOVER),srcDown:M(this.prefixUrl,d.flip.DOWN),onRelease:h,onFocus:c,onBlur:u}));if(g){this.buttonGroup=new m.ButtonGroup({buttons:p,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold});this.navControl=this.buttonGroup.element;this.addHandler("open",m.delegate(this,z));(this.toolbar||this).addControl(this.navControl,{anchor:this.navigationControlAnchor||m.ControlAnchor.TOP_LEFT})}else this.customButtons=p}return this},currentPage:function(){return this._sequenceIndex},goToPage:function(e){if(this.tileSources&&0<=e&&e<this.tileSources.length){this._sequenceIndex=e;this._updateSequenceButtons(e);this.open(this.tileSources[e]);this.referenceStrip&&this.referenceStrip.setFocus(e);this.raiseEvent("page",{page:e})}return this},addOverlay:function(e,t,i,n){let r;r=m.isPlainObject(e)?e:{element:e,location:t,placement:i,onDraw:n};e=m.getElement(r.element);if(0<=s(this.currentOverlays,e))return this;const o=h(this,r);this.currentOverlays.push(o);o.drawHTML(this.overlaysContainer,this.viewport);this.raiseEvent("add-overlay",{element:e,location:r.location,placement:r.placement});return this},updateOverlay:function(e,t,i){e=m.getElement(e);var n=s(this.currentOverlays,e);if(0<=n){this.currentOverlays[n].update(t,i);u[this.hash].forceRedraw=!0;this.raiseEvent("update-overlay",{element:e,location:t,placement:i})}return this},removeOverlay:function(e){e=m.getElement(e);var t=s(this.currentOverlays,e);if(0<=t){this.currentOverlays[t].destroy();this.currentOverlays.splice(t,1);u[this.hash].forceRedraw=!0;this.raiseEvent("remove-overlay",{element:e})}return this},clearOverlays:function(){for(;0<this.currentOverlays.length;)this.currentOverlays.pop().destroy();u[this.hash].forceRedraw=!0;this.raiseEvent("clear-overlay",{});return this},getOverlayById:function(e){e=m.getElement(e);e=s(this.currentOverlays,e);return 0<=e?this.currentOverlays[e]:null},_registerDrawer:function(e){this._drawerList||(this._drawerList=[]);this._drawerList.push(e)},_unregisterDrawer:function(e){this._drawerList?this._drawerList.splice(this._drawerList.indexOf(e),1):m.console.warn("Viewer._unregisterDrawer: cannot unregister on viewer that is not meant to share updates.")},_updateSequenceButtons:function(e){this.nextButton&&(this.tileSources&&this.tileSources.length-1!==e?this.nextButton.enable():this.navPrevNextWrap||this.nextButton.disable());this.previousButton&&(0<e?this.previousButton.enable():this.navPrevNextWrap||this.previousButton.disable())},_showMessage:function(e){this._hideMessage();const t=m.makeNeutralElement("div");t.appendChild(document.createTextNode(e));this.messageDiv=m.makeCenteredNode(t);m.addClass(this.messageDiv,"openseadragon-message");this.container.appendChild(this.messageDiv)},_hideMessage:function(){const e=this.messageDiv;if(e){e.parentNode.removeChild(e);delete this.messageDiv}},gestureSettingsByDeviceType:function(e){switch(e){case"mouse":return this.gestureSettingsMouse;case"touch":return this.gestureSettingsTouch;case"pen":return this.gestureSettingsPen;default:return this.gestureSettingsUnknown}},_drawOverlays:function(){var t=this.currentOverlays.length;for(let e=0;e<t;e++)this.currentOverlays[e].drawHTML(this.overlaysContainer,this.viewport)},_cancelPendingImages:function(){this._loadQueue=[]},removeReferenceStrip:function(){this.showReferenceStrip=!1;if(this.referenceStrip){this.referenceStrip.destroy();this.referenceStrip=null}},addReferenceStrip:function(){this.showReferenceStrip=!0;if(this.sequenceMode){if(!this.referenceStrip&&this.tileSources.length&&1<this.tileSources.length){this.referenceStrip=new m.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,viewer:this});this.referenceStrip.setFocus(this._sequenceIndex)}}else m.console.warn('Attempting to display a reference strip while "sequenceMode" is off.')},_addUpdatePixelDensityRatioEvent:function(){this._updatePixelDensityRatioBind=this._updatePixelDensityRatio.bind(this);m.addEvent(window,"resize",this._updatePixelDensityRatioBind)},_removeUpdatePixelDensityRatioEvent:function(){m.removeEvent(window,"resize",this._updatePixelDensityRatioBind)},_updatePixelDensityRatio:function(){var e=m.pixelDensityRatio;var t=m.getCurrentPixelDensityRatio();if(e!==t){m.pixelDensityRatio=t;this.forceResize()}},goToPreviousPage:function(){let e=this._sequenceIndex-1;this.navPrevNextWrap&&e<0&&(e+=this.tileSources.length);this.goToPage(e)},goToNextPage:function(){let e=this._sequenceIndex+1;this.navPrevNextWrap&&e>=this.tileSources.length&&(e=0);this.goToPage(e)},isAnimating:function(){return u[this.hash].animating},startZoomInAction:function(){u[this.hash].lastZoomTime=m.now();u[this.hash].zoomFactor=this.zoomPerSecond;u[this.hash].zooming=!0;o(this)},startZoomOutAction:function(){u[this.hash].lastZoomTime=m.now();u[this.hash].zoomFactor=1/this.zoomPerSecond;u[this.hash].zooming=!0;o(this)},endZoomAction:function(){u[this.hash].zooming=!1},singleZoomInAction:function(){if(this.viewport){u[this.hash].zooming=!1;this.viewport.zoomBy(+this.zoomPerClick);this.viewport.applyConstraints()}},singleZoomOutAction:function(){if(this.viewport){u[this.hash].zooming=!1;this.viewport.zoomBy(1/this.zoomPerClick);this.viewport.applyConstraints()}}});function l(e){e=m.getElement(e);return new m.Point(0===e.clientWidth?1:e.clientWidth,0===e.clientHeight?1:e.clientHeight)}function h(i,n){if(n instanceof m.Overlay)return n;let e=null;if(n.element)e=m.getElement(n.element);else{var t=n.id||"openseadragon-overlay-"+Math.floor(1e7*Math.random());e=m.getElement(n.id);if(!e){e=document.createElement("a");e.href="#/overlay/"+t}e.id=t;m.addClass(e,n.className||"openseadragon-overlay")}let r=n.location;let o=n.width;let s=n.height;if(!r){let e=n.x;let t=n.y;if(void 0!==n.px){i=i.viewport.imageToViewportRectangle(new m.Rect(n.px,n.py,o||0,s||0));e=i.x;t=i.y;o=void 0!==o?i.width:void 0;s=void 0!==s?i.height:void 0}r=new m.Point(e,t)}let a=n.placement;a&&"string"===m.type(a)&&(a=m.Placement[n.placement.toUpperCase()]);return new m.Overlay({element:e,location:r,placement:a,onDraw:n.onDraw,checkResize:n.checkResize,width:o,height:s,rotationMode:n.rotationMode})}function s(t,i){for(let e=t.length-1;0<=e;e--)if(t[e].element===i)return e;return-1}function c(e,t){return m.requestAnimationFrame(function(){t(e)})}function n(e){m.requestAnimationFrame(function(){!function(t){if(t.controlsShouldFade){var i=1-(m.now()-t.controlsFadeBeginTime)/t.controlsFadeLength;i=Math.min(1,i);i=Math.max(0,i);for(let e=t.controls.length-1;0<=e;e--)t.controls[e].autoFade&&t.controls[e].setOpacity(i);0<i&&n(t)}}(e)})}function d(e){if(e.autoHideControls){e.controlsShouldFade=!0;e.controlsFadeBeginTime=m.now()+e.controlsFadeDelay;window.setTimeout(function(){n(e)},e.controlsFadeDelay)}}function r(t){t.controlsShouldFade=!1;for(let e=t.controls.length-1;0<=e;e--)t.controls[e].setOpacity(1)}function f(){r(this)}function v(){d(this)}function p(e){var t={tracker:e.eventSource,position:e.position,originalEvent:e.originalEvent,preventDefault:e.preventDefault};this.raiseEvent("canvas-contextmenu",t);e.preventDefault=t.preventDefault}function i(e,t){switch(e){case"ArrowUp":case"KeyW":return t?"zoomIn":"panUp";case"ArrowDown":case"KeyS":return t?"zoomOut":"panDown";case"ArrowLeft":case"KeyA":return"panLeft";case"ArrowRight":case"KeyD":return"panRight";case"Equal":return"zoomIn";case"Minus":return"zoomOut";default:return null}}function g(e){var t=(e,t)=>{t=i(e,t);if(t&&this._activeActions[t]){this._activeActions[t]=!1;this._navActionFrames[t]<this._minNavActionFrames&&(this._navActionVirtuallyHeld[t]=!0)}};e=e.originalEvent.code;t(e,!0);t(e,!1)}function y(e){var t={originalEvent:e.originalEvent,preventDefaultAction:!this.keyboardNavEnabled,preventVerticalPan:e.preventVerticalPan||!this.panVertical,preventHorizontalPan:e.preventHorizontalPan||!this.panHorizontal};this.raiseEvent("canvas-key",t);if(t.preventDefaultAction||e.ctrl||e.alt||e.meta)e.preventDefault=!1;else{t=i(e.originalEvent.code,e.shift);if(!t||this._activeActions[t])switch(e.keyCode){case 48:this.viewport.goHome();this.viewport.applyConstraints();e.preventDefault=!0;break;case 82:e.shift?this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.flipped?this.viewport.setRotation(this.viewport.getRotation()-this.rotationIncrement):this.viewport.setRotation(this.viewport.getRotation()+this.rotationIncrement);this.viewport.applyConstraints();e.preventDefault=!0;break;case 70:this.viewport.toggleFlip();e.preventDefault=!0;break;case 74:this.goToPreviousPage();break;case 75:this.goToNextPage();break;default:e.preventDefault=!1}else{this._activeActions[t]=!0;this._navActionFrames[t]=0;e.preventDefault=!0}}}function w(e){e={originalEvent:e.originalEvent};this.raiseEvent("canvas-key-press",e)}function _(e){document.activeElement===this.canvas||this.canvas.focus();this.viewport.flipped&&(e.position.x=this.viewport.getContainerSize().x-e.position.x);var t={tracker:e.eventSource,position:e.position,quick:e.quick,shift:e.shift,originalEvent:e.originalEvent,originalTarget:e.originalTarget,preventDefaultAction:!1};this.raiseEvent("canvas-click",t);if(!t.preventDefaultAction&&this.viewport&&e.quick){if(!0===(t=this.gestureSettingsByDeviceType(e.pointerType)).clickToZoom){this.viewport.zoomBy(e.shift?1/this.zoomPerClick:this.zoomPerClick,t.zoomToRefPoint?this.viewport.pointFromPixel(e.position,!0):null);this.viewport.applyConstraints()}if(t.dblClickDragToZoom)if(!0===u[this.hash].draggingToZoom){u[this.hash].lastClickTime=null;u[this.hash].draggingToZoom=!1}else u[this.hash].lastClickTime=m.now()}}function T(e){var t;var i={tracker:e.eventSource,position:e.position,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-double-click",i);if(!i.preventDefaultAction&&this.viewport&&(t=this.gestureSettingsByDeviceType(e.pointerType)).dblClickToZoom){this.viewport.zoomBy(e.shift?1/this.zoomPerClick:this.zoomPerClick,t.zoomToRefPoint?this.viewport.pointFromPixel(e.position,!0):null);this.viewport.applyConstraints()}}function x(e){var t;var i={tracker:e.eventSource,pointerType:e.pointerType,position:e.position,delta:e.delta,speed:e.speed,direction:e.direction,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-drag",i);t=this.gestureSettingsByDeviceType(e.pointerType);if(!i.preventDefaultAction&&this.viewport)if(t.dblClickDragToZoom&&u[this.hash].draggingToZoom){var n=Math.pow(this.zoomPerDblClickDrag,e.delta.y/50);this.viewport.zoomBy(n)}else if(t.dragToPan&&!u[this.hash].draggingToZoom){this.panHorizontal||(e.delta.x=0);this.panVertical||(e.delta.y=0);this.viewport.flipped&&(e.delta.x=-e.delta.x);if(this.constrainDuringPan){i=this.viewport.deltaPointsFromPixels(e.delta.negate());this.viewport.centerSpringX.target.value+=i.x;this.viewport.centerSpringY.target.value+=i.y;n=this.viewport.getConstrainedBounds();this.viewport.centerSpringX.target.value-=i.x;this.viewport.centerSpringY.target.value-=i.y;n.xConstrained&&(e.delta.x=0);n.yConstrained&&(e.delta.y=0)}this.viewport.panBy(this.viewport.deltaPointsFromPixels(e.delta.negate()),t.flickEnabled&&!this.constrainDuringPan)}}function S(i){var n;var e={tracker:i.eventSource,pointerType:i.pointerType,position:i.position,speed:i.speed,direction:i.direction,shift:i.shift,originalEvent:i.originalEvent,preventDefaultAction:!1};this.raiseEvent("canvas-drag-end",e);n=this.gestureSettingsByDeviceType(i.pointerType);if(!e.preventDefaultAction&&this.viewport){if(!u[this.hash].draggingToZoom&&n.dragToPan&&n.flickEnabled&&i.speed>=n.flickMinSpeed){let e=0;this.panHorizontal&&(e=n.flickMomentum*i.speed*Math.cos(i.direction));let t=0;this.panVertical&&(t=n.flickMomentum*i.speed*Math.sin(i.direction));i=this.viewport.pixelFromPoint(this.viewport.getCenter(!0));i=this.viewport.pointFromPixel(new m.Point(i.x-e,i.y-t));this.viewport.panTo(i,!1)}this.viewport.applyConstraints()}n.dblClickDragToZoom&&!0===u[this.hash].draggingToZoom&&(u[this.hash].draggingToZoom=!1)}function E(e){this.raiseEvent("canvas-enter",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function C(e){this.raiseEvent("canvas-exit",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function b(e){this.raiseEvent("canvas-press",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,insideElementPressed:e.insideElementPressed,insideElementReleased:e.insideElementReleased,originalEvent:e.originalEvent});if(this.gestureSettingsByDeviceType(e.pointerType).dblClickDragToZoom){var t=u[this.hash].lastClickTime;e=m.now();if(null!==t){e-t<this.dblClickTimeThreshold&&(u[this.hash].draggingToZoom=!0);u[this.hash].lastClickTime=null}}}function P(e){this.raiseEvent("canvas-release",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,insideElementPressed:e.insideElementPressed,insideElementReleased:e.insideElementReleased,originalEvent:e.originalEvent})}function R(e){this.raiseEvent("canvas-nonprimary-press",{tracker:e.eventSource,position:e.position,pointerType:e.pointerType,button:e.button,buttons:e.buttons,originalEvent:e.originalEvent})}function D(e){this.raiseEvent("canvas-nonprimary-release",{tracker:e.eventSource,position:e.position,pointerType:e.pointerType,button:e.button,buttons:e.buttons,originalEvent:e.originalEvent})}function I(e){let t;let i;let n;var r={tracker:e.eventSource,pointerType:e.pointerType,gesturePoints:e.gesturePoints,lastCenter:e.lastCenter,center:e.center,lastDistance:e.lastDistance,distance:e.distance,shift:e.shift,originalEvent:e.originalEvent,preventDefaultPanAction:!1,preventDefaultZoomAction:!1,preventDefaultRotateAction:!1};this.raiseEvent("canvas-pinch",r);if(this.viewport){var o=this.gestureSettingsByDeviceType(e.pointerType);if(o.pinchToZoom&&(!r.preventDefaultPanAction||!r.preventDefaultZoomAction)){t=this.viewport.pointFromPixel(e.center,!0);if(o.zoomToRefPoint&&!r.preventDefaultPanAction){i=this.viewport.pointFromPixel(e.lastCenter,!0);n=i.minus(t);this.panHorizontal||(n.x=0);this.panVertical||(n.y=0);this.viewport.panBy(n,!0)}r.preventDefaultZoomAction||this.viewport.zoomBy(e.distance/e.lastDistance,t,!0);this.viewport.applyConstraints()}if(o.pinchRotate&&!r.preventDefaultRotateAction){o=Math.atan2(e.gesturePoints[0].currentPos.y-e.gesturePoints[1].currentPos.y,e.gesturePoints[0].currentPos.x-e.gesturePoints[1].currentPos.x);r=Math.atan2(e.gesturePoints[0].lastPos.y-e.gesturePoints[1].lastPos.y,e.gesturePoints[0].lastPos.x-e.gesturePoints[1].lastPos.x);t=this.viewport.pointFromPixel(e.center,!0);this.viewport.rotateTo(this.viewport.getRotation(!0)+(o-r)*(180/Math.PI),t,!0)}}}function A(e){this.raiseEvent("canvas-focus",{tracker:e.eventSource,originalEvent:e.originalEvent})}function F(e){for(const t in this._activeActions)this._activeActions[t]=!1;for(const i in this._navActionVirtuallyHeld)this._navActionVirtuallyHeld[i]=!1;this.raiseEvent("canvas-blur",{tracker:e.eventSource,originalEvent:e.originalEvent})}function L(e){var t;var i;var n=m.now();if(n-this._lastScrollTime>this.minScrollDeltaTime){this._lastScrollTime=n;t={tracker:e.eventSource,position:e.position,scroll:e.scroll,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1,preventDefault:!0};this.raiseEvent("canvas-scroll",t);if(!t.preventDefaultAction&&this.viewport){this.viewport.flipped&&(e.position.x=this.viewport.getContainerSize().x-e.position.x);if((i=this.gestureSettingsByDeviceType(e.pointerType)).scrollToZoom){n=Math.pow(this.zoomPerScroll,e.scroll);this.viewport.zoomBy(n,i.zoomToRefPoint?this.viewport.pointFromPixel(e.position,!0):null);this.viewport.applyConstraints()}}e.preventDefault=t.preventDefault}else e.preventDefault=!0}function O(e){u[this.hash].mouseInside=!0;r(this);this.raiseEvent("container-enter",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function k(e){if(e.pointers<1){u[this.hash].mouseInside=!1;u[this.hash].animating||d(this)}this.raiseEvent("container-exit",{tracker:e.eventSource,pointerType:e.pointerType,position:e.position,buttons:e.buttons,pointers:e.pointers,insideElementPressed:e.insideElementPressed,buttonDownAny:e.buttonDownAny,originalEvent:e.originalEvent})}function B(e){!function(i){!function(i){for(const e in i._activeActions)if(i._activeActions[e]||i._navActionVirtuallyHeld[e]){i._navActionFrames[e]++;i._navActionFrames[e]>=i._minNavActionFrames&&(i._navActionVirtuallyHeld[e]=!1)}function n(e){return i._activeActions[e]||i._navActionVirtuallyHeld[e]}var r=i.pixelsPerArrowPress/10;r=i.viewport.deltaPointsFromPixels(new OpenSeadragon.Point(r,r));if(n("zoomIn")){i.viewport.zoomBy(1.01,null,!0);i.viewport.applyConstraints()}else if(n("zoomOut")){i.viewport.zoomBy(.99,null,!0);i.viewport.applyConstraints()}else{let e=0;let t=0;if(!i.preventVerticalPan){n("panUp")&&(t-=r.y);n("panDown")&&(t+=r.y)}if(!i.preventHorizontalPan){n("panLeft")&&(e-=r.x);n("panRight")&&(e+=r.x)}if(0!==e||0!==t){i.viewport.panBy(new OpenSeadragon.Point(e,t),!0);i.viewport.applyConstraints()}}}(i);if(!i._opening&&u[i.hash]){let t=!1;if(i.autoResize||u[i.hash].forceResize){let e;if(i._autoResizePolling){e=l(i.container);var n=u[i.hash].prevContainerSize;e.equals(n)||(u[i.hash].needsResize=!0)}if(u[i.hash].needsResize){!function(e,t){const i=e.viewport;var n=i.getZoom();var r=i.getCenter();i.resize(t,e.preserveImageSizeOnResize);i.panTo(r,!0);let o;if(e.preserveImageSizeOnResize)o=u[e.hash].prevContainerSize.x/t.x;else{var s=new m.Point(0,0);r=new m.Point(u[e.hash].prevContainerSize.x,u[e.hash].prevContainerSize.y).distanceTo(s);s=new m.Point(t.x,t.y).distanceTo(s);o=s/r*u[e.hash].prevContainerSize.x/t.x}i.zoomTo(n*o,null,!0);u[e.hash].prevContainerSize=t;u[e.hash].forceRedraw=!0;u[e.hash].needsResize=!1;u[e.hash].forceResize=!1}(i,e||l(i.container));t=!0}}n=i.viewport.update()||t;let e=i.world.update(n)||n;n&&i.raiseEvent("viewport-change");i.referenceStrip&&(e=i.referenceStrip.update(i.viewport)||e);n=u[i.hash].animating;if(!n&&e){i.raiseEvent("animation-start");r(i)}n=n&&!e;n&&(u[i.hash].animating=!1);if(e||n||u[i.hash].forceRedraw||i.world.needsDraw()){!function(e){e.imageLoader.clear();e.world.draw();e.raiseEvent("update-viewport",{})}(i);i._drawOverlays();i.navigator&&i.navigator.update(i.viewport);u[i.hash].forceRedraw=!1;e&&i.raiseEvent("animation")}if(n){i.raiseEvent("animation-finish");u[i.hash].mouseInside||d(i)}u[i.hash].animating=e}}(e);e.isOpen()?e._updateRequestId=c(e,B):e._updateRequestId=!1}function M(e,t){return e?e+t:t}function o(e){m.requestAnimationFrame(m.delegate(e,t))}function t(){if(u[this.hash].zooming&&this.viewport){var e=m.now();var t=e-u[this.hash].lastZoomTime;t=Math.pow(u[this.hash].zoomFactor,t/1e3);this.viewport.zoomBy(t);this.viewport.applyConstraints();u[this.hash].lastZoomTime=e;o(this)}}function z(){if(this.buttonGroup){this.buttonGroup.emulateEnter();this.buttonGroup.emulateLeave()}}function H(){this.viewport&&this.viewport.goHome()}function N(){this.isFullPage()&&!m.isFullScreen()?this.setFullPage(!1):this.setFullScreen(!this.isFullPage());this.buttonGroup&&this.buttonGroup.emulateLeave();this.fullPageButton.element.focus();this.viewport&&this.viewport.applyConstraints()}function U(){if(this.viewport){let e=this.viewport.getRotation();this.viewport.flipped?e+=this.rotationIncrement:e-=this.rotationIncrement;this.viewport.setRotation(e)}}function W(){if(this.viewport){let e=this.viewport.getRotation();this.viewport.flipped?e-=this.rotationIncrement:e+=this.rotationIncrement;this.viewport.setRotation(e)}}function j(){this.viewport.toggleFlip()}function G(e){if("string"==typeof e)return e;const t=e&&e.prototype;return t&&t instanceof OpenSeadragon.DrawerBase&&m.isFunction(t.getType)?t.getType.call(e):void 0}function V(){var e=window.matchMedia("(pointer: coarse)").matches;return/iPad|iPhone|iPod|Mac/.test(navigator.userAgent)&&e?["canvas"]:["webgl","canvas"]}m.determineDrawer=function(e){"auto"===e&&(e=V()[0]);for(const i in OpenSeadragon){var t=OpenSeadragon[i];const n=t.prototype;if(n&&n instanceof OpenSeadragon.DrawerBase&&m.isFunction(n.getType)&&n.getType.call(t)===e)return t}return null}}(OpenSeadragon);!function(h){h.Navigator=function(i){const e=i.viewer;const n=this;var t;if(i.element||i.id){if(i.element){i.id&&h.console.warn("Given option.id for Navigator was ignored since option.element was provided and is being used instead.");i.element.id?i.id=i.element.id:i.id="navigator-"+h.now();this.element=i.element}else this.element=document.getElementById(i.id);i.controlOptions={anchor:h.ControlAnchor.NONE,attachToViewer:!1,autoFade:!1}}else{i.id="navigator-"+h.now();this.element=h.makeNeutralElement("div");i.controlOptions={anchor:h.ControlAnchor.TOP_RIGHT,attachToViewer:!0,autoFade:i.autoFade};if(i.position)if("BOTTOM_RIGHT"===i.position)i.controlOptions.anchor=h.ControlAnchor.BOTTOM_RIGHT;else if("BOTTOM_LEFT"===i.position)i.controlOptions.anchor=h.ControlAnchor.BOTTOM_LEFT;else if("TOP_RIGHT"===i.position)i.controlOptions.anchor=h.ControlAnchor.TOP_RIGHT;else if("TOP_LEFT"===i.position)i.controlOptions.anchor=h.ControlAnchor.TOP_LEFT;else if("ABSOLUTE"===i.position){i.controlOptions.anchor=h.ControlAnchor.ABSOLUTE;i.controlOptions.top=i.top;i.controlOptions.left=i.left;i.controlOptions.height=i.height;i.controlOptions.width=i.width}}this.element.id=i.id;this.element.className+=" navigator";(i=h.extend(!0,{sizeRatio:h.DEFAULT_SETTINGS.navigatorSizeRatio},i,{element:this.element,tabIndex:-1,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:i.animationTime,autoResize:!1,minZoomImageRatio:1,background:i.background,opacity:i.opacity,borderColor:i.borderColor,displayRegionColor:i.displayRegionColor})).minPixelRatio=this.minPixelRatio=e.minPixelRatio;h.setElementTouchActionNone(this.element);this.borderWidth=2;this.fudge=new h.Point(1,1);this.totalBorderWidths=new h.Point(2*this.borderWidth,2*this.borderWidth).minus(this.fudge);i.controlOptions.anchor!==h.ControlAnchor.NONE&&function(e,t){e.margin="0px";e.border=t+"px solid "+i.borderColor;e.padding="0px";e.background=i.background;e.opacity=i.opacity;e.overflow="hidden"}(this.element.style,this.borderWidth);this.displayRegion=h.makeNeutralElement("div");this.displayRegion.id=this.element.id+"-displayregion";this.displayRegion.className="displayregion";!function(e,t){e.position="relative";e.top="0px";e.left="0px";e.fontSize="0px";e.overflow="hidden";e.border=t+"px solid "+i.displayRegionColor;e.margin="0px";e.padding="0px";e.background="transparent";e.float="left";e.cssFloat="left";e.zIndex=999999999;e.cursor="default";e.boxSizing="content-box"}(this.displayRegion.style,this.borderWidth);h.setElementPointerEventsNone(this.displayRegion);h.setElementTouchActionNone(this.displayRegion);this.displayRegionContainer=h.makeNeutralElement("div");this.displayRegionContainer.id=this.element.id+"-displayregioncontainer";this.displayRegionContainer.className="displayregioncontainer";this.displayRegionContainer.style.width="100%";this.displayRegionContainer.style.height="100%";h.setElementPointerEventsNone(this.displayRegionContainer);h.setElementTouchActionNone(this.displayRegionContainer);e.addControl(this.element,i.controlOptions);this._resizeWithViewer=i.controlOptions.anchor!==h.ControlAnchor.ABSOLUTE&&i.controlOptions.anchor!==h.ControlAnchor.NONE;if(i.width&&i.height){this.setWidth(i.width);this.setHeight(i.height)}else if(this._resizeWithViewer){t=h.getElementSize(e.element);this.element.style.height=Math.round(t.y*i.sizeRatio)+"px";this.element.style.width=Math.round(t.x*i.sizeRatio)+"px";this.oldViewerSize=t;t=h.getElementSize(this.element);this.elementArea=t.x*t.y}this.oldContainerSize=new h.Point(0,0);h.Viewer.apply(this,[i]);this.displayRegionContainer.appendChild(this.displayRegion);this.element.getElementsByTagName("div")[0].appendChild(this.displayRegionContainer);function r(e,t){c(n.displayRegionContainer,e);c(n.displayRegion,-e);n.viewport.setRotation(e,t)}if(i.navigatorRotate){r(i.viewer.viewport?i.viewer.viewport.getRotation():i.viewer.degrees||0,!0);i.viewer.addHandler("rotate",function(e){r(e.degrees,e.immediately)})}this.innerTracker.destroy();this.innerTracker=new h.MouseTracker({userData:"Navigator.innerTracker",element:this.element,dragHandler:h.delegate(this,s),clickHandler:h.delegate(this,o),releaseHandler:h.delegate(this,a),scrollHandler:h.delegate(this,l),preProcessEventHandler:function(e){"wheel"===e.eventType&&(e.preventDefault=!0)}});this.outerTracker.userData="Navigator.outerTracker";h.setElementPointerEventsNone(this.canvas);h.setElementPointerEventsNone(this.container);this.addHandler("reset-size",function(){n.viewport&&n.viewport.goHome(!0)});e.world.addHandler("item-index-change",function(t){window.setTimeout(function(){var e=n.world.getItemAt(t.previousIndex);n.world.setItemIndex(e,t.newIndex)},1)});e.world.addHandler("remove-item",function(e){e=e.item;e=n._getMatchingItem(e);e&&n.world.removeItem(e)});this.update(e.viewport)};h.extend(h.Navigator.prototype,h.EventSource.prototype,h.Viewer.prototype,{updateSize:function(){if(this.viewport){const e=new h.Point(0===this.container.clientWidth?1:this.container.clientWidth,0===this.container.clientHeight?1:this.container.clientHeight);if(!e.equals(this.oldContainerSize)){this.viewport.resize(e,!0);this.viewport.goHome(!0);this.oldContainerSize=e;this.world.update();this.world.draw();this.update(this.viewer.viewport)}}},setWidth:function(e){this.width=e;this.element.style.width="number"==typeof e?e+"px":e;this._resizeWithViewer=!1;this.updateSize()},setHeight:function(e){this.height=e;this.element.style.height="number"==typeof e?e+"px":e;this._resizeWithViewer=!1;this.updateSize()},setFlip:function(e){this.viewport.setFlip(e);this.setDisplayTransform(this.viewer.viewport.getFlip()?"scale(-1,1)":"scale(1,1)");return this},setDisplayTransform:function(e){i(this.canvas,e);i(this.element,e)},update:function(e){let t;let i;let n;let r;let o;e=e||this.viewer.viewport;t=h.getElementSize(this.viewer.element);if(this._resizeWithViewer&&t.x&&t.y&&!t.equals(this.oldViewerSize)){this.oldViewerSize=t;if(this.maintainSizeRatio||!this.elementArea){i=t.x*this.sizeRatio;n=t.y*this.sizeRatio}else{i=Math.sqrt(this.elementArea*(t.x/t.y));n=this.elementArea/i}this.element.style.width=Math.round(i)+"px";this.element.style.height=Math.round(n)+"px";this.elementArea||(this.elementArea=i*n);this.updateSize()}if(e&&this.viewport){r=e.getBoundsNoRotate(!0);o=this.viewport.pixelFromPointNoRotate(r.getTopLeft(),!1);a=this.viewport.pixelFromPointNoRotate(r.getBottomRight(),!1).minus(this.totalBorderWidths);if(!this.navigatorRotate){var s=e.getRotation(!0);c(this.displayRegion,-s)}const l=this.displayRegion.style;l.display=this.world.getItemCount()?"block":"none";l.top=o.y.toFixed(2)+"px";l.left=o.x.toFixed(2)+"px";s=a.x-o.x;var a=a.y-o.y;l.width=Math.round(Math.max(s,0))+"px";l.height=Math.round(Math.max(a,0))+"px"}},addTiledImage:function(e){const n=this;const r=e.originalTiledImage;delete e.original;e=h.extend({},e,{success:function(e){const t=e.item;t._originalForNavigator=r;n._matchBounds(t,r,!0);n._matchOpacity(t,r);n._matchCompositeOperation(t,r);function i(){n._matchBounds(t,r)}r.addHandler("bounds-change",i);r.addHandler("clip-change",i);r.addHandler("opacity-change",function(){n._matchOpacity(t,r)});r.addHandler("composite-operation-change",function(){n._matchCompositeOperation(t,r)})}});return h.Viewer.prototype.addTiledImage.apply(this,[e])},destroy:function(){return h.Viewer.prototype.destroy.apply(this)},_getMatchingItem:function(t){var i=this.world.getItemCount();for(let e=0;e<i;e++){var n=this.world.getItemAt(e);if(n._originalForNavigator===t)return n}return null},_matchBounds:function(e,t,i){const n=t.getBoundsNoRotate();e.setPosition(n.getTopLeft(),i);e.setWidth(n.width,i);e.setRotation(t.getRotation(),i);e.setClip(t.getClip());e.setFlip(t.getFlip())},_matchOpacity:function(e,t){e.setOpacity(t.opacity)},_matchCompositeOperation:function(e,t){e.setCompositeOperation(t.compositeOperation)}});function o(e){var t={tracker:e.eventSource,position:e.position,quick:e.quick,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-click",t);if(!t.preventDefaultAction&&e.quick&&this.viewer.viewport&&(this.panVertical||this.panHorizontal)){this.viewer.viewport.flipped&&(e.position.x=this.viewport.getContainerSize().x-e.position.x);const i=this.viewport.pointFromPixel(e.position);this.panVertical?this.panHorizontal||(i.x=this.viewer.viewport.getCenter(!0).x):i.y=this.viewer.viewport.getCenter(!0).y;this.viewer.viewport.panTo(i);this.viewer.viewport.applyConstraints()}}function s(e){var t={tracker:e.eventSource,position:e.position,delta:e.delta,speed:e.speed,direction:e.direction,shift:e.shift,originalEvent:e.originalEvent,preventDefaultAction:!1};this.viewer.raiseEvent("navigator-drag",t);if(!t.preventDefaultAction&&this.viewer.viewport){this.panHorizontal||(e.delta.x=0);this.panVertical||(e.delta.y=0);this.viewer.viewport.flipped&&(e.delta.x=-e.delta.x);this.viewer.viewport.panBy(this.viewport.deltaPointsFromPixels(e.delta));this.viewer.constrainDuringPan&&this.viewer.viewport.applyConstraints()}}function a(e){e.insideElementPressed&&this.viewer.viewport&&this.viewer.viewport.applyConstraints()}function l(e){var t={tracker:e.eventSource,position:e.position,scroll:e.scroll,shift:e.shift,originalEvent:e.originalEvent,preventDefault:e.preventDefault};this.viewer.raiseEvent("navigator-scroll",t);e.preventDefault=t.preventDefault}function c(e,t){i(e,"rotate("+t+"deg)")}function i(e,t){e.style.webkitTransform=t;e.style.mozTransform=t;e.style.msTransform=t;e.style.oTransform=t;e.style.transform=t}}(OpenSeadragon);!function(s){const a={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"}};s.extend(s,{getString:function(e){var t=e.split(".");let i=null;const n=arguments;let r=a;let o;for(o=0;o<t.length-1;o++)r=r[t[o]]||{};i=r[t[o]];if("string"!=typeof i){s.console.error("Untranslated source string:",e);i=""}return i.replace(/\{\d+\}/g,function(e){e=parseInt(e.match(/\d+/),10)+1;return e<n.length?n[e]:""})},setString:function(e,t){var i=e.split(".");let n=a;let r;for(r=0;r<i.length-1;r++){n[i[r]]||(n[i[r]]={});n=n[i[r]]}n[i[r]]=t}})}(OpenSeadragon);!function(o){o.Point=function(e,t){this.x="number"==typeof e?e:0;this.y="number"==typeof t?t:0};o.Point.prototype={clone:function(){return new o.Point(this.x,this.y)},plus:function(e){return new o.Point(this.x+e.x,this.y+e.y)},minus:function(e){return new o.Point(this.x-e.x,this.y-e.y)},times:function(e){return new o.Point(this.x*e,this.y*e)},divide:function(e){return new o.Point(this.x/e,this.y/e)},negate:function(){return new o.Point(-this.x,-this.y)},distanceTo:function(e){return Math.sqrt(Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2))},squaredDistanceTo:function(e){return Math.pow(this.x-e.x,2)+Math.pow(this.y-e.y,2)},apply:function(e){return new o.Point(e(this.x),e(this.y))},equals:function(e){return e instanceof o.Point&&this.x===e.x&&this.y===e.y},rotate:function(e,t){t=t||new o.Point(0,0);let i;let n;if(e%90==0)switch(o.positiveModulo(e,360)){case 0:i=1;n=0;break;case 90:i=0;n=1;break;case 180:i=-1;n=0;break;case 270:i=0;n=-1}else{var r=e*Math.PI/180;i=Math.cos(r);n=Math.sin(r)}r=i*(this.x-t.x)-n*(this.y-t.y)+t.x;t=n*(this.x-t.x)+i*(this.y-t.y)+t.y;return new o.Point(r,t)},toString:function(){return"("+Math.round(100*this.x)/100+","+Math.round(100*this.y)/100+")"}}}(OpenSeadragon);!function(c){c.TileSource=function(e){c.EventSource.apply(this);this.url=null;this.addHandler("ready",e=>{const t=e.tileSource;this.ready=!0;this.aspectRatio=t.width&&t.height?t.width/t.height:1;this.dimensions=new c.Point(t.width,t.height);if(t.tileSize){this._tileWidth=this._tileHeight=t.tileSize;delete this.tileSize}else{if(t.tileWidth){this._tileWidth=t.tileWidth;delete this.tileWidth}else this._tileWidth=0;if(t.tileHeight){this._tileHeight=t.tileHeight;delete this.tileHeight}else this._tileHeight=0}this.tileOverlap=t.tileOverlap||0;this.minLevel=t.minLevel||0;this.maxLevel=void 0!==t.maxLevel&&null!==t.maxLevel?t.maxLevel:t.width&&t.height?Math.ceil(Math.log(Math.max(t.width,t.height))/Math.log(2)):0;t.success&&c.isFunction(t.success)&&t.success(this)},null,1/0);if("string"===c.type(e)){this.url=e;e=void 0}else c.extend(!0,this,e);if(this.url&&!this.ready){this.aspectRatio=1;this.dimensions=new c.Point(10,10);this._tileWidth=0;this._tileHeight=0;this.tileOverlap=0;this.minLevel=0;this.maxLevel=0;this.ready=!1;this._uniqueIdentifier=this.url;setTimeout(()=>this.getImageInfo(this.url))}else{this._uniqueIdentifier=Math.floor(1e10*Math.random()).toString(36);this.ready||void 0===this.ready?this.raiseEvent("ready",{tileSource:this}):setTimeout(()=>this.raiseEvent("ready",{tileSource:this}))}return this};c.TileSource.prototype={getTileSize:function(e){c.console.error("[TileSource.getTileSize] is deprecated. Use TileSource.getTileWidth() and TileSource.getTileHeight() instead");return this._tileWidth},getTileWidth:function(e){return this._tileWidth||this.getTileSize(e)},getTileHeight:function(e){return this._tileHeight||this.getTileSize(e)},setMaxLevel:function(e){this.maxLevel=e;this._memoizeLevelScale()},getLevelScale:function(e){this._memoizeLevelScale();return this.getLevelScale(e)},_memoizeLevelScale:function(){const t={};let e;for(e=0;e<=this.maxLevel;e++)t[e]=1/Math.pow(2,this.maxLevel-e);this.getLevelScale=function(e){return t[e]}},getNumTiles:function(e){var t=this.getLevelScale(e);var i=Math.ceil(t*this.dimensions.x/this.getTileWidth(e));e=Math.ceil(t*this.dimensions.y/this.getTileHeight(e));return new c.Point(i,e)},getPixelRatio:function(e){var t=this.dimensions.times(this.getLevelScale(e));e=1/t.x*c.pixelDensityRatio;t=1/t.y*c.pixelDensityRatio;return new c.Point(e,t)},getClosestLevel:function(){let e;var t;for(e=this.minLevel+1;e<=this.maxLevel&&!(1<(t=this.getNumTiles(e)).x||1<t.y);e++);return e-1},getTileAtPoint:function(e,t){var i=0<=t.x&&t.x<=1&&0<=t.y&&t.y<=1/this.aspectRatio;c.console.assert(i,"[TileSource.getTileAtPoint] must be called with a valid point.");var n=this.dimensions.x*this.getLevelScale(e);i=t.x*n;n=t.y*n;let r=Math.floor(i/this.getTileWidth(e));let o=Math.floor(n/this.getTileHeight(e));1<=t.x&&(r=this.getNumTiles(e).x-1);t.y>=1/this.aspectRatio-1e-15&&(o=this.getNumTiles(e).y-1);return new c.Point(r,o)},getTileBounds:function(e,t,i,n){var r=this.dimensions.times(this.getLevelScale(e));var o=this.getTileWidth(e);var s=this.getTileHeight(e);var a=0===t?0:o*t-this.tileOverlap;e=0===i?0:s*i-this.tileOverlap;t=o+(0===t?1:2)*this.tileOverlap;s+=(0===i?1:2)*this.tileOverlap;i=1/r.x;t=Math.min(t,r.x-a);s=Math.min(s,r.y-e);return n?new c.Rect(0,0,t,s):new c.Rect(a*i,e*i,t*i,s*i)},getImageInfo:function(r){const o=this;let t;let i;let n;let e;let s;var a;if(r){e=r.split("/");s=e[e.length-1];-1<(a=s.lastIndexOf("."))&&(e[e.length-1]=s.slice(0,a))}let l=null;if(this.splitHashDataForPost){var h=r.indexOf("#");if(-1!==h){l=r.substring(h+1);r=r.substr(0,h)}}t=function(e){"string"==typeof e&&(e=c.parseXml(e));const t=c.TileSource.determineType(o,e,r);if(t){n=t.prototype.configure.apply(o,[e,r,l]);void 0===n.ajaxWithCredentials&&(n.ajaxWithCredentials=o.ajaxWithCredentials);n.ready=!0;i=new t(n);o.ready=!0;o.raiseEvent("ready",{tileSource:i})}else o.raiseEvent("open-failed",{message:"Unable to load TileSource",source:r})};if(r.match(/\.js$/)){h=r.split("/").pop().replace(".js","");c.jsonp({url:r,async:!1,callbackName:h,callback:t})}else c.makeAjaxRequest({url:r,postData:l,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(e){e=function(t){const i=t.responseText;var e=t.status;var n;let r;{if(!t)throw new Error(c.getString("Errors.Security"));if(200!==t.status&&0!==t.status){e=t.status;n=404===e?"Not Found":t.statusText;throw new Error(c.getString("Errors.Status",e,n))}}if(i.match(/^\s*<.*/))try{r=t.responseXML&&t.responseXML.documentElement?t.responseXML:c.parseXml(i)}catch(e){r=t.responseText}else if(i.match(/\s*[{[].*/))try{r=c.parseJSON(i)}catch(e){r=i}else r=i;return r}(e);t(e)},error:function(e,i){let n;try{n="HTTP "+e.status+" attempting to load TileSource: "+r}catch(e){let t;t=void 0!==i&&i.toString?i.toString():"Unknown error";n=t+" attempting to load TileSource: "+r}c.console.error(n);o.raiseEvent("open-failed",{message:n,source:r,postData:l})}})},supports:function(e,t){return!1},equals:function(e){return this===e},batchEnabled(){return!1},batchCompatible(e){return!1},batchMaxJobs(){return-1},batchTimeout(){return 5},configure:function(e,t,i){throw new Error("Method not implemented.")},destroy:function(e){},getTileUrl:function(e,t,i){throw new Error("Method not implemented.")},getTilePostData:function(e,t,i){return null},getTileAjaxHeaders:function(e,t,i){return{}},getTileHashKey:function(e,t,i,n,r,o){function s(e){return r?e+"+"+JSON.stringify(r):e}return s("string"!=typeof n?this._uniqueIdentifier+":"+e+"/"+t+"_"+i:n)},tileExists:function(e,t,i){var n=this.getNumTiles(e);return e>=this.minLevel&&e<=this.maxLevel&&0<=t&&0<=i&&t<n.x&&i<n.y},hasTransparency:function(e,t,i,n){return t.match(".png")},downloadTileStart:function(o){if(o.loadWithAjax)o.userData.request=c.makeAjaxRequest({url:o.src,withCredentials:o.ajaxWithCredentials,headers:o.ajaxHeaders,responseType:"arraybuffer",postData:o.postData,success:function(t){let i;try{i=new window.Blob([t.response])}catch(e){const n=window.BlobBuilder||window.WebKitBlobBuilder||window.MozBlobBuilder||window.MSBlobBuilder;if("TypeError"===e.name&&n){const r=new n;r.append(t.response);i=r.getBlob()}}0===i.size?o.fail("[downloadTileStart] Empty image response.",t):o.finish(i,t,"rasterBlob")},error:function(e){o.fail("[downloadTileStart] Image load aborted - XHR error",e)}});else{const e=new Image;o.userData.imageRequest=e;e.onload=function(){e.onload=e.onerror=e.onabort=null;o.finish(e,null,"image")};e.onabort=e.onerror=function(){e.onload=e.onerror=e.onabort=null;o.fail("[downloadTileStart] Image load aborted or errored out.",null)};"string"==typeof o.crossOriginPolicy&&(e.crossOrigin=o.crossOriginPolicy);e.src=o.src}},downloadTileAbort:function(e){e.userData.request&&e.userData.request.abort();if(e.userData.imageRequest){const t=e.userData.imageRequest;t.onload=t.onerror=t.onabort=null;t.src=""}},downloadTileBatchStart(t){for(let e=0;e<t.jobs.length;e++)this.downloadTileStart(t.jobs[e])},downloadTileBatchAbort(t){for(let e=0;e<t.jobs.length;e++)this.downloadTileAbort(t.jobs[e])},createTileCache:function(e,t,i){c.console.error("[TileSource.createTileCache] has been deprecated. Use cache API of a tile instead.")},destroyTileCache:function(e){c.console.error("[TileSource.destroyTileCache] has been deprecated. Use cache API of a tile instead.")},getTileCacheData:function(e){c.console.error("[TileSource.getTileCacheData] has been deprecated. Use cache API of a tile instead.");return e.getDataAs(void 0,!1)},getTileCacheDataAsImage:function(e){c.console.error("[TileSource.getTileCacheDataAsImage] has been deprecated. Use cache API of a tile instead.");return e.getImage()},getTileCacheDataAsContext2D:function(e){c.console.error("[TileSource.getTileCacheDataAsContext2D] has been deprecated. Use cache API of a tile instead.");return e.getRenderedContext()}};c.extend(!0,c.TileSource.prototype,c.EventSource.prototype);c.TileSource.determineType=function(e,t,i){for(const n in OpenSeadragon)if(n.match(/.+TileSource$/)&&c.isFunction(OpenSeadragon[n])&&c.isFunction(OpenSeadragon[n].prototype.supports)&&OpenSeadragon[n].prototype.supports.call(e,t,i))return OpenSeadragon[n];c.console.error("No TileSource was able to open %s %s",i,t);return null}}(OpenSeadragon);!function(d){d.DziTileSource=function(e,t,i,n,r,o,s,a,l){let h;let c;c=d.isPlainObject(e)?e:{width:e,height:t,tileSize:i,tileOverlap:n,tilesUrl:r,fileFormat:o,displayRects:s,minLevel:a,maxLevel:l};this._levelRects={};this.tilesUrl=c.tilesUrl;this.fileFormat=c.fileFormat;this.displayRects=c.displayRects;this.queryParams=c.queryParams||"";if(this.displayRects)for(let e=this.displayRects.length-1;0<=e;e--){var u=this.displayRects[e];for(h=u.minLevel;h<=u.maxLevel;h++){this._levelRects[h]||(this._levelRects[h]=[]);this._levelRects[h].push(u)}}d.TileSource.apply(this,[c])};d.extend(d.DziTileSource.prototype,d.TileSource.prototype,{supports:function(e,t){let i;e.Image?i=e.Image.xmlns:e.documentElement&&("Image"!==e.documentElement.localName&&"Image"!==e.documentElement.tagName||(i=e.documentElement.namespaceURI));i=(i||"").toLowerCase();return-1!==i.indexOf("schemas.microsoft.com/deepzoom/2008")||-1!==i.indexOf("schemas.microsoft.com/deepzoom/2009")},configure:function(e,t,i){let n;n=(d.isPlainObject(e)?p:function(e,t){if(!t||!t.documentElement)throw new Error(d.getString("Errors.Xml"));const i=t.documentElement;var n=i.localName||i.tagName;var r=t.documentElement.namespaceURI;let o=null;const s=[];let a;let l;let h;let c;let u;if("Image"===n)try{c=i.getElementsByTagName("Size")[0];void 0===c&&(c=i.getElementsByTagNameNS(r,"Size")[0]);o={Image:{xmlns:"http://schemas.microsoft.com/deepzoom/2008",Url:i.getAttribute("Url"),Format:i.getAttribute("Format"),DisplayRect:null,Overlap:parseInt(i.getAttribute("Overlap"),10),TileSize:parseInt(i.getAttribute("TileSize"),10),Size:{Height:parseInt(c.getAttribute("Height"),10),Width:parseInt(c.getAttribute("Width"),10)}}};if(!d.imageFormatSupported(o.Image.Format))throw new Error(d.getString("Errors.ImageFormat",o.Image.Format.toUpperCase()));a=i.getElementsByTagName("DisplayRect");void 0===a&&(a=i.getElementsByTagNameNS(r,"DisplayRect")[0]);for(u=0;u<a.length;u++){l=a[u];h=l.getElementsByTagName("Rect")[0];void 0===h&&(h=l.getElementsByTagNameNS(r,"Rect")[0]);s.push({Rect:{X:parseInt(h.getAttribute("X"),10),Y:parseInt(h.getAttribute("Y"),10),Width:parseInt(h.getAttribute("Width"),10),Height:parseInt(h.getAttribute("Height"),10),MinLevel:parseInt(l.getAttribute("MinLevel"),10),MaxLevel:parseInt(l.getAttribute("MaxLevel"),10)}})}s.length&&(o.Image.DisplayRect=s);return p(0,o)}catch(e){throw e instanceof Error?e:new Error(d.getString("Errors.Dzi"))}else{if("Collection"===n)throw new Error(d.getString("Errors.Dzc"));if("Error"===n){n=i.getElementsByTagName("Message")[0].firstChild.nodeValue;throw new Error(n)}}throw new Error(d.getString("Errors.Dzi"))})(this,e);if(t&&!n.tilesUrl){n.tilesUrl=t.replace(/([^/]+?)(\.(dzi|xml|js)?(\?[^/]*)?)?\/?$/,"$1_files/");-1!==t.search(/\.(dzi|xml|js)\?/)?n.queryParams=t.match(/\?.*/):n.queryParams=""}return n},getTileUrl:function(e,t,i){return[this.tilesUrl,e,"/",t,"_",i,".",this.fileFormat,this.queryParams].join("")},equals:function(e){return e&&this.tilesUrl===e.tilesUrl},tileExists:function(t,i,n){var r=this._levelRects[t];var o;var s;var a;var l;if(this.minLevel&&t<this.minLevel||this.maxLevel&&t>this.maxLevel)return!1;if(!r||!r.length)return!0;for(let e=r.length-1;0<=e;e--){var h=r[e];if(!(t<h.minLevel||t>h.maxLevel)){l=this.getLevelScale(t);o=h.x*l;s=h.y*l;a=o+h.width*l;l=s+h.height*l;o=Math.floor(o/this._tileWidth);s=Math.floor(s/this._tileWidth);a=Math.ceil(a/this._tileWidth);l=Math.ceil(l/this._tileWidth);if(o<=i&&i<a&&s<=n&&n<l)return!0}}return!1}});function p(e,t){var i=t.Image;var n=i.Url;var r=i.Format;var o=i.Size;var s=i.DisplayRect||[];var a=parseInt(o.Width,10);var l=parseInt(o.Height,10);o=parseInt(i.TileSize,10);i=parseInt(i.Overlap,10);const h=[];var c;for(let e=0;e<s.length;e++){c=s[e].Rect;h.push(new d.DisplayRect(parseInt(c.X,10),parseInt(c.Y,10),parseInt(c.Width,10),parseInt(c.Height,10),parseInt(c.MinLevel,10),parseInt(c.MaxLevel,10)))}return d.extend(!0,{width:a,height:l,tileSize:o,tileOverlap:i,minLevel:null,maxLevel:null,tilesUrl:n,fileFormat:r,displayRects:h},t)}}(OpenSeadragon);!function(l){l.IIIFTileSource=function(n){l.extend(!0,this,n);this._id=this["@id"]||this.id||this.identifier||null;if(!(this.height&&this.width&&this._id))throw new Error("IIIF required parameters (width, height, or id) not provided.");n.tileSizePerScaleFactor={};this.tileFormat=this.tileFormat||"jpg";this.version=n.version;this.isLevel0=h(n);if(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(1===this.tiles.length){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(let t=0;t<this.tiles.length;t++)for(let e=0;e<this.tiles[t].scaleFactors.length;e++){var i=this.tiles[t].scaleFactors[e];this.scale_factors.push(i);n.tileSizePerScaleFactor[i]={width:this.tiles[t].width,height:this.tiles[t].height||this.tiles[t].width}}}else if(c(n)){var t=Math.min(this.height,this.width);var r=[256,512,1024];const s=[];for(let e=0;e<r.length;e++)r[e]<=t&&s.push(r[e]);0<s.length?n.tileSize=Math.max.apply(null,s):n.tileSize=t}else if(this.sizes&&0<this.sizes.length){this.emulateLegacyImagePyramid=!0;n.levels=u(this);l.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}else l.console.error("Nothing in the info.json to construct image pyramids from");if(!n.maxLevel&&!this.emulateLegacyImagePyramid)if(this.scale_factors){var e=Math.max.apply(null,this.scale_factors);n.maxLevel=Math.round(Math.log(e)*Math.LOG2E)}else n.maxLevel=Number(Math.round(Math.log(Math.max(this.width,this.height),2)));if(this.sizes){let i=this.sizes.length;const a=this.sizes.slice().sort((e,t)=>e.width-t.width);if(a[i-1].width<this.width&&a[i-1].height<this.height){a.push({width:this.width,height:this.height});i++}if(i===n.maxLevel+1){let t=1;if(this.scale_factors&&this.scale_factors.length===i)for(let e=0;e<i;e++){var o=this.scale_factors[i-e-1];if(Math.round(this.width/a[e].width)!==o||Math.round(this.height/a[e].height)!==o){t=0;break}}1===t&&(this.levelSizes=a)}}l.TileSource.apply(this,[n])};l.extend(l.IIIFTileSource.prototype,l.TileSource.prototype,{supports:function(e,t){return!(!e.protocol||"http://iiif.io/api/image"!==e.protocol)||(!(!e["@context"]||"http://library.stanford.edu/iiif/image-api/1.1/context.json"!==e["@context"]&&"http://iiif.io/api/image/1/context.json"!==e["@context"])||(!(!e.profile||0!==e.profile.indexOf("http://library.stanford.edu/iiif/image-api/compliance.html"))||(!!(e.identifier&&e.width&&e.height)||!(!e.documentElement||"info"!==e.documentElement.tagName||"http://library.stanford.edu/iiif/image-api/ns/"!==e.documentElement.namespaceURI))))},configure:function(i,e,t){if(l.isPlainObject(i)){if(i["@context"]){let t=i["@context"];if(Array.isArray(t))for(let e=0;e<t.length;e++)if("string"==typeof t[e]&&(/^http:\/\/iiif\.io\/api\/image\/[1-3]\/context\.json$/.test(t[e])||"http://library.stanford.edu/iiif/image-api/1.1/context.json"===t[e])){t=t[e];break}switch(t){case"http://iiif.io/api/image/1/context.json":case"http://library.stanford.edu/iiif/image-api/1.1/context.json":i.version=1;break;case"http://iiif.io/api/image/2/context.json":i.version=2;break;case"http://iiif.io/api/image/3/context.json":i.version=3;break;default:l.console.error("Data has a @context property which contains no known IIIF context URI.")}}else{i["@context"]="http://iiif.io/api/image/1.0/context.json";i["@id"]=e.replace("/info.json","");i.version=1}if(i.preferredFormats)for(let e=0;e<i.preferredFormats.length;e++)if(l.imageFormatSupported(i.preferredFormats[e])){i.tileFormat=i.preferredFormats[e];break}return i}{const n=function(e){if(!e||!e.documentElement)throw new Error(l.getString("Errors.Xml"));var t=e.documentElement;var i=t.tagName;e=null;if("info"===i)try{!function t(i,n,r){if(3===i.nodeType&&r){let e=i.nodeValue.trim();e.match(/^\d*$/)&&(e=Number(e));if(n[r]){l.isArray(n[r])||(n[r]=[n[r]]);n[r].push(e)}else n[r]=e}else if(1===i.nodeType)for(let e=0;e<i.childNodes.length;e++)t(i.childNodes[e],n,i.nodeName)}(t,e={});return e}catch(e){throw e instanceof Error?e:new Error(l.getString("Errors.IIIF"))}throw new Error(l.getString("Errors.IIIF"))}(i);n["@context"]="http://iiif.io/api/image/1.0/context.json";n["@id"]=e.replace("/info.xml","");n.version=1;return n}},getTileWidth:function(e){if(this.emulateLegacyImagePyramid)return l.TileSource.prototype.getTileWidth.call(this,e);e=Math.pow(2,this.maxLevel-e);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[e]?this.tileSizePerScaleFactor[e].width:this._tileWidth},getTileHeight:function(e){if(this.emulateLegacyImagePyramid)return l.TileSource.prototype.getTileHeight.call(this,e);e=Math.pow(2,this.maxLevel-e);return this.tileSizePerScaleFactor&&this.tileSizePerScaleFactor[e]?this.tileSizePerScaleFactor[e].height:this._tileHeight},getLevelScale:function(t){if(this.emulateLegacyImagePyramid){let e=NaN;0<this.levels.length&&t>=this.minLevel&&t<=this.maxLevel&&(e=this.levels[t].width/this.levels[this.maxLevel].width);return e}return l.TileSource.prototype.getLevelScale.call(this,t)},getNumTiles:function(e){if(this.emulateLegacyImagePyramid)return this.getLevelScale(e)?new l.Point(1,1):new l.Point(0,0);if(this.levelSizes){var t=this.levelSizes[e];var i=Math.ceil(t.width/this.getTileWidth(e));t=Math.ceil(t.height/this.getTileHeight(e));return new l.Point(i,t)}return l.TileSource.prototype.getNumTiles.call(this,e)},getTileAtPoint:function(i,n){if(this.emulateLegacyImagePyramid)return new l.Point(0,0);if(this.levelSizes){var r=0<=n.x&&n.x<=1&&0<=n.y&&n.y<=1/this.aspectRatio;l.console.assert(r,"[TileSource.getTileAtPoint] must be called with a valid point.");var o=this.levelSizes[i].width;r=n.x*o;o=n.y*o;let e=Math.floor(r/this.getTileWidth(i));let t=Math.floor(o/this.getTileHeight(i));1<=n.x&&(e=this.getNumTiles(i).x-1);n.y>=1/this.aspectRatio-1e-15&&(t=this.getNumTiles(i).y-1);return new l.Point(e,t)}return l.TileSource.prototype.getTileAtPoint.call(this,i,n)},getTileUrl:function(t,e,i){if(this.emulateLegacyImagePyramid){let e=null;0<this.levels.length&&t>=this.minLevel&&t<=this.maxLevel&&(e=this.levels[t].url);return e}var n=Math.pow(.5,this.maxLevel-t);let r;let o;let s;let a;let l;let h;let c;let u;var d;var p;let g;if(this.levelSizes){r=this.levelSizes[t].width;o=this.levelSizes[t].height}else{r=Math.ceil(this.width*n);o=Math.ceil(this.height*n)}d=this.getTileWidth(t);p=this.getTileHeight(t);t=Math.round(d/n);n=Math.round(p/n);g=1===this.version?"native."+this.tileFormat:"default."+this.tileFormat;if(r<d&&o<p){u=2===this.version&&r===this.width?"full":3===this.version&&r===this.width&&o===this.height?"max":3===this.version?r+","+o:r+",";s="full"}else{a=e*t;l=i*n;h=Math.min(t,this.width-a);c=Math.min(n,this.height-l);s=0===e&&0===i&&h===this.width&&c===this.height?"full":[a,l,h,c].join(",");d=Math.min(d,r-e*d);p=Math.min(p,o-i*p);u=2===this.version&&d===this.width?"full":3===this.version&&d===this.width&&p===this.height?"max":this.isLevel0&&this.version<3?d+",":d+","+p}return[this._id,s,u,"0",g].join("/")},equals:function(e){return e&&this._id===e._id},__testonly__:{canBeTiled:c,constructLevels:u}});function h(e){e=Array.isArray(e.profile)?e.profile[0]:e.profile;return-1!==["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"].indexOf(e)}function c(e){var t=h(e);let i=!1;2===e.version&&1<e.profile.length&&e.profile[1].supports&&(i=-1!==e.profile[1].supports.indexOf("sizeByW"));3===e.version&&e.extraFeatures&&(i=-1!==e.extraFeatures.indexOf("sizeByWh"));return!t||i}function u(t){const i=[];for(let e=0;e<t.sizes.length;e++)i.push({url:t._id+"/full/"+t.sizes[e].width+","+(3===t.version?t.sizes[e].height:"")+"/0/default."+t.tileFormat,width:t.sizes[e].width,height:t.sizes[e].height});return i.sort(function(e,t){return e.width-t.width})}}(OpenSeadragon);!function(a){a.IIPTileSource=function(e){a.EventSource.call(this);if(e&&e.iipsrv&&e.image){a.extend(this,e);this.aspectRatio=1;this.dimensions=new a.Point(10,10);this._tileWidth=0;this._tileHeight=0;this.tileOverlap=0;this.minLevel=0;this.maxLevel=0;this.ready=!1;e=this.getMetadataUrl();this.getImageInfo(e)}};a.extend(a.IIPTileSource.prototype,a.TileSource.prototype,{getMetadataUrl:function(){return this.iipsrv+"?FIF="+this.image+"&obj=IIP,1.0&obj=Max-size&obj=Tile-size&obj=Resolution-number&obj=Resolutions"},supports:function(e,t){return e&&"iipsrv"in e&&"image"in e},parseIIP:function(e){let t=e.split("Max-size:");if(!t[1])throw new Error("No Max-size returned");let i=t[1].split(" ");this.width=parseInt(i[0],10);this.height=parseInt(i[1],10);this.dimensions=new a.Point(this.width,this.height);this.aspectRatio=this.width/this.height;t=e.split("Tile-size:");if(!t[1])throw new Error("No Tile-size returned");i=t[1].split(" ");this._tileWidth=parseInt(i[0],10);this._tileHeight=parseInt(i[1],10);t=e.split("Resolution-number:");var n=parseInt(t[1],10);this.minLevel=0;this.maxLevel=n-1;this.tileOverlap=0;t=e.split("Resolutions:");i=t[1].split(",");var r=i.length;this.levelSizes=new Array(r);for(let e=0;e<r;e++){var o=i[e].split(" ");var s=parseInt(o[0],10);o=parseInt(o[1],10);this.levelSizes[e]={width:s,height:o}}},getImageInfo:function(n){const r=this;a.makeAjaxRequest({url:n,type:"GET",async:!1,withCredentials:this.ajaxWithCredentials,headers:this.ajaxHeaders,success:function(t){try{OpenSeadragon.IIPTileSource.prototype.parseIIP.call(r,t.responseText);r.ready=!0;r.raiseEvent("ready",{tileSource:r})}catch(e){t="IIPTileSource: Error parsing IIP metadata: "+e.message;r.raiseEvent("open-failed",{message:t,source:n})}},error:function(e,t){var i="IIPTileSource: Unable to get IIP metadata from "+n;a.console.error(i);r.raiseEvent("open-failed",{message:i,source:n})}})},configure:function(e,t,i){return e},getNumTiles:function(e){var t=this.levelSizes[e];e=Math.ceil(t.width/this._tileWidth);t=Math.ceil(t.height/this._tileHeight);return new a.Point(e,t)},getTileUrl:function(e,t,i){var n=this.levelSizes[e];n=Math.ceil(n.width/this._tileWidth);let r=this.iipsrv+"?FIF="+this.image+"&";if(this.transform){this.transform.stack&&(r+="SDS="+this.transform.stack+"&");this.transform.contrast&&(r+="CNT="+this.transform.contrast+"&");this.transform.gamma&&(r+="GAM="+this.transform.gamma+"&");this.transform.invert&&!0===this.transform.invert&&(r+="INV&");this.transform.color&&(r+="COL="+this.transform.color+"&");this.transform.twist&&(r+="CTW="+this.transform.twist+"&");this.transform.convolution&&(r+="CNV="+this.transform.convolution+"&");this.transform.quality&&(r+="QLT="+this.transform.quality+"&");this.transform.colormap&&(r+="CMP="+this.transform.colormap+"&");this.transform.minmax&&(r+="MINMAX="+this.transform.minmax+"&");this.transform.hillshade&&(r+="SHD="+this.transform.hillshade+"&")}let o="JTL";"png"===this.format?o="PTL":"webp"===this.format?o="WTL":"avif"===this.format&&(o="ATL");return r+o+"="+e+","+(i*n+t)}});a.extend(!0,a.IIPTileSource.prototype,a.EventSource.prototype)}(OpenSeadragon);!function(o){o.IrisTileSource=function(e){o.TileSource.apply(this,[e]);if(!e.serverUrl||!e.slideId)throw new Error("IrisTileSource requires serverUrl and slideId");this.serverUrl=e.serverUrl;this.slideId=e.slideId;this.ready=!1;if(e.metadata){this.parseMetadata(e.metadata);this.ready=!0;this.raiseEvent("ready",{tileSource:this})}else{e=this.getMetadataUrl();this.getImageInfo(e)}};o.extend(o.IrisTileSource.prototype,o.TileSource.prototype,{getMetadataUrl:function(){return this.serverUrl+"/slides/"+this.slideId+"/metadata"},supports:function(e){return e&&"iris"===e.type&&e.serverUrl&&e.slideId},parseMetadata:function(e){this._tileWidth=256;this._tileHeight=256;this.tileSize=this._tileWidth;this.tileOverlap=0;const t=e.extent.layers;var i=t.length-1;const n=t[i].scale;this.width=Math.ceil(e.extent.width*n);this.height=Math.ceil(e.extent.height*n);this.dimensions=new o.Point(this.width,this.height);this.aspectRatio=this.width/this.height;this.levelSizes=t.map(e=>({width:Math.ceil(e.x_tiles*this._tileWidth),height:Math.ceil(e.y_tiles*this._tileHeight),xTiles:Math.ceil(e.x_tiles),yTiles:Math.ceil(e.y_tiles)}));this.levelScales=t.map(e=>e.scale/n);this.minLevel=0;this.maxLevel=Math.ceil(this.levelSizes.length-1)},getImageInfo:function(n){const r=this;o.makeAjaxRequest({url:n,type:"GET",async:!0,success:function(e){try{var t=JSON.parse(e.responseText);r.parseMetadata(t);r.ready=!0;r.raiseEvent("ready",{tileSource:r})}catch(e){t="IrisTileSource: Error parsing metadata: "+e.message;o.console.error(t);r.raiseEvent("open-failed",{message:t,source:n})}},error:function(e,t){var i="IrisTileSource: Unable to get metadata from "+n;o.console.error(i);r.raiseEvent("open-failed",{message:i,source:n})}})},getNumTiles:function(e){return e<this.minLevel||e>this.maxLevel||!this.levelSizes[e]?new o.Point(0,0):new o.Point(Math.ceil(this.levelSizes[e].xTiles),Math.ceil(this.levelSizes[e].yTiles))},getTileUrl:function(e,t,i){t=i*this.levelSizes[e].xTiles+t;return`${this.serverUrl}/slides/${this.slideId}/layers/${e}/tiles/`+t},getLevelScale:function(e){return this.levelScales[e]},configure:function(e){return e}});o.extend(!0,o.IrisTileSource.prototype,o.EventSource.prototype)}(OpenSeadragon);!function(s){s.OsmTileSource=function(e,t,i,n,r){let o;o=s.isPlainObject(e)?e:{width:e,height:t,tileSize:i,tileOverlap:n,tilesUrl:r};if(!o.width||!o.height){o.width=67108864;o.height=67108864}if(!o.tileSize){o.tileSize=256;o.tileOverlap=0}o.tilesUrl||(o.tilesUrl="http://tile.openstreetmap.org/");o.minLevel=8;s.TileSource.apply(this,[o])};s.extend(s.OsmTileSource.prototype,s.TileSource.prototype,{supports:function(e,t){return e.type&&"openstreetmaps"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){return this.tilesUrl+(e-8)+"/"+t+"/"+i+".png"},equals:function(e){return e&&this.tilesUrl===e.tilesUrl}})}(OpenSeadragon);!function(h){h.TmsTileSource=function(e,t,i,n,r){let o;o=h.isPlainObject(e)?e:{width:e,height:t,tileSize:i,tileOverlap:n,tilesUrl:r};var s=256*Math.ceil(o.width/256);var a=256*Math.ceil(o.height/256);let l;l=a<s?s/256:a/256;o.maxLevel=Math.ceil(Math.log(l)/Math.log(2))-1;o.tileSize=256;o.width=s;o.height=a;h.TileSource.apply(this,[o])};h.extend(h.TmsTileSource.prototype,h.TileSource.prototype,{supports:function(e,t){return e.type&&"tiledmapservice"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){var n=this.getNumTiles(e).y-1;return this.tilesUrl+e+"/"+t+"/"+(n-i)+".png"},equals:function(e){return e&&this.tilesUrl===e.tilesUrl}})}(OpenSeadragon);!function(i){i.ZoomifyTileSource=function(e){void 0===e.tileSize&&(e.tileSize=256);if(void 0===e.fileFormat){e.fileFormat="jpg";this.fileFormat=e.fileFormat}const t={x:e.width,y:e.height};e.imageSizes=[{x:e.width,y:e.height}];e.gridSize=[this._getGridSize(e.width,e.height,e.tileSize)];for(;parseInt(t.x,10)>e.tileSize||parseInt(t.y,10)>e.tileSize;){t.x=Math.floor(t.x/2);t.y=Math.floor(t.y/2);e.imageSizes.push({x:t.x,y:t.y});e.gridSize.push(this._getGridSize(t.x,t.y,e.tileSize))}e.imageSizes.reverse();e.gridSize.reverse();e.minLevel=0;e.maxLevel=e.gridSize.length-1;i.TileSource.apply(this,[e])};i.extend(i.ZoomifyTileSource.prototype,i.TileSource.prototype,{_getGridSize:function(e,t,i){return{x:Math.ceil(e/i),y:Math.ceil(t/i)}},_calculateAbsoluteTileNumber:function(t,e,i){let n=0;let r={};for(let e=0;e<t;e++){r=this.gridSize[e];n+=r.x*r.y}r=this.gridSize[t];n+=r.x*i+e;return n},supports:function(e,t){return e.type&&"zoomifytileservice"===e.type},configure:function(e,t,i){return e},getTileUrl:function(e,t,i){var n=this._calculateAbsoluteTileNumber(e,t,i);n=Math.floor(n/256);return this.tilesUrl+"TileGroup"+n+"/"+e+"-"+t+"-"+i+"."+this.fileFormat},equals:function(e){return e&&this.tilesUrl===e.tilesUrl}})}(OpenSeadragon);!function(s){s.LegacyTileSource=function(e){let t;let i;let n;s.isArray(e)&&(t={type:"legacy-image-pyramid",levels:e});t.levels=function(t){const i=[];var n;for(let e=0;e<t.length;e++)(n=t[e]).height&&n.width&&n.url?i.push({url:n.url,width:Number(n.width),height:Number(n.height)}):s.console.error("Unsupported image format: %s",n.url||"<no URL>");return i.sort(function(e,t){return e.height-t.height})}(t.levels);if(0<t.levels.length){i=t.levels[t.levels.length-1].width;n=t.levels[t.levels.length-1].height}else{i=0;n=0;s.console.error("No supported image formats found")}s.extend(!0,t,{width:i,height:n,tileSize:Math.max(n,i),tileOverlap:0,minLevel:0,maxLevel:0<t.levels.length?t.levels.length-1:0});s.TileSource.apply(this,[t]);this.levels=t.levels};s.extend(s.LegacyTileSource.prototype,s.TileSource.prototype,{supports:function(e,t){return e.type&&"legacy-image-pyramid"===e.type||e.documentElement&&"legacy-image-pyramid"===e.documentElement.getAttribute("type")},configure:function(e,t,i){let n;n=s.isPlainObject(e)?e.levels:function(e){if(!e||!e.documentElement)throw new Error(s.getString("Errors.Xml"));const t=e.documentElement;var i=t.tagName;let n=null;var r=[];let o;if("image"===i)try{n={type:t.getAttribute("type"),levels:[]};r=t.getElementsByTagName("level");for(let e=0;e<r.length;e++){o=r[e];n.levels.push({url:o.getAttribute("url"),width:parseInt(o.getAttribute("width"),10),height:parseInt(o.getAttribute("height"),10)})}return n.levels}catch(e){throw e instanceof Error?e:new Error("Unknown error parsing Legacy Image Pyramid XML.")}else{if("collection"===i)throw new Error("Legacy Image Pyramid Collections not yet supported.");if("error"===i)throw new Error("Error: "+e)}throw new Error("Unknown element "+i)}(e);return n},getLevelScale:function(e){let t=NaN;0<this.levels.length&&e>=this.minLevel&&e<=this.maxLevel&&(t=this.levels[e].width/this.levels[this.maxLevel].width);return t},getNumTiles:function(e){return this.getLevelScale(e)?new s.Point(1,1):new s.Point(0,0)},getTileUrl:function(e,t,i){let n=null;0<this.levels.length&&e>=this.minLevel&&e<=this.maxLevel&&(n=this.levels[e].url);return n},equals:function(t){if(!t||!t.levels||t.levels.length!==this.levels.length)return!1;for(let e=this.minLevel;e<=this.maxLevel;e++)if(this.levels[e].url!==t.levels[e].url)return!1;return!0}})}(OpenSeadragon);!function(r){r.ImageTileSource=class extends r.TileSource{constructor(e){super(r.extend({buildPyramid:!0,crossOriginPolicy:!1,ajaxWithCredentials:!1},e))}supports(e,t){return e.type&&"image"===e.type}configure(e,t,i){return e}getImageInfo(e){const t=new Image,i=this;this.crossOriginPolicy&&(t.crossOrigin=this.crossOriginPolicy);r.addEvent(t,"load",function(){i.width=t.naturalWidth;i.height=t.naturalHeight;i.tileWidth=i.width;i.tileHeight=i.height;i.tileOverlap=0;i.minLevel=0;i.image=t;i.levels=i._buildLevels(t);i.maxLevel=i.levels.length-1;i.raiseEvent("ready",{tileSource:i})});r.addEvent(t,"error",function(){i.image=null;i.raiseEvent("open-failed",{message:"Error loading image at "+e,source:e})});t.src=e}getLevelScale(e){let t=NaN;e>=this.minLevel&&e<=this.maxLevel&&(t=this.levels[e].width/this.levels[this.maxLevel].width);return t}getNumTiles(e){return this.getLevelScale(e)?new r.Point(1,1):new r.Point(0,0)}getTileUrl(e,t,i){return e===this.maxLevel?this.url:this.url+`?l=${e}&x=${t}&y=`+i}equals(e){return this.url===e.url}getTilePostData(e,t,i){return{level:e,x:t,y:i}}getContext2D(e,t,i){r.console.error("Using [TiledImage.getContext2D] (for plain images only) is deprecated. Use overridden downloadTileStart (https://openseadragon.github.io/examples/advanced-data-model/) instead.");return this._createContext2D()}downloadTileStart(e){var t=e.postData;if(t.level!==this.maxLevel)if(t.level>=this.minLevel&&t.level<=this.maxLevel){var i=this.levels[t.level];i=this._createContext2D(this.image,i.width,i.height);e.finish(i,null,"context2d")}else e.fail(`Invalid level ${t.level} for plain image source. Did you forget to set buildPyramid=true?`);else e.finish(this.image,null,"image")}downloadTileAbort(e){}_buildLevels(e){const t=[{url:e.src,width:e.naturalWidth,height:e.naturalHeight}];if(!this.buildPyramid||!r.supportsCanvas||!this.useCanvas)return t;let i=e.naturalWidth,n=e.naturalHeight;for(;2<=i&&2<=n;){i=Math.floor(i/2);n=Math.floor(n/2);t.push({width:i,height:n})}return t.reverse()}_createContext2D(e,t,i){const n=document.createElement("canvas"),r=n.getContext("2d");n.width=t;n.height=i;r.drawImage(e,0,0,t,i);return r}}}(OpenSeadragon);!function(r){r.TileSourceCollection=function(e,t,i,n){r.console.error("TileSourceCollection is deprecated; use World instead")}}(OpenSeadragon);!function(o){const e=o;e.PriorityQueue=class{constructor(e=void 0){this.nodes_=[];e&&this.insertAll(e)}insert(e,t){this.insertNode(new Node(e,t))}insertNode(e){const t=this.nodes_;e.index=t.length;t.push(e);this.moveUp_(e.index)}insertAll(e){let t,i;if(!(e instanceof o.PriorityQueue))throw"insertAll supports only OpenSeadragon.PriorityQueue object!";t=e.getKeys();i=e.getValues();if(this.getCount()<=0){const n=this.nodes_;for(let e=0;e<t.length;e++){const r=new Node(t[e],i[e]);r.index=n.length;n.push(r)}}else for(let e=0;e<t.length;e++)this.insert(t[e],i[e])}remove(){const e=this.nodes_;var t=e.length;const i=e[0];if(!(t<=0)){if(1==t)e.length=0;else{e[0]=e.pop();e[0]&&(e[0].index=0);this.moveDown_(0)}i&&delete i.index;return i}}peek(){var e=this.nodes_;if(0!=e.length)return e[0].value}peekKey(){return this.nodes_[0]&&this.nodes_[0].key}decreaseKey(e,t){if(void 0===e.index){e.key=t;this.insertNode(e)}else{e.key=t;this.moveUp_(e.index)}}moveDown_(e){const t=this.nodes_;var i=t.length;const n=t[e];for(;e<i>>1;){var r=this.getLeftChildIndex_(e);var o=this.getRightChildIndex_(e);r=o<i&&t[o].key<t[r].key?o:r;if(t[r].key>n.key)break;t[e]=t[r];t[e].index=e;e=r}t[e]=n;n&&(n.index=e)}moveUp_(e){const t=this.nodes_;const i=t[e];for(;0<e;){var n=this.getParentIndex_(e);if(!(t[n].key>i.key))break;t[e]=t[n];t[e].index=e;e=n}t[e]=i;i&&(i.index=e)}getLeftChildIndex_(e){return 2*e+1}getRightChildIndex_(e){return 2*e+2}getParentIndex_(e){return e-1>>1}getValues(){return this.nodes_.map(e=>e.value)}getKeys(){return this.nodes_.map(e=>e.key)}containsValue(t){return this.nodes_.some(e=>e.value==t)}containsKey(t){return this.nodes_.some(e=>e.value==t)}clone(){return new o.PriorityQueue(this)}getCount(){return this.nodes_.length}isEmpty(){return 0===this.nodes_.length}clear(){this.nodes_.length=0}};e.PriorityQueue.Node=class Node{constructor(e,t){this.key=e;this.value=t;this.index=0}clone(){return new Node(this.key,this.value)}}}(OpenSeadragon);!function(u){const m=u;class e{constructor(){this.adjacencyList={};this.vertices={}}addVertex(e){if(this.vertices[e])return!1;this.vertices[e]=new u.PriorityQueue.Node(0,e);this.adjacencyList[e]=[];return!0}addEdge(e,t,i,n){i<0&&u.console.error("WeightedGraph: negative weights will make for invalid shortest path computation!");const r=this.adjacencyList[e],o=r.findIndex(e=>e.target===this.vertices[t]),s={target:this.vertices[t],origin:this.vertices[e],weight:i,transform:n};if(o<0){this.adjacencyList[e].push(s);return!0}this.adjacencyList[e][o]=s;return!1}dijkstra(e,t){const i=[];if(e===t)return{path:i,cost:0};const n=new m.PriorityQueue;let r;for(var o in this.vertices){o=this.vertices[o];if(o.value===e){o.key=0;n.insertNode(o)}else{o.key=1/0;delete o.index}o._previous=null}for(;0<n.getCount();){r=n.remove();if(r.value===t)break;var s=this.adjacencyList[r.value];for(const c in s){var a=s[c];var l=r.key+a.weight;const u=a.target;if(l<u.key){u._previous=r;n.decreaseKey(u,l)}}}if(r&&r._previous&&r.value===t){var h=r.key;for(;r._previous;){const d=r.value,p=r._previous,g=p.value;i.push(this.adjacencyList[g].find(e=>e.target.value===d));r=p}return{path:i.reverse(),cost:h}}}}let c;let t=0;const d=new Map;let p=!1;const g="undefined"!=typeof SharedArrayBuffer&&!0===self.crossOriginIsolated;function s(o,s,{timeoutMs:a=15e3}={}){const l=function(){if(c)return c;var e=URL.createObjectURL(new Blob([`
self.onmessage = async (e) => {
const { id, op, } = e.data;
let error;
try {
if (op === 'decodeFromBlob') {
const bmp = await createImageBitmap(e.data.blob, { colorSpaceConversion: 'none' });
postMessage({ id, ok: true, bmp }, [bmp]);
return;
}
if (op === 'decodeFromBytes') {
const u8 = new Uint8Array(e.data.bytes);
const b = new Blob([u8], { type: e.data.mime || '' });
const bmp = await createImageBitmap(b, { colorSpaceConversion: 'none' });
postMessage({ id, ok: true, bmp }, [bmp]);
return;
}
if (op === 'fetchDecode') {
const res = await fetch(e.data.url, e.data.setup);
if (!res.ok) throw new Error('HTTP ' + res.status);
const b = await res.blob();
const bmp = await createImageBitmap(b, { colorSpaceConversion: 'none' });
postMessage({ id, ok: true, bmp }, [bmp]);
return;
}
error = 'Unknown op: ' + op;
} catch (err) {
error = String(err && err.message || err);
}
postMessage({ id, ok: false, err: error });
};
`],{type:"text/javascript"}));c=new Worker(e);c.onmessage=e=>{var{id:t,ok:i,bmp:n,err:e}=e.data||{};const r=d.get(t);if(r){d.delete(t);if(r.timer){clearTimeout(r.timer);r.timer=null}i?r.resolve(n):r.reject(new Error(e))}};c.onerror=e=>{for(var[,t]of d){if(t.timer){clearTimeout(t.timer);t.timer=null}t.reject(new Error("Worker error"))}d.clear()};return c}();const h=++t;return new u.Promise((e,t)=>{s.id=h;s.op=o;const i={resolve:e,reject:t,timer:null};0<a&&(i.timer=setTimeout(()=>{i.timer=null;d.delete(h);t(new Error(`Worker timeout (${o})`))},a));d.set(h,i);if("decodeFromBytes"!==o)l.postMessage(s);else if(g){e=s.u8;var n=new SharedArrayBuffer(e.byteLength);new Uint8Array(n).set(e);l.postMessage({id:h,op:o,bytes:n,mime:s.mime})}else{if(!p){p=!0;console.warn("[Converter] SharedArrayBuffer unavailable; falling back to ArrayBuffer.")}const r=s.u8;n=0===r.byteOffset&&r.byteLength===r.buffer.byteLength?r:r.slice();l.postMessage({id:h,op:o,bytes:n.buffer,mime:s.mime},[n.buffer])}})}m.DataTypeConverter=class{constructor(){this.graph=new e;this.destructors={};this.copyings={};const i=(e,t)=>{const i=document.createElement("canvas");i.width=t.width;i.height=t.height;const n=i.getContext("2d",{willReadFrequently:!0});n.drawImage(t,0,0);return n};this.learn("rasterBlob","image",(e,r)=>new u.Promise((e,t)=>{var i=(window.URL||window.webkitURL).createObjectURL(r);if(!u.supportsAsync)return t("Not supported in sync mode!");const n=new Image;n.onerror=n.onabort=e=>{(window.URL||window.webkitURL).revokeObjectURL(r);t(e)};n.onload=()=>{(window.URL||window.webkitURL).revokeObjectURL(r);e(n)};n.decoding="async";n.src=i}),1,2);this.learn("context2d","rasterBlob",(e,i)=>new u.Promise((e,t)=>{if(!u.supportsAsync)return t("Not supported in sync mode!");i.canvas.toBlob(e)}),1,2);this.learn("rasterBlob","imageBitmap",(e,i)=>new u.Promise((e,t)=>{if(!u.supportsAsync)return t("Not supported in sync mode!");(c?s("decodeFromBlob",{blob:i}):createImageBitmap(i,{colorSpaceConversion:"none"})).then(e).catch(t)}),1,1);this.learn("imageBitmap","context2d",(e,t)=>{const i=document.createElement("canvas");i.width=t.width;i.height=t.height;const n=i.getContext("2d",{willReadFrequently:!0});n.drawImage(t,0,0);return n},1,2);this.learn("image","imageBitmap",(e,t)=>createImageBitmap(t,{colorSpaceConversion:"none"}),1,2);this.learn("image","context2d",i,1,2);this.learn("image","image",(e,t)=>((n,r)=>new u.Promise((e,t)=>{if(!u.supportsAsync)return t("Not supported in sync mode!");const i=new Image;i.onerror=i.onabort=e=>t("Failed to load image: "+r);i.onload=()=>e(i);n.tiledImage&&n.tiledImage.crossOriginPolicy&&(i.crossOrigin=n.tiledImage.crossOriginPolicy);i.src=r}))(e,t.src),1,1);this.learn("context2d","context2d",(e,t)=>i(0,t.canvas));this.learn("rasterBlob","rasterBlob",(e,t)=>t,0,1);this.learn("imageBitmap","imageBitmap",(e,r)=>new u.Promise((e,t)=>{try{if(!u.supportsAsync)return t("Not supported in sync mode!");if(!r)return t(new Error("No ImageBitmap to copy"));if("undefined"!=typeof OffscreenCanvas&&r.width&&r.height){const i=new OffscreenCanvas(r.width,r.height);const n=i.getContext("2d",{willReadFrequently:!1});n.drawImage(r,0,0);return"function"!=typeof i.transferToImageBitmap?createImageBitmap(i,{colorSpaceConversion:"none"}).then(e):e(i.transferToImageBitmap())}return createImageBitmap(r,{colorSpaceConversion:"none"}).then(e)}catch(e){return t(e)}}),1,1);this.learnDestroy("context2d",e=>{e.canvas.width=0;e.canvas.height=0})}guessType(e){if(Array.isArray(e)){const n=[];for(const r of e)if(void 0!==r&&null!==r){var t=this.guessType(r);n.includes(t)||n.push(t)}n.sort();return`Array [${n.join(",")}]`}const i=u.type(e);return"dom-node"===i?i.nodeName.toLowerCase():"object"===i&&u.isFunction(e.getType)?e.getType():i}learn(e,t,i,n=0,r=1){u.console.assert(0<=n&&n<=7,"[DataTypeConverter] Conversion costPower must be between <0, 7>.");u.console.assert(u.isFunction(i),"[DataTypeConverter:learn] Callback must be a valid function!");if(e===t)this.copyings[t]=i;else{n++;r=Math.min(Math.max(r,1),15);this.graph.addVertex(e);this.graph.addVertex(t);this.graph.addEdge(e,t,10*n^5+r,i);this._known={}}}learnDestroy(e,t){this.destructors[e]=t}convert(s,e,t,...i){const a=this.getConversionPath(t,i);if(!a){u.console.error(`[OpenSeadragon.converter.convert] Conversion ${t} ---> ${i} cannot be done!`);return u.Promise.resolve()}const l=a.length;const h=this;const c=(t,i,n=!0)=>{if(i>=l)return u.Promise.resolve(t);const r=a[i];let e;try{e=r.transform(s,t)}catch(e){n&&h.destroy(t,r.origin.value);return u.Promise.reject(`[OpenSeadragon.converter.convert] sync failure (while converting using ${r.origin.value} -> ${r.target.value})`)}if(void 0===e){n&&h.destroy(t,r.origin.value);return u.Promise.reject(`[OpenSeadragon.converter.convert] data mid result undefined value (while converting using ${r.origin.value} -> ${r.target.value})`)}n&&h.destroy(t,r.origin.value);const o="promise"===u.type(e)?e:u.Promise.resolve(e);return o.then(e=>c(e,i+1))};return c(e,0,!1)}copy(e,t,i){const n=this.copyings[i];if(n){t=n(e,t);return"promise"===u.type(t)?t:u.Promise.resolve(t)}u.console.warn("[OpenSeadragon.converter.copy] is not supported with type %s",i);return u.Promise.resolve(void 0)}destroy(e,t){const i=this.destructors[t];if(i){e=i(e);return"promise"===u.type(e)?e:u.Promise.resolve(e)}}getConversionPath(i,e){let n;let r=this._known[i];r||(this._known[i]=r={});if(Array.isArray(e)){u.console.assert(0<e.length,"[getConversionPath] conversion 'to' type must be defined.");let t=1/0;for(const o of e){let e=r[o];void 0===e&&(r[o]=e=this.graph.dijkstra(i,o));if(e&&t>e.cost){n=e;t=e.cost}}}else{u.console.assert("string"==typeof e,"[getConversionPath] conversion 'to' type must be defined.");n=r[e];if(void 0===n){n=this.graph.dijkstra(i,e);this._known[i][e]=n}}return n?n.path:void 0}getConversionPathFinalType(e){if(e&&e.length)return e[e.length-1].target.value}getKnownTypes(){return Object.keys(this.graph.vertices)}existsType(e){return!!this.graph.vertices[e]}};u.converter=new u.DataTypeConverter;u.converter.learn("__private__imageUrl","imageBitmap",(r,o)=>new u.Promise((e,t)=>{if(!u.supportsAsync)return t("Not supported in sync mode!");let i;if(r.tiledImage&&r.tiledImage.crossOriginPolicy){var n=r.tiledImage.crossOriginPolicy;"anonymous"===n?i={mode:"cors",credentials:"omit"}:"use-credentials"===n?i={mode:"cors",credentials:"include"}:n&&u.console.error(`Unsupported crossOriginPolicy ${n}. Ignoring the property.`)}return(c?s("fetchDecode",{url:o,setup:i}):fetch(o,i).then(e=>{if(!e.ok)throw new Error(`HTTP ${e.status} loading `+o);return e.blob()}).then(e=>createImageBitmap(e,{colorSpaceConversion:"none"}))).then(e).catch(t)}),1,1);u.converter.learn("__private__imageUrl","__private__imageUrl",(e,t)=>t,0,1)}(OpenSeadragon);!function(i){i.ButtonState={REST:0,GROUP:1,HOVER:2,DOWN:3};i.Button=function(e){const t=this;i.EventSource.call(this);i.extend(!0,this,{tooltip:null,srcRest:null,srcGroup:null,srcHover:null,srcDown:null,clickTimeThreshold:i.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:i.DEFAULT_SETTINGS.clickDistThreshold,fadeDelay:0,fadeLength:2e3,onPress:null,onRelease:null,onClick:null,onEnter:null,onExit:null,onFocus:null,onBlur:null,userData:null},e);this.element=e.element||i.makeNeutralElement("div");if(!e.element){this.imgRest=i.makeTransparentImage(this.srcRest);this.imgGroup=i.makeTransparentImage(this.srcGroup);this.imgHover=i.makeTransparentImage(this.srcHover);this.imgDown=i.makeTransparentImage(this.srcDown);this.imgRest.alt=this.imgGroup.alt=this.imgHover.alt=this.imgDown.alt=this.tooltip;i.setElementPointerEventsNone(this.imgRest);i.setElementPointerEventsNone(this.imgGroup);i.setElementPointerEventsNone(this.imgHover);i.setElementPointerEventsNone(this.imgDown);this.element.style.position="relative";i.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";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=i.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 i.MouseTracker({userData:"Button.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(e){if(e.insideElementPressed){r(t,i.ButtonState.DOWN);t.raiseEvent("enter",{originalEvent:e.originalEvent})}else e.buttonDownAny||r(t,i.ButtonState.HOVER)},focusHandler:function(e){t.tracker.enterHandler(e);t.raiseEvent("focus",{originalEvent:e.originalEvent})},leaveHandler:function(e){o(t,i.ButtonState.GROUP);e.insideElementPressed&&t.raiseEvent("exit",{originalEvent:e.originalEvent})},blurHandler:function(e){t.tracker.leaveHandler(e);t.raiseEvent("blur",{originalEvent:e.originalEvent})},pressHandler:function(e){r(t,i.ButtonState.DOWN);t.raiseEvent("press",{originalEvent:e.originalEvent})},releaseHandler:function(e){if(e.insideElementPressed&&e.insideElementReleased){o(t,i.ButtonState.HOVER);t.raiseEvent("release",{originalEvent:e.originalEvent})}else e.insideElementPressed?o(t,i.ButtonState.GROUP):r(t,i.ButtonState.HOVER)},clickHandler:function(e){e.quick&&t.raiseEvent("click",{originalEvent:e.originalEvent})},keyHandler:function(e){if(13===e.keyCode){t.raiseEvent("click",{originalEvent:e.originalEvent});t.raiseEvent("release",{originalEvent:e.originalEvent});e.preventDefault=!0}else e.preventDefault=!1}});o(this,i.ButtonState.REST)};i.extend(i.Button.prototype,i.EventSource.prototype,{notifyGroupEnter:function(){r(this,i.ButtonState.GROUP)},notifyGroupExit:function(){o(this,i.ButtonState.REST)},disable:function(){this.notifyGroupExit();this.element.disabled=!0;this.tracker.setTracking(!1);i.setElementOpacity(this.element,.2,!0)},enable:function(){this.element.disabled=!1;this.tracker.setTracking(!0);i.setElementOpacity(this.element,1,!0);this.notifyGroupEnter()},destroy:function(){if(this.imgRest){this.element.removeChild(this.imgRest);this.imgRest=null}if(this.imgGroup){this.element.removeChild(this.imgGroup);this.imgGroup=null}if(this.imgHover){this.element.removeChild(this.imgHover);this.imgHover=null}if(this.imgDown){this.element.removeChild(this.imgDown);this.imgDown=null}this.removeAllHandlers();this.tracker.destroy();this.element=null}});function n(e){i.requestAnimationFrame(function(){!function(e){var t;if(e.shouldFade){t=i.now();t=t-e.fadeBeginTime;t=1-t/e.fadeLength;t=Math.min(1,t);t=Math.max(0,t);e.imgGroup&&i.setElementOpacity(e.imgGroup,t,!0);0<t&&n(e)}}(e)})}function r(e,t){if(!e.element.disabled){if(t>=i.ButtonState.GROUP&&e.currentState===i.ButtonState.REST){!function(e){e.shouldFade=!1;e.imgGroup&&i.setElementOpacity(e.imgGroup,1,!0)}(e);e.currentState=i.ButtonState.GROUP}if(t>=i.ButtonState.HOVER&&e.currentState===i.ButtonState.GROUP){e.imgHover&&(e.imgHover.style.visibility="");e.currentState=i.ButtonState.HOVER}if(t>=i.ButtonState.DOWN&&e.currentState===i.ButtonState.HOVER){e.imgDown&&(e.imgDown.style.visibility="");e.currentState=i.ButtonState.DOWN}}}function o(e,t){if(!e.element.disabled){if(t<=i.ButtonState.HOVER&&e.currentState===i.ButtonState.DOWN){e.imgDown&&(e.imgDown.style.visibility="hidden");e.currentState=i.ButtonState.HOVER}if(t<=i.ButtonState.GROUP&&e.currentState===i.ButtonState.HOVER){e.imgHover&&(e.imgHover.style.visibility="hidden");e.currentState=i.ButtonState.GROUP}if(t<=i.ButtonState.REST&&e.currentState===i.ButtonState.GROUP){!function(e){e.shouldFade=!0;e.fadeBeginTime=i.now()+e.fadeDelay;window.setTimeout(function(){n(e)},e.fadeDelay)}(e);e.currentState=i.ButtonState.REST}}}}(OpenSeadragon);!function(r){r.ButtonGroup=function(e){r.extend(!0,this,{buttons:[],clickTimeThreshold:r.DEFAULT_SETTINGS.clickTimeThreshold,clickDistThreshold:r.DEFAULT_SETTINGS.clickDistThreshold,labelText:""},e);let t=this.buttons.concat([]),i=this,n;this.element=e.element||r.makeNeutralElement("div");if(!e.group){this.element.style.display="inline-block";for(n=0;n<t.length;n++)this.element.appendChild(t[n].element)}r.setElementTouchActionNone(this.element);this.tracker=new r.MouseTracker({userData:"ButtonGroup.tracker",element:this.element,clickTimeThreshold:this.clickTimeThreshold,clickDistThreshold:this.clickDistThreshold,enterHandler:function(e){let t;for(t=0;t<i.buttons.length;t++)i.buttons[t].notifyGroupEnter()},leaveHandler:function(e){let t;if(!e.insideElementPressed)for(t=0;t<i.buttons.length;t++)i.buttons[t].notifyGroupExit()}})};r.ButtonGroup.prototype={addButton:function(e){this.buttons.push(e);this.element.appendChild(e.element)},emulateEnter:function(){this.tracker.enterHandler({eventSource:this.tracker})},emulateLeave:function(){this.tracker.leaveHandler({eventSource:this.tracker})},destroy:function(){for(;this.buttons.length;){const e=this.buttons.pop();this.element.removeChild(e.element);e.destroy()}this.tracker.destroy();this.element=null}}}(OpenSeadragon);!function(p){p.Rect=function(e,t,i,n,r){this.x="number"==typeof e?e:0;this.y="number"==typeof t?t:0;this.width="number"==typeof i?i:0;this.height="number"==typeof n?n:0;this.degrees="number"==typeof r?r:0;this.degrees=p.positiveModulo(this.degrees,360);let o,s;if(270<=this.degrees){o=this.getTopRight();this.x=o.x;this.y=o.y;s=this.height;this.height=this.width;this.width=s;this.degrees-=270}else if(180<=this.degrees){o=this.getBottomRight();this.x=o.x;this.y=o.y;this.degrees-=180}else if(90<=this.degrees){o=this.getBottomLeft();this.x=o.x;this.y=o.y;s=this.height;this.height=this.width;this.width=s;this.degrees-=90}};p.Rect.fromSummits=function(e,t,i){var n=e.distanceTo(t);i=e.distanceTo(i);t=t.minus(e);let r=Math.atan(t.y/t.x);t.x<0?r+=Math.PI:t.y<0&&(r+=2*Math.PI);return new p.Rect(e.x,e.y,n,i,r/Math.PI*180)};p.Rect.prototype={clone:function(){return new p.Rect(this.x,this.y,this.width,this.height,this.degrees)},getAspectRatio:function(){return this.width/this.height},getTopLeft:function(){return new p.Point(this.x,this.y)},getBottomRight:function(){return new p.Point(this.x+this.width,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getTopRight:function(){return new p.Point(this.x+this.width,this.y).rotate(this.degrees,this.getTopLeft())},getBottomLeft:function(){return new p.Point(this.x,this.y+this.height).rotate(this.degrees,this.getTopLeft())},getCenter:function(){return new p.Point(this.x+this.width/2,this.y+this.height/2).rotate(this.degrees,this.getTopLeft())},getSize:function(){return new p.Point(this.width,this.height)},equals:function(e){return e instanceof p.Rect&&this.x===e.x&&this.y===e.y&&this.width===e.width&&this.height===e.height&&this.degrees===e.degrees},times:function(e){return new p.Rect(this.x*e,this.y*e,this.width*e,this.height*e,this.degrees)},translate:function(e){return new p.Rect(this.x+e.x,this.y+e.y,this.width,this.height,this.degrees)},union:function(e){var t=this.getBoundingBox();var i=e.getBoundingBox();var n=Math.min(t.x,i.x);var r=Math.min(t.y,i.y);e=Math.max(t.x+t.width,i.x+i.width);i=Math.max(t.y+t.height,i.y+i.height);return new p.Rect(n,r,e-n,i-r)},intersection:function(e){const s=1e-10;const t=[];var i=this.getTopLeft();e.containsPoint(i,s)&&t.push(i);i=this.getTopRight();e.containsPoint(i,s)&&t.push(i);i=this.getBottomLeft();e.containsPoint(i,s)&&t.push(i);i=this.getBottomRight();e.containsPoint(i,s)&&t.push(i);i=e.getTopLeft();this.containsPoint(i,s)&&t.push(i);i=e.getTopRight();this.containsPoint(i,s)&&t.push(i);i=e.getBottomLeft();this.containsPoint(i,s)&&t.push(i);i=e.getBottomRight();this.containsPoint(i,s)&&t.push(i);var n=this._getSegments();var r=e._getSegments();for(let e=0;e<n.length;e++){var o=n[e];for(let e=0;e<r.length;e++){var a=r[e];a=function(e,t,i,n){var r=t.minus(e);var o=n.minus(i);t=-o.x*r.y+r.x*o.y;if(0==t)return null;n=(r.x*(e.y-i.y)-r.y*(e.x-i.x))/t;t=(o.x*(e.y-i.y)-o.y*(e.x-i.x))/t;if(-s<=n&&n<=1-s&&-s<=t&&t<=1-s)return new p.Point(e.x+t*r.x,e.y+t*r.y);return null}(o[0],o[1],a[0],a[1]);a&&t.push(a)}}if(0===t.length)return null;let l=t[0].x;let h=t[0].x;let c=t[0].y;let u=t[0].y;for(let e=1;e<t.length;e++){var d=t[e];d.x<l&&(l=d.x);d.x>h&&(h=d.x);d.y<c&&(c=d.y);d.y>u&&(u=d.y)}return new p.Rect(l,c,h-l,u-c)},_getSegments:function(){var e=this.getTopLeft();var t=this.getTopRight();var i=this.getBottomLeft();var n=this.getBottomRight();return[[e,t],[t,n],[n,i],[i,e]]},rotate:function(e,t){if(0===(e=p.positiveModulo(e,360)))return this.clone();t=t||this.getCenter();var i=this.getTopLeft().rotate(e,t);const n=this.getTopRight().rotate(e,t);let r=n.minus(i);r=r.apply(function(e){return Math.abs(e)<1e-15?0:e});let o=Math.atan(r.y/r.x);r.x<0?o+=Math.PI:r.y<0&&(o+=2*Math.PI);return new p.Rect(i.x,i.y,this.width,this.height,o/Math.PI*180)},getBoundingBox:function(){if(0===this.degrees)return this.clone();var e=this.getTopLeft();var t=this.getTopRight();var i=this.getBottomLeft();var n=this.getBottomRight();var r=Math.min(e.x,t.x,i.x,n.x);var o=Math.max(e.x,t.x,i.x,n.x);var s=Math.min(e.y,t.y,i.y,n.y);n=Math.max(e.y,t.y,i.y,n.y);return new p.Rect(r,s,o-r,n-s)},getIntegerBoundingBox:function(){var e=this.getBoundingBox();var t=Math.floor(e.x);var i=Math.floor(e.y);var n=Math.ceil(e.width+e.x-t);e=Math.ceil(e.height+e.y-i);return new p.Rect(t,i,n,e)},containsPoint:function(e,t){t=t||0;var i=this.getTopLeft();const n=this.getTopRight();const r=this.getBottomLeft();var o=n.minus(i);var s=r.minus(i);return(e.x-i.x)*o.x+(e.y-i.y)*o.y>=-t&&(e.x-n.x)*o.x+(e.y-n.y)*o.y<=t&&(e.x-i.x)*s.x+(e.y-i.y)*s.y>=-t&&(e.x-r.x)*s.x+(e.y-r.y)*s.y<=t},toString:function(){return"["+Math.round(100*this.x)/100+", "+Math.round(100*this.y)/100+", "+Math.round(100*this.width)/100+"x"+Math.round(100*this.height)/100+", "+Math.round(100*this.degrees)/100+"deg]"}}}(OpenSeadragon);!function(c){const s={};c.ReferenceStrip=function(e){const t=e.viewer;var i=c.getElementSize(t.element);let n;let r;if(!e.id){e.id="referencestrip-"+c.now();this.element=c.makeNeutralElement("div");this.element.id=e.id;this.element.className="referencestrip"}e=c.extend(!0,{sizeRatio:c.DEFAULT_SETTINGS.referenceStripSizeRatio,position:c.DEFAULT_SETTINGS.referenceStripPosition,scroll:c.DEFAULT_SETTINGS.referenceStripScroll,clickTimeThreshold:c.DEFAULT_SETTINGS.clickTimeThreshold},e,{element:this.element});c.extend(this,e);s[this.id]={animating:!1};this.minPixelRatio=this.viewer.minPixelRatio;this.element.tabIndex=0;const o=this.element.style;o.marginTop="0px";o.marginRight="0px";o.marginBottom="0px";o.marginLeft="0px";o.left="0px";o.bottom="0px";o.border="0px";o.background="#000";o.position="relative";c.setElementTouchActionNone(this.element);c.setElementOpacity(this.element,.8);this.viewer=t;this.tracker=new c.MouseTracker({userData:"ReferenceStrip.tracker",element:this.element,clickHandler:c.delegate(this,a),dragHandler:c.delegate(this,l),scrollHandler:c.delegate(this,h),enterHandler:c.delegate(this,d),leaveHandler:c.delegate(this,p),keyDownHandler:c.delegate(this,g),keyHandler:c.delegate(this,m),preProcessEventHandler:function(e){"wheel"===e.eventType&&(e.preventDefault=!0)}});if(e.width&&e.height){this.element.style.width=e.width+"px";this.element.style.height=e.height+"px";t.addControl(this.element,{anchor:c.ControlAnchor.BOTTOM_LEFT})}else if("horizontal"===e.scroll){this.element.style.width=i.x*e.sizeRatio*t.tileSources.length+12*t.tileSources.length+"px";this.element.style.height=i.y*e.sizeRatio+"px";t.addControl(this.element,{anchor:c.ControlAnchor.BOTTOM_LEFT})}else{this.element.style.height=i.y*e.sizeRatio*t.tileSources.length+12*t.tileSources.length+"px";this.element.style.width=i.x*e.sizeRatio+"px";t.addControl(this.element,{anchor:c.ControlAnchor.TOP_LEFT})}this.panelWidth=i.x*this.sizeRatio+8;this.panelHeight=i.y*this.sizeRatio+8;this.panels=[];this.miniViewers={};for(r=0;r<t.tileSources.length;r++){n=c.makeNeutralElement("div");n.id=this.element.id+"-"+r;n.style.width=this.panelWidth+"px";n.style.height=this.panelHeight+"px";n.style.display="inline";n.style.float="left";n.style.cssFloat="left";n.style.padding="2px";c.setElementTouchActionNone(n);c.setElementPointerEventsNone(n);this.element.appendChild(n);n.activePanel=!1;this.panels.push(n)}u(this,"vertical"===this.scroll?i.y:i.x,0);this.setFocus(0)};c.ReferenceStrip.prototype={setFocus:function(e){var t=this.element.querySelector("#"+this.element.id+"-"+e);var i=c.getElementSize(this.viewer.canvas);var n=Number(this.element.style.width.replace("px",""));var r=Number(this.element.style.height.replace("px",""));var o=-Number(this.element.style.marginLeft.replace("px",""));var s=-Number(this.element.style.marginTop.replace("px",""));let a;if(this.currentSelected!==t){this.currentSelected&&(this.currentSelected.style.background="#000");this.currentSelected=t;this.currentSelected.style.background="#999";if("horizontal"===this.scroll){a=Number(e)*(this.panelWidth+3);if(a>o+i.x-this.panelWidth){a=Math.min(a,n-i.x);this.element.style.marginLeft=-a+"px";u(this,i.x,-a)}else if(a<o){a=Math.max(0,a-i.x/2);this.element.style.marginLeft=-a+"px";u(this,i.x,-a)}}else{a=Number(e)*(this.panelHeight+3);if(a>s+i.y-this.panelHeight){a=Math.min(a,r-i.y);this.element.style.marginTop=-a+"px";u(this,i.y,-a)}else if(a<s){a=Math.max(0,a-i.y/2);this.element.style.marginTop=-a+"px";u(this,i.y,-a)}}this.currentPage=e;d.call(this,{eventSource:this.tracker})}},update:function(){return!!s[this.id].animating},destroy:function(){if(this.miniViewers)for(const e in this.miniViewers)this.miniViewers[e].destroy();this.tracker.destroy();this.element&&this.viewer.removeControl(this.element)}};function a(t){if(t.quick){let e;e="horizontal"===this.scroll?Math.floor(t.position.x/(this.panelWidth+4)):Math.floor(t.position.y/this.panelHeight);this.viewer.goToPage(e)}this.element.focus()}function l(e){this.dragging=!0;if(this.element){var t=Number(this.element.style.marginLeft.replace("px",""));var i=Number(this.element.style.marginTop.replace("px",""));var n=Number(this.element.style.width.replace("px",""));var r=Number(this.element.style.height.replace("px",""));var o=c.getElementSize(this.viewer.canvas);if("horizontal"===this.scroll){if(0<-e.delta.x){if(t>-(n-o.x)){this.element.style.marginLeft=t+2*e.delta.x+"px";u(this,o.x,t+2*e.delta.x)}}else if(-e.delta.x<0&&t<0){this.element.style.marginLeft=t+2*e.delta.x+"px";u(this,o.x,t+2*e.delta.x)}}else if(0<-e.delta.y){if(i>-(r-o.y)){this.element.style.marginTop=i+2*e.delta.y+"px";u(this,o.y,i+2*e.delta.y)}}else if(-e.delta.y<0&&i<0){this.element.style.marginTop=i+2*e.delta.y+"px";u(this,o.y,i+2*e.delta.y)}}}function h(e){if(this.element){var t=Number(this.element.style.marginLeft.replace("px",""));var i=Number(this.element.style.marginTop.replace("px",""));var n=Number(this.element.style.width.replace("px",""));var r=Number(this.element.style.height.replace("px",""));var o=c.getElementSize(this.viewer.canvas);if("horizontal"===this.scroll){if(0<e.scroll){if(t>-(n-o.x)){this.element.style.marginLeft=t-60*e.scroll+"px";u(this,o.x,t-60*e.scroll)}}else if(e.scroll<0&&t<0){this.element.style.marginLeft=t-60*e.scroll+"px";u(this,o.x,t-60*e.scroll)}}else if(e.scroll<0){if(i>o.y-r){this.element.style.marginTop=i+60*e.scroll+"px";u(this,o.y,i+60*e.scroll)}}else if(0<e.scroll&&i<0){this.element.style.marginTop=i+60*e.scroll+"px";u(this,o.y,i+60*e.scroll)}e.preventDefault=!0}}function u(t,e,i){let n;let r;var o;let s;let a;let l;n="horizontal"===t.scroll?t.panelWidth:t.panelHeight;r=Math.ceil(e/n)+5;o=Math.ceil((Math.abs(i)+e)/n)+1;r=o-r;r=r<0?0:r;for(a=r;a<o&&a<t.panels.length;a++){l=t.panels[a];if(!l.activePanel){let e;var h=t.viewer.tileSources[a];e=h.referenceStripThumbnailUrl?{type:"image",url:h.referenceStripThumbnailUrl}:h;s=new c.Viewer({id:l.id,tileSources:[e],element:l,navigatorSizeRatio:t.sizeRatio,showNavigator:!1,mouseNavEnabled:!1,showNavigationControl:!1,showSequenceControl:!1,immediateRender:!0,blendTime:0,animationTime:0,loadTilesWithAjax:t.viewer.loadTilesWithAjax,ajaxHeaders:t.viewer.ajaxHeaders,viewer:t.viewer,drawer:"canvas"});c.setElementPointerEventsNone(s.canvas);c.setElementPointerEventsNone(s.container);s.innerTracker.setTracking(!1);s.outerTracker.setTracking(!1);t.miniViewers[l.id]=s;l.activePanel=!0}}}function d(e){const t=e.eventSource.element;"horizontal"===this.scroll?t.style.marginBottom="0px":t.style.marginLeft="0px"}function p(e){const t=e.eventSource.element;"horizontal"===this.scroll?t.style.marginBottom="-"+c.getElementSize(t).y/2+"px":t.style.marginLeft="-"+c.getElementSize(t).x/2+"px"}function g(e){if(e.ctrl||e.alt||e.meta)e.preventDefault=!1;else switch(e.keyCode){case 38:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});e.preventDefault=!0;break;case 40:case 37:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});e.preventDefault=!0;break;case 39:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});e.preventDefault=!0;break;default:e.preventDefault=!1}}function m(e){if(e.ctrl||e.alt||e.meta)e.preventDefault=!1;else switch(e.keyCode){case 61:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});e.preventDefault=!0;break;case 45:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});e.preventDefault=!0;break;case 48:case 119:case 87:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});e.preventDefault=!0;break;case 115:case 83:case 97:h.call(this,{eventSource:this.tracker,position:null,scroll:-1,shift:null});e.preventDefault=!0;break;case 100:h.call(this,{eventSource:this.tracker,position:null,scroll:1,shift:null});e.preventDefault=!0;break;default:e.preventDefault=!1}}}(OpenSeadragon);!function(s){s.DisplayRect=function(e,t,i,n,r,o){s.Rect.apply(this,[e,t,i,n]);this.minLevel=r;this.maxLevel=o};s.extend(s.DisplayRect.prototype,s.Rect.prototype)}(OpenSeadragon);!function(r){r.Spring=function(e){var t=arguments;"object"!=typeof e&&(e={initial:t.length&&"number"==typeof t[0]?t[0]:void 0,springStiffness:1<t.length?t[1].springStiffness:5,animationTime:1<t.length?t[1].animationTime:1.5});r.console.assert("number"==typeof e.springStiffness&&0!==e.springStiffness,"[OpenSeadragon.Spring] options.springStiffness must be a non-zero number");r.console.assert("number"==typeof e.animationTime&&0<=e.animationTime,"[OpenSeadragon.Spring] options.animationTime must be a number greater than or equal to 0");if(e.exponential){this._exponential=!0;delete e.exponential}r.extend(!0,this,e);this.current={value:"number"==typeof this.initial?this.initial:this._exponential?0:1,time:r.now()};r.console.assert(!this._exponential||0!==this.current.value,"[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};if(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)}};r.Spring.prototype={resetTo:function(e){r.console.assert(!this._exponential||0!==e,"[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=r.now();if(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){r.console.assert(!this._exponential||0!==e,"[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;if(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;if(this._exponential){r.console.assert(0!==this.target.value&&0!==this.start.value,"[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;if(this._exponential){r.console.assert(0!==this.current.value&&0!==this.target.value&&0!==this.start.value,"[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=r.now();let e,t;if(this._exponential){e=this.start._logValue;t=this.target._logValue}else{e=this.start.value;t=this.target.value}if(this.current.time>=this.target.time)this.current.value=this.target.value;else{i=e+(t-e)*(i=this.springStiffness,n=(this.current.time-this.start.time)/(this.target.time-this.start.time),(1-Math.exp(i*-n))/(1-Math.exp(-i)));this._exponential?this.current.value=Math.exp(i):this.current.value=i}var i,n;return this.current.value!==this.target.value},isAtTargetValue:function(){return this.current.value===this.target.value}}}(OpenSeadragon);!function(r){r.ImageJob=function(e){this.data=null;this.userData={};this.errorMsg=null;this.timeout=r.DEFAULT_SETTINGS.timeout;this.isBatched=!1;r.extend(!0,this,{jobId:null,tries:0},e)};r.ImageJob.prototype={start:function(){this.tries++;const e=this;const t=this.abort;this.jobId=window.setTimeout(function(){e.fail("Image load exceeded timeout ("+e.timeout+" ms)",null)},this.timeout);this.abort=function(){e.source.downloadTileAbort(e);"function"==typeof t&&t();e.fail("Image load aborted.",null)};this.source.downloadTileStart(this)},prepareForBatch:function(){this.tries++;this.jobId=-1},finish:function(e,t,i){if(this.jobId)if(null!=(n=e)&&!1!==n){var n;this.data=e;this.request=t;this.errorMsg=null;this.dataType=i;window.clearTimeout(this.jobId);this.jobId=null;this.callback(this)}else this.fail(i||"[downloadTileStart->finish()] Retrieved data is invalid!",t)},fail:function(e,t){this.data=null;this.request=t;this.errorMsg=e;this.dataType=null;if(this.jobId){window.clearTimeout(this.jobId);this.jobId=null}this.callback(this)}};r.BatchImageJob=function(e){r.extend(!0,this,{timeout:r.DEFAULT_SETTINGS.timeout,jobId:null,data:null,dataType:null,errorMsg:null},e);this.jobs=e.jobs||[];this.source=e.source};r.BatchImageJob.prototype={start:function(){this._finishedJobs=0;const t=this;this.jobId=window.setTimeout(function(){t.fail("Batch image load exceeded timeout ("+t.timeout+" ms)",null)},this.timeout);this.abort=function(){t.source.downloadTileBatchAbort(t);for(var e of this.jobs)e.jobId&&e.abort&&e.abort()};var e=(t,i)=>(...e)=>{if(this.jobId){this._finishedJobs++;t.call(i,...e);if(this._finishedJobs===this.jobs.length){window.clearTimeout(this.jobId);this.jobId=null;this.callback&&this.callback(this)}}};for(var i of this.jobs){i.finish=e(i.finish,i);i.fail=e(i.fail,i);i.prepareForBatch()}this.source.downloadTileBatchStart(this)},finish:function(e,t,i){r.console.error("Finish call on batch job is not desirable: call finish on individual child jobs!",e,t)},fail:function(t,i){this.data=null;this.request=i;this.errorMsg=t;this.dataType=null;for(let e=0;e<this.jobs.length;e++)this.jobs[e].jobId&&this.jobs[e].fail(t||"Batch failed",i);if(this.jobId){window.clearTimeout(this.jobId);this.jobId=null}this.callback&&this.callback(this)}};r.ImageLoader=function(e){r.extend(!0,this,{jobLimit:r.DEFAULT_SETTINGS.imageLoaderLimit,timeout:r.DEFAULT_SETTINGS.timeout,jobQueue:[],failedTiles:[],jobsInProgress:0},e);this._batchBuckets=[]};r.ImageLoader.prototype={addJob:function(t){if(!t.source){r.console.error("ImageLoader.prototype.addJob() requires [options.source]...");t.source=r.TileSource.prototype}const i=this,e={src:t.src,tile:t.tile||{},source:t.source,loadWithAjax:t.loadWithAjax,ajaxHeaders:t.loadWithAjax?t.ajaxHeaders:null,crossOriginPolicy:t.crossOriginPolicy,ajaxWithCredentials:t.ajaxWithCredentials,postData:t.postData,callback:e=>function(t,e,i){if(e.errorMsg&&null===e.data&&e.tries<1+t.tileRetryMax){e.isBatched=!1;t.failedTiles.push(e)}e.isBatched||t.jobsInProgress--;if(t.canAcceptNewJob()&&0<t.jobQueue.length){let e=t.jobQueue.shift();e.start();t.jobsInProgress++}if(0<t.tileRetryMax&&0===t.jobQueue.length&&t.canAcceptNewJob()&&0<t.failedTiles.length){let e=t.failedTiles.shift();setTimeout(function(){e.start()},t.tileRetryDelay);t.jobsInProgress++}i&&i(e.data,e.errorMsg,e.request,e.dataType,e.tries)}(i,e,t.callback),abort:t.abort,timeout:this.timeout},n=new r.ImageJob(e);if(t.source&&t.source.batchEnabled()){n.isBatched=!0;this._stageJobForBatching(n,t.source);return!1}if(!this.jobLimit||this.jobsInProgress<this.jobLimit){n.start();this.jobsInProgress++;return!0}this.jobQueue.push(n);return!1},_stageJobForBatching:function(e,t){let i=null;for(let e=0;e<this._batchBuckets.length;e++)if(this._batchBuckets[e].source.batchCompatible(t)){i=this._batchBuckets[e];break}if(i&&!i.timer){r.console.error("Attempted to add a new job to a batch bucket that has already been flushed. Creating a new batch bucket for this source. Check batch logic and timing if this happens frequently. Bucket source:",t,"Job ID:",e&&e.jobId);i=null}if(!i){i={source:t,jobs:[],timer:null,waitTimeout:t.batchTimeout(),maxJobs:t.batchMaxJobs()};i.timer=setTimeout(()=>this._flushBatchBucket(i),i.waitTimeout);this._batchBuckets.push(i)}i.jobs.push(e);if(1<=i.maxJobs&&i.jobs.length>=i.maxJobs){clearTimeout(i.timer);this._flushBatchBucket(i)}},_flushBatchBucket:function(e){e.timer=null;var t=this._batchBuckets.indexOf(e);-1<t&&this._batchBuckets.splice(t,1);if(0!==e.jobs.length){const i=this;const n=new r.BatchImageJob({source:e.source,jobs:e.jobs,timeout:this.timeout,callback:e=>function(e,t){e.jobsInProgress--;t.jobs.length=0}(i,e)});if(!this.jobLimit||this.jobsInProgress<this.jobLimit){n.start();this.jobsInProgress++}else this.jobQueue.push(n)}},canAcceptNewJob(){return!this.jobLimit||this.jobsInProgress<this.jobLimit},clear:function(){for(let e=0;e<this.jobQueue.length;e++){const t=this.jobQueue[e];"function"==typeof t.abort&&t.abort()}this.jobQueue=[];if(this._batchBuckets){for(let e=0;e<this._batchBuckets.length;e++){const i=this._batchBuckets[e];clearTimeout(i.timer);i.timer=null}this._batchBuckets=[]}}}}(OpenSeadragon);!function(d){d.Tile=function(e,t,i,n,r,o,s,a,l,h,c,u){this.level=e;this.x=t;this.y=i;this.bounds=n;this.positionedBounds=new OpenSeadragon.Rect(n.x,n.y,n.width,n.height);this.sourceBounds=h;this.exists=r;this._url=o;this.postData=c;s&&(this.context2D=s);this.loadWithAjax=a;this.ajaxHeaders=l;if(void 0===u){d.console.warn("Tile constructor needs 'cacheKey' variable: creation tile cache in Tile class is deprecated. TileSource.prototype.getTileHashKey will be used.");u=d.TileSource.prototype.getTileHashKey(e,t,i,o,l,c)}this._cKey=u||"";this._ocKey=u||"";this.loaded=!1;this.loading=!1;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;this.tiledImage=null;this._caches={};this.processing=!1;this.processingPromise=d.Promise.resolve(this)};d.Tile.prototype={toString:function(){return this.level+"/"+this.x+"_"+this.y},get cacheKey(){return this._cKey},set cacheKey(e){if(e!==this.cacheKey){this.getCache(e)||d.console.warn("[Tile.cacheKey] should not be set manually. Use addCache() with setAsMain=true.");this._updateMainCacheKey(e)}},set originalCacheKey(e){throw"Original Cache Key cannot be managed manually!"},get originalCacheKey(){return this._ocKey},get image(){d.console.error("[Tile.image] property has been deprecated. Use [Tile.getData] instead.");return this.getImage()},get url(){d.console.error("[Tile.url] property has been deprecated. Use [Tile.getUrl] instead.");return this.getUrl()},get element(){d.console.error("Tile::element property is deprecated. Use cache API instead. Moreover, this property might be unstable.");var e=this.getCache();if(!e||!e.loaded)return null;if(e.type===OpenSeadragon.HTMLDrawer.canvasCacheType&&e.type===OpenSeadragon.HTMLDrawer.imageCacheType)return e.data.element;d.console.error("Access to HtmlDrawer property via Tile instance: HTMLDrawer must be used!");return null},get imgElement(){d.console.error("Tile::imgElement property is deprecated. Use cache API instead. Moreover, this property might be unstable.");var e=this.getCache();if(!e||!e.loaded)return null;if(e.type===OpenSeadragon.HTMLDrawer.canvasCacheType&&e.type===OpenSeadragon.HTMLDrawer.imageCacheType)return e.data.imgElement;d.console.error("Access to HtmlDrawer property via Tile instance: HTMLDrawer must be used!");return null},get style(){d.console.error("Tile::style property is deprecated. Use cache API instead. Moreover, this property might be unstable.");var e=this.getCache();if(!e||!e.loaded)return null;if(e.type===OpenSeadragon.HTMLDrawer.canvasCacheType&&e.type===OpenSeadragon.HTMLDrawer.imageCacheType)return e.data.style;d.console.error("Access to HtmlDrawer property via Tile instance: HTMLDrawer must be used!");return null},getImage:function(){d.console.error("[Tile.getImage] property has been deprecated. Use 'tile-invalidated' routine event instead.");const e=this.getCache(this.cacheKey);if(e){e.transformTo("image");return e.data}},getUrl:function(){return"function"==typeof this._url?this._url():this._url},getCanvasContext:function(){d.console.error("[Tile.getCanvasContext] property has been deprecated. Use 'tile-invalidated' routine event instead.");const e=this.getCache(this.cacheKey);if(e){e.transformTo("context2d");return e.data}},get context2D(){d.console.error("[Tile.context2D] property has been deprecated. Use 'tile-invalidated' routine event instead.");return this.getCanvasContext()},set context2D(e){d.console.error("[Tile.context2D] property has been deprecated. Use 'tile-invalidated' routine event instead.");this._caches[this.cacheKey]&&this.removeCache(this.cacheKey);this.addCache(this.cacheKey,e,"context2d",!0,!1)},get cacheImageRecord(){d.console.error("[Tile.cacheImageRecord] property has been deprecated. Use Tile::getCache.");return this.getCache(this.cacheKey)},set cacheImageRecord(t){d.console.error("[Tile.cacheImageRecord] property has been deprecated. Use Tile::addCache.");this._caches[this.cacheKey]&&this.removeCache(this.cacheKey);t&&(t.loaded?this.addCache(this.cacheKey,t.data,t.type,!0,!1):t.await().then(e=>this.addCache(this.cacheKey,e,t.type,!0,!1)))},buildDistinctMainCacheKey:function(){return this.cacheKey===this.originalCacheKey?"mod://"+this.originalCacheKey:this.cacheKey},getCache:function(e=this._cKey){const t=this._caches[e];t&&t.withTileReference(this);return t},addCache:function(e,t,i=void 0,n=!1,r=!0){const o=this.tiledImage;if(!o)return null;if(!i){if(!this.__typeWarningReported){d.console.warn(this,"[Tile.addCache] called without type specification. Automated deduction is potentially unsafe: prefer specification of data type explicitly.");this.__typeWarningReported=!0}"function"==typeof t&&d.console.error("[TileCache.cacheTile] options.data as a callback requires type argument! Current is "+i);i=d.converter.guessType(t)}var s=e===this.cacheKey;if(r&&(s||n)){r=o.getDrawer().getSupportedDataFormats();const l=d.converter.getConversionPath(i,r);d.console.assert(l,"[Tile.addCache] data was set for the default tile cache we are unable"+`to render. Make sure OpenSeadragon.converter was taught to convert ${i} to (one of): `+l.toString())}i=o._tileCache.cacheTile({data:t,dataType:i,tile:this,cacheKey:e,cutoff:o.source.getClosestLevel()});const a=this._caches[e];if(a!==i){this._caches[e]=i;if(a){a.removeTile(this);o._tileCache.safeUnloadCache(a)}}!s&&n&&this._updateMainCacheKey(e);return i},setCache(e,t,i=!1,n=!0){const r=this.tiledImage;if(!r)return null;var o=e===this.cacheKey;if(n){d.console.assert(t instanceof d.CacheRecord,"[Tile.setCache] cache must be a CacheRecord object!");if(o||i){n=r.getDrawer().getSupportedDataFormats();const a=d.converter.getConversionPath(t.type,n);d.console.assert(a,"[Tile.setCache] data was set for the default tile cache we are unable"+`to render. Make sure OpenSeadragon.converter was taught to convert ${t.type} to (one of): `+a.toString())}}const s=this._caches[e];if(s!==t){(this._caches[e]=t).addTile(this);if(s){s.removeTile(this);r._tileCache.safeUnloadCache(s)}}!o&&i&&this._updateMainCacheKey(e);return t},_updateMainCacheKey:function(e){let t=this._caches[this._cKey];t&&t.destroyInternalCache();this._cKey=e},getCacheSize:function(){return Object.keys(this._caches).length},removeCache:function(e,t=!0){var i=this._caches[e];if(i){var n=this.cacheKey,r=this.originalCacheKey,o=n===r;if(o||r!==e){if(n===e){if(o||!this._caches[r]){d.console.warn("[Tile.removeCache] trying to remove the only cache that can be used to draw the tile!","If you want to remove the main cache, first set different cache as main with tile.addCache()");return}this._updateMainCacheKey(r)}this.tiledImage._tileCache.unloadCacheForTile(this,e,t,!1)&&delete this._caches[e];return i}d.console.warn("[Tile.removeCache] original data must not be manually deleted: other parts of the code might rely on it!","If you want the tile not to preserve the original data, toggle of data perseverance in tile.setData().")}else this.tiledImage._tileCache.unloadCacheForTile(this,e,t,!0)},getScaleForEdgeSmoothing:function(){d.console.warn("[Tile.getScaleForEdgeSmoothing] is deprecated, the following error is the consequence:");var e=this.getCanvasContext();if(e)return e.canvas.width/(this.size.x*d.pixelDensityRatio);d.console.warn("[Tile.drawCanvas] attempting to get tile scale %s when tile's not cached",this.toString());return 1},getTranslationForEdgeSmoothing:function(e,t,i){var n=Math.max(1,Math.ceil((i.x-t.x)/2));t=Math.max(1,Math.ceil((i.y-t.y)/2));return new d.Point(n,t).minus(this.position.times(d.pixelDensityRatio).times(e||1).apply(function(e){return e%1}))},reflectCacheRenamed:function(e,t){var i=this._caches[e];if(i){e===this._ocKey&&(this._ocKey=t);e===this._cKey&&(this._cKey=t);this._caches[t]=i;delete this._caches[e]}},equals(e){return this._ocKey===e._ocKey},unload:function(e=!1){this.loaded&&this.tiledImage._tileCache.unloadTile(this,e)},_unload:function(){this.tiledImage=null;this._caches={};this.loaded=!1;this.loading=!1;this._cKey=this._ocKey}}}(OpenSeadragon);!function(h){h.OverlayPlacement=h.Placement;h.OverlayRotationMode=h.freezeObject({NO_ROTATION:1,EXACT:2,BOUNDING_BOX:3});h.Overlay=function(e,t,i){let n;n=h.isPlainObject(e)?e:{element:e,location:t,placement:i};this.elementWrapper=document.createElement("div");this.element=n.element;this.elementWrapper.appendChild(this.element);this.element.id&&(this.elementWrapper.id="overlay-wrapper-"+this.element.id);this.elementWrapper.classList.add("openseadragon-overlay-wrapper");this.style=this.elementWrapper.style;this._init(n)};h.Overlay.prototype={_init:function(e){this.location=e.location;this.placement=void 0===e.placement?h.Placement.TOP_LEFT:e.placement;this.onDraw=e.onDraw;this.checkResize=void 0===e.checkResize||e.checkResize;this.width=void 0===e.width?null:e.width;this.height=void 0===e.height?null:e.height;this.rotationMode=e.rotationMode||h.OverlayRotationMode.EXACT;if(this.location instanceof h.Rect){this.width=this.location.width;this.height=this.location.height;this.location=this.location.getTopLeft();this.placement=h.Placement.TOP_LEFT}this.scales=null!==this.width&&null!==this.height;this.bounds=new h.Rect(this.location.x,this.location.y,this.width,this.height);this.position=this.location},adjust:function(e,t){var i=h.Placement.properties[this.placement];if(i){i.isHorizontallyCentered?e.x-=t.x/2:i.isRight&&(e.x-=t.x);i.isVerticallyCentered?e.y-=t.y/2:i.isBottom&&(e.y-=t.y)}},destroy:function(){const e=this.elementWrapper;const t=this.style;if(e.parentNode){e.parentNode.removeChild(e);if(e.prevElementParent){t.display="none";document.body.appendChild(e)}}this.onDraw=null;t.top="";t.left="";t.position="";null!==this.width&&(t.width="");null!==this.height&&(t.height="");var i=h.getCssPropertyWithVendorPrefix("transformOrigin");var n=h.getCssPropertyWithVendorPrefix("transform");if(i&&n){t[i]="";t[n]=""}},drawHTML:function(e,t){const i=this.elementWrapper;if(i.parentNode!==e){i.prevElementParent=i.parentNode;i.prevNextSibling=i.nextSibling;e.appendChild(i);this.style.position="absolute";this.size=h.getElementSize(this.elementWrapper)}var n=this._getOverlayPositionAndSize(t);var r=n.position;var o=this.size=n.size;let s="";t.overlayPreserveContentDirection&&(s=t.flipped?" scaleX(-1)":" scaleX(1)");e=t.flipped?-n.rotate:n.rotate;n=t.flipped?" scaleX(-1)":"";if(this.onDraw)this.onDraw(r,o,this.element);else{const a=this.style;const l=this.element.style;l.display="block";a.left=r.x+"px";a.top=r.y+"px";null!==this.width&&(l.width=o.x+"px");null!==this.height&&(l.height=o.y+"px");r=h.getCssPropertyWithVendorPrefix("transformOrigin");o=h.getCssPropertyWithVendorPrefix("transform");if(r&&o)if(e&&!t.flipped){l[o]="";a[r]=this._getTransformOrigin();a[o]="rotate("+e+"deg)"}else if(!e&&t.flipped){l[o]=s;a[r]=this._getTransformOrigin();a[o]=n}else if(e&&t.flipped){l[o]=s;a[r]=this._getTransformOrigin();a[o]="rotate("+e+"deg)"+n}else{l[o]="";a[r]="";a[o]=""}a.display="flex"}},_getOverlayPositionAndSize:function(e){let t=e.pixelFromPoint(this.location,!0);let i=this._getSizeInPixels(e);this.adjust(t,i);let n=0;if(e.getRotation(!0)&&this.rotationMode!==h.OverlayRotationMode.NO_ROTATION)if(this.rotationMode===h.OverlayRotationMode.BOUNDING_BOX&&null!==this.width&&null!==this.height){var r=new h.Rect(t.x,t.y,i.x,i.y);const o=this._getBoundingBox(r,e.getRotation(!0));t=o.getTopLeft();i=o.getSize()}else n=e.getRotation(!0);e.flipped&&(t.x=e.getContainerSize().x-t.x);return{position:t,size:i,rotate:n}},_getSizeInPixels:function(e){let t=this.size.x;let i=this.size.y;if(null!==this.width||null!==this.height){var n=e.deltaPixelsFromPointsNoRotate(new h.Point(this.width||0,this.height||0),!0);null!==this.width&&(t=n.x);null!==this.height&&(i=n.y)}if(this.checkResize&&(null===this.width||null===this.height)){n=this.size=h.getElementSize(this.elementWrapper);null===this.width&&(t=n.x);null===this.height&&(i=n.y)}return new h.Point(t,i)},_getBoundingBox:function(e,t){var i=this._getPlacementPoint(e);return e.rotate(t,i).getBoundingBox()},_getPlacementPoint:function(e){const t=new h.Point(e.x,e.y);var i=h.Placement.properties[this.placement];if(i){i.isHorizontallyCentered?t.x+=e.width/2:i.isRight&&(t.x+=e.width);i.isVerticallyCentered?t.y+=e.height/2:i.isBottom&&(t.y+=e.height)}return t},_getTransformOrigin:function(){let e="";var t=h.Placement.properties[this.placement];if(!t)return e;t.isLeft?e="left":t.isRight&&(e="right");t.isTop?e+=" top":t.isBottom&&(e+=" bottom");return e},update:function(e,t){t=h.isPlainObject(e)?e:{location:e,placement:t};this._init({location:t.location||this.location,placement:(void 0!==t.placement?t:this).placement,onDraw:t.onDraw||this.onDraw,checkResize:t.checkResize||this.checkResize,width:(void 0!==t.width?t:this).width,height:(void 0!==t.height?t:this).height,rotationMode:t.rotationMode||this.rotationMode})},getBounds:function(e){h.console.assert(e,"A viewport must now be passed to Overlay.getBounds.");let t=this.width;let i=this.height;if(null===t||null===i){var n=e.deltaPointsFromPixelsNoRotate(this.size,!0);null===t&&(t=n.x);null===i&&(i=n.y)}n=this.location.clone();this.adjust(n,new h.Point(t,i));return this._adjustBoundsForRotation(e,new h.Rect(n.x,n.y,t,i))},_adjustBoundsForRotation:function(e,t){if(!e||0===e.getRotation(!0)||this.rotationMode===h.OverlayRotationMode.EXACT)return t;if(this.rotationMode!==h.OverlayRotationMode.BOUNDING_BOX)return t.rotate(-e.getRotation(!0),this._getPlacementPoint(t));if(null===this.width||null===this.height)return t;t=this._getOverlayPositionAndSize(e);return e.viewerElementToViewportRectangle(new h.Rect(t.position.x,t.position.y,t.size.x,t.size.y))}}}(OpenSeadragon);!function(n){const i=n;i.DrawerBase=class{constructor(e){n.console.assert(e.viewer,"[Drawer] options.viewer is required");n.console.assert(e.viewport,"[Drawer] options.viewport is required");n.console.assert(e.element,"[Drawer] options.element is required");this._id=this.getType()+n.now();this.viewer=e.viewer;this.viewport=e.viewport;this.debugGridColor="string"==typeof e.debugGridColor?[e.debugGridColor]:e.debugGridColor||n.DEFAULT_SETTINGS.debugGridColor;this.options=n.extend({usePrivateCache:!1,preloadCache:!0,offScreen:!1,broadCastTileInvalidation:!0},this.defaultOptions,e.options);this.container=n.getElement(e.element);this._renderingTarget=this._createDrawingElement();if(!this.options.offScreen){this.canvas.style.width="100%";this.canvas.style.height="100%";this.canvas.style.position="absolute";this.canvas.style.left="0";n.setElementOpacity(this.canvas,this.viewer.opacity,!0);n.setElementPointerEventsNone(this.canvas);n.setElementTouchActionNone(this.canvas);this.container.style.textAlign="left";this.container.appendChild(this.canvas);if(this.options.broadCastTileInvalidation){let e=this.viewer;for(;e.viewer;)e=e.viewer;this._parentViewer=e;e._registerDrawer(this)}else{this.viewer._registerDrawer(this);this._parentViewer=this.viewer}}this._checkInterfaceImplementation();this.setInternalCacheNeedsRefresh()}get defaultOptions(){return{}}get canvas(){return this._renderingTarget}get element(){n.console.error("Drawer.element is deprecated. Use Drawer.container instead.");return this.container}getId(){return this._id}getType(){n.console.error("Drawer.getType must be implemented by child class")}getRequiredDataFormats(){return this.getSupportedDataFormats()}getSupportedDataFormats(){throw"Drawer.getSupportedDataFormats must define its supported rendering data types!"}getDataToDraw(e){const t=e.getCache(e.cacheKey);if(t){var i=t.getDataForRendering(this,e);return i&&i.data}n.console.warn("Attempt to draw tile %s when not cached!",e)}static isSupported(){n.console.error("Drawer.isSupported must be implemented by child class")}_createDrawingElement(){n.console.error("Drawer._createDrawingElement must be implemented by child class");return null}draw(e){n.console.error("Drawer.draw must be implemented by child class")}canRotate(){n.console.error("Drawer.canRotate must be implemented by child class")}destroy(){this._parentViewer._unregisterDrawer(this)}destroyInternalCache(){this.viewer.tileCache.clearDrawerInternalCache(this)}minimumOverlapRequired(e){return!1}setImageSmoothingEnabled(e){n.console.error("Drawer.setImageSmoothingEnabled must be implemented by child class")}drawDebuggingRect(e){n.console.warn("[drawer].drawDebuggingRect is not implemented by this drawer")}clear(){n.console.warn("[drawer].clear() is deprecated. The drawer is responsible for clearing itself as needed before drawing tiles.")}internalCacheCreate(e,t){}internalCacheFree(e){}setInternalCacheNeedsRefresh(){this._dataNeedsRefresh=n.now()}tiledImageCreated(e){}_checkInterfaceImplementation(){if(this._createDrawingElement===n.DrawerBase.prototype._createDrawingElement)throw new Error("[drawer]._createDrawingElement must be implemented by child class");if(this.draw===n.DrawerBase.prototype.draw)throw new Error("[drawer].draw must be implemented by child class");if(this.canRotate===n.DrawerBase.prototype.canRotate)throw new Error("[drawer].canRotate must be implemented by child class");if(this.destroy===n.DrawerBase.prototype.destroy)throw new Error("[drawer].destroy must be implemented by child class");if(this.setImageSmoothingEnabled===n.DrawerBase.prototype.setImageSmoothingEnabled)throw new Error("[drawer].setImageSmoothingEnabled must be implemented by child class")}viewportToDrawerRectangle(e){var t=this.viewport.pixelFromPointNoRotate(e.getTopLeft(),!0);e=this.viewport.deltaPixelsFromPointsNoRotate(e.getSize(),!0);return new n.Rect(t.x*n.pixelDensityRatio,t.y*n.pixelDensityRatio,e.x*n.pixelDensityRatio,e.y*n.pixelDensityRatio)}viewportCoordToDrawerCoord(e){e=this.viewport.pixelFromPointNoRotate(e,!0);return new n.Point(e.x*n.pixelDensityRatio,e.y*n.pixelDensityRatio)}_calculateCanvasSize(){var e=n.pixelDensityRatio;var t=this.viewport.getContainerSize();return new i.Point(Math.round(t.x*e),Math.round(t.y*e))}_raiseTiledImageDrawnEvent(e,t){this.viewer&&this.viewer.raiseEvent("tiled-image-drawn",{tiledImage:e,tiles:t})}_raiseDrawerErrorEvent(e,t){this.viewer&&this.viewer.raiseEvent("drawer-error",{tiledImage:e,drawer:this,error:t})}}}(OpenSeadragon);!function(o){var e=o;class t extends e.DrawerBase{constructor(e){super(e);this.viewer.rejectEventHandler("tile-drawing","The HTMLDrawer does not raise the tile-drawing event");this.viewer.allowEventHandler("tile-drawn");o.converter.learn("image",t.imageCacheType,function(e,t){var i=o.makeNeutralElement("div");const n=t.cloneNode();n.style.msInterpolationMode="nearest-neighbor";n.style.width="100%";n.style.height="100%";const r=i.style;r.position="absolute";return{element:i,imgElement:n,style:r,data:t}},1,1);o.converter.learn(t.imageCacheType,"image",(e,t)=>t.data,1,3);o.converter.learnDestroy(t.imageCacheType,function(e){e.imgElement&&e.imgElement.parentNode&&e.imgElement.parentNode.removeChild(e.imgElement);e.element&&e.element.parentNode&&e.element.parentNode.removeChild(e.element)})}static get imageCacheType(){return"htmlDrawer[image]"}static get canvasCacheType(){return"htmlDrawer[canvas]"}static isSupported(){return!0}getType(){return"html"}getSupportedDataFormats(){return[t.imageCacheType,t.canvasCacheType]}minimumOverlapRequired(e){return!0}_createDrawingElement(){return o.makeNeutralElement("div")}draw(e){const t=this;this._prepareNewFrame();e.forEach(function(e){0!==e.opacity&&t._drawTiles(e)})}canRotate(){return!1}destroy(){super.destroy();this.container.removeChild(this.canvas)}setImageSmoothingEnabled(){}_prepareNewFrame(){this.canvas.innerHTML=""}_drawTiles(t){var i=t.getTilesToDraw().map(e=>e.tile);if(0!==t.opacity&&(0!==i.length||t.placeholderFillStyle))for(let e=i.length-1;0<=e;e--){var n=i[e];this._drawTile(n);this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:t,tile:n})}}_drawTile(e){o.console.assert(e,"[Drawer._drawTile] tile is required");let t=this.canvas;if(e.loaded){const i=this.getDataToDraw(e);if(i){i.element.parentNode!==t&&t.appendChild(i.element);i.imgElement.parentNode!==i.element&&i.element.appendChild(i.imgElement);i.style.top=e.position.y+"px";i.style.left=e.position.x+"px";i.style.height=e.size.y+"px";i.style.width=e.size.x+"px";e.flipped&&(i.style.transform="scaleX(-1)");o.setElementOpacity(i.element,e.opacity)}}else o.console.warn("Attempting to draw tile %s when it's not yet loaded.",e.toString())}}o.HTMLDrawer=t}(OpenSeadragon);!function(d){var e=d;class t extends e.DrawerBase{constructor(e){super(e);this.context=this.canvas.getContext("2d");this.sketchCanvas=null;this.sketchContext=null;this._imageSmoothingEnabled=!0;this.viewer.allowEventHandler("tile-drawn");this.viewer.allowEventHandler("tile-drawing")}static isSupported(){return d.supportsCanvas}getType(){return"canvas"}getSupportedDataFormats(){return["context2d"]}_createDrawingElement(){const e=d.makeNeutralElement("canvas");var t=this._calculateCanvasSize();e.width=t.x;e.height=t.y;return e}draw(e){this._prepareNewFrame();this.viewer.viewport.getFlip()!==this._viewportFlipped&&this._flip();for(const t of e)0!==t.opacity&&this._drawTiles(t)}canRotate(){return!0}destroy(){super.destroy();this.canvas.width=1;this.canvas.height=1;this.sketchCanvas=null;this.sketchContext=null;this.container.removeChild(this.canvas)}minimumOverlapRequired(e){return!0}setImageSmoothingEnabled(e){this._imageSmoothingEnabled=!!e;this._updateImageSmoothingEnabled(this.context);this.viewer.forceRedraw()}drawDebuggingRect(e){const t=this.context;t.save();t.lineWidth=2*d.pixelDensityRatio;t.strokeStyle=this.debugGridColor[0];t.fillStyle=this.debugGridColor[0];t.strokeRect(e.x*d.pixelDensityRatio,e.y*d.pixelDensityRatio,e.width*d.pixelDensityRatio,e.height*d.pixelDensityRatio);t.restore()}get _viewportFlipped(){return this.context.getTransform().a<0}_raiseTileDrawingEvent(e,t,i,n){this.viewer.raiseEvent("tile-drawing",{tiledImage:e,context:t,tile:i,rendered:n})}_prepareNewFrame(){var e=this._calculateCanvasSize();if(this.canvas.width!==e.x||this.canvas.height!==e.y){this.canvas.width=e.x;this.canvas.height=e.y;this._updateImageSmoothingEnabled(this.context);if(null!==this.sketchCanvas){e=this._calculateSketchCanvasSize();this.sketchCanvas.width=e.x;this.sketchCanvas.height=e.y;this._updateImageSmoothingEnabled(this.sketchContext)}}this._clear()}_clear(e,t){const i=this._getContext(e);if(t)i.clearRect(t.x,t.y,t.width,t.height);else{t=i.canvas;i.clearRect(0,0,t.width,t.height)}}_drawTiles(a){var l=a.getTilesToDraw().map(e=>e.tile);if(0!==a.opacity&&(0!==l.length||a.placeholderFillStyle)){let t=l[0];let i;t&&(i=a.opacity<1||a.compositeOperation&&"source-over"!==a.compositeOperation||!a._isBottomItem()&&a.source.hasTransparency(null,t.getUrl(),t.ajaxHeaders,t.postData));let n;let r;var h=this.viewport.getZoom(!0);h=a.viewportToImageZoom(h);if(1<l.length&&h>a.smoothTileEdgesMinZoom&&!a.iOSDevice&&a.getRotation(!0)%360==0){i=!0;h=t.length&&this.getDataToDraw(t);n=h?h.canvas.width/(t.size.x*d.pixelDensityRatio):1;r=t.getTranslationForEdgeSmoothing(n,this._getCanvasSize(!1),this._getCanvasSize(!0))}let e;if(i){if(!n){e=this.viewport.viewportToViewerElementRectangle(a.getClippedBounds(!0)).getIntegerBoundingBox();e=e.times(d.pixelDensityRatio)}this._clear(!0,e)}n||this._setRotations(a,i);let o=!1;if(a._clip){this._saveContext(i);let e=a.imageToViewportRectangle(a._clip,!0);e=e.rotate(-a.getRotation(!0),a._getRotationPoint(!0));let t=this.viewportToDrawerRectangle(e);n&&(t=t.times(n));r&&(t=t.translate(r));this._setClip(t,i);o=!0}if(a._croppingPolygons){const u=this;o||this._saveContext(i);try{var c=a._croppingPolygons.map(function(e){return e.map(function(e){e=a.imageToViewportCoordinates(e.x,e.y,!0).rotate(-a.getRotation(!0),a._getRotationPoint(!0));let t=u.viewportCoordToDrawerCoord(e);n&&(t=t.times(n));r&&(t=t.plus(r));return t})});this._clipWithPolygons(c,i)}catch(e){d.console.error(e)}o=!0}a._hasOpaqueTile=!1;if(a.placeholderFillStyle&&!1===a._hasOpaqueTile){let e=this.viewportToDrawerRectangle(a.getBoundsNoRotate(!0));n&&(e=e.times(n));r&&(e=e.translate(r));let t=null;t="function"==typeof a.placeholderFillStyle?a.placeholderFillStyle(a,this.context):a.placeholderFillStyle;this._drawRectangle(e,t,i)}c=function(e){if("number"==typeof e)return m(e);if(!e||!d.Browser)return p;let t=e[d.Browser.vendor];g(t)&&(t=e["*"]);return m(t)}(a.subPixelRoundingForTransparency);let s=!1;c===d.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS?s=!0:c===d.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&(s=!(this.viewer&&this.viewer.isAnimating()));for(let e=0;e<l.length;e++){t=l[e];this._drawTile(t,a,i,n,r,s,a.source);this.viewer&&this.viewer.raiseEvent("tile-drawn",{tiledImage:a,tile:t})}o&&this._restoreContext(i);if(!n){a.getRotation(!0)%360!=0&&this._restoreRotationChanges(i);this.viewport.getRotation(!0)%360!=0&&this._restoreRotationChanges(i)}if(i){n&&this._setRotations(a);this.blendSketch({opacity:a.opacity,scale:n,translate:r,compositeOperation:a.compositeOperation,bounds:e});if(n){a.getRotation(!0)%360!=0&&this._restoreRotationChanges(!1);this.viewport.getRotation(!0)%360!=0&&this._restoreRotationChanges(!1)}}this._drawDebugInfo(a,l);this._raiseTiledImageDrawnEvent(a,l)}}_drawDebugInfo(t,i){if(t.debugMode)for(let e=i.length-1;0<=e;e--){var n=i[e];try{this._drawDebugInfoOnTile(n,i.length,e,t)}catch(e){d.console.error(e)}}}_clipWithPolygons(e,t){const i=this._getContext(t);i.beginPath();for(const o of e)for(var[n,r]of o.entries())i[0===n?"moveTo":"lineTo"](r.x,r.y);i.clip()}_drawTile(r,o,s,a,l,h,e){d.console.assert(r,"[Drawer._drawTile] tile is required");d.console.assert(o,"[Drawer._drawTile] drawingHandler is required");if(r.loaded){var c=this.getDataToDraw(r);if(c){const u=this._getContext(s);a=a||1;let e=r.position.times(d.pixelDensityRatio),t=r.size.times(d.pixelDensityRatio);u.save();if("number"==typeof a&&1!==a){e=e.times(a);t=t.times(a)}l instanceof d.Point&&(e=e.plus(l));if(1===u.globalAlpha&&r.hasTransparency){if(h){e.x=Math.round(e.x);e.y=Math.round(e.y);t.x=Math.round(t.x);t.y=Math.round(t.y)}u.clearRect(e.x,e.y,t.x,t.y)}this._raiseTileDrawingEvent(o,u,r,c);let i,n;if(r.sourceBounds){i=Math.min(r.sourceBounds.width,c.canvas.width);n=Math.min(r.sourceBounds.height,c.canvas.height)}else{i=c.canvas.width;n=c.canvas.height}u.translate(e.x+t.x/2,0);r.flipped&&u.scale(-1,1);u.drawImage(c.canvas,0,0,i,n,-t.x/2,e.y,t.x,t.y);u.restore()}}else d.console.warn("Attempting to draw tile %s when it's not yet loaded.",r.toString())}_getContext(e){let t=this.context;if(e){if(null===this.sketchCanvas){this.sketchCanvas=document.createElement("canvas");e=this._calculateSketchCanvasSize();this.sketchCanvas.width=e.x;this.sketchCanvas.height=e.y;this.sketchContext=this.sketchCanvas.getContext("2d");if(0===this.viewport.getRotation()){const i=this;this.viewer.addHandler("rotate",function e(){if(0!==i.viewport.getRotation()){i.viewer.removeHandler("rotate",e);var t=i._calculateSketchCanvasSize();i.sketchCanvas.width=t.x;i.sketchCanvas.height=t.y}})}this._updateImageSmoothingEnabled(this.sketchContext)}t=this.sketchContext}return t}_saveContext(e){this._getContext(e).save()}_restoreContext(e){this._getContext(e).restore()}_setClip(e,t){const i=this._getContext(t);i.beginPath();i.rect(e.x,e.y,e.width,e.height);i.clip()}_drawRectangle(e,t,i){const n=this._getContext(i);n.save();n.fillStyle=t;n.fillRect(e.x,e.y,e.width,e.height);n.restore()}blendSketch(i,n,r,o){let s=i;d.isPlainObject(s)||(s={opacity:i,scale:n,translate:r,compositeOperation:o});i=s.opacity;o=s.compositeOperation;const e=s.bounds;this.context.save();this.context.globalAlpha=i;o&&(this.context.globalCompositeOperation=o);if(e){if(e.x<0){e.width+=e.x;e.x=0}e.x+e.width>this.canvas.width&&(e.width=this.canvas.width-e.x);if(e.y<0){e.height+=e.y;e.y=0}e.y+e.height>this.canvas.height&&(e.height=this.canvas.height-e.y);this.context.drawImage(this.sketchCanvas,e.x,e.y,e.width,e.height,e.x,e.y,e.width,e.height)}else{n=s.scale||1;i=(r=s.translate)instanceof d.Point?r:new d.Point(0,0);let e=0;let t=0;if(r){o=this.sketchCanvas.width-this.canvas.width;r=this.sketchCanvas.height-this.canvas.height;e=Math.round(o/2);t=Math.round(r/2)}this.context.drawImage(this.sketchCanvas,i.x-e*n,i.y-t*n,(this.canvas.width+2*e)*n,(this.canvas.height+2*t)*n,-e,-t,this.canvas.width+2*e,this.canvas.height+2*t)}this.context.restore()}_drawDebugInfoOnTile(e,t,i,n){var r=this.viewer.world.getIndexOfItem(n)%this.debugGridColor.length;const o=this.context;o.save();o.lineWidth=2*d.pixelDensityRatio;o.font="small-caps bold "+13*d.pixelDensityRatio+"px arial";o.strokeStyle=this.debugGridColor[r];o.fillStyle=this.debugGridColor[r];this._setRotations(n);this._viewportFlipped&&this._flip({point:e.position.plus(e.size.divide(2))});o.strokeRect(e.position.x*d.pixelDensityRatio,e.position.y*d.pixelDensityRatio,e.size.x*d.pixelDensityRatio,e.size.y*d.pixelDensityRatio);var s=(e.position.x+e.size.x/2)*d.pixelDensityRatio;var a=(e.position.y+e.size.y/2)*d.pixelDensityRatio;o.translate(s,a);r=this.viewport.getRotation(!0);o.rotate(Math.PI/180*-r);o.translate(-s,-a);if(0===e.x&&0===e.y){o.fillText("Zoom: "+this.viewport.getZoom(),e.position.x*d.pixelDensityRatio,(e.position.y-30)*d.pixelDensityRatio);o.fillText("Pan: "+this.viewport.getBounds().toString(),e.position.x*d.pixelDensityRatio,(e.position.y-20)*d.pixelDensityRatio)}o.fillText("Level: "+e.level,(e.position.x+10)*d.pixelDensityRatio,(e.position.y+20)*d.pixelDensityRatio);o.fillText("Column: "+e.x,(e.position.x+10)*d.pixelDensityRatio,(e.position.y+30)*d.pixelDensityRatio);o.fillText("Row: "+e.y,(e.position.x+10)*d.pixelDensityRatio,(e.position.y+40)*d.pixelDensityRatio);o.fillText("Order: "+i+" of "+t,(e.position.x+10)*d.pixelDensityRatio,(e.position.y+50)*d.pixelDensityRatio);o.fillText("Size: "+e.size.toString(),(e.position.x+10)*d.pixelDensityRatio,(e.position.y+60)*d.pixelDensityRatio);o.fillText("Position: "+e.position.toString(),(e.position.x+10)*d.pixelDensityRatio,(e.position.y+70)*d.pixelDensityRatio);this.viewport.getRotation(!0)%360!=0&&this._restoreRotationChanges();n.getRotation(!0)%360!=0&&this._restoreRotationChanges();o.restore()}_updateImageSmoothingEnabled(e){e.msImageSmoothingEnabled=this._imageSmoothingEnabled;e.imageSmoothingEnabled=this._imageSmoothingEnabled}_getCanvasSize(e){e=this._getContext(e).canvas;return new d.Point(e.width,e.height)}_getCanvasCenter(){return new d.Point(this.canvas.width/2,this.canvas.height/2)}_setRotations(e,t=!1){let i=!1;if(this.viewport.getRotation(!0)%360!=0){this._offsetForRotation({degrees:this.viewport.getRotation(!0),useSketch:t,saveContext:i});i=!1}e.getRotation(!0)%360!=0&&this._offsetForRotation({degrees:e.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(e._getRotationPoint(!0),!0),useSketch:t,saveContext:i})}_offsetForRotation(e){var t=e.point?e.point.times(d.pixelDensityRatio):this._getCanvasCenter();const i=this._getContext(e.useSketch);i.save();i.translate(t.x,t.y);i.rotate(Math.PI/180*e.degrees);i.translate(-t.x,-t.y)}_flip(e){var t=(e=e||{}).point?e.point.times(d.pixelDensityRatio):this._getCanvasCenter();const i=this._getContext(e.useSketch);i.translate(t.x,0);i.scale(-1,1);i.translate(-t.x,0)}_restoreRotationChanges(e){const t=this._getContext(e);t.restore()}_calculateCanvasSize(){var e=d.pixelDensityRatio;var t=this.viewport.getContainerSize();return{x:Math.round(t.x*e),y:Math.round(t.y*e)}}_calculateSketchCanvasSize(){var e=this._calculateCanvasSize();if(0===this.viewport.getRotation())return e;e=Math.ceil(Math.sqrt(e.x*e.x+e.y*e.y));return{x:e,y:e}}}d.CanvasDrawer=t;const p=d.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER;function g(e){return e!==d.SUBPIXEL_ROUNDING_OCCURRENCES.ALWAYS&&e!==d.SUBPIXEL_ROUNDING_OCCURRENCES.ONLY_AT_REST&&e!==d.SUBPIXEL_ROUNDING_OCCURRENCES.NEVER}function m(e){return g(e)?p:e}}(OpenSeadragon);!function(C){const l=C;class d{constructor(e){this._renderingCanvas=e.renderingCanvas;this._unpackWithPremultipliedAlpha=!!e.unpackWithPremultipliedAlpha;this._imageSmoothingEnabled=void 0===e.imageSmoothingEnabled||e.imageSmoothingEnabled;this._initShaderProgram=e.initShaderProgram;this._gl=null;this._isWebGL2=!1;this._extTextureFilterAnisotropic=null;this._maxAnisotropy=0;this._firstPass=null;this._secondPass=null;this._glFrameBuffer=null;this._renderToTexture=null;this._glNumTextures=0;this._unitQuad=null;this._destroyed=!1;this._gl=this._renderingCanvas.getContext("webgl2");if(this._gl){this._isWebGL2=!0;this._setupWebGLExtensions()}else{this._gl=this._renderingCanvas.getContext("webgl");this._isWebGL2=!1;this._gl&&this._setupWebGLExtensions()}this._gl&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._unpackWithPremultipliedAlpha)}getContext(){return this._gl}isWebGL2(){return this._isWebGL2}getMaxTextures(){return this._gl?this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS):0}getRenderingCanvas(){return this._renderingCanvas}getFirstPass(){return this._firstPass}getSecondPass(){return this._secondPass}getFrameBuffer(){return this._glFrameBuffer}getRenderToTexture(){return this._renderToTexture}getUnitQuad(){return this._unitQuad}_setupWebGLExtensions(){const e=this._gl;this._extTextureFilterAnisotropic=e.getExtension("EXT_texture_filter_anisotropic")||e.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||e.getExtension("MOZ_EXT_texture_filter_anisotropic");this._extTextureFilterAnisotropic&&(this._maxAnisotropy=e.getParameter(this._extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT))}getTextureFilter(){var e=this._gl;return this._imageSmoothingEnabled?e.LINEAR:e.NEAREST}_applyAnisotropy(){if(this._imageSmoothingEnabled&&this._extTextureFilterAnisotropic&&!(this._maxAnisotropy<=0)){const e=this._gl;e.texParameterf(e.TEXTURE_2D,this._extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(4,this._maxAnisotropy))}}setupRenderer(e,t){const i=this._gl;if(i){this._unitQuad=this.makeQuadVertexBuffer(0,1,0,1);this._makeFirstPassShaderProgram();this._makeSecondPassShaderProgram();this._renderToTexture=i.createTexture();i.activeTexture(i.TEXTURE0);i.bindTexture(i.TEXTURE_2D,this._renderToTexture);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.getTextureFilter());this._applyAnisotropy();i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);this._glFrameBuffer=i.createFramebuffer();i.bindFramebuffer(i.FRAMEBUFFER,this._glFrameBuffer);i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this._renderToTexture,0);i.enable(i.BLEND);i.blendFunc(i.ONE,i.ONE_MINUS_SRC_ALPHA)}else C.console.error("WebGL context not available for setupRenderer")}resizeRenderer(e,t){const i=this._gl;if(i){i.viewport(0,0,e,t);i.deleteTexture(this._renderToTexture);this._renderToTexture=i.createTexture();i.activeTexture(i.TEXTURE0);i.bindTexture(i.TEXTURE_2D,this._renderToTexture);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,e,t,0,i.RGBA,i.UNSIGNED_BYTE,null);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.getTextureFilter());this._applyAnisotropy();i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);i.bindFramebuffer(i.FRAMEBUFFER,this._glFrameBuffer);i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,this._renderToTexture,0)}}createTexture(e,t={}){const i=this._gl;if(!i)return null;var n=i.createTexture();i.activeTexture(i.TEXTURE0);i.bindTexture(i.TEXTURE_2D,n);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,this.getTextureFilter());i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,this.getTextureFilter());this._applyAnisotropy();try{var r=void 0!==t.unpackWithPremultipliedAlpha?t.unpackWithPremultipliedAlpha:this._unpackWithPremultipliedAlpha;i.pixelStorei(i.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,e);return n}catch(e){i.deleteTexture(n);return null}}deleteTexture(e){this._gl&&e&&this._gl.deleteTexture(e)}setImageSmoothingEnabled(e){this._imageSmoothingEnabled=!!e}setUnpackWithPremultipliedAlpha(e){this._unpackWithPremultipliedAlpha=!!e;this._gl&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this._unpackWithPremultipliedAlpha)}makeQuadVertexBuffer(e,t,i,n){return new Float32Array([e,n,t,n,e,i,e,i,t,n,t,i])}_makeFirstPassShaderProgram(){const t=this._glNumTextures=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);var e=`
attribute vec2 a_output_position;
attribute vec2 a_texture_position;
attribute float a_index;
${[...Array(t).keys()].map(e=>`uniform mat3 u_matrix_${e};`).join("\n")} // create a uniform mat3 for each potential tile to draw
varying vec2 v_texture_position;
varying float v_image_index;
void main() {
mat3 transform_matrix; // value will be set by the if/elses in makeConditional()
${[...Array(t).keys()].map(e=>`${0<e?"else ":""}if(int(a_index) == ${e}) { transform_matrix = u_matrix_${e}; }`).join("\n")}
gl_Position = vec4(transform_matrix * vec3(a_output_position, 1), 1);
v_texture_position = a_texture_position;
v_image_index = a_index;
}
`;var i=`
precision mediump float;
// our textures
uniform sampler2D u_images[${t}];
// our opacities
uniform float u_opacities[${t}];
// the varyings passed in from the vertex shader.
varying vec2 v_texture_position;
varying float v_image_index;
void main() {
// can't index directly with a variable, need to use a loop iterator hack
for(int i = 0; i < ${t}; ++i){
if(i == int(v_image_index)){
gl_FragColor = texture2D(u_images[i], v_texture_position) * u_opacities[i];
}
}
}
`;const n=this._gl;const r=this._initShaderProgram(n,e,i);n.useProgram(r);this._firstPass={shaderProgram:r,aOutputPosition:n.getAttribLocation(r,"a_output_position"),aTexturePosition:n.getAttribLocation(r,"a_texture_position"),aIndex:n.getAttribLocation(r,"a_index"),uTransformMatrices:[...Array(this._glNumTextures).keys()].map(e=>n.getUniformLocation(r,"u_matrix_"+e)),uImages:n.getUniformLocation(r,"u_images"),uOpacities:n.getUniformLocation(r,"u_opacities"),bufferOutputPosition:n.createBuffer(),bufferTexturePosition:n.createBuffer(),bufferIndex:n.createBuffer()};n.uniform1iv(this._firstPass.uImages,[...Array(t).keys()]);const o=new Float32Array(12*t);for(let e=0;e<t;++e)o.set(Float32Array.from(this._unitQuad),12*e);n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferOutputPosition);n.bufferData(n.ARRAY_BUFFER,o,n.STATIC_DRAW);n.enableVertexAttribArray(this._firstPass.aOutputPosition);n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferTexturePosition);n.enableVertexAttribArray(this._firstPass.aTexturePosition);n.bindBuffer(n.ARRAY_BUFFER,this._firstPass.bufferIndex);i=[...Array(this._glNumTextures).keys()].map(e=>Array(6).fill(e)).flat();n.bufferData(n.ARRAY_BUFFER,new Float32Array(i),n.STATIC_DRAW);n.enableVertexAttribArray(this._firstPass.aIndex)}_makeSecondPassShaderProgram(){const e=this._gl;var t=this._initShaderProgram(e,`
attribute vec2 a_output_position;
attribute vec2 a_texture_position;
varying vec2 v_texture_position;
void main() {
// Transform to clip space (0:1 --> -1:1)
gl_Position = vec4(vec3(a_output_position * 2.0 - 1.0, 1), 1);
v_texture_position = a_texture_position;
}
`,`
precision mediump float;
// our texture
uniform sampler2D u_image;
// the texCoords passed in from the vertex shader.
varying vec2 v_texture_position;
// the opacity multiplier for the image
uniform float u_opacity_multiplier;
void main() {
gl_FragColor = texture2D(u_image, v_texture_position);
gl_FragColor *= u_opacity_multiplier;
}
`);e.useProgram(t);this._secondPass={shaderProgram:t,aOutputPosition:e.getAttribLocation(t,"a_output_position"),aTexturePosition:e.getAttribLocation(t,"a_texture_position"),uImage:e.getUniformLocation(t,"u_image"),uOpacityMultiplier:e.getUniformLocation(t,"u_opacity_multiplier"),bufferOutputPosition:e.createBuffer(),bufferTexturePosition:e.createBuffer()};e.bindBuffer(e.ARRAY_BUFFER,this._secondPass.bufferOutputPosition);e.bufferData(e.ARRAY_BUFFER,this._unitQuad,e.STATIC_DRAW);e.enableVertexAttribArray(this._secondPass.aOutputPosition);e.bindBuffer(e.ARRAY_BUFFER,this._secondPass.bufferTexturePosition);e.bufferData(e.ARRAY_BUFFER,this._unitQuad,e.DYNAMIC_DRAW);e.enableVertexAttribArray(this._secondPass.aTexturePosition)}destroy(){if(!this._destroyed){this._destroyed=!0;const i=this._gl;if(i){try{var t=i.getParameter(i.MAX_TEXTURE_IMAGE_UNITS);if(t&&0<t)for(let e=0;e<t;++e){i.activeTexture(i.TEXTURE0+e);i.bindTexture(i.TEXTURE_2D,null);i.bindTexture(i.TEXTURE_CUBE_MAP,null)}i.bindBuffer(i.ARRAY_BUFFER,null);i.bindBuffer(i.ELEMENT_ARRAY_BUFFER,null);i.bindRenderbuffer(i.RENDERBUFFER,null);i.bindFramebuffer(i.FRAMEBUFFER,null);this._secondPass&&this._secondPass.bufferOutputPosition&&i.deleteBuffer(this._secondPass.bufferOutputPosition);this._glFrameBuffer&&i.deleteFramebuffer(this._glFrameBuffer)}catch(e){C.console.warn("Error during WebGL cleanup in WebglContextManager.destroy():",e)}const e=i.getExtension("WEBGL_lose_context");e&&e.loseContext()}this._gl=null;this._firstPass=null;this._secondPass=null;this._glFrameBuffer=null;this._renderToTexture=null;this._unitQuad=null}}isDestroyed(){return this._destroyed}}l.WebGLDrawer=class p extends l.DrawerBase{constructor(e){super(e);this._destroyed=!1;this._glContext=null;this._enableContextRecovery=!0;this._outputCanvas=null;this._outputContext=null;this._clippingCanvas=null;this._clippingContext=null;this._renderingCanvas=null;this._backupCanvasDrawer=null;this._canvasFallbackAllowed=this.viewer.drawerCandidates&&this.viewer.drawerCandidates.includes("canvas");this._imageSmoothingEnabled=!0;this._unpackWithPremultipliedAlpha=!!this.options.unpackWithPremultipliedAlpha;this.viewer.rejectEventHandler("tile-drawn","The WebGLDrawer does not raise the tile-drawn event");this.viewer.rejectEventHandler("tile-drawing","The WebGLDrawer does not raise the tile-drawing event");this._setupCanvases();this._setupRenderer();this._supportedFormats=["context2d","image"];this.context=this._outputContext}get defaultOptions(){return{usePrivateCache:!0,preloadCache:!1,unpackWithPremultipliedAlpha:!1}}getSupportedDataFormats(){return this._supportedFormats}destroy(){if(!this._destroyed){super.destroy();if(this._resizeHandler){this.viewer.removeHandler("resize",this._resizeHandler);this._resizeHandler=null}if(this._glContext){this._glContext.destroy();this._glContext=null}this._renderingCanvas&&(this._renderingCanvas.width=this._renderingCanvas.height=1);this._clippingCanvas&&(this._clippingCanvas.width=this._clippingCanvas.height=1);this._outputCanvas&&(this._outputCanvas.width=this._outputCanvas.height=1);this._renderingCanvas=null;this._clippingCanvas=this._clippingContext=null;this._outputCanvas=this._outputContext=null;if(this._backupCanvasDrawer){this._backupCanvasDrawer.destroy();this._backupCanvasDrawer=null}this.container.removeChild(this.canvas);this.viewer.drawer===this&&(this.viewer.drawer=null);this.destroyInternalCache();this._destroyed=!0}}canRotate(){return!0}static isSupported(){let e=null;let t=null;let i=null;try{const l=document.createElement("canvas");l.width=4;l.height=4;if(!C.isFunction(l.getContext))return!1;i=l.getContext("webgl2")||l.getContext("webgl");if(!i)return!1;e=new d({renderingCanvas:l,unpackWithPremultipliedAlpha:!1,imageSmoothingEnabled:!0,initShaderProgram:p.initShaderProgram});if(!e.getContext())return!1;e.setupRenderer(4,4);var n=e.getFirstPass();var r=e.getFrameBuffer();if(!n||!r)return!1;var o=e.getMaxTextures();if(!o||o<=0)return!1;const h=new ImageData(4,4);h.data[0]=255;h.data[1]=0;h.data[2]=0;h.data[3]=255;t=e.createTexture(h);if(!t)return!1;var s=e.makeQuadVertexBuffer(0,1,0,1);i.viewport(0,0,4,4);i.bindFramebuffer(i.FRAMEBUFFER,r);i.clearColor(0,0,0,0);i.clear(i.COLOR_BUFFER_BIT);i.useProgram(n.shaderProgram);i.activeTexture(i.TEXTURE0);i.bindTexture(i.TEXTURE_2D,t);i.bindBuffer(i.ARRAY_BUFFER,n.bufferTexturePosition);i.bufferData(i.ARRAY_BUFFER,s,i.DYNAMIC_DRAW);var a=new Float32Array([2,0,0,0,2,0,-1,-1,1]);i.uniformMatrix3fv(n.uTransformMatrices[0],!1,a);i.uniform1fv(n.uOpacities,new Float32Array([1]));i.bindBuffer(i.ARRAY_BUFFER,n.bufferOutputPosition);i.vertexAttribPointer(n.aOutputPosition,2,i.FLOAT,!1,0,0);i.bindBuffer(i.ARRAY_BUFFER,n.bufferTexturePosition);i.vertexAttribPointer(n.aTexturePosition,2,i.FLOAT,!1,0,0);i.bindBuffer(i.ARRAY_BUFFER,n.bufferIndex);i.vertexAttribPointer(n.aIndex,1,i.FLOAT,!1,0,0);i.drawArrays(i.TRIANGLES,0,6);const c=new Uint8Array(64);i.readPixels(0,0,4,4,i.RGBA,i.UNSIGNED_BYTE,c);if(c.some(e=>0!==e))return!0;C.console.warn("[WebGLDrawer.isSupported] Functional test failed: no non-zero pixels read back.");return!1}catch(e){C.console.warn("[WebGLDrawer.isSupported] Functional test failed:",e&&e.message?e.message:e);return!1}finally{try{t&&e&&e.deleteTexture(t);if(e)e.destroy();else if(i){const u=i.getExtension("WEBGL_lose_context");u&&u.loseContext()}}catch(e){}}}getType(){return"webgl"}isWebGL2(){return!!this._glContext&&this._glContext.isWebGL2()}setContextRecoveryEnabled(e){this._enableContextRecovery=!!e}isContextRecoveryEnabled(){return this._enableContextRecovery}minimumOverlapRequired(e){return e.hasIssue("webgl")}_createDrawingElement(){const e=C.makeNeutralElement("canvas");var t=this._calculateCanvasSize();e.width=t.x;e.height=t.y;return e}_getBackupCanvasDrawer(){if(!this._backupCanvasDrawer){this._backupCanvasDrawer=this.viewer.requestDrawer("canvas",{mainDrawer:!1});this._backupCanvasDrawer.canvas.style.setProperty("visibility","hidden");this._backupCanvasDrawer.getSupportedDataFormats=()=>this._supportedFormats;this._backupCanvasDrawer.getDataToDraw=this.getDataToDraw.bind(this)}return this._backupCanvasDrawer}_draw(e,t=0){const w=this._glContext?this._glContext.getContext():null;if(w){const _=this._glContext.getFirstPass();const T=this._glContext.getSecondPass();const x=this._glContext.getFrameBuffer();const S=this._glContext.getRenderToTexture();var i=this.viewport.getBoundsNoRotateWithMargins(!0);const r=i,o=new l.Point(i.x+i.width/2,i.y+i.height/2),s=this.viewport.getRotation(!0)*Math.PI/180;var n=this.viewport.flipped?-1:1;i=C.Mat3.makeTranslation(-o.x,-o.y);const a=C.Mat3.makeScaling(2/r.width*n,-2/r.height);n=C.Mat3.makeRotation(-s);const E=a.multiply(n).multiply(i);w.bindFramebuffer(w.FRAMEBUFFER,null);w.clear(w.COLOR_BUFFER_BIT);this._outputContext.clearRect(0,0,this._outputCanvas.width,this._outputCanvas.height);let y=!1;e.forEach((i,e)=>{if(i.getIssue("webgl")){if(y){this._outputContext.drawImage(this._renderingCanvas,0,0);w.bindFramebuffer(w.FRAMEBUFFER,null);w.clear(w.COLOR_BUFFER_BIT);y=!1}if(this._canvasFallbackAllowed){const t=this._getBackupCanvasDrawer();t.draw([i]);this._outputContext.drawImage(t.canvas,0,0)}}else{const m=i.getTilesToDraw();i.placeholderFillStyle&&!1===i._hasOpaqueTile&&this._drawPlaceholder(i);if(0!==m.length&&0!==i.getOpacity()){var n=m[0];var r=i.compositeOperation||this.viewer.compositeOperation||i._clip||i._croppingPolygons||i.debugMode;var o=r||i.opacity<1||n.tile.hasTransparency;if(r){y&&this._outputContext.drawImage(this._renderingCanvas,0,0);w.bindFramebuffer(w.FRAMEBUFFER,null);w.clear(w.COLOR_BUFFER_BIT)}w.useProgram(_.shaderProgram);if(o){w.bindFramebuffer(w.FRAMEBUFFER,x);w.clear(w.COLOR_BUFFER_BIT)}else w.bindFramebuffer(w.FRAMEBUFFER,null);let t=E;var s=i.getRotation(!0);if(s%360!=0){n=C.Mat3.makeRotation(-s*Math.PI/180);s=i.getBoundsNoRotate(!0).getCenter();const v=C.Mat3.makeTranslation(s.x,s.y);s=C.Mat3.makeTranslation(-s.x,-s.y);s=v.multiply(n).multiply(s);t=E.multiply(s)}var a=this._glContext.getMaxTextures();if(a<=0||null==a)throw new Error(`WebGL error: bad value for gl parameter MAX_TEXTURE_IMAGE_UNITS (${a}). This could happen
if too many contexts have been created and not released, or there is another problem with the graphics card.`);var l=new Float32Array(12*a);var h=new Array(a);const f=new Array(a);var c=new Array(a);for(let e=0;e<m.length;e++){var u=m[e].tile;var d=e%a;var p=1+d;var g=this.getDataToDraw(u);g&&g.texture&&this._getTileData(u,i,g,t,d,l,h,f,c);if(p===a||e===m.length-1){for(let e=0;e<p;e++){w.activeTexture(w.TEXTURE0+e);w.bindTexture(w.TEXTURE_2D,h[e])}w.bindBuffer(w.ARRAY_BUFFER,_.bufferTexturePosition);w.bufferData(w.ARRAY_BUFFER,l,w.DYNAMIC_DRAW);f.forEach((e,t)=>{w.uniformMatrix3fv(_.uTransformMatrices[t],!1,e)});w.uniform1fv(_.uOpacities,new Float32Array(c));w.bindBuffer(w.ARRAY_BUFFER,_.bufferOutputPosition);w.vertexAttribPointer(_.aOutputPosition,2,w.FLOAT,!1,0,0);w.bindBuffer(w.ARRAY_BUFFER,_.bufferTexturePosition);w.vertexAttribPointer(_.aTexturePosition,2,w.FLOAT,!1,0,0);w.bindBuffer(w.ARRAY_BUFFER,_.bufferIndex);w.vertexAttribPointer(_.aIndex,1,w.FLOAT,!1,0,0);w.drawArrays(w.TRIANGLES,0,6*p)}}if(o){w.useProgram(T.shaderProgram);w.bindFramebuffer(w.FRAMEBUFFER,null);w.activeTexture(w.TEXTURE0);w.bindTexture(w.TEXTURE_2D,S);w.uniform1f(T.uOpacityMultiplier,i.opacity);w.bindBuffer(w.ARRAY_BUFFER,T.bufferTexturePosition);w.vertexAttribPointer(T.aTexturePosition,2,w.FLOAT,!1,0,0);w.bindBuffer(w.ARRAY_BUFFER,T.bufferOutputPosition);w.vertexAttribPointer(T.aOutputPosition,2,w.FLOAT,!1,0,0);w.drawArrays(w.TRIANGLES,0,6)}y=!0;if(r){this._applyContext2dPipeline(i,m,e);y=!1;w.bindFramebuffer(w.FRAMEBUFFER,null);w.clear(w.COLOR_BUFFER_BIT)}0===e&&this._raiseTiledImageDrawnEvent(i,m.map(e=>e.tile))}}});y&&this._outputContext.drawImage(this._renderingCanvas,0,0)}}draw(t,i=!1){try{this._draw(t,i)}catch(e){if(!this._isWebGLContextError(e))throw e;if(this._enableContextRecovery&&!i){C.console.warn("WebGL context error detected during draw operation, attempting to recreate context...",e);if(this._recreateContext()){C.console.info("WebGL context recreated successfully, retrying draw operation");this.viewer&&this.viewer.raiseEvent("webgl-context-recovered",{drawer:this,error:e});this.draw(t,!0)}else this._fallbackToCanvasDrawer(e,t)}else{if(!this._enableContextRecovery)throw e;this._fallbackToCanvasDrawer(e,t)}}}setImageSmoothingEnabled(e){if(this._imageSmoothingEnabled!==e){this._imageSmoothingEnabled=e;this._glContext&&this._glContext.setImageSmoothingEnabled(e);this.setInternalCacheNeedsRefresh();this.viewer.forceRedraw()}}setUnpackWithPremultipliedAlpha(e){if(this._unpackWithPremultipliedAlpha!==e){this._unpackWithPremultipliedAlpha=e;this._glContext&&this._glContext.setUnpackWithPremultipliedAlpha(e);this.setInternalCacheNeedsRefresh();this.viewer.forceRedraw()}}drawDebuggingRect(e){const t=this._outputContext;t.save();t.lineWidth=2*C.pixelDensityRatio;t.strokeStyle=this.debugGridColor[0];t.fillStyle=this.debugGridColor[0];t.strokeRect(e.x*C.pixelDensityRatio,e.y*C.pixelDensityRatio,e.width*C.pixelDensityRatio,e.height*C.pixelDensityRatio);t.restore()}_applyContext2dPipeline(e,t,i){this._outputContext.save();this._outputContext.globalCompositeOperation=0===i?null:e.compositeOperation||this.viewer.compositeOperation;if(e._croppingPolygons||e._clip){this._renderToClippingCanvas(e);this._outputContext.drawImage(this._clippingCanvas,0,0)}else this._outputContext.drawImage(this._renderingCanvas,0,0);this._outputContext.restore();if(e.debugMode){i=this.viewer.viewport.getFlip();i&&this._flip();this._drawDebugInfo(t,e,i);i&&this._flip()}}_getTileData(e,t,i,n,r,o,s,a,l){var h=i.texture;var c=i.position;var u=i.overlapFraction;o.set(c,12*r);i=e.positionedBounds.width*u.x;o=e.positionedBounds.height*u.y;c=e.positionedBounds.x+(0===e.x?0:i);u=e.positionedBounds.y+(0===e.y?0:o);i=e.positionedBounds.x+e.positionedBounds.width-(e.isRightMost?0:i);o=e.positionedBounds.y+e.positionedBounds.height-(e.isBottomMost?0:o);const d=new C.Mat3([i-c,0,0,0,o-u,0,c,u,1]);e.flipped&&d.scaleAndTranslateSelf(-1,1,1,0);d.scaleAndTranslateOtherSetSelf(n);l[r]=e.opacity;s[r]=h;a[r]=d.values}_setupRenderer(){this._glContext&&this._glContext.getContext()?this._glContext.setupRenderer(this._renderingCanvas.width,this._renderingCanvas.height):C.console.error("_setupCanvases must be called before _setupRenderer")}_resizeRenderer(){this._glContext&&this._glContext.resizeRenderer(this._renderingCanvas.width,this._renderingCanvas.height)}_setupCanvases(){const t=this;this._outputCanvas=this.canvas;this._outputContext=this._outputCanvas.getContext("2d");this._renderingCanvas=document.createElement("canvas");this._clippingCanvas=document.createElement("canvas");this._clippingContext=this._clippingCanvas.getContext("2d");this._renderingCanvas.width=this._clippingCanvas.width=this._outputCanvas.width;this._renderingCanvas.height=this._clippingCanvas.height=this._outputCanvas.height;this._glContext=new d({renderingCanvas:this._renderingCanvas,unpackWithPremultipliedAlpha:this._unpackWithPremultipliedAlpha,imageSmoothingEnabled:this._imageSmoothingEnabled,initShaderProgram:this.constructor.initShaderProgram});this._resizeHandler=function(){if(t._outputCanvas!==t.viewer.drawer.canvas){t._outputCanvas.style.width=t.viewer.drawer.canvas.clientWidth+"px";t._outputCanvas.style.height=t.viewer.drawer.canvas.clientHeight+"px"}var e=t._calculateCanvasSize();if(t._outputCanvas.width!==e.x||t._outputCanvas.height!==e.y){t._outputCanvas.width=e.x;t._outputCanvas.height=e.y}t._renderingCanvas.style.width=t._outputCanvas.clientWidth+"px";t._renderingCanvas.style.height=t._outputCanvas.clientHeight+"px";t._renderingCanvas.width=t._clippingCanvas.width=t._outputCanvas.width;t._renderingCanvas.height=t._clippingCanvas.height=t._outputCanvas.height;t._resizeRenderer()};this.viewer.addHandler("resize",this._resizeHandler)}_isWebGLContextError(e){if(!e||!e.message)return!1;const t=e.message.toLowerCase();return t.includes("max_texture_image_units")||t.includes("webgl")&&(t.includes("context")||t.includes("lost")||t.includes("invalid"))}_recreateContext(){if(this._destroyed)return null;try{var e=this._renderingCanvas;var t=e.width;var i=e.height;var n=e.style.width;var r=e.style.height;this.destroyInternalCache();if(this._glContext){this._glContext.destroy();this._glContext=null}this._renderingCanvas=document.createElement("canvas");this._renderingCanvas.width=t;this._renderingCanvas.height=i;n&&(this._renderingCanvas.style.width=n);r&&(this._renderingCanvas.style.height=r);this._glContext=new d({renderingCanvas:this._renderingCanvas,unpackWithPremultipliedAlpha:this._unpackWithPremultipliedAlpha,imageSmoothingEnabled:this._imageSmoothingEnabled,initShaderProgram:this.constructor.initShaderProgram});if(!this._glContext.getContext()){C.console.error("Failed to recreate WebGL context: no GL context");return null}try{var o=this._glContext.getMaxTextures();if(!o||o<=0){C.console.error("Failed to recreate WebGL context: invalid MAX_TEXTURE_IMAGE_UNITS");return null}}catch(e){C.console.error("Failed to verify new WebGL context:",e);return null}this._setupRenderer();this.setInternalCacheNeedsRefresh();return this}catch(e){C.console.error("Failed to recreate WebGL context:",e);return null}}_fallbackToCanvasDrawer(e,t){if(!this._canvasFallbackAllowed){this._raiseContextRecoveryFailedEvent(e,null);throw e}var i=this.viewer.requestDrawer("canvas",{mainDrawer:!0,redrawImmediately:!1});if(!i){C.console.error("Failed to create canvas drawer as fallback");this._raiseContextRecoveryFailedEvent(e,null);throw e}C.console.error("Failed to recreate WebGL context, switching to canvas drawer");this._raiseContextRecoveryFailedEvent(e,i);this.viewer.world.requestInvalidate(!0)}_raiseContextRecoveryFailedEvent(e,t=null){this.viewer&&this.viewer.raiseEvent("webgl-context-recovery-failed",{drawer:this,canvasDrawer:t,error:e})}internalCacheCreate(i,n){const r=n.tiledImage;if(!(this._glContext?this._glContext.getContext():null)){C.console.error("WebGL context not available in internalCacheCreate");return{}}let o;let s=i.data;let e=!1;if(s instanceof CanvasRenderingContext2D){s=s.canvas;e=!0}if(!r.getIssue("webgl"))if(e&&C.isCanvasTainted(s)){r.setIssue("webgl","WebGL cannot be used to draw this TiledImage because it has tainted data. Does crossOriginPolicy need to be set?");this._raiseDrawerErrorEvent(r,this._canvasFallbackAllowed?"Tainted data cannot be used by the WebGLDrawer. Falling back to CanvasDrawer for this TiledImage.":"Tainted data cannot be used by the WebGLDrawer, and canvas fallback is not enabled.");this.setInternalCacheNeedsRefresh()}else{let e,t;if(n.sourceBounds){e=Math.min(n.sourceBounds.width,s.width)/s.width;t=Math.min(n.sourceBounds.height,s.height)/s.height}else{e=1;t=1}var a=r.source.tileOverlap;var l=this._calculateOverlapFraction(n,r);if(0<a){var h=(0===n.x?0:l.x)*e;i=(0===n.y?0:l.y)*t;a=(n.isRightMost?1:1-l.x)*e;var c=(n.isBottomMost?1:1-l.y)*t;o=this._glContext.makeQuadVertexBuffer(h,a,i,c)}else o=1===e&&1===t?this._glContext.getUnitQuad():this._glContext.makeQuadVertexBuffer(0,e,0,t);if(c=this._glContext.createTexture(s,{unpackWithPremultipliedAlpha:this._unpackWithPremultipliedAlpha}))return{texture:c,position:o,overlapFraction:l,glContext:this._glContext};r.setIssue("webgl","Error creating texture in WebGL.");l=this._canvasFallbackAllowed;this._raiseDrawerErrorEvent(r,l?"Unknown error when creating texture. Falling back to CanvasDrawer for this TiledImage.":"Cannot use WebGL for this TiledImage; canvas fallback is not enabled.");this.setInternalCacheNeedsRefresh()}if(s instanceof Image){const t=document.createElement("canvas");t.width=s.width;t.height=s.height;const u=t.getContext("2d",{willReadFrequently:!0});u.drawImage(s,0,0);s=u}if(s instanceof CanvasRenderingContext2D)return s;C.console.error("Unsupported data used for WebGL Drawer - probably a bug!");return{}}internalCacheFree(e){if(e&&e.texture){const t=e.glContext||this._glContext;if(t&&!t.isDestroyed())try{t.deleteTexture(e.texture)}catch(e){}e.texture=null;e.glContext=null}}_calculateOverlapFraction(e,t){var i=t.source.tileOverlap;var n=e.sourceBounds.width;t=e.sourceBounds.height;return{x:i/(n+((0===e.x?0:i)+(e.isRightMost?0:i))),y:i/(t+((0===e.y?0:i)+(e.isBottomMost?0:i)))}}_setClip(){}_renderToClippingCanvas(t){this._clippingContext.clearRect(0,0,this._clippingCanvas.width,this._clippingCanvas.height);this._clippingContext.save();if(this.viewer.viewport.getFlip()){var e=new C.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(e.x,0);this._clippingContext.scale(-1,1);this._clippingContext.translate(-e.x,0)}if(t._clip){const i=[{x:t._clip.x,y:t._clip.y},{x:t._clip.x+t._clip.width,y:t._clip.y},{x:t._clip.x+t._clip.width,y:t._clip.y+t._clip.height},{x:t._clip.x,y:t._clip.y+t._clip.height}];const n=i.map(e=>{e=t.imageToViewportCoordinates(e.x,e.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(e)});this._clippingContext.beginPath();n.forEach((e,t)=>{this._clippingContext[0===t?"moveTo":"lineTo"](e.x,e.y)});this._clippingContext.clip();this._setClip()}if(t._croppingPolygons){const r=t._croppingPolygons.map(e=>e.map(e=>{e=t.imageToViewportCoordinates(e.x,e.y,!0).rotate(this.viewer.viewport.getRotation(!0),this.viewer.viewport.getCenter(!0));return this.viewportCoordToDrawerCoord(e)}));this._clippingContext.beginPath();r.forEach(e=>{e.forEach((e,t)=>{this._clippingContext[0===t?"moveTo":"lineTo"](e.x,e.y)})});this._clippingContext.clip()}if(this.viewer.viewport.getFlip()){e=new C.Point(this.canvas.width/2,this.canvas.height/2);this._clippingContext.translate(e.x,0);this._clippingContext.scale(-1,1);this._clippingContext.translate(-e.x,0)}this._clippingContext.drawImage(this._renderingCanvas,0,0);this._clippingContext.restore()}_setRotations(e){let t=!1;if(this.viewport.getRotation(!0)%360!=0){this._offsetForRotation({degrees:this.viewport.getRotation(!0),saveContext:t});t=!1}e.getRotation(!0)%360!=0&&this._offsetForRotation({degrees:e.getRotation(!0),point:this.viewport.pixelFromPointNoRotate(e._getRotationPoint(!0),!0),saveContext:t})}_offsetForRotation(e){var t=e.point?e.point.times(C.pixelDensityRatio):this._getCanvasCenter();const i=this._outputContext;i.save();i.translate(t.x,t.y);i.rotate(Math.PI/180*e.degrees);i.translate(-t.x,-t.y)}_flip(e){e=(e=e||{}).point?e.point.times(C.pixelDensityRatio):this._getCanvasCenter();const t=this._outputContext;t.translate(e.x,0);t.scale(-1,1);t.translate(-e.x,0)}_drawDebugInfo(t,i,n){for(let e=t.length-1;0<=e;e--){var r=t[e].tile;try{this._drawDebugInfoOnTile(r,t.length,e,i,n)}catch(e){C.console.error(e)}}}_drawDebugInfoOnTile(e,t,i,n,r){var o=this.viewer.world.getIndexOfItem(n)%this.debugGridColor.length;const s=this.context;s.save();s.lineWidth=2*C.pixelDensityRatio;s.font="small-caps bold "+13*C.pixelDensityRatio+"px arial";s.strokeStyle=this.debugGridColor[o];s.fillStyle=this.debugGridColor[o];this._setRotations(n);r&&this._flip({point:e.position.plus(e.size.divide(2))});s.strokeRect(e.position.x*C.pixelDensityRatio,e.position.y*C.pixelDensityRatio,e.size.x*C.pixelDensityRatio,e.size.y*C.pixelDensityRatio);var a=(e.position.x+e.size.x/2)*C.pixelDensityRatio;o=(e.position.y+e.size.y/2)*C.pixelDensityRatio;s.translate(a,o);r=this.viewport.getRotation(!0);s.rotate(Math.PI/180*-r);s.translate(-a,-o);if(0===e.x&&0===e.y){s.fillText("Zoom: "+this.viewport.getZoom(),e.position.x*C.pixelDensityRatio,(e.position.y-30)*C.pixelDensityRatio);s.fillText("Pan: "+this.viewport.getBounds().toString(),e.position.x*C.pixelDensityRatio,(e.position.y-20)*C.pixelDensityRatio)}s.fillText("Level: "+e.level,(e.position.x+10)*C.pixelDensityRatio,(e.position.y+20)*C.pixelDensityRatio);s.fillText("Column: "+e.x,(e.position.x+10)*C.pixelDensityRatio,(e.position.y+30)*C.pixelDensityRatio);s.fillText("Row: "+e.y,(e.position.x+10)*C.pixelDensityRatio,(e.position.y+40)*C.pixelDensityRatio);s.fillText("Order: "+i+" of "+t,(e.position.x+10)*C.pixelDensityRatio,(e.position.y+50)*C.pixelDensityRatio);s.fillText("Size: "+e.size.toString(),(e.position.x+10)*C.pixelDensityRatio,(e.position.y+60)*C.pixelDensityRatio);s.fillText("Position: "+e.position.toString(),(e.position.x+10)*C.pixelDensityRatio,(e.position.y+70)*C.pixelDensityRatio);this.viewport.getRotation(!0)%360!=0&&this._restoreRotationChanges();n.getRotation(!0)%360!=0&&this._restoreRotationChanges();s.restore()}_drawPlaceholder(e){var t=e.getBounds(!0);var i=this.viewportToDrawerRectangle(e.getBounds(!0));const n=this._outputContext;let r;r="function"==typeof e.placeholderFillStyle?e.placeholderFillStyle(e,n):e.placeholderFillStyle;this._offsetForRotation({degrees:this.viewer.viewport.getRotation(!0)});n.fillStyle=r;n.translate(i.x,i.y);n.rotate(Math.PI/180*t.degrees);n.translate(-i.x,-i.y);n.fillRect(i.x,i.y,i.width,i.height);this._restoreRotationChanges()}_getCanvasCenter(){return new C.Point(this.canvas.width/2,this.canvas.height/2)}_restoreRotationChanges(){const e=this._outputContext;e.restore()}static initShaderProgram(e,t,i){function n(e,t,i){t=e.createShader(t);e.shaderSource(t,i);e.compileShader(t);if(e.getShaderParameter(t,e.COMPILE_STATUS))return t;C.console.error("An error occurred compiling the shaders: "+e.getShaderInfoLog(t));e.deleteShader(t);return null}var r=n(e,e.VERTEX_SHADER,t);t=n(e,e.FRAGMENT_SHADER,i);i=e.createProgram();e.attachShader(i,r);e.attachShader(i,t);e.linkProgram(i);if(e.getProgramParameter(i,e.LINK_STATUS))return i;C.console.error("Unable to initialize the shader program: "+e.getProgramInfoLog(i));return null}}}(OpenSeadragon);!function(c){c.Viewport=function(e){var t=arguments;if((e=t.length&&t[0]instanceof c.Point?{containerSize:t[0],contentSize:t[1],config:t[2]}:e).config){c.extend(!0,e,e.config);delete e.config}this._margins=c.extend({left:0,top:0,right:0,bottom:0},e.margins||{});delete e.margins;e.initialDegrees=e.degrees;delete e.degrees;c.extend(!0,this,{containerSize:null,contentSize:null,zoomPoint:null,rotationPivot:null,viewer:null,springStiffness:c.DEFAULT_SETTINGS.springStiffness,animationTime:c.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:c.DEFAULT_SETTINGS.minZoomImageRatio,maxZoomPixelRatio:c.DEFAULT_SETTINGS.maxZoomPixelRatio,visibilityRatio:c.DEFAULT_SETTINGS.visibilityRatio,wrapHorizontal:c.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:c.DEFAULT_SETTINGS.wrapVertical,defaultZoomLevel:c.DEFAULT_SETTINGS.defaultZoomLevel,minZoomLevel:c.DEFAULT_SETTINGS.minZoomLevel,maxZoomLevel:c.DEFAULT_SETTINGS.maxZoomLevel,initialDegrees:c.DEFAULT_SETTINGS.degrees,flipped:c.DEFAULT_SETTINGS.flipped,homeFillsViewer:c.DEFAULT_SETTINGS.homeFillsViewer,silenceMultiImageWarnings:c.DEFAULT_SETTINGS.silenceMultiImageWarnings},e);this._updateContainerInnerSize();this.centerSpringX=new c.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime});this.centerSpringY=new c.Spring({initial:0,springStiffness:this.springStiffness,animationTime:this.animationTime});this.zoomSpring=new c.Spring({exponential:!0,initial:1,springStiffness:this.springStiffness,animationTime:this.animationTime});this.degreesSpring=new c.Spring({initial:e.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._sizeChanged=!1;this._setContentBounds(new c.Rect(0,0,1,1),1);this.goHome(!0);this.update()};c.Viewport.prototype={get degrees(){c.console.warn("Accessing [Viewport.degrees] is deprecated. Use viewport.getRotation instead.");return this.getRotation()},set degrees(e){c.console.warn("Setting [Viewport.degrees] is deprecated. Use viewport.rotateTo, viewport.rotateBy, or viewport.setRotation instead.");this.rotateTo(e)},resetContentSize:function(e){c.console.assert(e,"[Viewport.resetContentSize] contentSize is required");c.console.assert(e instanceof c.Point,"[Viewport.resetContentSize] contentSize must be an OpenSeadragon.Point");c.console.assert(0<e.x,"[Viewport.resetContentSize] contentSize.x must be greater than 0");c.console.assert(0<e.y,"[Viewport.resetContentSize] contentSize.y must be greater than 0");this._setContentBounds(new c.Rect(0,0,1,e.y/e.x),e.x);return this},setHomeBounds:function(e,t){c.console.error("[Viewport.setHomeBounds] this function is deprecated; The content bounds should not be set manually.");this._setContentBounds(e,t)},_setContentBounds:function(e,t){c.console.assert(e,"[Viewport._setContentBounds] bounds is required");c.console.assert(e instanceof c.Rect,"[Viewport._setContentBounds] bounds must be an OpenSeadragon.Rect");c.console.assert(0<e.width,"[Viewport._setContentBounds] bounds.width must be greater than 0");c.console.assert(0<e.height,"[Viewport._setContentBounds] bounds.height must be greater than 0");this._contentBoundsNoRotate=e.clone();this._contentSizeNoRotate=this._contentBoundsNoRotate.getSize().times(t);this._contentBounds=e.rotate(this.getRotation()).getBoundingBox();this._contentSize=this._contentBounds.getSize().times(t);this._contentAspectRatio=this._contentSize.x/this._contentSize.y;this.viewer&&this.viewer.raiseEvent("reset-size",{contentSize:this._contentSizeNoRotate.clone(),contentFactor:t,homeBounds:this._contentBoundsNoRotate.clone(),contentBounds:this._contentBounds.clone()})},getHomeZoom:function(){if(this.defaultZoomLevel)return this.defaultZoomLevel;var e=this._contentAspectRatio/this.getAspectRatio();let t;t=this.homeFillsViewer?1<=e?e:1:1<=e?1:e;return t/this._contentBounds.width},getHomeBounds:function(){return this.getHomeBoundsNoRotate().rotate(-this.getRotation())},getHomeBoundsNoRotate:function(){var e=this._contentBounds.getCenter();var t=1/this.getHomeZoom();var i=t/this.getAspectRatio();return new c.Rect(e.x-t/2,e.y-i/2,t,i)},goHome:function(e){this.viewer&&this.viewer.raiseEvent("home",{immediately:e});return this.fitBounds(this.getHomeBounds(),e)},getMinZoom:function(){var e=this.getHomeZoom();return this.minZoomLevel||this.minZoomImageRatio*e},getMaxZoom:function(){let e=this.maxZoomLevel;if(!e){e=this._contentSize.x*this.maxZoomPixelRatio/this._containerInnerSize.x;e/=this._contentBounds.width}return Math.max(e,this.getHomeZoom())},getAspectRatio:function(){return this._containerInnerSize.x/this._containerInnerSize.y},getContainerSize:function(){return new c.Point(this.containerSize.x,this.containerSize.y)},getMargins:function(){return c.extend({},this._margins)},setMargins:function(e){c.console.assert("object"===c.type(e),"[Viewport.setMargins] margins must be an object");this._margins=c.extend({left:0,top:0,right:0,bottom:0},e);this._updateContainerInnerSize();this.viewer&&this.viewer.forceRedraw()},getBounds:function(e){return this.getBoundsNoRotate(e).rotate(-this.getRotation(e))},getBoundsNoRotate:function(e){var t=this.getCenter(e);var i=1/this.getZoom(e);e=i/this.getAspectRatio();return new c.Rect(t.x-i/2,t.y-e/2,i,e)},getBoundsWithMargins:function(e){return this.getBoundsNoRotateWithMargins(e).rotate(-this.getRotation(e),this.getCenter(e))},getBoundsNoRotateWithMargins:function(e){const t=this.getBoundsNoRotate(e);e=this._containerInnerSize.x*this.getZoom(e);t.x-=this._margins.left/e;t.y-=this._margins.top/e;t.width+=(this._margins.left+this._margins.right)/e;t.height+=(this._margins.top+this._margins.bottom)/e;return t},getCenter:function(e){var t=new c.Point(this.centerSpringX.current.value,this.centerSpringY.current.value);const i=new c.Point(this.centerSpringX.target.value,this.centerSpringY.target.value);if(e)return t;if(!this.zoomPoint)return i;var n=this.pixelFromPoint(this.zoomPoint,!0);var r=this.getZoom();var o=1/r;e=o/this.getAspectRatio();e=new c.Rect(t.x-o/2,t.y-e/2,o,e);const s=this._pixelFromPoint(this.zoomPoint,e);const a=s.minus(n).rotate(-this.getRotation(!0));r=a.divide(this._containerInnerSize.x*r);return i.plus(r)},getZoom:function(e){return(e?this.zoomSpring.current:this.zoomSpring.target).value},_applyZoomConstraints:function(e){return Math.max(Math.min(e,this.getMaxZoom()),this.getMinZoom())},_applyBoundaryConstraints:function(e){const n=this.viewportToViewerElementRectangle(e).getBoundingBox();var r=this.viewportToViewerElementRectangle(this._contentBoundsNoRotate).getBoundingBox();let o=!1;let s=!1;if(!this.wrapHorizontal){var a=n.x+n.width;var l=r.x+r.width;let e,t,i;e=n.width>r.width?this.visibilityRatio*r.width:this.visibilityRatio*n.width;t=r.x-a+e;i=l-n.x-e;if(e>r.width){n.x+=(t+i)/2;o=!0}else if(i<0){n.x+=i;o=!0}else if(0<t){n.x+=t;o=!0}}if(!this.wrapVertical){a=n.y+n.height;l=r.y+r.height;let e,t,i;e=n.height>r.height?this.visibilityRatio*r.height:this.visibilityRatio*n.height;t=r.y-a+e;i=l-n.y-e;if(e>r.height){n.y+=(t+i)/2;s=!0}else if(i<0){n.y+=i;s=!0}else if(0<t){n.y+=t;s=!0}}r=o||s;const t=r?this.viewerElementToViewportRectangle(n):e.clone();t.xConstrained=o;t.yConstrained=s;t.constraintApplied=r;return t},_raiseConstraintsEvent:function(e){this.viewer&&this.viewer.raiseEvent("constrain",{immediately:e})},applyConstraints:function(e){var t=this.getZoom();var i=this._applyZoomConstraints(t);t!==i&&this.zoomTo(i,this.zoomPoint,e);i=this.getConstrainedBounds(!1);if(i.constraintApplied){this.fitBounds(i,e);this._raiseConstraintsEvent(e)}return this},ensureVisible:function(e){return this.applyConstraints(e)},_fitBounds:function(e,t){var i=(t=t||{}).immediately||!1;var n=t.constraints||!1;var r=this.getAspectRatio();var o=e.getCenter();const s=new c.Rect(e.x,e.y,e.width,e.height,e.degrees+this.getRotation()).getBoundingBox();s.getAspectRatio()>=r?s.height=s.width/r:s.width=s.height*r;s.x=o.x-s.width/2;s.y=o.y-s.height/2;let a=1/s.width;if(i){this.panTo(o,!0);this.zoomTo(a,null,!0);n&&this.applyConstraints(!0);return this}t=this.getCenter(!0);e=this.getZoom(!0);this.panTo(t,!0);this.zoomTo(e,null,!0);const l=this.getBounds();r=this.getZoom();if(0===r||Math.abs(a/r-1)<1e-8){this.zoomTo(a,null,!0);this.panTo(o,i);n&&this.applyConstraints(!1);return this}if(n){this.panTo(o,!1);a=this._applyZoomConstraints(a);this.zoomTo(a,null,!1);o=this.getConstrainedBounds();this.panTo(t,!0);this.zoomTo(e,null,!0);this.fitBounds(o)}else{const h=s.rotate(-this.getRotation());r=h.getTopLeft().times(a).minus(l.getTopLeft().times(r)).divide(a-r);this.zoomTo(a,r,i)}return this},fitBounds:function(e,t){return this._fitBounds(e,{immediately:t,constraints:!1})},fitBoundsWithConstraints:function(e,t){return this._fitBounds(e,{immediately:t,constraints:!0})},fitVertically:function(e){var t=new c.Rect(this._contentBounds.x+this._contentBounds.width/2,this._contentBounds.y,0,this._contentBounds.height);return this.fitBounds(t,e)},fitHorizontally:function(e){var t=new c.Rect(this._contentBounds.x,this._contentBounds.y+this._contentBounds.height/2,this._contentBounds.width,0);return this.fitBounds(t,e)},getConstrainedBounds:function(e){e=this.getBounds(e);return this._applyBoundaryConstraints(e)},panBy:function(e,t){const i=new c.Point;if(t){i.x=this.centerSpringX.current.value;i.y=this.centerSpringY.current.value}else{i.x=this.centerSpringX.target.value;i.y=this.centerSpringY.target.value}return this.panTo(i.plus(e),t)},panTo:function(e,t){if(t){this.centerSpringX.resetTo(e.x);this.centerSpringY.resetTo(e.y)}else{this.centerSpringX.springTo(e.x);this.centerSpringY.springTo(e.y)}this.viewer&&this.viewer.raiseEvent("pan",{center:e,immediately:t});return this},zoomBy:function(e,t,i){return this.zoomTo(this.zoomSpring.target.value*e,t,i)},zoomTo:function(e,t,i){const n=this;this.zoomPoint=t instanceof c.Point&&!isNaN(t.x)&&!isNaN(t.y)?t:null;i?this._adjustCenterSpringsForZoomPoint(function(){n.zoomSpring.resetTo(e)}):this.zoomSpring.springTo(e);this.viewer&&this.viewer.raiseEvent("zoom",{zoom:e,refPoint:t,immediately:i});return this},setRotation:function(e,t){return this.rotateTo(e,null,t)},getRotation:function(e){return(e?this.degreesSpring.current:this.degreesSpring.target).value},setRotationWithPivot:function(e,t,i){return this.rotateTo(e,t,i)},rotateTo:function(t,i,e){if(!this.viewer||!this.viewer.drawer.canRotate())return this;if(this.degreesSpring.target.value===t&&this.degreesSpring.isAtTargetValue())return this;this.rotationPivot=i instanceof c.Point&&!isNaN(i.x)&&!isNaN(i.y)?i:null;if(e)if(this.rotationPivot){if(!(t-this._oldDegrees)){this.rotationPivot=null;return this}this._rotateAboutPivot(t)}else this.degreesSpring.resetTo(t);else{var n=c.positiveModulo(this.degreesSpring.current.value,360);let e=c.positiveModulo(t,360);i=e-n;180<i?e-=360:i<-180&&(e+=360);n=n-e;this.degreesSpring.resetTo(t+n);this.degreesSpring.springTo(t)}this._setContentBounds(this.viewer.world.getHomeBounds(),this.viewer.world.getContentFactor());this.viewer.forceRedraw();this.viewer.raiseEvent("rotate",{degrees:t,immediately:!!e,pivot:this.rotationPivot||this.getCenter()});return this},rotateBy:function(e,t,i){return this.rotateTo(this.degreesSpring.target.value+e,t,i)},resize:function(e,t){var i=this.getBoundsNoRotate();const n=i;this._sizeChanged=!this.containerSize.equals(e);this.containerSize.x=e.x;this.containerSize.y=e.y;this._updateContainerInnerSize();if(t){r=e.x/this.containerSize.x;n.width=i.width*r;n.height=n.width/this.getAspectRatio()}this.viewer&&this.viewer.raiseEvent("resize",{newContainerSize:e,maintain:t});var r=this.fitBounds(n,!0);this.viewer&&this.viewer.raiseEvent("after-resize",{newContainerSize:e,maintain:t});return r},_updateContainerInnerSize:function(){this._containerInnerSize=new c.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(){const e=this;this._adjustCenterSpringsForZoomPoint(function(){e.zoomSpring.update()});this.degreesSpring.isAtTargetValue()&&(this.rotationPivot=null);this.centerSpringX.update();this.centerSpringY.update();this.rotationPivot?this._rotateAboutPivot(!0):this.degreesSpring.update();var t=this.centerSpringX.current.value!==this._oldCenterX||this.centerSpringY.current.value!==this._oldCenterY||this.zoomSpring.current.value!==this._oldZoom||this.degreesSpring.current.value!==this._oldDegrees||this._sizeChanged;this._sizeChanged=!1;this._oldCenterX=this.centerSpringX.current.value;this._oldCenterY=this.centerSpringY.current.value;this._oldZoom=this.zoomSpring.current.value;this._oldDegrees=this.degreesSpring.current.value;return t||!this.zoomSpring.isAtTargetValue()||!this.centerSpringX.isAtTargetValue()||!this.centerSpringY.isAtTargetValue()||!this.degreesSpring.isAtTargetValue()},_rotateAboutPivot:function(e){var t=!0===e;const i=this.rotationPivot.minus(this.getCenter());this.centerSpringX.shiftBy(i.x);this.centerSpringY.shiftBy(i.y);t?this.degreesSpring.update():this.degreesSpring.resetTo(e);e=this.degreesSpring.current.value-this._oldDegrees;e=i.rotate(-1*e).times(-1);this.centerSpringX.shiftBy(e.x);this.centerSpringY.shiftBy(e.y)},_adjustCenterSpringsForZoomPoint:function(e){if(this.zoomPoint){var t=this.pixelFromPoint(this.zoomPoint,!0);e();const i=this.pixelFromPoint(this.zoomPoint,!0);t=i.minus(t);t=this.deltaPointsFromPixels(t,!0);this.centerSpringX.shiftBy(t.x);this.centerSpringY.shiftBy(t.y);this.zoomSpring.isAtTargetValue()&&(this.zoomPoint=null)}else e()},deltaPixelsFromPointsNoRotate:function(e,t){return e.times(this._containerInnerSize.x*this.getZoom(t))},deltaPixelsFromPoints:function(e,t){return this.deltaPixelsFromPointsNoRotate(e.rotate(this.getRotation(t)),t)},deltaPointsFromPixelsNoRotate:function(e,t){return e.divide(this._containerInnerSize.x*this.getZoom(t))},deltaPointsFromPixels:function(e,t){return this.deltaPointsFromPixelsNoRotate(e,t).rotate(-this.getRotation(t))},pixelFromPointNoRotate:function(e,t){return this._pixelFromPointNoRotate(e,this.getBoundsNoRotate(t))},pixelFromPoint:function(e,t){return this._pixelFromPoint(e,this.getBoundsNoRotate(t))},_pixelFromPointNoRotate:function(e,t){return e.minus(t.getTopLeft()).times(this._containerInnerSize.x/t.width).plus(new c.Point(this._margins.left,this._margins.top))},_pixelFromPoint:function(e,t){return this._pixelFromPointNoRotate(e.rotate(this.getRotation(!0),this.getCenter(!0)),t)},pointFromPixelNoRotate:function(e,t){const i=this.getBoundsNoRotate(t);return e.minus(new c.Point(this._margins.left,this._margins.top)).divide(this._containerInnerSize.x/i.width).plus(i.getTopLeft())},pointFromPixel:function(e,t){return this.pointFromPixelNoRotate(e,t).rotate(-this.getRotation(t),this.getCenter(t))},_viewportToImageDelta:function(e,t){var i=this._contentBoundsNoRotate.width;return new c.Point(e*this._contentSizeNoRotate.x/i,t*this._contentSizeNoRotate.x/i)},viewportToImageCoordinates:function(e,t){if(e instanceof c.Point)return this.viewportToImageCoordinates(e.x,e.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(1<i)this.silenceMultiImageWarnings||c.console.error("[Viewport.viewportToImageCoordinates] is not accurate with multi-image; use TiledImage.viewportToImageCoordinates instead.");else if(1===i){const n=this.viewer.world.getItemAt(0);return n.viewportToImageCoordinates(e,t,!0)}}return this._viewportToImageDelta(e-this._contentBoundsNoRotate.x,t-this._contentBoundsNoRotate.y)},_imageToViewportDelta:function(e,t){var i=this._contentBoundsNoRotate.width;return new c.Point(e/this._contentSizeNoRotate.x*i,t/this._contentSizeNoRotate.x*i)},imageToViewportCoordinates:function(e,t){if(e instanceof c.Point)return this.imageToViewportCoordinates(e.x,e.y);if(this.viewer){var i=this.viewer.world.getItemCount();if(1<i)this.silenceMultiImageWarnings||c.console.error("[Viewport.imageToViewportCoordinates] is not accurate with multi-image; use TiledImage.imageToViewportCoordinates instead.");else if(1===i){const r=this.viewer.world.getItemAt(0);return r.imageToViewportCoordinates(e,t,!0)}}const n=this._imageToViewportDelta(e,t);n.x+=this._contentBoundsNoRotate.x;n.y+=this._contentBoundsNoRotate.y;return n},imageToViewportRectangle:function(e,t,i,n){let r=e;r instanceof c.Rect||(r=new c.Rect(e,t,i,n));if(this.viewer){var o=this.viewer.world.getItemCount();if(1<o)this.silenceMultiImageWarnings||c.console.error("[Viewport.imageToViewportRectangle] is not accurate with multi-image; use TiledImage.imageToViewportRectangle instead.");else if(1===o){const s=this.viewer.world.getItemAt(0);return s.imageToViewportRectangle(e,t,i,n,!0)}}i=this.imageToViewportCoordinates(r.x,r.y);n=this._imageToViewportDelta(r.width,r.height);return new c.Rect(i.x,i.y,n.x,n.y,r.degrees)},viewportToImageRectangle:function(e,t,i,n){let r=e;r instanceof c.Rect||(r=new c.Rect(e,t,i,n));if(this.viewer){var o=this.viewer.world.getItemCount();if(1<o)this.silenceMultiImageWarnings||c.console.error("[Viewport.viewportToImageRectangle] is not accurate with multi-image; use TiledImage.viewportToImageRectangle instead.");else if(1===o){const s=this.viewer.world.getItemAt(0);return s.viewportToImageRectangle(e,t,i,n,!0)}}i=this.viewportToImageCoordinates(r.x,r.y);n=this._viewportToImageDelta(r.width,r.height);return new c.Rect(i.x,i.y,n.x,n.y,r.degrees)},viewerElementToImageCoordinates:function(e){e=this.pointFromPixel(e,!0);return this.viewportToImageCoordinates(e)},imageToViewerElementCoordinates:function(e){e=this.imageToViewportCoordinates(e);return this.pixelFromPoint(e,!0)},windowToImageCoordinates:function(e){c.console.assert(this.viewer,"[Viewport.windowToImageCoordinates] the viewport must have a viewer.");e=e.minus(c.getElementPosition(this.viewer.container));return this.viewerElementToImageCoordinates(e)},imageToWindowCoordinates:function(e){c.console.assert(this.viewer,"[Viewport.imageToWindowCoordinates] the viewport must have a viewer.");const t=this.imageToViewerElementCoordinates(e);return t.plus(c.getElementPosition(this.viewer.container))},viewerElementToViewportCoordinates:function(e){return this.pointFromPixel(e,!0)},viewportToViewerElementCoordinates:function(e){return this.pixelFromPoint(e,!0)},viewerElementToViewportRectangle:function(e){return c.Rect.fromSummits(this.pointFromPixel(e.getTopLeft(),!0),this.pointFromPixel(e.getTopRight(),!0),this.pointFromPixel(e.getBottomLeft(),!0))},viewportToViewerElementRectangle:function(e){return c.Rect.fromSummits(this.pixelFromPoint(e.getTopLeft(),!0),this.pixelFromPoint(e.getTopRight(),!0),this.pixelFromPoint(e.getBottomLeft(),!0))},windowToViewportCoordinates:function(e){c.console.assert(this.viewer,"[Viewport.windowToViewportCoordinates] the viewport must have a viewer.");e=e.minus(c.getElementPosition(this.viewer.container));return this.viewerElementToViewportCoordinates(e)},viewportToWindowCoordinates:function(e){c.console.assert(this.viewer,"[Viewport.viewportToWindowCoordinates] the viewport must have a viewer.");const t=this.viewportToViewerElementCoordinates(e);return t.plus(c.getElementPosition(this.viewer.container))},viewportToImageZoom:function(e){if(this.viewer){var t=this.viewer.world.getItemCount();if(1<t)this.silenceMultiImageWarnings||c.console.error("[Viewport.viewportToImageZoom] is not accurate with multi-image.");else if(1===t){const i=this.viewer.world.getItemAt(0);return i.viewportToImageZoom(e)}}t=this._contentSizeNoRotate.x;return e*(this._containerInnerSize.x/t*this._contentBoundsNoRotate.width)},imageToViewportZoom:function(e){if(this.viewer){var t=this.viewer.world.getItemCount();if(1<t)this.silenceMultiImageWarnings||c.console.error("[Viewport.imageToViewportZoom] is not accurate with multi-image. Instead, use [TiledImage.imageToViewportZoom] for the specific image of interest");else if(1===t){const i=this.viewer.world.getItemAt(0);return i.imageToViewportZoom(e)}}return e*(this._contentSizeNoRotate.x/this._containerInnerSize.x/this._contentBoundsNoRotate.width)},toggleFlip:function(){this.setFlip(!this.getFlip());return this},getFlip:function(){return this.flipped},setFlip:function(e){if(this.flipped===e)return this;this.flipped=e;this.viewer.navigator&&this.viewer.navigator.setFlip(this.getFlip());this.viewer.forceRedraw();this.viewer.raiseEvent("flip",{flipped:e});return this},getMaxZoomPixelRatio:function(){return this.maxZoomPixelRatio},setMaxZoomPixelRatio:function(e,t=!0,i=!1){c.console.assert(!isNaN(e),"[Viewport.setMaxZoomPixelRatio] ratio must be a number");if(!isNaN(e)){this.maxZoomPixelRatio=e;t&&this.getZoom()>this.getMaxZoom()&&this.applyConstraints(i)}}}}(OpenSeadragon);!function(v){v.TiledImage=function(e){this._initialized=!1;v.console.assert(e.tileCache,"[TiledImage] options.tileCache is required");v.console.assert(e.drawer,"[TiledImage] options.drawer is required");v.console.assert(e.viewer,"[TiledImage] options.viewer is required");v.console.assert(e.imageLoader,"[TiledImage] options.imageLoader is required");v.console.assert(e.source,"[TiledImage] options.source is required");v.console.assert(!e.clip||e.clip instanceof v.Rect,"[TiledImage] options.clip must be an OpenSeadragon.Rect if present");v.EventSource.call(this);this._optimalWorldIndex=void 0;this._tileCache=e.tileCache;delete e.tileCache;this._drawer=e.drawer;delete e.drawer;this._imageLoader=e.imageLoader;delete e.imageLoader;e.clip instanceof v.Rect&&(this._clip=e.clip.clone());delete e.clip;var t=e.x||0;delete e.x;var i=e.y||0;delete e.y;this.normHeight=e.source.dimensions.y/e.source.dimensions.x;this.contentAspectX=e.source.dimensions.x/e.source.dimensions.y;let n=1;if(e.width){n=e.width;delete e.width;if(e.height){v.console.error("specifying both width and height to a tiledImage is not supported");delete e.height}}else if(e.height){n=e.height/this.normHeight;delete e.height}var r=e.fitBounds;delete e.fitBounds;var o=e.fitBoundsPlacement||OpenSeadragon.Placement.CENTER;delete e.fitBoundsPlacement;var s=e.degrees||0;delete e.degrees;var a=e.ajaxHeaders;delete e.ajaxHeaders;this.crossOriginPolicy=e.crossOriginPolicy;delete e.crossOriginPolicy;v.extend(!0,this,{viewer:null,tilesMatrix:{},coverage:{},loadingCoverage:{},lastResetTime:0,_needsDraw:!0,_needsUpdate:!0,_hasOpaqueTile:!1,_tilesLoading:0,_zombieCache:!1,_tilesToDraw:[],_lastDrawn:[],_arrayCacheMap:[],_isBlending:!1,_wasBlending:!1,_issues:{},springStiffness:v.DEFAULT_SETTINGS.springStiffness,animationTime:v.DEFAULT_SETTINGS.animationTime,minZoomImageRatio:v.DEFAULT_SETTINGS.minZoomImageRatio,wrapHorizontal:v.DEFAULT_SETTINGS.wrapHorizontal,wrapVertical:v.DEFAULT_SETTINGS.wrapVertical,immediateRender:v.DEFAULT_SETTINGS.immediateRender,loadDestinationTilesOnAnimation:v.DEFAULT_SETTINGS.loadDestinationTilesOnAnimation,blendTime:v.DEFAULT_SETTINGS.blendTime,alwaysBlend:v.DEFAULT_SETTINGS.alwaysBlend,minPixelRatio:v.DEFAULT_SETTINGS.minPixelRatio,smoothTileEdgesMinZoom:v.DEFAULT_SETTINGS.smoothTileEdgesMinZoom,iOSDevice:v.DEFAULT_SETTINGS.iOSDevice,debugMode:v.DEFAULT_SETTINGS.debugMode,ajaxWithCredentials:v.DEFAULT_SETTINGS.ajaxWithCredentials,placeholderFillStyle:v.DEFAULT_SETTINGS.placeholderFillStyle,opacity:v.DEFAULT_SETTINGS.opacity,preload:v.DEFAULT_SETTINGS.preload,compositeOperation:v.DEFAULT_SETTINGS.compositeOperation,subPixelRoundingForTransparency:v.DEFAULT_SETTINGS.subPixelRoundingForTransparency,maxTilesPerFrame:v.DEFAULT_SETTINGS.maxTilesPerFrame,originalDataType:void 0,_currentMaxTilesPerFrame:10*(e.maxTilesPerFrame||v.DEFAULT_SETTINGS.maxTilesPerFrame)},e);this._preload=this.preload;delete this.preload;this._fullyLoaded=!1;this._xSpring=new v.Spring({initial:t,springStiffness:this.springStiffness,animationTime:this.animationTime});this._ySpring=new v.Spring({initial:i,springStiffness:this.springStiffness,animationTime:this.animationTime});this._scaleSpring=new v.Spring({initial:n,springStiffness:this.springStiffness,animationTime:this.animationTime});this._degreesSpring=new v.Spring({initial:s,springStiffness:this.springStiffness,animationTime:this.animationTime});this._updateForScale();r&&this.fitBounds(r,o,!0);this._ownAjaxHeaders={};this.setAjaxHeaders(a,!1);this._initialized=!0};v.extend(v.TiledImage.prototype,v.EventSource.prototype,{needsDraw:function(){return this._needsDraw},redraw:function(){this._needsDraw=!0},getFullyLoaded:function(){return this._fullyLoaded},whenFullyLoaded:function(e){this.getFullyLoaded()?setTimeout(e,1):this.addOnceHandler("fully-loaded-change",function(){e()})},_setFullyLoaded:function(e){if(e!==this._fullyLoaded){this._fullyLoaded=e;this.raiseEvent("fully-loaded-change",{fullyLoaded:this._fullyLoaded})}},requestInvalidate:function(e=!0,t=!1,i=v.now()){t=t?this._lastDrawn.map(e=>e.tile):this._tileCache.getLoadedTilesFor(this);return this.viewer.world.requestTileInvalidateEvent(t,i,e)},reset:function(){this._tileCache.clearTilesFor(this);this._currentMaxTilesPerFrame=10*this.maxTilesPerFrame;this.lastResetTime=v.now();this._needsDraw=!0;this._fullyLoaded=!1},update:function(e){var t=this._xSpring.update();var i=this._ySpring.update();var n=this._scaleSpring.update();var r=this._degreesSpring.update();r=t||i||n||r||this._needsUpdate;if(r||e||!this._fullyLoaded){e=this._updateLevelsForViewport();this._setFullyLoaded(e)}this._needsUpdate=!1;if(r){this._updateForScale();this._raiseBoundsChange();return this._needsDraw=!0}return!1},setDrawn:function(){this._needsDraw=this._isBlending||this._wasBlending||0<this.opacity&&this._lastDrawn.length<1;return this._needsDraw},get crossOriginPolicy(){return this._crossOriginPolicy},set crossOriginPolicy(e){this._crossOriginPolicy="string"==typeof e?e.toLowerCase():v.DEFAULT_SETTINGS.crossOriginPolicy},setIssue(e,t=void 0,i=void 0){var n=i?i.message||i:"";this._issues[e]=(t||`TiledImage is ${e}}`)+n;v.console.warn(this._issues[e],i)},getIssue(e){return this._issues[e]},hasIssue(e){return!!this.getIssue(e)},destroy:function(){this.reset();this.source.destroy(this.viewer)},getBounds:function(e){return this.getBoundsNoRotate(e).rotate(this.getRotation(e),this._getRotationPoint(e))},getBoundsNoRotate:function(e){return e?new v.Rect(this._xSpring.current.value,this._ySpring.current.value,this._worldWidthCurrent,this._worldHeightCurrent):new v.Rect(this._xSpring.target.value,this._ySpring.target.value,this._worldWidthTarget,this._worldHeightTarget)},getWorldBounds:function(){v.console.error("[TiledImage.getWorldBounds] is deprecated; use TiledImage.getBounds instead");return this.getBounds()},getClippedBounds:function(e){let t=this.getBoundsNoRotate(e);if(this._clip){var i=(e?this._worldWidthCurrent:this._worldWidthTarget)/this.source.dimensions.x;i=this._clip.times(i);t=new v.Rect(t.x+i.x,t.y+i.y,i.width,i.height)}return t.rotate(this.getRotation(e),this._getRotationPoint(e))},getTileBounds:function(e,t,i){var n=this.source.getNumTiles(e);var r=(n.x+t%n.x)%n.x;var o=(n.y+i%n.y)%n.y;const s=this.source.getTileBounds(e,r,o);this.getFlip()&&(s.x=Math.max(0,1-s.x-s.width));s.x+=(t-r)/n.x;s.y+=this._worldHeightCurrent/this._worldWidthCurrent*((i-o)/n.y);return s},getContentSize:function(){return new v.Point(this.source.dimensions.x,this.source.dimensions.y)},getSizeInWindowCoordinates:function(){var e=this.imageToWindowCoordinates(new v.Point(0,0));var t=this.imageToWindowCoordinates(this.getContentSize());return new v.Point(t.x-e.x,t.y-e.y)},get lastDrawn(){return this._lastDrawn},getDrawer:function(){return this.viewer.drawer},_viewportToImageDelta:function(e,t,i){i=(i?this._scaleSpring.current:this._scaleSpring.target).value;return new v.Point(e*(this.source.dimensions.x/i),t*(this.source.dimensions.y*this.contentAspectX/i))},viewportToImageCoordinates:function(e,t,i){let n;if(e instanceof v.Point){i=t;n=e}else n=new v.Point(e,t);n=n.rotate(-this.getRotation(i),this._getRotationPoint(i));return i?this._viewportToImageDelta(n.x-this._xSpring.current.value,n.y-this._ySpring.current.value):this._viewportToImageDelta(n.x-this._xSpring.target.value,n.y-this._ySpring.target.value)},_imageToViewportDelta:function(e,t,i){i=(i?this._scaleSpring.current:this._scaleSpring.target).value;return new v.Point(e/this.source.dimensions.x*i,t/this.source.dimensions.y/this.contentAspectX*i)},imageToViewportCoordinates:function(e,t,i){if(e instanceof v.Point){i=t;t=e.y;e=e.x}const n=this._imageToViewportDelta(e,t,i);if(i){n.x+=this._xSpring.current.value;n.y+=this._ySpring.current.value}else{n.x+=this._xSpring.target.value;n.y+=this._ySpring.target.value}return n.rotate(this.getRotation(i),this._getRotationPoint(i))},imageToViewportRectangle:function(e,t,i,n,r){let o=e;o instanceof v.Rect?r=t:o=new v.Rect(e,t,i,n);i=this.imageToViewportCoordinates(o.getTopLeft(),r);n=this._imageToViewportDelta(o.width,o.height,r);return new v.Rect(i.x,i.y,n.x,n.y,o.degrees+this.getRotation(r))},viewportToImageRectangle:function(e,t,i,n,r){let o=e;e instanceof v.Rect?r=t:o=new v.Rect(e,t,i,n);i=this.viewportToImageCoordinates(o.getTopLeft(),r);n=this._viewportToImageDelta(o.width,o.height,r);return new v.Rect(i.x,i.y,n.x,n.y,o.degrees-this.getRotation(r))},viewerElementToImageCoordinates:function(e){e=this.viewport.pointFromPixel(e,!0);return this.viewportToImageCoordinates(e)},imageToViewerElementCoordinates:function(e){e=this.imageToViewportCoordinates(e);return this.viewport.pixelFromPoint(e,!0)},windowToImageCoordinates:function(e){e=e.minus(OpenSeadragon.getElementPosition(this.viewer.element));return this.viewerElementToImageCoordinates(e)},imageToWindowCoordinates:function(e){const t=this.imageToViewerElementCoordinates(e);return t.plus(OpenSeadragon.getElementPosition(this.viewer.element))},_viewportToTiledImageRectangle:function(e){var t=this._scaleSpring.current.value;e=e.rotate(-this.getRotation(!0),this._getRotationPoint(!0));return new v.Rect((e.x-this._xSpring.current.value)/t,(e.y-this._ySpring.current.value)/t,e.width/t,e.height/t,e.degrees)},viewportToImageZoom:function(e){return this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x*e},imageToViewportZoom:function(e){return e/(this._scaleSpring.current.value*this.viewport._containerInnerSize.x/this.source.dimensions.x)},setPosition:function(e,t){var i=this._xSpring.target.value===e.x&&this._ySpring.target.value===e.y;if(t){if(i&&this._xSpring.current.value===e.x&&this._ySpring.current.value===e.y)return;this._xSpring.resetTo(e.x);this._ySpring.resetTo(e.y);this._needsDraw=!0;this._needsUpdate=!0}else{if(i)return;this._xSpring.springTo(e.x);this._ySpring.springTo(e.y);this._needsDraw=!0;this._needsUpdate=!0}i||this._raiseBoundsChange()},setWidth:function(e,t){this._setScale(e,t)},setHeight:function(e,t){this._setScale(e/this.normHeight,t)},setCroppingPolygons:function(e){const t=function(e){return e instanceof v.Point||"number"==typeof e.x&&"number"==typeof e.y};try{if(!v.isArray(e))throw new Error("Provided cropping polygon is not an array");this._croppingPolygons=e.map(function(e){return e.map(function(e){try{if(t(e))return{x:e.x,y:e.y};throw new Error}catch(e){throw new Error("A Provided cropping polygon point is not supported")}})});this._needsDraw=!0}catch(e){v.console.error("[TiledImage.setCroppingPolygons] Cropping polygon format not supported");v.console.error(e);this.resetCroppingPolygons()}},resetCroppingPolygons:function(){this._croppingPolygons=null;this._needsDraw=!0},fitBounds:function(t,i,n){i=i||v.Placement.CENTER;i=v.Placement.properties[i];let r=this.contentAspectX;let o=0;let s=0;let a=1;let l=1;if(this._clip){r=this._clip.getAspectRatio();a=this._clip.width/this.source.dimensions.x;l=this._clip.height/this.source.dimensions.y;if(t.getAspectRatio()>r){o=this._clip.x/this._clip.height*t.height;s=this._clip.y/this._clip.height*t.height}else{o=this._clip.x/this._clip.width*t.width;s=this._clip.y/this._clip.width*t.width}}if(t.getAspectRatio()>r){var h=t.height/l;let e=0;i.isHorizontallyCentered?e=(t.width-t.height*r)/2:i.isRight&&(e=t.width-t.height*r);this.setPosition(new v.Point(t.x-o+e,t.y-s),n);this.setHeight(h,n)}else{h=t.width/a;let e=0;i.isVerticallyCentered?e=(t.height-t.width/r)/2:i.isBottom&&(e=t.height-t.width/r);this.setPosition(new v.Point(t.x-o,t.y-s+e),n);this.setWidth(h,n)}},getClip:function(){return this._clip?this._clip.clone():null},setClip:function(e){v.console.assert(!e||e instanceof v.Rect,"[TiledImage.setClip] newClip must be an OpenSeadragon.Rect or null");e instanceof v.Rect?this._clip=e.clone():this._clip=null;this._needsUpdate=!0;this._needsDraw=!0;this.raiseEvent("clip-change")},getFlip:function(){return this.flipped},setFlip:function(e){this.flipped=e},get flipped(){return this._flipped},set flipped(e){var t=this._flipped!==!!e;this._flipped=!!e;if(t&&this._initialized){this.update(!0);this._needsDraw=!0;this._raiseBoundsChange()}},get wrapHorizontal(){return this._wrapHorizontal},set wrapHorizontal(e){var t=this._wrapHorizontal!==!!e;this._wrapHorizontal=!!e;if(this._initialized&&t){this.update(!0);this._needsDraw=!0}},get wrapVertical(){return this._wrapVertical},set wrapVertical(e){var t=this._wrapVertical!==!!e;this._wrapVertical=!!e;if(this._initialized&&t){this.update(!0);this._needsDraw=!0}},get debugMode(){return this._debugMode},set debugMode(e){this._debugMode=!!e;this._needsDraw=!0},getOpacity:function(){return this.opacity},setOpacity:function(e){this.opacity=e},get opacity(){return this._opacity},set opacity(e){if(e!==this.opacity){this._opacity=e;this._needsDraw=!0;this._needsUpdate=!0;this.raiseEvent("opacity-change",{opacity:this.opacity})}},getPreload:function(){return this._preload},setPreload:function(e){this._preload=!!e;this._needsDraw=!0},getRotation:function(e){return(e?this._degreesSpring.current:this._degreesSpring.target).value},setRotation:function(e,t){if(this._degreesSpring.target.value!==e||!this._degreesSpring.isAtTargetValue()){t?this._degreesSpring.resetTo(e):this._degreesSpring.springTo(e);this._needsDraw=!0;this._needsUpdate=!0;this._raiseBoundsChange()}},getDrawArea:function(){if(0===this._opacity&&!this._preload)return!1;let e=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!0));if(!this.wrapHorizontal&&!this.wrapVertical){var t=this._viewportToTiledImageRectangle(this.getClippedBounds(!0));e=e.intersection(t)}return e},getLoadArea:function(){let e=this._viewportToTiledImageRectangle(this.viewport.getBoundsWithMargins(!1));if(!this.wrapHorizontal&&!this.wrapVertical){var t=this._viewportToTiledImageRectangle(this.getClippedBounds(!1));e=e.intersection(t)}return e},getTilesToDraw:function(){const e=this._lastDrawn;let t=0;for(const i of this._tilesToDraw)if(Array.isArray(i))for(const n of i)e[t++]=n;else i&&(e[t++]=i);e.length=t;this._updateTilesInViewport(e);t=0;for(const r of this._tilesToDraw)if(Array.isArray(r)){for(const o of r)if(o.tile.loaded){o.tile.beingDrawn=!0;e[t++]=o}}else if(r&&r.tile.loaded){r.tile.beingDrawn=!0;e[t++]=r}e.length=t;return e},_getRotationPoint:function(e){return this.getBoundsNoRotate(e).getCenter()},get compositeOperation(){return this._compositeOperation},set compositeOperation(e){if(e!==this._compositeOperation){this._compositeOperation=e;this._needsDraw=!0;this.raiseEvent("composite-operation-change",{compositeOperation:this._compositeOperation})}},getCompositeOperation:function(){return this._compositeOperation},setCompositeOperation:function(e){this.compositeOperation=e},setAjaxHeaders:function(e,t){if(v.isPlainObject(e=null===e?{}:e)){this._ownAjaxHeaders=e;this._updateAjaxHeaders(t)}else v.console.error("[TiledImage.setAjaxHeaders] Ignoring invalid headers, must be a plain object")},_updateAjaxHeaders:function(e){void 0===e&&(e=!0);v.isPlainObject(this.viewer.ajaxHeaders)?this.ajaxHeaders=v.extend({},this.viewer.ajaxHeaders,this._ownAjaxHeaders):this.ajaxHeaders=this._ownAjaxHeaders;if(e){let e,t,i,n;for(const s in this.tilesMatrix){e=this.source.getNumTiles(s);var r=this.tilesMatrix[s];for(const a in r){t=(e.x+a%e.x)%e.x;for(const l in r[a]){i=(e.y+l%e.y)%e.y;n=r[a][l];n.loadWithAjax=this.loadTilesWithAjax;if(n.loadWithAjax){var o=this.source.getTileAjaxHeaders(s,t,i);n.ajaxHeaders=v.extend({},this.ajaxHeaders,o)}else n.ajaxHeaders=null}}}for(let e=0;e<this._imageLoader.jobQueue.length;e++){const h=this._imageLoader.jobQueue[e];h.loadWithAjax=h.tile.loadWithAjax;h.ajaxHeaders=h.tile.loadWithAjax?h.tile.ajaxHeaders:null}}},allowZombieCache:function(e){this._zombieCache=e},_setScale:function(e,t){var i=this._scaleSpring.target.value===e;if(t){if(i&&this._scaleSpring.current.value===e)return;this._scaleSpring.resetTo(e);this._updateForScale();this._needsDraw=!0;this._needsUpdate=!0}else{if(i)return;this._scaleSpring.springTo(e);this._updateForScale();this._needsDraw=!0;this._needsUpdate=!0}i||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 e=Math.max(this.source.minLevel,Math.floor(Math.log(this.minZoomImageRatio)/Math.log(2)));var t=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(0),!0).x*this._scaleSpring.current.value;t=Math.min(Math.abs(this.source.maxLevel),Math.abs(Math.floor(Math.log(t/this.minPixelRatio)/Math.log(2))));t=Math.max(t,this.source.minLevel||0);return{lowestLevel:Math.min(e,t),highestLevel:t}},_updateLevelsForViewport:function(){var i=this._getLevelsInterval();var n=i.lowestLevel;i=i.highestLevel;var t=this.getDrawArea();let r=t;let o=this._getCachedArray("bestLoadTileCandidates",0);this.loadDestinationTilesOnAnimation&&(r=this.getLoadArea());var s=v.now();for(const e of this._lastDrawn)e.tile.beingDrawn=!1;this._tilesToDraw.length=0;this._tilesLoading=0;this.loadingCoverage={};if(!t){this._needsDraw=!1;return this._fullyLoaded}const a=this._getCachedArray("levelList",i-n+1);for(let e=0,t=i;t>=n;t--,e++)a[e]=t;for(let e=i+1;e<=this.source.maxLevel;e++){var l=this.tilesMatrix[e]&&this.tilesMatrix[e][0]&&this.tilesMatrix[e][0][0];if(l&&l.isBottomMost&&l.isRightMost&&l.loaded){a.push(e);break}}let h=!1;for(let e=0;e<a.length;e++){var c=a[e];var u=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(c),!0).x*this._scaleSpring.current.value;if(e===a.length-1||u>=this.minPixelRatio)h=!0;else if(!h)continue;var d=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(c),!1).x*this._scaleSpring.current.value;var p=this.viewport.deltaPixelsFromPointsNoRotate(this.source.getPixelRatio(Math.max(this.source.getClosestLevel(),0)),!1).x*this._scaleSpring.current.value;p=this.immediateRender?1:p;u=Math.min(1,(u-.5)/.5);d=p/Math.abs(p-d);d=this._updateLevel(c,u,d,t,r,s,o);this.viewer.world.ensureTilesUpToDate(d.tilesToDraw);o=d.bestLoadTileCandidates;this._tilesToDraw[c]=d.tilesToDraw;if(this._providesCoverage(this.coverage,c))break}if(o&&0<o.length){for(const g of o)g&&this._loadTile(g,s);return!(this._needsDraw=!0)}return 0===this._tilesLoading},_updateTilesInViewport:function(t){var i=v.now();var n=this;this._tilesLoading=0;this._wasBlending=this._isBlending;this._isBlending=!1;this.loadingCoverage={};var r=t.length?t[0].level:0;if(this.getDrawArea()){let e=0;for(const s of t){var o=s.tile;if(o&&o.loaded){o=n._blendTile(o,o.x,o.y,s.level,s.levelOpacity,i,r);n._isBlending=n._isBlending||o;n._needsDraw=n._needsDraw||o||n._wasBlending}this._providesCoverage(this.coverage,s.level)&&(e=Math.max(e,s.level))}if(0<e)for(const a in this._tilesToDraw)a<e&&(this._tilesToDraw[a]=void 0)}},_blendTile:function(e,t,i,n,r,o,s){let a=1e3*this.blendTime,l,h;e.blendStart||(e.blendStart=o);l=o-e.blendStart;h=a?Math.min(1,l/a):1;if(n===s){h=1;l=a}this.alwaysBlend&&(h*=r);e.opacity=h;if(1===h){this._setCoverage(this.coverage,n,t,i,!0);this._hasOpaqueTile=!0}return l<a},_updateLevel:function(r,o,s,e,a,l,h){var t=e.getBoundingBox().getTopLeft();var i=e.getBoundingBox().getBottomRight();this.viewer&&this.viewer.raiseEvent("update-level",{tiledImage:this,havedrawn:!0,level:r,opacity:o,visibility:s,drawArea:e,topleft:t,bottomright:i,currenttime:l,best:h});const c=this.source.getNumTiles(r);const u=this.viewport.pixelFromPoint(this.viewport.getCenter());this._resetCoverage(this.coverage,r);a&&this._resetCoverage(this.loadingCoverage,r);let d=null;let p=0;this._visitTiles(r,e,(t,i,e)=>{var n=this._getTile(t,i,r,l,c);d=d||this._getCachedArray(r,e);this.viewer&&this.viewer.raiseEvent("update-tile",{tiledImage:this,tile:n});this._setCoverage(this.coverage,r,t,i,!1);if(n.exists){if(n.loaded){1===n.opacity&&this._setCoverage(this.coverage,r,t,i,!0);d[p++]={tile:n,level:r,levelOpacity:o,currentTime:l};this._setCoverage(this.loadingCoverage,r,t,i,!0)}this._positionTile(n,this.source.tileOverlap,this.viewport,u,s)}if(a&&!n.loaded){let e=n.loading||this._isCovered(this.loadingCoverage,r,t,i);this._setCoverage(this.loadingCoverage,r,t,i,e);if(n.exists){!n.loading&&this._tryFindTileCacheRecord(n)&&(e=!0);n.loading?this._tilesLoading++:e||(h=this._compareTiles(h,n,this._currentMaxTilesPerFrame))}}});this._currentMaxTilesPerFrame>this.maxTilesPerFrame&&(this._currentMaxTilesPerFrame=Math.max(Math.ceil(this._currentMaxTilesPerFrame/2),this.maxTilesPerFrame));d&&(d.length=p);return{bestLoadTileCandidates:h,tilesToDraw:d||[]}},_visitTiles:function(n,r,o){const e=r.getBoundingBox();var t=this._getCornerTiles(n,e.getTopLeft(),e.getBottomRight());var s=t.topLeft;const a=t.bottomRight;var l=this.source.getNumTiles(n);if(this.getFlip()){a.x+=1;this.wrapHorizontal||(a.x=Math.min(a.x,l.x-1))}var h=Math.max(0,(a.x-s.x)*(a.y-s.y));for(let i=s.x;i<=a.x;i++)for(let t=s.y;t<=a.y;t++){let e;if(this.getFlip()){var c=(l.x+i%l.x)%l.x;e=i+l.x-c-c-1}else e=i;null!==r.intersection(this.getTileBounds(n,e,t))&&o(e,t,h)}},_positionTile:function(e,t,i,n,r){const o=e.bounds.getTopLeft();o.x*=this._scaleSpring.current.value;o.y*=this._scaleSpring.current.value;o.x+=this._xSpring.current.value;o.y+=this._ySpring.current.value;const s=e.bounds.getSize();s.x*=this._scaleSpring.current.value;s.y*=this._scaleSpring.current.value;e.positionedBounds.x=o.x;e.positionedBounds.y=o.y;e.positionedBounds.width=s.x;e.positionedBounds.height=s.y;var a=i.pixelFromPointNoRotate(o,!0);const l=i.pixelFromPointNoRotate(o,!1);let h=i.deltaPixelsFromPointsNoRotate(s,!0);const c=i.deltaPixelsFromPointsNoRotate(s,!1);i=l.plus(c.divide(2));i=n.squaredDistanceTo(i);if(this.getDrawer().minimumOverlapRequired(this)){t||(h=h.plus(new v.Point(1,1)));e.isRightMost&&this.wrapHorizontal&&(h.x+=.75);e.isBottomMost&&this.wrapVertical&&(h.y+=.75)}e.position=a;e.size=h;e.squaredDistance=i;e.visibility=r},_getCornerTiles:function(e,t,i){let n;let r;if(this.wrapHorizontal){n=v.positiveModulo(t.x,1);r=v.positiveModulo(i.x,1)}else{n=Math.max(0,t.x);r=Math.min(1,i.x)}let o;let s;var a=1/this.source.aspectRatio;if(this.wrapVertical){o=v.positiveModulo(t.y,a);s=v.positiveModulo(i.y,a)}else{o=Math.max(0,t.y);s=Math.min(a,i.y)}const l=this.source.getTileAtPoint(e,new v.Point(n,o));const h=this.source.getTileAtPoint(e,new v.Point(r,s));e=this.source.getNumTiles(e);if(this.wrapHorizontal){l.x+=e.x*Math.floor(t.x);h.x+=e.x*Math.floor(i.x)}if(this.wrapVertical){l.y+=e.y*Math.floor(t.y/a);h.y+=e.y*Math.floor(i.y/a)}return{topLeft:l,bottomRight:h}},_tryFindTileCacheRecord:function(e){var t=this._tileCache.getCacheRecord(e.originalCacheKey);if(!t)return!1;e.loading=!0;this._setTileLoaded(e,t.data,null,null,t.type);return!0},_getTile:function(e,t,i,n,r){let o,s,a,l,h,c,u,d,p,g=this.tilesMatrix,m=this.source;let f=g[i];f||(g[i]=f={});f[e]||(f[e]={});if(f[e][t]&&!f[e][t].flipped==!this.flipped)p=f[e][t];else{o=(r.x+e%r.x)%r.x;s=(r.y+t%r.y)%r.y;a=this.getTileBounds(i,e,t);l=m.getTileBounds(i,o,s,!0);h=m.tileExists(i,o,s);c=m.getTileUrl(i,o,s);u=m.getTilePostData(i,o,s);if(this.loadTilesWithAjax){d=m.getTileAjaxHeaders(i,o,s);v.isPlainObject(this.ajaxHeaders)&&(d=v.extend({},this.ajaxHeaders,d))}else d=null;p=new v.Tile(i,e,t,a,h,c,void 0,this.loadTilesWithAjax,d,l,u,m.getTileHashKey(i,o,s,c,d,u));this.getFlip()?0==o&&(p.isRightMost=!0):o==r.x-1&&(p.isRightMost=!0);s==r.y-1&&(p.isBottomMost=!0);p.flipped=this.flipped;f[e][t]=p}p.lastTouchTime=n;return p},_loadTile:function(o,s){const a=this;o.loading=!0;(o.tiledImage=this)._imageLoader.addJob({src:o.getUrl(),tile:o,source:this.source,postData:o.postData,loadWithAjax:o.loadWithAjax,ajaxHeaders:o.ajaxHeaders,crossOriginPolicy:this.crossOriginPolicy,ajaxWithCredentials:this.ajaxWithCredentials,callback:function(e,t,i,n,r){a._onTileLoad(o,s,e,t,i,n,r)},abort:function(){o.loading=!1}})||this.viewer.raiseEvent("job-queue-full",{tile:o,tiledImage:this,time:s})},_onTileLoad:function(t,e,i,n,r,o,s){if(null!=i){t.exists=!0;if(e<this.lastResetTime){v.console.warn("Ignoring tile %s loaded before reset: %s",t,t.getUrl());t.loading=!1}else if(this.originalDataType){var a=v.converter.getConversionPath(o,this.originalDataType);if(a){const l=v.converter.getConversionPathFinalType(a);v.converter.convert(t,i,o,l).then(e=>{this._setTileLoaded(t,e,null,r,l)}).catch(e=>{v.console.warn("Failed to satisfy original type [%s] %s from %s: %s",l,t,o,e);this._setTileLoaded(t,i,null,r,o)})}else{v.console.warn("Ignoring default base tile data type %s: no conversion possible from %s",this.originalDataType,o);this._setTileLoaded(t,i,null,r,o)}}else this._setTileLoaded(t,i,null,r,o)}else{v.console.error("Tile %s failed to load: %s - error: %s",t,t.getUrl(),n);this.viewer.raiseEvent("tile-load-failed",{tile:t,tiledImage:this,time:e,message:n,tileRequest:r,tries:s,maxReached:0===this.viewer.tileRetryMax||s>=this.viewer.tileRetryMax});t.loading=!1;t.exists=!1}},_setTileLoaded:function(i,t,e,n,r){i.tiledImage=this;v.console.assert(void 0!==r,"TileSource::downloadTileStart must return a dataType.");let o=!1;i.addCache(i.cacheKey,()=>{o=!0;return t},r,!1,!1);let s=null,a=0,l=!1;const h=this;function c(){a--;if(!(0<a)){l=!0;i.hasTransparency=i.hasTransparency||h.source.hasTransparency(void 0,i.getUrl(),i.ajaxHeaders,i.postData);i.loading=!1;i.loaded=!0;h.redraw();s(i)}}function u(){l&&v.console.error("Event 'tile-loaded' argument getCompletionCallback must be called synchronously. Its return value should be called asynchronously.");a++;return c}function d(){var e=u();h.viewer.raiseEventAwaiting("tile-loaded",{tile:i,tiledImage:h,tileRequest:n,promise:new v.Promise(e=>{s=e}),get image(){v.console.error("[tile-loaded] event 'image' has been deprecated. Use 'tile-invalidated' event to modify data instead.");return t},get data(){v.console.error("[tile-loaded] event 'data' has been deprecated. Use 'tile-invalidated' event to modify data instead.");return t},getCompletionCallback:function(){v.console.error("[tile-loaded] getCompletionCallback is deprecated: it introduces race conditions: use async event handlers instead, execution order is deducted by addHandler(...) priority argument.");return u()}}).catch(()=>{v.console.error("[tile-loaded] event finished with failure: there might be a problem with a plugin you are using.")}).then(e)}if(o)this.viewer.world.requestTileInvalidateEvent([i],void 0,!1,!0,!0).then(d).catch(d);else{r=i.getCache(i.originalCacheKey);const p=e=>{if(this.viewer.isDestroyed())return v.Promise.resolve();var t=this.getDrawer();return e.isUsableForDrawer(t)?v.Promise.resolve():e.prepareForRendering(t)};for(const g of r._tiles){if(g.cacheKey!==i.cacheKey){const m=g.getCache();p(m).then(()=>i.setCache(g.cacheKey,m,!0,!1)).then(d);return}if(g.processing){g.processingPromise.then(e=>{const t=e.getCache();p(t).then(()=>{i.setCache(e.cacheKey,t,!0,!1);return t.loaded?null:t.await()}).then(d)});return}}p(r).then(d)}},_compareTiles:function(t,i,e){if(!t)return[i];let n=!1;for(let e=0;e<t.length;e++){var r=t[e];if(0<this._sortTilesComparator(r,i)){t.splice(e,0,i);n=!0;break}}n||t.push(i);t.length>e&&t.pop();return t},_sortTilesComparator:function(e,t){return null===e?1:null===t?-1:e.visibility===t.visibility?e.squaredDistance-t.squaredDistance:t.visibility-e.visibility},_getCachedArray:function(e,t=void 0){let i=this._arrayCacheMap[e];i?void 0!==t&&(i.length=t):i=this._arrayCacheMap[e]=void 0!==t?new Array(t):[];return i},_providesCoverage:function(e,t,i,n){var r;var o;let s,a;if(!e[t])return!1;if(void 0!==i&&void 0!==n)return void 0===e[t][i]||void 0===e[t][i][n]||!0===e[t][i][n];for(s in r=e[t])if(Object.prototype.hasOwnProperty.call(r,s))for(a in o=r[s])if(Object.prototype.hasOwnProperty.call(o,a)&&!o[a])return!1;return!0},_isCovered:function(e,t,i,n){return void 0===i||void 0===n?this._providesCoverage(e,t+1):this._providesCoverage(e,t+1,2*i,2*n)&&this._providesCoverage(e,t+1,2*i,2*n+1)&&this._providesCoverage(e,t+1,2*i+1,2*n)&&this._providesCoverage(e,t+1,2*i+1,2*n+1)},_setCoverage:function(e,t,i,n,r){if(e[t]){e[t][i]||(e[t][i]={});e[t][i][n]=r}else v.console.warn("Setting coverage for a tile before its level's coverage has been reset: %s",t)},_resetCoverage:function(e,t){e[t]={}}})}(OpenSeadragon);!function(c){const e=c;const r=Symbol("DRAWER_INTERNAL_CACHE");e.CacheRecord=class{constructor(){this.revive()}get data(){return this._data}get type(){return this._type}await(){return this._promise||c.Promise.resolve(this._data)}getImage(){c.console.error("[CacheRecord.getImage] options.image is deprecated. Moreover, it might not work correctly as the cache system performs conversion asynchronously in case the type needs to be converted.");this.transformTo("image");return this.data}getRenderedContext(){c.console.error("[CacheRecord.getRenderedContext] options.getRenderedContext is deprecated. Moreover, it might not work correctly as the cache system performs conversion asynchronously in case the type needs to be converted.");this.transformTo("context2d");return this.data}setDataAs(e,t){c.console.assert(null!=e,"[CacheRecord.setDataAs] needs valid data to set!");if(this._conversionJobQueue){let i=null;var n=new c.Promise((e,t)=>{i=e});this._conversionJobQueue.push(()=>i(this._overwriteData(e,t)));return n}return this._overwriteData(e,t)}getDataAs(t=void 0,i=!0){return this.loaded?t===this._type?i?c.converter.copy(this._tRef,this._data,t||this._type):this._promise:this._transformDataIfNeeded(this._tRef,this._data,t||this._type,i)||this._promise:this._promise.then(e=>this._transformDataIfNeeded(this._tRef,e,t||this._type,i)||e)}_transformDataIfNeeded(e,t,i,n){if(this._destroyed)return c.Promise.resolve();let r;i!==this._type?r=c.converter.convert(e,t,this._type,i):n&&(r=c.converter.copy(e,t,i));return!!r&&r.then(e=>{if(!this._destroyed)return e;c.converter.destroy(e,i)}).catch(e=>{this._handleConversionError(e)})}getDataForRendering(e,t){if(this._destroyed){c.console.error(`Attempt to draw tile with destroyed main cache ${this}!`);t._unload()}else if(this.loaded)if(this._destroyed){c.console.error(`Attempt to draw tile with destroyed main cache ${this}!`);t._unload()}else{const i=e.getSupportedDataFormats();if(i.includes(this.type)){if(!e.options.usePrivateCache)return this;if(!e.options.preloadCache)return this.prepareInternalCacheSync(e);t=this._getInternalCacheRef(e);if(t&&t.loaded)return t;c.console.error(`Attempt to draw tile cache ${this} with internal cache non-ready state!`)}else{c.console.error(`Attempt to draw tile cache ${this} with unsupported type '${this.type}' for the target drawer!`);this.prepareForRendering(e)}}else this._promise||c.console.error(`Attempt to draw cache ${this} when not loaded!`)}isUsableForDrawer(e){const t=e.getSupportedDataFormats();if(!t.includes(this.type))return!1;if(e.options.usePrivateCache)if(!this._getInternalCacheRef(e))return!1;return!0}prepareForRendering(t){const e=t.getRequiredDataFormats();if(!this.loaded)return this.await().then(e=>this.prepareForRendering(t));let i;i=e.includes(this.type)?this.await():this.transformTo(e);var n=e=>e.catch(e=>{this._handleConversionError(e);return null});return t.options.usePrivateCache&&t.options.preloadCache?n(i.then(e=>this.prepareInternalCacheAsync(t))):n(i)}prepareInternalCacheAsync(t){let e=this._getInternalCacheRef(t);if(this._checkInternalCacheUpToDate(e,t))return e.await();e&&!e.loaded&&e.await().then(()=>e.destroy());c.console.assert(this._tRef,"Data Create called from invalidation routine needs tile reference!");var i=t.internalCacheCreate(this,this._tRef);c.console.assert(void 0!==i,"[DrawerBase.internalCacheCreate] must return a value if usePrivateCache is enabled!");var n=t.getId();e=this[r][n]=new c.InternalCacheRecord(i,n,e=>t.internalCacheFree(e));return e.await()}prepareInternalCacheSync(t){let e=this._getInternalCacheRef(t);if(this._checkInternalCacheUpToDate(e,t))return e;e&&e.destroy();c.console.assert(this._tRef,"Data Create called from drawing loop needs tile reference!");var i=t.internalCacheCreate(this,this._tRef);c.console.assert(void 0!==i,"[DrawerBase.internalCacheCreate] must return a value if usePrivateCache is enabled!");var n=t.getId();e=this[r][n]=new c.InternalCacheRecord(i,n,e=>t.internalCacheFree(e));return e}_getInternalCacheRef(t){if(t.options.usePrivateCache){let e=this[r];e=e||(this[r]={});return e[t.getId()]}c.console.error("[CacheRecord.prepareInternalCacheSync] must not be called when usePrivateCache is false.")}_checkInternalCacheUpToDate(e,t){return e&&e.tstamp>=t._dataNeedsRefresh}transformTo(e=this._type){if(!this.loaded){this._conversionJobQueue=this._conversionJobQueue||[];let i=null;var t=new c.Promise((e,t)=>{i=e});this._conversionJobQueue.push(()=>{if(!this._destroyed)if("string"==typeof e&&e!==this._type||Array.isArray(e)&&!e.includes(this._type)){this._convert(this._type,e);this._promise.then(e=>i(e))}else this._promise.then(e=>{this._checkAwaitsConvert();return i(e)})});return t}("string"==typeof e&&e!==this._type||Array.isArray(e)&&!e.includes(this._type))&&this._convert(this._type,e);return this._promise}destroyInternalCache(e=void 0){const t=this[r];if(t)if(e){const i=t[e];if(i){i.destroy();delete t[e]}}else{for(const n in t)t[n].destroy();delete this[r]}}withTileReference(e){this._tRef=e;return this}toString(){const e=this._tRef||this._tiles.length&&this._tiles[0];return e?`Cache ${this.type} [used e.g. by ${e.toString()}]`:"Orphan cache!"}revive(){c.console.assert(!this.loaded&&!this._type,"[CacheRecord::revive] must not be called when loaded!");this._tiles=[];this._data=null;this._type=null;this.loaded=!1;this._promise=null;this._destroyed=!1;this._ownerTileCache=null;this.cacheKey=null}destroy(){if(!this._destroyed){delete this._conversionJobQueue;this._destroyed=!0;if(this.loaded)this._destroySelfUnsafe(this._data,this._type);else if(this._promise){const t=this._type;this._promise.then(e=>this._destroySelfUnsafe(e,t)).catch(c.console.error)}}}_destroySelfUnsafe(e,t){c.converter.destroy(e,t);this.destroyInternalCache();if(this._destroyed){this.loaded=!1;this._tiles=null;this._data=null;this._type=null;this._tRef=null;this._promise=null}}addTile(e,t,i){if(!this._destroyed){c.console.assert(e,"[CacheRecord.addTile] tile is required");if(null!=t&&this._tiles.length<1){"function"==typeof t&&(t=t());if(this.type&&this._promise)t instanceof c.Promise?this._promise=t.then(e=>{this._overwriteData(e,i)}):this._overwriteData(t,i);else{if(t instanceof c.Promise){this._promise=t.then(e=>{if(!this._destroyed){this.loaded=!0;return this._data=e}try{c.converter.destroy(e,this._type)}catch(e){}}).catch(e=>{this._handleConversionError(e)});this._data=null}else{this._promise=c.Promise.resolve(t);this._data=t;this.loaded=!0}this._type=i}this._tiles.push(e)}else{t=this._tiles.includes(e);!t&&this.type&&this._promise?this._tiles.push(e):t||c.console.warn("Tile %s caching attempt without data argument on uninitialized cache entry!",e)}}}removeTile(t){if(this._destroyed)return!1;for(let e=0;e<this._tiles.length;e++)if(this._tiles[e]===t){this._tiles.splice(e,1);this._tRef===t&&(this._tRef=this._tiles[e-1]);return!0}c.console.warn("[CacheRecord.removeTile] trying to remove unknown tile",t);return!1}getTileCount(){return this._tiles?this._tiles.length:0}_checkAwaitsConvert(){this._conversionJobQueue&&!this._destroyed&&setTimeout(()=>{if(this._conversionJobQueue&&!this._destroyed){const e=this._conversionJobQueue[0];this._conversionJobQueue.splice(0,1);0===this._conversionJobQueue.length&&delete this._conversionJobQueue;e()}})}_triggerNeedsDraw(){0<this._tiles.length&&this._tiles[0].tiledImage.viewer.forceRedraw()}_overwriteData(i,n){if(this._destroyed){c.converter.destroy(i,n);return c.Promise.resolve()}if(this.loaded){if(this._data===i&&this._type===n)return this._promise;c.converter.destroy(this._data,this._type);this._type=n;this._data=i;this._promise=c.Promise.resolve(i);const e=this[r];if(e)for(const t in e)e[t].setDataAs(i,n);this._triggerNeedsDraw();return this._promise}return this._promise.then(()=>{if(this._data===i&&this._type===n)return this._data;c.converter.destroy(this._data,this._type);this._type=n;this._data=i;this._promise=c.Promise.resolve(i);const e=this[r];if(e)for(const t in e)e[t].setDataAs(i,n);this._triggerNeedsDraw();return this._data})}_convert(e,t){const o=c.converter,s=o.getConversionPath(e,t);if(s){var i=this._data;const a=s.length;const l=this;const h=(t,i)=>{if(i>=a){l._data=t;l.loaded=!0;l._checkAwaitsConvert();return c.Promise.resolve(t)}const n=s[i];let e;try{e=n.transform(l._tRef,t)}catch(e){o.destroy(t,n.origin.value);return c.Promise.reject(`[CacheRecord._convert] sync failure (while converting using ${n.target.value}, ${n.origin.value})`)}if(void 0===e){l.loaded=!1;o.destroy(t,n.origin.value);return c.Promise.reject(`[CacheRecord._convert] data mid result undefined value (while converting using ${n.target.value}, ${n.origin.value})`)}o.destroy(t,n.origin.value);const r="promise"===c.type(e)?e:c.Promise.resolve(e);return r.then(e=>h(e,i+1))};this.loaded=!1;this._data=void 0;this._type=s[a-1].target.value;this._promise=h(i,0).catch(e=>{this._handleConversionError(e)})}else c.console.error(`[CacheRecord._convert] Conversion ${e} ---> ${t} cannot be done!`)}_handleConversionError(e){c.console.error("[CacheRecord] Conversion/preparation error:",e);this._destroyed=!0;this.loaded=!1;this._data=null;if(this.cacheKey&&this._ownerTileCache)this._ownerTileCache._handleBrokenCacheRecord(this);else{this._promise=c.Promise.resolve(void 0);this._tiles=[];this._tRef=null}}};e.InternalCacheRecord=class{constructor(e,t,i){this.tstamp=c.now();this._ondestroy=i;this._type=t;if(e instanceof c.Promise)(this._promise=e).then(e=>{this.loaded=!0;this._data=e});else{this._promise=null;this.loaded=!0;this._data=e}}get data(){return this._data}get type(){return this._type}await(){return this._promise||c.Promise.resolve(this._data)}withTileReference(e){this._temporaryTileRef=e;return this}destroy(){if(this.loaded){this._ondestroy&&this._ondestroy(this._data);this._data=null;this.loaded=!1}}};e.TileCache=class{constructor(e){this._maxCacheItemCount=(e=e||{}).maxImageCacheCount||c.DEFAULT_SETTINGS.maxImageCacheCount;this._tilesLoaded=[];this._zombiesLoaded=[];this._zombiesLoadedCount=0;this._cachesLoaded=[];this._cachesLoadedCount=0}numTilesLoaded(){return this._tilesLoaded.length}numCachesLoaded(){return this._zombiesLoadedCount+this._cachesLoadedCount}cacheTile(e){c.console.assert(e,"[TileCache.cacheTile] options is required");var t=e.tile;c.console.assert(t,"[TileCache.cacheTile] options.tile is required");c.console.assert(t.cacheKey,"[TileCache.cacheTile] options.tile.cacheKey is required");if(e.image instanceof Image){c.console.warn("[TileCache.cacheTile] options.image is deprecated!");e.data=e.image;e.dataType="image"}var i=e.cacheKey||t.cacheKey;let n=this._cachesLoaded[i];if(!n){if(void 0===e.data){c.console.error("[TileCache.cacheTile] options.image was renamed to options.data. '.image' attribute has been deprecated and will be removed in the future.");e.data=e.image}n=this._zombiesLoaded[i];if(n){if(n._destroyed)n.revive();else{"function"==typeof e.data&&e.data();delete e.data}delete this._zombiesLoaded[i];this._zombiesLoadedCount--;this._cachesLoaded[i]=n;this._cachesLoadedCount++}else{var r=void 0!==e.data&&null!==e.data&&!1!==e.data;c.console.assert(r,"[TileCache.cacheTile] options.data is required to create an CacheRecord");n=this._cachesLoaded[i]=new c.CacheRecord;this._cachesLoadedCount++}}if(!e.dataType){c.console.error("[TileCache.cacheTile] options.dataType is newly required. For easier use of the cache system, use the tile instance API.");"function"==typeof e.data&&c.console.error("[TileCache.cacheTile] options.dataType is mandatory when data item is a callback!");e.dataType=c.converter.guessType(e.data)}n._ownerTileCache=this;n.cacheKey=i;n.addTile(t,e.data,e.dataType);this._freeOldRecordRoutine(t,e.cutoff||0);return n}renameCache(e){var t=e.newCacheKey,i=e.oldCacheKey;let n=this._cachesLoaded[i];if(n){if(this._cachesLoaded[t]){c.console.error("Cannot rename cache %s to %s: the target cache is occupied!",i,t);return null}this._cachesLoaded[t]=n;delete this._cachesLoaded[i]}else{n=this._zombiesLoaded[i];c.console.assert(n,"[TileCache.renameCache] oldCacheKey must reference existing cache!");if(this._zombiesLoaded[t]){c.console.error("Cannot rename zombie cache %s to %s: the target cache is occupied!",i,t);return null}this._zombiesLoaded[t]=n;delete this._zombiesLoaded[i]}n._ownerTileCache=this;n.cacheKey=t;for(const r of n._tiles)r.reflectCacheRenamed(i,t);return n}cloneCache(i){const n=i.tile;var e=i.copyTargetKey;const r=this._cachesLoaded[e]||this._zombiesLoaded[e];c.console.assert(r,"[TileCache.cloneCache] attempt to clone non-existent cache %s!",e);c.console.assert(!this._cachesLoaded[i.newCacheKey],"[TileCache.cloneCache] attempt to copy clone to existing cache %s!",i.newCacheKey);e=i.desiredType||void 0;return r.getDataAs(e,!0).then(e=>{const t=this._cachesLoaded[i.newCacheKey]=new c.CacheRecord;t.addTile(n,e,r.type);this._cachesLoadedCount++;this._freeOldRecordRoutine(n,i.cutoff||0);return t})}injectCache(e){const t=e.targetKey,i=e.tile;if(e.tileAllowNotLoaded||i.loaded||i.loading){var n=this._cachesLoaded[t];if(n)for(const i of[...n._tiles])this.unloadCacheForTile(i,t,!0,!1);this._cachesLoaded[t]&&c.console.error("The inject routine should've freed cache!");const r=e.cache;this._cachesLoaded[t]=r;r._ownerTileCache=this;r.cacheKey=t;for(const o of i.getCache(i.originalCacheKey)._tiles)o.setCache(t,r,e.setAsMainCache,!1)}else c.console.warn("Attempt to inject cache on tile in invalid state: this is probably a bug!")}replaceCache(e){const t=e.victimKey,i=e.consumerKey,n=this._cachesLoaded[t],r=e.tile;if(n&&(e.tileAllowNotLoaded||r.loaded||r.loading)){var o=this._cachesLoaded[i];if(o)for(const r of[...o._tiles])this.unloadCacheForTile(r,i,!0,!1);this._cachesLoaded[i]&&c.console.error("The consume routine should've freed cache!");var s=this.renameCache({oldCacheKey:t,newCacheKey:i});if(s)for(const a of r.getCache(r.originalCacheKey)._tiles)a.setCache(i,s,e.setAsMainCache,!1)}else c.console.warn("Attempt to consume cache on tile in invalid state: this is probably a bug!")}restoreTilesThatShareOriginalCache(e,t,i){for(const n of t._tiles)if(n.cacheKey!==n.originalCacheKey){this.unloadCacheForTile(n,n.cacheKey,i,!0);delete n._caches[n.cacheKey];n.cacheKey=n.originalCacheKey}}_freeOldRecordRoutine(e,i){let n=this._tilesLoaded.length,r=-1;if(this._cachesLoadedCount+this._zombiesLoadedCount>this._maxCacheItemCount)if(0<this._zombiesLoadedCount)for(const t in this._zombiesLoaded){this._zombiesLoaded[t].destroy();delete this._zombiesLoaded[t];this._zombiesLoadedCount--;break}else{let t=null;var o,s,a,l,h;for(let e=this._tilesLoaded.length-1;0<=e;e--)if(!((o=this._tilesLoaded[e]).level<=i||o.beingDrawn||o.loading||o.processing))if(t){l=o.lastTouchTime;s=t.lastTouchTime;h=o.level;a=t.level;if(l<s||l===s&&a<h){t=o;r=e}}else{t=o;r=e}if(t&&0<=r){this._unloadTile(t,!0);n=r}}0===e.getCacheSize()?this._tilesLoaded[n]=e:0<=r&&this._tilesLoaded.splice(n,1)}_handleBrokenCacheRecord(e){if(e){var t=e.cacheKey;if(t&&this._cachesLoaded[t]===e){delete this._cachesLoaded[t];this._cachesLoadedCount--}if(t&&this._zombiesLoaded[t]===e){delete this._zombiesLoaded[t];this._zombiesLoadedCount--}for(const r of e._tiles?[...e._tiles]:[]){var i=r.getCache&&r.getCache()===e;var n=t&&r.originalCacheKey===t;if(i||n){r.exists=!1;r.unload(!0)}else{r.removeCache&&t&&r.removeCache(t);e.removeTile(r)}}e._promise=c.Promise.resolve(void 0);e._tiles=[];e._tRef=null;e._ownerTileCache=null}}clearTilesFor(t){c.console.assert(t,"[TileCache.clearTilesFor] tiledImage is required");var i;let n=this._cachesLoadedCount+this._zombiesLoadedCount>this._maxCacheItemCount;if(t._zombieCache&&n&&0<this._zombiesLoadedCount){for(const e in this._zombiesLoaded){this._zombiesLoaded[e].destroy();delete this._zombiesLoaded[e]}this._zombiesLoadedCount=0;n=this._cachesLoadedCount>this._maxCacheItemCount}for(let e=this._tilesLoaded.length-1;0<=e;e--)(i=this._tilesLoaded[e]).tiledImage===t&&(i.loaded?i.tiledImage===t&&this._unloadTile(i,!t._zombieCache||n,e):this._tilesLoaded.splice(e,1))}clear(e=0){for(const t in this._zombiesLoaded)this._zombiesLoaded[t].destroy();for(const i in this._tilesLoaded)this._unloadTile(i,!0);this._tilesLoaded=[];this._zombiesLoaded=[];this._zombiesLoadedCount=0;this._cachesLoaded=[];this._cachesLoadedCount=0}clearDrawerInternalCache(e){var t=e.getId();for(const i of this._zombiesLoaded)i&&i.destroyInternalCache(t);for(const n of this._cachesLoaded)n&&n.destroyInternalCache(t)}getLoadedTilesFor(t){return t?this._tilesLoaded.filter(e=>e.tiledImage===t):[...this._tilesLoaded]}getCacheRecord(e){c.console.assert(e,"[TileCache.getCacheRecord] cacheKey is required");return this._cachesLoaded[e]||this._zombiesLoaded[e]}safeUnloadCache(e){if(e&&!e._destroyed&&e.getTileCount()<1){for(const t in this._zombiesLoaded){const i=this._zombiesLoaded[t];if(i===e){delete this._zombiesLoaded[t];i.destroy();return}}c.console.error("Attempt to delete an orphan cache that is not in zombie list: this could be a bug!",e);e.destroy()}}unloadCacheForTile(e,t,i,n){const r=this._cachesLoaded[t];if(r){if(r.removeTile(e)){if(!r.getTileCount()){if(i)r.destroy();else{this._zombiesLoaded[t]=r;this._zombiesLoadedCount++}delete this._cachesLoaded[t];this._cachesLoadedCount--}return!0}c.console.error("[TileCache.unloadCacheForTile] System tried to delete tile from cache it does not belong to! This could mean a bug in the cache system.");return!1}n||c.console.warn("[TileCache.unloadCacheForTile] Attempting to delete missing cache!");return!1}unloadTile(t,e=!1){if(t.loaded){var i=this._tilesLoaded.findIndex(e=>e===t);this._unloadTile(t,e,i)}else c.console.warn("Attempt to unload already unloaded tile.")}_unloadTile(e,t,i=void 0){c.console.assert(e,"[TileCache._unloadTile] tile is required");for(const n in e._caches)this.unloadCacheForTile(e,n,t,!1);void 0!==i&&this._tilesLoaded.splice(i,1);if(e.loaded){const r=e.tiledImage;e._unload();r.viewer.raiseEvent("tile-unloaded",{tile:e,tiledImage:r,destroyed:t})}}}}(OpenSeadragon);!function(v){v.World=function(e){const t=this;v.console.assert(e.viewer,"[World] options.viewer is required");v.EventSource.call(this);this.viewer=e.viewer;this._items=[];this._needsDraw=!1;this.__invalidatedAt=1;this._autoRefigureSizes=!0;this._needsSizesFigured=!1;this._delegatedFigureSizes=function(e){t._autoRefigureSizes?t._figureSizes():t._needsSizesFigured=!0};this._figureSizes()};v.extend(v.World.prototype,v.EventSource.prototype,{addItem:function(e,t){v.console.assert(e,"[World.addItem] item is required");v.console.assert(e instanceof v.TiledImage,"[World.addItem] only TiledImages supported at this time");if(void 0!==(t=t||{}).index){t=Math.max(0,Math.min(this._items.length,t.index));this._items.splice(t,0,e)}else this._items.push(e);this._autoRefigureSizes?this._figureSizes():this._needsSizesFigured=!0;this._needsDraw=!0;e.addHandler("bounds-change",this._delegatedFigureSizes);e.addHandler("clip-change",this._delegatedFigureSizes);this.raiseEvent("add-item",{item:e})},getItemAt:function(e){v.console.assert(void 0!==e,"[World.getItemAt] index is required");return this._items[e]},getIndexOfItem:function(e){v.console.assert(e,"[World.getIndexOfItem] item is required");return v.indexOf(this._items,e)},getItemCount:function(){return this._items.length},setItemIndex:function(e,t){v.console.assert(e,"[World.setItemIndex] item is required");v.console.assert(void 0!==t,"[World.setItemIndex] index is required");var i=this.getIndexOfItem(e);if(t>=this._items.length)throw new Error("Index bigger than number of layers.");this._items.splice(i,1);this._items.splice(t,0,e);this._needsDraw=!0;this.raiseEvent("item-index-change",{item:e,previousIndex:i,newIndex:t})},removeItem:function(e){v.console.assert(e,"[World.removeItem] item is required");var t=v.indexOf(this._items,e);if(-1!==t){e.removeHandler("bounds-change",this._delegatedFigureSizes);e.removeHandler("clip-change",this._delegatedFigureSizes);e.destroy();this._items.splice(t,1);this._figureSizes();this._needsDraw=!0;this._raiseRemoveItem(e)}},removeAll:function(){this.viewer._cancelPendingImages();let t;for(let e=0;e<this._items.length;e++){t=this._items[e];t.removeHandler("bounds-change",this._delegatedFigureSizes);t.removeHandler("clip-change",this._delegatedFigureSizes);t.destroy()}var i=this._items;this._items=[];this._figureSizes();this._needsDraw=!0;for(let e=0;e<i.length;e++){t=i[e];this._raiseRemoveItem(t)}},requestInvalidate:function(e=!0,t=v.now()){this.__invalidatedAt=t;let i=1/0;for(const c of this._items){c._lastDrawn.length&&(i=Math.min(i,c._lastDrawn[0].tile.lastTouchTime));for(const u of c._tilesToDraw)Array.isArray(u)?u.length&&(i=Math.min(i,u[0].tile.lastTouchTime)):u&&(i=Math.min(i,u.tile.lastTouchTime))}var n=this.viewer.tileCache.getLoadedTilesFor(null);const r=new Array(n.length);let o=0;let s=0;const a=this.viewer.tileCache;for(let e=0;e<n.length;e++){const d=n[e];var l=d.lastTouchTime>=i;var h=d.level<=(d.tiledImage.source.getClosestLevel()||0);if(l||h)r[o++]=d;else{a._unloadTile(d,!1,e-s);s++}}r.length=o;return this.requestTileInvalidateEvent(r,t,e)},requestTileInvalidateEvent:function(e,d,p=!0,g=!1,m=!1){if(!this.viewer.isOpen())return v.Promise.resolve();void 0===d&&(d=this.__invalidatedAt);const f=[];e=e.map(o=>{if(!o||!g&&!o.loaded&&!o.processing)return Promise.resolve();const t=o.tiledImage;const s=t.getDrawer();const e=s._parentViewer||this.viewer;const a=o.getCache(o.originalCacheKey);var i=o.getCache(o.originalCacheKey);if(i.__invStamp&&i.__invStamp>=d)return Promise.resolve();let l=!1;a.__finishProcessing&&a.__finishProcessing(!0);let n;a.__resolve||(n=new v.Promise(e=>{a.__resolve=e}));a.__finishProcessing=e=>{l=l||e;o.processing=!1;a.__finishProcessing=null;if(!e){a.__resolve(o);a.__resolve=null}};for(const r of a._tiles){r.processing=d;n&&(r.processingPromise=n)}a.__invStamp=d;a.__wasRestored=p;let h=null;const c=()=>{if(h){var e=o.buildDistinctMainCacheKey();t._tileCache.injectCache({tile:o,cache:h,targetKey:e,setAsMainCache:!0,tileAllowNotLoaded:o.loading})}else p&&t._tileCache.restoreTilesThatShareOriginalCache(o,o.getCache(o.originalCacheKey),!0)};const u=()=>l||"number"==typeof a.__invStamp&&a.__invStamp<this.__invalidatedAt||!o.loaded&&!o.loading;return e.raiseEventAwaiting("tile-invalidated",{tile:o,tiledImage:t,outdated:u,getData:t=>{if(h)return h.getDataAs(t,!1);var e=p?o.originalCacheKey:o.cacheKey;const i=o.getCache(e);if(!i){v.console.error("[Tile::getData] There is no cache available for tile with key %s",e);return v.Promise.reject()}t=t||i.type;h=(new v.CacheRecord).withTileReference(o);return i.getDataAs(t,!0).then(e=>{if(null==e)return v.Promise.reject(new Error("[World.getData] Working cache source data unavailable"));h.addTile(o,e,t);return h.data})},setData:(e,t)=>{if(h)return h.setDataAs(e,t);h=(new v.CacheRecord).withTileReference(o);h.addTile(o,e,t);return v.Promise.resolve()},resetData:()=>{if(h){h.destroy();h=null}},stopPropagation:()=>{return u()}}).catch(e=>{v.console.error("Update routine error:",e);if(h){try{h.destroy()}catch(e){}h=null}l=!0;a.__finishProcessing&&a.__finishProcessing(!0);return null}).then(e=>{if(this.viewer.isDestroyed()){a.__finishProcessing&&a.__finishProcessing(!0);return null}if(l)return null;if(a.__finishProcessing){if(!l&&(o.loaded||o.loading)){if(a.__invStamp<this.__invalidatedAt)f.push(o);else if(a.__invStamp===d){if(h)return h.prepareForRendering(s).then(e=>{if(l){h.destroy();h=null}else{if(!u()&&e)c();else{h.destroy();h=null}a.__finishProcessing()}});if(p){var t=o.getCache();const i=o.getCache(o.originalCacheKey);return t!==i?i.prepareForRendering(s).then(e=>{if(!l){!u()&&e&&c();a.__finishProcessing()}}):null}}else v.console.error("Invalidation flow error: tile processing state is invalid. "+`Tile: ${o?o.toString():"null"}, `+`loaded: ${o?o.loaded:"n/a"}, loading: ${o?o.loading:"n/a"}, `+`originalCache.__invStamp: ${a.__invStamp}, `+`this.__invalidatedAt: ${this.__invalidatedAt}, `+`tStamp: ${d}, wasOutdatedRun: `+l);if(m){const n=o.getCache();return n.prepareForRendering(s).then(()=>{!l&&a.__finishProcessing&&a.__finishProcessing()})}a.__finishProcessing();return null}l||a.__finishProcessing(!0)}if(m){const r=o.getCache();return r.prepareForRendering(s).then(()=>{!l&&a.__finishProcessing&&a.__finishProcessing()})}if(h){h.destroy();h=null}return null}).catch(e=>{v.console.error("Update routine error:",e);if(h){h.destroy();h=null}a.__finishProcessing()})});return v.Promise.all(e).then(()=>{f.length&&this.requestTileInvalidateEvent(f,void 0,p,!0);g||this.viewer.isDestroyed()||this.draw()})},ensureTilesUpToDate:function(e){let t;let i;for(var n of e){n=n.tile||n;if(n.loaded&&!n.processing){var r=n.getCache(n.originalCacheKey);i=r.__wasRestored;r.__invStamp<this.__invalidatedAt&&(t?t.push(n):t=[n])}}t&&t.length&&this.requestTileInvalidateEvent(t,v.now(),i,!1)},resetItems:function(){for(let e=0;e<this._items.length;e++)this._items[e].reset()},update:function(t){let i=!1;for(let e=0;e<this._items.length;e++)i=this._items[e].update(t)||i;return i},draw:function(){this.viewer.drawer.draw(this._items);this._needsDraw=!1;for(const e of this._items)this._needsDraw=e.setDrawn()||this._needsDraw},needsDraw:function(){for(let e=0;e<this._items.length;e++)if(this._items[e].needsDraw())return!0;return this._needsDraw},getHomeBounds:function(){return this._homeBounds.clone()},getContentFactor:function(){return this._contentFactor},setAutoRefigureSizes:function(e){if((this._autoRefigureSizes=e)&this._needsSizesFigured){this._figureSizes();this._needsSizesFigured=!1}},arrange:function(e){var t=(e=e||{}).immediately||!1;var i=e.layout||v.DEFAULT_SETTINGS.collectionLayout;var n=e.rows||v.DEFAULT_SETTINGS.collectionRows;var r=e.columns||v.DEFAULT_SETTINGS.collectionColumns;var o=e.tileSize||v.DEFAULT_SETTINGS.collectionTileSize;var s=o+(e.tileMargin||v.DEFAULT_SETTINGS.collectionTileMargin);let a;a=!e.rows&&r?r:Math.ceil(this._items.length/n);let l=0;let h=0;let c,u,d,p,g;this.setAutoRefigureSizes(!1);for(let e=0;e<this._items.length;e++){if(e&&e%a==0)if("horizontal"===i){h+=s;l=0}else{l+=s;h=0}c=this._items[e];u=c.getBoundsNoRotate();d=u.width>u.height?o:o*(u.width/u.height);p=d*(u.height/u.width);g=new v.Point(l+(o-d)/2,h+(o-p)/2);c.setPosition(g,t);c.setWidth(d,t);"horizontal"===i?l+=s:h+=s}this.setAutoRefigureSizes(!0)},_figureSizes:function(){var e=this._homeBounds?this._homeBounds.clone():null;var t=this._contentSize?this._contentSize.clone():null;var i=this._contentFactor||0;if(this._items.length){let t=this._items[0];var s=t.getBounds();this._contentFactor=t.getContentSize().x/s.width;var a=t.getClippedBounds().getBoundingBox();let i=a.x;let n=a.y;let r=a.x+a.width;let o=a.y+a.height;for(let e=1;e<this._items.length;e++){t=this._items[e];s=t.getBounds();this._contentFactor=Math.max(this._contentFactor,t.getContentSize().x/s.width);a=t.getClippedBounds().getBoundingBox();i=Math.min(i,a.x);n=Math.min(n,a.y);r=Math.max(r,a.x+a.width);o=Math.max(o,a.y+a.height)}this._homeBounds=new v.Rect(i,n,r-i,o-n);this._contentSize=new v.Point(this._homeBounds.width*this._contentFactor,this._homeBounds.height*this._contentFactor)}else{this._homeBounds=new v.Rect(0,0,1,1);this._contentSize=new v.Point(1,1);this._contentFactor=1}this._contentFactor===i&&this._homeBounds.equals(e)&&this._contentSize.equals(t)||this.raiseEvent("metrics-change",{})},_raiseRemoveItem:function(e){this.raiseEvent("remove-item",{item:e})}})}(OpenSeadragon);
//# sourceMappingURL=openseadragon.min.js.map